@kekonic/diagrams-studio 1.0.0-rc.10
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.
- package/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/browser/assets/SourceEditor-CVJmi6AX.js +23 -0
- package/dist/browser/assets/codicon-DF1abBS2.ttf +0 -0
- package/dist/browser/assets/dist-gV3Je5I4.js +52 -0
- package/dist/browser/assets/editor-bEjdOiDy.css +1 -0
- package/dist/browser/assets/editor.api-Cj6q1WDf.js +430 -0
- package/dist/browser/assets/editor.worker-BmdWdrHZ.js +33 -0
- package/dist/browser/assets/elk-B5tw4IVJ.js +25 -0
- package/dist/browser/assets/format-B3CctFKU.js +479 -0
- package/dist/browser/assets/format-BCE_sElR.css +1 -0
- package/dist/browser/assets/github-dark-C-LZuMrd.js +1 -0
- package/dist/browser/assets/github-light-EUqPIrTm.js +1 -0
- package/dist/browser/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/dist/browser/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist/browser/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/dist/browser/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist/browser/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/dist/browser/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/dist/browser/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/dist/browser/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/dist/browser/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/dist/browser/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/dist/browser/assets/index-CWVmUaAY.css +1 -0
- package/dist/browser/assets/index-KMDzz6hs.js +3092 -0
- package/dist/browser/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
- package/dist/browser/assets/inter-latin-500-normal-DPWUe_Rm.js +1 -0
- package/dist/browser/assets/kekonic-diagrams-symbol-DLqXST9D.svg +38 -0
- package/dist/browser/assets/language-jwV6PbsO.js +11 -0
- package/dist/browser/assets/monaco-features-BReLWANr.js +28 -0
- package/dist/browser/assets/monaco-features-CRQ1X1Hr.css +1 -0
- package/dist/browser/assets/rolldown-runtime-COiEfhsA.js +1 -0
- package/dist/browser/assets/wasm-BnjxR4X6.js +1 -0
- package/dist/browser/favicon.svg +38 -0
- package/dist/browser/index.html +17 -0
- package/dist/index.d.mts +185 -0
- package/dist/index.mjs +465 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,C as n,F as r,G as i,H as a,I as o,K as s,L as c,M as l,N as u,O as d,R as f,T as p,V as m,W as h,X as g,Y as _,_ as v,c as y,d as b,f as x,g as S,h as ee,i as C,j as w,k as T,l as E,n as D,o as O,p as k,q as A,r as j,s as M,t as N,u as te,w as P,z as ne}from"./index-KMDzz6hs.js";import{n as re,t as F}from"./elk-B5tw4IVJ.js";var I=500,ie=650,L=450,R=600,ae=350,z=12;function B(e){if(e.diagramKind===`sequence`&&e.sequence)return he(e);let t=oe(e);if(t.length===0)return null;let n=[],r=new Map(e.nodes.map(e=>[e.id,e])),i=-1,a=e=>{let t=r.get(e);return{op:`pulse`,targets:[{type:`node`,id:e}],durationMs:t?.kind===`choice`?ie:L}};for(let e of t)if(e.kind===`chapter`)i+=1,n.push({op:`dim`,targets:[{type:`all`}]}),i>0&&n.push({op:`wait`,durationMs:ae});else if(e.kind===`enter`)n.push({op:`activate`,targets:[{type:`node`,id:e.nodeId}]}),n.push(a(e.nodeId));else if(e.kind===`enter-many`){let t=e.nodeIds.map(e=>({type:`node`,id:e}));n.push({op:`activate`,targets:t}),n.push({op:`parallel`,cues:e.nodeIds.map(e=>a(e))})}else if(e.kind===`edge`)n.push({op:`flow`,path:[e.from,e.to],durationMs:I});else if(e.edges.length===1){let t=e.edges[0];n.push({op:`flow`,path:[t.from,t.to],durationMs:I})}else n.push({op:`parallel`,cues:e.edges.map(e=>({op:`flow`,path:[e.from,e.to],durationMs:I}))});return n.push({op:`wait`,durationMs:R}),{id:`auto`,name:`Automatic`,loop:!1,cues:n,source:`auto`}}function oe(e){let t=V(e);if(t.length===0)return[];let n=[];for(let e of t)n.push({kind:`chapter`}),n.push(...ce(e.startId,e.edges));return n}function V(e){if(e.nodes.length===0)return[];let t=new Set(e.nodes.map(e=>e.id)),n=new Map(e.nodes.map(e=>[e.id,e])),r=ue(e,t),i=de(e,t),a=e.nodes.filter(e=>(i.get(e.id)??0)===0),o=a.length>0?a.map(e=>e.id):[e.nodes[0].id],s=o[0],c=[],l=(e,t)=>{if(c.length>=z)return;let n=`${e}|${t.map(e=>`${e.from}>${e.to}`).join(`;`)}`;c.some(e=>`${e.startId}|${e.edges.map(e=>`${e.from}>${e.to}`).join(`;`)}`===n)||c.push({startId:e,edges:fe(t)})};for(let e of se(s,new Set,n,r))if(l(s,e),c.length>=z)break;let u=new Set;for(let e of c){u.add(e.startId);for(let t of e.edges)u.add(t.from),u.add(t.to)}for(let e of o.slice(1)){if(c.length>=z)break;let t=[],n=new Set,i=e;for(;i&&!n.has(i)&&(n.add(i),!(n.size>1&&u.has(i)));){let e=r.get(i)??[];if(e.length===0)break;let n=e[0];t.push({from:i,to:n.to}),i=n.to}l(e,t)}for(let t of e.nodes){if(u.has(t.id)||c.some(e=>e.startId===t.id||e.edges.some(e=>e.from===t.id||e.to===t.id)))continue;if(c.length>=z)break;let e=se(t.id,new Set,n,r);if(e.length===0)l(t.id,[]);else for(let n of e)l(t.id,n)}return c}function se(e,t,n,r){if(t.has(e))return[[]];let i=new Set(t);i.add(e);let a=r.get(e)??[];if(a.length===0)return[[]];if(le(n.get(e),a)){let t=[];for(let o of a){let a={from:e,to:o.to};for(let e of se(o.to,i,n,r))t.push([a,...e])}return t.length>0?t:[[]]}return H(a.map(t=>{let a={from:e,to:t.to};return se(t.to,i,n,r).map(e=>[a,...e])}))}function H(e){if(e.length===0)return[[]];let t=[[]];for(let n of e){let e=[];for(let r of t)for(let t of n)e.push([...r,...t]);if(t=e,t.length>=z)break}return t}function ce(e,t){let n=[],r=new Set(t.map(e=>pe(e))),i=new Map(t.map(e=>[pe(e),e])),a=new Set([e]);n.push({kind:`enter`,nodeId:e});let o=t.length+2;for(;r.size>0&&o-->0;){let e=[];for(let t of r){let n=i.get(t);a.has(n.from)&&e.push(n)}if(e.length===0)break;if(e.length===1){let t=e[0];n.push({kind:`edge`,from:t.from,to:t.to})}else n.push({kind:`parallel-edges`,edges:e});let t=[];for(let n of e)r.delete(pe(n)),a.has(n.to)||(a.add(n.to),t.push(n.to));let o=[...new Set(t)];o.length===1?n.push({kind:`enter`,nodeId:o[0]}):o.length>1&&n.push({kind:`enter-many`,nodeIds:o})}return n}function le(e,t){if(t.length<2)return!1;if(e?.kind===`choice`)return!0;let n=new Set(t.map(e=>e.edge.branch??m(e.edge.label)));return n.has(`yes`)&&n.has(`no`)}function ue(e,t){let n=new Map;for(let r of e.edges){if(!t.has(r.from)||!t.has(r.to))continue;let e=n.get(r.from);e?e.push({to:r.to,edge:r}):n.set(r.from,[{to:r.to,edge:r}])}return n}function de(e,t){let n=new Map;for(let e of t)n.set(e,0);for(let r of e.edges)t.has(r.to)&&n.set(r.to,(n.get(r.to)??0)+1);return n}function fe(e){let t=new Set,n=[];for(let r of e){let e=pe(r);t.has(e)||(t.add(e),n.push(r))}return n}function pe(e){return`${e.from}\0${e.to}`}function me(e,t){let n=new Set;for(let r of e)r.startOrder<=t&&t<=r.endOrder&&n.add(r.participantId);return[...n]}function he(e){let t=e.sequence;if(!t||t.messages.length===0)return null;let n=[],r=``;for(let e of t.messages){if(!e.from||!e.to||e.kind===`destroy`)continue;let i=me(t.activations,e.order),a=new Set(i);a.add(e.from),a.add(e.to);let o=[...a].sort().join(`\0`);o!==r&&(n.push({op:`dim`,targets:[{type:`all`}]}),n.push({op:`activate`,targets:[...a].map(e=>({type:`node`,id:e}))}),r=o),n.push({op:`flow`,path:[e.from,e.to],durationMs:I,edgeId:e.id,edgeIds:[e.id]}),n.push({op:`pulse`,targets:[{type:`node`,id:e.to}],durationMs:L})}return n.push({op:`wait`,durationMs:R}),{id:`auto`,name:`Automatic`,loop:!1,cues:n,source:`auto`}}function ge(e,t){if(t.edgeIds&&e<t.edgeIds.length)return t.edgeIds[e];if(e===0)return t.edgeId}function _e(e,t){let n=e.sequence;if(!n)return t;let r=n.messages.filter(e=>e.from&&e.to&&e.kind!==`destroy`).slice().sort((e,t)=>e.order-t.order),i=new Set,a=(e,t)=>{for(let n of r)if(!(i.has(n.id)||n.from!==e||n.to!==t))return i.add(n.id),n.id},o=e=>{if(e.op===`parallel`)return{...e,cues:e.cues.map(o)};if(e.op!==`flow`||e.edgeId||e.edgeIds&&e.edgeIds.length>0||e.path.length<2)return e;let t=e.path.length-1,n=[];for(let r=0;r<t;r++){let t=a(e.path[r],e.path[r+1]);if(!t)return e;n.push(t)}return{...e,edgeId:n[0],edgeIds:n}};return t.map(o)}function ve(e,...t){let n={...e};for(let e of t)if(e)for(let[t,r]of Object.entries(e))r!==void 0&&(n[t]=r);return n}function ye(e,t,n=0){return!(e.x+e.width+n<=t.x||t.x+t.width+n<=e.x||e.y+e.height+n<=t.y||t.y+t.height+n<=e.y)}var be={compact:10,standard:20,presentation:32},xe={compact:10,standard:16,presentation:24},Se=1.6;function Ce(e){return{top:e,right:e,bottom:e,left:e}}function we(e,t=0){return{top:e.top??t,right:e.right??t,bottom:e.bottom??t,left:e.left??t}}function Te(e,t){let n=typeof t==`number`?Ce(t):t;return{x:e.x+n.left,y:e.y+n.top,width:Math.max(0,e.width-n.left-n.right),height:Math.max(0,e.height-n.top-n.bottom)}}function Ee(e,t){let n=typeof t==`number`?Ce(t):t;return{x:e.x-n.left,y:e.y-n.top,width:e.width+n.left+n.right,height:e.height+n.top+n.bottom}}function De(e){if(e.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);return{x:t,y:n,width:r-t,height:i-n}}function Oe(e){let t=Math.hypot(e.x,e.y)||1;return{x:e.x/t,y:e.y/t}}function ke(e){switch(e){case`north`:return{x:0,y:-1};case`east`:return{x:1,y:0};case`south`:return{x:0,y:1};case`west`:return{x:-1,y:0}}}function Ae(e,t){let n=e.x+e.width/2,r=e.y+e.height/2;switch(t){case`north`:return{x:n,y:e.y};case`east`:return{x:e.x+e.width,y:r};case`south`:return{x:n,y:e.y+e.height};case`west`:return{x:e.x,y:r}}}function U(e,t,n){if(e.length<3)return null;let r=Oe(n),i=1/0,a=null;for(let n=0;n<e.length;n++){let o=e[n],s=e[(n+1)%e.length],c=je(t,r,o,s);c&&c.t>=0&&c.t<i&&(i=c.t,a=c.point)}return a}function je(e,t,n,r){let i=r.x-n.x,a=r.y-n.y,o=t.x*a-t.y*i;if(Math.abs(o)<1e-9)return null;let s=n.x-e.x,c=n.y-e.y,l=(s*a-c*i)/o,u=(s*t.y-c*t.x)/o;return u<-1e-9||u>1+1e-9?null:{t:l,point:{x:e.x+t.x*l,y:e.y+t.y*l}}}function Me(e,t,n){let r=e.x+e.width/2,i=e.y+e.height/2,a=e.width/2,o=e.height/2;if(a<=0||o<=0)return null;let s=Oe(n),c=(t.x-r)/a,l=(t.y-i)/o,u=s.x/a,d=s.y/o,f=u*u+d*d,p=2*(c*u+l*d),m=c*c+l*l-1,h=p*p-4*f*m;if(h<0||f===0)return null;let g=Math.sqrt(h),_=[(-p-g)/(2*f),(-p+g)/(2*f)].filter(e=>e>=0);if(!_.length)return null;let v=Math.min(..._);return{x:t.x+s.x*v,y:t.y+s.y*v}}function Ne(e,t,n){return U(Pe(e),t,n)}function Pe(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]}function Fe(e,t){let n=!1;for(let r=0,i=t.length-1;r<t.length;i=r++){let a=t[r],o=t[i];a.y>e.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y+1e-12)+a.x&&(n=!n)}return n}function Ie(e,t){let n=t.x+t.width/2,r=t.y+t.height/2,i=t.width/2,a=t.height/2;if(i<=0||a<=0)return!1;let o=(e.x-n)/i,s=(e.y-r)/a;return o*o+s*s<=1}function Le(e,t=!0){if(!e.length)return``;let[n,...r]=e,i=`M ${n.x} ${n.y}`;for(let e of r)i+=` L ${e.x} ${e.y}`;return t&&(i+=` Z`),i}function Re(e,t,n){let r=e.width*t,i=e.height*n;return{x:e.x+(e.width-r)/2,y:e.y+(e.height-i)/2,width:r,height:i}}function ze(e){return Math.max(0,e/2)}function Be(e,t,n={},r={}){let i=e.getContentBounds(t,n),a=[e.getVisualBounds(t,n)];r.externalLabels&&a.push(...r.externalLabels),r.badges&&a.push(...r.badges);let o=De(a),s=r.density??`standard`,c=be[s],l=e.clearSpaceBoost??0,u=we(r.clearSpace??{},c+l),d=r.edgeLaunch??xe[s],f=Ee(o,{top:u.top+d,right:u.right+d,bottom:u.bottom+d,left:u.left+d}),p=Math.max(0,(22-Math.min(t.width,t.height))/2),m=p>0?Ee(o,p):o;return{geometry:{...t},content:i,visual:o,interaction:m,footprint:f,clearSpace:u}}function W(e,t={}){let n=Ee(e,ze(t.strokeWidth??1.6));if(t.shadowBlur||t.shadowOffsetX||t.shadowOffsetY){let r=t.shadowBlur??0,i=t.shadowOffsetX??0,a=t.shadowOffsetY??0;n=De([n,{x:e.x+Math.min(0,i)-r,y:e.y+Math.min(0,a)-r,width:e.width+Math.abs(i)+r*2,height:e.height+Math.abs(a)+r*2}])}return n}function G(e,t,n={},r={}){return Be(e,t,r,n).footprint}function Ve(e,t){if(e.kind===`center`)return{x:t.x+t.width/2,y:t.y+t.height/2};if(e.kind===`corner`)switch(e.corner){case`northwest`:return{x:t.x,y:t.y};case`northeast`:return{x:t.x+t.width,y:t.y};case`southeast`:return{x:t.x+t.width,y:t.y+t.height};case`southwest`:return{x:t.x,y:t.y+t.height}}if(e.kind===`radial`){let n=t.x+t.width/2,r=t.y+t.height/2,i=e.angleDeg*Math.PI/180;return{x:n+Math.cos(i)*(t.width/2),y:r+Math.sin(i)*(t.height/2)}}if(e.kind===`named`)return Ae(t,`east`);let n=e.side,r=Math.max(1,e.count??1),i=Math.min(Math.max(0,e.index??0),r-1);return r===1?Ae(t,n):We(t,n,i,r)}function He(e,t,n){let r=Ve(e,t);if(e.kind!==`side`)return r;let i=t.x+t.width/2,a=t.y+t.height/2,o={x:r.x-i,y:r.y-a};return Math.hypot(o.x,o.y)<1e-9?r:n(o)??r}function Ue(e,t,n,r){return He(e,t,e=>r(n,{x:t.x+t.width/2,y:t.y+t.height/2},e))}function We(e,t,n,r,i=8){let a=t===`north`||t===`south`?Math.max(0,e.width-i*2):Math.max(0,e.height-i*2),o=i+(r>1?a/(r-1):0)*n;switch(t){case`north`:return{x:e.x+o,y:e.y};case`south`:return{x:e.x+o,y:e.y+e.height};case`east`:return{x:e.x+e.width,y:e.y+o};case`west`:return{x:e.x,y:e.y+o}}}function K(e,t){if(e.kind===`side`)return ke(e.side);if(e.kind===`corner`)switch(e.corner){case`northwest`:return Ge({x:-1,y:-1});case`northeast`:return Ge({x:1,y:-1});case`southeast`:return Ge({x:1,y:1});case`southwest`:return Ge({x:-1,y:1})}if(e.kind===`radial`){let t=e.angleDeg*Math.PI/180;return{x:Math.cos(t),y:Math.sin(t)}}return e.kind,{x:1,y:0}}function Ge(e){let t=Math.hypot(e.x,e.y)||1;return{x:e.x/t,y:e.y/t}}function Ke(e,t,n){if(n.pill)return e.height/2;let r=t?.cornerRadius??n.cornerRadius??0;return Math.min(r,e.width/2,e.height/2)}function qe(e,t,n=6){if(t<=0)return Pe(e);let{x:r,y:i,width:a,height:o}=e,s=Math.min(t,a/2,o/2),c=[],l=(e,t,r,i)=>{for(let a=0;a<=n;a++){let o=r+(i-r)*a/n;c.push({x:e+s*Math.cos(o),y:t+s*Math.sin(o)})}};return l(r+s,i+s,-Math.PI,-Math.PI/2),l(r+a-s,i+s,-Math.PI/2,0),l(r+a-s,i+o-s,0,Math.PI/2),l(r+s,i+o-s,Math.PI/2,Math.PI),c}function Je(e={id:`rectangle`}){let t={id:e.id,defaultSize:e.defaultSize??{width:160,height:72},minSize:e.minSize??{width:48,height:32},defaultPadding:e.defaultPadding??{top:16,right:18,bottom:16,left:18},contentPolicy:e.contentPolicy??{align:`start`,maxLabelLines:2,iconPlacement:`leading`},getPath(t,n={}){let r=Ke(t,n,e),{x:i,y:a,width:o,height:s}=t;if(r<=0){let e=Pe(t);return{d:Le(e),polygon:e}}return{d:[`M ${i+r} ${a}`,`L ${i+o-r} ${a}`,`A ${r} ${r} 0 0 1 ${i+o} ${a+r}`,`L ${i+o} ${a+s-r}`,`A ${r} ${r} 0 0 1 ${i+o-r} ${a+s}`,`L ${i+r} ${a+s}`,`A ${r} ${r} 0 0 1 ${i} ${a+s-r}`,`L ${i} ${a+r}`,`A ${r} ${r} 0 0 1 ${i+r} ${a}`,`Z`].join(` `),polygon:qe(t,r)}},getContentBounds(t,n={}){let r=n.strokeWidth??1.6,i=Ke(t,n,e);return Te(t,Math.max(r,i>0?i*.35:0)+2)},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,n,r){return G(t,e,n,r)},getPortPosition(t,n,r={}){let i=Ke(n,r,e);return i<=0?Ve(t,n):Ue(t,n,qe(n,i),U)},getPortNormal(e,t){return K(e,t)},intersectRay(t,n,r,i={}){let a=Ke(t,i,e);return a<=0?Ne(t,n,r):U(qe(t,a),n,r)},containsPoint(t,n,r={}){let i=Ke(t,r,e);return i<=0?Fe(n,Pe(t)):Fe(n,qe(t,i))}};return t}var Ye=Je({id:`rectangle`}),Xe=Je({id:`rounded`,cornerRadius:12,contentPolicy:{align:`start`,maxLabelLines:2,iconPlacement:`leading`}}),Ze=Je({id:`pill`,pill:!0,defaultSize:{width:120,height:40},contentPolicy:{align:`center`,maxLabelLines:1,iconPlacement:`leading`}});function Qe(e){let t=e.x+e.width/2,n=e.y+e.height/2;return[{x:t,y:e.y},{x:e.x+e.width,y:n},{x:t,y:e.y+e.height},{x:e.x,y:n}]}function $e(e){return Qe(e).map(e=>`${e.x},${e.y}`).join(` `)}var et={id:`diamond`,defaultSize:{width:140,height:100},minSize:{width:64,height:64},defaultPadding:{top:12,right:12,bottom:12,left:12},contentPolicy:{align:`center`,maxLabelLines:2,preferExternalLabel:!1,iconPlacement:`none`},clearSpaceBoost:6,getPath(e){let t=Qe(e);return{d:Le(t),polygon:t}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6;return Te(Re(e,.5,.5),n)},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(et,e,t,n)},getPortPosition(e,t){return Ue(e,t,Qe(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(Qe(e),t,n)},containsPoint(e,t){return Fe(t,Qe(e))}};function tt(e,t){return Math.min(e*.22,t*.42,e*.5-4)}function nt(e){let{x:t,y:n,width:r,height:i}=e,a=tt(r,i),o=n+i/2;return[{x:t+a,y:n},{x:t+r-a,y:n},{x:t+r,y:o},{x:t+r-a,y:n+i},{x:t+a,y:n+i},{x:t,y:o}]}function rt(e){return nt(e).map(e=>`${e.x},${e.y}`).join(` `)}function it(e){let t={id:e,defaultSize:{width:160,height:72},minSize:{width:72,height:40},defaultPadding:{top:14,right:20,bottom:14,left:20},contentPolicy:{align:`center`,maxLabelLines:2,iconPlacement:`none`},getPath(e){let t=nt(e);return{d:Le(t),polygon:t}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6,r=tt(e.width,e.height);return{x:e.x+r,y:e.y+n+4,width:Math.max(0,e.width-r*2),height:Math.max(0,e.height-(n+4)*2)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,n,r){return G(t,e,n,r)},getPortPosition(e,t){return Ue(e,t,nt(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(nt(e),t,n)},containsPoint(e,t){return Fe(t,nt(e))}};return t}var at=it(`hexagon`);function ot(e,t){return{rx:e/2,ry:Math.min(Math.max(e*.125,7),t*.16,13)}}function st(e){let{x:t,y:n,width:r,height:i}=e,{rx:a,ry:o}=ot(r,i);return{body:[`M ${t} ${n+o}`,`a ${a} ${o} 0 0 1 ${r} 0`,`l 0 ${i-2*o}`,`a ${a} ${o} 0 0 1 ${-r} 0`,`z`].join(` `),rim:`M ${t} ${n+o} a ${a} ${o} 0 0 0 ${r} 0`}}function ct(e,t=16){let{x:n,y:r,width:i,height:a}=e,{rx:o,ry:s}=ot(i,a),c=n+o,l=[];for(let e=0;e<=t;e++){let n=Math.PI-e/t*Math.PI;l.push({x:c+o*Math.cos(n),y:r+s-s*Math.sin(n)})}for(let e=0;e<=t;e++){let n=e/t*Math.PI;l.push({x:c+o*Math.cos(n),y:r+a-s+s*Math.sin(n)})}return l}var lt={id:`cylinder`,defaultSize:{width:140,height:88},minSize:{width:64,height:56},defaultPadding:{top:22,right:16,bottom:14,left:16},contentPolicy:{align:`center`,maxLabelLines:2,iconPlacement:`none`},getPath(e){let{body:t,rim:n}=st(e);return{d:t,decorations:[{d:n,role:`rim`}]}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6,{ry:r}=ot(e.width,e.height),i=Math.max(r*2,e.height*.22);return{x:e.x+n+8,y:e.y+i,width:Math.max(0,e.width-(n+8)*2),height:Math.max(0,e.height-i-n-8)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(lt,e,t,n)},getPortPosition(e,t){return Ue(e,t,ct(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(ct(e),t,n)},containsPoint(e,t){let{ry:n}=ot(e.width,e.height),r={x:e.x,y:e.y,width:e.width,height:n*2},i={x:e.x,y:e.y+e.height-n*2,width:e.width,height:n*2},a={x:e.x,y:e.y+n,width:e.width,height:Math.max(0,e.height-n*2)};return t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height||Ie(t,r)||Ie(t,i)}};function ut(e,t){let n=t/2;return{rx:Math.min(Math.max(t*.125,7),e*.16,13),ry:n}}function dt(e){let{x:t,y:n,width:r,height:i}=e,{rx:a,ry:o}=ut(r,i);return{body:[`M ${t+a} ${n}`,`l ${r-2*a} 0`,`a ${a} ${o} 0 0 1 0 ${i}`,`l ${-(r-2*a)} 0`,`a ${a} ${o} 0 0 1 0 ${-i}`,`z`].join(` `),rim:`M ${t+a} ${n} a ${a} ${o} 0 0 0 0 ${i}`}}function ft(e,t=16){let{x:n,y:r,width:i,height:a}=e,{rx:o,ry:s}=ut(i,a),c=r+s,l=[];for(let e=0;e<=t;e++){let r=Math.PI/2+e/t*Math.PI;l.push({x:n+o+o*Math.cos(r),y:c+s*Math.sin(r)})}for(let e=0;e<=t;e++){let r=-Math.PI/2+e/t*Math.PI;l.push({x:n+i-o+o*Math.cos(r),y:c+s*Math.sin(r)})}return l}var pt={id:`queue`,defaultSize:{width:160,height:64},minSize:{width:72,height:40},defaultPadding:{top:12,right:22,bottom:12,left:22},contentPolicy:{align:`center`,maxLabelLines:2,iconPlacement:`leading`},getPath(e){let{body:t,rim:n}=dt(e);return{d:t,decorations:[{d:n,role:`rim`}]}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6,{rx:r}=ut(e.width,e.height),i=Math.max(r*2,e.width*.12);return{x:e.x+i,y:e.y+n+6,width:Math.max(0,e.width-i*2),height:Math.max(0,e.height-(n+6)*2)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(pt,e,t,n)},getPortPosition(e,t){return Ue(e,t,ft(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(ft(e),t,n)},containsPoint(e,t){let{rx:n}=ut(e.width,e.height),r={x:e.x,y:e.y,width:n*2,height:e.height},i={x:e.x+e.width-n*2,y:e.y,width:n*2,height:e.height},a={x:e.x+n,y:e.y,width:Math.max(0,e.width-n*2),height:e.height};return t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height||Ie(t,r)||Ie(t,i)}};function mt(e,t){return Math.min(10,e*.18,t*.12)}function ht(e){let{y:t,height:n}=e;return[t+n/3,t+2*n/3]}function gt(e){let{x:t,y:n,width:r,height:i}=e,a=mt(i,r);return[`M ${t+a} ${n}`,`L ${t+r-a} ${n}`,`A ${a} ${a} 0 0 1 ${t+r} ${n+a}`,`L ${t+r} ${n+i-a}`,`A ${a} ${a} 0 0 1 ${t+r-a} ${n+i}`,`L ${t+a} ${n+i}`,`A ${a} ${a} 0 0 1 ${t} ${n+i-a}`,`L ${t} ${n+a}`,`A ${a} ${a} 0 0 1 ${t+a} ${n}`,`Z`].join(` `)}function _t(e){let{x:t,width:n,height:r}=e,i=Math.min(14,Math.max(8,n*.1)),a=Math.max(8,mt(r,n)*.75);return ht(e).map(e=>`M ${t+a} ${e} L ${t+a+i} ${e}`)}function vt(e){let{x:t,y:n,width:r,height:i}=e;return[{x:t,y:n},{x:t+r,y:n},{x:t+r,y:n+i},{x:t,y:n+i}]}var yt={id:`stream`,defaultSize:{width:160,height:72},minSize:{width:72,height:48},defaultPadding:{top:14,right:16,bottom:14,left:16},contentPolicy:{align:`center`,maxLabelLines:2,iconPlacement:`leading`},getPath(e){return{d:gt(e),decorations:_t(e).map(e=>({d:e,role:`partition`})),polygon:vt(e)}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6,r=Math.min(22,Math.max(16,e.width*.12));return{x:e.x+r,y:e.y+n+8,width:Math.max(0,e.width-r-n-10),height:Math.max(0,e.height-(n+8)*2)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(yt,e,t,n)},getPortPosition(e,t){return Ue(e,t,vt(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(vt(e),t,n)},containsPoint(e,t){return Fe(t,vt(e))}};function bt(e,t,n={}){let r={id:e,defaultSize:n.defaultSize??{width:120,height:80},minSize:{width:32,height:32},defaultPadding:{top:12,right:16,bottom:12,left:16},contentPolicy:{align:`center`,maxLabelLines:e===`circle`?1:2,preferExternalLabel:n.preferExternalLabel??e===`circle`,iconPlacement:`centered`},getPath(e){let t=e.x+e.width/2,n=e.y+e.height/2,r=e.width/2,i=e.height/2;return{d:[`M ${t-r} ${n}`,`A ${r} ${i} 0 1 0 ${t+r} ${n}`,`A ${r} ${i} 0 1 0 ${t-r} ${n}`,`Z`].join(` `)}},getContentBounds(e,n={}){let r=n.strokeWidth??1.6,i=Re(e,t.w,t.h);return{x:i.x+r,y:i.y+r,width:Math.max(0,i.width-r*2),height:Math.max(0,i.height-r*2)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(r,e,t,n)},getPortPosition(e,t){if(e.kind===`radial`){let n=t.x+t.width/2,r=t.y+t.height/2,i=e.angleDeg*Math.PI/180;return{x:n+Math.cos(i)*(t.width/2),y:r+Math.sin(i)*(t.height/2)}}return He(e,t,e=>Me(t,{x:t.x+t.width/2,y:t.y+t.height/2},e))},getPortNormal(e,t){if(e.kind===`radial`){let t=e.angleDeg*Math.PI/180;return{x:Math.cos(t),y:Math.sin(t)}}return K(e,t)},intersectRay(e,t,n){return Me(e,t,n)},containsPoint(e,t){return Ie(t,e)}};return r}var xt=bt(`ellipse`,{w:.7,h:.7}),St=bt(`circle`,{w:.55,h:.55},{preferExternalLabel:!0,defaultSize:{width:40,height:40}});function Ct(e,t=.18,n=`right`){let r=Math.min(e.width*t,e.width*.35),{x:i,y:a,width:o,height:s}=e;return n===`right`?[{x:i+r,y:a},{x:i+o,y:a},{x:i+o-r,y:a+s},{x:i,y:a+s}]:[{x:i,y:a},{x:i+o-r,y:a},{x:i+o,y:a+s},{x:i+r,y:a+s}]}function wt(e=`parallelogram`,t=`right`){let n={id:e,defaultSize:{width:160,height:64},minSize:{width:72,height:36},defaultPadding:{top:12,right:24,bottom:12,left:24},contentPolicy:{align:`center`,maxLabelLines:2,iconPlacement:`none`},getPath(e){let n=Ct(e,.18,t);return{d:Le(n),polygon:n}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6,r=Math.min(e.width*.18,e.width*.35);return{x:e.x+r+n,y:e.y+n+4,width:Math.max(0,e.width-r*2-n*2),height:Math.max(0,e.height-(n+4)*2)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,r){return G(n,e,t,r)},getPortPosition(e,n){return Ue(e,n,Ct(n,.18,t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,n,r){return U(Ct(e,.18,t),n,r)},containsPoint(e,n){return Fe(n,Ct(e,.18,t))}};return n}var Tt=wt();function Et(e,t=!0,n=.16){let r=Math.min(e.width*n,e.width*.3),{x:i,y:a,width:o,height:s}=e;return t?[{x:i+r,y:a},{x:i+o-r,y:a},{x:i+o,y:a+s},{x:i,y:a+s}]:[{x:i,y:a},{x:i+o,y:a},{x:i+o-r,y:a+s},{x:i+r,y:a+s}]}function Dt(e=`trapezoid`,t=!1){let n={id:e,defaultSize:{width:160,height:64},minSize:{width:72,height:36},defaultPadding:{top:12,right:16,bottom:12,left:16},contentPolicy:{align:`center`,maxLabelLines:2,iconPlacement:`none`},getPath(e){let n=Et(e,t);return{d:Le(n),polygon:n}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6,r=Math.min(e.width*.16,e.width*.3);return{x:e.x+r+n,y:e.y+n+4,width:Math.max(0,e.width-r*2-n*2),height:Math.max(0,e.height-(n+4)*2)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,r){return G(n,e,t,r)},getPortPosition(e,n){return Ue(e,n,Et(n,t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,n,r){return U(Et(e,t),n,r)},containsPoint(e,n){return Fe(n,Et(e,t))}};return n}var Ot=Dt(`trapezoid`,!1);function kt(e){return[{x:e.x+e.width/2,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]}var At={id:`triangle`,defaultSize:{width:72,height:64},minSize:{width:32,height:28},defaultPadding:{top:16,right:12,bottom:8,left:12},contentPolicy:{align:`center`,maxLabelLines:1,preferExternalLabel:!0,iconPlacement:`centered`},clearSpaceBoost:8,getPath(e){let t=kt(e);return{d:Le(t),polygon:t}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6;return Re({x:e.x+n,y:e.y+e.height*.35,width:Math.max(0,e.width-n*2),height:Math.max(0,e.height*.45-n)},1,1)},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(At,e,t,n)},getPortPosition(e,t){return Ue(e,t,kt(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(kt(e),t,n)},containsPoint(e,t){return Fe(t,kt(e))}};function jt(e,t=8){let{x:n,y:r,width:i,height:a}=e,o=Math.min(10,a*.12),s=a-o,c=[{x:n,y:r},{x:n+i,y:r},{x:n+i,y:r+s}];for(let e=t;e>=0;e--){let a=e/t,l=n+i*a,u=r+s+Math.sin(a*Math.PI)*o;c.push({x:l,y:u})}return c}var Mt={id:`document`,defaultSize:{width:140,height:80},minSize:{width:64,height:48},defaultPadding:{top:14,right:16,bottom:20,left:16},contentPolicy:{align:`start`,maxLabelLines:2,iconPlacement:`leading`},getPath(e){let t=jt(e);return{d:Le(t),polygon:t}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6,r=Math.min(10,e.height*.12);return{x:e.x+n+8,y:e.y+n+8,width:Math.max(0,e.width-(n+8)*2),height:Math.max(0,e.height-r-n*2-16)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(Mt,e,t,n)},getPortPosition(e,t){return Ue(e,t,jt(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(jt(e),t,n)},containsPoint(e,t){return Fe(t,jt(e))}};function Nt(e,t=14){let{x:n,y:r,width:i,height:a}=e,o=Math.min(t,i*.25,a*.25);return{body:[`M ${n} ${r}`,`L ${n+i-o} ${r}`,`L ${n+i} ${r+o}`,`L ${n+i} ${r+a}`,`L ${n} ${r+a}`,`Z`].join(` `),foldLine:`M ${n+i-o} ${r} L ${n+i-o} ${r+o} L ${n+i} ${r+o}`}}function Pt(e,t=14){let{x:n,y:r,width:i,height:a}=e,o=Math.min(t,i*.25,a*.25);return[{x:n,y:r},{x:n+i-o,y:r},{x:n+i,y:r+o},{x:n+i,y:r+a},{x:n,y:r+a}]}var Ft={id:`folded-document`,defaultSize:{width:140,height:80},minSize:{width:64,height:48},defaultPadding:{top:14,right:18,bottom:14,left:14},contentPolicy:{align:`start`,maxLabelLines:3,iconPlacement:`none`},getPath(e){let{body:t,foldLine:n}=Nt(e);return{d:t,decorations:[{d:n,role:`fold`}]}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6,r=Math.min(14,e.width*.25);return{x:e.x+n+8,y:e.y+n+8,width:Math.max(0,e.width-r-n*2-12),height:Math.max(0,e.height-(n+8)*2)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(Ft,e,t,n)},getPortPosition(e,t){return Ue(e,t,Pt(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(Pt(e),t,n)},containsPoint(e,t){return Fe(t,Pt(e))}},It={x:0,y:4,w:24,h:16},Lt=It.w/It.h;function Rt(e){if(e.width/Math.max(e.height,1e-6)>=Lt){let t=e.height*Lt;return{x:e.x+(e.width-t)/2,y:e.y,width:t,height:e.height}}let t=e.width/Lt;return{x:e.x,y:e.y+(e.height-t)/2,width:e.width,height:t}}function zt(e,t,n){return{x:e.x+(t-It.x)/It.w*e.width,y:e.y+(n-It.y)/It.h*e.height}}function Bt(e){let t=Rt(e),n=(e,n)=>zt(t,e,n);return{start:n(19.35,10.04),segs:[{type:`C`,c1:n(18.67,6.59),c2:n(15.64,4),end:n(12,4)},{type:`C`,c1:n(9.11,4),c2:n(6.6,5.64),end:n(5.35,8.04)},{type:`C`,c1:n(2.34,8.36),c2:n(0,10.91),end:n(0,14)},{type:`C`,c1:n(0,17.31),c2:n(2.69,20),end:n(6,20)},{type:`L`,end:n(19,20)},{type:`C`,c1:n(21.76,20),c2:n(24,17.76),end:n(24,15)},{type:`C`,c1:n(24,12.36),c2:n(21.95,10.22),end:n(19.35,10.04)}]}}function Vt(e,t,n,r,i){let a=[];for(let o=1;o<=i;o++){let s=o/i,c=1-s;a.push({x:c*c*c*e.x+3*c*c*s*t.x+3*c*s*s*n.x+s*s*s*r.x,y:c*c*c*e.y+3*c*c*s*t.y+3*c*s*s*n.y+s*s*s*r.y})}return a}function Ht(e,t=10){let{start:n,segs:r}=Bt(e),i=[n],a=n;for(let e of r)e.type===`L`?(i.push(e.end),a=e.end):(i.push(...Vt(a,e.c1,e.c2,e.end,t)),a=e.end);return i}function Ut(e){let{start:t,segs:n}=Bt(e),r=`M ${t.x} ${t.y}`;for(let e of n)e.type===`L`?r+=` L ${e.end.x} ${e.end.y}`:r+=` C ${e.c1.x} ${e.c1.y}, ${e.c2.x} ${e.c2.y}, ${e.end.x} ${e.end.y}`;return`${r} Z`}var Wt={id:`cloud`,defaultSize:{width:160,height:100},minSize:{width:80,height:56},defaultPadding:{top:20,right:24,bottom:20,left:24},contentPolicy:{align:`center`,maxLabelLines:2,preferExternalLabel:!1,iconPlacement:`centered`},getPath(e){return{d:Ut(e),polygon:Ht(e)}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6,r=Rt(e),i=Re(r,.55,.42);return i.y=r.y+r.height*.38,{x:i.x+n,y:i.y+n,width:Math.max(0,i.width-n*2),height:Math.max(0,i.height-n*2)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(Wt,e,t,n)},getPortPosition(e,t){return Ue(e,t,Ht(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(Ht(e),t,n)},containsPoint(e,t){return Fe(t,Ht(e))}},Gt=.42,Kt=12,qt=10;function Jt(e){return Math.max(4,e*Gt)}function Yt(e,t=Se){let{x:n,y:r,width:i,height:a}=e,o=t+1,s=Math.max(18,i/2-o),c=Math.max(10,Math.min(22,s*.38)),l=r+c+Math.max(3,o),u=l+c-Jt(c),d=r+a-o,f=Math.max(d-u,c*2.2),p=Math.min(s,f*.42),m=n+i/2;return{cx:m,headR:c,headCy:l,bodyTop:u,bodyBottom:d,bodyHalfW:s,bodyRx:p,content:{x:m-s+Kt,y:u+qt,width:Math.max(0,s*2-24),height:Math.max(0,d-u-20)}}}function Xt(e){let{cx:t,headR:n,headCy:r,bodyTop:i,bodyBottom:a,bodyHalfW:o,bodyRx:s}=Yt(e),c=Math.min(s,(a-i)/2),l=i+c+Math.max(2,(a-i-2*c)*.12);return{north:{x:t,y:r-n},east:{x:t+o,y:l},west:{x:t-o,y:l},south:{x:t,y:a}}}function Zt(e,t=12){let{cx:n,headR:r,headCy:i,bodyTop:a,bodyBottom:o,bodyHalfW:s,bodyRx:c}=Yt(e),l=[];for(let e=0;e<=t;e++){let a=Math.PI-e/t*Math.PI;l.push({x:n+r*Math.cos(a),y:i-r*Math.sin(a)})}let u=n+s,d=n-s,f=Math.min(c,(o-a)/2);return l.push({x:u,y:a+f}),l.push({x:u,y:o-f}),l.push({x:n+s-f*.15,y:o}),l.push({x:n,y:o}),l.push({x:n-s+f*.15,y:o}),l.push({x:d,y:o-f}),l.push({x:d,y:a+f}),l}function Qt(e){let{cx:t,headR:n,headCy:r,bodyTop:i,bodyBottom:a,bodyHalfW:o,bodyRx:s}=Yt(e),c=`M ${t} ${r} m ${-n} 0 a ${n} ${n} 0 1 0 ${n*2} 0 a ${n} ${n} 0 1 0 ${-n*2} 0`,l=t-o,u=t+o,d=Math.min(s,(a-i)/2);return{head:c,body:[`M ${l+d} ${i}`,`H ${u-d}`,`A ${d} ${d} 0 0 1 ${u} ${i+d}`,`V ${a-d}`,`A ${d} ${d} 0 0 1 ${u-d} ${a}`,`H ${l+d}`,`A ${d} ${d} 0 0 1 ${l} ${a-d}`,`V ${i+d}`,`A ${d} ${d} 0 0 1 ${l+d} ${i}`,`Z`].join(` `)}}function $t(e){let t=Math.max(18,e/2-2),n=Math.max(10,Math.min(22,t*.38));return n*2-Jt(n)+6}var en={id:`person`,defaultSize:{width:120,height:140},minSize:{width:72,height:96},defaultPadding:{top:8,right:12,bottom:10,left:12},contentPolicy:{align:`center`,maxLabelLines:2,preferExternalLabel:!1,iconPlacement:`above`},clearSpaceBoost:4,getPath(e){let{head:t,body:n}=Qt(e);return{d:`${t} ${n}`,decorations:[{d:t,role:`head`},{d:n,role:`body`}]}},getContentBounds(e,t={}){return Yt(e,t.strokeWidth??1.6).content},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(en,e,t,n)},getPortPosition(e,t){if(e.kind===`side`&&(e.count??1)<=1){let n=Xt(t),r=e.side;if(r===`north`||r===`east`||r===`south`||r===`west`)return n[r]}return Ue(e,t,Zt(t),U)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return U(Zt(e),t,n)},containsPoint(e,t){return Fe(t,Zt(e))}},tn={id:`table`,defaultSize:{width:240,height:160},minSize:{width:140,height:72},defaultPadding:{top:8,right:12,bottom:8,left:12},contentPolicy:{align:`start`,maxLabelLines:1,iconPlacement:`none`},getPath(e){let{x:t,y:n,width:r,height:i}=e;return{d:`M ${t} ${n} H ${t+r} V ${n+i} H ${t} Z`,polygon:Pe(e)}},getContentBounds(e,t={}){let n=t.strokeWidth??1.6;return{x:e.x+n+8,y:e.y+n+8,width:Math.max(0,e.width-(n+8)*2),height:Math.max(0,e.height-(n+8)*2)}},getVisualBounds(e,t){return W(e,t)},getLayoutFootprint(e,t,n){return G(tn,e,t,n)},getPortPosition(e,t){return Ve(e,t)},getPortNormal(e,t){return K(e,t)},intersectRay(e,t,n){return Ne(e,t,n)},containsPoint(e,t){return Fe(t,Pe(e))}},nn={id:`boundary`,defaultSize:{width:320,height:220},minSize:{width:120,height:80},defaultPadding:{top:28,right:20,bottom:20,left:20},contentPolicy:{align:`start`,maxLabelLines:1,iconPlacement:`none`},getPath(e){return tn.getPath(e)},getContentBounds(e,t){return tn.getContentBounds(e,t)},getVisualBounds(e,t){return tn.getVisualBounds(e,t)},getLayoutFootprint(e,t,n){return G(nn,e,t,n)},getPortPosition(e,t,n){return tn.getPortPosition(e,t,n)},getPortNormal(e,t,n){return tn.getPortNormal(e,t,n)},intersectRay(e,t,n,r){return tn.intersectRay(e,t,n,r)},containsPoint(e,t,n){return tn.containsPoint(e,t,n)}},rn={rectangle:Ye,rounded:Xe,pill:Ze,diamond:et,hexagon:at,queue:pt,stream:yt,cylinder:lt,circle:St,ellipse:xt,parallelogram:Tt,trapezoid:Ot,triangle:At,document:Mt,"folded-document":Ft,cloud:Wt,person:en,table:tn,boundary:nn},an=new Map;function on(e){return{id:e.id,geometry:e,defaultSize:e.defaultSize??{width:140,height:72},minSize:e.minSize??{width:40,height:32},defaultPadding:e.defaultPadding??{top:14,right:16,bottom:14,left:16},supportedPortStrategies:[`bbox-mid`,`distributed-sides`,`perimeter`],contentPolicy:e.contentPolicy??{align:`center`,maxLabelLines:2}}}function sn(e){let t=d(e),n=an.get(t)??an.get(e);if(n)return n;if(t in rn)return on(rn[t])}function cn(e){return sn(e)?.geometry}function ln(e){if(e){let t=cn(d(e));if(t)return t}return rn.rounded}function un(e){return d(e)}function dn(e,t,n){let r=Math.max(t.width,n?.width??t.width,e.minSize?.width??0),i=Math.max(t.height,n?.height??t.height,e.minSize?.height??0);for(let n=0;n<6;n++){let n={x:0,y:0,width:r,height:i},a=e.getContentBounds(n),o=a.width>0?t.width/a.width:1,s=a.height>0?t.height/a.height:1,c=Math.max(r*o,e.minSize?.width??0),l=Math.max(i*s,e.minSize?.height??0);if(Math.abs(c-r)<.5&&Math.abs(l-i)<.5){r=c,i=l;break}r=c,i=l}return{width:r,height:i}}function fn(e,t,n){return e.getContentBounds({x:0,y:0,width:t,height:n})}function pn(e){let t=ln(un(e.shapeId)),n=t.intersectRay(e.bounds,e.origin,e.direction,e.style);if(n)return n;let r=e.bounds.x+e.bounds.width/2,i=e.bounds.y+e.bounds.height/2;return t.intersectRay(e.bounds,{x:r,y:i},e.direction,e.style)??{x:r,y:i}}var mn=e(re(),1),hn=typeof mn.parse==`function`?mn:mn.default,gn;function _n(){if(typeof document<`u`)return null;if(gn!==void 0)return gn;try{let e=globalThis.process,t=e?.getBuiltinModule?.(`module`),n=e?.getBuiltinModule?.(`fs`);if(!t||!n)return null;let{createRequire:r}=t,{readFileSync:i}=n,a=i(r(import.meta.url).resolve(`@fontsource/inter/files/inter-latin-500-normal.woff`));return gn=hn.parse(a),gn}catch{return gn=null,null}}function vn(){let e=_n();return e?{measureText(t,n){let r=n.fontSize/e.unitsPerEm,i=0;for(let n of t){let t=e.charToGlyph(n);i+=(t.advanceWidth??0)*r}let a=(e.ascender??e.unitsPerEm*.8)*r,o=Math.abs(e.descender??e.unitsPerEm*.2)*r;return{width:i,height:a+o,ascent:a,descent:o}},wrapText(e,t){let n=e.split(/\s+/),r=[],i=``,a=0;for(let e of n){let n=i?`${i} ${e}`:e;this.measureText(n,t.style).width>t.maxWidth&&i?(r.push(i),a=Math.max(a,this.measureText(i,t.style).width),i=e):i=n}i&&(r.push(i),a=Math.max(a,this.measureText(i,t.style).width));let o=t.style.fontSize*yn;return{lines:r.length?r:[e],width:a,height:(r.length||1)*o}}}:null}var q=`"Inter", "Segoe UI", system-ui, sans-serif`,yn=1.2,bn=.55,xn=!1;function Sn(){return xn}function Cn(){return typeof document<`u`?Tn():vn()||(xn=!0,wn())}function wn(){return{measureText(e,t){return{width:e.length*t.fontSize*bn,height:t.fontSize*yn,ascent:t.fontSize*.8,descent:t.fontSize*.2}},wrapText(e,t){let n=e.split(/\s+/),r=[],i=``,a=0;for(let e of n){let n=i?`${i} ${e}`:e;n.length*t.style.fontSize*bn>t.maxWidth&&i?(r.push(i),a=Math.max(a,i.length*t.style.fontSize*bn),i=e):i=n}i&&(r.push(i),a=Math.max(a,i.length*t.style.fontSize*bn));let o=t.style.fontSize*yn;return{lines:r.length?r:[e],width:a,height:(r.length||1)*o}}}}function Tn(e){let t=(e??(typeof document<`u`?document.createElement(`canvas`):null))?.getContext(`2d`)??null;return{measureText(e,n){if(t){t.font=`${n.fontWeight??`500`} ${n.fontSize}px ${n.fontFamily}`;let r=t.measureText(e),i=r.actualBoundingBoxAscent??n.fontSize*.8,a=r.actualBoundingBoxDescent??n.fontSize*.2;return{width:r.width,height:i+a,ascent:i,descent:a}}return{width:e.length*n.fontSize*bn,height:n.fontSize*yn,ascent:n.fontSize*.8,descent:n.fontSize*.2}},wrapText(e,t){let n=e.split(/\s+/),r=[],i=``,a=0;for(let e of n){let n=i?`${i} ${e}`:e;this.measureText(n,t.style).width>t.maxWidth&&i?(r.push(i),a=Math.max(a,this.measureText(i,t.style).width),i=e):i=n}i&&(r.push(i),a=Math.max(a,this.measureText(i,t.style).width));let o=t.style.fontSize*yn;return{lines:r.length?r:[e],width:a,height:(r.length||1)*o}}}}var En;function Dn(){En=void 0,xn=!1}function On(){return En||=Cn(),En}var kn={measureText(e,t){return On().measureText(e,t)},wrapText(e,t){return On().wrapText(e,t)}};function An(e){return e.shape===`table`&&!!(e.columns&&e.columns.length>0)}function jn(e,t,n=1,r){let i=r??28*n,a=20*n;return e+i+t*a+a/2}function Mn(e){return!!e.note?.trim()}function Nn(e,t=1){return(28+(Mn(e)?14:0))*t}function Pn(e){return e.type?.trim()??``}function Fn(e){return e.note?.trim()??``}function In(e,t,n,r,i){let a=10*n,o=Nn(e,n),s=20*n,c=43*n,l=10*n,u=6*n,d=12*n,f=11*n,p=10*n,m=9.5*n,h=t.measureText(e.label,{fontSize:d,fontFamily:q,fontWeight:`700`}),g=e.note?.trim()??``,_=g?t.measureText(g,{fontSize:10*n,fontFamily:q,fontWeight:`500`}):void 0,v=0,y=e.columns??[];for(let e of y){let r=(e.depth??0)*14*n,i=t.measureText(e.name,{fontSize:f,fontFamily:q,fontWeight:`600`}).width,a=Pn(e),o=Fn(e),s=a?t.measureText(a,{fontSize:p,fontFamily:q,fontWeight:`500`}).width:0,d=o?t.measureText(o,{fontSize:m,fontFamily:q,fontWeight:`500`}).width:0,h=[s,e.notNull&&e.depth==null?t.measureText(`NN`,{fontSize:p,fontFamily:q,fontWeight:`700`}).width:0,d].filter(e=>e>0),g=h.reduce((e,t)=>e+t,0)+Math.max(0,h.length-1)*u;v=Math.max(v,r+c+i+(g?l+g:0))}let b=Math.max(h.width+8*n,_?.width??0,v)+a*2;return{width:Math.max(r,180*n,b),height:o+Math.max(1,y.length)*s,headerHeight:o,rowHeight:s,labelLines:[e.label]}}function Ln(e){let t=[];return e.keys.includes(`pk`)&&t.push(`PK`),e.keys.includes(`fk`)&&t.push(`FK`),e.keys.includes(`uk`)&&t.push(`UK`),t}var Rn=22,zn=20,Bn=26,Vn=28,Hn=15,Un=14,Wn=14,Gn=4,Kn=14,qn=32,Jn=20,Yn=30,Xn=64,Zn=16,Qn={diamond:{w:36,h:36},cylinder:{w:10,h:22},hexagon:{w:18,h:10},person:{w:24,h:0},queue:{w:18,h:18},parallelogram:{w:24,h:8},trapezoid:{w:20,h:8},triangle:{w:16,h:20},document:{w:8,h:16},"folded-document":{w:8,h:12},cloud:{w:28,h:24},circle:{w:12,h:12},ellipse:{w:16,h:16},boundary:{w:8,h:8}};function $n(e,t=1){let n=Jn*t,r=A(e),{width:i}=_(r??{width:1,height:1},n);return Math.max(qn*t,i)}function er(e,t=kn,r={}){let i=performance.now(),a=[];for(let i of e.nodes){let e=un(i.shape??`rounded`),o=ln(e),s=e===`rounded`||e===`rectangle`||e===`pill`,c=!!(i.icon&&i.icon!==`none`),{defaults:l}=n(i.kind),u=P(i.kind,`icon-only`)||l.capabilities.includes(`icon-only`),d=i.scale&&i.scale>0?i.scale:1,f=15*d,m=Rn*d,h=!!(i.technology&&i.technology.trim()||i.description&&i.description.trim()),g=(h?Bn:zn)*d,_=56*d,v=(i.minWidth??l.defaultMinWidth)*(i.minWidth?1:d),y=(i.maxWidth??l.defaultMaxWidth)*(i.maxWidth?1:d);if((i.kind===`initial`||i.kind===`final`||i.kind===`junction`)&&!i.labelAuthored){let e=v;a.push({nodeId:i.id,width:e,height:e,contentBox:fn(o,e,e),labelLines:[]});continue}if(u){let e=i.labelAuthored?t.wrapText(i.label,{maxWidth:y-m,style:{fontSize:f*.72,fontFamily:q,fontWeight:`700`}}):{lines:[],width:0,height:0},n=Math.max(v,Math.min(y,Xn*d+(e.height>0?Zn*d:0))),r=Math.max(n,Xn*d+e.height);a.push({nodeId:i.id,width:n,height:r,contentBox:fn(o,n,r),labelLines:e.lines});continue}if(e===`table`&&i.columns&&i.columns.length>0){let e=In(i,t,d,v,y);a.push({nodeId:i.id,width:e.width,height:e.height,contentBox:fn(o,e.width,e.height),labelLines:e.labelLines});continue}if(e===`diamond`){let e=(y-m*2)*.58,n=t.wrapText(i.label,{maxWidth:e,style:{fontSize:f,fontFamily:q,fontWeight:`800`}}),r={width:Math.max(...n.lines.map(e=>t.measureText(e,{fontSize:f,fontFamily:q,fontWeight:`800`}).width),n.width)+m*2,height:n.height+g*2},s=dn(o,r,{width:Math.max(v,r.width*1.7),height:Math.max(80*d,r.height*1.9)}),c=Math.max(v,s.width),l=Math.max(80*d,s.height);a.push({nodeId:i.id,width:c,height:l,contentBox:fn(o,c,l),labelLines:n.lines});continue}let b=s&&c&&i.icon?$n(i.icon,d):0,x=t.wrapText(i.label,{maxWidth:y-m*2-b,style:{fontSize:f,fontFamily:q,fontWeight:`800`}}),S=Qn[e]??{w:0,h:0},ee=s&&c?b+Yn*d:c?8*d:0,C=c&&!s?Vn*d:0,w=i.subtitle?.trim()?i.subtitle.trim():void 0,T=!!w||i.showSubtitle===!0||r.reserveKindSubtitles,E=T?Hn*d:0,D=0;if(T){let e=10.5/15*f,n=(w??p(i.kind)).toUpperCase();D=t.measureText(n,{fontSize:e,fontFamily:q,fontWeight:`600`}).width+Math.max(0,n.length-1)*e*.05}let O=i.note?Kn*d:0,k=0;i.note&&(k=t.measureText(i.note,{fontSize:9/15*f,fontFamily:q,fontWeight:`400`}).width);let A=i.technology?.trim()?i.technology.trim():void 0,j=i.description?.trim()?i.description.trim():void 0,M=y-m*2-b,N=Gn*d,te,ne=0,re=0;if(A){let e=11/15*f,n=t.wrapText(A,{maxWidth:M,style:{fontSize:e,fontFamily:q,fontWeight:`500`}});te=n.lines,ne=n.width,re=te.length*Un*d}let F,I=0,ie=0;if(j){let e=11/15*f,n=t.wrapText(j,{maxWidth:M,style:{fontSize:e,fontFamily:q,fontWeight:`500`}});F=n.lines,I=n.width,ie=F.length*Wn*d}let L=te||F?N:0,R=te&&F?N:0,ae=e===`person`&&c?Vn*d:e===`person`?0:C,z=x.height+E+L+re+R+ie+O,B=Math.max(x.width,D,ne,I,k)+m*2+S.w*d+ee,oe=z+g*2+S.h*d+ae,V=Math.max(v,B),se=B>0&&V>B?Math.min(V/B,1.45):1,H=Math.max(_,oe*se);if((e===`hexagon`||e===`queue`)&&(H=Math.max(H,V*.44)),e===`cylinder`&&(H=Math.max(H,Math.min(V*.55,96*d)),h)){let{ry:e}=ot(V,H),t=Math.max(e*2,H*.22),n=e+10;H=Math.max(H,t+z+g*2+n)}if(s){let e=dn(o,{width:Math.max(x.width,D,ne,I,k)+ee,height:z},{width:V,height:H});V=Math.max(V,e.width),H=Math.max(H,e.height)}if(e===`cloud`&&(V=Math.max(V,H*1.5)),e===`person`){let e=Math.max(v,B),t=h?16*d:0,n=Math.max(56*d,z+g*2+ae+t*2);V=e,H=$t(e)+n}if(e===`circle`){let e=Math.max(V,H);V=e,H=e}a.push({nodeId:i.id,width:V,height:H,contentBox:fn(o,V,H),labelLines:x.lines,technologyLines:te,descriptionLines:F})}return{nodes:a,measureMs:performance.now()-i}}var tr={compact:56,normal:88,spacious:116},nr={top:56,right:40,bottom:40,left:40},rr={top:20,right:20,bottom:20,left:20},ir={compact:{top:36,right:24,bottom:24,left:24},normal:{top:56,right:40,bottom:40,left:40},spacious:{top:88,right:60,bottom:60,left:60},pixel:{top:100,right:80,bottom:80,left:80}},ar=11,or=14,sr=10;function cr(e){let t=e.chrome===!1,n;if(e.paddingHint&&ir[e.paddingHint]){let r=ir[e.paddingHint];n=t?{top:r.left,right:r.right,bottom:r.bottom,left:r.left}:r}else if(e.paddingHint!=null){let r=Number(e.paddingHint);n=Number.isFinite(r)&&r>=0?{top:r,right:r,bottom:r,left:r}:t?rr:nr}else n=t?rr:nr;return!t&&e.kind===`swimlane`&&(n={top:Math.min(n.top,28),right:n.right,bottom:Math.min(n.bottom,28),left:Math.max(n.left,128)}),lr(e.shape,n,t)}function lr(e,t,n){if(n||!e)return t;let r=e.trim().toLowerCase();if(r!==`hexagon`&&r!==`circle`&&r!==`ellipse`)return t;let i=Math.max(16,Math.round(Math.max(t.left,t.right,24)*.4));return{top:t.top+i,right:t.right+i,bottom:t.bottom+i,left:t.left+i}}function ur(e){let t=Math.max(e.width,e.height);return{x:e.x-(t-e.width)/2,y:e.y-(t-e.height)/2,width:t,height:t}}function dr(e){if(!e)return!1;let t=e.trim().toLowerCase();return t===`hexagon`||t===`circle`}function fr(e,t,n){let r=new Map(t.map(e=>[e.nodeId,e])),i=new Map;for(let t of e.groups){let e=t.nodeIds.map(e=>r.get(e)?.bounds).filter(e=>!!e);if(!e.length)continue;let a=1/0,o=1/0,s=-1/0,c=-1/0;for(let t of e)a=Math.min(a,t.x),o=Math.min(o,t.y),s=Math.max(s,t.x+t.width),c=Math.max(c,t.y+t.height);i.set(t.id,{x:a-n.left,y:o-n.top,width:s-a+n.left+n.right,height:c-o+n.top+n.bottom})}return i}function pr(e,t,n=!1){let r=e.toUpperCase(),i=ar*.5740000000000001,a=n?20:0,o=Math.min(Math.max(r.length*i+8+a,48),Math.max(t.width-8,48));return{x:t.x+or,y:t.y+sr,width:o,height:19}}function mr(e,t){let n=[];for(let r of e.groups){let i=cr(r),a=fr(e,t,i).get(r.id);if(!a)continue;let o=!!(r.icon&&r.icon!==`none`&&r.chrome!==!1);n.push({groupId:r.id,bounds:a,labelBox:pr(r.label,a,o),padding:i})}return n}var hr=8;function gr(e){return e.groups.some(e=>e.kind===`swimlane`&&e.parentId==null)}function _r(e,t){return gr(e)?{...t,direction:t.direction??`LR`,groupLayout:t.groupLayout===`flat`?`flat`:`swimlane`}:t}function vr(e){return e.groups.filter(e=>e.kind===`swimlane`&&e.parentId==null).map(e=>e.id)}var yr=14,br=7.48;function xr(e,t){let n=e.split(/\s+/).filter(Boolean);if(n.length===0)return[e];let r=[],i=``;for(let e of n){let n=i?`${i} ${e}`:e;i&&n.length*br>t?(r.push(i),i=e):i=n}return i&&r.push(i),r}function Sr(e,t,n){let r=Math.max(t.width-12-18,24),i=xr(e,n?Math.max(r-14-6,24):r),a=Math.max(i.length*yr,19);return{x:t.x+12,y:t.y+(t.height-a)/2,width:r,height:a}}function Cr(e){return e.reduce((e,t)=>e+t.bounds.height,0)+16*Math.max(0,e.length-1)}function wr(e){if(e.length===0)return[];if(e.length===1){let t=e[0];return[{...t,bounds:{...t.bounds,y:0}}]}let t=[...e].sort((e,t)=>e.bounds.x-t.bounds.x||e.bounds.y-t.bounds.y),n=[];for(let e of t){let t=n[n.length-1];if(t){let n=Math.max(...t.map(e=>e.bounds.x+e.bounds.width));if(e.bounds.x<n-hr){t.push(e);continue}}n.push([e])}let r=Math.max(...n.map(Cr)),i=[];for(let e of n){let t=[...e].sort((e,t)=>e.bounds.y-t.bounds.y),n=(r-Cr(t))/2;for(let e of t)i.push({...e,bounds:{...e.bounds,y:n}}),n+=e.bounds.height+16}return i}function Tr(e,t,n){let r={x:n.x,y:n.y,width:128,height:n.height},i=!!(t?.icon&&t.icon!==`none`&&t.chrome!==!1);return{...e,bounds:n,headerBox:r,labelBox:Sr(t?.label??e.groupId,r,i),padding:{...e.padding,left:128}}}function Er(e,t,n,r){let i=new Map(n.map(e=>[e.groupId,e])),a=r.map(e=>i.get(e)).filter(e=>e!=null);if(a.length===0)return{nodes:t,groups:n,shiftX:0};let o=Math.min(...a.map(e=>e.bounds.x+e.padding.left)),s=Math.max(...a.map(e=>e.bounds.x+e.bounds.width-e.padding.right)),c=o-128,l=Math.max(s+Math.min(...a.map(e=>e.padding.right)),c+128+40);return Dr(t,n.map(t=>r.includes(t.groupId)?Tr(t,e.groups.find(e=>e.id===t.groupId),{x:c,y:t.bounds.y,width:l-c,height:t.bounds.height}):t))}function Dr(e,t){let n=Math.min(...t.map(e=>e.bounds.x)),r=n<64?64-n:0;if(r===0)return{nodes:e,groups:t,shiftX:0};let i=e=>({...e,x:e.x+r});return{nodes:e.map(e=>({...e,bounds:i(e.bounds)})),groups:t.map(e=>({...e,bounds:i(e.bounds),labelBox:i(e.labelBox),headerBox:e.headerBox?i(e.headerBox):void 0})),shiftX:r}}function Or(e,t,n){let r=vr(e);if(r.length===0)return{nodes:t,groups:n,shiftX:0};let i=new Map(n.map(e=>[e.groupId,e])),a=t.map(e=>({...e,bounds:{...e.bounds}})),o=new Map(a.map((e,t)=>[e.nodeId,t])),s=64,c=!1,l=new Map;for(let t of r){let n=e.groups.find(e=>e.id===t),r=i.get(t);if(!n||!r)continue;let u=n.nodeIds.map(e=>{let t=o.get(e);return t==null?void 0:a[t]}).filter(e=>e!=null);if(u.length===0)continue;c=!0;let d=cr(n),f=wr(u),p=Math.max(...f.map(e=>e.bounds.y+e.bounds.height),0),m={x:r.bounds.x,y:s,width:r.bounds.width,height:p+d.top+d.bottom};for(let e of f){let t=o.get(e.nodeId);t!=null&&(a[t]={...e,bounds:{...e.bounds,y:e.bounds.y+m.y+d.top}})}l.set(t,m),s+=m.height}if(!c)return Er(e,t,n,r);let u=a.filter(t=>{let n=e.nodes.find(e=>e.id===t.nodeId)?.groupId;return n!=null&&r.includes(n)}).map(e=>e.bounds),d=u.length>0?Math.min(...u.map(e=>e.x)):64,f=u.length>0?Math.max(...u.map(e=>e.x+e.width)):d+40,p=d-128,m=Math.max(f+40,p+128+40),h=mr(e,a),g=new Map(h.map(e=>[e.groupId,e])),_=n.map(t=>{if(r.includes(t.groupId)){let n=e.groups.find(e=>e.id===t.groupId),r=l.get(t.groupId);return r?Tr(t,n,{x:p,y:r.y,width:m-p,height:r.height}):t}return g.get(t.groupId)??t});for(let e of h)r.includes(e.groupId)||_.some(t=>t.groupId===e.groupId)||_.push(e);return Dr(a,_)}function kr(e){if(e.priority===`high`)return 20;if(e.priority===`low`)return 1;let t=e.branch??m(e.label);return e.kind===`failure`||t===`no`?3:t===`yes`?12:e.label?5:10}function Ar(e,t){let n=new Map;for(let t of e.nodes)n.set(t.id,[]);for(let r of e.edges){if(!t.has(r.id))continue;let e=n.get(r.from);e&&e.push(r.to)}return n}function jr(e,t,n,r){if(n===r)return!0;let i=Ar(e,t),a=new Set([n]),o=[n];for(;o.length;){let e=o.shift();for(let t of i.get(e)??[]){if(t===r)return!0;a.has(t)||(a.add(t),o.push(t))}}return!1}function Mr(e,t){let n=new Map,r=new Map;for(let t of e.nodes)n.set(t.id,0),r.set(t.id,[]);for(let i of e.edges)t.has(i.id)&&(r.get(i.from)?.push(i.to),n.set(i.to,(n.get(i.to)??0)+1));let i=new Map,a=[];for(let t of e.nodes)i.set(t.id,0),(n.get(t.id)??0)===0&&a.push(t.id);let o=0;for(;a.length;){let e=a.shift();o+=1;let t=i.get(e)??0;for(let o of r.get(e)??[]){i.set(o,Math.max(i.get(o)??0,t+1));let e=(n.get(o)??0)-1;n.set(o,e),e===0&&a.push(o)}}if(o!==e.nodes.length)for(let t of e.nodes)i.has(t.id)||i.set(t.id,0);return i}function Nr(e){let t=e.edges.filter(e=>kr(e)>=10),n=e.edges.filter(e=>kr(e)<10).sort((e,t)=>{let n=kr(t)-kr(e);return n===0?e.id.localeCompare(t.id):n}),r=new Set((t.length>0?t:e.edges).map(e=>e.id)),i=new Set,a=t.length>0?t:e.edges,o=new Set(a.map(e=>e.id)),s=[...a].sort((e,t)=>{let n=kr(e)-kr(t);return n===0?e.id.localeCompare(t.id):n});for(let t of s)jr(e,o,t.to,t.from)&&(o.delete(t.id),r.delete(t.id),i.add(t.id));for(let t of n)i.has(t.id)||(jr(e,r,t.to,t.from)?i.add(t.id):r.add(t.id));return{rank:Mr(e,r),feedbackEdgeIds:i}}function Pr(e){return e===`TD`||e===`BT`}function Fr(e){let t=new Map,n=new Map;for(let r of e.nodes)t.set(r.id,0),n.set(r.id,0);for(let r of e.edges)n.set(r.from,(n.get(r.from)??0)+1),t.set(r.to,(t.get(r.to)??0)+1);return{incoming:t,outgoing:n}}function Ir(e,t){let{incoming:n,outgoing:r}=Fr(e),i=[],a=new Set;for(let t of e.nodes)t.kind===`choice`&&(r.get(t.id)??0)>=2&&(i.push(t.id),a.add(t.id));let o=[],s=[];for(let t of e.nodes)(n.get(t.id)??0)>=2&&o.push(t.id),(r.get(t.id)??0)>=2&&s.push(t.id);return{direction:t,isWorkflowTD:Pr(t)&&i.length>0,choiceNodes:i,mergeNodes:o,fanOutNodes:s,choiceBranches:a,incoming:n,outgoing:r}}function Lr(e){return e.branch??m(e.label)}function Rr(e){let t=Lr(e),n=3,r=3,i=5;return e.kind===`failure`||t===`no`?(n=1,r=9):t===`yes`?(n=9,r=5):e.label||(n=7,r=4),e.priority===`high`?(n+=3,r+=2,i=20):e.priority===`low`&&(n=Math.max(0,n-4),i=1,t!==`no`&&e.kind!==`failure`&&(r=Math.max(1,r-1))),{"elk.layered.priority.straightness":String(n),"elk.layered.priority.shortness":String(r),"elk.layered.priority.direction":String(i)}}function zr(e){switch(e){case`BT`:return`NORTH`;case`LR`:return`EAST`;case`RL`:return`WEST`;default:return`SOUTH`}}function Br(e){switch(e){case`BT`:return`SOUTH`;case`LR`:return`WEST`;case`RL`:return`EAST`;default:return`NORTH`}}function Vr(e){switch(e){case`NORTH`:return`north`;case`EAST`:return`east`;case`WEST`:return`west`;default:return`south`}}function Hr(e,t){return`${e}:out:${t}`}function Ur(e,t){return`${e}:in:${t}`}function Wr(e,t,n,r,i,a,o){let s=ln(un(i)),c={x:0,y:0,width:a,height:o},l=s.getPortPosition({kind:`side`,side:Vr(t),index:n,count:r},c);return{id:e,x:l.x-.5,y:l.y-.5,width:1,height:1,layoutOptions:{"elk.port.side":t,"elk.port.index":String(n)}}}function Gr(e){let t=Lr(e);return t===`yes`?0:t===`no`?2:1}function Kr(e){let t=new Set;for(let n of e.edges)n.from!==n.to&&e.edges.some(e=>e.id!==n.id&&e.from===n.to&&e.to===n.from)&&t.add(n.id);return t}function qr(e,t,n,r){let i=new Map;for(let t of e){let e=i.get(t.side)??[];e.push(t),i.set(t.side,e)}let a=[];for(let[e,o]of i){o.sort((e,t)=>e.rank-t.rank||e.edgeId.localeCompare(t.edgeId));let i=o.length;o.forEach((o,s)=>{o.y==null?a.push(Wr(o.id,e,s,i,t,n,r)):a.push(Jr(o.id,e,o.y,n,r,s))})}return a}function Jr(e,t,n,r,i,a){let o=Math.max(1,Math.min(i-1,n));return{id:e,x:t===`EAST`?r-.5:t===`WEST`?-.5:r/2-.5,y:o-.5,width:1,height:1,layoutOptions:{"elk.port.side":t,"elk.port.index":String(a)}}}function Yr(e,t){if(!e||!t||!An(e))return;let n=o(e.columns,t);if(n<0)return;let r=e.scale&&e.scale>0?e.scale:1;return jn(0,n,r,Nn(e,r))}function Xr(e,t,n){let r=new Map(t.map(e=>[e.nodeId,e])),i=new Map(e.nodes.map(e=>[e.id,e.shape])),a=zr(n),o=Br(n),s=Kr(e),c=new Map,l=new Map,u=new Map,d=new Map,f=(e,t,n)=>{let r=e.get(t)??[];r.push(n),e.set(t,r)},p=new Map(e.nodes.map(e=>[e.id,e]));for(let t of e.edges){if(s.has(t.id))continue;let e=Hr(t.from,t.id),n=Ur(t.to,t.id);u.set(t.id,e),d.set(t.id,n);let r=!!(t.fromColumn||t.toColumn),i=p.get(t.from),m=p.get(t.to);f(c,t.from,{id:e,edgeId:t.id,side:r?`EAST`:a,rank:Gr(t),y:Yr(i,t.fromColumn)}),f(l,t.to,{id:n,edgeId:t.id,side:r?`WEST`:o,rank:1,y:Yr(m,t.toColumn)})}let m=new Map,h=new Set;for(let t of e.nodes){let e=r.get(t.id);if(!e)continue;let n=c.get(t.id)??[],a=l.get(t.id)??[];if(!n.length&&!a.length)continue;h.add(t.id);let o=i.get(t.id);m.set(t.id,[...qr(n,o,e.width,e.height),...qr(a,o,e.width,e.height)])}return{portsByNode:m,edgeSourcePort:u,edgeTargetPort:d,portedNodes:h}}var Zr=.75;function Qr(e,t=Zr){if(e.length<3)return e;let n=[e[0]];for(let r=1;r<e.length-1;r++){let i=n[n.length-1],a=e[r],o=e[r+1],s=Math.abs(i.x-a.x)<t&&Math.abs(a.x-o.x)<t,c=Math.abs(i.y-a.y)<t&&Math.abs(a.y-o.y)<t;s||c||n.push(a)}return n.push(e[e.length-1]),n}function $r(e,t,n,r){return Math.min(e,t)<=Math.max(n,r)&&Math.max(e,t)>=Math.min(n,r)}function ei(e,t,n,r){let i=t,a=e.length-1;i>0&&(e[i][n]=r),i+1<a&&(e[i+1][n]=r)}function ti(e,t,n){if(e.length<3||t.length===0||n<=0)return e;let r=e.map(e=>({x:e.x,y:e.y}));for(let e=0;e<3;e++){let e=!1;for(let i=0;i<r.length-1;i++){if(i===0||i===r.length-2)continue;let a=r[i],o=r[i+1],s=Math.abs(a.x-o.x)<Zr,c=Math.abs(a.y-o.y)<Zr;if(s||c)for(let c of t){let t=c.x,l=c.x+c.width,u=c.y,d=c.y+c.height;if(s){let s=(a.x+o.x)/2;if(!$r(a.y,o.y,u-n,d+n))continue;s>t-n&&s<t?(ei(r,i,`x`,t-n),e=!0):s>l&&s<l+n&&(ei(r,i,`x`,l+n),e=!0)}else{let s=(a.y+o.y)/2;if(!$r(a.x,o.x,t-n,l+n))continue;s>u-n&&s<u?(ei(r,i,`y`,u-n),e=!0):s>d&&s<d+n&&(ei(r,i,`y`,d+n),e=!0)}}}if(!e)break}return r}function ni(e,t=Zr){if(e.length<2)return e;let n=[{...e[0]}];for(let r=1;r<e.length;r++){let i=n[n.length-1],a=e[r],o=Math.abs(a.x-i.x),s=Math.abs(a.y-i.y);if(o>t&&s>t){let e=n.length>=2?n[n.length-2]:null,r=e==null?s>=o:Math.abs(e.x-i.x)<t;n.push(r?{x:i.x,y:a.y}:{x:a.x,y:i.y})}n.push({...a})}return Qr(n,t)}function ri(e,t=[],n=28){let r=Math.max(28,n);return e.map(e=>({...e,points:ni(Qr(ti(e.points,t,r)))}))}var ii=`balanced`,ai={straight:`BRANDES_KOEPF`,balanced:`NETWORK_SIMPLEX`,basic:`SIMPLE`},oi=24;function si(e){switch(e){case`RL`:return`LEFT`;case`TD`:return`DOWN`;case`BT`:return`UP`;default:return`RIGHT`}}function ci(e){let t=e.density??`normal`,n=e.spacingScale??1,r=tr[t]??tr.normal;return Math.round(r*n)}function li(e){return e===`TD`||e===`BT`?`0.72`:`1.55`}function ui(e){let t=e.indexOf(`:`);return t<=0?e:e.slice(0,t)}function di(e,t,n){let r=_r(e,n),i=new Map(t.map(e=>[e.nodeId,e])),a=ci(r),o=r.groupGap??72,s=r.direction??`LR`,c=Math.max(28,r.edgeNodeSpacing??Math.round(a*.6)),l=Math.max(12,r.edgeEdgeSpacing??Math.max(18,Math.round(a*.36))),u=r.groupGap==null?a:o,d=r.groupGap==null?a:Math.round(o*.9),f=ai[r.nodePlacement??ii]??ai.straight,p=Ir(e,s),m=Xr(e,t,s),h=e.groups.filter(e=>e.kind===`swimlane`&&e.parentId==null).length>0&&r.groupLayout!==`flat`,g=r.groupLayout===`flat`||h||r.groupLayout!==`compound`,_=g?`SEPARATE_CHILDREN`:`INCLUDE_CHILDREN`,v=p.incoming,y=p.outgoing,b=h?Nr(e):void 0,x={"elk.algorithm":`layered`,"elk.direction":si(s),"elk.edgeRouting":`ORTHOGONAL`,"elk.hierarchyHandling":_,"elk.aspectRatio":li(s),"elk.layered.thoroughness":String(oi),"elk.layered.crossingMinimization.strategy":`LAYER_SWEEP`,"elk.layered.nodePlacement.strategy":f,"elk.layered.nodePlacement.bk.edgeStraightening":`IMPROVE_STRAIGHTNESS`,"elk.layered.nodePlacement.favorStraightEdges":`true`,"elk.layered.compaction.postCompaction.strategy":`EDGE_LENGTH`,"elk.layered.unnecessaryBendpoints":`false`,"elk.layered.feedbackEdges":`false`,"elk.layered.considerModelOrder.strategy":h||r.considerModelOrder===!1?`NONE`:`NODES_AND_EDGES`,"elk.padding":`[top=64,left=64,bottom=64,right=64]`,"elk.spacing.nodeNode":String(u),"elk.layered.spacing.nodeNodeBetweenLayers":String(d),"elk.spacing.edgeNode":String(c),"elk.layered.spacing.edgeNodeBetweenLayers":String(c),"elk.spacing.edgeEdge":String(l),"elk.layered.spacing.edgeEdgeBetweenLayers":String(l),"elk.spacing.componentComponent":String(o)};e.edges.some(t=>e.nodes.find(e=>e.id===t.from)?.groupId!==e.nodes.find(e=>e.id===t.to)?.groupId)&&!g&&(x[`elk.layered.mergeHierarchyEdges`]=`true`);let S=new Map;for(let t of e.groups){if(g)continue;let e=t.parentId,n=S.get(e)??[];n.push(t),S.set(e,n)}let ee=new Set,C=e=>{let t={},n=b?.rank.get(e);if(n!=null)t[`elk.layered.layering.layerChoiceConstraint`]=String(n);else{let n=y.get(e)??0,r=v.get(e)??0;n===0&&r>0&&(t[`elk.layered.layering.layerConstraint`]=`LAST`),r===0&&n>0&&(t[`elk.layered.layering.layerConstraint`]=`FIRST`)}return m.portedNodes.has(e)&&(t[`elk.portConstraints`]=`FIXED_POS`),t},w=(e,t)=>{let n=C(e),r=m.portsByNode.get(e);return{id:e,width:t.width,height:t.height,...Object.keys(n).length?{layoutOptions:n}:{},...r?.length?{ports:r}:{}}},T=t=>{let n=e.groups.find(e=>e.id===t),r=cr(n),o=[];for(let e of n.nodeIds){let t=i.get(e);t&&(ee.add(e),o.push(w(e,t)))}for(let e of S.get(t)??[])o.push(T(e.id));let c={"elk.algorithm":`layered`,"elk.direction":si(s),"elk.edgeRouting":`ORTHOGONAL`,"elk.padding":`[top=${r.top},left=${r.left},bottom=${r.bottom},right=${r.right}]`,"elk.spacing.nodeNode":String(Math.round(a*.8)),"elk.layered.spacing.nodeNodeBetweenLayers":String(Math.round(a*.8)),"elk.layered.nodePlacement.strategy":f,"elk.layered.nodePlacement.favorStraightEdges":`true`,"elk.contentAlignment":`V_CENTER H_CENTER`};return{id:`group:${n.id}`,children:o,labels:n.label?[{id:`group:${n.id}:label`,text:n.label,width:80,height:18}]:void 0,layoutOptions:c}},E=[];for(let e of S.get(void 0)??[])E.push(T(e.id));for(let t of e.nodes){if(ee.has(t.id))continue;let e=i.get(t.id);e&&E.push(w(t.id,e))}let D=e=>m.edgeSourcePort.get(e.id)??e.from,O=e=>m.edgeTargetPort.get(e.id)??e.to;return{id:`root`,layoutOptions:x,children:E,edges:e.edges.filter(e=>!b?.feedbackEdgeIds.has(e.id)).map(e=>({id:e.id,sources:[D(e)],targets:[O(e)],layoutOptions:Rr(e)}))}}var fi=e(F(),1).default,pi=null;function mi(){return pi||=new fi({defaultLayoutOptions:{"elk.algorithm":`layered`,"elk.edgeRouting":`ORTHOGONAL`,"elk.hierarchyHandling":`INCLUDE_CHILDREN`}}),pi}var hi=`elk-layered-v1`,gi=`elk-orthogonal-v1`,_i=.75;function vi(e,t){return{x:t.x-e.x,y:t.y-e.y}}function yi(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function bi(e){return Math.abs(e.x)>=Math.abs(e.y)?{x:Math.sign(e.x)||1,y:0}:{x:0,y:Math.sign(e.y)||1}}function xi(e,t){return Math.abs(e.x-t.x)<_i||Math.abs(e.y-t.y)<_i}function Si(e,t,n,r){let i=e[t===0?1:t-1];if(xi(i,n)){e[t]=n;return}let a=Math.abs(r.y)>=Math.abs(r.x)?{x:i.x,y:n.y}:{x:n.x,y:i.y};e[t]=n,t===0?e.splice(1,0,a):e.splice(t,0,a)}function Ci(e,t){let n=t.x,r=t.x+t.width,i=t.y,a=t.y+t.height,o=e.x>=n-_i&&e.x<=r+_i,s=e.y>=i-_i&&e.y<=a+_i;return e.y<i&&o?{x:0,y:1}:e.y>a&&o?{x:0,y:-1}:e.x<n&&s?{x:1,y:0}:e.x>r&&s?{x:-1,y:0}:bi(vi(e,yi(t)))}function wi(e,t,n){let r=new Map(t.map(e=>[e.nodeId,e])),i=new Map(e.nodes.map(e=>[e.id,e]));return n.map(t=>{let n=e.edges.find(e=>e.id===t.edgeId);if(!n||t.points.length<2||n.fromColumn||n.toColumn)return t;let a=t.points.map(e=>({x:e.x,y:e.y})),o=r.get(n.from),s=r.get(n.to),c=i.get(n.from),l=i.get(n.to);if(o&&c){let e=a[1],t=Ci(e,o.bounds);Si(a,0,pn({shapeId:c.shape,bounds:o.bounds,origin:e,direction:t}),t)}if(s&&l){let e=a[a.length-2],t=Ci(e,s.bounds),n=pn({shapeId:l.shape,bounds:s.bounds,origin:e,direction:t});Si(a,a.length-1,n,t)}return{...t,points:a}})}var Ti={compact:tr.compact,normal:tr.normal,spacious:tr.spacious};function Ei(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,e):typeof e==`string`&&Ti[e]!=null?Ti[e]:72}function Di(e,t){return typeof e==`number`?Math.max(1,Math.floor(e)):Array.isArray(e)?Math.max(1,e.length):Math.max(1,t)}function Oi(e,t,n){let r=Di(e,1),i=1;for(let r of t){let t=n===`column`?r.column:r.row,a=n===`column`?r.colSpan??1:r.rowSpan??1;if(typeof t==`number`&&t>=1&&(i=Math.max(i,t+a-1)),typeof t==`string`&&Array.isArray(e)){let n=e.indexOf(t);n>=0&&(i=Math.max(i,n+a))}}return Math.max(r,i)}function ki(e,t,n,r){if(typeof e==`number`&&e>=1)return Math.min(r-1,Math.max(0,Math.floor(e)-1));if(typeof e==`string`&&Array.isArray(t)){let n=t.indexOf(e);if(n>=0)return n}return Math.min(r-1,Math.max(0,n))}function Ai(e,t){if(t<=0)return 0;switch(e){case`end`:return t;case`center`:return t/2;default:return 0}}function ji(e){let t=e.align??`stretch`,n=Ei(e.gap),r=e.origin?.x??0,i=e.origin?.y??0,a=e.cells;return a.length===0?[]:e.arrange===`stack`?Mi(a,t,n,r,i):e.arrange===`row`?Ni(a,t,n,r,i):Pi(e,t,n,r,i)}function Mi(e,t,n,r,i){let a=Math.max(...e.map(e=>e.width),0),o=i,s=[];for(let i of e){let e=t===`stretch`?a:i.width,c=r+Ai(t,a-e);s.push({groupId:i.groupId,bounds:{x:c,y:o,width:e,height:i.height}}),o+=i.height+n}return s}function Ni(e,t,n,r,i){let a=Math.max(...e.map(e=>e.height),0),o=r,s=[];for(let r of e){let e=t===`stretch`?a:r.height,c=i+Ai(t,a-e);s.push({groupId:r.groupId,bounds:{x:o,y:c,width:r.width,height:e}}),o+=r.width+n}return s}function Pi(e,t,n,r,i){let a=e.cells,o=0,s=0,c=Oi(e.columns,a,`column`),l=Oi(e.rows,a,`row`),u=a.map(t=>{let n=Math.max(1,t.colSpan??1),r=Math.max(1,t.rowSpan??1),i=ki(t.column,e.columns,o,c),a=ki(t.row,e.rows,s,l);return t.column==null&&t.row==null&&(i=o,a=s,o+=n,o>=c&&(o=0,s+=1)),{cell:t,col:i,row:a,colSpan:n,rowSpan:r}}),d=Math.max(c,...u.map(e=>e.col+e.colSpan)),f=Math.max(l,...u.map(e=>e.row+e.rowSpan)),p=Array.from({length:d},()=>0),m=Array.from({length:f},()=>0);for(let e of u){let t=e.cell.width/e.colSpan,n=e.cell.height/e.rowSpan;for(let n=e.col;n<e.col+e.colSpan;n++)p[n]=Math.max(p[n],t);for(let t=e.row;t<e.row+e.rowSpan;t++)m[t]=Math.max(m[t],n)}let h=[],g=r;for(let e=0;e<d;e++)h.push(g),g+=p[e]+(e<d-1?n:0);let _=[],v=i;for(let e=0;e<f;e++)_.push(v),v+=m[e]+(e<f-1?n:0);return u.map(e=>{let r=0;for(let t=e.col;t<e.col+e.colSpan;t++)r+=p[t],t<e.col+e.colSpan-1&&(r+=n);let i=0;for(let t=e.row;t<e.row+e.rowSpan;t++)i+=m[t],t<e.row+e.rowSpan-1&&(i+=n);let a=t===`stretch`?r:e.cell.width,o=t===`stretch`?i:e.cell.height,s=Ai(t,r-a),c=Ai(t,i-o);return{groupId:e.cell.groupId,bounds:{x:h[e.col]+s,y:_[e.row]+c,width:a,height:o}}})}function Fi(e){return e.arrange===`stack`||e.arrange===`row`||e.arrange===`grid`||e.arrange===`surround`}function Ii(e,t){return Math.hypot(e,t)/2}function Li(e){let t=Ei(e.gap),n=e.origin?.x??0,r=e.origin?.y??0,i=Math.max(1,e.hub.width),a=Math.max(1,e.hub.height),o=Ii(i,a),s=e.satellites.reduce((e,t)=>Math.max(e,Ii(t.width,t.height)),0),c=o+t+s,l=[];if(e.satellites.length!==0){let t=new Map;for(let n of e.satellites){let e=n.side??`auto`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=(e,t)=>{let n=0+Math.cos(t)*c-e.width/2,r=0-Math.sin(t)*c-e.height/2;l.push({id:e.id,x:n,y:r,width:e.width,height:e.height})},r={east:0,north:Math.PI/2,west:Math.PI,south:3*Math.PI/2},i=50*Math.PI/180;for(let e of[`west`,`east`,`north`,`south`]){let a=t.get(e);if(!a?.length)continue;let o=r[e];if(a.length===1)n(a[0],o);else for(let e=0;e<a.length;e++){let t=a.length===1?.5:e/(a.length-1),r=o-i+t*2*i;n(a[e],r)}}let a=t.get(`auto`)??[];if(a.length)for(let e=0;e<a.length;e++){let t=Math.PI-e*2*Math.PI/a.length;n(a[e],t)}}let u={x:0-i/2,y:0-a/2,width:i,height:a},d=u.x,f=u.y,p=u.x+u.width,m=u.y+u.height;for(let e of l)d=Math.min(d,e.x),f=Math.min(f,e.y),p=Math.max(p,e.x+e.width),m=Math.max(m,e.y+e.height);let h=n-d,g=r-f;return{hub:{x:u.x+h,y:u.y+g,width:i,height:a},satellites:l.map(e=>({groupId:e.id,bounds:{x:e.x+h,y:e.y+g,width:e.width,height:e.height}})),contentBounds:{x:n,y:r,width:p-d,height:m-f}}}var J=.5,Ri=16;function zi(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function Bi(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Vi(e,t,n){let r=Math.min(e.x,t.x),i=Math.max(e.x,t.x),a=Math.min(e.y,t.y),o=Math.max(e.y,t.y),s=n.x,c=n.x+n.width,l=n.y,u=n.y+n.height;if(Math.abs(e.x-t.x)<J){let t=e.x;return t<=s+J||t>=c-J?!1:o>l+J&&a<u-J}if(Math.abs(e.y-t.y)<J){let t=e.y;return t<=l+J||t>=u-J?!1:i>s+J&&r<c-J}return!1}function Hi(e,t,n,r){return Math.min(e,t)<=Math.max(n,r)&&Math.max(e,t)>=Math.min(n,r)}function Ui(e,t,n,r=Ri,i=!1){let a=Math.min(e.x,t.x),o=Math.max(e.x,t.x),s=Math.min(e.y,t.y),c=Math.max(e.y,t.y),l=n.x,u=n.x+n.width,d=n.y,f=n.y+n.height,p=Math.abs(t.x-e.x)+Math.abs(t.y-e.y);if(Math.abs(e.x-t.x)<J){let t=e.x,n=Math.abs(t-l)<=r,a=Math.abs(t-u)<=r;return!(n||a)||!Hi(s,c,d,f)||i&&p<=r*1.5?!1:Math.min(c,f)-Math.max(s,d)>r*.5}if(Math.abs(e.y-t.y)<J){let t=e.y,n=Math.abs(t-d)<=r,s=Math.abs(t-f)<=r;return!(n||s)||!Hi(a,o,l,u)||i&&p<=r*1.5?!1:Math.min(o,u)-Math.max(a,l)>r*.5}return!1}function Wi(e){let t=0;for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];t+=Math.abs(i.x-r.x)+Math.abs(i.y-r.y)}return t}function Gi(e){let t=[];for(let n of e){let e=t[t.length-1];e&&Math.abs(e.x-n.x)<J&&Math.abs(e.y-n.y)<J||t.push(n)}return t}function Ki(e){if(e.length<3)return e;let t=[e[0]];for(let n=1;n<e.length-1;n++){if(n===1||n===e.length-2){t.push(e[n]);continue}let r=t[t.length-1],i=e[n],a=e[n+1],o=Math.abs(r.x-i.x)<J&&Math.abs(i.x-a.x)<J,s=Math.abs(r.y-i.y)<J&&Math.abs(i.y-a.y)<J;o||s||t.push(i)}return t.push(e[e.length-1]),Gi(t)}function Y(e,t,n){let r=Math.min(.85,Math.max(.15,n));switch(t){case`N`:return{x:e.x+e.width*r,y:e.y};case`S`:return{x:e.x+e.width*r,y:e.y+e.height};case`E`:return{x:e.x+e.width,y:e.y+e.height*r};case`W`:return{x:e.x,y:e.y+e.height*r}}}function qi(e,t){return Math.abs(e.y-t.y)<J&&e.x>=t.x-J&&e.x<=t.x+t.width+J?`N`:Math.abs(e.y-(t.y+t.height))<J&&e.x>=t.x-J&&e.x<=t.x+t.width+J?`S`:Math.abs(e.x-(t.x+t.width))<J&&e.y>=t.y-J&&e.y<=t.y+t.height+J?`E`:Math.abs(e.x-t.x)<J&&e.y>=t.y-J&&e.y<=t.y+t.height+J?`W`:null}function Ji(e,t,n,r){let i=qi(n[0],e),a=qi(n[n.length-1],t),o=0;i&&i!==r[0]&&(o+=2400),a&&a!==r[1]&&(o+=9e3);let[s,c]=r;return s===`S`&&c===`N`&&a===`S`&&(o+=18e3),s===`S`&&c===`N`&&(a===`E`||a===`W`)&&(o+=12e3),s===`N`&&c===`S`&&a===`N`&&(o+=18e3),s===`E`&&c===`W`&&a===`E`&&(o+=18e3),s===`W`&&c===`E`&&a===`W`&&(o+=18e3),o}function Yi(e,t,n,r){let i=Y(e,t,n);switch(t){case`E`:return{x:i.x+r,y:i.y};case`W`:return{x:i.x-r,y:i.y};case`S`:return{x:i.x,y:i.y+r};case`N`:return{x:i.x,y:i.y-r}}}function Xi(e,t){let n=Zi(e,t),r=t.x-(e.x+e.width),i=e.x-(t.x+t.width),a=t.y-(e.y+e.height),o=e.y-(t.y+t.height);return[n,n[0]===`E`||n[0]===`W`?a>=o?[`S`,`N`]:[`N`,`S`]:r>=i?[`E`,`W`]:[`W`,`E`],[`E`,`W`],[`W`,`E`],[`S`,`N`],[`N`,`S`]]}function Zi(e,t){let n=t.x-(e.x+e.width),r=e.x-(t.x+t.width),i=t.y-(e.y+e.height),a=e.y-(t.y+t.height),o=Math.max(n,r),s=Math.max(i,a),c=o>8,l=s>8;if(c&&(!l||o>=s*.35||o>48))return n>=r?[`E`,`W`]:[`W`,`E`];if(l)return i>=a?[`S`,`N`]:[`N`,`S`];let u=Bi(e),d=Bi(t),f=d.x-u.x,p=d.y-u.y;return Math.abs(f)>=Math.abs(p)?f>=0?[`E`,`W`]:[`W`,`E`]:p>=0?[`S`,`N`]:[`N`,`S`]}function Qi(e,t,n,r){return n===`S`&&r===`N`?t.y-(e.y+e.height):n===`N`&&r===`S`?e.y-(t.y+t.height):n===`E`&&r===`W`?t.x-(e.x+e.width):n===`W`&&r===`E`?e.x-(t.x+t.width):null}function $i(e,t,n){return n===`S`||n===`N`?Hi(e.x,e.x+e.width,t.x,t.x+t.width):Hi(e.y,e.y+e.height,t.y,t.y+t.height)}function ea(e,t,n,r,i,a,o){let[s,c]=Xi(e,t)[0],l=Qi(e,t,s,c);if(l==null||l<=0||l>=o*2||!$i(e,t,s))return null;let u=Y(e,s,i),d=Y(t,c,a),f=l/2,p;if(s===`S`||s===`N`){let t=s===`S`?e.y+e.height+f:e.y-f;p=[{x:u.x,y:t},{x:d.x,y:t}]}else{let t=s===`E`?e.x+e.width+f:e.x-f;p=[{x:t,y:u.y},{x:t,y:d.y}]}let m=Ki(Gi([u,...p,d])),h=Math.min(r,Math.max(0,l/4-1));return ua(m,n.map(e=>zi(e,h)),[e,t])>0?null:m}function ta(e,t){return t==null||t<=0?e:Math.min(e,Math.max(2,t/2-1))}function na(e,t){return Math.abs(e.y-t.y)<J||Math.abs(e.x-t.x)<J?[e,t]:[e,{x:t.x,y:e.y},t]}function ra(e,t){return Math.abs(e.y-t.y)<J||Math.abs(e.x-t.x)<J?[e,t]:[e,{x:e.x,y:t.y},t]}function ia(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);return{x:t,y:n,width:r-t,height:i-n}}function aa(e,t,n,r,i=.5,a=.5){let o=[r,Math.min(r,12),6,2].filter((e,t,n)=>n.indexOf(e)===t),s=null;for(let r of o){let o=oa(e,t,n,r,i,a);if(o.clear)return o.points;s??=o.points}return s??[Bi(e),Bi(t)]}function oa(e,t,n,r,i,a){let o=Math.max(Math.max(Ri,r)*2.25,r+14),s=ea(e,t,n,r,i,a,o);if(s)return{points:s,clear:!0};let c=Math.max(Ri,o*.75),l=n.map(e=>zi(e,r)),u=[e,t],d=[],f=Xi(e,t),p=f[0];for(let n=0;n<f.length;n++){let[r,s]=f[n],c=ta(o,Qi(e,t,r,s)),l=Y(e,r,i),u=Y(t,s,a),p=Yi(e,r,i,c),m=Yi(t,s,a,c);for(let e of[na(p,m),ra(p,m)])d.push({raw:[l,...e,u],rank:n});let h=(p.x+m.x)/2,g=(p.y+m.y)/2;d.push({raw:[l,p,{x:h,y:p.y},{x:h,y:m.y},m,u],rank:n}),d.push({raw:[l,p,{x:p.x,y:g},{x:m.x,y:g},m,u],rank:n})}sa(d,e,t,l,r,i,a,p);let m=ia([...ca(e,t,l),zi(e,r),zi(t,r)]);if(m){let n=Math.max(r,o),s=m.x-n,c=m.x+m.width+n,l=m.y-n,u=m.y+m.height+n,f=[p[1],...[`N`,`S`,`E`,`W`].filter(e=>e!==p[1])];for(let n of f)la(d,e,i,o,r,s,c,l,u,Y(t,n,a),n===p[1]?2:5)}let h=null,g=1/0,_=d[0]?.raw??[Bi(e),Bi(t)],v=1/0;for(let r of d){let i=Ki(Gi(r.raw));if(i.length<2)continue;let a=Wi(i),o=ua(i,l,u),s=da(i,u,c)+da(i,n,Ri),d=Ji(e,t,i,p),f=o*1e5+s*140+r.rank*320+d+a;f<v&&(v=f,_=i),o===0&&f<g&&(g=f,h=i)}return{points:h??_,clear:h!=null}}function sa(e,t,n,r,i,a,o,s){let[c,l]=s,u=Math.max(i,Ri),d=Y(n,l,o),f=Yi(n,l,o,u);if(c===`E`&&l===`W`||c===`W`&&l===`E`){let i=c===`E`?t.x+t.width:n.x+n.width,o=c===`E`?n.x:t.x;if(o<=i+1)return;let s=r.filter(e=>e.x+e.width>i-1&&e.x<o-1&&(Hi(e.y,e.y+e.height,t.y,t.y+t.height)||Hi(e.y,e.y+e.height,n.y,n.y+n.height)));if(s.length===0)return;let l=Math.min(...s.map(e=>e.y))-u,p=Math.max(...s.map(e=>e.y+e.height))+u,m=Y(t,`N`,a),h=Y(t,`S`,a);e.push({raw:[m,{x:m.x,y:l},{x:f.x,y:l},f,d],rank:1}),e.push({raw:[h,{x:h.x,y:p},{x:f.x,y:p},f,d],rank:1});let g=Y(t,c,a),_=c===`E`?Math.min(g.x+u,(i+o)/2):Math.max(g.x-u,(i+o)/2);e.push({raw:[g,{x:_,y:g.y},{x:_,y:l},{x:f.x,y:l},f,d],rank:0}),e.push({raw:[g,{x:_,y:g.y},{x:_,y:p},{x:f.x,y:p},f,d],rank:0})}else if(c===`S`&&l===`N`||c===`N`&&l===`S`){let i=c===`S`?t.y+t.height:n.y+n.height,o=c===`S`?n.y:t.y;if(o<=i+1)return;let s=r.filter(e=>e.y+e.height>i-1&&e.y<o-1&&(Hi(e.x,e.x+e.width,t.x,t.x+t.width)||Hi(e.x,e.x+e.width,n.x,n.x+n.width)));if(s.length===0)return;let l=Math.min(...s.map(e=>e.x))-u,p=Math.max(...s.map(e=>e.x+e.width))+u,m=Y(t,`W`,a),h=Y(t,`E`,a);e.push({raw:[m,{x:l,y:m.y},{x:l,y:f.y},f,d],rank:1}),e.push({raw:[h,{x:p,y:h.y},{x:p,y:f.y},f,d],rank:1})}}function ca(e,t,n,r=160){let i=Math.min(e.x,t.x)-r,a=Math.min(e.y,t.y)-r,o=Math.max(e.x+e.width,t.x+t.width)+r,s=Math.max(e.y+e.height,t.y+t.height)+r;return n.filter(e=>!(e.x+e.width<i||e.x>o||e.y+e.height<a||e.y>s))}function la(e,t,n,r,i,a,o,s,c,l,u=3){let d=Y(t,`N`,n),f=Y(t,`S`,n),p=Y(t,`E`,n),m=Y(t,`W`,n),h=Math.min(r,Math.max(i,d.y-s)),g=Math.min(r,Math.max(i,c-f.y)),_=Math.min(r,Math.max(i,o-p.x)),v=Math.min(r,Math.max(i,m.x-a)),y=Yi(t,`N`,n,h),b=Yi(t,`S`,n,g),x=Yi(t,`E`,n,_),S=Yi(t,`W`,n,v);e.push({raw:[p,x,{x:o,y:x.y},{x:o,y:s},{x:l.x,y:s},l],rank:u}),e.push({raw:[p,x,{x:o,y:x.y},{x:o,y:c},{x:l.x,y:c},l],rank:u+1}),e.push({raw:[m,S,{x:a,y:S.y},{x:a,y:s},{x:l.x,y:s},l],rank:u}),e.push({raw:[m,S,{x:a,y:S.y},{x:a,y:c},{x:l.x,y:c},l],rank:u+1}),e.push({raw:[d,y,{x:y.x,y:s},{x:a,y:s},{x:a,y:l.y},l],rank:u}),e.push({raw:[d,y,{x:y.x,y:s},{x:o,y:s},{x:o,y:l.y},l],rank:u}),e.push({raw:[d,y,{x:y.x,y:s},{x:l.x,y:s},l],rank:u+1}),e.push({raw:[f,b,{x:b.x,y:c},{x:a,y:c},{x:a,y:l.y},l],rank:u}),e.push({raw:[f,b,{x:b.x,y:c},{x:o,y:c},{x:o,y:l.y},l],rank:u}),e.push({raw:[f,b,{x:b.x,y:c},{x:l.x,y:c},l],rank:u+1})}function ua(e,t,n){let r=0;for(let i=0;i<e.length-1;i++){let a=i===0||i===e.length-2;for(let n of t)Vi(e[i],e[i+1],n)&&(r+=1);if(!a)for(let t of n)Vi(e[i],e[i+1],t)&&(r+=1)}return r}function da(e,t,n){let r=0;for(let i=0;i<e.length-1;i++){let a=i===0||i===e.length-2;for(let o of t)Ui(e[i],e[i+1],o,n,a)&&(r+=1)}return r}function fa(e){return e===`row`?`TD`:e===`stack`?`LR`:`TD`}var pa=`__node__:`;function ma(e){switch(e){case`compact`:return 20;case`spacious`:return 40;default:return 28}}function ha(e,t){let n=t.spacingScale??1,r=e==null?ma(t.density):Ei(e);return Math.max(0,Math.round(r*n))}function ga(e,t){let n=t.spacingScale??1;return Math.max(0,Math.round(Ei(e)*n))}function _a(e){return`${pa}${e}`}function va(e){return e.startsWith(pa)?e.slice(9):null}function ya(e){switch(e){case`compact`:return 420;case`spacious`:return 720;default:return 560}}function ba(e,t){return gr(e)&&t.groupLayout!==`flat`?!1:t.arrange===`stack`||t.arrange===`row`||t.arrange===`grid`||t.arrange===`surround`||e.groups.some(e=>Fi(e))}function xa(e,t){let n=t??`LR`,r=n===`LR`||n===`RL`,i=[...e].sort((e,t)=>{let n=r?e.bounds.x:e.bounds.y,i=r?t.bounds.x:t.bounds.y;return n===i?(r?e.bounds.y:e.bounds.x)-(r?t.bounds.y:t.bounds.x):n-i}),a=new Map,o=0,s=-1/0;for(let e of i){let t=r?e.bounds.x:e.bounds.y;t-s>8&&(s!==-1/0&&(o+=1),s=t),a.set(e.nodeId,o)}let c=new Map;return i.map(e=>{let t=a.get(e.nodeId)??0,n=c.get(t)??0;return c.set(t,n+1),{...e,rank:t,order:n}})}function Sa(e,t,n,r,i=28){let a=new Map,o=0,s=0,c=0,l=ya(r),u=Math.max(0,i),d=[],f=[];for(let r of e){let e=t.get(r);e&&(n===`stack`?(a.set(r,{x:0,y:s,width:e.width,height:e.height}),s+=e.height+u):(o>0&&o+e.width>l&&(d.push(f),f=[],o=0,s+=c+u,c=0),a.set(r,{x:o,y:s,width:e.width,height:e.height}),f.push(r),o+=e.width+u,c=Math.max(c,e.height)))}if(f.length&&d.push(f),n===`stack`&&a.size>1){let e=Math.max(...[...a.values()].map(e=>e.width));for(let[t,n]of a)a.set(t,{...n,x:(e-n.width)/2})}else if(n===`pack`&&d.length>0){let e=Math.max(...d.map(e=>e.length),0),t=Array.from({length:e},()=>0),n=Array.from({length:d.length},()=>0);for(let e=0;e<d.length;e++){let r=d[e];for(let i=0;i<r.length;i++){let o=a.get(r[i]);t[i]=Math.max(t[i],o.width),n[e]=Math.max(n[e],o.height)}}let r=0;for(let e=0;e<d.length;e++){let i=d[e],o=0;for(let e=0;e<i.length;e++){let n=i[e],s=a.get(n);a.set(n,{x:o,y:r,width:s.width,height:s.height}),o+=t[e]+u}r+=n[e]+u}}return a}function Ca(e,t){let n=[],r=new Map,i=[];for(let n of t){let t=e.nodes.find(e=>e.id===n)?.groupId;if(!t){i.push(n);continue}let a=r.get(t)??[];a.push(n),r.set(t,a)}for(let e of r.values())e.length>1?n.push(e):i.push(e[0]);for(let e of i)n.push([e]);return n}function wa(e,t,n){if(t.length<=1)return n;let r=e.nodes.find(e=>e.id===t[0])?.groupId,i=r?e.groups.find(e=>e.id===r):void 0;return i?.cellArrange===`stack`||i?.cellArrange===`pack`?i.cellArrange:n}function Ta(e,t,n){if(t.length<=1)return;let r=e.nodes.find(e=>e.id===t[0])?.groupId;if((r?e.groups.find(e=>e.id===r):void 0)?.align!==`stretch`)return;let i=Math.max(...[...n.values()].map(e=>e.width));for(let[e,t]of n)n.set(e,{...t,x:0,width:i})}function Ea(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=!1;for(let o of e)a=!0,t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),i=Math.max(i,o.y+o.height);return a?{x:t,y:n,width:r-t,height:i-n}:null}function Da(e,t,n){for(let[r,i]of e)e.set(r,{...i,x:i.x+t,y:i.y+n})}async function Oa(e,t,n,r,i){let a=new Set(Aa(e,t.id));if(a.size===0)return new Map;let o={...e,nodes:e.nodes.filter(e=>a.has(e.id)),edges:e.edges.filter(e=>a.has(e.from)&&a.has(e.to)),groups:[]},s=n.filter(e=>a.has(e.nodeId));if(s.length===0)return new Map;if(o.edges.length===0)return Sa(s.map(e=>e.nodeId),new Map(n.map(e=>[e.nodeId,e])),i===`TD`||i===`BT`?`stack`:`pack`,r.density,ha(void 0,r));let c=di(o,s,{...r,direction:i,groupLayout:`flat`}),l=await mi().layout(c),u=new Map;for(let e of l.children??[])a.has(e.id)&&u.set(e.id,{x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0});let d=Ea(u.values());return d&&(d.x!==0||d.y!==0)&&Da(u,-d.x,-d.y),u}function ka(e,t,n,r){let i=Math.max(0,e.width-t.left-t.right),a=Math.max(0,e.height-t.top-t.bottom),o=Math.max(0,i-n.width),s=Math.max(0,a-n.height),c=r===`end`?o:r===`start`?0:o/2,l=r===`end`?s:r===`start`?0:s/2;return{x:e.x+t.left+c,y:e.y+t.top+l}}function Aa(e,t){let n=e.groups.find(e=>e.id===t);if(!n)return[];let r=[...n.nodeIds],i=[...n.childGroupIds];for(;i.length;){let t=i.pop(),n=e.groups.find(e=>e.id===t);n&&(r.push(...n.nodeIds),i.push(...n.childGroupIds))}return r}function ja(e,t){return e.groups.filter(e=>e.parentId===t)}function Ma(e,t,n){let r=[];for(let n of t.nodeIds){let t=e.nodes.find(e=>e.id===n);r.push({kind:`node`,id:n,order:t?.sourceRange?.start.offset??2**53-1})}for(let t of n){let n=2**53-1;for(let r of Aa(e,t.id)){let t=e.nodes.find(e=>e.id===r)?.sourceRange?.start.offset;t!=null&&(n=Math.min(n,t))}r.push({kind:`group`,id:t.id,order:n})}return r.sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id)),r.map(({kind:e,id:t})=>e===`node`?{kind:`node`,id:t}:{kind:`group`,id:t})}function Na(e,t){let n=e.nodes.filter(e=>e.groupId==null).map(e=>({kind:`node`,id:e.id,order:e.sourceRange?.start.offset??2**53-1}));for(let r of t){let t=2**53-1;for(let n of Aa(e,r.id)){let r=e.nodes.find(e=>e.id===n)?.sourceRange?.start.offset;r!=null&&(t=Math.min(t,r))}n.push({kind:`group`,id:r.id,order:t})}return n.sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id)),n.map(({kind:e,id:t})=>({kind:e,id:t}))}async function Pa(e,t){if(!t)return;let n=ja(e.graph,t.id);if(n.length!==1)return;let r=n[0];Fi(r)&&await Fa(e,r);let i,a,o=new Map;if(e.groupBounds.has(r.id)&&Fi(r)){let t=e.groupBounds.get(r.id);i=t.width,a=t.height}else{let t=r.cellArrange??`flow`,n=ha(r.gap,e.options),s;s=t===`pack`||t===`stack`?Sa(r.nodeIds,e.measureMap,t,e.options.density,n):await Oa(e.graph,r,e.measured,e.options,`TD`);for(let[e,t]of s)o.set(e,t);let c=cr(r),l=Ea(s.values())??{x:0,y:0,width:80,height:40};i=l.width+c.left+c.right,a=l.height+c.top+c.bottom}let s=t.nodeIds.map(t=>{let n=e.measureMap.get(t),r=e.graph.nodes.find(e=>e.id===t);return n?{id:t,width:n.width,height:n.height,side:r?.side}:null}).filter(e=>e!=null),c=ga(t.gap??e.options.gap,e.options),l=Li({hub:{width:i,height:a},satellites:s,gap:c,origin:{x:64,y:64}});if(o.size>0){let n=cr(r);e.groupBounds.set(r.id,l.hub);let i=Ea(o.values())??{x:0,y:0,width:0,height:0},a=ka(l.hub,n,i,t.align??`center`);for(let[t,n]of o)e.nodeBounds.set(t,{x:a.x+(n.x-i.x),y:a.y+(n.y-i.y),width:n.width,height:n.height})}else if(Fi(r)){let t=e.groupBounds.get(r.id);if(t){let n=l.hub.x-t.x,i=l.hub.y-t.y;if(e.groupBounds.set(r.id,l.hub),n!==0||i!==0){for(let t of Aa(e.graph,r.id)){let r=e.nodeBounds.get(t);r&&e.nodeBounds.set(t,{...r,x:r.x+n,y:r.y+i})}let t=[...r.childGroupIds];for(;t.length;){let r=t.pop(),a=e.groupBounds.get(r);a&&e.groupBounds.set(r,{...a,x:a.x+n,y:a.y+i});let o=e.graph.groups.find(e=>e.id===r);o&&t.push(...o.childGroupIds)}}}else e.groupBounds.set(r.id,l.hub)}else e.groupBounds.set(r.id,l.hub);for(let t of l.satellites)e.nodeBounds.set(t.groupId,{...t.bounds});let u=cr(t),d={x:l.contentBounds.x-u.left,y:l.contentBounds.y-u.top,width:l.contentBounds.width+u.left+u.right,height:l.contentBounds.height+u.top+u.bottom};dr(t.shape)&&(d=ur(d)),e.groupBounds.set(t.id,d)}async function Fa(e,t){let n=t?.arrange??e.options.arrange;if(!n)return;if(n===`surround`){await Pa(e,t);return}let r=ja(e.graph,t?.id),i=t?.members&&t.members.length>0?t.members:t?Ma(e.graph,t,r):Na(e.graph,r);if(i.length===0)return;let a=t?.align??e.options.align??`stretch`,o=fa(n),s=new Map(r.map(e=>[e.id,e]));for(let t of r)Fi(t)&&await Fa(e,t);let c=[],l=new Map;for(let t of i){if(t.kind===`node`){let n=e.measureMap.get(t.id);if(!n)continue;c.push({groupId:_a(t.id),width:n.width,height:n.height});continue}let n=s.get(t.id);if(!n)continue;let r;if(e.groupBounds.has(n.id)&&Fi(n)){let t=e.groupBounds.get(n.id);c.push({groupId:n.id,width:t.width,height:t.height,column:n.column,row:n.row,colSpan:n.colSpan??n.span,rowSpan:n.rowSpan});continue}let i=n.cellArrange??`flow`,a=ha(n.gap,e.options);r=i===`pack`||i===`stack`?Sa(n.nodeIds,e.measureMap,i,e.options.density,a):await Oa(e.graph,n,e.measured,e.options,o),l.set(n.id,r);let u=cr(n),d=Ea(r.values())??{x:0,y:0,width:80,height:40},f=d.width+u.left+u.right,p=d.height+u.top+u.bottom;c.push({groupId:n.id,width:f,height:p,column:n.column,row:n.row,colSpan:n.colSpan??n.span,rowSpan:n.rowSpan})}let u=ji({arrange:n,align:a,gap:ga(t?.gap??e.options.gap,e.options),columns:t?.columns??e.options.columns,rows:t?.rows??e.options.rows,cells:c,origin:{x:64,y:64}});for(let t of u){let n=va(t.groupId);if(n){let r=e.measureMap.get(n);if(r){let i={x:0,y:0,width:r.width,height:r.height},o=ka(t.bounds,{top:0,right:0,bottom:0,left:0},i,a);e.nodeBounds.set(n,{x:o.x,y:o.y,width:r.width,height:r.height})}else e.nodeBounds.set(n,{...t.bounds});continue}let r=s.get(t.groupId);if(!r)continue;let i=cr(r),o=l.get(r.id);if(o){e.groupBounds.set(r.id,t.bounds);let n=Ea(o.values())??{x:0,y:0,width:0,height:0},s=ka(t.bounds,i,n,a);for(let[t,r]of o)e.nodeBounds.set(t,{x:s.x+(r.x-n.x),y:s.y+(r.y-n.y),width:r.width,height:r.height})}else if(Fi(r)){let n=e.groupBounds.get(r.id);if(n){let i=t.bounds.x-n.x,a=t.bounds.y-n.y;if(e.groupBounds.set(r.id,t.bounds),i!==0||a!==0){for(let t of Aa(e.graph,r.id)){let n=e.nodeBounds.get(t);n&&e.nodeBounds.set(t,{...n,x:n.x+i,y:n.y+a})}let t=[...r.childGroupIds];for(;t.length;){let n=t.pop(),r=e.groupBounds.get(n);r&&e.groupBounds.set(n,{...r,x:r.x+i,y:r.y+a});let o=e.graph.groups.find(e=>e.id===n);o&&t.push(...o.childGroupIds)}}}else e.groupBounds.set(r.id,t.bounds)}else e.groupBounds.set(r.id,t.bounds)}if(t){let n=Ea(u.map(e=>e.bounds));if(n){let r=cr(t),i={x:n.x-r.left,y:n.y-r.top,width:n.width+r.left+r.right,height:n.height+r.top+r.bottom};dr(t.shape)&&(i=ur(i)),e.groupBounds.set(t.id,i)}}}function Ia(e,t,n,r,i,a,o,s,c){let l=aa(r,i,a,o,s,c),u=l[0],d=l[l.length-1],f=l.slice(1,-1);return{id:e,sources:[t],targets:[n],sections:[{id:`${e}_s0`,startPoint:{x:u.x,y:u.y},endPoint:{x:d.x,y:d.y},bendPoints:f}]}}function La(e,t){return t<=1?.5:.28+.44*e/(t-1)}function Ra(e,t){return Zi(e,t)[0]}function za(e,t){return Zi(e,t)[1]}function Ba(e,t,n){let r=t.x+t.width/2,i=t.y+t.height/2;return n===`N`||n===`S`?r-e.x:i-e.y}function Va(e,t){return!(e.x+e.width<t.x||t.x+t.width<e.x||e.y+e.height<t.y||t.y+t.height<e.y)}function Ha(e,t){let[n]=Zi(e,t);if(n===`E`||n===`W`){let r=n===`E`?e.x+e.width:t.x+t.width,i=n===`E`?t.x:e.x;if(i<=r+1)return null;let a=Math.min(e.y,t.y),o=Math.max(e.y+e.height,t.y+t.height);return{x:r,y:a,width:i-r,height:Math.max(1,o-a)}}let r=n===`S`?e.y+e.height:t.y+t.height,i=n===`S`?t.y:e.y;if(i<=r+1)return null;let a=Math.min(e.x,t.x),o=Math.max(e.x+e.width,t.x+t.width);return{x:a,y:r,width:Math.max(1,o-a),height:i-r}}function Ua(e,t){let n=new Map,r=new Map,i=new Map,a=new Map;for(let n of e){let e=t.get(n.from),r=t.get(n.to),o=Ra(e,r),s=za(e,r),c=`${n.from}:${o}`,l=`${n.to}:${s}`;i.has(c)||i.set(c,[]),a.has(l)||a.set(l,[]),i.get(c).push({edgeId:n.id,key:Ba(e,r,o)}),a.get(l).push({edgeId:n.id,key:Ba(r,e,s)})}for(let e of i.values())e.sort((e,t)=>e.key-t.key),e.forEach((t,r)=>n.set(t.edgeId,La(r,e.length)));for(let e of a.values())e.sort((e,t)=>e.key-t.key),e.forEach((t,n)=>r.set(t.edgeId,La(n,e.length)));return{tFrom:n,tTo:r}}function Wa(e,t,n,r){let i=[];for(let n of e.nodes){let e=t.get(n.id);e&&i.push({id:n.id,x:e.x,y:e.y,width:e.width,height:e.height})}let a=Math.max(28,r.edgeNodeSpacing??28),o=Math.min(12,a),s=e.edges.filter(e=>t.has(e.from)&&t.has(e.to)),{tFrom:c,tTo:l}=Ua(s,t),u=new Map,d=t=>{let n=u.get(t);return n||(n=new Set(Aa(e,t)),u.set(t,n)),n},f=t=>{let n=new Set([t]),r=[t];for(;r.length;){let t=r.pop(),i=e.groups.find(e=>e.id===t);if(i)for(let e of i.childGroupIds)n.has(e)||(n.add(e),r.push(e))}return n},p=(t,n)=>{let r=new Set;for(let i of e.groups){let e=d(i.id);if(e.has(t)&&!e.has(n))for(let e of f(i.id))r.add(e)}return r},m=s.map(e=>{let r=t.get(e.from),i=t.get(e.to),a=[];for(let[n,r]of t)n!==e.from&&n!==e.to&&a.push(r);let s=Ha(r,i);if(s){let t=new Set([...p(e.from,e.to),...p(e.to,e.from)]);for(let[r,i]of n){if(t.has(r))continue;let n=d(r);n.has(e.from)||n.has(e.to)||Va(i,s)&&a.push(i)}}return Ia(e.id,e.from,e.to,r,i,a,o,c.get(e.id)??.5,l.get(e.id)??.5)});return{id:`root`,layoutOptions:{"elk.algorithm":`fixed`,"elk.edgeRouting":`ORTHOGONAL`,"elk.direction":r.direction===`TD`?`DOWN`:r.direction===`BT`?`UP`:r.direction===`RL`?`LEFT`:`RIGHT`,"elk.spacing.nodeNode":`40`,"elk.spacing.edgeNode":String(a),"elk.spacing.edgeEdge":String(r.edgeEdgeSpacing??18),"elk.padding":`[top=64,left=64,bottom=64,right=64]`},children:i,edges:m}}async function Ga(e,t,n){let r=performance.now(),i=n.direction??`LR`,a=new Map(t.map(e=>[e.nodeId,e])),o={graph:e,measured:t,measureMap:a,options:n,nodeBounds:new Map,groupBounds:new Map};if(n.arrange)await Fa(o,null);else{let t=e.groups.filter(e=>Fi(e)).filter(t=>{if(!t.parentId)return!0;let n=e.groups.find(e=>e.id===t.parentId);return!n||!Fi(n)});for(let e of t)await Fa(o,e)}let s=new Set(o.nodeBounds.keys()),c=e.nodes.filter(e=>!s.has(e.id)).map(e=>e.id);if(c.length){let t=new Set(c),r=[],s=[],l=[];for(let n of c){let i=e.edges.some(e=>e.from===n&&!t.has(e.to)),a=e.edges.some(e=>e.to===n&&!t.has(e.from));i&&!a?r.push(n):a&&!i?s.push(n):l.push(n)}let u=(t,r)=>{if(t.length===0)return;let s=i===`TD`||i===`BT`?`pack`:`stack`,c=ha(void 0,n),l=new Map,u=0;for(let r of Ca(e,t)){let t=wa(e,r,s),i=Sa(r,a,t,n.density,c);Ta(e,r,i);let o=Ea(i.values())??{x:0,y:0,width:80,height:40};for(let[e,t]of i)s===`stack`?l.set(e,{...t,x:t.x-o.x,y:t.y-o.y+u}):l.set(e,{...t,x:t.x-o.x+u,y:t.y-o.y});u+=(s===`stack`?o.height:o.width)+c}let d=Ea(l.values())??{x:0,y:0,width:80,height:40},f=Ea(o.nodeBounds.values()),p=64,m=64;f&&(i===`TD`||i===`BT`?(p=f.x+(f.width-d.width)/2,m=r===`before`?f.y-d.height-Ka:f.y+f.height+Ka):(p=r===`before`?f.x-d.width-Ka:f.x+f.width+Ka,m=f.y+(f.height-d.height)/2));for(let[e,t]of l)o.nodeBounds.set(e,{...t,x:t.x-d.x+p,y:t.y-d.y+m})};u(r,`before`),u([...s,...l],`after`);let d=Ea(o.nodeBounds.values());if(d&&(d.x<64||d.y<64)){let e=Math.max(0,64-d.x),t=Math.max(0,64-d.y);if(e||t){for(let[n,r]of o.nodeBounds)o.nodeBounds.set(n,{...r,x:r.x+e,y:r.y+t});for(let[n,r]of o.groupBounds)o.groupBounds.set(n,{...r,x:r.x+e,y:r.y+t})}}}let l=Wa(e,o.nodeBounds,o.groupBounds,{...n,direction:i}),u=await mi().layout(l),d=xa([...o.nodeBounds.entries()].map(([e,t])=>({nodeId:e,bounds:t,rank:0,order:0})),i),f=[];for(let t of e.groups){let e=o.groupBounds.get(t.id);if(!e)continue;let n=cr(t);f.push({groupId:t.id,bounds:e,labelBox:pr(t.label,e,!!(t.icon&&t.icon!==`none`&&t.chrome!==!1)),padding:n})}let{nodes:p,groups:m,shiftX:h}=Or(e,d,f),g=[];for(let e of u.edges??[]){let t=[];for(let n of e.sections??[]){t.push({...n.startPoint});for(let e of n.bendPoints??[])t.push({...e});t.push({...n.endPoint})}t.length>=2&&g.push({edgeId:e.id,points:t})}let _=e=>{for(let t of e.edges??[]){if(g.some(e=>e.edgeId===t.id))continue;let n=[];for(let r of t.sections??[]){n.push({x:(r.startPoint.x??0)+(e.x??0),y:(r.startPoint.y??0)+(e.y??0)});for(let t of r.bendPoints??[])n.push({x:t.x+(e.x??0),y:t.y+(e.y??0)});n.push({x:(r.endPoint.x??0)+(e.x??0),y:(r.endPoint.y??0)+(e.y??0)})}n.length>=2&&g.push({edgeId:t.id,points:n})}for(let t of e.children??[])_(t)};if(_(u),h!==0)for(let e of g)e.points=e.points.map(e=>({...e,x:e.x+h}));let v=wi(e,p,g).map(e=>({...e,points:ni(Qr(e.points))})),y=[],b=0,x=0;for(let e of p)b=Math.max(b,e.bounds.x+e.bounds.width),x=Math.max(x,e.bounds.y+e.bounds.height);for(let e of m)b=Math.max(b,e.bounds.x+e.bounds.width),x=Math.max(x,e.bounds.y+e.bounds.height);for(let e of v)for(let t of e.points)b=Math.max(b,t.x),x=Math.max(x,t.y);return{layout:{nodes:p,groups:m,edgePaths:v,edgeLabels:y,direction:i,algorithmVersion:hi,layoutMs:performance.now()-r,width:b+8,height:x+8},edges:v,routerAlgorithm:gi}}var Ka=48,qa=`sequence-v1`,Ja=`sequence-direct-v1`,Ya=26,Xa=40,Za=50,Qa=16,$a=20,eo=8,to=18,no=12,ro=8,io=40,ao=20,oo=28,so=15,co=10,lo=34,uo=26,fo=176,po=176,mo={fontSize:11,fontFamily:q,fontWeight:`700`},ho={fontSize:11,fontFamily:q,fontWeight:`500`},go={fontSize:10,fontFamily:q,fontWeight:`700`},_o={fontSize:11,fontFamily:q,fontWeight:`700`},vo={fontSize:11,fontFamily:q,fontWeight:`600`},yo=.6,bo=.11,xo=14,So=10,Co={fontSize:10,fontFamily:q,fontWeight:`500`},wo=14,To=3,Eo=10,Do=8,Oo=209;function ko(e){return e===`compact`?.88:e===`spacious`?1.18:1}function Ao(e,t){let n=kn.measureText(e,mo).width;return{width:Math.ceil(n+(t?20:0)+16),height:$a}}function jo(e,t,n,r){let i=Ao(n,r),a=kn.measureText(n,mo).width,o=t-Qa,s={x:e-i.width/2,y:o-14,width:i.width,height:i.height};return{bounds:s,center:{x:s.x+eo+(r?20:0)+a/2,y:o}}}function Mo(e,t){let n=Math.max(48,t-20),r=kn.wrapText(e,{maxWidth:n,style:ho}),i=r.lines.length?r.lines:[e];return{lines:i,width:Math.max(t,Math.ceil(r.width+20)),height:i.length*so+18}}function No(e){let t=kn.measureText(e,go).width+e.length*yo;return Math.ceil(t+16+9)}function Po(e){let t=`[${e}]`,n=kn.measureText(t,_o).width+t.length*bo;return Math.ceil(n)}function Fo(e){return kn.measureText(e,Co).width}function Io(e){if(Fo(e)<=Oo)return[e];let t=[],n=e;for(;n.length>0;){if(Fo(n)<=Oo){t.push(n);break}let e=1;for(let t=1;t<=n.length;t++){if(Fo(n.slice(0,t))>Oo){e=Math.max(1,t-1);break}e=t}let r=n.lastIndexOf(` `,e);r>0?(t.push(n.slice(0,r)),n=n.slice(r+1)):(t.push(n.slice(0,e)),n=n.slice(e))}return t.length>0?t:[e]}function Lo(e){let t=e.replace(/\r\n/g,`
|
|
2
|
+
`).trim();if(!t)return;let n=t.split(`
|
|
3
|
+
`).flatMap(e=>Io(e)),r=n.length>6?[...n.slice(0,5),`…`]:n,i=Math.max(0,...r.map(e=>Fo(e)));return{lines:r,width:Math.ceil(i+20+To),height:16+r.length*wo}}function Ro(e,t,n,r){let i=n-12,a=n+3,o=r.filter(e=>e.bounds.y<a&&e.bounds.y+e.bounds.height>i).map(e=>e.bounds).sort((e,t)=>e.x-t.x),s=e;for(let e=0;e<o.length;e++){let e=!1;for(let n of o)s+t<=n.x-4||s>=n.x+n.width+4||(s=n.x+n.width+6,e=!0);if(!e)break}return s}function zo(e,t){if(e.placement===`over`){let n=e.participantIds.map(e=>t.get(e)).filter(e=>e!=null);return n.length>=2?Math.max(160,Math.max(...n)-Math.min(...n)+36):200}return e.placement===`left`?fo:po}function Bo(e,t,n,r,i,a){let o=[...e.messages.map(e=>e.order),...e.notes.map(e=>e.order),...e.dividers.map(e=>e.order),...e.activations.map(e=>e.endOrder),...e.activations.map(e=>e.startOrder)],s=e=>{for(let t of e){o.push(t.startOrder,t.endOrder);for(let e of t.operands)s(e.children)}};s(e.fragments);let c=Math.max(0,...o),l=new Set(e.notes.map(e=>e.order)),u=new Set(e.dividers.map(e=>e.order)),d=new Set(e.messages.filter(e=>e.from&&e.to&&e.from===e.to&&e.kind!==`destroy`).map(e=>e.order)),f=new Set,p=new Set,m=new Set,h=e=>{for(let t of e){f.add(t.startOrder),p.add(t.endOrder);for(let e=1;e<t.operands.length;e++)m.add(t.operands[e].startOrder);for(let e of t.operands)h(e.children)}};h(e.fragments);let g=new Map,_=new Map,v=new Map,y=t;for(let e=0;e<=c;e++){let t=0,o=n,s=0;f.has(e)&&(t+=32),m.has(e)&&(t+=12),l.has(e)&&(o=Math.max(o,(r.get(e)??48)+co)),u.has(e)&&(o=Math.max(o,lo)),d.has(e)&&(o=Math.max(o,n+12));let c=i.get(e);c&&(o=Math.max(o,c+16)),p.has(e)&&(s+=10),s+=a.get(e)??0;let h=y,b=y+t+o/2,x=y+t+o+s;_.set(e,h),g.set(e,b),v.set(e,x),y=x}let b=e=>t+e*n;return{yAt:e=>g.get(e)??b(e)+n/2,bandTop:e=>_.get(e)??b(e),bandBottom:e=>v.get(e)??b(e)+n,bottomY:y}}function Vo(e){let t=new Map;for(let n of e){let e=t.get(n.participantId)??[];e.push(n),t.set(n.participantId,e)}let n=new Map;for(let e of t.values()){let t=[...e].sort((e,t)=>e.startOrder-t.startOrder||t.endOrder-e.endOrder||e.id.localeCompare(t.id)),r=[];for(let e of t){for(;r.length&&r[r.length-1].endOrder<e.startOrder;)r.pop();n.set(e.id,r.length),r.push(e)}}return n}function Ho(e,t,n,r){let i=e.participantOrder,a=i.map(e=>t.get(e)?.width??120),o=i.map(e=>t.get(e)?.height??44),s=new Map(i.map((e,t)=>[e,t])),c=Array.from({length:Math.max(0,i.length-1)},()=>0),l=(e,t)=>{let r=0;for(let i=e;i<t;i++)r+=a[i]/2+a[i+1]/2+n+c[i];return r},u=(e,t,n)=>{let r=Math.min(e,t),i=Math.max(e,t);if(i===r)return;let a=l(r,i);if(a>=n)return;let o=(n-a)/(i-r);for(let e=r;e<i;e++)c[e]=(c[e]??0)+o};for(let t of e.messages){if(!t.label||!t.from||!t.to||t.from===t.to||t.kind===`destroy`||t.kind===`create`)continue;let e=s.get(t.from),n=s.get(t.to);e!=null&&n!=null&&u(e,n,Ao(t.label,r).width+32)}for(let t of e.messages){if(!t.from||t.from!==t.to||t.kind===`destroy`)continue;let e=s.get(t.from);if(e==null||e>=i.length-1)continue;let o=30+(t.label?Ao(t.label,r).width:0)/2,l=a[e]/2+n+c[e];l<o&&(c[e]=c[e]+(o-l))}let d=oo+(e.notes.some(e=>e.placement===`left`)?212:to),f=[];for(let e=0;e<i.length;e++){let t=a[e],r=o[e];f.push({id:i[e],x:d,width:t,height:r}),e<i.length-1&&(d+=t+n+c[e])}return f}function Uo(e,t,n){let r=new Set,i=t=>{t&&e.participantOrder.includes(t)&&r.add(t)};for(let r of e.messages)r.order<t||r.order>n||(i(r.from),i(r.to));for(let r of e.notes)if(!(r.order<t||r.order>n))for(let e of r.participantIds)i(e);if(r.size===0)return[...e.participantOrder];let a=[...r].map(t=>e.participantOrder.indexOf(t)),o=Math.min(...a),s=Math.max(...a);return e.participantOrder.slice(o,s+1)}function Wo(e,t,n={}){let i=performance.now(),a=e.sequence;if(!a||a.participantOrder.length===0)return Go(i);let o=ko(n.density),s=Za*o,c=Xa*o,l=Ho(a,new Map(t.map(e=>[e.nodeId,e])),c,a.autonumber),u=new Map(l.map(e=>[e.id,e.x+e.width/2])),d=new Map(l.map(e=>[e.id,e])),f=l.map((e,t)=>({nodeId:e.id,bounds:{x:e.x,y:oo,width:e.width,height:e.height},rank:0,order:t})),p=new Map(f.map(e=>[e.nodeId,e])),m=new Map,h=new Map;for(let e of a.messages)e.kind===`create`&&e.to&&!m.has(e.to)&&m.set(e.to,e),e.kind===`destroy`&&e.from&&h.set(e.from,e);let g=new Map,_=new Map;for(let e of a.notes){let t=Mo(e.text,zo(e,u));_.set(e.id,t),g.set(e.order,Math.max(g.get(e.order)??0,t.height))}let v=new Map;for(let e of m.values()){let t=d.get(e.to);t&&v.set(e.order,t.height)}let y=new Map,b=new Map;for(let e of a.messages){if(!e.payload||e.kind===`destroy`||e.kind===`create`)continue;let t=Lo(e.payload);if(!t)continue;y.set(e.id,t);let n=(e.from&&e.to&&e.from===e.to?ao*.7:0)+Eo;b.set(e.order,n+t.height+Do)}let x=oo+Math.max(44,...l.map(e=>e.height))+Ya*o,{yAt:S,bandTop:ee,bandBottom:C,bottomY:w}=Bo(a,x,s,g,v,b);for(let[e,t]of m){let n=p.get(e);if(!n)continue;let r=S(t.order);n.bounds={...n.bounds,y:r-n.bounds.height/2}}let T=Vo(a.activations),E=w+16,D=[];for(let e of l){let t=p.get(e.id),n=h.get(e.id),r=n?S(n.order)-10:E;D.push({participantId:e.id,x:u.get(e.id),y0:t.bounds.y+t.bounds.height,y1:Math.max(t.bounds.y+t.bounds.height+8,r)})}let O=new Map(D.map(e=>[e.participantId,e])),k=a.activations.map(e=>{let t=u.get(e.participantId)??oo,n=T.get(e.id)??0,r=O.get(e.participantId),i=S(e.startOrder)-7,a=S(e.endOrder)+7,o=Math.max(Math.min(i,a),r?.y0??i),s=Math.min(Math.max(i,a,o+10),r?.y1??a);return{id:e.id,participantId:e.participantId,startOrder:e.startOrder,endOrder:e.endOrder,bounds:{x:t-no/2+n*ro,y:o,width:no,height:Math.max(10,s-o)}}}),A=(e,t,n)=>{let r=k.filter(n=>n.participantId===e&&n.startOrder<=t&&n.endOrder>=t);if(n===`leave`){let e=r.filter(e=>e.startOrder<t);if(e.length)return e.reduce((e,t)=>(T.get(e.id)??0)>=(T.get(t.id)??0)?e:t)}if(r.length)return r.reduce((e,t)=>(T.get(e.id)??0)>=(T.get(t.id)??0)?e:t)},j=(e,t,n,r)=>{let i=A(e,t,r),a=u.get(e);return i?n===`right`?i.bounds.x+i.bounds.width:i.bounds.x:a},M=[],N=[],te=0;for(let e of a.messages){a.autonumber&&e.kind!==`destroy`&&(te+=1);let t=S(e.order),n=a.autonumber&&e.kind!==`destroy`?te:void 0,r,i,o,s=t;if(e.kind===`destroy`){let n=u.get(e.from)??oo;r=[{x:n-7,y:t-7},{x:n+7,y:t+7},{x:n+7,y:t-7},{x:n-7,y:t+7}]}else if(e.kind===`create`&&e.to&&p.has(e.to)){let t=p.get(e.to).bounds,n=t.y+t.height/2,a=e.from?u.get(e.from):void 0,c=a==null||t.x+t.width/2>=a,l=e.from&&u.has(e.from)?j(e.from,e.order,c?`right`:`left`,`leave`):t.x-42,d=c?t.x:t.x+t.width;r=[{x:l,y:n},{x:d,y:n}],e.from||(i=r[0],o=`start`),s=n}else if(e.from&&e.to&&e.from===e.to&&u.has(e.from)){let n=j(e.from,e.order,`right`,`leave`),i=A(e.from,e.order,`arrive`),a=i?i.bounds.x+i.bounds.width:n,o=Math.max(n,a)+io,c=t-ao*.45,l=t+ao*.7;r=[{x:n,y:c},{x:o,y:c},{x:o,y:l},{x:a,y:l}],s=c}else if(e.kind===`found`||!e.from&&e.to&&u.has(e.to)){let n=j(e.to,e.order,`left`,`arrive`),s=e.label?Ao(e.label,a.autonumber).width:0,c={x:n-Math.max(64,s+30),y:t};r=[c,{x:n,y:t}],i=c,o=`start`}else if(e.kind===`lost`||e.from&&!e.to&&u.has(e.from)){let n=j(e.from,e.order,`right`,`leave`),s=e.label?Ao(e.label,a.autonumber).width:0,c={x:n+Math.max(64,s+30),y:t};r=[{x:n,y:t},c],i=c,o=`end`}else{let n=e.from&&u.has(e.from)?e.from:null,i=e.to&&u.has(e.to)?e.to:null,a=n?u.get(n):oo,o=i?u.get(i):a+48,s=o>=a,c=n?j(n,e.order,s?`right`:`left`,`leave`):o-42,l=i?j(i,e.order,s?`left`:`right`,`arrive`):a+42;r=[{x:c,y:t},{x:l,y:t}],(s&&l-c<16||!s&&c-l<16)&&(r=[{x:a,y:t},{x:o,y:t}])}let c=!!e.label&&e.kind!==`destroy`&&e.kind!==`create`,l,d,f=r[0],m=r[Math.min(1,r.length-1)],h=r.length===4?(r[0].x+r[1].x)/2:(f.x+m.x)/2;if(c&&e.label){let t=jo(h,s,e.label,n!=null);l=t.center,d=t.bounds}let g=y.get(e.id),_,v;if(g){let e=r.length>=4?Math.max(...r.map(e=>e.y)):f.y;_=g.lines,v={x:Math.max(8,h-g.width/2),y:e+Eo,width:g.width,height:g.height}}M.push({messageId:e.id,kind:e.kind,points:r,label:c?e.label:e.kind===`create`?void 0:e.label,labelCenter:l,labelBounds:d,payloadLines:_,payloadBounds:v,number:n,endpoint:i,endpointAt:o}),e.from&&e.to&&e.from!==e.to&&e.kind!==`destroy`&&N.push({edgeId:e.id,points:r})}for(let e of k){if(e.startOrder!==e.endOrder)continue;let t=M.find(t=>{let n=a.messages.find(e=>e.id===t.messageId);return n?.order===e.startOrder&&n.from===e.participantId&&n.to===e.participantId});if(!t||t.points.length<4)continue;let n=t.points.map(e=>e.y),r=Math.min(...n)-3,i=Math.max(...n)+3;e.bounds={...e.bounds,y:r,height:Math.max(10,i-r)}}let P=a.notes.map(e=>{let t=_.get(e.id)??Mo(e.text,176),n=S(e.order),r=e.participantIds.filter(e=>u.has(e)),i;if(e.placement===`over`&&r.length){let a=r.map(e=>u.get(e)),o=Math.max(...a)-Math.min(...a),s=Math.max(t.width,o+36);return i=(Math.min(...a)+Math.max(...a))/2-s/2,{id:e.id,text:e.text,lines:t.lines,bounds:{x:i,y:n-t.height/2,width:s,height:t.height}}}let a=u.get(r[0]??``)??108;return i=e.placement===`left`?a-28-t.width:a+28,{id:e.id,text:e.text,lines:t.lines,bounds:{x:i,y:n-t.height/2,width:t.width,height:t.height}}}),ne=new Map(a.notes.map(e=>[e.id,e.order])),re=new Map(a.messages.map(e=>[e.id,e.order])),F=(e,t)=>{let n=e.operands.flatMap(e=>e.children.flatMap(e=>F(e,t+1))),i=Uo(a,e.startOrder,e.endOrder).map(e=>p.get(e)?.bounds).filter(e=>e!=null),o=i.length?i:l.map(e=>p.get(e.id).bounds),s=Math.min(...o.map(e=>e.x))-to,c=Math.max(...o.map(e=>e.x+e.width))+to,u=r(e.operator),d=No(u),f=d+xo;e.label&&(f=d+So+Po(e.label)+xo);for(let t of e.operands.slice(1))t.label&&(f=Math.max(f,12+Po(t.label)+xo));let m=t*12,h=s+m,g=c-m;g-h<f&&(h=s,g=Math.max(c,h+f));let _=(e,t)=>{h=Math.min(h,e),g=Math.max(g,t)};for(let t of P){let n=ne.get(t.id);n==null||n<e.startOrder||n>e.endOrder||_(t.bounds.x-10,t.bounds.x+t.bounds.width+10)}for(let t of M){let n=re.get(t.messageId);if(!(n==null||n<e.startOrder||n>e.endOrder)){for(let e of t.points)_(e.x-8,e.x+8);t.endpoint&&_(t.endpoint.x-10,t.endpoint.x+10),t.labelBounds&&_(t.labelBounds.x-6,t.labelBounds.x+t.labelBounds.width+6),t.payloadBounds&&_(t.payloadBounds.x-8,t.payloadBounds.x+t.payloadBounds.width+8)}}for(let e of n)_(e.bounds.x-6,e.bounds.x+e.bounds.width+6);g-h<f&&(g=h+f);let v=ee(e.startOrder)+2,y=C(e.endOrder)-2,b=v+14,x=h+d+So;if(e.label){let t=Po(e.label);x=Ro(x,t,b,k),g=Math.max(g,x+t+xo)}let S=[],w=[];for(let t=1;t<e.operands.length;t++){let n=e.operands[t];if(!n.label)continue;let r=ee(n.startOrder)+16,i=Po(n.label),a=Ro(h+12,i,r,k);w.push({text:n.label,x:a,y:r}),g=Math.max(g,a+i+xo)}let T=[];for(let t=0;t<e.operands.length;t++){let n=e.operands[t],r=t===0?v:ee(n.startOrder),i=t===e.operands.length-1?y:ee(e.operands[t+1].startOrder);T.push({startOrder:n.startOrder,endOrder:n.endOrder,styleRefs:n.styleRefs,bounds:{x:h,y:r,width:g-h,height:Math.max(8,i-r)}}),t>0&&S.push(r)}return[{id:e.id,operator:e.operator,label:e.label,styleRefs:e.styleRefs,unresolvedVars:e.unresolvedVars,bounds:{x:h,y:v,width:Math.max(24,g-h),height:Math.max(28,y-v)},startOrder:e.startOrder,endOrder:e.endOrder,separators:S,operandLabels:w,tab:{x:h,y:v,width:d,height:20},operatorLabel:u,guard:e.label?{text:e.label,x,y:b}:void 0,operandBands:T},...n]},I=a.fragments.flatMap(e=>F(e,0));for(let e of M){if(!e.labelBounds||!e.labelCenter)continue;let t=e.labelBounds,n=e.labelCenter;for(let e of I){if(!ye(t,e.tab,2))continue;let r=e.tab.x+e.tab.width+8-t.x;r>0&&(t={...t,x:t.x+r},n={...n,x:n.x+r})}e.labelBounds=t,e.labelCenter=n}for(let e of M){if(!e.labelBounds)continue;let t=re.get(e.messageId);if(t==null)continue;let n=e.labelBounds.x+e.labelBounds.width+8;for(let e of I){if(t<e.startOrder||t>e.endOrder||n<=e.bounds.x+e.bounds.width)continue;let r=n-e.bounds.x;e.bounds={...e.bounds,width:r};for(let t of e.operandBands)t.bounds={...t.bounds,width:r}}}for(let e of M){if(!e.payloadBounds)continue;let t=re.get(e.messageId);if(t==null)continue;let n=e.payloadBounds.y+e.payloadBounds.height+8,r=e.payloadBounds.x+e.payloadBounds.width+8;for(let e of I){if(t<e.startOrder||t>e.endOrder)continue;let i=e.bounds.x+e.bounds.width,a=e.bounds.y+e.bounds.height,o=e.bounds.width,s=e.bounds.height;if(r>i&&(o=r-e.bounds.x),n>a&&(s=n-e.bounds.y),o===e.bounds.width&&s===e.bounds.height)continue;let c=s!==e.bounds.height;e.bounds={...e.bounds,width:o,height:s};for(let t of e.operandBands)t.bounds={...t.bounds,width:o};let l=e.operandBands[e.operandBands.length-1];c&&l&&(l.bounds={...l.bounds,height:e.bounds.y+e.bounds.height-l.bounds.y})}}let ie=Math.min(...l.map(e=>e.x)),L=Math.max(...l.map(e=>e.x+e.width)),R=a.dividers.map(e=>{let t=S(e.order),n=e.label,r;if(n){let e=kn.measureText(n,vo).width,i=Math.ceil(e+18);r={x:(ie+L)/2-i/2,y:t-10,width:i,height:20}}return{id:e.id,y:t,x0:ie-8,x1:L+8,label:n,labelBounds:r}}),ae=a.messages.length>=6||E-x>=460,z=[];if(ae)for(let e of l){if(h.has(e.id))continue;let t=p.get(e.id),n={x:t.bounds.x,y:E+uo,width:t.bounds.width,height:t.bounds.height};z.push({participantId:e.id,bounds:n});let r=O.get(e.id);r&&(r.y1=n.y)}let B={lifelines:D,activations:k,fragments:I,notes:P,dividers:R,messages:M,footers:z},oe=L,V=E,se=(e,t)=>{oe=Math.max(oe,e),V=Math.max(V,t)},H=e=>{se(e.x+e.width,e.y+e.height),oe=Math.max(oe,e.x)};for(let e of f)H(e.bounds);for(let e of I)H(e.bounds),H(e.tab);for(let e of P)H(e.bounds);for(let e of z)H(e.bounds);for(let e of M){for(let t of e.points)se(t.x,t.y);e.labelBounds&&H(e.labelBounds),e.payloadBounds&&H(e.payloadBounds),e.endpoint&&se(e.endpoint.x,e.endpoint.y)}for(let e of R)se(e.x0,e.y),se(e.x1,e.y),e.labelBounds&&H(e.labelBounds);return{layout:{nodes:f,groups:[],edgePaths:N,edgeLabels:[],direction:`TD`,algorithmVersion:qa,layoutMs:performance.now()-i,width:oe+oo,height:V+oo,sequence:B},edges:N,routerAlgorithm:Ja}}function Go(e){return{layout:{nodes:[],groups:[],edgePaths:[],edgeLabels:[],direction:`TD`,algorithmVersion:qa,layoutMs:performance.now()-e,width:0,height:0},edges:[],routerAlgorithm:Ja}}function Ko(e){return e.diagramKind===`sequence`||e.sequence!=null}function qo(e,t,n,r,i,a){let o=t+(e.x??0),s=n+(e.y??0),c={x:o,y:s,width:e.width??0,height:e.height??0};a.set(e.id,{bounds:c,parentId:r}),e.id!==`root`&&i.set(e.id,c);for(let t of e.children??[])qo(t,o,s,e.id,i,a)}function Jo(e,t,n){if(!t||!n)return{x:0,y:0};let r=ui(t),i=ui(n),a=new Set,o=r;for(;o;)a.add(o),o=e.get(o)?.parentId??null;for(o=i;o;){if(a.has(o)){let t=e.get(o);return t?{x:t.bounds.x,y:t.bounds.y}:{x:0,y:0}}o=e.get(o)?.parentId??null}return{x:0,y:0}}function Yo(e,t,n,r,i){for(let a of e.edges??[]){if(i.has(a.id))continue;i.add(a.id);let e=Jo(t,a.sources?.[0],a.targets?.[0]),o=Xo(a,e.x,e.y);o.length>=2&&n.push({edgeId:a.id,points:o});for(let t of a.labels??[]){if(t.x==null||t.y==null||!t.width||!t.height)continue;let n={x:e.x+t.x,y:e.y+t.y,width:t.width,height:t.height};r.push({edgeId:a.id,text:t.text,bounds:n,anchor:{x:n.x+n.width/2,y:n.y+n.height/2}})}}for(let a of e.children??[])Yo(a,t,n,r,i)}function Xo(e,t,n){let r=[];for(let i of e.sections??[]){r.push({x:i.startPoint.x+t,y:i.startPoint.y+n});for(let e of i.bendPoints??[])r.push({x:e.x+t,y:e.y+n});r.push({x:i.endPoint.x+t,y:i.endPoint.y+n})}return Zo(r)}function Zo(e){let t=[];for(let n of e){let e=t[t.length-1];e&&Math.abs(e.x-n.x)<.5&&Math.abs(e.y-n.y)<.5||t.push(n)}return t}function Qo(e,t){return t<=1?.5:.28+.44*e/(t-1)}function $o(e,t,n){let r=new Map(t.map(e=>[e.nodeId,e.bounds])),i=e.edges.filter(e=>r.has(e.from)&&r.has(e.to)),a=new Map,o=new Map,s=new Map,c=new Map;for(let e of i){let t=s.get(e.from)??[];t.push(e),s.set(e.from,t);let n=c.get(e.to)??[];n.push(e),c.set(e.to,n)}for(let e of s.values())e.sort((e,t)=>r.get(e.to).x+r.get(e.to).width/2-(r.get(t.to).x+r.get(t.to).width/2)||r.get(e.to).y-r.get(t.to).y),e.forEach((t,n)=>a.set(t.id,Qo(n,e.length)));for(let e of c.values())e.sort((e,t)=>r.get(e.from).x+r.get(e.from).width/2-(r.get(t.from).x+r.get(t.from).width/2)||r.get(e.from).y-r.get(t.from).y),e.forEach((t,n)=>o.set(t.id,Qo(n,e.length)));let l=Math.max(28,n.edgeNodeSpacing??28),u=Math.min(12,l),d=[];for(let e of i){let t=r.get(e.from),n=r.get(e.to),i=[];for(let[t,n]of r)t!==e.from&&t!==e.to&&i.push(n);let s=aa(t,n,i,u,a.get(e.id)??.5,o.get(e.id)??.5);s.length>=2&&d.push({edgeId:e.id,points:s})}return d}function es(e,t){let n=t??`LR`,r=n===`LR`||n===`RL`,i=[...e].sort((e,t)=>{let n=r?e.bounds.x:e.bounds.y,i=r?t.bounds.x:t.bounds.y;return n===i?(r?e.bounds.y:e.bounds.x)-(r?t.bounds.y:t.bounds.x):n-i}),a=new Map,o=0,s=-1/0;for(let e of i){let t=r?e.bounds.x:e.bounds.y;t-s>8&&(s!==-1/0&&(o+=1),s=t),a.set(e.nodeId,o)}let c=new Map;return i.map(e=>{let t=a.get(e.nodeId)??0,n=c.get(t)??0;return c.set(t,n+1),{nodeId:e.nodeId,bounds:e.bounds,rank:t,order:n}})}function ts(e,t,n){let r=mr(e,n),i=new Map(r.map(e=>[e.groupId,e]));for(let n of e.groups){let e=t.get(`group:${n.id}`);if(!e||e.width<=0||e.height<=0)continue;let r=cr(n);i.set(n.id,{groupId:n.id,bounds:e,labelBox:pr(n.label,e,!!(n.icon&&n.icon!==`none`&&n.chrome!==!1)),padding:r})}return[...i.values()]}async function ns(e,t,n={}){if(Ko(e))return Wo(e,t,n);if(ba(e,n))return Ga(e,t,n);let r=performance.now(),i=_r(e,n),a=i.direction??`LR`,o=di(e,t,{...i,direction:a}),s=await mi().layout(o),c=new Map,l=new Map;qo(s,0,0,null,c,l);let u=es(e.nodes.map(e=>{let t=c.get(e.id);return t?{nodeId:e.id,bounds:t}:null}).filter(e=>e!=null),a),d=Or(e,u,ts(e,c,u)),f=es(d.nodes,a),p=d.groups,m=d.shiftX,h=[],g=[];if(gr(e))h=$o(e,f,i);else if(Yo(s,l,h,g,new Set),m!==0){for(let e of h)e.points=e.points.map(e=>({...e,x:e.x+m}));for(let e of g)e.bounds={...e.bounds,x:e.bounds.x+m},e.anchor={...e.anchor,x:e.anchor.x+m}}let _=ri(wi(e,f,h),f.map(e=>e.bounds),Math.max(28,i.edgeNodeSpacing??28)),v=g,y=0,b=0;for(let e of f)y=Math.max(y,e.bounds.x+e.bounds.width),b=Math.max(b,e.bounds.y+e.bounds.height);for(let e of p)y=Math.max(y,e.bounds.x+e.bounds.width),b=Math.max(b,e.bounds.y+e.bounds.height);for(let e of _)for(let t of e.points)y=Math.max(y,t.x),b=Math.max(b,t.y);for(let e of v)y=Math.max(y,e.bounds.x+e.bounds.width),b=Math.max(b,e.bounds.y+e.bounds.height);return{layout:{nodes:f,groups:p,edgePaths:_,edgeLabels:v,direction:a,algorithmVersion:hi,layoutMs:performance.now()-r,width:Math.max(y,s.width??0)+8,height:Math.max(b,s.height??0)+8},edges:_,routerAlgorithm:gi}}var rs=null,is=!1;function as(e){return typeof document>`u`||is?Promise.resolve():rs||(rs=(async()=>{let t=new FontFace(`Inter`,`url(${e})`,{weight:`500`,style:`normal`});await t.load(),document.fonts.add(t),await document.fonts.load(`500 14px "Inter"`),is=!0})(),rs)}var os=18;function ss(e,t,n){let r=new Map(t.nodes.map(e=>[e.nodeId,e])),i=new Map(e.nodes.map(e=>[e.id,e])),a=t.nodes.map(e=>({nodeId:e.nodeId,rect:e.bounds})),o=n.map(t=>{let n=e.edges.find(e=>e.id===t.edgeId);if(!n||!n.fromColumn&&!n.toColumn||t.points.length<2)return{path:t,skip:!0};let a=i.get(n.from),o=i.get(n.to),s=r.get(n.from),c=r.get(n.to);if(!a||!o||!s||!c)return{path:t,skip:!0};let l=cs(a,o,s.bounds,n,!0),u=cs(o,a,c.bounds,n,!1);if(l==null&&u==null)return{path:t,skip:!0};let d=ms(s.bounds,c.bounds,t.points),f=hs(s.bounds,d.fromSide,l??t.points[0].y),p=hs(c.bounds,d.toSide,u??t.points[t.points.length-1].y);return{path:t,skip:!1,start:f,end:p,sides:d,fromId:n.from,toId:n.to,fromBounds:s.bounds,toBounds:c.bounds,fromKey:`${n.from}|${d.fromSide}|${Math.round(f.y)}`,toKey:`${n.to}|${d.toSide}|${Math.round(p.y)}`}});return us(o,`start`),us(o,`end`),o.map(e=>{if(e.skip||!e.start||!e.end||!e.sides||!e.fromBounds||!e.toBounds)return e.path;let t=ds(e.start,e.end,e.path.points,e.sides,e.fromBounds,e.toBounds,a,e.fromId??``,e.toId??``);return{...e.path,points:t}})}function cs(e,t,n,r,i){let a=i?r.fromColumn:r.toColumn;if(!a||!An(e))return;let s=e.scale&&e.scale>0?e.scale:1,c=Nn(e,s),l=ls(e,t,a,i,r),u=[];for(let t of l){let r=o(e.columns,t);r>=0&&u.push(jn(n.y,r,s,c))}if(u.length!==0)return(Math.min(...u)+Math.max(...u))/2}function ls(e,t,n,r,i){if(e.columns?.some(e=>e.name===n&&e.references?.table===t.id))return c(e.columns,t.id,n).map(e=>e.name);let a=r?i.toColumn:i.fromColumn,o=c(t.columns,e.id,a);return o.length>1?[...new Set(o.flatMap(e=>e.references?f(e.references):[]))]:[n]}function us(e,t){let n=new Map;for(let r of e){if(r.skip)continue;let e=t===`start`?r.fromKey:r.toKey;if(!e)continue;let i=n.get(e)??[];i.push(r),n.set(e,i)}for(let e of n.values()){if(e.length<2)continue;e.sort((e,t)=>e.path.edgeId.localeCompare(t.path.edgeId));let n=e.length,r=t===`start`?e[0].start.y:e[0].end.y,i=Math.min(16,5*(n-1));e.forEach((e,a)=>{let o=r-i/2+i*a/(n-1);t===`start`&&e.start&&(e.start={...e.start,y:o}),t===`end`&&e.end&&(e.end={...e.end,y:o})})}}function ds(e,t,n,r,i,a,o,s,c){let l=[gs(e,t,n,r)];if(r.fromSide===r.toSide){let o=r.fromSide===`left`?`right`:`left`;l.push(gs(hs(i,o,e.y),hs(a,o,t.y),n,{fromSide:o,toSide:o}))}else{let r=Math.min(e.x,t.x),u=Math.max(e.x,t.x),d=new Set([(e.x+t.x)/2]);for(let{nodeId:e,rect:t}of o){if(e===s||e===c)continue;let n=t.x-os,i=t.x+t.width+os;n>r&&n<u&&d.add(n),i>r&&i<u&&d.add(i)}for(let n of d)l.push([e,{x:n,y:e.y},{x:n,y:t.y},t]);for(let r of[`left`,`right`])l.push(gs(hs(i,r,e.y),hs(a,r,t.y),n,{fromSide:r,toSide:r}))}for(let n of fs(o,s,c,i,a,e,t))l.push(ps(e,t,r,i,a,n));for(let e of l)if(!_s(e,o,s,c))return e;return l[0]}function fs(e,t,n,r,i,a,o){let s=Math.min(a.x,o.x,r.x,i.x),c=Math.max(a.x,o.x,r.x+r.width,i.x+i.width),l=Math.min(r.y,i.y,a.y,o.y),u=Math.max(r.y+r.height,i.y+i.height,a.y,o.y);for(let{nodeId:r,rect:i}of e)r!==t&&r!==n&&(i.x+i.width<s||i.x>c||(l=Math.min(l,i.y),u=Math.max(u,i.y+i.height)));return[l-os,u+os]}function ps(e,t,n,r,i,a){let o=n.fromSide===`left`?Math.min(e.x,r.x)-os:Math.max(e.x,r.x+r.width)+os,s=n.toSide===`left`?Math.min(t.x,i.x)-os:Math.max(t.x,i.x+i.width)+os;return[e,{x:o,y:e.y},{x:o,y:a},{x:s,y:a},{x:s,y:t.y},t]}function ms(e,t,n){let r=e.x+e.width,i=t.x+t.width,a=t.x-r,o=e.x-i;if(a>0)return{fromSide:`right`,toSide:`left`};if(o>0)return{fromSide:`left`,toSide:`right`};let s=e.x+e.width/2,c=n[0],l=!c||c.x<=s?`left`:`right`;return{fromSide:l,toSide:l}}function hs(e,t,n){return{x:t===`left`?e.x:e.x+e.width,y:n}}function gs(e,t,n,r){if(Math.abs(e.y-t.y)<.5||Math.abs(e.x-t.x)<.5)return[e,t];if(r.fromSide===r.toSide){let n=r.fromSide===`left`?Math.min(e.x,t.x)-os:Math.max(e.x,t.x)+os;return[e,{x:n,y:e.y},{x:n,y:t.y},t]}let i=Math.min(e.x,t.x),a=Math.max(e.x,t.x),o=(e.x+t.x)/2,s=n.slice(1,-1);if(s.length){let e=s.map(e=>e.x).sort((e,t)=>e-t),t=e[Math.floor(e.length/2)];t>=i&&t<=a&&(o=t)}return[e,{x:o,y:e.y},{x:o,y:t.y},t]}function _s(e,t,n,r){let i=new Set([n,r]);for(let n=0;n<e.length-1;n++){let r=e[n],a=e[n+1];for(let{nodeId:e,rect:n}of t)if(!i.has(e)&&vs(r,a,n))return!0}return!1}function vs(e,t,n){let r=n.x,i=n.x+n.width,a=n.y,o=n.y+n.height,s=.75;if(Math.abs(e.y-t.y)<s){let n=e.y;if(n<=a+s||n>=o-s)return!1;let c=Math.min(e.x,t.x),l=Math.max(e.x,t.x);return c<i-s&&l>r+s}if(Math.abs(e.x-t.x)<s){let n=e.x;if(n<=r+s||n>=i-s)return!1;let c=Math.min(e.y,t.y),l=Math.max(e.y,t.y);return c<o-s&&l>a+s}return!1}var ys=.75,bs=6,xs=8,Ss=3.5,Cs=16,ws=12,Ts=.75,Es=.5522847498,Ds={handleMin:28,handleMax:88,handleFactor:.55,filletMax:64,filletMin:14},Os={handleMin:20,handleMax:60,handleFactor:.46,filletMax:36,filletMin:12},ks={handleMin:28,handleMax:104,handleFactor:.58,filletMax:64,filletMin:16};function X(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function As(e,t){let n=X(e,t);return n<1e-6?{x:1,y:0}:{x:(t.x-e.x)/n,y:(t.y-e.y)/n}}function js(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Ms(e,t,n){return{x:e.x+t.x*n,y:e.y+t.y*n}}function Ns(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function Ps(e,t=ys){if(e.length<3)return e.map(e=>({x:e.x,y:e.y}));let n=[{...e[0]}];for(let r=1;r<e.length-1;r++){let i=n[n.length-1],a=e[r],o=e[r+1],s=Math.abs(i.x-a.x)<t&&Math.abs(a.x-o.x)<t,c=Math.abs(i.y-a.y)<t&&Math.abs(a.y-o.y)<t;s||c||n.push({...a})}return n.push({...e[e.length-1]}),n}function Fs(e,t,n){let r=.6,i=n.x+r,a=n.x+n.width-r,o=n.y+r,s=n.y+n.height-r;if(a<=i||s<=o)return!1;let c=t.x-e.x,l=t.y-e.y,u=0,d=1,f=(e,t)=>{if(Math.abs(e)<1e-12)return t>=0;let n=t/e;if(e<0){if(n>d)return!1;n>u&&(u=n)}else{if(n<u)return!1;n<d&&(d=n)}return!0};return!f(-c,e.x-i)||!f(c,a-e.x)||!f(-l,e.y-o)||!f(l,s-e.y)?!1:d>u&&d>.03&&u<.97}function Is(e,t,n){return n.some(n=>Fs(e,t,n))}function Ls(e,t,n=bs){return t.filter(t=>t.id!==e.fromId&&t.id!==e.toId).map(e=>Ns(e.bounds,n))}function Rs(e,t){let n=Ps(e);if(n.length<=2)return n;let r=[{...n[0]}],i=0;for(;i<n.length-1;){let e=i+1;for(let r=n.length-1;r>i+1;r--)if(!Is(n[i],n[r],t)){e=r;break}r.push({...n[e]}),i=e}return Ps(r)}function zs(e,t){let n=1-t,r=t*t,i=n*n;return{x:i*n*e.from.x+3*i*t*e.c1.x+3*n*r*e.c2.x+r*t*e.to.x,y:i*n*e.from.y+3*i*t*e.c1.y+3*n*r*e.c2.y+r*t*e.to.y}}function Bs(e,t=ws){if(!e.length)return[];let n=[{...e[0].from}];for(let r of e)for(let e=1;e<=t;e++)n.push(zs(r,e/t));return n}function Vs(e,t){let n=e.from;for(let r=1;r<Cs;r++){let i=zs(e,r/Cs);if(Is(n,i,t))return!0;n=i}return Is(n,e.to,t)}function Hs(e,t){let n=e===`bezier`?ks:e===`rounded`?Os:Ds;if(t==null||!Number.isFinite(t))return n;let r=Math.max(0,t);return{...n,filletMax:r,filletMin:Math.min(n.filletMin,r),handleMin:Math.max(8,Math.min(n.handleMin,r*.75)),handleMax:Math.max(n.handleMin,Math.min(n.handleMax,Math.max(r*1.4,16)))}}function Z(e,t,n){let r=X(e,t);return Math.max(n.handleMin,Math.min(n.handleMax,r*n.handleFactor))}function Us(e,t,n,r,i){let a=Math.max(1,X(e,t)),o=a*.55,s=Math.min(i,Math.max(22,a*.68)),c=a<48?s:Math.max(o,Math.min(52,i*.7)),l=Math.max(10,Math.min(i,c));return{from:{...e},c1:Ms(e,n,l),c2:Ms(t,r,-l),to:{...t}}}function Ws(e,t,n){let r=Math.abs(e.x-t.x),i=Math.abs(e.x-(t.x+t.width)),a=Math.abs(e.y-t.y),o=Math.abs(e.y-(t.y+t.height)),s=Math.min(r,i,a,o),c=[];return Math.abs(r-s)<Ts&&c.push({x:-1,y:0}),Math.abs(i-s)<Ts&&c.push({x:1,y:0}),Math.abs(a-s)<Ts&&c.push({x:0,y:-1}),Math.abs(o-s)<Ts&&c.push({x:0,y:1}),c.length===1?c[0]:c.find(e=>e.x*n.x+e.y*n.y>.5)??c[0]??n}function Gs(e,t,n,r,i){let a=X(e,t),o=Es;return{from:{...e},c1:Ms(e,r,a*o),c2:Ms(n,i,-a*o),to:{...n}}}function Ks(e,t,n,r,i,a){for(let o of[1,.72,.48,.28]){let s=Us(e,t,n,r,i*o);if(!Vs(s,a))return s}}function qs(e,t,n){let r=e.length,i=e.map((e,i)=>{let a=i===0,o=i===r-1,s=a?.94:o?.88:.6,c=o?.94:a?.88:.6;return Math.max(0,Math.min(n,e*s,t[i]*c))});for(let e=0;e<r-1;e++){let n=t[e]*.96,r=i[e]+i[e+1];if(r>n&&r>1e-6){let t=n/r;i[e]*=t,i[e+1]*=t}}return i}function Js(e,t,n,r,i){let a=e.length-1;if(e.length===2)return[Ks(e[0],e[1],t,n,Z(e[0],e[1],r),i)??Us(e[0],e[1],t,n,Z(e[0],e[1],r))];let o=[],s=[];for(let t=1;t<a;t++)o.push(X(e[t-1],e[t])),s.push(X(e[t],e[t+1]));let c=qs(o,s,r.filletMax),l=[],u=e[0],d=t,f=o.length,p=(e,t,n,a,o,s)=>{let c=Math.min(X(e,t)*.9,X(t,n)*.9),l=Math.min(r.filletMin,c),u=Math.min(Math.max(s,l),c);for(let e=0;e<6;e++){let e=Ms(t,a,-u),n=Ms(t,o,u);if(!Vs(Gs(e,t,n,a,o),i))return{before:e,after:n,r:u};u*=.62}let d=Math.max(l,Math.min(c,r.filletMin));return{before:Ms(t,a,-d),after:Ms(t,o,d),r:d}};for(let t=0;t<f;t++){let o=e[t+1],s=e[t+2],m=As(e[t],o),h=As(o,s),g=t===0,_=t===f-1,{before:v,after:y,r:b}=p(e[t],o,s,m,h,c[t]);if(g&&_){let t=Ks(u,e[a],d,n,Z(u,e[a],r),i);if(t)return[t];let s=X(u,v)>2?Ks(u,v,d,m,Z(u,v,r),i):void 0;s&&l.push(s),l.push(Gs(s?.to??u,o,y,m,h));let c=Ks(y,e[a],h,n,Z(y,e[a],r),i)??Us(y,e[a],h,n,Z(y,e[a],r));return l.push(c),l}if(g){if(f===1){let e=Ks(u,y,d,h,Z(u,y,r),i);if(e){l.push(e),u=y,d=h;continue}}X(u,v)>2&&l.push(Ks(u,v,d,m,Z(u,v,r),i)??Us(u,v,d,m,Math.max(10,b))),l.push(Gs(l[l.length-1]?.to??v,o,y,m,h)),u=y,d=h}else{if(_){if(f===1){let t=Ks(u,e[a],d,n,Z(u,e[a],r),i);if(t)return l.push(t),l}return X(u,v)>2&&l.push(Ks(u,v,d,m,Z(u,v,r),i)??Us(u,v,d,m,Math.max(10,b))),l.push(Gs(l[l.length-1]?.to??v,o,y,m,h)),l.push(Ks(y,e[a],h,n,Z(y,e[a],r),i)??Us(y,e[a],h,n,Z(y,e[a],r))),l}X(u,v)>2&&l.push(Ks(u,v,d,m,Z(u,v,r),i)??Us(u,v,d,m,Math.max(8,X(u,v)*.35))),l.push(Gs(l[l.length-1]?.to??v,o,y,m,h)),u=y,d=h}}return X(u,e[a])>1&&l.push(Ks(u,e[a],d,n,Z(u,e[a],r),i)??Us(u,e[a],d,n,Z(u,e[a],r))),l}function Ys(e,t,n={}){let r=Ps(e);if(r.length<2)return[];let i=Hs(n.mode,n.cornerRadius),a=n.t0??As(r[0],r[1]),o=n.t1??As(r[r.length-2],r[r.length-1]);if(r.length===2)return Js(r,a,o,i,t);let s=Ks(r[0],r[r.length-1],a,o,Z(r[0],r[r.length-1],i),t);return s?[s]:Js(r,a,o,i,t)}function Xs(e){if(!e.length)return``;let t=e[0],n=`M ${t.from.x} ${t.from.y}`;for(let t of e)n+=` C ${t.c1.x} ${t.c1.y} ${t.c2.x} ${t.c2.y} ${t.to.x} ${t.to.y}`;return n}function Zs(e,t,n){let r=As(e,t);return{x:-r.y*n,y:r.x*n}}function Qs(e,t,n,r){let i=X(e,t)||1,a=js(e,t,.5),o=js(n,r,.5),s=As(e,t),c={x:o.x-a.x,y:o.y-a.y},l=Math.abs(-s.y*c.x+s.x*c.y),u=(c.x*s.x+c.y*s.y)/i;return l<Ss&&Math.abs(u)<.35&&Math.abs(X(n,r)-i)/i<.25}function $s(e,t){if(t===`shared`)return e;let n=e.map((e,t)=>({e,index:t})).filter(({e})=>e.points.length===2),r=new Set;for(let{e,index:t}of n){if(r.has(e.edgeId))continue;let i=e.points[0],a=e.points[1],o=[{e,index:t}];for(let t of n)t.e.edgeId===e.edgeId||r.has(t.e.edgeId)||Qs(i,a,t.e.points[0],t.e.points[1])&&o.push(t);if(o.length<2)continue;o.sort((e,t)=>e.e.edgeId.localeCompare(t.e.edgeId));for(let e of o)r.add(e.e.edgeId);let s=o.length;for(let e=0;e<s;e++){let t=o[e],n=t.e.points[0],r=t.e.points[1],i=(e-(s-1)/2)*xs;if(Math.abs(i)<.5)continue;let a=js(n,r,.5),c=Zs(n,r,i);t.e.points=[n,{x:a.x+c.x,y:a.y+c.y},r]}}return e}function ec(e){return e.map(e=>({x:e.x,y:e.y}))}function tc(e,t,n){let r=As(n[0],n[1]),i=As(n[n.length-2],n[n.length-1]),a=t.find(t=>t.id===e.fromId)?.bounds,o=t.find(t=>t.id===e.toId)?.bounds,s=a?Ws(n[0],a,r):r,c=o?Ws(n[n.length-1],o,{x:-i.x,y:-i.y}):{x:-i.x,y:-i.y};return{t0:s,t1:{x:-c.x,y:-c.y}}}function nc(e,t){return t.map(t=>t.id===e.fromId||t.id===e.toId?Ns(t.bounds,0):Ns(t.bounds,bs))}function rc(e){if(e===`rounded`||e===`bezier`||e===`metro`)return e;if(e==null)return`metro`}function ic(e,t,n,r,i){if(n===`orthogonal`)return e.map(e=>({edgeId:e.edgeId,points:ec(e.points)}));if(n===`straight`)return $s(e.map(e=>e.fromId===e.toId||e.points.length<2?{edgeId:e.edgeId,points:ec(e.points)}:{edgeId:e.edgeId,points:Rs(e.points,Ls(e,t))}),r);let a=rc(n)??`metro`;return e.map(e=>{if(e.points.length<2||e.fromId===e.toId)return{edgeId:e.edgeId,points:ec(e.points)};let n=Ps(e.points),{t0:r,t1:o}=tc(e,t,n),s=Ys(n,nc(e,t),{mode:a,t0:r,t1:o,cornerRadius:i}),c=Bs(s);return{edgeId:e.edgeId,points:a===`bezier`&&c.length>=2?c:n,cubics:s}})}var ac=7.5,oc=ze(Se)+.25,sc=ac+oc,cc=new Set([`sync`,`async`,`eventual`,`dependency`,`failure`]);function lc(e,t){if(!t||e==null||!cc.has(e.kind))return{start:!1,end:!1};let n=e.arrows??`end`;return n===`none`?{start:!1,end:!1}:{start:n===`start`||n===`both`,end:n===`end`||n===`both`}}var uc=oc,dc=28,fc=48,pc=24;function mc(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function hc(e){let t=new Set;for(let n=0;n<e.length;n++){let r=0;for(let t=0;t<e.length;t++)n!==t&&mc(e[n].point,e[t].point)<=fc&&r++;r>=1&&t.add(n)}return t}function gc(e,t,n){let r=e.find(e=>e.edgeId===t);if(!r||r.points.length<3)return!1;for(let e=1;e<r.points.length-1;e++)if(mc(r.points[e],n)<=pc)return!0;return!1}function _c(e,t,n,r){return!(n.has(t)||gc(r,e.hop.edgeId,e.point)||gc(r,e.under.edgeId,e.point))}function vc(e){return e.cubics?.length?e.cubics.map(e=>({type:`cubic`,from:e.from,c1:e.c1,c2:e.c2,to:e.to})):e.segments.map(e=>({type:`line`,from:e.from,to:e.to}))}function yc(e,t){if(t===`none`)return e.map(e=>({edgeId:e.edgeId,segments:vc(e)}));let n=[];for(let t of e)t.segments.forEach((e,r)=>n.push({edgeId:t.edgeId,idx:r,from:e.from,to:e.to}));let r=[];for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++){let i=n[e],a=n[t];if(i.edgeId===a.edgeId)continue;let o=bc(i.from,i.to,a.from,a.to);if(!o)continue;let s=Math.abs(i.from.y-i.to.y)<=Math.abs(i.from.x-i.to.x)?i:a,c=s===i?a:i;r.push({hop:s,under:c,point:o})}let i=t===`smart`?hc(r):new Set,a=new Map;return r.forEach((n,r)=>{let o=`${n.hop.edgeId}:${n.hop.idx}`;a.has(o)||a.set(o,[]);let s=t===`jumps`||t!==`gaps`&&_c(n,r,i,e);a.get(o).push({point:n.point,useJump:s})}),e.map(e=>{let t=[];return e.segments.forEach((n,r)=>{let i=`${e.edgeId}:${r}`,o=a.get(i)??[];if(!o.length){t.push({type:`line`,from:n.from,to:n.to});return}let s=Math.hypot(n.to.x-n.from.x,n.to.y-n.from.y)||1,c=o.map(e=>({...e,t:Cc(n.from,n.to,e.point)})).filter(e=>{let t=e.t*s,n=(1-e.t)*s;return t>dc&&n>dc}).sort((e,t)=>e.t-t.t),l=n.from;for(let{point:e,useJump:r}of c){let i=Cc(n.from,n.to,e),a=Math.min(.04,Math.max(.015,8/(Math.hypot(n.to.x-n.from.x,n.to.y-n.from.y)||1))),o=wc(n.from,n.to,Math.max(0,i-a)),s=wc(n.from,n.to,Math.min(1,i+a));t.push({type:`line`,from:l,to:o}),r?t.push({type:`jump`,from:o,to:s,radius:10}):t.push({type:`gap`,from:o,to:s}),l=s}t.push({type:`line`,from:l,to:n.to})}),{edgeId:e.edgeId,segments:t}})}function bc(e,t,n,r){let i=.75,a=Math.abs(e.y-t.y)<i,o=Math.abs(e.x-t.x)<i,s=Math.abs(n.y-r.y)<i,c=Math.abs(n.x-r.x)<i;if(a&&c){let i=(e.y+t.y)/2,a=(n.x+r.x)/2;return Sc(a,e.x,t.x)&&Sc(i,n.y,r.y)?{x:a,y:i}:null}if(o&&s){let i=(e.x+t.x)/2,a=(n.y+r.y)/2;return Sc(a,e.y,t.y)&&Sc(i,n.x,r.x)?{x:i,y:a}:null}let l=(t.x-e.x)*(r.y-n.y)-(t.y-e.y)*(r.x-n.x);if(Math.abs(l)<1e-6)return null;let u=((n.x-e.x)*(r.y-n.y)-(n.y-e.y)*(r.x-n.x))/l,d=((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/l;return u>.02&&u<.98&&d>.02&&d<.98?{x:e.x+u*(t.x-e.x),y:e.y+u*(t.y-e.y)}:null}function xc(e){let t=[];for(let n of e)for(let e of n.segments)t.push({edgeId:n.edgeId,from:e.from,to:e.to});let n=[];for(let e=0;e<t.length;e++)for(let r=e+1;r<t.length;r++){let i=t[e],a=t[r];if(i.edgeId===a.edgeId)continue;let o=bc(i.from,i.to,a.from,a.to);o&&n.push(o)}return n}function Sc(e,t,n,r=1){let i=Math.min(t,n)+r,a=Math.max(t,n)-r;return e>i&&e<a}function Cc(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=r*r+i*i;return a<1e-6?0:((n.x-e.x)*r+(n.y-e.y)*i)/a}function wc(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}var Tc=1.5;function Ec(e,t={}){let n=t.sourceInset??1,r=t.targetInset??1;return e.map(e=>{let t=typeof n==`function`?n(e.edgeId):n,i=typeof r==`function`?r(e.edgeId):r;if(t<=0&&i<=0)return e;let a=e.segments.map(e=>Oc(e));return t>0&&kc(a,`start`,t),i>0&&kc(a,`end`,i),{edgeId:e.edgeId,segments:a}})}function Dc(e){return e.type===`line`||e.type===`cubic`}function Oc(e){return e.type===`line`?{...e,from:{...e.from},to:{...e.to}}:e.type===`cubic`?{...e,from:{...e.from},c1:{...e.c1},c2:{...e.c2},to:{...e.to}}:e}function kc(e,t,n){let r=Ac(e,t);if(r<0)return;let i=e[r];if(i.type===`cubic`){t===`start`?i.from=Rc(i.c1,i.from,n):i.to=Rc(i.c2,i.to,n);return}if(i.type!==`line`)return;let a=jc(e,r,t),o=Mc(e,a.start,a.end);if(o.length<2)return;let s=t===`start`?Lc(o,n):Ic(o,n);Nc(e,a.start,a.end,s)}function Ac(e,t){if(t===`start`)return e.findIndex(Dc);for(let t=e.length-1;t>=0;t--)if(Dc(e[t]))return t;return-1}function jc(e,t,n){let r=t,i=t;if(n===`start`)for(;i+1<e.length&&e[i+1].type===`line`;)i++;else for(;r>0&&e[r-1].type===`line`;)r--;return{start:r,end:i}}function Mc(e,t,n){let r=e[t];if(r.type!==`line`)return[];let i=[{...r.from},{...r.to}];for(let r=t+1;r<=n;r++){let t=e[r];if(t.type!==`line`)break;i.push({...t.to})}return i}function Nc(e,t,n,r){let i=[];for(let e=0;e<r.length-1;e++)i.push({type:`line`,from:r[e],to:r[e+1]});e.splice(t,n-t+1,...i)}function Pc(e,t){let n=e[e.length-2],r=e[e.length-1],i=Math.hypot(r.x-n.x,r.y-n.y);if(i<1e-6)return[{...n},{...r}];let a=Math.min(t,i);return[{...n},{x:n.x+(r.x-n.x)/i*a,y:n.y+(r.y-n.y)/i*a}]}function Fc(e,t){let n=e[0],r=e[1],i=Math.hypot(r.x-n.x,r.y-n.y);if(i<1e-6)return[{...n},{...r}];let a=Math.min(t,i);return[{x:r.x-(r.x-n.x)/i*a,y:r.y-(r.y-n.y)/i*a},{...r}]}function Ic(e,t){let n=e.map(e=>({...e})),r=t;for(;n.length>=2&&r>1e-9;){let e=n[n.length-2],t=n[n.length-1],i=Math.hypot(t.x-e.x,t.y-e.y);if(i<=1e-9)n.pop();else{if(i>r){let a=r/i;n[n.length-1]={x:t.x-(t.x-e.x)*a,y:t.y-(t.y-e.y)*a},r=0;break}r-=i,n.pop()}}return n.length>=2?n:Pc(e,Tc)}function Lc(e,t){let n=e.map(e=>({...e})),r=t;for(;n.length>=2&&r>1e-9;){let e=n[0],t=n[1],i=Math.hypot(t.x-e.x,t.y-e.y);if(i<=1e-9)n.shift();else{if(i>r){let a=r/i;n[0]={x:e.x+(t.x-e.x)*a,y:e.y+(t.y-e.y)*a},r=0;break}r-=i,n.shift()}}return n.length>=2?n:Fc(e,Tc)}function Rc(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=Math.hypot(r,i);if(a<1e-6)return t;let o=Math.min(n,Math.max(0,a-Tc));return{x:t.x-r/a*o,y:t.y-i/a*o}}function Q(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var zc=22,Bc=36;function Vc(e,t={}){if(!e.length)return``;let n=t.route??`metro`,r=Uc(e);if(r.length&&r.length===Hc(e))return Xs(r);let i=Gc(e);if(i.length<2)return r.length?Wc(e):``;if(r.length)return Wc(e);if(n===`bezier`||n===`rounded`||n===`metro`){let e=Ys(i,[],{mode:n,cornerRadius:t.cornerRadius??(n===`metro`?Bc:zc)});if(e.length)return Xs(e)}return qc(i)}function Hc(e){return e.filter(e=>e.type===`line`||e.type===`cubic`).length}function Uc(e){return e.filter(e=>e.type===`cubic`).map(e=>({from:e.from,c1:e.c1,c2:e.c2,to:e.to}))}function Wc(e){let t=``,n;for(let r of e)if(r.type===`gap`)n=void 0;else if(r.type===`jump`){n||(t+=`${t?` `:``}M ${r.from.x} ${r.from.y}`);let e=(r.from.x+r.to.x)/2,i=(r.from.y+r.to.y)/2;t+=` Q ${e} ${i-r.radius} ${r.to.x} ${r.to.y}`,n=r.to}else r.type===`cubic`?((!n||n.x!==r.from.x||n.y!==r.from.y)&&(t+=`${t?` `:``}M ${r.from.x} ${r.from.y}`),t+=` C ${r.c1.x} ${r.c1.y} ${r.c2.x} ${r.c2.y} ${r.to.x} ${r.to.y}`,n=r.to):((!n||n.x!==r.from.x||n.y!==r.from.y)&&(t+=`${t?` `:``}M ${r.from.x} ${r.from.y}`),t+=` L ${r.to.x} ${r.to.y}`,n=r.to);return t.trim()}function Gc(e){let t=[];for(let n of e)if(n.type===`line`)t.length||t.push(n.from),t.push(n.to);else if(n.type===`cubic`)t.length||t.push(n.from),t.push(n.to);else if(n.type===`jump`){t.length||t.push(n.from);let e=(n.from.x+n.to.x)/2,r=(n.from.y+n.to.y)/2;t.push({x:e,y:r-n.radius}),t.push(n.to)}return Kc(t)}function Kc(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.x===n.x&&e.y===n.y||t.push(n)}return t}function qc(e){return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}var Jc=4;function Yc(e,t,n,r=[]){if(!n||!e.length)return e;let i=t.x+Jc,a=t.y+Jc,o=t.x+t.width-Jc,s=t.y+t.height-Jc;return e.map(e=>{let{x:t,y:n}=e.bounds,{width:c,height:l}=e.bounds;if(t<i&&(t=i),n<a&&(n=a),t+c>o&&(t=Math.max(i,o-c)),n+l>s&&(n=Math.max(a,s-l)),r.length){let e=Xc({x:t,y:n,width:c,height:l},r,{minX:i,minY:a,maxX:o,maxY:s});t=e.x,n=e.y}let u=t-e.bounds.x,d=n-e.bounds.y;return u===0&&d===0?e:{...e,bounds:{...e.bounds,x:t,y:n}}})}function Xc(e,t,n){let{x:r,y:i,width:a,height:o}=e;for(let e=0;e<4;e++){let e;for(let n of t)if(ye({x:r,y:i,width:a,height:o},n,0)){e=n;break}if(!e)break;let s=[{x:r,y:e.y-o-Jc},{x:r,y:e.y+e.height+Jc},{x:e.x+e.width+Jc,y:i},{x:e.x-a-Jc,y:i}],c;for(let e of s){let s=e.x,l=e.y;s<n.minX&&(s=n.minX),l<n.minY&&(l=n.minY),s+a>n.maxX&&(s=Math.max(n.minX,n.maxX-a)),l+o>n.maxY&&(l=Math.max(n.minY,n.maxY-o));let u={x:s,y:l,width:a,height:o},d=Math.abs(s-r)+Math.abs(l-i);for(let e of t)ye(u,e,0)&&(d+=1e4);(!c||d<c.score)&&(c={x:s,y:l,score:d})}c&&(r=c.x,i=c.y)}return{x:r,y:i,width:a,height:o}}var Zc=[`#a78bfa`,`#34d399`,`#38bdf8`,`#f472b6`,`#818cf8`,`#e879f9`,`#2dd4bf`,`#60a5fa`];function Qc(e){return Zc[e%Zc.length]}function $c(e,t,n){let r=n.title?36+(n.title.subtitle?20:0)+n.contentPadding.top:n.contentPadding.top,i=n.padding.left+n.contentPadding.left,a=n.padding.top+r+n.contentPadding.top;return{width:n.padding.left+n.contentPadding.left+e+n.contentPadding.right+n.padding.right,height:n.padding.top+r+n.contentPadding.top+t+n.contentPadding.bottom+n.padding.bottom,contentOffsetX:i,contentOffsetY:a,titleAreaHeight:r}}function el(e){return e.title!==!1}function tl(e,t,n){if(!e.title)return``;let{text:r,subtitle:i,align:a}=e.title,o=a===`center`?`50%`:String(t),s=a===`center`?`middle`:`start`,c=n+28,l=`<g class="flow-canvas-title" role="group">`;return l+=`<text class="flow-canvas-title-text" x="${o}" y="${c}" text-anchor="${s}">${Q(r)}</text>`,i&&(l+=`<text class="flow-canvas-subtitle-text" x="${o}" y="${c+22}" text-anchor="${s}">${Q(i)}</text>`),l+=`</g>`,l}function nl(e){let t=e.roles??[];if(t.includes(`partition`))return`◆`;if(t.includes(`sort`))return`↕`;if(t.includes(`reference`))return`↗`;if(t.includes(`materialized`))return`≈`}function rl(e){switch(e){case`PK`:return`flow-table-badge flow-table-badge-pk`;case`FK`:return`flow-table-badge flow-table-badge-fk`;case`UK`:return`flow-table-badge flow-table-badge-uk`;default:return`flow-table-badge`}}function il(e,t,n=1,r=!1,i){let{x:a,y:o,width:s,height:c}=e,l=r?4*n:0,u=i??28*n,d=`kd-table-clip-${t.replace(/[^A-Za-z0-9_-]/g,`_`)}`,f=1.5,p=f/2,m=Math.max(0,l-p),h=``;return h+=`<rect class="flow-table-shell" x="${a}" y="${o}" width="${s}" height="${c}" rx="${l}" fill="var(--kd-table-fill, var(--node-fill, var(--kd-node-fill)))" stroke="none"/>`,h+=`<defs><clipPath id="${d}"><rect x="${a+p}" y="${o+p}" width="${Math.max(0,s-f)}" height="${Math.max(0,c-f)}" rx="${m}"/></clipPath></defs>`,h+=`<rect class="flow-table-header" x="${a}" y="${o}" width="${s}" height="${u}" clip-path="url(#${d})" fill="var(--kd-table-header-fill, var(--kd-surface-2, var(--kd-surface)))"/>`,h+=`<rect class="flow-table-border" x="${a}" y="${o}" width="${s}" height="${c}" rx="${l}" fill="none" stroke="var(--node-stroke, var(--kd-node-stroke))" stroke-width="${f}"/>`,h}function al(e,t,n=!1){let{x:r,y:i,width:a}=t,o=e.scale&&e.scale>0?e.scale:1,s=Nn(e,o),c=20*o,l=10*o,u=43*o,d=18*o,f=3*o,p=6*o,m=n?2*o:0,h=e.columns??[],g=Mn(e),_=``,v=g?i+11*o:i+s/2+.5;if(_+=`<text class="flow-table-title" x="${r+l}" y="${v}" dominant-baseline="middle" font-size="${12*o}">${Q(e.label)}</text>`,g){let t=i+35*o;_+=`<text class="flow-table-note" x="${r+l}" y="${t}" dominant-baseline="middle" font-size="${10*o}">${Q(e.note.trim())}</text>`}return h.forEach((t,n)=>{let h=i+s+n*c;n%2==1&&(_+=`<rect class="flow-table-zebra" x="${r+.5}" y="${h}" width="${a-1}" height="${c}" fill="var(--kd-table-zebra, transparent)"/>`);let g=h+c/2,v=Ln(t),y=r+l;for(let e of v){let t=12*o;_+=`<rect class="${rl(e)}" x="${y}" y="${g-t/2}" width="${d}" height="${t}" rx="${m}"/>`,_+=`<text class="flow-table-badge-text" x="${y+d/2}" y="${g+.5}" text-anchor="middle" dominant-baseline="middle" font-size="${8*o}">${e}</text>`,y+=d+f}let b=(t.depth??0)*14*o,x=r+l+u+b,S=nl(t);S&&(_+=`<text class="flow-doc-mark" x="${r+l+b}" y="${g}" dominant-baseline="middle" font-size="${10*o}">${Q(S)}</text>`);let ee=[`flow-table-col-name`,t.keys.includes(`pk`)?`flow-table-col-pk`:``,t.depth!=null&&t.notNull?`flow-doc-required`:``].filter(Boolean).join(` `);_+=`<text class="${ee}" x="${x}" y="${g}" dominant-baseline="middle" font-size="${11*o}">${Q(t.name)}</text>`;let C=Pn(t),w=Fn(t),T=!!t.notNull&&t.depth==null;if(C||w||T){let i=`kd-table-attrs-${e.id.replace(/[^A-Za-z0-9_-]/g,`_`)}-${n}`,s=x+Math.max(24*o,t.name.length*11*o*.56)+8*o,u=r+a-l,d=Math.max(0,u-s);_+=`<defs><clipPath id="${i}"><rect x="${s}" y="${h}" width="${d}" height="${c}"/></clipPath></defs>`,_+=`<text class="flow-table-col-attrs" clip-path="url(#${i})" x="${u}" y="${g}" text-anchor="end" dominant-baseline="middle" font-size="${10*o}">`;let f=!1;C&&(_+=`<tspan class="flow-table-col-type">${Q(C)}</tspan>`,f=!0),T&&(_+=`<tspan class="flow-table-col-nn"${f?` dx="${p}"`:``}>NN</tspan>`,f=!0),w&&(_+=`<tspan class="flow-table-col-note"${f?` dx="${p}"`:``}>${Q(w)}</tspan>`),_+=`</text>`}}),_}function $(e){let t=Math.round(e*100)/100;return String(t)}function ol(e){if(e.length===0)return``;let t=`M ${$(e[0].x)} ${$(e[0].y)}`;for(let n=1;n<e.length;n++)t+=` L ${$(e[n].x)} ${$(e[n].y)}`;return t}function sl(e,t){if(e.length<2)return``;if(e.length===2)return ol(e);let n=`M ${$(e[0].x)} ${$(e[0].y)}`;for(let r=1;r<e.length-1;r++){let i=e[r-1],a=e[r],o=e[r+1],s=Math.hypot(a.x-i.x,a.y-i.y),c=Math.hypot(o.x-a.x,o.y-a.y),l=Math.min(t,s/2,c/2);if(l<.6||s<.6||c<.6){n+=` L ${$(a.x)} ${$(a.y)}`;continue}let u=a.x-(a.x-i.x)/s*l,d=a.y-(a.y-i.y)/s*l,f=a.x+(o.x-a.x)/c*l,p=a.y+(o.y-a.y)/c*l;n+=` L ${$(u)} ${$(d)} Q ${$(a.x)} ${$(a.y)} ${$(f)} ${$(p)}`}let r=e[e.length-1];return n+=` L ${$(r.x)} ${$(r.y)}`,n}function cl(e,t){if(e.length<2||t<=0)return e;let n=e[e.length-2],r=e[e.length-1],i=r.x-n.x,a=r.y-n.y,o=Math.hypot(i,a);if(o<=t+.5)return e;let s=(o-t)/o,c=e.slice(0,-1);return c.push({x:n.x+i*s,y:n.y+a*s}),c}function ll(e,t){if(e.length<2||t<=0)return e;let n=e[0],r=e[1],i=r.x-n.x,a=r.y-n.y,o=Math.hypot(i,a);if(o<=t+.5)return e;let s=t/o,c=e.slice();return c[0]={x:n.x+i*s,y:n.y+a*s},c}function ul(e,t,n){let r=Math.atan2(e.y-t.y,e.x-t.x),i=n===`filled`?9:10,a=n===`filled`?.4:.5,o={x:e.x-i*Math.cos(r-a),y:e.y-i*Math.sin(r-a)},s={x:e.x-i*Math.cos(r+a),y:e.y-i*Math.sin(r+a)};return n===`open`?`M ${$(o.x)} ${$(o.y)} L ${$(e.x)} ${$(e.y)} L ${$(s.x)} ${$(s.y)}`:`M ${$(e.x)} ${$(e.y)} L ${$(o.x)} ${$(o.y)} L ${$(s.x)} ${$(s.y)} Z`}function dl(e){let t=Math.min(9,e.width/4),n=e.x,r=e.y,i=e.width,a=e.height;return`M ${$(n)} ${$(r)} H ${$(n+i-t)} L ${$(n+i)} ${$(r+a/2)} L ${$(n+i-t)} ${$(r+a)} H ${$(n)} Z`}function fl(e){let t=Math.min(12,e.width/4,e.height/3),n=e.x,r=e.y,i=e.width,a=e.height;return{card:`M ${$(n)} ${$(r)} H ${$(n+i-t)} L ${$(n+i)} ${$(r+t)} V ${$(r+a)} H ${$(n)} Z`,fold:`M ${$(n+i-t)} ${$(r)} V ${$(r+t)} H ${$(n+i)}`}}function pl(e){return e===`destroy`||e===`lost`?`none`:e===`return`||e===`async`?`open`:`filled`}function ml(e,t){let n=`<g class="flow-sequence-underlay">`,r=t?.roundedCorners!==!1,i=r?8:0,a=t?.styles??[];for(let t of e.fragments){let e=t.bounds,o=t.operandBands.some(e=>e.styleRefs.length>0),s=D({styleRefs:o?[]:t.styleRefs,unresolvedVars:t.unresolvedVars},a),c=s.classes.join(` `),l=Object.keys(s.cssVars).length?` style="${Q(C(s.cssVars))}"`:``,u=`flow-sequence-fragment flow-sequence-fragment-${Q(t.operator)} ${c}`.trim();n+=`<g class="${u}" data-fragment-id="${Q(t.id)}" data-start-order="${t.startOrder}" data-end-order="${t.endOrder}"${l}>`;let d=o?` fill="transparent"`:``;n+=`<rect class="flow-sequence-fragment-box" x="${$(e.x)}" y="${$(e.y)}" width="${$(e.width)}" height="${$(e.height)}" rx="${i}"${d}/>`;for(let[e,o]of t.operandBands.entries()){if(o.styleRefs.length===0)continue;let s=D({styleRefs:o.styleRefs,unresolvedVars:{}},a),c=`flow-sequence-fragment-operand ${s.classes.join(` `)}`.trim(),l=Object.keys(s.cssVars).length?` style="${Q(C(s.cssVars))}"`:``,u=o.bounds,d=1.25,f=r&&(e===0||e===t.operandBands.length-1)?Math.max(0,i-2):0;n+=`<rect class="${c}" data-start-order="${o.startOrder}" data-end-order="${o.endOrder}" x="${$(u.x+d)}" y="${$(u.y+d)}" width="${$(Math.max(0,u.width-d*2))}" height="${$(Math.max(0,u.height-d*2))}" rx="${f}"${l}/>`}n+=`<path class="flow-sequence-fragment-tab" d="${dl(t.tab)}"/>`;for(let r of t.separators)n+=`<line class="flow-sequence-fragment-sep" x1="${$(e.x)}" y1="${$(r)}" x2="${$(e.x+e.width)}" y2="${$(r)}"/>`;n+=`</g>`}for(let t of e.lifelines)n+=`<line class="flow-sequence-lifeline" data-participant-id="${Q(t.participantId)}" x1="${$(t.x)}" y1="${$(t.y0)}" x2="${$(t.x)}" y2="${$(t.y1)}"/>`;for(let t of e.activations){let e=t.bounds,i=r?2:0;n+=`<rect class="flow-sequence-activation" data-activation-id="${Q(t.id)}" data-participant-id="${Q(t.participantId)}" data-start-order="${t.startOrder}" data-end-order="${t.endOrder}" x="${$(e.x)}" y="${$(e.y)}" width="${$(e.width)}" height="${$(e.height)}" rx="${i}"/>`}n+=`<g class="flow-sequence-fragment-labels">`;for(let t of e.fragments){let e=t.tab.x+(t.tab.width-9)/2,r=t.tab.y+14;n+=`<text class="flow-sequence-fragment-tab-label" x="${$(e)}" y="${$(r)}" text-anchor="middle">${Q(t.operatorLabel)}</text>`,t.guard&&(n+=`<text class="flow-sequence-fragment-guard" x="${$(t.guard.x)}" y="${$(t.guard.y)}">[${Q(t.guard.text)}]</text>`);for(let e of t.operandLabels)n+=`<text class="flow-sequence-fragment-label" x="${$(e.x)}" y="${$(e.y)}">[${Q(e.text)}]</text>`}n+=`</g>`;for(let t of e.dividers){let e=t.labelBounds;if(n+=`<g class="flow-sequence-divider" data-divider-id="${Q(t.id)}">`,e&&t.label){n+=`<line class="flow-sequence-divider-rule" x1="${$(t.x0)}" y1="${$(t.y)}" x2="${$(e.x-8)}" y2="${$(t.y)}"/>`,n+=`<line class="flow-sequence-divider-rule" x1="${$(e.x+e.width+8)}" y1="${$(t.y)}" x2="${$(t.x1)}" y2="${$(t.y)}"/>`;let i=r?e.height/2:0;n+=`<rect class="flow-sequence-divider-chip" x="${$(e.x)}" y="${$(e.y)}" width="${$(e.width)}" height="${$(e.height)}" rx="${i}"/>`,n+=`<text class="flow-sequence-divider-label" x="${$(e.x+e.width/2)}" y="${$(e.y+14)}" text-anchor="middle">${Q(t.label)}</text>`}else n+=`<line class="flow-sequence-divider-rule" x1="${$(t.x0)}" y1="${$(t.y)}" x2="${$(t.x1)}" y2="${$(t.y)}"/>`;n+=`</g>`}return n+=`</g>`,n}function hl(e,t,n){if(e){let t=N(e,n);if(t.strokeDash&&t.strokeDash!==`none`)return` stroke-dasharray="${Q(t.strokeDash)}"`}return t===`return`||t===`create`?` stroke-dasharray="5 3.5"`:``}function gl(e,t,n){let r=t===`failure`||t===`destroy`?`var(--kd-danger)`:t===`async`?`var(--kd-async-stroke)`:t===`create`?`var(--kd-accent)`:t===`return`?`var(--kd-muted)`:`var(--kd-edge)`;if(!e)return{color:r,width:1.75,styleAttr:``,branchClass:``,labelClass:``,styleClasses:``};let i=N(e,n),a=y(e.label,e.branch),o=i.cssVars[`--edge-stroke`],s=o??r;!o&&e.kind===`failure`?s=`var(--kd-danger)`:!o&&(e.kind===`async`||e.kind===`eventual`)&&(s=`var(--kd-async-stroke)`),s=E(a,s);let c=i.strokeWidth??(t===`failure`?2.05:1.75),l=Object.keys(i.cssVars).length?` style="${Q(C(i.cssVars))}"`:``;return{color:s,width:c,styleAttr:l,branchClass:O(a),labelClass:M(a),styleClasses:i.classes.join(` `)}}function _l(e,t,n){let r=`<g class="flow-sequence-overlay">`,i=new Map((e.sequence?.messages??[]).map(e=>[e.id,e])),a=n?.roundedCorners!==!1,o=n?.roundedCorners===!0?10:0;for(let s of t.messages){let t=s.kind,c=e.edges.find(e=>e.id===s.messageId),l=i.get(s.messageId),u=c?.from??l?.from??void 0,d=c?.to??l?.to??void 0,f=gl(c,t,e.styles),p=c?` flow-edge-${c.kind}`:``,m=c?.sequenceOrder??l?.order,h=pl(t),g=`flow-sequence-message flow-sequence-message-${Q(t)} flow-edge${p} ${f.branchClass} ${f.styleClasses}`.trim(),_=c?` data-edge-id="${Q(c.id)}"`:``,v=u?` data-edge-from="${Q(u)}"`:``,y=d?` data-edge-to="${Q(d)}"`:``,b=m==null?``:` data-sequence-order="${m}"`;if(r+=`<g class="${g}" data-message-id="${Q(s.messageId)}" data-sequence-head="${h}"${_}${v}${y}${b}${f.styleAttr}>`,t===`destroy`&&s.points.length>=4)r+=`<path class="flow-edge-path flow-sequence-message-path flow-sequence-destroy" d="${ol([s.points[0],s.points[1]])}" stroke="${f.color}" stroke-width="2.15" fill="none"/>`,r+=`<path class="flow-sequence-destroy" d="${ol([s.points[2],s.points[3]])}" stroke="${f.color}" stroke-width="2.15" fill="none"/>`;else if(s.points.length>=2){let n=hl(c,t,e.styles),i=s.points;s.endpoint&&s.endpointAt===`start`&&(i=ll(i,6)),h===`filled`?i=cl(i,7.2):h===`open`&&(i=cl(i,8.2));let a=t!==`lost`&&t!==`found`&&s.points.length>=4?sl(i,8):ol(i);if(r+=`<path class="flow-edge-path flow-sequence-message-path" d="${a}" fill="none" stroke="${f.color}" stroke-width="${f.width}"${n}/>`,h!==`none`){let e=s.points[s.points.length-1],t=s.points[s.points.length-2],n=h===`open`?`flow-sequence-message-head flow-sequence-message-head-open`:`flow-sequence-message-head flow-sequence-message-head-filled`;r+=h===`open`?`<path class="${n}" d="${ul(e,t,`open`)}" fill="none" stroke="${f.color}" stroke-width="1.75" stroke-dasharray="none"/>`:`<path class="${n}" d="${ul(e,t,`filled`)}" fill="${f.color}" stroke="none"/>`}s.endpoint&&(r+=`<circle class="flow-sequence-endpoint" cx="${$(s.endpoint.x)}" cy="${$(s.endpoint.y)}" r="4.25"/>`)}if(s.payloadBounds&&s.payloadLines?.length){let e=s.payloadBounds,i=t===`async`?`async`:t===`return`?`return`:t===`failure`||t===`destroy`?`failure`:`call`,a=n?.roundedCorners===!0?3:0,o=e.x+3+10,c=e.y+8+10,l=``;s.payloadLines.forEach((e,t)=>{let n=t===0?0:14;l+=`<tspan x="${$(o)}" dy="${n}">${Q(e)}</tspan>`}),r+=`<g class="flow-sequence-payload flow-sequence-payload-${i}">`,r+=`<rect class="flow-sequence-payload-card" x="${$(e.x)}" y="${$(e.y)}" width="${$(e.width)}" height="${$(e.height)}" rx="${a}"/>`,r+=`<rect class="flow-sequence-payload-accent" x="${$(e.x)}" y="${$(e.y)}" width="3" height="${$(e.height)}"/>`,r+=`<text class="flow-sequence-payload-text" xml:space="preserve" x="${$(o)}" y="${$(c)}">${l}</text>`,r+=`</g>`}if(s.label&&s.labelCenter&&s.labelBounds){let e=s.labelBounds;if(r+=`<rect class="flow-sequence-message-label-bg flow-edge-label-bg" x="${$(e.x)}" y="${$(e.y)}" width="${$(e.width)}" height="${$(e.height)}" rx="${o}"/>`,s.number!=null){let t=s.number>=10?18:14,n=e.x+4,i=e.y+(e.height-14)/2,o=a?7:2;r+=`<rect class="flow-sequence-badge" x="${$(n)}" y="${$(i)}" width="${t}" height="14" rx="${o}"/>`,r+=`<text class="flow-sequence-badge-text" x="${$(n+t/2)}" y="${$(i+10.5)}" text-anchor="middle">${s.number}</text>`}let t=`flow-sequence-message-label flow-edge-label-text ${f.labelClass}`.trim();r+=`<text class="${t}" x="${$(s.labelCenter.x)}" y="${$(s.labelCenter.y)}" text-anchor="middle">${Q(s.label)}</text>`}r+=`</g>`}for(let e of t.notes){let t=e.bounds,n=fl(t),i=e.lines?.length?e.lines:[e.text];r+=`<g class="flow-sequence-note" data-note-id="${Q(e.id)}">`,r+=`<path class="flow-sequence-note-card" d="${n.card}"/>`,r+=`<path class="flow-sequence-note-fold" d="${n.fold}"/>`;let a=``;i.forEach((e,n)=>{let r=n===0?0:15;a+=`<tspan x="${$(t.x+10)}" dy="${r}">${Q(e)}</tspan>`}),r+=`<text class="flow-sequence-note-text" x="${$(t.x+10)}" y="${$(t.y+16)}">${a}</text>`,r+=`</g>`}return r+=`</g>`,r}function vl(e){return e.sequence!=null}function yl(){let e=[{id:`flow-card-one`,kind:`one`,mirror:!1},{id:`flow-card-zeroOrOne`,kind:`zeroOrOne`,mirror:!1},{id:`flow-card-oneOrMany`,kind:`oneOrMany`,mirror:!1},{id:`flow-card-zeroOrMany`,kind:`zeroOrMany`,mirror:!1},{id:`flow-card-one-start`,kind:`one`,mirror:!0},{id:`flow-card-zeroOrOne-start`,kind:`zeroOrOne`,mirror:!0},{id:`flow-card-oneOrMany-start`,kind:`oneOrMany`,mirror:!0},{id:`flow-card-zeroOrMany-start`,kind:`zeroOrMany`,mirror:!0}],t=``;for(let n of e)t+=`<marker id="${n.id}" markerWidth="16" markerHeight="12" refX="${n.mirror?1:15}" refY="6" orient="auto" markerUnits="userSpaceOnUse">`,t+=bl(n.kind,n.mirror),t+=`</marker>`;return t}function bl(e,t){let n=t?1:15,r=t?1:-1,i=`stroke="var(--kd-edge)" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"`,a=`fill="var(--kd-table-fill, var(--kd-bg))" stroke="var(--kd-edge)" stroke-width="1.35"`,o=``;if(e===`one`){let e=n+r*4,t=n+r*7;return o+=`<line x1="${e}" y1="1.5" x2="${e}" y2="10.5" ${i}/>`,o+=`<line x1="${t}" y1="1.5" x2="${t}" y2="10.5" ${i}/>`,o}if(e===`zeroOrOne`){let e=n+r*3,t=n+r*7;return o+=`<circle cx="${e}" cy="6" r="2.2" ${a}/>`,o+=`<line x1="${t}" y1="1.5" x2="${t}" y2="10.5" ${i}/>`,o}if(e===`oneOrMany`){let e=n+r*10,t=n+r*4;return o+=`<line x1="${e}" y1="1.5" x2="${e}" y2="10.5" ${i}/>`,o+=`<path d="M ${n} 6 L ${t} 1.2 M ${n} 6 L ${t} 6 M ${n} 6 L ${t} 10.8" ${i}/>`,o}let s=n+r*3.2,c=n+r*9;return o+=`<circle cx="${s}" cy="6" r="2.2" ${a}/>`,o+=`<path d="M ${n} 6 L ${c} 1.2 M ${n} 6 L ${c} 6 M ${n} 6 L ${c} 10.8" ${i}/>`,o}function xl(e){return{markerStart:`flow-card-${e.from}-start`,markerEnd:`flow-card-${e.to}`}}var Sl=Se;function Cl(e,t=``){return`class="flow-node-shell" fill="${e.fill}" stroke="${e.stroke}" stroke-width="${Sl}" stroke-linejoin="round" stroke-linecap="round"${e.dashAttr}${e.filterAttr}${t}`}function wl(e,t,n){return e===`pill`?t/2:n?e===`rectangle`?6:12:0}function Tl(e){return rt(e)}function El(e){return $e(e)}function Dl(e,t,n,r){let{x:i,y:a,width:o,height:s}=e;return`<rect x="${i}" y="${a}" width="${o}" height="${s}" rx="${wl(t,s,r)}" ${Cl(n)}/>`}function Ol(e,t){return`<polygon points="${El(e)}" ${Cl(t)}/>`}function kl(e,t){return`<polygon points="${Tl(e)}" ${Cl(t)}/>`}function Al(e,t){let{body:n,rim:r}=st(e),i=`<path d="${n}" ${Cl(t)}/>`;return i+=`<path d="${r}" class="flow-node-shell-rim" fill="none" stroke="${t.stroke}" stroke-width="${Sl}" stroke-linecap="round"${t.dashAttr}/>`,i}function jl(e,t){let{body:n,rim:r}=dt(e),i=`<path d="${n}" ${Cl(t)}/>`;return i+=`<path d="${r}" class="flow-node-shell-rim" fill="none" stroke="${t.stroke}" stroke-width="${Sl}" stroke-linecap="round"${t.dashAttr}/>`,i}function Ml(e,t){let n=`<path d="${gt(e)}" ${Cl(t)}/>`;for(let r of _t(e))n+=`<path d="${r}" class="flow-node-shell-partition" fill="none" stroke="${t.stroke}" stroke-width="${Sl}" stroke-linecap="round" opacity="0.4"${t.dashAttr}/>`;return n}function Nl(e,t){let{head:n,body:r}=Qt(e),i=Cl(t),a=`<path d="${r}" ${i}/>`;return a+=`<path d="${n}" ${i}/>`,a}function Pl(e,t,n){return e===`pill`?{strokeWidth:Sl,cornerRadius:n/2}:t?e===`rectangle`?{strokeWidth:Sl,cornerRadius:6}:{strokeWidth:Sl,cornerRadius:12}:{strokeWidth:Sl,cornerRadius:0}}function Fl(e,t,n,r){let i=ln(e),a=Pl(e,r,t.height),o=i.getPath(t,a),s=`<path d="${o.d}" ${Cl(n)}/>`;for(let e of o.decorations??[])s+=`<path d="${e.d}" class="flow-node-shell-${e.role}" fill="none" stroke="${n.stroke}" stroke-width="${Sl}" stroke-linecap="round"${n.dashAttr}/>`;return s}function Il(e,t,n,r){let i=un(e);switch(i){case`diamond`:return Ol(t,n);case`cylinder`:return Al(t,n);case`hexagon`:return kl(t,n);case`queue`:return jl(t,n);case`stream`:return Ml(t,n);case`person`:return Nl(t,n);case`rectangle`:case`pill`:case`rounded`:return Dl(t,i,n,r);case`table`:return Dl(t,`rectangle`,n,r);case`circle`:case`ellipse`:case`parallelogram`:case`trapezoid`:case`triangle`:case`document`:case`folded-document`:case`cloud`:case`boundary`:return Fl(i,t,n,r);default:return Dl(t,i,n,r)}}var Ll=new Set([`rounded`,`rectangle`,`pill`]),Rl=18,zl=28,Bl=12,Vl=18,Hl=15,Ul=14,Wl=14,Gl=4,Kl=26;function ql(e,t,n,r,i){let a=n+r.y+Kl*i,o=n+r.y+r.height-Kl*i;return Math.max(a,Math.min(e,o-t))}function Jl(e,t){let n=Math.min(Math.max(e.x,t.x),t.x+t.width),r=Math.min(Math.max(e.y,t.y),t.y+t.height);if(e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height){let n=e.x-t.x,r=t.x+t.width-e.x,i=e.y-t.y,a=t.y+t.height-e.y,o=Math.min(n,r,i,a);return o===n?{x:t.x,y:e.y}:o===r?{x:t.x+t.width,y:e.y}:o===i?{x:e.x,y:t.y}:{x:e.x,y:t.y+t.height}}return{x:n,y:r}}function Yl(e){let t=1/0;for(let n of e.nodes)t=Math.min(t,n.bounds.x);for(let n of e.groups)t=Math.min(t,n.bounds.x);return Number.isFinite(t)?t:0}function Xl(e,t,n,r){let i=un(e),a=`class="flow-group-box" fill="none" stroke="var(--kd-group-stroke)" stroke-width="1.6" stroke-dasharray="7 5"`;if(i===`hexagon`)return`<polygon points="${rt(t)}" ${a} stroke-linejoin="round"/>`;if(i===`circle`||i===`ellipse`)return`<path d="${ln(i).getPath(t,{strokeWidth:1.6,cornerRadius:0}).d}" ${a}/>`;if(i===`rounded`){let e=r?Math.max(n,12):n;return`<rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" rx="${e}" ${a}/>`}return`<rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" rx="${n}" ${a}/>`}function Zl(e){let{graph:n,layout:r,measured:i,treatedEdges:a,labels:o,options:s,routingOptions:c,underlay:u=``}=e,d=l(s.presentation,n.title),f={x:0,y:0,width:r.width,height:r.height},p=r.nodes.map(e=>e.bounds),m=Yc(o,f,d.clampLabels,p),h=$c(r.width,r.height,d),g=h.width,_=h.height,{contentOffsetX:v,contentOffsetY:b}=h,x=s.theme===`auto`,S=x?`dark`:s.theme??`dark`,w=x?!1:s.snapshotTheme??!1,D=Q(n.title??`Diagram`),A=Q(`Diagram with ${n.nodes.length} nodes and ${n.edges.length} edges`),P=new Map(i.map(e=>[e.nodeId,e])),re=new Map(r.nodes.map(e=>[e.nodeId,e])),F=``;w&&(F+=`<style>${ee(S,!0)}</style>`);let I=s.shadows===!0,ie=s.roundedCorners===!0;F+=`<defs>`,I&&(F+=`
|
|
4
|
+
<filter id="flow-node-shadow" x="-28%" y="-28%" width="156%" height="156%">
|
|
5
|
+
<feDropShadow dx="0" dy="8" stdDeviation="12" flood-color="var(--kd-node-shadow)" flood-opacity="0.95"/>
|
|
6
|
+
</filter>
|
|
7
|
+
<filter id="flow-node-glow" x="-35%" y="-35%" width="170%" height="170%">
|
|
8
|
+
<feDropShadow dx="0" dy="0" stdDeviation="6" flood-color="var(--kd-node-glow)" flood-opacity="0.65"/>
|
|
9
|
+
</filter>`),F+=`
|
|
10
|
+
<marker id="flow-arrow" markerWidth="10" markerHeight="10" refX="1.5" refY="5" orient="auto" markerUnits="userSpaceOnUse">
|
|
11
|
+
<path d="M1.5,1.5 L9,5 L1.5,8.5 Z" fill="context-stroke"/>
|
|
12
|
+
</marker>
|
|
13
|
+
<marker id="flow-arrow-start" markerWidth="10" markerHeight="10" refX="1.5" refY="5" orient="auto-start-reverse" markerUnits="userSpaceOnUse">
|
|
14
|
+
<path d="M1.5,1.5 L9,5 L1.5,8.5 Z" fill="context-stroke"/>
|
|
15
|
+
</marker>
|
|
16
|
+
${yl()}
|
|
17
|
+
</defs>`;let L=v+Yl(r);F+=tl(d,L,d.padding.top),F+=`<g class="flow-diagram-content" transform="translate(${v}, ${b})">`,u&&(F+=u);let R=vl(r);R&&(F+=`<rect class="flow-sequence-canvas" x="0" y="0" width="${r.width}" height="${r.height}" fill="var(--kd-bg)" pointer-events="none"/>`,F+=ml(r.sequence,{roundedCorners:ie,styles:n.styles}));let ae=r.groups.filter(e=>n.groups.find(t=>t.id===e.groupId)?.kind===`swimlane`).sort((e,t)=>e.bounds.y-t.bounds.y||e.bounds.x-t.bounds.x),z=ae[ae.length-1]?.groupId;r.groups.forEach((e,r)=>{let i=n.groups.find(t=>t.id===e.groupId),a=i?.chrome!==!1,o=d.groupAccent&&a?Qc(r):void 0,s=[];o&&s.push(`--group-accent: ${o}`,`--kd-group-fill: ${o}1f`,`--kd-group-stroke: ${o}99`),i?.iconColor&&s.push(`--icon-color: ${i.iconColor}`);let c=s.length?` style="${Q(s.join(`; `))}"`:``,l=i?t(i.label,T(i.labelAuthored,d.labelCase)):``,u=a&&i?.icon&&i.icon!==`none`?i.icon:null,f=i?.kind===`swimlane`,p=i?.kind===`database`;if(F+=`<g class="${a?f?`flow-group flow-group-swimlane`:p?o?`flow-group flow-group-database flow-group-accented`:`flow-group flow-group-database`:o?`flow-group flow-group-accented`:`flow-group`:`flow-group flow-group-chromeless`}" data-group-id="${Q(e.groupId)}"${c}>`,a){let{x:t,y:n,width:r,height:a}=e.bounds;if(f&&e.headerBox){let{x:i,y:o,width:s,height:c}=e.headerBox;if(F+=`<rect class="flow-group-header-bar" x="${i}" y="${o}" width="${s}" height="${c}" pointer-events="none"/>`,F+=`<line class="flow-group-header-rule" x1="${i+s}" y1="${o}" x2="${i+s}" y2="${o+c}"/>`,e.groupId!==z){let e=n+a;F+=`<line class="flow-group-swimlane-sep" x1="${t}" y1="${e}" x2="${t+r}" y2="${e}"/>`}}else if(!f){let e=ie?12:0,o=i?.shape?un(String(i.shape)):`rectangle`;F+=Xl(o,{x:t,y:n,width:r,height:a},e,ie)}if(i){let t=e.labelBox.x,n=f?`middle`:`start`,r=f?e.labelBox.y+e.labelBox.height/2:e.labelBox.y+16,a=f?xr(l,e.labelBox.width):[l];if(u){let n=e.labelBox.y+e.labelBox.height/2,r=e.labelBox.x+7;F+=au(u,r,n,i.iconPaint,!!i.iconColor),t=f?e.labelBox.x+e.labelBox.width/2:e.labelBox.x+14+6}else f&&(t=e.labelBox.x+e.labelBox.width/2);let o=f?` dominant-baseline="middle"`:``;if(f&&a.length>1){let e=r-(a.length-1)*14/2,i=``;a.forEach((e,n)=>{i+=`<tspan x="${t}" dy="${n===0?0:14}">${Q(e)}</tspan>`}),F+=`<text class="flow-group-label" x="${t}" y="${e}" text-anchor="${n}"${o}>${i}</text>`}else F+=`<text class="flow-group-label" x="${t}" y="${r}" text-anchor="${n}"${o}>${Q(l)}</text>`}}F+=`</g>`});for(let e of n.nodes){let t=re.get(e.id),r=P.get(e.id);if(!t||!r)continue;let i=j(e,n.styles),a=`flow-node flow-node-body ${k(e.kind)} ${i.classes.join(` `)}`.trim(),o=i.cssVars&&Object.keys(i.cssVars).length?` style="${Q(C(i.cssVars))}"`:``;if(F+=`<g class="${a}" aria-hidden="true" data-node-id="${Q(e.id)}"${o}>`,An(e)){let n=e.scale&&e.scale>0?e.scale:1;F+=il(t.bounds,e.id,n,ie,Nn(e,n))}else F+=eu(e,t.bounds,i.strokeDash,I,ie);F+=`</g>`}for(let e of a){if(R)break;let t=n.edges.find(t=>t.id===e.edgeId),r=t?N(t,n.styles):null,i=y(t?.label,t?.branch),a=O(i),o=t?`flow-edge flow-edge-${t.kind} ${a} ${r?.classes.join(` `)??``}`.trim():`flow-edge`,s=r?.strokeWidth??(t?.kind===`failure`?2.2:2),l=r?.cssVars[`--edge-stroke`]??(t?.kind===`failure`?`var(--kd-danger)`:t?.kind===`async`||t?.kind===`eventual`?`var(--kd-async-stroke)`:`var(--kd-edge)`);l=E(i,l);let u=r?.strokeDash&&r.strokeDash!==`none`?` stroke-dasharray="${Q(r.strokeDash)}"`:t?.identifying===!1?` stroke-dasharray="5 4"`:t?.kind===`dependency`?` stroke-dasharray="2 4"`:t?.kind===`async`||t?.kind===`eventual`?` stroke-dasharray="6 4"`:i!==`neutral`&&t?.kind===`sync`?` stroke-dasharray="7 5"`:``,d=r?` style="${Q(C(r.cssVars))}"`:``,f=c?.arrowheads!==!1,p=t?.cardinality,m=p?xl(p):void 0,h=m?{start:!1,end:!1}:lc(t,f);F+=`<g class="${o}" data-edge-id="${Q(e.edgeId)}" data-edge-from="${Q(t?.from??``)}" data-edge-to="${Q(t?.to??``)}"${d}>`,F+=Ql(e.segments,c,s,l,u,h.start||h.end?h:void 0,m),F+=`</g>`}for(let e of n.nodes){let t=re.get(e.id),r=P.get(e.id);if(!t||!r)continue;let i=j(e,n.styles),a=`flow-node flow-node-foreground ${k(e.kind)} ${i.classes.join(` `)}`.trim(),o=i.cssVars&&Object.keys(i.cssVars).length?` style="${Q(C(i.cssVars))}"`:``;F+=`<g class="${a}" role="group" aria-label="${Q(e.label)}, ${Q(te(e.kind))} node" data-node-id="${Q(e.id)}"${o}>`,An(e)?F+=al(e,t.bounds,ie):F+=tu(e,t.bounds,r.labelLines,r.contentBox,i.badge,s.debug?.showKindLabels===!0,e.note,d.showKindSubtitles,!!(e.iconColor||i.cssVars[`--icon-color`]),r.technologyLines,r.descriptionLines),F+=`</g>`}if(R){for(let e of r.sequence.footers){let t=n.nodes.find(t=>t.id===e.participantId),r=P.get(e.participantId);if(!t||!r)continue;let i=j(t,n.styles),a=i.cssVars&&Object.keys(i.cssVars).length?` style="${Q(C(i.cssVars))}"`:``,o=`flow-node flow-sequence-footer ${k(t.kind)} ${i.classes.join(` `)}`.trim();F+=`<g class="${o}" aria-hidden="true" data-node-id="${Q(t.id)}" data-sequence-footer="true"${a}>`,An(t)||(F+=eu(t,e.bounds,i.strokeDash,I,ie),F+=tu(t,e.bounds,r.labelLines,r.contentBox,i.badge,s.debug?.showKindLabels===!0,t.note,d.showKindSubtitles,!!(t.iconColor||i.cssVars[`--icon-color`]),r.technologyLines,r.descriptionLines)),F+=`</g>`}F+=_l(n,r.sequence,{roundedCorners:ie})}for(let e of m){if(R)break;let r=n.edges.find(t=>t.id===e.edgeId);if(r?.cardinality&&ne(r.label)&&ne(e.text)&&!r.fromColumn&&!r.toColumn)continue;let i=y(r?.label??e.text,r?.branch),a=`flow-edge-label ${M(i)}`.trim(),o=ie?e.bounds.height/2:0,s=e.bounds.y+e.bounds.height/2,c=!!(r?.icon&&r.icon!==`none`),l=!!(r?.fromColumn||r?.toColumn)||/→/.test(e.text),u=e.text.length>0?t(e.text,l?`as-authored`:T(r?.labelAuthored??!0,d.labelCase)):``,f=c&&r?.iconColor?` style="--icon-color: ${Q(r.iconColor)}"`:``;F+=`<g class="${a}" data-edge-id="${Q(e.edgeId)}"${f}>`;let p=Jl(e.anchor,e.bounds);if(Math.hypot(p.x-e.anchor.x,p.y-e.anchor.y)>3.5&&(F+=`<line class="flow-edge-label-leader" x1="${e.anchor.x}" y1="${e.anchor.y}" x2="${p.x}" y2="${p.y}"/>`),F+=`<rect class="flow-edge-label-bg" x="${e.bounds.x}" y="${e.bounds.y}" width="${e.bounds.width}" height="${e.bounds.height}" rx="${o}"/>`,c&&r?.icon){let t=u.length>0?e.bounds.x+8+6:e.bounds.x+e.bounds.width/2;F+=ou(r.icon,t,s,r.iconPaint,!!r.iconColor)}if(u.length>0){let t=c?e.bounds.x+8+12+4+(e.bounds.width-16-12-4)/2:e.bounds.x+e.bounds.width/2;F+=`<text class="flow-edge-label-text" x="${t}" y="${s}" dominant-baseline="middle" text-anchor="middle">${Q(u)}</text>`}F+=`</g>`}if(d.showEndpoints||s.debug?.showPorts){let e=s.debug?.showPorts===!0;for(let t of r.edgePaths){let r=n.edges.find(e=>e.id===t.edgeId),i=r?N(r,n.styles):null,a=y(r?.label,r?.branch),o=i?.cssVars[`--edge-stroke`]??(r?.kind===`failure`?`var(--kd-danger)`:r?.kind===`async`||r?.kind===`eventual`?`var(--kd-async-stroke)`:`var(--kd-edge)`);o=E(a,o);let s=t.points[0],c=t.points[t.points.length-1];if(s){let n=e?`flow-debug-port flow-debug-port-source`:`flow-edge-endpoint`,r=e?void 0:` fill="${o}"`;F+=`<circle class="${n}" cx="${s.x}" cy="${s.y}" r="3.25" data-edge-id="${Q(t.edgeId)}"${r??``}/>`}if(c){let n=e?`flow-debug-port flow-debug-port-target`:`flow-edge-endpoint`,r=e?void 0:` fill="${o}"`;F+=`<circle class="${n}" cx="${c.x}" cy="${c.y}" r="3.25" data-edge-id="${Q(t.edgeId)}"${r??``}/>`}}}if(s.debug?.showBounds){for(let e of r.nodes)F+=`<rect x="${e.bounds.x}" y="${e.bounds.y}" width="${e.bounds.width}" height="${e.bounds.height}" fill="none" stroke="var(--kd-accent)" stroke-width="1" stroke-dasharray="4 3" class="flow-debug-bounds" data-node-id="${Q(e.nodeId)}"/>`;for(let e of r.groups)F+=`<rect x="${e.bounds.x}" y="${e.bounds.y}" width="${e.bounds.width}" height="${e.bounds.height}" fill="none" stroke="var(--kd-danger)" stroke-width="1" stroke-dasharray="6 4" class="flow-debug-group-bounds" data-group-id="${Q(e.groupId)}"/>`}F+=`</g>`;let B=el(d)?` data-chrome="opt-in"`:``;return`<?xml version="1.0" encoding="UTF-8"?>
|
|
18
|
+
<svg${x?` class="k-diagram"`:` class="k-diagram kdiagram-theme-${Q(S)}"`}${x?``:` data-theme="${Q(S)}"`}${B} xmlns="http://www.w3.org/2000/svg" width="${g}" height="${_}" viewBox="0 0 ${g} ${_}" role="img" aria-label="${D}" aria-describedby="flow-desc">
|
|
19
|
+
${w?``:`<style>${ee(S)}</style>`}
|
|
20
|
+
<desc id="flow-desc">${A}</desc>
|
|
21
|
+
${F}
|
|
22
|
+
</svg>`}function Ql(e,t,n,r,i,a,o){let s=``,c=[],l=e=>e.type!==`line`&&e.type!==`cubic`?!1:Math.hypot(e.to.x-e.from.x,e.to.y-e.from.y)>=12,u=-1,d=-1;for(let t=0;t<e.length;t++)if((e[t].type===`line`||e[t].type===`cubic`)&&u<0&&(u=t),l(e[t])){u=t;break}for(let t=e.length-1;t>=0;t--)if((e[t].type===`line`||e[t].type===`cubic`)&&d<0&&(d=t),l(e[t])){d=t;break}let f=()=>{if(!c.length)return;let e=c.some(e=>e.idx===d),l=c.some(e=>e.idx===u),f=``;o?(l&&(f+=` marker-start="url(#${o.markerStart})"`),e&&(f+=` marker-end="url(#${o.markerEnd})"`)):a&&(a.start&&l&&(f+=` marker-start="url(#flow-arrow-start)"`),a.end&&e&&(f+=` marker-end="url(#flow-arrow)"`));let p=Vc(c.map(e=>e.seg),{route:t?.route??`metro`,cornerRadius:t?.cornerRadius});p&&(s+=`<path class="flow-edge-path" d="${p}" fill="none" stroke="${r}" stroke-width="${n}" stroke-linecap="round" stroke-linejoin="round"${i}${f}/>`),c=[]};return e.forEach((e,t)=>{if(e.type===`line`||e.type===`cubic`)c.push({seg:e,idx:t});else if(f(),e.type===`jump`){let t=(e.from.x+e.to.x)/2,a=(e.from.y+e.to.y)/2;s+=`<path d="M ${e.from.x} ${e.from.y} Q ${t} ${a-e.radius} ${e.to.x} ${e.to.y}" fill="none" stroke="${r}" stroke-width="${n}" stroke-linecap="round" class="flow-edge-jump"${i}/>`}}),f(),s}function $l(e){let t=un(e.shape??`rounded`);return Ll.has(t)}function eu(e,t,n,r=!1,i=!1){let a=un(e.shape??`rounded`),o=n&&n!==`none`?` stroke-dasharray="${Q(n)}"`:``,s=r?` filter="url(#flow-node-shadow)"`:``,c={fill:`var(--node-fill, var(--kd-node-fill))`,stroke:`var(--node-stroke, var(--kd-node-stroke))`,dashAttr:o,filterAttr:s};if(e.kind===`initial`||e.kind===`junction`){let n=t.x+t.width/2,r=t.y+t.height/2,i=Math.max(5,Math.min(t.width,t.height)/2-2);return`<circle class="flow-state-${e.kind}" cx="${n}" cy="${r}" r="${i}" fill="${c.stroke}" stroke="${c.stroke}" stroke-width="2"${s}/>`}if(e.kind===`final`){let n=t.x+t.width/2,r=t.y+t.height/2,a=Math.max(7,Math.min(t.width,t.height)/2-2),o=Math.max(4,a-5),s=e.labelAuthored?`<circle class="flow-state-final-ring" cx="${n}" cy="${r}" r="${o}" fill="none" stroke="${c.stroke}" stroke-width="2"/>`:`<circle class="flow-state-final-core" cx="${n}" cy="${r}" r="${o}" fill="${c.stroke}" stroke="none"/>`;return`<g class="flow-state-final">${Il(`circle`,t,c,i)}${s}</g>`}return Il(a,t,c,i)}function tu(e,t,n,r,i,a=!1,o,s=!1,c=!1,l,u){let{x:d,y:f,width:p,height:m}=t,h=d+p/2,g=un(e.shape??`rounded`),_=ln(g).contentPolicy?.preferExternalLabel===!0,v=iu(e),y=!!v,b=$l(e),x=nu(e),S=e.scale&&e.scale>0?e.scale:1,ee=15*S,C=Vl*S,w=10.5*S,T=11*S,E=11*S,D=e.subtitle?.trim()?e.subtitle.trim():void 0,O=!x&&(!!D||s||e.showSubtitle===!0),k=(!ru(e)||e.labelAuthored)&&(!x||e.labelAuthored)?n:[],A=!x&&l?.length?l:[],j=!x&&u?.length?u:[],M=A.length>0||j.length>0,N=Gl*S,P=``,ne=D??te(e.kind),re=f+m/2;if(g===`cylinder`){let{ry:e}=ot(p,m);re=f+e+(m-e)/2}else g===`diamond`?re=f+m*.5:g===`person`&&(re=f+r.y+r.height/2);if(x&&y&&v){let t=zl*S,n=k.length>0?k.length*C:0,r=k.length>0?f+(m-n)/2:re;P+=su(v,h,r,t/20,e.iconPaint,c)}else if(y&&v&&b){let t=$n(v,S),n=d+Rl+t/2;P+=su(v,n,re,S,e.iconPaint,c)}else y&&v&&g===`diamond`&&n.length>1&&(P+=su(v,h,f+m*.32,.7*S,e.iconPaint,c));let F=g===`diamond`?g===`diamond`&&O:O,I=k.length*C+(F?Hl*S:0)+(F&&M?N:0)+A.length*Ul*S+(A.length&&j.length?N:0)+j.length*Wl*S+(a?12:0),ie=y&&v&&b&&!x?$n(v,S):0,L=b&&y&&!x?d+Rl+ie+Bl:h,R=b&&y&&!x?`start`:`middle`,ae=x?f+m-10*S-(k.length-1)*C:re-I/2+C-4*S,z=y&&v&&!b&&!x&&g!==`diamond`&&!_;if(z&&v){let t=g===`person`?.9*S:1.05*S,n=20*t,i=6*S,a=n+i+I,o=d+r.x+r.width/2;L=o;let s=f+r.y,l=r.height;if(g===`cylinder`){let{ry:e}=ot(p,m);s=f+e*2+4*S,l=Math.max(n+I,f+m-8*S-s)}let u=s+Math.max(0,(l-a)/2);P+=su(v,o,u+n/2,t,e.iconPaint,c),ae=u+n+i+C-4*S}_&&!x&&(L=d+r.x+r.width/2,R=`middle`,ae=f+r.y+r.height/2-I/2+C*.7),g===`person`&&!z&&!x?(L=d+r.x+r.width/2,R=`middle`,ae=M?f+r.y+Kl*S+C-4*S:f+r.y+r.height/2-I/2+C*.7):M&&!x&&!z&&!_&&(L=b&&y?L:d+r.x+r.width/2,b&&y||(R=`middle`),ae=f+r.y+Kl*S+C-4*S),M&&!x&&!z&&(ae=ql(ae,I,f,r,S)),k.forEach((e,t)=>{let n=x?11*S:_?13*S:ee;P+=`<text class="flow-node-title" x="${L}" y="${ae+t*C}" text-anchor="${R}" font-size="${n}">${Q(e)}</text>`});let B=ae+k.length*C;F&&(B+=2*S,P+=`<text class="flow-node-subtitle" x="${L}" y="${B}" text-anchor="${R}" font-size="${w}">${Q(ne)}</text>`,B+=Hl*S-2*S,M&&(B+=N));for(let e of A)B+=Ul*S,P+=`<text class="flow-node-technology" x="${L}" y="${B}" text-anchor="${R}" font-size="${T}">${Q(e)}</text>`;A.length&&j.length&&(B+=N);for(let e of j)B+=Wl*S,P+=`<text class="flow-node-description" x="${L}" y="${B}" text-anchor="${R}" font-size="${E}">${Q(e)}</text>`;if(a&&(B+=12,P+=`<text x="${L}" y="${B}" text-anchor="${R}" fill="var(--kd-danger)" font-size="${8*S}" font-weight="600" letter-spacing="0.06em">${Q(e.kind.toUpperCase())}</text>`),i&&(P+=`<text class="flow-node-badge" x="${d+p-8}" y="${f+14}" text-anchor="end" fill="var(--node-title-fill, var(--node-stroke, var(--kd-text)))" font-size="10" font-weight="700">${Q(i)}</text>`),o){let e=f+m-10*S;P+=`<text class="flow-node-note-text" x="${h}" y="${e}" text-anchor="middle" fill="var(--kd-muted)" font-size="${9*S}" font-style="italic">${Q(o)}</text>`}return P}function nu(e){return P(e.kind,`icon-only`)}function ru(e){return e.kind===`initial`||e.kind===`final`||e.kind===`junction`}function iu(e){return!e.icon||e.icon===`none`?null:e.icon}function au(e,t,n,r,i=!1){let a=g(e,r,{hasIconColor:i});return h(e,t,n,{height:14,paint:a,color:a===`theme`?`var(--icon-color, var(--kd-muted))`:void 0,className:`flow-group-label-icon`})}function ou(e,t,n,r,i=!1){let a=g(e,r,{hasIconColor:i});return h(e,t,n,{height:12,paint:a,color:a===`theme`?`var(--icon-color, var(--kd-edge-label-text))`:void 0,className:`flow-edge-label-icon`})}function su(e,t,n,r=1,i,a=!1){let o=20*r,s=g(e,i,{hasIconColor:a});return h(e,t,n,{height:o,paint:s,color:s===`theme`?`var(--icon-color, var(--node-stroke, var(--kd-node-stroke)))`:void 0,className:`flow-node-icon-mark`})}var cu={fontSize:11,fontFamily:q,fontWeight:`700`},lu=36,uu=28,du=24;function fu(e,t){return e.map(e=>{let n=e.points,r=[];for(let e=0;e<n.length-1;e++)r.push({from:n[e],to:n[e+1]});let i=t?.get(e.edgeId);return{edgeId:e.edgeId,points:n,segments:r,cubics:i}})}function pu(e,t,n){let r=e.length>0?n.measureText(e,cu):{width:0,height:cu.fontSize*1.2},i=t?12+(e.length>0?4:0):0,a=t&&e.length===0?22:28;return{width:Math.max(a,r.width+i+16),height:Math.max(18,Math.ceil(r.height)+10)}}function mu(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return i<=n||a<=r?0:(i-n)*(a-r)}function hu(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function gu(e,t){return hu(e,{x:Math.min(Math.max(e.x,t.x),t.x+t.width),y:Math.min(Math.max(e.y,t.y),t.y+t.height)})}function _u(e){let t=0;for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];t+=hu(r,i)}return t}function vu(e,t){let n=e[0]??t,r=1/0;for(let i=0;i<e.length-1;i++){let a=e[i],o=e[i+1],s=o.x-a.x,c=o.y-a.y,l=s*s+c*c,u=l<1e-8?0:Math.min(1,Math.max(0,((t.x-a.x)*s+(t.y-a.y)*c)/l)),d={x:a.x+s*u,y:a.y+c*u},f=hu(t,d);f<r&&(r=f,n=d)}return n}function yu(e,t){let n=vu(t,{x:e.x+e.width/2,y:e.y+e.height/2});return hu(n,{x:Math.min(Math.max(n.x,e.x),e.x+e.width),y:Math.min(Math.max(n.y,e.y),e.y+e.height)})}function bu(e,t,n,r,i,a,o,s){let c=0;for(let t of n){let n=mu(e,t);n>0?c+=n*10:ye(e,t,4)&&(c+=4)}if(r.length>=2){let e=r[0],n=r[r.length-1],i=hu(t,e),a=hu(t,n);i<lu&&(c+=(lu-i)*2),a<lu&&(c+=(lu-a)*2);for(let e=1;e<r.length-1;e++){let n=hu(t,r[e]);n<uu&&(c+=(uu-n)*1.5)}}for(let t of i){let n=gu(t,e);n<du&&(c+=(du-n)*3)}let l=o===`start`?.22:o===`end`?.78:.5,u=Math.max(1,_u(r)),d=s?3.4:.55;c+=Math.abs(a-l)*u*d;let f=yu(e,r);return f>2&&(c+=(f-2)*6),c}function xu(e,t,n,r,i=[],a={}){let o=a.measurer??kn,s=a.crossings??[],c=a.position??`middle`,l=a.authoredPosition===!0,{width:u,height:d}=pu(t,a.hasIcon===!0,o),f=n[Math.floor(n.length/2)]??{x:0,y:0},p=Math.max(1,_u(n)),m=[],h=(e,t,i,a)=>{m.push({anchor:e,bounds:t,score:bu(t,e,r,n,s,a,c,l),length:i})},g=0;for(let e=0;e<n.length-1;e++){let t=n[e],r=n[e+1],i=hu(t,r),a=i>40?[.2,.35,.5,.65,.8]:[.5];for(let e of a){let n={x:t.x+(r.x-t.x)*e,y:t.y+(r.y-t.y)*e},a=(g+e*i)/p,o=r.x-t.x,s=r.y-t.y,c=Math.abs(o)<.5?[{dx:4,dy:-d/2},{dx:-u-4,dy:-d/2},{dx:4,dy:-d-4},{dx:-u-4,dy:-d-4},{dx:4,dy:4},{dx:-u-4,dy:4}]:Math.abs(s)<.5?[{dx:-u/2,dy:-d-4},{dx:-u/2,dy:4},{dx:-u/2,dy:-d/2},{dx:-u-4,dy:-d/2},{dx:4,dy:-d/2}]:(()=>{let e=Math.hypot(o,s)||1,t=-s/e*(d/2+4),n=o/e*(d/2+4);return[{dx:-u/2+t,dy:-d/2+n},{dx:-u/2-t,dy:-d/2-n},{dx:-u/2,dy:-d-4},{dx:-u/2,dy:4}]})();for(let{dx:e,dy:t}of c)h(n,{x:n.x+e,y:n.y+t,width:u,height:d},i,a)}g+=i}let _=i.length?i:r;if(_.length&&n.length>=2){let e=c===`start`?.22:c===`end`?.78:.5,t=0,r=e*p,i=n[0];for(let e=0;e<n.length-1;e++){let a=n[e],o=n[e+1],s=Math.abs(a.x-o.x)+Math.abs(a.y-o.y);if(t+s>=r||e===n.length-2){let e=s>0?Math.min(1,Math.max(0,(r-t)/s)):.5;i={x:a.x+(o.x-a.x)*e,y:a.y+(o.y-a.y)*e};break}t+=s}let a=Math.min(..._.map(e=>e.y)),o=Math.max(..._.map(e=>e.y+e.height));h(i,{x:i.x-u/2,y:a-d-4,width:u,height:d},1,e),h(i,{x:i.x-u/2,y:o+4,width:u,height:d},1,e),h(i,{x:i.x+4,y:i.y-d/2,width:u,height:d},1,e),h(i,{x:i.x-u-4,y:i.y-d/2,width:u,height:d},1,e)}m.sort((e,t)=>e.score-t.score||t.length-e.length);let v=m[0];if(v){let r=vu(n,{x:v.bounds.x+v.bounds.width/2,y:v.bounds.y+v.bounds.height/2});return{edgeId:e,text:t,bounds:v.bounds,anchor:r}}return{edgeId:e,text:t,bounds:{x:f.x-u/2,y:f.y-d-6,width:u,height:d},anchor:f}}function Su(e,t){return t.size?e.map(e=>{let n=t.get(e.edgeId);return!n?.length||e.segments.some(e=>e.type===`gap`||e.type===`jump`)?e:{edgeId:e.edgeId,segments:n.map(e=>({type:`cubic`,from:e.from,c1:e.c1,c2:e.c2,to:e.to}))}}):e}function Cu(e){let{graph:t,layout:n,edgePaths:r,routingOpts:i}=e;if(t.diagramKind===`sequence`||n.sequence){let e=fu(r),t=e.map(e=>({edgeId:e.edgeId,segments:e.segments.map(e=>({type:`line`,from:e.from,to:e.to}))}));return{labels:(n.edgeLabels??[]).map(e=>({edgeId:e.edgeId,text:e.text,bounds:e.bounds,anchor:e.anchor})),treatedEdges:t,routingEdges:e}}let a=e.measurer??kn,o=ss(t,n,r),s=i.route??`metro`,c=ic(o.map(e=>{let n=t.edges.find(t=>t.id===e.edgeId);return{edgeId:e.edgeId,fromId:n?.from??``,toId:n?.to??``,points:e.points}}),n.nodes.map(e=>({id:e.nodeId,bounds:e.bounds})),s,i.parallel,i.cornerRadius),l=new Map(c.filter(e=>e.cubics?.length).map(e=>[e.edgeId,e.cubics])),u=c.map(e=>({edgeId:e.edgeId,points:e.points})),d=fu(u,l),f=xc(d),p=new Map(n.nodes.map(e=>[e.nodeId,e.bounds])),m=n.nodes.map(e=>e.bounds),h=[],g=[];for(let e of t.edges){let t=u.find(t=>t.edgeId===e.id);if(!t||t.points.length<2)continue;let r=!!(e.cardinality&&ne(e.label)),i;e.fromColumn||e.toColumn,e.label&&!r&&(i=e.label);let o=!!(e.icon&&e.icon!==`none`);if(!i&&!o){let t=n.edgeLabels.find(t=>t.edgeId===e.id);t&&!r&&(h.push({edgeId:t.edgeId,text:t.text,bounds:t.bounds,anchor:t.anchor}),g.push(t.bounds));continue}let s=[p.get(e.from),p.get(e.to)].filter(e=>e!=null),c=xu(e.id,i??``,t.points,[...m,...g],s,{hasIcon:o,measurer:a,crossings:f,position:e.labelPosition,authoredPosition:e.labelPosition!=null});h.push(c),g.push(c.bounds)}let _=Su(yc(d,i.crossings??`none`),l),v=i.arrowheads!==!1;return{labels:h,treatedEdges:Ec(_,{sourceInset:e=>{let n=t.edges.find(t=>t.id===e);return n?.cardinality?uc:lc(n,v).start?sc:1},targetInset:e=>{let n=t.edges.find(t=>t.id===e);return n?.cardinality?uc:lc(n,v).end?sc:1}}),routingEdges:d}}var wu=16/9,Tu={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}};function Eu(e,t,n){let r=t.width/Math.max(1,t.height),i=xc(n).length,a=t.edgePaths.filter(e=>{if(e.points.length<2)return!1;let n=e.points.map(e=>e.x),r=e.points.map(e=>e.y),i=Math.max(...n)-Math.min(...n),a=Math.max(...r)-Math.min(...r),o=0;for(let t=1;t<e.points.length;t++){let n=e.points[t-1],r=e.points[t];o+=Math.abs(r.x-n.x)+Math.abs(r.y-n.y)}return Math.max(i/Math.max(1,t.width),a/Math.max(1,t.height))>.72&&o>.8*(t.width+t.height)}).length,o=new Map(t.nodes.map(e=>[e.nodeId,e.bounds])),s=t.direction===`LR`||t.direction===`RL`,c=e.edges.filter(e=>{let n=o.get(e.from),r=o.get(e.to);if(!n||!r)return!1;let i=s?n.x+n.width/2:n.y+n.height/2,a=s?r.x+r.width/2:r.y+r.height/2,c=t.direction===`RL`||t.direction===`BT`?-1:1;return(i-a)*c>24}).length,l=e.edges.filter(e=>e.label?.trim()).length,u={width:t.width,height:t.height,aspectRatio:Number(r.toFixed(3)),targetAspectRatio:Number(wu.toFixed(3)),targetAspectRatioDifference:Number(Math.abs(r-wu).toFixed(3)),edgeCrossings:i,canvasSpanningEdges:a,reverseFlowEdges:c,labeledEdges:l};if(e.nodes.length<6)return{metrics:u,diagnostics:[]};let d=[],f=Math.max(r,1/Math.max(.001,r));return f>3&&d.push({severity:`warning`,code:`extreme-aspect-ratio`,message:`Diagram canvas is extremely ${t.width>t.height?`wide`:`tall`} (${f.toFixed(1)}:1)`,range:Tu,hint:`Aim near 16:9 by trying another direction, a bounded grid, shorter labels, or multiple views.`}),a>=3&&d.push({severity:`warning`,code:`canvas-spanning-edges`,message:`${a} edges span most of the canvas`,range:Tu,hint:`Separate feedback behavior, reduce cross-region relationships, or use progressive views.`}),i>=Math.max(5,Math.ceil(e.edges.length/3))&&d.push({severity:`warning`,code:`excessive-edge-crossings`,message:`Diagram contains ${i} edge crossings`,range:Tu,hint:`Reorder regions, choose a different layout, or split secondary relationships into another view.`}),c>=Math.max(3,Math.ceil(e.edges.length*.2))&&d.push({severity:`warning`,code:`reverse-layout-flow`,message:`${c} transitions run against the primary layout direction`,range:Tu,hint:`Move retry behavior to a focused view or use responsibility lanes and explicit stages.`}),e.edges.length>e.nodes.length*1.6&&l>=12&&d.push({severity:`warning`,code:`edge-label-pressure`,message:`Edge-label pressure is high for the number of nodes`,range:Tu,hint:`Keep the primary story and move secondary conditions or event catalogs into another view.`}),{metrics:u,diagnostics:d}}var Du={direction:`LR`,density:`normal`,spacingScale:1.1,algorithmVersion:`elk-layered-v1`,groupLayout:`compound`,nodePlacement:`balanced`},Ou={route:`metro`,crossings:`gaps`,arrowheads:!0},ku={theme:`dark`,shadows:!1,roundedCorners:!1};function Au(e){let t=u(e);return{ast:t,diagnostics:t.diagnostics}}function ju(e,t=0){let{ast:n}=Au(e);return v(n,t)}function Mu(e={}){return e.view==null?e.diagramIndex==null?0:e.diagramIndex:{diagramIndex:e.diagramIndex??0,view:e.view}}async function Nu(e,t={}){let n=ve(Du,t);return(await ns(e,er(e).nodes,n)).layout}function Pu(e,t,n={}){let r=ve(Ou,n),i=performance.now(),a=Cu({graph:e,layout:t,edgePaths:t.edgePaths,routingOpts:r});return{labels:a.labels,treatedEdges:a.treatedEdges,routing:{edges:a.routingEdges,algorithmVersion:gi,routeMs:performance.now()-i,diagnostics:[]}}}async function Fu(e,t={}){let n=performance.now(),r=[],a=performance.now(),{ast:o,diagnostics:c}=Au(e);r.push(...c);let u=performance.now()-a,d=performance.now(),f=v(o,Mu(t));r.push(...f.diagnostics);let p=f.graph,m=performance.now()-d;if(r.some(e=>e.severity===`error`))return Iu(r,{parseMs:u,compileMs:m,measureMs:0,layoutMs:0,routeMs:0,renderMs:0,totalMs:performance.now()-n,nodeCount:p.nodes.length,edgeCount:p.edges.length,layoutAlgorithm:hi,routerAlgorithm:gi});let h=ve(Du,f.layoutHints,t.layout),g=ve(Ou,f.routingHints,t.edges),_=ve(ku,f.renderHints,t);_.presentation=w(f.renderHints.presentation,t.presentation);let y=l(_.presentation,p.title);await s(i([...p.nodes,...p.edges,...p.groups]));let b=performance.now(),x=er(p,void 0,{reserveKindSubtitles:y.showKindSubtitles}),S=performance.now()-b;Sn()&&r.push({severity:`warning`,code:`FM210`,message:`Text measurement using approximation fallback; bundled font unavailable`,range:{start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}},hint:`Install @fontsource/inter for shared CLI/browser metrics`});let ee=performance.now(),C=await ns(p,x.nodes,h),T=C.layout,E=performance.now()-ee,D=performance.now(),O=Cu({graph:p,layout:T,edgePaths:T.edgePaths,routingOpts:g});r.push(...Eu(p,T,O.routingEdges).diagnostics);let k=performance.now()-D,A={edges:O.routingEdges,algorithmVersion:C.routerAlgorithm,routeMs:k,diagnostics:[]},j=performance.now(),M=Zl({graph:p,layout:T,measured:x.nodes,treatedEdges:O.treatedEdges,labels:O.labels,options:_,routingOptions:{route:g.route??`orthogonal`,cornerRadius:g.cornerRadius,arrowheads:g.arrowheads}}),N={parseMs:u,compileMs:m,measureMs:S,layoutMs:E,routeMs:k,renderMs:performance.now()-j,totalMs:performance.now()-n,nodeCount:p.nodes.length,edgeCount:p.edges.length,layoutAlgorithm:T.algorithmVersion,routerAlgorithm:A.algorithmVersion};return{ok:!0,svg:M,ast:o,graph:p,layout:T,routing:A,labels:O.labels,diagnostics:r,stats:N}}function Iu(e,t){return{ok:!1,diagnostics:e,stats:t}}function Lu(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ru(e){let t=[],n=0,r=(e,n)=>{if(e.op===`dim`||e.op===`activate`)return t.push({startMs:n,endMs:n,cue:e}),0;if(e.op===`wait`||e.op===`pulse`||e.op===`flow`){let r=Math.max(0,e.durationMs);return t.push({startMs:n,endMs:n+r,cue:e}),r}if(e.op===`parallel`){let t=0;for(let i of e.cues)t=Math.max(t,r(i,n));return t}return 0};for(let t of e)n+=r(t,n);return{timed:t,durationMs:n}}function zu(e,t,n,r=!1){let i=!1,a=new Set,o=new Set,s=new Set,c=[],l=[],u=(e,t)=>{let n=e.path[t],r=e.path[t+1];o.add(`${n}->${r}`);let i=ge(t,e);i&&s.add(i)};for(let d of e){if(d.startMs>t)break;let e=d.cue;if(e.op===`dim`)for(let t of e.targets)t.type===`all`&&(i=!0,a.clear(),o.clear(),s.clear(),c.length=0,l.length=0);else if(e.op===`activate`)for(let t of e.targets)if(t.type===`all`)for(let e of n)a.add(e);else t.type===`node`?a.add(t.id):o.add(`${t.from}->${t.to}`);else if(e.op===`pulse`){if(t>=d.startMs&&t<=d.endMs&&!r){c.push(...e.targets);for(let t of e.targets)t.type===`node`&&a.add(t.id),t.type===`edge`&&o.add(`${t.from}->${t.to}`)}}else if(e.op===`flow`){if(t>=d.startMs&&t<=d.endMs){let n=Math.max(1,d.endMs-d.startMs),i=r?1:(t-d.startMs)/n;l.push({path:e.path,progress:i,edgeId:e.edgeId,edgeIds:e.edgeIds});let o=Math.max(1,e.path.length-1);for(let t=0;t<e.path.length;t++)i>=t/o-.001&&a.add(e.path[t]),e.path[t+1]&&i>=t/o&&u(e,t)}else if(t>d.endMs){for(let t of e.path)a.add(t);for(let t=0;t<e.path.length-1;t++)u(e,t)}}}return{dimAll:i,activeNodes:a,activeEdges:o,activeEdgeIds:s,pulseTargets:c,flows:l}}var Bu=class{#e=null;#t=null;#n=[];#r=null;#i=[];#a=0;#o=0;#s=!1;#c=!1;#l=1;#u=null;#d=0;#f=new Set;#p=null;list(){return this.#n.map(e=>({id:e.id,name:e.name,source:e.source}))}getState(){return{id:this.#r?.id??null,playing:this.#s,timeMs:this.#o,durationMs:this.#a,loop:this.#c,speed:this.#l}}subscribe(e){return this.#f.add(e),e(this.getState()),()=>this.#f.delete(e)}rebind(e,t){let n=this.#r?.id??null,r=this.#o,i=this.#s,a=this.#c,o=this.#l;if(this.#b(),this.#e=e,this.#t=t,this.#m(),!e||!t){this.#r=null,this.#i=[],this.#a=0,this.#o=0,this.#s=!1,this.#g();return}let s=n&&this.#n.find(e=>e.id===n)||this.#n[0]||null;this.#h(s,!1),s&&n===s.id&&(this.#c=a),this.#l=o,s?(this.seek(Math.min(r,this.#a)),i&&this.play()):this.#g()}play(e){if(e){let t=this.#n.find(t=>t.id===e);t&&this.#h(t,!0)}else this.#r||this.#h(this.#n[0]??null,!0);!this.#r||this.#a<=0?(this.#S(0),this.#g()):(this.#o>=this.#a&&(this.#o=0),this.#s=!0,this.#d=performance.now(),this.#_(),this.#g())}pause(){this.#s=!1,this.#v(),this.#g()}stop(){this.#s=!1,this.#v(),this.#o=0,this.#x(),this.#g()}seek(e){this.#o=Math.max(0,Math.min(this.#a,e)),this.#S(this.#o),this.#g()}step(e){if(this.#i.length===0)return;let t=[...new Set(this.#i.flatMap(e=>[e.startMs,e.endMs]))].sort((e,t)=>e-t);if(e>0){let e=t.find(e=>e>this.#o+.5);this.seek(e??this.#a)}else{let e=[...t].reverse().find(e=>e<this.#o-.5);this.seek(e??0)}}setLoop(e){this.#c=e,this.#g()}setSpeed(e){Number.isFinite(e)&&(this.#l=Math.min(2,Math.max(.5,e)),this.#g())}destroy(){this.stop(),this.#f.clear(),this.#e=null,this.#t=null,this.#n=[]}#m(){if(!this.#t){this.#n=[];return}let e=this.#t.animations??[],t=[];for(let n of e)if(n.source===`auto`){let e=B(this.#t);if(!e)continue;t.push({...e,id:n.id,name:n.name,loop:n.loop,source:`auto`})}else t.push({...n,cues:_e(this.#t,n.cues)});this.#n=t}#h(e,t){if(this.#r=e,!e){this.#i=[],this.#a=0,this.#o=0,this.#c=!1,this.#x();return}let n=Ru(e.cues);this.#i=n.timed,this.#a=n.durationMs,this.#c=e.loop,t&&(this.#o=0),this.#S(this.#o)}#g(){let e=this.getState();for(let t of this.#f)t(e)}#_(){this.#v(),this.#u=requestAnimationFrame(this.#y)}#v(){this.#u!=null&&(cancelAnimationFrame(this.#u),this.#u=null)}#y=e=>{if(!this.#s)return;let t=(e-this.#d)*this.#l;if(this.#d=e,this.#o+=t,this.#o>=this.#a){if(this.#c&&this.#a>0)this.#o%=this.#a;else{this.#o=this.#a,this.#s=!1,this.#S(this.#o),this.#g();return}}this.#S(this.#o),this.#g(),this.#_()};#b(){this.#v(),this.#x()}#x(){if(this.#e){for(let e of this.#e.querySelectorAll(`.flow-anim-dim, .flow-anim-active, .flow-anim-pulse`))e.classList.remove(`flow-anim-dim`,`flow-anim-active`,`flow-anim-pulse`);this.#p?.remove(),this.#p=null}}#S(e){if(!this.#e||!this.#t)return;this.#x();let t=Lu(),{dimAll:n,activeNodes:r,activeEdges:i,activeEdgeIds:a,pulseTargets:o,flows:s}=zu(this.#i,e,this.#t.nodes.map(e=>e.id),t);if(n){for(let e of this.#e.querySelectorAll(`[data-node-id], g.flow-edge[data-edge-id], .flow-sequence-activation, g.flow-sequence-fragment, .flow-sequence-fragment-operand, g.flow-sequence-note, g.flow-sequence-divider`))e.classList.add(`flow-anim-dim`);for(let e of this.#e.querySelectorAll(`g.flow-edge-label`))e.classList.add(`flow-anim-dim`)}for(let e of r)for(let t of this.#D(e))t.classList.remove(`flow-anim-dim`),t.classList.add(`flow-anim-active`);if(this.#t.sequence)for(let e of a)this.#w(e);else for(let e of i){let[t,n]=e.split(`->`);if(t&&n)for(let e of this.#O(t,n)){e.classList.remove(`flow-anim-dim`),e.classList.add(`flow-anim-active`);let t=e.getAttribute(`data-edge-id`);t&&this.#T(t)}}if(this.#C(n,a),o.length)for(let e of o)e.type===`node`?this.#D(e.id).forEach(e=>e.classList.add(`flow-anim-pulse`)):e.type===`edge`&&this.#O(e.from,e.to).forEach(e=>e.classList.add(`flow-anim-pulse`));s.length&&!t&&this.#M(s)}#C(e,t){if(!this.#e||!this.#t?.sequence)return;let n=new Set;for(let e of t)for(let t of this.#E(e)){let e=t.getAttribute(`data-sequence-order`);if(e==null)continue;let r=Number(e);Number.isFinite(r)&&n.add(r)}if(n.size===0&&!e)return;let r=t=>{let r=Number(t.getAttribute(`data-start-order`)),i=Number(t.getAttribute(`data-end-order`));if(!Number.isFinite(r)||!Number.isFinite(i))return;let a=!1;for(let e of n)if(r<=e&&e<=i){a=!0;break}a?(t.classList.remove(`flow-anim-dim`),t.classList.add(`flow-anim-active`)):e&&(t.classList.add(`flow-anim-dim`),t.classList.remove(`flow-anim-active`))};for(let e of this.#e.querySelectorAll(`.flow-sequence-activation`))r(e);for(let e of this.#e.querySelectorAll(`g.flow-sequence-fragment`))r(e);for(let e of this.#e.querySelectorAll(`.flow-sequence-fragment-operand`))r(e)}#w(e){for(let t of this.#E(e))t.classList.remove(`flow-anim-dim`),t.classList.add(`flow-anim-active`);this.#T(e)}#T(e){if(this.#e)for(let t of this.#e.querySelectorAll(`g.flow-edge-label[data-edge-id="${Vu(e)}"]`))t.classList.remove(`flow-anim-dim`),t.classList.add(`flow-anim-active`)}#E(e){return this.#e?[...this.#e.querySelectorAll(`g.flow-edge[data-edge-id="${Vu(e)}"]`)]:[]}#D(e){return this.#e?[...this.#e.querySelectorAll(`[data-node-id="${Vu(e)}"]`)]:[]}#O(e,t,n){if(!this.#e)return[];if(n){let e=this.#E(n);if(e.length)return e}return[...this.#e.querySelectorAll(`g.flow-edge[data-edge-from="${Vu(e)}"][data-edge-to="${Vu(t)}"]`)]}#k(e,t,n){let r=this.#O(e,t,n)[0];if(!r)return[];let i=[];for(let e of r.querySelectorAll(`path.flow-edge-path, path.flow-edge-jump`)){let t=e.getAttribute(`d`);t&&i.push(t)}return i}#A(e,t,n){let r=this.#O(e,t,n)[0]?.querySelector(`path.flow-edge-path, path.flow-edge-jump`);if(!r)return null;let i=getComputedStyle(r).stroke;return!i||i===`none`?null:i}#j(){return this.#e?.querySelector(`g.flow-diagram-content`)??this.#e}#M(e){if(!this.#e)return;let t=this.#j(),n=document.createElementNS(`http://www.w3.org/2000/svg`,`g`);n.setAttribute(`class`,`flow-anim-flow-layer`),n.style.pointerEvents=`none`;let r=!1;for(let i of e)i.path.length<2||this.#N(n,t,i)&&(r=!0);r&&(t.appendChild(n),this.#p=n)}#N(e,t,n){let{path:r,progress:i}=n,a=[];for(let e=0;e<r.length-1;e++){let i=r[e],o=r[e+1],s=ge(e,n),c=this.#k(i,o,s),l=[];for(let e of c){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);n.setAttribute(`d`,e),n.setAttribute(`visibility`,`hidden`),t.appendChild(n),l.push({d:e,len:n.getTotalLength?.()??0,probe:n})}a.push({stroke:this.#A(i,o,s),segs:l})}if(!a.some(e=>e.segs.length>0)){for(let e of a)for(let t of e.segs)t.probe.remove();return!1}let o=Math.max(0,Math.min(1,i)),s=a.length,c=o*s,l=o>=1?s-1:Math.min(s-1,Math.floor(c)),u=o>=1?1:c-l,d=null,f=null;for(let t=0;t<s;t++){let n=a[t],r=n.segs,i=r.reduce((e,t)=>e+t.len,0),o=t<l?i:t>l?0:Math.max(0,Math.min(i,u*i)),s=0;for(let t of r){let r=Math.max(0,Math.min(t.len,o-s));if(r>0&&t.len>0){let i=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);i.setAttribute(`class`,`flow-anim-flow-track`),i.setAttribute(`d`,t.d),i.style.strokeDasharray=`${t.len}`,i.style.strokeDashoffset=`${t.len-r}`,n.stroke&&(i.style.stroke=`color-mix(in srgb, ${n.stroke} 40%, transparent)`),e.appendChild(i);let a=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);a.setAttribute(`class`,`flow-anim-flow-overlay`),a.setAttribute(`d`,t.d),a.style.strokeDasharray=`${t.len}`,a.style.strokeDashoffset=`${t.len-r}`,n.stroke&&(a.style.stroke=n.stroke),e.appendChild(a);let c=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);c.setAttribute(`class`,`flow-anim-flow-core`),c.setAttribute(`d`,t.d),c.style.strokeDasharray=`${t.len}`,c.style.strokeDashoffset=`${t.len-r}`,n.stroke&&(c.style.stroke=`color-mix(in srgb, ${n.stroke} 35%, white)`),e.appendChild(c),o>=s&&o<=s+t.len?(d=t.probe.getPointAtLength(r),f=n.stroke):o>s+t.len&&(d=t.probe.getPointAtLength(t.len),f=n.stroke)}s+=t.len}}for(let e of a)for(let t of e.segs)t.probe.remove();if(d&&o>0&&o<1){let t=document.createElementNS(`http://www.w3.org/2000/svg`,`circle`);t.setAttribute(`class`,`flow-anim-flow-head`),t.setAttribute(`cx`,String(d.x)),t.setAttribute(`cy`,String(d.y)),t.setAttribute(`r`,`5.5`),f&&(t.style.fill=`color-mix(in srgb, ${f} 35%, white)`,t.style.stroke=f),e.appendChild(t)}return!0}};function Vu(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/["\\]/g,`\\$&`)}var Hu=`modifier`,Uu=1600;function Wu(e){return e===`always`?`always`:Hu}function Gu(e,t){return Wu(t)===`always`||e.ctrlKey||e.metaKey}function Ku(e=qu()){return Ju(e)?`Use ⌘ + scroll to zoom`:`Use Ctrl + scroll to zoom`}function qu(){return typeof navigator>`u`?``:navigator.platform||navigator.userAgent}function Ju(e){return/Mac|iPhone|iPad|iPod/i.test(e)}var Yu={parse(e){return Au(e)},compile(e,t){return ju(e)},async layout(e,t){return Nu(e,t)},route(e,t,n){return Pu(e,t,n)},format(e){return S(e)},async ensureFonts(){let{default:e}=await a(async()=>{let{default:e}=await import(`./inter-latin-500-normal-DPWUe_Rm.js`);return{default:e}},[],import.meta.url);await as(e),Dn()},async renderToSvg(e,t){return Fu(e,t)},renderToElement(e,t,n){let r=n?.theme??`dark`,i={...n},a={x:0,y:0,w:1,h:1},o={...a},s=!1,c={x:0,y:0,w:0,h:0},l={x:0,y:0},u=!1,d=null,f=null,p=document.createElement(`div`);p.className=`kdiagram-viewport kdiagram-theme-${r}`,p.style.cssText=`width:100%;height:100%;overflow:hidden;position:relative;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none;`;let m=()=>{for(let[e,n]of Object.entries(x(r)))p.style.setProperty(e,n),t.style.setProperty(e,n)};m();let h=document.createElement(`div`);h.className=`kdiagram-canvas`,h.style.cssText=`width:100%;height:100%;user-select:none;-webkit-user-select:none;`;let g=document.createElement(`div`);g.className=`kdiagram-zoom-hint`,g.setAttribute(`role`,`status`),g.setAttribute(`aria-hidden`,`true`),p.appendChild(h),p.appendChild(g),t.innerHTML=``,t.appendChild(p);let _=`${b}
|
|
23
|
+
.kdiagram-viewport, .kdiagram-viewport svg, .kdiagram-viewport text {
|
|
24
|
+
user-select: none;
|
|
25
|
+
-webkit-user-select: none;
|
|
26
|
+
}
|
|
27
|
+
.kdiagram-viewport svg { display:block; width:100%; height:100%; }
|
|
28
|
+
.kdiagram-zoom-hint {
|
|
29
|
+
position: absolute;
|
|
30
|
+
left: 50%;
|
|
31
|
+
top: 50%;
|
|
32
|
+
transform: translate(-50%, -50%);
|
|
33
|
+
margin: 0;
|
|
34
|
+
padding: 0.5rem 0.75rem;
|
|
35
|
+
border-radius: 0.5rem;
|
|
36
|
+
background: color-mix(in oklch, var(--kd-bg, Canvas) 18%, var(--kd-text, CanvasText) 82%);
|
|
37
|
+
color: var(--kd-bg, Canvas);
|
|
38
|
+
font: 600 12px/1.4 system-ui, sans-serif;
|
|
39
|
+
letter-spacing: 0.01em;
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
z-index: 2;
|
|
42
|
+
opacity: 0;
|
|
43
|
+
visibility: hidden;
|
|
44
|
+
transition: opacity 120ms ease, visibility 120ms ease;
|
|
45
|
+
}
|
|
46
|
+
.kdiagram-zoom-hint[data-visible="true"] {
|
|
47
|
+
opacity: 1;
|
|
48
|
+
visibility: visible;
|
|
49
|
+
}
|
|
50
|
+
@media (prefers-reduced-motion: reduce) {
|
|
51
|
+
.kdiagram-zoom-hint { transition: none; }
|
|
52
|
+
}`,v=document.getElementById(`kdiagram-theme-css`);v||(v=document.createElement(`style`),v.id=`kdiagram-theme-css`,document.head.appendChild(v)),v.textContent=_;let y=e,S=new Bu,ee=e=>{let t=(e.getAttribute(`viewBox`)??`0 0 1 1`).trim().split(/\s+/).map(Number);return{x:t[0]??0,y:t[1]??0,w:t[2]??1,h:t[3]??1}},C=()=>{let e=h.querySelector(`svg`);e&&(e.setAttribute(`viewBox`,`${o.x} ${o.y} ${o.w} ${o.h}`),e.setAttribute(`preserveAspectRatio`,`xMidYMid meet`),e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`)},w=(e,t)=>{let n=p.getBoundingClientRect(),r=(e-n.left)/n.width,i=(t-n.top)/n.height;return{x:o.x+r*o.w,y:o.y+i*o.h}},T=(e,t,n)=>{let r=w(e,t),i=a.w/4,s=a.w/.15,c=Math.min(s,Math.max(i,o.w*n)),l=c/o.w,u=o.h*l;o={x:r.x-(r.x-o.x)*l,y:r.y-(r.y-o.y)*l,w:c,h:u},C()},E=()=>{let e=p.clientWidth,t=p.clientHeight;if(!e||!t)return;let n=a.w*1.12,r=a.h*1.12,i=n/r,s=e/t,c,l;i>s?(c=n,l=c/s):(l=r,c=l*s),o={x:a.x+a.w/2-c/2,y:a.y+a.h/2-l/2,w:c,h:l},C()},D=async(e,t)=>{y=e,t&&(i={...i,...t});let n=u&&a.w>0?o.w/a.w:1,s=o.x+o.w/2,c=o.y+o.h/2,l=await Fu(e,{...i,theme:r});h.innerHTML=l.svg??``;let f=h.querySelector(`svg`);if(S.rebind(f,l.graph??null),f){if(a=ee(f),!u)u=!0,E(),(!p.clientWidth||!p.clientHeight)&&typeof ResizeObserver<`u`&&(d=new ResizeObserver(()=>{p.clientWidth&&p.clientHeight&&(E(),d?.disconnect(),d=null)}),d.observe(p));else{let e=a.w*n,t=a.h*n;o={x:s-e/2,y:c-t/2,w:e,h:t},C()}}return l},O=()=>{g.dataset.visible=`false`},k=()=>{g.textContent=Ku(),g.dataset.visible=`true`,f!=null&&clearTimeout(f),f=setTimeout(()=>{f=null,O()},Uu)},A=e=>{if(!h.querySelector(`svg`))return;if(!Gu(e,i.zoomOnWheel)){Math.abs(e.deltaY)>=Math.abs(e.deltaX)&&k();return}if(e.deltaY===0)return;e.preventDefault(),O();let t=e.deltaY>0?1.1:1/1.1;T(e.clientX,e.clientY,t)},j=e=>{(e.button===0||e.button===1)&&(e.preventDefault(),window.getSelection()?.removeAllRanges(),s=!0,c={...o},l={x:e.clientX,y:e.clientY},p.style.cursor=`grabbing`,p.setPointerCapture(e.pointerId))},M=e=>{if(!s)return;e.preventDefault();let t=(e.clientX-l.x)/p.clientWidth*o.w,n=(e.clientY-l.y)/p.clientHeight*o.h;o={...o,x:c.x-t,y:c.y-n},C()},N=e=>{s&&(s=!1,p.style.cursor=`grab`,p.releasePointerCapture(e.pointerId))},te=e=>{e.preventDefault()};p.addEventListener(`wheel`,A,{passive:!1}),p.addEventListener(`pointerdown`,j),p.addEventListener(`pointermove`,M),p.addEventListener(`pointerup`,N),p.addEventListener(`pointercancel`,N),p.addEventListener(`selectstart`,te);let P=D(e,n);return{async update(e,t){return D(e,t)},async setTheme(e){return r=e,p.className=`kdiagram-viewport kdiagram-theme-${e}`,m(),D(y)},ready(){return P},fit(){E()},zoomIn(){let e=p.getBoundingClientRect();T(e.left+e.width/2,e.top+e.height/2,1/1.2)},zoomOut(){let e=p.getBoundingClientRect();T(e.left+e.width/2,e.top+e.height/2,1.2)},resetView(){E()},animations:S,destroy(){S.destroy(),d?.disconnect(),d=null,f!=null&&(clearTimeout(f),f=null),p.removeEventListener(`wheel`,A),p.removeEventListener(`pointerdown`,j),p.removeEventListener(`pointermove`,M),p.removeEventListener(`pointerup`,N),p.removeEventListener(`pointercancel`,N),p.removeEventListener(`selectstart`,te),p.remove()}}}};export{Yu as KDiagram};
|