"u")};n.isExist=function(r){return typeof r<"u"},n.isEmptyObject=function(r){return Object.keys(r).length===0},n.merge=function(r,l,c){if(l){const f=Object.keys(l),T=f.length;for(let p=0;phi.get(n.position),gi=(n,t)=>{t&&(n.fill.color=t.color??n.fill.color,n.fill.opacity=t.opacity??n.fill.opacity)},Ti=(n,t)=>{t&&(n.stroke.color=t.color??n.stroke.color,n.stroke.width=t.width??n.stroke.width)},pi=(n,t)=>{t&&(n.font.color=t.color??n.font.color,n.font.size=t.size??n.font.size)},Ei=n=>{const t={fill:{color:p.DEFAULT_OVERLAY_FILL_COLOR.valueOf(),opacity:p.DEFAULT_OVERLAY_FILL_OPACITY.valueOf()},stroke:{color:p.DEFAULT_OVERLAY_STROKE_COLOR.valueOf(),width:p.DEFAULT_OVERLAY_STROKE_WIDTH.valueOf()},font:{color:p.DEFAULT_OVERLAY_FONT_COLOR.valueOf(),size:p.DEFAULT_OVERLAY_FONT_SIZE.valueOf()}},e=n.style,s={...t};return e&&(gi(s,e.fill),Ti(s,e.stroke),pi(s,e.font)),s};class Si{convert(t){const e=fi(t),s=Ei(t);return{position:e,style:s}}}function Ci(n){return new mi(n,new Si)}class mi{constructor(t,e){this.graph=t,this.overlayConverter=e}addOverlays(t,e){const s=this.graph.getModel().getCell(t);if(s)for(const o of m(e)){const i=new gt(o.label,this.overlayConverter.convert(o));this.graph.addCellOverlay(s,i)}}removeAllOverlays(t){const e=this.graph.getModel().getCell(t);e&&this.graph.removeCellOverlays(e)}}function Ii(n){return new Ai(Ci(n))}class Ai{constructor(t){this.overlaysUpdater=t}addOverlays(t,e){this.overlaysUpdater.addOverlays(t,e)}removeAllOverlays(t){this.overlaysUpdater.removeAllOverlays(t)}}class Ni{element(t){return`svg > g > g > g[data-bpmn-id="${t}"]`}elementsOfKind(t){return`svg > g > g > g.${t}:not(.bpmn-label)`}}function vi(n){return new Oi(n,new Li(n.getModel()))}const nt=n=>{const t=m(n);return t.push(...t.map(e=>be(e))),t};class Oi{constructor(t,e){this.graph=t,this.styleManager=e}clear(){this.styleManager.clear()}updateStyle(t,e){if(!e)return;const s=this.graph.getModel(),o=nt(t).map(i=>s.getCell(i)).filter(Boolean);o.length!==0&&this.graph.batchUpdate(()=>{for(const i of o){this.styleManager.ensureStyleIsStored(i);let r=i.getStyle();r=b(r,c.STYLE_OPACITY,e.opacity,fe),r=Qt(r,e.stroke),r=Jt(r,e.font),sn(e)&&(r=nn(r,e.fill)),s.setStyle(i,r)}})}resetStyle(t){this.graph.batchUpdate(()=>{if(t||t=="")for(const e of nt(t))this.styleManager.resetStyleIfIsStored(e);else this.styleManager.resetAllStyles()})}}const st=I.EXTRA_CSS_CLASSES;class Li{constructor(t){g(this,"stylesCache",new Map);this.model=t}clear(){this.stylesCache.clear()}resetAllStyles(){for(const t of this.stylesCache.keys())this.resetStyle(t,this.stylesCache.get(t))}resetStyleIfIsStored(t){const e=this.stylesCache.get(t);e&&this.resetStyle(t,e)}resetStyle(t,e){const s=this.model.getCell(t),o=en(s.getStyle(),st,""),i=b(e,st,o);this.model.setStyle(s,i),this.stylesCache.delete(t)}ensureStyleIsStored(t){const e=t.getId();this.stylesCache.has(e)||this.stylesCache.set(e,t.getStyle())}}function _i(n){return new yi(vi(n))}class yi{constructor(t){this.styleUpdater=t}clearCache(){this.styleUpdater.clear()}updateStyle(t,e){this.styleUpdater.updateStyle(t,e)}resetStyle(t){this.styleUpdater.resetStyle(t)}}function wi(n,t){return new Ri(n,new bi(t.container,new Ni),ci(t),Ii(t),_i(t))}class Ri{constructor(t,e,s,o,i){this.bpmnModelRegistry=t,this.htmlElementRegistry=e,this.cssClassesRegistry=s,this.overlaysRegistry=o,this.styleRegistry=i,this.bpmnModelRegistry.registerOnLoadCallback(()=>{this.cssClassesRegistry.clearCache(),this.styleRegistry.clearCache()})}getModelElementsByIds(t){return pe(t).map(e=>this.bpmnModelRegistry.getBpmnSemantic(e)).filter(Boolean)}getElementsByIds(t){return this.getModelElementsByIds(t).map(e=>({bpmnSemantic:e,htmlElement:this.htmlElementRegistry.getBpmnHtmlElement(e.id)}))}getModelElementsByKinds(t){return pe(t).flatMap(e=>this.htmlElementRegistry.getBpmnHtmlElements(e)).map(e=>this.getRelatedBpmnSemantic(e))}getElementsByKinds(t){return pe(t).flatMap(e=>this.htmlElementRegistry.getBpmnHtmlElements(e)).map(e=>({htmlElement:e,bpmnSemantic:this.getRelatedBpmnSemantic(e)}))}getRelatedBpmnSemantic(t){return this.bpmnModelRegistry.getBpmnSemantic(t.dataset.bpmnId)}addCssClasses(t,e){this.cssClassesRegistry.addCssClasses(t,e)}removeCssClasses(t,e){this.cssClassesRegistry.removeCssClasses(t,e)}removeAllCssClasses(t){this.cssClassesRegistry.removeAllCssClasses(t)}toggleCssClasses(t,e){this.cssClassesRegistry.toggleCssClasses(t,e)}addOverlays(t,e){this.overlaysRegistry.addOverlays(t,e)}removeAllOverlays(t){this.overlaysRegistry.removeAllOverlays(t)}updateStyle(t,e){this.styleRegistry.updateStyle(t,e)}resetStyle(t){this.styleRegistry.resetStyle(t)}}class bi{constructor(t,e){this.container=t,this.querySelectors=e}getBpmnHtmlElement(t){return this.container.querySelector(this.querySelectors.element(t))}getBpmnHtmlElements(t){const e=this.querySelectors.elementsOfKind(Ae(t));return[...this.container.querySelectorAll(e)]}}const pe=n=>[...new Set(m(n))];class Fi{filter(t,e){const s=[],o=[];for(const E of m(e==null?void 0:e.pools).filter(S=>S&&Object.keys(S).length>0))E.id?s.push(E.id):E.name&&o.push(E.name);if(s.length===0&&o.length===0)return t;const{filteredPools:i,filteredPoolIds:r}=Pi(t,s,o),l=[...s,...r],{filteredLanes:a,filteredLaneIds:d,filteredFlowNodes:u,filteredFlowNodeIds:f}=_t(t.lanes,t.flowNodes,l),T=xi(t.edges,[...l,...d,...f]);if(i.length===0&&a.length===0&&u.length===0&&T.length===0){let E=s.length>0?` for ids [${s}]`:"";const S=E?" and":"";throw E+=o.length>0?`${S} for names [${o}]`:"",new Error("No matching pools"+E)}return{lanes:a,flowNodes:u,pools:i,edges:T}}}function Pi(n,t,e){const s=n.pools.filter(i=>t.includes(i.bpmnElement.id)||e.includes(i.bpmnElement.name)),o=s.map(i=>i.bpmnElement.id);return{filteredPools:s,filteredPoolIds:o}}function _t(n,t,e){const{filteredLanes:s,filteredLaneIds:o}=yt(n,e),{filteredLanes:i,filteredLaneIds:r,filteredFlowNodes:l,filteredFlowNodeIds:a}=ki(t,[...e,...o],n);return s.push(...i),o.push(...r),{filteredLanes:s,filteredLaneIds:o,filteredFlowNodes:l,filteredFlowNodeIds:a}}function yt(n,t){const e=n.filter(o=>t.includes(o.bpmnElement.parentId)),s=e.map(o=>o.bpmnElement.id);if(e.length>0){const{filteredLanes:o,filteredLaneIds:i}=yt(n,s);e.push(...o),s.push(...i)}return{filteredLanes:e,filteredLaneIds:s}}function ki(n,t,e){const s=n.filter(d=>t.includes(d.bpmnElement.parentId));if(s.length===0)return{filteredLanes:[],filteredLaneIds:[],filteredFlowNodes:[],filteredFlowNodeIds:[]};const o=s.map(d=>d.bpmnElement.id),{filteredLanes:i,filteredLaneIds:r,filteredFlowNodes:l,filteredFlowNodeIds:a}=_t(e,n,o);return s.push(...l),o.push(...a),{filteredLanes:i,filteredLaneIds:r,filteredFlowNodes:s,filteredFlowNodeIds:o}}function xi(n,t){return n.filter(e=>t.includes(e.bpmnElement.sourceReferenceId)&&t.includes(e.bpmnElement.targetReferenceId))}class Bi{constructor(){g(this,"searchableModel");g(this,"onLoadCallback")}load(t,e){var o;const s=new Fi().filter(t,e);return this.searchableModel=new Vi(s),(o=this.onLoadCallback)==null||o.call(this),Mi(s)}registerOnLoadCallback(t){this.onLoadCallback=t}getBpmnSemantic(t){var i;const e=(i=this.searchableModel)==null?void 0:i.elementById(t);if(!e)return;const s=e.bpmnElement,o=s instanceof M;return{id:t,isShape:o,kind:s.kind,name:s.name,...s instanceof de?{sourceRefId:s.sourceReferenceId,targetRefId:s.targetReferenceId}:{callActivityGlobalTaskKind:s instanceof z?s.globalTaskKind:void 0,callActivityKind:s instanceof z?s.callActivityKind:void 0,eventDefinitionKind:s instanceof U?s.eventDefinitionKind:void 0,linkEventSourceIds:s instanceof me&&s.eventDefinitionKind==y.LINK?s.sourceIds:void 0,linkEventTargetId:s instanceof Ie?s.targetId:void 0,incomingIds:s.incomingIds,outgoingIds:s.outgoingIds,parentId:s.parentId,subProcessKind:s instanceof se?s.subProcessKind:void 0}}}}function Mi(n){const t=new Set(n.flowNodes.filter(i=>{const r=i.bpmnElement;return C.isSubProcess(r.kind)&&r.markers.includes(_.EXPAND)}).map(i=>i.bpmnElement.id)),e=[],s=[],o=[];for(const i of n.flowNodes){const r=i.bpmnElement.kind;C.isSubProcess(r)?e.push(i):C.isBoundaryEvent(r)?s.push(i):t.has(i.bpmnElement.parentId)||o.push(i)}return{boundaryEvents:s,edges:n.edges,lanes:n.lanes,otherFlowNodes:o,pools:n.pools,subprocesses:e}}class Vi{constructor(t){g(this,"elements",new Map);for(const e of[...t.pools,...t.lanes,...t.flowNodes,...t.edges])this.elements.set(e.bpmnElement.id,e)}elementById(t){return this.elements.get(t)}}class Yi{constructor(t){g(this,"graph");g(this,"navigation");g(this,"bpmnElementsRegistry");g(this,"bpmnModelRegistry");g(this,"parserOptions");g(this,"rendererOptions");this.rendererOptions=t==null?void 0:t.renderer;const e=new is(Dt(t==null?void 0:t.container));this.graph=e.configure(t),this.navigation=new rs(this.graph),this.bpmnModelRegistry=new Bi,this.bpmnElementsRegistry=wi(this.bpmnModelRegistry,this.graph),this.parserOptions=t==null?void 0:t.parser}load(t,e){const s=ri(this.parserOptions).parse(t),o=this.bpmnModelRegistry.load(s,e==null?void 0:e.modelFilter);fn(this.graph,this.rendererOptions).render(o,e==null?void 0:e.fit)}}function ar(n){document.readyState==="complete"||document.readyState==="interactive"?setTimeout(n,1):document.addEventListener("DOMContentLoaded",n)}function A(n,...t){Ve("[DEMO]",n,...t)}function Ve(n,t,...e){console.info(`${n} ${t}`,...e)}function F(n,...t){Ve("[DEMO STARTUP]",n,...t)}function wt(n,t){Rt(n),window.alert(n)}function Rt(n){console.error("[DEMO]",n)}function $(n,...t){Ve("[DEMO DOWNLOAD]",n,...t)}async function Gi(n){A(`Fetching BPMN content from url ${n}`);const t=await fetch(n);if(!t.ok)throw new Error(`HTTP status ${t.status}`);return await t.text()}function bt(n,t,e){const s=document.createElement("a");t.startsWith("data:image/svg+xml")&&(e=encodeURIComponent(e),t+=","),s.setAttribute("href",t+e),s.setAttribute("download",n),s.style.display="none",document.body.append(s),s.click(),s.remove()}function Di(n){$("Start SVG download"),bt("diagram.svg","data:image/svg+xml",n),$("Download completed")}function Ui(n){$("Start PNG download");const t=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),e=URL.createObjectURL(t),s=document.createElement("img");s.setAttribute("style","position: absolute; top: -9999px"),s.crossOrigin="anonymous",document.body.append(s);const o=document.createElement("canvas"),i=o.getContext("2d");s.addEventListener("load",function(){const r=new Image;o.width=s.naturalWidth,o.height=s.naturalHeight,r.crossOrigin="Anonymous",r.addEventListener("load",function(){i.drawImage(r,0,0),URL.revokeObjectURL(e);const l=o.toDataURL("image/png");s.remove(),bt("diagram.png","",l),$("Download completed")}),r.src=s.src}),s.src=e}class Wi{constructor(t,e,s,o){g(this,"document");g(this,"head");this.window=t,this.outerContainerId=e,this.containerToFade=s,this.dropCallback=o,this.document=t.document,this.head=document.head,this.initializeDragAndDrop()}initializeDragAndDrop(){this.containerToFade.classList.add("faded-container"),this.addDomElements(this.containerToFade),this.addStyle();const t=document.querySelector(`#${this.outerContainerId}`);this.preventDefaultsOnEvents(["dragover","drop"],this.window),this.preventDefaultsOnEvents(["dragover","dragleave","drop"],t),this.addEventsOnDropContainer(t,this.containerToFade),this.addEventsOnDocument(this.outerContainerId,this.containerToFade)}preventDefaults(t){t.preventDefault(),t.stopPropagation()}preventDefaultsOnEvents(t,e){for(const s of t)e.addEventListener(s,this.preventDefaults.bind(this),!1)}addDomElements(t){const e=this.document.createElement("p");e.textContent="open BPMN diagram";const s=this.document.createElement("div");s.classList.add("drop-here-text"),s.append(e);const o=this.document.createElement("div");o.id=this.outerContainerId,o.append(s),t.parentNode.prepend(o)}addStyle(){const t=`
+`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}s.prototype.build=function(r){return this.options.preserveOrder?n(r,this.options):(Array.isArray(r)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(r={[this.options.arrayNodeName]:r}),this.j2x(r,0,[]).val)},s.prototype.j2x=function(r,l,c){let f="",T="";const p=c.join(".");for(let S in r)if(Object.prototype.hasOwnProperty.call(r,S))if(typeof r[S]>"u")this.isAttribute(S)&&(T+="");else if(r[S]===null)this.isAttribute(S)?T+="":S[0]==="?"?T+=this.indentate(l)+"<"+S+"?"+this.tagEndChar:T+=this.indentate(l)+"<"+S+"/"+this.tagEndChar;else if(r[S]instanceof Date)T+=this.buildTextValNode(r[S],S,"",l);else if(typeof r[S]!="object"){const O=this.isAttribute(S);if(O&&!this.ignoreAttributesFn(O,p))f+=this.buildAttrPairStr(O,""+r[S]);else if(!O)if(S===this.options.textNodeName){let L=this.options.tagValueProcessor(S,""+r[S]);T+=this.replaceEntitiesValue(L)}else T+=this.buildTextValNode(r[S],S,"",l)}else if(Array.isArray(r[S])){const O=r[S].length;let L="",M="";for(let d=0;dFi.get(n.position),xi=(n,t)=>{t&&(n.fill.color=t.color??n.fill.color,n.fill.opacity=t.opacity??n.fill.opacity)},ki=(n,t)=>{t&&(n.stroke.color=t.color??n.stroke.color,n.stroke.width=t.width??n.stroke.width)},Bi=(n,t)=>{t&&(n.font.color=t.color??n.font.color,n.font.size=t.size??n.font.size)},Mi=n=>{const t={fill:{color:R.DEFAULT_OVERLAY_FILL_COLOR.valueOf(),opacity:R.DEFAULT_OVERLAY_FILL_OPACITY.valueOf()},stroke:{color:R.DEFAULT_OVERLAY_STROKE_COLOR.valueOf(),width:R.DEFAULT_OVERLAY_STROKE_WIDTH.valueOf()},font:{color:R.DEFAULT_OVERLAY_FONT_COLOR.valueOf(),size:R.DEFAULT_OVERLAY_FONT_SIZE.valueOf()}},e=n.style,s={...t};return e&&(xi(s,e.fill),ki(s,e.stroke),Bi(s,e.font)),s};class Vi{convert(t){const e=Pi(t),s=Mi(t);return{position:e,style:s}}}function Yi(n){return new Gi(n,new Vi)}class Gi{constructor(t,e){this.graph=t,this.overlayConverter=e}addOverlays(t,e){const s=this.graph.getModel().getCell(t);if(s)for(const i of P(e)){const o=new Kt(i.label,this.overlayConverter.convert(i));this.graph.addCellOverlay(s,o)}}removeAllOverlays(t){const e=this.graph.getModel().getCell(t);e&&this.graph.removeCellOverlays(e)}}function Di(n){return new Ui(Yi(n))}class Ui{constructor(t){this.overlaysUpdater=t}addOverlays(t,e){this.overlaysUpdater.addOverlays(t,e)}removeAllOverlays(t){this.overlaysUpdater.removeAllOverlays(t)}}class Wi{element(t){return`svg > g > g > g[data-bpmn-id="${t}"]`}elementsOfKind(t){return`svg > g > g > g.${t}:not(.bpmn-label)`}}function Hi(n){return new Ki(n,new zi(n.getModel()))}const Pt=n=>{const t=P(n);return t.push(...t.map(e=>et(e))),t};class Ki{constructor(t,e){this.graph=t,this.styleManager=e}clear(){this.styleManager.clear()}updateStyle(t,e){if(!e)return;const s=this.graph.getModel(),i=Pt(t).map(o=>s.getCell(o)).filter(Boolean);i.length!==0&&this.graph.batchUpdate(()=>{for(const o of i){this.styleManager.ensureStyleIsStored(o);let a=o.getStyle();a=K(a,u.STYLE_OPACITY,e.opacity,Le),a=_n(a,e.stroke),a=yn(a,e.font),Fn(e)&&(a=bn(a,e.fill)),s.setStyle(o,a)}})}resetStyle(t){this.graph.batchUpdate(()=>{if(t||t=="")for(const e of Pt(t))this.styleManager.resetStyleIfIsStored(e);else this.styleManager.resetAllStyles()})}}const xt=x.EXTRA_CSS_CLASSES;class zi{constructor(t){y(this,"stylesCache",new Map);this.model=t}clear(){this.stylesCache.clear()}resetAllStyles(){for(const t of this.stylesCache.keys())this.resetStyle(t,this.stylesCache.get(t))}resetStyleIfIsStored(t){const e=this.stylesCache.get(t);e&&this.resetStyle(t,e)}resetStyle(t,e){const s=this.model.getCell(t),i=wn(s.getStyle(),xt,""),o=K(e,xt,i);this.model.setStyle(s,o),this.stylesCache.delete(t)}ensureStyleIsStored(t){const e=t.getId();this.stylesCache.has(e)||this.stylesCache.set(e,t.getStyle())}}function Xi(n){return new qi(Hi(n))}class qi{constructor(t){this.styleUpdater=t}clearCache(){this.styleUpdater.clear()}updateStyle(t,e){this.styleUpdater.updateStyle(t,e)}resetStyle(t){this.styleUpdater.resetStyle(t)}}function $i(n,t){return new Zi(n,new ji(t.container,new Wi),wi(t),Di(t),Xi(t))}class Zi{constructor(t,e,s,i,o){this.bpmnModelRegistry=t,this.htmlElementRegistry=e,this.cssClassesRegistry=s,this.overlaysRegistry=i,this.styleRegistry=o,this.bpmnModelRegistry.registerOnLoadCallback(()=>{this.cssClassesRegistry.clearCache(),this.styleRegistry.clearCache()})}getModelElementsByIds(t){return De(t).map(e=>this.bpmnModelRegistry.getBpmnSemantic(e)).filter(Boolean)}getElementsByIds(t){return this.getModelElementsByIds(t).map(e=>({bpmnSemantic:e,htmlElement:this.htmlElementRegistry.getBpmnHtmlElement(e.id)}))}getModelElementsByKinds(t){return De(t).flatMap(e=>this.htmlElementRegistry.getBpmnHtmlElements(e)).map(e=>this.getRelatedBpmnSemantic(e))}getElementsByKinds(t){return De(t).flatMap(e=>this.htmlElementRegistry.getBpmnHtmlElements(e)).map(e=>({htmlElement:e,bpmnSemantic:this.getRelatedBpmnSemantic(e)}))}getRelatedBpmnSemantic(t){return this.bpmnModelRegistry.getBpmnSemantic(t.dataset.bpmnId)}addCssClasses(t,e){this.cssClassesRegistry.addCssClasses(t,e)}removeCssClasses(t,e){this.cssClassesRegistry.removeCssClasses(t,e)}removeAllCssClasses(t){this.cssClassesRegistry.removeAllCssClasses(t)}toggleCssClasses(t,e){this.cssClassesRegistry.toggleCssClasses(t,e)}addOverlays(t,e){this.overlaysRegistry.addOverlays(t,e)}removeAllOverlays(t){this.overlaysRegistry.removeAllOverlays(t)}updateStyle(t,e){this.styleRegistry.updateStyle(t,e)}resetStyle(t){this.styleRegistry.resetStyle(t)}}class ji{constructor(t,e){this.container=t,this.querySelectors=e}getBpmnHtmlElement(t){return this.container.querySelector(this.querySelectors.element(t))}getBpmnHtmlElements(t){const e=this.querySelectors.elementsOfKind(Xe(t));return[...this.container.querySelectorAll(e)]}}const De=n=>[...new Set(P(n))];class Ji{filter(t,e){const s=[],i=[];for(const S of P(e==null?void 0:e.pools).filter(O=>O&&Object.keys(O).length>0))S.id?s.push(S.id):S.name&&i.push(S.name);if(s.length===0&&i.length===0)return t;const{filteredPools:o,filteredPoolIds:a}=Qi(t,s,i),r=[...s,...a],{filteredLanes:l,filteredLaneIds:c,filteredFlowNodes:f,filteredFlowNodeIds:T}=Qt(t.lanes,t.flowNodes,r),p=to(t.edges,[...r,...c,...T]);if(o.length===0&&l.length===0&&f.length===0&&p.length===0){let S=s.length>0?` for ids [${s}]`:"";const O=S?" and":"";throw S+=i.length>0?`${O} for names [${i}]`:"",new Error("No matching pools"+S)}return{lanes:l,flowNodes:f,pools:o,edges:p}}}function Qi(n,t,e){const s=n.pools.filter(o=>t.includes(o.bpmnElement.id)||e.includes(o.bpmnElement.name)),i=s.map(o=>o.bpmnElement.id);return{filteredPools:s,filteredPoolIds:i}}function Qt(n,t,e){const{filteredLanes:s,filteredLaneIds:i}=en(n,e),{filteredLanes:o,filteredLaneIds:a,filteredFlowNodes:r,filteredFlowNodeIds:l}=eo(t,[...e,...i],n);return s.push(...o),i.push(...a),{filteredLanes:s,filteredLaneIds:i,filteredFlowNodes:r,filteredFlowNodeIds:l}}function en(n,t){const e=n.filter(i=>t.includes(i.bpmnElement.parentId)),s=e.map(i=>i.bpmnElement.id);if(e.length>0){const{filteredLanes:i,filteredLaneIds:o}=en(n,s);e.push(...i),s.push(...o)}return{filteredLanes:e,filteredLaneIds:s}}function eo(n,t,e){const s=n.filter(c=>t.includes(c.bpmnElement.parentId));if(s.length===0)return{filteredLanes:[],filteredLaneIds:[],filteredFlowNodes:[],filteredFlowNodeIds:[]};const i=s.map(c=>c.bpmnElement.id),{filteredLanes:o,filteredLaneIds:a,filteredFlowNodes:r,filteredFlowNodeIds:l}=Qt(e,n,i);return s.push(...r),i.push(...l),{filteredLanes:o,filteredLaneIds:a,filteredFlowNodes:s,filteredFlowNodeIds:i}}function to(n,t){return n.filter(e=>t.includes(e.bpmnElement.sourceReferenceId)&&t.includes(e.bpmnElement.targetReferenceId))}class no{constructor(){y(this,"searchableModel");y(this,"onLoadCallback")}load(t,e){var i;const s=new Ji().filter(t,e);return this.searchableModel=new io(s),(i=this.onLoadCallback)==null||i.call(this),so(s)}registerOnLoadCallback(t){this.onLoadCallback=t}getBpmnSemantic(t){var o;const e=(o=this.searchableModel)==null?void 0:o.elementById(t);if(!e)return;const s=e.bpmnElement,i=s instanceof J;return{id:t,isShape:i,kind:s.kind,name:s.name,...s instanceof Ne?{sourceRefId:s.sourceReferenceId,targetRefId:s.targetReferenceId}:{callActivityGlobalTaskKind:s instanceof oe?s.globalTaskKind:void 0,callActivityKind:s instanceof oe?s.callActivityKind:void 0,eventDefinitionKind:s instanceof se?s.eventDefinitionKind:void 0,linkEventSourceIds:s instanceof Ke&&s.eventDefinitionKind==H.LINK?s.sourceIds:void 0,linkEventTargetId:s instanceof ze?s.targetId:void 0,incomingIds:s.incomingIds,outgoingIds:s.outgoingIds,parentId:s.parentId,subProcessKind:s instanceof ge?s.subProcessKind:void 0}}}}function so(n){const t=new Set(n.flowNodes.filter(o=>{const a=o.bpmnElement;return F.isSubProcess(a.kind)&&a.markers.includes(W.EXPAND)}).map(o=>o.bpmnElement.id)),e=[],s=[],i=[];for(const o of n.flowNodes){const a=o.bpmnElement.kind;F.isSubProcess(a)?e.push(o):F.isBoundaryEvent(a)?s.push(o):t.has(o.bpmnElement.parentId)||i.push(o)}return{boundaryEvents:s,edges:n.edges,lanes:n.lanes,otherFlowNodes:i,pools:n.pools,subprocesses:e}}class io{constructor(t){y(this,"elements",new Map);for(const e of[...t.pools,...t.lanes,...t.flowNodes,...t.edges])this.elements.set(e.bpmnElement.id,e)}elementById(t){return this.elements.get(t)}}class oo{constructor(t){y(this,"graph");y(this,"navigation");y(this,"bpmnElementsRegistry");y(this,"bpmnModelRegistry");y(this,"parserOptions");y(this,"rendererOptions");this.rendererOptions=t==null?void 0:t.renderer;const e=new Ps(gn(t==null?void 0:t.container));this.graph=e.configure(t),this.navigation=new xs(this.graph),this.bpmnModelRegistry=new no,this.bpmnElementsRegistry=$i(this.bpmnModelRegistry,this.graph),this.parserOptions=t==null?void 0:t.parser}load(t,e){const s=vi(this.parserOptions).parse(t),i=this.bpmnModelRegistry.load(s,e==null?void 0:e.modelFilter);Dn(this.graph,this.rendererOptions).render(i,e==null?void 0:e.fit)}}function _o(n){document.readyState==="complete"||document.readyState==="interactive"?setTimeout(n,1):document.addEventListener("DOMContentLoaded",n)}function V(n,...t){ot("[DEMO]",n,...t)}function ot(n,t,...e){console.info(`${n} ${t}`,...e)}function q(n,...t){ot("[DEMO STARTUP]",n,...t)}function tn(n,t){nn(n),window.alert(n)}function nn(n){console.error("[DEMO]",n)}function le(n,...t){ot("[DEMO DOWNLOAD]",n,...t)}async function ro(n){V(`Fetching BPMN content from url ${n}`);const t=await fetch(n);if(!t.ok)throw new Error(`HTTP status ${t.status}`);return await t.text()}function sn(n,t,e){const s=document.createElement("a");t.startsWith("data:image/svg+xml")&&(e=encodeURIComponent(e),t+=","),s.setAttribute("href",t+e),s.setAttribute("download",n),s.style.display="none",document.body.append(s),s.click(),s.remove()}function lo(n){le("Start SVG download"),sn("diagram.svg","data:image/svg+xml",n),le("Download completed")}function ao(n){le("Start PNG download");const t=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),e=URL.createObjectURL(t),s=document.createElement("img");s.setAttribute("style","position: absolute; top: -9999px"),s.crossOrigin="anonymous",document.body.append(s);const i=document.createElement("canvas"),o=i.getContext("2d");s.addEventListener("load",function(){const a=new Image;i.width=s.naturalWidth,i.height=s.naturalHeight,a.crossOrigin="Anonymous",a.addEventListener("load",function(){o.drawImage(a,0,0),URL.revokeObjectURL(e);const r=i.toDataURL("image/png");s.remove(),sn("diagram.png","",r),le("Download completed")}),a.src=s.src}),s.src=e}class co{constructor(t,e,s,i){y(this,"document");y(this,"head");this.window=t,this.outerContainerId=e,this.containerToFade=s,this.dropCallback=i,this.document=t.document,this.head=document.head,this.initializeDragAndDrop()}initializeDragAndDrop(){this.containerToFade.classList.add("faded-container"),this.addDomElements(this.containerToFade),this.addStyle();const t=document.querySelector(`#${this.outerContainerId}`);this.preventDefaultsOnEvents(["dragover","drop"],this.window),this.preventDefaultsOnEvents(["dragover","dragleave","drop"],t),this.addEventsOnDropContainer(t,this.containerToFade),this.addEventsOnDocument(this.outerContainerId,this.containerToFade)}preventDefaults(t){t.preventDefault(),t.stopPropagation()}preventDefaultsOnEvents(t,e){for(const s of t)e.addEventListener(s,this.preventDefaults.bind(this),!1)}addDomElements(t){const e=this.document.createElement("p");e.textContent="open BPMN diagram";const s=this.document.createElement("div");s.classList.add("drop-here-text"),s.append(e);const i=this.document.createElement("div");i.id=this.outerContainerId,i.append(s),t.parentNode.prepend(i)}addStyle(){const t=`
.faded-container {
opacity: 1;
}
@@ -47,7 +47,7 @@ var Mt=Object.defineProperty;var Vt=(n,t,e)=>t in n?Mt(n,t,{enumerable:!0,config
align-items: center;
border: 2px dashed rgba(0,0,0,.2);
border-radius: 7px;
-}`,e=document.createElement("style");e.append(document.createTextNode(t)),this.head.append(e)}addEventsOnDropContainer(t,e){t.addEventListener("dragover",this.getAddClassCallback(e,!1),!1),t.addEventListener("mousedown",this.getRemoveClassCallback(e,!1),!1),t.addEventListener("drop",this.getDropCallbackForElement(e,!1,this.dropCallback),!1)}addEventsOnDocument(t,e){this.document.addEventListener("dragover",this.getAddClassCallback(e,!0,t),!1),this.document.addEventListener("dragleave",this.getRemoveClassCallback(e,!0,t),!1),this.document.addEventListener("drop",this.getDropCallbackForElement(e,!0,this.dropCallback,t),!1)}getAddClassCallback(t,e,s){return function(){e?this.querySelector("#"+s).classList.add("dragging"):this.classList.add("dragging"),t.classList.add("faded")}}getRemoveClassCallback(t,e,s){return function(){e?this.querySelector("#"+s).classList.remove("dragging"):this.classList.remove("dragging"),t.classList.remove("faded")}}getDropCallbackForElement(t,e,s,o){return function(i){try{const l=i.dataTransfer.files;s(l[0])}catch(r){const l=r instanceof Error?r.message:String(r);wt(l)}finally{e?this.querySelector("#"+o).classList.remove("dragging"):this.classList.remove("dragging"),t.classList.remove("faded")}}}}class Ft{constructor(t){this.graph=t}exportSvg(){return this.doSvgExport(!0)}exportSvgForPng(){const t=zt.IS_FF;return this.doSvgExport(t)}doSvgExport(t){const e=this.computeSvg({scale:1,border:25,enableForeignObjectForLabel:t});return`
+}`,e=document.createElement("style");e.append(document.createTextNode(t)),this.head.append(e)}addEventsOnDropContainer(t,e){t.addEventListener("dragover",this.getAddClassCallback(e,!1),!1),t.addEventListener("mousedown",this.getRemoveClassCallback(e,!1),!1),t.addEventListener("drop",this.getDropCallbackForElement(e,!1,this.dropCallback),!1)}addEventsOnDocument(t,e){this.document.addEventListener("dragover",this.getAddClassCallback(e,!0,t),!1),this.document.addEventListener("dragleave",this.getRemoveClassCallback(e,!0,t),!1),this.document.addEventListener("drop",this.getDropCallbackForElement(e,!0,this.dropCallback,t),!1)}getAddClassCallback(t,e,s){return function(){e?this.querySelector("#"+s).classList.add("dragging"):this.classList.add("dragging"),t.classList.add("faded")}}getRemoveClassCallback(t,e,s){return function(){e?this.querySelector("#"+s).classList.remove("dragging"):this.classList.remove("dragging"),t.classList.remove("faded")}}getDropCallbackForElement(t,e,s,i){return function(o){try{const r=o.dataTransfer.files;s(r[0])}catch(a){const r=a instanceof Error?a.message:String(a);tn(r)}finally{e?this.querySelector("#"+i).classList.remove("dragging"):this.classList.remove("dragging"),t.classList.remove("faded")}}}}class on{constructor(t){this.graph=t}exportSvg(){return this.doSvgExport(!0)}exportSvgForPng(){const t=In.IS_FF;return this.doSvgExport(t)}doSvgExport(t){const e=this.computeSvg({scale:1,border:25,enableForeignObjectForLabel:t});return`
-${N.getXml(e)}
-`}computeSvg(t){const e=t.scale??1,s=t.border??0,o=t.crisp??!0,i=t.enableForeignObjectForLabel??!0,r=this.graph.getGraphBounds(),l=this.graph.view.scale,a=N.createXmlDocument(),d=a.createElementNS(c.NS_SVG,"svg"),u=e/l,f=Math.max(1,Math.ceil(r.width*u)+2*s),T=Math.max(1,Math.ceil(r.height*u)+2*s);d.setAttribute("version","1.1"),d.setAttribute("width",f+"px"),d.setAttribute("height",T+"px"),d.setAttribute("viewBox",(o?"-0.5 -0.5":"0 0")+" "+f+" "+T),a.append(d);const E=a.createElementNS(c.NS_SVG,"g");d.append(E);const S=this.createSvgCanvas(E);S.foEnabled=i,S.foOffset=o?-.5:0,S.textOffset=o?-.5:0,S.imageOffset=o?-.5:0,S.translate(Math.floor((s/e-r.x)/l),Math.floor((s/e-r.y)/l)),S.scale(u);const R=new O.mxImageExport;return R.includeOverlays=!0,R.drawState(this.graph.getView().getState(this.graph.model.root),S),a}createSvgCanvas(t){const e=new Hi(t);return e.pointerEvents=!0,e}}class Hi extends Re{constructor(e){super(e);g(this,"htmlConverter",document.createElement("div"))}getAlternateText(e,s,o,i,r,l,a,d,u,f,T,E,S){return this.computeTruncatedText(l,i)}plainText(e,s,o,i,r,l,a,d,u,f,T,E){r=this.computeTruncatedText(r,o),super.plainText(e,s,o,i,r,l,a,d,u,f,T,E)}computeTruncatedText(e,s){if(e==null||this.state.fontSize<=0)return"";try{this.htmlConverter.innerHTML=e,e=N.extractTextWithWhitespace(this.htmlConverter.childNodes);const o=Math.ceil(2*s/this.state.fontSize),i=[];let r=0,l=0;for(;(o==0||r
")),r==null&&t.overlays!=null&&t.overlays.visit(function(l,a){r==null&&(e==a.node||e.parentNode==a.node)&&(r=a.overlay.toString())}),r==null){var s=this.selectionCellsHandler.getHandler(t.cell);s!=null&&typeof s.getTooltipForNode=="function"&&(r=s.getTooltipForNode(e))}r==null&&(r=this.getTooltipForCell(t.cell))}return r},mxGraph.prototype.getTooltipForCell=function(t){var e=null;return t!=null&&t.getTooltip!=null?e=t.getTooltip():e=this.convertValueToString(t),e},mxGraph.prototype.getLinkForCell=function(t){return null},mxGraph.prototype.getCursorForMouseEvent=function(t){return this.getCursorForCell(t.getCell())},mxGraph.prototype.getCursorForCell=function(t){return null},mxGraph.prototype.getStartSize=function(t,e){var i=new mxRectangle,n=this.getCurrentCellStyle(t,e),r=parseInt(mxUtils.getValue(n,mxConstants.STYLE_STARTSIZE,mxConstants.DEFAULT_STARTSIZE));return mxUtils.getValue(n,mxConstants.STYLE_HORIZONTAL,!0)?i.height=r:i.width=r,i},mxGraph.prototype.getSwimlaneDirection=function(t){var e=mxUtils.getValue(t,mxConstants.STYLE_DIRECTION,mxConstants.DIRECTION_EAST),i=mxUtils.getValue(t,mxConstants.STYLE_FLIPH,0)==1,n=mxUtils.getValue(t,mxConstants.STYLE_FLIPV,0)==1,r=mxUtils.getValue(t,mxConstants.STYLE_HORIZONTAL,!0),s=r?0:3;e==mxConstants.DIRECTION_NORTH?s--:e==mxConstants.DIRECTION_WEST?s+=2:e==mxConstants.DIRECTION_SOUTH&&(s+=1);var l=mxUtils.mod(s,2);return i&&l==1&&(s+=2),n&&l==0&&(s+=2),[mxConstants.DIRECTION_NORTH,mxConstants.DIRECTION_EAST,mxConstants.DIRECTION_SOUTH,mxConstants.DIRECTION_WEST][mxUtils.mod(s,4)]},mxGraph.prototype.getActualStartSize=function(t,e){var i=new mxRectangle;if(this.isSwimlane(t,e)){var n=this.getCurrentCellStyle(t,e),r=parseInt(mxUtils.getValue(n,mxConstants.STYLE_STARTSIZE,mxConstants.DEFAULT_STARTSIZE)),s=this.getSwimlaneDirection(n);s==mxConstants.DIRECTION_NORTH?i.y=r:s==mxConstants.DIRECTION_WEST?i.x=r:s==mxConstants.DIRECTION_SOUTH?i.height=r:i.width=r}return i},mxGraph.prototype.getImage=function(t){return t!=null&&t.style!=null?t.style[mxConstants.STYLE_IMAGE]:null},mxGraph.prototype.isTransparentState=function(t){var e=!1;if(t!=null){var i=mxUtils.getValue(t.style,mxConstants.STYLE_STROKECOLOR,mxConstants.NONE),n=mxUtils.getValue(t.style,mxConstants.STYLE_FILLCOLOR,mxConstants.NONE);e=i==mxConstants.NONE&&n==mxConstants.NONE&&this.getImage(t)==null}return e},mxGraph.prototype.getVerticalAlign=function(t){return t!=null&&t.style!=null?t.style[mxConstants.STYLE_VERTICAL_ALIGN]||mxConstants.ALIGN_MIDDLE:null},mxGraph.prototype.getIndicatorColor=function(t){return t!=null&&t.style!=null?t.style[mxConstants.STYLE_INDICATOR_COLOR]:null},mxGraph.prototype.getIndicatorGradientColor=function(t){return t!=null&&t.style!=null?t.style[mxConstants.STYLE_INDICATOR_GRADIENTCOLOR]:null},mxGraph.prototype.getIndicatorShape=function(t){return t!=null&&t.style!=null?t.style[mxConstants.STYLE_INDICATOR_SHAPE]:null},mxGraph.prototype.getIndicatorImage=function(t){return t!=null&&t.style!=null?t.style[mxConstants.STYLE_INDICATOR_IMAGE]:null},mxGraph.prototype.getBorder=function(){return this.border},mxGraph.prototype.setBorder=function(t){this.border=t},mxGraph.prototype.isSwimlane=function(t,e){return t!=null&&this.model.getParent(t)!=this.model.getRoot()&&!this.model.isEdge(t)?this.getCurrentCellStyle(t,e)[mxConstants.STYLE_SHAPE]==mxConstants.SHAPE_SWIMLANE:!1},mxGraph.prototype.isResizeContainer=function(){return this.resizeContainer},mxGraph.prototype.setResizeContainer=function(t){this.resizeContainer=t},mxGraph.prototype.isEnabled=function(){return this.enabled},mxGraph.prototype.setEnabled=function(t){this.enabled=t},mxGraph.prototype.isEscapeEnabled=function(){return this.escapeEnabled},mxGraph.prototype.setEscapeEnabled=function(t){this.escapeEnabled=t},mxGraph.prototype.isInvokesStopCellEditing=function(){return this.invokesStopCellEditing},mxGraph.prototype.setInvokesStopCellEditing=function(t){this.invokesStopCellEditing=t},mxGraph.prototype.isEnterStopsCellEditing=function(){return this.enterStopsCellEditing},mxGraph.prototype.setEnterStopsCellEditing=function(t){this.enterStopsCellEditing=t},mxGraph.prototype.isCellLocked=function(t){var e=this.model.getGeometry(t);return this.isCellsLocked()||e!=null&&this.model.isVertex(t)&&e.relative},mxGraph.prototype.isCellsLocked=function(){return this.cellsLocked},mxGraph.prototype.setCellsLocked=function(t){this.cellsLocked=t},mxGraph.prototype.getCloneableCells=function(t){return this.model.filterCells(t,mxUtils.bind(this,function(e){return this.isCellCloneable(e)}))},mxGraph.prototype.isCellCloneable=function(t){var e=this.getCurrentCellStyle(t);return this.isCellsCloneable()&&e[mxConstants.STYLE_CLONEABLE]!=0},mxGraph.prototype.isCellsCloneable=function(){return this.cellsCloneable},mxGraph.prototype.setCellsCloneable=function(t){this.cellsCloneable=t},mxGraph.prototype.getExportableCells=function(t){return this.model.filterCells(t,mxUtils.bind(this,function(e){return this.canExportCell(e)}))},mxGraph.prototype.canExportCell=function(t){return this.exportEnabled},mxGraph.prototype.getImportableCells=function(t){return this.model.filterCells(t,mxUtils.bind(this,function(e){return this.canImportCell(e)}))},mxGraph.prototype.canImportCell=function(t){return this.importEnabled},mxGraph.prototype.isCellSelectable=function(t){return this.isCellsSelectable()},mxGraph.prototype.isCellsSelectable=function(){return this.cellsSelectable},mxGraph.prototype.setCellsSelectable=function(t){this.cellsSelectable=t},mxGraph.prototype.getDeletableCells=function(t){return this.model.filterCells(t,mxUtils.bind(this,function(e){return this.isCellDeletable(e)}))},mxGraph.prototype.isCellDeletable=function(t){var e=this.getCurrentCellStyle(t);return this.isCellsDeletable()&&e[mxConstants.STYLE_DELETABLE]!=0},mxGraph.prototype.isCellsDeletable=function(){return this.cellsDeletable},mxGraph.prototype.setCellsDeletable=function(t){this.cellsDeletable=t},mxGraph.prototype.isLabelMovable=function(t){return!this.isCellLocked(t)&&(this.model.isEdge(t)&&this.edgeLabelsMovable||this.model.isVertex(t)&&this.vertexLabelsMovable)},mxGraph.prototype.isCellRotatable=function(t){var e=this.getCurrentCellStyle(t);return e[mxConstants.STYLE_ROTATABLE]!=0},mxGraph.prototype.getMovableCells=function(t){return this.model.filterCells(t,mxUtils.bind(this,function(e){return this.isCellMovable(e)}))},mxGraph.prototype.isCellMovable=function(t){var e=this.getCurrentCellStyle(t);return this.isCellsMovable()&&!this.isCellLocked(t)&&e[mxConstants.STYLE_MOVABLE]!=0},mxGraph.prototype.isCellsMovable=function(){return this.cellsMovable},mxGraph.prototype.setCellsMovable=function(t){this.cellsMovable=t},mxGraph.prototype.isGridEnabled=function(){return this.gridEnabled},mxGraph.prototype.setGridEnabled=function(t){this.gridEnabled=t},mxGraph.prototype.isPortsEnabled=function(){return this.portsEnabled},mxGraph.prototype.setPortsEnabled=function(t){this.portsEnabled=t},mxGraph.prototype.getGridSize=function(){return this.gridSize},mxGraph.prototype.setGridSize=function(t){this.gridSize=t},mxGraph.prototype.getTolerance=function(){return this.tolerance},mxGraph.prototype.setTolerance=function(t){this.tolerance=t},mxGraph.prototype.isVertexLabelsMovable=function(){return this.vertexLabelsMovable},mxGraph.prototype.setVertexLabelsMovable=function(t){this.vertexLabelsMovable=t},mxGraph.prototype.isEdgeLabelsMovable=function(){return this.edgeLabelsMovable},mxGraph.prototype.setEdgeLabelsMovable=function(t){this.edgeLabelsMovable=t},mxGraph.prototype.isSwimlaneNesting=function(){return this.swimlaneNesting},mxGraph.prototype.setSwimlaneNesting=function(t){this.swimlaneNesting=t},mxGraph.prototype.isSwimlaneSelectionEnabled=function(){return this.swimlaneSelectionEnabled},mxGraph.prototype.setSwimlaneSelectionEnabled=function(t){this.swimlaneSelectionEnabled=t},mxGraph.prototype.isMultigraph=function(){return this.multigraph},mxGraph.prototype.setMultigraph=function(t){this.multigraph=t},mxGraph.prototype.isAllowLoops=function(){return this.allowLoops},mxGraph.prototype.setAllowDanglingEdges=function(t){this.allowDanglingEdges=t},mxGraph.prototype.isAllowDanglingEdges=function(){return this.allowDanglingEdges},mxGraph.prototype.setConnectableEdges=function(t){this.connectableEdges=t},mxGraph.prototype.isConnectableEdges=function(){return this.connectableEdges},mxGraph.prototype.setCloneInvalidEdges=function(t){this.cloneInvalidEdges=t},mxGraph.prototype.isCloneInvalidEdges=function(){return this.cloneInvalidEdges},mxGraph.prototype.setAllowLoops=function(t){this.allowLoops=t},mxGraph.prototype.isDisconnectOnMove=function(){return this.disconnectOnMove},mxGraph.prototype.setDisconnectOnMove=function(t){this.disconnectOnMove=t},mxGraph.prototype.isDropEnabled=function(){return this.dropEnabled},mxGraph.prototype.setDropEnabled=function(t){this.dropEnabled=t},mxGraph.prototype.isSplitEnabled=function(){return this.splitEnabled},mxGraph.prototype.setSplitEnabled=function(t){this.splitEnabled=t},mxGraph.prototype.isCellResizable=function(t){var e=this.getCurrentCellStyle(t);return this.isCellsResizable()&&!this.isCellLocked(t)&&mxUtils.getValue(e,mxConstants.STYLE_RESIZABLE,"1")!="0"},mxGraph.prototype.isCellsResizable=function(){return this.cellsResizable},mxGraph.prototype.setCellsResizable=function(t){this.cellsResizable=t},mxGraph.prototype.isTerminalPointMovable=function(t,e){return!0},mxGraph.prototype.isCellBendable=function(t){var e=this.getCurrentCellStyle(t);return this.isCellsBendable()&&!this.isCellLocked(t)&&e[mxConstants.STYLE_BENDABLE]!=0},mxGraph.prototype.isCellsBendable=function(){return this.cellsBendable},mxGraph.prototype.setCellsBendable=function(t){this.cellsBendable=t},mxGraph.prototype.isCellEditable=function(t){var e=this.getCurrentCellStyle(t);return this.isCellsEditable()&&!this.isCellLocked(t)&&e[mxConstants.STYLE_EDITABLE]!=0},mxGraph.prototype.isCellsEditable=function(){return this.cellsEditable},mxGraph.prototype.setCellsEditable=function(t){this.cellsEditable=t},mxGraph.prototype.isCellDisconnectable=function(t,e,i){return this.isCellsDisconnectable()&&!this.isCellLocked(t)},mxGraph.prototype.isCellsDisconnectable=function(){return this.cellsDisconnectable},mxGraph.prototype.setCellsDisconnectable=function(t){this.cellsDisconnectable=t},mxGraph.prototype.isValidSource=function(t){return t==null&&this.allowDanglingEdges||t!=null&&(!this.model.isEdge(t)||this.connectableEdges)&&this.isCellConnectable(t)},mxGraph.prototype.isValidTarget=function(t){return this.isValidSource(t)},mxGraph.prototype.isValidConnection=function(t,e){return this.isValidSource(t)&&this.isValidTarget(e)},mxGraph.prototype.setConnectable=function(t){this.connectionHandler.setEnabled(t)},mxGraph.prototype.isConnectable=function(){return this.connectionHandler.isEnabled()},mxGraph.prototype.setTooltips=function(t){this.tooltipHandler.setEnabled(t)},mxGraph.prototype.setPanning=function(t){this.panningHandler.panningEnabled=t},mxGraph.prototype.isEditing=function(t){if(this.cellEditor!=null){var e=this.cellEditor.getEditingCell();return t==null?e!=null:t==e}return!1},mxGraph.prototype.isAutoSizeCell=function(t){var e=this.getCurrentCellStyle(t);return this.isAutoSizeCells()||e[mxConstants.STYLE_AUTOSIZE]==1},mxGraph.prototype.isAutoSizeCells=function(){return this.autoSizeCells},mxGraph.prototype.setAutoSizeCells=function(t){this.autoSizeCells=t},mxGraph.prototype.isExtendParent=function(t){return!this.getModel().isEdge(t)&&this.isExtendParents()},mxGraph.prototype.isExtendParents=function(){return this.extendParents},mxGraph.prototype.setExtendParents=function(t){this.extendParents=t},mxGraph.prototype.isExtendParentsOnAdd=function(t){return this.extendParentsOnAdd},mxGraph.prototype.setExtendParentsOnAdd=function(t){this.extendParentsOnAdd=t},mxGraph.prototype.isExtendParentsOnMove=function(){return this.extendParentsOnMove},mxGraph.prototype.setExtendParentsOnMove=function(t){this.extendParentsOnMove=t},mxGraph.prototype.isRecursiveResize=function(t){return this.recursiveResize},mxGraph.prototype.setRecursiveResize=function(t){this.recursiveResize=t},mxGraph.prototype.isConstrainChild=function(t){return this.isConstrainChildren()&&!this.getModel().isEdge(this.getModel().getParent(t))},mxGraph.prototype.isConstrainChildren=function(){return this.constrainChildren},mxGraph.prototype.setConstrainChildren=function(t){this.constrainChildren=t},mxGraph.prototype.isConstrainRelativeChildren=function(){return this.constrainRelativeChildren},mxGraph.prototype.setConstrainRelativeChildren=function(t){this.constrainRelativeChildren=t},mxGraph.prototype.isAllowNegativeCoordinates=function(){return this.allowNegativeCoordinates},mxGraph.prototype.setAllowNegativeCoordinates=function(t){this.allowNegativeCoordinates=t},mxGraph.prototype.getOverlap=function(t){return this.isAllowOverlapParent(t)?this.defaultOverlap:0},mxGraph.prototype.isAllowOverlapParent=function(t){return!1},mxGraph.prototype.getFoldableCells=function(t,e){return this.model.filterCells(t,mxUtils.bind(this,function(i){return this.isCellFoldable(i,e)}))},mxGraph.prototype.isCellFoldable=function(t,e){var i=this.getCurrentCellStyle(t);return this.model.getChildCount(t)>0&&i[mxConstants.STYLE_FOLDABLE]!=0},mxGraph.prototype.isValidDropTarget=function(t,e,i){return t!=null&&(this.isSplitEnabled()&&this.isSplitTarget(t,e,i)||!this.model.isEdge(t)&&(this.isSwimlane(t)||this.model.getChildCount(t)>0&&!this.isCellCollapsed(t)))},mxGraph.prototype.isSplitTarget=function(t,e,i){if(this.model.isEdge(t)&&e!=null&&e.length==1&&this.isCellConnectable(e[0])&&this.getEdgeValidationError(t,this.model.getTerminal(t,!0),e[0])==null){var n=this.model.getTerminal(t,!0),r=this.model.getTerminal(t,!1);return!this.model.isAncestor(e[0],n)&&!this.model.isAncestor(e[0],r)}return!1},mxGraph.prototype.getDropTarget=function(t,e,i,n){if(!this.isSwimlaneNesting()){for(var r=0;r0||!i&&d==0&&m>0)&&n.push(u);var g=i?d-m:m-d;g>a&&(a=g,l=u)}}n.length==0&&l!=null&&n.push(l)}return n},mxGraph.prototype.traverse=function(t,e,i,n,r,s){if(i!=null&&t!=null&&(e=e??!0,s=s??!1,r=r||new mxDictionary,!r.get(t))){r.put(t,!0);var l=i(t,n);if(l==null||l){var a=this.model.getEdgeCount(t);if(a>0)for(var o=0;o0?n.cells[0]:null;n.cells.length>1&&n.clear();var s=r!=null?this.model.getParent(r):this.getDefaultParent(),l=this.model.getChildCount(s);if(r==null&&l>0){var a=this.model.getChildAt(s,0);this.setSelectionCell(a)}else if((r==null||e)&&this.view.getState(s)!=null&&this.model.getGeometry(s)!=null)this.getCurrentRoot()!=s&&this.setSelectionCell(s);else if(r!=null&&i){var o=this.model.getChildCount(r);if(o>0){var a=this.model.getChildAt(r,0);this.setSelectionCell(a)}}else if(l>0){var u=s.getIndex(r);if(t){u++;var a=this.model.getChildAt(s,u%l);this.setSelectionCell(a)}else{u--;var p=u<0?l-1:u,a=this.model.getChildAt(s,p);this.setSelectionCell(a)}}},mxGraph.prototype.selectAll=function(t,e){t=t||this.getDefaultParent();var i=e?this.model.filterDescendants(mxUtils.bind(this,function(n){return n!=t&&this.view.getState(n)!=null}),t):this.model.getChildren(t);i!=null&&this.setSelectionCells(i)},mxGraph.prototype.selectVertices=function(t,e){this.selectCells(!0,!1,t,e)},mxGraph.prototype.selectEdges=function(t){this.selectCells(!1,!0,t)},mxGraph.prototype.selectCells=function(t,e,i,n){i=i||this.getDefaultParent();var r=mxUtils.bind(this,function(l){return this.view.getState(l)!=null&&((n||this.model.getChildCount(l)==0)&&this.model.isVertex(l)&&t&&!this.model.isEdge(this.model.getParent(l))||this.model.isEdge(l)&&e)}),s=this.model.filterDescendants(r,i);s!=null&&this.setSelectionCells(s)},mxGraph.prototype.selectCellForEvent=function(t,e){var i=this.isCellSelected(t);this.isToggleEvent(e)?i?this.removeSelectionCell(t):this.addSelectionCell(t):(!i||this.getSelectionCount()!=1)&&this.setSelectionCell(t)},mxGraph.prototype.selectCellsForEvent=function(t,e){this.isToggleEvent(e)?this.addSelectionCells(t):this.setSelectionCells(t)},mxGraph.prototype.createHandler=function(t){var e=null;if(t!=null)if(this.model.isEdge(t.cell)){var i=t.getVisibleTerminalState(!0),n=t.getVisibleTerminalState(!1),r=this.getCellGeometry(t.cell),s=this.view.getEdgeStyle(t,r!=null?r.points:null,i,n);e=this.createEdgeHandler(t,s)}else e=this.createVertexHandler(t);return e},mxGraph.prototype.createVertexHandler=function(t){return new mxVertexHandler(t)},mxGraph.prototype.createEdgeHandler=function(t,e){var i=null;return e==mxEdgeStyle.Loop||e==mxEdgeStyle.ElbowConnector||e==mxEdgeStyle.SideToSide||e==mxEdgeStyle.TopToBottom?i=this.createElbowEdgeHandler(t):e==mxEdgeStyle.SegmentConnector||e==mxEdgeStyle.OrthConnector?i=this.createEdgeSegmentHandler(t):i=new mxEdgeHandler(t),i},mxGraph.prototype.createEdgeSegmentHandler=function(t){return new mxEdgeSegmentHandler(t)},mxGraph.prototype.createElbowEdgeHandler=function(t){return new mxElbowEdgeHandler(t)},mxGraph.prototype.addMouseListener=function(t){this.mouseListeners==null&&(this.mouseListeners=[]),this.mouseListeners.push(t)},mxGraph.prototype.removeMouseListener=function(t){if(this.mouseListeners!=null){for(var e=0;e
"),this.div.style.visibility="",mxUtils.fit(this.div)}},mxTooltipHandler.prototype.destroy=function(){this.destroyed||(this.graph.removeMouseListener(this),mxEvent.release(this.div),this.div!=null&&this.div.parentNode!=null&&this.div.parentNode.removeChild(this.div),this.destroyed=!0,this.div=null)},__mxOutput.mxTooltipHandler=typeof mxTooltipHandler<"u"?mxTooltipHandler:void 0;function mxCellTracker(t,e,i){mxCellMarker.call(this,t,e),this.graph.addMouseListener(this),i!=null&&(this.getCell=i),mxClient.IS_IE&&mxEvent.addListener(window,"unload",mxUtils.bind(this,function(){this.destroy()}))}mxUtils.extend(mxCellTracker,mxCellMarker),mxCellTracker.prototype.mouseDown=function(t,e){},mxCellTracker.prototype.mouseMove=function(t,e){this.isEnabled()&&this.process(e)},mxCellTracker.prototype.mouseUp=function(t,e){},mxCellTracker.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this.graph.removeMouseListener(this),mxCellMarker.prototype.destroy.apply(this))},__mxOutput.mxCellTracker=typeof mxCellTracker<"u"?mxCellTracker:void 0;function mxCellHighlight(t,e,i,n){t!=null&&(this.graph=t,this.highlightColor=e??mxConstants.DEFAULT_VALID_COLOR,this.strokeWidth=i??mxConstants.HIGHLIGHT_STROKEWIDTH,this.dashed=n??!1,this.opacity=mxConstants.HIGHLIGHT_OPACITY,this.repaintHandler=mxUtils.bind(this,function(){if(this.state!=null){var r=this.graph.view.getState(this.state.cell);r==null?this.hide():(this.state=r,this.repaint())}}),this.graph.getView().addListener(mxEvent.SCALE,this.repaintHandler),this.graph.getView().addListener(mxEvent.TRANSLATE,this.repaintHandler),this.graph.getView().addListener(mxEvent.SCALE_AND_TRANSLATE,this.repaintHandler),this.graph.getModel().addListener(mxEvent.CHANGE,this.repaintHandler),this.resetHandler=mxUtils.bind(this,function(){this.hide()}),this.graph.getView().addListener(mxEvent.DOWN,this.resetHandler),this.graph.getView().addListener(mxEvent.UP,this.resetHandler))}mxCellHighlight.prototype.keepOnTop=!1,mxCellHighlight.prototype.graph=null,mxCellHighlight.prototype.state=null,mxCellHighlight.prototype.spacing=2,mxCellHighlight.prototype.resetHandler=null,mxCellHighlight.prototype.setHighlightColor=function(t){this.highlightColor=t,this.shape!=null&&(this.shape.stroke=t)},mxCellHighlight.prototype.drawHighlight=function(){this.shape=this.createShape(),this.repaint(),!this.keepOnTop&&this.shape.node.parentNode.firstChild!=this.shape.node&&this.shape.node.parentNode.insertBefore(this.shape.node,this.shape.node.parentNode.firstChild)},mxCellHighlight.prototype.createShape=function(){var t=this.graph.cellRenderer.createShape(this.state);return t.svgStrokeTolerance=this.graph.tolerance,t.points=this.state.absolutePoints,t.apply(this.state),t.stroke=this.highlightColor,t.opacity=this.opacity,t.isDashed=this.dashed,t.isShadow=!1,t.dialect=this.graph.dialect!=mxConstants.DIALECT_SVG?mxConstants.DIALECT_VML:mxConstants.DIALECT_SVG,t.init(this.graph.getView().getOverlayPane()),mxEvent.redirectMouseEvents(t.node,this.graph,this.state),this.graph.dialect!=mxConstants.DIALECT_SVG?t.pointerEvents=!1:t.svgPointerEvents="stroke",t},mxCellHighlight.prototype.getStrokeWidth=function(t){return this.strokeWidth},mxCellHighlight.prototype.repaint=function(){this.state!=null&&this.shape!=null&&(this.shape.scale=this.state.view.scale,this.graph.model.isEdge(this.state.cell)?(this.shape.strokewidth=this.getStrokeWidth(),this.shape.points=this.state.absolutePoints,this.shape.outline=!1):(this.shape.bounds=new mxRectangle(this.state.x-this.spacing,this.state.y-this.spacing,this.state.width+2*this.spacing,this.state.height+2*this.spacing),this.shape.rotation=Number(this.state.style[mxConstants.STYLE_ROTATION]||"0"),this.shape.strokewidth=this.getStrokeWidth()/this.state.view.scale,this.shape.outline=!0),this.state.shape!=null&&this.shape.setCursor(this.state.shape.getCursor()),(mxClient.IS_QUIRKS||document.documentMode==8)&&(this.shape.stroke=="transparent"?(this.shape.stroke="white",this.shape.opacity=1):this.shape.opacity=this.opacity),this.shape.redraw())},mxCellHighlight.prototype.hide=function(){this.highlight(null)},mxCellHighlight.prototype.highlight=function(t){this.state!=t&&(this.shape!=null&&(this.shape.destroy(),this.shape=null),this.state=t,this.state!=null&&this.drawHighlight())},mxCellHighlight.prototype.isHighlightAt=function(t,e){var i=!1;if(this.shape!=null&&document.elementFromPoint!=null&&!mxClient.IS_QUIRKS)for(var n=document.elementFromPoint(t,e);n!=null;){if(n==this.shape.node){i=!0;break}n=n.parentNode}return i},mxCellHighlight.prototype.destroy=function(){this.graph.getView().removeListener(this.resetHandler),this.graph.getView().removeListener(this.repaintHandler),this.graph.getModel().removeListener(this.repaintHandler),this.shape!=null&&(this.shape.destroy(),this.shape=null)},__mxOutput.mxCellHighlight=typeof mxCellHighlight<"u"?mxCellHighlight:void 0;function mxDefaultKeyHandler(t){if(t!=null){this.editor=t,this.handler=new mxKeyHandler(t.graph);var e=this.handler.escape;this.handler.escape=function(i){e.apply(this,arguments),t.hideProperties(),t.fireEvent(new mxEventObject(mxEvent.ESCAPE,"event",i))}}}mxDefaultKeyHandler.prototype.editor=null,mxDefaultKeyHandler.prototype.handler=null,mxDefaultKeyHandler.prototype.bindAction=function(t,e,i){var n=mxUtils.bind(this,function(){this.editor.execute(e)});i?this.handler.bindControlKey(t,n):this.handler.bindKey(t,n)},mxDefaultKeyHandler.prototype.destroy=function(){this.handler.destroy(),this.handler=null},__mxOutput.mxDefaultKeyHandler=typeof mxDefaultKeyHandler<"u"?mxDefaultKeyHandler:void 0;function mxDefaultPopupMenu(t){this.config=t}mxDefaultPopupMenu.prototype.imageBasePath=null,mxDefaultPopupMenu.prototype.config=null,mxDefaultPopupMenu.prototype.createMenu=function(t,e,i,n){if(this.config!=null){var r=this.createConditions(t,i,n),s=this.config.firstChild;this.addItems(t,e,i,n,r,s,null)}},mxDefaultPopupMenu.prototype.addItems=function(t,e,i,n,r,s,l){for(var a=!1;s!=null;){if(s.nodeName=="add"){var o=s.getAttribute("if");if(o==null||r[o]){var u=s.getAttribute("as");u=mxResources.get(u)||u;var p=mxUtils.eval(mxUtils.getTextContent(s)),m=s.getAttribute("action"),d=s.getAttribute("icon"),x=s.getAttribute("iconCls"),f=s.getAttribute("enabled-if"),g=f==null||r[f];a&&(e.addSeparator(l),a=!1),d!=null&&this.imageBasePath&&(d=this.imageBasePath+d);var c=this.addAction(e,t,u,d,p,m,i,l,x,g);this.addItems(t,e,i,n,r,s.firstChild,c)}}else s.nodeName=="separator"&&(a=!0);s=s.nextSibling}},mxDefaultPopupMenu.prototype.addAction=function(t,e,i,n,r,s,l,a,o,u){var p=function(m){typeof r=="function"&&r.call(e,e,l,m),s!=null&&e.execute(s,l,m)};return t.addItem(i,n,p,a,o,u)},mxDefaultPopupMenu.prototype.createConditions=function(t,e,i){var n=t.graph.getModel(),r=n.getChildCount(e),s=[];s.nocell=e==null,s.ncells=t.graph.getSelectionCount()>1,s.notRoot=n.getRoot()!=n.getParent(t.graph.getDefaultParent()),s.cell=e!=null;var l=e!=null&&t.graph.getSelectionCount()==1;s.nonEmpty=l&&r>0,s.expandable=l&&t.graph.isCellFoldable(e,!1),s.collapsable=l&&t.graph.isCellFoldable(e,!0),s.validRoot=l&&t.graph.isValidRoot(e),s.emptyValidRoot=s.validRoot&&r==0,s.swimlane=l&&t.graph.isSwimlane(e);for(var a=this.config.getElementsByTagName("condition"),o=0;o