@g1cloud/bpmn-modeler-next 5.0.0-alpha.48 → 5.0.0-alpha.49

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.
@@ -5837,7 +5837,7 @@ function er(e) {
5837
5837
  case "annotation-over-label":
5838
5838
  return `a|${e.annotation}|${e.label}`;
5839
5839
  case "group-overlap-unintended":
5840
- return `g|${e.groups[0]}|${e.groups[1]}`;
5840
+ return `g|${e.groups[0]}|${e.groups[1]}${e.container ? `|⊃${e.container}` : ""}`;
5841
5841
  case "group-overlap-unreadable":
5842
5842
  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(",")}`;
5843
5843
  case "group-stack-unreadable":
@@ -3,7 +3,7 @@
3
3
  column: `+k+`
4
4
  nested error: `+P.message;if(D)return a.addWarning({message:$,error:P}),!0;throw Qi($)}function l(P,C){return u(P,C,!0)}function p(){var P=a.elementsById,C=a.references,D,A;for(D=0;A=C[D];D++){var B=A.element,k=P[A.id],O=Si(B).propertiesByName[A.property];if(k||a.addWarning({message:"unresolved reference <"+A.id+">",element:A.element,property:A.property,value:A.id}),O.isMany){var $=B.get(O.name),re=$.indexOf(A);re===-1&&(re=$.length),k?$[re]=k:$.splice(re,1)}else B.set(O.name,k)}}function f(){c.pop().handleEnd()}var d=/^<\?xml /i,g=/ encoding="([^"]+)"/i,h=/^utf-8$/i;function m(P){if(d.test(P)){var C=g.exec(P),D=C&&C[1];!D||h.test(D)||a.addWarning({message:"unsupported document encoding <"+D+">, falling back to UTF-8"})}}function S(P,C){var D=c.peek();try{c.push(D.handleNode(P))}catch(A){u(A,C,o)&&c.push(new Nu)}}function y(P,C){try{c.peek().handleText(P)}catch(D){l(D,C)}}function _(P,C){P.trim()&&y(P,C)}var E=r.getPackages().reduce(function(P,C){return P[C.uri]=C.prefix,P},Object.entries(Bu).reduce(function(P,[C,D]){return P[D]=C,P},r.config&&r.config.nsMap||{}));return s.ns(E).on("openTag",function(P,C,D,A){var B=P.attrs||{},k=Object.keys(B).reduce(function($,re){var ye=C(B[re]);return $[re]=ye,$},{}),O={name:P.name,originalName:P.originalName,attributes:k,ns:P.ns};S(O,A)}).on("question",m).on("closeTag",f).on("cdata",y).on("text",function(P,C,D){_(C(P),D)}).on("error",u).on("warn",l),new Promise(function(P,C){var D;try{s.parse(e),p()}catch($){D=$}var A=i.element;!D&&!A&&(D=Qi("failed to parse document as <"+i.type.$descriptor.name+">"));var B=a.warnings,k=a.references,O=a.elementsById;return D?(D.warnings=B,C(D)):P({rootElement:A,elementsById:O,references:k,warnings:B})})},Fu.prototype.handler=function(e){return new ju(this.model,e)};function q0(){var e=[];return Object.defineProperty(e,"peek",{value:function(){return this[this.length-1]}}),e}var Y0=`<?xml version="1.0" encoding="UTF-8"?>
