@g1cloud/bpmn-modeler-next 5.0.0-beta.10 → 5.0.0-beta.11
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:j,error:_}),!0;throw Er(j)}function u(_,E){return l(_,E,!0)}function p(){var _=a.elementsById,E=a.references,T,k;for(T=0;k=E[T];T++){var B=k.element,P=_[k.id],O=er(B).propertiesByName[k.property];if(P||a.addWarning({message:"unresolved reference <"+k.id+">",element:k.element,property:k.property,value:k.id}),O.isMany){var j=B.get(O.name),Q=j.indexOf(k);Q===-1&&(Q=j.length),P?j[Q]=P:j.splice(Q,1)}else B.set(O.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 R(_,E){var T=c.peek();try{c.push(T.handleNode(_))}catch(k){l(k,E,o)&&c.push(new pp)}}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(up).reduce(function(_,[E,T]){return _[T]=E,_},r.config&&r.config.nsMap||{}));return s.ns(v).on("openTag",function(_,E,T,k){var B=_.attrs||{},P=Object.keys(B).reduce(function(j,Q){var me=E(B[Q]);return j[Q]=me,j},{}),O={name:_.name,originalName:_.originalName,attributes:P,ns:_.ns};R(O,k)}).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(j){T=j}var k=i.element;!T&&!k&&(T=Er("failed to parse document as <"+i.type.$descriptor.name+">"));var B=a.warnings,P=a.references,O=a.elementsById;return T?(T.warnings=B,E(T)):_({rootElement:k,elementsById:O,references:P,warnings:B})})},hp.prototype.handler=function(e){return new dp(this.model,e)};function B1(){var e=[];return Object.defineProperty(e,"peek",{value:function(){return this[this.length-1]}}),e}var N1=`<?xml version="1.0" encoding="UTF-8"?>
|
|
5
5
|
`,$1=/<|>|'|"|&|\n\r|\n/g,gm=/<|>|&/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 F1(e){return e.charAt(0).toLowerCase()+e.slice(1)}function j1(e,t){return fm(t)?F1(e):e}function ym(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function vm(e){return Vn(e)?e:(e.prefix?e.prefix+":":"")+e.localName}function H1(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 z1(e,t){return t.isGeneric?W({localName:t.ns.localName},e):W({localName:j1(t.ns.localName,t.$pkg)},e)}function G1(e,t){return W({localName:t.ns.localName},e)}function V1(e){var t=e.$descriptor;return nt(t.properties,function(n){var i=n.name;if(n.isVirtual||!Wn(e,i))return!1;var r=e[i];return r===n.default||r===null?!1:n.isMany?r.length:!0})}var W1={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},U1={"<":"lt",">":"gt","&":"amp"};function bm(e,t,n){return e=Vn(e)?e:""+e,e.replace(t,function(i){return"&"+n[i]+";"})}function q1(e){return bm(e,$1,W1)}function Y1(e){return bm(e,gm,U1)}function K1(e){return nt(e,function(t){return t.isAttr})}function X1(e){return nt(e,function(t){return!t.isAttr})}function mp(e){this.tagName=e}mp.prototype.build=function(e){return this.element=e,this},mp.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?Y1(this.value):this.value)},so.prototype.build=function(e,t){return this.value=t,e.type==="String"&&t.search(gm)!==-1&&(this.escape=!0),this};function gp(e){this.tagName=e}ym(gp,so),gp.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"),this.serializeValue(e),e.append("</"+this.tagName+">").appendNewLine()};function Bt(e,t){this.body=[],this.attrs=[],this.parent=e,this.propertyDescriptor=t}Bt.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=V1(e),this.parseAttributes(K1(r)),this.parseContainments(X1(r))),this.parseGenericAttributes(e,i),this},Bt.prototype.nsTagName=function(e){var t=this.logNamespaceUsed(e.ns);return z1(t,e)},Bt.prototype.nsPropertyTagName=function(e){var t=this.logNamespaceUsed(e.ns);return G1(t,e)},Bt.prototype.isLocalNs=function(e){return e.uri===this.ns.uri},Bt.prototype.nsAttributeName=function(e){var t;if(Vn(e)?t=On(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}:W({localName:t.localName},n)},Bt.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}))},Bt.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 Bt(this).build(i))})},Bt.prototype.parseNsAttribute=function(e,t,n){var i=e.$model,r=On(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)}},Bt.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},Bt.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)}})},Bt.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(om(r.type))z(o,function(l){n.push(new gp(t.addTagName(t.nsPropertyTagName(r))).build(r,l))});else if(a)z(o,function(l){n.push(new mp(t.addTagName(t.nsPropertyTagName(r))).build(l))});else{var c=hm(r);z(o,function(l){var u;c?c===dm?u=new Bt(t,r):u=new sc(t,r,c):u=new Bt(t),n.push(u.build(l))})}})},Bt.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},Bt.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},Bt.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},Bt.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)})},Bt.prototype.addTagName=function(e){var t=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(t),vm(e)},Bt.prototype.addAttribute=function(e,t){var n=this.attrs;Vn(t)&&(t=q1(t));var i=Qh(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)},Bt.prototype.serializeAttributes=function(e){var t=this.attrs,n=this.namespaces;n&&(t=H1(n).concat(t)),z(t,function(i){e.append(" ").append(vm(i.name)).append('="').append(i.value).append('"')})},Bt.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 sc(e,t,n){Bt.call(this,e,t),this.serialization=n}ym(sc,Bt),sc.prototype.parseNsAttributes=function(e){var t=Bt.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},sc.prototype.isLocalNs=function(e){return e.uri===(this.typeNs||this.ns).uri};function Z1(){this.value="",this.write=function(e){this.value+=e}}function Q1(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 J1(e){e=W({format:!1,preamble:!0},e||{});function t(n,i){var r=i||new Z1,o=new Q1(r,e.format);e.preamble&&o.append(N1);var a=new Bt,s=n.$model;if(a.getNamespaces().mapDefaultPrefixes(eS(s)),a.build(n).serializeTo(o),!i)return r.value}return{toXML:t}}function eS(e){const t=e.config&&e.config.nsMap||{},n={};for(const i in up)n[i]=up[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 cc(e,t){pi.call(this,e,t)}cc.prototype=Object.create(pi.prototype),cc.prototype.fromXML=function(e,t,n){Vn(t)||(n=t,t="bpmn:Definitions");var i=new hp(W({model:this,lax:!0},n)),r=i.handler(t);return i.fromXML(e,r)},cc.prototype.toXML=function(e,t){var n=new J1(t);return new Promise(function(i,r){try{var o=n.toXML(e);return i({xml:o})}catch(a){return r(a)}})};var tS="BPMN20",nS="http://www.omg.org/spec/BPMN/20100524/MODEL",iS="bpmn",rS=[],oS=[{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"}]}],aS=[{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"}]}],sS={tagAlias:"lowerCase",typePrefix:"t"},cS={name:tS,uri:nS,prefix:iS,associations:rS,types:oS,enumerations:aS,xml:sS},lS="BPMNDI",uS="http://www.omg.org/spec/BPMN/20100524/DI",pS="bpmndi",fS=[{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"]}],dS=[{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"}]}],hS=[],mS={name:lS,uri:uS,prefix:pS,types:fS,enumerations:dS,associations:hS},gS="DC",yS="http://www.omg.org/spec/DD/20100524/DC",vS="dc",bS=[{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}]}],xS=[],_S={name:gS,uri:yS,prefix:vS,types:bS,associations:xS},wS="DI",ES="http://www.omg.org/spec/DD/20100524/DI",SS="di",RS=[{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"}]}],CS=[],AS={tagAlias:"lowerCase"},MS={name:wS,uri:ES,prefix:SS,types:RS,associations:CS,xml:AS},PS="bpmn.io colors for BPMN",TS="http://bpmn.io/schema/bpmn/biocolor/1.0",kS="bioc",OS=[{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"}]}],DS=[],LS=[],IS={name:PS,uri:TS,prefix:kS,types:OS,enumerations:DS,associations:LS},BS="BPMN in Color",NS="http://www.omg.org/spec/BPMN/non-normative/color/1.0",$S="color",FS=[{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"}]}],jS=[],HS=[],zS={name:BS,uri:NS,prefix:$S,types:FS,enumerations:jS,associations:HS};const GS={bpmn:cS,bpmndi:mS,dc:_S,di:MS,bioc:IS,color:zS};function xm(e,t){const n=W({},GS,e);return new cc(n,t)}const VS={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"}},lc={[em]:VS,[Wu]:Kh};function _m(){return xm(lc)}const wm=_m();async function Ho(e){const{rootElement:t,warnings:n}=await wm.fromXML(e,"bpmn:Definitions");return{definitions:t,warnings:n}}async function WS(e){const{xml:t}=await wm.toXML(e,{format:!0});return t}function yp(e){return e.map(t=>typeof t=="string"?t:t.message??String(t))}const zo={cjkEm:.865,upperEm:.68,lowerEm:.5,digitEm:.556,spaceEm:.278,otherEm:.35,ascentEm:.9,descentEm:.25},US=/[ᄀ-ᇿ -〿-ヿ㐀-鿿가--⦆]/;function qS(e){const t=zo;return US.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 Go(e,t){let n=0;for(const i of e)n+=t*qS(i);return n}function Em(e=globalThis,{textMeasurement:t="approximate"}={}){if(!(e!=null&&e.SVGElement))throw new Error("installHeadlessBpmnDom: DOM 전역이 없다 — jsdom window 를 전역에 올린 뒤 호출할 것");t==="approximate"&&YS(e),KS(e),XS(e),ZS(e)}function YS(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:Go(r,o),fontBoundingBoxAscent:o*zo.ascentEm,fontBoundingBoxDescent:o*zo.descentEm,actualBoundingBoxAscent:o*zo.ascentEm,actualBoundingBoxDescent:o*zo.descentEm}}};t.getContext=()=>n}function KS(e){if(e.SVGMatrix)return;class t{constructor(){ui(this,"a",1);ui(this,"b",0);ui(this,"c",0);ui(this,"d",1);ui(this,"e",0);ui(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 XS(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 ZS(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:Go(n,12),height:14}})}const uc=new Set(["bpmn:Participant","bpmn:Lane","bpmn:Group","bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),QS=new Set(["bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),JS=1,pc=new Set(["bpmn:TextAnnotation","bpmn:DataStoreReference","bpmn:DataObjectReference","bpmn:DataInput","bpmn:DataOutput"]),eR=2;function ut(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 Sm=20,fc=5,Rm=3,tR=8,Vo=15,vp=50,Cm=12,nR=Cm*1.2;function bp(e,t){const n=t.split(/\r?\n/),i=Math.max(...n.map(o=>Go(o,Cm))),r=n.length*nR;return{x:e.x+e.width/2-i/2,y:e.y+e.height/2-r/2,width:i,height:r}}const Am=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 Wo(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)>Am)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>=Sm&&(!n||l>n.length)&&(n={axis:a.axis,length:l,kind:c})}return n}function xp(e){return e.kind==="edge-overlap-opposite"||e.kind==="edge-overlap-mixed"||e.kind==="edge-overlap-unrelated"}function Mm(e,t){const n=Wo(e,t);return n&&n.kind==="opposite"?{axis:n.axis,length:n.length}:null}function iR(e,t){let n=0;for(const i of t)i.id!==e.id&&Mm(e,i)&&n++;return n}function ri(e,t){let n=0;for(const i of t)i.id!==e.id&&Wo(e,i)&&n++;return n}const Pm=15,Tm=20;function rR(e,t){const n=t.axis==="v"?[e.x,e.x+e.width]:[e.y,e.y+e.height];if(t.at<n[0]-Tm||t.at>n[1]+Tm)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 _p=20;function dc(e,t){const n=[];for(const i of t){if(i.axis!==e.axis||Math.abs(i.at-e.at)>Am)continue;const r=Math.max(e.lo,i.lo),o=Math.min(e.hi,i.hi);o-r<Sm||n.push([r-_p,o+_p])}return n}function hc(e,t){const n=e.label;if(!n)return null;let i=null;for(const r of gn(e)){const o=rR(n,r);if(o){for(const a of t)if(a.id!==e.id&&!(i&&a.id>=i.other)){for(const[s,c]of dc(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 oR=10,aR=1,sR=(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 cR(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 wp(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 lR=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Uo=1;function Fi(e,t){const n=e.x+Uo,i=e.x+e.width-Uo,r=e.y+Uo,o=e.y+e.height-Uo;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 qo(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 km(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(qo(i).some(r=>Fi(n,r)))return i.id;return null}function En(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(cR(e.waypoints[o],e.waypoints[o+1],r,eR)){i.push(r);break}}return i}const $a=(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))},uR=(e,t,n,i)=>Dm(e,t,n,i)?0:Math.min($a(e,n,i),$a(t,n,i),$a(n,e,t),$a(i,e,t)),Om=(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 mc(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,$a({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(Om(e,s)||Om(t,s))return 0;let c=1/0;for(let l=0;l<s.length;l++)c=Math.min(c,uR(e,t,s[l],s[(l+1)%s.length]));return c}function Dm(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 Lm=(e,t)=>e.endpoints.some(n=>t.endpoints.includes(n));function Fa(e,t){let n=0;for(const i of t){if(i.id===e.id||Lm(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++)Dm(e.waypoints[o],e.waypoints[o+1],i.waypoints[a],i.waypoints[a+1])&&(r=!0);r&&n++}return n}function oi(e,t){let n=0;for(const i of t)i.id===e.id||Lm(e,i)||Fa(e,[i])>0&&(n+=i.type===e.type?2:1);return n}function Im(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++)Fa(n[i],[n[r]])>0&&(t+=n[i].type===n[r].type?2:1);return t}function gc(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)if(Fa(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 Bm(e){const t=gc(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:pR(e)}}function pR(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 Nm(e,t,n){const i=new Set(t.flatMap(r=>[...r.members]));return e.shapes.filter(r=>!r.container&&!pc.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 $m(e){var n;const t=(n=Dt(e==null?void 0:e.extensionElements))==null?void 0:n.values;if(Array.isArray(t))for(const i of t){const r=Dt(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 Fm=e=>e?{members:e}:{},ai=e=>e.shapes.filter(t=>!t.container);function fR(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 dR(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 jm(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(qo(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 Hm=3;function zm(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 ja(e,t){const n=[];for(const i of t.shapes){if(i.container||pc.has(i.type))continue;const r=zm(e,i);r>=Hm&&n.push({shape:i.id,depth:r})}return n.sort((i,r)=>i.shape.localeCompare(r.shape))}function ht(e,t={}){const n=[],i=e.shapes.filter(m=>!m.container);for(const m of e.edges)for(const v of En(m,i))n.push({kind:"edge-crosses-shape",edge:m.id,shape:v.id});const r=e.shapes.filter(m=>m.container&&QS.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 En(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(O=>O.id===_);if(!T||T.container)continue;const k=Math.max(T.x-E.x,E.x-(T.x+T.width),0),B=Math.max(T.y-E.y,E.y-(T.y+T.height),0),P=Math.hypot(k,B);P>oR&&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=(k,B)=>k.x<=B.x&&k.y<=B.y&&k.x+k.width>=B.x+B.width&&k.y+k.height>=B.y+B.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(!wp(_,E,JS))continue;const T=_.id<E.id?[_.id,E.id]:[E.id,_.id];n.push({kind:"shape-overlap",shapes:T,identical:lR(_,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),k=Math.min(_.y+_.height,E.y+E.height)-Math.max(_.y,E.y);if(T<=fc||k<=fc)continue;const B=_.id<E.id?[_.id,E.id]:[E.id,_.id],P=new Set(E.members);if(_.members.some(j=>P.has(j))){const j=Nm(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)});j.length&&n.push({kind:"group-overlap-unreadable",reason:"orphan",groups:B,shapes:j});continue}const O=_.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:B,...O?{container:O}:{}})}const c=new Set(s.flatMap(m=>[...m.members])),l=m=>e.shapes.filter(v=>!v.container&&!pc.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,k=!1,B=!1;for(const P of e.edges){if(P.type!=="bpmn:SequenceFlow"||!P.source||!P.target)continue;const O=E.has(P.source),j=E.has(P.target);!O&&j&&!v.has(P.source)?T=!0:O&&!j&&!v.has(P.target)?k=!0:O&&j&&(B=!0)}T&&k&&B&&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<=fc||T.bottom-T.y<=fc)continue;const k=Nm(e,[],T);if(!k.length)continue;const B=E.map(P=>P.id).sort();n.push({kind:"group-stack-unreadable",groups:B,shapes:k})}for(const m of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of e.shapes){if(v.container||v.attached||pc.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,k,B,P]of _){const O=k==="h"?v.x:v.y,j=k==="h"?v.x+v.width:v.y+v.height;if(!(O<P&&B<j))continue;const Q=k==="h"?v.y:v.x,me=k==="h"?v.y+v.height:v.x+v.width;if(!(Q<T&&T<me))continue;const Pe=Math.min(T-Q,me-T);Pe<tR||n.push({kind:"group-cuts-shape",group:m.id,shape:v.id,side:E,depth:Pe})}}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,k=E.y+E.height,B=v.endpoints.some(O=>{const j=m.get(O);return!!j&&E.x<j.x&&j.x<T&&E.y<j.y&&j.y<k});let P=null;for(const O of _){const[j,Q,me]=O.axis==="v"?[E.y,k,[["left",E.x],["right",T]]]:[E.x,T,[["top",E.y],["bottom",k]]],Pe=Math.min(O.hi,Q)-Math.max(O.lo,j);if(Pe<vp)continue;const De=O.axis==="v"?E.x<O.at&&O.at<T:E.y<O.at&&O.at<k;if(!(De&&B))for(const[Ke,rt]of me){const Ae=Math.abs(O.at-rt);Ae<=Vo&&(!P||Ae<P.distance)&&(P={side:Ke,inside:De,distance:Ae,length:Pe})}}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[k,B,P,O]of T)O&&Math.abs(B-P)<=Rm&&n.push({kind:"group-on-container-boundary",group:m.id,container:v.id,side:k})}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,k=_.y<E.y+E.height&&E.y<_.y+_.height,B=[["x",_.x+_.width,E.x,k],["x",E.x+E.width,_.x,k],["y",_.y+_.height,E.y,T],["y",E.y+E.height,_.y,T]];for(const[P,O,j,Q]of B)if(Q&&Math.abs(O-j)<=Rm){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=Wo(_,E);if(!T)continue;const k=_.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:k,axis:T.axis,length:Math.round(T.length)})}for(const m of e.edges){if(!m.label)continue;const v=hc(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=km(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 ja(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=jm(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)||wp(m.label,_,Uo)&&n.push({kind:"pool-name-over-label",pool:m.id,label:v});const R=co(e);for(const m of i)if(m.type==="bpmn:TextAnnotation")for(const{owner:v,rect:_}of R)v!==m.id&&wp(m,_,Uo)&&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??fR(m,e,x);if(!v)continue;const _=x.get(v);!_||!_.container||sR(_,m,aR)||m.type==="bpmn:TextAnnotation"&&!dR(m,_,e)||n.push({kind:"shape-outside-container",shape:m.id,container:_.id})}return n.sort((m,v)=>ut(m).localeCompare(ut(v)))}const Dt=e=>typeof e=="object"&&e!==null?e:void 0,Ut=e=>typeof e=="number"?e:0,tr=e=>{const t=Dt(e);return typeof(t==null?void 0:t.id)=="string"?t.id:void 0};function hR(e){const t=Dt(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 mR(e){const t=Dt(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 gR(e,t){const n=Dt(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(uc.has(i)&&i!=="bpmn:Lane"&&i!=="bpmn:Group")return tr(n)}function Gm(e){var a,s,c,l,u;const t=[],n=[],i=((a=Dt(e))==null?void 0:a.diagrams)??[],r=new Map,o=new Set;for(const p of((s=Dt(e))==null?void 0:s.rootElements)??[]){const f=Dt(p);if((f==null?void 0:f.$type)==="bpmn:Collaboration")for(const d of f.participants??[]){const g=Dt(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=Dt((c=Dt(p))==null?void 0:c.plane),d=(f==null?void 0:f.planeElement)??[];for(const g of d){const h=Dt(g);if(!h)continue;const y=Dt(h.bpmnElement),R=typeof(y==null?void 0:y.id)=="string"?y.id:void 0;if(!R)continue;const x=typeof(y==null?void 0:y.$type)=="string"?y.$type:"",m=Dt(h.bounds);if(m){const _=h.isExpanded===!1&&x!=="bpmn:Participant",E=Dt((l=Dt(h.label))==null?void 0:l.bounds),T={id:R,type:x,x:Ut(m.x),y:Ut(m.y),width:Ut(m.width),height:Ut(m.height),container:uc.has(x)&&!_,attached:(y==null?void 0:y.attachedToRef)!==void 0,...y?{parent:gR(y,r)}:{},...E?{label:{x:Ut(E.x),y:Ut(E.y),width:Ut(E.width),height:Ut(E.height)}}:{},...x==="bpmn:Group"?Fm($m(y)):{}},k=h.isHorizontal!==!1,B=typeof(y==null?void 0:y.name)=="string"?y.name:"";o.has(R)&&k&&B&&(T.label=bp(T,B)),t.push(T);continue}const v=h.waypoint;if(Array.isArray(v)){const _=Dt((u=Dt(h.label))==null?void 0:u.bounds);n.push({id:R,type:x,waypoints:v.map(E=>{var T,k;return{x:Ut((T=Dt(E))==null?void 0:T.x),y:Ut((k=Dt(E))==null?void 0:k.y)}}),endpoints:hR(y),...mR(y),..._?{label:{x:Ut(_.x),y:Ut(_.y),width:Ut(_.width),height:Ut(_.height)}}:{}})}}}return{shapes:t,edges:n}}function Vm(e){return ht(Gm(e),{includeObservationOnly:!0})}async function yR(e){const{definitions:t,warnings:n}=await Ho(e);return{findings:Vm(t),warnings:n}}function Xe(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=Dt(o.label),y=tr(o.source),R=tr(o.target);n.push({id:o.id,type:a,waypoints:s.map(x=>({x:Ut(x.x),y:Ut(x.y)})),endpoints:[y,R].filter(x=>!!x),...y&&R?{source:y,target:R}:{},...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=Dt(o.businessObject),l=Dt(o.label);let u=Dt(o.parent);for(;u&&u.type==="bpmn:Lane";)u=Dt(u.parent);const p=typeof(u==null?void 0:u.type)=="string"?u.type:"",f=u&&uc.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:uc.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"?Fm($m(c)):{}},g=typeof(c==null?void 0:c.name)=="string"?c.name:"";a==="bpmn:Participant"&&!(c!=null&&c.processRef)&&g&&((i=Dt(o.di))==null?void 0:i.isHorizontal)!==!1&&(d.label=bp(d,g)),t.push(d)}return{shapes:t,edges:n}}const vR={"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 bR(e,t){const n=vR[e];return n||(e==="label"||e.startsWith("bpmndi:")?"other":e.startsWith("bpmn:")&&!("waypoints"in t&&t.waypoints)?"flowNode":"other")}function Wm(e){let t=e.parent;for(;t;){if(t.type==="bpmn:Participant")return t.id;t=t.parent}}function Um(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 bR(i.type,i)},lanesOf:n=>t().filter(i=>i.type==="bpmn:Lane"&&Wm(i)===n).sort((i,r)=>i.y-r.y).map(i=>i.id),participantOf:n=>{const i=e.get(n);return i?Wm(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 Vu(r)},reviewRequestLocalesOf:n=>{const i=e.get(n);return!i||i.type==="label"?[]:xr(i.businessObject).map(r=>r.locale)}}}const Ep=20,xR=4,kt=(e,t)=>Math.abs(e-t)<.5;function yc(e,t,n,i=Ep){if(kt(e.y,t.y)&&!kt(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(kt(e.x,t.x)&&!kt(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 qm(e,t,n,i=Ep){if(n.length<2)return null;if(kt(e.y,t.y)&&!kt(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(kt(e.x,t.x)&&!kt(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 Ym(e,t,n=Ep){if(e.length!==4)return null;const[i,r,o,a]=e;if(kt(i.y,r.y)&&kt(r.x,o.x)&&kt(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(kt(i.x,r.x)&&kt(r.y,o.y)&&kt(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 vc(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 Km=30,_R=[0,-25,25,-40,40];function wR(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+Km:s-Km,l=a?i.y+i.height:i.y,u=n.x+n.width/2,p=i.x+i.width/2;return _R.map(f=>[{x:u,y:s},{x:u,y:c},{x:p+f,y:c},{x:p+f,y:l}])}const Sp=(e,t,n)=>[...e.slice(0,t+1),...n,...e.slice(t+1)],Yo=(e,t,n)=>En({...e,waypoints:t},n).length;function Rp(e,t,n,i){let r=[...e.waypoints],o=Yo(e,r,t);if(o===0)return null;let a=!1;for(const p of vc(e,t))if(Yo(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=>dc(f,s).length>0),l=wR(e,t).filter(p=>Yo(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&&kt(p.y+p.height/2,f.y+f.height/2)){const d=[r[0],r[r.length-1]];if(kt(d[0].y,d[1].y)&&!kt(d[0].x,d[1].x)){const g=t.filter(x=>!e.endpoints.includes(x.id)&&En({...e,waypoints:d},[x]).length>0),h=g.length>=2?qm(d[0],d[1],g):null,R=(h?h.map(x=>[d[0],...x,d[1]]):g.length===1?(yc(d[0],d[1],g[0])??[]).map(x=>[d[0],...x,d[1]]):g.length===0?[d]:[]).filter(x=>Yo(e,x,t)===0&&x.length<=r.length).sort((x,m)=>Number(u(m))-Number(u(x)));if(R.length)return R.find(x=>!c(x))??R[0]}}}for(let p=0;p+1<r.length;p++){const f=r[p],d=r[p+1],g=t.filter(R=>!e.endpoints.includes(R.id)&&En({...e,waypoints:[f,d]},[R]).length>0);if(g.length<2)continue;const h=qm(f,d,g);if(!h)continue;const y=h.map(R=>Sp(r,p,R)).filter(R=>Yo(e,R,t)===0).sort((R,x)=>Number(u(x))-Number(u(R)));if(y.length)return y.find(R=>!c(R))??y[0]}for(let p=0;p<xR&&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)||En({...e,waypoints:[g,h]},[y]).length===0)continue;const R=yc(g,h,y),x=R?R.map(v=>Sp(r,d,v)):Ym(r,y)??[];if(!x.length)continue;const m=[...x].sort((v,_)=>Number(u(_))-Number(u(v)));for(const v of m){const _=Yo(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 Cp(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=ai(o),s=new Set,c=ht(o).filter(u=>u.kind==="edge-crosses-shape"&&!t.has(ut(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=Rp(p,a,g,o.edges);if(!h){En(p,a).some(m=>m.type==="bpmn:TextAnnotation")&&s.add(u);continue}const y=o.edges.filter(m=>m.id!==u),R=ri(p,y);ri({...p,waypoints:h},y)>R||r.updateWaypoints(f,h)}return s}const ER=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},Ap=(e,t)=>Fa(e,[t])>0;function Xm(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=ai(o);let s=o;const c=new Set(ht(o).map(ut));for(const[l,u]of gc(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(B=>B.id===p),g=s.edges.find(B=>B.id===f);if(!d||!g)continue;const h=i.get(p);if(!h)continue;const y=h.parent,R=y&&typeof y.x=="number"&&typeof y.width=="number"?{x:y.x,y:y.y,width:y.width,height:y.height}:void 0,x=ER(g),m=[...vc(d,a)??[]],v=Rp(d,[...a,...x],R,o.edges);v&&m.push(v);for(let B=0;B+1<d.waypoints.length;B++)for(const P of x)for(const O of yc(d.waypoints[B],d.waypoints[B+1],P)??[])m.push(Sp(d.waypoints,B,O));const _=s.edges.filter(B=>B.id!==p),E=B=>({...s,edges:s.edges.map(P=>P.id===p?{...P,waypoints:B}:P)}),T=B=>!R||B.every(P=>P.x>=R.x&&P.x<=R.x+R.width&&P.y>=R.y&&P.y<=R.y+R.height),k=m.find(B=>{const P={...d,waypoints:B};return Ap(P,g)||!T(B)||_.some(O=>O.id!==f&&!Ap(d,O)&&Ap(P,O))?!1:ht(E(B)).every(O=>c.has(ut(O)))});if(k){r.updateWaypoints(h,k),s=E(k);break}}}const SR=10;function Zm(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 Qm(e,t){if(e.waypoints.length<2||e.endpoints.length!==2)return null;const n=t.shapes.filter(j=>j.type==="bpmn:Participant"&&j.container),i=t.shapes.find(j=>j.id===e.endpoints[0]),r=t.shapes.find(j=>j.id===e.endpoints[1]);if(!i||!r)return null;const o=Zm(i,n),a=Zm(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(j=>j.id!==o.id&&j.id!==a.id&&j.y>=c.y+c.height&&j.y+j.height<=l.y).sort((j,Q)=>j.y-Q.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,R=e.waypoints[0],x=e.waypoints[e.waypoints.length-1],m=ai(t),v=t.edges.filter(j=>j.id!==e.id),_=oi(e,v),E=En(e,m).length;if(_===0&&E===0||E===0&&e.waypoints.length===2)return null;const T=Math.min(...u.map(j=>j.x)),k=Math.max(...u.map(j=>j.x+j.width)),B=(R.x+x.x)/2,P=j=>j.filter((Q,me)=>me===0||!(kt(Q.x,j[me-1].x)&&kt(Q.y,j[me-1].y)));let O;for(let j=T;j<=k;j+=SR){const Q=P([R,{x:R.x,y:h},{x:j,y:h},{x:j,y},{x:x.x,y},x]),me={...e,waypoints:Q};if(En(me,m).length>0)continue;const Pe=oi(me,v),De=Math.abs(j-B);(!O||Pe<O.cross||Pe===O.cross&&De<O.detour)&&(O={pts:Q,cross:Pe,detour:De})}return O&&(E>0?O.cross<=_:O.cross<_)?O.pts:null}function Jm(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Xe(n);for(const o of r.edges){if(o.type!=="bpmn:MessageFlow"||t.has(o.id))continue;const a=Xe(n),s=a.edges.find(u=>u.id===o.id);if(!s)continue;const c=Qm(s,a);if(!c)continue;const l=n.get(o.id);l&&i.updateWaypoints(l,c)}}const ji=[25,-25,40,-40],Ko=35;function RR(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)-Ko:Math.max(e.y+e.height,t.y+t.height)+Ko;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 bc(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 RR(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-Ko:n.y+n.height+Ko,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,R=s?i.y+i.height+Ko:i.y-Ko;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:R},{x:m,y:R},{x:m,y}],cost:h+Math.abs(x)+Math.abs(v)})}}return p}const xc=30;function eg(e,t){for(let n=1;n<e.length-2;n++){const i=e[n],r=e[n+1],o=kt(i.y,r.y)&&!kt(i.x,r.x),a=kt(i.x,r.x)&&!kt(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)<xc||Math.abs(i.y-(s.y+s.height))<xc)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)<xc||Math.abs(i.x-(s.x+s.width))<xc)return!0}}return!1}const _c=40;function CR(e,t,n){let i=0;for(const r of t){if(r.container||n.includes(r.id))continue;const o=r.x-_c,a=r.x+r.width+_c,s=r.y-_c,c=r.y+r.height+_c;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 tg(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=ai(t),o=t.edges.filter(E=>E.id!==e.id),a=ri(e,o),s=oi(e,o),c=E=>CR(E,t.shapes,e.endpoints)+(eg(E,n)?1:0),l=c(e.waypoints),u=E=>{if(!E)return;const T=E.x+E.width/2,k=E.y+E.height/2;return n.find(B=>B.type==="bpmn:Lane"&&T>=B.x&&T<=B.x+B.width&&k>=B.y&&k<=B.y+B.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 k=E[T],B=E[T+1];if(kt(k.y,B.y)&&!kt(k.x,B.x)&&k.y>f.y&&k.y<f.y+f.height)return!0}return!1},h=g(e.waypoints),R=(E=>{if(!E)return;const T=E.x+E.width/2,k=E.y+E.height/2;return n.filter(B=>B.type==="bpmn:Participant"&&T>=B.x&&T<=B.x+B.width&&k>=B.y&&k<=B.y+B.height).sort((B,P)=>B.width*B.height-P.width*P.height)[0]})(i.get(e.endpoints[0]??"")),x=E=>{if(!R)return 0;let T=0;for(let k=1;k<E.length-1;k++){const B=E[k];(B.x<R.x||B.x>R.x+R.width||B.y<R.y||B.y>R.y+R.height)&&T++}return T},m=x(e.waypoints);if(!eg(e.waypoints,n)&&!(d&&!h)&&m===0)return null;const v=E=>E.reduce((T,k,B)=>B?T+Math.abs(k.x-E[B-1].x)+Math.abs(k.y-E[B-1].y):0,0);let _;for(const{pts:E,cost:T}of bc(e,i)){const k={...e,waypoints:E};if(En(k,r).length>0)continue;const B=ri(k,o);if(B>a)continue;const P=x(E);if(P>m)continue;const O=P<m&&B===0;if(!O&&oi(k,o)>s)continue;const j=c(E),Q=g(E);if(!O&&!(Q&&!h)&&j>=l)continue;const Pe=Q?0:1,De=v(E);(!_||P<_.out||P===_.out&&(Pe<_.lane||Pe===_.lane&&(B<_.opp||B===_.opp&&(j<_.sc||j===_.sc&&(T<_.cost||T===_.cost&&De<_.len)))))&&(_={pts:E,out:P,sc:j,lane:Pe,opp:B,cost:T,len:De})}return(_==null?void 0:_.pts)??null}function AR(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 MR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(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=Xe(i),c=s.edges.find(y=>y.id===a);if(!c||c.waypoints.length<4)continue;const l=ai(s),u=s.edges.filter(y=>y.id!==a),p=En(c,l).length,f=ri(c,u),d=oi(c,u),g=n.has(a)?new Set(ht(s).map(ut)):null,h=vc(c,s.shapes);h.length===2&&AR(c,s)&&h.reverse();for(const y of h){if(y.length>=c.waypoints.length)continue;const R={...c,waypoints:y};if(En(R,l).length>p||ri(R,u)>f||oi(R,u)>d)continue;if(g){const m=new Set(ht({...s,edges:s.edges.map(E=>E.id===a?R:E)}).map(ut)),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 ng(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Xe(n).edges.filter(o=>o.type==="bpmn:SequenceFlow"&&!t.has(o.id)).map(o=>o.id).sort();for(const o of r){const a=Xe(n),s=a.edges.find(u=>u.id===o);if(!s)continue;const c=tg(s,a);if(!c)continue;const l=n.get(o);l&&i.updateWaypoints(l,c)}}function Mp(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=kt(n[0].x,n[1].x)&&!kt(n[0].y,n[1].y),s=kt(n[n.length-1].x,n[n.length-2].x)&&!kt(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 PR(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 R of[0,...ji])Math.abs(R)<i.width/2-5&&y.push({pts:[{x:f,y:l},{x:u+R,y:l},{x:u+R,y:h}],cost:Math.abs(R)}),Math.abs(R)<i.height/2-5&&y.push({pts:[{x:c,y:d},{x:c,y:p+R},{x:g,y:p+R}],cost:Math.abs(R)});return y}function Pp(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 ig(e,t){const n=new Map(t.shapes.map(d=>[d.id,d])),i=ai(t),r=t.edges.filter(d=>d.id!==e.id),o=ri(e,r);if(o===0)return null;const a=oi(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=[...bc(e,n),...Pp(e,n),...Mp(e,n)];for(const{pts:d,cost:g}of f){const h={...e,waypoints:d};if(En(h,i).length>0)continue;const y=ri(h,r),R=oi(h,r),x=o-y+(p-u(d));if(y>=o||R-a>x)continue;const m=c(d);(!s||y<s.opposite||y===s.opposite&&(R<s.cross||R===s.cross&&(g<s.cost||g===s.cost&&m<s.len)))&&(s={pts:d,opposite:y,cross:R,cost:g,len:m})}return(s==null?void 0:s.pts)??null}function rg(e,t){var i;let n=0;for(const r of t)r.id!==e.id&&((i=Wo(e,r))==null?void 0:i.kind)==="unrelated"&&n++;return n}function TR(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=ai(t),r=t.edges.filter(f=>f.id!==e.id),o=rg(e,r);if(o===0)return null;const a=ri(e,r),s=oi(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=[...bc(e,n),...Pp(e,n),...PR(e,n),...Mp(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(En(g,i).length>0)continue;const h=rg(g,r);if(h>=o)continue;const y=ri(g,r);if(y-h>a-o)continue;const R=oi(g,r);if(R-s>(o-h)*l)continue;const x=c(f);(!u||h<u.fake||h===u.fake&&(y<u.unreadable||y===u.unreadable&&(R<u.cross||R===u.cross&&(d<u.cost||d===u.cost&&x<u.length))))&&(u={pts:f,fake:h,unreadable:y,cross:R,cost:d,length:x})}return(u==null?void 0:u.pts)??null}function og(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=ht(Xe(i)).filter(s=>s.kind==="edge-overlap-unrelated"&&!t.has(ut(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=Xe(i),l=c.edges.find(f=>f.id===s);if(!l)continue;const u=TR(l,c);if(!u)continue;const p=i.get(s);p&&r.updateWaypoints(p,u)}}function ag(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 sg(e,t,n){var l;if(e.type!=="bpmn:SequenceFlow"||t.type!=="bpmn:SequenceFlow"||((l=Wo(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:ag(e,n)&&ag(t,n)}function cg(e,t,n){let i=0;for(const r of t)r.id!==e.id&&sg(e,r,n)&&i++;return i}function kR(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=ai(t),r=t.edges.filter(f=>f.id!==e.id),o=cg(e,r,n);if(o===0)return null;const a=ri(e,r),s=oi(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=[...bc(e,n),...Pp(e,n),...Mp(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(En(g,i).length>0)continue;const h=cg(g,r,n);if(h>=o)continue;const y=ri(g,r);if(y-h>a-o)continue;const R=oi(g,r);if(R-s>(o-h)*l)continue;const x=c(f);(!u||h<u.chain||h===u.chain&&(y<u.unreadable||y===u.unreadable&&(R<u.cross||R===u.cross&&(d<u.cost||d===u.cost&&x<u.length))))&&(u={pts:f,chain:h,unreadable:y,cross:R,cost:d,length:x})}return(u==null?void 0:u.pts)??null}function OR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=new Map(o.shapes.map(l=>[l.id,l])),s=ht(o).filter(l=>l.kind==="edge-overlap-opposite"&&!t.has(ut(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||!sg(u,p,a)))for(const f of l.edges)n.has(f)||c.add(f)}for(const l of[...c].sort()){const u=Xe(i),p=u.edges.find(g=>g.id===l);if(!p)continue;const f=kR(p,u);if(!f)continue;const d=i.get(l);d&&r.updateWaypoints(d,f)}}function lg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=ht(o).filter(u=>xp(u)&&!t.has(ut(u)));if(!a.length)return;const s=new Set;for(const u of a)if(xp(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=Xe(i),f=p.edges.find(h=>h.id===u);if(!f)continue;const d=ig(f,p);if(!d)continue;const g=i.get(u);g&&r.updateWaypoints(g,d)}}const DR=10,LR=(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 ug(e,t){const n=e.label;if(!n)return null;const i=t.edges.filter(a=>a.id!==e.id);if(!hc(e,i))return null;const r=ai(t),o=i.flatMap(gn);for(const a of gn(e)){let s=[[a.lo,a.hi]];for(const[d,g]of dc(a,o))s=s.flatMap(([h,y])=>{const R=[];return d>h&&R.push([h,Math.min(y,d)]),g<y&&R.push([Math.max(h,g),y]),R.filter(([x,m])=>m>x)});const c=a.axis==="h"?n.width:n.height,l=s.find(([d,g])=>g-d>=c+DR*2);if(!l)continue;const u=(l[0]+l[1])/2,p=a.axis==="h"?{x:u,y:a.at-Pm}:{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(!hc({...e,label:f},i)&&!r.some(d=>!e.endpoints.includes(d.id)&&LR(f,d)))return f}return null}const Sn=8;function Tp(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(qo)],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 pg=30,IR=(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},fg=(e,t)=>IR({x:e.x+e.width/2,y:e.y+e.height/2},t);function BR(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(qo)],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))&&!ja(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 dg(e,t){var a,s;const{elementRegistry:n}=e,i=e.modeling;let r=Xe(n),o=new Set(ht(r).map(ut));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(O=>O.id===c);if(!(E!=null&&E.label)||!ja(E.label,r).length)continue;let T={...E.label,x:l.label.x,y:l.label.y};if((ja(T,r).length||fg(T,E.waypoints)>pg)&&(T=null),!T&&fg(E.label,E.waypoints)>pg&&(T=BR(E,r)),!T)continue;const k=T,B={...r,edges:r.edges.map(O=>O.id===c?{...O,label:k}:O)},P=ht(B);if(P.some(O=>!o.has(ut(O))))continue;i.moveElements([f],{x:k.x-f.x,y:k.y-f.y}),r=B,o=new Set(P.map(ut));continue}const y=l.label.x+d-f.x,R=l.label.y+g-f.y;if(y===0&&R===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+R},v={...r,edges:r.edges.map(E=>E.id===c?{...E,label:m}:E)},_=ht(v);_.some(E=>!o.has(ut(E)))||(i.moveElements([f],{x:y,y:R}),r=v,o=new Set(_.map(ut)))}}function hg(e,t,n=new Set){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i);for(const a of o.edges){if(!a.label||t.has(a.id)&&!n.has(a.id))continue;const s=Tp(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 mg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=ht(o).filter(s=>s.kind==="label-on-shared-segment"&&!t.has(ut(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=ug(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 gg(e,t){const n=e.label;if(!n)return null;const i=[...t.edges.flatMap(gn),...t.shapes.filter(f=>f.container).flatMap(qo)],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 yg(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Xe(n);for(const o of r.shapes){if(o.container||!o.label||t.has(o.id))continue;const a=gg(o,Xe(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 NR(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 vg(e,t){const{elementRegistry:n}=e,i=e.modeling;let r=Xe(n),o=new Set(ht(r).map(ut));const a=[...new Set(ht(r).filter(s=>s.kind==="edge-endpoint-detached"&&!t.has(ut(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 R=h?r.shapes.find(m=>m.id===h):void 0;if(!R)continue;const x=NR(R,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=ht(f);if(d.some(h=>!o.has(ut(h))))continue;const g=n.get(s);g&&(i.updateWaypoints(g,l),r=f,o=new Set(d.map(ut)))}}const kp=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function bg(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 $R(e,t,n){const i=[],r=n?La(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 bg(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(!kp(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 fi(e,t,n){const i=t==="text"?"texts":"names",{[i]:r,...o}=e;return n===void 0?o:{...o,[t]:n}}function FR(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(kp(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=bg(c,t);if(!l.length){s.push(c);continue}switch(c.kind){case"participant.add":{const[u,...p]=l,f=fi(c.participant,"name",a(u));c.participant.lanes&&(f.lanes=c.participant.lanes.map((d,g)=>fi(d,"name",a(p[g])))),s.push({...c,participant:f});break}case"participant.update":{const[u,...p]=l,f=fi(c,"name",a(u));c.lanes&&(f.lanes=c.lanes.map((d,g)=>fi(d,"name",a(p[g])))),s.push(f);break}case"node.add":s.push({...c,node:fi(c.node,"name",a(l[0]))});break;case"sequenceFlow.add":s.push({...c,flow:fi(c.flow,"name",a(l[0]))});break;case"messageFlow.add":s.push({...c,flow:fi(c.flow,"name",a(l[0]))});break;case"dataStore.add":s.push({...c,dataStore:fi(c.dataStore,"name",a(l[0]))});break;case"annotation.add":s.push({...c,annotation:fi(c.annotation,"text",a(l[0]))});break;case"group.add":s.push({...c,group:fi(c.group,"name",a(l[0]))});break;case"annotation.update":s.push(fi(c,"text",a(l[0])));break;default:s.push(kp(l[0].map)?fi(c,"name",a(l[0])):(a(l[0]),c))}}return{ops:s,writes:i}}const jR=/^[\p{L}_][\p{L}\p{N}_.\-]*$/u,xg=new Set(["sequenceFlow","messageFlow","dataAssociation","association"]),_g={"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}]},Ha=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),wc=e=>typeof e=="string"&&e!=="";function HR(e){const t=[];function n(i,r,o,a){if(a===null){wc(o)||t.push({kind:"payload-invalid",opIndex:i,field:r});return}if(!Ha(o)){t.push({kind:"payload-invalid",opIndex:i,field:r});return}for(const s of a)wc(o[s])||t.push({kind:"payload-invalid",opIndex:i,field:`${r}.${s}`})}return e.forEach((i,r)=>{var o,a,s;if(!Ha(i)||!wc(i.kind)||!(i.kind in _g)){t.push({kind:"payload-invalid",opIndex:r,field:"kind"});return}for(const c of _g[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(!Ha(f))break;f=f[g]}if(!Ha(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;Ha(c)&&!wc(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"&&!Uh(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&&!qh(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 wg(e,t,n={}){const i=HR(e);if(i.length>0)return i;const r=[],o=new Map,a=new Map;function s(h,y,R){if(!jR.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,{...R,opIndex:h})}e.forEach((h,y)=>{var R;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"}),(R=h.association)!=null&&R.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,R,x){const m=c(y);if(m===void 0){r.push({kind:"ref-missing",opIndex:h,ref:y,role:R});return}if(x&&!x.includes(m)){r.push({kind:"ref-category",opIndex:h,ref:y,role:R,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 R;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&&((((R=o.get(x))==null?void 0:R.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"]),k=u(y,v,"target",["flowNode"]);T&&k&&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),k=l(v);T!==void 0&&T===k&&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&&xg.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&&xg.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(...$R(e,t,n.i18n)),r;function g(h,y,R){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(R&&x!==R){r.push({kind:"ref-category",opIndex:h,ref:y,role:"target",expected:R,actual:x});return}return x}}function Eg(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 Ec(e){return`bpmn:${e[0].toUpperCase()}${e.slice(1)}`}const Sc={"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,zR=300,GR=160,Sg=20,Op=100,Rg=40,VR=10;function Dp(e,t,n,i,r){const o=n,a=(P,O)=>{const[j,Q]=Sc[P];let me={x:t.x+t.width/2+j*(t.width/2+o.width/2+O),y:t.y+t.height/2+Q*(t.height/2+o.height/2+O)};const Pe=i.x+Rn+o.width/2,De=i.x+i.width-Rn-o.width/2,Ke=i.y+Rn+o.height/2,rt=i.y+i.height-Rn-o.height/2,Ae={x:Math.min(De,Math.max(Pe,me.x)),y:Math.min(rt,Math.max(Ke,me.y))};return(Ae.x!==me.x||Ae.y!==me.y)&&(me=Math.abs(Ae.x-(t.x+t.width/2))<(t.width+o.width)/2+Rn&&Math.abs(Ae.y-(t.y+t.height/2))<(t.height+o.height)/2+Rn?{x:t.x+t.width+Rn+o.width/2,y:Ae.y}:Ae),me},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=Xe(e),l=P=>{var j,Q;if(!r.selfId)return!1;const O=e.get(P);return!!O&&(((j=O.source)==null?void 0:j.id)===r.selfId||((Q=O.target)==null?void 0:Q.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 O=f(P);return s.some(j=>O.x0<j.x+j.width&&O.x1>j.x&&O.y0<j.y+j.height&&O.y1>j.y)},g=P=>{const O=f(P);return u.some(j=>j.axis==="h"?j.at>O.y0&&j.at<O.y1&&j.lo<O.x1&&j.hi>O.x0:j.at>O.x0&&j.at<O.x1&&j.lo<O.y1&&j.hi>O.y0)},h=P=>{const O=f(P);return p.some(j=>O.x0<j.x+j.width&&O.x1>j.x&&O.y0<j.y+j.height&&O.y1>j.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}]),R=P=>{const O=f(P);return y.some(j=>j.axis==="h"?j.at>O.y0&&j.at<O.y1&&j.lo<O.x1&&j.hi>O.x0:j.at>O.x0&&j.at<O.x1&&j.lo<O.y1&&j.hi>O.y0)},x=P=>d(P)||g(P)||h(P)||R(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"),O=De=>De.endsWith("left")?De.replace(/left$/,"right"):De.replace(/right$/,"left"),j=r.placement.side,Q=[j,P(j),O(j),P(O(j)),"top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"],me=r.placement.offset??50;let Pe=a(j,me);if(x(Pe)){const De=new Set;for(const Ke of Q){if(De.has(Ke))continue;De.add(Ke);const rt=a(Ke,me);if(m(rt)&&!x(rt)){Pe=rt;break}}}return Pe}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,k=i.y+i.height-Rn-o.height/2;let B={x:Math.min(E,Math.max(_,v.x)),y:Math.min(k,Math.max(T,v.y))};if(x(B)){const P=(t.width+o.width)/2+Rn,j=[{x:B.x+P,y:B.y},{x:B.x-P,y:B.y},{x:B.x,y:B.y-o.height-Rn},{x:B.x,y:B.y+o.height+Rn}].filter(m).find(Q=>!x(Q));j&&(B=j)}return B}function Qt(e,t){return e.filter(n=>n.kind===t)}class Cg extends Error{constructor(t){super(t.kind),this.issue=t,this.name="LowerIssueError"}}function Ag(e,t){var SE,RE,CE,AE,ME,PE,TE,kE,OE,DE,LE,IE,BE,NE,$E,FE,jE,HE,zE,GE,VE,WE,UE;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 C=p(b);if(!C)throw new Error(`하강 참조 해소 실패: ${b}`);return C},d=b=>{let C=b.parent;for(;C;){if(C.type==="bpmn:Participant")return C;C=C.parent}},g=new Map;for(const b of o.filter(C=>!("waypoints"in C&&C.waypoints)&&C.type!=="bpmn:Lane"&&C.type!=="label"&&typeof C.x=="number"))g.set(b.id,{x:b.x,y:b.y});const h=Qt(e,"participant.add"),y=Qt(e,"node.add"),R=Qt(e,"sequenceFlow.add"),x=Qt(e,"messageFlow.add"),m=Qt(e,"dataStore.add"),v=Qt(e,"dataAssociation.add"),_=Qt(e,"annotation.add"),E=Qt(e,"group.add"),T=new Map(y.map(b=>[b.node.id,b])),k=(b,C,M)=>{var F;const D=b.businessObject,I=(((F=D.extensionElements)==null?void 0:F.values)??[]).filter(N=>N.$type!==C),L=M?[...I,i.create(C,M)]:I;if(!L.length){D.extensionElements&&n.updateProperties(b,{extensionElements:void 0});return}const H=i.create("bpmn:ExtensionElements",{values:L});L.forEach(N=>{N.$parent=H}),n.updateProperties(b,{extensionElements:H})},B=b=>({anchor:b.anchor,side:b.side,...b.offset!==void 0?{offset:b.offset}:{}});for(const b of Qt(e,"element.remove")){const C=p(b.id);C&&n.removeElements([C])}const P=b=>o.filter(C=>{var M;return C.type==="bpmn:Lane"&&((M=d(C))==null?void 0:M.id)===b}).sort((C,M)=>C.y-M.y);for(const b of Qt(e,"participant.update")){const C=f(b.id);if(b.name!==void 0&&n.updateProperties(C,{name:b.name??void 0}),!b.lanes)continue;const M=P(b.id);if(!M.length){n.splitLane(C,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 D=new Set(M.map(I=>I.id));b.lanes.forEach((I,L)=>{if(D.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 O=150,j=130,Q=80,me=90,Pe=180,De=30,Ke=30,rt=(b,C,M,D,I)=>{const L=M-C.width/2,H=D-C.height/2;return(b.children??[]).find(F=>!("waypoints"in F&&F.waypoints)&&F.type!=="bpmn:Lane"&&F.type!=="label"&&!(I!=null&&I.has(F.id))&&typeof F.x=="number"&&L<F.x+F.width+Ke&&L+C.width+Ke>F.x&&H<F.y+F.height&&H+C.height>F.y)},Ae=new Set;for(const b of h){Ae.add(`pool:${b.participant.id}`);for(const C of b.participant.lanes??[])Ae.add(C.id)}const X=new Map;for(const b of y){const C=b.node.lane??`pool:${b.node.participant??""}`;let M=X.get(C);M||X.set(C,M=new Set([0])),b.band!==void 0&&M.add(b.band)}const ne=new Map;for(const[b,C]of X){if(!Ae.has(b))continue;const M=[...C].sort((L,H)=>L-H),D=M.map((L,H)=>H===0?0:H%2===1?Math.ceil(H/2):-(H/2)),I=Math.min(...D);ne.set(b,new Map(M.map((L,H)=>[L,D[H]-I])))}{const b=new Map;for(const C of h)(C.participant.lanes??[]).forEach((M,D)=>b.set(M.id,D));for(const[C,M]of ne){if(!b.has(C)||M.size<2)continue;const D=b.get(C),I=M.get(0)??0,L=new Set;for(const J of y){if(J.node.lane!==C||(J.band??0)!==0||!J.node.type.endsWith("Gateway"))continue;const de={in:new Set,out:new Set,cross:new Set};for(const pe of R){const ge=pe.flow.source===J.node.id;if(!ge&&pe.flow.target!==J.node.id)continue;const tt=T.get(ge?pe.flow.target:pe.flow.source);if(!tt||tt.node.participant!==J.node.participant||!tt.node.lane)continue;let Re,te=!1;if(tt.node.lane!==C){const ie=b.get(tt.node.lane);if(ie===void 0)continue;Re=ie>D?"down":"up",te=!0}else{const ie=M.get(tt.band??0)??I;Re=ie>I?"down":ie<I?"up":void 0}Re&&(de[ge?"out":"in"].add(Re),te&&de.cross.add(Re))}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,F=Math.max(...M.values()),N=H==="down"?F:0;if(I===N)continue;const q=[...M.entries()].filter(([J])=>J!==0).sort((J,de)=>J[1]-de[1]),Y=[...Array(F+1).keys()].filter(J=>J!==N),oe=new Map([[0,N]]);q.forEach(([J],de)=>oe.set(J,Y[de])),ne.set(C,oe)}}const U=b=>{var C;return(((C=X.get(b))==null?void 0:C.size)??0)>1},K=b=>b.band??(b.node.lane||!U(`pool:${b.node.participant??""}`)?void 0:0),re=new Map,fe=b=>re.get(b.node.id)??K(b),Te=new Set,$=new Set;{const b=new Map;for(const D of R)b.set(D.flow.target,(b.get(D.flow.target)??0)+1);const C=D=>{const I=[],L=new Set([D]),H=[D];for(;H.length;){const F=H.shift();I.push(F);for(const N of R)N.flow.source!==F||L.has(N.flow.target)||(b.get(N.flow.target)??0)!==1||(L.add(N.flow.target),H.push(N.flow.target))}return I},M=(D,I)=>{var L;return((L=ne.get(D))==null?void 0:L.get(I))??I};for(const D of y){if(!D.node.type.endsWith("Gateway"))continue;const I=D.node.lane??`pool:${D.node.participant??""}`,L=ne.get(I);if(!L||L.size<2)continue;const H=fe(D);if(H===void 0||M(I,H)!==M(I,0))continue;const F=M(I,H),N=R.filter(pe=>pe.flow.source===D.node.id).map(pe=>T.get(pe.flow.target)).filter(pe=>!!pe&&(pe.node.lane??`pool:${pe.node.participant??""}`)===I),q=N.filter(pe=>{const ge=fe(pe);return ge!==void 0&&M(I,ge)===F&&(b.get(pe.node.id)??0)===1}),Y=N.some(pe=>{const ge=fe(pe);return ge!==void 0&&M(I,ge)>F});if(q.length!==1||!Y)continue;const oe=new Set(N.flatMap(pe=>C(pe.node.id)));if(!R.some(pe=>pe.flow.target===D.node.id&&oe.has(pe.flow.source)))continue;const de=new Map;for(const[pe,ge]of L)de.set(pe,ge+1);de.set(-1,0),ne.set(I,de);for(const pe of C(q[0].node.id))T.has(pe)&&(re.set(pe,-1),$.add(pe));Te.add(D.node.id)}}const S=(b,C)=>{var M;return((M=ne.get(b))==null?void 0:M.get(C))??C},w=(b,C,M,D)=>{const I=b?p(b):C?p(C):void 0;if(!I)return!1;const L=b?I.y+Math.min(I.height/2,me):I.y+Q;return Math.abs(L+S(b??`pool:${C??""}`,M)*O-D)<=O/2},G=new Map;for(const[b,C]of X){let M=0;for(const D of C)M=Math.max(M,S(b,D));G.set(b,M)}const V=b=>Pe+O*b,ee=(b,C,M)=>{const D=u().children.filter(I=>!("waypoints"in I&&I.waypoints)&&!(I.type==="label"&&!("waypoints"in(I.labelTarget??{})))&&I.id!==C&&typeof I.y=="number"&&I.y>=b);D.length&&n.moveElements(D,{x:0,y:M})},Ce=(b,C,M)=>{const D=b.type==="bpmn:Participant"?b:void 0;if(!D||D.children.some(F=>F.type==="bpmn:Lane"))return;const I=M+C.height/2+De-D.y;if(D.height>=I)return;const L=I-D.height,H=D.y+D.height;n.resizeShape(D,{x:D.x,y:D.y,width:D.width,height:I}),ee(H,D.id,L)},Ze=(b,C)=>{const M=C-b.height;if(M<=0)return;const D=d(b)??b,I=[],L=N=>{I.push(N);for(const q of N.children??[])L(q)};L(D);const H=b.y+b.height-10,F=l.calculateAdjustments(I,"y",M,H);l.makeSpace(F.movingShapes,F.resizingShapes,{x:0,y:M},"s",H)},ft=(b,C,M)=>{if(b){const H=f(b),F=V(C);if(H.height>=F)return;const N=F-H.height,q=d(H),Y=q?q.y+q.height:H.y+H.height;Ze(H,F),ee(Y,q==null?void 0:q.id,N);return}if(!M)return;const D=O*(C+1);if(M.height>=D)return;const I=D-M.height,L=M.y+M.height;n.resizeShape(M,{x:M.x,y:M.y,width:M.width,height:D}),ee(L,M.id,I)},Wt=new Map;for(const b of R)Wt.set(b.flow.target,(Wt.get(b.flow.target)??0)+1);const xt=b=>(Wt.get(b)??0)<=1,fn=(b,C)=>{if(!b)return;const M=p(b);if(!M||M.height>=V(C))return;const D=M.y+M.height-10,I=d(M);if(I)return new Set((I.children??[]).filter(L=>L.type!=="bpmn:Lane"&&typeof L.y=="number"&&L.y>D).map(L=>L.id))},xn=(b,C,M)=>{if(!b)return!0;const D=p(b);return D?M-C.height/2>=D.y&&M+C.height/2<=D.y+D.height:!0},_n=h.map((b,C)=>({op:b,declared:C}));_n.sort((b,C)=>{const M=b.op.order??Number.POSITIVE_INFINITY,D=C.op.order??Number.POSITIVE_INFINITY;return M!==D?M-D:b.declared-C.declared});let _t=80;for(const b of o.getAll())b.parent===u()&&"height"in b&&typeof b.y=="number"&&(_t=Math.max(_t,b.y+b.height+60));for(const{op:b}of _n){const C=b.participant,M=y.filter(J=>J.node.participant===C.id).length,D=((SE=C.lanes)==null?void 0:SE.length)??0,I=Math.max(1200,M*160+300),L=(C.lanes??[]).map(J=>V(G.get(J.id)??0)),H=L.reduce((J,de)=>J+de,0);D&&H<300&&(L[D-1]+=300-H);const F=Math.max(300,O*((G.get(`pool:${C.id}`)??0)+1)),N=C.blackBox||M+D===0?120:D?Math.max(300,H):F,q=r.createShape({type:"bpmn:Participant",businessObject:i.create("bpmn:Participant",{id:C.id,name:C.name,...b.order!==void 0?{"bwl:poolOrder":b.order}:{},...C.blackBox?{}:{processRef:i.create("bpmn:Process")}}),width:I,height:N,isExpanded:!0}),Y=n.createShape(q,{x:100+I/2,y:_t+N/2},u()),oe=C.lanes??[];if(oe.length&&n.splitLane(Y,oe.length),oe.length){const J=o.filter(de=>{var pe;return de.type==="bpmn:Lane"&&((pe=d(de))==null?void 0:pe.id)===C.id}).sort((de,pe)=>de.y-pe.y);if(J.forEach((de,pe)=>{const ge=oe[pe];ge&&n.updateProperties(de,{id:ge.id,name:ge.name})}),L.some(de=>de!==Y.height/D)){let de=Y.y;J.forEach((pe,ge)=>{const tt=L[ge];n.resizeShape(pe,{x:pe.x,y:de,width:pe.width,height:tt}),de+=tt})}}_t=Y.y+Y.height+60}const dn=b=>{var D;const C=T.get(b);if(C)return C.node.participant??"";const M=p(b);return M?M.type==="bpmn:Participant"?M.id:((D=d(M))==null?void 0:D.id)??"":""},vn=new Map,Ao=b=>{let C=vn.get(b);return C||vn.set(b,C={nodes:[],flows:[]}),C};for(const b of y)Ao(b.node.participant??"").nodes.push(b);for(const b of R)Ao(dn(b.flow.source)).flows.push(b);const ti=b=>{var C;return i.create("bpmn:SequenceFlow",{id:b.id,name:b.name??((C=b.condition)==null?void 0:C.label)})},Ri=(b,C,M)=>r.createShape({type:Ec(b.type),...b.eventDefinition?{eventDefinitionType:Qs[b.eventDefinition]}:{},businessObject:i.create(Ec(b.type),{id:b.id,name:b.name,...C!==void 0?{"bwl:band":C}:{},...M!==void 0?{"bwl:afterColumn":M}:{}})}),Ci=[..._n.map(({op:b})=>b.participant.id).filter(b=>vn.has(b)),...[...vn.keys()].filter(b=>!h.some(C=>C.participant.id===b))],Kt=b=>b.endsWith("Gateway");for(const b of Ci){const C=vn.get(b),M=b?f(b):void 0,D=M?M.x+150:250;let I=M?M.y+80:120;const L=(te,ie,ce)=>{if(te){const ve=f(te);return ve.y+Math.min(ve.height/2,me)+S(te,ie??0)*O}return ie!==void 0&&M?M.y+Q+S(`pool:${b}`,ie)*O:ce},H=(te,ie,ce)=>{if(te){const ve=f(te);return ve.y+Math.min(ve.height/2,me)+ie*O}return M?M.y+Q+ie*O:ce},F=te=>te.participant?f(te.participant):u(),N=(te,ie,ce,ve,Ve,We,St)=>{const $t=ce!==void 0||ve!==void 0,be=S(ce??`pool:${b}`,ve??0);if((ve===void 0||w(ce,b,ve,St??Number.NaN))&&St!==void 0&&xn(ce,ie,St)&&!rt(te,ie,Ve,St))return{x:Ve,y:St};if($t)for(let ye=0;ye<4;ye++){const Le=H(ce,be+ye,We);if(!rt(te,ie,Ve,Le,fn(ce,be+ye)))return ft(ce,be+ye,M),{x:Ve,y:Le}}const xe=L(ce,ve,We);$t?ft(ce,be,M):Ce(te,ie,xe);let ae=Ve;for(let ye=0;ye<64;ye++){const Le=rt(te,ie,ae,xe);if(!Le)break;ae=Le.x+Le.width+j+ie.width/2}return{x:ae,y:xe}},q=new Set(C.flows.map(te=>te.flow.target)),Y=new Map,oe=te=>{if(te===void 0)return;const ie=o.get(te);if(!(!ie||typeof ie.x!="number"||typeof ie.width!="number"))return ie.x+ie.width+j};for(const te of C.nodes){if(q.has(te.node.id))continue;const ie=Ri(te.node,te.band,te.afterColumn),ce=K(te),ve=te.node.lane?`${te.node.lane}|${ce??""}`:ce!==void 0?`band:${ce}`:"",Ve=F(te.node),We=Y.get(ve)??D,St=oe(te.afterColumn),$t=St===void 0?We:Math.max(We,St),be=N(Ve,ie,te.node.lane,ce,$t,I);n.createShape(ie,be,Ve),Y.set(ve,be.x+ie.width+j),!te.node.lane&&ce===void 0&&(I+=160)}const J=new Set,de=new Map,pe=new Map,ge=new Map;if(b&&Ae.has(`pool:${b}`)){const te=new Map;for(const be of C.flows)te.set(be.flow.target,(te.get(be.flow.target)??0)+1);const ie=be=>L(be.node.lane,fe(be),Number.NaN),ce=new Set,ve=be=>{var ye;const xe=(ye=T.get(be))==null?void 0:ye.node.participant;if(xe)return p(xe);const ae=p(be);if(ae)return ae.type==="bpmn:Participant"?ae:d(ae)},Ve=be=>{const xe=[],ae=new Set([be]),ye=[be];for(;ye.length;){const Le=ye.shift(),Ye=T.get(Le);Ye&&xe.push(Ye);for(const ke of C.flows)ke.flow.source!==Le||ae.has(ke.flow.target)||(te.get(ke.flow.target)??0)!==1||(ae.add(ke.flow.target),ye.push(ke.flow.target))}return xe},We=be=>{if(!M)return;const xe=new Set(be.map(Le=>Le.node.id));let ae=!1,ye=!1;for(const Le of x){if(!xe.has(Le.flow.source))continue;const Ye=ve(Le.flow.target);!Ye||Ye.id===M.id||(Ye.y<M.y?ae=!0:ye=!0)}return ae&&!ye?"up":ye&&!ae?"down":void 0};for(const be of C.nodes){if(!Kt(be.node.type))continue;const xe=L(be.node.lane,K(be),Number.NaN);if(Number.isNaN(xe))continue;const ae=[];for(const ke of C.flows){if(ke.flow.source!==be.node.id)continue;const He=T.get(ke.flow.target);if(!He||He.node.lane!==be.node.lane||(te.get(He.node.id)??0)!==1)continue;const Qe=K(He);if(Qe===void 0)continue;const we=L(He.node.lane,Qe,Number.NaN);if(Number.isNaN(we))continue;const ot=Ve(He.node.id),Me=We(ot);Me&&ae.push({subtree:ot,band:Qe,row:we,dir:Me})}if(!ae.some(ke=>ke.dir==="up")||!ae.some(ke=>ke.dir==="down")||!ae.some(ke=>ke.dir==="up"&&ae.some(He=>He.dir==="down"&&He.row<ke.row)))continue;const Le=[...ae].sort((ke,He)=>ke.row-He.row);[...ae.filter(ke=>ke.dir==="up"),...ae.filter(ke=>ke.dir==="down")].sort((ke,He)=>ke.dir===He.dir?ke.row-He.row:ke.dir==="up"?-1:1).forEach((ke,He)=>{const Qe=Le[He].band;if(Qe!==ke.band){ce.add(be.node.id);for(const we of ke.subtree)K(we)===ke.band&&re.set(we.node.id,Qe)}})}const St=be=>{if(!M)return;const xe=new Set(be.map(Le=>Le.node.id));let ae=!1,ye=!1;for(const Le of x){if(!xe.has(Le.flow.target))continue;const Ye=ve(Le.flow.source);!Ye||Ye.id===M.id||(Ye.y<M.y?ae=!0:ye=!0)}return ae&&!ye?"up":ye&&!ae?"down":void 0};for(const be of C.nodes){if(!Kt(be.node.type))continue;const xe=be.node.lane??`pool:${b}`,ae=ne.get(xe);if(!ae||ae.size<2)continue;const ye=ae.get(0);if(ye===void 0)continue;const Le=Math.max(...ae.values()),Ye=ye===Le&&ye!==0?"down":void 0;if(!Ye)continue;const ke=[];for(const Me of C.flows){if(Me.flow.source!==be.node.id)continue;const wt=T.get(Me.flow.target);if(!wt||wt.node.lane!==be.node.lane||(te.get(wt.node.id)??0)!==1)continue;const gt=fe(wt);gt!==void 0&&ke.push({t:wt,subtree:Ve(wt.node.id),band:gt})}const He=ke.find(Me=>(ae.get(Me.band)??Me.band)===ye);if(!He||St(He.subtree)===Ye||We(He.subtree)===Ye)continue;const Qe=ke.find(Me=>Me!==He&&St(Me.subtree)===Ye);if(!Qe)continue;const we=He.band,ot=Qe.band;for(const Me of He.subtree)fe(Me)===we&&re.set(Me.node.id,ot);for(const Me of Qe.subtree)fe(Me)===ot&&re.set(Me.node.id,we);ce.add(be.node.id)}for(const be of C.nodes){if(!Kt(be.node.type))continue;const xe=ie(be);if(Number.isNaN(xe)||_.some(ke=>{var He,Qe;return(((He=ke.placement)==null?void 0:He.anchor)??(ke.association?ke.association.source===ke.annotation.id?ke.association.target:ke.association.source:void 0))===be.node.id&&((Qe=ke.placement)==null?void 0:Qe.side.startsWith("bottom"))}))continue;let ye,Le=!1,Ye;for(const ke of C.flows){if(ke.flow.source!==be.node.id)continue;const He=T.get(ke.flow.target);if(!He||!He.node.lane&&K(He)===void 0)continue;const Qe=ie(He);Number.isNaN(Qe)||(Math.abs(Qe-xe)<.5&&(Le=!0),Qe>xe?!ye||Qe>ye.row?ye={id:He.node.id,row:Qe,count:1}:Qe===ye.row&&ye.count++:Qe<xe&&He.node.lane===be.node.lane&&(!Ye||Qe>Ye.row?Ye={op:He,row:Qe,count:1}:Qe===Ye.row&&Ye.count++))}ye&&ye.count===1&&(te.get(ye.id)??0)===1&&!ce.has(be.node.id)&&J.add(ye.id),!Le&&Ye&&Ye.count===1&&(te.get(Ye.op.node.id)??0)===1&&!Te.has(be.node.id)&&de.set(Ye.op.node.id,{lane:be.node.lane,band:fe(be)})}const $t=new Map;for(const be of x)$t.set(be.flow.target,[...$t.get(be.flow.target)??[],be]);for(const be of C.nodes){const xe=$t.get(be.node.id);if(!xe||xe.length!==1||!te.get(be.node.id)||!be.node.lane&&K(be)===void 0||$.has(be.node.id))continue;const ae=(RE=T.get(xe[0].flow.source))==null?void 0:RE.node.participant,ye=ae?p(ae):void 0;if(!ye||!M||ye.id===M.id)continue;const Le=be.node.lane??`pool:${b}`,Ye=ne.get(Le);if(!Ye)continue;const ke=Ye.get(0)??0,He=(Ye.get(fe(be)??0)??ke)-ke;if(He===0)continue;const Qe=ye.y<M.y;if(Qe&&He<0||!Qe&&He>0)continue;let we;for(const[ot,Me]of Ye){const wt=Me-ke;(Qe&&wt<0&&(!we||wt<we.row)||!Qe&&wt>0&&(!we||wt>we.row))&&(we={band:ot,row:wt})}we&&pe.set(be.node.id,{lane:be.node.lane,band:we.band})}}const tt=new Set;let Re=0;for(;Re++<C.nodes.length+2;){for(let ce=0;ce<C.nodes.length+C.flows.length+2;ce++){let ve=!1;for(const Ve of C.flows){const We=Ve.flow;if(tt.has(We.id))continue;const St=p(We.source);if(!St)continue;const $t=p(We.target),be=T.get(We.target);if(!$t&&be){const xe=Ri(be.node,be.band),ae=fe(be);if(be.node.lane||ae!==void 0){const ye=F(be.node),Le=St,Ye=Le.x+(ge.get(We.source)??0)+Le.width+j,ke=de.get(We.target)??pe.get(We.target),He=N(ye,xe,ke?ke.lane:be.node.lane,ke?ke.band:ae,J.has(We.target)?Le.x+Le.width/2:Ye,Number.NaN,ke||!xt(We.target)?void 0:Le.y+Le.height/2),Qe=n.createShape(xe,He,ye);J.has(We.target)&&ge.set(We.target,Ye-(Qe.x+Qe.width/2)),n.connect(St,Qe,{type:"bpmn:SequenceFlow",businessObject:ti(We)})}else s.append(St,xe,{connection:{type:"bpmn:SequenceFlow",businessObject:ti(We)}})}else if($t)n.connect(St,$t,{type:"bpmn:SequenceFlow",businessObject:ti(We)});else continue;tt.add(We.id),ve=!0}if(!ve)break}const te=C.nodes.filter(ce=>!p(ce.node.id));if(!te.length)break;const ie=te[0];{const ce=Ri(ie.node,ie.band),ve=F(ie.node),Ve=K(ie);n.createShape(ce,N(ve,ce,ie.node.lane,Ve,D,I),ve),!ie.node.lane&&Ve===void 0&&(I+=160)}}}const Ai=40,Ta=b=>{const C=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,M=()=>new Set(ht(Xe(o)).filter(Y=>!C(Y)).map(Y=>ut(Y))),D=M(),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 F=M(),N=[...F].filter(Y=>!D.has(Y)).length,q=[...D].filter(Y=>!F.has(Y)).length;N<=q||(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}))},ni=5,st=10,yt=200,Iu=new Set([...R.map(b=>b.flow.id),...x.map(b=>b.flow.id),...Qt(e,"sequenceFlow.update").map(b=>b.id),...Qt(e,"messageFlow.update").map(b=>b.id)].filter(b=>!!b)),ON=(b,C,M,D,I,L)=>{const H=new Set(b.map(te=>te.id)),F=Math.min(...b.map(te=>te.x))+C-st,N=Math.max(...b.map(te=>te.x+te.width))+C+yt+st,q=Math.min(...b.map(te=>te.y+Math.min(0,...M)))-st,Y=Math.max(...b.map(te=>te.y+te.height+Math.max(0,...M)))+st,oe=o.getAll().filter(te=>{if(te.type!=="bpmn:SequenceFlow"&&te.type!=="bpmn:MessageFlow")return!1;const ie=te;return Iu.has(ie.id)||!ie.waypoints||ie.waypoints.length<2||[ie.source,ie.target].some(ve=>!ve||H.has(ve.id)||ve.x>=D)?!1:ie.waypoints.some((ve,Ve)=>{const We=ie.waypoints[Ve+1];return!!We&&Math.max(ve.x,We.x)>=F&&Math.min(ve.x,We.x)<=N&&Math.max(ve.y,We.y)>=q&&Math.min(ve.y,We.y)<=Y})});if(!oe.length)return 0;const J=te=>{const ie=new Map;for(const ce of b)for(const ve of M){const Ve={id:ce.id,type:ce.type,x:ce.x+C+te,y:ce.y+ve,width:ce.width,height:ce.height};for(const We of oe){let St=1/0;for(let be=0;be+1<We.waypoints.length;be++)St=Math.min(St,mc(We.waypoints[be],We.waypoints[be+1],Ve));const $t=`${We.id}|${ce.id}`;ie.set($t,Math.min(ie.get($t)??1/0,St))}}return ie},de=[...J(0)].filter(([,te])=>te<=ni).map(([te])=>te);if(!de.length)return 0;let pe=0;for(let te=1;te<=yt;te++){const ie=J(te);if([...ie.values()].every(ce=>ce>ni)&&de.every(ce=>(ie.get(ce)??1/0)>=st)){pe=te;break}}if(!pe)return 0;const ge=Math.min(...b.map(te=>te.x))+C+pe,tt=new Set(de.map(te=>te.slice(0,te.indexOf("|"))));return oe.some(te=>te.type==="bpmn:SequenceFlow"&&tt.has(te.id)&&te.waypoints.some((ie,ce)=>{const ve=te.waypoints[ce+1];if(!ve||Math.min(ie.y,ve.y)>L||Math.max(ie.y,ve.y)<L||ie.y===ve.y)return!1;const Ve=ie.x+(L-ie.y)*(ve.x-ie.x)/(ve.y-ie.y);return Ve>I&&Ve<ge}))?0:pe},Mo=(b,C=()=>!0)=>{const M=p(b);if(!M)return[];const D=[M],I=new Set([b]);for(let L=0;L<D.length;L++){const H=D[L].id;for(const F of R){const N=F.flow.target;if(F.flow.source!==H||I.has(N)||!T.has(N))continue;I.add(N);const q=p(N);q&&C(q)&&D.push(q)}}return D},DN=(b,C=()=>!0)=>{const M=p(b);if(!M)return[];const D=[M],I=new Set([b]);for(let L=0;L<D.length;L++){const H=D[L].id;for(const F of R){const N=F.flow.source;if(F.flow.target!==H||I.has(N)||!T.has(N))continue;I.add(N);const q=p(N);q&&C(q)&&D.push(q)}}return D},Mi=30,vr=b=>!("waypoints"in b&&b.waypoints)&&b.type!=="bpmn:Lane"&&b.type!=="label"&&typeof b.x=="number",Bu=(b,C)=>Ip(n,b,C),Vs=(b,C,M=!1)=>{const D=new Set(b.flatMap(N=>N.subtree.map(q=>q.id)));for(const N of b){const q=(N.pool.children??[]).filter(vr).filter(oe=>!D.has(oe.id));if(N.subtree.some(oe=>q.some(J=>oe.x+C<J.x+J.width+Mi&&oe.x+C+oe.width+Mi>J.x&&oe.y<J.y+J.height&&oe.y+oe.height>J.y)))return null}const I=b.map(N=>N.pool.width),L=M?o.filter(N=>Array.isArray(N.waypoints)).map(N=>({c:N,wps:N.waypoints.map(q=>({x:q.x,y:q.y}))})):[],H=o.filter(N=>N.type==="label").map(N=>({label:N,x:N.x,y:N.y}));n.moveElements(b.flatMap(N=>N.subtree),{x:C,y:0});const F=b.map(N=>{const Y=Math.max(...N.subtree.map(oe=>oe.x+oe.width))+Mg-(N.pool.x+N.pool.width);return Y>0&&Bu(N.pool,N.pool.width+Y),Y});return()=>{n.moveElements(b.flatMap(N=>N.subtree),{x:-C,y:0}),b.forEach((N,q)=>{F[q]>0&&Bu(N.pool,I[q])});for(const{c:N,wps:q}of L){const Y=N.waypoints??[];Y.length===q.length&&Y.every((J,de)=>Math.abs(J.x-q[de].x)<=.5&&Math.abs(J.y-q[de].y)<=.5)||n.updateWaypoints(N,q.map(J=>({x:J.x,y:J.y})))}for(let N=0;N<3;N++){let q=0;for(const Y of H){const oe=Y.x-Y.label.x,J=Y.y-Y.label.y;Math.abs(oe)<=.5&&Math.abs(J)<=.5||(n.moveElements([Y.label],{x:oe,y:J}),q++)}if(!q)break}}},Ih=b=>{var I,L;const C=new Map,M=new Map;for(const H of o.getAll()){if(H.type!=="bpmn:Participant")continue;const F=H;(F.children??[]).length||(C.set(F.id,F),M.set(F.id,[]))}for(const H of o.getAll()){if(H.type!=="bpmn:MessageFlow")continue;const F=H,N=(I=F.source)==null?void 0:I.id,q=(L=F.target)==null?void 0:L.id;N&&q&&M.has(N)&&M.get(N).push(q),N&&q&&M.has(q)&&M.get(q).push(N)}const D=[];for(const[H,F]of M)F.length&&F.every(N=>b.has(N))&&D.push(C.get(H));return D},eE=(b,C)=>{if(!b.length)return null;const M=new Set(b.map(Y=>Y.id)),D=o.getAll().filter(Y=>Y.type==="bpmn:Participant"&&!M.has(Y.id)),I=Math.min(...D.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 oe=L.has(Y.id)?Y.x:Y.x+C,J=L.has(Y.id)?Y.width+C:Y.width;return D.some(de=>oe<de.x+de.width+Mi&&oe+J+Mi>de.x&&Y.y<de.y+de.height&&Y.y+Y.height>de.y)}))return null;const F=o.filter(Y=>Y.type==="label").map(Y=>({label:Y,x:Y.x,y:Y.y})),N=b.filter(Y=>!L.has(Y.id)),q=b.filter(Y=>L.has(Y.id)).map(Y=>({pool:Y,was:{x:Y.x,y:Y.y,width:Y.width,height:Y.height}}));N.length&&n.moveElements(N,{x:C,y:0});for(const{pool:Y,was:oe}of q)n.resizeShape(Y,{...oe,width:oe.width+C});return()=>{for(const{pool:Y,was:oe}of q)n.resizeShape(Y,oe);N.length&&n.moveElements(N,{x:-C,y:0});for(let Y=0;Y<3;Y++){let oe=0;for(const J of F){const de=J.x-J.label.x,pe=J.y-J.label.y;Math.abs(de)<=.5&&Math.abs(pe)<=.5||(n.moveElements([J.label],{x:de,y:pe}),oe++)}if(!oe)break}}},tE=(b,C,M)=>{const D=M.x+M.width/2,I=C.y>M.y,L=I?M.y+M.height:M.y,H=I?C.y:C.y+C.height,F=b.source===C?[{x:D,y:H},{x:D,y:L}]:[{x:D,y:L},{x:D,y:H}],N=Xe(o),q={...N.edges.find(Y=>Y.id===b.id),waypoints:F};return En(q,ai(N)).length?!1:(n.updateWaypoints(b,F),!0)},LN=()=>{const b=o.filter(I=>I.type==="bpmn:Participant"),C=Math.min(...b.filter(I=>(I.children??[]).length>0).map(I=>I.x)),M=I=>!!I&&I.type==="bpmn:Participant"&&!(I.children??[]).length&&Math.abs(I.x-C)<=2&&!h.some(L=>L.participant.id===I.id),D=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(N=>M(N)),F=H===L.source?L.target:L.source;H&&F&&F.type!=="bpmn:Participant"&&D.add(L.id)}return D},IN=b=>{var M;const C=new Map;for(const D of b){const I=o.get(D);if(!I||(I.waypoints??[]).length===2)continue;const L=((M=I.source)==null?void 0:M.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 F=C.get(L.id)??{pool:L,msgs:[]};F.msgs.push({conn:I,other:H}),C.set(L.id,F)}for(const{pool:D,msgs:I}of C.values()){const L=Math.max(...I.map(({other:pe})=>pe.x+pe.width/2))+Op;if(o.getAll().some(pe=>{if(pe.type!=="bpmn:Participant"||pe.id===D.id)return!1;const ge=pe;return D.x<ge.x+ge.width+Mi&&L+Mi>ge.x&&D.y<ge.y+ge.height&&D.y+D.height>ge.y}))continue;const F={x:D.x,y:D.y,width:D.width,height:D.height},N=[...D.incoming??[],...D.outgoing??[]],q=N.map(pe=>({c:pe,wps:(pe.waypoints??[]).map(ge=>({x:ge.x,y:ge.y}))})),Y=N.flatMap(pe=>{const ge=pe.label;return ge?[{label:ge,x:ge.x,y:ge.y}]:[]}),oe=Qr();n.resizeShape(D,{...F,width:L-D.x});const J=I.filter(({conn:pe,other:ge})=>tE(pe,D,ge)).length,de=Qr();if(!(J>0&&de.messages>oe.messages&&de.lines>=oe.lines)){n.resizeShape(D,F);for(const{c:pe,wps:ge}of q){const tt=pe.waypoints??[];tt.length===ge.length&&tt.every((te,ie)=>Math.abs(te.x-ge[ie].x)<=.5&&Math.abs(te.y-ge[ie].y)<=.5)||n.updateWaypoints(pe,ge.map(te=>({x:te.x,y:te.y})))}for(let pe=0;pe<3;pe++){let ge=0;for(const tt of Y){const Re=tt.x-tt.label.x,te=tt.y-tt.label.y;Math.abs(Re)<=.5&&Math.abs(te)<=.5||(n.moveElements([tt.label],{x:Re,y:te}),ge++)}if(!ge)break}}}},nE=()=>{let b=0;for(const C of o.getAll()){if(C.type!=="bpmn:DataInputAssociation"&&C.type!=="bpmn:DataOutputAssociation")continue;const M=C.waypoints??[];for(let D=1;D<M.length;D++)b+=Math.hypot(M[D].x-M[D-1].x,M[D].y-M[D-1].y)}return b},iE=()=>{let b=0;for(const C of o.getAll()){if(C.type!=="bpmn:Association")continue;const M=C.waypoints??[];for(let D=1;D<M.length;D++)b+=Math.hypot(M[D].x-M[D-1].x,M[D].y-M[D-1].y)}return b},BN=b=>{const C=[];for(const M of o.getAll()){if(M.type!=="bpmn:TextAnnotation")continue;const D=M;if(b.has(D.id))continue;const L=[...D.incoming??[],...D.outgoing??[]].filter(N=>N.type==="bpmn:Association").map(N=>N.source===D?N.target:N.source);if(!L.length||L.some(N=>N===void 0))continue;const H=N=>{if(!("waypoints"in N&&N.waypoints))return[N.id];const q=N,Y=[q.source,q.target];return Y.some(oe=>!oe)?[]:Y.map(oe=>oe.id)},F=L.flatMap(N=>H(N));F.length&&F.every(N=>b.has(N))&&C.push(D)}return C},rE=()=>ht(Xe(o)).filter(b=>b.kind==="edge-crosses-shape").length,oE=b=>{const C=(b.children??[]).filter(vr);let M=0;for(let D=0;D<C.length;D++)for(let I=D+1;I<C.length;I++){const L=C[D],H=C[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&&M++}return M},Qr=()=>{const b=Xe(o),C=M=>M.length>=2&&(M.every(D=>Math.abs(D.x-M[0].x)<.01)||M.every(D=>Math.abs(D.y-M[0].y)<.01));return{messages:b.edges.filter(M=>M.type==="bpmn:MessageFlow"&&M.waypoints.length===2).length,lines:b.edges.filter(M=>C(M.waypoints)).length}},aE=b=>{const C=new Map;for(const D of o.getAll()){if(D.type!=="bpmn:MessageFlow")continue;const I=D;if(!I.waypoints||I.waypoints.length!==2)continue;const L=I.source,H=I.target;if(!L||!H)continue;const F=b.has(L.id);if(F===b.has(H.id))continue;const N=F?H:L,q=d(N);if(!q||b.has(N.id))continue;const Y=C.get(q.id);Y?N.x<Y.minX&&(Y.minX=N.x):C.set(q.id,{pool:q,minX:N.x})}const M=[];for(const{pool:D,minX:I}of C.values()){const L=(D.children??[]).filter(H=>vr(H)&&!b.has(H.id)&&H.x>=I);L.length&&M.push({subtree:L,pool:D})}return M},NN=(b,C,M)=>{const D=new Map(C.map(H=>[H.pool.id,{subtree:[...H.subtree],pool:H.pool}])),I=new Set(b);for(const H of C)for(const F of H.subtree)I.add(F.id);let L=!1;for(;;){let H=0;for(const F of aE(I)){if(F.pool===M)continue;const N=D.get(F.pool.id);N?N.subtree.push(...F.subtree):D.set(F.pool.id,{subtree:[...F.subtree],pool:F.pool});for(const q of F.subtree)I.add(q.id);H+=F.subtree.length}if(!H)break;L=!0}return L?[...D.values()]:null},sE=new Map;for(const b of Qt(e,"sequenceFlow.update")){if(b.target===void 0)continue;const C=T.get(b.target);if(!C)continue;const M=p(b.target),D=p(b.id);if(!M||!D)continue;const I=b.source!==void 0?p(b.source):D.source,L=D.target;if(!I||!L||L.id===M.id)continue;const H=D.waypoints&&D.waypoints.length>=3&&Math.abs(D.waypoints[0].x-D.waypoints[1].x)<1&&Math.abs(D.waypoints[0].y-D.waypoints[1].y)>1?{x:D.waypoints[0].x,y:D.waypoints[0].y}:void 0,F=H?D.waypoints[1].y:void 0,N=H&&D.label?{x:D.label.x,y:D.label.y}:void 0,q=N&&D.label&&Math.abs(N.y+D.label.height/2-F)<=O/5&&N.x+D.label.width>H.x?N.x+D.label.width+6:void 0,Y=(I.outgoing??[]).filter(we=>we.type==="bpmn:SequenceFlow"&&we.id!==D.id&&we.target&&!Iu.has(we.id)),oe=new Set(Y.map(we=>we.target.id)),J=we=>{const ot={type:"bpmn:Task",x:we.x+2,y:we.y+2,width:we.width-4,height:we.height-4};return Y.find(Me=>(Me.waypoints??[]).some((wt,gt)=>!!Me.waypoints[gt+1]&&mc(wt,Me.waypoints[gt+1],ot)===0))},de=Mo(b.target),pe=new Set(de.map(we=>we.id)),ge=Math.min(...de.map(we=>we.x)),tt=Math.max(...de.map(we=>we.x+we.width)),Re=I.x+I.width,te=M.y+M.height/2,ie=ON(de,Re+Ai-ge,[0,I.y+I.height/2-te,L.y+L.height/2-te],L.x,Re,I.y+I.height/2),ce=Re+Ai+ie,ve=(()=>{if(q===void 0)return 0;const we=Re+Ai,ot=I.y+I.height/2-M.height/2,Me={x:we,y:ot,width:tt-ge,height:M.height},wt=d(I);return((wt==null?void 0:wt.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<Me.x+Me.width&&mt.x+mt.width>Me.x&&mt.y<Me.y+Me.height&&mt.y+mt.height>Me.y)||J(Me)?Math.max(0,q-we):0})(),Ve=tt-ge+Ai*2+ie+ve-(L.x-Re);let We=[];if(Ve>0){const we=d(M),ot=(we==null?void 0:we.children)??[],Me=Be=>Be.type==="bpmn:Lane";We=(()=>{const Be=new Set;for(const Ne of ot)vr(Ne)&&!pe.has(Ne.id)&&Ne.id!==I.id&&Ne.x>=L.x&&Be.add(Ne.id);const Mt=[];for(const Ne of ot){if(Ne.type!=="bpmn:DataStoreReference"&&Ne.type!=="bpmn:DataObjectReference")continue;const vt=Ne,Gn=[...vt.incoming??[],...vt.outgoing??[]].filter(Xt=>Xt.type==="bpmn:DataInputAssociation"||Xt.type==="bpmn:DataOutputAssociation").map(Xt=>Xt.source===vt?Xt.target:Xt.source);Gn.length&&Gn.every(Xt=>Xt!==void 0&&Be.has(Xt.id))&&Mt.push(vt)}return Mt})();const gt=ot.filter(Be=>!("waypoints"in Be&&Be.waypoints)&&!Me(Be)&&Be.type!=="label"&&!pe.has(Be.id)&&Be.id!==I.id&&Be.x>=L.x),mt=gt.flatMap(Be=>Be.labels??[]),Lt=we?[we,...ot.filter(Be=>Me(Be))]:[];if(gt.length){const Be=new Set(gt.map(bt=>bt.id)),Mt=aE(Be),Ne=Mt.length?NN(Be,Mt,we):null,vt=bt=>{const Tt=new Set(Be);for(const jt of bt)for(const Ii of jt.subtree)Tt.add(Ii.id);return BN(Tt)},Fn=vt(Mt),Gn=Ne?vt(Ne):Fn,Xt=Ih(Be),Hu=new Set(Be);for(const bt of Mt)for(const Tt of bt.subtree)Hu.add(Tt.id);const zu=Mt.length?Ih(Hu):Xt,Gu=(()=>{if(!Ne)return[];const bt=new Set(Be);for(const Tt of Ne)for(const jt of Tt.subtree)bt.add(jt.id);return Ih(bt)})(),qs=new Set([...gt,...Lt].map(bt=>bt.id)),Gh=ot.filter(bt=>{const Tt=bt.labelTarget;return bt.type==="label"&&!!Tt&&"waypoints"in Tt&&!!Tt.source&&!!Tt.target&&qs.has(Tt.source.id)&&qs.has(Tt.target.id)}),Vh=LN();n.createSpace([...gt,...mt,...Gh],Lt,{x:Ve,y:0},"e",L.x-1);const Li=(bt,Tt)=>{const jt=Qr(),Ii=Vs(bt,Ve);if(!Ii)return!1;const It=Tt.length?eE(Tt,Ve):null,Pi=Qr();return Pi.messages>jt.messages&&Pi.lines>=jt.lines?!0:(It==null||It(),Ii(),!1)},dt=Ne?Li(Ne,Gu):!1;let an=dt;!an&&Mt.length&&(an=Li(Mt,zu));const Ft=dt?Gn:Fn;if(!an){for(const bt of Mt){const Tt=Qr(),jt=Vs([bt],Ve);if(!jt)continue;const Ii=Qr();(Ii.messages<=Tt.messages||Ii.lines<Tt.lines)&&jt()}if(Xt.length){const bt=Qr(),Tt=eE(Xt,Ve);if(Tt){const jt=Qr();(jt.messages<=bt.messages||jt.lines<bt.lines)&&Tt()}}}if(IN(Vh),Ft.length){const bt=()=>new Set(ht(Xe(o)).map(jt=>ut(jt))),Tt=jt=>{const Ii=iE(),It=bt(),Pi=jt.map(Zt=>({a:Zt,x:Zt.x,y:Zt.y})),Oo=o.filter(Zt=>Zt.type==="label").map(Zt=>({label:Zt,x:Zt.x,y:Zt.y}));n.moveElements(jt,{x:Ve,y:0});const o$=[...bt()].filter(Zt=>!It.has(Zt));if(iE()<Ii&&o$.length===0)return!0;for(const{a:Zt,x:Ys,y:Ks}of Pi)(Zt.x!==Ys||Zt.y!==Ks)&&n.moveElements([Zt],{x:Ys-Zt.x,y:Ks-Zt.y});for(const Zt of Oo){const Ys=Zt.x-Zt.label.x,Ks=Zt.y-Zt.label.y;(Ys!==0||Ks!==0)&&n.moveElements([Zt.label],{x:Ys,y:Ks})}return!1};if(!Tt(Ft)&&Ft.length>1)for(const jt of Ft)Tt([jt])}}}const St=C.node.lane!==void 0?p(C.node.lane):C.node.participant!==void 0?p(C.node.participant):void 0,$t=we=>{if(!St)return!0;const ot=we.y+we.height/2;return ot>=St.y&&ot<=St.y+St.height},be=!$t(I)&&$t(L)?L:I,xe=be.y+be.height/2,ae=xe-(M.y+M.height/2),ye=C.band!==void 0,Le=ye?[M]:de,Ye=(C.band===void 0||w(C.node.lane,C.node.participant,C.band,xe))&&xt(b.target)&&Le.every(we=>{var ot;return xn((ot=T.get(we.id))==null?void 0:ot.node.lane,we,we.y+we.height/2+ae)}),ke=we=>Math.abs(we.y+we.height/2-(M.y+M.height/2))<=O/2;if(Ye&&ye){const we=Math.abs(ae)<=O/2?de.filter(ot=>ot.id!==M.id&&ke(ot)):[];if(n.moveElements(de,{x:ce-ge,y:0}),n.moveElements([M],{x:0,y:ae}),we.length){const ot=()=>new Set(ht(Xe(o)).map(Be=>ut(Be))),Me=ot(),wt=o.filter(Be=>Be.type==="label").map(Be=>({label:Be,x:Be.x,y:Be.y}));n.moveElements(we,{x:0,y:ae});const gt=ot(),mt=[...gt].filter(Be=>!Me.has(Be)).length,Lt=[...Me].filter(Be=>!gt.has(Be)).length;if(mt>Lt){n.moveElements(we,{x:0,y:-ae});for(const Be of wt){const Mt=Be.x-Be.label.x,Ne=Be.y-Be.label.y;(Mt!==0||Ne!==0)&&n.moveElements([Be.label],{x:Mt,y:Ne})}}}}else n.moveElements(de,{x:ce-ge,y:Ye?ae:0});const He=d(M);if(!Ye&&C.node.lane===void 0&&C.band!==void 0&&He){const we=He.y+Q+S(`pool:${C.node.participant??""}`,C.band)*O,ot=we-(M.y+M.height/2);ot!==0&&!rt(He,M,M.x+M.width/2,we,pe)&&n.moveElements([M],{x:0,y:ot})}if(He){const we=(He.children??[]).filter(gt=>vr(gt)&&!pe.has(gt.id)&>.type!=="bpmn:Group"&>.type!=="bpmn:Participant"),ot=(gt,mt,Lt,Be,Mt)=>gt.x+mt<Mt.x+Mt.width+Be&>.x+mt+gt.width+Be>Mt.x&>.y+Lt<Mt.y+Mt.height+Be&>.y+Lt+gt.height+Be>Mt.y,Me=we.find(gt=>ot(M,0,0,0,gt)),wt=Me?void 0:J(M);if(Me||wt){const gt=["bpmn:SequenceFlow","bpmn:MessageFlow","bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation"],mt=o.getAll().filter(dt=>{if(!gt.includes(dt.type))return!1;const an=dt;return Iu.has(an.id)||!an.waypoints||an.waypoints.length<2?!1:![an.source,an.target].some(Ft=>!Ft||pe.has(Ft.id))}),Lt=(dt,an,Ft)=>{var bt;return xn((bt=T.get(dt.id))==null?void 0:bt.node.lane,dt,dt.y+Ft+dt.height/2)&&dt.x+an>=He.x&&dt.x+an+dt.width<=He.x+He.width&&dt.y+Ft>=He.y&&dt.y+Ft+dt.height<=He.y+He.height},Be=(dt,an)=>de.every(Ft=>Lt(Ft,dt,an)&&!we.some(bt=>ot(Ft,dt,an,st,bt))&&mt.every(bt=>{const Tt={id:Ft.id,type:Ft.type,x:Ft.x+dt,y:Ft.y+an,width:Ft.width,height:Ft.height};for(let jt=0;jt+1<bt.waypoints.length;jt++)if(mc(bt.waypoints[jt],bt.waypoints[jt+1],Tt)<st)return!1;return!0})),Mt=M.y+M.height/2,Ne=[F,L.y+L.height/2].filter(dt=>dt!==void 0&&Math.abs(dt-Mt)>=1),vt=Me&&oe.has(Me.id)?Me:wt==null?void 0:wt.target,Fn=vt?vt.x-M.x:0,Gn=Math.max(...de.map(dt=>dt.x+dt.width)),Xt=[...Fn!==0?[Fn]:[],...ie!==0?[-ie]:[],0],Hu=q===void 0?[]:Xt.map(dt=>Math.max(dt,q-M.x)),zu=dt=>Gn+dt+Ai<=L.x,Gu=[...new Set([...Hu,...Xt])].filter(zu),qs=Me&&oe.has(Me.id)?[Me.x+Me.width+Ai-M.x]:[],Gh=q===void 0?[]:qs.map(dt=>Math.max(dt,q-M.x)),Vh=[...new Set([...Gh,...qs])].filter(dt=>zu(dt)&&!Gu.includes(dt));let Li;for(const dt of[Gu,Vh]){for(const an of Ne){for(const Ft of dt)if(Be(Ft,an-Mt)){Li={dx:Ft,dy:an-Mt};break}if(Li)break}if(Li)break}if(Li){const dt=It=>{const Pi=It;return[Pi.edge,Pi.other,...Array.isArray(Pi.edges)?Pi.edges:[]].some(Oo=>typeof Oo=="string"&&Iu.has(Oo))},an=()=>new Set(ht(Xe(o)).filter(It=>!dt(It)).map(It=>ut(It))),Ft=an(),bt=o.filter(It=>It.type==="label").map(It=>({label:It,x:It.x,y:It.y}));n.moveElements(de,{x:Li.dx,y:Li.dy});const Tt=an(),jt=[...Tt].filter(It=>!Ft.has(It)).length,Ii=[...Ft].filter(It=>!Tt.has(It)).length;if(jt>Ii){n.moveElements(de,{x:-Li.dx,y:-Li.dy});for(const It of bt){const Pi=It.x-It.label.x,Oo=It.y-It.label.y;(Pi!==0||Oo!==0)&&n.moveElements([It.label],{x:Pi,y:Oo})}}else H&&sE.set(D.id,{exit:H,channelY:F,label:N})}}}{const we=new Set(de.map(mt=>mt.id)),ot=new Set(R.map(mt=>mt.flow.id)),Me=20,wt=mt=>{const Lt=mt.source,Be=mt.target,Mt=Math.min(Lt.x,Be.x)-Me,Ne=Math.max(Lt.x+Lt.width,Be.x+Be.width)+Me,vt=Math.min(Lt.y,Be.y)-Me,Fn=Math.max(Lt.y+Lt.height,Be.y+Be.height)+Me;return mt.waypoints.some(Gn=>Gn.x<Mt||Gn.x>Ne||Gn.y<vt||Gn.y>Fn)},gt=new Map;for(const mt of de)for(const Lt of[...mt.incoming??[],...mt.outgoing??[]])Lt.id!==b.id&&ot.has(Lt.id)&&!(we.has(Lt.source.id)&&we.has(Lt.target.id))&>.set(Lt.id,Lt);for(const mt of gt.values())wt(mt)&&Ta(mt)}const Qe=We.length?d(We[0]):void 0;if(Qe){const we={assoc:nE(),overlaps:oE(Qe),crosses:rE()},ot=We.map(Ne=>({st:Ne,x:Ne.x})),Me=o.filter(Ne=>Ne.type==="label").map(Ne=>({label:Ne,x:Ne.x,y:Ne.y})),wt=Math.min(...We.flatMap(Ne=>[...Ne.incoming??[],...Ne.outgoing??[]].filter(vt=>vt.type==="bpmn:DataInputAssociation"||vt.type==="bpmn:DataOutputAssociation").map(vt=>(vt.source===Ne?vt.target:vt.source).x))),gt=new Set(We.map(Ne=>Ne.id)),mt=(Qe.children??[]).filter(vr).filter(Ne=>!gt.has(Ne.id));let Lt=wt;for(const Ne of[...We].sort((vt,Fn)=>vt.x-Fn.x)){let vt=Lt;for(let Fn=0;Fn<100;Fn++){const Gn=mt.find(Xt=>vt<Xt.x+Xt.width+Mi&&vt+Ne.width+Mi>Xt.x&&Ne.y<Xt.y+Xt.height&&Ne.y+Ne.height>Xt.y);if(!Gn)break;vt=Gn.x+Gn.width+Mi}vt!==Ne.x&&n.moveElements([Ne],{x:vt-Ne.x,y:0}),Lt=vt+Ne.width+Mi}const Be=Lt+150-(Qe.x+Qe.width);Be>0&&Bu(Qe,Qe.width+Be);const Mt={assoc:nE(),overlaps:oE(Qe),crosses:rE()};if(Mt.assoc>=we.assoc||Mt.overlaps>we.overlaps||Mt.crosses>we.crosses){for(const{st:Ne,x:vt}of ot)Ne.x!==vt&&n.moveElements([Ne],{x:vt-Ne.x,y:0});Be>0&&Bu(Qe,Qe.width-Be);for(const Ne of Me){const vt=Ne.x-Ne.label.x,Fn=Ne.y-Ne.label.y;(vt!==0||Fn!==0)&&n.moveElements([Ne.label],{x:vt,y:Fn})}}}}const cE=(b,C)=>{const M=C.target===b,D=f(C.source),I=f(C.target),L=M?"bpmn:DataOutputAssociation":"bpmn:DataInputAssociation";n.connect(D,I,C.id?{type:L,businessObject:i.create(L,{id:C.id})}:{type:L})},lE=b=>{for(const C of h){if(!C.participant.blackBox)continue;const M=p(C.participant.id);if(!M)continue;const D=[];for(const L of x){const H=L.flow.source===C.participant.id?L.flow.target:L.flow.target===C.participant.id?L.flow.source:void 0,F=H?p(H):void 0;F&&typeof F.x=="number"&&F.type!=="bpmn:Participant"&&D.push(F)}if(!D.length)continue;if(!b&&C.order===void 0){const L=(()=>{var F;const H=new Map;for(const N of D){const q=d(N);if(!q)continue;const Y=H.get(q.id);Y?Y.n+=1:H.set(q.id,{shape:q,n:1})}return(F=[...H.values()].sort((N,q)=>q.n-N.n)[0])==null?void 0:F.shape})();if(L){const H=q=>q.reduce((Y,oe)=>Y+oe,0)/q.length,F=H(D.map(q=>q.y+q.height/2))<L.y+L.height/2,N=o.filter(q=>q.type==="bpmn:Participant"&&q.id!==C.participant.id&&q.id!==L.id).filter(q=>F?q.y+q.height<=L.y+5:q.y>=L.y+L.height-5);if(N.length){const q=[...N.reduce((ce,ve)=>ce.set(ve.y,(ce.get(ve.y)??0)+1),new Map)].sort((ce,ve)=>ve[1]-ce[1]||(F?ve[0]-ce[0]:ce[0]-ve[0]))[0][0],Y=Math.min(M.width,zR),oe=GR,J=D.map(ce=>ce.x+ce.width/2),de=Math.round(H(J)-Y/2),pe=Math.max(...J)+Op,ge=ce=>({x:ce,width:Math.max(Y,pe-ce)}),tt=N.filter(ce=>Math.min(ce.y+ce.height,q+oe)-Math.max(ce.y,q)>0),Re=ce=>{const ve=ge(ce);return tt.some(Ve=>Ve.x<ve.x+ve.width&&ve.x<Ve.x+Ve.width)},te=ce=>{const ve=ge(ce);return J.filter(Ve=>Ve>=ve.x+10&&Ve<=ve.x+ve.width-10).length},ie=(()=>{if(!Re(de))return de;const ce=te(de);return tt.flatMap(ve=>[ve.x+ve.width+Sg,ve.x-Sg-Y]).map(ve=>Math.round(ve)).filter(ve=>!Re(ve)&&te(ve)>=ce).sort((ve,Ve)=>Math.abs(ve-de)-Math.abs(Ve-de))[0]??de})();if(ie!==M.x||q!==M.y||Y!==M.width||oe!==M.height){const ce=()=>new Set(ht(Xe(o)).map(be=>ut(be))),ve=ce(),Ve={x:M.x,y:M.y,width:M.width,height:M.height};n.resizeShape(M,{x:ie,y:q,width:Y,height:oe});const We=ce(),St=[...We].filter(be=>!ve.has(be)).length,$t=[...ve].filter(be=>!We.has(be)).length;St>$t&&n.resizeShape(M,Ve)}}}}const I=Math.max(...D.map(L=>L.x+L.width/2))+Op;if(I>M.x+M.width&&n.resizeShape(M,{x:M.x,y:M.y,width:I-M.x,height:M.height}),!!b)for(const L of x){const H=p(L.flow.id),F=L.flow.source===C.participant.id?L.flow.target:L.flow.target===C.participant.id?L.flow.source:void 0,N=F?p(F):void 0;if(!H||!N||N.type==="bpmn:Participant")continue;const q=N.x+N.width/2;q<M.x+10||q>M.x+M.width-10||tE(H,M,N)}}};lE(!1);for(const b of x){const C=b.flow;n.connect(f(C.source),f(C.target),{type:"bpmn:MessageFlow",businessObject:i.create("bpmn:MessageFlow",{id:C.id,name:C.name})})}{const M=new Set([...R.map(N=>N.flow.id),...x.map(N=>N.flow.id)].filter(N=>!!N)),D=o.filter(N=>!!N.waypoints),I=(N,q)=>Math.abs(q.x-N.x)<2?"L":Math.abs(q.x-(N.x+N.width))<2?"R":Math.abs(q.y-N.y)<2?"T":Math.abs(q.y-(N.y+N.height))<2?"B":void 0,L=new Map,H=(N,q,Y)=>{if(!N||!q||typeof N.x!="number")return;const oe=I(N,q);if(!oe)return;let J=L.get(N.id);J||L.set(N.id,J=new Map),J.set(oe,[...J.get(oe)??[],Y])};for(const N of D){const q=N.waypoints;!q||q.length<2||(H(N.source,q[0],{id:N.id,dir:"out"}),H(N.target,q[q.length-1],{id:N.id,dir:"in"}))}const F=new Set;for(const[N,q]of L){const Y=p(N);if(!Y||typeof Y.x!="number"||![...q.values()].some(Re=>{const te=Re.filter(ie=>ie.dir==="in");return Re.length>=3&&te.length>=1&&Re.some(ie=>ie.dir==="out")&&te.some(ie=>M.has(ie.id))}))continue;const J=d(Y);if(!J||F.has(J.id)||(J.children??[]).some(Re=>Re.type==="bpmn:Lane"))continue;const de=(CE=q.get("T"))!=null&&CE.length?(AE=q.get("B"))!=null&&AE.length?void 0:"B":"T";if(!de||(de==="T"?Y.y-J.y:J.y+J.height-(Y.y+Y.height))>=O)continue;const ge=(J.children??[]).filter(Re=>!("waypoints"in Re&&Re.waypoints)&&Re.type!=="label"&&typeof Re.x=="number"),tt=J.y+J.height;n.resizeShape(J,{x:J.x,y:J.y,width:J.width,height:J.height+O}),ee(tt,J.id,O),de==="T"&&ge.length&&n.moveElements(ge,{x:0,y:O}),F.add(J.id)}}const Bh=20,uE=4,$N=2,FN=[10,30,80],Jr=()=>{const b=Xe(o);return{bad:ht(b).filter(C=>C.kind==="edge-crosses-shape"||C.kind==="edge-overlap-opposite"||C.kind==="edge-overlap-mixed").length,crossings:Im(b),straight:b.edges.filter(C=>C.type==="bpmn:MessageFlow"&&C.waypoints.length===2).length}},ka=b=>{const C=Xe(o),M=C.edges.find(D=>D.id===b);return M?En(M,ai(C)).length:0},Nu=b=>ka(b)>0,$u=b=>Xe(o).edges.filter(C=>C.type==="bpmn:MessageFlow"&&C.id!==b&&C.waypoints.length===2).length,jN=(b,C,M)=>Vs([{subtree:b,pool:C}],M),pE=(b,C)=>C.bad>b.bad||C.crossings>b.crossings&&C.straight<=b.straight&&C.bad>=b.bad,Oa=(b,C)=>pE(b,C)||C.straight<b.straight,Po=(b,C,M=()=>!0,D=pE,I=!1)=>{const L=Jr(),H=Vs(b,C,I);if(!H)return!1;const F=Jr();return D(L,F)||!M()?(H(),!1):!0},HN=(b,C,M,D=()=>!0)=>Po([{subtree:b,pool:C}],M,D),To=b=>{var C;return!!((C=T.get(b))!=null&&C.node.participant)},Ws=new Map;for(const b of x){if(!To(b.flow.target))continue;const C=Ws.get(b.flow.target)??[];C.push(b),Ws.set(b.flow.target,C)}const Fu=[...Ws.keys()],Nh=new Set(R.map(b=>b.flow.target)),fE=b=>_n.findIndex(({op:C})=>C.participant.id===b);Fu.sort((b,C)=>{var I,L;const M=Nh.has(b)?1:0,D=Nh.has(C)?1:0;return M!==D?M-D:fE((I=T.get(b))==null?void 0:I.node.participant)-fE((L=T.get(C))==null?void 0:L.node.participant)});const eo=b=>b.x+b.width/2,zN=b=>{const C=new Map;for(const I of o.getAll()){const L=I;if(!L.waypoints||!L.source||!L.target)continue;(C.get(L.source.id)??C.set(L.source.id,[]).get(L.source.id)).push(L.target.id)}const M=new Set([b]),D=[b];for(let I=0;I<D.length;I++)for(const L of C.get(D[I])??[])M.has(L)||(M.add(L),D.push(L));return M},GN=(b,C)=>{const M=zN(C);let D;for(const I of o.getAll()){const L=I;if(L.type!=="bpmn:MessageFlow"||!L.source||!L.target||L.target.id!==b||M.has(L.source.id))continue;const H=L.source;if(typeof H.x!="number"||H.type==="bpmn:Participant")continue;const F=eo(H);(D===void 0||F>D)&&(D=F)}return D},$h=(b,C)=>{const M=p(b.flow.source);if(M)return M.type==="bpmn:Participant"?GN(M.id,C):eo(M)},dE=b=>{let C;for(const M of Ws.get(b)??[]){const D=$h(M,b);D!==void 0&&(!C||D>C.cx)&&(C={op:M,cx:D})}return C==null?void 0:C.op},VN=b=>{const C=dE(b),M=p(b),D=C?$h(C,b):void 0;return M&&D!==void 0?D-eo(M):void 0},WN=b=>{const C=VN(b);return C!==void 0&&Math.abs(C)<Bh},Fh=(b,C,M,D,I)=>{var L;for(let H=!0;H;){H=!1;for(const F of x){if(F.flow.id===M)continue;const N=C.has(F.flow.source),q=C.has(F.flow.target);if(N===q||D(N?F.flow.source:F.flow.target))continue;const Y=N?F.flow.target:F.flow.source;if(I(Y)||!To(Y))continue;const oe=p(F.flow.id);if(!(oe!=null&&oe.waypoints)||oe.waypoints.length!==2)continue;const J=p(Y),de=(L=T.get(Y))==null?void 0:L.node.participant;if(!J||!de)continue;const pe=Mo(Y,ge=>ge.x>=J.x).filter(ge=>!C.has(ge.id));if(!(!pe.length||pe.some(ge=>I(ge.id)))){for(const ge of pe)C.add(ge.id);b.set(de,[...b.get(de)??[],...pe]),H=!0}}}return[...b].map(([H,F])=>({subtree:F,pool:f(H)}))},hE=(b,C,M,D,I)=>Fh(new Map([[C,[...b]]]),new Set(b.map(L=>L.id)),D,L=>L===M,L=>L===I),jh=b=>{const C=dE(b);if(!C)return null;const M=p(b),D=p(C.flow.source),I=$h(C,b);if(!M||!D||I===void 0)return null;const L=I-eo(M);if(L>=Bh){const H=T.get(b).node.participant,F=Mo(b,N=>N.x>=M.x);return{groups:hE(F,H,b,C.flow.id,C.flow.source),dx:L}}if(-L>=Bh&&To(C.flow.source)){const H=T.get(C.flow.source).node.participant,F=Mo(C.flow.source,N=>N.x>=D.x&&!WN(N.id));return{groups:hE(F,H,C.flow.source,C.flow.id,b),dx:-L}}return null},mE=()=>Fu.map(b=>({id:b,plan:jh(b)})).filter(b=>!!b.plan).sort((b,C)=>Math.min(...b.plan.groups.flatMap(M=>M.subtree.map(D=>D.x)))-Math.min(...C.plan.groups.flatMap(M=>M.subtree.map(D=>D.x)))).map(b=>b.id);for(let b=0;b<3;b++){const C=Jr(),M=[];for(const I of mE()){const L=jh(I);if(!L)continue;const H=Vs(L.groups,L.dx);H&&M.push(H)}if(!M.length)break;if(!Oa(C,Jr()))continue;for(const I of M.reverse())I();let D=!1;for(const I of mE()){const L=jh(I);L&&Po(L.groups,L.dx,()=>!0,Oa)&&(D=!0)}if(!D)break}for(const b of Fu){if(Nh.has(b))continue;const C=T.get(b);if(!C||C.node.lane!==void 0)continue;const M=K(C);if(M===void 0)continue;const D=p(b),I=D?d(D):void 0;if(!D||!I)continue;const L=I.y+Q+S(`pool:${C.node.participant??""}`,M)*O,H=L-(D.y+D.height/2);H!==0&&!rt(I,D,D.x+D.width/2,L)&&n.moveElements([D],{x:0,y:H})}for(const b of Fu.flatMap(C=>Ws.get(C)??[])){if(!Nu(b.flow.id))continue;const C=p(b.flow.target);if(!C)continue;const M=f(T.get(b.flow.target).node.participant),D=Mo(b.flow.target,F=>F.x>=C.x),I=C.width+j,L=ka(b.flow.id),H=$u(b.flow.id);for(let F=1;F<=uE;F++){const N=()=>ka(b.flow.id)<L&&$u(b.flow.id)>=H;if(HN(D,M,I*F,N))break}}const Hh=x.map(b=>({id:b.flow.id,source:b.flow.source,target:b.flow.target,preexisting:!1})),gE=new Set(Hh.map(b=>b.id));for(const b of o.filter(C=>C.type==="bpmn:MessageFlow"))gE.has(b.id)||!b.source||!b.target||b.source.type==="bpmn:Participant"!=(b.target.type==="bpmn:Participant")&&Hh.push({id:b.id,source:b.source.id,target:b.target.id,preexisting:!0});for(const b of Hh){if(!Nu(b.id))continue;const C=p(b.source),M=p(b.target);if(!C||!M)continue;let D,I,L;if(b.preexisting){const[F,N]=C.type==="bpmn:Participant"?[M,C]:[C,M];if(D=eo(F),D<N.x||D>N.x+N.width)continue;[I,L]=F.y<N.y?[F.y+F.height,N.y]:[N.y+N.height,F.y]}else{if(C.type==="bpmn:Participant"||M.type==="bpmn:Participant"||(D=C.x+C.width/2,Math.abs(D-(M.x+M.width/2))>15))continue;[I,L]=C.y<M.y?[C.y+C.height,M.y]:[M.y+M.height,C.y]}const H=[...T.values()].map(F=>p(F.node.id)).filter(F=>!!F&&F.id!==C.id&&F.id!==M.id).filter(F=>F.x<=D&&D<=F.x+F.width&&F.y+F.height>I&&F.y<L).sort((F,N)=>F.x-N.x);for(const F of H){const N=(ME=T.get(F.id))==null?void 0:ME.node.participant,q=N?p(N):void 0;if(!N||!q)continue;const Y=[...T.values()].filter(ie=>ie.node.participant===N).map(ie=>ie.node.id),oe=ie=>ie.map(ce=>p(ce)).filter(ce=>!!ce),de=[DN(F.id,ie=>{var ce;return((ce=T.get(ie.id))==null?void 0:ce.node.participant)===N}),oe(Y)].filter(ie=>ie.length).map(ie=>[{subtree:ie,pool:q}]);if(b.preexisting){const ie=oe(Y);ie.length&&de.push(Fh(new Map([[N,[...ie]]]),new Set(ie.map(ce=>ce.id)),b.id,()=>!1,ce=>ce===C.id||ce===M.id))}const pe=F.width+j,ge=ka(b.id),tt=$u(b.id),Re=()=>ka(b.id)<ge&&$u(b.id)>=tt;let te=!1;for(const ie of de){for(let ce=1;ce<=uE;ce++)if(Po(ie,pe*ce,Re)){te=!0;break}if(te)break}if(!Nu(b.id))break}}const ju=()=>{var C;const b=new Set;for(const M of ht(Xe(o)))M.kind!=="edge-crosses-shape"||gE.has(M.edge)||((C=p(M.edge))==null?void 0:C.type)==="bpmn:MessageFlow"&&b.add(`${M.edge}>${M.shape}`);return b},UN=(b,C)=>Jr().bad>=b&&[...ju()].some(M=>!C.has(M)),yE=b=>{var C,M;return ka(b)===0&&((M=(C=p(b))==null?void 0:C.waypoints)==null?void 0:M.length)===2},qN=(b,C,M)=>{const D=new Set(b.flatMap(L=>L.subtree.map(H=>H.id))),I=[...ju()].filter(L=>!M.has(L)).map(L=>L.split(">")[1]);return[...new Set(I)].filter(L=>D.has(L)&&L!==C.source&&L!==C.target)},YN=(b,C,M,D,I)=>{const L=b.map(q=>({...q,subtree:q.subtree.filter(Y=>!I.includes(Y.id))})).filter(q=>q.subtree.length),H=new Set(L.flatMap(q=>q.subtree.map(Y=>Y.id))),F=()=>I.every(q=>{const Y=p(q);return!!Y&&R.filter(oe=>oe.flow.target===q&&H.has(oe.flow.source)).every(oe=>{const J=p(oe.flow.source);return!!J&&J.x+J.width<=Y.x})});return Po(L,C,()=>yE(M.id)&&[...ju()].every(q=>D.has(q))&&F(),Oa,!0)};for(const b of x){if(!Nu(b.flow.id))continue;const C=p(b.flow.id);if(((PE=C==null?void 0:C.waypoints)==null?void 0:PE.length)!==2)continue;const M=p(b.flow.source),D=p(b.flow.target);if(!M||!D||M.type==="bpmn:Participant"||D.type==="bpmn:Participant"||!To(b.flow.source)||!To(b.flow.target)||Math.abs(eo(M)-eo(D))>$N)continue;const I=eo(M),L=C.waypoints.map(ge=>ge.y),[H,F]=[Math.min(...L),Math.max(...L)],N=ai(Xe(o)).filter(ge=>ge.id!==M.id&&ge.id!==D.id&&ge.x<I&&I<ge.x+ge.width&&H<ge.y+ge.height&&ge.y<F);if(!N.length)continue;const q=(TE=T.get(b.flow.source))==null?void 0:TE.node.participant,Y=(kE=T.get(b.flow.target))==null?void 0:kE.node.participant;if(!q||!Y)continue;const oe=new Map;for(const[ge,tt,Re]of[[b.flow.source,M,q],[b.flow.target,D,Y]]){const te=oe.get(Re)??[],ie=Mo(ge,ce=>ce.x>=tt.x).filter(ce=>!te.some(ve=>ve.id===ce.id));oe.set(Re,[...te,...ie])}const J=new Set([...oe.values()].flat().map(ge=>ge.id)),de=Fh(oe,J,b.flow.id,ge=>ge===b.flow.source||ge===b.flow.target,()=>!1),pe=Math.max(...N.map(ge=>ge.x+ge.width));for(const ge of FN){const tt=pe+ge-I;if(tt<=0)continue;const Re=Jr().bad,te=ju();let ie=[],ce=!0;const ve=()=>!yE(b.flow.id)||ce&&(ie=qN(de,b.flow,te),ie.length)?!1:!UN(Re,te);if(Po(de,tt,ve,Oa))break;if(ie.length&&(YN(de,tt,b.flow,te,ie)||(ce=!1,Po(de,tt,ve,Oa))))break}}{const b=M=>M.y+M.height/2,C=[];for(const M of T.keys()){if(!To(M))continue;const D=R.filter(H=>H.flow.target===M);if(D.length!==1)continue;const I=p(D[0].flow.source),L=p(M);!I||!L||!T.has(I.id)||Math.abs(b(I)-b(L))>1||L.x-(I.x+I.width)<=j+1||C.push({id:M,pred:I,node:L})}C.sort((M,D)=>M.node.x-D.node.x);for(const{id:M}of C){const D=T.get(M),I=p(M),L=p(R.find(J=>J.flow.target===M).flow.source);if(!I||!L)continue;const H=I.x-(L.x+L.width);if(H<=j+1)continue;const F=f(D.node.participant),N=Mo(M,J=>J.x>=I.x),q=Jr(),Y=jN(N,F,-(H-j));if(!Y)continue;const oe=Jr();(oe.bad>q.bad||oe.crossings>=q.crossings||oe.straight<q.straight)&&Y()}}lE(!0);const KN=10,XN=400,ZN=b=>[...b.incoming??[],...b.outgoing??[]].filter(C=>C.type==="bpmn:DataInputAssociation"||C.type==="bpmn:DataOutputAssociation").map(C=>C.source===b?C.target:C.source).filter(C=>!!C&&typeof C.y=="number"),QN=o.filter(b=>b.type==="bpmn:DataStoreReference"&&g.has(b.id)),JN=(b,C)=>{const M=b.x+b.width/2,D=b.y+b.height/2;let I;for(const L of QN){if((d(L)??u())!==C||L.y<b.y+b.height)continue;const H=Math.abs(L.x+L.width/2-M);H>XN||H<L.width||!ZN(L).some(N=>N.height===b.height&&Math.abs(N.y+N.height/2-D)<=KN&&L.y>=N.y+N.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 C=b.associations??[],M=C.map(L=>L.source===b.dataStore.id?L.target:L.source).map(p).find(Boolean),D=M?d(M)??u():u(),I=M?{x:M.x+M.width/2,y:JN(M,D)??M.y+M.height+110}:{x:200,y:_t+60};n.createShape({type:"bpmn:DataStoreReference",businessObject:i.create("bpmn:DataStoreReference",{id:b.dataStore.id,name:b.dataStore.name})},I,D);for(const L of C)cE(b.dataStore.id,L)}for(const b of v){const M=f(b.association.target).type==="bpmn:DataStoreReference"?b.association.target:b.association.source;cE(M,b.association)}let vE=0;const ko=10,bE=40,e$=(b,C)=>{const M=C.map(N=>d(N)).filter(N=>!!N);for(const N of M){const q=ko,Y=N.y,oe=N.y+N.height,J=N.x,de=N.x+N.width;if(Math.abs(b.y-Y)<q){const pe=Y+q-b.y;b.y+=pe,b.height-=pe}if(Math.abs(b.y+b.height-oe)<q&&(b.height=oe-q-b.y),Math.abs(b.x-J)<q){const pe=J+q-b.x;b.x+=pe,b.width-=pe}Math.abs(b.x+b.width-de)<q&&(b.width=de-q-b.x)}if(!M.length)return;const D=Math.min(...M.map(N=>N.y)),I=Math.max(...M.map(N=>N.y+N.height)),L=D-b.y,H=b.y+b.height-I,F=bE-ko;if(L>0!=H>0)if(L>0&&L<F){const N=L+ko;b.y+=N,b.height-=N}else H>0&&H<F&&(b.height-=H+ko)},t$=(b,C)=>{const M=ko,D=30,I=o.filter(L=>L.type==="bpmn:Group"&&L.id!==C);for(const L of I){const H=L.x,F=L.x+L.width,N=L.y,q=L.y+L.height,Y=b.y<q&&N<b.y+b.height,oe=b.x<F&&H<b.x+b.width;if(Y){if(Math.abs(b.x-F)<M){const J=Math.min(F+M-b.x,D);J>0&&b.width-J>0&&(b.x+=J,b.width-=J)}if(Math.abs(b.x+b.width-H)<M){const J=Math.min(b.x+b.width-(H-M),D);J>0&&b.width-J>0&&(b.width-=J)}}if(oe){if(Math.abs(b.y-q)<M){const J=Math.min(q+M-b.y,D);J>0&&b.height-J>0&&(b.y+=J,b.height-=J)}if(Math.abs(b.y+b.height-N)<M){const J=Math.min(b.y+b.height-(N-M),D);J>0&&b.height-J>0&&(b.height-=J)}}}},zh=(b,C)=>{const M=bE,D=Math.min(...b.map(N=>N.x))-M,I=Math.min(...b.map(N=>N.y))-M,L=Math.max(...b.map(N=>N.x+N.width))+M,H=Math.max(...b.map(N=>N.y+N.height))+M,F={x:D,y:I,width:L-D,height:H-I};return e$(F,b),t$(F,C),F};for(const b of E){const C=(b.group.members??[]).map(p).filter(I=>!!I);let M;C.length?M=zh(C,b.group.id):(M={x:300+vE*350,y:40,width:300,height:200},vE++);const D=n.createShape({type:"bpmn:Group",businessObject:i.create("bpmn:Group",{id:b.group.id}),width:M.width,height:M.height},{x:M.x+M.width/2,y:M.y+M.height/2},u());b.group.name&&n.updateLabel(D,b.group.name),(OE=b.group.members)!=null&&OE.length&&k(D,"bwl:Members",{refs:b.group.members.join(" ")})}{const b=o.filter(I=>!!I.waypoints),C=new Map,M=(I,L)=>{!I||!L||(C.has(I)||C.set(I,new Set),C.get(I).add(L))};for(const I of b){const L=(DE=I.source)==null?void 0:DE.id,H=(LE=I.target)==null?void 0:LE.id;M(L,H),((IE=I.type)!=null&&IE.includes("DataOutputAssociation")||(BE=I.type)!=null&&BE.includes("DataInputAssociation")||I.type==="bpmn:Association")&&M(H,L)}const D=o.filter(I=>I.type==="bpmn:Group");for(const I of D){const H=(((NE=I.businessObject.extensionElements)==null?void 0:NE.values)??[]).find(Re=>Re.$type==="bwl:Members"),F=((H==null?void 0:H.refs)??"").split(" ").filter(Boolean);if(!F.length)continue;const N=new Set(F),q=[...F];for(;q.length;){const Re=q.shift();for(const te of C.get(Re)??[])N.has(te)||(N.add(te),q.push(te))}const Y=I.x,oe=I.x+I.width,J=I.y,de=I.y+I.height,pe=Re=>R.filter(te=>te.flow.target===Re).length,ge=Re=>{var ie;const te=((ie=p(Re))==null?void 0:ie.type)??"";if(te==="bpmn:StartEvent"&&pe(Re)===0)return!1;if(te.endsWith("Gateway")){const ce=R.filter(ve=>ve.flow.target===Re).map(ve=>ve.flow.source);if(ce.length&&ce.every(ve=>{var Ve;return((Ve=p(ve))==null?void 0:Ve.type)==="bpmn:StartEvent"&&pe(ve)===0}))return!1}return!0},tt=o.filter(Re=>vr(Re)).filter(Re=>Re.type!=="bpmn:Group"&&Re.type!=="bpmn:Participant"&&Re.type!=="bpmn:TextAnnotation"&&!N.has(Re.id)&&To(Re.id)&&ge(Re.id)&&Re.x<oe&&Re.x+Re.width>Y&&Re.y<de&&Re.y+Re.height>J);if(tt.length)for(const Re of[-1,1]){const te=tt.filter(xe=>(xe.x+xe.width-Y<=oe-xe.x?-1:1)===Re);if(!te.length)continue;const ie=[];for(const xe of te){const ae=ie.find(ye=>ye.some(Le=>xe.y<Le.y+Le.height&&xe.y+xe.height>Le.y));ae?ae.push(xe):ie.push([xe])}const ce=new Map;for(const xe of ie){let ae=Re<0?Y-ko:oe+ko;for(const ye of[...xe].sort((Le,Ye)=>Re<0?Ye.x-Le.x:Le.x-Ye.x)){const Le=Re<0?Math.min(ye.x,ae-ye.width):Math.max(ye.x,ae);ae=Re<0?Le-Mi:Le+ye.width+Mi,Le!==ye.x&&Math.sign(Le-ye.x)===Re&&ce.set(ye.id,Le-ye.x)}}const ve=new Map,Ve=xe=>ve.get(xe)===xe||!ve.get(xe)?xe:Ve(ve.get(xe));for(const xe of te)ve.set(xe.id,xe.id);for(const xe of x){const ae=ce.has(xe.flow.source)?xe.flow.source:void 0,ye=ce.has(xe.flow.target)?xe.flow.target:void 0;if(!ae||!ye)continue;const Le=p(xe.flow.id);(($E=Le==null?void 0:Le.waypoints)==null?void 0:$E.length)===2&&ve.set(Ve(ae),Ve(ye))}const We=new Map;for(const xe of te){if(!ce.has(xe.id))continue;const ae=Ve(xe.id);We.set(ae,[...We.get(ae)??[],xe])}const St=[...We.values()].sort((xe,ae)=>Re<0?Math.min(...xe.map(ye=>ye.x))-Math.min(...ae.map(ye=>ye.x)):Math.max(...ae.map(ye=>ye.x))-Math.max(...xe.map(ye=>ye.x))),$t=[];let be=!0;for(const xe of St){const ae=xe.map(Ye=>ce.get(Ye.id)??0).reduce((Ye,ke)=>Math.abs(ke)>Math.abs(Ye)?ke:Ye,0),ye=new Map;let Le=!0;for(const Ye of xe){const ke=d(Ye);if(!ke){Le=!1;break}ye.has(ke.id)||ye.set(ke.id,{subtree:[],pool:ke}),ye.get(ke.id).subtree.push(Ye)}Le&&Po([...ye.values()],ae,()=>!0,Oa)?$t.push({shapes:xe,dx:ae}):be=!1}if(!be)for(const xe of $t.reverse())n.moveElements(xe.shapes,{x:-xe.dx,y:0})}}}{const b=new Set([...E.map(C=>C.group.id),...Qt(e,"group.update").map(C=>C.id)]);for(const C of o.filter(M=>M.type==="bpmn:Group")){if(b.has(C.id))continue;const D=(((FE=C.businessObject.extensionElements)==null?void 0:FE.values)??[]).find(F=>F.$type==="bwl:Members"),I=((D==null?void 0:D.refs)??"").split(" ").filter(Boolean).map(p).filter(F=>!!F);!I.length||!I.some(F=>{const N=g.get(F.id);return!N||N.x!==F.x||N.y!==F.y})||!I.some(F=>F.x<C.x||F.y<C.y||F.x+F.width>C.x+C.width||F.y+F.height>C.y+C.height)||n.resizeShape(C,zh(I,C.id))}}{const C=new Map(co(Xe(o)).map(F=>[F.owner,F.rect])),M=o.filter(F=>!!F.waypoints),D=new Map,I=(F,N)=>{!F||!N||(D.has(F)||D.set(F,new Set),D.get(F).add(N))};for(const F of M){const N=(jE=F.source)==null?void 0:jE.id,q=(HE=F.target)==null?void 0:HE.id;I(N,q),((zE=F.type)!=null&&zE.includes("DataOutputAssociation")||(GE=F.type)!=null&&GE.includes("DataInputAssociation")||F.type==="bpmn:Association")&&I(q,N)}const L=F=>R.filter(N=>N.flow.target===F).length,H=F=>{var q;const N=((q=p(F))==null?void 0:q.type)??"";if(N==="bpmn:StartEvent"&&L(F)===0)return!1;if(N.endsWith("Gateway")){const Y=R.filter(oe=>oe.flow.target===F).map(oe=>oe.flow.source);if(Y.length&&Y.every(oe=>{var J;return((J=p(oe))==null?void 0:J.type)==="bpmn:StartEvent"&&L(oe)===0}))return!1}return!0};for(const F of o.filter(N=>N.type==="bpmn:Group")){const q=(((VE=F.businessObject.extensionElements)==null?void 0:VE.values)??[]).find(ae=>ae.$type==="bwl:Members"),Y=((q==null?void 0:q.refs)??"").split(" ").filter(Boolean);if(!Y.length)continue;const oe=Y.map(p).filter(ae=>!!ae);if(!oe.length||!(E.some(ae=>ae.group.id===F.id)||Qt(e,"group.update").some(ae=>ae.id===F.id)||oe.some(ae=>{const ye=g.get(ae.id);return!ye||ye.x!==ae.x||ye.y!==ae.y})))continue;const de=new Set(Y),pe=[...Y];for(;pe.length;){const ae=pe.shift();for(const ye of D.get(ae)??[])de.has(ye)||(de.add(ye),pe.push(ye))}const ge=F.x,tt=F.x+F.width,Re=F.y,te=F.y+F.height,ie=ae=>{const ye=C.get(ae.id),Le={x:ae.x,y:ae.y,width:ae.width,height:ae.height};return ye?[Le,{x:ye.x,y:ye.y,width:ye.width,height:ye.height}]:[Le]},ce=oe.flatMap(ie),ve=Math.min(...ce.map(ae=>ae.x)),Ve=Math.max(...ce.map(ae=>ae.x+ae.width)),We=Math.min(...ce.map(ae=>ae.y)),St=Math.max(...ce.map(ae=>ae.y+ae.height)),$t={L:ve-ge,R:tt-Ve,T:We-Re,B:te-St},be=o.filter(ae=>vr(ae)).filter(ae=>ae.type!=="bpmn:Group"&&ae.type!=="bpmn:Participant"&&ae.type!=="bpmn:TextAnnotation"&&!de.has(ae.id)&&H(ae.id)&&ae.x<tt&&ae.x+ae.width>ge&&ae.y<te&&ae.y+ae.height>Re);if(!be.length)continue;const xe={L:0,R:0,T:0,B:0};for(const ae of be){const ye=ie(ae),Le=Math.min(...ye.map(Me=>Me.x)),Ye=Math.max(...ye.map(Me=>Me.x+Me.width)),ke=Math.min(...ye.map(Me=>Me.y)),He=Math.max(...ye.map(Me=>Me.y+Me.height)),Qe={L:Ye-ge,R:tt-Le,T:He-Re,B:te-ke},we=["L","R","T","B"].filter(Me=>Qe[Me]<=$t[Me]+.001);if(!we.length)continue;const ot=we.reduce((Me,wt)=>Qe[wt]<Qe[Me]?wt:Me,we[0]);xe[ot]=Math.max(xe[ot],Math.min(Qe[ot]+10,$t[ot]))}!xe.L&&!xe.R&&!xe.T&&!xe.B||n.resizeShape(F,{x:F.x+xe.L,y:F.y+xe.T,width:F.width-xe.L-xe.R,height:F.height-xe.T-xe.B})}}const xE=b=>{const C=b.waypoints;if(C!=null&&C.length){const D=C[Math.floor((C.length-1)/2)];return{x:D.x,y:D.y,width:0,height:0}}const M=b;return{x:M.x,y:M.y,width:M.width,height:M.height}};let Us=0;const _E=12,wE=14,n$=15,i$=300,r$=b=>{const C=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 J1(e){e=W({format:!1,preamble:!0},e||{});function t(n,i){var r=i||new Z1,o=new Q1(r,e.format);e.preamble&&o.append(N1);var a=new Bt,s=n.$model;if(a.getNamespaces().mapDefaultPrefixes(eS(s)),a.build(n).serializeTo(o),!i)return r.value}return{toXML:t}}function eS(e){const t=e.config&&e.config.nsMap||{},n={};for(const i in up)n[i]=up[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 cc(e,t){pi.call(this,e,t)}cc.prototype=Object.create(pi.prototype),cc.prototype.fromXML=function(e,t,n){Vn(t)||(n=t,t="bpmn:Definitions");var i=new hp(W({model:this,lax:!0},n)),r=i.handler(t);return i.fromXML(e,r)},cc.prototype.toXML=function(e,t){var n=new J1(t);return new Promise(function(i,r){try{var o=n.toXML(e);return i({xml:o})}catch(a){return r(a)}})};var tS="BPMN20",nS="http://www.omg.org/spec/BPMN/20100524/MODEL",iS="bpmn",rS=[],oS=[{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"}]}],aS=[{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"}]}],sS={tagAlias:"lowerCase",typePrefix:"t"},cS={name:tS,uri:nS,prefix:iS,associations:rS,types:oS,enumerations:aS,xml:sS},lS="BPMNDI",uS="http://www.omg.org/spec/BPMN/20100524/DI",pS="bpmndi",fS=[{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"]}],dS=[{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"}]}],hS=[],mS={name:lS,uri:uS,prefix:pS,types:fS,enumerations:dS,associations:hS},gS="DC",yS="http://www.omg.org/spec/DD/20100524/DC",vS="dc",bS=[{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}]}],xS=[],_S={name:gS,uri:yS,prefix:vS,types:bS,associations:xS},wS="DI",ES="http://www.omg.org/spec/DD/20100524/DI",SS="di",RS=[{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"}]}],CS=[],AS={tagAlias:"lowerCase"},MS={name:wS,uri:ES,prefix:SS,types:RS,associations:CS,xml:AS},PS="bpmn.io colors for BPMN",TS="http://bpmn.io/schema/bpmn/biocolor/1.0",kS="bioc",OS=[{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"}]}],DS=[],LS=[],IS={name:PS,uri:TS,prefix:kS,types:OS,enumerations:DS,associations:LS},BS="BPMN in Color",NS="http://www.omg.org/spec/BPMN/non-normative/color/1.0",$S="color",FS=[{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"}]}],jS=[],HS=[],zS={name:BS,uri:NS,prefix:$S,types:FS,enumerations:jS,associations:HS};const GS={bpmn:cS,bpmndi:mS,dc:_S,di:MS,bioc:IS,color:zS};function xm(e,t){const n=W({},GS,e);return new cc(n,t)}const VS={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"}},lc={[em]:VS,[Wu]:Kh};function _m(){return xm(lc)}const wm=_m();async function Ho(e){const{rootElement:t,warnings:n}=await wm.fromXML(e,"bpmn:Definitions");return{definitions:t,warnings:n}}async function WS(e){const{xml:t}=await wm.toXML(e,{format:!0});return t}function yp(e){return e.map(t=>typeof t=="string"?t:t.message??String(t))}const zo={cjkEm:.865,upperEm:.68,lowerEm:.5,digitEm:.556,spaceEm:.278,otherEm:.35,ascentEm:.9,descentEm:.25},US=/[ᄀ-ᇿ -〿-ヿ㐀-鿿가--⦆]/;function qS(e){const t=zo;return US.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 Go(e,t){let n=0;for(const i of e)n+=t*qS(i);return n}function Em(e=globalThis,{textMeasurement:t="approximate"}={}){if(!(e!=null&&e.SVGElement))throw new Error("installHeadlessBpmnDom: DOM 전역이 없다 — jsdom window 를 전역에 올린 뒤 호출할 것");t==="approximate"&&YS(e),KS(e),XS(e),ZS(e)}function YS(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:Go(r,o),fontBoundingBoxAscent:o*zo.ascentEm,fontBoundingBoxDescent:o*zo.descentEm,actualBoundingBoxAscent:o*zo.ascentEm,actualBoundingBoxDescent:o*zo.descentEm}}};t.getContext=()=>n}function KS(e){if(e.SVGMatrix)return;class t{constructor(){ui(this,"a",1);ui(this,"b",0);ui(this,"c",0);ui(this,"d",1);ui(this,"e",0);ui(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 XS(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 ZS(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:Go(n,12),height:14}})}const uc=new Set(["bpmn:Participant","bpmn:Lane","bpmn:Group","bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),QS=new Set(["bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),JS=1,pc=new Set(["bpmn:TextAnnotation","bpmn:DataStoreReference","bpmn:DataObjectReference","bpmn:DataInput","bpmn:DataOutput"]),eR=2;function ut(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 Sm=20,fc=5,Rm=3,tR=8,Vo=15,vp=50,Cm=12,nR=Cm*1.2;function bp(e,t){const n=t.split(/\r?\n/),i=Math.max(...n.map(o=>Go(o,Cm))),r=n.length*nR;return{x:e.x+e.width/2-i/2,y:e.y+e.height/2-r/2,width:i,height:r}}const Am=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 Wo(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)>Am)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>=Sm&&(!n||l>n.length)&&(n={axis:a.axis,length:l,kind:c})}return n}function xp(e){return e.kind==="edge-overlap-opposite"||e.kind==="edge-overlap-mixed"||e.kind==="edge-overlap-unrelated"}function Mm(e,t){const n=Wo(e,t);return n&&n.kind==="opposite"?{axis:n.axis,length:n.length}:null}function iR(e,t){let n=0;for(const i of t)i.id!==e.id&&Mm(e,i)&&n++;return n}function ri(e,t){let n=0;for(const i of t)i.id!==e.id&&Wo(e,i)&&n++;return n}const Pm=15,Tm=20;function rR(e,t){const n=t.axis==="v"?[e.x,e.x+e.width]:[e.y,e.y+e.height];if(t.at<n[0]-Tm||t.at>n[1]+Tm)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 _p=20;function dc(e,t){const n=[];for(const i of t){if(i.axis!==e.axis||Math.abs(i.at-e.at)>Am)continue;const r=Math.max(e.lo,i.lo),o=Math.min(e.hi,i.hi);o-r<Sm||n.push([r-_p,o+_p])}return n}function hc(e,t){const n=e.label;if(!n)return null;let i=null;for(const r of gn(e)){const o=rR(n,r);if(o){for(const a of t)if(a.id!==e.id&&!(i&&a.id>=i.other)){for(const[s,c]of dc(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 oR=10,aR=1,sR=(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 cR(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 wp(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 lR=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Uo=1;function Fi(e,t){const n=e.x+Uo,i=e.x+e.width-Uo,r=e.y+Uo,o=e.y+e.height-Uo;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 qo(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 km(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(qo(i).some(r=>Fi(n,r)))return i.id;return null}function En(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(cR(e.waypoints[o],e.waypoints[o+1],r,eR)){i.push(r);break}}return i}const $a=(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))},uR=(e,t,n,i)=>Dm(e,t,n,i)?0:Math.min($a(e,n,i),$a(t,n,i),$a(n,e,t),$a(i,e,t)),Om=(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 mc(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,$a({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(Om(e,s)||Om(t,s))return 0;let c=1/0;for(let l=0;l<s.length;l++)c=Math.min(c,uR(e,t,s[l],s[(l+1)%s.length]));return c}function Dm(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 Lm=(e,t)=>e.endpoints.some(n=>t.endpoints.includes(n));function Fa(e,t){let n=0;for(const i of t){if(i.id===e.id||Lm(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++)Dm(e.waypoints[o],e.waypoints[o+1],i.waypoints[a],i.waypoints[a+1])&&(r=!0);r&&n++}return n}function oi(e,t){let n=0;for(const i of t)i.id===e.id||Lm(e,i)||Fa(e,[i])>0&&(n+=i.type===e.type?2:1);return n}function Im(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++)Fa(n[i],[n[r]])>0&&(t+=n[i].type===n[r].type?2:1);return t}function gc(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)if(Fa(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 Bm(e){const t=gc(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:pR(e)}}function pR(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 Nm(e,t,n){const i=new Set(t.flatMap(r=>[...r.members]));return e.shapes.filter(r=>!r.container&&!pc.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 $m(e){var n;const t=(n=Dt(e==null?void 0:e.extensionElements))==null?void 0:n.values;if(Array.isArray(t))for(const i of t){const r=Dt(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 Fm=e=>e?{members:e}:{},ai=e=>e.shapes.filter(t=>!t.container);function fR(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 dR(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 jm(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(qo(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 Hm=3;function zm(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 ja(e,t){const n=[];for(const i of t.shapes){if(i.container||pc.has(i.type))continue;const r=zm(e,i);r>=Hm&&n.push({shape:i.id,depth:r})}return n.sort((i,r)=>i.shape.localeCompare(r.shape))}function ht(e,t={}){const n=[],i=e.shapes.filter(m=>!m.container);for(const m of e.edges)for(const v of En(m,i))n.push({kind:"edge-crosses-shape",edge:m.id,shape:v.id});const r=e.shapes.filter(m=>m.container&&QS.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 En(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(O=>O.id===_);if(!T||T.container)continue;const k=Math.max(T.x-E.x,E.x-(T.x+T.width),0),B=Math.max(T.y-E.y,E.y-(T.y+T.height),0),P=Math.hypot(k,B);P>oR&&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=(k,B)=>k.x<=B.x&&k.y<=B.y&&k.x+k.width>=B.x+B.width&&k.y+k.height>=B.y+B.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(!wp(_,E,JS))continue;const T=_.id<E.id?[_.id,E.id]:[E.id,_.id];n.push({kind:"shape-overlap",shapes:T,identical:lR(_,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),k=Math.min(_.y+_.height,E.y+E.height)-Math.max(_.y,E.y);if(T<=fc||k<=fc)continue;const B=_.id<E.id?[_.id,E.id]:[E.id,_.id],P=new Set(E.members);if(_.members.some(j=>P.has(j))){const j=Nm(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)});j.length&&n.push({kind:"group-overlap-unreadable",reason:"orphan",groups:B,shapes:j});continue}const O=_.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:B,...O?{container:O}:{}})}const c=new Set(s.flatMap(m=>[...m.members])),l=m=>e.shapes.filter(v=>!v.container&&!pc.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,k=!1,B=!1;for(const P of e.edges){if(P.type!=="bpmn:SequenceFlow"||!P.source||!P.target)continue;const O=E.has(P.source),j=E.has(P.target);!O&&j&&!v.has(P.source)?T=!0:O&&!j&&!v.has(P.target)?k=!0:O&&j&&(B=!0)}T&&k&&B&&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<=fc||T.bottom-T.y<=fc)continue;const k=Nm(e,[],T);if(!k.length)continue;const B=E.map(P=>P.id).sort();n.push({kind:"group-stack-unreadable",groups:B,shapes:k})}for(const m of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of e.shapes){if(v.container||v.attached||pc.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,k,B,P]of _){const O=k==="h"?v.x:v.y,j=k==="h"?v.x+v.width:v.y+v.height;if(!(O<P&&B<j))continue;const Q=k==="h"?v.y:v.x,me=k==="h"?v.y+v.height:v.x+v.width;if(!(Q<T&&T<me))continue;const Pe=Math.min(T-Q,me-T);Pe<tR||n.push({kind:"group-cuts-shape",group:m.id,shape:v.id,side:E,depth:Pe})}}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,k=E.y+E.height,B=v.endpoints.some(O=>{const j=m.get(O);return!!j&&E.x<j.x&&j.x<T&&E.y<j.y&&j.y<k});let P=null;for(const O of _){const[j,Q,me]=O.axis==="v"?[E.y,k,[["left",E.x],["right",T]]]:[E.x,T,[["top",E.y],["bottom",k]]],Pe=Math.min(O.hi,Q)-Math.max(O.lo,j);if(Pe<vp)continue;const De=O.axis==="v"?E.x<O.at&&O.at<T:E.y<O.at&&O.at<k;if(!(De&&B))for(const[Ke,rt]of me){const Ae=Math.abs(O.at-rt);Ae<=Vo&&(!P||Ae<P.distance)&&(P={side:Ke,inside:De,distance:Ae,length:Pe})}}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[k,B,P,O]of T)O&&Math.abs(B-P)<=Rm&&n.push({kind:"group-on-container-boundary",group:m.id,container:v.id,side:k})}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,k=_.y<E.y+E.height&&E.y<_.y+_.height,B=[["x",_.x+_.width,E.x,k],["x",E.x+E.width,_.x,k],["y",_.y+_.height,E.y,T],["y",E.y+E.height,_.y,T]];for(const[P,O,j,Q]of B)if(Q&&Math.abs(O-j)<=Rm){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=Wo(_,E);if(!T)continue;const k=_.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:k,axis:T.axis,length:Math.round(T.length)})}for(const m of e.edges){if(!m.label)continue;const v=hc(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=km(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 ja(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=jm(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)||wp(m.label,_,Uo)&&n.push({kind:"pool-name-over-label",pool:m.id,label:v});const R=co(e);for(const m of i)if(m.type==="bpmn:TextAnnotation")for(const{owner:v,rect:_}of R)v!==m.id&&wp(m,_,Uo)&&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??fR(m,e,x);if(!v)continue;const _=x.get(v);!_||!_.container||sR(_,m,aR)||m.type==="bpmn:TextAnnotation"&&!dR(m,_,e)||n.push({kind:"shape-outside-container",shape:m.id,container:_.id})}return n.sort((m,v)=>ut(m).localeCompare(ut(v)))}const Dt=e=>typeof e=="object"&&e!==null?e:void 0,Ut=e=>typeof e=="number"?e:0,tr=e=>{const t=Dt(e);return typeof(t==null?void 0:t.id)=="string"?t.id:void 0};function hR(e){const t=Dt(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 mR(e){const t=Dt(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 gR(e,t){const n=Dt(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(uc.has(i)&&i!=="bpmn:Lane"&&i!=="bpmn:Group")return tr(n)}function Gm(e){var a,s,c,l,u;const t=[],n=[],i=((a=Dt(e))==null?void 0:a.diagrams)??[],r=new Map,o=new Set;for(const p of((s=Dt(e))==null?void 0:s.rootElements)??[]){const f=Dt(p);if((f==null?void 0:f.$type)==="bpmn:Collaboration")for(const d of f.participants??[]){const g=Dt(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=Dt((c=Dt(p))==null?void 0:c.plane),d=(f==null?void 0:f.planeElement)??[];for(const g of d){const h=Dt(g);if(!h)continue;const y=Dt(h.bpmnElement),R=typeof(y==null?void 0:y.id)=="string"?y.id:void 0;if(!R)continue;const x=typeof(y==null?void 0:y.$type)=="string"?y.$type:"",m=Dt(h.bounds);if(m){const _=h.isExpanded===!1&&x!=="bpmn:Participant",E=Dt((l=Dt(h.label))==null?void 0:l.bounds),T={id:R,type:x,x:Ut(m.x),y:Ut(m.y),width:Ut(m.width),height:Ut(m.height),container:uc.has(x)&&!_,attached:(y==null?void 0:y.attachedToRef)!==void 0,...y?{parent:gR(y,r)}:{},...E?{label:{x:Ut(E.x),y:Ut(E.y),width:Ut(E.width),height:Ut(E.height)}}:{},...x==="bpmn:Group"?Fm($m(y)):{}},k=h.isHorizontal!==!1,B=typeof(y==null?void 0:y.name)=="string"?y.name:"";o.has(R)&&k&&B&&(T.label=bp(T,B)),t.push(T);continue}const v=h.waypoint;if(Array.isArray(v)){const _=Dt((u=Dt(h.label))==null?void 0:u.bounds);n.push({id:R,type:x,waypoints:v.map(E=>{var T,k;return{x:Ut((T=Dt(E))==null?void 0:T.x),y:Ut((k=Dt(E))==null?void 0:k.y)}}),endpoints:hR(y),...mR(y),..._?{label:{x:Ut(_.x),y:Ut(_.y),width:Ut(_.width),height:Ut(_.height)}}:{}})}}}return{shapes:t,edges:n}}function Vm(e){return ht(Gm(e),{includeObservationOnly:!0})}async function yR(e){const{definitions:t,warnings:n}=await Ho(e);return{findings:Vm(t),warnings:n}}function Xe(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=Dt(o.label),y=tr(o.source),R=tr(o.target);n.push({id:o.id,type:a,waypoints:s.map(x=>({x:Ut(x.x),y:Ut(x.y)})),endpoints:[y,R].filter(x=>!!x),...y&&R?{source:y,target:R}:{},...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=Dt(o.businessObject),l=Dt(o.label);let u=Dt(o.parent);for(;u&&u.type==="bpmn:Lane";)u=Dt(u.parent);const p=typeof(u==null?void 0:u.type)=="string"?u.type:"",f=u&&uc.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:uc.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"?Fm($m(c)):{}},g=typeof(c==null?void 0:c.name)=="string"?c.name:"";a==="bpmn:Participant"&&!(c!=null&&c.processRef)&&g&&((i=Dt(o.di))==null?void 0:i.isHorizontal)!==!1&&(d.label=bp(d,g)),t.push(d)}return{shapes:t,edges:n}}const vR={"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 bR(e,t){const n=vR[e];return n||(e==="label"||e.startsWith("bpmndi:")?"other":e.startsWith("bpmn:")&&!("waypoints"in t&&t.waypoints)?"flowNode":"other")}function Wm(e){let t=e.parent;for(;t;){if(t.type==="bpmn:Participant")return t.id;t=t.parent}}function Um(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 bR(i.type,i)},lanesOf:n=>t().filter(i=>i.type==="bpmn:Lane"&&Wm(i)===n).sort((i,r)=>i.y-r.y).map(i=>i.id),participantOf:n=>{const i=e.get(n);return i?Wm(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 Vu(r)},reviewRequestLocalesOf:n=>{const i=e.get(n);return!i||i.type==="label"?[]:xr(i.businessObject).map(r=>r.locale)}}}const Ep=20,xR=4,kt=(e,t)=>Math.abs(e-t)<.5;function yc(e,t,n,i=Ep){if(kt(e.y,t.y)&&!kt(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(kt(e.x,t.x)&&!kt(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 qm(e,t,n,i=Ep){if(n.length<2)return null;if(kt(e.y,t.y)&&!kt(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(kt(e.x,t.x)&&!kt(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 Ym(e,t,n=Ep){if(e.length!==4)return null;const[i,r,o,a]=e;if(kt(i.y,r.y)&&kt(r.x,o.x)&&kt(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(kt(i.x,r.x)&&kt(r.y,o.y)&&kt(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 vc(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 Km=30,_R=[0,-25,25,-40,40];function wR(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+Km:s-Km,l=a?i.y+i.height:i.y,u=n.x+n.width/2,p=i.x+i.width/2;return _R.map(f=>[{x:u,y:s},{x:u,y:c},{x:p+f,y:c},{x:p+f,y:l}])}const Sp=(e,t,n)=>[...e.slice(0,t+1),...n,...e.slice(t+1)],Yo=(e,t,n)=>En({...e,waypoints:t},n).length;function Rp(e,t,n,i){let r=[...e.waypoints],o=Yo(e,r,t);if(o===0)return null;let a=!1;for(const p of vc(e,t))if(Yo(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=>dc(f,s).length>0),l=wR(e,t).filter(p=>Yo(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&&kt(p.y+p.height/2,f.y+f.height/2)){const d=[r[0],r[r.length-1]];if(kt(d[0].y,d[1].y)&&!kt(d[0].x,d[1].x)){const g=t.filter(x=>!e.endpoints.includes(x.id)&&En({...e,waypoints:d},[x]).length>0),h=g.length>=2?qm(d[0],d[1],g):null,R=(h?h.map(x=>[d[0],...x,d[1]]):g.length===1?(yc(d[0],d[1],g[0])??[]).map(x=>[d[0],...x,d[1]]):g.length===0?[d]:[]).filter(x=>Yo(e,x,t)===0&&x.length<=r.length).sort((x,m)=>Number(u(m))-Number(u(x)));if(R.length)return R.find(x=>!c(x))??R[0]}}}for(let p=0;p+1<r.length;p++){const f=r[p],d=r[p+1],g=t.filter(R=>!e.endpoints.includes(R.id)&&En({...e,waypoints:[f,d]},[R]).length>0);if(g.length<2)continue;const h=qm(f,d,g);if(!h)continue;const y=h.map(R=>Sp(r,p,R)).filter(R=>Yo(e,R,t)===0).sort((R,x)=>Number(u(x))-Number(u(R)));if(y.length)return y.find(R=>!c(R))??y[0]}for(let p=0;p<xR&&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)||En({...e,waypoints:[g,h]},[y]).length===0)continue;const R=yc(g,h,y),x=R?R.map(v=>Sp(r,d,v)):Ym(r,y)??[];if(!x.length)continue;const m=[...x].sort((v,_)=>Number(u(_))-Number(u(v)));for(const v of m){const _=Yo(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 Cp(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=ai(o),s=new Set,c=ht(o).filter(u=>u.kind==="edge-crosses-shape"&&!t.has(ut(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=Rp(p,a,g,o.edges);if(!h){En(p,a).some(m=>m.type==="bpmn:TextAnnotation")&&s.add(u);continue}const y=o.edges.filter(m=>m.id!==u),R=ri(p,y);ri({...p,waypoints:h},y)>R||r.updateWaypoints(f,h)}return s}const ER=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},Ap=(e,t)=>Fa(e,[t])>0;function Xm(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=ai(o);let s=o;const c=new Set(ht(o).map(ut));for(const[l,u]of gc(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(B=>B.id===p),g=s.edges.find(B=>B.id===f);if(!d||!g)continue;const h=i.get(p);if(!h)continue;const y=h.parent,R=y&&typeof y.x=="number"&&typeof y.width=="number"?{x:y.x,y:y.y,width:y.width,height:y.height}:void 0,x=ER(g),m=[...vc(d,a)??[]],v=Rp(d,[...a,...x],R,o.edges);v&&m.push(v);for(let B=0;B+1<d.waypoints.length;B++)for(const P of x)for(const O of yc(d.waypoints[B],d.waypoints[B+1],P)??[])m.push(Sp(d.waypoints,B,O));const _=s.edges.filter(B=>B.id!==p),E=B=>({...s,edges:s.edges.map(P=>P.id===p?{...P,waypoints:B}:P)}),T=B=>!R||B.every(P=>P.x>=R.x&&P.x<=R.x+R.width&&P.y>=R.y&&P.y<=R.y+R.height),k=m.find(B=>{const P={...d,waypoints:B};return Ap(P,g)||!T(B)||_.some(O=>O.id!==f&&!Ap(d,O)&&Ap(P,O))?!1:ht(E(B)).every(O=>c.has(ut(O)))});if(k){r.updateWaypoints(h,k),s=E(k);break}}}const SR=10;function Zm(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 Qm(e,t){if(e.waypoints.length<2||e.endpoints.length!==2)return null;const n=t.shapes.filter(j=>j.type==="bpmn:Participant"&&j.container),i=t.shapes.find(j=>j.id===e.endpoints[0]),r=t.shapes.find(j=>j.id===e.endpoints[1]);if(!i||!r)return null;const o=Zm(i,n),a=Zm(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(j=>j.id!==o.id&&j.id!==a.id&&j.y>=c.y+c.height&&j.y+j.height<=l.y).sort((j,Q)=>j.y-Q.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,R=e.waypoints[0],x=e.waypoints[e.waypoints.length-1],m=ai(t),v=t.edges.filter(j=>j.id!==e.id),_=oi(e,v),E=En(e,m).length;if(_===0&&E===0||E===0&&e.waypoints.length===2)return null;const T=Math.min(...u.map(j=>j.x)),k=Math.max(...u.map(j=>j.x+j.width)),B=(R.x+x.x)/2,P=j=>j.filter((Q,me)=>me===0||!(kt(Q.x,j[me-1].x)&&kt(Q.y,j[me-1].y)));let O;for(let j=T;j<=k;j+=SR){const Q=P([R,{x:R.x,y:h},{x:j,y:h},{x:j,y},{x:x.x,y},x]),me={...e,waypoints:Q};if(En(me,m).length>0)continue;const Pe=oi(me,v),De=Math.abs(j-B);(!O||Pe<O.cross||Pe===O.cross&&De<O.detour)&&(O={pts:Q,cross:Pe,detour:De})}return O&&(E>0?O.cross<=_:O.cross<_)?O.pts:null}function Jm(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Xe(n);for(const o of r.edges){if(o.type!=="bpmn:MessageFlow"||t.has(o.id))continue;const a=Xe(n),s=a.edges.find(u=>u.id===o.id);if(!s)continue;const c=Qm(s,a);if(!c)continue;const l=n.get(o.id);l&&i.updateWaypoints(l,c)}}const ji=[25,-25,40,-40],Ko=35;function RR(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)-Ko:Math.max(e.y+e.height,t.y+t.height)+Ko;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 bc(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 RR(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-Ko:n.y+n.height+Ko,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,R=s?i.y+i.height+Ko:i.y-Ko;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:R},{x:m,y:R},{x:m,y}],cost:h+Math.abs(x)+Math.abs(v)})}}return p}const xc=30;function eg(e,t){for(let n=1;n<e.length-2;n++){const i=e[n],r=e[n+1],o=kt(i.y,r.y)&&!kt(i.x,r.x),a=kt(i.x,r.x)&&!kt(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)<xc||Math.abs(i.y-(s.y+s.height))<xc)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)<xc||Math.abs(i.x-(s.x+s.width))<xc)return!0}}return!1}const _c=40;function CR(e,t,n){let i=0;for(const r of t){if(r.container||n.includes(r.id))continue;const o=r.x-_c,a=r.x+r.width+_c,s=r.y-_c,c=r.y+r.height+_c;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 tg(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=ai(t),o=t.edges.filter(E=>E.id!==e.id),a=ri(e,o),s=oi(e,o),c=E=>CR(E,t.shapes,e.endpoints)+(eg(E,n)?1:0),l=c(e.waypoints),u=E=>{if(!E)return;const T=E.x+E.width/2,k=E.y+E.height/2;return n.find(B=>B.type==="bpmn:Lane"&&T>=B.x&&T<=B.x+B.width&&k>=B.y&&k<=B.y+B.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 k=E[T],B=E[T+1];if(kt(k.y,B.y)&&!kt(k.x,B.x)&&k.y>f.y&&k.y<f.y+f.height)return!0}return!1},h=g(e.waypoints),R=(E=>{if(!E)return;const T=E.x+E.width/2,k=E.y+E.height/2;return n.filter(B=>B.type==="bpmn:Participant"&&T>=B.x&&T<=B.x+B.width&&k>=B.y&&k<=B.y+B.height).sort((B,P)=>B.width*B.height-P.width*P.height)[0]})(i.get(e.endpoints[0]??"")),x=E=>{if(!R)return 0;let T=0;for(let k=1;k<E.length-1;k++){const B=E[k];(B.x<R.x||B.x>R.x+R.width||B.y<R.y||B.y>R.y+R.height)&&T++}return T},m=x(e.waypoints);if(!eg(e.waypoints,n)&&!(d&&!h)&&m===0)return null;const v=E=>E.reduce((T,k,B)=>B?T+Math.abs(k.x-E[B-1].x)+Math.abs(k.y-E[B-1].y):0,0);let _;for(const{pts:E,cost:T}of bc(e,i)){const k={...e,waypoints:E};if(En(k,r).length>0)continue;const B=ri(k,o);if(B>a)continue;const P=x(E);if(P>m)continue;const O=P<m&&B===0;if(!O&&oi(k,o)>s)continue;const j=c(E),Q=g(E);if(!O&&!(Q&&!h)&&j>=l)continue;const Pe=Q?0:1,De=v(E);(!_||P<_.out||P===_.out&&(Pe<_.lane||Pe===_.lane&&(B<_.opp||B===_.opp&&(j<_.sc||j===_.sc&&(T<_.cost||T===_.cost&&De<_.len)))))&&(_={pts:E,out:P,sc:j,lane:Pe,opp:B,cost:T,len:De})}return(_==null?void 0:_.pts)??null}function AR(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 MR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(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=Xe(i),c=s.edges.find(y=>y.id===a);if(!c||c.waypoints.length<4)continue;const l=ai(s),u=s.edges.filter(y=>y.id!==a),p=En(c,l).length,f=ri(c,u),d=oi(c,u),g=n.has(a)?new Set(ht(s).map(ut)):null,h=vc(c,s.shapes);h.length===2&&AR(c,s)&&h.reverse();for(const y of h){if(y.length>=c.waypoints.length)continue;const R={...c,waypoints:y};if(En(R,l).length>p||ri(R,u)>f||oi(R,u)>d)continue;if(g){const m=new Set(ht({...s,edges:s.edges.map(E=>E.id===a?R:E)}).map(ut)),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 ng(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Xe(n).edges.filter(o=>o.type==="bpmn:SequenceFlow"&&!t.has(o.id)).map(o=>o.id).sort();for(const o of r){const a=Xe(n),s=a.edges.find(u=>u.id===o);if(!s)continue;const c=tg(s,a);if(!c)continue;const l=n.get(o);l&&i.updateWaypoints(l,c)}}function Mp(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=kt(n[0].x,n[1].x)&&!kt(n[0].y,n[1].y),s=kt(n[n.length-1].x,n[n.length-2].x)&&!kt(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 PR(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 R of[0,...ji])Math.abs(R)<i.width/2-5&&y.push({pts:[{x:f,y:l},{x:u+R,y:l},{x:u+R,y:h}],cost:Math.abs(R)}),Math.abs(R)<i.height/2-5&&y.push({pts:[{x:c,y:d},{x:c,y:p+R},{x:g,y:p+R}],cost:Math.abs(R)});return y}function Pp(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 ig(e,t){const n=new Map(t.shapes.map(d=>[d.id,d])),i=ai(t),r=t.edges.filter(d=>d.id!==e.id),o=ri(e,r);if(o===0)return null;const a=oi(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=[...bc(e,n),...Pp(e,n),...Mp(e,n)];for(const{pts:d,cost:g}of f){const h={...e,waypoints:d};if(En(h,i).length>0)continue;const y=ri(h,r),R=oi(h,r),x=o-y+(p-u(d));if(y>=o||R-a>x)continue;const m=c(d);(!s||y<s.opposite||y===s.opposite&&(R<s.cross||R===s.cross&&(g<s.cost||g===s.cost&&m<s.len)))&&(s={pts:d,opposite:y,cross:R,cost:g,len:m})}return(s==null?void 0:s.pts)??null}function rg(e,t){var i;let n=0;for(const r of t)r.id!==e.id&&((i=Wo(e,r))==null?void 0:i.kind)==="unrelated"&&n++;return n}function TR(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=ai(t),r=t.edges.filter(f=>f.id!==e.id),o=rg(e,r);if(o===0)return null;const a=ri(e,r),s=oi(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=[...bc(e,n),...Pp(e,n),...PR(e,n),...Mp(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(En(g,i).length>0)continue;const h=rg(g,r);if(h>=o)continue;const y=ri(g,r);if(y-h>a-o)continue;const R=oi(g,r);if(R-s>(o-h)*l)continue;const x=c(f);(!u||h<u.fake||h===u.fake&&(y<u.unreadable||y===u.unreadable&&(R<u.cross||R===u.cross&&(d<u.cost||d===u.cost&&x<u.length))))&&(u={pts:f,fake:h,unreadable:y,cross:R,cost:d,length:x})}return(u==null?void 0:u.pts)??null}function og(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=ht(Xe(i)).filter(s=>s.kind==="edge-overlap-unrelated"&&!t.has(ut(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=Xe(i),l=c.edges.find(f=>f.id===s);if(!l)continue;const u=TR(l,c);if(!u)continue;const p=i.get(s);p&&r.updateWaypoints(p,u)}}function ag(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 sg(e,t,n){var l;if(e.type!=="bpmn:SequenceFlow"||t.type!=="bpmn:SequenceFlow"||((l=Wo(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:ag(e,n)&&ag(t,n)}function cg(e,t,n){let i=0;for(const r of t)r.id!==e.id&&sg(e,r,n)&&i++;return i}function kR(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=ai(t),r=t.edges.filter(f=>f.id!==e.id),o=cg(e,r,n);if(o===0)return null;const a=ri(e,r),s=oi(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=[...bc(e,n),...Pp(e,n),...Mp(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(En(g,i).length>0)continue;const h=cg(g,r,n);if(h>=o)continue;const y=ri(g,r);if(y-h>a-o)continue;const R=oi(g,r);if(R-s>(o-h)*l)continue;const x=c(f);(!u||h<u.chain||h===u.chain&&(y<u.unreadable||y===u.unreadable&&(R<u.cross||R===u.cross&&(d<u.cost||d===u.cost&&x<u.length))))&&(u={pts:f,chain:h,unreadable:y,cross:R,cost:d,length:x})}return(u==null?void 0:u.pts)??null}function OR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=new Map(o.shapes.map(l=>[l.id,l])),s=ht(o).filter(l=>l.kind==="edge-overlap-opposite"&&!t.has(ut(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||!sg(u,p,a)))for(const f of l.edges)n.has(f)||c.add(f)}for(const l of[...c].sort()){const u=Xe(i),p=u.edges.find(g=>g.id===l);if(!p)continue;const f=kR(p,u);if(!f)continue;const d=i.get(l);d&&r.updateWaypoints(d,f)}}function lg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=ht(o).filter(u=>xp(u)&&!t.has(ut(u)));if(!a.length)return;const s=new Set;for(const u of a)if(xp(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=Xe(i),f=p.edges.find(h=>h.id===u);if(!f)continue;const d=ig(f,p);if(!d)continue;const g=i.get(u);g&&r.updateWaypoints(g,d)}}const DR=10,LR=(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 ug(e,t){const n=e.label;if(!n)return null;const i=t.edges.filter(a=>a.id!==e.id);if(!hc(e,i))return null;const r=ai(t),o=i.flatMap(gn);for(const a of gn(e)){let s=[[a.lo,a.hi]];for(const[d,g]of dc(a,o))s=s.flatMap(([h,y])=>{const R=[];return d>h&&R.push([h,Math.min(y,d)]),g<y&&R.push([Math.max(h,g),y]),R.filter(([x,m])=>m>x)});const c=a.axis==="h"?n.width:n.height,l=s.find(([d,g])=>g-d>=c+DR*2);if(!l)continue;const u=(l[0]+l[1])/2,p=a.axis==="h"?{x:u,y:a.at-Pm}:{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(!hc({...e,label:f},i)&&!r.some(d=>!e.endpoints.includes(d.id)&&LR(f,d)))return f}return null}const Sn=8;function Tp(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(qo)],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 pg=30,IR=(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},fg=(e,t)=>IR({x:e.x+e.width/2,y:e.y+e.height/2},t);function BR(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(qo)],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))&&!ja(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 dg(e,t){var a,s;const{elementRegistry:n}=e,i=e.modeling;let r=Xe(n),o=new Set(ht(r).map(ut));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(O=>O.id===c);if(!(E!=null&&E.label)||!ja(E.label,r).length)continue;let T={...E.label,x:l.label.x,y:l.label.y};if((ja(T,r).length||fg(T,E.waypoints)>pg)&&(T=null),!T&&fg(E.label,E.waypoints)>pg&&(T=BR(E,r)),!T)continue;const k=T,B={...r,edges:r.edges.map(O=>O.id===c?{...O,label:k}:O)},P=ht(B);if(P.some(O=>!o.has(ut(O))))continue;i.moveElements([f],{x:k.x-f.x,y:k.y-f.y}),r=B,o=new Set(P.map(ut));continue}const y=l.label.x+d-f.x,R=l.label.y+g-f.y;if(y===0&&R===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+R},v={...r,edges:r.edges.map(E=>E.id===c?{...E,label:m}:E)},_=ht(v);_.some(E=>!o.has(ut(E)))||(i.moveElements([f],{x:y,y:R}),r=v,o=new Set(_.map(ut)))}}function hg(e,t,n=new Set){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i);for(const a of o.edges){if(!a.label||t.has(a.id)&&!n.has(a.id))continue;const s=Tp(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 mg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Xe(i),a=ht(o).filter(s=>s.kind==="label-on-shared-segment"&&!t.has(ut(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=ug(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 gg(e,t){const n=e.label;if(!n)return null;const i=[...t.edges.flatMap(gn),...t.shapes.filter(f=>f.container).flatMap(qo)],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 yg(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Xe(n);for(const o of r.shapes){if(o.container||!o.label||t.has(o.id))continue;const a=gg(o,Xe(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 NR(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 vg(e,t){const{elementRegistry:n}=e,i=e.modeling;let r=Xe(n),o=new Set(ht(r).map(ut));const a=[...new Set(ht(r).filter(s=>s.kind==="edge-endpoint-detached"&&!t.has(ut(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 R=h?r.shapes.find(m=>m.id===h):void 0;if(!R)continue;const x=NR(R,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=ht(f);if(d.some(h=>!o.has(ut(h))))continue;const g=n.get(s);g&&(i.updateWaypoints(g,l),r=f,o=new Set(d.map(ut)))}}const kp=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function bg(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 $R(e,t,n){const i=[],r=n?La(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 bg(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(!kp(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 fi(e,t,n){const i=t==="text"?"texts":"names",{[i]:r,...o}=e;return n===void 0?o:{...o,[t]:n}}function FR(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(kp(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=bg(c,t);if(!l.length){s.push(c);continue}switch(c.kind){case"participant.add":{const[u,...p]=l,f=fi(c.participant,"name",a(u));c.participant.lanes&&(f.lanes=c.participant.lanes.map((d,g)=>fi(d,"name",a(p[g])))),s.push({...c,participant:f});break}case"participant.update":{const[u,...p]=l,f=fi(c,"name",a(u));c.lanes&&(f.lanes=c.lanes.map((d,g)=>fi(d,"name",a(p[g])))),s.push(f);break}case"node.add":s.push({...c,node:fi(c.node,"name",a(l[0]))});break;case"sequenceFlow.add":s.push({...c,flow:fi(c.flow,"name",a(l[0]))});break;case"messageFlow.add":s.push({...c,flow:fi(c.flow,"name",a(l[0]))});break;case"dataStore.add":s.push({...c,dataStore:fi(c.dataStore,"name",a(l[0]))});break;case"annotation.add":s.push({...c,annotation:fi(c.annotation,"text",a(l[0]))});break;case"group.add":s.push({...c,group:fi(c.group,"name",a(l[0]))});break;case"annotation.update":s.push(fi(c,"text",a(l[0])));break;default:s.push(kp(l[0].map)?fi(c,"name",a(l[0])):(a(l[0]),c))}}return{ops:s,writes:i}}const jR=/^[\p{L}_][\p{L}\p{N}_.\-]*$/u,xg=new Set(["sequenceFlow","messageFlow","dataAssociation","association"]),_g={"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}]},Ha=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),wc=e=>typeof e=="string"&&e!=="";function HR(e){const t=[];function n(i,r,o,a){if(a===null){wc(o)||t.push({kind:"payload-invalid",opIndex:i,field:r});return}if(!Ha(o)){t.push({kind:"payload-invalid",opIndex:i,field:r});return}for(const s of a)wc(o[s])||t.push({kind:"payload-invalid",opIndex:i,field:`${r}.${s}`})}return e.forEach((i,r)=>{var o,a,s;if(!Ha(i)||!wc(i.kind)||!(i.kind in _g)){t.push({kind:"payload-invalid",opIndex:r,field:"kind"});return}for(const c of _g[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(!Ha(f))break;f=f[g]}if(!Ha(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;Ha(c)&&!wc(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"&&!Uh(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&&!qh(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 wg(e,t,n={}){const i=HR(e);if(i.length>0)return i;const r=[],o=new Map,a=new Map;function s(h,y,R){if(!jR.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,{...R,opIndex:h})}e.forEach((h,y)=>{var R;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"}),(R=h.association)!=null&&R.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,R,x){const m=c(y);if(m===void 0){r.push({kind:"ref-missing",opIndex:h,ref:y,role:R});return}if(x&&!x.includes(m)){r.push({kind:"ref-category",opIndex:h,ref:y,role:R,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 R;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&&((((R=o.get(x))==null?void 0:R.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"]),k=u(y,v,"target",["flowNode"]);T&&k&&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),k=l(v);T!==void 0&&T===k&&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&&xg.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&&xg.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(...$R(e,t,n.i18n)),r;function g(h,y,R){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(R&&x!==R){r.push({kind:"ref-category",opIndex:h,ref:y,role:"target",expected:R,actual:x});return}return x}}function Eg(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 Ec(e){return`bpmn:${e[0].toUpperCase()}${e.slice(1)}`}const Sc={"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,zR=300,GR=160,Sg=20,Op=100,Rg=40,VR=10;function Dp(e,t,n,i,r){const o=n,a=(P,O)=>{const[j,Q]=Sc[P];let me={x:t.x+t.width/2+j*(t.width/2+o.width/2+O),y:t.y+t.height/2+Q*(t.height/2+o.height/2+O)};const Pe=i.x+Rn+o.width/2,De=i.x+i.width-Rn-o.width/2,Ke=i.y+Rn+o.height/2,rt=i.y+i.height-Rn-o.height/2,Ae={x:Math.min(De,Math.max(Pe,me.x)),y:Math.min(rt,Math.max(Ke,me.y))};return(Ae.x!==me.x||Ae.y!==me.y)&&(me=Math.abs(Ae.x-(t.x+t.width/2))<(t.width+o.width)/2+Rn&&Math.abs(Ae.y-(t.y+t.height/2))<(t.height+o.height)/2+Rn?{x:t.x+t.width+Rn+o.width/2,y:Ae.y}:Ae),me},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=Xe(e),l=P=>{var j,Q;if(!r.selfId)return!1;const O=e.get(P);return!!O&&(((j=O.source)==null?void 0:j.id)===r.selfId||((Q=O.target)==null?void 0:Q.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 O=f(P);return s.some(j=>O.x0<j.x+j.width&&O.x1>j.x&&O.y0<j.y+j.height&&O.y1>j.y)},g=P=>{const O=f(P);return u.some(j=>j.axis==="h"?j.at>O.y0&&j.at<O.y1&&j.lo<O.x1&&j.hi>O.x0:j.at>O.x0&&j.at<O.x1&&j.lo<O.y1&&j.hi>O.y0)},h=P=>{const O=f(P);return p.some(j=>O.x0<j.x+j.width&&O.x1>j.x&&O.y0<j.y+j.height&&O.y1>j.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}]),R=P=>{const O=f(P);return y.some(j=>j.axis==="h"?j.at>O.y0&&j.at<O.y1&&j.lo<O.x1&&j.hi>O.x0:j.at>O.x0&&j.at<O.x1&&j.lo<O.y1&&j.hi>O.y0)},x=P=>d(P)||g(P)||h(P)||R(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"),O=De=>De.endsWith("left")?De.replace(/left$/,"right"):De.replace(/right$/,"left"),j=r.placement.side,Q=[j,P(j),O(j),P(O(j)),"top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"],me=r.placement.offset??50;let Pe=a(j,me);if(x(Pe)){const De=new Set;for(const Ke of Q){if(De.has(Ke))continue;De.add(Ke);const rt=a(Ke,me);if(m(rt)&&!x(rt)){Pe=rt;break}}}return Pe}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,k=i.y+i.height-Rn-o.height/2;let B={x:Math.min(E,Math.max(_,v.x)),y:Math.min(k,Math.max(T,v.y))};if(x(B)){const P=(t.width+o.width)/2+Rn,j=[{x:B.x+P,y:B.y},{x:B.x-P,y:B.y},{x:B.x,y:B.y-o.height-Rn},{x:B.x,y:B.y+o.height+Rn}].filter(m).find(Q=>!x(Q));j&&(B=j)}return B}function Qt(e,t){return e.filter(n=>n.kind===t)}class Cg extends Error{constructor(t){super(t.kind),this.issue=t,this.name="LowerIssueError"}}function Ag(e,t){var SE,RE,CE,AE,ME,PE,TE,kE,OE,DE,LE,IE,BE,NE,$E,FE,jE,HE,zE,GE,VE,WE,UE;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 C=p(b);if(!C)throw new Error(`하강 참조 해소 실패: ${b}`);return C},d=b=>{let C=b.parent;for(;C;){if(C.type==="bpmn:Participant")return C;C=C.parent}},g=new Map;for(const b of o.filter(C=>!("waypoints"in C&&C.waypoints)&&C.type!=="bpmn:Lane"&&C.type!=="label"&&typeof C.x=="number"))g.set(b.id,{x:b.x,y:b.y});const h=Qt(e,"participant.add"),y=Qt(e,"node.add"),R=Qt(e,"sequenceFlow.add"),x=Qt(e,"messageFlow.add"),m=Qt(e,"dataStore.add"),v=Qt(e,"dataAssociation.add"),_=Qt(e,"annotation.add"),E=Qt(e,"group.add"),T=new Map(y.map(b=>[b.node.id,b])),k=(b,C,M)=>{var F;const D=b.businessObject,I=(((F=D.extensionElements)==null?void 0:F.values)??[]).filter(N=>N.$type!==C),L=M?[...I,i.create(C,M)]:I;if(!L.length){D.extensionElements&&n.updateProperties(b,{extensionElements:void 0});return}const H=i.create("bpmn:ExtensionElements",{values:L});L.forEach(N=>{N.$parent=H}),n.updateProperties(b,{extensionElements:H})},B=b=>({anchor:b.anchor,side:b.side,...b.offset!==void 0?{offset:b.offset}:{}});for(const b of Qt(e,"element.remove")){const C=p(b.id);C&&n.removeElements([C])}const P=b=>o.filter(C=>{var M;return C.type==="bpmn:Lane"&&((M=d(C))==null?void 0:M.id)===b}).sort((C,M)=>C.y-M.y);for(const b of Qt(e,"participant.update")){const C=f(b.id);if(b.name!==void 0&&n.updateProperties(C,{name:b.name??void 0}),!b.lanes)continue;const M=P(b.id);if(!M.length){n.splitLane(C,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 D=new Set(M.map(I=>I.id));b.lanes.forEach((I,L)=>{if(D.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 O=150,j=130,Q=80,me=90,Pe=180,De=30,Ke=30,rt=(b,C,M,D,I)=>{const L=M-C.width/2,H=D-C.height/2;return(b.children??[]).find(F=>!("waypoints"in F&&F.waypoints)&&F.type!=="bpmn:Lane"&&F.type!=="label"&&!(I!=null&&I.has(F.id))&&typeof F.x=="number"&&L<F.x+F.width+Ke&&L+C.width+Ke>F.x&&H<F.y+F.height&&H+C.height>F.y)},Ae=new Set;for(const b of h){Ae.add(`pool:${b.participant.id}`);for(const C of b.participant.lanes??[])Ae.add(C.id)}const X=new Map;for(const b of y){const C=b.node.lane??`pool:${b.node.participant??""}`;let M=X.get(C);M||X.set(C,M=new Set([0])),b.band!==void 0&&M.add(b.band)}const ne=new Map;for(const[b,C]of X){if(!Ae.has(b))continue;const M=[...C].sort((L,H)=>L-H),D=M.map((L,H)=>H===0?0:H%2===1?Math.ceil(H/2):-(H/2)),I=Math.min(...D);ne.set(b,new Map(M.map((L,H)=>[L,D[H]-I])))}{const b=new Map;for(const C of h)(C.participant.lanes??[]).forEach((M,D)=>b.set(M.id,D));for(const[C,M]of ne){if(!b.has(C)||M.size<2)continue;const D=b.get(C),I=M.get(0)??0,L=new Set;for(const J of y){if(J.node.lane!==C||(J.band??0)!==0||!J.node.type.endsWith("Gateway"))continue;const de={in:new Set,out:new Set,cross:new Set};for(const pe of R){const ge=pe.flow.source===J.node.id;if(!ge&&pe.flow.target!==J.node.id)continue;const tt=T.get(ge?pe.flow.target:pe.flow.source);if(!tt||tt.node.participant!==J.node.participant||!tt.node.lane)continue;let Re,te=!1;if(tt.node.lane!==C){const ie=b.get(tt.node.lane);if(ie===void 0)continue;Re=ie>D?"down":"up",te=!0}else{const ie=M.get(tt.band??0)??I;Re=ie>I?"down":ie<I?"up":void 0}Re&&(de[ge?"out":"in"].add(Re),te&&de.cross.add(Re))}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,F=Math.max(...M.values()),N=H==="down"?F:0;if(I===N)continue;const q=[...M.entries()].filter(([J])=>J!==0).sort((J,de)=>J[1]-de[1]),Y=[...Array(F+1).keys()].filter(J=>J!==N),oe=new Map([[0,N]]);q.forEach(([J],de)=>oe.set(J,Y[de])),ne.set(C,oe)}}const U=b=>{var C;return(((C=X.get(b))==null?void 0:C.size)??0)>1},K=b=>b.band??(b.node.lane||!U(`pool:${b.node.participant??""}`)?void 0:0),re=new Map,fe=b=>re.get(b.node.id)??K(b),Te=new Set,$=new Set;{const b=new Map;for(const D of R)b.set(D.flow.target,(b.get(D.flow.target)??0)+1);const C=D=>{const I=[],L=new Set([D]),H=[D];for(;H.length;){const F=H.shift();I.push(F);for(const N of R)N.flow.source!==F||L.has(N.flow.target)||(b.get(N.flow.target)??0)!==1||(L.add(N.flow.target),H.push(N.flow.target))}return I},M=(D,I)=>{var L;return((L=ne.get(D))==null?void 0:L.get(I))??I};for(const D of y){if(!D.node.type.endsWith("Gateway"))continue;const I=D.node.lane??`pool:${D.node.participant??""}`,L=ne.get(I);if(!L||L.size<2)continue;const H=fe(D);if(H===void 0||M(I,H)!==M(I,0))continue;const F=M(I,H),N=R.filter(pe=>pe.flow.source===D.node.id).map(pe=>T.get(pe.flow.target)).filter(pe=>!!pe&&(pe.node.lane??`pool:${pe.node.participant??""}`)===I),q=N.filter(pe=>{const ge=fe(pe);return ge!==void 0&&M(I,ge)===F&&(b.get(pe.node.id)??0)===1}),Y=N.some(pe=>{const ge=fe(pe);return ge!==void 0&&M(I,ge)>F});if(q.length!==1||!Y)continue;const oe=new Set(N.flatMap(pe=>C(pe.node.id)));if(!R.some(pe=>pe.flow.target===D.node.id&&oe.has(pe.flow.source)))continue;const de=new Map;for(const[pe,ge]of L)de.set(pe,ge+1);de.set(-1,0),ne.set(I,de);for(const pe of C(q[0].node.id))T.has(pe)&&(re.set(pe,-1),$.add(pe));Te.add(D.node.id)}}const S=(b,C)=>{var M;return((M=ne.get(b))==null?void 0:M.get(C))??C},w=(b,C,M,D)=>{const I=b?p(b):C?p(C):void 0;if(!I)return!1;const L=b?I.y+Math.min(I.height/2,me):I.y+Q;return Math.abs(L+S(b??`pool:${C??""}`,M)*O-D)<=O/2},G=new Map;for(const[b,C]of X){let M=0;for(const D of C)M=Math.max(M,S(b,D));G.set(b,M)}const V=b=>Pe+O*b,ee=(b,C,M)=>{const D=u().children.filter(I=>!("waypoints"in I&&I.waypoints)&&I.type!=="label"&&I.id!==C&&typeof I.y=="number"&&I.y>=b);D.length&&n.moveElements(D,{x:0,y:M})},Ce=(b,C,M)=>{const D=b.type==="bpmn:Participant"?b:void 0;if(!D||D.children.some(F=>F.type==="bpmn:Lane"))return;const I=M+C.height/2+De-D.y;if(D.height>=I)return;const L=I-D.height,H=D.y+D.height;n.resizeShape(D,{x:D.x,y:D.y,width:D.width,height:I}),ee(H,D.id,L)},Ze=(b,C)=>{const M=C-b.height;if(M<=0)return;const D=d(b)??b,I=[],L=N=>{I.push(N);for(const q of N.children??[])L(q)};L(D);const H=b.y+b.height-10,F=l.calculateAdjustments(I,"y",M,H);l.makeSpace(F.movingShapes,F.resizingShapes,{x:0,y:M},"s",H)},ft=(b,C,M)=>{if(b){const H=f(b),F=V(C);if(H.height>=F)return;const N=F-H.height,q=d(H),Y=q?q.y+q.height:H.y+H.height;Ze(H,F),ee(Y,q==null?void 0:q.id,N);return}if(!M)return;const D=O*(C+1);if(M.height>=D)return;const I=D-M.height,L=M.y+M.height;n.resizeShape(M,{x:M.x,y:M.y,width:M.width,height:D}),ee(L,M.id,I)},Wt=new Map;for(const b of R)Wt.set(b.flow.target,(Wt.get(b.flow.target)??0)+1);const xt=b=>(Wt.get(b)??0)<=1,fn=(b,C)=>{if(!b)return;const M=p(b);if(!M||M.height>=V(C))return;const D=M.y+M.height-10,I=d(M);if(I)return new Set((I.children??[]).filter(L=>L.type!=="bpmn:Lane"&&typeof L.y=="number"&&L.y>D).map(L=>L.id))},xn=(b,C,M)=>{if(!b)return!0;const D=p(b);return D?M-C.height/2>=D.y&&M+C.height/2<=D.y+D.height:!0},_n=h.map((b,C)=>({op:b,declared:C}));_n.sort((b,C)=>{const M=b.op.order??Number.POSITIVE_INFINITY,D=C.op.order??Number.POSITIVE_INFINITY;return M!==D?M-D:b.declared-C.declared});let _t=80;for(const b of o.getAll())b.parent===u()&&"height"in b&&typeof b.y=="number"&&(_t=Math.max(_t,b.y+b.height+60));for(const{op:b}of _n){const C=b.participant,M=y.filter(J=>J.node.participant===C.id).length,D=((SE=C.lanes)==null?void 0:SE.length)??0,I=Math.max(1200,M*160+300),L=(C.lanes??[]).map(J=>V(G.get(J.id)??0)),H=L.reduce((J,de)=>J+de,0);D&&H<300&&(L[D-1]+=300-H);const F=Math.max(300,O*((G.get(`pool:${C.id}`)??0)+1)),N=C.blackBox||M+D===0?120:D?Math.max(300,H):F,q=r.createShape({type:"bpmn:Participant",businessObject:i.create("bpmn:Participant",{id:C.id,name:C.name,...b.order!==void 0?{"bwl:poolOrder":b.order}:{},...C.blackBox?{}:{processRef:i.create("bpmn:Process")}}),width:I,height:N,isExpanded:!0}),Y=n.createShape(q,{x:100+I/2,y:_t+N/2},u()),oe=C.lanes??[];if(oe.length&&n.splitLane(Y,oe.length),oe.length){const J=o.filter(de=>{var pe;return de.type==="bpmn:Lane"&&((pe=d(de))==null?void 0:pe.id)===C.id}).sort((de,pe)=>de.y-pe.y);if(J.forEach((de,pe)=>{const ge=oe[pe];ge&&n.updateProperties(de,{id:ge.id,name:ge.name})}),L.some(de=>de!==Y.height/D)){let de=Y.y;J.forEach((pe,ge)=>{const tt=L[ge];n.resizeShape(pe,{x:pe.x,y:de,width:pe.width,height:tt}),de+=tt})}}_t=Y.y+Y.height+60}const dn=b=>{var D;const C=T.get(b);if(C)return C.node.participant??"";const M=p(b);return M?M.type==="bpmn:Participant"?M.id:((D=d(M))==null?void 0:D.id)??"":""},vn=new Map,Ao=b=>{let C=vn.get(b);return C||vn.set(b,C={nodes:[],flows:[]}),C};for(const b of y)Ao(b.node.participant??"").nodes.push(b);for(const b of R)Ao(dn(b.flow.source)).flows.push(b);const ti=b=>{var C;return i.create("bpmn:SequenceFlow",{id:b.id,name:b.name??((C=b.condition)==null?void 0:C.label)})},Ri=(b,C,M)=>r.createShape({type:Ec(b.type),...b.eventDefinition?{eventDefinitionType:Qs[b.eventDefinition]}:{},businessObject:i.create(Ec(b.type),{id:b.id,name:b.name,...C!==void 0?{"bwl:band":C}:{},...M!==void 0?{"bwl:afterColumn":M}:{}})}),Ci=[..._n.map(({op:b})=>b.participant.id).filter(b=>vn.has(b)),...[...vn.keys()].filter(b=>!h.some(C=>C.participant.id===b))],Kt=b=>b.endsWith("Gateway");for(const b of Ci){const C=vn.get(b),M=b?f(b):void 0,D=M?M.x+150:250;let I=M?M.y+80:120;const L=(te,ie,ce)=>{if(te){const ve=f(te);return ve.y+Math.min(ve.height/2,me)+S(te,ie??0)*O}return ie!==void 0&&M?M.y+Q+S(`pool:${b}`,ie)*O:ce},H=(te,ie,ce)=>{if(te){const ve=f(te);return ve.y+Math.min(ve.height/2,me)+ie*O}return M?M.y+Q+ie*O:ce},F=te=>te.participant?f(te.participant):u(),N=(te,ie,ce,ve,Ve,We,St)=>{const $t=ce!==void 0||ve!==void 0,be=S(ce??`pool:${b}`,ve??0);if((ve===void 0||w(ce,b,ve,St??Number.NaN))&&St!==void 0&&xn(ce,ie,St)&&!rt(te,ie,Ve,St))return{x:Ve,y:St};if($t)for(let ye=0;ye<4;ye++){const Le=H(ce,be+ye,We);if(!rt(te,ie,Ve,Le,fn(ce,be+ye)))return ft(ce,be+ye,M),{x:Ve,y:Le}}const xe=L(ce,ve,We);$t?ft(ce,be,M):Ce(te,ie,xe);let ae=Ve;for(let ye=0;ye<64;ye++){const Le=rt(te,ie,ae,xe);if(!Le)break;ae=Le.x+Le.width+j+ie.width/2}return{x:ae,y:xe}},q=new Set(C.flows.map(te=>te.flow.target)),Y=new Map,oe=te=>{if(te===void 0)return;const ie=o.get(te);if(!(!ie||typeof ie.x!="number"||typeof ie.width!="number"))return ie.x+ie.width+j};for(const te of C.nodes){if(q.has(te.node.id))continue;const ie=Ri(te.node,te.band,te.afterColumn),ce=K(te),ve=te.node.lane?`${te.node.lane}|${ce??""}`:ce!==void 0?`band:${ce}`:"",Ve=F(te.node),We=Y.get(ve)??D,St=oe(te.afterColumn),$t=St===void 0?We:Math.max(We,St),be=N(Ve,ie,te.node.lane,ce,$t,I);n.createShape(ie,be,Ve),Y.set(ve,be.x+ie.width+j),!te.node.lane&&ce===void 0&&(I+=160)}const J=new Set,de=new Map,pe=new Map,ge=new Map;if(b&&Ae.has(`pool:${b}`)){const te=new Map;for(const be of C.flows)te.set(be.flow.target,(te.get(be.flow.target)??0)+1);const ie=be=>L(be.node.lane,fe(be),Number.NaN),ce=new Set,ve=be=>{var ye;const xe=(ye=T.get(be))==null?void 0:ye.node.participant;if(xe)return p(xe);const ae=p(be);if(ae)return ae.type==="bpmn:Participant"?ae:d(ae)},Ve=be=>{const xe=[],ae=new Set([be]),ye=[be];for(;ye.length;){const Le=ye.shift(),Ye=T.get(Le);Ye&&xe.push(Ye);for(const ke of C.flows)ke.flow.source!==Le||ae.has(ke.flow.target)||(te.get(ke.flow.target)??0)!==1||(ae.add(ke.flow.target),ye.push(ke.flow.target))}return xe},We=be=>{if(!M)return;const xe=new Set(be.map(Le=>Le.node.id));let ae=!1,ye=!1;for(const Le of x){if(!xe.has(Le.flow.source))continue;const Ye=ve(Le.flow.target);!Ye||Ye.id===M.id||(Ye.y<M.y?ae=!0:ye=!0)}return ae&&!ye?"up":ye&&!ae?"down":void 0};for(const be of C.nodes){if(!Kt(be.node.type))continue;const xe=L(be.node.lane,K(be),Number.NaN);if(Number.isNaN(xe))continue;const ae=[];for(const ke of C.flows){if(ke.flow.source!==be.node.id)continue;const He=T.get(ke.flow.target);if(!He||He.node.lane!==be.node.lane||(te.get(He.node.id)??0)!==1)continue;const Qe=K(He);if(Qe===void 0)continue;const we=L(He.node.lane,Qe,Number.NaN);if(Number.isNaN(we))continue;const ot=Ve(He.node.id),Me=We(ot);Me&&ae.push({subtree:ot,band:Qe,row:we,dir:Me})}if(!ae.some(ke=>ke.dir==="up")||!ae.some(ke=>ke.dir==="down")||!ae.some(ke=>ke.dir==="up"&&ae.some(He=>He.dir==="down"&&He.row<ke.row)))continue;const Le=[...ae].sort((ke,He)=>ke.row-He.row);[...ae.filter(ke=>ke.dir==="up"),...ae.filter(ke=>ke.dir==="down")].sort((ke,He)=>ke.dir===He.dir?ke.row-He.row:ke.dir==="up"?-1:1).forEach((ke,He)=>{const Qe=Le[He].band;if(Qe!==ke.band){ce.add(be.node.id);for(const we of ke.subtree)K(we)===ke.band&&re.set(we.node.id,Qe)}})}const St=be=>{if(!M)return;const xe=new Set(be.map(Le=>Le.node.id));let ae=!1,ye=!1;for(const Le of x){if(!xe.has(Le.flow.target))continue;const Ye=ve(Le.flow.source);!Ye||Ye.id===M.id||(Ye.y<M.y?ae=!0:ye=!0)}return ae&&!ye?"up":ye&&!ae?"down":void 0};for(const be of C.nodes){if(!Kt(be.node.type))continue;const xe=be.node.lane??`pool:${b}`,ae=ne.get(xe);if(!ae||ae.size<2)continue;const ye=ae.get(0);if(ye===void 0)continue;const Le=Math.max(...ae.values()),Ye=ye===Le&&ye!==0?"down":void 0;if(!Ye)continue;const ke=[];for(const Me of C.flows){if(Me.flow.source!==be.node.id)continue;const wt=T.get(Me.flow.target);if(!wt||wt.node.lane!==be.node.lane||(te.get(wt.node.id)??0)!==1)continue;const gt=fe(wt);gt!==void 0&&ke.push({t:wt,subtree:Ve(wt.node.id),band:gt})}const He=ke.find(Me=>(ae.get(Me.band)??Me.band)===ye);if(!He||St(He.subtree)===Ye||We(He.subtree)===Ye)continue;const Qe=ke.find(Me=>Me!==He&&St(Me.subtree)===Ye);if(!Qe)continue;const we=He.band,ot=Qe.band;for(const Me of He.subtree)fe(Me)===we&&re.set(Me.node.id,ot);for(const Me of Qe.subtree)fe(Me)===ot&&re.set(Me.node.id,we);ce.add(be.node.id)}for(const be of C.nodes){if(!Kt(be.node.type))continue;const xe=ie(be);if(Number.isNaN(xe)||_.some(ke=>{var He,Qe;return(((He=ke.placement)==null?void 0:He.anchor)??(ke.association?ke.association.source===ke.annotation.id?ke.association.target:ke.association.source:void 0))===be.node.id&&((Qe=ke.placement)==null?void 0:Qe.side.startsWith("bottom"))}))continue;let ye,Le=!1,Ye;for(const ke of C.flows){if(ke.flow.source!==be.node.id)continue;const He=T.get(ke.flow.target);if(!He||!He.node.lane&&K(He)===void 0)continue;const Qe=ie(He);Number.isNaN(Qe)||(Math.abs(Qe-xe)<.5&&(Le=!0),Qe>xe?!ye||Qe>ye.row?ye={id:He.node.id,row:Qe,count:1}:Qe===ye.row&&ye.count++:Qe<xe&&He.node.lane===be.node.lane&&(!Ye||Qe>Ye.row?Ye={op:He,row:Qe,count:1}:Qe===Ye.row&&Ye.count++))}ye&&ye.count===1&&(te.get(ye.id)??0)===1&&!ce.has(be.node.id)&&J.add(ye.id),!Le&&Ye&&Ye.count===1&&(te.get(Ye.op.node.id)??0)===1&&!Te.has(be.node.id)&&de.set(Ye.op.node.id,{lane:be.node.lane,band:fe(be)})}const $t=new Map;for(const be of x)$t.set(be.flow.target,[...$t.get(be.flow.target)??[],be]);for(const be of C.nodes){const xe=$t.get(be.node.id);if(!xe||xe.length!==1||!te.get(be.node.id)||!be.node.lane&&K(be)===void 0||$.has(be.node.id))continue;const ae=(RE=T.get(xe[0].flow.source))==null?void 0:RE.node.participant,ye=ae?p(ae):void 0;if(!ye||!M||ye.id===M.id)continue;const Le=be.node.lane??`pool:${b}`,Ye=ne.get(Le);if(!Ye)continue;const ke=Ye.get(0)??0,He=(Ye.get(fe(be)??0)??ke)-ke;if(He===0)continue;const Qe=ye.y<M.y;if(Qe&&He<0||!Qe&&He>0)continue;let we;for(const[ot,Me]of Ye){const wt=Me-ke;(Qe&&wt<0&&(!we||wt<we.row)||!Qe&&wt>0&&(!we||wt>we.row))&&(we={band:ot,row:wt})}we&&pe.set(be.node.id,{lane:be.node.lane,band:we.band})}}const tt=new Set;let Re=0;for(;Re++<C.nodes.length+2;){for(let ce=0;ce<C.nodes.length+C.flows.length+2;ce++){let ve=!1;for(const Ve of C.flows){const We=Ve.flow;if(tt.has(We.id))continue;const St=p(We.source);if(!St)continue;const $t=p(We.target),be=T.get(We.target);if(!$t&&be){const xe=Ri(be.node,be.band),ae=fe(be);if(be.node.lane||ae!==void 0){const ye=F(be.node),Le=St,Ye=Le.x+(ge.get(We.source)??0)+Le.width+j,ke=de.get(We.target)??pe.get(We.target),He=N(ye,xe,ke?ke.lane:be.node.lane,ke?ke.band:ae,J.has(We.target)?Le.x+Le.width/2:Ye,Number.NaN,ke||!xt(We.target)?void 0:Le.y+Le.height/2),Qe=n.createShape(xe,He,ye);J.has(We.target)&&ge.set(We.target,Ye-(Qe.x+Qe.width/2)),n.connect(St,Qe,{type:"bpmn:SequenceFlow",businessObject:ti(We)})}else s.append(St,xe,{connection:{type:"bpmn:SequenceFlow",businessObject:ti(We)}})}else if($t)n.connect(St,$t,{type:"bpmn:SequenceFlow",businessObject:ti(We)});else continue;tt.add(We.id),ve=!0}if(!ve)break}const te=C.nodes.filter(ce=>!p(ce.node.id));if(!te.length)break;const ie=te[0];{const ce=Ri(ie.node,ie.band),ve=F(ie.node),Ve=K(ie);n.createShape(ce,N(ve,ce,ie.node.lane,Ve,D,I),ve),!ie.node.lane&&Ve===void 0&&(I+=160)}}}const Ai=40,Ta=b=>{const C=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,M=()=>new Set(ht(Xe(o)).filter(Y=>!C(Y)).map(Y=>ut(Y))),D=M(),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 F=M(),N=[...F].filter(Y=>!D.has(Y)).length,q=[...D].filter(Y=>!F.has(Y)).length;N<=q||(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}))},ni=5,st=10,yt=200,Iu=new Set([...R.map(b=>b.flow.id),...x.map(b=>b.flow.id),...Qt(e,"sequenceFlow.update").map(b=>b.id),...Qt(e,"messageFlow.update").map(b=>b.id)].filter(b=>!!b)),ON=(b,C,M,D,I,L)=>{const H=new Set(b.map(te=>te.id)),F=Math.min(...b.map(te=>te.x))+C-st,N=Math.max(...b.map(te=>te.x+te.width))+C+yt+st,q=Math.min(...b.map(te=>te.y+Math.min(0,...M)))-st,Y=Math.max(...b.map(te=>te.y+te.height+Math.max(0,...M)))+st,oe=o.getAll().filter(te=>{if(te.type!=="bpmn:SequenceFlow"&&te.type!=="bpmn:MessageFlow")return!1;const ie=te;return Iu.has(ie.id)||!ie.waypoints||ie.waypoints.length<2||[ie.source,ie.target].some(ve=>!ve||H.has(ve.id)||ve.x>=D)?!1:ie.waypoints.some((ve,Ve)=>{const We=ie.waypoints[Ve+1];return!!We&&Math.max(ve.x,We.x)>=F&&Math.min(ve.x,We.x)<=N&&Math.max(ve.y,We.y)>=q&&Math.min(ve.y,We.y)<=Y})});if(!oe.length)return 0;const J=te=>{const ie=new Map;for(const ce of b)for(const ve of M){const Ve={id:ce.id,type:ce.type,x:ce.x+C+te,y:ce.y+ve,width:ce.width,height:ce.height};for(const We of oe){let St=1/0;for(let be=0;be+1<We.waypoints.length;be++)St=Math.min(St,mc(We.waypoints[be],We.waypoints[be+1],Ve));const $t=`${We.id}|${ce.id}`;ie.set($t,Math.min(ie.get($t)??1/0,St))}}return ie},de=[...J(0)].filter(([,te])=>te<=ni).map(([te])=>te);if(!de.length)return 0;let pe=0;for(let te=1;te<=yt;te++){const ie=J(te);if([...ie.values()].every(ce=>ce>ni)&&de.every(ce=>(ie.get(ce)??1/0)>=st)){pe=te;break}}if(!pe)return 0;const ge=Math.min(...b.map(te=>te.x))+C+pe,tt=new Set(de.map(te=>te.slice(0,te.indexOf("|"))));return oe.some(te=>te.type==="bpmn:SequenceFlow"&&tt.has(te.id)&&te.waypoints.some((ie,ce)=>{const ve=te.waypoints[ce+1];if(!ve||Math.min(ie.y,ve.y)>L||Math.max(ie.y,ve.y)<L||ie.y===ve.y)return!1;const Ve=ie.x+(L-ie.y)*(ve.x-ie.x)/(ve.y-ie.y);return Ve>I&&Ve<ge}))?0:pe},Mo=(b,C=()=>!0)=>{const M=p(b);if(!M)return[];const D=[M],I=new Set([b]);for(let L=0;L<D.length;L++){const H=D[L].id;for(const F of R){const N=F.flow.target;if(F.flow.source!==H||I.has(N)||!T.has(N))continue;I.add(N);const q=p(N);q&&C(q)&&D.push(q)}}return D},DN=(b,C=()=>!0)=>{const M=p(b);if(!M)return[];const D=[M],I=new Set([b]);for(let L=0;L<D.length;L++){const H=D[L].id;for(const F of R){const N=F.flow.source;if(F.flow.target!==H||I.has(N)||!T.has(N))continue;I.add(N);const q=p(N);q&&C(q)&&D.push(q)}}return D},Mi=30,vr=b=>!("waypoints"in b&&b.waypoints)&&b.type!=="bpmn:Lane"&&b.type!=="label"&&typeof b.x=="number",Bu=(b,C)=>Ip(n,b,C),Vs=(b,C,M=!1)=>{const D=new Set(b.flatMap(N=>N.subtree.map(q=>q.id)));for(const N of b){const q=(N.pool.children??[]).filter(vr).filter(oe=>!D.has(oe.id));if(N.subtree.some(oe=>q.some(J=>oe.x+C<J.x+J.width+Mi&&oe.x+C+oe.width+Mi>J.x&&oe.y<J.y+J.height&&oe.y+oe.height>J.y)))return null}const I=b.map(N=>N.pool.width),L=M?o.filter(N=>Array.isArray(N.waypoints)).map(N=>({c:N,wps:N.waypoints.map(q=>({x:q.x,y:q.y}))})):[],H=o.filter(N=>N.type==="label").map(N=>({label:N,x:N.x,y:N.y}));n.moveElements(b.flatMap(N=>N.subtree),{x:C,y:0});const F=b.map(N=>{const Y=Math.max(...N.subtree.map(oe=>oe.x+oe.width))+Mg-(N.pool.x+N.pool.width);return Y>0&&Bu(N.pool,N.pool.width+Y),Y});return()=>{n.moveElements(b.flatMap(N=>N.subtree),{x:-C,y:0}),b.forEach((N,q)=>{F[q]>0&&Bu(N.pool,I[q])});for(const{c:N,wps:q}of L){const Y=N.waypoints??[];Y.length===q.length&&Y.every((J,de)=>Math.abs(J.x-q[de].x)<=.5&&Math.abs(J.y-q[de].y)<=.5)||n.updateWaypoints(N,q.map(J=>({x:J.x,y:J.y})))}for(let N=0;N<3;N++){let q=0;for(const Y of H){const oe=Y.x-Y.label.x,J=Y.y-Y.label.y;Math.abs(oe)<=.5&&Math.abs(J)<=.5||(n.moveElements([Y.label],{x:oe,y:J}),q++)}if(!q)break}}},Ih=b=>{var I,L;const C=new Map,M=new Map;for(const H of o.getAll()){if(H.type!=="bpmn:Participant")continue;const F=H;(F.children??[]).length||(C.set(F.id,F),M.set(F.id,[]))}for(const H of o.getAll()){if(H.type!=="bpmn:MessageFlow")continue;const F=H,N=(I=F.source)==null?void 0:I.id,q=(L=F.target)==null?void 0:L.id;N&&q&&M.has(N)&&M.get(N).push(q),N&&q&&M.has(q)&&M.get(q).push(N)}const D=[];for(const[H,F]of M)F.length&&F.every(N=>b.has(N))&&D.push(C.get(H));return D},eE=(b,C)=>{if(!b.length)return null;const M=new Set(b.map(Y=>Y.id)),D=o.getAll().filter(Y=>Y.type==="bpmn:Participant"&&!M.has(Y.id)),I=Math.min(...D.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 oe=L.has(Y.id)?Y.x:Y.x+C,J=L.has(Y.id)?Y.width+C:Y.width;return D.some(de=>oe<de.x+de.width+Mi&&oe+J+Mi>de.x&&Y.y<de.y+de.height&&Y.y+Y.height>de.y)}))return null;const F=o.filter(Y=>Y.type==="label").map(Y=>({label:Y,x:Y.x,y:Y.y})),N=b.filter(Y=>!L.has(Y.id)),q=b.filter(Y=>L.has(Y.id)).map(Y=>({pool:Y,was:{x:Y.x,y:Y.y,width:Y.width,height:Y.height}}));N.length&&n.moveElements(N,{x:C,y:0});for(const{pool:Y,was:oe}of q)n.resizeShape(Y,{...oe,width:oe.width+C});return()=>{for(const{pool:Y,was:oe}of q)n.resizeShape(Y,oe);N.length&&n.moveElements(N,{x:-C,y:0});for(let Y=0;Y<3;Y++){let oe=0;for(const J of F){const de=J.x-J.label.x,pe=J.y-J.label.y;Math.abs(de)<=.5&&Math.abs(pe)<=.5||(n.moveElements([J.label],{x:de,y:pe}),oe++)}if(!oe)break}}},tE=(b,C,M)=>{const D=M.x+M.width/2,I=C.y>M.y,L=I?M.y+M.height:M.y,H=I?C.y:C.y+C.height,F=b.source===C?[{x:D,y:H},{x:D,y:L}]:[{x:D,y:L},{x:D,y:H}],N=Xe(o),q={...N.edges.find(Y=>Y.id===b.id),waypoints:F};return En(q,ai(N)).length?!1:(n.updateWaypoints(b,F),!0)},LN=()=>{const b=o.filter(I=>I.type==="bpmn:Participant"),C=Math.min(...b.filter(I=>(I.children??[]).length>0).map(I=>I.x)),M=I=>!!I&&I.type==="bpmn:Participant"&&!(I.children??[]).length&&Math.abs(I.x-C)<=2&&!h.some(L=>L.participant.id===I.id),D=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(N=>M(N)),F=H===L.source?L.target:L.source;H&&F&&F.type!=="bpmn:Participant"&&D.add(L.id)}return D},IN=b=>{var M;const C=new Map;for(const D of b){const I=o.get(D);if(!I||(I.waypoints??[]).length===2)continue;const L=((M=I.source)==null?void 0:M.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 F=C.get(L.id)??{pool:L,msgs:[]};F.msgs.push({conn:I,other:H}),C.set(L.id,F)}for(const{pool:D,msgs:I}of C.values()){const L=Math.max(...I.map(({other:pe})=>pe.x+pe.width/2))+Op;if(o.getAll().some(pe=>{if(pe.type!=="bpmn:Participant"||pe.id===D.id)return!1;const ge=pe;return D.x<ge.x+ge.width+Mi&&L+Mi>ge.x&&D.y<ge.y+ge.height&&D.y+D.height>ge.y}))continue;const F={x:D.x,y:D.y,width:D.width,height:D.height},N=[...D.incoming??[],...D.outgoing??[]],q=N.map(pe=>({c:pe,wps:(pe.waypoints??[]).map(ge=>({x:ge.x,y:ge.y}))})),Y=N.flatMap(pe=>{const ge=pe.label;return ge?[{label:ge,x:ge.x,y:ge.y}]:[]}),oe=Qr();n.resizeShape(D,{...F,width:L-D.x});const J=I.filter(({conn:pe,other:ge})=>tE(pe,D,ge)).length,de=Qr();if(!(J>0&&de.messages>oe.messages&&de.lines>=oe.lines)){n.resizeShape(D,F);for(const{c:pe,wps:ge}of q){const tt=pe.waypoints??[];tt.length===ge.length&&tt.every((te,ie)=>Math.abs(te.x-ge[ie].x)<=.5&&Math.abs(te.y-ge[ie].y)<=.5)||n.updateWaypoints(pe,ge.map(te=>({x:te.x,y:te.y})))}for(let pe=0;pe<3;pe++){let ge=0;for(const tt of Y){const Re=tt.x-tt.label.x,te=tt.y-tt.label.y;Math.abs(Re)<=.5&&Math.abs(te)<=.5||(n.moveElements([tt.label],{x:Re,y:te}),ge++)}if(!ge)break}}}},nE=()=>{let b=0;for(const C of o.getAll()){if(C.type!=="bpmn:DataInputAssociation"&&C.type!=="bpmn:DataOutputAssociation")continue;const M=C.waypoints??[];for(let D=1;D<M.length;D++)b+=Math.hypot(M[D].x-M[D-1].x,M[D].y-M[D-1].y)}return b},iE=()=>{let b=0;for(const C of o.getAll()){if(C.type!=="bpmn:Association")continue;const M=C.waypoints??[];for(let D=1;D<M.length;D++)b+=Math.hypot(M[D].x-M[D-1].x,M[D].y-M[D-1].y)}return b},BN=b=>{const C=[];for(const M of o.getAll()){if(M.type!=="bpmn:TextAnnotation")continue;const D=M;if(b.has(D.id))continue;const L=[...D.incoming??[],...D.outgoing??[]].filter(N=>N.type==="bpmn:Association").map(N=>N.source===D?N.target:N.source);if(!L.length||L.some(N=>N===void 0))continue;const H=N=>{if(!("waypoints"in N&&N.waypoints))return[N.id];const q=N,Y=[q.source,q.target];return Y.some(oe=>!oe)?[]:Y.map(oe=>oe.id)},F=L.flatMap(N=>H(N));F.length&&F.every(N=>b.has(N))&&C.push(D)}return C},rE=()=>ht(Xe(o)).filter(b=>b.kind==="edge-crosses-shape").length,oE=b=>{const C=(b.children??[]).filter(vr);let M=0;for(let D=0;D<C.length;D++)for(let I=D+1;I<C.length;I++){const L=C[D],H=C[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&&M++}return M},Qr=()=>{const b=Xe(o),C=M=>M.length>=2&&(M.every(D=>Math.abs(D.x-M[0].x)<.01)||M.every(D=>Math.abs(D.y-M[0].y)<.01));return{messages:b.edges.filter(M=>M.type==="bpmn:MessageFlow"&&M.waypoints.length===2).length,lines:b.edges.filter(M=>C(M.waypoints)).length}},aE=b=>{const C=new Map;for(const D of o.getAll()){if(D.type!=="bpmn:MessageFlow")continue;const I=D;if(!I.waypoints||I.waypoints.length!==2)continue;const L=I.source,H=I.target;if(!L||!H)continue;const F=b.has(L.id);if(F===b.has(H.id))continue;const N=F?H:L,q=d(N);if(!q||b.has(N.id))continue;const Y=C.get(q.id);Y?N.x<Y.minX&&(Y.minX=N.x):C.set(q.id,{pool:q,minX:N.x})}const M=[];for(const{pool:D,minX:I}of C.values()){const L=(D.children??[]).filter(H=>vr(H)&&!b.has(H.id)&&H.x>=I);L.length&&M.push({subtree:L,pool:D})}return M},NN=(b,C,M)=>{const D=new Map(C.map(H=>[H.pool.id,{subtree:[...H.subtree],pool:H.pool}])),I=new Set(b);for(const H of C)for(const F of H.subtree)I.add(F.id);let L=!1;for(;;){let H=0;for(const F of aE(I)){if(F.pool===M)continue;const N=D.get(F.pool.id);N?N.subtree.push(...F.subtree):D.set(F.pool.id,{subtree:[...F.subtree],pool:F.pool});for(const q of F.subtree)I.add(q.id);H+=F.subtree.length}if(!H)break;L=!0}return L?[...D.values()]:null},sE=new Map;for(const b of Qt(e,"sequenceFlow.update")){if(b.target===void 0)continue;const C=T.get(b.target);if(!C)continue;const M=p(b.target),D=p(b.id);if(!M||!D)continue;const I=b.source!==void 0?p(b.source):D.source,L=D.target;if(!I||!L||L.id===M.id)continue;const H=D.waypoints&&D.waypoints.length>=3&&Math.abs(D.waypoints[0].x-D.waypoints[1].x)<1&&Math.abs(D.waypoints[0].y-D.waypoints[1].y)>1?{x:D.waypoints[0].x,y:D.waypoints[0].y}:void 0,F=H?D.waypoints[1].y:void 0,N=H&&D.label?{x:D.label.x,y:D.label.y}:void 0,q=N&&D.label&&Math.abs(N.y+D.label.height/2-F)<=O/5&&N.x+D.label.width>H.x?N.x+D.label.width+6:void 0,Y=(I.outgoing??[]).filter(we=>we.type==="bpmn:SequenceFlow"&&we.id!==D.id&&we.target&&!Iu.has(we.id)),oe=new Set(Y.map(we=>we.target.id)),J=we=>{const ot={type:"bpmn:Task",x:we.x+2,y:we.y+2,width:we.width-4,height:we.height-4};return Y.find(Me=>(Me.waypoints??[]).some((wt,gt)=>!!Me.waypoints[gt+1]&&mc(wt,Me.waypoints[gt+1],ot)===0))},de=Mo(b.target),pe=new Set(de.map(we=>we.id)),ge=Math.min(...de.map(we=>we.x)),tt=Math.max(...de.map(we=>we.x+we.width)),Re=I.x+I.width,te=M.y+M.height/2,ie=ON(de,Re+Ai-ge,[0,I.y+I.height/2-te,L.y+L.height/2-te],L.x,Re,I.y+I.height/2),ce=Re+Ai+ie,ve=(()=>{if(q===void 0)return 0;const we=Re+Ai,ot=I.y+I.height/2-M.height/2,Me={x:we,y:ot,width:tt-ge,height:M.height},wt=d(I);return((wt==null?void 0:wt.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<Me.x+Me.width&&mt.x+mt.width>Me.x&&mt.y<Me.y+Me.height&&mt.y+mt.height>Me.y)||J(Me)?Math.max(0,q-we):0})(),Ve=tt-ge+Ai*2+ie+ve-(L.x-Re);let We=[];if(Ve>0){const we=d(M),ot=(we==null?void 0:we.children)??[],Me=Be=>Be.type==="bpmn:Lane";We=(()=>{const Be=new Set;for(const Ne of ot)vr(Ne)&&!pe.has(Ne.id)&&Ne.id!==I.id&&Ne.x>=L.x&&Be.add(Ne.id);const Mt=[];for(const Ne of ot){if(Ne.type!=="bpmn:DataStoreReference"&&Ne.type!=="bpmn:DataObjectReference")continue;const vt=Ne,Gn=[...vt.incoming??[],...vt.outgoing??[]].filter(Xt=>Xt.type==="bpmn:DataInputAssociation"||Xt.type==="bpmn:DataOutputAssociation").map(Xt=>Xt.source===vt?Xt.target:Xt.source);Gn.length&&Gn.every(Xt=>Xt!==void 0&&Be.has(Xt.id))&&Mt.push(vt)}return Mt})();const gt=ot.filter(Be=>!("waypoints"in Be&&Be.waypoints)&&!Me(Be)&&Be.type!=="label"&&!pe.has(Be.id)&&Be.id!==I.id&&Be.x>=L.x),mt=gt.flatMap(Be=>Be.labels??[]),Lt=we?[we,...ot.filter(Be=>Me(Be))]:[];if(gt.length){const Be=new Set(gt.map(bt=>bt.id)),Mt=aE(Be),Ne=Mt.length?NN(Be,Mt,we):null,vt=bt=>{const Tt=new Set(Be);for(const jt of bt)for(const Ii of jt.subtree)Tt.add(Ii.id);return BN(Tt)},Fn=vt(Mt),Gn=Ne?vt(Ne):Fn,Xt=Ih(Be),Hu=new Set(Be);for(const bt of Mt)for(const Tt of bt.subtree)Hu.add(Tt.id);const zu=Mt.length?Ih(Hu):Xt,Gu=(()=>{if(!Ne)return[];const bt=new Set(Be);for(const Tt of Ne)for(const jt of Tt.subtree)bt.add(jt.id);return Ih(bt)})(),qs=new Set([...gt,...Lt].map(bt=>bt.id)),Gh=ot.filter(bt=>{const Tt=bt.labelTarget;return bt.type==="label"&&!!Tt&&"waypoints"in Tt&&!!Tt.source&&!!Tt.target&&qs.has(Tt.source.id)&&qs.has(Tt.target.id)}),Vh=LN();n.createSpace([...gt,...mt,...Gh],Lt,{x:Ve,y:0},"e",L.x-1);const Li=(bt,Tt)=>{const jt=Qr(),Ii=Vs(bt,Ve);if(!Ii)return!1;const It=Tt.length?eE(Tt,Ve):null,Pi=Qr();return Pi.messages>jt.messages&&Pi.lines>=jt.lines?!0:(It==null||It(),Ii(),!1)},dt=Ne?Li(Ne,Gu):!1;let an=dt;!an&&Mt.length&&(an=Li(Mt,zu));const Ft=dt?Gn:Fn;if(!an){for(const bt of Mt){const Tt=Qr(),jt=Vs([bt],Ve);if(!jt)continue;const Ii=Qr();(Ii.messages<=Tt.messages||Ii.lines<Tt.lines)&&jt()}if(Xt.length){const bt=Qr(),Tt=eE(Xt,Ve);if(Tt){const jt=Qr();(jt.messages<=bt.messages||jt.lines<bt.lines)&&Tt()}}}if(IN(Vh),Ft.length){const bt=()=>new Set(ht(Xe(o)).map(jt=>ut(jt))),Tt=jt=>{const Ii=iE(),It=bt(),Pi=jt.map(Zt=>({a:Zt,x:Zt.x,y:Zt.y})),Oo=o.filter(Zt=>Zt.type==="label").map(Zt=>({label:Zt,x:Zt.x,y:Zt.y}));n.moveElements(jt,{x:Ve,y:0});const o$=[...bt()].filter(Zt=>!It.has(Zt));if(iE()<Ii&&o$.length===0)return!0;for(const{a:Zt,x:Ys,y:Ks}of Pi)(Zt.x!==Ys||Zt.y!==Ks)&&n.moveElements([Zt],{x:Ys-Zt.x,y:Ks-Zt.y});for(const Zt of Oo){const Ys=Zt.x-Zt.label.x,Ks=Zt.y-Zt.label.y;(Ys!==0||Ks!==0)&&n.moveElements([Zt.label],{x:Ys,y:Ks})}return!1};if(!Tt(Ft)&&Ft.length>1)for(const jt of Ft)Tt([jt])}}}const St=C.node.lane!==void 0?p(C.node.lane):C.node.participant!==void 0?p(C.node.participant):void 0,$t=we=>{if(!St)return!0;const ot=we.y+we.height/2;return ot>=St.y&&ot<=St.y+St.height},be=!$t(I)&&$t(L)?L:I,xe=be.y+be.height/2,ae=xe-(M.y+M.height/2),ye=C.band!==void 0,Le=ye?[M]:de,Ye=(C.band===void 0||w(C.node.lane,C.node.participant,C.band,xe))&&xt(b.target)&&Le.every(we=>{var ot;return xn((ot=T.get(we.id))==null?void 0:ot.node.lane,we,we.y+we.height/2+ae)}),ke=we=>Math.abs(we.y+we.height/2-(M.y+M.height/2))<=O/2;if(Ye&&ye){const we=Math.abs(ae)<=O/2?de.filter(ot=>ot.id!==M.id&&ke(ot)):[];if(n.moveElements(de,{x:ce-ge,y:0}),n.moveElements([M],{x:0,y:ae}),we.length){const ot=()=>new Set(ht(Xe(o)).map(Be=>ut(Be))),Me=ot(),wt=o.filter(Be=>Be.type==="label").map(Be=>({label:Be,x:Be.x,y:Be.y}));n.moveElements(we,{x:0,y:ae});const gt=ot(),mt=[...gt].filter(Be=>!Me.has(Be)).length,Lt=[...Me].filter(Be=>!gt.has(Be)).length;if(mt>Lt){n.moveElements(we,{x:0,y:-ae});for(const Be of wt){const Mt=Be.x-Be.label.x,Ne=Be.y-Be.label.y;(Mt!==0||Ne!==0)&&n.moveElements([Be.label],{x:Mt,y:Ne})}}}}else n.moveElements(de,{x:ce-ge,y:Ye?ae:0});const He=d(M);if(!Ye&&C.node.lane===void 0&&C.band!==void 0&&He){const we=He.y+Q+S(`pool:${C.node.participant??""}`,C.band)*O,ot=we-(M.y+M.height/2);ot!==0&&!rt(He,M,M.x+M.width/2,we,pe)&&n.moveElements([M],{x:0,y:ot})}if(He){const we=(He.children??[]).filter(gt=>vr(gt)&&!pe.has(gt.id)&>.type!=="bpmn:Group"&>.type!=="bpmn:Participant"),ot=(gt,mt,Lt,Be,Mt)=>gt.x+mt<Mt.x+Mt.width+Be&>.x+mt+gt.width+Be>Mt.x&>.y+Lt<Mt.y+Mt.height+Be&>.y+Lt+gt.height+Be>Mt.y,Me=we.find(gt=>ot(M,0,0,0,gt)),wt=Me?void 0:J(M);if(Me||wt){const gt=["bpmn:SequenceFlow","bpmn:MessageFlow","bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation"],mt=o.getAll().filter(dt=>{if(!gt.includes(dt.type))return!1;const an=dt;return Iu.has(an.id)||!an.waypoints||an.waypoints.length<2?!1:![an.source,an.target].some(Ft=>!Ft||pe.has(Ft.id))}),Lt=(dt,an,Ft)=>{var bt;return xn((bt=T.get(dt.id))==null?void 0:bt.node.lane,dt,dt.y+Ft+dt.height/2)&&dt.x+an>=He.x&&dt.x+an+dt.width<=He.x+He.width&&dt.y+Ft>=He.y&&dt.y+Ft+dt.height<=He.y+He.height},Be=(dt,an)=>de.every(Ft=>Lt(Ft,dt,an)&&!we.some(bt=>ot(Ft,dt,an,st,bt))&&mt.every(bt=>{const Tt={id:Ft.id,type:Ft.type,x:Ft.x+dt,y:Ft.y+an,width:Ft.width,height:Ft.height};for(let jt=0;jt+1<bt.waypoints.length;jt++)if(mc(bt.waypoints[jt],bt.waypoints[jt+1],Tt)<st)return!1;return!0})),Mt=M.y+M.height/2,Ne=[F,L.y+L.height/2].filter(dt=>dt!==void 0&&Math.abs(dt-Mt)>=1),vt=Me&&oe.has(Me.id)?Me:wt==null?void 0:wt.target,Fn=vt?vt.x-M.x:0,Gn=Math.max(...de.map(dt=>dt.x+dt.width)),Xt=[...Fn!==0?[Fn]:[],...ie!==0?[-ie]:[],0],Hu=q===void 0?[]:Xt.map(dt=>Math.max(dt,q-M.x)),zu=dt=>Gn+dt+Ai<=L.x,Gu=[...new Set([...Hu,...Xt])].filter(zu),qs=Me&&oe.has(Me.id)?[Me.x+Me.width+Ai-M.x]:[],Gh=q===void 0?[]:qs.map(dt=>Math.max(dt,q-M.x)),Vh=[...new Set([...Gh,...qs])].filter(dt=>zu(dt)&&!Gu.includes(dt));let Li;for(const dt of[Gu,Vh]){for(const an of Ne){for(const Ft of dt)if(Be(Ft,an-Mt)){Li={dx:Ft,dy:an-Mt};break}if(Li)break}if(Li)break}if(Li){const dt=It=>{const Pi=It;return[Pi.edge,Pi.other,...Array.isArray(Pi.edges)?Pi.edges:[]].some(Oo=>typeof Oo=="string"&&Iu.has(Oo))},an=()=>new Set(ht(Xe(o)).filter(It=>!dt(It)).map(It=>ut(It))),Ft=an(),bt=o.filter(It=>It.type==="label").map(It=>({label:It,x:It.x,y:It.y}));n.moveElements(de,{x:Li.dx,y:Li.dy});const Tt=an(),jt=[...Tt].filter(It=>!Ft.has(It)).length,Ii=[...Ft].filter(It=>!Tt.has(It)).length;if(jt>Ii){n.moveElements(de,{x:-Li.dx,y:-Li.dy});for(const It of bt){const Pi=It.x-It.label.x,Oo=It.y-It.label.y;(Pi!==0||Oo!==0)&&n.moveElements([It.label],{x:Pi,y:Oo})}}else H&&sE.set(D.id,{exit:H,channelY:F,label:N})}}}{const we=new Set(de.map(mt=>mt.id)),ot=new Set(R.map(mt=>mt.flow.id)),Me=20,wt=mt=>{const Lt=mt.source,Be=mt.target,Mt=Math.min(Lt.x,Be.x)-Me,Ne=Math.max(Lt.x+Lt.width,Be.x+Be.width)+Me,vt=Math.min(Lt.y,Be.y)-Me,Fn=Math.max(Lt.y+Lt.height,Be.y+Be.height)+Me;return mt.waypoints.some(Gn=>Gn.x<Mt||Gn.x>Ne||Gn.y<vt||Gn.y>Fn)},gt=new Map;for(const mt of de)for(const Lt of[...mt.incoming??[],...mt.outgoing??[]])Lt.id!==b.id&&ot.has(Lt.id)&&!(we.has(Lt.source.id)&&we.has(Lt.target.id))&>.set(Lt.id,Lt);for(const mt of gt.values())wt(mt)&&Ta(mt)}const Qe=We.length?d(We[0]):void 0;if(Qe){const we={assoc:nE(),overlaps:oE(Qe),crosses:rE()},ot=We.map(Ne=>({st:Ne,x:Ne.x})),Me=o.filter(Ne=>Ne.type==="label").map(Ne=>({label:Ne,x:Ne.x,y:Ne.y})),wt=Math.min(...We.flatMap(Ne=>[...Ne.incoming??[],...Ne.outgoing??[]].filter(vt=>vt.type==="bpmn:DataInputAssociation"||vt.type==="bpmn:DataOutputAssociation").map(vt=>(vt.source===Ne?vt.target:vt.source).x))),gt=new Set(We.map(Ne=>Ne.id)),mt=(Qe.children??[]).filter(vr).filter(Ne=>!gt.has(Ne.id));let Lt=wt;for(const Ne of[...We].sort((vt,Fn)=>vt.x-Fn.x)){let vt=Lt;for(let Fn=0;Fn<100;Fn++){const Gn=mt.find(Xt=>vt<Xt.x+Xt.width+Mi&&vt+Ne.width+Mi>Xt.x&&Ne.y<Xt.y+Xt.height&&Ne.y+Ne.height>Xt.y);if(!Gn)break;vt=Gn.x+Gn.width+Mi}vt!==Ne.x&&n.moveElements([Ne],{x:vt-Ne.x,y:0}),Lt=vt+Ne.width+Mi}const Be=Lt+150-(Qe.x+Qe.width);Be>0&&Bu(Qe,Qe.width+Be);const Mt={assoc:nE(),overlaps:oE(Qe),crosses:rE()};if(Mt.assoc>=we.assoc||Mt.overlaps>we.overlaps||Mt.crosses>we.crosses){for(const{st:Ne,x:vt}of ot)Ne.x!==vt&&n.moveElements([Ne],{x:vt-Ne.x,y:0});Be>0&&Bu(Qe,Qe.width-Be);for(const Ne of Me){const vt=Ne.x-Ne.label.x,Fn=Ne.y-Ne.label.y;(vt!==0||Fn!==0)&&n.moveElements([Ne.label],{x:vt,y:Fn})}}}}const cE=(b,C)=>{const M=C.target===b,D=f(C.source),I=f(C.target),L=M?"bpmn:DataOutputAssociation":"bpmn:DataInputAssociation";n.connect(D,I,C.id?{type:L,businessObject:i.create(L,{id:C.id})}:{type:L})},lE=b=>{for(const C of h){if(!C.participant.blackBox)continue;const M=p(C.participant.id);if(!M)continue;const D=[];for(const L of x){const H=L.flow.source===C.participant.id?L.flow.target:L.flow.target===C.participant.id?L.flow.source:void 0,F=H?p(H):void 0;F&&typeof F.x=="number"&&F.type!=="bpmn:Participant"&&D.push(F)}if(!D.length)continue;if(!b&&C.order===void 0){const L=(()=>{var F;const H=new Map;for(const N of D){const q=d(N);if(!q)continue;const Y=H.get(q.id);Y?Y.n+=1:H.set(q.id,{shape:q,n:1})}return(F=[...H.values()].sort((N,q)=>q.n-N.n)[0])==null?void 0:F.shape})();if(L){const H=q=>q.reduce((Y,oe)=>Y+oe,0)/q.length,F=H(D.map(q=>q.y+q.height/2))<L.y+L.height/2,N=o.filter(q=>q.type==="bpmn:Participant"&&q.id!==C.participant.id&&q.id!==L.id).filter(q=>F?q.y+q.height<=L.y+5:q.y>=L.y+L.height-5);if(N.length){const q=[...N.reduce((ce,ve)=>ce.set(ve.y,(ce.get(ve.y)??0)+1),new Map)].sort((ce,ve)=>ve[1]-ce[1]||(F?ve[0]-ce[0]:ce[0]-ve[0]))[0][0],Y=Math.min(M.width,zR),oe=GR,J=D.map(ce=>ce.x+ce.width/2),de=Math.round(H(J)-Y/2),pe=Math.max(...J)+Op,ge=ce=>({x:ce,width:Math.max(Y,pe-ce)}),tt=N.filter(ce=>Math.min(ce.y+ce.height,q+oe)-Math.max(ce.y,q)>0),Re=ce=>{const ve=ge(ce);return tt.some(Ve=>Ve.x<ve.x+ve.width&&ve.x<Ve.x+Ve.width)},te=ce=>{const ve=ge(ce);return J.filter(Ve=>Ve>=ve.x+10&&Ve<=ve.x+ve.width-10).length},ie=(()=>{if(!Re(de))return de;const ce=te(de);return tt.flatMap(ve=>[ve.x+ve.width+Sg,ve.x-Sg-Y]).map(ve=>Math.round(ve)).filter(ve=>!Re(ve)&&te(ve)>=ce).sort((ve,Ve)=>Math.abs(ve-de)-Math.abs(Ve-de))[0]??de})();if(ie!==M.x||q!==M.y||Y!==M.width||oe!==M.height){const ce=()=>new Set(ht(Xe(o)).map(be=>ut(be))),ve=ce(),Ve={x:M.x,y:M.y,width:M.width,height:M.height};n.resizeShape(M,{x:ie,y:q,width:Y,height:oe});const We=ce(),St=[...We].filter(be=>!ve.has(be)).length,$t=[...ve].filter(be=>!We.has(be)).length;St>$t&&n.resizeShape(M,Ve)}}}}const I=Math.max(...D.map(L=>L.x+L.width/2))+Op;if(I>M.x+M.width&&n.resizeShape(M,{x:M.x,y:M.y,width:I-M.x,height:M.height}),!!b)for(const L of x){const H=p(L.flow.id),F=L.flow.source===C.participant.id?L.flow.target:L.flow.target===C.participant.id?L.flow.source:void 0,N=F?p(F):void 0;if(!H||!N||N.type==="bpmn:Participant")continue;const q=N.x+N.width/2;q<M.x+10||q>M.x+M.width-10||tE(H,M,N)}}};lE(!1);for(const b of x){const C=b.flow;n.connect(f(C.source),f(C.target),{type:"bpmn:MessageFlow",businessObject:i.create("bpmn:MessageFlow",{id:C.id,name:C.name})})}{const M=new Set([...R.map(N=>N.flow.id),...x.map(N=>N.flow.id)].filter(N=>!!N)),D=o.filter(N=>!!N.waypoints),I=(N,q)=>Math.abs(q.x-N.x)<2?"L":Math.abs(q.x-(N.x+N.width))<2?"R":Math.abs(q.y-N.y)<2?"T":Math.abs(q.y-(N.y+N.height))<2?"B":void 0,L=new Map,H=(N,q,Y)=>{if(!N||!q||typeof N.x!="number")return;const oe=I(N,q);if(!oe)return;let J=L.get(N.id);J||L.set(N.id,J=new Map),J.set(oe,[...J.get(oe)??[],Y])};for(const N of D){const q=N.waypoints;!q||q.length<2||(H(N.source,q[0],{id:N.id,dir:"out"}),H(N.target,q[q.length-1],{id:N.id,dir:"in"}))}const F=new Set;for(const[N,q]of L){const Y=p(N);if(!Y||typeof Y.x!="number"||![...q.values()].some(Re=>{const te=Re.filter(ie=>ie.dir==="in");return Re.length>=3&&te.length>=1&&Re.some(ie=>ie.dir==="out")&&te.some(ie=>M.has(ie.id))}))continue;const J=d(Y);if(!J||F.has(J.id)||(J.children??[]).some(Re=>Re.type==="bpmn:Lane"))continue;const de=(CE=q.get("T"))!=null&&CE.length?(AE=q.get("B"))!=null&&AE.length?void 0:"B":"T";if(!de||(de==="T"?Y.y-J.y:J.y+J.height-(Y.y+Y.height))>=O)continue;const ge=(J.children??[]).filter(Re=>!("waypoints"in Re&&Re.waypoints)&&Re.type!=="label"&&typeof Re.x=="number"),tt=J.y+J.height;n.resizeShape(J,{x:J.x,y:J.y,width:J.width,height:J.height+O}),ee(tt,J.id,O),de==="T"&&ge.length&&n.moveElements(ge,{x:0,y:O}),F.add(J.id)}}const Bh=20,uE=4,$N=2,FN=[10,30,80],Jr=()=>{const b=Xe(o);return{bad:ht(b).filter(C=>C.kind==="edge-crosses-shape"||C.kind==="edge-overlap-opposite"||C.kind==="edge-overlap-mixed").length,crossings:Im(b),straight:b.edges.filter(C=>C.type==="bpmn:MessageFlow"&&C.waypoints.length===2).length}},ka=b=>{const C=Xe(o),M=C.edges.find(D=>D.id===b);return M?En(M,ai(C)).length:0},Nu=b=>ka(b)>0,$u=b=>Xe(o).edges.filter(C=>C.type==="bpmn:MessageFlow"&&C.id!==b&&C.waypoints.length===2).length,jN=(b,C,M)=>Vs([{subtree:b,pool:C}],M),pE=(b,C)=>C.bad>b.bad||C.crossings>b.crossings&&C.straight<=b.straight&&C.bad>=b.bad,Oa=(b,C)=>pE(b,C)||C.straight<b.straight,Po=(b,C,M=()=>!0,D=pE,I=!1)=>{const L=Jr(),H=Vs(b,C,I);if(!H)return!1;const F=Jr();return D(L,F)||!M()?(H(),!1):!0},HN=(b,C,M,D=()=>!0)=>Po([{subtree:b,pool:C}],M,D),To=b=>{var C;return!!((C=T.get(b))!=null&&C.node.participant)},Ws=new Map;for(const b of x){if(!To(b.flow.target))continue;const C=Ws.get(b.flow.target)??[];C.push(b),Ws.set(b.flow.target,C)}const Fu=[...Ws.keys()],Nh=new Set(R.map(b=>b.flow.target)),fE=b=>_n.findIndex(({op:C})=>C.participant.id===b);Fu.sort((b,C)=>{var I,L;const M=Nh.has(b)?1:0,D=Nh.has(C)?1:0;return M!==D?M-D:fE((I=T.get(b))==null?void 0:I.node.participant)-fE((L=T.get(C))==null?void 0:L.node.participant)});const eo=b=>b.x+b.width/2,zN=b=>{const C=new Map;for(const I of o.getAll()){const L=I;if(!L.waypoints||!L.source||!L.target)continue;(C.get(L.source.id)??C.set(L.source.id,[]).get(L.source.id)).push(L.target.id)}const M=new Set([b]),D=[b];for(let I=0;I<D.length;I++)for(const L of C.get(D[I])??[])M.has(L)||(M.add(L),D.push(L));return M},GN=(b,C)=>{const M=zN(C);let D;for(const I of o.getAll()){const L=I;if(L.type!=="bpmn:MessageFlow"||!L.source||!L.target||L.target.id!==b||M.has(L.source.id))continue;const H=L.source;if(typeof H.x!="number"||H.type==="bpmn:Participant")continue;const F=eo(H);(D===void 0||F>D)&&(D=F)}return D},$h=(b,C)=>{const M=p(b.flow.source);if(M)return M.type==="bpmn:Participant"?GN(M.id,C):eo(M)},dE=b=>{let C;for(const M of Ws.get(b)??[]){const D=$h(M,b);D!==void 0&&(!C||D>C.cx)&&(C={op:M,cx:D})}return C==null?void 0:C.op},VN=b=>{const C=dE(b),M=p(b),D=C?$h(C,b):void 0;return M&&D!==void 0?D-eo(M):void 0},WN=b=>{const C=VN(b);return C!==void 0&&Math.abs(C)<Bh},Fh=(b,C,M,D,I)=>{var L;for(let H=!0;H;){H=!1;for(const F of x){if(F.flow.id===M)continue;const N=C.has(F.flow.source),q=C.has(F.flow.target);if(N===q||D(N?F.flow.source:F.flow.target))continue;const Y=N?F.flow.target:F.flow.source;if(I(Y)||!To(Y))continue;const oe=p(F.flow.id);if(!(oe!=null&&oe.waypoints)||oe.waypoints.length!==2)continue;const J=p(Y),de=(L=T.get(Y))==null?void 0:L.node.participant;if(!J||!de)continue;const pe=Mo(Y,ge=>ge.x>=J.x).filter(ge=>!C.has(ge.id));if(!(!pe.length||pe.some(ge=>I(ge.id)))){for(const ge of pe)C.add(ge.id);b.set(de,[...b.get(de)??[],...pe]),H=!0}}}return[...b].map(([H,F])=>({subtree:F,pool:f(H)}))},hE=(b,C,M,D,I)=>Fh(new Map([[C,[...b]]]),new Set(b.map(L=>L.id)),D,L=>L===M,L=>L===I),jh=b=>{const C=dE(b);if(!C)return null;const M=p(b),D=p(C.flow.source),I=$h(C,b);if(!M||!D||I===void 0)return null;const L=I-eo(M);if(L>=Bh){const H=T.get(b).node.participant,F=Mo(b,N=>N.x>=M.x);return{groups:hE(F,H,b,C.flow.id,C.flow.source),dx:L}}if(-L>=Bh&&To(C.flow.source)){const H=T.get(C.flow.source).node.participant,F=Mo(C.flow.source,N=>N.x>=D.x&&!WN(N.id));return{groups:hE(F,H,C.flow.source,C.flow.id,b),dx:-L}}return null},mE=()=>Fu.map(b=>({id:b,plan:jh(b)})).filter(b=>!!b.plan).sort((b,C)=>Math.min(...b.plan.groups.flatMap(M=>M.subtree.map(D=>D.x)))-Math.min(...C.plan.groups.flatMap(M=>M.subtree.map(D=>D.x)))).map(b=>b.id);for(let b=0;b<3;b++){const C=Jr(),M=[];for(const I of mE()){const L=jh(I);if(!L)continue;const H=Vs(L.groups,L.dx);H&&M.push(H)}if(!M.length)break;if(!Oa(C,Jr()))continue;for(const I of M.reverse())I();let D=!1;for(const I of mE()){const L=jh(I);L&&Po(L.groups,L.dx,()=>!0,Oa)&&(D=!0)}if(!D)break}for(const b of Fu){if(Nh.has(b))continue;const C=T.get(b);if(!C||C.node.lane!==void 0)continue;const M=K(C);if(M===void 0)continue;const D=p(b),I=D?d(D):void 0;if(!D||!I)continue;const L=I.y+Q+S(`pool:${C.node.participant??""}`,M)*O,H=L-(D.y+D.height/2);H!==0&&!rt(I,D,D.x+D.width/2,L)&&n.moveElements([D],{x:0,y:H})}for(const b of Fu.flatMap(C=>Ws.get(C)??[])){if(!Nu(b.flow.id))continue;const C=p(b.flow.target);if(!C)continue;const M=f(T.get(b.flow.target).node.participant),D=Mo(b.flow.target,F=>F.x>=C.x),I=C.width+j,L=ka(b.flow.id),H=$u(b.flow.id);for(let F=1;F<=uE;F++){const N=()=>ka(b.flow.id)<L&&$u(b.flow.id)>=H;if(HN(D,M,I*F,N))break}}const Hh=x.map(b=>({id:b.flow.id,source:b.flow.source,target:b.flow.target,preexisting:!1})),gE=new Set(Hh.map(b=>b.id));for(const b of o.filter(C=>C.type==="bpmn:MessageFlow"))gE.has(b.id)||!b.source||!b.target||b.source.type==="bpmn:Participant"!=(b.target.type==="bpmn:Participant")&&Hh.push({id:b.id,source:b.source.id,target:b.target.id,preexisting:!0});for(const b of Hh){if(!Nu(b.id))continue;const C=p(b.source),M=p(b.target);if(!C||!M)continue;let D,I,L;if(b.preexisting){const[F,N]=C.type==="bpmn:Participant"?[M,C]:[C,M];if(D=eo(F),D<N.x||D>N.x+N.width)continue;[I,L]=F.y<N.y?[F.y+F.height,N.y]:[N.y+N.height,F.y]}else{if(C.type==="bpmn:Participant"||M.type==="bpmn:Participant"||(D=C.x+C.width/2,Math.abs(D-(M.x+M.width/2))>15))continue;[I,L]=C.y<M.y?[C.y+C.height,M.y]:[M.y+M.height,C.y]}const H=[...T.values()].map(F=>p(F.node.id)).filter(F=>!!F&&F.id!==C.id&&F.id!==M.id).filter(F=>F.x<=D&&D<=F.x+F.width&&F.y+F.height>I&&F.y<L).sort((F,N)=>F.x-N.x);for(const F of H){const N=(ME=T.get(F.id))==null?void 0:ME.node.participant,q=N?p(N):void 0;if(!N||!q)continue;const Y=[...T.values()].filter(ie=>ie.node.participant===N).map(ie=>ie.node.id),oe=ie=>ie.map(ce=>p(ce)).filter(ce=>!!ce),de=[DN(F.id,ie=>{var ce;return((ce=T.get(ie.id))==null?void 0:ce.node.participant)===N}),oe(Y)].filter(ie=>ie.length).map(ie=>[{subtree:ie,pool:q}]);if(b.preexisting){const ie=oe(Y);ie.length&&de.push(Fh(new Map([[N,[...ie]]]),new Set(ie.map(ce=>ce.id)),b.id,()=>!1,ce=>ce===C.id||ce===M.id))}const pe=F.width+j,ge=ka(b.id),tt=$u(b.id),Re=()=>ka(b.id)<ge&&$u(b.id)>=tt;let te=!1;for(const ie of de){for(let ce=1;ce<=uE;ce++)if(Po(ie,pe*ce,Re)){te=!0;break}if(te)break}if(!Nu(b.id))break}}const ju=()=>{var C;const b=new Set;for(const M of ht(Xe(o)))M.kind!=="edge-crosses-shape"||gE.has(M.edge)||((C=p(M.edge))==null?void 0:C.type)==="bpmn:MessageFlow"&&b.add(`${M.edge}>${M.shape}`);return b},UN=(b,C)=>Jr().bad>=b&&[...ju()].some(M=>!C.has(M)),yE=b=>{var C,M;return ka(b)===0&&((M=(C=p(b))==null?void 0:C.waypoints)==null?void 0:M.length)===2},qN=(b,C,M)=>{const D=new Set(b.flatMap(L=>L.subtree.map(H=>H.id))),I=[...ju()].filter(L=>!M.has(L)).map(L=>L.split(">")[1]);return[...new Set(I)].filter(L=>D.has(L)&&L!==C.source&&L!==C.target)},YN=(b,C,M,D,I)=>{const L=b.map(q=>({...q,subtree:q.subtree.filter(Y=>!I.includes(Y.id))})).filter(q=>q.subtree.length),H=new Set(L.flatMap(q=>q.subtree.map(Y=>Y.id))),F=()=>I.every(q=>{const Y=p(q);return!!Y&&R.filter(oe=>oe.flow.target===q&&H.has(oe.flow.source)).every(oe=>{const J=p(oe.flow.source);return!!J&&J.x+J.width<=Y.x})});return Po(L,C,()=>yE(M.id)&&[...ju()].every(q=>D.has(q))&&F(),Oa,!0)};for(const b of x){if(!Nu(b.flow.id))continue;const C=p(b.flow.id);if(((PE=C==null?void 0:C.waypoints)==null?void 0:PE.length)!==2)continue;const M=p(b.flow.source),D=p(b.flow.target);if(!M||!D||M.type==="bpmn:Participant"||D.type==="bpmn:Participant"||!To(b.flow.source)||!To(b.flow.target)||Math.abs(eo(M)-eo(D))>$N)continue;const I=eo(M),L=C.waypoints.map(ge=>ge.y),[H,F]=[Math.min(...L),Math.max(...L)],N=ai(Xe(o)).filter(ge=>ge.id!==M.id&&ge.id!==D.id&&ge.x<I&&I<ge.x+ge.width&&H<ge.y+ge.height&&ge.y<F);if(!N.length)continue;const q=(TE=T.get(b.flow.source))==null?void 0:TE.node.participant,Y=(kE=T.get(b.flow.target))==null?void 0:kE.node.participant;if(!q||!Y)continue;const oe=new Map;for(const[ge,tt,Re]of[[b.flow.source,M,q],[b.flow.target,D,Y]]){const te=oe.get(Re)??[],ie=Mo(ge,ce=>ce.x>=tt.x).filter(ce=>!te.some(ve=>ve.id===ce.id));oe.set(Re,[...te,...ie])}const J=new Set([...oe.values()].flat().map(ge=>ge.id)),de=Fh(oe,J,b.flow.id,ge=>ge===b.flow.source||ge===b.flow.target,()=>!1),pe=Math.max(...N.map(ge=>ge.x+ge.width));for(const ge of FN){const tt=pe+ge-I;if(tt<=0)continue;const Re=Jr().bad,te=ju();let ie=[],ce=!0;const ve=()=>!yE(b.flow.id)||ce&&(ie=qN(de,b.flow,te),ie.length)?!1:!UN(Re,te);if(Po(de,tt,ve,Oa))break;if(ie.length&&(YN(de,tt,b.flow,te,ie)||(ce=!1,Po(de,tt,ve,Oa))))break}}{const b=M=>M.y+M.height/2,C=[];for(const M of T.keys()){if(!To(M))continue;const D=R.filter(H=>H.flow.target===M);if(D.length!==1)continue;const I=p(D[0].flow.source),L=p(M);!I||!L||!T.has(I.id)||Math.abs(b(I)-b(L))>1||L.x-(I.x+I.width)<=j+1||C.push({id:M,pred:I,node:L})}C.sort((M,D)=>M.node.x-D.node.x);for(const{id:M}of C){const D=T.get(M),I=p(M),L=p(R.find(J=>J.flow.target===M).flow.source);if(!I||!L)continue;const H=I.x-(L.x+L.width);if(H<=j+1)continue;const F=f(D.node.participant),N=Mo(M,J=>J.x>=I.x),q=Jr(),Y=jN(N,F,-(H-j));if(!Y)continue;const oe=Jr();(oe.bad>q.bad||oe.crossings>=q.crossings||oe.straight<q.straight)&&Y()}}lE(!0);const KN=10,XN=400,ZN=b=>[...b.incoming??[],...b.outgoing??[]].filter(C=>C.type==="bpmn:DataInputAssociation"||C.type==="bpmn:DataOutputAssociation").map(C=>C.source===b?C.target:C.source).filter(C=>!!C&&typeof C.y=="number"),QN=o.filter(b=>b.type==="bpmn:DataStoreReference"&&g.has(b.id)),JN=(b,C)=>{const M=b.x+b.width/2,D=b.y+b.height/2;let I;for(const L of QN){if((d(L)??u())!==C||L.y<b.y+b.height)continue;const H=Math.abs(L.x+L.width/2-M);H>XN||H<L.width||!ZN(L).some(N=>N.height===b.height&&Math.abs(N.y+N.height/2-D)<=KN&&L.y>=N.y+N.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 C=b.associations??[],M=C.map(L=>L.source===b.dataStore.id?L.target:L.source).map(p).find(Boolean),D=M?d(M)??u():u(),I=M?{x:M.x+M.width/2,y:JN(M,D)??M.y+M.height+110}:{x:200,y:_t+60};n.createShape({type:"bpmn:DataStoreReference",businessObject:i.create("bpmn:DataStoreReference",{id:b.dataStore.id,name:b.dataStore.name})},I,D);for(const L of C)cE(b.dataStore.id,L)}for(const b of v){const M=f(b.association.target).type==="bpmn:DataStoreReference"?b.association.target:b.association.source;cE(M,b.association)}let vE=0;const ko=10,bE=40,e$=(b,C)=>{const M=C.map(N=>d(N)).filter(N=>!!N);for(const N of M){const q=ko,Y=N.y,oe=N.y+N.height,J=N.x,de=N.x+N.width;if(Math.abs(b.y-Y)<q){const pe=Y+q-b.y;b.y+=pe,b.height-=pe}if(Math.abs(b.y+b.height-oe)<q&&(b.height=oe-q-b.y),Math.abs(b.x-J)<q){const pe=J+q-b.x;b.x+=pe,b.width-=pe}Math.abs(b.x+b.width-de)<q&&(b.width=de-q-b.x)}if(!M.length)return;const D=Math.min(...M.map(N=>N.y)),I=Math.max(...M.map(N=>N.y+N.height)),L=D-b.y,H=b.y+b.height-I,F=bE-ko;if(L>0!=H>0)if(L>0&&L<F){const N=L+ko;b.y+=N,b.height-=N}else H>0&&H<F&&(b.height-=H+ko)},t$=(b,C)=>{const M=ko,D=30,I=o.filter(L=>L.type==="bpmn:Group"&&L.id!==C);for(const L of I){const H=L.x,F=L.x+L.width,N=L.y,q=L.y+L.height,Y=b.y<q&&N<b.y+b.height,oe=b.x<F&&H<b.x+b.width;if(Y){if(Math.abs(b.x-F)<M){const J=Math.min(F+M-b.x,D);J>0&&b.width-J>0&&(b.x+=J,b.width-=J)}if(Math.abs(b.x+b.width-H)<M){const J=Math.min(b.x+b.width-(H-M),D);J>0&&b.width-J>0&&(b.width-=J)}}if(oe){if(Math.abs(b.y-q)<M){const J=Math.min(q+M-b.y,D);J>0&&b.height-J>0&&(b.y+=J,b.height-=J)}if(Math.abs(b.y+b.height-N)<M){const J=Math.min(b.y+b.height-(N-M),D);J>0&&b.height-J>0&&(b.height-=J)}}}},zh=(b,C)=>{const M=bE,D=Math.min(...b.map(N=>N.x))-M,I=Math.min(...b.map(N=>N.y))-M,L=Math.max(...b.map(N=>N.x+N.width))+M,H=Math.max(...b.map(N=>N.y+N.height))+M,F={x:D,y:I,width:L-D,height:H-I};return e$(F,b),t$(F,C),F};for(const b of E){const C=(b.group.members??[]).map(p).filter(I=>!!I);let M;C.length?M=zh(C,b.group.id):(M={x:300+vE*350,y:40,width:300,height:200},vE++);const D=n.createShape({type:"bpmn:Group",businessObject:i.create("bpmn:Group",{id:b.group.id}),width:M.width,height:M.height},{x:M.x+M.width/2,y:M.y+M.height/2},u());b.group.name&&n.updateLabel(D,b.group.name),(OE=b.group.members)!=null&&OE.length&&k(D,"bwl:Members",{refs:b.group.members.join(" ")})}{const b=o.filter(I=>!!I.waypoints),C=new Map,M=(I,L)=>{!I||!L||(C.has(I)||C.set(I,new Set),C.get(I).add(L))};for(const I of b){const L=(DE=I.source)==null?void 0:DE.id,H=(LE=I.target)==null?void 0:LE.id;M(L,H),((IE=I.type)!=null&&IE.includes("DataOutputAssociation")||(BE=I.type)!=null&&BE.includes("DataInputAssociation")||I.type==="bpmn:Association")&&M(H,L)}const D=o.filter(I=>I.type==="bpmn:Group");for(const I of D){const H=(((NE=I.businessObject.extensionElements)==null?void 0:NE.values)??[]).find(Re=>Re.$type==="bwl:Members"),F=((H==null?void 0:H.refs)??"").split(" ").filter(Boolean);if(!F.length)continue;const N=new Set(F),q=[...F];for(;q.length;){const Re=q.shift();for(const te of C.get(Re)??[])N.has(te)||(N.add(te),q.push(te))}const Y=I.x,oe=I.x+I.width,J=I.y,de=I.y+I.height,pe=Re=>R.filter(te=>te.flow.target===Re).length,ge=Re=>{var ie;const te=((ie=p(Re))==null?void 0:ie.type)??"";if(te==="bpmn:StartEvent"&&pe(Re)===0)return!1;if(te.endsWith("Gateway")){const ce=R.filter(ve=>ve.flow.target===Re).map(ve=>ve.flow.source);if(ce.length&&ce.every(ve=>{var Ve;return((Ve=p(ve))==null?void 0:Ve.type)==="bpmn:StartEvent"&&pe(ve)===0}))return!1}return!0},tt=o.filter(Re=>vr(Re)).filter(Re=>Re.type!=="bpmn:Group"&&Re.type!=="bpmn:Participant"&&Re.type!=="bpmn:TextAnnotation"&&!N.has(Re.id)&&To(Re.id)&&ge(Re.id)&&Re.x<oe&&Re.x+Re.width>Y&&Re.y<de&&Re.y+Re.height>J);if(tt.length)for(const Re of[-1,1]){const te=tt.filter(xe=>(xe.x+xe.width-Y<=oe-xe.x?-1:1)===Re);if(!te.length)continue;const ie=[];for(const xe of te){const ae=ie.find(ye=>ye.some(Le=>xe.y<Le.y+Le.height&&xe.y+xe.height>Le.y));ae?ae.push(xe):ie.push([xe])}const ce=new Map;for(const xe of ie){let ae=Re<0?Y-ko:oe+ko;for(const ye of[...xe].sort((Le,Ye)=>Re<0?Ye.x-Le.x:Le.x-Ye.x)){const Le=Re<0?Math.min(ye.x,ae-ye.width):Math.max(ye.x,ae);ae=Re<0?Le-Mi:Le+ye.width+Mi,Le!==ye.x&&Math.sign(Le-ye.x)===Re&&ce.set(ye.id,Le-ye.x)}}const ve=new Map,Ve=xe=>ve.get(xe)===xe||!ve.get(xe)?xe:Ve(ve.get(xe));for(const xe of te)ve.set(xe.id,xe.id);for(const xe of x){const ae=ce.has(xe.flow.source)?xe.flow.source:void 0,ye=ce.has(xe.flow.target)?xe.flow.target:void 0;if(!ae||!ye)continue;const Le=p(xe.flow.id);(($E=Le==null?void 0:Le.waypoints)==null?void 0:$E.length)===2&&ve.set(Ve(ae),Ve(ye))}const We=new Map;for(const xe of te){if(!ce.has(xe.id))continue;const ae=Ve(xe.id);We.set(ae,[...We.get(ae)??[],xe])}const St=[...We.values()].sort((xe,ae)=>Re<0?Math.min(...xe.map(ye=>ye.x))-Math.min(...ae.map(ye=>ye.x)):Math.max(...ae.map(ye=>ye.x))-Math.max(...xe.map(ye=>ye.x))),$t=[];let be=!0;for(const xe of St){const ae=xe.map(Ye=>ce.get(Ye.id)??0).reduce((Ye,ke)=>Math.abs(ke)>Math.abs(Ye)?ke:Ye,0),ye=new Map;let Le=!0;for(const Ye of xe){const ke=d(Ye);if(!ke){Le=!1;break}ye.has(ke.id)||ye.set(ke.id,{subtree:[],pool:ke}),ye.get(ke.id).subtree.push(Ye)}Le&&Po([...ye.values()],ae,()=>!0,Oa)?$t.push({shapes:xe,dx:ae}):be=!1}if(!be)for(const xe of $t.reverse())n.moveElements(xe.shapes,{x:-xe.dx,y:0})}}}{const b=new Set([...E.map(C=>C.group.id),...Qt(e,"group.update").map(C=>C.id)]);for(const C of o.filter(M=>M.type==="bpmn:Group")){if(b.has(C.id))continue;const D=(((FE=C.businessObject.extensionElements)==null?void 0:FE.values)??[]).find(F=>F.$type==="bwl:Members"),I=((D==null?void 0:D.refs)??"").split(" ").filter(Boolean).map(p).filter(F=>!!F);!I.length||!I.some(F=>{const N=g.get(F.id);return!N||N.x!==F.x||N.y!==F.y})||!I.some(F=>F.x<C.x||F.y<C.y||F.x+F.width>C.x+C.width||F.y+F.height>C.y+C.height)||n.resizeShape(C,zh(I,C.id))}}{const C=new Map(co(Xe(o)).map(F=>[F.owner,F.rect])),M=o.filter(F=>!!F.waypoints),D=new Map,I=(F,N)=>{!F||!N||(D.has(F)||D.set(F,new Set),D.get(F).add(N))};for(const F of M){const N=(jE=F.source)==null?void 0:jE.id,q=(HE=F.target)==null?void 0:HE.id;I(N,q),((zE=F.type)!=null&&zE.includes("DataOutputAssociation")||(GE=F.type)!=null&&GE.includes("DataInputAssociation")||F.type==="bpmn:Association")&&I(q,N)}const L=F=>R.filter(N=>N.flow.target===F).length,H=F=>{var q;const N=((q=p(F))==null?void 0:q.type)??"";if(N==="bpmn:StartEvent"&&L(F)===0)return!1;if(N.endsWith("Gateway")){const Y=R.filter(oe=>oe.flow.target===F).map(oe=>oe.flow.source);if(Y.length&&Y.every(oe=>{var J;return((J=p(oe))==null?void 0:J.type)==="bpmn:StartEvent"&&L(oe)===0}))return!1}return!0};for(const F of o.filter(N=>N.type==="bpmn:Group")){const q=(((VE=F.businessObject.extensionElements)==null?void 0:VE.values)??[]).find(ae=>ae.$type==="bwl:Members"),Y=((q==null?void 0:q.refs)??"").split(" ").filter(Boolean);if(!Y.length)continue;const oe=Y.map(p).filter(ae=>!!ae);if(!oe.length||!(E.some(ae=>ae.group.id===F.id)||Qt(e,"group.update").some(ae=>ae.id===F.id)||oe.some(ae=>{const ye=g.get(ae.id);return!ye||ye.x!==ae.x||ye.y!==ae.y})))continue;const de=new Set(Y),pe=[...Y];for(;pe.length;){const ae=pe.shift();for(const ye of D.get(ae)??[])de.has(ye)||(de.add(ye),pe.push(ye))}const ge=F.x,tt=F.x+F.width,Re=F.y,te=F.y+F.height,ie=ae=>{const ye=C.get(ae.id),Le={x:ae.x,y:ae.y,width:ae.width,height:ae.height};return ye?[Le,{x:ye.x,y:ye.y,width:ye.width,height:ye.height}]:[Le]},ce=oe.flatMap(ie),ve=Math.min(...ce.map(ae=>ae.x)),Ve=Math.max(...ce.map(ae=>ae.x+ae.width)),We=Math.min(...ce.map(ae=>ae.y)),St=Math.max(...ce.map(ae=>ae.y+ae.height)),$t={L:ve-ge,R:tt-Ve,T:We-Re,B:te-St},be=o.filter(ae=>vr(ae)).filter(ae=>ae.type!=="bpmn:Group"&&ae.type!=="bpmn:Participant"&&ae.type!=="bpmn:TextAnnotation"&&!de.has(ae.id)&&H(ae.id)&&ae.x<tt&&ae.x+ae.width>ge&&ae.y<te&&ae.y+ae.height>Re);if(!be.length)continue;const xe={L:0,R:0,T:0,B:0};for(const ae of be){const ye=ie(ae),Le=Math.min(...ye.map(Me=>Me.x)),Ye=Math.max(...ye.map(Me=>Me.x+Me.width)),ke=Math.min(...ye.map(Me=>Me.y)),He=Math.max(...ye.map(Me=>Me.y+Me.height)),Qe={L:Ye-ge,R:tt-Le,T:He-Re,B:te-ke},we=["L","R","T","B"].filter(Me=>Qe[Me]<=$t[Me]+.001);if(!we.length)continue;const ot=we.reduce((Me,wt)=>Qe[wt]<Qe[Me]?wt:Me,we[0]);xe[ot]=Math.max(xe[ot],Math.min(Qe[ot]+10,$t[ot]))}!xe.L&&!xe.R&&!xe.T&&!xe.B||n.resizeShape(F,{x:F.x+xe.L,y:F.y+xe.T,width:F.width-xe.L-xe.R,height:F.height-xe.T-xe.B})}}const xE=b=>{const C=b.waypoints;if(C!=null&&C.length){const D=C[Math.floor((C.length-1)/2)];return{x:D.x,y:D.y,width:0,height:0}}const M=b;return{x:M.x,y:M.y,width:M.width,height:M.height}};let Us=0;const _E=12,wE=14,n$=15,i$=300,r$=b=>{const C=b.split(`
|
|
7
7
|
`),M=Math.max(...C.map(L=>Go(L,_E))),D=Math.max(100,Math.min(i$,Math.ceil(M)+wE)),I=C.reduce((L,H)=>L+Math.max(1,Math.ceil((Go(H,_E)+wE)/D)),0);return{width:D,height:Math.max(30,I*n$+10)}};for(const b of _){const C=b.association,M=((WE=b.placement)==null?void 0:WE.anchor)??(C?C.source===b.annotation.id?C.target:C.source:void 0),D=M?p(M):void 0,I=D?xE(D):void 0,L=r$(b.annotation.text??"");let H;if(I&&b.placement){const[Y,oe]=Sc[b.placement.side],J=b.placement.offset??50;H={x:I.x+I.width/2+Y*(I.width/2+L.width/2+J),y:I.y+I.height/2+oe*(I.height/2+L.height/2+J)}}else I?(H={x:I.x+I.width/2+180+Us%3*260,y:I.y-110-Us%2*95},Us++):(H={x:300+Us*260,y:60},Us++);const F=D?d(D)??u():u(),N=F;I&&typeof N.x=="number"&&typeof N.width=="number"&&N.type==="bpmn:Participant"&&(H=Dp(o,I,L,N,b.placement?{placement:b.placement}:{from:H}));const q=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,F);if(C){const Y=oe=>oe===b.annotation.id?q:f(oe);n.connect(Y(C.source),Y(C.target),C.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:C.id})}:{type:"bpmn:Association"})}b.placement&&k(q,"bwl:Placement",B(b.placement))}for(const b of Qt(e,"association.add")){const C=b.association;n.connect(f(C.source),f(C.target),C.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:C.id})}:{type:"bpmn:Association"})}const EE=()=>new Set(o.getAll().filter(b=>b.type!=="label").map(b=>b.id));for(const b of Qt(e,"node.update")){let C=f(b.id);if(b.type&&Ec(b.type)!==C.type){const M=C.x+C.width/2,D=C.y+C.height/2,I=EE();C=c.replaceElement(C,{type:Ec(b.type),...b.eventDefinition?{eventDefinitionType:Qs[b.eventDefinition]}:{}});const L=EE(),H=[...I].filter(q=>q!==b.id&&!L.has(q));if(H.length)throw new Cg({kind:"type-change-drops-elements",opIndex:e.indexOf(b),id:b.id,type:b.type,dropped:H});const F=Math.round(M-(C.x+C.width/2)),N=Math.round(D-(C.y+C.height/2));if(F!==0||N!==0){n.moveShape(C,{x:F,y:N});for(const q of[...C.incoming??[],...C.outgoing??[]])Ta(q)}}if(b.name!==void 0&&n.updateProperties(C,{name:b.name??void 0}),b.lane||b.band!==void 0){b.band!==void 0&&n.updateProperties(C,{"bwl:band":b.band});const M=C.y+C.height/2,D=d(C),I=b.lane?f(b.lane):((D==null?void 0:D.children)??[]).find(H=>H.type==="bpmn:Lane"&&M>=H.y&&M<=H.y+H.height);b.band!==void 0&&ft(I==null?void 0:I.id,b.band,D);const L=I?I.y+(b.band===void 0?I.height/2:Math.min(I.height/2,me)+S(I.id,b.band)*O):b.band!==void 0&&D?D.y+Q+S(`pool:${D.id}`,b.band)*O:void 0;if(L!==void 0){const H=L-M;H!==0&&n.moveElements([C],{x:0,y:H})}}}for(const b of Qt(e,"sequenceFlow.update")){const C=f(b.id);if(b.source!==void 0||b.target!==void 0){const M=C,D=b.source!==void 0?f(b.source):M.source,I=b.target!==void 0?f(b.target):M.target,L=N=>({x:N.x+N.width/2,y:N.y+N.height/2});n.reconnect(M,D,I,[L(D),L(I)]);const H=sE.get(M.id),F=I.y+I.height/2;if(H&&I.x>H.exit.x&&Math.abs(F-H.exit.y)>1){n.updateWaypoints(M,[H.exit,{x:H.exit.x,y:F},{x:I.x,y:F}]);const N=M.label;if(N&&H.label){const Y=Math.abs(H.label.y+N.height/2-H.channelY)<=O/5&&H.label.x+N.width>H.exit.x,oe=H.exit.x+6,J=I.x-6-N.width,de=Y?J>=oe?{x:Math.max(oe,Math.min(H.label.x,J)),y:H.label.y+(F-H.channelY)}:void 0:H.label;de&&(de.x!==N.x||de.y!==N.y)&&n.moveElements([N],{x:de.x-N.x,y:de.y-N.y})}}else Math.abs(F-(D.y+D.height/2))>1&&Ta(M)}b.name!==void 0&&n.updateProperties(C,{name:b.name??void 0}),b.condition!==void 0&&n.updateProperties(C,{name:((UE=b.condition)==null?void 0:UE.label)??void 0})}for(const b of Qt(e,"messageFlow.update"))b.name!==void 0&&n.updateProperties(f(b.id),{name:b.name??void 0});for(const b of Qt(e,"dataStore.update"))b.name!==void 0&&n.updateProperties(f(b.id),{name:b.name??void 0});for(const b of Qt(e,"annotation.update")){const C=f(b.id);if(b.text!==void 0&&n.updateProperties(C,{text:b.text}),b.placement===null)k(C,"bwl:Placement",null);else if(b.placement){const M=f(b.placement.anchor),D=xE(M),I=d(M)??u(),L=typeof I.x=="number"&&typeof I.width=="number"&&I.type==="bpmn:Participant",[H,F]=Sc[b.placement.side],N=b.placement.offset??50,q={x:D.x+D.width/2+H*(D.width/2+C.width/2+N),y:D.y+D.height/2+F*(D.height/2+C.height/2+N)},Y=L?Dp(o,D,{width:C.width,height:C.height},I,{placement:b.placement,selfId:b.id}):q;n.moveElements([C],{x:Y.x-(C.x+C.width/2),y:Y.y-(C.y+C.height/2)}),k(C,"bwl:Placement",B(b.placement))}}for(const b of Qt(e,"group.update")){const C=f(b.id);if(b.name!==void 0&&n.updateLabel(C,b.name??""),b.members){const M=b.members.map(p).filter(D=>!!D);M.length&&n.resizeShape(C,zh(M,b.id)),k(C,"bwl:Members",{refs:b.members.join(" ")})}}}function Lp(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 WR(e,t,n){var u,p;const{elementRegistry:i}=e,r=e.modeling,o=f=>ht(f).filter(d=>!t.has(ut(d))),a=f=>{var d;return((d=i.get(f))==null?void 0:d.type)==="bpmn:TextAnnotation"},s=Xe(i),c=o(s),l=[...new Set(c.flatMap(Lp))].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 me=d.x+d.width/2,Pe=d.y+d.height/2;h=i.getAll().find(De=>{if(De.type!=="bpmn:Participant")return!1;const Ke=De;return typeof Ke.x=="number"&&typeof Ke.width=="number"&&me>=Ke.x&&me<=Ke.x+Ke.width&&Pe>=Ke.y&&Pe<=Ke.y+Ke.height})}if(!h||typeof h.x!="number"||typeof h.width!="number")continue;const R=(((u=d.businessObject.extensionElements)==null?void 0:u.values)??[]).find(me=>me.$type==="bwl:Placement"),x=[...d.incoming??[],...d.outgoing??[]].find(me=>me.type==="bpmn:Association"),m=(R!=null&&R.anchor?i.get(R.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},k=R==null?void 0:R.side,B=[];k&&k in Sc&&B.push(Dp(i,_,E,h,{placement:{side:k,offset:(R==null?void 0:R.offset)??null},selfId:f}));for(const[me,Pe]of[[-1,0],[1,0],[0,-1],[0,1]])for(let De=1;De<=VR;De++)B.push({x:T.x+me*Rg*De,y:T.y+Pe*Rg*De});const P={...s,edges:s.edges.filter(me=>me.id!==(x==null?void 0:x.id))},O=o(P),j=O.filter(me=>Lp(me).includes(f)).length;if(!j)continue;let Q;for(const me of B){const Pe=me.x-T.x,De=me.y-T.y;if(!Pe&&!De||me.x-E.width/2<h.x||me.x+E.width/2>h.x+h.width||me.y-E.height/2<h.y||me.y+E.height/2>h.y+h.height)continue;const Ke={...P,shapes:P.shapes.map(ne=>ne.id===f?{...ne,x:ne.x+Pe,y:ne.y+De}:ne)},rt=o(Ke),Ae=rt.filter(ne=>Lp(ne).includes(f)).length;if(Ae>=j||rt.length>O.length)continue;const X=Math.abs(Pe)+Math.abs(De);if((!Q||Ae<Q.mine||Ae===Q.mine&&(rt.length<Q.all||rt.length===Q.all&&X<Q.dist))&&(Q={x:me.x,y:me.y,mine:Ae,all:rt.length,dist:X}),Q.mine===0&&Q.all<O.length)break}Q&&r.moveElements([d],{x:Q.x-T.x,y:Q.y-T.y})}}const UR=60;function Ip(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 qR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=u=>ht(u).filter(p=>!t.has(ut(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 R of n.shapes)R.type!=="bpmn:Group"||f.has(R.id)||[...d].some(x=>{const m=s.get(x);return m&&c(R,m)})&&(f.add(R.id),y=!0);for(const R of n.shapes)R.type!=="bpmn:Participant"||d.has(R.id)||[...f].some(x=>{const m=s.get(x);return m&&c(m,R)})&&(d.add(R.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 R=s.get(y);return R&&c(R,h)})).map(h=>h.id);return[...d,...f,...g]};for(let u=0;u<6;u++){const p=Xe(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(_),k=g.get(E);if(!T||!k)continue;const[B,P]=T.x<=k.x?[T,k]:[k,T];if(v.contained)continue;const O=s.get(B.id),j=s.get(P.id),Q=O&&j?Math.max(j.x-(O.x+O.width),0):UR,me=B.x+B.width+Q-P.x;if(me<=0)continue;const Pe=l(P.id).filter(De=>i.get(De));Pe.length&&(!h||me>h.dx)&&(h={movers:Pe,dx:me})}if(!h)return;const y=h.movers.map(v=>i.get(v)).filter(v=>!!v&&typeof v.x=="number");if(!y.length)return;const R=f.length,x=d.length;r.moveElements(y,{x:h.dx,y:0});const m=o(Xe(i));if(!(a(m).length<x&&m.length<=R)){r.moveElements(y,{x:-h.dx,y:0});return}}}const Rc=.5,Mg=150;function YR(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)>Rc)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))>Rc))return;const l=s.map(m=>m.x+m.width);if(Math.max(...l)-Math.min(...l)<=Rc)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(..._)+Mg))}const h=s.filter(m=>Math.abs(u(m)-g)>Rc);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(O=>O.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},O=new Set([m.id,..._.map(Q=>Q.id),...E.map(Q=>Q.id),...T.map(Q=>Q.id)]);if(n.getAll().some(Q=>{var De;if("waypoints"in Q&&Q.waypoints||Q.type==="bpmn:Group"||!p(Q))return!1;const me=Q.type==="label"?(De=Q.labelTarget)==null?void 0:De.id:Q.id;if(!me||O.has(me)||O.has(Q.id))return!1;const Pe=Q;return Pe.x<P.x+P.width&&Pe.x+Pe.width>P.x&&Pe.y<P.y+P.height&&Pe.y+Pe.height>P.y}))return}}const y=()=>new Set(ht(Xe(n)).map(ut)),R=y(),x=h.map(m=>m.width);for(const m of h)Ip(i,m,g-m.x,{layout:!1});[...y()].every(m=>R.has(m))||h.forEach((m,v)=>Ip(i,m,x[v],{layout:!1}))}function KR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=l=>ht(l).filter(u=>!t.has(ut(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),R=g.r+(l.x+l.width-d.r),x=g.b+(l.y+l.height-d.b),m={x:h,y,width:R-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(Xe(i)).length,_={x:u.x,y:u.y,width:u.width,height:u.height};r.resizeShape(u,m),o(Xe(i)).length>v&&r.resizeShape(u,_)}}const Cc=20,Ac=10;function XR(e,t,n,i){var p,f;const{elementRegistry:r}=e,o=e.modeling,a=d=>new Set(ht(d,{includeObservationOnly:!0}).filter(g=>g.kind==="edge-along-group-boundary").map(ut)),s=Xe(r),c=ht(s,{includeObservationOnly:!0}).filter(d=>d.kind==="edge-along-group-boundary"&&!t.has(ut(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,k=h.y,B=h.x+h.width,P=h.y+h.height;let O=T,j=k,Q=B,me=P;for(const Te of g){const $=s.edges.find(w=>w.id===Te.edge);if(!$)continue;const S=$.endpoints.some(w=>{const G=s.shapes.find(Ce=>Ce.id===w);if(!G||G.container)return!1;const V=G.x+G.width/2,ee=G.y+G.height/2;return T<V&&V<B&&k<ee&&ee<P});for(const w of gn($)){const G=w.axis==="v"?[k,P]:[T,B];Math.min(w.hi,G[1])-Math.max(w.lo,G[0])<vp||(w.axis==="v"?T<w.at&&w.at<B:k<w.at&&w.at<P)&&S||(w.axis==="v"?(Math.abs(w.at-T)<=Vo&&(O=Math.max(O,w.at+Cc)),Math.abs(w.at-B)<=Vo&&(Q=Math.min(Q,w.at-Cc))):(Math.abs(w.at-k)<=Vo&&(j=Math.max(j,w.at+Cc)),Math.abs(w.at-P)<=Vo&&(me=Math.min(me,w.at-Cc))))}}if(O>m-Ac&&(O=T),j>v-Ac&&(j=k),Q<_+Ac&&(Q=B),me<E+Ac&&(me=P),O===T&&j===k&&Q===B&&me===P)continue;const Pe=r.get(d),De={x:Pe.x,y:Pe.y,width:Pe.width,height:Pe.height},Ke=Xe(r),rt=new Set(ht(Ke).map(ut)),Ae=a(Ke);o.resizeShape(Pe,{x:O,y:j,width:Q-O,height:me-j});let X=Xe(r),ne=ht(X).filter(Te=>!rt.has(ut(Te)));const U=[];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(ee=>ee.id===Te.edge),S=$&&Tp($,X),w=(f=r.get(Te.edge))==null?void 0:f.label;if(!S||!w)continue;const G=S.x-w.x,V=S.y-w.y;o.moveElements([w],{x:G,y:V}),U.push({label:w,dx:G,dy:V})}X=Xe(r),ne=ht(X).filter(Te=>!rt.has(ut(Te)))}const re=a(X),fe=[...re].some(Te=>!Ae.has(Te));if(ne.length||fe||re.size>=Ae.size){for(const Te of U.reverse())o.moveElements([Te.label],{x:-Te.dx,y:-Te.dy});o.resizeShape(Pe,De)}}}function ZR(e,t,n,i){var c;const r=n.getRootElement().businessObject,o=Zu((r==null?void 0:r.$parent)??r),a=La(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:Qu(u,i,o),requests:np(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 Pg(e,t,n={}){var B,P;const{i18n:i,lower:r=Ag}=n,o=Eg(e),a=Um(o.elementRegistry),s=wg(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=FR(t,a,i),u=i&&l.writes.size?ZR(l.writes,o.elementRegistry,o.canvas,i):void 0,p=Xe(o.elementRegistry),f=new Set(ht(p).map(ut)),d=new Set(ht(p,{includeObservationOnly:!0}).map(ut)),g=new Set(p.edges.map(O=>O.id)),h=new Set(t.flatMap(O=>O.kind==="sequenceFlow.update"&&(O.source!==void 0||O.target!==void 0)?[O.id]:[])),y=new Set(p.shapes.map(O=>O.id)),R=gc(p),x=R.length,m=new Set(R.map(([O,j])=>`${O}|${j}`)),v=new Map;for(const O of o.elementRegistry.filter(j=>"waypoints"in j&&!!j.waypoints))O.label&&v.set(O.id,{wps:O.waypoints.map(j=>({x:j.x,y:j.y})),label:{x:O.label.x,y:O.label.y},source:(B=O.source)==null?void 0:B.id,target:(P=O.target)==null?void 0:P.id});const _=e.get("commandStack");try{Zh(_,()=>{r(l.ops,o);for(const j of(u==null?void 0:u.contexts())??[])_.execute(ep,j);qR(o,f,p),YR(o,p),KR(o,f,p),Jm(o,g);const O=Cp(o,f);Xm(o,m,g),lg(o,f,g),ng(o,g),MR(o,g,h),og(o,f,g),OR(o,f,g),mg(o,f,g),hg(o,g,h),yg(o,y),WR(o,f,y),Cp(o,f,O),XR(o,d,p,g),vg(o,f),dg(o,v)})}catch(O){return{ok:!1,issues:[O instanceof Cg?O.issue:{kind:"lower-failed",message:O instanceof Error?O.message:String(O)}],findings:[],stats:c}}const E=Xe(o.elementRegistry),T=ht(E,{includeObservationOnly:!0}).filter(O=>!d.has(ut(O))),k=Bm(E);return{ok:!0,issues:[],findings:T,stats:{edgeCrossings:{before:x,after:k.pairs.length,pairs:k.pairs,solidPairs:k.solidPairs,dashedPairs:k.dashedPairs,mixedPairs:k.mixedPairs,crossPoolMessages:k.crossPoolMessages}}}}function QR(e){const t=e.slice(e.indexOf(":")+1);return t.charAt(0).toLowerCase()+t.slice(1)}function Tg(e,t){return typeof e.get=="function"?e.get(t):e[t]}function kg(e,t){const n=Tg(e,t);return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Og(e,t){var i;return(((i=e.extensionElements)==null?void 0:i.values)??[]).find(r=>(r==null?void 0:r.$type)===t)}function JR(e){return typeof e=="string"&&Uu.includes(e)}function ki(e){if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:void 0}function Dg(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=[],R=[],x=[],m=new Map,v=new Set,_=new Set,E=X=>{X&&v.add(X)},T=X=>{v.add(X),_.add(X)},k=X=>{const ne=Og(X,"bwl:Placement");if(!ne)return;const U=typeof ne.anchor=="string"?ne.anchor:void 0;if(!U||!JR(ne.side))return;const K=typeof ne.offset=="number"?ne.offset:void 0;y.push({owner:X.id,anchor:U,side:ne.side,...K!==void 0?{offset:K}:{}})},B=X=>{const ne=Og(X,"bwl:Members"),U=typeof(ne==null?void 0:ne.refs)=="string"?ne.refs.split(/\s+/).filter(Boolean):[];U.length&&x.push({owner:X.id,refs:U})},P=X=>{var ne;for(const U of X)switch(E(U.id),U.$type){case"bpmn:TextAnnotation":T(U.id),m.set(U.id,U),c.push({id:U.id,text:typeof U.text=="string"?U.text:""}),k(U);break;case"bpmn:Association":g.push({id:U.id,type:U.$type,source:ki(U.sourceRef),target:ki(U.targetRef)});break;case"bpmn:Group":{T(U.id),m.set(U.id,U);const K=(ne=U.categoryValueRef)==null?void 0:ne.value;l.push({id:U.id,...typeof K=="string"&&K?{name:K}:{}}),B(U);break}default:u.push({id:U.id,type:U.$type,reason:"type-outside-mvp"})}},O=X=>{for(const ne of X.flowElements??[])E(ne.id),u.push({id:ne.id,type:ne.$type,reason:"inside-container"}),(ne.flowElements??[]).length&&O(ne);for(const ne of X.artifacts??[])E(ne.id),u.push({id:ne.id,type:ne.$type,reason:"inside-container"})},j=(X,ne)=>{const U=X.flowElements??[],K=(X.laneSets??[]).flatMap(fe=>fe.lanes??[]),re=new Map;for(const fe of K){E(fe.id),m.set(fe.id,fe);for(const Te of fe.flowNodeRef??[]){const $=ki(Te);$&&re.set($,fe.id)}}for(const fe of U){if(E(fe.id),m.set(fe.id,fe),fe.$type==="bpmn:SequenceFlow"){f.push({id:fe.id,source:ki(fe.sourceRef),target:ki(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=QR(fe.$type),$=Te==="intermediateCatchEvent"?Vu((fe.eventDefinitions??[]).map(V=>V.$type)):void 0;if(!Wh(Te)||Te==="intermediateCatchEvent"&&!$){u.push({id:fe.id,type:fe.$type,reason:"type-outside-mvp"});continue}T(fe.id);const S=Te==="boundaryEvent"?ki(fe.attachedToRef):void 0;a.push({id:fe.id,type:Te,...fe.name?{name:fe.name}:{},...ne?{participant:ne}:{},...re.has(fe.id)?{lane:re.get(fe.id)}:{},...S?{attachedTo:S}:{},...$?{eventDefinition:$}:{}}),Te==="subProcess"&&O(fe);const w=kg(fe,"bwl:band");w!==void 0&&(p.bands[fe.id]=w);const G=Tg(fe,"bwl:afterColumn");typeof G=="string"&&G!==""&&R.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:ki(V.targetRef)});for(const V of fe.dataInputAssociations??[])E(V.id),h.push({id:V.id,type:V.$type,source:ki((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 U=ki(ne.processRef);U&&X.add(U);const K=U?r.get(U):void 0,re=((K==null?void 0:K.laneSets)??[]).flatMap(S=>S.lanes??[]),fe=re.map(S=>({id:S.id,...S.name?{name:S.name}:{}}));for(const S of fe)T(S.id);const Te=!K||(K.flowElements??[]).length===0&&re.length===0&&(K.artifacts??[]).length===0;o.push({id:ne.id,...ne.name?{name:ne.name}:{},...Te?{blackBox:!0}:{},...fe.length?{lanes:fe}:{}});const $=kg(ne,"bwl:poolOrder");$!==void 0&&(p.poolOrders[ne.id]=$),K&&j(K,ne.id)}for(const ne of i.messageFlows??[])E(ne.id),m.set(ne.id,ne),d.push({id:ne.id,source:ki(ne.sourceRef),target:ki(ne.targetRef),...typeof ne.name=="string"&&ne.name?{name:ne.name}:{}});P(i.artifacts??[]);for(const[ne,U]of r)!X.has(ne)&&(U.flowElements??[]).length>0&&u.push({id:ne,type:U.$type,reason:"unreachable-process"})}else for(const X of r.values())j(X);const Q=[],me=[],Pe=[],De=[],Ke=(X,ne)=>!!X&&!!ne&&_.has(X)&&_.has(ne);for(const X of f){if(!Ke(X.source,X.target)){u.push({id:X.id,type:"bpmn:SequenceFlow",reason:"endpoint-outside-mvp"});continue}Q.push({id:X.id,source:X.source,target:X.target,...X.name?{name:X.name}:{}}),_.add(X.id)}for(const X of d){if(!Ke(X.source,X.target)){u.push({id:X.id,type:"bpmn:MessageFlow",reason:"endpoint-outside-mvp"});continue}me.push({id:X.id,source:X.source,target:X.target,...X.name?{name:X.name}:{}}),_.add(X.id)}for(const X of h){if(!Ke(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(!Ke(X.source,X.target)){u.push({id:X.id??"",type:X.type,reason:"endpoint-outside-mvp"});continue}Pe.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 U=ne.filter(re=>v.has(re)),K=rt.get(X);K&&U.length&&(K.members=U)}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 R)v.has(ne)&&(p.afterColumns[X]=ne);const Ae={...o.length?{participants:o}:{},nodes:a,sequenceFlows:Q,...me.length?{messageFlows:me}:{},...s.length?{dataStores:s}:{},...De.length?{dataAssociations:De}:{},...c.length?{annotations:c}:{},...Pe.length?{associations:Pe}:{},...l.length?{groups:l}:{}};return t.i18n?{definition:Ae,hints:p,omitted:u,i18n:eC(Ae,m,e,t.i18n)}:{definition:Ae,hints:p,omitted:u}}function eC(e,t,n,i){const r=Zu(n),o=La(i),a=[],s=(c,l)=>{const u=t.get(c.id);if(!u)return;const p=Qu(u,i,r);Object.keys(p).length&&(c[l]=p);for(const f of np(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 tC(e,t={}){const{definitions:n,warnings:i}=await Ho(e);return{...Dg(n,t),warnings:i}}const nC=new Set(["bpmn:ExclusiveGateway","bpmn:ParallelGateway","bpmn:InclusiveGateway","bpmn:EventBasedGateway","bpmn:ComplexGateway"]);function Bp(e){if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:void 0}function iC(e){return Bp(e.processRef)!==void 0}function rC(e){const t=new Set,n=r=>{const o=Bp(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 oC(e){const t=[],n=i=>{for(const r of i.flowElements??[])nC.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 aC(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 Np(e){const t=[],n=e.rootElements??[],i=rC(e);for(const o of oC(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??[])iC(s)&&aC(o.get(Bp(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 sC(e){const{definitions:t,warnings:n}=await Ho(e);return{issues:Np(t),warnings:n}}const cC=.5,lC=8,uC=new Set(["bpmn:Definitions","bpmn:Collaboration","bpmn:Process","bpmn:LaneSet","bpmn:ExtensionElements","bpmn:Documentation","bpmn:Relationship","bpmn:Property","bpmn:Category","bpmn:CategoryValue"]),Xo=e=>typeof e=="number"?e:Number(e??NaN),Mc=e=>{if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:""};function pC(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}=${Mc(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=>`${Mc(s)}:${typeof(s==null?void 0:s.value)=="string"?s.value:""}`).sort().join(",")}]`)}Array.isArray(t.flowNodeRef)&&n.push(`lane=[${t.flowNodeRef.map(Mc).sort().join(",")}]`);const r=t.conditionExpression;return r&&typeof r.body=="string"&&n.push(`cond=${r.body}`),n.join("|")}function fC(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?[Xo(s.x),Xo(s.y),Xo(s.width),Xo(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=Mc(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=>[Xo(f.x),Xo(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 Lg(e){const t=fC(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:")&&!uC.has(s)&&n.set(c,{type:s,props:pC(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 Ig(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 Bg(e,t,n={}){const i=n.moveTolerance??cC,r=Lg(e),o=Lg(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||Ig(p.geometry,u.geometry,i)||Ig(p.label,u.label,n.labelTolerance??lC))&&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 dC(e,t,n={}){const[i,r]=await Promise.all([Ho(e),Ho(t)]);return{...Bg(i.definitions,r.definitions,n),warnings:[...i.warnings,...r.warnings]}}function hC(e){return new Set([...e.added,...e.modified])}function mC(e,t,n,i={}){return{documentId:e,baseVersion:t,ops:[...n],origin:i.origin??"agent",clientOpId:(i.mkClientOpId??(()=>crypto.randomUUID()))()}}async function Ng(e,t,{currentVersion:n,i18n:i}){if(t.baseVersion!==n)return{status:"conflict",baseVersion:t.baseVersion,currentVersion:n};const r=Pg(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 gC=Symbol("bpmn-editor"),$p={geometry:[],semantic:[]};function yC(){const e=he.ref(!1),t=he.ref(!0),n=he.ref(!1),i=he.shallowRef($p),r=he.shallowRef(void 0),o=he.shallowRef(void 0);let a,s,c,l;const u=()=>{if(f(),!c){i.value=$p;return}const x=ht(Xe(c.get("elementRegistry")),{includeObservationOnly:!0}),m=c.getDefinitions();i.value={geometry:x,semantic:m?Np(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 R(){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=$p,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 Ng(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:yp(m)}},async saveXml(){const{xml:x}=await y().saveXML({format:!0});return e.value=!1,x??""},undo:()=>{var x;return(x=R())==null?void 0:x.undo()},redo:()=>{var x;return(x=R())==null?void 0:x.redo()},canUndo:()=>{var x;return((x=R())==null?void 0:x.canUndo())??!1},canRedo:()=>{var x;return((x=R())==null?void 0:x.canRedo())??!1}}}const vC=new RegExp("\\p{Script=Hangul}","u"),bC=/[\p{Script=Hiragana}\p{Script=Katakana}]/u,xC=new RegExp("\\p{Script=Han}","u");function Fp(e){const t=vC.test(e),n=bC.test(e);return t&&n?{script:"mixed"}:t?{script:"hangul",locale:"ko"}:n?{script:"kana",locale:"ja"}:{script:xC.test(e)?"han":"other"}}function $g(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 Fg(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:$o(a).filter(l=>kn(l))})}return n}const za=e=>({id:e.bo.id,type:e.bo.$type,name:e.name});function _C(e){const t=$g(e),n=Fg(e);let i;const r={},o=[],a=[],s=[];for(const g of n){const h=g.trs.filter(y=>(y.body??"")===g.name).map(kn);if(h.length){const y=[...h].sort().join("+");r[y]=(r[y]??0)+1,i=i?new Set([...i].filter(R=>h.includes(R))):new Set(h)}else g.trs.some(y=>y.body)?o.push(za(g)):s.push({e:g,inference:Fp(g.name)});for(const y of g.trs){const R=kn(y),x=y.body??"",m=Fp(x);m.locale&&m.locale!==R?a.push({...za(g),locale:R,script:m.script}):R==="ko"&&m.script==="han"&&g.trs.some(v=>v!==y&&v.body===x)&&a.push({...za(g),locale:R,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({...za(g),locale:h.locale}):d.push({...za(g),script:h.script});return{root:{current:t,proposed:l,reason:u},additions:f,undecided:d,drift:o,matchedBy:r,scriptMismatch:a}}function wC(e,t){const n=e.$model;let i=0;if(t.root.proposed&&!$g(e)&&(e.set("xml:lang",t.root.proposed),i++),!t.additions.length)return i;const r=new Map(Fg(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=>kn(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(No,{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 EC(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jp={exports:{}},jg;function SC(){if(jg)return jp.exports;jg=1;var e=jp.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},jp.exports}var RC=SC(),CC=EC(RC);function Hi(e){if(!(this instanceof Hi))return new Hi(e);e=e||[128,36,1],this._seed=e.length?CC.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 cn={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};cn.td=cn.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],cn.option=cn.optgroup=[1,'<select multiple="multiple">',"</select>"],cn.thead=cn.tbody=cn.colgroup=cn.caption=cn.tfoot=[1,"<table>","</table>"],cn.polyline=cn.ellipse=cn.polygon=cn.circle=cn.text=cn.line=cn.path=cn.rect=cn.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];function Ot(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(cn,i)?cn[i]:cn._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 AC(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 Nn(e,...t){const n=e.style;return z(t,function(i){i&&z(i,function(r,o){n[o]=r})}),e}function Dn(e,t,n){return arguments.length==2?e.getAttribute(t):n===null?e.removeAttribute(t):(e.setAttribute(t,n),e)}const MC=Object.prototype.toString;function Nt(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 MC.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 Pc(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 PC(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Tc={},Hg;function TC(){if(Hg)return Tc;Hg=1;var e,t,n;function i(){e=window.addEventListener?"addEventListener":"attachEvent",t=window.removeEventListener?"removeEventListener":"detachEvent",n=e!=="addEventListener"?"on":""}return Tc.bind=function(r,o,a,s){return e||i(),r[e](n+o,a,s||!1),a},Tc.unbind=function(r,o,a,s){return t||i(),r[t](n+o,a,s||!1),a},Tc}var zg=TC(),kC=PC(zg),Ge=AC({__proto__:null,default:kC},[zg]),Gg=["focus","blur"];function OC(e,t,n,i,r){return Gg.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 DC(e,t,n,i){return Gg.indexOf(t)!==-1&&(i=!0),Ge.unbind(e,t,n,i)}var qn={bind:OC,unbind:DC};function Hp(e,t){return e&&typeof e.matches=="function"&&e.matches(t)||!1}function Et(e,t){return t=t||document,t.querySelector(e)}function kc(e,t){return t=t||document,t.querySelectorAll(e)}function zi(e){e.parentNode&&e.parentNode.removeChild(e)}function LC(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch{}return e}function IC(e,t){return t.appendChild(LC(e,t))}function Ue(e,t){return IC(t,e),e}var zp=2,Vg={"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":zp,"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":zp,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function BC(e,t){return Vg[t]?e.style[t]:e.getAttributeNS(null,t)}function Wg(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Vg[i];r?(r===zp&&typeof n=="number"&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function NC(e,t){var n=Object.keys(t),i,r;for(i=0,r;r=n[i];i++)Wg(e,r,t[r])}function Se(e,t,n){if(typeof t=="string")if(n!==void 0)Wg(e,t,n);else return BC(e,t);else NC(e,t);return e}const $C=Object.prototype.toString;function ct(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 $C.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 Oc(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Ug(e){return e.cloneNode(!0)}var Gp={svg:"http://www.w3.org/2000/svg"},qg='<svg xmlns="'+Gp.svg+'"';function FC(e){var t=!1;e.substring(0,4)==="<svg"?e.indexOf(Gp.svg)===-1&&(e=qg+e.substring(4)):(e=qg+">"+e+"</svg>",t=!0);var n=jC(e);if(!t)return n;for(var i=document.createDocumentFragment(),r=n.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function jC(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=FC(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(Gp.svg,e),t&&Se(n,t),n}var Vp=null;function Yg(){return Vp===null&&(Vp=Oe("svg")),Vp}function Kg(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}function HC(e,t,n,i,r,o){var a=Yg().createSVGMatrix();switch(arguments.length){case 0:return a;case 1:return Kg(a,e);case 6:return Kg(a,{a:e,b:t,c:n,d:i,e:r,f:o})}}function Ga(e){return Yg().createSVGTransform()}var Xg=/([&<>]{1})/g,zC=/([&<>\n\r"]{1})/g,GC={"&":"&","<":"<",">":">",'"':"'"};function Wp(e,t){function n(i,r){return GC[r]||r}return e.replace(t,n)}function Zg(e,t){var n,i,r,o,a;switch(e.nodeType){case 3:t.push(Wp(e.textContent,Xg));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,'="',Wp(o.value,zC),'"');if(e.hasChildNodes()){for(t.push(">"),a=e.childNodes,n=0,i=a.length;n<i;++n)Zg(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("<!--",Wp(e.nodeValue,Xg),"-->");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function VC(e){for(var t=e.firstChild,n=[];t;)Zg(t,n),t=t.nextSibling;return n.join("")}function Qg(e,t){return VC(e)}function ln(e){var t=e.parentNode;return t&&t.removeChild(e),e}function WC(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function UC(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(WC(e,i))}function Va(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),UC(n,t)),n.consolidate()}const qC=/^class[ {]/;function YC(e){return qC.test(e.toString())}function Up(e){return Array.isArray(e)}function qp(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Dc(...e){e.length===1&&Up(e[0])&&(e=e[0]),e=[...e];const t=e.pop();return t.$inject=e,t}const KC=/constructor\s*[^(]*\(\s*([^)]*)\)/m,XC=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,ZC=/\/\*([^*]*)\*\//m;function QC(e){if(typeof e!="function")throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(YC(e)?KC:XC);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map(i=>{const r=i.match(ZC);return(r&&r[1]||i).trim()})||[]}function Jg(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(qp(o,m))return o[m];if(qp(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(Up(m))m=Dc(m.slice());else throw s(`Cannot invoke "${m}". Expected a function!`);const E=(m.$inject||QC(m)).map(T=>qp(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 Dc(v=>m.get(v))}function d(m,v){if(v&&v.length){const _=Object.create(null),E=Object.create(null),T=[],k=[],B=[];let P,O,j,Q;for(let me in r)P=r[me],v.indexOf(me)!==-1&&(P[2]==="private"?(O=T.indexOf(P[3]),O===-1?(j=P[3].createChild([],v),Q=f(j),T.push(P[3]),k.push(j),B.push(Q),_[me]=[Q,me,"private",j]):_[me]=[B[O],me,"private",k[O]]):_[me]=[P[2],P[1]],E[me]=!0),(P[2]==="factory"||P[2]==="type")&&P[1].$scope&&v.forEach(Pe=>{P[1].$scope.indexOf(Pe)!==-1&&(_[me]=[P[2],P[1]],E[Pe]=!0)});v.forEach(me=>{if(!E[me])throw new Error('No provider for "'+me+'". Cannot use provider from the parent!')}),m.unshift(_)}return new Jg(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((O,j)=>(j!=="__exports__"&&j!=="__modules__"&&j!=="__init__"&&j!=="__depends__"&&(O[j]=m[j]),O),Object.create(null)),T=(_||[]).concat(E),k=d(T),B=Dc(function(O){return k.get(O)});v.forEach(function(O){r[O]=[B,O,"private",k]});const P=(m.__init__||[]).slice();return P.unshift(function(){k.init()}),m=Object.assign({},m,{__init__:P}),h(m,k)}return Object.keys(m).forEach(function(_){if(_==="__init__"||_==="__depends__")return;const E=m[_];if(E[2]==="private"){r[_]=E;return}const T=E[0],k=E[1];r[_]=[g[T],JC(T,k),T]}),h(m,a)}function R(m,v){return m.indexOf(v)!==-1||(m=(v.__depends__||[]).reduce(R,m),m.indexOf(v)!==-1)?m:m.concat(v)}function x(m){const v=m.reduce(R,[]).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 JC(e,t){return e!=="value"&&Up(t)&&(t=Dc(t.slice())),t}var eA=1e3;function nr(e,t){var n=this;t=t||eA,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 tA(e){return["M",e.x,e.y]}function Yp(e){return["L",e.x,e.y]}function nA(e,t,n){return["C",e.x,e.y,t.x,t.y,n.x,n.y]}function iA(e,t){const n=e.length,i=[tA(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(Yp(a));continue}const c=Math.min(t,Kp(a.x-o.x,a.y-o.y),Kp(s.x-a.x,s.y-a.y));if(!c){i.push(Yp(a));continue}const l=Lc(a,o,c),u=Lc(a,o,c*.5),p=Lc(a,s,c),f=Lc(a,s,c*.5);i.push(Yp(l)),i.push(nA(u,f,p))}return i}function Lc(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=Kp(i,r),a=n/o;return{x:e.x+i*a,y:e.y+r*a}}function Kp(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function Wa(e,t,n){ze(t)&&(n=t,t=null),t||(t={});const i=Oe("path",t);return ze(n)&&(i.dataset.cornerRadius=String(n)),Xp(i,e)}function Xp(e,t){const n=parseInt(e.dataset.cornerRadius,10)||0;return Se(e,{d:uo(iA(t,n))}),e}function Ic(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,$e(e)||(e=[e]),z(e,function(i,r){var o=t(i,r,n);$e(o)&&o.length&&po(o,t,n+1)})}function Zp(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 Ua(e,t){return Zp(e)}function rA(e,t,n){no(t)&&(t=!0),hn(t)&&(n=t,t=!0),n=n||{};var i=qa(n.allShapes),r=qa(n.allConnections),o=qa(n.enclosedElements),a=qa(n.enclosedConnections),s=qa(n.topLevel,t&&Io(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 Jt(e,t){t=!!t,$e(e)||(e=[e]);var n,i,r,o;return z(e,function(a){var s=a;a.waypoints&&!t&&(s=Jt(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 Zo(e,t){var n={};return z(e,function(i){var r=i;r.waypoints&&(r=Jt(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 ey(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function ty(e){return!!(e&&e.isFrame)}function qa(e,t){return W({},e||{},t||{})}var oA=1;function Cr(e,t){nr.call(this,e,oA),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}),ty(n)?Se(r,W({},this.FRAME_STYLE,i||{})):Se(r,W({},this.SHAPE_STYLE,i||{})),Ue(t,r),r},Cr.prototype.drawConnection=function(t,n,i){var r=Wa(n.waypoints,W({},this.CONNECTION_STYLE,i||{}));return Ue(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 aA(){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 W(o,{class:n})},this.style=function(n,i){!$e(n)&&!i&&(i=n,n=[]);var r=Un(n,function(o,a){return W(o,e[a]||{})},{});return i?W(r,i):r},this.computeStyle=function(n,i,r){return $e(i)||(r=i,i=[]),t.style(i||[],W({},r,n||{}))}}const sA={__init__:["defaultRenderer"],defaultRenderer:["type",Cr],styles:["type",aA]};function qt(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return n!==-1&&e.splice(n,1),n}function Yt(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 Qp(e,t){return!e||!t?-1:e.indexOf(t)}function Ya(e,t){return!e||!t?-1:Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Jp(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=Ya(e,t);return Math.abs(r/o)<=i}var cA=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(lA(r,n))return o;return!1}function lA(e,t){const n=t[0];return io(t,function(i){return Math.abs(n[e]-i[e])<=cA})}function ny(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 ef(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}var uA=/,?([a-z]),?/gi,iy=parseFloat,en=Math,Ar=en.PI,Gi=en.min,Vi=en.max,ry=en.pow,Mr=en.abs,pA=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/ig,fA=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/ig,oy=Array.isArray||function(e){return e instanceof Array};function dA(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function hA(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 mA(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 dA(r,i)?(hA(o,i),r[i]):(o.length>=1e3&&delete r[o.shift()],o.push(i),r[i]=e(...arguments),r[i])}return t}function gA(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(pA,function(i,r,o){var a=[],s=r.toLowerCase();for(o.replace(fA,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=nf,n}function yA(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 vA(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 tf(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 nf(){return this.join(",").replace(uA,"$1")}function bA(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=nf,t}function ay(e,t,n,i,r,o,a,s,c){var l=1-c,u=ry(l,3),p=ry(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:Bc(g),y:Bc(h)}}function sy(e){var t=RA(...e);return tf(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 xA(e,t){return e=tf(e),t=tf(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 cy(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 ly(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=cy(h,e,n,r,a),R=cy(h,t,i,o,s),x=y*y+R*R;d+=f[g]*en.sqrt(x)}return l*d}function _A(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=Bc(c/u),f=Bc(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 Bc(e){return Math.round(e*1e11)/1e11}function wA(e,t,n){var i=sy(e),r=sy(t);if(!xA(i,r))return[];var o=ly(...e),a=ly(...t),s=py(e)?1:~~(o/5)||1,c=py(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=ay(...e,d/s);l[d]={x:h.x,y:h.y,t:d/s}}for(d=0;d<c+1;d++)h=ay(...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],R=l[d+1],x=u[g],m=u[g+1],v=Mr(R.x-y.x)<.01?"y":"x",_=Mr(m.x-x.x)<.01?"y":"x",E=_A(y.x,y.y,R.x,R.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 k=y.t+Mr((E[v]-y[v])/(R[v]-y[v]))*(R.t-y.t),B=x.t+Mr((E[_]-x[_])/(m[_]-x[_]))*(m.t-x.t);k>=0&&k<=1&&B>=0&&B<=1&&f.push({x:E.x,y:E.y,t1:k,t2:B})}}return f}function uy(e,t,n){e=hy(e),t=hy(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 R=0,x=t.length;R<x;R++){var m=t[R];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=wA(p,f);{for(var _=0,E=v.length;_<E;_++)v[_].segment1=g,v[_].segment2=R,v[_].bez1=p,v[_].bez2=f;d=d.concat(v)}}}}}return d}function EA(e){return oy(e)&&oy(e[0])}function SA(e){if(yA(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=nf,t}function py(e){return e[0]===e[2]&&e[1]===e[3]&&e[4]===e[6]&&e[5]===e[7]}function Nc(e,t,n,i){return[e,t,n,i,n,i]}function fy(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 dy(e,t,n,i,r,o,a,s,c,l){var u=Ar*120/180,p=Ar/180*(+r||0),f=[],d,g=mA(function($,S,w){var G=$*en.cos(w)-S*en.sin(w),V=$*en.sin(w)+S*en.cos(w);return{x:G,y:V}});if(l)T=l[0],k=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,R=h*h/(n*n)+y*y/(i*i);R>1&&(R=en.sqrt(R),n=R*n,i=R*i);var x=n*n,m=i*i,v=(o==a?-1:1)*en.sqrt(Mr((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=en.asin(((t-E)/i).toFixed(9)),k=en.asin(((c-E)/i).toFixed(9));T=e<_?Ar-T:T,k=s<_?Ar-k:k,T<0&&(T=Ar*2+T),k<0&&(k=Ar*2+k),a&&T>k&&(T=T-Ar*2),!a&&k>T&&(k=k-Ar*2)}var B=k-T;if(Mr(B)>u){var P=k,O=s,j=c;k=T+u*(a&&k>T?1:-1),s=_+n*en.cos(k),c=E+i*en.sin(k),f=dy(s,c,n,i,r,0,a,O,j,[k,P,_,E])}B=k-T;var Q=en.cos(T),me=en.sin(T),Pe=en.cos(k),De=en.sin(k),Ke=en.tan(B/4),rt=4/3*n*Ke,Ae=4/3*i*Ke,X=[e,t],ne=[e+rt*me,t-Ae*Q],U=[s+rt*De,c-Ae*Pe],K=[s,c];if(ne[0]=2*X[0]-ne[0],ne[1]=2*X[1]-ne[1],l)return[ne,U,K].concat(f);f=[ne,U,K].concat(f).join().split(",");for(var re=[],fe=0,Te=f.length;fe<Te;fe++)re[fe]=fe%2?g(f[fe-1],f[fe],p).y:g(f[fe],f[fe+1],p).x;return re}function RA(e,t,n,i,r,o,a,s){for(var c=[],l=[[],[]],u,p,f,d,g,h,y,R,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),Mr(u)<1e-12){if(Mr(p)<1e-12)continue;d=-f/p,0<d&&d<1&&c.push(d);continue}y=p*p-4*f*u,R=en.sqrt(y),!(y<0)&&(g=(-p+R)/(2*u),0<g&&g<1&&c.push(g),h=(-p-R)/(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 hy(e){if(EA(e)||(e=gA(e)),vA(e))return e;for(var t=bA(SA(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",...dy(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",...fy(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",...fy(d.x,d.y,f[1],f[2],f[3],f[4])];break;case"L":f=["C",...Nc(d.x,d.y,f[1],f[2])];break;case"H":f=["C",...Nc(d.x,d.y,f[1],d.y)];break;case"V":f=["C",...Nc(d.x,d.y,d.x,f[1])];break;case"Z":f=["C",...Nc(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=iy(u[p-4])||n.x,n.by=iy(u[p-3])||n.y}return t}function Rt(e){return hn(e)&&Wn(e,"waypoints")}function Je(e){return hn(e)&&Wn(e,"labelTarget")}function CA(e){return hn(e)&&Do(e.parent)}function my(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 Ie(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function $c(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function AA(e){return rr({x:e.x+(e.width||0)/2,y:e.y+(e.height||0)/2})}function MA(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=kA(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 Fe(e){return Rt(e)?MA(e):AA(e)}function Cn(e,t,n){n=n||0,hn(n)||(n={x:n,y:n});var i=Ie(e),r=Ie(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 Ka(e,t,n){var i=PA(e,t);return i.length===1||i.length===2&&Ya(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 PA(e,t){return uy(e,t)}function TA(e){e=e.slice();for(var t=0,n,i,r;e[t];)n=e[t],i=e[t-1],r=e[t+1],Ya(n,r)===0||Jp(i,r,n)?e.splice(t,1):t++;return e}function kA(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Fc(e,t){return Math.round(e*t)/t}function gy(e){return ze(e)?e+"px":e}function OA(e){for(;e.parent;)e=e.parent;return e}function DA(e){e=W({},{width:"100%",height:"100%"},e);const t=e.container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),Nn(n,{position:"relative",overflow:"hidden",width:gy(e.width),height:gy(e.height)}),t.appendChild(n),n}function yy(e,t,n){const i=Oe("g");ct(i).add(t);const r=n!==void 0?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}const LA="base",vy=0,IA=1,BA={shape:["x","y","width","height"],connection:["waypoints"]};function je(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||{})}je.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],je.prototype._init=function(e){const t=this._eventBus,n=this._container=DA(e),i=this._svg=Oe("svg");Se(i,{width:"100%",height:"100%"}),Dn(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")}),Ue(n,i);const r=this._viewport=yy(i,"viewport");e.deferUpdate&&(this._viewboxChanged=Xu(this._viewboxChanged,300)),this._restoreFocus=Xu(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)},je.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},je.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))},je.prototype._clear=function(){this._elementRegistry.getAll().forEach(t=>{const n=ey(t);n==="root"?this.removeRootElement(t):this._removeElement(t,n)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox},je.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},je.prototype.restoreFocus=function(){this._restoreFocus()},je.prototype._restoreFocus=function(){document.activeElement===document.body&&this.focus()},je.prototype.isFocused=function(){return this._focused},je.prototype.getDefaultLayer=function(){return this.getLayer(LA,vy)},je.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},je.prototype._getChildIndex=function(e){return Un(this._layers,function(t,n){return n.visible&&e>=n.index&&t++,t},0)},je.prototype._createLayer=function(e,t){typeof t>"u"&&(t=IA);const n=this._getChildIndex(t);return{group:yy(this._viewport,"layer-"+e,n),index:t,visible:!0}},je.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},je.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&&(ln(n),t.visible=!1),n},je.prototype._removeLayer=function(e){const t=this._layers[e];t&&(delete this._layers[e],ln(t.group))},je.prototype.getActiveLayer=function(){const e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null},je.prototype.findRoot=function(e){const t=this._resolveElements(e);let n;for(const i of t){const r=this._findPlaneForRoot(OA(i));if(!r||n&&r.rootElement!==n)return;n=r.rootElement}return n},je.prototype.getRootElements=function(){return this._planes.map(function(e){return e.rootElement})},je.prototype._findPlaneForRoot=function(e){return Pt(this._planes,function(t){return t.rootElement===e})},je.prototype._resolveElement=function(e){return typeof e=="string"?this._elementRegistry.get(e):e},je.prototype._resolveElements=function(e){return $e(e)||(e=[e]),e.map(t=>this._resolveElement(t)).filter(Boolean)},je.prototype.getContainer=function(){return this._container},je.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),ct(r).add(t)):(e.markers.delete(t),ct(r).remove(t)))}),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},je.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},je.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},je.prototype.hasMarker=function(e,t){return e=this._resolveElement(e),e.markers?e.markers.has(t):!1},je.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},je.prototype.getRootElement=function(){const e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))},je.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,vy);return this.hideLayer(n),this._addRoot(e,i),this._planes.push({rootElement:e,layer:i}),e},je.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},je.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},je.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)},je.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})},je.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})},je.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=BA[e];if(!io(n,function(r){return typeof t[r]<"u"}))throw new Error("must supply { "+n.join(", ")+" } with "+e)},je.prototype._setParent=function(e,t,n){Yt(t.children,e,n),e.parent=t},je.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},je.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},je.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},je.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},je.prototype.removeShape=function(e){return this._removeElement(e,"shape")},je.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},je.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},je.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},je.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},je.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);Va(t,u)});else return o=this._rootElement?this.getActiveLayer():null,i=o&&o.getBBox()||{},a=Va(t),r=a?a.matrix:HC(),s=Fc(r.a,1e3),c=Fc(-r.e||0,1e3),l=Fc(-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},je.prototype.scroll=function(e){const t=this._viewport;let n=t.getCTM();return e&&this._changeViewbox(function(){e=W({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),by(t,n)}),{x:n.e,y:n.f}},je.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=Jt(o),s=Ie(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=Ie(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),R=Math.min(0,s.top-f.top);u=g||h,p=y||R}this.scroll({dx:-u*l,dy:-p*l})},je.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)}),Fc(i.a,1e3)};function by(e,t){const n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}je.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},je.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=W(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),by(this._viewport,u),u},je.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},je.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}},je.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var Qo="data-element-id";function si(e){this._elements={},this._eventBus=e}si.$inject=["eventBus"],si.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),Se(t,Qo,i),n&&Se(n,Qo,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},si.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(Se(i.gfx,Qo,""),i.secondaryGfx&&Se(i.secondaryGfx,Qo,""),delete t[n])},si.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)},si.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,Qo,i),t},si.prototype.get=function(e){var t;typeof e=="string"?t=e:t=e&&Se(e,Qo);var n=this._elements[t];return n&&n.element},si.prototype.filter=function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(n)}),t},si.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}},si.prototype.getAll=function(){return this.filter(function(e){return e})},si.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)})},si.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},si.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 NA(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 $A(e){return e.__refs_collection===!0}function FA(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)}function xy(e,t,n){var i=NA(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 jA(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 di(e,t){if(!(this instanceof di))return new di(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}di.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?xy(this,t,e):jA(this,t,e)},di.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return $A(n)||xy(this,t,e),n},di.prototype.ensureBound=function(e,t){FA(e,t)||this.bind(e,t)},di.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},di.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var rf=new di({name:"children",enumerable:!0,collection:!0},{name:"parent"}),_y=new di({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),wy=new di({name:"attachers",collection:!0},{name:"host"}),Ey=new di({name:"outgoing",collection:!0},{name:"source"}),Sy=new di({name:"incoming",collection:!0},{name:"target"});function Jo(){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)}}),rf.bind(this,"parent"),_y.bind(this,"labels"),Ey.bind(this,"outgoing"),Sy.bind(this,"incoming")}function Xa(){Jo.call(this),rf.bind(this,"children"),wy.bind(this,"host"),wy.bind(this,"attachers")}Ee(Xa,Jo);function Ry(){Jo.call(this),rf.bind(this,"children")}Ee(Ry,Xa);function Cy(){Xa.call(this),_y.bind(this,"labelTarget")}Ee(Cy,Xa);function Ay(){Jo.call(this),Ey.bind(this,"source"),Sy.bind(this,"target")}Ee(Ay,Jo);var HA={connection:Ay,shape:Xa,label:Cy,root:Ry};function zA(e,t){var n=HA[e];if(!n)throw new Error("unknown type: <"+e+">");return W(new n,t)}function GA(e){return e instanceof Jo}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=W({},t||{}),t.id||(t.id=e+"_"+this._uid++),zA(e,t)};var jc="__fn",My=1e3,VA=Array.prototype.slice;function Yn(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}Yn.prototype.on=function(e,t,n,i){if(e=$e(e)?e:[e],mn(t)&&(i=n,n=t,t=My),!ze(t))throw new Error("priority must be a number");var r=n;i&&(r=jn(n,i),r[jc]=n[jc]||n);var o=this;e.forEach(function(a){o._addListener(a,{priority:t,callback:r,next:null})})},Yn.prototype.once=function(e,t,n,i){var r=this;if(mn(t)&&(i=n,n=t,t=My),!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[jc]=n,this.on(e,t,o)},Yn.prototype.off=function(e,t){e=$e(e)?e:[e];var n=this;e.forEach(function(i){n._removeListener(i,t)})},Yn.prototype.createEvent=function(e){var t=new Za;return t.init(e),t},Yn.prototype.fire=function(e,t){var n,i,r,o;if(o=VA.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 Za?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}},Yn.prototype.handleError=function(e){return this.fire("error",{error:e})===!1},Yn.prototype._destroy=function(){this._listeners={}},Yn.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},Yn.prototype._invokeListener=function(e,t,n){var i;if(n.callback.__isTomb)return i;try{i=WA(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},Yn.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},Yn.prototype._getListeners=function(e){return this._listeners[e]},Yn.prototype._setListeners=function(e,t){this._listeners[e]=t},Yn.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[jc]===t)&&(r?r.next=i:this._setListeners(e,i)),r=n,n=i};function Za(){}Za.prototype.stopPropagation=function(){this.cancelBubble=!0},Za.prototype.preventDefault=function(){this.defaultPrevented=!0},Za.prototype.init=function(e){W(this,e||{})};function WA(e,t){return e.apply(null,t)}function fo(e){return e.childNodes[0]}function UA(e){return e.parentNode.childNodes[1]}function Hc(e,t,n,i,r){var o=Ga();o.setTranslate(t,n);var a=Ga();a.setRotate(i||0,0,0);var s=Ga();s.setScale(1,1),Va(e,[o,a,s])}function An(e,t,n){var i=Ga();i.setTranslate(t,n),Va(e,i)}function Py(e,t){var n=Ga();n.setRotate(t,0,0),Va(e,n)}function ci(e,t){this._eventBus=e,this._elementRegistry=t}ci.$inject=["eventBus","elementRegistry"],ci.prototype._getChildrenContainer=function(e){var t=this._elementRegistry.getGraphics(e),n;return e.parent?(n=UA(t),n||(n=Oe("g"),ct(n).add("djs-children"),Ue(t.parentNode,n))):n=t,n},ci.prototype._clear=function(e){var t=fo(e);return Pc(t),t},ci.prototype._createContainer=function(e,t,n,i){var r=Oe("g");ct(r).add("djs-group"),typeof n<"u"?qA(r,t,t.childNodes[n]):Ue(t,r);var o=Oe("g");ct(o).add("djs-element"),ct(o).add("djs-"+e),i&&ct(o).add("djs-frame"),Ue(r,o);var a=Oe("g");return ct(a).add("djs-visual"),Ue(o,a),o},ci.prototype.create=function(e,t,n){var i=this._getChildrenContainer(t.parent);return this._createContainer(e,i,n,ty(t))},ci.prototype.updateContainments=function(e){var t=this,n=this._elementRegistry,i;i=Un(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)})}})},ci.prototype.drawShape=function(e,t,n={}){var i=this._eventBus;return i.fire("render.shape",{gfx:e,element:t,attrs:n})},ci.prototype.getShapePath=function(e){var t=this._eventBus;return t.fire("render.getShapePath",e)},ci.prototype.drawConnection=function(e,t,n={}){var i=this._eventBus;return i.fire("render.connection",{gfx:e,element:t,attrs:n})},ci.prototype.getConnectionPath=function(e){var t=this._eventBus;return t.fire("render.getConnectionPath",e)},ci.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if(e==="shape")this.drawShape(i,t),An(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")}},ci.prototype.remove=function(e){var t=this._elementRegistry.getGraphics(e);ln(t.parentNode)};function qA(e,t,n){var i=n||t.firstChild;e!==i&&t.insertBefore(e,i)}const YA={__depends__:[sA],__init__:["canvas"],canvas:["type",je],elementRegistry:["type",si],elementFactory:["type",or],eventBus:["type",Yn],graphicsFactory:["type",ci]};function KA(e){var t=new Jg(e);return t.init(),t}function XA(e){e=e||{};var t={config:["value",e]},n=[t,YA].concat(e.modules||[]);return KA(n)}function Tr(e,t){this._injector=t||XA(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 Ln(e){return e?"<"+e.$type+(e.id?' id="'+e.id:"")+'" />':"<null>"}function Hn(e,t){return e.$instanceOf(t)}function ZA(e){return Pt(e.rootElements,function(t){return Hn(t,"bpmn:Process")||Hn(t,"bpmn:Collaboration")})}function QA(e){var t={},n=[],i={};function r(U,K){return function(re){U(re,K)}}function o(U){t[U.id]=U}function a(U){return t[U.id]}function s(U,K){var re=U.gfx;if(re)throw new Error(`already rendered ${Ln(U)}`);return e.element(U,i[U.id],K)}function c(U,K){return e.root(U,i[U.id],K)}function l(U,K){try{var re=i[U.id]&&s(U,K);return o(U),re}catch(fe){u(fe.message,{element:U,error:fe}),console.error(`failed to import ${Ln(U)}`,fe)}}function u(U,K){e.error(U,K)}var p=this.registerDi=function(K){var re=K.bpmnElement;re?i[re.id]?u(`multiple DI elements defined for ${Ln(re)}`,{element:re}):i[re.id]=K:u(`no bpmnElement referenced in ${Ln(K)}`,{element:K})};function f(U){d(U.plane)}function d(U){p(U),z(U.planeElement,g)}function g(U){p(U)}this.handleDefinitions=function(K,re){var fe=K.diagrams;if(re&&fe.indexOf(re)===-1)throw new Error("diagram not part of <bpmn:Definitions />");if(!re&&fe&&fe.length&&(re=fe[0]),!re)throw new Error("no diagram to display");i={},f(re);var Te=re.plane;if(!Te)throw new Error(`no plane for ${Ln(re)}`);var $=Te.bpmnElement;if(!$)if($=ZA(K),$)u(`correcting missing bpmnElement on ${Ln(Te)} to ${Ln($)}`),Te.bpmnElement=$,p(Te);else throw new Error("no process or collaboration to display");var S=c($,Te);if(Hn($,"bpmn:Process")||Hn($,"bpmn:SubProcess"))y($,S);else if(Hn($,"bpmn:Collaboration"))X($,S),R(K.rootElements,S);else throw new Error(`unsupported bpmnElement for ${Ln(Te)}: ${Ln($)}`);h(n)};var h=this.handleDeferred=function(){for(var K;n.length;)K=n.shift(),K()};function y(U,K){Ke(U,K),B(U.ioSpecification,K),k(U.artifacts,K),o(U)}function R(U,K){var re=nt(U,function(fe){return!a(fe)&&Hn(fe,"bpmn:Process")&&fe.laneSets});re.forEach(r(y,K))}function x(U,K){l(U,K)}function m(U,K){z(U,r(x,K))}function v(U,K){l(U,K)}function _(U,K){l(U,K)}function E(U,K){l(U,K)}function T(U,K){l(U,K)}function k(U,K){z(U,function(re){Hn(re,"bpmn:Association")?n.push(function(){T(re,K)}):T(re,K)})}function B(U,K){U&&(z(U.dataInputs,r(_,K)),z(U.dataOutputs,r(E,K)))}var P=this.handleSubProcess=function(K,re){Ke(K,re),k(K.artifacts,re)};function O(U,K){var re=l(U,K);Hn(U,"bpmn:SubProcess")&&P(U,re||K),Hn(U,"bpmn:Activity")&&B(U.ioSpecification,K),n.push(function(){z(U.dataInputAssociations,r(v,K)),z(U.dataOutputAssociations,r(v,K))})}function j(U,K){l(U,K)}function Q(U,K){l(U,K)}function me(U,K){n.push(function(){var re=l(U,K);U.childLaneSet&&Pe(U.childLaneSet,re||K),ne(U)})}function Pe(U,K){z(U.lanes,r(me,K))}function De(U,K){z(U,r(Pe,K))}function Ke(U,K){rt(U.flowElements,K),U.laneSets&&De(U.laneSets,K)}function rt(U,K){z(U,function(re){Hn(re,"bpmn:SequenceFlow")?n.push(function(){j(re,K)}):Hn(re,"bpmn:BoundaryEvent")?n.unshift(function(){O(re,K)}):Hn(re,"bpmn:FlowNode")?O(re,K):Hn(re,"bpmn:DataObject")||(Hn(re,"bpmn:DataStoreReference")||Hn(re,"bpmn:DataObjectReference")?Q(re,K):u(`unrecognized flowElement ${Ln(re)} in context ${Ln(K&&K.businessObject)}`,{element:re,context:K}))})}function Ae(U,K){var re=l(U,K),fe=U.processRef;fe&&y(fe,re||K)}function X(U,K){z(U.participants,r(Ae,K)),n.push(function(){m(U.messageFlows,K)}),k(U.artifacts,K)}function ne(U){z(U.flowNodeRef,function(K){var re=K.get("lanes");re&&re.push(U)})}}function JA(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,R){return i.add(h,y,R)},error:function(h,y){s.push({message:h,context:y})}},f=new QA(p);u=u||l.diagrams&&l.diagrams[0];var d=eM(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 eM(e,t){if(!(!t||!t.plane)){var n=t.plane.bpmnElement,i=n;!A(n,"bpmn:Process")&&!A(n,"bpmn:Collaboration")&&(i=tM(n));var r;A(i,"bpmn:Collaboration")?r=i:r=Pt(e.rootElements,function(l){if(A(l,"bpmn:Collaboration"))return Pt(l.participants,function(u){return u.processRef===i})});var o=[i];r&&(o=Tn(r.participants,function(l){return l.processRef}),o.push(r));var a=Ty(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 Ty(e){var t=[];return z(e,function(n){n&&(t.push(n),t=t.concat(Ty(n.flowElements)))}),t}function tM(e){for(var t=e;t;){if(A(t,"bpmn:Process"))return t;t=t.$parent}}var nM='<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>',ky=nM,Oy={verticalAlign:"middle"},Dy={color:"#404040"},iM={zIndex:"1001",position:"fixed",top:"0",left:"0",right:"0",bottom:"0"},rM={width:"100%",height:"100%",background:"rgba(40,40,40,0.2)"},oM={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"},aM='<div class="bjs-powered-by-lightbox"><div class="backdrop"></div><div class="notice"><a href="https://bpmn.io" target="_blank" rel="noopener" class="link">'+ky+'</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 sM(){Wi=Ot(aM),Nn(Wi,iM),Nn(Et("svg",Wi),Oy),Nn(Et(".backdrop",Wi),rM),Nn(Et(".notice",Wi),oM),Nn(Et(".link",Wi),Dy,{margin:"15px 20px 15px 10px",alignSelf:"center"})}function cM(){Wi||(sM(),qn.bind(Wi,".backdrop","click",function(e){document.body.removeChild(Wi)})),document.body.appendChild(Wi)}const zc=5,Ly="djs-outline-hidden";function Ht(e){e=W({},uM,e),this._moddle=this._createModdle(e),this._container=this._createContainer(e),this._init(this._container,this._moddle,e),fM(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||[]),Gc(s,o),s=lM(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 Gc(o,[]),o}if(typeof t=="string"&&(i=pM(n,t),!i)){const o=new Error("BPMNDiagram <"+t+"> not found");throw Gc(o,[]),o}try{this.clear()}catch(o){throw Gc(o,[]),o}const{warnings:r}=await JA(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=Et(":scope > defs",i._svg),a=Qg(r),s=o?"<defs>"+Qg(o)+"</defs>":"",c=i.getContainer();Nt(c).add(Ly);let l;try{l=r.getBBox()}finally{Nt(c).remove(Ly)}const u=l.x-zc,p=l.y-zc,f=l.width+zc*2,d=l.height+zc*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">
|