finch-markdown-editor 0.2.5 → 0.2.6

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.
@@ -0,0 +1,71 @@
1
+ import{a as e,i as t,t as n}from"./rolldown-runtime-8V8biNmG.mjs";function r(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}const i=[`default`,`dark`,`hand-drawn`],a=[`antv`,`spectral`],o=i.map(e=>({id:e,name:r(e),isDark:e===`dark`})),s=a.map(e=>({id:e,name:r(e)})),c=o.map(e=>e.id),l=s.map(e=>e.id);function u(e){return i.includes(e)}function d(e){return a.includes(e)}const f=[{id:`kami`,name:`Kami`},{id:`bauhaus`,name:`Bauhaus`},{id:`blueprint`,name:`Blueprint`},{id:`botanical`,name:`Botanical`},{id:`newsprint`,name:`Newsprint`},{id:`retro`,name:`Retro`},{id:`sketch`,name:`Sketch`},{id:`terminal`,name:`Terminal`}],p=f.map(e=>e.id),m=`kami`,h=new Set([`kami`,`botanical`,`newsprint`]);function g(e){return e!=null&&f.some(t=>t.id===e)&&!h.has(e)?`sans-serif`:`serif`}var _=e(n(((e,n)=>{(function(t){if(typeof e==`object`&&n!==void 0)n.exports=t();else if(typeof define==`function`&&define.amd)define([],t);else{var r=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this;r.dagre=t()}})(function(){return(function(){function e(n,r,i){function a(s,c){if(!r[s]){if(!n[s]){var l=typeof t==`function`&&t;if(!c&&l)return l(s,!0);if(o)return o(s,!0);var u=Error(`Cannot find module '`+s+`'`);throw u.code=`MODULE_NOT_FOUND`,u}var d=r[s]={exports:{}};n[s][0].call(d.exports,function(e){var t=n[s][1][e];return a(t||e)},d,d.exports,e,n,r,i)}return r[s].exports}for(var o=typeof t==`function`&&t,s=0;s<i.length;s++)a(i[s]);return a}return e})()({1:[function(e,t,n){t.exports={graphlib:e("@dagrejs/graphlib"),layout:e("./lib/layout"),debug:e("./lib/debug"),util:{time:e("./lib/util").time,notime:e("./lib/util").notime},version:e("./lib/version")}},{"./lib/debug":6,"./lib/layout":8,"./lib/util":27,"./lib/version":28,"@dagrejs/graphlib":29}],2:[function(e,t,n){let r=e("./greedy-fas"),i=e("./util").uniqueId;t.exports={run:a,undo:s};function a(e){(e.graph().acyclicer===`greedy`?r(e,t(e)):o(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,i(`rev`))});function t(e){return t=>e.edge(t).weight}}function o(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function s(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}},{"./greedy-fas":7,"./util":27}],3:[function(e,t,n){let r=e("./util");t.exports=i;function i(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)a(e,`borderLeft`,`_bl`,n,i,t),a(e,`borderRight`,`_br`,n,i,t)}}e.children().forEach(t)}function a(e,t,n,i,a,o){let s={width:0,height:0,rank:o,borderType:t},c=a[t][o-1],l=r.addDummyNode(e,`border`,s,n);a[t][o]=l,e.setParent(l,i),c&&e.setEdge(c,l,{weight:1})}},{"./util":27}],4:[function(e,t,n){t.exports={adjust:r,undo:i};function r(e){let t=e.graph().rankdir.toLowerCase();(t===`lr`||t===`rl`)&&a(e)}function i(e){let t=e.graph().rankdir.toLowerCase();(t===`bt`||t===`rl`)&&s(e),(t===`lr`||t===`rl`)&&(l(e),a(e))}function a(e){e.nodes().forEach(t=>o(e.node(t))),e.edges().forEach(t=>o(e.edge(t)))}function o(e){let t=e.width;e.width=e.height,e.height=t}function s(e){e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(c),Object.hasOwn(n,`y`)&&c(n)})}function c(e){e.y=-e.y}function l(e){e.nodes().forEach(t=>u(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(u),Object.hasOwn(n,`x`)&&u(n)})}function u(e){let t=e.x;e.x=e.y,e.y=t}},{}],5:[function(e,t,n){class r{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return i(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&i(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,a)),n=n._prev;return`[`+e.join(`, `)+`]`}}function i(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function a(e,t){if(e!==`_next`&&e!==`_prev`)return t}t.exports=r},{}],6:[function(e,t,n){let r=e("./util"),i=e("@dagrejs/graphlib").Graph;t.exports={debugOrdering:a};function a(e){let t=r.buildLayerMatrix(e),n=new i({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}},{"./util":27,"@dagrejs/graphlib":29}],7:[function(e,t,n){let r=e("@dagrejs/graphlib").Graph,i=e("./data/list");t.exports=o;let a=()=>1;function o(e,t){if(e.nodeCount()<=1)return[];let n=l(e,t||a);return s(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))}function s(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)c(e,t,n,o);for(;o=i.dequeue();)c(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i].dequeue(),o){r=r.concat(c(e,t,n,o,!0));break}}}return r}function c(e,t,n,r,i){let a=i?[]:void 0;return e.inEdges(r.v).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,u(t,n,s)}),e.outEdges(r.v).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,u(t,n,o)}),e.removeNode(r.v),a}function l(e,t){let n=new r,a=0,o=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let r=n.edge(e.v,e.w)||0,i=t(e),s=r+i;n.setEdge(e.v,e.w,s),o=Math.max(o,n.node(e.v).out+=i),a=Math.max(a,n.node(e.w).in+=i)});let s=d(o+a+3).map(()=>new i),c=a+1;return n.nodes().forEach(e=>{u(s,c,n.node(e))}),{graph:n,buckets:s,zeroIdx:c}}function u(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}function d(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}},{"./data/list":5,"@dagrejs/graphlib":29}],8:[function(e,t,n){let r=e("./acyclic"),i=e("./normalize"),a=e("./rank"),o=e("./util").normalizeRanks,s=e("./parent-dummy-chains"),c=e("./util").removeEmptyRanks,l=e("./nesting-graph"),u=e("./add-border-segments"),d=e("./coordinate-system"),f=e("./order"),p=e("./position"),m=e("./util"),h=e("@dagrejs/graphlib").Graph;t.exports=g;function g(e,t){let n=t&&t.debugTiming?m.time:m.notime;n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>ne(e));n(` runLayout`,()=>_(r,n,t)),n(` updateInputGraph`,()=>v(e,r))})}function _(e,t,n){t(` makeSpaceForEdgeLabels`,()=>T(e)),t(` removeSelfEdges`,()=>ue(e)),t(` acyclic`,()=>r.run(e)),t(` nestingGraph.run`,()=>l.run(e)),t(` rank`,()=>a(m.asNonCompoundGraph(e))),t(` injectEdgeLabelProxies`,()=>re(e)),t(` removeEmptyRanks`,()=>c(e)),t(` nestingGraph.cleanup`,()=>l.cleanup(e)),t(` normalizeRanks`,()=>o(e)),t(` assignRankMinMax`,()=>ie(e)),t(` removeEdgeLabelProxies`,()=>ae(e)),t(` normalize.run`,()=>i.run(e)),t(` parentDummyChains`,()=>s(e)),t(` addBorderSegments`,()=>u(e)),t(` order`,()=>f(e,n)),t(` insertSelfEdges`,()=>de(e)),t(` adjustCoordinateSystem`,()=>d.adjust(e)),t(` position`,()=>p(e)),t(` positionSelfEdges`,()=>fe(e)),t(` removeBorderNodes`,()=>le(e)),t(` normalize.undo`,()=>i.undo(e)),t(` fixupEdgeLabelCoords`,()=>E(e)),t(` undoCoordinateSystem`,()=>d.undo(e)),t(` translateGraph`,()=>oe(e)),t(` assignNodeIntersects`,()=>se(e)),t(` reversePoints`,()=>ce(e)),t(` acyclic.undo`,()=>r.undo(e))}function v(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}let y=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],b={ranksep:50,edgesep:20,nodesep:50,rankdir:`tb`},x=[`acyclicer`,`ranker`,`rankdir`,`align`],S=[`width`,`height`,`rank`],C={width:0,height:0},ee=[`minlen`,`weight`,`width`,`height`,`labeloffset`],te={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},w=[`labelpos`];function ne(e){let t=new h({multigraph:!0,compound:!0}),n=O(e.graph());return t.setGraph(Object.assign({},b,D(n,y),m.pick(n,x))),e.nodes().forEach(n=>{let r=D(O(e.node(n)),S);Object.keys(C).forEach(e=>{r[e]===void 0&&(r[e]=C[e])}),t.setNode(n,r),t.setParent(n,e.parent(n))}),e.edges().forEach(n=>{let r=O(e.edge(n));t.setEdge(n,Object.assign({},te,D(r,ee),m.pick(r,w)))}),t}function T(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function re(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),r={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};m.addDummyNode(e,`edge-proxy`,r,`_ep`)}})}function ie(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function ae(e){e.nodes().forEach(t=>{let n=e.node(t);n.dummy===`edge-proxy`&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function oe(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function se(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(m.intersectRect(r,a)),n.points.push(m.intersectRect(i,o))})}function E(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset;break}})}function ce(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function le(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function ue(e){e.edges().forEach(t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function de(e){m.buildLayerMatrix(e).forEach(t=>{var n=0;t.forEach((t,r)=>{var i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{m.addDummyNode(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function fe(e){e.nodes().forEach(t=>{var n=e.node(t);if(n.dummy===`selfedge`){var r=e.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function D(e,t){return m.mapValues(m.pick(e,t),Number)}function O(e){var t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}},{"./acyclic":2,"./add-border-segments":3,"./coordinate-system":4,"./nesting-graph":9,"./normalize":10,"./order":15,"./parent-dummy-chains":20,"./position":22,"./rank":24,"./util":27,"@dagrejs/graphlib":29}],9:[function(e,t,n){let r=e("./util");t.exports={run:i,cleanup:c};function i(e){let t=r.addDummyNode(e,`root`,{},`_root`),n=o(e),i=Object.values(n),c=r.applyWithChunking(Math.max,i)-1,l=2*c+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=l);let u=s(e)+1;e.children().forEach(r=>a(e,t,l,u,c,n,r)),e.graph().nodeRankFactor=l}function a(e,t,n,i,o,s,c){let l=e.children(c);if(!l.length){c!==t&&e.setEdge(t,c,{weight:0,minlen:n});return}let u=r.addBorderNode(e,`_bt`),d=r.addBorderNode(e,`_bb`),f=e.node(c);e.setParent(u,c),f.borderTop=u,e.setParent(d,c),f.borderBottom=d,l.forEach(r=>{a(e,t,n,i,o,s,r);let l=e.node(r),f=l.borderTop?l.borderTop:r,p=l.borderBottom?l.borderBottom:r,m=l.borderTop?i:2*i,h=f===p?o-s[c]+1:1;e.setEdge(u,f,{weight:m,minlen:h,nestingEdge:!0}),e.setEdge(p,d,{weight:m,minlen:h,nestingEdge:!0})}),e.parent(c)||e.setEdge(t,u,{weight:0,minlen:o+s[c]})}function o(e){var t={};function n(r,i){var a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children().forEach(e=>n(e,1)),t}function s(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function c(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}},{"./util":27}],10:[function(e,t,n){let r=e("./util");t.exports={run:i,undo:o};function i(e){e.graph().dummyChains=[],e.edges().forEach(t=>a(e,t))}function a(e,t){let n=t.v,i=e.node(n).rank,a=t.w,o=e.node(a).rank,s=t.name,c=e.edge(t),l=c.labelRank;if(o===i+1)return;e.removeEdge(t);let u,d,f;for(f=0,++i;i<o;++f,++i)c.points=[],d={width:0,height:0,edgeLabel:c,edgeObj:t,rank:i},u=r.addDummyNode(e,`edge`,d,`_d`),i===l&&(d.width=c.width,d.height=c.height,d.dummy=`edge-label`,d.labelpos=c.labelpos),e.setEdge(n,u,{weight:c.weight},s),f===0&&e.graph().dummyChains.push(u),n=u;e.setEdge(n,a,{weight:c.weight},s)}function o(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}},{"./util":27}],11:[function(e,t,n){t.exports=r;function r(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}},{}],12:[function(e,t,n){t.exports=r;function r(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(n.length){let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}else return{v:t}})}},{}],13:[function(e,t,n){let r=e("@dagrejs/graphlib").Graph,i=e("../util");t.exports=a;function a(e,t,n,i){i||=e.nodes();let a=o(e),s=new r({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(t=>e.node(t));return i.forEach(r=>{let i=e.node(r),o=e.parent(r);(i.rank===t||i.minRank<=t&&t<=i.maxRank)&&(s.setNode(r),s.setParent(r,o||a),e[n](r).forEach(t=>{let n=t.v===r?t.w:t.v,i=s.edge(n,r),a=i===void 0?0:i.weight;s.setEdge(n,r,{weight:e.edge(t).weight+a})}),Object.hasOwn(i,`minRank`)&&s.setNode(r,{borderLeft:i.borderLeft[t],borderRight:i.borderRight[t]}))}),s}function o(e){for(var t;e.hasNode(t=i.uniqueId(`_root`)););return t}},{"../util":27,"@dagrejs/graphlib":29}],14:[function(e,t,n){let r=e("../util").zipObject;t.exports=i;function i(e,t){let n=0;for(let r=1;r<t.length;++r)n+=a(e,t[r-1],t[r]);return n}function a(e,t,n){let i=r(n,n.map((e,t)=>t)),a=t.flatMap(t=>e.outEdges(t).map(t=>({pos:i[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos)),o=1;for(;o<n.length;)o<<=1;let s=2*o-1;--o;let c=Array(s).fill(0),l=0;return a.forEach(e=>{let t=e.pos+o;c[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=c[t+1]),t=t-1>>1,c[t]+=e.weight;l+=e.weight*n}),l}},{"../util":27}],15:[function(e,t,n){let r=e("./init-order"),i=e("./cross-count"),a=e("./sort-subgraph"),o=e("./build-layer-graph"),s=e("./add-subgraph-constraints"),c=e("@dagrejs/graphlib").Graph,l=e("../util");t.exports=u;function u(e,t){if(t&&typeof t.customOrder==`function`){t.customOrder(e,u);return}let n=l.maxRank(e),a=d(e,l.range(1,n+1),`inEdges`),o=d(e,l.range(n-1,-1,-1),`outEdges`),s=r(e);if(p(e,s),t&&t.disableOptimalOrderHeuristic)return;let c=1/0,m;for(let t=0,n=0;n<4;++t,++n){f(t%2?a:o,t%4>=2),s=l.buildLayerMatrix(e);let r=i(e,s);r<c&&(n=0,m=Object.assign({},s),c=r)}p(e,m)}function d(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return o(e,t,n,r.get(t)||[])})}function f(e,t){let n=new c;e.forEach(function(e){let r=e.graph().root,i=a(e,r,n,t);i.vs.forEach((t,n)=>e.node(t).order=n),s(e,n,i.vs)})}function p(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}},{"../util":27,"./add-subgraph-constraints":11,"./build-layer-graph":13,"./cross-count":14,"./init-order":16,"./sort-subgraph":18,"@dagrejs/graphlib":29}],16:[function(e,t,n){let r=e("../util");t.exports=i;function i(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),i=n.map(t=>e.node(t).rank),a=r.applyWithChunking(Math.max,i),o=r.range(a+1).map(()=>[]);function s(n){if(t[n])return;t[n]=!0;let r=e.node(n);o[r.rank].push(n),e.successors(n).forEach(s)}return n.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(s),o}},{"../util":27}],17:[function(e,t,n){let r=e("../util");t.exports=i;function i(e,t){let n={};return e.forEach((e,t)=>{let r=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight)}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(n[e.w]))}),a(Object.values(n).filter(e=>!e.indegree))}function a(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&o(e,t)}}function i(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(n(r)),r.out.forEach(i(r))}return t.filter(e=>!e.merged).map(e=>r.pick(e,[`vs`,`i`,`barycenter`,`weight`]))}function o(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}},{"../util":27}],18:[function(e,t,n){let r=e("./barycenter"),i=e("./resolve-conflicts"),a=e("./sort");t.exports=o;function o(e,t,n,l){let u=e.children(t),d=e.node(t),f=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};f&&(u=u.filter(e=>e!==f&&e!==p));let h=r(e,u);h.forEach(t=>{if(e.children(t.v).length){let r=o(e,t.v,n,l);m[t.v]=r,Object.hasOwn(r,`barycenter`)&&c(t,r)}});let g=i(h,n);s(g,m);let _=a(g,l);if(f&&(_.vs=[f,_.vs,p].flat(!0),e.predecessors(f).length)){let t=e.node(e.predecessors(f)[0]),n=e.node(e.predecessors(p)[0]);Object.hasOwn(_,`barycenter`)||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+t.order+n.order)/(_.weight+2),_.weight+=2}return _}function s(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function c(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}},{"./barycenter":12,"./resolve-conflicts":17,"./sort":19}],19:[function(e,t,n){let r=e("../util");t.exports=i;function i(e,t){let n=r.partition(e,e=>Object.hasOwn(e,`barycenter`)),i=n.lhs,s=n.rhs.sort((e,t)=>t.i-e.i),c=[],l=0,u=0,d=0;i.sort(o(!!t)),d=a(c,s,d),i.forEach(e=>{d+=e.vs.length,c.push(e.vs),l+=e.barycenter*e.weight,u+=e.weight,d=a(c,s,d)});let f={vs:c.flat(!0)};return u&&(f.barycenter=l/u,f.weight=u),f}function a(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function o(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}},{"../util":27}],20:[function(e,t,n){t.exports=r;function r(e){let t=a(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),a=r.edgeObj,o=i(e,t,a.v,a.w),s=o.path,c=o.lca,l=0,u=s[l],d=!0;for(;n!==a.w;){if(r=e.node(n),d){for(;(u=s[l])!==c&&e.node(u).maxRank<r.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<s.length-1&&e.node(u=s[l+1]).minRank<=r.rank;)l++;u=s[l]}e.setParent(n,u),n=e.successors(n)[0]}})}function i(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c,l;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)a.push(c);return{path:i.concat(a.reverse()),lca:l}}function a(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children().forEach(r),t}},{}],21:[function(e,t,n){let r=e("@dagrejs/graphlib").Graph,i=e("../util");t.exports={positionX:g,findType1Conflicts:a,findType2Conflicts:o,addConflict:c,hasConflict:l,verticalAlignment:u,horizontalCompaction:d,alignCoordinates:m,findSmallestWidthAlignment:p,balance:h};function a(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,l=r[r.length-1];return r.forEach((t,u)=>{let d=s(e,t),f=d?e.node(d).order:o;(d||t===l)&&(r.slice(a,u+1).forEach(t=>{e.predecessors(t).forEach(r=>{let a=e.node(r),o=a.order;(o<i||f<o)&&!(a.dummy&&e.node(t).dummy)&&c(n,r,t)})}),a=u+1,i=f)}),r}return t.length&&t.reduce(r),n}function o(e,t){let n={};function r(t,r,a,o,s){let l;i.range(r,a).forEach(r=>{l=t[r],e.node(l).dummy&&e.predecessors(l).forEach(t=>{let r=e.node(t);r.dummy&&(r.order<o||r.order>s)&&c(n,t,l)})})}function a(t,n){let i=-1,a,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);t.length&&(a=e.node(t[0]).order,r(n,o,c,i,a),o=c,i=a)}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(a),n}function s(e,t){if(e.node(t).dummy)return e.predecessors(t).find(t=>e.node(t).dummy)}function c(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function l(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function u(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s.length){s=s.sort((e,t)=>o[e]-o[t]);let r=(s.length-1)/2;for(let c=Math.floor(r),u=Math.ceil(r);c<=u;++c){let r=s[c];a[e]===e&&t<o[r]&&!l(n,e,r)&&(a[r]=e,a[e]=i[e]=i[r],t=o[r])}}})}),{root:i,align:a}}function d(e,t,n,r,i){let a={},o=f(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes(),r=n.pop(),i={};for(;r;)i[r]?e(r):(i[r]=!0,n.push(r),n=n.concat(t(r))),r=n.pop()}function l(e){a[e]=o.inEdges(e).reduce((e,t)=>Math.max(e,a[t.v]+o.edge(t)),0)}function u(t){let n=o.outEdges(t).reduce((e,t)=>Math.min(e,a[t.w]-o.edge(t)),1/0),r=e.node(t);n!==1/0&&r.borderType!==s&&(a[t]=Math.max(a[t],n))}return c(l,o.predecessors.bind(o)),c(u,o.successors.bind(o)),Object.keys(r).forEach(e=>a[e]=a[n[e]]),a}function f(e,t,n,i){let a=new r,o=e.graph(),s=_(o.nodesep,o.edgesep,i);return t.forEach(t=>{let r;t.forEach(t=>{let i=n[t];if(a.setNode(i),r){var o=n[r],c=a.edge(o,i);a.setEdge(o,i,Math.max(s(e,t,r),c||0))}r=t})}),a}function p(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=v(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function m(e,t){let n=Object.values(t),r=i.applyWithChunking(Math.min,n),a=i.applyWithChunking(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(o=>{let s=n+o,c=e[s];if(c===t)return;let l=Object.values(c),u=r-i.applyWithChunking(Math.min,l);o!==`l`&&(u=a-i.applyWithChunking(Math.max,l)),u&&(e[s]=i.mapValues(c,e=>e+u))})})}function h(e,t){return i.mapValues(e.ul,(n,r)=>{if(t)return e[t.toLowerCase()][r];{let t=Object.values(e).map(e=>e[r]).sort((e,t)=>e-t);return(t[1]+t[2])/2}})}function g(e){let t=i.buildLayerMatrix(e),n=Object.assign(a(e,t),o(e,t)),r={},s;return[`u`,`d`].forEach(a=>{s=a===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(s=s.map(e=>Object.values(e).reverse()));let o=(a===`u`?e.predecessors:e.successors).bind(e),c=u(e,s,n,o),l=d(e,s,c.root,c.align,t===`r`);t===`r`&&(l=i.mapValues(l,e=>-e)),r[a+t]=l})}),m(r,p(e,r)),h(r,e.graph().align)}function _(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2;break}if(l&&(c+=n?l:-l),l=0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2;break}return l&&(c+=n?l:-l),l=0,c}}function v(e,t){return e.node(t).width}},{"../util":27,"@dagrejs/graphlib":29}],22:[function(e,t,n){let r=e("../util"),i=e("./bk").positionX;t.exports=a;function a(e){e=r.asNonCompoundGraph(e),o(e),Object.entries(i(e)).forEach(([t,n])=>e.node(t).x=n)}function o(e){let t=r.buildLayerMatrix(e),n=e.graph().ranksep,i=0;t.forEach(t=>{let r=t.reduce((t,n)=>{let r=e.node(n).height;return t>r?t:r},0);t.forEach(t=>e.node(t).y=i+r/2),i+=r+n})}},{"../util":27,"./bk":21}],23:[function(e,t,n){var r=e("@dagrejs/graphlib").Graph,i=e("./util").slack;t.exports=a;function a(e){var t=new r({directed:!1}),n=e.nodes()[0],a=e.nodeCount();t.setNode(n,{});for(var l,u;o(t,e)<a;)l=s(t,e),u=t.hasNode(l.v)?i(e,l):-i(e,l),c(t,e,u);return t}function o(e,t){function n(r){t.nodeEdges(r).forEach(a=>{var o=a.v,s=r===o?a.w:o;!e.hasNode(s)&&!i(t,a)&&(e.setNode(s,{}),e.setEdge(r,s,{}),n(s))})}return e.nodes().forEach(n),e.nodeCount()}function s(e,t){return t.edges().reduce((n,r)=>{let a=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(a=i(t,r)),a<n[0]?[a,r]:n},[1/0,null])[1]}function c(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}},{"./util":26,"@dagrejs/graphlib":29}],24:[function(e,t,n){var r=e("./util").longestPath,i=e("./feasible-tree"),a=e("./network-simplex");t.exports=o;function o(e){var t=e.graph().ranker;if(t instanceof Function)return t(e);switch(e.graph().ranker){case`network-simplex`:l(e);break;case`tight-tree`:c(e);break;case`longest-path`:s(e);break;case`none`:break;default:l(e)}}var s=r;function c(e){r(e),i(e)}function l(e){a(e)}},{"./feasible-tree":23,"./network-simplex":25,"./util":26}],25:[function(e,t,n){var r=e("./feasible-tree"),i=e("./util").slack,a=e("./util").longestPath,o=e("@dagrejs/graphlib").alg.preorder,s=e("@dagrejs/graphlib").alg.postorder,c=e("../util").simplify;t.exports=l,l.initLowLimValues=p,l.initCutValues=u,l.calcCutValue=f,l.leaveEdge=h,l.enterEdge=g,l.exchangeEdges=_;function l(e){e=c(e),a(e);var t=r(e);p(t),u(t,e);for(var n,i;n=h(t);)i=g(t,e,n),_(t,e,n,i)}function u(e,t){var n=s(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>d(e,t,n))}function d(e,t,n){var r=e.node(n).parent;e.edge(n,r).cutvalue=f(e,t,n)}function f(e,t,n){var r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;return a||=(i=!1,t.edge(r,n)),o=a.weight,t.nodeEdges(n).forEach(a=>{var s=a.v===n,c=s?a.w:a.v;if(c!==r){var l=s===i,u=t.edge(a).weight;if(o+=l?u:-u,y(e,n,c)){var d=e.edge(n,c).cutvalue;o+=l?-d:d}}}),o}function p(e,t){arguments.length<2&&(t=e.nodes()[0]),m(e,{},1,t)}function m(e,t,n,r,i){var a=n,o=e.node(r);return t[r]=!0,e.neighbors(r).forEach(i=>{Object.hasOwn(t,i)||(n=m(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function h(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function g(e,t,n){var r=n.v,a=n.w;t.hasEdge(r,a)||(r=n.w,a=n.v);var o=e.node(r),s=e.node(a),c=o,l=!1;return o.lim>s.lim&&(c=s,l=!0),t.edges().filter(t=>l===b(e,e.node(t.v),c)&&l!==b(e,e.node(t.w),c)).reduce((e,n)=>i(t,n)<i(t,e)?n:e)}function _(e,t,n,r){var i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),p(e),u(e,t),v(e,t)}function v(e,t){var n=o(e,e.nodes().find(e=>!t.node(e).parent));n=n.slice(1),n.forEach(n=>{var r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function y(e,t,n){return e.hasEdge(t,n)}function b(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}},{"../util":27,"./feasible-tree":23,"./util":26,"@dagrejs/graphlib":29}],26:[function(e,t,n){let{applyWithChunking:r}=e("../util");t.exports={longestPath:i,slack:a};function i(e){var t={};function n(i){var a=e.node(i);if(Object.hasOwn(t,i))return a.rank;t[i]=!0;let o=e.outEdges(i).map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen);var s=r(Math.min,o);return s===1/0&&(s=0),a.rank=s}e.sources().forEach(n)}function a(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}},{"../util":27}],27:[function(e,t,n){let r=e("@dagrejs/graphlib").Graph;t.exports={addBorderNode:p,addDummyNode:i,applyWithChunking:g,asNonCompoundGraph:o,buildLayerMatrix:u,intersectRect:l,mapValues:te,maxRank:_,normalizeRanks:d,notime:b,partition:v,pick:ee,predecessorWeights:c,range:C,removeEmptyRanks:f,simplify:a,successorWeights:s,time:y,uniqueId:S,zipObject:w};function i(e,t,n,r){for(var i=r;e.hasNode(i);)i=S(r);return n.dummy=t,e.setNode(i,n),i}function a(e){let t=new r().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function o(e){let t=new r({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function s(e){let t=e.nodes().map(t=>{let n={};return e.outEdges(t).forEach(t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight}),n});return w(e.nodes(),t)}function c(e){let t=e.nodes().map(t=>{let n={};return e.inEdges(t).forEach(t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight}),n});return w(e.nodes(),t)}function l(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function u(e){let t=C(_(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i][r.order]=n)}),t}function d(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=g(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function f(e){let t=e.nodes().map(t=>e.node(t).rank),n=g(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function p(e,t,n,r){let a={width:0,height:0};return arguments.length>=4&&(a.rank=n,a.order=r),i(e,`border`,a,t)}function m(e,t=h){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}let h=65535;function g(e,t){if(t.length>h){let n=m(t);return e.apply(null,n.map(t=>e.apply(null,t)))}else return e.apply(null,t)}function _(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return g(Math.max,t)}function v(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function y(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function b(e,t){return t()}let x=0;function S(e){return e+(``+ ++x)}function C(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function ee(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function te(e,t){let n=t;return typeof t==`string`&&(n=e=>e[t]),Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function w(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}},{"@dagrejs/graphlib":29}],28:[function(e,t,n){t.exports=`1.1.8`},{}],29:[function(e,t,n){var r=e("./lib");t.exports={Graph:r.Graph,json:e("./lib/json"),alg:e("./lib/alg"),version:r.version}},{"./lib":45,"./lib/alg":36,"./lib/json":46}],30:[function(e,t,n){t.exports=r;function r(e){var t={},n=[],r;function i(n){Object.hasOwn(t,n)||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}},{}],31:[function(e,t,n){t.exports=r;function r(e,t,n){Array.isArray(t)||(t=[t]);var r=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),o=n===`post`?i:a,s=[],c={};return t.forEach(t=>{if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);o(t,r,c,s)}),s}function i(e,t,n,r){for(var i=[[e,!1]];i.length>0;){var a=i.pop();a[1]?r.push(a[0]):Object.hasOwn(n,a[0])||(n[a[0]]=!0,i.push([a[0],!0]),o(t(a[0]),e=>i.push([e,!1])))}}function a(e,t,n,r){for(var i=[e];i.length>0;){var a=i.pop();Object.hasOwn(n,a)||(n[a]=!0,r.push(a),o(t(a),e=>i.push(e)))}}function o(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}},{}],32:[function(e,t,n){var r=e("./dijkstra");t.exports=i;function i(e,t,n){return e.nodes().reduce(function(i,a){return i[a]=r(e,a,t,n),i},{})}},{"./dijkstra":33}],33:[function(e,t,n){var r=e("../data/priority-queue");t.exports=a;var i=()=>1;function a(e,t,n,r){return o(e,String(t),n||i,r||function(t){return e.outEdges(t)})}function o(e,t,n,i){var a={},o=new r,s,c,l=function(e){var t=e.v===s?e.w:e.v,r=a[t],i=n(e),l=c.distance+i;if(i<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+i);l<r.distance&&(r.distance=l,r.predecessor=s,o.decrease(t,l))};for(e.nodes().forEach(function(e){var n=e===t?0:1/0;a[e]={distance:n},o.add(e,n)});o.size()>0&&(s=o.removeMin(),c=a[s],c.distance!==1/0);)i(s).forEach(l);return a}},{"../data/priority-queue":43}],34:[function(e,t,n){var r=e("./tarjan");t.exports=i;function i(e){return r(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}},{"./tarjan":41}],35:[function(e,t,n){t.exports=i;var r=()=>1;function i(e,t,n){return a(e,t||r,n||function(t){return e.outEdges(t)})}function a(e,t,n){var r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0})}),n(e).forEach(function(n){var i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){var t=r[e];i.forEach(function(n){var a=r[n];i.forEach(function(n){var r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}},{}],36:[function(e,t,n){t.exports={components:e("./components"),dijkstra:e("./dijkstra"),dijkstraAll:e("./dijkstra-all"),findCycles:e("./find-cycles"),floydWarshall:e("./floyd-warshall"),isAcyclic:e("./is-acyclic"),postorder:e("./postorder"),preorder:e("./preorder"),prim:e("./prim"),tarjan:e("./tarjan"),topsort:e("./topsort")}},{"./components":30,"./dijkstra":33,"./dijkstra-all":32,"./find-cycles":34,"./floyd-warshall":35,"./is-acyclic":37,"./postorder":38,"./preorder":39,"./prim":40,"./tarjan":41,"./topsort":42}],37:[function(e,t,n){var r=e("./topsort");t.exports=i;function i(e){try{r(e)}catch(e){if(e instanceof r.CycleException)return!1;throw e}return!0}},{"./topsort":42}],38:[function(e,t,n){var r=e("./dfs");t.exports=i;function i(e,t){return r(e,t,`post`)}},{"./dfs":31}],39:[function(e,t,n){var r=e("./dfs");t.exports=i;function i(e,t){return r(e,t,`pre`)}},{"./dfs":31}],40:[function(e,t,n){var r=e("../graph"),i=e("../data/priority-queue");t.exports=a;function a(e,t){var n=new r,a={},o=new i,s;function c(e){var n=e.v===s?e.w:e.v,r=o.priority(n);if(r!==void 0){var i=t(e);i<r&&(a[n]=s,o.decrease(n,i))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(e){o.add(e,1/0),n.setNode(e)}),o.decrease(e.nodes()[0],0);for(var l=!1;o.size()>0;){if(s=o.removeMin(),Object.hasOwn(a,s))n.setEdge(s,a[s]);else if(l)throw Error(`Input graph is not connected: `+e);else l=!0;e.nodeEdges(s).forEach(c)}return n}},{"../data/priority-queue":43,"../graph":44}],41:[function(e,t,n){t.exports=r;function r(e){var t=0,n=[],r={},i=[];function a(o){var s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){Object.hasOwn(r,e)?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){var c=[],l;do l=n.pop(),r[l].onStack=!1,c.push(l);while(o!==l);i.push(c)}}return e.nodes().forEach(function(e){Object.hasOwn(r,e)||a(e)}),i}},{}],42:[function(e,t,n){function r(e){var t={},n={},r=[];function a(o){if(Object.hasOwn(n,o))throw new i;Object.hasOwn(t,o)||(n[o]=!0,t[o]=!0,e.predecessors(o).forEach(a),delete n[o],r.push(o))}if(e.sinks().forEach(a),Object.keys(t).length!==e.nodeCount())throw new i;return r}class i extends Error{constructor(){super(...arguments)}}t.exports=r,r.CycleException=i},{}],43:[function(e,t,n){class r{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(e){return e.key})}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var r=this._arr,i=r.length;return n[e]=i,r.push({key:e,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw Error(`New priority is greater than current priority. Key: `+e+` Old: `+this._arr[n].priority+` New: `+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){for(var t=this._arr,n=t[e].priority,r;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){var n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}}t.exports=r},{}],44:[function(e,t,n){class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>void 0;_defaultEdgeLabelFn=()=>void 0;_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(e){e&&(this._isDirected=!Object.hasOwn(e,`directed`)||e.directed,this._isMultigraph=Object.hasOwn(e,`multigraph`)?e.multigraph:!1,this._isCompound=Object.hasOwn(e,`compound`)?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,typeof e!=`function`&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter(t=>Object.keys(e._in[t]).length===0)}sinks(){var e=this;return this.nodes().filter(t=>Object.keys(e._out[t]).length===0)}setNodes(e,t){var n=arguments,r=this;return e.forEach(function(e){n.length>1?r.setNode(e,t):r.setNode(e)}),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(function(e){t.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(var n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else if(e===`\0`)return this.nodes();else if(this.hasNode(e))return[]}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){let r=new Set(t);for(var n of this.successors(e))r.add(n);return Array.from(r.values())}}isLeaf(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach(function([n,r]){e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))});var r={};function i(e){var a=n.parent(e);return a===void 0||t.hasNode(a)?(r[e]=a,a):a in r?r[a]:i(a)}return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,i(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,typeof e!=`function`&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,r=arguments;return e.reduce(function(e,i){return r.length>1?n.setEdge(e,i,t):n.setEdge(e,i),i}),this}setEdge(){var e,t,n,r,a=!1,c=arguments[0];typeof c==`object`&&c&&`v`in c?(e=c.v,t=c.w,n=c.name,arguments.length===2&&(r=arguments[1],a=!0)):(e=c,t=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],a=!0)),e=``+e,t=``+t,n!==void 0&&(n=``+n);var l=o(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,l))return a&&(this._edgeLabels[l]=r),this;if(n!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(e),this.setNode(t),this._edgeLabels[l]=a?r:this._defaultEdgeLabelFn(e,t,n);var u=s(this._isDirected,e,t,n);return e=u.v,t=u.w,Object.freeze(u),this._edgeObjs[l]=u,i(this._preds[t],e),i(this._sucs[e],t),this._in[t][l]=u,this._out[e][l]=u,this._edgeCount++,this}edge(e,t,n){var r=arguments.length===1?c(this._isDirected,arguments[0]):o(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(){let e=this.edge(...arguments);return typeof e==`object`?e:{label:e}}hasEdge(e,t,n){var r=arguments.length===1?c(this._isDirected,arguments[0]):o(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,r)}removeEdge(e,t,n){var r=arguments.length===1?c(this._isDirected,arguments[0]):o(this._isDirected,e,t,n),i=this._edgeObjs[r];return i&&(e=i.v,t=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],a(this._preds[t],e),a(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.v===t):r}}outEdges(e,t){var n=this._out[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.w===t):r}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}}function i(e,t){e[t]?e[t]++:e[t]=1}function a(e,t){--e[t]||delete e[t]}function o(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}return i+``+a+``+(r===void 0?`\0`:r)}function s(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function c(e,t){return o(e,t.v,t.w,t.name)}t.exports=r},{}],45:[function(e,t,n){t.exports={Graph:e("./graph"),version:e("./version")}},{"./graph":44,"./version":47}],46:[function(e,t,n){var r=e("./graph");t.exports={write:i,read:s};function i(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:a(e),edges:o(e)};return e.graph()!==void 0&&(t.value=structuredClone(e.graph())),t}function a(e){return e.nodes().map(function(t){var n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function o(e){return e.edges().map(function(t){var n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function s(e){var t=new r(e.options).setGraph(e.value);return e.nodes.forEach(function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}},{"./graph":44}],47:[function(e,t,n){t.exports=`2.2.4`},{}]},{},[1])(1)})}))(),1),v={bg:`#FFFFFF`,fg:`#27272A`},y={textSec:60,textMuted:40,textFaint:25,line:30,arrow:50,nodeFill:3,nodeStroke:20,groupHeader:5,innerStroke:12,keyBadge:10},b={"zinc-dark":{bg:`#18181B`,fg:`#FAFAFA`},"tokyo-night":{bg:`#1a1b26`,fg:`#a9b1d6`,line:`#3d59a1`,accent:`#7aa2f7`,muted:`#565f89`},"tokyo-night-storm":{bg:`#24283b`,fg:`#a9b1d6`,line:`#3d59a1`,accent:`#7aa2f7`,muted:`#565f89`},"tokyo-night-light":{bg:`#d5d6db`,fg:`#343b58`,line:`#34548a`,accent:`#34548a`,muted:`#9699a3`},"catppuccin-mocha":{bg:`#1e1e2e`,fg:`#cdd6f4`,line:`#585b70`,accent:`#cba6f7`,muted:`#6c7086`},"catppuccin-latte":{bg:`#eff1f5`,fg:`#4c4f69`,line:`#9ca0b0`,accent:`#8839ef`,muted:`#9ca0b0`},nord:{bg:`#2e3440`,fg:`#d8dee9`,line:`#4c566a`,accent:`#88c0d0`,muted:`#616e88`},"nord-light":{bg:`#eceff4`,fg:`#2e3440`,line:`#aab1c0`,accent:`#5e81ac`,muted:`#7b88a1`},dracula:{bg:`#282a36`,fg:`#f8f8f2`,line:`#6272a4`,accent:`#bd93f9`,muted:`#6272a4`},"github-light":{bg:`#ffffff`,fg:`#1f2328`,line:`#d1d9e0`,accent:`#0969da`,muted:`#59636e`},"github-dark":{bg:`#0d1117`,fg:`#e6edf3`,line:`#3d444d`,accent:`#4493f8`,muted:`#9198a1`},"solarized-light":{bg:`#fdf6e3`,fg:`#657b83`,line:`#93a1a1`,accent:`#268bd2`,muted:`#93a1a1`},"solarized-dark":{bg:`#002b36`,fg:`#839496`,line:`#586e75`,accent:`#268bd2`,muted:`#586e75`},"one-dark":{bg:`#282c34`,fg:`#abb2bf`,line:`#4b5263`,accent:`#c678dd`,muted:`#5c6370`}};function x(e,t){let n=[`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@400;500;600;700&amp;display=swap');`,...t?[`@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&amp;display=swap');`]:[]],r=`
2
+ /* Derived from --bg and --fg (overridable via --line, --accent, etc.) */
3
+ --_text: var(--fg);
4
+ --_text-sec: var(--muted, color-mix(in srgb, var(--fg) ${y.textSec}%, var(--bg)));
5
+ --_text-muted: var(--muted, color-mix(in srgb, var(--fg) ${y.textMuted}%, var(--bg)));
6
+ --_text-faint: color-mix(in srgb, var(--fg) ${y.textFaint}%, var(--bg));
7
+ --_line: var(--line, color-mix(in srgb, var(--fg) ${y.line}%, var(--bg)));
8
+ --_arrow: var(--accent, color-mix(in srgb, var(--fg) ${y.arrow}%, var(--bg)));
9
+ --_node-fill: var(--surface, color-mix(in srgb, var(--fg) ${y.nodeFill}%, var(--bg)));
10
+ --_node-stroke: var(--border, color-mix(in srgb, var(--fg) ${y.nodeStroke}%, var(--bg)));
11
+ --_group-fill: var(--bg);
12
+ --_group-hdr: color-mix(in srgb, var(--fg) ${y.groupHeader}%, var(--bg));
13
+ --_inner-stroke: color-mix(in srgb, var(--fg) ${y.innerStroke}%, var(--bg));
14
+ --_key-badge: color-mix(in srgb, var(--fg) ${y.keyBadge}%, var(--bg));`;return[`<style>`,` ${n.join(`
15
+ `)}`,` text { font-family: '${e}', system-ui, sans-serif; }`,...t?[` .mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace; }`]:[],` svg {${r}`,` }`,`</style>`].join(`
16
+ `)}function S(e,t,n,r){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e} ${t}" width="${e}" height="${t}" style="${[`--bg:${n.bg}`,`--fg:${n.fg}`,n.line?`--line:${n.line}`:``,n.accent?`--accent:${n.accent}`:``,n.muted?`--muted:${n.muted}`:``,n.surface?`--surface:${n.surface}`:``,n.border?`--border:${n.border}`:``].filter(Boolean).join(`;`)}${r?``:`;background:var(--bg)`}">`}function C(e){let t=e.split(`
17
+ `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`%%`));if(t.length===0)throw Error(`Empty mermaid diagram`);let n=t[0];return/^stateDiagram(-v2)?\s*$/i.test(n)?te(t):ee(t)}function ee(e){let t=e[0].match(/^(?:graph|flowchart)\s+(TD|TB|LR|BT|RL)\s*$/i);if(!t)throw Error(`Invalid mermaid header: "${e[0]}". Expected "graph TD", "flowchart LR", "stateDiagram-v2", etc.`);let n={direction:t[1].toUpperCase(),nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map},r=[];for(let t=1;t<e.length;t++){let i=e[t],a=i.match(/^classDef\s+(\w+)\s+(.+)$/);if(a){let e=a[1],t=a[2],r=T(t);n.classDefs.set(e,r);continue}let o=i.match(/^class\s+([\w,-]+)\s+(\w+)$/);if(o){let e=o[1].split(`,`).map(e=>e.trim()),t=o[2];for(let r of e)n.classAssignments.set(r,t);continue}let s=i.match(/^style\s+([\w,-]+)\s+(.+)$/);if(s){let e=s[1].split(`,`).map(e=>e.trim()),t=T(s[2]);for(let r of e)n.nodeStyles.set(r,{...n.nodeStyles.get(r),...t});continue}let c=i.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(c&&r.length>0){r[r.length-1].direction=c[1].toUpperCase();continue}let l=i.match(/^subgraph\s+(.+)$/);if(l){let e=l[1].trim(),t=e.match(/^([\w-]+)\s*\[(.+)\]$/),n,i;t?(n=t[1],i=t[2]):(i=e,n=e.replace(/\s+/g,`_`).replace(/[^\w]/g,``));let a={id:n,label:i,nodeIds:[],children:[]};r.push(a);continue}if(i===`end`){let e=r.pop();e&&(r.length>0?r[r.length-1].children.push(e):n.subgraphs.push(e));continue}se(i,n,r)}return n}function te(e){let t={direction:`TD`,nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map},n=[],r=0,i=0;for(let a=1;a<e.length;a++){let o=e[a],s=o.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(s){n.length>0?n[n.length-1].direction=s[1].toUpperCase():t.direction=s[1].toUpperCase();continue}let c=o.match(/^state\s+(?:"([^"]+)"\s+as\s+)?(\w+)\s*\{$/);if(c){let e=c[1]??c[2],t={id:c[2],label:e,nodeIds:[],children:[]};n.push(t);continue}if(o===`}`){let e=n.pop();e&&(n.length>0?n[n.length-1].children.push(e):t.subgraphs.push(e));continue}let l=o.match(/^state\s+"([^"]+)"\s+as\s+(\w+)\s*$/);if(l){let e=l[1],r=l[2];w(t,n,{id:r,label:e,shape:`rounded`});continue}let u=o.match(/^(\[\*\]|[\w-]+)\s*(-->)\s*(\[\*\]|[\w-]+)(?:\s*:\s*(.+))?$/);if(u){let e=u[1],a=u[3],o=u[4]?.trim()||void 0;e===`[*]`?(r++,e=`_start${r>1?r:``}`,w(t,n,{id:e,label:``,shape:`state-start`})):ne(t,n,e),a===`[*]`?(i++,a=`_end${i>1?i:``}`,w(t,n,{id:a,label:``,shape:`state-end`})):ne(t,n,a),t.edges.push({source:e,target:a,label:o,style:`solid`,hasArrowStart:!1,hasArrowEnd:!0});continue}let d=o.match(/^([\w-]+)\s*:\s*(.+)$/);if(d){let e=d[1];w(t,n,{id:e,label:d[2].trim(),shape:`rounded`});continue}}return t}function w(e,t,n){if(e.nodes.has(n.id)||e.nodes.set(n.id,n),t.length>0){let e=t[t.length-1];e.nodeIds.includes(n.id)||e.nodeIds.push(n.id)}}function ne(e,t,n){if(!e.nodes.has(n))w(e,t,{id:n,label:n,shape:`rounded`});else if(t.length>0){let e=t[t.length-1];e.nodeIds.includes(n)||e.nodeIds.push(n)}}function T(e){let t={};for(let n of e.split(`,`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}}return t}var re=/^(<)?(-->|-.->|==>|---|-\.-|===)(?:\|([^|]*)\|)?/,ie=[{regex:/^([\w-]+)\(\(\((.+?)\)\)\)/,shape:`doublecircle`},{regex:/^([\w-]+)\(\[(.+?)\]\)/,shape:`stadium`},{regex:/^([\w-]+)\(\((.+?)\)\)/,shape:`circle`},{regex:/^([\w-]+)\[\[(.+?)\]\]/,shape:`subroutine`},{regex:/^([\w-]+)\[\((.+?)\)\]/,shape:`cylinder`},{regex:/^([\w-]+)\[\/(.+?)\\\]/,shape:`trapezoid`},{regex:/^([\w-]+)\[\\(.+?)\/\]/,shape:`trapezoid-alt`},{regex:/^([\w-]+)>(.+?)\]/,shape:`asymmetric`},{regex:/^([\w-]+)\{\{(.+?)\}\}/,shape:`hexagon`},{regex:/^([\w-]+)\[(.+?)\]/,shape:`rectangle`},{regex:/^([\w-]+)\((.+?)\)/,shape:`rounded`},{regex:/^([\w-]+)\{(.+?)\}/,shape:`diamond`}],ae=/^([\w-]+)/,oe=/^:::([\w][\w-]*)/;function se(e,t,n){let r=e.trim(),i=E(r,t,n);if(!i||i.ids.length===0)return;r=i.remaining.trim();let a=i.ids;for(;r.length>0;){let e=r.match(re);if(!e)break;let i=!!e[1],o=e[2],s=e[3]?.trim()||void 0;r=r.slice(e[0].length).trim();let c=de(o),l=o.endsWith(`>`),u=E(r,t,n);if(!u||u.ids.length===0)break;r=u.remaining.trim();for(let e of a)for(let n of u.ids)t.edges.push({source:e,target:n,label:s,style:c,hasArrowStart:i,hasArrowEnd:l});a=u.ids}}function E(e,t,n){let r=ce(e,t,n);if(!r)return null;let i=[r.id],a=r.remaining.trim();for(;a.startsWith(`&`);){a=a.slice(1).trim();let e=ce(a,t,n);if(!e)break;i.push(e.id),a=e.remaining.trim()}return{ids:i,remaining:a}}function ce(e,t,n){let r=null,i=e;for(let{regex:a,shape:o}of ie){let s=e.match(a);if(s){r=s[1];let a=s[2];le(t,n,{id:r,label:a,shape:o}),i=e.slice(s[0].length);break}}if(r===null){let a=e.match(ae);a&&(r=a[1],t.nodes.has(r)?ue(n,r):le(t,n,{id:r,label:r,shape:`rectangle`}),i=e.slice(a[0].length))}if(r===null)return null;let a=i.match(oe);return a&&(t.classAssignments.set(r,a[1]),i=i.slice(a[0].length)),{id:r,remaining:i}}function le(e,t,n){e.nodes.has(n.id)||e.nodes.set(n.id,n),ue(t,n.id)}function ue(e,t){if(e.length>0){let n=e[e.length-1];n.nodeIds.includes(t)||n.nodeIds.push(t)}}function de(e){return e===`-.->`||e===`-.-`?`dotted`:e===`==>`||e===`===`?`thick`:`solid`}function fe(e){let t={actors:[],messages:[],blocks:[],notes:[]},n=new Set,r=[];for(let i=1;i<e.length;i++){let a=e[i],o=a.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(o){let e=o[1],r=o[2],i=o[3]?.trim()??r;n.has(r)||(n.add(r),t.actors.push({id:r,label:i,type:e}));continue}let s=a.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);if(s){let e=s[1].toLowerCase(),r=s[2].trim(),i=s[3].trim(),a=r.split(`,`).map(e=>e.trim());for(let e of a)D(t,n,e);let o=`over`;e===`left of`?o=`left`:e===`right of`&&(o=`right`),t.notes.push({actorIds:a,text:i,position:o,afterIndex:t.messages.length-1});continue}let c=a.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);if(c){let e=c[1],n=c[2]?.trim()??``;r.push({type:e,label:n,startIndex:t.messages.length,dividers:[]});continue}let l=a.match(/^(else|and)\s*(.*)$/);if(l&&r.length>0){let e=l[2]?.trim()??``;r[r.length-1].dividers.push({index:t.messages.length,label:e});continue}if(a===`end`&&r.length>0){let e=r.pop();t.blocks.push({type:e.type,label:e.label,startIndex:e.startIndex,endIndex:Math.max(t.messages.length-1,e.startIndex),dividers:e.dividers});continue}let u=a.match(/^(\S+?)\s*(--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(\S+?)\s*:\s*(.+)$/);if(u){let e=u[1],r=u[2],i=u[3],a=u[4],o=u[5].trim();D(t,n,e),D(t,n,a);let s={from:e,to:a,label:o,lineStyle:r.startsWith(`--`)?`dashed`:`solid`,arrowHead:r.includes(`>>`)||r.includes(`x`)?`filled`:`open`};i===`+`&&(s.activate=!0),i===`-`&&(s.deactivate=!0),t.messages.push(s);continue}let d=a.match(/^(\S+?)\s*(->>|-->>|-\)|--\)|-x|--x|->|-->)\s*([+-]?)(\S+?)\s*:\s*(.+)$/);if(d){let e=d[1],r=d[2],i=d[3],a=d[4],o=d[5].trim();D(t,n,e),D(t,n,a);let s={from:e,to:a,label:o,lineStyle:r.startsWith(`--`)?`dashed`:`solid`,arrowHead:r.includes(`>>`)||r.includes(`x`)?`filled`:`open`};i===`+`&&(s.activate=!0),i===`-`&&(s.deactivate=!0),t.messages.push(s);continue}}return t}function D(e,t,n){t.has(n)||(t.add(n),e.actors.push({id:n,label:n,type:`participant`}))}function O(e){let t={classes:[],relationships:[],namespaces:[]},n=new Map,r=null,i=null,a=0;for(let o=1;o<e.length;o++){let s=e[o];if(i&&a>0){if(s===`}`){a--,a===0&&(i=null);continue}let e=s.match(/^<<(\w+)>>$/);if(e){i.annotation=e[1];continue}let t=pe(s);t&&(t.isMethod?i.methods.push(t.member):i.attributes.push(t.member));continue}let c=s.match(/^namespace\s+(\S+)\s*\{$/);if(c){r={name:c[1],classIds:[]};continue}if(s===`}`&&r){t.namespaces.push(r),r=null;continue}let l=s.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);if(l){let e=l[1],t=l[2],o=k(n,e);t&&(o.label=`${e}<${t}>`),i=o,a=1,r&&r.classIds.push(e);continue}let u=s.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);if(u){let e=u[1],t=u[2],i=k(n,e);t&&(i.label=`${e}<${t}>`),r&&r.classIds.push(e);continue}let d=s.match(/^class\s+(\S+?)\s*\{\s*<<(\w+)>>\s*\}$/);if(d){let e=k(n,d[1]);e.annotation=d[2];continue}let f=s.match(/^(\S+?)\s*:\s*(.+)$/);if(f){let e=f[2];if(!e.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)){let t=k(n,f[1]),r=pe(e);r&&(r.isMethod?t.methods.push(r.member):t.attributes.push(r.member));continue}}let p=me(s);if(p){k(n,p.from),k(n,p.to),t.relationships.push(p);continue}}return t.classes=[...n.values()],t}function k(e,t){let n=e.get(t);return n||(n={id:t,label:t,attributes:[],methods:[]},e.set(t,n)),n}function pe(e){let t=e.trim().replace(/;$/,``);if(!t)return null;let n=``,r=t;/^[+\-#~]/.test(r)&&(n=r[0],r=r.slice(1).trim());let i=r.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);if(i){let e=i[1].trim(),t=i[3]?.trim(),a=e.endsWith(`$`)||r.includes(`$`),o=e.endsWith(`*`)||r.includes(`*`);return{member:{visibility:n,name:e.replace(/[$*]$/,``),type:t||void 0,isStatic:a,isAbstract:o},isMethod:!0}}let a=r.split(/\s+/),o,s;a.length>=2?(s=a[0],o=a.slice(1).join(` `)):o=a[0]??r;let c=o.endsWith(`$`),l=o.endsWith(`*`);return{member:{visibility:n,name:o.replace(/[$*]$/,``),type:s||void 0,isStatic:c,isAbstract:l},isMethod:!1}}function me(e){let t=e.match(/^(\S+?)\s+(?:"([^"]*?)"\s+)?(<\|--|<\|\.\.|\*--|o--|-->|--\*|--o|--|>\s*|\.\.>|\.\.\|>|--)\s+(?:"([^"]*?)"\s+)?(\S+?)(?:\s*:\s*(.+))?$/);if(!t)return null;let n=t[1],r=t[2]||void 0,i=t[3].trim(),a=t[4]||void 0,o=t[5],s=t[6]?.trim()||void 0,c=he(i);return c?{from:n,to:o,type:c.type,markerAt:c.markerAt,label:s,fromCardinality:r,toCardinality:a}:null}function he(e){switch(e){case`<|--`:return{type:`inheritance`,markerAt:`from`};case`<|..`:return{type:`realization`,markerAt:`from`};case`*--`:return{type:`composition`,markerAt:`from`};case`--*`:return{type:`composition`,markerAt:`to`};case`o--`:return{type:`aggregation`,markerAt:`from`};case`--o`:return{type:`aggregation`,markerAt:`to`};case`-->`:return{type:`association`,markerAt:`to`};case`..>`:return{type:`dependency`,markerAt:`to`};case`..|>`:return{type:`realization`,markerAt:`to`};case`--`:return{type:`association`,markerAt:`to`};default:return null}}function ge(e){let t={entities:[],relationships:[]},n=new Map,r=null;for(let i=1;i<e.length;i++){let a=e[i];if(r){if(a===`}`){r=null;continue}let e=ve(a);e&&r.attributes.push(e);continue}let o=a.match(/^(\S+)\s*\{$/);if(o){let e=o[1];r=_e(n,e);continue}let s=ye(a);if(s){_e(n,s.entity1),_e(n,s.entity2),t.relationships.push(s);continue}}return t.entities=[...n.values()],t}function _e(e,t){let n=e.get(t);return n||(n={id:t,label:t,attributes:[]},e.set(t,n)),n}function ve(e){let t=e.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);if(!t)return null;let n=t[1],r=t[2],i=t[3]?.trim()??``,a=[],o,s=i.match(/"([^"]*)"/);s&&(o=s[1]);let c=i.replace(/"[^"]*"/,``).trim();for(let e of c.split(/\s+/)){let t=e.toUpperCase();(t===`PK`||t===`FK`||t===`UK`)&&a.push(t)}return{type:n,name:r,keys:a,comment:o}}function ye(e){let t=e.match(/^(\S+)\s+([|o}{]+(?:--|\.\.)[|o}{]+)\s+(\S+)\s*:\s*(.+)$/);if(!t)return null;let n=t[1],r=t[2],i=t[3],a=t[4].trim(),o=r.match(/^([|o}{]+)(--|\.\.?)([|o}{]+)$/);if(!o)return null;let s=o[1],c=o[2],l=o[3],u=be(s),d=be(l);return!u||!d?null:{entity1:n,entity2:i,cardinality1:u,cardinality2:d,label:a,identifying:c===`--`}}function be(e){let t=e.split(``).sort().join(``);return t===`||`?`one`:t===`o|`?`zero-one`:t===`|}`||t===`{|`?`many`:t===`{o`||t===`o{`?`zero-many`:null}function A(e,t,n){let r=n>=600?.58:n>=500?.55:.52;return e.length*t*r}function xe(e,t){return e.length*t*.6}var j={nodeLabel:13,edgeLabel:11,groupHeader:12},M={nodeLabel:500,edgeLabel:400,groupHeader:600},Se=8,N={horizontal:16,vertical:10,diamondExtra:24},P={outerBox:1,innerBox:.75,connector:.75},F=`0.35em`,I={width:8,height:4.8};function L(e,t,n,r){return{x:e-n/2,y:t-r/2}}function R(e,t,n,r,i){let a=e.x-t,o=e.y-n;if(Math.abs(a)<.5&&Math.abs(o)<.5)return e;let s=1/(Math.abs(a)/r+Math.abs(o)/i);return{x:t+s*a,y:n+s*o}}function z(e,t,n,r){let i=e.x-t,a=e.y-n,o=Math.sqrt(i*i+a*a);if(o<.5)return e;let s=r/o;return{x:t+s*i,y:n+s*a}}function B(e,t=!0){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<1||s<1){n.push(a);continue}t?n.push({x:i.x,y:a.y}):n.push({x:a.x,y:i.y}),n.push(a)}return Ce(n)}function Ce(e){if(e.length<3)return e;let t=[e[0]];for(let n=1;n<e.length-1;n++){let r=t[t.length-1],i=e[n],a=e[n+1],o=Math.abs(r.x-i.x)<1&&Math.abs(i.x-a.x)<1,s=Math.abs(r.y-i.y)<1&&Math.abs(i.y-a.y)<1;o||s||t.push(i)}return t.push(e[e.length-1]),t}function V(e,t,n){if(e.length<2)return e;let r=e.map(e=>({...e}));if(n){let t=r.length-1;if(e.length===2){let e=r[0],i=r[t],a=Math.abs(i.x-e.x);if(Math.abs(i.y-e.y)>=a){let a=i.y>e.y?n.cy-n.hh:n.cy+n.hh;r[t]={x:i.x,y:a}}else r[t]={x:i.x>e.x?n.cx-n.hw:n.cx+n.hw,y:i.y}}else{let e=r[t-1],i=r[t],a=Math.abs(i.x-e.x),o=Math.abs(i.y-e.y),s=o<1&&a>=1,c=a<1&&o>=1,l=!s&&!c&&o<a,u=!s&&!c&&a<o;if(s)r[t]={x:i.x>e.x?n.cx-n.hw:n.cx+n.hw,y:n.cy},r[t-1]={...e,y:n.cy};else if(c){let a=i.y>e.y?n.cy-n.hh:n.cy+n.hh;r[t]={x:n.cx,y:a},r[t-1]={...e,x:n.cx}}else if(l){let a=i.x>e.x?n.cx-n.hw:n.cx+n.hw;e.y>=n.cy-n.hh&&e.y<=n.cy+n.hh?r[t]={x:a,y:e.y}:(r[t]={x:a,y:n.cy},r[t-1]={...e,y:n.cy})}else if(u){let a=i.y>e.y?n.cy-n.hh:n.cy+n.hh;e.x>=n.cx-n.hw&&e.x<=n.cx+n.hw?r[t]={x:e.x,y:a}:(r[t]={x:n.cx,y:a},r[t-1]={...e,x:n.cx})}}}if(t&&e.length>=3){let e=r[0],n=r[1],i=Math.abs(n.x-e.x),a=Math.abs(n.y-e.y),o=a<1&&i>=1,s=i<1&&a>=1,c=!o&&!s&&a<i,l=!o&&!s&&i<a;if(o)r[0]={x:n.x>e.x?t.cx+t.hw:t.cx-t.hw,y:t.cy},r[1]={...r[1],y:t.cy};else if(s){let i=n.y>e.y?t.cy+t.hh:t.cy-t.hh;r[0]={x:t.cx,y:i},r[1]={...r[1],x:t.cx}}else if(c){let i=n.x>e.x?t.cx+t.hw:t.cx-t.hw;n.y>=t.cy-t.hh&&n.y<=t.cy+t.hh?r[0]={x:i,y:n.y}:(r[0]={x:i,y:t.cy},r[1]={...r[1],y:t.cy})}else if(l){let i=n.y>e.y?t.cy+t.hh:t.cy-t.hh;n.x>=t.cx-t.hw&&n.x<=t.cx+t.hw?r[0]={x:n.x,y:i}:(r[0]={x:t.cx,y:i},r[1]={...r[1],x:t.cx})}}return r}var H=new Set([`circle`,`doublecircle`,`state-start`,`state-end`]),U=new Set([`diamond`,`circle`,`doublecircle`,`state-start`,`state-end`]),we={font:`Inter`,padding:40,nodeSpacing:24,layerSpacing:40};function Te(e,t,n){let r=new _.default.graphlib.Graph({directed:!0,compound:!0});r.setGraph({rankdir:De(e.direction),acyclicer:`greedy`,nodesep:n.nodeSpacing,ranksep:n.layerSpacing,marginx:16,marginy:12}),r.setDefaultEdgeLabel(()=>({}));let i=new Set;i.add(e.id),W(e,i);for(let n of e.nodeIds){let e=t.nodes.get(n);if(e){let t=Oe(n,e.label,e.shape);r.setNode(n,{label:e.label,width:t.width,height:t.height})}}for(let n of e.children)ke(r,n,t);let a=new Set;for(let e=0;e<t.edges.length;e++){let n=t.edges[e];if(i.has(n.source)&&i.has(n.target)){a.add(e);let t={_index:e};n.label&&(t.label=n.label,t.width=A(n.label,j.edgeLabel,M.edgeLabel)+8,t.height=j.edgeLabel+6,t.labelpos=`c`),r.setEdge(n.source,n.target,t)}}_.default.layout(r);let o=e.direction===`TD`||e.direction===`TB`||e.direction===`BT`,s=new Set;for(let t of e.children)ze(t,s);let c=[];for(let e of r.nodes()){if(s.has(e))continue;let n=t.nodes.get(e);if(!n)continue;let i=r.node(e);if(!i)continue;let a=L(i.x,i.y,i.width,i.height);c.push({id:e,label:n.label,shape:n.shape,x:a.x,y:a.y,width:i.width,height:i.height,inlineStyle:je(t,e)})}let l=r.edges().map(e=>{let n=r.edge(e),i=t.edges[n._index],a=n.points??[];if(a.length>0){let n=t.nodes.get(e.v)?.shape;if(n===`diamond`){let t=r.node(e.v);a[0]=R(a[0],t.x,t.y,t.width/2,t.height/2)}else if(n&&H.has(n)){let t=r.node(e.v);a[0]=z(a[0],t.x,t.y,Math.min(t.width,t.height)/2)}let i=t.nodes.get(e.w)?.shape;if(i===`diamond`){let t=r.node(e.w),n=a.length-1;a[n]=R(a[n],t.x,t.y,t.width/2,t.height/2)}else if(i&&H.has(i)){let t=r.node(e.w),n=a.length-1;a[n]=z(a[n],t.x,t.y,Math.min(t.width,t.height)/2)}}let s=B(a,o),c=t.nodes.get(e.v)?.shape,l=t.nodes.get(e.w)?.shape,u=V(s,c&&!U.has(c)||!c?(()=>{let t=r.node(e.v);return t?{cx:t.x,cy:t.y,hw:t.width/2,hh:t.height/2}:null})():null,l&&!U.has(l)||!l?(()=>{let t=r.node(e.w);return t?{cx:t.x,cy:t.y,hw:t.width/2,hh:t.height/2}:null})():null),d;return i.label&&n.x!=null&&n.y!=null&&(d={x:n.x,y:n.y}),{source:i.source,target:i.target,label:i.label,style:i.style,hasArrowStart:i.hasArrowStart,hasArrowEnd:i.hasArrowEnd,points:u,labelPosition:d}}),u=e.children.map(e=>Ne(r,e)),d=r.graph();return{id:e.id,label:e.label,width:d.width??200,height:d.height??100,nodes:c,edges:l,groups:u,nodeIds:i,internalEdgeIndices:a}}async function Ee(e,t={}){let n={...we,...t},r=new Map;for(let t of e.subgraphs)t.direction&&t.direction!==e.direction&&r.set(t.id,Te(t,e,n));let i=new _.default.graphlib.Graph({directed:!0,compound:!0});i.setGraph({rankdir:De(e.direction),acyclicer:`greedy`,nodesep:n.nodeSpacing,ranksep:n.layerSpacing,marginx:n.padding,marginy:n.padding}),i.setDefaultEdgeLabel(()=>({}));let a=new Set;for(let t of e.subgraphs)a.add(t.id),W(t,a);for(let[t,n]of e.nodes)if(!a.has(t)){let e=Oe(t,n.label,n.shape);i.setNode(t,{label:n.label,width:e.width,height:e.height})}for(let t of e.subgraphs)if(r.has(t.id)){let e=r.get(t.id);i.setNode(t.id,{width:e.width,height:e.height})}else ke(i,t,e);let o=new Map,s=new Map;for(let t of e.subgraphs)r.has(t.id)||Ae(t,o,s);for(let[e,t]of r)for(let n of t.nodeIds)o.set(n,e),s.set(n,e);let c=new Set;for(let e of r.values())for(let t of e.internalEdgeIndices)c.add(t);let l=new Set;for(let t=0;t<e.edges.length;t++){if(c.has(t))continue;let n=e.edges[t],r=s.get(n.source)??n.source,a=o.get(n.target)??n.target,u={_index:t};n.label&&(u.label=n.label,u.width=A(n.label,j.edgeLabel,M.edgeLabel)+8,u.height=j.edgeLabel+6,u.labelpos=`c`),l.has(a)||(u.weight=2,l.add(a)),i.setEdge(r,a,u)}try{_.default.layout(i)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Dagre layout failed: ${t}`)}return Me(i,e,n.padding,r)}function De(e){switch(e){case`LR`:return`LR`;case`RL`:return`RL`;case`BT`:return`BT`;default:return`TB`}}function Oe(e,t,n){let r=A(t,j.nodeLabel,M.nodeLabel)+N.horizontal*2,i=j.nodeLabel+N.vertical*2;if(n===`diamond`){let e=Math.max(r,i)+N.diamondExtra;r=e,i=e}if(n===`circle`||n===`doublecircle`){let e=Math.ceil(Math.sqrt(r*r+i*i))+8;r=n===`doublecircle`?e+12:e,i=r}return n===`hexagon`&&(r+=N.horizontal),(n===`trapezoid`||n===`trapezoid-alt`)&&(r+=N.horizontal),n===`asymmetric`&&(r+=12),n===`cylinder`&&(i+=14),(n===`state-start`||n===`state-end`)&&(r=28,i=28),r=Math.max(r,60),i=Math.max(i,36),{width:r,height:i}}function ke(e,t,n,r){e.setNode(t.id,{label:t.label}),r&&e.setParent(t.id,r);for(let r of t.nodeIds){let i=n.nodes.get(r);if(i){let n=Oe(r,i.label,i.shape);e.setNode(r,{label:i.label,width:n.width,height:n.height}),e.setParent(r,t.id)}}for(let r of t.children)ke(e,r,n,t.id)}function Ae(e,t,n){for(let r of e.children)Ae(r,t,n);let r=[...e.nodeIds,...e.children.map(e=>e.id)];if(r.length===0){t.set(e.id,e.id),n.set(e.id,e.id);return}let i=r[0],a=r[r.length-1];t.set(e.id,t.get(i)??i),n.set(e.id,n.get(a)??a)}function je(e,t){let n=e.classAssignments.get(t),r=n?e.classDefs.get(n):void 0,i=e.nodeStyles.get(t);if(!(!r&&!i))return{...r,...i}}function W(e,t){for(let n of e.nodeIds)t.add(n);for(let n of e.children)W(n,t)}function Me(e,t,n,r){let i=[],a=[],o=new Set;for(let e of t.subgraphs)ze(e,o);let s=new Set;if(r)for(let e of r.values())for(let t of e.nodeIds)s.add(t);for(let n of e.nodes()){if(o.has(n))continue;let r=t.nodes.get(n);if(!r)continue;let a=e.node(n);if(!a)continue;let s=L(a.x,a.y,a.width,a.height);i.push({id:n,label:r.label,shape:r.shape,x:s.x,y:s.y,width:a.width,height:a.height,inlineStyle:je(t,n)})}for(let n of t.subgraphs)a.push(Ne(e,n));let c=t.direction===`TD`||t.direction===`TB`||t.direction===`BT`,l=e.edges().map(n=>{let r=e.edge(n),i=t.edges[r._index],a=r.points??[];if(a.length>0){let r=t.nodes.get(n.v)?.shape;if(r===`diamond`){let t=e.node(n.v);a[0]=R(a[0],t.x,t.y,t.width/2,t.height/2)}else if(r&&H.has(r)){let t=e.node(n.v);a[0]=z(a[0],t.x,t.y,Math.min(t.width,t.height)/2)}let i=t.nodes.get(n.w)?.shape;if(i===`diamond`){let t=e.node(n.w),r=a.length-1;a[r]=R(a[r],t.x,t.y,t.width/2,t.height/2)}else if(i&&H.has(i)){let t=e.node(n.w),r=a.length-1;a[r]=z(a[r],t.x,t.y,Math.min(t.width,t.height)/2)}}let o=B(a,c),s=t.nodes.get(n.v)?.shape,l=t.nodes.get(n.w)?.shape,u=V(o,s&&!U.has(s)||!s?(()=>{let t=e.node(n.v);return t?{cx:t.x,cy:t.y,hw:t.width/2,hh:t.height/2}:null})():null,l&&!U.has(l)||!l?(()=>{let t=e.node(n.w);return t?{cx:t.x,cy:t.y,hw:t.width/2,hh:t.height/2}:null})():null),d;return i.label&&r.x!=null&&r.y!=null&&(d={x:r.x,y:r.y}),{source:i.source,target:i.target,label:i.label,style:i.style,hasArrowStart:i.hasArrowStart,hasArrowEnd:i.hasArrowEnd,points:u,labelPosition:d}});if(r&&r.size>0){let t=new Map;for(let e of i)t.set(e.id,{cx:e.x+e.width/2,cy:e.y+e.height/2});for(let[n,o]of r){let r=e.node(n);if(!r)continue;let s=L(r.x,r.y,r.width,r.height);for(let e of o.nodes){let n={...e,x:e.x+s.x,y:e.y+s.y};i.push(n),t.set(n.id,{cx:n.x+n.width/2,cy:n.y+n.height/2})}for(let e of o.edges)l.push({...e,points:e.points.map(e=>({x:e.x+s.x,y:e.y+s.y})),labelPosition:e.labelPosition?{x:e.labelPosition.x+s.x,y:e.labelPosition.y+s.y}:void 0});let c=Le(a,n);c&&o.groups.length>0&&(c.children=o.groups.map(e=>Re(e,s.x,s.y)))}for(let e of l){if(s.has(e.source)&&s.has(e.target))continue;let n=!1;if(s.has(e.source)){let r=t.get(e.source);r&&e.points.length>0&&(e.points[0]={x:r.cx,y:r.cy},n=!0)}if(s.has(e.target)){let r=t.get(e.target);r&&e.points.length>0&&(e.points[e.points.length-1]={x:r.cx,y:r.cy},n=!0)}n&&(e.points=B(e.points,c))}}Pe(a,j.groupHeader+16);let u=Ie(a),d=[...i.map(e=>e.y),...u.map(e=>e.y)],f=d.length>0?Math.min(...d):n,p=e.graph().width??800,m=e.graph().height??600;if(f<n){let e=n-f;for(let t of i)t.y+=e;for(let t of l){for(let n of t.points)n.y+=e;t.labelPosition&&(t.labelPosition.y+=e)}for(let t of u)t.y+=e;m+=e}let h=Math.max(...i.map(e=>e.y+e.height),...u.map(e=>e.y+e.height),...l.flatMap(e=>e.points.map(e=>e.y)));return h+n>m&&(m=h+n),{width:p,height:m,nodes:i,edges:l,groups:a}}function Ne(e,t){let n=e.node(t.id),r=n?L(n.x,n.y,n.width,n.height):{x:0,y:0};return{id:t.id,label:t.label,x:r.x,y:r.y,width:n?.width??0,height:n?.height??0,children:t.children.map(t=>Ne(e,t))}}function Pe(e,t){for(let n of e)Fe(n,t)}function Fe(e,t){for(let n of e.children)Fe(n,t);if(e.children.length>0){let t=e.y,n=e.y+e.height;for(let r of e.children)t=Math.min(t,r.y),n=Math.max(n,r.y+r.height);e.height=n-t,e.y=t}if(e.label){let n=t+Se;e.y-=n,e.height+=n}}function Ie(e){let t=[];for(let n of e)t.push(n),t.push(...Ie(n.children));return t}function Le(e,t){for(let n of e){if(n.id===t)return n;let e=Le(n.children,t);if(e)return e}}function Re(e,t,n){return{...e,x:e.x+t,y:e.y+n,children:e.children.map(e=>Re(e,t,n))}}function ze(e,t){t.add(e.id);for(let n of e.children)ze(n,t)}function Be(e,t,n=`Inter`,r=!1){let i=[];i.push(S(e.width,e.height,t,r)),i.push(x(n,!1)),i.push(`<defs>`),i.push(Ve()),i.push(`</defs>`);for(let t of e.groups)i.push(He(t));for(let t of e.edges)i.push(Ue(t));for(let t of e.edges)t.label&&i.push(Ge(t));for(let t of e.nodes)i.push(Je(t));for(let t of e.nodes)i.push(lt(t));return i.push(`</svg>`),i.join(`
18
+ `)}function Ve(){let e=I.width,t=I.height;return` <marker id="arrowhead" markerWidth="${e}" markerHeight="${t}" refX="${e}" refY="${t/2}" orient="auto">
19
+ <polygon points="0 0, ${e} ${t/2}, 0 ${t}" fill="var(--_arrow)" />
20
+ </marker>
21
+ <marker id="arrowhead-start" markerWidth="${e}" markerHeight="${t}" refX="0" refY="${t/2}" orient="auto-start-reverse">
22
+ <polygon points="${e} 0, 0 ${t/2}, ${e} ${t}" fill="var(--_arrow)" />
23
+ </marker>`}function He(e,t){let n=j.groupHeader+16,r=[];r.push(`<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="0" ry="0" fill="var(--_group-fill)" stroke="var(--_node-stroke)" stroke-width="${P.outerBox}" />`),r.push(`<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${n}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${P.outerBox}" />`),r.push(`<text x="${e.x+12}" y="${e.y+n/2}" dy="${F}" font-size="${j.groupHeader}" font-weight="${M.groupHeader}" fill="var(--_text-sec)">${G(e.label)}</text>`);for(let t of e.children)r.push(He(t));return r.join(`
24
+ `)}function Ue(e){if(e.points.length<2)return``;let t=We(e.points),n=e.style===`dotted`?` stroke-dasharray="4 4"`:``,r=e.style===`thick`?P.connector*2:P.connector,i=``;return e.hasArrowEnd&&(i+=` marker-end="url(#arrowhead)"`),e.hasArrowStart&&(i+=` marker-start="url(#arrowhead-start)"`),`<polyline points="${t}" fill="none" stroke="var(--_line)" stroke-width="${r}"${n}${i} />`}function We(e){return e.map(e=>`${e.x},${e.y}`).join(` `)}function Ge(e,t){let n=e.labelPosition??Ke(e.points),r=e.label,i=A(r,j.edgeLabel,M.edgeLabel)+16,a=j.edgeLabel+16;return`<rect x="${n.x-i/2}" y="${n.y-a/2}" width="${i}" height="${a}" rx="4" ry="4" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
25
+ <text x="${n.x}" y="${n.y}" text-anchor="middle" dy="${F}" font-size="${j.edgeLabel}" font-weight="${M.edgeLabel}" fill="var(--_text-muted)">${G(r)}</text>`}function Ke(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];let t=0;for(let n=1;n<e.length;n++)t+=qe(e[n-1],e[n]);let n=t/2;for(let t=1;t<e.length;t++){let r=qe(e[t-1],e[t]);if(n<=r){let i=n/r;return{x:e[t-1].x+i*(e[t].x-e[t-1].x),y:e[t-1].y+i*(e[t].y-e[t-1].y)}}n-=r}return e[e.length-1]}function qe(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}function Je(e){let{x:t,y:n,width:r,height:i,shape:a,inlineStyle:o}=e,s=G(o?.fill??`var(--_node-fill)`),c=G(o?.stroke??`var(--_node-stroke)`),l=G(o?.[`stroke-width`]??String(P.innerBox));switch(a){case`diamond`:return $e(t,n,r,i,s,c,l);case`rounded`:return Xe(t,n,r,i,s,c,l);case`stadium`:return Ze(t,n,r,i,s,c,l);case`circle`:return Qe(t,n,r,i,s,c,l);case`subroutine`:return et(t,n,r,i,s,c,l);case`doublecircle`:return tt(t,n,r,i,s,c,l);case`hexagon`:return nt(t,n,r,i,s,c,l);case`cylinder`:return rt(t,n,r,i,s,c,l);case`asymmetric`:return it(t,n,r,i,s,c,l);case`trapezoid`:return at(t,n,r,i,s,c,l);case`trapezoid-alt`:return ot(t,n,r,i,s,c,l);case`state-start`:return st(t,n,r,i);case`state-end`:return ct(t,n,r,i);default:return Ye(t,n,r,i,s,c,l)}}function Ye(e,t,n,r,i,a,o){return`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="0" ry="0" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function Xe(e,t,n,r,i,a,o){return`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="6" ry="6" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function Ze(e,t,n,r,i,a,o){let s=r/2;return`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="${s}" ry="${s}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function Qe(e,t,n,r,i,a,o){return`<circle cx="${e+n/2}" cy="${t+r/2}" r="${Math.min(n,r)/2}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function $e(e,t,n,r,i,a,o){let s=e+n/2,c=t+r/2,l=n/2,u=r/2;return`<polygon points="${[`${s},${c-u}`,`${s+l},${c}`,`${s},${c+u}`,`${s-l},${c}`].join(` `)}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function et(e,t,n,r,i,a,o){return`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="0" ry="0" fill="${i}" stroke="${a}" stroke-width="${o}" />
26
+ <line x1="${e+8}" y1="${t}" x2="${e+8}" y2="${t+r}" stroke="${a}" stroke-width="${o}" />
27
+ <line x1="${e+n-8}" y1="${t}" x2="${e+n-8}" y2="${t+r}" stroke="${a}" stroke-width="${o}" />`}function tt(e,t,n,r,i,a,o){let s=e+n/2,c=t+r/2,l=Math.min(n,r)/2;return`<circle cx="${s}" cy="${c}" r="${l}" fill="${i}" stroke="${a}" stroke-width="${o}" />
28
+ <circle cx="${s}" cy="${c}" r="${l-5}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function nt(e,t,n,r,i,a,o){let s=r/4;return`<polygon points="${[`${e+s},${t}`,`${e+n-s},${t}`,`${e+n},${t+r/2}`,`${e+n-s},${t+r}`,`${e+s},${t+r}`,`${e},${t+r/2}`].join(` `)}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function rt(e,t,n,r,i,a,o){let s=e+n/2,c=t+7,l=r-14;return`<rect x="${e}" y="${c}" width="${n}" height="${l}" fill="${i}" stroke="none" />
29
+ <line x1="${e}" y1="${c}" x2="${e}" y2="${c+l}" stroke="${a}" stroke-width="${o}" />
30
+ <line x1="${e+n}" y1="${c}" x2="${e+n}" y2="${c+l}" stroke="${a}" stroke-width="${o}" />
31
+ <ellipse cx="${s}" cy="${t+r-7}" rx="${n/2}" ry="7" fill="${i}" stroke="${a}" stroke-width="${o}" />
32
+ <ellipse cx="${s}" cy="${c}" rx="${n/2}" ry="7" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function it(e,t,n,r,i,a,o){return`<polygon points="${[`${e+12},${t}`,`${e+n},${t}`,`${e+n},${t+r}`,`${e+12},${t+r}`,`${e},${t+r/2}`].join(` `)}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function at(e,t,n,r,i,a,o){let s=n*.15;return`<polygon points="${[`${e+s},${t}`,`${e+n-s},${t}`,`${e+n},${t+r}`,`${e},${t+r}`].join(` `)}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function ot(e,t,n,r,i,a,o){let s=n*.15;return`<polygon points="${[`${e},${t}`,`${e+n},${t}`,`${e+n-s},${t+r}`,`${e+s},${t+r}`].join(` `)}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function st(e,t,n,r){return`<circle cx="${e+n/2}" cy="${t+r/2}" r="${Math.min(n,r)/2-2}" fill="var(--_text)" stroke="none" />`}function ct(e,t,n,r){let i=e+n/2,a=t+r/2,o=Math.min(n,r)/2-2,s=o-4;return`<circle cx="${i}" cy="${a}" r="${o}" fill="none" stroke="var(--_text)" stroke-width="${P.innerBox*2}" />
33
+ <circle cx="${i}" cy="${a}" r="${s}" fill="var(--_text)" stroke="none" />`}function lt(e,t){if((e.shape===`state-start`||e.shape===`state-end`)&&!e.label)return``;let n=e.x+e.width/2,r=e.y+e.height/2,i=G(e.inlineStyle?.color??`var(--_text)`);return`<text x="${n}" y="${r}" text-anchor="middle" dy="${F}" font-size="${j.nodeLabel}" font-weight="${M.nodeLabel}" fill="${i}">${G(e.label)}</text>`}function G(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}var K={padding:30,actorGap:140,actorHeight:40,actorPadX:16,headerGap:20,messageRowHeight:40,selfMessageHeight:30,activationWidth:10,blockPadX:10,blockPadTop:40,blockPadBottom:8,blockHeaderExtra:28,dividerExtra:24,noteWidth:120,notePadding:8,noteGap:10};function ut(e,t={}){if(e.actors.length===0)return{width:0,height:0,actors:[],lifelines:[],messages:[],activations:[],blocks:[],notes:[]};let n=e.actors.map(e=>{let t=A(e.label,j.nodeLabel,M.nodeLabel);return Math.max(t+K.actorPadX*2,80)}),r=[],i=K.padding+n[0]/2;for(let t=0;t<e.actors.length;t++){if(t>0){let e=Math.max(K.actorGap,(n[t-1]+n[t])/2+40);i+=e}r.push(i)}let a=new Map;for(let t=0;t<e.actors.length;t++)a.set(e.actors[t].id,t);let o=K.padding,s=e.actors.map((e,t)=>({id:e.id,label:e.label,type:e.type,x:r[t],y:o,width:n[t],height:K.actorHeight})),c=o+K.actorHeight+K.headerGap,l=[],u=new Map;for(let t of e.blocks){let e=u.get(t.startIndex)??0;u.set(t.startIndex,Math.max(e,K.blockHeaderExtra));for(let e of t.dividers){let t=u.get(e.index)??0;u.set(e.index,Math.max(t,K.dividerExtra))}}let d=new Map,f=[];for(let t=0;t<e.messages.length;t++){let n=e.messages[t],i=a.get(n.from)??0,o=a.get(n.to)??0,s=n.from===n.to,p=u.get(t)??0;p>0&&(c+=p);let m=r[i],h=r[o];if(l.push({from:n.from,to:n.to,label:n.label,lineStyle:n.lineStyle,arrowHead:n.arrowHead,x1:m,x2:h,y:c,isSelf:s}),n.activate&&(d.has(n.to)||d.set(n.to,[]),d.get(n.to).push(c)),n.deactivate){let e=d.get(n.from);if(e&&e.length>0){let t=e.pop(),i=a.get(n.from)??0;f.push({actorId:n.from,x:r[i]-K.activationWidth/2,topY:t,bottomY:c,width:K.activationWidth})}}c+=s?K.selfMessageHeight+K.messageRowHeight:K.messageRowHeight}for(let[e,t]of d)for(let n of t){let t=a.get(e)??0;f.push({actorId:e,x:r[t]-K.activationWidth/2,topY:n,bottomY:c-K.messageRowHeight/2,width:K.activationWidth})}let p=e.blocks.map(t=>{let i=l[t.startIndex],o=l[t.endIndex],s=(i?.y??c)-K.blockPadTop,u=(o?.y??c)+K.blockPadBottom+12,d=new Set;for(let n=t.startIndex;n<=t.endIndex;n++){let t=e.messages[n];t&&(d.add(a.get(t.from)??0),d.add(a.get(t.to)??0))}if(d.size===0)for(let t=0;t<e.actors.length;t++)d.add(t);let f=Math.min(...d),p=Math.max(...d),m=r[f]-n[f]/2-K.blockPadX,h=r[p]+n[p]/2+K.blockPadX,g=t.dividers.map(e=>{let t=l[e.index],n=t?.y??c,r=28;if(e.label&&t?.label){let n=A(`[${e.label}]`,j.edgeLabel,M.edgeLabel),i=m+8,a=i+n,o=A(t.label,j.edgeLabel,M.edgeLabel),s=t.isSelf?t.x1+36:(t.x1+t.x2)/2-o/2,c=s+o;a>s&&i<c&&(r=36)}return{y:n-r,label:e.label}});return{type:t.type,label:t.label,x:m,y:s,width:h-m,height:u-s,dividers:g}}),m=e.notes.map(e=>{let t=Math.max(K.noteWidth,A(e.text,j.edgeLabel,M.edgeLabel)+K.notePadding*2),i=j.edgeLabel+K.notePadding*2,s=(l[e.afterIndex]?.y??o+K.actorHeight)+4,c=a.get(e.actorIds[0]??``)??0,u;if(e.position===`left`)u=r[c]-n[c]/2-t-K.noteGap;else if(e.position===`right`)u=r[c]+n[c]/2+K.noteGap;else if(e.actorIds.length>1){let n=a.get(e.actorIds[e.actorIds.length-1]??``)??c;u=(r[c]+r[n])/2-t/2}else u=r[c]-t/2;return{text:e.text,x:u,y:s,width:t,height:i}}),h=c+K.padding,g=K.padding,_=0;for(let e of s)g=Math.min(g,e.x-e.width/2),_=Math.max(_,e.x+e.width/2);for(let e of p)g=Math.min(g,e.x),_=Math.max(_,e.x+e.width);for(let e of m)g=Math.min(g,e.x),_=Math.max(_,e.x+e.width);let v=g<K.padding?K.padding-g:0;if(v>0){for(let e of s)e.x+=v;for(let e of l)e.x1+=v,e.x2+=v;for(let e of f)e.x+=v;for(let e of p)e.x+=v;for(let e of m)e.x+=v;for(let e=0;e<r.length;e++)r[e]+=v}let y=e.actors.map((e,t)=>({actorId:e.id,x:r[t],topY:o+K.actorHeight,bottomY:h-K.padding})),b=_+v+K.padding;return{width:Math.max(b,200),height:Math.max(h,100),actors:s,lifelines:y,messages:l,activations:f,blocks:p,notes:m}}function dt(e,t,n=`Inter`,r=!1){let i=[];i.push(S(e.width,e.height,t,r)),i.push(x(n,!1)),i.push(`<defs>`),i.push(ft()),i.push(`</defs>`);for(let t of e.blocks)i.push(_t(t));for(let t of e.lifelines)i.push(mt(t));for(let t of e.activations)i.push(ht(t));for(let t of e.messages)i.push(gt(t));for(let t of e.notes)i.push(vt(t));for(let t of e.actors)i.push(pt(t));return i.push(`</svg>`),i.join(`
34
+ `)}function ft(){let e=I.width,t=I.height;return` <marker id="seq-arrow" markerWidth="${e}" markerHeight="${t}" refX="${e}" refY="${t/2}" orient="auto-start-reverse">
35
+ <polygon points="0 0, ${e} ${t/2}, 0 ${t}" fill="var(--_arrow)" />
36
+ </marker>
37
+ <marker id="seq-arrow-open" markerWidth="${e}" markerHeight="${t}" refX="${e}" refY="${t/2}" orient="auto-start-reverse">
38
+ <polyline points="0 0, ${e} ${t/2}, 0 ${t}" fill="none" stroke="var(--_arrow)" stroke-width="1" />
39
+ </marker>`}function pt(e){let{x:t,y:n,width:r,height:i,label:a,type:o}=e;if(o===`actor`){let e=i/24*.9,r=t-12*e,o=n+(i-24*e)/2,s=P.outerBox/e,c=`var(--_line)`;return`<g transform="translate(${r},${o}) scale(${e})">
40
+ <path d="M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" fill="none" stroke="${c}" stroke-width="${s}" />
41
+ <path d="M15 10C15 11.6569 13.6569 13 12 13C10.3431 13 9 11.6569 9 10C9 8.34315 10.3431 7 12 7C13.6569 7 15 8.34315 15 10Z" fill="none" stroke="${c}" stroke-width="${s}" />
42
+ <path d="M5.62842 18.3563C7.08963 17.0398 9.39997 16 12 16C14.6 16 16.9104 17.0398 18.3716 18.3563" fill="none" stroke="${c}" stroke-width="${s}" />
43
+ </g>
44
+ <text x="${t}" y="${n+i+14}" text-anchor="middle" font-size="${j.nodeLabel}" font-weight="${M.nodeLabel}" fill="var(--_text)">${q(a)}</text>`}return`<rect x="${t-r/2}" y="${n}" width="${r}" height="${i}" rx="4" ry="4" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${P.outerBox}" />
45
+ <text x="${t}" y="${n+i/2}" text-anchor="middle" dy="${F}" font-size="${j.nodeLabel}" font-weight="${M.nodeLabel}" fill="var(--_text)">${q(a)}</text>`}function mt(e){return`<line x1="${e.x}" y1="${e.topY}" x2="${e.x}" y2="${e.bottomY}" stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`}function ht(e){return`<rect x="${e.x}" y="${e.topY}" width="${e.width}" height="${e.bottomY-e.topY}" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${P.innerBox}" />`}function gt(e){let t=[],n=e.lineStyle===`dashed`?` stroke-dasharray="6 4"`:``,r=e.arrowHead===`filled`?`seq-arrow`:`seq-arrow-open`;if(e.isSelf)t.push(`<polyline points="${e.x1},${e.y} ${e.x1+30},${e.y} ${e.x1+30},${e.y+20} ${e.x2},${e.y+20}" fill="none" stroke="var(--_line)" stroke-width="${P.connector}"${n} marker-end="url(#${r})" />`),t.push(`<text x="${e.x1+30+6}" y="${e.y+20/2}" dy="${F}" font-size="${j.edgeLabel}" font-weight="${M.edgeLabel}" fill="var(--_text-muted)">${q(e.label)}</text>`);else{t.push(`<line x1="${e.x1}" y1="${e.y}" x2="${e.x2}" y2="${e.y}" stroke="var(--_line)" stroke-width="${P.connector}"${n} marker-end="url(#${r})" />`);let i=(e.x1+e.x2)/2;t.push(`<text x="${i}" y="${e.y-6}" text-anchor="middle" font-size="${j.edgeLabel}" font-weight="${M.edgeLabel}" fill="var(--_text-muted)">${q(e.label)}</text>`)}return t.join(`
46
+ `)}function _t(e){let t=[];t.push(`<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="0" ry="0" fill="none" stroke="var(--_node-stroke)" stroke-width="${P.outerBox}" />`);let n=`${e.type}${e.label?` [${e.label}]`:``}`,r=A(n,j.edgeLabel,M.groupHeader)+16;t.push(`<rect x="${e.x}" y="${e.y}" width="${r}" height="18" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${P.outerBox}" />`),t.push(`<text x="${e.x+6}" y="${e.y+18/2}" dy="${F}" font-size="${j.edgeLabel}" font-weight="${M.groupHeader}" fill="var(--_text-sec)">${q(n)}</text>`);for(let n of e.dividers)t.push(`<line x1="${e.x}" y1="${n.y}" x2="${e.x+e.width}" y2="${n.y}" stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`),n.label&&t.push(`<text x="${e.x+8}" y="${n.y+14}" font-size="${j.edgeLabel}" font-weight="${M.edgeLabel}" fill="var(--_text-muted)">[${q(n.label)}]</text>`);return t.join(`
47
+ `)}function vt(e){return`<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${P.innerBox}" />
48
+ <polygon points="${e.x+e.width-6},${e.y} ${e.x+e.width},${e.y+6} ${e.x+e.width-6},${e.y+6}" fill="var(--_inner-stroke)" />
49
+ <text x="${e.x+e.width/2}" y="${e.y+e.height/2}" text-anchor="middle" dy="${F}" font-size="${j.edgeLabel}" font-weight="${M.edgeLabel}" fill="var(--_text-muted)">${q(e.text)}</text>`}function q(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}var J={padding:40,boxPadX:8,headerBaseHeight:32,annotationHeight:16,memberRowHeight:20,sectionPadY:8,emptySectionHeight:8,minWidth:120,memberFontSize:11,nodeSpacing:40,layerSpacing:60};async function yt(e,t={}){if(e.classes.length===0)return{width:0,height:0,classes:[],relationships:[]};let n=new Map;for(let t of e.classes){let e=t.annotation?J.headerBaseHeight+J.annotationHeight:J.headerBaseHeight,r=t.attributes.length>0?t.attributes.length*J.memberRowHeight+J.sectionPadY:J.emptySectionHeight,i=t.methods.length>0?t.methods.length*J.memberRowHeight+J.sectionPadY:J.emptySectionHeight,a=A(t.label,j.nodeLabel,M.nodeLabel),o=bt(t.attributes),s=bt(t.methods),c=Math.max(J.minWidth,a+J.boxPadX*2,o+J.boxPadX*2,s+J.boxPadX*2),l=e+r+i;n.set(t.id,{width:c,height:l,headerHeight:e,attrHeight:r,methodHeight:i})}let r=new _.default.graphlib.Graph({directed:!0});r.setGraph({rankdir:`TB`,acyclicer:`greedy`,nodesep:J.nodeSpacing,ranksep:J.layerSpacing,marginx:J.padding,marginy:J.padding}),r.setDefaultEdgeLabel(()=>({}));for(let t of e.classes){let e=n.get(t.id);r.setNode(t.id,{width:e.width,height:e.height})}for(let t=0;t<e.relationships.length;t++){let n=e.relationships[t],i={_index:t};n.label&&(i.label=n.label,i.width=A(n.label,j.edgeLabel,M.edgeLabel)+8,i.height=j.edgeLabel+6,i.labelpos=`c`),r.setEdge(n.from,n.to,i)}try{_.default.layout(r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Dagre layout failed (class diagram): ${t}`)}let i=new Map;for(let t of e.classes)i.set(t.id,t);let a=e.classes.map(e=>{let t=r.node(e.id),i=n.get(e.id),a=L(t.x,t.y,t.width,t.height);return{id:e.id,label:e.label,annotation:e.annotation,attributes:e.attributes,methods:e.methods,x:a.x,y:a.y,width:t.width??i.width,height:t.height??i.height,headerHeight:i.headerHeight,attrHeight:i.attrHeight,methodHeight:i.methodHeight}}),o=r.edges().map(t=>{let n=r.edge(t),i=e.relationships[n._index],a=B(n.points??[],!0),o=r.node(t.v),s=r.node(t.w),c=V(a,o?{cx:o.x,cy:o.y,hw:o.width/2,hh:o.height/2}:null,s?{cx:s.x,cy:s.y,hw:s.width/2,hh:s.height/2}:null),l;return i.label&&n.x!=null&&n.y!=null&&(l={x:n.x,y:n.y}),{from:i.from,to:i.to,type:i.type,markerAt:i.markerAt,label:i.label,fromCardinality:i.fromCardinality,toCardinality:i.toCardinality,points:c,labelPosition:l}});return{width:r.graph().width??600,height:r.graph().height??400,classes:a,relationships:o}}function bt(e){if(e.length===0)return 0;let t=0;for(let n of e){let e=xe(xt(n),J.memberFontSize);e>t&&(t=e)}return t}function xt(e){let t=e.visibility?`${e.visibility} `:``,n=e.type?`: ${e.type}`:``;return`${t}${e.name}${n}`}var Y={memberSize:11,memberWeight:400,annotationSize:10,annotationWeight:500};function St(e,t,n=`Inter`,r=!1){let i=[];i.push(S(e.width,e.height,t,r)),i.push(x(n,!0)),i.push(`<defs>`),i.push(Ct()),i.push(`</defs>`);for(let t of e.relationships)i.push(Et(t));for(let t of e.classes)i.push(wt(t));for(let t of e.relationships)i.push(kt(t));return i.push(`</svg>`),i.join(`
50
+ `)}function Ct(){return` <marker id="cls-inherit" markerWidth="12" markerHeight="10" refX="12" refY="5" orient="auto-start-reverse">
51
+ <polygon points="0 0, 12 5, 0 10" fill="var(--bg)" stroke="var(--_arrow)" stroke-width="1.5" />
52
+ </marker>
53
+ <marker id="cls-composition" markerWidth="12" markerHeight="10" refX="0" refY="5" orient="auto-start-reverse">
54
+ <polygon points="6 0, 12 5, 6 10, 0 5" fill="var(--_arrow)" stroke="var(--_arrow)" stroke-width="1" />
55
+ </marker>
56
+ <marker id="cls-aggregation" markerWidth="12" markerHeight="10" refX="0" refY="5" orient="auto-start-reverse">
57
+ <polygon points="6 0, 12 5, 6 10, 0 5" fill="var(--bg)" stroke="var(--_arrow)" stroke-width="1.5" />
58
+ </marker>
59
+ <marker id="cls-arrow" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto-start-reverse">
60
+ <polyline points="0 0, 8 3, 0 6" fill="none" stroke="var(--_arrow)" stroke-width="1.5" />
61
+ </marker>`}function wt(e){let{x:t,y:n,width:r,height:i,headerHeight:a,attrHeight:o,methodHeight:s}=e,c=[];c.push(`<rect x="${t}" y="${n}" width="${r}" height="${i}" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${P.outerBox}" />`),c.push(`<rect x="${t}" y="${n}" width="${r}" height="${a}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${P.outerBox}" />`);let l=n+a/2;if(e.annotation){let i=n+12;c.push(`<text x="${t+r/2}" y="${i}" text-anchor="middle" dy="${F}" font-size="${Y.annotationSize}" font-weight="${Y.annotationWeight}" font-style="italic" fill="var(--_text-muted)">&lt;&lt;${X(e.annotation)}&gt;&gt;</text>`),l=n+a/2+6}c.push(`<text x="${t+r/2}" y="${l}" text-anchor="middle" dy="${F}" font-size="${j.nodeLabel}" font-weight="700" fill="var(--_text)">${X(e.label)}</text>`);let u=n+a;c.push(`<line x1="${t}" y1="${u}" x2="${t+r}" y2="${u}" stroke="var(--_node-stroke)" stroke-width="${P.innerBox}" />`);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n],i=u+4+n*20+20/2;c.push(Tt(r,t+J.boxPadX,i))}let d=u+o;c.push(`<line x1="${t}" y1="${d}" x2="${t+r}" y2="${d}" stroke="var(--_node-stroke)" stroke-width="${P.innerBox}" />`);for(let n=0;n<e.methods.length;n++){let r=e.methods[n],i=d+4+n*20+20/2;c.push(Tt(r,t+J.boxPadX,i))}return c.join(`
62
+ `)}function Tt(e,t,n){let r=e.isAbstract?` font-style="italic"`:``,i=e.isStatic?` text-decoration="underline"`:``,a=[];return e.visibility&&a.push(`<tspan fill="var(--_text-faint)">${X(e.visibility)} </tspan>`),a.push(`<tspan fill="var(--_text-sec)">${X(e.name)}</tspan>`),e.type&&(a.push(`<tspan fill="var(--_text-faint)">: </tspan>`),a.push(`<tspan fill="var(--_text-muted)">${X(e.type)}</tspan>`)),`<text x="${t}" y="${n}" class="mono" dy="${F}" font-size="${Y.memberSize}" font-weight="${Y.memberWeight}"${r}${i}>${a.join(``)}</text>`}function Et(e){if(e.points.length<2)return``;let t=e.points.map(e=>`${e.x},${e.y}`).join(` `),n=e.type===`dependency`||e.type===`realization`?` stroke-dasharray="6 4"`:``,r=Dt(e.type,e.markerAt);return`<polyline points="${t}" fill="none" stroke="var(--_line)" stroke-width="${P.connector}"${n}${r} />`}function Dt(e,t){let n=Ot(e);return n?t===`from`?` marker-start="url(#${n})"`:` marker-end="url(#${n})"`:``}function Ot(e){switch(e){case`inheritance`:case`realization`:return`cls-inherit`;case`composition`:return`cls-composition`;case`aggregation`:return`cls-aggregation`;case`association`:case`dependency`:return`cls-arrow`;default:return null}}function kt(e){if(!e.label&&!e.fromCardinality&&!e.toCardinality||e.points.length<2)return``;let t=[];if(e.label){let n=e.labelPosition??At(e.points);t.push(`<text x="${n.x}" y="${n.y-8}" text-anchor="middle" font-size="${j.edgeLabel}" font-weight="${M.edgeLabel}" fill="var(--_text-muted)">${X(e.label)}</text>`)}if(e.fromCardinality){let n=e.points[0],r=e.points[1],i=jt(n,r);t.push(`<text x="${n.x+i.x}" y="${n.y+i.y}" text-anchor="middle" font-size="${j.edgeLabel}" font-weight="${M.edgeLabel}" fill="var(--_text-muted)">${X(e.fromCardinality)}</text>`)}if(e.toCardinality){let n=e.points[e.points.length-1],r=e.points[e.points.length-2],i=jt(n,r);t.push(`<text x="${n.x+i.x}" y="${n.y+i.y}" text-anchor="middle" font-size="${j.edgeLabel}" font-weight="${M.edgeLabel}" fill="var(--_text-muted)">${X(e.toCardinality)}</text>`)}return t.join(`
63
+ `)}function At(e){return e.length===0?{x:0,y:0}:e[Math.floor(e.length/2)]}function jt(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.abs(n)>Math.abs(r)?{x:n>0?14:-14,y:-10}:{x:-14,y:r>0?14:-14}}function X(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}var Z={padding:40,boxPadX:12,headerHeight:32,rowHeight:22,minWidth:140,attrFontSize:11,nodeSpacing:50,layerSpacing:70};async function Mt(e,t={}){if(e.entities.length===0)return{width:0,height:0,entities:[],relationships:[]};let n=new Map;for(let t of e.entities){let e=A(t.label,j.nodeLabel,M.nodeLabel),r=0;for(let e of t.attributes){let t=xe(`${e.type} ${e.name}${e.keys.length>0?` `+e.keys.join(`,`):``}`,Z.attrFontSize);t>r&&(r=t)}let i=Math.max(Z.minWidth,e+Z.boxPadX*2,r+Z.boxPadX*2),a=Z.headerHeight+Math.max(t.attributes.length,1)*Z.rowHeight;n.set(t.id,{width:i,height:a})}let r=new _.default.graphlib.Graph({directed:!0});r.setGraph({rankdir:`LR`,acyclicer:`greedy`,nodesep:Z.nodeSpacing,ranksep:Z.layerSpacing,marginx:Z.padding,marginy:Z.padding}),r.setDefaultEdgeLabel(()=>({}));for(let t of e.entities){let e=n.get(t.id);r.setNode(t.id,{width:e.width,height:e.height})}for(let t=0;t<e.relationships.length;t++){let n=e.relationships[t];r.setEdge(n.entity1,n.entity2,{_index:t,label:n.label,width:A(n.label,j.edgeLabel,M.edgeLabel)+8,height:j.edgeLabel+6,labelpos:`c`})}try{_.default.layout(r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Dagre layout failed (ER diagram): ${t}`)}let i=new Map;for(let t of e.entities)i.set(t.id,t);let a=e.entities.map(e=>{let t=r.node(e.id),i=L(t.x,t.y,t.width,t.height);return{id:e.id,label:e.label,attributes:e.attributes,x:i.x,y:i.y,width:t.width??n.get(e.id).width,height:t.height??n.get(e.id).height,headerHeight:Z.headerHeight,rowHeight:Z.rowHeight}}),o=r.edges().map(t=>{let n=r.edge(t),i=e.relationships[n._index],a=B(n.points??[],!1),o=r.node(t.v),s=r.node(t.w),c=V(a,o?{cx:o.x,cy:o.y,hw:o.width/2,hh:o.height/2}:null,s?{cx:s.x,cy:s.y,hw:s.width/2,hh:s.height/2}:null);return{entity1:i.entity1,entity2:i.entity2,cardinality1:i.cardinality1,cardinality2:i.cardinality2,label:i.label,identifying:i.identifying,points:c}});return{width:r.graph().width??600,height:r.graph().height??400,entities:a,relationships:o}}var Q={attrSize:11,attrWeight:400,keySize:9,keyWeight:600};function Nt(e,t,n=`Inter`,r=!1){let i=[];i.push(S(e.width,e.height,t,r)),i.push(x(n,!0)),i.push(`<defs>`),i.push(`</defs>`);for(let t of e.relationships)i.push(It(t));for(let t of e.entities)i.push(Pt(t));for(let t of e.relationships)i.push(Rt(t));for(let t of e.relationships)i.push(Lt(t));return i.push(`</svg>`),i.join(`
64
+ `)}function Pt(e){let{x:t,y:n,width:r,height:i,headerHeight:a,rowHeight:o,label:s,attributes:c}=e,l=[];l.push(`<rect x="${t}" y="${n}" width="${r}" height="${i}" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${P.outerBox}" />`),l.push(`<rect x="${t}" y="${n}" width="${r}" height="${a}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${P.outerBox}" />`),l.push(`<text x="${t+r/2}" y="${n+a/2}" text-anchor="middle" dy="${F}" font-size="${j.nodeLabel}" font-weight="700" fill="var(--_text)">${$(s)}</text>`);let u=n+a;l.push(`<line x1="${t}" y1="${u}" x2="${t+r}" y2="${u}" stroke="var(--_node-stroke)" stroke-width="${P.innerBox}" />`);for(let e=0;e<c.length;e++){let n=c[e],i=u+e*o+o/2;l.push(Ft(n,t,i,r))}return c.length===0&&l.push(`<text x="${t+r/2}" y="${u+o/2}" text-anchor="middle" dy="${F}" font-size="${Q.attrSize}" fill="var(--_text-faint)" font-style="italic">(no attributes)</text>`),l.join(`
65
+ `)}function Ft(e,t,n,r){let i=[],a=0;e.keys.length>0&&(a=A(e.keys.join(`,`),Q.keySize,Q.keyWeight)+8,i.push(`<rect x="${t+6}" y="${n-7}" width="${a}" height="14" rx="2" ry="2" fill="var(--_key-badge)" />`),i.push(`<text x="${t+6+a/2}" y="${n}" text-anchor="middle" dy="${F}" font-size="${Q.keySize}" font-weight="${Q.keyWeight}" fill="var(--_text-sec)">${e.keys.join(`,`)}</text>`));let o=t+8+(a>0?a+6:0);i.push(`<text x="${o}" y="${n}" class="mono" dy="${F}" font-size="${Q.attrSize}" font-weight="${Q.attrWeight}"><tspan fill="var(--_text-muted)">${$(e.type)}</tspan></text>`);let s=t+r-8;return i.push(`<text x="${s}" y="${n}" class="mono" text-anchor="end" dy="${F}" font-size="${Q.attrSize}" font-weight="${Q.attrWeight}"><tspan fill="var(--_text-sec)">${$(e.name)}</tspan></text>`),i.join(`
66
+ `)}function It(e){if(e.points.length<2)return``;let t=e.points.map(e=>`${e.x},${e.y}`).join(` `),n=e.identifying?``:` stroke-dasharray="6 4"`;return`<polyline points="${t}" fill="none" stroke="var(--_line)" stroke-width="${P.connector}"${n} />`}function Lt(e){if(!e.label||e.points.length<2)return``;let t=Bt(e.points),n=A(e.label,j.edgeLabel,M.edgeLabel)+8,r=j.edgeLabel+6;return`<rect x="${t.x-n/2}" y="${t.y-r/2}" width="${n}" height="${r}" rx="2" ry="2" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />
67
+ <text x="${t.x}" y="${t.y}" text-anchor="middle" dy="${F}" font-size="${j.edgeLabel}" font-weight="${M.edgeLabel}" fill="var(--_text-muted)">${$(e.label)}</text>`}function Rt(e){if(e.points.length<2)return``;let t=[],n=e.points[0],r=e.points[1];t.push(zt(n,r,e.cardinality1));let i=e.points[e.points.length-1],a=e.points[e.points.length-2];return t.push(zt(i,a,e.cardinality2)),t.join(`
68
+ `)}function zt(e,t,n){let r=[],i=P.connector+.25,a=e.x-t.x,o=e.y-t.y,s=Math.sqrt(a*a+o*o);if(s===0)return``;let c=a/s,l=o/s,u=-l,d=c,f=e.x-c*4,p=e.y-l*4,m=e.x-c*16,h=e.y-l*16,g=n===`one`||n===`zero-one`,_=n===`many`||n===`zero-many`,v=n===`zero-one`||n===`zero-many`;if(g){r.push(`<line x1="${f+u*6}" y1="${p+d*6}" x2="${f-u*6}" y2="${p-d*6}" stroke="var(--_line)" stroke-width="${i}" />`);let e=f-c*4,t=p-l*4;r.push(`<line x1="${e+u*6}" y1="${t+d*6}" x2="${e-u*6}" y2="${t-d*6}" stroke="var(--_line)" stroke-width="${i}" />`)}if(_){let e=f,t=p;r.push(`<line x1="${e+u*7}" y1="${t+d*7}" x2="${m}" y2="${h}" stroke="var(--_line)" stroke-width="${i}" />`),r.push(`<line x1="${e}" y1="${t}" x2="${m}" y2="${h}" stroke="var(--_line)" stroke-width="${i}" />`),r.push(`<line x1="${e-u*7}" y1="${t-d*7}" x2="${m}" y2="${h}" stroke="var(--_line)" stroke-width="${i}" />`)}if(v){let t=_?20:12,n=e.x-c*t,a=e.y-l*t;r.push(`<circle cx="${n}" cy="${a}" r="4" fill="var(--bg)" stroke="var(--_line)" stroke-width="${i}" />`)}return r.join(`
69
+ `)}function Bt(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];let t=0;for(let n=1;n<e.length;n++){let r=e[n].x-e[n-1].x,i=e[n].y-e[n-1].y;t+=Math.sqrt(r*r+i*i)}if(t===0)return e[0];let n=t/2,r=0;for(let t=1;t<e.length;t++){let i=e[t].x-e[t-1].x,a=e[t].y-e[t-1].y,o=Math.sqrt(i*i+a*a);if(r+o>=n){let s=o>0?(n-r)/o:0;return{x:e[t-1].x+i*s,y:e[t-1].y+a*s}}r+=o}return e[e.length-1]}function $(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Vt(e){let t=e.trim().split(`
70
+ `)[0]?.trim().toLowerCase()??``;return/^sequencediagram\s*$/.test(t)?`sequence`:/^classdiagram\s*$/.test(t)?`class`:/^erdiagram\s*$/.test(t)?`er`:`flowchart`}function Ht(e){return{bg:e.bg??v.bg,fg:e.fg??v.fg,line:e.line,accent:e.accent,muted:e.muted,surface:e.surface,border:e.border}}async function Ut(e,t={}){let n=Ht(t),r=t.font??`Inter`,i=t.transparent??!1,a=Vt(e),o=e.split(`
71
+ `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`%%`));switch(a){case`sequence`:return dt(ut(fe(o),t),n,r,i);case`class`:return St(await yt(O(o),t),n,r,i);case`er`:return Nt(await Mt(ge(o),t),n,r,i);default:return Be(await Ee(C(e),t),n,r,i)}}export{g as a,d as c,p as i,u as l,Ut as n,l as o,m as r,c as s,b as t};