5
5
  `,K0=/<|>|'|"|&|\n\r|\n/g,yd=/<|>|&/g;function si(e){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=e,this.defaultPrefixMap=e&&e.defaultPrefixMap||{}}si.prototype.mapDefaultPrefixes=function(e){this.defaultPrefixMap=e},si.prototype.defaultUriByPrefix=function(e){return this.defaultPrefixMap[e]},si.prototype.byUri=function(e){return this.uriMap[e]||this.parent&&this.parent.byUri(e)},si.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)},si.prototype.uriByPrefix=function(e){return this.prefixMap[e||"xmlns"]||this.parent&&this.parent.uriByPrefix(e)},si.prototype.mapPrefix=function(e,t){this.prefixMap[e||"xmlns"]=t},si.prototype.getNSKey=function(e){return e.prefix!==void 0?e.uri+"|"+e.prefix:e.uri},si.prototype.logUsed=function(e){var t=e.uri,n=this.getNSKey(e);this.used[n]=this.byUri(t),this.parent&&this.parent.logUsed(e)},si.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 X0(e){return e.charAt(0).toLowerCase()+e.slice(1)}function Z0(e,t){return dd(t)?X0(e):e}function vd(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function bd(e){return En(e)?e:(e.prefix?e.prefix+":":"")+e.localName}function Q0(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 J0(e,t){return t.isGeneric?j({localName:t.ns.localName},e):j({localName:Z0(t.ns.localName,t.$pkg)},e)}function ew(e,t){return j({localName:t.ns.localName},e)}function tw(e){var t=e.$descriptor;return ze(t.properties,function(n){var i=n.name;if(n.isVirtual||!Sn(e,i))return!1;var r=e[i];return r===n.default||r===null?!1:n.isMany?r.length:!0})}var nw={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},iw={"<":"lt",">":"gt","&":"amp"};function _d(e,t,n){return e=En(e)?e:""+e,e.replace(t,function(i){return"&"+n[i]+";"})}function rw(e){return _d(e,K0,nw)}function ow(e){return _d(e,yd,iw)}function aw(e){return ze(e,function(t){return t.isAttr})}function sw(e){return ze(e,function(t){return!t.isAttr})}function Hu(e){this.tagName=e}Hu.prototype.build=function(e){return this.element=e,this},Hu.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"+this.element.id+"</"+this.tagName+">").appendNewLine()};function Or(){}Or.prototype.serializeValue=Or.prototype.serializeTo=function(e){e.append(this.escape?ow(this.value):this.value)},Or.prototype.build=function(e,t){return this.value=t,e.type==="String"&&t.search(yd)!==-1&&(this.escape=!0),this};function zu(e){this.tagName=e}vd(zu,Or),zu.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"),this.serializeValue(e),e.append("</"+this.tagName+">").appendNewLine()};function mt(e,t){this.body=[],this.attrs=[],this.parent=e,this.propertyDescriptor=t}mt.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=tw(e),this.parseAttributes(aw(r)),this.parseContainments(sw(r))),this.parseGenericAttributes(e,i),this},mt.prototype.nsTagName=function(e){var t=this.logNamespaceUsed(e.ns);return J0(t,e)},mt.prototype.nsPropertyTagName=function(e){var t=this.logNamespaceUsed(e.ns);return ew(t,e)},mt.prototype.isLocalNs=function(e){return e.uri===this.ns.uri},mt.prototype.nsAttributeName=function(e){var t;if(En(e)?t=un(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}:j({localName:t.localName},n)},mt.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}))},mt.prototype.parseGenericContainments=function(e){var t=e.$body;t&&this.body.push(new Or().build({type:"String"},t));var n=e.$children;n&&L(n,i=>{this.body.push(new mt(this).build(i))})},mt.prototype.parseNsAttribute=function(e,t,n){var i=e.$model,r=un(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)}},mt.prototype.parseNsAttributes=function(e){var t=this,n=e.$attrs,i=[];return L(n,function(r,o){var a=t.parseNsAttribute(e,o,r);a&&i.push(a)}),i},mt.prototype.parseGenericAttributes=function(e,t){var n=this;L(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)}})},mt.prototype.parseContainments=function(e){var t=this,n=this.body,i=this.element;L(e,function(r){var o=i.get(r.name),a=r.isReference,s=r.isMany;if(s||(o=[o]),r.isBody)n.push(new Or().build(r,o[0]));else if(ad(r.type))L(o,function(u){n.push(new zu(t.addTagName(t.nsPropertyTagName(r))).build(r,u))});else if(a)L(o,function(u){n.push(new Hu(t.addTagName(t.nsPropertyTagName(r))).build(u))});else{var c=md(r);L(o,function(u){var l;c?c===hd?l=new mt(t,r):l=new ns(t,r,c):l=new mt(t),n.push(l.build(u))})}})},mt.prototype.getNamespaces=function(e){var t=this.namespaces,n=this.parent,i;return t||(i=n&&n.getNamespaces(),e||!i?this.namespaces=t=new si(i):t=i),t},mt.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},mt.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},mt.prototype.parseAttributes=function(e){var t=this,n=this.element;L(e,function(i){var r=n.get(i.name);if(i.isReference)if(!i.isMany)r=r.id;else{var o=[];L(r,function(a){o.push(a.id)}),r=o.join(" ")}t.addAttribute(t.nsAttributeName(i),r)})},mt.prototype.addTagName=function(e){var t=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(t),bd(e)},mt.prototype.addAttribute=function(e,t){var n=this.attrs;En(t)&&(t=rw(t));var i=nd(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)},mt.prototype.serializeAttributes=function(e){var t=this.attrs,n=this.namespaces;n&&(t=Q0(n).concat(t)),L(t,function(i){e.append(" ").append(bd(i.name)).append('="').append(i.value).append('"')})},mt.prototype.serializeTo=function(e){var t=this.body[0],n=t&&t.constructor!==Or;e.appendIndent().append("<"+this.tagName),this.serializeAttributes(e),e.append(t?">":" />"),t&&(n&&e.appendNewLine().indent(),L(this.body,function(i){i.serializeTo(e)}),n&&e.unindent().appendIndent(),e.append("</"+this.tagName+">")),e.appendNewLine()};function ns(e,t,n){mt.call(this,e,t),this.serialization=n}vd(ns,mt),ns.prototype.parseNsAttributes=function(e){var t=mt.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},ns.prototype.isLocalNs=function(e){return e.uri===(this.typeNs||this.ns).uri};function cw(){this.value="",this.write=function(e){this.value+=e}}function uw(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 lw(e){e=j({format:!1,preamble:!0},e||{});function t(n,i){var r=i||new cw,o=new uw(r,e.format);e.preamble&&o.append(Y0);var a=new mt,s=n.$model;if(a.getNamespaces().mapDefaultPrefixes(pw(s)),a.build(n).serializeTo(o),!i)return r.value}return{toXML:t}}function pw(e){const t=e.config&&e.config.nsMap||{},n={};for(const i in Bu)n[i]=Bu[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 is(e,t){jn.call(this,e,t)}is.prototype=Object.create(jn.prototype),is.prototype.fromXML=function(e,t,n){En(t)||(n=t,t="bpmn:Definitions");var i=new Fu(j({model:this,lax:!0},n)),r=i.handler(t);return i.fromXML(e,r)},is.prototype.toXML=function(e,t){var n=new lw(t);return new Promise(function(i,r){try{var o=n.toXML(e);return i({xml:o})}catch(a){return r(a)}})};var fw="BPMN20",dw="http://www.omg.org/spec/BPMN/20100524/MODEL",hw="bpmn",mw=[],gw=[{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"}]}],yw=[{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"}]}],vw={tagAlias:"lowerCase",typePrefix:"t"},bw={name:fw,uri:dw,prefix:hw,associations:mw,types:gw,enumerations:yw,xml:vw},_w="BPMNDI",xw="http://www.omg.org/spec/BPMN/20100524/DI",ww="bpmndi",Ew=[{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"]}],Sw=[{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"}]}],Rw=[],Cw={name:_w,uri:xw,prefix:ww,types:Ew,enumerations:Sw,associations:Rw},Pw="DC",Aw="http://www.omg.org/spec/DD/20100524/DC",Tw="dc",Mw=[{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}]}],kw=[],Ow={name:Pw,uri:Aw,prefix:Tw,types:Mw,associations:kw},Dw="DI",Lw="http://www.omg.org/spec/DD/20100524/DI",Iw="di",Bw=[{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"}]}],Nw=[],$w={tagAlias:"lowerCase"},jw={name:Dw,uri:Lw,prefix:Iw,types:Bw,associations:Nw,xml:$w},Fw="bpmn.io colors for BPMN",Hw="http://bpmn.io/schema/bpmn/biocolor/1.0",zw="bioc",Gw=[{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"}]}],Vw=[],Ww=[],Uw={name:Fw,uri:Hw,prefix:zw,types:Gw,enumerations:Vw,associations:Ww},qw="BPMN in Color",Yw="http://www.omg.org/spec/BPMN/non-normative/color/1.0",Kw="color",Xw=[{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"}]}],Zw=[],Qw=[],Jw={name:qw,uri:Yw,prefix:Kw,types:Xw,enumerations:Zw,associations:Qw};const eE={bpmn:bw,bpmndi:Cw,dc:Ow,di:jw,bioc:Uw,color:Jw};function xd(e,t){const n=j({},eE,e);return new is(n,t)}const tE={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"}},nE="http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0",wd="i18n",rs={[wd]:tE,[Ru]:Zf};function Ed(){return xd(rs)}const Sd=Ed();async function Gu(e){const{rootElement:t,warnings:n}=await Sd.fromXML(e,"bpmn:Definitions");return{definitions:t,warnings:n}}async function iE(e){const{xml:t}=await Sd.toXML(e,{format:!0});return t}function Vu(e){return e.map(t=>typeof t=="string"?t:t.message??String(t))}const ao={cjkEm:.865,upperEm:.68,lowerEm:.5,digitEm:.556,spaceEm:.278,otherEm:.35,ascentEm:.9,descentEm:.25},rE=/[ᄀ-ᇿ -〿぀-ヿ㐀-鿿가-힯＀-⦆]/;function oE(e){const t=ao;return rE.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 so(e,t){let n=0;for(const i of e)n+=t*oE(i);return n}function Rd(e=globalThis,{textMeasurement:t="approximate"}={}){if(!(e!=null&&e.SVGElement))throw new Error("installHeadlessBpmnDom: DOM 전역이 없다 — jsdom window 를 전역에 올린 뒤 호출할 것");t==="approximate"&&aE(e),sE(e),cE(e),uE(e)}function aE(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:so(r,o),fontBoundingBoxAscent:o*ao.ascentEm,fontBoundingBoxDescent:o*ao.descentEm,actualBoundingBoxAscent:o*ao.ascentEm,actualBoundingBoxDescent:o*ao.descentEm}}};t.getContext=()=>n}function sE(e){if(e.SVGMatrix)return;class t{constructor(){Jr(this,"a",1);Jr(this,"b",0);Jr(this,"c",0);Jr(this,"d",1);Jr(this,"e",0);Jr(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 cE(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,u=0){const l=s*Math.PI/180,p=Math.cos(l),f=Math.sin(l);a.a=p,a.b=f,a.c=-f,a.d=p,a.e=c-p*c+f*u,a.f=u-f*c-p*u},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 uE(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:so(n,12),height:14}})}const os=new Set(["bpmn:Participant","bpmn:Lane","bpmn:Group","bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),lE=1,Wu=new Set(["bpmn:TextAnnotation","bpmn:DataStoreReference","bpmn:DataObjectReference","bpmn:DataInput","bpmn:DataOutput"]),pE=2;function Ri(e){switch(e.kind){case"label-over-line":return`L|${e.edge}|${e.line}`;case"edge-crosses-shape":return`x|${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"label-on-shared-segment":return`l|${e.edge}|${e.other}`;case"annotation-over-label":return`a|${e.annotation}|${e.label}`;case"group-overlap-unintended":return`g|${e.groups[0]}|${e.groups[1]}`;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"pool-name-over-label":return`pn|${e.pool}|${e.label}`}}const Cd=20,as=5,Pd=3,fE=8,Ad=12,dE=Ad*1.2;function Uu(e,t){const n=t.split(/\r?\n/),i=Math.max(...n.map(o=>so(o,Ad))),r=n.length*dE;return{x:e.x+e.width/2-i/2,y:e.y+e.height/2-r/2,width:i,height:r}}const Td=1;function mn(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 ss(e,t){let n=null;const i=e.type!==t.type;for(const r of mn(e))for(const o of mn(t)){if(r.axis!==o.axis||Math.abs(r.at-o.at)>Td)continue;const a=r.dir!==o.dir?"opposite":i?"mixed":null;if(!a)continue;const s=Math.min(r.hi,o.hi)-Math.max(r.lo,o.lo);s>=Cd&&(!n||s>n.length)&&(n={axis:r.axis,length:s,kind:a})}return n}function Md(e,t){const n=ss(e,t);return n&&n.kind==="opposite"?{axis:n.axis,length:n.length}:null}function hE(e,t){let n=0;for(const i of t)i.id!==e.id&&Md(e,i)&&n++;return n}function Ci(e,t){let n=0;for(const i of t)i.id!==e.id&&ss(e,i)&&n++;return n}const kd=15,Od=20;function mE(e,t){const n=t.axis==="v"?[e.x,e.x+e.width]:[e.y,e.y+e.height];if(t.at<n[0]-Od||t.at>n[1]+Od)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 qu=20;function cs(e,t){const n=[];for(const i of t){if(i.axis!==e.axis||Math.abs(i.at-e.at)>Td)continue;const r=Math.max(e.lo,i.lo),o=Math.min(e.hi,i.hi);o-r<Cd||n.push([r-qu,o+qu])}return n}function us(e,t){const n=e.label;if(!n)return null;let i=null;for(const r of mn(e)){const o=mE(n,r);if(o){for(const a of t)if(a.id!==e.id&&!(i&&a.id>=i.other)){for(const[s,c]of cs(r,mn(a)))if(Math.min(c,o[1])>Math.max(s,o[0])){i={other:a.id,axis:r.axis};break}}}}return i}const gE=1,yE=(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 vE(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,u=t.y-e.y;let l=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>l&&(l=h)}else{if(h<l)return!1;h<p&&(p=h)}return!0};return f(r-e.x,c)&&f(e.x-a,-c)&&f(o-e.y,u)&&f(e.y-s,-u)&&p>l}function Yu(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 bE=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,co=1;function Pi(e,t){const n=e.x+co,i=e.x+e.width-co,r=e.y+co,o=e.y+e.height-co;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 Dd(e,t){const n=e.label;if(!n)return null;if(mn(e).some(i=>Pi(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(mn(i).some(r=>Pi(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=>Pi(n,r)))return i.id;return null}function Fn(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(vE(e.waypoints[o],e.waypoints[o+1],r,pE)){i.push(r);break}}return i}function _E(e,t,n,i){const r=(u,l,p)=>(l.x-u.x)*(p.y-u.y)-(l.y-u.y)*(p.x-u.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 Ld=(e,t)=>e.endpoints.some(n=>t.endpoints.includes(n));function ls(e,t){let n=0;for(const i of t){if(i.id===e.id||Ld(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++)_E(e.waypoints[o],e.waypoints[o+1],i.waypoints[a],i.waypoints[a+1])&&(r=!0);r&&n++}return n}function Ai(e,t){let n=0;for(const i of t)i.id===e.id||Ld(e,i)||ls(e,[i])>0&&(n+=i.type===e.type?2:1);return n}function Id(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++)ls(n[i],[n[r]])>0&&(t+=n[i].type===n[r].type?2:1);return t}function Ku(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)if(ls(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 Bd(e){const t=Ku(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),u=i.get(s);if(!c||!u)continue;const l=n(c.type),p=n(u.type);l==="solid"&&p==="solid"?r++:l==="dashed"&&p==="dashed"&&o++}return{pairs:t,solidPairs:r,dashedPairs:o,mixedPairs:t.length-r-o,crossPoolMessages:xE(e)}}function xE(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(u=>u.id!==o.id&&u.id!==a.id&&u.y>s&&u.y+u.height<c)&&i++}return i}function Nd(e,t,n){const i=new Set(t.flatMap(r=>[...r.members]));return e.shapes.filter(r=>!r.container&&!Wu.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 $d(e){var n;const t=(n=ht(e==null?void 0:e.extensionElements))==null?void 0:n.values;if(Array.isArray(t))for(const i of t){const r=ht(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 jd=e=>e?{members:e}:{},ci=e=>e.shapes.filter(t=>!t.container);function wE(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){if(o.container)return o.id;if(o.parent)return o.parent}}}function Fd(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(mn(i).some(r=>Pi(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=>Pi(n,r)))return i.id;return null}function uo(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}function Ti(e){const t=[],n=e.shapes.filter(h=>!h.container);for(const h of e.edges)for(const m of Fn(h,n))t.push({kind:"edge-crosses-shape",edge:h.id,shape:m.id});const i=n.filter(h=>!h.attached);for(let h=0;h<i.length;h++)for(let m=h+1;m<i.length;m++){const S=i[h],y=i[m];if(!Yu(S,y,lE))continue;const _=S.id<y.id?[S.id,y.id]:[y.id,S.id];t.push({kind:"shape-overlap",shapes:_,identical:bE(S,y)})}const r=e.shapes.filter(h=>h.type==="bpmn:Group"&&Array.isArray(h.members)&&h.members.length>0);for(let h=0;h<r.length;h++)for(let m=h+1;m<r.length;m++){const S=r[h],y=r[m],_=Math.min(S.x+S.width,y.x+y.width)-Math.max(S.x,y.x),E=Math.min(S.y+S.height,y.y+y.height)-Math.max(S.y,y.y);if(_<=as||E<=as)continue;const P=S.id<y.id?[S.id,y.id]:[y.id,S.id],C=new Set(y.members);if(S.members.some(A=>C.has(A))){const A=Nd(e,r,{x:Math.max(S.x,y.x),y:Math.max(S.y,y.y),right:Math.min(S.x+S.width,y.x+y.width),bottom:Math.min(S.y+S.height,y.y+y.height)});A.length&&t.push({kind:"group-overlap-unreadable",reason:"orphan",groups:P,shapes:A});continue}const D=S.x<=y.x&&S.y<=y.y&&S.x+S.width>=y.x+y.width&&S.y+S.height>=y.y+y.height?S.id:y.x<=S.x&&y.y<=S.y&&y.x+y.width>=S.x+S.width&&y.y+y.height>=S.y+S.height?y.id:void 0;t.push({kind:"group-overlap-unintended",groups:P,...D?{container:D}:{}})}const o=new Set(r.flatMap(h=>[...h.members])),a=h=>e.shapes.filter(m=>!m.container&&!Wu.has(m.type)&&m.x>=h.x&&m.y>=h.y&&m.x+m.width<=h.x+h.width&&m.y+m.height<=h.y+h.height);for(const h of r){const m=a(h);if(!m.length)continue;const S=new Set(h.members),y=m.filter(_=>!S.has(_.id));y.some(_=>o.has(_.id))&&(y.length*2<m.length||t.push({kind:"group-overlap-unreadable",reason:"minority",group:h.id,shapes:y.map(_=>_.id).sort()}))}for(const h of r){const m=new Set(a(h).map(C=>C.id)),S=new Set(h.members),y=new Set([...m].filter(C=>!S.has(C)&&o.has(C)));if(!y.size)continue;let _=!1,E=!1,P=!1;for(const C of e.edges){if(C.type!=="bpmn:SequenceFlow"||!C.source||!C.target)continue;const D=y.has(C.source),A=y.has(C.target);!D&&A&&!m.has(C.source)?_=!0:D&&!A&&!m.has(C.target)?E=!0:D&&A&&(P=!0)}_&&E&&P&&t.push({kind:"group-overlap-unreadable",reason:"throughpass",group:h.id,shapes:[...y].sort()})}const s=e.shapes.filter(h=>h.type==="bpmn:Group");for(let h=0;h<s.length;h++)for(let m=h+1;m<s.length;m++)for(let S=m+1;S<s.length;S++){const y=[s[h],s[m],s[S]],_={x:Math.max(...y.map(C=>C.x)),y:Math.max(...y.map(C=>C.y)),right:Math.min(...y.map(C=>C.x+C.width)),bottom:Math.min(...y.map(C=>C.y+C.height))};if(_.right-_.x<=as||_.bottom-_.y<=as)continue;const E=Nd(e,[],_);if(!E.length)continue;const P=y.map(C=>C.id).sort();t.push({kind:"group-stack-unreadable",groups:P,shapes:E})}for(const h of e.shapes.filter(m=>m.type==="bpmn:Group"))for(const m of e.shapes){if(m.container||m.attached||Wu.has(m.type)||m.width<=0||m.height<=0)continue;const S=[["top",h.y,"h",h.x,h.x+h.width],["bottom",h.y+h.height,"h",h.x,h.x+h.width],["left",h.x,"v",h.y,h.y+h.height],["right",h.x+h.width,"v",h.y,h.y+h.height]];for(const[y,_,E,P,C]of S){const D=E==="h"?m.x:m.y,A=E==="h"?m.x+m.width:m.y+m.height;if(!(D<C&&P<A))continue;const B=E==="h"?m.y:m.x,k=E==="h"?m.y+m.height:m.x+m.width;if(!(B<_&&_<k))continue;const O=Math.min(_-B,k-_);O<fE||t.push({kind:"group-cuts-shape",group:h.id,shape:m.id,side:y,depth:O})}}const c=e.shapes.filter(h=>h.container&&h.type!=="bpmn:Group"&&h.type!=="bpmn:Lane");for(const h of e.shapes.filter(m=>m.type==="bpmn:Group"))for(const m of c){const S=h.x<m.x+m.width&&m.x<h.x+h.width,y=h.y<m.y+m.height&&m.y<h.y+h.height,_=[["top",h.y,m.y,S],["bottom",h.y+h.height,m.y+m.height,S],["left",h.x,m.x,y],["right",h.x+h.width,m.x+m.width,y]];for(const[E,P,C,D]of _)D&&Math.abs(P-C)<=Pd&&t.push({kind:"group-on-container-boundary",group:h.id,container:m.id,side:E})}const u=e.shapes.filter(h=>h.type==="bpmn:Group");for(let h=0;h<u.length;h++)for(let m=h+1;m<u.length;m++){const S=u[h],y=u[m],_=S.x<y.x+y.width&&y.x<S.x+S.width,E=S.y<y.y+y.height&&y.y<S.y+S.height,P=[["x",S.x+S.width,y.x,E],["x",y.x+y.width,S.x,E],["y",S.y+S.height,y.y,_],["y",y.y+y.height,S.y,_]];for(const[C,D,A,B]of P)if(B&&Math.abs(D-A)<=Pd){t.push({kind:"group-on-group-boundary",groups:S.id<y.id?[S.id,y.id]:[y.id,S.id],axis:C});break}}for(let h=0;h<e.edges.length;h++)for(let m=h+1;m<e.edges.length;m++){const S=e.edges[h],y=e.edges[m],_=ss(S,y);if(!_)continue;const E=S.id<y.id?[S.id,y.id]:[y.id,S.id];t.push({kind:_.kind==="opposite"?"edge-overlap-opposite":"edge-overlap-mixed",edges:E,axis:_.axis,length:Math.round(_.length)})}for(const h of e.edges){if(!h.label)continue;const m=us(h,e.edges);m&&t.push({kind:"label-on-shared-segment",edge:h.id,other:m.other,axis:m.axis})}for(const h of e.edges){if(!h.label)continue;const m=Dd(h,e);m&&t.push({kind:"label-over-line",edge:h.id,line:m})}const l=new Set(n.map(h=>h.id)),p=e.shapes.filter(h=>h.type==="bpmn:Participant"&&h.label);for(const h of[...n,...p.filter(m=>!l.has(m.id))]){if(!h.label)continue;const m=Fd(h,e);m&&t.push({kind:"label-over-line",edge:h.id,line:m})}const f=new Set(e.shapes.filter(h=>h.type==="bpmn:TextAnnotation").map(h=>h.id));for(const h of p)for(const{owner:m,rect:S}of uo(e))m===h.id||f.has(m)||Yu(h.label,S,co)&&t.push({kind:"pool-name-over-label",pool:h.id,label:m});const d=uo(e);for(const h of n)if(h.type==="bpmn:TextAnnotation")for(const{owner:m,rect:S}of d)m!==h.id&&Yu(h,S,co)&&t.push({kind:"annotation-over-label",annotation:h.id,label:m});const g=new Map(e.shapes.map(h=>[h.id,h]));for(const h of n){const m=h.parent??wE(h,e,g);if(!m)continue;const S=g.get(m);!S||!S.container||yE(S,h,gE)||t.push({kind:"shape-outside-container",shape:h.id,container:S.id})}return t.sort((h,m)=>Ri(h).localeCompare(Ri(m)))}const ht=e=>typeof e=="object"&&e!==null?e:void 0,xt=e=>typeof e=="number"?e:0,Mi=e=>{const t=ht(e);return typeof(t==null?void 0:t.id)=="string"?t.id:void 0};function EE(e){const t=ht(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=Mi(o);a&&n.push(a)}}return n}function SE(e){const t=ht(e);if(!t)return{};const n=Array.isArray(t.sourceRef)?void 0:Mi(t.sourceRef),i=Array.isArray(t.targetRef)?void 0:Mi(t.targetRef);return n&&i?{source:n,target:i}:{}}function RE(e,t){const n=ht(e.$parent);if(!n)return;const i=typeof n.$type=="string"?n.$type:"";if(i==="bpmn:Process"){const r=Mi(n);return r?t.get(r):void 0}if(os.has(i)&&i!=="bpmn:Lane"&&i!=="bpmn:Group")return Mi(n)}function Hd(e){var a,s,c,u,l;const t=[],n=[],i=((a=ht(e))==null?void 0:a.diagrams)??[],r=new Map,o=new Set;for(const p of((s=ht(e))==null?void 0:s.rootElements)??[]){const f=ht(p);if((f==null?void 0:f.$type)==="bpmn:Collaboration")for(const d of f.participants??[]){const g=ht(d),h=Mi(g),m=Mi(g==null?void 0:g.processRef);h&&m?r.set(m,h):h&&o.add(h)}}for(const p of i){const f=ht((c=ht(p))==null?void 0:c.plane),d=(f==null?void 0:f.planeElement)??[];for(const g of d){const h=ht(g);if(!h)continue;const m=ht(h.bpmnElement),S=typeof(m==null?void 0:m.id)=="string"?m.id:void 0;if(!S)continue;const y=typeof(m==null?void 0:m.$type)=="string"?m.$type:"",_=ht(h.bounds);if(_){const P=h.isExpanded===!1&&y!=="bpmn:Participant",C=ht((u=ht(h.label))==null?void 0:u.bounds),D={id:S,type:y,x:xt(_.x),y:xt(_.y),width:xt(_.width),height:xt(_.height),container:os.has(y)&&!P,attached:(m==null?void 0:m.attachedToRef)!==void 0,...m?{parent:RE(m,r)}:{},...C?{label:{x:xt(C.x),y:xt(C.y),width:xt(C.width),height:xt(C.height)}}:{},...y==="bpmn:Group"?jd($d(m)):{}},A=h.isHorizontal!==!1,B=typeof(m==null?void 0:m.name)=="string"?m.name:"";o.has(S)&&A&&B&&(D.label=Uu(D,B)),t.push(D);continue}const E=h.waypoint;if(Array.isArray(E)){const P=ht((l=ht(h.label))==null?void 0:l.bounds);n.push({id:S,type:y,waypoints:E.map(C=>{var D,A;return{x:xt((D=ht(C))==null?void 0:D.x),y:xt((A=ht(C))==null?void 0:A.y)}}),endpoints:EE(m),...SE(m),...P?{label:{x:xt(P.x),y:xt(P.y),width:xt(P.width),height:xt(P.height)}}:{}})}}}return{shapes:t,edges:n}}function zd(e){return Ti(Hd(e))}async function CE(e){const{definitions:t,warnings:n}=await Gu(e);return{findings:zd(t),warnings:n}}function wt(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=ht(o.label),m=Mi(o.source),S=Mi(o.target);n.push({id:o.id,type:a,waypoints:s.map(y=>({x:xt(y.x),y:xt(y.y)})),endpoints:[m,S].filter(y=>!!y),...m&&S?{source:m,target:S}:{},...h&&typeof h.x=="number"?{label:{x:h.x,y:xt(h.y),width:xt(h.width),height:xt(h.height)}}:{}});continue}if(typeof o.x!="number"||typeof o.y!="number")continue;const c=ht(o.businessObject),u=ht(o.label);let l=ht(o.parent);for(;l&&l.type==="bpmn:Lane";)l=ht(l.parent);const p=typeof(l==null?void 0:l.type)=="string"?l.type:"",f=l&&os.has(p)&&p!=="bpmn:Group"&&typeof l.id=="string"?l.id:void 0,d={id:o.id,type:a,x:o.x,y:o.y,width:xt(o.width),height:xt(o.height),container:os.has(a)&&(a==="bpmn:Participant"||o.collapsed!==!0),attached:(c==null?void 0:c.attachedToRef)!==void 0,...f!==void 0?{parent:f}:{},...u&&typeof u.x=="number"?{label:{x:u.x,y:xt(u.y),width:xt(u.width),height:xt(u.height)}}:{},...a==="bpmn:Group"?jd($d(c)):{}},g=typeof(c==null?void 0:c.name)=="string"?c.name:"";a==="bpmn:Participant"&&!(c!=null&&c.processRef)&&g&&((i=ht(o.di))==null?void 0:i.isHorizontal)!==!1&&(d.label=Uu(d,g)),t.push(d)}return{shapes:t,edges:n}}const PE={"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 AE(e,t){const n=PE[e];return n||(e==="label"||e.startsWith("bpmndi:")?"other":e.startsWith("bpmn:")&&!("waypoints"in t&&t.waypoints)?"flowNode":"other")}function Gd(e){let t=e.parent;for(;t;){if(t.type==="bpmn:Participant")return t.id;t=t.parent}}function Vd(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 AE(i.type,i)},lanesOf:n=>t().filter(i=>i.type==="bpmn:Lane"&&Gd(i)===n).sort((i,r)=>i.y-r.y).map(i=>i.id),participantOf:n=>{const i=e.get(n);return i?Gd(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}}}}const Wd=20,TE=4,Mt=(e,t)=>Math.abs(e-t)<.5;function Ud(e,t,n,i=Wd){if(Mt(e.y,t.y)&&!Mt(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=u=>[{x:a,y:e.y},{x:a,y:u},{x:s,y:u},{x:s,y:e.y}];return[c(n.y-i),c(n.y+n.height+i)]}if(Mt(e.x,t.x)&&!Mt(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=u=>[{x:e.x,y:a},{x:u,y:a},{x:u,y:s},{x:e.x,y:s}];return[c(n.x-i),c(n.x+n.width+i)]}return null}function qd(e,t,n=Wd){if(e.length!==4)return null;const[i,r,o,a]=e;if(Mt(i.y,r.y)&&Mt(r.x,o.x)&&Mt(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(Mt(i.x,r.x)&&Mt(r.y,o.y)&&Mt(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 Xu(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,u=[{x:n.x+n.width,y:r},{x:a,y:r},{x:a,y:c?i.y+i.height:i.y}],l=[{x:s,y:c?n.y:n.y+n.height},{x:s,y:o},{x:i.x,y:o}];return[u,l]}const Yd=30,ME=[0,-25,25,-40,40];function kE(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+Yd:s-Yd,u=a?i.y+i.height:i.y,l=n.x+n.width/2,p=i.x+i.width/2;return ME.map(f=>[{x:l,y:s},{x:l,y:c},{x:p+f,y:c},{x:p+f,y:u}])}const OE=(e,t,n)=>[...e.slice(0,t+1),...n,...e.slice(t+1)],ps=(e,t,n)=>Fn({...e,waypoints:t},n).length;function Kd(e,t,n,i){let r=[...e.waypoints],o=ps(e,r,t);if(o===0)return null;let a=!1;for(const p of Xu(e,t))if(ps(e,p,t)===0)return p;const s=(i??[]).filter(p=>p.id!==e.id).flatMap(mn),c=p=>mn({...e,waypoints:p}).some(f=>cs(f,s).length>0),u=kE(e,t).filter(p=>ps(e,p,t)===0);if(u.length)return u.find(p=>!c(p))??u[0];const l=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);for(let p=0;p<TE&&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 m of t){if(e.endpoints.includes(m.id)||Fn({...e,waypoints:[g,h]},[m]).length===0)continue;const S=Ud(g,h,m),y=S?S.map(E=>OE(r,d,E)):qd(r,m)??[];if(!y.length)continue;const _=[...y].sort((E,P)=>Number(l(P))-Number(l(E)));for(const E of _){const P=ps(e,E,t);if(P<o){r=E,o=P,f=!0,a=!0;break}}if(f)break}}if(!f)break}return a&&o===0?r:null}function Xd(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n),o=ci(r),a=Ti(r).filter(c=>c.kind==="edge-crosses-shape"&&!t.has(Ri(c)));if(!a.length)return;const s=new Map;for(const c of a){if(c.kind!=="edge-crosses-shape"||s.has(c.edge))continue;const u=r.edges.find(l=>l.id===c.edge);u&&s.set(c.edge,u)}for(const[c,u]of s){const l=n.get(c);if(!l)continue;const p=l.parent,f=p&&typeof p.x=="number"&&typeof p.width=="number"?{x:p.x,y:p.y,width:p.width,height:p.height}:void 0,d=Kd(u,o,f,r.edges);if(!d)continue;const g=r.edges.filter(S=>S.id!==c),h=Ci(u,g);Ci({...u,waypoints:d},g)>h||i.updateWaypoints(l,d)}}const DE=10;function Zd(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 Qd(e,t){if(e.waypoints.length<2||e.endpoints.length!==2)return null;const n=t.shapes.filter($=>$.type==="bpmn:Participant"&&$.container),i=t.shapes.find($=>$.id===e.endpoints[0]),r=t.shapes.find($=>$.id===e.endpoints[1]);if(!i||!r)return null;const o=Zd(i,n),a=Zd(r,n);if(!o||!a||o.id===a.id)return null;const s=a.y>o.y,c=s?o:a,u=s?a:o,l=n.filter($=>$.id!==o.id&&$.id!==a.id&&$.y>=c.y+c.height&&$.y+$.height<=u.y).sort(($,re)=>$.y-re.y);if(!l.length)return null;const p=l[0],f=l[l.length-1],d=(c.y+c.height+p.y)/2,g=(f.y+f.height+u.y)/2,h=s?d:g,m=s?g:d,S=e.waypoints[0],y=e.waypoints[e.waypoints.length-1],_=ci(t),E=t.edges.filter($=>$.id!==e.id),P=Ai(e,E),C=Fn(e,_).length;if(P===0&&C===0||C===0&&e.waypoints.length===2)return null;const D=Math.min(...l.map($=>$.x)),A=Math.max(...l.map($=>$.x+$.width)),B=(S.x+y.x)/2,k=$=>$.filter((re,ye)=>ye===0||!(Mt(re.x,$[ye-1].x)&&Mt(re.y,$[ye-1].y)));let O;for(let $=D;$<=A;$+=DE){const re=k([S,{x:S.x,y:h},{x:$,y:h},{x:$,y:m},{x:y.x,y:m},y]),ye={...e,waypoints:re};if(Fn(ye,_).length>0)continue;const Ue=Ai(ye,E),q=Math.abs($-B);(!O||Ue<O.cross||Ue===O.cross&&q<O.detour)&&(O={pts:re,cross:Ue,detour:q})}return O&&(C>0?O.cross<=P:O.cross<P)?O.pts:null}function Jd(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n);for(const o of r.edges){if(o.type!=="bpmn:MessageFlow"||t.has(o.id))continue;const a=wt(n),s=a.edges.find(l=>l.id===o.id);if(!s)continue;const c=Qd(s,a);if(!c)continue;const u=n.get(o.id);u&&i.updateWaypoints(u,c)}}const Dr=[25,-25,40,-40],fs=35;function eh(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[];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,u=s?n.y:n.y+n.height,l=s?n.y-fs:n.y+n.height+fs,p=[];for(const y of[0,...Dr]){if(Math.abs(y)>=i.width/2-5)continue;const _=o+y;p.push({pts:[{x:n.x,y:r},{x:_,y:r},{x:_,y:c}],cost:Math.abs(y)});for(const E of[0,...Dr]){if(Math.abs(E)>=n.width/2-5)continue;const P=a+E;p.push({pts:[{x:P,y:u},{x:P,y:l},{x:_,y:l},{x:_,y:c}],cost:Math.abs(y)+Math.abs(E)})}}const f=50,d=i.y+i.height/2,g=s?n.y+n.height:n.y;for(const y of[0,...Dr]){if(Math.abs(y)>=n.width/2-5)continue;const _=a+y;p.push({pts:[{x:_,y:g},{x:_,y:d},{x:i.x+i.width,y:d}],cost:f+Math.abs(y)})}const h=60,m=s?i.y+i.height:i.y,S=s?i.y+i.height+fs:i.y-fs;for(const y of[0,...Dr]){if(Math.abs(y)>=i.width/2-5)continue;const _=o+y;for(const E of[0,...Dr]){if(Math.abs(E)>=n.width/2-5)continue;const P=a+E;p.push({pts:[{x:P,y:g},{x:P,y:S},{x:_,y:S},{x:_,y:m}],cost:h+Math.abs(y)+Math.abs(E)})}}return p}const ds=30;function th(e,t){for(let n=1;n<e.length-2;n++){const i=e[n],r=e[n+1],o=Mt(i.y,r.y)&&!Mt(i.x,r.x),a=Mt(i.x,r.x)&&!Mt(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)<ds||Math.abs(i.y-(s.y+s.height))<ds)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)<ds||Math.abs(i.x-(s.x+s.width))<ds)return!0}}return!1}const hs=40;function LE(e,t,n){let i=0;for(const r of t){if(r.container||n.includes(r.id))continue;const o=r.x-hs,a=r.x+r.width+hs,s=r.y-hs,c=r.y+r.height+hs;for(let u=1;u<e.length-2;u++){const l=e[u],p=e[u+1],f={x:Math.min(l.x,p.x),y:Math.min(l.y,p.y)},d={x:Math.max(l.x,p.x),y:Math.max(l.y,p.y)};if(f.x<a&&d.x>o&&f.y<c&&d.y>s){i++;break}}}return i}function nh(e,t){if(e.type!=="bpmn:SequenceFlow")return null;const n=t.shapes.filter(C=>C.container),i=new Map(t.shapes.map(C=>[C.id,C])),r=ci(t),o=t.edges.filter(C=>C.id!==e.id),a=Ci(e,o),s=Ai(e,o),c=C=>LE(C,t.shapes,e.endpoints)+(th(C,n)?1:0),u=c(e.waypoints),l=C=>{if(!C)return;const D=C.x+C.width/2,A=C.y+C.height/2;return n.find(B=>B.type==="bpmn:Lane"&&D>=B.x&&D<=B.x+B.width&&A>=B.y&&A<=B.y+B.height)},p=l(i.get(e.endpoints[0]??"")),f=l(i.get(e.endpoints[1]??"")),d=!!p&&!!f&&p.id!==f.id,g=C=>{if(!d||!f)return!1;for(let D=1;D<C.length-2;D++){const A=C[D],B=C[D+1];if(Mt(A.y,B.y)&&!Mt(A.x,B.x)&&A.y>f.y&&A.y<f.y+f.height)return!0}return!1},h=g(e.waypoints),S=(C=>{if(!C)return;const D=C.x+C.width/2,A=C.y+C.height/2;return n.filter(B=>B.type==="bpmn:Participant"&&D>=B.x&&D<=B.x+B.width&&A>=B.y&&A<=B.y+B.height).sort((B,k)=>B.width*B.height-k.width*k.height)[0]})(i.get(e.endpoints[0]??"")),y=C=>{if(!S)return 0;let D=0;for(let A=1;A<C.length-1;A++){const B=C[A];(B.x<S.x||B.x>S.x+S.width||B.y<S.y||B.y>S.y+S.height)&&D++}return D},_=y(e.waypoints);if(!th(e.waypoints,n)&&!(d&&!h)&&_===0)return null;const E=C=>C.reduce((D,A,B)=>B?D+Math.abs(A.x-C[B-1].x)+Math.abs(A.y-C[B-1].y):0,0);let P;for(const{pts:C,cost:D}of eh(e,i)){const A={...e,waypoints:C};if(Fn(A,r).length>0)continue;const B=Ci(A,o);if(B>a)continue;const k=y(C);if(k>_)continue;const O=k<_&&B===0;if(!O&&Ai(A,o)>s)continue;const $=c(C),re=g(C);if(!O&&!(re&&!h)&&$>=u)continue;const Ue=re?0:1,q=E(C);(!P||k<P.out||k===P.out&&(Ue<P.lane||Ue===P.lane&&(B<P.opp||B===P.opp&&($<P.sc||$===P.sc&&(D<P.cost||D===P.cost&&q<P.len)))))&&(P={pts:C,out:k,sc:$,lane:Ue,opp:B,cost:D,len:q})}return(P==null?void 0:P.pts)??null}function IE(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n).edges.filter(o=>!t.has(o.id)&&o.waypoints.length>=4).map(o=>o.id).sort();for(const o of r){const a=wt(n),s=a.edges.find(d=>d.id===o);if(!s||s.waypoints.length<4)continue;const c=ci(a),u=a.edges.filter(d=>d.id!==o),l=Fn(s,c).length,p=Ci(s,u),f=Ai(s,u);for(const d of Xu(s,a.shapes)){if(d.length>=s.waypoints.length)continue;const g={...s,waypoints:d};if(Fn(g,c).length>l||Ci(g,u)>p||Ai(g,u)>f)continue;const h=n.get(o);h&&i.updateWaypoints(h,d);break}}}function ih(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n).edges.filter(o=>o.type==="bpmn:SequenceFlow"&&!t.has(o.id)).map(o=>o.id).sort();for(const o of r){const a=wt(n),s=a.edges.find(l=>l.id===o);if(!s)continue;const c=nh(s,a);if(!c)continue;const u=n.get(o);u&&i.updateWaypoints(u,c)}}function BE(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=Mt(n[0].x,n[1].x)&&!Mt(n[0].y,n[1].y),s=Mt(n[n.length-1].x,n[n.length-2].x)&&!Mt(n[n.length-1].y,n[n.length-2].y);for(const c of Dr){if(a&&r&&Math.abs(c)<r.width/2-5){const u=n.map(l=>({...l}));u[0].x+=c,u[1].x+=c,i.push({pts:u,cost:Math.abs(c)})}if(s&&o&&Math.abs(c)<o.width/2-5){const u=n.map(l=>({...l}));u[u.length-1].x+=c,u[u.length-2].x+=c,i.push({pts:u,cost:Math.abs(c)})}}return i}function NE(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,u=a?i.y+i.height:i.y,l=(r+o)/2,p=[];for(const f of[0,...Dr]){const d=l+f;d<=r||d>=o||p.push({pts:[{x:d,y:c},{x:d,y:u}],cost:Math.abs(f)})}return p}function rh(e,t){const n=new Map(t.shapes.map(d=>[d.id,d])),i=ci(t),r=t.edges.filter(d=>d.id!==e.id),o=Ci(e,r);if(o===0)return null;const a=Ai(e,r);let s;const c=d=>d.reduce((g,h,m)=>m?g+Math.abs(h.x-d[m-1].x)+Math.abs(h.y-d[m-1].y):0,0),u=3,l=d=>{const g=d[0],h=d[d.length-1],m=Math.hypot(h.x-g.x,h.y-g.y);return m>=1&&c(d)/m>=u?1:0},p=l(e.waypoints),f=[...eh(e,n),...NE(e,n),...BE(e,n)];for(const{pts:d,cost:g}of f){const h={...e,waypoints:d};if(Fn(h,i).length>0)continue;const m=Ci(h,r),S=Ai(h,r),y=o-m+(p-l(d));if(m>=o||S-a>y)continue;const _=c(d);(!s||m<s.opposite||m===s.opposite&&(S<s.cross||S===s.cross&&(g<s.cost||g===s.cost&&_<s.len)))&&(s={pts:d,opposite:m,cross:S,cost:g,len:_})}return(s==null?void 0:s.pts)??null}function oh(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=wt(i),a=Ti(o).filter(l=>(l.kind==="edge-overlap-opposite"||l.kind==="edge-overlap-mixed")&&!t.has(Ri(l)));if(!a.length)return;const s=new Set;for(const l of a)if(!(l.kind!=="edge-overlap-opposite"&&l.kind!=="edge-overlap-mixed"))for(const p of l.edges)n.has(p)||s.add(p);const c=l=>{var p;return((p=o.edges.find(f=>f.id===l))==null?void 0:p.type)??""},u=[...s].sort((l,p)=>{const f=c(l)==="bpmn:SequenceFlow"?0:1,d=c(p)==="bpmn:SequenceFlow"?0:1;return f!==d?f-d:l.localeCompare(p)});for(const l of u){const p=wt(i),f=p.edges.find(h=>h.id===l);if(!f)continue;const d=rh(f,p);if(!d)continue;const g=i.get(l);g&&r.updateWaypoints(g,d)}}const $E=10,jE=(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 ah(e,t){const n=e.label;if(!n)return null;const i=t.edges.filter(a=>a.id!==e.id);if(!us(e,i))return null;const r=ci(t),o=i.flatMap(mn);for(const a of mn(e)){let s=[[a.lo,a.hi]];for(const[d,g]of cs(a,o))s=s.flatMap(([h,m])=>{const S=[];return d>h&&S.push([h,Math.min(m,d)]),g<m&&S.push([Math.max(h,g),m]),S.filter(([y,_])=>_>y)});const c=a.axis==="h"?n.width:n.height,u=s.find(([d,g])=>g-d>=c+$E*2);if(!u)continue;const l=(u[0]+u[1])/2,p=a.axis==="h"?{x:l,y:a.at-kd}:{x:a.at+Cn+n.width/2,y:l},f={x:p.x-n.width/2,y:p.y-n.height/2,width:n.width,height:n.height};if(!us({...e,label:f},i)&&!r.some(d=>!e.endpoints.includes(d.id)&&jE(f,d)))return f}return null}const Cn=8;function sh(e,t){const n=e.label;if(!n)return null;const i=mn(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(mn),...t.shapes.filter(f=>f.container).flatMap(qo)],u=f=>!c.some(d=>Pi(f,d));if(u(n))return null;const l=(s.axis==="v"?n.height:n.width)+Cn,p=[0,-l,l,-2*l,2*l];if(s.axis==="v")for(const f of[s.at+Cn,s.at-Cn-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(u(h))return h}else for(const f of[s.at-Cn-n.height,s.at+Cn])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(u(h))return h}return null}function ch(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n);for(const o of r.edges){if(!o.label||t.has(o.id))continue;const a=sh(o,r);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 uh(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=wt(i),a=Ti(o).filter(s=>s.kind==="label-on-shared-segment"&&!t.has(Ri(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 u=ah(c,o);if(!u)continue;const l=i.get(s.edge),p=l==null?void 0:l.label;p&&r.moveElements([p],{x:u.x-p.x,y:u.y-p.y})}}function lh(e,t){const n=e.label;if(!n)return null;const i=[...t.edges.flatMap(mn),...t.shapes.filter(f=>f.container).flatMap(qo)],r=i.filter(f=>Pi(n,f));if(!r.length)return null;const o=t.shapes.filter(f=>!f.container&&f.id!==e.id),a=uo(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=>Pi(f,d))&&!o.some(d=>s(f,d))&&!a.some(d=>s(f,d)),u=[];for(const f of r)f.axis==="h"?u.push({...n,y:f.at-Cn-n.height},{...n,y:f.at+Cn}):u.push({...n,x:f.at-Cn-n.width},{...n,x:f.at+Cn});const l=e.x+e.width/2,p=e.y+e.height/2;return u.push({...n,x:l-n.width/2,y:e.y+e.height+Cn},{...n,x:l-n.width/2,y:e.y-Cn-n.height},{...n,x:e.x+e.width+Cn,y:p-n.height/2},{...n,x:e.x-Cn-n.width,y:p-n.height/2}),u.find(c)??null}function ph(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n);for(const o of r.shapes){if(o.container||!o.label||t.has(o.id))continue;const a=lh(o,wt(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})}}const FE=/^[\p{L}_][\p{L}\p{N}_.\-]*$/u,fh=new Set(["sequenceFlow","messageFlow","dataAssociation","association"]),dh={"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","text"]},{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}],"element.remove":[{path:"id",shape:null}]},ms=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Zu=e=>typeof e=="string"&&e!=="";function HE(e){const t=[];function n(i,r,o,a){if(a===null){Zu(o)||t.push({kind:"payload-invalid",opIndex:i,field:r});return}if(!ms(o)){t.push({kind:"payload-invalid",opIndex:i,field:r});return}for(const s of a)Zu(o[s])||t.push({kind:"payload-invalid",opIndex:i,field:`${r}.${s}`})}return e.forEach((i,r)=>{if(!ms(i)||!Zu(i.kind)||!(i.kind in dh)){t.push({kind:"payload-invalid",opIndex:r,field:"kind"});return}for(const o of dh[i.kind]){const a=o.path.endsWith("[]"),s=a?o.path.slice(0,-2):o.path,c=s.split(".");let u=i;for(const p of c.slice(0,-1)){if(!ms(u))break;u=u[p]}if(!ms(u))continue;const l=u[c[c.length-1]];if(!(l===void 0&&o.optional)&&!(l===null&&o.optional)){if(!a){n(r,o.path,l,o.shape);continue}if(!Array.isArray(l)){t.push({kind:"payload-invalid",opIndex:r,field:o.path});continue}l.forEach((p,f)=>n(r,`${s}[${f}]`,p,o.shape))}}if(i.kind==="node.add"){const o=i.band;o!==void 0&&(!Number.isInteger(o)||o<0)&&t.push({kind:"payload-invalid",opIndex:r,field:"band"})}}),t}function hh(e,t){const n=HE(e);if(n.length>0)return n;const i=[],r=new Map,o=new Map;function a(f,d,g){if(!FE.test(d)){i.push({kind:"id-invalid",opIndex:f,id:d});return}if(t.categoryOf(d)!==void 0||r.has(d)){i.push({kind:"id-duplicate",opIndex:f,id:d});return}r.set(d,{...g,opIndex:f})}e.forEach((f,d)=>{var g;switch(f.kind){case"participant.add":a(d,f.participant.id,{category:"participant",lanes:(f.participant.lanes??[]).map(h=>h.id)});for(const h of f.participant.lanes??[])a(d,h.id,{category:"lane"});break;case"node.add":a(d,f.node.id,{category:"flowNode",participant:f.node.participant});break;case"sequenceFlow.add":a(d,f.flow.id,{category:"sequenceFlow"});break;case"messageFlow.add":a(d,f.flow.id,{category:"messageFlow"});break;case"dataStore.add":a(d,f.dataStore.id,{category:"dataStore"});for(const h of f.associations??[])h.id&&a(d,h.id,{category:"dataAssociation"});break;case"dataAssociation.add":f.association.id&&a(d,f.association.id,{category:"dataAssociation"});break;case"association.add":f.association.id&&a(d,f.association.id,{category:"association"});break;case"annotation.add":a(d,f.annotation.id,{category:"annotation"}),(g=f.association)!=null&&g.id&&a(d,f.association.id,{category:"association"});break;case"group.add":a(d,f.group.id,{category:"group"});break;case"participant.update":if(f.lanes){o.set(f.id,f.lanes.map(h=>h.id));for(const h of f.lanes)t.categoryOf(h.id)===void 0&&a(d,h.id,{category:"lane"})}break}});const s=f=>{var d;return((d=r.get(f))==null?void 0:d.category)??t.categoryOf(f)},c=f=>{const d=r.get(f);return d?d.category==="participant"?f:d.participant:t.categoryOf(f)==="participant"?f:t.participantOf(f)};function u(f,d,g,h){const m=s(d);if(m===void 0){i.push({kind:"ref-missing",opIndex:f,ref:d,role:g});return}if(h&&!h.includes(m)){i.push({kind:"ref-category",opIndex:f,ref:d,role:g,expected:h.join("|"),actual:m});return}return m}const l=t.isCollaboration()||e.some(f=>f.kind==="participant.add");return e.forEach((f,d)=>{var g;switch(f.kind){case"participant.add":break;case"node.add":{const{participant:h,lane:m}=f.node;if(h===void 0){(l||m!==void 0)&&i.push({kind:"participant-required",opIndex:d,id:f.node.id});break}if(u(d,h,"participant",["participant"])===void 0)break;m!==void 0&&((((g=r.get(h))==null?void 0:g.lanes)??o.get(h)??t.lanesOf(h)).includes(m)||i.push({kind:"lane-unknown",opIndex:d,lane:m,participant:h}));break}case"sequenceFlow.add":{const{id:h,source:m,target:S,name:y,condition:_}=f.flow,E=u(d,m,"source",["flowNode"]),P=u(d,S,"target",["flowNode"]);E&&P&&c(m)!==c(S)&&i.push({kind:"flow-cross-pool",opIndex:d,id:h}),y!==void 0&&_!==void 0&&i.push({kind:"condition-name-conflict",opIndex:d,id:h});break}case"messageFlow.add":{const{id:h,source:m,target:S}=f.flow,y=u(d,m,"source",["flowNode","participant"]),_=u(d,S,"target",["flowNode","participant"]);if(y&&_){const E=c(m),P=c(S);E!==void 0&&E===P&&i.push({kind:"message-flow-same-pool",opIndex:d,id:h})}break}case"dataStore.add":{for(const h of f.associations??[]){if([h.source,h.target].filter(y=>y===f.dataStore.id).length!==1){i.push({kind:"data-association-ends",opIndex:d,source:h.source,target:h.target});continue}const S=h.source===f.dataStore.id?h.target:h.source;u(d,S,"dataAssociation",["flowNode"])}break}case"dataAssociation.add":{const{source:h,target:m}=f.association,S=u(d,h,"source"),y=u(d,m,"target");if(S&&y){const _=new Set([S,y]);_.has("dataStore")&&_.has("flowNode")||i.push({kind:"data-association-ends",opIndex:d,source:h,target:m})}break}case"association.add":{const{id:h,source:m,target:S}=f.association,y=u(d,m,"source"),_=u(d,S,"target");y&&_&&y!=="annotation"&&_!=="annotation"&&i.push({kind:"association-detached",opIndex:d,annotation:h??`${m}->${S}`});break}case"annotation.add":{if(f.association){const{source:h,target:m}=f.association;if(h!==f.annotation.id&&m!==f.annotation.id)i.push({kind:"association-detached",opIndex:d,annotation:f.annotation.id});else{const S=h===f.annotation.id?m:h;u(d,S,"association")}}f.placement&&u(d,f.placement.anchor,"anchor");break}case"group.add":{for(const h of f.group.members??[]){const m=u(d,h,"member");m&&fh.has(m)&&i.push({kind:"ref-category",opIndex:d,ref:h,role:"member",expected:"shape",actual:m})}break}case"participant.update":{if(p(d,f.id,"participant")===void 0)break;if(f.lanes){const h=t.lanesOf(f.id),m=f.lanes.map(y=>y.id);for(const y of h)m.includes(y)||i.push({kind:"lane-shrink-unsupported",opIndex:d,participant:f.id,lane:y});for(const y of m)t.categoryOf(y)!==void 0&&!h.includes(y)&&i.push({kind:"id-duplicate",opIndex:d,id:y});const S=m.filter(y=>h.includes(y));S.length===h.length&&S.some((y,_)=>y!==h[_])&&i.push({kind:"lane-reorder-unsupported",opIndex:d,participant:f.id})}break}case"node.update":{if(p(d,f.id,"flowNode")===void 0)break;if(f.lane!==void 0){const h=t.participantOf(f.id);(h?o.get(h)??t.lanesOf(h):[]).includes(f.lane)||i.push({kind:"lane-unknown",opIndex:d,lane:f.lane,participant:h??""})}break}case"sequenceFlow.update":{if(p(d,f.id,"sequenceFlow")===void 0)break;if(f.name!==void 0&&f.condition!==void 0&&i.push({kind:"condition-name-conflict",opIndex:d,id:f.id}),f.source!==void 0||f.target!==void 0){const h=f.source===void 0||u(d,f.source,"source",["flowNode"])!==void 0,m=f.target===void 0||u(d,f.target,"target",["flowNode"])!==void 0,S=t.endpointsOf(f.id),y=f.source??(S==null?void 0:S.source),_=f.target??(S==null?void 0:S.target);h&&m&&y!==void 0&&_!==void 0&&new Set([c(y),c(_),c(f.id)]).size>1&&i.push({kind:"flow-cross-pool",opIndex:d,id:f.id})}break}case"messageFlow.update":p(d,f.id,"messageFlow");break;case"dataStore.update":p(d,f.id,"dataStore");break;case"annotation.update":{if(p(d,f.id,"annotation")===void 0)break;f.placement&&u(d,f.placement.anchor,"anchor");break}case"group.update":{if(p(d,f.id,"group")===void 0)break;for(const h of f.members??[]){const m=u(d,h,"member");m&&fh.has(m)&&i.push({kind:"ref-category",opIndex:d,ref:h,role:"member",expected:"shape",actual:m})}break}case"element.remove":{p(d,f.id)==="lane"&&i.push({kind:"ref-category",opIndex:d,ref:f.id,role:"target",expected:"removable",actual:"lane"});break}}}),i;function p(f,d,g){if(r.has(d)){i.push({kind:"target-added-in-batch",opIndex:f,id:d});return}const h=t.categoryOf(d);if(h===void 0){i.push({kind:"ref-missing",opIndex:f,ref:d,role:"target"});return}if(g&&h!==g){i.push({kind:"ref-category",opIndex:f,ref:d,role:"target",expected:g,actual:h});return}return h}}function mh(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")}}function gs(e){return`bpmn:${e[0].toUpperCase()}${e.slice(1)}`}const ys={"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]},en=10,gh=40,zE=10;function Qu(e,t,n,i,r){const o=n,a=(k,O)=>{const[$,re]=ys[k];let ye={x:t.x+t.width/2+$*(t.width/2+o.width/2+O),y:t.y+t.height/2+re*(t.height/2+o.height/2+O)};const Ue=i.x+en+o.width/2,q=i.x+i.width-en-o.width/2,le=i.y+en+o.height/2,me=i.y+i.height-en-o.height/2,se={x:Math.min(q,Math.max(Ue,ye.x)),y:Math.min(me,Math.max(le,ye.y))};return(se.x!==ye.x||se.y!==ye.y)&&(ye=Math.abs(se.x-(t.x+t.width/2))<(t.width+o.width)/2+en&&Math.abs(se.y-(t.y+t.height/2))<(t.height+o.height)/2+en?{x:t.x+t.width+en+o.width/2,y:se.y}:se),ye},s=(i.children??[]).filter(k=>!("waypoints"in k&&k.waypoints)&&k.type!=="bpmn:Lane"&&k.type!=="label"&&typeof k.x=="number"&&k.id!==r.selfId),c=wt(e),u=k=>{var $,re;if(!r.selfId)return!1;const O=e.get(k);return!!O&&((($=O.source)==null?void 0:$.id)===r.selfId||((re=O.target)==null?void 0:re.id)===r.selfId)},l=c.edges.filter(k=>!u(k.id)).flatMap(mn),p=uo(c).filter(k=>k.owner!==r.selfId).map(k=>k.rect),f=k=>({x0:k.x-o.width/2-en,x1:k.x+o.width/2+en,y0:k.y-o.height/2-en,y1:k.y+o.height/2+en}),d=k=>{const O=f(k);return s.some($=>O.x0<$.x+$.width&&O.x1>$.x&&O.y0<$.y+$.height&&O.y1>$.y)},g=k=>{const O=f(k);return l.some($=>$.axis==="h"?$.at>O.y0&&$.at<O.y1&&$.lo<O.x1&&$.hi>O.x0:$.at>O.x0&&$.at<O.x1&&$.lo<O.y1&&$.hi>O.y0)},h=k=>{const O=f(k);return p.some($=>O.x0<$.x+$.width&&O.x1>$.x&&O.y0<$.y+$.height&&O.y1>$.y)},m=c.shapes.filter(k=>k.type==="bpmn:Group").flatMap(k=>[{axis:"h",at:k.y,lo:k.x,hi:k.x+k.width},{axis:"h",at:k.y+k.height,lo:k.x,hi:k.x+k.width},{axis:"v",at:k.x,lo:k.y,hi:k.y+k.height},{axis:"v",at:k.x+k.width,lo:k.y,hi:k.y+k.height}]),S=k=>{const O=f(k);return m.some($=>$.axis==="h"?$.at>O.y0&&$.at<O.y1&&$.lo<O.x1&&$.hi>O.x0:$.at>O.x0&&$.at<O.x1&&$.lo<O.y1&&$.hi>O.y0)},y=k=>d(k)||g(k)||h(k)||S(k),_=k=>k.x-o.width/2>=i.x&&k.x+o.width/2<=i.x+i.width&&k.y-o.height/2>=i.y&&k.y+o.height/2<=i.y+i.height;if(r.placement){const k=q=>q.startsWith("top")?q.replace(/^top/,"bottom"):q.replace(/^bottom/,"top"),O=q=>q.endsWith("left")?q.replace(/left$/,"right"):q.replace(/right$/,"left"),$=r.placement.side,re=[$,k($),O($),k(O($)),"top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"],ye=r.placement.offset??50;let Ue=a($,ye);if(y(Ue)){const q=new Set;for(const le of re){if(q.has(le))continue;q.add(le);const me=a(le,ye);if(_(me)&&!y(me)){Ue=me;break}}}return Ue}const E=r.from,P=i.x+en+o.width/2,C=i.x+i.width-en-o.width/2,D=i.y+en+o.height/2,A=i.y+i.height-en-o.height/2;let B={x:Math.min(C,Math.max(P,E.x)),y:Math.min(A,Math.max(D,E.y))};if(y(B)){const k=(t.width+o.width)/2+en,$=[{x:B.x+k,y:B.y},{x:B.x-k,y:B.y},{x:B.x,y:B.y-o.height-en},{x:B.x,y:B.y+o.height+en}].filter(_).find(re=>!y(re));$&&(B=$)}return B}function Xt(e,t){return e.filter(n=>n.kind===t)}function yh(e,t){var jx,Fx,Hx,zx,Gx,Vx,Wx,Ux,qx,Yx,Kx,Xx,Zx,Qx,Jx,e0,t0,n0,i0,r0,o0,a0,s0;const{modeling:n,bpmnFactory:i,elementFactory:r,elementRegistry:o,canvas:a,autoPlace:s,bpmnReplace:c}=t,u=()=>a.getRootElement(),l=w=>o.get(w),p=w=>{const R=l(w);if(!R)throw new Error(`하강 참조 해소 실패: ${w}`);return R},f=w=>{let R=w.parent;for(;R;){if(R.type==="bpmn:Participant")return R;R=R.parent}},d=new Map;for(const w of o.filter(R=>!("waypoints"in R&&R.waypoints)&&R.type!=="bpmn:Lane"&&R.type!=="label"&&typeof R.x=="number"))d.set(w.id,{x:w.x,y:w.y});const g=Xt(e,"participant.add"),h=Xt(e,"node.add"),m=Xt(e,"sequenceFlow.add"),S=Xt(e,"messageFlow.add"),y=Xt(e,"dataStore.add"),_=Xt(e,"dataAssociation.add"),E=Xt(e,"annotation.add"),P=Xt(e,"group.add"),C=new Map(h.map(w=>[w.node.id,w])),D=(w,R,M)=>{var G;const F=w.businessObject,H=(((G=F.extensionElements)==null?void 0:G.values)??[]).filter(W=>W.$type!==R),I=M?[...H,i.create(R,M)]:H;if(!I.length){F.extensionElements&&n.updateProperties(w,{extensionElements:void 0});return}const Y=i.create("bpmn:ExtensionElements",{values:I});I.forEach(W=>{W.$parent=Y}),n.updateProperties(w,{extensionElements:Y})},A=w=>({anchor:w.anchor,side:w.side,...w.offset!==void 0?{offset:w.offset}:{}});for(const w of Xt(e,"element.remove")){const R=l(w.id);R&&n.removeElements([R])}const B=w=>o.filter(R=>{var M;return R.type==="bpmn:Lane"&&((M=f(R))==null?void 0:M.id)===w}).sort((R,M)=>R.y-M.y);for(const w of Xt(e,"participant.update")){const R=p(w.id);if(w.name!==void 0&&n.updateProperties(R,{name:w.name??void 0}),!w.lanes)continue;const M=B(w.id);if(!M.length){n.splitLane(R,w.lanes.length),B(w.id).forEach((H,I)=>{const Y=w.lanes[I];Y&&n.updateProperties(H,{id:Y.id,name:Y.name})});continue}const F=new Set(M.map(H=>H.id));w.lanes.forEach((H,I)=>{if(F.has(H.id)){n.updateProperties(p(H.id),{name:H.name});return}const Y=I===0?n.addLane(B(w.id)[0],"top"):n.addLane(p(w.lanes[I-1].id),"bottom");n.updateProperties(Y,{id:H.id,name:H.name})})}const k=150,O=130,$=80,re=90,ye=180,Ue=30,q=(w,R,M,F,H)=>{const I=M-R.width/2,Y=F-R.height/2;return(w.children??[]).find(G=>!("waypoints"in G&&G.waypoints)&&G.type!=="bpmn:Lane"&&G.type!=="label"&&!(H!=null&&H.has(G.id))&&typeof G.x=="number"&&I<G.x+G.width+Ue&&I+R.width+Ue>G.x&&Y<G.y+G.height&&Y+R.height>G.y)},le=new Set;for(const w of g){le.add(`pool:${w.participant.id}`);for(const R of w.participant.lanes??[])le.add(R.id)}const me=new Map;for(const w of h){const R=w.node.lane??`pool:${w.node.participant??""}`;let M=me.get(R);M||me.set(R,M=new Set([0])),w.band!==void 0&&M.add(w.band)}const se=new Map;for(const[w,R]of me){if(!le.has(w))continue;const M=[...R].sort((I,Y)=>I-Y),F=M.map((I,Y)=>Y===0?0:Y%2===1?Math.ceil(Y/2):-(Y/2)),H=Math.min(...F);se.set(w,new Map(M.map((I,Y)=>[I,F[Y]-H])))}{const w=new Map;for(const R of g)(R.participant.lanes??[]).forEach((M,F)=>w.set(M.id,F));for(const[R,M]of se){if(!w.has(R)||M.size<2)continue;const F=w.get(R),H=M.get(0)??0,I=new Set;for(const oe of h){if(oe.node.lane!==R||(oe.band??0)!==0||!oe.node.type.endsWith("Gateway"))continue;const Me={in:new Set,out:new Set,cross:new Set};for(const pe of m){const ve=pe.flow.source===oe.node.id;if(!ve&&pe.flow.target!==oe.node.id)continue;const ot=C.get(ve?pe.flow.target:pe.flow.source);if(!ot||ot.node.participant!==oe.node.participant||!ot.node.lane)continue;let Ce,$e=!1;if(ot.node.lane!==R){const ue=w.get(ot.node.lane);if(ue===void 0)continue;Ce=ue>F?"down":"up",$e=!0}else{const ue=M.get(ot.band??0)??H;Ce=ue>H?"down":ue<H?"up":void 0}Ce&&(Me[ve?"out":"in"].add(Ce),$e&&Me.cross.add(Ce))}for(const pe of["up","down"])Me.in.has(pe)&&Me.out.has(pe)&&Me.cross.has(pe)&&I.add(pe)}if(I.size!==1)continue;const[Y]=I,G=Math.max(...M.values()),W=Y==="down"?G:0;if(H===W)continue;const ce=[...M.entries()].filter(([oe])=>oe!==0).sort((oe,Me)=>oe[1]-Me[1]),xe=[...Array(G+1).keys()].filter(oe=>oe!==W),Re=new Map([[0,W]]);ce.forEach(([oe],Me)=>Re.set(oe,xe[Me])),se.set(R,Re)}}const _e=w=>{var R;return(((R=me.get(w))==null?void 0:R.size)??0)>1},ne=w=>w.band??(w.node.lane||!_e(`pool:${w.node.participant??""}`)?void 0:0),U=new Map,V=w=>U.get(w.node.id)??ne(w),Z=new Set,Fe=new Set;{const w=new Map;for(const F of m)w.set(F.flow.target,(w.get(F.flow.target)??0)+1);const R=F=>{const H=[],I=new Set([F]),Y=[F];for(;Y.length;){const G=Y.shift();H.push(G);for(const W of m)W.flow.source!==G||I.has(W.flow.target)||(w.get(W.flow.target)??0)!==1||(I.add(W.flow.target),Y.push(W.flow.target))}return H},M=(F,H)=>{var I;return((I=se.get(F))==null?void 0:I.get(H))??H};for(const F of h){if(!F.node.type.endsWith("Gateway"))continue;const H=F.node.lane??`pool:${F.node.participant??""}`,I=se.get(H);if(!I||I.size<2)continue;const Y=V(F);if(Y===void 0||M(H,Y)!==M(H,0))continue;const G=M(H,Y),W=m.filter(pe=>pe.flow.source===F.node.id).map(pe=>C.get(pe.flow.target)).filter(pe=>!!pe&&(pe.node.lane??`pool:${pe.node.participant??""}`)===H),ce=W.filter(pe=>{const ve=V(pe);return ve!==void 0&&M(H,ve)===G&&(w.get(pe.node.id)??0)===1}),xe=W.some(pe=>{const ve=V(pe);return ve!==void 0&&M(H,ve)>G});if(ce.length!==1||!xe)continue;const Re=new Set(W.flatMap(pe=>R(pe.node.id)));if(!m.some(pe=>pe.flow.target===F.node.id&&Re.has(pe.flow.source)))continue;const Me=new Map;for(const[pe,ve]of I)Me.set(pe,ve+1);Me.set(-1,0),se.set(H,Me);for(const pe of R(ce[0].node.id))C.has(pe)&&(U.set(pe,-1),Fe.add(pe));Z.add(F.node.id)}}const Rt=(w,R)=>{var M;return((M=se.get(w))==null?void 0:M.get(R))??R},T=new Map;for(const[w,R]of me){let M=0;for(const F of R)M=Math.max(M,Rt(w,F));T.set(w,M)}const x=w=>ye+k*w,v=g.map((w,R)=>({op:w,declared:R}));v.sort((w,R)=>{const M=w.op.order??Number.POSITIVE_INFINITY,F=R.op.order??Number.POSITIVE_INFINITY;return M!==F?M-F:w.declared-R.declared});let N=80;for(const w of o.getAll())w.parent===u()&&"height"in w&&typeof w.y=="number"&&(N=Math.max(N,w.y+w.height+60));for(const{op:w}of v){const R=w.participant,M=h.filter(oe=>oe.node.participant===R.id).length,F=((jx=R.lanes)==null?void 0:jx.length)??0,H=Math.max(1200,M*160+300),I=(R.lanes??[]).map(oe=>x(T.get(oe.id)??0)),Y=I.reduce((oe,Me)=>oe+Me,0);F&&Y<300&&(I[F-1]+=300-Y);const G=Math.max(300,k*((T.get(`pool:${R.id}`)??0)+1)),W=R.blackBox||M+F===0?120:F?Math.max(300,Y):G,ce=r.createShape({type:"bpmn:Participant",businessObject:i.create("bpmn:Participant",{id:R.id,name:R.name,...w.order!==void 0?{"bwl:poolOrder":w.order}:{},...R.blackBox?{}:{processRef:i.create("bpmn:Process")}}),width:H,height:W,isExpanded:!0}),xe=n.createShape(ce,{x:100+H/2,y:N+W/2},u()),Re=R.lanes??[];if(Re.length&&n.splitLane(xe,Re.length),Re.length){const oe=o.filter(Me=>{var pe;return Me.type==="bpmn:Lane"&&((pe=f(Me))==null?void 0:pe.id)===R.id}).sort((Me,pe)=>Me.y-pe.y);if(oe.forEach((Me,pe)=>{const ve=Re[pe];ve&&n.updateProperties(Me,{id:ve.id,name:ve.name})}),I.some(Me=>Me!==xe.height/F)){let Me=xe.y;oe.forEach((pe,ve)=>{const ot=I[ve];n.resizeShape(pe,{x:pe.x,y:Me,width:pe.width,height:ot}),Me+=ot})}}N=xe.y+xe.height+60}const z=w=>{var F;const R=C.get(w);if(R)return R.node.participant??"";const M=l(w);return M?M.type==="bpmn:Participant"?M.id:((F=f(M))==null?void 0:F.id)??"":""},K=new Map,ge=w=>{let R=K.get(w);return R||K.set(w,R={nodes:[],flows:[]}),R};for(const w of h)ge(w.node.participant??"").nodes.push(w);for(const w of m)ge(z(w.flow.source)).flows.push(w);const Be=w=>{var R;return i.create("bpmn:SequenceFlow",{id:w.id,name:w.name??((R=w.condition)==null?void 0:R.label)})},Qe=(w,R)=>r.createShape({type:gs(w.type),businessObject:i.create(gs(w.type),{id:w.id,name:w.name,...R!==void 0?{"bwl:band":R}:{}})}),Ct=[...v.map(({op:w})=>w.participant.id).filter(w=>K.has(w)),...[...K.keys()].filter(w=>!g.some(R=>R.participant.id===w))],rt=w=>w.endsWith("Gateway");for(const w of Ct){const R=K.get(w),M=w?p(w):void 0,F=M?M.x+150:250;let H=M?M.y+80:120;const I=(ue,we,Ne)=>{const it=u().children.filter(dt=>!("waypoints"in dt&&dt.waypoints)&&dt.id!==we&&typeof dt.y=="number"&&dt.y>=ue);it.length&&n.moveElements(it,{x:0,y:Ne})},Y=(ue,we)=>{if(ue){const et=p(ue),Ut=x(we);if(et.height>=Ut)return;const Jt=Ut-et.height,X=f(et),te=X?X.y+X.height:et.y+et.height;n.resizeLane(et,{x:et.x,y:et.y,width:et.width,height:Ut},!1),I(te,X==null?void 0:X.id,Jt);return}if(!M)return;const Ne=k*(we+1);if(M.height>=Ne)return;const it=Ne-M.height,dt=M.y+M.height;n.resizeShape(M,{x:M.x,y:M.y,width:M.width,height:Ne}),I(dt,M.id,it)},G=(ue,we,Ne)=>{if(ue){const it=p(ue);return it.y+Math.min(it.height/2,re)+Rt(ue,we??0)*k}return we!==void 0&&M?M.y+$+Rt(`pool:${w}`,we)*k:Ne},W=(ue,we,Ne)=>{if(ue){const it=p(ue);return it.y+Math.min(it.height/2,re)+we*k}return M?M.y+$+we*k:Ne},ce=ue=>ue.participant?p(ue.participant):u(),xe=(ue,we,Ne,it,dt,et)=>{const Ut=Ne!==void 0||it!==void 0,Jt=Rt(Ne??`pool:${w}`,it??0);if(Ut)for(let ae=0;ae<4;ae++){const be=W(Ne,Jt+ae,et);if(!q(ue,we,dt,be))return Y(Ne,Jt+ae),{x:dt,y:be}}const X=G(Ne,it,et);Ut&&Y(Ne,Jt);let te=dt;for(let ae=0;ae<64;ae++){const be=q(ue,we,te,X);if(!be)break;te=be.x+be.width+O+we.width/2}return{x:te,y:X}},Re=new Set(R.flows.map(ue=>ue.flow.target)),oe=new Map;for(const ue of R.nodes){if(Re.has(ue.node.id))continue;const we=Qe(ue.node,ue.band),Ne=ne(ue),it=ue.node.lane?`${ue.node.lane}|${Ne??""}`:Ne!==void 0?`band:${Ne}`:"",dt=ce(ue.node),et=xe(dt,we,ue.node.lane,Ne,oe.get(it)??F,H);n.createShape(we,et,dt),oe.set(it,et.x+we.width+O),!ue.node.lane&&Ne===void 0&&(H+=160)}const Me=new Set,pe=new Map,ve=new Map,ot=new Map;if(w&&le.has(`pool:${w}`)){const ue=new Map;for(const X of R.flows)ue.set(X.flow.target,(ue.get(X.flow.target)??0)+1);const we=X=>G(X.node.lane,V(X),Number.NaN),Ne=new Set,it=X=>{var be;const te=(be=C.get(X))==null?void 0:be.node.participant;if(te)return l(te);const ae=l(X);if(ae)return ae.type==="bpmn:Participant"?ae:f(ae)},dt=X=>{const te=[],ae=new Set([X]),be=[X];for(;be.length;){const Je=be.shift(),Ge=C.get(Je);Ge&&te.push(Ge);for(const ke of R.flows)ke.flow.source!==Je||ae.has(ke.flow.target)||(ue.get(ke.flow.target)??0)!==1||(ae.add(ke.flow.target),be.push(ke.flow.target))}return te},et=X=>{if(!M)return;const te=new Set(X.map(Je=>Je.node.id));let ae=!1,be=!1;for(const Je of S){if(!te.has(Je.flow.source))continue;const Ge=it(Je.flow.target);!Ge||Ge.id===M.id||(Ge.y<M.y?ae=!0:be=!0)}return ae&&!be?"up":be&&!ae?"down":void 0};for(const X of R.nodes){if(!rt(X.node.type))continue;const te=G(X.node.lane,ne(X),Number.NaN);if(Number.isNaN(te))continue;const ae=[];for(const ke of R.flows){if(ke.flow.source!==X.node.id)continue;const Ve=C.get(ke.flow.target);if(!Ve||Ve.node.lane!==X.node.lane||(ue.get(Ve.node.id)??0)!==1)continue;const tt=ne(Ve);if(tt===void 0)continue;const qt=G(Ve.node.lane,tt,Number.NaN);if(Number.isNaN(qt))continue;const At=dt(Ve.node.id),$t=et(At);$t&&ae.push({subtree:At,band:tt,row:qt,dir:$t})}if(!ae.some(ke=>ke.dir==="up")||!ae.some(ke=>ke.dir==="down")||!ae.some(ke=>ke.dir==="up"&&ae.some(Ve=>Ve.dir==="down"&&Ve.row<ke.row)))continue;const Je=[...ae].sort((ke,Ve)=>ke.row-Ve.row);[...ae.filter(ke=>ke.dir==="up"),...ae.filter(ke=>ke.dir==="down")].sort((ke,Ve)=>ke.dir===Ve.dir?ke.row-Ve.row:ke.dir==="up"?-1:1).forEach((ke,Ve)=>{const tt=Je[Ve].band;if(tt!==ke.band){Ne.add(X.node.id);for(const qt of ke.subtree)ne(qt)===ke.band&&U.set(qt.node.id,tt)}})}const Ut=X=>{if(!M)return;const te=new Set(X.map(Je=>Je.node.id));let ae=!1,be=!1;for(const Je of S){if(!te.has(Je.flow.target))continue;const Ge=it(Je.flow.source);!Ge||Ge.id===M.id||(Ge.y<M.y?ae=!0:be=!0)}return ae&&!be?"up":be&&!ae?"down":void 0};for(const X of R.nodes){if(!rt(X.node.type))continue;const te=X.node.lane??`pool:${w}`,ae=se.get(te);if(!ae||ae.size<2)continue;const be=ae.get(0);if(be===void 0)continue;const Je=Math.max(...ae.values()),Ge=be===Je&&be!==0?"down":void 0;if(!Ge)continue;const ke=[];for(const $t of R.flows){if($t.flow.source!==X.node.id)continue;const ei=C.get($t.flow.target);if(!ei||ei.node.lane!==X.node.lane||(ue.get(ei.node.id)??0)!==1)continue;const c0=V(ei);c0!==void 0&&ke.push({t:ei,subtree:dt(ei.node.id),band:c0})}const Ve=ke.find($t=>(ae.get($t.band)??$t.band)===be);if(!Ve||Ut(Ve.subtree)===Ge||et(Ve.subtree)===Ge)continue;const tt=ke.find($t=>$t!==Ve&&Ut($t.subtree)===Ge);if(!tt)continue;const qt=Ve.band,At=tt.band;for(const $t of Ve.subtree)V($t)===qt&&U.set($t.node.id,At);for(const $t of tt.subtree)V($t)===At&&U.set($t.node.id,qt);Ne.add(X.node.id)}for(const X of R.nodes){if(!rt(X.node.type))continue;const te=we(X);if(Number.isNaN(te)||E.some(ke=>{var Ve,tt;return(((Ve=ke.placement)==null?void 0:Ve.anchor)??(ke.association?ke.association.source===ke.annotation.id?ke.association.target:ke.association.source:void 0))===X.node.id&&((tt=ke.placement)==null?void 0:tt.side.startsWith("bottom"))}))continue;let be,Je=!1,Ge;for(const ke of R.flows){if(ke.flow.source!==X.node.id)continue;const Ve=C.get(ke.flow.target);if(!Ve||!Ve.node.lane&&ne(Ve)===void 0)continue;const tt=we(Ve);Number.isNaN(tt)||(Math.abs(tt-te)<.5&&(Je=!0),tt>te?!be||tt>be.row?be={id:Ve.node.id,row:tt,count:1}:tt===be.row&&be.count++:tt<te&&Ve.node.lane===X.node.lane&&(!Ge||tt>Ge.row?Ge={op:Ve,row:tt,count:1}:tt===Ge.row&&Ge.count++))}be&&be.count===1&&(ue.get(be.id)??0)===1&&!Ne.has(X.node.id)&&Me.add(be.id),!Je&&Ge&&Ge.count===1&&(ue.get(Ge.op.node.id)??0)===1&&!Z.has(X.node.id)&&pe.set(Ge.op.node.id,{lane:X.node.lane,band:V(X)})}const Jt=new Map;for(const X of S)Jt.set(X.flow.target,[...Jt.get(X.flow.target)??[],X]);for(const X of R.nodes){const te=Jt.get(X.node.id);if(!te||te.length!==1||!ue.get(X.node.id)||!X.node.lane&&ne(X)===void 0||Fe.has(X.node.id))continue;const ae=(Fx=C.get(te[0].flow.source))==null?void 0:Fx.node.participant,be=ae?l(ae):void 0;if(!be||!M||be.id===M.id)continue;const Je=X.node.lane??`pool:${w}`,Ge=se.get(Je);if(!Ge)continue;const ke=Ge.get(0)??0,Ve=(Ge.get(V(X)??0)??ke)-ke;if(Ve===0)continue;const tt=be.y<M.y;if(tt&&Ve<0||!tt&&Ve>0)continue;let qt;for(const[At,$t]of Ge){const ei=$t-ke;(tt&&ei<0&&(!qt||ei<qt.row)||!tt&&ei>0&&(!qt||ei>qt.row))&&(qt={band:At,row:ei})}qt&&ve.set(X.node.id,{lane:X.node.lane,band:qt.band})}}const Ce=new Set;let $e=0;for(;$e++<R.nodes.length+2;){for(let Ne=0;Ne<R.nodes.length+R.flows.length+2;Ne++){let it=!1;for(const dt of R.flows){const et=dt.flow;if(Ce.has(et.id))continue;const Ut=l(et.source);if(!Ut)continue;const Jt=l(et.target),X=C.get(et.target);if(!Jt&&X){const te=Qe(X.node,X.band),ae=V(X);if(X.node.lane||ae!==void 0){const be=ce(X.node),Je=Ut,Ge=Je.x+(ot.get(et.source)??0)+Je.width+O,ke=pe.get(et.target)??ve.get(et.target),Ve=xe(be,te,ke?ke.lane:X.node.lane,ke?ke.band:ae,Me.has(et.target)?Je.x+Je.width/2:Ge,Number.NaN),tt=n.createShape(te,Ve,be);Me.has(et.target)&&ot.set(et.target,Ge-(tt.x+tt.width/2)),n.connect(Ut,tt,{type:"bpmn:SequenceFlow",businessObject:Be(et)})}else s.append(Ut,te,{connection:{type:"bpmn:SequenceFlow",businessObject:Be(et)}})}else if(Jt)n.connect(Ut,Jt,{type:"bpmn:SequenceFlow",businessObject:Be(et)});else continue;Ce.add(et.id),it=!0}if(!it)break}const ue=R.nodes.filter(Ne=>!l(Ne.node.id));if(!ue.length)break;const we=ue[0];{const Ne=Qe(we.node,we.band),it=ce(we.node),dt=ne(we);n.createShape(Ne,xe(it,Ne,we.node.lane,dt,F,H),it),!we.node.lane&&dt===void 0&&(H+=160)}}}const Nt=40,Pt=(w,R=()=>!0)=>{const M=l(w);if(!M)return[];const F=[M],H=new Set([w]);for(let I=0;I<F.length;I++){const Y=F[I].id;for(const G of m){const W=G.flow.target;if(G.flow.source!==Y||H.has(W)||!C.has(W))continue;H.add(W);const ce=l(W);ce&&R(ce)&&F.push(ce)}}return F},vn=(w,R=()=>!0)=>{const M=l(w);if(!M)return[];const F=[M],H=new Set([w]);for(let I=0;I<F.length;I++){const Y=F[I].id;for(const G of m){const W=G.flow.source;if(G.flow.target!==Y||H.has(W)||!C.has(W))continue;H.add(W);const ce=l(W);ce&&R(ce)&&F.push(ce)}}return F};for(const w of Xt(e,"sequenceFlow.update")){if(w.target===void 0)continue;const R=C.get(w.target);if(!R)continue;const M=l(w.target),F=l(w.id);if(!M||!F)continue;const H=w.source!==void 0?l(w.source):F.source,I=F.target;if(!H||!I||I.id===M.id)continue;const Y=Pt(w.target),G=new Set(Y.map(pe=>pe.id)),W=Math.min(...Y.map(pe=>pe.x)),ce=Math.max(...Y.map(pe=>pe.x+pe.width)),xe=H.x+H.width,Re=ce-W+Nt*2-(I.x-xe);if(Re>0){const pe=f(M),ve=(pe==null?void 0:pe.children)??[],ot=ue=>ue.type==="bpmn:Lane",Ce=ve.filter(ue=>!("waypoints"in ue&&ue.waypoints)&&!ot(ue)&&!G.has(ue.id)&&ue.x>=I.x),$e=pe?[pe,...ve.filter(ue=>ot(ue))]:[];Ce.length&&n.createSpace(Ce,$e,{x:Re,y:0},"e",I.x-1)}const oe=R.node.lane||R.band!==void 0?M.y+M.height/2:H.y+H.height/2;n.moveElements(Y,{x:xe+Nt-W,y:oe-(M.y+M.height/2)});const Me=f(M);if(R.node.lane===void 0&&R.band!==void 0&&Me){const pe=Me.y+$+Rt(`pool:${R.node.participant??""}`,R.band)*k,ve=pe-(M.y+M.height/2);ve!==0&&!q(Me,M,M.x+M.width/2,pe,G)&&n.moveElements([M],{x:0,y:ve})}}const pt=(w,R)=>{const M=R.target===w,F=p(R.source),H=p(R.target),I=M?"bpmn:DataOutputAssociation":"bpmn:DataInputAssociation";n.connect(F,H,R.id?{type:I,businessObject:i.create(I,{id:R.id})}:{type:I})},Vt=100,dn=w=>{for(const R of g){if(!R.participant.blackBox)continue;const M=l(R.participant.id);if(!M)continue;const F=[];for(const I of S){const Y=I.flow.source===R.participant.id?I.flow.target:I.flow.target===R.participant.id?I.flow.source:void 0,G=Y?l(Y):void 0;G&&typeof G.x=="number"&&G.type!=="bpmn:Participant"&&F.push(G)}if(!F.length)continue;const H=Math.max(...F.map(I=>I.x+I.width/2))+Vt;if(H>M.x+M.width&&n.resizeShape(M,{x:M.x,y:M.y,width:H-M.x,height:M.height}),!!w)for(const I of S){const Y=l(I.flow.id),G=I.flow.source===R.participant.id?I.flow.target:I.flow.target===R.participant.id?I.flow.source:void 0,W=G?l(G):void 0;if(!Y||!W||W.type==="bpmn:Participant")continue;const ce=W.x+W.width/2;if(ce<M.x+10||ce>M.x+M.width-10)continue;const xe=M.y>W.y,Re=xe?W.y+W.height:W.y,oe=xe?M.y:M.y+M.height,Me=I.flow.source===R.participant.id?[{x:ce,y:oe},{x:ce,y:Re}]:[{x:ce,y:Re},{x:ce,y:oe}],pe=wt(o),ve={...pe.edges.find(ot=>ot.id===I.flow.id),waypoints:Me};Fn(ve,ci(pe)).length||n.updateWaypoints(Y,Me)}}};dn(!1);for(const w of S){const R=w.flow;n.connect(p(R.source),p(R.target),{type:"bpmn:MessageFlow",businessObject:i.create("bpmn:MessageFlow",{id:R.id,name:R.name})})}{const M=new Set([...m.map(W=>W.flow.id),...S.map(W=>W.flow.id)].filter(W=>!!W)),F=o.filter(W=>!!W.waypoints),H=(W,ce)=>Math.abs(ce.x-W.x)<2?"L":Math.abs(ce.x-(W.x+W.width))<2?"R":Math.abs(ce.y-W.y)<2?"T":Math.abs(ce.y-(W.y+W.height))<2?"B":void 0,I=new Map,Y=(W,ce,xe)=>{if(!W||!ce||typeof W.x!="number")return;const Re=H(W,ce);if(!Re)return;let oe=I.get(W.id);oe||I.set(W.id,oe=new Map),oe.set(Re,[...oe.get(Re)??[],xe])};for(const W of F){const ce=W.waypoints;!ce||ce.length<2||(Y(W.source,ce[0],{id:W.id,dir:"out"}),Y(W.target,ce[ce.length-1],{id:W.id,dir:"in"}))}const G=new Set;for(const[W,ce]of I){const xe=l(W);if(!xe||typeof xe.x!="number"||![...ce.values()].some($e=>{const ue=$e.filter(we=>we.dir==="in");return $e.length>=3&&ue.length>=1&&$e.some(we=>we.dir==="out")&&ue.some(we=>M.has(we.id))}))continue;const oe=f(xe);if(!oe||G.has(oe.id)||(oe.children??[]).some($e=>$e.type==="bpmn:Lane"))continue;const Me=(Hx=ce.get("T"))!=null&&Hx.length?(zx=ce.get("B"))!=null&&zx.length?void 0:"B":"T";if(!Me||(Me==="T"?xe.y-oe.y:oe.y+oe.height-(xe.y+xe.height))>=k)continue;const ve=(oe.children??[]).filter($e=>!("waypoints"in $e&&$e.waypoints)&&$e.type!=="label"&&typeof $e.x=="number"),ot=oe.y+oe.height;n.resizeShape(oe,{x:oe.x,y:oe.y,width:oe.width,height:oe.height+k});const Ce=u().children.filter($e=>!("waypoints"in $e&&$e.waypoints)&&$e.id!==oe.id&&typeof $e.y=="number"&&$e.y>=ot);Ce.length&&n.moveElements(Ce,{x:0,y:k}),Me==="T"&&ve.length&&n.moveElements(ve,{x:0,y:k}),G.add(oe.id)}}const Pr=20,wn=30,ri=4,Jn=2,Wt=[10,30,80],qi=w=>!("waypoints"in w&&w.waypoints)&&w.type!=="bpmn:Lane"&&w.type!=="label"&&typeof w.x=="number",Yi=()=>{const w=wt(o);return{bad:Ti(w).filter(R=>R.kind==="edge-crosses-shape"||R.kind==="edge-overlap-opposite"||R.kind==="edge-overlap-mixed").length,crossings:Id(w),straight:w.edges.filter(R=>R.type==="bpmn:MessageFlow"&&R.waypoints.length===2).length}},an=w=>{const R=wt(o),M=R.edges.find(F=>F.id===w);return M?Fn(M,ci(R)).length:0},Ke=w=>an(w)>0,nt=w=>wt(o).edges.filter(R=>R.type==="bpmn:MessageFlow"&&R.id!==w&&R.waypoints.length===2).length,Vf=(w,R)=>{const M=new Set(w.flatMap(I=>I.subtree.map(Y=>Y.id)));for(const I of w){const Y=(I.pool.children??[]).filter(qi).filter(W=>!M.has(W.id));if(I.subtree.some(W=>Y.some(ce=>W.x+R<ce.x+ce.width+wn&&W.x+R+W.width+wn>ce.x&&W.y<ce.y+ce.height&&W.y+W.height>ce.y)))return null}const F=w.map(I=>I.pool.width);n.moveElements(w.flatMap(I=>I.subtree),{x:R,y:0});const H=w.map(I=>{const G=Math.max(...I.subtree.map(W=>W.x+W.width))+150-(I.pool.x+I.pool.width);return G>0&&n.resizeShape(I.pool,{x:I.pool.x,y:I.pool.y,width:I.pool.width+G,height:I.pool.height}),G});return()=>{n.moveElements(w.flatMap(I=>I.subtree),{x:-R,y:0}),w.forEach((I,Y)=>{H[Y]>0&&n.resizeShape(I.pool,{x:I.pool.x,y:I.pool.y,width:F[Y],height:I.pool.height})})}},MD=(w,R,M)=>Vf([{subtree:w,pool:R}],M),Px=(w,R)=>R.bad>w.bad||R.crossings>w.crossings&&R.straight<=w.straight&&R.bad>=w.bad,wu=(w,R)=>Px(w,R)||R.straight<w.straight,Eu=(w,R,M=()=>!0,F=Px)=>{const H=Yi(),I=Vf(w,R);if(!I)return!1;const Y=Yi();return F(H,Y)||!M()?(I(),!1):!0},Ax=(w,R,M,F=()=>!0)=>Eu([{subtree:w,pool:R}],M,F),Zr=w=>{var R;return!!((R=C.get(w))!=null&&R.node.participant)},Ka=new Map;for(const w of S){if(!Zr(w.flow.target))continue;const R=Ka.get(w.flow.target)??[];R.push(w),Ka.set(w.flow.target,R)}const Wf=[...Ka.keys()],Tx=new Set(m.map(w=>w.flow.target)),Mx=w=>v.findIndex(({op:R})=>R.participant.id===w);Wf.sort((w,R)=>{var H,I;const M=Tx.has(w)?1:0,F=Tx.has(R)?1:0;return M!==F?M-F:Mx((H=C.get(w))==null?void 0:H.node.participant)-Mx((I=C.get(R))==null?void 0:I.node.participant)});const Qr=w=>w.x+w.width/2,kD=w=>{const R=new Map;for(const H of o.getAll()){const I=H;if(!I.waypoints||!I.source||!I.target)continue;(R.get(I.source.id)??R.set(I.source.id,[]).get(I.source.id)).push(I.target.id)}const M=new Set([w]),F=[w];for(let H=0;H<F.length;H++)for(const I of R.get(F[H])??[])M.has(I)||(M.add(I),F.push(I));return M},OD=(w,R)=>{const M=kD(R);let F;for(const H of o.getAll()){const I=H;if(I.type!=="bpmn:MessageFlow"||!I.source||!I.target||I.target.id!==w||M.has(I.source.id))continue;const Y=I.source;if(typeof Y.x!="number"||Y.type==="bpmn:Participant")continue;const G=Qr(Y);(F===void 0||G>F)&&(F=G)}return F},Uf=(w,R)=>{const M=l(w.flow.source);if(M)return M.type==="bpmn:Participant"?OD(M.id,R):Qr(M)},kx=w=>{let R;for(const M of Ka.get(w)??[]){const F=Uf(M,w);F!==void 0&&(!R||F>R.cx)&&(R={op:M,cx:F})}return R==null?void 0:R.op},DD=w=>{const R=kx(w),M=l(w),F=R?Uf(R,w):void 0;return M&&F!==void 0?F-Qr(M):void 0},LD=w=>{const R=DD(w);return R!==void 0&&Math.abs(R)<Pr},Ox=(w,R,M,F,H)=>{var I;for(let Y=!0;Y;){Y=!1;for(const G of S){if(G.flow.id===M)continue;const W=R.has(G.flow.source),ce=R.has(G.flow.target);if(W===ce||F(W?G.flow.source:G.flow.target))continue;const xe=W?G.flow.target:G.flow.source;if(H(xe)||!Zr(xe))continue;const Re=l(G.flow.id);if(!(Re!=null&&Re.waypoints)||Re.waypoints.length!==2)continue;const oe=l(xe),Me=(I=C.get(xe))==null?void 0:I.node.participant;if(!oe||!Me)continue;const pe=Pt(xe,ve=>ve.x>=oe.x).filter(ve=>!R.has(ve.id));if(!(!pe.length||pe.some(ve=>H(ve.id)))){for(const ve of pe)R.add(ve.id);w.set(Me,[...w.get(Me)??[],...pe]),Y=!0}}}return[...w].map(([Y,G])=>({subtree:G,pool:p(Y)}))},Dx=(w,R,M,F,H)=>Ox(new Map([[R,[...w]]]),new Set(w.map(I=>I.id)),F,I=>I===M,I=>I===H),qf=w=>{const R=kx(w);if(!R)return null;const M=l(w),F=l(R.flow.source),H=Uf(R,w);if(!M||!F||H===void 0)return null;const I=H-Qr(M);if(I>=Pr){const Y=C.get(w).node.participant,G=Pt(w,W=>W.x>=M.x);return{groups:Dx(G,Y,w,R.flow.id,R.flow.source),dx:I}}if(-I>=Pr&&Zr(R.flow.source)){const Y=C.get(R.flow.source).node.participant,G=Pt(R.flow.source,W=>W.x>=F.x&&!LD(W.id));return{groups:Dx(G,Y,R.flow.source,R.flow.id,w),dx:-I}}return null},Lx=()=>Wf.map(w=>({id:w,plan:qf(w)})).filter(w=>!!w.plan).sort((w,R)=>Math.min(...w.plan.groups.flatMap(M=>M.subtree.map(F=>F.x)))-Math.min(...R.plan.groups.flatMap(M=>M.subtree.map(F=>F.x)))).map(w=>w.id);for(let w=0;w<3;w++){const R=Yi(),M=[];for(const H of Lx()){const I=qf(H);if(!I)continue;const Y=Vf(I.groups,I.dx);Y&&M.push(Y)}if(!M.length)break;if(!wu(R,Yi()))continue;for(const H of M.reverse())H();let F=!1;for(const H of Lx()){const I=qf(H);I&&Eu(I.groups,I.dx,()=>!0,wu)&&(F=!0)}if(!F)break}for(const w of Wf.flatMap(R=>Ka.get(R)??[])){if(!Ke(w.flow.id))continue;const R=l(w.flow.target);if(!R)continue;const M=p(C.get(w.flow.target).node.participant),F=Pt(w.flow.target,G=>G.x>=R.x),H=R.width+O,I=an(w.flow.id),Y=nt(w.flow.id);for(let G=1;G<=ri;G++){const W=()=>an(w.flow.id)<I&&nt(w.flow.id)>=Y;if(Ax(F,M,H*G,W))break}}for(const w of S){if(!Ke(w.flow.id))continue;const R=l(w.flow.source),M=l(w.flow.target);if(!R||!M||R.type==="bpmn:Participant"||M.type==="bpmn:Participant")continue;const F=R.x+R.width/2;if(Math.abs(F-(M.x+M.width/2))>15)continue;const[H,I]=R.y<M.y?[R.y+R.height,M.y]:[M.y+M.height,R.y],Y=[...C.values()].map(G=>l(G.node.id)).filter(G=>!!G&&G.id!==R.id&&G.id!==M.id).filter(G=>G.x<=F&&F<=G.x+G.width&&G.y+G.height>H&&G.y<I).sort((G,W)=>G.x-W.x);for(const G of Y){const W=(Gx=C.get(G.id))==null?void 0:Gx.node.participant,ce=W?l(W):void 0;if(!ce)continue;const xe=[...C.values()].filter(ue=>ue.node.participant===W).map(ue=>ue.node.id),Re=ue=>ue.map(we=>l(we)).filter(we=>!!we),Me=[vn(G.id,ue=>{var we;return((we=C.get(ue.id))==null?void 0:we.node.participant)===W}),Re(xe)].filter(ue=>ue.length),pe=G.width+O,ve=an(w.flow.id),ot=nt(w.flow.id),Ce=()=>an(w.flow.id)<ve&&nt(w.flow.id)>=ot;let $e=!1;for(const ue of Me){for(let we=1;we<=ri;we++)if(Ax(ue,ce,pe*we,Ce)){$e=!0;break}if($e)break}if(!Ke(w.flow.id))break}}for(const w of S){if(!Ke(w.flow.id))continue;const R=l(w.flow.id);if(((Vx=R==null?void 0:R.waypoints)==null?void 0:Vx.length)!==2)continue;const M=l(w.flow.source),F=l(w.flow.target);if(!M||!F||M.type==="bpmn:Participant"||F.type==="bpmn:Participant"||!Zr(w.flow.source)||!Zr(w.flow.target)||Math.abs(Qr(M)-Qr(F))>Jn)continue;const H=Qr(M),I=R.waypoints.map(ve=>ve.y),[Y,G]=[Math.min(...I),Math.max(...I)],W=ci(wt(o)).filter(ve=>ve.id!==M.id&&ve.id!==F.id&&ve.x<H&&H<ve.x+ve.width&&Y<ve.y+ve.height&&ve.y<G);if(!W.length)continue;const ce=(Wx=C.get(w.flow.source))==null?void 0:Wx.node.participant,xe=(Ux=C.get(w.flow.target))==null?void 0:Ux.node.participant;if(!ce||!xe)continue;const Re=new Map;for(const[ve,ot,Ce]of[[w.flow.source,M,ce],[w.flow.target,F,xe]]){const $e=Re.get(Ce)??[],ue=Pt(ve,we=>we.x>=ot.x).filter(we=>!$e.some(Ne=>Ne.id===we.id));Re.set(Ce,[...$e,...ue])}const oe=new Set([...Re.values()].flat().map(ve=>ve.id)),Me=Ox(Re,oe,w.flow.id,ve=>ve===w.flow.source||ve===w.flow.target,()=>!1),pe=Math.max(...W.map(ve=>ve.x+ve.width));for(const ve of Wt){const ot=pe+ve-H;if(ot<=0)continue;if(Eu(Me,ot,()=>{var $e,ue;return an(w.flow.id)===0&&((ue=($e=l(w.flow.id))==null?void 0:$e.waypoints)==null?void 0:ue.length)===2},wu))break}}{const w=M=>M.y+M.height/2,R=[];for(const M of C.keys()){if(!Zr(M))continue;const F=m.filter(Y=>Y.flow.target===M);if(F.length!==1)continue;const H=l(F[0].flow.source),I=l(M);!H||!I||!C.has(H.id)||Math.abs(w(H)-w(I))>1||I.x-(H.x+H.width)<=O+1||R.push({id:M,pred:H,node:I})}R.sort((M,F)=>M.node.x-F.node.x);for(const{id:M}of R){const F=C.get(M),H=l(M),I=l(m.find(oe=>oe.flow.target===M).flow.source);if(!H||!I)continue;const Y=H.x-(I.x+I.width);if(Y<=O+1)continue;const G=p(F.node.participant),W=Pt(M,oe=>oe.x>=H.x),ce=Yi(),xe=MD(W,G,-(Y-O));if(!xe)continue;const Re=Yi();(Re.bad>ce.bad||Re.crossings>=ce.crossings||Re.straight<ce.straight)&&xe()}}dn(!0);for(const w of y){const R=w.associations??[],M=R.map(I=>I.source===w.dataStore.id?I.target:I.source).map(l).find(Boolean),F=M?f(M)??u():u(),H=M?{x:M.x+M.width/2,y:M.y+M.height+110}:{x:200,y:N+60};n.createShape({type:"bpmn:DataStoreReference",businessObject:i.create("bpmn:DataStoreReference",{id:w.dataStore.id,name:w.dataStore.name})},H,F);for(const I of R)pt(w.dataStore.id,I)}for(const w of _){const M=p(w.association.target).type==="bpmn:DataStoreReference"?w.association.target:w.association.source;pt(M,w.association)}let Ix=0;const Su=10,ID=(w,R)=>{for(const M of R.map(F=>f(F)).filter(F=>!!F)){const F=Su,H=M.y,I=M.y+M.height,Y=M.x,G=M.x+M.width;if(Math.abs(w.y-H)<F){const W=H+F-w.y;w.y+=W,w.height-=W}if(Math.abs(w.y+w.height-I)<F&&(w.height=I-F-w.y),Math.abs(w.x-Y)<F){const W=Y+F-w.x;w.x+=W,w.width-=W}Math.abs(w.x+w.width-G)<F&&(w.width=G-F-w.x)}},BD=(w,R)=>{const M=Su,F=30,H=o.filter(I=>I.type==="bpmn:Group"&&I.id!==R);for(const I of H){const Y=I.x,G=I.x+I.width,W=I.y,ce=I.y+I.height,xe=w.y<ce&&W<w.y+w.height,Re=w.x<G&&Y<w.x+w.width;if(xe){if(Math.abs(w.x-G)<M){const oe=Math.min(G+M-w.x,F);oe>0&&w.width-oe>0&&(w.x+=oe,w.width-=oe)}if(Math.abs(w.x+w.width-Y)<M){const oe=Math.min(w.x+w.width-(Y-M),F);oe>0&&w.width-oe>0&&(w.width-=oe)}}if(Re){if(Math.abs(w.y-ce)<M){const oe=Math.min(ce+M-w.y,F);oe>0&&w.height-oe>0&&(w.y+=oe,w.height-=oe)}if(Math.abs(w.y+w.height-W)<M){const oe=Math.min(w.y+w.height-(W-M),F);oe>0&&w.height-oe>0&&(w.height-=oe)}}}},Yf=(w,R)=>{const F=Math.min(...w.map(W=>W.x))-40,H=Math.min(...w.map(W=>W.y))-40,I=Math.max(...w.map(W=>W.x+W.width))+40,Y=Math.max(...w.map(W=>W.y+W.height))+40,G={x:F,y:H,width:I-F,height:Y-H};return ID(G,w),BD(G,R),G};for(const w of P){const R=(w.group.members??[]).map(l).filter(H=>!!H);let M;R.length?M=Yf(R,w.group.id):(M={x:300+Ix*350,y:40,width:300,height:200},Ix++);const F=n.createShape({type:"bpmn:Group",businessObject:i.create("bpmn:Group",{id:w.group.id}),width:M.width,height:M.height},{x:M.x+M.width/2,y:M.y+M.height/2},u());w.group.name&&n.updateLabel(F,w.group.name),(qx=w.group.members)!=null&&qx.length&&D(F,"bwl:Members",{refs:w.group.members.join(" ")})}{const w=o.filter(H=>!!H.waypoints),R=new Map,M=(H,I)=>{!H||!I||(R.has(H)||R.set(H,new Set),R.get(H).add(I))};for(const H of w){const I=(Yx=H.source)==null?void 0:Yx.id,Y=(Kx=H.target)==null?void 0:Kx.id;M(I,Y),((Xx=H.type)!=null&&Xx.includes("DataOutputAssociation")||(Zx=H.type)!=null&&Zx.includes("DataInputAssociation")||H.type==="bpmn:Association")&&M(Y,I)}const F=o.filter(H=>H.type==="bpmn:Group");for(const H of F){const Y=(((Qx=H.businessObject.extensionElements)==null?void 0:Qx.values)??[]).find(Ce=>Ce.$type==="bwl:Members"),G=((Y==null?void 0:Y.refs)??"").split(" ").filter(Boolean);if(!G.length)continue;const W=new Set(G),ce=[...G];for(;ce.length;){const Ce=ce.shift();for(const $e of R.get(Ce)??[])W.has($e)||(W.add($e),ce.push($e))}const xe=H.x,Re=H.x+H.width,oe=H.y,Me=H.y+H.height,pe=Ce=>m.filter($e=>$e.flow.target===Ce).length,ve=Ce=>{var ue;const $e=((ue=l(Ce))==null?void 0:ue.type)??"";if($e==="bpmn:StartEvent"&&pe(Ce)===0)return!1;if($e.endsWith("Gateway")){const we=m.filter(Ne=>Ne.flow.target===Ce).map(Ne=>Ne.flow.source);if(we.length&&we.every(Ne=>{var it;return((it=l(Ne))==null?void 0:it.type)==="bpmn:StartEvent"&&pe(Ne)===0}))return!1}return!0},ot=o.filter(Ce=>qi(Ce)).filter(Ce=>Ce.type!=="bpmn:Group"&&Ce.type!=="bpmn:Participant"&&Ce.type!=="bpmn:TextAnnotation"&&!W.has(Ce.id)&&Zr(Ce.id)&&ve(Ce.id)&&Ce.x<Re&&Ce.x+Ce.width>xe&&Ce.y<Me&&Ce.y+Ce.height>oe);if(ot.length)for(const Ce of[-1,1]){const $e=ot.filter(X=>(X.x+X.width-xe<=Re-X.x?-1:1)===Ce);if(!$e.length)continue;const ue=[];for(const X of $e){const te=ue.find(ae=>ae.some(be=>X.y<be.y+be.height&&X.y+X.height>be.y));te?te.push(X):ue.push([X])}const we=new Map;for(const X of ue){let te=Ce<0?xe-Su:Re+Su;for(const ae of[...X].sort((be,Je)=>Ce<0?Je.x-be.x:be.x-Je.x)){const be=Ce<0?Math.min(ae.x,te-ae.width):Math.max(ae.x,te);te=Ce<0?be-wn:be+ae.width+wn,be!==ae.x&&Math.sign(be-ae.x)===Ce&&we.set(ae.id,be-ae.x)}}const Ne=new Map,it=X=>Ne.get(X)===X||!Ne.get(X)?X:it(Ne.get(X));for(const X of $e)Ne.set(X.id,X.id);for(const X of S){const te=we.has(X.flow.source)?X.flow.source:void 0,ae=we.has(X.flow.target)?X.flow.target:void 0;if(!te||!ae)continue;const be=l(X.flow.id);((Jx=be==null?void 0:be.waypoints)==null?void 0:Jx.length)===2&&Ne.set(it(te),it(ae))}const dt=new Map;for(const X of $e){if(!we.has(X.id))continue;const te=it(X.id);dt.set(te,[...dt.get(te)??[],X])}const et=[...dt.values()].sort((X,te)=>Ce<0?Math.min(...X.map(ae=>ae.x))-Math.min(...te.map(ae=>ae.x)):Math.max(...te.map(ae=>ae.x))-Math.max(...X.map(ae=>ae.x))),Ut=[];let Jt=!0;for(const X of et){const te=X.map(Je=>we.get(Je.id)??0).reduce((Je,Ge)=>Math.abs(Ge)>Math.abs(Je)?Ge:Je,0),ae=new Map;let be=!0;for(const Je of X){const Ge=f(Je);if(!Ge){be=!1;break}ae.has(Ge.id)||ae.set(Ge.id,{subtree:[],pool:Ge}),ae.get(Ge.id).subtree.push(Je)}be&&Eu([...ae.values()],te,()=>!0,wu)?Ut.push({shapes:X,dx:te}):Jt=!1}if(!Jt)for(const X of Ut.reverse())n.moveElements(X.shapes,{x:-X.dx,y:0})}}}{const w=new Set([...P.map(R=>R.group.id),...Xt(e,"group.update").map(R=>R.id)]);for(const R of o.filter(M=>M.type==="bpmn:Group")){if(w.has(R.id))continue;const F=(((e0=R.businessObject.extensionElements)==null?void 0:e0.values)??[]).find(G=>G.$type==="bwl:Members"),H=((F==null?void 0:F.refs)??"").split(" ").filter(Boolean).map(l).filter(G=>!!G);!H.length||!H.some(G=>{const W=d.get(G.id);return!W||W.x!==G.x||W.y!==G.y})||!H.some(G=>G.x<R.x||G.y<R.y||G.x+G.width>R.x+R.width||G.y+G.height>R.y+R.height)||n.resizeShape(R,Yf(H,R.id))}}{const R=new Map(uo(wt(o)).map(G=>[G.owner,G.rect])),M=o.filter(G=>!!G.waypoints),F=new Map,H=(G,W)=>{!G||!W||(F.has(G)||F.set(G,new Set),F.get(G).add(W))};for(const G of M){const W=(t0=G.source)==null?void 0:t0.id,ce=(n0=G.target)==null?void 0:n0.id;H(W,ce),((i0=G.type)!=null&&i0.includes("DataOutputAssociation")||(r0=G.type)!=null&&r0.includes("DataInputAssociation")||G.type==="bpmn:Association")&&H(ce,W)}const I=G=>m.filter(W=>W.flow.target===G).length,Y=G=>{var ce;const W=((ce=l(G))==null?void 0:ce.type)??"";if(W==="bpmn:StartEvent"&&I(G)===0)return!1;if(W.endsWith("Gateway")){const xe=m.filter(Re=>Re.flow.target===G).map(Re=>Re.flow.source);if(xe.length&&xe.every(Re=>{var oe;return((oe=l(Re))==null?void 0:oe.type)==="bpmn:StartEvent"&&I(Re)===0}))return!1}return!0};for(const G of o.filter(W=>W.type==="bpmn:Group")){const ce=(((o0=G.businessObject.extensionElements)==null?void 0:o0.values)??[]).find(te=>te.$type==="bwl:Members"),xe=((ce==null?void 0:ce.refs)??"").split(" ").filter(Boolean);if(!xe.length)continue;const Re=xe.map(l).filter(te=>!!te);if(!Re.length||!(P.some(te=>te.group.id===G.id)||Xt(e,"group.update").some(te=>te.id===G.id)||Re.some(te=>{const ae=d.get(te.id);return!ae||ae.x!==te.x||ae.y!==te.y})))continue;const Me=new Set(xe),pe=[...xe];for(;pe.length;){const te=pe.shift();for(const ae of F.get(te)??[])Me.has(ae)||(Me.add(ae),pe.push(ae))}const ve=G.x,ot=G.x+G.width,Ce=G.y,$e=G.y+G.height,ue=te=>{const ae=R.get(te.id),be={x:te.x,y:te.y,width:te.width,height:te.height};return ae?[be,{x:ae.x,y:ae.y,width:ae.width,height:ae.height}]:[be]},we=Re.flatMap(ue),Ne=Math.min(...we.map(te=>te.x)),it=Math.max(...we.map(te=>te.x+te.width)),dt=Math.min(...we.map(te=>te.y)),et=Math.max(...we.map(te=>te.y+te.height)),Ut={L:Ne-ve,R:ot-it,T:dt-Ce,B:$e-et},Jt=o.filter(te=>qi(te)).filter(te=>te.type!=="bpmn:Group"&&te.type!=="bpmn:Participant"&&te.type!=="bpmn:TextAnnotation"&&!Me.has(te.id)&&Y(te.id)&&te.x<ot&&te.x+te.width>ve&&te.y<$e&&te.y+te.height>Ce);if(!Jt.length)continue;const X={L:0,R:0,T:0,B:0};for(const te of Jt){const ae=ue(te),be=Math.min(...ae.map(At=>At.x)),Je=Math.max(...ae.map(At=>At.x+At.width)),Ge=Math.min(...ae.map(At=>At.y)),ke=Math.max(...ae.map(At=>At.y+At.height)),Ve={L:Je-ve,R:ot-be,T:ke-Ce,B:$e-Ge},tt=["L","R","T","B"].filter(At=>Ve[At]<=Ut[At]+.001);if(!tt.length)continue;const qt=tt.reduce((At,$t)=>Ve[$t]<Ve[At]?$t:At,tt[0]);X[qt]=Math.max(X[qt],Math.min(Ve[qt]+10,Ut[qt]))}!X.L&&!X.R&&!X.T&&!X.B||n.resizeShape(G,{x:G.x+X.L,y:G.y+X.T,width:G.width-X.L-X.R,height:G.height-X.T-X.B})}}const Bx=w=>{const R=w.waypoints;if(R!=null&&R.length){const F=R[Math.floor((R.length-1)/2)];return{x:F.x,y:F.y,width:0,height:0}}const M=w;return{x:M.x,y:M.y,width:M.width,height:M.height}};let Xa=0;const Nx=12,$x=14,ND=15,$D=300,jD=w=>{const R=w.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 lw(e){e=j({format:!1,preamble:!0},e||{});function t(n,i){var r=i||new cw,o=new uw(r,e.format);e.preamble&&o.append(Y0);var a=new mt,s=n.$model;if(a.getNamespaces().mapDefaultPrefixes(pw(s)),a.build(n).serializeTo(o),!i)return r.value}return{toXML:t}}function pw(e){const t=e.config&&e.config.nsMap||{},n={};for(const i in Bu)n[i]=Bu[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 is(e,t){jn.call(this,e,t)}is.prototype=Object.create(jn.prototype),is.prototype.fromXML=function(e,t,n){En(t)||(n=t,t="bpmn:Definitions");var i=new Fu(j({model:this,lax:!0},n)),r=i.handler(t);return i.fromXML(e,r)},is.prototype.toXML=function(e,t){var n=new lw(t);return new Promise(function(i,r){try{var o=n.toXML(e);return i({xml:o})}catch(a){return r(a)}})};var fw="BPMN20",dw="http://www.omg.org/spec/BPMN/20100524/MODEL",hw="bpmn",mw=[],gw=[{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"}]}],yw=[{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"}]}],vw={tagAlias:"lowerCase",typePrefix:"t"},bw={name:fw,uri:dw,prefix:hw,associations:mw,types:gw,enumerations:yw,xml:vw},_w="BPMNDI",xw="http://www.omg.org/spec/BPMN/20100524/DI",ww="bpmndi",Ew=[{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"]}],Sw=[{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"}]}],Rw=[],Cw={name:_w,uri:xw,prefix:ww,types:Ew,enumerations:Sw,associations:Rw},Pw="DC",Aw="http://www.omg.org/spec/DD/20100524/DC",Tw="dc",Mw=[{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}]}],kw=[],Ow={name:Pw,uri:Aw,prefix:Tw,types:Mw,associations:kw},Dw="DI",Lw="http://www.omg.org/spec/DD/20100524/DI",Iw="di",Bw=[{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"}]}],Nw=[],$w={tagAlias:"lowerCase"},jw={name:Dw,uri:Lw,prefix:Iw,types:Bw,associations:Nw,xml:$w},Fw="bpmn.io colors for BPMN",Hw="http://bpmn.io/schema/bpmn/biocolor/1.0",zw="bioc",Gw=[{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"}]}],Vw=[],Ww=[],Uw={name:Fw,uri:Hw,prefix:zw,types:Gw,enumerations:Vw,associations:Ww},qw="BPMN in Color",Yw="http://www.omg.org/spec/BPMN/non-normative/color/1.0",Kw="color",Xw=[{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"}]}],Zw=[],Qw=[],Jw={name:qw,uri:Yw,prefix:Kw,types:Xw,enumerations:Zw,associations:Qw};const eE={bpmn:bw,bpmndi:Cw,dc:Ow,di:jw,bioc:Uw,color:Jw};function xd(e,t){const n=j({},eE,e);return new is(n,t)}const tE={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"}},nE="http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0",wd="i18n",rs={[wd]:tE,[Ru]:Zf};function Ed(){return xd(rs)}const Sd=Ed();async function Gu(e){const{rootElement:t,warnings:n}=await Sd.fromXML(e,"bpmn:Definitions");return{definitions:t,warnings:n}}async function iE(e){const{xml:t}=await Sd.toXML(e,{format:!0});return t}function Vu(e){return e.map(t=>typeof t=="string"?t:t.message??String(t))}const ao={cjkEm:.865,upperEm:.68,lowerEm:.5,digitEm:.556,spaceEm:.278,otherEm:.35,ascentEm:.9,descentEm:.25},rE=/[ᄀ-ᇿ -〿぀-ヿ㐀-鿿가-힯＀-⦆]/;function oE(e){const t=ao;return rE.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 so(e,t){let n=0;for(const i of e)n+=t*oE(i);return n}function Rd(e=globalThis,{textMeasurement:t="approximate"}={}){if(!(e!=null&&e.SVGElement))throw new Error("installHeadlessBpmnDom: DOM 전역이 없다 — jsdom window 를 전역에 올린 뒤 호출할 것");t==="approximate"&&aE(e),sE(e),cE(e),uE(e)}function aE(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:so(r,o),fontBoundingBoxAscent:o*ao.ascentEm,fontBoundingBoxDescent:o*ao.descentEm,actualBoundingBoxAscent:o*ao.ascentEm,actualBoundingBoxDescent:o*ao.descentEm}}};t.getContext=()=>n}function sE(e){if(e.SVGMatrix)return;class t{constructor(){Jr(this,"a",1);Jr(this,"b",0);Jr(this,"c",0);Jr(this,"d",1);Jr(this,"e",0);Jr(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 cE(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,u=0){const l=s*Math.PI/180,p=Math.cos(l),f=Math.sin(l);a.a=p,a.b=f,a.c=-f,a.d=p,a.e=c-p*c+f*u,a.f=u-f*c-p*u},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 uE(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:so(n,12),height:14}})}const os=new Set(["bpmn:Participant","bpmn:Lane","bpmn:Group","bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),lE=1,Wu=new Set(["bpmn:TextAnnotation","bpmn:DataStoreReference","bpmn:DataObjectReference","bpmn:DataInput","bpmn:DataOutput"]),pE=2;function Ri(e){switch(e.kind){case"label-over-line":return`L|${e.edge}|${e.line}`;case"edge-crosses-shape":return`x|${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"label-on-shared-segment":return`l|${e.edge}|${e.other}`;case"annotation-over-label":return`a|${e.annotation}|${e.label}`;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"pool-name-over-label":return`pn|${e.pool}|${e.label}`}}const Cd=20,as=5,Pd=3,fE=8,Ad=12,dE=Ad*1.2;function Uu(e,t){const n=t.split(/\r?\n/),i=Math.max(...n.map(o=>so(o,Ad))),r=n.length*dE;return{x:e.x+e.width/2-i/2,y:e.y+e.height/2-r/2,width:i,height:r}}const Td=1;function mn(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 ss(e,t){let n=null;const i=e.type!==t.type;for(const r of mn(e))for(const o of mn(t)){if(r.axis!==o.axis||Math.abs(r.at-o.at)>Td)continue;const a=r.dir!==o.dir?"opposite":i?"mixed":null;if(!a)continue;const s=Math.min(r.hi,o.hi)-Math.max(r.lo,o.lo);s>=Cd&&(!n||s>n.length)&&(n={axis:r.axis,length:s,kind:a})}return n}function Md(e,t){const n=ss(e,t);return n&&n.kind==="opposite"?{axis:n.axis,length:n.length}:null}function hE(e,t){let n=0;for(const i of t)i.id!==e.id&&Md(e,i)&&n++;return n}function Ci(e,t){let n=0;for(const i of t)i.id!==e.id&&ss(e,i)&&n++;return n}const kd=15,Od=20;function mE(e,t){const n=t.axis==="v"?[e.x,e.x+e.width]:[e.y,e.y+e.height];if(t.at<n[0]-Od||t.at>n[1]+Od)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 qu=20;function cs(e,t){const n=[];for(const i of t){if(i.axis!==e.axis||Math.abs(i.at-e.at)>Td)continue;const r=Math.max(e.lo,i.lo),o=Math.min(e.hi,i.hi);o-r<Cd||n.push([r-qu,o+qu])}return n}function us(e,t){const n=e.label;if(!n)return null;let i=null;for(const r of mn(e)){const o=mE(n,r);if(o){for(const a of t)if(a.id!==e.id&&!(i&&a.id>=i.other)){for(const[s,c]of cs(r,mn(a)))if(Math.min(c,o[1])>Math.max(s,o[0])){i={other:a.id,axis:r.axis};break}}}}return i}const gE=1,yE=(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 vE(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,u=t.y-e.y;let l=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>l&&(l=h)}else{if(h<l)return!1;h<p&&(p=h)}return!0};return f(r-e.x,c)&&f(e.x-a,-c)&&f(o-e.y,u)&&f(e.y-s,-u)&&p>l}function Yu(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 bE=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,co=1;function Pi(e,t){const n=e.x+co,i=e.x+e.width-co,r=e.y+co,o=e.y+e.height-co;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 Dd(e,t){const n=e.label;if(!n)return null;if(mn(e).some(i=>Pi(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(mn(i).some(r=>Pi(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=>Pi(n,r)))return i.id;return null}function Fn(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(vE(e.waypoints[o],e.waypoints[o+1],r,pE)){i.push(r);break}}return i}function _E(e,t,n,i){const r=(u,l,p)=>(l.x-u.x)*(p.y-u.y)-(l.y-u.y)*(p.x-u.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 Ld=(e,t)=>e.endpoints.some(n=>t.endpoints.includes(n));function ls(e,t){let n=0;for(const i of t){if(i.id===e.id||Ld(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++)_E(e.waypoints[o],e.waypoints[o+1],i.waypoints[a],i.waypoints[a+1])&&(r=!0);r&&n++}return n}function Ai(e,t){let n=0;for(const i of t)i.id===e.id||Ld(e,i)||ls(e,[i])>0&&(n+=i.type===e.type?2:1);return n}function Id(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++)ls(n[i],[n[r]])>0&&(t+=n[i].type===n[r].type?2:1);return t}function Ku(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)if(ls(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 Bd(e){const t=Ku(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),u=i.get(s);if(!c||!u)continue;const l=n(c.type),p=n(u.type);l==="solid"&&p==="solid"?r++:l==="dashed"&&p==="dashed"&&o++}return{pairs:t,solidPairs:r,dashedPairs:o,mixedPairs:t.length-r-o,crossPoolMessages:xE(e)}}function xE(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(u=>u.id!==o.id&&u.id!==a.id&&u.y>s&&u.y+u.height<c)&&i++}return i}function Nd(e,t,n){const i=new Set(t.flatMap(r=>[...r.members]));return e.shapes.filter(r=>!r.container&&!Wu.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 $d(e){var n;const t=(n=ht(e==null?void 0:e.extensionElements))==null?void 0:n.values;if(Array.isArray(t))for(const i of t){const r=ht(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 jd=e=>e?{members:e}:{},ci=e=>e.shapes.filter(t=>!t.container);function wE(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){if(o.container)return o.id;if(o.parent)return o.parent}}}function Fd(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(mn(i).some(r=>Pi(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=>Pi(n,r)))return i.id;return null}function uo(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}function Ti(e){const t=[],n=e.shapes.filter(h=>!h.container);for(const h of e.edges)for(const m of Fn(h,n))t.push({kind:"edge-crosses-shape",edge:h.id,shape:m.id});const i=n.filter(h=>!h.attached);for(let h=0;h<i.length;h++)for(let m=h+1;m<i.length;m++){const S=i[h],y=i[m];if(!Yu(S,y,lE))continue;const _=S.id<y.id?[S.id,y.id]:[y.id,S.id];t.push({kind:"shape-overlap",shapes:_,identical:bE(S,y)})}const r=e.shapes.filter(h=>h.type==="bpmn:Group"&&Array.isArray(h.members)&&h.members.length>0);for(let h=0;h<r.length;h++)for(let m=h+1;m<r.length;m++){const S=r[h],y=r[m],_=Math.min(S.x+S.width,y.x+y.width)-Math.max(S.x,y.x),E=Math.min(S.y+S.height,y.y+y.height)-Math.max(S.y,y.y);if(_<=as||E<=as)continue;const P=S.id<y.id?[S.id,y.id]:[y.id,S.id],C=new Set(y.members);if(S.members.some(A=>C.has(A))){const A=Nd(e,r,{x:Math.max(S.x,y.x),y:Math.max(S.y,y.y),right:Math.min(S.x+S.width,y.x+y.width),bottom:Math.min(S.y+S.height,y.y+y.height)});A.length&&t.push({kind:"group-overlap-unreadable",reason:"orphan",groups:P,shapes:A});continue}const D=S.x<=y.x&&S.y<=y.y&&S.x+S.width>=y.x+y.width&&S.y+S.height>=y.y+y.height?S.id:y.x<=S.x&&y.y<=S.y&&y.x+y.width>=S.x+S.width&&y.y+y.height>=S.y+S.height?y.id:void 0;t.push({kind:"group-overlap-unintended",groups:P,...D?{container:D}:{}})}const o=new Set(r.flatMap(h=>[...h.members])),a=h=>e.shapes.filter(m=>!m.container&&!Wu.has(m.type)&&m.x>=h.x&&m.y>=h.y&&m.x+m.width<=h.x+h.width&&m.y+m.height<=h.y+h.height);for(const h of r){const m=a(h);if(!m.length)continue;const S=new Set(h.members),y=m.filter(_=>!S.has(_.id));y.some(_=>o.has(_.id))&&(y.length*2<m.length||t.push({kind:"group-overlap-unreadable",reason:"minority",group:h.id,shapes:y.map(_=>_.id).sort()}))}for(const h of r){const m=new Set(a(h).map(C=>C.id)),S=new Set(h.members),y=new Set([...m].filter(C=>!S.has(C)&&o.has(C)));if(!y.size)continue;let _=!1,E=!1,P=!1;for(const C of e.edges){if(C.type!=="bpmn:SequenceFlow"||!C.source||!C.target)continue;const D=y.has(C.source),A=y.has(C.target);!D&&A&&!m.has(C.source)?_=!0:D&&!A&&!m.has(C.target)?E=!0:D&&A&&(P=!0)}_&&E&&P&&t.push({kind:"group-overlap-unreadable",reason:"throughpass",group:h.id,shapes:[...y].sort()})}const s=e.shapes.filter(h=>h.type==="bpmn:Group");for(let h=0;h<s.length;h++)for(let m=h+1;m<s.length;m++)for(let S=m+1;S<s.length;S++){const y=[s[h],s[m],s[S]],_={x:Math.max(...y.map(C=>C.x)),y:Math.max(...y.map(C=>C.y)),right:Math.min(...y.map(C=>C.x+C.width)),bottom:Math.min(...y.map(C=>C.y+C.height))};if(_.right-_.x<=as||_.bottom-_.y<=as)continue;const E=Nd(e,[],_);if(!E.length)continue;const P=y.map(C=>C.id).sort();t.push({kind:"group-stack-unreadable",groups:P,shapes:E})}for(const h of e.shapes.filter(m=>m.type==="bpmn:Group"))for(const m of e.shapes){if(m.container||m.attached||Wu.has(m.type)||m.width<=0||m.height<=0)continue;const S=[["top",h.y,"h",h.x,h.x+h.width],["bottom",h.y+h.height,"h",h.x,h.x+h.width],["left",h.x,"v",h.y,h.y+h.height],["right",h.x+h.width,"v",h.y,h.y+h.height]];for(const[y,_,E,P,C]of S){const D=E==="h"?m.x:m.y,A=E==="h"?m.x+m.width:m.y+m.height;if(!(D<C&&P<A))continue;const B=E==="h"?m.y:m.x,k=E==="h"?m.y+m.height:m.x+m.width;if(!(B<_&&_<k))continue;const O=Math.min(_-B,k-_);O<fE||t.push({kind:"group-cuts-shape",group:h.id,shape:m.id,side:y,depth:O})}}const c=e.shapes.filter(h=>h.container&&h.type!=="bpmn:Group"&&h.type!=="bpmn:Lane");for(const h of e.shapes.filter(m=>m.type==="bpmn:Group"))for(const m of c){const S=h.x<m.x+m.width&&m.x<h.x+h.width,y=h.y<m.y+m.height&&m.y<h.y+h.height,_=[["top",h.y,m.y,S],["bottom",h.y+h.height,m.y+m.height,S],["left",h.x,m.x,y],["right",h.x+h.width,m.x+m.width,y]];for(const[E,P,C,D]of _)D&&Math.abs(P-C)<=Pd&&t.push({kind:"group-on-container-boundary",group:h.id,container:m.id,side:E})}const u=e.shapes.filter(h=>h.type==="bpmn:Group");for(let h=0;h<u.length;h++)for(let m=h+1;m<u.length;m++){const S=u[h],y=u[m],_=S.x<y.x+y.width&&y.x<S.x+S.width,E=S.y<y.y+y.height&&y.y<S.y+S.height,P=[["x",S.x+S.width,y.x,E],["x",y.x+y.width,S.x,E],["y",S.y+S.height,y.y,_],["y",y.y+y.height,S.y,_]];for(const[C,D,A,B]of P)if(B&&Math.abs(D-A)<=Pd){t.push({kind:"group-on-group-boundary",groups:S.id<y.id?[S.id,y.id]:[y.id,S.id],axis:C});break}}for(let h=0;h<e.edges.length;h++)for(let m=h+1;m<e.edges.length;m++){const S=e.edges[h],y=e.edges[m],_=ss(S,y);if(!_)continue;const E=S.id<y.id?[S.id,y.id]:[y.id,S.id];t.push({kind:_.kind==="opposite"?"edge-overlap-opposite":"edge-overlap-mixed",edges:E,axis:_.axis,length:Math.round(_.length)})}for(const h of e.edges){if(!h.label)continue;const m=us(h,e.edges);m&&t.push({kind:"label-on-shared-segment",edge:h.id,other:m.other,axis:m.axis})}for(const h of e.edges){if(!h.label)continue;const m=Dd(h,e);m&&t.push({kind:"label-over-line",edge:h.id,line:m})}const l=new Set(n.map(h=>h.id)),p=e.shapes.filter(h=>h.type==="bpmn:Participant"&&h.label);for(const h of[...n,...p.filter(m=>!l.has(m.id))]){if(!h.label)continue;const m=Fd(h,e);m&&t.push({kind:"label-over-line",edge:h.id,line:m})}const f=new Set(e.shapes.filter(h=>h.type==="bpmn:TextAnnotation").map(h=>h.id));for(const h of p)for(const{owner:m,rect:S}of uo(e))m===h.id||f.has(m)||Yu(h.label,S,co)&&t.push({kind:"pool-name-over-label",pool:h.id,label:m});const d=uo(e);for(const h of n)if(h.type==="bpmn:TextAnnotation")for(const{owner:m,rect:S}of d)m!==h.id&&Yu(h,S,co)&&t.push({kind:"annotation-over-label",annotation:h.id,label:m});const g=new Map(e.shapes.map(h=>[h.id,h]));for(const h of n){const m=h.parent??wE(h,e,g);if(!m)continue;const S=g.get(m);!S||!S.container||yE(S,h,gE)||t.push({kind:"shape-outside-container",shape:h.id,container:S.id})}return t.sort((h,m)=>Ri(h).localeCompare(Ri(m)))}const ht=e=>typeof e=="object"&&e!==null?e:void 0,xt=e=>typeof e=="number"?e:0,Mi=e=>{const t=ht(e);return typeof(t==null?void 0:t.id)=="string"?t.id:void 0};function EE(e){const t=ht(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=Mi(o);a&&n.push(a)}}return n}function SE(e){const t=ht(e);if(!t)return{};const n=Array.isArray(t.sourceRef)?void 0:Mi(t.sourceRef),i=Array.isArray(t.targetRef)?void 0:Mi(t.targetRef);return n&&i?{source:n,target:i}:{}}function RE(e,t){const n=ht(e.$parent);if(!n)return;const i=typeof n.$type=="string"?n.$type:"";if(i==="bpmn:Process"){const r=Mi(n);return r?t.get(r):void 0}if(os.has(i)&&i!=="bpmn:Lane"&&i!=="bpmn:Group")return Mi(n)}function Hd(e){var a,s,c,u,l;const t=[],n=[],i=((a=ht(e))==null?void 0:a.diagrams)??[],r=new Map,o=new Set;for(const p of((s=ht(e))==null?void 0:s.rootElements)??[]){const f=ht(p);if((f==null?void 0:f.$type)==="bpmn:Collaboration")for(const d of f.participants??[]){const g=ht(d),h=Mi(g),m=Mi(g==null?void 0:g.processRef);h&&m?r.set(m,h):h&&o.add(h)}}for(const p of i){const f=ht((c=ht(p))==null?void 0:c.plane),d=(f==null?void 0:f.planeElement)??[];for(const g of d){const h=ht(g);if(!h)continue;const m=ht(h.bpmnElement),S=typeof(m==null?void 0:m.id)=="string"?m.id:void 0;if(!S)continue;const y=typeof(m==null?void 0:m.$type)=="string"?m.$type:"",_=ht(h.bounds);if(_){const P=h.isExpanded===!1&&y!=="bpmn:Participant",C=ht((u=ht(h.label))==null?void 0:u.bounds),D={id:S,type:y,x:xt(_.x),y:xt(_.y),width:xt(_.width),height:xt(_.height),container:os.has(y)&&!P,attached:(m==null?void 0:m.attachedToRef)!==void 0,...m?{parent:RE(m,r)}:{},...C?{label:{x:xt(C.x),y:xt(C.y),width:xt(C.width),height:xt(C.height)}}:{},...y==="bpmn:Group"?jd($d(m)):{}},A=h.isHorizontal!==!1,B=typeof(m==null?void 0:m.name)=="string"?m.name:"";o.has(S)&&A&&B&&(D.label=Uu(D,B)),t.push(D);continue}const E=h.waypoint;if(Array.isArray(E)){const P=ht((l=ht(h.label))==null?void 0:l.bounds);n.push({id:S,type:y,waypoints:E.map(C=>{var D,A;return{x:xt((D=ht(C))==null?void 0:D.x),y:xt((A=ht(C))==null?void 0:A.y)}}),endpoints:EE(m),...SE(m),...P?{label:{x:xt(P.x),y:xt(P.y),width:xt(P.width),height:xt(P.height)}}:{}})}}}return{shapes:t,edges:n}}function zd(e){return Ti(Hd(e))}async function CE(e){const{definitions:t,warnings:n}=await Gu(e);return{findings:zd(t),warnings:n}}function wt(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=ht(o.label),m=Mi(o.source),S=Mi(o.target);n.push({id:o.id,type:a,waypoints:s.map(y=>({x:xt(y.x),y:xt(y.y)})),endpoints:[m,S].filter(y=>!!y),...m&&S?{source:m,target:S}:{},...h&&typeof h.x=="number"?{label:{x:h.x,y:xt(h.y),width:xt(h.width),height:xt(h.height)}}:{}});continue}if(typeof o.x!="number"||typeof o.y!="number")continue;const c=ht(o.businessObject),u=ht(o.label);let l=ht(o.parent);for(;l&&l.type==="bpmn:Lane";)l=ht(l.parent);const p=typeof(l==null?void 0:l.type)=="string"?l.type:"",f=l&&os.has(p)&&p!=="bpmn:Group"&&typeof l.id=="string"?l.id:void 0,d={id:o.id,type:a,x:o.x,y:o.y,width:xt(o.width),height:xt(o.height),container:os.has(a)&&(a==="bpmn:Participant"||o.collapsed!==!0),attached:(c==null?void 0:c.attachedToRef)!==void 0,...f!==void 0?{parent:f}:{},...u&&typeof u.x=="number"?{label:{x:u.x,y:xt(u.y),width:xt(u.width),height:xt(u.height)}}:{},...a==="bpmn:Group"?jd($d(c)):{}},g=typeof(c==null?void 0:c.name)=="string"?c.name:"";a==="bpmn:Participant"&&!(c!=null&&c.processRef)&&g&&((i=ht(o.di))==null?void 0:i.isHorizontal)!==!1&&(d.label=Uu(d,g)),t.push(d)}return{shapes:t,edges:n}}const PE={"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 AE(e,t){const n=PE[e];return n||(e==="label"||e.startsWith("bpmndi:")?"other":e.startsWith("bpmn:")&&!("waypoints"in t&&t.waypoints)?"flowNode":"other")}function Gd(e){let t=e.parent;for(;t;){if(t.type==="bpmn:Participant")return t.id;t=t.parent}}function Vd(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 AE(i.type,i)},lanesOf:n=>t().filter(i=>i.type==="bpmn:Lane"&&Gd(i)===n).sort((i,r)=>i.y-r.y).map(i=>i.id),participantOf:n=>{const i=e.get(n);return i?Gd(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}}}}const Wd=20,TE=4,Mt=(e,t)=>Math.abs(e-t)<.5;function Ud(e,t,n,i=Wd){if(Mt(e.y,t.y)&&!Mt(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=u=>[{x:a,y:e.y},{x:a,y:u},{x:s,y:u},{x:s,y:e.y}];return[c(n.y-i),c(n.y+n.height+i)]}if(Mt(e.x,t.x)&&!Mt(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=u=>[{x:e.x,y:a},{x:u,y:a},{x:u,y:s},{x:e.x,y:s}];return[c(n.x-i),c(n.x+n.width+i)]}return null}function qd(e,t,n=Wd){if(e.length!==4)return null;const[i,r,o,a]=e;if(Mt(i.y,r.y)&&Mt(r.x,o.x)&&Mt(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(Mt(i.x,r.x)&&Mt(r.y,o.y)&&Mt(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 Xu(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,u=[{x:n.x+n.width,y:r},{x:a,y:r},{x:a,y:c?i.y+i.height:i.y}],l=[{x:s,y:c?n.y:n.y+n.height},{x:s,y:o},{x:i.x,y:o}];return[u,l]}const Yd=30,ME=[0,-25,25,-40,40];function kE(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+Yd:s-Yd,u=a?i.y+i.height:i.y,l=n.x+n.width/2,p=i.x+i.width/2;return ME.map(f=>[{x:l,y:s},{x:l,y:c},{x:p+f,y:c},{x:p+f,y:u}])}const OE=(e,t,n)=>[...e.slice(0,t+1),...n,...e.slice(t+1)],ps=(e,t,n)=>Fn({...e,waypoints:t},n).length;function Kd(e,t,n,i){let r=[...e.waypoints],o=ps(e,r,t);if(o===0)return null;let a=!1;for(const p of Xu(e,t))if(ps(e,p,t)===0)return p;const s=(i??[]).filter(p=>p.id!==e.id).flatMap(mn),c=p=>mn({...e,waypoints:p}).some(f=>cs(f,s).length>0),u=kE(e,t).filter(p=>ps(e,p,t)===0);if(u.length)return u.find(p=>!c(p))??u[0];const l=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);for(let p=0;p<TE&&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 m of t){if(e.endpoints.includes(m.id)||Fn({...e,waypoints:[g,h]},[m]).length===0)continue;const S=Ud(g,h,m),y=S?S.map(E=>OE(r,d,E)):qd(r,m)??[];if(!y.length)continue;const _=[...y].sort((E,P)=>Number(l(P))-Number(l(E)));for(const E of _){const P=ps(e,E,t);if(P<o){r=E,o=P,f=!0,a=!0;break}}if(f)break}}if(!f)break}return a&&o===0?r:null}function Xd(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n),o=ci(r),a=Ti(r).filter(c=>c.kind==="edge-crosses-shape"&&!t.has(Ri(c)));if(!a.length)return;const s=new Map;for(const c of a){if(c.kind!=="edge-crosses-shape"||s.has(c.edge))continue;const u=r.edges.find(l=>l.id===c.edge);u&&s.set(c.edge,u)}for(const[c,u]of s){const l=n.get(c);if(!l)continue;const p=l.parent,f=p&&typeof p.x=="number"&&typeof p.width=="number"?{x:p.x,y:p.y,width:p.width,height:p.height}:void 0,d=Kd(u,o,f,r.edges);if(!d)continue;const g=r.edges.filter(S=>S.id!==c),h=Ci(u,g);Ci({...u,waypoints:d},g)>h||i.updateWaypoints(l,d)}}const DE=10;function Zd(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 Qd(e,t){if(e.waypoints.length<2||e.endpoints.length!==2)return null;const n=t.shapes.filter($=>$.type==="bpmn:Participant"&&$.container),i=t.shapes.find($=>$.id===e.endpoints[0]),r=t.shapes.find($=>$.id===e.endpoints[1]);if(!i||!r)return null;const o=Zd(i,n),a=Zd(r,n);if(!o||!a||o.id===a.id)return null;const s=a.y>o.y,c=s?o:a,u=s?a:o,l=n.filter($=>$.id!==o.id&&$.id!==a.id&&$.y>=c.y+c.height&&$.y+$.height<=u.y).sort(($,re)=>$.y-re.y);if(!l.length)return null;const p=l[0],f=l[l.length-1],d=(c.y+c.height+p.y)/2,g=(f.y+f.height+u.y)/2,h=s?d:g,m=s?g:d,S=e.waypoints[0],y=e.waypoints[e.waypoints.length-1],_=ci(t),E=t.edges.filter($=>$.id!==e.id),P=Ai(e,E),C=Fn(e,_).length;if(P===0&&C===0||C===0&&e.waypoints.length===2)return null;const D=Math.min(...l.map($=>$.x)),A=Math.max(...l.map($=>$.x+$.width)),B=(S.x+y.x)/2,k=$=>$.filter((re,ye)=>ye===0||!(Mt(re.x,$[ye-1].x)&&Mt(re.y,$[ye-1].y)));let O;for(let $=D;$<=A;$+=DE){const re=k([S,{x:S.x,y:h},{x:$,y:h},{x:$,y:m},{x:y.x,y:m},y]),ye={...e,waypoints:re};if(Fn(ye,_).length>0)continue;const Ue=Ai(ye,E),q=Math.abs($-B);(!O||Ue<O.cross||Ue===O.cross&&q<O.detour)&&(O={pts:re,cross:Ue,detour:q})}return O&&(C>0?O.cross<=P:O.cross<P)?O.pts:null}function Jd(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n);for(const o of r.edges){if(o.type!=="bpmn:MessageFlow"||t.has(o.id))continue;const a=wt(n),s=a.edges.find(l=>l.id===o.id);if(!s)continue;const c=Qd(s,a);if(!c)continue;const u=n.get(o.id);u&&i.updateWaypoints(u,c)}}const Dr=[25,-25,40,-40],fs=35;function eh(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[];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,u=s?n.y:n.y+n.height,l=s?n.y-fs:n.y+n.height+fs,p=[];for(const y of[0,...Dr]){if(Math.abs(y)>=i.width/2-5)continue;const _=o+y;p.push({pts:[{x:n.x,y:r},{x:_,y:r},{x:_,y:c}],cost:Math.abs(y)});for(const E of[0,...Dr]){if(Math.abs(E)>=n.width/2-5)continue;const P=a+E;p.push({pts:[{x:P,y:u},{x:P,y:l},{x:_,y:l},{x:_,y:c}],cost:Math.abs(y)+Math.abs(E)})}}const f=50,d=i.y+i.height/2,g=s?n.y+n.height:n.y;for(const y of[0,...Dr]){if(Math.abs(y)>=n.width/2-5)continue;const _=a+y;p.push({pts:[{x:_,y:g},{x:_,y:d},{x:i.x+i.width,y:d}],cost:f+Math.abs(y)})}const h=60,m=s?i.y+i.height:i.y,S=s?i.y+i.height+fs:i.y-fs;for(const y of[0,...Dr]){if(Math.abs(y)>=i.width/2-5)continue;const _=o+y;for(const E of[0,...Dr]){if(Math.abs(E)>=n.width/2-5)continue;const P=a+E;p.push({pts:[{x:P,y:g},{x:P,y:S},{x:_,y:S},{x:_,y:m}],cost:h+Math.abs(y)+Math.abs(E)})}}return p}const ds=30;function th(e,t){for(let n=1;n<e.length-2;n++){const i=e[n],r=e[n+1],o=Mt(i.y,r.y)&&!Mt(i.x,r.x),a=Mt(i.x,r.x)&&!Mt(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)<ds||Math.abs(i.y-(s.y+s.height))<ds)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)<ds||Math.abs(i.x-(s.x+s.width))<ds)return!0}}return!1}const hs=40;function LE(e,t,n){let i=0;for(const r of t){if(r.container||n.includes(r.id))continue;const o=r.x-hs,a=r.x+r.width+hs,s=r.y-hs,c=r.y+r.height+hs;for(let u=1;u<e.length-2;u++){const l=e[u],p=e[u+1],f={x:Math.min(l.x,p.x),y:Math.min(l.y,p.y)},d={x:Math.max(l.x,p.x),y:Math.max(l.y,p.y)};if(f.x<a&&d.x>o&&f.y<c&&d.y>s){i++;break}}}return i}function nh(e,t){if(e.type!=="bpmn:SequenceFlow")return null;const n=t.shapes.filter(C=>C.container),i=new Map(t.shapes.map(C=>[C.id,C])),r=ci(t),o=t.edges.filter(C=>C.id!==e.id),a=Ci(e,o),s=Ai(e,o),c=C=>LE(C,t.shapes,e.endpoints)+(th(C,n)?1:0),u=c(e.waypoints),l=C=>{if(!C)return;const D=C.x+C.width/2,A=C.y+C.height/2;return n.find(B=>B.type==="bpmn:Lane"&&D>=B.x&&D<=B.x+B.width&&A>=B.y&&A<=B.y+B.height)},p=l(i.get(e.endpoints[0]??"")),f=l(i.get(e.endpoints[1]??"")),d=!!p&&!!f&&p.id!==f.id,g=C=>{if(!d||!f)return!1;for(let D=1;D<C.length-2;D++){const A=C[D],B=C[D+1];if(Mt(A.y,B.y)&&!Mt(A.x,B.x)&&A.y>f.y&&A.y<f.y+f.height)return!0}return!1},h=g(e.waypoints),S=(C=>{if(!C)return;const D=C.x+C.width/2,A=C.y+C.height/2;return n.filter(B=>B.type==="bpmn:Participant"&&D>=B.x&&D<=B.x+B.width&&A>=B.y&&A<=B.y+B.height).sort((B,k)=>B.width*B.height-k.width*k.height)[0]})(i.get(e.endpoints[0]??"")),y=C=>{if(!S)return 0;let D=0;for(let A=1;A<C.length-1;A++){const B=C[A];(B.x<S.x||B.x>S.x+S.width||B.y<S.y||B.y>S.y+S.height)&&D++}return D},_=y(e.waypoints);if(!th(e.waypoints,n)&&!(d&&!h)&&_===0)return null;const E=C=>C.reduce((D,A,B)=>B?D+Math.abs(A.x-C[B-1].x)+Math.abs(A.y-C[B-1].y):0,0);let P;for(const{pts:C,cost:D}of eh(e,i)){const A={...e,waypoints:C};if(Fn(A,r).length>0)continue;const B=Ci(A,o);if(B>a)continue;const k=y(C);if(k>_)continue;const O=k<_&&B===0;if(!O&&Ai(A,o)>s)continue;const $=c(C),re=g(C);if(!O&&!(re&&!h)&&$>=u)continue;const Ue=re?0:1,q=E(C);(!P||k<P.out||k===P.out&&(Ue<P.lane||Ue===P.lane&&(B<P.opp||B===P.opp&&($<P.sc||$===P.sc&&(D<P.cost||D===P.cost&&q<P.len)))))&&(P={pts:C,out:k,sc:$,lane:Ue,opp:B,cost:D,len:q})}return(P==null?void 0:P.pts)??null}function IE(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n).edges.filter(o=>!t.has(o.id)&&o.waypoints.length>=4).map(o=>o.id).sort();for(const o of r){const a=wt(n),s=a.edges.find(d=>d.id===o);if(!s||s.waypoints.length<4)continue;const c=ci(a),u=a.edges.filter(d=>d.id!==o),l=Fn(s,c).length,p=Ci(s,u),f=Ai(s,u);for(const d of Xu(s,a.shapes)){if(d.length>=s.waypoints.length)continue;const g={...s,waypoints:d};if(Fn(g,c).length>l||Ci(g,u)>p||Ai(g,u)>f)continue;const h=n.get(o);h&&i.updateWaypoints(h,d);break}}}function ih(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n).edges.filter(o=>o.type==="bpmn:SequenceFlow"&&!t.has(o.id)).map(o=>o.id).sort();for(const o of r){const a=wt(n),s=a.edges.find(l=>l.id===o);if(!s)continue;const c=nh(s,a);if(!c)continue;const u=n.get(o);u&&i.updateWaypoints(u,c)}}function BE(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=Mt(n[0].x,n[1].x)&&!Mt(n[0].y,n[1].y),s=Mt(n[n.length-1].x,n[n.length-2].x)&&!Mt(n[n.length-1].y,n[n.length-2].y);for(const c of Dr){if(a&&r&&Math.abs(c)<r.width/2-5){const u=n.map(l=>({...l}));u[0].x+=c,u[1].x+=c,i.push({pts:u,cost:Math.abs(c)})}if(s&&o&&Math.abs(c)<o.width/2-5){const u=n.map(l=>({...l}));u[u.length-1].x+=c,u[u.length-2].x+=c,i.push({pts:u,cost:Math.abs(c)})}}return i}function NE(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,u=a?i.y+i.height:i.y,l=(r+o)/2,p=[];for(const f of[0,...Dr]){const d=l+f;d<=r||d>=o||p.push({pts:[{x:d,y:c},{x:d,y:u}],cost:Math.abs(f)})}return p}function rh(e,t){const n=new Map(t.shapes.map(d=>[d.id,d])),i=ci(t),r=t.edges.filter(d=>d.id!==e.id),o=Ci(e,r);if(o===0)return null;const a=Ai(e,r);let s;const c=d=>d.reduce((g,h,m)=>m?g+Math.abs(h.x-d[m-1].x)+Math.abs(h.y-d[m-1].y):0,0),u=3,l=d=>{const g=d[0],h=d[d.length-1],m=Math.hypot(h.x-g.x,h.y-g.y);return m>=1&&c(d)/m>=u?1:0},p=l(e.waypoints),f=[...eh(e,n),...NE(e,n),...BE(e,n)];for(const{pts:d,cost:g}of f){const h={...e,waypoints:d};if(Fn(h,i).length>0)continue;const m=Ci(h,r),S=Ai(h,r),y=o-m+(p-l(d));if(m>=o||S-a>y)continue;const _=c(d);(!s||m<s.opposite||m===s.opposite&&(S<s.cross||S===s.cross&&(g<s.cost||g===s.cost&&_<s.len)))&&(s={pts:d,opposite:m,cross:S,cost:g,len:_})}return(s==null?void 0:s.pts)??null}function oh(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=wt(i),a=Ti(o).filter(l=>(l.kind==="edge-overlap-opposite"||l.kind==="edge-overlap-mixed")&&!t.has(Ri(l)));if(!a.length)return;const s=new Set;for(const l of a)if(!(l.kind!=="edge-overlap-opposite"&&l.kind!=="edge-overlap-mixed"))for(const p of l.edges)n.has(p)||s.add(p);const c=l=>{var p;return((p=o.edges.find(f=>f.id===l))==null?void 0:p.type)??""},u=[...s].sort((l,p)=>{const f=c(l)==="bpmn:SequenceFlow"?0:1,d=c(p)==="bpmn:SequenceFlow"?0:1;return f!==d?f-d:l.localeCompare(p)});for(const l of u){const p=wt(i),f=p.edges.find(h=>h.id===l);if(!f)continue;const d=rh(f,p);if(!d)continue;const g=i.get(l);g&&r.updateWaypoints(g,d)}}const $E=10,jE=(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 ah(e,t){const n=e.label;if(!n)return null;const i=t.edges.filter(a=>a.id!==e.id);if(!us(e,i))return null;const r=ci(t),o=i.flatMap(mn);for(const a of mn(e)){let s=[[a.lo,a.hi]];for(const[d,g]of cs(a,o))s=s.flatMap(([h,m])=>{const S=[];return d>h&&S.push([h,Math.min(m,d)]),g<m&&S.push([Math.max(h,g),m]),S.filter(([y,_])=>_>y)});const c=a.axis==="h"?n.width:n.height,u=s.find(([d,g])=>g-d>=c+$E*2);if(!u)continue;const l=(u[0]+u[1])/2,p=a.axis==="h"?{x:l,y:a.at-kd}:{x:a.at+Cn+n.width/2,y:l},f={x:p.x-n.width/2,y:p.y-n.height/2,width:n.width,height:n.height};if(!us({...e,label:f},i)&&!r.some(d=>!e.endpoints.includes(d.id)&&jE(f,d)))return f}return null}const Cn=8;function sh(e,t){const n=e.label;if(!n)return null;const i=mn(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(mn),...t.shapes.filter(f=>f.container).flatMap(qo)],u=f=>!c.some(d=>Pi(f,d));if(u(n))return null;const l=(s.axis==="v"?n.height:n.width)+Cn,p=[0,-l,l,-2*l,2*l];if(s.axis==="v")for(const f of[s.at+Cn,s.at-Cn-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(u(h))return h}else for(const f of[s.at-Cn-n.height,s.at+Cn])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(u(h))return h}return null}function ch(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n);for(const o of r.edges){if(!o.label||t.has(o.id))continue;const a=sh(o,r);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 uh(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=wt(i),a=Ti(o).filter(s=>s.kind==="label-on-shared-segment"&&!t.has(Ri(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 u=ah(c,o);if(!u)continue;const l=i.get(s.edge),p=l==null?void 0:l.label;p&&r.moveElements([p],{x:u.x-p.x,y:u.y-p.y})}}function lh(e,t){const n=e.label;if(!n)return null;const i=[...t.edges.flatMap(mn),...t.shapes.filter(f=>f.container).flatMap(qo)],r=i.filter(f=>Pi(n,f));if(!r.length)return null;const o=t.shapes.filter(f=>!f.container&&f.id!==e.id),a=uo(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=>Pi(f,d))&&!o.some(d=>s(f,d))&&!a.some(d=>s(f,d)),u=[];for(const f of r)f.axis==="h"?u.push({...n,y:f.at-Cn-n.height},{...n,y:f.at+Cn}):u.push({...n,x:f.at-Cn-n.width},{...n,x:f.at+Cn});const l=e.x+e.width/2,p=e.y+e.height/2;return u.push({...n,x:l-n.width/2,y:e.y+e.height+Cn},{...n,x:l-n.width/2,y:e.y-Cn-n.height},{...n,x:e.x+e.width+Cn,y:p-n.height/2},{...n,x:e.x-Cn-n.width,y:p-n.height/2}),u.find(c)??null}function ph(e,t){const{elementRegistry:n}=e,i=e.modeling,r=wt(n);for(const o of r.shapes){if(o.container||!o.label||t.has(o.id))continue;const a=lh(o,wt(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})}}const FE=/^[\p{L}_][\p{L}\p{N}_.\-]*$/u,fh=new Set(["sequenceFlow","messageFlow","dataAssociation","association"]),dh={"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","text"]},{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}],"element.remove":[{path:"id",shape:null}]},ms=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Zu=e=>typeof e=="string"&&e!=="";function HE(e){const t=[];function n(i,r,o,a){if(a===null){Zu(o)||t.push({kind:"payload-invalid",opIndex:i,field:r});return}if(!ms(o)){t.push({kind:"payload-invalid",opIndex:i,field:r});return}for(const s of a)Zu(o[s])||t.push({kind:"payload-invalid",opIndex:i,field:`${r}.${s}`})}return e.forEach((i,r)=>{if(!ms(i)||!Zu(i.kind)||!(i.kind in dh)){t.push({kind:"payload-invalid",opIndex:r,field:"kind"});return}for(const o of dh[i.kind]){const a=o.path.endsWith("[]"),s=a?o.path.slice(0,-2):o.path,c=s.split(".");let u=i;for(const p of c.slice(0,-1)){if(!ms(u))break;u=u[p]}if(!ms(u))continue;const l=u[c[c.length-1]];if(!(l===void 0&&o.optional)&&!(l===null&&o.optional)){if(!a){n(r,o.path,l,o.shape);continue}if(!Array.isArray(l)){t.push({kind:"payload-invalid",opIndex:r,field:o.path});continue}l.forEach((p,f)=>n(r,`${s}[${f}]`,p,o.shape))}}if(i.kind==="node.add"){const o=i.band;o!==void 0&&(!Number.isInteger(o)||o<0)&&t.push({kind:"payload-invalid",opIndex:r,field:"band"})}}),t}function hh(e,t){const n=HE(e);if(n.length>0)return n;const i=[],r=new Map,o=new Map;function a(f,d,g){if(!FE.test(d)){i.push({kind:"id-invalid",opIndex:f,id:d});return}if(t.categoryOf(d)!==void 0||r.has(d)){i.push({kind:"id-duplicate",opIndex:f,id:d});return}r.set(d,{...g,opIndex:f})}e.forEach((f,d)=>{var g;switch(f.kind){case"participant.add":a(d,f.participant.id,{category:"participant",lanes:(f.participant.lanes??[]).map(h=>h.id)});for(const h of f.participant.lanes??[])a(d,h.id,{category:"lane"});break;case"node.add":a(d,f.node.id,{category:"flowNode",participant:f.node.participant});break;case"sequenceFlow.add":a(d,f.flow.id,{category:"sequenceFlow"});break;case"messageFlow.add":a(d,f.flow.id,{category:"messageFlow"});break;case"dataStore.add":a(d,f.dataStore.id,{category:"dataStore"});for(const h of f.associations??[])h.id&&a(d,h.id,{category:"dataAssociation"});break;case"dataAssociation.add":f.association.id&&a(d,f.association.id,{category:"dataAssociation"});break;case"association.add":f.association.id&&a(d,f.association.id,{category:"association"});break;case"annotation.add":a(d,f.annotation.id,{category:"annotation"}),(g=f.association)!=null&&g.id&&a(d,f.association.id,{category:"association"});break;case"group.add":a(d,f.group.id,{category:"group"});break;case"participant.update":if(f.lanes){o.set(f.id,f.lanes.map(h=>h.id));for(const h of f.lanes)t.categoryOf(h.id)===void 0&&a(d,h.id,{category:"lane"})}break}});const s=f=>{var d;return((d=r.get(f))==null?void 0:d.category)??t.categoryOf(f)},c=f=>{const d=r.get(f);return d?d.category==="participant"?f:d.participant:t.categoryOf(f)==="participant"?f:t.participantOf(f)};function u(f,d,g,h){const m=s(d);if(m===void 0){i.push({kind:"ref-missing",opIndex:f,ref:d,role:g});return}if(h&&!h.includes(m)){i.push({kind:"ref-category",opIndex:f,ref:d,role:g,expected:h.join("|"),actual:m});return}return m}const l=t.isCollaboration()||e.some(f=>f.kind==="participant.add");return e.forEach((f,d)=>{var g;switch(f.kind){case"participant.add":break;case"node.add":{const{participant:h,lane:m}=f.node;if(h===void 0){(l||m!==void 0)&&i.push({kind:"participant-required",opIndex:d,id:f.node.id});break}if(u(d,h,"participant",["participant"])===void 0)break;m!==void 0&&((((g=r.get(h))==null?void 0:g.lanes)??o.get(h)??t.lanesOf(h)).includes(m)||i.push({kind:"lane-unknown",opIndex:d,lane:m,participant:h}));break}case"sequenceFlow.add":{const{id:h,source:m,target:S,name:y,condition:_}=f.flow,E=u(d,m,"source",["flowNode"]),P=u(d,S,"target",["flowNode"]);E&&P&&c(m)!==c(S)&&i.push({kind:"flow-cross-pool",opIndex:d,id:h}),y!==void 0&&_!==void 0&&i.push({kind:"condition-name-conflict",opIndex:d,id:h});break}case"messageFlow.add":{const{id:h,source:m,target:S}=f.flow,y=u(d,m,"source",["flowNode","participant"]),_=u(d,S,"target",["flowNode","participant"]);if(y&&_){const E=c(m),P=c(S);E!==void 0&&E===P&&i.push({kind:"message-flow-same-pool",opIndex:d,id:h})}break}case"dataStore.add":{for(const h of f.associations??[]){if([h.source,h.target].filter(y=>y===f.dataStore.id).length!==1){i.push({kind:"data-association-ends",opIndex:d,source:h.source,target:h.target});continue}const S=h.source===f.dataStore.id?h.target:h.source;u(d,S,"dataAssociation",["flowNode"])}break}case"dataAssociation.add":{const{source:h,target:m}=f.association,S=u(d,h,"source"),y=u(d,m,"target");if(S&&y){const _=new Set([S,y]);_.has("dataStore")&&_.has("flowNode")||i.push({kind:"data-association-ends",opIndex:d,source:h,target:m})}break}case"association.add":{const{id:h,source:m,target:S}=f.association,y=u(d,m,"source"),_=u(d,S,"target");y&&_&&y!=="annotation"&&_!=="annotation"&&i.push({kind:"association-detached",opIndex:d,annotation:h??`${m}->${S}`});break}case"annotation.add":{if(f.association){const{source:h,target:m}=f.association;if(h!==f.annotation.id&&m!==f.annotation.id)i.push({kind:"association-detached",opIndex:d,annotation:f.annotation.id});else{const S=h===f.annotation.id?m:h;u(d,S,"association")}}f.placement&&u(d,f.placement.anchor,"anchor");break}case"group.add":{for(const h of f.group.members??[]){const m=u(d,h,"member");m&&fh.has(m)&&i.push({kind:"ref-category",opIndex:d,ref:h,role:"member",expected:"shape",actual:m})}break}case"participant.update":{if(p(d,f.id,"participant")===void 0)break;if(f.lanes){const h=t.lanesOf(f.id),m=f.lanes.map(y=>y.id);for(const y of h)m.includes(y)||i.push({kind:"lane-shrink-unsupported",opIndex:d,participant:f.id,lane:y});for(const y of m)t.categoryOf(y)!==void 0&&!h.includes(y)&&i.push({kind:"id-duplicate",opIndex:d,id:y});const S=m.filter(y=>h.includes(y));S.length===h.length&&S.some((y,_)=>y!==h[_])&&i.push({kind:"lane-reorder-unsupported",opIndex:d,participant:f.id})}break}case"node.update":{if(p(d,f.id,"flowNode")===void 0)break;if(f.lane!==void 0){const h=t.participantOf(f.id);(h?o.get(h)??t.lanesOf(h):[]).includes(f.lane)||i.push({kind:"lane-unknown",opIndex:d,lane:f.lane,participant:h??""})}break}case"sequenceFlow.update":{if(p(d,f.id,"sequenceFlow")===void 0)break;if(f.name!==void 0&&f.condition!==void 0&&i.push({kind:"condition-name-conflict",opIndex:d,id:f.id}),f.source!==void 0||f.target!==void 0){const h=f.source===void 0||u(d,f.source,"source",["flowNode"])!==void 0,m=f.target===void 0||u(d,f.target,"target",["flowNode"])!==void 0,S=t.endpointsOf(f.id),y=f.source??(S==null?void 0:S.source),_=f.target??(S==null?void 0:S.target);h&&m&&y!==void 0&&_!==void 0&&new Set([c(y),c(_),c(f.id)]).size>1&&i.push({kind:"flow-cross-pool",opIndex:d,id:f.id})}break}case"messageFlow.update":p(d,f.id,"messageFlow");break;case"dataStore.update":p(d,f.id,"dataStore");break;case"annotation.update":{if(p(d,f.id,"annotation")===void 0)break;f.placement&&u(d,f.placement.anchor,"anchor");break}case"group.update":{if(p(d,f.id,"group")===void 0)break;for(const h of f.members??[]){const m=u(d,h,"member");m&&fh.has(m)&&i.push({kind:"ref-category",opIndex:d,ref:h,role:"member",expected:"shape",actual:m})}break}case"element.remove":{p(d,f.id)==="lane"&&i.push({kind:"ref-category",opIndex:d,ref:f.id,role:"target",expected:"removable",actual:"lane"});break}}}),i;function p(f,d,g){if(r.has(d)){i.push({kind:"target-added-in-batch",opIndex:f,id:d});return}const h=t.categoryOf(d);if(h===void 0){i.push({kind:"ref-missing",opIndex:f,ref:d,role:"target"});return}if(g&&h!==g){i.push({kind:"ref-category",opIndex:f,ref:d,role:"target",expected:g,actual:h});return}return h}}function mh(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")}}function gs(e){return`bpmn:${e[0].toUpperCase()}${e.slice(1)}`}const ys={"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]},en=10,gh=40,zE=10;function Qu(e,t,n,i,r){const o=n,a=(k,O)=>{const[$,re]=ys[k];let ye={x:t.x+t.width/2+$*(t.width/2+o.width/2+O),y:t.y+t.height/2+re*(t.height/2+o.height/2+O)};const Ue=i.x+en+o.width/2,q=i.x+i.width-en-o.width/2,le=i.y+en+o.height/2,me=i.y+i.height-en-o.height/2,se={x:Math.min(q,Math.max(Ue,ye.x)),y:Math.min(me,Math.max(le,ye.y))};return(se.x!==ye.x||se.y!==ye.y)&&(ye=Math.abs(se.x-(t.x+t.width/2))<(t.width+o.width)/2+en&&Math.abs(se.y-(t.y+t.height/2))<(t.height+o.height)/2+en?{x:t.x+t.width+en+o.width/2,y:se.y}:se),ye},s=(i.children??[]).filter(k=>!("waypoints"in k&&k.waypoints)&&k.type!=="bpmn:Lane"&&k.type!=="label"&&typeof k.x=="number"&&k.id!==r.selfId),c=wt(e),u=k=>{var $,re;if(!r.selfId)return!1;const O=e.get(k);return!!O&&((($=O.source)==null?void 0:$.id)===r.selfId||((re=O.target)==null?void 0:re.id)===r.selfId)},l=c.edges.filter(k=>!u(k.id)).flatMap(mn),p=uo(c).filter(k=>k.owner!==r.selfId).map(k=>k.rect),f=k=>({x0:k.x-o.width/2-en,x1:k.x+o.width/2+en,y0:k.y-o.height/2-en,y1:k.y+o.height/2+en}),d=k=>{const O=f(k);return s.some($=>O.x0<$.x+$.width&&O.x1>$.x&&O.y0<$.y+$.height&&O.y1>$.y)},g=k=>{const O=f(k);return l.some($=>$.axis==="h"?$.at>O.y0&&$.at<O.y1&&$.lo<O.x1&&$.hi>O.x0:$.at>O.x0&&$.at<O.x1&&$.lo<O.y1&&$.hi>O.y0)},h=k=>{const O=f(k);return p.some($=>O.x0<$.x+$.width&&O.x1>$.x&&O.y0<$.y+$.height&&O.y1>$.y)},m=c.shapes.filter(k=>k.type==="bpmn:Group").flatMap(k=>[{axis:"h",at:k.y,lo:k.x,hi:k.x+k.width},{axis:"h",at:k.y+k.height,lo:k.x,hi:k.x+k.width},{axis:"v",at:k.x,lo:k.y,hi:k.y+k.height},{axis:"v",at:k.x+k.width,lo:k.y,hi:k.y+k.height}]),S=k=>{const O=f(k);return m.some($=>$.axis==="h"?$.at>O.y0&&$.at<O.y1&&$.lo<O.x1&&$.hi>O.x0:$.at>O.x0&&$.at<O.x1&&$.lo<O.y1&&$.hi>O.y0)},y=k=>d(k)||g(k)||h(k)||S(k),_=k=>k.x-o.width/2>=i.x&&k.x+o.width/2<=i.x+i.width&&k.y-o.height/2>=i.y&&k.y+o.height/2<=i.y+i.height;if(r.placement){const k=q=>q.startsWith("top")?q.replace(/^top/,"bottom"):q.replace(/^bottom/,"top"),O=q=>q.endsWith("left")?q.replace(/left$/,"right"):q.replace(/right$/,"left"),$=r.placement.side,re=[$,k($),O($),k(O($)),"top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"],ye=r.placement.offset??50;let Ue=a($,ye);if(y(Ue)){const q=new Set;for(const le of re){if(q.has(le))continue;q.add(le);const me=a(le,ye);if(_(me)&&!y(me)){Ue=me;break}}}return Ue}const E=r.from,P=i.x+en+o.width/2,C=i.x+i.width-en-o.width/2,D=i.y+en+o.height/2,A=i.y+i.height-en-o.height/2;let B={x:Math.min(C,Math.max(P,E.x)),y:Math.min(A,Math.max(D,E.y))};if(y(B)){const k=(t.width+o.width)/2+en,$=[{x:B.x+k,y:B.y},{x:B.x-k,y:B.y},{x:B.x,y:B.y-o.height-en},{x:B.x,y:B.y+o.height+en}].filter(_).find(re=>!y(re));$&&(B=$)}return B}function Xt(e,t){return e.filter(n=>n.kind===t)}function yh(e,t){var jx,Fx,Hx,zx,Gx,Vx,Wx,Ux,qx,Yx,Kx,Xx,Zx,Qx,Jx,e0,t0,n0,i0,r0,o0,a0,s0;const{modeling:n,bpmnFactory:i,elementFactory:r,elementRegistry:o,canvas:a,autoPlace:s,bpmnReplace:c}=t,u=()=>a.getRootElement(),l=w=>o.get(w),p=w=>{const R=l(w);if(!R)throw new Error(`하강 참조 해소 실패: ${w}`);return R},f=w=>{let R=w.parent;for(;R;){if(R.type==="bpmn:Participant")return R;R=R.parent}},d=new Map;for(const w of o.filter(R=>!("waypoints"in R&&R.waypoints)&&R.type!=="bpmn:Lane"&&R.type!=="label"&&typeof R.x=="number"))d.set(w.id,{x:w.x,y:w.y});const g=Xt(e,"participant.add"),h=Xt(e,"node.add"),m=Xt(e,"sequenceFlow.add"),S=Xt(e,"messageFlow.add"),y=Xt(e,"dataStore.add"),_=Xt(e,"dataAssociation.add"),E=Xt(e,"annotation.add"),P=Xt(e,"group.add"),C=new Map(h.map(w=>[w.node.id,w])),D=(w,R,M)=>{var G;const F=w.businessObject,H=(((G=F.extensionElements)==null?void 0:G.values)??[]).filter(W=>W.$type!==R),I=M?[...H,i.create(R,M)]:H;if(!I.length){F.extensionElements&&n.updateProperties(w,{extensionElements:void 0});return}const Y=i.create("bpmn:ExtensionElements",{values:I});I.forEach(W=>{W.$parent=Y}),n.updateProperties(w,{extensionElements:Y})},A=w=>({anchor:w.anchor,side:w.side,...w.offset!==void 0?{offset:w.offset}:{}});for(const w of Xt(e,"element.remove")){const R=l(w.id);R&&n.removeElements([R])}const B=w=>o.filter(R=>{var M;return R.type==="bpmn:Lane"&&((M=f(R))==null?void 0:M.id)===w}).sort((R,M)=>R.y-M.y);for(const w of Xt(e,"participant.update")){const R=p(w.id);if(w.name!==void 0&&n.updateProperties(R,{name:w.name??void 0}),!w.lanes)continue;const M=B(w.id);if(!M.length){n.splitLane(R,w.lanes.length),B(w.id).forEach((H,I)=>{const Y=w.lanes[I];Y&&n.updateProperties(H,{id:Y.id,name:Y.name})});continue}const F=new Set(M.map(H=>H.id));w.lanes.forEach((H,I)=>{if(F.has(H.id)){n.updateProperties(p(H.id),{name:H.name});return}const Y=I===0?n.addLane(B(w.id)[0],"top"):n.addLane(p(w.lanes[I-1].id),"bottom");n.updateProperties(Y,{id:H.id,name:H.name})})}const k=150,O=130,$=80,re=90,ye=180,Ue=30,q=(w,R,M,F,H)=>{const I=M-R.width/2,Y=F-R.height/2;return(w.children??[]).find(G=>!("waypoints"in G&&G.waypoints)&&G.type!=="bpmn:Lane"&&G.type!=="label"&&!(H!=null&&H.has(G.id))&&typeof G.x=="number"&&I<G.x+G.width+Ue&&I+R.width+Ue>G.x&&Y<G.y+G.height&&Y+R.height>G.y)},le=new Set;for(const w of g){le.add(`pool:${w.participant.id}`);for(const R of w.participant.lanes??[])le.add(R.id)}const me=new Map;for(const w of h){const R=w.node.lane??`pool:${w.node.participant??""}`;let M=me.get(R);M||me.set(R,M=new Set([0])),w.band!==void 0&&M.add(w.band)}const se=new Map;for(const[w,R]of me){if(!le.has(w))continue;const M=[...R].sort((I,Y)=>I-Y),F=M.map((I,Y)=>Y===0?0:Y%2===1?Math.ceil(Y/2):-(Y/2)),H=Math.min(...F);se.set(w,new Map(M.map((I,Y)=>[I,F[Y]-H])))}{const w=new Map;for(const R of g)(R.participant.lanes??[]).forEach((M,F)=>w.set(M.id,F));for(const[R,M]of se){if(!w.has(R)||M.size<2)continue;const F=w.get(R),H=M.get(0)??0,I=new Set;for(const oe of h){if(oe.node.lane!==R||(oe.band??0)!==0||!oe.node.type.endsWith("Gateway"))continue;const Me={in:new Set,out:new Set,cross:new Set};for(const pe of m){const ve=pe.flow.source===oe.node.id;if(!ve&&pe.flow.target!==oe.node.id)continue;const ot=C.get(ve?pe.flow.target:pe.flow.source);if(!ot||ot.node.participant!==oe.node.participant||!ot.node.lane)continue;let Ce,$e=!1;if(ot.node.lane!==R){const ue=w.get(ot.node.lane);if(ue===void 0)continue;Ce=ue>F?"down":"up",$e=!0}else{const ue=M.get(ot.band??0)??H;Ce=ue>H?"down":ue<H?"up":void 0}Ce&&(Me[ve?"out":"in"].add(Ce),$e&&Me.cross.add(Ce))}for(const pe of["up","down"])Me.in.has(pe)&&Me.out.has(pe)&&Me.cross.has(pe)&&I.add(pe)}if(I.size!==1)continue;const[Y]=I,G=Math.max(...M.values()),W=Y==="down"?G:0;if(H===W)continue;const ce=[...M.entries()].filter(([oe])=>oe!==0).sort((oe,Me)=>oe[1]-Me[1]),xe=[...Array(G+1).keys()].filter(oe=>oe!==W),Re=new Map([[0,W]]);ce.forEach(([oe],Me)=>Re.set(oe,xe[Me])),se.set(R,Re)}}const _e=w=>{var R;return(((R=me.get(w))==null?void 0:R.size)??0)>1},ne=w=>w.band??(w.node.lane||!_e(`pool:${w.node.participant??""}`)?void 0:0),U=new Map,V=w=>U.get(w.node.id)??ne(w),Z=new Set,Fe=new Set;{const w=new Map;for(const F of m)w.set(F.flow.target,(w.get(F.flow.target)??0)+1);const R=F=>{const H=[],I=new Set([F]),Y=[F];for(;Y.length;){const G=Y.shift();H.push(G);for(const W of m)W.flow.source!==G||I.has(W.flow.target)||(w.get(W.flow.target)??0)!==1||(I.add(W.flow.target),Y.push(W.flow.target))}return H},M=(F,H)=>{var I;return((I=se.get(F))==null?void 0:I.get(H))??H};for(const F of h){if(!F.node.type.endsWith("Gateway"))continue;const H=F.node.lane??`pool:${F.node.participant??""}`,I=se.get(H);if(!I||I.size<2)continue;const Y=V(F);if(Y===void 0||M(H,Y)!==M(H,0))continue;const G=M(H,Y),W=m.filter(pe=>pe.flow.source===F.node.id).map(pe=>C.get(pe.flow.target)).filter(pe=>!!pe&&(pe.node.lane??`pool:${pe.node.participant??""}`)===H),ce=W.filter(pe=>{const ve=V(pe);return ve!==void 0&&M(H,ve)===G&&(w.get(pe.node.id)??0)===1}),xe=W.some(pe=>{const ve=V(pe);return ve!==void 0&&M(H,ve)>G});if(ce.length!==1||!xe)continue;const Re=new Set(W.flatMap(pe=>R(pe.node.id)));if(!m.some(pe=>pe.flow.target===F.node.id&&Re.has(pe.flow.source)))continue;const Me=new Map;for(const[pe,ve]of I)Me.set(pe,ve+1);Me.set(-1,0),se.set(H,Me);for(const pe of R(ce[0].node.id))C.has(pe)&&(U.set(pe,-1),Fe.add(pe));Z.add(F.node.id)}}const Rt=(w,R)=>{var M;return((M=se.get(w))==null?void 0:M.get(R))??R},T=new Map;for(const[w,R]of me){let M=0;for(const F of R)M=Math.max(M,Rt(w,F));T.set(w,M)}const x=w=>ye+k*w,v=g.map((w,R)=>({op:w,declared:R}));v.sort((w,R)=>{const M=w.op.order??Number.POSITIVE_INFINITY,F=R.op.order??Number.POSITIVE_INFINITY;return M!==F?M-F:w.declared-R.declared});let N=80;for(const w of o.getAll())w.parent===u()&&"height"in w&&typeof w.y=="number"&&(N=Math.max(N,w.y+w.height+60));for(const{op:w}of v){const R=w.participant,M=h.filter(oe=>oe.node.participant===R.id).length,F=((jx=R.lanes)==null?void 0:jx.length)??0,H=Math.max(1200,M*160+300),I=(R.lanes??[]).map(oe=>x(T.get(oe.id)??0)),Y=I.reduce((oe,Me)=>oe+Me,0);F&&Y<300&&(I[F-1]+=300-Y);const G=Math.max(300,k*((T.get(`pool:${R.id}`)??0)+1)),W=R.blackBox||M+F===0?120:F?Math.max(300,Y):G,ce=r.createShape({type:"bpmn:Participant",businessObject:i.create("bpmn:Participant",{id:R.id,name:R.name,...w.order!==void 0?{"bwl:poolOrder":w.order}:{},...R.blackBox?{}:{processRef:i.create("bpmn:Process")}}),width:H,height:W,isExpanded:!0}),xe=n.createShape(ce,{x:100+H/2,y:N+W/2},u()),Re=R.lanes??[];if(Re.length&&n.splitLane(xe,Re.length),Re.length){const oe=o.filter(Me=>{var pe;return Me.type==="bpmn:Lane"&&((pe=f(Me))==null?void 0:pe.id)===R.id}).sort((Me,pe)=>Me.y-pe.y);if(oe.forEach((Me,pe)=>{const ve=Re[pe];ve&&n.updateProperties(Me,{id:ve.id,name:ve.name})}),I.some(Me=>Me!==xe.height/F)){let Me=xe.y;oe.forEach((pe,ve)=>{const ot=I[ve];n.resizeShape(pe,{x:pe.x,y:Me,width:pe.width,height:ot}),Me+=ot})}}N=xe.y+xe.height+60}const z=w=>{var F;const R=C.get(w);if(R)return R.node.participant??"";const M=l(w);return M?M.type==="bpmn:Participant"?M.id:((F=f(M))==null?void 0:F.id)??"":""},K=new Map,ge=w=>{let R=K.get(w);return R||K.set(w,R={nodes:[],flows:[]}),R};for(const w of h)ge(w.node.participant??"").nodes.push(w);for(const w of m)ge(z(w.flow.source)).flows.push(w);const Be=w=>{var R;return i.create("bpmn:SequenceFlow",{id:w.id,name:w.name??((R=w.condition)==null?void 0:R.label)})},Qe=(w,R)=>r.createShape({type:gs(w.type),businessObject:i.create(gs(w.type),{id:w.id,name:w.name,...R!==void 0?{"bwl:band":R}:{}})}),Ct=[...v.map(({op:w})=>w.participant.id).filter(w=>K.has(w)),...[...K.keys()].filter(w=>!g.some(R=>R.participant.id===w))],rt=w=>w.endsWith("Gateway");for(const w of Ct){const R=K.get(w),M=w?p(w):void 0,F=M?M.x+150:250;let H=M?M.y+80:120;const I=(ue,we,Ne)=>{const it=u().children.filter(dt=>!("waypoints"in dt&&dt.waypoints)&&dt.id!==we&&typeof dt.y=="number"&&dt.y>=ue);it.length&&n.moveElements(it,{x:0,y:Ne})},Y=(ue,we)=>{if(ue){const et=p(ue),Ut=x(we);if(et.height>=Ut)return;const Jt=Ut-et.height,X=f(et),te=X?X.y+X.height:et.y+et.height;n.resizeLane(et,{x:et.x,y:et.y,width:et.width,height:Ut},!1),I(te,X==null?void 0:X.id,Jt);return}if(!M)return;const Ne=k*(we+1);if(M.height>=Ne)return;const it=Ne-M.height,dt=M.y+M.height;n.resizeShape(M,{x:M.x,y:M.y,width:M.width,height:Ne}),I(dt,M.id,it)},G=(ue,we,Ne)=>{if(ue){const it=p(ue);return it.y+Math.min(it.height/2,re)+Rt(ue,we??0)*k}return we!==void 0&&M?M.y+$+Rt(`pool:${w}`,we)*k:Ne},W=(ue,we,Ne)=>{if(ue){const it=p(ue);return it.y+Math.min(it.height/2,re)+we*k}return M?M.y+$+we*k:Ne},ce=ue=>ue.participant?p(ue.participant):u(),xe=(ue,we,Ne,it,dt,et)=>{const Ut=Ne!==void 0||it!==void 0,Jt=Rt(Ne??`pool:${w}`,it??0);if(Ut)for(let ae=0;ae<4;ae++){const be=W(Ne,Jt+ae,et);if(!q(ue,we,dt,be))return Y(Ne,Jt+ae),{x:dt,y:be}}const X=G(Ne,it,et);Ut&&Y(Ne,Jt);let te=dt;for(let ae=0;ae<64;ae++){const be=q(ue,we,te,X);if(!be)break;te=be.x+be.width+O+we.width/2}return{x:te,y:X}},Re=new Set(R.flows.map(ue=>ue.flow.target)),oe=new Map;for(const ue of R.nodes){if(Re.has(ue.node.id))continue;const we=Qe(ue.node,ue.band),Ne=ne(ue),it=ue.node.lane?`${ue.node.lane}|${Ne??""}`:Ne!==void 0?`band:${Ne}`:"",dt=ce(ue.node),et=xe(dt,we,ue.node.lane,Ne,oe.get(it)??F,H);n.createShape(we,et,dt),oe.set(it,et.x+we.width+O),!ue.node.lane&&Ne===void 0&&(H+=160)}const Me=new Set,pe=new Map,ve=new Map,ot=new Map;if(w&&le.has(`pool:${w}`)){const ue=new Map;for(const X of R.flows)ue.set(X.flow.target,(ue.get(X.flow.target)??0)+1);const we=X=>G(X.node.lane,V(X),Number.NaN),Ne=new Set,it=X=>{var be;const te=(be=C.get(X))==null?void 0:be.node.participant;if(te)return l(te);const ae=l(X);if(ae)return ae.type==="bpmn:Participant"?ae:f(ae)},dt=X=>{const te=[],ae=new Set([X]),be=[X];for(;be.length;){const Je=be.shift(),Ge=C.get(Je);Ge&&te.push(Ge);for(const ke of R.flows)ke.flow.source!==Je||ae.has(ke.flow.target)||(ue.get(ke.flow.target)??0)!==1||(ae.add(ke.flow.target),be.push(ke.flow.target))}return te},et=X=>{if(!M)return;const te=new Set(X.map(Je=>Je.node.id));let ae=!1,be=!1;for(const Je of S){if(!te.has(Je.flow.source))continue;const Ge=it(Je.flow.target);!Ge||Ge.id===M.id||(Ge.y<M.y?ae=!0:be=!0)}return ae&&!be?"up":be&&!ae?"down":void 0};for(const X of R.nodes){if(!rt(X.node.type))continue;const te=G(X.node.lane,ne(X),Number.NaN);if(Number.isNaN(te))continue;const ae=[];for(const ke of R.flows){if(ke.flow.source!==X.node.id)continue;const Ve=C.get(ke.flow.target);if(!Ve||Ve.node.lane!==X.node.lane||(ue.get(Ve.node.id)??0)!==1)continue;const tt=ne(Ve);if(tt===void 0)continue;const qt=G(Ve.node.lane,tt,Number.NaN);if(Number.isNaN(qt))continue;const At=dt(Ve.node.id),$t=et(At);$t&&ae.push({subtree:At,band:tt,row:qt,dir:$t})}if(!ae.some(ke=>ke.dir==="up")||!ae.some(ke=>ke.dir==="down")||!ae.some(ke=>ke.dir==="up"&&ae.some(Ve=>Ve.dir==="down"&&Ve.row<ke.row)))continue;const Je=[...ae].sort((ke,Ve)=>ke.row-Ve.row);[...ae.filter(ke=>ke.dir==="up"),...ae.filter(ke=>ke.dir==="down")].sort((ke,Ve)=>ke.dir===Ve.dir?ke.row-Ve.row:ke.dir==="up"?-1:1).forEach((ke,Ve)=>{const tt=Je[Ve].band;if(tt!==ke.band){Ne.add(X.node.id);for(const qt of ke.subtree)ne(qt)===ke.band&&U.set(qt.node.id,tt)}})}const Ut=X=>{if(!M)return;const te=new Set(X.map(Je=>Je.node.id));let ae=!1,be=!1;for(const Je of S){if(!te.has(Je.flow.target))continue;const Ge=it(Je.flow.source);!Ge||Ge.id===M.id||(Ge.y<M.y?ae=!0:be=!0)}return ae&&!be?"up":be&&!ae?"down":void 0};for(const X of R.nodes){if(!rt(X.node.type))continue;const te=X.node.lane??`pool:${w}`,ae=se.get(te);if(!ae||ae.size<2)continue;const be=ae.get(0);if(be===void 0)continue;const Je=Math.max(...ae.values()),Ge=be===Je&&be!==0?"down":void 0;if(!Ge)continue;const ke=[];for(const $t of R.flows){if($t.flow.source!==X.node.id)continue;const ei=C.get($t.flow.target);if(!ei||ei.node.lane!==X.node.lane||(ue.get(ei.node.id)??0)!==1)continue;const c0=V(ei);c0!==void 0&&ke.push({t:ei,subtree:dt(ei.node.id),band:c0})}const Ve=ke.find($t=>(ae.get($t.band)??$t.band)===be);if(!Ve||Ut(Ve.subtree)===Ge||et(Ve.subtree)===Ge)continue;const tt=ke.find($t=>$t!==Ve&&Ut($t.subtree)===Ge);if(!tt)continue;const qt=Ve.band,At=tt.band;for(const $t of Ve.subtree)V($t)===qt&&U.set($t.node.id,At);for(const $t of tt.subtree)V($t)===At&&U.set($t.node.id,qt);Ne.add(X.node.id)}for(const X of R.nodes){if(!rt(X.node.type))continue;const te=we(X);if(Number.isNaN(te)||E.some(ke=>{var Ve,tt;return(((Ve=ke.placement)==null?void 0:Ve.anchor)??(ke.association?ke.association.source===ke.annotation.id?ke.association.target:ke.association.source:void 0))===X.node.id&&((tt=ke.placement)==null?void 0:tt.side.startsWith("bottom"))}))continue;let be,Je=!1,Ge;for(const ke of R.flows){if(ke.flow.source!==X.node.id)continue;const Ve=C.get(ke.flow.target);if(!Ve||!Ve.node.lane&&ne(Ve)===void 0)continue;const tt=we(Ve);Number.isNaN(tt)||(Math.abs(tt-te)<.5&&(Je=!0),tt>te?!be||tt>be.row?be={id:Ve.node.id,row:tt,count:1}:tt===be.row&&be.count++:tt<te&&Ve.node.lane===X.node.lane&&(!Ge||tt>Ge.row?Ge={op:Ve,row:tt,count:1}:tt===Ge.row&&Ge.count++))}be&&be.count===1&&(ue.get(be.id)??0)===1&&!Ne.has(X.node.id)&&Me.add(be.id),!Je&&Ge&&Ge.count===1&&(ue.get(Ge.op.node.id)??0)===1&&!Z.has(X.node.id)&&pe.set(Ge.op.node.id,{lane:X.node.lane,band:V(X)})}const Jt=new Map;for(const X of S)Jt.set(X.flow.target,[...Jt.get(X.flow.target)??[],X]);for(const X of R.nodes){const te=Jt.get(X.node.id);if(!te||te.length!==1||!ue.get(X.node.id)||!X.node.lane&&ne(X)===void 0||Fe.has(X.node.id))continue;const ae=(Fx=C.get(te[0].flow.source))==null?void 0:Fx.node.participant,be=ae?l(ae):void 0;if(!be||!M||be.id===M.id)continue;const Je=X.node.lane??`pool:${w}`,Ge=se.get(Je);if(!Ge)continue;const ke=Ge.get(0)??0,Ve=(Ge.get(V(X)??0)??ke)-ke;if(Ve===0)continue;const tt=be.y<M.y;if(tt&&Ve<0||!tt&&Ve>0)continue;let qt;for(const[At,$t]of Ge){const ei=$t-ke;(tt&&ei<0&&(!qt||ei<qt.row)||!tt&&ei>0&&(!qt||ei>qt.row))&&(qt={band:At,row:ei})}qt&&ve.set(X.node.id,{lane:X.node.lane,band:qt.band})}}const Ce=new Set;let $e=0;for(;$e++<R.nodes.length+2;){for(let Ne=0;Ne<R.nodes.length+R.flows.length+2;Ne++){let it=!1;for(const dt of R.flows){const et=dt.flow;if(Ce.has(et.id))continue;const Ut=l(et.source);if(!Ut)continue;const Jt=l(et.target),X=C.get(et.target);if(!Jt&&X){const te=Qe(X.node,X.band),ae=V(X);if(X.node.lane||ae!==void 0){const be=ce(X.node),Je=Ut,Ge=Je.x+(ot.get(et.source)??0)+Je.width+O,ke=pe.get(et.target)??ve.get(et.target),Ve=xe(be,te,ke?ke.lane:X.node.lane,ke?ke.band:ae,Me.has(et.target)?Je.x+Je.width/2:Ge,Number.NaN),tt=n.createShape(te,Ve,be);Me.has(et.target)&&ot.set(et.target,Ge-(tt.x+tt.width/2)),n.connect(Ut,tt,{type:"bpmn:SequenceFlow",businessObject:Be(et)})}else s.append(Ut,te,{connection:{type:"bpmn:SequenceFlow",businessObject:Be(et)}})}else if(Jt)n.connect(Ut,Jt,{type:"bpmn:SequenceFlow",businessObject:Be(et)});else continue;Ce.add(et.id),it=!0}if(!it)break}const ue=R.nodes.filter(Ne=>!l(Ne.node.id));if(!ue.length)break;const we=ue[0];{const Ne=Qe(we.node,we.band),it=ce(we.node),dt=ne(we);n.createShape(Ne,xe(it,Ne,we.node.lane,dt,F,H),it),!we.node.lane&&dt===void 0&&(H+=160)}}}const Nt=40,Pt=(w,R=()=>!0)=>{const M=l(w);if(!M)return[];const F=[M],H=new Set([w]);for(let I=0;I<F.length;I++){const Y=F[I].id;for(const G of m){const W=G.flow.target;if(G.flow.source!==Y||H.has(W)||!C.has(W))continue;H.add(W);const ce=l(W);ce&&R(ce)&&F.push(ce)}}return F},vn=(w,R=()=>!0)=>{const M=l(w);if(!M)return[];const F=[M],H=new Set([w]);for(let I=0;I<F.length;I++){const Y=F[I].id;for(const G of m){const W=G.flow.source;if(G.flow.target!==Y||H.has(W)||!C.has(W))continue;H.add(W);const ce=l(W);ce&&R(ce)&&F.push(ce)}}return F};for(const w of Xt(e,"sequenceFlow.update")){if(w.target===void 0)continue;const R=C.get(w.target);if(!R)continue;const M=l(w.target),F=l(w.id);if(!M||!F)continue;const H=w.source!==void 0?l(w.source):F.source,I=F.target;if(!H||!I||I.id===M.id)continue;const Y=Pt(w.target),G=new Set(Y.map(pe=>pe.id)),W=Math.min(...Y.map(pe=>pe.x)),ce=Math.max(...Y.map(pe=>pe.x+pe.width)),xe=H.x+H.width,Re=ce-W+Nt*2-(I.x-xe);if(Re>0){const pe=f(M),ve=(pe==null?void 0:pe.children)??[],ot=ue=>ue.type==="bpmn:Lane",Ce=ve.filter(ue=>!("waypoints"in ue&&ue.waypoints)&&!ot(ue)&&!G.has(ue.id)&&ue.x>=I.x),$e=pe?[pe,...ve.filter(ue=>ot(ue))]:[];Ce.length&&n.createSpace(Ce,$e,{x:Re,y:0},"e",I.x-1)}const oe=R.node.lane||R.band!==void 0?M.y+M.height/2:H.y+H.height/2;n.moveElements(Y,{x:xe+Nt-W,y:oe-(M.y+M.height/2)});const Me=f(M);if(R.node.lane===void 0&&R.band!==void 0&&Me){const pe=Me.y+$+Rt(`pool:${R.node.participant??""}`,R.band)*k,ve=pe-(M.y+M.height/2);ve!==0&&!q(Me,M,M.x+M.width/2,pe,G)&&n.moveElements([M],{x:0,y:ve})}}const pt=(w,R)=>{const M=R.target===w,F=p(R.source),H=p(R.target),I=M?"bpmn:DataOutputAssociation":"bpmn:DataInputAssociation";n.connect(F,H,R.id?{type:I,businessObject:i.create(I,{id:R.id})}:{type:I})},Vt=100,dn=w=>{for(const R of g){if(!R.participant.blackBox)continue;const M=l(R.participant.id);if(!M)continue;const F=[];for(const I of S){const Y=I.flow.source===R.participant.id?I.flow.target:I.flow.target===R.participant.id?I.flow.source:void 0,G=Y?l(Y):void 0;G&&typeof G.x=="number"&&G.type!=="bpmn:Participant"&&F.push(G)}if(!F.length)continue;const H=Math.max(...F.map(I=>I.x+I.width/2))+Vt;if(H>M.x+M.width&&n.resizeShape(M,{x:M.x,y:M.y,width:H-M.x,height:M.height}),!!w)for(const I of S){const Y=l(I.flow.id),G=I.flow.source===R.participant.id?I.flow.target:I.flow.target===R.participant.id?I.flow.source:void 0,W=G?l(G):void 0;if(!Y||!W||W.type==="bpmn:Participant")continue;const ce=W.x+W.width/2;if(ce<M.x+10||ce>M.x+M.width-10)continue;const xe=M.y>W.y,Re=xe?W.y+W.height:W.y,oe=xe?M.y:M.y+M.height,Me=I.flow.source===R.participant.id?[{x:ce,y:oe},{x:ce,y:Re}]:[{x:ce,y:Re},{x:ce,y:oe}],pe=wt(o),ve={...pe.edges.find(ot=>ot.id===I.flow.id),waypoints:Me};Fn(ve,ci(pe)).length||n.updateWaypoints(Y,Me)}}};dn(!1);for(const w of S){const R=w.flow;n.connect(p(R.source),p(R.target),{type:"bpmn:MessageFlow",businessObject:i.create("bpmn:MessageFlow",{id:R.id,name:R.name})})}{const M=new Set([...m.map(W=>W.flow.id),...S.map(W=>W.flow.id)].filter(W=>!!W)),F=o.filter(W=>!!W.waypoints),H=(W,ce)=>Math.abs(ce.x-W.x)<2?"L":Math.abs(ce.x-(W.x+W.width))<2?"R":Math.abs(ce.y-W.y)<2?"T":Math.abs(ce.y-(W.y+W.height))<2?"B":void 0,I=new Map,Y=(W,ce,xe)=>{if(!W||!ce||typeof W.x!="number")return;const Re=H(W,ce);if(!Re)return;let oe=I.get(W.id);oe||I.set(W.id,oe=new Map),oe.set(Re,[...oe.get(Re)??[],xe])};for(const W of F){const ce=W.waypoints;!ce||ce.length<2||(Y(W.source,ce[0],{id:W.id,dir:"out"}),Y(W.target,ce[ce.length-1],{id:W.id,dir:"in"}))}const G=new Set;for(const[W,ce]of I){const xe=l(W);if(!xe||typeof xe.x!="number"||![...ce.values()].some($e=>{const ue=$e.filter(we=>we.dir==="in");return $e.length>=3&&ue.length>=1&&$e.some(we=>we.dir==="out")&&ue.some(we=>M.has(we.id))}))continue;const oe=f(xe);if(!oe||G.has(oe.id)||(oe.children??[]).some($e=>$e.type==="bpmn:Lane"))continue;const Me=(Hx=ce.get("T"))!=null&&Hx.length?(zx=ce.get("B"))!=null&&zx.length?void 0:"B":"T";if(!Me||(Me==="T"?xe.y-oe.y:oe.y+oe.height-(xe.y+xe.height))>=k)continue;const ve=(oe.children??[]).filter($e=>!("waypoints"in $e&&$e.waypoints)&&$e.type!=="label"&&typeof $e.x=="number"),ot=oe.y+oe.height;n.resizeShape(oe,{x:oe.x,y:oe.y,width:oe.width,height:oe.height+k});const Ce=u().children.filter($e=>!("waypoints"in $e&&$e.waypoints)&&$e.id!==oe.id&&typeof $e.y=="number"&&$e.y>=ot);Ce.length&&n.moveElements(Ce,{x:0,y:k}),Me==="T"&&ve.length&&n.moveElements(ve,{x:0,y:k}),G.add(oe.id)}}const Pr=20,wn=30,ri=4,Jn=2,Wt=[10,30,80],qi=w=>!("waypoints"in w&&w.waypoints)&&w.type!=="bpmn:Lane"&&w.type!=="label"&&typeof w.x=="number",Yi=()=>{const w=wt(o);return{bad:Ti(w).filter(R=>R.kind==="edge-crosses-shape"||R.kind==="edge-overlap-opposite"||R.kind==="edge-overlap-mixed").length,crossings:Id(w),straight:w.edges.filter(R=>R.type==="bpmn:MessageFlow"&&R.waypoints.length===2).length}},an=w=>{const R=wt(o),M=R.edges.find(F=>F.id===w);return M?Fn(M,ci(R)).length:0},Ke=w=>an(w)>0,nt=w=>wt(o).edges.filter(R=>R.type==="bpmn:MessageFlow"&&R.id!==w&&R.waypoints.length===2).length,Vf=(w,R)=>{const M=new Set(w.flatMap(I=>I.subtree.map(Y=>Y.id)));for(const I of w){const Y=(I.pool.children??[]).filter(qi).filter(W=>!M.has(W.id));if(I.subtree.some(W=>Y.some(ce=>W.x+R<ce.x+ce.width+wn&&W.x+R+W.width+wn>ce.x&&W.y<ce.y+ce.height&&W.y+W.height>ce.y)))return null}const F=w.map(I=>I.pool.width);n.moveElements(w.flatMap(I=>I.subtree),{x:R,y:0});const H=w.map(I=>{const G=Math.max(...I.subtree.map(W=>W.x+W.width))+150-(I.pool.x+I.pool.width);return G>0&&n.resizeShape(I.pool,{x:I.pool.x,y:I.pool.y,width:I.pool.width+G,height:I.pool.height}),G});return()=>{n.moveElements(w.flatMap(I=>I.subtree),{x:-R,y:0}),w.forEach((I,Y)=>{H[Y]>0&&n.resizeShape(I.pool,{x:I.pool.x,y:I.pool.y,width:F[Y],height:I.pool.height})})}},MD=(w,R,M)=>Vf([{subtree:w,pool:R}],M),Px=(w,R)=>R.bad>w.bad||R.crossings>w.crossings&&R.straight<=w.straight&&R.bad>=w.bad,wu=(w,R)=>Px(w,R)||R.straight<w.straight,Eu=(w,R,M=()=>!0,F=Px)=>{const H=Yi(),I=Vf(w,R);if(!I)return!1;const Y=Yi();return F(H,Y)||!M()?(I(),!1):!0},Ax=(w,R,M,F=()=>!0)=>Eu([{subtree:w,pool:R}],M,F),Zr=w=>{var R;return!!((R=C.get(w))!=null&&R.node.participant)},Ka=new Map;for(const w of S){if(!Zr(w.flow.target))continue;const R=Ka.get(w.flow.target)??[];R.push(w),Ka.set(w.flow.target,R)}const Wf=[...Ka.keys()],Tx=new Set(m.map(w=>w.flow.target)),Mx=w=>v.findIndex(({op:R})=>R.participant.id===w);Wf.sort((w,R)=>{var H,I;const M=Tx.has(w)?1:0,F=Tx.has(R)?1:0;return M!==F?M-F:Mx((H=C.get(w))==null?void 0:H.node.participant)-Mx((I=C.get(R))==null?void 0:I.node.participant)});const Qr=w=>w.x+w.width/2,kD=w=>{const R=new Map;for(const H of o.getAll()){const I=H;if(!I.waypoints||!I.source||!I.target)continue;(R.get(I.source.id)??R.set(I.source.id,[]).get(I.source.id)).push(I.target.id)}const M=new Set([w]),F=[w];for(let H=0;H<F.length;H++)for(const I of R.get(F[H])??[])M.has(I)||(M.add(I),F.push(I));return M},OD=(w,R)=>{const M=kD(R);let F;for(const H of o.getAll()){const I=H;if(I.type!=="bpmn:MessageFlow"||!I.source||!I.target||I.target.id!==w||M.has(I.source.id))continue;const Y=I.source;if(typeof Y.x!="number"||Y.type==="bpmn:Participant")continue;const G=Qr(Y);(F===void 0||G>F)&&(F=G)}return F},Uf=(w,R)=>{const M=l(w.flow.source);if(M)return M.type==="bpmn:Participant"?OD(M.id,R):Qr(M)},kx=w=>{let R;for(const M of Ka.get(w)??[]){const F=Uf(M,w);F!==void 0&&(!R||F>R.cx)&&(R={op:M,cx:F})}return R==null?void 0:R.op},DD=w=>{const R=kx(w),M=l(w),F=R?Uf(R,w):void 0;return M&&F!==void 0?F-Qr(M):void 0},LD=w=>{const R=DD(w);return R!==void 0&&Math.abs(R)<Pr},Ox=(w,R,M,F,H)=>{var I;for(let Y=!0;Y;){Y=!1;for(const G of S){if(G.flow.id===M)continue;const W=R.has(G.flow.source),ce=R.has(G.flow.target);if(W===ce||F(W?G.flow.source:G.flow.target))continue;const xe=W?G.flow.target:G.flow.source;if(H(xe)||!Zr(xe))continue;const Re=l(G.flow.id);if(!(Re!=null&&Re.waypoints)||Re.waypoints.length!==2)continue;const oe=l(xe),Me=(I=C.get(xe))==null?void 0:I.node.participant;if(!oe||!Me)continue;const pe=Pt(xe,ve=>ve.x>=oe.x).filter(ve=>!R.has(ve.id));if(!(!pe.length||pe.some(ve=>H(ve.id)))){for(const ve of pe)R.add(ve.id);w.set(Me,[...w.get(Me)??[],...pe]),Y=!0}}}return[...w].map(([Y,G])=>({subtree:G,pool:p(Y)}))},Dx=(w,R,M,F,H)=>Ox(new Map([[R,[...w]]]),new Set(w.map(I=>I.id)),F,I=>I===M,I=>I===H),qf=w=>{const R=kx(w);if(!R)return null;const M=l(w),F=l(R.flow.source),H=Uf(R,w);if(!M||!F||H===void 0)return null;const I=H-Qr(M);if(I>=Pr){const Y=C.get(w).node.participant,G=Pt(w,W=>W.x>=M.x);return{groups:Dx(G,Y,w,R.flow.id,R.flow.source),dx:I}}if(-I>=Pr&&Zr(R.flow.source)){const Y=C.get(R.flow.source).node.participant,G=Pt(R.flow.source,W=>W.x>=F.x&&!LD(W.id));return{groups:Dx(G,Y,R.flow.source,R.flow.id,w),dx:-I}}return null},Lx=()=>Wf.map(w=>({id:w,plan:qf(w)})).filter(w=>!!w.plan).sort((w,R)=>Math.min(...w.plan.groups.flatMap(M=>M.subtree.map(F=>F.x)))-Math.min(...R.plan.groups.flatMap(M=>M.subtree.map(F=>F.x)))).map(w=>w.id);for(let w=0;w<3;w++){const R=Yi(),M=[];for(const H of Lx()){const I=qf(H);if(!I)continue;const Y=Vf(I.groups,I.dx);Y&&M.push(Y)}if(!M.length)break;if(!wu(R,Yi()))continue;for(const H of M.reverse())H();let F=!1;for(const H of Lx()){const I=qf(H);I&&Eu(I.groups,I.dx,()=>!0,wu)&&(F=!0)}if(!F)break}for(const w of Wf.flatMap(R=>Ka.get(R)??[])){if(!Ke(w.flow.id))continue;const R=l(w.flow.target);if(!R)continue;const M=p(C.get(w.flow.target).node.participant),F=Pt(w.flow.target,G=>G.x>=R.x),H=R.width+O,I=an(w.flow.id),Y=nt(w.flow.id);for(let G=1;G<=ri;G++){const W=()=>an(w.flow.id)<I&&nt(w.flow.id)>=Y;if(Ax(F,M,H*G,W))break}}for(const w of S){if(!Ke(w.flow.id))continue;const R=l(w.flow.source),M=l(w.flow.target);if(!R||!M||R.type==="bpmn:Participant"||M.type==="bpmn:Participant")continue;const F=R.x+R.width/2;if(Math.abs(F-(M.x+M.width/2))>15)continue;const[H,I]=R.y<M.y?[R.y+R.height,M.y]:[M.y+M.height,R.y],Y=[...C.values()].map(G=>l(G.node.id)).filter(G=>!!G&&G.id!==R.id&&G.id!==M.id).filter(G=>G.x<=F&&F<=G.x+G.width&&G.y+G.height>H&&G.y<I).sort((G,W)=>G.x-W.x);for(const G of Y){const W=(Gx=C.get(G.id))==null?void 0:Gx.node.participant,ce=W?l(W):void 0;if(!ce)continue;const xe=[...C.values()].filter(ue=>ue.node.participant===W).map(ue=>ue.node.id),Re=ue=>ue.map(we=>l(we)).filter(we=>!!we),Me=[vn(G.id,ue=>{var we;return((we=C.get(ue.id))==null?void 0:we.node.participant)===W}),Re(xe)].filter(ue=>ue.length),pe=G.width+O,ve=an(w.flow.id),ot=nt(w.flow.id),Ce=()=>an(w.flow.id)<ve&&nt(w.flow.id)>=ot;let $e=!1;for(const ue of Me){for(let we=1;we<=ri;we++)if(Ax(ue,ce,pe*we,Ce)){$e=!0;break}if($e)break}if(!Ke(w.flow.id))break}}for(const w of S){if(!Ke(w.flow.id))continue;const R=l(w.flow.id);if(((Vx=R==null?void 0:R.waypoints)==null?void 0:Vx.length)!==2)continue;const M=l(w.flow.source),F=l(w.flow.target);if(!M||!F||M.type==="bpmn:Participant"||F.type==="bpmn:Participant"||!Zr(w.flow.source)||!Zr(w.flow.target)||Math.abs(Qr(M)-Qr(F))>Jn)continue;const H=Qr(M),I=R.waypoints.map(ve=>ve.y),[Y,G]=[Math.min(...I),Math.max(...I)],W=ci(wt(o)).filter(ve=>ve.id!==M.id&&ve.id!==F.id&&ve.x<H&&H<ve.x+ve.width&&Y<ve.y+ve.height&&ve.y<G);if(!W.length)continue;const ce=(Wx=C.get(w.flow.source))==null?void 0:Wx.node.participant,xe=(Ux=C.get(w.flow.target))==null?void 0:Ux.node.participant;if(!ce||!xe)continue;const Re=new Map;for(const[ve,ot,Ce]of[[w.flow.source,M,ce],[w.flow.target,F,xe]]){const $e=Re.get(Ce)??[],ue=Pt(ve,we=>we.x>=ot.x).filter(we=>!$e.some(Ne=>Ne.id===we.id));Re.set(Ce,[...$e,...ue])}const oe=new Set([...Re.values()].flat().map(ve=>ve.id)),Me=Ox(Re,oe,w.flow.id,ve=>ve===w.flow.source||ve===w.flow.target,()=>!1),pe=Math.max(...W.map(ve=>ve.x+ve.width));for(const ve of Wt){const ot=pe+ve-H;if(ot<=0)continue;if(Eu(Me,ot,()=>{var $e,ue;return an(w.flow.id)===0&&((ue=($e=l(w.flow.id))==null?void 0:$e.waypoints)==null?void 0:ue.length)===2},wu))break}}{const w=M=>M.y+M.height/2,R=[];for(const M of C.keys()){if(!Zr(M))continue;const F=m.filter(Y=>Y.flow.target===M);if(F.length!==1)continue;const H=l(F[0].flow.source),I=l(M);!H||!I||!C.has(H.id)||Math.abs(w(H)-w(I))>1||I.x-(H.x+H.width)<=O+1||R.push({id:M,pred:H,node:I})}R.sort((M,F)=>M.node.x-F.node.x);for(const{id:M}of R){const F=C.get(M),H=l(M),I=l(m.find(oe=>oe.flow.target===M).flow.source);if(!H||!I)continue;const Y=H.x-(I.x+I.width);if(Y<=O+1)continue;const G=p(F.node.participant),W=Pt(M,oe=>oe.x>=H.x),ce=Yi(),xe=MD(W,G,-(Y-O));if(!xe)continue;const Re=Yi();(Re.bad>ce.bad||Re.crossings>=ce.crossings||Re.straight<ce.straight)&&xe()}}dn(!0);for(const w of y){const R=w.associations??[],M=R.map(I=>I.source===w.dataStore.id?I.target:I.source).map(l).find(Boolean),F=M?f(M)??u():u(),H=M?{x:M.x+M.width/2,y:M.y+M.height+110}:{x:200,y:N+60};n.createShape({type:"bpmn:DataStoreReference",businessObject:i.create("bpmn:DataStoreReference",{id:w.dataStore.id,name:w.dataStore.name})},H,F);for(const I of R)pt(w.dataStore.id,I)}for(const w of _){const M=p(w.association.target).type==="bpmn:DataStoreReference"?w.association.target:w.association.source;pt(M,w.association)}let Ix=0;const Su=10,ID=(w,R)=>{for(const M of R.map(F=>f(F)).filter(F=>!!F)){const F=Su,H=M.y,I=M.y+M.height,Y=M.x,G=M.x+M.width;if(Math.abs(w.y-H)<F){const W=H+F-w.y;w.y+=W,w.height-=W}if(Math.abs(w.y+w.height-I)<F&&(w.height=I-F-w.y),Math.abs(w.x-Y)<F){const W=Y+F-w.x;w.x+=W,w.width-=W}Math.abs(w.x+w.width-G)<F&&(w.width=G-F-w.x)}},BD=(w,R)=>{const M=Su,F=30,H=o.filter(I=>I.type==="bpmn:Group"&&I.id!==R);for(const I of H){const Y=I.x,G=I.x+I.width,W=I.y,ce=I.y+I.height,xe=w.y<ce&&W<w.y+w.height,Re=w.x<G&&Y<w.x+w.width;if(xe){if(Math.abs(w.x-G)<M){const oe=Math.min(G+M-w.x,F);oe>0&&w.width-oe>0&&(w.x+=oe,w.width-=oe)}if(Math.abs(w.x+w.width-Y)<M){const oe=Math.min(w.x+w.width-(Y-M),F);oe>0&&w.width-oe>0&&(w.width-=oe)}}if(Re){if(Math.abs(w.y-ce)<M){const oe=Math.min(ce+M-w.y,F);oe>0&&w.height-oe>0&&(w.y+=oe,w.height-=oe)}if(Math.abs(w.y+w.height-W)<M){const oe=Math.min(w.y+w.height-(W-M),F);oe>0&&w.height-oe>0&&(w.height-=oe)}}}},Yf=(w,R)=>{const F=Math.min(...w.map(W=>W.x))-40,H=Math.min(...w.map(W=>W.y))-40,I=Math.max(...w.map(W=>W.x+W.width))+40,Y=Math.max(...w.map(W=>W.y+W.height))+40,G={x:F,y:H,width:I-F,height:Y-H};return ID(G,w),BD(G,R),G};for(const w of P){const R=(w.group.members??[]).map(l).filter(H=>!!H);let M;R.length?M=Yf(R,w.group.id):(M={x:300+Ix*350,y:40,width:300,height:200},Ix++);const F=n.createShape({type:"bpmn:Group",businessObject:i.create("bpmn:Group",{id:w.group.id}),width:M.width,height:M.height},{x:M.x+M.width/2,y:M.y+M.height/2},u());w.group.name&&n.updateLabel(F,w.group.name),(qx=w.group.members)!=null&&qx.length&&D(F,"bwl:Members",{refs:w.group.members.join(" ")})}{const w=o.filter(H=>!!H.waypoints),R=new Map,M=(H,I)=>{!H||!I||(R.has(H)||R.set(H,new Set),R.get(H).add(I))};for(const H of w){const I=(Yx=H.source)==null?void 0:Yx.id,Y=(Kx=H.target)==null?void 0:Kx.id;M(I,Y),((Xx=H.type)!=null&&Xx.includes("DataOutputAssociation")||(Zx=H.type)!=null&&Zx.includes("DataInputAssociation")||H.type==="bpmn:Association")&&M(Y,I)}const F=o.filter(H=>H.type==="bpmn:Group");for(const H of F){const Y=(((Qx=H.businessObject.extensionElements)==null?void 0:Qx.values)??[]).find(Ce=>Ce.$type==="bwl:Members"),G=((Y==null?void 0:Y.refs)??"").split(" ").filter(Boolean);if(!G.length)continue;const W=new Set(G),ce=[...G];for(;ce.length;){const Ce=ce.shift();for(const $e of R.get(Ce)??[])W.has($e)||(W.add($e),ce.push($e))}const xe=H.x,Re=H.x+H.width,oe=H.y,Me=H.y+H.height,pe=Ce=>m.filter($e=>$e.flow.target===Ce).length,ve=Ce=>{var ue;const $e=((ue=l(Ce))==null?void 0:ue.type)??"";if($e==="bpmn:StartEvent"&&pe(Ce)===0)return!1;if($e.endsWith("Gateway")){const we=m.filter(Ne=>Ne.flow.target===Ce).map(Ne=>Ne.flow.source);if(we.length&&we.every(Ne=>{var it;return((it=l(Ne))==null?void 0:it.type)==="bpmn:StartEvent"&&pe(Ne)===0}))return!1}return!0},ot=o.filter(Ce=>qi(Ce)).filter(Ce=>Ce.type!=="bpmn:Group"&&Ce.type!=="bpmn:Participant"&&Ce.type!=="bpmn:TextAnnotation"&&!W.has(Ce.id)&&Zr(Ce.id)&&ve(Ce.id)&&Ce.x<Re&&Ce.x+Ce.width>xe&&Ce.y<Me&&Ce.y+Ce.height>oe);if(ot.length)for(const Ce of[-1,1]){const $e=ot.filter(X=>(X.x+X.width-xe<=Re-X.x?-1:1)===Ce);if(!$e.length)continue;const ue=[];for(const X of $e){const te=ue.find(ae=>ae.some(be=>X.y<be.y+be.height&&X.y+X.height>be.y));te?te.push(X):ue.push([X])}const we=new Map;for(const X of ue){let te=Ce<0?xe-Su:Re+Su;for(const ae of[...X].sort((be,Je)=>Ce<0?Je.x-be.x:be.x-Je.x)){const be=Ce<0?Math.min(ae.x,te-ae.width):Math.max(ae.x,te);te=Ce<0?be-wn:be+ae.width+wn,be!==ae.x&&Math.sign(be-ae.x)===Ce&&we.set(ae.id,be-ae.x)}}const Ne=new Map,it=X=>Ne.get(X)===X||!Ne.get(X)?X:it(Ne.get(X));for(const X of $e)Ne.set(X.id,X.id);for(const X of S){const te=we.has(X.flow.source)?X.flow.source:void 0,ae=we.has(X.flow.target)?X.flow.target:void 0;if(!te||!ae)continue;const be=l(X.flow.id);((Jx=be==null?void 0:be.waypoints)==null?void 0:Jx.length)===2&&Ne.set(it(te),it(ae))}const dt=new Map;for(const X of $e){if(!we.has(X.id))continue;const te=it(X.id);dt.set(te,[...dt.get(te)??[],X])}const et=[...dt.values()].sort((X,te)=>Ce<0?Math.min(...X.map(ae=>ae.x))-Math.min(...te.map(ae=>ae.x)):Math.max(...te.map(ae=>ae.x))-Math.max(...X.map(ae=>ae.x))),Ut=[];let Jt=!0;for(const X of et){const te=X.map(Je=>we.get(Je.id)??0).reduce((Je,Ge)=>Math.abs(Ge)>Math.abs(Je)?Ge:Je,0),ae=new Map;let be=!0;for(const Je of X){const Ge=f(Je);if(!Ge){be=!1;break}ae.has(Ge.id)||ae.set(Ge.id,{subtree:[],pool:Ge}),ae.get(Ge.id).subtree.push(Je)}be&&Eu([...ae.values()],te,()=>!0,wu)?Ut.push({shapes:X,dx:te}):Jt=!1}if(!Jt)for(const X of Ut.reverse())n.moveElements(X.shapes,{x:-X.dx,y:0})}}}{const w=new Set([...P.map(R=>R.group.id),...Xt(e,"group.update").map(R=>R.id)]);for(const R of o.filter(M=>M.type==="bpmn:Group")){if(w.has(R.id))continue;const F=(((e0=R.businessObject.extensionElements)==null?void 0:e0.values)??[]).find(G=>G.$type==="bwl:Members"),H=((F==null?void 0:F.refs)??"").split(" ").filter(Boolean).map(l).filter(G=>!!G);!H.length||!H.some(G=>{const W=d.get(G.id);return!W||W.x!==G.x||W.y!==G.y})||!H.some(G=>G.x<R.x||G.y<R.y||G.x+G.width>R.x+R.width||G.y+G.height>R.y+R.height)||n.resizeShape(R,Yf(H,R.id))}}{const R=new Map(uo(wt(o)).map(G=>[G.owner,G.rect])),M=o.filter(G=>!!G.waypoints),F=new Map,H=(G,W)=>{!G||!W||(F.has(G)||F.set(G,new Set),F.get(G).add(W))};for(const G of M){const W=(t0=G.source)==null?void 0:t0.id,ce=(n0=G.target)==null?void 0:n0.id;H(W,ce),((i0=G.type)!=null&&i0.includes("DataOutputAssociation")||(r0=G.type)!=null&&r0.includes("DataInputAssociation")||G.type==="bpmn:Association")&&H(ce,W)}const I=G=>m.filter(W=>W.flow.target===G).length,Y=G=>{var ce;const W=((ce=l(G))==null?void 0:ce.type)??"";if(W==="bpmn:StartEvent"&&I(G)===0)return!1;if(W.endsWith("Gateway")){const xe=m.filter(Re=>Re.flow.target===G).map(Re=>Re.flow.source);if(xe.length&&xe.every(Re=>{var oe;return((oe=l(Re))==null?void 0:oe.type)==="bpmn:StartEvent"&&I(Re)===0}))return!1}return!0};for(const G of o.filter(W=>W.type==="bpmn:Group")){const ce=(((o0=G.businessObject.extensionElements)==null?void 0:o0.values)??[]).find(te=>te.$type==="bwl:Members"),xe=((ce==null?void 0:ce.refs)??"").split(" ").filter(Boolean);if(!xe.length)continue;const Re=xe.map(l).filter(te=>!!te);if(!Re.length||!(P.some(te=>te.group.id===G.id)||Xt(e,"group.update").some(te=>te.id===G.id)||Re.some(te=>{const ae=d.get(te.id);return!ae||ae.x!==te.x||ae.y!==te.y})))continue;const Me=new Set(xe),pe=[...xe];for(;pe.length;){const te=pe.shift();for(const ae of F.get(te)??[])Me.has(ae)||(Me.add(ae),pe.push(ae))}const ve=G.x,ot=G.x+G.width,Ce=G.y,$e=G.y+G.height,ue=te=>{const ae=R.get(te.id),be={x:te.x,y:te.y,width:te.width,height:te.height};return ae?[be,{x:ae.x,y:ae.y,width:ae.width,height:ae.height}]:[be]},we=Re.flatMap(ue),Ne=Math.min(...we.map(te=>te.x)),it=Math.max(...we.map(te=>te.x+te.width)),dt=Math.min(...we.map(te=>te.y)),et=Math.max(...we.map(te=>te.y+te.height)),Ut={L:Ne-ve,R:ot-it,T:dt-Ce,B:$e-et},Jt=o.filter(te=>qi(te)).filter(te=>te.type!=="bpmn:Group"&&te.type!=="bpmn:Participant"&&te.type!=="bpmn:TextAnnotation"&&!Me.has(te.id)&&Y(te.id)&&te.x<ot&&te.x+te.width>ve&&te.y<$e&&te.y+te.height>Ce);if(!Jt.length)continue;const X={L:0,R:0,T:0,B:0};for(const te of Jt){const ae=ue(te),be=Math.min(...ae.map(At=>At.x)),Je=Math.max(...ae.map(At=>At.x+At.width)),Ge=Math.min(...ae.map(At=>At.y)),ke=Math.max(...ae.map(At=>At.y+At.height)),Ve={L:Je-ve,R:ot-be,T:ke-Ce,B:$e-Ge},tt=["L","R","T","B"].filter(At=>Ve[At]<=Ut[At]+.001);if(!tt.length)continue;const qt=tt.reduce((At,$t)=>Ve[$t]<Ve[At]?$t:At,tt[0]);X[qt]=Math.max(X[qt],Math.min(Ve[qt]+10,Ut[qt]))}!X.L&&!X.R&&!X.T&&!X.B||n.resizeShape(G,{x:G.x+X.L,y:G.y+X.T,width:G.width-X.L-X.R,height:G.height-X.T-X.B})}}const Bx=w=>{const R=w.waypoints;if(R!=null&&R.length){const F=R[Math.floor((R.length-1)/2)];return{x:F.x,y:F.y,width:0,height:0}}const M=w;return{x:M.x,y:M.y,width:M.width,height:M.height}};let Xa=0;const Nx=12,$x=14,ND=15,$D=300,jD=w=>{const R=w.split(`
7
7
  `),M=Math.max(...R.map(I=>so(I,Nx))),F=Math.max(100,Math.min($D,Math.ceil(M)+$x)),H=R.reduce((I,Y)=>I+Math.max(1,Math.ceil((so(Y,Nx)+$x)/F)),0);return{width:F,height:Math.max(30,H*ND+10)}};for(const w of E){const R=w.association,M=((a0=w.placement)==null?void 0:a0.anchor)??(R?R.source===w.annotation.id?R.target:R.source:void 0),F=M?l(M):void 0,H=F?Bx(F):void 0,I=jD(w.annotation.text??"");let Y;if(H&&w.placement){const[xe,Re]=ys[w.placement.side],oe=w.placement.offset??50;Y={x:H.x+H.width/2+xe*(H.width/2+I.width/2+oe),y:H.y+H.height/2+Re*(H.height/2+I.height/2+oe)}}else H?(Y={x:H.x+H.width/2+180+Xa%3*260,y:H.y-110-Xa%2*95},Xa++):(Y={x:300+Xa*260,y:60},Xa++);const G=F?f(F)??u():u(),W=G;H&&typeof W.x=="number"&&typeof W.width=="number"&&W.type==="bpmn:Participant"&&(Y=Qu(o,H,I,W,w.placement?{placement:w.placement}:{from:Y}));const ce=n.createShape({type:"bpmn:TextAnnotation",width:I.width,height:I.height,businessObject:i.create("bpmn:TextAnnotation",{id:w.annotation.id,text:w.annotation.text})},Y,G);if(R){const xe=Re=>Re===w.annotation.id?ce:p(Re);n.connect(xe(R.source),xe(R.target),R.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:R.id})}:{type:"bpmn:Association"})}w.placement&&D(ce,"bwl:Placement",A(w.placement))}for(const w of Xt(e,"association.add")){const R=w.association;n.connect(p(R.source),p(R.target),R.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:R.id})}:{type:"bpmn:Association"})}for(const w of Xt(e,"node.update")){let R=p(w.id);if(w.type&&gs(w.type)!==R.type&&(R=c.replaceElement(R,{type:gs(w.type)})),w.name!==void 0&&n.updateProperties(R,{name:w.name??void 0}),w.lane){const M=p(w.lane),F=M.y+M.height/2-(R.y+R.height/2);F!==0&&n.moveElements([R],{x:0,y:F})}}for(const w of Xt(e,"sequenceFlow.update")){const R=p(w.id);if(w.source!==void 0||w.target!==void 0){const M=R,F=w.source!==void 0?p(w.source):M.source,H=w.target!==void 0?p(w.target):M.target,I=Y=>({x:Y.x+Y.width/2,y:Y.y+Y.height/2});n.reconnect(M,F,H,[I(F),I(H)])}w.name!==void 0&&n.updateProperties(R,{name:w.name??void 0}),w.condition!==void 0&&n.updateProperties(R,{name:((s0=w.condition)==null?void 0:s0.label)??void 0})}for(const w of Xt(e,"messageFlow.update"))w.name!==void 0&&n.updateProperties(p(w.id),{name:w.name??void 0});for(const w of Xt(e,"dataStore.update"))w.name!==void 0&&n.updateProperties(p(w.id),{name:w.name??void 0});for(const w of Xt(e,"annotation.update")){const R=p(w.id);if(w.text!==void 0&&n.updateProperties(R,{text:w.text}),w.placement===null)D(R,"bwl:Placement",null);else if(w.placement){const M=p(w.placement.anchor),F=Bx(M),H=f(M)??u(),I=typeof H.x=="number"&&typeof H.width=="number"&&H.type==="bpmn:Participant",[Y,G]=ys[w.placement.side],W=w.placement.offset??50,ce={x:F.x+F.width/2+Y*(F.width/2+R.width/2+W),y:F.y+F.height/2+G*(F.height/2+R.height/2+W)},xe=I?Qu(o,F,{width:R.width,height:R.height},H,{placement:w.placement,selfId:w.id}):ce;n.moveElements([R],{x:xe.x-(R.x+R.width/2),y:xe.y-(R.y+R.height/2)}),D(R,"bwl:Placement",A(w.placement))}}for(const w of Xt(e,"group.update")){const R=p(w.id);if(w.name!==void 0&&n.updateLabel(R,w.name??""),w.members){const M=w.members.map(l).filter(F=>!!F);M.length&&n.resizeShape(R,Yf(M,w.id)),D(R,"bwl:Members",{refs:w.members.join(" ")})}}}function Ju(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 GE(e,t,n){var l,p;const{elementRegistry:i}=e,r=e.modeling,o=f=>Ti(f).filter(d=>!t.has(Ri(d))),a=f=>{var d;return((d=i.get(f))==null?void 0:d.type)==="bpmn:TextAnnotation"},s=wt(i),c=o(s),u=[...new Set(c.flatMap(Ju))].filter(f=>n.has(f)&&a(f));if(u.length)for(const f of u){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 ye=d.x+d.width/2,Ue=d.y+d.height/2;h=i.getAll().find(q=>{if(q.type!=="bpmn:Participant")return!1;const le=q;return typeof le.x=="number"&&typeof le.width=="number"&&ye>=le.x&&ye<=le.x+le.width&&Ue>=le.y&&Ue<=le.y+le.height})}if(!h||typeof h.x!="number"||typeof h.width!="number")continue;const S=(((l=d.businessObject.extensionElements)==null?void 0:l.values)??[]).find(ye=>ye.$type==="bwl:Placement"),y=[...d.incoming??[],...d.outgoing??[]].find(ye=>ye.type==="bpmn:Association"),_=(S!=null&&S.anchor?i.get(S.anchor):void 0)??(y?((p=y.source)==null?void 0:p.id)===f?y.target:y.source:void 0);if(!_)continue;const E=_.waypoints,P=E!=null&&E.length?{x:E[Math.floor((E.length-1)/2)].x,y:E[Math.floor((E.length-1)/2)].y,width:0,height:0}:{x:_.x,y:_.y,width:_.width,height:_.height},C={width:d.width,height:d.height},D={x:d.x+d.width/2,y:d.y+d.height/2},A=S==null?void 0:S.side,B=[];A&&A in ys&&B.push(Qu(i,P,C,h,{placement:{side:A,offset:(S==null?void 0:S.offset)??null},selfId:f}));for(const[ye,Ue]of[[-1,0],[1,0],[0,-1],[0,1]])for(let q=1;q<=zE;q++)B.push({x:D.x+ye*gh*q,y:D.y+Ue*gh*q});const k={...s,edges:s.edges.filter(ye=>ye.id!==(y==null?void 0:y.id))},O=o(k),$=O.filter(ye=>Ju(ye).includes(f)).length;if(!$)continue;let re;for(const ye of B){const Ue=ye.x-D.x,q=ye.y-D.y;if(!Ue&&!q||ye.x-C.width/2<h.x||ye.x+C.width/2>h.x+h.width||ye.y-C.height/2<h.y||ye.y+C.height/2>h.y+h.height)continue;const le={...k,shapes:k.shapes.map(ne=>ne.id===f?{...ne,x:ne.x+Ue,y:ne.y+q}:ne)},me=o(le),se=me.filter(ne=>Ju(ne).includes(f)).length;if(se>=$||me.length>O.length)continue;const _e=Math.abs(Ue)+Math.abs(q);if((!re||se<re.mine||se===re.mine&&(me.length<re.all||me.length===re.all&&_e<re.dist))&&(re={x:ye.x,y:ye.y,mine:se,all:me.length,dist:_e}),re.mine===0&&re.all<O.length)break}re&&r.moveElements([d],{x:re.x-D.x,y:re.y-D.y})}}function vh(e,t,n=yh){const i=mh(e),r=hh(t,Vd(i.elementRegistry)),o={edgeCrossings:{before:0,after:0,pairs:[],solidPairs:0,dashedPairs:0,mixedPairs:0,crossPoolMessages:0}};if(r.length)return{ok:!1,issues:r,findings:[],stats:o};const a=wt(i.elementRegistry),s=new Set(Ti(a).map(Ri)),c=new Set(a.edges.map(h=>h.id)),u=new Set(a.shapes.map(h=>h.id)),l=Ku(a).length,p=e.get("commandStack");try{Jf(p,()=>{n(t,i),Jd(i,c),Xd(i,s),oh(i,s,c),ih(i,c),IE(i,c),uh(i,s,c),ch(i,c),ph(i,u),GE(i,s,u)})}catch(h){return{ok:!1,issues:[{kind:"lower-failed",message:h instanceof Error?h.message:String(h)}],findings:[],stats:o}}const f=wt(i.elementRegistry),d=Ti(f).filter(h=>!s.has(Ri(h))),g=Bd(f);return{ok:!0,issues:[],findings:d,stats:{edgeCrossings:{before:l,after:g.pairs.length,pairs:g.pairs,solidPairs:g.solidPairs,dashedPairs:g.dashedPairs,mixedPairs:g.mixedPairs,crossPoolMessages:g.crossPoolMessages}}}}function VE(e){const t=e.slice(e.indexOf(":")+1);return t.charAt(0).toLowerCase()+t.slice(1)}function WE(e,t){return typeof e.get=="function"?e.get(t):e[t]}function bh(e,t){const n=WE(e,t);return typeof n=="number"&&Number.isFinite(n)?n:void 0}function _h(e,t){var i;return(((i=e.extensionElements)==null?void 0:i.values)??[]).find(r=>(r==null?void 0:r.$type)===t)}function UE(e){return typeof e=="string"&&Cu.includes(e)}function ui(e){if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:void 0}function xh(e){const t=e.rootElements??[],n=t.find(q=>q.$type==="bpmn:Collaboration"),i=new Map(t.filter(q=>q.$type==="bpmn:Process").map(q=>[q.id,q])),r=[],o=[],a=[],s=[],c=[],u=[],l={poolOrders:{},bands:{},placements:{}},p=[],f=[],d=[],g=[],h=[],m=[],S=new Set,y=new Set,_=q=>{q&&S.add(q)},E=q=>{S.add(q),y.add(q)},P=q=>{const le=_h(q,"bwl:Placement");if(!le)return;const me=typeof le.anchor=="string"?le.anchor:void 0;if(!me||!UE(le.side))return;const se=typeof le.offset=="number"?le.offset:void 0;h.push({owner:q.id,anchor:me,side:le.side,...se!==void 0?{offset:se}:{}})},C=q=>{const le=_h(q,"bwl:Members"),me=typeof(le==null?void 0:le.refs)=="string"?le.refs.split(/\s+/).filter(Boolean):[];me.length&&m.push({owner:q.id,refs:me})},D=q=>{var le;for(const me of q)switch(_(me.id),me.$type){case"bpmn:TextAnnotation":E(me.id),s.push({id:me.id,text:typeof me.text=="string"?me.text:""}),P(me);break;case"bpmn:Association":d.push({id:me.id,type:me.$type,source:ui(me.sourceRef),target:ui(me.targetRef)});break;case"bpmn:Group":{E(me.id);const se=(le=me.categoryValueRef)==null?void 0:le.value;c.push({id:me.id,...typeof se=="string"&&se?{name:se}:{}}),C(me);break}default:u.push({id:me.id,type:me.$type,reason:"type-outside-mvp"})}},A=(q,le)=>{const me=q.flowElements??[],se=(q.laneSets??[]).flatMap(ne=>ne.lanes??[]),_e=new Map;for(const ne of se){_(ne.id);for(const U of ne.flowNodeRef??[]){const V=ui(U);V&&_e.set(V,ne.id)}}for(const ne of me){if(_(ne.id),ne.$type==="bpmn:SequenceFlow"){p.push({id:ne.id,source:ui(ne.sourceRef),target:ui(ne.targetRef),...typeof ne.name=="string"&&ne.name?{name:ne.name}:{}});continue}if(ne.$type==="bpmn:DataStoreReference"){E(ne.id),a.push({id:ne.id,...ne.name?{name:ne.name}:{}});continue}const U=VE(ne.$type);if(!Kf(U)){u.push({id:ne.id,type:ne.$type,reason:"type-outside-mvp"});continue}E(ne.id),o.push({id:ne.id,type:U,...ne.name?{name:ne.name}:{},...le?{participant:le}:{},..._e.has(ne.id)?{lane:_e.get(ne.id)}:{}});const V=bh(ne,"bwl:band");V!==void 0&&(l.bands[ne.id]=V);for(const Z of ne.dataOutputAssociations??[])_(Z.id),g.push({id:Z.id,type:Z.$type,source:ne.id,target:ui(Z.targetRef)});for(const Z of ne.dataInputAssociations??[])_(Z.id),g.push({id:Z.id,type:Z.$type,source:ui((Z.sourceRef??[])[0]),target:ne.id})}D(q.artifacts??[])};if(n){const q=new Set;for(const le of n.participants??[]){E(le.id);const me=ui(le.processRef);me&&q.add(me);const se=me?i.get(me):void 0,_e=((se==null?void 0:se.laneSets)??[]).flatMap(Z=>Z.lanes??[]),ne=_e.map(Z=>({id:Z.id,...Z.name?{name:Z.name}:{}}));for(const Z of ne)E(Z.id);const U=!se||(se.flowElements??[]).length===0&&_e.length===0&&(se.artifacts??[]).length===0;r.push({id:le.id,...le.name?{name:le.name}:{},...U?{blackBox:!0}:{},...ne.length?{lanes:ne}:{}});const V=bh(le,"bwl:poolOrder");V!==void 0&&(l.poolOrders[le.id]=V),se&&A(se,le.id)}for(const le of n.messageFlows??[])_(le.id),f.push({id:le.id,source:ui(le.sourceRef),target:ui(le.targetRef),...typeof le.name=="string"&&le.name?{name:le.name}:{}});D(n.artifacts??[]);for(const[le,me]of i)!q.has(le)&&(me.flowElements??[]).length>0&&u.push({id:le,type:me.$type,reason:"unreachable-process"})}else for(const q of i.values())A(q);const B=[],k=[],O=[],$=[],re=(q,le)=>!!q&&!!le&&y.has(q)&&y.has(le);for(const q of p){if(!re(q.source,q.target)){u.push({id:q.id,type:"bpmn:SequenceFlow",reason:"endpoint-outside-mvp"});continue}B.push({id:q.id,source:q.source,target:q.target,...q.name?{name:q.name}:{}}),y.add(q.id)}for(const q of f){if(!re(q.source,q.target)){u.push({id:q.id,type:"bpmn:MessageFlow",reason:"endpoint-outside-mvp"});continue}k.push({id:q.id,source:q.source,target:q.target,...q.name?{name:q.name}:{}}),y.add(q.id)}for(const q of g){if(!re(q.source,q.target)){u.push({id:q.id??"",type:q.type,reason:"endpoint-outside-mvp"});continue}$.push({...q.id?{id:q.id}:{},source:q.source,target:q.target}),q.id&&y.add(q.id)}for(const q of d){if(!re(q.source,q.target)){u.push({id:q.id??"",type:q.type,reason:"endpoint-outside-mvp"});continue}O.push({...q.id?{id:q.id}:{},source:q.source,target:q.target})}const ye=new Map(c.map(q=>[q.id,q]));for(const{owner:q,refs:le}of m){const me=le.filter(_e=>S.has(_e)),se=ye.get(q);se&&me.length&&(se.members=me)}for(const q of h)S.has(q.anchor)&&(l.placements[q.owner]={anchor:q.anchor,side:q.side,...q.offset!==void 0?{offset:q.offset}:{}});return{definition:{...r.length?{participants:r}:{},nodes:o,sequenceFlows:B,...k.length?{messageFlows:k}:{},...a.length?{dataStores:a}:{},...$.length?{dataAssociations:$}:{},...s.length?{annotations:s}:{},...O.length?{associations:O}:{},...c.length?{groups:c}:{}},hints:l,omitted:u}}async function qE(e){const{definitions:t,warnings:n}=await Gu(e);return{...xh(t),warnings:n}}function YE(e,t,n,i={}){return{documentId:e,baseVersion:t,ops:[...n],origin:i.origin??"agent",clientOpId:(i.mkClientOpId??(()=>crypto.randomUUID()))()}}async function wh(e,t,{currentVersion:n}){if(t.baseVersion!==n)return{status:"conflict",baseVersion:t.baseVersion,currentVersion:n};const i=vh(e,t.ops);if(!i.ok)return{status:"rejected",issues:i.issues};const{xml:r}=await e.saveXML({format:!0});return{status:"applied",version:n+1,xml:r??"",findings:i.findings,stats:i.stats}}const KE=Symbol("bpmn-editor");function XE(){const e=Tt.ref(!1),t=Tt.ref(!0),n=Tt.ref(!1);let i,r;const o=()=>{e.value=!0};function a(u,l){u.get("canvas").getContainer().style.pointerEvents=l?"":"none";const p=u.get("keyboard");l?(r&&p.bind(r),r=void 0):r||(r=p.getBinding(),p.unbind())}function s(){if(!i)throw new Error("modeler not attached — 뷰 @ready 후 attach() 필요");return i}function c(){return i==null?void 0:i.get("commandStack")}return{dirty:e,editable:t,agentBusy:n,attach(u){i&&this.detach(),i=u,i.get("eventBus").on("commandStack.changed",o),t.value||a(i,!1)},detach(){i==null||i.get("eventBus").off("commandStack.changed",o),i&&!t.value&&a(i,!0),r=void 0,i=void 0},setEditable(u){t.value=u,i&&a(i,u)},async applyAgentBatch(u,l){const p=s();n.value=!0;try{const f=await wh(p,u,{currentVersion:l});return f.status==="applied"&&(e.value=!1),f}finally{n.value=!1}},async importXml(u){const{warnings:l}=await s().importXML(u);return e.value=!1,{warnings:Vu(l)}},async saveXml(){const{xml:u}=await s().saveXML({format:!0});return e.value=!1,u??""},undo:()=>{var u;return(u=c())==null?void 0:u.undo()},redo:()=>{var u;return(u=c())==null?void 0:u.redo()},canUndo:()=>{var u;return((u=c())==null?void 0:u.canUndo())??!1},canRedo:()=>{var u;return((u=c())==null?void 0:u.canRedo())??!1}}}function de(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}function ZE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var el={exports:{}},Eh;function QE(){if(Eh)return el.exports;Eh=1;var e=el.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 u=parseInt(a,n);return u!==1/0&&u>=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},el.exports}var JE=QE(),e1=ZE(JE);function li(e){if(!(this instanceof li))return new li(e);e=e||[128,36,1],this._seed=e.length?e1.rack(e[0],e[1],e[2]):e}li.prototype.next=function(e){return this._seed(e||!0)},li.prototype.nextPrefixed=function(e,t){var n;do n=e+this.next(!0);while(this.assigned(n));return this.claim(n,t),n},li.prototype.claim=function(e,t){this._seed.set(e,t||!0)},li.prototype.assigned=function(e){return this._seed.get(e)||!1},li.prototype.unclaim=function(e){delete this._seed.hats[e]},li.prototype.clear=function(){var e=this._seed.hats,t;for(t in e)this.unclaim(t)};const Ft={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};Ft.td=Ft.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],Ft.option=Ft.optgroup=[1,'<select multiple="multiple">',"</select>"],Ft.thead=Ft.tbody=Ft.colgroup=Ft.caption=Ft.tfoot=[1,"<table>","</table>"],Ft.polyline=Ft.ellipse=Ft.polygon=Ft.circle=Ft.text=Ft.line=Ft.path=Ft.rect=Ft.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];function ft(e,t=globalThis.document){var u;if(typeof e!="string")throw new TypeError("String expected");const n=/^<!--(.*?)-->$/s.exec(e);if(n)return t.createComment(n[1]);const i=(u=/<([\w:]+)/.exec(e))==null?void 0:u[1];if(!i)return t.createTextNode(e);if(e=e.trim(),i==="body"){const l=t.createElement("html");l.innerHTML=e;const{lastChild:p}=l;return p.remove(),p}let[r,o,a]=Object.hasOwn(Ft,i)?Ft[i]:Ft._default,s=t.createElement("div");for(s.innerHTML=o+e+a;r--;)s=s.lastChild;if(s.firstChild===s.lastChild){const{firstChild:l}=s;return l.remove(),l}const c=t.createDocumentFragment();return c.append(...s.childNodes),c}function t1(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 gn(e,...t){const n=e.style;return L(t,function(i){i&&L(i,function(r,o){n[o]=r})}),e}function ln(e,t,n){return arguments.length==2?e.getAttribute(t):n===null?e.removeAttribute(t):(e.setAttribute(t,n),e)}const n1=Object.prototype.toString;function gt(e){return new Ji(e)}function Ji(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}Ji.prototype.add=function(e){return this.list.add(e),this},Ji.prototype.remove=function(e){return n1.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)},Ji.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},Ji.prototype.toggle=function(e,t){return typeof t<"u"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Ji.prototype.array=function(){return Array.from(this.list)},Ji.prototype.has=Ji.prototype.contains=function(e){return this.list.contains(e)};function vs(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Lr(e,t,n){var i=n?e:e.parentNode;return i&&typeof i.closest=="function"&&i.closest(t)||null}function i1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bs={},Sh;function r1(){if(Sh)return bs;Sh=1;var e,t,n;function i(){e=window.addEventListener?"addEventListener":"attachEvent",t=window.removeEventListener?"removeEventListener":"detachEvent",n=e!=="addEventListener"?"on":""}return bs.bind=function(r,o,a,s){return e||i(),r[e](n+o,a,s||!1),a},bs.unbind=function(r,o,a,s){return t||i(),r[t](n+o,a,s||!1),a},bs}var Rh=r1(),o1=i1(Rh),De=t1({__proto__:null,default:o1},[Rh]),Ch=["focus","blur"];function a1(e,t,n,i,r){return Ch.indexOf(n)!==-1&&(r=!0),De.bind(e,n,function(o){var a=o.target||o.srcElement;o.delegateTarget=Lr(a,t,!0),o.delegateTarget&&i.call(e,o)},r)}function s1(e,t,n,i){return Ch.indexOf(t)!==-1&&(i=!0),De.unbind(e,t,n,i)}var Pn={bind:a1,unbind:s1};function tl(e,t){return e&&typeof e.matches=="function"&&e.matches(t)||!1}function at(e,t){return t=t||document,t.querySelector(e)}function _s(e,t){return t=t||document,t.querySelectorAll(e)}function pi(e){e.parentNode&&e.parentNode.removeChild(e)}function c1(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch{}return e}function u1(e,t){return t.appendChild(c1(e,t))}function Le(e,t){return u1(t,e),e}var nl=2,Ph={"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":nl,"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":nl,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function l1(e,t){return Ph[t]?e.style[t]:e.getAttributeNS(null,t)}function Ah(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Ph[i];r?(r===nl&&typeof n=="number"&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function p1(e,t){var n=Object.keys(t),i,r;for(i=0,r;r=n[i];i++)Ah(e,r,t[r])}function he(e,t,n){if(typeof t=="string")if(n!==void 0)Ah(e,t,n);else return l1(e,t);else p1(e,t);return e}const f1=Object.prototype.toString;function Ye(e){return new er(e)}function er(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}er.prototype.add=function(e){return this.list.add(e),this},er.prototype.remove=function(e){return f1.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)},er.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},er.prototype.toggle=function(e,t){return typeof t<"u"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},er.prototype.array=function(){return Array.from(this.list)},er.prototype.has=er.prototype.contains=function(e){return this.list.contains(e)};function xs(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Th(e){return e.cloneNode(!0)}var il={svg:"http://www.w3.org/2000/svg"},Mh='<svg xmlns="'+il.svg+'"';function d1(e){var t=!1;e.substring(0,4)==="<svg"?e.indexOf(il.svg)===-1&&(e=Mh+e.substring(4)):(e=Mh+">"+e+"</svg>",t=!0);var n=h1(e);if(!t)return n;for(var i=document.createDocumentFragment(),r=n.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function h1(e){var t;return t=new DOMParser,t.async=!1,t.parseFromString(e,"text/xml")}function Ee(e,t){var n;return e=e.trim(),e.charAt(0)==="<"?(n=d1(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(il.svg,e),t&&he(n,t),n}var rl=null;function kh(){return rl===null&&(rl=Ee("svg")),rl}function Oh(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}function m1(e,t,n,i,r,o){var a=kh().createSVGMatrix();switch(arguments.length){case 0:return a;case 1:return Oh(a,e);case 6:return Oh(a,{a:e,b:t,c:n,d:i,e:r,f:o})}}function Yo(e){return kh().createSVGTransform()}var Dh=/([&<>]{1})/g,g1=/([&<>\n\r"]{1})/g,y1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function ol(e,t){function n(i,r){return y1[r]||r}return e.replace(t,n)}function Lh(e,t){var n,i,r,o,a;switch(e.nodeType){case 3:t.push(ol(e.textContent,Dh));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,'="',ol(o.value,g1),'"');if(e.hasChildNodes()){for(t.push(">"),a=e.childNodes,n=0,i=a.length;n<i;++n)Lh(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("<!--",ol(e.nodeValue,Dh),"-->");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function v1(e){for(var t=e.firstChild,n=[];t;)Lh(t,n),t=t.nextSibling;return n.join("")}function Ih(e,t){return v1(e)}function Ht(e){var t=e.parentNode;return t&&t.removeChild(e),e}function b1(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function _1(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(b1(e,i))}function Ko(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),_1(n,t)),n.consolidate()}const x1=/^class[ {]/;function w1(e){return x1.test(e.toString())}function al(e){return Array.isArray(e)}function sl(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ws(...e){e.length===1&&al(e[0])&&(e=e[0]),e=[...e];const t=e.pop();return t.$inject=e,t}const E1=/constructor\s*[^(]*\(\s*([^)]*)\)/m,S1=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,R1=/\/\*([^*]*)\*\//m;function C1(e){if(typeof e!="function")throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(w1(e)?E1:S1);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map(i=>{const r=i.match(R1);return(r&&r[1]||i).trim()})||[]}function Bh(e,t){const n=t||{get:function(_,E){if(i.push(_),E===!1)return null;throw s(`No provider for "${_}"!`)}},i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),a=o.injector=this,s=function(_){const E=i.join(" -> ");return i.length=0,new Error(E?`${_} (Resolving: ${E})`:_)};function c(_,E){if(!r[_]&&_.includes(".")){const P=_.split(".");let C=c(P.shift());for(;P.length;)C=C[P.shift()];return C}if(sl(o,_))return o[_];if(sl(r,_)){if(i.indexOf(_)!==-1)throw i.push(_),s("Cannot resolve circular dependency!");return i.push(_),o[_]=r[_][0](r[_][1]),i.pop(),o[_]}return n.get(_,E)}function u(_,E){if(typeof E>"u"&&(E={}),typeof _!="function")if(al(_))_=ws(_.slice());else throw s(`Cannot invoke "${_}". Expected a function!`);const C=(_.$inject||C1(_)).map(D=>sl(E,D)?E[D]:c(D));return{fn:_,dependencies:C}}function l(_){const{fn:E,dependencies:P}=u(_),C=Function.prototype.bind.call(E,null,...P);return new C}function p(_,E,P){const{fn:C,dependencies:D}=u(_,P);return C.apply(E,D)}function f(_){return ws(E=>_.get(E))}function d(_,E){if(E&&E.length){const P=Object.create(null),C=Object.create(null),D=[],A=[],B=[];let k,O,$,re;for(let ye in r)k=r[ye],E.indexOf(ye)!==-1&&(k[2]==="private"?(O=D.indexOf(k[3]),O===-1?($=k[3].createChild([],E),re=f($),D.push(k[3]),A.push($),B.push(re),P[ye]=[re,ye,"private",$]):P[ye]=[B[O],ye,"private",A[O]]):P[ye]=[k[2],k[1]],C[ye]=!0),(k[2]==="factory"||k[2]==="type")&&k[1].$scope&&E.forEach(Ue=>{k[1].$scope.indexOf(Ue)!==-1&&(P[ye]=[k[2],k[1]],C[Ue]=!0)});E.forEach(ye=>{if(!C[ye])throw new Error('No provider for "'+ye+'". Cannot use provider from the parent!')}),_.unshift(P)}return new Bh(_,a)}const g={factory:p,type:l,value:function(_){return _}};function h(_,E){const P=_.__init__||[];return function(){P.forEach(C=>{typeof C=="string"?E.get(C):E.invoke(C)})}}function m(_){const E=_.__exports__;if(E){const P=_.__modules__,C=Object.keys(_).reduce((O,$)=>($!=="__exports__"&&$!=="__modules__"&&$!=="__init__"&&$!=="__depends__"&&(O[$]=_[$]),O),Object.create(null)),D=(P||[]).concat(C),A=d(D),B=ws(function(O){return A.get(O)});E.forEach(function(O){r[O]=[B,O,"private",A]});const k=(_.__init__||[]).slice();return k.unshift(function(){A.init()}),_=Object.assign({},_,{__init__:k}),h(_,A)}return Object.keys(_).forEach(function(P){if(P==="__init__"||P==="__depends__")return;const C=_[P];if(C[2]==="private"){r[P]=C;return}const D=C[0],A=C[1];r[P]=[g[D],P1(D,A),D]}),h(_,a)}function S(_,E){return _.indexOf(E)!==-1||(_=(E.__depends__||[]).reduce(S,_),_.indexOf(E)!==-1)?_:_.concat(E)}function y(_){const E=_.reduce(S,[]).map(m);let P=!1;return function(){P||(P=!0,E.forEach(C=>C()))}}this.get=c,this.invoke=p,this.instantiate=l,this.createChild=d,this.init=y(e)}function P1(e,t){return e!=="value"&&al(t)&&(t=ws(t.slice())),t}var A1=1e3;function ki(e,t){var n=this;t=t||A1,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)})}ki.prototype.canRender=function(e){},ki.prototype.drawShape=function(e,t){},ki.prototype.drawConnection=function(e,t){},ki.prototype.getShapePath=function(e){},ki.prototype.getConnectionPath=function(e){};function Ir(e){return e.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function T1(e){return["M",e.x,e.y]}function cl(e){return["L",e.x,e.y]}function M1(e,t,n){return["C",e.x,e.y,t.x,t.y,n.x,n.y]}function k1(e,t){const n=e.length,i=[T1(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(cl(a));continue}const c=Math.min(t,ul(a.x-o.x,a.y-o.y),ul(s.x-a.x,s.y-a.y));if(!c){i.push(cl(a));continue}const u=Es(a,o,c),l=Es(a,o,c*.5),p=Es(a,s,c),f=Es(a,s,c*.5);i.push(cl(u)),i.push(M1(l,f,p))}return i}function Es(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=ul(i,r),a=n/o;return{x:e.x+i*a,y:e.y+r*a}}function ul(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function Xo(e,t,n){Oe(t)&&(n=t,t=null),t||(t={});const i=Ee("path",t);return Oe(n)&&(i.dataset.cornerRadius=String(n)),ll(i,e)}function ll(e,t){const n=parseInt(e.dataset.cornerRadius,10)||0;return he(e,{d:Ir(k1(t,n))}),e}function Ss(e){var t=new Set(e);return ze(e,function(n){for(var i=n.parent;i;){if(t.has(i))return!1;i=i.parent}return!0})}function Br(e,t,n){n=n||0,Pe(e)||(e=[e]),L(e,function(i,r){var o=t(i,r,n);Pe(o)&&o.length&&Br(o,t,n+1)})}function pl(e,t,n){var i=new Set,r=new Set;return Br(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 Zo(e,t){return pl(e)}function O1(e,t,n){Ar(t)&&(t=!0),Yt(t)&&(n=t,t=!0),n=n||{};var i=Qo(n.allShapes),r=Qo(n.allConnections),o=Qo(n.enclosedElements),a=Qo(n.enclosedConnections),s=Qo(n.topLevel,t&&no(e,function(l){return l.id}));function c(l){s[l.source.id]&&s[l.target.id]&&(s[l.id]=[l]),i[l.source.id]&&i[l.target.id]&&(a[l.id]=o[l.id]=l),r[l.id]=l}function u(l){if(o[l.id]=l,l.waypoints)a[l.id]=r[l.id]=l;else return i[l.id]=l,L(l.incoming,c),L(l.outgoing,c),l.children}return Br(e,u),{allShapes:i,allConnections:r,topLevel:s,enclosedConnections:a,enclosedElements:o}}function kt(e,t){t=!!t,Pe(e)||(e=[e]);var n,i,r,o;return L(e,function(a){var s=a;a.waypoints&&!t&&(s=kt(a.waypoints,!0));var c=s.x,u=s.y,l=s.height||0,p=s.width||0;(c<n||n===void 0)&&(n=c),(u<i||i===void 0)&&(i=u),(c+p>r||r===void 0)&&(r=c+p),(u+l>o||o===void 0)&&(o=u+l)}),{x:n,y:i,height:o-i,width:r-n}}function lo(e,t){var n={};return L(e,function(i){var r=i;r.waypoints&&(r=kt(r)),!Oe(t.y)&&r.x>t.x&&(n[i.id]=i),!Oe(t.x)&&r.y>t.y&&(n[i.id]=i),r.x>t.x&&r.y>t.y&&(Oe(t.width)&&Oe(t.height)&&r.width+r.x<t.width+t.x&&r.height+r.y<t.height+t.y||!Oe(t.width)||!Oe(t.height))&&(n[i.id]=i)}),n}function Nh(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function $h(e){return!!(e&&e.isFrame)}function Qo(e,t){return j({},e||{},t||{})}var D1=1;function tr(e,t){ki.call(this,e,D1),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})}de(tr,ki),tr.prototype.canRender=function(){return!0},tr.prototype.drawShape=function(t,n,i){var r=Ee("rect");return he(r,{x:0,y:0,width:n.width||0,height:n.height||0}),$h(n)?he(r,j({},this.FRAME_STYLE,i||{})):he(r,j({},this.SHAPE_STYLE,i||{})),Le(t,r),r},tr.prototype.drawConnection=function(t,n,i){var r=Xo(n.waypoints,j({},this.CONNECTION_STYLE,i||{}));return Le(t,r),r},tr.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 Ir(a)},tr.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 Ir(o)},tr.$inject=["eventBus","styles"];function L1(){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 j(o,{class:n})},this.style=function(n,i){!Pe(n)&&!i&&(i=n,n=[]);var r=Rn(n,function(o,a){return j(o,e[a]||{})},{});return i?j(r,i):r},this.computeStyle=function(n,i,r){return Pe(i)||(r=i,i=[]),t.style(i||[],j({},r,n||{}))}}const I1={__init__:["defaultRenderer"],defaultRenderer:["type",tr],styles:["type",L1]};function Et(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return n!==-1&&e.splice(n,1),n}function St(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 fl(e,t){return!e||!t?-1:e.indexOf(t)}function Jo(e,t){return!e||!t?-1:Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function dl(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=Jo(e,t);return Math.abs(r/o)<=i}var B1=2;function Oi(e,t){var n=Array.from(arguments).flat();const i={x:"v",y:"h"};for(const[r,o]of Object.entries(i))if(N1(r,n))return o;return!1}function N1(e,t){const n=t[0];return Tr(t,function(i){return Math.abs(n[e]-i[e])<=B1})}function jh(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 hl(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}var $1=/,?([a-z]),?/gi,Fh=parseFloat,Ot=Math,nr=Ot.PI,fi=Ot.min,di=Ot.max,Hh=Ot.pow,ir=Ot.abs,j1=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/ig,F1=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/ig,zh=Array.isArray||function(e){return e instanceof Array};function H1(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function z1(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 G1(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 H1(r,i)?(z1(o,i),r[i]):(o.length>=1e3&&delete r[o.shift()],o.push(i),r[i]=e(...arguments),r[i])}return t}function V1(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(j1,function(i,r,o){var a=[],s=r.toLowerCase();for(o.replace(F1,function(c,u){u&&a.push(+u)}),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=gl,n}function W1(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 U1(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 ml(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 gl(){return this.join(",").replace($1,"$1")}function q1(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=gl,t}function Gh(e,t,n,i,r,o,a,s,c){var u=1-c,l=Hh(u,3),p=Hh(u,2),f=c*c,d=f*c,g=l*e+p*3*c*n+u*3*c*c*r+d*a,h=l*t+p*3*c*i+u*3*c*c*o+d*s;return{x:Rs(g),y:Rs(h)}}function Vh(e){var t=J1(...e);return ml(t.x0,t.y0,t.x1-t.x0,t.y1-t.y0)}function rr(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function Y1(e,t){return e=ml(e),t=ml(t),rr(t,e.x,e.y)||rr(t,e.x2,e.y)||rr(t,e.x,e.y2)||rr(t,e.x2,e.y2)||rr(e,t.x,t.y)||rr(e,t.x2,t.y)||rr(e,t.x,t.y2)||rr(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 Wh(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 Uh(e,t,n,i,r,o,a,s,c){c==null&&(c=1),c=c>1?1:c<0?0:c;for(var u=c/2,l=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<l;g++){var h=u*p[g]+u,m=Wh(h,e,n,r,a),S=Wh(h,t,i,o,s),y=m*m+S*S;d+=f[g]*Ot.sqrt(y)}return u*d}function K1(e,t,n,i,r,o,a,s){if(!(di(e,n)<fi(r,a)||fi(e,n)>di(r,a)||di(t,i)<fi(o,s)||fi(t,i)>di(o,s))){var c=(e*i-t*n)*(r-a)-(e-n)*(r*s-o*a),u=(e*i-t*n)*(o-s)-(t-i)*(r*s-o*a),l=(e-n)*(o-s)-(t-i)*(r-a);if(l){var p=Rs(c/l),f=Rs(u/l),d=+p.toFixed(2),g=+f.toFixed(2);if(!(d<+fi(e,n).toFixed(2)||d>+di(e,n).toFixed(2)||d<+fi(r,a).toFixed(2)||d>+di(r,a).toFixed(2)||g<+fi(t,i).toFixed(2)||g>+di(t,i).toFixed(2)||g<+fi(o,s).toFixed(2)||g>+di(o,s).toFixed(2)))return{x:p,y:f}}}}function Rs(e){return Math.round(e*1e11)/1e11}function X1(e,t,n){var i=Vh(e),r=Vh(t);if(!Y1(i,r))return[];var o=Uh(...e),a=Uh(...t),s=Yh(e)?1:~~(o/5)||1,c=Yh(t)?1:~~(a/5)||1,u=new Array(s+1),l=new Array(c+1),p={},f=[],d,g;for(d=0;d<s+1;d++){var h=Gh(...e,d/s);u[d]={x:h.x,y:h.y,t:d/s}}for(d=0;d<c+1;d++)h=Gh(...t,d/c),l[d]={x:h.x,y:h.y,t:d/c};for(d=0;d<s;d++)for(g=0;g<c;g++){var m=u[d],S=u[d+1],y=l[g],_=l[g+1],E=ir(S.x-m.x)<.01?"y":"x",P=ir(_.x-y.x)<.01?"y":"x",C=K1(m.x,m.y,S.x,S.y,y.x,y.y,_.x,_.y),D;if(C){if(D=C.x.toFixed(9)+"#"+C.y.toFixed(9),p[D])continue;p[D]=!0;var A=m.t+ir((C[E]-m[E])/(S[E]-m[E]))*(S.t-m.t),B=y.t+ir((C[P]-y[P])/(_[P]-y[P]))*(_.t-y.t);A>=0&&A<=1&&B>=0&&B<=1&&f.push({x:C.x,y:C.y,t1:A,t2:B})}}return f}function qh(e,t,n){e=Zh(e),t=Zh(t);for(var i,r,o,a,s,c,u,l,p,f,d=n?0:[],g=0,h=e.length;g<h;g++){var m=e[g];if(m[0]=="M")i=s=m[1],r=c=m[2];else{m[0]=="C"?(p=[i,r,...m.slice(1)],i=p[6],r=p[7]):(p=[i,r,i,r,s,c,s,c],i=s,r=c);for(var S=0,y=t.length;S<y;S++){var _=t[S];if(_[0]=="M")o=u=_[1],a=l=_[2];else{_[0]=="C"?(f=[o,a,..._.slice(1)],o=f[6],a=f[7]):(f=[o,a,o,a,u,l,u,l],o=u,a=l);var E=X1(p,f);{for(var P=0,C=E.length;P<C;P++)E[P].segment1=g,E[P].segment2=S,E[P].bez1=p,E[P].bez2=f;d=d.concat(E)}}}}}return d}function Z1(e){return zh(e)&&zh(e[0])}function Q1(e){if(W1(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,u,l=a,p=e.length;l<p;l++){if(u=e[l],s=u[0],t[l]=c=new Array(u.length),s!=s.toUpperCase())switch(c[0]=s.toUpperCase(),c[0]){case"A":c[1]=u[1],c[2]=u[2],c[3]=u[3],c[4]=u[4],c[5]=u[5],c[6]=+u[6]+n,c[7]=+u[7]+i;break;case"V":c[1]=+u[1]+i;break;case"H":c[1]=+u[1]+n;break;case"M":r=+u[1]+n,o=+u[2]+i;default:for(var f=1,d=u.length;f<d;f++)c[f]=+u[f]+(f%2?n:i)}else for(var g=0,h=u.length;g<h;g++)c[g]=u[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=gl,t}function Yh(e){return e[0]===e[2]&&e[1]===e[3]&&e[4]===e[6]&&e[5]===e[7]}function Cs(e,t,n,i){return[e,t,n,i,n,i]}function Kh(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 Xh(e,t,n,i,r,o,a,s,c,u){var l=nr*120/180,p=nr/180*(+r||0),f=[],d,g=G1(function(T,x,v){var N=T*Ot.cos(v)-x*Ot.sin(v),z=T*Ot.sin(v)+x*Ot.cos(v);return{x:N,y:z}});if(u)D=u[0],A=u[1],P=u[2],C=u[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,m=(t-c)/2,S=h*h/(n*n)+m*m/(i*i);S>1&&(S=Ot.sqrt(S),n=S*n,i=S*i);var y=n*n,_=i*i,E=(o==a?-1:1)*Ot.sqrt(ir((y*_-y*m*m-_*h*h)/(y*m*m+_*h*h))),P=E*n*m/i+(e+s)/2,C=E*-i*h/n+(t+c)/2,D=Ot.asin(((t-C)/i).toFixed(9)),A=Ot.asin(((c-C)/i).toFixed(9));D=e<P?nr-D:D,A=s<P?nr-A:A,D<0&&(D=nr*2+D),A<0&&(A=nr*2+A),a&&D>A&&(D=D-nr*2),!a&&A>D&&(A=A-nr*2)}var B=A-D;if(ir(B)>l){var k=A,O=s,$=c;A=D+l*(a&&A>D?1:-1),s=P+n*Ot.cos(A),c=C+i*Ot.sin(A),f=Xh(s,c,n,i,r,0,a,O,$,[A,k,P,C])}B=A-D;var re=Ot.cos(D),ye=Ot.sin(D),Ue=Ot.cos(A),q=Ot.sin(A),le=Ot.tan(B/4),me=4/3*n*le,se=4/3*i*le,_e=[e,t],ne=[e+me*ye,t-se*re],U=[s+me*q,c-se*Ue],V=[s,c];if(ne[0]=2*_e[0]-ne[0],ne[1]=2*_e[1]-ne[1],u)return[ne,U,V].concat(f);f=[ne,U,V].concat(f).join().split(",");for(var Z=[],Fe=0,Rt=f.length;Fe<Rt;Fe++)Z[Fe]=Fe%2?g(f[Fe-1],f[Fe],p).y:g(f[Fe],f[Fe+1],p).x;return Z}function J1(e,t,n,i,r,o,a,s){for(var c=[],u=[[],[]],l,p,f,d,g,h,m,S,y=0;y<2;++y){if(y==0?(p=6*e-12*n+6*r,l=-3*e+9*n-9*r+3*a,f=3*n-3*e):(p=6*t-12*i+6*o,l=-3*t+9*i-9*o+3*s,f=3*i-3*t),ir(l)<1e-12){if(ir(p)<1e-12)continue;d=-f/p,0<d&&d<1&&c.push(d);continue}m=p*p-4*f*l,S=Ot.sqrt(m),!(m<0)&&(g=(-p+S)/(2*l),0<g&&g<1&&c.push(g),h=(-p-S)/(2*l),0<h&&h<1&&c.push(h))}for(var _=c.length,E=_,P;_--;)d=c[_],P=1-d,u[0][_]=P*P*P*e+3*P*P*d*n+3*P*d*d*r+d*d*d*a,u[1][_]=P*P*P*t+3*P*P*d*i+3*P*d*d*o+d*d*d*s;return u[0][E]=e,u[1][E]=t,u[0][E+1]=a,u[1][E+1]=s,u[0].length=u[1].length=E+2,{x0:fi(...u[0]),y0:fi(...u[1]),x1:di(...u[0]),y1:di(...u[1])}}function Zh(e){if(Z1(e)||(e=V1(e)),U1(e))return e;for(var t=q1(Q1(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,m;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",...Xh(d.x,d.y,...f.slice(1))];break;case"S":g=="C"||g=="S"?(h=d.x*2-d.bx,m=d.y*2-d.by):(h=d.x,m=d.y),f=["C",h,m,...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",...Kh(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",...Kh(d.x,d.y,f[1],f[2],f[3],f[4])];break;case"L":f=["C",...Cs(d.x,d.y,f[1],f[2])];break;case"H":f=["C",...Cs(d.x,d.y,f[1],d.y)];break;case"V":f=["C",...Cs(d.x,d.y,d.x,f[1])];break;case"Z":f=["C",...Cs(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),u=t.length}},o=[],a="",s="",c=0,u=t.length;c<u;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 l=t[c],p=l.length;n.x=l[p-2],n.y=l[p-1],n.bx=Fh(l[p-4])||n.x,n.by=Fh(l[p-3])||n.y}return t}function st(e){return Yt(e)&&Sn(e,"waypoints")}function je(e){return Yt(e)&&Sn(e,"labelTarget")}function eS(e){return Yt(e)&&eo(e.parent)}function Qh(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}}function Di(e){return{x:Math.round(e.x),y:Math.round(e.y)}}function Se(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function Ps(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function tS(e){return Di({x:e.x+(e.width||0)/2,y:e.y+(e.height||0)/2})}function nS(e){for(var t=e.waypoints,n=t.reduce(function(u,l,p){var f=t[p-1];if(f){var d=u[u.length-1],g=d&&d.endLength||0,h=oS(f,l);u.push({start:f,end:l,startLength:g,endLength:g+h,length:h})}return u},[]),i=n.reduce(function(u,l){return u+l.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 Ae(e){return st(e)?nS(e):tS(e)}function tn(e,t,n){n=n||0,Yt(n)||(n={x:n,y:n});var i=Se(e),r=Se(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,u=o?"top":s?"bottom":null,l=c?"left":a?"right":null;return l&&u?u+"-"+l:l||u||"intersect"}function ea(e,t,n){var i=iS(e,t);return i.length===1||i.length===2&&Jo(i[0],i[1])<1?Di(i[0]):i.length>1?(i=oi(i,function(r){var o=Math.floor(r.t2*100)||1;return o=100-o,o=(o<10?"0":"")+o,r.segment2+"#"+o}),Di(i[n?0:i.length-1])):null}function iS(e,t){return qh(e,t)}function rS(e){e=e.slice();for(var t=0,n,i,r;e[t];)n=e[t],i=e[t-1],r=e[t+1],Jo(n,r)===0||dl(i,r,n)?e.splice(t,1):t++;return e}function oS(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function As(e,t){return Math.round(e*t)/t}function Jh(e){return Oe(e)?e+"px":e}function aS(e){for(;e.parent;)e=e.parent;return e}function sS(e){e=j({},{width:"100%",height:"100%"},e);const t=e.container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),gn(n,{position:"relative",overflow:"hidden",width:Jh(e.width),height:Jh(e.height)}),t.appendChild(n),n}function em(e,t,n){const i=Ee("g");Ye(i).add(t);const r=n!==void 0?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}const cS="base",tm=0,uS=1,lS={shape:["x","y","width","height"],connection:["waypoints"]};function Te(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||{})}Te.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],Te.prototype._init=function(e){const t=this._eventBus,n=this._container=sS(e),i=this._svg=Ee("svg");he(i,{width:"100%",height:"100%"}),ln(i,"tabindex",0),e.autoFocus&&t.on("element.hover",()=>{this.restoreFocus()}),t.on("element.mousedown",500,o=>{this.focus()}),i.addEventListener("focusin",()=>{this._setFocused(!0)}),i.addEventListener("focusout",()=>{this._setFocused(!1)}),i.addEventListener("mouseover",()=>{this._eventBus.fire("canvas.mouseover")}),i.addEventListener("mouseout",()=>{this._eventBus.fire("canvas.mouseout")}),Le(n,i);const r=this._viewport=em(i,"viewport");e.deferUpdate&&(this._viewboxChanged=Mu(this._viewboxChanged,300)),this._restoreFocus=Mu(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)},Te.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},Te.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))},Te.prototype._clear=function(){this._elementRegistry.getAll().forEach(t=>{const n=Nh(t);n==="root"?this.removeRootElement(t):this._removeElement(t,n)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox},Te.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},Te.prototype.restoreFocus=function(){this._restoreFocus()},Te.prototype._restoreFocus=function(){document.activeElement===document.body&&this.focus()},Te.prototype.isFocused=function(){return this._focused},Te.prototype.getDefaultLayer=function(){return this.getLayer(cS,tm)},Te.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},Te.prototype._getChildIndex=function(e){return Rn(this._layers,function(t,n){return n.visible&&e>=n.index&&t++,t},0)},Te.prototype._createLayer=function(e,t){typeof t>"u"&&(t=uS);const n=this._getChildIndex(t);return{group:em(this._viewport,"layer-"+e,n),index:t,visible:!0}},Te.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},Te.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&&(Ht(n),t.visible=!1),n},Te.prototype._removeLayer=function(e){const t=this._layers[e];t&&(delete this._layers[e],Ht(t.group))},Te.prototype.getActiveLayer=function(){const e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null},Te.prototype.findRoot=function(e){const t=this._resolveElements(e);let n;for(const i of t){const r=this._findPlaneForRoot(aS(i));if(!r||n&&r.rootElement!==n)return;n=r.rootElement}return n},Te.prototype.getRootElements=function(){return this._planes.map(function(e){return e.rootElement})},Te.prototype._findPlaneForRoot=function(e){return lt(this._planes,function(t){return t.rootElement===e})},Te.prototype._resolveElement=function(e){return typeof e=="string"?this._elementRegistry.get(e):e},Te.prototype._resolveElements=function(e){return Pe(e)||(e=[e]),e.map(t=>this._resolveElement(t)).filter(Boolean)},Te.prototype.getContainer=function(){return this._container},Te.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&&(L([i.gfx,i.secondaryGfx],function(r){r&&(n?(e.markers.add(t),Ye(r).add(t)):(e.markers.delete(t),Ye(r).remove(t)))}),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},Te.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},Te.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},Te.prototype.hasMarker=function(e,t){return e=this._resolveElement(e),e.markers?e.markers.has(t):!1},Te.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},Te.prototype.getRootElement=function(){const e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))},Te.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,tm);return this.hideLayer(n),this._addRoot(e,i),this._planes.push({rootElement:e,layer:i}),e},Te.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},Te.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},Te.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)},Te.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})},Te.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})},Te.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=lS[e];if(!Tr(n,function(r){return typeof t[r]<"u"}))throw new Error("must supply { "+n.join(", ")+" } with "+e)},Te.prototype._setParent=function(e,t,n){St(t.children,e,n),e.parent=t},Te.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},Te.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},Te.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},Te.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),Et(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},Te.prototype.removeShape=function(e){return this._removeElement(e,"shape")},Te.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},Te.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},Te.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},Te.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},Te.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,u;if(e)this._changeViewbox(function(){s=Math.min(n.width/e.width,n.height/e.height);const l=this._svg.createSVGMatrix().scale(s).translate(-e.x,-e.y);Ko(t,l)});else return o=this._rootElement?this.getActiveLayer():null,i=o&&o.getBBox()||{},a=Ko(t),r=a?a.matrix:m1(),s=As(r.a,1e3),c=As(-r.e||0,1e3),u=As(-r.f||0,1e3),e=this._cachedViewbox={x:c?c/s:0,y:u?u/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},Te.prototype.scroll=function(e){const t=this._viewport;let n=t.getCTM();return e&&this._changeViewbox(function(){e=j({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),nm(t,n)}),{x:n.e,y:n.f}},Te.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=kt(o),s=Se(a),c=this.viewbox(),u=this.zoom();let l,p;c.y+=t.top/u,c.x+=t.left/u,c.width-=(t.right+t.left)/u,c.height-=(t.bottom+t.top)/u;const f=Se(c);if(!(a.width<c.width&&a.height<c.height))l=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),m=Math.max(0,s.bottom-f.bottom),S=Math.min(0,s.top-f.top);l=g||h,p=m||S}this.scroll({dx:-l*u,dy:-p*u})},Te.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)}),As(i.a,1e3)};function nm(e,t){const n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}Te.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},Te.prototype._setZoom=function(e,t){const n=this._svg,i=this._viewport,r=n.createSVGMatrix(),o=n.createSVGPoint();let a,s,c,u,l;c=i.getCTM();const p=c.a;return t?(a=j(o,t),s=a.matrixTransform(c.inverse()),u=r.translate(s.x,s.y).scale(1/p*e).translate(-s.x,-s.y),l=c.multiply(u)):l=r.scale(e),nm(this._viewport,l),l},Te.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},Te.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}},Te.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var po="data-element-id";function Bn(e){this._elements={},this._eventBus=e}Bn.$inject=["eventBus"],Bn.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),he(t,po,i),n&&he(n,po,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},Bn.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(he(i.gfx,po,""),i.secondaryGfx&&he(i.secondaryGfx,po,""),delete t[n])},Bn.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)},Bn.prototype.updateGraphics=function(e,t,n){var i=e.id||e,r=this._elements[i];return n?r.secondaryGfx=t:r.gfx=t,t&&he(t,po,i),t},Bn.prototype.get=function(e){var t;typeof e=="string"?t=e:t=e&&he(e,po);var n=this._elements[t];return n&&n.element},Bn.prototype.filter=function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(n)}),t},Bn.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}},Bn.prototype.getAll=function(){return this.filter(function(e){return e})},Bn.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)})},Bn.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},Bn.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 pS(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 fS(e){return e.__refs_collection===!0}function dS(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)}function im(e,t,n){var i=pS(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 hS(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 Hn(e,t){if(!(this instanceof Hn))return new Hn(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}Hn.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?im(this,t,e):hS(this,t,e)},Hn.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return fS(n)||im(this,t,e),n},Hn.prototype.ensureBound=function(e,t){dS(e,t)||this.bind(e,t)},Hn.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},Hn.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var yl=new Hn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),rm=new Hn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),om=new Hn({name:"attachers",collection:!0},{name:"host"}),am=new Hn({name:"outgoing",collection:!0},{name:"source"}),sm=new Hn({name:"incoming",collection:!0},{name:"target"});function fo(){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)}}),yl.bind(this,"parent"),rm.bind(this,"labels"),am.bind(this,"outgoing"),sm.bind(this,"incoming")}function ta(){fo.call(this),yl.bind(this,"children"),om.bind(this,"host"),om.bind(this,"attachers")}de(ta,fo);function cm(){fo.call(this),yl.bind(this,"children")}de(cm,ta);function um(){ta.call(this),rm.bind(this,"labelTarget")}de(um,ta);function lm(){fo.call(this),am.bind(this,"source"),sm.bind(this,"target")}de(lm,fo);var mS={connection:lm,shape:ta,label:um,root:cm};function gS(e,t){var n=mS[e];if(!n)throw new Error("unknown type: <"+e+">");return j(new n,t)}function yS(e){return e instanceof fo}function Li(){this._uid=12}Li.prototype.createRoot=function(e){return this.create("root",e)},Li.prototype.createLabel=function(e){return this.create("label",e)},Li.prototype.createShape=function(e){return this.create("shape",e)},Li.prototype.createConnection=function(e){return this.create("connection",e)},Li.prototype.create=function(e,t){return t=j({},t||{}),t.id||(t.id=e+"_"+this._uid++),gS(e,t)};var Ts="__fn",pm=1e3,vS=Array.prototype.slice;function An(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}An.prototype.on=function(e,t,n,i){if(e=Pe(e)?e:[e],Kt(t)&&(i=n,n=t,t=pm),!Oe(t))throw new Error("priority must be a number");var r=n;i&&(r=bn(n,i),r[Ts]=n[Ts]||n);var o=this;e.forEach(function(a){o._addListener(a,{priority:t,callback:r,next:null})})},An.prototype.once=function(e,t,n,i){var r=this;if(Kt(t)&&(i=n,n=t,t=pm),!Oe(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[Ts]=n,this.on(e,t,o)},An.prototype.off=function(e,t){e=Pe(e)?e:[e];var n=this;e.forEach(function(i){n._removeListener(i,t)})},An.prototype.createEvent=function(e){var t=new na;return t.init(e),t},An.prototype.fire=function(e,t){var n,i,r,o;if(o=vS.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 na?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}},An.prototype.handleError=function(e){return this.fire("error",{error:e})===!1},An.prototype._destroy=function(){this._listeners={}},An.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},An.prototype._invokeListener=function(e,t,n){var i;if(n.callback.__isTomb)return i;try{i=bS(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},An.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},An.prototype._getListeners=function(e){return this._listeners[e]},An.prototype._setListeners=function(e,t){this._listeners[e]=t},An.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[Ts]===t)&&(r?r.next=i:this._setListeners(e,i)),r=n,n=i};function na(){}na.prototype.stopPropagation=function(){this.cancelBubble=!0},na.prototype.preventDefault=function(){this.defaultPrevented=!0},na.prototype.init=function(e){j(this,e||{})};function bS(e,t){return e.apply(null,t)}function Nr(e){return e.childNodes[0]}function _S(e){return e.parentNode.childNodes[1]}function Ms(e,t,n,i,r){var o=Yo();o.setTranslate(t,n);var a=Yo();a.setRotate(i||0,0,0);var s=Yo();s.setScale(1,1),Ko(e,[o,a,s])}function nn(e,t,n){var i=Yo();i.setTranslate(t,n),Ko(e,i)}function fm(e,t){var n=Yo();n.setRotate(t,0,0),Ko(e,n)}function Nn(e,t){this._eventBus=e,this._elementRegistry=t}Nn.$inject=["eventBus","elementRegistry"],Nn.prototype._getChildrenContainer=function(e){var t=this._elementRegistry.getGraphics(e),n;return e.parent?(n=_S(t),n||(n=Ee("g"),Ye(n).add("djs-children"),Le(t.parentNode,n))):n=t,n},Nn.prototype._clear=function(e){var t=Nr(e);return vs(t),t},Nn.prototype._createContainer=function(e,t,n,i){var r=Ee("g");Ye(r).add("djs-group"),typeof n<"u"?xS(r,t,t.childNodes[n]):Le(t,r);var o=Ee("g");Ye(o).add("djs-element"),Ye(o).add("djs-"+e),i&&Ye(o).add("djs-frame"),Le(r,o);var a=Ee("g");return Ye(a).add("djs-visual"),Le(o,a),o},Nn.prototype.create=function(e,t,n){var i=this._getChildrenContainer(t.parent);return this._createContainer(e,i,n,$h(t))},Nn.prototype.updateContainments=function(e){var t=this,n=this._elementRegistry,i;i=Rn(e,function(r,o){return o.parent&&(r[o.parent.id]=o.parent),r},{}),L(i,function(r){var o=r.children;if(o){var a=t._getChildrenContainer(r),s=a.firstChild;L(o,function(c){var u=n.getGraphics(c).parentNode;u===s?s=s.nextSibling:a.insertBefore(u,s)})}})},Nn.prototype.drawShape=function(e,t,n={}){var i=this._eventBus;return i.fire("render.shape",{gfx:e,element:t,attrs:n})},Nn.prototype.getShapePath=function(e){var t=this._eventBus;return t.fire("render.getShapePath",e)},Nn.prototype.drawConnection=function(e,t,n={}){var i=this._eventBus;return i.fire("render.connection",{gfx:e,element:t,attrs:n})},Nn.prototype.getConnectionPath=function(e){var t=this._eventBus;return t.fire("render.getConnectionPath",e)},Nn.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if(e==="shape")this.drawShape(i,t),nn(n,t.x,t.y);else if(e==="connection")this.drawConnection(i,t);else throw new Error("unknown type: "+e);t.hidden?he(n,"display","none"):he(n,"display","block")}},Nn.prototype.remove=function(e){var t=this._elementRegistry.getGraphics(e);Ht(t.parentNode)};function xS(e,t,n){var i=n||t.firstChild;e!==i&&t.insertBefore(e,i)}const wS={__depends__:[I1],__init__:["canvas"],canvas:["type",Te],elementRegistry:["type",Bn],elementFactory:["type",Li],eventBus:["type",An],graphicsFactory:["type",Nn]};function ES(e){var t=new Bh(e);return t.init(),t}function SS(e){e=e||{};var t={config:["value",e]},n=[t,wS].concat(e.modules||[]);return ES(n)}function or(e,t){this._injector=t||SS(e),this.get("eventBus").fire("diagram.init")}or.prototype.get=function(e,t){return this._injector.get(e,t)},or.prototype.invoke=function(e,t,n){return this._injector.invoke(e,t,n)},or.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},or.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};function pn(e){return e?"<"+e.$type+(e.id?' id="'+e.id:"")+'" />':"<null>"}function _n(e,t){return e.$instanceOf(t)}function RS(e){return lt(e.rootElements,function(t){return _n(t,"bpmn:Process")||_n(t,"bpmn:Collaboration")})}function CS(e){var t={},n=[],i={};function r(U,V){return function(Z){U(Z,V)}}function o(U){t[U.id]=U}function a(U){return t[U.id]}function s(U,V){var Z=U.gfx;if(Z)throw new Error(`already rendered ${pn(U)}`);return e.element(U,i[U.id],V)}function c(U,V){return e.root(U,i[U.id],V)}function u(U,V){try{var Z=i[U.id]&&s(U,V);return o(U),Z}catch(Fe){l(Fe.message,{element:U,error:Fe}),console.error(`failed to import ${pn(U)}`,Fe)}}function l(U,V){e.error(U,V)}var p=this.registerDi=function(V){var Z=V.bpmnElement;Z?i[Z.id]?l(`multiple DI elements defined for ${pn(Z)}`,{element:Z}):i[Z.id]=V:l(`no bpmnElement referenced in ${pn(V)}`,{element:V})};function f(U){d(U.plane)}function d(U){p(U),L(U.planeElement,g)}function g(U){p(U)}this.handleDefinitions=function(V,Z){var Fe=V.diagrams;if(Z&&Fe.indexOf(Z)===-1)throw new Error("diagram not part of <bpmn:Definitions />");if(!Z&&Fe&&Fe.length&&(Z=Fe[0]),!Z)throw new Error("no diagram to display");i={},f(Z);var Rt=Z.plane;if(!Rt)throw new Error(`no plane for ${pn(Z)}`);var T=Rt.bpmnElement;if(!T)if(T=RS(V),T)l(`correcting missing bpmnElement on ${pn(Rt)} to ${pn(T)}`),Rt.bpmnElement=T,p(Rt);else throw new Error("no process or collaboration to display");var x=c(T,Rt);if(_n(T,"bpmn:Process")||_n(T,"bpmn:SubProcess"))m(T,x);else if(_n(T,"bpmn:Collaboration"))_e(T,x),S(V.rootElements,x);else throw new Error(`unsupported bpmnElement for ${pn(Rt)}: ${pn(T)}`);h(n)};var h=this.handleDeferred=function(){for(var V;n.length;)V=n.shift(),V()};function m(U,V){le(U,V),B(U.ioSpecification,V),A(U.artifacts,V),o(U)}function S(U,V){var Z=ze(U,function(Fe){return!a(Fe)&&_n(Fe,"bpmn:Process")&&Fe.laneSets});Z.forEach(r(m,V))}function y(U,V){u(U,V)}function _(U,V){L(U,r(y,V))}function E(U,V){u(U,V)}function P(U,V){u(U,V)}function C(U,V){u(U,V)}function D(U,V){u(U,V)}function A(U,V){L(U,function(Z){_n(Z,"bpmn:Association")?n.push(function(){D(Z,V)}):D(Z,V)})}function B(U,V){U&&(L(U.dataInputs,r(P,V)),L(U.dataOutputs,r(C,V)))}var k=this.handleSubProcess=function(V,Z){le(V,Z),A(V.artifacts,Z)};function O(U,V){var Z=u(U,V);_n(U,"bpmn:SubProcess")&&k(U,Z||V),_n(U,"bpmn:Activity")&&B(U.ioSpecification,V),n.push(function(){L(U.dataInputAssociations,r(E,V)),L(U.dataOutputAssociations,r(E,V))})}function $(U,V){u(U,V)}function re(U,V){u(U,V)}function ye(U,V){n.push(function(){var Z=u(U,V);U.childLaneSet&&Ue(U.childLaneSet,Z||V),ne(U)})}function Ue(U,V){L(U.lanes,r(ye,V))}function q(U,V){L(U,r(Ue,V))}function le(U,V){me(U.flowElements,V),U.laneSets&&q(U.laneSets,V)}function me(U,V){L(U,function(Z){_n(Z,"bpmn:SequenceFlow")?n.push(function(){$(Z,V)}):_n(Z,"bpmn:BoundaryEvent")?n.unshift(function(){O(Z,V)}):_n(Z,"bpmn:FlowNode")?O(Z,V):_n(Z,"bpmn:DataObject")||(_n(Z,"bpmn:DataStoreReference")||_n(Z,"bpmn:DataObjectReference")?re(Z,V):l(`unrecognized flowElement ${pn(Z)} in context ${pn(V&&V.businessObject)}`,{element:Z,context:V}))})}function se(U,V){var Z=u(U,V),Fe=U.processRef;Fe&&m(Fe,Z||V)}function _e(U,V){L(U.participants,r(se,V)),n.push(function(){_(U.messageFlows,V)}),A(U.artifacts,V)}function ne(U){L(U.flowNodeRef,function(V){var Z=V.get("lanes");Z&&Z.push(U)})}}function b(e,t){var n=ee(e);return n&&typeof n.$instanceOf=="function"&&n.$instanceOf(t)}function He(e,t){return Ki(t,function(n){return b(e,n)})}function ee(e){return e&&e.businessObject||e}function Xe(e){return e&&e.di}function PS(e,t,n){var i,r,o,a,s=[];function c(u,l){var p={root:function(h,m){return i.add(h,m)},element:function(h,m,S){return i.add(h,m,S)},error:function(h,m){s.push({message:h,context:m})}},f=new CS(p);l=l||u.diagrams&&u.diagrams[0];var d=AS(u,l);if(!d)throw new Error("no diagram to display");L(d,function(h){f.handleDefinitions(u,h)});var g=l.plane.bpmnElement.id;o.setRootElement(o.findRoot(g+"_plane")||o.findRoot(g))}return new Promise(function(u,l){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}),u({warnings:s})}catch(p){return p.warnings=s,l(p)}})}function AS(e,t){if(!(!t||!t.plane)){var n=t.plane.bpmnElement,i=n;!b(n,"bpmn:Process")&&!b(n,"bpmn:Collaboration")&&(i=TS(n));var r;b(i,"bpmn:Collaboration")?r=i:r=lt(e.rootElements,function(u){if(b(u,"bpmn:Collaboration"))return lt(u.participants,function(l){return l.processRef===i})});var o=[i];r&&(o=cn(r.participants,function(u){return u.processRef}),o.push(r));var a=dm(o),s=[t],c=[n];return L(e.diagrams,function(u){if(u.plane){var l=u.plane.bpmnElement;a.indexOf(l)!==-1&&c.indexOf(l)===-1&&(s.push(u),c.push(l))}}),s}}function dm(e){var t=[];return L(e,function(n){n&&(t.push(n),t=t.concat(dm(n.flowElements)))}),t}function TS(e){for(var t=e;t;){if(b(t,"bpmn:Process"))return t;t=t.$parent}}var MS='<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>',hm=MS,mm={verticalAlign:"middle"},gm={color:"#404040"},kS={zIndex:"1001",position:"fixed",top:"0",left:"0",right:"0",bottom:"0"},OS={width:"100%",height:"100%",background:"rgba(40,40,40,0.2)"},DS={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"},LS='<div class="bjs-powered-by-lightbox"><div class="backdrop"></div><div class="notice"><a href="https://bpmn.io" target="_blank" rel="noopener" class="link">'+hm+'</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>',hi;function IS(){hi=ft(LS),gn(hi,kS),gn(at("svg",hi),mm),gn(at(".backdrop",hi),OS),gn(at(".notice",hi),DS),gn(at(".link",hi),gm,{margin:"15px 20px 15px 10px",alignSelf:"center"})}function BS(){hi||(IS(),Pn.bind(hi,".backdrop","click",function(e){document.body.removeChild(hi)})),document.body.appendChild(hi)}const ks=5,ym="djs-outline-hidden";function yt(e){e=j({},$S,e),this._moddle=this._createModdle(e),this._container=this._createContainer(e),this._init(this._container,this._moddle,e),FS(this._container)}de(yt,or),yt.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,u=a.warnings,l=a.elementsById;o=o.concat(u),s=this._emit("import.parse.complete",r({error:null,definitions:s,elementsById:l,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||[]),Os(s,o),s=NS(s),this._emit("import.done",{error:s,warnings:s.warnings}),s}},yt.prototype.importDefinitions=async function(t,n){return this._setDefinitions(t),{warnings:(await this.open(n)).warnings}},yt.prototype.open=async function(t){const n=this._definitions;let i=t;if(!n){const o=new Error("no XML imported");throw Os(o,[]),o}if(typeof t=="string"&&(i=jS(n,t),!i)){const o=new Error("BPMNDiagram <"+t+"> not found");throw Os(o,[]),o}try{this.clear()}catch(o){throw Os(o,[]),o}const{warnings:r}=await PS(this,n,i);return{warnings:r}},yt.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},yt.prototype.saveSVG=async function(){this._emit("saveSVG.start");let t,n;try{const i=this.get("canvas"),r=i.getActiveLayer(),o=at(":scope > defs",i._svg),a=Ih(r),s=o?"<defs>"+Ih(o)+"</defs>":"",c=i.getContainer();gt(c).add(ym);let u;try{u=r.getBBox()}finally{gt(c).remove(ym)}const l=u.x-ks,p=u.y-ks,f=u.width+ks*2,d=u.height+ks*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">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@g1cloud/bpmn-modeler-next",
3
3
  "private": false,
4
- "version": "5.0.0-alpha.48",
4
+ "version": "5.0.0-alpha.49",
5
5
  "description": "Vue 3 BPMN document authoring editor (bpmn-js based) with AI agent authoring",
6
6
  "type": "module",
7
7
  "files": [