zombie-mermaid 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ascii.cjs +7 -7
- package/dist/ascii.cjs.map +1 -1
- package/dist/ascii.js +943 -913
- package/dist/ascii.js.map +1 -1
- package/dist/cli.js +3265 -3229
- package/dist/index.cjs +51 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +191 -161
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +84 -13
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.js +84 -13
- package/dist/mcp.js.map +1 -1
- package/package.json +3 -3
- package/packages/ascii-renderer/src/class-diagram.ts +192 -12
- package/packages/ascii-renderer/src/sequence.ts +42 -8
- package/src/__tests__/ascii-class-box-occupancy.test.ts +82 -43
- package/src/__tests__/ascii-class-detour-label-routing-487.test.ts +8 -8
- package/src/__tests__/ascii-class-parent-alignment-971.test.ts +139 -0
- package/src/__tests__/ascii-class-parent-alignment-972.test.ts +208 -0
- package/src/__tests__/ascii-sequence-form-invariants.test.ts +51 -0
package/dist/index.cjs
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("elkjs/lib/elk.bundled.js");c=s(c,1);let l=require("entities");function u(e,t){let n=e.match(/^click\s+([\w\p{L}-]+)\s+(.*)$/iu);if(!n)return;let r=n[1],i=n[2].trim(),a={...t.get(r)},o=i.match(/^(?:call|callback)\s+(.+?)\s*$/i);if(o){let e=o[1].match(/^(.*?\))\s+"([^"]*)"\s*$/);e?(a.callback=e[1].trim(),a.tooltip=e[2]):a.callback=o[1].trim(),t.set(r,a);return}i=i.replace(/^href\s+/i,``);let s=[...i.matchAll(/"([^"]*)"/g)].map(e=>e[1]);s.length>0&&(a.href=s[0]),s.length>1&&(a.tooltip=s[1]);let c=i.match(/(_blank|_self|_parent|_top)\s*$/i);c&&(a.target=c[1].toLowerCase()),(a.href!==void 0||a.tooltip!==void 0)&&t.set(r,a)}function d(e){if(!e||/[\x00-\x1F\x7F]/.test(e))return;let t=e.trim();if(/^[./#?]/.test(t))return t;let n=t.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/)?.[1];return n===void 0||/^(https?|mailto)$/i.test(n)?t:void 0}var f=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,p=/^rgba?\(\s*([\d.]+%?)\s*[, ]\s*([\d.]+%?)\s*[, ]\s*([\d.]+%?)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i;function m(e){let t=h(e);return t?[t.r,t.g,t.b]:null}function h(e){let t=f.exec(e.trim());if(!t)return null;let n=t[1];if(n===void 0)return null;let r=n;return(r.length===3||r.length===4)&&(r=r.split(``).map(e=>e+e).join(``)),{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16),a:r.length===8?parseInt(r.slice(6,8),16)/255:1}}function g(e){return e.endsWith(`%`)?Number(e.slice(0,-1))/100*255:Number(e)}function _(e){return e===void 0?1:e.endsWith(`%`)?Number(e.slice(0,-1))/100:Number(e)}function v(e){let t=e.trim();if(t.toLowerCase()===`transparent`)return{r:0,g:0,b:0,a:0};let n=h(t);if(n)return n;let r=p.exec(t);if(r){let[,e,t,n,i]=r;if(e===void 0||t===void 0||n===void 0)return null;let a={r:g(e),g:g(t),b:g(n),a:_(i)};return[a.r,a.g,a.b,a.a].some(e=>Number.isNaN(e))?null:a}return null}function y(e,t,n,r){let i,a;n===void 0&&r===void 0?(i=50,a=50):n===void 0?(a=r??50,i=100-a):r===void 0?(i=n,a=100-i):(i=n,a=r);let o=i+a;if(o===0)return null;let s=o<100?o/100:1;i/=o,a/=o;let c=e.a*i+t.a*a,l=(n,r)=>c===0?0:(n*e.a*i+r*t.a*a)/c;return{r:l(e.r,t.r),g:l(e.g,t.g),b:l(e.b,t.b),a:c*s}}var b=e=>Math.min(255,Math.max(0,Math.round(e)));function x(e){let t=b(e.r),n=b(e.g),r=b(e.b),i=Math.min(1,Math.max(0,e.a));return i>=1?`#`+[t,n,r].map(e=>e.toString(16).padStart(2,`0`)).join(``):`rgba(${t}, ${n}, ${r}, ${Number(i.toFixed(3))})`}var S=/^[&#](?:#?[0-9]+|#?[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*);/,C=new Set([`&`,`#`]);function w(e){let t=null;for(let n=0;n<e.length;n++){let r=e[n];if(t!==null){r===t&&(t=null);continue}if(r===`"`||r===`'`){t=r;continue}if(C.has(r)){let t=S.exec(e.slice(n));if(t){n+=t[0].length-1;continue}}if(r===`%`&&e[n+1]===`%`)return n}return-1}function T(e){let t=[],n=``,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r!==null){n+=a,a===r&&(r=null);continue}if(a===`"`||a===`'`){r=a,n+=a;continue}if(C.has(a)){let t=S.exec(e.slice(i));if(t){n+=t[0],i+=t[0].length-1;continue}}if(a===`;`){t.push(n),n=``;continue}n+=a}return t.push(n),t}function E(e){let t=[],n=e.split(`
|
|
2
|
-
`);for(let e=0;e<n.length;e++){let r=n[e].trim(),i=e+1,a=w(r);if(a!==-1&&(r=r.slice(0,a).trim()),r.length===0)continue;let o=[];for(let e of T(r)){let t=e.trim();t.length!==0&&o.push({text:t,line:i})}o.length>0&&t.push(o)}return t}function D(e){return E(e).flat()}function O(e){let t=D(e)[0]?.text.toLowerCase()??``;return/^xychart(?:-beta)?(?:\s|$)/.test(t)?`xychart`:/^sequencediagram\s*$/.test(t)?`sequence`:/^classdiagram\s*$/.test(t)?`class`:/^erdiagram\s*$/.test(t)?`er`:`flowchart`}function k(e){return e===`TD`||e===`TB`||e===`LR`||e===`BT`||e===`RL`}function A(e){let t=e?.toUpperCase();if(t===void 0||!k(t))throw Error(`Invalid direction: "${e}"`);return t}function j(e,t){return t===void 0||!k(t)?e:{...e,direction:t}}var ee=new Set([`linear`,`basis`,`natural`,`step`,`stepBefore`,`stepAfter`]),M={theme:"colors come from the caller's bg/fg render options, which are usually CSS variables so a diagram inherits the host page's light/dark. A diagram-supplied theme would hard-code colors that fight it. Mermaid's theme names (default/dark/forest/neutral) also have no equivalent in this renderer's palettes — pass `bg`/`fg`, or a THEMES entry, instead",securitylevel:`this renderer emits static SVG and never executes diagram-supplied script, so there is no sandbox to configure`,defaultrenderer:`ELK is the only layout engine; dagre/elk selection has no effect`,fontfamily:"use the `font` render option instead",htmllabels:`labels are always rendered as SVG text; there is no HTML label mode`,maxtextsize:`no text-size limit is enforced`,startonload:`not a browser auto-render integration`},
|
|
3
|
-
`),i=t*be,a=0;for(let e of r){let r=
|
|
2
|
+
`);for(let e=0;e<n.length;e++){let r=n[e].trim(),i=e+1,a=w(r);if(a!==-1&&(r=r.slice(0,a).trim()),r.length===0)continue;let o=[];for(let e of T(r)){let t=e.trim();t.length!==0&&o.push({text:t,line:i})}o.length>0&&t.push(o)}return t}function D(e){return E(e).flat()}function O(e){let t=D(e)[0]?.text.toLowerCase()??``;return/^xychart(?:-beta)?(?:\s|$)/.test(t)?`xychart`:/^sequencediagram\s*$/.test(t)?`sequence`:/^classdiagram\s*$/.test(t)?`class`:/^erdiagram\s*$/.test(t)?`er`:`flowchart`}function k(e){return e===`TD`||e===`TB`||e===`LR`||e===`BT`||e===`RL`}function A(e){let t=e?.toUpperCase();if(t===void 0||!k(t))throw Error(`Invalid direction: "${e}"`);return t}function j(e,t){return t===void 0||!k(t)?e:{...e,direction:t}}var ee=new Set([`linear`,`basis`,`natural`,`step`,`stepBefore`,`stepAfter`]),M={theme:"colors come from the caller's bg/fg render options, which are usually CSS variables so a diagram inherits the host page's light/dark. A diagram-supplied theme would hard-code colors that fight it. Mermaid's theme names (default/dark/forest/neutral) also have no equivalent in this renderer's palettes — pass `bg`/`fg`, or a THEMES entry, instead",securitylevel:`this renderer emits static SVG and never executes diagram-supplied script, so there is no sandbox to configure`,defaultrenderer:`ELK is the only layout engine; dagre/elk selection has no effect`,fontfamily:"use the `font` render option instead",htmllabels:`labels are always rendered as SVG text; there is no HTML label mode`,maxtextsize:`no text-size limit is enforced`,startonload:`not a browser auto-render integration`},N=/^\s*%%\{\s*(?:init|initialize)\s*:\s*([\s\S]*?)\}%%/i;function te(e){let t=``,n=null;for(let r=0;r<e.length;r++){let i=e[r];if(n!==null){if(i===`\\`&&r+1<e.length){let n=e[r+1];t+=n===`'`?`'`:`\\${n}`,r++}else i===n?(n=null,t+=`"`):t+=i===`"`?`\\"`:i;continue}if(i===`"`||i===`'`){n=i,t+=`"`;continue}if(/[A-Za-z_$]/.test(i)){let n=r;for(;n<e.length&&/[\w$-]/.test(e[n]);)n++;let i=e.slice(r,n),a=n;for(;a<e.length&&/\s/.test(e[a]);)a++;if(e[a]===`:`){t+=`"${i}"`,r=n-1;continue}t+=/^(true|false|null)$/i.test(i)?i.toLowerCase():`"${i}"`,r=n-1;continue}t+=i}return t}function ne(e){let t=e.match(N);if(!t)return;let n;try{n=JSON.parse(te(t[1]))}catch{return}if(typeof n!=`object`||!n)return;let r={ignored:[]},i={...n};for(let[e,t]of Object.entries(i)){let n=e.toLowerCase();if(n===`theme`&&typeof t==`string`){r.theme=t,r.ignored.push(e);continue}if(n===`flowchart`&&typeof t==`object`&&t){let e={...t};for(let[t,n]of Object.entries(e)){if(t.toLowerCase()===`curve`&&typeof n==`string`){ee.has(n)&&(r.curve=n);continue}t.toLowerCase()in M&&r.ignored.push(t)}continue}n in M&&r.ignored.push(e)}return r}function re(e){let t={ignored:[]};for(let n of e){let e=ne(n);e&&(e.theme!==void 0&&(t.theme=e.theme),e.curve!==void 0&&(t.curve=e.curve),t.ignored.push(...e.ignored))}return t}var ie={" ":.521,"!":.533,'"':.863,"#":1.173,$:1.188,"%":1.818,"&":1.193,"'":.555,"(":.675,")":.675,"*":.928,"+":1.225,",":.534,"-":.852,".":.534,"/":.667,0:1.168,1:.753,2:1.129,3:1.144,4:1.196,5:1.099,6:1.148,7:1.048,8:1.146,9:1.148,":":.534,";":.559,"<":1.225,"=":1.225,">":1.225,"?":.947,"@":1.789,A:1.278,B:1.212,C:1.353,D:1.336,E:1.113,F:1.093,G:1.382,H:1.376,I:.497,J:1.057,K:1.244,L:1.047,M:1.673,N:1.395,O:1.416,P:1.183,Q:1.416,R:1.192,S:1.188,T:1.195,U:1.378,V:1.278,W:1.825,X:1.263,Y:1.257,Z:1.165,"[":.675,"\\":.667,"]":.675,"^":.873,_:.845,"`":.598,a:1.04,b:1.134,c:1.058,d:1.134,e:1.08,f:.685,g:1.136,h:1.095,i:.448,j:.448,k:1.016,l:.448,m:1.622,n:1.094,o:1.11,p:1.134,q:1.134,r:.697,s:.977,t:.606,u:1.095,v:1.041,w:1.515,x:1.011,y:1.041,z:1.023,"{":.789,"|":.616,"}":.789,"~":1.225},ae=new Set([`i`,`l`,`t`,`f`,`j`,`I`,`1`,`!`,`|`,`.`,`,`,`:`,`;`,`'`]),oe=new Set([`W`,`M`,`w`,`m`,`@`,`%`]),P=new Set([`W`,`M`]),se=new Set([`(`,`)`,`[`,`]`,`{`,`}`,`/`,`\\`,`-`,`"`,"`"]);function ce(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function le(e){return e>=4352&&e<=4447||e>=11904&&e<=12031||e>=12032&&e<=12255||e>=12288&&e<=12351||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=12544&&e<=12591||e>=12592&&e<=12687||e>=12688&&e<=12799||e>=12800&&e<=13311||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072}var ue=/\p{Emoji_Presentation}/u,F=/\p{Extended_Pictographic}/u;function de(e){return e>=9632&&e<=9727}function fe(e){if(ue.test(e))return!0;let t=e.codePointAt(0);return t!==void 0&&de(t)?!1:F.test(e)}function pe(e){let t=e.codePointAt(0);return t===void 0?!1:le(t)||fe(e)}function me(e){let t=e.codePointAt(0);if(t===void 0)return 0;if(Object.hasOwn(ie,e)){let t=ie[e];if(t!==void 0)return t}if(ce(t))return 0;if(le(t)||fe(e))return 2;let n=e.normalize(`NFD`)[0];if(n!==void 0&&n!==e){let e=ie[n];if(e!==void 0)return e}return e===` `?.3:P.has(e)?1.5:oe.has(e)?1.2:ae.has(e)?.4:se.has(e)?.5:e===`r`?.8:t>=65&&t<=90?1.2:1}var he=.6,ge=!1;function _e(e){return/mono|consol|menlo|courier|\bcode\b/i.test(e)}function ve(e){ge=e}function ye(e,t,n){let r=t*.15;if(ge){let n=0;for(let t of e)n+=1;return n*t*he+r}let i=n>=600?.6:n>=500?.57:.54,a=0;for(let t of e)a+=me(t);return a*t*i+r}var be=1.3;function I(e,t,n){let r=e.split(`
|
|
3
|
+
`),i=t*be,a=0;for(let e of r){let r=ye(e.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi,``),t,n);r>a&&(a=r)}return{width:a,height:r.length*i,lines:r,lineHeight:i}}function L(e){let t=e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e;return(t.length>=2&&t.startsWith("`")&&t.endsWith("`")?t.slice(1,-1):t).replace(/<br\s*\/?>/gi,`
|
|
4
4
|
`).replace(/\\n/g,`
|
|
5
|
-
`).replace(/<\/?(?:sub|sup|small|mark)\s*>/gi,``).replace(/\*\*(.+?)\*\*/g,`<b>$1</b>`).replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g,`<i>$1</i>`).replace(/~~(.+?)~~/g,`<s>$1</s>`)}function
|
|
6
|
-
`);if(o.length===1)return`<text x="${t}" y="${n}" ${i} dy="${r*a}">${Ee(e)}</text>`;let s=r*be,c=-((o.length-1)/2)*s+r*a;return`<text x="${t}" y="${n}" ${i}>${o.map((e,n)=>`<tspan x="${t}" dy="${n===0?c:s}">${Ee(e)}</tspan>`).join(``)}</text>`}function
|
|
5
|
+
`).replace(/<\/?(?:sub|sup|small|mark)\s*>/gi,``).replace(/\*\*(.+?)\*\*/g,`<b>$1</b>`).replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g,`<i>$1</i>`).replace(/~~(.+?)~~/g,`<s>$1</s>`)}function xe(e){return e.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi,``)}function Se(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function R(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}var Ce=/<(\/)?(?:(b|strong)|(i|em)|(u)|(s|del))\s*>/gi;function we(e){let t=[],n=!1,r=!1,i=!1,a=!1,o=0;Ce.lastIndex=0;let s;for(;(s=Ce.exec(e))!==null;){s.index>o&&t.push({text:e.slice(o,s.index),bold:n,italic:r,underline:i,strikethrough:a}),o=s.index+s[0].length;let c=!!s[1];s[2]?n=!c:s[3]?r=!c:s[4]?i=!c:s[5]&&(a=!c)}return o<e.length&&t.push({text:e.slice(o),bold:n,italic:r,underline:i,strikethrough:a}),t}var Te=/<\/?(?:b|strong|i|em|u|s|del)\s*>/i;function Ee(e){if(!Te.test(e))return Se(e);let t=we(e);return t.length===0?``:t.every(e=>!e.bold&&!e.italic&&!e.underline&&!e.strikethrough)?t.map(e=>Se(e.text)).join(``):t.map(e=>{let t=Se(e.text);if(!e.bold&&!e.italic&&!e.underline&&!e.strikethrough)return t;let n=[];e.bold&&n.push(`font-weight="bold"`),e.italic&&n.push(`font-style="italic"`);let r=[];return e.underline&&r.push(`underline`),e.strikethrough&&r.push(`line-through`),r.length&&n.push(`text-decoration="${r.join(` `)}"`),`<tspan ${n.join(` `)}>${t}</tspan>`}).join(``)}function z(e,t,n,r,i,a=.35){let o=e.split(`
|
|
6
|
+
`);if(o.length===1)return`<text x="${t}" y="${n}" ${i} dy="${r*a}">${Ee(e)}</text>`;let s=r*be,c=-((o.length-1)/2)*s+r*a;return`<text x="${t}" y="${n}" ${i}>${o.map((e,n)=>`<tspan x="${t}" dy="${n===0?c:s}">${Ee(e)}</tspan>`).join(``)}</text>`}function De(e,t,n,r,i,a,o,s,c){let l=r+o*2,u=i+o*2;return`${`<rect x="${t-l/2}" y="${n-u/2}" width="${l}" height="${u}" ${c} />`}\n${z(e,t,n,a,s)}`}function Oe(e){let t=e.replace(/;\s*$/,``),n={};for(let e of t.split(`,`)){let t=e.indexOf(`:`);if(t>0){let r=e.slice(0,t).trim(),i=e.slice(t+1).trim();r&&i&&(n[r]=i)}}return n}function ke(e,t){let n=e.match(/^classDef\s+([\w,-]+)\s+(.+)$/);if(!n)return!1;let r=Oe(n[2]);for(let e of n[1].split(`,`)){let n=e.trim();n&&t.classDefs.set(n,r)}return!0}function Ae(e,t){let n=e.match(/^class\s+([\w,-]+)\s+([\w-]+)\s*;?\s*$/);if(!n)return!1;let r=n[2];for(let e of n[1].split(`,`))t.classAssignments.set(e.trim(),r);return!0}function je(e,t){let n=e.match(/^cssClass\s+"([^"]*)"\s+([\w-]+)\s*;?\s*$/);if(!n)return!1;let r=n[2];for(let e of n[1].split(`,`)){let n=e.trim();n&&t.classAssignments.set(n,r)}return!0}function Me(e,t){let n=e.match(/^style\s+([\w,-]+)\s+(.+)$/);if(!n)return!1;let r=Oe(n[2]);for(let e of n[1].split(`,`).map(e=>e.trim()))t.nodeStyles.set(e,{...t.nodeStyles.get(e),...r});return!0}function Ne(e){let t=e.match(/^(.+?):::([\w][\w-]*)$/);return t?{id:t[1],className:t[2]}:{id:e}}function Pe(e,t){let n,r=t.classDefs.get(`default`);r&&(n={...r});let i=t.classAssignments.get(e);if(i){let e=t.classDefs.get(i);e&&(n=n?{...n,...e}:{...e})}let a=t.nodeStyles.get(e);return a&&(n=n?{...n,...a}:{...a}),n}function Fe(e){if(e)return/^-?[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e)?e:void 0}var Ie={bg:`#FFFFFF`,fg:`#27272A`},Le={text:100,textSec:60,textMuted:40,textFaint:25,line:50,arrow:85,nodeFill:3,nodeStroke:20,groupHeader:5,innerStroke:12,keyBadge:10},Re={"zinc-light":{bg:`#FFFFFF`,fg:`#27272A`},"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 ze(e){let t=e.colors??{},n=e.type===`dark`,r=t=>e.tokenColors?.find(e=>Array.isArray(e.scope)?e.scope.includes(t):e.scope===t)?.settings?.foreground;return{bg:t[`editor.background`]??(n?`#1e1e1e`:`#ffffff`),fg:t[`editor.foreground`]??(n?`#d4d4d4`:`#333333`),line:t[`editorLineNumber.foreground`]??void 0,accent:t.focusBorder??r(`keyword`)??void 0,muted:r(`comment`)??t[`editorLineNumber.foreground`]??void 0,surface:t[`editor.selectionBackground`]??void 0,border:t[`editorWidget.border`]??void 0}}var Be=/[<>{};]/;function Ve(e){let t=e.trim();if(!t.startsWith(`var(`)||!t.endsWith(`)`)||Be.test(t))return!1;let n=0;for(let e of t)if(e===`(`)n++;else if(e===`)`&&(n--,n<0))return!1;return n===0}var He=new Set([`sans-serif`,`serif`,`monospace`,`system-ui`,`ui-sans-serif`,`ui-serif`,`ui-monospace`,`ui-rounded`,`cursive`,`fantasy`,`math`,`emoji`,`fangsong`]);function Ue(e){let t=e.trim();return t.includes(`,`)?!0:He.has(t.toLowerCase())}function We(e){return e===void 0||e.trim()===``?`<style>`:`<style nonce="${R(e)}">`}function Ge(e,t,n){let r=Ve(e),i=r?e.trim():e.replace(/[<>{};'"]/g,``),a=[...r||Ue(e)?[]:[`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(i)}:wght@400;500;600;700&display=swap');`],...t?[`@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');`]:[]],o=`
|
|
7
7
|
/* Derived from --bg and --fg (overridable via --line, --accent, etc.) */
|
|
8
8
|
--_text: var(--fg);
|
|
9
|
-
--_text-sec: var(--muted, color-mix(in srgb, var(--fg) ${
|
|
10
|
-
--_text-muted: var(--muted, color-mix(in srgb, var(--fg) ${
|
|
11
|
-
--_text-faint: color-mix(in srgb, var(--fg) ${
|
|
12
|
-
--_line: var(--line, color-mix(in srgb, var(--fg) ${
|
|
13
|
-
--_arrow: var(--accent, color-mix(in srgb, var(--fg) ${
|
|
14
|
-
--_node-fill: var(--surface, color-mix(in srgb, var(--fg) ${
|
|
15
|
-
--_node-stroke: var(--border, color-mix(in srgb, var(--fg) ${
|
|
9
|
+
--_text-sec: var(--muted, color-mix(in srgb, var(--fg) ${Le.textSec}%, var(--bg)));
|
|
10
|
+
--_text-muted: var(--muted, color-mix(in srgb, var(--fg) ${Le.textMuted}%, var(--bg)));
|
|
11
|
+
--_text-faint: color-mix(in srgb, var(--fg) ${Le.textFaint}%, var(--bg));
|
|
12
|
+
--_line: var(--line, color-mix(in srgb, var(--fg) ${Le.line}%, var(--bg)));
|
|
13
|
+
--_arrow: var(--accent, color-mix(in srgb, var(--fg) ${Le.arrow}%, var(--bg)));
|
|
14
|
+
--_node-fill: var(--surface, color-mix(in srgb, var(--fg) ${Le.nodeFill}%, var(--bg)));
|
|
15
|
+
--_node-stroke: var(--border, color-mix(in srgb, var(--fg) ${Le.nodeStroke}%, var(--bg)));
|
|
16
16
|
--_group-fill: var(--bg);
|
|
17
|
-
--_group-hdr: color-mix(in srgb, var(--fg) ${
|
|
18
|
-
--_inner-stroke: color-mix(in srgb, var(--fg) ${
|
|
19
|
-
--_key-badge: color-mix(in srgb, var(--fg) ${
|
|
17
|
+
--_group-hdr: color-mix(in srgb, var(--fg) ${Le.groupHeader}%, var(--bg));
|
|
18
|
+
--_inner-stroke: color-mix(in srgb, var(--fg) ${Le.innerStroke}%, var(--bg));
|
|
19
|
+
--_key-badge: color-mix(in srgb, var(--fg) ${Le.keyBadge}%, var(--bg));`;return[We(n),...a.length>0?[` ${a.join(`
|
|
20
20
|
`)}`]:[],` text { font-family: ${r?i:`'${i}'`}, system-ui, sans-serif; }`,...t?[` .mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace; }`]:[],` svg {${o}`,` }`,`</style>`].join(`
|
|
21
|
-
`)}function qe(e,t,n){return(.299*e+.587*t+.114*n)/255}function Je(e,t){if(!e)return t;let n=m(e);return n?qe(...n)>.5?`#000000`:`#FFFFFF`:t}var Ye=0;function Xe(){return Ye+=1,`zm-title-${Ye}`}function Ze(e,t){return`${[`--bg:${e.bg}`,`--fg:${e.fg}`,e.line?`--line:${e.line}`:``,e.accent?`--accent:${e.accent}`:``,e.muted?`--muted:${e.muted}`:``,e.surface?`--surface:${e.surface}`:``,e.border?`--border:${e.border}`:``].filter(Boolean).join(`;`)}${t?``:`;background:var(--bg)`}`}function Qe(e,t,n,r,i,a,o,s=!0){let c=s?` style="${Ze(n,r)}"`:``,l=``,u=``;if(o){if(i){let e=Xe();l=` aria-labelledby="${e}"`,u=`\n <title id="${e}">${Ce(i)}</title>`}}else if(a)l=` aria-hidden="true"`;else if(l=` role="img"`,i){let e=Xe();l+=` aria-labelledby="${e}"`,u=`\n <title id="${e}">${Ce(i)}</title>`}return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e} ${t}" width="${e}" height="${t}"${l}${c}>`+u}var $e=`<\\|--|<\\|\\.\\.|\\*--|o--|-->|--\\*|--o|--\\|>|\\.\\.>|\\.\\.\\|>|<--|<\\.\\.?|--`,et=new RegExp($e);function tt(e){let t={classes:[],relationships:[],namespaces:[],interactions:new Map,classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,notes:[]},n=new Map,r=null,i=null,a=0,o;for(let c=1;c<e.length;c++){let l=e[c],d=l.text;if(i&&a>0){if(d===`}`){a--,a===0&&(i=null,o=void 0);continue}let e=d.match(/^<<(\w+)>>$/);if(e){i.annotation=e[1];continue}if(d.startsWith(`<<`))throw Error(`Line ${l.line}: Malformed class annotation "${d}" — expected "<<name>>" (e.g. "<<interface>>").`);nt(i,d,l.line);continue}if(/^click\s+/i.test(d)){u(d,t.interactions);continue}let f=d.match(/^note\s+(?:for\s+(\S+)\s+)?"([^"]*)"\s*$/);if(f){let e=f[1];t.notes.push({text:I(f[2]),...e?{forClass:e}:{}});continue}if(Ae(d,t)||Ne(d,t)||Me(d,t)||je(d,t))continue;let p=d.match(/^namespace\s+(\S+)\s*\{$/);if(p){r={name:p[1],classIds:[]};continue}if(d===`}`&&r){t.namespaces.push(r),r=null;continue}let m=d.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);if(m){let e=s(m[1],m[2]);i=n.get(e)??null,a=1,o=l.line;continue}let h=d.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);if(h){s(h[1],h[2]);continue}let g=d.match(/^class\s+(\S+?)\s*\{\s*(.*?)\s*\}$/);if(g){let e=s(g[1],void 0),t=n.get(e),r=g[2],i=r.match(/^<<(\w+)>>$/);if(t&&i)t.annotation=i[1];else if(t&&r.startsWith(`<<`))throw Error(`Line ${l.line}: Malformed class annotation "${r}" — expected "<<name>>" (e.g. "<<interface>>").`);else t&&r&&nt(t,r,l.line);continue}let _=d.match(/^(\S+?)\s*:\s*(.+)$/);if(_){let e=_[2];if(!e.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)){nt(rt(n,_[1]),e,l.line);continue}}let v=ct(d);if(v){v.from=s(v.from,void 0,!1),v.to=s(v.to,void 0,!1),t.relationships.push(v);continue}if(et.test(d))throw Error(`Line ${l.line}: Malformed class-diagram relationship "${d}". Expected "FROM ARROW TO" (optionally with cardinalities and a ": label"), e.g. "Animal <|-- Dog" or 'A "1" --> "*" B : label'. ARROW must be one of <|--, <|.., *--, o--, -->, --*, --o, --|>, ..>, ..|>, <--, <.., or --.`)}if(i!==null)throw Error(`Line ${o}: Unclosed class body for "${i.id}" — expected a closing "}" before the diagram ends.`);return t.classes=[...n.values()],t;function s(e,i,a=!0){let{id:o,className:s}=Pe(e),c=o,l=i;if(!l){let e=o.match(/^(.+?)~(\w+)~$/);e&&(c=e[1],l=e[2])}let u=rt(n,c);return l&&(u.label=`${c}<${l}>`),s&&t.classAssignments.set(c,s),a&&r&&r.classIds.push(c),c}}function nt(e,t,n){let r=st(t,n);r&&(r.isMethod?e.methods.push(r.member):e.attributes.push(r.member))}function rt(e,t){let n=e.get(t);return n||(n={id:t,label:t,attributes:[],methods:[]},e.set(t,n)),n}function it(e,t){return Math.max(0,e.split(t).length-1)}function at(e){let t=it(e,`~`);if(t<=1)return e;let n=e,r=!1;t%2!=0&&n.startsWith(`~`)&&(n=n.slice(1),r=!0);let i=[...n],a=i.indexOf(`~`),o=i.lastIndexOf(`~`);for(;a!==-1&&o!==-1&&a!==o;)i[a]=`<`,i[o]=`>`,a=i.indexOf(`~`),o=i.lastIndexOf(`~`);return r&&i.unshift(`~`),i.join(``)}function ot(e){let t=e.split(/(,)/),n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r===`,`&&e>0&&e+1<t.length){let i=t[e-1],a=t[e+1];it(i,`~`)===1&&it(a,`~`)===1&&(r=`${i},${a}`,e++,n.pop())}n.push(at(r))}return n.join(``)}function st(e,t){let n=e.trim().replace(/;$/,``);if(!n)return null;let r=``,i=n,a=i[0];if((a===`+`||a===`-`||a===`#`||a===`~`)&&(r=a,i=i.slice(1).trim()),i.includes(`(`)&&!i.includes(`)`))throw Error(`Line ${t}: Malformed class member "${n}" — unclosed "(" in a method signature. Expected e.g. "+eat() void" or "+eat(Food f) void".`);let o=i.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);if(o){let e=ot(o[1].trim()),t=o[2]?.trim(),n=t?ot(t):void 0,a=o[3]?.trim(),s=a?ot(a):void 0,c=e.endsWith(`$`)||i.includes(`$`),l=e.endsWith(`*`)||i.includes(`*`);return{member:{visibility:r,name:e.replace(/[$*]$/,``),type:s||void 0,isStatic:c,isAbstract:l,isMethod:!0,params:n},isMethod:!0}}let s=ot(i).split(/\s+/),c,l;s.length>=2?(l=s[0],c=s.slice(1).join(` `)):c=s[0]??i;let u=c.endsWith(`$`),d=c.endsWith(`*`);return{member:{visibility:r,name:c.replace(/[$*]$/,``),type:l||void 0,isStatic:u,isAbstract:d,isMethod:!1},isMethod:!1}}function ct(e){let t=e.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${$e})\\s+(?:"([^"]*?)"\\s+)?(\\S+?)(?::::([\\w][\\w-]*))?(?:\\s*:\\s*(.+))?$`));if(!t)return null;let n=t[1],r=t[2],i=r?I(r):void 0,a=t[3].trim(),o=t[4],s=o?I(o):void 0,c=t[6]?`${t[5]}:::${t[6]}`:t[5],l=t[7]?.trim(),u=l?I(l):void 0,d=lt(a);return d?{from:n,to:c,type:d.type,markerAt:d.markerAt,label:u,fromCardinality:i,toCardinality:s}:null}function lt(e){switch(e.trim()){case`<|--`:return{type:`inheritance`,markerAt:`from`};case`--|>`:return{type:`inheritance`,markerAt:`to`};case`<|..`:return{type:`realization`,markerAt:`from`};case`..|>`:return{type:`realization`,markerAt:`to`};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:`association`,markerAt:`from`};case`..>`:return{type:`dependency`,markerAt:`to`};case`<..`:return{type:`dependency`,markerAt:`from`};case`--`:return{type:`association`,markerAt:`to`};default:return null}}function ut(e){return`${e.visibility?`${e.visibility} `:``}${e.isMethod?`${e.name}(${e.params||``})`:e.name}${e.type?`: ${e.type}`:``}`}function dt(e){let t={entities:[],relationships:[]},n=new Map,r=null;for(let i=1;i<e.length;i++){let a=e[i],o=a.text;if(r){if(o===`}`){r=null;continue}let e=pt(o);e&&r.attributes.push(e);continue}let s=o.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(s){t.direction=A(s[1]);continue}let c=o.match(/^(\S+?)(?:\[(.+)\])?\s*\{(.*)$/);if(c){let e=c[1],t=c[2],i=ft(n,e,t===void 0?void 0:I(t.trim().replace(/^["']|["']$/g,``))),a=c[3].trim(),o=a.endsWith(`}`),s=o?a.slice(0,-1).trim():a;for(let e of s.split(`;`).map(e=>e.trim()).filter(Boolean)){let t=pt(e);t&&i.attributes.push(t)}o||(r=i);continue}let l=mt(o,a.line);if(l){ft(n,l.entity1),ft(n,l.entity2),t.relationships.push(l);continue}}return t.entities=[...n.values()],t}function ft(e,t,n){let r=e.get(t);return r?n!==void 0&&(r.label=n):(r={id:t,label:n??t,attributes:[]},e.set(t,r)),r}function pt(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=I(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 mt(e,t){let n=e.match(/^(\S+)\s+(\S*(?:--|\.\.)\S*)\s+(\S+)\s*(?::\s*(.*))?$/);if(!n)return null;let r=n[1],i=n[2],a=n[3],o=n[4]!==void 0,s=n[4]?.trim()??``,c=i.match(/^([|o}{]*)(--|\.\.?)([|o}{]*)$/),l=c?ht(c[1]):null,u=c?gt(c[3]):null;if(!l||!u)throw Error(`Line ${t}: Invalid ER relationship cardinality "${i}" in "${e}". Left side must be one of ||, |o, }|, }o; right side must be one of ||, o|, |{, o{ (e.g. "||--o{").`);if(!o||s.length===0)throw Error(`Line ${t}: ER relationship "${r} ${i} ${a}" is missing a ": label" — expected e.g. "${r} ${i} ${a} : label".`);return{entity1:r,entity2:a,cardinality1:l,cardinality2:u,label:I(s.replace(/^["']|["']$/g,``)),identifying:c[2]===`--`}}function ht(e){return e===`||`?`one`:e===`|o`?`zero-one`:e===`}|`?`many`:e===`}o`?`zero-many`:null}function gt(e){return e===`||`?`one`:e===`o|`?`zero-one`:e===`|{`?`many`:e===`o{`?`zero-many`:null}var _t=new Set(`aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen`.split(` `)),vt=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,yt=/^(?:rgba?|hsla?)\(\s*[\d.%]+(?:[\s,/]+[\d.%]+){2,3}\s*\)$/i;function bt(e){return _t.has(e.toLowerCase())||vt.test(e)||yt.test(e)}function xt(e){let t=e.trim(),n=t.match(/^((?:rgba?|hsla?)\s*\([^)]*\)|#[0-9a-fA-F]+|\S+)?(.*)$/),r=n?.[1]??``,i=n?.[2]?.trim()??``;return r.toLowerCase()===`transparent`?{label:i}:r!==``&&bt(r)?{color:r,label:i}:{label:t}}function St(e){return e===`loop`||e===`alt`||e===`opt`||e===`par`||e===`critical`||e===`break`||e===`rect`}function Ct(e){if(!St(e))throw Error(`Invalid block type: "${e}"`);return e}var wt=/^(.+?)\s*(<<->>|<<-->>|--?>?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/,Tt=/^(.+?)\s*(<<->>|<<-->>|--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/;function Et(e){let t={actors:[],messages:[],blocks:[],notes:[],activations:[],boxes:[]},n={open:void 0,membership:new Map},r=0,i,a=new Set,o=[],s={enabled:!1,next:1,step:1},c,l;for(let u=1;u<e.length;u++){let d=e[u],f=d.text,p=f.match(/^box(?:\s+(.*))?$/);if(p){if(n.open!==void 0)throw Error(`Line ${d.line}: Sequence diagram: a box cannot be nested inside another box — close the open box with "end" first`);let{color:e,label:a}=xt(p[1]??``),s={label:I(a),actorIds:[]};e!==void 0&&(s.color=e),t.boxes.push(s),n.open=t.boxes.length-1,r=o.length,i=d.line;continue}let m=f.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(m){let e=m[1]===`actor`?`actor`:`participant`,r=m[2];if(a.has(r))throw Error(`Line ${d.line}: It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior`);a.add(r),t.actors.push({id:r,label:I(m[3]?.trim()??r),type:e}),kt(t,n,r,d.line),c=r;continue}let h=f.match(/^destroy\s+(.+)$/);if(h){let e=h[1].trim();Ot(t,a,n,e,d.line),l=e;continue}let g=f.match(/^autonumber(?:\s+(off|\d+(?:\.\d{1,2})?)(?:\s+(\d+(?:\.\d{1,2})?))?)?$/);if(g){let e=g[1],t=g[2];e===`off`?s.enabled=!1:(s.enabled=!0,s.next=e===void 0?1:Number(e),s.step=t===void 0?1:Number(t));continue}let _=f.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(_){let e=_[1]===`actor`?`actor`:`participant`,r=_[2],i=I(_[3]?.trim()??r);a.has(r)||(a.add(r),t.actors.push({id:r,label:i,type:e})),kt(t,n,r,d.line);continue}let v=f.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);if(v){let e=v[1].toLowerCase(),r=v[2].trim(),i=I(v[3].trim()),o=r.split(`,`).map(e=>e.trim());for(let e of o)Ot(t,a,n,e,d.line);let s=`over`;e===`left of`?s=`left`:e===`right of`&&(s=`right`),t.notes.push({actorIds:o,text:i,position:s,afterIndex:t.messages.length-1});continue}let y=f.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);if(y){let e=Ct(y[1]),n=I(y[2]?.trim()??``);o.push({type:e,label:n,startIndex:t.messages.length,dividers:[],line:d.line});continue}let b=f.match(/^(else|and)\s*(.*)$/);if(b&&o.length>0){let e=I(b[2]?.trim()??``);o[o.length-1].dividers.push({index:t.messages.length,label:e});continue}if(f===`end`&&n.open!==void 0&&o.length===r){n.open=void 0,i=void 0;continue}if(f===`end`&&o.length>0){let e=o.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}if(f===`end`)throw Error(`Line ${d.line}: Sequence diagram: "end" does not match any open block ("loop"/"alt"/"opt"/"par"/"critical"/"break"/"rect") or "box" — nothing is currently open to close.`);let x=f.match(/^(activate|deactivate)\s+(.+)$/);if(x){let e=x[2].trim();Ot(t,a,n,e,d.line),t.activations.push({actorId:e,kind:x[1]===`activate`?`start`:`end`,afterIndex:t.messages.length-1});continue}let S=f.match(wt)??f.match(Tt);if(S){let e=S[2],r=S[4][0];if(r===`>`||r===`)`)throw Error(`Line ${d.line}: Malformed sequence-diagram arrow in "${f}" — "${e}${r}" is not a recognized arrow. Expected one of: ->, -->, ->>, -->>, -x, --x, -), --), <<->>, <<-->>.`);At(t,a,n,s,S[1],S[2],S[3],S[4],S[5],d.line);let i=t.messages.length-1,o=t.messages[i];if(c!==void 0){if(o.to!==c)throw Error(`Line ${d.line}: The created participant ${c} does not have an associated creating message after its declaration. Please check the sequence diagram.`);Dt(t,c).createdAt=i,c=void 0}if(l!==void 0){if(o.from!==l&&o.to!==l)throw Error(`Line ${d.line}: The destroyed participant ${l} does not have an associated destroying message after its declaration. Please check the sequence diagram.`);Dt(t,l).destroyedAt=i,l=void 0}continue}}if(o.length>0){let e=o[o.length-1];throw Error(`Line ${e.line}: Sequence diagram: unclosed "${e.type}" block — expected a matching "end" before the diagram ends.`)}if(n.open!==void 0){let e=t.boxes[n.open];throw Error(`Line ${i}: Sequence diagram: unclosed "box${e.label?` ${e.label}`:``}" — expected a matching "end" before the diagram ends.`)}return t}function Dt(e,t){let n=e.actors.find(e=>e.id===t);if(n===void 0)throw Error(`Sequence diagram: unknown actor "${t}"`);return n}function Ot(e,t,n,r,i){t.has(r)||(t.add(r),e.actors.push({id:r,label:r,type:`participant`})),kt(e,n,r,i)}function kt(e,t,n,r){let i=t.open;if(i===void 0)return;let a=t.membership.get(n);if(a!==i){if(a!==void 0){let t=e.boxes[a].label,o=e.boxes[i].label;throw Error(`Line ${r}: A same participant should only be defined in one Box: ${n} can't be in '${t}' and in '${o}' at the same time.`)}t.membership.set(n,i),e.boxes[i].actorIds.push(n)}}function At(e,t,n,r,i,a,o,s,c,l){Ot(e,t,n,i,l),Ot(e,t,n,s,l);let u=a===`<<->>`||a===`<<-->>`,d=u?a===`<<-->>`?`dashed`:`solid`:a.startsWith(`--`)?`dashed`:`solid`,f=a.includes(`>>`)||a.includes(`x`)?`filled`:`open`,p=a.includes(`x`),m={from:i,to:s,label:I(c.trim()),lineStyle:d,arrowHead:f};p&&(m.isLost=!0),u&&(m.bidirectional=!0),o===`+`&&(m.activate=!0),o===`-`&&(m.deactivate=!0),r.enabled&&(m.seqNumber=r.next,r.next=Math.round((r.next+r.step)*100)/100),e.messages.push(m)}function jt(e){let t={},n={},r=[],i,a=!1;for(let o of e){let e=o.text;if(/^xychart(-beta)?\b/i.test(e)){/\bhorizontal\b/i.test(e)&&(a=!0);continue}let s=e.match(/^title\s+"([^"]+)"/);if(s){i=s[1];continue}let c=e.match(/^x-axis\s+(?:"([^"]*)"\s*)?\[([^\]]+)\]/);if(c){c[1]&&(t.title=c[1]),t.categories=c[2].split(`,`).map(e=>e.trim());continue}let l=e.match(/^x-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(l){l[1]&&(t.title=l[1]),t.range={min:parseFloat(l[2]),max:parseFloat(l[3])};continue}let u=e.match(/^y-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(u){u[1]&&(n.title=u[1]),n.range={min:parseFloat(u[2]),max:parseFloat(u[3])};continue}let d=e.match(/^y-axis\s+"([^"]+)"\s*$/);if(d){n.title=d[1];continue}let f=e.match(/^bar\s+\[([^\]]+)\]/);if(f){r.push({type:`bar`,data:Mt(f[1],`bar`,e,o.line)});continue}let p=e.match(/^line\s+\[([^\]]+)\]/);if(p){r.push({type:`line`,data:Mt(p[1],`line`,e,o.line)});continue}let m=e.match(/^(x-axis|y-axis|bar|line|title)\b/i);if(m)throw Pt(m[1].toLowerCase(),e,o.line)}if(!n.range&&r.length>0){let e=r.flatMap(e=>e.data),t=Math.min(...e),i=Math.max(...e),a=i-t||1;t-=a*.1,i+=a*.1,t>0&&t<a*.5&&(t=0),n.range={min:t,max:i}}return n.range||={min:0,max:100},{title:i,horizontal:a,xAxis:t,yAxis:n,series:r}}function Mt(e,t,n,r){return e.split(`,`).map((e,i)=>{let a=e.trim(),o=parseFloat(a);if(a.length===0||Number.isNaN(o))throw Error(`Line ${r}: Invalid numeric value ${JSON.stringify(a)} at position ${i+1} in "${n}". Every value in a ${t} [...] list must be a number.`);return o})}var Nt={"x-axis":`x-axis [A, B, C] (categories) or x-axis 0 --> 100 (numeric range), either optionally preceded by a quoted title`,"y-axis":`y-axis 0 --> 100 (numeric range) or y-axis "Title" (title only), optionally preceded by a quoted title before a range`,bar:`bar [10, 20, 30] — a comma-separated numeric array in square brackets`,line:`line [10, 20, 30] — a comma-separated numeric array in square brackets`,title:`title "Chart Title" — a double-quoted string`};function Pt(e,t,n){let r=Nt[e]??e;return Error(`Line ${n}: Malformed xychart-beta "${e}" directive: "${t}". Expected: ${r}.`)}var Ft=`#3b82f6`;function It(e){let t=e.replace(`#`,``),n=parseInt(t.substring(0,2),16)/255,r=parseInt(t.substring(2,4),16)/255,i=parseInt(t.substring(4,6),16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)return[0,0,s*100];let c=a-o,l=s>.5?c/(2-a-o):c/(a+o),u;return u=a===n?((r-i)/c+(r<i?6:0))/6:a===r?((i-n)/c+2)/6:((n-r)/c+4)/6,[u*360,l*100,s*100]}function Lt(e,t,n){let r=t/100,i=n/100,a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(e/60%2-1)),s=i-a/2,c,l,u;e<60?(c=a,l=o,u=0):e<120?(c=o,l=a,u=0):e<180?(c=0,l=a,u=o):e<240?(c=0,l=o,u=a):e<300?(c=o,l=0,u=a):(c=a,l=0,u=o);let d=e=>Math.round((e+s)*255).toString(16).padStart(2,`0`);return`#${d(c)}${d(l)}${d(u)}`}function Rt(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function zt(e){return It(e)[2]<50}function Bt(e,t,n){if(e===0)return t;let r=Rt(t)?t:Ft,i=n&&Rt(n)?n:void 0,[a,o]=It(r),s=Math.max(55,Math.min(85,o)),c=Math.ceil(e/2),l=e%2==1,u=i&&zt(i)?!l:l,d=u?Math.max(25,48-c*13):Math.min(78,55+c*11);return Lt(((a+(u?-8:12)*c)%360+360)%360,s,d)}var Vt={rect:`rectangle`,rectangle:`rectangle`,proc:`rectangle`,process:`rectangle`,"normal-rect":`rectangle`,rounded:`rounded`,event:`rounded`,"rounded-rect":`rounded`,stadium:`stadium`,pill:`stadium`,terminal:`stadium`,subproc:`subroutine`,subprocess:`subroutine`,subroutine:`subroutine`,"framed-rectangle":`subroutine`,"fr-rect":`subroutine`,cyl:`cylinder`,cylinder:`cylinder`,db:`cylinder`,database:`cylinder`,"h-cyl":`cylinder`,das:`cylinder`,"horizontal-cylinder":`cylinder`,"lin-cyl":`cylinder`,"lined-cylinder":`cylinder`,disk:`cylinder`,circ:`circle`,circle:`circle`,start:`circle`,"dbl-circ":`doublecircle`,"double-circle":`doublecircle`,stop:`doublecircle`,"f-circ":`filled-circle`,"filled-circle":`filled-circle`,junction:`filled-circle`,"cross-circ":`crossed-circle`,"crossed-circle":`crossed-circle`,summary:`crossed-circle`,diam:`diamond`,diamond:`diamond`,decision:`diamond`,question:`diamond`,hex:`hexagon`,hexagon:`hexagon`,prepare:`hexagon`,odd:`asymmetric`,"rect-left-inv-arrow":`asymmetric`,"lean-r":`parallelogram`,"lean-right":`parallelogram`,"in-out":`parallelogram`,"lean-l":`parallelogram-alt`,"lean-left":`parallelogram-alt`,"out-in":`parallelogram-alt`,"trap-b":`trapezoid`,"trapezoid-bottom":`trapezoid`,priority:`trapezoid`,"trap-t":`trapezoid-alt`,"trapezoid-top":`trapezoid-alt`,manual:`trapezoid-alt`,"curv-trap":`trapezoid-alt`,"curved-trapezoid":`trapezoid-alt`,display:`trapezoid-alt`,doc:`document`,document:`document`,"lin-doc":`document`,"lined-document":`document`,"tag-doc":`document`,"tagged-document":`document`,docs:`stacked-document`,documents:`stacked-document`,"st-doc":`stacked-document`,"stacked-document":`stacked-document`,"notch-rect":`card`,card:`card`,"notched-rectangle":`card`,"lin-rect":`lined-process`,"lined-rectangle":`lined-process`,"lin-proc":`lined-process`,"shaded-process":`lined-process`,"div-rect":`divided-process`,"divided-rectangle":`divided-process`,"div-proc":`divided-process`,"tag-rect":`rectangle`,"tagged-rectangle":`rectangle`,"tag-proc":`rectangle`,procs:`stacked-process`,processes:`stacked-process`,"st-rect":`stacked-process`,"stacked-rectangle":`stacked-process`,tri:`triangle`,triangle:`triangle`,extract:`triangle`,"flip-tri":`flipped-triangle`,"flipped-triangle":`flipped-triangle`,"manual-file":`flipped-triangle`,"win-pane":`window-pane`,"window-pane":`window-pane`,"internal-storage":`window-pane`,fork:`fork-join`,join:`fork-join`,"long-rect":`fork-join`,"notch-pent":`notched-pentagon`,"loop-limit":`notched-pentagon`,"notched-pentagon":`notched-pentagon`,"sl-rect":`sloped-rectangle`,"sloped-rectangle":`sloped-rectangle`,"manual-input":`sloped-rectangle`,flag:`flag`,"paper-tape":`flag`,"bow-rect":`bow-tie-rectangle`,"bow-tie-rectangle":`bow-tie-rectangle`,"stored-data":`bow-tie-rectangle`,delay:`half-rounded-rectangle`,"half-rounded-rectangle":`half-rounded-rectangle`,brace:`brace`,"brace-l":`brace`,comment:`brace`,"brace-r":`brace-right`,braces:`braces`,bolt:`bolt`,"com-link":`bolt`,"lightning-bolt":`bolt`,text:`text`,anchor:`anchor`};function Ht(e){return Vt[e.trim().toLowerCase()]}function Ut(e){let t={};for(let n of Wt(e,`,`)){let e=n.trim();if(e.length===0)continue;let r=Gt(e,`:`);if(r===-1){t.shape??=Kt(e);continue}let i=e.slice(0,r).trim().toLowerCase(),a=Kt(e.slice(r+1).trim());i.length>0&&(t[i]=a)}return t}function Wt(e,t){let n=[],r=``,i=null;for(let a of e){if(i!==null){r+=a,a===i&&(i=null);continue}if(a===`"`||a===`'`){i=a,r+=a;continue}if(a===t){n.push(r),r=``;continue}r+=a}return n.push(r),n}function Gt(e,t){let n=null;for(let r=0;r<e.length;r++){let i=e[r];if(n!==null){i===n&&(n=null);continue}if(i===`"`||i===`'`){n=i;continue}if(i===t)return r}return-1}function Kt(e){return e.length>=2&&(e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))?e.slice(1,-1):e}function qt(e){if(!e.startsWith(`@{`))return;let t=0,n=null;for(let r=1;r<e.length;r++){let i=e[r];if(n!==null){i===n&&(n=null);continue}if(i===`"`||i===`'`){n=i;continue}if(i===`{`){t++;continue}if(i===`}`&&(t--,t===0))return{body:e.slice(2,r),length:r+1}}}function Jt(e){let t=e.trim();return t.length>=2&&(t[0]===`"`&&t[t.length-1]===`"`||t[0]===`'`&&t[t.length-1]===`'`)?t.slice(1,-1):t}var Yt=`"graph <dir>"/"flowchart <dir>" (dir: TD, TB, LR, BT, RL), "stateDiagram-v2", "sequenceDiagram", "classDiagram", "erDiagram", "xychart-beta"`;function Xt(e){let t=e.trim().toLowerCase();if(/^sequence/.test(t))return`sequenceDiagram`;if(/^class/.test(t))return`classDiagram`;if(/^er/.test(t))return`erDiagram`;if(/^xychart/.test(t))return`xychart-beta`;if(/^state/.test(t))return`stateDiagram-v2`}var Zt=/^(?:[\w-]+@)?<?(?:-{2,}|={2,}|-\.+-?|~{3,})/;function Qt(e){let t=[];for(let n of e)n.forEach((e,n)=>{if(n===0&&t.length>0&&Zt.test(e.text)){let n=t[t.length-1];t[t.length-1]={text:`${n.text} ${e.text}`,line:n.line}}else t.push(e)});return t}function $t(e){let t=ie(e.split(`
|
|
22
|
-
`).map(e=>e.trim())),n=Qt(E(e));if(n.length===0)throw Error(`Empty mermaid diagram`);let r=n[0],i=/^stateDiagram(-v2)?\s*$/i.test(r.text)?tn(n):en(n);return i.initConfig=t,i}function en(e){let t=e[0];if(t===void 0)throw Error(`parseFlowchart called with no lines`);let n=t.text,r=n.match(/^(?:graph|flowchart)\s+(TD|TB|LR|BT|RL)\s*$/i);if(!r){let e=n.match(/^(?:graph|flowchart)\b\s*(.*)$/i);if(e){let r=e[1].trim();throw Error(r.length>0?`Line ${t.line}: Invalid direction "${r}" in header "${n}". Expected one of: TD, TB, LR, BT, RL.`:`Line ${t.line}: Missing direction in header "${n}". Expected e.g. "graph TD" or "flowchart LR" — one of: TD, TB, LR, BT, RL.`)}let r=Xt(n),i=r&&r.toLowerCase()!==n.trim().toLowerCase()?` Did you mean "${r}"?`:``;throw Error(`Line ${t.line}: Invalid mermaid header: "${n}".${i} Supported headers: ${Yt}.`)}let i={direction:A(r[1]),nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map,interactions:new Map},a=[];for(let t=1;t<e.length;t++){let n=e[t].text;if(Ae(n,i)||je(n,i)||Ne(n,i))continue;if(/^click\s+/i.test(n)){mn(n,i);continue}if(gn(n,i))continue;let r=n.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);if(r){let e=r[1].trim(),t=ke(r[2]);if(e==="default")i.linkStyles.set(`default`,{...i.linkStyles.get(`default`),...t});else{let n=e.split(`,`).map(e=>parseInt(e.trim(),10));for(let e of n)isNaN(e)||i.linkStyles.set(e,{...i.linkStyles.get(e),...t})}continue}let o=n.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(o&&a.length>0){a[a.length-1].direction=A(o[1]);continue}let s=n.match(/^subgraph\s+(.+)$/);if(s){let e=s[1].trim(),t=e.match(/^([^\s[]+)\s*\[(.+)\]$/),n,r;t?(n=t[1],r=I(Jt(t[2]))):(r=I(Jt(e)),n=r.replace(/\s+/g,`_`).replace(/[^\p{L}\p{N}_-]/gu,``));let i={id:n,label:r,nodeIds:[],children:[]};a.push(i);continue}if(n===`end`){let e=a.pop();e&&(a.length>0?a[a.length-1].children.push(e):i.subgraphs.push(e));continue}bn(n,i,a)}return i}function tn(e){let t={direction:`TD`,nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map,interactions:new Map},n=[],r=new Set,i=0,a=0;for(let o=1;o<e.length;o++){let s=e[o].text,c=s.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(c){n.length>0?n[n.length-1].direction=A(c[1]):t.direction=A(c[1]);continue}let l=s.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);if(l){let e=l[1].trim(),n=ke(l[2]);if(e==="default")t.linkStyles.set(`default`,{...t.linkStyles.get(`default`),...n});else{let r=e.split(`,`).map(e=>parseInt(e.trim(),10));for(let e of r)isNaN(e)||t.linkStyles.set(e,{...t.linkStyles.get(e),...n})}continue}if(gn(s,t))continue;let u=s.match(/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}]+)\s*\{$/u);if(u){let e=u[1]??u[2],i=u[2],a={id:i,label:e,nodeIds:[],children:[]};n.push(a),r.add(i),t.nodes.delete(i);continue}if(s===`}`){let e=n.pop();e&&(n.length>0?n[n.length-1].children.push(e):t.subgraphs.push(e));continue}let d=s.match(/^state\s+"([^"]+)"\s+as\s+([\w\p{L}]+)\s*$/u);if(d){let e=I(d[1]),r=d[2];nn(t,n,{id:r,label:e,shape:`rounded`});continue}let f=s.match(/^(\[\*\]|[\w\p{L}-]+)\s*(?:([\w-]+)@)?-->\s*(\[\*\]|[\w\p{L}-]+)(?:\s*:\s*(.+))?$/u);if(f){let e=f[1],o=f[2],s=f[3],c=f[4]?.trim(),l=c?I(c):void 0;e===`[*]`?(i++,e=`_start${i>1?i:``}`,nn(t,n,{id:e,label:``,shape:`state-start`})):r.has(e)||rn(t,n,e),s===`[*]`?(a++,s=`_end${a>1?a:``}`,nn(t,n,{id:s,label:``,shape:`state-end`})):r.has(s)||rn(t,n,s),t.edges.push({source:e,target:s,label:l,style:`solid`,hasArrowStart:!1,hasArrowEnd:!0,...o===void 0?{}:{id:o}});continue}let p=s.match(/^([\w\p{L}-]+)\s*:\s*(.+)$/u);if(p){let e=p[1];nn(t,n,{id:e,label:I(p[2].trim()),shape:`rounded`});continue}}return t}function nn(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 rn(e,t,n){if(!e.nodes.has(n))nn(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)}}var an=/^(<|o|x)?(-{2,}|={2,}|-\.+-|~{3,})(>|o|x)?(?:\|([^|]*)\|)?/,on=new Set([`--`,`==`]);function sn(e){if(e===`o`)return`circle`;if(e===`x`)return`cross`}var cn=/^(<|o|x)?(--|-\.|==)\s+(.+?)\s+(-{2,}[>ox]|={2,}[>ox]|\.+-[>ox]|-{3,}|={3,}|-\.+-)/,ln=[{regex:/^([\w\p{L}-]+)\(\(\(((?:"[^"]*"|(?!\)\)\)).)+)\)\)\)/u,shape:`doublecircle`},{regex:/^([\w\p{L}-]+)\(\[((?:"[^"]*"|(?!\]\)).)+)\]\)/u,shape:`stadium`},{regex:/^([\w\p{L}-]+)\(\(((?:"[^"]*"|(?!\)\)).)+)\)\)/u,shape:`circle`},{regex:/^([\w\p{L}-]+)\[\[((?:"[^"]*"|(?!\]\]).)+)\]\]/u,shape:`subroutine`},{regex:/^([\w\p{L}-]+)\[\(((?:"[^"]*"|(?!\)\]).)+)\)\]/u,shape:`cylinder`},{regex:/^([\w\p{L}-]+)\[\/((?:"[^"]*"|(?![\\/]\]).)+)([\\/])\]/u,shape:e=>e===`\\`?`trapezoid`:`parallelogram`},{regex:/^([\w\p{L}-]+)\[\\((?:"[^"]*"|(?![\\/]\]).)+)([\\/])\]/u,shape:e=>e===`/`?`trapezoid-alt`:`parallelogram-alt`},{regex:/^([\w\p{L}-]+)>((?:"[^"]*"|(?!\]).)+)\]/u,shape:`asymmetric`},{regex:/^([\w\p{L}-]+)\{\{((?:"[^"]*"|(?!\}\}).)+)\}\}/u,shape:`hexagon`},{regex:/^([\w\p{L}-]+)\[((?:"[^"]*"|(?!\]).)+)\]/u,shape:`rectangle`},{regex:/^([\w\p{L}-]+)\(((?:"[^"]*"|(?!\)).)+)\)/u,shape:`rounded`},{regex:/^([\w\p{L}-]+)\{((?:"[^"]*"|(?!\}).)+)\}/u,shape:`diamond`}],un=/^([\w\p{L}]+(?:-[\w\p{L}]+)*)/u,dn=/^([\w\p{L}-]+)(?=@\{)/u;function fn(e){if(e.shape)return Ht(e.shape)??`rectangle`;if(e.icon!==void 0||e.img!==void 0)switch(e.form?.toLowerCase()){case`circle`:return`circle`;case`rounded`:return`rounded`;default:return`rectangle`}return`rectangle`}function pn(e,t){return t.label!==void 0&&t.label.length>0?t.label:t.icon?t.icon:t.img?t.img:e}function mn(e,t){u(e,t.interactions)}var hn=/^([\w-]+)(?=@\{)/;function gn(e,t){let n=e.match(hn);if(!n||!t.edges.some(e=>e.id===n[1]))return!1;let r=qt(e.slice(n[1].length));return r?(_n(t,n[1],Ut(r.body)),!0):!1}function _n(e,t,n){for(let r of e.edges)r.id===t&&(n.animate!==void 0&&(r.animate=n.animate.toLowerCase()!==`false`),n.animation!==void 0&&(r.animate=!0))}var vn=/^:::([\w][\w-]*)/,yn=/^([\w\p{L}-]+):::([\w][\w-]*)/u;function bn(e,t,n){let r=e.trim(),i=xn(r,t,n);if(!i||i.ids.length===0)return;r=i.remaining.trim();let a=i.ids;for(;r.length>0;){let e,i,o,s,c,l,u,d=r.match(/^([\w-]+)@(?=[-=<~ox])/);d&&(u=d[1],r=r.slice(d[0].length));let f=r.match(an),p=f?.[2],m=f?.[1],h=f?.[3];if(f&&p!==void 0&&!(m===void 0&&h===void 0&&on.has(p))){e=m!==void 0,c=sn(m);let t=f[4]?.trim();s=t?I(t):void 0,r=r.slice(f[0].length).trim(),i=Tn(p),o=h!==void 0,l=sn(h)}else{let t=r.match(cn);if(!t)break;e=!!t[1],c=sn(t[1]);let n=t[3].trim();s=n?I(n):void 0;let a=t[2],u=t[4];r=r.slice(t[0].length).trim(),i=En(a,u),l=sn(u.slice(-1)),o=u.endsWith(`>`)||l!==void 0}let g=xn(r,t,n);if(!g||g.ids.length===0)break;r=g.remaining.trim();for(let n of a)for(let r of g.ids)t.edges.push({source:n,target:r,label:s,style:i,hasArrowStart:e,hasArrowEnd:o,...c===void 0?{}:{startMarker:c},...l===void 0?{}:{endMarker:l},...u===void 0?{}:{id:u}});a=g.ids}}function xn(e,t,n){let r=Sn(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=Sn(a,t,n);if(!e)break;i.push(e.id),a=e.remaining.trim()}return{ids:i,remaining:a}}function Sn(e,t,n){let r=null,i=e,a,o=i.match(yn);o&&(a=o[2],i=o[1]+i.slice(o[0].length));let s=i.match(dn);if(s){let e=s[1],a=qt(i.slice(e.length));if(a){let o=Ut(a.body);Cn(t,n,{id:e,label:I(pn(e,o)),shape:fn(o)}),r=e,i=i.slice(e.length+a.length)}}if(r===null)for(let{regex:e,shape:a}of ln){let o=i.match(e);if(o){r=o[1];let e=I(o[2]),s=typeof a==`function`?a(o[3]??``):a;Cn(t,n,{id:r,label:e,shape:s}),i=i.slice(o[0].length);break}}if(r===null){let e=i.match(un);e&&(r=e[1],t.nodes.has(r)||Cn(t,n,{id:r,label:r,shape:`rectangle`}),i=i.slice(e[0].length))}if(r===null)return null;a&&t.classAssignments.set(r,a);let c=i.match(vn);return c&&(t.classAssignments.set(r,c[1]),i=i.slice(c[0].length)),{id:r,remaining:i}}function Cn(e,t,n){e.nodes.has(n.id)||e.nodes.set(n.id,n),wn(t,n.id)}function wn(e,t){if(e.length>0){let n=e[e.length-1];n.nodeIds.includes(t)||n.nodeIds.push(t)}}function Tn(e){return e.startsWith(`~`)?`invisible`:e.includes(`.`)?`dotted`:e.startsWith(`=`)?`thick`:`solid`}function En(e,t){return e.includes(`.`)||t.includes(`.`)?`dotted`:e.startsWith(`=`)||t.startsWith(`=`)?`thick`:`solid`}function Dn(e){return`M ${e.x} ${e.y}`}function On(e){return Dn(e[0])+e.slice(1).map(e=>` L ${e.x} ${e.y}`).join(``)}function kn(e){if(e.length<3)return On(e);let t=e[e.length-1],n=[Dn(e[0])],r=(e,t,n)=>` C ${(2*e.x+t.x)/3} ${(2*e.y+t.y)/3}, ${(e.x+2*t.x)/3} ${(e.y+2*t.y)/3}, ${(e.x+4*t.x+n.x)/6} ${(e.y+4*t.y+n.y)/6}`;n.push(` L ${(5*e[0].x+e[1].x)/6} ${(5*e[0].y+e[1].y)/6}`);for(let t=2;t<e.length;t++)n.push(r(e[t-2],e[t-1],e[t]));return n.push(r(e[e.length-2],t,t)),n.push(` L ${t.x} ${t.y}`),n.join(``)}function An(e){if(e.length<3)return On(e);let t=[Dn(e[0])];for(let n=1;n<e.length-1;n++){let r=e[n-1],i=e[n],a=e[n+1],o=Math.hypot(i.x-r.x,i.y-r.y),s=Math.hypot(a.x-i.x,a.y-i.y);if(o===0||s===0){t.push(` L ${i.x} ${i.y}`);continue}let c=Math.min(12,o/2,s/2),l=i.x-(i.x-r.x)/o*c,u=i.y-(i.y-r.y)/o*c,d=i.x+(a.x-i.x)/s*c,f=i.y+(a.y-i.y)/s*c;t.push(` L ${l} ${u}`),t.push(` Q ${i.x} ${i.y}, ${d} ${f}`)}let n=e[e.length-1];return t.push(` L ${n.x} ${n.y}`),t.join(``)}function jn(e,t){let n=[Dn(e[0])],r=e.length-1;for(let i=0;i<r;i++){let a=e[i],o=e[i+1];if(i===r-1){n.push(` L ${o.x} ${o.y}`);break}if(t===`before`)n.push(` L ${a.x} ${o.y} L ${o.x} ${o.y}`);else if(t===`after`)n.push(` L ${o.x} ${a.y} L ${o.x} ${o.y}`);else{let e=(a.y+o.y)/2;n.push(` L ${a.x} ${e} L ${o.x} ${e} L ${o.x} ${o.y}`)}}return n.join(``)}function Mn(e,t=`linear`){if(e.length===0)return``;if(e.length===1)return Dn(e[0]);switch(t){case`basis`:return kn(e);case`natural`:return An(e);case`step`:return jn(e,`mid`);case`stepBefore`:return jn(e,`before`);case`stepAfter`:return jn(e,`after`);default:return On(e)}}var Nn=null,Pn=null,Fn=20;function In(e=Fn){if(!Number.isInteger(e)||e<1)throw Error(`createLayoutCache: maxSize must be a positive integer, got ${e}`);return{map:new Map,maxSize:e}}function Ln(e){if(Array.isArray(e))return`[${e.map(Ln).join(`,`)}]`;if(typeof e==`object`&&e){let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${Ln(t[e])}`).join(`,`)}}`}return JSON.stringify(e)}function Rn(){if(Nn&&Pn)return Pn;let e=[],t=globalThis.setTimeout;globalThis.setTimeout=(n,r)=>r===0?(e.push(n),0):t(n,r);let n=globalThis,r=`self`in n,i=n.self;if(r&&n.document===void 0&&delete n.self,Nn=new c.default,!Nn)throw Error(`ELKBundled construction unexpectedly produced no instance`);return r&&(n.self=i),globalThis.setTimeout=t,e.forEach(e=>e()),Pn=Nn.worker.worker,Pn}function zn(e,t){let n=t,r=n?Ln(e):void 0;if(n&&r!==void 0){let e=n.map.get(r);if(e)return n.map.delete(r),n.map.set(r,e),e}let i=Rn(),a,o,s=i.onmessage;if(i.onmessage=e=>{e.data.error?o=e.data.error:a=e.data.data},i.dispatcher.saveDispatch({data:{id:0,cmd:`layout`,graph:e}}),i.onmessage=s,o)throw o;if(!a)throw Error(`ELK layout did not return synchronously`);if(n&&r!==void 0&&(n.map.set(r,a),n.map.size>n.maxSize)){let e=n.map.keys().next().value;e!==void 0&&n.map.delete(e)}return a}function Bn(e,t,n){return F(e,t,n)}function Vn(e,t){return e.length*t*.6}var Hn={nodeLabel:13,edgeLabel:11,groupHeader:12};function Un(e){return{nodeLabel:e?.nodeLabel??Hn.nodeLabel,edgeLabel:e?.edgeLabel??Hn.edgeLabel,groupHeader:e?.groupHeader??Hn.groupHeader}}var z={nodeLabel:500,edgeLabel:400,groupHeader:600},Wn={horizontal:20,vertical:10,diamondExtra:24},B={outerBox:1,innerBox:.75,connector:1},Gn=`0.35em`,Kn={width:8,height:5},qn={font:`Inter`,padding:40,nodeSpacing:28,layerSpacing:48,mergeEdges:!0,thoroughness:3,fontSizes:Hn},Jn={flowchart:`DOWN`,state:`DOWN`,class:`DOWN`,er:`RIGHT`};function Yn(e,t){switch(e){case`LR`:return`RIGHT`;case`RL`:return`LEFT`;case`BT`:return`UP`;case`TD`:case`TB`:return`DOWN`;default:return t}}function Xn(e){let t=typeof e==`number`?{top:e,left:e,bottom:e,right:e}:e;return`[top=${t.top},left=${t.left},bottom=${t.bottom},right=${t.right}]`}function Zn(e){return{"elk.algorithm":`layered`,"elk.direction":e.direction,"elk.spacing.nodeNode":String(e.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(e.layerSpacing),"elk.padding":Xn(e.padding),"elk.edgeRouting":`ORTHOGONAL`}}function Qn(e,t,n){let r={id:e,width:t.width,height:t.height};return n!==void 0&&(r.labels=[{text:n}]),r}var $n={"elk.edgeLabels.inline":`true`,"elk.edgeLabels.placement":`CENTER`};function er(e,t){let n=xe(e,t.fontSize,z.edgeLabel),r={text:e,width:n.width+8,height:n.height+6};return t.layoutOptions&&(r.layoutOptions={...t.layoutOptions}),r}function tr(e){let t={id:e.id,sources:[e.source],targets:[e.target]};return e.label&&(t.labels=[er(e.label,e.labelStyle)]),t}function nr(e){return Yn(e,Jn.flowchart)}function rr(e){return{...Zn(e),"elk.spacing.edgeEdge":`12`,"elk.layered.spacing.edgeEdgeBetweenLayers":`12`,"elk.layered.spacing.edgeNodeBetweenLayers":`12`,"elk.layered.nodePlacement.bk.fixedAlignment":`BALANCED`,"elk.contentAlignment":`H_CENTER V_CENTER`}}function ir(e){return{fontSize:e.fontSizes.edgeLabel,layoutOptions:$n}}function ar(e,t,n,r){let i=xe(t,r,z.nodeLabel),a=i.width+Wn.horizontal*2,o=i.height+Wn.vertical*2;if(n===`diamond`){let e=Math.max(a,o)+Wn.diamondExtra;a=e,o=e}if(n===`circle`||n===`doublecircle`){let e=Math.ceil(Math.sqrt(a*a+o*o))+8;a=n===`doublecircle`?e+12:e,o=a}return n===`hexagon`&&(a+=Wn.horizontal),(n===`trapezoid`||n===`trapezoid-alt`||n===`parallelogram`||n===`parallelogram-alt`)&&(a+=Wn.horizontal),n===`asymmetric`&&(a+=12),n===`cylinder`&&(o+=14),n===`state-start`||n===`state-end`?{width:28,height:28}:(a=Math.max(a,60),o=Math.max(o,36),{width:a,height:o})}var or=` root`;function sr(e){for(let t of e)if(t.direction!==void 0||sr(t.children))return!0;return!1}function cr(e,t){for(let n of e.nodeIds)t.add(n);for(let n of e.children)cr(n,t)}function lr(e,t){let n=new Set;if(cr(e,n),n.size===0)return!0;let r=t=>n.has(t)||t===e.id;return!t.edges.some(e=>r(e.source)!==r(e.target))}function ur(e){let t=new Map;function n(e,r){let i=[...r,e.id];t.set(e.id,i);for(let t of e.children)n(t,i)}for(let t of e)n(t,[]);return t}function dr(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function fr(e,t){let n=new Set,r=new Set;for(let t of e.subgraphs)r.add(t.id),mr(t,n,r);let i=hr(e.subgraphs),a=ur(e.subgraphs),o=e=>e?a.get(e)??[]:[],s=new Map;s.set(null,[]);let c=[];for(let t=0;t<e.edges.length;t++){let n=e.edges[t],r=i.get(n.source),a=i.get(n.target);if(r&&r===a){let e=s.get(r)??[];s.set(r,e),e.push({index:t,edge:n})}else!r&&!a?s.get(null).push({index:t,edge:n}):c.push({index:t,edge:n,srcChain:o(r),tgtChain:o(a)})}let l=sr(e.subgraphs),u=[],d=[],f={...rr({direction:nr(e.direction),nodeSpacing:t.nodeSpacing,layerSpacing:t.layerSpacing,padding:t.padding}),"elk.layered.thoroughness":String(qn.thoroughness),"elk.layered.highDegreeNodes.treatment":`true`,"elk.layered.highDegreeNodes.threshold":`8`,"elk.layered.compaction.postCompaction.strategy":`LEFT_RIGHT_CONSTRAINT_LOCKING`,"elk.layered.considerModelOrder.strategy":`NODES_AND_EDGES`,"elk.layered.wrapping.strategy":`OFF`,"elk.hierarchyHandling":l?`SEPARATE`:`INCLUDE_CHILDREN`},p=new Map,m=new Map;function h(e,t){let n=p.get(e)??new Set;p.set(e,n),n.add(t)}function g(e,t){let n=m.get(e)??[];m.set(e,n),n.push(t)}if(l)for(let{index:e,edge:n,srcChain:r,tgtChain:i}of c){let a=dr(r,i),o=n.source;if(r.length>a){for(let t=r.length-1;t>=a;t--){let i=r[t],a=`${i}_out_${e}`;h(i,a);let o=t===r.length-1?n.source:`${r[t+1]}_out_${e}`;g(i,{id:`e${e}_s${t}`,sources:[o],targets:[a]})}o=`${r[a]}_out_${e}`}let s=n.target;if(i.length>a){for(let t=a;t<=i.length-1;t++){let r=i[t],a=`${r}_in_${e}`;h(r,a);let o=t===i.length-1?n.target:`${i[t+1]}_in_${e}`;g(r,{id:`e${e}_t${t}`,sources:[a],targets:[o]})}s=`${i[a]}_in_${e}`}g(a>0?r[a-1]:or,tr({id:`e${e}`,source:o,target:s,label:n.label,labelStyle:ir(t)}))}for(let[i,a]of e.nodes)if(!n.has(i)&&!r.has(i)){let e=ar(i,a.label,a.shape,t.fontSizes.nodeLabel);u.push(Qn(i,e,a.label))}for(let n of[...e.subgraphs].reverse())u.push(pr(n,e,t,s,p,m,e.direction));for(let{index:e,edge:n}of s.get(null))n.source!==n.target&&d.push(tr({id:`e${e}`,source:n.source,target:n.target,label:n.label,labelStyle:ir(t)}));if(l)for(let e of m.get(or)??[])d.push(e);else for(let{index:e,edge:n}of c)d.push(tr({id:`e${e}`,source:n.source,target:n.target,label:n.label,labelStyle:ir(t)}));return{id:`root`,layoutOptions:f,children:u,edges:d}}function pr(e,t,n,r,i,a,o){let s=e.direction!==void 0&&lr(e,t)?e.direction:o,c=rr({direction:nr(s),nodeSpacing:n.nodeSpacing,layerSpacing:n.layerSpacing,padding:{top:44,left:16,bottom:16,right:16}}),l,u=i.get(e.id);u&&u.size>0&&(l=[...u].map(e=>({id:e})));let d=[];for(let r of e.nodeIds){let e=t.nodes.get(r);if(e){let t=ar(r,e.label,e.shape,n.fontSizes.nodeLabel);d.push(Qn(r,t,e.label))}}for(let o of[...e.children].reverse())d.push(pr(o,t,n,r,i,a,s));let f=[],p=r.get(e.id)??[];for(let{index:e,edge:t}of p)t.source!==t.target&&f.push(tr({id:`e${e}`,source:t.source,target:t.target,label:t.label,labelStyle:ir(n)}));for(let t of a.get(e.id)??[])f.push(t);return{id:e.id,layoutOptions:c,labels:e.label?[{text:e.label}]:void 0,ports:l,children:d,edges:f}}function mr(e,t,n){for(let n of e.nodeIds)t.add(n);for(let r of e.children)n.add(r.id),mr(r,t,n)}function hr(e){let t=new Map;function n(e){for(let n of e.nodeIds)t.set(n,e.id);for(let t of e.children)n(t)}for(let t of e)n(t);return t}function gr(e,t,n){if(e.length<2||t.shape===`rectangle`||t.shape===`rounded`||t.shape===`stadium`)return e;let r=[...e];if(t.shape===`diamond`){if(n)r[0]=_r(e[0],e[1],t);else{let n=e.length-1;r[n]=_r(e[n],e[n-1],t)}}return r}function _r(e,t,n){let r=n.x+n.width/2,i=n.y+n.height/2,a={x:r,y:n.y},o={x:n.x+n.width,y:i},s={x:r,y:n.y+n.height},c={x:n.x,y:i},l=e.x-t.x,u=e.y-t.y;if(Math.abs(l)<Math.abs(u)){let t=e.x;return u>0?t<=r?yr(t,c,a)??a:yr(t,a,o)??a:t<=r?yr(t,s,c)??s:yr(t,o,s)??s}{let t=e.y;return l>0?t<=i?vr(t,a,c)??c:vr(t,c,s)??c:t<=i?vr(t,a,o)??o:vr(t,o,s)??o}}function vr(e,t,n){let r=n.y-t.y;if(Math.abs(r)<.001)return null;let i=(e-t.y)/r;return i<0||i>1?null:{x:t.x+i*(n.x-t.x),y:e}}function yr(e,t,n){let r=n.x-t.x;if(Math.abs(r)<.001)return null;let i=(e-t.x)/r;return i<0||i>1?null:{x:e,y:t.y+i*(n.y-t.y)}}function br(e,t,n){if(e.length===0)return;let r=n===`LR`||n===`RL`,i=new Set;for(let e of t)i.add(`${e.source}:${e.target}`),i.add(`${e.target}:${e.source}`);let a=qn.layerSpacing*.6,o=[...e].sort((e,t)=>r?e.x-t.x:e.y-t.y),s=[],c=[o[0]];for(let e=1;e<o.length;e++){let t=(r?o[e].x:o[e].y)-(r?o[e-1].x:o[e-1].y),n=c.some(t=>i.has(`${t.id}:${o[e].id}`));t<=a&&!n?c.push(o[e]):(s.push(c),c=[o[e]])}s.push(c);let l=new Map;for(let e of s){if(e.length<=1)continue;let t=e.map(e=>r?e.x:e.y),n=Math.min(...t),i=Math.max(...t);if(i-n<=1)continue;let a=(n+i)/2;for(let t of e){let e=a-(r?t.x:t.y);Math.abs(e)>.5&&(r?t.x=a:t.y=a,l.set(t.id,e))}}if(l.size!==0)for(let e of t){if(e.points.length<2)continue;let t=l.get(e.source),n=l.get(e.target);if(t!=null){let n=e.points[0];r?(n.x+=t,e.points.length>1&&e.points[1].x===n.x-t&&(e.points[1].x+=t)):(n.y+=t,e.points.length>1&&e.points[1].y===n.y-t&&(e.points[1].y+=t))}if(n!=null){let t=e.points[e.points.length-1];if(r){if(t.x+=n,e.points.length>1){let r=e.points[e.points.length-2];r.x===t.x-n&&(r.x+=n)}}else if(t.y+=n,e.points.length>1){let r=e.points[e.points.length-2];r.y===t.y-n&&(r.y+=n)}}}}var xr=.5;function Sr(e,t,n){for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1],o=Math.min(i.x,a.x),s=Math.max(i.x,a.x),c=Math.min(i.y,a.y),l=Math.max(i.y,a.y);for(let e of t){if(n.has(e.id))continue;let t=e.x+xr,r=e.x+e.width-xr,i=e.y+xr,a=e.y+e.height-xr;if(!(t>=r||i>=a)&&o<r&&s>t&&c<a&&l>i)return!1}}return!0}function Cr(e,t,n){let r=[];for(let i of n)e>=i.x&&e<=i.x+i.width&&t>=i.y&&t<=i.y+i.height&&(r.push(i),r.push(...Cr(e,t,i.children)));return r}function wr(e,t,n,r,i){let a=i===`LR`,o=i===`RL`,s=i===`BT`,c=a||o,l=new Set(Cr(t,n,r).map(e=>e.id)),u=Cr(c?e:t,c?n:e,r).find(e=>!l.has(e.id));return u?a?u.x-12:o?u.x+u.width+12:s?u.y+u.height+12:u.y-12:e}function Tr(e,t,n,r){let i=new Map(t.map(e=>[e.id,e])),a=new Set,o=r===`LR`,s=r===`RL`,c=r===`BT`,l=o||s,u=new Map;for(let t of e){if(t.source===t.target)continue;let e=u.get(t.source)??[];u.set(t.source,e),e.push(t)}for(let[e,d]of u){if(d.length<2)continue;let u=d[0].style;if(d.some(e=>e.label||e.style!==u))continue;let f=i.get(e);if(!f)continue;let p=[];for(let e of d){let t=i.get(e.target);t&&(o?t.x>f.x+f.width:s?t.x+t.width<f.x:c?t.y+t.height<f.y:t.y>f.y+f.height)&&p.push({edge:e,node:t})}if(p.length<2)continue;let m=f.x+f.width/2,h=f.y+f.height/2;if(l){let i=o?f.x+f.width:f.x,s=h,c=i+((o?Math.min(...p.map(e=>e.node.x)):Math.max(...p.map(e=>e.node.x+e.node.width)))-i)/2;c=wr(c,m,h,n,r);let l=[];for(let{edge:n,node:r}of p){let a=o?r.x:r.x+r.width,u=r.y+r.height/2,d=[{x:i,y:s},{x:c,y:s},{x:c,y:u},{x:a,y:u}];Sr(d,t,new Set([e,r.id]))&&l.push({edge:n,points:d})}if(l.length<2)continue;for(let{edge:e,points:t}of l)e.points=t,a.add(e)}else{let i=m,o=c?f.y:f.y+f.height,s=o+((c?Math.max(...p.map(e=>e.node.y+e.node.height)):Math.min(...p.map(e=>e.node.y)))-o)/2;s=wr(s,m,h,n,r);let l=[];for(let{edge:n,node:r}of p){let a=r.x+r.width/2,u=c?r.y+r.height:r.y,d=[{x:i,y:o},{x:i,y:s},{x:a,y:s},{x:a,y:u}];Sr(d,t,new Set([e,r.id]))&&l.push({edge:n,points:d})}if(l.length<2)continue;for(let{edge:e,points:t}of l)e.points=t,a.add(e)}}let d=new Map;for(let t of e){if(a.has(t)||t.source===t.target)continue;let e=d.get(t.target)??[];d.set(t.target,e),e.push(t)}for(let[e,a]of d){if(a.length<2)continue;let u=a[0].style;if(a.some(e=>e.label||e.style!==u))continue;let d=i.get(e);if(!d)continue;let f=[];for(let e of a){let t=i.get(e.source);t&&(o?t.x+t.width<d.x:s?t.x>d.x+d.width:c?t.y>d.y+d.height:t.y+t.height<d.y)&&f.push({edge:e,node:t})}if(f.length<2)continue;let p=d.x+d.width/2,m=d.y+d.height/2;if(l){let i=o?d.x:d.x+d.width,a=m,s=o?Math.max(...f.map(e=>e.node.x+e.node.width)):Math.min(...f.map(e=>e.node.x)),c=s+(i-s)/2;c=wr(c,p,m,n,r);let l=[];for(let{edge:n,node:r}of f){let s=o?r.x+r.width:r.x,u=r.y+r.height/2,d=[{x:s,y:u},{x:c,y:u},{x:c,y:a},{x:i,y:a}];Sr(d,t,new Set([r.id,e]))&&l.push({edge:n,points:d})}if(l.length<2)continue;for(let{edge:e,points:t}of l)e.points=t}else{let i=p,a=c?d.y+d.height:d.y,o=c?Math.min(...f.map(e=>e.node.y)):Math.max(...f.map(e=>e.node.y+e.node.height)),s=o+(a-o)/2;s=wr(s,p,m,n,r);let l=[];for(let{edge:n,node:r}of f){let o=r.x+r.width/2,u=[{x:o,y:c?r.y:r.y+r.height},{x:o,y:s},{x:i,y:s},{x:i,y:a}];Sr(u,t,new Set([r.id,e]))&&l.push({edge:n,points:u})}if(l.length<2)continue;for(let{edge:e,points:t}of l)e.points=t}}}function Er(e,t=0,n=0){let r=[];if(!e.sections||e.sections.length===0)return r;let i=e.sections[0];if(r.push({x:i.startPoint.x+t,y:i.startPoint.y+n}),i.bendPoints)for(let e of i.bendPoints)r.push({x:e.x+t,y:e.y+n});return r.push({x:i.endPoint.x+t,y:i.endPoint.y+n}),r}function Dr(e,t=0,n=0){if(!e.labels||e.labels.length===0)return;let r=e.labels[0];if(r.x!=null&&r.y!=null)return{x:r.x+(r.width??0)/2+t,y:r.y+(r.height??0)/2+n}}var Or=16,kr=28,Ar=18,jr=28,Mr=10;function Nr(e,t){let n=e.x+e.width,r=e.y+e.height/2,i=Math.min(jr,e.height*.6)/2,a=kr+t*Ar,o=[];for(let e=0;e<=Or;e++){let t=Math.PI*e/Or;o.push({x:n+a*Math.sin(t),y:r-i*Math.cos(t)})}return{points:o,labelPosition:{x:n+a+Mr,y:r}}}function Pr(e,t,n){let r=new Map;for(let i=0;i<e.edges.length;i++){let a=e.edges[i];if(a.source!==a.target)continue;let o=t.get(a.source);if(!o)continue;let s=r.get(o.id)??0;r.set(o.id,s+1);let{points:c,labelPosition:l}=Nr(o,s);n.push({source:a.source,target:a.target,label:a.label,style:a.style,hasArrowStart:a.hasArrowStart,hasArrowEnd:a.hasArrowEnd,points:c,labelPosition:a.label?l:void 0,inlineStyle:Gr(i,e),id:a.id,animate:a.animate})}}function Fr(e){let t=[];for(let n of e)t.push({x:n.x,y:n.y,right:n.x+n.width,bottom:n.y+n.height}),t.push(...Fr(n.children));return t}function Ir(e,t,n=!1){let r=[],i=[],a=[],o=new Set;for(let e of t.subgraphs)Wr(e,o);Lr(e,t,o,r,a,0,0);let s=Fr(a);Br(e,t,i,0,0,s.length>0?{leftX:Math.min(...s.map(e=>e.x))-20,rightX:Math.max(...s.map(e=>e.right))+20}:void 0),br(r,i,t.direction);let c=new Map(r.map(e=>[e.id,e]));Pr(t,c,i),n&&Tr(i,r,a,t.direction);for(let e of i){let t=c.get(e.source),n=c.get(e.target);t&&(e.points=gr(e.points,t,!0)),n&&(e.points=gr(e.points,n,!1))}let l=e.width??800,u=e.height??600,d=Kn.width,f=qn.padding;for(let e of i){for(let t of e.points)l=Math.max(l,t.x+d+f),u=Math.max(u,t.y+d+f);e.labelPosition&&(l=Math.max(l,e.labelPosition.x+60+f),u=Math.max(u,e.labelPosition.y+20+f))}return{width:l,height:u,nodes:r,edges:i,groups:a}}function Lr(e,t,n,r,i,a,o){if(e.children)for(let s of e.children){let e=(s.x??0)+a,c=(s.y??0)+o,l=s.width??0,u=s.height??0;if(n.has(s.id)){let a=[];Lr(s,t,n,r,a,e,c);let o=Ur(t.subgraphs,s.id);i.push({id:s.id,label:o?.label??``,x:e,y:c,width:l,height:u,children:a})}else{let a=t.nodes.get(s.id);if(a){let n=Fe(s.id,t),i=t.classAssignments.get(s.id);r.push({id:s.id,label:a.label,shape:a.shape,x:e,y:c,width:l,height:u,inlineStyle:n,className:i,interaction:t.interactions.get(s.id)})}s.children&&s.children.length>0&&Lr(s,t,n,r,i,e,c)}}}function Rr(e){let t=/^e(\d+)$/.exec(e);if(t)return{edgeIndex:parseInt(t[1],10),role:`bridge`};let n=/^e(\d+)_([st])(\d+)$/.exec(e);if(n)return{edgeIndex:parseInt(n[1],10),role:n[2]===`s`?`source`:`target`,level:parseInt(n[3],10)}}function zr(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)}let n=t/2;for(let t=1;t<e.length;t++){let r=e[t].x-e[t-1].x,i=e[t].y-e[t-1].y,a=Math.sqrt(r*r+i*i);if(n<=a){let o=n/a;return{x:e[t-1].x+o*r,y:e[t-1].y+o*i}}n-=a}return e[e.length-1]}function Br(e,t,n,r,i,a){let o=new Map;Hr(e,o,0,0);let s=0;for(let[e,r]of o){let i=t.edges[e];if(!i)continue;let o=[],c=e=>{!e||e.points.length===0||(o.length>0?o.push(...e.points.slice(1)):o.push(...e.points))},l=[...r.sourceHops.keys()].sort((e,t)=>t-e);for(let e of l)c(r.sourceHops.get(e));c(r.bridge);let u=[...r.targetHops.keys()].sort((e,t)=>e-t);for(let e of u)c(r.targetHops.get(e));let d;i.label&&o.length>=2&&(d=r.bridge?.labelPosition??zr(o));let f=Vr(o,a,s);f!==o&&s++,i.label&&f!==o&&f.length>=2&&(d=zr(f)),n.push({source:i.source,target:i.target,label:i.label,style:i.style,hasArrowStart:i.hasArrowStart,hasArrowEnd:i.hasArrowEnd,points:f,labelPosition:d,inlineStyle:Gr(e,t),id:i.id,animate:i.animate})}}function Vr(e,t,n=0){if(e.length<2)return e;let r=!1;for(let t=1;t<e.length;t++){let n=Math.abs(e[t].x-e[t-1].x),i=Math.abs(e[t].y-e[t-1].y);if(n>1&&i>1){r=!0;break}}if(!r)return e;let i=[e[0]];for(let r=1;r<e.length;r++){let a=i[i.length-1],o=e[r],s=Math.abs(o.x-a.x),c=Math.abs(o.y-a.y);if(s>1&&c>1){if(t){let e=n%2==0,r=Math.floor(n/2)*12,s=e?t.rightX+r:t.leftX-r;i.push({x:s,y:a.y}),i.push({x:s,y:o.y})}else{let e=(a.y+o.y)/2;i.push({x:a.x,y:e}),i.push({x:o.x,y:e})}}i.push(o)}return i}function Hr(e,t,n,r){if(e.edges)for(let i of e.edges){let e=Rr(i.id);if(!e)continue;let{edgeIndex:a}=e,o=Er(i,n,r),s=Dr(i,n,r),c=t.get(a)??{sourceHops:new Map,targetHops:new Map};t.set(a,c);let l={edgeIndex:a,points:o,labelPosition:s};e.role===`bridge`?c.bridge=l:e.role===`source`?c.sourceHops.set(e.level,l):c.targetHops.set(e.level,l)}if(e.children)for(let i of e.children)Hr(i,t,n+(i.x??0),r+(i.y??0))}function Ur(e,t){for(let n of e){if(n.id===t)return n;let e=Ur(n.children,t);if(e)return e}}function Wr(e,t){t.add(e.id);for(let n of e.children)Wr(n,t)}function Gr(e,t){let n,r=t.linkStyles.get(`default`);r&&(n={...r});let i=t.linkStyles.get(e);return i&&(n=n?{...n,...i}:{...i}),n}function Kr(e,t={}){let n={...qn,...t,fontSizes:Un(t.fontSizes)};return Ir(zn(fr(e,n),t.layoutCache),e,n.mergeEdges)}function qr(e,t,n=`Inter`,r=!1,i=Hn,a=`linear`,o,s=!0,c=!0,l,u,f={}){let p=[],m=c&&e.nodes.some(e=>!!d(e.interaction?.href));p.push(Wi(Qe(e.width,e.height,t,r,l,u,m,f.styleAttribute),o)),p.push(Ke(n,!1,f.nonce)),s&&e.edges.some(e=>e.animate)&&p.push(Jr(f.nonce)),p.push(`<defs>`),p.push(Yr());let h=new Set;for(let t of e.edges)t.inlineStyle?.stroke&&h.add(t.inlineStyle.stroke);for(let e of h)p.push(Xr(e));p.push(`</defs>`);for(let t of e.groups)p.push($r(t,n,i));for(let t of e.edges)p.push(ei(t,a,s));for(let t of e.edges)t.label&&p.push(ni(t,n,i));for(let t of e.nodes)p.push(oi(t,n,i,c));return p.push(`</svg>`),p.join(`
|
|
23
|
-
`)}function
|
|
24
|
-
`)}function
|
|
25
|
-
`+s(`arrowhead-start${t}`,`auto-start-reverse`)}function
|
|
26
|
-
`)}function
|
|
27
|
-
`)}\n</g>`}function
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
30
|
-
`)}function
|
|
31
|
-
`)}function
|
|
21
|
+
`)}function Ke(e,t,n){return(.299*e+.587*t+.114*n)/255}function qe(e,t){if(!e)return t;let n=m(e);return n?Ke(...n)>.5?`#000000`:`#FFFFFF`:t}var Je=0;function Ye(){return Je+=1,`zm-title-${Je}`}function Xe(e,t){return`${[`--bg:${e.bg}`,`--fg:${e.fg}`,e.line?`--line:${e.line}`:``,e.accent?`--accent:${e.accent}`:``,e.muted?`--muted:${e.muted}`:``,e.surface?`--surface:${e.surface}`:``,e.border?`--border:${e.border}`:``].filter(Boolean).join(`;`)}${t?``:`;background:var(--bg)`}`}function Ze(e,t,n,r,i,a,o,s=!0){let c=s?` style="${Xe(n,r)}"`:``,l=``,u=``;if(o){if(i){let e=Ye();l=` aria-labelledby="${e}"`,u=`\n <title id="${e}">${Se(i)}</title>`}}else if(a)l=` aria-hidden="true"`;else if(l=` role="img"`,i){let e=Ye();l+=` aria-labelledby="${e}"`,u=`\n <title id="${e}">${Se(i)}</title>`}return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e} ${t}" width="${e}" height="${t}"${l}${c}>`+u}var Qe=`<\\|--|<\\|\\.\\.|\\*--|o--|-->|--\\*|--o|--\\|>|\\.\\.>|\\.\\.\\|>|<--|<\\.\\.?|--`,$e=new RegExp(Qe);function et(e){let t={classes:[],relationships:[],namespaces:[],interactions:new Map,classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,notes:[]},n=new Map,r=null,i=null,a=0,o;for(let c=1;c<e.length;c++){let l=e[c],d=l.text;if(i&&a>0){if(d===`}`){a--,a===0&&(i=null,o=void 0);continue}let e=d.match(/^<<(\w+)>>$/);if(e){i.annotation=e[1];continue}if(d.startsWith(`<<`))throw Error(`Line ${l.line}: Malformed class annotation "${d}" — expected "<<name>>" (e.g. "<<interface>>").`);tt(i,d,l.line);continue}if(/^click\s+/i.test(d)){u(d,t.interactions);continue}let f=d.match(/^note\s+(?:for\s+(\S+)\s+)?"([^"]*)"\s*$/);if(f){let e=f[1];t.notes.push({text:L(f[2]),...e?{forClass:e}:{}});continue}if(ke(d,t)||Me(d,t)||je(d,t)||Ae(d,t))continue;let p=d.match(/^namespace\s+(\S+)\s*\{$/);if(p){r={name:p[1],classIds:[]};continue}if(d===`}`&&r){t.namespaces.push(r),r=null;continue}let m=d.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);if(m){let e=s(m[1],m[2]);i=n.get(e)??null,a=1,o=l.line;continue}let h=d.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);if(h){s(h[1],h[2]);continue}let g=d.match(/^class\s+(\S+?)\s*\{\s*(.*?)\s*\}$/);if(g){let e=s(g[1],void 0),t=n.get(e),r=g[2],i=r.match(/^<<(\w+)>>$/);if(t&&i)t.annotation=i[1];else if(t&&r.startsWith(`<<`))throw Error(`Line ${l.line}: Malformed class annotation "${r}" — expected "<<name>>" (e.g. "<<interface>>").`);else t&&r&&tt(t,r,l.line);continue}let _=d.match(/^(\S+?)\s*:\s*(.+)$/);if(_){let e=_[2];if(!e.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)){tt(nt(n,_[1]),e,l.line);continue}}let v=st(d);if(v){v.from=s(v.from,void 0,!1),v.to=s(v.to,void 0,!1),t.relationships.push(v);continue}if($e.test(d))throw Error(`Line ${l.line}: Malformed class-diagram relationship "${d}". Expected "FROM ARROW TO" (optionally with cardinalities and a ": label"), e.g. "Animal <|-- Dog" or 'A "1" --> "*" B : label'. ARROW must be one of <|--, <|.., *--, o--, -->, --*, --o, --|>, ..>, ..|>, <--, <.., or --.`)}if(i!==null)throw Error(`Line ${o}: Unclosed class body for "${i.id}" — expected a closing "}" before the diagram ends.`);return t.classes=[...n.values()],t;function s(e,i,a=!0){let{id:o,className:s}=Ne(e),c=o,l=i;if(!l){let e=o.match(/^(.+?)~(\w+)~$/);e&&(c=e[1],l=e[2])}let u=nt(n,c);return l&&(u.label=`${c}<${l}>`),s&&t.classAssignments.set(c,s),a&&r&&r.classIds.push(c),c}}function tt(e,t,n){let r=ot(t,n);r&&(r.isMethod?e.methods.push(r.member):e.attributes.push(r.member))}function nt(e,t){let n=e.get(t);return n||(n={id:t,label:t,attributes:[],methods:[]},e.set(t,n)),n}function rt(e,t){return Math.max(0,e.split(t).length-1)}function it(e){let t=rt(e,`~`);if(t<=1)return e;let n=e,r=!1;t%2!=0&&n.startsWith(`~`)&&(n=n.slice(1),r=!0);let i=[...n],a=i.indexOf(`~`),o=i.lastIndexOf(`~`);for(;a!==-1&&o!==-1&&a!==o;)i[a]=`<`,i[o]=`>`,a=i.indexOf(`~`),o=i.lastIndexOf(`~`);return r&&i.unshift(`~`),i.join(``)}function at(e){let t=e.split(/(,)/),n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r===`,`&&e>0&&e+1<t.length){let i=t[e-1],a=t[e+1];rt(i,`~`)===1&&rt(a,`~`)===1&&(r=`${i},${a}`,e++,n.pop())}n.push(it(r))}return n.join(``)}function ot(e,t){let n=e.trim().replace(/;$/,``);if(!n)return null;let r=``,i=n,a=i[0];if((a===`+`||a===`-`||a===`#`||a===`~`)&&(r=a,i=i.slice(1).trim()),i.includes(`(`)&&!i.includes(`)`))throw Error(`Line ${t}: Malformed class member "${n}" — unclosed "(" in a method signature. Expected e.g. "+eat() void" or "+eat(Food f) void".`);let o=i.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);if(o){let e=at(o[1].trim()),t=o[2]?.trim(),n=t?at(t):void 0,a=o[3]?.trim(),s=a?at(a):void 0,c=e.endsWith(`$`)||i.includes(`$`),l=e.endsWith(`*`)||i.includes(`*`);return{member:{visibility:r,name:e.replace(/[$*]$/,``),type:s||void 0,isStatic:c,isAbstract:l,isMethod:!0,params:n},isMethod:!0}}let s=at(i).split(/\s+/),c,l;s.length>=2?(l=s[0],c=s.slice(1).join(` `)):c=s[0]??i;let u=c.endsWith(`$`),d=c.endsWith(`*`);return{member:{visibility:r,name:c.replace(/[$*]$/,``),type:l||void 0,isStatic:u,isAbstract:d,isMethod:!1},isMethod:!1}}function st(e){let t=e.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${Qe})\\s+(?:"([^"]*?)"\\s+)?(\\S+?)(?::::([\\w][\\w-]*))?(?:\\s*:\\s*(.+))?$`));if(!t)return null;let n=t[1],r=t[2],i=r?L(r):void 0,a=t[3].trim(),o=t[4],s=o?L(o):void 0,c=t[6]?`${t[5]}:::${t[6]}`:t[5],l=t[7]?.trim(),u=l?L(l):void 0,d=ct(a);return d?{from:n,to:c,type:d.type,markerAt:d.markerAt,label:u,fromCardinality:i,toCardinality:s}:null}function ct(e){switch(e.trim()){case`<|--`:return{type:`inheritance`,markerAt:`from`};case`--|>`:return{type:`inheritance`,markerAt:`to`};case`<|..`:return{type:`realization`,markerAt:`from`};case`..|>`:return{type:`realization`,markerAt:`to`};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:`association`,markerAt:`from`};case`..>`:return{type:`dependency`,markerAt:`to`};case`<..`:return{type:`dependency`,markerAt:`from`};case`--`:return{type:`association`,markerAt:`to`};default:return null}}function lt(e){return`${e.visibility?`${e.visibility} `:``}${e.isMethod?`${e.name}(${e.params||``})`:e.name}${e.type?`: ${e.type}`:``}`}function ut(e){let t={entities:[],relationships:[]},n=new Map,r=null;for(let i=1;i<e.length;i++){let a=e[i],o=a.text;if(r){if(o===`}`){r=null;continue}let e=ft(o);e&&r.attributes.push(e);continue}let s=o.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(s){t.direction=A(s[1]);continue}let c=o.match(/^(\S+?)(?:\[(.+)\])?\s*\{(.*)$/);if(c){let e=c[1],t=c[2],i=dt(n,e,t===void 0?void 0:L(t.trim().replace(/^["']|["']$/g,``))),a=c[3].trim(),o=a.endsWith(`}`),s=o?a.slice(0,-1).trim():a;for(let e of s.split(`;`).map(e=>e.trim()).filter(Boolean)){let t=ft(e);t&&i.attributes.push(t)}o||(r=i);continue}let l=pt(o,a.line);if(l){dt(n,l.entity1),dt(n,l.entity2),t.relationships.push(l);continue}}return t.entities=[...n.values()],t}function dt(e,t,n){let r=e.get(t);return r?n!==void 0&&(r.label=n):(r={id:t,label:n??t,attributes:[]},e.set(t,r)),r}function ft(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=L(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 pt(e,t){let n=e.match(/^(\S+)\s+(\S*(?:--|\.\.)\S*)\s+(\S+)\s*(?::\s*(.*))?$/);if(!n)return null;let r=n[1],i=n[2],a=n[3],o=n[4]!==void 0,s=n[4]?.trim()??``,c=i.match(/^([|o}{]*)(--|\.\.?)([|o}{]*)$/),l=c?mt(c[1]):null,u=c?ht(c[3]):null;if(!l||!u)throw Error(`Line ${t}: Invalid ER relationship cardinality "${i}" in "${e}". Left side must be one of ||, |o, }|, }o; right side must be one of ||, o|, |{, o{ (e.g. "||--o{").`);if(!o||s.length===0)throw Error(`Line ${t}: ER relationship "${r} ${i} ${a}" is missing a ": label" — expected e.g. "${r} ${i} ${a} : label".`);return{entity1:r,entity2:a,cardinality1:l,cardinality2:u,label:L(s.replace(/^["']|["']$/g,``)),identifying:c[2]===`--`}}function mt(e){return e===`||`?`one`:e===`|o`?`zero-one`:e===`}|`?`many`:e===`}o`?`zero-many`:null}function ht(e){return e===`||`?`one`:e===`o|`?`zero-one`:e===`|{`?`many`:e===`o{`?`zero-many`:null}var gt=new Set(`aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen`.split(` `)),_t=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,vt=/^(?:rgba?|hsla?)\(\s*[\d.%]+(?:[\s,/]+[\d.%]+){2,3}\s*\)$/i;function yt(e){return gt.has(e.toLowerCase())||_t.test(e)||vt.test(e)}function bt(e){let t=e.trim(),n=t.match(/^((?:rgba?|hsla?)\s*\([^)]*\)|#[0-9a-fA-F]+|\S+)?(.*)$/),r=n?.[1]??``,i=n?.[2]?.trim()??``;return r.toLowerCase()===`transparent`?{label:i}:r!==``&&yt(r)?{color:r,label:i}:{label:t}}function xt(e){return e===`loop`||e===`alt`||e===`opt`||e===`par`||e===`critical`||e===`break`||e===`rect`}function St(e){if(!xt(e))throw Error(`Invalid block type: "${e}"`);return e}var Ct=/^(.+?)\s*(<<->>|<<-->>|--?>?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/,wt=/^(.+?)\s*(<<->>|<<-->>|--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/;function Tt(e){let t={actors:[],messages:[],blocks:[],notes:[],activations:[],boxes:[]},n={open:void 0,membership:new Map},r=0,i,a=new Set,o=[],s={enabled:!1,next:1,step:1},c,l;for(let u=1;u<e.length;u++){let d=e[u],f=d.text,p=f.match(/^box(?:\s+(.*))?$/);if(p){if(n.open!==void 0)throw Error(`Line ${d.line}: Sequence diagram: a box cannot be nested inside another box — close the open box with "end" first`);let{color:e,label:a}=bt(p[1]??``),s={label:L(a),actorIds:[]};e!==void 0&&(s.color=e),t.boxes.push(s),n.open=t.boxes.length-1,r=o.length,i=d.line;continue}let m=f.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(m){let e=m[1]===`actor`?`actor`:`participant`,r=m[2];if(a.has(r))throw Error(`Line ${d.line}: It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior`);a.add(r),t.actors.push({id:r,label:L(m[3]?.trim()??r),type:e}),Ot(t,n,r,d.line),c=r;continue}let h=f.match(/^destroy\s+(.+)$/);if(h){let e=h[1].trim();Dt(t,a,n,e,d.line),l=e;continue}let g=f.match(/^autonumber(?:\s+(off|\d+(?:\.\d{1,2})?)(?:\s+(\d+(?:\.\d{1,2})?))?)?$/);if(g){let e=g[1],t=g[2];e===`off`?s.enabled=!1:(s.enabled=!0,s.next=e===void 0?1:Number(e),s.step=t===void 0?1:Number(t));continue}let _=f.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(_){let e=_[1]===`actor`?`actor`:`participant`,r=_[2],i=L(_[3]?.trim()??r);a.has(r)||(a.add(r),t.actors.push({id:r,label:i,type:e})),Ot(t,n,r,d.line);continue}let v=f.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);if(v){let e=v[1].toLowerCase(),r=v[2].trim(),i=L(v[3].trim()),o=r.split(`,`).map(e=>e.trim());for(let e of o)Dt(t,a,n,e,d.line);let s=`over`;e===`left of`?s=`left`:e===`right of`&&(s=`right`),t.notes.push({actorIds:o,text:i,position:s,afterIndex:t.messages.length-1});continue}let y=f.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);if(y){let e=St(y[1]),n=L(y[2]?.trim()??``);o.push({type:e,label:n,startIndex:t.messages.length,dividers:[],line:d.line});continue}let b=f.match(/^(else|and)\s*(.*)$/);if(b&&o.length>0){let e=L(b[2]?.trim()??``);o[o.length-1].dividers.push({index:t.messages.length,label:e});continue}if(f===`end`&&n.open!==void 0&&o.length===r){n.open=void 0,i=void 0;continue}if(f===`end`&&o.length>0){let e=o.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}if(f===`end`)throw Error(`Line ${d.line}: Sequence diagram: "end" does not match any open block ("loop"/"alt"/"opt"/"par"/"critical"/"break"/"rect") or "box" — nothing is currently open to close.`);let x=f.match(/^(activate|deactivate)\s+(.+)$/);if(x){let e=x[2].trim();Dt(t,a,n,e,d.line),t.activations.push({actorId:e,kind:x[1]===`activate`?`start`:`end`,afterIndex:t.messages.length-1});continue}let S=f.match(Ct)??f.match(wt);if(S){let e=S[2],r=S[4][0];if(r===`>`||r===`)`)throw Error(`Line ${d.line}: Malformed sequence-diagram arrow in "${f}" — "${e}${r}" is not a recognized arrow. Expected one of: ->, -->, ->>, -->>, -x, --x, -), --), <<->>, <<-->>.`);kt(t,a,n,s,S[1],S[2],S[3],S[4],S[5],d.line);let i=t.messages.length-1,o=t.messages[i];if(c!==void 0){if(o.to!==c)throw Error(`Line ${d.line}: The created participant ${c} does not have an associated creating message after its declaration. Please check the sequence diagram.`);Et(t,c).createdAt=i,c=void 0}if(l!==void 0){if(o.from!==l&&o.to!==l)throw Error(`Line ${d.line}: The destroyed participant ${l} does not have an associated destroying message after its declaration. Please check the sequence diagram.`);Et(t,l).destroyedAt=i,l=void 0}continue}}if(o.length>0){let e=o[o.length-1];throw Error(`Line ${e.line}: Sequence diagram: unclosed "${e.type}" block — expected a matching "end" before the diagram ends.`)}if(n.open!==void 0){let e=t.boxes[n.open];throw Error(`Line ${i}: Sequence diagram: unclosed "box${e.label?` ${e.label}`:``}" — expected a matching "end" before the diagram ends.`)}return t}function Et(e,t){let n=e.actors.find(e=>e.id===t);if(n===void 0)throw Error(`Sequence diagram: unknown actor "${t}"`);return n}function Dt(e,t,n,r,i){t.has(r)||(t.add(r),e.actors.push({id:r,label:r,type:`participant`})),Ot(e,n,r,i)}function Ot(e,t,n,r){let i=t.open;if(i===void 0)return;let a=t.membership.get(n);if(a!==i){if(a!==void 0){let t=e.boxes[a].label,o=e.boxes[i].label;throw Error(`Line ${r}: A same participant should only be defined in one Box: ${n} can't be in '${t}' and in '${o}' at the same time.`)}t.membership.set(n,i),e.boxes[i].actorIds.push(n)}}function kt(e,t,n,r,i,a,o,s,c,l){Dt(e,t,n,i,l),Dt(e,t,n,s,l);let u=a===`<<->>`||a===`<<-->>`,d=u?a===`<<-->>`?`dashed`:`solid`:a.startsWith(`--`)?`dashed`:`solid`,f=a.includes(`>>`)||a.includes(`x`)?`filled`:`open`,p=a.includes(`x`),m={from:i,to:s,label:L(c.trim()),lineStyle:d,arrowHead:f};p&&(m.isLost=!0),u&&(m.bidirectional=!0),o===`+`&&(m.activate=!0),o===`-`&&(m.deactivate=!0),r.enabled&&(m.seqNumber=r.next,r.next=Math.round((r.next+r.step)*100)/100),e.messages.push(m)}function At(e){let t={},n={},r=[],i,a=!1;for(let o of e){let e=o.text;if(/^xychart(-beta)?\b/i.test(e)){/\bhorizontal\b/i.test(e)&&(a=!0);continue}let s=e.match(/^title\s+"([^"]+)"/);if(s){i=s[1];continue}let c=e.match(/^x-axis\s+(?:"([^"]*)"\s*)?\[([^\]]+)\]/);if(c){c[1]&&(t.title=c[1]),t.categories=c[2].split(`,`).map(e=>e.trim());continue}let l=e.match(/^x-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(l){l[1]&&(t.title=l[1]),t.range={min:parseFloat(l[2]),max:parseFloat(l[3])};continue}let u=e.match(/^y-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(u){u[1]&&(n.title=u[1]),n.range={min:parseFloat(u[2]),max:parseFloat(u[3])};continue}let d=e.match(/^y-axis\s+"([^"]+)"\s*$/);if(d){n.title=d[1];continue}let f=e.match(/^bar\s+\[([^\]]+)\]/);if(f){r.push({type:`bar`,data:jt(f[1],`bar`,e,o.line)});continue}let p=e.match(/^line\s+\[([^\]]+)\]/);if(p){r.push({type:`line`,data:jt(p[1],`line`,e,o.line)});continue}let m=e.match(/^(x-axis|y-axis|bar|line|title)\b/i);if(m)throw Nt(m[1].toLowerCase(),e,o.line)}if(!n.range&&r.length>0){let e=r.flatMap(e=>e.data),t=Math.min(...e),i=Math.max(...e),a=i-t||1;t-=a*.1,i+=a*.1,t>0&&t<a*.5&&(t=0),n.range={min:t,max:i}}return n.range||={min:0,max:100},{title:i,horizontal:a,xAxis:t,yAxis:n,series:r}}function jt(e,t,n,r){return e.split(`,`).map((e,i)=>{let a=e.trim(),o=parseFloat(a);if(a.length===0||Number.isNaN(o))throw Error(`Line ${r}: Invalid numeric value ${JSON.stringify(a)} at position ${i+1} in "${n}". Every value in a ${t} [...] list must be a number.`);return o})}var Mt={"x-axis":`x-axis [A, B, C] (categories) or x-axis 0 --> 100 (numeric range), either optionally preceded by a quoted title`,"y-axis":`y-axis 0 --> 100 (numeric range) or y-axis "Title" (title only), optionally preceded by a quoted title before a range`,bar:`bar [10, 20, 30] — a comma-separated numeric array in square brackets`,line:`line [10, 20, 30] — a comma-separated numeric array in square brackets`,title:`title "Chart Title" — a double-quoted string`};function Nt(e,t,n){let r=Mt[e]??e;return Error(`Line ${n}: Malformed xychart-beta "${e}" directive: "${t}". Expected: ${r}.`)}var Pt=`#3b82f6`;function Ft(e){let t=e.replace(`#`,``),n=parseInt(t.substring(0,2),16)/255,r=parseInt(t.substring(2,4),16)/255,i=parseInt(t.substring(4,6),16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)return[0,0,s*100];let c=a-o,l=s>.5?c/(2-a-o):c/(a+o),u;return u=a===n?((r-i)/c+(r<i?6:0))/6:a===r?((i-n)/c+2)/6:((n-r)/c+4)/6,[u*360,l*100,s*100]}function It(e,t,n){let r=t/100,i=n/100,a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(e/60%2-1)),s=i-a/2,c,l,u;e<60?(c=a,l=o,u=0):e<120?(c=o,l=a,u=0):e<180?(c=0,l=a,u=o):e<240?(c=0,l=o,u=a):e<300?(c=o,l=0,u=a):(c=a,l=0,u=o);let d=e=>Math.round((e+s)*255).toString(16).padStart(2,`0`);return`#${d(c)}${d(l)}${d(u)}`}function Lt(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function Rt(e){return Ft(e)[2]<50}function zt(e,t,n){if(e===0)return t;let r=Lt(t)?t:Pt,i=n&&Lt(n)?n:void 0,[a,o]=Ft(r),s=Math.max(55,Math.min(85,o)),c=Math.ceil(e/2),l=e%2==1,u=i&&Rt(i)?!l:l,d=u?Math.max(25,48-c*13):Math.min(78,55+c*11);return It(((a+(u?-8:12)*c)%360+360)%360,s,d)}var Bt={rect:`rectangle`,rectangle:`rectangle`,proc:`rectangle`,process:`rectangle`,"normal-rect":`rectangle`,rounded:`rounded`,event:`rounded`,"rounded-rect":`rounded`,stadium:`stadium`,pill:`stadium`,terminal:`stadium`,subproc:`subroutine`,subprocess:`subroutine`,subroutine:`subroutine`,"framed-rectangle":`subroutine`,"fr-rect":`subroutine`,cyl:`cylinder`,cylinder:`cylinder`,db:`cylinder`,database:`cylinder`,"h-cyl":`cylinder`,das:`cylinder`,"horizontal-cylinder":`cylinder`,"lin-cyl":`cylinder`,"lined-cylinder":`cylinder`,disk:`cylinder`,circ:`circle`,circle:`circle`,start:`circle`,"dbl-circ":`doublecircle`,"double-circle":`doublecircle`,stop:`doublecircle`,"f-circ":`filled-circle`,"filled-circle":`filled-circle`,junction:`filled-circle`,"cross-circ":`crossed-circle`,"crossed-circle":`crossed-circle`,summary:`crossed-circle`,diam:`diamond`,diamond:`diamond`,decision:`diamond`,question:`diamond`,hex:`hexagon`,hexagon:`hexagon`,prepare:`hexagon`,odd:`asymmetric`,"rect-left-inv-arrow":`asymmetric`,"lean-r":`parallelogram`,"lean-right":`parallelogram`,"in-out":`parallelogram`,"lean-l":`parallelogram-alt`,"lean-left":`parallelogram-alt`,"out-in":`parallelogram-alt`,"trap-b":`trapezoid`,"trapezoid-bottom":`trapezoid`,priority:`trapezoid`,"trap-t":`trapezoid-alt`,"trapezoid-top":`trapezoid-alt`,manual:`trapezoid-alt`,"curv-trap":`trapezoid-alt`,"curved-trapezoid":`trapezoid-alt`,display:`trapezoid-alt`,doc:`document`,document:`document`,"lin-doc":`document`,"lined-document":`document`,"tag-doc":`document`,"tagged-document":`document`,docs:`stacked-document`,documents:`stacked-document`,"st-doc":`stacked-document`,"stacked-document":`stacked-document`,"notch-rect":`card`,card:`card`,"notched-rectangle":`card`,"lin-rect":`lined-process`,"lined-rectangle":`lined-process`,"lin-proc":`lined-process`,"shaded-process":`lined-process`,"div-rect":`divided-process`,"divided-rectangle":`divided-process`,"div-proc":`divided-process`,"tag-rect":`rectangle`,"tagged-rectangle":`rectangle`,"tag-proc":`rectangle`,procs:`stacked-process`,processes:`stacked-process`,"st-rect":`stacked-process`,"stacked-rectangle":`stacked-process`,tri:`triangle`,triangle:`triangle`,extract:`triangle`,"flip-tri":`flipped-triangle`,"flipped-triangle":`flipped-triangle`,"manual-file":`flipped-triangle`,"win-pane":`window-pane`,"window-pane":`window-pane`,"internal-storage":`window-pane`,fork:`fork-join`,join:`fork-join`,"long-rect":`fork-join`,"notch-pent":`notched-pentagon`,"loop-limit":`notched-pentagon`,"notched-pentagon":`notched-pentagon`,"sl-rect":`sloped-rectangle`,"sloped-rectangle":`sloped-rectangle`,"manual-input":`sloped-rectangle`,flag:`flag`,"paper-tape":`flag`,"bow-rect":`bow-tie-rectangle`,"bow-tie-rectangle":`bow-tie-rectangle`,"stored-data":`bow-tie-rectangle`,delay:`half-rounded-rectangle`,"half-rounded-rectangle":`half-rounded-rectangle`,brace:`brace`,"brace-l":`brace`,comment:`brace`,"brace-r":`brace-right`,braces:`braces`,bolt:`bolt`,"com-link":`bolt`,"lightning-bolt":`bolt`,text:`text`,anchor:`anchor`};function Vt(e){return Bt[e.trim().toLowerCase()]}function Ht(e){let t={};for(let n of Ut(e,`,`)){let e=n.trim();if(e.length===0)continue;let r=Wt(e,`:`);if(r===-1){t.shape??=Gt(e);continue}let i=e.slice(0,r).trim().toLowerCase(),a=Gt(e.slice(r+1).trim());i.length>0&&(t[i]=a)}return t}function Ut(e,t){let n=[],r=``,i=null;for(let a of e){if(i!==null){r+=a,a===i&&(i=null);continue}if(a===`"`||a===`'`){i=a,r+=a;continue}if(a===t){n.push(r),r=``;continue}r+=a}return n.push(r),n}function Wt(e,t){let n=null;for(let r=0;r<e.length;r++){let i=e[r];if(n!==null){i===n&&(n=null);continue}if(i===`"`||i===`'`){n=i;continue}if(i===t)return r}return-1}function Gt(e){return e.length>=2&&(e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))?e.slice(1,-1):e}function Kt(e){if(!e.startsWith(`@{`))return;let t=0,n=null;for(let r=1;r<e.length;r++){let i=e[r];if(n!==null){i===n&&(n=null);continue}if(i===`"`||i===`'`){n=i;continue}if(i===`{`){t++;continue}if(i===`}`&&(t--,t===0))return{body:e.slice(2,r),length:r+1}}}function qt(e){let t=e.trim();return t.length>=2&&(t[0]===`"`&&t[t.length-1]===`"`||t[0]===`'`&&t[t.length-1]===`'`)?t.slice(1,-1):t}var Jt=`"graph <dir>"/"flowchart <dir>" (dir: TD, TB, LR, BT, RL), "stateDiagram-v2", "sequenceDiagram", "classDiagram", "erDiagram", "xychart-beta"`;function Yt(e){let t=e.trim().toLowerCase();if(/^sequence/.test(t))return`sequenceDiagram`;if(/^class/.test(t))return`classDiagram`;if(/^er/.test(t))return`erDiagram`;if(/^xychart/.test(t))return`xychart-beta`;if(/^state/.test(t))return`stateDiagram-v2`}var Xt=/^(?:[\w-]+@)?<?(?:-{2,}|={2,}|-\.+-?|~{3,})/;function Zt(e){let t=[];for(let n of e)n.forEach((e,n)=>{if(n===0&&t.length>0&&Xt.test(e.text)){let n=t[t.length-1];t[t.length-1]={text:`${n.text} ${e.text}`,line:n.line}}else t.push(e)});return t}function Qt(e){let t=re(e.split(`
|
|
22
|
+
`).map(e=>e.trim())),n=Zt(E(e));if(n.length===0)throw Error(`Empty mermaid diagram`);let r=n[0],i=/^stateDiagram(-v2)?\s*$/i.test(r.text)?en(n):$t(n);return i.initConfig=t,i}function $t(e){let t=e[0];if(t===void 0)throw Error(`parseFlowchart called with no lines`);let n=t.text,r=n.match(/^(?:graph|flowchart)\s+(TD|TB|LR|BT|RL)\s*$/i);if(!r){let e=n.match(/^(?:graph|flowchart)\b\s*(.*)$/i);if(e){let r=e[1].trim();throw Error(r.length>0?`Line ${t.line}: Invalid direction "${r}" in header "${n}". Expected one of: TD, TB, LR, BT, RL.`:`Line ${t.line}: Missing direction in header "${n}". Expected e.g. "graph TD" or "flowchart LR" — one of: TD, TB, LR, BT, RL.`)}let r=Yt(n),i=r&&r.toLowerCase()!==n.trim().toLowerCase()?` Did you mean "${r}"?`:``;throw Error(`Line ${t.line}: Invalid mermaid header: "${n}".${i} Supported headers: ${Jt}.`)}let i={direction:A(r[1]),nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map,interactions:new Map},a=[];for(let t=1;t<e.length;t++){let n=e[t].text;if(ke(n,i)||Ae(n,i)||Me(n,i))continue;if(/^click\s+/i.test(n)){pn(n,i);continue}if(hn(n,i))continue;let r=n.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);if(r){let e=r[1].trim(),t=Oe(r[2]);if(e==="default")i.linkStyles.set(`default`,{...i.linkStyles.get(`default`),...t});else{let n=e.split(`,`).map(e=>parseInt(e.trim(),10));for(let e of n)isNaN(e)||i.linkStyles.set(e,{...i.linkStyles.get(e),...t})}continue}let o=n.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(o&&a.length>0){a[a.length-1].direction=A(o[1]);continue}let s=n.match(/^subgraph\s+(.+)$/);if(s){let e=s[1].trim(),t=e.match(/^([^\s[]+)\s*\[(.+)\]$/),n,r;t?(n=t[1],r=L(qt(t[2]))):(r=L(qt(e)),n=r.replace(/\s+/g,`_`).replace(/[^\p{L}\p{N}_-]/gu,``));let i={id:n,label:r,nodeIds:[],children:[]};a.push(i);continue}if(n===`end`){let e=a.pop();e&&(a.length>0?a[a.length-1].children.push(e):i.subgraphs.push(e));continue}yn(n,i,a)}return i}function en(e){let t={direction:`TD`,nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map,interactions:new Map},n=[],r=new Set,i=0,a=0;for(let o=1;o<e.length;o++){let s=e[o].text,c=s.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(c){n.length>0?n[n.length-1].direction=A(c[1]):t.direction=A(c[1]);continue}let l=s.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);if(l){let e=l[1].trim(),n=Oe(l[2]);if(e==="default")t.linkStyles.set(`default`,{...t.linkStyles.get(`default`),...n});else{let r=e.split(`,`).map(e=>parseInt(e.trim(),10));for(let e of r)isNaN(e)||t.linkStyles.set(e,{...t.linkStyles.get(e),...n})}continue}if(hn(s,t))continue;let u=s.match(/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}]+)\s*\{$/u);if(u){let e=u[1]??u[2],i=u[2],a={id:i,label:e,nodeIds:[],children:[]};n.push(a),r.add(i),t.nodes.delete(i);continue}if(s===`}`){let e=n.pop();e&&(n.length>0?n[n.length-1].children.push(e):t.subgraphs.push(e));continue}let d=s.match(/^state\s+"([^"]+)"\s+as\s+([\w\p{L}]+)\s*$/u);if(d){let e=L(d[1]),r=d[2];tn(t,n,{id:r,label:e,shape:`rounded`});continue}let f=s.match(/^(\[\*\]|[\w\p{L}-]+)\s*(?:([\w-]+)@)?-->\s*(\[\*\]|[\w\p{L}-]+)(?:\s*:\s*(.+))?$/u);if(f){let e=f[1],o=f[2],s=f[3],c=f[4]?.trim(),l=c?L(c):void 0;e===`[*]`?(i++,e=`_start${i>1?i:``}`,tn(t,n,{id:e,label:``,shape:`state-start`})):r.has(e)||nn(t,n,e),s===`[*]`?(a++,s=`_end${a>1?a:``}`,tn(t,n,{id:s,label:``,shape:`state-end`})):r.has(s)||nn(t,n,s),t.edges.push({source:e,target:s,label:l,style:`solid`,hasArrowStart:!1,hasArrowEnd:!0,...o===void 0?{}:{id:o}});continue}let p=s.match(/^([\w\p{L}-]+)\s*:\s*(.+)$/u);if(p){let e=p[1];tn(t,n,{id:e,label:L(p[2].trim()),shape:`rounded`});continue}}return t}function tn(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 nn(e,t,n){if(!e.nodes.has(n))tn(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)}}var rn=/^(<|o|x)?(-{2,}|={2,}|-\.+-|~{3,})(>|o|x)?(?:\|([^|]*)\|)?/,an=new Set([`--`,`==`]);function on(e){if(e===`o`)return`circle`;if(e===`x`)return`cross`}var sn=/^(<|o|x)?(--|-\.|==)\s+(.+?)\s+(-{2,}[>ox]|={2,}[>ox]|\.+-[>ox]|-{3,}|={3,}|-\.+-)/,cn=[{regex:/^([\w\p{L}-]+)\(\(\(((?:"[^"]*"|(?!\)\)\)).)+)\)\)\)/u,shape:`doublecircle`},{regex:/^([\w\p{L}-]+)\(\[((?:"[^"]*"|(?!\]\)).)+)\]\)/u,shape:`stadium`},{regex:/^([\w\p{L}-]+)\(\(((?:"[^"]*"|(?!\)\)).)+)\)\)/u,shape:`circle`},{regex:/^([\w\p{L}-]+)\[\[((?:"[^"]*"|(?!\]\]).)+)\]\]/u,shape:`subroutine`},{regex:/^([\w\p{L}-]+)\[\(((?:"[^"]*"|(?!\)\]).)+)\)\]/u,shape:`cylinder`},{regex:/^([\w\p{L}-]+)\[\/((?:"[^"]*"|(?![\\/]\]).)+)([\\/])\]/u,shape:e=>e===`\\`?`trapezoid`:`parallelogram`},{regex:/^([\w\p{L}-]+)\[\\((?:"[^"]*"|(?![\\/]\]).)+)([\\/])\]/u,shape:e=>e===`/`?`trapezoid-alt`:`parallelogram-alt`},{regex:/^([\w\p{L}-]+)>((?:"[^"]*"|(?!\]).)+)\]/u,shape:`asymmetric`},{regex:/^([\w\p{L}-]+)\{\{((?:"[^"]*"|(?!\}\}).)+)\}\}/u,shape:`hexagon`},{regex:/^([\w\p{L}-]+)\[((?:"[^"]*"|(?!\]).)+)\]/u,shape:`rectangle`},{regex:/^([\w\p{L}-]+)\(((?:"[^"]*"|(?!\)).)+)\)/u,shape:`rounded`},{regex:/^([\w\p{L}-]+)\{((?:"[^"]*"|(?!\}).)+)\}/u,shape:`diamond`}],ln=/^([\w\p{L}]+(?:-[\w\p{L}]+)*)/u,un=/^([\w\p{L}-]+)(?=@\{)/u;function dn(e){if(e.shape)return Vt(e.shape)??`rectangle`;if(e.icon!==void 0||e.img!==void 0)switch(e.form?.toLowerCase()){case`circle`:return`circle`;case`rounded`:return`rounded`;default:return`rectangle`}return`rectangle`}function fn(e,t){return t.label!==void 0&&t.label.length>0?t.label:t.icon?t.icon:t.img?t.img:e}function pn(e,t){u(e,t.interactions)}var mn=/^([\w-]+)(?=@\{)/;function hn(e,t){let n=e.match(mn);if(!n||!t.edges.some(e=>e.id===n[1]))return!1;let r=Kt(e.slice(n[1].length));return r?(gn(t,n[1],Ht(r.body)),!0):!1}function gn(e,t,n){for(let r of e.edges)r.id===t&&(n.animate!==void 0&&(r.animate=n.animate.toLowerCase()!==`false`),n.animation!==void 0&&(r.animate=!0))}var _n=/^:::([\w][\w-]*)/,vn=/^([\w\p{L}-]+):::([\w][\w-]*)/u;function yn(e,t,n){let r=e.trim(),i=bn(r,t,n);if(!i||i.ids.length===0)return;r=i.remaining.trim();let a=i.ids;for(;r.length>0;){let e,i,o,s,c,l,u,d=r.match(/^([\w-]+)@(?=[-=<~ox])/);d&&(u=d[1],r=r.slice(d[0].length));let f=r.match(rn),p=f?.[2],m=f?.[1],h=f?.[3];if(f&&p!==void 0&&!(m===void 0&&h===void 0&&an.has(p))){e=m!==void 0,c=on(m);let t=f[4]?.trim();s=t?L(t):void 0,r=r.slice(f[0].length).trim(),i=wn(p),o=h!==void 0,l=on(h)}else{let t=r.match(sn);if(!t)break;e=!!t[1],c=on(t[1]);let n=t[3].trim();s=n?L(n):void 0;let a=t[2],u=t[4];r=r.slice(t[0].length).trim(),i=Tn(a,u),l=on(u.slice(-1)),o=u.endsWith(`>`)||l!==void 0}let g=bn(r,t,n);if(!g||g.ids.length===0)break;r=g.remaining.trim();for(let n of a)for(let r of g.ids)t.edges.push({source:n,target:r,label:s,style:i,hasArrowStart:e,hasArrowEnd:o,...c===void 0?{}:{startMarker:c},...l===void 0?{}:{endMarker:l},...u===void 0?{}:{id:u}});a=g.ids}}function bn(e,t,n){let r=xn(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=xn(a,t,n);if(!e)break;i.push(e.id),a=e.remaining.trim()}return{ids:i,remaining:a}}function xn(e,t,n){let r=null,i=e,a,o=i.match(vn);o&&(a=o[2],i=o[1]+i.slice(o[0].length));let s=i.match(un);if(s){let e=s[1],a=Kt(i.slice(e.length));if(a){let o=Ht(a.body);Sn(t,n,{id:e,label:L(fn(e,o)),shape:dn(o)}),r=e,i=i.slice(e.length+a.length)}}if(r===null)for(let{regex:e,shape:a}of cn){let o=i.match(e);if(o){r=o[1];let e=L(o[2]),s=typeof a==`function`?a(o[3]??``):a;Sn(t,n,{id:r,label:e,shape:s}),i=i.slice(o[0].length);break}}if(r===null){let e=i.match(ln);e&&(r=e[1],t.nodes.has(r)||Sn(t,n,{id:r,label:r,shape:`rectangle`}),i=i.slice(e[0].length))}if(r===null)return null;a&&t.classAssignments.set(r,a);let c=i.match(_n);return c&&(t.classAssignments.set(r,c[1]),i=i.slice(c[0].length)),{id:r,remaining:i}}function Sn(e,t,n){e.nodes.has(n.id)||e.nodes.set(n.id,n),Cn(t,n.id)}function Cn(e,t){if(e.length>0){let n=e[e.length-1];n.nodeIds.includes(t)||n.nodeIds.push(t)}}function wn(e){return e.startsWith(`~`)?`invisible`:e.includes(`.`)?`dotted`:e.startsWith(`=`)?`thick`:`solid`}function Tn(e,t){return e.includes(`.`)||t.includes(`.`)?`dotted`:e.startsWith(`=`)||t.startsWith(`=`)?`thick`:`solid`}function En(e){return`M ${e.x} ${e.y}`}function Dn(e){return En(e[0])+e.slice(1).map(e=>` L ${e.x} ${e.y}`).join(``)}function On(e){if(e.length<3)return Dn(e);let t=e[e.length-1],n=[En(e[0])],r=(e,t,n)=>` C ${(2*e.x+t.x)/3} ${(2*e.y+t.y)/3}, ${(e.x+2*t.x)/3} ${(e.y+2*t.y)/3}, ${(e.x+4*t.x+n.x)/6} ${(e.y+4*t.y+n.y)/6}`;n.push(` L ${(5*e[0].x+e[1].x)/6} ${(5*e[0].y+e[1].y)/6}`);for(let t=2;t<e.length;t++)n.push(r(e[t-2],e[t-1],e[t]));return n.push(r(e[e.length-2],t,t)),n.push(` L ${t.x} ${t.y}`),n.join(``)}function kn(e){if(e.length<3)return Dn(e);let t=[En(e[0])];for(let n=1;n<e.length-1;n++){let r=e[n-1],i=e[n],a=e[n+1],o=Math.hypot(i.x-r.x,i.y-r.y),s=Math.hypot(a.x-i.x,a.y-i.y);if(o===0||s===0){t.push(` L ${i.x} ${i.y}`);continue}let c=Math.min(12,o/2,s/2),l=i.x-(i.x-r.x)/o*c,u=i.y-(i.y-r.y)/o*c,d=i.x+(a.x-i.x)/s*c,f=i.y+(a.y-i.y)/s*c;t.push(` L ${l} ${u}`),t.push(` Q ${i.x} ${i.y}, ${d} ${f}`)}let n=e[e.length-1];return t.push(` L ${n.x} ${n.y}`),t.join(``)}function An(e,t){let n=[En(e[0])],r=e.length-1;for(let i=0;i<r;i++){let a=e[i],o=e[i+1];if(i===r-1){n.push(` L ${o.x} ${o.y}`);break}if(t===`before`)n.push(` L ${a.x} ${o.y} L ${o.x} ${o.y}`);else if(t===`after`)n.push(` L ${o.x} ${a.y} L ${o.x} ${o.y}`);else{let e=(a.y+o.y)/2;n.push(` L ${a.x} ${e} L ${o.x} ${e} L ${o.x} ${o.y}`)}}return n.join(``)}function jn(e,t=`linear`){if(e.length===0)return``;if(e.length===1)return En(e[0]);switch(t){case`basis`:return On(e);case`natural`:return kn(e);case`step`:return An(e,`mid`);case`stepBefore`:return An(e,`before`);case`stepAfter`:return An(e,`after`);default:return Dn(e)}}var Mn=null,Nn=null,Pn=20;function Fn(e=Pn){if(!Number.isInteger(e)||e<1)throw Error(`createLayoutCache: maxSize must be a positive integer, got ${e}`);return{map:new Map,maxSize:e}}function In(e){if(Array.isArray(e))return`[${e.map(In).join(`,`)}]`;if(typeof e==`object`&&e){let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${In(t[e])}`).join(`,`)}}`}return JSON.stringify(e)}function Ln(){if(Mn&&Nn)return Nn;let e=[],t=globalThis.setTimeout;globalThis.setTimeout=(n,r)=>r===0?(e.push(n),0):t(n,r);let n=globalThis,r=`self`in n,i=n.self;if(r&&n.document===void 0&&delete n.self,Mn=new c.default,!Mn)throw Error(`ELKBundled construction unexpectedly produced no instance`);return r&&(n.self=i),globalThis.setTimeout=t,e.forEach(e=>e()),Nn=Mn.worker.worker,Nn}function Rn(e,t){let n=t,r=n?In(e):void 0;if(n&&r!==void 0){let e=n.map.get(r);if(e)return n.map.delete(r),n.map.set(r,e),e}let i=Ln(),a,o,s=i.onmessage;if(i.onmessage=e=>{e.data.error?o=e.data.error:a=e.data.data},i.dispatcher.saveDispatch({data:{id:0,cmd:`layout`,graph:e}}),i.onmessage=s,o)throw o;if(!a)throw Error(`ELK layout did not return synchronously`);if(n&&r!==void 0&&(n.map.set(r,a),n.map.size>n.maxSize)){let e=n.map.keys().next().value;e!==void 0&&n.map.delete(e)}return a}function zn(e,t,n){return ye(e,t,n)}function Bn(e,t){return e.length*t*.6}var Vn={nodeLabel:13,edgeLabel:11,groupHeader:12};function Hn(e){return{nodeLabel:e?.nodeLabel??Vn.nodeLabel,edgeLabel:e?.edgeLabel??Vn.edgeLabel,groupHeader:e?.groupHeader??Vn.groupHeader}}var B={nodeLabel:500,edgeLabel:400,groupHeader:600},Un={horizontal:20,vertical:10,diamondExtra:24},V={outerBox:1,innerBox:.75,connector:1},Wn=`0.35em`,Gn={width:8,height:5},Kn={font:`Inter`,padding:40,nodeSpacing:28,layerSpacing:48,mergeEdges:!0,thoroughness:3,fontSizes:Vn},qn={flowchart:`DOWN`,state:`DOWN`,class:`DOWN`,er:`RIGHT`};function Jn(e,t){switch(e){case`LR`:return`RIGHT`;case`RL`:return`LEFT`;case`BT`:return`UP`;case`TD`:case`TB`:return`DOWN`;default:return t}}function Yn(e){let t=typeof e==`number`?{top:e,left:e,bottom:e,right:e}:e;return`[top=${t.top},left=${t.left},bottom=${t.bottom},right=${t.right}]`}function Xn(e){return{"elk.algorithm":`layered`,"elk.direction":e.direction,"elk.spacing.nodeNode":String(e.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(e.layerSpacing),"elk.padding":Yn(e.padding),"elk.edgeRouting":`ORTHOGONAL`}}function Zn(e,t,n){let r={id:e,width:t.width,height:t.height};return n!==void 0&&(r.labels=[{text:n}]),r}var Qn={"elk.edgeLabels.inline":`true`,"elk.edgeLabels.placement":`CENTER`};function $n(e,t){let n=I(e,t.fontSize,B.edgeLabel),r={text:e,width:n.width+8,height:n.height+6};return t.layoutOptions&&(r.layoutOptions={...t.layoutOptions}),r}function er(e){let t={id:e.id,sources:[e.source],targets:[e.target]};return e.label&&(t.labels=[$n(e.label,e.labelStyle)]),t}function tr(e){return Jn(e,qn.flowchart)}function nr(e){return{...Xn(e),"elk.spacing.edgeEdge":`12`,"elk.layered.spacing.edgeEdgeBetweenLayers":`12`,"elk.layered.spacing.edgeNodeBetweenLayers":`12`,"elk.layered.nodePlacement.bk.fixedAlignment":`BALANCED`,"elk.contentAlignment":`H_CENTER V_CENTER`}}function rr(e){return{fontSize:e.fontSizes.edgeLabel,layoutOptions:Qn}}function ir(e,t,n,r){let i=I(t,r,B.nodeLabel),a=i.width+Un.horizontal*2,o=i.height+Un.vertical*2;if(n===`diamond`){let e=Math.max(a,o)+Un.diamondExtra;a=e,o=e}if(n===`circle`||n===`doublecircle`){let e=Math.ceil(Math.sqrt(a*a+o*o))+8;a=n===`doublecircle`?e+12:e,o=a}return n===`hexagon`&&(a+=Un.horizontal),(n===`trapezoid`||n===`trapezoid-alt`||n===`parallelogram`||n===`parallelogram-alt`)&&(a+=Un.horizontal),n===`asymmetric`&&(a+=12),n===`cylinder`&&(o+=14),n===`state-start`||n===`state-end`?{width:28,height:28}:(a=Math.max(a,60),o=Math.max(o,36),{width:a,height:o})}var ar=` root`;function or(e){for(let t of e)if(t.direction!==void 0||or(t.children))return!0;return!1}function sr(e,t){for(let n of e.nodeIds)t.add(n);for(let n of e.children)sr(n,t)}function cr(e,t){let n=new Set;if(sr(e,n),n.size===0)return!0;let r=t=>n.has(t)||t===e.id;return!t.edges.some(e=>r(e.source)!==r(e.target))}function lr(e){let t=new Map;function n(e,r){let i=[...r,e.id];t.set(e.id,i);for(let t of e.children)n(t,i)}for(let t of e)n(t,[]);return t}function ur(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function dr(e,t){let n=new Set,r=new Set;for(let t of e.subgraphs)r.add(t.id),pr(t,n,r);let i=mr(e.subgraphs),a=lr(e.subgraphs),o=e=>e?a.get(e)??[]:[],s=new Map;s.set(null,[]);let c=[];for(let t=0;t<e.edges.length;t++){let n=e.edges[t],r=i.get(n.source),a=i.get(n.target);if(r&&r===a){let e=s.get(r)??[];s.set(r,e),e.push({index:t,edge:n})}else!r&&!a?s.get(null).push({index:t,edge:n}):c.push({index:t,edge:n,srcChain:o(r),tgtChain:o(a)})}let l=or(e.subgraphs),u=[],d=[],f={...nr({direction:tr(e.direction),nodeSpacing:t.nodeSpacing,layerSpacing:t.layerSpacing,padding:t.padding}),"elk.layered.thoroughness":String(Kn.thoroughness),"elk.layered.highDegreeNodes.treatment":`true`,"elk.layered.highDegreeNodes.threshold":`8`,"elk.layered.compaction.postCompaction.strategy":`LEFT_RIGHT_CONSTRAINT_LOCKING`,"elk.layered.considerModelOrder.strategy":`NODES_AND_EDGES`,"elk.layered.wrapping.strategy":`OFF`,"elk.hierarchyHandling":l?`SEPARATE`:`INCLUDE_CHILDREN`},p=new Map,m=new Map;function h(e,t){let n=p.get(e)??new Set;p.set(e,n),n.add(t)}function g(e,t){let n=m.get(e)??[];m.set(e,n),n.push(t)}if(l)for(let{index:e,edge:n,srcChain:r,tgtChain:i}of c){let a=ur(r,i),o=n.source;if(r.length>a){for(let t=r.length-1;t>=a;t--){let i=r[t],a=`${i}_out_${e}`;h(i,a);let o=t===r.length-1?n.source:`${r[t+1]}_out_${e}`;g(i,{id:`e${e}_s${t}`,sources:[o],targets:[a]})}o=`${r[a]}_out_${e}`}let s=n.target;if(i.length>a){for(let t=a;t<=i.length-1;t++){let r=i[t],a=`${r}_in_${e}`;h(r,a);let o=t===i.length-1?n.target:`${i[t+1]}_in_${e}`;g(r,{id:`e${e}_t${t}`,sources:[a],targets:[o]})}s=`${i[a]}_in_${e}`}g(a>0?r[a-1]:ar,er({id:`e${e}`,source:o,target:s,label:n.label,labelStyle:rr(t)}))}for(let[i,a]of e.nodes)if(!n.has(i)&&!r.has(i)){let e=ir(i,a.label,a.shape,t.fontSizes.nodeLabel);u.push(Zn(i,e,a.label))}for(let n of[...e.subgraphs].reverse())u.push(fr(n,e,t,s,p,m,e.direction));for(let{index:e,edge:n}of s.get(null))n.source!==n.target&&d.push(er({id:`e${e}`,source:n.source,target:n.target,label:n.label,labelStyle:rr(t)}));if(l)for(let e of m.get(ar)??[])d.push(e);else for(let{index:e,edge:n}of c)d.push(er({id:`e${e}`,source:n.source,target:n.target,label:n.label,labelStyle:rr(t)}));return{id:`root`,layoutOptions:f,children:u,edges:d}}function fr(e,t,n,r,i,a,o){let s=e.direction!==void 0&&cr(e,t)?e.direction:o,c=nr({direction:tr(s),nodeSpacing:n.nodeSpacing,layerSpacing:n.layerSpacing,padding:{top:44,left:16,bottom:16,right:16}}),l,u=i.get(e.id);u&&u.size>0&&(l=[...u].map(e=>({id:e})));let d=[];for(let r of e.nodeIds){let e=t.nodes.get(r);if(e){let t=ir(r,e.label,e.shape,n.fontSizes.nodeLabel);d.push(Zn(r,t,e.label))}}for(let o of[...e.children].reverse())d.push(fr(o,t,n,r,i,a,s));let f=[],p=r.get(e.id)??[];for(let{index:e,edge:t}of p)t.source!==t.target&&f.push(er({id:`e${e}`,source:t.source,target:t.target,label:t.label,labelStyle:rr(n)}));for(let t of a.get(e.id)??[])f.push(t);return{id:e.id,layoutOptions:c,labels:e.label?[{text:e.label}]:void 0,ports:l,children:d,edges:f}}function pr(e,t,n){for(let n of e.nodeIds)t.add(n);for(let r of e.children)n.add(r.id),pr(r,t,n)}function mr(e){let t=new Map;function n(e){for(let n of e.nodeIds)t.set(n,e.id);for(let t of e.children)n(t)}for(let t of e)n(t);return t}function hr(e,t,n){if(e.length<2||t.shape===`rectangle`||t.shape===`rounded`||t.shape===`stadium`)return e;let r=[...e];if(t.shape===`diamond`){if(n)r[0]=gr(e[0],e[1],t);else{let n=e.length-1;r[n]=gr(e[n],e[n-1],t)}}return r}function gr(e,t,n){let r=n.x+n.width/2,i=n.y+n.height/2,a={x:r,y:n.y},o={x:n.x+n.width,y:i},s={x:r,y:n.y+n.height},c={x:n.x,y:i},l=e.x-t.x,u=e.y-t.y;if(Math.abs(l)<Math.abs(u)){let t=e.x;return u>0?t<=r?vr(t,c,a)??a:vr(t,a,o)??a:t<=r?vr(t,s,c)??s:vr(t,o,s)??s}{let t=e.y;return l>0?t<=i?_r(t,a,c)??c:_r(t,c,s)??c:t<=i?_r(t,a,o)??o:_r(t,o,s)??o}}function _r(e,t,n){let r=n.y-t.y;if(Math.abs(r)<.001)return null;let i=(e-t.y)/r;return i<0||i>1?null:{x:t.x+i*(n.x-t.x),y:e}}function vr(e,t,n){let r=n.x-t.x;if(Math.abs(r)<.001)return null;let i=(e-t.x)/r;return i<0||i>1?null:{x:e,y:t.y+i*(n.y-t.y)}}function yr(e,t,n){if(e.length===0)return;let r=n===`LR`||n===`RL`,i=new Set;for(let e of t)i.add(`${e.source}:${e.target}`),i.add(`${e.target}:${e.source}`);let a=Kn.layerSpacing*.6,o=[...e].sort((e,t)=>r?e.x-t.x:e.y-t.y),s=[],c=[o[0]];for(let e=1;e<o.length;e++){let t=(r?o[e].x:o[e].y)-(r?o[e-1].x:o[e-1].y),n=c.some(t=>i.has(`${t.id}:${o[e].id}`));t<=a&&!n?c.push(o[e]):(s.push(c),c=[o[e]])}s.push(c);let l=new Map;for(let e of s){if(e.length<=1)continue;let t=e.map(e=>r?e.x:e.y),n=Math.min(...t),i=Math.max(...t);if(i-n<=1)continue;let a=(n+i)/2;for(let t of e){let e=a-(r?t.x:t.y);Math.abs(e)>.5&&(r?t.x=a:t.y=a,l.set(t.id,e))}}if(l.size!==0)for(let e of t){if(e.points.length<2)continue;let t=l.get(e.source),n=l.get(e.target);if(t!=null){let n=e.points[0];r?(n.x+=t,e.points.length>1&&e.points[1].x===n.x-t&&(e.points[1].x+=t)):(n.y+=t,e.points.length>1&&e.points[1].y===n.y-t&&(e.points[1].y+=t))}if(n!=null){let t=e.points[e.points.length-1];if(r){if(t.x+=n,e.points.length>1){let r=e.points[e.points.length-2];r.x===t.x-n&&(r.x+=n)}}else if(t.y+=n,e.points.length>1){let r=e.points[e.points.length-2];r.y===t.y-n&&(r.y+=n)}}}}var br=.5;function xr(e,t,n){for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1],o=Math.min(i.x,a.x),s=Math.max(i.x,a.x),c=Math.min(i.y,a.y),l=Math.max(i.y,a.y);for(let e of t){if(n.has(e.id))continue;let t=e.x+br,r=e.x+e.width-br,i=e.y+br,a=e.y+e.height-br;if(!(t>=r||i>=a)&&o<r&&s>t&&c<a&&l>i)return!1}}return!0}function Sr(e,t,n){let r=[];for(let i of n)e>=i.x&&e<=i.x+i.width&&t>=i.y&&t<=i.y+i.height&&(r.push(i),r.push(...Sr(e,t,i.children)));return r}function Cr(e,t,n,r,i){let a=i===`LR`,o=i===`RL`,s=i===`BT`,c=a||o,l=new Set(Sr(t,n,r).map(e=>e.id)),u=Sr(c?e:t,c?n:e,r).find(e=>!l.has(e.id));return u?a?u.x-12:o?u.x+u.width+12:s?u.y+u.height+12:u.y-12:e}function wr(e,t,n,r){let i=new Map(t.map(e=>[e.id,e])),a=new Set,o=r===`LR`,s=r===`RL`,c=r===`BT`,l=o||s,u=new Map;for(let t of e){if(t.source===t.target)continue;let e=u.get(t.source)??[];u.set(t.source,e),e.push(t)}for(let[e,d]of u){if(d.length<2)continue;let u=d[0].style;if(d.some(e=>e.label||e.style!==u))continue;let f=i.get(e);if(!f)continue;let p=[];for(let e of d){let t=i.get(e.target);t&&(o?t.x>f.x+f.width:s?t.x+t.width<f.x:c?t.y+t.height<f.y:t.y>f.y+f.height)&&p.push({edge:e,node:t})}if(p.length<2)continue;let m=f.x+f.width/2,h=f.y+f.height/2;if(l){let i=o?f.x+f.width:f.x,s=h,c=i+((o?Math.min(...p.map(e=>e.node.x)):Math.max(...p.map(e=>e.node.x+e.node.width)))-i)/2;c=Cr(c,m,h,n,r);let l=[];for(let{edge:n,node:r}of p){let a=o?r.x:r.x+r.width,u=r.y+r.height/2,d=[{x:i,y:s},{x:c,y:s},{x:c,y:u},{x:a,y:u}];xr(d,t,new Set([e,r.id]))&&l.push({edge:n,points:d})}if(l.length<2)continue;for(let{edge:e,points:t}of l)e.points=t,a.add(e)}else{let i=m,o=c?f.y:f.y+f.height,s=o+((c?Math.max(...p.map(e=>e.node.y+e.node.height)):Math.min(...p.map(e=>e.node.y)))-o)/2;s=Cr(s,m,h,n,r);let l=[];for(let{edge:n,node:r}of p){let a=r.x+r.width/2,u=c?r.y+r.height:r.y,d=[{x:i,y:o},{x:i,y:s},{x:a,y:s},{x:a,y:u}];xr(d,t,new Set([e,r.id]))&&l.push({edge:n,points:d})}if(l.length<2)continue;for(let{edge:e,points:t}of l)e.points=t,a.add(e)}}let d=new Map;for(let t of e){if(a.has(t)||t.source===t.target)continue;let e=d.get(t.target)??[];d.set(t.target,e),e.push(t)}for(let[e,a]of d){if(a.length<2)continue;let u=a[0].style;if(a.some(e=>e.label||e.style!==u))continue;let d=i.get(e);if(!d)continue;let f=[];for(let e of a){let t=i.get(e.source);t&&(o?t.x+t.width<d.x:s?t.x>d.x+d.width:c?t.y>d.y+d.height:t.y+t.height<d.y)&&f.push({edge:e,node:t})}if(f.length<2)continue;let p=d.x+d.width/2,m=d.y+d.height/2;if(l){let i=o?d.x:d.x+d.width,a=m,s=o?Math.max(...f.map(e=>e.node.x+e.node.width)):Math.min(...f.map(e=>e.node.x)),c=s+(i-s)/2;c=Cr(c,p,m,n,r);let l=[];for(let{edge:n,node:r}of f){let s=o?r.x+r.width:r.x,u=r.y+r.height/2,d=[{x:s,y:u},{x:c,y:u},{x:c,y:a},{x:i,y:a}];xr(d,t,new Set([r.id,e]))&&l.push({edge:n,points:d})}if(l.length<2)continue;for(let{edge:e,points:t}of l)e.points=t}else{let i=p,a=c?d.y+d.height:d.y,o=c?Math.min(...f.map(e=>e.node.y)):Math.max(...f.map(e=>e.node.y+e.node.height)),s=o+(a-o)/2;s=Cr(s,p,m,n,r);let l=[];for(let{edge:n,node:r}of f){let o=r.x+r.width/2,u=[{x:o,y:c?r.y:r.y+r.height},{x:o,y:s},{x:i,y:s},{x:i,y:a}];xr(u,t,new Set([r.id,e]))&&l.push({edge:n,points:u})}if(l.length<2)continue;for(let{edge:e,points:t}of l)e.points=t}}}function Tr(e,t=0,n=0){let r=[];if(!e.sections||e.sections.length===0)return r;let i=e.sections[0];if(r.push({x:i.startPoint.x+t,y:i.startPoint.y+n}),i.bendPoints)for(let e of i.bendPoints)r.push({x:e.x+t,y:e.y+n});return r.push({x:i.endPoint.x+t,y:i.endPoint.y+n}),r}function Er(e,t=0,n=0){if(!e.labels||e.labels.length===0)return;let r=e.labels[0];if(r.x!=null&&r.y!=null)return{x:r.x+(r.width??0)/2+t,y:r.y+(r.height??0)/2+n}}var Dr=16,Or=28,kr=18,Ar=28,jr=10;function Mr(e,t){let n=e.x+e.width,r=e.y+e.height/2,i=Math.min(Ar,e.height*.6)/2,a=Or+t*kr,o=[];for(let e=0;e<=Dr;e++){let t=Math.PI*e/Dr;o.push({x:n+a*Math.sin(t),y:r-i*Math.cos(t)})}return{points:o,labelPosition:{x:n+a+jr,y:r}}}function Nr(e,t,n){let r=new Map;for(let i=0;i<e.edges.length;i++){let a=e.edges[i];if(a.source!==a.target)continue;let o=t.get(a.source);if(!o)continue;let s=r.get(o.id)??0;r.set(o.id,s+1);let{points:c,labelPosition:l}=Mr(o,s);n.push({source:a.source,target:a.target,label:a.label,style:a.style,hasArrowStart:a.hasArrowStart,hasArrowEnd:a.hasArrowEnd,points:c,labelPosition:a.label?l:void 0,inlineStyle:Wr(i,e),id:a.id,animate:a.animate})}}function Pr(e){let t=[];for(let n of e)t.push({x:n.x,y:n.y,right:n.x+n.width,bottom:n.y+n.height}),t.push(...Pr(n.children));return t}function Fr(e,t,n=!1){let r=[],i=[],a=[],o=new Set;for(let e of t.subgraphs)Ur(e,o);Ir(e,t,o,r,a,0,0);let s=Pr(a);zr(e,t,i,0,0,s.length>0?{leftX:Math.min(...s.map(e=>e.x))-20,rightX:Math.max(...s.map(e=>e.right))+20}:void 0),yr(r,i,t.direction);let c=new Map(r.map(e=>[e.id,e]));Nr(t,c,i),n&&wr(i,r,a,t.direction);for(let e of i){let t=c.get(e.source),n=c.get(e.target);t&&(e.points=hr(e.points,t,!0)),n&&(e.points=hr(e.points,n,!1))}let l=e.width??800,u=e.height??600,d=Gn.width,f=Kn.padding;for(let e of i){for(let t of e.points)l=Math.max(l,t.x+d+f),u=Math.max(u,t.y+d+f);e.labelPosition&&(l=Math.max(l,e.labelPosition.x+60+f),u=Math.max(u,e.labelPosition.y+20+f))}return{width:l,height:u,nodes:r,edges:i,groups:a}}function Ir(e,t,n,r,i,a,o){if(e.children)for(let s of e.children){let e=(s.x??0)+a,c=(s.y??0)+o,l=s.width??0,u=s.height??0;if(n.has(s.id)){let a=[];Ir(s,t,n,r,a,e,c);let o=Hr(t.subgraphs,s.id);i.push({id:s.id,label:o?.label??``,x:e,y:c,width:l,height:u,children:a})}else{let a=t.nodes.get(s.id);if(a){let n=Pe(s.id,t),i=t.classAssignments.get(s.id);r.push({id:s.id,label:a.label,shape:a.shape,x:e,y:c,width:l,height:u,inlineStyle:n,className:i,interaction:t.interactions.get(s.id)})}s.children&&s.children.length>0&&Ir(s,t,n,r,i,e,c)}}}function Lr(e){let t=/^e(\d+)$/.exec(e);if(t)return{edgeIndex:parseInt(t[1],10),role:`bridge`};let n=/^e(\d+)_([st])(\d+)$/.exec(e);if(n)return{edgeIndex:parseInt(n[1],10),role:n[2]===`s`?`source`:`target`,level:parseInt(n[3],10)}}function Rr(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)}let n=t/2;for(let t=1;t<e.length;t++){let r=e[t].x-e[t-1].x,i=e[t].y-e[t-1].y,a=Math.sqrt(r*r+i*i);if(n<=a){let o=n/a;return{x:e[t-1].x+o*r,y:e[t-1].y+o*i}}n-=a}return e[e.length-1]}function zr(e,t,n,r,i,a){let o=new Map;Vr(e,o,0,0);let s=0;for(let[e,r]of o){let i=t.edges[e];if(!i)continue;let o=[],c=e=>{!e||e.points.length===0||(o.length>0?o.push(...e.points.slice(1)):o.push(...e.points))},l=[...r.sourceHops.keys()].sort((e,t)=>t-e);for(let e of l)c(r.sourceHops.get(e));c(r.bridge);let u=[...r.targetHops.keys()].sort((e,t)=>e-t);for(let e of u)c(r.targetHops.get(e));let d;i.label&&o.length>=2&&(d=r.bridge?.labelPosition??Rr(o));let f=Br(o,a,s);f!==o&&s++,i.label&&f!==o&&f.length>=2&&(d=Rr(f)),n.push({source:i.source,target:i.target,label:i.label,style:i.style,hasArrowStart:i.hasArrowStart,hasArrowEnd:i.hasArrowEnd,points:f,labelPosition:d,inlineStyle:Wr(e,t),id:i.id,animate:i.animate})}}function Br(e,t,n=0){if(e.length<2)return e;let r=!1;for(let t=1;t<e.length;t++){let n=Math.abs(e[t].x-e[t-1].x),i=Math.abs(e[t].y-e[t-1].y);if(n>1&&i>1){r=!0;break}}if(!r)return e;let i=[e[0]];for(let r=1;r<e.length;r++){let a=i[i.length-1],o=e[r],s=Math.abs(o.x-a.x),c=Math.abs(o.y-a.y);if(s>1&&c>1){if(t){let e=n%2==0,r=Math.floor(n/2)*12,s=e?t.rightX+r:t.leftX-r;i.push({x:s,y:a.y}),i.push({x:s,y:o.y})}else{let e=(a.y+o.y)/2;i.push({x:a.x,y:e}),i.push({x:o.x,y:e})}}i.push(o)}return i}function Vr(e,t,n,r){if(e.edges)for(let i of e.edges){let e=Lr(i.id);if(!e)continue;let{edgeIndex:a}=e,o=Tr(i,n,r),s=Er(i,n,r),c=t.get(a)??{sourceHops:new Map,targetHops:new Map};t.set(a,c);let l={edgeIndex:a,points:o,labelPosition:s};e.role===`bridge`?c.bridge=l:e.role===`source`?c.sourceHops.set(e.level,l):c.targetHops.set(e.level,l)}if(e.children)for(let i of e.children)Vr(i,t,n+(i.x??0),r+(i.y??0))}function Hr(e,t){for(let n of e){if(n.id===t)return n;let e=Hr(n.children,t);if(e)return e}}function Ur(e,t){t.add(e.id);for(let n of e.children)Ur(n,t)}function Wr(e,t){let n,r=t.linkStyles.get(`default`);r&&(n={...r});let i=t.linkStyles.get(e);return i&&(n=n?{...n,...i}:{...i}),n}function Gr(e,t={}){let n={...Kn,...t,fontSizes:Hn(t.fontSizes)};return Fr(Rn(dr(e,n),t.layoutCache),e,n.mergeEdges)}function Kr(e,t,n=`Inter`,r=!1,i=Vn,a=`linear`,o,s=!0,c=!0,l,u,f={}){let p=[],m=c&&e.nodes.some(e=>!!d(e.interaction?.href));p.push(Ui(Ze(e.width,e.height,t,r,l,u,m,f.styleAttribute),o)),p.push(Ge(n,!1,f.nonce)),s&&e.edges.some(e=>e.animate)&&p.push(qr(f.nonce)),p.push(`<defs>`),p.push(Jr());let h=new Set;for(let t of e.edges)t.inlineStyle?.stroke&&h.add(t.inlineStyle.stroke);for(let e of h)p.push(Yr(e));p.push(`</defs>`);for(let t of e.groups)p.push(Qr(t,n,i));for(let t of e.edges)p.push($r(t,a,s));for(let t of e.edges)t.label&&p.push(ti(t,n,i));for(let t of e.nodes)p.push(ai(t,n,i,c));return p.push(`</svg>`),p.join(`
|
|
23
|
+
`)}function qr(e){return[We(e),` @keyframes zm-edge-dash { to { stroke-dashoffset: -28; } }`,` .edge-animated { animation: zm-edge-dash 1s linear infinite; }`,` @media (prefers-reduced-motion: reduce) {`,` .edge-animated { animation: none; }`,` }`,`</style>`].join(`
|
|
24
|
+
`)}function Jr(){return Xr(`var(--_arrow)`,``)}function Yr(e){return Xr(R(e),`-${Zr(e)}`)}function Xr(e,t){let n=Gn.width,r=Gn.height,i=n-1,a=`fill="${e}" stroke="${e}" stroke-width="0.75" stroke-linejoin="round"`,o=`<polygon points="0 0, ${n} ${r/2}, 0 ${r}" ${a} />`,s=(e,t)=>` <marker id="${e}" markerWidth="${n}" markerHeight="${r}" refX="${i}" refY="${r/2}" orient="${t}">\n ${o}\n </marker>`;return s(`arrowhead${t}`,`auto`)+`
|
|
25
|
+
`+s(`arrowhead-start${t}`,`auto-start-reverse`)}function Zr(e){return e.replace(/[^a-zA-Z0-9]/g,e=>e.charCodeAt(0).toString(16))}function Qr(e,t,n){let r=n.groupHeader+16,i=[];i.push(`<g class="subgraph" data-id="${R(e.id)}" data-label="${R(e.label)}">`),i.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="${V.outerBox}" />`),i.push(` <rect x="${e.x}" y="${e.y}" width="${e.width}" height="${r}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${V.outerBox}" />`),i.push(` `+z(e.label,e.x+12,e.y+r/2,n.groupHeader,`font-size="${n.groupHeader}" font-weight="${B.groupHeader}" fill="var(--_text-sec)"`));for(let r of e.children)i.push(Qr(r,t,n));return i.push(`</g>`),i.join(`
|
|
26
|
+
`)}function $r(e,t,n=!0){if(e.points.length<2)return``;let r=n&&(e.animate??!1),i=t!==`linear`,a=e.style===`invisible`,o=e.style===`dotted`?` stroke-dasharray="4 4"`:``,s=e.style===`thick`?V.connector*2:V.connector,c=a?`none`:R(e.inlineStyle?.stroke??`var(--_line)`),l=R(e.inlineStyle?.[`stroke-width`]??String(s)),u=e.inlineStyle?.stroke?`-${Zr(e.inlineStyle.stroke)}`:``,d=``;a||(e.hasArrowEnd&&(d+=` marker-end="url(#arrowhead${u})"`),e.hasArrowStart&&(d+=` marker-start="url(#arrowhead-start${u})"`));let f=[`class="edge${r?` edge-animated`:``}"`,`data-from="${R(e.source)}"`,`data-to="${R(e.target)}"`,`data-style="${e.style}"`,`data-arrow-start="${e.hasArrowStart}"`,`data-arrow-end="${e.hasArrowEnd}"`];e.label&&f.push(`data-label="${R(e.label)}"`),e.id&&f.push(`data-id="${R(e.id)}"`);let p=r&&!o?` stroke-dasharray="8 6"`:``,m=i?`d="${jn(e.points,t)}"`:`points="${ei(e.points)}"`;return`<${i?`path`:`polyline`} ${f.join(` `)} ${m} fill="none" stroke="${c}" stroke-width="${l}"${o}${p}${d} />`}function ei(e){return e.map(e=>`${e.x},${e.y}`).join(` `)}function ti(e,t,n){if(!e.label)return``;let r=e.label,i=e.labelPosition??ri(e.points),a=I(r,n.edgeLabel,B.edgeLabel),o=De(r,i.x,i.y,a.width,a.height,n.edgeLabel,8,`text-anchor="middle" font-size="${n.edgeLabel}" font-weight="${B.edgeLabel}" fill="var(--_text-sec)"`,`rx="2" ry="2" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="1"`);return`<g class="edge-label" data-from="${R(e.source)}" data-to="${R(e.target)}" data-label="${R(r)}">\n ${o.replace(/\n/g,`
|
|
27
|
+
`)}\n</g>`}function ni(e,t){let n=e[t];if(!n)throw Error(`edgeMidpoint: missing point at index ${t}`);return n}function ri(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+=ii(ni(e,n-1),ni(e,n));let n=t/2;for(let t=1;t<e.length;t++){let r=ni(e,t-1),i=ni(e,t),a=ii(r,i);if(n<=a){let e=n/a;return{x:r.x+e*(i.x-r.x),y:r.y+e*(i.y-r.y)}}n-=a}return e[e.length-1]}function ii(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}function ai(e,t,n,r=!0){let i=oi(e),a=Vi(e,t,n),o=[],s=Fe(e.className),c=s?`node ${s}`:`node`,l=e.interaction,u=[`class="${c}"`,`data-id="${R(e.id)}"`,`data-label="${R(e.label)}"`,`data-shape="${e.shape}"`];o.push(`<g ${u.join(` `)}>`);let f=r?d(l?.href):void 0,p=f?` `:` `;if(f){let e=l?.target?` target="${R(l.target)}"`:``;o.push(` <a href="${R(f)}"${e}>`)}return r&&l?.tooltip&&o.push(`${p}<title>${Se(l.tooltip)}</title>`),o.push(`${p}${i.replace(/\n/g,`\n${p}`)}`),a&&o.push(`${p}${a.replace(/\n/g,`\n${p}`)}`),f&&o.push(` </a>`),o.push(`</g>`),o.join(`
|
|
28
|
+
`)}function oi(e){let{x:t,y:n,width:r,height:i,shape:a,inlineStyle:o}=e,s=R(o?.fill??`var(--_node-fill)`),c=R(o?.stroke??`var(--_node-stroke)`),l=R(o?.[`stroke-width`]??String(V.innerBox));switch(a){case`diamond`:return di(t,n,r,i,s,c,l);case`rounded`:return ci(t,n,r,i,s,c,l);case`stadium`:return li(t,n,r,i,s,c,l);case`circle`:return ui(t,n,r,i,s,c,l);case`subroutine`:return fi(t,n,r,i,s,c,l);case`doublecircle`:return pi(t,n,r,i,s,c,l);case`hexagon`:return mi(t,n,r,i,s,c,l);case`cylinder`:return hi(t,n,r,i,s,c,l);case`asymmetric`:return gi(t,n,r,i,s,c,l);case`trapezoid`:return _i(t,n,r,i,s,c,l);case`trapezoid-alt`:return vi(t,n,r,i,s,c,l);case`parallelogram`:return yi(t,n,r,i,s,c,l);case`parallelogram-alt`:return bi(t,n,r,i,s,c,l);case`state-start`:return zi(t,n,r,i);case`state-end`:return Bi(t,n,r,i);case`document`:return Si(t,n,r,i,s,c,l);case`stacked-document`:return Ci(t,n,r,i,s,c,l,!0);case`stacked-process`:return Ci(t,n,r,i,s,c,l,!1);case`card`:return wi(t,n,r,i,s,c,l);case`lined-process`:return Ti(t,n,r,i,s,c,l);case`divided-process`:return Ei(t,n,r,i,s,c,l);case`window-pane`:return Di(t,n,r,i,s,c,l);case`triangle`:return Oi(t,n,r,i,s,c,l,!1);case`flipped-triangle`:return Oi(t,n,r,i,s,c,l,!0);case`filled-circle`:return ki(t,n,r,i,c);case`crossed-circle`:return Ai(t,n,r,i,s,c,l);case`fork-join`:return ji(t,n,r,i,c);case`notched-pentagon`:return Mi(t,n,r,i,s,c,l);case`sloped-rectangle`:return Ni(t,n,r,i,s,c,l);case`flag`:return Pi(t,n,r,i,s,c,l);case`bow-tie-rectangle`:return Fi(t,n,r,i,s,c,l);case`half-rounded-rectangle`:return Ii(t,n,r,i,s,c,l);case`brace`:return Li(t,n,r,i,s,c,l,`left`);case`brace-right`:return Li(t,n,r,i,s,c,l,`right`);case`braces`:return Li(t,n,r,i,s,c,l,`both`);case`bolt`:return Ri(t,n,r,i,s,c,l);case`text`:case`anchor`:return``;default:return si(t,n,r,i,s,c,l)}}function si(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 ci(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 li(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 ui(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 di(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 fi(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}" />\n<line x1="${e+8}" y1="${t}" x2="${e+8}" y2="${t+r}" stroke="${a}" stroke-width="${o}" />\n<line x1="${e+n-8}" y1="${t}" x2="${e+n-8}" y2="${t+r}" stroke="${a}" stroke-width="${o}" />`}function pi(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}" />\n<circle cx="${s}" cy="${c}" r="${l-5}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function mi(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 hi(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" />\n<line x1="${e}" y1="${c}" x2="${e}" y2="${c+l}" stroke="${a}" stroke-width="${o}" />\n<line x1="${e+n}" y1="${c}" x2="${e+n}" y2="${c+l}" stroke="${a}" stroke-width="${o}" />\n<ellipse cx="${s}" cy="${t+r-7}" rx="${n/2}" ry="7" fill="${i}" stroke="${a}" stroke-width="${o}" />\n<ellipse cx="${s}" cy="${c}" rx="${n/2}" ry="7" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function gi(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 _i(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 vi(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 yi(e,t,n,r,i,a,o){let s=n*.15;return`<polygon points="${[`${e+s},${t}`,`${e+n},${t}`,`${e+n-s},${t+r}`,`${e},${t+r}`].join(` `)}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function bi(e,t,n,r,i,a,o){let s=n*.15;return`<polygon points="${[`${e},${t}`,`${e+n-s},${t}`,`${e+n},${t+r}`,`${e+s},${t+r}`].join(` `)}" fill="${i}" stroke="${a}" stroke-width="${o}" />`}function xi(e,t,n){return`fill="${e}" stroke="${t}" stroke-width="${n}"`}function Si(e,t,n,r,i,a,o){let s=Math.min(10,r*.16),c=t+r-s;return`<path d="${`M ${e} ${t} L ${e+n} ${t} L ${e+n} ${c} C ${e+n*.75} ${c+s*1.8} ${e+n*.25} ${c-s*.8} ${e} ${c} Z`}" ${xi(i,a,o)} />`}function Ci(e,t,n,r,i,a,o,s){let c=n-10,l=r-10,u=[];for(let n=2;n>=1;n--)u.push(`<rect x="${e+5*n}" y="${t+5*(2-n)}" width="${c}" height="${l}" ${xi(i,a,o)} />`);return u.push(s?Si(e,t+10,c,l,i,a,o):`<rect x="${e}" y="${t+10}" width="${c}" height="${l}" ${xi(i,a,o)} />`),u.join(`
|
|
29
|
+
`)}function wi(e,t,n,r,i,a,o){let s=Math.min(14,n*.12,r*.3);return`<polygon points="${[`${e+s},${t}`,`${e+n},${t}`,`${e+n},${t+r}`,`${e},${t+r}`,`${e},${t+s}`].join(` `)}" ${xi(i,a,o)} />`}function Ti(e,t,n,r,i,a,o){let s=Math.min(12,n*.12);return`<rect x="${e}" y="${t}" width="${n}" height="${r}" ${xi(i,a,o)} />\n<line x1="${e+s}" y1="${t}" x2="${e+s}" y2="${t+r}" stroke="${a}" stroke-width="${o}" />`}function Ei(e,t,n,r,i,a,o){let s=t+Math.min(16,r*.3);return`<rect x="${e}" y="${t}" width="${n}" height="${r}" ${xi(i,a,o)} />\n<line x1="${e}" y1="${s}" x2="${e+n}" y2="${s}" stroke="${a}" stroke-width="${o}" />`}function Di(e,t,n,r,i,a,o){let s=e+Math.min(16,n*.16),c=t+Math.min(14,r*.28);return`<rect x="${e}" y="${t}" width="${n}" height="${r}" ${xi(i,a,o)} />\n<line x1="${s}" y1="${t}" x2="${s}" y2="${t+r}" stroke="${a}" stroke-width="${o}" />\n<line x1="${e}" y1="${c}" x2="${e+n}" y2="${c}" stroke="${a}" stroke-width="${o}" />`}function Oi(e,t,n,r,i,a,o,s){return`<polygon points="${(s?[`${e},${t}`,`${e+n},${t}`,`${e+n/2},${t+r}`]:[`${e+n/2},${t}`,`${e+n},${t+r}`,`${e},${t+r}`]).join(` `)}" ${xi(i,a,o)} />`}function ki(e,t,n,r,i){let a=Math.min(n,r)/2-2;return`<circle cx="${e+n/2}" cy="${t+r/2}" r="${a}" fill="${i}" stroke="${i}" />`}function Ai(e,t,n,r,i,a,o){let s=e+n/2,c=t+r/2,l=Math.min(n,r)/2-2,u=l/Math.SQRT2;return`<circle cx="${s}" cy="${c}" r="${l}" ${xi(i,a,o)} />\n<line x1="${s-u}" y1="${c-u}" x2="${s+u}" y2="${c+u}" stroke="${a}" stroke-width="${o}" />\n<line x1="${s+u}" y1="${c-u}" x2="${s-u}" y2="${c+u}" stroke="${a}" stroke-width="${o}" />`}function ji(e,t,n,r,i){let a=Math.min(8,r);return`<rect x="${e}" y="${t+(r-a)/2}" width="${n}" height="${a}" fill="${i}" stroke="${i}" />`}function Mi(e,t,n,r,i,a,o){let s=Math.min(14,n*.12,r*.3);return`<polygon points="${[`${e+s},${t}`,`${e+n-s},${t}`,`${e+n},${t+s}`,`${e+n},${t+r}`,`${e},${t+r}`,`${e},${t+s}`].join(` `)}" ${xi(i,a,o)} />`}function Ni(e,t,n,r,i,a,o){return`<polygon points="${[`${e},${t+Math.min(12,r*.3)}`,`${e+n},${t}`,`${e+n},${t+r}`,`${e},${t+r}`].join(` `)}" ${xi(i,a,o)} />`}function Pi(e,t,n,r,i,a,o){let s=Math.min(8,r*.14);return`<path d="${`M ${e} ${t+s} C ${e+n*.25} ${t-s} ${e+n*.75} ${t+s*2} ${e+n} ${t+s} L ${e+n} ${t+r-s} C ${e+n*.75} ${t+r+s} ${e+n*.25} ${t+r-s*2} ${e} ${t+r-s} Z`}" ${xi(i,a,o)} />`}function Fi(e,t,n,r,i,a,o){let s=Math.min(14,n*.12);return`<path d="${`M ${e+s} ${t} L ${e+n} ${t} Q ${e+n-s*1.4} ${t+r/2} ${e+n} ${t+r} L ${e+s} ${t+r} Q ${e+s*1.4} ${t+r/2} ${e+s} ${t} Z`}" ${xi(i,a,o)} />`}function Ii(e,t,n,r,i,a,o){let s=r/2,c=Math.max(0,n-s);return`<path d="${`M ${e} ${t} L ${e+c} ${t} A ${s} ${s} 0 0 1 ${e+c} ${t+r} L ${e} ${t+r} Z`}" ${xi(i,a,o)} />`}function Li(e,t,n,r,i,a,o,s){let c=Math.min(10,n*.12),l=[`<rect x="${e}" y="${t}" width="${n}" height="${r}" fill="none" stroke="none" />`],u=`M ${e+c} ${t} Q ${e} ${t} ${e} ${t+r*.25} Q ${e} ${t+r/2} ${e-c*.4} ${t+r/2} Q ${e} ${t+r/2} ${e} ${t+r*.75} Q ${e} ${t+r} ${e+c} ${t+r}`,d=`M ${e+n-c} ${t} Q ${e+n} ${t} ${e+n} ${t+r*.25} Q ${e+n} ${t+r/2} ${e+n+c*.4} ${t+r/2} Q ${e+n} ${t+r/2} ${e+n} ${t+r*.75} Q ${e+n} ${t+r} ${e+n-c} ${t+r}`;return(s===`left`||s===`both`)&&l.push(`<path d="${u}" fill="none" stroke="${a}" stroke-width="${o}" />`),(s===`right`||s===`both`)&&l.push(`<path d="${d}" fill="none" stroke="${a}" stroke-width="${o}" />`),l.join(`
|
|
30
|
+
`)}function Ri(e,t,n,r,i,a,o){return`<polygon points="${[`${e+n*.42},${t}`,`${e+n},${t}`,`${e+n*.62},${t+r*.42}`,`${e+n},${t+r*.42}`,`${e+n*.3},${t+r}`,`${e+n*.5},${t+r*.55}`,`${e},${t+r*.55}`].join(` `)}" ${xi(i,a,o)} />`}function zi(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 Bi(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="${V.innerBox*2}" />\n<circle cx="${i}" cy="${a}" r="${s}" fill="var(--_text)" stroke="none" />`}function Vi(e,t,n){if((e.shape===`state-start`||e.shape===`state-end`)&&!e.label)return``;let r=e.x+e.width/2,i=e.y+e.height/2,a=R(e.inlineStyle?.color??qe(e.inlineStyle?.fill,`var(--_text)`)),o=`text-anchor="middle" font-size="${n.nodeLabel}" font-weight="${B.nodeLabel}" fill="${a}"`,s=e.inlineStyle?.[`font-family`];return s&&(o+=` style="font-family: ${R(s)};"`),z(e.label,r,i,n.nodeLabel,o)}function Hi(e){return R(e).replace(/\r/g,` `).replace(/\n/g,` `).replace(/\t/g,`	`)}function Ui(e,t){return t===void 0?e:e.replace(`<svg `,`<svg data-src="${Hi(t)}" `)}var Wi=class{raw=new Map;resolved=new Map;inProgress=new Set;declare(e,t){this.raw.set(e,t),this.resolved.delete(e)}lookup(e){if(this.resolved.has(e))return this.resolved.get(e);let t=this.raw.get(e);if(t===void 0||this.inProgress.has(e))return;this.inProgress.add(e);let n=Zi(t,this).trim();this.inProgress.delete(e);let r=!/\bvar\(|\bcolor-mix\(/.test(n);return this.resolved.set(e,r?n:void 0),r?n:void 0}};function Gi(e,t){let n=0;for(let r=t;r<e.length;r++){let t=e[r];if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}return-1}function Ki(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?n++:a===`)`?n--:a===`,`&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}var qi=`(?<![\\w-])(var|color-mix)\\(`;function Ji(e,t){let[n,...r]=Ki(e),i=(n??``).trim(),a=t.lookup(i);return a===void 0?r.length>0?r.join(`,`).trim():null:a}function Yi(e){let t=e.trim().split(/\s+/),n,r;for(let e of t)if(/^[\d.]+%$/.test(e)){if(r!==void 0)return null;r=Number(e.slice(0,-1))}else{if(n!==void 0)return null;n=e}return n===void 0?null:{color:n,pct:r}}function Xi(e){let t=Ki(e);if(t.length!==3)return null;let[n,r,i]=t;if(n===void 0||r===void 0||i===void 0||!/^\s*in\s+srgb\s*$/i.test(n))return null;let a=Yi(r),o=Yi(i);if(!a||!o)return null;let s=v(a.color),c=v(o.color);if(!s||!c)return null;let l=y(s,c,a.pct,o.pct);return l?x(l):null}function Zi(e,t){let n=``,r=0,i=new RegExp(qi,`g`),a;for(;(a=i.exec(e))!==null;){let o=a[1];if(o===void 0)continue;let s=a.index,c=s+o.length,l=Gi(e,c);if(l===-1)break;let u=Zi(e.slice(c+1,l),t),d=o===`var`?Ji(u,t):Xi(u);n+=e.slice(r,s),n+=d??`${o}(${u})`,r=l+1,i.lastIndex=r}return n+e.slice(r)}var Qi=/(--[\w-]+)\s*:\s*([^;{}]+)/g,$i=/(\s)([\w:.-]+)(=)("[^"]*"|'[^']*')/g,ea=new Set([`data-src`]);function ta(e,t){Qi.lastIndex=0;let n;for(;(n=Qi.exec(e))!==null;){let[,e,r]=n;e!==void 0&&r!==void 0&&t.declare(e,r.trim())}}function na(e,t){return e.replace($i,(e,n,r,i,a)=>{if(ea.has(r))return e;let o=a[0]??`"`;return`${n}${r}${i}${o}${Zi(a.slice(1,-1),t)}${o}`})}function ra(e,t){let n=new Wi;n.declare(`--bg`,t.bg),n.declare(`--fg`,t.fg),t.line&&n.declare(`--line`,t.line),t.accent&&n.declare(`--accent`,t.accent),t.muted&&n.declare(`--muted`,t.muted),t.surface&&n.declare(`--surface`,t.surface),t.border&&n.declare(`--border`,t.border);for(let t of e.matchAll(/<style[^>]*>([\s\S]*?)<\/style>/g)){let e=t[1];e!==void 0&&ta(e,n)}for(let t of e.matchAll(/\sstyle=("[^"]*"|'[^']*')/g)){let e=t[1];e!==void 0&&ta(e.slice(1,-1),n)}let r=``,i=0;for(;i<e.length;){let t=e.indexOf(`<`,i);if(t===-1)break;if(r+=e.slice(i,t),e.startsWith(`<style`,t)){let a=e.indexOf(`>`,t),o=e.indexOf(`</style>`,t);if(a===-1||o===-1)break;r+=e.slice(t,a+1),r+=Zi(e.slice(a+1,o),n),r+=`</style>`,i=o+8;continue}let a=-1,o=null;for(let n=t+1;n<e.length;n++){let t=e[n];if(o!==null)t===o&&(o=null);else if(t===`"`||t===`'`)o=t;else if(t===`>`){a=n;break}}if(a===-1)break;let s=e.slice(t,a+1);r+=s.startsWith(`<!`)||s.startsWith(`<?`)||s.startsWith(`</`)?s:na(s,n),i=a+1}return r+e.slice(i)}var ia={padding:40,boxPadX:8,headerBaseHeight:32,annotationHeight:16,memberRowHeight:20,sectionPadY:8,emptySectionHeight:8,minWidth:120,memberFontSize:11,memberFontWeight:400,nodeSpacing:40,layerSpacing:60,notePadX:10,notePadY:6};function aa(e){return`note ${e}`}function oa(e){return`${e} link`}function sa(e,t){let n=new Map,r=new Map,i=Hn(t.fontSizes);for(let t of e.classes){let e=t.annotation?ia.headerBaseHeight+ia.annotationHeight:ia.headerBaseHeight,r=t.attributes.length>0?t.attributes.length*ia.memberRowHeight+ia.sectionPadY:ia.emptySectionHeight,a=t.methods.length>0?t.methods.length*ia.memberRowHeight+ia.sectionPadY:ia.emptySectionHeight,o=zn(t.label,i.nodeLabel,B.nodeLabel),s=ua(t.attributes),c=ua(t.methods),l=Math.max(ia.minWidth,o+ia.boxPadX*2,s+ia.boxPadX*2,c+ia.boxPadX*2),u=e+r+a;n.set(t.id,{width:l,height:u,headerHeight:e,attrHeight:r,methodHeight:a})}let a=[];for(let[e,t]of n)a.push(Zn(e,t));let o={fontSize:i.edgeLabel},s=[];for(let[t,n]of e.relationships.entries())s.push(er({id:`e${t}`,source:n.from,target:n.to,label:n.label,labelStyle:o}));let c=new Set(n.keys());for(let[t,n]of e.notes.entries()){let e=aa(t),l=I(n.text,i.edgeLabel,B.edgeLabel),u={width:l.width+ia.notePadX*2,height:l.height+ia.notePadY*2};r.set(e,u),a.push(Zn(e,u)),n.forClass!==void 0&&c.has(n.forClass)&&s.push(er({id:oa(e),source:e,target:n.forClass,labelStyle:o}))}return{elkGraph:{id:`root`,layoutOptions:{...Xn({direction:Jn(void 0,qn.class),nodeSpacing:ia.nodeSpacing,layerSpacing:ia.layerSpacing,padding:ia.padding}),"elk.edgeLabels.placement":`CENTER`},children:a,edges:s},classSizes:n,noteSizes:r}}function ca(e,t,n,r){let i=new Map;for(let e of t.classes)i.set(e.id,e);let a=[];for(let r of e.children??[]){let e=i.get(r.id);if(e){let i=n.get(e.id);if(!i)throw Error(`Missing computed size for class "${e.id}"`);a.push({id:e.id,label:e.label,annotation:e.annotation,attributes:e.attributes,methods:e.methods,x:r.x??0,y:r.y??0,width:r.width??i.width,height:r.height??i.height,headerHeight:i.headerHeight,attrHeight:i.attrHeight,methodHeight:i.methodHeight,interaction:t.interactions.get(e.id),inlineStyle:Pe(e.id,t),className:t.classAssignments.get(e.id)})}}let o=[],s=e.edges??[];for(let[e,n]of t.relationships.entries()){let t=s[e];if(!t)throw Error(`Missing ELK edge for relationship ${e}`);let r=Tr(t),i=Er(t);o.push({from:n.from,to:n.to,type:n.type,markerAt:n.markerAt,label:n.label,fromCardinality:n.fromCardinality,toCardinality:n.toCardinality,points:r,labelPosition:i})}let c=new Map;for(let e of s.slice(t.relationships.length))c.set(e.id,e);let l=new Map;for(let t of e.children??[])l.set(t.id,t);let u=[];for(let[e,n]of t.notes.entries()){let t=aa(e),i=l.get(t),a=r.get(t);if(!i||!a)throw Error(`Missing layout for note ${e}`);let o=c.get(oa(t));u.push({id:t,text:n.text,...o&&n.forClass!==void 0?{forClass:n.forClass}:{},x:i.x??0,y:i.y??0,width:i.width??a.width,height:i.height??a.height,...o?{linkPoints:Tr(o)}:{}})}return{width:e.width??600,height:e.height??400,classes:a,relationships:o,notes:u}}function la(e,t={}){if(e.classes.length===0&&e.notes.length===0)return{width:0,height:0,classes:[],relationships:[],notes:[]};let{elkGraph:n,classSizes:r,noteSizes:i}=sa(e,t);return ca(Rn(n,t.layoutCache),e,r,i)}function ua(e){if(e.length===0)return 0;let t=0;for(let n of e){let e=Bn(lt(n),ia.memberFontSize);e>t&&(t=e)}return t}var da={memberSize:11,memberWeight:400,annotationSize:10,annotationWeight:500};function fa(e,t,n=`Inter`,r=!1,i=Vn,a,o,s,c=!0,l={}){let u=[],f=c&&e.classes.some(e=>!!d(e.interaction?.href));u.push(Ui(Ze(e.width,e.height,t,r,o,s,f,l.styleAttribute),a)),u.push(Ge(n,!0,l.nonce)),u.push(`<defs>`),u.push(pa()),u.push(`</defs>`);for(let t of e.relationships)u.push(ya(t));for(let t of e.notes)u.push(va(t));for(let t of e.classes)u.push(ma(t,i,c));for(let t of e.notes)u.push(_a(t,i));for(let t of e.relationships)u.push(Sa(t,i));return u.push(`</svg>`),u.join(`
|
|
31
|
+
`)}function pa(){return` <marker id="cls-inherit" markerWidth="12" markerHeight="10" refX="12" refY="5" orient="auto-start-reverse">
|
|
32
32
|
<polygon points="0 0, 12 5, 0 10" fill="var(--bg)" stroke="var(--_arrow)" stroke-width="1.5" />
|
|
33
33
|
</marker>
|
|
34
34
|
<marker id="cls-composition" markerWidth="12" markerHeight="10" refX="0" refY="5" orient="auto-start-reverse">
|
|
@@ -39,33 +39,33 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
39
39
|
</marker>
|
|
40
40
|
<marker id="cls-arrow" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto-start-reverse">
|
|
41
41
|
<polyline points="0 0, 8 3, 0 6" fill="none" stroke="var(--_arrow)" stroke-width="1.5" />
|
|
42
|
-
</marker>`}function
|
|
43
|
-
`)}function
|
|
44
|
-
`)}function
|
|
45
|
-
`)}function
|
|
46
|
-
`))}return u.length===0&&d.push(` <text x="${r+a/2}" y="${f+c/2}" text-anchor="middle" dy="${
|
|
47
|
-
`)}function
|
|
48
|
-
`);i.push(`<g><title>${
|
|
49
|
-
`)}function
|
|
50
|
-
`)}function
|
|
51
|
-
`)}function
|
|
52
|
-
`)}function
|
|
53
|
-
`)}function
|
|
54
|
-
`)}function
|
|
55
|
-
`)}function
|
|
56
|
-
`)[0],o=
|
|
57
|
-
`)}function no(e,t){let{x:n,y:r,width:i,height:a}=e,o=e.actors&&e.actors.length>0?` data-actors="${e.actors.map(L).join(`,`)}"`:``;return`<g class="note"${e.position?` data-position="${L(e.position)}"`:``}${o}>\n <polygon points="${[`${n},${r}`,`${n+i-6},${r}`,`${n+i},${r+6}`,`${n+i},${r+a}`,`${n},${r+a}`].join(` `)}" fill="var(--bg)" stroke="var(--_node-stroke)" stroke-width="${B.innerBox}" />\n <polygon points="${n+i-6},${r} ${n+i},${r+6} ${n+i-6},${r+6}" fill="var(--_inner-stroke)" stroke="var(--_node-stroke)" stroke-width="${B.innerBox}" />\n ${De(e.text,n+i/2,r+a/2,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${z.edgeLabel}" fill="var(--_text-muted)"`)}\n</g>`}var V={plotWidth:600,plotHeight:340,padding:22,titleFontSize:18,titleFontWeight:600,titleHeight:42,axisLabelFontSize:14,axisLabelFontWeight:400,axisTitleFontSize:15,axisTitleFontWeight:500,xLabelHeight:38,yLabelWidth:58,yLabelGap:18,axisTitlePad:30,tickLength:4,barPadRatio:.2,barGroupGap:0,maxBarWidth:40,legendFontSize:14,legendFontWeight:400,legendHeight:28,legendSwatchW:14,legendSwatchH:14,legendGap:6,legendItemGap:16};function ro(e,t={}){return e.horizontal?ao(e):io(e)}function io(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,i=e.series.length>1,a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=fo(a.min,a.max),s=Math.max(...o.map(e=>Bn(po(e),V.axisLabelFontSize,V.axisLabelFontWeight)),V.yLabelWidth),c=V.padding+(t?V.titleHeight:0)+(i?V.legendHeight:0),l=V.padding+V.xLabelHeight+(n?V.axisTitlePad:0),u=V.padding+s+V.yLabelGap+(r?V.axisTitlePad:0),d=V.padding,f=V.plotWidth,p=V.plotHeight,m=u+f+d,h=c+p+l,g={x:u,y:c,width:f,height:p},_=oo(e),v=e=>u+(e+.5)*(f/_),y=f/_,b=e=>{let t=(e-a.min)/(a.max-a.min||1);return c+p-t*p},x=co(e,v,c+p,y),S=o.map(e=>({label:po(e),x:u,y:b(e),tx:u-V.tickLength,ty:b(e),labelX:u-V.yLabelGap,labelY:b(e),textAnchor:`end`})),C=o.map(e=>({x1:u,y1:b(e),x2:u+f,y2:b(e)})),w=so(e,_),T=e.series.map((e,t)=>t),E=lo(e,v,b,y,a.min,w,T),D=uo(e,v,b,w,T),O=V.padding+(t?V.titleHeight:0)+V.legendHeight/2,k=i?mo(e,m/2,O,T):[],A={x1:u,y1:c+p,x2:u+f,y2:c+p},j={x1:u,y1:c,x2:u,y2:c+p},ee={ticks:x,line:A,...e.xAxis.title?{title:{text:e.xAxis.title,x:u+f/2,y:h-V.padding}}:{}},M={ticks:S,line:j,...e.yAxis.title?{title:{text:e.yAxis.title,x:V.padding+4,y:c+p/2,rotate:-90}}:{}};return{width:m,height:h,title:e.title?{text:e.title,x:m/2,y:V.padding+V.titleFontSize}:void 0,xAxis:ee,yAxis:M,plotArea:g,bars:E,lines:D,gridLines:C,legend:k}}function ao(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,i=e.series.length>1,a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=fo(a.min,a.max),s=oo(e),c=so(e,s),l=Math.max(...c.map(e=>Bn(e,V.axisLabelFontSize,V.axisLabelFontWeight)),40),u=V.padding+(t?V.titleHeight:0)+(i?V.legendHeight:0),d=V.padding+V.xLabelHeight+(r?V.axisTitlePad:0),f=V.padding+l+V.yLabelGap+(n?V.axisTitlePad:0),p=V.padding,m=V.plotWidth,h=V.plotHeight,g=f+m+p,_=u+h+d,v={x:f,y:u,width:m,height:h},y=e=>{let t=(e-a.min)/(a.max-a.min||1);return f+t*m},b=h/s,x=e=>u+(e+.5)*b,S=o.map(e=>({label:po(e),x:y(e),y:u+h,tx:y(e),ty:u+h+V.tickLength,labelX:y(e),labelY:u+h+18,textAnchor:`middle`})),C=c.map((e,t)=>({label:e,x:f,y:x(t),tx:f-V.tickLength,ty:x(t),labelX:f-V.yLabelGap,labelY:x(t),textAnchor:`end`})),w=o.map(e=>({x1:y(e),y1:u,x2:y(e),y2:u+h})),T=e.series.map((e,t)=>t),E=e.series.filter(e=>e.type===`bar`).length,D=[];if(E>0){let t=b*(1-V.barPadRatio),n=E>1?(t-(E-1)*V.barGroupGap)/E:t,r=Math.min(n,V.maxBarWidth),i=E>1?r*E+V.barGroupGap*(E-1):r,o=0,s=0;for(let t of e.series){if(t.type!==`bar`){s++;continue}for(let e=0;e<t.data.length;e++){let n=x(e)-i/2+o*(r+V.barGroupGap),l=y(Math.max(t.data[e],a.min)),u=y(Math.max(0,a.min));D.push({x:Math.min(u,l),y:n,width:Math.abs(l-u),height:r,value:t.data[e],label:c[e],seriesIndex:o,colorIndex:T[s]})}o++,s++}}let O=[],k=0,A=0;for(let t of e.series){if(t.type!==`line`){A++;continue}let e=t.data.map((e,t)=>({x:y(e),y:x(t),value:e,label:c[t]}));O.push({points:e,seriesIndex:k,colorIndex:T[A]}),k++,A++}let j={x1:f,y1:u+h,x2:f+m,y2:u+h},ee={x1:f,y1:u,x2:f,y2:u+h},M={ticks:S,line:j,...e.yAxis.title?{title:{text:e.yAxis.title,x:f+m/2,y:_-V.padding}}:{}},te={ticks:C,line:ee,...e.xAxis.title?{title:{text:e.xAxis.title,x:V.padding+4,y:u+h/2,rotate:-90}}:{}},ne=e.title?{text:e.title,x:g/2,y:V.padding+V.titleFontSize}:void 0,re=V.padding+(t?V.titleHeight:0)+V.legendHeight/2;return{width:g,height:_,horizontal:!0,title:ne,xAxis:M,yAxis:te,plotArea:v,bars:D,lines:O,gridLines:w,legend:i?mo(e,g/2,re,T):[]}}function oo(e){if(e.xAxis.categories)return e.xAxis.categories.length;for(let t of e.series)if(t.data.length>0)return t.data.length;return 1}function so(e,t){if(e.xAxis.categories)return e.xAxis.categories;if(e.xAxis.range){let{min:n,max:r}=e.xAxis.range,i=t>1?(r-n)/(t-1):0;return Array.from({length:t},(e,t)=>po(n+i*t))}return Array.from({length:t},(e,t)=>String(t+1))}function co(e,t,n,r){return so(e,oo(e)).map((e,r)=>({label:e,x:t(r),y:n,tx:t(r),ty:n+V.tickLength,labelX:t(r),labelY:n+18,textAnchor:`middle`}))}function lo(e,t,n,r,i,a,o){let s=e.series.filter(e=>e.type===`bar`).length;if(s===0)return[];let c=r*(1-V.barPadRatio),l=s>1?(c-(s-1)*V.barGroupGap)/s:c,u=Math.min(l,V.maxBarWidth),d=s>1?u*s+V.barGroupGap*(s-1):u,f=[],p=0,m=0;for(let r of e.series){if(r.type!==`bar`){m++;continue}for(let e=0;e<r.data.length;e++){let s=t(e)-d/2+p*(u+V.barGroupGap),c=n(r.data[e]),l=n(Math.max(0,i));f.push({x:s,y:Math.min(c,l),width:u,height:Math.abs(l-c),value:r.data[e],label:a[e],seriesIndex:p,colorIndex:o[m]})}p++,m++}return f}function uo(e,t,n,r,i){let a=[],o=0,s=0;for(let c of e.series){if(c.type!==`line`){s++;continue}let e=c.data.map((e,i)=>({x:t(i),y:n(e),value:e,label:r[i]}));a.push({points:e,seriesIndex:o,colorIndex:i[s]}),o++,s++}return a}function fo(e,t){let n=t-e;if(n<=0)return[e];let r=n/6,i=10**Math.floor(Math.log10(r)),a=r/i,o;o=a<=1.5?i:a<=3?2*i:a<=7?5*i:10*i;let s=Math.ceil(e/o)*o,c=[];for(let e=s;e<=t+o*.001;e+=o)c.push(Math.round(e*1e10)/1e10);return c}function po(e){return Number.isInteger(e)?String(e):e.toFixed(+(Math.abs(e)<10))}function mo(e,t,n,r){let i=[],a=0,o=0;for(let t=0;t<e.series.length;t++){let s=e.series[t],c=s.type===`bar`?`Bar ${a+1}`:`Line ${o+1}`;i.push({label:c,x:0,y:n,type:s.type,seriesIndex:s.type===`bar`?a:o,colorIndex:r[t]}),s.type===`bar`?a++:o++}let s=i.map(e=>{let t=Bn(e.label,V.legendFontSize,V.legendFontWeight);return V.legendSwatchW+V.legendGap+t}),c=t-(s.reduce((e,t)=>e+t,0)+(i.length-1)*V.legendItemGap)/2;for(let e=0;e<i.length;e++)i[e].x=c,c+=s[e]+V.legendItemGap;return i}var H={titleSize:18,titleWeight:600,axisTitleSize:15,axisTitleWeight:500,labelSize:14,labelWeight:400,legendSize:14,legendWeight:400,dotRadius:5,lineWidth:2.5,barRadius:8},U={fontSize:15,fontWeight:500,height:32,padX:14,offsetY:12,rx:8,minY:4,pointerSize:6};function ho(e,t,n=`Inter`,r=!1,i=!1,a,o,s,c={}){let l=[],u=Math.max(0,...e.bars.map(e=>e.colorIndex),...e.lines.map(e=>e.colorIndex)),d=Wi(Qe(e.width,e.height,t,r,o,s,void 0,c.styleAttribute).replace(`<svg `,`<svg data-xychart-colors="${u}" `),a);l.push(d),l.push(Ke(n,!1,c.nonce));let f=Math.max(...e.lines.map(e=>e.points.length),0),p=f>0&&f<=12,{style:m,defs:h}=go(e,i,p,t.accent,t.bg,c.nonce);l.push(m),h&&l.push(h);let{plotArea:g}=e,_=e.xAxis.ticks.map(e=>e.x),v=e.horizontal?e.yAxis.ticks.map(e=>e.y):e.gridLines.map(e=>e.y1),y=_.length>1?Math.abs(_[1]-_[0]):g.width/6,b=v.length>1?Math.abs(v[1]-v[0]):g.height/6,x=y/Math.max(1,Math.round(y/20)),S=b/Math.max(1,Math.round(b/20)),C=_[0]??g.x,w=v[0]??g.y,T=C-Math.ceil((C-g.x)/x)*x,E=w-Math.ceil((w-g.y)/S)*S;for(let e=E;e<=g.y+g.height+.5;e+=S)for(let t=T;t<=g.x+g.width+.5;t+=x)l.push(`<circle cx="${W(t)}" cy="${W(e)}" r="1.5" class="xychart-grid"/>`);let D=[];for(let t of e.bars){let n=` data-value="${t.value}"${t.label?` data-label="${Co(t.label)}"`:``}`,r=e.horizontal?vo(t.x,t.y,t.width,t.height,H.barRadius):_o(t.x,t.y,t.width,t.height,H.barRadius);if(l.push(`<path d="${r}" class="xychart-bar xychart-color-${t.colorIndex}"${n}/>`),i){let e=So(t.value),n=t.label?`${t.label}: ${e}`:e,r=xo(t.x+t.width/2,t.y,e);D.push(`<g class="xychart-bar-group"><rect x="${W(t.x)}" y="${W(t.y)}" width="${W(t.width)}" height="${W(t.height)}" fill="transparent"/><title>${Co(n)}</title>`+r+`</g>`)}}for(let t of e.lines){if(t.points.length===0)continue;let e=yo(t.points);l.push(`<path d="${e}" class="xychart-line-shadow xychart-color-${t.colorIndex}" transform="translate(0,2)"/>`),l.push(`<path d="${e}" class="xychart-line xychart-color-${t.colorIndex}"/>`)}let O=[];if(i||p){let t=new Map;for(let n of e.legend)n.type===`line`&&t.set(n.seriesIndex,n.label);let n=new Map;for(let t of e.lines)for(let e of t.points){let r=W(e.x),i=n.get(r)??[];n.set(r,i),i.push({x:e.x,y:e.y,value:e.value,label:e.label,seriesIndex:t.seriesIndex,colorIndex:t.colorIndex})}for(let e of n.values()){let n=e[0].x,r=e[0].label||``;if(i&&e.length>1){let i=Math.min(...e.map(e=>e.y)),a=Math.max(...e.map(e=>e.y)),o=H.dotRadius*3,s=`<rect x="${W(n-o)}" y="${W(i-o)}" width="${W(o*2)}" height="${W(a-i+o*2)}" fill="transparent" class="xychart-hit"/>`,c=e.map(e=>({text:So(e.value),legendLabel:t.get(e.seriesIndex)||`Line ${e.seriesIndex+1}`})),l=bo(n,i-H.dotRadius,r,c),u=c.map(e=>e.text),d=r?`${r}: ${u.join(` · `)}`:u.join(` · `),f=`<g class="xychart-dot-group">${s}`;for(let t of e){let e=` data-value="${t.value}"${t.label?` data-label="${Co(t.label)}"`:``}`;f+=`<circle cx="${W(t.x)}" cy="${W(t.y)}" r="${H.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${e}/>`}f+=`<title>${Co(d)}</title>${l}</g>`,O.push(f)}else if(i){let t=e[0],r=` data-value="${t.value}"${t.label?` data-label="${Co(t.label)}"`:``}`,i=So(t.value),a=t.label?`${t.label}: ${i}`:i,o=xo(n,t.y-H.dotRadius,i),s=p?`<circle cx="${W(n)}" cy="${W(t.y)}" r="${H.dotRadius*3}" fill="transparent" class="xychart-hit"/>`:``;O.push(`<g class="xychart-dot-group">${s}<circle cx="${W(t.x)}" cy="${W(t.y)}" r="${H.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${r}/><title>${Co(a)}</title>${o}</g>`)}else for(let t of e){let e=` data-value="${t.value}"${t.label?` data-label="${Co(t.label)}"`:``}`;l.push(`<circle cx="${W(t.x)}" cy="${W(t.y)}" r="${H.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${e}/>`)}}}for(let t of e.xAxis.ticks)l.push(`<text x="${t.labelX}" y="${t.labelY}" text-anchor="${t.textAnchor}" font-size="${H.labelSize}" font-weight="${H.labelWeight}" dy="${Gn}" class="xychart-label">${Co(t.label)}</text>`);for(let t of e.yAxis.ticks)l.push(`<text x="${t.labelX}" y="${t.labelY}" text-anchor="${t.textAnchor}" font-size="${H.labelSize}" font-weight="${H.labelWeight}" dy="${Gn}" class="xychart-label">${Co(t.label)}</text>`);if(e.xAxis.title){let t=e.xAxis.title,n=t.rotate?` transform="rotate(${t.rotate},${t.x},${t.y})"`:``;l.push(`<text x="${t.x}" y="${t.y}" text-anchor="middle"${n} font-size="${H.axisTitleSize}" font-weight="${H.axisTitleWeight}" dy="${Gn}" class="xychart-axis-title">${Co(t.text)}</text>`)}if(e.yAxis.title){let t=e.yAxis.title,n=t.rotate?` transform="rotate(${t.rotate},${t.x},${t.y})"`:``;l.push(`<text x="${t.x}" y="${t.y}" text-anchor="middle"${n} font-size="${H.axisTitleSize}" font-weight="${H.axisTitleWeight}" dy="${Gn}" class="xychart-axis-title">${Co(t.text)}</text>`)}e.title&&l.push(`<text x="${e.title.x}" y="${e.title.y}" text-anchor="middle" font-size="${H.titleSize}" font-weight="${H.titleWeight}" dy="${Gn}" class="xychart-title">${Co(e.title.text)}</text>`);for(let t of e.legend){if(t.type===`bar`)l.push(`<rect x="${t.x}" y="${t.y-7}" width="14" height="14" rx="3" class="xychart-bar xychart-color-${t.colorIndex}"/>`);else{let e=t.y;l.push(`<line x1="${t.x}" y1="${e}" x2="${t.x+14}" y2="${e}" stroke-width="${H.lineWidth}" stroke-linecap="round" class="xychart-legend-line xychart-color-${t.colorIndex}"/>`)}l.push(`<text x="${t.x+14+6}" y="${t.y}" text-anchor="start" font-size="${H.legendSize}" font-weight="${H.legendWeight}" dy="${Gn}" class="xychart-label">${Co(t.label)}</text>`)}for(let e of D)l.push(e);for(let e of O)l.push(e);return l.push(`</svg>`),l.join(`
|
|
58
|
-
`)}function
|
|
42
|
+
</marker>`}function ma(e,t,n=!0){let{x:r,y:i,width:a,height:o,headerHeight:s,attrHeight:c,inlineStyle:l}=e,u=[],f=e.interaction,p=R(l?.fill??`var(--_node-fill)`),m=R(l?.stroke??`var(--_node-stroke)`),h=R(l?.[`stroke-width`]??String(V.outerBox)),g=l?.fill?p:`var(--_group-hdr)`,_=l?.color?R(l.color):l?.fill?R(qe(l.fill,`var(--_text)`)):void 0,v=e.annotation?` data-annotation="${R(e.annotation)}"`:``,y=Fe(e.className),b=[`class="${y?`class-node ${y}`:`class-node`}"`,`data-id="${R(e.id)}"`,`data-label="${R(e.label)}"`];u.push(`<g ${b.join(` `)}${v}>`);let x=n?d(f?.href):void 0;if(x){let e=f?.target?` target="${R(f.target)}"`:``;u.push(` <a href="${R(x)}"${e}>`)}n&&f?.tooltip&&u.push(` <title>${Ta(f.tooltip)}</title>`),u.push(` <rect x="${r}" y="${i}" width="${a}" height="${o}" rx="0" ry="0" fill="${p}" stroke="${m}" stroke-width="${h}" />`),u.push(` <rect x="${r}" y="${i}" width="${a}" height="${s}" rx="0" ry="0" fill="${g}" stroke="${m}" stroke-width="${h}" />`);let S=i+s/2;if(e.annotation){let t=i+12;u.push(` <text x="${r+a/2}" y="${t}" text-anchor="middle" dy="${Wn}" font-size="${da.annotationSize}" font-weight="${da.annotationWeight}" font-style="italic" fill="${_??`var(--_text-muted)`}"><<${Ta(e.annotation)}>></text>`),S=i+s/2+6}u.push(` `+z(e.label,r+a/2,S,t.nodeLabel,`text-anchor="middle" font-size="${t.nodeLabel}" font-weight="700" fill="${_??`var(--_text)`}"`));let C=i+s;u.push(` <line x1="${r}" y1="${C}" x2="${r+a}" y2="${C}" stroke="${m}" stroke-width="${V.innerBox}" />`);for(let t=0;t<e.attributes.length;t++){let n=e.attributes[t],i=C+4+t*20+10;u.push(` `+ha(n,r+ia.boxPadX,i,_))}let w=C+c;u.push(` <line x1="${r}" y1="${w}" x2="${r+a}" y2="${w}" stroke="${m}" stroke-width="${V.innerBox}" />`);for(let t=0;t<e.methods.length;t++){let n=e.methods[t],i=w+4+t*20+10;u.push(` `+ha(n,r+ia.boxPadX,i,_))}return x&&u.push(` </a>`),u.push(`</g>`),u.join(`
|
|
43
|
+
`)}function ha(e,t,n,r){let i=e.isAbstract?` font-style="italic"`:``,a=e.isStatic?` text-decoration="underline"`:``,o=r??`var(--_text-faint)`,s=r??`var(--_text-sec)`,c=r??`var(--_text-muted)`,l=[];e.visibility&&l.push(`<tspan fill="${o}">${Ta(e.visibility)} </tspan>`);let u=e.isMethod?`${e.name}(${e.params||``})`:e.name;return l.push(`<tspan fill="${s}">${Ta(u)}</tspan>`),e.type&&(l.push(`<tspan fill="${o}">: </tspan>`),l.push(`<tspan fill="${c}">${Ta(e.type)}</tspan>`)),`<text x="${t}" y="${n}" class="mono" dy="${Wn}" font-size="${da.memberSize}" font-weight="${da.memberWeight}"${i}${a}>${l.join(``)}</text>`}var ga=6;function _a(e,t){let{x:n,y:r,width:i,height:a}=e,o=e.forClass===void 0?``:` data-for="${R(e.forClass)}"`,s=[`${n},${r}`,`${n+i-ga},${r}`,`${n+i},${r+ga}`,`${n+i},${r+a}`,`${n},${r+a}`].join(` `),c=`${n+i-ga},${r} ${n+i},${r+ga} ${n+i-ga},${r+ga}`;return`<g class="class-note"${o}>\n <polygon points="${s}" fill="var(--bg)" stroke="var(--_node-stroke)" stroke-width="${V.innerBox}" />\n <polygon points="${c}" fill="var(--_inner-stroke)" stroke="var(--_node-stroke)" stroke-width="${V.innerBox}" />\n ${z(e.text,n+i/2,r+a/2,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${B.edgeLabel}" fill="var(--_text-muted)"`)}\n</g>`}function va(e){if(!e.linkPoints||e.linkPoints.length<2)return``;let t=e.linkPoints.map(e=>`${e.x},${e.y}`).join(` `);return`<polyline class="class-note-link"${e.forClass===void 0?``:` data-for="${R(e.forClass)}"`} points="${t}" fill="none" stroke="var(--_line)" stroke-width="${V.connector}" stroke-dasharray="2 3" />`}function ya(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=ba(e.type,e.markerAt),i=[`class="class-relationship"`,`data-from="${R(e.from)}"`,`data-to="${R(e.to)}"`,`data-type="${e.type}"`,`data-marker-at="${e.markerAt}"`];return e.label&&i.push(`data-label="${R(e.label)}"`),e.fromCardinality&&i.push(`data-from-cardinality="${R(e.fromCardinality)}"`),e.toCardinality&&i.push(`data-to-cardinality="${R(e.toCardinality)}"`),`<polyline ${i.join(` `)} points="${t}" fill="none" stroke="var(--_line)" stroke-width="${V.connector}"${n}${r} />`}function ba(e,t){let n=xa(e);return n?t===`from`?` marker-start="url(#${n})"`:` marker-end="url(#${n})"`:``}function xa(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 Sa(e,t){if(!e.label&&!e.fromCardinality&&!e.toCardinality||e.points.length<2)return``;let n=[];if(e.label){let r=e.labelPosition??Ca(e.points);n.push(z(e.label,r.x,r.y-8,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${B.edgeLabel}" fill="var(--_text-muted)"`))}if(e.fromCardinality&&e.points.length>=2){let r=e.points[0],i=e.points[1],a=wa(r,i);n.push(z(e.fromCardinality,r.x+a.x,r.y+a.y,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${B.edgeLabel}" fill="var(--_text-muted)"`))}if(e.toCardinality&&e.points.length>=2){let r=e.points[e.points.length-1],i=e.points[e.points.length-2],a=wa(r,i);n.push(z(e.toCardinality,r.x+a.x,r.y+a.y,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${B.edgeLabel}" fill="var(--_text-muted)"`))}return n.join(`
|
|
44
|
+
`)}function Ca(e){return e.length===0?{x:0,y:0}:e[Math.floor(e.length/2)]}function wa(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}}var Ta=Se,Ea={padding:40,boxPadX:14,headerHeight:34,rowHeight:22,minWidth:140,attrFontSize:11,attrFontWeight:400,nodeSpacing:70,layerSpacing:90};function Da(e,t){let n=new Map,r=Hn(t.fontSizes);for(let t of e.entities){let e=zn(t.label,r.nodeLabel,B.nodeLabel),i=0;for(let e of t.attributes){let t=Bn(`${e.type} ${e.name}${e.keys.length>0?` `+e.keys.join(`,`):``}`,Ea.attrFontSize);t>i&&(i=t)}let a=Math.max(Ea.minWidth,e+Ea.boxPadX*2,i+Ea.boxPadX*2),o=Ea.headerHeight+Math.max(t.attributes.length,1)*Ea.rowHeight;n.set(t.id,{width:a,height:o})}let i=[];for(let[e,t]of n)i.push(Zn(e,t));let a={fontSize:r.edgeLabel},o=[];for(let[t,n]of e.relationships.entries())o.push(er({id:`e${t}`,source:n.entity1,target:n.entity2,label:n.label,labelStyle:a}));return{elkGraph:{id:`root`,layoutOptions:{...Xn({direction:Jn(e.direction,qn.er),nodeSpacing:Ea.nodeSpacing,layerSpacing:Ea.layerSpacing,padding:Ea.padding}),"elk.edgeLabels.placement":`CENTER`},children:i,edges:o},entitySizes:n}}function Oa(e,t,n){let r=new Map;for(let e of t.entities)r.set(e.id,e);let i=[];for(let t of e.children??[]){let e=r.get(t.id);if(e){let r=n.get(e.id);if(!r)throw Error(`Missing computed size for entity "${e.id}"`);i.push({id:e.id,label:e.label,attributes:e.attributes,x:t.x??0,y:t.y??0,width:t.width??r.width,height:t.height??r.height,headerHeight:Ea.headerHeight,rowHeight:Ea.rowHeight})}}let a=[];for(let[n,r]of(e.edges??[]).entries()){let e=t.relationships[n],i=Tr(r);a.push({entity1:e.entity1,entity2:e.entity2,cardinality1:e.cardinality1,cardinality2:e.cardinality2,label:e.label,identifying:e.identifying,points:i})}return{width:e.width??600,height:e.height??400,entities:i,relationships:a}}function ka(e,t={}){if(e.entities.length===0)return{width:0,height:0,entities:[],relationships:[]};let{elkGraph:n,entitySizes:r}=Da(e,t);return Oa(Rn(n,t.layoutCache),e,r)}var Aa={attrSize:11,attrWeight:400,keySize:9,keyWeight:600};function ja(e,t,n=`Inter`,r=!1,i=Vn,a,o,s,c={}){let l=[];l.push(Ui(Ze(e.width,e.height,t,r,o,s,void 0,c.styleAttribute),a)),l.push(Ge(n,!0,c.nonce)),l.push(`<defs>`),l.push(`</defs>`);for(let t of e.relationships)l.push(Pa(t));for(let t of e.entities)l.push(Ma(t,i));for(let t of e.relationships)l.push(Ia(t));for(let t of e.relationships)l.push(Fa(t,i));return l.push(`</svg>`),l.join(`
|
|
45
|
+
`)}function Ma(e,t){let{id:n,x:r,y:i,width:a,height:o,headerHeight:s,rowHeight:c,label:l,attributes:u}=e,d=[];d.push(`<g class="entity" data-id="${R(n)}" data-label="${R(l)}">`),d.push(` <rect x="${r}" y="${i}" width="${a}" height="${o}" rx="0" ry="0" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${V.outerBox}" />`),d.push(` <rect x="${r}" y="${i}" width="${a}" height="${s}" rx="0" ry="0" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${V.outerBox}" />`),d.push(` `+z(l,r+a/2,i+s/2,t.nodeLabel,`text-anchor="middle" font-size="${t.nodeLabel}" font-weight="700" fill="var(--_text)"`));let f=i+s;d.push(` <line x1="${r}" y1="${f}" x2="${r+a}" y2="${f}" stroke="var(--_node-stroke)" stroke-width="${V.innerBox}" />`);for(let e=0;e<u.length;e++){let t=u[e],n=f+e*c+c/2;d.push(` `+Na(t,r,n,a).replace(/\n/g,`
|
|
46
|
+
`))}return u.length===0&&d.push(` <text x="${r+a/2}" y="${f+c/2}" text-anchor="middle" dy="${Wn}" font-size="${Aa.attrSize}" fill="var(--_text-faint)" font-style="italic">(no attributes)</text>`),d.push(`</g>`),d.join(`
|
|
47
|
+
`)}function Na(e,t,n,r){let i=[],a=e.comment&&e.comment.length>0;if(e.comment&&e.comment.length>0){let t=e.comment.replace(/<br\s*\/?>/gi,`
|
|
48
|
+
`);i.push(`<g><title>${za(t)}</title>`)}let o=0;e.keys.length>0&&(o=zn(e.keys.join(`,`),Aa.keySize,Aa.keyWeight)+8,i.push(`<rect x="${t+6}" y="${n-7}" width="${o}" height="14" rx="2" ry="2" fill="var(--_key-badge)" />`),i.push(`<text x="${t+6+o/2}" y="${n}" text-anchor="middle" dy="${Wn}" font-size="${Aa.keySize}" font-weight="${Aa.keyWeight}" fill="var(--_text-sec)">${e.keys.join(`,`)}</text>`));let s=t+8+(o>0?o+6:0);i.push(`<text x="${s}" y="${n}" class="mono" dy="${Wn}" font-size="${Aa.attrSize}" font-weight="${Aa.attrWeight}"><tspan fill="var(--_text-muted)">${za(e.type)}</tspan></text>`);let c=t+r-8;return i.push(`<text x="${c}" y="${n}" class="mono" text-anchor="end" dy="${Wn}" font-size="${Aa.attrSize}" font-weight="${Aa.attrWeight}"><tspan fill="var(--_text-sec)">${za(e.name)}</tspan></text>`),a&&i.push(`</g>`),i.join(`
|
|
49
|
+
`)}function Pa(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"`,r=e.label?` data-label="${R(e.label)}"`:``;return`<polyline ${[`class="er-relationship"`,`data-entity1="${R(e.entity1)}"`,`data-entity2="${R(e.entity2)}"`,`data-cardinality1="${e.cardinality1}"`,`data-cardinality2="${e.cardinality2}"`,`data-identifying="${e.identifying}"`].join(` `)}${r} points="${t}" fill="none" stroke="var(--_line)" stroke-width="${V.connector}"${n} />`}function Fa(e,t){if(!e.label||e.points.length<2)return``;let n=Ra(e.points),r=I(e.label,t.edgeLabel,B.edgeLabel),i=r.width+8,a=r.height+6;return`<rect x="${n.x-i/2}" y="${n.y-a/2}" width="${i}" height="${a}" rx="2" ry="2" fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />\n${z(e.label,n.x,n.y,t.edgeLabel,`text-anchor="middle" font-size="${t.edgeLabel}" font-weight="${B.edgeLabel}" fill="var(--_text-muted)"`)}`}function Ia(e){if(e.points.length<2)return``;let t=[],n=e.points[0],r=e.points[1];t.push(La(n,r,e.cardinality1));let i=e.points[e.points.length-1],a=e.points[e.points.length-2];return t.push(La(i,a,e.cardinality2)),t.join(`
|
|
50
|
+
`)}function La(e,t,n){let r=[],i=V.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(`
|
|
51
|
+
`)}function Ra(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]}var za=Se,Ba={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:60,notePadX:12,notePadY:6,noteGap:10,noteOffsetAfterMessage:8,noteStackGap:4,boxPad:10};function Va(e){return e+8}function Ha(e){return{...Ba,actorHeight:e?.actorHeight??Ba.actorHeight,headerGap:e?.headerGap??Ba.headerGap,messageRowHeight:e?.messageRowHeight??Ba.messageRowHeight,noteOffsetAfterMessage:e?.noteOffsetAfterMessage??Ba.noteOffsetAfterMessage,noteStackGap:e?.noteStackGap??Ba.noteStackGap}}function Ua(e,t={}){if(e.actors.length===0)return{width:0,height:0,actors:[],lifelines:[],messages:[],activations:[],blocks:[],notes:[],boxes:[]};let n=Ha(t.sequence),r=Hn(t.fontSizes),i=e.actors.map(e=>{let t=zn(e.label,r.nodeLabel,B.nodeLabel);return Math.max(t+n.actorPadX*2,80)}),a=[],o=n.padding+i[0]/2;for(let t=0;t<e.actors.length;t++){if(t>0){let e=Math.max(n.actorGap,(i[t-1]+i[t])/2+40);o+=e}a.push(o)}let s=new Map;for(let t=0;t<e.actors.length;t++)s.set(e.actors[t].id,t);let c=e.boxes.filter(e=>e.actorIds.length>0),l=c.some(e=>e.label!==``),u=c.length===0?0:n.boxPad+(l?Va(r.edgeLabel):0),d=n.padding+u,f=e.actors.map((e,t)=>({id:e.id,label:e.label,type:e.type,x:a[t],y:d,width:i[t],height:n.actorHeight})),p=c.map(e=>{let t=e.actorIds.map(e=>s.get(e)??0),r=Math.min(...t),o=Math.max(...t),c=a[r]-i[r]/2-n.boxPad,l=a[o]+i[o]/2+n.boxPad,u={label:e.label,x:c,y:n.padding,width:l-c,height:0};return e.color!==void 0&&(u.color=e.color),u}),m=d+n.actorHeight+n.headerGap,h=[],g=new Map;for(let t of e.blocks){let e=g.get(t.startIndex)??0;g.set(t.startIndex,Math.max(e,n.blockHeaderExtra));for(let e of t.dividers){let t=g.get(e.index)??0;g.set(e.index,Math.max(t,n.dividerExtra))}}let _=new Map;for(let t of e.notes){let e=_.get(t.afterIndex)??[];e.push(t),_.set(t.afterIndex,e)}let v=[],y=_.get(-1);if(y&&y.length>0){let e=m;for(let t of y){let o=Math.max(n.noteWidth,zn(t.text,r.edgeLabel,B.edgeLabel)+n.notePadX*2),c=r.edgeLabel+n.notePadY*2,l=s.get(t.actorIds[0]??``)??0,u;if(t.position===`left`)u=a[l]-i[l]/2-o-n.noteGap;else if(t.position===`right`)u=a[l]+i[l]/2+n.noteGap;else if(t.actorIds.length>1){let e=s.get(t.actorIds[t.actorIds.length-1]??``)??l;u=(a[l]+a[e])/2-o/2}else u=a[l]-o/2;v.push({text:t.text,x:u,y:e,width:o,height:c,position:t.position,actors:t.actorIds}),e+=c+n.noteStackGap}m=Math.max(m,e+n.messageRowHeight/2)}let b=new Map,x=[];function S(e,t){let n=b.get(e)??[];b.set(e,n);let r=n.length;n.push({startY:t,depth:r})}function C(e,t){let r=b.get(e);if(!r||r.length===0)return;let{startY:i,depth:o}=r.pop(),c=s.get(e)??0,l=o*4;x.push({actorId:e,x:a[c]-n.activationWidth/2+l,topY:i,bottomY:t,width:n.activationWidth})}let w=new Map;for(let t of e.activations){let e=w.get(t.afterIndex)??[];e.push(t),w.set(t.afterIndex,e)}function T(e,t){for(let n of w.get(e)??[])n.kind===`start`?S(n.actorId,t):C(n.actorId,t)}T(-1,m);for(let t=0;t<e.messages.length;t++){let o=e.messages[t],c=s.get(o.from)??0,l=s.get(o.to)??0,u=o.from===o.to,d=g.get(t)??0;d>0&&(m+=d);let f=a[c],p=a[l],y=!u&&e.actors[l].createdAt===t;if(y){let e=i[l]/2;p+=f<p?-e:e}h.push({from:o.from,to:o.to,label:o.label,lineStyle:o.lineStyle,arrowHead:o.arrowHead,x1:f,x2:p,y:m,isSelf:u,bidirectional:o.bidirectional??!1,seqNumber:o.seqNumber}),o.activate&&S(o.to,m),o.deactivate&&C(o.from,m),T(t,m),m+=u?n.selfMessageHeight+n.messageRowHeight:n.messageRowHeight,y&&(m+=n.actorHeight/2);let b=_.get(t);if(b&&b.length>0){let e=u?n.selfMessageHeight:0,o=h[t].y+e+n.noteOffsetAfterMessage;for(let e of b){let t=Math.max(n.noteWidth,zn(e.text,r.edgeLabel,B.edgeLabel)+n.notePadX*2),c=r.edgeLabel+n.notePadY*2,l=s.get(e.actorIds[0]??``)??0,u;if(e.position===`left`)u=a[l]-i[l]/2-t-n.noteGap;else if(e.position===`right`)u=a[l]+i[l]/2+n.noteGap;else if(e.actorIds.length>1){let n=s.get(e.actorIds[e.actorIds.length-1]??``)??l;u=(a[l]+a[n])/2-t/2}else u=a[l]-t/2;v.push({text:e.text,x:u,y:o,width:t,height:c,position:e.position,actors:e.actorIds}),o+=c+n.noteStackGap}m=Math.max(m,o+n.messageRowHeight/2)}}for(let[e,t]of b)for(let{startY:r,depth:i}of t){let t=s.get(e)??0,o=i*4;x.push({actorId:e,x:a[t]-n.activationWidth/2+o,topY:r,bottomY:m-n.messageRowHeight/2,width:n.activationWidth})}let E=e.blocks.map(t=>{let o=h[t.startIndex],c=h[t.endIndex],l=(o?.y??m)-n.blockPadTop,u=(c?.y??m)+n.blockPadBottom+12,d=new Set;for(let n=t.startIndex;n<=t.endIndex;n++){let t=e.messages[n];t&&(d.add(s.get(t.from)??0),d.add(s.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),g=a[f]-i[f]/2-n.blockPadX,_=a[p]+i[p]/2+n.blockPadX,v=t.dividers.map(e=>{let t=h[e.index],n=t?.y??m,i=28;if(e.label&&t?.label){let n=zn(`[${e.label}]`,r.edgeLabel,B.edgeLabel),a=g+8,o=a+n,s=zn(t.label,r.edgeLabel,B.edgeLabel),c=t.isSelf?t.x1+36:(t.x1+t.x2)/2-s/2,l=c+s;o>c&&a<l&&(i=36)}return{y:n-i,label:e.label}});return{type:t.type,label:t.label,x:g,y:l,width:_-g,height:u-l,dividers:v}}),D=v,O=m+n.padding,k=n.padding,A=0;for(let e of f)k=Math.min(k,e.x-e.width/2),A=Math.max(A,e.x+e.width/2);for(let e of E)k=Math.min(k,e.x),A=Math.max(A,e.x+e.width);for(let e of D)k=Math.min(k,e.x),A=Math.max(A,e.x+e.width);for(let e of p)k=Math.min(k,e.x),A=Math.max(A,e.x+e.width);for(let e of h)if(e.isSelf&&e.label){let t=e.x1+30+8,n=zn(e.label,r.edgeLabel,B.edgeLabel);A=Math.max(A,t+n+8)}let j=k<n.padding?n.padding-k:0;if(j>0){for(let e of f)e.x+=j;for(let e of h)e.x1+=j,e.x2+=j;for(let e of x)e.x+=j;for(let e of E)e.x+=j;for(let e of D)e.x+=j;for(let e of p)e.x+=j;for(let e=0;e<a.length;e++)a[e]+=j}for(let t=0;t<e.actors.length;t++){let r=e.actors[t].createdAt;r!==void 0&&(f[t].y=(h[r]?.y??m)-n.actorHeight/2)}let ee=e.actors.map((e,t)=>{let r=e.destroyedAt,i={actorId:e.id,x:a[t],topY:f[t].y+n.actorHeight,bottomY:r===void 0?O-n.padding:h[r]?.y??m};return r!==void 0&&(i.destroyed=!0),i});for(let e of p)e.height=O-n.padding+n.boxPad-e.y;let M=A+j+n.padding;return{width:Math.max(M,200),height:Math.max(O,100),actors:f,lifelines:ee,messages:h,activations:x,blocks:E,notes:D,boxes:p}}function Wa(e,t,n=`Inter`,r=!1,i=Vn,a,o,s,c={}){let l=[];l.push(Ui(Ze(e.width,e.height,t,r,o,s,void 0,c.styleAttribute),a)),l.push(Ge(n,!1,c.nonce)),l.push(`<defs>`),l.push(Ga()),l.push(`</defs>`);for(let t of e.boxes)l.push($a(t,i));for(let t of e.blocks)l.push(eo(t,i));for(let t of e.lifelines)l.push(qa(t));for(let t of e.activations)l.push(Ya(t));for(let t of e.messages)l.push(Xa(t,i));for(let t of e.notes)l.push(to(t,i));for(let t of e.actors)l.push(Ka(t,i));return l.push(`</svg>`),l.join(`
|
|
52
|
+
`)}function Ga(){let e=Gn.width,t=Gn.height;return` <marker id="seq-arrow" markerWidth="${e}" markerHeight="${t}" refX="${e}" refY="${t/2}" orient="auto-start-reverse">\n <polygon points="0 0, ${e} ${t/2}, 0 ${t}" fill="var(--_arrow)" />\n </marker>\n <marker id="seq-arrow-open" markerWidth="${e}" markerHeight="${t}" refX="${e}" refY="${t/2}" orient="auto-start-reverse">\n <polyline points="0 0, ${e} ${t/2}, 0 ${t}" fill="none" stroke="var(--_arrow)" stroke-width="1" />\n </marker>`}function Ka(e,t){let{id:n,x:r,y:i,width:a,height:o,label:s,type:c}=e,l=[];if(l.push(`<g class="actor" data-id="${R(n)}" data-label="${R(s)}" data-type="${c}">`),c===`actor`){let e=o/24*.9,n=r-12*e,a=i+(o-24*e)/2,c=V.outerBox/e,u=`var(--_line)`;l.push(` <g transform="translate(${n},${a}) scale(${e})">\n <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="${u}" stroke-width="${c}" />\n <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="${u}" stroke-width="${c}" />\n <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="${u}" stroke-width="${c}" />\n </g>`),l.push(` `+z(s,r,i+o+14,t.nodeLabel,`font-size="${t.nodeLabel}" text-anchor="middle" font-weight="${B.nodeLabel}" fill="var(--_text)"`))}else{let e=r-a/2;l.push(` <rect x="${e}" y="${i}" width="${a}" height="${o}" rx="4" ry="4" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${V.outerBox}" />`),l.push(` `+z(s,r,i+o/2,t.nodeLabel,`font-size="${t.nodeLabel}" text-anchor="middle" font-weight="${B.nodeLabel}" fill="var(--_text)"`))}return l.push(`</g>`),l.join(`
|
|
53
|
+
`)}function qa(e){let t=`<line class="lifeline" data-actor="${R(e.actorId)}" x1="${e.x}" y1="${e.topY}" x2="${e.x}" y2="${e.bottomY}" stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`;if(!e.destroyed)return t;let{x:n,bottomY:r}=e,i=Ja;return t+`\n<path class="destroy" data-actor="${R(e.actorId)}" d="M${n-i} ${r-i} L${n+i} ${r+i} M${n+i} ${r-i} L${n-i} ${r+i}" fill="none" stroke="var(--_line)" stroke-width="${V.outerBox}" stroke-linecap="round" />`}var Ja=8;function Ya(e){return`<rect class="activation" data-actor="${R(e.actorId)}" x="${e.x}" y="${e.topY}" width="${e.width}" height="${e.bottomY-e.topY}" fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${V.innerBox}" />`}function Xa(e,t){let n=[],r=e.lineStyle===`dashed`?` stroke-dasharray="6 4"`:``,i=e.arrowHead===`filled`?`seq-arrow`:`seq-arrow-open`,a=e.bidirectional?` marker-start="url(#${i})"`:``;if(n.push(`<g class="message" data-from="${R(e.from)}" data-to="${R(e.to)}" data-label="${R(e.label)}" data-line-style="${e.lineStyle}" data-arrow-head="${e.arrowHead}" data-self="${e.isSelf}" data-bidirectional="${e.bidirectional}">`),e.isSelf)n.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="${V.connector}"${r} marker-end="url(#${i})"${a} />`),n.push(` `+z(e.label,e.x1+30+8,e.y+10,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="start" font-weight="${B.edgeLabel}" fill="var(--_text-muted)"`));else{n.push(` <line x1="${e.x1}" y1="${e.y}" x2="${e.x2}" y2="${e.y}" stroke="var(--_line)" stroke-width="${V.connector}"${r} marker-end="url(#${i})"${a} />`);let o=(e.x1+e.x2)/2;n.push(` `+z(e.label,o,e.y-10,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${B.edgeLabel}" fill="var(--_text-muted)"`))}return e.seqNumber!==void 0&&n.push(` `+Za(e,t)),n.push(`</g>`),n.join(`
|
|
54
|
+
`)}function Za(e,t){let n=Math.max(t.edgeLabel-2,8),r=e.bidirectional?e.x1+Math.sign(e.x2-e.x1)*(8+Gn.width):e.x1;return`<g class="seq-number"><circle cx="${r}" cy="${e.y}" r="8" fill="var(--bg)" stroke="var(--_arrow)" stroke-width="${V.innerBox}" />`+z(String(e.seqNumber),r,e.y,n,`font-size="${n}" text-anchor="middle" font-weight="${B.edgeLabel}" fill="var(--_arrow)"`)+`</g>`}var Qa=35;function $a(e,t){let n=e.label?` data-label="${R(e.label)}"`:``,r=e.color===void 0?``:` data-color="${R(e.color)}"`,i=e.color===void 0?`none`:`color-mix(in srgb, ${R(e.color)} ${Qa}%, var(--bg))`,a=[`<g class="participant-box"${n}${r}>`,` <rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="4" ry="4" fill="${i}" stroke="var(--_node-stroke)" stroke-width="${V.innerBox}" />`];return e.label&&a.push(` `+z(e.label,e.x+e.width/2,e.y+Va(t.edgeLabel)/2,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${B.groupHeader}" fill="var(--_text-sec)"`)),a.push(`</g>`),a.join(`
|
|
55
|
+
`)}function eo(e,t){let n=[],r=e.label?` data-label="${R(e.label)}"`:``;n.push(`<g class="block" data-type="${R(e.type)}"${r}>`),n.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="${V.outerBox}" />`);let i=`${e.type}${e.label?` [${e.label}]`:``}`,a=i.split(`
|
|
56
|
+
`)[0],o=zn(a,t.edgeLabel,B.groupHeader)+16;n.push(` <rect x="${e.x}" y="${e.y}" width="${o}" height="18" fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${V.outerBox}" />`),n.push(` `+z(i,e.x+6,e.y+9,t.edgeLabel,`font-size="${t.edgeLabel}" font-weight="${B.groupHeader}" fill="var(--_text-sec)"`));for(let r of e.dividers)n.push(` <line x1="${e.x}" y1="${r.y}" x2="${e.x+e.width}" y2="${r.y}" stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`),r.label&&n.push(` `+z(`[${r.label}]`,e.x+8,r.y+14,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="start" font-weight="${B.edgeLabel}" fill="var(--_text-muted)"`));return n.push(`</g>`),n.join(`
|
|
57
|
+
`)}function to(e,t){let{x:n,y:r,width:i,height:a}=e,o=e.actors&&e.actors.length>0?` data-actors="${e.actors.map(R).join(`,`)}"`:``;return`<g class="note"${e.position?` data-position="${R(e.position)}"`:``}${o}>\n <polygon points="${[`${n},${r}`,`${n+i-6},${r}`,`${n+i},${r+6}`,`${n+i},${r+a}`,`${n},${r+a}`].join(` `)}" fill="var(--bg)" stroke="var(--_node-stroke)" stroke-width="${V.innerBox}" />\n <polygon points="${n+i-6},${r} ${n+i},${r+6} ${n+i-6},${r+6}" fill="var(--_inner-stroke)" stroke="var(--_node-stroke)" stroke-width="${V.innerBox}" />\n ${z(e.text,n+i/2,r+a/2,t.edgeLabel,`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${B.edgeLabel}" fill="var(--_text-muted)"`)}\n</g>`}var H={plotWidth:600,plotHeight:340,padding:22,titleFontSize:18,titleFontWeight:600,titleHeight:42,axisLabelFontSize:14,axisLabelFontWeight:400,axisTitleFontSize:15,axisTitleFontWeight:500,xLabelHeight:38,yLabelWidth:58,yLabelGap:18,axisTitlePad:30,tickLength:4,barPadRatio:.2,barGroupGap:0,maxBarWidth:40,legendFontSize:14,legendFontWeight:400,legendHeight:28,legendSwatchW:14,legendSwatchH:14,legendGap:6,legendItemGap:16};function no(e,t={}){return e.horizontal?io(e):ro(e)}function ro(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,i=e.series.length>1,a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=uo(a.min,a.max),s=Math.max(...o.map(e=>zn(fo(e),H.axisLabelFontSize,H.axisLabelFontWeight)),H.yLabelWidth),c=H.padding+(t?H.titleHeight:0)+(i?H.legendHeight:0),l=H.padding+H.xLabelHeight+(n?H.axisTitlePad:0),u=H.padding+s+H.yLabelGap+(r?H.axisTitlePad:0),d=H.padding,f=H.plotWidth,p=H.plotHeight,m=u+f+d,h=c+p+l,g={x:u,y:c,width:f,height:p},_=ao(e),v=e=>u+(e+.5)*(f/_),y=f/_,b=e=>{let t=(e-a.min)/(a.max-a.min||1);return c+p-t*p},x=so(e,v,c+p,y),S=o.map(e=>({label:fo(e),x:u,y:b(e),tx:u-H.tickLength,ty:b(e),labelX:u-H.yLabelGap,labelY:b(e),textAnchor:`end`})),C=o.map(e=>({x1:u,y1:b(e),x2:u+f,y2:b(e)})),w=oo(e,_),T=e.series.map((e,t)=>t),E=co(e,v,b,y,a.min,w,T),D=lo(e,v,b,w,T),O=H.padding+(t?H.titleHeight:0)+H.legendHeight/2,k=i?po(e,m/2,O,T):[],A={x1:u,y1:c+p,x2:u+f,y2:c+p},j={x1:u,y1:c,x2:u,y2:c+p},ee={ticks:x,line:A,...e.xAxis.title?{title:{text:e.xAxis.title,x:u+f/2,y:h-H.padding}}:{}},M={ticks:S,line:j,...e.yAxis.title?{title:{text:e.yAxis.title,x:H.padding+4,y:c+p/2,rotate:-90}}:{}};return{width:m,height:h,title:e.title?{text:e.title,x:m/2,y:H.padding+H.titleFontSize}:void 0,xAxis:ee,yAxis:M,plotArea:g,bars:E,lines:D,gridLines:C,legend:k}}function io(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,i=e.series.length>1,a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=uo(a.min,a.max),s=ao(e),c=oo(e,s),l=Math.max(...c.map(e=>zn(e,H.axisLabelFontSize,H.axisLabelFontWeight)),40),u=H.padding+(t?H.titleHeight:0)+(i?H.legendHeight:0),d=H.padding+H.xLabelHeight+(r?H.axisTitlePad:0),f=H.padding+l+H.yLabelGap+(n?H.axisTitlePad:0),p=H.padding,m=H.plotWidth,h=H.plotHeight,g=f+m+p,_=u+h+d,v={x:f,y:u,width:m,height:h},y=e=>{let t=(e-a.min)/(a.max-a.min||1);return f+t*m},b=h/s,x=e=>u+(e+.5)*b,S=o.map(e=>({label:fo(e),x:y(e),y:u+h,tx:y(e),ty:u+h+H.tickLength,labelX:y(e),labelY:u+h+18,textAnchor:`middle`})),C=c.map((e,t)=>({label:e,x:f,y:x(t),tx:f-H.tickLength,ty:x(t),labelX:f-H.yLabelGap,labelY:x(t),textAnchor:`end`})),w=o.map(e=>({x1:y(e),y1:u,x2:y(e),y2:u+h})),T=e.series.map((e,t)=>t),E=e.series.filter(e=>e.type===`bar`).length,D=[];if(E>0){let t=b*(1-H.barPadRatio),n=E>1?(t-(E-1)*H.barGroupGap)/E:t,r=Math.min(n,H.maxBarWidth),i=E>1?r*E+H.barGroupGap*(E-1):r,o=0,s=0;for(let t of e.series){if(t.type!==`bar`){s++;continue}for(let e=0;e<t.data.length;e++){let n=x(e)-i/2+o*(r+H.barGroupGap),l=y(Math.max(t.data[e],a.min)),u=y(Math.max(0,a.min));D.push({x:Math.min(u,l),y:n,width:Math.abs(l-u),height:r,value:t.data[e],label:c[e],seriesIndex:o,colorIndex:T[s]})}o++,s++}}let O=[],k=0,A=0;for(let t of e.series){if(t.type!==`line`){A++;continue}let e=t.data.map((e,t)=>({x:y(e),y:x(t),value:e,label:c[t]}));O.push({points:e,seriesIndex:k,colorIndex:T[A]}),k++,A++}let j={x1:f,y1:u+h,x2:f+m,y2:u+h},ee={x1:f,y1:u,x2:f,y2:u+h},M={ticks:S,line:j,...e.yAxis.title?{title:{text:e.yAxis.title,x:f+m/2,y:_-H.padding}}:{}},N={ticks:C,line:ee,...e.xAxis.title?{title:{text:e.xAxis.title,x:H.padding+4,y:u+h/2,rotate:-90}}:{}},te=e.title?{text:e.title,x:g/2,y:H.padding+H.titleFontSize}:void 0,ne=H.padding+(t?H.titleHeight:0)+H.legendHeight/2;return{width:g,height:_,horizontal:!0,title:te,xAxis:M,yAxis:N,plotArea:v,bars:D,lines:O,gridLines:w,legend:i?po(e,g/2,ne,T):[]}}function ao(e){if(e.xAxis.categories)return e.xAxis.categories.length;for(let t of e.series)if(t.data.length>0)return t.data.length;return 1}function oo(e,t){if(e.xAxis.categories)return e.xAxis.categories;if(e.xAxis.range){let{min:n,max:r}=e.xAxis.range,i=t>1?(r-n)/(t-1):0;return Array.from({length:t},(e,t)=>fo(n+i*t))}return Array.from({length:t},(e,t)=>String(t+1))}function so(e,t,n,r){return oo(e,ao(e)).map((e,r)=>({label:e,x:t(r),y:n,tx:t(r),ty:n+H.tickLength,labelX:t(r),labelY:n+18,textAnchor:`middle`}))}function co(e,t,n,r,i,a,o){let s=e.series.filter(e=>e.type===`bar`).length;if(s===0)return[];let c=r*(1-H.barPadRatio),l=s>1?(c-(s-1)*H.barGroupGap)/s:c,u=Math.min(l,H.maxBarWidth),d=s>1?u*s+H.barGroupGap*(s-1):u,f=[],p=0,m=0;for(let r of e.series){if(r.type!==`bar`){m++;continue}for(let e=0;e<r.data.length;e++){let s=t(e)-d/2+p*(u+H.barGroupGap),c=n(r.data[e]),l=n(Math.max(0,i));f.push({x:s,y:Math.min(c,l),width:u,height:Math.abs(l-c),value:r.data[e],label:a[e],seriesIndex:p,colorIndex:o[m]})}p++,m++}return f}function lo(e,t,n,r,i){let a=[],o=0,s=0;for(let c of e.series){if(c.type!==`line`){s++;continue}let e=c.data.map((e,i)=>({x:t(i),y:n(e),value:e,label:r[i]}));a.push({points:e,seriesIndex:o,colorIndex:i[s]}),o++,s++}return a}function uo(e,t){let n=t-e;if(n<=0)return[e];let r=n/6,i=10**Math.floor(Math.log10(r)),a=r/i,o;o=a<=1.5?i:a<=3?2*i:a<=7?5*i:10*i;let s=Math.ceil(e/o)*o,c=[];for(let e=s;e<=t+o*.001;e+=o)c.push(Math.round(e*1e10)/1e10);return c}function fo(e){return Number.isInteger(e)?String(e):e.toFixed(+(Math.abs(e)<10))}function po(e,t,n,r){let i=[],a=0,o=0;for(let t=0;t<e.series.length;t++){let s=e.series[t],c=s.type===`bar`?`Bar ${a+1}`:`Line ${o+1}`;i.push({label:c,x:0,y:n,type:s.type,seriesIndex:s.type===`bar`?a:o,colorIndex:r[t]}),s.type===`bar`?a++:o++}let s=i.map(e=>{let t=zn(e.label,H.legendFontSize,H.legendFontWeight);return H.legendSwatchW+H.legendGap+t}),c=t-(s.reduce((e,t)=>e+t,0)+(i.length-1)*H.legendItemGap)/2;for(let e=0;e<i.length;e++)i[e].x=c,c+=s[e]+H.legendItemGap;return i}var U={titleSize:18,titleWeight:600,axisTitleSize:15,axisTitleWeight:500,labelSize:14,labelWeight:400,legendSize:14,legendWeight:400,dotRadius:5,lineWidth:2.5,barRadius:8},W={fontSize:15,fontWeight:500,height:32,padX:14,offsetY:12,rx:8,minY:4,pointerSize:6};function mo(e,t,n=`Inter`,r=!1,i=!1,a,o,s,c={}){let l=[],u=Math.max(0,...e.bars.map(e=>e.colorIndex),...e.lines.map(e=>e.colorIndex)),d=Ui(Ze(e.width,e.height,t,r,o,s,void 0,c.styleAttribute).replace(`<svg `,`<svg data-xychart-colors="${u}" `),a);l.push(d),l.push(Ge(n,!1,c.nonce));let f=Math.max(...e.lines.map(e=>e.points.length),0),p=f>0&&f<=12,{style:m,defs:h}=ho(e,i,p,t.accent,t.bg,c.nonce);l.push(m),h&&l.push(h);let{plotArea:g}=e,_=e.xAxis.ticks.map(e=>e.x),v=e.horizontal?e.yAxis.ticks.map(e=>e.y):e.gridLines.map(e=>e.y1),y=_.length>1?Math.abs(_[1]-_[0]):g.width/6,b=v.length>1?Math.abs(v[1]-v[0]):g.height/6,x=y/Math.max(1,Math.round(y/20)),S=b/Math.max(1,Math.round(b/20)),C=_[0]??g.x,w=v[0]??g.y,T=C-Math.ceil((C-g.x)/x)*x,E=w-Math.ceil((w-g.y)/S)*S;for(let e=E;e<=g.y+g.height+.5;e+=S)for(let t=T;t<=g.x+g.width+.5;t+=x)l.push(`<circle cx="${G(t)}" cy="${G(e)}" r="1.5" class="xychart-grid"/>`);let D=[];for(let t of e.bars){let n=` data-value="${t.value}"${t.label?` data-label="${So(t.label)}"`:``}`,r=e.horizontal?_o(t.x,t.y,t.width,t.height,U.barRadius):go(t.x,t.y,t.width,t.height,U.barRadius);if(l.push(`<path d="${r}" class="xychart-bar xychart-color-${t.colorIndex}"${n}/>`),i){let e=xo(t.value),n=t.label?`${t.label}: ${e}`:e,r=bo(t.x+t.width/2,t.y,e);D.push(`<g class="xychart-bar-group"><rect x="${G(t.x)}" y="${G(t.y)}" width="${G(t.width)}" height="${G(t.height)}" fill="transparent"/><title>${So(n)}</title>`+r+`</g>`)}}for(let t of e.lines){if(t.points.length===0)continue;let e=vo(t.points);l.push(`<path d="${e}" class="xychart-line-shadow xychart-color-${t.colorIndex}" transform="translate(0,2)"/>`),l.push(`<path d="${e}" class="xychart-line xychart-color-${t.colorIndex}"/>`)}let O=[];if(i||p){let t=new Map;for(let n of e.legend)n.type===`line`&&t.set(n.seriesIndex,n.label);let n=new Map;for(let t of e.lines)for(let e of t.points){let r=G(e.x),i=n.get(r)??[];n.set(r,i),i.push({x:e.x,y:e.y,value:e.value,label:e.label,seriesIndex:t.seriesIndex,colorIndex:t.colorIndex})}for(let e of n.values()){let n=e[0].x,r=e[0].label||``;if(i&&e.length>1){let i=Math.min(...e.map(e=>e.y)),a=Math.max(...e.map(e=>e.y)),o=U.dotRadius*3,s=`<rect x="${G(n-o)}" y="${G(i-o)}" width="${G(o*2)}" height="${G(a-i+o*2)}" fill="transparent" class="xychart-hit"/>`,c=e.map(e=>({text:xo(e.value),legendLabel:t.get(e.seriesIndex)||`Line ${e.seriesIndex+1}`})),l=yo(n,i-U.dotRadius,r,c),u=c.map(e=>e.text),d=r?`${r}: ${u.join(` · `)}`:u.join(` · `),f=`<g class="xychart-dot-group">${s}`;for(let t of e){let e=` data-value="${t.value}"${t.label?` data-label="${So(t.label)}"`:``}`;f+=`<circle cx="${G(t.x)}" cy="${G(t.y)}" r="${U.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${e}/>`}f+=`<title>${So(d)}</title>${l}</g>`,O.push(f)}else if(i){let t=e[0],r=` data-value="${t.value}"${t.label?` data-label="${So(t.label)}"`:``}`,i=xo(t.value),a=t.label?`${t.label}: ${i}`:i,o=bo(n,t.y-U.dotRadius,i),s=p?`<circle cx="${G(n)}" cy="${G(t.y)}" r="${U.dotRadius*3}" fill="transparent" class="xychart-hit"/>`:``;O.push(`<g class="xychart-dot-group">${s}<circle cx="${G(t.x)}" cy="${G(t.y)}" r="${U.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${r}/><title>${So(a)}</title>${o}</g>`)}else for(let t of e){let e=` data-value="${t.value}"${t.label?` data-label="${So(t.label)}"`:``}`;l.push(`<circle cx="${G(t.x)}" cy="${G(t.y)}" r="${U.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${e}/>`)}}}for(let t of e.xAxis.ticks)l.push(`<text x="${t.labelX}" y="${t.labelY}" text-anchor="${t.textAnchor}" font-size="${U.labelSize}" font-weight="${U.labelWeight}" dy="${Wn}" class="xychart-label">${So(t.label)}</text>`);for(let t of e.yAxis.ticks)l.push(`<text x="${t.labelX}" y="${t.labelY}" text-anchor="${t.textAnchor}" font-size="${U.labelSize}" font-weight="${U.labelWeight}" dy="${Wn}" class="xychart-label">${So(t.label)}</text>`);if(e.xAxis.title){let t=e.xAxis.title,n=t.rotate?` transform="rotate(${t.rotate},${t.x},${t.y})"`:``;l.push(`<text x="${t.x}" y="${t.y}" text-anchor="middle"${n} font-size="${U.axisTitleSize}" font-weight="${U.axisTitleWeight}" dy="${Wn}" class="xychart-axis-title">${So(t.text)}</text>`)}if(e.yAxis.title){let t=e.yAxis.title,n=t.rotate?` transform="rotate(${t.rotate},${t.x},${t.y})"`:``;l.push(`<text x="${t.x}" y="${t.y}" text-anchor="middle"${n} font-size="${U.axisTitleSize}" font-weight="${U.axisTitleWeight}" dy="${Wn}" class="xychart-axis-title">${So(t.text)}</text>`)}e.title&&l.push(`<text x="${e.title.x}" y="${e.title.y}" text-anchor="middle" font-size="${U.titleSize}" font-weight="${U.titleWeight}" dy="${Wn}" class="xychart-title">${So(e.title.text)}</text>`);for(let t of e.legend){if(t.type===`bar`)l.push(`<rect x="${t.x}" y="${t.y-7}" width="14" height="14" rx="3" class="xychart-bar xychart-color-${t.colorIndex}"/>`);else{let e=t.y;l.push(`<line x1="${t.x}" y1="${e}" x2="${t.x+14}" y2="${e}" stroke-width="${U.lineWidth}" stroke-linecap="round" class="xychart-legend-line xychart-color-${t.colorIndex}"/>`)}l.push(`<text x="${t.x+14+6}" y="${t.y}" text-anchor="start" font-size="${U.legendSize}" font-weight="${U.legendWeight}" dy="${Wn}" class="xychart-label">${So(t.label)}</text>`)}for(let e of D)l.push(e);for(let e of O)l.push(e);return l.push(`</svg>`),l.join(`
|
|
58
|
+
`)}function ho(e,t,n,r,i,a){let o=r??`#3b82f6`,s=new Set;for(let t of e.bars)s.add(t.colorIndex);for(let t of e.lines)s.add(t.colorIndex);let c=[];for(let e of[...s].sort((e,t)=>e-t)){let t=e===0?`var(--accent, ${Pt})`:zt(e,o,i);c.push(` --xychart-color-${e}: ${t};`),c.push(` --xychart-bar-fill-${e}: color-mix(in srgb, var(--bg) 75%, var(--xychart-color-${e}) 25%);`)}let l=[];for(let e of[...s].sort((e,t)=>e-t)){let t=`var(--xychart-color-${e})`;l.push(` .xychart-bar.xychart-color-${e} { stroke: ${t}; fill: var(--xychart-bar-fill-${e}); }`),l.push(` path.xychart-color-${e}, line.xychart-color-${e} { stroke: ${t}; }`),l.push(` circle.xychart-color-${e} { fill: ${t}; }`)}let u=t?`
|
|
59
59
|
.xychart-tip { opacity: 0; pointer-events: none; }
|
|
60
60
|
.xychart-tip-bg { fill: var(--_text); filter: drop-shadow(0 1px 3px color-mix(in srgb, var(--fg) 20%, transparent)); }
|
|
61
|
-
.xychart-tip-text { fill: var(--bg); font-size: ${
|
|
61
|
+
.xychart-tip-text { fill: var(--bg); font-size: ${W.fontSize}px; font-weight: ${W.fontWeight}; }
|
|
62
62
|
.xychart-tip-ptr { fill: var(--_text); }
|
|
63
63
|
.xychart-bar-group:hover .xychart-tip,
|
|
64
64
|
.xychart-dot-group:hover .xychart-tip { opacity: 1; }`:``,d=c.length>0?`\n svg {\n${c.join(`
|
|
65
|
-
`)}\n }`:``;return{style:`${
|
|
65
|
+
`)}\n }`:``;return{style:`${We(a)}
|
|
66
66
|
.xychart-grid { fill: var(--_inner-stroke); stroke: none; opacity: 0.65; }
|
|
67
67
|
.xychart-bar { stroke-width: 1.5; }
|
|
68
|
-
.xychart-line { fill: none; stroke-width: ${
|
|
68
|
+
.xychart-line { fill: none; stroke-width: ${U.lineWidth}; stroke-linecap: round; stroke-linejoin: round; }
|
|
69
69
|
.xychart-line-shadow { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.12; }
|
|
70
70
|
.xychart-dot { stroke: var(--bg); stroke-width: 2; }
|
|
71
71
|
.xychart-label { fill: var(--_text-muted); }
|
|
@@ -73,10 +73,10 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
73
73
|
.xychart-title { fill: var(--_text); }${d}
|
|
74
74
|
${l.join(`
|
|
75
75
|
`)}${u}
|
|
76
|
-
</style>`,defs:``}}function _o(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return a<=0?`M${W(e)},${W(t)} h${W(n)} v${W(r)} h${W(-n)} Z`:[`M${W(e)},${W(t+a)}`,`Q${W(e)},${W(t)} ${W(e+a)},${W(t)}`,`L${W(e+n-a)},${W(t)}`,`Q${W(e+n)},${W(t)} ${W(e+n)},${W(t+a)}`,`L${W(e+n)},${W(t+r-a)}`,`Q${W(e+n)},${W(t+r)} ${W(e+n-a)},${W(t+r)}`,`L${W(e+a)},${W(t+r)}`,`Q${W(e)},${W(t+r)} ${W(e)},${W(t+r-a)}`,`Z`].join(` `)}function vo(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return a<=0?`M${W(e)},${W(t)} h${W(n)} v${W(r)} h${W(-n)} Z`:[`M${W(e+a)},${W(t)}`,`L${W(e+n-a)},${W(t)}`,`Q${W(e+n)},${W(t)} ${W(e+n)},${W(t+a)}`,`L${W(e+n)},${W(t+r-a)}`,`Q${W(e+n)},${W(t+r)} ${W(e+n-a)},${W(t+r)}`,`L${W(e+a)},${W(t+r)}`,`Q${W(e)},${W(t+r)} ${W(e)},${W(t+r-a)}`,`L${W(e)},${W(t+a)}`,`Q${W(e)},${W(t)} ${W(e+a)},${W(t)}`,`Z`].join(` `)}function yo(e){if(e.length===0)return``;if(e.length===1)return`M${W(e[0].x)},${W(e[0].y)}`;if(e.length===2)return`M${W(e[0].x)},${W(e[0].y)} L${W(e[1].x)},${W(e[1].y)}`;let t=e.length,n=[],r=[];for(let i=0;i<t-1;i++)n.push(e[i+1].x-e[i].x),r.push(n[i]===0?0:(e[i+1].y-e[i].y)/n[i]);let i=Array(t).fill(0);if(t>2){let e=Array(t).fill(0),a=Array(t).fill(0);for(let i=1;i<t-1;i++){let t=2*(n[i-1]+n[i]),o=3*(r[i]-r[i-1]);if(i===1)e[i]=n[i]/t,a[i]=o/t;else{let r=t-n[i-1]*e[i-1];e[i]=n[i]/r,a[i]=(o-n[i-1]*a[i-1])/r}}for(let n=t-2;n>=1;n--)i[n]=a[n]-e[n]*i[n+1]}let a=Array(t).fill(0);for(let e=0;e<t-1;e++)a[e]=r[e]-n[e]*(2*i[e]+i[e+1])/3;a[t-1]=r[t-2]+n[t-2]*i[t-2]/3;let o=`M${W(e[0].x)},${W(e[0].y)}`;for(let r=0;r<t-1;r++){let t=n[r]/3,i=e[r].x+t,s=e[r].y+a[r]*t,c=e[r+1].x-t,l=e[r+1].y-a[r+1]*t;o+=` C${W(i)},${W(s)} ${W(c)},${W(l)} ${W(e[r+1].x)},${W(e[r+1].y)}`}return o}function bo(e,t,n,r){let i=Bn(n,U.fontSize,600),a=Math.max(...r.map(e=>{let t=Bn(e.legendLabel,U.fontSize,U.fontWeight),n=Bn(e.text,U.fontSize,U.fontWeight);return t+10+n})),o=Math.max(i,a)+U.padX*2,s=26+r.length*20+6,c=Math.max(U.minY,t-U.offsetY-s-U.pointerSize),l=e-o/2,u=e,d=c+s,f=U.pointerSize,p=`<polygon points="${W(u-f)},${W(d)} ${W(u+f)},${W(d)} ${W(u)},${W(d+f)}" class="xychart-tip xychart-tip-ptr"/>`,m=`<rect x="${W(l)}" y="${W(c)}" width="${W(o)}" height="${s}" rx="${U.rx}" class="xychart-tip xychart-tip-bg"/>`;m+=p;let h=c+6+10;m+=`<text x="${W(e)}" y="${W(h)}" text-anchor="middle" font-weight="600" font-size="${U.fontSize}" dy="${Gn}" class="xychart-tip xychart-tip-text">${Co(n)}</text>`;let g=l+U.padX,_=l+o-U.padX;for(let e of r)h+=20,m+=`<text x="${W(g)}" y="${W(h)}" text-anchor="start" font-size="${U.fontSize}" font-weight="${U.fontWeight}" dy="${Gn}" class="xychart-tip xychart-tip-text">${Co(e.legendLabel)}</text>`,m+=`<text x="${W(_)}" y="${W(h)}" text-anchor="end" font-size="${U.fontSize}" font-weight="${U.fontWeight}" dy="${Gn}" class="xychart-tip xychart-tip-text">${Co(e.text)}</text>`;return m}function xo(e,t,n){let r=Bn(n,U.fontSize,U.fontWeight)+U.padX*2,i=U.height,a=Math.max(U.minY,t-U.offsetY-i-U.pointerSize),o=e-r/2,s=e,c=a+i/2,l=e,u=a+i,d=U.pointerSize,f=`<polygon points="${W(l-d)},${W(u)} ${W(l+d)},${W(u)} ${W(l)},${W(u+d)}" class="xychart-tip xychart-tip-ptr"/>`;return`<rect x="${W(o)}" y="${W(a)}" width="${W(r)}" height="${i}" rx="${U.rx}" class="xychart-tip xychart-tip-bg"/>`+f+`<text x="${W(s)}" y="${W(c)}" text-anchor="middle" dy="${Gn}" class="xychart-tip xychart-tip-text">${Co(n)}</text>`}function So(e){return Number.isInteger(e)?e.toLocaleString(`en-US`):e.toFixed(+(Math.abs(e)<10))}function W(e){return String(Math.round(e*10)/10)}function Co(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function wo(e){return[e.length-1,(e[0]?.length??1)-1]}var To=`\x1B]8;;\x1B\\`;function Eo(e){return`\x1b]8;;${e.replace(/[^\x21-\x7e]/gu,e=>encodeURIComponent(e))}\x1b\\`}var Do=/\x1b\]8;[^\x07\x1b]*(?:\x1b\\|\x07)/g;function Oo(e){return e.replace(Do,``)}function ko(e,t){let n=[];for(let r=0;r<=e;r++){let e=[];for(let n=0;n<=t;n++)e.push(null);n.push(e)}return n}function Ao(e,t,n,r){let i=e[t];i===void 0||n<0||n>=i.length||(i[n]=r)}function jo(e){for(let t of e)t.reverse();return e}function Mo(e,t,n,r,i){let[a,o]=wo(t),s=Math.max(1,i?.from??1),c=Math.min(o-1,i?.to??o-1);for(let i=s;i<=c;i++){let o=-1,s=-1;for(let e=1;e<=a-1;e++)t[e]?.[i]!==` `&&(o===-1&&(o=e),s=e);if(o!==-1)for(let t=o;t<=s;t++)Ao(e,t+n.x,i+n.y,r)}}function No(e,t){let[n,r]=wo(e.canvas),i=ko(n,r);for(let n of e.nodes){if(!n.drawing||!n.drawingCoord)continue;let e=d(t.get(n.name)?.href);e!==void 0&&Mo(i,n.drawing,n.drawingCoord,e)}return i}var Po=class{current=null;advance(e){if(e===this.current)return``;let t=this.current===null?``:To;return e!==null&&(t+=Eo(e)),this.current=e,t}finish(){let e=this.current===null?``:To;return this.current=null,e}};function Fo(e,t){let n=new Po,r=``;for(let[i,a]of e.entries())r+=n.advance(t[i]??null)+a;return r+n.finish()}var Io={fg:`#27272a`,border:`#a1a1aa`,line:`#71717a`,arrow:`#52525b`,corner:`#71717a`,junction:`#a1a1aa`};function Lo(){let e=globalThis.process;if(e){if(!e.stdout?.isTTY)return`none`;let t=e.env?.COLORTERM?.toLowerCase()??``,n=e.env?.TERM?.toLowerCase()??``;return t===`truecolor`||t===`24bit`?`truecolor`:n.includes(`256color`)||n.includes(`256`)?`ansi256`:n&&n!==`dumb`?`ansi16`:`none`}return typeof document<`u`?`html`:`none`}function Ro(e){return h(e.startsWith(`#`)?e:`#${e}`)??{r:0,g:0,b:0}}var zo=`\x1B[`,Bo=`${zo}0m`;function Vo(e){let{r:t,g:n,b:r}=Ro(e);return`${zo}38;2;${t};${n};${r}m`}function Ho(e,t,n){let r=(e+t+n)/3;if(Math.max(Math.abs(e-r),Math.abs(t-r),Math.abs(n-r))<10){let e=Math.round(r/255*23);return 232+Math.min(23,Math.max(0,e))}let i=e=>e<48?0:e<115?1:Math.min(5,Math.floor((e-35)/40)),a=i(e),o=i(t),s=i(n);return 16+36*a+6*o+s}function Uo(e){let{r:t,g:n,b:r}=Ro(e);return`${zo}38;5;${Ho(t,n,r)}m`}function Wo(e){let{r:t,g:n,b:r}=Ro(e),i=.299*t+.587*n+.114*r,a=i>100?0:60,o;return o=t>180&&n<100&&r<100?31:n>180&&t<100&&r<100?32:t>150&&n>150&&r<100?33:r>180&&t<100&&n<100?34:t>150&&r>150&&n<100?35:n>150&&r>150&&t<100?36:i>200?37:i<50?30:37,`${zo}${o+a}m`}function Go(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function Ko(e,t){return`<span style="color:${e}">${Go(t)}</span>`}function qo(e,t){switch(e){case`text`:return t.fg;case`border`:return t.border;case`line`:return t.line;case`arrow`:return t.arrow;case`corner`:return t.corner??t.line;case`junction`:return t.junction??t.border;default:return t.fg}}function Jo(e,t,n){if(n===`none`)return``;let r=qo(e,t);switch(n){case`truecolor`:return Vo(r);case`ansi256`:return Uo(r);case`ansi16`:return Wo(r);default:return``}}function Yo(e,t,n,r,i){if(r===`none`)return i?Fo(e,i):e.join(``);if(r===`html`)return Xo(e,t,n);let a=new Po,o=``,s=null,c=``;for(let[l,u]of e.entries()){let e=t[l]??null,d=i?a.advance(i[l]??null):``;if(u===` `){c.length>0&&(o+=s===null?c:Jo(s,n,r)+c+Bo,c=``,s=null),o+=d+u;continue}if(e===s){c+=d+u;continue}c.length>0&&(o+=s===null?c:Jo(s,n,r)+c+Bo),c=d+u,s=e}return c.length>0&&s!==null?o+=Jo(s,n,r)+c+Bo:c.length>0&&(o+=c),o+a.finish()}function Xo(e,t,n){let r=``,i=null,a=``,o=()=>{a.length!==0&&(r+=i===null?Go(a):Ko(qo(i,n),a),a=``,i=null)};for(let[n,s]of e.entries()){let e=t[n]??null;if(s===` `){o(),r+=` `;continue}if(e===i){a+=s;continue}o(),a=s,i=e}return o(),r}function Zo(e,t,n){if(n===`none`||e.length===0)return e;if(n===`html`)return Ko(t,e);let r;switch(n){case`truecolor`:r=Vo(t);break;case`ansi256`:r=Uo(t);break;case`ansi16`:r=Wo(t);break;default:return e}return`${r}${e}${Bo}`}var Qo=/\p{Mn}|\p{Me}/u;function $o(e){return Qo.test(e)}var es=new Intl.Segmenter(void 0,{granularity:`grapheme`}),ts=`️`;function ns(e){let t=[];for(let{segment:n}of es.segment(e))t.push(n);return t}function rs(e){if(e.includes(ts))return 2;let t=!1,n=!1;for(let r of e)me(r)&&(t=!0),$o(r)||(n=!0);return t?2:+!!n}function G(e){let t=0;for(let n of ns(e))t+=rs(n);return t}function is(e){let t=[];for(let n of ns(e)){let e=rs(n);e!==0&&(t.push(n),e===2&&t.push(``))}return t}function as(e,t){let n=[];for(let r=0;r<=e;r++){let e=[];for(let n=0;n<=t;n++)e.push(` `);n.push(e)}return n}function K(e){let[t,n]=ls(e);return as(t,n)}function os(e,t){let n=[];for(let r=0;r<=e;r++){let e=[];for(let n=0;n<=t;n++)e.push(null);n.push(e)}return n}function ss(e,t,n){let r=e.length-1,i=(e[0]?.length??1)-1,a=os(Math.max(t,r),Math.max(n,i));for(let t=0;t<a.length;t++)for(let n=0;n<(a[0]?.length??0);n++)t<e.length&&n<(e[0]?.length??0)&&(a[t][n]=e[t][n]);return e.length=0,e.push(...a),e}function cs(e,t,n,r){(t>=e.length||n>=(e[0]?.length??0))&&ss(e,t,n),e[t][n]=r}function ls(e){return[e.length-1,(e[0]?.length??1)-1]}function us(e,t,n){let[r,i]=ls(e),a=as(Math.max(t,r),Math.max(n,i));for(let t=0;t<a.length;t++)for(let n=0;n<(a[0]?.length??0);n++)t<e.length&&n<(e[0]?.length??0)&&(a[t][n]=e[t][n]);return e.length=0,e.push(...a),e}function q(e,t,n,r,i){let[a,o]=ls(e);t<0||t>a||n<0||n>o||(e[t][n]=r,i&&cs(i.roleCanvas,t,n,i.role))}var ds=new Set([`─`,`│`,`┌`,`┐`,`└`,`┘`,`├`,`┤`,`┬`,`┴`,`┼`,`╴`,`╵`,`╶`,`╷`]);function fs(e){return ds.has(e)}function ps(e){return/^[a-zA-Z0-9]$/.test(e)}var ms={"─":{"│":`┼`,"┌":`┬`,"┐":`┬`,"└":`┴`,"┘":`┴`,"├":`┼`,"┤":`┼`,"┬":`┬`,"┴":`┴`},"│":{"─":`┼`,"┌":`├`,"┐":`┤`,"└":`├`,"┘":`┤`,"├":`├`,"┤":`┤`,"┬":`┼`,"┴":`┼`},"┌":{"─":`┬`,"│":`├`,"┐":`┬`,"└":`├`,"┘":`┼`,"├":`├`,"┤":`┼`,"┬":`┬`,"┴":`┼`},"┐":{"─":`┬`,"│":`┤`,"┌":`┬`,"└":`┼`,"┘":`┤`,"├":`┼`,"┤":`┤`,"┬":`┬`,"┴":`┼`},"└":{"─":`┴`,"│":`├`,"┌":`├`,"┐":`┼`,"┘":`┴`,"├":`├`,"┤":`┼`,"┬":`┼`,"┴":`┴`},"┘":{"─":`┴`,"│":`┤`,"┌":`┼`,"┐":`┤`,"└":`┴`,"├":`┼`,"┤":`┤`,"┬":`┼`,"┴":`┴`},"├":{"─":`┼`,"│":`├`,"┌":`├`,"┐":`┼`,"└":`├`,"┘":`┼`,"┤":`┼`,"┬":`┼`,"┴":`┼`},"┤":{"─":`┼`,"│":`┤`,"┌":`┼`,"┐":`┤`,"└":`┼`,"┘":`┤`,"├":`┼`,"┬":`┼`,"┴":`┼`},"┬":{"─":`┬`,"│":`┼`,"┌":`┬`,"┐":`┬`,"└":`┼`,"┘":`┼`,"├":`┼`,"┤":`┼`,"┴":`┼`},"┴":{"─":`┴`,"│":`┼`,"┌":`┼`,"┐":`┼`,"└":`┴`,"┘":`┴`,"├":`┼`,"┤":`┼`,"┬":`┼`}};function hs(e,t){return ms[e]?.[t]??e}function gs(e,t,n,...r){let[i,a]=ls(e);for(let e of r){let[n,r]=ls(e);i=Math.max(i,n+t.x),a=Math.max(a,r+t.y)}let o=as(i,a);for(let t=0;t<=i;t++)for(let n=0;n<=a;n++)t<e.length&&n<(e[0]?.length??0)&&(o[t][n]=e[t][n]);for(let e of r)for(let r=0;r<e.length;r++)for(let i=0;i<(e[0]?.length??0);i++){let a=e[r][i];if(a!==` `){let e=r+t.x,s=i+t.y,c=o[e][s];!n&&fs(a)&&fs(c)?o[e][s]=hs(c,a):ps(c)&&ps(a)||(o[e][s]=a)}}return o}function _s(e,t){let[n,r]=ls(e),i=[],a=t?.roleCanvas,o=t?.colorMode??`none`,s=t?.theme??Io,c=o===`html`?void 0:t?.linkCanvas;for(let t=0;t<=r;t++)if(o===`none`||!a){let r=[];for(let i=0;i<=n;i++)r.push(e[i][t]);if(c){let e=r.map((e,n)=>c[n]?.[t]??null);i.push(Fo(r,e))}else i.push(r.join(``))}else{let r=[],l=[],u=[];for(let i=0;i<=n;i++)r.push(e[i][t]),l.push(a[i]?.[t]??null),u.push(c?.[i]?.[t]??null);i.push(Yo(r,l,s,o,c?u:void 0))}return i.join(`
|
|
77
|
-
`)}var vs={"▲":`▼`,"▼":`▲`,"◤":`◣`,"◣":`◤`,"◥":`◢`,"◢":`◥`,"^":`v`,v:`^`,"┌":`└`,"└":`┌`,"┐":`┘`,"┘":`┐`,"┬":`┴`,"┴":`┬`,"╵":`╷`,"╷":`╵`};function ys(e){for(let t of e)t.reverse();for(let t of e)for(let[e,n]of t.entries()){let r=vs[n];r&&(t[e]=r)}return e}function bs(e){for(let t of e)t.reverse();return e}function xs(e,t,n,r=!1){let i=
|
|
78
|
-
`)}function Us(e,t,n,r,i){if(i===`none`)return e.join(``);let a=``,o=null,s=``;for(let c=0;c<e.length;c++){let l=e[c];if(l===` `){s.length>0&&(a+=o?
|
|
79
|
-
`)}function Lc(e){let t=$(e);return Math.max(...t.map(e=>G(e)),0)}function Rc(e){return $(e).length}var zc={rectangle:{unicode:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`+`,tr:`+`,bl:`+`,br:`+`}},rounded:{unicode:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`},ascii:{tl:`.`,tr:`.`,bl:`'`,br:`'`}},circle:{unicode:{tl:`◯`,tr:`◯`,bl:`◯`,br:`◯`},ascii:{tl:`o`,tr:`o`,bl:`o`,br:`o`}},doublecircle:{unicode:{tl:`◎`,tr:`◎`,bl:`◎`,br:`◎`},ascii:{tl:`@`,tr:`@`,bl:`@`,br:`@`}},diamond:{unicode:{tl:`◇`,tr:`◇`,bl:`◇`,br:`◇`},ascii:{tl:`<`,tr:`>`,bl:`<`,br:`>`}},hexagon:{unicode:{tl:`⌜`,tr:`⌝`,bl:`⌞`,br:`⌟`},ascii:{tl:`*`,tr:`*`,bl:`*`,br:`*`}},stadium:{unicode:{tl:`(`,tr:`)`,bl:`(`,br:`)`},ascii:{tl:`(`,tr:`)`,bl:`(`,br:`)`}},subroutine:{unicode:{tl:`╟`,tr:`╢`,bl:`╟`,br:`╢`},ascii:{tl:`|`,tr:`|`,bl:`|`,br:`|`}},cylinder:{unicode:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`},ascii:{tl:`.`,tr:`.`,bl:`'`,br:`'`}},asymmetric:{unicode:{tl:`▷`,tr:`┐`,bl:`▷`,br:`┘`},ascii:{tl:`>`,tr:`+`,bl:`>`,br:`+`}},trapezoid:{unicode:{tl:`/`,tr:`\\`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`\\`,bl:`+`,br:`+`}},"trapezoid-alt":{unicode:{tl:`┌`,tr:`┐`,bl:`\\`,br:`/`},ascii:{tl:`+`,tr:`+`,bl:`\\`,br:`/`}},parallelogram:{unicode:{tl:`/`,tr:`/`,bl:`/`,br:`/`},ascii:{tl:`/`,tr:`/`,bl:`/`,br:`/`}},"parallelogram-alt":{unicode:{tl:`\\`,tr:`\\`,bl:`\\`,br:`\\`},ascii:{tl:`\\`,tr:`\\`,bl:`\\`,br:`\\`}},"state-start":{unicode:{tl:`●`,tr:`●`,bl:`●`,br:`●`},ascii:{tl:`*`,tr:`*`,bl:`*`,br:`*`}},"state-end":{unicode:{tl:`◉`,tr:`◉`,bl:`◉`,br:`◉`},ascii:{tl:`@`,tr:`@`,bl:`@`,br:`@`}},document:{unicode:{tl:`┌`,tr:`┐`,bl:`╰`,br:`╮`},ascii:{tl:`+`,tr:`+`,bl:`'`,br:`~`}},"stacked-document":{unicode:{tl:`┌`,tr:`╗`,bl:`╰`,br:`╮`},ascii:{tl:`+`,tr:`#`,bl:`'`,br:`~`}},"stacked-process":{unicode:{tl:`┌`,tr:`╗`,bl:`└`,br:`╝`},ascii:{tl:`+`,tr:`#`,bl:`+`,br:`#`}},card:{unicode:{tl:`╱`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`+`,bl:`+`,br:`+`}},"lined-process":{unicode:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`+`,tr:`+`,bl:`+`,br:`+`}},"divided-process":{unicode:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`+`,tr:`+`,bl:`+`,br:`+`}},"window-pane":{unicode:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`+`,tr:`+`,bl:`+`,br:`+`}},triangle:{unicode:{tl:`╱`,tr:`╲`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`\\`,bl:`+`,br:`+`}},"flipped-triangle":{unicode:{tl:`┌`,tr:`┐`,bl:`╲`,br:`╱`},ascii:{tl:`+`,tr:`+`,bl:`\\`,br:`/`}},"filled-circle":{unicode:{tl:`●`,tr:`●`,bl:`●`,br:`●`},ascii:{tl:`*`,tr:`*`,bl:`*`,br:`*`}},"crossed-circle":{unicode:{tl:`╳`,tr:`╳`,bl:`╳`,br:`╳`},ascii:{tl:`X`,tr:`X`,bl:`X`,br:`X`}},"fork-join":{unicode:{tl:`━`,tr:`━`,bl:`━`,br:`━`},ascii:{tl:`=`,tr:`=`,bl:`=`,br:`=`}},"notched-pentagon":{unicode:{tl:`╱`,tr:`╲`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`\\`,bl:`+`,br:`+`}},"sloped-rectangle":{unicode:{tl:`╱`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`+`,bl:`+`,br:`+`}},flag:{unicode:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`},ascii:{tl:`~`,tr:`~`,bl:`~`,br:`~`}},"bow-tie-rectangle":{unicode:{tl:`╲`,tr:`╱`,bl:`╱`,br:`╲`},ascii:{tl:`\\`,tr:`/`,bl:`/`,br:`\\`}},"half-rounded-rectangle":{unicode:{tl:`┌`,tr:`╮`,bl:`└`,br:`╯`},ascii:{tl:`+`,tr:`.`,bl:`+`,br:`'`}},brace:{unicode:{tl:`╭`,tr:`┐`,bl:`╰`,br:`┘`},ascii:{tl:`{`,tr:`+`,bl:`{`,br:`+`}},"brace-right":{unicode:{tl:`┌`,tr:`╮`,bl:`└`,br:`╯`},ascii:{tl:`+`,tr:`}`,bl:`+`,br:`}`}},braces:{unicode:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`},ascii:{tl:`{`,tr:`}`,bl:`{`,br:`}`}},bolt:{unicode:{tl:`╱`,tr:`╲`,bl:`╲`,br:`╱`},ascii:{tl:`/`,tr:`\\`,bl:`\\`,br:`/`}},text:{unicode:{tl:` `,tr:` `,bl:` `,br:` `},ascii:{tl:` `,tr:` `,bl:` `,br:` `}},anchor:{unicode:{tl:` `,tr:` `,bl:` `,br:` `},ascii:{tl:` `,tr:` `,bl:` `,br:` `}}};function Bc(e,t){let n=zc[e]??zc.rectangle;return t?n.ascii:n.unicode}function Vc(e,t){let n=$(e),r=Math.max(...n.map(e=>G(e)),0),i=n.length,a=2*t.padding+r,o=a+2,s=i+2*t.padding,c=s%2==0?s+1:s;return{width:o,height:c+2,labelArea:{x:1+t.padding,y:1+t.padding,width:r,height:i},gridColumns:[1,a,1],gridRows:[1,c,1]}}function Hc(e,t,n,r){let{width:i,height:a}=t,o=as(i-1,a-1),s={x:0,y:0},c={x:i-1,y:a-1},l=r?`-`:`─`,u=r?`|`:`│`;for(let e=s.x+1;e<c.x;e++)o[e][s.y]=l,o[e][c.y]=l;for(let e=s.y+1;e<c.y;e++)o[s.x][e]=u,o[c.x][e]=u;o[s.x][s.y]=n.tl,o[c.x][s.y]=n.tr,o[s.x][c.y]=n.bl,o[c.x][c.y]=n.br;let d=$(e),f=i-1,p=a-1,m=Math.floor(p/2)-Math.floor((d.length-1)/2);for(let e=0;e<d.length;e++){let t=d[e],n=Math.floor(f/2)-Math.ceil(G(t)/2)+1,r=is(t);for(let t=0;t<r.length;t++){let i=n+t,a=m+e;i>=0&&i<o.length&&a>=0&&a<o[0].length&&(o[i][a]=r[t])}}return o}function Uc(e,t,n){let{width:r,height:i}=t,a=n.x+Math.floor(r/2),o=n.y+Math.floor(i/2);return Q(e,J)?{x:a,y:n.y}:Q(e,Y)?{x:a,y:n.y+i-1}:Q(e,X)?{x:n.x,y:o}:Q(e,Z)?{x:n.x+r-1,y:o}:Q(e,Ys)?{x:n.x,y:n.y}:Q(e,Js)?{x:n.x+r-1,y:n.y}:Q(e,Zs)?{x:n.x,y:n.y+i-1}:Q(e,Xs)?{x:n.x+r-1,y:n.y+i-1}:{x:a,y:o}}var Wc={getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`rectangle`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc},Gc=new Map([[`rectangle`,Wc],[`rounded`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`rounded`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`diamond`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`diamond`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`stadium`,{getDimensions(e,t){let n=$(e),r=Math.max(...n.map(e=>G(e)),0),i=n.length,a=2*t.padding+r,o=a+4,s=i+2*t.padding;return{width:o,height:Math.max(s+2,3),labelArea:{x:2+t.padding,y:1+t.padding,width:r,height:i},gridColumns:[2,a,2],gridRows:[1,s,1]}},render(e,t,n){let{width:r,height:i}=t,a=as(r-1,i-1),o=Math.floor(i/2),s=n.useAscii?`-`:`─`;if(i===3)a[0][o]=`(`,a[r-1][o]=`)`;else if(n.useAscii){for(let e=0;e<i;e++)a[0][e]=`(`,a[r-1][e]=`)`;for(let e=1;e<r-1;e++)a[e][0]=s,a[e][i-1]=s}else{a[0][0]=`╭`;for(let e=1;e<r-1;e++)a[e][0]=s;a[r-1][0]=`╮`;for(let e=1;e<i-1;e++)a[0][e]=`│`,a[r-1][e]=`│`;a[0][i-1]=`╰`;for(let e=1;e<r-1;e++)a[e][i-1]=s;a[r-1][i-1]=`╯`}let c=$(e),l=o-Math.floor((c.length-1)/2);for(let e=0;e<c.length;e++){let t=c[e],n=Math.floor(r/2)-Math.floor(G(t)/2),o=is(t);for(let t=0;t<o.length;t++){let s=n+t,c=l+e;s>0&&s<r-1&&c>=0&&c<i&&(a[s][c]=o[t])}}return a},getAttachmentPoint:Uc}],[`circle`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`circle`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`subroutine`,{getDimensions(e,t){let n=$(e),r=Math.max(...n.map(e=>G(e)),0),i=n.length,a=2*t.padding+r,o=a+4,s=i+2*t.padding;return{width:o,height:s+2,labelArea:{x:2+t.padding,y:1+t.padding,width:r,height:i},gridColumns:[2,a,2],gridRows:[1,s,1]}},render(e,t,n){let{width:r,height:i}=t,a=as(r-1,i-1),o=n.useAscii?`-`:`─`,s=n.useAscii?`|`:`│`;a[0][0]=n.useAscii?`+`:`┌`,a[1][0]=n.useAscii?`+`:`┬`;for(let e=2;e<r-2;e++)a[e][0]=o;a[r-2][0]=n.useAscii?`+`:`┬`,a[r-1][0]=n.useAscii?`+`:`┐`;for(let e=1;e<i-1;e++)a[0][e]=s,a[1][e]=s,a[r-2][e]=s,a[r-1][e]=s;a[0][i-1]=n.useAscii?`+`:`└`,a[1][i-1]=n.useAscii?`+`:`┴`;for(let e=2;e<r-2;e++)a[e][i-1]=o;a[r-2][i-1]=n.useAscii?`+`:`┴`,a[r-1][i-1]=n.useAscii?`+`:`┘`;let c=$(e),l=Math.floor(i/2)-Math.floor((c.length-1)/2);for(let e=0;e<c.length;e++){let t=c[e],n=Math.floor(r/2)-Math.floor(G(t)/2),o=is(t);for(let t=0;t<o.length;t++){let s=n+t,c=l+e;s>1&&s<r-2&&c>0&&c<i-1&&(a[s][c]=o[t])}}return a},getAttachmentPoint:Uc}],[`doublecircle`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`doublecircle`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`hexagon`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`hexagon`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`cylinder`,{getDimensions(e,t){let n=$(e),r=Math.max(...n.map(e=>G(e)),0),i=n.length,a=2*t.padding+r,o=a+2,s=i+2*t.padding+2;return{width:o,height:s+2,labelArea:{x:1+t.padding,y:2+t.padding,width:r,height:i},gridColumns:[1,a,1],gridRows:[2,s-2,2]}},render(e,t,n){let{width:r,height:i}=t,a=as(r-1,i-1),o=n.useAscii?`-`:`─`,s=n.useAscii?`|`:`│`;a[0][0]=n.useAscii?`.`:`╭`;for(let e=1;e<r-1;e++)a[e][0]=o;a[r-1][0]=n.useAscii?`.`:`╮`,a[0][1]=s;for(let e=1;e<r-1;e++)a[e][1]=o;a[r-1][1]=s;for(let e=2;e<i-2;e++)a[0][e]=s,a[r-1][e]=s;a[0][i-2]=s;for(let e=1;e<r-1;e++)a[e][i-2]=o;a[r-1][i-2]=s,a[0][i-1]=n.useAscii?`'`:`╰`;for(let e=1;e<r-1;e++)a[e][i-1]=o;a[r-1][i-1]=n.useAscii?`'`:`╯`;let c=$(e),l=Math.floor(i/2)-Math.floor((c.length-1)/2);for(let e=0;e<c.length;e++){let t=c[e],n=Math.floor(r/2)-Math.floor(G(t)/2),o=is(t);for(let t=0;t<o.length;t++){let s=n+t,c=l+e;s>0&&s<r-1&&c>1&&c<i-2&&(a[s][c]=o[t])}}return a},getAttachmentPoint:Uc}],[`asymmetric`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`asymmetric`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`trapezoid`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`trapezoid`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`trapezoid-alt`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`trapezoid-alt`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`parallelogram`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`parallelogram`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`parallelogram-alt`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`parallelogram-alt`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`state-start`,{getDimensions(e,t){return{width:5,height:3,labelArea:{x:2,y:1,width:1,height:1},gridColumns:[1,3,1],gridRows:[1,1,1]}},render(e,t,n){let{width:r,height:i}=t,a=as(r-1,i-1),o=Math.floor(r/2);return n.useAscii?(a[0][0]=`.`,a[1][0]=`-`,a[2][0]=`-`,a[3][0]=`-`,a[4][0]=`.`,a[0][1]=`|`,a[o][1]=`*`,a[4][1]=`|`,a[0][2]=`'`,a[1][2]=`-`,a[2][2]=`-`,a[3][2]=`-`,a[4][2]=`'`):(a[0][0]=`╭`,a[1][0]=`─`,a[2][0]=`─`,a[3][0]=`─`,a[4][0]=`╮`,a[0][1]=`│`,a[o][1]=`●`,a[4][1]=`│`,a[0][2]=`╰`,a[1][2]=`─`,a[2][2]=`─`,a[3][2]=`─`,a[4][2]=`╯`),a},getAttachmentPoint(e,t,n){let{width:r,height:i}=t,a=n.x+Math.floor(r/2),o=n.y+Math.floor(i/2);return Q(e,J)?{x:a,y:n.y}:Q(e,Y)?{x:a,y:n.y+i-1}:Q(e,X)?{x:n.x,y:o}:Q(e,Z)?{x:n.x+r-1,y:o}:{x:a,y:o}}}],[`state-end`,{getDimensions(e,t){return{width:5,height:3,labelArea:{x:2,y:1,width:1,height:1},gridColumns:[1,3,1],gridRows:[1,1,1]}},render(e,t,n){let{width:r,height:i}=t,a=as(r-1,i-1),o=Math.floor(r/2);return n.useAscii?(a[0][0]=`#`,a[1][0]=`=`,a[2][0]=`=`,a[3][0]=`=`,a[4][0]=`#`,a[0][1]=`#`,a[o][1]=`*`,a[4][1]=`#`,a[0][2]=`#`,a[1][2]=`=`,a[2][2]=`=`,a[3][2]=`=`,a[4][2]=`#`):(a[0][0]=`╔`,a[1][0]=`═`,a[2][0]=`═`,a[3][0]=`═`,a[4][0]=`╗`,a[0][1]=`║`,a[o][1]=`◎`,a[4][1]=`║`,a[0][2]=`╚`,a[1][2]=`═`,a[2][2]=`═`,a[3][2]=`═`,a[4][2]=`╝`),a},getAttachmentPoint(e,t,n){let{width:r,height:i}=t,a=n.x+Math.floor(r/2),o=n.y+Math.floor(i/2);return Q(e,J)?{x:a,y:n.y}:Q(e,Y)?{x:a,y:n.y+i-1}:Q(e,X)?{x:n.x,y:o}:Q(e,Z)?{x:n.x+r-1,y:o}:{x:a,y:o}}}]]);function Kc(e){return Gc.get(e)??Wc}function qc(e,t,n){return Kc(e).getDimensions(t,n)}function Jc(e,t,n,r){return Kc(e).getAttachmentPoint(t,n,r)}function Yc(e,t,n){let r=n?{x:t.x+n.x,y:t.y+n.y}:t,i=0;for(let t=0;t<r.x;t++)i+=e.columnWidth.get(t)??0;let a=0;for(let t=0;t<r.y;t++)a+=e.rowHeight.get(t)??0;let o=e.columnWidth.get(r.x)??0,s=e.rowHeight.get(r.y)??0;return{x:i+Math.floor(o/2)+e.offsetX,y:a+Math.floor(s/2)+e.offsetY}}function Xc(e,t){return t.map(t=>Yc(e,t))}function Zc(e,t,n,r){let i=r??cl(e,t);return pc(e.grid,n,3)?(mc(e.grid,n,3),t.gridCoord=n,n):i===`LR`?Zc(e,t,{x:n.x,y:n.y+4},i):Zc(e,t,{x:n.x+4,y:n.y},i)}function Qc(e,t){let n=oc(t),r=e.config.boxBorderPadding,i=qc(t.shape,t.displayLabel,{useAscii:e.config.useAscii,padding:r}),a=i.gridColumns,o=i.gridRows;for(let t=0;t<a.length;t++){let r=n.x+t,i=e.columnWidth.get(r)??0;e.columnWidth.set(r,Math.max(i,a[t]))}for(let t=0;t<o.length;t++){let r=n.y+t,i=e.rowHeight.get(r)??0;e.rowHeight.set(r,Math.max(i,o[t]))}if(n.x>0){let t=e.columnWidth.get(n.x-1)??0;e.columnWidth.set(n.x-1,Math.max(t,e.config.paddingX))}if(n.y>0){let r=e.config.paddingY;ll(e,t)&&(r+=4);let i=e.rowHeight.get(n.y-1)??0;e.rowHeight.set(n.y-1,Math.max(i,r))}}function $c(e,t){for(let n of t)e.columnWidth.has(n.x)||e.columnWidth.set(n.x,Math.floor(e.config.paddingX/2)),e.rowHeight.has(n.y)||e.rowHeight.set(n.y,Math.floor(e.config.paddingY/2))}var el=8;function tl(e,t,n,r){let i=[];try{for(let a=0;a<el;a++){let a=Fc(r,n,t.path,t.style);if(!a)return;e.grid.add(ac(a)),i.push(a),Ll(e,t)}}finally{for(let t of i)e.grid.delete(ac(t))}}function nl(e,t){return e.subgraphs.some(e=>e.nodes.includes(t))}function rl(e,t){let n=null;for(let r of e.subgraphs)r.nodes.includes(t)&&(!n||il(n,r))&&(n=r);return n}function il(e,t){let n=t;for(;n!==null;){if(n===e)return!0;n=n.parent}return!1}function al(e,t){let n=rl(e,t);if(!n)return null;let r=n;for(;r.parent;)r=r.parent;return r}function ol(e){let t=[...e.nodes];for(let n of e.children)t.push(...ol(n));return t}function sl(e,t,n){if(t===n)return!0;let r=new Set([t]),i=[t];for(;i.length>0;){let t=i.shift();for(let a of wl(e,t)){if(a===n)return!0;r.has(a)||(r.add(a),i.push(a))}}return!1}function cl(e,t){let n=rl(e,t);return n?.direction?n.direction:e.config.graphDirection}function ll(e,t){let n=rl(e,t);if(!n)return!1;let r=!1;for(let i of e.edges)if(i.to===t&&rl(e,i.from)!==n){r=!0;break}if(!r)return!1;let i=oc(t).y;for(let r of n.nodes){if(r===t||!r.gridCoord)continue;let a=!1;for(let t of e.edges)if(t.to===r&&rl(e,t.from)!==n){a=!0;break}if(a&&r.gridCoord.y<i)return!1}return!0}function ul(e,t){if(t.nodes.length===0)return;let n=1e6,r=1e6,i=-1e6,a=-1e6;for(let o of t.children)ul(e,o),o.nodes.length>0&&(n=Math.min(n,o.minX),r=Math.min(r,o.minY),i=Math.max(i,o.maxX),a=Math.max(a,o.maxY));for(let e of t.nodes){if(!e.drawingCoord||!e.drawing)continue;let t=e.drawingCoord.x,o=e.drawingCoord.y,s=t+e.drawing.length-1,c=o+e.drawing[0].length-1;n=Math.min(n,t),r=Math.min(r,o),i=Math.max(i,s),a=Math.max(a,c)}t.minX=n-2,t.minY=r-2-2,t.maxX=i+2,t.maxY=a+2;let o=Math.max(0,...$(t.name).map(e=>G(e))),s=t.maxX-t.minX,c=o+1;if(c>s){let e=c-s,n=Math.floor(e/2),r=e-n;t.minX-=n,t.maxX+=r}}function dl(e){let t=e.subgraphs.filter(e=>e.parent===null&&e.nodes.length>0);for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let r=t[e],i=t[n];r.minX<i.maxX&&r.maxX>i.minX&&(r.maxY>=i.minY-1&&r.minY<i.minY?i.minY=r.maxY+1+1:i.maxY>=r.minY-1&&i.minY<r.minY&&(r.minY=i.maxY+1+1)),r.minY<i.maxY&&r.maxY>i.minY&&(r.maxX>=i.minX-1&&r.minX<i.minX?i.minX=r.maxX+1+1:i.maxX>=r.minX-1&&i.minX<r.minX&&(r.minX=i.maxX+1+1))}}function fl(e){for(let t of e.subgraphs)ul(e,t);dl(e)}function pl(e){if(e.subgraphs.length===0)return;let t=0,n=0;for(let r of e.subgraphs)t=Math.min(t,r.minX),n=Math.min(n,r.minY);let r=-t,i=-n;if(r!==0||i!==0){e.offsetX=r,e.offsetY=i;for(let t of e.subgraphs)t.minX+=r,t.minY+=i,t.maxX+=r,t.maxY+=i;for(let t of e.nodes)t.drawingCoord&&(t.drawingCoord.x+=r,t.drawingCoord.y+=i)}}function ml(e,t){let n=t=>{let n=wl(e,t);return n.length>0?n[0].name:null},r=new Map,i=t.map((e,t)=>{let i=n(e);if(i===null)return t;let a=r.get(i);return a===void 0?(r.set(i,t),t):a});return t.map((e,t)=>({node:e,i:t})).sort((e,t)=>i[e.i]-i[t.i]||e.i-t.i).map(({node:e})=>e)}function hl(e,t){let n=new Set,r=t=>{let r=[t];for(;r.length>0;){let t=r.shift();if(!n.has(t.name)){n.add(t.name);for(let n of wl(e,t))r.push(n)}}};for(let e of t)r(e);let i=[...t];for(let t of e.nodes)n.has(t.name)||(i.push(t),r(t));return i}function gl(e,t){return e.nodes.find(e=>e.gridCoord!==null&&e.gridCoord.x===t.x&&e.gridCoord.y===t.y)}function _l(e,t,n,r,i){let a=r===`x`?`y`:`x`,o=i=>{let o=4;for(;;){let s=t[r]+i*o;if(s<0)return null;let c=r===`x`?{x:s,y:t[a]}:{x:t[a],y:s};if(pc(e.grid,c,3))return c;let l=gl(e,c);if(!l||al(e,l)!==n)return null;o+=4}};return o(i)??o(i*-1)}function vl(e,t,n,r){let i=al(e,t);if(!i)return;let a=n.get(i);if(!a)return;n.delete(i);let o=oc(t),s=cl(e,t)===`LR`?`y`:`x`;for(let t of a){let n=cl(e,t),a=_l(e,o,i,s,1);Zc(e,e.nodes[t.index],a??o,n),r.add(t)}}function yl(e,t){let n=!0;for(;n;){n=!1;let r=t=>e.config.graphDirection===`LR`?t.gridCoord?.y??0:t.gridCoord?.x??0,i=e.nodes.filter(e=>e.gridCoord!==null).sort((e,t)=>r(e)-r(t));for(let r of i){let i=r.gridCoord;if(i===null)continue;let a=[...wl(e,r)].sort((t,n)=>Cl(e,t,n));for(let o of a){if(o.gridCoord!==null)continue;let a=rl(e,r),s=rl(e,o),c=a&&a===s&&a.direction?a.direction:e.config.graphDirection,l=c===`LR`?i.x+4:i.y+4,u;u=c===e.config.graphDirection?t[l]??0:c===`LR`?i.y:i.x;let d=c===`LR`?{x:l,y:u}:{x:u,y:l};Zc(e,e.nodes[o.index],d,c),c===e.config.graphDirection&&(t[l]=u+4),n=!0}}}}function bl(e){let t=e.config.graphDirection,n=[],r=new Set;for(let t of e.edges)t.from!==t.to&&r.add(t.to.name);let i=hl(e,e.nodes.filter(e=>!r.has(e.name))).filter(t=>{let n=rl(e,t);if(!n)return!0;for(let r of e.edges)if(r.to===t&&rl(e,r.from)!==n)return!1;return!0}),a=new Set(i),o=[],s=[];for(let t of i){let n=al(e,t);n!==null&&ol(n).some(n=>n!==t&&!a.has(n)&&!sl(e,t,n))?o.push(t):s.push(t)}let c=ml(e,s),l=new Map;for(let t of o){let n=al(e,t),r=l.get(n);r?r.push(t):l.set(n,[t])}let u=new Set,d=!1,f=!1;for(let t of c)nl(e,t)?wl(e,t).length>0&&(f=!0):d=!0;let p=t===`LR`&&d&&f,m,h=[];p?(m=c.filter(t=>!nl(e,t)),h=c.filter(t=>nl(e,t))):m=c;for(let r of m){let i=t===`LR`?{x:0,y:n[0]??0}:{x:n[0]??0,y:0};Zc(e,e.nodes[r.index],i),n[0]=(n[0]??0)+4,vl(e,r,l,u)}if(p&&h.length>0)for(let r of h){let i=t===`LR`?{x:4,y:n[4]??0}:{x:n[4]??0,y:4};Zc(e,e.nodes[r.index],i),n[4]=(n[4]??0)+4,vl(e,r,l,u)}yl(e,n);for(let t of o){if(u.has(t))continue;let r=al(e,t),i=cl(e,t),a=ol(r).filter(e=>e!==t&&e.gridCoord!==null),o;if(a.length>0){let t=a[0];for(let e of a)(i===`LR`?e.gridCoord.x<t.gridCoord.x:e.gridCoord.y<t.gridCoord.y)&&(t=e);let n=i===`LR`?`y`:`x`;o=_l(e,t.gridCoord,r,n,1)??{x:t.gridCoord.x,y:t.gridCoord.y}}else o=i===`LR`?{x:0,y:n[0]??0}:{x:n[0]??0,y:0},n[0]=(n[0]??0)+4;Zc(e,e.nodes[t.index],o,i)}yl(e,n);for(let t of e.nodes)Qc(e,t);e.pathBudget=Sc(),Fl(e),e.bundles=kc(e),Nc(e);let g=Pc(),_=uc(e.grid);for(let t of e.edges){if(t.bundle&&t.path.length>0){$c(e,t.path),Ic(_,g,t.path,t.style),Bl(e,t);continue}Ll(e,t),tl(e,t,g,_),$c(e,t.path),Ic(_,g,t.path,t.style),Bl(e,t)}for(let t of e.nodes)t.drawingCoord=Yc(e,oc(t)),t.drawing=_u(t,e);Ss(e.canvas,e.columnWidth,e.rowHeight),Cs(e.roleCanvas,e.columnWidth,e.rowHeight),fl(e),pl(e)}function xl(e,t){return e.edges.filter(e=>e.from.name===t.name)}function Sl(e,t){let n=rl(e,t),r=[],i=n;for(;i!==null;)r.unshift(i),i=i.parent;return r}function Cl(e,t,n){let r=Sl(e,t),i=Sl(e,n),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=r[a],s=i[a];return!o||!s||o===s?0:e.subgraphs.indexOf(s)-e.subgraphs.indexOf(o)}function wl(e,t){return xl(e,t).map(e=>e.to)}function Tl(e){return e===J?Y:e===Y?J:e===X?Z:e===Z?X:e===Js?Zs:e===Ys?Xs:e===Xs?Ys:e===Zs?Js:Qs}function El(e,t){return e.x===t.x?e.y<t.y?Y:J:e.y===t.y?e.x<t.x?Z:X:e.x<t.x?e.y<t.y?Xs:Js:e.y<t.y?Zs:Ys}function Dl(e){return e===`LR`?[Z,Y,Y,Z]:[Y,Z,Z,Y]}function Ol(e,t){if(e.from===e.to)return Dl(t);let n=El(oc(e.from),oc(e.to)),r,i,a,o,s=t===`LR`?Q(n,X)||Q(n,Ys)||Q(n,Zs):Q(n,J)||Q(n,Ys)||Q(n,Js);return Q(n,Xs)?t===`LR`?(r=Y,i=X,a=Z,o=J):(r=Z,i=J,a=Y,o=X):Q(n,Js)?t===`LR`?(r=J,i=X,a=Z,o=Y):(r=Z,i=Y,a=J,o=X):Q(n,Zs)?t===`LR`?(r=Y,i=Y,a=X,o=J):(r=X,i=J,a=Y,o=Z):Q(n,Ys)?t===`LR`?(r=Y,i=Y,a=X,o=Y):(r=Z,i=Z,a=J,o=Z):s?t===`LR`&&Q(n,X)?(r=Y,i=Y,a=X,o=Z):t===`TD`&&Q(n,J)?(r=Z,i=Z,a=J,o=Y):(r=n,i=Tl(n),a=n,o=Tl(n)):(r=n,i=Tl(n),a=n,o=Tl(n)),[r,i,a,o]}var kl=2,Al=200;function jl(e,t){let n=e.gridCoord;return n?t.x>=n.x&&t.x<=n.x+2&&t.y>=n.y&&t.y<=n.y+2:!1}function Ml(e,t,n=[]){for(let r=1;r<t.length-1;r++){let i=t[r];if(dc(e.grid,i)&&!n.some(e=>jl(e,i)))return!1}return!0}function Nl(e){let t=e.from.gridCoord,n=e.to.gridCoord;return!t||!n?!1:t.y===n.y&&t.x!==n.x}function Pl(e){let t=e.from.name,n=e.to.name;return Nl(e)&&n<t?JSON.stringify([n,t]):JSON.stringify([t,n])}function Fl(e){let t=new Map;for(let n of e.edges){if(n.from===n.to)continue;let e=Pl(n),r=t.get(e);r?r.push(n):t.set(e,[n])}for(let e of t.values()){if(e.length<2)continue;let t=new Set;for(let n=0;n<e.length;n++)e[n].parallelLane={index:n,total:e.length,usedOffsets:t}}}function Il(e,t,n,r,i){let a=ic(oc(t.from),n),o=ic(oc(t.to),r),s=Q(n,X)||Q(n,Z),c=[t.from,t.to],l=t.parallelLane.usedOffsets,u=Q(n,Z)?1:Q(n,X)?-1:Q(n,Y)?1:-1,d=Q(r,Z)?1:Q(r,X)?-1:Q(r,Y)?1:-1,f=s?{x:a.x+u,y:a.y}:{x:a.x,y:a.y+u},p=s?{x:o.x+d,y:o.y}:{x:o.x,y:o.y+d},m=[a,o],h=[a,o],g=kl*i;for(let t=0;t<Al;t++){let n=g+t;if(l.has(n))continue;let r=a.y+n,i=a.x+n,u=s?[{x:a.x,y:r},{x:o.x,y:r}]:[{x:i,y:a.y},{x:i,y:o.y}],d=wc([a,...u,o]);if(Ml(e,gc(d),c))return l.add(n),{path:d,labelSegment:u};m=d,h=u;let _=s?f.x!==p.x:f.y!==p.y,v=s?_?[{x:f.x,y:r},{x:p.x,y:r}]:[{x:f.x,y:r},{x:f.x,y:r}]:_?[{x:i,y:f.y},{x:i,y:p.y}]:[{x:i,y:f.y},{x:i,y:f.y}],y=wc(s?[a,f,{x:f.x,y:r},{x:p.x,y:r},p,o]:[a,f,{x:i,y:f.y},{x:i,y:p.y},p,o]);if(Ml(e,gc(y),c))return l.add(n),{path:y,labelSegment:v};m=y,h=v}return{path:m,labelSegment:h}}function Ll(e,t){let n=rl(e,t.from),r=rl(e,t.to),[i,a,o,s]=Ol(t,n&&n===r&&n.direction?n.direction:e.config.graphDirection);if(t.parallelLane&&t.parallelLane.index>0){let n=Q(i,a),r=n?o:i,c=n?s:a;t.startDir=r,t.endDir=c;let l=Il(e,t,r,c,t.parallelLane.index);t.path=l.path,t.text.length>0&&Hl(e,t,l.labelSegment,G(t.text));return}let c=ic(oc(t.from),i),l=ic(oc(t.to),a),u=Oc(e,c,l,ec(i)),d=Oc(e,ic(oc(t.from),o),ic(oc(t.to),s),ec(o));if(u!==null&&d!==null){u.length<=d.length?(t.startDir=i,t.endDir=a,t.path=u):(t.startDir=o,t.endDir=s,t.path=d);return}if(u!==null){t.startDir=i,t.endDir=a,t.path=u;return}if(d!==null){t.startDir=o,t.endDir=s,t.path=d;return}t.startDir=i,t.endDir=a,t.path=[c,l]}function Rl(e,t){for(let n of e.nodes){let e=n.gridCoord;if(e&&t>=e.x&&t<=e.x+2)return!0}return!1}function zl(e,t,n,r){if(!Rl(e,r))return r;for(let i=1;i<=n-t;i++){let a=r+i;if(a<=n&&!Rl(e,a))return a;let o=r-i;if(o>=t&&!Rl(e,o))return o}return r}function Bl(e,t){if(t.text.length===0||t.parallelLane&&t.parallelLane.index>0)return;let n=G(t.text),r=Vl(t.path),i=r.length,a=[];for(let t=1;t<i;t++){let n=r[t-1],i=r[t],o=[n,i],s=Ul(e,o),c=n.x===i.x;a.push({line:o,width:s,index:t,isVertical:c})}let o=t=>Ml(e,gc(t)),s=e=>e.index===1||e.index===a.length,c=a.filter(e=>e.width>=n&&!s(e)&&o(e.line)),l;if(c.length>0)c.sort((e,t)=>t.index-e.index),l=c[0].line;else{let e=a.filter(e=>e.width>=n&&o(e.line));if(e.length>0)e.sort((e,t)=>t.index-e.index),l=e[0].line;else{let e=a.filter(e=>!s(e)&&o(e.line)),n=a.filter(e=>o(e.line)),r=e.length>0?e:n.length>0?n:a;if(r.sort((e,t)=>t.width-e.width),r.length>0)l=r[0].line;else{let e=t.path[0]??{x:0,y:0};l=[e,e]}}}Hl(e,t,l,n)}function Vl(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.x!==n.x&&e.y!==n.y&&t.push({x:n.x,y:e.y}),t.push(n)}return t}function Hl(e,t,n,r){let i=Math.min(n[0].x,n[1].x),a=Math.max(n[0].x,n[1].x),o=zl(e,i,a,i+Math.floor((a-i)/2)),s=e.columnWidth.get(o)??0;e.columnWidth.set(o,Math.max(s,r+2)),t.labelLine=[n[0],n[1]]}function Ul(e,t){let n=0,r=Math.min(t[0].x,t[1].x),i=Math.max(t[0].x,t[1].x);for(let t=r;t<=i;t++)n+=e.columnWidth.get(t)??0;return n}var Wl={solid:{h:{unicode:`─`,ascii:`-`},v:{unicode:`│`,ascii:`|`}},dotted:{h:{unicode:`┄`,ascii:`.`},v:{unicode:`┆`,ascii:`:`}},thick:{h:{unicode:`━`,ascii:`=`},v:{unicode:`┃`,ascii:`‖`}},invisible:{h:{unicode:` `,ascii:` `},v:{unicode:` `,ascii:` `}}};function Gl(e,t,n,r,i,a,o=`solid`){let s=El(t,n),c=[],l=Wl[o],u=a?l.h.ascii:l.h.unicode,d=a?l.v.ascii:l.v.unicode;if(Q(s,J))for(let a=t.y-r;a>=n.y-i;a--)c.push({x:t.x,y:a}),q(e,t.x,a,d);else if(Q(s,Y))for(let a=t.y+r;a<=n.y+i;a++)c.push({x:t.x,y:a}),q(e,t.x,a,d);else if(Q(s,X))for(let a=t.x-r;a>=n.x-i;a--)c.push({x:a,y:t.y}),q(e,a,t.y,u);else if(Q(s,Z))for(let a=t.x+r;a<=n.x+i;a++)c.push({x:a,y:t.y}),q(e,a,t.y,u);else if(Q(s,Ys)){for(let i=t.x-r;i>=n.x;i--)c.push({x:i,y:t.y}),q(e,i,t.y,u);for(let r=t.y-1;r>=n.y-i;r--)c.push({x:n.x,y:r}),q(e,n.x,r,d)}else if(Q(s,Js)){for(let i=t.x+r;i<=n.x;i++)c.push({x:i,y:t.y}),q(e,i,t.y,u);for(let r=t.y-1;r>=n.y-i;r--)c.push({x:n.x,y:r}),q(e,n.x,r,d)}else if(Q(s,Zs)){for(let i=t.x-r;i>=n.x;i--)c.push({x:i,y:t.y}),q(e,i,t.y,u);for(let r=t.y+1;r<=n.y+i;r++)c.push({x:n.x,y:r}),q(e,n.x,r,d)}else if(Q(s,Xs)){if(n.x-t.x<=1)for(let a=t.y+r;a<=n.y+i;a++)c.push({x:t.x,y:a}),q(e,t.x,a,d);else{for(let i=t.x+r;i<=n.x;i++)c.push({x:i,y:t.y}),q(e,i,t.y,u);for(let r=t.y+1;r<=n.y+i;r++)c.push({x:n.x,y:r}),q(e,n.x,r,d)}}return c}function Kl(e,t){if(t.path.length===0){let t=K(e.canvas);return[t,t,t,t,t,t]}let n=nu(e,t),[r,i,a]=Jl(e,t.path,t.style),o=i.length>0,s=t.style===`invisible`,c=o&&!s?Zl(e,t.path,i[0],t.from):K(e.canvas),l;l=t.hasArrowEnd&&o?$l(e,i[i.length-1],a[a.length-1],t.endMarker):K(e.canvas);let u;if(t.hasArrowStart&&o){let n=i[0][0],r=ql(a[0]),o={x:n.x,y:n.y};Q(a[0],Z)?o.x=n.x-1:Q(a[0],X)?o.x=n.x+1:Q(a[0],Y)?o.y=n.y-1:Q(a[0],J)&&(o.y=n.y+1),u=$l(e,[n,o],r,t.startMarker)}else u=K(e.canvas);let d=s?K(e.canvas):eu(e,t.path);return[r,c,l,u,d,n]}function ql(e){return Q(e,J)?Y:Q(e,Y)?J:Q(e,X)?Z:Q(e,Z)?X:Q(e,Ys)?Xs:Q(e,Js)?Zs:Q(e,Zs)?Js:Q(e,Xs)?Ys:Qs}function Jl(e,t,n=`solid`){let r=K(e.canvas),i=t[0],a=[],o=[];for(let s=1;s<t.length;s++){let c=t[s],l=Yc(e,i),u=Yc(e,c);if(rc(l,u)){i=c;continue}let d=El(i,c),f=Gl(r,l,u,1,-1,e.config.useAscii,n);f.length===0&&f.push(l),a.push(f),o.push(d),i=c}return[r,a,o]}var Yl=new Set([`│`,`┃`,`║`,`┆`,`┊`,`|`,`‖`]),Xl=new Set([`─`,`━`,`═`,`╌`,`┄`,`-`,`=`]);function Zl(e,t,n,r){let i=K(e.canvas),a=e.config.useAscii;if(r.shape===`state-start`||r.shape===`state-end`)return i;let o=n[0],s=El(t[0],t[1]),c=a?`+`:null,l=(t,n)=>e.canvas[t]?.[n];if(Q(s,J)){let e=o.x,t=o.y+1,n=l(e,t);q(i,e,t,n!==void 0&&Xl.has(n)?c??`┴`:a?`|`:`│`)}else if(Q(s,Y)){let e=o.x,t=o.y-1,n=l(e,t);q(i,e,t,n!==void 0&&Xl.has(n)?c??`┬`:a?`|`:`│`)}else if(Q(s,X)||Q(s,Z)){let e=r.drawingCoord,t=r.drawing;if(e===null||t===null)throw Error(`drawBoxStart: node "${r.name}" has no drawingCoord/drawing assigned`);let n=t.length,u=Q(s,X)?e.x:e.x+n-1,d=o.y,f=l(u,d);q(i,u,d,f!==void 0&&Yl.has(f)?c??(Q(s,X)?`┤`:`├`):a?`-`:`─`)}return i}function Ql(e,t){if(t===`circle`)return e?`o`:`○`;if(t===`cross`)return e?`x`:`✕`}function $l(e,t,n,r){let i=K(e.canvas);if(t.length===0)return i;let a=t[0],o=t[t.length-1],s=El(a,o);(t.length===1||Q(s,Qs))&&(s=n);let c,l=Ql(e.config.useAscii,r);return c=l===void 0?e.config.useAscii?Q(s,J)?`^`:Q(s,Y)?`v`:Q(s,X)?`<`:Q(s,Z)?`>`:Q(n,J)?`^`:Q(n,Y)?`v`:Q(n,X)?`<`:Q(n,Z)?`>`:`*`:Q(s,J)?`▲`:Q(s,Y)?`▼`:Q(s,X)?`◄`:Q(s,Z)?`►`:Q(s,Js)?`◥`:Q(s,Ys)?`◤`:Q(s,Xs)?`◢`:Q(s,Zs)?`◣`:Q(n,J)?`▲`:Q(n,Y)?`▼`:Q(n,X)?`◄`:Q(n,Z)?`►`:Q(n,Js)?`◥`:Q(n,Ys)?`◤`:Q(n,Xs)?`◢`:Q(n,Zs)?`◣`:`●`:l,q(i,o.x,o.y,c),i}function eu(e,t){let n=K(e.canvas);for(let r=1;r<t.length-1;r++){let i=t[r],a=Yc(e,i),o=El(t[r-1],i),s=El(i,t[r+1]),c;c=e.config.useAscii?`+`:Q(o,Z)&&Q(s,Y)||Q(o,J)&&Q(s,X)?`┐`:Q(o,Z)&&Q(s,J)||Q(o,Y)&&Q(s,X)?`┘`:Q(o,X)&&Q(s,Y)||Q(o,J)&&Q(s,Z)?`┌`:Q(o,X)&&Q(s,J)||Q(o,Y)&&Q(s,Z)?`└`:`+`,q(n,a.x,a.y,c)}return n}function tu(e,t){return e.edges.some(e=>e!==t&&e.from===t.to&&e.to===t.from)}function nu(e,t){let n=K(e.canvas);if(t.text.length===0)return n;let r=Xc(e,t.labelLine),i;if(t.path.length>=2){let e=t.path[0].y,n=t.path[t.path.length-1].y;n<e?i=!0:n>e&&(i=!1)}let a=tu(e,t);return ru(n,r,t.text,i,a),n}function ru(e,t,n,r,i=!1){if(t.length<2)return;let a=Math.min(t[0].x,t[1].x),o=Math.max(t[0].x,t[1].x),s=Math.min(t[0].y,t[1].y),c=Math.max(t[0].y,t[1].y),l=a+Math.floor((o-a)/2),u=s+Math.floor((c-s)/2);if(r!==void 0&&a===o){let e=c-s,t=Math.max(1,Math.floor(e/4));(i?r:!r)?u-=t:u+=t}let d=$(n),f=u-Math.floor((d.length-1)/2);for(let t=0;t<d.length;t++){let n=d[t];xs(e,{x:l-Math.floor(G(n)/2),y:f+t},n)}}function iu(e,t,n){let r=oc(t),i=0;for(let t=0;t<2;t++)i+=e.columnWidth.get(r.x+t)??0;let a=0;for(let t=0;t<2;t++)a+=e.rowHeight.get(r.y+t)??0;let o={width:i+1,height:a+1,labelArea:{x:0,y:0,width:0,height:0},gridColumns:[0,0,0],gridRows:[0,0,0]},s=t.drawingCoord;if(s===null)throw Error(`Node "${t.name}" has no drawingCoord; grid layout must run before bundled-edge drawing`);return Jc(t.shape,n,o,s)}function au(e,t,n){let r=K(e.canvas),i=t.pathToJunction;if(!i||i.length===0)return[r,r,r,r,r,r];let a=K(e.canvas),o=e.config.useAscii,s=i.map((r,a)=>n.type===`fan-in`&&a===0?iu(e,t.from,t.startDir):n.type===`fan-out`&&a===i.length-1?iu(e,t.to,t.endDir):Yc(e,r));for(let e=1;e<s.length;e++){let n=s[e-1],r=s[e];rc(n,r)||Gl(a,n,r,1,-1,o,t.style)}let c=K(e.canvas);for(let t=1;t<i.length-1;t++){let n=i[t],r=Yc(e,n),a=El(i[t-1],n),s=El(n,i[t+1]),l;l=o?`+`:Q(a,Z)&&Q(s,Y)||Q(a,J)&&Q(s,X)?`┐`:Q(a,Z)&&Q(s,J)||Q(a,Y)&&Q(s,X)?`┘`:Q(a,X)&&Q(s,Y)||Q(a,J)&&Q(s,Z)?`┌`:Q(a,X)&&Q(s,J)||Q(a,Y)&&Q(s,Z)?`└`:`+`,q(c,r.x,r.y,l)}let l=K(e.canvas);if(n.type===`fan-in`&&i.length>=2){let e=s[0],t=El(i[0],i[1]),n=o?`+`:null;Q(t,J)?q(l,e.x,e.y,n??`┴`):Q(t,Y)?q(l,e.x,e.y,n??`┬`):Q(t,X)?q(l,e.x,e.y,n??`┤`):Q(t,Z)&&q(l,e.x,e.y,n??`├`)}return[a,l,r,r,c,K(e.canvas)]}function ou(e,t){let n=K(e.canvas),r=K(e.canvas);if(t.sharedPath.length<2)return[n,r];let i=e.config.useAscii,a=t.edges[0]?.style??`solid`,o=e.config.graphDirection,s=t.sharedPath.map((n,r)=>{if(t.type===`fan-in`&&r===t.sharedPath.length-1){let n=o===`TD`?J:X;return iu(e,t.sharedNode,n)}if(t.type===`fan-out`&&r===0){let n=o===`TD`?Y:Z;return iu(e,t.sharedNode,n)}return Yc(e,n)});for(let e=1;e<s.length;e++){let t=s[e-1],r=s[e];rc(t,r)||Gl(n,t,r,1,-1,i,a)}for(let n=1;n<t.sharedPath.length-1;n++){let a=t.sharedPath[n],o=Yc(e,a),s=El(t.sharedPath[n-1],a),c=El(a,t.sharedPath[n+1]),l;l=i?`+`:Q(s,Z)&&Q(c,Y)||Q(s,J)&&Q(c,X)?`┐`:Q(s,Z)&&Q(c,J)||Q(s,Y)&&Q(c,X)?`┘`:Q(s,X)&&Q(c,Y)||Q(s,J)&&Q(c,Z)?`┌`:Q(s,X)&&Q(c,J)||Q(s,Y)&&Q(c,Z)?`└`:`+`,q(r,o.x,o.y,l)}return[n,r]}function su(e,t){let n=K(e.canvas);if(t.sharedPath.length<2)return n;let r=t.sharedPath.length-1,i=t.sharedPath[r-1],a=t.sharedPath[r],o=El(i,a),s=e.config.graphDirection,c=s===`TD`?J:X,l=iu(e,t.sharedNode,c);s===`TD`?--l.y:--l.x;let u=t.edges[0]?.endMarker,d=t.edges.every(e=>e.endMarker===u)?u:void 0,f=Ql(e.config.useAscii,d),p;return p=f===void 0?e.config.useAscii?Q(o,J)?`^`:Q(o,Y)?`v`:Q(o,X)?`<`:Q(o,Z)?`>`:`v`:Q(o,J)?`▲`:Q(o,Y)?`▼`:Q(o,X)?`◄`:Q(o,Z)?`►`:`▼`:f,q(n,l.x,l.y,p),n}function cu(e,t){let n=K(e.canvas);if(!t.pathToJunction||t.pathToJunction.length<2)return n;let r=t.pathToJunction.length-1,i=t.pathToJunction[r-1],a=t.pathToJunction[r],o=El(i,a),s=e.config.graphDirection,c=s===`TD`?J:X,l=iu(e,t.to,c);s===`TD`?--l.y:--l.x;let u=Ql(e.config.useAscii,t.endMarker),d;return d=u===void 0?e.config.useAscii?Q(o,J)?`^`:Q(o,Y)?`v`:Q(o,X)?`<`:Q(o,Z)?`>`:`v`:Q(o,J)?`▲`:Q(o,Y)?`▼`:Q(o,X)?`◄`:Q(o,Z)?`►`:`▼`:u,q(n,l.x,l.y,d),n}function lu(e){return Q(e,J)?Y:Q(e,Y)?J:Q(e,X)?Z:Q(e,Z)?X:e}function uu(e,t){let n=K(e.canvas);if(t.sharedPath.length<2)return n;let r=t.sharedPath[0],i=t.sharedPath[1],a=lu(El(r,i)),o=e.config.graphDirection,s=o===`TD`?Y:Z,c=iu(e,t.sharedNode,s);o===`TD`?c.y+=1:c.x+=1;let l;return l=e.config.useAscii?Q(a,J)?`^`:Q(a,Y)?`v`:Q(a,X)?`<`:Q(a,Z)?`>`:`^`:Q(a,J)?`▲`:Q(a,Y)?`▼`:Q(a,X)?`◄`:Q(a,Z)?`►`:`▲`,q(n,c.x,c.y,l),n}function du(e,t){let n=K(e.canvas);if(!t.pathToJunction||t.pathToJunction.length<2)return n;let r=t.pathToJunction[0],i=t.pathToJunction[1],a=lu(El(r,i)),o=iu(e,t.from,t.startDir);Q(t.startDir,J)?--o.y:Q(t.startDir,Y)?o.y+=1:Q(t.startDir,X)?--o.x:Q(t.startDir,Z)&&(o.x+=1);let s;return s=e.config.useAscii?Q(a,J)?`^`:Q(a,Y)?`v`:Q(a,X)?`<`:Q(a,Z)?`>`:`v`:Q(a,J)?`▲`:Q(a,Y)?`▼`:Q(a,X)?`◄`:Q(a,Z)?`►`:`▼`,q(n,o.x,o.y,s),n}function fu(e,t){let n=K(e.canvas);if(!t.junctionPoint)return n;let r=Yc(e,t.junctionPoint),i=e.config.useAscii,a=!1,o=!1,s=!1,c=!1;if(t.sharedPath.length>=2){let e=t.type===`fan-in`?0:t.sharedPath.length-1,n=t.type===`fan-in`?1:t.sharedPath.length-2,r=El(t.sharedPath[e],t.sharedPath[n]);Q(r,Y)?o=!0:Q(r,J)?a=!0:Q(r,Z)?c=!0:Q(r,X)&&(s=!0)}for(let e of t.edges)if(e.pathToJunction&&e.pathToJunction.length>=2){let n=t.type===`fan-in`?e.pathToJunction.length-1:0,r=t.type===`fan-in`?e.pathToJunction.length-2:1,i=El(e.pathToJunction[r],e.pathToJunction[n]);Q(i,Y)?a=!0:Q(i,J)?o=!0:Q(i,Z)?s=!0:Q(i,X)&&(c=!0)}let l;return l=i?`+`:a&&o&&s&&c?`┼`:o&&s&&c&&!a?`┬`:a&&s&&c&&!o?`┴`:a&&o&&c&&!s?`├`:a&&o&&s&&!c?`┤`:s&&c?`─`:a&&o?`│`:o&&c?`┌`:o&&s?`┐`:a&&c?`└`:a&&s?`┘`:`┼`,q(n,r.x,r.y,l),n}function pu(e,t){let n=e.maxX-e.minX,r=e.maxY-e.minY;if(n<=0||r<=0)return as(0,0);let i={x:0,y:0},a={x:n,y:r},o=as(n,r);if(t.config.useAscii){for(let e=i.x+1;e<a.x;e++)q(o,e,i.y,`-`);for(let e=i.x+1;e<a.x;e++)q(o,e,a.y,`-`);for(let e=i.y+1;e<a.y;e++)q(o,i.x,e,`|`);for(let e=i.y+1;e<a.y;e++)q(o,a.x,e,`|`);q(o,i.x,i.y,`+`),q(o,a.x,i.y,`+`),q(o,i.x,a.y,`+`),q(o,a.x,a.y,`+`)}else{for(let e=i.x+1;e<a.x;e++)q(o,e,i.y,`─`);for(let e=i.x+1;e<a.x;e++)q(o,e,a.y,`─`);for(let e=i.y+1;e<a.y;e++)q(o,i.x,e,`│`);for(let e=i.y+1;e<a.y;e++)q(o,a.x,e,`│`);q(o,i.x,i.y,`┌`),q(o,a.x,i.y,`┐`),q(o,i.x,a.y,`└`),q(o,a.x,a.y,`┘`)}return o}function mu(e,t){let n=e.maxX-e.minX,r=e.maxY-e.minY;if(n<=0||r<=0)return[as(0,0),{x:0,y:0},[]];let i=as(n,r),a=[],o=$(e.name);for(let e=0;e<o.length;e++){let t=o[e],s=1+e,c=1+Math.ceil((n-1-G(t))/2);c<1&&(c=1);let l=is(t);for(let e=0;e<l.length;e++)c+e>=n||s>=r||(q(i,c+e,s,l[e]),a.push({x:c+e,y:s}))}return[i,{x:e.minX,y:e.minY},a]}function hu(e,t){return gu(e,t)}function gu(e,t){let n=oc(e),r=t.config.useAscii,i=0;for(let e=0;e<2;e++)i+=t.columnWidth.get(n.x+e)??0;let a=0;for(let e=0;e<2;e++)a+=t.rowHeight.get(n.y+e)??0;let o={x:0,y:0},s={x:i,y:a},c=as(Math.max(o.x,s.x),Math.max(o.y,s.y)),l=Bc(e.shape,r),u=e.shape===`state-end`,d=r?u?`=`:`-`:u?`═`:`─`,f=r?u?`‖`:`|`:u?`║`:`│`,p=u?r?{tl:`#`,tr:`#`,bl:`#`,br:`#`}:{tl:`╔`,tr:`╗`,bl:`╚`,br:`╝`}:l;for(let e=o.x+1;e<s.x;e++)q(c,e,o.y,d);for(let e=o.x+1;e<s.x;e++)q(c,e,s.y,d);for(let e=o.y+1;e<s.y;e++)q(c,o.x,e,f);for(let e=o.y+1;e<s.y;e++)q(c,s.x,e,f);q(c,o.x,o.y,p.tl),q(c,s.x,o.y,p.tr),q(c,o.x,s.y,p.bl),q(c,s.x,s.y,p.br);let m=e.displayLabel,h=$(m),g=o.y+Math.floor(a/2)-Math.floor((h.length-1)/2);for(let e=0;e<h.length;e++){let t=h[e],n=G(t),r=o.x+Math.floor(i/2)-Math.ceil(n/2)+1,a=is(t);for(let t=0;t<a.length;t++)q(c,r+t,g+e,a[t])}return c}function _u(e,t){return hu(e,t)}function vu(e){return/^[┌┐└┘├┤┬┴┼│─╭╮╰╯+\-|]$/.test(e)?`border`:`text`}function yu(e,t=1){let n=Math.max(0,t),r=0;for(let t of e)for(let e of t)r=Math.max(r,G(e));let i=0;for(let t of e)i+=Math.max(t.length,1);return{width:r+2*n+2,height:i+(e.length-1)+2}}function bu(e,t,n=1){let r=Math.max(0,n),{width:i,height:a}=yu(e,r),o=t?`-`:`─`,s=t?`|`:`│`,c=t?`+`:`┌`,l=t?`+`:`┐`,u=t?`+`:`└`,d=t?`+`:`┘`,f=t?`+`:`├`,p=t?`+`:`┤`,m=as(i-1,a-1);q(m,0,0,c);for(let e=1;e<i-1;e++)q(m,e,0,o);q(m,i-1,0,l),q(m,0,a-1,u);for(let e=1;e<i-1;e++)q(m,e,a-1,o);q(m,i-1,a-1,d);for(let e=1;e<a-1;e++)q(m,0,e,s),q(m,i-1,e,s);let h=1;for(let t=0;t<e.length;t++){let n=e[t],a=n.length>0?n:[``];for(let e of a){let t=1+r,n=is(e);for(let e=0;e<n.length;e++)q(m,t+e,h,n[e]);h++}if(t<e.length-1){q(m,0,h,f);for(let e=1;e<i-1;e++)q(m,e,h,o);q(m,i-1,h,p),h++}}return m}function xu(e){function t(e){return e.parent===null?0:1+t(e.parent)}let n=[...e];return n.sort((e,n)=>t(e)-t(n)),n}function Su(e,t,n,r){for(let i=0;i<t.length;i++)for(let a=0;a<(t[0]?.length??0);a++){let o=t[i]?.[a];if(o&&o!==` `){let t=i+n.x,o=a+n.y;t>=0&&o>=0&&cs(e,t,o,r)}}}function Cu(e,t,n,r){for(let i of t)Su(e,i,n,r)}function wu(e,t,n){let r=e=>/^[┌┐└┘├┤┬┴┼│─╭╮╰╯+\-|.':]$/.test(e);for(let i=0;i<t.length;i++)for(let a=0;a<(t[0]?.length??0);a++){let o=t[i]?.[a];if(o&&o!==` `){let t=i+n.x,s=a+n.y;t>=0&&s>=0&&cs(e,t,s,r(o)?`border`:`text`)}}}function Tu(e){let t=e.config.useAscii,n={x:0,y:0},r=xu(e.subgraphs);for(let n of r){let r=pu(n,e),i={x:n.minX,y:n.minY};e.canvas=gs(e.canvas,i,t,r),Su(e.roleCanvas,r,i,`border`)}for(let n of e.nodes)!n.drawn&&n.drawingCoord&&n.drawing&&(e.canvas=gs(e.canvas,n.drawingCoord,t,n.drawing),wu(e.roleCanvas,n.drawing,n.drawingCoord),n.drawn=!0);let i=[],a=[],o=[],s=[],c=[],l=[],u=[],d=new Set;for(let t of e.edges)if(t.bundle&&t.pathToJunction){let n=t.bundle,[r,f,,,p,m]=au(e,t,n);if(i.push(r),a.push(p),c.push(f),l.push(m),n.type===`fan-in`&&t.hasArrowStart){let n=du(e,t);s.push(n)}if(!d.has(n)){d.add(n);let[t,r]=ou(e,n);if(i.push(t),a.push(r),n.type===`fan-in`){let t=su(e,n);o.push(t)}if(n.type===`fan-out`&&n.edges.every(e=>e.hasArrowStart)){let t=uu(e,n);s.push(t)}let c=fu(e,n);u.push(c)}if(n.type===`fan-out`&&t.hasArrowEnd){let n=cu(e,t);o.push(n)}}else{let[n,r,u,d,f,p]=Kl(e,t);i.push(n),a.push(f),o.push(u),s.push(d),c.push(r),l.push(p)}e.canvas=gs(e.canvas,n,t,...i),Cu(e.roleCanvas,i,n,`line`),e.canvas=gs(e.canvas,n,t,...a),Cu(e.roleCanvas,a,n,`corner`),e.canvas=gs(e.canvas,n,t,...u),Cu(e.roleCanvas,u,n,`junction`),e.canvas=gs(e.canvas,n,t,...o),Cu(e.roleCanvas,o,n,`arrow`),e.canvas=gs(e.canvas,n,t,...c),Cu(e.roleCanvas,c,n,`junction`),e.canvas=gs(e.canvas,n,t,...s),Cu(e.roleCanvas,s,n,`arrow`),e.canvas=gs(e.canvas,n,t,...l),Cu(e.roleCanvas,l,n,`text`);for(let n of e.subgraphs){if(n.nodes.length===0)continue;let[r,i,a]=mu(n,e);e.canvas=gs(e.canvas,i,t,r),Su(e.roleCanvas,r,i,`text`);for(let{x:t,y:n}of a){let a=r[t]?.[n];a===` `&&(q(e.canvas,t+i.x,n+i.y,a),cs(e.roleCanvas,t+i.x,n+i.y,`text`))}}return e.canvas}function Eu(e,t,n,r){if(r(e))return e;let i=Math.max(e-t,n-e);for(let a=1;a<=i;a++){let i=e+a;if(i<=n&&r(i))return i;let o=e-a;if(o>=t&&r(o))return o}}function Du(e){return`${e.keys.length>0?e.keys.join(`,`)+` `:` `}${e.type} ${e.name}`}function Ou(e){let t=$(e.label),n=e.attributes.map(Du);return n.length===0?[t]:[t,n]}function ku(e,t,n=!1,r=!1){if(t)switch(e){case`one`:return r?`+`:`|`;case`zero-one`:return n?`o|`:`|o`;case`many`:return n?`<`:`>`;case`zero-many`:return n?`o<`:`>o`}else switch(e){case`one`:return r?`┼`:`│`;case`zero-one`:return n?`○│`:`│○`;case`many`:return n?`╟`:`╢`;case`zero-many`:return n?`○╟`:`╢○`}}function Au(e){let t=new Set,n=[],r=new Map;for(let t of e.entities)r.set(t.id,new Set);for(let t of e.relationships)r.get(t.entity1)?.add(t.entity2),r.get(t.entity2)?.add(t.entity1);function i(e,n){let i=[e];for(;i.length>0;){let e=i.pop();if(!t.has(e)){t.add(e),n.add(e);for(let n of r.get(e)??[])t.has(n)||i.push(n)}}}for(let r of e.entities)if(!t.has(r.id)){let e=new Set;i(r.id,e),e.size>0&&n.push(e)}return n}function ju(e,t,n){let r=e.get(t);if(r===void 0)throw Error(`ER diagram layout: missing ${n} for entity "${t}"`);return r}function Mu(e,t,n,r){let i=dt(D(e));if(i.entities.length===0)return``;let a=t.useAscii,o=tc(t.paddingX,5,6,6),s=tc(t.paddingY,5,4,2),c=tc(t.paddingY,5,2,1),l=Math.max(...[`one`,`zero-one`,`many`,`zero-many`].flatMap(e=>[ku(e,a,!1).length,ku(e,a,!0).length])),u=new Map,d=new Map,f=new Map,p=new Map;for(let e of i.entities){p.set(e.id,e);let n=Ou(e);u.set(e.id,n);let{width:r,height:i}=yu(n,t.boxBorderPadding);d.set(e.id,r),f.set(e.id,i)}let m=new Map;for(let e of i.relationships){if(!e.label)continue;let t=[e.entity1,e.entity2].sort().join(`|`),n=Lc(e.label);m.set(t,Math.max(m.get(t)??0,n))}let h=Au(i),g=new Map,_=0;for(let e of h){let t=i.entities.filter(t=>e.has(t.id)),n=Math.max(2,Math.ceil(Math.sqrt(t.length))),r=0,a=0,l=0;for(let e=0;e<t.length;e++){let i=t[e],c=ju(d,i.id,`box width`),p=ju(f,i.id,`box height`);l>=n&&(_+=a+s,r=0,a=0,l=0),g.set(i.id,{entity:i,sections:ju(u,i.id,`sections`),x:r,y:_,width:c,height:p});let h=o,v=l+1>=n,y=t[e+1];if(!v&&y){let e=[i.id,y.id].sort().join(`|`),t=m.get(e)??0;t>0&&(h=Math.max(h,t+2))}r+=c+h,a=Math.max(a,p),l++}_+=a+c}let v=0,y=0;for(let e of g.values())v=Math.max(v,e.x+e.width),y=Math.max(y,e.y+e.height);v+=4,y+=2;let b=as(v-1,y-1),x=os(v-1,y-1);function S(e,t,n,r){q(b,e,t,n,{role:r,roleCanvas:x})}function C(e,t){let n=x[e]?.[t];return n===`text`||n===`border`}function w(e,t,n,r,i){for(let a=0;a<e.length;a++){let e=t+a;if(!(e<r||e>i)&&C(e,n))return!1}return!0}function T(e,t,n,r,i){for(let a=0;a<e.length;a++){let e=t+a;if(!(e<r||e>i)&&(C(e,n)||x[e]?.[n]===`arrow`||E.has(`${e},${n}`)))return!1}return!0}for(let e of g.values()){let n=bu(e.sections,a,t.boxBorderPadding);for(let t=0;t<n.length;t++)for(let r=0;r<n[0].length;r++){let i=n[t][r];if(i!==` `){let n=e.x+t,a=e.y+r;n<v&&a<y&&S(n,a,i,vu(i))}}}let E=new Set;for(let e of g.values())for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++)E.add(`${e.x+n},${e.y+t}`);function O(e,t,n,r){E.has(`${e},${t}`)||(r===`text`||x[e]?.[t]!==`text`)&&S(e,t,n,r)}function k(e,t,n,r){x[e-1]?.[t]!==`text`&&x[e+1]?.[t]!==`text`&&O(e,t,n,r)}function A(e,t,n,r){for(let i=n;i<=r;i++)for(let n=e;n<=t;n++){let e=b[n]?.[i];if(e!==void 0&&e!==` `)return!1}return!0}let j=[];function ee(e,t,n){for(let r of j)if(Math.abs(r.x-e)===1&&t<=r.yEnd&&n>=r.yStart)return!0;return!1}function M(e,t,n){for(let r of j)if(!(Math.abs(r.x-e)>1)&&t<=r.yEnd&&n>=r.yStart)return!0;return!1}function te(e,t,n){j.push({x:e,yStart:t,yEnd:n})}let ne=a?`-`:`─`,re=a?`|`:`│`,ie=a?`.`:`╌`,ae=a?`:`:`┊`;function oe(e,t){return a?`+`:e===`down`?t===`right`?`┌`:`┐`:t===`right`?`└`:`┘`}function se(e,t,n,r){O(e,t,oe(n,r),`line`)}let N=new Map,ce=new Map;for(let e of i.relationships){let t=g.get(e.entity1),n=g.get(e.entity2);if(!t||!n)continue;let r=t.y+Math.floor(t.height/2),i=n.y+Math.floor(n.height/2);if(Math.abs(r-i)<Math.max(t.height,n.height))continue;let[a,o]=r<i?[t,n]:[n,t],s=a.x+Math.floor(a.width/2),c=o.x+Math.floor(o.width/2),l=ce.get(a.entity.id);l||(l=[],ce.set(a.entity.id,l)),l.push({rel:e,otherCenterX:c});let u=N.get(o.entity.id);u||(u=[],N.set(o.entity.id,u)),u.push({rel:e,otherCenterX:s})}function le(e,t,n){let r=n.get(e.entity.id),i=e.x+Math.floor(e.width/2);if(!r||r.length<=1)return i;let a=[...r].sort((e,t)=>e.otherCenterX-t.otherCenterX),o=a.findIndex(e=>e.rel===t);if(o===-1)return i;let s=Math.min(1,Math.floor((e.width-1)/2)),c=Math.max(0,e.width-1-s*2),l=a.length>1?c/(a.length-1):0;return e.x+s+Math.round(o*l)}for(let e of i.relationships){let t=g.get(e.entity1),n=g.get(e.entity2);if(!t||!n)continue;let r=e.identifying?ne:ie,i=e.identifying?re:ae,o=t.x+Math.floor(t.width/2),c=t.y+Math.floor(t.height/2),u=n.x+Math.floor(n.width/2),d=n.y+Math.floor(n.height/2);if(Math.abs(c-d)<Math.max(t.height,n.height)){let[c,d]=o<u?[t,n]:[n,t],[f,p]=o<u?[e.cardinality1,e.cardinality2]:[e.cardinality2,e.cardinality1],m=c.x+c.width,h=d.x-1,_=c.y+Math.floor(c.height/2),v;for(let e of g.values())e!==c&&e!==d&&e.y===c.y&&e.x<h+1&&e.x+e.width>m&&(v=Math.max(v??0,e.y+e.height));let y=h-m+1,S=+(y>=l+1),C=ku(f,a,!1),T=ku(p,a,!0),E=+(y>=3&&C[0]===re),D=+(y>=3&&T[T.length-1]===re),j=m+E,ee=h-D,M;if(v===void 0){for(let e=m;e<=h;e++)k(e,_,r,`line`);if(M=_+1,e.label){let t=m+S,n=h-S,r=$(e.label).length,i=_+1+Math.max(s-1,1);for(;M<i&&!A(t,n,M,M+r-1);)M++}}else{let t=Math.max(c.y+c.height,d.y+d.height,v),n=e.label?$(e.label).length:0,a=t+1,o=t+Math.max(s*3,4);for(;a<o&&!A(m,h,a,a+n);)a++;us(b,h+1,a+n+1),ss(x,h+1,a+n+1);for(let e=_;e<=a;e++)O(m,e,i,`line`),O(h,e,i,`line`);for(let e=m;e<=h;e++)k(e,a,r,`line`);m!==h&&(se(m,a,`up`,`right`),se(h,a,`up`,`left`)),M=a+1}for(let e=0;e<C.length;e++)O(j+e,_,C[e],`arrow`);for(let e=0;e<T.length;e++)O(ee-T.length+1+e,_,T[e],`arrow`);if(e.label){let t=$(e.label),n=Math.floor((m+h)/2),r=m+S,i=h-S;for(let e=0;e<t.length;e++){let a=t[e],o=is(a),s=Math.max(r,n-Math.floor(o.length/2)),c=M+e;if(us(b,Math.max(s+o.length,1),Math.max(c+1,1)),ss(x,Math.max(s+o.length,1),Math.max(c+1,1)),w(o,s,c,r,i))for(let e=0;e<o.length;e++){let t=s+e;t>=r&&t<=i&&O(t,c,o[e],`text`)}}}}else{let[o,s]=c<d?[t,n]:[n,t],[l,u]=c<d?[e.cardinality1,e.cardinality2]:[e.cardinality2,e.cardinality1],f=o.y+o.height,p=s.y-1,m=le(o,e,ce),h=le(s,e,N);function P(e,t,n){for(let r=t;r<=n;r++)if(E.has(`${e},${r}`))return!1;return!0}let _=f,v=p,y=Math.max(...[...g.values()].filter(e=>e.y===o.y).map(e=>e.y+e.height)),C=s.y,w=Math.max(f,y+1),D=Math.min(p,C-1);function ue(e,t,n){let r=Math.floor(w<=D?(w+D)/2:(f+p)/2);if(w>D)return r;for(let r=w;r<=D;r++)if(A(e,t,r,r+n))return r;return r}let j=m!==h,ne=Math.min(m,h),re=Math.max(m,h),ie=j?ue(ne,re,0):p,ae=j?ie-1:p,oe=!P(m,w,D)||!P(h,w,D)||ee(m,f,j?ie:p)||j&&ee(h,ie,p),de=m;if(oe){let e=b.length,t;for(let n=0;n<=e;n++){let e=m+n;if(P(e,f,p)&&!M(e,f,p)){t=e;break}let r=m-n;if(n>0&&P(r,f,p)&&!M(r,f,p)){t=r;break}}de=t??m;for(let e=f;e<=_;e++)O(m,e,i,`line`);for(let e=Math.min(m,de);e<=Math.max(m,de);e++)k(e,_,r,`line`);for(let e=_;e<=v;e++)O(de,e,i,`line`);for(let e=Math.min(de,h);e<=Math.max(de,h);e++)k(e,v,r,`line`);for(let e=v;e<=p;e++)O(h,e,i,`line`);if(m!==de){let e=de>m?`right`:`left`,t=e===`right`?`left`:`right`;se(m,_,`up`,e),se(de,_,`down`,t)}if(de!==h){let e=h>de?`right`:`left`,t=e===`right`?`left`:`right`;se(de,v,`up`,e),se(h,v,`down`,t)}te(de,_,v)}else{for(let e=f;e<=ae;e++)O(m,e,i,`line`);if(te(m,f,j?ie:ae),j){for(let e=ne;e<=re;e++)k(e,ie,r,`line`);for(let e=ie+1;e<=p;e++)O(h,e,i,`line`);te(h,ie,p);let e=h>m?`right`:`left`,t=e===`right`?`left`:`right`;se(m,ie,`up`,e),se(h,ie,`down`,t),de=h}}let fe=ku(l,a,!1,!0);for(let e=0;e<fe.length;e++)O(m-Math.floor(fe.length/2)+e,_,fe[e],`arrow`);let pe=m===h?m:h,me=ku(u,a,!0,!0);for(let e=0;e<me.length;e++)O(pe-Math.floor(me.length/2)+e,v,me[e],`arrow`);if(e.label){let t=$(e.label),n=Math.max(fe.length-1-Math.floor(fe.length/2),me.length-1-Math.floor(me.length/2)),r=de+n+2,i=t.map(e=>is(e)),a=r+Math.max(...i.map(e=>e.length))-1,o=t.length,s=Math.floor((f+p)/2)-Math.floor((o-1)/2);a>=0&&(us(b,a+1,p+1),ss(x,a+1,p+1));let c=null;for(let e=0;e<=p-f&&c===null;e++){let t=e===0?[s]:[s+e,s-e];for(let e of t)if(!(e<f||e+o-1>p)&&i.every((t,n)=>T(t,r,e+n,0,a))){c=e;break}}if(c!==null)for(let e=0;e<o;e++){let t=i[e],n=c+e;for(let e=0;e<t.length;e++){let i=r+e;i>=0&&O(i,n,t[e],`text`)}x[r-1]?.[n]===`line`&&S(r-1,n,` `,`line`);let a=r+t.length;x[a]?.[n]===`line`&&S(a,n,` `,`line`)}}}}return _s(b,{roleCanvas:x,colorMode:n,theme:r})}var Nu=4,Pu=[`O`,`/|\\`,`/ \\`],Fu=3,Iu=4;function Lu(e){return e.seqNumber===void 0?Nu:Nu+String(e.seqNumber).length}function Ru(e,t,n,r){let i=Et(D(e));if(i.actors.length===0)return``;let a=t.useAscii,o=a?`-`:`─`,s=a?`|`:`│`,c=a?`+`:`┌`,l=a?`+`:`┐`,u=a?`+`:`└`,d=a?`+`:`┘`,f=a?`+`:`┬`,p=a?`+`:`┴`,m=a?`+`:`├`,h=a?`+`:`┤`,g=new Map;i.actors.forEach((e,t)=>g.set(e.id,t));function _(e){let t=g.get(e);if(t===void 0)throw Error(`Sequence diagram: unknown actor "${e}"`);return t}function v(e){let t=Lc(e.label?`${e.type} [${e.label}]`:e.type);for(let n of e.dividers)n.label&&(t=Math.max(t,Lc(`[${n.label}]`)));return t}let y=Math.max(0,t.boxBorderPadding),b=e=>Math.max(Lc(e.label),e.type===`actor`?Fu:0),x=e=>Rc(e.label)+(e.type===`actor`?Pu.length:0),S=i.actors.map(e=>b(e)+2*y+2),C=S.map(e=>Math.ceil(e/2)),w=i.actors.map(e=>x(e)+2),T=Math.max(...w,3),E=(e,t)=>t-Math.floor(S[e]/2),O=Math.floor((T-1)/2),k=T-1-O,A=new Map,j=new Map;i.actors.forEach((e,t)=>{e.createdAt!==void 0&&A.set(e.createdAt,t),e.destroyedAt!==void 0&&j.set(e.destroyedAt,t)});let ee=new Map,M=new Map,te=i.boxes.filter(e=>e.actorIds.length>0).map(e=>{let t=e.actorIds.map(_);return{label:e.label,lo:Math.min(...t),hi:Math.max(...t)}}),ne=te.length>0,re=i.actors.map((e,t)=>te.findIndex(e=>e.lo<=t&&t<=e.hi)),ie=+!!ne,ae=e=>e===``?0:Lc(e)+6,oe=Array(Math.max(i.actors.length-1,0)).fill(0);for(let e of i.messages){let t=_(e.from),n=_(e.to);if(t===n)continue;let r=Math.min(t,n),i=Math.max(t,n),a=Lc(e.label)+4,o=i-r,s=Math.ceil(a/o);for(let e=r;e<i;e++)oe[e]=Math.max(oe[e],s)}function se(e){let t=$(e.text);return Math.max(...t.map(e=>G(e)))+2+2*y}let N=Array(i.actors.length).fill(0),ce=Array(i.actors.length).fill(0);for(let e of i.notes){if(e.position!==`left`&&e.position!==`right`)continue;let t=g.get(e.actorIds[0])??0,n=se(e);e.position===`left`?N[t]=Math.max(N[t],n):ce[t]=Math.max(ce[t],n)}let le=tc(t.paddingX,5,10,4),P=[Math.max(C[0]+(re[0]===-1?0:2),N[0]+1)];for(let e=1;e<i.actors.length;e++){let t=re[e-1],n=re[e],r=t===n?0:(t===-1?0:1)+(n===-1?0:1),i=r===0?0:r*2-1,a=Math.max(ce[e-1],N[e])+2,o=Math.max(C[e-1]+C[e]+2+i,oe[e-1]+2,a,le);P[e]=P[e-1]+o}let ue=e=>E(e.lo,P[e.lo])-1-1,de=e=>Math.max(E(e.hi,P[e.hi])+S[e.hi]-1+1+1,ue(e)+ae(e.label)-1);for(let e of te){if(e.hi+1>=i.actors.length)continue;let t=E(e.hi+1,P[e.hi+1]),n=re[e.hi+1]===-1?0:2,r=de(e)+1+1+n-t;if(r>0){let t=P.slice(e.hi+1).map(e=>e+r);P.splice(e.hi+1,t.length,...t)}}for(let e of i.blocks){let t=-1,n=-1,r=1/0,a=-1;for(let o=e.startIndex;o<=e.endIndex&&!(o>=i.messages.length);o++){let e=i.messages[o],s=_(e.from),c=_(e.to);if(t=t===-1?Math.min(s,c):Math.min(t,s,c),n=Math.max(n,s,c),r=Math.min(r,P[Math.min(s,c)]),a=Math.max(a,P[Math.max(s,c)]),s===c){let t=P[s]+Nu+2+Lc(e.label);a=Math.max(a,t)}}if(n===-1||n+1>=i.actors.length)continue;let o=Math.max(0,r-Iu),s=a+Iu,c=o+1+v(e),l=Math.max(s,c),u=P[n+1],d=l+2-u;if(d>0){let e=P.slice(n+1).map(e=>e+d);P.splice(n+1,e.length,...e)}}let fe=[],pe=[],me=new Map,he=new Map,ge=new Map,_e=[],ve=ie,ye=ve+T,F=ye+ie,be=tc(t.paddingY,5,1,0),xe=Math.max(be,1);for(let e of i.notes){if(e.afterIndex!==-1)continue;F+=be;let t=$(e.text),n=se(e),r=t.length+2,i=g.get(e.actorIds[0])??0,a;if(e.position===`left`)a=P[i]-n-1;else if(e.position===`right`)a=P[i]+2;else if(e.actorIds.length>=2){let t=g.get(e.actorIds[1])??i;a=Math.floor((P[i]+P[t])/2)-Math.floor(n/2)}else a=P[i]-Math.floor(n/2);a=Math.max(0,a),_e.push({x:a,y:F,width:n,height:r,lines:t}),F+=r}for(let e=0;e<i.messages.length;e++){for(let t=0;t<i.blocks.length;t++)i.blocks[t].startIndex===e&&(F+=be+1,me.set(t,F-1));for(let t=0;t<i.blocks.length;t++)for(let n=0;n<i.blocks[t].dividers.length;n++)i.blocks[t].dividers[n].index===e&&(F+=be,ge.set(`${t}:${n}`,F),F+=xe);F+=be;let t=i.messages[e],n=t.from===t.to,r=Rc(t.label),a=n?void 0:A.get(e),o=j.get(e);if(n)pe[e]=F+1,fe[e]=F,F+=2+r;else{let t=a===void 0?0:O,n=a===void 0?0:k;pe[e]=F,fe[e]=F+r+t,F+=r+t+1+n,a!==void 0&&ee.set(a,fe[e]-t)}o!==void 0&&(M.set(o,F),F+=1);for(let t=0;t<i.notes.length;t++)if(i.notes[t].afterIndex===e){F+=be;let e=i.notes[t],n=$(e.text),r=se(e),a=n.length+2,o=g.get(e.actorIds[0])??0,s;if(e.position===`left`)s=P[o]-r-1;else if(e.position===`right`)s=P[o]+2;else if(e.actorIds.length>=2){let t=g.get(e.actorIds[1])??o;s=Math.floor((P[o]+P[t])/2)-Math.floor(r/2)}else s=P[o]-Math.floor(r/2);s=Math.max(0,s),_e.push({x:s,y:F,width:r,height:a,lines:n}),F+=a}for(let t=0;t<i.blocks.length;t++)i.blocks[t].endIndex===e&&(F+=be,he.set(t,F),F+=xe)}F+=xe;let I=F,Se=I+ie,Ce=Se+T+ie,L=(P[P.length-1]??0)+(C[C.length-1]??0)+2;for(let e of te)L=Math.max(L,de(e)+2);for(let e=0;e<i.messages.length;e++){let t=i.messages[e];if(t.from===t.to){let e=P[_(t.from)]+Lu(t)+2+2+Lc(t.label);L=Math.max(L,e+1)}}for(let e of _e)L=Math.max(L,e.x+e.width+1);let we=as(L,Ce-1),Te=os(L,Ce-1);function R(e,t,n,r){q(we,e,t,n,{role:r,roleCanvas:Te})}function Ee(e,t,n,r,i){let a=is(n);for(let n=0;n<a.length;n++){let o=e+n;if(i!==void 0&&o>=i||a[n+1]===``&&i!==void 0&&o+1>=i)break;R(o,t,a[n],r)}}function De(e,t,n,r,i){let a=r===`actor`?Pu:[],f=[...a,...$(n)],p=Math.max(Lc(n),a.length>0?Fu:0),m=p+2*y+2,h=i,g=h-2,_=e-Math.floor(m/2);R(_,t,c,`border`);for(let e=1;e<m-1;e++)R(_+e,t,o,`border`);R(_+m-1,t,l,`border`);for(let e=0;e<g;e++){let n=t+1+e;R(_,n,s,`border`),R(_+m-1,n,s,`border`);let r=f[e];r!==void 0&&Ee(_+1+y+Math.floor((p-G(r))/2),n,r,`text`)}let v=t+h-1;R(_,v,u,`border`);for(let e=1;e<m-1;e++)R(_+e,v,o,`border`);R(_+m-1,v,d,`border`)}let Oe=e=>{let t=ee.get(e);return t===void 0?ye:t+T},ke=e=>M.get(e)??I;for(let e=0;e<i.actors.length;e++){let t=P[e];for(let n=Oe(e);n<=ke(e);n++)R(t,n,s,`line`)}let Ae=a?`+`:`┼`;function je(e,t,n){let r=ue(e),i=de(e),a=t+T+1;R(r,t,c,`border`),R(i,t,l,`border`),R(r,a,u,`border`),R(i,a,d,`border`);for(let e=r+1;e<i;e++)R(e,t,o,`border`),R(e,a,o,`border`);for(let e=t+1;e<a;e++)R(r,e,s,`border`),R(i,e,s,`border`);n!==``&&Ee(r+2,t,` ${$(n)[0]} `,`text`);for(let n=e.lo;n<=e.hi;n++){let e=P[n];Oe(n)<=t&&t<=ke(n)&&R(e,t,Ae,`junction`),Oe(n)<=a&&a<=ke(n)&&R(e,a,Ae,`junction`)}}for(let e of te)je(e,0,e.label),je(e,I,``);for(let e=0;e<i.actors.length;e++){let t=i.actors[e],n=ee.get(e)??ve,r=M.has(e);De(P[e],n,t.label,t.type,T),r||De(P[e],Se,t.label,t.type,T),a||(R(P[e],n+T-1,f,`junction`),r||R(P[e],Se,p,`junction`))}for(let e=0;e<i.messages.length;e++){let t=i.messages[e],n=_(t.from),r=_(t.to),c=P[n],l=P[r],u=n===r,d=t.lineStyle===`dashed`,f=t.arrowHead===`filled`,p=t.isLost===!0,h=a?`x`:`✕`,g=d?a?`.`:`╌`:o;if(u){let n=fe[e],r=Lu(t),i=t.seqNumber===void 0?void 0:String(t.seqNumber),o=$(t.label);R(c,n,m,`junction`);let l=c+1;if(i!==void 0){for(let e=0;e<i.length;e++)R(c+1+e,n,i[e],`text`);l=c+1+i.length}for(let e=l;e<c+r;e++)R(e,n,g,`line`);R(c+r,n,a?`+`:`┐`,`corner`);let u=c+r+2;for(let e=0;e<o.length;e++){let t=n+1+e;R(c+r,t,s,`line`),Ee(u,t,o[e],`text`,L)}let d=n+1+o.length;R(c,d,p?h:f?a?`<`:`◀`:a?`<`:`◁`,`arrow`);for(let e=c+1;e<c+r;e++)R(e,d,g,`line`);R(c+r,d,a?`+`:`┘`,`corner`)}else{let n=pe[e],i=fe[e],o=c<l,s=A.get(e)===r,u=l;if(s){let e=E(r,l),t=e+S[r]-1;u=o?e-1:t+1}let d=Math.floor((c+l)/2),m=$(t.label);for(let e=0;e<m.length;e++){let t=m[e];Ee(d-Math.floor(G(t)/2),n+e,t,`text`,L)}if(o){for(let e=c+1;e<u;e++)R(e,i,g,`line`);R(u,i,p?h:f?a?`>`:`▶`:a?`>`:`▷`,`arrow`),t.bidirectional&&R(c,i,a?`<`:`◀`,`arrow`)}else{for(let e=u+1;e<c;e++)R(e,i,g,`line`);R(u,i,p?h:f?a?`<`:`◀`:a?`<`:`◁`,`arrow`),t.bidirectional&&R(c,i,a?`>`:`▶`,`arrow`)}if(t.seqNumber!==void 0){let e=String(t.seqNumber);if(o){let t=c+1;if(t+e.length<l)for(let n=0;n<e.length;n++)R(t+n,i,e[n],`text`)}else{let t=c-e.length;if(t>u)for(let n=0;n<e.length;n++)R(t+n,i,e[n],`text`)}}}}for(let[e,t]of M)R(P[e],t,a?`x`:`✕`,`arrow`);let Me=L-1;for(let e=0;e<i.blocks.length;e++){let t=i.blocks[e],n=me.get(e),r=he.get(e);if(n===void 0||r===void 0)continue;let a=L,f=0;for(let e=t.startIndex;e<=t.endIndex&&!(e>=i.messages.length);e++){let t=i.messages[e],n=g.get(t.from)??0,r=g.get(t.to)??0;if(a=Math.min(a,P[Math.min(n,r)]),f=Math.max(f,P[Math.max(n,r)]),n===r){let e=P[n]+Lu(t)+2+Lc(t.label);f=Math.max(f,e)}}let p=a-Iu,_=f+Iu,y=1/0,b=-1/0;for(let e of P)e>f&&e<y&&(y=e),e<a&&e>b&&(b=e);_>=y&&(_=Math.max(f,y-Iu)),p<=b&&(p=Math.min(a,b+Iu)),p=Math.max(0,p),_>Me&&(us(we,_+1,Ce-1),ss(Te,_+1,Ce-1),Me=_);let x=t.label?`${t.type} [${t.label}]`:t.type,S=p+1+v(t);if(S>_){_=S;let[e]=ls(we);_>e&&(us(we,_,Ce-1),ss(Te,_,Ce-1)),L=Math.max(L,_+1),Me=Math.max(Me,_)}R(p,n,c,`border`);for(let e=p+1;e<_;e++)R(e,n,o,`border`);R(_,n,l,`border`);let C=$(x);for(let e=0;e<C.length&&n+e<r;e++)Ee(p+1,n+e,C[e],`text`,_);R(p,r,u,`border`);for(let e=p+1;e<_;e++)R(e,r,o,`border`);R(_,r,d,`border`);for(let e=n+1;e<r;e++)R(p,e,s,`border`),R(_,e,s,`border`);for(let n=0;n<t.dividers.length;n++){let r=ge.get(`${e}:${n}`);if(r===void 0)continue;let i=Ne();R(p,r,m,`junction`);for(let e=p+1;e<_;e++)R(e,r,i,`line`);R(_,r,h,`junction`);let a=t.dividers[n].label;if(a){let e=`[${a}]`;Ee(p+1,r,e,`text`,_)}}}for(let e of _e){us(we,e.x+e.width,e.y+e.height),ss(Te,e.x+e.width,e.y+e.height),R(e.x,e.y,c,`border`);for(let t=1;t<e.width-1;t++)R(e.x+t,e.y,o,`border`);R(e.x+e.width-1,e.y,l,`border`);for(let t=0;t<e.lines.length;t++){let n=e.y+1+t;R(e.x,n,s,`border`),R(e.x+e.width-1,n,s,`border`);for(let t=e.x+1;t<e.x+e.width-1;t++)R(t,n,` `,`text`);Ee(e.x+1+y,n,e.lines[t],`text`)}let t=e.y+e.height-1;R(e.x,t,u,`border`);for(let n=1;n<e.width-1;n++)R(e.x+n,t,o,`border`);R(e.x+e.width-1,t,d,`border`)}return _s(we,{roleCanvas:Te,colorMode:n,theme:r});function Ne(){return a?`-`:`╌`}}function zu(e,t){return e.rowStart<=t.rowEnd&&t.rowStart<=e.rowEnd}function Bu(e,t){let n=e.map(e=>({item:e,geom:t(e)})).sort((e,t)=>e.geom.idealMid-t.geom.idealMid),r=(e,t)=>{let r=n[e];if(r)for(let i=e+t;i>=0&&i<n.length;i+=t){let e=n[i];if(e&&zu(e.geom,r.geom))return e.geom}},i=new Map;for(let[e,t]of n.entries()){let n=t.geom,a=r(e,-1),o=r(e,1),s=a&&a.end>=n.start?Math.floor((a.idealMid+n.idealMid)/2)+1:-1/0,c=o&&n.end>=o.start?Math.floor((n.idealMid+o.idealMid)/2):1/0;i.set(t.item,{left:s,right:c})}return i}function Vu(e){let t=[];e.annotation&&t.push(`<<${e.annotation}>>`);let n=$(e.label);t.push(...n);let r=e.attributes.map(ut),i=e.methods.map(ut),a=[t];return r.length>0&&a.push(r),i.length>0&&a.push(i),a}function Hu(e,t){return{type:e,markerAt:t,dashed:e===`dependency`||e===`realization`}}function Uu(e,t,n){switch(e){case`inheritance`:case`realization`:return n===`down`?t?`^`:`△`:n===`up`?t?`v`:`▽`:n===`left`?t?`>`:`◁`:t?`<`:`▷`;case`composition`:return t?`*`:`◆`;case`aggregation`:return t?`o`:`◇`;case`association`:case`dependency`:return n===`down`?t?`v`:`▼`:n===`up`?t?`^`:`▲`:n===`left`?t?`<`:`◀`:t?`>`:`▶`}}function Wu(e,t,n,r,i){let a=e+t.length-1,o=r>e,s=i<a;if(!o&&!s)return{start:e,cells:t};let c=o?r:e,l=Math.max(0,(s?i:a)-c+1),u=+!!o+ +!!s;if(l===0)return{start:c,cells:[]};if(l<u)return{start:c,cells:[`…`]};let d=Math.max(0,l-u),f=is(n),p=f.length<=d?f:o&&!s?f.slice(f.length-d):f.slice(0,d),m=[...o?[`…`]:[],...p,...s?[`…`]:[]];return{start:c+Math.max(0,Math.floor((l-m.length)/2)),cells:m}}function Gu(e){return Math.max(...$(e).map(e=>G(e)))+2}function Ku(e,t,n,r,i={}){let{diagram:a,notesById:o}=qu(tt(D(e)));if(a.classes.length===0)return``;let s=t.useAscii,c=tc(t.paddingX,5,4,1),l=tc(t.paddingY,5,3,1),u=new Map,f=new Map,p=new Map;for(let e of a.classes){let n=Vu(e);u.set(e.id,n);let{width:r,height:i}=yu(n,t.boxBorderPadding);f.set(e.id,r),p.set(e.id,i)}let m=new Map;for(let e of a.classes)m.set(e.id,e);let h=new Map,g=new Map;for(let e of a.relationships){let t=e.from,n=e.to,r=h.get(n)??new Set;h.set(n,r),r.add(t);let i=g.get(t)??new Set;g.set(t,i),i.add(n)}let _=new Map,v=a.classes.filter(e=>!h.has(e.id)||h.get(e.id).size===0).map(e=>e.id);for(let e of v)_.set(e,0);let y=a.classes.length-1,b=0;for(;b<v.length;){let e=v[b++],t=g.get(e);if(t)for(let n of t){let t=(_.get(e)??0)+1;t>y||(!_.has(n)||_.get(n)<t)&&(_.set(n,t),v.push(n))}}for(let e of a.classes)_.has(e.id)||_.set(e.id,0);Ju(o,_);let x=Math.max(..._.values(),0),S=Array.from({length:x+1},()=>[]);for(let e of a.classes)S[_.get(e.id)].push(e.id);let C=new Map,w=new Map;{let e=new Map;a.relationships.forEach((t,n)=>{let r=[t.from,t.to].sort().join(`::`),i=e.get(r)??[];i.push(n),e.set(r,i)});for(let t of e.values()){if(t.length<2)continue;let e=t.length,n=Math.max(...t.map(e=>{let t=a.relationships[e].label;return t?Gu(t):3}))+1;t.forEach((t,r)=>{C.set(t,Math.round((r-(e-1)/2)*n)),w.set(t,(e-1)*n)})}}let T=new Map,E=new Map,O=new Map,k=new Map;{let e=(e,t,n)=>{let r=new Map;a.relationships.forEach((t,n)=>{if(C.has(n)||!m.has(t.from)||!m.has(t.to))return;let i=_.get(t.from)??0;if((_.get(t.to)??0)-i!==1)return;let a=e(t),o=r.get(a)??[];o.push(n),r.set(a,o)});for(let e of r.values()){if(e.length<2)continue;let r=e.length,i=Math.max(...e.map(e=>{let t=a.relationships[e].label;return t?Gu(t):3}))+1;e.forEach((e,a)=>{t.set(e,Math.round((a-(r-1)/2)*i)),n.set(e,(r-1)*i)})}};e(e=>e.to,O,k),e(e=>e.from,T,E)}let A=new Map;for(let e of a.classes)A.set(e.id,{left:0,right:0});a.relationships.forEach((e,t)=>{if(!m.has(e.from)||!m.has(e.to))return;let n=e.label?Gu(e.label):1,r=C.get(t)??T.get(t)??0,i=C.get(t)??O.get(t)??0,a=A.get(e.from);a.left=Math.max(a.left,Math.floor(n/2)-r),a.right=Math.max(a.right,r+n-1-Math.floor(n/2));let o=A.get(e.to);o.left=Math.max(o.left,Math.floor(n/2)-i),o.right=Math.max(o.right,i+n-1-Math.floor(n/2))});let j=new Map,ee=0,M=0;for(let e=0;e<=x;e++){let t=S[e];if(t.length===0)continue;let n=0,r=0;for(let e of t){let t=m.get(e),i=f.get(e),a=p.get(e),o=A.get(e),s=Math.max(0,o.left-Math.floor(i/2)),l=Math.max(0,o.right-(i-1-Math.floor(i/2)));j.set(e,{cls:t,sections:u.get(e),x:n+s,y:ee,width:i,height:a});let d=s+i+l;M=Math.max(M,n+d),n+=d+c,r=Math.max(r,a)}ee+=r+l}let te=M,ne=0;for(let e of j.values())te=Math.max(te,e.x+e.width),ne=Math.max(ne,e.y+e.height);te+=4,ne+=2;let re=as(te-1,ne-1),ie=os(te-1,ne-1);function ae(e,t,n,r){q(re,e,t,n,{role:r,roleCanvas:ie})}let oe=i.hyperlinks?ko(te-1,ne-1):void 0;for(let e of j.values()){let n=bu(e.sections,s,t.boxBorderPadding);for(let t=0;t<n.length;t++)for(let r=0;r<n[0].length;r++){let i=n[t][r];if(i!==` `){let n=e.x+t,a=e.y+r;n<te&&a<ne&&ae(n,a,i,vu(i))}}if(oe){let t=d(a.interactions.get(e.cls.id)?.href),r=e.sections[0];if(t!==void 0&&r!==void 0){let i=1+ +!!e.cls.annotation;Mo(oe,n,{x:e.x,y:e.y},t,{from:i,to:r.length})}}}let se=new Set;for(let e of j.values())for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++)se.add(`${e.x+n},${e.y+t}`);function N(e,t,n,r){se.has(`${e},${t}`)||ae(e,t,n,r)}function ce(e,t,n){for(let[r,i]of j.entries())if(!n?.has(r)&&e>=i.x&&e<=i.x+i.width-1&&t>=i.y&&t<=i.y+i.height-1)return!0;return!1}function le(e,t,n,r){return Eu(e,0,e+te+9,e=>{for(let i=Math.min(t,n);i<=Math.max(t,n);i++)if(ce(e,i,r))return!1;return!0})??te+2}let P=s?`-`:`─`,ue=s?`|`:`│`,de=s?`.`:`╌`,fe=s?`:`:`┊`;function pe(e,t,n){let r=Math.floor(n/2),i=n-1-r,a=t>r+i?(r+i)/t:1;return Math.max(-r,Math.min(i,Math.round(e*a)))}function me(e,t,n){let r=C.get(e)??T.get(e)??0,i=C.get(e)??O.get(e)??0,a=w.get(e)??E.get(e)??0,o=w.get(e)??k.get(e)??0,s=t.x+Math.floor(t.width/2),c=n.x+Math.floor(n.width/2);return{fromCX:s+r,toCX:c+i,fromAnchorX:s+pe(r,a,t.width),toAnchorX:c+pe(i,o,n.width)}}function he(e,t,n,r){if(se.has(`${e},${t}`)||ie[e]?.[t]===`arrow`)return;let i=re[e]?.[t];if(!s&&i!==void 0&&fs(i)&&fs(n)){let a=hs(i,n);ae(e,t,a,a===n?r:`junction`);return}ae(e,t,n,r)}function ge(e,t,n,r,i){if(t===n)return;let a=Math.min(t,n),o=Math.max(t,n);for(let t=a+1;t<o;t++)he(t,e,r,`line`);if(s){he(t,e,r,`line`),he(n,e,r,`line`);return}let c=n>t,l=i?c?`└`:`┘`:c?`┌`:`┐`,u=i?c?`┐`:`┌`:c?`┘`:`└`;he(t,e,l,`corner`),he(n,e,u,`corner`)}let _e=new Map,ve=new Map;a.relationships.forEach((e,t)=>{let n=j.get(e.from),r=j.get(e.to);if(!n||!r)return;let i=Hu(e.type,e.markerAt),a=i.dashed?de:P,o=i.dashed?fe:ue,c=new Set([e.from,e.to]),{fromCX:l,toCX:u,fromAnchorX:d,toAnchorX:f}=me(t,n,r),p=n.y+n.height-1,m=r.y;if(p<m){let e=le(l,p+1,m-1,c),n=e!==l;if(e>=te&&us(re,e+2,ne),n){let n=p+1,r=m-1;_e.set(t,{routeX:e,exitY:n,entryY:r,fromAnchorX:d,toAnchorX:f,clearSide:e>l?`right`:`left`});let c=Math.min(d,e),u=Math.max(d,e);for(let e=c;e<=u;e++)N(e,n,a,`line`);!s&&n<(re[0]?.length??0)&&(d<e?(N(d,n,`└`,`corner`),N(e,n,`┐`,`corner`)):(N(d,n,`┘`,`corner`),N(e,n,`┌`,`corner`)));for(let t=n+1;t<=r;t++)N(e,t,o,`line`);if(e!==f){let t=Math.min(e,f),n=Math.max(e,f);for(let e=t;e<=n;e++)N(e,r,a,`line`);!s&&r<(re[0]?.length??0)&&(e<f?(N(e,r,`└`,`corner`),N(f,r,`┐`,`corner`)):(N(e,r,`┘`,`corner`),N(f,r,`┌`,`corner`)))}if(i.markerAt===`to`){let e=i.type===`inheritance`||i.type===`realization`;N(f,r,Uu(i.type,s,e?`up`:`down`),`arrow`)}if(i.markerAt===`from`){let e=Uu(i.type,s,`down`);N(d,p+1,e,`arrow`)}}else{let e=p+Math.floor((m-p)/2),t=l!==d,n=u!==f;ge(p+1,d,l,a,!0);for(let n=p+(t?2:1);n<=e;n++)N(l,n,o,`line`);if(l!==u&&e<(re[0]?.length??0)){let t=Math.min(l,u),n=Math.max(l,u);for(let r=t;r<=n;r++)N(r,e,a,`line`);s||(N(l,e,l<u?`└`:`┘`,`corner`),N(u,e,l<u?`┐`:`┌`,`corner`))}for(let t=e+1;t<m-+!!n;t++)N(u,t,o,`line`);if(ge(m-1,f,u,a,!1),i.markerAt===`to`){let e=i.type===`inheritance`||i.type===`realization`;N(f,m-1,Uu(i.type,s,e?`up`:`down`),`arrow`)}i.markerAt===`from`&&N(d,p+1,Uu(i.type,s,`down`),`arrow`)}}else if(r.y+r.height-1<n.y){let e=n.y,t=r.y+r.height-1,c=t+Math.floor((e-t)/2),p=l!==d,m=u!==f;ge(e-1,d,l,a,!1);for(let t=e-(p?2:1);t>=c;t--)N(l,t,o,`line`);if(l!==u){let e=Math.min(l,u),t=Math.max(l,u);for(let n=e;n<=t;n++)N(n,c,a,`line`);!s&&c>=0&&c<ne&&(N(l,c,l<u?`┌`:`┐`,`corner`),N(u,c,l<u?`┘`:`└`,`corner`))}for(let e=c-1;e>t+ +!!m;e--)N(u,e,o,`line`);if(ge(t+1,f,u,a,!0),i.markerAt===`from`){let t=Uu(i.type,s,`up`),n=e-1;for(let e=0;e<t.length;e++)N(d-Math.floor(t.length/2)+e,n,t[e],`arrow`)}if(i.markerAt===`to`){let e=i.type===`inheritance`||i.type===`realization`?`down`:`up`,n=Uu(i.type,s,e),r=t+1;for(let e=0;e<n.length;e++)N(f-Math.floor(n.length/2)+e,r,n[e],`arrow`)}}else{let c=r.y+r.height-1,m=Math.min(l,u),h=Math.max(l,u),g=Math.max(p,c);for(let[t,r]of j.entries())t!==e.from&&t!==e.to&&r.y===n.y&&r.x<h+1&&r.x+r.width>m&&(g=Math.max(g,r.y+r.height-1));let _=g+2;ve.set(t,_),us(re,te,_+1),ss(ie,te,_+1);let v=l!==d,y=u!==f;ge(p+1,d,l,a,!0);for(let e=p+(v?2:1);e<=_;e++)N(l,e,o,`line`);for(let e=m;e<=h;e++)N(e,_,a,`line`);for(let e=_-1;e>=c+(y?2:1);e--)N(u,e,o,`line`);if(ge(c+1,f,u,a,!0),i.markerAt===`from`){let e=Uu(i.type,s,`down`),t=p+1;for(let n=0;n<e.length;n++)N(d-Math.floor(e.length/2)+n,t,e[n],`arrow`)}if(i.markerAt===`to`){let e=i.type===`inheritance`||i.type===`realization`,t=Uu(i.type,s,e?`down`:`up`),n=r.y+r.height;for(let e=0;e<t.length;e++)N(f-Math.floor(t.length/2)+e,n,t[e],`arrow`)}}});function ye(e,t,n,r){let{fromCX:i,toCX:a}=me(e,t,n),o=t.y+t.height-1,s=n.y;if(o<s){let t=_e.get(e);if(t){let e=t.exitY+1,n=t.entryY;if(n>=e)return{idealMidX:t.clearSide===`right`?t.routeX+1+Math.floor(r/2):t.routeX-1-Math.ceil(r/2),baseMidY:Math.floor((e+n)/2)};let i=Math.abs(t.routeX-t.fromAnchorX);return Math.abs(t.toAnchorX-t.routeX)>=i?{idealMidX:Math.floor((t.routeX+t.toAnchorX)/2),baseMidY:t.entryY}:{idealMidX:Math.floor((t.fromAnchorX+t.routeX)/2),baseMidY:t.exitY}}return{idealMidX:Math.floor((i+a)/2),baseMidY:Math.floor((o+1+s-1)/2)}}if(n.y+n.height-1<t.y){let e=n.y+n.height-1;return{idealMidX:Math.floor((i+a)/2),baseMidY:Math.floor((e+1+t.y-1)/2)}}return{idealMidX:Math.floor((i+a)/2),baseMidY:ve.get(e)??Math.max(o,n.y+n.height-1)+2}}function F(e,t,n,r,i,a,o){let s=r,c=Math.floor(a/2),l=e.y+e.height-1,u=t.y,d=!1;for(let e=0;e<a;e++){let t=s-c+e,r=n-Math.floor(i/2),a=Math.max(0,r);for(let e=a;e<a+i;e++)if(ce(e,t,o)){d=!0;break}if(d)break}if(d){let e=l+1,t=u-1;for(let r=e;r<=t;r++){let e=!0,t=n-Math.floor(i/2),a=Math.max(0,t);for(let t=a;t<a+i;t++)if(ce(t,r,o)){e=!1;break}if(e){s=r;break}}}return s}let be=new Map,xe=[];for(let[e,t]of a.relationships.entries()){if(!t.label)continue;let n=j.get(t.from),r=j.get(t.to);if(!n||!r)continue;let i=$(t.label),a=Math.floor(i.length/2),o=Math.max(...i.map(G))+2,{idealMidX:s,baseMidY:c}=ye(e,n,r,o),l=new Set([t.from,t.to]),u=F(n,r,s,c,o,i.length,l);be.set(t,u);let d=Math.max(0,s-Math.floor(o/2));xe.push({rel:t,idealMidX:s,naturalStart:d,naturalEnd:d+o-1,rowStart:u-a,rowEnd:u+a})}let I=Bu(xe,e=>({idealMid:e.idealMidX,start:e.naturalStart,end:e.naturalEnd,rowStart:e.rowStart,rowEnd:e.rowEnd})),Se=new Map;for(let e of xe){let t=I.get(e);t&&Se.set(e.rel,t)}for(let[e,t]of a.relationships.entries()){let n=j.get(t.from),r=j.get(t.to);if(!(!n||!r)&&t.label){let i=$(t.label),{idealMidX:a}=ye(e,n,r,Math.max(...i.map(e=>G(e)))+2),o=be.get(t)-Math.floor(i.length/2),s=Se.get(t);for(let e=0;e<i.length;e++){let t=o+e,n=i[e],r=is(` ${n} `),{start:c,cells:l}=Wu(Math.max(0,a-Math.floor(r.length/2)),r,n,Math.max(0,s.left),s.right),u=c+l.length;u>0&&t>=0&&(us(re,Math.max(u,1),Math.max(t+1,1)),ss(ie,Math.max(u,1),Math.max(t+1,1)));for(let e=0;e<l.length;e++){let n=c+e;n>=0&&t>=0&&ae(n,t,l[e],`text`)}}}}return Yu(o,j,re,s,ae),_s(re,{roleCanvas:ie,colorMode:n,theme:r,linkCanvas:oe})}function qu(e){let t=new Map;if(e.notes.length===0)return{diagram:e,notesById:t};let n=(e,n)=>{let r=`note ${e}`;return t.set(r,n),{id:r,label:n.text,attributes:[],methods:[]}},r=new Set(e.classes.map(e=>e.id)),i=[];for(let t of e.classes){i.push(t);for(let[r,a]of e.notes.entries())a.forClass===t.id&&i.push(n(r,a))}for(let[t,a]of e.notes.entries())(a.forClass===void 0||!r.has(a.forClass))&&i.push(n(t,a));return{diagram:{...e,classes:i},notesById:t}}function Ju(e,t){for(let[n,r]of e){if(r.forClass===void 0)continue;let e=t.get(r.forClass);e!==void 0&&t.set(n,e)}}function Yu(e,t,n,r,i){if(e.size===0)return;let a=Bc(`rounded`,r),o=r?`.`:`╌`;for(let[r,s]of e){let e=t.get(r);if(!e)continue;let c=e.x+e.width-1,l=e.y+e.height-1;if(i(e.x,e.y,a.tl,`border`),i(c,e.y,a.tr,`border`),i(e.x,l,a.bl,`border`),i(c,l,a.br,`border`),s.forClass===void 0)continue;let u=t.get(s.forClass);if(!u||u.x+u.width>e.x||u.y!==e.y)continue;let d=u.y+1;for(let t=u.x+u.width;t<e.x;t++)n[t]?.[d]===` `&&i(t,d,o,`line`)}}function Xu(e,t){let n=new Set,r=new Map;for(let t of e.subgraphs)Zu(t,n,r);let i=new Map,a=0;for(let[t,r]of e.nodes){if(n.has(t))continue;let e={name:t,displayLabel:Se(r.label),shape:r.shape,index:a,gridCoord:null,drawingCoord:null,drawing:null,drawn:!1,styleClassName:``,styleClass:sc};i.set(t,e),a++}let o=[...i.values()],s=[];for(let t of e.edges){let a=t.source,o=t.target;if(n.has(a)){let t=r.get(a),n=t?ed(t,e,`exit`):void 0;n&&(a=n)}if(n.has(o)){let t=r.get(o),n=t?ed(t,e,`entry`):void 0;n&&(o=n)}let c=i.get(a),l=i.get(o);!c||!l||s.push({from:c,to:l,text:t.label?Se(t.label):``,path:[],labelLine:[],startDir:{x:0,y:0},endDir:{x:0,y:0},style:t.style,hasArrowStart:t.hasArrowStart,hasArrowEnd:t.hasArrowEnd,...t.startMarker===void 0?{}:{startMarker:t.startMarker},...t.endMarker===void 0?{}:{endMarker:t.endMarker}})}let c=[];for(let t of e.subgraphs)td(t,null,i,c,e);nd(e.subgraphs,c,i);let l=e.classDefs.get(`default`);if(l)for(let e of i.values())e.styleClassName=`default`,e.styleClass={name:`default`,styles:l};for(let[t,n]of e.classAssignments){let r=i.get(t),a=e.classDefs.get(n);r&&a&&(r.styleClassName=n,r.styleClass={name:n,styles:l?{...l,...a}:a})}return{nodes:o,edges:s,canvas:as(0,0),roleCanvas:os(0,0),grid:lc(),columnWidth:new Map,rowHeight:new Map,subgraphs:c,config:t,offsetX:0,offsetY:0,bundles:[]}}function Zu(e,t,n){t.add(e.id),n.set(e.id,e);for(let r of e.children)Zu(r,t,n)}function Qu(e,t){for(let n of e.nodeIds)t.add(n);for(let n of e.children)Qu(n,t)}function $u(e,t){let n=new Set;if(Qu(e,n),n.size===0)return!0;let r=t=>n.has(t)||t===e.id;return!t.edges.some(e=>r(e.source)!==r(e.target))}function ed(e,t,n){let r=new Set;if(Qu(e,r),r.size===0)return;let i=[...t.nodes.keys()].filter(e=>r.has(e));if(i.length===0)return;let a=i.filter(e=>n===`entry`?!t.edges.some(t=>t.target===e&&r.has(t.source)):!t.edges.some(t=>t.source===e&&r.has(t.target))),o=a.length>0?a:i;return n===`entry`?o[0]:o[o.length-1]}function td(e,t,n,r,i){let a;e.direction&&$u(e,i)&&(a=e.direction===`LR`||e.direction===`RL`?`LR`:`TD`);let o={name:e.label,nodes:[],parent:t,children:[],minX:0,minY:0,maxX:0,maxY:0,direction:a};for(let t of e.nodeIds){let e=n.get(t);e&&o.nodes.push(e)}r.push(o);for(let t of e.children){let e=td(t,o,n,r,i);o.children.push(e);for(let t of e.nodes)o.nodes.includes(t)||o.nodes.push(t)}return o}function nd(e,t,n){let r=new Map;id(e,t,r);let i=new Map;function a(e){let t=r.get(e);if(t){for(let t of e.children)a(t);for(let n of e.nodeIds)i.has(n)||i.set(n,t)}}for(let t of e)a(t);for(let e of t)e.nodes=e.nodes.filter(t=>{let r;for(let[e,i]of n)if(i===t){r=e;break}if(!r)return!1;let a=i.get(r);return!a||rd(e,a)})}function rd(e,t){let n=t;for(;n!==null;){if(n===e)return!0;n=n.parent}return!1}function id(e,t,n){let r=[];function i(e){for(let t of e)r.push(t),i(t.children)}i(e);for(let e=0;e<r.length&&e<t.length;e++){let i=r[e],a=t[e];!i||!a||n.set(i,a)}}function ad(e,t,n,r,i={}){let a=j($t(e),i.direction);t.graphDirection=a.direction===`LR`||a.direction===`RL`?`LR`:`TD`;let o=Xu(a,t);bl(o),Tu(o);let s=i.hyperlinks?No(o,a.interactions):void 0;return a.direction===`BT`&&(ys(o.canvas),bs(o.roleCanvas),s&&jo(s)),_s(o.canvas,{roleCanvas:o.roleCanvas,colorMode:n,theme:r,linkCanvas:s})}var od={xychart:(e,t,n,r)=>As(e,t,n,r),er:(e,t,n,r)=>Mu(e,t,n,r),sequence:(e,t,n,r)=>Ru(e,t,n,r),class:(e,t,n,r,i)=>Ku(e,t,n,r,i),flowchart:(e,t,n,r,i)=>ad(e,t,n,r,i)},sd=/\x1b\[[0-9;]*m/g;function cd(e){let t=e.split(`
|
|
80
|
-
`),n=t.reduce((e,t)=>Math.max(e,
|
|
81
|
-
`)}function ld(e,t={}){let n={useAscii:t.useAscii??!1,paddingX:t.paddingX??5,paddingY:t.paddingY??5,boxBorderPadding:t.boxBorderPadding??1,graphDirection:`TD`},r=t.colorMode===`auto`||t.colorMode===void 0?
|
|
76
|
+
</style>`,defs:``}}function go(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return a<=0?`M${G(e)},${G(t)} h${G(n)} v${G(r)} h${G(-n)} Z`:[`M${G(e)},${G(t+a)}`,`Q${G(e)},${G(t)} ${G(e+a)},${G(t)}`,`L${G(e+n-a)},${G(t)}`,`Q${G(e+n)},${G(t)} ${G(e+n)},${G(t+a)}`,`L${G(e+n)},${G(t+r-a)}`,`Q${G(e+n)},${G(t+r)} ${G(e+n-a)},${G(t+r)}`,`L${G(e+a)},${G(t+r)}`,`Q${G(e)},${G(t+r)} ${G(e)},${G(t+r-a)}`,`Z`].join(` `)}function _o(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return a<=0?`M${G(e)},${G(t)} h${G(n)} v${G(r)} h${G(-n)} Z`:[`M${G(e+a)},${G(t)}`,`L${G(e+n-a)},${G(t)}`,`Q${G(e+n)},${G(t)} ${G(e+n)},${G(t+a)}`,`L${G(e+n)},${G(t+r-a)}`,`Q${G(e+n)},${G(t+r)} ${G(e+n-a)},${G(t+r)}`,`L${G(e+a)},${G(t+r)}`,`Q${G(e)},${G(t+r)} ${G(e)},${G(t+r-a)}`,`L${G(e)},${G(t+a)}`,`Q${G(e)},${G(t)} ${G(e+a)},${G(t)}`,`Z`].join(` `)}function vo(e){if(e.length===0)return``;if(e.length===1)return`M${G(e[0].x)},${G(e[0].y)}`;if(e.length===2)return`M${G(e[0].x)},${G(e[0].y)} L${G(e[1].x)},${G(e[1].y)}`;let t=e.length,n=[],r=[];for(let i=0;i<t-1;i++)n.push(e[i+1].x-e[i].x),r.push(n[i]===0?0:(e[i+1].y-e[i].y)/n[i]);let i=Array(t).fill(0);if(t>2){let e=Array(t).fill(0),a=Array(t).fill(0);for(let i=1;i<t-1;i++){let t=2*(n[i-1]+n[i]),o=3*(r[i]-r[i-1]);if(i===1)e[i]=n[i]/t,a[i]=o/t;else{let r=t-n[i-1]*e[i-1];e[i]=n[i]/r,a[i]=(o-n[i-1]*a[i-1])/r}}for(let n=t-2;n>=1;n--)i[n]=a[n]-e[n]*i[n+1]}let a=Array(t).fill(0);for(let e=0;e<t-1;e++)a[e]=r[e]-n[e]*(2*i[e]+i[e+1])/3;a[t-1]=r[t-2]+n[t-2]*i[t-2]/3;let o=`M${G(e[0].x)},${G(e[0].y)}`;for(let r=0;r<t-1;r++){let t=n[r]/3,i=e[r].x+t,s=e[r].y+a[r]*t,c=e[r+1].x-t,l=e[r+1].y-a[r+1]*t;o+=` C${G(i)},${G(s)} ${G(c)},${G(l)} ${G(e[r+1].x)},${G(e[r+1].y)}`}return o}function yo(e,t,n,r){let i=zn(n,W.fontSize,600),a=Math.max(...r.map(e=>{let t=zn(e.legendLabel,W.fontSize,W.fontWeight),n=zn(e.text,W.fontSize,W.fontWeight);return t+10+n})),o=Math.max(i,a)+W.padX*2,s=26+r.length*20+6,c=Math.max(W.minY,t-W.offsetY-s-W.pointerSize),l=e-o/2,u=e,d=c+s,f=W.pointerSize,p=`<polygon points="${G(u-f)},${G(d)} ${G(u+f)},${G(d)} ${G(u)},${G(d+f)}" class="xychart-tip xychart-tip-ptr"/>`,m=`<rect x="${G(l)}" y="${G(c)}" width="${G(o)}" height="${s}" rx="${W.rx}" class="xychart-tip xychart-tip-bg"/>`;m+=p;let h=c+6+10;m+=`<text x="${G(e)}" y="${G(h)}" text-anchor="middle" font-weight="600" font-size="${W.fontSize}" dy="${Wn}" class="xychart-tip xychart-tip-text">${So(n)}</text>`;let g=l+W.padX,_=l+o-W.padX;for(let e of r)h+=20,m+=`<text x="${G(g)}" y="${G(h)}" text-anchor="start" font-size="${W.fontSize}" font-weight="${W.fontWeight}" dy="${Wn}" class="xychart-tip xychart-tip-text">${So(e.legendLabel)}</text>`,m+=`<text x="${G(_)}" y="${G(h)}" text-anchor="end" font-size="${W.fontSize}" font-weight="${W.fontWeight}" dy="${Wn}" class="xychart-tip xychart-tip-text">${So(e.text)}</text>`;return m}function bo(e,t,n){let r=zn(n,W.fontSize,W.fontWeight)+W.padX*2,i=W.height,a=Math.max(W.minY,t-W.offsetY-i-W.pointerSize),o=e-r/2,s=e,c=a+i/2,l=e,u=a+i,d=W.pointerSize,f=`<polygon points="${G(l-d)},${G(u)} ${G(l+d)},${G(u)} ${G(l)},${G(u+d)}" class="xychart-tip xychart-tip-ptr"/>`;return`<rect x="${G(o)}" y="${G(a)}" width="${G(r)}" height="${i}" rx="${W.rx}" class="xychart-tip xychart-tip-bg"/>`+f+`<text x="${G(s)}" y="${G(c)}" text-anchor="middle" dy="${Wn}" class="xychart-tip xychart-tip-text">${So(n)}</text>`}function xo(e){return Number.isInteger(e)?e.toLocaleString(`en-US`):e.toFixed(+(Math.abs(e)<10))}function G(e){return String(Math.round(e*10)/10)}function So(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Co(e){return[e.length-1,(e[0]?.length??1)-1]}var wo=`\x1B]8;;\x1B\\`;function To(e){return`\x1b]8;;${e.replace(/[^\x21-\x7e]/gu,e=>encodeURIComponent(e))}\x1b\\`}var Eo=/\x1b\]8;[^\x07\x1b]*(?:\x1b\\|\x07)/g;function Do(e){return e.replace(Eo,``)}function Oo(e,t){let n=[];for(let r=0;r<=e;r++){let e=[];for(let n=0;n<=t;n++)e.push(null);n.push(e)}return n}function ko(e,t,n,r){let i=e[t];i===void 0||n<0||n>=i.length||(i[n]=r)}function Ao(e){for(let t of e)t.reverse();return e}function jo(e,t,n,r,i){let[a,o]=Co(t),s=Math.max(1,i?.from??1),c=Math.min(o-1,i?.to??o-1);for(let i=s;i<=c;i++){let o=-1,s=-1;for(let e=1;e<=a-1;e++)t[e]?.[i]!==` `&&(o===-1&&(o=e),s=e);if(o!==-1)for(let t=o;t<=s;t++)ko(e,t+n.x,i+n.y,r)}}function Mo(e,t){let[n,r]=Co(e.canvas),i=Oo(n,r);for(let n of e.nodes){if(!n.drawing||!n.drawingCoord)continue;let e=d(t.get(n.name)?.href);e!==void 0&&jo(i,n.drawing,n.drawingCoord,e)}return i}var No=class{current=null;advance(e){if(e===this.current)return``;let t=this.current===null?``:wo;return e!==null&&(t+=To(e)),this.current=e,t}finish(){let e=this.current===null?``:wo;return this.current=null,e}};function Po(e,t){let n=new No,r=``;for(let[i,a]of e.entries())r+=n.advance(t[i]??null)+a;return r+n.finish()}var Fo={fg:`#27272a`,border:`#a1a1aa`,line:`#71717a`,arrow:`#52525b`,corner:`#71717a`,junction:`#a1a1aa`};function Io(){let e=globalThis.process;if(e){if(!e.stdout?.isTTY)return`none`;let t=e.env?.COLORTERM?.toLowerCase()??``,n=e.env?.TERM?.toLowerCase()??``;return t===`truecolor`||t===`24bit`?`truecolor`:n.includes(`256color`)||n.includes(`256`)?`ansi256`:n&&n!==`dumb`?`ansi16`:`none`}return typeof document<`u`?`html`:`none`}function Lo(e){return h(e.startsWith(`#`)?e:`#${e}`)??{r:0,g:0,b:0}}var Ro=`\x1B[`,zo=`${Ro}0m`;function Bo(e){let{r:t,g:n,b:r}=Lo(e);return`${Ro}38;2;${t};${n};${r}m`}function Vo(e,t,n){let r=(e+t+n)/3;if(Math.max(Math.abs(e-r),Math.abs(t-r),Math.abs(n-r))<10){let e=Math.round(r/255*23);return 232+Math.min(23,Math.max(0,e))}let i=e=>e<48?0:e<115?1:Math.min(5,Math.floor((e-35)/40)),a=i(e),o=i(t),s=i(n);return 16+36*a+6*o+s}function Ho(e){let{r:t,g:n,b:r}=Lo(e);return`${Ro}38;5;${Vo(t,n,r)}m`}function Uo(e){let{r:t,g:n,b:r}=Lo(e),i=.299*t+.587*n+.114*r,a=i>100?0:60,o;return o=t>180&&n<100&&r<100?31:n>180&&t<100&&r<100?32:t>150&&n>150&&r<100?33:r>180&&t<100&&n<100?34:t>150&&r>150&&n<100?35:n>150&&r>150&&t<100?36:i>200?37:i<50?30:37,`${Ro}${o+a}m`}function Wo(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function Go(e,t){return`<span style="color:${e}">${Wo(t)}</span>`}function Ko(e,t){switch(e){case`text`:return t.fg;case`border`:return t.border;case`line`:return t.line;case`arrow`:return t.arrow;case`corner`:return t.corner??t.line;case`junction`:return t.junction??t.border;default:return t.fg}}function qo(e,t,n){if(n===`none`)return``;let r=Ko(e,t);switch(n){case`truecolor`:return Bo(r);case`ansi256`:return Ho(r);case`ansi16`:return Uo(r);default:return``}}function Jo(e,t,n,r,i){if(r===`none`)return i?Po(e,i):e.join(``);if(r===`html`)return Yo(e,t,n);let a=new No,o=``,s=null,c=``;for(let[l,u]of e.entries()){let e=t[l]??null,d=i?a.advance(i[l]??null):``;if(u===` `){c.length>0&&(o+=s===null?c:qo(s,n,r)+c+zo,c=``,s=null),o+=d+u;continue}if(e===s){c+=d+u;continue}c.length>0&&(o+=s===null?c:qo(s,n,r)+c+zo),c=d+u,s=e}return c.length>0&&s!==null?o+=qo(s,n,r)+c+zo:c.length>0&&(o+=c),o+a.finish()}function Yo(e,t,n){let r=``,i=null,a=``,o=()=>{a.length!==0&&(r+=i===null?Wo(a):Go(Ko(i,n),a),a=``,i=null)};for(let[n,s]of e.entries()){let e=t[n]??null;if(s===` `){o(),r+=` `;continue}if(e===i){a+=s;continue}o(),a=s,i=e}return o(),r}function Xo(e,t,n){if(n===`none`||e.length===0)return e;if(n===`html`)return Go(t,e);let r;switch(n){case`truecolor`:r=Bo(t);break;case`ansi256`:r=Ho(t);break;case`ansi16`:r=Uo(t);break;default:return e}return`${r}${e}${zo}`}var Zo=/\p{Mn}|\p{Me}/u;function Qo(e){return Zo.test(e)}var $o=new Intl.Segmenter(void 0,{granularity:`grapheme`}),es=`️`;function ts(e){let t=[];for(let{segment:n}of $o.segment(e))t.push(n);return t}function ns(e){if(e.includes(es))return 2;let t=!1,n=!1;for(let r of e)pe(r)&&(t=!0),Qo(r)||(n=!0);return t?2:+!!n}function K(e){let t=0;for(let n of ts(e))t+=ns(n);return t}function rs(e){let t=[];for(let n of ts(e)){let e=ns(n);e!==0&&(t.push(n),e===2&&t.push(``))}return t}function is(e,t){let n=[];for(let r=0;r<=e;r++){let e=[];for(let n=0;n<=t;n++)e.push(` `);n.push(e)}return n}function as(e){let[t,n]=ls(e);return is(t,n)}function os(e,t){let n=[];for(let r=0;r<=e;r++){let e=[];for(let n=0;n<=t;n++)e.push(null);n.push(e)}return n}function ss(e,t,n){let r=e.length-1,i=(e[0]?.length??1)-1,a=os(Math.max(t,r),Math.max(n,i));for(let t=0;t<a.length;t++)for(let n=0;n<(a[0]?.length??0);n++)t<e.length&&n<(e[0]?.length??0)&&(a[t][n]=e[t][n]);return e.length=0,e.push(...a),e}function cs(e,t,n,r){(t>=e.length||n>=(e[0]?.length??0))&&ss(e,t,n),e[t][n]=r}function ls(e){return[e.length-1,(e[0]?.length??1)-1]}function us(e,t,n){let[r,i]=ls(e),a=is(Math.max(t,r),Math.max(n,i));for(let t=0;t<a.length;t++)for(let n=0;n<(a[0]?.length??0);n++)t<e.length&&n<(e[0]?.length??0)&&(a[t][n]=e[t][n]);return e.length=0,e.push(...a),e}function q(e,t,n,r,i){let[a,o]=ls(e);t<0||t>a||n<0||n>o||(e[t][n]=r,i&&cs(i.roleCanvas,t,n,i.role))}var ds=new Set([`─`,`│`,`┌`,`┐`,`└`,`┘`,`├`,`┤`,`┬`,`┴`,`┼`,`╴`,`╵`,`╶`,`╷`]);function fs(e){return ds.has(e)}function ps(e){return/^[a-zA-Z0-9]$/.test(e)}var ms={"─":{"│":`┼`,"┌":`┬`,"┐":`┬`,"└":`┴`,"┘":`┴`,"├":`┼`,"┤":`┼`,"┬":`┬`,"┴":`┴`},"│":{"─":`┼`,"┌":`├`,"┐":`┤`,"└":`├`,"┘":`┤`,"├":`├`,"┤":`┤`,"┬":`┼`,"┴":`┼`},"┌":{"─":`┬`,"│":`├`,"┐":`┬`,"└":`├`,"┘":`┼`,"├":`├`,"┤":`┼`,"┬":`┬`,"┴":`┼`},"┐":{"─":`┬`,"│":`┤`,"┌":`┬`,"└":`┼`,"┘":`┤`,"├":`┼`,"┤":`┤`,"┬":`┬`,"┴":`┼`},"└":{"─":`┴`,"│":`├`,"┌":`├`,"┐":`┼`,"┘":`┴`,"├":`├`,"┤":`┼`,"┬":`┼`,"┴":`┴`},"┘":{"─":`┴`,"│":`┤`,"┌":`┼`,"┐":`┤`,"└":`┴`,"├":`┼`,"┤":`┤`,"┬":`┼`,"┴":`┴`},"├":{"─":`┼`,"│":`├`,"┌":`├`,"┐":`┼`,"└":`├`,"┘":`┼`,"┤":`┼`,"┬":`┼`,"┴":`┼`},"┤":{"─":`┼`,"│":`┤`,"┌":`┼`,"┐":`┤`,"└":`┼`,"┘":`┤`,"├":`┼`,"┬":`┼`,"┴":`┼`},"┬":{"─":`┬`,"│":`┼`,"┌":`┬`,"┐":`┬`,"└":`┼`,"┘":`┼`,"├":`┼`,"┤":`┼`,"┴":`┼`},"┴":{"─":`┴`,"│":`┼`,"┌":`┼`,"┐":`┼`,"└":`┴`,"┘":`┴`,"├":`┼`,"┤":`┼`,"┬":`┼`}};function hs(e,t){return ms[e]?.[t]??e}function gs(e,t,n,...r){let[i,a]=ls(e);for(let e of r){let[n,r]=ls(e);i=Math.max(i,n+t.x),a=Math.max(a,r+t.y)}let o=is(i,a);for(let t=0;t<=i;t++)for(let n=0;n<=a;n++)t<e.length&&n<(e[0]?.length??0)&&(o[t][n]=e[t][n]);for(let e of r)for(let r=0;r<e.length;r++)for(let i=0;i<(e[0]?.length??0);i++){let a=e[r][i];if(a!==` `){let e=r+t.x,s=i+t.y,c=o[e][s];!n&&fs(a)&&fs(c)?o[e][s]=hs(c,a):ps(c)&&ps(a)||(o[e][s]=a)}}return o}function _s(e,t){let[n,r]=ls(e),i=[],a=t?.roleCanvas,o=t?.colorMode??`none`,s=t?.theme??Fo,c=o===`html`?void 0:t?.linkCanvas;for(let t=0;t<=r;t++)if(o===`none`||!a){let r=[];for(let i=0;i<=n;i++)r.push(e[i][t]);if(c){let e=r.map((e,n)=>c[n]?.[t]??null);i.push(Po(r,e))}else i.push(r.join(``))}else{let r=[],l=[],u=[];for(let i=0;i<=n;i++)r.push(e[i][t]),l.push(a[i]?.[t]??null),u.push(c?.[i]?.[t]??null);i.push(Jo(r,l,s,o,c?u:void 0))}return i.join(`
|
|
77
|
+
`)}var vs={"▲":`▼`,"▼":`▲`,"◤":`◣`,"◣":`◤`,"◥":`◢`,"◢":`◥`,"^":`v`,v:`^`,"┌":`└`,"└":`┌`,"┐":`┘`,"┘":`┐`,"┬":`┴`,"┴":`┬`,"╵":`╷`,"╷":`╵`};function ys(e){for(let t of e)t.reverse();for(let t of e)for(let[e,n]of t.entries()){let r=vs[n];r&&(t[e]=r)}return e}function bs(e){for(let t of e)t.reverse();return e}function xs(e,t,n,r=!1){let i=rs(n);us(e,t.x+i.length,t.y);for(let[n,a]of i.entries()){let i=t.x+n,o=e[i][t.y];(r||o===` `)&&(e[i][t.y]=a)}}function Ss(e,t,n){let r=0,i=0;for(let e of t.values())r+=e;for(let e of n.values())i+=e;us(e,r-1,i-1)}function Cs(e,t,n){let r=0,i=0;for(let e of t.values())r+=e;for(let e of n.values())i+=e;ss(e,r-1,i-1)}var ws=60,Ts=20,Es={hLine:`─`,vLine:`│`,origin:`┼`,yTick:`┤`,xTick:`┬`,bar:`█`,grid:`·`,cornerTL:`╭`,cornerTR:`╮`,cornerBL:`╰`,cornerBR:`╯`},Ds={hLine:`-`,vLine:`|`,origin:`+`,yTick:`+`,xTick:`+`,bar:`#`,grid:`.`,cornerTL:`+`,cornerTR:`+`,cornerBL:`+`,cornerBR:`+`};function Os(e,t){let n=t.accent??`#3b82f6`;return e<=1?[n]:Array.from({length:e},(e,r)=>zt(r,n,t.bg))}function ks(e,t){switch(e){case`text`:return t.fg;case`border`:return t.border;case`line`:return t.line;case`arrow`:return t.arrow;case`corner`:return t.corner??t.line;case`junction`:return t.junction??t.border;default:return t.fg}}function As(e,t,n,r){let i=At(D(e)),a=t.useAscii?Ds:Es;return i.horizontal?Ms(i,a,n,r):js(i,a,n,r)}function js(e,t,n,r){let i=Ws(e);if(i===0)return``;let a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=Ks(a.min,a.max),s=o.map(e=>qs(e)),c=Math.max(...s.map(e=>e.length))+1,l=Math.max(ws,i*6),u=Ts,d=Math.floor(l/i),f=Gs(e,i),p=!!e.title,m=!!e.xAxis.title,h=!!e.yAxis.title,g=e.series.length>1,_=p?0:-1,v=(p?2:0)+ +!!g,y=h?2:0,b=y+c+1,x=b+d*i+2,S=v+u,C=S+1,w=m?C+1:-1,T=C+1+ +!!m+0,E=Is(x,T),D=Ls(x,T),O=Rs(x,T),k=Os(e.series.length,r),A=e=>{let t=(e-a.min)/(a.max-a.min||1);return Math.round(t*19)},j=e=>b+Math.floor(d*(e+.5));e.title&&_>=0&&Vs(E,D,_,Math.floor(x/2-e.title.length/2),e.title,`text`),g&&Fs(E,D,O,e,+!!p,x,t,k);for(let e=0;e<u;e++)zs(E,D,v+(19-e),b-1,t.vLine,`border`);zs(E,D,S,b-1,t.origin,`border`);for(let e of o){let n=A(e);if(n<0||n>=u)continue;let r=v+(19-n),i=qs(e);zs(E,D,r,b-1,n===0?t.origin:t.yTick,`border`);let a=y+c-i.length;Vs(E,D,r,Math.max(0,a),i,`text`)}for(let e=b;e<b+d*i;e++)zs(E,D,S,e,t.hLine,`border`);for(let e=0;e<i;e++){let n=j(e);zs(E,D,S,n,t.xTick,`border`);let r=f[e],i=n-Math.floor(r.length/2);Vs(E,D,C,Math.max(0,i),r,`text`)}if(e.xAxis.title&&w>=0){let t=e.xAxis.title;Vs(E,D,w,Math.floor(x/2-t.length/2),t,`text`)}if(e.yAxis.title){let t=e.yAxis.title,n=v+Math.max(0,Math.floor((u-t.length)/2));for(let e=0;e<t.length;e++){let r=n+e;if(r>=v+u)break;zs(E,D,r,0,t[e],`text`)}}for(let e of o){let n=A(e);if(n<0||n>=u)continue;let r=v+(19-n);for(let e=b;e<b+d*i;e++)Bs(E,r,e)===` `&&zs(E,D,r,e,t.grid,`line`)}let ee=[];for(let t=0;t<e.series.length;t++)e.series[t].type===`bar`&&ee.push({data:e.series[t].data,globalIdx:t});if(ee.length>0){let e=Math.max(1,d-2),n=Math.max(1,Math.min(e,8)),r=A(Math.max(0,a.min));for(let e=0;e<ee.length;e++){let i=ee[e],a=k[i.globalIdx];for(let e=0;e<i.data.length;e++){let o=j(e)-Math.floor(n/2),s=A(i.data[e]),c=Math.min(r,s),l=Math.max(r,s);for(let e=c;e<=l;e++){let r=v+(19-e);for(let e=o;e<o+n;e++)zs(E,D,r,e,t.bar,`arrow`,O,a)}}}}let M=[];for(let t=0;t<e.series.length;t++)e.series[t].type===`line`&&M.push({data:e.series[t].data,globalIdx:t});for(let e of M){if(e.data.length===0)continue;let n=k[e.globalIdx];Ns(E,D,e.data,j,A,v,u,b,d*i,t,O,n)}return Hs(E,D,O,n,r)}function Ms(e,t,n,r){let i=Ws(e);if(i===0)return``;let a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=Ks(a.min,a.max),s=Gs(e,i),c=Math.max(...s.map(e=>e.length))+1,l=Math.max(ws,40),u=Math.max(2,Math.floor(Ts/i)),d=u*i,f=!!e.title,p=!!e.yAxis.title,m=e.series.length>1,h=(f?2:0)+ +!!m,g=c+1,_=g+l+2,v=h+d+2+ +!!p,y=h+d,b=Is(_,v),x=Ls(_,v),S=Rs(_,v),C=Os(e.series.length,r),w=e=>{let t=(e-a.min)/(a.max-a.min||1);return g+Math.round(t*59)},T=e=>h+Math.floor(u*(e+.5));e.title&&Vs(b,x,0,Math.floor(_/2-e.title.length/2),e.title,`text`),m&&Fs(b,x,S,e,+!!f,_,t,C);for(let e=h;e<h+d;e++)zs(b,x,e,g-1,t.vLine,`border`);zs(b,x,y,g-1,t.origin,`border`);for(let e=0;e<i;e++){let t=T(e),n=s[e],r=c-n.length;Vs(b,x,t,Math.max(0,r),n,`text`)}for(let e=g;e<g+l;e++)zs(b,x,y,e,t.hLine,`border`);for(let e of o){let n=w(e);if(n<g||n>=g+l)continue;zs(b,x,y,n,t.xTick,`border`);let r=qs(e);Vs(b,x,y+1,n-Math.floor(r.length/2),r,`text`)}if(e.yAxis.title){let t=e.yAxis.title;Vs(b,x,v-1,Math.floor(_/2-t.length/2),t,`text`)}for(let e of o){let n=w(e);if(!(n<g||n>=g+l))for(let e=h;e<h+d;e++)Bs(b,e,n)===` `&&zs(b,x,e,n,t.grid,`line`)}let E=[];for(let t=0;t<e.series.length;t++)e.series[t].type===`bar`&&E.push({data:e.series[t].data,globalIdx:t});if(E.length>0){let e=w(Math.max(0,a.min));for(let n=0;n<E.length;n++){let r=E[n],i=C[r.globalIdx];for(let n=0;n<r.data.length;n++){let a=T(n),o=w(r.data[n]),s=Math.min(e,o),c=Math.max(e,o);for(let e=a;e<a+1;e++)for(let n=s;n<=c;n++)zs(b,x,e,n,t.bar,`arrow`,S,i)}}}let D=[];for(let t=0;t<e.series.length;t++)e.series[t].type===`line`&&D.push({data:e.series[t].data,globalIdx:t});for(let e of D){if(e.data.length===0)continue;let n=C[e.globalIdx];Ps(b,x,e.data,T,w,h,d,g,l,t,S,n)}return Hs(b,x,S,n,r)}function Ns(e,t,n,r,i,a,o,s,c,l,u,d){if(n.length===0)return;let f=n.map((e,t)=>({col:r(t),row:i(e)})),p=(n,r,i)=>{let l=a+(o-1-r);l>=0&&n>=s&&n<s+c&&zs(e,t,l,n,i,`arrow`,u,d)};if(f.length===1){p(f[0].col,f[0].row,l.hLine);return}for(let e=0;e<f.length-1;e++){let t=f[e],n=f[e+1];if(t.row===n.row){for(let e=t.col;e<=n.col;e++)p(e,t.row,l.hLine);continue}let r=Math.round((t.col+n.col)/2),i=n.row>t.row;for(let e=t.col;e<r;e++)p(e,t.row,l.hLine);i?p(r,t.row,l.cornerBR):p(r,t.row,l.cornerTR);let a=Math.min(t.row,n.row),o=Math.max(t.row,n.row);for(let e=a+1;e<o;e++)p(r,e,l.vLine);i?p(r,n.row,l.cornerTL):p(r,n.row,l.cornerBL);for(let e=r+1;e<=n.col;e++)p(e,n.row,l.hLine);if(e===0){let e=Math.max(s,t.col-Math.floor((n.col-t.col)/4));for(let n=e;n<t.col;n++)p(n,t.row,l.hLine)}if(e===f.length-2){let e=Math.min(s+c-1,n.col+Math.floor((n.col-t.col)/4));for(let t=n.col+1;t<=e;t++)p(t,n.row,l.hLine)}}}function Ps(e,t,n,r,i,a,o,s,c,l,u,d){if(n.length===0)return;let f=n.map((e,t)=>({row:r(t),col:i(e)})),p=(n,r,i)=>{n>=a&&n<a+o&&r>=s&&r<s+c&&zs(e,t,n,r,i,`arrow`,u,d)};if(f.length===1){p(f[0].row,f[0].col,l.vLine);return}for(let e=0;e<f.length-1;e++){let t=f[e],n=f[e+1];if(t.col===n.col){for(let e=t.row;e<=n.row;e++)p(e,t.col,l.vLine);continue}let r=Math.round((t.row+n.row)/2),i=n.col>t.col;for(let e=t.row;e<r;e++)p(e,t.col,l.vLine);i?p(r,t.col,l.cornerBL):p(r,t.col,l.cornerBR);let a=Math.min(t.col,n.col),o=Math.max(t.col,n.col);for(let e=a+1;e<o;e++)p(r,e,l.hLine);i?p(r,n.col,l.cornerTR):p(r,n.col,l.cornerTL);for(let e=r+1;e<=n.row;e++)p(e,n.col,l.vLine)}}function Fs(e,t,n,r,i,a,o,s){let c=[],l=0,u=0;for(let e=0;e<r.series.length;e++)r.series[e].type===`bar`?(c.push({symbol:o.bar,label:`Bar ${l+1}`,globalIdx:e}),l++):(c.push({symbol:o.hLine,label:`Line ${u+1}`,globalIdx:e}),u++);let d=0;for(let e=0;e<c.length;e++)e>0&&(d+=2),d+=2+c[e].label.length;let f=Math.max(0,Math.floor(a/2-d/2));for(let r=0;r<c.length;r++){r>0&&(f+=2);let a=c[r];zs(e,t,i,f,a.symbol,`arrow`,n,s[a.globalIdx]),f+=1,f+=1,Vs(e,t,i,f,a.label,`text`),f+=a.label.length}}function Is(e,t){return is(e-1,t-1)}function Ls(e,t){return os(e-1,t-1)}function Rs(e,t){return Array.from({length:e},()=>Array.from({length:t}).fill(null))}function zs(e,t,n,r,i,a,o,s){r>=0&&r<e.length&&n>=0&&n<(e[0]?.length??0)&&(q(e,r,n,i,{role:a,roleCanvas:t}),o&&s&&(o[r][n]=s))}function Bs(e,t,n){return n>=0&&n<e.length&&t>=0&&t<e[0].length?e[n][t]:` `}function Vs(e,t,n,r,i,a){for(let o=0;o<i.length;o++)zs(e,t,n,r+o,i[o],a)}function Hs(e,t,n,r,i){if(e.length===0)return``;let a=e[0].length,o=e.length,s=[];for(let c=0;c<a;c++){let a=[],l=[],u=[];for(let r=0;r<o;r++)a.push(e[r][c]),l.push(t[r][c]),u.push(n[r][c]);let d=a.length-1;for(;d>=0&&a[d]===` `;)d--;d<0?s.push(``):s.push(Us(a.slice(0,d+1),l.slice(0,d+1),u.slice(0,d+1),i,r))}for(;s.length>0&&s[s.length-1]===``;)s.pop();return s.join(`
|
|
78
|
+
`)}function Us(e,t,n,r,i){if(i===`none`)return e.join(``);let a=``,o=null,s=``;for(let c=0;c<e.length;c++){let l=e[c];if(l===` `){s.length>0&&(a+=o?Xo(s,o,i):s,s=``,o=null),a+=` `;continue}let u=n[c]??null,d=t[c]??null,f=u??(d?ks(d,r):null);f===o?s+=l:(s.length>0&&(a+=o?Xo(s,o,i):s),s=l,o=f)}return s.length>0&&(a+=o?Xo(s,o,i):s),a}function Ws(e){if(e.xAxis.categories)return e.xAxis.categories.length;for(let t of e.series)if(t.data.length>0)return t.data.length;return 0}function Gs(e,t){if(e.xAxis.categories)return e.xAxis.categories;if(e.xAxis.range){let{min:n,max:r}=e.xAxis.range,i=t>1?(r-n)/(t-1):0;return Array.from({length:t},(e,t)=>qs(n+i*t))}return Array.from({length:t},(e,t)=>String(t+1))}function Ks(e,t){let n=t-e;if(n<=0)return[e];let r=n/6,i=10**Math.floor(Math.log10(r)),a=r/i,o;o=a<=1.5?i:a<=3?2*i:a<=7?5*i:10*i;let s=Math.ceil(e/o)*o,c=[];for(let e=s;e<=t+o*.001;e+=o)c.push(Math.round(e*1e10)/1e10);return c}function qs(e){return Number.isInteger(e)?String(e):e.toFixed(+(Math.abs(e)<10))}var J={x:1,y:0},Y={x:1,y:2},X={x:0,y:1},Z={x:2,y:1},Js={x:2,y:0},Ys={x:0,y:0},Xs={x:2,y:2},Zs={x:0,y:2},Qs={x:1,y:1};function Q(e,t){return e.x===t.x&&e.y===t.y}function $s(e){return Q(e,J)||Q(e,Y)||Q(e,X)||Q(e,Z)}function ec(e){if(!$s(e))throw Error(`Expected a cardinal direction (Up/Down/Left/Right); got {x:${e.x}, y:${e.y}}`);return e}function tc(e,t,n,r){return Math.max(r,n+(e-t))}function nc(e,t){return e.x===t.x&&e.y===t.y}function rc(e,t){return e.x===t.x&&e.y===t.y}function ic(e,t){return{x:e.x+t.x,y:e.y+t.y}}function ac(e){return`${e.x},${e.y}`}function oc(e){let t=e.gridCoord;if(t===null)throw Error(`Node "${e.name}" has no gridCoord; grid layout must run before it is read`);return t}var sc={name:``,styles:{}},cc=class{#e=new Set;has(e){return this.#e.has(e)}add(e){this.#e.add(e)}delete(e){this.#e.delete(e)}keys(){return this.#e.keys()}};function lc(){return new cc}function uc(e){let t=lc();for(let n of e.keys())t.add(n);return t}function dc(e,t){return e.has(ac(t))}function fc(e,t){return t.x<0||t.y<0?!1:!dc(e,t)}function pc(e,t,n=3){for(let r=0;r<n;r++)for(let i=0;i<n;i++)if(dc(e,{x:t.x+r,y:t.y+i}))return!1;return!0}function mc(e,t,n=3){if(!pc(e,t,n))throw Error(`Grid block at (${t.x},${t.y}) is already occupied`);for(let r=0;r<n;r++)for(let i=0;i<n;i++){let n={x:t.x+r,y:t.y+i};e.add(ac(n))}}var hc=1e5;function gc(e){if(e.length===0)return[];let t=[e[0]];for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n],a=r.x,o=r.y,s=Math.abs(i.x-r.x),c=Math.abs(i.y-r.y),l=r.x<i.x?1:-1,u=r.y<i.y?1:-1,d=s-c,f=0;for(;a!==i.x||o!==i.y;){if(f>=hc)throw Error(`pathCells: segment from (${r.x},${r.y}) to (${i.x},${i.y}) did not reach its endpoint within ${hc} steps`);let e=2*d;e>-c&&(d-=c,a+=l),e<s&&(d+=s,o+=u),t.push({x:a,y:o}),f++}}return t}var _c=class{items=[];get length(){return this.items.length}push(e){this.items.push(e),this.bubbleUp(this.items.length-1)}pop(){if(this.items.length===0)return;let e=this.items[0],t=this.items.pop();return this.items.length>0&&(this.items[0]=t,this.sinkDown(0)),e}bubbleUp(e){let t=e;for(;t>0;){let e=t-1>>1;if(this.items[t].priority<this.items[e].priority)[this.items[t],this.items[e]]=[this.items[e],this.items[t]],t=e;else break}}sinkDown(e){let t=this.items.length,n=e;for(;;){let e=n,r=2*n+1,i=2*n+2;if(r<t&&this.items[r].priority<this.items[e].priority&&(e=r),i<t&&this.items[i].priority<this.items[e].priority&&(e=i),e!==n)[this.items[n],this.items[e]]=[this.items[e],this.items[n]],n=e;else break}}};function vc(e,t){let n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);return n===0||r===0?n+r:n+r+1}var yc=[{x:1,y:0},{x:-1,y:0},{x:0,y:1},{x:0,y:-1}],bc=5e4,xc=2e5;function Sc(e=xc){return{remaining:e}}function Cc(e,t,n,r){if(r&&r.remaining<=0)return null;let i=new _c;i.push({coord:t,priority:0});let a=new Map;a.set(ac(t),0);let o=new Map;o.set(ac(t),null);let s=0;for(;i.length>0;){if(++s>bc)return null;if(r){if(r.remaining<=0)return null;r.remaining--}let t=i.pop().coord;if(nc(t,n)){let e=[],n=t;for(;n!==null;)e.unshift(n),n=o.get(ac(n))??null;return e}let c=a.get(ac(t));if(c===void 0)throw Error(`A* pathfinding: missing cost for visited cell ${ac(t)}`);for(let r of yc){let s={x:t.x+r.x,y:t.y+r.y};if(!fc(e,s)&&!nc(s,n))continue;let l=c+1,u=ac(s),d=a.get(u);if(d===void 0||l<d){a.set(u,l);let e=l+vc(s,n);i.push({coord:s,priority:e}),o.set(u,t)}}}return null}function wc(e){if(e.length<=2)return e;let t=new Set,n=e[0],r=e[1];for(let i=2;i<e.length;i++){let a=e[i],o=r.x-n.x,s=r.y-n.y,c=a.x-r.x,l=a.y-r.y;o===c&&s===l&&t.add(i-1),n=r,r=a}return e.filter((e,n)=>!t.has(n))}function Tc(e,t,n,r){if(t.x===n.x&&t.y===n.y)return!0;let i=t.x===n.x;if(!i&&t.y!==n.y)return!1;let a=i?n.y>t.y?1:-1:n.x>t.x?1:-1,o=i?t.y:t.x,s=i?n.y:n.x;for(o+=a;;o+=a){let n=o===s,a=i?{x:t.x,y:o}:{x:o,y:t.y};if(!(n&&!r)&&!fc(e,a))return!1;if(n)break}return!0}function Ec(e,t,n,r){let i=r?{x:n.x,y:t.y}:{x:t.x,y:n.y};return!Tc(e,t,i,!0)||!Tc(e,i,n,!1)?null:[t,i,n]}function Dc(e,t,n,r){if(t.x===n.x||t.y===n.y)return null;let i=Q(r,X)||Q(r,Z);return Ec(e.grid,t,n,i)??Ec(e.grid,t,n,!i)}function Oc(e,t,n,r){if(!e.pathBudget)throw Error(`routeEdge requires graph.pathBudget to be set; call createPathBudget() (see grid.ts createMapping) before routing edges`);let i=Dc(e,t,n,r)??Cc(e.grid,t,n,e.pathBudget);return i?wc(i):null}function kc(e){if(e.config.graphDirection!==`TD`)return[];let t=[],n=new Set,r=new Map;for(let t of e.edges){if(t.from===t.to)continue;let e=r.get(t.to)??[];e.push(t),r.set(t.to,e)}for(let[i,a]of r){if(a.length<2||!Ac(a,e)||a.some(e=>n.has(e)))continue;let r={type:`fan-in`,edges:[...a],sharedNode:i,otherNodes:a.map(e=>e.from),junctionPoint:null,sharedPath:[],junctionDir:Qs,sharedNodeDir:Qs};for(let e of a)e.bundle=r,n.add(e);t.push(r)}let i=new Map;for(let t of e.edges){if(t.from===t.to||n.has(t))continue;let e=i.get(t.from)??[];e.push(t),i.set(t.from,e)}for(let[r,a]of i){if(a.length<2||!Ac(a,e))continue;let i={type:`fan-out`,edges:[...a],sharedNode:r,otherNodes:a.map(e=>e.to),junctionPoint:null,sharedPath:[],junctionDir:Qs,sharedNodeDir:Qs};for(let e of a)e.bundle=i,n.add(e);t.push(i)}return t}function Ac(e,t){if(e.length<2)return!1;let n=e[0].style,r=rl(t,e[0].from),i=rl(t,e[0].to);for(let a of e){if(a.style!==n||a.text.length>0)return!1;let e=rl(t,a.from),o=rl(t,a.to);if(e!==r||o!==i||e!==o)return!1}let a=e.every(t=>t.to===e[0].to),o=a?e.map(e=>e.from):e.map(e=>e.to);if(new Set(o).size!==o.length||e.some(e=>e.parallelLane))return!1;let s=t.config.graphDirection===`LR`?`x`:`y`,c=(a?e[0].to:e[0].from).gridCoord;if(!c)return!1;for(let t of e){let e=(a?t.from:t.to).gridCoord;if(!e)return!1;if(a){if(e[s]>=c[s])return!1}else if(e[s]<=c[s])return!1}return!0}function jc(e,t){let n=e.config.graphDirection,r=oc(t.sharedNode);if(t.type===`fan-in`){if(n===`TD`){let e=r.y-1;return{x:r.x+1,y:e}}return{x:r.x-1,y:r.y+1}}if(n===`TD`){let e=r.y+3;return{x:r.x+1,y:e}}return{x:r.x+3,y:r.y+1}}function Mc(e,t){let n=e.config.graphDirection;t.junctionPoint=jc(e,t);let r=t.junctionPoint;if(t.type===`fan-in`){t.junctionDir=n===`TD`?J:X,t.sharedNodeDir=n===`TD`?Y:Z;let i=oc(t.sharedNode),a=ec(n===`TD`?J:X),o=ic(i,a);t.sharedPath=Oc(e,r,o,a)??[r,o];for(let i of t.edges){let o=oc(i.from),s=ec(n===`TD`?Y:Z),c=ic(o,s);i.pathToJunction=Oc(e,c,r,s)??[c,r],i.startDir=s,i.endDir=a,i.path=[...i.pathToJunction,...t.sharedPath.slice(1)]}}else{t.junctionDir=n===`TD`?Y:Z,t.sharedNodeDir=n===`TD`?J:X;let i=oc(t.sharedNode),a=ec(n===`TD`?Y:Z),o=ic(i,a);t.sharedPath=Oc(e,o,r,a)??[o,r];for(let i of t.edges){let o=oc(i.to),s=ec(n===`TD`?J:X),c=ic(o,s);i.pathToJunction=Oc(e,r,c,s)??[r,c],i.startDir=a,i.endDir=s,i.path=[...t.sharedPath,...i.pathToJunction.slice(1)]}}}function Nc(e){for(let t of e.bundles)Mc(e,t)}function Pc(){return new Map}function Fc(e,t,n,r){for(let i of gc(n)){if(dc(e,i))continue;let n=t.get(ac(i));if(n!==void 0&&n!==r)return i}return null}function Ic(e,t,n,r){for(let i of gc(n)){if(dc(e,i))continue;let n=ac(i);t.has(n)||t.set(n,r)}}function $(e){return e.split(`
|
|
79
|
+
`)}function Lc(e){let t=$(e);return Math.max(...t.map(e=>K(e)),0)}function Rc(e){return $(e).length}var zc={rectangle:{unicode:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`+`,tr:`+`,bl:`+`,br:`+`}},rounded:{unicode:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`},ascii:{tl:`.`,tr:`.`,bl:`'`,br:`'`}},circle:{unicode:{tl:`◯`,tr:`◯`,bl:`◯`,br:`◯`},ascii:{tl:`o`,tr:`o`,bl:`o`,br:`o`}},doublecircle:{unicode:{tl:`◎`,tr:`◎`,bl:`◎`,br:`◎`},ascii:{tl:`@`,tr:`@`,bl:`@`,br:`@`}},diamond:{unicode:{tl:`◇`,tr:`◇`,bl:`◇`,br:`◇`},ascii:{tl:`<`,tr:`>`,bl:`<`,br:`>`}},hexagon:{unicode:{tl:`⌜`,tr:`⌝`,bl:`⌞`,br:`⌟`},ascii:{tl:`*`,tr:`*`,bl:`*`,br:`*`}},stadium:{unicode:{tl:`(`,tr:`)`,bl:`(`,br:`)`},ascii:{tl:`(`,tr:`)`,bl:`(`,br:`)`}},subroutine:{unicode:{tl:`╟`,tr:`╢`,bl:`╟`,br:`╢`},ascii:{tl:`|`,tr:`|`,bl:`|`,br:`|`}},cylinder:{unicode:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`},ascii:{tl:`.`,tr:`.`,bl:`'`,br:`'`}},asymmetric:{unicode:{tl:`▷`,tr:`┐`,bl:`▷`,br:`┘`},ascii:{tl:`>`,tr:`+`,bl:`>`,br:`+`}},trapezoid:{unicode:{tl:`/`,tr:`\\`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`\\`,bl:`+`,br:`+`}},"trapezoid-alt":{unicode:{tl:`┌`,tr:`┐`,bl:`\\`,br:`/`},ascii:{tl:`+`,tr:`+`,bl:`\\`,br:`/`}},parallelogram:{unicode:{tl:`/`,tr:`/`,bl:`/`,br:`/`},ascii:{tl:`/`,tr:`/`,bl:`/`,br:`/`}},"parallelogram-alt":{unicode:{tl:`\\`,tr:`\\`,bl:`\\`,br:`\\`},ascii:{tl:`\\`,tr:`\\`,bl:`\\`,br:`\\`}},"state-start":{unicode:{tl:`●`,tr:`●`,bl:`●`,br:`●`},ascii:{tl:`*`,tr:`*`,bl:`*`,br:`*`}},"state-end":{unicode:{tl:`◉`,tr:`◉`,bl:`◉`,br:`◉`},ascii:{tl:`@`,tr:`@`,bl:`@`,br:`@`}},document:{unicode:{tl:`┌`,tr:`┐`,bl:`╰`,br:`╮`},ascii:{tl:`+`,tr:`+`,bl:`'`,br:`~`}},"stacked-document":{unicode:{tl:`┌`,tr:`╗`,bl:`╰`,br:`╮`},ascii:{tl:`+`,tr:`#`,bl:`'`,br:`~`}},"stacked-process":{unicode:{tl:`┌`,tr:`╗`,bl:`└`,br:`╝`},ascii:{tl:`+`,tr:`#`,bl:`+`,br:`#`}},card:{unicode:{tl:`╱`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`+`,bl:`+`,br:`+`}},"lined-process":{unicode:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`+`,tr:`+`,bl:`+`,br:`+`}},"divided-process":{unicode:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`+`,tr:`+`,bl:`+`,br:`+`}},"window-pane":{unicode:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`+`,tr:`+`,bl:`+`,br:`+`}},triangle:{unicode:{tl:`╱`,tr:`╲`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`\\`,bl:`+`,br:`+`}},"flipped-triangle":{unicode:{tl:`┌`,tr:`┐`,bl:`╲`,br:`╱`},ascii:{tl:`+`,tr:`+`,bl:`\\`,br:`/`}},"filled-circle":{unicode:{tl:`●`,tr:`●`,bl:`●`,br:`●`},ascii:{tl:`*`,tr:`*`,bl:`*`,br:`*`}},"crossed-circle":{unicode:{tl:`╳`,tr:`╳`,bl:`╳`,br:`╳`},ascii:{tl:`X`,tr:`X`,bl:`X`,br:`X`}},"fork-join":{unicode:{tl:`━`,tr:`━`,bl:`━`,br:`━`},ascii:{tl:`=`,tr:`=`,bl:`=`,br:`=`}},"notched-pentagon":{unicode:{tl:`╱`,tr:`╲`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`\\`,bl:`+`,br:`+`}},"sloped-rectangle":{unicode:{tl:`╱`,tr:`┐`,bl:`└`,br:`┘`},ascii:{tl:`/`,tr:`+`,bl:`+`,br:`+`}},flag:{unicode:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`},ascii:{tl:`~`,tr:`~`,bl:`~`,br:`~`}},"bow-tie-rectangle":{unicode:{tl:`╲`,tr:`╱`,bl:`╱`,br:`╲`},ascii:{tl:`\\`,tr:`/`,bl:`/`,br:`\\`}},"half-rounded-rectangle":{unicode:{tl:`┌`,tr:`╮`,bl:`└`,br:`╯`},ascii:{tl:`+`,tr:`.`,bl:`+`,br:`'`}},brace:{unicode:{tl:`╭`,tr:`┐`,bl:`╰`,br:`┘`},ascii:{tl:`{`,tr:`+`,bl:`{`,br:`+`}},"brace-right":{unicode:{tl:`┌`,tr:`╮`,bl:`└`,br:`╯`},ascii:{tl:`+`,tr:`}`,bl:`+`,br:`}`}},braces:{unicode:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`},ascii:{tl:`{`,tr:`}`,bl:`{`,br:`}`}},bolt:{unicode:{tl:`╱`,tr:`╲`,bl:`╲`,br:`╱`},ascii:{tl:`/`,tr:`\\`,bl:`\\`,br:`/`}},text:{unicode:{tl:` `,tr:` `,bl:` `,br:` `},ascii:{tl:` `,tr:` `,bl:` `,br:` `}},anchor:{unicode:{tl:` `,tr:` `,bl:` `,br:` `},ascii:{tl:` `,tr:` `,bl:` `,br:` `}}};function Bc(e,t){let n=zc[e]??zc.rectangle;return t?n.ascii:n.unicode}function Vc(e,t){let n=$(e),r=Math.max(...n.map(e=>K(e)),0),i=n.length,a=2*t.padding+r,o=a+2,s=i+2*t.padding,c=s%2==0?s+1:s;return{width:o,height:c+2,labelArea:{x:1+t.padding,y:1+t.padding,width:r,height:i},gridColumns:[1,a,1],gridRows:[1,c,1]}}function Hc(e,t,n,r){let{width:i,height:a}=t,o=is(i-1,a-1),s={x:0,y:0},c={x:i-1,y:a-1},l=r?`-`:`─`,u=r?`|`:`│`;for(let e=s.x+1;e<c.x;e++)o[e][s.y]=l,o[e][c.y]=l;for(let e=s.y+1;e<c.y;e++)o[s.x][e]=u,o[c.x][e]=u;o[s.x][s.y]=n.tl,o[c.x][s.y]=n.tr,o[s.x][c.y]=n.bl,o[c.x][c.y]=n.br;let d=$(e),f=i-1,p=a-1,m=Math.floor(p/2)-Math.floor((d.length-1)/2);for(let e=0;e<d.length;e++){let t=d[e],n=Math.floor(f/2)-Math.ceil(K(t)/2)+1,r=rs(t);for(let t=0;t<r.length;t++){let i=n+t,a=m+e;i>=0&&i<o.length&&a>=0&&a<o[0].length&&(o[i][a]=r[t])}}return o}function Uc(e,t,n){let{width:r,height:i}=t,a=n.x+Math.floor(r/2),o=n.y+Math.floor(i/2);return Q(e,J)?{x:a,y:n.y}:Q(e,Y)?{x:a,y:n.y+i-1}:Q(e,X)?{x:n.x,y:o}:Q(e,Z)?{x:n.x+r-1,y:o}:Q(e,Ys)?{x:n.x,y:n.y}:Q(e,Js)?{x:n.x+r-1,y:n.y}:Q(e,Zs)?{x:n.x,y:n.y+i-1}:Q(e,Xs)?{x:n.x+r-1,y:n.y+i-1}:{x:a,y:o}}var Wc={getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`rectangle`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc},Gc=new Map([[`rectangle`,Wc],[`rounded`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`rounded`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`diamond`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`diamond`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`stadium`,{getDimensions(e,t){let n=$(e),r=Math.max(...n.map(e=>K(e)),0),i=n.length,a=2*t.padding+r,o=a+4,s=i+2*t.padding;return{width:o,height:Math.max(s+2,3),labelArea:{x:2+t.padding,y:1+t.padding,width:r,height:i},gridColumns:[2,a,2],gridRows:[1,s,1]}},render(e,t,n){let{width:r,height:i}=t,a=is(r-1,i-1),o=Math.floor(i/2),s=n.useAscii?`-`:`─`;if(i===3)a[0][o]=`(`,a[r-1][o]=`)`;else if(n.useAscii){for(let e=0;e<i;e++)a[0][e]=`(`,a[r-1][e]=`)`;for(let e=1;e<r-1;e++)a[e][0]=s,a[e][i-1]=s}else{a[0][0]=`╭`;for(let e=1;e<r-1;e++)a[e][0]=s;a[r-1][0]=`╮`;for(let e=1;e<i-1;e++)a[0][e]=`│`,a[r-1][e]=`│`;a[0][i-1]=`╰`;for(let e=1;e<r-1;e++)a[e][i-1]=s;a[r-1][i-1]=`╯`}let c=$(e),l=o-Math.floor((c.length-1)/2);for(let e=0;e<c.length;e++){let t=c[e],n=Math.floor(r/2)-Math.floor(K(t)/2),o=rs(t);for(let t=0;t<o.length;t++){let s=n+t,c=l+e;s>0&&s<r-1&&c>=0&&c<i&&(a[s][c]=o[t])}}return a},getAttachmentPoint:Uc}],[`circle`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`circle`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`subroutine`,{getDimensions(e,t){let n=$(e),r=Math.max(...n.map(e=>K(e)),0),i=n.length,a=2*t.padding+r,o=a+4,s=i+2*t.padding;return{width:o,height:s+2,labelArea:{x:2+t.padding,y:1+t.padding,width:r,height:i},gridColumns:[2,a,2],gridRows:[1,s,1]}},render(e,t,n){let{width:r,height:i}=t,a=is(r-1,i-1),o=n.useAscii?`-`:`─`,s=n.useAscii?`|`:`│`;a[0][0]=n.useAscii?`+`:`┌`,a[1][0]=n.useAscii?`+`:`┬`;for(let e=2;e<r-2;e++)a[e][0]=o;a[r-2][0]=n.useAscii?`+`:`┬`,a[r-1][0]=n.useAscii?`+`:`┐`;for(let e=1;e<i-1;e++)a[0][e]=s,a[1][e]=s,a[r-2][e]=s,a[r-1][e]=s;a[0][i-1]=n.useAscii?`+`:`└`,a[1][i-1]=n.useAscii?`+`:`┴`;for(let e=2;e<r-2;e++)a[e][i-1]=o;a[r-2][i-1]=n.useAscii?`+`:`┴`,a[r-1][i-1]=n.useAscii?`+`:`┘`;let c=$(e),l=Math.floor(i/2)-Math.floor((c.length-1)/2);for(let e=0;e<c.length;e++){let t=c[e],n=Math.floor(r/2)-Math.floor(K(t)/2),o=rs(t);for(let t=0;t<o.length;t++){let s=n+t,c=l+e;s>1&&s<r-2&&c>0&&c<i-1&&(a[s][c]=o[t])}}return a},getAttachmentPoint:Uc}],[`doublecircle`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`doublecircle`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`hexagon`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`hexagon`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`cylinder`,{getDimensions(e,t){let n=$(e),r=Math.max(...n.map(e=>K(e)),0),i=n.length,a=2*t.padding+r,o=a+2,s=i+2*t.padding+2;return{width:o,height:s+2,labelArea:{x:1+t.padding,y:2+t.padding,width:r,height:i},gridColumns:[1,a,1],gridRows:[2,s-2,2]}},render(e,t,n){let{width:r,height:i}=t,a=is(r-1,i-1),o=n.useAscii?`-`:`─`,s=n.useAscii?`|`:`│`;a[0][0]=n.useAscii?`.`:`╭`;for(let e=1;e<r-1;e++)a[e][0]=o;a[r-1][0]=n.useAscii?`.`:`╮`,a[0][1]=s;for(let e=1;e<r-1;e++)a[e][1]=o;a[r-1][1]=s;for(let e=2;e<i-2;e++)a[0][e]=s,a[r-1][e]=s;a[0][i-2]=s;for(let e=1;e<r-1;e++)a[e][i-2]=o;a[r-1][i-2]=s,a[0][i-1]=n.useAscii?`'`:`╰`;for(let e=1;e<r-1;e++)a[e][i-1]=o;a[r-1][i-1]=n.useAscii?`'`:`╯`;let c=$(e),l=Math.floor(i/2)-Math.floor((c.length-1)/2);for(let e=0;e<c.length;e++){let t=c[e],n=Math.floor(r/2)-Math.floor(K(t)/2),o=rs(t);for(let t=0;t<o.length;t++){let s=n+t,c=l+e;s>0&&s<r-1&&c>1&&c<i-2&&(a[s][c]=o[t])}}return a},getAttachmentPoint:Uc}],[`asymmetric`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`asymmetric`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`trapezoid`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`trapezoid`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`trapezoid-alt`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`trapezoid-alt`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`parallelogram`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`parallelogram`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`parallelogram-alt`,{getDimensions:Vc,render(e,t,n){return Hc(e,t,Bc(`parallelogram-alt`,n.useAscii),n.useAscii)},getAttachmentPoint:Uc}],[`state-start`,{getDimensions(e,t){return{width:5,height:3,labelArea:{x:2,y:1,width:1,height:1},gridColumns:[1,3,1],gridRows:[1,1,1]}},render(e,t,n){let{width:r,height:i}=t,a=is(r-1,i-1),o=Math.floor(r/2);return n.useAscii?(a[0][0]=`.`,a[1][0]=`-`,a[2][0]=`-`,a[3][0]=`-`,a[4][0]=`.`,a[0][1]=`|`,a[o][1]=`*`,a[4][1]=`|`,a[0][2]=`'`,a[1][2]=`-`,a[2][2]=`-`,a[3][2]=`-`,a[4][2]=`'`):(a[0][0]=`╭`,a[1][0]=`─`,a[2][0]=`─`,a[3][0]=`─`,a[4][0]=`╮`,a[0][1]=`│`,a[o][1]=`●`,a[4][1]=`│`,a[0][2]=`╰`,a[1][2]=`─`,a[2][2]=`─`,a[3][2]=`─`,a[4][2]=`╯`),a},getAttachmentPoint(e,t,n){let{width:r,height:i}=t,a=n.x+Math.floor(r/2),o=n.y+Math.floor(i/2);return Q(e,J)?{x:a,y:n.y}:Q(e,Y)?{x:a,y:n.y+i-1}:Q(e,X)?{x:n.x,y:o}:Q(e,Z)?{x:n.x+r-1,y:o}:{x:a,y:o}}}],[`state-end`,{getDimensions(e,t){return{width:5,height:3,labelArea:{x:2,y:1,width:1,height:1},gridColumns:[1,3,1],gridRows:[1,1,1]}},render(e,t,n){let{width:r,height:i}=t,a=is(r-1,i-1),o=Math.floor(r/2);return n.useAscii?(a[0][0]=`#`,a[1][0]=`=`,a[2][0]=`=`,a[3][0]=`=`,a[4][0]=`#`,a[0][1]=`#`,a[o][1]=`*`,a[4][1]=`#`,a[0][2]=`#`,a[1][2]=`=`,a[2][2]=`=`,a[3][2]=`=`,a[4][2]=`#`):(a[0][0]=`╔`,a[1][0]=`═`,a[2][0]=`═`,a[3][0]=`═`,a[4][0]=`╗`,a[0][1]=`║`,a[o][1]=`◎`,a[4][1]=`║`,a[0][2]=`╚`,a[1][2]=`═`,a[2][2]=`═`,a[3][2]=`═`,a[4][2]=`╝`),a},getAttachmentPoint(e,t,n){let{width:r,height:i}=t,a=n.x+Math.floor(r/2),o=n.y+Math.floor(i/2);return Q(e,J)?{x:a,y:n.y}:Q(e,Y)?{x:a,y:n.y+i-1}:Q(e,X)?{x:n.x,y:o}:Q(e,Z)?{x:n.x+r-1,y:o}:{x:a,y:o}}}]]);function Kc(e){return Gc.get(e)??Wc}function qc(e,t,n){return Kc(e).getDimensions(t,n)}function Jc(e,t,n,r){return Kc(e).getAttachmentPoint(t,n,r)}function Yc(e,t,n){let r=n?{x:t.x+n.x,y:t.y+n.y}:t,i=0;for(let t=0;t<r.x;t++)i+=e.columnWidth.get(t)??0;let a=0;for(let t=0;t<r.y;t++)a+=e.rowHeight.get(t)??0;let o=e.columnWidth.get(r.x)??0,s=e.rowHeight.get(r.y)??0;return{x:i+Math.floor(o/2)+e.offsetX,y:a+Math.floor(s/2)+e.offsetY}}function Xc(e,t){return t.map(t=>Yc(e,t))}function Zc(e,t,n,r){let i=r??cl(e,t);return pc(e.grid,n,3)?(mc(e.grid,n,3),t.gridCoord=n,n):i===`LR`?Zc(e,t,{x:n.x,y:n.y+4},i):Zc(e,t,{x:n.x+4,y:n.y},i)}function Qc(e,t){let n=oc(t),r=e.config.boxBorderPadding,i=qc(t.shape,t.displayLabel,{useAscii:e.config.useAscii,padding:r}),a=i.gridColumns,o=i.gridRows;for(let t=0;t<a.length;t++){let r=n.x+t,i=e.columnWidth.get(r)??0;e.columnWidth.set(r,Math.max(i,a[t]))}for(let t=0;t<o.length;t++){let r=n.y+t,i=e.rowHeight.get(r)??0;e.rowHeight.set(r,Math.max(i,o[t]))}if(n.x>0){let t=e.columnWidth.get(n.x-1)??0;e.columnWidth.set(n.x-1,Math.max(t,e.config.paddingX))}if(n.y>0){let r=e.config.paddingY;ll(e,t)&&(r+=4);let i=e.rowHeight.get(n.y-1)??0;e.rowHeight.set(n.y-1,Math.max(i,r))}}function $c(e,t){for(let n of t)e.columnWidth.has(n.x)||e.columnWidth.set(n.x,Math.floor(e.config.paddingX/2)),e.rowHeight.has(n.y)||e.rowHeight.set(n.y,Math.floor(e.config.paddingY/2))}var el=8;function tl(e,t,n,r){let i=[];try{for(let a=0;a<el;a++){let a=Fc(r,n,t.path,t.style);if(!a)return;e.grid.add(ac(a)),i.push(a),Ll(e,t)}}finally{for(let t of i)e.grid.delete(ac(t))}}function nl(e,t){return e.subgraphs.some(e=>e.nodes.includes(t))}function rl(e,t){let n=null;for(let r of e.subgraphs)r.nodes.includes(t)&&(!n||il(n,r))&&(n=r);return n}function il(e,t){let n=t;for(;n!==null;){if(n===e)return!0;n=n.parent}return!1}function al(e,t){let n=rl(e,t);if(!n)return null;let r=n;for(;r.parent;)r=r.parent;return r}function ol(e){let t=[...e.nodes];for(let n of e.children)t.push(...ol(n));return t}function sl(e,t,n){if(t===n)return!0;let r=new Set([t]),i=[t];for(;i.length>0;){let t=i.shift();for(let a of wl(e,t)){if(a===n)return!0;r.has(a)||(r.add(a),i.push(a))}}return!1}function cl(e,t){let n=rl(e,t);return n?.direction?n.direction:e.config.graphDirection}function ll(e,t){let n=rl(e,t);if(!n)return!1;let r=!1;for(let i of e.edges)if(i.to===t&&rl(e,i.from)!==n){r=!0;break}if(!r)return!1;let i=oc(t).y;for(let r of n.nodes){if(r===t||!r.gridCoord)continue;let a=!1;for(let t of e.edges)if(t.to===r&&rl(e,t.from)!==n){a=!0;break}if(a&&r.gridCoord.y<i)return!1}return!0}function ul(e,t){if(t.nodes.length===0)return;let n=1e6,r=1e6,i=-1e6,a=-1e6;for(let o of t.children)ul(e,o),o.nodes.length>0&&(n=Math.min(n,o.minX),r=Math.min(r,o.minY),i=Math.max(i,o.maxX),a=Math.max(a,o.maxY));for(let e of t.nodes){if(!e.drawingCoord||!e.drawing)continue;let t=e.drawingCoord.x,o=e.drawingCoord.y,s=t+e.drawing.length-1,c=o+e.drawing[0].length-1;n=Math.min(n,t),r=Math.min(r,o),i=Math.max(i,s),a=Math.max(a,c)}t.minX=n-2,t.minY=r-2-2,t.maxX=i+2,t.maxY=a+2;let o=Math.max(0,...$(t.name).map(e=>K(e))),s=t.maxX-t.minX,c=o+1;if(c>s){let e=c-s,n=Math.floor(e/2),r=e-n;t.minX-=n,t.maxX+=r}}function dl(e){let t=e.subgraphs.filter(e=>e.parent===null&&e.nodes.length>0);for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let r=t[e],i=t[n];r.minX<i.maxX&&r.maxX>i.minX&&(r.maxY>=i.minY-1&&r.minY<i.minY?i.minY=r.maxY+1+1:i.maxY>=r.minY-1&&i.minY<r.minY&&(r.minY=i.maxY+1+1)),r.minY<i.maxY&&r.maxY>i.minY&&(r.maxX>=i.minX-1&&r.minX<i.minX?i.minX=r.maxX+1+1:i.maxX>=r.minX-1&&i.minX<r.minX&&(r.minX=i.maxX+1+1))}}function fl(e){for(let t of e.subgraphs)ul(e,t);dl(e)}function pl(e){if(e.subgraphs.length===0)return;let t=0,n=0;for(let r of e.subgraphs)t=Math.min(t,r.minX),n=Math.min(n,r.minY);let r=-t,i=-n;if(r!==0||i!==0){e.offsetX=r,e.offsetY=i;for(let t of e.subgraphs)t.minX+=r,t.minY+=i,t.maxX+=r,t.maxY+=i;for(let t of e.nodes)t.drawingCoord&&(t.drawingCoord.x+=r,t.drawingCoord.y+=i)}}function ml(e,t){let n=t=>{let n=wl(e,t);return n.length>0?n[0].name:null},r=new Map,i=t.map((e,t)=>{let i=n(e);if(i===null)return t;let a=r.get(i);return a===void 0?(r.set(i,t),t):a});return t.map((e,t)=>({node:e,i:t})).sort((e,t)=>i[e.i]-i[t.i]||e.i-t.i).map(({node:e})=>e)}function hl(e,t){let n=new Set,r=t=>{let r=[t];for(;r.length>0;){let t=r.shift();if(!n.has(t.name)){n.add(t.name);for(let n of wl(e,t))r.push(n)}}};for(let e of t)r(e);let i=[...t];for(let t of e.nodes)n.has(t.name)||(i.push(t),r(t));return i}function gl(e,t){return e.nodes.find(e=>e.gridCoord!==null&&e.gridCoord.x===t.x&&e.gridCoord.y===t.y)}function _l(e,t,n,r,i){let a=r===`x`?`y`:`x`,o=i=>{let o=4;for(;;){let s=t[r]+i*o;if(s<0)return null;let c=r===`x`?{x:s,y:t[a]}:{x:t[a],y:s};if(pc(e.grid,c,3))return c;let l=gl(e,c);if(!l||al(e,l)!==n)return null;o+=4}};return o(i)??o(i*-1)}function vl(e,t,n,r){let i=al(e,t);if(!i)return;let a=n.get(i);if(!a)return;n.delete(i);let o=oc(t),s=cl(e,t)===`LR`?`y`:`x`;for(let t of a){let n=cl(e,t),a=_l(e,o,i,s,1);Zc(e,e.nodes[t.index],a??o,n),r.add(t)}}function yl(e,t){let n=!0;for(;n;){n=!1;let r=t=>e.config.graphDirection===`LR`?t.gridCoord?.y??0:t.gridCoord?.x??0,i=e.nodes.filter(e=>e.gridCoord!==null).sort((e,t)=>r(e)-r(t));for(let r of i){let i=r.gridCoord;if(i===null)continue;let a=[...wl(e,r)].sort((t,n)=>Cl(e,t,n));for(let o of a){if(o.gridCoord!==null)continue;let a=rl(e,r),s=rl(e,o),c=a&&a===s&&a.direction?a.direction:e.config.graphDirection,l=c===`LR`?i.x+4:i.y+4,u;u=c===e.config.graphDirection?t[l]??0:c===`LR`?i.y:i.x;let d=c===`LR`?{x:l,y:u}:{x:u,y:l};Zc(e,e.nodes[o.index],d,c),c===e.config.graphDirection&&(t[l]=u+4),n=!0}}}}function bl(e){let t=e.config.graphDirection,n=[],r=new Set;for(let t of e.edges)t.from!==t.to&&r.add(t.to.name);let i=hl(e,e.nodes.filter(e=>!r.has(e.name))).filter(t=>{let n=rl(e,t);if(!n)return!0;for(let r of e.edges)if(r.to===t&&rl(e,r.from)!==n)return!1;return!0}),a=new Set(i),o=[],s=[];for(let t of i){let n=al(e,t);n!==null&&ol(n).some(n=>n!==t&&!a.has(n)&&!sl(e,t,n))?o.push(t):s.push(t)}let c=ml(e,s),l=new Map;for(let t of o){let n=al(e,t),r=l.get(n);r?r.push(t):l.set(n,[t])}let u=new Set,d=!1,f=!1;for(let t of c)nl(e,t)?wl(e,t).length>0&&(f=!0):d=!0;let p=t===`LR`&&d&&f,m,h=[];p?(m=c.filter(t=>!nl(e,t)),h=c.filter(t=>nl(e,t))):m=c;for(let r of m){let i=t===`LR`?{x:0,y:n[0]??0}:{x:n[0]??0,y:0};Zc(e,e.nodes[r.index],i),n[0]=(n[0]??0)+4,vl(e,r,l,u)}if(p&&h.length>0)for(let r of h){let i=t===`LR`?{x:4,y:n[4]??0}:{x:n[4]??0,y:4};Zc(e,e.nodes[r.index],i),n[4]=(n[4]??0)+4,vl(e,r,l,u)}yl(e,n);for(let t of o){if(u.has(t))continue;let r=al(e,t),i=cl(e,t),a=ol(r).filter(e=>e!==t&&e.gridCoord!==null),o;if(a.length>0){let t=a[0];for(let e of a)(i===`LR`?e.gridCoord.x<t.gridCoord.x:e.gridCoord.y<t.gridCoord.y)&&(t=e);let n=i===`LR`?`y`:`x`;o=_l(e,t.gridCoord,r,n,1)??{x:t.gridCoord.x,y:t.gridCoord.y}}else o=i===`LR`?{x:0,y:n[0]??0}:{x:n[0]??0,y:0},n[0]=(n[0]??0)+4;Zc(e,e.nodes[t.index],o,i)}yl(e,n);for(let t of e.nodes)Qc(e,t);e.pathBudget=Sc(),Fl(e),e.bundles=kc(e),Nc(e);let g=Pc(),_=uc(e.grid);for(let t of e.edges){if(t.bundle&&t.path.length>0){$c(e,t.path),Ic(_,g,t.path,t.style),Bl(e,t);continue}Ll(e,t),tl(e,t,g,_),$c(e,t.path),Ic(_,g,t.path,t.style),Bl(e,t)}for(let t of e.nodes)t.drawingCoord=Yc(e,oc(t)),t.drawing=_u(t,e);Ss(e.canvas,e.columnWidth,e.rowHeight),Cs(e.roleCanvas,e.columnWidth,e.rowHeight),fl(e),pl(e)}function xl(e,t){return e.edges.filter(e=>e.from.name===t.name)}function Sl(e,t){let n=rl(e,t),r=[],i=n;for(;i!==null;)r.unshift(i),i=i.parent;return r}function Cl(e,t,n){let r=Sl(e,t),i=Sl(e,n),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=r[a],s=i[a];return!o||!s||o===s?0:e.subgraphs.indexOf(s)-e.subgraphs.indexOf(o)}function wl(e,t){return xl(e,t).map(e=>e.to)}function Tl(e){return e===J?Y:e===Y?J:e===X?Z:e===Z?X:e===Js?Zs:e===Ys?Xs:e===Xs?Ys:e===Zs?Js:Qs}function El(e,t){return e.x===t.x?e.y<t.y?Y:J:e.y===t.y?e.x<t.x?Z:X:e.x<t.x?e.y<t.y?Xs:Js:e.y<t.y?Zs:Ys}function Dl(e){return e===`LR`?[Z,Y,Y,Z]:[Y,Z,Z,Y]}function Ol(e,t){if(e.from===e.to)return Dl(t);let n=El(oc(e.from),oc(e.to)),r,i,a,o,s=t===`LR`?Q(n,X)||Q(n,Ys)||Q(n,Zs):Q(n,J)||Q(n,Ys)||Q(n,Js);return Q(n,Xs)?t===`LR`?(r=Y,i=X,a=Z,o=J):(r=Z,i=J,a=Y,o=X):Q(n,Js)?t===`LR`?(r=J,i=X,a=Z,o=Y):(r=Z,i=Y,a=J,o=X):Q(n,Zs)?t===`LR`?(r=Y,i=Y,a=X,o=J):(r=X,i=J,a=Y,o=Z):Q(n,Ys)?t===`LR`?(r=Y,i=Y,a=X,o=Y):(r=Z,i=Z,a=J,o=Z):s?t===`LR`&&Q(n,X)?(r=Y,i=Y,a=X,o=Z):t===`TD`&&Q(n,J)?(r=Z,i=Z,a=J,o=Y):(r=n,i=Tl(n),a=n,o=Tl(n)):(r=n,i=Tl(n),a=n,o=Tl(n)),[r,i,a,o]}var kl=2,Al=200;function jl(e,t){let n=e.gridCoord;return n?t.x>=n.x&&t.x<=n.x+2&&t.y>=n.y&&t.y<=n.y+2:!1}function Ml(e,t,n=[]){for(let r=1;r<t.length-1;r++){let i=t[r];if(dc(e.grid,i)&&!n.some(e=>jl(e,i)))return!1}return!0}function Nl(e){let t=e.from.gridCoord,n=e.to.gridCoord;return!t||!n?!1:t.y===n.y&&t.x!==n.x}function Pl(e){let t=e.from.name,n=e.to.name;return Nl(e)&&n<t?JSON.stringify([n,t]):JSON.stringify([t,n])}function Fl(e){let t=new Map;for(let n of e.edges){if(n.from===n.to)continue;let e=Pl(n),r=t.get(e);r?r.push(n):t.set(e,[n])}for(let e of t.values()){if(e.length<2)continue;let t=new Set;for(let n=0;n<e.length;n++)e[n].parallelLane={index:n,total:e.length,usedOffsets:t}}}function Il(e,t,n,r,i){let a=ic(oc(t.from),n),o=ic(oc(t.to),r),s=Q(n,X)||Q(n,Z),c=[t.from,t.to],l=t.parallelLane.usedOffsets,u=Q(n,Z)?1:Q(n,X)?-1:Q(n,Y)?1:-1,d=Q(r,Z)?1:Q(r,X)?-1:Q(r,Y)?1:-1,f=s?{x:a.x+u,y:a.y}:{x:a.x,y:a.y+u},p=s?{x:o.x+d,y:o.y}:{x:o.x,y:o.y+d},m=[a,o],h=[a,o],g=kl*i;for(let t=0;t<Al;t++){let n=g+t;if(l.has(n))continue;let r=a.y+n,i=a.x+n,u=s?[{x:a.x,y:r},{x:o.x,y:r}]:[{x:i,y:a.y},{x:i,y:o.y}],d=wc([a,...u,o]);if(Ml(e,gc(d),c))return l.add(n),{path:d,labelSegment:u};m=d,h=u;let _=s?f.x!==p.x:f.y!==p.y,v=s?_?[{x:f.x,y:r},{x:p.x,y:r}]:[{x:f.x,y:r},{x:f.x,y:r}]:_?[{x:i,y:f.y},{x:i,y:p.y}]:[{x:i,y:f.y},{x:i,y:f.y}],y=wc(s?[a,f,{x:f.x,y:r},{x:p.x,y:r},p,o]:[a,f,{x:i,y:f.y},{x:i,y:p.y},p,o]);if(Ml(e,gc(y),c))return l.add(n),{path:y,labelSegment:v};m=y,h=v}return{path:m,labelSegment:h}}function Ll(e,t){let n=rl(e,t.from),r=rl(e,t.to),[i,a,o,s]=Ol(t,n&&n===r&&n.direction?n.direction:e.config.graphDirection);if(t.parallelLane&&t.parallelLane.index>0){let n=Q(i,a),r=n?o:i,c=n?s:a;t.startDir=r,t.endDir=c;let l=Il(e,t,r,c,t.parallelLane.index);t.path=l.path,t.text.length>0&&Hl(e,t,l.labelSegment,K(t.text));return}let c=ic(oc(t.from),i),l=ic(oc(t.to),a),u=Oc(e,c,l,ec(i)),d=Oc(e,ic(oc(t.from),o),ic(oc(t.to),s),ec(o));if(u!==null&&d!==null){u.length<=d.length?(t.startDir=i,t.endDir=a,t.path=u):(t.startDir=o,t.endDir=s,t.path=d);return}if(u!==null){t.startDir=i,t.endDir=a,t.path=u;return}if(d!==null){t.startDir=o,t.endDir=s,t.path=d;return}t.startDir=i,t.endDir=a,t.path=[c,l]}function Rl(e,t){for(let n of e.nodes){let e=n.gridCoord;if(e&&t>=e.x&&t<=e.x+2)return!0}return!1}function zl(e,t,n,r){if(!Rl(e,r))return r;for(let i=1;i<=n-t;i++){let a=r+i;if(a<=n&&!Rl(e,a))return a;let o=r-i;if(o>=t&&!Rl(e,o))return o}return r}function Bl(e,t){if(t.text.length===0||t.parallelLane&&t.parallelLane.index>0)return;let n=K(t.text),r=Vl(t.path),i=r.length,a=[];for(let t=1;t<i;t++){let n=r[t-1],i=r[t],o=[n,i],s=Ul(e,o),c=n.x===i.x;a.push({line:o,width:s,index:t,isVertical:c})}let o=t=>Ml(e,gc(t)),s=e=>e.index===1||e.index===a.length,c=a.filter(e=>e.width>=n&&!s(e)&&o(e.line)),l;if(c.length>0)c.sort((e,t)=>t.index-e.index),l=c[0].line;else{let e=a.filter(e=>e.width>=n&&o(e.line));if(e.length>0)e.sort((e,t)=>t.index-e.index),l=e[0].line;else{let e=a.filter(e=>!s(e)&&o(e.line)),n=a.filter(e=>o(e.line)),r=e.length>0?e:n.length>0?n:a;if(r.sort((e,t)=>t.width-e.width),r.length>0)l=r[0].line;else{let e=t.path[0]??{x:0,y:0};l=[e,e]}}}Hl(e,t,l,n)}function Vl(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.x!==n.x&&e.y!==n.y&&t.push({x:n.x,y:e.y}),t.push(n)}return t}function Hl(e,t,n,r){let i=Math.min(n[0].x,n[1].x),a=Math.max(n[0].x,n[1].x),o=zl(e,i,a,i+Math.floor((a-i)/2)),s=e.columnWidth.get(o)??0;e.columnWidth.set(o,Math.max(s,r+2)),t.labelLine=[n[0],n[1]]}function Ul(e,t){let n=0,r=Math.min(t[0].x,t[1].x),i=Math.max(t[0].x,t[1].x);for(let t=r;t<=i;t++)n+=e.columnWidth.get(t)??0;return n}var Wl={solid:{h:{unicode:`─`,ascii:`-`},v:{unicode:`│`,ascii:`|`}},dotted:{h:{unicode:`┄`,ascii:`.`},v:{unicode:`┆`,ascii:`:`}},thick:{h:{unicode:`━`,ascii:`=`},v:{unicode:`┃`,ascii:`‖`}},invisible:{h:{unicode:` `,ascii:` `},v:{unicode:` `,ascii:` `}}};function Gl(e,t,n,r,i,a,o=`solid`){let s=El(t,n),c=[],l=Wl[o],u=a?l.h.ascii:l.h.unicode,d=a?l.v.ascii:l.v.unicode;if(Q(s,J))for(let a=t.y-r;a>=n.y-i;a--)c.push({x:t.x,y:a}),q(e,t.x,a,d);else if(Q(s,Y))for(let a=t.y+r;a<=n.y+i;a++)c.push({x:t.x,y:a}),q(e,t.x,a,d);else if(Q(s,X))for(let a=t.x-r;a>=n.x-i;a--)c.push({x:a,y:t.y}),q(e,a,t.y,u);else if(Q(s,Z))for(let a=t.x+r;a<=n.x+i;a++)c.push({x:a,y:t.y}),q(e,a,t.y,u);else if(Q(s,Ys)){for(let i=t.x-r;i>=n.x;i--)c.push({x:i,y:t.y}),q(e,i,t.y,u);for(let r=t.y-1;r>=n.y-i;r--)c.push({x:n.x,y:r}),q(e,n.x,r,d)}else if(Q(s,Js)){for(let i=t.x+r;i<=n.x;i++)c.push({x:i,y:t.y}),q(e,i,t.y,u);for(let r=t.y-1;r>=n.y-i;r--)c.push({x:n.x,y:r}),q(e,n.x,r,d)}else if(Q(s,Zs)){for(let i=t.x-r;i>=n.x;i--)c.push({x:i,y:t.y}),q(e,i,t.y,u);for(let r=t.y+1;r<=n.y+i;r++)c.push({x:n.x,y:r}),q(e,n.x,r,d)}else if(Q(s,Xs)){if(n.x-t.x<=1)for(let a=t.y+r;a<=n.y+i;a++)c.push({x:t.x,y:a}),q(e,t.x,a,d);else{for(let i=t.x+r;i<=n.x;i++)c.push({x:i,y:t.y}),q(e,i,t.y,u);for(let r=t.y+1;r<=n.y+i;r++)c.push({x:n.x,y:r}),q(e,n.x,r,d)}}return c}function Kl(e,t){if(t.path.length===0){let t=as(e.canvas);return[t,t,t,t,t,t]}let n=nu(e,t),[r,i,a]=Jl(e,t.path,t.style),o=i.length>0,s=t.style===`invisible`,c=o&&!s?Zl(e,t.path,i[0],t.from):as(e.canvas),l;l=t.hasArrowEnd&&o?$l(e,i[i.length-1],a[a.length-1],t.endMarker):as(e.canvas);let u;if(t.hasArrowStart&&o){let n=i[0][0],r=ql(a[0]),o={x:n.x,y:n.y};Q(a[0],Z)?o.x=n.x-1:Q(a[0],X)?o.x=n.x+1:Q(a[0],Y)?o.y=n.y-1:Q(a[0],J)&&(o.y=n.y+1),u=$l(e,[n,o],r,t.startMarker)}else u=as(e.canvas);let d=s?as(e.canvas):eu(e,t.path);return[r,c,l,u,d,n]}function ql(e){return Q(e,J)?Y:Q(e,Y)?J:Q(e,X)?Z:Q(e,Z)?X:Q(e,Ys)?Xs:Q(e,Js)?Zs:Q(e,Zs)?Js:Q(e,Xs)?Ys:Qs}function Jl(e,t,n=`solid`){let r=as(e.canvas),i=t[0],a=[],o=[];for(let s=1;s<t.length;s++){let c=t[s],l=Yc(e,i),u=Yc(e,c);if(rc(l,u)){i=c;continue}let d=El(i,c),f=Gl(r,l,u,1,-1,e.config.useAscii,n);f.length===0&&f.push(l),a.push(f),o.push(d),i=c}return[r,a,o]}var Yl=new Set([`│`,`┃`,`║`,`┆`,`┊`,`|`,`‖`]),Xl=new Set([`─`,`━`,`═`,`╌`,`┄`,`-`,`=`]);function Zl(e,t,n,r){let i=as(e.canvas),a=e.config.useAscii;if(r.shape===`state-start`||r.shape===`state-end`)return i;let o=n[0],s=El(t[0],t[1]),c=a?`+`:null,l=(t,n)=>e.canvas[t]?.[n];if(Q(s,J)){let e=o.x,t=o.y+1,n=l(e,t);q(i,e,t,n!==void 0&&Xl.has(n)?c??`┴`:a?`|`:`│`)}else if(Q(s,Y)){let e=o.x,t=o.y-1,n=l(e,t);q(i,e,t,n!==void 0&&Xl.has(n)?c??`┬`:a?`|`:`│`)}else if(Q(s,X)||Q(s,Z)){let e=r.drawingCoord,t=r.drawing;if(e===null||t===null)throw Error(`drawBoxStart: node "${r.name}" has no drawingCoord/drawing assigned`);let n=t.length,u=Q(s,X)?e.x:e.x+n-1,d=o.y,f=l(u,d);q(i,u,d,f!==void 0&&Yl.has(f)?c??(Q(s,X)?`┤`:`├`):a?`-`:`─`)}return i}function Ql(e,t){if(t===`circle`)return e?`o`:`○`;if(t===`cross`)return e?`x`:`✕`}function $l(e,t,n,r){let i=as(e.canvas);if(t.length===0)return i;let a=t[0],o=t[t.length-1],s=El(a,o);(t.length===1||Q(s,Qs))&&(s=n);let c,l=Ql(e.config.useAscii,r);return c=l===void 0?e.config.useAscii?Q(s,J)?`^`:Q(s,Y)?`v`:Q(s,X)?`<`:Q(s,Z)?`>`:Q(n,J)?`^`:Q(n,Y)?`v`:Q(n,X)?`<`:Q(n,Z)?`>`:`*`:Q(s,J)?`▲`:Q(s,Y)?`▼`:Q(s,X)?`◄`:Q(s,Z)?`►`:Q(s,Js)?`◥`:Q(s,Ys)?`◤`:Q(s,Xs)?`◢`:Q(s,Zs)?`◣`:Q(n,J)?`▲`:Q(n,Y)?`▼`:Q(n,X)?`◄`:Q(n,Z)?`►`:Q(n,Js)?`◥`:Q(n,Ys)?`◤`:Q(n,Xs)?`◢`:Q(n,Zs)?`◣`:`●`:l,q(i,o.x,o.y,c),i}function eu(e,t){let n=as(e.canvas);for(let r=1;r<t.length-1;r++){let i=t[r],a=Yc(e,i),o=El(t[r-1],i),s=El(i,t[r+1]),c;c=e.config.useAscii?`+`:Q(o,Z)&&Q(s,Y)||Q(o,J)&&Q(s,X)?`┐`:Q(o,Z)&&Q(s,J)||Q(o,Y)&&Q(s,X)?`┘`:Q(o,X)&&Q(s,Y)||Q(o,J)&&Q(s,Z)?`┌`:Q(o,X)&&Q(s,J)||Q(o,Y)&&Q(s,Z)?`└`:`+`,q(n,a.x,a.y,c)}return n}function tu(e,t){return e.edges.some(e=>e!==t&&e.from===t.to&&e.to===t.from)}function nu(e,t){let n=as(e.canvas);if(t.text.length===0)return n;let r=Xc(e,t.labelLine),i;if(t.path.length>=2){let e=t.path[0].y,n=t.path[t.path.length-1].y;n<e?i=!0:n>e&&(i=!1)}let a=tu(e,t);return ru(n,r,t.text,i,a),n}function ru(e,t,n,r,i=!1){if(t.length<2)return;let a=Math.min(t[0].x,t[1].x),o=Math.max(t[0].x,t[1].x),s=Math.min(t[0].y,t[1].y),c=Math.max(t[0].y,t[1].y),l=a+Math.floor((o-a)/2),u=s+Math.floor((c-s)/2);if(r!==void 0&&a===o){let e=c-s,t=Math.max(1,Math.floor(e/4));(i?r:!r)?u-=t:u+=t}let d=$(n),f=u-Math.floor((d.length-1)/2);for(let t=0;t<d.length;t++){let n=d[t];xs(e,{x:l-Math.floor(K(n)/2),y:f+t},n)}}function iu(e,t,n){let r=oc(t),i=0;for(let t=0;t<2;t++)i+=e.columnWidth.get(r.x+t)??0;let a=0;for(let t=0;t<2;t++)a+=e.rowHeight.get(r.y+t)??0;let o={width:i+1,height:a+1,labelArea:{x:0,y:0,width:0,height:0},gridColumns:[0,0,0],gridRows:[0,0,0]},s=t.drawingCoord;if(s===null)throw Error(`Node "${t.name}" has no drawingCoord; grid layout must run before bundled-edge drawing`);return Jc(t.shape,n,o,s)}function au(e,t,n){let r=as(e.canvas),i=t.pathToJunction;if(!i||i.length===0)return[r,r,r,r,r,r];let a=as(e.canvas),o=e.config.useAscii,s=i.map((r,a)=>n.type===`fan-in`&&a===0?iu(e,t.from,t.startDir):n.type===`fan-out`&&a===i.length-1?iu(e,t.to,t.endDir):Yc(e,r));for(let e=1;e<s.length;e++){let n=s[e-1],r=s[e];rc(n,r)||Gl(a,n,r,1,-1,o,t.style)}let c=as(e.canvas);for(let t=1;t<i.length-1;t++){let n=i[t],r=Yc(e,n),a=El(i[t-1],n),s=El(n,i[t+1]),l;l=o?`+`:Q(a,Z)&&Q(s,Y)||Q(a,J)&&Q(s,X)?`┐`:Q(a,Z)&&Q(s,J)||Q(a,Y)&&Q(s,X)?`┘`:Q(a,X)&&Q(s,Y)||Q(a,J)&&Q(s,Z)?`┌`:Q(a,X)&&Q(s,J)||Q(a,Y)&&Q(s,Z)?`└`:`+`,q(c,r.x,r.y,l)}let l=as(e.canvas);if(n.type===`fan-in`&&i.length>=2){let e=s[0],t=El(i[0],i[1]),n=o?`+`:null;Q(t,J)?q(l,e.x,e.y,n??`┴`):Q(t,Y)?q(l,e.x,e.y,n??`┬`):Q(t,X)?q(l,e.x,e.y,n??`┤`):Q(t,Z)&&q(l,e.x,e.y,n??`├`)}return[a,l,r,r,c,as(e.canvas)]}function ou(e,t){let n=as(e.canvas),r=as(e.canvas);if(t.sharedPath.length<2)return[n,r];let i=e.config.useAscii,a=t.edges[0]?.style??`solid`,o=e.config.graphDirection,s=t.sharedPath.map((n,r)=>{if(t.type===`fan-in`&&r===t.sharedPath.length-1){let n=o===`TD`?J:X;return iu(e,t.sharedNode,n)}if(t.type===`fan-out`&&r===0){let n=o===`TD`?Y:Z;return iu(e,t.sharedNode,n)}return Yc(e,n)});for(let e=1;e<s.length;e++){let t=s[e-1],r=s[e];rc(t,r)||Gl(n,t,r,1,-1,i,a)}for(let n=1;n<t.sharedPath.length-1;n++){let a=t.sharedPath[n],o=Yc(e,a),s=El(t.sharedPath[n-1],a),c=El(a,t.sharedPath[n+1]),l;l=i?`+`:Q(s,Z)&&Q(c,Y)||Q(s,J)&&Q(c,X)?`┐`:Q(s,Z)&&Q(c,J)||Q(s,Y)&&Q(c,X)?`┘`:Q(s,X)&&Q(c,Y)||Q(s,J)&&Q(c,Z)?`┌`:Q(s,X)&&Q(c,J)||Q(s,Y)&&Q(c,Z)?`└`:`+`,q(r,o.x,o.y,l)}return[n,r]}function su(e,t){let n=as(e.canvas);if(t.sharedPath.length<2)return n;let r=t.sharedPath.length-1,i=t.sharedPath[r-1],a=t.sharedPath[r],o=El(i,a),s=e.config.graphDirection,c=s===`TD`?J:X,l=iu(e,t.sharedNode,c);s===`TD`?--l.y:--l.x;let u=t.edges[0]?.endMarker,d=t.edges.every(e=>e.endMarker===u)?u:void 0,f=Ql(e.config.useAscii,d),p;return p=f===void 0?e.config.useAscii?Q(o,J)?`^`:Q(o,Y)?`v`:Q(o,X)?`<`:Q(o,Z)?`>`:`v`:Q(o,J)?`▲`:Q(o,Y)?`▼`:Q(o,X)?`◄`:Q(o,Z)?`►`:`▼`:f,q(n,l.x,l.y,p),n}function cu(e,t){let n=as(e.canvas);if(!t.pathToJunction||t.pathToJunction.length<2)return n;let r=t.pathToJunction.length-1,i=t.pathToJunction[r-1],a=t.pathToJunction[r],o=El(i,a),s=e.config.graphDirection,c=s===`TD`?J:X,l=iu(e,t.to,c);s===`TD`?--l.y:--l.x;let u=Ql(e.config.useAscii,t.endMarker),d;return d=u===void 0?e.config.useAscii?Q(o,J)?`^`:Q(o,Y)?`v`:Q(o,X)?`<`:Q(o,Z)?`>`:`v`:Q(o,J)?`▲`:Q(o,Y)?`▼`:Q(o,X)?`◄`:Q(o,Z)?`►`:`▼`:u,q(n,l.x,l.y,d),n}function lu(e){return Q(e,J)?Y:Q(e,Y)?J:Q(e,X)?Z:Q(e,Z)?X:e}function uu(e,t){let n=as(e.canvas);if(t.sharedPath.length<2)return n;let r=t.sharedPath[0],i=t.sharedPath[1],a=lu(El(r,i)),o=e.config.graphDirection,s=o===`TD`?Y:Z,c=iu(e,t.sharedNode,s);o===`TD`?c.y+=1:c.x+=1;let l;return l=e.config.useAscii?Q(a,J)?`^`:Q(a,Y)?`v`:Q(a,X)?`<`:Q(a,Z)?`>`:`^`:Q(a,J)?`▲`:Q(a,Y)?`▼`:Q(a,X)?`◄`:Q(a,Z)?`►`:`▲`,q(n,c.x,c.y,l),n}function du(e,t){let n=as(e.canvas);if(!t.pathToJunction||t.pathToJunction.length<2)return n;let r=t.pathToJunction[0],i=t.pathToJunction[1],a=lu(El(r,i)),o=iu(e,t.from,t.startDir);Q(t.startDir,J)?--o.y:Q(t.startDir,Y)?o.y+=1:Q(t.startDir,X)?--o.x:Q(t.startDir,Z)&&(o.x+=1);let s;return s=e.config.useAscii?Q(a,J)?`^`:Q(a,Y)?`v`:Q(a,X)?`<`:Q(a,Z)?`>`:`v`:Q(a,J)?`▲`:Q(a,Y)?`▼`:Q(a,X)?`◄`:Q(a,Z)?`►`:`▼`,q(n,o.x,o.y,s),n}function fu(e,t){let n=as(e.canvas);if(!t.junctionPoint)return n;let r=Yc(e,t.junctionPoint),i=e.config.useAscii,a=!1,o=!1,s=!1,c=!1;if(t.sharedPath.length>=2){let e=t.type===`fan-in`?0:t.sharedPath.length-1,n=t.type===`fan-in`?1:t.sharedPath.length-2,r=El(t.sharedPath[e],t.sharedPath[n]);Q(r,Y)?o=!0:Q(r,J)?a=!0:Q(r,Z)?c=!0:Q(r,X)&&(s=!0)}for(let e of t.edges)if(e.pathToJunction&&e.pathToJunction.length>=2){let n=t.type===`fan-in`?e.pathToJunction.length-1:0,r=t.type===`fan-in`?e.pathToJunction.length-2:1,i=El(e.pathToJunction[r],e.pathToJunction[n]);Q(i,Y)?a=!0:Q(i,J)?o=!0:Q(i,Z)?s=!0:Q(i,X)&&(c=!0)}let l;return l=i?`+`:a&&o&&s&&c?`┼`:o&&s&&c&&!a?`┬`:a&&s&&c&&!o?`┴`:a&&o&&c&&!s?`├`:a&&o&&s&&!c?`┤`:s&&c?`─`:a&&o?`│`:o&&c?`┌`:o&&s?`┐`:a&&c?`└`:a&&s?`┘`:`┼`,q(n,r.x,r.y,l),n}function pu(e,t){let n=e.maxX-e.minX,r=e.maxY-e.minY;if(n<=0||r<=0)return is(0,0);let i={x:0,y:0},a={x:n,y:r},o=is(n,r);if(t.config.useAscii){for(let e=i.x+1;e<a.x;e++)q(o,e,i.y,`-`);for(let e=i.x+1;e<a.x;e++)q(o,e,a.y,`-`);for(let e=i.y+1;e<a.y;e++)q(o,i.x,e,`|`);for(let e=i.y+1;e<a.y;e++)q(o,a.x,e,`|`);q(o,i.x,i.y,`+`),q(o,a.x,i.y,`+`),q(o,i.x,a.y,`+`),q(o,a.x,a.y,`+`)}else{for(let e=i.x+1;e<a.x;e++)q(o,e,i.y,`─`);for(let e=i.x+1;e<a.x;e++)q(o,e,a.y,`─`);for(let e=i.y+1;e<a.y;e++)q(o,i.x,e,`│`);for(let e=i.y+1;e<a.y;e++)q(o,a.x,e,`│`);q(o,i.x,i.y,`┌`),q(o,a.x,i.y,`┐`),q(o,i.x,a.y,`└`),q(o,a.x,a.y,`┘`)}return o}function mu(e,t){let n=e.maxX-e.minX,r=e.maxY-e.minY;if(n<=0||r<=0)return[is(0,0),{x:0,y:0},[]];let i=is(n,r),a=[],o=$(e.name);for(let e=0;e<o.length;e++){let t=o[e],s=1+e,c=1+Math.ceil((n-1-K(t))/2);c<1&&(c=1);let l=rs(t);for(let e=0;e<l.length;e++)c+e>=n||s>=r||(q(i,c+e,s,l[e]),a.push({x:c+e,y:s}))}return[i,{x:e.minX,y:e.minY},a]}function hu(e,t){return gu(e,t)}function gu(e,t){let n=oc(e),r=t.config.useAscii,i=0;for(let e=0;e<2;e++)i+=t.columnWidth.get(n.x+e)??0;let a=0;for(let e=0;e<2;e++)a+=t.rowHeight.get(n.y+e)??0;let o={x:0,y:0},s={x:i,y:a},c=is(Math.max(o.x,s.x),Math.max(o.y,s.y)),l=Bc(e.shape,r),u=e.shape===`state-end`,d=r?u?`=`:`-`:u?`═`:`─`,f=r?u?`‖`:`|`:u?`║`:`│`,p=u?r?{tl:`#`,tr:`#`,bl:`#`,br:`#`}:{tl:`╔`,tr:`╗`,bl:`╚`,br:`╝`}:l;for(let e=o.x+1;e<s.x;e++)q(c,e,o.y,d);for(let e=o.x+1;e<s.x;e++)q(c,e,s.y,d);for(let e=o.y+1;e<s.y;e++)q(c,o.x,e,f);for(let e=o.y+1;e<s.y;e++)q(c,s.x,e,f);q(c,o.x,o.y,p.tl),q(c,s.x,o.y,p.tr),q(c,o.x,s.y,p.bl),q(c,s.x,s.y,p.br);let m=e.displayLabel,h=$(m),g=o.y+Math.floor(a/2)-Math.floor((h.length-1)/2);for(let e=0;e<h.length;e++){let t=h[e],n=K(t),r=o.x+Math.floor(i/2)-Math.ceil(n/2)+1,a=rs(t);for(let t=0;t<a.length;t++)q(c,r+t,g+e,a[t])}return c}function _u(e,t){return hu(e,t)}function vu(e){return/^[┌┐└┘├┤┬┴┼│─╭╮╰╯+\-|]$/.test(e)?`border`:`text`}function yu(e,t=1){let n=Math.max(0,t),r=0;for(let t of e)for(let e of t)r=Math.max(r,K(e));let i=0;for(let t of e)i+=Math.max(t.length,1);return{width:r+2*n+2,height:i+(e.length-1)+2}}function bu(e,t,n=1){let r=Math.max(0,n),{width:i,height:a}=yu(e,r),o=t?`-`:`─`,s=t?`|`:`│`,c=t?`+`:`┌`,l=t?`+`:`┐`,u=t?`+`:`└`,d=t?`+`:`┘`,f=t?`+`:`├`,p=t?`+`:`┤`,m=is(i-1,a-1);q(m,0,0,c);for(let e=1;e<i-1;e++)q(m,e,0,o);q(m,i-1,0,l),q(m,0,a-1,u);for(let e=1;e<i-1;e++)q(m,e,a-1,o);q(m,i-1,a-1,d);for(let e=1;e<a-1;e++)q(m,0,e,s),q(m,i-1,e,s);let h=1;for(let t=0;t<e.length;t++){let n=e[t],a=n.length>0?n:[``];for(let e of a){let t=1+r,n=rs(e);for(let e=0;e<n.length;e++)q(m,t+e,h,n[e]);h++}if(t<e.length-1){q(m,0,h,f);for(let e=1;e<i-1;e++)q(m,e,h,o);q(m,i-1,h,p),h++}}return m}function xu(e){function t(e){return e.parent===null?0:1+t(e.parent)}let n=[...e];return n.sort((e,n)=>t(e)-t(n)),n}function Su(e,t,n,r){for(let i=0;i<t.length;i++)for(let a=0;a<(t[0]?.length??0);a++){let o=t[i]?.[a];if(o&&o!==` `){let t=i+n.x,o=a+n.y;t>=0&&o>=0&&cs(e,t,o,r)}}}function Cu(e,t,n,r){for(let i of t)Su(e,i,n,r)}function wu(e,t,n){let r=e=>/^[┌┐└┘├┤┬┴┼│─╭╮╰╯+\-|.':]$/.test(e);for(let i=0;i<t.length;i++)for(let a=0;a<(t[0]?.length??0);a++){let o=t[i]?.[a];if(o&&o!==` `){let t=i+n.x,s=a+n.y;t>=0&&s>=0&&cs(e,t,s,r(o)?`border`:`text`)}}}function Tu(e){let t=e.config.useAscii,n={x:0,y:0},r=xu(e.subgraphs);for(let n of r){let r=pu(n,e),i={x:n.minX,y:n.minY};e.canvas=gs(e.canvas,i,t,r),Su(e.roleCanvas,r,i,`border`)}for(let n of e.nodes)!n.drawn&&n.drawingCoord&&n.drawing&&(e.canvas=gs(e.canvas,n.drawingCoord,t,n.drawing),wu(e.roleCanvas,n.drawing,n.drawingCoord),n.drawn=!0);let i=[],a=[],o=[],s=[],c=[],l=[],u=[],d=new Set;for(let t of e.edges)if(t.bundle&&t.pathToJunction){let n=t.bundle,[r,f,,,p,m]=au(e,t,n);if(i.push(r),a.push(p),c.push(f),l.push(m),n.type===`fan-in`&&t.hasArrowStart){let n=du(e,t);s.push(n)}if(!d.has(n)){d.add(n);let[t,r]=ou(e,n);if(i.push(t),a.push(r),n.type===`fan-in`){let t=su(e,n);o.push(t)}if(n.type===`fan-out`&&n.edges.every(e=>e.hasArrowStart)){let t=uu(e,n);s.push(t)}let c=fu(e,n);u.push(c)}if(n.type===`fan-out`&&t.hasArrowEnd){let n=cu(e,t);o.push(n)}}else{let[n,r,u,d,f,p]=Kl(e,t);i.push(n),a.push(f),o.push(u),s.push(d),c.push(r),l.push(p)}e.canvas=gs(e.canvas,n,t,...i),Cu(e.roleCanvas,i,n,`line`),e.canvas=gs(e.canvas,n,t,...a),Cu(e.roleCanvas,a,n,`corner`),e.canvas=gs(e.canvas,n,t,...u),Cu(e.roleCanvas,u,n,`junction`),e.canvas=gs(e.canvas,n,t,...o),Cu(e.roleCanvas,o,n,`arrow`),e.canvas=gs(e.canvas,n,t,...c),Cu(e.roleCanvas,c,n,`junction`),e.canvas=gs(e.canvas,n,t,...s),Cu(e.roleCanvas,s,n,`arrow`),e.canvas=gs(e.canvas,n,t,...l),Cu(e.roleCanvas,l,n,`text`);for(let n of e.subgraphs){if(n.nodes.length===0)continue;let[r,i,a]=mu(n,e);e.canvas=gs(e.canvas,i,t,r),Su(e.roleCanvas,r,i,`text`);for(let{x:t,y:n}of a){let a=r[t]?.[n];a===` `&&(q(e.canvas,t+i.x,n+i.y,a),cs(e.roleCanvas,t+i.x,n+i.y,`text`))}}return e.canvas}function Eu(e,t,n,r){if(r(e))return e;let i=Math.max(e-t,n-e);for(let a=1;a<=i;a++){let i=e+a;if(i<=n&&r(i))return i;let o=e-a;if(o>=t&&r(o))return o}}function Du(e){return`${e.keys.length>0?e.keys.join(`,`)+` `:` `}${e.type} ${e.name}`}function Ou(e){let t=$(e.label),n=e.attributes.map(Du);return n.length===0?[t]:[t,n]}function ku(e,t,n=!1,r=!1){if(t)switch(e){case`one`:return r?`+`:`|`;case`zero-one`:return n?`o|`:`|o`;case`many`:return n?`<`:`>`;case`zero-many`:return n?`o<`:`>o`}else switch(e){case`one`:return r?`┼`:`│`;case`zero-one`:return n?`○│`:`│○`;case`many`:return n?`╟`:`╢`;case`zero-many`:return n?`○╟`:`╢○`}}function Au(e){let t=new Set,n=[],r=new Map;for(let t of e.entities)r.set(t.id,new Set);for(let t of e.relationships)r.get(t.entity1)?.add(t.entity2),r.get(t.entity2)?.add(t.entity1);function i(e,n){let i=[e];for(;i.length>0;){let e=i.pop();if(!t.has(e)){t.add(e),n.add(e);for(let n of r.get(e)??[])t.has(n)||i.push(n)}}}for(let r of e.entities)if(!t.has(r.id)){let e=new Set;i(r.id,e),e.size>0&&n.push(e)}return n}function ju(e,t,n){let r=e.get(t);if(r===void 0)throw Error(`ER diagram layout: missing ${n} for entity "${t}"`);return r}function Mu(e,t,n,r){let i=ut(D(e));if(i.entities.length===0)return``;let a=t.useAscii,o=tc(t.paddingX,5,6,6),s=tc(t.paddingY,5,4,2),c=tc(t.paddingY,5,2,1),l=Math.max(...[`one`,`zero-one`,`many`,`zero-many`].flatMap(e=>[ku(e,a,!1).length,ku(e,a,!0).length])),u=new Map,d=new Map,f=new Map,p=new Map;for(let e of i.entities){p.set(e.id,e);let n=Ou(e);u.set(e.id,n);let{width:r,height:i}=yu(n,t.boxBorderPadding);d.set(e.id,r),f.set(e.id,i)}let m=new Map;for(let e of i.relationships){if(!e.label)continue;let t=[e.entity1,e.entity2].sort().join(`|`),n=Lc(e.label);m.set(t,Math.max(m.get(t)??0,n))}let h=Au(i),g=new Map,_=0;for(let e of h){let t=i.entities.filter(t=>e.has(t.id)),n=Math.max(2,Math.ceil(Math.sqrt(t.length))),r=0,a=0,l=0;for(let e=0;e<t.length;e++){let i=t[e],c=ju(d,i.id,`box width`),p=ju(f,i.id,`box height`);l>=n&&(_+=a+s,r=0,a=0,l=0),g.set(i.id,{entity:i,sections:ju(u,i.id,`sections`),x:r,y:_,width:c,height:p});let h=o,v=l+1>=n,y=t[e+1];if(!v&&y){let e=[i.id,y.id].sort().join(`|`),t=m.get(e)??0;t>0&&(h=Math.max(h,t+2))}r+=c+h,a=Math.max(a,p),l++}_+=a+c}let v=0,y=0;for(let e of g.values())v=Math.max(v,e.x+e.width),y=Math.max(y,e.y+e.height);v+=4,y+=2;let b=is(v-1,y-1),x=os(v-1,y-1);function S(e,t,n,r){q(b,e,t,n,{role:r,roleCanvas:x})}function C(e,t){let n=x[e]?.[t];return n===`text`||n===`border`}function w(e,t,n,r,i){for(let a=0;a<e.length;a++){let e=t+a;if(!(e<r||e>i)&&C(e,n))return!1}return!0}function T(e,t,n,r,i){for(let a=0;a<e.length;a++){let e=t+a;if(!(e<r||e>i)&&(C(e,n)||x[e]?.[n]===`arrow`||E.has(`${e},${n}`)))return!1}return!0}for(let e of g.values()){let n=bu(e.sections,a,t.boxBorderPadding);for(let t=0;t<n.length;t++)for(let r=0;r<n[0].length;r++){let i=n[t][r];if(i!==` `){let n=e.x+t,a=e.y+r;n<v&&a<y&&S(n,a,i,vu(i))}}}let E=new Set;for(let e of g.values())for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++)E.add(`${e.x+n},${e.y+t}`);function O(e,t,n,r){E.has(`${e},${t}`)||(r===`text`||x[e]?.[t]!==`text`)&&S(e,t,n,r)}function k(e,t,n,r){x[e-1]?.[t]!==`text`&&x[e+1]?.[t]!==`text`&&O(e,t,n,r)}function A(e,t,n,r){for(let i=n;i<=r;i++)for(let n=e;n<=t;n++){let e=b[n]?.[i];if(e!==void 0&&e!==` `)return!1}return!0}let j=[];function ee(e,t,n){for(let r of j)if(Math.abs(r.x-e)===1&&t<=r.yEnd&&n>=r.yStart)return!0;return!1}function M(e,t,n){for(let r of j)if(!(Math.abs(r.x-e)>1)&&t<=r.yEnd&&n>=r.yStart)return!0;return!1}function N(e,t,n){j.push({x:e,yStart:t,yEnd:n})}let te=a?`-`:`─`,ne=a?`|`:`│`,re=a?`.`:`╌`,ie=a?`:`:`┊`;function ae(e,t){return a?`+`:e===`down`?t===`right`?`┌`:`┐`:t===`right`?`└`:`┘`}function oe(e,t,n,r){O(e,t,ae(n,r),`line`)}let P=new Map,se=new Map;for(let e of i.relationships){let t=g.get(e.entity1),n=g.get(e.entity2);if(!t||!n)continue;let r=t.y+Math.floor(t.height/2),i=n.y+Math.floor(n.height/2);if(Math.abs(r-i)<Math.max(t.height,n.height))continue;let[a,o]=r<i?[t,n]:[n,t],s=a.x+Math.floor(a.width/2),c=o.x+Math.floor(o.width/2),l=se.get(a.entity.id);l||(l=[],se.set(a.entity.id,l)),l.push({rel:e,otherCenterX:c});let u=P.get(o.entity.id);u||(u=[],P.set(o.entity.id,u)),u.push({rel:e,otherCenterX:s})}function ce(e,t,n){let r=n.get(e.entity.id),i=e.x+Math.floor(e.width/2);if(!r||r.length<=1)return i;let a=[...r].sort((e,t)=>e.otherCenterX-t.otherCenterX),o=a.findIndex(e=>e.rel===t);if(o===-1)return i;let s=Math.min(1,Math.floor((e.width-1)/2)),c=Math.max(0,e.width-1-s*2),l=a.length>1?c/(a.length-1):0;return e.x+s+Math.round(o*l)}for(let e of i.relationships){let t=g.get(e.entity1),n=g.get(e.entity2);if(!t||!n)continue;let r=e.identifying?te:re,i=e.identifying?ne:ie,o=t.x+Math.floor(t.width/2),c=t.y+Math.floor(t.height/2),u=n.x+Math.floor(n.width/2),d=n.y+Math.floor(n.height/2);if(Math.abs(c-d)<Math.max(t.height,n.height)){let[c,d]=o<u?[t,n]:[n,t],[f,p]=o<u?[e.cardinality1,e.cardinality2]:[e.cardinality2,e.cardinality1],m=c.x+c.width,h=d.x-1,_=c.y+Math.floor(c.height/2),v;for(let e of g.values())e!==c&&e!==d&&e.y===c.y&&e.x<h+1&&e.x+e.width>m&&(v=Math.max(v??0,e.y+e.height));let y=h-m+1,S=+(y>=l+1),C=ku(f,a,!1),T=ku(p,a,!0),E=+(y>=3&&C[0]===ne),D=+(y>=3&&T[T.length-1]===ne),j=m+E,ee=h-D,M;if(v===void 0){for(let e=m;e<=h;e++)k(e,_,r,`line`);if(M=_+1,e.label){let t=m+S,n=h-S,r=$(e.label).length,i=_+1+Math.max(s-1,1);for(;M<i&&!A(t,n,M,M+r-1);)M++}}else{let t=Math.max(c.y+c.height,d.y+d.height,v),n=e.label?$(e.label).length:0,a=t+1,o=t+Math.max(s*3,4);for(;a<o&&!A(m,h,a,a+n);)a++;us(b,h+1,a+n+1),ss(x,h+1,a+n+1);for(let e=_;e<=a;e++)O(m,e,i,`line`),O(h,e,i,`line`);for(let e=m;e<=h;e++)k(e,a,r,`line`);m!==h&&(oe(m,a,`up`,`right`),oe(h,a,`up`,`left`)),M=a+1}for(let e=0;e<C.length;e++)O(j+e,_,C[e],`arrow`);for(let e=0;e<T.length;e++)O(ee-T.length+1+e,_,T[e],`arrow`);if(e.label){let t=$(e.label),n=Math.floor((m+h)/2),r=m+S,i=h-S;for(let e=0;e<t.length;e++){let a=t[e],o=rs(a),s=Math.max(r,n-Math.floor(o.length/2)),c=M+e;if(us(b,Math.max(s+o.length,1),Math.max(c+1,1)),ss(x,Math.max(s+o.length,1),Math.max(c+1,1)),w(o,s,c,r,i))for(let e=0;e<o.length;e++){let t=s+e;t>=r&&t<=i&&O(t,c,o[e],`text`)}}}}else{let[o,s]=c<d?[t,n]:[n,t],[l,u]=c<d?[e.cardinality1,e.cardinality2]:[e.cardinality2,e.cardinality1],f=o.y+o.height,p=s.y-1,m=ce(o,e,se),h=ce(s,e,P);function le(e,t,n){for(let r=t;r<=n;r++)if(E.has(`${e},${r}`))return!1;return!0}let _=f,v=p,y=Math.max(...[...g.values()].filter(e=>e.y===o.y).map(e=>e.y+e.height)),C=s.y,w=Math.max(f,y+1),D=Math.min(p,C-1);function ue(e,t,n){let r=Math.floor(w<=D?(w+D)/2:(f+p)/2);if(w>D)return r;for(let r=w;r<=D;r++)if(A(e,t,r,r+n))return r;return r}let j=m!==h,te=Math.min(m,h),ne=Math.max(m,h),re=j?ue(te,ne,0):p,ie=j?re-1:p,ae=!le(m,w,D)||!le(h,w,D)||ee(m,f,j?re:p)||j&&ee(h,re,p),F=m;if(ae){let e=b.length,t;for(let n=0;n<=e;n++){let e=m+n;if(le(e,f,p)&&!M(e,f,p)){t=e;break}let r=m-n;if(n>0&&le(r,f,p)&&!M(r,f,p)){t=r;break}}F=t??m;for(let e=f;e<=_;e++)O(m,e,i,`line`);for(let e=Math.min(m,F);e<=Math.max(m,F);e++)k(e,_,r,`line`);for(let e=_;e<=v;e++)O(F,e,i,`line`);for(let e=Math.min(F,h);e<=Math.max(F,h);e++)k(e,v,r,`line`);for(let e=v;e<=p;e++)O(h,e,i,`line`);if(m!==F){let e=F>m?`right`:`left`,t=e===`right`?`left`:`right`;oe(m,_,`up`,e),oe(F,_,`down`,t)}if(F!==h){let e=h>F?`right`:`left`,t=e===`right`?`left`:`right`;oe(F,v,`up`,e),oe(h,v,`down`,t)}N(F,_,v)}else{for(let e=f;e<=ie;e++)O(m,e,i,`line`);if(N(m,f,j?re:ie),j){for(let e=te;e<=ne;e++)k(e,re,r,`line`);for(let e=re+1;e<=p;e++)O(h,e,i,`line`);N(h,re,p);let e=h>m?`right`:`left`,t=e===`right`?`left`:`right`;oe(m,re,`up`,e),oe(h,re,`down`,t),F=h}}let de=ku(l,a,!1,!0);for(let e=0;e<de.length;e++)O(m-Math.floor(de.length/2)+e,_,de[e],`arrow`);let fe=m===h?m:h,pe=ku(u,a,!0,!0);for(let e=0;e<pe.length;e++)O(fe-Math.floor(pe.length/2)+e,v,pe[e],`arrow`);if(e.label){let t=$(e.label),n=Math.max(de.length-1-Math.floor(de.length/2),pe.length-1-Math.floor(pe.length/2)),r=F+n+2,i=t.map(e=>rs(e)),a=r+Math.max(...i.map(e=>e.length))-1,o=t.length,s=Math.floor((f+p)/2)-Math.floor((o-1)/2);a>=0&&(us(b,a+1,p+1),ss(x,a+1,p+1));let c=null;for(let e=0;e<=p-f&&c===null;e++){let t=e===0?[s]:[s+e,s-e];for(let e of t)if(!(e<f||e+o-1>p)&&i.every((t,n)=>T(t,r,e+n,0,a))){c=e;break}}if(c!==null)for(let e=0;e<o;e++){let t=i[e],n=c+e;for(let e=0;e<t.length;e++){let i=r+e;i>=0&&O(i,n,t[e],`text`)}x[r-1]?.[n]===`line`&&S(r-1,n,` `,`line`);let a=r+t.length;x[a]?.[n]===`line`&&S(a,n,` `,`line`)}}}}return _s(b,{roleCanvas:x,colorMode:n,theme:r})}var Nu=4,Pu=[`O`,`/|\\`,`/ \\`],Fu=3,Iu=4;function Lu(e){return e.seqNumber===void 0?Nu:Nu+String(e.seqNumber).length}function Ru(e,t,n,r){let i=Tt(D(e));if(i.actors.length===0)return``;let a=t.useAscii,o=a?`-`:`─`,s=a?`|`:`│`,c=a?`+`:`┌`,l=a?`+`:`┐`,u=a?`+`:`└`,d=a?`+`:`┘`,f=a?`+`:`┬`,p=a?`+`:`┴`,m=a?`+`:`├`,h=a?`+`:`┤`,g=new Map;i.actors.forEach((e,t)=>g.set(e.id,t));function _(e){let t=g.get(e);if(t===void 0)throw Error(`Sequence diagram: unknown actor "${e}"`);return t}function v(e){let t=Lc(e.label?`${e.type} [${e.label}]`:e.type);for(let n of e.dividers)n.label&&(t=Math.max(t,Lc(`[${n.label}]`)));return t}let y=Math.max(0,t.boxBorderPadding),b=e=>Math.max(Lc(e.label),e.type===`actor`?Fu:0),x=e=>Rc(e.label)+(e.type===`actor`?Pu.length:0),S=i.actors.map(e=>b(e)+2*y+2),C=S.map(e=>Math.ceil(e/2)),w=i.actors.map(e=>x(e)+2),T=Math.max(...w,3),E=(e,t)=>t-Math.floor(S[e]/2),O=Math.floor((T-1)/2),k=T-1-O,A=new Map,j=new Map;i.actors.forEach((e,t)=>{e.createdAt!==void 0&&A.set(e.createdAt,t),e.destroyedAt!==void 0&&j.set(e.destroyedAt,t)});let ee=new Map,M=new Map,N=i.boxes.filter(e=>e.actorIds.length>0).map(e=>{let t=e.actorIds.map(_);return{label:e.label,lo:Math.min(...t),hi:Math.max(...t)}}),te=N.length>0,ne=i.actors.map((e,t)=>N.findIndex(e=>e.lo<=t&&t<=e.hi)),re=+!!te,ie=e=>e===``?0:Lc(e)+6,ae=Array(Math.max(i.actors.length-1,0)).fill(0);for(let e of i.messages){let t=_(e.from),n=_(e.to);if(t===n)continue;let r=Math.min(t,n),i=Math.max(t,n),a=Lc(e.label)+4,o=i-r,s=Math.ceil(a/o);for(let e=r;e<i;e++)ae[e]=Math.max(ae[e],s)}function oe(e){let t=$(e.text);return Math.max(...t.map(e=>K(e)))+2+2*y}let P=Array(i.actors.length).fill(0),se=Array(i.actors.length).fill(0),ce=Array(i.actors.length).fill(0),le=Array(i.actors.length).fill(0);for(let e of i.notes)if(e.position===`left`||e.position===`right`){let t=_(e.actorIds[0]),n=oe(e);e.position===`left`?P[t]=Math.max(P[t],n):se[t]=Math.max(se[t],n)}else if(e.position===`over`&&e.actorIds.length===1){let t=_(e.actorIds[0]),n=oe(e),r=Math.floor(n/2),i=n-r;ce[t]=Math.max(ce[t],r),le[t]=Math.max(le[t],i)}let ue=tc(t.paddingX,5,10,4),F=[Math.max(C[0]+(ne[0]===-1?0:2),P[0]+1,ce[0])];for(let e=1;e<i.actors.length;e++){let t=ne[e-1],n=ne[e],r=t===n?0:(t===-1?0:1)+(n===-1?0:1),i=r===0?0:r*2-1,a=Math.max(se[e-1],P[e],le[e-1],ce[e])+2,o=Math.max(C[e-1]+C[e]+2+i,ae[e-1]+2,a,ue);F[e]=F[e-1]+o}let de=e=>E(e.lo,F[e.lo])-1-1,fe=e=>Math.max(E(e.hi,F[e.hi])+S[e.hi]-1+1+1,de(e)+ie(e.label)-1);for(let e of N){if(e.hi+1>=i.actors.length)continue;let t=E(e.hi+1,F[e.hi+1]),n=ne[e.hi+1]===-1?0:2,r=fe(e)+1+1+n-t;if(r>0){let t=F.slice(e.hi+1).map(e=>e+r);F.splice(e.hi+1,t.length,...t)}}for(let e of i.blocks){let t=-1,n=-1,r=1/0,a=-1;for(let o=e.startIndex;o<=e.endIndex&&!(o>=i.messages.length);o++){let e=i.messages[o],s=_(e.from),c=_(e.to);if(t=t===-1?Math.min(s,c):Math.min(t,s,c),n=Math.max(n,s,c),r=Math.min(r,F[Math.min(s,c)]),a=Math.max(a,F[Math.max(s,c)]),s===c){let t=F[s]+Nu+2+Lc(e.label);a=Math.max(a,t)}}if(n===-1||n+1>=i.actors.length)continue;let o=Math.max(0,r-Iu),s=a+Iu,c=o+1+v(e),l=Math.max(s,c),u=F[n+1],d=l+2-u;if(d>0){let e=F.slice(n+1).map(e=>e+d);F.splice(n+1,e.length,...e)}}let pe=[],me=[],he=new Map,ge=new Map,_e=new Map,ve=[],ye=re,be=ye+T,I=be+re,L=tc(t.paddingY,5,1,0),xe=Math.max(L,1);for(let e of i.notes){if(e.afterIndex!==-1)continue;I+=L;let t=$(e.text),n=oe(e),r=t.length+2,i=g.get(e.actorIds[0])??0,a;if(e.position===`left`)a=F[i]-n-1;else if(e.position===`right`)a=F[i]+2;else if(e.actorIds.length>=2){let t=g.get(e.actorIds[1])??i;a=Math.floor((F[i]+F[t])/2)-Math.floor(n/2)}else a=F[i]-Math.floor(n/2);a=Math.max(0,a),ve.push({x:a,y:I,width:n,height:r,lines:t}),I+=r}for(let e=0;e<i.messages.length;e++){for(let t=0;t<i.blocks.length;t++)i.blocks[t].startIndex===e&&(I+=L+1,he.set(t,I-1));for(let t=0;t<i.blocks.length;t++)for(let n=0;n<i.blocks[t].dividers.length;n++)i.blocks[t].dividers[n].index===e&&(I+=L,_e.set(`${t}:${n}`,I),I+=xe);I+=L;let t=i.messages[e],n=t.from===t.to,r=Rc(t.label),a=n?void 0:A.get(e),o=j.get(e);if(n)me[e]=I+1,pe[e]=I,I+=2+r;else{let t=a===void 0?0:O,n=a===void 0?0:k;me[e]=I,pe[e]=I+r+t,I+=r+t+1+n,a!==void 0&&ee.set(a,pe[e]-t)}o!==void 0&&(M.set(o,I),I+=1);for(let t=0;t<i.notes.length;t++)if(i.notes[t].afterIndex===e){I+=L;let e=i.notes[t],n=$(e.text),r=oe(e),a=n.length+2,o=g.get(e.actorIds[0])??0,s;if(e.position===`left`)s=F[o]-r-1;else if(e.position===`right`)s=F[o]+2;else if(e.actorIds.length>=2){let t=g.get(e.actorIds[1])??o;s=Math.floor((F[o]+F[t])/2)-Math.floor(r/2)}else s=F[o]-Math.floor(r/2);s=Math.max(0,s),ve.push({x:s,y:I,width:r,height:a,lines:n}),I+=a}for(let t=0;t<i.blocks.length;t++)i.blocks[t].endIndex===e&&(I+=L,ge.set(t,I),I+=xe)}I+=xe;let Se=I,R=Se+re,Ce=R+T+re,we=(F[F.length-1]??0)+(C[C.length-1]??0)+2;for(let e of N)we=Math.max(we,fe(e)+2);for(let e=0;e<i.messages.length;e++){let t=i.messages[e];if(t.from===t.to){let e=F[_(t.from)]+Lu(t)+2+2+Lc(t.label);we=Math.max(we,e+1)}}for(let e of ve)we=Math.max(we,e.x+e.width+1);let Te=is(we,Ce-1),Ee=os(we,Ce-1);function z(e,t,n,r){q(Te,e,t,n,{role:r,roleCanvas:Ee})}function De(e,t,n,r,i){let a=rs(n);for(let n=0;n<a.length;n++){let o=e+n;if(i!==void 0&&o>=i||a[n+1]===``&&i!==void 0&&o+1>=i)break;z(o,t,a[n],r)}}function Oe(e,t,n,r,i){let a=r===`actor`?Pu:[],f=[...a,...$(n)],p=Math.max(Lc(n),a.length>0?Fu:0),m=p+2*y+2,h=i,g=h-2,_=e-Math.floor(m/2);z(_,t,c,`border`);for(let e=1;e<m-1;e++)z(_+e,t,o,`border`);z(_+m-1,t,l,`border`);for(let e=0;e<g;e++){let n=t+1+e;z(_,n,s,`border`),z(_+m-1,n,s,`border`);let r=f[e];r!==void 0&&De(_+1+y+Math.floor((p-K(r))/2),n,r,`text`)}let v=t+h-1;z(_,v,u,`border`);for(let e=1;e<m-1;e++)z(_+e,v,o,`border`);z(_+m-1,v,d,`border`)}let ke=e=>{let t=ee.get(e);return t===void 0?be:t+T},Ae=e=>M.get(e)??Se;for(let e=0;e<i.actors.length;e++){let t=F[e];for(let n=ke(e);n<=Ae(e);n++)z(t,n,s,`line`)}let je=a?`+`:`┼`;function Me(e,t,n){let r=de(e),i=fe(e),a=t+T+1;z(r,t,c,`border`),z(i,t,l,`border`),z(r,a,u,`border`),z(i,a,d,`border`);for(let e=r+1;e<i;e++)z(e,t,o,`border`),z(e,a,o,`border`);for(let e=t+1;e<a;e++)z(r,e,s,`border`),z(i,e,s,`border`);n!==``&&De(r+2,t,` ${$(n)[0]} `,`text`);for(let n=e.lo;n<=e.hi;n++){let e=F[n];ke(n)<=t&&t<=Ae(n)&&z(e,t,je,`junction`),ke(n)<=a&&a<=Ae(n)&&z(e,a,je,`junction`)}}for(let e of N)Me(e,0,e.label),Me(e,Se,``);for(let e=0;e<i.actors.length;e++){let t=i.actors[e],n=ee.get(e)??ye,r=M.has(e);Oe(F[e],n,t.label,t.type,T),r||Oe(F[e],R,t.label,t.type,T),a||(z(F[e],n+T-1,f,`junction`),r||z(F[e],R,p,`junction`))}for(let e=0;e<i.messages.length;e++){let t=i.messages[e],n=_(t.from),r=_(t.to),c=F[n],l=F[r],u=n===r,d=t.lineStyle===`dashed`,f=t.arrowHead===`filled`,p=t.isLost===!0,h=a?`x`:`✕`,g=d?a?`.`:`╌`:o;if(u){let n=pe[e],r=Lu(t),i=t.seqNumber===void 0?void 0:String(t.seqNumber),o=$(t.label);z(c,n,m,`junction`);let l=c+1;if(i!==void 0){for(let e=0;e<i.length;e++)z(c+1+e,n,i[e],`text`);l=c+1+i.length}for(let e=l;e<c+r;e++)z(e,n,g,`line`);z(c+r,n,a?`+`:`┐`,`corner`);let u=c+r+2;for(let e=0;e<o.length;e++){let t=n+1+e;z(c+r,t,s,`line`),De(u,t,o[e],`text`,we)}let d=n+1+o.length;z(c,d,p?h:f?a?`<`:`◀`:a?`<`:`◁`,`arrow`);for(let e=c+1;e<c+r;e++)z(e,d,g,`line`);z(c+r,d,a?`+`:`┘`,`corner`)}else{let n=me[e],i=pe[e],o=c<l,s=A.get(e)===r,u=l;if(s){let e=E(r,l),t=e+S[r]-1;u=o?e-1:t+1}let d=Math.floor((c+l)/2),m=$(t.label);for(let e=0;e<m.length;e++){let t=m[e];De(d-Math.floor(K(t)/2),n+e,t,`text`,we)}if(o){for(let e=c+1;e<u;e++)z(e,i,g,`line`);z(u,i,p?h:f?a?`>`:`▶`:a?`>`:`▷`,`arrow`),t.bidirectional&&z(c,i,a?`<`:`◀`,`arrow`)}else{for(let e=u+1;e<c;e++)z(e,i,g,`line`);z(u,i,p?h:f?a?`<`:`◀`:a?`<`:`◁`,`arrow`),t.bidirectional&&z(c,i,a?`>`:`▶`,`arrow`)}if(t.seqNumber!==void 0){let e=String(t.seqNumber);if(o){let t=c+1;if(t+e.length<l)for(let n=0;n<e.length;n++)z(t+n,i,e[n],`text`)}else{let t=c-e.length;if(t>u)for(let n=0;n<e.length;n++)z(t+n,i,e[n],`text`)}}}}for(let[e,t]of M)z(F[e],t,a?`x`:`✕`,`arrow`);let Ne=we-1;for(let e=0;e<i.blocks.length;e++){let t=i.blocks[e],n=he.get(e),r=ge.get(e);if(n===void 0||r===void 0)continue;let a=we,f=0;for(let e=t.startIndex;e<=t.endIndex&&!(e>=i.messages.length);e++){let t=i.messages[e],n=g.get(t.from)??0,r=g.get(t.to)??0;if(a=Math.min(a,F[Math.min(n,r)]),f=Math.max(f,F[Math.max(n,r)]),n===r){let e=F[n]+Lu(t)+2+Lc(t.label);f=Math.max(f,e)}}let p=a-Iu,_=f+Iu,y=1/0,b=-1/0;for(let e of F)e>f&&e<y&&(y=e),e<a&&e>b&&(b=e);_>=y&&(_=Math.max(f,y-Iu)),p<=b&&(p=Math.min(a,b+Iu)),p=Math.max(0,p),_>Ne&&(us(Te,_+1,Ce-1),ss(Ee,_+1,Ce-1),Ne=_);let x=t.label?`${t.type} [${t.label}]`:t.type,S=p+1+v(t);if(S>_){_=S;let[e]=ls(Te);_>e&&(us(Te,_,Ce-1),ss(Ee,_,Ce-1)),we=Math.max(we,_+1),Ne=Math.max(Ne,_)}z(p,n,c,`border`);for(let e=p+1;e<_;e++)z(e,n,o,`border`);z(_,n,l,`border`);let C=$(x);for(let e=0;e<C.length&&n+e<r;e++)De(p+1,n+e,C[e],`text`,_);z(p,r,u,`border`);for(let e=p+1;e<_;e++)z(e,r,o,`border`);z(_,r,d,`border`);for(let e=n+1;e<r;e++)z(p,e,s,`border`),z(_,e,s,`border`);for(let n=0;n<t.dividers.length;n++){let r=_e.get(`${e}:${n}`);if(r===void 0)continue;let i=Pe();z(p,r,m,`junction`);for(let e=p+1;e<_;e++)z(e,r,i,`line`);z(_,r,h,`junction`);let a=t.dividers[n].label;if(a){let e=`[${a}]`;De(p+1,r,e,`text`,_)}}}for(let e of ve){us(Te,e.x+e.width,e.y+e.height),ss(Ee,e.x+e.width,e.y+e.height),z(e.x,e.y,c,`border`);for(let t=1;t<e.width-1;t++)z(e.x+t,e.y,o,`border`);z(e.x+e.width-1,e.y,l,`border`);for(let t=0;t<e.lines.length;t++){let n=e.y+1+t;z(e.x,n,s,`border`),z(e.x+e.width-1,n,s,`border`);for(let t=e.x+1;t<e.x+e.width-1;t++)z(t,n,` `,`text`);De(e.x+1+y,n,e.lines[t],`text`)}let t=e.y+e.height-1;z(e.x,t,u,`border`);for(let n=1;n<e.width-1;n++)z(e.x+n,t,o,`border`);z(e.x+e.width-1,t,d,`border`)}return _s(Te,{roleCanvas:Ee,colorMode:n,theme:r});function Pe(){return a?`-`:`╌`}}function zu(e,t){return e.rowStart<=t.rowEnd&&t.rowStart<=e.rowEnd}function Bu(e,t){let n=e.map(e=>({item:e,geom:t(e)})).sort((e,t)=>e.geom.idealMid-t.geom.idealMid),r=(e,t)=>{let r=n[e];if(r)for(let i=e+t;i>=0&&i<n.length;i+=t){let e=n[i];if(e&&zu(e.geom,r.geom))return e.geom}},i=new Map;for(let[e,t]of n.entries()){let n=t.geom,a=r(e,-1),o=r(e,1),s=a&&a.end>=n.start?Math.floor((a.idealMid+n.idealMid)/2)+1:-1/0,c=o&&n.end>=o.start?Math.floor((n.idealMid+o.idealMid)/2):1/0;i.set(t.item,{left:s,right:c})}return i}function Vu(e){let t=[];e.annotation&&t.push(`<<${e.annotation}>>`);let n=$(e.label);t.push(...n);let r=e.attributes.map(lt),i=e.methods.map(lt),a=[t];return r.length>0&&a.push(r),i.length>0&&a.push(i),a}function Hu(e,t){return{type:e,markerAt:t,dashed:e===`dependency`||e===`realization`}}function Uu(e,t,n){switch(e){case`inheritance`:case`realization`:return n===`down`?t?`^`:`△`:n===`up`?t?`v`:`▽`:n===`left`?t?`>`:`◁`:t?`<`:`▷`;case`composition`:return t?`*`:`◆`;case`aggregation`:return t?`o`:`◇`;case`association`:case`dependency`:return n===`down`?t?`v`:`▼`:n===`up`?t?`^`:`▲`:n===`left`?t?`<`:`◀`:t?`>`:`▶`}}function Wu(e,t,n,r,i){let a=e+t.length-1,o=r>e,s=i<a;if(!o&&!s)return{start:e,cells:t};let c=o?r:e,l=Math.max(0,(s?i:a)-c+1),u=+!!o+ +!!s;if(l===0)return{start:c,cells:[]};if(l<u)return{start:c,cells:[`…`]};let d=Math.max(0,l-u),f=rs(n),p=f.length<=d?f:o&&!s?f.slice(f.length-d):f.slice(0,d),m=[...o?[`…`]:[],...p,...s?[`…`]:[]];return{start:c+Math.max(0,Math.floor((l-m.length)/2)),cells:m}}function Gu(e){return Math.max(...$(e).map(e=>K(e)))+2}function Ku(e,t,n,r,i={}){let{diagram:a,notesById:o}=qu(et(D(e)));if(a.classes.length===0)return``;let s=t.useAscii,c=tc(t.paddingX,5,4,1),l=tc(t.paddingY,5,3,1),u=new Map,f=new Map,p=new Map;for(let e of a.classes){let n=Vu(e);u.set(e.id,n);let{width:r,height:i}=yu(n,t.boxBorderPadding);f.set(e.id,r),p.set(e.id,i)}let m=new Map;for(let e of a.classes)m.set(e.id,e);let h=new Map,g=new Map;for(let e of a.relationships){let t=e.from,n=e.to,r=h.get(n)??new Set;h.set(n,r),r.add(t);let i=g.get(t)??new Set;g.set(t,i),i.add(n)}let _=new Map,v=a.classes.filter(e=>!h.has(e.id)||h.get(e.id).size===0).map(e=>e.id);for(let e of v)_.set(e,0);let y=a.classes.length-1,b=0;for(;b<v.length;){let e=v[b++],t=g.get(e);if(t)for(let n of t){let t=(_.get(e)??0)+1;t>y||(!_.has(n)||_.get(n)<t)&&(_.set(n,t),v.push(n))}}for(let e of a.classes)_.has(e.id)||_.set(e.id,0);Ju(o,_);let x=Math.max(..._.values(),0),S=Array.from({length:x+1},()=>[]);for(let e of a.classes)S[_.get(e.id)].push(e.id);let C=new Map,w=new Map;{let e=new Map;a.relationships.forEach((t,n)=>{let r=[t.from,t.to].sort().join(`::`),i=e.get(r)??[];i.push(n),e.set(r,i)});for(let t of e.values()){if(t.length<2)continue;let e=t.length,n=Math.max(...t.map(e=>{let t=a.relationships[e].label;return t?Gu(t):3}))+1;t.forEach((t,r)=>{C.set(t,Math.round((r-(e-1)/2)*n)),w.set(t,(e-1)*n)})}}let T=new Map,E=new Map,O=new Map,k=new Map;{let e=(e,t,n)=>{let r=new Map;a.relationships.forEach((t,n)=>{if(C.has(n)||!m.has(t.from)||!m.has(t.to))return;let i=_.get(t.from)??0;if((_.get(t.to)??0)-i!==1)return;let a=e(t),o=r.get(a)??[];o.push(n),r.set(a,o)});for(let e of r.values()){if(e.length<2)continue;let r=e.length,i=Math.max(...e.map(e=>{let t=a.relationships[e].label;return t?Gu(t):3}))+1;e.forEach((e,a)=>{t.set(e,Math.round((a-(r-1)/2)*i)),n.set(e,(r-1)*i)})}};e(e=>e.to,O,k),e(e=>e.from,T,E)}let A=new Map;for(let e of a.classes)A.set(e.id,{left:0,right:0});a.relationships.forEach((e,t)=>{if(!m.has(e.from)||!m.has(e.to))return;let n=e.label?Gu(e.label):1,r=C.get(t)??T.get(t)??0,i=C.get(t)??O.get(t)??0,a=A.get(e.from);a.left=Math.max(a.left,Math.floor(n/2)-r),a.right=Math.max(a.right,r+n-1-Math.floor(n/2));let o=A.get(e.to);o.left=Math.max(o.left,Math.floor(n/2)-i),o.right=Math.max(o.right,i+n-1-Math.floor(n/2))});let j=new Map,ee=0,M=0;for(let e=0;e<=x;e++){let t=S[e];if(t.length===0)continue;let n=e=>{let t=h.get(e);return t&&t.size>0?[...t].sort().join(`,`):`root:${e}`},r=new Map;for(let e of t){let t=n(e),i=r.get(t);i||(i=[],r.set(t,i)),i.push(e)}let i=new Map,a=new Map,o=new Map;{let e=0;for(let n of t){let t=f.get(n),r=A.get(n),s=Math.max(0,r.left-Math.floor(t/2)),l=Math.max(0,r.right-(t-1-Math.floor(t/2)));i.set(n,e),a.set(n,s+t+l),o.set(n,s),e+=s+t+l+c}}let s=0,d=0,g=(e,t)=>{let n=m.get(e),r=f.get(e),i=p.get(e),l=o.get(e),h=a.get(e);j.set(e,{cls:n,sections:u.get(e),x:t+l,y:ee,width:r,height:i}),M=Math.max(M,t+h),s=t+h+c,d=Math.max(d,i)},v=new Set;for(let l of t){if(v.has(l))continue;let t=n(l),u=h.get(l),d=u?[...u].filter(t=>_.get(t)<e):[];if(d.length===0){g(l,Math.max(i.get(l),s,0)),v.add(l);continue}let p=r.get(t),m=d.map(e=>{let t=j.get(e);return t.x+Math.floor(t.width/2)}),y=Math.round(m.reduce((e,t)=>e+t,0)/m.length),b=0;for(let e=0;e<p.length;e++)b+=a.get(p[e]),e<p.length-1&&(b+=c);let x=o.get(p[0]),S=p[p.length-1],C=a.get(S)-o.get(S)-f.get(S),w=b-x-C,T=y-x-Math.floor(w/2),E=Math.max(T,s,0);for(let e of p)g(e,E),v.add(e),E=s}ee+=d+l}let N=M,te=0;for(let e of j.values())N=Math.max(N,e.x+e.width),te=Math.max(te,e.y+e.height);N+=4,te+=2;let ne=is(N-1,te-1),re=os(N-1,te-1);function ie(e,t,n,r){q(ne,e,t,n,{role:r,roleCanvas:re})}let ae=i.hyperlinks?Oo(N-1,te-1):void 0;for(let e of j.values()){let n=bu(e.sections,s,t.boxBorderPadding);for(let t=0;t<n.length;t++)for(let r=0;r<n[0].length;r++){let i=n[t][r];if(i!==` `){let n=e.x+t,a=e.y+r;n<N&&a<te&&ie(n,a,i,vu(i))}}if(ae){let t=d(a.interactions.get(e.cls.id)?.href),r=e.sections[0];if(t!==void 0&&r!==void 0){let i=1+ +!!e.cls.annotation;jo(ae,n,{x:e.x,y:e.y},t,{from:i,to:r.length})}}}let oe=new Set;for(let e of j.values())for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++)oe.add(`${e.x+n},${e.y+t}`);function P(e,t,n,r){oe.has(`${e},${t}`)||ie(e,t,n,r)}function se(e,t,n){for(let[r,i]of j.entries())if(!n?.has(r)&&e>=i.x&&e<=i.x+i.width-1&&t>=i.y&&t<=i.y+i.height-1)return!0;return!1}function ce(e,t,n,r){return Eu(e,0,e+N+9,e=>{for(let i=Math.min(t,n);i<=Math.max(t,n);i++)if(se(e,i,r))return!1;return!0})??N+2}let le=s?`-`:`─`,ue=s?`|`:`│`,F=s?`.`:`╌`,de=s?`:`:`┊`;function fe(e,t,n){let r=Math.floor(n/2),i=n-1-r,a=t>r+i?(r+i)/t:1;return Math.max(-r,Math.min(i,Math.round(e*a)))}function pe(e,t,n){let r=C.get(e)??T.get(e)??0,i=C.get(e)??O.get(e)??0,a=w.get(e)??E.get(e)??0,o=w.get(e)??k.get(e)??0,s=t.x+Math.floor(t.width/2),c=n.x+Math.floor(n.width/2);return{fromCX:s+r,toCX:c+i,fromAnchorX:s+fe(r,a,t.width),toAnchorX:c+fe(i,o,n.width)}}function me(e,t,n,r){if(oe.has(`${e},${t}`)||re[e]?.[t]===`arrow`)return;let i=ne[e]?.[t];if(!s&&i!==void 0&&fs(i)&&fs(n)){let a=hs(i,n);ie(e,t,a,a===n?r:`junction`);return}ie(e,t,n,r)}function he(e,t,n,r,i){if(t===n)return;let a=Math.min(t,n),o=Math.max(t,n);for(let t=a+1;t<o;t++)me(t,e,r,`line`);if(s){me(t,e,r,`line`),me(n,e,r,`line`);return}let c=n>t,l=i?c?`└`:`┘`:c?`┌`:`┐`,u=i?c?`┐`:`┌`:c?`┘`:`└`;me(t,e,l,`corner`),me(n,e,u,`corner`)}let ge=new Map,_e=new Map;a.relationships.forEach((e,t)=>{let n=j.get(e.from),r=j.get(e.to);if(!n||!r)return;let i=Hu(e.type,e.markerAt),a=i.dashed?F:le,o=i.dashed?de:ue,c=new Set([e.from,e.to]),{fromCX:l,toCX:u,fromAnchorX:d,toAnchorX:f}=pe(t,n,r),p=n.y+n.height-1,m=r.y;if(p<m){let e=ce(l,p+1,m-1,c),n=e!==l;if(e>=N&&us(ne,e+2,te),n){let n=p+1,r=m-1;ge.set(t,{routeX:e,exitY:n,entryY:r,fromAnchorX:d,toAnchorX:f,clearSide:e>l?`right`:`left`});let c=Math.min(d,e),u=Math.max(d,e);for(let e=c;e<=u;e++)P(e,n,a,`line`);!s&&n<(ne[0]?.length??0)&&(d<e?(P(d,n,`└`,`corner`),P(e,n,`┐`,`corner`)):(P(d,n,`┘`,`corner`),P(e,n,`┌`,`corner`)));for(let t=n+1;t<=r;t++)P(e,t,o,`line`);if(e!==f){let t=Math.min(e,f),n=Math.max(e,f);for(let e=t;e<=n;e++)P(e,r,a,`line`);!s&&r<(ne[0]?.length??0)&&(e<f?(P(e,r,`└`,`corner`),P(f,r,`┐`,`corner`)):(P(e,r,`┘`,`corner`),P(f,r,`┌`,`corner`)))}if(i.markerAt===`to`){let e=i.type===`inheritance`||i.type===`realization`;P(f,r,Uu(i.type,s,e?`up`:`down`),`arrow`)}if(i.markerAt===`from`){let e=Uu(i.type,s,`down`);P(d,p+1,e,`arrow`)}}else{let e=p+Math.floor((m-p)/2),t=l!==d,n=u!==f;he(p+1,d,l,a,!0);for(let n=p+(t?2:1);n<=e;n++)P(l,n,o,`line`);if(l!==u&&e<(ne[0]?.length??0)){let t=Math.min(l,u),n=Math.max(l,u);for(let r=t;r<=n;r++)P(r,e,a,`line`);s||(P(l,e,l<u?`└`:`┘`,`corner`),P(u,e,l<u?`┐`:`┌`,`corner`))}for(let t=e+1;t<m-+!!n;t++)P(u,t,o,`line`);if(he(m-1,f,u,a,!1),i.markerAt===`to`){let e=i.type===`inheritance`||i.type===`realization`;P(f,m-1,Uu(i.type,s,e?`up`:`down`),`arrow`)}i.markerAt===`from`&&P(d,p+1,Uu(i.type,s,`down`),`arrow`)}}else if(r.y+r.height-1<n.y){let e=n.y,t=r.y+r.height-1,c=t+Math.floor((e-t)/2),p=l!==d,m=u!==f;he(e-1,d,l,a,!1);for(let t=e-(p?2:1);t>=c;t--)P(l,t,o,`line`);if(l!==u){let e=Math.min(l,u),t=Math.max(l,u);for(let n=e;n<=t;n++)P(n,c,a,`line`);!s&&c>=0&&c<te&&(P(l,c,l<u?`┌`:`┐`,`corner`),P(u,c,l<u?`┘`:`└`,`corner`))}for(let e=c-1;e>t+ +!!m;e--)P(u,e,o,`line`);if(he(t+1,f,u,a,!0),i.markerAt===`from`){let t=Uu(i.type,s,`up`),n=e-1;for(let e=0;e<t.length;e++)P(d-Math.floor(t.length/2)+e,n,t[e],`arrow`)}if(i.markerAt===`to`){let e=i.type===`inheritance`||i.type===`realization`?`down`:`up`,n=Uu(i.type,s,e),r=t+1;for(let e=0;e<n.length;e++)P(f-Math.floor(n.length/2)+e,r,n[e],`arrow`)}}else{let c=r.y+r.height-1,m=Math.min(l,u),h=Math.max(l,u),g=Math.max(p,c);for(let[t,r]of j.entries())t!==e.from&&t!==e.to&&r.y===n.y&&r.x<h+1&&r.x+r.width>m&&(g=Math.max(g,r.y+r.height-1));let _=g+2;_e.set(t,_),us(ne,N,_+1),ss(re,N,_+1);let v=l!==d,y=u!==f;he(p+1,d,l,a,!0);for(let e=p+(v?2:1);e<=_;e++)P(l,e,o,`line`);for(let e=m;e<=h;e++)P(e,_,a,`line`);for(let e=_-1;e>=c+(y?2:1);e--)P(u,e,o,`line`);if(he(c+1,f,u,a,!0),i.markerAt===`from`){let e=Uu(i.type,s,`down`),t=p+1;for(let n=0;n<e.length;n++)P(d-Math.floor(e.length/2)+n,t,e[n],`arrow`)}if(i.markerAt===`to`){let e=i.type===`inheritance`||i.type===`realization`,t=Uu(i.type,s,e?`down`:`up`),n=r.y+r.height;for(let e=0;e<t.length;e++)P(f-Math.floor(t.length/2)+e,n,t[e],`arrow`)}}});function ve(e,t,n,r){let{fromCX:i,toCX:a}=pe(e,t,n),o=t.y+t.height-1,s=n.y;if(o<s){let t=ge.get(e);if(t){let e=t.exitY+1,n=t.entryY;if(n>=e)return{idealMidX:t.clearSide===`right`?t.routeX+1+Math.floor(r/2):t.routeX-1-Math.ceil(r/2),baseMidY:Math.floor((e+n)/2)};let i=Math.abs(t.routeX-t.fromAnchorX);return Math.abs(t.toAnchorX-t.routeX)>=i?{idealMidX:Math.floor((t.routeX+t.toAnchorX)/2),baseMidY:t.entryY}:{idealMidX:Math.floor((t.fromAnchorX+t.routeX)/2),baseMidY:t.exitY}}return{idealMidX:Math.floor((i+a)/2),baseMidY:Math.floor((o+1+s-1)/2)}}if(n.y+n.height-1<t.y){let e=n.y+n.height-1;return{idealMidX:Math.floor((i+a)/2),baseMidY:Math.floor((e+1+t.y-1)/2)}}return{idealMidX:Math.floor((i+a)/2),baseMidY:_e.get(e)??Math.max(o,n.y+n.height-1)+2}}function ye(e,t,n,r,i,a,o){let s=r,c=Math.floor(a/2),l=e.y+e.height-1,u=t.y,d=!1;for(let e=0;e<a;e++){let t=s-c+e,r=n-Math.floor(i/2),a=Math.max(0,r);for(let e=a;e<a+i;e++)if(se(e,t,o)){d=!0;break}if(d)break}if(d){let e=l+1,t=u-1;for(let r=e;r<=t;r++){let e=!0,t=n-Math.floor(i/2),a=Math.max(0,t);for(let t=a;t<a+i;t++)if(se(t,r,o)){e=!1;break}if(e){s=r;break}}}return s}let be=new Map,I=[];for(let[e,t]of a.relationships.entries()){if(!t.label)continue;let n=j.get(t.from),r=j.get(t.to);if(!n||!r)continue;let i=$(t.label),a=Math.floor(i.length/2),o=Math.max(...i.map(K))+2,{idealMidX:s,baseMidY:c}=ve(e,n,r,o),l=new Set([t.from,t.to]),u=ye(n,r,s,c,o,i.length,l);be.set(t,u);let d=Math.max(0,s-Math.floor(o/2));I.push({rel:t,idealMidX:s,naturalStart:d,naturalEnd:d+o-1,rowStart:u-a,rowEnd:u+a})}let L=Bu(I,e=>({idealMid:e.idealMidX,start:e.naturalStart,end:e.naturalEnd,rowStart:e.rowStart,rowEnd:e.rowEnd})),xe=new Map;for(let e of I){let t=L.get(e);t&&xe.set(e.rel,t)}for(let[e,t]of a.relationships.entries()){let n=j.get(t.from),r=j.get(t.to);if(!(!n||!r)&&t.label){let i=$(t.label),{idealMidX:a}=ve(e,n,r,Math.max(...i.map(e=>K(e)))+2),o=be.get(t)-Math.floor(i.length/2),s=xe.get(t);for(let e=0;e<i.length;e++){let t=o+e,n=i[e],r=rs(` ${n} `),{start:c,cells:l}=Wu(Math.max(0,a-Math.floor(r.length/2)),r,n,Math.max(0,s.left),s.right),u=c+l.length;u>0&&t>=0&&(us(ne,Math.max(u,1),Math.max(t+1,1)),ss(re,Math.max(u,1),Math.max(t+1,1)));for(let e=0;e<l.length;e++){let n=c+e;n>=0&&t>=0&&ie(n,t,l[e],`text`)}}}}return Yu(o,j,ne,s,ie),_s(ne,{roleCanvas:re,colorMode:n,theme:r,linkCanvas:ae})}function qu(e){let t=new Map;if(e.notes.length===0)return{diagram:e,notesById:t};let n=(e,n)=>{let r=`note ${e}`;return t.set(r,n),{id:r,label:n.text,attributes:[],methods:[]}},r=new Set(e.classes.map(e=>e.id)),i=[];for(let t of e.classes){i.push(t);for(let[r,a]of e.notes.entries())a.forClass===t.id&&i.push(n(r,a))}for(let[t,a]of e.notes.entries())(a.forClass===void 0||!r.has(a.forClass))&&i.push(n(t,a));return{diagram:{...e,classes:i},notesById:t}}function Ju(e,t){for(let[n,r]of e){if(r.forClass===void 0)continue;let e=t.get(r.forClass);e!==void 0&&t.set(n,e)}}function Yu(e,t,n,r,i){if(e.size===0)return;let a=Bc(`rounded`,r),o=r?`.`:`╌`;for(let[r,s]of e){let e=t.get(r);if(!e)continue;let c=e.x+e.width-1,l=e.y+e.height-1;if(i(e.x,e.y,a.tl,`border`),i(c,e.y,a.tr,`border`),i(e.x,l,a.bl,`border`),i(c,l,a.br,`border`),s.forClass===void 0)continue;let u=t.get(s.forClass);if(!u||u.x+u.width>e.x||u.y!==e.y)continue;let d=u.y+1;for(let t=u.x+u.width;t<e.x;t++)n[t]?.[d]===` `&&i(t,d,o,`line`)}}function Xu(e,t){let n=new Set,r=new Map;for(let t of e.subgraphs)Zu(t,n,r);let i=new Map,a=0;for(let[t,r]of e.nodes){if(n.has(t))continue;let e={name:t,displayLabel:xe(r.label),shape:r.shape,index:a,gridCoord:null,drawingCoord:null,drawing:null,drawn:!1,styleClassName:``,styleClass:sc};i.set(t,e),a++}let o=[...i.values()],s=[];for(let t of e.edges){let a=t.source,o=t.target;if(n.has(a)){let t=r.get(a),n=t?ed(t,e,`exit`):void 0;n&&(a=n)}if(n.has(o)){let t=r.get(o),n=t?ed(t,e,`entry`):void 0;n&&(o=n)}let c=i.get(a),l=i.get(o);!c||!l||s.push({from:c,to:l,text:t.label?xe(t.label):``,path:[],labelLine:[],startDir:{x:0,y:0},endDir:{x:0,y:0},style:t.style,hasArrowStart:t.hasArrowStart,hasArrowEnd:t.hasArrowEnd,...t.startMarker===void 0?{}:{startMarker:t.startMarker},...t.endMarker===void 0?{}:{endMarker:t.endMarker}})}let c=[];for(let t of e.subgraphs)td(t,null,i,c,e);nd(e.subgraphs,c,i);let l=e.classDefs.get(`default`);if(l)for(let e of i.values())e.styleClassName=`default`,e.styleClass={name:`default`,styles:l};for(let[t,n]of e.classAssignments){let r=i.get(t),a=e.classDefs.get(n);r&&a&&(r.styleClassName=n,r.styleClass={name:n,styles:l?{...l,...a}:a})}return{nodes:o,edges:s,canvas:is(0,0),roleCanvas:os(0,0),grid:lc(),columnWidth:new Map,rowHeight:new Map,subgraphs:c,config:t,offsetX:0,offsetY:0,bundles:[]}}function Zu(e,t,n){t.add(e.id),n.set(e.id,e);for(let r of e.children)Zu(r,t,n)}function Qu(e,t){for(let n of e.nodeIds)t.add(n);for(let n of e.children)Qu(n,t)}function $u(e,t){let n=new Set;if(Qu(e,n),n.size===0)return!0;let r=t=>n.has(t)||t===e.id;return!t.edges.some(e=>r(e.source)!==r(e.target))}function ed(e,t,n){let r=new Set;if(Qu(e,r),r.size===0)return;let i=[...t.nodes.keys()].filter(e=>r.has(e));if(i.length===0)return;let a=i.filter(e=>n===`entry`?!t.edges.some(t=>t.target===e&&r.has(t.source)):!t.edges.some(t=>t.source===e&&r.has(t.target))),o=a.length>0?a:i;return n===`entry`?o[0]:o[o.length-1]}function td(e,t,n,r,i){let a;e.direction&&$u(e,i)&&(a=e.direction===`LR`||e.direction===`RL`?`LR`:`TD`);let o={name:e.label,nodes:[],parent:t,children:[],minX:0,minY:0,maxX:0,maxY:0,direction:a};for(let t of e.nodeIds){let e=n.get(t);e&&o.nodes.push(e)}r.push(o);for(let t of e.children){let e=td(t,o,n,r,i);o.children.push(e);for(let t of e.nodes)o.nodes.includes(t)||o.nodes.push(t)}return o}function nd(e,t,n){let r=new Map;id(e,t,r);let i=new Map;function a(e){let t=r.get(e);if(t){for(let t of e.children)a(t);for(let n of e.nodeIds)i.has(n)||i.set(n,t)}}for(let t of e)a(t);for(let e of t)e.nodes=e.nodes.filter(t=>{let r;for(let[e,i]of n)if(i===t){r=e;break}if(!r)return!1;let a=i.get(r);return!a||rd(e,a)})}function rd(e,t){let n=t;for(;n!==null;){if(n===e)return!0;n=n.parent}return!1}function id(e,t,n){let r=[];function i(e){for(let t of e)r.push(t),i(t.children)}i(e);for(let e=0;e<r.length&&e<t.length;e++){let i=r[e],a=t[e];!i||!a||n.set(i,a)}}function ad(e,t,n,r,i={}){let a=j(Qt(e),i.direction);t.graphDirection=a.direction===`LR`||a.direction===`RL`?`LR`:`TD`;let o=Xu(a,t);bl(o),Tu(o);let s=i.hyperlinks?Mo(o,a.interactions):void 0;return a.direction===`BT`&&(ys(o.canvas),bs(o.roleCanvas),s&&Ao(s)),_s(o.canvas,{roleCanvas:o.roleCanvas,colorMode:n,theme:r,linkCanvas:s})}var od={xychart:(e,t,n,r)=>As(e,t,n,r),er:(e,t,n,r)=>Mu(e,t,n,r),sequence:(e,t,n,r)=>Ru(e,t,n,r),class:(e,t,n,r,i)=>Ku(e,t,n,r,i),flowchart:(e,t,n,r,i)=>ad(e,t,n,r,i)},sd=/\x1b\[[0-9;]*m/g;function cd(e){let t=e.split(`
|
|
80
|
+
`),n=t.reduce((e,t)=>Math.max(e,Do(t.replace(sd,``)).length),0),r=String(Math.max(0,t.length-1)).length,i=` `.repeat(r+1);return[i+Array.from({length:n},(e,t)=>String(Math.floor(t/10)%10)).join(``),i+Array.from({length:n},(e,t)=>String(t%10)).join(``),...t.map((e,t)=>`${String(t).padStart(r,` `)} ${e}`)].join(`
|
|
81
|
+
`)}function ld(e,t={}){let n={useAscii:t.useAscii??!1,paddingX:t.paddingX??5,paddingY:t.paddingY??5,boxBorderPadding:t.boxBorderPadding??1,graphDirection:`TD`},r=t.colorMode===`auto`||t.colorMode===void 0?Io():t.colorMode,i={...Fo,...t.theme},a=od[O(e)](e,n,r,i,{hyperlinks:t.hyperlinks??!1,direction:t.direction});return t.showCoords?cd(a):a}var ud=ld,dd={type:`xychart`,parse:At,layoutForSvg:no,renderSvg(e,t,n){let r=n.interactivity===void 0?n.interactive??!1:n.interactivity===`full`;return mo(e,t.colors,t.font,t.transparent,r,t.embedSource,t.title,t.decorative,t.emit)}},fd={type:`sequence`,parse:Tt,layoutForSvg:Ua,renderSvg(e,t){return Wa(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,t.emit)}};function pd(e){return(e.interactivity??`static`)!==`none`}function md(e){return(e.interactivity??`static`)===`full`}var hd={xychart:dd,er:{type:`er`,parse:ut,layoutForSvg(e,t){return ka(j(e,t.direction),t)},renderSvg(e,t){return ja(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,t.emit)}},sequence:fd,class:{type:`class`,parse:et,layoutForSvg:la,renderSvg(e,t,n){return fa(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,pd(n),t.emit)}},flowchart:{type:`flowchart`,parse:(e,t)=>Qt(t),layoutForSvg(e,t){return{graph:Gr(j(e,t.direction),t),curve:t.curve??e.initConfig?.curve??`linear`}},renderSvg(e,t,n){return Kr(e.graph,t.colors,t.font,t.transparent,t.fontSizes,e.curve,t.embedSource,md(n),pd(n),t.title,t.decorative,t.emit)}}};function gd(e){return{bg:e.bg??Ie.bg,fg:e.fg??Ie.fg,line:e.line,accent:e.accent,muted:e.muted,surface:e.surface,border:e.border}}function _d(e={}){return Xe(gd(e),e.transparent)}function vd(e){return{nonce:e.nonce,styleAttribute:e.styleAttribute}}function yd(e,t={}){let n=bd(e,t);return t.resolveColors?ra(n,gd(t)):n}function bd(e,t){let n=(0,l.decodeXML)(e),r=gd(t),i=t.font??`Inter`;ve(_e(i));let a=t.transparent??!1,o=Hn(t.fontSizes),s=O(n),c=t.embedSource?e:void 0,u=t.title,d=t.decorative,f=vd(t),p=D(n),m=hd[s],h=m.parse(p,n),g=m.layoutForSvg(h,t),_={colors:r,font:i,transparent:a,fontSizes:o,embedSource:c,title:u,decorative:d,emit:f};return m.renderSvg(g,_,t)}async function xd(e,t={}){return yd(e,t)}var Sd=yd,Cd=xd;exports.DEFAULTS=Ie,exports.THEMES=Re,exports.createLayoutCache=Fn,exports.fromShikiTheme=ze,exports.parseMermaid=Qt,exports.renderMermaid=Cd,exports.renderMermaidASCII=ld,exports.renderMermaidAscii=ud,exports.renderMermaidSVG=yd,exports.renderMermaidSVGAsync=xd,exports.renderMermaidSync=Sd,exports.themeCssVariables=_d;
|
|
82
82
|
//# sourceMappingURL=index.cjs.map
|