axstack 0.74.0 → 0.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,149 @@
1
+ var V1=[["flowchart","flowchart-elk",/^\s*flowchart-elk/],["mindmap","mindmap",/^\s*mindmap/],["architecture","architecture",/^\s*architecture/],["agentflow","agentflow",/^\s*agentflow-beta\b/],["c4","c4",/^\s*(?:C4Context|C4Container|C4Component|C4Dynamic|C4Deployment)/],["kanban","kanban",/^\s*kanban/],["class","classDiagram",/^\s*classDiagram/],["er","er",/^\s*erDiagram/],["gantt","gantt",/^\s*gantt/],["info","info",/^\s*info/],["pie","pie",/^\s*pie/],["requirement","requirement",/^\s*requirement(Diagram)?/],["sequence","sequence",/^\s*sequenceDiagram/],["swimlane","swimlane",/^\s*swimlane-beta\b/],["flowchart","flowchart-v2",/^\s*(graph|flowchart)/],["timeline","timeline",/^\s*timeline/],["gitGraph","gitGraph",/^\s*gitGraph/],["state","stateDiagram",/^\s*stateDiagram/],["journey","journey",/^\s*journey/],["quadrantChart","quadrantChart",/^\s*quadrantChart/],["sankey","sankey",/^\s*sankey(-beta)?/],["packet","packet",/^\s*packet(-beta)?/],["xychart","xychart",/^\s*xychart(-beta)?/],["block","block",/^\s*block(-beta)?/],["eventmodeling","eventmodeling",/^\s*eventmodeling/],["treeView","treeView",/^\s*treeView-beta/],["radar","radar",/^\s*radar-beta/],["ishikawa","ishikawa",/^\s*ishikawa(-beta)?\b/i],["treemap","treemap",/^\s*treemap/],["railroad","railroad",/^\s*railroad-beta/i],["railroad","railroadEbnf",/^\s*railroad-ebnf-beta/i],["railroad","railroadAbnf",/^\s*railroad-abnf-beta/i],["railroad","railroadPeg",/^\s*railroad-peg-beta/i],["venn","venn",/^\s*venn-beta/],["wardley","wardley",/^\s*wardley-beta/i],["cynefin","cynefin",/^\s*cynefin-beta(?:[\s:]|$)/],["usecase","usecase",/^\s*usecase-beta(?:\s|$)/]];function Jd(e){for(let[t,n,r]of V1)if(r.test(e))return{type:t,mermaidType:n};return null}var qe=class extends Error{code;type;mermaidType;line;column;snippet;constructor(t,n="syntax",r={}){super(t),this.name="PeleError",this.code=n,this.type=r.type??null,this.mermaidType=r.mermaidType??null,this.line=r.line??0,this.column=r.column??0,this.snippet=r.snippet??""}};function ls(e,t,n){return Array.from(e.matchAll(t),r=>[r.index,r.index+r[0].length,n])}function j1(e,t){let n=0;for(let[r,i,s]of e){let a=r-n;if(t<a)break;if(t<a+s)return r+Math.min(t-a,i-r-1);n+=i-r-s}return t+n}function Kr(e,t){for(let n=e.length-1;n>=0;n--)t=j1(e[n],t);return t}var _i;function Qp(e,t){let n=_i;_i=e;try{return t()}finally{_i=n}}function cs(e,t){return _i!==void 0&&e===_i.parsed?_i.find(t):[e,t]}function ar(e,t){let n=e.trimEnd().length;n>0&&t>=n?([e,t]=cs(e,n-1),t++):[e,t]=cs(e,t);let r=1,i=0;for(let c=e.indexOf(`
2
+ `);c!==-1&&c<t;c=e.indexOf(`
3
+ `,c+1))r++,i=c+1;let s=e.indexOf(`
4
+ `,t);s===-1&&(s=e.length);let a=t-i+1,o=e.slice(i,s);return{line:r,column:a,snippet:o+`
5
+ `+"-".repeat(a-1)+"^"}}function ut(e,t,n,r,i=!1){let s=ar(t,n),a=i?`Lexical error on line ${s.line}. Unrecognized text.`:`Parse error on line ${s.line}:`,o=i?`${a}
6
+ ${s.snippet}`:`${a}
7
+ ${s.snippet}
8
+ ${r}`;return new qe(o,"syntax",{type:e,...s})}var X1="amp:38,lt:60,gt:62,quot:34,apos:39,nbsp:160,shy:173,iexcl:161,cent:162,pound:163,curren:164,yen:165,sect:167,copy:169,laquo:171,not:172,reg:174,deg:176,plusmn:177,sup2:178,sup3:179,micro:181,para:182,middot:183,sup1:185,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,euro:8364,trade:8482,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,radic:8730,infin:8734,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830,check:10003,cross:10007,AMP:38,LT:60,GT:62,QUOT:34,lsqb:91,rsqb:93,lcub:123,rcub:125,verbar:124,VerticalLine:124,midast:42,DiacriticalGrave:96,Hat:94,UnderBar:95,equals:61,colon:58,semi:59,num:35,percnt:37,lpar:40,rpar:41,lbrack:91,rbrack:93,lbrace:123,rbrace:125,vert:124,sol:47,bsol:92,quest:63,excl:33,ast:42,plus:43,comma:44,period:46,dollar:36,commat:64,grave:96,hat:94,lowbar:95,tilde:126,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969",Va;function q1(e){if(!Va){Va=new Map;for(let t of X1.split(",")){let n=t.indexOf(":");Va.set(t.slice(0,n),String.fromCodePoint(Number(t.slice(n+1))))}}return Va.get(e)}function Zp(e,t){return e>0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint(e):t}var Q1=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|(\w+));/g,Jp="fl°",em="¶ß";function Z1(e){let t="",n=0,r=e.indexOf(Jp);for(;r!==-1;){let i=e.indexOf("¶",r+2);if(i===-1)break;if(e[i+1]==="ß"){let s=e[r+2]==="°";t+=e.slice(n,r)+(s?"&#":"&")+e.slice(r+(s?3:2),i)+";",n=i+2}r=e.indexOf(Jp,i+1)}return n===0?e:t+e.slice(n)}var J1=/fl°°?(\w+)¶ß/g;function Eo(e){return e.includes(em)?e.replace(J1,"#$1;"):e}function gt(e){return e.includes(em)&&(e=Z1(e)),e.includes("&")&&(e=e.replace(Q1,(t,n,r,i)=>n?Zp(Number(n),t):r?Zp(parseInt(r,16),t):q1(i)??t)),e}var xo,Ao=new Map;function tm(e,t){let n=xo,r=Ao;xo=e,Ao=new Map;try{return t()}finally{xo=n,Ao=r}}function Ri(e){if(xo===void 0)return"";let t=Ao.get(e);return t===void 0&&(t=xo(e)??"",Ao.set(e,t)),t}var Sr,Ti=new Map;function rm(e,t){let n=Sr,r=Ti;Sr=e,Ti=new Map;try{return t()}finally{Sr=n,Ti=r}}function sm(){return Sr!==void 0}function nm(e){return Number.isFinite(e)&&e>0}function im(e,t){if(Sr===void 0)return;let n=t+`
9
+ `+e;if(Ti.has(n))return Ti.get(n);let r=Sr(e,t)??void 0,i=r&&nm(r.width)&&nm(r.height)&&typeof("svg"in r?r.svg:r.html)=="string"?r:void 0;return Ti.set(n,i),i}function om(e){if(Sr===void 0)return e();let t=Sr;Sr=void 0;try{return e()}finally{Sr=t}}var ds=class{constructor(t){this.message=t}message},lm=64;function ja(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var nu=class{lines;i=0;constructor(t){this.lines=(t.includes("\r")?t.replace(/\r\n?/g,`
10
+ `):t).split(`
11
+ `)}skipBlank(){for(;this.i<this.lines.length;){let t=this.lines[this.i].trim();if(t!==""&&t[0]!=="#"&&t!=="---")break;this.i++}}indent(){let t=this.lines[this.i],n=0;for(;n<t.length&&t[n]===" ";)n++;if(t[n]===" ")throw new Error("YAML: tabs are not allowed for indentation");return n}},ew=/^[-+]?(?:0|[1-9][0-9]*)$/,tw=/^[-+]?0x[0-9a-fA-F]+$/,nw=/^[-+]?0o[0-7]+$/,rw=/^[-+]?0b[01]+$/,sw=/^[-+]?(?:[0-9][0-9]*(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/,iw=/[\s#:,[\]{}&*!|>'"%@`]/;function So(e){return e===" "||e===" "||e===`
12
+ `||e==="\r"}function eu(e){let t=e[0],n,r;if(t==='"'||t==="'"){let s=1;for(;;){if(s>=e.length)return null;let a=e[s];if(t==='"'&&a==="\\")s+=2;else if(a===t){if(t==='"'||e[s+1]!=="'")break;s+=2}else s++}for(n=s+1,r=n;So(e[r]);)r++;if(e[r]!==":")return null}else{if(t===void 0||iw.test(t)||t==="-"&&(e.length<2||So(e[1])||e[1]===":"||e[1]==="#"))return null;for(r=1;r<e.length&&e[r]!==":"&&e[r]!=="#";)r++;if(e[r]!==":")return null;for(n=r;So(e[n-1]);)n--}let i=r+1;if(i<e.length&&!So(e[i]))return null;for(;So(e[i]);)i++;return{key:e.slice(0,n),length:i}}function ru(e){let t=e.trim();if(t===""||t==="~"||t==="null"||t==="Null"||t==="NULL")return null;if(t==="true"||t==="True"||t==="TRUE")return!0;if(t==="false"||t==="False"||t==="FALSE")return!1;let n=t[0];if(n!=="-"&&n!=="+"&&n!=="."&&(n<"0"||n>"9"))return t;if(ew.test(t)||sw.test(t))return Number(t);if(tw.test(t)||nw.test(t)||rw.test(t)){let r=t[0]==="-",i=Number(r||t[0]==="+"?t.slice(1):t);return r?-i:i}return/^[-+]?\.(?:inf|Inf|INF)$/.test(t)?t[0]==="-"?-1/0:1/0:/^\.(?:nan|NaN|NAN)$/.test(t)?NaN:t}var am={0:"\0",a:"\x07",b:"\b",t:" ",n:`
13
+ `,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"…",_:" ",L:"\u2028",P:"\u2029"};function wo(e){if(!e.includes(`
14
+ `))return e;let t=e.split(`
15
+ `),n=t.length-1;for(let r=0;r<=n;r++){let i=t[r],s=0,a=i.length;if(r>0)for(;s<a&&(i.charCodeAt(s)===32||i.charCodeAt(s)===9);)s++;if(r<n)for(;a>s&&(i.charCodeAt(a-1)===32||i.charCodeAt(a-1)===9);)a--;t[r]=i.slice(s,a)}return t.join(`
16
+ `).replace(/\n+/g,r=>r.length===1?" ":`
17
+ `.repeat(r.length-1))}function ow(e){if(!e.includes("\\"))return wo(e);let t="",n=wo(e.replace(/\\\n[ \t]*/g,""));for(let r=0;r<n.length;r++){let i=n[r];if(i!=="\\"){t+=i;continue}let s=n[++r];if(s==="x"||s==="u"||s==="U"){let a=s==="x"?2:s==="u"?4:8;t+=String.fromCodePoint(parseInt(n.slice(r+1,r+1+a),16)),r+=a}else if(s in am)t+=am[s];else throw new Error("YAML: unknown escape sequence")}return t}function Bs(e,t,n){for(;t<e.length;){let r=e[t];if(r===" "||r===`
18
+ `||r===" "||r==="\r"||n&&r===",")t++;else if(r==="#"&&(t===0||/\s/.test(e[t-1]))){let i=e.indexOf(`
19
+ `,t);t=i===-1?e.length:i}else break}return t}function cm(e,t){if(!t)throw new Error("YAML: missed comma between flow collection entries");if(e===",")throw new Error("YAML: expected the node content, but found ','")}function Mi(e,t,n,r=0){if(r>lm)throw new Error("YAML: nesting is too deep");t=Bs(e,t,!1);let i=e[t];if(i==="{"){let a={};t++;let o=!0;for(;;){if(t=Bs(e,t,!1),t>=e.length)throw new ds("YAML: unexpected end of the stream within a flow collection");if(e[t]==="}")return[a,t+1];cm(e[t],o);let c;[c,t]=Mi(e,t,":,}",r+1),t=Bs(e,t,!1);let l=null;e[t]===":"&&([l,t]=Mi(e,t+1,",}",r+1)),ja(a,String(c),l),t=Bs(e,t,!1),o=e[t]===",",o&&t++}}if(i==="["){let a=[];t++;let o=!0;for(;;){if(t=Bs(e,t,!1),t>=e.length)throw new ds("YAML: unexpected end of the stream within a flow collection");if(e[t]==="]")return[a,t+1];cm(e[t],o);let c;[c,t]=Mi(e,t,",]",r+1),a.push(c),t=Bs(e,t,!1),o=e[t]===",",o&&t++}}if(i==='"'){let a=t+1;for(;a<e.length&&e[a]!=='"';)a+=e[a]==="\\"?2:1;if(a>=e.length)throw new ds("YAML: unexpected end of the stream within a double quoted scalar");return[ow(e.slice(t+1,a)),a+1]}if(i==="'"){let a=t+1;for(;a<e.length;){if(e[a]==="'"){if(e[a+1]!=="'")break;a++}a++}if(a>=e.length)throw new ds("YAML: unexpected end of the stream within a single quoted scalar");return[wo(e.slice(t+1,a)).replace(/''/g,"'"),a+1]}let s=t;for(;s<e.length;){let a=e[s];if(n.includes(a)&&(a!==":"||s+1>=e.length||/[\s,[\]{}]/.test(e[s+1])))break;if(a==="#"&&s>t&&/\s/.test(e[s-1])){let o=e.indexOf(`
20
+ `,s);return[ru(wo(e.slice(t,s).trim())),o===-1?e.length:o]}s++}return[ru(wo(e.slice(t,s).trim())),s]}function _o(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(t)r==="\\"&&t==='"'?n++:r===t&&(t="");else if(r==='"'||r==="'")t=r;else if(r==="#"&&(n===0||e[n-1]===" "||e[n-1]===" "))return e.slice(0,n)}return e}function aw(e,t,n){let r=t[0]===">",i=t.includes("-")?"-":t.includes("+")?"+":"",s=/[1-9]/.exec(t),a=s?n+Number(s[0]):-1,o=[];for(;e.i<e.lines.length;){let u=e.lines[e.i];if(u.trim()===""){o.push(""),e.i++;continue}let h=u.length-u.trimStart().length;if(a===-1){if(h<=n)break;a=h}if(h<a)break;o.push(u.slice(a)),e.i++}let c=0;for(;o.length>0&&o[o.length-1]==="";)o.pop(),c++;let l;if(r){l="";for(let u=0;u<o.length;u++){let h=o[u];if(u>0){let d=o[u-1];h===""?l+=`
21
+ `:d!==""&&(l+=/^[ \t]/.test(d)||/^[ \t]/.test(h)?`
22
+ `:" ")}l+=h}}else l=o.join(`
23
+ `);return o.length===0?i==="+"?`
24
+ `.repeat(c):"":i==="-"?l:i==="+"?l+`
25
+ `.repeat(c+1):l+`
26
+ `}function tu(e,t,n){let r=t[0];if((r==="|"||r===">")&&/^[|>][-+0-9]*\s*(?:#.*)?$/.test(t))return aw(e,t,n);if(r==="{"||r==="["||r==='"'||r==="'"){let s=e.i,a=t,o=0,c=1;for(;;)try{let[l,u]=Mi(a,0,""),h=0;for(let m=a.indexOf(`
27
+ `);m!==-1&&m<u;m=a.indexOf(`
28
+ `,m+1))h++;let d=a.indexOf(`
29
+ `,u);if(_o(a.slice(u,d===-1?a.length:d)).trim()!=="")throw new Error("YAML: unexpected content after a value");return e.i=s+h,l}catch(l){if(!(l instanceof ds))throw l;if(s+o>=e.lines.length)throw new Error(l.message);let u=e.lines.slice(s+o,s+o+c);a+=`
30
+ `+u.join(`
31
+ `),o+=u.length,c*=2}}let i=_o(t).trim();for(;e.i<e.lines.length;){let s=e.lines[e.i];if(s.trim()===""){let o=e.i;for(;o<e.lines.length&&e.lines[o].trim()==="";)o++;if(o>=e.lines.length||e.lines[o].length-e.lines[o].trimStart().length<=n)break;i+=`
32
+ `.repeat(o-e.i),e.i=o;continue}if(s.length-s.trimStart().length<=n)break;let a=_o(s).trim();i+=(i.endsWith(`
33
+ `)?"":" ")+a,e.i++}return ru(i)}function Xa(e,t,n=0){if(n>lm)throw new Error("YAML: nesting is too deep");if(e.skipBlank(),e.i>=e.lines.length)return null;let r=e.indent();if(r<t)return null;let i=e.lines[e.i].slice(r);if(i==="-"||i.startsWith("- ")){let a=[];for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length||e.indent()!==r));){let o=e.lines[e.i].slice(r);if(o!=="-"&&!o.startsWith("- "))break;let c=o.slice(1),l=c.length-c.trimStart().length+1,u=_o(c).trim();u===""?(e.i++,a.push(Xa(e,r+1,n+1))):eu(u)!==null?(e.lines[e.i]=" ".repeat(r+l)+c.trimStart(),a.push(Xa(e,r+l,n+1))):(e.i++,a.push(tu(e,c.trim(),r)))}return a}if(eu(i)===null)return e.i++,tu(e,i.trim(),r-1);let s={};for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length));){let a=e.indent();if(a<r)break;if(a>r)throw new Error("YAML: bad indentation of a mapping entry");let o=e.lines[e.i].slice(r),c=eu(o);if(!c)throw new Error("YAML: can not read a block mapping entry");let l=String(Mi(c.key,0,"")[0]),u=o.slice(c.length);if(e.i++,_o(u).trim()==="")if(e.skipBlank(),e.i<e.lines.length){let h=e.indent(),d=e.lines[e.i].slice(h),m=d==="-"||d.startsWith("- ");ja(s,l,h>r||m&&h===r?Xa(e,m?r:r+1,n+1):null)}else ja(s,l,null);else ja(s,l,tu(e,u.trim(),r))}return s}function cr(e){let t=e.trim();if(t[0]==="{"||t[0]==="[")try{let[i,s]=Mi(t,0,"");if(Bs(t,s,!1)===t.length)return i}catch(i){throw i instanceof ds?new Error(i.message):i}let n=new nu(e),r=Xa(n,0);if(n.skipBlank(),n.i<n.lines.length&&n.lines[n.i].trim()!=="...")throw new Error("YAML: end of the stream or a document separator is expected");return r}function Xe(e){return e<128?e===32||e>=9&&e<=13:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function jn(e){return e===32||e===9}function Ws(e){return e===10||e===13||e===8232||e===8233}function Et(e){return e>=48&&e<=57}function zr(e){return e>=65&&e<=90||e>=97&&e<=122}function qa(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function it(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95}var cw=/^\s*%%(?!{)[^\n]+\n?/gm,Ci=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,lw=/<(\w+)([^>]*)>/g,dw=/="([^"]*)"/g,uw=new Set(["__proto__","constructor","prototype"]);function um(e,t,n){return n?.push(ls(e,t,0)),e.replace(t,"")}function ou(e,t){e.includes("%%")&&(e=um(e,cw,t));let n=e.trimStart();return t?.push([[0,e.length-n.length,0]]),n}function au(e){return e.includes("\r")?e.replace(/\r\n?/g,`
34
+ `):e}function Qa(e){return e===`
35
+ `||e==="\r"}function su(e){return e!==void 0&&/\s/.test(e)}function fw(e){let t=0;for(;t<e.length&&su(e[t])&&!Qa(e[t]);)t++;let n=e.slice(0,t);if(!e.startsWith("---",t))return;let r=[];for(let h=t+3;h<e.length&&su(e[h]);h++)Qa(e[h])&&r.push(h);if(r.length===0)return;let i=n+"---",s=h=>{if(!Qa(e[h])||!e.startsWith(i,h+1))return-1;let d=-1;for(let m=h+1+i.length;m<e.length&&su(e[m]);m++)Qa(e[m])&&(d=m);return d},a=`
36
+ `+i,o=-1;for(let h=e.lastIndexOf(a);h>r[0];h=e.lastIndexOf(a,h-1))if(s(h)!==-1){o=h;break}if(o===-1)return;let c=r[0];for(let h of r)h<o&&(c=h);let l=c+1,u=l>0?l-1:0;for(let h=e.indexOf(a,u);h!==-1&&h<=o;h=e.indexOf(a,h+1)){if(h<l)continue;let d=s(h);if(d!==-1)return{indent:n,body:e.slice(l,h),length:d+1}}}function Vr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Za(e,t){for(let n of Object.keys(t)){if(uw.has(n))continue;let r=t[n],i=e[n];Vr(r)&&Vr(i)?Za(i,r):Vr(r)?e[n]=Za({},r):e[n]=r}return e}function hw(e,t,n){if(!e.includes("%%{"))return e;let r=e.trim().replace(/'/g,'"');Ci.lastIndex=0;let i;for(;(i=Ci.exec(r))!==null;){i.index===Ci.lastIndex&&Ci.lastIndex++;let s=i[1]??i[2];if(s==="wrap")t.wrap=!0;else if((s==="init"||s==="initialize")&&i[4])try{let a=JSON.parse(i[4].trim());Vr(a)&&Za(t,a)}catch{}}return Ci.lastIndex=0,um(e,Ci,n)}function Ja(e,t){let n=au(e),r=n.includes("<")?n.lastIndexOf(">"):-1;r>0&&(n=n.slice(0,r+1).replace(lw,(c,l,u)=>"<"+l+u.replace(dw,"='$1'")+">")+n.slice(r+1));let i={},s,a=0,o=n.includes("---")?fw(n):void 0;if(o){let c=o.indent?o.body.split(`
37
+ `).map(u=>u.startsWith(o.indent)?u.slice(o.indent.length):u).join(`
38
+ `):o.body,l;try{l=cr(c)}catch(u){throw new qe(`Front matter is not valid YAML. ${u.message}`,"syntax")}if(Vr(l)&&(l.title&&(s=String(l.title)),Vr(l.config)&&Za(i,l.config),l.displayMode)){let u=Vr(i.gantt)?i.gantt:i.gantt={};u.displayMode=String(l.displayMode)}for(let u=n.indexOf(`
39
+ `);u!==-1&&u<o.length;u=n.indexOf(`
40
+ `,u+1))a++;n=n.slice(o.length),t?.push([[0,o.length,0]])}return n=hw(n,i,t),{text:ou(n),title:s,config:i,withComments:n,lineOffset:a}}var pw=/#\w+;/g,mw=/^\+?\d+$/,iu=new RegExp("[\\n\\r\u2028\u2029]","g");function fm(e){if(e===void 0)return;let t=[];return e.push(t),t}function dm(e,t,n){let r=fm(n),i=e.indexOf(t);if(i===-1)return e;let s="",a=0;for(;i!==-1;){iu.lastIndex=i;let o=iu.test(e)?iu.lastIndex-1:e.length,c=!1,l=-1;for(let u=i+t.length;u<o;u++){let h=e.charCodeAt(u);if(h===58)c=!0;else if(h===35){if(c){l=u;break}}else Xe(h)&&(c=!1)}if(l!==-1){let u=e.lastIndexOf(";",o-1);u>l&&(r?.push([u,u+1,0]),s+=e.slice(a,u),a=u+1)}i=o>=e.length?-1:e.indexOf(t,o+1)}return a===0?e:s+e.slice(a)}function cu(e,t){if(!e.includes("#"))return e;e=dm(dm(e,"style",t),"classDef",t);let n=fm(t);return e.replace(pw,(r,i)=>{let s=r.substring(1,r.length-1),a=(mw.test(s)?"fl°°":"fl°")+s+"¶ß";return n?.push([i,i+r.length,a.length]),a})}var hm="7q7q9vfgfgopij5b9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg7q7qg8g8g8fgs7ijijk2k2ijgzlmk27qdwijfgn5k2lmijlmk2ijgzk2ijq8ijijgz7q7q7qd1fg99fgfgdwfgfg7qfgfg6666dw66n5fgfgfgfg99dw7qfgdwk2dwdwdw9a789ag8",pm="7q99d6fgfgopk26m9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg9999g8g8g8gzr3k2k2k2k2ijgzlmk27qfgk2gzn5k2lmijlmk2ijgzk2ijq8ijijgz997q99g8fg99fggzfggzfg99gzgz7q7qfg7qopgzgzgzgzatfg99gzfglmfgfgdwat7satg8";var bm=1.2;function mm(e){let t=new Uint16Array(95);for(let n=0;n<95;n++)t[n]=parseInt(e.substr(n*2,2),36);return t}var gw,bw;function yw(e){return e>=4352&&e<=4447||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=55296&&e<=56319}function Ew(e){return e===173||e>=768&&e<=879||e>=8203&&e<=8207||e>=56320&&e<=57343||e>=65024&&e<=65039||e===65279}var xw={width(e,t,n){let r=(n&4)!==0,i=n&24?t/bm:t,s=n&1?bw??=mm(pm):gw??=mm(hm),a=0;for(let o=0;o<e.length;o++){let c=e.charCodeAt(o);if(!(c<32))if(c<127)a+=r?600:s[c-32];else{if(Ew(c))continue;yw(c)?a+=r?1200:1e3:a+=r?600:580}}return a*i/1e3}};function Aw(){let e=globalThis;try{if(e.OffscreenCanvas)return new e.OffscreenCanvas(1,1).getContext("2d");if(e.document)return e.document.createElement("canvas").getContext("2d")}catch{return null}return null}var Sw=2e4;function gm(){let e=globalThis;return e.document?.fonts??e.fonts}function ww(e,t,n){try{return e?.check(t,n)??!0}catch{return!0}}function _w(e,t="monospace"){let n=Aw();if(!n)return null;let r=new Map,i="",s=gm()?.size;return{width(a,o,c){let l=gm();l?.size!==s&&(s=l?.size,r.clear());let u=c&24?o/bm:o,h=(c&2?"italic ":"")+(c&1?"bold ":"")+u+"px "+(c&4?t:e),d=r.get(h);d||r.set(h,d=new Map);let m=d.get(a);return m===void 0&&(h!==i&&(n.font=i=h),m=n.measureText(a).width,ww(l,h,a)&&(d.size>=Sw&&d.clear(),d.set(a,m))),m}}}var lu=new Map;function at(e="sans-serif",t="monospace"){let n=e+`
41
+ `+t,r=lu.get(n);return r||(r=_w(e,t)??xw,lu.set(n,r)),r}function du(){lu.clear()}var Rw=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]/u,Tw=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]+/gu,Mw={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},ec=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]/u;function nt(e){return Rw.test(e)?e.replace(Tw,t=>Mw[t]??""):e}function We(e){return nt(gt(e))}var uu=[];for(let e=0;e<100;e++)uu.push(e===0?"":e%10===0?"."+e/10:"."+(e<10?"0"+e:e));function f(e){let t=Math.round(e*100);if(t===0)return"0";if(t>0){if(t<1e11){let n=Math.floor(t/100);return n+uu[t-n*100]}}else if(t>-1e11){let n=-t,r=Math.floor(n/100);return"-"+r+uu[n-r*100]}return String(t/100)}function Ce(e,t,n,r,i){let s=e.lines;if(s.length===0)return"";let a=e.lineHeight,o=e.heights,c=e.size*.35,l=n-e.height/2,u=s.length===1&&s[0].length===1?s[0][0]:void 0;if(u&&u.icon===void 0&&u.math===void 0&&u.style===0)return`<text${r} x="${f(t)}" y="${f(l+a/2+c)}" text-anchor="middle">${nt(u.text)}</text>`;let h=jr(e),d=r,m;r=Xn(r,h);let p="",y="";for(let E=0;E<s.length;E++){let b=s[E],S=o?o[E]:a,x=l+S/2,I=x+c,L=!1;for(let O of b)(O.icon!==void 0||O.math)&&(L=!0);if(L){let O=t-e.widths[E]/2;for(let v of b){if(v.math){let G=`x="${f(O)}" y="${f(x-v.math.height/2)}" width="${f(v.math.width)}" height="${f(v.math.height)}"`;m??=Lw(d),y+=m.halo===void 0?Ow(v.math,G,e.size,m.attrs):`<rect ${G} rx="2" fill="${m.halo}"/>`}else if(v.icon!==void 0){let G=e.size*1.1,K=i?.(v.icon)??"";y+=`<svg class="pele-icon" data-icon="${We(v.icon)}" x="${f(O)}" y="${f(x-G/2)}" width="${f(G)}" height="${f(G)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${K}</svg>`}else v.text!==""&&(p+=`<tspan x="${f(O)}" y="${f(I)}" text-anchor="start"${wr(v.style&~h)}>${nt(v.text)}</tspan>`);O+=v.width}}else{for(let O=0;O<b.length;O++){let v=b[O],G=O===0?` x="${f(t)}" y="${f(I)}"`:"";p+=`<tspan${G}${wr(v.style&~h)}>${nt(v.text)}</tspan>`}b.length===0&&(p+=`<tspan x="${f(t)}" y="${f(I)}"> </tspan>`)}l+=S}return`<text${r} text-anchor="middle" xml:space="preserve">${p}</text>${y}`}var Cw=/ fill="([^"]*)"/,Nw=/ stroke="([^"]*)"/,Iw=/ style="([^"]*)"/,kw=/(?:^|;)\s*fill:([^;]*)/,$w=/(?:^|;)\s*opacity:([^;]*)/;function Lw(e){let t=Iw.exec(e)?.[1]??"",n=(kw.exec(t)?.[1]??Cw.exec(e)?.[1]??"").trim();if(n==="none")return{attrs:"",halo:Nw.exec(e)?.[1]??"none"};let r=$w.exec(t)?.[1].trim();return{attrs:(n===""?"":` color="${n}"`)+(r?` opacity="${r}"`:"")}}function Ow(e,t,n,r){return"svg"in e?`<svg class="pele-math" ${t} overflow="visible"${r}>${e.svg}</svg>`:`<foreignObject class="pele-math" ${t} overflow="visible"${r}><div xmlns="http://www.w3.org/1999/xhtml" style="display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:${f(n)}px;line-height:normal;white-space:nowrap">${e.html}</div></foreignObject>`}var ym=' font-weight="var(--_w)"',Em=' font-style="italic"',Dw=' text-decoration="underline"',xm=' font-family="var(--_fm)"',vw=' baseline-shift="sub" font-size="smaller"',Pw=' baseline-shift="super" font-size="smaller"';function wr(e){return(e&1?ym:"")+(e&2?Em:"")+(e&4?xm:"")+(e&32?Dw:"")+(e&8?vw:e&16?Pw:"")}function jr(e){let t=7,n=!1;for(let r of e.lines)for(let i of r)i.icon!==void 0||i.text===""||(t&=i.style,n=!0);return n?t:0}function Xn(e,t){return e+(t&1&&!e.includes(' font-weight="')?ym:"")+(t&2&&!e.includes(' font-style="')?Em:"")+(t&4&&!e.includes(' font-family="')?xm:"")}var Am=new Set("black blue blueviolet brown crimson darkblue darkcyan darkgreen darkmagenta darkolivegreen darkorchid darkred darkslateblue darkslategray darkviolet dimgray firebrick forestgreen green indigo maroon mediumblue mediumslateblue mediumvioletred midnightblue navy olive purple rebeccapurple royalblue saddlebrown seagreen sienna slateblue steelblue teal".split(" ")),Sm=new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque blanchedalmond burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk cyan darkgoldenrod darkgray darkkhaki darkorange darksalmon darkseagreen darkturquoise deeppink deepskyblue dodgerblue floralwhite fuchsia gainsboro ghostwhite gold goldenrod gray greenyellow honeydew hotpink indianred ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightpink lightsalmon lightseagreen lightskyblue lightslategray lightsteelblue lightyellow lime limegreen linen magenta mediumaquamarine mediumorchid mediumpurple mediumseagreen mediumspringgreen mediumturquoise mintcream mistyrose moccasin navajowhite oldlace olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue red rosybrown salmon sandybrown seashell silver skyblue slategray snow springgreen tan thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen".split(" ")),tc="var(--pele-fg-on-light,#1f1f1f)",nc="var(--pele-fg-on-dark,#fff)",hu=/[";]fill:([^;"]*)/,Fw=/[";](?:fill-)?opacity:([^;"]*)/g,wm=/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i,Bw=/^(rgba?|hsla?)\(([^()]*)\)$/i,_m=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i,fu=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,pu=(e,t,n)=>.2126*fu(e)+.7152*fu(t)+.0722*fu(n),Ww=e=>Math.min(Math.max(e,0),1),Uw=Math.sqrt(1.05*(pu(31/255,31/255,31/255)+.05))-.05;function To(e,t){let n=_m.exec(e);return!n||n[1]&&n[1]!=="%"?NaN:Ww(parseFloat(e)/(n[1]?100:t))}function Gw(e){let t=_m.exec(e);if(!t||t[1]==="%")return NaN;let n=t[1]?.toLowerCase(),r=parseFloat(e);return n==="turn"?r*360:n==="rad"?r*180/Math.PI:n==="grad"?r*.9:r}function Yw(e,t){let n=e.includes(","),[r,i,s]=n?[e]:e.split("/");if(s!==void 0)return;let a=r.trim().split(n?/\s*,\s*/:/\s+/);if(n?a.length<3||a.length>4:a.length!==3)return;if(i!==void 0&&a.push(i.trim()),!n)return a.map(c=>c==="none"?"0":c);let o=a.slice(t?1:0,3).filter(c=>c.endsWith("%")).length;return o===(t?2:3)||!t&&o===0?a:void 0}function Rm(e){let t=e.trim().toLowerCase(),n=t.replace("grey","gray");return wm.test(t)||Am.has(n)||Sm.has(n)||t==="transparent"||t==="currentcolor"}function Tm(e){let t=e.trim().toLowerCase(),n=t.replace("grey","gray");if(Am.has(n))return[0,1];if(Sm.has(n))return[1,1];if(wm.test(t)){let l=t.length<6?t.slice(1).replace(/./g,"$&$&"):t.slice(1),u=h=>parseInt(l.slice(2*h,2*h+2),16)/255;return[pu(u(0),u(1),u(2)),l.length===8?u(3):1]}let r=Bw.exec(t),i=r?.[1].startsWith("hsl")??!1,s=r&&Yw(r[2],i);if(!s)return;let a=s.length===4?To(s[3],1):1,o;if(!i)o=s.slice(0,3).map(l=>To(l,255));else{let l=(Gw(s[0])%360+360)%360/30,u=To(s[1],100),h=To(s[2],100),d=u*Math.min(h,1-h);o=[0,8,4].map(m=>{let p=(m+l)%12;return h-d*Math.max(-1,Math.min(p-3,9-p,1))})}let c=pu(o[0],o[1],o[2]);return Number.isNaN(c+a)?void 0:[c,a]}function Mm(e){let t=1;for(let[,n]of e.matchAll(Fw))t*=To(n.trim(),1);return t}var Ro=new Map;function lr(e,t=""){let n=`${e}\0${t}`;if(Ro.has(n))return Ro.get(n);Ro.size>1e3&&Ro.clear();let r=Hw(e,t);return Ro.set(n,r),r}function Hw(e,t){let n=hu.exec(e),r=n&&!hu.test(t)?Tm(n[1]):void 0;if(r&&r[1]*Mm(e)>=.5)return r[0]>Uw?tc:nc}function Tn(e){let t=hu.exec(e)?.[1].trim().toLowerCase();if(!t||t==="none"||t==="transparent")return!1;let n=Mm(e);return(Tm(t)?.[1]??1)*(Number.isNaN(n)?1:n)>0}function Dt(e,t){let n=lr(e.shape,e.text)??t;return n?` fill="${n}"`:""}var Kw={pie:{prefix:"pie",first:1},gitGraph:{prefix:"git",first:0},timeline:{prefix:"cScale",first:0},radar:{prefix:"cScale",first:0},treemap:{prefix:"cScale",first:0},mindmap:{prefix:"cScale",first:1},venn:{prefix:"venn",first:1,repeat:!0}},Mo=8,zw=/^[\w\s#%.,+\-/()]{1,200}$/,Vw=/([\w-]*)\s*\(/g,jw=/var\(\s*([\w-]*)/gi,Xw=new Set(["rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color","color-mix","light-dark","var"]),Cm=e=>Vr(e)?e:{};function qw(e){if(typeof e!="string")return;let t=e.trim();if(!zw.test(t))return;if(!t.includes("("))return Rm(t)?t:void 0;let n=0;for(let r of t)if(r==="(")n++;else if(r===")"&&--n<0)return;if(n===0){for(let[,r]of t.matchAll(Vw))if(!Xw.has(r.toLowerCase()))return;for(let[,r]of t.matchAll(jw))if(!r.startsWith("--pele-"))return;return t}}function Qw(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let s=e[i];s==="("?n++:s===")"?n--:s===","&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t.map(i=>i.trim())}function Zw(e,t){if(e==="xychart"){let i=Cm(t.xyChart).plotColorPalette;return typeof i=="string"?{list:Qw(i),repeat:!0}:void 0}let n=Kw[e];if(n===void 0)return;let r=[];for(let i=0;i<Mo;i++)r.push(t[n.prefix+(n.first+i)]);return n.repeat&&(r=r.filter(i=>i!=null&&i!=="")),{list:r,repeat:n.repeat===!0}}var mu={style:"",inks:[]};function Nm(e,t){let n=Zw(e,Cm(t.themeVariables));if(n===void 0||n.list.length===0)return mu;let{list:r,repeat:i}=n,s="",a=[];for(let o=0;o<Mo&&!(!i&&o>=r.length);o++){let c=qw(r[o%r.length]);c!==void 0&&(s+=`;--pele-series-${o+1}:${c}`,a[o]=lr(`;fill:${c}`))}return s===""?mu:{style:nt(s),inks:a}}var Co=mu;function Im(e,t){let n=Co;Co=e;try{return t()}finally{Co=n}}var km=()=>Co.style;function us(e){let t=Co.inks[(e%Mo+Mo)%Mo];return t?` fill="${t}"`:""}function Us(e){return e.ownerDocument?.defaultView??globalThis}function gu(e,t){let n=e.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0);return n>0?n:0}function Jw(e,t,n,r,i){let s=t.width/n,a=t.height/n,o=(c,l,u)=>l>=u?Math.min(Math.max(c,u-l),0):Math.min(Math.max(c,0),u-l);return{x:o(r,s,e.width),y:o(i,a,e.height),width:s,height:a}}var Ni=1.25,rc=48,e_=4,t_="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_b:var(--pele-border,#8a8a8a);position:absolute;top:var(--pele-zoom-top,8px);right:var(--pele-zoom-right,8px);bottom:var(--pele-zoom-bottom,auto);left:var(--pele-zoom-left,auto);display:flex;flex-direction:column;gap:2px;padding:2px;width:auto;max-width:none;border:1px solid var(--_b);border-radius:var(--pele-radius,4px);background:var(--_bg);color:var(--_fg);line-height:0",n_="appearance:none;display:grid;place-items:center;width:24px;height:24px;margin:0;padding:0;border:0;border-radius:calc(var(--pele-radius,4px) - 1px);background:transparent;color:inherit;font:inherit;cursor:var(--pele-zoom-cursor,pointer)",r_={zoomIn:"M5 12h14M12 5v14",zoomOut:"M5 12h14",reset:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8M3 3v5h5"},s_={zoomIn:"Zoom in",zoomOut:"Zoom out",reset:"Reset zoom"};function i_(e,t={}){return bu(e,t,!0)}function bu(e,t,n){let r=null,i={width:0,height:0},s={width:0,height:0},a={width:0,height:0},o=!1,c="",l={width:"",height:"",maxWidth:"",margin:"",display:""},u=null,h=0,d=0,m=0,p=0,y=()=>Us(e),E=()=>i.width>0&&s.width>0?s.width/i.width:1,b=()=>Math.max(E(),t.maxScale??3),S=()=>r!==null&&i.width>0&&(t.always===!0||E()<.999),x=()=>{if(!r||h!==0)return;let ce=r.getBoundingClientRect();s={width:ce.width,height:ce.height},a={width:Math.max(s.width,e.clientWidth),height:Math.max(s.height,e.clientHeight)},o=a.width>s.width+1||a.height>s.height+1,o||(a=s);let he=y().getComputedStyle(e);c=["Top","Right","Bottom","Left"].map(V=>`${-(parseFloat(he.getPropertyValue(`padding-${V.toLowerCase()}`))||0)}px`).join(" ")},I,L={},O=!1,v=()=>{if(t.controls===!1)return;let ce=S();if(!I){if(!ce)return;let V=e.ownerDocument;I=V.createElement("div"),I.className="pele pele-zoom",I.setAttribute("style",t_);let X={zoomIn:()=>H((h||E())*Ni*Ni),zoomOut:()=>H((h||E())/(Ni*Ni)),reset:()=>C()};for(let le of["zoomIn","zoomOut","reset"]){let de=V.createElement("button"),Ae=t.labels?.[le]??s_[le];de.type="button",de.className=`pele-zoom-${le==="zoomIn"?"in":le==="zoomOut"?"out":"reset"}`,de.setAttribute("style",n_),de.setAttribute("aria-label",Ae),de.title=Ae,de.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${r_[le]}"/></svg>`,de.addEventListener("click",X[le]),L[le]=de,I.append(de)}}ce&&!O&&y().getComputedStyle(e).position==="static"&&(e.style.position="relative",O=!0),ce&&I.parentNode!==e&&e.append(I),I.hidden=!ce,I.style.display=ce?"flex":"none";let he=(V,X)=>{V&&(V.disabled=X,V.style.opacity=X?"0.35":"",V.style.cursor=X?"default":"var(--pele-zoom-cursor,pointer)")};he(L.zoomIn,(h||E())>=b()*.999),he(L.zoomOut,h===0),L.reset&&(L.reset.style.display=h===0?"none":"grid")},G=ce=>I!==void 0&&ce.target instanceof y().Node&&I.contains(ce.target),K=()=>{r&&(oe(),r.style.width=l.width,r.style.height=l.height,r.style.maxWidth=l.maxWidth,r.style.margin=l.margin,r.style.display=l.display)},C=()=>{r&&(K(),h=0,r.setAttribute("viewBox",`0 0 ${i.width} ${i.height}`),r.style.cursor="",r.style.userSelect="",x(),r.style.touchAction=S()?"pan-y":"",S()?r.setAttribute("tabindex","0"):r.removeAttribute("tabindex"),ue(S()),v(),Z())},Z=()=>{if(!r||!I||I.hidden)return;let ce=I.getBoundingClientRect(),he=[...r.querySelectorAll("text")].some(Te=>{let Me=Te.getBoundingClientRect();return Me.right>ce.left&&Me.left<ce.right&&Me.bottom>ce.top&&Me.top<ce.bottom}),V=r.getBoundingClientRect(),X=ce.left-e_;if(!he||V.right-X>=V.width/2)return;let le=e.getBoundingClientRect(),de=e.offsetWidth>0?le.width/e.offsetWidth:1,Ae=parseFloat(y().getComputedStyle(e).paddingRight)||0,we=le.left+(e.clientLeft+e.clientWidth-Ae)*de,Ee=[r.style.maxWidth,r.style.marginRight];r.style.maxWidth=`${(X-V.left)/de}px`,r.style.marginRight=`${Math.max(we-X,0)/de}px`,u={before:Ee,after:[r.style.maxWidth,r.style.marginRight]},r.getBoundingClientRect().right>X+1&&oe(),x()},oe=()=>{!r||!u||(r.style.maxWidth===u.after[0]&&(r.style.maxWidth=u.before[0]),r.style.marginRight===u.after[1]&&(r.style.marginRight=u.before[1]),u=null)},H=(ce,he,V)=>{if(!r||(h===0&&x(),!S()))return;let X=h||E(),le=Math.min(Math.max(ce,E()),b());if(le<=E()*1.001){C();return}let de=r.getBoundingClientRect(),Ae=he??de.left+de.width/2,we=V??de.top+de.height/2,Ee=(h?d:0)+(Ae-de.left)/X,Te=(h?m:0)+(we-de.top)/X;h=le;let Me=de;o&&(r.style.maxWidth="none",r.style.margin=c,r.style.display="block",r.style.width=`${a.width}px`,r.style.height=`${a.height}px`,Me=r.getBoundingClientRect()),z(Ee-(Ae-Me.left)/h,Te-(we-Me.top)/h),r.style.cursor="grab",r.style.userSelect="none",r.style.touchAction="none",v()},z=(ce,he)=>{if(!r)return;let V=Jw(i,a,h,ce,he);d=V.x,m=V.y,r.setAttribute("viewBox",`${d} ${m} ${V.width} ${V.height}`)},M=(ce,he)=>{h!==0&&z(d-ce/h,m-he/h)},T=()=>{$();let ce=e.clientWidth+e.clientHeight;ce!==p&&(p=ce,C())},R,_,$=()=>{if(!n)return;let ce=y();ce!==_&&(R?.disconnect(),_=ce,R=ce.ResizeObserver?new ce.ResizeObserver(T):void 0,R?.observe(e))},g=()=>{$(),h!==0?K():oe();let ce=e.firstElementChild;if(r=ce&&ce.localName==="svg"?ce:null,h=0,!r){I?.remove(),ue(!1);return}i={width:Number(r.getAttribute("width"))||0,height:Number(r.getAttribute("height"))||0},l={width:r.style.width,height:r.style.height,maxWidth:r.style.maxWidth,margin:r.style.margin,display:r.style.display},C()},N=new Map,w=!1,A=0,D=0,U=()=>{let[ce,he]=[...N.values()];return{distance:Math.hypot(ce.x-he.x,ce.y-he.y),x:(ce.x+he.x)/2,y:(ce.y+he.y)/2}},B=()=>{w=!1},F=ce=>{!S()||G(ce)||ce.pointerType==="mouse"&&ce.button!==0||(N.set(ce.pointerId,{x:ce.clientX,y:ce.clientY}),A=0,N.size===2&&(D=U().distance),(N.size===2||h!==0)&&(e.setPointerCapture?.(ce.pointerId),r&&(r.style.cursor="grabbing")))},W=ce=>{let he=N.get(ce.pointerId);if(he){if(N.size===2){let V=U();N.set(ce.pointerId,{x:ce.clientX,y:ce.clientY});let X=U();D>0&&X.distance>0&&H((h||E())*(X.distance/V.distance),X.x,X.y),M(X.x-V.x,X.y-V.y),w=!0;return}N.set(ce.pointerId,{x:ce.clientX,y:ce.clientY}),h!==0&&(A+=Math.abs(ce.clientX-he.x)+Math.abs(ce.clientY-he.y),A>4&&(w=!0),M(ce.clientX-he.x,ce.clientY-he.y))}},j=ce=>{N.delete(ce.pointerId)&&(D=0,N.size===0&&r&&h!==0&&(r.style.cursor="grab"))},Q=ce=>{!w||ce.detail===0||(w=!1,ce.preventDefault(),ce.stopPropagation())},Y=ce=>{if(!(ce.ctrlKey||ce.metaKey)||!S())return;ce.preventDefault(),h===0&&x();let he=Math.min(Math.max(-ce.deltaY,-24),24);H((h||E())*2**(he*.02),ce.clientX,ce.clientY)},ne=ce=>{!S()||G(ce)||(ce.preventDefault(),h!==0?C():H(Math.max(1,E()*2),ce.clientX,ce.clientY))},q=ce=>{if(!S()||G(ce)||ce.ctrlKey||ce.metaKey||ce.altKey)return;let he=ce.key;if(he==="+"||he==="=")H((h||E())*Ni);else if(he==="-")H((h||E())/Ni);else{if(h===0)return;if(he==="0"||he==="Escape")C();else if(he==="ArrowLeft")M(rc,0);else if(he==="ArrowRight")M(-rc,0);else if(he==="ArrowUp")M(0,rc);else if(he==="ArrowDown")M(0,-rc);else return}ce.preventDefault()},k=ce=>{if(!r||ce.target!==r)return;let he=!0;try{he=r.matches(":focus-visible")}catch{}r.style.outline=he?"":"none"},J=0,te=ce=>{S()&&(ce.preventDefault(),h===0&&x(),J=h||E())},se=ce=>{if(J===0)return;ce.preventDefault();let{scale:he,clientX:V,clientY:X}=ce;H(J*he,V,X)},re=()=>{J=0},P=[["pointerdown",B,{capture:!0}],["pointerdown",F],["pointermove",W],["pointerup",j],["pointercancel",j],["click",Q,{capture:!0}],["dblclick",ne],["keydown",q],["focusin",k]];for(let[ce,he,V]of P)e.addEventListener(ce,he,V);let ee=[["wheel",Y,{passive:!1}],["gesturestart",te,{passive:!1}],["gesturechange",se,{passive:!1}],["gestureend",re,{passive:!1}]],ae=!1;function ue(ce){if(ce!==ae){ae=ce;for(let[he,V,X]of ee)ce?e.addEventListener(he,V,X):e.removeEventListener(he,V,X);ce||(J=0)}}return p=e.clientWidth+e.clientHeight,g(),{get scale(){return h||E()},get fit(){return E()},zoomBy(ce){H((h||E())*ce)},zoomTo(ce){H(ce)},reset:C,refresh:g,resized:T,destroy(){C(),oe(),r&&(r.style.touchAction="",r.removeAttribute("tabindex")),I?.remove(),O&&(e.style.position=""),R?.disconnect(),ue(!1);for(let[ce,he,V]of P)e.removeEventListener(ce,he,V)}}}function yu(e,t){let n=t?Us(t).getComputedStyle(t):e;return{family:n.getPropertyValue("--pele-font").trim()||e.fontFamily||void 0,mono:n.getPropertyValue("--pele-font-mono").trim()||void 0}}function o_(e){return[...new Set([e.ownerDocument?.fonts,globalThis.document?.fonts])].filter(n=>n!==void 0)}var Eu=new WeakMap;function a_(e){let t=Eu.get(e);return t||(t=e.ready.then(()=>{Eu.delete(e),du()}),Eu.set(e,t)),t}var xu=new WeakMap;function c_(e,t){Promise.all(e.map(a_)).then(()=>{let n=t.deref();n&&xu.get(n)?.()})}var sc=new WeakMap,l_=0,d_=Math.random().toString(36).slice(2,7),u_="position:relative;height:1.3em;margin-top:-1.3em;line-height:1.3;font-size:0.8em;color:var(--pele-error,#e45756);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;",f_="margin:0;font-size:0.8em;font-family:var(--pele-font-mono,monospace);color:var(--pele-error,#e45756);white-space:pre-wrap;";function h_(e){return e instanceof Error?e.message:String(e)}function p_(e){let t=e.split(`
42
+ `).filter(n=>n.trim()!=="");return t.length>1?`${t[0]} ${t[t.length-1]}`:t[0]??""}function $m(e,t,n,r={}){sc.get(t)?.destroy();let i=n,s=r,a,o,c=!1,l,u,h,d=`pele-${d_}-${++l_}`,m={},p,y=-1,E=!1,b=!1,S=!1,x=(A,D)=>{let{onRender:U,onError:B,sanitize:F,...W}=s,j={...W,idPrefix:W.idPrefix??d,fontFamily:W.fontFamily??m.family,fontFamilyMono:W.fontFamilyMono??m.mono,maxWidth:void 0};D&&(u=e.render(a,j),p=void 0);let Q=s.maxWidth??gu(t,A);return y=Q,Q>0&&Q<u.width&&(p??=e.render(a,{...j,maxWidth:1}).svg!==u.svg,p)?e.render(a,{...j,maxWidth:Q}):u},I=A=>{s.sanitize?t.replaceChildren(s.sanitize(A)):t.innerHTML=A},L,O=()=>{let A=h?t.firstElementChild:null;if(A?.style&&(A.style.opacity=l===void 0?"":"0.4"),l===void 0){L?.remove(),L=void 0;return}let D=t.ownerDocument;if(!D)return;L??=D.createElement("div"),L.className="pele pele-error";let U=h_(l);A?(L.textContent=p_(U),L.title=U,L.setAttribute("style",u_),L.parentNode!==t&&t.append(L)):(L.textContent=U,L.removeAttribute("title"),L.setAttribute("style",f_),t.replaceChildren(L))},v=A=>{l=A,O(),s.onError?.(A)},G=()=>{if(b||S)return;let A=o_(t).filter(D=>D.status==="loading");A.length!==0&&(b=!0,c_(A,new WeakRef(w)))},K=()=>{b=!1,E=!0,T()},C=(A,D=!A)=>{let U=Us(t).getComputedStyle(t),B=t.firstElementChild??null,F={fonts:m,natural:u,adapts:p,drawnFor:y,stale:E},W;try{if(A&&(m=yu(U,B),E=t.isConnected===!1),W=x(U,A),D&&W.svg===h?.svg){A&&(o=a),c&&l!==void 0&&(l=void 0,O());return}I(W.svg)}catch(j){throw{fonts:m,natural:u,adapts:p,drawnFor:y,stale:E}=F,j}if(A&&(o=a),A&&!B&&t.firstElementChild){let j=yu(U,t.firstElementChild);if(j.family!==m.family||j.mono!==m.mono){let Q={fonts:m,natural:u,adapts:p,drawnFor:y};m=j;try{let Y=x(U,!0);I(Y.svg),W=Y}catch{({fonts:m,natural:u,adapts:p,drawnFor:y}=Q)}}}h=W,c&&(l=void 0),O(),Z?.refresh(),G(),s.onRender?.(W)},Z,oe=!1,H=()=>{let A=s.zoom??"auto";A!==oe&&(Z?.destroy(),oe=A,Z=A===!1?void 0:bu(t,typeof A=="object"?A:{always:A===!0},!1))},z=()=>t.isConnected===!1||!(t.clientWidth>0),M=()=>t.isConnected!==!1&&!(t.clientWidth>0),T=()=>{if(S||(N(),!a||z()))return;let A=Us(t).getComputedStyle(t),D=yu(A,t.firstElementChild??null);try{if(E||D.family!==m.family||D.mono!==m.mono)C(!0,!0);else if(p!==!1&&s.maxWidth===void 0){let U=gu(t,A);U!==y&&U!==h?.width&&C(!1)}}catch(U){E=!1,c&&(l=U),a!==o&&(a=o,c=!1),O(),s.onError?.(U)}Z?.resized(),G()},R,_,$,g=()=>{$!==void 0&&R?.cancelAnimationFrame($),$=void 0},N=()=>{let A=Us(t);A!==R&&(_?.disconnect(),g(),R=A,_=A.ResizeObserver?new A.ResizeObserver(()=>{if($===void 0){if(!A.requestAnimationFrame)return T();$=A.requestAnimationFrame(()=>{$=void 0,T()})}}):void 0,_?.observe(t))},w={get result(){return h},get source(){return i},get error(){return l},get zoom(){return Z},update(A,D=s){let U=!c||A!==i||D.limit!==s.limit||D.maxEdges!==s.maxEdges||D.config!==s.config;i=A,s=D;let B=a;if(U)try{B=e.parse(A,D)}catch(W){c=!1,v(W),H();return}let F=h;if(a=B,c=!0,M()){E=!0,H();return}try{C(!0)}catch(W){if(h!==F)throw H(),W;a=o,c=!1,v(W)}H()},refresh:T,destroy(){S=!0,_?.disconnect(),_=void 0,g(),R=void 0,Z?.destroy(),xu.delete(w),sc.get(t)===w&&sc.delete(t)}};xu.set(w,K);try{a=e.parse(n,r),c=!0,C(!0)}catch(A){if(h)throw A;a=o,c=!1,v(A)}return H(),N(),sc.set(t,w),w}var ic=new Map;function Lm(...e){for(let t of e)ic.set(t.type,t)}function sO(e){return ic.has(e)}var m_=5e4,g_=4e6,b_=5e3;function Om(e){try{return e()}catch(t){throw t instanceof RangeError?new qe("Diagram is nested too deeply.","limit"):t}}function Dm(e,t){try{return t()}catch(n){if(n instanceof RangeError)throw new qe("Diagram is nested too deeply.","limit",e);if(n instanceof qe){n.type??=e.type,n.mermaidType??=e.mermaidType;let r=Eo(n.message);r!==n.message&&(n.stack=n.stack?.replace(n.message,()=>r),n.message=r),n.snippet=Eo(n.snippet)}throw n}}var vm=new WeakMap;function Pm(e,t=m_,n=b_,r){if(e.length>t)throw new qe(`Diagram source is longer than the limit of ${t} characters.`,"limit");let i=Ja(e),s=Jd(i.text);if(s===null)throw new qe("No diagram type detected for the given text.","unsupported-diagram");let a=ic.get(s.type);if(a===void 0)throw new qe(`Diagram type "${s.type}" is not supported yet.`,"unsupported-diagram",s);let o=r?{...r,...i.config}:i.config,c=a.keepComments===!0,l=cu(c?i.withComments:i.text)+`
43
+ `,u=Dm(s,()=>Qp({parsed:l,find:y_(e,c)},()=>a.parse(l,o,i.title,i.lineOffset,{maxEdges:n})));return{...s,diagram:a,model:u,config:o}}function y_(e,t){let n,r="";return i=>{if(n===void 0){n=[];let s=Ja(e,n);cu(t?s.withComments:ou(s.withComments,n),n),r=au(e)+`
44
+ `}return[r,Kr(n,i)]}}function E_(e,t){if(typeof e=="string")return Pm(e,t.limit,t.maxEdges,t.config);let n=vm.get(e);if(n===void 0)throw new TypeError("render() takes diagram text or a model that parse() returned.");return n}function x_(e){return Jd(Ja(e).text)?.type??null}function iO(e){try{let t=x_(e);return t!==null&&ic.has(t)}catch{return!1}}function A_(e,t={}){return Om(()=>{let n=Pm(e,t.limit,t.maxEdges,t.config),r=n.model;return Object.defineProperty(r,"mermaidType",{value:n.mermaidType,enumerable:!0}),vm.set(r,n),r})}function S_(e,t={}){return Om(()=>{let{type:n,mermaidType:r,diagram:i,model:s,config:a}=E_(e,t),o=a[i.section??n],c=typeof o=="object"&&o!==null&&!Array.isArray(o)&&o.useMaxWidth===!1,l=t.responsive??!c,u=t.icons,h=u&&(p=>u(gt(p))),d=Dm({type:n,mermaidType:r},()=>Im(Nm(n,a),()=>rm(i.math?t.math:void 0,()=>tm(h,()=>i.render(s,a,{...t,responsive:l,icons:h}))))),m=t.outputLimit??g_;if(d.svg.length>m)throw new qe(`Diagram output is longer than the limit of ${m} characters.`,"limit",{type:n,mermaidType:r});for(let p of d.links)p.id=gt(p.id);return{type:n,mermaidType:r,...d}})}function oO(e,t,n={}){return $m({parse:A_,render:S_},e,t,n)}var No="about:blank",w_=/^([^\w]*)(javascript|data|vbscript)/im,Fm=/&#(\w+)(^\w|;)?/g,Bm=/&(newline|tab);/gi,Au=/[\u0000-\u001F\u007F-\u009F -‍\uD800-\uDFFF\uFFFE\uFFFF]/gimu,__=/^.+(:|&colon;)/gim,Wm=/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;function Um(e){try{return decodeURIComponent(e)}catch{return e}}function Su(e,t){let n=t?Um(e.trim()):e.trim(),r,i=0;do{if(++i>32)return;n=n.replace(Au,"").replace(Fm,(s,a)=>String.fromCharCode(a)).replace(Bm,"").replace(Au,"").replace(Wm,"").trim(),t&&(n=Um(n)),r=n.match(Au)||n.match(Fm)||n.match(Bm)||n.match(Wm)}while(r&&r.length>0);return n}function Ii(e){if(!e)return No;let t=Su(e,!0),n=Su(e,!1);if(!t||!n)return No;if(t[0]==="."||t[0]==="/")return n;let r=t.trimStart().match(__);if(!r)return n;let i=r[0].toLowerCase().trim();if(w_.test(i))return No;let s=n.trimStart().replace(/\\/g,"/");if(i==="mailto:"||i.includes("://"))return s;if(i==="http:"||i==="https:"){let a;try{a=new URL(s)}catch{return No}return a.protocol=a.protocol.toLowerCase(),a.hostname=a.hostname.toLowerCase(),a.toString()}return s}function qn(e){return Ii(gt(e))}var R_=["http","https","mailto","tel"],T_=["http","https"],M_=/^([a-z][a-z0-9+.-]*):/i,C_=/^[\\/]{2}/;function Gm(e,t){if(C_.test(e))return!1;let n=M_.exec(e);return!n||t.includes(n[1].toLowerCase())}function Ym(e,t){let n=Su(e,!0);return n!==void 0&&Gm(e,t)&&Gm(n,t)?e:void 0}function Io(e,t){return t.links===!1?void 0:Ym(e,t.linkSchemes??R_)}function Hm(e,t){return t.images===!1?void 0:Ym(e,t.imageSchemes??T_)}var N_=new RegExp(ec.source,"gu");function ki(e,t){let n=Ii(e);if(n===No||Io(n,t)===void 0)return!1;let r=e.replace(N_,"").replace(/[\t\n\r]/g,"").replace(/^[\x00-\x20]+/,"");return Io(r,t)!==void 0}function Qn(e,t,n,r,i,s=""){let a=Io(t,i);return a===void 0?e:(r.push({id:n,href:a,internal:!1}),`<a href="${nt(a)}"${s}${Xr(i)}>${e}</a>`)}function Xr(e){let t=e.linkRel??"noopener";return t?` rel="${nt(t)}"`:""}var I_=[["rect","proc","process","rectangle","squareRect"],["rounded","event","roundedRect"],["stadium","terminal","pill"],["fr-rect","subprocess","subproc","framed-rectangle","subroutine"],["cyl","db","database","cylinder"],["datastore","data-store"],["folder","directory"],["bucket"],["console"],["browser"],["person"],["circle","circ"],["bang"],["cloud"],["diam","decision","diamond","question"],["hex","hexagon","prepare"],["lean-r","lean-right","in-out","lean_right"],["lean-l","lean-left","out-in","lean_left"],["trap-b","priority","trapezoid-bottom","trapezoid"],["trap-t","manual","trapezoid-top","inv-trapezoid","inv_trapezoid"],["dbl-circ","double-circle","doublecircle"],["text"],["notch-rect","card","notched-rectangle"],["lin-rect","lined-rectangle","lined-process","lin-proc","shaded-process"],["sm-circ","start","small-circle","stateStart"],["fr-circ","stop","framed-circle","stateEnd"],["fork","join","forkJoin"],["hourglass","collate"],["brace","comment","brace-l"],["brace-r"],["braces"],["bolt","com-link","lightning-bolt"],["doc","document"],["delay","half-rounded-rectangle"],["h-cyl","das","horizontal-cylinder"],["lin-cyl","disk","lined-cylinder"],["curv-trap","curved-trapezoid","display"],["div-rect","div-proc","divided-rectangle","divided-process"],["tri","extract","triangle"],["win-pane","internal-storage","window-pane"],["f-circ","junction","filled-circle"],["notch-pent","loop-limit","notched-pentagon"],["flip-tri","manual-file","flipped-triangle"],["sl-rect","manual-input","sloped-rectangle"],["docs","documents","st-doc","stacked-document"],["st-rect","procs","processes","stacked-rectangle"],["bow-rect","stored-data","bow-tie-rectangle"],["cross-circ","summary","crossed-circle"],["tag-doc","tagged-document"],["tag-rect","tagged-rectangle","tag-proc","tagged-process"],["flag","paper-tape"],["odd","rect_left_inv_arrow"],["lin-doc","lined-document"]],k_=["state","choice","note","composite","rectWithTitle","labelRect","block_arrow","collapsedGroup","iconSquare","iconCircle","icon","iconRounded","imageSquare","anchor","kanbanItem","mindmapCircle","defaultMindmapNode","classBox","erBox","requirementBox","usecaseActor","usecaseActorHollow","usecaseActorAwesome","usecaseActorIcon","usecaseBusiness","usecaseEllipse","usecaseJsonTable"],$_=new Map([["square","rect"],["round","rounded"],["ellipse","ellipse"],["hexagon","hex"],["diamond","diam"]]),oc=new Map;for(let e of I_)for(let t of e)oc.set(t,e[0]);for(let e of k_)oc.set(e,e);function ac(e){return oc.has(e)}function cc(e){return e===void 0?"rect":$_.get(e)??oc.get(e)??"rect"}var L_=new Map([["task","roundedRect"],["tool","subroutine"],["input","lean-right"],["decision","diamond"],["refdoc","lin-doc"],["action","hexagon"],["round","rect"]]),O_=new Set(["doc","stadium","terminal","circle","trapezoid","inv_trapezoid","inv-trapezoid","doublecircle","double-circle","typeDeclaration","procs","lean_left","lean-left","in-out","cylinder","ellipse","odd","tag-rect","tagged-rectangle","delay","half-rounded-rectangle","lin-rect","lined-rectangle","win-pane","window-pane","curv-trap","curved-trapezoid"]),D_=new Set(["roundedRect","subroutine","subprocess","subproc","framed-rectangle","lean-right","diamond","lin-doc","lined-document","hexagon","hex","connector","collapsedGroup"]),ko="roundedRect";function $i(e){return e&&(L_.get(e)??e)}function Km(e){return ac(e)||e==="constructor"}function zm(e,t){for(let n of e)n.isGroup||((!n.shape||n.shape==="squareRect"||n.shape==="rect")&&(n.shape=ko),O_.has(n.shape)?(t.emitError("SHAPE_REMOVED",`shape "${n.shape}" was removed in v0.8.1, using "${ko}"`,{nodeId:n.id}),n.shape=ko):D_.has(n.shape)||(t.emitWarning("SHAPE_UNSUPPORTED",`shape "${n.shape}" is not supported, using "${ko}"`,{nodeId:n.id}),n.shape=ko))}var v_=new Set(["shape","view","icon","img","form","pos","w","h","class","style","labelType"]),P_=new Set(["subroutine","subprocess","subproc","framed-rectangle","tool"]);function F_(e){return P_.has(e.type)}function wu(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function Vm(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function _u(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function B_(e){let t=i=>Array.isArray(i)?[]:_u(i)?{}:i,n=t(e),r=[[e,n]];for(;r.length>0;){let[i,s]=r.pop();if(Array.isArray(i))for(let a of i){let o=t(a);s.push(o),typeof a=="object"&&a!==null&&r.push([a,o])}else if(_u(i))for(let a of Object.keys(i)){if(a==="__proto__"||a==="constructor"||a==="prototype")continue;let o=i[a],c=t(o);s[a]=c,typeof o=="object"&&o!==null&&r.push([o,c])}}return n}function lc(e,t){return Object.assign(e??{},t)}var W_=/:\s*[>|][\d+-]*\s*$/,U_=/,([\t ]*)$/;function G_(e){let t=!1,n=!1,r=0,i,s=[];for(let a of e.split(`
45
+ `)){if(i!==void 0){let u=a.length-a.trimStart().length;if(a.trim()===""||u>i){s.push(a);continue}i=void 0}let o=-1;for(let u=0;u<a.length;u++){let h=a[u];if(n)h==="\\"?u++:h==='"'&&(n=!1);else if(t)h==="'"&&(t=!1);else if(h==='"')n=!0;else if(h==="'")t=!0;else if(h==="#"&&(u===0||a[u-1]===" "||a[u-1]===" ")){o=u;break}else h==="["||h==="{"?r++:(h==="]"||h==="}")&&(r=Math.max(0,r-1))}if(t||n||r>0){s.push(a);continue}let c=o>=0?a.slice(0,o):a,l=o>=0?a.slice(o):"";if(W_.test(c)){i=a.length-a.trimStart().length,s.push(a);continue}s.push(c.replace(U_,"$1")+l)}return s.join(`
46
+ `)}function Y_(e,t){if(e==="arrow_point"&&t==="normal")return"sequence";if(e==="arrow_cross"&&t==="normal")return"failure";if(e==="arrow_open"&&t==="dotted")return"reference"}function H_(e){let t=e.trim(),n=t.slice(0,-1),r="arrow_open";switch(t.slice(-1)){case"x":r="arrow_cross";break;case">":r="arrow_point";break;case"-":case".":n=t;break}let i="normal",s=n.length-1,a=0;for(let o=0;o<n.length;o++)n[o]==="."&&a++;return a>0&&(i="dotted",s=a),{type:r,stroke:i,length:s}}function jm(e){if(!e)return;let t={},n=!1;for(let r of Object.keys(e))v_.has(r)||(t[r]=e[r],n=!0);return n?t:void 0}var dc=class{type="agentflow";direction;nodes=new Map;edges=[];subgraphs=[];connectors=new Map;classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;mappings=[];diagnostics=[];title;accTitle;accDescr;lineOffset;subgraphLookup=new Map;globalNodes=new Set;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;bareMappings=new Set;firstMapping=new Map;reported=new Map;options;constructor(t={}){this.options=t,this.lineOffset=t.lineOffset??0}metadata(t,n,r){let i=n.includes(`
47
+ `),s;try{s=cr(i?n+`
48
+ `:`{
49
+ `+n+`
50
+ }`)}catch(a){let o=i?G_(n):n,c;if(o!==n)try{c=cr(o+`
51
+ `)}catch{c=void 0}if(c===void 0){let{line:l,column:u}=this.errorAt(r),h=r?` (${l}:${u})`:"";throw new qe(`Metadata of "${t}" is not valid YAML. ${a.message}${h}`,"syntax",{type:"agentflow",line:l,column:u})}s=c}return B_(s??{})}errorAt(t){if(t===void 0)return{line:0,column:0};let n=this.options.source;if(n===void 0)return{line:t.first_line+this.lineOffset,column:t.first_column+1};let r=0;for(let a=1;a<t.first_line;a++)r=n.indexOf(`
52
+ `,r)+1;let{line:i,column:s}=ar(n,r+t.first_column);return{line:i,column:s}}shapeError(t,n){return new qe(t,"semantic",{type:"agentflow",...this.errorAt(n)})}addVertex(t,n,r,i,s,a,o={},c,l){if(!t||t.trim().length===0)return;let u,h,d;c!==void 0&&(u=this.metadata(t,c,l),_u(u)&&(h=u,typeof u.shape=="string"&&(d=u.shape,u.shape=$i(u.shape))));let m=this.subgraphLookup.get(t);if(m&&u){m.metadata=lc(m.metadata,u);return}let p=this.connectors.get(t);if(p&&u){p.metadata=lc(p.metadata,u);return}if(t==="connectors")return;let y=this.edgeById.get(t);if(y){h?.animate!==void 0&&(y.animate=h.animate),h?.animation!==void 0&&(y.animation=h.animation),h?.curve!==void 0&&(y.interpolate=h.curve),u&&(y.metadata=lc(y.metadata,u));return}let E=this.nodes.get(t);if(E===void 0&&(E={id:t,labelType:"text",styles:[],classes:[]},this.nodes.set(t,E)),n!==void 0?(E.labelType=n.type,E.text=Vm(n.text.trim())):E.text===void 0&&(E.text=t),r!==void 0&&(E.type=r),i!=null)for(let b of i)E.styles.push(b);if(s!=null)for(let b of s)E.classes.push(b);if(a!==void 0&&(E.dir=a),E.props===void 0?E.props=o:o!==void 0&&Object.assign(E.props,o),!!u&&(E.metadata=lc(E.metadata,u),h!==void 0)){if(h.shape){let b=d??h.shape;if(typeof b!="string")throw this.shapeError(`No such shape: ${JSON.stringify(b)}.`,l);if(b!==b.toLowerCase()||b.includes("_"))throw this.shapeError(`No such shape: ${b}. Shape names should be lowercase.`,l);let S=h.shape;if(!Km(S))throw this.shapeError(`No such shape: ${S}.`,l);E.type=S}h.label&&(E.text=String(h.label),E.labelType=wu(h.labelType))}}addSingleLink(t,n,r,i){let s={start:t,end:n,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},a=r?.text;a!==void 0&&(s.text=Vm(a.text.trim()),s.labelType=wu(a.type)),r!==void 0&&(s.type=r.type,s.stroke=r.stroke,s.length=r.length>10?10:r.length,r.edgeSemantic&&(s.edgeSemantic=r.edgeSemantic));let o=t+"\0"+n,c=this.pairCount.get(o)??0;i&&!this.edgeById.has(i)?(s.id=i,s.isUserDefinedId=!0):s.id=`L_${t}_${n}_${c===0?0:c+1}`;let l=this.options.maxEdges;if(l!==void 0&&this.edges.length>=l)throw new qe(`Edge limit exceeded. The limit is ${l}.`,"limit",{type:"agentflow"});this.edges.push(s),this.pairCount.set(o,c+1),this.edgeById.has(s.id)||this.edgeById.set(s.id,s)}addLink(t,n,r){let i=typeof r?.id=="string"?r.id.replace("@",""):void 0,s=t[t.length-1],a=n[0];for(let o of t)for(let c of n)this.addSingleLink(o,c,r,o===s&&c===a?i:void 0)}updateLinkInterpolate(t,n){for(let r of t)r==="default"?this.defaultInterpolate=n:this.edgeAt(r).interpolate=n}updateLink(t,n){for(let r of t){if(r==="default"){this.defaultEdgeStyle=n;continue}let i=this.edgeAt(r);i.style=n,n.length>0&&!n.some(s=>s?.startsWith("fill"))&&n.push("fill:none")}}edgeAt(t){let n=this.edges[Number(t)];if(n===void 0)throw new qe(`The index ${t} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length-1}. (Help: Ensure that the index is within the range of existing edges.)`,"semantic",{type:"agentflow"});return n}addClass(t,n){let r=n.join().replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let i of t.split(",")){let s=this.classes.get(i);s===void 0&&(s={id:i,styles:[],textStyles:[]},this.classes.set(i,s));for(let a of r)a.includes("color")&&s.textStyles.push(a.replace("fill","bgFill")),s.styles.push(a)}}setDirection(t){let n=t.trim();n.includes("<")&&(n="RL"),n.includes("^")&&(n="BT"),n.includes(">")&&(n="LR"),n.includes("v")&&(n="TB"),n==="TD"&&(n="TB"),this.direction=n}setClass(t,n){for(let r of t.split(","))this.nodes.get(r)?.classes.push(n),this.edgeById.get(r)?.classes.push(n),this.subgraphLookup.get(r)?.classes.push(n)}setTooltip(t,n){if(n!==void 0)for(let r of t.split(","))this.tooltips.set(r,n)}setLink(t,n,r){let i=n.trim();for(let s of t.split(",")){let a=this.nodes.get(s);a!==void 0&&(a.link=i?qn(i):void 0,a.linkTarget=r)}this.setClass(t,"clickable")}setClickEvent(t,n,r){this.setClass(t,"clickable")}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
53
+ `)}addSubGraph(t,n,r,i){let s=t?.text?.trim(),a=r?.text||"";t!==void 0&&t===r&&/\s/.test(a)&&(s=void 0);let o=new Set,c=[],l;for(let p of n)if(typeof p=="string")p.trim()!==""&&!o.has(p)&&(o.add(p),c.push(p));else if(Array.isArray(p))for(let y of p)y.trim()!==""&&!o.has(y)&&(o.add(y),c.push(y));else l=p.value;l??=this.options.inheritDir?this.direction??this.options.direction:void 0,s??="subGraph"+this.subCount,this.subCount++;let u=this.members,h=c.filter(p=>p!==s&&!this.globalNodes.has(p)&&!u.has(p));for(let p of h)u.add(p);let d=this.subgraphLookup.get(s);if(d){for(let p of h)d.nodes.push(p);return a.trim()&&(d.title=a.trim()),l&&(d.dir=l),s}let m={id:s,nodes:h,title:a.trim(),classes:[],dir:l,labelType:wu(r?.type),type:"flow"};return this.subgraphs.push(m),this.subgraphLookup.set(s,m),s}addGlobal(t){let n=!1,r=i=>{let s=i.trim();s!==""&&(this.globalNodes.add(s),this.members.delete(s)&&(n=!0))};for(let i of t)if(typeof i=="string")r(i);else if(Array.isArray(i))for(let s of i)r(s);if(n)for(let i of this.subgraphs)i.nodes=i.nodes.filter(s=>!this.globalNodes.has(s))}addConnector(t,n){let r=t?.text?.trim();if(!r)return"";let i=n?.text?.trim()??"",s=this.connectors.get(r);if(s)i.length>0&&(s.text=i);else{let a={id:r,labelType:"text",styles:[],classes:[],isConnector:!0,text:i.length>0?i:r};this.connectors.set(r,a),this.nodes.set(r,a)}return r}destructLink(t,n){let r=H_(t);return n&&(n.includes(".")?"dotted":"normal")!==r.stroke?{type:"INVALID",stroke:"INVALID"}:{...r,edgeSemantic:Y_(r.type,r.stroke)}}subgraph(t){return this.subgraphLookup.get(t)}vertexKind(t){if(F_(t))return"tool";let n=$i(t.type);return n==="hexagon"||n==="hex"?"action":n==="lean-right"||n==="lean_right"?"input":n==="lin-doc"||n==="lined-document"?"refdoc":n==="diamond"?"decision":"task"}semanticModel(){let t=[],n=[];for(let[a,o]of this.nodes){if(this.subgraphLookup.has(a))continue;let c=jm(o.metadata);if(o.isConnector){let h={id:a};o.text!==void 0&&o.text!==a&&(h.title=o.text),c&&(h.metadata=c),n.push(h);continue}let l={id:a};o.text!==void 0&&(l.label=o.text);let u=$i(o.type);u!==void 0&&(l.shape=u),l.vertexKind=this.vertexKind(o),c&&(l.metadata=c),t.push(l)}let r=this.edges.map(a=>{let o={start:a.start,end:a.end};return a.id!==void 0&&(o.id=a.id),a.text.length>0&&(o.label=a.text),a.type!==void 0&&(o.type=a.type),a.stroke!==void 0&&(o.stroke=a.stroke),a.edgeSemantic!==void 0&&(o.edgeSemantic=a.edgeSemantic),a.length!==void 0&&(o.length=a.length),a.metadata&&Object.keys(a.metadata).length>0&&(o.metadata={...a.metadata}),o}),i=this.subgraphs.map(a=>{let o={id:a.id,nodes:[...a.nodes],type:a.type,title:a.title};a.dir!==void 0&&(o.direction=a.dir);let c=jm(a.metadata);return c&&(o.metadata=c),o}),s={vertices:t,edges:r,subGraphs:i,connectors:n,diagnostics:this.diagnostics};return this.direction!==void 0&&(s.direction=this.direction),s}position(t){let n=t?.first_line??0,r=t?.first_column??0;return{startLine:n+this.lineOffset,startColumn:r,endLine:(t?.last_line??n)+this.lineOffset,endColumn:t?.last_column??r,startIndex:0,endIndex:0}}pushMapping(t,n,r){let i={id:t,type:n,position:r};return this.mappings.push(i),this.firstMapping.has(t)||this.firstMapping.set(t,i),i}addVertexMapping(t,n,r,i){if(!t)return;let s=this.pushMapping(t,"vertex",this.position(i));r==null&&this.bareMappings.add(s)}extendVertexMapping(t,n){if(!t||!n)return;let r=this.position(n);for(let i=this.mappings.length-1;i>=0;i--){let s=this.mappings[i];if(s.type!=="vertex"||s.id!==t)continue;this.bareMappings.delete(s)&&(s.type="attachment");let a=s.position;(r.endLine>a.endLine||r.endLine===a.endLine&&r.endColumn>a.endColumn)&&(a.endLine=r.endLine,a.endColumn=r.endColumn);return}this.pushMapping(t,"attachment",r)}addEdgeMapping(t,n,r,i){let s=Array.isArray(n)?n.filter(a=>typeof a=="string"&&a!==""):[];this.pushMapping(s.length>0?s.join(">"):"edge","edge",this.position(i))}blockMapping(t,n,r,i){if(!t)return;let s=this.position(r),a=i?this.position(i):s;this.pushMapping(t,n,{startLine:s.startLine,startColumn:s.startColumn,endLine:a.endLine,endColumn:a.endColumn,startIndex:0,endIndex:0})}addSubgraphMapping(t,n,r,i){let s=typeof t=="string"?t:t?.text;this.blockMapping(s??"","subgraph",r,i)}addConnectorMapping(t,n,r,i){this.blockMapping(t?.text?.trim()??"","connector",r,i)}emit(t,n,r,i){let s=i?.nodeId??i?.edgeId,a={id:t,severity:n,message:r};i?.nodeId?a.nodeId=i.nodeId:i?.edgeId&&(a.edgeId=i.edgeId);let o=s?this.firstMapping.get(s):void 0;o&&(a.position=o.position);let c=s??"",l=this.reported.get(c);if(l===void 0)this.reported.set(c,[a]);else{for(let u of l)if(u.id===t&&u.severity===n&&u.message===r&&u.nodeId===a.nodeId&&u.edgeId===a.edgeId)return;l.push(a)}this.diagnostics.push(a),this.options.log?.(n,`agentflow[${t}]: ${r}`)}emitWarning(t,n,r){this.emit(t,"warning",n,r)}emitError(t,n,r){this.emit(t,"error",n,r)}};var K_="4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 9 0 2 2 2 0 2 j 2 2a 2 3u 9 4d a 11 3 0 8 12 21 q 6 2 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 20 0 2 a 2g 1h 4 0 j 0 8 9 g 6 2 6 6 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 k 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 10 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 9 2 4 4 0 r 1 7 1 10 7 2 2 2 m 2 9 2 4 4 0 x 0 2 1 g 1 j 7 2 2 2 14 3 0 h 0 i 1 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 3 1 2 0 3 0 7 3 2 6 2 2 2 0 2 0 3 1 2 3 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2c d h7 3 g 2 p 6 22 m c 2 3 f h f h f c 2 2 g 1f 10 0 5 0 1w 2f 9 14 2 0 6 1x b s 1g t 3 4 c 17 m 6 1l m a 1g 2b 0 2m 1a i 6 1k t e 1 b 17 r z 16 2 b z 30 3 2 3 4 1 a 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 4 4 7 0 2 0 2 0 2 3 2 a 3 3 6 4 5 0 1h 1 22k 1a 2 1a 2 3o 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 29 0 d2 1 17 4 6 1 5 2d 7 2 2 2h 2 3 6 14 4 2l i q 1i f e9 52t 23 g5o 1g wc 1w 19 3 7g 4 f b 1 l 1a h o 9 1x 1e 8 3 2u 3 3 2 3 d a 26 9 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 f r b m q s 8 1a t 0 1d 14 o 2 2 7 l m 4 0 6 1b 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 42 y u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2",z_;function V_(){let e=K_.split(" "),t=new Uint16Array(e.length),n=0;for(let r=0;r<e.length;r+=2){let i=n+parseInt(e[r],36);n=i+parseInt(e[r+1],36),t[r]=i,t[r+1]=n}return t}function Li(e){if(e<170||e>65500)return!1;let t=z_??=V_(),n=0,r=(t.length>>1)-1;for(;n<=r;){let i=n+r>>1;if(e<t[i*2])r=i-1;else if(e>t[i*2+1])n=i+1;else return!0}return!1}var Ru=["$end","INVALID","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","SHAPE_DATA","CALLBACKNAME","CALLBACKARGS","MD_STR","STR","STYLE","DEFAULT","LINKSTYLE","INTERPOLATE","CLASSDEF","CLASS","HREF","CLICK","GRAPH","flow","connector","global","end","LINK_TARGET","NODIR","DIR","direction_tb","direction_bt","direction_rl","direction_lr","direction_td","LINK_ID","NUM","BRKT","STYLE_SEPARATOR","COLON","AMP","SEMI","COMMA","MULT","LINK","START_LINK","EDGE_TEXT","-)","TEXT","(-","STADIUMEND","STADIUMSTART","SUBROUTINEEND","SUBROUTINESTART","VERTEX_WITH_PROPS_START","TAGEND","CYLINDEREND","CYLINDERSTART","DOUBLECIRCLEEND","DOUBLECIRCLESTART","TRAPEND","INVTRAPEND","TRAPSTART","INVTRAPSTART","TAGSTART","UP","SEP","DOWN","COMMENT","NODE_STRING","MINUS","UNICODE_TEXT","PIPE","PE","PS","SQE","SQS","DIAMOND_STOP","DIAMOND_START","NEWLINE","SPACE","EOF"];var Xm=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")Xm[e.charCodeAt(0)]=1;var j_=/accTitle\s*:\s*/y,X_=/accDescr\s*:\s*/y,q_=/accDescr\s*\{\s*/y,Q_=/call\s+/y,Z_=/click\s+/y,J_=/(?:\r?\n)*\s*\n/y,eR=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,tR=/\s*[<>^]/y,nR=/\s*v\b/y,rR=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y,/.*direction\s+TD[^\n]*/y],Tu=/[\n\r\u2028\u2029]/g,sR=/\(\s*\)/y,iR=/\n\s*/g;function qm(e){let t=e.length,n=[],r=[],i=[],s=[],a=[],o=0,c=0,l=1,u=0,h=!0,d=e.indexOf("direction"),m=e.indexOf("@"),p=-1,y=0,E=0,b=-1,S=-1,x=-1,I=-1,L=-1,O=-1,v=-1,G=F=>{let W=-1;for(let j=c;j<F;j++){let Q=e.charCodeAt(j);Q===10?(l++,W=j):Q===13&&(j+1<F&&e.charCodeAt(j+1)===10&&j++,l++,W=j)}if(W<0)u+=F-c;else{let j=W+1;for(;j<F;){let Q=e.charCodeAt(j);if(Q===8232||Q===8233)break;j++}u=j-W-1}c=F},K=(F,W)=>{n.push(F),r.push(e.slice(c,W)),i.push(c),s.push(l,u),G(W),s.push(l,u)},C=(F,W)=>{n.push(F),r.push(e.slice(c,W)),i.push(c),s.push(l,u),u+=W-c,c=W,s.push(l,u)},Z=(F,W)=>{n.push(F),r.push(e.slice(c,W)),i.push(c),s.push(l,u);for(let j=c;j<W;j++){let Q=e.charCodeAt(j);Q===10||Q===13?(l++,u=0):u++}c=W,s.push(l,u)},oe=(F,W,j)=>{n.push(F),r.push(W),i.push(c),s.push(l,u),G(j),s.push(l,u)},H=F=>{a.push(o),o=F},z=()=>{a.length>0&&(o=a.pop())},M=(F,W)=>(F.lastIndex=W,F.test(e)?F.lastIndex:-1),T=F=>e.startsWith(F,c)&&!it(e.charCodeAt(c+F.length)),R=F=>{if(F>=S&&F<=x)return x;let W=F;for(;W<t&&Xe(e.charCodeAt(W));)W++;return S=F,x=W,W},_=F=>{if(F>=I&&F<=L)return L;let W=F;for(;W<t;){let j=e.charCodeAt(W);if(j!==32&&j!==9)break;W++}return I=F,L=W,W},$=F=>{let W=R(F);if(W===v||e.charCodeAt(W)!==45||e.charCodeAt(W+1)!==45)return-1;let j=W+2;for(;e.charCodeAt(j)===45;)j++;let Q=e.charCodeAt(j);return Q===120||Q===62?R(j+1):(v=W,-1)},g=()=>{let F=R(c);if(F===O||e.charCodeAt(F)!==45)return!1;let W=e.charCodeAt(F+1),j=F+2;if(W===45){for(;e.charCodeAt(j)===45;)j++;let Q=e.charCodeAt(j);return Q===120||Q===62?K(42,R(j+1)):(H(10),K(43,R(F+2))),!0}if(W===46){for(;e.charCodeAt(j)===46;)j++;if(e.charCodeAt(j)===45)return K(42,R(j+1)),!0}return O=F,!1},N=F=>{if(e.charCodeAt(F)!==37||e.charCodeAt(F+1)!==37||e.charCodeAt(F+2)===123)return-1;let W=e.indexOf(`
54
+ `,F+2);return W===-1?t:W},w=()=>{e.charCodeAt(c+1)===96?(H(2),G(c+2)):(H(1),G(c+1))},A=F=>{let W=e.charCodeAt(c+1);return F===40?(W===45?(H(8),C(47,c+2)):W===91?(H(7),C(49,c+2)):W===40&&e.charCodeAt(c+2)===40?(H(7),C(57,c+3)):(H(7),C(72,c+1)),!0):F===91?(W===91?(H(7),C(51,c+2)):W===40?(H(7),C(55,c+2)):W===47?(H(9),C(60,c+2)):W===92?(H(9),C(61,c+2)):(H(7),C(74,c+1)),!0):F===124?(H(7),C(70,c+1),!0):F===123?(H(7),C(76,c+1),!0):!1},D=()=>{let F=c;for(;F<t;){let W=e.charCodeAt(F);if(W<128&&Xm[W]===1)F++;else if(W===45&&F+1<t){let j=e.charCodeAt(F+1);if(j===62||j===45||j===46)break;F++}else break}return F===c?!1:(C(67,F),!0)},U=F=>{let W=F;for(;W<t;){let j=e.charCodeAt(W);if(j!==32&&j!==9)break;W++}return W},B=F=>{let W;switch(F){case 97:if(e.startsWith("acc",c)){if((W=M(j_,c))>=0)return H(3),K(2,W),!0;if((W=M(X_,c))>=0)return H(4),K(4,W),!0;if((W=M(q_,c))>=0)return H(5),G(W),!0}if(T("agentflow-beta"))return h&&(h=!1,H(6)),C(20,c+14),!0;break;case 64:if(e.charCodeAt(c+1)===123)return H(14),oe(7,"",c+2),!0;break;case 99:if((W=M(Q_,c))>=0)return H(12),G(W),!0;if(T("classDef"))return C(16,c+8),!0;if(T("class"))return C(17,c+5),!0;if((W=M(Z_,c))>=0)return H(11),G(W),!0;if(T("connector"))return C(22,c+9),!0;break;case 34:return w(),!0;case 115:if(T("style"))return C(12,c+5),!0;break;case 100:if(T("default"))return C(13,c+7),!0;break;case 108:if(T("linkStyle"))return C(14,c+9),!0;break;case 105:if(T("interpolate"))return C(15,c+11),!0;break;case 104:if(e.startsWith("href",c)&&Xe(e.charCodeAt(c+4)))return K(18,c+5),!0;break;case 102:if(T("flow"))return C(21,c+4),!0;break;case 103:if(T("global"))return C(23,U(c+6)),!0;break;case 101:if(T("end"))return C(24,U(c+3)),!0;break;case 95:if(T("_self"))return C(25,c+5),!0;if(T("_blank"))return C(25,c+6),!0;if(T("_parent"))return C(25,c+7),!0;if(T("_top"))return C(25,c+4),!0;break}if(d!==-1&&c>=y&&(d<c&&(d=e.indexOf("direction",c)),d!==-1&&(p<c&&(Tu.lastIndex=c,p=Tu.test(e)?Tu.lastIndex-1:t),d<p))){for(let j=0;j<5;j++)if((W=M(rR[j],c))>=0)return K(28+j,W),!0;y=p}if(m!==-1&&F!==34&&!Xe(F)){if(c>=E){m<c&&(m=e.indexOf("@",c));let j=c;for(;j<t;){let Q=e.charCodeAt(j);if(Q===34||Xe(Q))break;j++}if(E=j,b=-1,m!==-1&&m<j)for(let Q=Math.min(j,t-1)-1;Q>=m;Q--){if(e.charCodeAt(Q)!==64)continue;let Y=e.charCodeAt(Q+1);if(Y!==123&&Y!==34){b=Q;break}}}if(b>c)return C(33,b+1),!0}if(F>=48&&F<=57){let j=c+1;for(;j<t;){let Q=e.charCodeAt(j);if(Q<48||Q>57)break;j++}return C(34,j),!0}switch(F){case 35:return C(35,c+1),!0;case 58:return e.charCodeAt(c+1)===58&&e.charCodeAt(c+2)===58?C(36,c+3):C(37,c+1),!0;case 38:return C(38,c+1),!0;case 59:return C(39,c+1),!0;case 44:return C(40,c+1),!0;case 42:return C(41,c+1),!0;case 60:return C(62,c+1),!0;case 45:return g()||D()||C(68,c+1),!0;case 40:return A(F);case 91:return e.charCodeAt(c+1)===124?(C(52,c+2),!0):A(F);case 124:case 123:return A(F);case 62:return H(7),C(53,c+1),!0;case 94:return C(63,c+1),!0;case 92:return e.charCodeAt(c+1)===124?(C(64,c+2),!0):D();case 118:return it(e.charCodeAt(c+1))?D():(C(65,c+1),!0);case 37:return(W=N(c))>=0?(K(66,W),!0):D()}if(Xe(F)){if(g())return!0;if((F===32||F===9)&&(W=N(_(c)))>=0)return K(66,W),!0;for(W=c;;){let j=e.charCodeAt(W);if(j===10)W++;else if(j===13&&e.charCodeAt(W+1)===10)W+=2;else break}return W>c?K(77,W):K(78,c+1),!0}return F<128?D():Li(F)?(C(69,c+1),!0):!1};e:for(;;){if(c>=t){let j=-1;switch(o){case 0:j=79;break;case 3:j=3;break;case 4:j=5;break;case 5:j=6;break;case 11:j=19;break;case 12:j=8;break;case 13:j=9;break}j!==-1&&C(j,t);break}let F=e.charCodeAt(c),W=!0;switch(o){case 0:W=B(F);break;case 1:if(F===34)e.charCodeAt(c+1)===96?(H(2),G(c+2)):(z(),G(c+1));else{let j=e.indexOf('"',c);K(11,j===-1?t:j)}break;case 2:if(F===96)e.charCodeAt(c+1)===34?(z(),G(c+2)):W=!1;else if(F===34)w();else{let j=c+1;for(;j<t;){let Q=e.charCodeAt(j);if(Q===96||Q===34)break;j++}K(10,j)}break;case 3:case 4:{let j=e.indexOf(`
55
+ `,c);j===-1&&(j=t);let Q=o===3?3:5;z(),K(Q,j);break}case 5:if(F===125)z(),G(c+1);else{let j=e.indexOf("}",c);j===-1&&(j=t),K(6,j)}break;case 6:{let j;F===34?w():(j=M(J_,c))>=0?(z(),K(26,j)):(j=M(eR,c))>=0||(j=M(tR,c))>=0||(j=M(nR,c))>=0?(z(),K(27,j)):W=A(F);break}case 7:{let j=e.charCodeAt(c+1);switch(F){case 34:w();break;case 40:case 91:case 123:A(F);break;case 93:z(),j===41?C(48,c+2):j===93?C(50,c+2):C(73,c+1);break;case 41:z(),j===93?C(54,c+2):j===41&&e.charCodeAt(c+2)===41?C(56,c+3):C(71,c+1);break;case 124:z(),C(70,c+1);break;case 125:z(),C(75,c+1);break;case 37:{let Q=N(c);Q>=0?G(Q):W=!1;break}default:{let Q=c+1;for(;Q<t;){let Y=e.charCodeAt(Q);if(Y===91||Y===93||Y===40||Y===41||Y===123||Y===125||Y===124||Y===34||Y===37)break;Q++}K(46,Q)}}break}case 8:{let j=e.charCodeAt(c+1),Q;if(F===34)w();else if(F===37&&(Q=N(c))>=0)G(Q);else if((F===45||F===47||F===41)&&j===41)z(),C(45,c+2);else if(F===40||F===91||F===123)A(F);else if(F===41||F===93||F===125)W=!1;else{let Y=c+1;for(;Y<t;){let ne=e.charCodeAt(Y);if(ne===34||ne===40||ne===41||ne===91||ne===93||ne===123||ne===125||(ne===45||ne===47)&&e.charCodeAt(Y+1)===41||ne===37&&e.charCodeAt(Y+1)===37&&e.charCodeAt(Y+2)!==123)break;Y++}Z(46,Y)}break}case 9:{let j=e.charCodeAt(c+1);if(F===34){w();break}switch(F){case 40:j===45||j===91||j===40&&e.charCodeAt(c+2)===40?A(F):j===93?(z(),C(58,c+2)):A(F);break;case 91:case 123:A(F);break;case 92:j===93?(z(),C(58,c+2)):C(46,c+1);break;case 47:j===93?(z(),C(59,c+2)):C(46,c+1);break;case 93:case 41:j===93?(z(),C(58,c+2)):W=!1;break;case 125:W=!1;break;case 37:{let Q=N(c);Q>=0?G(Q):W=!1;break}default:{if((F===63||F===61)&&j===93){z(),C(58,c+2);break}let Q=c+1;for(;Q<t;){let Y=e.charCodeAt(Q);if(Y===92||Y===91||Y===93||Y===40||Y===41||Y===123||Y===125||Y===47||Y===37)break;Q++}K(46,Q)}}break}case 10:{if(F===34){w();break}let j=$(c);if(j>=0){z(),K(42,j);break}if(F===45&&e.charCodeAt(c+1)===45){W=!1;break}let Q=c+1;for(;Q<t;){let Y=e.charCodeAt(Q);if(Y===34)break;if(Y===45){if(e.charCodeAt(Q+1)===45)break}else if(Xe(Y)&&$(Q)>=0)break;Q++}Z(44,Q);break}case 11:if(F===34)w();else if(Xe(F))z(),G(c+1);else{let j=c+1;for(;j<t&&!Xe(e.charCodeAt(j));)j++;C(19,j)}break;case 12:if(F===40){let j=M(sR,c);z(),j>=0?G(j):(H(13),G(c+1))}else{let j=e.indexOf("(",c);j===-1&&(j=t),K(8,j)}break;case 13:if(F===41)z(),G(c+1);else{let j=e.indexOf(")",c);j===-1&&(j=t),K(9,j)}break;case 14:if(F===34)H(15),C(7,c+1);else if(F===125)z(),G(c+1);else if(F===94)W=!1;else{let j=c+1;for(;j<t;){let Q=e.charCodeAt(j);if(Q===125||Q===94||Q===34)break;j++}K(7,j)}break;case 15:if(F===34)z(),C(7,c+1);else{let j=e.indexOf('"',c);j===-1&&(j=t),oe(7,e.slice(c,j).replace(iR,"<br/>"),j)}break}if(!W)return n.push(1),r.push(""),i.push(c),s.push(l,u,l,u),{types:n,texts:r,starts:i,locs:s};continue e}return n.push(0),r.push(""),i.push(t),s.push(l,u,l,u),{types:n,texts:r,starts:i,locs:s}}var uc=new Uint8Array(80);for(let e of[34,67,65,68,13,40,37,38,35,41,69])uc[e]=1;var Cu=new Uint8Array(80);for(let e of[34,69,67,27,65,68,40,37,38,35,41])Cu[e]=1;var Nu=new Uint8Array(80);for(let e of[34,67,78,68,38,69,37,41,35,12,14,16,17,19,20,27,21,22,23,24,65,63,43])Nu[e]=1;var Iu=new Uint8Array(80);for(let e of[34,67,37,78,35,12])Iu[e]=1;var fc=new Uint8Array(80);for(let e of[77,39,79,66])fc[e]=1;var Qm="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",Mu="'COMMENT', 'SEMI', 'NEWLINE', 'EOF'",eg=new Uint8Array(80);for(let e of[66,77,78,79])eg[e]=1;var $o=[],Zm=/}[^\S\n]*\n/g;function tg(e,t,n=!1){let r=!n&&e.includes("}")?e.replace(Zm,`}
56
+ `):e,{types:i,texts:s,starts:a,locs:o}=qm(r),c=0,l,u=0,h=0,d=w=>{let A=i[c],D=a[c];if(A===79||A===0){let B=c;for(;B>0&&eg[i[B-1]];)B--;D=r.slice(0,a[B]).trimEnd().length}let U=r===e?D:Kr([ls(e,Zm,2)],D);throw A===1?ut("agentflow",e,U,"",!0):ut("agentflow",e,U,`Expecting ${w}, got '${Ru[A]}'`)},m=(w,A)=>({first_line:o[4*w],first_column:o[4*w+1],last_line:o[4*A+2],last_column:o[4*A+3]}),p=(w,A="")=>(i[c]!==w&&d(`'${Ru[w]}'${A?", "+A:""}`),s[c++]),y=()=>{fc[i[c]]===0&&d(Mu),c++},E=()=>{uc[i[c]]===0&&d("'NODE_STRING'");let w=s[c++];for(;uc[i[c]]===1;)w+=s[c++];return w},b=()=>{Cu[i[c]]===0&&d("'NODE_STRING'");let w=s[c++];for(;Cu[i[c]]===1;)w+=s[c++];return w},S=()=>{let w=i[c],A;if(w===11)A="string";else if(w===10)A="markdown";else if(w===46||w===62||w===53||w===69)A="text";else return d(`${Qm}, 'TAGEND', 'STR', 'MD_STR'`);let D=s[c++];for(;;){let U=i[c];if(U!==46&&U!==62&&U!==53&&U!==69)break;D+=s[c++]}return{text:D,type:A}},x=w=>{p(w,Qm)},I=()=>{let w=i[c],A;if(w===11)A="string";else if(w===10)A="markdown";else if(w===44||w===69)A="text";else return d("'EDGE_TEXT', 'STR', 'MD_STR'");let D=s[c++];for(;i[c]===44||i[c]===69;)D+=s[c++];return{text:D,type:A}},L=()=>{let w=i[c],A;if(w===11)A="text";else if(w===10)A="markdown";else if(Nu[w]===1)A="text";else return d("'NODE_STRING', 'STR', 'MD_STR'");let D=s[c++];for(;Nu[i[c]]===1;)D+=s[c++];return{text:D,type:A}},O=()=>{u=c;let w=s[c++];for(;i[c]===7;)w+=s[c++];return h=c-1,w},v=(w,A,D,U)=>{let B=m(D,U);t.addVertex(w,void 0,void 0,void 0,void 0,void 0,void 0,A,B),t.extendVertexMapping(w,B)},G=(w,A)=>{A.data!==void 0&&t.addVertex(w,void 0,void 0,void 0,void 0,void 0,void 0,A.data,m(A.dataFrom,A.dataTo))},K=()=>{let w=c,A=E(),D,U,B;switch(i[c]){case 74:c++,D=S(),x(73),U="square";break;case 57:c++,D=S(),x(56),U="doublecircle";break;case 72:c++,i[c]===72?(c++,D=S(),x(71),p(71),U="circle"):(D=S(),x(71),U="round");break;case 47:c++,D=S(),x(45),U="ellipse";break;case 49:c++,D=S(),x(48),U="stadium";break;case 51:c++,D=S(),x(50),U="subroutine";break;case 52:{c++;let F=p(67);p(37);let W=p(67);p(70),D=S(),x(73),U="rect",B={[F]:W};break}case 55:c++,D=S(),x(54),U="cylinder";break;case 76:c++,i[c]===76?(c++,D=S(),x(75),p(75),U="hexagon"):(D=S(),x(75),U="diamond");break;case 53:c++,D=S(),x(73),U="odd";break;case 60:c++,D=S(),i[c]===59?(c++,U="lean_right"):(x(58),U="trapezoid");break;case 61:c++,D=S(),i[c]===58?(c++,U="lean_left"):(x(59),U="inv_trapezoid");break}return B!==void 0?t.addVertex(A,D,U,void 0,void 0,void 0,B):U!==void 0?t.addVertex(A,D,U):t.addVertex(A),t.addVertexMapping(A,D,U,m(w,c-1)),A},C=()=>{let w=K();return i[c]===36&&(c++,t.setClass(w,E())),w},Z=()=>{let w=[C()];for(l=void 0;;){let D=i[c]===7?O():void 0,U=u,B=h;if(i[c]!==78)return l=D,w;do c++;while(i[c]===78);if(i[c]!==38)return D!==void 0&&d("'AMP'"),w;c++,i[c]!==78&&d("'SPACE'");do c++;while(i[c]===78);let F=C();D!==void 0&&v(w[w.length-1],D,U,B),w.push(F)}},oe=()=>{let w;if(i[c]===33&&(w=s[c++]),i[c]===42){let A=t.destructLink(s[c++]);return w!==void 0&&(A.id=w),i[c]===70&&(c++,A.text=S(),x(70),i[c]===78&&c++),A}if(i[c]===43){let A=s[c++],D=I(),U=p(42,"'EDGE_TEXT'"),B=t.destructLink(U,A);return B.text=D,w!==void 0&&(B.id=w),B}return d("'LINK', 'START_LINK'")},H=()=>{let w=c,A=Z();l!==void 0&&v(A[A.length-1],l,u,h);let D=A;for(;;){let U=i[c];if(U!==42&&U!==43&&U!==33)return D;let B=oe(),F=Z();l!==void 0&&v(F[F.length-1],l,u,h),t.addLink(A,F,B),t.addEdgeMapping(A,F,B,m(w,c-1)),D=F.concat(D),A=F}},z=()=>{Iu[i[c]]===0&&d("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let w=s[c++];for(;Iu[i[c]]===1;)w+=s[c++];return w},M=()=>{let w=[z()];for(;i[c]===40;)c++,w.push(z());return w},T=()=>{c++,p(78);let w;if(i[c]===13)w=[s[c++]];else for(w=[p(34,"'DEFAULT'")];i[c]===40;)c++,w.push(p(34));if(p(78),i[c]!==15){t.updateLink(w,M());return}c++,p(78);let A=b();if(i[c]===78){c++;let D=M();t.updateLinkInterpolate(w,A),t.updateLink(w,D)}else t.updateLinkInterpolate(w,A)},R=(w,A)=>{if(i[c]!==78){t.setLink(w,A);return}if(c++,i[c]===25){t.setLink(w,A,s[c++]);return}let D=p(11,"'LINK_TARGET'");i[c]===78?(c++,t.setLink(w,A,p(25))):t.setLink(w,A),t.setTooltip(w,D)},_=()=>{let w=s[c++];switch(i[c]){case 8:{let A=s[c++],D=i[c]===9,U=D?s[c++]:void 0,B;i[c]===78&&(c++,B=p(11)),D?t.setClickEvent(w,A,U):t.setClickEvent(w,A),B!==void 0&&t.setTooltip(w,B);return}case 18:c++,R(w,p(11));return;case 11:R(w,s[c++]);return;default:{let A=b();if(i[c]===78){c++;let D=p(11);t.setClickEvent(w,A),t.setTooltip(w,D)}else t.setClickEvent(w,A)}}},$=w=>{p(78,Mu);let A=L(),D={text:"",type:"text"};i[c]===74&&(c++,D=S(),x(73));let U=i[c]===7?O():void 0;return fc[i[c]]===0&&d(`${Mu}, 'SHAPE_DATA'`),{global:!1,at:w,id:A,title:D,data:U,dataFrom:u,dataTo:h,list:[],collect:!1}},g=()=>{let w=i[c];switch(w){case 12:{c++,p(78);let A=E();return p(78),t.addVertex(A,void 0,void 0,M()),y(),$o}case 14:return T(),y(),$o;case 16:{c++,p(78);let A=E();return p(78),t.addClass(A,M()),y(),$o}case 17:{c++,p(78);let A=E();return p(78),t.setClass(A,E()),y(),$o}case 19:return _(),y(),$o;case 22:{let A=$(c++),D=c++,U=t.addConnector(A.id,A.title);return G(U,A),t.addConnectorMapping(A.id,A.title,m(A.at,A.at),m(D,D)),U}case 28:case 29:case 30:case 31:case 32:return c++,{stmt:"dir",value:oR[w-28]};case 2:{c++;let A=p(3).trim();return t.setAccTitle(A),A}case 4:{c++;let A=p(5).trim();return t.setAccDescription(A),A}case 6:{let A=s[c++].trim();return t.setAccDescription(A),A}default:{uc[w]===0&&d(Jm);let A=H();return y(),A}}},N=()=>{let w=[],A=[],D=!1;for(;;){let U=i[c];if(U===0)break;if(U===24){let B=w.pop();if(B===void 0)break;let F=c++;if(B.global){t.addGlobal(A),A=B.list,D=B.collect;continue}let W=t.addSubGraph(B.id,A,B.title,"flow");G(W,B),t.addSubgraphMapping(B.id,B.title,m(B.at,B.at),m(F,F)),A=B.list,D=B.collect,D&&A.push(W)}else if(U===39||U===77||U===78||U===79)D&&A.push(s[c]),c++;else if(U===66)c++;else if(U===21||U===23){let B=c++,F;U===23||fc[i[c]]===1?(F={global:U===23,at:B,id:void 0,title:void 0,data:void 0,dataFrom:0,dataTo:0,list:A,collect:D},y()):(F=$(B),F.list=A,F.collect=D,c++),w.push(F),A=[],D=!0}else{let B=g();D&&(!Array.isArray(B)||B.length>0)&&A.push(B)}}w.length>0&&d("'end'")};for(;i[c]===78||i[c]===77||i[c]===66;)c++;if(p(20,"'SPACE', 'NEWLINE', 'COMMENT'"),i[c]===26)c++,t.setDirection("TB");else{let w=p(27,"'NODIR'"),A=i[c];if(A===78){do c++;while(i[c]===78);A=i[c],A!==77&&d("'NEWLINE', 'SPACE'")}else A!==39&&A!==77&&A!==66&&d("'COMMENT', 'SEMI', 'NEWLINE', 'SPACE'");c++,t.setDirection(w)}N(),i[c]!==0&&d(Jm)}var oR=["TB","BT","RL","LR","TD"],Jm="'COMMENT', 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'flow', 'global', 'connector', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";function Gs(e,t,n=0){return{w:e,h:t,kind:n,pin:0,hint:NaN,key:NaN,span:0,x:0,y:0,rank:0}}function Ys(e,t,n=1,r=0,i=0){return{tail:e,head:t,minlen:n,labelW:r,labelH:i,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var aR=24,ng=2e4,Lu=16,rg=8,cR=.125,sg=3,lR=18,dR=10,uR=14,fR=2,hR=28,ig=12,pR=12,mR=8,gR=4,og=.5,_r=.5,Ou=1,bR=12,ag=24,yR=40,cg=400,Oi=16,ku=new Float64Array(2*Oi+2),$u=new Float64Array(2*Oi+2);function Di(e){return e===1||e===2}function lg(e,t,n,r){for(let i=t+1;i<n;i++){let s=e[i],a=r[s],o=i-1;for(;o>=t&&(r[e[o]]>a||r[e[o]]===a&&e[o]>s);)e[o+1]=e[o],o--;e[o+1]=s}}function ER(e,t,n,r,i,s){let a=(u,h)=>n[u]<n[h]||n[u]===n[h]&&(i?r[u]>r[h]:r[u]<r[h]);for(let u=0;u<t;u+=8)for(let h=u+1,d=Math.min(t,u+8);h<d;h++){let m=e[h],p=h-1;for(;p>=u&&a(m,e[p]);)e[p+1]=e[p],p--;e[p+1]=m}let c=e,l=s;for(let u=8;u<t;u*=2){for(let d=0;d<t;d+=2*u){let m=Math.min(t,d+u),p=Math.min(t,d+2*u),y=d,E=m,b=d;for(;y<m&&E<p;)l[b++]=a(c[E],c[y])?c[E++]:c[y++];for(;y<m;)l[b++]=c[y++];for(;E<p;)l[b++]=c[E++]}let h=c;c=l,l=h}if(c!==e)for(let u=0;u<t;u++)e[u]=c[u]}function hc(e,t,n){let r=e.length;if(r===0)return{width:0,height:0};let i=t.length;if(r===1&&i===0&&e[0].kind===0){let ie=e[0];return ie.rank=0,ie.x=ie.w/2,ie.y=ie.h/2,{width:ie.w,height:ie.h}}let s=1;if(i>0){let ie=new Set;for(let pe of t){let Re=Math.min(pe.tail,pe.head),be=Math.max(pe.tail,pe.head),Se=Re*r+be;if(pe.labelW>0||ie.has(Se)){s=2;break}ie.add(Se)}}Oo(e,t),Do(e,t,s);let a=new Int32Array(i),o=0;for(let ie=0;ie<i;ie++){let pe=t[ie];a[ie]=Math.abs(e[pe.head].rank-e[pe.tail].rank),a[ie]>1&&(o+=a[ie]-1)}let c=new Uint8Array(i);if(o>ng){let ie=[];for(let pe=0;pe<i;pe++)a[pe]>1&&ie.push(pe);ie.sort((pe,Re)=>a[Re]-a[pe]||pe-Re);for(let pe of ie){if(o<=ng)break;c[pe]=1,o-=a[pe]-1}}let l=r+o,u=new Float64Array(l),h=new Float64Array(l),d=new Uint8Array(l),m=new Int32Array(l),p=0;for(let ie=0;ie<r;ie++){let pe=e[ie];u[ie]=pe.w,h[ie]=pe.h,d[ie]=pe.kind,m[ie]=pe.rank,pe.rank>p&&(p=pe.rank)}let y=0;for(let ie=0;ie<i;ie++)c[ie]||(y+=a[ie]);let E=new Int32Array(y),b=new Int32Array(y),S=new Float64Array(y),x=new Float64Array(y),I=new Int32Array(i).fill(-1),L=new Uint8Array(p+1),O=new Int32Array(i).fill(-1),v=!1;for(let ie=0;ie<r;ie++)e[ie].span>0&&e[ie].kind===0&&(v=!0);let G=v?new Uint8Array(y):void 0,K=v?new Uint8Array(y):void 0,C=new Int32Array(i).fill(-1),Z=new Int32Array(i).fill(-1),oe=new Float64Array(l).fill(NaN);for(let ie=0;ie<r;ie++)oe[ie]=e[ie].key;let H=!1;{let ie=r,pe=0;for(let Re=0;Re<i;Re++){if(c[Re])continue;let be=t[Re],Se=be.reversed?be.head:be.tail,Ne=be.reversed?be.tail:be.head,De=be.reversed?be.headDx:be.tailDx,ve=be.reversed?be.tailDx:be.headDx;(De!==0||ve!==0)&&(H=!0);let fe=m[Se],_e=m[Ne],Fe=-1;be.labelW>0&&(Fe=fe+(_e-fe>>1),s===2&&_e-fe>=4?(Fe&1)===1&&(Fe+=be.reversed?1:-1):s===2&&(Fe&1)===0&&(Fe+=be.reversed?1:-1));let me=Se;_e-fe>1&&(I[Re]=ie),C[Re]=pe,G&&!(be.reversed?be.headFixed:be.tailFixed)&&(G[pe]=be.reversed?2:1);for(let $e=fe+1;$e<_e;$e++){let Pe=ie++;m[Pe]=$e,oe[Pe]=oe[Se]+(oe[Ne]-oe[Se])*($e-fe)/(_e-fe),$e===Fe?(u[Pe]=be.labelW,h[Pe]=be.labelH,d[Pe]=2,O[Re]=Pe,L[$e]|=be.reversed?2:1):d[Pe]=1,E[pe]=me,b[pe]=Pe,S[pe]=me===Se?De:0,pe++,me=Pe}E[pe]=me,b[pe]=Ne,S[pe]=me===Se?De:0,x[pe]=ve,K&&!(be.reversed?be.tailFixed:be.headFixed)&&(K[pe]=be.reversed?1:2),Z[Re]=pe,pe++}}let z;if(n.groups){let{of:ie,parent:pe}=n.groups;z=new Int32Array(l);for(let Se=0;Se<r;Se++)z[Se]=ie[Se];let Re=Se=>{let Ne=0;for(;Se>=0;Se=pe[Se])Ne++;return Ne},be=(Se,Ne)=>{let De=Re(Se),ve=Re(Ne);for(;De>ve;De--)Se=pe[Se];for(;ve>De;ve--)Ne=pe[Ne];for(;Se!==Ne;)Se=pe[Se],Ne=pe[Ne];return Se};for(let Se=0;Se<i;Se++){if(I[Se]<0)continue;let Ne=t[Se],De=be(ie[Ne.tail],ie[Ne.head]);for(let ve=I[Se],fe=ve+a[Se]-1;ve<fe;ve++)z[ve]=De}}let M=new Int32Array(l+1),T=new Int32Array(l+1);for(let ie=0;ie<y;ie++)M[E[ie]+1]++,T[b[ie]+1]++;for(let ie=0;ie<l;ie++)M[ie+1]+=M[ie],T[ie+1]+=T[ie];let R=new Int32Array(y),_=new Int32Array(y);{let ie=M.slice(0,l),pe=T.slice(0,l);for(let Re=0;Re<y;Re++)R[ie[E[Re]]++]=Re,_[pe[b[Re]]++]=Re}let $=new Int32Array(p+2);for(let ie=0;ie<l;ie++)$[m[ie]+1]++;for(let ie=0;ie<=p;ie++)$[ie+1]+=$[ie];let g=new Int32Array(l),N=new Int32Array(l);{let ie=new Int32Array(l),pe=$.slice(0,p+1);for(let Se=0;Se<l;Se++)ie[pe[m[Se]]++]=Se;for(let Se=0;Se<=p;Se++)pe[Se]=$[Se];let Re=new Uint8Array(l),be=[];for(let Se=0;Se<l;Se++)if(!Re[ie[Se]])for(be.push(ie[Se]);be.length>0;){let Ne=be.pop();if(!Re[Ne]){Re[Ne]=1,g[pe[m[Ne]]++]=Ne;for(let De=M[Ne+1]-1;De>=M[Ne];De--){let ve=b[R[De]];Re[ve]||be.push(ve)}}}}let w=(ie,pe)=>{let Re=$[ie],be=$[ie+1];if(be-Re<2)return!1;for(let De=Re;De<be;De++)if(Number.isNaN(pe(g[De])))return!1;let Se=Array.from(g.subarray(Re,be)),Ne=new Map;return Se.forEach((De,ve)=>Ne.set(De,ve)),Se.sort((De,ve)=>pe(De)-pe(ve)||Ne.get(De)-Ne.get(ve)),g.set(Se,Re),!0};for(let ie=0;ie<=p;ie++)w(ie,pe=>oe[pe]);let A=!1;for(let ie=0;ie<r;ie++)e[ie].pin!==0&&(A=!0);if(A)for(let ie=0;ie<=p;ie++){let pe=Array.from(g.subarray($[ie],$[ie+1])),Re=new Map;pe.forEach((Se,Ne)=>Re.set(Se,Ne));let be=Se=>Se<r?e[Se].pin:0;pe.sort((Se,Ne)=>be(Se)-be(Ne)||Re.get(Se)-Re.get(Ne)),g.set(pe,$[ie])}let D=new Uint8Array(p+1),U=ie=>ie<r&&(e[ie].kind===3||e[ie].kind===4)?e[ie].hint:NaN;for(let ie of[0,p])w(ie,U)&&(D[ie]=1);let B=()=>{for(let ie=0;ie<=p;ie++){let pe=$[ie];for(let Re=pe,be=$[ie+1];Re<be;Re++)N[g[Re]]=Re-pe}};B();let F={n:l,real:r,maxRank:p,W:u,KIND:d,RANK:m,EF:E,ET:b,EFD:S,ETD:x,succStart:M,succE:R,predStart:T,predE:_,layerStart:$,order:g,pos:N,offsets:H,fixed:D,GRP:z,groupParent:n.groups?.parent},W=0,j=0;if(y>0&&p>0&&([W,j]=IR(F,e),B()),n.orderOnly){let ie=dg(F,n);for(let pe=0;pe<r;pe++)e[pe].x=ie[pe];for(let pe=0;pe<i;pe++){let Re=t[pe],be=Re.reversed?Re.head:Re.tail,Se=Re.reversed?Re.tail:Re.head,Ne=[m[be],ie[be]];if(!c[pe]&&I[pe]>=0)for(let De=I[pe],ve=De+a[pe]-1;De<ve;De++)Ne.push(m[De],ie[De]);Ne.push(m[Se],ie[Se]),Re.points=Ne}return{width:0,height:0,crossings:W,declared:j}}G&&K&&xR(F,e,G,K);let Q=dg(F,n),Y=TR(F);if(G&&K){let ie=SR(F,G,K);wR(F,e,Q,ie,n,Y),_R(F,e,Q,G,K,ie,Y),RR(F,Q,Y,n);for(let pe=0;pe<i;pe++){if(c[pe])continue;let Re=t[pe],be=S[C[pe]],Se=x[Z[pe]];Re.tailDx=Re.reversed?Se:be,Re.headDx=Re.reversed?be:Se}}AR(F,Q,Y);let ne=new Uint8Array(l);Y&&!n.tracks&&CR(F,Q,Y,I,a,n.apart?0:n.edgeSep,ne),n.tracks||NR(F,Q,I,a,n.edgeSep,ne);let q=new Int32Array(i+1),k=n.tracks||G&&!n.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,J=new Int32Array(p+1);if(k){for(let ie=0;ie<i;ie++){if(q[ie]=k.from.length,c[ie])continue;let pe=I[ie],Re=!1;for(let Ne=pe,De=pe<0?pe:pe+a[ie]-1;Ne<De;Ne++){let ve=Y!==void 0&&Y[m[Ne]]===1;!n.tracks&&ve!==(ne[Ne]===1)&&(Re=!0)}if(Re)continue;let be=Q[E[C[ie]]]+S[C[ie]],Se=m[E[C[ie]]];for(let Ne=pe,De=pe<0?pe:pe+a[ie]-1;Ne<De;Ne++)Y&&Y[m[Ne]]||(k.from.push(be),k.to.push(Q[Ne]),k.rank.push(Se),k.lower.push(Ne),be=Q[Ne],Se=m[Ne]);k.from.push(be),k.to.push(Q[b[Z[ie]]]+x[Z[ie]]),k.rank.push(Se),k.lower.push(-1)}q[i]=k.from.length}let te=(ie,pe)=>{let Re=!1;for(let be=$[ie];be<$[ie+1];be++){let Se=d[g[be]];if(Se===pe)Re=!0;else if(Se!==1)return!1}return Re},se=te(0,3)?s:0,re=te(p,4)?s:0,P=new Float64Array(p+1);for(let ie=0;ie<y;ie++){let pe=Math.abs(Q[E[ie]]+S[ie]-Q[b[ie]]-x[ie]);pe>P[m[E[ie]]]&&(P[m[E[ie]]]=pe)}let ee=new Float64Array(p+1),ae=new Float64Array(p+1),ue=ie=>(ie<se||ie>=p-re?n.portSep:n.rankSep)/s,ce=new Float64Array(p+1);for(let ie=0;ie<p;ie++)ce[ie]=k?ue(ie):Math.max(ue(ie),Math.min(sg*n.rankSep/s,P[ie]*cR));let he=new Uint8Array(p+1).fill(1);for(let ie=0;ie<r;ie++)he[m[ie]]=0;for(let ie=1;ie<p;ie++){if(n.tracks||!he[ie]||L[ie]!==1&&L[ie]!==2)continue;let pe=Math.min((n.headRoom??0)/2,ce[L[ie]===1?ie-1:ie]/2);ce[ie-1]+=L[ie]===1?-pe:pe,ce[ie]+=L[ie]===1?pe:-pe}let V=ie=>d[ie]===1&&he[m[ie]]&&!n.tracks?(ae[m[ie]]-ee[m[ie]])/4:0,X=n.tracks?lR:hR,le=n.tracks?dR:ig,de=n.tracks?uR:ig,Ae=new Int32Array(p+1);if(k){let ie=new Float64Array(p+1);for(let Re=0;Re<p;Re++){if(Y&&Y[Re])continue;let be=Re+1;for(ie[Re]=ce[Re];be<p&&Y&&Y[be];)ie[Re]+=ce[be++];Ae[Re]=be}for(let Re=0;Re<k.from.length;Re++)k.wide.push(Math.abs(k.from[Re]-k.to[Re])>fR*ie[k.rank[Re]]?1:0);let pe=new Float64Array(p+1);MR(k,J,!n.tracks,ie,pe);for(let Re=0;Re<p;Re++)J[Re]>0?ce[Re]+=Math.max(0,2*X+(J[Re]-1)*le-ie[Re]):pe[Re]>0&&(ce[Re]+=Math.max(0,Math.min(sg*n.rankSep,pe[Re])-ie[Re]))}let we=0;for(let ie=0;ie<=p;ie++){let pe=0;for(let Re=$[ie];Re<$[ie+1];Re++)h[g[Re]]>pe&&(pe=h[g[Re]]);ee[ie]=we,ae[ie]=we+pe,we+=pe+ce[ie]}let Ee=we,Te=(ie,pe=k.track[ie])=>{let Re=k.rank[ie],be=ae[Re],Se=ee[Ae[Re]],Ne=n.tracks?J[Re]:k.levels[ie],De=Ne>1?Math.min(de,(Se-be-2*X)/(Ne-1)):0;return(be+Se)/2+(pe-(Ne-1)/2)*De},Me=1/0,Ie=-1/0;for(let ie=0;ie<l;ie++){let pe=u[ie]/2;Q[ie]-pe<Me&&(Me=Q[ie]-pe),Q[ie]+pe>Ie&&(Ie=Q[ie]+pe)}let ge=new Uint8Array(p+1),xe=new Uint8Array(p+1);for(let ie=0;ie<r;ie++)d[ie]!==0||!G||(T[ie+1]>T[ie]&&(ge[m[ie]]=1),M[ie+1]>M[ie]&&(xe[m[ie]]=1));for(let ie=0;ie<r;ie++){let pe=e[ie],Re=pe.rank;pe.x=Q[ie]-Me,d[ie]===0&&xe[Re]&&!ge[Re]?pe.y=ae[Re]-pe.h/2:d[ie]===0&&ge[Re]&&!xe[Re]?pe.y=ee[Re]+pe.h/2:pe.y=(ee[Re]+ae[Re])/2}for(let ie=0;ie<i;ie++){let pe=t[ie],Re=e[pe.reversed?pe.head:pe.tail],be=e[pe.reversed?pe.tail:pe.head],Se=[Re.x+(pe.reversed?pe.headDx:pe.tailDx),Re.y+Re.h/2],Ne=I[ie];if(k&&q[ie+1]>q[ie])for(let ve=q[ie];ve<q[ie+1];ve++){if(k.track[ve]>=0&&(n.tracks||k.wide[ve]===1)){let _e=Te(ve);Se.push(k.from[ve]-Me,_e,k.to[ve]-Me,_e)}else k.track[ve]>0&&Se.push(k.from[ve]-Me,Te(ve,k.track[ve]-1));let fe=k.lower[ve];fe<0||(Se.push(Q[fe]-Me,ee[m[fe]]+V(fe)),ae[m[fe]]>ee[m[fe]]&&Se.push(Q[fe]-Me,ae[m[fe]]-V(fe)))}else if(Ne>=0)for(let ve=Ne,fe=Ne+a[ie]-1;ve<fe;ve++){if(ne[ve])continue;let _e=Q[ve]-Me,Fe=ee[m[ve]],me=ae[m[ve]];Se.push(_e,Fe+V(ve)),me>Fe&&Se.push(_e,me-V(ve))}if(Se.push(be.x+(pe.reversed?pe.tailDx:pe.headDx),be.y-be.h/2),pe.reversed)for(let ve=0,fe=Se.length-2;ve<fe;ve+=2,fe-=2){let _e=Se[ve],Fe=Se[ve+1];Se[ve]=Se[fe],Se[ve+1]=Se[fe+1],Se[fe]=_e,Se[fe+1]=Fe}pe.points=Se;let De=O[ie];De>=0?(pe.labelX=Q[De]-Me,pe.labelY=(ee[m[De]]+ae[m[De]])/2):pe.labelW>0&&(pe.labelX=(Se[0]+Se[Se.length-2])/2,pe.labelY=(Se[1]+Se[Se.length-1])/2)}return{width:Ie-Me,height:Ee}}function Oo(e,t){let n=e.length,r=t.length,i=new Int32Array(n+1);for(let l=0;l<r;l++){let u=t[l];u.reversed=e[u.head].kind===3||e[u.tail].kind===4,u.reversed||i[u.tail+1]++}for(let l=0;l<n;l++)i[l+1]+=i[l];let s=new Int32Array(i[n]);{let l=i.slice(0,n);for(let u=0;u<r;u++)t[u].reversed||(s[l[t[u].tail]++]=u)}let a=new Uint8Array(n),o=i.slice(0,n),c=[];for(let l=0;l<n;l++)if(a[l]===0)for(c.push(l),a[l]=1;c.length>0;){let u=c[c.length-1];if(o[u]<i[u+1]){let h=t[s[o[u]++]],d=h.head;a[d]===1?h.reversed=!0:a[d]===0&&(a[d]=1,c.push(d))}else a[u]=2,c.pop()}}function Do(e,t,n){let r=e.length,i=t.length,s=new Int32Array(i),a=new Int32Array(i),o=new Int32Array(i),c=new Int32Array(r+1),l=new Int32Array(r+1);for(let x=0;x<i;x++){let I=t[x],L=I.reversed?I.head:I.tail,O=I.reversed?I.tail:I.head;s[x]=L,a[x]=O,o[x]=Math.max(1,I.minlen)*n,c[L+1]++,l[O+1]++}for(let x=0;x<r;x++)c[x+1]+=c[x],l[x+1]+=l[x];let u=new Int32Array(i),h=new Int32Array(i);{let x=c.slice(0,r),I=l.slice(0,r);for(let L=0;L<i;L++)u[x[s[L]]++]=L,h[I[a[L]]++]=L}let d=new Int32Array(r);for(let x=0;x<r;x++)e[x].kind===3&&(d[x]=-n);let m=new Int32Array(r);for(let x=0;x<r;x++)m[x]=l[x+1]-l[x];let p=new Int32Array(r),y=0;for(let x=0;x<r;x++)m[x]===0&&(p[y++]=x);for(let x=0;x<y;x++){let I=p[x];for(let L=c[I];L<c[I+1];L++){let O=u[L],v=a[O];d[I]+o[O]>d[v]&&(d[v]=d[I]+o[O]),--m[v]===0&&(p[y++]=v)}}for(let x=0;x<8;x++){let I=!1;for(let L=y-1;L>=0;L--){let O=p[L],v=l[O+1]-l[O],G=c[O+1]-c[O];if(v===0&&G===0)continue;let K=-1/0,C=1/0;for(let oe=l[O];oe<l[O+1];oe++){let H=h[oe];K=Math.max(K,d[s[H]]+o[H])}for(let oe=c[O];oe<c[O+1];oe++){let H=u[oe];C=Math.min(C,d[a[H]]-o[H])}let Z=d[O];G>v&&C!==1/0?Z=C:v>G&&K!==-1/0&&(Z=K),Z!==d[O]&&(d[O]=Z,I=!0)}if(!I)break}let E=1/0,b=-1/0,S=!1;for(let x=0;x<r;x++){let I=e[x].kind;I===3&&(S=!0),!(I===3||I===4)&&(d[x]<E&&(E=d[x]),d[x]>b&&(b=d[x]))}E===1/0&&(E=0,b=0);for(let x=0;x<r;x++)e[x].kind===3?d[x]=E-n:e[x].kind===4&&(d[x]=b+n);S&&(E-=n);for(let x=0;x<r;x++)e[x].rank=d[x]-E}function ug(e,t,n,r,i,s,a){let o=n===0?e.predStart:e.succStart,c=n===0?e.predE:e.succE,l=n===0?e.EF:e.ET,u=e.pos;for(let p=o[t];p<o[t+1];p++)i[c[p]]!==0&&s.push(c[p]);if(s.length<2)return 0;s.sort((p,y)=>u[l[p]]-u[l[y]]||p-y);let h=p=>{let y=0;a[0]=0;for(let E=1;E<s.length;E++){let b=i[s[E]]===i[s[E-1]];a[E]=p(b&&i[s[E]]===1,b),y+=a[E]}return y},d=h(()=>1);if(r/d<rg&&(d=h(p=>p?.5:1)),r/d<rg&&(d=h((p,y)=>y?0:1)),d===0)return 0;let m=Math.min(Lu,r/d);for(let p=1;p<s.length;p++)a[p]*=m;return d*m}function xR(e,t,n,r){let{real:i,W:s,EFD:a,ETD:o}=e;for(let c=0;c<i;c++){let l=Math.min(t[c].span,s[c]);if(!(l<=0||t[c].kind!==0))for(let u=0;u<2;u++){let h=[],d=[],m=ug(e,c,u,l,u===0?r:n,h,d);if(m===0)continue;let p=u===0?o:a,y=-m/2;for(let E=0;E<h.length;E++)y+=d[E],p[h[E]]=y}}}function Lo(e,t,n,r){if(!t)return n;let{KIND:i,RANK:s,EF:a,ET:o,succStart:c,succE:l,predStart:u,predE:h}=e;for(let d=0;d<1e5;d++){let m=r===0?a[n]:o[n];if(i[m]!==1||!t[s[m]])break;n=r===0?h[u[m]]:l[c[m]]}return n}function AR(e,t,n){let{maxRank:r,KIND:i,EF:s,ET:a,EFD:o,ETD:c,succStart:l,succE:u,predStart:h,predE:d,layerStart:m,order:p}=e;for(let[y,E]of[[0,3],[r,4]]){let b=m[y],S=m[y+1],x=[];for(let I=b;I<S;I++){let L=p[I],O=E===3;if(i[L]!==E||(O?l[L+1]-l[L]:h[L+1]-h[L])!==1)break;let v=Lo(e,n,O?u[l[L]]:d[h[L]],O?1:0),G=O?t[a[v]]+c[v]:t[s[v]]+o[v];if(x.length>0&&G<x[x.length-1]+Ou)break;x.push(G)}if(!(x.length===0||x.length!==S-b))for(let I=b;I<S;I++)t[p[I]]=x[I-b]}}function SR(e,t,n){let r=[new Int32Array(e.n),new Int32Array(e.n)];for(let i=0;i<e.EF.length;i++)n[i]!==0&&r[0][e.ET[i]]++,t[i]!==0&&r[1][e.EF[i]]++;return r}function vi(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function wR(e,t,n,r,i,s){let a=i.edgeSep,{n:o,real:c,maxRank:l,KIND:u,RANK:h,W:d,EF:m,ET:p,EFD:y,ETD:E,succStart:b,succE:S,predStart:x,predE:I,layerStart:L,order:O,pos:v}=e,G=z=>u[z]===2||u[z]===1&&!(s!==void 0&&s[h[z]]===1),K=(z,M)=>{let T=M===0?m[z]:p[z];return[M===0?n[T]+y[z]:n[T]+E[z],T<c&&t[T].kind===0?r[1-M][T]:0]},C=z=>{let M=L[h[z]],T=M+v[z],R=_=>d[_]/2+d[z]/2+(u[_]===0?i.nodeSep/2+a/2:u[_]===u[z]?a:a/2);return[T>M?n[O[T-1]]+R(O[T-1]):-1/0,T+1<L[h[z]+1]?n[O[T+1]]-R(O[T+1]):1/0]},Z=(z,M,T,R,_)=>{let g=(M[1]!==T[1]?M[1]<T[1]:Math.abs(M[0]-z)<=Math.abs(T[0]-z))?[M[0],T[0]]:[T[0],M[0]];return g.find(N=>N>=R&&N<=_)??Math.max(R,Math.min(_,g[0]))},oe=new Uint8Array(o),H=[];for(let z=1;z<l;z++)for(let M=L[z];M<L[z+1];M++){if(!G(O[M])||oe[O[M]])continue;let T=O[M];for(;Di(u[m[I[x[T]]]]);)T=m[I[x[T]]];let R=T,_=-1/0,$=1/0;H.length=0;for(let g=T;Di(u[g]);g=p[S[b[g]]]){if(R=g,!G(g))continue;oe[g]=1,H.push(g);let[N,w]=C(g);N>_&&(_=N),w<$&&($=w)}if(_<=$){let g=Z(n[H[0]],K(I[x[T]],0),K(S[b[R]],1),_,$);for(let N of H)n[N]=g;continue}for(let g of H){let[N,w]=C(g);N>w||(n[g]=Z(n[g],K(Lo(e,s,I[x[g]],0),0),K(Lo(e,s,S[b[g]],1),1),N,w))}}}function _R(e,t,n,r,i,s,a){let{real:o,W:c,EF:l,ET:u,EFD:h,ETD:d,succStart:m,succE:p,predStart:y,predE:E,pos:b}=e,S=(I,L,O,v,G)=>{if(s[L][O]<2)return 0;I=Lo(e,a,I,L);let K=L===0?l[I]:u[I],C=L===0?n[K]+h[I]:n[K]+d[I];if(G&&Math.abs(C-n[O])<=v/2+_r)return Math.max(-v/2,Math.min(v/2,C-n[O]));let Z=C,oe=0;K<o&&t[K].kind===0&&(L===0?r:i)[I]!==0&&s[1-L][K]>=2&&(oe=Math.max(0,Math.min(t[K].span,c[K])),oe>0&&(Z=n[K]));let H=Math.max(n[O]-v/2,Z-oe/2),z=Math.min(n[O]+v/2,Z+oe/2);if(H>z+_r){let T=Math.max(0,v/2-yR);return Math.max(-T,Math.min(T,C-n[O]))}let M=(n[O]*oe+Z*v)/(oe+v);return Math.max(H,Math.min(z,M))-n[O]},x=[];for(let I=0;I<o;I++){let L=Math.min(t[I].span,c[I]);if(!(L<=0||t[I].kind!==0))for(let O=0;O<2;O++){let v=O===0?l:u,G=O===0?y:m,K=O===0?E:p,C=[],Z=[];if(ug(e,I,O,L,O===0?i:r,C,Z),C.length===0)continue;C.length===1&&(Z[0]=0);let oe=[];for(let H=G[I];H<G[I+1];H++)oe.push(K[H]);oe.sort((H,z)=>b[v[H]]-b[v[z]]||H-z),x.push({v:I,side:O,span:L,ids:C,room:Z,all:oe})}}for(let I=0,L=!0;L&&I<6;I++){L=!1;for(let{v:O,side:v,span:G,ids:K,room:C,all:Z}of x){let oe=v===0?i:r,H=v===0?d:h,z=0,M=-G/2;for(let T=0;T<=Z.length;T++){let R=T<Z.length&&oe[Z[T]]===0;if(T<Z.length&&!R)continue;let _=0;for(let g=T-1;g>=0&&oe[Z[g]]!==0;g--)_++;let $=R?H[Z[T]]-Lu:G/2;if(_>0){let g=[],N=[],w=0;for(let U=0;U<_;U++){U>0&&(w+=C[z+U]),g.push(S(K[z+U],v,O,G,I>0)-w),N.push(1);let B=U>0&&C[z+U]===0;for(;g.length>1&&(B||g[g.length-2]/N[N.length-2]>g[g.length-1]/N[N.length-1]);){B=!1;let F=g.pop(),W=N.pop();g[g.length-1]+=F,N[N.length-1]+=W}}let A=w,D=0;w=0;for(let U=0;U<g.length;U++){let B=$-A<M?(M+$-A)/2:Math.max(M,Math.min($-A,g[U]/N[U]));for(let F=0;F<N[U];F++,D++)D>0&&(w+=C[z+D]),Math.abs(H[K[z+D]]-B-w)>.01&&(L=!0),H[K[z+D]]=B+w}z+=_}R&&(M=H[Z[T]]+Lu)}}}}function RR(e,t,n,r){let{n:i,KIND:s,RANK:a,EF:o,ET:c,EFD:l,ETD:u,layerStart:h,order:d,pos:m}=e,p=C=>n!==void 0&&s[C]===1&&n[a[C]]===1,y=[],E=[],b=[],S=[];for(let C=0;C<o.length;C++){if(p(o[C]))continue;let Z=Lo(e,n,C,1);y.push(o[C]),E.push(c[Z]),b.push(l[C]),S.push(u[Z])}let x=C=>t[E[C]]+S[C]-t[y[C]]-b[C],I=new Int32Array(i),L=[];for(let C=0;C<i;C++)I[C]=C,L.push([C]);let O=(C,Z)=>{let oe=I[C],H=I[Z];if(oe!==H){L[oe].length<L[H].length&&([oe,H]=[H,oe]);for(let z of L[H])I[z]=oe,L[oe].push(z);L[H]=[]}},v=[];for(let C=0;C<y.length;C++){let Z=Math.abs(x(C));Z<.01?O(y[C],E[C]):Z<=ag&&v.push(C)}if(v.length===0)return;v.sort((C,Z)=>Math.abs(x(C))-Math.abs(x(Z))||C-Z);let G=C=>fg(e,r,C),K=(C,Z)=>{for(let oe of L[C]){let H=h[a[oe]],z=h[a[oe]+1],M=H+m[oe];if(M>H&&I[d[M-1]]!==C&&t[oe]+Z-t[d[M-1]]<G(oe)+G(d[M-1])-.01||M+1<z&&I[d[M+1]]!==C&&t[d[M+1]]-t[oe]-Z<G(oe)+G(d[M+1])-.01)return!1}return!0};for(let C of v){let Z=x(C);if(Math.abs(Z)<.01){O(y[C],E[C]);continue}if(Math.abs(Z)>ag||I[y[C]]===I[E[C]])continue;let oe=I[y[C]],H=I[E[C]],z=L[oe].length<=L[H].length?oe:H;for(let M of[z,z===oe?H:oe]){let T=M===oe?Z:-Z;if(!(Math.abs(Z)>bR&&!L[M].every(R=>s[R]===1))&&K(M,T)){for(let R of L[M])t[R]+=T;O(y[C],E[C]);break}}}}function TR(e){let{maxRank:t,KIND:n,layerStart:r,order:i}=e,s=new Uint8Array(t+1),a=!1;for(let o=1;o<t;o++){let c=r[o+1]>r[o];for(let l=r[o];c&&l<r[o+1];l++)n[i[l]]!==1&&(c=!1);c&&(s[o]=1,a=!0)}return a?s:void 0}function MR(e,t,n,r,i){let{from:s,to:a,rank:o,track:c,levels:l,wide:u}=e,h=s.length,d=new Map;for(let C=0;C<h;C++){if(c.push(-1),l.push(0),Math.abs(s[C]-a[C])<_r)continue;let Z=d.get(o[C]);Z?Z.push(C):d.set(o[C],[C])}if(d.size===0)return;let m=new Float64Array(h),p=new Float64Array(h);for(let C=0;C<h;C++)m[C]=Math.min(s[C],a[C]),p[C]=Math.max(s[C],a[C]);let y=(C,Z)=>C>=m[Z]-_r&&C<=p[Z]+_r?1:0,E=(C,Z)=>Math.abs(s[C]-s[Z])<_r||Math.abs(a[C]-a[Z])<_r,b=(C,Z)=>m[C]<p[Z]-_r&&m[Z]<p[C]-_r,S=(C,Z)=>b(C,Z)&&!E(C,Z),x=(C,Z)=>b(C,Z)||y(a[C],Z)+y(s[Z],C)+y(a[Z],C)+y(s[C],Z)>0,I=(C,Z)=>y(a[C],Z)+y(s[Z],C),L=C=>{let Z=C.map((H,z)=>z).sort((H,z)=>m[C[H]]-m[C[z]]),oe=[];for(let H=0;H<Z.length;H++){let z=Z[H],M=p[C[z]]+4*_r;for(let T=H+1;T<Z.length&&m[C[Z[T]]]<=M;T++){let R=Z[T];oe.push(Math.min(z,R),Math.max(z,R))}}return oe},O=C=>{C.sort((D,U)=>p[U]-m[U]-(p[D]-m[D])||m[D]-m[U]||D-U);let Z=C.length,oe=[],H=C.map((D,U)=>U),z=D=>{for(;H[D]!==D;)D=H[D]=H[H[D]];return D},M=Z<=cg,T=M?L(C):[],R=M?C.map(()=>[]):[];for(let D=0;D<T.length;D+=2){let U=T[D],B=T[D+1];S(C[U],C[B])&&(R[U].push(B),R[B].push(U))}let _=C.map((D,U)=>U);if(M){let D=new Int32Array(Z),U=[];for(let F=0;F<Z;F++)oe.push([]),U.push([]);for(let F=0;F<T.length;F+=2){let W=T[F],j=T[F+1],Q=C[W],Y=C[j];if(!x(Q,Y))continue;H[z(W)]=z(j);let ne=I(Q,Y),q=I(Y,Q);if(ne===q)continue;let k=ne<q?W:j,J=ne<q?j:W;oe[J].push(k),U[k].push(J),D[J]++}let B=new Uint8Array(Z);_=[];for(let F=0;F<Z;F++){let W=-1;for(let j=0;j<Z&&!(!B[j]&&((W<0||D[j]<D[W])&&(W=j),D[j]===0));j++);B[W]=1,_.push(W);for(let j of U[W])D[j]--}}let $=new Set,g=[],N=0;for(let D of _){let U=C[D],B=0;for(let F of oe[D]??[])c[C[F]]>=B&&(B=c[C[F]]+1);if(M){$.clear();for(let F of R[D])$.add(c[C[F]]);for(;$.has(B);)B++}else{for(;g[B]?.some(F=>S(U,F));)B++;(g[B]??=[]).push(U)}c[U]=B,B>=N&&(N=B+1)}let w=new Int32Array(Z).fill(N),A=new Int32Array(Z).fill(-1);for(let D=0;D<Z;D++){let U=z(D);w[U]=Math.min(w[U],c[C[D]]),A[U]=Math.max(A[U],c[C[D]])}for(let D=0;D<Z;D++){let U=z(D);l[C[D]]=A[U]-w[U]+1,n&&(c[C[D]]-=w[U])}return N},v=(C,Z,oe)=>{let H=vi(a[C]-s[C],Z);for(let z=0;z<=Oi;z++){let M=z/Oi,T=1-M;oe[2*z]=s[C]+(a[C]-s[C])*M*M*(3-2*M),oe[2*z+1]=Z*(3*H*M*T*T+3*(1-H)*M*M*T+M*M*M)}},G=(C,Z,oe)=>{let H=oe*oe*1.000000001;for(let z=0;z<=Oi;z++){let M=C[2*z],T=C[2*z+1];for(let R=0;R<Oi;R++){let _=Z[2*R+2]-Z[2*R],$=Z[2*R+3]-Z[2*R+1],g=Math.max(0,Math.min(1,((M-Z[2*R])*_+(T-Z[2*R+1])*$)/(_*_+$*$||1))),N=M-Z[2*R]-g*_,w=T-Z[2*R+1]-g*$;if(N*N+w*w<H&&Math.hypot(N,w)<oe)return!0}}return!1},K=(C,Z,oe,H)=>{let z=Math.max(oe/2,oe-2*pR);return v(C,z,ku),v(Z,z,$u),G(ku,$u,H)||G($u,ku,H)};for(let[C,Z]of d){if(!n){t[C]=O(Z);continue}if(Z.length>cg)continue;let oe=Z.filter(g=>u[g]===1);O(oe);let H=new Set(oe.filter(g=>l[g]>1)),z=L(Z);for(let g=0;g<z.length;g+=2){let N=Z[z[g]],w=Z[z[g+1]];H.has(N)&&H.has(w)||!S(N,w)||s[N]<a[N]!=s[w]<a[w]||K(N,w,r[C],u[N]===1||u[w]===1?mR:gR)&&H.add(N).add(w)}for(let g of oe)c[g]=-1,l[g]=0;if(H.size===0)continue;let M=0,T=0,R=new Set;for(let g=0;g<z.length;g+=2){let N=Z[z[g]],w=Z[z[g+1]];if(H.has(N)&&H.has(w)){if(!b(N,w))continue;s[N]<a[N]!=s[w]<a[w]?M++:E(N,w)||T++}else(H.has(N)||H.has(w))&&x(N,w)&&R.add(N).add(w)}if(M>T){for(let g of Z)(p[g]-m[g])*og>i[C]&&(i[C]=(p[g]-m[g])*og);continue}let _=Z.filter(g=>H.has(g)||u[g]!==1&&R.has(g));O(_);let $=0;for(let g of _)l[g]>$&&($=l[g]);t[C]=$}}function CR(e,t,n,r,i,s,a){let{maxRank:o,EF:c,ET:l,EFD:u,ETD:h,succStart:d,succE:m,predStart:p,predE:y,layerStart:E,order:b}=e,S=new Float64Array(t.length),x=new Float64Array(t.length),I=new Float64Array(t.length);for(let O=0;O<r.length;O++){let v=r[O];if(v<0)continue;let G=v+i[O]-1,K=e.RANK[v];for(let C=v;C<G;C++){if(!n[K+C-v])continue;let Z=C;for(;Z+1<G&&n[K+Z+1-v];)Z++;let oe=y[p[C]],H=m[d[Z]],z=t[c[oe]]+u[oe],M=t[l[H]]+h[H],T=Z-C+2;for(let R=C;R<=Z;R++)S[R]=z+(M-z)*(R-C+1)/T,x[R]=z,I[R]=M;C=Z}}let L=[];for(let O=1;O<o;O++){if(!n[O])continue;let v=E[O],G=E[O+1],K=Array.from(b.subarray(v,G)).sort((C,Z)=>x[C]-x[Z]||I[C]-I[Z]||C-Z);for(let C=0;C<K.length;){L.length=0;let Z=C;for(;Z<K.length&&Math.abs(x[K[Z]]-x[K[C]])<Ou&&Math.abs(I[K[Z]]-I[K[C]])<Ou;Z++)L.push(K[Z]);L.sort((oe,H)=>e.pos[oe]-e.pos[H]);for(let oe=0;oe<L.length;oe++){let H=L[oe];t[H]=S[H]+(oe-(L.length-1)/2)*s,(L.length===1||s===0)&&(a[H]=1)}C=Z}}}function NR(e,t,n,r,i,s){let{maxRank:a,W:o,KIND:c,RANK:l,EF:u,ET:h,EFD:d,ETD:m,succStart:p,succE:y,predStart:E,predE:b,layerStart:S,order:x}=e,I=new Uint8Array(a+1),L=!1;for(let O=1;O<a;O++){let v=!1,G=!1;for(let K=S[O];K<S[O+1];K++){let C=c[x[K]];C===2?v=!0:C!==1&&(G=!0)}v&&!G&&(I[O]=1,L=!0)}if(L)for(let O=0;O<n.length;O++){let v=n[O];if(!(v<0))for(let G=v,K=v+r[O]-1;G<K;G++){if(c[G]!==1||!I[l[G]])continue;let C=G,Z=G;for(;C>v&&s[C-1];)C--;for(;Z+1<K&&s[Z+1];)Z++;let oe=b[E[C]],H=y[p[Z]],z=t[u[oe]]+d[oe],M=t[h[H]]+m[H],T=Math.min(z,M)-i,R=Math.max(z,M)+i,_=!0,$=l[G];for(let N=S[$];_&&N<S[$+1];N++){let w=x[N];c[w]===2&&t[w]+o[w]/2>T&&t[w]-o[w]/2<R&&(_=!1)}if(!_)continue;s[G]=1;let g=Z-C+2;for(let N=C;N<=Z;N++)t[N]=z+(M-z)*(N-C+1)/g}}}function IR(e,t){let{n,real:r,maxRank:i,W:s,EF:a,ET:o,EFD:c,ETD:l,succStart:u,succE:h,predStart:d,predE:m,layerStart:p,order:y,pos:E,offsets:b,fixed:S,GRP:x,groupParent:I}=e,L=0;for(let P=0;P<=i;P++)L=Math.max(L,p[P+1]-p[P]);if(L<2)return[0,0];let O=b?new Int32Array(a.length):void 0,v=new Int32Array(O?a.length:0),G=new Int32Array(O?n:0),K=O?h.slice():h,C=new Uint8Array(O?n:0);if(O){let P=m.slice(),ee=(ae,ue,ce,he)=>{for(let V=ue+1;V<ce;V++)if(he[ae[V]]!==he[ae[ue]])return ae.subarray(ue,ce).sort((X,le)=>he[X]-he[le]),!0;return!1};for(let ae=0;ae<n;ae++){if(G[ae]=1,ee(P,d[ae],d[ae+1],l))for(let ue=d[ae]+1;ue<d[ae+1];ue++)l[P[ue]]!==l[P[ue-1]]&&G[ae]++,v[P[ue]]=G[ae]-1;ee(K,u[ae],u[ae+1],c)&&(C[ae]=1)}}let Z=1;for(;Z<(O?L+a.length:L);)Z<<=1;let oe=new Int32Array(2*Z),H=new Int32Array(a.length),z=()=>{let P=0;for(let ee=0;ee<i;ee++){let ae=p[ee+2]-p[ee+1];if(O){let he=0;for(let V=p[ee+1];V<p[ee+2];V++){let X=y[V];for(let le=d[X];le<d[X+1];le++)O[m[le]]=he+v[m[le]];he+=G[X]}ae=he}if(ae<2)continue;let ue=0;for(let he=p[ee];he<p[ee+1];he++){let V=y[he],X=u[V],le=u[V+1],de=ue;for(let we=X;we<le;we++)H[ue++]=O?O[K[we]]:E[o[h[we]]];let Ae=ue-de;if(!(Ae<2))if(O&&C[V])for(let we=de+1;we<ue;we++){let Ee=H[we],Te=c[K[X+we-de]],Me=we-1;for(;Me>=de&&c[K[X+Me-de]]===Te&&H[Me]>Ee;)H[Me+1]=H[Me],Me--;H[Me+1]=Ee}else if(Ae<=12)for(let we=de+1;we<ue;we++){let Ee=H[we],Te=we-1;for(;Te>=de&&H[Te]>Ee;)H[Te+1]=H[Te],Te--;H[Te+1]=Ee}else H.subarray(de,ue).sort()}if(ue<2)continue;let ce=1;for(;ce<ae;)ce<<=1;oe.fill(0,0,2*ce);for(let he=0;he<ue;he++){let V=H[he]+ce;for(oe[V]++;V>1;)(V&1)===0&&(P+=oe[V+1]),V>>=1,oe[V]++}}return P},M=z(),T=new Float64Array(n),R=new Int32Array(L),_=new Int32Array(L),$=I?I.length:0,g=new Int32Array($);for(let P=0;P<$;P++)for(let ee=P;ee>=0;ee=I[ee])g[P]++;let N=new Float64Array($),w=new Int32Array($),A=new Int32Array($),D=(P,ee)=>{let ae=p[P],ue=p[P+1];for(let le=ae;le<ue;le++)for(let de=x[y[le]];de>=0;de=I[de])N[de]=0,w[de]=0;for(let le=ae;le<ue;le++){let de=y[le];for(let Ae=x[de];Ae>=0;Ae=I[Ae])w[Ae]===0&&(A[Ae]=le),N[Ae]+=ee[de],w[Ae]++}let ce=le=>le>=n?N[le-n]/w[le-n]:ee[le],he=le=>le>=n?A[le-n]:ae+E[le],V=(le,de)=>{let Ae=le,we=de,Ee=x[le],Te=x[de],Me=Ee<0?0:g[Ee],Ie=Te<0?0:g[Te];for(;Me>Ie;Me--)Ae=n+Ee,Ee=I[Ee];for(;Ie>Me;Ie--)we=n+Te,Te=I[Te];for(;Ee!==Te;)Ae=n+Ee,Ee=I[Ee],we=n+Te,Te=I[Te];return ce(Ae)-ce(we)||he(Ae)-he(we)},X=Array.from(y.subarray(ae,ue)).sort(V);y.set(X,ae);for(let le=ae;le<ue;le++)E[y[le]]=le-ae};if(x){let P=new Float64Array(n);for(let ee=0;ee<=i;ee++){for(let ae=p[ee];ae<p[ee+1];ae++)P[y[ae]]=ae-p[ee];D(ee,P)}}let U=x?z():M;if(U===0)return[0,M];let B=y.slice(),F=Math.min(U,M),W=(P,ee)=>{let ae=P?d:u,ue=P?m:h,ce=P?a:o,he=P?c:l;for(let V=1;V<=i;V++){let X=P?V:i-V;if(S[X])continue;let le=p[X],de=p[X+1],Ae=0;for(let Ee=le;Ee<de;Ee++){let Te=y[Ee],Me=Te<r?t[Te].pin:0;if(Me!==0){T[Te]=Me*1e9,R[Ae++]=Te;continue}let Ie=ae[Te],ge=ae[Te+1];if(Ie===ge){if(x){let ie=P?p[X]-p[X-1]:p[X+2]-p[X+1];T[Te]=(Ee-le)*ie/(de-le);continue}T[Te]=-1;continue}let xe=0;for(let ie=Ie;ie<ge;ie++){let pe=ce[ue[ie]];xe+=E[pe],b&&s[pe]>0&&(xe+=he[ue[ie]]/s[pe])}T[Te]=xe/(ge-Ie),R[Ae++]=Te}if(x){D(X,T);continue}if(Ae<2)continue;ER(R,Ae,T,E,ee,_);let we=0;for(let Ee=le;Ee<de;Ee++)T[y[Ee]]!==-1&&(y[Ee]=R[we++]);for(let Ee=le;Ee<de;Ee++)E[y[Ee]]=Ee-le}},j=()=>{let P=0;for(let ee=0;ee<=i;ee++)for(let ae=p[ee];ae<p[ee+1];ae++)if(!(y[ae]>=r))for(let ue=ae+1;ue<p[ee+1];ue++)y[ue]<y[ae]&&P++;return P},Q=()=>{for(let P=0;P<=i;P++)for(let ee=p[P];ee<p[P+1];ee++)E[y[ee]]=ee-p[P]},Y=P=>P<r?t[P].pin:0,ne=(P,ee)=>{let ae=ee?a[P]:o[P];return b&&s[ae]>0?E[ae]+(ee?c[P]:l[P])/s[ae]:E[ae]},q=(P,ee)=>{let ae=0;for(let ue=d[P];ue<d[P+1];ue++){let ce=ne(m[ue],!0);for(let he=d[ee];he<d[ee+1];he++)ce>ne(m[he],!0)&&ae++}for(let ue=u[P];ue<u[P+1];ue++){let ce=ne(h[ue],!1);for(let he=u[ee];he<u[ee+1];he++)ce>ne(h[he],!1)&&ae++}return ae},k=()=>{for(let P=0;P<8;P++){let ee=!1;for(let ae=0;ae<=i;ae++){if(S[ae])continue;let ue=p[ae];for(let ce=ue;ce+1<p[ae+1];ce++){let he=y[ce],V=y[ce+1];Y(he)!==Y(V)||x&&x[he]!==x[V]||q(V,he)>=q(he,V)||(y[ce]=V,y[ce+1]=he,E[V]=ce-ue,E[he]=ce+1-ue,ee=!0)}}if(!ee)break}},J=y.slice(),te=n<=600,se=B,re=1/0;for(let P=0;P<(te?2:1);P++){P>0&&(y.set(J),Q());let ee=F,ae=J.slice();for(let ce=0,he=0;he<4&&ce<aR;ce++,he++){W((ce+P)%2===0,ce%4>=2);let V=z();if(V<ee&&(ee=V,ae.set(y),he=0,V===0))break}if(y.set(ae),te&&ee>0){Q(),k();let ce=z();ce<ee&&(ee=ce,ae.set(y))}let ue=te?j():0;(P===0||ee<U||ee===U&&ue<re)&&(U=ee,se=ae,re=ue)}if(y.set(se),Q(),B.set(se),x&&(U=z()),!te)return[U,M];for(let P=0;P<r;P++)if(t[P].pin!==0)return[U,M];if(re===0||S[0]||S[i])return[U,M];for(let P=0;P<=i;P++)y.subarray(p[P],p[P+1]).reverse();return Q(),(z()>U||j()>=re)&&y.set(B),[U,M]}function fg(e,t,n){return e.W[n]/2+(e.KIND[n]===0?t.nodeSep:t.edgeSep)/2}function dg(e,t){let{n,maxRank:r,W:i,KIND:s,EF:a,ET:o,EFD:c,ETD:l,succStart:u,succE:h,predStart:d,predE:m,layerStart:p,order:y,pos:E}=e,b=a.length,S=new Float64Array(n);for(let A=0;A<n;A++)S[A]=fg(e,t,A);let x=new Int32Array(b);for(let A=0;A<b;A++)x[A]=E[o[A]];for(let A=0;A<n;A++)u[A+1]-u[A]>1&&lg(h,u[A],u[A+1],x);for(let A=0;A<b;A++)x[A]=E[a[A]];for(let A=0;A<n;A++)d[A+1]-d[A]>1&&lg(m,d[A],d[A+1],x);let I=new Uint8Array(b);for(let A=1;A<=r;A++){let D=p[A]-p[A-1],U=p[A],B=p[A+1],F=0,W=U;for(let j=U;j<B;j++){let Q=y[j],Y=-1;if(Di(s[Q])){let q=a[m[d[Q]]];Di(s[q])&&(Y=q)}let ne=Y>=0?E[Y]:D;if(Y>=0||j===B-1){for(let q=W;q<=j;q++){let k=y[q],J=Di(s[k]);for(let te=d[k];te<d[k+1];te++){let se=m[te],re=E[a[se]];(re<F||ne<re)&&!(J&&Di(s[a[se]]))&&(I[se]=1)}}W=j+1,F=ne}}}let L=[],O=new Int32Array(n),v=new Int32Array(n),G=new Float64Array(n),K=new Int32Array(n),C=new Int32Array(n),Z=new Float64Array(n),oe=new Int32Array(n),H=new Int32Array(n+1),z=new Int32Array(n),M=new Int32Array(n),T=new Int32Array(n),R=new Float64Array(n);for(let A=0;A<4;A++){let D=A<2,U=(A&1)===1,B=D?d:u,F=D?m:h,W=D?a:o,j=D?l:c,Q=D?c:l;for(let k=0;k<n;k++)O[k]=k,v[k]=k,G[k]=0,oe[k]=0,H[k+1]=0,R[k]=0;for(let k=0;k<=r;k++){let J=D?k:r-k,te=p[J],se=p[J+1],re=D?J-1:J+1,P=re>=0&&re<=r?p[re+1]-p[re]-1:0,ee=-1;for(let ae=U?se-1:te;U?ae>=te:ae<se;U?ae--:ae++){let ue=y[ae],ce=B[ue],he=B[ue+1]-ce;if(he===0)continue;let V=ce+(he-1>>1),X=ce+(he>>1);for(let le=0;le<2&&!(le===1&&V===X);le++){let de=F[le===0!==U?V:X],Ae=W[de],we=U?P-E[Ae]:E[Ae];v[ue]===ue&&ee<we&&I[de]===0&&(v[Ae]=ue,v[ue]=O[ue]=O[Ae],G[ue]=G[Ae]+Q[de]-j[de],ee=we)}}}let Y=0;for(let k=0;k<=r;k++){let J=p[k],te=p[k+1];for(let se=J+1;se<te;se++){let re=U?y[se]:y[se-1],P=U?y[se-1]:y[se],ee=S[re]+S[P];K[Y]=O[re],C[Y]=O[P],Z[Y]=U?ee-G[re]+G[P]:ee+G[re]-G[P],oe[O[P]]++,H[O[re]+1]++,Y++}}for(let k=0;k<n;k++)H[k+1]+=H[k];for(let k=0;k<n;k++)M[k]=H[k];for(let k=0;k<Y;k++)z[M[K[k]]++]=k;let ne=0;for(let k=0;k<n;k++)O[k]===k&&oe[k]===0&&(T[ne++]=k);for(let k=0;k<ne;k++){let J=T[k];for(let te=H[J];te<H[J+1];te++){let se=z[te],re=C[se];R[J]+Z[se]>R[re]&&(R[re]=R[J]+Z[se]),--oe[re]===0&&(T[ne++]=re)}}for(let k=ne-1;k>=0;k--){let J=T[k],te=1/0;for(let se=H[J];se<H[J+1];se++){let re=z[se],P=R[C[re]]-Z[re];P<te&&(te=P)}te!==1/0&&te>R[J]&&(R[J]=te)}let q=new Float64Array(n);for(let k=0;k<n;k++)q[k]=(U?-R[O[k]]:R[O[k]])+G[k];L.push(q)}let _=0,$=1/0,g=[],N=[];for(let A=0;A<4;A++){let D=1/0,U=-1/0,B=L[A];for(let F=0;F<n;F++){let W=i[F]/2;B[F]-W<D&&(D=B[F]-W),B[F]+W>U&&(U=B[F]+W)}g.push(D),N.push(U),U-D<$&&($=U-D,_=A)}for(let A=0;A<4;A++){let D=(A&1)===0?g[_]-g[A]:N[_]-N[A];if(D!==0){let U=L[A];for(let B=0;B<n;B++)U[B]+=D}}let w=new Float64Array(n);for(let A=0;A<n;A++){let D=L[0][A],U=L[1][A],B=L[2][A],F=L[3][A],W;D>U&&(W=D,D=U,U=W),B>F&&(W=B,B=F,F=W),D>B&&(W=D,D=B,B=W),U>F&&(W=U,U=F,F=W),U>B&&(W=U,U=B,B=W),w[A]=(U+B)/2}return w}function cn(e){return e==="BT"||e==="LR"||e==="RL"?e:"TB"}var kR=4e4,$R=400,LR=500,OR=1.5,DR=4;function hg(e,t,n,r){let i=[];for(let o of e)i.push(o.x,o.y,o.w,o.h);let s=[];for(let o of t)s.push(o.labelX,o.labelY);let a=[];for(let o of n){a.push(o.x,o.y);for(let c of o.ports)a.push(c.px,c.py)}return{nodes:i,routes:t.map(o=>o.route),labels:s,levels:a,total:r}}function pg(e,t,n,r){t.forEach((s,a)=>{s.x=e.nodes[4*a],s.y=e.nodes[4*a+1],s.w=e.nodes[4*a+2],s.h=e.nodes[4*a+3]}),n.forEach((s,a)=>{s.route=e.routes[a],s.labelX=e.labels[2*a],s.labelY=e.labels[2*a+1]});let i=0;for(let s of r){s.x=e.levels[i++],s.y=e.levels[i++];for(let a of s.ports)a.px=e.levels[i++],a.py=e.levels[i++]}return e.total}var mg=24,Pi=.5,Du=3,vu=2,vR=Math.max(3,Du,vu+1),pc=.62,PR=128;function FR(e){return e.tracks?1:e.straight?2:0}function mc(e,t,n=0){let r=0;for(let M of t)M.src!==M.dst&&M.route.length>3&&(r+=(M.route.length/3-1)*vR);let i=new Float64Array(r),s=new Float64Array(r),a=new Float64Array(r),o=new Float64Array(r),c=new Float64Array(r),l=new Float64Array(r),u=new Int32Array(r),h=new Uint8Array(r),d=0,m=1/0,p=-1/0,y=NaN,E=NaN,b=NaN,S=NaN,x=(M,T,R,_,$,g)=>{let N=d-1;R===b&&_===S&&(g===_&&E===_||$===R&&y===R)&&u[N]===M&&h[N]===T&&(R-y)*($-R)+(_-E)*(g-_)>0&&(d--,R=y,_=E),y=R,E=_,b=$,S=g,h[d]=T,i[d]=Math.min(R,$),a[d]=Math.max(R,$),s[d]=R<=$?_:g,o[d]=R<=$?g:_,c[d]=Math.min(_,g),l[d]=Math.max(_,g),c[d]<m&&(m=c[d]),l[d]>p&&(p=l[d]),u[d++]=M};for(let M=0;M<t.length;M++){let T=t[M];if(T.src===T.dst)continue;let R=T.route,_=A=>Math.abs(R[A]-R[A-3])<.01||Math.abs(R[A+1]-R[A-2])<.01,$=A=>Math.abs(R[A]-R[A-3])+Math.abs(R[A+1]-R[A-2]),g=A=>n===0&&A>0&&A<R.length-3&&_(A)&&_(A+3)&&$(A)>=.01&&$(A+3)>=.01&&Math.abs(R[A]-R[A-3])<.01!=Math.abs(R[A+3]-R[A])<.01,N=R[0],w=R[1];for(let A=3;A<R.length;A+=3){let D=(A===3?1:0)|(A===R.length-3?2:0),U=N,B=w,F=R[A],W=R[A+1];if(N=F,w=W,_(A)||n===2){if(!g(A)){x(M,D,U,B,F,W);continue}let q=g(A-3)?$(A)/2:$(A),k=g(A+3)?$(A+3)/2:$(A+3),J=(F-R[A-3])/$(A),te=(W-R[A-2])/$(A),se=(R[A+3]-F)/$(A+3),re=(R[A+4]-W)/$(A+3),P=F-J*q,ee=W-te*q;x(M,D,U,B,P,ee);let ae=F-J*q*(1-pc),ue=W-te*q*(1-pc),ce=F+se*k*(1-pc),he=W+re*k*(1-pc);N=F+se*k,w=W+re*k;let V=D|(A+3===R.length-3?2:0),X=P,le=ee;for(let de=1;de<=vu;de++){let Ae=de/vu,we=1-Ae,Ee=we*we*we*P+3*we*we*Ae*ae+3*we*Ae*Ae*ce+Ae*Ae*Ae*N,Te=we*we*we*ee+3*we*we*Ae*ue+3*we*Ae*Ae*he+Ae*Ae*Ae*w;x(M,V,X,le,Ee,Te),X=Ee,le=Te}continue}if(n===1){let q=R[A+2]===0,k=q?U:(U+F)/2,J=q?(B+W)/2:B;x(M,D,U,B,k,J),x(M,D,k,J,q?F:k,q?J:W),x(M,D,q?F:k,q?J:W,F,W);continue}let j=R[A+2]===0,Q=j?vi(F-U,W-B):vi(W-B,F-U),Y=U,ne=B;for(let q=1;q<=Du;q++){let k=q/Du,J=1-k,te=k*k*(3-2*k),se=3*Q*k*J*J+3*(1-Q)*k*k*J+k*k*k,re=U+(F-U)*(j?te:se),P=B+(W-B)*(j?se:te);x(M,D,Y,ne,re,P),Y=re,ne=P}}}let I=p>m?Math.round(Math.sqrt(d)):1,L=p>m?I/(p-m):0,O=M=>Math.min(I-1,Math.floor((M-m)*L)),v=new Int32Array(d),G=new Int32Array(I+1);for(let M=0;M<d;M++){v[M]=O(c[M]);for(let T=v[M],R=O(l[M]);T<=R;T++)G[T+1]++}for(let M=0;M<I;M++)G[M+1]+=G[M];let K=G.slice(0,I),C=new Int32Array(G[I]);for(let M=0;M<d;M++)for(let T=v[M],R=O(l[M]);T<=R;T++)C[K[T]++]=M;let Z=new Float64Array(t.length*8),oe=(M,T,R,_)=>Math.abs(M[T]-M[R])<Pi&&Math.abs(M[T]-M[_])<Pi||Math.abs(M[T+1]-M[R+1])<Pi&&Math.abs(M[T+1]-M[_+1])<Pi;for(let M=0;M<t.length;M++){let T=t[M].route;if(T.length<6)continue;let R=3;for(;R+3<T.length&&oe(T,0,R,R+3);)R+=3;let _=T.length-3,$=_-3;for(;$>=3&&oe(T,_,$,$-3);)$-=3;Z.set([T[0],T[1],T[R],T[R+1],T[$],T[$+1],T[_],T[_+1]],M*8)}let H=(M,T,R,_)=>{let $=M*8+(T===1?0:4),g=Z[$],N=Z[$+1],w=Z[$+2]-g,A=Z[$+3]-N,D=w*w+A*A,U=D>0?Math.max(0,Math.min(1,((R-g)*w+(_-N)*A)/D)):0;return Math.hypot(R-g-U*w,_-N-U*A)<Pi},z=0;for(let M=0;M<I;M++){let T=G[M+1];if(T-G[M]>PR)C.subarray(G[M],T).sort((R,_)=>i[R]-i[_]||R-_);else for(let R=G[M]+1;R<T;R++){let _=C[R],$=R;for(;$>G[M]&&i[C[$-1]]>i[_];$--)C[$]=C[$-1];C[$]=_}for(let R=G[M];R<T;R++){let _=C[R],$=a[_]-i[_],g=o[_]-s[_],N=v[_]===M;for(let w=R+1;w<T;w++){let A=C[w];if(i[A]>a[_])break;if(l[A]<c[_]||c[A]>l[_]||u[_]===u[A]||!N&&v[A]!==M)continue;let D=$*(s[A]-s[_])-g*(i[A]-i[_]),U=$*(o[A]-s[_])-g*(a[A]-i[_]);if(D>0==U>0)continue;let B=a[A]-i[A],F=o[A]-s[A],W=B*(s[_]-s[A])-F*(i[_]-i[A]),j=B*(o[_]-s[A])-F*(a[_]-i[A]);if(W>0==j>0)continue;let Q=t[u[_]],Y=t[u[A]],ne=W/(W-j),q=i[_]+ne*$,k=s[_]+ne*g,J=(te,se,re)=>(h[_]&se)!==0&&(h[A]&re)!==0||Math.abs(q-e[te].x)<e[te].w/2+mg&&Math.abs(k-e[te].y)<e[te].h/2+mg||H(u[_],se,q,k)&&H(u[A],re,q,k);Q.src===Y.src&&J(Q.src,1,1)||Q.src===Y.dst&&J(Q.src,1,2)||Q.dst===Y.src&&J(Q.dst,2,1)||Q.dst===Y.dst&&J(Q.dst,2,2)||z++}}}return z}function bc(e,t){let n=r=>{let i=new Set;for(let s=e[r].parent;s>=0&&!i.has(s);s=e[s].parent)i.add(s);return i};for(let[r,i]of t){if(r<0||i<0||r===i)continue;let s=n(r),a=n(i);for(let o of s)a.has(o)||(e[o].dir=void 0);for(let o of a)s.has(o)||(e[o].dir=void 0)}}function Rr(e,t,n,r){for(let i of e)i.x+=n,i.y+=r;for(let i of t){for(let s=0;s<i.route.length;s+=3)i.route[s]+=n,i.route[s+1]+=r;i.labelX+=n,i.labelY+=r}}function Ft(e,t,n=-1){return{w:e,h:t,parent:n,isGroup:!1,dir:void 0,padX:0,padTop:0,padBottom:0,minW:0,seq:0,span:0,x:0,y:0}}function gc(e){return e==="TB"?0:e==="BT"?2:e==="LR"?3:1}function vo(e){return e+2&3}function Ln(e,t,n,r){let i=e.length,s=new Map,a=[],o=(T,R)=>{let _={id:T,dir:R,items:[],edges:[],ports:[],portOf:new Map,routes:new Map,x:0,y:0};return s.set(T,_),_},c=o(-1,n),l=[];for(let T=0;T<i;T++)l.push([]);let u=[];for(let T=0;T<i;T++){let R=e[T].parent;R>=0&&R<i&&R!==T&&e[R].isGroup?l[R].push(T):(e[T].parent=-1,u.push(T))}c.items=u,a.push(c);let h=new Int32Array(i),d=new Uint8Array(i),m=T=>{for(let R=T;R<a.length;R++){let _=a[R];for(let $ of _.items)if(d[$]=1,h[$]=_.id<0?0:h[_.id]+1,e[$].isGroup){let g=o($,e[$].dir??_.dir);g.items=l[$],a.push(g)}}};m(0);for(let T=0;T<i;T++){if(d[T])continue;let R=e[T].parent;if(l[R]=l[R].filter(_=>_!==T),e[T].parent=-1,c.items.push(T),d[T]=1,h[T]=0,e[T].isGroup){let _=a.length,$=o(T,e[T].dir??n);$.items=l[T],a.push($),m(_)}}for(let T=a.length-1;T>0;T--){let R=a[T],_=1/0;for(let $ of R.items)e[$].seq<_&&(_=e[$].seq);_!==1/0&&(e[R.id].seq=_)}for(let T of a)T.items.sort((R,_)=>e[R].seq-e[_].seq||R-_);let p=0;for(let T of t){let R=T.src,_=T.dst,$=0;for(;h[R]>h[_];$++)R=e[R].parent;for(;h[_]>h[R];$++)_=e[_].parent;for(;R!==_&&e[R].parent!==e[_].parent;$+=2)R=e[R].parent,_=e[_].parent;R!==_&&(p+$>kR?(T.src=R,T.dst=_):p+=$)}let y=[],E=[];for(let T=0;T<t.length;T++){let R=t[T];if(R.route=[],R.src===R.dst){y.push(T);continue}let _=R.src,$=R.dst,g=[],N=[];for(;h[_]>h[$];)g.push(_),_=e[_].parent;for(;h[$]>h[_];)N.push($),$=e[$].parent;if(_===$){E.push(T);continue}for(;e[_].parent!==e[$].parent;)g.push(_),N.push($),_=e[_].parent,$=e[$].parent;s.get(e[_].parent).edges.push({e:T,a:_,b:$});for(let[w,A]of[[g,!0],[N,!1]])for(let D of w){let U=s.get(e[D].parent),B={e:T,inner:D,out:A,side:0,hint:NaN,px:0,py:0,route:[]};U.ports.push(B),U.portOf.set(T*2+(A?0:1),B)}}let b=new Int32Array(i),S=(T,R,_)=>(_?R.src:R.dst)!==T,x=(T,R)=>{let _=T.dir==="TB"||T.dir==="BT",$=gc(T.dir),g=[],N=[];T.items.forEach((U,B)=>{b[U]=B;let F=e[U],W=R?Gs(_?F.w:F.h,_?F.h:F.w):Gs(0,0);W.span=F.isGroup?Math.min(F.span,W.w-2*F.padX):F.span,W.key=O?L[U]:NaN,g.push(W)});let w=(U,B,F)=>e[U].isGroup&&S(U,t[B],F),A=(U,B,F)=>{if(!R||!e[U].isGroup||!S(U,t[B],F))return 0;let W=s.get(U).portOf.get(B*2+(F?0:1));return _?W.px-e[U].w/2:W.py-e[U].h/2};for(let U of T.edges){let B=t[U.e],F=Ys(b[U.a],b[U.b],B.minlen);R&&(F.labelW=_?B.labelW:B.labelH,F.labelH=_?B.labelH:B.labelW,F.tailDx=A(U.a,U.e,!0),F.headDx=A(U.b,U.e,!1),F.tailFixed=w(U.a,U.e,!0),F.headFixed=w(U.b,U.e,!1)),N.push(F)}let D=new Int32Array(T.ports.length).fill(-1);return T.ports.forEach((U,B)=>{if(U.side===$||U.side===vo($)){let F=g.length,W=Gs(0,0,U.side===$?3:4);W.key=O?L[U.out?t[U.e].dst:t[U.e].src]:NaN,W.hint=Number.isNaN(U.hint)&&O&&G?G(T,U):U.hint,g.push(W),D[B]=F;let j=U.out?Ys(b[U.inner],F):Ys(F,b[U.inner]);U.out?(j.tailDx=A(U.inner,U.e,!0),j.tailFixed=w(U.inner,U.e,!0)):(j.headDx=A(U.inner,U.e,!1),j.headFixed=w(U.inner,U.e,!1)),N.push(j)}else g[b[U.inner]].pin=U.side===0||U.side===3?-1:1}),{lnodes:g,ledges:N,dummies:D}},I=p>1&&p<=$R&&t.length<=LR,L=new Float64Array(i).fill(NaN),O=!1,v=0,G,K=a.length>1&&I;for(let T of a)T.dir!==n&&(K=!1);if(K){let T=n==="TB"||n==="BT",R=new Int32Array(i).fill(-1),_=new Int32Array(i).fill(-1),$=[],g=[],N=[];for(let W=0;W<i;W++)e[W].isGroup&&(_[W]=N.length,N.push(-1));for(let W=0;W<i;W++){let j=e[W].parent;e[W].isGroup?N[_[W]]=j>=0?_[j]:-1:(R[W]=$.length,$.push(Gs(T?e[W].w:e[W].h,T?e[W].h:e[W].w)),g.push(j>=0?_[j]:-1))}let w=[],A=new Int32Array(t.length).fill(-1);t.forEach((W,j)=>{W.src===W.dst||R[W.src]<0||R[W.dst]<0||(A[j]=w.length,w.push(Ys(R[W.src],R[W.dst],W.minlen,T?W.labelW:W.labelH,T?W.labelH:W.labelW)))});let D=hc($,w,{...r,groups:{of:Int32Array.from(g),parent:Int32Array.from(N)},orderOnly:!0});v=Math.min(D.crossings??0,D.declared??0);let U=new Float64Array(i),B=new Int32Array(i),F=new Int32Array(i).fill(-1);for(let W=0;W<i;W++)if(!(R[W]<0)){L[W]=$[R[W]].x;for(let j=e[W].parent;j>=0;j=e[j].parent)U[j]+=L[W],B[j]++,F[j]=Math.max(F[j],$[R[W]].rank)}for(let W=0;W<i;W++)B[W]>0&&(L[W]=U[W]/B[W]);G=(W,j)=>{let Q=A[j.e];if(Q<0||W.id<0||!j.out||j.side!==vo(gc(W.dir)))return NaN;let Y=w[Q].points,ne=L[t[j.e].src],q=0;for(let k=0;k<Y.length;k+=2)Y[k]===F[W.id]&&(ne=Y[k+1]),Y[k]===F[W.id]+1&&(q=Y[k+1]);return ne+q*1e-6}}let C=new Map,Z=(T,R,_)=>{if(!I)return{lnodes:R,ledges:_,size:hc(R,_,r)};let $=[];for(let w of R)$.push(w.w,w.h,w.kind,w.pin,w.hint,w.key,w.span);for(let w of _)$.push(w.tail,w.head,w.minlen,w.labelW,w.labelH,w.tailDx,w.headDx,+w.tailFixed,+w.headFixed);let g=C.get(T.id);g||C.set(T.id,g=[]);for(let w of g){let A=w.given.length===$.length;for(let D=0;A&&D<$.length;D++)A=Object.is(w.given[D],$[D]);if(A)return w}let N={given:$,lnodes:R,ledges:_,size:hc(R,_,r)};return g.push(N),N},oe={width:0,height:0},H=()=>{for(let R of a){for(let w of R.ports)e[w.inner].isGroup&&S(w.inner,t[w.e],w.out)&&(s.get(w.inner).portOf.get(w.e*2+(w.out?0:1)).side=w.side);if(R.edges.length===0)continue;let _=!1;for(let w of R.edges){let A=t[w.e];(e[w.a].isGroup&&A.src!==w.a||e[w.b].isGroup&&A.dst!==w.b)&&(_=!0)}if(!_)continue;let{lnodes:$,ledges:g}=x(R,!1);Oo($,g),Do($,g,1);let N=gc(R.dir);R.edges.forEach((w,A)=>{let D=t[w.e],U=!g[A].reversed;e[w.a].isGroup&&D.src!==w.a&&(s.get(w.a).portOf.get(w.e*2).side=U?vo(N):N),e[w.b].isGroup&&D.dst!==w.b&&(s.get(w.b).portOf.get(w.e*2+1).side=U?N:vo(N))})}for(let R=a.length-1;R>=0;R--){let _=a[R],$=_.id>=0?e[_.id]:void 0,g=_.dir==="TB"||_.dir==="BT",N=_.dir==="BT"||_.dir==="RL",w=x(_,!0),{lnodes:A,ledges:D,size:U}=Z(_,w.lnodes,w.ledges),B=w.dummies,F=g?U.width:U.height,W=g?U.height:U.width,j=$?$.padX:0,Q=$?$.padTop:0,Y=Math.max(F+2*j,$?$.minW:0),ne=W+Q+($?$.padBottom:0),q=(Y-F)/2,k=Q,J=(ee,ae)=>q+(g?ee:N?U.height-ae:ae),te=(ee,ae)=>k+(g?N?U.height-ae:ae:ee),se=g?0:1,re=ee=>{let ae=[];for(let ue=0;ue<ee.length;ue+=2)ae.push(J(ee[ue],ee[ue+1]),te(ee[ue],ee[ue+1]),se);return ae};_.items.forEach((ee,ae)=>{e[ee].x=J(A[ae].x,A[ae].y),e[ee].y=te(A[ae].x,A[ae].y)}),_.edges.forEach((ee,ae)=>{let ue=D[ae];_.routes.set(ee.e,re(ue.points));let ce=t[ee.e];ce.labelW>0&&(ce.labelX=J(ue.labelX,ue.labelY),ce.labelY=te(ue.labelX,ue.labelY))});let P=_.edges.length;_.ports.forEach((ee,ae)=>{let ue=e[ee.inner];if(B[ae]>=0){let de=re(D[P++].points),Ae=ee.out?de.length-3:0,we=de[Ae],Ee=de[Ae+1];ee.side===0?Ee=0:ee.side===2?Ee=ne:ee.side===3?we=0:we=Y,ee.out?de.push(we,Ee,se):de.unshift(we,Ee,se),ee.px=we,ee.py=Ee,ee.route=de;return}let ce=ue.x,he=ue.y;if(ue.isGroup&&S(ee.inner,t[ee.e],ee.out)){let de=s.get(ee.inner).portOf.get(ee.e*2+(ee.out?0:1));ce+=de.px-ue.w/2,he+=de.py-ue.h/2}else ee.side===0?he-=ue.h/2:ee.side===2?he+=ue.h/2:ee.side===3?ce-=ue.w/2:ce+=ue.w/2;let V=ce,X=he;ee.side===0?X=0:ee.side===2?X=ne:ee.side===3?V=0:V=Y;let le=ee.side===0||ee.side===2?0:1;ee.px=V,ee.py=X,ee.route=ee.out?[ce,he,le,V,X,le]:[V,X,le,ce,he,le]}),$?($.w=Y,$.h=ne):oe={width:Y,height:ne}}for(let R of a){let _=R.x,$=R.y;for(let g of R.items){let N=e[g];if(N.x+=_,N.y+=$,N.isGroup){let w=s.get(g);w.x=N.x-N.w/2,w.y=N.y-N.h/2}}}let T=(R,_,$,g)=>{for(let N=0;N<_.length;N+=3){let w=_[N]+$,A=_[N+1]+g,D=R.length;D>=3&&Math.abs(R[D-3]-w)<.01&&Math.abs(R[D-2]-A)<.01||R.push(w,A,_[N+2])}};for(let R of a)for(let _ of R.edges){let $=t[_.e],g=[],N=[];for(let A=$.src;e[A].parent!==R.id;A=e[A].parent)N.push(s.get(e[A].parent));for(let A of N)T(g,A.portOf.get(_.e*2).route,A.x,A.y);T(g,R.routes.get(_.e),R.x,R.y);let w=[];for(let A=$.dst;e[A].parent!==R.id;A=e[A].parent)w.push(s.get(e[A].parent));for(let A=w.length-1;A>=0;A--)T(g,w[A].portOf.get(_.e*2+1).route,w[A].x,w[A].y);$.route=g,$.labelW>0&&($.labelX+=R.x,$.labelY+=R.y)}},z=FR(r);O=K,H();let M=-1;if(K&&(M=mc(e,t,z),M>v*OR+DR)){let T=hg(e,t,a,oe);O=!1,H();let R=mc(e,t,z);R>=M?(O=!0,oe=pg(T,e,t,a)):M=R}if(O===K&&I){let T=!1;for(let R of a){if(R.id<0)continue;let _=e[R.id],$=R.dir==="TB"||R.dir==="BT",g=vo(gc(R.dir)),N=[];for(let w of R.ports){if(w.side!==g)continue;let A=t[w.e].route,D=R.x+w.px,U=R.y+w.py,B=-1;for(let j=0;j<A.length&&(B<0||w.out);j+=3)Math.abs(A[j]-D)<.01&&Math.abs(A[j+1]-U)<.01&&(B=j);if(B<0)continue;let F=$?0:1,W=w.out?B+3:B-3;for(;W>=0&&W<A.length&&Math.abs(A[W+F]-A[B+F])<Pi;)W+=w.out?3:-3;W<0||W>=A.length||(w.hint=A[W+F]-($?_.x-_.w/2:_.y-_.h/2),N.push([$?w.px:w.py,w.hint]))}N.sort((w,A)=>w[0]-A[0]);for(let w=1;w<N.length;w++)N[w-1][1]>N[w][1]&&(T=!0)}if(T){let R=M>=0?M:mc(e,t,z),_=R>0?hg(e,t,a,oe):void 0;_&&(H(),mc(e,t,z)>=R&&(oe=pg(_,e,t,a)))}}for(let T of E){let R=t[T],_=e[R.src],$=e[R.dst];R.route=[_.x,_.y,0,$.x,$.y,0],R.labelX=(_.x+$.x)/2,R.labelY=(_.y+$.y)/2}for(let T of y){let R=t[T],_=e[R.src];R.labelX=_.x+_.w/2+28+R.labelW/2,R.labelY=_.y}return oe}function dr(e,t){for(let n=0;n<t.length;n+=3){let r=Math.round(t[n+1]),i=e.get(r);i?i.push(t[n]):e.set(r,[t[n]])}}function fs(e,t,n,r){if(t===0)return e.x;let i=e.y-e.h/2,s=e.x-e.w/2,a=t/2,o=[s+r-6+a,e.x,s+e.w-r+6-a],c=n.get(Math.round(i));if(c===void 0)return o[0];let l=o[0],u=-1;for(let h of o){let d=1/0;for(let m of c)m>s&&m<s+e.w&&(d=Math.min(d,Math.abs(m-h)-a));if(d>=6)return h;d>u+.5&&(u=d,l=h)}return l}function yc(e,t,n,r){let i=t>0?r.get(Math.round(e.y-e.h/2)):void 0;if(i===void 0)return!1;let s=e.x-e.w/2;for(let a of i)if(a>s&&a<s+e.w&&Math.abs(a-n)<t/2+4)return!0;return!1}function Ec(e,t,n,r,i,s,a,o){let c=1;for(let u=s[a].parent;u>=0&&c<8;u=s[u].parent)c++;let l=`color-mix(in srgb,var(--_a) ${f(100*(1-.5**c))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${i}">`+Ce(e,t,n,` fill="none" stroke="${l}" stroke-width="5" stroke-linejoin="round"`,o)+Ce(e,t,n,r,o)+"</g>"}var $t=8,BR=12,xc=.62,Po=6;function Ac(){let e=new Map;return{add(t,n,r){let i=_t(r);n>=0&&i>0&&i+Po>(e.get(t*4+n)??0)&&e.set(t*4+n,i+Po)},of:(t,n)=>n>=0?e.get(t*4+n)??0:0}}function Mn(e,t,n,r,i=n>0?n+Po:0,s=r>0?r+Po:0){let a=t==="linear",o=t==="step"||t==="stepBefore"||t==="stepAfter",c=[],l=[],u=[],h=(g,N,w,A)=>Math.abs(g-w)<.01&&Math.abs(N-A)<.01;for(let g=0;g<e.length;g+=3){let N=e[g],w=e[g+1],A=e[g+2],D=c.length-1;if(o&&D>=0&&Math.abs(N-c[D])>=.01&&Math.abs(w-l[D])>=.01){let U=c[D],B=l[D],F=t==="stepBefore"?B:t==="stepAfter"?w:(B+w)/2,W=t==="stepBefore"?U:t==="stepAfter"?N:(U+N)/2,j=A===0?[U,F,N,F]:[W,B,W,w];for(let Q=0;Q<4;Q+=2)h(j[Q],j[Q+1],U,B)||h(j[Q],j[Q+1],N,w)||(c.push(j[Q]),l.push(j[Q+1]),u.push(A))}c.push(N),l.push(w),u.push(A)}let d=c.length-1,m=g=>Math.abs(c[g]-c[g-1])<.01||Math.abs(l[g]-l[g-1])<.01,p=g=>a||m(g),y=(g,N,w)=>{if(!p(Math.max(g,N)))return w===0?[0,Math.sign(l[N]-l[g])||1]:[Math.sign(c[N]-c[g])||1,0];let A=c[N]-c[g],D=l[N]-l[g],U=Math.hypot(A,D)||1;return[A/U,D/U]},[E,b]=y(0,1,u[1]),[S,x]=y(d-1,d,u[d]),I=c[0],L=l[0],O=c[d],v=l[d];c[0]+=E*n,l[0]+=b*n,c[d]-=S*r,l[d]-=x*r;let G=g=>Math.abs(c[g]-c[g-1])+Math.abs(l[g]-l[g-1]),K=g=>!a&&g>0&&g<d&&m(g)&&m(g+1)&&G(g)>=.01&&G(g+1)>=.01&&Math.abs(c[g]-c[g-1])<.01!=Math.abs(c[g+1]-c[g])<.01,C=(g,N,w)=>Math.abs(c[g]-c[g-1])*Math.abs(N)+Math.abs(l[g]-l[g-1])*Math.abs(w),Z=(g,N,w)=>{let A=Math.min(Math.max(0,g-Po-N),w/4);return A+Math.min(g-N-A,(w-A)/4)},oe=s>r&&(!p(d)||K(d-1))?Z(s,r,C(d,S,x)):0,H=i>n&&(!p(1)||K(1))?Z(i,n,C(1,E,b)):0;oe>=1&&(c.splice(d,0,c[d]-S*oe),l.splice(d,0,l[d]-x*oe),u.splice(d,0,u[d]),d++),H>=1&&(c.splice(1,0,c[0]+E*H),l.splice(1,0,l[0]+b*H),u.splice(1,0,u[1]),d++);let z=[],M=g=>(z.push(YR(g)),f(g));z.push(77,2);let T=`M${M(c[0])},${M(l[0])}`,R=c[0],_=l[0],$=(g,N)=>{h(g,N,R,_)||(z.push(76,2),T+=`L${M(g)},${M(N)}`,R=g,_=N)};for(let g=1;g<=d;g++){let N=c[g],w=l[g];if(!p(g)){let j=u[g]===0,Q=j?w-_:N-R,Y=Math.abs(Q)*vi(j?N-R:w-_,Q),ne=j?0:Math.sign(Q)*Y,q=j?Math.sign(Q)*Y:0;z.push(67,6),T+=`C${M(R+ne)},${M(_+q)} ${M(N-ne)},${M(w-q)} ${M(N)},${M(w)}`,R=N,_=w;continue}if(!K(g)){if(g<d&&m(g)&&m(g+1)&&(N-c[g-1])*(c[g+1]-N)+(w-l[g-1])*(l[g+1]-w)>0)continue;$(N,w);continue}let A=K(g-1)?G(g)/2:G(g),D=K(g+1)?G(g+1)/2:G(g+1);o&&(A=D=Math.min(BR,A,D));let[U,B]=y(g-1,g,u[g]),[F,W]=y(g,g+1,u[g+1]);$(N-U*A,w-B*A),R=N+F*D,_=w+W*D,o?(z.push(81,4),T+=`Q${M(N)},${M(w)} ${M(R)},${M(_)}`):(z.push(67,6),T+=`C${M(N-U*A*(1-xc))},${M(w-B*A*(1-xc))} ${M(N+F*D*(1-xc))},${M(w+W*D*(1-xc))} ${M(R)},${M(_)}`)}return{d:T,tokens:z,sx:I,sy:L,sdx:-E,sdy:-b,ex:O,ey:v,edx:S,edy:x}}function _t(e){return e==="arrow_point"?$t-1:e==="arrow_circle"?$t:e==="arrow_cross"?4:0}function wt(e,t,n,r,i,s,a="none"){let o=-i,c=r;if(e==="arrow_point"){let l=t-r*$t,u=n-i*$t,h=$t*.42;return`<path class="pele-marker" d="M${f(t)},${f(n)}L${f(l+o*h)},${f(u+c*h)}L${f(l-o*h)},${f(u-c*h)}Z" fill="${s}" stroke="${a}"/>`}if(e==="arrow_circle")return`<circle class="pele-marker" cx="${f(t-r*4)}" cy="${f(n-i*4)}" r="3.5" fill="${s}" stroke="${a}"/>`;if(e==="arrow_cross"){let l=t-r*4,u=n-i*4,h=3.5,d=(r+o)*h,m=(i+c)*h,p=(r-o)*h,y=(i-c)*h;return`<path class="pele-marker" d="M${f(l-d)},${f(u-m)}L${f(l+d)},${f(u+m)}M${f(l-p)},${f(u-y)}L${f(l+p)},${f(u+y)}"/>`}return""}var WR=Array.from({length:23},(e,t)=>+`1e${t}`);function UR(e){return gg(GR(e))}function GR(e){let t=[],n=-1;for(let r=0;r<e.length;){let i=e.charCodeAt(r);if(i>=65&&i<=90&&i!==69)n=t.length+1,t.push(i,0),r++;else if(i===45||i===46||i>=48&&i<=57){let s=i===45?r+1:r,a=0,o=-1;for(let l=e.charCodeAt(s);l>=48&&l<=57||l===46&&o<0;l=e.charCodeAt(++s))l===46?o=0:(a=a*10+l-48,o>=0&&o++);let c;if((e.charCodeAt(s)|32)===101||a>Number.MAX_SAFE_INTEGER||o>22){for(let l=e.charCodeAt(s);l===46||l===101||l===69||l>=48&&l<=57||(l===45||l===43)&&(e.charCodeAt(s-1)|32)===101;l=e.charCodeAt(++s));c=Number(e.slice(r,s))}else c=o>0?a/WR[o]:a,i===45&&(c=-c);n>=0&&(t.push(c),t[n]++),r=s}else r++}return t}function YR(e){let t=Math.round(e*100);return t===0?0:t/100}function gg(e){let t=[],n=0,r=0;for(let i=0;i<e.length;){let s=e[i],a=e[i+1],o=i+2,c=o+a;if(i=c,s===72||s===86)for(let l=o;l<c;l++)s===72?n=e[l]:r=e[l],t.push(n,r);else if(s===67||s===81){let l=s===67,u=l?6:4;for(let h=o;h+u<=c;h+=u){let d=e[h],m=e[h+1],p=e[h+2],y=e[h+3],E=l?e[h+4]:p,b=l?e[h+5]:y;for(let S=.125;S<=1;S+=.125){let x=n+(d-n)*S,I=r+(m-r)*S,L=d+(p-d)*S,O=m+(y-m)*S;if(l){let v=p+(E-p)*S,G=y+(b-y)*S;x+=(L-x)*S,I+=(O-I)*S,L+=(v-L)*S,O+=(G-O)*S}t.push(x+(L-x)*S,I+(O-I)*S)}n=E,r=b}}else if(s===65)for(let l=o;l+7<=c;l+=7)HR(t,n,r,e[l],e[l+1],e[l+3],e[l+4],e[l+5],e[l+6]),n=e[l+5],r=e[l+6];else for(let l=o;l+2<=c;l+=2)s===77&&l===o&&t.length>0&&t.push(NaN,NaN),n=e[l],r=e[l+1],t.push(n,r)}return t}function HR(e,t,n,r,i,s,a,o,c){let l=(t-o)/2,u=(n-c)/2;if(r===0||i===0||l===0&&u===0){e.push(o,c);return}let h=Math.max(1,Math.sqrt(l*l/(r*r)+u*u/(i*i)));r*=h,i*=h;let d=(s===a?-1:1)*Math.sqrt(Math.max(0,(r*r*i*i-r*r*u*u-i*i*l*l)/(r*r*u*u+i*i*l*l))),m=d*r*u/i+(t+o)/2,p=-d*i*l/r+(n+c)/2,y=Math.atan2((n-p)/i,(t-m)/r),E=Math.atan2((c-p)/i,(o-m)/r)-y;a&&E<0?E+=2*Math.PI:!a&&E>0&&(E-=2*Math.PI);for(let b=1;b<=8;b++)e.push(m+r*Math.cos(y+E*b/8),p+i*Math.sin(y+E*b/8))}function KR(e,t,n,r,i,s,a,o){let c=0,l=1;for(let u=0;u<4;u++){let h=u===0?-n:u===1?n:u===2?-r:r,d=u===0?e-i:u===1?a-e:u===2?t-s:o-t;h===0?d<0&&(l=-1):h<0?c=Math.max(c,d/h):l=Math.min(l,d/h)}return c<l}function zR(e,t,n,r,i){for(let s=0;s+2<e.length;s+=2){let a=e[s],o=e[s+1],c=e[s+2],l=e[s+3];if(!(a<t&&c<t||a>r&&c>r||o<n&&l<n||o>i&&l>i)&&KR(a,o,c-a,l-o,t,n,r,i))return!0}return!1}function Fo(e,t,n,r){if(n.length===0)return;let i=r?gg(r):UR(e),s=1/0,a=1/0,o=-1/0,c=-1/0;for(let h=0;h<i.length+t.length;h+=2){let d=h<i.length?i[h]:t[h-i.length],m=h<i.length?i[h+1]:t[h+1-i.length];d<s&&(s=d),d>o&&(o=d),m<a&&(a=m),m>c&&(c=m)}let l,u=1/0;for(let h of n){let[d,m,p,y]=h.box;if(o<d+.5||s>p-.5||c<m+.5||a>y-.5)continue;let E=zR(i,d+.5,m+.5,p-.5,y-.5);for(let S=0;S<t.length&&!E;S+=2)E=t[S]>d+.5&&t[S]<p-.5&&t[S+1]>m+.5&&t[S+1]<y-.5;if(!E)continue;if(s<d||o>p||a<m||c>y)return"";let b=(p-d)*(y-m);b<u&&(u=b,l=h)}return l}function Bo(e,t=""){return(/[";]stroke:/.test(t)?void 0:lr(e.shape))??""}function Wo(e,t){let n=/[";]fill:([^;"]*)/.exec(t.shape)?.[1].trim();return n?e.replace(/ fill="var\(--_bg\)"/g,` fill="${n}"`):e}function Tr(e,t,n,r="",i){let s=Fo(e,t,n,i);return s&&Bo(s,r)}var Pu=4;function Uo(e,t,n="",r=!1){let i=u=>n.includes(u)?new RegExp(`[";]${u}:([^;"]+);`).exec(n)?.[1].trim():void 0,s=i("stroke");if(s==="none"||s==="transparent")return"";let a=r?"2.5":i("stroke-width"),o="",c="";a!==void 0&&/^[\d.]+(?:px)?$/.test(a)?parseFloat(a)!==1&&(o=` stroke-width="${f(parseFloat(a)+Pu)}"`):a!==void 0&&(c+=`stroke-width:calc(${a} + ${Pu}px);`);for(let u of["opacity","stroke-opacity"]){let h=i(u);h!==void 0&&(c+=`${u}:${h};`)}let l=`<path d="${e}"/>`+t.replace(/ class="pele-marker"/g,"");return o||c?`<g${o}${c?` style="${c}"`:""}>${l}</g>`:l}function Mr(e,t,n,r="",i=!1){return Uo(e.d,wt(t,e.sx,e.sy,e.sdx,e.sdy,"var(--_bg)","var(--_bg)")+wt(n,e.ex,e.ey,e.edx,e.edy,"var(--_bg)","var(--_bg)"),r,i)}function On(e){return e?`<g class="pele-casings" fill="none" stroke="var(--_bg)" stroke-width="${1+Pu}" stroke-linecap="round" stroke-linejoin="round" pointer-events="none">${e}</g>`:""}function ln(e,t,n,r,i,s){let a=t.width+8,o=t.height;return`<g class="pele-edge-label" data-id="${We(e)}"><rect x="${f(n-a/2)}" y="${f(r-o/2)}" width="${f(a)}" height="${f(o)}" rx="3" fill="var(--_bg)"/>`+Ce(t,n,r,i,s)+"</g>"}function Sc(e,t,n,r,i,s,a,o){let c=(i?t:n)/2,l=Math.min(c-4,8+r*6),u=s+r*8,h=Math.hypot(u,l)||1,d=(y,E)=>i?`${f(e.x+E)},${f(e.y+n/2+y)}`:`${f(e.x+t/2+y)},${f(e.y+E)}`,m=u/h*a,p=l/h*a;return i?(o.labelX=e.x,o.labelY=e.y+n/2+u+4+o.labelH/2):(o.labelX=e.x+t/2+u+4+o.labelW/2,o.labelY=e.y),{d:`M${d(0,-l)}C${d(u,-l*2)} ${d(u,l*2)} ${d(m,l+p)}`,sx:i?e.x-l:e.x+t/2,sy:i?e.y+n/2:e.y-l,sdx:i?0:-1,sdy:i?-1:0,ex:i?e.x+l:e.x+t/2,ey:i?e.y+n/2:e.y+l,edx:i?-l/h:-u/h,edy:i?-u/h:-l/h}}var xg="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg)",ur="var(--_fm)",Ag="var(--pele-radius,4px)",ft=' style="rx:var(--_r)"',VR=/[";]fill:/,Dn=e=>VR.test(e);function xt(e){let t=e.indexOf(' style="');return t<0?e+ft:`${e.slice(0,t+8)}rx:var(--_r);${e.slice(t+8)}`}var Go="var(--pele-critical,#e45756)",bg=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,jR=new RegExp(String.raw`^\s*${bg}(?:\s*,\s*${bg})*\s*$`,"u");function yg(e,t){return e&&jR.test(e)?e:t}function Sg(e,t,n){return`;--_fm:var(--pele-font-mono,${yg(n,"monospace")});font:${e}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${yg(t,"sans-serif")})`}var XR=new Set(["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","opacity","rx","ry"]),qR=new Set(["color","font-size","font-family","font-weight","font-style","text-decoration","letter-spacing","word-spacing","opacity"]),QR=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,Eg={shape:"",line:"",text:"",stroke:void 0,bold:!1,italic:!1,fontSize:void 0};function Mt(e){if(e.length===0)return Eg;let t=new Map,n=new Map;for(let l of e){let u=l.indexOf(":");if(u<=0)continue;let h=l.slice(0,u).trim().toLowerCase(),d=l.slice(u+1).replace(/!important/gi,"").trim();d===""||QR.test(d)||ec.test(d)||(XR.has(h)&&t.set(h,d),qR.has(h)&&n.set(h==="color"?"fill":h,d))}if(t.size===0&&n.size===0)return Eg;let r="",i="";for(let[l,u]of t)r+=`${l}:${u};`,l!=="fill"&&l!=="fill-opacity"&&(i+=`${l}:${u};`);let s="";for(let[l,u]of n)s+=`${l}:${u};`;let a=n.get("font-weight"),o=n.get("font-size"),c=o&&/^[\d.]+(px)?$/.test(o)?parseFloat(o):void 0;return{shape:r?` style="${nt(r)}"`:"",line:i?` style="${nt(i)}"`:"",text:s?` style="${nt(s)}"`:"",stroke:t.get("stroke"),bold:a==="bold"||a==="bolder"||Number(a)>=600,italic:n.get("font-style")==="italic",fontSize:c!==void 0&&c>0&&c<=200?c:void 0}}var ZR=/[^\w-]+/g;function Nt(e){let t=e.replace(ZR," ").trim();return t===""?"":" "+t}var JR=["#4c78a8","#f58518","#54a24b","#e45756","#72b7b2","#eeca3b","#b279a2","#9d755d"];function yt(e){let t=(e%8+8)%8;return`var(--pele-series-${t+1},${JR[t]})`}var eT=[["tw","title"],["hw","heading"],["w","bold"]],tT=/var\(--_(r|tw|hw|w)\)/g;function ot(e,t,n,r,i,s,a){let o=nt(i.idPrefix??"pele"),c="",l="";s.accTitle&&(c+=`<title id="${o}-title">${We(s.accTitle)}</title>`,l+=` aria-labelledby="${o}-title"`),s.accDescr&&(c+=`<desc id="${o}-desc">${We(s.accDescr)}</desc>`,l+=` aria-describedby="${o}-desc"`);let u=i.responsive===!1?"":"max-width:100%;height:auto;",h=new Set;for(let[,m]of a.matchAll(tT))if(h.add(m),h.size===4)break;let d=h.has("r")?`;--_r:${Ag}`:"";for(let[m,p]of eT)h.has(m)&&(d+=`;--_${m}:var(--pele-${p}-weight,bold)`);return`<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-${e}" viewBox="0 0 ${t} ${n}" width="${t}" height="${n}" style="${u}${xg}${d}${nt(Sg(r,i.fontFamily,i.fontFamilyMono))}${km()}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${e}"${l}>`+c+a+"</svg>"}var Rt=18,Tt=12,Bi=12,Un=(e,t,n)=>(n?t:e)-2*Bi,Yo=e=>(t,n,r)=>r?0:t-2*e(n)-2*Bi;function Tc(e,t,n){let r=Math.min(1,Math.abs(e)/t);return n*(1-Math.sqrt(1-r*r))}var Hs=(e,t,n,r)=>n&1?Tc(r,t/2,e/2):Tc(r,e/2,t/2),Ks=(e,t,n)=>(n?t:e)*.6,wg=(e,t,n,r)=>n&1?0:Tc(r,e/2,Math.min(12,Math.max(6,e/14))),zs=(e,t)=>()=>({w:e,h:t,dy:0});function _g(e,t,n){let r=Math.max(1.6*e+40,80),i=(t+10)/(1-(e+8)/r),s=i/2-10-t/2;return{w:r,h:i,dy:n?-s:s}}function Fi(e,t){return`<path d="${e}"${t}/>`}var wc=(e,t,n)=>n&1?t/8:0,Ho=(e,t)=>({w:Math.max(e+2*Rt,2*Rt+12),h:t+2*Tt,dy:0});function Cn(e,t){let n="";for(let r=0;r<e.length;r+=2)n+=(r?" ":"")+f(e[r])+","+f(e[r+1]);return`<polygon points="${n}"${t}/>`}function En(e,t,n,r=""){return`<rect x="${f(-e/2)}" y="${f(-t/2)}" width="${f(e)}" height="${f(t)}"${r}${n}/>`}var Rg={rect:{size:Ho,span:Un,draw:(e,t,n)=>En(e,t,xt(n))},rounded:{size:Ho,span:Un,draw:(e,t,n)=>En(e,t,n,` rx="${f(Math.min(12,t/2))}"`)},stadium:{inset:(e,t,n,r)=>n&1?Tc(r,t/2,t/2):0,span:(e,t,n)=>n?t*.6:e-t,size:(e,t)=>{let n=t+2*Tt;return{w:e+n*.5+2*Rt-8,h:n,dy:0}},draw:(e,t,n)=>En(e,t,n,` rx="${f(t/2)}"`)},"fr-rect":{span:Un,size:(e,t)=>({w:e+2*Rt+16,h:t+2*Tt,dy:0}),draw:(e,t,n,r)=>{let i=e/2-8;return En(e,t,xt(n))+`<path d="M${f(-i)},${f(-t/2)}V${f(t/2)}M${f(i)},${f(-t/2)}V${f(t/2)}" fill="none"${r}/>`}},cyl:{inset:wg,span:(e,t,n)=>n?t-2*Bi-12:e*.6,size:(e,t)=>{let n=Math.max(e+2*Rt,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*Tt+2*r,dy:r/2}},draw:(e,t,n,r)=>{let i=e/2,s=Math.min(12,Math.max(6,e/14)),a=-t/2+s,o=t/2-s;return`<path d="M${f(-i)},${f(a)}A${f(i)},${f(s)} 0 0 1 ${f(i)},${f(a)}V${f(o)}A${f(i)},${f(s)} 0 0 1 ${f(-i)},${f(o)}Z"${n}/><path d="M${f(-i)},${f(a)}A${f(i)},${f(s)} 0 0 0 ${f(i)},${f(a)}" fill="none"${r}/>`}},circle:{inset:Hs,span:Ks,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+16,44);return{w:n,h:n,dy:0}},draw:(e,t,n)=>`<circle r="${f(e/2)}"${n}/>`},"dbl-circ":{inset:Hs,span:Ks,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+26,54);return{w:n,h:n,dy:0}},draw:(e,t,n,r)=>`<circle r="${f(e/2)}"${n}/><circle r="${f(e/2-5)}" fill="none"${r}/>`},ellipse:{inset:Hs,span:Ks,size:(e,t)=>({w:e*1.3+2*Rt,h:t*1.2+2*Tt,dy:0}),draw:(e,t,n)=>`<ellipse rx="${f(e/2)}" ry="${f(t/2)}"${n}/>`},diam:{inset:(e,t,n,r)=>n&1?Math.abs(r)*e/t:Math.abs(r)*t/e,span:(e,t,n)=>(n?t:e)*.6,size:(e,t)=>{let n=e+16,r=t+8;return{w:n+1.6*r,h:n/1.6+r,dy:0}},draw:(e,t,n)=>Cn([0,-t/2,e/2,0,0,t/2,-e/2,0],n)},hex:{inset:(e,t,n,r)=>n&1?Math.abs(r)/2:0,span:(e,t,n)=>n?t*.5:e-t/2-Bi,size:(e,t)=>{let n=t+2*Tt;return{w:e+2*Rt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Cn([-e/2+r,-t/2,e/2-r,-t/2,e/2,0,e/2-r,t/2,-e/2+r,t/2,-e/2,0],n)}},odd:{inset:(e,t,n)=>n===3?t/4:0,span:Yo(()=>0),size:(e,t)=>{let n=t+2*Tt;return{w:e+2*Rt+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Cn([-e/2,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2+r,0],n)}},"lean-r":{inset:wc,span:Yo(e=>e/4),size:(e,t)=>{let n=t+2*Tt;return{w:e+2*Rt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Cn([-e/2+r,-t/2,e/2,-t/2,e/2-r,t/2,-e/2,t/2],n)}},"lean-l":{inset:wc,span:Yo(e=>e/4),size:(e,t)=>{let n=t+2*Tt;return{w:e+2*Rt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Cn([-e/2,-t/2,e/2-r,-t/2,e/2,t/2,-e/2+r,t/2],n)}},"trap-b":{inset:wc,span:Yo(e=>e/4),size:(e,t)=>{let n=t+2*Tt;return{w:e+2*Rt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Cn([-e/2+r,-t/2,e/2-r,-t/2,e/2,t/2,-e/2,t/2],n)}},"trap-t":{inset:wc,span:Yo(e=>e/4),size:(e,t)=>{let n=t+2*Tt;return{w:e+2*Rt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Cn([-e/2,-t/2,e/2,-t/2,e/2-r,t/2,-e/2+r,t/2],n)}},text:{bare:!0,span:Un,size:(e,t)=>({w:e+8,h:t+8,dy:0}),draw:(e,t)=>En(e,t,' fill="none" stroke="none"')},"sm-circ":{noLabel:!0,inset:Hs,span:Ks,size:zs(14,14),draw:(e,t,n)=>`<circle r="${f(e/2)}"${n}/>`},"f-circ":{noLabel:!0,inset:Hs,span:Ks,size:zs(14,14),draw:(e,t,n,r)=>`<circle r="${f(e/2)}" fill="var(--_l)"${r}/>`},"fr-circ":{noLabel:!0,inset:Hs,span:Ks,size:zs(18,18),draw:(e,t,n,r)=>`<circle r="${f(e/2)}"${n}/><circle r="${f(e/2-4)}" fill="var(--_l)"${r}/>`},fork:{noLabel:!0,span:(e,t,n)=>(n?t:e)-8,size:zs(72,8),draw:(e,t,n,r)=>En(e,t,` fill="var(--_l)"${r}`,' rx="2"')},"notch-rect":{size:Ho,span:Un,draw:(e,t,n)=>Cn([-e/2+10,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},"lin-rect":{span:Un,size:(e,t)=>({w:e+2*Rt+8,h:t+2*Tt,dy:0}),draw:(e,t,n,r)=>En(e,t,xt(n))+`<path d="M${f(-e/2+8)},${f(-t/2)}V${f(t/2)}" fill="none"${r}/>`},"div-rect":{span:Un,size:(e,t)=>({w:e+2*Rt,h:t+2*Tt+8,dy:4}),draw:(e,t,n,r)=>En(e,t,xt(n))+`<path d="M${f(-e/2)},${f(-t/2+8)}H${f(e/2)}" fill="none"${r}/>`},"win-pane":{span:Un,size:(e,t)=>({w:e+2*Rt+8,h:t+2*Tt+8,dy:4}),draw:(e,t,n,r)=>En(e,t,xt(n))+`<path d="M${f(-e/2+8)},${f(-t/2)}V${f(t/2)}M${f(-e/2)},${f(-t/2+8)}H${f(e/2)}" fill="none"${r}/>`},tri:{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>_g(e,t,!1),draw:(e,t,n)=>Cn([0,-t/2,e/2,t/2,-e/2,t/2],n)},"flip-tri":{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>_g(e,t,!0),draw:(e,t,n)=>Cn([-e/2,-t/2,e/2,-t/2,0,t/2],n)},"sl-rect":{inset:(e,t,n)=>n===0?5:0,size:(e,t)=>({w:e+2*Rt,h:t+2*Tt+10,dy:5}),draw:(e,t,n)=>Cn([-e/2,-t/2+10,e/2,-t/2,e/2,t/2,-e/2,t/2],n)},"notch-pent":{span:Un,size:(e,t)=>({w:e+2*Rt,h:t+2*Tt,dy:0}),draw:(e,t,n)=>Cn([-e/2+10,-t/2,e/2-10,-t/2,e/2,-t/2+10,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},hourglass:{noLabel:!0,inset:(e,t,n)=>n&1?e/2:0,size:zs(32,40),draw:(e,t,n)=>Cn([-e/2,-t/2,e/2,-t/2,-e/2,t/2,e/2,t/2],n)},delay:{size:(e,t)=>{let n=t+2*Tt;return{w:e+2*Rt+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/2;return`<path d="M${f(-e/2)},${f(-r)}H${f(e/2-r)}A${f(r)},${f(r)} 0 0 1 ${f(e/2-r)},${f(r)}H${f(-e/2)}Z"${n}/>`}},"h-cyl":{size:(e,t)=>{let n=t+2*Tt,r=Math.min(12,n/4);return{w:e+2*Rt+2*r,h:n,dy:0}},draw:(e,t,n,r)=>{let i=t/2,s=Math.min(12,t/4),a=-e/2+s,o=e/2-s;return`<path d="M${f(a)},${f(-i)}H${f(o)}A${f(s)},${f(i)} 0 0 1 ${f(o)},${f(i)}H${f(a)}A${f(s)},${f(i)} 0 0 1 ${f(a)},${f(-i)}Z"${n}/><path d="M${f(o)},${f(-i)}A${f(s)},${f(i)} 0 0 0 ${f(o)},${f(i)}" fill="none"${r}/>`}},"cross-circ":{noLabel:!0,inset:Hs,span:Ks,size:zs(44,44),draw:(e,t,n,r)=>{let i=e/2,s=i*Math.SQRT1_2;return`<circle r="${f(i)}"${n}/><path d="M${f(-s)},${f(-s)}L${f(s)},${f(s)}M${f(s)},${f(-s)}L${f(-s)},${f(s)}" fill="none"${r}/>`}},"st-rect":{span:(e,t,n)=>(n?t:e)-2*Bi-8,size:(e,t)=>({w:e+2*Rt+8,h:t+2*Tt+8,dy:4}),draw:(e,t,n)=>{let r=e-8,i=t-8,s="";for(let a=0;a<3;a++){let o=-e/2+(2-a)*4,c=-t/2+a*4;s+=`<rect x="${f(o)}" y="${f(c)}" width="${f(r)}" height="${f(i)}"${xt(n)}/>`}return s}},doc:{inset:(e,t,n)=>n===2?10:0,size:(e,t)=>({w:e+2*Rt,h:t+2*Tt+10,dy:-5}),draw:(e,t,n)=>Rc(e,t,n)},flag:{inset:(e,t,n)=>n&1?0:8,size:(e,t)=>({w:e+2*Rt,h:t+2*Tt+16,dy:0}),draw:(e,t,n)=>{let r=e/2,i=t/2-8,s=e/4;return`<path d="M${f(-r)},${f(-i)}q${f(s)},-10 ${f(2*s)},0t${f(2*s)},0V${f(i)}q${f(-s)},10 ${f(-2*s)},0t${f(-2*s)},0Z"${n}/>`}},datastore:{size:Ho,span:Un,draw:(e,t,n,r)=>En(e,t,n.replace('stroke="var(--_b)"','stroke="none"'))+`<path d="M${f(-e/2)},${f(-t/2)}H${f(e/2)}M${f(-e/2)},${f(t/2)}H${f(e/2)}" fill="none"${r}/>`},folder:{size:(e,t)=>({w:Math.max(e+2*Rt,64),h:t+2*Tt+8,dy:4}),draw:(e,t,n)=>{let r=e/2,i=t/2,s=Math.min(e*.4,48);return Fi(`M${f(-r)},${f(-i)}H${f(-r+s)}L${f(-r+s+8)},${f(-i+8)}H${f(r)}V${f(i)}H${f(-r)}Z`,n)}},bucket:{size:(e,t)=>({w:e+2*Rt+20,h:t+2*Tt+10,dy:3}),inset:(e,t,n)=>n&1?t/12:0,draw:(e,t,n,r)=>{let i=e/2,s=t/2,a=5,o=t/6;return Fi(`M${f(-i)},${f(-s+a)}A${f(i)},${f(a)} 0 0 1 ${f(i)},${f(-s+a)}L${f(i-o)},${f(s-a)}A${f(i-o)},${f(a)} 0 0 1 ${f(-i+o)},${f(s-a)}Z`,n)+`<path d="M${f(-i)},${f(-s+a)}A${f(i)},${f(a)} 0 0 0 ${f(i)},${f(-s+a)}" fill="none"${r}/>`}},console:{span:Un,size:(e,t)=>({w:Math.max(e+2*Rt,72),h:t+2*Tt+12,dy:6}),draw:(e,t,n,r)=>En(e,t,xt(n))+`<path d="M${f(-e/2)},${f(-t/2+12)}H${f(e/2)}M${f(-e/2+7)},${f(-t/2+4)}l3,2.5l-3,2.5M${f(-e/2+13)},${f(-t/2+9)}h4" fill="none"${r}/>`},browser:{span:Un,size:(e,t)=>({w:Math.max(e+2*Rt,72),h:t+2*Tt+12,dy:6}),draw:(e,t,n,r)=>{let i="";for(let s=0;s<3;s++)i+=`<circle cx="${f(-e/2+8+s*7)}" cy="${f(-t/2+6)}" r="1.5" fill="none"${r}/>`;return En(e,t,xt(n))+`<path d="M${f(-e/2)},${f(-t/2+12)}H${f(e/2)}" fill="none"${r}/>`+i}},person:{size:(e,t)=>({w:Math.max(e+2*Rt,56),h:t+2*Tt+26,dy:13}),draw:(e,t,n)=>{let r=-t/2;return`<rect x="${f(-e/2)}" y="${f(r+26)}" width="${f(e)}" height="${f(t-26)}" rx="12"${n}/><circle cy="${f(r+14)}" r="13"${n}/>`}},bang:{size:(e,t)=>({w:e+2*Rt+28,h:t+2*Tt+24,dy:0}),inset:()=>3,draw:(e,t,n)=>{let i=[];for(let s=0;s<28;s++){let a=Math.PI*s/14-Math.PI/2,o=s%2===0?1:.82;i.push(Math.cos(a)*(e/2)*o,Math.sin(a)*(t/2)*o)}return Cn(i,n)}},cloud:{size:(e,t)=>({w:e+2*Rt+32,h:t+2*Tt+24,dy:0}),inset:(e,t,n)=>n&1?2:1,draw:(e,t,n)=>{let r=e/2,i=t/2,s=i*.55;return Fi(`M${f(-r+s)},${f(i)}A${f(s)},${f(s)} 0 0 1 ${f(-r+s*.6)},${f(-i*.1)}A${f(r*.42)},${f(i*.7)} 0 0 1 ${f(-r*.1)},${f(-i*.72)}A${f(r*.4)},${f(i*.62)} 0 0 1 ${f(r*.62)},${f(-i*.42)}A${f(s*1.05)},${f(s*1.05)} 0 0 1 ${f(r-s)},${f(i)}Z`,n)}},brace:{bare:!0,size:(e,t)=>({w:e+2*Rt+12,h:t+2*Tt,dy:0}),draw:(e,t,n,r)=>En(e,t,' fill="none" stroke="none"')+_c(-e/2+12,t,-1,r)},"brace-r":{bare:!0,size:(e,t)=>({w:e+2*Rt+12,h:t+2*Tt,dy:0}),draw:(e,t,n,r)=>En(e,t,' fill="none" stroke="none"')+_c(e/2-12,t,1,r)},braces:{bare:!0,size:(e,t)=>({w:e+2*Rt+24,h:t+2*Tt,dy:0}),draw:(e,t,n,r)=>En(e,t,' fill="none" stroke="none"')+_c(-e/2+12,t,-1,r)+_c(e/2-12,t,1,r)},bolt:{noLabel:!0,size:zs(36,56),inset:(e,t,n)=>n&1?e/4:0,draw:(e,t,n)=>Cn([e*.15,-t/2,-e/2,t*.08,-e*.05,t*.08,-e*.15,t/2,e/2,-t*.08,e*.05,-t*.08],n)},"lin-cyl":{inset:wg,span:(e,t,n)=>n?t-2*Bi-20:e*.6,size:(e,t)=>{let n=Math.max(e+2*Rt,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*Tt+2*r+8,dy:r/2+4}},draw:(e,t,n,r)=>{let i=e/2,s=Math.min(12,Math.max(6,e/14)),a=-t/2+s,o=t/2-s,c=l=>`M${f(-i)},${f(l)}A${f(i)},${f(s)} 0 0 0 ${f(i)},${f(l)}`;return Fi(`M${f(-i)},${f(a)}A${f(i)},${f(s)} 0 0 1 ${f(i)},${f(a)}V${f(o)}A${f(i)},${f(s)} 0 0 1 ${f(-i)},${f(o)}Z`,n)+`<path d="${c(a)}${c(a+8)}" fill="none"${r}/>`}},"curv-trap":{size:(e,t)=>{let n=t+2*Tt;return{w:e+2*Rt+n*.6,h:n,dy:0}},draw:(e,t,n)=>{let r=e/2,i=t/2,s=t*.3;return Fi(`M${f(-r+s)},${f(-i)}H${f(r-s)}A${f(s)},${f(i)} 0 0 1 ${f(r-s)},${f(i)}H${f(-r+s)}L${f(-r)},0Z`,n)}},docs:{size:(e,t)=>({w:e+2*Rt+8,h:t+2*Tt+18,dy:-1}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n)=>{let r="";for(let i=0;i<3;i++)r+=`<g transform="translate(${(1-i)*4},${(i-1)*4})">${Rc(e-8,t-8,n)}</g>`;return r}},"bow-rect":{size:(e,t)=>{let n=t+2*Tt;return{w:e+2*Rt+n*.4,h:n,dy:0}},inset:(e,t,n)=>n===1?t*.2:0,draw:(e,t,n)=>{let r=e/2,i=t/2,s=t*.2;return Fi(`M${f(-r+s)},${f(-i)}H${f(r)}A${f(s)},${f(i)} 0 0 0 ${f(r)},${f(i)}H${f(-r+s)}A${f(s)},${f(i)} 0 0 1 ${f(-r+s)},${f(-i)}Z`,n)}},"tag-rect":{size:Ho,span:Un,draw:(e,t,n,r)=>En(e,t,xt(n))+`<path d="M${f(e/2-12)},${f(t/2)}L${f(e/2)},${f(t/2-12)}" fill="none"${r}/>`},"tag-doc":{size:(e,t)=>({w:e+2*Rt,h:t+2*Tt+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>Rc(e,t,n)+`<path d="M${f(e/2-12)},${f(t/2-14)}L${f(e/2)},${f(t/2-26)}" fill="none"${r}/>`},"lin-doc":{size:(e,t)=>({w:e+2*Rt+8,h:t+2*Tt+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>Rc(e,t,n)+`<path d="M${f(-e/2+8)},${f(-t/2)}V${f(t/2-6)}" fill="none"${r}/>`},collapsedGroup:{size:(e,t)=>({w:e+2*Rt+8,h:t+2*Tt+8,dy:-2}),draw:(e,t,n)=>`<rect x="${f(-e/2+6)}" y="${f(-t/2+8)}" width="${f(e-12)}" height="${f(t-8)}"${xt(n)}/><rect x="${f(-e/2)}" y="${f(-t/2)}" width="${f(e)}" height="${f(t-4)}"${xt(n)}/>`}};function _c(e,t,n,r){let i=t/2,s=6*n;return`<path d="M${f(e)},${f(-i)}q${f(s)},0 ${f(s)},6V-6q0,6 ${f(s)},6q${f(-s)},0 ${f(-s)},6V${f(i-6)}q0,6 ${f(-s)},6" fill="none"${r}/>`}function Rc(e,t,n){let r=e/2,i=-t/2,s=t/2-10,a=e/4;return`<path d="M${f(-r)},${f(i)}H${f(r)}V${f(s)}q${f(-a)},-12 ${f(-2*a)},0t${f(-2*a)},0Z"${n}/>`}var Fu=Rg.rect,Wi=new Map(Object.entries(Rg));function hs(e,t,n){return(Wi.get(e)??Fu).size(t,n)}function fr(e,t,n,r,i){return(Wi.get(e)??Fu).draw(t,n,r,i)}function qr(e,t,n,r,i=0){return Wi.get(e)?.inset?.(t,n,r,i)??0}function Tg(e,t,n,r){return Math.max(0,Wi.get(e)?.span?.(t,n,r)??0)}function Mg(e){return Wi.get(e)?.noLabel!==!0}function Ui(e){return(Wi.get(e)??Fu).bare!==!0}function Zn(e,t,n){let r=e[t]-n.x,i=e[t+1]-n.y;return Math.abs(Math.abs(i)-n.h/2)<.5?i<0?0:2:Math.abs(Math.abs(r)-n.w/2)<.5?r<0?3:1:-1}function Vs(e,t,n,r){if(r.isGroup)return;let i=Zn(e,t,r);if(i===0||i===2){let s=qr(n.shape,n.w,n.h,i,e[t]-r.x)+(r.h-n.h)/2;e[t+1]+=i===0?s:-s}else if(i>=0){let s=qr(n.shape,n.w,n.h,i,e[t+1]-r.y)+(r.w-n.w)/2;e[t]+=i===3?s:-s}}var nT=1.5,$g=1.3,rT=/<br\s*\/?>|\\n|\n/gi,Cg=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,Ng=/(fa[bklrs]?):fa-([\w-]+)/g,sT=/[<\\\n*_]|fa[bklrs]?:fa-/,iT=new Map([["b",1],["strong",1],["i",2],["em",2],["cite",2],["dfn",2],["var",2],["code",4],["kbd",4],["samp",4],["tt",4],["sub",8],["sup",16],["u",32],["ins",32]]),oT=24,aT=new Set("a abbr address article aside audio b bdi bdo big blockquote body br button caption center cite code col colgroup data dd del details dfn dialog div dl dt em embed fieldset figcaption figure font footer form h1 h2 h3 h4 h5 h6 head header hr html i iframe img input ins kbd label legend li link main map mark meta meter nav noscript object ol optgroup option output p picture pre progress q rp rt ruby s samp script section select small source span strike strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr".split(" ")),Uu="\\u2e80-\\u9fff\\uf900-\\ufaff\\uff00-\\uff60",Ig="、。,.:;!?)]}」』】〕〉》〙〗ー…‥・ゝゞぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ,.:;!?)\\]}",cT="([{「『【〔〈《〘〖([{",lT=new RegExp(`[${Uu}]`),Mc="\\u200b\\u00ad",dT=new RegExp(`[${Mc}]`),uT=new RegExp(`\\s*(?:[${cT}]*[${Uu}][${Ig}]*|[^\\s${Uu}${Mc}]+[${Mc}]*[${Ig}]*|[${Mc}]+)\\s*|\\s+`,"g"),Lg=57344,fT=6400,hT=/\$\$(.+?)\$\$/g,Og=/[\ue000-\uf8ff]/,pT=/([\ue000-\uf8ff])/,Ko,mT={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function gT(e){let t=e.split(`
57
+ `),n=1/0;for(let r of t){if(r.trim()==="")continue;let i=r.length-r.trimStart().length;i<n&&(n=i)}return n===1/0||n===0?e:t.map(r=>r.slice(Math.min(n,r.length-r.trimStart().length))).join(`
58
+ `)}function Cc(e){return e!==void 0&&e.icon===void 0&&e.math===void 0}function Bu(e,t,n){if(t!==""){if(Ko!==void 0&&Og.test(t)){let r=Ko,i=t.split(pT);for(let s=0;s<i.length;s++){if(s%2===0){i[s]!==""&&Wu(e,i[s],n);continue}let a=i[s].charCodeAt(0)-Lg,o=r.math[a];o?e.push({text:"",style:n,math:o,width:o.width}):Wu(e,`$$${r.tex[a]}$$`,n)}return}Wu(e,t,n)}}function Wu(e,t,n){let r=gt(t),i=e[e.length-1];Cc(i)&&i.style===n?i.text+=r:e.push({text:r,style:n,width:0})}function bT(e,t,n){if(!t.includes(":fa-")){Bu(e,t,n);return}let r=0;Ng.lastIndex=0;let i;for(;(i=Ng.exec(t))!==null;){let s=`${i[1]}:fa-${i[2]}`;if(Bu(e,t.slice(r,i.index),n),r=i.index+i[0].length,Ri(s)!=="")e.push({text:"",style:n,icon:s,width:0});else if(t[r]===" ")r++;else if(r===t.length){let a=e[e.length-1];Cc(a)&&(a.text=a.text.trimEnd())}}Bu(e,t.slice(r),n)}function yT(e,t,n,r,i){let s=i.style,a=0,o="",c=0,l=t.length,u=()=>{bT(e,o,s|(i.shifts[i.shifts.length-1]??0)),o=""};for(;c<l;){let h=t[c];if(h==="<"){Cg.lastIndex=c;let d=Cg.exec(t);if(d&&d.index===c){let m=d[1].toLowerCase(),p=t[c+1]==="/",y=iT.get(m)??0;if(y&oT){u();let E=i.shifts.lastIndexOf(y);p?E!==-1&&i.shifts.splice(E,1):i.shifts.push(y)}else y&&(u(),i.style=p?i.style&~y|r&y:i.style|y,s=p?s&~y|r&y:s|y);if(y||aT.has(m)){c+=d[0].length;continue}}}else if(n&&(h==="*"||h==="_")){let d=t[c+1]===h,m=d?1:2,p=d?2:1,y=(a&m)===0,E=c>0?t[c-1]:" ",b=c+p<l?t[c+p]:" ",S=y&&b.trim()!==""&&t.indexOf(d?h+h:h,c+p)!==-1,x=!y&&E.trim()!=="",I=h==="_"&&/\w/.test(E)&&/\w/.test(b);if((S||x)&&!I){u(),a=S?a|m:a&~m,s=S?s|m:s&~m|r&m,c+=p;continue}}o+=h,c++}u()}function ET(e,t,n){let r=0;for(let i of e)i.width=i.icon!==void 0?n*1.25:i.math?i.math.width:t.width(i.text,n,i.style),r+=i.width;return r}function Dg(e,t,n,r,i,s){let a=[],o=0,c=(l=!1)=>{let u=a[a.length-1];if(Cc(u)){let h=u.text.trimEnd();if(l&&u.text.endsWith("­")&&(h=h.slice(0,-1)+"-"),h!==u.text){u.text=h;let d=t.width(h,n,u.style);o+=d-u.width,u.width=d}}i.push(a),s.push(o),a=[],o=0};for(let l of e){if(l.icon!==void 0||l.math){let y=l.math?l.math.width:n*1.25;o>0&&o+y>r&&c(),a.push({...l,width:y}),o+=y;continue}let u=l.text.match(uT)??[],h=l.text.includes("­"),d=h?u.length:0,m=new Float64Array(d),p=new Float64Array(d+1);for(let y=d-1;y>=0;y--){let E=u[y].endsWith("­"),b=u[y].trimEnd();m[y]=t.width(E?b.slice(0,-1):b,n,l.style),p[y]=E?y===d-1?l===e[e.length-1]?m[y]:1/0:m[y]+p[y+1]:m[y]}for(let y=0;y<u.length;y++){let E=u[y],b=h?m[y]:t.width(E.trimEnd(),n,l.style),S=!h||!E.endsWith("­")?o+b<=r:o+t.width(E.slice(0,-1)+"-",n,l.style)<=r||o+p[y]<=r;o>0&&!S&&(c(E.trimStart()===E),E=E.trimStart());let x=a[a.length-1];if(Cc(x)&&x.style===l.style){if(x.text+=E,b>0||E.trimEnd()!==E){let I=x.width;x.width=t.width(x.text,n,x.style),o+=x.width-I}}else{let I=t.width(E,n,l.style);a.push({text:E,style:l.style,width:I}),o+=I}}}(a.length>0||i.length===0)&&c()}function Ue(e,t,n,r,i,s=0){if(e===void 0||e==="")return mT;let a=Math.round(r*nT);if(sm()&&e.includes("$$")&&!Og.test(e)){let o={tex:[],math:[]},c=e.replace(hT,(l,u)=>o.tex.length===fT?l:(o.tex.push(u),String.fromCharCode(Lg+o.tex.length-1)));if(o.tex.length>0){for(let l of o.tex)o.math.push(im(gt(l),r));return kg(c,t,n,r,i,s,a,o)}}if(!sT.test(e)&&!e.includes("&")&&!e.includes("fl")){let o=e.trim(),c=n.width(o,r,s);if(c<=i||!(o.includes(" ")||lT.test(o)||dT.test(o)))return{lines:[[{text:o,style:s,width:c}]],widths:[c],width:c,height:a,size:r,lineHeight:a};let l=[],u=[];Dg([{text:o,style:s,width:c}],n,r,i,l,u);let h=0;for(let m of u)m>h&&(h=m);let d=l.length>1?Math.round(r*$g):a;return{lines:l,widths:u,width:h,height:l.length*d,size:r,lineHeight:d}}return kg(e,t,n,r,i,s,a)}function kg(e,t,n,r,i,s,a,o){let c=Ko;Ko=o;try{let l=xT(e,t,n,r,i,s,a);return o?zo(l):l}finally{Ko=c}}function xT(e,t,n,r,i,s,a){let o=t?gT(e.replace(/\r\n?/g,`
59
+ `)).trim():e.trim(),c=[],l=[],u=0,h={style:s,shifts:[]};for(let m of o.split(rT)){let p=[];yT(p,m.trim(),t,s,h);let y=ET(p,n,r);y>i?Dg(p,n,r,i,c,l):(c.push(p),l.push(y))}for(let m of l)m>u&&(u=m);let d=c.length>1?Math.round(r*$g):a;return{lines:c,widths:l,width:u,height:c.length*d,size:r,lineHeight:d}}function zo(e){let t;for(let r=0;r<e.lines.length;r++){let i=e.lineHeight;for(let s of e.lines[r])s.math&&(i=Math.max(i,Math.ceil(s.math.height+e.size/4)));i!==e.lineHeight&&t===void 0&&(t=e.lines.map(()=>e.lineHeight)),t&&(t[r]=i)}if(t===void 0)return e.heights===void 0?e:{...e,heights:void 0,height:e.lines.length*e.lineHeight};let n=0;for(let r of t)n+=r;return{...e,heights:t,height:n}}function Gi(e){for(let t of e)if(t.math)return!0;return!1}function Cr(e,t){let n=e.heights;if(!n)return(t+.5)*e.lineHeight;let r=0;for(let i=0;i<t;i++)r+=n[i];return r+n[t]/2}function Nr(e,t){let n=e.widths[t],r=e.heights?e.heights[t]:e.lineHeight,i={lines:[e.lines[t]],widths:[n],width:n,height:r,size:e.size,lineHeight:e.lineHeight};return r!==e.lineHeight&&(i.heights=[r]),i}function ps(e,t,n,r){let i=r(t,!1),s=e.maxWidth;if(s===void 0||!(s>0)||i.width<=s)return i;let a=Math.min(n,t),o=t;i=r(o,!0);for(let c=0;c<3&&i.width>s&&o>a;c++)o=Math.max(a,o-(i.width-s)),i=r(o,!0);return i}function It(e){let t=e.maxWidth;return t!==void 0&&t>0?Math.max(80,t-2*(e.padding??8)):4e3}function ms(e,t,n,r=0){let i=e.maxWidth;return i===void 0||!(i>0)?t:Math.max(Math.min(n,t),Math.min(t,i-r))}var AT=640;function vt(e,t){let n=t(!1),r=e.maxWidth;if(e.autoDirection===!1||r===void 0||!(r>0)||n.width<=r)return n;let i=e.directionBreakpoint;if(r>=(i!==void 0&&i>0?i:AT))return n;let s=t(!0);return s.width<n.width?s:n}function vn(e){return e==="LR"||e==="RL"}function xn(e,t){let n=t(!1),r=e.maxWidth;if(r===void 0||!(r>0)||n.width<=r)return n;let i=t(!0);return i.width<n.width?i:n}var js=new Map([["tool",0],["task",1],["decision",2],["input",3],["refdoc",4],["connector",5],["action",6]]),vg=js.size,ST=e=>Math.max(1,e-vg),wT=(e,t)=>{let n=vg+e%ST(t);return t>0?n%t:n};function Pg(e,t,n,r){let i=n.size;for(let s of e){if(s.isGroup||s.shape==="collapsedGroup"){s.colorIndex=wT(n.get(s.id)??i++,r);continue}let a=t(s.id);a&&js.has(a)&&(s.kind=a)}}function Fg(e,t,n){let r=[],i=[],s=e.subgraphs,a=b=>{let S=[];for(let x of b){let I=e.classes.get(x);I?.styles&&(S=[...S,...I.styles].map(L=>L.trim())),I?.textStyles&&(S=[...S,...I.textStyles].map(L=>L.trim()))}return S},o=new Set,c=new Map,l=new Set;for(let b of s){if(b.metadata?.view!=="collapsed"||o.has(b.id))continue;let S=[b.id];for(;S.length>0;){let x=e.subgraph(S.pop())?.nodes;if(x!==void 0)for(let I of x)I===b.id||o.has(I)||(o.add(I),c.set(I,b.id),l.has(I)||S.push(I))}l.add(b.id)}let u=new Map;for(let b of o){let S=[b],x=c.get(b);for(;;){let I=u.get(x),L=I??c.get(x);if(L===void 0||(I===void 0&&S.push(x),x=L,I!==void 0))break}for(let I of S)u.set(I,x)}let h=new Map;s.forEach((b,S)=>h.set(b.id,S));let d=new Map,m=(b,S,x)=>{let I=h.get(b);if(I===void 0||I<x)return!1;let L=S;for(let O=0;L!==void 0&&O<=s.length;O++){if(L===b)return!0;L=d.get(L)}return!1};for(let b=s.length-1;b>=0;b--){let S=s[b];if(!o.has(S.id))for(let x of S.nodes){if(m(x,S.id,b)){e.emitWarning("CONTAINMENT_VIOLATION",`Container "${S.id}" cannot contain "${x}" because "${x}" already contains it. The nesting that would close the loop is dropped.`,{nodeId:x});continue}d.set(x,S.id)}}let p=new Map;for(let b=s.length-1;b>=0;b--){let S=s[b];if(o.has(S.id))continue;let x=S.metadata?.view==="collapsed",I={id:S.id,label:S.title,labelType:S.labelType,parentId:d.get(S.id),cssStyles:[],cssCompiledStyles:a(S.classes),cssClasses:S.classes.join(" "),shape:x?"collapsedGroup":"flowGroup",dir:S.dir,isGroup:!x,metadata:x?{...S.metadata,containerType:S.type}:S.metadata};r.push(I),p.set(S.id,I)}for(let b of e.nodes.values()){if(o.has(b.id))continue;let S=p.get(b.id);if(S){S.cssStyles=b.styles,S.cssCompiledStyles=a(b.classes),S.cssClasses=b.classes.join(" ");continue}let x=$i(b.type),I={id:b.id,label:b.text,labelType:b.labelType,parentId:d.get(b.id),cssStyles:b.styles,cssCompiledStyles:a(["default","node",...b.classes]),cssClasses:"default "+b.classes.join(" "),dir:b.dir,link:b.link,linkTarget:b.linkTarget,tooltip:e.tooltips.get(b.id),metadata:b.metadata,isGroup:!1,shape:x==="square"||x===void 0?"squareRect":x};r.push(I),p.set(b.id,I)}e.edges.forEach((b,S)=>{let x=u.get(b.start)??b.start,I=u.get(b.end)??b.end;if(x===I&&b.start!==b.end)return;let L=[...e.defaultEdgeStyle??[]];b.style&&L.push(...b.style);let O=b.type==="arrow_open"?"none":b.type==="arrow_cross"||b.type==="arrow_point"?b.type:"arrow_point";i.push({id:b.id||`L_${x}_${I}_${S}`,isUserDefinedId:b.isUserDefinedId,start:x,end:I,type:b.type??"normal",label:b.text,labelType:b.labelType,thickness:b.stroke,pattern:b.stroke,minlen:b.length,classes:"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:"none",arrowTypeEnd:O,cssCompiledStyles:a(b.classes),style:L,animate:b.animate,animation:b.animation,curve:b.interpolate||e.defaultInterpolate||n,metadata:b.metadata})}),zm(r,e);let y=new Map;for(let b of s){let S=d.get(b.id);if(S===void 0)continue;let x=y.get(S);x?x.push(b.id):y.set(S,[b.id])}let E=new Map;for(let b of s){if(d.get(b.id)!==void 0)continue;let S=[b.id];for(;S.length>0;){let x=S.pop();if(E.has(x))continue;E.set(x,E.size);let I=y.get(x);if(I)for(let L=I.length-1;L>=0;L--)S.push(I[L])}}return Pg(r,b=>{if(e.connectors.has(b))return"connector";let S=e.nodes.get(b);return S?e.vertexKind(S):void 0},E,t),{nodes:r,edges:i}}var _T=8,RT=40,TT=16,MT=48,Vo=20,Gu=26,Nc=14,Yu="collapsed",CT={TB:2,RL:3,BT:0,LR:1},Bg=new WeakMap;function zu(e,t){let n=Bg.get(e);if(n===void 0){let r=t.flowchart?.curve;n=Fg(e,_T,typeof r=="string"?r:void 0),Bg.set(e,n)}return n}function Ic(e,t,n){let r=e.agentflow?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function Hu(e,t,n){let r=yt(e);return` fill="${r}"${Dn(n.shape)?"":` fill-opacity="${t}"`} stroke="${r}"`}function Ug(e,t,n){return vn(e.direction)?vt(n,r=>Wg(e,t,n,r)):Wg(e,t,n,!1)}function Wg(e,t,n,r){let i=zu(e,t),s=n.fontSize??16,a=Math.round(s*.875),o=n.measurer??at(n.fontFamily,n.fontFamilyMono),c=Ic(t,"wrappingWidth",120),l=Ic(t,"minNodeWidth",120),u=n.padding??8,h=n.icons,d=new Map,m=[],p=[];i.nodes.forEach((ne,q)=>d.set(ne.id,q));for(let ne of i.nodes){let q=ne.cssStyles.length>0?ne.cssCompiledStyles.concat(ne.cssStyles):ne.cssCompiledStyles,k=Mt(q),J=(k.bold?1:0)|(k.italic?2:0),te=ne.labelType==="markdown",se=k.fontSize??s,re,P;if(ne.isGroup){let ee=Ue(ne.label,te,o,se,4e3,J);re={node:ne,style:k,label:ee,shape:"group",w:0,h:0,dy:0,loops:0},P=Ft(0,0),P.isGroup=!0,P.dir=ne.dir?cn(ne.dir):void 0,P.padX=Vo,P.padTop=ee.height>0?ee.height+16:Vo,P.padBottom=Vo,P.minW=ee.width+2*Vo-12}else if(ne.shape==="collapsedGroup"){let ee=Ue(ne.label,te,o,se,c,J),ae=Math.max(ee.width,l)+2*Rt,ue=ee.height+2*Tt+Nc;re={node:ne,style:k,label:ee,shape:Yu,w:ae,h:ue,dy:-Nc/2,loops:0},P=Ft(ae,ue)}else{let ee=cc(ne.shape),ae=Ue(ne.label,te,o,se,c,J),ue=hs(ee,ee==="diam"?ae.width:Math.max(ae.width,l),ae.height);re={node:ne,style:k,label:ae,shape:ee,w:ue.w,h:ue.h,dy:ue.dy,loops:0},P=Ft(ue.w,ue.h)}P.seq=m.length,m.push(re),p.push(P)}i.nodes.forEach((ne,q)=>{p[q].parent=ne.parentId!==void 0?d.get(ne.parentId)??-1:-1}),bc(p,i.edges.map(ne=>[d.get(ne.start)??-1,d.get(ne.end)??-1]));let y=r?"TB":cn(e.direction),E=ne=>{let q;for(let k=p[ne].parent,J=0;k>=0&&q===void 0&&J<1e4;k=p[k].parent,J++)q=p[k].dir;return q??y},b=ne=>{let q=E(ne);return q==="LR"||q==="RL"},S=new Int32Array(p.length).fill(-1);for(let ne=0;ne<p.length;ne++){let q=[],k=ne;for(;k>=0&&S[k]<0&&q.length<=p.length;)q.push(k),k=p[k].parent;let J=k>=0?S[k]+1:0;for(let te=q.length-1;te>=0;te--)S[q[te]]=J++}let x=(ne,q)=>{let k=q;for(let J=S[q];J>S[ne];J--)k=p[k].parent;return k===ne&&q!==ne},I=[],L=[],O=[],v=[];for(let ne of i.edges){let q=d.get(ne.start),k=d.get(ne.end);if(q===void 0||k===void 0)continue;let J=Ue(ne.label,ne.labelType==="markdown",o,a,c);if(x(q,k)||x(k,q)){v.push({edge:ne,label:J,src:q,dst:k});continue}q===k&&(m[q].loops++,b(q)?p[q].h+=2*(Gu+(J.height>0?J.height+8:0)):p[q].w+=2*(Gu+(J.width>0?J.width+12:0))),O.push(ne),L.push(J),I.push({src:q,dst:k,minlen:ne.minlen??1,labelW:J.width>0?J.width+12:0,labelH:J.height>0?J.height+4:0,route:[],labelX:0,labelY:0})}let G=Ln(p,I,y,{nodeSep:Ic(t,"nodeSpacing",RT),edgeSep:TT,rankSep:Ic(t,"rankSpacing",MT),portSep:20}),K=Ue(e.title,!1,o,s,4e3,1),C=K.height>0?K.height+12:0,Z=Math.max(G.width,K.width),oe=u+(Z-G.width)/2,H=u+C;Rr(p,I,oe,H);let z=Math.ceil(Z+2*u),M=Math.ceil(G.height+C+2*u),T=[],R=[],_=[],$=[],g=v.length*p.length<2e6;for(let{edge:ne,src:q,dst:k}of v){let J=x(k,q),te=J?k:q,se=J?q:k,re=p[te],P=p[se],ee=CT[re.dir??E(te)],ae=J?ee:ee+2&3,ue=X=>{let le=(X&1)===0,de=X===0||X===3?-1:1,Ae=le?P.x:P.x+de*P.w/2,we=le?P.y+de*P.h/2:P.y,Ee=le?P.x:re.x+de*re.w/2,Te=le?re.y+de*re.h/2:P.y,Me=le?0:1;return J?[Ae,we,Me,Ee,Te,Me]:[Ee,Te,Me,Ae,we,Me]},ce=X=>{for(let le=0;le<p.length;le++){let de=p[le];if(le!==se&&!de.isGroup&&de.x+de.w/2>Math.min(X[0],X[3])-1&&de.x-de.w/2<Math.max(X[0],X[3])+1&&de.y+de.h/2>Math.min(X[1],X[4])-1&&de.y-de.h/2<Math.max(X[1],X[4])+1)return!0}return!1},he=ue(ae);if(g&&ce(he))for(let X of[ae+1&3,ae+3&3,ae+2&3]){let le=ue(X);if(!ce(le)){he=le;break}}$.push(he),_.push((he[0]+he[3])/2,(he[1]+he[4])/2);let V=he.slice();Vs(V,J?0:3,m[se],P),R.push(Mn(V,"linear",0,_t(ne.arrowTypeEnd)))}let N=new Map,w=!1;for(let ne of p)ne.isGroup&&(w=!0);if(w){for(let ne of I)dr(N,ne.route);for(let ne of $)dr(N,ne)}let A="",D="",U=[];for(let ne=0;ne<m.length;ne++){let q=m[ne],k=p[ne],J=q.node,te=k.x,se=k.y,re=Nt(J.cssClasses.replace(/^default\s?/,"")),P=We(J.id);if(k.isGroup){Tn(q.style.shape)&&U.push({box:[te-k.w/2,se-k.h/2,te+k.w/2,se+k.h/2],shape:q.style.shape});let de=fs(k,q.label.width,N,Vo);A+=`<g class="pele-cluster pele-flow${re}" data-id="${P}"><rect x="${f(te-k.w/2)}" y="${f(se-k.h/2)}" width="${f(k.w)}" height="${f(k.h)}"${xt(Hu(J.colorIndex??js.size,"0.06",q.style)+q.style.shape)}/>`+Ce(q.label,de,se-k.h/2+8+q.label.height/2,` class="pele-cluster-label"${Dt(q.style,"var(--_m)")}${q.style.text}`,h)+"</g>";continue}let ee=q.w,ae=q.h,ue="",ce;if(q.shape===Yu){let de=yt(J.colorIndex??js.size),Ae=ae/2-Nc-2,we=Ae+(Nc+2)/2;ce=`<rect x="${f(-ee/2)}" y="${f(-ae/2)}" width="${f(ee)}" height="${f(ae)}"${xt(Hu(J.colorIndex??js.size,"0.06",q.style)+q.style.shape)}/><path d="M${f(-ee/2+10)},${f(Ae)}H${f(ee/2-10)}" fill="none" stroke="${de}" stroke-dasharray="3 3"${q.style.line}/><path class="pele-collapsed-mark" d="${Ku(-9,we)}${Ku(0,we)}${Ku(9,we)}" fill="${de}" stroke="none"/>`}else{let de=js.get(J.kind??"task")??1;ue=` pele-kind-${J.kind??"task"}`,ce=fr(q.shape,ee,ae,Hu(de,"0.14",q.style)+q.style.shape,` stroke="${yt(de)}"`+q.style.line)}let he=q.shape===Yu||Ui(q.shape)?Dt(q.style):"",V=Ce(q.label,0,q.dy,` class="pele-label"${he}${q.style.text}`,h);if(/ internal-link(?: |$)/.test(re+" ")&&J.label&&n.links!==!1){let de=gt(J.label),Ae=ki(de,n),we=nt(de);V=`<a class="internal-link"${Ae?` href="${we}"${Xr(n)}`:""} data-href="${we}">${V}</a>`,T.push({id:J.id,href:de,internal:!0})}let le=ce+V;J.tooltip&&(le=`<title>${We(J.tooltip)}</title>`+le),J.link&&(le=Qn(le,J.link,J.id,T,n,J.linkTarget?` target="${nt(J.linkTarget)}"`:"")),D+=`<g class="pele-node pele-shape-${q.shape}${ue}${re}" data-id="${P}" transform="translate(${f(te)},${f(se)})">${le}</g>`}let B="",F="",W="",j=(ne,q,k,J,te)=>{let se=ne.style.length>0||ne.cssCompiledStyles.length>0?Mt(ne.cssCompiledStyles.concat(ne.style)):void 0,re=ne.arrowTypeEnd,P=Tr(k.d,[k.ex,k.ey],U,se?.line,k.tokens),ee=P||(se?.stroke?nt(se.stroke):"var(--_l)"),ae=ne.thickness==="dotted"?"reference":re==="arrow_cross"?"failure":"sequence",ue=Nt(ne.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));P===""&&(B+=Mr(k,"none",re,se?.line)),F+=`<g class="pele-edge pele-edge-${ae}${ue}" data-id="${We(ne.id)}"${P?` stroke="${P}"`:""}${se?.line??""}><path d="${k.d}"${ne.thickness==="dotted"?' stroke-dasharray="3 4"':""}/>`+wt(re,k.ex,k.ey,k.edx,k.edy,ee)+"</g>",q.width>0&&(W+=ln(ne.id,q,J,te,se?.text??"",h))},Q=new Map;for(let ne=0;ne<I.length;ne++){let q=I[ne],k=O[ne],J=L[ne],te=k.arrowTypeEnd,se;if(q.src===q.dst){let re=m[q.src],P=Q.get(q.src)??0;Q.set(q.src,P+1),se=Sc(p[q.src],re.w,re.h,P,b(q.src),Gu,_t(te),q)}else{let re=q.route.slice();Vs(re,0,m[q.src],p[q.src]),Vs(re,re.length-3,m[q.dst],p[q.dst]),se=Mn(re,k.curve,0,_t(te))}j(k,J,se,q.labelX,q.labelY)}return v.forEach((ne,q)=>j(ne.edge,ne.label,R[q],_[2*q],_[2*q+1])),{svg:ot("agentflow",z,M,s,n,e,Ce(K,z/2,u+K.height/2,' class="pele-title" font-weight="var(--_tw)"')+(A?`<g class="pele-clusters">${A}</g>`:"")+On(B)+(F?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${F}</g>`:"")+(W?`<g class="pele-edge-labels" font-size="${a}">${W}</g>`:"")+`<g class="pele-nodes">${D}</g>`),width:z,height:M,links:T}}function Ku(e,t){return`M${f(e-1.75)},${f(t)}a1.75,1.75 0 1 0 3.5,0a1.75,1.75 0 1 0 -3.5,0Z`}var Gg={type:"agentflow",keepComments:!0,parse(e,t,n,r,i){let s=t.flowchart??{},a=new dc({inheritDir:s.inheritDir===!0,direction:typeof t.direction=="string"?t.direction:void 0,lineOffset:r,source:e,maxEdges:i.maxEdges});return n&&(a.title=n),tg(e,a),zu(a,t),a},render:Ug};function Ir(e){throw new qe(e,"semantic",{type:"architecture"})}var kc=class{type="architecture";title;accTitle;accDescr;nodes=new Map;groups=new Map;edges=[];layoutHints=[];registered=new Map;register(t,n,r){this.registered.has(n)&&Ir(`The ${t} id [${n}] is already in use by another ${this.registered.get(n)}`),r!==void 0&&(n===r&&Ir(`The ${t} [${n}] cannot be placed within itself`),this.registered.has(r)||Ir(`The ${t} [${n}]'s parent does not exist. Please make sure the parent is created before this ${t}`),this.registered.get(r)==="node"&&Ir(`The ${t} [${n}]'s parent is not a group`)),this.registered.set(n,t==="group"?"group":"node")}addService({id:t,icon:n,iconText:r,title:i,in:s}){this.register("service",t,s),this.nodes.set(t,{id:t,type:"service",icon:n,iconText:r,title:i,in:s})}addJunction({id:t,in:n}){this.register("junction",t,n),this.nodes.set(t,{id:t,type:"junction",in:n})}addGroup({id:t,icon:n,title:r,in:i}){this.register("group",t,i),this.groups.set(t,{id:t,icon:n,title:r,in:i})}addEdge({lhsId:t,rhsId:n,lhsDir:r,rhsDir:i,lhsInto:s,rhsInto:a,lhsGroup:o,rhsGroup:c,title:l}){let u=[["left",t,o],["right",n,c]];for(let[d,m]of u)this.registered.has(m)||Ir(`The ${d}-hand id [${m}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[d,m]of u)this.nodes.has(m)||Ir(`The ${d}-hand id [${m}] is a group. Add {group} to a service inside it instead.`);let h=this.nodes.get(t).in;if(h!==void 0&&h===this.nodes.get(n).in)for(let[d,m,p]of u)p&&Ir(`The ${d}-hand id [${m}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);this.edges.push({lhsId:t,lhsDir:r,lhsInto:s,lhsGroup:o,rhsId:n,rhsDir:i,rhsInto:a,rhsGroup:c,title:l})}addLayoutHint(t){t.members.length<2&&Ir(`An align directive requires at least two members; got ${t.members.length}`);let n=new Set;for(let r of t.members)this.registered.get(r)!=="node"&&Ir(`align ${t.direction} references [${r}], which is not a service or junction`),n.has(r)&&Ir(`align ${t.direction} lists [${r}] more than once`),n.add(r);this.layoutHints.push(t)}};function Yg(e,t){e.accDescr&&(t.accDescr=e.accDescr.replace(/\n\s+/g,`
60
+ `)),e.accTitle&&(t.accTitle=e.accTitle.replace(/^\s+/g,"")),e.title&&(t.title=e.title);for(let n of e.groups)t.addGroup(n);for(let n of e.services)t.addService(n);for(let n of e.junctions)t.addJunction(n);for(let n of e.edges)t.addEdge(n);for(let n of e.alignments)t.addLayoutHint({direction:n.direction,members:[...n.members]})}var Hg=new WeakMap;function NT(e){let t=e.map((i,s)=>s),n=[];for(let i=0;i<128;i++){let s=String.fromCharCode(i);n.push(t.filter(a=>{let{pattern:o,first:c}=e[a];return typeof o=="string"?o[0]===s:c===void 0||c.includes(s)}))}let r={starting:n,every:t,longer:e.map(i=>i.longer?.map(s=>e.indexOf(s)))};return Hg.set(e,r),r}function Gt(e,t,n){let r=[],i=[],s=[],a=new Uint8Array(t.length),{starting:o,every:c,longer:l}=Hg.get(t)??NT(t),u=[],h=e.length,d=(p,y)=>{if(a[p])return-1;let E=t[p];if(E.match!==void 0)return E.match(e,y,r[r.length-1]??-1);if(E.scanner!==void 0)return(u[p]??=E.scanner())(e,y,r[r.length-1]??-1);let b=E.pattern;return typeof b=="string"?e.startsWith(b,y)?y+b.length:-1:(b.lastIndex=y,b.test(e)?b.lastIndex:(E.opener!==void 0&&(E.opener.lastIndex=y,E.opener.test(e)&&(a[p]=1)),-1))},m=0;e:for(;m<h;){let p=e.charCodeAt(m);for(let y of p<128?o[p]:c){let E=d(y,m);if(E<=m)continue;let b=y,S=l[y];if(S!==void 0)for(let x of S){let I=d(x,m);if(I>E){b=x,E=I;break}}t[b].hidden||(r.push(b),i.push(m),s.push(E)),m=E;continue e}throw ut(n,e,m,"",!0)}return r.push(-1),i.push(h),s.push(h),{kinds:r,starts:i,ends:s,src:e}}var rn={name:"ACC_DESCR",pattern:/[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:" a"},jt={name:"ACC_TITLE",pattern:/[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:" a"},hr={name:"TITLE",pattern:/[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:" t"};function Jn(e){return{...hr,pattern:new RegExp(String.raw`[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|(?!${e}))`,"y")}}var Pn={name:"STRING",pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`},An={name:"NEWLINE",pattern:/\r?\n/y,first:`\r
61
+ `},Sn={name:"WHITESPACE",pattern:/[\t ]+/y,hidden:!0,first:" "},Yt={name:"YAML",pattern:/---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/y,hidden:!0,opener:/---[\t ]*\r?\n/y,first:"-"},qt={name:"DIRECTIVE",pattern:/[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/y,hidden:!0,opener:/[\t ]*%%{/y,first:" %"},Qt={name:"SINGLE_LINE_COMMENT",pattern:/[\t ]*%%[^\n\r]*/y,first:" %",hidden:!0};function Zt(e){return{name:e,pattern:new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"(?:(?=%%)|(?!\\S))","y"),first:e[0]}}var IT=/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,kT=/accTitle[\t ]*:([^\n\r]*)/,$T=/title([\t ][^\n\r]*|)/;function Vu(e){return e.trim().replace(/[\t ]{2,}/gm," ")}function Ht(e){return Vu($T.exec(e)[1])}function Kt(e){return Vu(kT.exec(e)[1])}function zt(e){let t=IT.exec(e);return t[1]!==void 0?Vu(t[1]):t[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,`
62
+ `)}var LT=new Map([["b","\b"],["f","\f"],["n",`
63
+ `],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function dn(e){if(!e.includes("\\"))return e.slice(1,-1);let t="";for(let n=1;n<e.length-1;n++){let r=e[n];if(r==="\\"){let i=e[++n];t+=LT.get(i)??i}else t+=r}return t}var Wt=class{constructor(t,n,r){this.tokens=t;this.types=n;this.diagram=r;this.kinds=t.kinds}tokens;types;diagram;i=0;kinds;get kind(){return this.kinds[this.i]}text(t=this.i){return this.tokens.src.slice(this.tokens.starts[t],this.tokens.ends[t])}take(){return this.text(this.i++)}accept(t){return this.kinds[this.i]!==t?!1:(this.i++,!0)}expect(t){return this.kinds[this.i]!==t&&this.fail(`token of type '${this.types[t].name}'`),this.take()}fail(t){let n=this.kind===-1?"end of input":`\`${this.text()}\``,{src:r,starts:i,ends:s}=this.tokens,a=i[this.i];if(this.kind===-1){let o=this.i;for(;o>0&&r.slice(i[o-1],s[o-1]).trim()==="";)o--;o>0&&(a=s[o-1])}throw ut(this.diagram,r,a,`Expecting ${t} but found ${n}.`)}};var zg={name:"ID",pattern:/[\w]([-\w]*\w)?/y};function gs(e){return{name:e,pattern:e,longer:[zg]}}var Kg=[gs("architecture-beta"),gs("junction"),gs("service"),gs("column"),gs("group"),gs("align"),gs("row"),{name:"--",pattern:"--",longer:[Yt]},gs("in"),{name:":",pattern:":"},{name:"-",pattern:"-",longer:[Yt]},{name:"ARROW_DIRECTION",pattern:/L|R|T|B/y},{name:"ARROW_GROUP",pattern:/\{group\}/y},{name:"ARROW_INTO",pattern:/<|>/y},rn,jt,Jn(String.raw`[-\w]*\w`),Pn,zg,An,Sn,Yt,qt,Qt,{name:"ARCH_ICON",pattern:/\([\w-:]+\)/y},{name:"ARCH_TITLE",pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];function ju(e){let t=e.slice(1,-1).trim();return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).replace(/\\"/g,'"').replace(/\\'/g,"'")),t.trim()}function Vg(e){let t=new Wt(Gt(e,Kg,"architecture"),Kg,"architecture"),n={$type:"Architecture",groups:[],services:[],junctions:[],edges:[],alignments:[]},r=s=>t.kinds[t.i]===s,i=()=>{if(t.kind!==-1)for(t.kind!==19&&t.fail("a line break or the end of input");t.kind===19;)t.i++};for(;t.kind===19;)t.i++;for(t.expect(0);t.kind!==-1;){switch(t.kind){case 19:t.i++;continue;case 14:n.accDescr=zt(t.take());break;case 15:n.accTitle=Kt(t.take());break;case 16:n.title=Ht(t.take());break;case 4:{t.i++;let s={$type:"Group",id:t.expect(18)};r(24)&&(s.icon=t.take().slice(1,-1)),r(25)&&(s.title=ju(t.take())),t.accept(8)&&(s.in=t.expect(18)),n.groups.push(s);break}case 2:{t.i++;let s={$type:"Service",id:t.expect(18)};r(17)?s.iconText=dn(t.take()):r(24)&&(s.icon=t.take().slice(1,-1)),r(25)&&(s.title=ju(t.take())),t.accept(8)&&(s.in=t.expect(18)),n.services.push(s);break}case 1:{t.i++;let s={$type:"Junction",id:t.expect(18)};t.accept(8)&&(s.in=t.expect(18)),n.junctions.push(s);break}case 18:{let s=t.take(),a=t.accept(12);t.expect(9);let o=t.expect(11),c=t.accept(13),l;t.accept(7)||(r(10)||t.fail("'--' or '-'"),t.i++,l=ju(t.expect(25)),t.expect(10));let u=t.accept(13),h=t.expect(11);t.expect(9);let d=t.expect(18),m=t.accept(12);n.edges.push({$type:"Edge",lhsId:s,lhsGroup:a,lhsDir:o,lhsInto:c,title:l,rhsInto:u,rhsDir:h,rhsId:d,rhsGroup:m});break}case 5:{t.i++,!r(6)&&!r(3)&&t.fail("'row' or 'column'");let s=t.take(),a=[t.expect(18),t.expect(18)];for(;r(18);)a.push(t.take());n.alignments.push({$type:"Alignment",direction:s,members:a});break}default:t.fail("a group, a service, a junction, an edge, an alignment, a title, or a line break")}i()}return n}var OT=new Map([["database","M4 6a8 3 0 1 0 16 0a8 3 0 1 0-16 0M4 6v12a8 3 0 0 0 16 0V6M4 12a8 3 0 0 0 16 0"],["server","M3 4h18v7H3zM3 13h18v7H3zM7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6"],["disk","M5 3h14v18H5zM12 6.5a4 4 0 1 0 0 8a4 4 0 1 0 0-8M12 10.5h.01M8 18h3"],["internet","M3 12a9 9 0 1 0 18 0a9 9 0 1 0-18 0M3 12h18M12 3a13 13 0 0 0 0 18M12 3a13 13 0 0 1 0 18"],["cloud","M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9.5a4.25 4.25 0 0 1-.5 8.5z"]]);function jg(e){let t=OT.get(e);return t===void 0?"":`<path d="${t}" stroke="var(--_fg)" stroke-width="1.5"/>`}var jo=[-1,1,0,0],$c=[0,0,-1,1];function Xo(e){return e==="L"?0:e==="R"?1:e==="T"?2:3}var Xg=64,Lc=2**25,qg=2**26;function Qg(e,t,n,r){let i=e.length,s=t.length,a=s,o=new Map,c=new Map,l=new Int32Array(i+s).fill(a),u=new Int32Array(s+1),h=[];for(let Y=0;Y<=s;Y++)h.push([]);t.forEach((Y,ne)=>{c.set(Y.id,ne);let q=Y.in===void 0?void 0:c.get(Y.in);q!==void 0&&q!==ne?(l[i+ne]=q,u[ne]=u[q]+1):u[ne]=1}),e.forEach((Y,ne)=>{o.set(Y.id,ne);let q=Y.in===void 0?void 0:c.get(Y.in);q!==void 0&&(l[ne]=q),h[l[ne]].push(ne)});for(let Y=0;Y<s;Y++)h[l[i+Y]].push(i+Y);let d=[],m=[],p=[],y=[],E=[],b=[],S=new Array(i+s),x=new Array(i+s),I=(Y,ne,q,k,J)=>{if(Y===ne)return;let te=Y,se=ne,re=l[Y],P=l[ne];for(;re!==P;)u[re]>=u[P]?(te=i+re,re=l[te]):(se=i+P,P=l[se]);let ee=d.length;d.push(Y),m.push(ne),p.push(q),y.push(k),E.push(te),b.push(se),(J[te]??=[]).push(ee),(J[se]??=[]).push(ee)};for(let Y of r){let ne=Y.direction==="row";for(let q=1;q<Y.members.length;q++){let k=o.get(Y.members[q-1]),J=o.get(Y.members[q]);k!==void 0&&J!==void 0&&I(k,J,ne?1:3,ne?0:2,S)}}for(let Y of[!1,!0])for(let ne of n){if(ne.lhsDir===ne.rhsDir!==Y)continue;let q=o.get(ne.lhsId),k=o.get(ne.rhsId);q!==void 0&&k!==void 0&&I(q,k,Xo(ne.lhsDir),Xo(ne.rhsDir),x)}let L=new Int32Array(i+s),O=new Int32Array(i+s),v=new Int32Array(i+s).fill(1),G=new Int32Array(i+s).fill(1),K=new Uint8Array(i+s),C=[],Z=new Map,oe=[],H=new Map,z=0,M=0,T=0,R=(Y,ne)=>{M=0,T=0;for(let q=Y;q!==ne;q=i+l[q])M+=L[q],T+=O[q]},_=(Y,ne,q)=>{if(L[Y]=ne,O[Y]=q,K[Y]=1,C.push(Y),v[Y]*G[Y]>Xg){oe.push(Y);return}for(let k=q;k<q+G[Y];k++)for(let J=ne;J<ne+v[Y];J++)Z.set((J+Lc)*qg+k+Lc,Y)},$=(Y,ne,q,k,J)=>L[Y]<ne+k&&ne<L[Y]+v[Y]&&O[Y]<q+J&&q<O[Y]+G[Y],g=(Y,ne,q,k)=>{if(q*k>Xg){for(let J=z;J<C.length;J++)if($(C[J],Y,ne,q,k))return C[J];return-1}for(let J=ne;J<ne+k;J++)for(let te=Y;te<Y+q;te++){let se=Z.get((te+Lc)*qg+J+Lc);if(se!==void 0)return se}for(let J of oe)if($(J,Y,ne,q,k))return J;return-1},N=(Y,ne,q,k,J,te)=>{let se=`${Y},${ne},${q},${k},${J},${te}`,re=H.get(se)??0;for(;;){let P=g(Y+re*J,ne+re*te,q,k);if(P<0)break;re=J>0?L[P]+v[P]-Y:J<0?Y+q-L[P]:te>0?O[P]+G[P]-ne:ne+k-O[P]}return H.set(se,re),re},w=(Y,ne)=>{let q=E[ne]===Y,k=q?b[ne]:E[ne];if(K[k])return;let J=q?p[ne]:y[ne],te=q?y[ne]:p[ne];R(q?d[ne]:m[ne],Y);let se=M,re=T;R(q?m[ne]:d[ne],k);let P=jo[J],ee=$c[J],ae=0,ue=0,ce=jo[J]+jo[te]===0&&$c[J]+$c[te]===0;J===te?(P=jo[J]===0?1:0,ee=1-P):ce||(ae=-jo[te],ue=-$c[te]);let he,V;if(P!==0?(he=P>0?L[Y]+v[Y]:L[Y]-v[k],V=O[Y]+re+ue-T):(V=ee>0?O[Y]+G[Y]:O[Y]-G[k],he=L[Y]+se+ae-M),ce){let X=x[k];if(X!==void 0&&X.length>1){let Te=[];for(let Me of X){let Ie=b[Me]===k,ge=Ie?E[Me]:b[Me];if(!K[ge]||(Ie?p[Me]:y[Me])!==J||(Ie?y[Me]:p[Me])!==te)continue;R(Ie?d[Me]:m[Me],ge);let xe=P!==0?O[ge]+T:L[ge]+M;R(Ie?m[Me]:d[Me],k),Te.push(xe-(P!==0?T:M))}Te.length>1&&(Te.sort((Me,Ie)=>Me-Ie),P!==0?V=Te[Te.length-1>>1]:he=Te[Te.length-1>>1])}let le=P===0?1:0,de=1-le,Ae=N(he,V,v[k],G[k],le,de),we=Ae===0?0:N(he,V,v[k],G[k],-le,-de),Ee=Ae<=we?Ae:-we;he+=le*Ee,V+=de*Ee}else{let X=N(he,V,v[k],G[k],P,ee);he+=P*X,V+=ee*X}_(k,he,V)},A=Y=>{let ne=h[Y];if(ne.length===0)return;C.length=0;let q=[];for(let X of ne){if(K[X])continue;z=C.length,q.push(z),Z.clear(),oe.length=0,H.clear(),_(X,0,0);let le=z,de=z,Ae=0;for(;;){if(le<C.length){let Ee=C[le++],Te=S[Ee];if(Te!==void 0)for(let Me of Te)w(Ee,Me);continue}if(de>=C.length)break;let we=x[C[de]];if(we===void 0||Ae>=we.length){de++,Ae=0;continue}w(C[de],we[Ae++])}}q.push(C.length);let k=q.length-1,J=new Array(k),te=new Array(k),se=new Array(k),re=new Array(k),P=0,ee=0;for(let X=0;X<k;X++){let le=1/0,de=1/0,Ae=-1/0,we=-1/0;for(let Ee=q[X];Ee<q[X+1];Ee++){let Te=C[Ee];le=Math.min(le,L[Te]),de=Math.min(de,O[Te]),Ae=Math.max(Ae,L[Te]+v[Te]),we=Math.max(we,O[Te]+G[Te])}J[X]=le,te[X]=de,se[X]=Ae-le,re[X]=we-de,P+=se[X]*re[X],ee=Math.max(ee,se[X])}let ae=Math.max(ee,Math.ceil(Math.sqrt(P*2))),ue=0,ce=0,he=0,V=0;for(let X=0;X<k;X++){ue>0&&ue+se[X]>ae&&(ce+=he,ue=0,he=0);for(let le=q[X];le<q[X+1];le++)L[C[le]]+=ue-J[X],O[C[le]]+=ce-te[X];ue+=se[X],he=Math.max(he,re[X]),V=Math.max(V,ue)}Y<s&&(v[i+Y]=V,G[i+Y]=ce+he)};for(let Y=s-1;Y>=0;Y--)A(Y);A(a);let D=new Int32Array(s),U=new Int32Array(s),B=new Int32Array(s),F=new Uint8Array(s);for(let Y=0;Y<s;Y++){let ne=l[i+Y];B[Y]=ne===a?-1:ne,D[Y]=L[i+Y]+(ne===a?0:D[ne]),U[Y]=O[i+Y]+(ne===a?0:U[ne]),h[Y].length===0&&(F[Y]=1)}let W=new Int32Array(i),j=new Int32Array(i),Q=new Int32Array(i);for(let Y=0;Y<i;Y++){let ne=l[Y];Q[Y]=ne===a?-1:ne,W[Y]=L[Y]+(ne===a?0:D[ne]),j[Y]=O[Y]+(ne===a?0:U[ne])}return{col:W,row:j,groupCol:D,groupRow:U,groupCols:v.slice(i),groupRows:G.slice(i),groupParent:B,groupEmpty:F,nodeParent:Q}}var Nn=12,DT=6,Zg=4,Jg=3,vT=[-1,1,0,0],PT=[0,0,-1,1];function Xu(e,t,n,r,i){let s=e.architecture,a=s!==null&&typeof s=="object"&&!Array.isArray(s)?s[t]:void 0;return typeof a=="number"&&Number.isFinite(a)?Math.min(i,Math.max(r,a)):n}function eb(e){let t=new Map;for(let n of e.sort((r,i)=>r-i))t.has(n)||t.set(n,t.size);return t}function tb(e,t,n,r,i){return`<svg class="pele-icon" data-icon="${We(e)}" x="${f(t)}" y="${f(n)}" width="${f(r)}" height="${f(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??jg(e)}</svg>`}function FT(e,t,n,r){let i=e.lines.length>n;if(!i&&e.width<=t)return e;let s=r.width("…",e.size,0),a=[],o=[],c=0;for(let l=0;l<Math.min(n,e.lines.length);l++){let u=e.lines[l].map(d=>({...d})),h=e.widths[l];if(h>t||i&&l===n-1)for(;;){let d=u[u.length-1];if(d===void 0){u.push({text:"…",style:0,width:s}),h=s;break}let m=h-d.width;if(d.icon===void 0&&m+s<t){let p=0,y=d.text.length;for(;p<y;){let b=p+y+1>>1;m+r.width(d.text.slice(0,b),e.size,d.style)+s<=t?p=b:y=b-1}let E=p>0?d.text.charCodeAt(p-1):0;E>=55296&&E<=56319&&p--,d.text=d.text.slice(0,p).trimEnd()+"…",d.width=r.width(d.text,e.size,d.style),h=m+d.width;break}u.pop(),h=m}a.push(u),o.push(h),c=Math.max(c,h)}return{...e,lines:a,widths:o,width:c,height:a.length*e.lineHeight}}function BT(e,t){let{x:n,y:r,dx:i,dy:s}=e,{x:a,y:o,dx:c,dy:l}=t,u=n+i*Nn,h=r+s*Nn,d=a+c*Nn,m=o+l*Nn;if(i*c+s*l===0){let b=i!==0?a:n,S=i!==0?r:o;return(b-n)*i+(S-r)*s>0&&(b-a)*c+(S-o)*l>0?[n,r,b,S,a,o]:i!==0?[n,r,u,h,u,m,d,m,a,o]:[n,r,u,h,d,h,d,m,a,o]}let p=i!==0,y=p?o-r:a-n;if(i===-c&&s===-l){if((a-n)*i+(o-r)*s>0){if(Math.abs(y)<.5)return[n,r,a,o];if(p){let L=i>0?e.x1:t.x1,O=i>0?t.x0:e.x0,v=L<O?(L+O)/2:(n+a)/2;return[n,r,v,r,v,o,a,o]}let S=s>0?e.y1:t.y1,x=s>0?t.y0:e.y0,I=S<x?(S+x)/2:(r+o)/2;return[n,r,n,I,a,I,a,o]}}else if(Math.abs(y)>=1){if(p){let S=i>0?Math.max(n,a)+Nn:Math.min(n,a)-Nn;return[n,r,S,r,S,o,a,o]}let b=s>0?Math.max(r,o)+Nn:Math.min(r,o)-Nn;return[n,r,n,b,a,b,a,o]}if(p){let b=e.y1+Nn<=t.y0?(e.y1+t.y0)/2:t.y1+Nn<=e.y0?(t.y1+e.y0)/2:Math.max(e.y1,t.y1)+Nn;return[n,r,u,r,u,b,d,b,d,o,a,o]}let E=e.x1+Nn<=t.x0?(e.x1+t.x0)/2:t.x1+Nn<=e.x0?(t.x1+e.x0)/2:Math.max(e.x1,t.x1)+Nn;return[n,r,n,h,E,h,E,m,a,m,a,o]}function WT(e){let t=[e[0],e[1]];for(let n=2;n<e.length;n+=2){let r=e[n],i=e[n+1],s=t.length,a=Math.abs(r-t[s-2])<.01,o=Math.abs(i-t[s-1])<.01;a&&o||(s>=4&&(a&&Math.abs(t[s-4]-t[s-2])<.01||o&&Math.abs(t[s-3]-t[s-1])<.01)?(t[s-2]=r,t[s-1]=i):t.push(r,i))}return t}function UT(e,t,n){let r=e.length/2,i=new Array(r),s=new Array(r);for(let c=0;c<r;c++)i[c]=e[c*2],s[c]=e[c*2+1];let a=(c,l,u)=>{let h=Math.hypot(i[l]-i[c],s[l]-s[c]),d=Math.min(u,Math.max(0,h-1));h>0&&d>0&&(i[c]+=(i[l]-i[c])/h*d,s[c]+=(s[l]-s[c])/h*d)};a(0,1,t),a(r-1,r-2,n);let o=`M${f(i[0])},${f(s[0])}`;for(let c=1;c<r-1;c++){let l=Math.hypot(i[c]-i[c-1],s[c]-s[c-1]),u=Math.hypot(i[c+1]-i[c],s[c+1]-s[c]),h=Math.min(DT,l/2,u/2);if(h<.5){o+=`L${f(i[c])},${f(s[c])}`;continue}let d=i[c]-(i[c]-i[c-1])/l*h,m=s[c]-(s[c]-s[c-1])/l*h,p=i[c]+(i[c+1]-i[c])/u*h,y=s[c]+(s[c+1]-s[c])/u*h;o+=`L${f(d)},${f(m)}Q${f(i[c])},${f(s[c])} ${f(p)},${f(y)}`}return o+`L${f(i[r-1])},${f(s[r-1])}`}function nb(e,t,n){return xn(n,r=>GT(e,t,n,r))}function GT(e,t,n,r){let i=Xu(t,"iconSize",48,8,512),s=Xu(t,"fontSize",n.fontSize??16,4,128),a=Math.min(Xu(t,"padding",20,0,256),r?12:1/0),o=Math.round(s*.875),c=n.measurer??at(n.fontFamily,n.fontFamilyMono),l=n.padding??8,u=n.icons,h=i/2,d=[...e.nodes.values()],m=[...e.groups.values()],p=d.length,y=m.length,E=Qg(d,m,e.edges,e.layoutHints),b=new Map;d.forEach((me,$e)=>b.set(me.id,$e));let S=new Array(p),x=new Float64Array(p),I=new Float64Array(p),L=r?Math.max(i,64):Math.max(i*2.25,96);for(let me=0;me<p;me++){let $e=d[me],Pe=Ue($e.type==="service"?$e.title:void 0,!0,c,s,L);S[me]=Pe,x[me]=Math.max(i,2*Math.ceil(Pe.width/2)),I[me]=i+(Pe.height>0?Zg+Pe.height:0)}let O=[],v=[];for(let me=0;me<p;me++)O.push(E.col[me]),v.push(E.row[me]);for(let me=0;me<y;me++)E.groupEmpty[me]&&(O.push(E.groupCol[me]),v.push(E.groupRow[me]));let G=eb(O),K=eb(v),C=G.size,Z=K.size,oe=new Float64Array(C),H=new Float64Array(Z),z=r?Math.max(24,2*Nn):Math.max(40,Math.round(i*.75)),M=new Float64Array(C).fill(z),T=new Float64Array(Z).fill(z),R=new Int32Array(p),_=new Int32Array(p);for(let me=0;me<p;me++){let $e=R[me]=G.get(E.col[me]),Pe=_[me]=K.get(E.row[me]);oe[$e]=Math.max(oe[$e],x[me]),H[Pe]=Math.max(H[Pe],I[me])}for(let me=0;me<y;me++){if(!E.groupEmpty[me])continue;let $e=G.get(E.groupCol[me]),Pe=K.get(E.groupRow[me]);oe[$e]=Math.max(oe[$e],i),H[Pe]=Math.max(H[Pe],h)}let $=e.edges.length,g=new Array($),N=new Int32Array($*2);for(let me=0;me<$;me++){let $e=e.edges[me],Pe=N[me*2]=b.get($e.lhsId)??-1,ze=N[me*2+1]=b.get($e.rhsId)??-1,Le=Ue($e.title,!0,c,o,160);if(g[me]=Le,!(Le.width===0||Pe<0||ze<0)){if(R[Pe]!==R[ze]){let Ve=Math.min(R[Pe],R[ze]);M[Ve]=Math.max(M[Ve],Math.ceil(Le.width)+28)}else if(oe[R[Pe]]=Math.max(oe[R[Pe]],2*Math.ceil(Le.width/2)+8),_[Pe]!==_[ze]){let Ve=Math.min(_[Pe],_[ze]);T[Ve]=Math.max(T[Ve],Math.ceil(Le.height)+24)}}}let w=new Array(y),A=new Int32Array(y),D=new Int32Array(y),U=new Int32Array(y),B=new Int32Array(y),F=new Float64Array(y),W=new Float64Array(y),j=new Float64Array(y),Q=new Float64Array(y),Y=new Float64Array(y),ne=new Float64Array(y),q=new Float64Array(C),k=new Float64Array(C),J=new Float64Array(Z),te=new Float64Array(Z),se=Math.round(s*1.25);for(let me=0;me<y;me++){A[me]=G.get(E.groupCol[me]),D[me]=G.get(E.groupCol[me]+E.groupCols[me]-1),U[me]=K.get(E.groupRow[me]),B[me]=K.get(E.groupRow[me]+E.groupRows[me]-1);let $e=Ue(m[me].title,!0,c,s,r?Math.max(80,It(n)/2):320);w[me]=$e;let Pe=m[me].icon?se:0;Y[me]=$e.width+Pe+($e.width>0&&Pe>0?6:0),ne[me]=Math.max($e.height,Pe)}for(let me=y-1;me>=0;me--){let $e=a+F[me],Pe=a+W[me],ze=(ne[me]>0?Math.max(a,ne[me]+12):a)+j[me],Le=a+Q[me];if(Y[me]>0){let Ze=$e+Pe;for(let ke=A[me];ke<=D[me];ke++)Ze+=oe[ke]+(ke<D[me]?k[ke]+M[ke]+q[ke+1]:0);Y[me]+20>Ze&&(Pe+=Math.ceil(Y[me]+20-Ze))}F[me]=$e,W[me]=Pe,j[me]=ze,Q[me]=Le,q[A[me]]=Math.max(q[A[me]],$e),k[D[me]]=Math.max(k[D[me]],Pe),J[U[me]]=Math.max(J[U[me]],ze),te[B[me]]=Math.max(te[B[me]],Le);let Ve=E.groupParent[me];Ve<0||(A[Ve]===A[me]&&(F[Ve]=Math.max(F[Ve],$e)),D[Ve]===D[me]&&(W[Ve]=Math.max(W[Ve],Pe)),U[Ve]===U[me]&&(j[Ve]=Math.max(j[Ve],ze)),B[Ve]===B[me]&&(Q[Ve]=Math.max(Q[Ve],Le)))}let re=new Float64Array(C),P=new Float64Array(Z),ee=0;for(let me=0;me<C;me++)re[me]=ee+q[me],ee=re[me]+oe[me]+k[me]+(me<C-1?M[me]:0);let ae=0;for(let me=0;me<Z;me++)P[me]=ae+J[me],ae=P[me]+H[me]+te[me]+(me<Z-1?T[me]:0);let ue=0,ce=0,he=ee,V=ae,X=me=>re[A[me]]-F[me],le=me=>re[D[me]]+oe[D[me]]+W[me],de=me=>P[U[me]]-j[me],Ae=me=>P[B[me]]+H[B[me]]+Q[me],we=me=>re[R[me]]+oe[R[me]]/2,Ee=(me,$e,Pe)=>{let ze=vT[$e],Le=PT[$e],Ve=we(me),Ze=P[_[me]],ke={x:Ve,y:Ze+h,dx:ze,dy:Le,x0:Ve-x[me]/2,y0:Ze,x1:Ve+x[me]/2,y1:Ze+I[me],gap:0,wire:!1};d[me].type==="junction"?(ke.x0=ke.x1=Ve,ke.y0=ke.y1=ke.y,ke.gap=Jg):ze!==0?ke.x=Ve+ze*h:ke.y=Le<0?Ze:Ze+I[me]+(S[me].height>0?2:0);let Qe=Pe?E.nodeParent[me]:-1;return Qe>=0&&(ke.x0=X(Qe),ke.x1=le(Qe),ke.y0=de(Qe),ke.y1=Ae(Qe),ke.gap=0,ke.wire=d[me].type==="junction",ze!==0?ke.x=ze<0?ke.x0:ke.x1:ke.y=Le<0?ke.y0:ke.y1),ke},Te="",Me="",Ie=[],ge=_t("arrow_point");for(let me=0;me<$;me++){let $e=e.edges[me],Pe=N[me*2],ze=N[me*2+1];if(Pe<0||ze<0)continue;let Le=Ee(Pe,Xo($e.lhsDir),$e.lhsGroup),Ve=Ee(ze,Xo($e.rhsDir),$e.rhsGroup);Le.x===Ve.x&&Le.y===Ve.y&&Le.dx===Ve.dx&&(Le.x-=8*Math.abs(Le.dy),Le.y-=8*Math.abs(Le.dx),Ve.x+=8*Math.abs(Le.dy),Ve.y+=8*Math.abs(Le.dx));let Ze=BT(Le,Ve);Le.wire&&Ze.unshift(we(Pe),P[_[Pe]]+h),Ve.wire&&Ze.push(we(ze),P[_[ze]]+h);let ke=WT(Ze);if(ke.length<4)continue;let Qe=We(`${$e.lhsId}-${$e.rhsId}`);Te+=`<g class="pele-edge" data-id="${Qe}"><path d="${UT(ke,$e.lhsInto&&!Le.wire?ge+Le.gap:0,$e.rhsInto&&!Ve.wire?ge+Ve.gap:0)}"/>`+($e.lhsInto?wt("arrow_point",Le.x+Le.dx*Le.gap,Le.y+Le.dy*Le.gap,-Le.dx,-Le.dy,"var(--_l)"):"")+($e.rhsInto?wt("arrow_point",Ve.x+Ve.dx*Ve.gap,Ve.y+Ve.dy*Ve.gap,-Ve.dx,-Ve.dy,"var(--_l)"):"")+"</g>";let et=-1,pt=-1,lt=-1,ye=-1,Be=g[me];for(let Oe=0;Oe<ke.length;Oe+=2)ue=Math.min(ue,ke[Oe]-4),he=Math.max(he,ke[Oe]+4),ce=Math.min(ce,ke[Oe+1]-4),V=Math.max(V,ke[Oe+1]+4);for(let Oe=0;Oe+3<ke.length;Oe+=2){let je=Math.abs(ke[Oe+1]-ke[Oe+3])<.01,Ke=Math.abs(ke[Oe]-ke[Oe+2])+Math.abs(ke[Oe+1]-ke[Oe+3]);je||Ie.push(ke[Oe],Math.min(ke[Oe+1],ke[Oe+3]),Math.max(ke[Oe+1],ke[Oe+3])),Ke>pt&&(et=Oe,pt=Ke),je&&Ke>ye&&(lt=Oe,ye=Ke)}if(Be.width>0){let Oe=ye>=Be.width+8?lt:et,je=(ke[Oe]+ke[Oe+2])/2,Ke=(ke[Oe+1]+ke[Oe+3])/2,Je=Be.width+8,Ge=Math.abs(ke[Oe]-ke[Oe+2])<.01;for(let Ye of[Le,Ve])je+Je/2<=Ye.x0||je-Je/2>=Ye.x1||Ke+Be.height/2<=Ye.y0||Ke-Be.height/2>=Ye.y1||(Ge?je=je>=(Ye.x0+Ye.x1)/2?Ye.x1+Je/2+4:Ye.x0-Je/2-4:Ke=Ke>=(Ye.y0+Ye.y1)/2?Ye.y1+Be.height/2+4:Ye.y0-Be.height/2-4);ue=Math.min(ue,je-Je/2),he=Math.max(he,je+Je/2),ce=Math.min(ce,Ke-Be.height/2),V=Math.max(V,Ke+Be.height/2),Me+=ln(`${$e.lhsId}-${$e.rhsId}`,Be,je,Ke,"",u)}}let xe="";for(let me=0;me<y;me++){let $e=m[me],Pe=X(me),ze=de(me),Le=le(me)-Pe,Ve=w[me],Ze="";if(Y[me]>0){let ke=ze+ne[me]+12,Qe=[];for(let ye=0;ye<Ie.length;ye+=3)Ie[ye+1]<ke&&Ie[ye+2]>ze&&Ie[ye]>Pe&&Ie[ye]<Pe+Le&&Qe.push(Ie[ye]);Qe.sort((ye,Be)=>ye-Be),Qe.push(Pe+Le-4);let et=Pe+10;for(let ye of Qe){if(ye-6-et>=Y[me])break;et=Math.max(et,ye+6)}et+Y[me]>Pe+Le-4&&(et=Pe+10);let pt=ze+6+ne[me]/2,lt=et;$e.icon&&(Ze+=tb($e.icon,et,pt-se/2,se,u),lt+=se+6),Ze+=Ce(Ve,lt+Ve.width/2,pt,' class="pele-cluster-label" fill="var(--_m)"',u)}xe+=`<g class="pele-cluster" data-id="${We($e.id)}"><rect x="${f(Pe)}" y="${f(ze)}" width="${f(Le)}" height="${f(Ae(me)-ze)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ft}/>`+Ze+"</g>"}let ie="",pe=i*.5,Re=Math.max(6,Math.round(s*.75));for(let me=0;me<p;me++){let $e=d[me],Pe=`data-id="${We($e.id)}" transform="translate(${f(we(me))},${f(P[_[me]])})"`;if($e.type==="junction"){ie+=`<g class="pele-node pele-junction" ${Pe}><circle cy="${f(h)}" r="${Jg}" fill="var(--_l)"/></g>`;continue}let ze="";if($e.icon)ze=tb($e.icon,-pe/2,(i-pe)/2,pe,u);else if($e.iconText){let Le=Ue($e.iconText,!1,c,Re,i-8),Ve=Math.max(1,Math.floor((i-4)/(Le.lineHeight||1)));ze=Ce(FT(Le,i-8,Ve,c),0,h,` class="pele-icon-text" font-size="${Re}"`,u)}ie+=`<g class="pele-node pele-service" ${Pe}><rect x="${f(-h)}" width="${f(i)}" height="${f(i)}" fill="var(--_s)" stroke="var(--_b)"${ft}/>`+ze+Ce(S[me],0,i+Zg+S[me].height/2,' class="pele-label"',u)+"</g>"}let be=Ue(e.title,!1,c,s,r?It(n):4e3,1),Se=be.height>0?be.height+12:0,Ne=Math.ceil(Math.max(he-ue,be.width)+2*l),De=Math.ceil(V-ce+Se+2*l),ve=Math.round((Ne-(he-ue))/2-ue),fe=Math.round(l+Se-ce),_e=(xe?`<g class="pele-clusters">${xe}</g>`:"")+(Te?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${Te}</g>`:"")+(Me?`<g class="pele-edge-labels" font-size="${o}">${Me}</g>`:"")+(ie?`<g class="pele-nodes">${ie}</g>`:"");return{svg:ot("architecture",Ne,De,s,n,e,Ce(be,Ne/2,l+be.height/2,' class="pele-title" font-weight="var(--_tw)"')+(_e?`<g transform="translate(${ve},${fe})">${_e}</g>`:"")),width:Ne,height:De,links:[]}}var rb={type:"architecture",parse(e,t,n){let r=new kc;return n&&(r.title=n),Yg(Vg(e),r),r},render:nb};var sb=1e5;function YT(e){switch(e){case"[]":return"square";case"()":return"round";case"(())":return"circle";case">]":return"rect_left_inv_arrow";case"{}":return"diamond";case"{{}}":return"hexagon";case"([])":return"stadium";case"[[]]":return"subroutine";case"[()]":return"cylinder";case"((()))":return"doublecircle";case"[//]":return"lean_right";case"[\\\\]":return"lean_left";case"[/\\]":return"trapezoid";case"[\\/]":return"inv_trapezoid";case"<[]>":return"block_arrow";default:return"na"}}function HT(e){switch(e.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}function KT(e){switch(e.trim().charAt(0)){case"x":return"arrow_cross";case"o":return"arrow_circle";case"<":return"arrow_point";default:return"arrow_open"}}function zT(e){return e.includes("==")?"thick":"normal"}function VT(e){return e.includes(".-")?"dotted":"solid"}function ib(e,t){let n=e.flat(),r=-1;for(let i of n)if(i.type==="column-setting"){r=i.columns??-1;break}return{list:n,at:0,parent:t,children:[],columns:r}}var Oc=class{type="block";title;root={id:"root",type:"composite",children:[],columns:-1};blocks=[];edges=[];classes=new Map;byId=new Map;typeStr2Type=YT;edgeStrToEdgeData=HT;edgeStrToEdgeStartData=KT;edgeStrToThickness=zT;edgeStrToPattern=VT;warn;pending=new Set;edgeCount=new Map;ids=0;colors=0;spaces=0;constructor(t={}){this.warn=t.warn}generateId(){return"id-"+ ++this.ids}addStyleClass(t,n=""){let r=this.classes.get(t);r||(r={id:t,styles:[],textStyles:[]},this.classes.set(t,r));for(let i of n.split(",")){let s=i.indexOf(";"),a=(s===-1?i:i.slice(0,s)+i.slice(s+1)).trim();i.includes("color")&&r.textStyles.push(a.replace("fill","bgFill").replace("color","fill")),r.styles.push(a)}}addStyle2Node(t,n=""){this.named(t).styles=n.split(",")}setCssClass(t,n){for(let r of t.split(","))(this.named(r.trim()).classes??=[]).push(n)}named(t){let n=this.byId.get(t);return n===void 0&&(n={id:t,type:"na",children:[]},this.byId.set(t,n),this.pending.add(t)),n}setHierarchy(t){let n=[ib(t,this.root)];for(;n.length>0;){let r=n[n.length-1];if(r.at===r.list.length){r.parent.children=r.children,n.pop();continue}let i=r.list[r.at++];switch(r.columns>0&&i.type!=="column-setting"&&typeof i.widthInColumns=="number"&&i.widthInColumns>r.columns&&this.warn?.(`Block ${i.id} width ${i.widthInColumns} exceeds configured column width ${r.columns}`),i.type){case"classDef":this.addStyleClass(i.id,i.css);continue;case"applyClass":this.setCssClass(i.id,i.styleClass??"");continue;case"applyStyles":i.stylesStr&&this.addStyle2Node(i.id,i.stylesStr);continue;case"column-setting":r.parent.columns=i.columns??-1;continue;case"edge":{let c=(this.edgeCount.get(i.id)??0)+1;this.edgeCount.set(i.id,c),i.id=c+"-"+i.id,this.edges.push(i);continue}}i.id??=this.generateId(),i.label||(i.label=i.type==="composite"?"":i.id);let s=this.byId.get(i.id),a=s===void 0||this.pending.delete(i.id);a?(s&&(i.classes=s.classes,i.styles=s.styles),i.type==="composite"&&(i.colorIndex=this.colors++),this.byId.set(i.id,i)):(i.type!=="na"&&(s.type=i.type),i.label!==i.id&&(s.label=i.label));let o=i.children;if(i.children=[],i.type==="space"){let c=i.width??1;if(!(c<=sb-this.spaces))throw new qe(`A block diagram can hold at most ${sb} space blocks.`,"limit",{type:"block"});this.spaces+=Math.max(c,0);for(let l=0;l<c;l++){let u={...i,id:i.id+"-"+l,children:[]};this.byId.set(u.id,u),r.children.push(u)}}else a&&r.children.push(i);o&&o.length>0&&n.push(ib(o,i))}this.blocks=this.root.children??[]}};var qu=["$end","INVALID","BLOCK_DIAGRAM_KEY","id-block","COLUMNS","MD_STR","STR","SPACE_BLOCK","DEFAULT","LINKSTYLE","INTERPOLATE","classDef","DEFAULT_CLASSDEF_ID","CLASSDEF_ID","CLASSDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","style","STYLE_ENTITY_IDS","STYLE_DEFINITION_DATA","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","end","NODE_DSTART","NODE_DEND","BLOCK_ARROW_START","BLOCK_ARROW_END","DIR","NODE_ID","LINK","START_LINK","LINK_LABEL","SIZE","EOF"];var jT=["right","left","x","y","up","down"],ob=new Uint8Array(128);for(let e of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])ob[e]=1;function ab(e){let t=e.length,n=[],r=[],i=[],s=[],a=0,o=0,c=(K,C,Z)=>(n.push(K),r.push(C),i.push(o),o=Z,!0),l=(K,C)=>c(K,e.slice(o,C),C),u=K=>{s.push(a),a=K},h=()=>{s.length>0&&(a=s.pop())},d=K=>{for(;K<t&&Xe(e.charCodeAt(K));)K++;return K},m=K=>{for(;K<t;){let C=e.charCodeAt(K);if(C<48||C>57)break;K++}return K},p=K=>{for(;K<t&&it(e.charCodeAt(K));)K++;return K},y=K=>e.startsWith(K,o)&&!it(e.charCodeAt(o+K.length)),E=()=>(e.charCodeAt(o+1)===96?(u(2),o+=2):(u(1),o++),!0),b=K=>{if(e.charCodeAt(K)!==46)return-1;do K++;while(e.charCodeAt(K)===46);if(e.charCodeAt(K)!==45)return-1;let C=e.charCodeAt(K+1);return C===120||C===111||C===62?K+2:K+1},S=K=>{let C=e.charCodeAt(K);(C===120||C===111||C===60)&&K++;let Z=e.charCodeAt(K);if(Z===46)return b(K);if(Z!==45&&Z!==61)return-1;let oe=K+1;for(;e.charCodeAt(oe)===Z;)oe++;if(oe-K===1)return Z===45?b(oe):-1;let H=e.charCodeAt(oe);return H===120||H===111||H===62?oe+1:oe-K>=3?oe:-1},x=()=>{let K=S(o);if(K>=0)return l(33,d(K));let C=e.charCodeAt(o)===60?o+1:o,Z=e.charCodeAt(C),oe=e.charCodeAt(C+1);return Z===45&&(oe===45||oe===46)||Z===61&&oe===61?(u(6),l(34,d(C+2))):!1},I=K=>{let C=e.indexOf(`
64
+ `,o);return C===-1&&(C=t),h(),l(K,C)},L=(K,C)=>{let Z=p(o);if(Z===o)return!1;for(;e.charCodeAt(Z)===44;){let oe=d(Z+1),H=p(oe);if(H===oe)break;Z=H}return a=C,l(K,Z)},O=K=>{if(Xe(K))return o=d(o+1),!0;let C;switch(K){case 98:if(e.startsWith("block",o)){if(y("block-beta"))return l(2,o+10);if(e.charCodeAt(o+5)===58)return l(3,o+6);if(!it(e.charCodeAt(o+5)))return l(2,o+5)}break;case 99:if(e.startsWith("columns",o)){if(C=d(o+7),C>o+7){if(e.startsWith("auto",C)&&!it(e.charCodeAt(C+4)))return c(4,"-1",C+4);let Z=m(C);if(Z>C)return c(4,e.slice(C,Z),Z)}}else if(e.startsWith("class",o)){let Z=e.startsWith("Def",o+5),oe=Z?o+8:o+5;if(C=d(oe),C>oe)return u(Z?7:9),l(Z?11:15,C)}break;case 34:return E();case 115:if(e.startsWith("space",o)){if(e.charCodeAt(o+5)===58){let Z=m(o+6);if(Z>o+6)return c(7,e.slice(o+6,Z),Z)}if(!it(e.charCodeAt(o+5)))return c(7,"1",o+5)}else if(e.startsWith("style",o)&&(C=d(o+5),C>o+5))return u(11),l(18,C);break;case 100:if(y("default"))return l(8,o+7);break;case 108:if(y("linkStyle"))return l(9,o+9);break;case 105:if(y("interpolate"))return l(10,o+11);break;case 97:if(e.startsWith("accTitle",o)){if(C=d(o+8),e.charCodeAt(C)===58)return u(13),l(21,d(C+1))}else if(e.startsWith("accDescr",o)){C=d(o+8);let Z=e.charCodeAt(C);if(Z===58)return u(14),l(23,d(C+1));if(Z===123)return u(15),o=d(C+1),!0}break;case 101:if(y("end"))return l(26,d(o+3));break;case 45:return e.charCodeAt(o+1)===41?(u(3),l(27,o+2)):x();case 61:return x();case 60:return e.charCodeAt(o+1)===91?(u(4),l(29,o+2)):x();case 40:{let Z=e.charCodeAt(o+1),oe=Z===45||Z===91?2:Z===40?e.charCodeAt(o+2)===40?3:2:1;return u(3),l(27,o+oe)}case 41:case 123:return u(3),l(27,e.charCodeAt(o+1)===K?o+2:o+1);case 62:return u(3),l(27,o+1);case 91:{let Z=e.charCodeAt(o+1);return u(3),l(27,Z===91||Z===124||Z===40||Z===92||Z===47?o+2:o+1)}case 58:{let Z=m(o+1);return Z>o+1?c(36,e.slice(o+1,Z),Z):!1}}for(C=o;C<t;){let Z=e.charCodeAt(C);if(Z<128?ob[Z]===1:Xe(Z))break;C++}return C>o&&l(32,C)},v=K=>{let C=e.charCodeAt(o+1),Z=0;switch(K){case 34:return E();case 40:Z=C===45?2:C===40?e.charCodeAt(o+2)===40?3:2:1;break;case 41:Z=C===41?e.charCodeAt(o+2)===41?3:2:C===93?2:1;break;case 125:Z=C===125?2:1;break;case 45:Z=C===41?2:0;break;case 93:Z=C===93||C===41||C===62?2:1;break;case 92:case 47:Z=C===93?2:0;break}return Z===0?!1:(h(),l(28,o+Z))},G=K=>{if(K===41)return h(),h(),c(30,"]>",d(o+1));let C=d(K===44?o+1:o);for(let Z of jT)if(e.startsWith(Z,C)){let oe=d(C+Z.length);return c(31,e.slice(K===44?C:o,oe),oe)}return!1};for(;;){if(o>=t){let Z=-1;switch(a){case 0:Z=37;break;case 1:Z=6;break;case 8:Z=14;break;case 10:Z=17;break;case 12:Z=20;break;case 13:Z=22;break;case 14:Z=24;break;case 15:Z=25;break}o=t,Z!==-1&&c(Z,"",t);break}let K=e.charCodeAt(o),C=!0;switch(a){case 0:C=O(K);break;case 1:if(K===34)h(),o++;else{let Z=e.indexOf('"',o);l(6,Z===-1?t:Z)}break;case 2:if(K===96)C=e.charCodeAt(o+1)===34,C&&(h(),o+=2);else if(K===34)C=!1;else{let Z=o+1;for(;Z<t;){let oe=e.charCodeAt(Z);if(oe===96||oe===34)break;Z++}l(5,Z)}break;case 3:C=v(K);break;case 4:if(K===34)E();else if(K===93&&e.charCodeAt(o+1)===62){let Z=d(o+2);C=e.charCodeAt(Z)===40,C&&(u(5),o=Z+1)}else C=!1;break;case 5:C=G(K);break;case 6:if(K===34)e.charCodeAt(o+1)===96?E():(l(35,o+1),u(1));else{let Z=S(d(o));C=Z>=0,C&&(h(),l(33,d(Z)))}break;case 7:{let Z=12,oe=e.startsWith("DEFAULT",o)?o+7:o,H=d(oe);(oe===o||H===oe)&&(Z=13,oe=p(o),H=d(oe)),C=oe>o&&H>oe,C&&(a=8,l(Z,H));break}case 8:I(14);break;case 9:C=L(16,10);break;case 10:I(17);break;case 11:C=L(19,12);break;case 12:I(20);break;case 13:I(22);break;case 14:I(24);break;case 15:if(K===125)h(),o++;else{let Z=e.indexOf("}",o);l(25,Z===-1?t:Z)}break}if(!C)return n.push(1),r.push(""),i.push(o),{types:n,texts:r,starts:i}}return n.push(0),r.push(""),i.push(t),{types:n,texts:r,starts:i}}var qo="'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'";function cb(e){let t=e[e.length-1];return Array.isArray(t)?(e.pop(),e.concat(t)):e}function lb(e,t){let{types:n,texts:r,starts:i}=ab(e),s=0,a=d=>{let m=n[s];throw m===1?ut("block",e,i[s],"",!0):ut("block",e,i[s],`Expecting ${d}, got '${qu[m]}'`)},o=d=>(n[s]!==d&&a(`'${qu[d]}'`),r[s++]),c=()=>{let d=o(32);if(n[s]===27){let m=r[s++],p=o(6);return{id:d,label:p,typeStr:m+o(28)}}if(n[s]===29){let m=r[s++],p=o(6),y=[o(31)];for(;n[s]===31;)y.push(r[s++]);return{id:d,label:p,typeStr:m+o(30),directions:y}}return{id:d}},l=()=>{let d=c(),m=n[s]===36?parseInt(r[s++],10):1,p={id:d.id,label:d.label,type:t.typeStr2Type(d.typeStr),directions:d.directions,widthInColumns:m},y;for(;n[s]===33||n[s]===34;){let E="";n[s++]===34&&(o(35),E=o(6),o(33));let b=r[s-1],S=c(),x=t.edgeStrToEdgeData(b),I=t.edgeStrToEdgeStartData(b),L=t.edgeStrToThickness(b),O=t.edgeStrToPattern(b);y??=[{id:p.id,label:p.label,type:p.type,directions:p.directions}],p={id:S.id,label:S.label,type:t.typeStr2Type(S.typeStr),directions:S.directions},y.push({id:y[y.length-1].id+"-"+S.id,start:y[y.length-1].id,end:S.id,label:E,type:"edge",thickness:L,pattern:O,directions:S.directions,arrowTypeEnd:x,arrowTypeStart:I},p)}return y??p};o(2);let u=[],h=[];for(;;)switch(n[s]){case 32:h.push(l());break;case 4:h.push({type:"column-setting",columns:parseInt(r[s++],10)});break;case 7:{let d=parseInt(r[s++],10);h.push({id:t.generateId(),type:"space",label:"",width:d,children:[]});break}case 2:s++,u.push({list:h,header:void 0}),h=[];break;case 3:s++,n[s]!==32&&a("'NODE_ID'"),u.push({list:h,header:l()}),h=[];break;case 26:{let d=u.pop();if(d===void 0||h.length===0)return a(qo);s++;let m=t.generateId(),p=cb(h);h=d.list,h.push(d.header===void 0?{id:m,type:"composite",label:"",children:p}:{...d.header,type:"composite",children:p});break}case 11:{s++;let d=o(13).trim();h.push({type:"classDef",id:d,css:o(14).trim()});break}case 15:{s++;let d=o(16).trim();h.push({type:"applyClass",id:d,styleClass:o(17).trim()});break}case 18:{s++;let d=o(19).trim();h.push({type:"applyStyles",id:d,stylesStr:o(20).trim()});break}case 37:u.length>0&&a(qo+", 'end'"),h.length===0&&a(qo),t.setHierarchy(cb(h));return;default:a(h.length===0?qo:qo+(u.length>0?", 'end'":", 'EOF'"))}}function bn(e,t,n,r){return om(()=>Ue(e,!1,t,n,r,1))}function Dc(e,t,n,r,i,s,a){let o=bn(e,t,n,4e3);if(o.height===0)return{width:i,height:s,content:a};let c=o.height+12,l=Math.max(i,Math.ceil(o.width+2*r));return{width:l,height:Math.ceil(s+c),content:Ce(o,l/2,r+o.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f((l-i)/2)},${f(c)})">${a}</g>`}}var kr=1,$r=2,Lr=4,Or=8,Xs=7,vc=20,ys=12;function db(e){let t=0;if(e)for(let n of e)switch(n.trim()){case"right":t|=kr;break;case"left":t|=$r;break;case"up":t|=Lr;break;case"down":t|=Or;break;case"x":t|=kr|$r;break;case"y":t|=Lr|Or;break}return t}var bs=(e,t)=>e&t?1:0;function Qo(e){return e!==0&&(e&(Lr|Or))===0?"x":e!==0&&(e&(kr|$r))===0?"y":""}function Qu(e,t,n){let r=Qo(e),i=bs(e,$r)-bs(e,kr),s=bs(e,Lr)-bs(e,Or);if(r==="x"){let a=Math.max(n+8,14)+2*Xs,o=Math.min(a/2,vc);return{w:Math.max(t+12,16)+o*(e===(kr|$r)?2:1),h:a,dx:i*o/2,dy:0}}if(r==="y"){let a=Math.max(t+16,14)+2*Xs,o=Math.min(a/2,vc);return{w:a,h:Math.max(n+8,16)+o*(e===(Lr|Or)?2:1),dx:0,dy:s*o/2}}return{w:Math.max(t+16,24)+ys*(bs(e,$r)+bs(e,kr)),h:Math.max(n+8,24)+ys*(bs(e,Lr)+bs(e,Or)),dx:i*ys/2,dy:s*ys/2}}function ub(e,t,n,r){let i=Qo(e),s=t/2,a=n/2,o;if(i==="x"){let l=Math.min(a,vc),u=a-Xs,h=e&$r?-s+l:-s,d=e&kr?s-l:s;o=[h,-u,d,-u],e&kr&&o.push(d,-a,s,0,d,a),o.push(d,u,h,u),e&$r&&o.push(h,a,-s,0,h,-a)}else if(i==="y"){let l=Math.min(s,vc),u=s-Xs,h=e&Lr?-a+l:-a,d=e&Or?a-l:a;o=[u,h,u,d],e&Or&&o.push(s,d,0,a,-s,d),o.push(-u,d,-u,h),e&Lr&&o.push(-s,h,0,-a,s,h)}else{let l=e&$r?-s+ys:-s,u=e&kr?s-ys:s,h=e&Lr?-a+ys:-a,d=e&Or?a-ys:a,m=(l+u)/2,p=(h+d)/2,y=Math.min(10,(u-l)/2),E=Math.min(10,(d-h)/2);o=[l,h],e&Lr&&o.push(m-y,h,m,-a,m+y,h),o.push(u,h),e&kr&&o.push(u,p-E,s,p,u,p+E),o.push(u,d),e&Or&&o.push(m+y,d,m,a,m-y,d),o.push(l,d),e&$r&&o.push(l,p+E,-s,p,l,p-E)}let c="";for(let l=0;l<o.length;l+=2)c+=(l?" ":"")+f(o[l])+","+f(o[l+1]);return`<polygon points="${c}" stroke-linejoin="round"${r}/>`}var XT=1e3;function qT(e,t){if(e===0||!Number.isInteger(e))throw new qe("Columns must be an integer !== 0.","semantic",{type:"block"});if(t<0||!Number.isInteger(t))throw new qe("Position must be a non-negative integer."+t,"semantic",{type:"block"});return e<0?{px:t,py:0}:{px:t%e,py:Math.floor(t/e)}}function QT(e,t,n){let r=e.columns,i=[],s=0,a=0,o=0,c=0;for(let u of e.children){let{px:h,py:d}=qT(r,s),m=u.span>=1?Math.min(u.span,XT):1;if(r>0&&m>r-h&&(m=r-h),u.span=m,u.col=h,u.row=d,s+=m,h+m>a&&(a=h+m),d===i.length&&i.push(0),u.children.length===0?i[d]=-1:i[d]>=0&&u.nh>i[d]&&(i[d]=u.nh),u.space)continue;let p=(u.nw-t*(m-1))/m;p>o&&(o=p),u.nh>c&&(c=u.nh)}let l=(i.length-1)*t+Pc(e.rowGaps);for(let u=0;u<i.length;u++)i[u]<0&&(i[u]=c),l+=i[u];e.cols=a,e.heights=i,e.nw=Math.max(e.nw,a*o+(a-1)*t+Pc(e.colGaps)+2*n),e.nh=l+2*n+e.head}function ZT(e,t,n){let{cols:r,heights:i,rowGaps:s,colGaps:a}=e,o=i.length,c=(e.w-2*n-(r-1)*t-Pc(a))/r,l=e.h-2*n-e.head-(o-1)*t-Pc(s),u=[];if(a.length>0){let b=0;for(let S=0;S<r;S++)u.push(b),b+=a[S]??0}let h=0;for(let b of i)h+=b;let d=h>0?l/h:0,m=h>0?0:l/o,p=e.x-e.w/2+n,y=e.y-e.h/2+n+e.head,E=0;for(let b of e.children){for(;E<b.row;E++)y+=i[E]*d+m+t+(s[E]??0);let S=u[b.col]??0;b.w=c*b.span+t*(b.span-1)+(u[b.col+b.span-1]??0)-S,b.h=i[E]*d+m,b.x=p+b.col*(c+t)+S+b.w/2,b.y=y+b.h/2}}function Pc(e){let t=0;for(let n of e)t+=n??0;return t}function fb(e,t){let n=[e];for(let r=0;r<n.length;r++)for(let i of n[r].children)n.push(i);for(let r=n.length-1;r>=0;r--){let i=n[r];i.children.length>0&&QT(i,t,r===0?0:t)}e.w=e.nw,e.h=e.nh,e.x=e.w/2,e.y=e.h/2;for(let r=0;r<n.length;r++){let i=n[r];i.children.length>0&&ZT(i,t,r===0?0:t)}return{width:e.w,height:e.h}}var JT=12,hb=200,e2=8,pb=' fill="var(--_s)" stroke="var(--_b)"',t2=' stroke="var(--_b)"',mb=[],n2=[],r2=[],Ki=[],s2=["default"],gb=2e6,Zu=4,i2=new Map([["square","rect"],["round","rounded"],["circle","circle"],["doublecircle","dbl-circ"],["diamond","diam"],["hexagon","hex"],["stadium","stadium"],["subroutine","fr-rect"],["cylinder","cyl"],["rect_left_inv_arrow","odd"],["lean_right","lean-r"],["lean_left","lean-l"],["trapezoid","trap-b"],["inv_trapezoid","trap-t"]]),bb=new Set(["circle","dbl-circ","diam"]),o2=new Set(["stadium","hex","odd","lean-r","lean-l","trap-b","trap-t"]);function Fc(e){return e.kind===0&&(e.shape==="circle"||e.shape==="dbl-circ")}function Yi(e,t,n){let r=e.bw/2,i=e.bh/2,s=Math.abs(t-e.x),a=i;return Fc(e)?a=Math.sqrt(Math.max(r*r-s*s,0)):e.kind===0&&e.shape==="diam"?a=i*Math.max(1-s/r,0):e.kind===0?a=i-qr(e.shape,e.bw,e.bh,n>0?2:0):e.kind===1&&Qo(e.mask)==="x"&&(a=i-Xs),e.y+n*a}function Hi(e,t,n){let r=e.bw/2,i=e.bh/2,s=Math.abs(t-e.y),a=r;return Fc(e)?a=Math.sqrt(Math.max(i*i-s*s,0)):e.kind===0&&e.shape==="diam"?a=r*Math.max(1-s/i,0):e.kind===0?a=r-qr(e.shape,e.bw,e.bh,n>0?1:3):e.kind===1&&Qo(e.mask)==="y"&&(a=r-Xs),e.x+n*a}function yb(e,t,n,r){let i=t-e.x,s=n-e.y,a=e.bw/2,o=e.bh/2,c;Fc(e)?c=a/(Math.hypot(i,s)||1):e.kind===0&&e.shape==="diam"?c=1/(Math.abs(i)/a+Math.abs(s)/o||1):c=Math.min(i===0?1/0:a/Math.abs(i),s===0?1/0:o/Math.abs(s)),c===1/0&&(c=0),r.push(e.x+i*c,e.y+s*c)}function a2(e,t,n,r,i){let s=i.x-i.bw/2+1,a=i.x+i.bw/2-1,o=i.y-i.bh/2+1,c=i.y+i.bh/2-1;if(e<s&&n<s||e>a&&n>a||t<o&&r<o||t>c&&r>c)return!1;if(e===n||t===r)return!0;let l=n-e,u=r-t,h=(m,p)=>Math.sign(l*(p-t)-u*(m-e)),d=h(s,o);return d===0||h(a,o)!==d||h(a,c)!==d||h(s,c)!==d}function Ju(e,t,n,r){let i=0;for(let s of r)if(!(s===t||s===n)){for(let a=0;a+3<e.length;a+=2)if(a2(e[a],e[a+1],e[a+2],e[a+3],s)){i++;break}}return i}function c2(e,t,n,r){let i=e.x-e.bw/2,s=e.x+e.bw/2,a=e.y-e.bh/2,o=e.y+e.bh/2,c=t.x-t.bw/2,l=t.x+t.bw/2,u=t.y-t.bh/2,h=t.y+t.bh/2,d=Math.max(i,c),m=Math.min(s,l),p=Math.max(a,u),y=Math.min(o,h),E=m-d>6,b=y-p>6;if(E&&b){let oe=e.bw*e.bh<=t.bw*t.bh?e:t,H=oe===e?t:e,z=oe.y-oe.bh/2-(H.y-H.bh/2),M=H.y+H.bh/2-(oe.y+oe.bh/2),T=oe.x-oe.bw/2-(H.x-H.bw/2),R=H.x+H.bw/2-(oe.x+oe.bw/2),_=Math.min(z,M,T,R),$;return _===M?$=[oe.x,Yi(oe,oe.x,1),oe.x,H.y+H.bh/2]:_===z?$=[oe.x,Yi(oe,oe.x,-1),oe.x,H.y-H.bh/2]:_===R?$=[Hi(oe,oe.y,1),oe.y,H.x+H.bw/2,oe.y]:$=[Hi(oe,oe.y,-1),oe.y,H.x-H.bw/2,oe.y],oe===e?$:[$[2],$[3],$[0],$[1]]}if(E){let oe=Math.min(6,(m-d)/2),H=Math.min(Math.max((d+m)/2+n,d+oe),m-oe),z=t.y>e.y?1:-1;return[H,Yi(e,H,z),H,Yi(t,H,-z)]}if(b){let oe=Math.min(6,(y-p)/2),H=Math.min(Math.max((p+y)/2+n,p+oe),y-oe),z=t.x>e.x?1:-1;return[Hi(e,H,z),H,Hi(t,H,-z),H]}let S=t.x>e.x?1:-1,x=t.y>e.y?1:-1,I=[Hi(e,e.y,S),e.y,t.x,e.y,t.x,Yi(t,t.x,-x)],L=[e.x,Yi(e,e.x,x),e.x,t.y,Hi(t,t.y,-S),t.y],O=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y),v=O?I:L;if(r===void 0)return v;let G=Ju(v,e,t,r);if(G===0)return v;let K=O?L:I,C=Ju(K,e,t,r);if(C<G&&(v=K,G=C),G===0)return v;let Z=[];return yb(e,t.x,t.y,Z),yb(t,e.x,e.y,Z),Ju(Z,e,t,r)<G?Z:v}function l2(e,t,n){let r=e.length,i=e[0],s=e[1],a=e[r-2],o=e[r-1],c=e[2]-i,l=e[3]-s,u=Math.hypot(c,l);c/=u||1,l/=u||1;let h=a-e[r-4],d=o-e[r-3],m=Math.hypot(h,d);if(h/=m||1,d/=m||1,r===4&&t+n>u){let y=u/(t+n);t*=y,n*=y}t=Math.min(t,u),n=Math.min(n,m);let p=`M${f(i+c*t)},${f(s+l*t)}`;if(r===6){let y=Math.max(0,Math.min(e2,u-t,m-n));p+=`L${f(e[2]-c*y)},${f(e[3]-l*y)}Q${f(e[2])},${f(e[3])} ${f(e[2]+h*y)},${f(e[3]+d*y)}`}return p+=`L${f(a-h*n)},${f(o-d*n)}`,{d:p,sx:i,sy:s,sdx:-c,sdy:-l,ex:a,ey:o,edx:h,edy:d}}function ef(e,t){let n=e.bw/2,r=e.bh/2,i=Math.max(1,Math.min(10+5*(t-1),n,r));if(Fc(e)){let s=e.x+n*Math.SQRT1_2,a=e.y-n*Math.SQRT1_2,o=2*Math.asin(Math.min(1,i/(2*n))),c=l=>Math.atan2(e.y-n*Math.sin(l)-a,e.x+n*Math.cos(l)-s);return[s,a,i,c(Math.PI/4+o),c(Math.PI/4-o)]}if(e.kind===0&&e.shape==="diam"){let s=Math.atan2(r,n);return[e.x+n/2,e.y-r/2,i,s+Math.PI,s]}return[e.x+n,e.y-r,i,Math.PI,Math.PI/2]}function d2(e,t,n,r){let[i,s,a,o,c]=ef(e,t),l=o+n/a,u=c-r/a,h=(u-l)%(2*Math.PI);h<=0&&(h+=2*Math.PI);let d=i+a*Math.cos(l),m=s+a*Math.sin(l),p=i+a*Math.cos(u),y=s+a*Math.sin(u),E=i+a*Math.cos(o),b=s+a*Math.sin(o),S=i+a*Math.cos(c),x=s+a*Math.sin(c),I=Math.hypot(E-d,b-m),L=Math.hypot(S-p,x-y);return{d:`M${f(d)},${f(m)}A${f(a)},${f(a)} 0 ${h>Math.PI?1:0} 1 ${f(p)},${f(y)}`,sx:E,sy:b,sdx:I>0?(E-d)/I:Math.sin(o),sdy:I>0?(b-m)/I:-Math.cos(o),ex:S,ey:x,edx:L>0?(S-p)/L:-Math.sin(c),edy:L>0?(x-y)/L:Math.cos(c)}}var u2=[.5,.3,.7,.15,.85];function Eb(e,t,n,r,i,s,a){if(a===void 0)return!1;for(let o of a)if(o!==i&&o!==s&&Math.abs(e-o.x)<(n+o.bw)/2&&Math.abs(t-o.y)<(r+o.bh)/2)return!0;return!1}function f2(e,t,n,r,i,s,a){if(a===void 0)return .5;for(let o of u2){let c=e[t]+(e[t+2]-e[t])*o,l=e[t+1]+(e[t+3]-e[t+1])*o;if(!Eb(c,l,n,r,i,s,a))return o}return .5}function h2(e,t,n,r,i,s){let a=n[e[0]][0]===n[e[0]][2],o=-1/0,c=1/0,l=-Zu,u=!1;for(let m=0;m<e.length;m++){let p=n[e[m]];if(a?p[0]!==p[2]:p[1]!==p[3])return 0;o=Math.max(o,a?Math.min(p[1],p[3]):Math.min(p[0],p[2])),c=Math.min(c,a?Math.max(p[1],p[3]):Math.max(p[0],p[2]));let y=t[e[m]];l+=(a?y.label.height:y.label.width+8)+Zu;for(let E=0;E<m;E++){let b=t[e[E]];Math.abs(y.lx-b.lx)<(y.label.width+b.label.width)/2+8&&Math.abs(y.ly-b.ly)<(y.label.height+b.label.height)/2&&(u=!0)}}if(!u)return 0;if(l>c-o-2*$t)return l-(c-o-2*$t);let h=[],d=(o+c-l)/2;for(let m of e){let{label:p,lx:y,ly:E}=t[m],b=a?p.height:p.width+8,S=d+b/2;if(Eb(a?y:S,a?S:E,p.width+8,p.height,r,i,s))return 0;h.push(S),d+=b+Zu}return e.forEach((m,p)=>{a?t[m].ly=h[p]:t[m].lx=h[p]}),0}function p2(e,t,n,r,i,s){let a=new Set;for(let d=t;d!==void 0;d=e[d.index])a.add(d);let o,c=n;for(;c!==void 0&&!a.has(c);)o=c,c=e[c.index];if(c===void 0||o===void 0||c===t)return!1;let l=t;for(;e[l.index]!==c;)l=e[l.index];let u;if(r){if(l.row===o.row)return!1;u=Math.max(l.row,o.row)-1,c.rowGaps===Ki&&(c.rowGaps=[])}else{let[d,m]=l.col<o.col?[l,o]:[o,l];if(m.col<d.col+d.span)return!1;u=m.col-1,c.colGaps===Ki&&(c.colGaps=[])}let h=r?c.rowGaps:c.colGaps;return s.has(h)||s.set(h,h.slice()),h[u]=Math.max(h[u]??0,(s.get(h)[u]??0)+i),!0}function xb(e,t,n){return xn(n,r=>m2(e,t,n,r))}function m2(e,t,n,r){let i=n.fontSize??16,s=Math.round(i*.875),a=n.measurer??at(n.fontFamily,n.fontFamilyMono),o=n.padding??8,c=n.icons,l=t.block?.padding,u=Math.min(typeof l=="number"&&l>=0?Math.min(l,200):JT,r?6:1/0),h=r?80:hb,d=re=>{let P=[],ee=ae=>{for(let ue of ae)for(let ce of ue.split(";"))P.push(ce)};for(let ae of re.classes&&re.classes.length>0?re.classes:s2){let ue=e.classes.get(ae);ue&&ee(ue.styles)}return re.styles&&ee(re.styles),Mt(P)},m=(re,P)=>{let ee=re.type,ae=ee==="space"?Mt(mb):d(re),ue=(ae.bold?1:0)|(ae.italic?2:0),ce=ae.fontSize??i,he=0,V="",X,le=0,de=0,Ae=0,we=0,Ee=0,Te=0;if(ee==="space")he=3,X=Ue(void 0,!1,a,ce,h);else if(ee==="composite")he=2,X=Ue(re.label,!1,a,ce,r?It(n):4e3,ue),Ae=X.height>0?X.height+4:0,le=X.width+2*u,de=Ae+2*u;else if(ee==="block_arrow"){he=1,X=Ue(re.label,!1,a,ce,h,ue);let Me=!0;for(let ge of X.lines)for(let xe of ge)(xe.icon!==void 0||xe.text.trim()!=="")&&(Me=!1);we=db(re.directions);let Ie=Me?Qu(we,0,0):Qu(we,X.width,X.height);le=Ie.w,de=Ie.h,Ee=Ie.dx,Te=Ie.dy}else{V=i2.get(ee??"")??"rect",X=Ue(re.label,!1,a,ce,h,ue);let Me=hs(V,X.width,X.height);le=Me.w,de=V==="cyl"?Math.max(Me.h,X.height+40):Me.h,Te=Me.dy}return{children:[],columns:he===2?re.columns??-1:-1,span:he===3?1:re.widthInColumns??1,space:he===3,head:Ae,nw:le,nh:de,col:0,row:0,cols:0,heights:r2,rowGaps:Ki,colGaps:Ki,x:0,y:0,w:0,h:0,block:re,kind:he,index:P,shape:V,label:X,style:ae,mask:we,dx:Ee,dy:Te,bw:0,bh:0}},p=m(e.root,0);p.nw=0,p.nh=0;let y=[p],E=[],b=new Map;for(let re=0;re<y.length;re++){let P=y[re];if(P.kind===2)for(let ee of P.block.children??n2){let ae=m(ee,y.length);P.children.push(ae),E[ae.index]=P,y.push(ae),ae.kind!==3&&b.set(ee.id,ae)}}let S=[],x=[],I=y.map(re=>re.nw),L=()=>{for(let P of y)P.nw=I[P.index];let re=fb(p,u);S.length=0,x.length=0;for(let P of y)P.kind===0&&bb.has(P.shape)?(P.bw=P.nw,P.bh=P.nh):P.kind===1?(P.bw=P.span>1?P.w:P.nw,P.bh=P.nh):(P.bw=P.w,P.bh=P.kind===0&&o2.has(P.shape)?P.nh:P.h),P.kind===0&&P.shape==="cyl"&&(P.dy=Math.min(12,Math.max(6,P.bw/14))/2),P.kind===0||P.kind===1?S.push(P):P.head>0&&x.push({x:P.x,y:P.y-P.h/2+(P.head+u)/2+2,bw:P.label.width,bh:P.label.height});return re},O=L(),v=new Map,G=new Set,K=[],C=[];for(let re of e.edges){let P=b.get(re.start??""),ee=b.get(re.end??"");if(P===void 0||ee===void 0)continue;let ae=Math.min(P.index,ee.index)*y.length+Math.max(P.index,ee.index);v.set(ae,(v.get(ae)??0)+1),re.label&&G.add(ae),K.push([P,ee]),C.push(re)}let Z=C.length*S.length<=gb?S:void 0,oe=[],H=new Map,z=[],M=()=>{let re=new Map;oe.length=0,H.clear();for(let P=0;P<C.length;P++){let[ee,ae]=K[P],ue=Math.min(ee.index,ae.index)*y.length+Math.max(ee.index,ae.index),ce=v.get(ue)??1,he=re.get(ue)??0;re.set(ue,he+1);let V=Ue(C[P].label,!1,a,s,hb),X,le,de;if(ee===ae){let[Ae,we,Ee]=ef(ee,he+1);X=[],le=Ae+Ee+6+V.width/2,de=we-Ee/2}else{let Ae=G.has(ue)?Math.round(s*1.5)+2:14;X=c2(ee,ae,(he-(ce-1)/2)*Ae,Z);let we=X.length,Ee=Math.abs(X[2]-X[0])+Math.abs(X[3]-X[1]),Te=Math.abs(X[we-2]-X[we-4])+Math.abs(X[we-1]-X[we-3]),Me=we===6&&Te>Ee?2:0,Ie=V.width>0?f2(X,Me,V.width+8,V.height,ee,ae,Z):.5;if(le=X[Me]+(X[Me+2]-X[Me])*Ie,de=X[Me+1]+(X[Me+3]-X[Me+1])*Ie,V.width>0&&ce>1){z[P]=X.slice(Me,Me+4);let ge=H.get(ue);ge?ge.push(P):H.set(ue,[P])}}oe.push({edge:C[P],points:X,loop:ee===ae?he+1:0,label:V,lx:le,ly:de})}},T=re=>{M();let P=Z&&[...Z,...x],ee=new Map,ae=!1;for(let ue of H.values()){if(ue.length<2)continue;let[ce,he]=K[ue[0]],V=h2(ue,oe,z,ce,he,P),X=z[ue[0]][0]===z[ue[0]][2];re&&V>0&&(X||!r)&&p2(E,ce,he,X,Math.ceil(V),ee)&&(ae=!0)}return ae},R=()=>{let re=0;for(let P=0;P<oe.length;P++){let ee=oe[P];for(let ae=P+1;ae<oe.length;ae++){let ue=oe[ae],ce=(ee.label.width+8)/2,he=(ue.label.width+8)/2,V=Math.min(ee.lx+ce,ue.lx+he)-Math.max(ee.lx-ce,ue.lx-he),X=Math.min(ee.ly+ee.label.height/2,ue.ly+ue.label.height/2)-Math.max(ee.ly-ee.label.height/2,ue.ly-ue.label.height/2);ee.label.width>0&&ue.label.width>0&&V>0&&X>0&&(re+=V*X)}}return re},_=0,$=0,g=0,N=0,w=(re,P,ee,ae)=>{re-ee/2<_&&(_=re-ee/2),re+ee/2>g&&(g=re+ee/2),P-ae/2<$&&($=P-ae/2),P+ae/2>N&&(N=P+ae/2)},A=()=>{_=0,$=0,g=O.width,N=O.height;for(let re=0;re<oe.length;re++){let P=oe[re];if(P.loop>0){let[ee,ae,ue]=ef(K[re][0],P.loop);w(ee,ae,2*ue+2,2*ue+2)}P.label.width>0&&w(P.lx,P.ly,P.label.width+8,P.label.height)}return g-_};if(T(C.length*C.length<=gb)){let re=R(),P=A(),ee=!0;for(let ce=0;ce<3&&ee;ce++)O=L(),ee=T(ce<2);let ae=A(),ue=n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth:1/0;if(R()>re-1||ae>P&&Math.ceil(ae+2*o)>ue){for(let ce of y)ce.rowGaps=Ki,ce.colGaps=Ki;O=L(),T(!1)}}A();let D=bn(e.title,a,i,r?It(n):4e3),U=D.height>0?D.height+12:0,B=Math.max(g-_,D.width),F=o-_+(B-(g-_))/2,W=o+U-$;for(let re of y)re.x+=F,re.y+=W;let j=Math.ceil(B+2*o),Q=Math.ceil(N-$+U+2*o),Y="",ne="",q=[];for(let re=1;re<y.length;re++){let P=y[re];if(P.kind===3)continue;let ee=Nt((P.block.classes??mb).join(" ")),ae=We(P.block.id);if(P.kind===2){let he=P.y-P.h/2;Tn(P.style.shape)&&q.push({box:[P.x-P.w/2,he,P.x+P.w/2,he+P.h],shape:P.style.shape}),Y+=`<g class="pele-cluster${ee}" data-id="${ae}"><rect x="${f(P.x-P.w/2)}" y="${f(he)}" width="${f(P.w)}" height="${f(P.h)}" fill="var(--_a)"${Dn(P.style.shape)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${xt(P.style.shape)}/>`+Ce(P.label,P.x,he+(P.head+u)/2+2,` class="pele-cluster-label"${Dt(P.style,"var(--_m)")}${P.style.text}`,c)+"</g>";continue}let ue=P.kind===1,ce=P.label;if(P.span>1&&P.label.width>0&&P.label.lines.length>1&&P.bw>P.nw&&(ue||!bb.has(P.shape))){let he=(P.style.bold?1:0)|(P.style.italic?2:0),V=P.label.width+(P.bw-P.nw);ce=Ue(P.block.label,!1,a,P.label.size,V,he)}ne+=`<g class="pele-node pele-shape-${ue?"block-arrow":P.shape}${ee}" data-id="${ae}" transform="translate(${f(P.x)},${f(P.y)})">`+(ue?ub(P.mask,P.bw,P.bh,pb+P.style.shape):fr(P.shape,P.bw,P.bh,pb+P.style.shape,t2+P.style.line))+Ce(ce,P.dx,P.dy,` class="pele-label"${ue||Ui(P.shape)?Dt(P.style):""}${P.style.text}`,c)+"</g>"}let k="",J="",te="";for(let re=0;re<oe.length;re++){let{edge:P,points:ee,loop:ae,label:ue}=oe[re],ce=P.arrowTypeStart??"",he=P.arrowTypeEnd??"",V;if(ae>0)V=d2(K[re][0],ae,_t(ce),_t(he));else{for(let de=0;de<ee.length;de+=2)ee[de]+=F,ee[de+1]+=W;V=l2(ee,_t(ce),_t(he))}let X=Tr(V.d,[V.sx,V.sy,V.ex,V.ey],q);X===""&&(k+=Mr(V,ce,he,"",P.thickness==="thick"));let le=We(P.id);if(J+=`<g class="pele-edge" data-id="${le}"${X?` stroke="${X}"`:""}><path d="${V.d}"${P.thickness==="thick"?' stroke-width="2.5"':""}${P.pattern==="dotted"?' stroke-dasharray="3 4"':""}/>`+wt(ce,V.sx,V.sy,V.sdx,V.sdy,X||"var(--_l)")+wt(he,V.ex,V.ey,V.edx,V.edy,X||"var(--_l)")+"</g>",ue.width>0){let de=oe[re].lx+F,Ae=oe[re].ly+W;te+=ln(P.id,ue,de,Ae,"",c)}}return{svg:ot("block",j,Q,i,n,e,Ce(D,j/2,o+D.height/2,' class="pele-title" font-weight="var(--_tw)"')+(Y?`<g class="pele-clusters">${Y}</g>`:"")+On(k)+(J?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${J}</g>`:"")+`<g class="pele-nodes">${ne}</g>`+(te?`<g class="pele-edge-labels" font-size="${s}">${te}</g>`:"")),width:j,height:Q,links:[]}}var Ab={type:"block",math:!0,parse(e,t,n){let r=new Oc;return r.title=n,lb(e,r),r},render:xb};var g2=new Set(["label","type","descr","techn","sprite","tags","link","bgColor","fontColor","borderColor","shadowing","shape","legendText","legendSprite"]),b2=new Set(["label","descr","techn","sprite","tags","link","textColor","lineColor"]);function Zo(e,t){let{key:n,value:r}=t;"from"in e&&(n==="offsetX"||n==="offsetY")?e[n]=parseInt(r):("from"in e?b2:g2).has(n)?e[n]=r:(e.extra??=new Map).set(n,r)}function Vt(e,t,n){n!==void 0&&(typeof n=="string"?e[t]=n:Zo(e,n))}function zi(e,t,n){n===void 0?e[t]??="":Vt(e,t,n)}function Sb(e,t){e.labelAttr=void 0,typeof t=="object"?(e.label="",e.labelAttr=t,Zo(e,t)):e.label=t??""}var Bc=class{type="c4";c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:"global",label:"global",type:"global",parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=new Map;boundaryIndex=new Map;relIndex=new Map;current=this.boundaries[0];stack=[];setC4Type(t){this.c4Type=t}setTitle(t){this.title=t}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
65
+ `)}element(t,n,r,i){let s=typeof r=="string"?n.get(r):void 0;return s===void 0&&(s={alias:"",label:"",parent:void 0},t.push(s),typeof r=="string"?(s.alias=r,n.set(r,s)):(s.aliasAttr=r,Zo(s,r))),Sb(s,i),s}addPersonOrSystem(t,n){let r=this.element(this.shapes,this.shapeIndex,n[0],n[1]);zi(r,"descr",n[2]),this.finishShape(r,t,n,3)}addContainer(t,n){let r=this.element(this.shapes,this.shapeIndex,n[0],n[1]);zi(r,"techn",n[2]),zi(r,"descr",n[3]),this.finishShape(r,t,n,4)}addComponent(t,n){this.addContainer(t,n)}finishShape(t,n,r,i){Vt(t,"sprite",r[i]),Vt(t,"tags",r[i+1]),Vt(t,"link",r[i+2]),t.kind=n,t.parent=this.current}boundary(t,n){let r=this.element(this.boundaries,this.boundaryIndex,t[0],t[1]);return t[2]===void 0?r.type=n:Vt(r,"type",t[2]),r}open(t){t.parent=this.current,this.stack.push(this.current),this.current=t}addPersonOrSystemBoundary(t,n="system"){let r=this.boundary(t,n);Vt(r,"tags",t[3]),Vt(r,"link",t[4]),this.open(r)}addContainerBoundary(t){this.addPersonOrSystemBoundary(t,"container")}addDeploymentNode(t,n){let r=this.boundary(n,"node");zi(r,"descr",n[3]),Vt(r,"sprite",n[4]),Vt(r,"tags",n[5]),Vt(r,"link",n[6]),r.nodeType=t,this.open(r)}popBoundaryParseStack(){this.current=this.stack.pop()??this.boundaries[0]}addRel(t,n){let r=n[0],i=n[1];if(r===void 0||i===void 0||n[2]===void 0)return;let s=typeof r=="string"&&typeof i=="string",a=s?this.relIndex.get(r)?.get(i):void 0;if(a===void 0){if(a={type:t,from:"",to:"",label:""},this.rels.push(a),s){let o=this.relIndex.get(r);o===void 0&&this.relIndex.set(r,o=new Map),o.set(i,a)}typeof r=="string"?a.from=r:a.fromAttr=r,typeof i=="string"?a.to=i:a.toAttr=i}a.type=t,Sb(a,n[2]),zi(a,"techn",n[3]),zi(a,"descr",n[4]),Vt(a,"sprite",n[5]),Vt(a,"tags",n[6]),Vt(a,"link",n[7])}getC4Shape(t){return this.shapeIndex.get(t)??this.boundaryIndex.get(t)}updateElStyle(t,n){let r=typeof n[0]=="string"?this.getC4Shape(n[0]):void 0;r!==void 0&&(Vt(r,"bgColor",n[1]),Vt(r,"fontColor",n[2]),Vt(r,"borderColor",n[3]),Vt(r,"shadowing",n[4]),Vt(r,"shape",n[5]),Vt(r,"sprite",n[6]),Vt(r,"techn",n[7]),Vt(r,"legendText",n[8]),Vt(r,"legendSprite",n[9]))}updateRelStyle(t,n){let r=n[0],i=n[1],s=typeof r=="string"&&typeof i=="string"?this.relIndex.get(r)?.get(i):void 0;if(s===void 0)return;Vt(s,"textColor",n[2]),Vt(s,"lineColor",n[3]);let a=n[4],o=n[5];typeof a=="string"?s.offsetX=parseInt(a):a!==void 0&&Zo(s,a),typeof o=="string"?s.offsetY=parseInt(o):o!==void 0&&Zo(s,o)}updateLayoutConfig(t,n){let r=a=>a===void 0?NaN:parseInt(typeof a=="string"?a:a.value),i=r(n[0]),s=r(n[1]);i>=1&&(this.shapeInRow=i),s>=1&&(this.boundaryInRow=s)}};var tf=["$end","INVALID","direction_tb","direction_bt","direction_rl","direction_lr","title","accDescription","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","NEWLINE","C4_CONTEXT","C4_CONTAINER","C4_COMPONENT","C4_DYNAMIC","C4_DEPLOYMENT","PERSON","PERSON_EXT","SYSTEM","SYSTEM_DB","SYSTEM_QUEUE","SYSTEM_EXT","SYSTEM_EXT_DB","SYSTEM_EXT_QUEUE","CONTAINER","CONTAINER_DB","CONTAINER_QUEUE","CONTAINER_EXT","CONTAINER_EXT_DB","CONTAINER_EXT_QUEUE","COMPONENT","COMPONENT_DB","COMPONENT_QUEUE","COMPONENT_EXT","COMPONENT_EXT_DB","COMPONENT_EXT_QUEUE","ENTERPRISE_BOUNDARY","SYSTEM_BOUNDARY","BOUNDARY","CONTAINER_BOUNDARY","NODE","NODE_L","NODE_R","REL","BIREL","REL_U","REL_D","REL_L","REL_R","REL_B","REL_INDEX","UPDATE_EL_STYLE","UPDATE_REL_STYLE","UPDATE_LAYOUT_CONFIG","EOF_IN_STRUCT","ATTRIBUTE_EMPTY","STR","STR_KEY","STR_VALUE","LBRACE","RBRACE","EOF"];var y2=new Map([["C4Context",14],["C4Container",15],["C4Component",16],["C4Dynamic",17],["C4Deployment",18],["Person",19],["Person_Ext",20],["System",21],["SystemDb",22],["SystemQueue",23],["System_Ext",24],["SystemDb_Ext",25],["SystemQueue_Ext",26],["Container",27],["ContainerDb",28],["ContainerQueue",29],["Container_Ext",30],["ContainerDb_Ext",31],["ContainerQueue_Ext",32],["Component",33],["ComponentDb",34],["ComponentQueue",35],["Component_Ext",36],["ComponentDb_Ext",37],["ComponentQueue_Ext",38],["Enterprise_Boundary",39],["System_Boundary",40],["Boundary",41],["Container_Boundary",42],["Deployment_Node",43],["Node",43],["Node_L",44],["Node_R",45],["Rel",46],["BiRel",47],["Rel_Up",48],["Rel_U",48],["Rel_Down",49],["Rel_D",49],["Rel_Left",50],["Rel_L",50],["Rel_Right",51],["Rel_R",51],["Rel_Back",52],["RelIndex",53],["UpdateElementStyle",54],["UpdateRelStyle",55],["UpdateLayoutConfig",56]]),nf=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],rf=/[\n\r\u2028\u2029]/g,sf=/title[^\S\r\n]*(?=[\r\n]|$)\s*/y;function wb(e){let t=e.length,n=[],r=[],i=[],s=0,a=9,o=0,c=!1,l=-2,u=-1,h=0,d=(E,b,S)=>{n.push(E),r.push(b),i.push(S),o=S},m=E=>{for(;E<t&&Xe(e.charCodeAt(E));)E++;return E},p=(E,b)=>{let S=e.indexOf(E,b);return S===-1?t:S},y=(E,b)=>{let S=o+E.length;if(!e.startsWith(E,o)||!Xe(e.charCodeAt(S)))return!1;let x=++S;for(;S<t;){let I=e.charCodeAt(S);if(I===35||I===10||I===59)break;S++}return S===x?!1:(d(b,o,S),!0)};for(;;){if(c){d(0,t,t);break}o>=t&&(c=!0);let E=e.charCodeAt(o);if(s===0){if(o>=t){d(64,t,t);continue}if(l!==-1&&o>=h&&(l<o&&(l=e.indexOf("direction",o)),l!==-1&&(u<o&&(rf.lastIndex=o,u=rf.test(e)?rf.lastIndex-1:t),l<u))){let b=!1;for(let S=0;S<4&&!b;S++)nf[S].lastIndex=o,nf[S].test(e)&&(d(2+S,o,nf[S].lastIndex),b=!0);if(b)continue;h=u}if(E===116){if(sf.lastIndex=o,sf.test(e)){o=sf.lastIndex;continue}if(y("title",6))continue}if(E===97){if(y("accDescription",7))continue;let b=e.startsWith("accTitle",o);if(b||e.startsWith("accDescr",o)){let S=m(o+8),x=e.charCodeAt(S);if(x===58){d(b?8:10,o,m(S+1)),a=b?9:11,s=7;continue}if(x===123&&!b){o=m(S+1),s=8;continue}}}if(E===37&&e.charCodeAt(o+1)===37){let b=p(`
66
+ `,o+2);for(;b<t&&(e.charCodeAt(b)===10||e.charCodeAt(b)===13);)b++;o=b;continue}if(Xe(E)){let b=o,S=-1;for(;b<t;){let x=e.charCodeAt(b);if(!Xe(x))break;x===10&&(S=b),b++}S!==-1?d(13,o,S+1):o=b;continue}if(E===123){d(62,o,o+1);continue}if(E===125){d(63,o,o+1);continue}if(it(E)){let b=o+1;for(;b<t&&it(e.charCodeAt(b));)b++;let S=b-o<=19?y2.get(e.slice(o,b)):void 0;if(S!==void 0){S>18&&(s=1),d(S,o,b);continue}}d(1,o,o);break}if(s===1){if(o>=t)d(57,t,t);else if(E===40){let b=o+1;for(;e.charCodeAt(b)===32;)b++;e.charCodeAt(b)===44?d(58,o,b+1):o++,s=2}else if(E===41)o++,s=0;else{d(1,o,o);break}continue}if(s===2){if(o>=t)continue;if(E===41)o++,s=0;else if(E===44)e.charCodeAt(o+1)===44?d(58,o,o+2):o++;else{let b=o;for(;e.charCodeAt(b)===32;)b++;let S=e.charCodeAt(b);S===34?e.charCodeAt(b+1)===34?d(58,o,b+2):(o=b+1,s=3):S===36?(o=b+1,s=4):d(59,o,p(",",o))}continue}if(s===3){E===34?(o++,s=2):d(59,o,p('"',o));continue}if(s===4){d(60,o,p("=",o)),s=5;continue}if(s===5){if(o>=t)continue;let b=o+1;if(E===61)for(;e.charCodeAt(b)===32;)b++;if(E!==61||e.charCodeAt(b)!==34){d(1,o,o);break}o=b+1,s=6;continue}if(s===6){if(o>=t)continue;E===34?(o++,s=2):d(61,o,p('"',o));continue}if(s===7){d(a,o,p(`
67
+ `,o)),s=0;continue}E===125?(o++,s=0):d(12,o,p("}",o))}return{types:n,starts:r,ends:i}}var of=["person","external_person","system","system_db","system_queue","external_system","external_system_db","external_system_queue","container","container_db","container_queue","external_container","external_container_db","external_container_queue","component","component_db","component_queue","external_component","external_component_db","external_component_queue"],E2=["rel","birel","rel_u","rel_d","rel_l","rel_r","rel_b","rel"],x2=["node","nodeL","nodeR"],A2="'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'",S2="'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'";function w2(e){return e===6||e===7||e===8||e===10||e===12}function _b(e){return e>=19&&e<=56}function Rb(e,t){let{types:n,starts:r,ends:i}=wb(e),s=0,a=y=>e.slice(r[y],i[y]),o=y=>{let E=n[s];throw E===1?ut("c4",e,r[s],"",!0):ut("c4",e,r[s],`Expecting ${y}, got '${tf[E]}'`)},c=y=>{n[s]!==y&&o(`'${tf[y]}'`),s++},l=()=>{let y=[];for(;;){let E=n[s];if(E===59)y.push(a(s++).trim());else if(E===58)y.push(""),s++;else if(E===60)s++,n[s]!==61&&o("'STR_VALUE'"),y.push({key:a(s-1).trim(),value:a(s).trim()}),s++;else break}return y.length===0&&o(S2),y},u=y=>{y===6?t.setTitle(a(s++).substring(6)):y===7?t.setAccDescription(a(s++).substring(15)):y===12?t.setAccDescription(a(s++).trim()):(s++,y===8?(n[s]!==9&&o("'acc_title_value'"),t.setTitle(a(s++).trim())):(n[s]!==11&&o("'acc_descr_value'"),t.setAccDescription(a(s++).trim())))},h=y=>{s++;let E=l();if(y<=26)t.addPersonOrSystem(of[y-19],E);else if(y<=32)t.addContainer(of[y-19],E);else if(y<=38)t.addComponent(of[y-19],E);else{if(y<=45)return y===39?E.splice(2,0,"ENTERPRISE"):y===40?E.splice(2,0,"SYSTEM"):y===42&&E.splice(2,0,"CONTAINER"),y>=43?t.addDeploymentNode(x2[y-43],E):y===42?t.addContainerBoundary(E):t.addPersonOrSystemBoundary(E),n[s]===62?(s++,c(13)):n[s]===13?(s++,c(62),n[s]===13&&s++):o("'NEWLINE', 'LBRACE'"),!0;y<=53?(y===53&&E.splice(0,1),t.addRel(E2[y-46],E)):y===54?t.updateElStyle("update_el_style",E):y===55?t.updateRelStyle("update_rel_style",E):t.updateLayoutConfig("update_layout_config",E)}return!1},d=n[s];(d<14||d>18)&&o(A2),s++,c(13);let m=0,p=0;for(;;){let y=n[s];if(p===3||p===4){if(y===13){s++,p=2;continue}if(p===3&&_b(y)){p=1;continue}}else if(_b(y)){h(y)?(m++,p=1):p=4;continue}else if(w2(y)&&p!==1){u(y),p=3;continue}else p!==2&&o("'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'");if(m>0)y!==63&&o("'NEWLINE', 'RBRACE'"),s++,t.popBoundaryParseStack(),m--,p=4;else{y!==64&&o("'NEWLINE', 'EOF'"),s++,c(0),t.setC4Type(a(0));return}}}var af=/\s/;function qs(e,t,n,r,i=0){let s=[];for(let l of e.split(`
68
+ `)){let u=Array.from(l);u.length===0&&s.push("");let h=0;for(;h<u.length;){let d=S=>t.width(u.slice(h,h+S).join(""),n,i)<=r,m=1;for(;m<u.length-h&&d(m);)m=Math.min(u.length-h,m*2);let p=1;for(;p<m;){let S=Math.ceil((p+m)/2);d(S)?p=S:m=S-1}let y=p,E=h+y<u.length;if(E&&!af.test(u[h+y])){for(let S=y-1;S>0;S--)if(af.test(u[h+S])){y=S+1;break}}let b=u.slice(h,h+y).join("");for(s.push(E&&b.trimEnd()||b),h+=y;E&&h<u.length&&af.test(u[h]);)h++}}e===""&&(s.length=0);let a=s.map(l=>t.width(l,n,i)),o=0;for(let l of a)o=Math.max(o,l);let c=Math.round(n*1.5);return{lines:s.map((l,u)=>[{text:l,style:i,width:a[u]}]),widths:a,width:o,height:s.length*c,size:n,lineHeight:c}}function Qs(e,t,n){if(e.width<=n)return e;let r=[],i=[];for(let o=0;o<e.lines.length;o++){if(e.widths[o]<=n){r.push(e.lines[o]),i.push(e.widths[o]);continue}let c=[],l=0,u=()=>{r.push(c),i.push(l),c=[],l=0};for(let h of e.lines[o]){if(h.icon!==void 0||h.math){c.length&&l+h.width>n&&u(),c.push(h),l+=h.width;continue}for(let d of Array.from(h.text)){let m=c[c.length-1],p=m&&m.icon===void 0&&m.math===void 0&&m.style===h.style,E=t.width(p?m.text+d:d,e.size,h.style)-(p?m.width:0);c.length&&l+E>n&&(u(),m=void 0,E=t.width(d,e.size,h.style)),m&&m.icon===void 0&&m.math===void 0&&m.style===h.style?(m.text+=d,m.width+=E):c.push({text:d,style:h.style,width:E}),l+=E}}(c.length||!e.lines[o].length)&&u()}let s=0;for(let o of i)s=Math.max(s,o);let a={...e,lines:r,widths:i,width:s,height:r.length*e.lineHeight};return e.heights?zo(a):a}function Qr(e,t,n,r){let i=jr(e),s="<text"+Xn(r,i),a="";for(let o=0;o<e.lines.length;o++){let c=e.lines[o],l=n+(o+.5)*e.lineHeight;if(c.some(h=>h.icon!==void 0)){let h=e.widths[o];a+=Ce({...e,lines:[c],widths:[h],width:h,height:e.lineHeight},t+h/2,l,r);continue}let u="";for(let h of c){let d=wr(h.style&~i);u+=d?`<tspan${d}>${nt(h.text)}</tspan>`:nt(h.text)}u!==""&&(a+=`${s} x="${f(t)}" y="${f(l+e.size*.35)}" text-anchor="start" xml:space="preserve">${u}</text>`)}return a}var Vi=28,Js=20,Cb=7,_2=8,R2=30,ea=88,Wc=160,Yc=8,ta=26,lf=e=>Math.min(12,Math.max(6,e/14)),df=e=>Math.min(12,e/4);function Zs(e,t,n,r,i,s,a,o){let c=0,l=1;if(a===0){if(i<e||i>n)return 1/0}else{let u=(e-i)/a,h=(n-i)/a;c=Math.max(c,Math.min(u,h)),l=Math.min(l,Math.max(u,h))}if(o===0){if(s<t||s>r)return 1/0}else{let u=(t-s)/o,h=(r-s)/o;c=Math.max(c,Math.min(u,h)),l=Math.min(l,Math.max(u,h))}return c<=l?c:1/0}function Jo(e,t,n,r,i,s,a,o){let c=a/n,l=o/r,u=(i-e)/n,h=(s-t)/r,d=c*c+l*l,m=2*(c*u+l*h),p=u*u+h*h-1,y=m*m-4*d*p;if(d===0||y<0)return 1/0;let E=(-m-Math.sqrt(y))/(2*d);return E>=0&&E<=1?E:p<=0?0:1/0}function Gn(e,t,n,r,i){let{x:s,y:a,w:o,h:c}=e,l=r-t,u=i-n;if(e.form==="person")return Math.min(Zs(s,a+ta,s+o,a+c,t,n,l,u),Jo(s+o/2,a+14,13,13,t,n,l,u));if(e.form==="cyl"){let h=lf(o);return Math.min(Zs(s,a+h,s+o,a+c-h,t,n,l,u),Jo(s+o/2,a+h,o/2,h,t,n,l,u),Jo(s+o/2,a+c-h,o/2,h,t,n,l,u))}if(e.form==="h-cyl"){let h=df(c);return Math.min(Zs(s+h,a,s+o-h,a+c,t,n,l,u),Jo(s+h,a+c/2,h,c/2,t,n,l,u),Jo(s+o-h,a+c/2,h,c/2,t,n,l,u))}return Zs(s,a,s+o,a+c,t,n,l,u)}function uf(e,t,n,r,i){for(let s=2;s<e.length;s+=2){let a=e[s-2],o=e[s-1];if(Zs(t,n,r,i,a,o,e[s]-a,e[s+1]-o)<=1)return!0}return!1}function Uc(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.w>=t.x+t.w&&e.y+e.h>=t.y+t.h}function T2(e,t,n){let r=e.x+e.w/2,i=e.y+e.h/2,s=t.x+t.w/2,a=t.y+t.h/2,o=Uc(e,t);if(o||Uc(t,e)){let L=o?e:t,O=o?t:e,v=O.x+O.w/2,G=O.y+O.h/2,K=O.x-L.x,C=L.x+L.w-O.x-O.w,Z=O.y-L.y,oe=L.y+L.h-O.y-O.h,H=Math.min(K,C,Z,oe),z=H===K?L.x:H===C?L.x+L.w:v,M=H===K||H===C?G:H===oe?L.y+L.h:L.y,T=Math.min(Gn(O,z,M,v,G),1),R=z+(v-z)*T,_=M+(G-M)*T;return o?[z,M,R,_]:[R,_,z,M]}let c=r,l=i,u=s,h=a,d=Math.max(e.x,t.x),m=Math.min(e.x+e.w,t.x+t.w),p=Math.max(e.y,t.y),y=Math.min(e.y+e.h,t.y+t.h);d<m?c=u=(d+m)/2:p<y&&(l=h=(p+y)/2);let E=Math.hypot(u-c,h-l)||1,b=-(h-l)/E*n,S=(u-c)/E*n,x=Gn(e,u+b,h+S,c+b,l+S),I=Gn(t,c+b,l+S,u+b,h+S);return x<=1&&I<=1?(c+=b,l+=S,u+=b,h+=S):(c=r,l=i,u=s,h=a,x=Math.min(Gn(e,u,h,c,l),1),I=Math.min(Gn(t,c,l,u,h),1)),[u+(c-u)*x,h+(l-h)*x,c+(u-c)*I,l+(h-l)*I]}var cf=6,M2=3,Tb=12,Gc=class{upright=[];level=[];frames=[[],[]];taken=new Map;squeezed=0;free(t,n,r,i){let s=Math.min(r,i),a=Math.max(r,i),o=(c,l)=>{for(let u=0;u<c.length;u+=3)if(Math.abs(c[u]-n)<l&&c[u+1]<a&&c[u+2]>s)return!0;return!1};return!o(t?this.upright:this.level,cf)&&!o(this.frames[t?0:1],M2)}crossings(t){let n=0;for(let r=2;r<t.length;r+=2){let i=t[r]===t[r-2],s=i?t[r]:t[r+1],a=Math.min(i?t[r-1]:t[r-2],i?t[r+1]:t[r]),o=Math.max(i?t[r-1]:t[r-2],i?t[r+1]:t[r]),c=i?this.level:this.upright;for(let l=0;l<c.length;l+=3)c[l]>a&&c[l]<o&&c[l+1]<s&&c[l+2]>s&&n++}return n}frame(t){this.frames[0].push(t.x,t.y,t.y+t.h,t.x+t.w,t.y,t.y+t.h),this.frames[1].push(t.y,t.x,t.x+t.w,t.y+t.h,t.x,t.x+t.w)}take(t){for(let n=2;n<t.length;n+=2)t[n]===t[n-2]?this.upright.push(t[n],Math.min(t[n-1],t[n+1]),Math.max(t[n-1],t[n+1])):t[n+1]===t[n-1]&&this.level.push(t[n+1],Math.min(t[n-2],t[n]),Math.max(t[n-2],t[n]))}ports(t,n,r,i,s){let a=this.taken.get(t)??[],o=[];for(let c=0;c<9&&o.length<4;c++){let l=r+(c&1?1:-1)*Math.ceil(c/2)*Tb;if(l<i||l>s)continue;let u=!0;for(let h=0;h<a.length;h+=2)a[h]===n&&Math.abs(a[h+1]-l)<Tb&&(u=!1);u&&o.push(l)}return o.length?o:[r]}claim(t,n,r){let i=this.taken.get(t);i?i.push(n,r):this.taken.set(t,[n,r])}};function C2(e,t,n){let r=e.length,i=Math.sign(e[2]-e[0]),s=Math.sign(e[3]-e[1]),a=`M${f(e[0]+i*t)},${f(e[1]+s*t)}`;for(let l=2;l<r-2;l+=2){let u=e[l],h=e[l+1],d=Math.sign(u-e[l-2]),m=Math.sign(h-e[l-1]),p=Math.sign(e[l+2]-u),y=Math.sign(e[l+3]-h),E=Math.min(_2,Math.abs(u-e[l-2]+h-e[l-1])/2,Math.abs(e[l+2]-u+e[l+3]-h)/2);a+=`${d?"H"+f(u-d*E):"V"+f(h-m*E)}Q${f(u)},${f(h)} ${f(u+p*E)},${f(h+y*E)}`}let o=Math.sign(e[r-2]-e[r-4]),c=Math.sign(e[r-1]-e[r-3]);return a+(o?"H"+f(e[r-2]-o*n):"V"+f(e[r-1]-c*n))}function Nb(e,t,n,r){for(let i of t)if(i!==n&&i!==r&&uf(e,i.x,i.y,i.x+i.w,i.y+i.h))return!1;return!0}function Ib(e,t,n,r,i){let s=e.length;return{d:C2(e,n,r),sx:e[0],sy:e[1],sdx:-Math.sign(e[2]-e[0]),sdy:-Math.sign(e[3]-e[1]),ex:e[s-2],ey:e[s-1],edx:Math.sign(e[s-2]-e[s-4]),edy:Math.sign(e[s-1]-e[s-3]),x0:e[t],y0:e[t+1],x1:e[t+2],y1:e[t+3],nx:0,ny:0,lean:0,room:Wc,...i,points:e}}function Mb(e,t){let n=[],r=(e+t)/2,i=Math.max(Cb,(t-e)/4);for(let s=0;s<9;s++){let a=r+(s&1?1:-1)*Math.ceil(s/2)*i;a>=e+cf&&a<=t-cf&&n.push(a)}return n}function N2(e,t,n,r,i,s){let a=e.x+e.w/2,o=e.y+e.h/2,c=t.x+t.w/2,l=t.y+t.h/2,u,h=(y,E,b)=>{if(!Nb(y,n,e,t))return;for(let x=2;x<y.length;x+=2){let I=y[x]===y[x-2];if(!r.free(I,I?y[x]:y[x+1],I?y[x-1]:y[x-2],I?y[x+1]:y[x]))return}let S=r.crossings(y)*1e6;for(let x=2;x<y.length;x+=2)S+=Math.abs(y[x]-y[x-2])+Math.abs(y[x+1]-y[x-1]);(!u||S<u.cost)&&(u={points:y,cost:S,upright:E,sides:b})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let y=c>a,E=Math.sign(l-o),b=y?[1,0]:[0,1],S=Mb(y?e.x+e.w:t.x+t.w,y?t.x:e.x);e:for(let x of r.ports(e,b[0],o+E*e.h/4,e.y+8,e.y+e.h-8))for(let I of r.ports(t,b[1],l-E*t.h/4,t.y+8,t.y+t.h-8))for(let L of S){let O=L+(a-L)*Math.min(Gn(e,L,x,a,x),1),v=L+(c-L)*Math.min(Gn(t,L,I,c,I),1),G=u;if(h([O,x,L,x,L,I,v,I],!0,b),u!==G)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let y=l>o,E=Math.sign(c-a),b=y?[3,2]:[2,3],S=Mb(y?e.y+e.h:t.y+t.h,y?t.y:e.y);e:for(let x of r.ports(e,b[0],a+E*e.w/4,e.x+8,e.x+e.w-8))for(let I of r.ports(t,b[1],c-E*t.w/4,t.x+8,t.x+t.w-8))for(let L of S){let O=L+(o-L)*Math.min(Gn(e,x,L,x,o),1),v=L+(l-L)*Math.min(Gn(t,I,L,I,l),1),G=u;if(h([x,O,x,L,I,L,I,v],!1,b),u!==G)break e}}if(!u)return;let{points:d,upright:m,sides:p}=u;return r.take(d),r.claim(e,p[0],m?d[1]:d[0]),r.claim(t,p[1],m?d[7]:d[6]),Ib(d,2,i,s,{room:m?ea:Wc})}function kb(e,t,n,r,i,s,a){if(e===t){let E=Math.min(e.h/2-4,10),b=Math.hypot(Vi,E),S=e.x+e.w,x=e.y+e.h/2,I=Vi/b,L=E/b;return{d:`M${f(S+I*s)},${f(x-E-L*s)}C${f(S+Vi)},${f(x-E*2)} ${f(S+Vi)},${f(x+E*2)} ${f(S+I*a)},${f(x+E+L*a)}`,sx:S,sy:x-E,sdx:-I,sdy:L,ex:S,ey:x+E,edx:-I,edy:-L,x0:S+Vi+4,y0:x,x1:S+Vi+4,y1:x,nx:1,ny:0,lean:0,room:64,points:[]}}let[o,c,l,u]=T2(e,t,n),h=o===l,d=!1;if(r&&!Uc(e,t)&&!Uc(t,e))for(let E of r)E!==e&&E!==t&&Zs(E.x,E.y,E.x+E.w,E.y+E.h,o,c,l-o,u-c)<=1&&(d=!0);if(r&&d&&!h&&c!==u){let E=N2(e,t,r,i,s,a);if(E)return E;i.squeezed++}if(r&&d&&(h||c===u)){let E=A=>{let D=A?-1/0:1/0,U=B=>{let F=h?B.x:B.y;D=A?Math.max(D,F+(h?B.w:B.h)):Math.min(D,F)};U(e),U(t);for(let B of r)B!==e&&B!==t&&Zs(B.x,B.y,B.x+B.w,B.y+B.h,o,c,l-o,u-c)<=1&&U(B);return D},b=h?Math.min(e.y,t.y):Math.min(e.x,t.x),S=h?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),x=(A,D)=>{for(let U of r){if(U===e||U===t)continue;let B=h?U.y<S&&U.y+U.h>b:U.x<S&&U.x+U.w>b,F=h?U.x:U.y,W=F+(h?U.w:U.h);if(B&&(A?W>D:F<D))return!1}return!0},I=e.x+e.w/2,L=e.y+e.h/2,O=t.x+t.w/2,v=t.y+t.h/2,G=Math.sign(h?v-L:O-I),K=A=>{let D=E(A),U=A?1:-1,B=h?A?1:0:A?3:2,F=h?i.ports(e,B,L+G*e.h/4,e.y+8,e.y+e.h-8)[0]:i.ports(e,B,I+G*e.w/4,e.x+8,e.x+e.w-8)[0],W=h?i.ports(t,B,v-G*t.h/4,t.y+8,t.y+t.h-8)[0]:i.ports(t,B,O-G*t.w/4,t.x+8,t.x+t.w-8)[0],j=Y=>{if(h){let k=Y+(I-Y)*Math.min(Gn(e,Y,F,I,F),1),J=Y+(O-Y)*Math.min(Gn(t,Y,W,O,W),1);return[k,F,Y,F,Y,W,J,W]}let ne=Y+(L-Y)*Math.min(Gn(e,F,Y,F,L),1),q=Y+(v-Y)*Math.min(Gn(t,W,Y,W,v),1);return[F,ne,F,Y,W,Y,W,q]},Q=j(D+U*Js);for(let Y=0;Y<=4;Y++){let ne=D+U*(Js+Y*Cb),q=j(ne);if(Nb(q,r,e,t)&&(Q=q,i.free(h,ne,F,W)))return{points:Q,side:B,p0:F,p1:W,step:Y}}return{points:Q,side:B,p0:F,p1:W,step:5}},C=h?u>c:l<o,Z=x(C,E(C)),oe=x(!C,E(!C)),H=K(C),z=Z===oe?K(!C):void 0,M=A=>i.crossings(A.points)*8+A.step,T=oe&&!Z||z&&M(z)<M(H)?!C:C,{points:R,side:_,p0:$,p1:g,step:N}=T===C?H:z??K(!C),w=T?1:-1;return N>4&&i.squeezed++,i.take(R),i.claim(e,_,$),i.claim(t,_,g),Ib(R,2,s,a,h?{nx:w,lean:R2,room:ea}:{room:Wc})}let m=Math.hypot(l-o,u-c)||1,p=(l-o)/m,y=(u-c)/m;return(h||c===u)&&i.take([o,c,l,u]),{d:`M${f(o+p*s)},${f(c+y*s)}L${f(l-p*a)},${f(u-y*a)}`,sx:o,sy:c,sdx:-p,sdy:-y,ex:l,ey:u,edx:p,edy:y,x0:o,y0:c,x1:l,y1:u,nx:n?-y:0,ny:n?p:0,lean:0,room:Math.abs(p)>Math.abs(y)?ea:Wc,points:[o,c,l,u]}}var hf=216,I2=64,$b=14,k2=12,$2=ea+Yc+3*$t,L2=88,Lb=Js+8,Hc=48,ji=16,Kc=10,ff=new Map([["person","person"],["box","rect"],["rounded","rect"],["component","rect"],["cylinder","cyl"],["database","cyl"],["db","cyl"],["queue","h-cyl"],["pipe","h-cyl"]]);function O2(e){let t=ff.get((e.shape??"").toLowerCase())??ff.get((e.sprite??"").toLowerCase());if(t)return t;if(e.tags)for(let r of e.tags.split(",")){let i=ff.get(r.trim().toLowerCase());if(i)return i}let n=e.kind;return n.endsWith("person")?"person":n.endsWith("_db")?"cyl":n.endsWith("_queue")?"h-cyl":"rect"}function D2(e,t,n,r,i=hf){let s=O2(e),a=s==="h-cyl"?36:0,o=s==="person"?ta:s==="cyl"?24:0,c=i-2*$b-a,l=[Ue("«"+e.kind.replace(/_/g," ")+"»",!1,t,r-1,c),Ue(e.label,!1,t,n,c,1),Ue(e.techn?`[${e.techn}]`:void 0,!1,t,r,c),Ue(e.descr,!1,t,r,c)],u=0,h=l[3].height>0?4:0;for(let d of l)u=Math.max(u,d.width),h+=d.height;return{shape:e,form:s,labels:l,textH:h,x:0,y:0,w:Math.max(i,u+2*$b+a),h:Math.max(I2,h+2*k2+o)}}function Ob(e,t,n,r,i){let s=0,a=0;for(let o=0;o<e.length;o+=t){let c=Math.min(e.length,o+t),l=0,u=0;for(let h=o;h<c;h++)u=Math.max(u,e[h].h);for(let h=o;h<c;h++){let d=e[h];d.x=l,d.y=a,i&&(d.h=u),l+=d.w+n}s=Math.max(s,l-n),a+=u+r}return[s,e.length>0?a-r:0]}function Db(e,t,n,r,i,s){let a=i===void 0?Lb:12,o=new Map;for(let y of e.boundaries){let E=i===void 0?4e3:Math.max(80,i-2*ji-2*Lb*2),b=y.parent?[Ue(y.label,!1,t,n,E,1),Ue(y.type?`[${y.type}]`:void 0,!1,t,r,E),Ue(y.descr,!1,t,r,E)]:[],S=0,x=0;for(let I of b)S+=I.height,x=Math.max(x,I.width);o.set(y,{boundary:y,kids:[],nodes:[],labels:b,head:S>0?S+Kc+6+Js:a,headW:x,headX:ji,x:0,y:0,w:0,h:0,form:"rect"})}let c=o.get(e.boundaries[0]);for(let y of o.values()){let E=y.boundary.parent;E&&o.get(E)?.kids.push(y)}let l=[c],u=new Map([[c.boundary,0]]);for(let y=0;y<l.length;y++)for(let E of l[y].kids)u.set(E.boundary,u.get(l[y].boundary)+1),l.push(E);for(let y of e.shapes)if(y.parent){let E=u.get(y.parent)??0,b=i===void 0?hf:Math.max(100,Math.min(hf,i-2*E*a-32));o.get(y.parent)?.nodes.push(D2(y,t,n,r,b))}let h=Math.max(1,e.shapeInRow),d=Math.max(1,e.boundaryInRow),m=new Map;for(let y=l.length-1;y>=0;y--){let E=l[y],b=i===void 0?$2:s,S=(K,C,Z)=>{if(i===void 0)return C;let oe=1;for(let H of K)oe=Math.max(oe,H.w);return Math.max(1,Math.min(C,Math.floor((i+Z-2*a)/(oe+Z))))},[x,I]=Ob(E.nodes,S(E.nodes,h,b),b,L2,!0),[L,O]=Ob(E.kids,S(E.kids,d,Hc),Hc,Hc,!1),v=I>0&&O>0?Hc:0,G=E===c?0:a;m.set(E,I+v),E.w=Math.max(x,L,E.headW+2*ji-2*G)+2*G,E.h=(G&&E.head)+I+v+O+G}let p=new Map;for(let y of l){let E=y.x+(y===c?0:a),b=y.y+(y===c?0:y.head);for(let S of y.nodes)S.x+=E,S.y+=b,p.set(S.shape,S);for(let S of y.kids)S.x+=E,S.y+=b+m.get(y);y!==c&&p.set(y.boundary,y)}return{order:l,boxes:p}}var v2=7,Vc=36,pf=24,vb=2e3,zc=8,P2=[.5,.4,.6,.3,.7,.2,.8],F2=2e6;function na(e,t,n){let r=[];return e&&r.push("fill:"+e),t&&r.push("stroke:"+t),n&&r.push("color:"+n),Mt(r)}function mf(e,t,n,r,i){return t?Qn(e,Ii(t.includes("¶ß")?t.replace(/\ufb02\u00b0\u00b0?/g,"#").replace(/\u00b6\u00df/g,";"):t),n,r,i):e}function Pb(e,t,n){return xn(n,r=>{if(!r)return gf(e,t,n,!1)[0];let[i,s]=gf(e,t,n,!0,Vc);for(let a=Vc+pf;s>0&&a<=Vc+3*pf;a+=pf){let[o,c]=gf(e,t,n,!0,a);c<s&&([i,s]=[o,c])}return i})}function gf(e,t,n,r,i=Vc){let s=n.fontSize??16,a=Math.round(s*.8125),o=n.measurer??at(n.fontFamily,n.fontFamilyMono),c=n.padding??8,l=[],{order:u,boxes:h}=Db(e,o,s,a,r?Math.max(80,(n.maxWidth??320)-2*c):void 0,i),d=u[0],m=0,p=0,y=d.w,E=d.h,b=(B,F,W,j)=>{m=Math.min(m,B),p=Math.min(p,F),y=Math.max(y,W),E=Math.max(E,j)},S=[],x=new Map;for(let B of e.rels){let F=B.fromAttr?void 0:e.getC4Shape(B.from),W=B.toAttr?void 0:e.getC4Shape(B.to),j=F&&h.get(F),Q=W&&h.get(W);if(!j||!Q)throw new qe(`C4 rel "${B.from}" -> "${B.to}" references an unknown shape or boundary`,"semantic",{type:"c4"});S.push(j,Q);let Y=x.get(j);Y||x.set(j,Y=new Set),Y.add(Q)}let I=[],L=[];for(let B of u)for(let F of B.nodes)I.push(F),L.push(F.x+zc,F.y+zc,F.x+F.w-zc,F.y+F.h-zc);let O=e.rels.length*(I.length+u.length+3*e.rels.length)<=F2,v=(B,F,W,j)=>{let Q=0;for(let Y=0;Y<L.length;Y+=4){let ne=Math.min(W,L[Y+2])-Math.max(B,L[Y]);if(ne<=0)continue;let q=Math.min(j,L[Y+3])-Math.max(F,L[Y+1]);q>0&&(Q+=ne*q)}return Q},G=B=>B?Math.max(-vb,Math.min(vb,B)):0,K="",C="",Z=_t("arrow_point"),oe=[];for(let B of u){if(B===d)continue;let F=na(B.boundary.bgColor,void 0,void 0).shape;Tn(F)&&oe.push({box:[B.x,B.y,B.x+B.w,B.y+B.h],shape:F})}let H=new Gc;for(let B of u)B!==d&&H.frame(B);let z=e.rels.map((B,F)=>{let W=S[F*2],j=S[F*2+1],Q=na(void 0,B.lineColor,void 0),Y=B.type==="birel"||B.type==="rel_b",ne=B.type!=="rel_b",q=W!==j&&x.get(j)?.has(W)===!0,k=kb(W,j,q?v2:0,O?I:void 0,H,Y?Z:0,ne?Z:0);b(Math.min(k.x0,k.x1),Math.min(k.y0,k.y1),Math.max(k.x0,k.x1),Math.max(k.y0,k.y1)),Y&&O&&L.push(k.sx-$t,k.sy-$t,k.sx+$t,k.sy+$t),ne&&O&&L.push(k.ex-$t,k.ey-$t,k.ex+$t,k.ey+$t);let J=Tr(k.d,[k.sx,k.sy,k.ex,k.ey],oe,Q.line),te=J||(Q.stroke?nt(Q.stroke):"var(--_l)");return J===""&&(K+=Mr(k,Y?"arrow_point":"none",ne?"arrow_point":"none",Q.line)),C+=`<g class="pele-edge" data-id="${We(B.from+"-"+B.to)}"${J?` stroke="${J}"`:""}${Q.line}><path d="${k.d}"/>`+(Y?wt("arrow_point",k.sx,k.sy,k.sdx,k.sdy,te):"")+(ne?wt("arrow_point",k.ex,k.ey,k.edx,k.edy,te):"")+"</g>",k});for(let B of u){if(!O||B.headW===0)continue;let F=B.y+Kc,W=B.y+B.head-Js,j=1/0;for(let Q of[ji,(B.w-B.headW)/2,B.w-ji-B.headW]){let Y=0;for(let ne of z)uf(ne.points,B.x+Q-4,F,B.x+Q+B.headW+4,W)&&Y++;if(Y<j&&(j=Y,B.headX=Q),Y===0)break}L.push(B.x+B.headX-4,F,B.x+B.headX+B.headW+4,W)}let M="";e.rels.forEach((B,F)=>{let W=z[F],j=B.from+"-"+B.to,Q=na(void 0,void 0,B.textColor),Y=(e.c4Type==="C4Dynamic"?F+1+": ":"")+B.label,ne=Ue(Y,!1,o,a,W.room),q=Ue(B.techn?`[${B.techn}]`:void 0,!1,o,a,W.room,2),k=Math.max(ne.width,q.width)+Yc,J=ne.height+q.height;if(J===0)return;let te=Math.abs(W.nx)*(k/2)+Math.abs(W.ny)*(J/2)+2,se=W.lean?Math.max(0,Math.min(W.lean,te-14)):te,re=W.nx*se+(r?0:G(B.offsetX)),P=W.ny*se+(r?0:G(B.offsetY)),ee=.5;if(O){let ce=1/0,he=re!==W.nx*se||P!==W.ny*se;for(let V=0;V<(he?2:1)&&ce>0;V++){let X=V?W.nx*se:re,le=V?W.ny*se:P;for(let de of P2){let Ae=W.x0+(W.x1-W.x0)*de+X,we=W.y0+(W.y1-W.y0)*de+le,Ee=v(Ae-k/2,we-J/2,Ae+k/2,we+J/2);if(Ee<ce&&(ce=Ee,ee=de,re=X,P=le),Ee===0)break}}}let ae=W.x0+(W.x1-W.x0)*ee+re,ue=W.y0+(W.y1-W.y0)*ee+P-J/2;O&&L.push(ae-k/2,ue,ae+k/2,ue+J),b(ae-k/2,ue,ae+k/2,ue+J),M+=`<g class="pele-edge-label" data-id="${We(j)}">`+(B.descr?`<title>${We(B.descr)}</title>`:"")+`<rect x="${f(ae-k/2)}" y="${f(ue)}" width="${f(k)}" height="${f(J)}" rx="3" fill="var(--_bg)"/>`+mf(Ce(ne,ae,ue+ne.height/2,Q.text)+Ce(q,ae,ue+ne.height+q.height/2,` class="pele-c4-techn" fill="var(--_m)"${Q.text}`),B.link,j,l,n)+"</g>"});let T="",R="";for(let B of u){if(B!==d){let F=B.boundary,W=na(F.bgColor,F.borderColor,F.fontColor),j=B.x+B.headX,Q=B.y+Kc,Y=Dt(W)+W.text,ne=Dt(W,"var(--_m)")+W.text,q=Qr(B.labels[0],j,Q,` class="pele-cluster-label" font-weight="var(--_hw)"${Y}`);Q+=B.labels[0].height,q+=Qr(B.labels[1],j,Q,` class="pele-c4-type" font-size="${a}"${ne}`),Q+=B.labels[1].height,q+=Qr(B.labels[2],j,Q,` class="pele-c4-descr" font-size="${a}"${ne}`),T+=`<g class="pele-cluster pele-c4-${F.nodeType?"node":"boundary"}" data-id="${We(F.alias)}"><rect x="${f(B.x)}" y="${f(B.y)}" width="${f(B.w)}" height="${f(B.h)}" fill="none" stroke="var(--_b)"${F.nodeType?"":' stroke-dasharray="6 4"'}${xt(W.shape)}/>`+mf(q,F.link,F.alias,l,n)+"</g>"}for(let F of B.nodes){let W=F.shape,j=W.kind.startsWith("external"),Q=na(W.bgColor,W.borderColor,W.fontColor),Y=' stroke="var(--_b)"'+(j?' stroke-dasharray="4 3"':""),{w:ne,h:q,form:k,labels:J}=F,te=k==="h-cyl"?-df(q)/2:0,se=k==="person"?ta/2:k==="cyl"?lf(ne)/2:0,re=Dt(Q)+Q.text,P=Dt(Q,"var(--_m)")+Q.text,ee=se-F.textH/2,ae=Ce(J[0],te,ee+J[0].height/2,` class="pele-c4-type" font-size="${a-1}"${P}`);ee+=J[0].height,ae+=Ce(J[1],te,ee+J[1].height/2,` class="pele-label" font-weight="var(--_hw)"${re}`),ee+=J[1].height,ae+=Ce(J[2],te,ee+J[2].height/2,` class="pele-c4-techn" font-size="${a}"${P}`),ee+=J[2].height+4,ae+=Ce(J[3],te,ee+J[3].height/2,` class="pele-c4-descr" font-size="${a}"${re}`),R+=`<g class="pele-node pele-shape-${k} pele-c4-${W.kind}${j?" pele-c4-external":""}" data-id="${We(W.alias)}" transform="translate(${f(F.x+ne/2)},${f(F.y+q/2)})">`+mf(fr(k,ne,q,` fill="var(${j?"--_bg":"--_s"})"${Y}${Q.shape}`,Y+Q.line)+ae,W.link,W.alias,l,n)+"</g>"}}let _=Ue(e.title,!1,o,s,r?It(n):4e3,1),$=_.height>0?_.height+12:0,g=Math.max(y-m,_.width),N=Math.ceil(g+2*c),w=Math.ceil(E-p+$+2*c),A=c-m+(g-(y-m))/2,D=c+$-p;return[{svg:ot("c4",N,w,s,n,e,Ce(_,N/2,c+_.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f(A)},${f(D)})">`+(T?`<g class="pele-clusters">${T}</g>`:"")+On(K)+(C?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${C}</g>`:"")+(R?`<g class="pele-nodes">${R}</g>`:"")+(M?`<g class="pele-edge-labels" font-size="${a}">${M}</g>`:"")+"</g>"),width:N,height:w,links:l},H.squeezed]}var Fb={type:"c4",parse(e,t,n){let r=new Bc;return n&&(r.title=n),Rb(e,r),r},render:Pb};function bf(e){let t=0;for(let n=e.indexOf("~");n!==-1;n=e.indexOf("~",n+1))t++;return t}function B2(e){let t=bf(e);if(t<=1)return e;let n=t%2!==0&&e.startsWith("~"),r=e.split(""),i=[];for(let s=n?1:0;s<r.length;s++)r[s]==="~"&&i.push(s);for(let s=0,a=i.length-1;s<a;s++,a--)r[i[s]]="<",r[i[a]]=">";return r.join("")}function Es(e){if(!e.includes("~"))return e;let t=e.split(/(,)/),n=[];for(let r=0;r<t.length;r++){let i=t[r];i===","&&r>0&&r+1<t.length&&bf(t[r-1])===1&&bf(t[r+1])===1&&(i=t[r-1]+","+t[r+1],r++,n.pop()),n.push(B2(i))}return n.join("")}function Bb(e){return e==="#"||e==="+"||e==="~"||e==="-"}var ra=class{id="";memberType;visibility="";classifier="";parameters="";returnType="";constructor(t,n){this.memberType=n,(n!=="method"||!this.parseMethod(t))&&this.parseAttribute(t),this.id=this.id.startsWith(" ")?" "+this.id.trim():this.id.trim()}parseMethod(t){let n=t.length;for(let r=0;r<n;){let i=r;for(;i<n&&!Ws(t.charCodeAt(i));)i++;let s=i-1;for(;s>r&&t.charCodeAt(s)!==41;)s--;let a=s-1;for(;a>r&&t.charCodeAt(a)!==40;)a--;if(a>r){let o=t[r],c=Bb(o)&&a>r+1;c&&(this.visibility=o),this.id=t.slice(c?r+1:r,a),this.parameters=t.slice(a+1,s).trim();let l=s+1,u="";if(l<n){let d=t[l];(d==="$"||d==="*"||d.trim()==="")&&(u=d.trim(),l++)}let h=l;for(;h<n&&!Ws(t.charCodeAt(h));)h++;if(this.returnType=t.slice(l,h).trim(),u===""){let d=this.returnType.slice(-1);(d==="$"||d==="*")&&(u=d,this.returnType=this.returnType.slice(0,-1))}return this.classifier=u,!0}r=i+1}return this.memberType="attribute",!1}parseAttribute(t){let n=t.slice(0,1),r=t.slice(-1);Bb(n)&&(this.visibility=n),(r==="$"||r==="*")&&(this.classifier=r),this.id=t.substring(this.visibility===""?0:1,this.classifier===""?t.length:t.length-1)}getDisplayDetails(){let t=this.visibility+Es(this.id);return this.memberType==="method"&&(t+=`(${Es(this.parameters.trim())})`,this.returnType&&(t+=" : "+Es(this.returnType))),{displayText:t.trim(),cssStyle:this.parseClassifier()}}parseClassifier(){return this.classifier==="*"?"font-style:italic;":this.classifier==="$"?"text-decoration:underline;":""}};var W2={LINE:0,DOTTED_LINE:1},Xi={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4},U2="classId-";function xs(e){let t=e.indexOf("~");if(t<=0)return{className:e,type:""};let n=e.indexOf("~",t+1);return{className:e.slice(0,t),type:e.slice(t+1,n===-1?e.length:n)}}function Wb(e){let t=e.charCodeAt(0);return xs(t>=48&&t<=57?U2+e:e).className}var jc=class{type="class";lineType=W2;relationType=Xi;direction="TB";classes=new Map;relations=[];notes=new Map;namespaces=new Map;interfaces=[];styleClasses=new Map;title;accTitle;accDescr;namespaceStack=[];withCssClass=new Map;addClass(t){let{className:n,type:r}=xs(t);if(this.classes.has(n))return;let i={id:n,type:r,label:n,cssClasses:"default",methods:[],members:[],annotations:[],styles:[]};this.classes.set(n,i),this.tag(i,"default")}tag(t,n){let r=this.withCssClass.get(n);r?r.add(t):this.withCssClass.set(n,new Set([t]))}ensure(t){return this.addClass(t),this.classes.get(xs(t).className)}setClassLabel(t,n){this.ensure(t).label=n}addRelation(t){let{type1:n,type2:r}=t.relation;n===Xi.LOLLIPOP&&r==="none"?(this.addClass(t.id2),t.id1=this.addInterface(t.id1,t.id2)):r===Xi.LOLLIPOP&&n==="none"?(this.addClass(t.id1),t.id2=this.addInterface(t.id2,t.id1)):(this.addClass(t.id1),this.addClass(t.id2)),t.id1=xs(t.id1).className,t.id2=xs(t.id2).className,t.relationTitle1=t.relationTitle1.trim(),t.relationTitle2=t.relationTitle2.trim(),this.relations.push(t)}addInterface(t,n){let r=`interface${this.interfaces.length}`;return this.interfaces.push({id:r,label:t,classId:n}),r}addAnnotation(t,n){this.ensure(t).annotations.push(n)}addMember(t,n){let r=this.ensure(t);if(typeof n!="string")return;let i=n.trim();if(i.startsWith("<<")&&i.endsWith(">>"))r.annotations.push(i.substring(2,i.length-2));else if(i.indexOf(")")>0){let s=new ra(i,"method");(s.memberType==="method"?r.methods:r.members).push(s)}else i&&r.members.push(new ra(i,"attribute"))}addMembers(t,n){if(Array.isArray(n)){n.reverse();for(let r of n)this.addMember(t,r)}}addNote(t,n){let r=this.notes.size,i=`note${r}`;return this.notes.set(i,{id:i,class:n,text:t,index:r}),i}cleanupLabel(t){return(t.startsWith(":")?t.substring(1):t).trim()}setCssClass(t,n){for(let r of t.split(",")){let i=this.classes.get(Wb(r));if(i!==void 0){i.cssClasses+=" "+n;for(let s of n.split(" "))this.tag(i,s)}}}defineClass(t,n){for(let r of t){let i=this.styleClasses.get(r);if(i===void 0&&(i={id:r,styles:[],textStyles:[]},this.styleClasses.set(r,i)),!n)continue;for(let o of n)o.includes("color")&&i.textStyles.push(o.replace("fill","bgFill")),i.styles.push(o);let s=this.withCssClass.get(r);if(s===void 0)continue;let a=n.flatMap(o=>o.split(","));for(let o of s)for(let c of a)o.styles.push(c)}}setTooltip(t,n){if(n!==void 0)for(let r of t.split(",")){let i=this.classes.get(xs(r).className);i&&(i.tooltip=n)}}setLink(t,n,r){let i=gt(n).trim();for(let s of t.split(",")){let a=this.classes.get(Wb(s));a&&(a.link=i?Ii(i):void 0,a.linkTarget=typeof r=="string"?r:"_blank")}this.setCssClass(t,"clickable")}setClickEvent(t,n,r){for(let i of t.split(",")){let s=this.classes.get(xs(i).className);s&&(s.haveCallback=!0)}this.setCssClass(t,"clickable")}setDirection(t){this.direction=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
69
+ `)}addNamespace(t,n){let r=this.namespaceStack[this.namespaceStack.length-1],i=r?`${r}.${t}`:t;this.namespaceStack.push(i);let s=this.namespaces.get(i);if(s)return s.explicit=!0,n&&(s.label=n),i;let a=r||void 0,o=r?r.length+1:0;for(;;){let c=i.indexOf(".",o),l=c===-1,u=l?i:i.slice(0,c),h=this.namespaces.get(u);if(h===void 0){let m=i.slice(o,l?i.length:c);h={id:u,label:l&&n?n:m,classes:new Map,notes:new Map,children:new Map,parent:a,explicit:l},this.namespaces.set(u,h)}else l&&(h.explicit=!0);let d=a?this.namespaces.get(a):void 0;if(d&&(d.children.has(u)||d.children.set(u,h),h.parent??=a),l)return i;a=u,o=c+1}}popNamespace(){this.namespaceStack.pop()}addClassesToNamespace(t,n,r){let i=this.namespaces.get(t);if(i!==void 0){for(let s of n){let{className:a}=xs(s),o=this.classes.get(a);o!==void 0&&(o.parent=t,i.classes.set(a,o))}for(let s of r){let a=this.notes.get(s);a!==void 0&&(a.parent=t,i.notes.set(s,a))}}}setCssStyle(t,n){let r=this.classes.get(t);if(!(!n||!r))for(let i of n)for(let s of i.split(","))r.styles.push(s)}};var yf=["$end","INVALID","CLASS_DIAGRAM","NEWLINE","EOF","SQS","STR","SQE","DOT","GENERICTYPE","LABEL","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","STRUCT_START","STRUCT_STOP","NAMESPACE","STYLE_SEPARATOR","ANNOTATION_START","ANNOTATION_END","CLASS","MEMBER","NOTE_FOR","NOTE","CLASSDEF","ALPHA","COMMA","direction_tb","direction_bt","direction_rl","direction_lr","AGGREGATION","EXTENSION","COMPOSITION","DEPENDENCY","LOLLIPOP","LINE","DOTTED_LINE","CALLBACK","LINK","LINK_TARGET","CLICK","CALLBACK_NAME","CALLBACK_ARGS","HREF","STYLE","CSSCLASS","COLON","BRKT","PCT","MINUS","UNICODE_TEXT","BQUOTE_STR","EDGE_STATE","EOF_IN_STRUCT","OPEN_IN_STRUCT","PLUS","EQUALS","PUNCTUATION"];var G2=[4,6,4,9,44,45,12,14,15,4,56,4,56],Y2=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],Ef=/[\n\r\u2028\u2029]/g;function Ub(e){let t=e.length,n=[],r=[],i=[],s=[],a=0,o=0,c=e.indexOf("direction"),l=-1,u=0,h=(O,v,G)=>(n.push(O),r.push(e.slice(v,G)),i.push(v),o=G,!0),d=O=>{s.push(a),a=O},m=()=>{s.length>0&&(a=s.pop())},p=O=>e.startsWith(O,o)&&!it(e.charCodeAt(o+O.length)),y=O=>{for(;O<t&&Xe(e.charCodeAt(O));)O++;return O},E=O=>{let v=e.indexOf(O,o);return v===-1?t:v},b=O=>{let v=o,G=-1;for(let K=e.charCodeAt(v);v<t&&Xe(K);K=e.charCodeAt(++v))K===10&&(G=v);if(G<0){o=v;return}O&&m(),h(3,o,G+1)},S=O=>{switch(O){case 99:if(p("cssClass"))return h(48,o,o+8);if(p("callback"))return h(40,o,o+8);if(p("click"))return h(43,o,o+5);break;case 108:if(p("link"))return h(41,o,o+4);break;case 110:if(p("note for"))return h(24,o,o+8);if(p("note"))return h(25,o,o+4);break;case 60:if(e.charCodeAt(o+1)===60)return h(20,o,o+2);break;case 62:if(e.charCodeAt(o+1)===62)return h(21,o,o+2);break;case 104:if(p("href"))return h(46,o,o+4);break}return!1},x=O=>{if(S(O))return!0;let v=e.charCodeAt(o+1);switch(O){case 34:return d(1),o++,!0;case 126:return d(3),o++,!0;case 96:return d(2),o++,!0;case 95:if(p("_self"))return h(42,o,o+5);if(p("_blank"))return h(42,o,o+6);if(p("_parent"))return h(42,o,o+7);if(p("_top"))return h(42,o,o+4);break;case 60:return v===124?h(34,o,o+2):h(36,o,o+1);case 124:return v===62&&h(34,o,o+2);case 62:return h(36,o,o+1);case 42:return h(35,o,o+1);case 111:if(!it(v))return h(33,o,o+1);break;case 40:return v===41&&h(37,o,o+2);case 45:return v===45?h(38,o,o+2):h(52,o,o+1);case 46:return v===46?h(39,o,o+2):h(8,o,o+1);case 58:{let G=o+1;for(;G<t;){let K=e.charCodeAt(G);if(K===58||K===10||K===59)break;G++}return G>o+1?h(10,o,G):v===58&&e.charCodeAt(o+2)===58&&h(19,o,o+3)}case 43:return h(58,o,o+1);case 37:return h(51,o,o+1);case 61:return h(59,o,o+1);case 91:return h(5,o,o+1);case 93:return h(7,o,o+1);case 33:case 35:case 36:case 38:case 39:case 44:case 63:case 92:case 47:return h(60,o,o+1)}if(it(O)){let G=o+1;for(;it(e.charCodeAt(G));)G++;return h(27,o,G)}return Li(O)&&h(53,o,o+1)},I=()=>{if(c===-1||o<u||(c<o&&(c=e.indexOf("direction",o)),c===-1)||(l<o&&(Ef.lastIndex=o,l=Ef.test(e)?Ef.lastIndex-1:t),c>=l))return!1;for(let O=0;O<4;O++){let v=Y2[O];if(v.lastIndex=o,v.test(e))return h(29+O,o,v.lastIndex)}return u=l,!1},L=O=>{if(I())return!0;if(Xe(O))return b(!1),!0;switch(O){case 37:if(e.charCodeAt(o+1)===37){let v=E(`
70
+ `);for(;v<t&&(e.charCodeAt(v)===10||e.charCodeAt(v)===13);)v++;return o=v,!0}break;case 97:{let v=e.startsWith("accTitle",o);if(!v&&!e.startsWith("accDescr",o))break;let G=y(o+8),K=e.charCodeAt(G);if(K===58)return h(v?11:13,o,y(G+1)),d(v?6:7),!0;if(K===123&&!v)return o=y(G+1),d(8),!0;break}case 99:if(p("classDiagram-v2"))return h(2,o,o+15);if(p("classDiagram"))return h(2,o,o+12);if(e.startsWith("call",o)&&Xe(e.charCodeAt(o+4)))return o=y(o+4),d(4),!0;if(p("classDef"))return h(26,o,o+8);if(p("class"))return d(9),h(22,o,o+5);break;case 91:if(e.startsWith("*]",o+1))return h(55,o,o+3);break;case 115:if(p("style"))return h(47,o,o+5);break;case 110:if(p("namespace"))return d(11),h(18,o,o+9);break;case 44:return h(28,o,o+1);case 35:return h(50,o,o+1)}return x(O)||O===58&&h(49,o,o+1)};for(;;){if(o>=t){n.push(G2[a]),r.push(""),i.push(t);break}let O=e.charCodeAt(o),v=!0;switch(a){case 0:v=L(O);break;case 9:Xe(O)?b(!0):O===125?(m(),m(),h(17,o,o+1)):O===123?(d(10),h(16,o,o+1)):v=x(O);break;case 10:if(O===34)d(1),o++;else if(O===125)m(),h(17,o,o+1);else if(O===91&&e.startsWith("*]",o+1))h(55,o,o+3);else if(O===123)h(57,o,o+1);else if(O===10)o++;else{let G=o+1;for(;G<t;){let K=e.charCodeAt(G);if(K===123||K===125||K===10)break;G++}h(23,o,G)}break;case 11:Xe(O)?b(!0):O===123?(d(12),h(16,o,o+1)):O===125?m():O===110&&p("namespace")?(d(11),h(18,o,o+9)):v=x(O);break;case 12:Xe(O)?b(!1):O===125?(m(),h(17,o,o+1)):O===110&&p("namespace")?(d(11),h(18,o,o+9)):O===91&&e.startsWith("*]",o+1)?h(55,o,o+3):O===99&&p("class")?(d(9),h(22,o,o+5)):v=x(O);break;case 1:O===34?(m(),o++):h(6,o,E('"'));break;case 3:if(O===34)d(1),o++;else{if(S(O))break;O===126?(m(),o++):h(9,o,E("~"))}break;case 2:if(O===34)d(1),o++;else{if(S(O))break;O===126?(d(3),o++):O===96?(m(),o++):h(54,o,E("`"))}break;case 4:if(O===40){let G=y(o+1);m(),e.charCodeAt(G)===41?o=G+1:(d(5),o++)}else h(44,o,E("("));break;case 5:O===41?(m(),o++):h(45,o,E(")"));break;case 6:case 7:h(a===6?12:14,o,E(`
71
+ `)),m();break;case 8:O===125?(m(),o++):h(15,o,E("}"));break}if(!v)return n.push(1),r.push(""),i.push(o),{types:n,texts:r,starts:i}}return n.push(0),r.push(""),i.push(t),{types:n,texts:r,starts:i}}var Af=61,Xc=new Uint8Array(Af);for(let e of[53,27,52])Xc[e]=1;var xf=new Uint8Array(Af);for(let e of[27,49,50,47,51,10])xf[e]=1;var ei=new Uint8Array(Af);ei[33]=1;ei[34]=2;ei[35]=3;ei[36]=4;ei[37]=5;var H2="'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS', 'BQUOTE_STR'";function Gb(e,t){let{types:n,texts:r,starts:i}=Ub(e),s=0,a=O=>{let v=n[s];throw v===1?ut("class",e,i[s],"",!0):ut("class",e,i[s],`Expecting ${O}, got '${yf[v]}'`)},o=O=>(n[s]!==O&&a(`'${yf[O]}'`),r[s++]),c=()=>(Xc[n[s]]===0&&a("'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS'"),r[s++]),l=O=>{let v="";for(;;){if(n[s]===54){v+=r[s++];break}Xc[n[s]]===0&&a(H2),v+=r[s++];let G=n[s];if(G===8)v+=".",s++;else if(Xc[G]===0&&G!==54)break}return O&&n[s]===9&&(v+="~"+r[s++]+"~"),v},u=()=>{s++;let O=o(6);return o(7),O},h=()=>{n[s]!==23&&a("'STRUCT_STOP', 'MEMBER'");let O=[];for(;n[s]===23;)O.push(r[s++]);return o(17),O.reverse()},d=()=>{s++;let O=l(!0);switch(t.addClass(O),n[s]===5&&t.setClassLabel(O,u()),n[s]){case 19:{s++;let v=c();t.setCssClass(O,v),n[s]===16&&(s++,t.addMembers(O,h()));break}case 16:s++,n[s]===17?s++:t.addMembers(O,h());break;case 20:{s++;let v=c();o(21),t.addAnnotation(O,v),n[s]===16&&(s++,n[s]===17?s++:t.addMembers(O,h()));break}}return O},m=()=>{if(n[s++]===25)return t.addNote(o(6));let O=l(!0);return t.addNote(o(6),O)},p=()=>{let O=[];for(;;){s++;let v=l(!1),G=n[s]===5?t.addNamespace(v,u()):t.addNamespace(v);o(16),n[s]===3&&s++,O.push({id:G,classes:[],notes:[]});let K=!0;for(;K;){let C=O[O.length-1],Z=n[s];if(Z===18)break;for(Z===22?C.classes.push(d()):Z===25||Z===24?C.notes.push(m()):a("'NAMESPACE', 'CLASS', 'NOTE_FOR', 'NOTE'");;){if(n[s]===3){let H=n[s+1];if(H===18||H===22||H===25||H===24){s++;break}s++}o(17);let oe=O.pop();if(t.addClassesToNamespace(oe.id,oe.classes,oe.notes),t.popNamespace(),O.length===0){K=!1;break}}}if(O.length===0)return}},y=()=>{let O=ei[n[s]];return O===0?"none":(s++,O-1)},E=()=>{let O=l(!0),v=n[s];if(v===10){t.addMember(O,t.cleanupLabel(r[s++]));return}let G="none";if(v===6)G=r[s++],v=n[s];else if(ei[v]===0&&v!==38&&v!==39)return;let K=y();v=n[s],v!==38&&v!==39&&a("'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE'"),s++;let C=y(),Z=n[s]===6?r[s++]:"none",oe=l(!0),H={id1:O,id2:oe,relation:{type1:K,type2:C,lineType:v===38?0:1},relationTitle1:G,relationTitle2:Z};n[s]===10&&(H.title=t.cleanupLabel(r[s++])),t.addRelation(H)},b=()=>{let O=[];for(;;){xf[n[s]]===0&&a("'ALPHA', 'NUM', 'COLON', 'UNIT', 'SPACE', 'BRKT', 'STYLE', 'PCT', 'LABEL'");let v=r[s++];for(;xf[n[s]]===1;)v+=r[s++];if(O.push(v),n[s]!==28)return O;s++}},S=O=>{n[s]===6&&t.setTooltip(O,r[s++])},x=O=>{let v=o(6),G=n[s]===6?r[s++]:void 0;n[s]===42?t.setLink(O,v,r[s++]):t.setLink(O,v),G!==void 0&&t.setTooltip(O,G)},I=()=>{let O=n[s];switch(O){case 53:case 27:case 52:case 54:E();return;case 18:p();return;case 22:d();return;case 23:s++;return;case 20:{s++;let v=c();o(21),t.addAnnotation(l(!0),v);return}case 40:{s++;let v=l(!0);t.setClickEvent(v,o(6)),S(v);return}case 41:s++,x(l(!0));return;case 43:{s++;let v=l(!0);if(n[s]===46){s++,x(v);return}let G=o(44);n[s]===45?t.setClickEvent(v,G,r[s++]):t.setClickEvent(v,G),S(v);return}case 47:{s++;let v=o(27);t.setCssStyle(v,b());return}case 48:{s++;let v=o(6);t.setCssClass(v,o(27));return}case 25:case 24:m();return;case 26:{s++;let v=[o(27)];for(;n[s]===28;)s++,v.push(o(27));t.defineClass(v,b());return}case 29:case 30:case 31:case 32:s++,t.setDirection(O===29?"TB":O===30?"BT":O===31?"RL":"LR");return;case 11:s++,t.setAccTitle(o(12).trim());return;case 13:s++,t.setAccDescription(o(14).trim());return;case 15:t.setAccDescription(r[s++].trim());return}a("'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'NAMESPACE', 'ANNOTATION_START', 'CLASS', 'MEMBER', 'NOTE_FOR', 'NOTE', 'CLASSDEF', 'direction_tb', 'CALLBACK', 'LINK', 'CLICK', 'STYLE', 'CSSCLASS', 'ALPHA', 'MINUS', 'BQUOTE_STR'")},L=n[s]===2;for(L&&(s++,o(3));I(),!(n[s]!==3||(s++,n[s]===4||n[s]===0)););L&&o(4),o(0)}function Yb(e,t,n,r){let i=Int32Array.from(e,(b,S)=>S),s=b=>{for(;i[b]!==b;)i[b]=i[i[b]],b=i[b];return b},a=(b,S)=>{i[s(b)]=s(S)};for(let b=0;b<e.length;b++)e[b].parent>=0&&a(b,e[b].parent);for(let b of t)a(b.src,b.dst);let o=new Map,c=(b,S,x,I=0,L=0)=>{b.left=Math.min(b.left,S-I/2),b.top=Math.min(b.top,x-L/2),b.right=Math.max(b.right,S+I/2),b.bottom=Math.max(b.bottom,x+L/2)};for(let b=0;b<e.length;b++){let S=s(b),x=o.get(S);x||(x={nodes:[],edges:[],left:1/0,top:1/0,right:-1/0,bottom:-1/0},o.set(S,x));let I=e[b];x.nodes.push(I),c(x,I.x,I.y,I.w,I.h)}if(o.size<2)return;for(let b of t){let S=o.get(s(b.src));S.edges.push(b);for(let x=0;x<b.route.length;x+=3)c(S,b.route[x],b.route[x+1]);b.labelW>0&&c(S,b.labelX,b.labelY,b.labelW,b.labelH)}let l=0,u=0,h=0,d=0,m=1/0,p=-1/0,y=[];for(let b of o.values()){let S=b.right-b.left,x=b.bottom-b.top;l>0&&l+S>n&&(u+=h+r,l=0,h=0),y.push(l-b.left,u-b.top),m=Math.min(m,b.left),p=Math.max(p,b.right),d=Math.max(d,l+S),h=Math.max(h,x),l+=S+r}if(d>=p-m)return;let E=0;for(let b of o.values())Rr(b.nodes,b.edges,y[E++],y[E++]);return{width:d,height:u+h}}var K2=["aggregation","extension","composition","dependency","lollipop"];function Hb(e){return typeof e=="number"&&K2[e]||"none"}function Kb(e,t=!0){let n=[],r=[],i=new Map,s=new Map,a=new Map,o=new Map,c=d=>{if(t||d===void 0)return d;let m=[],p=d,y;for(;p;){if(o.has(p)){y=o.get(p);break}let E=e.namespaces.get(p);if(E===void 0)break;if(E.explicit){y=p;break}m.push(p),p=E.parent}for(let E of m)o.set(E,y);return y},l=d=>d===void 0?-1:i.get(d)??-1;for(let d of e.namespaces.values())!t&&!d.explicit||(i.set(d.id,n.length),n.push({id:d.id,label:t?d.label:d.id,isGroup:!0,shape:"rect",parentId:t?d.parent:void 0,parent:-1}));for(let d of n)d.parent=l(d.parentId);let u=0;for(let d of e.classes.values()){let m=c(d.parent);s.set(d.id,n.length),n.push({id:d.id,label:d.label,isGroup:!1,shape:"classBox",parentId:m,parent:l(m),classNode:d,colorIndex:u++})}for(let d of e.notes.values()){let m=c(d.parent),p=d.class===void 0?void 0:s.get(d.class);p!==void 0&&r.push({id:`edgeNote${d.index}`,start:d.id,end:n[p].id,source:n.length,target:p,label:void 0,arrowTypeStart:"none",arrowTypeEnd:"none",startLabelRight:"",endLabelLeft:"",pattern:"dotted",classes:"relation"}),n.push({id:d.id,label:d.text,isGroup:!1,shape:"note",parentId:m,parent:l(m)})}for(let d of e.interfaces){let m=s.get(d.classId);a.set(d.id,n.length),n.push({id:d.id,label:d.label,isGroup:!1,shape:"interface",parentId:void 0,parent:m===void 0?-1:n[m].parent})}let h=0;for(let d of e.relations){h++;let{type1:m,type2:p}=d.relation,y=m===Xi.LOLLIPOP&&p==="none"?a:s,E=y===s&&p===Xi.LOLLIPOP&&m==="none"?a:s;r.push({id:`id_${d.id1}_${d.id2}_${h}`,start:d.id1,end:d.id2,source:y.get(d.id1)??-1,target:E.get(d.id2)??-1,label:d.title,arrowTypeStart:Hb(m),arrowTypeEnd:Hb(p),startLabelRight:d.relationTitle1==="none"?"":d.relationTitle1,endLabelLeft:d.relationTitle2==="none"?"":d.relationTitle2,pattern:d.relation.lineType===1?"dashed":"solid",classes:"relation"})}return{nodes:n,edges:r}}var Sf=12,ia=16,sa=6,qc=5;function wf(e){switch(e){case"extension":return Sf;case"composition":case"aggregation":return ia;case"lollipop":return 2*qc;case"dependency":return _t("arrow_point")}return 0}function _f(e,t,n,r,i,s){let a=-i,o=r;switch(e){case"extension":{let c=t-r*Sf,l=n-i*Sf;return`<path class="pele-marker" d="M${f(t)},${f(n)}L${f(c+a*sa)},${f(l+o*sa)}L${f(c-a*sa)},${f(l-o*sa)}Z" stroke-linejoin="round"/>`}case"composition":case"aggregation":{let c=t-r*ia/2,l=n-i*ia/2,u=sa-1;return`<path class="pele-marker" d="M${f(t)},${f(n)}L${f(c+a*u)},${f(l+o*u)}L${f(t-r*ia)},${f(n-i*ia)}L${f(c-a*u)},${f(l-o*u)}Z" stroke-linejoin="round"${e==="composition"?` fill="${s}"`:""}/>`}case"lollipop":return`<circle class="pele-marker" cx="${f(t-r*qc)}" cy="${f(n-i*qc)}" r="${qc}"/>`;case"dependency":return wt("arrow_point",t,n,r,i,s)}return""}var zb=40,z2=16,Vb=56,ti=20,Rf=26,Tf=12,Qc=8,jb=6,V2=10,j2=64,Zc=8,Mf="var(--_l)",X2=new Set(["_self","_blank","_parent","_top"]);function Cf(e,t,n){let r=e[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}var Jc=[],el=[];function Xb(e,t,n,r){let i=gt(e.getDisplayDetails().displayText).trim(),s=(e.classifier==="*"?2:0)|(r?4:0);return{text:i,width:t.width(i,n,s),classifier:e.classifier}}function qb(e,t,n){let r=i=>xn(n,s=>q2(e,t,n,i,s));return vn(e.direction)?vt(n,r):r(!1)}function q2(e,t,n,r,i){let s=t.class??{},a=Kb(e,s.hierarchicalNamespaces!==!1),o=s.hideEmptyMembersBox===!0,c=Array.isArray(n.monospace)&&n.monospace.includes("members"),l=ge=>c&&!/[";]font-family:/.test(ge.text),u=n.fontSize??16,h=Math.round(u*.875),d=Math.round(u*.8),m=Math.round(d*1.4),p=n.measurer??at(n.fontFamily,n.fontFamilyMono),y=n.padding??8,E=(ge,xe)=>{if(!ge.includes("$$"))return;let ie=Ue(ge,!1,p,xe,4e3);return ie.lines.some(Gi)?ie:void 0},b=ge=>ge?E(ge,d)?.width??p.width(gt(ge),d,0):0,S=r?"TB":cn(e.direction),x=new Map,I=new Map,L=new Map,O=ge=>{let xe=x.get(ge);if(xe===void 0){let ie=Mt([ge]);xe=ie.shape===""&&ie.text===""?"":ge.slice(0,ge.indexOf(":")).trim().toLowerCase(),x.set(ge,xe)}xe!==""&&L.set(xe,ge)},v=ge=>{L.clear();let xe=I.get(ge.cssClasses);if(xe===void 0){for(let ie of ge.cssClasses.split(" ")){let pe=e.styleClasses.get(ie);if(pe)for(let Re of pe.styles)for(let be of Re.split(","))O(be)}xe=[...L],I.set(ge.cssClasses,xe)}else for(let[ie,pe]of xe)L.set(ie,pe);for(let ie of ge.styles)O(ie);return Mt(L.size===0?el:[...L.values()])},G=new Int32Array(a.nodes.length);for(let ge of a.nodes)ge.parent>=0&&G[ge.parent]++;let K=new Uint8Array(a.nodes.length);for(let ge of a.edges){if(ge.source<0||ge.target<0)continue;let xe=a.nodes[ge.source].parent,ie=a.nodes[ge.target].parent;if(xe!==ie){for(let pe=xe;pe>=0&&K[pe]===0;pe=a.nodes[pe].parent)K[pe]=1;for(let pe=ie;pe>=0&&K[pe]===0;pe=a.nodes[pe].parent)K[pe]=1}}let C=[],Z=[];a.nodes.forEach((ge,xe)=>{let ie,pe;if(ge.isGroup){let Re=Ue(ge.label,!1,p,u,4e3);ie=oe(ge,Re,0,0,u),G[xe]>0?(pe=Ft(0,0),pe.isGroup=!0,pe.padX=ti,pe.padTop=Re.height>0?Re.height+16:ti,pe.padBottom=ti,pe.minW=Re.width+2*ti-12+(K[xe]===1&&!i?Math.min(Re.width+24,240):0)):(ie.w=Math.max(Re.width+2*ti,80),ie.h=Re.height+2*ti,pe=Ft(ie.w,ie.h))}else if(ge.classNode)ie=H(ge,ge.classNode),pe=Ft(ie.w,ie.h);else if(ge.shape==="note"){let Re=Ue(ge.label,!0,p,h,260);ie=oe(ge,Re,Math.max(Re.width+2*Tf,40),Re.height+2*Qc,h),pe=Ft(ie.w,ie.h)}else{let Re=Ue(ge.label,!1,p,h,200);ie=oe(ge,Re,Math.max(Re.width,12)+4,Math.max(Re.height,12),h),pe=Ft(ie.w,ie.h)}pe.parent=ge.parent,pe.seq=xe,C.push(ie),Z.push(pe)});function oe(ge,xe,ie,pe,Re){return{node:ge,style:Mt(el),label:xe,w:ie,h:pe,loops:0,annotations:el,attributes:Jc,methods:Jc,titleH:0,attributesH:0,fontSize:Re}}function H(ge,xe){let ie=v(xe),pe=ie.fontSize??u,Re=Math.round(pe*.875),be=Math.round(Re*1.5),Se=xe.type?"&lt;"+Es(xe.type).replace(/</g,"&lt;").replace(/>/g,"&gt;")+"&gt;":"",Ne=Ue(xe.label+Se,!1,p,pe,4e3,1|(ie.italic?2:0)),De=xe.annotations.length>0?xe.annotations.map(Le=>E(`«${Le.trim()}»`,d)??`«${gt(Le).trim()}»`):el,ve=xe.members.length>0?xe.members.map(Le=>Xb(Le,p,Re,l(ie))):Jc,fe=xe.methods.length>0?xe.methods.map(Le=>Xb(Le,p,Re,l(ie))):Jc,_e=Ne.width,Fe=0;for(let Le of De)_e=Math.max(_e,typeof Le=="string"?p.width(Le,d,0):Le.width),Fe+=typeof Le=="string"?m:Math.max(m,Le.height);for(let Le of ve)_e=Math.max(_e,Le.width);for(let Le of fe)_e=Math.max(_e,Le.width);let me=!(o&&ve.length===0&&fe.length===0),$e=Le=>me?Le>0?2*jb+Le*be:V2:0,Pe=2*Qc+Fe+Math.max(Ne.height,Math.round(pe*1.5)),ze=$e(ve.length);return{node:ge,style:ie,label:Ne,w:Math.max(_e+2*Tf,j2),h:Pe+ze+$e(fe.length),loops:0,annotations:De,attributes:ve,methods:fe,titleH:Pe,attributesH:ze,fontSize:pe}}let z=[],M=[],T=[],R=[],_=[],$=new Float64Array(C.length*4),g=(ge,xe,ie)=>{$[ge*4+xe]++,ie>$[ge*4+xe+1]&&($[ge*4+xe+1]=ie)};for(let ge of a.edges){if(ge.source<0||ge.target<0)continue;let xe=Ue(ge.label,!0,p,h,200),ie=b(ge.startLabelRight),pe=b(ge.endLabelLeft);ge.source===ge.target?(C[ge.source].loops++,Z[ge.source].w+=2*(Rf+(xe.width>0?xe.width+12:0))):(g(ge.source,0,ie),g(ge.target,2,pe)),R.push(ie),_.push(pe),M.push(ge),T.push(xe),z.push({src:ge.source,dst:ge.target,minlen:1,labelW:xe.width>0?xe.width+12:0,labelH:xe.height>0?xe.height+4:0,route:[],labelX:0,labelY:0})}if(S==="TB"||S==="BT")for(let ge=0;ge<C.length;ge++){if(!C[ge].node.classNode)continue;let xe=0;for(let ie=0;ie<4;ie+=2){let pe=$[ge*4+ie],Re=$[ge*4+ie+1];pe>1&&(xe=Math.max(xe,(pe-1)*(Re>0?Re+24:14)+24))}xe=Math.min(xe,480),xe>C[ge].w&&(Z[ge].w+=xe-C[ge].w,C[ge].w=xe)}let N=!1;for(let ge=0;ge<M.length&&!N;ge++)N=R[ge]>0||_[ge]>0;let w=0;if(S==="TB"||S==="BT"){let ge=xe=>xe?Math.max(m,E(xe,d)?.height??0):0;for(let xe of M)w=Math.max(w,ge(xe.startLabelRight)+ge(xe.endLabelLeft)-2*m)}let A=Ln(Z,z,S,{nodeSep:Cf(s,"nodeSpacing",zb),edgeSep:z2,rankSep:Cf(s,"rankSpacing",N?Vb+16:Vb)+w,portSep:20,apart:!0}),D=new Map,U=[],B=(ge,xe,ie,pe,Re)=>{let be=ge.route,Se=Z[ie],Ne=Zn(be,xe,Se);if(Ne<0)return;let De=(Se.w-C[ie].w)/2;Ne===1?be[xe]-=De:Ne===3&&(be[xe]+=De);let ve=Ne&1,fe=be[(xe===0?3:xe-3)+ve],_e=fe-be[xe+ve],Fe={route:be,at:xe,toward:fe,order:Re,room:pe,side:Ne,after:ve?_e>0:_e>=0},me=ie*4+Ne,$e=D.get(me);return $e?$e.push(Fe):D.set(me,[Fe]),Fe},F=[],W=[];for(let ge=0;ge<z.length;ge++){let xe=z[ge],ie=xe.src!==xe.dst&&xe.route.length>=6;F.push(ie?B(xe,0,xe.src,R[ge],ge):void 0),W.push(ie?B(xe,xe.route.length-3,xe.dst,_[ge],ge):void 0)}let j=(ge,xe,ie)=>{for(let pe=Z[ge].parent,Re=0;pe>=0&&Re<1e4;pe=Z[pe].parent,Re++){let be=Z[pe],Se=Math.abs(xe-be.x),Ne=Math.abs(ie-be.y);if(Math.abs(Ne-be.h/2)<.5&&Se<=be.w/2+.5||Math.abs(Se-be.w/2)<.5&&Ne<=be.h/2+.5)return!0}return!1},Q=[];for(let[ge,xe]of D){if(xe.length<2)continue;let ie=ge>>2,pe=ge&1,Re=pe?C[ie].h:C[ie].w;xe.sort((De,ve)=>De.toward-ve.toward||De.order-ve.order);let be=0;for(let De=0;De+1<xe.length;De++){let ve=xe[De],fe=xe[De+1],_e=pe?20:24;ve.room>0&&ve.after&&(_e+=pe?m+6:ve.room),fe.room>0&&!fe.after&&(_e+=pe?m+6:fe.room),Q[De]=_e,be+=_e}let Se=Math.min(1,(Re-24)/be);if(Se<=0)continue;let Ne=(pe?Z[ie].y:Z[ie].x)-be*Se/2;for(let De=0;De<xe.length;De++){let{route:ve,at:fe}=xe[De],_e=fe===0?3:-3,Fe=fe+_e,me=-1;for(let $e=Fe;$e>=0&&$e<ve.length&&Math.abs(ve[$e+pe]-ve[Fe+pe])<.5;$e+=_e)if(j(ie,ve[$e],ve[$e+1])){me=$e;break}if(me>=0&&Math.abs(ve[Fe+pe]-Ne)<=24)for(let $e=Fe;$e!==me+_e;$e+=_e)ve[$e+pe]=Ne;ve[fe+pe]=Ne,Ne+=Q[De]*Se}}let Y=(ge,xe,ie,pe)=>{if(xe===void 0||ie<=0)return;let Re=xe.side&1,be=pe?0:ge.length-3,Se=be+1-Re,Ne=Math.abs(ge[(pe?3:be-3)+1-Re]-ge[Se]),De=Math.min(Re?ie+10:m+6,Ne*.35);if(De<4)return;let ve=[ge[be],ge[be+1],ge[be+2]];ve[1-Re]+=(xe.side===0||xe.side===3?-1:1)*De,ge.splice(pe?3:be,0,ve[0],ve[1],ve[2])};for(let ge=0;ge<z.length;ge++)Y(z[ge].route,F[ge],R[ge],!0),Y(z[ge].route,W[ge],_[ge],!1);let ne=0,q=0,k=A.width,J=A.height,te=(ge,xe,ie,pe,Re,be,Se)=>{if(!xe)return;let Ne=E(xe,d),De=Ne?Math.max(m,Ne.height):m,ve=pe,fe=Re;be&1?(ve+=(be===3?-1:1)*(5+ie/2),fe+=(Se?1:-1)*(7+De/2)):(ve+=(Se?1:-1)*(9+ie/2),fe+=(be===0?-1:1)*(3+De/2)),U.push({text:gt(xe),math:Ne,x:ve,y:fe,w:ie,h:De,parent:ge}),ne=Math.min(ne,ve-ie/2),k=Math.max(k,ve+ie/2),q=Math.min(q,fe-De/2),J=Math.max(J,fe+De/2)},se=new Map,re=new Int32Array(z.length);for(let ge=0;ge<z.length;ge++){let xe=z[ge],ie=M[ge],pe=xe.route;if(xe.src===xe.dst){let Re=se.get(xe.src)??0;se.set(xe.src,Re+1),re[ge]=Re;let be=Z[xe.src],Se=C[xe.src],Ne=be.x+Se.w/2,De=Math.min(Se.h/2-4,8+Re*6);te(xe.src,ie.startLabelRight,R[ge],Ne,be.y-De,1,!1),te(xe.dst,ie.endLabelLeft,_[ge],Ne,be.y+De,1,!0),xe.labelX=be.x+Se.w/2+Rf+Re*8+4+xe.labelW/2,xe.labelY=be.y}else if(pe.length>=6){let Re=pe.length-3,be=F[ge],Se=W[ge];te(xe.src,ie.startLabelRight,R[ge],pe[0],pe[1],be?be.side:2,be?be.after:!0),te(xe.dst,ie.endLabelLeft,_[ge],pe[Re],pe[Re+1],Se?Se.side:0,Se?Se.after:!0)}}let P=n.maxWidth;if(P!==void 0&&P>0&&k-ne+2*y>P){let ge=U.map(ie=>({...Ft(ie.w,ie.h,ie.parent),x:ie.x,y:ie.y})),xe=Yb(Z.concat(ge),z,Math.max(1,P-2*y),Cf(s,"nodeSpacing",zb));xe&&(U.forEach((ie,pe)=>{ie.x=ge[pe].x,ie.y=ge[pe].y}),ne=q=0,k=xe.width,J=xe.height)}let ee=y-ne,ae=y-q,ue=Math.ceil(k-ne+2*y),ce=Math.ceil(J-q+2*y),he=[],V=new Map;if(a.nodes.length>0&&a.nodes[0].isGroup)for(let ge of z)dr(V,ge.route);let X="",le="",de="";for(let ge=0;ge<C.length;ge++){let xe=C[ge],ie=Z[ge],pe=xe.node,Re=ie.x+ee,be=ie.y+ae,Se=We(pe.id),Ne=ie.isGroup?ie.w:xe.w,De=ie.isGroup?ie.h:xe.h;if(pe.isGroup){let fe=ie.isGroup?fs(ie,xe.label.width,V,ti):ie.x,_e=be-De/2+8+xe.label.height/2,Fe=' class="pele-cluster-label" fill="var(--_m)"',me=ie.isGroup&&yc(ie,xe.label.width,fe,V);me&&(le+=Ec(xe.label,fe+ee,_e,Fe,Se,a.nodes,ge)),X+=`<g class="pele-cluster pele-namespace" data-id="${Se}"><rect x="${f(Re-Ne/2)}" y="${f(be-De/2)}" width="${f(Ne)}" height="${f(De)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ft}/>`+(me?"":Ce(xe.label,fe+ee,_e,Fe))+"</g>";continue}let ve=` transform="translate(${f(Re)},${f(be)})"`;if(pe.classNode)de+=Ae(xe,pe.classNode,Se,ve);else if(pe.shape==="note"){let fe=Ne/2,_e=-De/2;de+=`<g class="pele-node pele-note" data-id="${Se}"${ve}><path d="M${f(-fe)},${f(_e)}H${f(fe-Zc)}L${f(fe)},${f(_e+Zc)}V${f(-_e)}H${f(-fe)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"/><path d="M${f(fe-Zc)},${f(_e)}V${f(_e+Zc)}H${f(fe)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"/>`+Ce(xe.label,0,0,` class="pele-label" font-size="${h}"`,n.icons)+"</g>"}else de+=`<g class="pele-node pele-interface" data-id="${Se}"${ve}>`+Ce(xe.label,0,0,` class="pele-label" font-size="${h}"`,n.icons)+"</g>"}function Ae(ge,xe,ie,pe){let{w:Re,h:be,style:Se}=ge,Ne=-Re/2,De=-be/2,ve=Math.round(ge.fontSize*.875),fe=Math.round(ve*1.5),_e=`<rect x="${f(Ne)}" y="${f(De)}" width="${f(Re)}" height="${f(be)}" fill="var(--_s)" stroke="var(--_b)"${xt(Se.shape)}/>`,Fe=Dt(Se),me=De+ge.titleH,$e=me+ge.attributesH;if(be>ge.titleH){let Ve=Se.stroke?` style="stroke:${nt(Se.stroke)}"`:"";_e+=`<path class="pele-divider" d="M${f(Ne)},${f(me)}H${f(-Ne)}M${f(Ne)},${f($e)}H${f(-Ne)}" fill="none" stroke="var(--_b)"${Ve}/>`}let Pe=De+Qc;for(let Ve of ge.annotations)if(typeof Ve=="string")_e+=`<text class="pele-annotation" x="0" y="${f(Pe+m/2+d*.35)}" text-anchor="middle" font-size="${d}"${Fe||' fill="var(--_m)"'}>${nt(Ve)}</text>`,Pe+=m;else{let Ze=Math.max(m,Ve.height);_e+=Ce(Ve,0,Pe+Ze/2,` class="pele-annotation" font-size="${d}"${Fe||' fill="var(--_m)"'}`,n.icons),Pe+=Ze}let ze=ge.fontSize===u?"":` font-size="${f(ge.fontSize)}"`;_e+=Ce(ge.label,0,(Pe+me-Qc)/2,` class="pele-label"${ze} font-weight="var(--_hw)"${Fe}${Se.text}`,n.icons);let Le=(Ve,Ze,ke)=>{let Qe="",et=ke+jb+fe/2+ve*.35;for(let pt of Ve){let lt=pt.classifier==="$"?` pele-static"${Se.text?Se.text.slice(0,-1)+'text-decoration:underline"':' style="text-decoration:underline"'}`:pt.classifier==="*"?` pele-abstract" font-style="italic"${Se.text}`:`"${Se.text}`;Qe+=`<text class="pele-member pele-${Ze}${lt} x="${f(Ne+Tf)}" y="${f(et)}">${nt(pt.text)}</text>`,et+=fe}return Qe};return(ge.attributes.length>0||ge.methods.length>0)&&(_e+=`<g class="pele-members" font-size="${ve}"${Fe}${l(Se)?` font-family="${ur}"`:""}>${Le(ge.attributes,"attribute",me)}${Le(ge.methods,"method",$e)}</g>`),xe.tooltip&&(_e=`<title>${We(xe.tooltip)}</title>`+_e),xe.link&&(_e=Qn(_e,xe.link,xe.id,he,n,xe.linkTarget&&X2.has(xe.linkTarget)?` target="${xe.linkTarget}"`:"")),`<g class="pele-node pele-class${Nt(xe.cssClasses.replace(/^default\s?/,""))}" data-id="${ie}"${pe}>${_e}</g>`}let we="",Ee="";for(let ge=0;ge<z.length;ge++){let xe=z[ge],ie=M[ge],pe=T[ge],Re=ie.arrowTypeStart,be=ie.arrowTypeEnd,Se=wf(Re),Ne=wf(be),De;if(xe.src===xe.dst){let fe=Z[xe.src],_e=C[xe.src],Fe=re[ge],me=fe.x+ee+_e.w/2,$e=fe.y+ae,Pe=Math.min(_e.h/2-4,8+Fe*6),ze=Rf+Fe*8;De={d:`M${f(me+Se)},${f($e-Pe)}C${f(me+ze+Se)},${f($e-Pe)} ${f(me+ze+Ne)},${f($e+Pe)} ${f(me+Ne)},${f($e+Pe)}`,sx:me,sy:$e-Pe,sdx:-1,sdy:0,ex:me,ey:$e+Pe,edx:-1,edy:0}}else{let fe=xe.route;for(let _e=0;_e<fe.length;_e+=3)fe[_e]+=ee,fe[_e+1]+=ae;De=Mn(fe,void 0,Se,Ne)}let ve=ie.pattern==="dashed"?' stroke-dasharray="6 4"':ie.pattern==="dotted"?' stroke-dasharray="2 4"':"";if(we+=`<g class="pele-edge${ie.pattern==="dotted"?" pele-note-edge":" pele-relation"}" data-id="${We(ie.id)}"><path d="${De.d}"${ve}/>`+_f(Re,De.sx,De.sy,De.sdx,De.sdy,Mf)+_f(be,De.ex,De.ey,De.edx,De.edy,Mf)+"</g>",pe.width>0){let fe=xe.labelX+ee,_e=xe.labelY+ae;Ee+=ln(ie.id,pe,fe,_e,"",n.icons)}}let Te="";for(let ge of U)Te+=ge.math?Ce(ge.math,ge.x+ee,ge.y+ae,' class="pele-cardinality"',n.icons):`<text class="pele-cardinality" x="${f(ge.x+ee)}" y="${f(ge.y+ae+d*.35)}" text-anchor="middle">${nt(ge.text)}</text>`;let Me=Dc(e.title,p,u,y,ue,ce,(X?`<g class="pele-clusters">${X}</g>`:"")+(we?`<g class="pele-edges" fill="none" stroke="${Mf}" stroke-linecap="round">${we}</g>`:"")+(le?`<g class="pele-cluster-titles">${le}</g>`:"")+(Ee?`<g class="pele-edge-labels" font-size="${h}">${Ee}</g>`:"")+(Te?`<g class="pele-cardinalities" font-size="${d}" fill="var(--_m)">${Te}</g>`:"")+`<g class="pele-nodes">${de}</g>`);return{svg:ot("class",Me.width,Me.height,u,n,e,Me.content),width:Me.width,height:Me.height,links:he}}var Qb={type:"class",math:!0,parse(e,t,n){let r=new jc;return n&&(r.title=n),Gb(e,r),r},render:qb};var Nf=class{domains=new Map;transitions=[];setDomains(t){if(t)for(let n of t){let r=n.domain;this.domains.set(r,{name:r,items:(n.items??[]).map(i=>({label:i.label}))})}}setTransitions(t){t&&(this.transitions=t.filter(n=>n.from!==n.to).map(n=>({from:n.from,to:n.to,label:n.label||void 0})))}};function Zb(e,t){let n=new Nf;return n.setDomains(e.domains),n.setTransitions(e.transitions),{type:"cynefin",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
72
+ `):void 0,domains:n.domains,transitions:n.transitions}}var Jb=[{name:"cynefin-beta:",pattern:"cynefin-beta:"},Zt("cynefin-beta"),{name:"-->",pattern:"-->"},{name:":",pattern:":"},{name:"DOMAIN_NAME",pattern:/complex|complicated|clear|chaotic|confusion/y},rn,jt,hr,Pn,An,Sn,Yt,qt,Qt];function ey(e){let t=new Wt(Gt(e,Jb,"cynefin"),Jb,"cynefin"),n={$type:"Cynefin",domains:[],transitions:[]},r=()=>{for(;t.kinds[t.i]===9;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==9&&t.fail("a line break or the end of input"),r())};for(r(),t.kind!==1&&t.kind!==0&&t.fail("'cynefin-beta'"),t.i++;t.kind!==-1;)switch(t.kind){case 9:t.i++;break;case 5:n.accDescr=zt(t.take()),i();break;case 6:n.accTitle=Kt(t.take()),i();break;case 7:n.title=Ht(t.take()),i();break;case 4:{let s=t.take();if(t.accept(2)){let o={$type:"Transition",from:s,to:t.expect(4)};t.accept(3)&&(o.label=dn(t.expect(8))),i(),n.transitions.push(o);break}let a={$type:"DomainBlock",domain:s,items:[]};for(r();t.kinds[t.i]===8;)a.items.push({$type:"DomainItem",label:dn(t.take())}),r();n.domains.push(a);break}default:t.fail("a domain, a transition, a title, or a line break")}return n}function ty(e){let t=e+1831565813|0;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Q2(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}function ny(e,t){return typeof e=="number"&&Number.isFinite(e)&&e!==0?e:Q2(t)}var ry={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},If={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function tl(e,t,n,r,i,s){let a=(t-e)/s.segments,o=[],c=[];for(let u=0;u<=s.segments;u++){let h=u===0&&s.pinStart||u===s.segments&&s.pinEnd;o.push(e+u*a),c.push(h?n:n+ty(r+u*s.pointStep)*i*2-i)}let l=s.vertical?[c[0],o[0]]:[o[0],c[0]];for(let u=0;u<s.segments;u++){let h=(o[u]+o[u+1])/2,d=i*1.5*(u%2===0?1:-1)*ty(r+u*s.controlStep+s.controlShift);s.vertical?l.push(c[u]+d,h,c[u+1]-d,h,c[u+1],o[u+1]):l.push(h,c[u]+d,h,c[u+1]-d,o[u+1],c[u+1])}return l}function sy(e,t,n,r){let i=n-t;return[e,t,e+r,t+i*.2,e-r*1.5,t+i*.55,e+r*.5,t+i*.75,e-r,t+i*.85,e+r*.3,t+i*.95,e,n]}function qi(e){let t="";for(let n=2;n<e.length;n+=6)t+=`C${f(e[n])},${f(e[n+1])} ${f(e[n+2])},${f(e[n+3])} ${f(e[n+4])},${f(e[n+5])}`;return t}function oa(e){let t="";for(let n=e.length-6;n>=2;n-=6)t+=`C${f(e[n+2])},${f(e[n+3])} ${f(e[n])},${f(e[n+1])} ${f(e[n-2])},${f(e[n-1])}`;return t}function aa(e){return`M${f(e[0])},${f(e[1])}${qi(e)}`}function iy(e,t,n,r){let i=`${f(n)},${f(r)}`;return`M${f(e-n)},${f(t)}A${i} 0 1,1 ${f(e+n)},${f(t)}A${i} 0 1,1 ${f(e-n)},${f(t)}Z`}var kf=[["complex",0,0,0],["complicated",1,0,1],["chaotic",0,1,3],["clear",1,1,2]],Z2=4,J2=new Map([["complex",["Complex","Probe → Sense → Respond","Emergent Practices"]],["complicated",["Complicated","Sense → Analyse → Respond","Good Practices"]],["clear",["Clear","Sense → Categorise → Respond","Best Practices"]],["chaotic",["Chaotic","Act → Sense → Respond","Novel Practices"]],["confusion",["Confusion","","Disorder"]]]),oy=3,ay=200,eM=10,tM=4,nl=6,cy=10,ly=20,rl=10;function sl(e,t,n,r,i){let s=e.cynefin?.[t];return typeof s=="number"&&s>=r&&s<=i?s:n}function dy(e,t,n){let r=n.fontSize??16,i=Math.round(r*.8125),s=Math.round(r*.875),a=n.measurer??at(n.fontFamily,n.fontFamilyMono),o=n.padding??8,c=n.icons,l=t.cynefin?.showDomainDescriptions!==!1,u=sl(t,"boundaryAmplitude",8,0,50),h=ny(sl(t,"seed",0,-1e15,1e15),n.idPrefix??"pele"),d=Math.round(s*1.5),m=(k,J)=>{let te=Ue(k,!1,a,s,ay);return{text:k,label:te,w:te.width+2*eM,h:Math.max(te.height,d)+2*tM,overflow:J}},p=k=>{let J=J2.get(k),te=Ue(J[0],!1,a,r,4e3,1),se=[];if(l)for(let ce of[J[1],J[2]])ce&&se.push(Ue(ce,!1,a,i,4e3,2));let re=e.domains.get(k)?.items??[],P=k==="confusion"&&re.length>oy?oy:re.length,ee=[];for(let ce=0;ce<P;ce++)ee.push(m(re[ce].label,!1));P<re.length&&ee.push(m(`+${re.length-P} more`,!0));let ae=te.width,ue=te.height;for(let ce of se)ae=Math.max(ae,ce.width),ue+=ce.height;ee.length>0&&(ue+=cy-nl);for(let ce of ee)ae=Math.max(ae,ce.w),ue+=nl+ce.h;return{name:k,title:te,subtitles:se,badges:ee,w:ae,h:ue,cx:0,cy:0}},y=kf.map(([k])=>p(k)),E=p("confusion"),b=Math.max(88,E.w*.71+8),S=Math.max(64,E.h*.71+6),x=sl(t,"width",640,100,1e4)/2,I=sl(t,"height",440,100,1e4)/2;for(let k of y)x=Math.max(x,k.w+2*ly),I=Math.max(I,k.h+2*ly);for(let k of y){let J=(x-k.w)/2,te=(I-k.h)/2;if((J/(b+rl))**2+(te/(S+rl))**2>=1)continue;let se=k.w+2*(b+rl),re=k.h+2*(S+rl);se*I<=x*re?x=Math.max(x,se):I=Math.max(I,re)}let L=Ue(e.title,!1,a,r,4e3,1),O=L.height>0?L.height+12:0,v=2*x,G=2*I,K=o,C=o+O,Z=K+x,oe=C+I,H=K+v,z=C+G,M=tl(C,oe,Z,h,u,{...ry,segments:4,pinEnd:!0}),T=tl(K,Z,oe,h+100,u,{...If,segments:4,pinEnd:!0}),R=tl(Z,H,oe,h+200,u,{...If,segments:4,pinStart:!0}),_=sy(Z,oe,z,v*.03),$=(k,J)=>J?`${f(k[k.length-2])},${f(k[k.length-1])}`:`${f(k[0])},${f(k[1])}`,g=new Map([["complex",`M${f(K)},${f(C)}L${$(M,!1)}${qi(M)}${oa(T)}Z`],["complicated",`M${$(M,!1)}L${f(H)},${f(C)}L${$(R,!0)}${oa(R)}${oa(M)}Z`],["chaotic",`M${$(T,!1)}${qi(T)}${qi(_)}L${f(K)},${f(z)}Z`],["clear",`M${$(R,!1)}${qi(R)}L${f(H)},${f(z)}L${$(_,!0)}${oa(_)}Z`]]),N="";for(let[k,,,J]of kf)N+=`<path class="pele-cynefin-region" data-id="${k}" d="${g.get(k)}" fill="${yt(J)}" fill-opacity="0.14"/>`;let w=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${aa(M)}"/><path d="${aa(T)}"/><path d="${aa(R)}"/><path class="pele-cynefin-cliff" d="${aa(_)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,A=iy(Z,oe,b,S),D=`<path d="${A}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${A}" fill="${yt(Z2)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,U=k=>{let J=k.cy-k.h/2,te=Ce(k.title,k.cx,J+k.title.height/2,' class="pele-label" font-weight="var(--_hw)"');J+=k.title.height;for(let se of k.subtitles)te+=Ce(se,k.cx,J+se.height/2,` class="pele-cynefin-subtitle" font-size="${i}" font-style="italic" fill="var(--_m)"`),J+=se.height;J+=cy-nl;for(let se of k.badges)J+=nl,te+=`<g class="pele-node${se.overflow?" pele-cynefin-overflow":""}"${se.overflow?"":` data-id="${We(se.text)}"`}><rect x="${f(k.cx-se.w/2)}" y="${f(J)}" width="${f(se.w)}" height="${f(se.h)}" fill="var(--_bg)" stroke="var(--_b)"${se.overflow?' stroke-dasharray="3 2"':""}${ft}/>`+Ce(se.label,k.cx,J+se.h/2,` class="pele-label" font-size="${s}"${se.overflow?' fill="var(--_m)"':""}`,c)+"</g>",J+=se.h;return`<g class="pele-cynefin-domain" data-id="${k.name}">${te}</g>`},B=new Map,F="";kf.forEach(([k,J,te],se)=>{let re=y[se];re.cx=K+x*(J+.5),re.cy=C+I*(te+.5),B.set(k,re),F+=U(re)}),E.cx=Z,E.cy=oe,B.set("confusion",E),F+=U(E);let W=(k,J,te)=>k===E?((J-Z)/(b+4))**2+((te-oe)/(S+4))**2<=1:Math.abs(J-k.cx)<=k.w/2+8&&Math.abs(te-k.cy)<=k.h/2+8,j="",Q=new Map;for(let k of e.transitions){let J=B.get(k.from),te=B.get(k.to);if(!J||!te||J===te)continue;let se=k.from<k.to?`${k.from} ${k.to}`:`${k.to} ${k.from}`,re=Q.get(se)??0;Q.set(se,re+1);let P=te.cx-J.cx,ee=te.cy-J.cy,ae=Math.hypot(P,ee)||1,ue=(J.cx+te.cx)/2,ce=(J.cy+te.cy)/2,he=-ee*(ue-Z)+P*(ce-oe)>=0?1:-1,V=-ee/ae*he,X=P/ae*he,de=(J!==E&&te!==E&&Math.abs(P)>1&&Math.abs(ee)>1?2*(Math.hypot(b*V,S*X)+16):ae*.15)+re*56,Ae=ue+V*de,we=ce+X*de,Ee=$e=>{let Pe=1-$e;return[Pe*Pe*J.cx+2*Pe*$e*Ae+$e*$e*te.cx,Pe*Pe*J.cy+2*Pe*$e*we+$e*$e*te.cy]},Te=($e,Pe,ze,Le)=>{for(let Ve=0;Ve<16;Ve++){let Ze=(Pe+ze)/2;W($e,...Ee(Ze))===Le?Pe=Ze:ze=Ze}return(Pe+ze)/2},Me=48,Ie=1;for(;Ie<=Me&&W(J,...Ee(Ie/Me));)Ie++;if(Ie>Me)continue;let ge=Te(J,(Ie-1)/Me,Ie/Me,!0);for(;Ie<=Me&&!W(te,...Ee(Ie/Me));)Ie++;let xe=Ie>Me?1:Te(te,(Ie-1)/Me,Ie/Me,!1),[ie,pe]=Ee(ge),[Re,be]=Ee(xe),Se=($e,Pe,ze)=>(1-ge)*(1-xe)*$e+((1-ge)*xe+ge*(1-xe))*Pe+ge*xe*ze,Ne=Se(J.cx,Ae,te.cx),De=Se(J.cy,we,te.cy),ve=Math.hypot(Re-Ne,be-De)||1,fe=(Re-Ne)/ve,_e=(be-De)/ve,Fe=wt("arrow_point",Re,be,fe,_e,"var(--_l)");Re-=fe*_t("arrow_point"),be-=_e*_t("arrow_point");let me="";if(k.label){let $e=Ue(k.label,!1,a,i,ay),[Pe,ze]=Ee((ge+xe)/2),Le=Math.abs(V)*$e.width/2+Math.abs(X)*$e.height/2+6,Ve=$e.width/2+4,Ze=Math.min(Math.max(Pe+V*Le,K+Ve),Math.max(H-Ve,K+Ve));me=Ce($e,Ze,ze+X*Le,` class="pele-edge-label" font-size="${i}"`,c)}j+=`<g class="pele-edge" data-id="${k.from}-${k.to}"><path d="M${f(ie)},${f(pe)}Q${f(Ne)},${f(De)} ${f(Re)},${f(be)}" fill="none" stroke="var(--_l)"/>`+Fe+me+"</g>"}let Y=Math.ceil(Math.max(v,L.width)+2*o),ne=Math.ceil(G+O+2*o),q=Ce(L,K+v/2,o+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-cynefin-regions">${N}</g>`+w+D+F+(j?`<g class="pele-edges">${j}</g>`:"");return{svg:ot("cynefin",Y,ne,r,n,e,q),width:Y,height:ne,links:[]}}var uy={type:"cynefin",parse:(e,t,n)=>Zb(ey(e),n),render:dy};function nM(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}var il=class{type="er";direction="TB";entities=new Map;relationships=[];classes=new Map;subgraphs=[];title;accTitle;accDescr;subgraphLookup=new Map;claimed=new Set;addEntity(t,n=""){let r=this.entities.get(t);return r===void 0?(r={id:`entity-${t}-${this.entities.size}`,label:t,alias:n,attributes:[],cssClasses:"default",cssStyles:[]},this.entities.set(t,r)):!r.alias&&n&&(r.alias=n),r}addAttributes(t,n){let r=this.addEntity(t);for(let i=n.length-1;i>=0;i--){let s=n[i];s.keys??=[],s.comment??="",r.attributes.push(s)}}addRelationship(t,n,r,i){let s=this.subgraphLookup.has(t)?t:this.addEntity(t).id,a=this.subgraphLookup.has(r)?r:this.addEntity(r).id;this.relationships.push({entityA:s,roleA:n,entityB:a,relSpec:i})}setDirection(t){this.direction=t}addCssStyles(t,n){if(n)for(let r of t){let i=this.entities.get(r);if(i)for(let a of n)i.cssStyles.push(a);let s=this.subgraphLookup.get(r);if(s)for(let a of n)s.cssStyles.push(a)}}addClass(t,n){for(let r of t){let i=this.classes.get(r);if(i===void 0&&(i={id:r,styles:[],textStyles:[]},this.classes.set(r,i)),!!n)for(let s of n)s.includes("color")&&i.textStyles.push(s.replace("fill","bgFill")),i.styles.push(s)}}setClass(t,n){for(let r of t){let i=this.entities.get(r);if(i)for(let a of n)i.cssClasses+=" "+a;let s=this.subgraphLookup.get(r);if(s)for(let a of n)s.classes.push(a)}}addSubGraph(t,n,r){let i=t.text.trim(),s=new Set,a=[],o;for(let l of n.flat()){if(typeof l!="string"){l?.stmt==="dir"&&(o=l.value);continue}let u=l.trim();u===""||s.has(u)||(s.add(u),this.claimed.has(l)||a.push(l))}for(let l of a)this.claimed.add(l);let c={id:i,nodes:a,title:(r.text||"").trim(),classes:[],cssStyles:[],dir:o,labelType:nM(r.type)};return this.subgraphs.push(c),this.subgraphLookup.set(i,c),i}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
73
+ `)}};var $f=["$end","INVALID","ER_DIAGRAM","EOF","NEWLINE","COLON","STYLE_SEPARATOR","BLOCK_START","BLOCK_STOP","SQS","SQE","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","END","SUBGRAPH","direction_tb","direction_bt","direction_rl","direction_lr","CLASSDEF","UNICODE_TEXT","STYLE_TEXT","COMMA","CLASS","STYLE","SEMI","NUM","BRKT","ENTITY_NAME","DECIMAL_NUM","ENTITY_ONE","ATTRIBUTE_WORD","ATTRIBUTE_KEY","COMMENT","ZERO_OR_ONE","ZERO_OR_MORE","ONE_OR_MORE","ONLY_ONE","MD_PARENT","NON_IDENTIFYING","IDENTIFYING","WORD","CHAR"];var ca=1,ol=2,Df=4,la=8,pr=new Uint8Array(128);for(let e=0;e<128;e++){let t=e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95,n=t&&(e<48||e>57);t&&(pr[e]|=ca|ol|la),n&&(pr[e]|=Df)}for(let e of"-*")pr[e.charCodeAt(0)]|=ca|ol|la;pr[46]|=ca|la;pr[42]|=Df;for(let e of"[](),")pr[e.charCodeAt(0)]|=la;var rM=/accTitle\s*:\s*/iy,sM=/accDescr\s*:\s*/iy,iM=/accDescr\s*\{\s*/iy,oM=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],Lf=/direction/gi,Of=/[\n\r\u2028\u2029]/g;function fy(e,t){return e<128?(pr[e]&t)!==0:e>=192||e===181}function hy(e){let t=e.length,n=[],r=[],i=[],s=0,a=0,o=-2,c=0,l=-1,u=-2,h=-1,d=-1,m=-1,p=(H,z,M)=>{n.push(H),r.push(e.slice(z,M)),i.push(z),a=M},y=(H,z)=>(H.lastIndex=z,H.test(e)?H.lastIndex:-1),E=H=>{for(let z=0;z<H.length;z++){let M=H.charCodeAt(z),T=e.charCodeAt(a+z);if(T!==M&&(M<97||M>122||(T|32)!==M))return!1}return!0},b=H=>E(H)&&!it(e.charCodeAt(a+H.length)),S=H=>{let z=e.charCodeAt(H);return z>=65&&z<=90?z+32:z},x=H=>(Of.lastIndex=H,Of.test(e)?Of.lastIndex-1:t),I=H=>{for(;Et(e.charCodeAt(H));)H++;return H},L=()=>{if(o===-1||o<a&&(Lf.lastIndex=a,o=Lf.test(e)?Lf.lastIndex-9:-1,o===-1)||a<c||(l<a&&(l=x(a)),o>=l))return!1;for(let H=0;H<4;H++){let z=y(oM[H],a);if(z>=0)return p(18+H,a,z),!0}return c=l,!1},O=()=>{let H=e.indexOf('"',a+1);if(H===-1){p(45,a,a+1);return}let z=H>a+1;for(let M=a+1;z&&M<H;M++){let T=e.charCodeAt(M);(T===37||T===92||T===13||T===10||T===11||T===8)&&(z=!1)}p(z?31:44,a,H+1)},v=H=>{let z=e.charCodeAt(a+1);if(z===43&&(H===49||H===48)){p(H===49?39:38,a,a+2);return}let M=I(a+1);if(e.charCodeAt(M)===46&&Et(e.charCodeAt(M+1))){p(32,a,I(M+2));return}if(H===49){if(Xe(z)){let T=a+2;for(;Xe(e.charCodeAt(T));)T++;let R=e.charCodeAt(T);if(it(R)||R===34||R===39){p(40,a,a+1);return}}else if(z===45||z===46){let T=e.charCodeAt(a+2);if(T===45||T===46){p(40,a,a+1);return}}if(!it(z)){p(33,a,a+1);return}}p(29,a,M)},G=H=>{let z=e.charCodeAt(a+1);switch(H){case 101:if(b("erdiagram"))p(2,a,a+9);else if(b("end")){let M=a+3;for(;Xe(e.charCodeAt(M));)M++;p(16,a,M)}else return!1;return!0;case 115:if(b("style"))s=6,p(27,a,a+5);else if(b("subgraph"))p(17,a,a+8);else return!1;return!0;case 99:if(b("classdef"))s=6,p(22,a,a+8);else if(b("class"))p(26,a,a+5);else return!1;return!0;case 111:if(b("one or zero"))p(37,a,a+11);else if(b("one or more")||b("one or many"))p(39,a,a+11);else if(b("one"))p(40,a,a+3);else if(b("only one"))p(40,a,a+8);else if(z===124)p(37,a,a+2);else if(z===123)p(38,a,a+2);else if(b("optionally to"))p(42,a,a+13);else return!1;return!0;case 122:if(b("zero or one"))p(37,a,a+11);else if(b("zero or more")||b("zero or many"))p(38,a,a+12);else return!1;return!0;case 109:if(E("many(0)"))p(38,a,a+7);else if(E("many(1)"))p(39,a,a+7);else if(b("many"))p(38,a,a+4);else return!1;return!0;case 116:return b("to")?(p(43,a,a+2),!0):!1;case 117:return z!==46&&z!==45&&z!==124?!1:(p(41,a,a+1),!0);case 124:if(S(a+1)===111&&!it(e.charCodeAt(a+2)))p(37,a,a+2);else if(z===124)p(40,a,a+2);else if(z===123)p(39,a,a+2);else return!1;return!0;case 125:if(S(a+1)===111&&!it(e.charCodeAt(a+2)))p(38,a,a+2);else if(z===124)p(39,a,a+2);else return!1;return!0;case 46:return z!==46&&z!==45?!1:(p(42,a,a+2),!0);case 45:if(z===45)p(43,a,a+2);else if(z===46)p(42,a,a+2);else return!1;return!0}return!1},K=H=>{let z;if((H===97||H===65)&&E("acc")){if((z=y(rM,a))>=0){s=3,p(11,a,z);return}if((z=y(sM,a))>=0){s=4,p(13,a,z);return}if((z=y(iM,a))>=0){s=5,a=z;return}}if(!L()){switch(H){case 32:case 9:case 13:z=a+1;for(let M=e.charCodeAt(z);M===32||M===9||M===13;M=e.charCodeAt(z))z++;a=z;return;case 10:for(z=a+1;e.charCodeAt(z)===10;)z++;p(4,a,z);return;case 34:O();return;case 123:s=1,p(7,a,a+1);return;case 35:p(30,a,a+1);return;case 44:p(25,a,a+1);return;case 58:e.charCodeAt(a+1)===58&&e.charCodeAt(a+2)===58?p(6,a,a+3):p(5,a,a+1);return;case 91:p(9,a,a+1);return;case 93:p(10,a,a+1);return}if(Et(H)){v(H);return}if(!G(H>=65&&H<=90?H+32:H)){if(H>=128||(pr[H]&ca)!==0){z=a+1;for(let M=e.charCodeAt(z);M>=128||(pr[M]&ca)!==0;M=e.charCodeAt(z))z++;p(23,a,z);return}p(45,a,a+1)}}},C=()=>{if(u===-1||u<a&&(u=e.indexOf("~",a),u===-1))return!1;if(m<a){let z=a;for(;z<t&&!Xe(e.charCodeAt(z));)z++;m=z}if(u>=m||(h<a&&(h=x(a),d=e.lastIndexOf("~",h-1)),d<=u))return!1;let H=d+1;for(;H<t&&!Xe(e.charCodeAt(H));)H++;return p(34,a,H),!0},Z=H=>{if(Xe(H)){for(a++;Xe(e.charCodeAt(a));)a++;return}let z=H|32;if((z===112||z===102||z===117)&&(e.charCodeAt(a+1)|32)===107&&!it(e.charCodeAt(a+2))){p(35,a,a+2);return}if(!C()){if(fy(H,Df)){let M=a+1;for(;M<t&&fy(e.charCodeAt(M),la);)M++;p(34,a,M);return}if(H===96){s=2,a++;return}if(H===34){let M=e.indexOf('"',a+1);if(M!==-1){p(36,a,M+1);return}}else if(H===125){s=0,p(8,a,a+1);return}p(45,a,a+1)}};for(;a<t;){let H=e.charCodeAt(a),z;switch(s){case 0:K(H);break;case 1:Z(H);break;case 2:H===96?(s=1,a++):(z=e.indexOf("`",a),p(34,a,z===-1?t:z));break;case 3:case 4:z=e.indexOf(`
74
+ `,a),p(s===3?12:14,a,z===-1?t:z),s=0;break;case 5:H===125?(s=0,a++):(z=e.indexOf("}",a),p(15,a,z===-1?t:z));break;case 6:if(H===10){for(z=a+1;e.charCodeAt(z)===10;)z++;s=0,p(4,a,z)}else if(Xe(H))for(a++;Xe(e.charCodeAt(a));)a++;else if(H===58)p(5,a,a+1);else if(H===44)p(25,a,a+1);else if(H===35)p(30,a,a+1);else if(H===59)p(28,a,a+1);else if(H>=128||(pr[H]&ol)!==0){z=a+1;for(let M=e.charCodeAt(z);M>=128||(pr[M]&ol)!==0;M=e.charCodeAt(z))z++;p(24,a,z)}else return n.push(1),r.push(""),i.push(a),{types:n,texts:r,starts:i};break}}let oe=s===0?3:s===3?12:s===4?14:s===5?15:-1;return oe!==-1&&(n.push(oe),r.push(""),i.push(t)),n.push(0),r.push(""),i.push(t),{types:n,texts:r,starts:i}}var vf=new Map([[37,"ZERO_OR_ONE"],[38,"ZERO_OR_MORE"],[39,"ONE_OR_MORE"],[40,"ONLY_ONE"],[41,"MD_PARENT"]]),aM=["TB","BT","RL","LR"],py="'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'",cM="'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'",al="'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', "+py;function my(e,t){let{types:n,texts:r,starts:i}=hy(e),s=0,a=v=>{let G=n[s];throw G===1?ut("er",e,i[s],"",!0):ut("er",e,i[s],`Expecting ${v}, got '${G===45?r[s]:$f[G]}'`)},o=v=>(n[s]!==v&&a(`'${$f[v]}'`),r[s++]),c=()=>{let v=n[s];v!==4&&v!==28&&v!==3&&a("'EOF', 'NEWLINE', 'SEMI'"),s++},l=v=>v===23||v===31||v===29||v===32||v===33,u=()=>{let v=n[s];l(v)||a(py);let G=r[s++];return v===31?G.slice(1,-1):G},h=()=>{let v=[];for(;;){let G=n[s];if(G!==23&&G!==24&&a("'UNICODE_TEXT', 'STYLE_TEXT'"),v.push(r[s++]),n[s]!==25)return v;s++}},d=v=>v===24||v===29||v===5||v===30,m=()=>{let v=[];for(;;){d(n[s])||a("'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'");let G=r[s++];for(;d(n[s]);)G+=r[s++];if(v.push(G),n[s]!==25)return v;s++}},p=()=>{let v=vf.get(n[s++]),G=n[s];G!==43&&G!==42&&a("'NON_IDENTIFYING', 'IDENTIFYING'");let K=G===43?"IDENTIFYING":"NON_IDENTIFYING";s++;let C=vf.get(n[s]);return C===void 0?a(cM):(s++,{cardA:C,relType:K,cardB:v})},y=()=>{let v=n[s];v!==44&&v!==31&&v!==23&&a("'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'");let G=r[s++];return v===23?G:G.slice(1,-1)},E=v=>n[s]===45&&r[s]===v,b=()=>{let v=[];do{let G=o(34);E("?")&&(G+=r[s++]),n[s]!==34&&a(G.endsWith("?")?"'ATTRIBUTE_WORD'":"'ATTRIBUTE_WORD', '?'");let K={type:G,name:r[s++]};if(n[s]===35){let C=[r[s++]];for(;E(",");)s++,C.push(o(35));K.keys=C}n[s]===36&&(K.comment=r[s++].slice(1,-1)),v.push(K)}while(n[s]!==8);return v.reverse()},S=()=>{if(n[s]!==7)return;if(s++,n[s]===8){s++;return}let v=b();return s++,v},x=()=>{let v=u(),G=n[s];if(G===9){s++;let Z=u();o(10);let oe;n[s]===6&&(s++,oe=h());let H=S();return t.addEntity(v,Z),H&&t.addAttributes(v,H),oe&&t.setClass([v],oe),[v]}let K;if(G===6&&(s++,K=h(),G=n[s]),vf.has(G)){let Z=p(),oe=u(),H;n[s]===6&&(s++,H=h()),o(5);let z=y();return t.addEntity(v),t.addEntity(oe),t.addRelationship(v,z,oe,Z),K&&t.setClass([v],K),H&&t.setClass([oe],H),[v,oe]}let C=S();return t.addEntity(v),C&&t.addAttributes(v,C),K&&t.setClass([v],K),[v]};o(2);let I=[{id:"",title:"",list:[]}],L=I[0],O=!1;for(;;){let v=n[s];switch(v){case 4:s++;break;case 3:s++,O&&a(`'END', ${al}`);return;case 16:{O||a(al),s++;let G=t.addSubGraph({text:L.id},L.list,{text:L.title});I.pop(),L=I[I.length-1],O=I.length>1,O&&L.list.push(G);break}case 17:{s++;let G=u(),K=G;if(n[s]===9){for(s++,K=u();l(n[s]);)K+=" "+u();o(10)}c(),L={id:G,title:K,list:[]},I.push(L),O=!0;break}case 11:{s++;let G=o(12).trim();t.setAccTitle(G),O&&L.list.push(G);break}case 13:{s++;let G=o(14).trim();t.setAccDescription(G),O&&L.list.push(G);break}case 15:{let G=r[s++].trim();t.setAccDescription(G),O&&L.list.push(G);break}case 18:case 19:case 20:case 21:{s++;let G=aM[v-18];O?L.list.push({stmt:"dir",value:G}):t.setDirection(G);break}case 22:{let G=r[s++],K=h(),C=m();c(),t.addClass(K,C),O&&L.list.push(G);break}case 26:{let G=r[s++],K=h();t.setClass(K,h()),O&&L.list.push(G);break}case 27:{let G=r[s++],K=h(),C=m();c(),t.addCssStyles(K,C),O&&L.list.push(G);break}default:{l(v)||a(O?`'END', ${al}`:al);let G=x();if(O)for(let K of G)L.list.push(K)}}}}var lM=[];function gy(e){let t=[],n=[],r=e.subgraphs,i=c=>{let l=[];for(let u of c){let h=e.classes.get(u);if(h!==void 0){for(let d of h.styles)l.push(d.trim());for(let d of h.textStyles)l.push(d.trim())}}return l},s=new Map,a=new Set;for(let c=r.length-1;c>=0;c--){let l=r[c];a.add(l.id);for(let u of l.nodes)s.set(u,l.id)}for(let c=r.length-1;c>=0;c--){let l=r[c];t.push({id:l.id,label:l.title,alias:"",attributes:lM,isGroup:!0,parentId:s.get(l.id),cssStyles:l.cssStyles,cssCompiledStyles:i(l.classes),cssClasses:l.classes.join(" "),dir:l.dir,labelType:l.labelType})}let o=new Map;for(let[c,l]of e.entities){if(a.has(c)){o.set(l.id,c);continue}t.push({id:l.id,label:l.label,alias:l.alias,attributes:l.attributes,isGroup:!1,parentId:s.get(c),cssStyles:l.cssStyles,cssCompiledStyles:i(l.cssClasses.split(" ")),cssClasses:l.cssClasses,dir:void 0,labelType:"markdown"})}return e.relationships.forEach((c,l)=>{n.push({id:`id_${c.entityA}_${c.entityB}_${l}`,start:o.get(c.entityA)??c.entityA,end:o.get(c.entityB)??c.entityB,label:c.roleA,arrowTypeStart:c.relSpec.cardB.toLowerCase(),arrowTypeEnd:c.relSpec.cardA.toLowerCase(),pattern:c.relSpec.relType==="IDENTIFYING"?"solid":"dashed"})}),{nodes:t,edges:n}}var Dr=18,by=5,yy=6,Pf=10,Ey=3.5;function ni(e,t,n,r,i){let s=(u,h)=>f(t-r*u-i*h)+","+f(n-i*u+r*h),a=u=>`M${s(u,-by)}L${s(u,by)}`,o=`M${s(0,-yy)}L${s(Pf,0)}L${s(0,yy)}`,c=u=>`<circle class="pele-marker" cx="${f(t-r*u)}" cy="${f(n-i*u)}" r="${Ey}" fill="var(--_bg)"/>`,l=u=>`<path class="pele-marker" d="${u}"/>`;switch(e){case"only_one":return l(a(6)+a(10));case"zero_or_one":return l(a(6))+c(13.5);case"one_or_more":return l(o+a(Pf+3.5));case"zero_or_more":return l(o)+c(Pf+Ey+.5);case"md_parent":return`<path class="pele-marker" d="M${s(0,0)}L${s(6,4)}L${s(12,0)}L${s(6,-4)}Z" fill="var(--_bg)"/>`}return""}var dM=48,uM=20,fM=64,da=20,ua=28,hM=38,xy=96,Ay=18,pM=12,mM=9,Ff=12,Sy=16,Bf=9,gM=260,Wf=1e6,bM=[],yM=18,EM=14,wy=' fill="var(--_s)" stroke="var(--_b)"';function _y(e,t,n){let r=e.er?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function cl(e,t,n,r,i,s=0){let a=e.lines;if(a.length===0)return"";let o=a.length===1&&a[0].length===1?a[0][0]:void 0;if(o&&o.icon===void 0&&o.math===void 0&&o.style===s&&!(s&&o.text.includes(" ")))return`<text${Xn(r,s)} x="${f(t)}" y="${f(n)}">${nt(o.text)}</text>`;let c=jr(e),l=e.size*.35,u=n-l-e.lineHeight/2,h="",d="";for(let m=0;m<a.length;m++){let p=a[m],y=u+Cr(e,m);if(Gi(p)){d+=Ce(Nr(e,m),t+e.widths[m]/2,y,r,i);continue}n=y+l;let E=!1;for(let x of p)x.icon!==void 0&&(E=!0);let b=t,S=!1;for(let x of p){if(x.icon!==void 0){let I=e.size*1.1;d+=`<svg class="pele-icon" data-icon="${We(x.icon)}" x="${f(b)}" y="${f(n-e.size*.35-I/2)}" width="${f(I)}" height="${f(I)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(x.icon)??""}</svg>`}else if(x.text!==""){let I=E||!S?` x="${f(b)}" y="${f(n)}"`:"";h+=`<tspan${I}${wr(x.style&~c)}>${nt(x.text)}</tspan>`,S=!0}b+=x.width}}return`<text${Xn(r,c)} xml:space="preserve">${h}</text>${d}`}function Uf(e){let t=Es(e);return t===e?e:t.replace(/</g,"&lt;").replace(/>/g,"&gt;")}function My(e,t,n){return vn(e.direction)?vt(n,r=>Ry(e,t,n,r)):Ry(e,t,n,!1)}function Ry(e,t,n,r){let i=gy(e),s=Array.isArray(n.monospace)&&n.monospace.includes("attributes"),a=n.fontSize??16,o=Math.round(a*.875),c=n.measurer??at(n.fontFamily,n.fontFamilyMono),l=n.padding??8,u=n.icons,h=new Map,d=[],m=[];i.nodes.forEach((A,D)=>h.set(A.id,D));let p=[],y=[],E=[],b=new Map,S=[];for(let A of i.edges){let D=h.get(A.start),U=h.get(A.end);if(D===void 0||U===void 0)continue;let B=Ue(A.label,!0,c,o,200),F;if(D===U){F={label:B,band:0,at:0};let W=b.get(D);W?W.push(F):b.set(D,[F])}S.push(F),E.push(A),y.push(B),p.push({src:D,dst:U,minlen:1,labelW:B.width>0?B.width+12:0,labelH:B.height>0?B.height+4:0,route:[],labelX:0,labelY:0})}let x=A=>{let D=A;for(let U=0;U<i.nodes.length;U++){let B=i.nodes[D].parentId,F=B===void 0?void 0:h.get(B);if(F===void 0)break;let W=i.nodes[F].dir;if(W)return W==="LR"||W==="RL";D=F}return e.direction==="LR"||e.direction==="RL"};for(let A=0;A<i.nodes.length;A++){let D=i.nodes[A],U=Mt(D.cssStyles.length>0?D.cssCompiledStyles.concat(D.cssStyles):D.cssCompiledStyles),B=(U.bold?1:0)|(U.italic?2:0),F=s&&!/[";]font-family:/.test(U.text)?4:0,W=U.fontSize??a,j=U.fontSize??o,Q=U.fontSize??Math.round(a*.75),Y=D.isGroup?Ue(D.label,!0,c,W,4e3,B):Ue(D.alias||D.label,!0,c,W,240,B),ne=b.get(A)??bM,q=ne.length>0&&!D.isGroup&&x(A),k={node:D,style:U,label:Y,w:0,h:0,headH:0,rows:[],cols:[],rowSize:j,keySize:Q,mono:F,below:q},J=0,te=0;for(let P of ne)P.band=Math.max(hM,q?P.label.width+12:P.label.height+6),te+=P.band,J=Math.max(J,q?P.label.height:P.label.width);let se=Math.max(xy,q?te+8:0),re;if(D.isGroup)re=Ft(0,0),re.isGroup=!0,re.dir=D.dir?cn(D.dir):void 0,re.padX=da,re.padTop=k.label.height>0?k.label.height+16:da,re.padBottom=da,re.minW=Math.max(k.label.width+2*da-12,xy);else{let P=Math.max(Y.height,Math.round(W*1.5));if(D.attributes.length===0)k.w=Math.max(Y.width+2*Ay,se),k.h=Math.max(P+2*pM,q?0:te+8);else{let ae=Math.round(j*1.5),ue=[0,0,0,0];for(let le of D.attributes){let de=[Ue(Uf(le.type),!0,c,j,Wf,B|F),Ue(Uf(le.name),!0,c,j,Wf,B|F),Ue(le.keys.join(", "),!1,c,Q,Wf,B|F),Ue(Uf(le.comment),!0,c,j,gM,B)],Ae=ae;for(let we=0;we<4;we++)de[we].width>ue[we]&&(ue[we]=de[we].width),de[we].height>Ae&&(Ae=de[we].height);k.rows.push({cells:de,h:Ae+Bf}),k.h+=Ae+Bf}let ce=0,he=0;for(let le of ue)le!==0&&(he+=le+(ce>0?Sy:0),ce++);k.w=Math.max(he+2*Ff,Y.width+2*Ay,se);let V=ce>0?(k.w-he-2*Ff)/ce:0,X=Ff;for(let le of ue)k.cols.push(X),le>0&&(X+=le+V+Sy);k.headH=P+2*mM,k.h+=k.headH}let ee=ne.length>0?2*(Dr+ua*.75+10+J):0;re=q?Ft(k.w,k.h+ee):Ft(k.w+ee,k.h)}re.seq=d.length,d.push(k),m.push(re)}i.nodes.forEach((A,D)=>{m[D].parent=A.parentId!==void 0?h.get(A.parentId)??-1:-1});let I=Ln(m,p,r?"TB":cn(e.direction),{nodeSep:_y(t,"nodeSpacing",dM),edgeSep:uM,rankSep:_y(t,"rankSpacing",fM),portSep:24});AM(p,m,d);let L=I.width;for(let[A,D]of b){let U=m[A];if(!U.isGroup)continue;let B=0;for(let F of D)B=Math.max(B,F.label.width);L=Math.max(L,U.x+U.w/2+Dr+ua*.75+10+B)}let O=bn(e.title,c,a,4e3),v=O.height>0?O.height+12:0,G=Math.max(L,O.width),K=l+(G-L)/2,C=l+v;Rr(m,p,K,C);let Z=Math.ceil(G+2*l),oe=Math.ceil(I.height+v+2*l),H=[],z=new Map,M=!1;for(let A of m)A.isGroup&&(M=!0);if(M)for(let A of p)dr(z,A.route);let T="",R=[],_="";for(let A=0;A<d.length;A++){let D=d[A],U=m[A],B=D.node,F=Nt(B.cssClasses.replace(/^default\s?/,""));if(U.isGroup){D.w=U.w,D.h=U.h;let P=U.x-U.w/2,ee=U.y-U.h/2,ae=fs(U,D.label.width,z,da);Tn(D.style.shape)&&R.push({box:[P,ee,P+U.w,ee+U.h],shape:D.style.shape}),T+=`<g class="pele-cluster${F}" data-id="${We(B.id)}"><rect x="${f(P)}" y="${f(ee)}" width="${f(U.w)}" height="${f(U.h)}" fill="var(--_a)"${Dn(D.style.shape)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${xt(D.style.shape)}/>`+Ce(D.label,ae,ee+8+D.label.height/2,` class="pele-cluster-label"${Dt(D.style,"var(--_m)")}${D.style.text}`,u)+"</g>";continue}let W=D.w,j=D.h,Q=-W/2,Y=-j/2,ne=D.style.text,q=Dt(D.style),k=q||' fill="var(--_m)"',J=`x="${f(Q)}" y="${f(Y)}" width="${f(W)}" height="${f(j)}"`,te=Ce(D.label,0,D.rows.length>0?Y+D.headH/2:0,` class="pele-label"${q}${ne}`,u),se=gt(B.alias||B.label);if(/ internal-link(?: |$)/.test(F+" ")&&te!==""&&n.links!==!1){let P=ki(se,n),ee=nt(se);te=`<a class="internal-link"${P?` href="${ee}"${Xr(n)}`:""} data-href="${ee}">${te}</a>`,H.push({id:B.label,href:se,internal:!0})}let re;if(D.rows.length===0)re=`<rect ${J}${xt(wy+D.style.shape)}/>`+te;else{let P=Math.round(D.rowSize*1.5),ee=D.style.stroke?nt(D.style.stroke):"var(--_b)",ae="",ue="",ce=Y+D.headH;for(let le=0;le<D.rows.length;le++){let de=D.rows[le];if(le%2===0){let Ie=`x="${f(Q)}" width="${f(W)}"`;le===D.rows.length-1?ae+=`<rect ${Ie} y="${f(ce)}" height="${f(de.h)}"${ft}/><rect ${Ie} y="${f(ce)}" height="${f(de.h/2)}"/>`:ae+=`<rect ${Ie} y="${f(ce)}" height="${f(de.h)}"/>`}let Ae=ce+Bf/2+P/2+D.rowSize*.35,[we,Ee,Te,Me]=de.cells;ue+=cl(we,Q+D.cols[0],Ae,` class="pele-er-type"${k}${ne}`,u,D.mono)+cl(Ee,Q+D.cols[1],Ae,` class="pele-er-name"${q}${ne}`,u,D.mono)+cl(Te,Q+D.cols[2],Ae,` class="pele-er-keys" font-size="${D.keySize}"${k}${ne}`,u,D.mono)+cl(Me,Q+D.cols[3],Ae,` class="pele-er-comment"${k}${ne}`,u),ce+=de.h}let he=f(Y+D.headH),V=lr(D.style.shape),X=V===tc?nc:V===nc?tc:"var(--_bg)";re=`<rect ${J}${xt(wy+D.style.shape)}/><g class="pele-er-stripes" fill="${X}"${D.style.shape.includes("fill:")?' opacity="0.6"':""}>${ae}</g><path class="pele-er-divider" d="M${f(Q)},${he}H${f(Q+W)}" stroke="${ee}"/><rect ${J} fill="none" stroke="var(--_b)"${xt(D.style.line)}/>`+te+`<g class="pele-er-attributes" font-size="${D.rowSize}">${ue}</g>`}_+=`<g class="pele-node pele-entity${F}" data-id="${We(B.label)}" transform="translate(${f(U.x)},${f(U.y)})">${re}</g>`}for(let[A,D]of b){let U=d[A],B=0;for(let j of D)B+=j.band;let F=Math.min(1,Math.max((U.below?U.w:U.h)-8,0)/B),W=-B*F/2;for(let j of D)j.band*=F,j.at=W+j.band/2,W+=j.band}let $="",g="",N="";for(let A=0;A<p.length;A++){let D=p[A],U=E[A],B=y[A],F,W,j,Q=S[A];if(Q){let k=m[D.src],J=d[D.src],te=Math.max(Math.min(Q.band/2-6,13),1),se=Dr+ua*.75+6;if(J.below){let re=k.x+Q.at,P=k.y+J.h/2,ee=f(P+Dr),ae=f(P+Dr+ua);F=`M${f(re-te)},${f(P)}V${ee}C${f(re-te)},${ae} ${f(re+te)},${ae} ${f(re+te)},${ee}V${f(P)}`,W=ni(U.arrowTypeStart,re-te,P,0,-1),j=ni(U.arrowTypeEnd,re+te,P,0,-1),D.labelX=re,D.labelY=P+se+B.height/2}else{let re=k.x+J.w/2,P=k.y+Q.at,ee=f(re+Dr),ae=f(re+Dr+ua);F=`M${f(re)},${f(P-te)}H${ee}C${ae},${f(P-te)} ${ae},${f(P+te)} ${ee},${f(P+te)}H${f(re)}`,W=ni(U.arrowTypeStart,re,P-te,-1,0),j=ni(U.arrowTypeEnd,re,P+te,-1,0),D.labelX=re+se+B.width/2,D.labelY=P}}else{let k=xM(D.route);if(k.length<6)continue;Ty(k,0,d[D.src],m[D.src]),Ty(k,k.length-3,d[D.dst],m[D.dst]);let J=Math.abs(k[k.length-3]-k[0]),te=Math.abs(k[k.length-2]-k[1]),re=k.length===6&&(J<.01||te<.01||Math.hypot(J,te)<=3*Dr)?0:Dr,P=Mn(k,void 0,re,re);F=re>0?`M${f(P.sx)},${f(P.sy)}L${P.d.slice(1)}L${f(P.ex)},${f(P.ey)}`:P.d,W=ni(U.arrowTypeStart,P.sx,P.sy,P.sdx,P.sdy),j=ni(U.arrowTypeEnd,P.ex,P.ey,P.edx,P.edy)}let Y=Fo(F,[],R),ne=Y&&Bo(Y);ne===""&&(g+=Uo(F,W+j)),Y&&ne&&(W=Wo(W,Y),j=Wo(j,Y));let q=U.pattern==="dashed";if($+=`<g class="pele-edge pele-er-${q?"non-identifying":"identifying"}" data-id="${We(U.id)}"${ne?` stroke="${ne}"`:""}><path d="${F}"${q?' stroke-dasharray="4 3"':""}/>`+W+j+"</g>",B.width>0){let k=D.labelX,J=D.labelY;N+=ln(U.id,B,k,J,"",u)}}return{svg:ot("er",Z,oe,a,n,e,Ce(O,Z/2,l+O.height/2,' class="pele-title" font-weight="var(--_tw)"')+(T?`<g class="pele-clusters">${T}</g>`:"")+On(g)+($?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${$}</g>`:"")+(N?`<g class="pele-edge-labels" font-size="${o}">${N}</g>`:"")+`<g class="pele-nodes">${_}</g>`),width:Z,height:oe,links:H}}function xM(e){let t=e.slice(0,3);for(let n=3;n<e.length;n+=3){let r=t.length-3,i=s=>Math.abs(t[r+s]-e[n+s])<.01&&Math.abs(e[n+s]-e[n+3+s])<.01;n+3<e.length&&(i(0)||i(1))||t.push(e[n],e[n+1],e[n+2])}return t}function AM(e,t,n){let r=new Map,i=(s,a,o,c)=>{let l=t[s],u=a[o]-l.x,h=a[o+1]-l.y,d;if(Math.abs(Math.abs(h)-l.h/2)<.5)d=h<0?0:2;else if(Math.abs(Math.abs(u)-l.w/2)<.5)d=u<0?3:1;else return;let m=s*4+d,p={route:a,at:o,toward:a[c+(d&1?1:0)]},y=r.get(m);y?y.push(p):r.set(m,[p])};for(let s of e){let a=s.route.length-3;s.src===s.dst||a<3||(i(s.src,s.route,0,3),i(s.dst,s.route,a,a-3))}for(let[s,a]of r){if(a.length<2)continue;let o=s>>2,c=(s&1)===1,l=t[o].isGroup?t[o]:n[o],u=c?l.h:l.w,h=Math.max(Math.min(yM,(u-2*EM)/(a.length-1)),0),d=c?t[o].y:t[o].x;a.sort((m,p)=>m.toward-p.toward);for(let m=0;m<a.length;m++)a[m].route[a[m].at+(c?1:0)]=d+(m-(a.length-1)/2)*h}}function Ty(e,t,n,r){if(r.isGroup)return;let i=e[t]-r.x,s=e[t+1]-r.y;r.w!==n.w&&Math.abs(Math.abs(i)-r.w/2)<.5&&(e[t]-=Math.sign(i)*(r.w-n.w)/2),r.h!==n.h&&Math.abs(Math.abs(s)-r.h/2)<.5&&(e[t+1]-=Math.sign(s)*(r.h-n.h)/2)}var Cy={type:"er",math:!0,parse(e,t,n){let r=new il;return n&&(r.title=n),my(e,r),r},render:My};var SM=new Map([["ui","ui"],["pcr","processor"],["processor","processor"],["rmo","readmodel"],["readmodel","readmodel"],["cmd","command"],["command","command"],["evt","event"],["event","event"]]),wM=new Map([["trigger",[0,"UI/Automation","UI/A: "]],["state",[100,"Command/Read Model","C/RM: "]],["stream",[200,"Events","Stream: "]]]);function _M(e){return e==="ui"||e==="processor"?"trigger":e==="event"?"stream":"state"}function Gf(e){let t=e.indexOf("{"),n=e.lastIndexOf("}"),i=(t!==-1&&n>t?e.slice(t+1,n):t===-1&&e.length>=2?e.slice(1,-1):"").replace(/\r/g,"").split(`
75
+ `);for(;i.length>0&&i[0].trim()==="";)i.shift();for(;i.length>0&&i[i.length-1].trim()==="";)i.pop();let s=1/0;for(let a of i)a.trim()!==""&&(s=Math.min(s,a.length-a.trimStart().length));return i.map(a=>a.slice(Math.min(s,a.length)).trimEnd()).join(`
76
+ `)}function Ny(e,t){let n=new Set;for(let h of e.frames){if(n.has(h.name)){let d=ar(e.$source,h.$offset).line;throw new qe(`Duplicate event modeling frame ID "${h.name}" on line ${d}`,"semantic",{type:"eventmodeling",line:d})}n.add(h.name)}let r=new Map;for(let h of e.dataEntities)r.has(h.name)||r.set(h.name,h.dataBlockValue);let i=new Map,s=new Map,a=(h,d)=>{let m=_M(h),p=d===void 0?m:`${m} ${d}`,y=i.get(p);if(!y){let[E,b,S]=wM.get(m),x=E;d!==void 0&&(x=s.get(m)??E+1,s.set(m,x+1)),y={index:x,label:d===void 0?b:S+d,group:m,namespace:d},i.set(p,y)}return y},o=[],c=new Map,l=[];e.frames.forEach((h,d)=>{let m=h.entityIdentifier.split("."),p=m.length===2?m[0]:void 0,y=SM.get(h.modelEntityType)??"event",E=h.dataInlineValue===void 0?void 0:Gf(h.dataInlineValue);if(h.dataReference){let S=r.get(h.dataReference.$refText);S!==void 0&&(E=Gf(S))}let b={id:h.name,kind:y,entity:h.entityIdentifier,name:m.length===2?m[1]:h.entityIdentifier,namespace:p,reset:h.$type==="EmResetFrame",lane:a(y,p),data:E,dataType:h.dataType};if(o.push(b),c.set(b.id,b),h.sourceFrames.length>0){let S=new Set(h.sourceFrames.map(x=>x.$refText));for(let x of o)S.has(x.id)&&l.push({source:x,target:b})}else if(d>0&&!b.reset){for(let S=d-1;S>=0;S--)if(o[S].lane!==b.lane){l.push({source:o[S],target:b});break}}});let u=h=>h.map(d=>d.entityIdentifier.$refText);return{type:"eventmodeling",title:e.title&&Ht(e.title)||t,accTitle:e.accTitle?Kt(e.accTitle).replace(/^\s+/g,""):void 0,accDescr:e.accDescr?zt(e.accDescr).replace(/\n\s+/g,`
77
+ `):void 0,boxes:o,lanes:[...i.values()].sort((h,d)=>h.index-d.index),relations:l,notes:e.noteEntities.map(h=>({frame:h.sourceFrame.$refText,text:Gf(h.dataBlockValue),dataType:h.dataType})),specifications:e.gwtEntities.map(h=>({frame:h.sourceFrame.$refText,given:u(h.givenStatements),when:u(h.whenStatements),then:u(h.thenStatements)})),entities:e.modelEntities.map(h=>h.name)}}var Yf=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y;function RM(){let e=!1;return(t,n)=>{Yf.lastIndex=n;let r=Yf.exec(t);if(r===null)return-1;let i=Yf.lastIndex;if(r[1]===void 0)return i;if(e)return-1;let s=t.indexOf("}",i);return e=s===-1,s+1||-1}}function Qi(e="ACC_DESCR"){return{...rn,name:e,scanner:RM}}var Kf={name:"EM_ID",pattern:/[_a-zA-Z][\w_]*/y},Zi=e=>({name:e,pattern:e,longer:[Kf]}),fa=e=>({name:e,pattern:e}),TM=["resetframe","readmodel","processor","timeframe","command","entity","event","jsobj","figma","given","json","salt","html","text","data","note","when","then","rmo","cmd","evt","pcr","uri"],zf=[{...Zt("eventmodeling"),longer:[Kf]},...TM.map(Zi),fa("->>"),Zi("gwt"),Zi("ui"),Zi("md"),Zi("tf"),fa("[["),fa("]]"),Zi("rf"),fa("`"),fa("."),Kf,{name:"EM_FID",pattern:/\d{1,3}/y},{name:"EM_DATA_INLINE",pattern:/\{(.*)\}|"(.*)"|'(.*)'/y},{name:"EM_DATA_BLOCK",pattern:/\{[\t ]*\r?\n(?:[\S\s]*?\r?\n)?\}(?:\r?\n|(?!\S))/y},Qi("EM_ACC_DESCR"),{...jt,name:"EM_ACC_TITLE"},{...Jn(String.raw`\w`),name:"EM_TITLE"},{name:"EM_WS",pattern:/\s+/y,hidden:!0},{...Yt,name:"EM_YAML"},{...qt,name:"EM_DIRECTIVE"},{...Qt,name:"EM_SINGLE_LINE_COMMENT"},{name:"EM_ML_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0},{name:"EM_SL_COMMENT",pattern:/\/\/[^\n\r]*/y,hidden:!0}],Jt=e=>zf.findIndex(t=>t.name===e),ll=e=>new Set(e.map(Jt)),Lt={keyword:0,arrow:Jt("->>"),open:Jt("[["),close:Jt("]]"),tick:Jt("`"),dot:Jt("."),id:Jt("EM_ID"),frameId:Jt("EM_FID"),inline:Jt("EM_DATA_INLINE"),block:Jt("EM_DATA_BLOCK"),accDescr:Jt("EM_ACC_DESCR"),accTitle:Jt("EM_ACC_TITLE"),title:Jt("EM_TITLE"),entity:Jt("entity"),data:Jt("data"),note:Jt("note"),gwt:Jt("gwt"),given:Jt("given"),when:Jt("when"),then:Jt("then")},Iy=ll(["tf","timeframe"]),MM=ll(["rf","resetframe"]),Hf=ll(["rmo","readmodel","ui","cmd","command","evt","event","pcr","processor"]),CM=ll(["json","jsobj","figma","salt","uri","md","html","text"]);function ky(e){let t=new Wt(Gt(e,zf,"eventmodeling"),zf,"eventmodeling"),n={$type:"EventModel",modelEntities:[],frames:[],dataEntities:[],noteEntities:[],gwtEntities:[],$source:e},r=c=>t.kinds[t.i]===c,i=(c,l)=>c.has(t.kinds[t.i])?t.take():t.fail(l),s=()=>{let c=t.expect(Lt.id);for(;t.accept(Lt.dot);)c+="."+t.expect(Lt.id);return c},a=()=>{if(!t.accept(Lt.tick))return;let c=i(CM,"a data type");return t.expect(Lt.tick),c},o=()=>{let c=[];do i(Hf,"an entity type"),c.push({$type:"EmGwtStatement",entityIdentifier:{$refText:t.expect(Lt.id)}});while(Hf.has(t.kinds[t.i]));return c};for(t.expect(Lt.keyword);!r(-1);){let c=t.kinds[t.i];if(c===Lt.accDescr)n.accDescr=t.take();else if(c===Lt.accTitle)n.accTitle=t.take();else if(c===Lt.title)n.title=t.take();else if(c===Lt.entity)t.i++,n.modelEntities.push({$type:"EmModelEntity",name:s()});else if(Iy.has(c)||MM.has(c)){let l={$type:Iy.has(c)?"EmTimeFrame":"EmResetFrame",name:"",modelEntityType:"",entityIdentifier:"",sourceFrames:[],$offset:t.tokens.starts[t.i]};for(t.i++,l.name=t.expect(Lt.frameId),l.modelEntityType=i(Hf,"an entity type"),l.entityIdentifier=s();t.accept(Lt.arrow);)l.sourceFrames.push({$refText:t.expect(Lt.frameId)});if(t.accept(Lt.open)&&(l.dataReference={$refText:t.expect(Lt.id)},t.expect(Lt.close)),r(Lt.tick)||r(Lt.inline)){let u=a();u!==void 0&&(l.dataType=u),l.dataInlineValue=t.expect(Lt.inline)}n.frames.push(l)}else if(c===Lt.data){t.i++;let l={$type:"EmDataEntity",name:t.expect(Lt.id),dataBlockValue:""},u=a();u!==void 0&&(l.dataType=u),l.dataBlockValue=t.expect(Lt.block),n.dataEntities.push(l)}else if(c===Lt.note){t.i++;let l={$type:"EmNoteEntity",sourceFrame:{$refText:t.expect(Lt.frameId)},dataBlockValue:""},u=a();u!==void 0&&(l.dataType=u),l.dataBlockValue=t.expect(Lt.block),n.noteEntities.push(l)}else if(c===Lt.gwt){t.i++;let l={$type:"EmGwt",sourceFrame:{$refText:t.expect(Lt.frameId)},givenStatements:[],whenStatements:[],thenStatements:[]};t.expect(Lt.given),l.givenStatements=o(),t.accept(Lt.when)&&(l.whenStatements=o()),t.expect(Lt.then),l.thenStatements=o(),n.gwtEntities.push(l)}else t.fail("a frame, an entity, a data block, a note, or a specification")}return n}var vy=new Map([["command",0],["event",1],["readmodel",2],["processor",6]]),un=12,Yn=10,NM=96,$y=16,IM=80,dl=12,Ly=8,kM=48,Oy=80,Py=8;function Vf(e,t){let n=[];for(let r of gt(e).split(`
78
+ `)){let i=r.length<=t?void 0:Array.from(r);if(i===void 0||i.length<=t){n.push(r);continue}for(let s=0;s<i.length;s+=t)n.push(i.slice(s,s+t).join(""))}return n}function ul(e,t,n,r,i){let s="";for(let a=0;a<e.length;a++)e[a]!==""&&(s+=`<tspan x="${f(t)}" y="${f(n+a*r)}">${nt(e[a])}</tspan>`);return s===""?"":`<text${i} xml:space="preserve">${s}</text>`}function Fy(e,t,n){return vt(n,r=>$M(e,t,n,r))}function $M(e,t,n,r){if(r)return DM(e,n);let i=n.fontSize??16,s=Math.round(i*.875),a=Math.round(i*.8125),o=Math.round(i*.75),c=Math.round(o*1.4),l=Math.round(a*1.5),u=n.measurer??at(n.fontFamily,n.fontFamilyMono),h=n.padding??8,d=(w,A,D)=>{let U=0;for(let B of w)U=Math.max(U,u.width(B,A,D));return U},m=new Map,p=0;for(let w of e.lanes){let A=Ue(w.label,!1,u,a,4e3,1);p=Math.max(p,A.width),m.set(w,{lane:w,label:A,right:-1/0,y:0,h:0})}p+=2*dl;let y=[],E=new Map,b;for(let w of e.boxes){let A=m.get(w.lane),D=Ue(w.name,!1,u,s,4e3,1),U=w.data?Vf(w.data,kM):[],B=Math.max(NM,Math.max(D.width,d(U,o,4))+2*un),F=2*Yn+D.height+(U.length>0?6+U.length*c:0),W=0;if(b){let Q=b.x+Math.max(b.w/2,b.w-IM);W=b.box.lane===w.lane?A.right+$y:Math.max(Q,A.right+$y)}let j={box:w,name:D,data:U,x:W,y:0,w:B,h:F};A.right=W+B,A.h=Math.max(A.h,F),y.push(j),E.set(w,j),b=j}let S=0;for(let w of y)S=Math.max(S,w.x+w.w);let x=p+S+dl,I=Ue(e.title,!1,u,i,4e3,1),L=I.height>0?I.height+12:0,O=h,v=h+L,G=v,K="";for(let w of m.values())w.y=G,w.h+=2*dl,K+=`<g class="pele-cluster pele-em-lane" data-id="${We(w.lane.label)}"><rect x="${f(O)}" y="${f(G)}" width="${f(x)}" height="${f(w.h)}" fill="var(--_s)"${ft}/>`+Ce(w.label,O+dl+w.label.width/2,G+w.h/2,` class="pele-cluster-label" font-size="${a}" font-weight="var(--_hw)" fill="var(--_m)"`)+"</g>",G+=w.h+Ly;let C=m.size>0?G-Ly:v,Z="";for(let w of y){let A=m.get(w.box.lane);w.x+=O+p,w.y=A.y+(A.h-w.h)/2;let D=vy.get(w.box.kind),U=`x="${f(w.x)}" y="${f(w.y)}" width="${f(w.w)}" height="${f(w.h)}"`,B=D===void 0?`<rect ${U} fill="var(--_bg)" stroke="var(--_b)"${ft}/>`:`<rect ${U} fill="var(--_bg)"${ft}/><rect ${U} fill="${yt(D)}" fill-opacity="0.22" stroke="${yt(D)}"${ft}/>`,F=w.y+Yn+w.name.height/2,W=Ce(w.name,w.x+w.w/2,F,` class="pele-label" font-size="${s}" font-weight="var(--_hw)"`)+ul(w.data,w.x+un,w.y+Yn+w.name.height+6+c/2+o*.35,c,` class="pele-em-data" font-family="${ur}" font-size="${o}"`);Z+=`<g class="pele-node pele-em-${w.box.kind}${w.box.reset?" pele-em-reset":""}" data-id="${We(w.box.id)}">${B}${W}</g>`}let oe="",H=_t("arrow_point");for(let w of e.relations){let A=E.get(w.source),D=E.get(w.target);if(!A||!D||A===D)continue;let U,B;if(A.box.lane===D.box.lane){let F=D.x>=A.x,W=F?A.x+A.w:A.x,j=F?D.x:D.x+D.w,Q=A.y+A.h/2,Y=D.y+D.h/2,ne=j>=W?1:-1;U=`M${f(W)},${f(Q)}L${f(j-ne*H)},${f(Y)}`,B=wt("arrow_point",j,Y,ne,0,"var(--_l)")}else{let F=D.y>A.y,W=Math.max(A.x,D.x),j=Math.min(A.x+A.w,D.x+D.w),Q=re=>Math.min(24,re/4),Y=j-W>=16?(W+j)/2:D.x>A.x?A.x+A.w-Q(A.w):A.x+Q(A.w),ne=j-W>=16?Y:D.x>A.x?D.x+Q(D.w):D.x+D.w-Q(D.w),q=F?A.y+A.h:A.y,k=F?D.y:D.y+D.h,J=F?1:-1,te=k-J*H,se=(q+te)/2;U=Y===ne?`M${f(Y)},${f(q)}V${f(te)}`:`M${f(Y)},${f(q)}C${f(Y)},${f(se)} ${f(ne)},${f(se)} ${f(ne)},${f(te)}`,B=wt("arrow_point",ne,k,0,J,"var(--_l)")}oe+=`<g class="pele-edge" data-id="${We(w.source.id)}-${We(w.target.id)}"><path d="${U}" fill="none" stroke="var(--_l)"/>${B}</g>`}let z=new Map;for(let w of e.boxes)z.set(w.id,w.name);let M="",T=0,R=(w,A,D,U)=>{let B=Ue(`${A} · ${D}${z.has(D)?" "+z.get(D):""}`,!1,u,a,4e3,1),F=Math.max(B.width,d(U,a,0))+2*un,W=2*Yn+B.height+U.length*l,j=C+(M===""&&m.size===0?0:Py);M+=`<g class="pele-em-${w}" data-id="${We(D)}"><rect x="${f(O)}" y="${f(j)}" width="${f(F)}" height="${f(W)}" fill="var(--_bg)" stroke="var(--_b)"${ft}/>`+Ce(B,O+un+B.width/2,j+Yn+B.height/2,` font-size="${a}" font-weight="var(--_hw)"`)+ul(U,O+un,j+Yn+B.height+l/2+a*.35,l,` font-size="${a}"`)+"</g>",C=j+W,T=Math.max(T,F)};for(let w of e.notes)R("note","Note",w.frame,Vf(w.text,Oy));for(let w of e.specifications){let A=[`Given ${w.given.join(", ")}`];w.when.length>0&&A.push(`When ${w.when.join(", ")}`),A.push(`Then ${w.then.join(", ")}`),R("specification","Given / When / Then",w.frame,A.flatMap(D=>Vf(D,Oy)))}let _=Math.max(m.size>0?x:0,T,I.width),$=Math.ceil(_+2*h),g=Math.ceil(C+h),N=Ce(I,$/2,h+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+K+oe+Z+M;return{svg:ot("eventmodeling",$,g,i,n,e,N),width:$,height:g,links:[]}}var Dy=8,LM=120,OM=20;function DM(e,t){let n=t.fontSize??16,r=Math.round(n*.875),i=Math.round(n*.75),s=t.padding??8,a=t.measurer??at(t.fontFamily,t.fontFamilyMono),o=Math.max(160,(t.maxWidth??320)-2*s),c=new Map(e.boxes.map((z,M)=>[z,M])),l=new Map,u=new Set;for(let z of e.relations){let M=c.get(z.source),T=c.get(z.target);if(M===void 0||T===void 0||M===T)continue;if(Math.abs(M-T)<2){u.add(e.boxes[Math.max(M,T)]);continue}let R=l.get(z.target);R?(R[0]=Math.min(R[0],M),R[1]=Math.max(R[1],M)):l.set(z.target,[Math.min(M,T),Math.max(M,T)])}let h=new Map,d=[];for(let[z,[M,T]]of[...l].sort((R,_)=>R[1][0]-_[1][0])){let R=d.findIndex(_=>_<M);R<0&&(R=d.length),d[R]=T,h.set(z,R)}let m=24+Dy*Math.max(0,d.length-1),p=Math.max(LM,o-m),y=p-2*un,E=Ue(e.title,!1,a,n,o,1),b=s+(E.height?E.height+12:0),S=s+E.height,x=Math.max(E.width,p+m),I="",L="",O="",v=new Map,G=(z,M,T=0)=>qs(gt(z),a,M,y,T);e.boxes.forEach((z,M)=>{let T=u.has(z)?y-OM:y,R=Qs(Ue(z.lane.label,!1,a,r,T,1),a,T),_=Ue(z.name,!1,a,r,y-36,1),$=z.data?G(z.data,i,4):void 0,g=Math.max(p,R.width+2*un,_.width+2*un+36,($?.width??0)+2*un),N=R.height+12,w=2*Yn+_.height+($?$.height+6:0),A=vy.get(z.kind),D=b+N,U=`x="${f(s)}" y="${f(D)}" width="${f(g)}" height="${f(w)}"`;I+=`<g class="pele-cluster pele-em-lane" data-id="${We(z.lane.label)}">`+Qr(R,s+un,b,` class="pele-cluster-label" font-size="${r}" font-weight="var(--_hw)" fill="var(--_m)"`)+`<g class="pele-node pele-em-${z.kind}${z.reset?" pele-em-reset":""}" data-id="${We(z.id)}"><rect ${U} fill="var(--_bg)" stroke="var(--_b)"${ft}/>`+(A===void 0?"":`<rect ${U} fill="${yt(A)}" fill-opacity="0.22" stroke="${yt(A)}"${ft}/>`)+Ce(_,s+un+_.width/2,D+Yn+_.height/2,` class="pele-label" font-size="${r}" font-weight="var(--_hw)"`)+`<text class="pele-em-frame" x="${f(s+g-un)}" y="${f(D+Yn+r)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${nt(z.id)}</text>`+($?ul($.lines.map(B=>B.map(F=>F.text).join("")),s+un,D+Yn+_.height+6+$.lineHeight/2+i*.35,$.lineHeight,` class="pele-em-data" font-family="${ur}" font-size="${i}"`):"")+"</g></g>",v.set(z,{y:D,h:w,w:g,index:M,lane:R.width}),x=Math.max(x,g+m),S=D+w,b=S+28});for(let z of e.relations){let M=v.get(z.source),T=v.get(z.target);if(!M||!T||M===T)continue;let R=T.y>M.y,_=R?1:-1,$=R?M.y+M.h:M.y,g=R?T.y:T.y+T.h,N,w;if(Math.abs(M.index-T.index)===1){let A=s+Math.max(Math.min(M.w,T.w)/2,un+(R?T:M).lane+16);N=`M${f(A)},${f($)}V${f(g-_*_t("arrow_point"))}`,w=wt("arrow_point",A,g,0,_,"var(--_l)")}else{let A=s+x-m+12+Dy*(h.get(z.target)??0),D=M.y+M.h/2-5,U=T.y+T.h/2+5;N=`M${f(s+M.w)},${f(D)}H${f(A)}V${f(U)}H${f(s+T.w+_t("arrow_point"))}`,w=wt("arrow_point",s+T.w,U,-1,0,"var(--_l)")}L+=`<g class="pele-edge" data-id="${We(z.source.id)}-${We(z.target.id)}"><path d="${N}" fill="none" stroke="var(--_l)"/>${w}</g>`}let K=new Map(e.boxes.map(z=>[z.id,z.name])),C=(z,M,T,R)=>{let _=Ue(`${M} · ${T}${K.has(T)?" "+K.get(T):""}`,!1,a,r,y,1),$=G(R,r),g=Math.max(p,_.width+2*un,$.width+2*un),N=2*Yn+_.height+$.height;O+=`<g class="pele-em-${z}" data-id="${We(T)}"><rect x="${f(s)}" y="${f(b)}" width="${f(g)}" height="${f(N)}" fill="var(--_bg)" stroke="var(--_b)"${ft}/>`+Ce(_,s+un+_.width/2,b+Yn+_.height/2,` font-size="${r}" font-weight="var(--_hw)"`)+ul($.lines.map(w=>w.map(A=>A.text).join("")),s+un,b+Yn+_.height+$.lineHeight/2+r*.35,$.lineHeight,` font-size="${r}"`)+"</g>",S=b+N,b=S+Py,x=Math.max(x,g)};for(let z of e.notes)C("note","Note",z.frame,z.text);for(let z of e.specifications){let M=[`Given ${z.given.join(", ")}`];z.when.length&&M.push(`When ${z.when.join(", ")}`),M.push(`Then ${z.then.join(", ")}`),C("specification","Given / When / Then",z.frame,M.join(`
79
+ `))}let Z=Math.ceil(x+2*s),oe=Math.ceil(S+s),H=Ce(E,Z/2,s+E.height/2,' class="pele-title" font-weight="var(--_tw)"')+L+I+O;return{svg:ot("eventmodeling",Z,oe,n,t,e,H),width:Z,height:oe,links:[]}}var By={type:"eventmodeling",keepComments:!0,parse:(e,t,n)=>Ny(ky(e),n),render:Fy};function jf(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function Wy(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function vM(e,t){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}function PM(e){let t=e.trim(),n="arrow_open";switch(t[0]){case"<":n="arrow_point",t=t.slice(1);break;case"x":n="arrow_cross",t=t.slice(1);break;case"o":n="arrow_circle",t=t.slice(1);break}let r="normal";return t.includes("=")&&(r="thick"),t.includes(".")&&(r="dotted"),{type:n,stroke:r}}function FM(e){let t=e.trim(),n=t.slice(0,-1),r="arrow_open";switch(t.slice(-1)){case"x":r="arrow_cross",t.startsWith("x")&&(r="double_"+r,n=n.slice(1));break;case">":r="arrow_point",t.startsWith("<")&&(r="double_"+r,n=n.slice(1));break;case"o":r="arrow_circle",t.startsWith("o")&&(r="double_"+r,n=n.slice(1));break}let i="normal",s=n.length-1;n.startsWith("=")&&(i="thick"),n.startsWith("~")&&(i="invisible");let a=vM(".",n);return a&&(i="dotted",s=a),{type:r,stroke:i,length:s}}var fl=class{type="flowchart";direction;nodes=new Map;edges=[];subgraphs=[];classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;title;accTitle;accDescr;subgraphLookup=new Map;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;options;constructor(t={}){this.options=t}addVertex(t,n,r,i,s,a,o,c){if(!t||t.trim().length===0)return;let l;if(c!==void 0){let p=c.includes(`
80
+ `)?c+`
81
+ `:`{
82
+ `+c+`
83
+ }`,y;try{y=cr(p)}catch(E){throw new qe(`Metadata of "${t}" is not valid YAML. ${E.message}`,"syntax",{type:"flowchart"})}l=y!==null&&typeof y=="object"&&!Array.isArray(y)?y:void 0}let u=this.subgraphLookup.get(t);if(u&&l){u.metadata={...u.metadata,...l};return}let h=this.edgeById.get(t);if(h){l?.animate!==void 0&&(h.animate=l.animate),l?.animation!==void 0&&(h.animation=l.animation),l?.curve!==void 0&&(h.interpolate=l.curve);return}let d=this.nodes.get(t);if(d===void 0&&(n===void 0&&r===void 0&&i!==void 0&&i!==null&&this.options.warn?.(`Style applied to unknown node "${t}". This may indicate a typo. The node will be created automatically.`),d={id:t,labelType:"text",styles:[],classes:[]},this.nodes.set(t,d)),n!==void 0?(d.labelType=n.type,d.text=Wy(n.text.trim())):d.text===void 0&&(d.text=t),r!==void 0&&(d.type=r),i!=null)for(let p of i)d.styles.push(p);if(s!=null)for(let p of s)d.classes.push(p);if(a!==void 0&&(d.dir=a),d.props===void 0?d.props=o??{}:o!==void 0&&Object.assign(d.props,o),l===void 0)return;if(l.shape){let p=String(l.shape);if(p!==p.toLowerCase()||p.includes("_"))throw new qe(`No such shape: ${p}. Shape names should be lowercase.`,"semantic",{type:"flowchart"});if(!ac(p))throw new qe(`No such shape: ${p}.`,"semantic",{type:"flowchart"});d.type=p}let m=typeof l.label=="string"?l.label:void 0;l.label&&(d.text=String(l.label),d.labelType=jf(l.labelType)),l.icon&&(d.icon=String(l.icon),!m?.trim()&&d.text===t&&(d.text="")),l.form&&(d.form=String(l.form)),l.pos&&(d.pos=String(l.pos)),l.img&&(d.img=String(l.img),!m?.trim()&&d.text===t&&(d.text="")),l.constraint&&(d.constraint=String(l.constraint)),l.w&&(d.assetWidth=Number(l.w)),l.h&&(d.assetHeight=Number(l.h))}addSingleLink(t,n,r,i){let s={start:t,end:n,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},a=r?.text;a!==void 0&&(s.text=Wy(a.text.trim()),s.labelType=jf(a.type)),r!==void 0&&(s.type=r.type,s.stroke=r.stroke,s.length=r.length>10?10:r.length);let o=t+"\0"+n,c=this.pairCount.get(o)??0;i&&!this.edgeById.has(i)?(s.id=i,s.isUserDefinedId=!0):s.id=`L_${t}_${n}_${c===0?0:c+1}`;let l=this.options.maxEdges;if(l!==void 0&&this.edges.length>=l)throw new qe(`Edge limit exceeded. The limit is ${l}.`,"limit",{type:"flowchart"});this.edges.push(s),this.pairCount.set(o,c+1),this.edgeById.has(s.id)||this.edgeById.set(s.id,s)}addLink(t,n,r){let i=typeof r?.id=="string"?r.id.replace("@",""):void 0,s=t[t.length-1],a=n[0];for(let o of t)for(let c of n)this.addSingleLink(o,c,r,o===s&&c===a?i:void 0)}updateLinkInterpolate(t,n){for(let r of t)r==="default"?this.defaultInterpolate=n:this.edgeAt(r).interpolate=n}updateLink(t,n){for(let r of t){if(r==="default"){this.defaultEdgeStyle=n;continue}let i=this.edgeAt(r);i.style=n,n.length>0&&!n.some(s=>s?.startsWith("fill"))&&n.push("fill:none")}}edgeAt(t){let n=this.edges[Number(t)];if(n===void 0)throw new qe(`The index ${t} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length-1}. (Help: Ensure that the index is within the range of existing edges.)`,"semantic",{type:"flowchart"});return n}addClass(t,n){let r=n.join().replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let i of t.split(",")){let s=this.classes.get(i);s===void 0&&(s={id:i,styles:[],textStyles:[]},this.classes.set(i,s));for(let a of r)a.includes("color")&&s.textStyles.push(a.replace("fill","bgFill")),s.styles.push(a)}}setDirection(t){let n=t.trim();n.includes("<")&&(n="RL"),n.includes("^")&&(n="BT"),n.includes(">")&&(n="LR"),n.includes("v")&&(n="TB"),n==="TD"&&(n="TB"),this.direction=n}setClass(t,n){for(let r of t.split(","))this.nodes.get(r)?.classes.push(n),this.edgeById.get(r)?.classes.push(n),this.subgraphLookup.get(r)?.classes.push(n)}setTooltip(t,n){if(n!==void 0)for(let r of t.split(","))this.tooltips.set(r,n)}setLink(t,n,r){let i=n.trim();for(let s of t.split(",")){let a=this.nodes.get(s);a!==void 0&&(a.link=i?qn(i):void 0,a.linkTarget=r)}this.setClass(t,"clickable")}setClickEvent(t,n,r){this.setClass(t,"clickable")}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
84
+ `)}addSubGraph(t,n,r){let i=t?.text.trim(),s=r?.text??"";t!==void 0&&t===r&&/\s/.test(s)&&(i=void 0);let a=new Set,o=[],c;for(let d of n)if(typeof d=="string")d.trim()!==""&&!a.has(d)&&(a.add(d),o.push(d));else if(Array.isArray(d))for(let m of d)m.trim()!==""&&!a.has(m)&&(a.add(m),o.push(m));else c=d.value;c??=this.options.inheritDir?this.direction??this.options.direction:void 0,i??="subGraph"+this.subCount,s=s||"",this.subCount++;let l={id:i,nodes:o,title:s.trim(),classes:[],dir:c,labelType:jf(r?.type)},u=this.members;l.nodes=o.filter(d=>!u.has(d)&&d!==i);for(let d of l.nodes)u.add(d);let h=this.subgraphLookup.get(i);if(h)for(let d of l.nodes)h.nodes.push(d);else this.subgraphs.push(l);return this.subgraphLookup.set(i,h??l),i}exists(t,n){for(let r of t)if(r.nodes.includes(n))return!0;return!1}makeUniq(t,n){let r=new Set;for(let i of n)for(let s of i.nodes)r.add(s);return{nodes:t.nodes.filter(i=>!r.has(i))}}destructLink(t,n){let r=FM(t);if(!n)return r;let i=PM(n);if(i.stroke!==r.stroke)return{type:"INVALID",stroke:"INVALID"};if(i.type==="arrow_open")i.type=r.type;else{if(i.type!==r.type)return{type:"INVALID",stroke:"INVALID"};i.type="double_"+i.type}return i.type==="double_arrow"&&(i.type="double_arrow_point"),i.length=r.length,i}subgraph(t){return this.subgraphLookup.get(t)}};var Xf=["$end","INVALID","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","SHAPE_DATA","CALLBACKNAME","CALLBACKARGS","MD_STR","STR","STYLE","DEFAULT","LINKSTYLE","INTERPOLATE","CLASSDEF","CLASS","HREF","CLICK","GRAPH","subgraph","end","LINK_TARGET","NODIR","DIR","direction_tb","direction_bt","direction_rl","direction_lr","direction_td","LINK_ID","NUM","BRKT","STYLE_SEPARATOR","COLON","AMP","SEMI","COMMA","MULT","LINK","START_LINK","EDGE_TEXT","-)","TEXT","(-","STADIUMEND","STADIUMSTART","SUBROUTINEEND","SUBROUTINESTART","VERTEX_WITH_PROPS_START","TAGEND","CYLINDEREND","CYLINDERSTART","DOUBLECIRCLEEND","DOUBLECIRCLESTART","TRAPEND","INVTRAPEND","TRAPSTART","INVTRAPSTART","TAGSTART","UP","SEP","DOWN","NODE_STRING","MINUS","UNICODE_TEXT","PIPE","PE","PS","SQE","SQS","DIAMOND_STOP","DIAMOND_START","NEWLINE","SPACE","EOF"];var Hy=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")Hy[e.charCodeAt(0)]=1;var BM=/accTitle\s*:\s*/y,WM=/accDescr\s*:\s*/y,UM=/accDescr\s*\{\s*/y,GM=/call\s+/y,YM=/click\s+/y,HM=/(?:\r?\n)*\s*\n/y,KM=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,zM=/\s*[<>^]/y,VM=/\s*v\b/y,jM=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y,/.*direction\s+TD[^\n]*/y],qf=/[\n\r\u2028\u2029]/g,Uy=/\s*[xo<]?--+[-xo>]\s*/y,XM=/\s*[xo<]?--\s*/y,Gy=/\s*[xo<]?==+[=xo>]\s*/y,qM=/\s*[xo<]?==\s*/y,Qf=/\s*[xo<]?-?\.+-[xo>]?\s*/y,QM=/\s*[xo<]?-\.\s*/y,Yy=/\s*~~~+\s*/y,ZM=/(?:\r?\n)+/y,JM=/[^\S\n\r]+/y,eC=/\(\s*\)/y,tC=/\n\s*/g;function Ky(e){let t=e.length,n=[],r=[],i=[],s=[],a=0,o=0,c=!0,l=e.indexOf("direction"),u=e.indexOf("@"),h=-1,d=0,m=0,p=-1,y=-1,E=-1,b=(T,R,_)=>{n.push(T),r.push(e.slice(R,_)),i.push(R),o=_},S=T=>{s.push(a),a=T},x=()=>{s.length>0&&(a=s.pop())},I=(T,R)=>(T.lastIndex=R,T.test(e)?T.lastIndex:-1),L=T=>e.startsWith(T,o)&&!it(e.charCodeAt(o+T.length)),O=T=>{let R=T;if(T>=y&&T<=E)R=E;else if(Xe(e.charCodeAt(T))){for(;R<t&&Xe(e.charCodeAt(R));)R++;y=T,E=R}let _=e.charCodeAt(R);return _===120||_===111||_===60?e.charCodeAt(R+1):_},v=T=>{let R=T;if(T>=y&&T<=E)R=E;else if(Xe(e.charCodeAt(T))){for(;R<t&&Xe(e.charCodeAt(R));)R++;y=T,E=R}return e.charCodeAt(R)===126},G=()=>{e.charCodeAt(o+1)===96?(S(2),o+=2):(S(1),o++)},K=()=>{if(!v(o))return!1;let T=I(Yy,o);return T<0?!1:(b(40,o,T),!0)},C=T=>{let R=e.charCodeAt(o+1);return T===40?(R===45?(S(8),b(45,o,o+2)):R===91?(S(7),b(47,o,o+2)):R===40&&e.charCodeAt(o+2)===40?(S(7),b(55,o,o+3)):(S(7),b(69,o,o+1)),!0):T===91?(R===91?(S(7),b(49,o,o+2)):R===40?(S(7),b(53,o,o+2)):R===47?(S(9),b(58,o,o+2)):R===92?(S(9),b(59,o,o+2)):(S(7),b(71,o,o+1)),!0):T===124?(S(7),b(67,o,o+1),!0):T===123?(S(7),b(73,o,o+1),!0):!1},Z=T=>{c&&(c=!1,S(6)),b(20,o,o+T)},oe=()=>{let T=o;for(;T<t;){let R=e.charCodeAt(T);if(R<128&&Hy[R]===1)T++;else if(R===45&&T+1<t){let _=e.charCodeAt(T+1);if(_===62||_===45||_===46)break;T++}else break}return T===o?!1:(b(64,o,T),!0)},H=T=>{let R=O(o),_;if(R===45){if((_=I(Uy,o))>=0)return b(40,o,_),!0;if((_=I(XM,o))>=0)return S(10),b(41,o,_),!0;if((_=I(Qf,o))>=0)return b(40,o,_),!0;if((_=I(QM,o))>=0)return S(12),b(41,o,_),!0}else if(R===61){if((_=I(Gy,o))>=0)return b(40,o,_),!0;if((_=I(qM,o))>=0)return S(11),b(41,o,_),!0}else if(R===46&&(_=I(Qf,o))>=0)return b(40,o,_),!0;return T!==45&&T!==61&&T!==46&&K()},z=T=>{let R;switch(T){case 97:if(e.startsWith("acc",o)){if((R=I(BM,o))>=0)return S(3),b(2,o,R),!0;if((R=I(WM,o))>=0)return S(4),b(4,o,R),!0;if((R=I(UM,o))>=0)return S(5),o=R,!0}break;case 64:if(e.charCodeAt(o+1)===123)return S(16),n.push(7),r.push(""),i.push(o),o+=2,!0;break;case 99:if((R=I(GM,o))>=0)return S(14),o=R,!0;if(L("classDef"))return b(16,o,o+8),!0;if(L("class"))return b(17,o,o+5),!0;if((R=I(YM,o))>=0)return S(13),o=R,!0;break;case 34:return G(),!0;case 115:if(L("style"))return b(12,o,o+5),!0;if(L("swimlane-beta"))return Z(13),!0;if(L("subgraph"))return b(21,o,o+8),!0;break;case 100:if(L("default"))return b(13,o,o+7),!0;break;case 108:if(L("linkStyle"))return b(14,o,o+9),!0;break;case 105:if(L("interpolate"))return b(15,o,o+11),!0;break;case 104:if(e.startsWith("href",o)&&Xe(e.charCodeAt(o+4)))return b(18,o,o+5),!0;break;case 102:if(L("flowchart-elk"))return Z(13),!0;if(L("flowchart"))return Z(9),!0;break;case 103:if(L("graph"))return Z(5),!0;break;case 101:if(L("end")){for(R=o+3;R<t&&Xe(e.charCodeAt(R));)R++;return b(22,o,R),!0}break;case 95:if(L("_self"))return b(23,o,o+5),!0;if(L("_blank"))return b(23,o,o+6),!0;if(L("_parent"))return b(23,o,o+7),!0;if(L("_top"))return b(23,o,o+4),!0;break}if(l!==-1&&o>=d&&(l<o&&(l=e.indexOf("direction",o)),l!==-1&&(h<o&&(qf.lastIndex=o,h=qf.test(e)?qf.lastIndex-1:t),l<h))){for(let _=0;_<5;_++)if((R=I(jM[_],o))>=0)return b(26+_,o,R),!0;d=h}if(u!==-1&&T!==34&&!Xe(T)){if(o>=m){u<o&&(u=e.indexOf("@",o));let _=o;for(;_<t;){let $=e.charCodeAt(_);if($===34||Xe($))break;_++}if(m=_,p=-1,u!==-1&&u<_)for(let $=Math.min(_,t-1)-1;$>=u;$--){if(e.charCodeAt($)!==64)continue;let g=e.charCodeAt($+1);if(g!==123&&g!==34){p=$;break}}}if(p>o)return b(31,o,p+1),!0}if(T>=48&&T<=57){let _=o+1;for(;_<t;){let $=e.charCodeAt(_);if($<48||$>57)break;_++}return b(32,o,_),!0}switch(T){case 35:return b(33,o,o+1),!0;case 58:return e.charCodeAt(o+1)===58&&e.charCodeAt(o+2)===58?b(34,o,o+3):b(35,o,o+1),!0;case 38:return b(36,o,o+1),!0;case 59:return b(37,o,o+1),!0;case 44:return b(38,o,o+1),!0;case 42:return b(39,o,o+1),!0;case 120:case 111:return H(T)||oe();case 60:return H(T)||b(60,o,o+1),!0;case 45:return H(T)||oe()||b(65,o,o+1),!0;case 61:return H(T);case 46:return H(T)||oe();case 126:return K();case 40:return C(T);case 91:return e.charCodeAt(o+1)===124?(b(50,o,o+2),!0):C(T);case 124:case 123:return C(T);case 62:return S(7),b(51,o,o+1),!0;case 94:return b(61,o,o+1),!0;case 92:return e.charCodeAt(o+1)===124?(b(62,o,o+2),!0):oe();case 118:return it(e.charCodeAt(o+1))?oe():(b(63,o,o+1),!0)}return Xe(T)?H(T)?!0:(R=I(ZM,o))>=0?(b(74,o,R),!0):(R=I(JM,o))>=0?(b(75,o,R),!0):!1:T<128?oe():Li(T)?(b(66,o,o+1),!0):!1},M=(T,R,_,$)=>{if(T===34)return G(),!0;let g=O(o);if(g===_||g===$){let w=I(R,o);if(w>=0)return x(),b(40,o,w),!0}if(T===_&&(_!==45||e.charCodeAt(o+1)===45))return!1;let N=o+1;for(;N<t;){let w=e.charCodeAt(N);if(w===34)break;if(w===_){if(_!==45||e.charCodeAt(N+1)===45)break}else if(w===120||w===111||w===60||w===$||Xe(w)){let A=O(N);if((A===_||A===$)&&I(R,N)>=0)break}N++}return b(42,o,N),!0};e:for(;;){if(o>=t){let _=-1;switch(a){case 0:_=76;break;case 3:_=3;break;case 4:_=5;break;case 5:_=6;break;case 13:_=19;break;case 14:_=8;break;case 15:_=9;break}_!==-1&&b(_,t,t);break}let T=e.charCodeAt(o),R=!0;switch(a){case 0:R=z(T);break;case 1:if(T===34)e.charCodeAt(o+1)===96?(S(2),o+=2):(x(),o++);else{let _=e.indexOf('"',o);b(11,o,_===-1?t:_)}break;case 2:if(T===96)e.charCodeAt(o+1)===34?(x(),o+=2):R=!1;else if(T===34)G();else{let _=o+1;for(;_<t;){let $=e.charCodeAt(_);if($===96||$===34)break;_++}b(10,o,_)}break;case 3:case 4:{let _=e.indexOf(`
85
+ `,o);_===-1&&(_=t);let $=a===3?3:5;x(),b($,o,_);break}case 5:if(T===125)x(),o++;else{let _=e.indexOf("}",o);_===-1&&(_=t),b(6,o,_)}break;case 6:{let _;T===34?G():(_=I(HM,o))>=0?(x(),b(24,o,_)):(_=I(KM,o))>=0||(_=I(zM,o))>=0||(_=I(VM,o))>=0?(x(),b(25,o,_)):R=K()||C(T);break}case 7:{let _=e.charCodeAt(o+1);switch(T){case 34:G();break;case 40:case 91:case 123:C(T);break;case 93:x(),_===41?b(46,o,o+2):_===93?b(48,o,o+2):b(70,o,o+1);break;case 41:x(),_===93?b(52,o,o+2):_===41&&e.charCodeAt(o+2)===41?b(54,o,o+3):b(68,o,o+1);break;case 124:x(),b(67,o,o+1);break;case 125:x(),b(72,o,o+1);break;default:{if((T===126||Xe(T))&&K())break;let $=o+1;for(;$<t;){let g=e.charCodeAt($);if(g===91||g===93||g===40||g===41||g===123||g===125||g===124||g===34)break;$++}b(44,o,$)}}break}case 8:{let _=e.charCodeAt(o+1);if(T===34)G();else{if((T===126||Xe(T))&&K())break;if((T===45||T===47||T===41)&&_===41)x(),b(43,o,o+2);else if(T===40||T===91||T===123)C(T);else if(T===41||T===93||T===125)R=!1;else{let $=o+1;for(;$<t;){let g=e.charCodeAt($);if(g===34||g===40||g===41||g===91||g===93||g===123||g===125||(g===45||g===47)&&e.charCodeAt($+1)===41||(g===126||Xe(g))&&v($)&&I(Yy,$)>=0)break;$++}b(44,o,$)}}break}case 9:{let _=e.charCodeAt(o+1);if(T===34){G();break}if((T===126||Xe(T))&&K())break;switch(T){case 40:_===45||_===91||_===40&&e.charCodeAt(o+2)===40?C(T):_===93?(x(),b(56,o,o+2)):C(T);break;case 91:case 123:C(T);break;case 92:_===93?(x(),b(56,o,o+2)):b(44,o,o+1);break;case 47:_===93?(x(),b(57,o,o+2)):b(44,o,o+1);break;case 93:case 41:_===93?(x(),b(56,o,o+2)):R=!1;break;case 125:R=!1;break;default:{if((T===63||T===61)&&_===93){x(),b(56,o,o+2);break}let $=o+1;for(;$<t;){let g=e.charCodeAt($);if(g===92||g===91||g===93||g===40||g===41||g===123||g===125||g===47)break;$++}b(44,o,$)}}break}case 10:R=M(T,Uy,45,-1);break;case 11:R=M(T,Gy,61,-1);break;case 12:R=M(T,Qf,46,45);break;case 13:if(T===34)G();else if(Xe(T))x(),o++;else{let _=o+1;for(;_<t&&!Xe(e.charCodeAt(_));)_++;b(19,o,_)}break;case 14:if(T===40){let _=I(eC,o);x(),_>=0?o=_:(S(15),o++)}else{let _=e.indexOf("(",o);_===-1&&(_=t),b(8,o,_)}break;case 15:if(T===41)x(),o++;else{let _=e.indexOf(")",o);_===-1&&(_=t),b(9,o,_)}break;case 16:if(T===34)S(17),b(7,o,o+1);else if(T===125)x(),o++;else if(T===94)R=!1;else{let _=o+1;for(;_<t;){let $=e.charCodeAt(_);if($===125||$===94||$===34)break;_++}b(7,o,_)}break;case 17:if(T===34)x(),b(7,o,o+1);else{let _=e.indexOf('"',o);_===-1&&(_=t),n.push(7),r.push(e.slice(o,_).replace(tC,"<br/>")),i.push(o),o=_}break}if(!R)return n.push(1),r.push(""),i.push(o),{types:n,texts:r,starts:i};continue e}return n.push(0),r.push(""),i.push(t),{types:n,texts:r,starts:i}}var hl=new Uint8Array(77);for(let e of[32,64,63,65,13,38,35,36,33,39,66])hl[e]=1;var Zf=new Uint8Array(77);for(let e of[32,66,64,25,63,65,38,35,36,33,39])Zf[e]=1;var Jf=new Uint8Array(77);for(let e of[32,64,75,65,36,66,35,39,33,12,14,16,17,19,20,25,21,22,63,61,41])Jf[e]=1;var eh=new Uint8Array(77);for(let e of[32,64,35,75,33,12])eh[e]=1;var zy="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",ha=[],Vy=/}\s*\n/g;function Xy(e,t){let n=e.includes("}")?e.replace(Vy,`}
86
+ `):e,{types:r,texts:i,starts:s}=Ky(n),a=0,o,c=M=>{let T=r[a],R=n===e?s[a]:Kr([ls(e,Vy,2)],s[a]);throw T===1?ut("flowchart",e,R,"",!0):ut("flowchart",e,R,`Expecting ${M}, got '${Xf[T]}'`)},l=(M,T="")=>(r[a]!==M&&c(`'${Xf[M]}'${T?", "+T:""}`),i[a++]),u=()=>{let M=r[a];M!==74&&M!==37&&M!==76&&c("'SEMI', 'NEWLINE', 'EOF'"),a++},h=()=>{hl[r[a]]===0&&c("'NODE_STRING'");let M=i[a++];for(;hl[r[a]]===1;)M+=i[a++];return M},d=()=>{Zf[r[a]]===0&&c("'NODE_STRING'");let M=i[a++];for(;Zf[r[a]]===1;)M+=i[a++];return M},m=()=>{let M=r[a],T;if(M===11)T="string";else if(M===10)T="markdown";else if(M===44||M===60||M===51||M===66)T="text";else return c(`${zy}, 'TAGEND', 'STR', 'MD_STR'`);let R=i[a++];for(;;){let _=r[a];if(_!==44&&_!==60&&_!==51&&_!==66)break;R+=i[a++]}return{text:R,type:T}},p=M=>{l(M,zy)},y=()=>{let M=r[a],T;if(M===11)T="string";else if(M===10)T="markdown";else if(M===42||M===66)T="text";else return c("'EDGE_TEXT', 'STR', 'MD_STR'");let R=i[a++];for(;r[a]===42||r[a]===66;)R+=i[a++];return{text:R,type:T}},E=()=>{let M=r[a],T;if(M===11)T="text";else if(M===10)T="markdown";else if(Jf[M]===1)T="text";else return c("'NODE_STRING', 'STR', 'MD_STR'");let R=i[a++];for(;Jf[r[a]]===1;)R+=i[a++];return{text:R,type:T}},b=()=>{let M=i[a++];for(;r[a]===7;)M+=i[a++];return M},S=()=>{let M=h(),T;switch(r[a]){case 71:a++,T=m(),p(70),t.addVertex(M,T,"square");break;case 55:a++,T=m(),p(54),t.addVertex(M,T,"doublecircle");break;case 69:a++,r[a]===69?(a++,T=m(),p(68),l(68),t.addVertex(M,T,"circle")):(T=m(),p(68),t.addVertex(M,T,"round"));break;case 45:a++,T=m(),p(43),t.addVertex(M,T,"ellipse");break;case 47:a++,T=m(),p(46),t.addVertex(M,T,"stadium");break;case 49:a++,T=m(),p(48),t.addVertex(M,T,"subroutine");break;case 50:{a++;let R=l(64);l(35);let _=l(64);l(67),T=m(),p(70),t.addVertex(M,T,"rect",void 0,void 0,void 0,{[R]:_});break}case 53:a++,T=m(),p(52),t.addVertex(M,T,"cylinder");break;case 73:a++,r[a]===73?(a++,T=m(),p(72),l(72),t.addVertex(M,T,"hexagon")):(T=m(),p(72),t.addVertex(M,T,"diamond"));break;case 51:a++,T=m(),p(70),t.addVertex(M,T,"odd");break;case 58:a++,T=m(),r[a]===57?(a++,t.addVertex(M,T,"lean_right")):(p(56),t.addVertex(M,T,"trapezoid"));break;case 59:a++,T=m(),r[a]===56?(a++,t.addVertex(M,T,"lean_left")):(p(57),t.addVertex(M,T,"inv_trapezoid"));break;default:t.addVertex(M)}return M},x=()=>{let M=S();return r[a]===34&&(a++,t.setClass(M,h())),M},I=()=>{let M=[x()];for(o=void 0;;){let T=r[a]===7?b():void 0;if(r[a]!==75)return o=T,M;do a++;while(r[a]===75);if(r[a]!==36)return T!==void 0&&c("'AMP'"),M;a++,r[a]!==75&&c("'SPACE'");do a++;while(r[a]===75);let R=x();T!==void 0&&t.addVertex(M[M.length-1],void 0,void 0,void 0,void 0,void 0,void 0,T),M.push(R)}},L=()=>{let M;if(r[a]===31&&(M=i[a++]),r[a]===40){let T=t.destructLink(i[a++]);return M!==void 0&&(T.id=M),r[a]===67&&(a++,T.text=m(),p(67),r[a]===75&&a++),T}if(r[a]===41){let T=i[a++],R=y(),_=l(40,"'EDGE_TEXT'"),$=t.destructLink(_,T);return $.text=R,M!==void 0&&($.id=M),$}return c("'LINK', 'START_LINK'")},O=M=>{let T=I();o!==void 0&&t.addVertex(T[T.length-1],void 0,void 0,void 0,void 0,void 0,void 0,o);let R=T;for(;;){let _=r[a];if(_!==40&&_!==41&&_!==31)return R;let $=L(),g=I();o!==void 0&&t.addVertex(g[g.length-1],void 0,void 0,void 0,void 0,void 0,void 0,o),t.addLink(T,g,$),M&&(R=g.concat(R)),T=g}},v=()=>{eh[r[a]]===0&&c("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let M=i[a++];for(;eh[r[a]]===1;)M+=i[a++];return M},G=()=>{let M=[v()];for(;r[a]===38;)a++,M.push(v());return M},K=()=>{a++,l(75);let M;if(r[a]===13)M=[i[a++]];else for(M=[l(32,"'DEFAULT'")];r[a]===38;)a++,M.push(l(32));if(l(75),r[a]!==15){t.updateLink(M,G());return}a++,l(75);let T=d();if(r[a]===75){a++;let R=G();t.updateLinkInterpolate(M,T),t.updateLink(M,R)}else t.updateLinkInterpolate(M,T)},C=(M,T)=>{if(r[a]!==75){t.setLink(M,T);return}if(a++,r[a]===23){t.setLink(M,T,i[a++]);return}let R=l(11,"'LINK_TARGET'");r[a]===75?(a++,t.setLink(M,T,l(23))):t.setLink(M,T),t.setTooltip(M,R)},Z=()=>{let M=i[a++];switch(r[a]){case 8:{let T=i[a++],R=r[a]===9,_=R?i[a++]:void 0,$;r[a]===75&&(a++,$=l(11)),R?t.setClickEvent(M,T,_):t.setClickEvent(M,T),$!==void 0&&t.setTooltip(M,$);return}case 18:a++,C(M,l(11));return;case 11:C(M,i[a++]);return;default:{let T=d();if(r[a]===75){a++;let R=l(11);t.setClickEvent(M,T),t.setTooltip(M,R)}else t.setClickEvent(M,T)}}},oe=()=>{a++;let M=r[a];if(M===74||M===37||M===76)return a++,{id:void 0,title:void 0,list:[],collect:!1};l(75,"'SEMI', 'NEWLINE', 'EOF'");let T=E(),R=T;return r[a]===71&&(a++,R=m(),p(70)),M=r[a],M!==74&&M!==37&&M!==76&&c("'SEMI', 'NEWLINE', 'EOF', 'SQS'"),a++,{id:T,title:R,list:[],collect:!1}},H=M=>{let T=r[a];switch(T){case 12:{a++,l(75);let R=h();return l(75),t.addVertex(R,void 0,void 0,G()),u(),ha}case 14:return K(),u(),ha;case 16:{a++,l(75);let R=h();return l(75),t.addClass(R,G()),u(),ha}case 17:{a++,l(75);let R=h();return l(75),t.setClass(R,h()),u(),ha}case 19:return Z(),u(),ha;case 26:case 27:case 28:case 29:case 30:return a++,{stmt:"dir",value:nC[T-26]};case 2:{a++;let R=l(3).trim();return t.setAccTitle(R),R}case 4:{a++;let R=l(5).trim();return t.setAccDescription(R),R}case 6:{let R=i[a++].trim();return t.setAccDescription(R),R}default:{hl[T]===0&&c(jy);let R=O(M);return u(),R}}},z=()=>{let M=[],T=[],R=!1;for(;;){let _=r[a];if(_===0)break;if(_===22){let $=M.pop();if($===void 0)break;a++;let g=t.addSubGraph($.id,T,$.title);T=$.list,R=$.collect,R&&T.push(g)}else if(_===37||_===74||_===75||_===76)R&&T.push(i[a]),a++;else if(_===21){let $=oe();$.list=T,$.collect=R,M.push($),T=[],R=!0}else{let $=H(R);R&&(!Array.isArray($)||$.length>0)&&T.push($)}}M.length>0&&c("'end'")};for(;r[a]===75||r[a]===74;)a++;if(l(20,"'SPACE', 'NEWLINE'"),r[a]===24)a++,t.setDirection("TB");else{let M=l(25,"'NODIR'"),T=r[a];if(T===75){do a++;while(r[a]===75);T=r[a],T!==74&&c("'NEWLINE', 'SPACE'")}else T!==37&&T!==74&&c("'SEMI', 'NEWLINE', 'SPACE'");a++,t.setDirection(M)}z(),r[a]!==0&&c(jy)}var nC=["TB","BT","RL","LR","TD"],jy="'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";function rC(e){if(e.img)return"imageSquare";if(e.icon)return e.form==="circle"?"iconCircle":e.form==="square"?"iconSquare":e.form==="rounded"?"iconRounded":"icon";switch(e.type){case"square":case void 0:return"squareRect";case"round":return"roundedRect";default:return e.type}}function sC(e){switch(e){case"arrow_point":case"arrow_circle":case"arrow_cross":return["none",e];case"double_arrow_point":case"double_arrow_circle":case"double_arrow_cross":{let t=e.replace("double_","");return[t,t]}}return["none","arrow_point"]}function qy(e,t){let n=[],r=[],i=e.subgraphs,s=x=>{let I=[];for(let L of x){let O=e.classes.get(L);if(O!==void 0){for(let v of O.styles)I.push(v.trim());for(let v of O.textStyles)I.push(v.trim())}}return I},a=new Map;for(let x of i)for(let I of x.nodes)e.subgraph(I)&&a.set(I,x.id);let o=new Map,c=new Map;for(let x of i){let I=a.get(x.id);if(I===void 0)continue;let L=c.get(I);L?L.push(x.id):c.set(I,[x.id])}let l=0;for(let x of i){if(a.has(x.id))continue;let I=[x.id];for(;I.length>0;){let L=I.pop();if(o.has(L))continue;o.set(L,l++);let O=c.get(L);if(O)for(let v=O.length-1;v>=0;v--)I.push(O[v])}}let u=x=>e.subgraph(x)?.metadata?.view==="collapsed",h=!1;for(let x of i)x.metadata?.view==="collapsed"&&(h=!0);let d=new Map,m=x=>{let I=[],L=new Set,O=x;for(;O!==void 0&&!d.has(O)&&!L.has(O);)L.add(O),I.push(O),O=a.get(O);let v=O!==void 0?d.get(O):void 0;for(let G=I.length-1;G>=0;G--)v===void 0&&u(I[G])&&(v=I[G]),d.set(I[G],v);return v},p=new Set,y=new Map;for(let x of h?i:[]){let I=m(x.id);if(I!==void 0){x.id!==I&&(p.add(x.id),y.set(x.id,I));for(let L of x.nodes)L!==I&&(p.add(L),y.set(L,I))}}let E=new Map,b=new Set;for(let x=i.length-1;x>=0;x--){let I=i[x];if(!p.has(I.id)){I.nodes.length>0&&b.add(I.id);for(let L of I.nodes)E.set(L,I.id)}}let S=new Map;for(let x=i.length-1;x>=0;x--){let I=i[x];if(p.has(I.id))continue;let L=I.metadata?.view==="collapsed",O={id:I.id,label:I.title,labelType:I.labelType,parentId:E.get(I.id),cssStyles:[],cssCompiledStyles:s(I.classes),cssClasses:I.classes.join(" "),shape:L?"collapsedGroup":"rect",dir:I.dir,isGroup:!L,colorIndex:o.get(I.id)};L||(O.metadata=I.metadata),n.push(O),S.set(I.id,O)}for(let x of e.nodes.values()){if(p.has(x.id))continue;let I=S.get(x.id);if(I){I.cssStyles=x.styles,I.cssCompiledStyles=s(x.classes),I.cssClasses=x.classes.join(" ");continue}let L=b.has(x.id),O={id:x.id,label:x.text,labelType:x.labelType,parentId:E.get(x.id),cssStyles:x.styles,cssCompiledStyles:s(["default","node",...x.classes]),cssClasses:"default "+x.classes.join(" "),dir:x.dir,link:x.link,linkTarget:x.linkTarget,tooltip:e.tooltips.get(x.id),icon:x.icon,pos:x.pos,img:x.img,assetWidth:x.assetWidth,assetHeight:x.assetHeight,constraint:x.constraint,isGroup:L,shape:L?"rect":rC(x)};n.push(O)}return e.edges.forEach((x,I)=>{let L=y.get(x.start)??x.start,O=y.get(x.end)??x.end;if(L===O&&(y.has(x.start)||y.has(x.end)))return;let[v,G]=sC(x.type),K=[...e.defaultEdgeStyle??[]];x.style&&K.push(...x.style);let C=x.stroke==="invisible"||x.type==="arrow_open";r.push({id:x.id||`L_${L}_${O}_${I}`,isUserDefinedId:x.isUserDefinedId,start:L,end:O,type:x.type??"normal",label:x.text,labelType:x.labelType,thickness:x.stroke,pattern:x.stroke,minlen:x.length,classes:x.stroke==="invisible"?"":"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:C?"none":v,arrowTypeEnd:C?"none":G,cssCompiledStyles:s(x.classes),style:K,animate:x.animate,animation:x.animation,curve:x.interpolate||e.defaultInterpolate||t})}),{nodes:n,edges:r}}var iC=40,oC=16,aC=48,Qy=20,th=26,nh=' fill="var(--_s)" stroke="var(--_b)"',cC=' stroke="var(--_b)"';function rh(e,t,n){let r=e[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function pa(e,t){return e!==void 0&&e>0&&e<=4e3?e:t}function pl(e,t,n,r){let i=s=>xn(n,a=>lC(e,t,n,r,s,a));return vn(e.direction)?vt(n,i):i(!1)}function lC(e,t,n,r,i,s){let a=s?12:Qy,o=r?t[r.type]:void 0,c=typeof o=="object"&&o!==null&&!Array.isArray(o)?o:t.flowchart??{},l=qy(e,typeof c.curve=="string"?c.curve:void 0);r?.prepare(l);let u=n.fontSize??16,h=Math.round(u*.875),d=n.measurer??at(n.fontFamily,n.fontFamilyMono),m=Math.min(rh(c,"wrappingWidth",200),r&&s?100:1/0),p=n.padding??8,y=n.icons,E=new Map,b=[],S=[];l.nodes.forEach((Q,Y)=>E.set(Q.id,Y));for(let Q of l.nodes){let Y=Mt(Q.cssStyles.length>0?Q.cssCompiledStyles.concat(Q.cssStyles):Q.cssCompiledStyles),ne=(Y.bold?1:0)|(Y.italic?2:0),q=Q.labelType==="markdown",k=Y.fontSize??u,J,te;if(Q.isGroup){let se=Ue(Q.label,q,d,k,r&&s?Math.max(80,It(n)/2):4e3,ne);J={node:Q,style:Y,label:se,shape:"group",w:0,h:0,dy:0,loops:0},te=Ft(0,0),te.isGroup=!0,te.dir=Q.dir?cn(Q.dir):void 0,te.padX=a,te.padTop=se.height>0?se.height+16:Qy,te.padBottom=a,te.minW=se.width+2*a-12}else{let se=cc(Q.shape),re=Q.img||Q.icon||Mg(se)?Q.label:void 0,P=Ue(re,q,d,k,m,ne),ee,ae,ue=0;if(Q.img||Q.icon){let ce=Q.img?80:48,he=pa(Q.assetWidth,ce),V=pa(Q.assetHeight,ce);ee=Math.max(he,P.width+8),ae=V+(P.height>0?P.height+6:0),ue=Q.pos==="t"?-V/2:V/2,P.height===0&&(ue=0)}else{let ce=hs(se,P.width,P.height);ee=ce.w,ae=ce.h,ue=ce.dy}J={node:Q,style:Y,label:P,shape:se,w:ee,h:ae,dy:ue,loops:0},te=Ft(ee,ae)}te.seq=b.length,b.push(J),S.push(te)}l.nodes.forEach((Q,Y)=>{S[Y].parent=Q.parentId!==void 0?E.get(Q.parentId)??-1:-1}),bc(S,l.edges.map(Q=>[E.get(Q.start)??-1,E.get(Q.end)??-1]));let x=i?"TB":cn(e.direction),I=Q=>{let Y;for(let ne=S[Q].parent,q=0;ne>=0&&Y===void 0&&q<1e4;ne=S[ne].parent,q++)Y=S[ne].dir;return Y??=x,Y==="LR"||Y==="RL"};b.forEach((Q,Y)=>{Q.node.isGroup?S[Y].span=1/0:!Q.node.img&&!Q.node.icon&&(S[Y].span=Tg(Q.shape,Q.w,Q.h,I(Y)))});let L=[],O=[],v=[];for(let Q of l.edges){let Y=E.get(Q.start),ne=E.get(Q.end);if(Y===void 0||ne===void 0)continue;let q=Ue(Q.label,Q.labelType==="markdown",d,h,m);Y===ne&&(b[Y].loops++,I(Y)?S[Y].h+=2*(th+(q.height>0?q.height+8:0)):S[Y].w+=2*(th+(q.width>0?q.width+12:0))),v.push(Q),O.push(q),L.push({src:Y,dst:ne,minlen:Q.minlen??1,labelW:q.width>0?q.width+12:0,labelH:q.height>0?q.height+4:0,route:[],labelX:0,labelY:0})}let G={nodeSep:rh(c,"nodeSpacing",iC)*(s?.5:1),edgeSep:oC,rankSep:rh(c,"rankSpacing",aC)*(s?.75:1),portSep:20,tracks:typeof c.curve=="string"&&/^step/.test(c.curve),straight:c.curve==="linear",headRoom:_t("arrow_point")},K=r?r.layout(S,L,x,G,s):Ln(S,L,x,G),C=bn(e.title,d,u,s?It(n):4e3),Z=C.height>0?C.height+12:0,oe=Math.max(K.width,C.width),H=p+(oe-K.width)/2,z=p+Z;Rr(S,L,H,z);let M=Math.ceil(oe+2*p),T=Math.ceil(K.height+Z+2*p),R=[],_=new Map,$=!1;for(let Q of S)Q.isGroup&&($=!0);if($)for(let Q of L)dr(_,Q.route);let g="",N="",w="",A=[];for(let Q=0;Q<b.length;Q++){let Y=b[Q],ne=S[Q],q=Y.node,k=ne.x,J=ne.y,te=Nt(q.cssClasses.replace(/^default\s?/,"")),se=We(q.id);if(ne.isGroup&&r?.drawGroup&&ne.parent<0){Tn(Y.style.shape)&&r.filledBox&&A.push({box:r.filledBox(ne,x),shape:Y.style.shape}),g+=r.drawGroup(ne,Y.label,Y.style,te,se,x,y);continue}if(ne.isGroup){Tn(Y.style.shape)&&A.push({box:[k-ne.w/2,J-ne.h/2,k+ne.w/2,J+ne.h/2],shape:Y.style.shape});let V=fs(ne,Y.label.width,_,a),X=J-ne.h/2+8+Y.label.height/2,le=yc(ne,Y.label.width,V,_),de=` class="pele-cluster-label"${le?' fill="var(--_m)"':Dt(Y.style,"var(--_m)")}${Y.style.text}`;le&&(N+=Ec(Y.label,V,X,de,se,S,Q,y)),g+=`<g class="pele-cluster${te}" data-id="${se}"><rect x="${f(k-ne.w/2)}" y="${f(J-ne.h/2)}" width="${f(ne.w)}" height="${f(ne.h)}" fill="var(--_a)"${Dn(Y.style.shape)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${xt(Y.style.shape)}/>`+(le?"":Ce(Y.label,V,X,de,y))+"</g>";continue}let re=Y.w,P=Y.h,ee,ae="";if(q.img){let V=pa(q.assetWidth,80),X=pa(q.assetHeight,80),le=Y.label.height>0?q.pos==="t"?P/2-X:-P/2:-X/2,de=Hm(qn(q.img),n);ee=de===void 0?"":`<image href="${nt(de)}" x="${f(-V/2)}" y="${f(le)}" width="${f(V)}" height="${f(X)}" preserveAspectRatio="${q.constraint==="on"?"xMidYMid meet":"none"}"/>`}else if(q.icon){let V=pa(q.assetHeight,48),X=Y.label.height>0?q.pos==="t"?P/2-V:-P/2:-V/2,le=q.shape==="icon"?"":q.shape==="iconCircle"?`<circle cy="${f(X+V/2)}" r="${f(V/2)}"${nh}${Y.style.shape}/>`:`<rect x="${f(-V/2)}" y="${f(X)}" width="${f(V)}" height="${f(V)}" rx="${q.shape==="iconRounded"?8:0}"${nh}${Y.style.shape}/>`,de=V*.6;ee=le+`<svg class="pele-icon" data-icon="${We(q.icon)}" x="${f(-de/2)}" y="${f(X+(V-de)/2)}" width="${f(de)}" height="${f(de)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${y?.(q.icon)??""}</svg>`}else ee=fr(Y.shape,re,P,nh+Y.style.shape,cC+Y.style.line),Ui(Y.shape)&&(ae=Dt(Y.style));let ue=Ce(Y.label,0,Y.dy,` class="pele-label"${ae}${Y.style.text}`,y);if(/ internal-link(?: |$)/.test(te+" ")&&q.label&&n.links!==!1){let V=gt(q.label),X=ki(V,n),le=nt(V);ue=`<a class="internal-link"${X?` href="${le}"${Xr(n)}`:""} data-href="${le}">${ue}</a>`,R.push({id:q.id,href:V,internal:!0})}let he=ee+ue;q.tooltip&&(he=`<title>${We(q.tooltip)}</title>`+he),q.link&&(he=Qn(he,q.link,q.id,R,n,q.linkTarget?` target="${nt(q.linkTarget)}"`:"")),w+=`<g class="pele-node pele-shape-${Y.shape}${te}" data-id="${se}" transform="translate(${f(k)},${f(J)})">${he}</g>`}let D=Ac();for(let Q=0;Q<L.length;Q++){let Y=L[Q];Y.src===Y.dst||v[Q].thickness==="invisible"||Y.route.length<6||(D.add(Y.src,Zn(Y.route,0,S[Y.src]),v[Q].arrowTypeStart),D.add(Y.dst,Zn(Y.route,Y.route.length-3,S[Y.dst]),v[Q].arrowTypeEnd))}let U="",B="",F="",W=new Map;for(let Q=0;Q<L.length;Q++){let Y=L[Q],ne=v[Q],q=O[Q],k=ne.style.length>0||ne.cssCompiledStyles.length>0?Mt(ne.cssCompiledStyles.concat(ne.style)):void 0;if(ne.thickness!=="invisible"){let J=ne.arrowTypeStart,te=ne.arrowTypeEnd,se;if(Y.src===Y.dst){let ue=b[Y.src],ce=W.get(Y.src)??0;W.set(Y.src,ce+1),se=Sc(S[Y.src],ue.w,ue.h,ce,I(Y.src),th,_t(te),Y)}else{let ue=Y.route.slice(),ce=D.of(Y.src,Zn(ue,0,S[Y.src])),he=D.of(Y.dst,Zn(ue,ue.length-3,S[Y.dst]));Vs(ue,0,b[Y.src],S[Y.src]),Vs(ue,ue.length-3,b[Y.dst],S[Y.dst]),se=Mn(ue,ne.curve,_t(J),_t(te),ce,he)}let re=Tr(se.d,[se.sx,se.sy,se.ex,se.ey],A,k?.line,se.tokens),P=re||(k?.stroke&&ne.thickness!=="invisible"?nt(k.stroke):"var(--_l)"),ee="";ne.thickness==="thick"?ee+=' stroke-width="2.5"':ne.thickness==="dotted"&&(ee+=' stroke-dasharray="3 4"');let ae=Nt(ne.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));re===""&&(U+=Mr(se,J,te,k?.line,ne.thickness==="thick")),B+=`<g class="pele-edge${ae}" data-id="${We(ne.id)}"${re?` stroke="${re}"`:""}${k?.line??""}><path d="${se.d}"${ee}/>`+wt(J,se.sx,se.sy,se.sdx,se.sdy,P)+wt(te,se.ex,se.ey,se.edx,se.edy,P)+"</g>"}if(q.width>0){let J=Y.labelX,te=Y.labelY;F+=ln(ne.id,q,J,te,k?.text??"",y)}}return{svg:ot(r?.type??"flowchart",M,T,u,n,e,Ce(C,M/2,p+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+(g?`<g class="pele-clusters">${g}</g>`:"")+On(U)+(B?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${B}</g>`:"")+(N?`<g class="pele-cluster-titles">${N}</g>`:"")+(F?`<g class="pele-edge-labels" font-size="${h}">${F}</g>`:"")+`<g class="pele-nodes">${w}</g>`),width:M,height:T,links:R}}var ml={type:"flowchart",math:!0,parse(e,t,n,r,i){let s=t.flowchart??{},a=new fl({inheritDir:s.inheritDir===!0,maxEdges:i.maxEdges});return n&&(a.title=n),Xy(e,a),a},render:pl};var ri=["January","February","March","April","May","June","July","August","September","October","November","December"],Zr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Ji(e){return!Number.isNaN(e.getTime())}function Hn(e,t){let n=String(e);return n.length>=t?n:"0".repeat(t-n.length)+n}function oE(e){let t=["th","st","nd","rd"],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])}function sh(e){let t=-Math.round(e.getTimezoneOffset()/15)*15;return t===0?0:t}function Zy(e){let t=sh(e),n=Math.abs(t);return(t>=0?"+":"-")+Hn(Math.floor(n/60),2)+":"+Hn(n%60,2)}function aE(e){return e.getDay()||7}function vr(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function dC(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t.getDate()}function Jy(e,t){let n=new Date(e);return n.setDate(1),t(n),n.setDate(Math.min(e.getDate(),dC(n))),n}function bl(e,t,n){switch(n){case"M":return Jy(e,r=>r.setMonth(e.getMonth()+t));case"y":return Jy(e,r=>r.setFullYear(e.getFullYear()+t));case"d":return vr(e,Math.round(t));case"w":return vr(e,Math.round(7*t));case"h":return new Date(e.getTime()+t*36e5);case"m":return new Date(e.getTime()+t*6e4);case"s":return new Date(e.getTime()+t*1e3);default:return new Date(e.getTime()+t)}}function cE(e){return vr(e,4-aE(e))}function eE(e){let t=cE(e),n=new Date(t.getFullYear(),0,1),r=aE(n),i=vr(n,4-r+(r>4?7:0)),s=(sh(i)-sh(t))*6e4,a=(t.getTime()-i.getTime()-s)/6048e5;return(a<0?Math.ceil(a)||0:Math.floor(a))+1}var uC=/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,fC=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,hC="YYYY-MM-DDTHH:mm:ssZ";function ih(e,t){if(!Ji(e))return"Invalid Date";let n=t||hC;if(n==="YYYY-MM-DD")return oh(e);let r=!1,i=n.replace(uC,a=>{switch(a){case"Q":return String(Math.ceil((e.getMonth()+1)/3));case"Do":return"["+oE(e.getDate())+"]";case"GGGG":return String(cE(e).getFullYear());case"W":return String(eE(e));case"WW":return Hn(eE(e),2);case"k":return String(e.getHours()||24);case"kk":return Hn(e.getHours()||24,2);case"X":return String(Math.floor(e.getTime()/1e3));case"x":return String(e.getTime());case"gggg":case"wo":case"w":case"ww":case"z":case"zzz":return r=!0,a;default:return a}});if(r)return;let s=e.getHours();return i.replace(fC,(a,o)=>{if(o)return o;switch(a){case"YY":return String(e.getFullYear()).slice(-2);case"YYYY":return Hn(e.getFullYear(),4);case"M":return String(e.getMonth()+1);case"MM":return Hn(e.getMonth()+1,2);case"MMM":return ri[e.getMonth()].slice(0,3);case"MMMM":return ri[e.getMonth()];case"D":return String(e.getDate());case"DD":return Hn(e.getDate(),2);case"d":return String(e.getDay());case"dd":return Zr[e.getDay()].slice(0,2);case"ddd":return Zr[e.getDay()].slice(0,3);case"dddd":return Zr[e.getDay()];case"H":return String(s);case"HH":return Hn(s,2);case"h":return String(s%12||12);case"hh":return Hn(s%12||12,2);case"a":return s<12?"am":"pm";case"A":return s<12?"AM":"PM";case"m":return String(e.getMinutes());case"mm":return Hn(e.getMinutes(),2);case"s":return String(e.getSeconds());case"ss":return Hn(e.getSeconds(),2);case"SSS":return Hn(e.getMilliseconds(),3);case"Z":return Zy(e);default:return Zy(e).replace(":","")}})}function oh(e){let t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate();return(t>=1e3&&t<=9999?t:Hn(t,4))+(n<10?"-0":"-")+n+(r<10?"-0":"-")+r}var pC=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,mC=/\[[^\]]+]/g,tE=/\d/,ma=/\d\d/,gC=/\d{3}/,bC=/\d{4}/,mr=/\d\d?/,yC=/[+-]?\d+/,nE=/[+-]\d\d:?(\d\d)?|Z/,ga=/\d*[^-_:/,()\s\d]+/;function wn(e){return(t,n)=>(t[e]=+n,!0)}var rE=(e,t)=>{if(t==="Z")return e.offset=0,!0;let n=t.match(/([+-]|\d\d)/g),r=+n[1]*60+(+n[2]||0);return e.offset=r===0?0:n[0]==="+"?-r:r,!0};function sE(e){return(t,n)=>{let r=e.indexOf(n)+1;return r<1?!1:(t.month=r%12||r,!0)}}var EC=new Map([["A",{re:ga,read:(e,t)=>(e.afternoon=t==="PM",!0)}],["a",{re:ga,read:(e,t)=>(e.afternoon=t==="pm",!0)}],["Q",{re:tE,read:(e,t)=>(e.month=(+t-1)*3+1,!0)}],["S",{re:tE,read:(e,t)=>(e.milliseconds=+t*100,!0)}],["SS",{re:ma,read:(e,t)=>(e.milliseconds=+t*10,!0)}],["SSS",{re:gC,read:(e,t)=>(e.milliseconds=+t,!0)}],["s",{re:mr,read:wn("seconds")}],["ss",{re:mr,read:wn("seconds")}],["m",{re:mr,read:wn("minutes")}],["mm",{re:mr,read:wn("minutes")}],["H",{re:mr,read:wn("hours")}],["h",{re:mr,read:wn("hours")}],["HH",{re:mr,read:wn("hours")}],["hh",{re:mr,read:wn("hours")}],["D",{re:mr,read:wn("day")}],["DD",{re:ma,read:wn("day")}],["Do",{re:ga,read:(e,t)=>{let n=t.match(/\d+/);if(!n)return!1;e.day=+n[0],e.dayGiven=!0;for(let r=1;r<=31;r++)oE(r)===t&&(e.day=r);return!0}}],["w",{re:mr,read:wn("week")}],["ww",{re:ma,read:wn("week")}],["M",{re:mr,read:wn("month")}],["MM",{re:ma,read:wn("month")}],["MMM",{re:ga,read:sE(ri.map(e=>e.slice(0,3)))}],["MMMM",{re:ga,read:sE(ri)}],["Y",{re:yC,read:wn("year")}],["YY",{re:ma,read:(e,t)=>(e.year=+t+(+t>68?1900:2e3),!0)}],["YYYY",{re:bC,read:wn("year")}],["Z",{re:nE,read:rE}],["ZZ",{re:nE,read:rE}]]),iE,gl=null;function xC(e){if(e===iE)return gl;if(iE=e,gl=null,/[Ll]/.test(e.replace(mC,"")))return null;let t=e.match(pC);return t?(gl=t.map(n=>EC.get(n)??n.replace(/^\[|\]$/g,"")),gl):null}function AC(e,t,n){if(t==="x"||t==="X")return new Date((t==="X"?1e3:1)*Number(e));let r=xC(t);if(!r)return;let i={},s=e,a=0;for(let p of r){if(typeof p=="string"){a+=p.length;continue}let y=p.re.exec(s.slice(a));if(!y||!p.read(i,y[0]))return;s=s.replace(y[0],"")}i.afternoon!==void 0&&i.hours!==void 0&&(i.afternoon?i.hours<12&&(i.hours+=12):i.hours===12&&(i.hours=0));let o=i.dayGiven||i.day?i.day:!i.year&&!i.month?n.getDate():1,c=i.year||n.getFullYear(),l=0;i.year&&!i.month||(l=i.month>0?i.month-1:n.getMonth());let u=i.hours||0,h=i.minutes||0,d=i.seconds||0,m=i.milliseconds||0;if(i.offset!==void 0)return new Date(Date.UTC(c,l,o,u,h,d,m+i.offset*6e4));if(!i.week)return new Date(c,l,o,u,h,d,m)}function lE(e,t,n){let r=AC(e,t,n);return r&&Ji(r)&&ih(r,t)===e?r:void 0}var SC=/^[YMDHhmsSZXx\-/.:, T]*$/,wC=/^\s*(active|done|crit|milestone|vert)\s*$/,_C=/^after\s+([\d\w- ]+)/,RC=/^until\s+([\d\w- ]+)/,TC=/^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/,MC=/[\s,]+/,CC=/^\d+$/,NC=new Set(Zr.map(e=>e.toLowerCase())),IC=4e8,kC=400,$C=200,LC=400;function ah(e){let t=e===void 0?NaN:+e;return Number.isFinite(t)?t:Date.now()}function OC(e){let t=TC.exec(e.trim());return t?[Number.parseFloat(t[1]),t[2]]:[NaN,"ms"]}function dE(e,t){let n=new Set(e);for(let r of t.toLowerCase().split(MC))r!==""&&n.add(r);return[...n]}var yl=class{type="gantt";title;accTitle;accDescr;dateFormat="";axisFormat="";tickInterval;todayMarker="";includes=[];excludes=[];inclusiveEndDates=!1;topAxis=!1;displayMode="";weekday;weekend="saturday";sections=[];links=new Map;tasks=[];byId=new Map;currentSection="";taskCount=0;lastOrder=0;lastTaskId;options;now=0;work=0;includeSet=new Set;excludeSet=new Set;excludedDays=[];datedTokens=!1;constructor(t={}){this.options=t}setDateFormat(t){this.dateFormat=t}enableInclusiveEndDates(){this.inclusiveEndDates=!0}TopAxis(){this.topAxis=!0}setAxisFormat(t){this.axisFormat=t}setTickInterval(t){this.tickInterval=t}setTodayMarker(t){this.todayMarker=t}setIncludes(t){this.includes=dE(this.includes,t)}setExcludes(t){this.excludes=dE(this.excludes,t)}setWeekday(t){this.weekday=t}setWeekend(t){this.weekend=t}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
87
+ `)}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,n){let r=(n.startsWith(":")?n.slice(1):n).split(","),i={id:"",task:t,section:this.currentSection,startTime:void 0,endTime:void 0,renderEndTime:null,manualEndTime:!1,processed:!1,active:!1,done:!1,crit:!1,milestone:!1,vert:!1,order:-1,classes:[],prevTaskId:this.lastTaskId,raw:{data:n,start:void 0,end:""}},s;for(;r.length>0&&(s=wC.exec(r[0]))!==null;)i[s[1]]=!0,r.shift();if(r.length===0)throw new qe(`Task "${t.trim()}" needs a duration or an end date.`,"semantic",{type:"gantt"});if(r.length>3)throw new qe(`Task "${t.trim()}" has too many fields. A task takes an id, a start, and an end or duration.`,"semantic",{type:"gantt"});for(let a=0;a<r.length;a++)r[a]=r[a].trim();r.length===3?i.id=r[0]:(this.taskCount++,i.id="task"+this.taskCount),r.length>1&&(i.raw.start=r[r.length-2]),i.raw.end=r[r.length-1],i.vert||(i.order=this.lastOrder++),this.tasks.push(i),this.lastTaskId=i.id,this.byId.set(i.id,i)}setLink(t,n){let r=qn(n);for(let i of t.split(","))this.byId.has(i)&&this.links.set(i,r);this.setClass(t,"clickable")}setClickEvent(t,n,r){this.setClass(t,"clickable")}setClass(t,n){for(let r of t.split(","))this.byId.get(r)?.classes.push(n)}getTasks(t){this.now=ah(t),this.work=0,this.includeSet=new Set(this.includes),this.excludeSet=new Set(this.excludes);let n=this.weekend==="friday"?5:this.weekend==="saturday"?6:NaN,r=this.excludeSet.has("weekends");this.excludedDays=Zr.map((s,a)=>{let o=a||7;return r&&(o===n||o===n+1)||this.excludeSet.has(s.toLowerCase())}),this.datedTokens=this.includes.length>0||!SC.test(this.dateFormat.trim());for(let s of this.excludes)s!=="weekends"&&!NC.has(s)&&(this.datedTokens=!0);for(let s of this.tasks)s.startTime=s.endTime=void 0,s.renderEndTime=null,s.processed=s.manualEndTime=!1;let i=this.compileTasks();for(let s=0;!i&&s<10;s++)i=this.compileTasks();return this.tasks}isInvalidDate(t){let n=this.excludedDays[t.getDay()];if(!this.datedTokens)return n;let r=this.dateFormat.trim(),i=oh(t),s=i;this.spend($C),r!=="YYYY-MM-DD"&&(this.spend(LC+r.length*8),s=ih(t,r));let a=o=>o.has(i)||s!==void 0&&o.has(s);return a(this.includeSet)?!1:n||a(this.excludeSet)}spend(t){if(this.work+=t,this.work>IC)throw new qe("The gantt chart takes too much work to schedule.","limit",{type:"gantt"})}parse(t,n){return this.spend((n.length+1)*(t.length+1)),lE(t,n,new Date(this.now))}today(){let t=new Date(this.now);return t.setHours(0,0,0,0),t}warn(t){this.options.warn&&this.options.warn(t())}compileTasks(){let t=!0;for(let n of this.tasks)this.compileTask(n),t=t&&n.processed;return t}compileTask(t){let n=t.raw.start;if(n===void 0){let r=t.prevTaskId===void 0?void 0:this.byId.get(t.prevTaskId);t.startTime=r?r.endTime:this.today()}else{let r=this.getStartDate(n);r&&(t.startTime=r)}t.startTime&&(t.endTime=this.getEndDate(t.startTime,t.raw.end),t.endTime&&(t.processed=!0,t.manualEndTime=this.parse(t.raw.end,"YYYY-MM-DD")!==void 0,this.checkTaskDates(t)))}references(t,n){let r=[],i;for(let s of n.split(" ")){if(s==="")continue;let a=this.byId.get(s);a?r.push(a):(i??=[]).push(s)}if(i){let s=i;this.warn(()=>`Gantt: "${t}" refers to task ids that do not exist: ${s.join(", ")}.`)}return r}getStartDate(t){let n=t.trim(),r=this.dateFormat.trim();if((r==="x"||r==="X")&&CC.test(n))return this.checked(new Date(Number(n)),n);let i=_C.exec(n);if(i!==null){let o=this.references("after",i[1]),c;for(let l of o)(!c||l.endTime>c.endTime)&&(c=l);return c?c.endTime:this.today()}let s=this.parse(n,r);if(s)return s;let a=new Date(n);if(!Ji(a)||a.getFullYear()<-1e4||a.getFullYear()>1e4)throw new qe("Invalid date:"+n,"semantic",{type:"gantt"});return a}checked(t,n){if(!Ji(t))throw new qe("Invalid date:"+n,"semantic",{type:"gantt"});return t}getEndDate(t,n){let r=n.trim(),i=RC.exec(r);if(i!==null){let u=this.references("until",i[1]),h;for(let d of u)(!h||d.startTime<h.startTime)&&(h=d);return h?h.startTime:this.today()}let s=this.dateFormat.trim(),a=this.parse(r,s);if(a)return this.inclusiveEndDates?vr(a,1):a;let[o,c]=OC(r);if(Number.isNaN(o))return this.warn(()=>`Gantt: "${r}" is neither a date in the "${s}" format nor a duration such as "3d", so the task gets no duration.`),new Date(t);let l=bl(t,o,c);return Ji(l)?l:new Date(t)}checkTaskDates(t){if(this.excludes.length===0||t.manualEndTime)return;let n=vr(t.startTime,1),r=new Date(t.endTime),i=+vr(r,1e4),s=!1,a=null;for(;+n<=+r;){if(this.spend(kC),s||(a=+r),s=this.isInvalidDate(n),s&&(r.setDate(r.getDate()+1),+r>i))throw new qe("Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.","semantic",{type:"gantt"});n.setDate(n.getDate()+1)}t.endTime=r,t.renderEndTime=a===null?null:new Date(a)}};var uE=["$end","INVALID","open_directive","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","NL","href","callbackname","callbackargs","click","gantt","dateFormat","inclusiveEndDates","topAxis","axisFormat","tickInterval","includes","excludes","todayMarker","weekday_monday","weekday_tuesday","weekday_wednesday","weekday_thursday","weekday_friday","weekday_saturday","weekday_sunday","weekend_friday","weekend_saturday","date","title","accDescription","section","taskTxt","taskData",":","EOF"];var DC=/accTitle\s*:\s*/iy,vC=/accDescr\s*:\s*/iy,PC=/accDescr\s*\{\s*/iy,FC=/href\s+"/iy,BC=/call\s+/iy,WC=/click\s+/iy,UC=/\(\s*\)/y,ch=/weekday\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/iy,GC=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],lh=/weekend\s+(?:(friday)|saturday)\b/iy,YC=/\d\d\d\d-\d\d-\d\d\b/y,HC=/title[^\S\r\n]*(?=[\r\n]|$)/iy,KC=new Map([[97,[[/axisFormat\s[^#\n;]+/iy,17],[/accDescription\s[^#\n;]+/iy,33]]],[103,[[/gantt\b/iy,13]]],[100,[[/dateFormat\s[^#\n;]+/iy,14]]],[105,[[/inclusiveEndDates\b/iy,15],[/includes\s[^#\n;]+/iy,19]]],[116,[[/topAxis\b/iy,16],[/tickInterval\s[^#\n;]+/iy,18],[/todayMarker\s[^\n;]+/iy,21],[/title[^\S\r\n][^\n]+/iy,32]]],[101,[[/excludes\s[^#\n;]+/iy,20]]],[115,[[/section\s[^\n]+/iy,34]]]]);function fE(e){let t=e.length,n=[],r=[],i=[],s=0,a=0,o=(h,d,m)=>{n.push(h),r.push(e.slice(d,m)),i.push(d),a=m},c=h=>(h.lastIndex=a,h.test(e)?h.lastIndex:-1),l=(h,d)=>{let m=e.indexOf(h,d);return m===-1?t:m},u=h=>{let d;switch(h|32){case 97:if((d=c(DC))>=0)return s=1,o(3,a,d),!0;if((d=c(vC))>=0)return s=2,o(5,a,d),!0;if((d=c(PC))>=0)return s=3,a=d,!0;break;case 104:if((d=c(FC))>=0)return s=4,a=d,!0;break;case 99:if((d=c(BC))>=0)return s=5,a=d,!0;if((d=c(WC))>=0)return s=7,a=d,!0;break;case 116:if((d=c(HC))>=0)return a=d,!0;break;case 119:{ch.lastIndex=a;let p=ch.exec(e);if(p)return o(22+GC.indexOf(p[1].toLowerCase()),a,ch.lastIndex),!0;if(lh.lastIndex=a,p=lh.exec(e),p)return o(p[1]!==void 0?29:30,a,lh.lastIndex),!0;break}}let m=KC.get(h|32);if(m){for(let[p,y]of m)if((d=c(p))>=0)return o(y,a,d),!0}return!1};for(;;){if(a>=t){let d=38;switch(s){case 1:d=4;break;case 2:d=6;break;case 3:d=7;break;case 4:d=9;break;case 5:d=10;break;case 6:d=11;break;case 7:d=12;break}o(d,t,t);break}let h=e.charCodeAt(a);switch(s){case 0:{let d=e.charCodeAt(a+1);if(h===37)if(d!==37){let m=l(`
88
+ `,a+1);for(;e.charCodeAt(m)===10;)m++;a=m}else{if(e.charCodeAt(a+2)===123)return o(2,a,a+3),o(1,a,a),{types:n,texts:r,starts:i};a=l(`
89
+ `,a+2)}else if(h===10){let m=a+1;for(;e.charCodeAt(m)===10;)m++;o(8,a,m)}else if(Xe(h))for(a++;a<t&&Xe(e.charCodeAt(a));)a++;else{if(u(h))break;if(h>=48&&h<=57&&c(YC)>=0)o(31,a,a+10);else if(h!==58){let m=a+1;for(;m<t;){let p=e.charCodeAt(m);if(p===58||p===10)break;m++}o(35,a,m)}else{let m=a+1;for(;m<t;){let p=e.charCodeAt(m);if(p===35||p===10||p===59)break;m++}o(m>a+1?36:37,a,m)}}break}case 1:case 2:{let d=s===1?4:6;s=0,o(d,a,l(`
90
+ `,a));break}case 3:h===125?(s=0,a++):o(7,a,l("}",a));break;case 4:h===34?(s=0,a++):o(9,a,l('"',a));break;case 5:if(h===40){let d=c(UC);d>=0?(s=0,a=d):(s=6,a++)}else o(10,a,l("(",a));break;case 6:h===41?(s=0,a++):o(11,a,l(")",a));break;case 7:if(Xe(h))s=0,a++;else{let d=a+1;for(;d<t&&!Xe(e.charCodeAt(d));)d++;o(12,a,d)}break}}return n.push(0),r.push(""),i.push(t),{types:n,texts:r,starts:i}}var zC=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],hE="'EOF', 'SPACE', 'NL', 'weekday_monday', 'weekday_tuesday', 'weekday_wednesday', 'weekday_thursday', 'weekday_friday', 'weekday_saturday', 'weekday_sunday', 'weekend_friday', 'weekend_saturday', 'dateFormat', 'inclusiveEndDates', 'topAxis', 'axisFormat', 'tickInterval', 'excludes', 'includes', 'todayMarker', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskTxt', 'click'",El=new Uint8Array(39);for(let e=22;e<=30;e++)El[e]=1;for(let e of[38,8,14,15,16,17,18,20,19,21,32,3,5,7,34,35,12])El[e]=1;function pE(e,t){let{types:n,texts:r,starts:i}=fE(e),s=0,a=c=>{let l=n[s];throw ut("gantt",e,i[s],`Expecting ${c}, got '${l===0?"1":uE[l]}'`)},o=(c="")=>{El[n[s]]!==1&&a(hE+c)};for(n[s]!==13&&a("'gantt'"),s++;;){let c=n[s],l=r[s];switch(El[c]!==1&&a(hE),s++,c){case 38:if(n[s]===0)return;o();break;case 8:break;case 14:o(),t.setDateFormat(l.slice(11));break;case 15:o(),t.enableInclusiveEndDates();break;case 16:o(),t.TopAxis();break;case 17:o(),t.setAxisFormat(l.slice(11));break;case 18:o(),t.setTickInterval(l.slice(13));break;case 20:o(),t.setExcludes(l.slice(9));break;case 19:o(),t.setIncludes(l.slice(9));break;case 21:o(),t.setTodayMarker(l.slice(12));break;case 29:o(),t.setWeekend("friday");break;case 30:o(),t.setWeekend("saturday");break;case 32:o(),t.setDiagramTitle(l.slice(6));break;case 3:{n[s]!==4&&a("'acc_title_value'");let u=r[s++];o(),t.setAccTitle(u.trim());break}case 5:{n[s]!==6&&a("'acc_descr_value'");let u=r[s++];o(),t.setAccDescription(u.trim());break}case 7:o(),t.setAccDescription(l.trim());break;case 34:o(),t.addSection(l.slice(8));break;case 35:{n[s]!==36&&a("'taskData'");let u=r[s++];o(),t.addTask(l,u);break}case 12:{let u,h=null,d;n[s]===10?(u=r[s++],n[s]===11&&(h=r[s++]),n[s]===9?(d=r[s++],o()):o(h===null?", 'callbackargs', 'href'":", 'href'")):n[s]===9?(d=r[s++],n[s]===10?(u=r[s++],n[s]===11?(h=r[s++],o()):o(", 'callbackargs'")):o(", 'callbackname'")):a("'callbackname', 'href'"),u!==void 0&&t.setClickEvent(l,u,h),d!==void 0&&t.setLink(l,d);break}default:o(),t.setWeekday(zC[c-22])}}}var Jr=1e3,es=60*Jr,si=60*es,ii=24*si,Ea=7*ii,uh=30*ii,Sl=365*ii;function xl(e){e.setHours(0,0,0,0)}function _l(e){return{floor(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),xl(t)},offset:(t,n)=>t.setDate(t.getDate()+n*7),cycle:1/0,ms:Ea}}var ba={millisecond:{floor:()=>{},offset:(e,t)=>e.setTime(+e+t),cycle:1/0,ms:1},second:{floor:e=>e.setTime(+e-e.getMilliseconds()),offset:(e,t)=>e.setTime(+e+t*Jr),field:e=>e.getUTCSeconds(),cycle:60,ms:Jr},minute:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*Jr),offset:(e,t)=>e.setTime(+e+t*es),field:e=>e.getMinutes(),cycle:60,ms:es},hour:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*Jr-e.getMinutes()*es),offset:(e,t)=>e.setTime(+e+t*si),field:e=>e.getHours(),cycle:24,ms:si},day:{floor:xl,offset:(e,t)=>e.setDate(e.getDate()+t),field:e=>e.getDate()-1,cycle:31,ms:ii},month:{floor(e){e.setDate(1),xl(e)},offset:(e,t)=>e.setMonth(e.getMonth()+t),field:e=>e.getMonth(),cycle:12,ms:uh},year:{floor(e){e.setMonth(0,1),xl(e)},offset:(e,t)=>e.setFullYear(e.getFullYear()+t),cycle:1/0,ms:Sl}};function wl(e,t,n){return Math.floor((+t-+e-(t.getTimezoneOffset()-e.getTimezoneOffset())*es)/n)}function VC(e,t){return(e%t+t)%t}function Al(e,t,n){let r=e==="week"?_l(n):ba[e];if(t<=1)return r;if(e==="millisecond")return{...r,floor:a=>a.setTime(Math.floor(+a/t)*t),offset:(a,o)=>a.setTime(+a+o*t)};if(e==="year")return{...r,floor(a){a.setFullYear(Math.floor(a.getFullYear()/t)*t),r.floor(a)},offset:(a,o)=>a.setFullYear(a.getFullYear()+o*t)};if(e==="week"){let a=new Date(0);return r.floor(a),{...r,floor(o){r.floor(o),r.offset(o,-VC(wl(a,o,Ea),t))},offset:(o,c)=>r.offset(o,c*t)}}let i=r.field,s=a=>i(a)%t===0;return{...r,floor(a){for(r.floor(a);Number.isFinite(+a)&&!s(a);r.floor(a))a.setTime(+a-1)},offset(a,o){for(let c=0;c<o&&Number.isFinite(+a);c++)do r.offset(a,1);while(Number.isFinite(+a)&&!s(a))}}}function bE(e,t,n,r){let i=new Date(t-1);e.floor(i),e.offset(i,1),e.floor(i);let s=[],a=-1/0;for(;+i<=n&&+i>a;){if(s.length>=r)return;a=+i,s.push(a),e.offset(i,1),e.floor(i)}return s}function mE(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),a=s>=Math.sqrt(50)?10:s>=Math.sqrt(10)?5:s>=Math.SQRT2?2:1;return Math.pow(10,i)*a}var eo=[["second",1,Jr],["second",5,5*Jr],["second",15,15*Jr],["second",30,30*Jr],["minute",1,es],["minute",5,5*es],["minute",15,15*es],["minute",30,30*es],["hour",1,si],["hour",3,3*si],["hour",6,6*si],["hour",12,12*si],["day",1,ii],["day",2,2*ii],["week",1,Ea],["month",1,uh],["month",3,3*uh],["year",1,Sl]];function yE(e,t,n){let r=(t-e)/n,i=0;for(;i<eo.length&&eo[i][2]<=r;)i++;let s;if(i===eo.length)s=Al("year",Math.max(1,mE(e/Sl,t/Sl,n)),0);else if(i===0)s=Al("millisecond",Math.max(mE(e,t,n),1),0);else{let[a,o]=eo[r/eo[i-1][2]<eo[i][2]/r?i-1:i];s=Al(a,o,0)}return bE(s,e,t,4*n+8)??[]}var jC=/^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/,XC=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function EE(e,t,n,r,i){let s=jC.exec(e);if(!s)return;let a=parseInt(s[1],10),o=s[2],c=Al(o,a,Math.max(0,XC.indexOf(t)));if(!((r-n)/(Math.min(a,c.cycle)*c.ms)>i))return bE(c,n,r,i)}function fn(e,t,n){let r=e<0?"-":"",i=String(r?-e:e);return r+(i.length<n?t.repeat(n-i.length)+i:i)}function As(e,t){let n=new Date(+e);return t.floor(n),n}function gE(e,t){let n=_l(t),r=As(e,ba.year);return wl(As(new Date(+r-1),n),As(e,n),Ea)}function dh(e){let t=_l(4),n=e.getDay(),r=As(n>=4||n===0?e:new Date(+e-1),t);return n>=4||n===0||(t.offset(r,1),t.floor(r)),r}var qC=new Map([["-",""],["_"," "],["0","0"]]);function ya(e,t){let n="",r=0,i=e.length;for(let s=0;s<i;s++){if(e.charCodeAt(s)!==37)continue;n+=e.slice(r,s);let a=e.charAt(++s),o=qC.get(a);o!==void 0?a=e.charAt(++s):o=a==="e"?" ":"0",n+=QC(a,t,o),r=s+1}return n+e.slice(r)}function QC(e,t,n){switch(e){case"a":return Zr[t.getDay()].slice(0,3);case"A":return Zr[t.getDay()];case"b":return ri[t.getMonth()].slice(0,3);case"B":return ri[t.getMonth()];case"c":return ya("%x, %X",t);case"d":case"e":return fn(t.getDate(),n,2);case"f":return fn(t.getMilliseconds(),n,3)+"000";case"g":return fn(dh(t).getFullYear()%100,n,2);case"G":return fn(dh(t).getFullYear()%1e4,n,4);case"H":return fn(t.getHours(),n,2);case"I":return fn(t.getHours()%12||12,n,2);case"j":return fn(1+wl(As(t,ba.year),As(t,ba.day),ii),n,3);case"L":return fn(t.getMilliseconds(),n,3);case"m":return fn(t.getMonth()+1,n,2);case"M":return fn(t.getMinutes(),n,2);case"p":return t.getHours()>=12?"PM":"AM";case"q":return String(1+Math.floor(t.getMonth()/3));case"Q":return String(+t);case"s":return String(Math.floor(+t/1e3));case"S":return fn(t.getSeconds(),n,2);case"u":return String(t.getDay()||7);case"U":return fn(gE(t,0),n,2);case"V":{let r=dh(t),i=As(r,ba.year),s=As(i,_l(4));return fn(wl(s,r,Ea)+(i.getDay()===4?1:0),n,2)}case"w":return String(t.getDay());case"W":return fn(gE(t,1),n,2);case"x":return ya("%-m/%-d/%Y",t);case"X":return ya("%-I:%M:%S %p",t);case"y":return fn(t.getFullYear()%100,n,2);case"Y":return fn(t.getFullYear()%1e4,n,4);case"Z":{let r=t.getTimezoneOffset(),i=Math.abs(r);return(r>0?"-":"+")+fn(Math.floor(i/60),"0",2)+fn(i%60,"0",2)}case"%":return"%";default:return e}}var ZC=800,JC=240,to=8,eN=/<br\s*\/?>/gi;function Pr(e,t,n,r){let i=e.gantt?.[t];return typeof i=="number"&&Number.isFinite(i)?Math.min(r,Math.max(n,i)):void 0}function fh(e,t){let n=e.gantt?.[t];return typeof n=="string"?n:void 0}function tN(e,t){return e.gantt?.[t]===!0}function xE(e,t,n){let r=Ue(e.replace(eN," "),!1,t,n,4e3);return r.lines.length<=1?r:{...r,lines:[r.lines[0]],widths:[r.widths[0]],width:r.widths[0],height:r.lineHeight}}function Rl(e){return Number.isFinite(+e.startTime)&&Number.isFinite(+e.endTime)}function nN(e,t,n){let r=e.filter(Rl).sort((a,o)=>+a.startTime-+o.startTime||a.order-o.order),i=[];for(let a of r){let o=+a.startTime,c=0;for(;c<i.length&&o<i[c];)c++;i[c]=+a.endTime,n.set(a,t+c)}let s=i.length;for(let a of e)n.has(a)||n.set(a,t+s++);return Math.max(s,1)}function AE(e,t,n){let r=n.fontSize??16,i=n.measurer??at(n.fontFamily,n.fontFamilyMono),s=n.padding??8,a=ah(n.now),o=Pr(t,"fontSize",4,72)??Math.round(r*.8125),c=Pr(t,"sectionFontSize",4,72)??o,l=Math.round(r*.75),u=Pr(t,"barHeight",4,400)??Math.round(o*1.85),h=Pr(t,"barGap",0,400)??Math.round(u/4),d=u+h,m=Math.round(Pr(t,"numberSectionStyles",1,1e3)??4),p=e.displayMode==="compact",y=e.topAxis||tN(t,"topAxis"),E=e.getTasks(a),b=E.filter(be=>!be.vert),S=E.filter(be=>be.vert&&Rl(be)),x=new Map;for(let be of b)x.has(be.section)||x.set(be.section,x.size);let I=new Map,L=[];if(p){let be=new Map;for(let Se of b){let Ne=be.get(Se.section);Ne?Ne.push(Se):be.set(Se.section,[Se])}for(let[Se,Ne]of be){let De=nN(Ne,L.length,I);for(let ve=0;ve<De;ve++)L.push(Se)}}else for(let be of b)I.set(be,L.length),L.push(be.section);let O=L.length,v=1/0,G=-1/0;for(let be of E)Rl(be)&&(v=Math.min(v,+be.startTime),G=Math.max(G,+be.endTime));let K=v<=G,C=Ue(e.title,!1,i,r,4e3,1),Z=C.height>0?C.height+16:0;if(!K){let be=Math.ceil(Math.max(C.width,1)+2*s),Se=Math.ceil(Math.max(C.height,1)+2*s),Ne=Ce(C,be/2,s+C.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:ot("gantt",be,Se,r,n,e,Ne),width:be,height:Se,links:[]}}let oe=new Map,H=0;for(let be of x.keys()){let Se=Ue(be,!1,i,c,180);oe.set(be,Se),H=Math.max(H,Se.width)}let z=e.axisFormat||(e.dateFormat==="D"?"%d":fh(t,"axisFormat")??"%Y-%m-%d"),M=be=>ya(z,new Date(be)),T=Math.max(i.width(M(v),l,0),i.width(M(G),l,0)),R=s+(Pr(t,"leftPadding",0,2e3)??Math.max(H>0?H+24:0,T/2)),_=Pr(t,"rightPadding",0,2e3)??Math.max(16,T/2),$=ms(n,Pr(t,"useWidth",100,2e4)??ZC,280),g=Math.max(JC,$-R-_-s),N=R+g,w=G>v?g/(G-v):0,A=be=>w===0?R+g/2:R+(be-v)*w,D=Math.round(l*1.75),U=Pr(t,"topPadding",0,2e3),B=Pr(t,"gridLineStartPadding",0,2e3),F=s+Z+(y?D:0),W=Math.max(F,U??0),j=U!==void 0&&B!==void 0?Math.max(0,Math.min(U-B,W-F)):0,Q=Math.max(O,1)*d,Y=W+Q,ne=[],q=N+_;for(let be of b){let Se=xE(be.task,i,o),Ne=I.get(be);if(!Rl(be)){let Fe=R+to+Se.width/2;q=Math.max(q,Fe+Se.width/2),ne.push({task:be,label:Se,row:Ne,x0:NaN,x1:NaN,labelX:Fe,inside:!1});continue}let De=A(+be.startTime),ve=Math.max(A(+(be.renderEndTime??be.endTime)),De+(be.milestone?0:2));if(be.milestone){let Fe=De+(A(+be.endTime)-De)/2;De=Fe-u/2,ve=Fe+u/2}let fe=!be.milestone&&Se.width+2*to<=ve-De,_e=(De+ve)/2;if(!fe){let Fe=ve+to+Se.width<=N+_,me=De-to-Se.width>=R;_e=Fe||!me?ve+to+Se.width/2:De-to-Se.width/2,q=Math.max(q,_e+Se.width/2)}ne.push({task:be,label:Se,row:Ne,x0:De,x1:ve,labelX:_e,inside:fe})}let k=e.tickInterval||fh(t,"tickInterval")||"",J=e.weekday??fh(t,"weekday")??"sunday",te=Math.max(2,Math.min(10,Math.floor(g/(T+24)))),se=EE(k,J,v,G,Math.ceil(g/3))??yE(v,G,te),re="",P="",ee="",ae=-1/0,ue="",ce=Y+D/2+2,he=W-j-D/2-2;for(let be of se){let Se=A(be);re+=`M${f(Se)},${f(W-j)}V${f(Y)}`;let Ne=M(be),De=i.width(Ne,l,0);if(Se-De/2<ae+8||Ne===ue)continue;ae=Se+De/2,ue=Ne,q=Math.max(q,ae);let ve=`text-anchor="middle">${nt(Ne)}</text>`;P+=`<text x="${f(Se)}" y="${f(ce+l*.35)}" ${ve}`,y&&(ee+=`<text x="${f(Se)}" y="${f(he+l*.35)}" ${ve}`)}let V="",X="",le=[],de=Y+D+4,Ae=Math.round(o*1.5);for(let be of[...S].sort((Se,Ne)=>+Se.startTime-+Ne.startTime)){let Se=A(+be.startTime),Ne=xE(be.task,i,o),De=Math.max(s+Ne.width/2,Se),ve=0;for(;ve<le.length&&De-Ne.width/2<le[ve]+8;)ve++;le[ve]=De+Ne.width/2,q=Math.max(q,le[ve]),V+=`<path class="pele-vert" data-id="${We(be.id)}" d="M${f(Se)},${f(W-j)}V${f(Y)}"/>`,X+=Ce(Ne,De,de+ve*Ae+Ae/2,` class="pele-vert-label" data-id="${We(be.id)}"`)}let we=Math.ceil(Math.max(q,s+C.width)+s),Ee=Math.ceil(Y+D+(le.length>0?4+le.length*Ae:0)+s),Te="",Me="";for(let be=0;be<O;){let Se=L[be],Ne=be+1;for(;Ne<O&&L[Ne]===Se;)Ne++;let De=x.get(Se)%m,ve=W+be*d,fe=(Ne-be)*d;(x.size>1||Se!=="")&&(Te+=`<rect class="pele-section pele-section-${De}" x="0" y="${f(ve)}" width="${we}" height="${f(fe)}" fill="${De%2===0?"var(--_s)":"none"}"/>`);let _e=oe.get(Se);Me+=Ce(_e,s+8+_e.width/2,ve+fe/2,` class="pele-section-label" data-id="${We(Se)}"`,n.icons),be=Ne}let Ie="";if((e.excludes.length>0||e.includes.length>0)&&+bl(new Date(v),6,"y")>G){let be,Se,Ne=()=>{if(!be||!Se)return;let De=new Date(be);De.setHours(0,0,0,0);let ve=new Date(Se);ve.setHours(23,59,59,999);let fe=Math.max(R,A(+De)),_e=Math.min(N,A(+ve));_e>fe&&(Ie+=`<rect x="${f(fe)}" y="${f(W)}" width="${f(_e-fe)}" height="${f(Q)}"/>`),be=Se=void 0};for(let De=new Date(v);+De<=G;De=vr(De,1))e.isInvalidDate(De)?(be??=De,Se=De):Ne();Ne()}let ge=[],xe="";for(let be of ne){let Se=be.task,Ne=W+be.row*d+d/2,De=Se.active?"active":Se.done?"done":"",ve="pele-task";De&&(ve+=" pele-"+De),Se.crit&&(ve+=" pele-crit"),Se.milestone&&(ve+=" pele-milestone"),Se.classes.includes("clickable")&&(ve+=" pele-clickable");let fe="",_e="";if(Number.isNaN(be.x0))ve+=" pele-unscheduled",_e=' fill="var(--_m)"';else{let $e=Se.crit?Go:"var(--_c)",Pe=De==="done"?'fill="var(--_a)"':De==="active"?`fill="${$e}" fill-opacity="0.25"`:`fill="${$e}"`,ze=`stroke="${De==="done"&&!Se.crit?"var(--_b)":$e}"`;if(Se.milestone){let Le=(be.x0+be.x1)/2,Ve=u/2;fe=`<path d="M${f(Le)},${f(Ne-Ve)}L${f(Le+Ve)},${f(Ne)}L${f(Le)},${f(Ne+Ve)}L${f(Le-Ve)},${f(Ne)}Z" ${Pe} ${ze} stroke-linejoin="round"/>`}else fe=`<rect x="${f(be.x0)}" y="${f(Ne-u/2)}" width="${f(be.x1-be.x0)}" height="${f(u)}" ${Pe} ${ze}${ft}/>`;be.inside?_e=De===""?' fill="var(--_bg)"':"":De==="done"&&(_e=' fill="var(--_m)"')}let Fe=fe+Ce(be.label,be.labelX,Ne,` class="pele-label"${_e}`),me=e.links.get(Se.id);me!==void 0&&(Fe=Qn(Fe,me,Se.id,ge,n)),xe+=`<g class="${ve}" data-id="${We(Se.id)}">${Fe}</g>`}let ie="";if(e.todayMarker!=="off"&&a>=v&&a<=G&&G>v){let be=A(a),Se=W-j,Ne=e.todayMarker?Mt(e.todayMarker.split(",")).line:"";ie=`<g class="pele-today"><path d="M${f(be)},${f(Se)}V${f(Y)}" fill="none" stroke="var(--_c)" stroke-width="2"${Ne}/>`+(Ne?"":`<path d="M${f(be-4)},${f(Se-5)}H${f(be+4)}L${f(be)},${f(Se+1)}Z" fill="var(--_c)"/>`)+"</g>"}let pe=`M${f(R)},${f(Y)}H${f(N)}`+(y?`M${f(R)},${f(W-j)}H${f(N)}`:""),Re=Ce(C,we/2,s+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+(Te?`<g class="pele-sections">${Te}</g>`:"")+(Ie?`<g class="pele-excluded" fill="var(--_a)">${Ie}</g>`:"")+`<g class="pele-grid" fill="none"><path d="${re}" stroke="var(--_b)" stroke-dasharray="1 3"/><path d="${pe}" stroke="var(--_b)"/></g>`+(V?`<g class="pele-verts" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-dasharray="4 3">${V}</g>`:"")+ie+`<g class="pele-tasks" font-size="${f(o)}">${xe}</g><g class="pele-section-labels" font-size="${f(c)}">${Me}</g><g class="pele-axis" font-size="${l}" fill="var(--_m)">${P}${ee}</g>`+(X?`<g class="pele-vert-labels" font-size="${f(o)}">${X}</g>`:"");return{svg:ot("gantt",we,Ee,r,n,e,Re),width:we,height:Ee,links:ge}}var SE={type:"gantt",parse(e,t,n){let r=new yl;n&&(r.title=n);let i=t.gantt?.displayMode;return typeof i=="string"&&(r.displayMode=i),pE(e,r),r},render:AE};var en={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4};function Fn(e){throw new qe(e,"semantic",{type:"gitGraph"})}function wE(e){return e==="REVERSE"?en.REVERSE:e==="HIGHLIGHT"?en.HIGHLIGHT:en.NORMAL}function rN(e,t){e.dir&&t.setDirection(e.dir);for(let n of e.statements)sN(n,t)}function sN(e,t){switch(e.$type){case"Commit":t.commit({id:e.id,msg:e.message??"",type:e.type!==void 0?wE(e.type):en.NORMAL,tags:e.tags??void 0});break;case"Branch":t.branch({name:e.name,order:e.order??0});break;case"Merge":t.merge({branch:e.branch,id:e.id??"",type:e.type!==void 0?wE(e.type):void 0,tags:e.tags??void 0});break;case"Checkout":t.checkout(e.branch);break;case"CherryPicking":t.cherryPick({id:e.id,targetId:"",tags:e.tags?.length===0?void 0:e.tags,parent:e.parent});break}}function _E(e,t,n){let r=t.gitGraph,i=typeof r?.mainBranchName=="string"?r.mainBranchName:"main",s=typeof r?.mainBranchOrder=="number"?r.mainBranchOrder:0,a=new Map,o=new Map([[i,null]]),c=new Map([[i,s]]),l=[],u=null,h=i,d="LR",m=0,p=()=>{for(let S=m+1;;S+=2654435761){let x=`${m}-${(Math.imul(S,2654435761)>>>0).toString(16).padStart(8,"0").slice(0,7)}`;if(!a.has(x))return x}},y=S=>{u=S,a.set(S.id,S),o.set(h,S.id)},E=S=>{o.has(S)||Fn(`Trying to checkout branch which is not yet created. (Help try using "branch ${S}")`),h=S;let x=o.get(S);u=x?a.get(x)??null:null};rN(e,{setDirection(S){d=S},commit({msg:S,id:x,type:I,tags:L}){let O={id:x||p(),message:S,seq:m++,type:I??en.NORMAL,tags:L?[...L]:[],parents:u===null?[]:[u.id],branch:h};a.has(O.id)&&l.push(`Commit ID ${O.id} already exists`),y(O)},branch({name:S,order:x}){o.has(S)&&Fn(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${S}")`),o.set(S,u!==null?u.id:null),c.set(S,x),E(S)},merge({branch:S,id:x,type:I,tags:L}){let O=o.get(h),v=o.get(S),G=O?a.get(O):void 0,K=v?a.get(v):void 0;G&&K&&G.branch===S&&Fn(`Cannot merge branch '${S}' into itself.`),h===S&&Fn('Incorrect usage of "merge". Cannot merge a branch to itself'),G===void 0&&Fn(`Incorrect usage of "merge". Current branch (${h})has no commits`),o.has(S)||Fn(`Incorrect usage of "merge". Branch to be merged (${S}) does not exist`),K===void 0&&Fn(`Incorrect usage of "merge". Branch to be merged (${S}) has no commits`),G===K&&Fn('Incorrect usage of "merge". Both branches have same head'),x&&a.has(x)&&Fn(`Incorrect usage of "merge". Commit with id:${x} already exists, use different custom id`),y({id:x||p(),message:`merged branch ${S} into ${h}`,seq:m++,parents:u===null?[]:[u.id,v||""],branch:h,type:en.MERGE,customType:I,customId:!!x,tags:L?[...L]:[]})},cherryPick({id:S,targetId:x,tags:I,parent:L}){let O=S?a.get(S):void 0;if(O===void 0&&Fn('Incorrect usage of "cherryPick". Source commit id should exist and provided'),L&&!O.parents.includes(L)&&Fn("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."),O.type===en.MERGE&&!L&&Fn("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."),x&&a.has(x))return;O.branch===h&&Fn('Incorrect usage of "cherryPick". Source commit is already on current branch');let v=o.get(h);(!v||!a.has(v))&&Fn(`Incorrect usage of "cherry-pick". Current branch (${h})has no commits`),y({id:p(),message:`cherry-picked ${O.message} into ${h}`,seq:m++,parents:u===null?[]:[u.id,O.id],branch:h,type:en.CHERRY_PICK,tags:I?I.filter(Boolean):[`cherry-pick:${O.id}${O.type===en.MERGE?`|parent:${L}`:""}`]})},checkout:E});let b=[...c].map(([S,x],I)=>({name:S,order:x??parseFloat(`0.${I}`)})).sort((S,x)=>S.order-x.order).map(S=>S.name);return{type:"gitGraph",title:e.title||n,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
91
+ `):void 0,direction:d,commits:a,branches:o,lanes:b,currentBranch:h,head:u,warnings:l}}var TE={name:"REFERENCE",pattern:/\w([-\./\w]*[-\w])?/y},ME=[TE];function er(e){return{name:e,pattern:e,longer:ME}}var RE=[er("cherry-pick"),{name:"gitGraph:",pattern:"gitGraph:"},er("HIGHLIGHT"),{...Zt("gitGraph"),longer:ME},er("checkout"),er("REVERSE"),{name:"parent:",pattern:"parent:"},er("commit"),er("NORMAL"),er("branch"),{name:"order:",pattern:"order:"},er("switch"),{name:"type:",pattern:"type:"},er("merge"),{name:"msg:",pattern:"msg:"},{name:"tag:",pattern:"tag:"},{name:"id:",pattern:"id:"},er("LR"),er("TB"),er("BT"),{name:":",pattern:":"},{...rn,opener:/[\t ]*accDescr\s*{/y},jt,Jn(String.raw`[-./\w]*[-\w]`),{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Pn,An,Sn,Yt,qt,Qt,TE];function CE(e){let t=new Wt(Gt(e,RE,"gitGraph"),RE,"gitGraph"),n={$type:"GitGraph",statements:[]},r=()=>{if(t.kind!==-1)for(t.kind!==26&&t.fail("a line break or the end of input");t.kind===26;)t.i++},i=()=>t.kind===31?t.take():t.kind===25?dn(t.take()):t.fail("a branch name"),s=()=>dn(t.expect(25)),a=()=>(t.kind!==8&&t.kind!==5&&t.kind!==2&&t.fail("NORMAL, REVERSE, or HIGHLIGHT"),t.take());for(;t.kind===26;)t.i++;if(!t.accept(1)){t.expect(3);let o=t.kinds[t.i+1];(t.kind===17||t.kind===18||t.kind===19)&&o===20?(n.$type="Direction",n.dir=t.take(),t.i++):t.accept(20)}for(;t.kind!==-1;)switch(t.kind){case 26:t.i++;break;case 21:n.accDescr=zt(t.take()),r();break;case 22:n.accTitle=Kt(t.take()),r();break;case 23:n.title=Ht(t.take()),r();break;case 7:{t.i++;let o={$type:"Commit",tags:[]};for(;;)if(t.accept(16))o.id=s();else if(t.accept(15))o.tags.push(s());else if(t.accept(12))o.type=a();else if(t.accept(14)||t.kinds[t.i]===25)o.message=s();else break;r(),n.statements.push(o);break}case 9:{t.i++;let o={$type:"Branch",name:i()};t.accept(10)&&(o.order=parseInt(t.expect(24))),r(),n.statements.push(o);break}case 13:{t.i++;let o={$type:"Merge",branch:i(),tags:[]};for(;;)if(t.accept(16))o.id=s();else if(t.accept(15))o.tags.push(s());else if(t.accept(12))o.type=a();else break;r(),n.statements.push(o);break}case 4:case 11:{t.i++;let o={$type:"Checkout",branch:i()};r(),n.statements.push(o);break}case 0:{t.i++;let o={$type:"CherryPicking",tags:[]};for(;;)if(t.accept(16))o.id=s();else if(t.accept(15))o.tags.push(s());else if(t.accept(6))o.parent=s();else break;r(),n.statements.push(o);break}default:t.fail("a statement, a title, or a line break")}return n}var iN=/<(?!br\s*\/?>)/gi,oN=/:fa-/g,aN=/<br\s*\/?>|fl°°?\w+¶ß|&#?\w+;|[\ud800-\udbff][\udc00-\udfff]|[\s\S]/gi;function gr(e,t,n,r,i=0){let s=e;return s!==void 0&&(s.includes("<")&&(s=s.replace(iN,"&lt;")),s.includes(":fa-")&&(s=s.replace(oN,"&colon;fa-"))),Ue(s,!1,t,n,r,i)}function Bn(e,t,n,r,i=0){let s=gr(e,t,n,r,i);if(e===void 0||s.width<=r)return s;let a="",o=0;for(let c of e.match(aN)??[]){if(c.trim()===""||c.length>2&&c[0]==="<")o=0;else{let l=t.width(c.length>2?"x":c,n,i);o>0&&o+l>r&&(a+=`
92
+ `,o=0),o+=l}a+=c}return gr(a,t,n,r,i)}var tn=7,cN=44,lN=44,Tl=36,Ml=8,oi=20,xa=20,Aa=7,NE=6,hh=Math.SQRT1_2,IE=["normal","reverse","highlight","merge","cherry-pick"];function Cl(e,t,n){let r=e.gitGraph?.[t];return typeof r=="boolean"?r:n}function kE(e){return Aa+4+e.width+6}function dN(e,t,n,r){let i=`cx="${f(t)}" cy="${f(n)}"`;if(e===en.HIGHLIGHT)return`<rect x="${f(t-tn-1)}" y="${f(n-tn-1)}" width="${2*tn+2}" height="${2*tn+2}" rx="2" fill="${r}"/>`;if(e===en.MERGE)return`<circle ${i} r="${tn-1}" fill="var(--_bg)" stroke="${r}" stroke-width="2"/><circle ${i} r="2.5" fill="${r}"/>`;let s=`<circle ${i} r="${tn}" fill="${r}"/>`;return e===en.REVERSE?s+`<path d="M${f(t-3)},${f(n-3)}l6,6M${f(t-3)},${f(n+3)}l6,-6" fill="none" stroke="var(--_bg)" stroke-width="1.5" stroke-linecap="round"/>`:e===en.CHERRY_PICK?s+`<path d="M${f(t-2.6)},${f(n+1)}L${f(t+.8)},${f(n-4.2)}L${f(t+2.6)},${f(n+1)}" fill="none" stroke="var(--_bg)" stroke-linejoin="round"/><circle cx="${f(t-2.6)}" cy="${f(n+2.2)}" r="1.8" fill="var(--_bg)"/><circle cx="${f(t+2.6)}" cy="${f(n+2.2)}" r="1.8" fill="var(--_bg)"/>`:s}function LE(e,t,n){return e.direction!=="LR"?$E(e,t,n,e.direction):vt(n,r=>$E(e,t,n,r?"TB":"LR"))}function $E(e,t,n,r){let i=n.fontSize??16,s=Math.round(i*.75),a=n.measurer??at(n.fontFamily,n.fontFamilyMono),o=n.padding??8,c=Cl(t,"showBranches",!0),l=Cl(t,"showCommitLabel",!0),u=Cl(t,"rotateCommitLabel",!0),h=Cl(t,"parallelCommits",!1),d=r!=="LR",m=r==="BT",p=new Map;e.lanes.forEach((k,J)=>p.set(k,J));let y=e.lanes.length,E=Math.round(i*.875),b=e.lanes.map(k=>gr(c?k:"",a,E,4e3)),S=[],x=new Map;for(let k of[...e.commits.values()].sort((J,te)=>J.seq-te.seq)){let J=l&&k.type!==en.CHERRY_PICK&&(k.type!==en.MERGE||k.customId===!0),te=[];for(let re of k.tags){let P=gr(re,a,s,4e3);P.lines.length>0&&te.push(P)}let se={commit:k,index:S.length,lane:p.get(k.branch)??0,m:0,label:J?gr(k.id,a,s,4e3):void 0,tags:te};S.push(se),x.set(k.id,se)}let I=new Float64Array(S.length),L=new Float64Array(S.length),O=new Float64Array(y).fill(tn),v=new Float64Array(y).fill(tn);S.forEach((k,J)=>{let{label:te,tags:se}=k,re=0,P=0;for(let V of se){let X=kE(V);d?(re=Math.max(re,V.height),P+=X+4):(re=Math.max(re,X),P+=V.height+3)}let ee=0,ae=0;te!==void 0&&te.lines.length>0&&(u?ae=3+hh*(te.width+te.height):(ee=d?te.height:te.width,ae=6+(d?te.width:te.height))),I[J]=Math.max(tn,re/2,ee/2),L[J]=re/2;let ue=tn+(se.length>0?NE+P:0),ce=tn+ae,he=k.lane;O[he]=Math.max(O[he],d?ce:ue),v[he]=Math.max(v[he],d?ue:ce)});let G=new Float64Array(S.length);d||S.forEach((k,J)=>{if(L[J]!==0)for(let te of k.commit.parents){let se=x.get(te);se!==void 0&&se.lane<k.lane&&(G[J]=L[J]+4)}});let K=(k,J)=>Math.max(cN,I[k]+I[J]+Ml,G[J]>0?I[k]+Tl+G[J]:0);S.forEach((k,J)=>{if(!h){k.m=J===0?0:S[J-1].m+K(J-1,J);return}let te=0;for(let se of k.commit.parents){let re=x.get(se);re===void 0||re.index>=J||(te=Math.max(te,re.m+K(re.index,J)))}k.m=te});let C=0;for(let k of S)C=Math.max(C,k.m);let Z=new Float64Array(y);for(let k=0;k<y;k++){let J=b[k],te=J.lines.length===0?0:d?J.width/2+8:J.height/2+2;O[k]=Math.max(O[k],te),v[k]=Math.max(v[k],te),k>0&&(Z[k]=Z[k-1]+Math.max(lN,v[k-1]+O[k]+Ml))}let oe=(k,J)=>d?J:k,H=(k,J)=>d?m?-k:k:J,z=(k,J)=>`${f(oe(k,J))},${f(H(k,J))}`,M=1/0,T=1/0,R=-1/0,_=-1/0,$=(k,J,te,se)=>{k<M&&(M=k),J<T&&(T=J),te>R&&(R=te),se>_&&(_=se)},g="";if(c)for(let k=0;k<y;k++){let J=b[k],te=yt(k),se=Z[k],re=J.width+16,P=J.height+4,ee=J.lines.length===0?-oi:-oi-(d?P:re),ae=oe(ee+(d?P:re)/2,se),ue=H(ee+(d?P:re)/2,se);$(oe(-oi,se),H(-oi,se),oe(-oi,se),H(-oi,se)),$(oe(C+xa,se),H(C+xa,se),oe(C+xa,se),H(C+xa,se)),g+=`<g class="pele-branch" data-id="${We(e.lanes[k])}"><path class="pele-lane" d="M${z(-oi,se)}L${z(C+xa,se)}" stroke="${te}" stroke-dasharray="2 4"/>`,J.lines.length>0&&($(ae-re/2,ue-P/2,ae+re/2,ue+P/2),g+=`<rect x="${f(ae-re/2)}" y="${f(ue-P/2)}" width="${f(re)}" height="${f(P)}" fill="${te}"${ft}/>`+Ce(J,ae,ue,' class="pele-label"'+(us(k)||' fill="var(--_bg)"'))),g+="</g>"}let N=Array.from({length:y},()=>[]);for(let k of S)N[k.lane].push(k.m);if(h)for(let k of N)k.sort((J,te)=>J-te);let w=(k,J,te)=>{let se=N[k],re=0,P=se.length;for(;re<P;){let ee=re+P>>1;se[ee]<=J?re=ee+1:P=ee}return re<se.length&&se[re]<te},A="",D="";for(let k of S){let{commit:J}=k,te=Z[k.lane],se=k.m;for(let re=0;re<J.parents.length;re++){let P=x.get(J.parents[re]);if(P===void 0||P===k)continue;let ee=Z[P.lane],ae=P.m;if(P.lane===k.lane){D+=`<path class="pele-edge" d="M${z(ae,ee)}L${z(se,te)}" stroke="${yt(k.lane)}"/>`;continue}let ue=re>0&&J.type===en.MERGE,ce=re>0&&!ue,he=`M${z(ae,ee)}`;if(se<=ae){let V=(ae+se)/2;he+=`C${z(V,ee)} ${z(V,te)} ${z(se,te)}`}else if(!ue&&!w(k.lane,ae,se)){let V=Math.min(Tl,se-ae);he+=`C${z(ae+V/2,ee)} ${z(ae+V/2,te)} ${z(ae+V,te)}L${z(se,te)}`}else{let V=P.lane<k.lane&&se-G[k.index]>ae?se-G[k.index]:se,X=Math.min(Tl,V-ae),le=ee;(!ue||w(P.lane,ae,se))&&(le=ee>te?te+v[k.lane]+Ml/2:te-O[k.lane]-Ml/2,X=Math.min(Tl,(V-ae)/2),he+=`C${z(ae+X/2,ee)} ${z(ae+X/2,le)} ${z(ae+X,le)}`),he+=`L${z(V-X,le)}C${z(V-X/2,le)} ${z(V-X/2,te)} ${z(V,te)}`,V<se&&(he+=`L${z(se,te)}`)}A+=`<path class="pele-edge${ue?" pele-edge-merge":ce?" pele-edge-cherry-pick":""}" d="${he}" stroke="${yt(ue?P.lane:k.lane)}"${ce?' stroke-dasharray="4 3"':""}/>`}}let U="";for(let k of S){let{commit:J,label:te,tags:se}=k,re=oe(k.m,Z[k.lane]),P=H(k.m,Z[k.lane]),ee=J.customType??J.type;$(re-tn-1,P-tn-1,re+tn+1,P+tn+1);let ue=J.type<en.MERGE&&J.message!==""?`<title>${We(J.message)}</title>`:"";if(ue+=dN(ee,re,P,yt(k.lane)),te!==void 0&&te.lines.length>0){let V=te.width,X=te.height,le=(de,Ae)=>`<rect x="${f(de-V/2-2)}" y="${f(Ae-X/2+2)}" width="${f(V+4)}" height="${f(X-4)}" rx="3" fill="var(--_bg)"/>`;if(u){let de=hh*X/2,Ae=d?re-tn-3-de:re+3,we=d?P:P+tn+3+de,Ee=hh*V+de;$(Ae-Ee,m?we-Ee:we-de,Ae+de,m?we+de:we+Ee),ue+=`<g class="pele-commit-label" transform="rotate(${m?45:-45} ${f(Ae)} ${f(we)})">`+le(Ae-V/2,we)+Ce(te,Ae-V/2,we,"")+"</g>"}else{let de=d?re-tn-6-V/2:re,Ae=d?P:P+tn+6+X/2;$(de-V/2,Ae-X/2,de+V/2,Ae+X/2),ue+=`<g class="pele-commit-label">${le(de,Ae)}${Ce(te,de,Ae,"")}</g>`}}let ce=tn+NE;for(let V=d?0:se.length-1;V>=0&&V<se.length;V+=d?1:-1){let X=se[V],le=kE(X),de=X.height,Ae=d?re+ce:re-le/2,we=d?P:P-ce-de/2;ce+=d?le+4:de+3,$(Ae,we-de/2,Ae+le,we+de/2),ue+=`<g class="pele-tag"><path d="M${f(Ae)},${f(we)}L${f(Ae+Aa)},${f(we-de/2)}H${f(Ae+le)}V${f(we+de/2)}H${f(Ae+Aa)}Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/><circle cx="${f(Ae+Aa)}" cy="${f(we)}" r="1.5" fill="var(--_b)"/>`+Ce(X,Ae+Aa+4+X.width/2,we,' fill="var(--_fg)"')+"</g>"}let he=J.type===en.MERGE&&ee!==en.MERGE?" pele-commit-merge":"";U+=`<g class="pele-commit pele-commit-${IE[ee]??IE[0]}${he}" data-id="${We(J.id)}">${ue}</g>`}M>R&&$(0,0,0,0);let B=Ue(e.title,!1,a,i,4e3,1),F=B.height>0?B.height+16:0,W=Math.max(R-M,B.width),j=Math.ceil(W+2*o),Q=Math.ceil(_-T+F+2*o),Y=o-M+(W-(R-M))/2,ne=o+F-T,q=Ce(B,j/2,o+B.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f(Y)},${f(ne)})">`+(g?`<g class="pele-branches" fill="none" font-size="${E}">${g}</g>`:"")+(A||D?`<g class="pele-edges" fill="none" stroke-width="2" stroke-linecap="round">${A}${D}</g>`:"")+(U?`<g class="pele-commits" font-size="${s}" fill="var(--_m)">${U}</g>`:"")+"</g>";return{svg:ot("gitGraph",j,Q,i,n,e,q),width:j,height:Q,links:[]}}var OE={type:"gitGraph",parse:(e,t,n)=>_E(CE(e),t,n),render:LE};function DE(e,t){return{type:"info",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
93
+ `):void 0}}var vE=[Zt("showInfo"),Zt("info"),rn,jt,hr,An,Sn,Yt,qt,Qt];function PE(e){let t=new Wt(Gt(e,vE,"info"),vE,"info"),n={$type:"Info"};for(;t.kind===5;)t.i++;for(t.expect(1);t.kind===5;)t.i++;if(t.accept(0))for(;t.kind===5;)t.i++;for(;t.kind!==-1;){let r=t.kind;if(r===2?n.accDescr=zt(t.take()):r===3?n.accTitle=Kt(t.take()):r===4?n.title=Ht(t.take()):t.fail("a title or the end of input"),t.kind===-1)break;for(t.kind!==5&&t.fail("a line break or the end of input");t.kind===5;)t.i++}return n}var FE="1.13.0";function BE(e,t,n){let r=n.fontSize??16,i=n.measurer??at(n.fontFamily,n.fontFamilyMono),s=n.padding??8,a=Ue(e.title,!1,i,r,4e3,1),o=a.height>0?a.height+8:0,c=Ue(`Pele v${FE}`,!1,i,r,4e3),l=Math.ceil(Math.max(a.width,c.width)+2*s),u=Math.ceil(o+c.height+2*s),h=Ce(a,l/2,s+a.height/2,' class="pele-title" font-weight="var(--_tw)"')+Ce(c,l/2,s+o+c.height/2,' class="pele-version" fill="var(--_m)"');return{svg:ot("info",l,u,r,n,e,h),width:l,height:u,links:[]}}var WE={type:"info",parse:(e,t,n)=>DE(PE(e),n),render:BE};var Nl=class{type="ishikawa";title;root;stack=[];baseLevel;addNode(t,n){let r={text:n,children:[]};if(!this.root){this.root=r,this.stack=[{level:0,node:r}];return}this.baseLevel??=t;let i=Math.max(t-this.baseLevel+1,1),s=this.stack;for(;s.length>1&&s[s.length-1].level>=i;)s.pop();s[s.length-1].node.children.push(r),s.push({level:i,node:r})}};var UE=["$end","EOF","SPACELINE","NL","ISHIKAWA","SPACELIST","TEXT"];function fN(e,t){let n="ishikawa-beta",r=0;for(;r<13;){let i=e.charCodeAt(t+r),s=n.charCodeAt(r);if(i!==s&&(i+32!==s||i<65||i>90))break;r++}return r===13&&!it(e.charCodeAt(t+13))?13:r>=8&&!it(e.charCodeAt(t+8))?8:0}function GE(e){let t=[],n=[],r=[],i=e.length,s=0;for(;s<i;){let a=s,o=-1;for(;a<i&&Xe(e.charCodeAt(a));)e.charCodeAt(a)===10&&(o=a),a++;let c,l;if(e.charCodeAt(a)===37&&e.charCodeAt(a+1)===37)for(c=2,l=a+2;l<i;){let u=e.charCodeAt(l);if(u===10||u===13||u===8232||u===8233)break;l++}else if(a===s){let u=fN(e,s);u>0?(c=4,l=s+u):(c=6,l=e.indexOf(`
94
+ `,s),l===-1&&(l=i))}else o>s?(c=2,l=o+1):o===s?(c=3,l=s+1):(c=5,l=a);t.push(c),n.push(s),r.push(l),s=l}return t.push(1,0),n.push(i,i),r.push(i,i),{types:t,starts:n,ends:r}}var ph="'SPACELINE', 'NL', 'EOF'";function YE(e,t){let{types:n,starts:r,ends:i}=GE(e),s=0,a=o=>{throw ut("ishikawa",e,r[s],`Expecting ${o}, got '${UE[n[s]]}'`)};if(n[s]===2){for(s++;n[s]===2||n[s]===3;)s++;n[s]!==4&&a("'SPACELINE', 'NL', 'ISHIKAWA'")}else n[s]!==4&&a("'SPACELINE', 'ISHIKAWA'");for(s++,n[s]===3&&s++;;){let o=n[s];if(o===6||o===5&&n[s+1]===6){let c=o===6?s:s+1;s=c+1,n[s]!==2&&n[s]!==3&&n[s]!==1&&a(ph),t.addNode(o===6?0:i[c-1]-r[c-1],e.slice(r[c],i[c]).trim())}else o===2||o===5?(s++,n[s]!==2&&n[s]!==3&&n[s]!==1&&a(o===5?`${ph}, 'TEXT'`:ph)):a("'SPACELINE', 'SPACELIST', 'TEXT'");for(s++;n[s]===3||n[s]===1;)s++;if(n[s]===0)return}}var kl=.5,Il=Math.hypot(kl,1),hN=14,pN=6,mN=8,HE=22,gN=18,mh=5,bN=26,KE=34,yN=28,EN=10,xN=5;function AN(e,t,n,r,i){let s=Ue(e.text,!1,n,r,180),a=Math.round(i*1.5),o=[],c=[],l=[],u=(p,y,E)=>{let b=p.length;for(let S=b-1;S>=0;S--)l.push({node:p[t?b-1-S:S],depth:y,parent:E,slot:S,bone:-1})};for(u(e.children,2,-1);l.length>0;){let p=l.pop();if(p.bone!==-1){c.push(p.bone);continue}let y=o.length;o.push({label:Ue(p.node.text,!1,n,i,200),depth:p.depth,parent:p.parent,slot:p.slot,kids:p.node.children.length,rise:0,at:0,textEnd:0}),p.depth%2===0?c.push(y):(p.bone=y,l.push(p)),u(p.node.children,p.depth+1,y)}let h=hN;for(let p of c){let y=Math.max(o[p].label.height,a)+pN;o[p].rise=h+y/2,h+=y}let d=s.width+2*EN,m=d/2;for(let p of o){let y=p.parent===-1?void 0:o[p.parent];p.depth%2===0?(p.at=y?y.at:0,p.textEnd=p.at-(p.kids>0?(p.kids+1)*HE:gN)-mh):(p.at=y.at-(y.kids-p.slot)*HE,p.textEnd=p.at-mh),m=Math.max(m,p.label.width-p.textEnd)}return{node:e,label:s,boxW:d,boxH:s.height+2*xN,bones:o,rise:h+mN,reach:m}}function zE(e,t,n){return vt(n,r=>SN(e,t,n,r))}function SN(e,t,n,r){let i=n.fontSize??16,s=Math.round(i*.875),a=n.measurer??at(n.fontFamily,n.fontFamilyMono),o=n.padding??8;if(r)return wN(e,n);let c=e.root,l=Ue(e.title,!1,a,i,4e3,1),u=l.height>0?l.height+12:0,h="",d=0,m=0,p=0,y=0;if(c){let O=Ue(c.text,!1,a,i,200,1),v=Math.max(O.height+24,48),G=O.width+24+v/2,K=c.children.map((M,T)=>AN(M,T%2===0,a,i,s));for(let M of K)M.rise=Math.max(M.rise,v/2+14);let C=[],Z=-KE;for(let M=0;M<K.length;M+=2){if(M>0){let T=0;for(let R=0;R<2;R++){let _=K[M-2+R],$=K[M+R];_&&(T=Math.max(T,_.reach+($?$.boxW/2:0)))}Z-=T+bN}C.push(Z,Z)}let oe=K.length>0?Z-yN:-KE;m=G,d=oe,p=-v/2,y=v/2;let H="";K.forEach((M,T)=>{let R=T%2===0?-1:1,_=C[T],$=(B,F)=>_+B-F*kl,g=$(0,M.rise),N=R*M.rise,w=$t-1,A=`M${f(_-kl/Il*w)},${f(R*w/Il)}L${f(g)},${f(N)}`,D="";for(let B of M.bones){let F=R*B.rise;if(B.depth%2===0)A+=`M${f($(B.at,B.rise))},${f(F)}H${f($(B.textEnd+mh,B.rise))}`;else{let j=M.bones[B.parent].rise;A+=`M${f($(B.at,j))},${f(R*j)}L${f($(B.at,B.rise))},${f(F)}`}let W=$(B.textEnd,B.rise);D+=Ce(B.label,W-B.label.width/2,F,B.depth>2?' fill="var(--_m)"':""),d=Math.min(d,W-B.label.width)}let U=N+R*(M.boxH/2);d=Math.min(d,g-M.boxW/2),m=Math.max(m,g+M.boxW/2),p=Math.min(p,U-M.boxH/2),y=Math.max(y,U+M.boxH/2),H+=`<g class="pele-ishikawa-category" data-id="${We(M.node.text)}"><path class="pele-ishikawa-bones" d="${A}" fill="none" stroke="var(--_l)"/>`+wt("arrow_point",_,0,kl/Il,-R/Il,"var(--_l)")+`<rect x="${f(g-M.boxW/2)}" y="${f(U-M.boxH/2)}" width="${f(M.boxW)}" height="${f(M.boxH)}" fill="var(--_s)" stroke="var(--_b)"${ft}/>`+Ce(M.label,g,U,' class="pele-label"')+(D?`<g class="pele-ishikawa-causes" font-size="${s}">${D}</g>`:"")+"</g>"});let z=v/2;h=`<path class="pele-ishikawa-spine" d="M${f(oe)},0H${f(-($t-1))}" fill="none" stroke="var(--_l)"/>`+wt("arrow_point",0,0,1,0,"var(--_l)")+H+`<g class="pele-ishikawa-head" data-id="${We(c.text)}"><path d="M0,${f(-z)}H${f(G-z)}A${f(z)},${f(z)} 0 0 1 ${f(G-z)},${f(z)}H0Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/>`+Ce(O,12+O.width/2,0,' class="pele-label" font-weight="var(--_hw)"')+"</g>"}let E=Math.max(m-d,l.width),b=Math.ceil(E+2*o),S=Math.ceil(y-p+u+2*o),x=o+(E-(m-d))/2-d,I=o+u-p;return{svg:ot("ishikawa",b,S,i,n,{},Ce(l,b/2,o+l.height/2,' class="pele-title" font-weight="var(--_tw)"')+(h?`<g transform="translate(${f(x)},${f(I)})">${h}</g>`:"")),width:b,height:S,links:[]}}function wN(e,t){let n=t.fontSize??16,r=Math.round(n*.875),i=t.measurer??at(t.fontFamily,t.fontFamilyMono),s=t.padding??8,a=Math.max(140,(t.maxWidth??320)-2*s),o=Ue(e.title,!1,i,n,It(t),1),c=[],l=e.root?[{node:e.root,depth:0,parent:-1}]:[],u=0;for(;l.length;){let x=l.pop(),I=c.length;c.push({...x,x:0,y:0,w:0,h:0}),u=Math.max(u,x.depth);for(let L=x.node.children.length-1;L>=0;L--)l.push({node:x.node.children[L],depth:x.depth+1,parent:I})}let h=Math.min(20,Math.max(2,(a-120)/Math.max(1,u))),d=s+(o.height?o.height+12:0),m=o.width,p="",y="";for(let x of c){x.x=s+x.depth*h;let I=Math.max(60,a-x.depth*h-20);x.label=Qs(Ue(x.node.text,!1,i,x.depth<2?n:r,I,x.depth<2?1:0),i,I),x.w=x.label.width+20,x.h=x.label.height+12,x.y=d,d+=x.h+12,m=Math.max(m,x.x-s+x.w);let L=x.depth<2;if(p+=`<g class="pele-node ${x.depth===0?"pele-ishikawa-head":x.depth===1?"pele-ishikawa-category":"pele-ishikawa-cause"}" data-id="${We(x.node.text)}">`+(L?`<rect x="${f(x.x)}" y="${f(x.y)}" width="${f(x.w)}" height="${f(x.h)}" rx="${x.depth===0?12:4}" fill="var(--_s)" stroke="var(--_b)"/>`:"")+Ce(x.label,x.x+x.w/2,x.y+x.h/2,` class="pele-label"${x.depth<2?' font-weight="var(--_hw)"':""}${x.depth>1?` font-size="${r}"`:""}`)+"</g>",x.parent>=0){let O=c[x.parent],v=O.x+h/2;y+=`<path class="pele-edge" d="M${f(v)},${f(O.y+O.h)}V${f(x.y+x.h/2)}H${f(x.x)}" fill="none" stroke="var(--_b)"/>`}}let E=Math.ceil(m+2*s),b=Math.ceil(Math.max(s+o.height,d-12)+s),S=Ce(o,E/2,s+o.height/2,' class="pele-title" font-weight="var(--_tw)"')+y+p;return{svg:ot("ishikawa",E,b,n,t,{},S),width:E,height:b,links:[]}}var VE={type:"ishikawa",parse(e,t,n){let r=new Nl;return r.title=n,YE(e,r),r},render:zE};function Ll(e){let t=new Set;for(let n of e)for(let r of n.people)t.add(r);return[...t].sort()}var $l=class{type="journey";title;accTitle;accDescr;sections=[];tasks=[];currentSection="";setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
95
+ `)}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,n){let r=n.substring(1).split(":"),i=r.length===1?[]:r[1].split(",").map(s=>s.trim());this.tasks.push({task:t,score:Number(r[0]),people:i,section:this.currentSection})}getActors(){return Ll(this.tasks)}};function Sa(e,t){let n=e.indexOf(`
96
+ `,t);return n===-1?e.length:n}function tr(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function Ol(e,t){let n=e.length,r=t;for(;r<n;){let i=e.charCodeAt(r);if(i===37&&e.charCodeAt(r+1)!==123)r=Sa(e,r);else{if(i===10)return r;if(Xe(i))do r++;while(r<n&&Xe(e.charCodeAt(r)));else if(i===35)r=Sa(e,r);else return r}}return r}function gh(e,t){let n=t;for(;Xe(e.charCodeAt(n));)n++;return n}function Dl(e,t,n,r){let i=tr(e,t,"accdescr");if(!i&&!tr(e,t,"acctitle"))return t;let s=e.length,a=gh(e,t+8),o=e.charCodeAt(a),c=(l,u,h)=>{n.types.push(l),n.texts.push(e.slice(u,h)),n.starts.push(u)};if(o===58){a=gh(e,a+1);let l=Sa(e,a);return c(i?r+2:r,t,a),c(i?r+3:r+1,a,l),l}if(!i||o!==123)return t;for(a=gh(e,a+1);e.charCodeAt(a)!==125;){let l=e.indexOf("}",a);if(l===-1&&(l=s),c(r+4,a,l),a===s)return s;a=l}return a+1}var jE=["$end","EOF","INVALID","NEWLINE","journey","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","taskName","taskData",":"];function vl(e,t,n){let r=e.length,i=t;for(;i<r;i++){let s=e.charCodeAt(i);if(s===35||s===10||s===59||n&&s===58)break}return i}function XE(e){let t=e.length,n=[],r=[],i=[],s={types:n,texts:r,starts:i},a=0,o=(c,l)=>{n.push(c),r.push(e.slice(a,l)),i.push(a),a=l};for(;a=Ol(e,a),!(a>=t);){let c=e.charCodeAt(a),l=a+1;if(c===10){for(;e.charCodeAt(l)===10;)l++;o(3,l);continue}if(tr(e,a,"journey")&&!it(e.charCodeAt(a+7))){o(4,a+7);continue}if(tr(e,a,"title")){for(l=a+5;e.charCodeAt(l)!==10&&Xe(e.charCodeAt(l));)l++;if(l===t||e.charCodeAt(l)===10){a=l;continue}let u=e.charCodeAt(a+5);if(u!==13&&Xe(u)&&(l=vl(e,a+6,!1),l>a+6)){o(5,l);continue}}if(l=Dl(e,a,s,6),l!==a){a=l;continue}if(tr(e,a,"section")&&Xe(e.charCodeAt(a+7))&&(l=vl(e,a+8,!0),l>a+8)){o(11,l);continue}c===58?(l=vl(e,a+1,!1),o(l>a+1?13:14,l>a+1?l:a+1)):c===59?o(2,a+1):o(12,vl(e,a+1,!0))}return(i.length===0||i[i.length-1]<t)&&o(1,t),o(0,t),s}var _N="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'";function qE(e,t){let{types:n,texts:r,starts:i}=XE(e),s=(a,o)=>{let c=n[a]===0?"1":jE[n[a]];throw ut("journey",e,i[a],`Expecting ${o}, got '${c}'`)};n[0]!==4&&s(0,"'journey'");for(let a=1;;a++){let o=r[a];switch(n[a]){case 3:break;case 5:t.setDiagramTitle(o.substring(6));break;case 6:t.setAccTitle(r[++a].trim());break;case 8:t.setAccDescription(r[++a].trim());break;case 10:t.setAccDescription(o.trim());break;case 11:t.addSection(o.substring(8));break;case 12:n[++a]!==13&&s(a,"'taskData'"),t.addTask(o,r[a]);break;case 1:return;default:s(a,_N)}}}var Fl=10,Ss=8,RN=124,TN=200,Pl=12,QE=6,bh=24,yh=26,no=11,Fr=5,MN=13,CN=20,NN='<circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/>',IN={happy:"M-5,2A6,6 0 0 0 5,2",neutral:"M-4.5,4.5H4.5",sad:"M-5,6.5A6,6 0 0 1 5,6.5"};function ZE(e,t,n){return`<g class="pele-face pele-face-${n}" transform="translate(${f(e)},${f(t)})"><circle r="${no}" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)">${NN}</g><path d="${IN[n]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}function JE(e,t,n){return vt(n,r=>kN(e,t,n,r))}function kN(e,t,n,r){let i=n.fontSize??16,s=Math.round(i*.875),a=Math.round(i*.75),o=n.measurer??at(n.fontFamily,n.fontFamilyMono),c=n.padding??8;if(r)return $N(e,n);let l=e.tasks,u=l.length,h=Ll(l).filter(j=>j!==""),d=new Map;h.forEach((j,Q)=>d.set(j,Q));let m=RN,p=l.map(j=>gr(j.task,o,s,m)),y=0;for(let j of p)y=Math.max(y,j.width);y>m&&(m=Math.min(Math.ceil(y),TN),p=l.map(j=>Bn(j.task,o,s,m)));let E=m+2*Fl,b=E+Pl,S=u>0?u*b-Pl:0,x=Math.round(s*1.5),I=Math.max(S,240),L=[],O=0,v=0,G=0;for(let j of h){let Q=Bn(j,o,s,I-2*Fr-6),Y=2*Fr+6+Q.width;G>0&&G+Y>I&&(G=0,v+=4);let ne=G>0?L[L.length-1].y:v,q=Math.max(Q.height,x);L.push({name:j,label:Q,x:G,y:ne,h:q}),G+=Y,O=Math.max(O,G),v=Math.max(v,ne+q),G+=CN}let K=u>0?bh+S:0,C=Bn(e.title,o,i,Math.max(K,320),1),Z=C.height>0?C.height+16:0,oe=Math.max(K,C.width,u>0?bh+O:0),H=c+(oe-K)/2+bh,z=c+Z,M=[],T=0;for(let j=0;j<u;){let Q=j+1;for(;Q<u&&l[Q].section===l[j].section;)Q++;let Y;l[j].section!==""&&(Y=Bn(l[j].section,o,s,(Q-j)*b-Pl-2*Fl,1),T=Math.max(T,Math.max(Y.height,x)+2*QE)),M.push({start:j,count:Q-j,label:Y}),j=Q}let R=x;for(let j of p)R=Math.max(R,j.height);let _=h.length>0?2*Fr+6:0,$=R+_+2*Ss,g=z+(T>0?T+QE:0),N=g+$+no+16,w=N+4*yh,A=H+S,D="",U=z;if(u>0){let j="",Q="";for(let J=5;J>=1;J--){let te=N+(5-J)*yh;j+=`M${f(H-6)},${f(te)}H${f(A)}`,Q+=`<text x="${f(H-12)}" y="${f(te+a*.35)}">${J}</text>`}D+=`<path class="pele-grid" d="${j}" fill="none" stroke="var(--_a)"/><g class="pele-scale" font-size="${a}" text-anchor="end" fill="var(--_m)">${Q}</g>`;let Y="",ne="",q="",k=[];l.forEach((J,te)=>{let se=H+te*b,re=se+E/2,P=J.score,ee=Number.isNaN(P)?3:Math.min(5,Math.max(1,P)),ae=N+(5-ee)*yh;Y+=`${te===0?"M":"L"}${f(re)},${f(ae)}`,ne+=`M${f(re)},${f(g+$)}V${f(ae-no)}`,q+=ZE(re,ae,P>3?"happy":P<3?"sad":"neutral");let ue="",ce=J.people.filter(V=>V!==""),he=Math.min(MN,(E-2*Fl-2*Fr)/Math.max(ce.length-1,1));ce.forEach((V,X)=>{ue+=`<circle class="pele-actor" cx="${f(re+(X-(ce.length-1)/2)*he)}" cy="${f(g+$-Ss-Fr)}" r="${Fr}" fill="${yt(d.get(V)??0)}" stroke="var(--_s)"><title>${We(V)}</title></circle>`}),k.push(`<g class="pele-node pele-task" data-id="${We(J.task.trim())}"><rect x="${f(se)}" y="${f(g)}" width="${f(E)}" height="${f($)}" fill="var(--_s)" stroke="var(--_b)"${ft}/>`+Ce(p[te],re,g+Ss+R/2,` font-size="${s}"`)+ue+"</g>")}),D+=`<path class="pele-stems" d="${ne}" fill="none" stroke="var(--_b)" stroke-dasharray="2 3"/>`+(u>1?`<path class="pele-edge" d="${Y}" fill="none" stroke="var(--_l)" stroke-linejoin="round"/>`:"")+q;for(let J of M){let te=k.slice(J.start,J.start+J.count).join("");if(!J.label){D+=te;continue}let se=H+J.start*b,re=J.count*b-Pl;D+=`<g class="pele-cluster pele-section" data-id="${We(l[J.start].section.trim())}"><rect x="${f(se)}" y="${f(z)}" width="${f(re)}" height="${f(T)}" fill="var(--_a)"${ft}/>`+Ce(J.label,se+re/2,z+T/2,` font-size="${s}" font-weight="var(--_hw)"`)+te+"</g>"}if(U=w+no,L.length>0){let J=H+(S-O)/2,te=U+16,se="";for(let re of L){let P=te+re.y+re.h/2;se+=`<g class="pele-legend-item" data-id="${We(re.name)}"><circle cx="${f(J+re.x+Fr)}" cy="${f(P)}" r="${Fr}" fill="${yt(d.get(re.name)??0)}"/>`+Ce(re.label,J+re.x+2*Fr+6+re.label.width/2,P,"")+"</g>"}D+=`<g class="pele-legend" font-size="${s}">${se}</g>`,U=te+v}}let B=Math.ceil(oe+2*c),F=Math.ceil(Math.max(U,c)+c),W=Ce(C,c+oe/2,c+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+D;return{svg:ot("journey",B,F,i,n,e,W),width:B,height:F,links:[]}}function $N(e,t){let n=t.fontSize??16,r=Math.round(n*.875),i=t.measurer??at(t.fontFamily,t.fontFamilyMono),s=t.padding??8,a=Math.max(140,(t.maxWidth??320)-2*s),o=Bn(e.title,i,n,a,1),c=Ll(e.tasks).filter(b=>b!==""),l=new Map(c.map((b,S)=>[b,S])),u=s+(o.height?o.height+16:0),h,d="",m=o.width;e.tasks.forEach((b,S)=>{if(b.section!==h){h=b.section;let C=Bn(h,i,n,a-16,1);C.height&&(d+=Ce(C,s+8+C.width/2,u+C.height/2,' class="pele-cluster-label" font-weight="var(--_hw)"'),m=Math.max(m,C.width+16),u+=C.height+8)}let x=Bn(b.task,i,r,a-72),I=b.people.filter(C=>C!=="").map(C=>({name:C,label:Bn(C,i,r,a-44)})),L=Math.max(x.height,42),O=2*Ss+L;for(let C of I)O+=Math.max(16,C.label.height)+4;let v=Math.max(a,x.width+72);d+=`<g class="pele-node pele-journey-step" data-id="${S}"><rect x="${f(s)}" y="${f(u)}" width="${f(v)}" height="${f(O)}" fill="var(--_s)" stroke="var(--_b)"${ft}/>`,d+=Ce(x,s+Fl+x.width/2,u+Ss+x.height/2,' class="pele-label"');let G=s+v-28;d+=ZE(G,u+Ss+no,b.score>3?"happy":b.score<3?"sad":"neutral"),Number.isNaN(b.score)||(d+=`<text class="pele-journey-score" x="${f(G)}" y="${f(u+Ss+2*no+r)}" font-size="${r}" text-anchor="middle">${f(Math.min(5,Math.max(1,b.score)))}</text>`);let K=u+Ss+L+4;for(let C of I){let Z=Math.max(16,C.label.height);d+=`<circle class="pele-actor" cx="${f(s+16)}" cy="${f(K+Z/2)}" r="${Fr}" fill="${yt(l.get(C.name))}"/>`+Ce(C.label,s+28+C.label.width/2,K+Z/2,` class="pele-journey-actor" font-size="${r}"`),K+=Z+4}d+="</g>",u+=O,S+1<e.tasks.length&&(d+=`<path class="pele-edge" d="M${f(s+v/2)},${f(u)}v16" fill="none" stroke="var(--_l)"/>`),u+=16,m=Math.max(m,v)});let p=Math.ceil(m+2*s),y=Math.ceil(Math.max(s+o.height,u-(e.tasks.length?16:0))+s),E=Ce(o,p/2,s+o.height/2,' class="pele-title" font-weight="var(--_tw)"')+d;return{svg:ot("journey",p,y,n,t,e,E),width:p,height:y,links:[]}}var e0={type:"journey",parse(e,t,n){let r=new $l;return r.title=n,qE(e,r),r},render:JE};var LN=["1","INVALID","SPACELINE","NL","EOF","","SPACELIST","ICON","CLASS","NODE_DSTART","NODE_ID","NODE_DESCR","NODE_DEND","SHAPE_DATA"];function t0(e,t){return e===5?t?"KANBAN":"MINDMAP":LN[e]}var ws={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6};function Bl(e,t){switch(e){case"[":return ws.RECT;case"(":return t===")"?ws.ROUNDED_RECT:ws.CLOUD;case"((":return ws.CIRCLE;case")":return ws.CLOUD;case"))":return ws.BANG;case"{{":return ws.HEXAGON;default:return ws.DEFAULT}}var ON=/\s+/y,Eh=/.+/y,DN=/[^([\n){}]+/y,vN=/[^([\n){}@]+/y,PN=/[^)\](}]+/y,FN=/[^`"]+/y,BN=/[^}^"]+/y,WN=/\n\s*/g;function n0(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function xh(e,t){let n=e.length,r=[],i=[],s=[],a=t?"kanban":"mindmap",o=t?vN:DN,c=0,l=0,u=-1,h=(y,E,b)=>{r.push(y),i.push(E),s.push(l),l=b},d=(y,E,b)=>{h(y,e.slice(l,E),E),c=b},m=(y,E)=>(y.lastIndex=E,y.test(e)?y.lastIndex:-1),p=y=>{let E=e.indexOf(y,l);return E===-1?n:E};for(;l<n;){let y=e.charCodeAt(l),E=e.charCodeAt(l+1),b;if(c===0){let S=y<=32||y>=160?Math.max(m(ON,l),l):l;if(t&&y===64&&E===123)h(13,"",l+2),c=6;else if(e.charCodeAt(S)===37&&e.charCodeAt(S+1)===37)d(2,m(Eh,S),0);else if(S>l)u<l&&(u=p(`
97
+ `)),u>=S?d(6,S,0):(b=e.lastIndexOf(`
98
+ `,S-1))>l?d(2,b+1,0):d(3,l+1,0);else if(n0(e,l,a)&&!it(e.charCodeAt(l+a.length)))d(5,l+a.length,0);else if(y===58&&E===58&&e.charCodeAt(l+2)===58)l+=3,c=1;else if(y===58&&E===58&&n0(e,l+2,"icon")&&e.charCodeAt(l+6)===40)l+=7,c=2;else if(y===45&&E===41||y===40&&(E===45||E===40)||(y===41||y===123)&&E===y)d(9,l+2,3);else if(y===41||y===40||y===91)d(9,l+1,3);else if((b=m(o,l))!==-1)d(10,b,0);else break}else if(c===3)y===34?(c=E===96?5:4,l+=E===96?2:1):y===41||y===40?d(12,E===y||y===40&&E===45?l+2:l+1,0):y===93?d(12,l+1,0):y===125&&E===125||y===45&&E===41?d(12,l+2,0):d(11,m(y===125?Eh:PN,l),3);else if(c===4)y===34?(l++,c=3):d(11,p('"'),4);else if(c===5)if(y===96&&E===34)l+=2,c=3;else if((b=m(FN,l))!==-1)d(11,b,5);else break;else if(c===1)if((b=m(Eh,l))!==-1)d(8,b,0);else if(y===10)l++,c=0;else break;else if(c===2)y===41?(l++,c=0):d(7,p(")"),2);else if(c===6)if(y===34)d(13,l+1,7);else if(y===125)l++,c=0;else if((b=m(BN,l))!==-1)d(13,b,6);else break;else y===34?d(13,l+1,6):(b=p('"'),h(13,e.slice(l,b).replace(WN,"<br/>"),b))}return l<n?h(1,"",l):(c===0&&h(4,"",n),h(0,"",n)),{types:r,texts:i,starts:s}}var ai="'SPACELINE', 'NL', 'EOF'",r0=new Uint8Array(14);for(let e of[2,6,7,8,9,10])r0[e]=1;function ro(e){return e===2||e===3||e===4}function Wl(e,t,n){let r=n?"kanban":"mindmap",{types:i,texts:s,starts:a}=xh(e,n),o=n?", 'SHAPE_DATA'":"",c=0,l=d=>{let m=i[c];throw m===1?ut(r,e,a[c],"",!0):ut(r,e,a[c],`Expecting ${d}, got '${t0(m,n)}'`)},u=`'${t0(5,n)}'`;if(i[c]===2){for(c++;i[c]===2||i[c]===3;)c++;i[c]!==5&&l(`'SPACELINE', 'NL', ${u}`)}else i[c]!==5&&l(`'SPACELINE', ${u}`);c++;let h="'SPACELINE', 'NL', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'";for(i[c]===3&&(c++,h="'SPACELINE', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'");;){let d=i[c],m=0,p=d===6;if(p&&(m=s[c++].length,d=i[c]),d===10||d===9){let y,E,b=0;if(d===10&&(y=s[c++]),i[c]===9){let S=s[c++];i[c]!==11&&l("'NODE_DESCR'"),E=s[c++],i[c]!==12&&l("'NODE_DEND'");let x=s[c++];!ro(i[c])&&i[c]!==13&&l(ai+o),b=t.getType(S,x)}else!ro(i[c])&&i[c]!==13&&l(ai+", 'NODE_DSTART'"+o),E=y;if(i[c]===13){let S=s[c++];for(;i[c]===13;)S+=s[c++];ro(i[c])||l(ai+o),t.addNode(m,y??E,E,b,S)}else t.addNode(m,y??E,E,b)}else if(d===7||d===8){let y=s[c++];ro(i[c])||l(ai),t.decorateNode(d===7?{icon:y}:{class:y})}else p?ro(d)||l(ai+", 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'"):d===2?ro(i[++c])||l(ai):l(h);for(c++;i[c]===3||i[c]===4;)c++;if(i[c]===0)return;r0[i[c]]===0&&l(ai+", 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'")}}var Ul=class{type="kanban";title;sections=[];getType=Bl;last;sectionLevel=0;misplaced;addNode(t,n,r,i,s){let a={id:n,level:t,label:r};if(s!==void 0){let c=s.includes(`
99
+ `)?s+`
100
+ `:`{
101
+ `+s+`
102
+ }`,l;try{l=cr(c)}catch(u){throw new qe(`Metadata of "${a.id}" is not valid YAML. ${u.message}`,"syntax",{type:"kanban"})}if(l!==null&&typeof l=="object"&&!Array.isArray(l)){let u=l.shape?String(l.shape):"";if(u!==u.toLowerCase()||u.includes("_"))throw new qe(`No such shape: ${u}. Shape names should be lowercase.`,"semantic",{type:"kanban"});l.label&&(a.label=String(l.label)),l.icon&&(a.icon=String(l.icon)),l.assigned&&(a.assigned=String(l.assigned)),l.ticket&&(a.ticket=String(l.ticket)),l.priority&&(a.priority=String(l.priority))}}if(this.misplaced)throw new qe(`Items without section detected, found section ("${this.misplaced.label}")`,"semantic",{type:"kanban"});let o=this.sections;if(o.length===0&&(this.sectionLevel=t),this.last=a,t===this.sectionLevel){let c=a;c.items=[],o.push(c)}else o[o.length-1].items.push(a),t<this.sectionLevel&&(this.misplaced=a)}decorateNode(t){let n=this.last;!t||!n||(t.icon&&(n.icon=t.icon),t.class&&(n.cssClasses=t.class))}};function s0(e,t){Wl(e,t,!0)}function wa(e,t,n,r,i){return`<svg class="pele-icon" data-icon="${We(e)}" x="${f(t)}" y="${f(n)}" width="${f(r)}" height="${f(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??""}</svg>`}var Br=12,Wr=8,br=10,Ah=8,UN=4,_a=6,GN=new Map([["very high",`stroke="${Go}"`],["high",`stroke="${Go}" opacity="0.5"`],["low",'stroke="var(--_m)" opacity="0.5"'],["very low",'stroke="var(--_m)"']]);function Gl(e,t,n,r,i,s=0){let a=Ue(e,t,n,r,i,s);if(a.width<=i)return a;let o=[],c=[],l=0,u=[],h=0,d=()=>{o.push(u),c.push(h),l=Math.max(l,h),u=[],h=0};for(let p=0;p<a.lines.length;p++){if(a.widths[p]<=i){u=a.lines[p],h=a.widths[p],d();continue}for(let y of a.lines[p]){if(y.icon!==void 0||y.math){h>0&&h+y.width>i&&d(),u.push(y),h+=y.width;continue}let E="",b=h;for(let S of y.text){let x=n.width(S,r,y.style);h>0&&h+x>i&&(E&&u.push({text:E,style:y.style,width:h-b}),d(),E="",b=0),E+=S,h+=x}E&&u.push({text:E,style:y.style,width:h-b})}d()}let m={...a,lines:o,widths:c,width:l,height:o.length*a.lineHeight};return a.heights?zo(m):m}function Ra(e,t,n,r,i,s=!1){let a="";for(let o=0;o<e.lines.length;o++){let c=e.lines[o],l=n+Cr(e,o);if(c.length===1&&c[0].icon===void 0&&c[0].math===void 0&&(c[0].style&56)===0)a+=`<text${Xn(r,c[0].style)} x="${f(t)}" y="${f(l+e.size*.35)}"${s?' text-anchor="end"':""}>${nt(c[0].text)}</text>`;else{let u=e.widths[o];a+=Ce(Nr(e,o),t+(s?-u:u)/2,l,r,i)}}return a}var so=e=>!!e&&Ri(e)!=="";function i0(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),s=Math.round(r*1.5),a=Math.round(i*1.5),o=n.measurer??at(n.fontFamily,n.fontFamilyMono),c=n.padding??8,l=n.icons,u=t.kanban??{},h=u.sectionWidth,d=i*1.25,m=0,p=(W,j,Q)=>{if(!(!W||!W.includes("$$")))for(let Y of Ue(W,!0,o,j,1/0).lines)for(let ne of Y)ne.math&&(m=Math.max(m,ne.math.width+Q))};for(let W of e.sections){let j=o.width(String(W.items.length),i,0);p(W.label,r,2*Wr+8+j+12+(so(W.icon)?d+_a:0));for(let Q of W.items){let Y=2*(Wr+br);p(Q.label,i,Y+(so(Q.icon)?d+_a:0)),p(Q.ticket,i,Y),p(Q.assigned,i,Y)}}let y=Math.max(typeof h=="number"&&h>0?Math.min(Math.max(h,80),2e3):200,Math.ceil(m)),E=n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*c:1/0,b=e.sections.length,S=b*(y+Br)-Br<=E,x=S?Math.max(b,1):Math.max(1,Math.floor((E+Br)/(y+Br))),I=S?y:Math.max(Math.min(y,E),Math.min(Math.floor((E+Br)/x)-Br,y*2),Math.ceil(m)),L=typeof u.ticketBaseUrl=="string"?u.ticketBaseUrl:"",O=I-2*Wr,v=O-2*br,G=[],K=e.sections,C=[],Z=[],oe=[],H=s,z=[];for(let W of K){let j=o.width(String(W.items.length),i,0),Q=j+12+(so(W.icon)?d+_a:0),Y=Gl(W.label,!0,o,r,O-8-Q,1);H=Math.max(H,Y.height),Z.push(j),C.push(Y);let ne=[],q=0;for(let k of W.items){let J=Gl(k.label,!0,o,i,v-(so(k.icon)?d+_a:0)),te=Gl(k.ticket,!1,o,i,v),se=Gl(k.assigned,!1,o,i,v),re=te.width+se.width+8>v?te.height+se.height:Math.max(te.height,se.height),P=2*br+Math.max(J.height,a)+(re?UN+re:0);ne.push({item:k,label:J,ticket:te,assigned:se,meta:re,height:P}),q+=P+Ah}oe.push(ne),z.push(q)}H+=2*Wr;let M=[],T=[];for(let W=0,j=0;W<K.length;W+=x){let Q=Ah;for(let Y=W;Y<Math.min(W+x,K.length);Y++)Q=Math.max(Q,z[Y]);T.push(j),M.push(H+Q),j+=H+Q+Br}let R=M.length>0?T[T.length-1]+M[M.length-1]:0,_=bn(e.title,o,r,It(n)),$=_.height>0?_.height+16:0,g=Math.max(Math.min(K.length,x)*(I+Br)-Br,0),N=Math.max(g,_.width),w=c+(N-g)/2,A=I-Wr-4,D="";for(let W=0;W<K.length;W++){let j=K[W],Q=Math.floor(W/x),Y=`<rect width="${I}" height="${f(M[Q])}" fill="var(--_s)"${ft}/>`+Ra(C[W],Wr+4,Wr,' class="pele-cluster-label" font-weight="var(--_hw)"',l)+`<text class="pele-count" x="${A}" y="${f(Wr+s/2+i*.35)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${j.items.length}</text>`;so(j.icon)&&(Y+=wa(j.icon,A-Z[W]-_a-d,Wr+(s-d)/2,d,l));let ne=H;for(let q of oe[W]){let k=q.item,J=(k.priority??"").trim().toLowerCase(),te=GN.get(J),se=`<rect width="${O}" height="${f(q.height)}" fill="var(--_bg)" stroke="var(--_b)"${ft}/>`;te!==void 0&&(se+=`<path class="pele-priority" d="M2.5,5V${f(q.height-5)}" fill="none" ${te} stroke-width="3" stroke-linecap="round"/>`),se+=Ra(q.label,br,br,' class="pele-label"',l),so(k.icon)&&(se+=wa(k.icon,O-br-d,br+(a-d)/2,d,l));let re=q.height-br;if(k.ticket){let P=re-q.meta,ee=L?Io(qn(L.replace("#TICKET#",()=>k.ticket)),n):void 0;ee===void 0?se+=Ra(q.ticket,br,P,' class="pele-ticket" fill="var(--_m)"',l):(se+=`<a href="${nt(ee)}" target="_blank"${Xr(n)}>`+Ra(q.ticket,br,P,' class="pele-ticket" fill="var(--_c)"',l)+"</a>",G.push({id:k.id,href:ee,internal:!1}))}k.assigned&&(se+=Ra(q.assigned,O-br,re-q.assigned.height,' class="pele-assigned" fill="var(--_m)"',l,!0)),Y+=`<g class="pele-node pele-card${te===void 0?"":" pele-priority-"+J.replace(" ","-")}${Nt(k.cssClasses??"")}" data-id="${We(k.id)}" transform="translate(${Wr},${f(ne)})" font-size="${i}">${se}</g>`,ne+=q.height+Ah}D+=`<g class="pele-cluster pele-column${Nt(j.cssClasses??"")}" data-id="${We(j.id)}" transform="translate(${f(w+W%x*(I+Br))},${f(c+$+T[Q])})">${Y}</g>`}let U=Math.ceil(N+2*c),B=Math.ceil(R+$+2*c),F=Ce(_,U/2,c+_.height/2,' class="pele-title" font-weight="var(--_tw)"')+D;return{svg:ot("kanban",U,B,r,n,{},F),width:U,height:B,links:G}}var o0={type:"kanban",math:!0,parse(e,t,n){let r=new Ul;return r.title=n,s0(e,r),r},render:i0};var YN=11,Yl=class{type="mindmap";title;nodes=[];getType=Bl;baseLevel=0;open=[];addNode(t,n,r,i){let s=this.nodes.length===0;s&&(this.baseLevel=t),t-=this.baseLevel;let a=this.open,o=a.length;for(;o>0&&a[o-1].level>=t;)o--;let c=a[o-1];if(!c&&!s)throw new qe(`There can be only one root. No parent could be found for ("${r}")`,"semantic",{type:"mindmap"});let l={id:this.nodes.length,nodeId:n,level:t,descr:r,type:i,children:[],isRoot:s};c&&(l.section=c.isRoot?c.children.length%YN:c.section,c.children.push(l)),a.length=o,a.push(l),this.nodes.push(l)}decorateNode(t){let n=this.nodes[this.nodes.length-1];!t||!n||(t.icon&&(n.icon=t.icon),t.class&&(n.class=t.class))}};function a0(e,t){Wl(e,t,!1)}var HN=["","rounded","rect","circle","cloud","bang","hex"],c0="stadium",KN=36,zN=8,VN=18,jN=52,l0=28,d0=6,XN=12,qN=.22,Sh=6,wh=28,u0=12,f0=8,h0=10;function QN(e,t,n,r){if(e.lines.length<2)return Ce(e,t+e.width/2,n,' class="pele-label"',r);let i="",s=n-e.height/2;for(let a=0;a<e.lines.length;a++)i+=Ce(Nr(e,a),t+e.widths[a]/2,s+Cr(e,a),' class="pele-label"',r);return i}function p0(e,t,n){return vt(n,r=>ZN(e,t,n,r))}function ZN(e,t,n,r){let i=n.fontSize??16,s=n.measurer??at(n.fontFamily,n.fontFamilyMono),a=n.padding??8,o=n.icons,c=t.mindmap?.maxNodeWidth,l=typeof c=="number"&&c>0?Math.min(c,2e3):200,u=i*1.25,h=e.nodes,d=h.length,m=new Int32Array(d),p=new Int32Array(d);for(let q=0;q<d;q++)for(let k of h[q].children)m[k.id]=q,p[k.id]=p[q]+1;let y=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*a:1/0,E=new Array(d),b=new Array(d),S=new Float64Array(d),x=new Float64Array(d),I=new Float64Array(d),L=new Float64Array(d),O=new Uint8Array(d);for(let q=0;q<d;q++){let k=h[q];O[q]=k.icon!==void 0&&Ri(k.icon)!==""?1:0;let J=Math.min(l,Math.max(72,y-p[q]*wh-2*d0-(O[q]?u+Sh:0))),te=E[q]=Ue(k.descr,!0,s,i,J),se=te.width+(O[q]?u+(te.width>0?Sh:0):0),re=Math.max(te.height,Math.round(i*1.5)),P=HN[k.type]||(q===0?c0:"");if(r&&q===0&&P!=="rect"&&P!=="rounded"&&(P=c0),b[q]=P,P===""){let ee=k.children.length>0;S[q]=se+2*(ee?XN:d0),x[q]=re+(ee?6:0),L[q]=x[q]/2}else{let ee=hs(P,se,re);S[q]=ee.w,x[q]=ee.h,I[q]=ee.dy,L[q]=ee.h/2}}let v=new Float64Array(d),G=new Float64Array(d),K=new Float64Array(d),C=new Float64Array(d),Z=0,oe=(q,k,J,te)=>{let se=0,re=0;for(let ae=k;ae<J;ae++){let ue=q[ae].id;G[ue]=se,re=q[ae].children.length>0||ae+1<J&&q[ae+1].children.length>0?Math.max(te,VN):te,se+=v[ue]+re}Z=se-re;let P=q[k].id,ee=q[J-1].id;return(G[P]+K[P]+L[P]+G[ee]+K[ee]+L[ee])/2};for(let q=d-1;q>0;q--){let k=h[q].children;if(k.length===0){v[q]=x[q];continue}let J=oe(k,0,k.length,zN)-L[q],te=Math.min(0,J);v[q]=Math.max(Z,J+x[q])-te,K[q]=J-te,C[q]=-te}let H=new Float64Array(d),z=new Float64Array(d),M=new Float64Array(d),T=new Int8Array(d),R=new Float64Array(d);if(r){let q=0;for(let k=0;k<d;k++)k>0&&m[k]===0&&(q+=h0),H[k]=p[k]*wh+S[k]/2,z[k]=q,q+=x[k]+h0}else if(d>0){let q=h[0].children,k=q.length,J=0;for(let P of q)J+=v[P.id];let te=k,se=1/0,re=0;for(let P=1;P<k;P++){re+=v[q[P-1].id];let ee=Math.abs(2*re-J+(2*P-k)*l0);ee<se&&(se=ee,te=P)}for(let P=0,ee=te,ae=1;P<k;P=ee,ee=k,ae=-1){let ue=oe(q,P,ee,l0);for(let ce=P;ce<ee;ce++){let he=q[ce].id;M[he]=G[he]-ue,T[he]=ae}}z[0]=-x[0]/2;for(let P=0;P<d;P++){P>0&&(z[P]=M[P]+K[P]);for(let ee of h[P].children){let ae=ee.id;P>0&&(T[ae]=T[P],M[ae]=M[P]+C[P]+G[ae]),H[ae]=H[P]+T[ae]*(S[P]/2+(P>0?KN:jN)+S[ae]/2)}}}let _=0,$=0,g=0,N=0,w="",A="",D="",U="",B=q=>{D!==""&&(w+=`<g class="pele-branch pele-section-${q??0}"><g class="pele-edges" fill="none" stroke="${U}" stroke-width="1.5">${A}</g>${D}</g>`,A=D="")};for(let q=1;q<=d;q++){let k=q%d,J=h[k],te=b[k],se=E[k],re=H[k],P=z[k];if(_=Math.min(_,re-S[k]/2),$=Math.max($,re+S[k]/2),g=Math.min(g,P),N=Math.max(N,P+x[k]),(k===0||m[k]===0)&&B(h[q-1].section),k>0&&r){m[k]===0&&(U=yt(J.section??0));let V=m[k],X=V===0?Math.min(Math.max(u0,x[0]/2),wh-f0):u0,le=H[V]-S[V]/2+Math.min(X,S[V]/2),de=R[V]||z[V]+x[V],we=re-S[k]/2+(te?qr(te,S[k],x[k],3):0),Ee=P+L[k],Te=Math.max(0,Math.min(f0,we-le,Ee-de));R[V]=Ee-Te,A+=`<path class="pele-edge" d="M${f(le)},${f(de)}V${f(Ee-Te)}Q${f(le)},${f(Ee)} ${f(le+Te)},${f(Ee)}H${f(we)}"/>`}else if(k>0){m[k]===0&&(U=yt(J.section??0));let V=m[k],X=T[k],le=X>0?1:3,de=H[V]+X*(S[V]/2-(b[V]?qr(b[V],S[V],x[V],le):0)),Ae=z[V]+L[V],Ee=re-X*S[k]/2+(te?X*qr(te,S[k],x[k],4-le):0),Te=P+L[k],Me=f((de+Ee)/2);A+=`<path class="pele-edge" d="M${f(de)},${f(Ae)}C${Me},${f(Ae)} ${Me},${f(Te)} ${f(Ee)},${f(Te)}"/>`}let ee=!te&&J.children.length>0,ae=` fill="${U}" fill-opacity="${qN}" stroke="${U}"`,ue="";te?ue=k>0?fr(te,S[k],x[k],ae,` stroke="${U}"`):fr(te,S[k],x[k],' fill="var(--_s)" stroke="var(--_b)"',' stroke="var(--_b)"'):ee&&(ue=`<rect x="${f(-S[k]/2)}" y="${f(-x[k]/2)}" width="${f(S[k])}" height="${f(x[k])}" rx="${f(x[k]/2)}"${ae}/>`);let ce=0;J.icon&&O[k]&&(ce=(u+(se.width>0?Sh:0))/2,ue+=wa(J.icon,-ce-se.width/2,I[k]-u/2,u,o));let he=`<g class="pele-node pele-shape-${te||(ee?"branch":"text")}${k>0?"":" pele-root"}${Nt(J.class??"")}" data-id="${We(J.nodeId)}" transform="translate(${f(re)},${f(P+x[k]/2)})">`+ue+(r&&!te?QN(se,ce-se.width/2,I[k],o):Ce(se,ce,I[k],' class="pele-label"',o))+"</g>";k>0?D+=he:w+=he}let F=bn(e.title,s,i,It(n)),W=F.height>0?F.height+16:0,j=Math.max($-_,F.width),Q=Math.ceil(j+2*a),Y=Math.ceil(N-g+W+2*a),ne=Ce(F,Q/2,a+F.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f(a-_+(j-$+_)/2)},${f(a+W-g)})">${w}</g>`;return{svg:ot("mindmap",Q,Y,i,n,{},ne),width:Q,height:Y,links:[]}}var m0={type:"mindmap",math:!0,parse(e,t,n){let r=new Yl;return r.title=n,a0(e,r),r},render:p0};var JN=1e4;function io(e,t,n,r,i){let s=e.packet?.[t];return typeof s=="number"&&s>=r?Math.min(s,i):n}function _h(e){return new qe(e,"semantic",{type:"packet"})}function g0(e,t,n){let r=Math.floor(io(t,"bitsPerRow",32,1,4096)),i=[],s=-1,a=[],o=1;for(let c of e.blocks){let{start:l,end:u,bits:h}=c;if(l!==void 0&&u!==void 0&&u<l)throw _h(`Packet block ${l} - ${u} is invalid. End must be greater than start.`);if(l??=s+1,l!==s+1)throw _h(`Packet block ${l} - ${u??l} is not contiguous. It should start from ${s+1}.`);if(h===0)throw _h(`Packet block ${l} is invalid. Cannot have a zero bit field.`);for(u??=l+(h??1)-1,h??=u-l+1,s=u;a.length<=r+1&&i.length<JN;){let d=o*r-1;if(u<=d){a.push({start:l,end:u,bits:h,label:c.label}),u===d&&(i.push(a),a=[],o++);break}a.push({start:l,end:d,bits:d-l,label:c.label}),i.push(a),a=[],o++,l=d+1,h=u-l}}return a.length>0&&i.push(a),{type:"packet",title:e.title||n,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
103
+ `):void 0,bitsPerRow:r,rows:i}}var b0=[{name:"packet-beta",pattern:"packet-beta"},Zt("packet"),{name:"-",pattern:"-",longer:[Yt]},{name:"+",pattern:"+"},{name:":",pattern:":"},rn,jt,hr,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Pn,An,Sn,Yt,qt,Qt];function y0(e){let t=new Wt(Gt(e,b0,"packet"),b0,"packet"),n={$type:"Packet",blocks:[]},r=()=>{if(t.kind!==-1)for(t.kind!==10&&t.fail("a line break or the end of input");t.kind===10;)t.i++};for(;t.kind===10;)t.i++;for(t.accept(0)||t.expect(1);t.kind!==-1;)switch(t.kind){case 10:t.i++;break;case 5:n.accDescr=zt(t.take()),r();break;case 6:n.accTitle=Kt(t.take()),r();break;case 7:n.title=Ht(t.take()),r();break;case 8:case 3:{let i={$type:"PacketBlock",label:""};t.accept(3)?i.bits=Number(t.expect(8)):(i.start=Number(t.take()),t.accept(2)&&(i.end=Number(t.expect(8)))),t.expect(4),i.label=dn(t.expect(9)),n.blocks.push(i),r();break}default:t.fail("a field, a title, or a line break")}return n}function Ta(e,t,n,r,i,s=0){if(e===""||t<=0)return;let a=i.width(e,n,s);if(a<=t)return{text:e,size:n,width:a};let o=Math.max(r,Math.floor(n*t/a));for(;o>=r;){if(a=i.width(e,o,s),a<=t)return{text:e,size:o,width:a};o--}let c=Array.from(e),l=0,u=c.length-1;for(;l<u;){let d=l+u+1>>1;i.width(c.slice(0,d).join("").trimEnd()+"…",r,s)<=t?l=d:u=d-1}if(l===0)return;let h=c.slice(0,l).join("").trimEnd()+"…";return a=i.width(h,r,s),a<=t?{text:h,size:r,width:a}:void 0}function E0(e,t,n){return vt(n,r=>eI(e,t,n,r))}function eI(e,t,n,r){let i=n.fontSize??16,s=Math.round(i*.875),a=Math.round(i*.625),o=n.measurer??at(n.fontFamily,n.fontFamilyMono),c=n.padding??8,l=t.packet??{},u=io(t,"rowHeight",32,1,400),h=io(t,"bitWidth",32,1,400),d=io(t,"paddingX",5,0,400),m=io(t,"paddingY",5,0,400),p=l.showBits!==!1,y=l.bitOrder==="descending",E=e.bitsPerRow,b=e.rows;if(r){let $=Math.max(1,Math.floor(((n.maxWidth??320)-2*c)/Math.min(h,18)));E=Math.min(E,Math.max(8,2**Math.floor(Math.log2($))));let g=e.rows[e.rows.length-1],N=g?.[g.length-1]?.end??0;Math.ceil((N+1)/E)>1e4&&(E=e.bitsPerRow),h=Math.min(h,Math.max(18,((n.maxWidth??320)-2*c)/E));let w=D=>D.bits===D.end-D.start,A=[];for(let D of e.rows)for(let U of D){let B=A[A.length-1];B&&w(B)&&w(U)&&B.label===U.label&&U.start===B.end+1&&U.start%e.bitsPerRow===0?(B.end=U.end,B.bits=B.end-B.start):A.push({...U})}b=[];for(let D of A)for(let U=D.start;U<=D.end;){let B=Math.min(D.end,(Math.floor(U/E)+1)*E-1),F=Math.floor(U/E);(b[F]??(b[F]=[])).push({...D,start:U,end:B}),U=B+1}}let S=new Map;if(r)for(let $ of b)for(let g of $){let N=Math.max(1,(g.end-g.start+1)*h-Math.min(d,h-1)-6),w=qs(gt(g.label).trim(),o,s,N);S.set(g,w)}let x=p?a+4:0,I=b.map($=>{let g=u;if(r)for(let N of $)g=Math.max(g,S.get(N).height+10);return g}),L=[],O=0;for(let $ of I)L.push(O),O+=x+$+m;b.length&&(O-=m);let v=Math.min(d,h-1),G=b.length>0?E*h-v:0,K=Ue(e.title,!1,o,i,r?It(n):4e3,1),C=K.height>0?K.height+(O>0?12:0):0,Z=new Map,oe=($,g)=>{let N=Z.get($);return N||Z.set($,N=new Map),N.has(g)||N.set(g,Ta(gt($).trim(),g,s,Math.round(i*.5),o)),N.get(g)},H=c+Math.max(0,(K.width-G)/2),z="",M="";b.forEach(($,g)=>{let N=c+L[g]+x,w=I[g];for(let A of $){let D=A.end-A.start+1,U=A.start%E,B=H+(y?E-U-D:U)*h,F=D*h-v,W=r?void 0:oe(A.label,F-6);if(z+=`<g class="pele-node" data-id="${A.start}-${A.end}"><rect x="${f(B)}" y="${f(N)}" width="${f(F)}" height="${f(w)}" fill="var(--_s)" stroke="var(--_b)"${ft}/>`+(r?Ce(S.get(A),B+F/2,N+w/2,""):W&&W.size<=w?`<text x="${f(B+F/2)}" y="${f(N+w/2+W.size*.35)}"${W.size===s?"":` font-size="${f(W.size)}"`}>${nt(W.text)}</text>`:"")+"</g>",!p)continue;let j=y?A.end:A.start,Q=y?A.start:A.end;D===1?M+=`<text x="${f(B+F/2)}" y="${f(N-4)}" text-anchor="middle">${j}</text>`:M+=`<text x="${f(B)}" y="${f(N-4)}">${j}</text><text x="${f(B+F)}" y="${f(N-4)}" text-anchor="end">${Q}</text>`}});let T=Math.ceil(Math.max(G,K.width)+2*c),R=Math.ceil(O+C+2*c),_=(z?`<g class="pele-packet-fields" font-size="${s}" text-anchor="middle">${z}</g>`:"")+(M?`<g class="pele-packet-bits" font-size="${a}" fill="var(--_m)">${M}</g>`:"")+Ce(K,T/2,R-c-K.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:ot("packet",T,R,i,n,e,_),width:T,height:R,links:[]}}var x0={type:"packet",parse:(e,t,n)=>g0(y0(e),t,n),render:E0};function A0(e,t){let n=new Map;for(let{label:r,value:i}of e.sections){if(i<0)throw new qe(`"${r}" has invalid value: ${i}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,"semantic",{type:"pie"});n.has(r)||n.set(r,i)}return{type:"pie",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
104
+ `):void 0,showData:e.showData,sections:n}}function S0(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function tI(){let e=0,t=0,n=-1;return(r,i)=>{let s=r.charCodeAt(i)===45?i+1:i;if((s<e||s>=t)&&(e=s,t=S0(r,s),n=-1,t>s&&r.charCodeAt(t)===46)){let a=S0(r,t+1),o=a-t-1;o>0&&r.charCodeAt(a)!==46?n=a:o>1&&(n=a-1)}return t===s?-1:n>=0?n:r.charCodeAt(s)===48?r.charCodeAt(s+1)===46?-1:s+1:r.charCodeAt(t)!==46?t:t-1>s?t-1:-1}}var w0=[Zt("showData"),Zt("pie"),{name:":",pattern:":"},{name:"NUMBER_PIE",pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:tI,first:"-0123456789"},rn,jt,hr,Pn,An,Sn,Yt,qt,Qt];function _0(e){let t=new Wt(Gt(e,w0,"pie"),w0,"pie"),n={$type:"Pie",showData:!1,sections:[]},r=()=>{if(t.kind!==-1)for(t.kind!==8&&t.fail("a line break or the end of input");t.kind===8;)t.i++};for(;t.kind===8;)t.i++;for(t.expect(1),n.showData=t.accept(0);t.kind!==-1;)switch(t.kind){case 8:t.i++;break;case 4:n.accDescr=zt(t.take()),r();break;case 5:n.accTitle=Kt(t.take()),r();break;case 6:n.title=Ht(t.take()),r();break;case 7:{let i=dn(t.take());t.expect(2);let s=Number(t.expect(3));n.sections.push({$type:"PieSection",label:i,value:s}),r();break}default:t.fail("a section, a title, or a line break")}return n}var nI=120,Ma=12,Rh=26,Th=32,R0=28;function Mh(e,t){return e.pie?.[t]}function oo(e,t){return`${f(Math.sin(e)*t)},${f(-Math.cos(e)*t)}`}function rI(e,t,n,r){if(t-e>=Math.PI*2-1e-9){let s=(a,o)=>`M0,${f(-a)}A${f(a)},${f(a)} 0 1 ${o} 0,${f(a)}A${f(a)},${f(a)} 0 1 ${o} 0,${f(-a)}Z`;return s(n,1)+(r>0?s(r,0):"")}let i=t-e>Math.PI?1:0;return r<=0?`M0,0L${oo(e,n)}A${f(n)},${f(n)} 0 ${i} 1 ${oo(t,n)}Z`:`M${oo(e,n)}A${f(n)},${f(n)} 0 ${i} 1 ${oo(t,n)}L${oo(t,r)}A${f(r)},${f(r)} 0 ${i} 0 ${oo(e,r)}Z`}function T0(e,t,n){return ps(n,nI*2,140,(r,i)=>sI(e,t,n,r/2,i))}function sI(e,t,n,r,i){let s=n.fontSize??16,a=Math.round(s*.875),o=n.measurer??at(n.fontFamily,n.fontFamilyMono),c=n.padding??8,l=Mh(t,"textPosition"),u=typeof l=="number"&&l>=0&&l<=1?l:.75,h=Mh(t,"donutHole"),d=typeof h=="number"&&h>0&&h<=.9?h*r:0,m=String(Mh(t,"legendPosition")??"right"),p=i&&(m==="left"||m==="right")?"bottom":m,y=[...e.sections],E=0;for(let[,Q]of y)E+=Q;let b=y.map(([Q,Y])=>Ue(e.showData?`${Q} [${Y}]`:Q,!1,o,a,4e3)),S=0;for(let Q of b)S=Math.max(S,Q.width);S+=b.length>0?Ma+8:0;let x=b.length*Rh,I=Ue(e.title,!1,o,s,It(n),1),L=I.height>0?I.height+16:0,O=y.map(([,Q])=>{let Y=E>0?Q/E:0;return Y*100>=1&&(Y*100).toFixed(0)!=="0"?Y:0}),v=O.map(Q=>Q===0||Q>=.5?!1:2*r*u*Math.sin(Q*Math.PI)<o.width((Q*100).toFixed(0)+"%",a,0)+6),G=v.includes(!0)?R0:0,K=p==="left"||p==="right"||p==="center"?p:"",C=p==="top"||p==="bottom",Z=(r+G)*2,oe=Z,H=Z;K==="left"||K==="right"?(oe+=S>0?Th+S:0,H=Math.max(H,x)):C&&(oe=Math.max(oe,S),H+=x>0?20+x:0),oe=Math.max(oe,I.width);let z=c+(K==="left"?S+Th+Z/2:K==="right"?Z/2:oe/2),M=c+L,T=M+(p==="top"?x+20+Z/2:C?Z/2:H/2),R="",_="",$="",g=0,N=r+R0/2,w=[],A=(Q,Y,ne)=>w.every(q=>Math.abs(Q-q.x)>=(ne+q.width)/2+2||Math.abs(Y-q.y)>=a+2);y.forEach(([Q],Y)=>{let ne=O[Y];if(ne===0)return;let q=g+ne*Math.PI*2;R+=`<path class="pele-slice" data-id="${We(Q)}" d="${rI(g,q,r,d)}" fill="${yt(Y)}"/>`;let k=(g+q)/2,J=(ne*100).toFixed(0)+"%";if(v[Y]){let te=o.width(J,a,0),se=k;for(let ee=0;ee<360&&!A(Math.sin(se)*N,-Math.cos(se)*N,te);ee++)se+=2/N;let re=Math.sin(se)*N,P=-Math.cos(se)*N;w.push({x:re,y:P,width:te}),$+=`<text x="${f(re)}" y="${f(P+a*.35)}">${J}</text>`}else{let te=r*u;_+=`<text x="${f(Math.sin(k)*te)}" y="${f(-Math.cos(k)*te+a*.35)}"${us(Y)}>${J}</text>`}g=q}),R===""&&(R=`<circle class="pele-slice" r="${r}" fill="none" stroke="var(--_b)"/>`);let D="",U,B;K==="right"?(U=z+Z/2+Th,B=M+(H-x)/2):K==="left"?(U=c,B=M+(H-x)/2):K==="center"?(U=z-S/2,B=T-x/2):(U=c+(oe-S)/2,B=p==="top"?M:M+Z+20),b.forEach((Q,Y)=>{let ne=B+Y*Rh+Rh/2;D+=`<g class="pele-legend-item" data-id="${We(y[Y][0])}"><rect x="${f(U)}" y="${f(ne-Ma/2)}" width="${Ma}" height="${Ma}" rx="2" fill="${yt(Y)}"/>`+Ce(Q,U+Ma+8+Q.width/2,ne,"")+"</g>"});let F=Math.ceil(oe+2*c),W=Math.ceil(H+L+2*c),j=Ce(I,F/2,c+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-slices" transform="translate(${f(z)},${f(T)})" stroke="var(--_bg)" stroke-width="1" stroke-linejoin="round">${R}</g>`+(_?`<g class="pele-slice-labels" transform="translate(${f(z)},${f(T)})" font-size="${a}" text-anchor="middle" fill="var(--_bg)">${_}</g>`:"")+($?`<g class="pele-slice-labels" transform="translate(${f(z)},${f(T)})" font-size="${a}" text-anchor="middle">${$}</g>`:"")+(D?`<g class="pele-legend" font-size="${a}">${D}</g>`:"");return{svg:ot("pie",F,W,s,n,e,j),width:F,height:W,links:[]}}var M0={type:"pie",parse:(e,t,n)=>A0(_0(e),n),render:T0};var iI=/^\d+$/,C0=/^#?([\dA-Fa-f]{6}|[\dA-Fa-f]{3})$/,oI=/^\d+px$/;function Hl(e,t,n){return new qe(`value for ${e} ${t} is invalid, please use a valid ${n}`,"semantic",{type:"quadrantChart"})}function aI(e){let t=e.trim(),n=t.indexOf(":");if(n===-1)return[t,"undefined"];let r=t.slice(n+1).trimStart(),i=r.indexOf(":");return[t.slice(0,n).trimEnd(),i===-1?r:r.slice(0,i).trimEnd()]}function N0(e){let t={};for(let n of e){let[r,i]=aI(n);if(r==="radius"){if(!iI.test(i))throw Hl(r,i,"number");t.radius=parseInt(i)}else if(r==="color"){if(!C0.test(i))throw Hl(r,i,"hex code");t.color=i}else if(r==="stroke-color"){if(!C0.test(i))throw Hl(r,i,"hex code");t.strokeColor=i}else if(r==="stroke-width"){if(!oI.test(i))throw Hl(r,i,"number of pixels (eg. 10px)");t.strokeWidth=i}else throw new qe(`style named ${r} is not supported.`,"semantic",{type:"quadrantChart"})}return t}function ts(e){return{text:e.text.trim(),type:e.type}}var Kl=class{type="quadrantChart";title;accTitle;accDescr;quadrants=[void 0,void 0,void 0,void 0];xAxisLeft;xAxisRight;yAxisBottom;yAxisTop;points=[];classes=new Map;setQuadrant1Text(t){this.quadrants[0]=ts(t)}setQuadrant2Text(t){this.quadrants[1]=ts(t)}setQuadrant3Text(t){this.quadrants[2]=ts(t)}setQuadrant4Text(t){this.quadrants[3]=ts(t)}setXAxisLeftText(t){this.xAxisLeft=ts(t)}setXAxisRightText(t){this.xAxisRight=ts(t)}setYAxisBottomText(t){this.yAxisBottom=ts(t)}setYAxisTopText(t){this.yAxisTop=ts(t)}addPoint(t,n,r,i,s){this.points.push({x:Number(r),y:Number(i),text:ts(t),className:n,...N0(s)})}addClass(t,n){this.classes.set(t,N0(n))}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
105
+ `)}};function hn(e,t,n){for(let r=0;r<n.length;r++){let i=e.charCodeAt(t+r),s=n.charCodeAt(r);if(i!==s&&!(s>=97&&s<=122&&i===s-32))return!1}return!0}var Ch=["$end","INVALID","NEWLINE","title","title_value","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","X-AXIS","Y-AXIS","AXIS-TEXT-DELIMITER","QUADRANT_1","QUADRANT_2","QUADRANT_3","QUADRANT_4","CLASSDEF","MD_STR","STR","class_name","point_start","point_x","point_y","QUADRANT","ALPHA","UNICODE_TEXT","COLON","PLUS","COMMA","EQUALS","MULT","BRKT","UNDERSCORE","DOT","AMP","MINUS","NUM","SPACE","SEMI","PUNCTUATION","EOF"];var Nh=[41,4,6,8,9,19],Ih=new Uint8Array(128);for(let[e,t]of[[":",27],["+",28],[",",29],["=",30],["*",31],["#",32],["_",33],[".",34],["&",35],["-",36],[" \v\f",38],[";",39],["!$%'`?\\/",40]])for(let n=0;n<e.length;n++)Ih[e.charCodeAt(n)]=t;function I0(e){let t=e.length,n=[],r=[],i=[],s=[],a=0,o=0,c=0,l=0,u=0,h=0,d=0,m=0,p=0,y=0,E=(v,G,K)=>{n.push(v),r.push(e.slice(G,K)),i.push(G),o=K},b=v=>{s.push(a),a=v},S=()=>{s.length>0&&(a=s.pop())},x=v=>{let G=e.indexOf(`
106
+ `,v);return G===-1?t:G},I=v=>{for(;e.charCodeAt(v)===32;)v++;return v},L=v=>{for(;v<t&&Xe(e.charCodeAt(v));)v++;return v},O=v=>{let G=e.charCodeAt(v);if(G===49)return v+1;if(G!==48)return-1;let K=v+1;if(K<t&&!Ws(e.charCodeAt(K))&&Et(e.charCodeAt(K+1)))for(K+=2;Et(e.charCodeAt(K));)K++;return K};e:for(;o<t;){let v=e.charCodeAt(o),G=e.charCodeAt(o+1);switch(a){case 0:break;case 1:case 2:case 3:E(Nh[a],o,x(o)),S();continue;case 4:if(v===125)o++,S();else{let M=e.indexOf("}",o);E(9,o,M===-1?t:M)}continue;case 5:if(v===34)o++,S();else{let M=e.indexOf('"',o);E(19,o,M===-1?t:M)}continue;case 6:if(v===96&&G===34){o+=2,S();continue}if(v!==96&&v!==34){let M=o+1;for(let T=e.charCodeAt(M);M<t&&T!==96&&T!==34;T=e.charCodeAt(++M));E(18,o,M);continue}break e;case 7:if(it(v)){let M=o+1;for(;it(e.charCodeAt(M));)M++;E(20,o,M),S();continue}break e;case 8:{let M=O(o);if(M!==-1){E(22,o,M),b(9);continue}let T=L(o);if(e.charCodeAt(T)===93){o=I(T+1),S();continue}break e}case 9:{let M=L(o);if(e.charCodeAt(M)===44){o=L(M+1),a=10;continue}break e}case 10:{let M=O(o);if(M!==-1){E(23,o,M),S();continue}break e}}if(v===37&&G===37){o=x(o+2);continue}if(v===10||v===13){let M=o+1;for(let T=e.charCodeAt(M);T===10||T===13;T=e.charCodeAt(++M));E(2,o,M);continue}let K=v|32;if(K===116&&hn(e,o,"title")&&!it(e.charCodeAt(o+5))){E(3,o,o+5),b(1);continue}if(K===97&&hn(e,o,"acc")){let M=hn(e,o+3,"descr");if(M||hn(e,o+3,"title")){let T=L(o+8),R=e.charCodeAt(T);if(R===58){E(M?7:5,o,L(T+1)),b(M?3:2);continue}if(R===123&&M){o=L(T+1),b(4);continue}}}let C=o;v===32&&((o<c||o>=l)&&(c=o,l=I(o)),C=l);let Z=e.charCodeAt(C),oe=Z|32,H=0,z=0;if(oe===120&&hn(e,C,"x-axis"))H=10,z=C+6;else if(oe===121&&hn(e,C,"y-axis"))H=11,z=C+6;else if(Z===45){if(C<u||C>=h)for(u=C,h=C;e.charCodeAt(h)===45;)h++;h-C>=2&&e.charCodeAt(h)===62&&(H=12,z=h+1)}else if(oe===113&&hn(e,C,"quadrant")){let M=e.charCodeAt(C+9);e.charCodeAt(C+8)===45&&M>=49&&M<=52?(H=13+M-49,z=C+10):hn(e,C+8,"chart")&&(H=24,z=C+13)}if(H!==0){E(H,o,I(z));continue}if(K===99&&hn(e,o,"classdef")&&!it(e.charCodeAt(o+8))){E(17,o,o+8);continue}if(v===34){G===96?(o+=2,b(6)):(o++,b(5));continue}if(v===58&&G===58&&e.charCodeAt(o+2)===58){o+=3,b(7);continue}if(v===58||Xe(v)){let M=o;if(v!==58&&((o<d||o>=m)&&(d=o,m=L(o)),M=m),e.charCodeAt(M)===58&&((M+1<p||M+1>=y)&&(p=M+1,y=L(M+1)),e.charCodeAt(y)===91)){E(21,o,L(y+1)),b(8);continue}}if(zr(v)){let M=o+1;for(;zr(e.charCodeAt(M));)M++;E(25,o,M);continue}if(v>=128){let M=o+1;for(;e.charCodeAt(M)>=128;)M++;E(26,o,M);continue}if(Et(v)){let M=o+1;for(;Et(e.charCodeAt(M));)M++;E(37,o,M);continue}if(Ih[v]!==0){E(Ih[v],o,o+1);continue}break}return o<t?(n.push(1),r.push(""),i.push(o),{types:n,texts:r,starts:i}):(a<Nh.length&&(n.push(Nh[a]),r.push(""),i.push(t)),n.push(0),r.push(""),i.push(t),{types:n,texts:r,starts:i})}function zl(...e){let t=new Uint8Array(42);for(let n of e)t[n]=1;return t}var k0=zl(40,35,37,25,29,28,30,31,34,32,33,26),$0=zl(25,37,36,29,27,35,32,31,26),kh=zl(25,37,27,38,32,36),L0=zl(2,39,41),cI=["setQuadrant1Text","setQuadrant2Text","setQuadrant3Text","setQuadrant4Text"],lI="'STR', 'MD_STR', 'ALPHA', 'NUM', 'UNICODE_TEXT', 'PUNCTUATION'";function O0(e,t){let{types:n,texts:r,starts:i}=I0(e),s=0,a=h=>{let d=n[s];throw d===1?ut("quadrantChart",e,i[s],"",!0):ut("quadrantChart",e,i[s],`Expecting ${h}, got '${Ch[d]}'`)},o=h=>(n[s]!==h&&a(`'${Ch[h]}'`),r[s++]),c=h=>h===19||h===18||k0[h]===1,l=()=>{let h=n[s];c(h)||a(lI);let d=r[s++];for(;k0[n[s]]===1||n[s]===38||n[s]===36;)d+=r[s++];return{text:d,type:h===18?"markdown":"text"}},u=()=>{let h=[];for(;;){kh[n[s]]===0&&a("'ALPHA', 'NUM', 'COLON', 'SPACE', 'BRKT', 'MINUS'");let d=r[s++];for(;kh[n[s]]===1;)d+=r[s++];if(h.push(d.trim()),n[s]!==29)return h;s++}};for(;L0[n[s]]===1||n[s]===38;)s++;for(o(24);n[s]!==0;){for(;n[s]===38;)s++;let h=n[s];switch(h){case 17:{s++,o(38),$0[n[s]]===0&&a("'ALPHA', 'NUM', 'UNICODE_TEXT'");let d=r[s++];for(;$0[n[s]]===1;)d+=r[s++];o(38),t.addClass(d,u());break}case 10:case 11:{s++;let d=l(),m;n[s]===12&&(s++,c(n[s])?m=l():d.text+=" ⟶ "),h===10?(t.setXAxisLeftText(d),m&&t.setXAxisRightText(m)):(t.setYAxisBottomText(d),m&&t.setYAxisTopText(m));break}case 13:case 14:case 15:case 16:s++,t[cI[h-13]](l());break;case 3:s++,t.setDiagramTitle(o(4).trim());break;case 5:s++,t.setAccTitle(o(6).trim());break;case 7:s++,t.setAccDescription(o(8).trim());break;case 9:t.setAccDescription(r[s++].trim());break;default:if(c(h)){let d=l(),m=n[s]===20?r[s++]:"";o(21);let p=o(22),y=o(23);t.addPoint(d,m,p,y,kh[n[s]]===1?u():[])}}L0[n[s]]===0&&a("'NEWLINE', 'SEMI', 'EOF'"),s++}}var D0=4,dI=300;function Vl(e,t){return e.quadrantChart?.[t]}function ns(e,t,n,r){let i=Vl(e,t);return typeof i=="number"&&i>=0?Math.min(i,r):n}function Ca(e,t,n){let r=Vl(e,t);return typeof r=="number"&&Number.isFinite(r)?Math.min(72,Math.max(4,r)):n}function v0(e){return e.startsWith("#")?e:"#"+e}function P0(e,t,n){let r=n.fontSize??16,i=Ca(t,"titleFontSize",r),s=Ca(t,"quadrantLabelFontSize",r),a=Ca(t,"xAxisLabelFontSize",Math.round(r*.875)),o=Ca(t,"yAxisLabelFontSize",Math.round(r*.875)),c=Ca(t,"pointLabelFontSize",Math.round(r*.75)),l=(P,ee)=>P===ee?"":` font-size="${P}"`,u=n.measurer??at(n.fontFamily,n.fontFamilyMono),h=Math.round(Math.max(100,ns(t,"chartWidth",500,4e3))),d=Math.round(ms(n,h,280)),m=Math.round(Math.max(100,ns(t,"chartHeight",500,4e3))*d/h),p=ns(t,"quadrantPadding",n.padding??8,200),y=ns(t,"xAxisLabelPadding",5,200),E=ns(t,"yAxisLabelPadding",5,200),b=e.points.length>0,S=(P,ee,ae)=>Ue(P?.text,P?.type==="markdown",u,ee,Math.max(ae,40)),x=Ue(e.title,!1,u,i,Math.max(d-2*p,40),1),I=ns(t,"titlePadding",10,200),L=x.height>0?x.height+I:0,O=!!(e.xAxisLeft?.text||e.xAxisRight?.text),v=!!(e.yAxisBottom?.text||e.yAxisTop?.text),G=b||Vl(t,"xAxisPosition")==="bottom",K=Vl(t,"yAxisPosition")==="right",C=d-2*p,Z=S(e.xAxisLeft,a,e.xAxisRight?C/2-16:C),oe=S(e.xAxisRight,a,C/2-16),H=Math.max(Z.height,oe.height),z=O?H+y:0,M=m-2*p-L-z,T=S(e.yAxisBottom,o,e.yAxisTop?M/2-16:M),R=S(e.yAxisTop,o,M/2-16),_=Math.max(T.height,R.height),$=v?_+E:0,g=p+(K?0:$),N=p+L+(G?0:z),w=Math.max(0,C-$),A=Math.max(0,M),D=Math.max(0,(w-D0)/2),U=Math.max(0,(A-D0)/2),B=[g+D,N,g+w-D,N+A,g,N+U,g+w,N+A-U],F=(P,ee,ae,ue,ce)=>{for(let he=P;he<B.length;he+=4)if(!(B[he]>=B[he+2]||B[he+1]>=B[he+3])&&ee<B[he+2]&&ue>B[he]&&ae<B[he+3]&&ce>B[he+1])return!1;return!0},W=ns(t,"quadrantTextTopPadding",5,200),j="";for(let P=0;P<4;P++){let ee=P===0||P===3?g+w-D:g,ae=P<2?N:N+A-U,ue=S(e.quadrants[P],s,D-16),ce=ee+D/2,he=b?ae+W+ue.height/2:ae+U/2;B.push(ce-ue.width/2,he-ue.height/2,ce+ue.width/2,he+ue.height/2),j+=`<g class="pele-quadrant" data-id="${P+1}"><rect x="${f(ee)}" y="${f(ae)}" width="${f(D)}" height="${f(U)}"${ft}/>`+Ce(ue,ce,he,` class="pele-label"${l(s,r)} fill="var(--_fg)" stroke="none"`)+"</g>"}let Q="";if(O){let P=G?N+A+y+H/2:N-y-H/2;Q+=Ce(Z,oe.height>0?g+w/4:g+Z.width/2,P,"")+Ce(oe,g+w*3/4,P,"")}if(v){let P=K?g+w+E+_/2:g-E-_/2,ee=(ae,ue)=>ae.height>0?`<g transform="translate(${f(P)},${f(ue)}) rotate(-90)"${l(o,a)}>${Ce(ae,0,0,"")}</g>`:"";Q+=ee(T,R.height>0?N+A*3/4:N+A-T.width/2)+ee(R,N+A/4)}let Y=ns(t,"pointRadius",5,200),ne=ns(t,"pointTextPadding",5,200),q=yt(0),k=[],J=[];for(let P of e.points){if(!(P.x>=0&&P.x<=1&&P.y>=0&&P.y<=1))continue;let ee=e.classes.get(P.className),ae=Math.min(P.radius??ee?.radius??Y,2e3),ue=P.color??ee?.color,ce=P.strokeColor??ee?.strokeColor,he=P.strokeWidth??ee?.strokeWidth,V=[];ue&&V.push("fill:"+v0(ue)),he&&(ce&&V.push("stroke:"+v0(ce)),V.push("stroke-width:"+he));let X=g+P.x*w,le=N+(1-P.y)*A;k.push({cx:X,cy:le,reach:ae+(he?Math.min(parseInt(he),400)/2:0),text:S(P.text,c,w)}),J.push(`<circle class="pele-point${Nt(P.className)}" data-id="${We(P.text.text)}" cx="${f(X)}" cy="${f(le)}" r="${f(ae)}"${he&&!ce?` stroke="${q}"`:""}${Mt(V).shape}/>`)}let te=k.length<=dI;if(te)for(let{cx:P,cy:ee,reach:ae}of k)B.push(P-ae,ee-ae,P+ae,ee+ae);let se="";for(let{cx:P,cy:ee,reach:ae,text:ue}of k){let ce=ue.width/2,he=ue.size*.6+(ue.height-ue.lineHeight)/2,V=ae+ne,X=Math.min(V,Math.max(0,(D-ue.width)/2)),le=8+4*(P<g+w/2?ee<N+A/2?1:2:ee<N+A/2?0:3),de=Math.max(ee+V,B[le+3]+ne)+he,Ae=[P,ee+V+he,P,ee-V-he,P+V+ce,ee,P-V-ce,ee,P,de],we=P,Ee=Ae[1],Te=!1;for(let Me=0;Me<20;Me+=2){let Ie=Me%10,ge=Ie===8?X:0,xe=(Ie<4||Ie===8)&&ue.width<w?Math.min(Math.max(Ae[Ie],g+ce+ge),g+w-ce-ge):Ae[Ie],ie=Ae[Ie+1];if(xe-ce<g||xe+ce>g+w||ie-he<N||ie+he>N+A)continue;let pe=!te||F(Me<10?0:8,xe-ce,ie-he,xe+ce,ie+he);if((!Te||pe)&&(we=xe,Ee=ie,Te=!0),pe)break}te&&B.push(we-ce,Ee-he,we+ce,Ee+he),se+=Ce(ue,we,Ee,' class="pele-label"')}let re=Ce(x,d/2,I/2+x.height/2,` class="pele-title"${l(i,r)} font-weight="var(--_tw)"`)+`<g class="pele-quadrants" fill="var(--_s)" stroke="var(--_b)">${j}</g>`+(Q?`<g class="pele-axis-labels" font-size="${a}" fill="var(--_m)">${Q}</g>`:"")+(k.length>0?`<g class="pele-points" fill="${q}">${J.reverse().join("")}</g><g class="pele-point-labels" font-size="${c}">${se}</g>`:"");return{svg:ot("quadrantChart",d,m,r,n,e,re),width:d,height:m,links:[]}}var F0={type:"quadrantChart",parse(e,t,n){let r=new Kl;return r.title=n,O0(e,r),r},render:P0};var B0=32;function W0(e){return new qe(e,"semantic",{type:"radar"})}function U0(e,t){let n=e.axes.map(s=>({name:s.name,label:s.label??s.name})),r=e.curves.map(s=>{let a;if(s.entries[0].axis===void 0)a=s.entries.map(o=>o.value);else{if(n.length===0)throw W0("Axes must be populated before curves for reference entries");let o=new Map;for(let c of s.entries)c.axis!==void 0&&!o.has(c.axis.$refText)&&o.set(c.axis.$refText,c.value);a=n.map(c=>{let l=o.get(c.name);if(l===void 0)throw W0("Missing entry for axis "+c.label);return l})}return{name:s.name,label:s.label??s.name,entries:a}}),i={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"};for(let s of e.options)s.name==="showLegend"?i.showLegend=s.value:s.name==="graticule"?i.graticule=s.value:i[s.name]=s.value;return i.ticks>B0&&(i.ticks=B0),{type:"radar",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
107
+ `):void 0,axes:n,curves:r,options:i}}var Oh=0,jl=0;function G0(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function uI(e,t){(t<Oh||t>=jl)&&(Oh=t,jl=G0(e,t));let n=jl;if(n===t)return-1;let r=e.charCodeAt(n)===46;if(r){let i=G0(e,n+1),s=i-n-1;if(s>0&&e.charCodeAt(i)!==46)return i;if(s>1)return i-1}return e.charCodeAt(t)===48?t+1:r?n-1>t?n-1:-1:n}var $h=rn.pattern,Lh=/[\t ]*accDescr\s*{/y,Xl=-2;function fI(e,t){return Lh.lastIndex=t,Lh.test(e)&&(Xl===-2&&(Xl=e.lastIndexOf("}")),Lh.lastIndex>Xl)?-1:($h.lastIndex=t,$h.test(e)?$h.lastIndex:-1)}var Dh={name:"ID",pattern:/[\w]([-\w]*\w)?/y},Y0=/[-\w]*\w/y;function H0(e,t){return(n,r,i)=>{if(e.lastIndex=r,!e.test(n))return-1;let s=e.lastIndex;return i===t?s:(Y0.lastIndex=s,Y0.test(n)?-1:s)}}var ci=e=>({name:e,pattern:e,longer:[Dh]}),li=e=>({name:e,pattern:e}),K0=[li("radar-beta:"),{...Zt("radar-beta"),longer:[Dh]},ci("showLegend"),ci("graticule"),ci("curve"),ci("ticks"),ci("axis"),ci("max"),ci("min"),li(":"),li(","),li("["),li("]"),li("{"),li("}"),{name:"GRATICULE",pattern:/circle|polygon/y,match:H0(/circle|polygon/y,3)},{name:"BOOLEAN",pattern:/true|false/y,match:H0(/true|false/y,2)},{...rn,match:fI},jt,Jn(String.raw`[-\w]*\w`),{name:"NUMBER",pattern:/(?:[0-9]+\.[0-9]+(?!\.))|(?:0|[1-9][0-9]*(?!\.))/y,match:uI},Pn,Dh,An,Sn,Yt,qt,Qt];function hI(e){return Oh=jl=0,Xl=-2,Gt(e,K0,"radar")}function z0(e){let t=new Wt(hI(e),K0,"radar"),n={$type:"Radar",axes:[],curves:[],options:[]},r=()=>{for(;t.kind===23;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==23&&t.fail("a line break or the end of input"),r())},s=()=>{if(!t.accept(11))return;let h=dn(t.expect(21));return t.expect(12),h},a=h=>{if(!h)return{$type:"Entry",value:Number(t.expect(20))};let d={$refText:t.expect(22)};return t.accept(9),{$type:"Entry",axis:d,value:Number(t.expect(20))}},o=()=>{let h=t.expect(22),d=s(),m={$type:"Curve",name:h,entries:[]};d!==void 0&&(m.label=d),t.expect(13),r(),t.kind!==20&&t.kind!==22&&t.fail("a number or an axis name");let p=t.kind===22;for(m.entries.push(a(p));t.accept(10);)r(),m.entries.push(a(p));return r(),t.expect(14),m},c=()=>{let h={$type:"Axis",name:t.expect(22)},d=s();return d!==void 0&&(h.label=d),h},l=()=>{let h=t.kind,d=t.take(),m;return h===2?m=t.expect(16)==="true":h===3?m=t.expect(15):m=Number(t.expect(20)),{$type:"Option",name:d,value:m}},u=()=>t.kind===2||t.kind===5||t.kind===7||t.kind===8||t.kind===3;for(r(),t.accept(0)||(t.expect(1),t.accept(9)),r();t.kind!==-1;)switch(t.kind){case 23:t.i++;break;case 17:n.accDescr=zt(t.take()),i();break;case 18:n.accTitle=Kt(t.take()),i();break;case 19:n.title=Ht(t.take()),i();break;case 6:t.i++;do n.axes.push(c());while(t.accept(10));break;case 4:t.i++;do n.curves.push(o());while(t.accept(10));break;default:for(u()||t.fail("an axis, a curve, an option, a title, or a line break"),n.options.push(l());t.accept(10);)u()||t.fail("an option"),n.options.push(l())}return n}var ao=12,vh=26,V0=24;function rs(e,t,n,r,i){let s=e.radar?.[t];return typeof s=="number"&&s>=r?Math.min(s,i):n}function pI(e,t,n,r){let i=Math.min(Math.max(e,t),n),s=r*(i-t);return Number.isFinite(s)?s/(n-t):r*((i-t)/(n-t))}function mI(e,t){let n=e.length,r=`M${f(e[0].x)},${f(e[0].y)}`;for(let i=0;i<n;i++){let s=e[(i-1+n)%n],a=e[i],o=e[(i+1)%n],c=e[(i+2)%n];r+=` C${f(a.x+(o.x-s.x)*t)},${f(a.y+(o.y-s.y)*t)} ${f(o.x-(c.x-a.x)*t)},${f(o.y-(c.y-a.y)*t)} ${f(o.x)},${f(o.y)}`}return r+" Z"}function j0(e){let t="";for(let n of e)t+=(t?" ":"")+f(n.x)+","+f(n.y);return t}function X0(e,t,n){let r=rs(t,"width",320,1,4e3);return ps(n,r,160,(i,s)=>gI(e,t,n,i,rs(t,"height",320,1,4e3)*i/r,s))}function gI(e,t,n,r,i,s){let a=n.fontSize??16,o=Math.round(a*.875),c=n.measurer??at(n.fontFamily,n.fontFamilyMono),l=n.padding??8,u=rs(t,"axisScaleFactor",1,0,10),h=rs(t,"axisLabelFactor",1.05,0,10),d=rs(t,"curveTension",.17,0,1),m=Math.min(r,i)/2,{axes:p,curves:y}=e,{ticks:E,graticule:b,min:S}=e.options,x=p.length,I=p.map((F,W)=>{let j=2*Math.PI*W/x-Math.PI/2;return{x:Math.cos(j),y:Math.sin(j)}}),L=e.options.max;if(L===null){L=-1/0;for(let F of y)for(let W of F.entries)W>L&&(L=W)}let O=-r/2-rs(t,"marginLeft",16,0,2e3),v=r/2+rs(t,"marginRight",16,0,2e3),G=-i/2-rs(t,"marginTop",16,0,2e3),K=i/2+rs(t,"marginBottom",16,0,2e3),C="";for(let F=0;F<E;F++){let W=Math.min(m,m*(F+1)/E);b==="circle"?C+=`<circle r="${f(W)}"/>`:C+=`<polygon points="${j0(I.map(j=>({x:j.x*W,y:j.y*W})))}"/>`}let Z="",oe="";I.forEach((F,W)=>{let j=m*u;Z+=`M0,0L${f(F.x*j)},${f(F.y*j)}`;let Q=Ue(p[W].label,!1,c,o,4e3),Y=m*h+6,ne=F.x*Y+(F.x>.01?Q.width/2:F.x<-.01?-Q.width/2:0),q=F.y*Y+(F.y>.01?Q.height/2:F.y<-.01?-Q.height/2:0);oe+=`<g class="pele-axis-label" data-id="${We(p[W].name)}">${Ce(Q,ne,q,"")}</g>`,O=Math.min(O,ne-Q.width/2),v=Math.max(v,ne+Q.width/2),G=Math.min(G,q-Q.height/2),K=Math.max(K,q+Q.height/2)});let H="";y.forEach((F,W)=>{if(F.entries.length!==x)return;let j=F.entries.map((ne,q)=>{let k=pI(ne,S,L,m),J=Number.isFinite(k)?k:0;return{x:I[q].x*J,y:I[q].y*J}}),Q=yt(W),Y=` class="pele-curve" data-id="${We(F.name)}" fill="${Q}" stroke="${Q}"`;H+=b==="circle"?`<path${Y} d="${mI(j,d)}"/>`:`<polygon${Y} points="${j0(j)}"/>`});let z=e.options.showLegend?y.map(F=>Ue(F.label,!1,c,o,4e3)):[],M=0;for(let F of z)M=Math.max(M,F.width);let T=z.length*vh,R=s?-(ao+8+M)/2:v+V0,_=s?K+V0/2:-T/2;z.length>0&&s?(O=Math.min(O,R),v=Math.max(v,-R),K=_+T):z.length>0&&(v=R+ao+8+M,G=Math.min(G,-T/2),K=Math.max(K,T/2));let $="";z.forEach((F,W)=>{let j=_+W*vh+vh/2,Q=yt(W);$+=`<g class="pele-legend-item" data-id="${We(y[W].name)}"><rect x="${f(R)}" y="${f(j-ao/2)}" width="${ao}" height="${ao}" rx="2" fill="${Q}" fill-opacity="0.4" stroke="${Q}"/>`+Ce(F,R+ao+8+F.width/2,j,"")+"</g>"});let g=Ue(e.title,!1,c,a,It(n),1),N=g.height>0?g.height+8:0,w=Math.max(v-O,g.width),A=Math.ceil(w+2*l),D=Math.ceil(K-G+N+2*l),U=`translate(${f(l+(w-(v-O))/2-O)},${f(l+N-G)})`,B=Ce(g,A/2,l+g.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="${U}">`+(C?`<g class="pele-graticule" fill="none" stroke="var(--_a)">${C}</g>`:"")+(Z?`<path class="pele-axes" d="${Z}" fill="none" stroke="var(--_b)"/>`:"")+(H?`<g class="pele-curves" fill-opacity="0.2" stroke-width="1.5" stroke-linejoin="round">${H}</g>`:"")+(oe?`<g class="pele-axis-labels" font-size="${o}">${oe}</g>`:"")+($?`<g class="pele-legend" font-size="${o}">${$}</g>`:"")+"</g>";return{svg:ot("radar",A,D,a,n,e,B),width:A,height:D,links:[]}}var q0={type:"radar",parse:(e,t,n)=>U0(z0(e),n),render:X0};function Ph(e){return e===32||e>=9&&e<=13||e>127&&/\s/.test(String.fromCharCode(e))}function bI(){let e=1/0;return(t,n)=>{if(!t.startsWith("accDescr",n))return-1;let r=t.length,i=n+8;for(;i<r&&(t.charCodeAt(i)===32||t.charCodeAt(i)===9);)i++;if(t.charCodeAt(i)===58){for(i++;i<r;i++){let a=t.charCodeAt(i);if(a===10||a===13||a===37&&t.charCodeAt(i+1)===37)break}return i}for(;i<r&&Ph(t.charCodeAt(i));)i++;if(t.charCodeAt(i)!==123||i>=e)return-1;let s=t.indexOf("}",i+1);return s===-1&&(e=i),s+1||-1}}var Fh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function _s(e){return{name:"TITLE",pattern:new RegExp(String.raw`title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|(?!${e}))`,"y"),first:"t"}}var Rs={name:"ACC_TITLE",pattern:/accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"a"},Ts={name:"ACC_DESCR",pattern:/accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"a",scanner:bI};function At(e,t){return{name:e,pattern:e,longer:t}}function Ms(e,t){return{...Zt(e),longer:[t]}}function co(e){return{name:e,pattern:/[A-Z_a-z][\w-]*/y,first:Fh+"_"}}function lo(e){return{name:e,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`}}function Cs(e){return[{name:e+"_WHITESPACE",pattern:/[\t \r\n]+/y,hidden:!0,first:` \r
108
+ `},{...Yt,name:e+"_YAML",first:"-"},{...qt,name:e+"_DIRECTIVE",first:" %"},{...Qt,name:e+"_SINGLE_LINE_COMMENT",first:" %"}]}function ss(e){if(!e.includes("\\"))return e.slice(1,-1);let t=e.length-1,n="";for(let r=1;r<t;r++){let i=e[r];i==="\\"&&r+1<t?(i=e[++r],n+=i==="n"?`
109
+ `:i==="r"?"\r":i==="t"?" ":i):n+=i}return n}function Ns(e,t,n,r,i,s){let a=new Wt(Gt(e,t,"railroad"),t,"railroad"),o={$type:n,rules:[]};for(a.expect(0);;){let c=a.kind;if(c===r){let l=Ht(a.take()),u=l[0];o.title=(u==='"'||u==="'")&&l.endsWith(u)?i(l):l}else if(c===r+1)o.accTitle=Kt(a.take());else if(c===r+2)o.accDescr=zt(a.take());else break}for(;a.kind!==-1;)o.rules.push(s(a));return o}var Bh=[];function ql(e){let t=e,n=t.element??t.primary??t.suffix,r=t.alternatives??t.elements??(n?[n]:Bh);if(t.base){r=[t.base];for(let i of t.postfixes)i.except&&r.push(i.except)}return r}var is=e=>({type:"terminal",value:e}),Is=e=>({type:"nonterminal",name:e}),di=e=>({type:"special",text:e}),Ur=e=>({type:"optional",element:e}),os=(e,t,n=1/0)=>({type:"repetition",element:e,min:t,max:n});function ks(e){return e.length===1?e[0]:{type:"sequence",elements:e}}function $s(e){return e.length===1?e[0]:{type:"choice",alternatives:e}}function Ls(e,t){return e.rules.map(n=>({name:n.name,definition:Wh(n.definition,ql,t)}))}function Wh(e,t,n){let r=[e],i=[t(e)],s=[[]];for(;;){let a=r.length-1,o=s[a];if(o.length<i[a].length){let c=i[a][o.length];r.push(c),i.push(t(c)),s.push([])}else{let c=n(r[a],o);if(a===0)return c;r.pop(),i.pop(),s.pop(),s[a-1].push(c)}}}var Q0="0123456789",Z0={name:"ABNF_RULENAME",pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:Fh},J0={name:"ABNF_COMMENT",pattern:/;[^\n\r]*/y,hidden:!0,first:";"},tx=[Ms("railroad-abnf-beta",Z0),At("="),At(";",[J0]),At("/"),At("("),At(")"),At("["),At("]"),_s(String.raw`[A-Za-z0-9-]`),Rs,Ts,Z0,{name:"ABNF_STRING",pattern:/"[^"]*"/y,first:'"'},{name:"ABNF_NUMVAL",pattern:/%[xXdDbB][0-9A-Fa-f]+(?:-[0-9A-Fa-f]+|\.[0-9A-Fa-f]+)*/y,first:"%"},{name:"ABNF_REPEAT",pattern:/[0-9]*\*[0-9]*/y,first:Q0+"*"},{name:"ABNF_EXACT_REPEAT",pattern:/[0-9]+/y,first:Q0},...Cs("ABNF"),J0];function ex(e,t,n,r){let i={$type:"AbnfConcatenation",elements:[]};return t.alternatives.push(i),{alternation:t,concatenation:i,node:e,close:n,repeat:r}}function yI(e){let t=[],n=ex(void 0,{$type:"AbnfAlternation",alternatives:[]},-2,void 0);for(;;){let r=e.kind===14||e.kind===15?e.take():void 0,i,s=e.kind;switch(s){case 12:i={$type:"AbnfStringLiteral",value:e.take().slice(1,-1)};break;case 13:i={$type:"AbnfNumVal",value:e.take()};break;case 11:i={$type:"AbnfRuleName",name:e.take()};break;case 4:case 6:{e.i++;let a={$type:"AbnfAlternation",alternatives:[]};t.push(n),n=ex({$type:s===4?"AbnfGroup":"AbnfOptionalGroup",element:a},a,s+1,r);continue}default:e.fail("a string, a number, a name, or an opening bracket")}for(;;){n.concatenation.elements.push(r===void 0?{$type:"AbnfElement",primary:i}:{$type:"AbnfElement",repeat:r,primary:i});let a=e.kind;if(a===n.close){e.i++,i=n.node,r=n.repeat,n=t.pop();continue}if(a===3)e.i++,n.concatenation={$type:"AbnfConcatenation",elements:[]},n.alternation.alternatives.push(n.concatenation);else if(a!==12&&a!==13&&a!==11&&a!==4&&a!==6&&a!==14&&a!==15){if(t.length===0)return n.alternation;e.fail(`token of type '${tx[n.close].name}'`)}break}}}function nx(e){return Ns(e,tx,"RailroadAbnf",8,t=>t.slice(1,-1),t=>{let n=t.expect(11);t.expect(1);let r=yI(t);return t.expect(2),{$type:"AbnfRule",name:n,definition:r}})}function EI(e,t){switch(e.$type){case"AbnfAlternation":return $s(t);case"AbnfConcatenation":return ks(t);case"AbnfElement":{let n=e.repeat;if(!n)return t[0];let r=n.indexOf("*"),i=r===-1,s=r>0||i?parseInt(n,10):0,a=i?s:r<n.length-1?parseInt(n.slice(r+1),10):1/0;return s===0&&a===1?Ur(t[0]):os(t[0],s,a)}case"AbnfStringLiteral":case"AbnfNumVal":return is(e.value);case"AbnfRuleName":return Is(e.name);case"AbnfGroup":return t[0];case"AbnfOptionalGroup":return Ur(t[0])}}var rx=e=>Ls(e,EI);function xI(e,t){if(e.charCodeAt(t)!==63)return-1;let n=!1;for(let r=t+1;r<e.length;r++){let i=e.charCodeAt(r);if(i===63)return n?r+1:-1;if(i===59)return-1;n||=!Ph(i)}return-1}var sx=co("EBNF_ID"),ix={name:"EBNF_SPECIAL_SEQUENCE",pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:"?",scanner:()=>xI},ox=Cs("EBNF"),ax={name:"EBNF_ISO_COMMENT",pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:"(",opener:/\(\*/y},lx=[Ms("railroad-ebnf-beta",sx),At("::="),At("="),At(";"),At("|"),At(","),At("(",[ax]),At(")"),At("["),At("]"),At("{"),At("}"),At("?",[ix]),At("*"),At("+"),At("-",[ox[1]]),_s(String.raw`[\w-]`),Rs,Ts,sx,lo("EBNF_STRING"),ix,...ox,{name:"EBNF_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y},ax];function cx(e,t,n,r){let i={$type:"EbnfSequence",elements:[]};return t.alternatives.push(i),{choice:t,sequence:i,term:void 0,node:e,close:n,except:r}}var AI=["EbnfGroup","EbnfOptional","EbnfRepetition"];function SI(e){let t=[],n=cx(void 0,{$type:"EbnfChoice",alternatives:[]},-2,!1),r=!1;for(;;){let i,s=e.kind;switch(s){case 20:i={$type:"EbnfTerminal",value:ss(e.take())};break;case 19:i={$type:"EbnfNonTerminal",name:e.take()};break;case 21:i={$type:"EbnfSpecial",text:e.take().slice(1,-1).trim()};break;case 6:case 8:case 10:{e.i++;let a={$type:"EbnfChoice",alternatives:[]};t.push(n),n=cx({$type:AI[s-6>>1],element:a},a,s+1,r),r=!1;continue}default:e.fail("a terminal, a name, or an opening bracket")}for(;;){r?(n.term.postfixes.push({$type:"EbnfExceptionPostfix",except:i}),r=!1):(n.term={$type:"EbnfTerm",base:i,postfixes:[]},n.sequence.elements.push(n.term));let a=n.term.postfixes;for(;;){let c=e.kind;if(c===12)a.push({$type:"EbnfOptionalPostfix",operator:e.take()});else if(c===13)a.push({$type:"EbnfZeroOrMorePostfix",operator:e.take()});else if(c===14)a.push({$type:"EbnfOneOrMorePostfix",operator:e.take()});else break}let o=e.kind;if(o===n.close){e.i++,i=n.node,r=n.except,n=t.pop();continue}if(o===15)e.i++,r=!0;else if(o===5)e.i++;else if(o===4)e.i++,n.sequence={$type:"EbnfSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(o!==20&&o!==19&&o!==21&&o!==6&&o!==8&&o!==10){if(t.length===0)return n.choice;e.fail(`token of type '${lx[n.close].name}'`)}break}}}function dx(e){return Ns(e,lx,"RailroadEbnf",16,ss,t=>{let n=t.expect(19);t.accept(2)||t.expect(1);let r={$type:"EbnfRule",name:n,definition:SI(t)};return t.expect(3),r})}function wI(e,t){switch(e.$type){case"EbnfChoice":return $s(t);case"EbnfSequence":return ks(t);case"EbnfTerm":{let n=t[0],r=1;for(let i of e.postfixes)i.$type==="EbnfOptionalPostfix"?n=Ur(n):i.$type==="EbnfExceptionPostfix"?n={type:"sequence",elements:[n,is("-"),t[r++]]}:n=os(n,i.$type==="EbnfOneOrMorePostfix"?1:0);return n}case"EbnfTerminal":return is(e.value);case"EbnfNonTerminal":return Is(e.name);case"EbnfSpecial":return di(e.text);case"EbnfGroup":return t[0];case"EbnfOptional":return Ur(t[0]);case"EbnfRepetition":return os(t[0],0)}}var ux=e=>Ls(e,wI);var Yh=co("RR_ID"),Os=e=>At(e,[Yh]),_I=[Ms("railroad-beta",Yh),Os("nonterminal"),Os("zeroOrMore"),Os("oneOrMore"),Os("sequence"),Os("optional"),Os("terminal"),Os("special"),Os("choice"),At("="),At(";"),At("("),At(","),At(")"),_s(String.raw`[\w-]`),Rs,Ts,Yh,lo("RR_STRING"),...Cs("RR"),{name:"RR_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y}];function Uh(e){e.i++,e.expect(11);let t=ss(e.expect(18));return e.expect(13),t}function Gh(e){return{$type:e,element:void 0}}function RI(e){let t=[];for(;;){let n;switch(e.kind){case 6:n={$type:"RailroadTerminalExpr",value:Uh(e)};break;case 1:n={$type:"RailroadNonTerminalExpr",name:Uh(e)};break;case 7:n={$type:"RailroadSpecialExpr",text:Uh(e)};break;case 4:n={$type:"RailroadSequenceExpr",elements:[]};break;case 8:n={$type:"RailroadChoiceExpr",alternatives:[]};break;case 5:n=Gh("RailroadOptionalExpr");break;case 3:n=Gh("RailroadOneOrMoreExpr");break;case 2:n=Gh("RailroadZeroOrMoreExpr");break;default:e.fail("an expression")}if("elements"in n||"alternatives"in n||"element"in n){e.i++,e.expect(11),t.push(n);continue}for(;;){let r=t[t.length-1];if(r===void 0)return n;if("element"in r)r.element=n;else if(("elements"in r?r.elements:r.alternatives).push(n),e.accept(12))break;e.expect(13),t.pop(),n=r}}}function fx(e){return Ns(e,_I,"Railroad",14,ss,t=>{let n=t.expect(17);t.expect(9);let r=RI(t);return t.expect(10),{$type:"RailroadRule",name:n,definition:r}})}function TI(e,t){switch(e.$type){case"RailroadTerminalExpr":return is(e.value);case"RailroadNonTerminalExpr":return Is(e.name);case"RailroadSpecialExpr":return di(e.text);case"RailroadSequenceExpr":return ks(t);case"RailroadChoiceExpr":return $s(t);case"RailroadOptionalExpr":return Ur(t[0]);default:return os(t[0],e.$type==="RailroadOneOrMoreExpr"?1:0)}}var hx=e=>Ls(e,TI);var px=co("PEG_ID"),MI=[Ms("railroad-peg-beta",px),At("<-"),At(";"),At("/"),At("&"),At("!"),At("?"),At("*"),At("+"),At("("),At(")"),At("."),_s(String.raw`[\w-]`),Rs,Ts,px,lo("PEG_STRING"),...Cs("PEG"),{name:"PEG_LINE_COMMENT",pattern:/#[^\n\r]*/y,hidden:!0,first:"#"}];function mx(e,t,n){let r={$type:"PegSequence",elements:[]};return t.alternatives.push(r),{choice:t,sequence:r,node:e,operator:n}}function CI(e){let t=[],n=mx(void 0,{$type:"PegOrderedChoice",alternatives:[]},void 0);for(;;){let r=e.kind===4||e.kind===5?e.take():void 0,i;switch(e.kind){case 16:i={$type:"PegLiteral",value:ss(e.take())};break;case 15:i={$type:"PegIdentifier",name:e.take()};break;case 11:i={$type:"PegAny",dot:e.take()};break;case 9:{e.i++;let a={$type:"PegOrderedChoice",alternatives:[]};t.push(n),n=mx({$type:"PegGroup",element:a},a,r);continue}default:e.fail("a literal, a name, a dot, or an opening parenthesis")}for(;;){let a={$type:"PegSuffix",primary:i};(e.kind===6||e.kind===7||e.kind===8)&&(a.operator=e.take()),n.sequence.elements.push(r===void 0?{$type:"PegPrefix",suffix:a}:{$type:"PegPrefix",operator:r,suffix:a});let o=e.kind;if(o===10&&t.length>0){e.i++,i=n.node,r=n.operator,n=t.pop();continue}if(o===3)e.i++,n.sequence={$type:"PegSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(o!==4&&o!==5&&o!==16&&o!==15&&o!==11&&o!==9){if(t.length===0)return n.choice;e.fail("token of type ')'")}break}}}function gx(e){return Ns(e,MI,"RailroadPeg",12,ss,t=>{let n=t.expect(15);t.expect(1);let r={$type:"PegRule",name:n,definition:CI(t)};return t.expect(2),r})}function NI(e){switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}}function II(e,t){let n=t[0];switch(e.$type){case"PegOrderedChoice":return $s(t);case"PegSequence":return ks(t);case"PegPrefix":return e.operator?di(e.operator+NI(n)):n;case"PegSuffix":return e.operator?e.operator==="?"?Ur(n):os(n,e.operator==="+"?1:0):n;case"PegLiteral":return is(e.value);case"PegIdentifier":return Is(e.name);case"PegAny":return di(e.dot);case"PegGroup":return n}}var bx=e=>Ls(e,II);var Hh=class{type="railroad";notation="railroad";title;accTitle;accDescr;rules=[];byName=new Map;setTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
110
+ `)}addRule(t){this.rules.push(t),this.byName.set(t.name,t)}getRule(t){return this.byName.get(t)}},kI=/^\s*railroad-(ebnf-|abnf-|peg-)?beta/i;function $I(e){let t=kI.exec(e);if(t===null)return;let n=t[1]?.toLowerCase();return n==="ebnf-"?"ebnf":n==="abnf-"?"abnf":n==="peg-"?"peg":"railroad"}function LI(e,t){switch(t){case"ebnf":{let n=dx(e);return[n,ux(n)]}case"abnf":{let n=nx(e);return[n,rx(n)]}case"peg":{let n=gx(e);return[n,bx(n)]}default:{let n=fx(e);return[n,hx(n)]}}}function OI(e,t,n){let[r,i]=LI(t,n);e.notation=n,r.accDescr&&e.setAccDescription(r.accDescr),r.accTitle&&e.setAccTitle(r.accTitle),r.title&&e.setTitle(r.title);for(let s of i)e.addRule(s)}function yx(e,t){let n=$I(e);if(n===void 0)throw new qe("No railroad diagram keyword found.","syntax",{type:"railroad"});let r=new Hh;return t&&(r.title=t),OI(r,e,n),r}var Kh=12,DI=6,vI=18,Jl=12,yr=7;function ui(e,t,n,r){let i=e.railroad?.[t];return typeof i=="number"&&i>=0?Math.min(i,r):n}var PI=/[\n\r\t]/g;function Zl(e){return(e.includes("¶ß")?gt(e.replace(/&/g,"&amp;")):e).replace(PI,n=>n===`
111
+ `?"\\n":n==="\r"?"\\r":"\\t")}function Ql(e,t){for(let n=t,r=e.length-1;n<r;n++,r--){let i=e[n];e[n]=e[r],e[r]=i}}function Vh(e){return Math.ceil(e/2)*2}function zh(e,t,n,r,i){let s=i.height/2,a=Math.max(Vh(i.measurer.width(t,i.size,r)+2*i.padding),i.height);return{kind:e,width:a,up:s,down:s,kids:Bh,text:t,id:n,reach:0}}function FI(e,t){if(t===1/0&&e<=1)return"";let n=r=>Number.isFinite(r)?String(r):"∞";return e===t?n(e)+"×":t===1/0?"≥"+n(e)+"×":e===0?"≤"+n(t)+"×":n(e)+"–"+n(t)+"×"}function xx(e,t,n,r){return Math.max(e+t.down+r.sep+n.up,2*r.arc)}function Ex(e,t){let n=Math.max(e.up+t.sep,2*t.arc);return{kind:5,width:e.width+4*t.arc,up:n,down:e.down,kids:[e],text:"",id:"",reach:n}}function BI(e,t,n=1/0){let r=new Map,i=[[e,n]];for(let s=0;n!==1/0&&s<i.length;s++){let[a,o]=i[s];r.set(a,o);let c=a.type==="choice"||a.type==="optional"?4*t.arc:a.type==="repetition"?(a.min===0?6:2)*t.arc:a.type==="sequence"?6*t.arc:0;for(let l of ql(a))i.push([l,Math.max(40,o-c)])}return Wh(e,ql,(s,a)=>{let o=r.get(s)??1/0;switch(s.type){case"terminal":{let c=Zl(s.value);return zh(0,/^ +$/.test(c)?"␣".repeat(c.length):c,"",4,t)}case"nonterminal":return zh(1,Zl(s.name),s.name,0,t);case"special":return zh(2,"? "+Zl(s.text)+" ?","",2,t);case"sequence":{let c=Math.max(0,a.length-1)*t.gap,l=0,u=0;for(let S of a)c+=S.width,l=Math.max(l,S.up),u=Math.max(u,S.down);let h={kind:3,width:c,up:l,down:u,kids:a,text:"",id:"",reach:0};if(c<=o||a.length<2)return h;let d=[],m=[],p=0,y=()=>{let S=0,x=0;for(let I of m)S=Math.max(S,I.up),x=Math.max(x,I.down);d.push({kind:3,width:p,up:S,down:x,kids:m,text:"",id:"",reach:0}),m=[],p=0};for(let S of a)m.length&&p+t.gap+S.width>Math.max(40,o-6*t.arc)&&y(),p+=(m.length?t.gap:0)+S.width,m.push(S);if(y(),d.length<2)return h;let E=0,b=0;for(let S=0;S<d.length;S++)E=Math.max(E,d[S].width),S&&(b+=d[S-1].down+Math.max(t.sep,2*t.arc)+d[S].up);return{kind:7,width:E+6*t.arc,up:d[0].up,down:b+d[d.length-1].down,kids:d,text:"",id:"",reach:0}}case"choice":{let c=0,l=0;for(let h=0;h<a.length;h++)c=Math.max(c,a[h].width),h>0&&(l=xx(l,a[h-1],a[h],t));let u=a[a.length-1];return{kind:4,width:c+4*t.arc,up:a.length>0?a[0].up:0,down:u?l+u.down:0,kids:a,text:"",id:"",reach:0}}case"optional":return Ex(a[0],t);case"repetition":{let{min:c,max:l}=s,u=a[0];if(c===1&&l===1)return u;let h=FI(c,l),d=Math.max(u.down+t.sep,2*t.arc),m=h===""?0:Vh(t.measurer.width(h,Jl,0)),p={kind:6,width:Math.max(u.width,m)+2*t.arc,up:u.up,down:d+(h===""?yr/2+1:Jl+6),kids:[u],text:h,id:"",reach:d};return c===0?Ex(p,t):p}}})}function Ax(e,t,n){return xn(n,r=>WI(e,t,n,r))}function WI(e,t,n,r){let i=n.fontSize??16,s=ui(t,"fontSize",0,200),a=s||Math.round(i*.875),o=s||i,c=ui(t,"padding",-1,200),l=Math.round(a*1.5),u={measurer:n.measurer??at(n.fontFamily,n.fontFamilyMono),size:a,padding:c<0?12:c,height:Vh(l+(c<0?9:2*c)),gap:Math.min(ui(t,"horizontalSeparation",16,500),r?12:1/0),sep:ui(t,"verticalSeparation",10,500),arc:Math.min(ui(t,"arcRadius",10,200),r?6:1/0)},h=t.railroad?.showMarkers===!1?0:ui(t,"markerRadius",4,50),d=ui(t,"strokeWidth",0,20),m=d>0?` stroke-width="${f(d)}"`:"",p=n.padding??8,{arc:y}=u,E=f(y),b=(U,B,F)=>`a${E},${E} 0 0 ${U} ${B}${E},${F}${E}`,S=b(1,"",""),x=b(0,"",""),I=b(0,"","-"),L=b(1,"","-"),O=b(0,"-",""),v=b(0,"-","-"),G=Ue(e.title,!1,u.measurer,i,r?It(n):4e3,1),K=G.height>0?G.height+16:0,C=Math.round(o*1.5),Z=a*.35,oe=u.height/2,H="",z="",M="",T=(U,B,F)=>{F>U&&(H+=`M${f(U)},${f(B)}H${f(F)}`)},R=(U,B,F)=>{let W=[U],j=[B,F];for(;W.length>0;){let Q=W.pop(),Y=j.pop(),ne=j.pop(),q=Q.kids,k=ne+Q.width;switch(Q.kind){case 3:{let J=k;for(let te=q.length-1;te>=0;te--)J-=q[te].width,W.push(q[te]),j.push(J,Y),te>0&&T(J-u.gap,Y,J),J-=u.gap;break}case 7:{let J=ne+2*y,te=W.length,se=0;T(ne,Y,J);for(let re=0;re<q.length;re++){let P=q[re],ee=Y+se;if(W.push(P),j.push(ee,J),re+1<q.length){let ae=q[re+1],ue=se+P.down+Math.max(u.sep,2*y)+ae.up,ce=Y+se+P.down+Math.max(u.sep,2*y)/2;H+=`M${f(J+P.width)},${f(ee)}H${f(k-2*y)}V${f(ce)}H${f(ne+y)}V${f(Y+ue)}H${f(J)}`,z+=`M${f(J-yr)},${f(Y+ue-yr/2)}l${yr},${yr/2}l${-yr},${yr/2}z`,se=ue}else H+=`M${f(J+P.width)},${f(ee)}H${f(k-y)}V${f(Y)}H${f(k)}`}Ql(W,te),Ql(j,2*te);break}case 4:{let J=Q.width-4*y,te=ne+y,se=k-y,re=W.length,P=0;for(let ee=0;ee<q.length;ee++){let ae=q[ee];ee>0&&(P=xx(P,q[ee-1],ae,u));let ue=Y+P,ce=ne+2*y+(J-ae.width)/2,he=ee===q.length-1;ee===0?(T(ne,Y,ce),T(ce+ae.width,Y,k)):H+=(he?`M${f(ne)},${f(Y)}${S}V${f(ue-y)}`:`M${f(te)},${f(ue-y)}`)+x+(ce>te+y?`H${f(ce)}`:"")+`M${f(ce+ae.width)},${f(ue)}`+(ce>te+y?`H${f(se-y)}`:"")+I+(he?`V${f(Y+y)}${L}`:""),W.push(ae),j.push(ue,ce)}Ql(W,re),Ql(j,2*re);break}case 5:{let J=q[0],te=ne+2*y;T(ne,Y,te),T(te+J.width,Y,k),H+=`M${f(ne)},${f(Y)}${I}V${f(Y-Q.reach+y)}${L}H${f(k-2*y)}${S}V${f(Y-y)}${x}`,W.push(J),j.push(te,Y);break}case 6:{let J=q[0],te=ne+(Q.width-J.width)/2,se=Y+Q.reach,re=ne+Q.width/2;T(ne,Y,te),T(te+J.width,Y,k),H+=`M${f(ne+y)},${f(Y)}${O}V${f(se-y)}${x}H${f(k-y)}${I}V${f(Y+y)}${v}`,z+=`M${f(re-yr/2)},${f(se)}l${yr},${-yr/2}v${yr}z`,Q.text!==""&&(M+=`<text class="pele-edge-label pele-count" x="${f(re)}" y="${f(se+Jl+3)}" font-size="${Jl}" fill="var(--_m)">${nt(Q.text)}</text>`),W.push(J),j.push(te,Y);break}default:{let J=Q.text,te=J.startsWith(" ")||J.endsWith(" ")||J.includes(" ")?' xml:space="preserve"':"",se=`<rect x="${f(ne)}" y="${f(Y-oe)}" width="${f(Q.width)}" height="${f(u.height)}"`,re=`<text x="${f(ne+Q.width/2)}" y="${f(Y+Z)}"${te}`;Q.kind===0?M+=`<g class="pele-node pele-terminal">${se} rx="${f(oe)}" fill="var(--_s)" stroke="var(--_b)"${m}/>${re} font-family="${ur}">${nt(J)}</text></g>`:Q.kind===1?M+=`<g class="pele-node pele-nonterminal" data-id="${We(Q.id)}">${se} fill="var(--_bg)" stroke="var(--_b)"${m}${ft}/>${re}>${nt(J)}</text></g>`:M+=`<g class="pele-node pele-special">${se} fill="var(--_bg)" stroke="var(--_b)" stroke-dasharray="4 3"${m}${ft}/>${re} font-style="italic"><tspan fill="var(--_m)">? </tspan>${nt(J.slice(2,-2))}<tspan fill="var(--_m)"> ?</tspan></text></g>`}}}},_="",$=G.width,g=p+K,N=p+G.height;for(let U of e.rules){let B=BI(U.definition,u,r?Math.max(80,(n.maxWidth??320)-2*p-4*h-2*Kh-1):1/0),F=Zl(U.name),W=g+C+DI+B.up,j=p+2*h,Q=j+Kh,Y=Q+B.width+Kh;H="",z="",M="",T(j,W,Q),T(Q+B.width,W,Y),R(B,Q,W);let ne=h>0?`<circle class="pele-marker pele-start" cx="${f(p+h)}" cy="${f(W)}" r="${f(h)}" fill="var(--_l)"/><circle class="pele-marker pele-end" cx="${f(Y+h)}" cy="${f(W)}" r="${f(h)}" fill="var(--_l)"/>`:"";_+=`<g class="pele-rule" data-id="${We(U.name)}"><text class="pele-rule-name" x="${f(p)}" y="${f(g+C/2+o*.35)}" font-size="${f(o)}" font-weight="var(--_hw)" text-anchor="start">${nt(F)}</text><path class="pele-edge pele-track" d="${H}" fill="none" stroke="var(--_l)"${m}/>`+(z?`<path class="pele-marker" d="${z}" fill="var(--_l)"/>`:"")+ne+M+"</g>",$=Math.max($,Y+2*h-p,u.measurer.width(F,o,1)),N=W+B.down,g=N+u.sep+vI}let w=Math.ceil($+2*p),A=Math.ceil(N+p),D=Ce(G,w/2,p+G.height/2,' class="pele-title" font-weight="var(--_tw)"')+(_?`<g class="pele-rules" transform="translate(0.5,0.5)" font-size="${f(a)}" text-anchor="middle">${_}</g>`:"");return{svg:ot("railroad",w,A,i,n,e,D),width:w,height:A,links:[]}}var Sx={type:"railroad",parse:(e,t,n)=>yx(e,n),render:Ax};var fi={REQUIREMENT:"Requirement",FUNCTIONAL_REQUIREMENT:"Functional Requirement",INTERFACE_REQUIREMENT:"Interface Requirement",PERFORMANCE_REQUIREMENT:"Performance Requirement",PHYSICAL_REQUIREMENT:"Physical Requirement",DESIGN_CONSTRAINT:"Design Constraint"},td={LOW_RISK:"Low",MED_RISK:"Medium",HIGH_RISK:"High"},Na={VERIFY_ANALYSIS:"Analysis",VERIFY_DEMONSTRATION:"Demonstration",VERIFY_INSPECTION:"Inspection",VERIFY_TEST:"Test"},Gr={CONTAINS:"contains",COPIES:"copies",DERIVES:"derives",SATISFIES:"satisfies",VERIFIES:"verifies",REFINES:"refines",TRACES:"traces"},UI=1e6,ed=class{type="requirement";direction="TB";requirements=new Map;elements=new Map;relations=[];classes=new Map;title;accTitle;accDescr;newId="";newText="";newRisk="";newVerifyMethod="";newElementType="";newDocRef="";styleCopies=0;copy(t,n){if(this.styleCopies+=n.length,this.styleCopies>UI)throw new qe("Requirement diagram applies too many style declarations.","limit",{type:"requirement"});for(let r of n)t.push(r)}setDirection(t){this.direction=t}addRequirement(t,n){let r=this.requirements.get(t);return r===void 0&&(r={name:t,type:n,requirementId:this.newId,text:this.newText,risk:this.newRisk,verifyMethod:this.newVerifyMethod,cssStyles:[],classes:["default"]},this.requirements.set(t,r)),this.newId=this.newText=this.newRisk=this.newVerifyMethod="",r}setNewReqId(t){this.newId=t}setNewReqText(t){this.newText=t}setNewReqRisk(t){this.newRisk=t}setNewReqVerifyMethod(t){this.newVerifyMethod=t}addElement(t){let n=this.elements.get(t);return n===void 0&&(n={name:t,type:this.newElementType,docRef:this.newDocRef,cssStyles:[],classes:["default"]},this.elements.set(t,n)),this.newElementType=this.newDocRef="",n}setNewElementType(t){this.newElementType=t}setNewElementDocRef(t){this.newDocRef=t}addRelationship(t,n,r){this.relations.push({type:t,src:n,dst:r})}node(t){return this.requirements.get(t)??this.elements.get(t)}setCssStyle(t,n){for(let r of t){let i=this.node(r);if(!n||!i)return;for(let s of n)this.copy(i.cssStyles,s.includes(",")?s.split(","):[s])}}setClass(t,n){for(let r of t){let i=this.node(r);if(i)for(let s of n){i.classes.push(s);let a=this.classes.get(s)?.styles;a&&this.copy(i.cssStyles,a)}}}defineClass(t,n){for(let r of t){let i=this.classes.get(r);i===void 0&&(i={id:r,styles:[],textStyles:[]},this.classes.set(r,i));for(let a of n)a.includes("color")&&i.textStyles.push(a.replace("fill","bgFill")),i.styles.push(a);let s=n.flatMap(a=>a.split(","));for(let a of this.requirements.values())a.classes.includes(r)&&this.copy(a.cssStyles,s);for(let a of this.elements.values())a.classes.includes(r)&&this.copy(a.cssStyles,s)}}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
112
+ `)}};var jh=["$end","INVALID","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","direction_tb","direction_bt","direction_rl","direction_lr","NEWLINE","EOF","RD","STRUCT_START","STRUCT_STOP","STYLE_SEPARATOR","COLONSEP","ID","TEXT","RISK","VERIFYMTHD","REQUIREMENT","FUNCTIONAL_REQUIREMENT","INTERFACE_REQUIREMENT","PERFORMANCE_REQUIREMENT","PHYSICAL_REQUIREMENT","DESIGN_CONSTRAINT","LOW_RISK","MED_RISK","HIGH_RISK","VERIFY_ANALYSIS","VERIFY_DEMONSTRATION","VERIFY_INSPECTION","VERIFY_TEST","ELEMENT","CONTAINS","COPIES","DERIVES","SATISFIES","VERIFIES","REFINES","TRACES","TYPE","DOCREF","STYLE","CLASSDEF","CLASS","ALPHA","COLON","SEMICOLON","PERCENT","MINUS","BRKT","END_ARROW_L","END_ARROW_R","LINE","qString","unqString","COMMA"],wx=new Map([["requirementdiagram",14],["id",19],["text",20],["risk",21],["verifymethod",22],["requirement",23],["functionalrequirement",24],["interfacerequirement",25],["performancerequirement",26],["physicalrequirement",27],["designconstraint",28],["low",29],["medium",30],["high",31],["analysis",32],["demonstration",33],["inspection",34],["test",35],["element",36],["contains",37],["copies",38],["derives",39],["satisfies",40],["verifies",41],["refines",42],["traces",43],["type",44],["docref",45],["style",46],["classdef",47],["class",48]]);var YI=/accTitle\s*:\s*/iy,HI=/accDescr\s*:\s*/iy,KI=/accDescr\s*\{\s*/iy,nd=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi,Xh=/[\n\r\u2028\u2029]/g,zI=22,_x=new Uint8Array(128);for(let e of`:,\r
113
+ {<>-=`)_x[e.charCodeAt(0)]=1;function Rx(e){let t=e.length,n=[],r=[],i=[],s=[],a=0,o=0,c=[[],[],[],[]],l=[[],[],[],[]],u=[0,0,0,0],h=!1,d=-1;nd.lastIndex=0;for(let O=nd.exec(e);O!==null;O=nd.exec(e)){let v=O[1]!==void 0?0:O[2]!==void 0?1:O[3]!==void 0?2:3;c[v].push(O.index),l[v].push(nd.lastIndex),h=!0}let m=(O,v,G)=>{n.push(O),r.push(e.slice(v,G)),i.push(v),o=G},p=O=>{s.push(a),a=O},y=()=>{s.length>0&&(a=s.pop())},E=(O,v)=>(O.lastIndex=v,O.test(e)?O.lastIndex:-1),b=O=>{let v=e.indexOf(`
114
+ `,O);return v===-1?t:v},S=()=>{if(d<o){Xh.lastIndex=o,d=Xh.test(e)?Xh.lastIndex-1:t;for(let O=0;O<4;O++){let v=c[O],G=u[O];for(;G<v.length&&v[G]<=d;)G++;u[O]=G}}for(let O=0;O<4;O++){let v=u[O]-1;if(v>=0&&c[O][v]>=o)return m(8+O,o,b(l[O][v])),!0}return!1},x=O=>{let v=O|32;if(v===116&&e.slice(o+1,o+5).toLowerCase()==="itle"&&Xe(e.charCodeAt(o+5))){let G=o+6;for(;G<t;){let K=e.charCodeAt(G);if(K===35||K===10||K===59)break;G++}if(G>o+6)return m(2,o,G),!0}if(v===97&&(e.charCodeAt(o+1)|32)===99&&(e.charCodeAt(o+2)|32)===99){let G;if((G=E(YI,o))>=0)return p(3),m(3,o,G),!0;if((G=E(HI,o))>=0)return p(4),m(5,o,G),!0;if((G=E(KI,o))>=0)return p(5),o=G,!0}if(h&&!Ws(O)&&S())return!0;if(O===10||O===13&&e.charCodeAt(o+1)===10){let G=o;for(;G<t;){let K=e.charCodeAt(G);if(K===10)G++;else if(K===13&&e.charCodeAt(G+1)===10)G+=2;else break}return m(12,o,G),!0}if(Xe(O)){for(o++;o<t&&Xe(e.charCodeAt(o));)o++;return!0}if(O===35||O===37)return o=b(o),!0;if(it(O)){let G=o+1;for(;G<t&&it(e.charCodeAt(G));)G++;if(G-o<=zI){let K=wx.get(e.slice(o,G).toLowerCase());if(K!==void 0)return(K===46||K===47||K===48)&&p(2),m(K,o,G),!0}for(;G<t;){let K=e.charCodeAt(G);if(K<128&&_x[K]===1)break;G++}return n.push(59),r.push(e.slice(o,G).trim()),i.push(o),o=G,!0}switch(O){case 123:return m(15,o,o+1),!0;case 125:return m(16,o,o+1),!0;case 58:return e.charCodeAt(o+1)===58&&e.charCodeAt(o+2)===58?m(17,o,o+3):m(18,o,o+1),!0;case 60:return e.charCodeAt(o+1)!==45?!1:(m(55,o,o+2),!0);case 45:return e.charCodeAt(o+1)===62?m(56,o,o+2):m(57,o,o+1),!0;case 34:return p(1),o++,!0;case 44:return m(60,o,o+1),!0}return!1},I=O=>{if(it(O)){let v=o+1;for(;v<t&&it(e.charCodeAt(v));)v++;return m(49,o,v),!0}switch(O){case 58:return m(50,o,o+1),!0;case 59:return m(51,o,o+1),!0;case 37:return m(52,o,o+1),!0;case 45:return m(53,o,o+1),!0;case 35:return m(54,o,o+1),!0;case 32:return o++,!0;case 34:return p(1),o++,!0;case 10:return y(),o++,!0;case 44:return m(60,o,o+1),!0}return!1};for(;o<t;){let O=e.charCodeAt(o),v=!0;switch(a){case 0:v=x(O);break;case 2:v=I(O);break;case 1:if(O===34)y(),o++;else{let G=e.indexOf('"',o);m(58,o,G===-1?t:G)}break;case 3:y(),m(4,o,b(o));break;case 4:y(),m(6,o,b(o));break;case 5:if(O===125)y(),o++;else{let G=e.indexOf("}",o);m(7,o,G===-1?t:G)}break}if(!v)return n.push(1),r.push(""),i.push(o),{types:n,texts:r,starts:i}}let L=a===0?13:a===1?58:a===3?4:a===4?6:a===5?7:-1;return L!==-1&&m(L,t,t),m(0,t,t),{types:n,texts:r,starts:i}}var VI=[fi.REQUIREMENT,fi.FUNCTIONAL_REQUIREMENT,fi.INTERFACE_REQUIREMENT,fi.PERFORMANCE_REQUIREMENT,fi.PHYSICAL_REQUIREMENT,fi.DESIGN_CONSTRAINT,td.LOW_RISK,td.MED_RISK,td.HIGH_RISK,Na.VERIFY_ANALYSIS,Na.VERIFY_DEMONSTRATION,Na.VERIFY_INSPECTION,Na.VERIFY_TEST,"",Gr.CONTAINS,Gr.COPIES,Gr.DERIVES,Gr.SATISFIES,Gr.VERIFIES,Gr.REFINES,Gr.TRACES];function Tx(e){return e===49||e===50||e===54||e===53||e===51}function Mx(e,t){let{types:n,texts:r,starts:i}=Rx(e),s=0,a=[],o=[],c=(b,S=b,...x)=>{let I=n[s];if(I===1)throw ut("requirement",e,i[s],"",!0);for(let O=S;O>=b;O--)x.unshift(O);let L=x.map(O=>`'${jh[O]}'`).join(", ");throw ut("requirement",e,i[s],`Expecting ${L}, got '${jh[I]}'`)},l=b=>(n[s]!==b&&c(b),r[s++]),u=(b,S)=>{let x=n[s];return(x<b||x>S)&&c(b,S),s++,VI[x-23]},h=()=>{let b=n[s];return b!==59&&b!==58&&c(58,59),r[s++]},d=()=>{let b=n[s];if(b===3)s++,t.setAccTitle(l(4).trim());else if(b===5)s++,t.setAccDescription(l(6).trim());else if(b===7)t.setAccDescription(r[s++].trim());else return!1;return!0},m=()=>{let b=[];for(;;){let S=n[s];if(S!==49&&S!==59&&S!==58&&c(58,59,49),b.push(r[s++]),n[s]!==60)return b;s++}},p=()=>{let b=[];for(;;){Tx(n[s])||c(49,51,53,54);let S=r[s++];for(;Tx(n[s]);)S+=r[s++];if(b.push(S),n[s]!==60)return b;s++}},y=()=>{let b;return n[s]===17?(s++,b=m(),l(15)):n[s]===15?s++:c(15,15,17),l(12),b},E=b=>{for(a.length=0,o.length=0;;){let S=n[s];if(S===16){s++;break}if(S===12){s++;continue}(b?S<19||S>22:S!==44&&S!==45)&&(b&&c(19,22,12,16),c(44,45,12,16)),s++,l(18),o.push(S===21?u(29,31):S===22?u(32,35):h()),a.push(S),l(12)}for(let S=a.length-1;S>=0;S--){let x=o[S];switch(a[S]){case 19:t.setNewReqId(x);break;case 20:t.setNewReqText(x);break;case 21:t.setNewReqRisk(x);break;case 22:t.setNewReqVerifyMethod(x);break;case 44:t.setNewElementType(x);break;default:t.setNewElementDocRef(x)}}};for(;d();)n[s]===12&&s++;for(n[s]!==14&&c(14,14,3,5,7),s++,l(12);;){let b=n[s];if(b===13)return;if(b===12)s++;else{if(d())continue;if(b>=8&&b<=11)s++,t.setDirection(b===8?"TB":b===9?"BT":b===10?"RL":"LR");else if(b>=23&&b<=28){let S=u(23,28),x=h(),I=y();E(!0),t.addRequirement(x,S),I&&t.setClass([x],I)}else if(b===36){s++;let S=h(),x=y();E(!1),t.addElement(S),x&&t.setClass([S],x)}else if(b===46){s++;let S=m();t.setCssStyle(S,p())}else if(b===47){s++;let S=m();t.defineClass(S,p())}else if(b===48){s++;let S=m();t.setClass(S,m())}else if(b===59||b===58){let S=r[s++],x=n[s];if(x===17)s++,t.setClass([S],m());else if(x===55||x===57){s++;let I=u(37,43);l(x===57?56:57);let L=h();x===57?t.addRelationship(I,S,L):t.addRelationship(I,L,S)}else c(17,17,55,57)}else c(12,13,3,5,7,8,9,10,11,23,24,25,26,27,28,36,47,48,46,59,58)}}}function Cx(e){let t=[];for(let i of e.requirements.values())t.push({id:i.name,requirement:i,element:void 0,cssStyles:i.cssStyles,cssClasses:i.classes.join(" ")});for(let i of e.elements.values())t.push({id:i.name,requirement:void 0,element:i,cssStyles:i.cssStyles,cssClasses:i.classes.join(" ")});let n=i=>e.requirements.has(i)||e.elements.has(i)?i:void 0,r=e.relations.map((i,s)=>({id:`${i.src}-${i.dst}-${s}`,start:n(i.src),end:n(i.dst),type:i.type,contains:i.type===Gr.CONTAINS}));return{nodes:t,edges:r,direction:e.direction}}var jI=40,XI=16,qI=56,rd=14,Ia=10,qh=2,Nx=12,QI=120,ZI=280,JI=240,Qh=26,Lx=6,Ix=9,sd=4.5,ek=28,tk=14;function id(e,t,n){if(t===0||e.lines.length===0)return e;let r=0,i=[],s=e.lines.map(a=>{let o=0,c=a.map(l=>{let u=l.style|t,h=l.icon!==void 0||l.math?l.width:n.width(l.text,e.size,u);return o+=h,{...l,style:u,width:h}});return i.push(o),o>r&&(r=o),c});return{...e,lines:s,widths:i,width:r}}function kx(e,t,n,r){let i=jr(e),s="",a="";for(let o=0;o<e.lines.length;o++){let c=e.lines[o],l=n+Cr(e,o);if(Gi(c)){a+=Ce(Nr(e,o),t+e.widths[o]/2,l,r);continue}let u=l+e.size*.35,h=!0;for(let d of c)d.icon!==void 0||d.text===""||(s+=`<tspan${h?` x="${f(t)}" y="${f(u)}"`:""}${wr(d.style&~i)}>${nt(d.text)}</tspan>`,h=!1)}return(s===""?"":`<text${Xn(r,i)} text-anchor="start" xml:space="preserve">${s}</text>`)+a}function nk(e,t,n,r){let i=Lx,s=e-n*i,a=t-r*i;return`<circle class="pele-marker" cx="${f(s)}" cy="${f(a)}" r="${i}"/><path class="pele-marker" d="M${f(s-n*i)},${f(a-r*i)}L${f(s+n*i)},${f(a+r*i)}M${f(s+r*i)},${f(a-n*i)}L${f(s-r*i)},${f(a+n*i)}"/>`}function rk(e,t,n,r){let i=e-n*Ix,s=t-r*Ix;return`<path class="pele-marker" d="M${f(i-r*sd)},${f(s+n*sd)}L${f(e)},${f(t)}L${f(i+r*sd)},${f(s-n*sd)}" stroke-linejoin="round"/>`}function sk(e,t,n){let r=new Map;for(let i of t){let s=i.route;if(!(i.src===i.dst||s.length<6))for(let a of[0,s.length-3]){let o=a===0?i.src:i.dst,c=e[o],l=s[a]-c.x,u=s[a+1]-c.y,h=a===0?3:a-3,d;if(Math.abs(Math.abs(u)-c.h/2)<.5)d=u<0?0:2;else if(Math.abs(Math.abs(l)-c.w/2)<.5)d=l<0?3:1;else continue;let m=o*4+d,p={route:s,at:a,toward:s[d%2===0?h:h+1]},y=r.get(m);y?y.push(p):r.set(m,[p])}}for(let[i,s]of r){if(s.length<2)continue;let a=i>>2,o=i%2===1,c=(o?n[a].h:n[a].w)-2*tk,l=Math.max(0,Math.min(ek,c/(s.length-1)));s.sort((u,h)=>u.toward-h.toward);for(let u=0;u<s.length;u++){let h=(u-(s.length-1)/2)*l;o?s[u].route[s[u].at+1]=e[a].y+h:s[u].route[s[u].at]=e[a].x+h}}}function Ox(e,t,n){return vn(e.direction)?vt(n,r=>$x(e,t,n,r)):$x(e,t,n,!1)}function $x(e,t,n,r){let i=Cx(e),s=n.fontSize??16,a=Math.round(s*.875),o=n.measurer??at(n.fontFamily,n.fontFamilyMono),c=n.padding??8,l=new Map,u=[],h=[];for(let z of i.nodes){let M=Mt(z.cssStyles),T=(M.bold?1:0)|(M.italic?2:0),R=M.fontSize??s,_=M.fontSize??a,$=z.requirement,g=z.element,N=id(Ue(`«${$?$.type:"Element"}»`,!1,o,_,4e3),T,o),w=id(Ue(z.id,!0,o,R,ZI),T|1,o),A=$?[["ID",$.requirementId],["Text",$.text],["Risk",$.risk],["Verification",$.verifyMethod]]:[["Type",g.type],["Doc Ref",g.docRef]],D=[],U=0,B=0,F=0;for(let[Y,ne]of A){if(!ne)continue;let q=id(Ue(Y,!1,o,_,4e3),T,o),k=id(Ue(ne,!0,o,_,JI),T,o),J=Math.max(q.height,k.height);D.push({key:q,value:k,height:J}),U=Math.max(U,q.width),B=Math.max(B,k.width),F+=J+qh}D.length>0&&(F+=2*Ia-qh);let W=2*Ia+N.height+w.height,j=Math.max(QI,Math.max(N.width,w.width)+2*rd,D.length>0?U+Nx+B+2*rd:0);l.has(z.id)||l.set(z.id,u.length);let Q=Ft(j,W+F);Q.seq=u.length,u.push({node:z,style:M,kind:N,name:w,rows:D,keyWidth:U,headHeight:W,w:j,h:W+F}),h.push(Q)}let d=r?"TB":cn(i.direction),m=d==="LR"||d==="RL",p=[],y=[],E=[];for(let z of i.edges){let M=z.start===void 0?void 0:l.get(z.start),T=z.end===void 0?void 0:l.get(z.end);if(M===void 0||T===void 0)continue;let R=Ue(`«${z.type}»`,!1,o,a,4e3);M===T&&(m?h[M].h+=2*(Qh+R.height+8):h[M].w+=2*(Qh+R.width+12)),E.push(z),y.push(R),p.push({src:M,dst:T,minlen:1,labelW:R.width+12,labelH:R.height+4,route:[],labelX:0,labelY:0})}let b=Ln(h,p,d,{nodeSep:jI,edgeSep:XI,rankSep:qI,portSep:20});sk(h,p,u);let S=bn(e.title,o,s,4e3),x=S.height>0?S.height+12:0,I=Math.max(b.width,S.width),L=c+(I-b.width)/2,O=c+x,v=Math.ceil(I+2*c),G=Math.ceil(b.height+x+2*c),K="";for(let z=0;z<u.length;z++){let M=u[z],{w:T,h:R,style:_}=M,$=Dt(_),g=$||' fill="var(--_m)"',N=-T/2,w=-R/2,A=`<rect x="${f(N)}" y="${f(w)}" width="${f(T)}" height="${f(R)}" fill="var(--_s)" stroke="var(--_b)"${xt(_.shape)}/>`+Ce(M.kind,0,w+Ia+M.kind.height/2,` class="pele-stereotype" font-size="${M.kind.size}"${g}${_.text}`)+Ce(M.name,0,w+Ia+M.kind.height+M.name.height/2,` class="pele-label" font-size="${M.name.size}" font-weight="var(--_hw)"${$}${_.text}`);if(M.rows.length>0){let D=w+M.headHeight;A+=`<path class="pele-divider" d="M${f(N)},${f(D)}H${f(-N)}" stroke="var(--_b)"${_.line}/>`;let U=D+Ia,B="";for(let F of M.rows)B+=kx(F.key,N+rd,U,` class="pele-field"${g}${_.text}`)+kx(F.value,N+rd+M.keyWidth+Nx,U,` class="pele-value"${$}${_.text}`),U+=F.height+qh;A+=`<g class="pele-fields" font-size="${M.rows[0].key.size}">${B}</g>`}K+=`<g class="pele-node ${M.node.requirement?"pele-requirement":"pele-element"}${Nt(M.node.cssClasses.replace(/^default\s?/,""))}" data-id="${We(M.node.id)}" transform="translate(${f(h[z].x+L)},${f(h[z].y+O)})">${A}</g>`}let C="",Z="",oe=new Map;for(let z=0;z<p.length;z++){let M=p[z],T=E[z],R=y[z],_=T.contains?2*Lx:0,$,g=M.labelX+L,N=M.labelY+O;if(M.src===M.dst){let w=u[M.src],A=h[M.src].x+L,D=h[M.src].y+O,U=oe.get(M.src)??0;oe.set(M.src,U+1);let B=(m?w.w:w.h)/2,F=Math.min(B-4,12+U*6),W=Qh+U*8,j=(Y,ne)=>m?`${f(A+ne)},${f(D+w.h/2+Y)}`:`${f(A+w.w/2+Y)},${f(D+ne)}`,Q=W/.75;$={d:`M${j(_,-F)}C${j(Q,-F)} ${j(Q,F)} ${j(0,F)}`,sx:m?A-F:A+w.w/2,sy:m?D+w.h/2:D-F,sdx:m?0:-1,sdy:m?-1:0,ex:m?A+F:A+w.w/2,ey:m?D+w.h/2:D+F,edx:m?0:-1,edy:m?-1:0},m?(g=A,N=D+w.h/2+W+4+M.labelH/2):(g=A+w.w/2+W+4+M.labelW/2,N=D)}else{let w=M.route.slice();for(let A=0;A<w.length;A+=3)w[A]+=L,w[A+1]+=O;$=Mn(w,void 0,_,0)}C+=`<g class="pele-edge pele-relationship-${T.contains?"contains":"arrow"}" data-id="${We(T.id)}"><path d="${$.d}"${T.contains?"":' stroke-dasharray="5 4"'}/>`+(T.contains?nk($.sx,$.sy,$.sdx,$.sdy):rk($.ex,$.ey,$.edx,$.edy))+"</g>",Z+=ln(T.id,R,g,N,"")}return{svg:ot("requirement",v,G,s,n,e,Ce(S,v/2,c+S.height/2,' class="pele-title" font-weight="var(--_tw)"')+(C?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${C}</g>`:"")+(Z?`<g class="pele-edge-labels" font-size="${a}" fill="var(--_m)">${Z}</g>`:"")+`<g class="pele-nodes">${K}</g>`),width:v,height:G,links:[]}}var Dx={type:"requirement",math:!0,parse(e,t,n){let r=new ed;return n&&(r.title=n),Mx(e,r),r},render:Ox};var od=class{type="sankey";nodes=[];links=[];title;accTitle;accDescr;lookup=new Map;findOrCreateNode(t){let n=this.lookup.get(t);return n===void 0&&(n={id:t,index:this.nodes.length},this.lookup.set(t,n),this.nodes.push(n)),n}addLink(t,n,r){this.links.push({source:t,target:n,value:r})}};var ad=["$end","STUCK","SANKEY","NEWLINE","COMMA","DQUOTE","NON_ESCAPED_TEXT","ESCAPED_TEXT","EOF"];function vx(e){return e>=32&&e<=126&&e!==34&&e!==44||e>=160&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}function Px(e){let t=e.length,n=[],r=[],i=[],s=[],a=0,o=0,c=(u,h,d)=>{n.push(u),r.push(e.slice(h,d)),i.push(h),o=d},l=u=>e.slice(o,o+u.length).toLowerCase()===u&&!it(e.charCodeAt(o+u.length));for(;o<t;){let u=e.charCodeAt(o),h=o,d=o;if(a===2){if(u===34&&e.charCodeAt(o+1)!==34){s.length>0&&(a=s.pop()),c(5,o,o+1);continue}for(;d<t;){let m=e.codePointAt(d);if(vx(m)||m===44||m===13||m===10)d+=m>65535?2:1;else if(m===34&&e.charCodeAt(d+1)===34)d+=2;else break}c(7,o,d)}else{if(a===0&&(u|32)===115){let m=l("sankey-beta")?11:l("sankey")?6:0;if(m>0){s.push(a),a=1,c(2,o,o+m);continue}}if(u===10||u===13&&e.charCodeAt(o+1)===10){c(3,o,u===10?o+1:o+2);continue}if(u===44){c(4,o,o+1);continue}if(u===34){s.push(a),a=2,c(5,o,o+1);continue}for(;d<t;){let m=e.codePointAt(d);if(!vx(m))break;d+=m>65535?2:1}c(6,o,d)}if(d===h)return c(1,o,o),{types:n,texts:r,starts:i}}return c(a===2?7:8,t,t),c(0,t,t),{types:n,texts:r,starts:i}}var Fx=/[\n\r]+/g,ik=/[\x00-\x08\x0b\x0c\x0e-\x1f\ud800-\udfff\ufffe\uffff]/u;function Zh(e){return e===10||e===13?!1:e<128?e===32||e===9||e===11||e===12:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function ok(e,t){let n=e.length;for(;n>0&&Zh(e.charCodeAt(n-1));)n--;let r="",i=0,s=!1;for(let a=0;a<n;){let o=e.charCodeAt(a);if(s)o===34&&(e.charCodeAt(a+1)===34?a++:s=!1),a++;else if(o===34)s=!0,a++;else if(Zh(o)){let c=a+1;for(;Zh(e.charCodeAt(c));)c++;let l=e.charCodeAt(a-1),u=e.charCodeAt(c);(a===0||u===10||u===13||(l===10||l===13)&&u!==44)&&(r+=e.slice(i,a),t.push([a,c,0]),i=c),a=c}else a++}return n<e.length&&t.push([n,e.length,0]),r+e.slice(i,n)}function Jh(e,t){let n=[],r=ok(e,n),i=r.replace(Fx,`
115
+ `),s=i.trim();if(t!==void 0){let a=i.length-i.trimStart().length;t.push(n,ls(r,Fx,1),[[0,a,0],[a+s.length,i.length,0]])}return s}function Bx(e,t,n=e){let{types:r,texts:i,starts:s}=Px(e),a=0,o=(d,m)=>{let p=[];n!==e&&Jh(n,p);let y=d>0&&d>=e.length?Kr(p,e.length-1)+1:Kr(p,d);return ut("sankey",n,y,m)},c=d=>{let m=r[a],p=m===1?ad[r[a-1]]:ad[m];throw o(s[a],`Expecting ${d}, got '${p}'`)},l=(d,m="")=>{r[a]!==d&&c(`'${ad[d]}'${m}`),a++},u=()=>{if(r[a]===6)return i[a++];r[a]!==5&&c("'DQUOTE', 'NON_ESCAPED_TEXT'"),a++,r[a]!==7&&c("'ESCAPED_TEXT'");let d=i[a++];return l(5),d},h=()=>{let d=s[a],m=u().trim().replaceAll('""','"');if(ik.test(gt(m)))throw o(d,"Invalid XML character in node name");return m};for(l(2),l(3);;){let d=h();l(4,", 'NEWLINE', 'EOF'");let m=h();l(4,", 'NEWLINE', 'EOF'");let p=s[a],y=parseFloat(u());if(!Number.isFinite(y))throw o(p,"Expecting a number");let E=t.findOrCreateNode(d),b=t.findOrCreateNode(m);if(t.addLink(E,b,y),r[a]!==3)break;a++}r[a]===8&&a++,r[a]!==0&&c("'NEWLINE', 'EOF'")}var ak=6;function ep(e,t){if(e.length>8){e.sort(t);return}for(let n=1;n<e.length;n++){let r=e[n],i=n-1;for(;i>=0&&t(e[i],r)>0;)e[i+1]=e[i],i--;e[i+1]=r}}function Wx(e,t){let n=e.nodes.length,r=e.links.map(R=>({source:R.source.index,target:R.target.index,value:Number.isFinite(R.value)&&R.value>0?R.value:0,thickness:0,sourceY:0,targetY:0})),i=[],s=[];for(let R=0;R<n;R++)i.push([]),s.push([]);r.forEach((R,_)=>{i[R.source].push(_),s[R.target].push(_)});let a=new Int32Array(n),o=new Int32Array(n),c=[];for(let R=0;R<n;R++)o[R]=s[R].length,o[R]===0&&c.push(R);for(let R=0;R<c.length;R++){let _=c[R];for(let $ of i[_]){let g=r[$].target;a[g]<a[_]+1&&(a[g]=a[_]+1),--o[g]===0&&c.push(g)}}if(c.length<n){let R=0;for(;o[R]===0;)R++;let _=new Uint8Array(n);for(;_[R]===0;){_[R]=1;for(let $ of s[R])if(o[r[$].source]>0){R=r[$].source;break}}throw new qe(`Sankey diagrams cannot have circular links, and "${e.nodes[R].id}" is part of one.`,"semantic",{type:"sankey"})}let l=1;for(let R=0;R<n;R++)a[R]+1>l&&(l=a[R]+1);let u=new Int32Array(n);for(let R=n-1;R>=0;R--){let _=c[R];for(let $ of i[_])u[_]<u[r[$].target]+1&&(u[_]=u[r[$].target]+1)}let h=0;for(let R of r)R.value>h&&(h=R.value);let d=h>0?1/h:0,m=[],p=new Float64Array(n),y=[];for(let R=0;R<l;R++)y.push([]);let E=l>1?(t.width-t.nodeWidth)/(l-1):0;for(let R=0;R<n;R++){let _;if(t.alignment==="left")_=a[R];else if(t.alignment==="right")_=l-1-u[R];else if(t.alignment==="center"){if(_=a[R],s[R].length===0&&i[R].length>0){_=l;for(let A of i[R])a[r[A].target]-1<_&&(_=a[r[A].target]-1)}}else _=i[R].length>0?a[R]:l-1;let $=0,g=0,N=0,w=0;for(let A of s[R])$+=r[A].value*d,N+=r[A].value;for(let A of i[R])g+=r[A].value*d,w+=r[A].value;p[R]=Math.max($,g),m.push({layer:_,value:Math.max(N,w),x:_*E,y:0,height:0}),y[_].push(R)}let b=1;for(let R of y)R.length>b&&(b=R.length);let S=b>1?Math.min(t.nodePadding,t.height/(b-1)):t.nodePadding,x=1/0;for(let R of y){let _=0;for(let $ of R)_+=p[$];_>0&&(x=Math.min(x,(t.height-(R.length-1)*S)/_))}(!Number.isFinite(x)||x<0)&&(x=0);let I=Math.max(0,t.labelHeight-S),L=R=>{for(let _ of y){let $=(_.length-1)*S;for(let g of _)$+=Math.max(p[g]*R,I);if($>t.height+1e-6)return!1}return!0};if(I>0&&!L(x))if(L(0)){let R=0;for(let _=0;_<40;_++){let $=(R+x)/2;L($)?R=$:x=$}x=R}else I=0;let O=new Float64Array(n);for(let R of r)R.thickness=R.value*d*x;for(let R of y){let _=0;for(let g of R)m[g].height=p[g]*x,O[g]=Math.max(0,I-m[g].height)/2,m[g].y=_+O[g],_+=m[g].height+2*O[g]+S;let $=(t.height-_+S)/(R.length+1);R.forEach((g,N)=>m[g].y+=$*(N+1))}let v=R=>m[R].y+m[R].height/2,G=new Float64Array(r.length),K=new Float64Array(r.length),C=(R,_)=>v(r[R].target)-v(r[_].target)||R-_,Z=(R,_)=>v(r[R].source)-v(r[_].source)||R-_,oe=(R,_)=>v(R)-v(_)||R-_,H=R=>{let _=0;ep(i[R],C);for(let $ of i[R])G[$]=_+r[$].thickness/2,_+=r[$].thickness},z=R=>{let _=0;ep(s[R],Z);for(let $ of s[R])K[$]=_+r[$].thickness/2,_+=r[$].thickness},M=()=>{for(let R=0;R<n;R++)H(R),z(R)},T=(R,_,$)=>{for(let N of R){let w=$?s[N]:i[N];if(w.length===0)continue;$?z(N):H(N);let A=0,D=0,U=0;for(let F of w){let W=$?m[r[F].source].y+G[F]-K[F]:m[r[F].target].y+K[F]-G[F];A+=W*r[F].thickness,D+=r[F].thickness,U+=v($?r[F].source:r[F].target)-m[N].height/2}let B=D>0?A/D:U/w.length;m[N].y+=(B-m[N].y)*_}ep(R,oe);let g=0;for(let N of R)m[N].y-O[N]<g&&(m[N].y=g+O[N]),g=m[N].y+m[N].height+O[N]+S;g=t.height;for(let N=R.length-1;N>=0;N--){let w=R[N];m[w].y+m[w].height+O[w]>g&&(m[w].y=g-m[w].height-O[w]),g=m[w].y-O[w]-S}};M();for(let R=0;R<ak;R++){let _=Math.pow(.99,R);for(let $=l-2;$>=0;$--)T(y[$],_,!1);M();for(let $=1;$<l;$++)T(y[$],_,!0);M()}for(let R=0;R<r.length;R++)r[R].sourceY=m[r[R].source].y+G[R],r[R].targetY=m[r[R].target].y+K[R];return{nodes:m,links:r}}var Yr=6,ck=15,lk=1.8,Ux=300;function dk(e){let t=2166136261,n=5381;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619),n=Math.imul(n,33)+i|0}return(t>>>0).toString(36)+(n>>>0).toString(36)}function Kx(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function cd(e,t,n,r,i){let s=e[t];return typeof s=="number"&&s>=r?Math.min(s,i):n}function Gx(e,t){let n=e[t];return typeof n=="string"||typeof n=="number"&&Number.isFinite(n)?String(n):""}function Yx(e){return Math.abs(e)<1e15?Math.round(e*100)/100:e}function Hx(e){return typeof e=="string"?Mt([`fill:${e}`]).shape:""}function zx(e,t,n){let r=Kx(t.sankey)?t.sankey:{},i=cd(r,"width",600,1,1e4);return ps(n,i,160,s=>uk(e,r,n,s,i))}function uk(e,t,n,r,i){let s=n.fontSize??16,a=Math.round(s*.625),o=Math.max(a,Math.round(s*.875*Math.min(1,r/i))),c=n.measurer??at(n.fontFamily,n.fontFamilyMono),l=n.padding??8,u=cd(t,"height",400,1,1e4),h=Math.min(cd(t,"nodeWidth",10,1,200),r),d=t.showValues!==!1,m=gt(Gx(t,"prefix")),p=gt(Gx(t,"suffix")),y=t.labelStyle==="outlined",E=t.nodeAlignment==="left"||t.nodeAlignment==="right"||t.nodeAlignment==="center"?t.nodeAlignment:"justify",b=typeof t.linkColor=="string"?t.linkColor:"gradient",S=te=>Wx(e,{width:r,height:u,nodeWidth:h,nodePadding:cd(t,"nodePadding",12,0,200)+(d?ck:0),labelHeight:te*1.15,alignment:E}),x=S(o),I=new Map,L=1;for(let te of x.nodes){let se=(I.get(te.layer)??0)+1;I.set(te.layer,se),se>L&&(L=se)}let O=Math.max(a,Math.round(u/L/lk));O<o&&(o=O,x=S(o));let{nodes:v,links:G}=x,K=o*1.5,C=new Map;if(Kx(t.nodeColors))for(let[te,se]of Object.entries(t.nodeColors)){let re=Hx(se);re&&C.set(te,re)}let Z=te=>C.get(e.nodes[te].id)??"",oe=te=>/^ style="fill:(.*);"$/.exec(Z(te))?.[1]??yt(te),H=0,z=0;v.forEach(te=>{te.value>z&&(z=te.value,H=te.layer)});let M=0,T=r,R=0,_=u,$=v.map((te,se)=>{let re=gt(e.nodes[se].id),P=d?`${m}${Yx(te.value)}${p}`:"",ee=c.width(P?`${re} ${P}`:re,o,0),ae=y?te.layer>=H:te.x<r/2,ue=ae?te.x+h+Yr:te.x-Yr,ce=te.y+te.height/2;return M=Math.min(M,ae?ue:ue-ee),T=Math.max(T,ae?ue+ee:ue),R=Math.min(R,ce-o*.75),_=Math.max(_,ce+o*.75),{value:P,width:ee,after:ae,left:ae?ue:ue-ee,y:ce}}),g=new Map;if(v.length<=Ux)for(let te of $){let se=Math.floor(te.y/K);for(let re of[se-2,se-1,se,se+1,se+2]){let P=g.get(re);P?P.push(te):g.set(re,[te])}}let N="",w="";v.forEach((te,se)=>{let re=e.nodes[se].id,P=gt(re),ee=Math.max(te.height,1);w+=`<rect class="pele-sankey-node" data-id="${We(re)}" x="${f(te.x)}" y="${f(te.y)}" width="${f(h)}" height="${f(ee)}" rx="${f(Math.min(2,ee/2))}" fill="${yt(se)}"${Z(se)}/>`;let ae=$[se],ue=(Ae,we)=>(g.get(Math.floor(we/K))??[]).some(Ee=>Ee!==ae&&Math.abs(Ee.y-we)<K&&Ae<Ee.left+Ee.width+Yr&&Ae+ae.width>Ee.left-Yr);if(v.length<=Ux&&ue(ae.left,ae.y))e:for(let Ae of[0,-K,K])for(let we of[ae.after,!ae.after]){let Ee=we?te.x+h+Yr:te.x-Yr-ae.width,Te=ae.y+Ae;if(ue(Ee,Te)||Ee<M||Ee+ae.width>T||Te-o*.75<R||Te+o*.75>_||v.some((Ie,ge)=>ge!==se&&Ee<Ie.x+h+Yr&&Ee+ae.width>Ie.x-Yr&&Te-o*.75<Ie.y+Ie.height&&Te+o*.75>Ie.y))continue;let Me=Math.max(0,te.y-Te,Te-te.y-te.height);if(!v.some((Ie,ge)=>ge!==se&&Ie.x===te.x&&Math.max(0,Ie.y-Te,Te-Ie.y-Ie.height)<=Me)){ae.left=Ee,ae.y=Te,ae.after=we;break e}}let{value:ce,after:he,y:V}=ae,X=he?te.x+h+Yr:te.x-Yr,le=` x="${f(X)}" y="${f(V+o*.35)}" text-anchor="${he?"start":"end"}"`,de=nt(P)+(ce?` <tspan class="pele-sankey-value" fill="var(--_m)">${nt(ce)}</tspan>`:"");N+=`<g class="pele-label" data-id="${We(re)}">`+(y?`<text${le} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${nt(P)}${ce?" "+nt(ce):""}</text>`:"")+`<text${le}>${de}</text></g>`});let A=b==="gradient"||b==="source"||b==="target"?"":Hx(b),D=n.idPrefix??"",U=b==="gradient"&&/^[\w-]+$/.test(D),B=new Map,F="";for(let te of G){let se=b==="target"?te.target:te.source,re=Math.max(te.thickness,1)/2,P=v[te.source].x+h,ee=v[te.target].x,ae=`fill="${yt(se)}"${A||Z(se)}`;if(U){let V=`x1="${f(P)}" x2="${f(ee)}"><stop offset="0" stop-color="${oe(te.source)}"/><stop offset="1" stop-color="${oe(te.target)}"/>`,X=`${D}-sankey-${dk(V)}`;B.set(X,`<linearGradient id="${X}" gradientUnits="userSpaceOnUse" ${V}</linearGradient>`),ae=`fill="url(#${X}) ${oe(te.source)}"`}let ue=f((P+ee)/2),ce=We(e.nodes[te.source].id),he=We(e.nodes[te.target].id);F+=`<path class="pele-sankey-link" data-id="${ce}-&gt;${he}" d="M${f(P)},${f(te.sourceY-re)}C${ue},${f(te.sourceY-re)} ${ue},${f(te.targetY-re)} ${f(ee)},${f(te.targetY-re)}L${f(ee)},${f(te.targetY+re)}C${ue},${f(te.targetY+re)} ${ue},${f(te.sourceY+re)} ${f(P)},${f(te.sourceY+re)}Z" ${ae}><title>${ce} → ${he}: ${nt(m)}${Yx(te.value)}${nt(p)}</title></path>`}let W=Ue(e.title,!1,c,s,It(n),1),j=W.height>0?W.height+12:0,Q=Math.max(T-M,W.width),Y=l-M+(Q-(T-M))/2,ne=l+j-R,q=Math.ceil(Q+2*l),k=Math.ceil(_-R+j+2*l);return{svg:ot("sankey",q,k,s,n,e,Ce(W,q/2,l+W.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f(Y)},${f(ne)})">`+(B.size>0?`<defs>${[...B.values()].join("")}</defs>`:"")+`<g class="pele-sankey-links" fill-opacity="0.4">${F}</g><g class="pele-sankey-nodes">${w}</g><g class="pele-labels" font-size="${o}">${N}</g></g>`),width:q,height:k,links:[]}}var Vx={type:"sankey",parse(e,t,n){let r=new od;return n&&(r.title=n),Bx(Jh(e),r,e),r},render:zx};var fk="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 transparent currentcolor inherit initial unset revert accentcolor accentcolortext activetext buttonborder buttonface buttontext canvas canvastext field fieldtext graytext highlight highlighttext linktext mark marktext selecteditem selecteditemtext visitedtext activeborder activecaption appworkspace background buttonhighlight buttonshadow captiontext inactiveborder inactivecaption inactivecaptiontext infobackground infotext menu menutext scrollbar threeddarkshadow threedface threedhighlight threedlightshadow threedshadow window windowframe windowtext",jx,hk=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;function Xx(e){if(e.toLowerCase()==="none")return 4;let t=hk.exec(e);return t?t[1]===void 0?1:t[1]==="%"?2:3:0}function pk(e,t){let n=Xx(e);return n===1||n===2||t&&n===4}function mk(e){let t=e.startsWith("hsl"),n=e.indexOf("("),r=e.slice(0,n);if(r!=="rgb"&&r!=="rgba"&&r!=="hsl"&&r!=="hsla"||e.length>120||e.indexOf(")")!==e.length-1)return!1;let i=e.slice(n+1,-1).trim(),s,a,o=i.includes(",");if(o)s=i.split(",").map(l=>l.trim()),s.length===4&&(a=s.pop());else{let l=i.split("/");if(l.length>2)return!1;s=l[0].trim().split(/\s+/),l.length===2&&(a=l[1].trim())}if(s.length!==3||a!==void 0&&!pk(a,!o))return!1;let c=s.map(Xx);if(o)return t?(c[0]===1||c[0]===3)&&c[1]===2&&c[2]===2:(c[0]===1||c[0]===2)&&c[1]===c[0]&&c[2]===c[0];for(let l=0;l<3;l++){let u=c[l];if(!(u===1||u===4||(t&&l===0?u===3:u===2)))return!1}return!0}function qx(e){return e.includes("(")?mk(e):(jx??=new Set(fk.split(" ")),jx.has(e.toLowerCase()))}var gk=/^:?wrap:/,bk=/^:?nowrap:/,yk=/^:?(?:no)?wrap:/,Ek=/^(?:rgba?|hsla?)\s*\(/,Qx=/[\r\u2028\u2029]/,xk=/^\w*/;function ka(e){throw new qe(e,"semantic",{type:"sequence"})}function Zx(e){let t=e.trim(),n=gk.test(t)?!0:bk.test(t)?!1:void 0;return{text:(n===void 0?t:t.replace(yk,"")).trim(),wrap:n}}function Ak(e){let t=Ek.exec(e);if(t){let r=e.lastIndexOf(")");if(r>=t[0].length)return Qx.test(e.slice(t[0].length))?void 0:[e.slice(0,r+1),e.slice(r+1)]}if(Qx.test(e))return;let n=xk.exec(e)[0];return[n,e.slice(n.length)]}function Jx(e){return typeof e=="string"?[...e].map((t,n)=>[String(n),t]):e!==null&&typeof e=="object"?Object.entries(e):[]}var ld=class{type="sequence";actors=new Map;createdActors=new Map;destroyedActors=new Map;boxes=[];messages=[];notes=[];title;accTitle;accDescr;prevActor;currentBox;lastCreated;lastDestroyed;wrapEnabled;sequenceWrap;active=new Map;constructor(t={}){this.wrapEnabled=t.wrap,this.sequenceWrap=t.sequenceWrap??!1}autoWrap(){return this.wrapEnabled??this.sequenceWrap}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
116
+ `)}setDiagramTitle(t){this.title=t}parseMessage(t){return Zx(t)}parseBoxData(t){let n=Ak(t),r=n?.[0]?n[0].trim():"transparent",i=n?.[1]?n[1].trim():void 0;if(qx(r)||(r="transparent",i=t.trim()),i===void 0)return{text:void 0,color:r,wrap:void 0};let{text:s,wrap:a}=Zx(i);return{text:s||void 0,color:r,wrap:a}}addBox(t){this.currentBox={name:t.text,wrap:t.wrap??this.autoWrap(),fill:t.color,actorKeys:[]},this.boxes.push(this.currentBox)}addActor(t,n,r,i,s){let a=this.currentBox,o;if(s!==void 0){let h;try{h=cr(s.includes(`
117
+ `)?s+`
118
+ `:`{
119
+ `+s+`
120
+ }`)}catch(d){throw new qe(`Config of participant "${t}" is not valid YAML. ${d.message}`,"syntax",{type:"sequence"})}h!==null&&typeof h=="object"&&!Array.isArray(h)&&(o=h)}let c=o&&Object.prototype.hasOwnProperty.call(o,"type")?o.type:void 0,l=o&&Object.prototype.hasOwnProperty.call(o,"alias")?o.alias:void 0;c!=null&&(i=String(c)),l&&(!r||r.text===n)&&(r={text:String(l),wrap:r?.wrap,type:i});let u=this.actors.get(t);if(!(u&&(this.currentBox&&u.box&&this.currentBox!==u.box&&ka(`A same participant should only be defined in one Box: ${u.name} can't be in '${u.box.name}' and in '${this.currentBox.name}' at the same time.`),a=u.box?u.box:this.currentBox,u.box=a,n===u.name&&r==null))){if((r?.text==null||i==null)&&(r={text:n,type:i}),this.actors.set(t,{box:a,name:n,description:r.text,wrap:r.wrap??this.autoWrap(),prevActor:this.prevActor,links:new Map,properties:new Map,type:i??"participant"}),this.prevActor){let h=this.actors.get(this.prevActor);h&&(h.nextActor=t)}this.currentBox&&this.currentBox.actorKeys.push(t),this.prevActor=t}}addMessage(t,n,r,i){this.messages.push({id:String(this.messages.length),from:t,to:n,message:r.text,wrap:r.wrap??this.autoWrap(),answer:i})}addSignal(t,n,r,i,s=!1,a){if(i===18){let o=t?this.active.get(t)??0:0;o<1&&ka(`Trying to inactivate an inactive participant (${t})`),this.active.set(t,o-1)}else i===17&&t&&this.active.set(t,(this.active.get(t)??0)+1);return this.messages.push({id:String(this.messages.length),from:t,to:n,message:r?.text??"",wrap:r?.wrap??this.autoWrap(),type:i,activate:s,centralConnection:a??0}),!0}addNote(t,n,r){let i=r.wrap??this.autoWrap(),s={actor:t,placement:n,message:r.text,wrap:i},a=typeof t=="string"?[t,t]:t;this.notes.push(s),this.messages.push({id:String(this.messages.length),from:a[0],to:a[1],message:r.text,wrap:i,type:2,placement:n})}addLinks(t,n){let r=this.actors.get(t);if(r)try{let i=JSON.parse(n.text);for(let[s,a]of Jx(i))r.links.set(s,a)}catch{return}}addALink(t,n){let r=this.actors.get(t);if(!r)return;let i=n.text.indexOf("@");r.links.set(n.text.slice(0,i-1).trim(),n.text.slice(i+1).trim())}addProperties(t,n){let r=this.actors.get(t);if(r)try{let i=JSON.parse(n.text);for(let[s,a]of Jx(i))r.properties.set(s,a)}catch{return}}addDetails(t,n){let r=this.actors.get(t);r&&(r.details=n.text)}apply(t){let n=[],r=[],i=t;for(;;){i!==void 0&&(Array.isArray(i)?(n.push(i),r.push(0)):typeof i!="string"&&this.applyOne(i));let s=n.length-1;if(s<0)return;let a=n[s];r[s]<a.length?i=a[r[s]++]:(n.pop(),r.pop(),i=void 0)}}applyOne(t){let n=t.actor;switch(t.type){case"sequenceIndex":this.messages.push({id:String(this.messages.length),from:void 0,to:void 0,message:{start:t.sequenceIndex,step:t.sequenceIndexStep,visible:t.sequenceVisible===!0},wrap:!1,type:t.signalType});break;case"addParticipant":this.addActor(n,n,t.description,t.draw,t.config);break;case"createParticipant":this.actors.has(n)&&ka("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"),this.lastCreated=n,this.addActor(n,n,t.description,t.draw,t.config),this.createdActors.set(n,this.messages.length);break;case"destroyParticipant":this.lastDestroyed=n,this.destroyedActors.set(n,this.messages.length);break;case"activeStart":case"activeEnd":case"centralConnection":case"centralConnectionReverse":this.addSignal(n,void 0,void 0,t.signalType);break;case"addNote":this.addNote(t.actor,t.placement,t.text);break;case"addLinks":this.addLinks(n,t.text);break;case"addALink":this.addALink(n,t.text);break;case"addProperties":this.addProperties(n,t.text);break;case"addDetails":this.addDetails(n,t.text);break;case"addMessage":this.lastCreated?(t.to!==this.lastCreated&&ka(`The created participant ${this.lastCreated} does not have an associated creating message after its declaration. Please check the sequence diagram.`),this.lastCreated=void 0):this.lastDestroyed&&(t.to!==this.lastDestroyed&&t.from!==this.lastDestroyed&&ka(`The destroyed participant ${this.lastDestroyed} does not have an associated destroying message after its declaration. Please check the sequence diagram.`),this.lastDestroyed=void 0),this.addSignal(t.from,t.to,t.msg,t.signalType,t.activate,t.centralConnection);break;case"boxStart":this.addBox(t.boxData);break;case"boxEnd":this.currentBox=void 0;break;case"loopStart":this.addSignal(void 0,void 0,t.loopText,t.signalType);break;case"rectStart":this.addSignal(void 0,void 0,t.color,t.signalType);break;case"optStart":this.addSignal(void 0,void 0,t.optText,t.signalType);break;case"altStart":case"else":this.addSignal(void 0,void 0,t.altText,t.signalType);break;case"parStart":case"and":this.addSignal(void 0,void 0,t.parText,t.signalType);break;case"criticalStart":this.addSignal(void 0,void 0,t.criticalText,t.signalType);break;case"option":this.addSignal(void 0,void 0,t.optionText,t.signalType);break;case"breakStart":this.addSignal(void 0,void 0,t.breakText,t.signalType);break;case"loopEnd":case"rectEnd":case"optEnd":case"altEnd":case"parEnd":case"criticalEnd":case"breakEnd":this.addSignal(void 0,void 0,void 0,t.signalType);break}}};var tp=["$end","INVALID","INVALID","NEWLINE","SD","create","box","restOfLine","end","autonumber","NUM","off","activate","deactivate","title","legacy_title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","loop","rect","opt","alt","par","par_over","critical","break","option","and","else","participant","AS","participant_actor","destroy","note","over","links","link","properties","details",",","left_of","right_of","+","-","()","ACTOR","CONFIG_START","CONFIG_CONTENT","CONFIG_END","TXT","SOLID_OPEN_ARROW","DOTTED_OPEN_ARROW","SOLID_ARROW","BIDIRECTIONAL_SOLID_ARROW","DOTTED_ARROW","BIDIRECTIONAL_DOTTED_ARROW","SOLID_CROSS","DOTTED_CROSS","SOLID_POINT","DOTTED_POINT","SOLID_ARROW_TOP","SOLID_ARROW_BOTTOM","STICK_ARROW_TOP","STICK_ARROW_BOTTOM","SOLID_ARROW_TOP_DOTTED","SOLID_ARROW_BOTTOM_DOTTED","STICK_ARROW_TOP_DOTTED","STICK_ARROW_BOTTOM_DOTTED","SOLID_ARROW_TOP_REVERSE","SOLID_ARROW_BOTTOM_REVERSE","STICK_ARROW_TOP_REVERSE","STICK_ARROW_BOTTOM_REVERSE","SOLID_ARROW_TOP_REVERSE_DOTTED","SOLID_ARROW_BOTTOM_REVERSE_DOTTED","STICK_ARROW_TOP_REVERSE_DOTTED","STICK_ARROW_BOTTOM_REVERSE_DOTTED"];var eA=new Uint8Array(128);for(let e=0;e<128;e++){let t=String.fromCharCode(e),n=e===32||e>=9&&e<=13,r=0;`/\\+()<->:
121
+ ,;`.includes(t)||(r|=1),`+<->:
122
+ ,;`.includes(t)||(r|=2),`<>:
123
+ ,;@`.includes(t)||(r|=8|(n?0:4)),`#
124
+ ;`.includes(t)||(r|=16),!`/\\+()<>:
125
+ ,;-`.includes(t)&&!n&&(r|=32),eA[e]=r}function tA(e){let t=e.length,n=[],r=[],i=[],s=[],a=0,o=0,c=-1,l=(_,$,g)=>{n.push(_),r.push(e.slice($,g)),i.push($),o=g},u=(_,$,g,N)=>{n.push(_),r.push(N),i.push($),o=g},h=_=>{s.push(a),a=_},d=()=>{s.length>0&&(a=s.pop())},m=_=>(c<_&&(c=e.indexOf(`
126
+ `,_),c===-1&&(c=t)),c),p=(_,$)=>{let g=e.charCodeAt(_);return g<128?(eA[g]&$)!==0:$===4||$===32?!Xe(g):!0},y=(_,$)=>{for(let g=0;g<$.length;g++){let N=$.charCodeAt(g),w=e.charCodeAt(_+g);if(N>=97&&N<=122?(w|32)!==N:w!==N)return!1}return!0},E=_=>y(o,_)&&!it(e.charCodeAt(o+_.length)),b=_=>{for(;_<t&&Xe(e.charCodeAt(_));)_++;return _},S=()=>{let _=o;for(;_<t;){let $=e.charCodeAt(_);if($===10||!Xe($))break;_++}return _===o?!1:(o=_,!0)},x=_=>{for(;_<t&&p(_,16);)_++;return _},I=(_,$,g)=>{l(_,o,o+$),h(g)},L=(_,$,g=-1)=>E(_)?(l($,o,o+_.length),g>=0&&h(g),!0):!1,O=(_,$)=>{if(!y(o,_))return!1;let g=o+_.length,N=e.charCodeAt(g);if(N!==32&&N!==9)return!1;for(;N===32||N===9;)N=e.charCodeAt(++g);return g>=t||!p(g,32)?!1:(l($,o,o+_.length),!0)},v=_=>{let $=e.charCodeAt(_),g=e.charCodeAt(_+1);if($===45){if(g===120||g===88||g===41||g===92||g===47||g===45)return!0;let N=e.charCodeAt(_+2);return g===124&&(N===92||N===47)}return $===47||$===92?(g===124||g===$)&&e.charCodeAt(_+2)===45:$===40&&g===41},G=()=>{let _=o+1;for(;_<t&&p(_,1);)_++;for(;_<t&&!v(_);){let $=_;for(;e.charCodeAt($)===45;)$++;if($>=t||!p($,2))break;for($++;$<t&&p($,2);)$++;_=$}u(48,o,_,e.slice(o,_).trim())},K=()=>{let _=o;for(;Et(e.charCodeAt(_));)_++;let $=_>o;if(e.charCodeAt(_)===46&&Et(e.charCodeAt(_+1))){let N=Et(e.charCodeAt(_+2))?_+3:_+2,w=e.charCodeAt(N);if(w===32||w===10)return l(10,o,N),!0}let g=e.charCodeAt(_);return $&&(g===32||g===10)?(l(10,o,_),!0):!1},C=()=>{let _=e.charCodeAt(o+1),$=e.charCodeAt(o+2);if(_===62)l($===62?55:53,o,o+($===62?3:2));else if(_===120||_===88)l(59,o,o+2);else if(_===41)l(61,o,o+2);else if(_===124&&$===92)l(63,o,o+3);else if(_===124&&$===47)l(64,o,o+3);else if(_===92&&$===92)l(65,o,o+3);else if(_===47&&$===47)l(66,o,o+3);else if(_===45){let g=e.charCodeAt(o+3);$===62?l(g===62?57:54,o,o+(g===62?4:3)):$===120||$===88?l(60,o,o+3):$===41?l(62,o,o+3):$===124&&g===92?l(67,o,o+4):$===124&&g===47?l(68,o,o+4):$===92&&g===92?l(69,o,o+4):$===47&&g===47?l(70,o,o+4):l(46,o,o+1)}else l(46,o,o+1)},Z=_=>{let $=e.charCodeAt(o+1);if($!==124&&$!==_||e.charCodeAt(o+2)!==45)return!1;let g=e.charCodeAt(o+3)===45,N=_===47,w;return $===124?g?w=N?75:76:w=N?71:72:g?w=N?77:78:w=N?73:74,l(w,o,o+(g?4:3)),!0},oe=()=>{if(!y(o,"title"))return!1;let _=o+5,$=e.charCodeAt(_)===58;$&&_++;let g=_;for(;g<t&&e.charCodeAt(g)!==10&&Xe(e.charCodeAt(g));)g++;if(g===t||e.charCodeAt(g)===10)return o=g,!0;let N=e.charCodeAt(_);return!Xe(N)||N===13||!p(_+1,16)?!1:(l($?15:14,o,x(_+1)),!0)},H=()=>{let _=y(o,"accdescr");if(!_&&!y(o,"acctitle"))return!1;let $=b(o+8),g=e.charCodeAt($);return g===58?(l(_?18:16,o,b($+1)),h(_?6:5),!0):_&&g===123?(o=b($+1),h(7),!0):!1},z=_=>{switch(_|32){case 97:return L("actor",34,1)||L("alt",24,3)||L("and",30,3)||L("activate",12,1)||H()||L("autonumber",9);case 98:return L("box",6,3)||L("break",28,3);case 99:return L("create",5)||L("critical",27,3);case 100:return L("destroy",35,1)||O("details",41)||L("deactivate",13,1);case 101:return L("else",31,3)||L("end",8);case 108:return L("loop",21,3)||L("left of",43)||O("links",38)||O("link",39);case 110:return L("note",36);case 111:return L("opt",23,3)||L("option",29,3)||L("over",37)||L("off",11);case 112:return L("participant",32,1)||L("par",25,3)||L("par_over",26,3)||O("properties",40);case 114:return L("rect",22,3)||L("right of",44);case 115:return L("sequencediagram",4);case 116:return oe();default:return!1}},M=()=>{let _=e.charCodeAt(o);if(_===10){let $=o+1;for(;e.charCodeAt($)===10;)$++;l(3,o,$);return}if(Xe(_)){o=b(o+1);return}if(_===35||_===37&&e.charCodeAt(o+1)!==123){o=m(o);return}if(!((Et(_)||_===46)&&K())&&!(_<128&&(_|32)>=97&&(_|32)<=122&&z(_)))if(_===44)l(42,o,o+1);else if(_===59)l(3,o,o+1);else if(p(o,1))G();else if(_===45)C();else if(_===60&&e.startsWith("<<->>",o))l(56,o,o+5);else if(_===60&&e.startsWith("<<-->>",o))l(58,o,o+6);else{if((_===47||_===92)&&Z(_))return;_===58?l(52,o,x(o+1)):_===43?l(45,o,o+1):_===40&&e.charCodeAt(o+1)===41?l(47,o,o+2):l(2,o,o+1)}},T=()=>{if(S())return!0;let _=e.charCodeAt(o);if(_===35)return o=m(o),!0;if(_===64&&e.charCodeAt(o+1)===123)return I(49,2,4),!0;let $=o;for(;$<t&&p($,4);)$++;if($>o){let N=b($);if(e.charCodeAt(N)===64&&e.charCodeAt(N+1)===123)return l(48,o,$),!0;if(N>$&&y(N,"as")&&Xe(e.charCodeAt(N+2)))return l(48,o,$),h(2),!0}let g=$;for(;g<t&&p(g,8);)g++;if(g>o){let N=e.charCodeAt(g),w=g;if(g<t&&N!==10&&N!==59)for(w--;w>o&&e.charCodeAt(w)!==35;)w--;if(w>o)return u(48,o,w,e.slice(o,w).trim()),d(),!0}if(e.charCodeAt(g)===60)return l(2,o,m(o)),d(),!0;if(_!==10){let N=m(o);return u(2,o,N,e.slice(o,N).trim()),d(),!0}return!1},R=()=>{switch(a){case 0:return M(),!0;case 1:return T();case 2:return S()?!0:e.charCodeAt(o)===35?(o=m(o),!0):(d(),d(),E("as")?I(33,2,3):l(3,o,o),!0);case 3:return S()?!0:e.charCodeAt(o)===35?(o=m(o),!0):(l(7,o,x(o)),d(),!0);case 4:if(e.charCodeAt(o)!==125){let _=e.indexOf("}",o);return _===-1&&(_=t),l(50,o,_),!0}else{let _=b(o+1),$=_>o+1&&y(_,"as")&&Xe(e.charCodeAt(_+2));return l(51,o,o+1),d(),$?h(2):d(),!0}case 5:case 6:return l(a===5?17:19,o,m(o)),d(),!0;default:if(e.charCodeAt(o)===125)o++,d();else{let _=e.indexOf("}",o);_===-1&&(_=t),l(20,o,_)}return!0}};for(;o<t;)if(!R())return n.push(1),r.push(""),i.push(o),{types:n,texts:r,starts:i};return a===0||a===2?l(3,t,t):a===3?l(7,t,t):a===5?l(17,t,t):a===6?l(19,t,t):a===7&&l(20,t,t),n.push(0),r.push(""),i.push(t),{types:n,texts:r,starts:i}}var Bt=new Int8Array(79).fill(-1);Bt[53]=5;Bt[54]=6;Bt[55]=0;Bt[57]=1;Bt[56]=33;Bt[58]=34;Bt[59]=3;Bt[60]=4;Bt[61]=24;Bt[62]=25;Bt[63]=41;Bt[64]=42;Bt[65]=43;Bt[66]=44;Bt[67]=51;Bt[68]=52;Bt[69]=53;Bt[70]=54;Bt[71]=45;Bt[72]=46;Bt[73]=47;Bt[74]=48;Bt[75]=55;Bt[76]=56;Bt[77]=57;Bt[78]=58;var Hr=new Int8Array(79).fill(-1);Hr[21]=2;Hr[22]=3;Hr[23]=4;Hr[28]=5;Hr[24]=6;Hr[25]=7;Hr[26]=7;Hr[27]=8;Hr[6]=1;var Sk="'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'";function nA(e,t){let{types:n,texts:r,starts:i}=tA(e),s=0,a=x=>{let I=n[s];throw I===1?ut("sequence",e,i[s],"",!0):ut("sequence",e,i[s],`Expecting ${x}, got '${tp[I]}'`)},o=x=>(n[s]!==x&&a(`'${tp[x]}'`),r[s++]),c=()=>{let x=n[s];return x!==48&&x!==39&&a("'ACTOR'"),{type:"addParticipant",actor:r[s++]}},l=()=>t.parseMessage(o(52).trim().substring(1)),u=()=>{let x=n[s++];if(x===35){let L=c();return o(3),L.type="destroyParticipant",L}let I=c();if(n[s]===49&&n[s-1]===48){s++;let L=o(50);o(51),I.config=L.trim()}if(I.draw=x===32?"participant":"actor",n[s]===33){s++;let L=o(7);o(3),I.description=t.parseMessage(L)}else n[s]===3?s++:a("'AS', 'NEWLINE'");return I},h=x=>{let I=!1;n[s]===47&&(I=!0,s++);let L=Bt[n[s]];L<0&&a(Sk),s++;let O=n[s];(O===47||!I&&(O===45||O===46))&&s++;let v=c(),G=l(),K={type:"addMessage",from:x.actor,to:v.actor,signalType:L,msg:G},C=[x,v,K];if(I){let Z=O===47;K.activate=Z,K.centralConnection=Z?61:60,Z&&C.push({type:"centralConnection",signalType:59,actor:v.actor}),C.push({type:"centralConnectionReverse",signalType:60,actor:x.actor})}else O===45?(K.activate=!0,C.push({type:"activeStart",signalType:17,actor:v.actor})):O===46?C.push({type:"activeEnd",signalType:18,actor:x.actor}):O===47&&(K.activate=!0,K.centralConnection=59,C.push({type:"centralConnection",signalType:59,actor:v.actor}));return C},d=x=>{s++;let I=c();return[I,{type:x,actor:I.actor,text:l()}]},m=()=>{s++;let x=n[s];if(x===37){s++;let O=c(),v=O,G=[O.actor,O.actor];if(n[s]===42){s++;let K=c();v=[O,K],G=[O.actor,K.actor]}return[v,{type:"addNote",placement:2,actor:G,text:l()}]}x!==43&&x!==44&&a("'over', 'left_of', 'right_of'"),s++;let I=c(),L=x===43?0:1;return[I,{type:"addNote",placement:L,actor:I.actor,text:l()}]},p=()=>{s++;let x={type:"sequenceIndex",sequenceVisible:!0,signalType:26};return n[s]===10?(x.sequenceIndex=Number(r[s++]),x.sequenceIndexStep=n[s]===10?Number(r[s++]):1):n[s]===11&&(s++,x.sequenceVisible=!1),n[s]!==3&&a("'NEWLINE', 'NUM', 'off'"),s++,x},y=(x,I,L,O)=>{let v=x.list,G=x.sections;if(G)for(let K=G.length-2;K>=0;K-=2){let C={type:I,signalType:O};C[L]=t.parseMessage(G[K+1]),v=G[K].concat([C,v])}return v},E=x=>{let I=x.text,L=x.list;switch(x.kind){case 1:L[0]={type:"boxStart",boxData:t.parseBoxData(I)},L.push({type:"boxEnd",boxText:I});break;case 2:L[0]={type:"loopStart",loopText:t.parseMessage(I),signalType:10},L.push({type:"loopEnd",loopText:I,signalType:11});break;case 3:L[0]={type:"rectStart",color:t.parseMessage(I),signalType:22},L.push({type:"rectEnd",color:t.parseMessage(I),signalType:23});break;case 4:L[0]={type:"optStart",optText:t.parseMessage(I),signalType:15},L.push({type:"optEnd",optText:t.parseMessage(I),signalType:16});break;case 5:L[0]={type:"breakStart",breakText:t.parseMessage(I),signalType:30},L.push({type:"breakEnd",optText:t.parseMessage(I),signalType:31});break;case 6:L=y(x,"else","altText",13),L[0]={type:"altStart",altText:t.parseMessage(I),signalType:12},L.push({type:"altEnd",signalType:14});break;case 7:L=y(x,"and","parText",20),L[0]={type:"parStart",parText:t.parseMessage(I),signalType:x.startType},L.push({type:"parEnd",signalType:21});break;default:L=y(x,"option","optionText",28),L[0]={type:"criticalStart",criticalText:t.parseMessage(I),signalType:27},L.push({type:"criticalEnd",signalType:29})}return L};for(;n[s]===3;)s++;o(4);let b=[],S={kind:0,text:"",startType:0,list:[],sections:void 0};for(;;){let x=n[s],I=S.list;if(S.kind===1){if(x===32||x===34||x===35)I.push(u());else if(x===3)I.push([]),s++;else if(x===8){s++;let L=E(S);S=b.pop(),S.list.push(L)}else a("'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'");continue}switch(x){case 3:case 2:I.push([]),s++;break;case 32:case 34:case 35:I.push(u());break;case 5:{s++;let L=n[s];L!==32&&L!==34&&L!==35&&a("'participant', 'participant_actor', 'destroy'");let O=u();O.type="createParticipant",I.push(O);break}case 48:I.push(h(c())),o(3);break;case 39:{let L=n[s+1];I.push(L===48||L===39?d("addALink"):h(c())),o(3);break}case 38:I.push(d("addLinks")),o(3);break;case 40:I.push(d("addProperties")),o(3);break;case 41:I.push(d("addDetails")),o(3);break;case 36:I.push(m()),o(3);break;case 9:I.push(p());break;case 12:case 13:{s++;let L=c();o(3),I.push(x===12?{type:"activeStart",signalType:17,actor:L.actor}:{type:"activeEnd",signalType:18,actor:L.actor});break}case 14:case 15:{let L=r[s++].substring(x===14?6:7);t.setDiagramTitle(L),I.push(L);break}case 16:{s++;let L=o(17).trim();t.setAccTitle(L),I.push(L);break}case 18:{s++;let L=o(19).trim();t.setAccDescription(L),I.push(L);break}case 20:{let L=r[s++].trim();t.setAccDescription(L),I.push(L);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{s++;let L=o(7);b.push(S),S={kind:Hr[x],text:L,startType:x===26?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{S.kind!==(x===31?6:x===30?7:8)&&a("'end'"),s++;let O=o(7);(S.sections??=[]).push(I,O),S.list=[];break}case 8:{S.kind===0&&a("'NEWLINE', 'EOF'"),s++;let L=E(S);S=b.pop(),S.list.push(L);break}case 0:S.kind!==0&&a("'end'"),t.apply(I);return;default:a("'NEWLINE', 'ACTOR', 'participant', 'note', 'end'")}}}var wk=16,_k=10,rA=34,sA=4,pi=5,hi=6,as=' fill="var(--_s)" stroke="var(--_b)"',uo=' fill="none" stroke="var(--_b)"',Rk=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]),Tk=new Set(["actor","boundary","control","entity","database"]);function iA(e){return Rk.has(e)?e:"participant"}function $a(e){return Tk.has(e)}function oA(e,t,n,r,i=wk){if($a(e))return{w:Math.max(40,t.width+8),h:rA+(t.height>0?sA+t.height:0)};let s=e==="collections"?pi:e==="queue"?2*hi:0;return{w:Math.max(n,t.width+2*i)+s,h:Math.max(r,t.height+2*_k)+(e==="collections"?pi:0)}}function Mk(e,t,n){let r=f(t),i=s=>f(n+s);switch(e){case"actor":return`<circle cx="${r}" cy="${i(7)}" r="6"${as}/><path d="M${r},${i(13)}V${i(24)}M${f(t-10)},${i(17)}H${f(t+10)}M${f(t-8)},${i(34)}L${r},${i(24)}L${f(t+8)},${i(34)}"${uo}/>`;case"boundary":return`<path d="M${f(t-19)},${i(6)}V${i(28)}M${f(t-19)},${i(17)}H${f(t-8)}"${uo}/><circle cx="${f(t+3)}" cy="${i(17)}" r="11"${as}/>`;case"control":return`<circle cx="${r}" cy="${i(21)}" r="11"${as}/><path d="M${f(t+5)},${i(5)}L${f(t-1)},${i(10)}L${f(t+5)},${i(15)}"${uo}/>`;case"entity":return`<circle cx="${r}" cy="${i(15)}" r="11"${as}/><path d="M${f(t-11)},${i(30)}H${f(t+11)}"${uo}/>`;default:{let s=f(t-14),a=f(t+14);return`<path d="M${s},${i(7)}V${i(27)}A14,5 0 0 0 ${a},${i(27)}V${i(7)}A14,5 0 0 0 ${s},${i(7)}Z"${as}/><path d="M${s},${i(7)}A14,5 0 0 0 ${a},${i(7)}"${uo}/>`}}}function aA(e,t,n,r,i,s,a=""){let{w:o,h:c}=r,l=' class="pele-label"';if($a(e))return Mk(e,t,n)+Ce(i,t,n+rA+sA+i.height/2,l+a,s);let u=t-o/2;if(e==="collections"){let h=o-pi,d=c-pi,m=`<rect x="${f(u+pi)}" y="${f(n)}" width="${f(h)}" height="${f(d)}"${as}${ft}/>`,p=`<rect x="${f(u)}" y="${f(n+pi)}" width="${f(h)}" height="${f(d)}"${as}${ft}/>`;return m+p+Ce(i,u+h/2,n+pi+d/2,l,s)}if(e==="queue"){let h=f(u+hi),d=f(u+o-hi),m=f(n+c),p=f(c/2);return`<path d="M${h},${f(n)}H${d}A${hi},${p} 0 0 1 ${d},${m}H${h}A${hi},${p} 0 0 1 ${h},${f(n)}Z"${as}/><path d="M${d},${f(n)}A${hi},${p} 0 0 0 ${d},${m}"${uo}/>`+Ce(i,t-hi/2,n+c/2,l,s)}return`<rect x="${f(u)}" y="${f(n)}" width="${f(o)}" height="${f(c)}"${as}${ft}/>`+Ce(i,t,n+c/2,l,s)}var sp=[];function pn(e,t,n,r=1,i=!1){sp[e]={dotted:t,head:n,atStart:r!==1,atEnd:r!==0,bottom:i}}pn(0,!1,1);pn(1,!0,1);pn(3,!1,2);pn(4,!0,2);pn(5,!1,0);pn(6,!0,0);pn(24,!1,3);pn(25,!0,3);pn(33,!1,1,2);pn(34,!0,1,2);for(let e of[!1,!0]){let t=e?10:0;pn(41+t,e,4),pn(42+t,e,4,1,!0),pn(43+t,e,5),pn(44+t,e,5,1,!0),pn(45+t,e,4,0),pn(46+t,e,4,0,!0),pn(47+t,e,5,0),pn(48+t,e,5,0,!0)}var Ck=new Map([[10,"loop"],[12,"alt"],[15,"opt"],[19,"par"],[32,"par"],[27,"critical"],[30,"break"],[22,"rect"]]),Nk=12,np=28,cA=22,nr=10,lA=4,Ik=14,fo=10,kk=16,$k=20,Lk=10,dd=20,dA=240,ud=16,ho=4,uA=' stroke-dasharray="4 4"';function rp(e){return e!==void 0&&sp[e]!==void 0}function Ok(e,t){let n=new Array(e.length),r=new Array(e.length),i=1,s=1,a=!1;for(let o=0;o<e.length;o++){let c=e[o];if(n[o]=NaN,r[o]=!1,c.type===26){let l=c.message;i=l.start||i,s=l.step||s,a=l.visible}else rp(c.type)&&(n[o]=i,r[o]=a||t,i=Math.round((i+s)*100)/100)}return{index:n,shown:r,visible:a}}var fA={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function mi(e,t,n){let r=e[t];return typeof r=="number"&&r>=0&&r<=2e3?r:n}function hA(e,t,n,r,i,s){let a=f(e-n*$t);return i?`<path class="pele-marker" d="M${f(e)},${f(t)}L${a},${f(t+r*5)}"/>`:`<path class="pele-marker" d="M${f(e)},${f(t)}L${a},${f(t+r*4.5)}V${f(t)}Z" fill="${s}" stroke="none"/>`}function fd(e,t,n,r,i,s){switch(e){case 1:return wt("arrow_point",t,n,r,0,s);case 2:return wt("arrow_cross",t,n,r,0,s);case 3:return`<path class="pele-marker" d="M${f(t-r*$t)},${f(n-4.5)}L${f(t)},${f(n)}L${f(t-r*$t)},${f(n+4.5)}" stroke-linejoin="round"/>`;case 4:return hA(t,n,r,i,!1,s);case 5:return hA(t,n,r,i,!0,s);default:return""}}function Dk(e){return e===1?$t-1:e===2?4:0}function pA(e,t,n){return xn(n,r=>mA(e,t,n,r))}function mA(e,t,n,r,i=0,s=!0){let a=t.sequence??{},o=n.fontSize??16,c=Math.round(o*.875),l=Math.round(o*.75),u=n.measurer??at(n.fontFamily,n.fontFamilyMono),h=Array.isArray(n.monospace)&&n.monospace.includes("messages"),d=h?{width:(ye,Be,Oe)=>u.width(ye,Be,Oe|4)}:u,m=n.icons,p=n.padding??8,y=a.mirrorActors!==!1,E=a.rightAngles===!0,b=Math.min(mi(a,"actorMargin",40),r?8:1/0),S=Math.min(mi(a,"width",64),r?48:1/0),x=mi(a,"height",Math.round(o*1.5)+20),I=Math.min(mi(a,"width",160),r?Math.max(32,((n.maxWidth??320)-2*p)/Math.max(1,e.actors.size)-b-24):1/0),L=Math.max(4,14+mi(a,"messageMargin",35)-35),O=Math.min(mi(a,"noteMargin",10),r?6:1/0),v=Math.min(mi(a,"boxMargin",10),r?6:1/0),G=a.messageAlign==="left"?-1:a.messageAlign==="right"?1:0,K=r?6:Nk,C=r?8:kk,Z=r?12:$k,oe=r?6:Lk,H=e.messages,z=H.length,M=Ok(H,a.showSequenceNumbers===!0),T=(ye,Be,Oe,je=I,Ke=u)=>{let Je=Ue(ye,!1,Ke,Be,r||Oe?je:1/0);return r?Qs(Je,Ke,Math.max(120,je)):Je},R=(ye,Be,Oe=I)=>T(ye,c,Be,Oe,d),_;if(a.hideUnusedParticipants===!0){_=new Set;for(let ye of H)_.add(ye.from).add(ye.to)}let $=new Int32Array(z+1);$[z]=-1;for(let ye=z-1;ye>=0;ye--)$[ye]=rp(H[ye].type)?ye:$[ye+1];let g=[],N=new Map;for(let[ye,Be]of e.actors){if(_&&!_.has(ye))continue;let Oe=iA(Be.type),je=T(Be.description,o,Be.wrap),Ke=e.createdActors.get(ye),Je=e.destroyedActors.get(ye),Ge=Ke===void 0?-1:$[Math.min(Ke,z)];Ge>=0&&H[Ge].to!==ye&&(Ge=-1);let Ye=Je===void 0?-1:$[Math.min(Je,z)];Ye>=0&&H[Ye].to!==ye&&H[Ye].from!==ye&&(Ye=-1),N.set(ye,g.length),g.push({id:ye,actor:Be,kind:Oe,label:je,size:oA(Oe,je,S,x,r?8:void 0),x:0,createAt:Ge,destroyAt:Ye,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let w=g.length-1,A=new Map,D=(ye,Be,Oe)=>{if(ye<0||Be>w)return;let je=ye*g.length+Be;(A.get(je)??0)<Oe&&A.set(je,Oe)},U=ye=>M.shown[ye]?Math.max(ud,u.width(String(M.index[ye]),l,0)+8):0,B=new Array(z),F=new Array(z),W=(ye,Be)=>{let Oe=F[ye];if(!Oe){if(Be===I)return B[ye].label;F[ye]=Oe=new Map([[I,B[ye].label]])}let je=Oe.get(Be);return je||Oe.set(Be,je=R(H[ye].message,!0,Be)),je};for(let ye=0;ye<z;ye++){let Be=H[ye],Oe=Be.from===void 0?void 0:N.get(Be.from),je=Be.to===void 0?void 0:N.get(Be.to);if(!(Oe===void 0||je===void 0||typeof Be.message!="string")){if(Be.type===2){let Ke=T(Be.message,c,Be.wrap),Je=Ke.width+2*O;Be.placement===0?D(Oe-1,Oe,Je+2*fo+nr):Be.placement===1?D(Oe,Oe+1,Je+2*fo+nr):Oe===je?(D(Oe-1,Oe,Je/2+fo),D(Oe,Oe+1,Je/2+fo)):D(Math.min(Oe,je),Math.max(Oe,je),Je-2*C),B[ye]={kind:2,a:Oe,b:je,label:Ke,x:0,w:Je}}else if(rp(Be.type)){let Ke=R(Be.message,Be.wrap),Je=U(ye);if(Oe===je)D(Oe,Oe+1,np+8+Ke.width+16+nr+Je),B[ye]={kind:1,a:Oe,b:je,label:Ke,x:0,w:0};else{let Ge=g[je].createAt===ye?g[je].size.w/2:0,Ye=Be.centralConnection?4*ho:0;D(Math.min(Oe,je),Math.max(Oe,je),(r?Math.min(Ke.width,Math.max(16,I-16)):Ke.width)+2*K+nr+Je+Ge+Ye),B[ye]={kind:0,a:Oe,b:je,label:Ke,x:0,w:0}}}}}let j=[];for(let ye=0;ye<=w;ye++){let Be=g[ye].actor.box,Oe=j[j.length-1];Be&&Oe&&Oe.box===Be&&Oe.last===ye-1?Oe.last=ye:Be&&j.push({box:Be,first:ye,last:ye,title:T(Be.name,c,Be.wrap),grow:0})}let Q=new Array(Math.max(w,0));for(let ye=0;ye<w;ye++){let Be=g[ye],Oe=g[ye+1],je=Be.actor.box!==Oe.actor.box?(Be.actor.box?v:0)+(Oe.actor.box?v:0):0;Q[ye]=Math.max(Be.size.w/2+Oe.size.w/2+b+je,A.get(ye*g.length+ye+1)??0)}let Y=[];for(let[ye,Be]of A){let Oe=Math.floor(ye/g.length),je=ye%g.length;je-Oe>1&&Y.push([Oe,je,Be])}Y.sort((ye,Be)=>ye[1]-ye[0]-(Be[1]-Be[0])||ye[0]-Be[0]);for(let[ye,Be,Oe]of Y){let je=0;for(let Je=ye;Je<Be;Je++)je+=Q[Je];if(je>=Oe)continue;let Ke=(Oe-je)/(Be-ye);for(let Je=ye;Je<Be;Je++)Q[Je]+=Ke}let ne=()=>{for(let ye=1;ye<=w;ye++)g[ye].x=g[ye-1].x+Q[ye-1]};ne();for(let ye of j){let Be=g[ye.last].x+g[ye.last].size.w/2-(g[ye.first].x-g[ye.first].size.w/2);ye.grow=Math.max(0,(ye.title.width-Be)/2),ye.grow!==0&&(ye.first>0&&(Q[ye.first-1]+=ye.grow),ye.last<w&&(Q[ye.last]+=ye.grow))}let q=1/0,k=-1/0,J=(ye,Be)=>{ye<q&&(q=ye),Be>k&&(k=Be)},te=ye=>[g[ye.first].x-g[ye.first].size.w/2-v-ye.grow,g[ye.last].x+g[ye.last].size.w/2+v+ye.grow],se=new Array(z),re=()=>{ne(),q=1/0,k=-1/0;for(let Oe of g)J(Oe.x-Oe.size.w/2,Oe.x+Oe.size.w/2);for(let Oe of j)J(...te(Oe));let ye=[],Be=()=>w<0?[0,120]:[g[0].x-Z,g[w].x+Z];for(let Oe=0;Oe<z;Oe++){let je=H[Oe],Ke=je.type,Je=Ke===void 0?void 0:Ck.get(Ke),Ge=B[Oe];if(Je!==void 0){let Ye={kind:Je,x0:1/0,x1:-1/0,top:0,title:fA,tabW:0,fill:Je==="rect"&&typeof je.message=="string"?je.message:"",dividers:[Oe],dividerY:[],dividerLabels:[]};se[Oe]=Ye,ye.push(Ye)}else if(Ke===13||Ke===20||Ke===28)ye[ye.length-1]?.dividers.push(Oe);else if(Ke===11||Ke===14||Ke===16||Ke===21||Ke===29||Ke===31||Ke===23){let Ye=ye.pop();if(!Ye)continue;if(se[Oe]=Ye,Ye.x0>Ye.x1&&([Ye.x0,Ye.x1]=Be()),Ye.kind!=="rect"){Ye.tabW=u.width(Ye.kind,l,1)+14;for(let st=0;st<Ye.dividers.length;st++){let St=H[Ye.dividers[st]].message,dt=st===0?Ye.tabW+8:0,rt=Ye.x1-Ye.x0-16-dt,ht=St?T(`[${St}]`,c,!0,Math.max(rt,r?Math.min(dA,I):dA)):fA;ht.width>rt&&(Ye.x1+=ht.width-rt),st===0?Ye.title=ht:Ye.dividerLabels.push(ht)}}J(Ye.x0,Ye.x1);let tt=ye[ye.length-1];tt&&(tt.x0=Math.min(tt.x0,Ye.x0-oe),tt.x1=Math.max(tt.x1,Ye.x1+oe))}else if(Ge){let Ye=g[Ge.a],tt=g[Ge.b],st,St;if(Ge.kind===2){if(je.placement===0)Ge.x=Ye.x-fo-Ge.w;else if(je.placement===1)Ge.x=Ye.x+fo;else if(Ge.a===Ge.b)Ge.x=Ye.x-Ge.w/2;else{let rt=Math.min(Ye.x,tt.x)-C,ht=Math.max(Ye.x,tt.x)+C;(r||je.wrap)&&(Ge.label=T(je.message,c,!0,Math.max(I,ht-rt-2*O))),Ge.w=Math.max(ht-rt,Ge.label.width+2*O),Ge.x=(rt+ht-Ge.w)/2}st=Ge.x,St=Ge.x+Ge.w}else Ge.kind===1?(st=Ye.x,St=Ye.x+nr+np+8+Ge.label.width+U(Oe)):(st=Math.min(Ye.x,tt.x),St=Math.max(Ye.x,tt.x),(r||je.wrap)&&(Ge.label=W(Oe,Math.max(I,St-st-2*K-nr))),tt.createAt===Oe&&(tt.x>Ye.x?St+=tt.size.w/2:st-=tt.size.w/2));J(st,St);let dt=ye[ye.length-1];dt&&(dt.x0=Math.min(dt.x0,st-Z),dt.x1=Math.max(dt.x1,St+Z))}}};re();let P=!1,ee=!1;if(r&&n.maxWidth!==void 0){let ye=Math.floor(n.maxWidth)-Math.ceil(k-q+2*p)-i,Be=new Int32Array(g.length),Oe=new Array(Q.length).fill(0),je=[],Ke=0;for(let Ye=0;ye>0&&Ye<B.length;Ye++){let tt=B[Ye];if(tt?.kind!==0)continue;let st=R(H[Ye].message,!1,1/0);if(tt.label.lines.length<=st.lines.length)continue;je.push(Ye),Ke+=tt.label.lines.length;let St=Math.min(tt.a,tt.b),dt=Math.max(tt.a,tt.b);Be[St]++,Be[dt]--;let rt=(st.width-(g[dt].x-g[St].x-2*K-nr))/(dt-St);for(let ht=St;ht<dt;ht++)Oe[ht]=Math.max(Oe[ht],rt)}let Je=0,Ge=0;for(let Ye=0;Ye<Q.length;Ye++)Je+=Be[Ye],Be[Ye]=Je>0?1:0,Ge+=Be[Ye];if(Ge>0){let Ye=Q.slice(),tt=mt=>{for(let bt=0;bt<Q.length;bt++)Q[bt]=Ye[bt]+mt(bt);return re(),je.map(bt=>B[bt].label.lines.length)},st=mt=>mt.reduce((bt,Ct)=>bt+Ct,0),St=mt=>Be[mt]*ye/Ge,dt=tt(St),rt=st(Oe),ht=mt=>Oe[mt]*(ye-.01)/rt;if(s&&Ge>1&&rt>0&&Q.some((mt,bt)=>ht(bt)>St(bt))){let mt=dt;dt=tt(ht),ee=st(dt)<st(mt)&&dt.every((bt,Ct)=>bt<=mt[Ct]),ee||(dt=tt(St))}P=st(dt)<Ke,P||(Q.splice(0,Q.length,...Ye),re())}}let ae=0;for(let ye of j)ae=Math.max(ae,ye.title.height);let ue=j.length>0?v+(ae>0?ae+4:0):0,ce=0;for(let ye of g)ye.createAt<0&&(ce=Math.max(ce,ye.size.h));let he=ue+ce;for(let ye of g)ye.top=he-ye.size.h,ye.lifeStart=he;let V=g.map(ye=>ye.x),X=(ye,Be)=>{let Oe=0,je=V.length;for(;Oe<je;){let Ke=Oe+je>>1;V[Ke]<=ye?Oe=Ke+1:je=Ke}return Oe<V.length&&V[Oe]<Be},le=[],de=new Map,Ae=ye=>{if(ye)return de.has(ye)||de.set(ye,lr(Mt([`fill:${ye}`]).shape)),de.get(ye)},we=ye=>{let Be=Ae(ye);return Be?` fill="${Be}"`:""},Ee=(ye,Be)=>{for(let Oe=le.length-1;Oe>=0;Oe--)if(le[Oe].kind==="rect")return le[Oe].fill;for(let Oe of j){let[je,Ke]=te(Oe);if(ye>=je&&Be<=Ke)return Oe.box.fill}},Te=(ye,Be)=>we(Ee(ye,Be)),Me=(ye,Be,Oe,je=!1)=>{if(ye.width===0)return"";let Ke=Be-ye.width/2,Je=X(Ke,Ke+ye.width),Ge=Je?`<rect x="${f(Ke-3)}" y="${f(Oe-ye.height/2+2)}" width="${f(ye.width+6)}" height="${f(ye.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:"",Ye=Je?"":Te(Ke,Ke+ye.width);return Ge+Ce(ye,Be,Oe,je?` class="pele-frame-label"${Ye||' fill="var(--_m)"'} stroke="none"`:Ye,m)},Ie=(ye,Be=0)=>ye.activations.length+Be>0?ye.x-nr/2:ye.x,ge=(ye,Be=0)=>{let Oe=ye.activations.length+Be;return Oe>0?ye.x+nr/2+(Oe-1)*lA:ye.x},xe=[],ie=[],pe="",Re="",be="",Se="",Ne="",De="",ve=(ye,Be)=>{let Oe=ye.activations.pop(),je=Math.max(Be,Oe+Ik),Ke=ye.x-nr/2+ye.activations.length*lA;return J(Ke,Ke+nr),ie.push(`<rect class="pele-activation" data-id="${We(ye.id)}" x="${f(Ke)}" y="${f(Oe)}" width="${nr}" height="${f(je-Oe)}" rx="2"/>`),je},fe=(ye,Be)=>{let Oe=ye.x,je=Be+16;return ye.lifeEnd=je,De+=`<path class="pele-destroy" data-id="${We(ye.id)}" d="M${f(Oe-6)},${f(je-6)}L${f(Oe+6)},${f(je+6)}M${f(Oe+6)},${f(je-6)}L${f(Oe-6)},${f(je+6)}"/>`,je+6},_e=(ye,Be,Oe)=>{let je=ye.actor.properties.get("class");return`<g class="pele-node pele-actor pele-actor-${ye.kind}${Oe?" pele-actor-footer":""}${typeof je=="string"?Nt(je):""}" data-id="${We(ye.id)}">`+aA(ye.kind,ye.x,Be,ye.size,ye.label,m,$a(ye.kind)?we(ye.actor.box?.fill):"")+"</g>"},Fe=(ye,Be,Oe,je)=>`<g class="pele-sequence-number"><rect x="${f(Be-je/2)}" y="${f(Oe-ud/2)}" width="${f(je)}" height="${ud}" rx="${ud/2}" fill="var(--_l)" stroke="none"/><text x="${f(Be)}" y="${f(Oe+l*.35)}" text-anchor="middle" font-size="${l}" fill="var(--_bg)" stroke="none">${nt(String(M.index[ye]))}</text></g>`,me=he+6;for(let ye=0;ye<z;ye++){let Be=H[ye],Oe=Be.type,je=B[ye],Ke=se[ye];if(Oe===17){let Je=Be.from===void 0?void 0:N.get(Be.from);Je!==void 0&&g[Je].activations.push(me)}else if(Oe===18){let Je=Be.from===void 0?void 0:N.get(Be.from);Je!==void 0&&g[Je].activations.length>0&&(me=Math.max(me,ve(g[Je],me)))}else if(Ke&&Ke.dividers[0]===ye)le.push(Ke),Ke.kind==="rect"?(Ke.top=me+8,me=Ke.top):(Ke.top=me+12,me=Ke.top+Math.max(dd,Ke.title.height+2));else if(Ke){le.pop();let Je=me+12,Ge=f(Ke.x0),Ye=f(Ke.x1-Ke.x0);if(Ke.kind==="rect"){let tt=Ke.fill?Mt([`fill:${Ke.fill}`]).shape:"";xe.push(`<rect class="pele-rect" x="${Ge}" y="${f(Ke.top)}" width="${Ye}" height="${f(Je-Ke.top)}"${xt((tt?"":' fill-opacity="0.5"')+tt)}/>`)}else{let tt=`<rect x="${Ge}" y="${f(Ke.top)}" width="${Ye}" height="${f(Je-Ke.top)}" fill="none"${ft}/>`;for(let st=0;st<Ke.dividerY.length;st++){let St=Ke.dividerY[st],dt=Ke.dividerLabels[st];tt+=`<path d="M${Ge},${f(St)}H${f(Ke.x1)}"${uA}/>`+Me(dt,Ke.x0+8+dt.width/2,St+2+dt.height/2,!0)}tt+=`<rect x="${Ge}" y="${f(Ke.top)}" width="${f(Ke.tabW)}" height="${dd}" fill="var(--_s)"${ft}/><text class="pele-frame-kind" x="${f(Ke.x0+Ke.tabW/2)}" y="${f(Ke.top+dd/2+l*.35)}" text-anchor="middle" font-size="${l}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${Ke.kind}</text>`+Me(Ke.title,Ke.x0+Ke.tabW+8+Ke.title.width/2,Ke.top+Math.max(dd,Ke.title.height)/2,!0),pe+=`<g class="pele-frame pele-frame-${Ke.kind}">${tt}</g>`}me=Je}else if(Oe===13||Oe===20||Oe===28){let Je=le[le.length-1];if(Je){let Ge=Je.dividerLabels[Je.dividerY.length];Je.dividerY.push(me+12),me+=12+(Ge.height>0?Ge.height:0)}}else if(je&&je.kind===2){let Je=g[je.a],Ge=je.label.height+2*Math.max(4,O-4),Ye=me+10,tt=je.x;Be.placement===1?tt+=ge(Je)-Je.x:Be.placement===0&&(tt+=Ie(Je)-Je.x),J(tt,tt+je.w),Se+=`<g class="pele-note" data-id="i${We(Be.id)}"><rect x="${f(tt)}" y="${f(Ye)}" width="${f(je.w)}" height="${f(Ge)}"${ft}/>`+Ce(je.label,tt+je.w/2,Ye+Ge/2,' class="pele-label" stroke="none" fill="var(--_fg)"',m)+"</g>",me=Ye+Ge}else if(je){let Je=sp[Oe],Ge=g[je.a],Ye=g[je.b],tt=je.label,st=U(ye),St=0;for(let kt=ye+1;kt<z;kt++){let Xt=H[kt].type;if(Xt===17)H[kt].from===Be.to&&St++;else if(Xt!==18&&Xt!==59&&Xt!==60)break}let dt=Je.bottom?1:-1,rt=Je.dotted?uA:"",ht=Be.centralConnection,mt=ht===59||ht===61,bt=ht===60||ht===61,Ct,Pt="var(--_l)",Vn=(kt,Xt)=>`<circle class="pele-central" cx="${f(kt)}" cy="${f(Xt)}" r="${ho}" fill="${Pt}" stroke="none"/>`,yn=Je.atStart&&!Je.atEnd,Ar=Dk(Je.head),on="",an;if(je.kind===1){let kt=me+L+Math.max(0,(tt.height-cA)/2),Xt=kt+cA,$n=bt?Ge.x+ho:ge(Ge),Rn=mt?Ge.x+ho:ge(Ge,St),ir=Math.max($n,Rn)+np+st/2;Ct=Ae(Ee(Ge.x,ir)),Pt=Ct??Pt,bt&&(on+=Vn(Ge.x,kt)),mt&&(on+=Vn(Ge.x,Xt)),st>0&&(on+=Fe(ye,yn?Rn:$n,yn?Xt:kt,st),yn?Rn+=st/2:$n+=st/2);let qd=(Je.atStart?fd(Je.head,$n,kt,-1,dt,Pt):"")+(Je.atEnd?fd(Je.head,Rn,Xt,-1,-dt,Pt):""),za=f($n+(Je.atStart?Ar:0)),or=f(Rn+(Je.atEnd?Ar:0));on=`<path d="${E?`M${za},${f(kt)}H${f(ir)}V${f(Xt)}H${or}`:`M${za},${f(kt)}H${f(ir-6)}A6,6 0 0 1 ${f(ir)},${f(kt+6)}V${f(Xt-6)}A6,6 0 0 1 ${f(ir-6)},${f(Xt)}H${or}`}"${rt}/>`+qd+on,J(Ge.x,ir+8+tt.width),tt.width>0&&(be+=`<g class="pele-edge-label" data-id="i${We(Be.id)}">${Ce(tt,ir+8+tt.width/2,(kt+Xt)/2,Te(ir+8,ir+8+tt.width),m)}</g>`),an=Math.max(Xt,(kt+Xt)/2+tt.height/2)}else{let kt=Ye.x>Ge.x?1:-1,Xt=Ye.createAt===ye;Ct=Ae(Ee(Math.min(Ge.x,Ye.x),Math.max(Ge.x,Ye.x))),Pt=Ct??Pt,an=me+L+Math.max(tt.height>0?tt.height+2:6,Xt?Ye.size.h/2-L+6:0);let $n=kt>0?ge(Ge):Ie(Ge),Rn=kt>0?Ie(Ye,St):ge(Ye,St);if(Xt&&(Ye.top=an-Ye.size.h/2,Ye.lifeStart=Ye.top+Ye.size.h,Rn=Ye.x-kt*($a(Ye.kind)?18:Ye.size.w/2+1)),bt&&(on+=Vn(Ge.x,an),$n=Ge.x+kt*ho),mt&&(on+=Vn(Ye.x,an),Rn=Ye.x-kt*ho),st>0)if(yn){let or=mt?Rn-kt*(st/2+2):Rn;on+=Fe(ye,or,an,st),Rn=or-kt*st/2}else{let or=bt?$n+kt*(st/2+2):$n;on+=Fe(ye,or,an,st),$n=or+kt*st/2}let ir=(Je.atStart?fd(Je.head,$n,an,-kt,dt*kt,Pt):"")+(Je.atEnd?fd(Je.head,Rn,an,kt,dt*kt,Pt):""),qd=$n+(Je.atStart?kt*Ar:0),za=Rn-(Je.atEnd?kt*Ar:0);if(on=`<path d="M${f(qd)},${f(an)}H${f(za)}"${rt}/>`+ir+on,tt.width>0){let or=Math.min($n,Rn),Qd=Math.max($n,Rn),Zd=G<0?or+K+tt.width/2:G>0?Qd-K-tt.width/2:(or+Qd)/2;J(Zd-tt.width/2,Zd+tt.width/2),be+=`<g class="pele-edge-label" data-id="i${We(Be.id)}">${Me(tt,Zd,an-4-tt.height/2)}</g>`}Xt&&(me=an+Ye.size.h/2-6)}Re+=`<g class="pele-edge pele-message" data-id="i${We(Be.id)}"${Ct?` stroke="${Ct}"`:""}>${on}</g>`,me=Math.max(me,an),Ge.destroyAt===ye&&(me=Math.max(me,fe(Ge,an))),Ye.destroyAt===ye&&Ye!==Ge&&(me=Math.max(me,fe(Ye,an)))}}me+=20;for(let ye of g)for(;ye.activations.length>0;)ve(ye,me);let $e=me;if(y){let ye=0;for(let Be of g)Be.lifeEnd>=0||(ye=Math.max(ye,Be.size.h),Ne+=_e(Be,me,!0));$e=me+ye}let Pe="";for(let ye of g){Ne+=_e(ye,ye.top,!1);let Be=ye.lifeEnd>=0?ye.lifeEnd:me;Be>ye.lifeStart&&(Pe+=`<path class="pele-lifeline" data-id="${We(ye.id)}" d="M${f(ye.x)},${f(ye.lifeStart)}V${f(Be)}"/>`)}let ze="";for(let ye of j){let[Be,Oe]=te(ye),je=ye.box.fill==="transparent"?"":Mt([`fill:${ye.box.fill}`]).shape;ze+=`<g class="pele-cluster pele-box"${ye.box.name?` data-id="${We(ye.box.name)}"`:""}><rect x="${f(Be)}" y="0" width="${f(Oe-Be)}" height="${f($e+v)}" fill="var(--_a)" stroke="var(--_b)"${xt((je?"":' fill-opacity="0.5"')+je)}/>`+Ce(ye.title,(Be+Oe)/2,v/2+2+ye.title.height/2,` class="pele-cluster-label"${we(ye.box.fill)||' fill="var(--_m)"'}`,m)+"</g>"}j.length>0&&($e+=v);let Le=0,Ve="",Ze=It(n),ke=bn(e.title,u,o,r?Ze:1/0),Qe=r?Qs(ke,u,Math.max(120,Ze)):ke;if(q>k&&J(0,Math.max(Qe.width,40)),Qe.width>0){let ye=(q+k)/2;J(ye-Qe.width/2,ye+Qe.width/2),Le=-Qe.height-12,Ve=Ce(Qe,ye,Le+Qe.height/2,' class="pele-title" font-weight="var(--_tw)"',m)}let et=Math.ceil(k-q+2*p);if(P&&et>n.maxWidth)return mA(e,t,n,r,ee?i:i>0?1/0:et-Math.floor(n.maxWidth),!1);let pt=Math.ceil($e-Le+2*p);return{svg:ot("sequence",et,pt,o,n,e,`<g transform="translate(${f(p-q)},${f(p-Le)})">`+Ve+(ze?`<g class="pele-boxes" font-size="${c}">${ze}</g>`:"")+(xe.length>0?`<g class="pele-rects" fill="var(--_a)">${xe.reverse().join("")}</g>`:"")+(Pe?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${Pe}</g>`:"")+(ie.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${ie.reverse().join("")}</g>`:"")+(pe?`<g class="pele-frames" font-size="${c}" stroke="var(--_b)">${pe}</g>`:"")+(Re?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${Re}</g>`:"")+(De?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${De}</g>`:"")+(be?`<g class="pele-edge-labels" font-size="${c}"${h?` font-family="${ur}"`:""}>${be}</g>`:"")+(Se?`<g class="pele-notes" font-size="${c}" fill="var(--_a)" stroke="var(--_b)">${Se}</g>`:"")+(Ne?`<g class="pele-nodes">${Ne}</g>`:"")+"</g>"),width:et,height:pt,links:[]}}var gA={type:"sequence",math:!0,parse(e,t,n){let r=t.sequence??{},i=new ld({wrap:typeof t.wrap=="boolean"?t.wrap:void 0,sequenceWrap:r.wrap===!0});return n&&i.setDiagramTitle(n),nA(e,i),i},render:pA};function vk(e){let t="TB";for(let n of e)typeof n!="string"&&n.stmt==="dir"&&(t=n.value);return t}function bA(e,t,n){let r=[],i=[],s=new Map,a=new Map,o=new Map,c=0,l=0,u=m=>{if(!m.id||m.id==="</join></fork>"||m.id==="</choice>")return;if(m.cssClasses){let y;for(let E of m.cssClasses.split(" ")){let b=n.get(E);if(b){y??=m.cssCompiledStyles.slice();for(let S of b.styles)y.push(S)}}y&&(m.cssCompiledStyles=y)}let p=s.get(m.id);if(p){let y=m.parentId??p.parentId;Object.assign(p,m),y!==void 0&&(p.parentId=y)}else s.set(m.id,m),r.push(m)},h=(m,p,y)=>{let E=p.id;if(E==="root")return;let b=t.get(E),S=b?.classes?.join(" ")??"",x=b?.styles??[],I=a.get(E);if(!I){let H="rect";p.start===!0?H="stateStart":p.start===!1&&(H="stateEnd"),p.type!=="default"&&(H=p.type),I={shape:H,description:E,cssClasses:`${S} statediagram-state`,cssStyles:x,type:void 0,dir:void 0,colorIndex:void 0},a.set(E,I)}if(p.description&&(Array.isArray(I.description)?(I.shape="rectWithTitle",I.description=I.description.concat(p.description)):I.description.length>0?(I.shape="rectWithTitle",I.description=I.description===E?[p.description].flat():[I.description,p.description].flat()):(I.shape="rect",I.description=Array.isArray(p.description)?p.description.slice():p.description)),I.description.length===1&&I.shape==="rectWithTitle"&&(I.shape=I.type==="group"?"roundedWithTitle":"rect"),!I.type&&p.doc){if(I.type="group",I.dir=vk(p.doc),I.shape=p.type==="divider"?"divider":"roundedWithTitle",I.shape==="divider"&&m?.id!==void 0&&o.has(m.id))I.colorIndex=o.get(m.id);else{let H=l++;I.colorIndex=S.trim()!==""||x.length>0?void 0:H}o.set(E,I.colorIndex),I.cssClasses=`${I.cssClasses} statediagram-cluster ${y?"statediagram-cluster-alt":""}`}let L=I.description,O={id:E,shape:I.shape,label:Array.isArray(L)?L[0]:L,description:Array.isArray(L)?L.slice(1):[],cssClasses:I.cssClasses,cssCompiledStyles:[],cssStyles:I.cssStyles,type:I.type,isGroup:I.type==="group",dir:I.dir,colorIndex:I.colorIndex};O.shape==="divider"&&(O.label=""),m&&m.id!=="root"&&(O.parentId=m.id);let v=p.note;if(!v){u(O);return}let G=(H,z,M,T)=>({id:H,shape:z,label:v.text,description:[],cssClasses:M,cssCompiledStyles:[],cssStyles:[],type:T?"group":"node",isGroup:T,dir:void 0,position:v.position}),K=G(`${E}----note-${c++}`,"note","statediagram-note",!1);K.parentId=`${E}----parent`,K.noteFor=E,u(G(K.parentId,"noteGroup",I.cssClasses,!0)),u(K),u(O);let C=v.position==="left of",Z=C?K.id:E,oe=C?E:K.id;i.push({id:`${Z}-${oe}`,start:Z,end:oe,label:"",classes:"transition note-edge",pattern:"dashed"})},d=[{item:void 0,doc:e,at:0,alt:!0}];for(;d.length>0;){let m=d[d.length-1];if(m.at>=m.doc.length){d.pop();continue}let p=m.doc[m.at++];typeof p!="string"&&(p.stmt==="state"?(h(m.item,p,m.alt),p.doc&&d.push({item:p,doc:p.doc,at:0,alt:!m.alt})):p.stmt==="relation"&&(h(m.item,p.state1,m.alt),h(m.item,p.state2,m.alt),i.push({id:`edge${c++}`,start:p.state1.id,end:p.state2.id,label:p.description??"",classes:"transition"})))}for(let m of r)if(m.isGroup&&m.description.length>0)throw new qe(`Group nodes can only have label. Remove the additional description for node [${m.id}]`,"semantic",{type:"state"});return{nodes:r,edges:i}}var hd=class{type="state";rootDoc=[];states=new Map;relations=[];classes=new Map;links=new Map;graph={nodes:[],edges:[]};title;accTitle;accDescr;dividerCount=0;get direction(){let t="TB";for(let n of this.rootDoc)typeof n!="string"&&n.stmt==="dir"&&(t=n.value);return t}setRootDoc(t){this.rootDoc=t,this.translate(),this.extract(t)}extract(t){this.states=new Map,this.relations=[],this.classes=new Map;let n=Array.isArray(t)?t:t.doc;for(let r of n)if(typeof r!="string")switch(r.stmt){case"state":this.addState(r.id.trim(),r.type,r.doc,r.description,r.note);break;case"relation":this.addRelation(r.state1,r.state2,r.description);break;case"classDef":this.addStyleClass(r.id.trim(),r.classes);break;case"style":{let i=r.styleClass.split(",").map(s=>s.replace(/;/g,"").trim());for(let s of this.named(r.id.trim()))s.styles=i.slice();break}case"applyClass":this.setCssClass(r.id.trim(),r.styleClass);break;case"click":this.addLink(typeof r.id=="string"?r.id:r.id.id,r.url,r.tooltip);break}this.graph=bA(n,this.states,this.classes)}translate(){let t=[["root",{stmt:"root",id:"root",doc:this.rootDoc},!0]];for(;t.length>0;){let[n,r,i]=t.pop();if(typeof r=="string")continue;if(r.stmt==="relation"){t.push([n,r.state2,!1],[n,r.state1,!0]);continue}if(r.stmt==="state")r.id==="[*]"?(r.id=n+(i?"_start":"_end"),r.start=i):r.id=r.id.trim();else if(r.stmt!=="root")continue;if(!r.doc)continue;let s=[],a=[];for(let o of r.doc)typeof o!="string"&&o.stmt==="state"&&o.type==="divider"&&!o.doc?(s.push({...o,doc:a}),a=[]):a.push(o);s.length>0&&(a.length>0&&s.push({stmt:"state",id:this.getDividerId(),type:"divider",doc:a}),r.doc=s);for(let o=r.doc.length-1;o>=0;o--)t.push([r.id,r.doc[o],!0])}}addState(t,n="default",r,i,s,a){let o=t.trim(),c=this.states.get(o);if(c?(c.doc||(c.doc=r),c.type||(c.type=n)):(c={stmt:"state",id:o,descriptions:[],type:n,doc:r,note:s,classes:[],styles:[],textStyles:[]},this.states.set(o,c)),i)for(let l of Array.isArray(i)?i:[i])this.addDescription(o,l.trim());if(s&&(c.note=s),a)for(let l of a)this.setCssClass(o,l.trim())}getState(t){return this.states.get(t)}addLink(t,n,r){this.links.set(t,{url:n,tooltip:r})}addRelation(t,n,r=""){for(let i of[t,n])this.addState(i.id,i.type,i.doc,i.description,i.note,i.classes);this.relations.push({id1:t.id.trim(),id2:n.id.trim(),relationTitle:r})}addDescription(t,n){this.states.get(t)?.descriptions?.push(n.startsWith(":")?n.replace(":","").trim():n)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(t,n=""){let r=this.classes.get(t);if(r||(r={id:t,styles:[],textStyles:[]},this.classes.set(t,r)),!!n)for(let i of n.split(",")){let s=i.replace(";","").trim();i.includes("color")&&r.textStyles.push(s.replace("fill","bgFill").replace("color","fill")),r.styles.push(s)}}setCssClass(t,n){for(let r of this.named(t))r.classes?.push(n)}getDirection(){for(let t of this.rootDoc)if(typeof t!="string"&&t.stmt==="dir")return t.value;return"TB"}setDirection(t){for(let n of this.rootDoc)if(typeof n!="string"&&n.stmt==="dir"){n.value=t;return}this.rootDoc.unshift({stmt:"dir",value:t})}trimColon(t){return t.startsWith(":")?t.slice(1).trim():t.trim()}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
127
+ `)}named(t){let n=[];for(let r of t.split(",")){let i=this.states.get(r);i||(this.addState(r),i=this.states.get(r.trim())),i&&n.push(i)}return n}};var ip=["$end","INVALID","NL","SD","DESCR","-->","HIDE_EMPTY","scale","WIDTH","COMPOSIT_STATE","STRUCT_START","STRUCT_STOP","STATE_DESCR","AS","ID","FORK","JOIN","CHOICE","CONCURRENT","note","NOTE_TEXT","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","CLICK","STRING","HREF","classDef","CLASSDEF_ID","DEFAULT_CLASSDEF_ID","CLASSDEF_STYLEOPTS","DEFAULT","style","STYLE_IDS","STYLEDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","direction_tb","direction_bt","direction_rl","direction_lr","EDGE_STATE","STYLE_SEPARATOR","left_of","right_of","INVALID"];var Pk=/direction/gi,Fk=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,Bk=/[\n\r\u2028\u2029]/g,Wk=/%%/g,Uk=/\{/g;function La(e,t){let n=0,r=-2;return i=>{if(r===-2||i<n||r!==-1&&i>r){e.lastIndex=i;let s=e.exec(t);r=s?s.index:-1,n=i}return r}}function yA(e){let t=e.length,n=[],r=[],i=[],s=[],a=0,o=0,c,l=La(Pk,e),u=La(Fk,e),h=La(Bk,e),d=La(Wk,e),m=La(Uk,e),p=-1,y=-1,E=[-1,-1,-1,-1],b=[0,0,0,0],S=-1,x=-1,I=[-1,-1,-1,-1,-1,-1],L=(_,$,g)=>{n.push(_),r.push(e.slice($,g)),i.push($),o=g},O=(_,$,g,N)=>{n.push(_),r.push($),i.push(g),o=N},v=_=>{s.push(a),a=_},G=()=>{s.length>0&&(a=s.pop())},K=(_,$)=>{for(let g=0;g<_.length;g++){let N=_.charCodeAt(g),w=e.charCodeAt($+g);if(w!==N&&!(N>=97&&N<=122&&w===N-32))return!1}return!0},C=_=>{let $=_;for(;$<t&&Xe(e.charCodeAt($));)$++;return $},Z=_=>{let $=_;for(;$<t&&it(e.charCodeAt($));)$++;return $},oe=_=>{let $=e.indexOf(`
128
+ `,_);return $===-1?t:$},H=_=>{let $=h(_);return $===-1?t:$},z=_=>{if(_<p||_>y){let $=l(_),g=$===-1?t:H(_);p=_,y=g,E[0]=E[1]=E[2]=E[3]=-1;for(let N=$;N!==-1&&N<g;N=l(N+1)){let w=C(N+9);if(w===N+9)continue;let A=K("tb",w)?0:K("bt",w)?1:K("rl",w)?2:K("lr",w)?3:-1;A!==-1&&(E[A]=N,b[A]=w+2)}}for(let $=0;$<4;$++)if(E[$]>=_)return $;return-1},M=_=>{if(_<S||_>x){let $=u(_),g=$===-1?t:H(_);S=_,x=g,I.fill(-1);for(let N=$;N!==-1&&N<g;N=u(N+1)){let w=e.charCodeAt(N+2)|32;I[(e.charCodeAt(N)===60?0:3)+(w===102?0:w===106?1:2)]=N}}for(let $=0;$<6;$++)if(I[$]>=_)return $;return-1},T=(_,$)=>{let g=d(_);return g===-1||g+2>$?(L(14,_,$),!0):g===_?(o=$,!1):(L(14,_,g),!0)},R=_=>(n.push(_),r.push(""),i.push(o),{types:n,texts:r,starts:i,error:c});for(;;){if(o>=t){switch(a){case 0:L(2,t,t);break;case 6:L(22,t,t);break;case 7:L(24,t,t);break;case 8:L(25,t,t);break;case 10:L(32,t,t);break;case 12:L(39,t,t);break;case 14:L(36,t,t);break;case 3:L(12,t,t);break;case 18:L(20,t,t);break;case 4:case 19:L(14,t,t);break}return R(0)}let _=e.charCodeAt(o);switch(a){case 0:case 1:{let $=a===0,g=_|32;if($){if(g===99&&K("click",o)&&!it(e.charCodeAt(o+5))){L(26,o,o+5);continue}if(g===104&&K("href",o)&&!it(e.charCodeAt(o+4))){L(28,o,o+4);continue}if(_===34){let A=e.indexOf('"',o+1);if(A!==-1){L(27,o,A+1);continue}}if(g===100&&K("default",o)&&!it(e.charCodeAt(o+7))){L(33,o,o+7);continue}let w=z(o);if(w!==-1){L(40+w,o,oe(b[w]));continue}if(_===10){let A=o+1;for(;e.charCodeAt(A)===10;)A++;L(2,o,A);continue}if(Xe(_)){o=C(o);continue}}else if(_!==10&&Xe(_)){let w=o+1;for(;w<t&&e.charCodeAt(w)!==10&&Xe(e.charCodeAt(w));)w++;o=w;continue}if(_===35||_===37&&e.charCodeAt(o+1)===37&&e.charCodeAt(o+2)!==123){o=oe(o);continue}if(g===115){if($&&K("scale",o)){let w=C(o+5);if(w>o+5){L(7,o,w),v(5);continue}}if(K("style",o)){let w=C(o+5);if(w>o+5){L(34,o,w),v(13);continue}}if(K("state",o)){let w=C(o+5);if(w>o+5){o=w,v(2);continue}if($&&K("diagram",o+5)){let A=K("-v2",o+12)?o+15:o+12;if(w=C(A),w>A){L(3,o,w);continue}}}}else if(g===99){if(K("class",o)){let w=K("def",o+5),A=w?o+8:o+5,D=C(A);if(D>A){L(w?29:37,o,D),v(w?9:11);continue}}}else if(g===97&&$&&(K("acctitle",o)||K("accdescr",o))){let w=(e.charCodeAt(o+3)|32)===116,A=C(o+8),D=e.charCodeAt(A);if(D===58){L(w?21:23,o,C(A+1)),v(w?6:7);continue}if(D===123&&!w){o=C(A+1),v(8);continue}}if($){if(_===123){L(10,o,o+1),v(1);continue}}else{let w=z(o);if(w!==-1){L(40+w,o,oe(b[w]));continue}if(_===125){L(11,o,o+1),G();continue}if(_===10){o++;continue}}if(g===110&&K("note",o)){let w=C(o+4);if(w>o+4){L(19,o,w),v(15);continue}}if($&&g===104&&K("hide empty description",o)&&!it(e.charCodeAt(o+22))){L(6,o,o+22);continue}if(_===91&&e.charCodeAt(o+1)===42&&e.charCodeAt(o+2)===93){L(44,o,o+3);continue}let N=o;for(;N<t;){let w=e.charCodeAt(N);if(w===58||w===45||w===123||Xe(w))break;N++}if(N>o){T(o,N);continue}if(_===58){for(N=o+1;N<t;){let w=e.charCodeAt(N);if(w===10||w===59)break;if(w===58){let A=e.charCodeAt(N+1);if(N+1>=t||A===58||A===10||A===59)break;N++}N++}if(N>o+1){O(4,e.slice(o,N).trim(),o,N);continue}if(e.charCodeAt(o+1)===58&&e.charCodeAt(o+2)===58){L(45,o,o+3);continue}}else if(_===45&&e.charCodeAt(o+1)===45){if(e.charCodeAt(o+2)===62){L(5,o,o+3);continue}if(!$){L(18,o,o+2);continue}}if(!$)return R(1);L(48,o,o+1);continue}case 2:{if(_!==10&&Xe(_)){let w=o+1;for(;w<t&&e.charCodeAt(w)!==10&&Xe(e.charCodeAt(w));)w++;o=w;continue}if(_===35||_===37&&e.charCodeAt(o+1)===37&&e.charCodeAt(o+2)!==123){o=oe(o);continue}let $=M(o);if($!==-1){let w=I[$],A=$===2||$===5;O(A?17:$%3===0?15:16,e.slice(o,w).trim(),o,w+(A?10:8)),G();continue}if(_===34){o++,v(3);continue}let g=_===10?C(o):o;if(K("as",g)){let w=C(g+2);if(w>g+2){L(13,o,w),v(4);continue}}if(_===10){o++,G();continue}if(_===123){L(10,o,o+1),G(),v(1);continue}if(it(_)){let w=Z(o),A=C(w);if(A>w&&it(e.charCodeAt(A))){let D=m(A+1);if(D!==-1&&D<H(A))return c=`Error: State name must be a single word. Found: "${e.slice(o,D+1).trim()}"`,R(1)}}let N=o+1;for(;N<t;){let w=e.charCodeAt(N);if(w===123||Xe(w))break;N++}L(9,o,N);continue}case 3:{if(_===34){o++,G();continue}let $=e.indexOf('"',o);L(12,o,$===-1?t:$);continue}case 4:{let $=o;for(;$<t;){let g=e.charCodeAt($);if(g===10||g===123)break;$++}T(o,$)&&G();continue}case 5:{if(_>=48&&_<=57){let g=o+1;for(;g<t&&e.charCodeAt(g)>=48&&e.charCodeAt(g)<=57;)g++;L(8,o,g);continue}let $=C(o);if($>o&&K("width",$)&&!it(e.charCodeAt($+5))){o=$+5,G();continue}return R(1)}case 6:L(22,o,oe(o)),G();continue;case 7:L(24,o,oe(o)),G();continue;case 8:{if(_===125){o++,G();continue}let $=e.indexOf("}",o);L(25,o,$===-1?t:$);continue}case 9:{let $=K("default",o)&&C(o+7)>o+7,g=$?o+7:Z(o),N=C(g);if(g===o||N===g)return R(1);L($?31:30,o,N),G(),v(10);continue}case 10:L(32,o,oe(o)),G();continue;case 11:{let $=Z(o);if($===o)return R(1);for(;e.charCodeAt($)===44;){let g=C($+1),N=Z(g);if(N===g)break;$=N}L(38,o,$),G(),v(12);continue}case 12:L(39,o,oe(o)),G();continue;case 13:{let $=o;for(;$<t&&(it(e.charCodeAt($))||e.charCodeAt($)===44);)$++;let g=C($);if($===o||g===$)return R(1);L(35,o,g),G(),v(14);continue}case 14:L(36,o,oe(o)),G();continue;case 15:{if(K("left of",o)&&!it(e.charCodeAt(o+7))){L(46,o,o+7),G(),v(16);continue}if(K("right of",o)&&!it(e.charCodeAt(o+8))){L(47,o,o+8),G(),v(16);continue}if(_===34){o++,G(),v(18);continue}return R(1)}case 16:{let $=C(o),g=$;for(;g<t;){let N=e.charCodeAt(g);if(N===58||N===45||Xe(N))break;g++}if(g===$)return R(1);T(o,g)&&(G(),v(17));continue}case 17:{let $=C(o);if(e.charCodeAt($)===58){let w=$+1;for(;w<t;){let A=e.charCodeAt(w);if(A===58||A===10||A===59)break;w++}if(w>$+1){O(20,e.slice(o+2,w).trim(),o,w),G();continue}}let g=e.indexOf(`
129
+ `,o),N=-1;for(;g!==-1&&(N=C(g),!(K("end note",N)&&!it(e.charCodeAt(N+8))));)g=e.indexOf(`
130
+ `,N);if(g===-1)return R(1);O(20,e.slice(o,N).trim(),o,N+8),G();continue}case 18:{let $=C(o);if(K("as",$)){L(13,o,C($+2)),G(),v(19);continue}if(_===34){o++;continue}let g=e.indexOf('"',o);L(20,o,g===-1?t:g);continue}case 19:T(o,oe(o))&&G();continue}}}var Gk=["TB","BT","RL","LR"],pd="'NL', 'ID', 'HIDE_EMPTY', 'scale', 'COMPOSIT_STATE', 'STATE_DESCR', 'FORK', 'JOIN', 'CHOICE', 'CONCURRENT', 'note', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'CLICK', 'classDef', 'style', 'class', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'EDGE_STATE'";function EA(e,t){let{types:n,texts:r,starts:i,error:s}=yA(e),a=0,o=p=>{let y=n[a];throw y===1?s!==void 0?new qe(s,"syntax",{type:"state",...ar(e,i[a])}):ut("state",e,i[a],"",!0):ut("state",e,i[a],`Expecting ${p}, got '${ip[y]}'`)},c=p=>(n[a]!==p&&o(`'${ip[p]}'`),r[a++]),l=()=>{let p=n[a];p!==14&&p!==44&&o("'ID', 'EDGE_STATE'");let y=r[a++].trim();return n[a]!==45?{stmt:"state",id:y,type:"default",description:""}:(a++,{stmt:"state",id:y,classes:[c(14).trim()],type:"default",description:""})};for(;n[a]===2;)a++;n[a]!==3&&o("'NL', 'SD'"),a++;let u=[],h=[],d=p=>{p!=="nl"&&u.push(p)},m=(p,y)=>{a++;let E=[];u.push({stmt:"state",id:p,type:"default",description:y,doc:E}),h.push(u),u=E};for(;;){let p=n[a];switch(p){case 2:a++;break;case 14:case 44:{let y=l();if(n[a]===4)y.description=t.trimColon(r[a++]),d(y);else if(n[a]===5){a++;let E=l();n[a]===4?d({stmt:"relation",state1:y,state2:E,description:t.trimColon(r[a++])}):d({stmt:"relation",state1:y,state2:E})}else d(y);break}case 6:d(r[a++]);break;case 7:a++,c(8),d(r[a-2]);break;case 9:n[a+1]===10?m(r[a++],""):d(r[a++]);break;case 12:{let y=r[a++];c(13);let E=c(14);if(n[a]===10)m(E,y);else if(E.includes(":")){let b=E.split(":");d({stmt:"state",id:b[0],type:"default",description:[y.trim(),b[1]]})}else d({stmt:"state",id:E,type:"default",description:y.trim()});break}case 15:d({stmt:"state",id:r[a++],type:"fork"});break;case 16:d({stmt:"state",id:r[a++],type:"join"});break;case 17:d({stmt:"state",id:r[a++],type:"choice"});break;case 18:a++,d({stmt:"state",id:t.getDividerId(),type:"divider"});break;case 19:{let y=r[a++];if(n[a]===46||n[a]===47){let E=r[a++].trim(),b=c(14).trim();d({stmt:"state",id:b,note:{position:E,text:c(20).trim()}})}else n[a]!==20&&o("'NOTE_TEXT', 'left_of', 'right_of'"),a++,c(13),c(14),d(y);break}case 40:case 41:case 42:case 43:{let y=Gk[p-40];a++,t.setDirection(y),d({stmt:"dir",value:y});break}case 21:{a++;let y=c(22).trim();t.setAccTitle(y),d(y);break}case 23:{a++;let y=c(24).trim();t.setAccDescription(y),d(y);break}case 25:{let y=r[a++].trim();t.setAccDescription(y),d(y);break}case 26:{a++;let y=l(),E,b="";n[a]===28?(a++,E=c(27)):(n[a]!==27&&o("'STRING', 'HREF'"),E=r[a++],b=c(27)),c(2),d({stmt:"click",id:y,url:E,tooltip:b});break}case 29:{a++;let y=c(30).trim();d({stmt:"classDef",id:y,classes:c(32).trim()});break}case 34:{a++;let y=c(35).trim();d({stmt:"style",id:y,styleClass:c(36).trim()});break}case 37:{a++;let y=c(38).trim();d({stmt:"applyClass",id:y,styleClass:c(39).trim()});break}case 11:h.length===0&&o(`'$end', ${pd}`),a++,u=h.pop();break;case 0:return h.length>0&&o(`'STRUCT_STOP', ${pd}`),t.setRootDoc(u),u;default:o(h.length>0?`'STRUCT_STOP', ${pd}`:`'$end', ${pd}`)}}}var Yk=40,Hk=16,Kk=44,po=16,op=10,zk=16,xA=10,ap=26,AA=8,Vk=320,cp=10,SA=8,wA=' fill="var(--_s)" stroke="var(--_b)"',md=' fill="none" stroke="var(--_b)"',jk=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g;var Xk=new Map([["rectWithTitle",1],["stateStart",2],["stateEnd",3],["choice",4],["fork",5],["join",6],["note",7],["divider",10]]),qk=["pele-node pele-state","pele-node pele-state","pele-node pele-state-start","pele-node pele-state-end","pele-node pele-state-choice","pele-node pele-state-fork","pele-node pele-state-join","pele-note","pele-cluster pele-state-composite"];function _A(e){return e==="TB"||e==="BT"}function lp(e,t,n){let r=e.state?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function RA(e){let t=0,n=e.length;for(;t<n&&e.charCodeAt(t)===34;)t++;for(;n>t&&e.charCodeAt(n-1)===34;)n--;return e.slice(t,n)}function TA(e,t,n){return e<t?t:e>n?n:e}function gd(e,t,n,r,i){return`<rect x="${f(e)}" y="${f(t)}" width="${f(n)}" height="${f(r)}"${i}/>`}function bd(e,t,n,r){let i=Ft(0,0);return i.isGroup=!0,i.dir=e,i.padX=t,i.padTop=n,i.padBottom=r,i}function CA(e,t,n){return vn(e.direction)?vt(n,r=>MA(e,t,n,r)):MA(e,t,n,!1)}function MA(e,t,n,r){let i=e.graph,s=t.flowchart?.curve,a=n.fontSize??16,o=Math.round(a*.875),c=n.measurer??at(n.fontFamily,n.fontFamilyMono),l=lp(t,"wrappingWidth",200),u=n.padding??8,h=n.icons,d=r?"TB":cn(e.direction),m=Ue(void 0,!1,c,a,0),p=(V,X,le,de=0)=>Ue(V,!0,c,X,le,de),y=new Map,E=[],b=[],S=(V,X,le)=>(E.push({node:V,kind:X,style:void 0,label:m,lines:[],w:0,h:0,titleH:0}),le&&b.push(le),E.length-1);for(let V of i.nodes){if(V.shape==="noteGroup")continue;let X=V.isGroup?V.shape==="divider"?9:8:Xk.get(V.shape)??0;y.set(V.id,S(V,X,void 0))}let x=E.length,I=[];for(let V=0;V<x;V++){let X=E[V].node.parentId,le=X===void 0?void 0:y.get(X);I.push(le!==void 0&&le!==V&&E[le].node.isGroup?le:-1)}{let V=[];for(let Ee=0;Ee<x;Ee++)V.push([]);let X=[],le=new Uint8Array(x);for(let Ee=0;Ee<x;Ee++)I[Ee]===-1?(le[Ee]=1,X.push(Ee)):V[I[Ee]].push(Ee);let de=0,Ae=()=>{for(;de<X.length;de++)for(let Ee of V[X[de]])le[Ee]||(le[Ee]=1,X.push(Ee))};Ae();let we=new Int32Array(x).fill(-1);for(let Ee=0;Ee<x;Ee++){if(le[Ee])continue;let Te=Ee;for(;we[Te]!==Ee;)we[Te]=Ee,Te=I[Te];I[Te]=-1,le[Te]=1,X.push(Te),Ae()}}let L=new Int32Array(x).fill(-1);for(let V=0;V<x;V++){let X=E[V].node.noteFor,le=X===void 0?void 0:y.get(X);le!==void 0&&(L[V]=le,I[V]=I[le])}let O=V=>cn(E[V].node.dir),v=V=>_A(I[V]===-1?d:O(I[V])),G=new Int32Array(x),K=new Uint8Array(x),C=new Array(x).fill(1/0),Z=0,oe=new Int32Array(2*x);for(let V of i.edges){let X=y.get(V.start),le=y.get(V.end);if(!(X===void 0||le===void 0)){if(V.pattern==="dashed"){K[E[X].kind===7?le:X]=1;continue}G[X]=Math.max(G[X],++oe[2*X]),G[le]=Math.max(G[le],++oe[2*le+1]),C[X]===1/0&&(C[X]=Z++),C[le]===1/0&&(C[le]=Z++)}}for(let V=0;V<x;V++){let X=E[V],le=X.node,de=Mt(le.cssStyles.length>0?le.cssCompiledStyles.concat(le.cssStyles):le.cssCompiledStyles),Ae=(de.bold?1:0)|(de.italic?2:0),we=de.fontSize??a;X.style=de;let Ee;switch(X.kind){case 8:X.label=p(le.label,we,4e3,Ae),X.titleH=X.label.height>0?X.label.height+12:0,Ee=bd(O(V),po,X.titleH+po,po),Ee.minW=X.label.width+2*po;break;case 9:Ee=bd(O(V),op,op,op);break;case 2:X.w=X.h=14;break;case 3:X.w=X.h=18;break;case 4:X.w=X.h=30;break;case 5:case 6:{let Te=TA(40*G[V]+16,72,320);X.w=v(V)?Te:SA,X.h=v(V)?SA:Te;break}case 10:break;case 7:X.label=p(le.label,o,Math.max(l,Vk)),X.w=X.label.width+24,X.h=X.label.height+16;break;default:{X.label=p(le.label,we,l,Ae);let Te=X.label.width,Me=X.label.height+2*xA;if(X.kind===1){Me+=14;for(let Ie of le.description){let ge=p(Ie===""?" ":Ie,o,l,Ae);X.lines.push(ge),ge.width>Te&&(Te=ge.width),Me+=ge.height}}X.w=Math.max(Te+2*zk,56),X.h=Me}}Ee??=Ft(X.w,X.h),(X.kind===0||X.kind===1)&&(Ee.span=(v(V)?X.w:X.h)-24),b.push(Ee)}let H=[],z=[],M=[],T=new Int32Array(x),R=new Float64Array(x),_=new Float64Array(x),$=new Map,g=(V,X)=>{if(!b[V].isGroup)return!1;for(let le=I[X];le!==-1;le=I[le])if(le===V)return!0;return!1},N=(V,X)=>($.set(H.length,V),C.push(X?-1:1/0),S(void 0,10,Ft(0,0,V)));for(let V of i.edges){let X=y.get(V.start),le=y.get(V.end);if(X===void 0||le===void 0)continue;let de=p(V.label,o,l),Ae=de.width>0?de.width+12:0;X===le?(T[X]++,R[X]=Math.max(R[X],Ae),_[X]+=de.height):g(X,le)?X=N(X,!0):g(le,X)&&(le=N(le,!1)),M.push(V),z.push(de),H.push({src:X,dst:le,minlen:1,labelW:Ae,labelH:de.height>0?de.height+4:0,route:[],labelX:0,labelY:0})}for(let V=0;V<x;V++){if(L[V]!==-1)continue;let X=b[V],le=0;if(T[V]>0){let Ae=ap+(T[V]-1)*8;le=v(V)?Ae+R[V]:Ae*.75+4+_[V],X.isGroup||(v(V)?(X.w+=2*le,X.h=Math.max(X.h,_[V])):(X.h+=2*le,X.w=Math.max(X.w,R[V])),le=0)}if(!K[V]&&le===0){X.parent=I[V];continue}let de=v(V)?bd("LR",le,0,0):bd("TB",0,le,le);de.parent=I[V],C.push(C[V]),b[V].parent=S(void 0,10,de)}for(let V=0;V<x;V++)L[V]!==-1&&(b[V].parent=b[L[V]].parent);{let V=[];for(let Ee=0;Ee<b.length;Ee++)V.push([]);let X=[];for(let Ee=0;Ee<b.length;Ee++){let Te=b[Ee].parent;Te>=0?V[Te].push(Ee):X.push(Ee)}let le=Ee=>E[Ee].kind===2?0:1,de=(Ee,Te)=>le(Ee)-le(Te)||(C[Ee]===C[Te]?0:C[Ee]<C[Te]?-1:1)||Ee-Te,Ae=0,we=X.sort(de).reverse();for(;we.length>0;){let Ee=we.pop();b[Ee].seq=Ae++;let Te=V[Ee].sort(de);for(let Me=Te.length-1;Me>=0;Me--)we.push(Te[Me])}}let w=Ln(b,H,d,{nodeSep:lp(t,"nodeSpacing",Yk),edgeSep:Hk,rankSep:lp(t,"rankSpacing",Kk),portSep:20,tracks:s==="step"||s==="stepBefore"||s==="stepAfter",straight:s==="linear",headRoom:_t("arrow_point")}),A=Math.ceil(w.width+2*u),D=Math.ceil(w.height+2*u),U=[],B=new Map;for(let V of H){let X=V.route;for(let le=3;le<X.length-3;le+=3){let de=Math.round(X[le+1]),Ae=B.get(de);Ae?Ae.push(X[le]):B.set(de,[X[le]])}}let F=[];for(let V=0;V<b.length;V++)F.push([]);let W=[];for(let V=0;V<b.length;V++){let X=b[V].parent;X>=0?F[X].push(V):W.push(V)}let j=W.slice();for(let V=0;V<W.length;V++)for(let X of F[W[V]])W.push(X);let Q="",Y=[],ne="",q="",k="",J=(V,X,le,de,Ae)=>{let we=V.filter(Me=>E[Me].kind===9);if(we.length<2)return;let Ee=(Me,Ie)=>Ie?b[Me].x-b[Me].w/2:b[Me].y-b[Me].h/2,Te=(Me,Ie)=>Ie?b[Me].x+b[Me].w/2:b[Me].y+b[Me].h/2;for(let Me of[!0,!1]){let Ie=we.slice().sort((xe,ie)=>Ee(xe,Me)-Ee(ie,Me)||xe-ie),ge=!0;for(let xe=1;xe<Ie.length;xe++)Te(Ie[xe-1],Me)>Ee(Ie[xe],Me)+.5&&(ge=!1);if(ge){for(let xe=1;xe<Ie.length;xe++){let ie=f((Te(Ie[xe-1],Me)+Ee(Ie[xe],Me))/2+u);ne+=`<path class="pele-divider" d="M${Me?`${ie},${f(le)}V${f(Ae)}`:`${f(X)},${ie}H${f(de)}`}"/>`}return}}for(let Me of we){let Ie=b[Me];ne+=gd(Ie.x-Ie.w/2+u,Ie.y-Ie.h/2+u,Ie.w,Ie.h,` class="pele-divider" rx="${cp}"`)}};J(j,u/2,u/2,A-u/2,D-u/2);for(let V of W){let X=E[V],le=X.node,de=X.style;if(le===void 0||de===void 0||X.kind>=9)continue;let Ae=b[V],we=Ae.x+u,Ee=Ae.y+u,Te=X.w,Me=X.h,Ie=Dt(de),ge=` class="pele-label"${Ie}${de.text}`,xe;switch(X.kind){case 8:{let Re=we-Ae.w/2,be=Ee-Ae.h/2;Tn(de.shape)&&Y.push({box:[Re,be,Re+Ae.w,be+Ae.h],shape:de.shape}),xe=gd(Re,be,Ae.w,Ae.h,` rx="${cp}" fill="var(--_a)"${Dn(de.shape)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${de.shape}`),X.titleH>0&&(xe+=`<path d="M${f(Re)},${f(be+X.titleH)}H${f(Re+Ae.w)}"${md}${de.line}/>`+Ce(X.label,Qk(Ae,X.label.width,B)+u,be+X.titleH/2,` class="pele-cluster-label"${Ie}${de.text}`,h)),J(F[V],Re,be+X.titleH,Re+Ae.w,be+Ae.h);break}case 2:xe=`<circle r="7" fill="var(--_l)"${de.shape}/>`;break;case 3:xe=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${de.line}/><circle r="5" fill="var(--_l)"${de.shape}/>`;break;case 4:xe=`<polygon points="0,${f(-Me/2)} ${f(Te/2)},0 0,${f(Me/2)} ${f(-Te/2)},0"${wA}${de.shape}/>`;break;case 5:case 6:xe=gd(-Te/2,-Me/2,Te,Me,` rx="2" fill="var(--_l)"${de.shape}`);break;case 7:{let Re=f(Te/2),be=f(Me/2),Se=f(Te/2-AA),Ne=f(AA-Me/2);xe=`<path d="M-${Re},-${be}H${Se}L${Re},${Ne}V${be}H-${Re}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${Se},-${be}V${Ne}H${Re}"${md}/>`+Ce(X.label,0,0,` class="pele-label" font-size="${o}" fill="var(--_m)"`,h);break}default:{if(xe=gd(-Te/2,-Me/2,Te,Me,` rx="${f(Math.min(cp,Me/2))}"${wA}${de.shape}`),X.kind===0){xe+=Ce(X.label,0,0,ge,h);break}let Re=xA-Me/2+X.label.height;xe+=`<path d="M${f(-Te/2)},${f(Re+6)}H${f(Te/2)}"${md}${de.line}/>`+Ce(X.label,0,Re-X.label.height/2,ge,h),Re+=14;for(let be of X.lines)xe+=Ce(be,0,Re+be.height/2,` class="pele-state-description" font-size="${o}"${Ie}${de.text}`,h),Re+=be.height}}let ie=e.links.get(le.id);if(ie){let Re=gt(RA(ie.tooltip));Re&&(xe=`<title>${nt(Re)}</title>`+xe),xe=Qn(xe,qn(RA(ie.url)),le.id,U,n,' target="_blank"')}let pe=`<g class="${qk[X.kind]}${Nt(le.cssClasses.replace(jk,""))}" data-id="${We(le.id)}"`;X.kind===8?Q+=`${pe}>${xe}</g>`:X.kind===7?k+=`${pe} transform="translate(${f(we)},${f(Ee)})">${xe}</g>`:q+=`${pe} transform="translate(${f(we)},${f(Ee)})">${xe}</g>`}let te=(V,X,le)=>{let de=b[le];if(de.isGroup)return;let Ae=E[le],we=Ae.kind===5||Ae.kind===6,Ee=X===0?3:X-3;for(let Te of[1,0]){let Me=Te?de.h:de.w,Ie=Te?Ae.h:Ae.w,ge=Te?Ae.w:Ae.h,xe=(Te?de.y:de.x)+u,ie=(Te?de.x:de.y)+u,pe=V[X+Te]-xe;if(!(Math.abs(Math.abs(pe)-Me/2)>=.5)){V[X+Te]-=Math.sign(pe)*(Me-Ie)/2,we&&ge>Ie&&(V[X+1-Te]=TA(V[Ee+1-Te],ie-ge/2+6,ie+ge/2-6));return}}},se=Ac();for(let V=0;V<H.length;V++){let X=H[V];X.src===X.dst||X.route.length<6||M[V].pattern==="dashed"||se.add(X.dst,Zn(X.route,X.route.length-3,b[X.dst]),"arrow_point")}let re="",P="",ee="",ae=new Int32Array(x),ue=new Float64Array(x);for(let V=0;V<H.length;V++){let X=H[V],le=M[V],de=z[V],Ae=le.pattern==="dashed",we=Ae?"none":"arrow_point",Ee;if(X.src===X.dst){let Ie=b[X.src],ge=E[X.src],xe=ae[X.src]++,ie=v(X.src),pe=Ie.isGroup?Ie.w:ge.w,Re=Ie.isGroup?Ie.h:ge.h,be=(ie?pe:Re)/2,Se=Math.max(Math.min((ie?Re:pe)/2-4,8+xe*6),2),Ne=ap+xe*8,De=_t(we)/(Math.hypot(Ne,Se)||1),ve=(Pe,ze)=>Ie.x+u+(ie?be+Pe:-ze),fe=(Pe,ze)=>Ie.y+u+(ie?ze:be+Pe),_e=(Pe,ze)=>`${f(ve(Pe,ze))},${f(fe(Pe,ze))}`;Ee={d:`M${_e(0,-Se)}C${_e(Ne,-2*Se)} ${_e(Ne,2*Se)} ${_e(Ne*De,Se+Se*De)}`,sx:0,sy:0,sdx:0,sdy:0,ex:ve(0,Se),ey:fe(0,Se),edx:ve(-Ne,-Se)-ve(0,0),edy:fe(-Ne,-Se)-fe(0,0)};let Fe=Math.hypot(Ee.edx,Ee.edy)||1;Ee.edx/=Fe,Ee.edy/=Fe;let me=ap+(T[X.src]-1)*8,$e=ue[X.src]+de.height/2;ue[X.src]+=de.height,X.labelX=ie?Ie.x+be+me+4+X.labelW/2:Ie.x,X.labelY=ie?Ie.y-_[X.src]/2+$e:Ie.y+be+me*.75+4+$e}else{let Ie=X.route.slice(),ge=se.of(X.src,Zn(Ie,0,b[X.src])),xe=se.of(X.dst,Zn(Ie,Ie.length-3,b[X.dst]));for(let pe=0;pe<Ie.length;pe+=3)Ie[pe]+=u,Ie[pe+1]+=u;te(Ie,0,X.src),te(Ie,Ie.length-3,X.dst);let ie=$.get(V);if(ie!==void 0&&Ie.length>=6){let pe=b[ie],Re=E[X.src].kind===10,be=Re?0:Ie.length-3,Se=(pe.dir==="TB"||pe.dir==="LR")===Re,Ne=_A(pe.dir)?[Ie[be],pe.y+u+(Se?E[ie].titleH-pe.h/2:pe.h/2),0]:[pe.x+u+(Se?-pe.w/2:pe.w/2),Ie[be+1],1];Ie=Re?Ne.concat(Ie):Ie.concat(Ne)}Ee=Mn(Ie,typeof s=="string"?s:void 0,0,_t(we),ge,xe)}let Te=Tr(Ee.d,[Ee.ex,Ee.ey],Y,"",Ee.tokens);Te===""&&(re+=Mr(Ee,"none",we));let Me=Ae?`pele-note-edge" stroke="${Te||"var(--_b)"}" stroke-dasharray="3 4`:Te?`pele-transition" stroke="${Te}`:"pele-transition";if(P+=`<g class="pele-edge ${Me}" data-id="${We(le.id)}"><path d="${Ee.d}"/>`+wt(we,Ee.ex,Ee.ey,Ee.edx,Ee.edy,Te||"var(--_l)")+"</g>",de.width>0){let Ie=X.labelX+u,ge=X.labelY+u;ee+=ln(le.id,de,Ie,ge,"",h)}}let ce=Dc(e.title,c,a,u,A,D,(Q?`<g class="pele-clusters">${Q}</g>`:"")+(ne?`<g class="pele-dividers" stroke-dasharray="4 4"${md}>${ne}</g>`:"")+On(re)+(P?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${P}</g>`:"")+(ee?`<g class="pele-edge-labels" font-size="${o}">${ee}</g>`:"")+`<g class="pele-nodes">${q}${k}</g>`);return{svg:ot("state",ce.width,ce.height,a,n,e,ce.content),width:ce.width,height:ce.height,links:U}}function Qk(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(r===void 0||t===0)return e.x;let i=e.x-e.w/2,s=t/2,a=e.x,o=-1;for(let c of[e.x,i+po+s,i+e.w-po-s]){let l=1/0;for(let u of r)u>i&&u<i+e.w&&(l=Math.min(l,Math.abs(u-c)-s));if(l>=6)return c;l>o+.5&&(o=l,a=c)}return a}var NA={type:"state",math:!0,parse(e,t,n){let r=new hd;return n&&(r.title=n),EA(e,r),r},render:CA};var Zk=34,Jk=24,e$=8,t$=2e4,IA=1e4,dp=2e6,kA=4,n$=3,$A=8,up=20,LA=20,OA=14,r$=3;function vA(e,t,n,r,i=Jk){let s=e.length;if(s===0)return{width:0,height:0};let a=n==="LR"||n==="RL",o=n==="BT"||n==="RL",c=[];for(let H=s-1;H>=0;H--)e[H].parent<0&&e[H].isGroup&&c.push(H);let l=Math.max(1,c.length),u=new Int32Array(s).fill(-1);c.forEach((H,z)=>u[H]=z);let h=new Uint8Array(s);for(let H=0;H<s;H++)e[H].parent>=0&&(h[e[H].parent]=1);let d=new Float64Array(l).fill(i),m=i,p=H=>{let z=H,M=i;for(let R=0;e[z].parent>=0&&R<IA;R++)z=e[z].parent,u[z]<0&&(M+=Math.max(e[z].padX,e[z].padTop,e[z].padBottom));let T=Math.max(0,u[z]);return M>d[T]&&(d[T]=M),M>m&&(m=M),T},y=new Int32Array(s).fill(-1),E=[];for(let H=0;H<s;H++)u[H]>=0||(!e[H].isGroup||!h[H])&&(y[H]=E.length,E.push(H));let b=H=>a?H.w:H.h,S=H=>a?H.h:H.w,x=E.map(H=>Gs(S(e[H]),b(e[H]))),I=[],L=[],O=1;{let H=new Set;for(let z=0;z<t.length;z++){let M=t[z],T=y[M.src],R=y[M.dst];if(T<0||R<0||T===R)continue;let _=Math.min(T,R)*E.length+Math.max(T,R);(M.labelW>0||H.has(_))&&(O=2),H.add(_),I.push(Ys(T,R,M.minlen,a?M.labelH:M.labelW,a?M.labelW:M.labelH)),L.push(z)}}Oo(x,I),Do(x,I,O);let v=I.length,G=Int32Array.from(E,p),K=(H,z)=>{let M=d.map((fe,_e)=>z[_e]?Math.max(fe,LA):fe),T=new Uint8Array(l),R=0,_=new Int32Array(v);for(let fe=0;fe<v;fe++)_[fe]=Math.abs(x[I[fe].head].rank-x[I[fe].tail].rank),H[fe]||(R+=_[fe]-1);let $=R>t$,g=E.length+($?0:R),N=new Int32Array(g),w=new Int32Array(g),A=new Float64Array(g),D=new Float64Array(g),U=new Uint8Array(g),B=0;for(let fe=0;fe<E.length;fe++)N[fe]=x[fe].rank,w[fe]=G[fe],A[fe]=x[fe].w,D[fe]=x[fe].h,N[fe]>B&&(B=N[fe]);let F=new Int32Array(v).fill(-1),W=new Int32Array(v).fill(-1),j=[];{let fe=E.length;for(let _e=0;_e<v;_e++){let Fe=I[_e],me=Fe.reversed?Fe.head:Fe.tail,$e=Fe.reversed?Fe.tail:Fe.head;if($||_[_e]<2||H[_e]){j.push(me,$e);continue}let Pe=N[me],ze=N[$e],Le=-1;Fe.labelW>0&&(Le=Pe+(ze-Pe>>1),O===2&&(Le&1)===0&&Le--),F[_e]=fe;let Ve=me;for(let Ze=Pe+1;Ze<ze;Ze++){let ke=fe++;N[ke]=Ze,w[ke]=w[me]+Math.round((w[$e]-w[me])*(Ze-Pe)/(ze-Pe)),U[ke]=1,Ze===Le&&(A[ke]=Fe.labelW,D[ke]=Fe.labelH,W[_e]=ke),j.push(Ve,ke),Ve=ke}j.push(Ve,$e)}}let Q=new Int32Array(g+1),Y=new Int32Array(g+1);for(let fe=0;fe<j.length;fe+=2)Y[j[fe]+1]++,Q[j[fe+1]+1]++;for(let fe=0;fe<g;fe++)Q[fe+1]+=Q[fe],Y[fe+1]+=Y[fe];let ne=new Int32Array(j.length/2),q=new Int32Array(j.length/2);{let fe=Q.slice(0,g),_e=Y.slice(0,g);for(let Fe=0;Fe<j.length;Fe+=2)q[_e[j[Fe]]++]=j[Fe+1],ne[fe[j[Fe+1]]++]=j[Fe]}let k=[];for(let fe=0;fe<=B;fe++)k.push([]);for(let fe=0;fe<g;fe++)k[N[fe]].push(fe);let J=new Float64Array(g),te=new Float64Array(g),se=fe=>{fe.sort((_e,Fe)=>w[_e]-w[Fe]||te[_e]-te[Fe]||_e-Fe);for(let _e=0;_e<fe.length;_e++)J[fe[_e]]=_e};for(let fe of k){for(let _e=0;_e<fe.length;_e++)te[fe[_e]]=_e;se(fe)}for(let fe=0;fe<e$&&B>0;fe++){let _e=(fe&1)===0;for(let Fe=1;Fe<=B;Fe++){let me=k[_e?Fe:B-Fe],$e=_e?Q:Y,Pe=_e?ne:q;for(let ze of me){let Le=0,Ve=$e[ze+1]-$e[ze];for(let Ze=$e[ze];Ze<$e[ze+1];Ze++)Le+=J[Pe[Ze]];te[ze]=Ve>0?Le/Ve:J[ze]}se(me)}}let re=(fe,_e)=>U[fe]||U[_e]?r.edgeSep:r.nodeSep,P=(fe,_e)=>{let Fe=0;for(;Fe<fe.length;){let me=Fe;for(;me+1<fe.length&&w[fe[me+1]]===w[fe[Fe]];)me++;_e(fe,Fe,me),Fe=me+1}},ee=(fe,_e,Fe)=>{let me=A[fe[_e]];for(let $e=_e;$e<Fe;$e++)me+=re(fe[$e],fe[$e+1])+A[fe[$e+1]];return me},ae=new Float64Array(l),ue=c.length>0?Zk:0;for(let fe=0;fe<c.length;fe++){let _e=e[c[fe]];ae[fe]=Math.max(0,_e.minW-2*M[fe]),_e.padTop>ue&&(ue=_e.padTop)}for(let fe of k)P(fe,(_e,Fe,me)=>{let $e=ee(fe,Fe,me);$e>ae[w[fe[Fe]]]&&(ae[w[fe[Fe]]]=$e)});let ce=new Float64Array(l+1);for(let fe=0;fe<l;fe++)ce[fe+1]=ce[fe]+ae[fe]+2*M[fe];let he=new Float64Array(g),V=new Float64Array(g),X=(fe,_e,Fe)=>{let me=w[fe[_e]],$e=(ce[me]+M[me]+(ce[me+1]-M[me])-ee(fe,_e,Fe))/2;for(let Pe=_e;Pe<=Fe;Pe++)he[fe[Pe]]=$e+A[fe[Pe]]/2,Pe<Fe&&($e+=A[fe[Pe]]+re(fe[Pe],fe[Pe+1]))},le=(fe,_e,Fe)=>{let me=w[fe[_e]],$e=ce[me]+M[me];for(let ze=_e;ze<=Fe;ze++){let Le=fe[ze];he[Le]=Math.max(V[Le],$e+A[Le]/2),ze<Fe&&($e=he[Le]+A[Le]/2+re(Le,fe[ze+1]))}let Pe=ce[me+1]-M[me];for(let ze=Fe;ze>=_e;ze--){let Le=fe[ze];he[Le]=Math.min(he[Le],Pe-A[Le]/2),ze>_e&&(Pe=he[Le]-A[Le]/2-re(fe[ze-1],Le))}};for(let fe of k)P(fe,X);for(let fe=0;fe<4&&B>0;fe++){let _e=(fe&1)===0;for(let Fe=1;Fe<=B;Fe++){let me=k[_e?Fe:B-Fe],$e=_e?Q:Y,Pe=_e?ne:q;for(let ze of me){let Le=0,Ve=0;for(let Ze=$e[ze];Ze<$e[ze+1];Ze++)w[Pe[Ze]]===w[ze]&&(Le+=he[Pe[Ze]],Ve++);V[ze]=Ve>0?Le/Ve:he[ze]}P(me,le)}}let de=new Float64Array(B+1),Ae=new Float64Array(B+1),we=new Float64Array(B+1).fill(r.rankSep/O);if(H.some(fe=>fe===1)){let fe=r.rankSep/O;we.fill(fe/r$);for(let _e=0;_e<v;_e++){let Fe=I[_e],me=Fe.reversed?Fe.head:Fe.tail,$e=Fe.reversed?Fe.tail:Fe.head;if(H[_e]){if(Fe.labelH<=0||_[_e]>O)continue;let ze=Math.min(fe,(Fe.labelH+2*up-Math.min(D[me],D[$e])/2)/_[_e]);for(let Le=N[me];Le<N[$e];Le++)ze>we[Le]&&(we[Le]=ze);continue}let Pe=F[_e];if(Pe<0||_[_e]<=O*Fe.minlen){for(let ze=N[me];ze<N[$e];ze++)we[ze]=fe;continue}for(let ze=Pe-1;ze<Pe+_[_e]-1;ze++){let Le=ze<Pe?me:ze,Ve=ze+1<Pe+_[_e]-1?ze+1:$e;(w[Le]!==w[Ve]||Math.abs(he[Le]-he[Ve])>=.5)&&(we[N[Le]]=fe)}}}let Ee=ue+m;for(let fe=0;fe<=B;fe++){let _e=0;for(let Fe of k[fe])D[Fe]>_e&&(_e=D[Fe]);de[fe]=Ee,Ae[fe]=Ee+_e,Ee+=_e+(fe===B?0:we[fe])}let Te=Ee+m,Me=ce[l],Ie=fe=>o?ue+Te-fe:fe,ge=(fe,_e)=>a?Ie(_e):fe,xe=(fe,_e)=>a?fe:Ie(_e),ie=a?1:0;for(let fe=0;fe<E.length;fe++){let _e=e[E[fe]],Fe=(de[N[fe]]+Ae[N[fe]])/2;_e.x=ge(he[fe],Fe),_e.y=xe(he[fe],Fe)}for(let fe=0;fe<c.length;fe++){let _e=e[c[fe]],Fe=(ce[fe]+ce[fe+1])/2,me=ce[fe+1]-ce[fe];_e.x=a?Te/2:Fe,_e.y=a?Fe:Te/2,_e.w=a?Te:me,_e.h=a?me:Te,_e.padTop=ue}let pe=new Int32Array(s),Re=[];for(let fe=0;fe<s;fe++){if(!e[fe].isGroup||u[fe]>=0||y[fe]>=0)continue;let _e=0;for(let Fe=e[fe].parent;Fe>=0&&_e<IA;Fe=e[Fe].parent)_e++;pe[fe]=_e,Re.push(fe)}Re.sort((fe,_e)=>pe[_e]-pe[fe]||fe-_e);let be=new Float64Array(s*4);for(let fe=0;fe<s;fe++)be[fe*4]=1/0,be[fe*4+1]=1/0,be[fe*4+2]=-1/0,be[fe*4+3]=-1/0;let Se=(fe,_e)=>{_e.x-_e.w/2<be[fe*4]&&(be[fe*4]=_e.x-_e.w/2),_e.y-_e.h/2<be[fe*4+1]&&(be[fe*4+1]=_e.y-_e.h/2),_e.x+_e.w/2>be[fe*4+2]&&(be[fe*4+2]=_e.x+_e.w/2),_e.y+_e.h/2>be[fe*4+3]&&(be[fe*4+3]=_e.y+_e.h/2)};for(let fe of E)e[fe].parent>=0&&u[e[fe].parent]<0&&Se(e[fe].parent,e[fe]);for(let fe of Re){let _e=e[fe];if(be[fe*4]===1/0)continue;let Fe=Math.max(be[fe*4+2]-be[fe*4]+2*_e.padX,_e.minW);_e.x=(be[fe*4]+be[fe*4+2])/2,_e.w=Fe,_e.y=(be[fe*4+1]-_e.padTop+be[fe*4+3]+_e.padBottom)/2,_e.h=be[fe*4+3]-be[fe*4+1]+_e.padTop+_e.padBottom,_e.parent>=0&&u[_e.parent]<0&&Se(_e.parent,_e)}for(let fe of t)fe.route=[];for(let fe=0;fe<v;fe++){let _e=I[fe],Fe=t[L[fe]],me=_e.reversed?_e.head:_e.tail,$e=_e.reversed?_e.tail:_e.head,Pe=[he[me],Ae[N[me]]-(Ae[N[me]]-de[N[me]]-D[me])/2],ze=F[fe];if(ze>=0)for(let Ze=ze;Ze<ze+_[fe]-1;Ze++)Pe.push(he[Ze],de[N[Ze]]),Ae[N[Ze]]>de[N[Ze]]&&Pe.push(he[Ze],Ae[N[Ze]]);Pe.push(he[$e],de[N[$e]]+(Ae[N[$e]]-de[N[$e]]-D[$e])/2);let Le=[];for(let Ze=0;Ze<Pe.length;Ze+=2)Le.push(ge(Pe[Ze],Pe[Ze+1]),xe(Pe[Ze],Pe[Ze+1]),ie);if(_e.reversed)for(let Ze=0,ke=Le.length-3;Ze<ke;Ze+=3,ke-=3)for(let Qe=0;Qe<2;Qe++){let et=Le[Ze+Qe];Le[Ze+Qe]=Le[ke+Qe],Le[ke+Qe]=et}Fe.route=Le;let Ve=W[fe];if(Ve>=0){let Ze=(de[N[Ve]]+Ae[N[Ve]])/2;Fe.labelX=ge(he[Ve],Ze),Fe.labelY=xe(he[Ve],Ze)}else Fe.labelX=(Le[0]+Le[Le.length-3])/2,Fe.labelY=(Le[1]+Le[Le.length-2])/2}for(let fe of t){if(fe.route.length>0||fe.src===fe.dst)continue;let _e=e[fe.src],Fe=e[fe.dst],[me,$e]=DA(_e,Fe),[Pe,ze]=DA(Fe,_e),Le=Math.abs(Pe-me)>Math.abs(ze-$e)?1:0;fe.route=[me,$e,Le,Pe,ze,Le],fe.labelX=(me+Pe)/2,fe.labelY=($e+ze)/2}let Ne=new Uint8Array(v),De=t.reduce((fe,_e)=>fe+_e.route.length/3,0),ve=v*(E.length+t.length+De);if(ve<=dp){let fe=Le=>(de[N[Le]]+Ae[N[Le]])/2,_e=t.map(Le=>[a?Le.labelY:Le.labelX,Ie(a?Le.labelX:Le.labelY)]),Fe=(Le,Ve,Ze,ke,Qe,et,pt,lt)=>Ze>Qe-pt/2&&Le<Qe+pt/2&&ke>et-lt/2&&Ve<et+lt/2,me=(Le,Ve,Ze,ke,Qe,et,pt)=>{for(let lt=0;lt<E.length;lt++)if(lt!==Qe&&lt!==et&&Fe(Le,Ve,Ze,ke,he[lt],fe(lt),A[lt]+8,D[lt]+8))return!1;for(let lt=0;lt<t.length;lt++){let ye=t[lt];if(lt!==pt&&ye.labelW>0&&ye.src!==ye.dst&&Fe(Le,Ve,Ze,ke,_e[lt][0],_e[lt][1],a?ye.labelH:ye.labelW,a?ye.labelW:ye.labelH))return!1}return!0},$e=(Le,Ve,Ze,ke,Qe)=>{let et=0;for(let pt=0;pt<t.length;pt++){if(pt===Qe)continue;let lt=t[pt].route;for(let ye=3;ye<lt.length;ye+=3)if(Math.max(lt[ye-3],lt[ye])>Le&&Math.min(lt[ye-3],lt[ye])<Ze&&Math.max(lt[ye-2],lt[ye+1])>Ve&&Math.min(lt[ye-2],lt[ye+1])<ke){et++;break}}return et},Pe=(Le,Ve,Ze)=>{let ke=0;for(let Qe=0;Qe<t.length;Qe++){let et=t[Qe].route;if(Qe===Ze||et.length===0)continue;let pt=et.length-3;(Math.abs(et[0]-Le)<1&&Math.abs(et[1]-Ve)<1||Math.abs(et[pt]-Le)<1&&Math.abs(et[pt+1]-Ve)<1)&&ke++}return ke},ze=(Le,Ve,Ze,ke,Qe)=>{let et=Math.abs(Ze-Le)<.5,pt=et?Math.min(Ve,ke):Math.min(Le,Ze),lt=et?Math.max(Ve,ke):Math.max(Le,Ze),ye=et?Le:Ve;for(let Be=0;Be<t.length;Be++){let Oe=t[Be];if(Be===Qe||Oe.src===t[Qe].src||Oe.dst===t[Qe].dst)continue;let je=Oe.route;for(let Ke=3;Ke<je.length;Ke+=3){let Je=je[Ke-3+(et?0:1)],Ge=je[Ke+(et?0:1)];if(Math.abs(Je-ye)>=kA||Math.abs(Ge-ye)>=kA)continue;let Ye=je[Ke-3+(et?1:0)],tt=je[Ke+(et?1:0)];if(Math.min(lt,Math.max(Ye,tt))-Math.max(pt,Math.min(Ye,tt))>1)return!0}}return!1};for(let Le=0;Le<v;Le++){let Ve=I[Le],Ze=L[Le],ke=t[Ze],Qe=Ve.tail,et=Ve.head;if(w[Qe]===w[et]||Math.abs(he[et]-he[Qe])<1)continue;let pt=he[Qe],lt=he[et],ye=fe(Qe),Be=fe(et),Oe=Math.sign(lt-pt),je=Math.sign(Be-ye),Ke=(Ge,Ye)=>{for(let rt=2;rt<Ge.length;rt+=2)if(!me(Math.min(Ge[rt-2],Ge[rt])-Ye,Math.min(Ge[rt-1],Ge[rt+1])-Ye,Math.max(Ge[rt-2],Ge[rt])+Ye,Math.max(Ge[rt-1],Ge[rt+1])+Ye,Qe,et,Ze)||ze(ge(Ge[rt-2],Ge[rt-1]),xe(Ge[rt-2],Ge[rt-1]),ge(Ge[rt],Ge[rt+1]),xe(Ge[rt],Ge[rt+1]),Ze))return!1;let tt=0,st=0,St=-1;if(ke.labelW>0){let rt=Ve.labelW,ht=Ve.labelH;for(let mt=2;mt<Ge.length;mt+=2){let bt=(Ge[mt-2]+Ge[mt])/2,Ct=(Ge[mt-1]+Ge[mt+1])/2,Pt=Math.abs(Ge[mt]-Ge[mt-2]),Vn=Math.abs(Ge[mt+1]-Ge[mt-1]),yn=Pt+Vn;if(yn<=St||(Pt>0?Pt<rt+8:Vn<ht+8)||bt-rt/2<0||bt+rt/2>Me||Ct-ht/2<0||Ct+ht/2>Te||!me(bt-rt/2,Ct-ht/2,bt+rt/2,Ct+ht/2,-1,-1,Ze))continue;let Ar=ge(bt,Ct),on=xe(bt,Ct);$e(Ar-ke.labelW/2,on-ke.labelH/2,Ar+ke.labelW/2,on+ke.labelH/2,Ze)>0||(tt=bt,st=Ct,St=yn)}if(St<0)return!1}let dt=[Ge[0],Ge[1]];for(let rt=2;rt<Ge.length;rt+=2){let ht=Ge[rt]-Ge[rt-2],mt=Ge[rt+1]-Ge[rt-1],bt=Math.abs(ht)+Math.abs(mt),Ct=rt>2?up:0,Pt=rt+2<Ge.length?up:0;bt>Ct+Pt+1&&(Ct&&dt.push(Ge[rt-2]+ht/bt*Ct,Ge[rt-1]+mt/bt*Ct),Pt&&dt.push(Ge[rt]-ht/bt*Pt,Ge[rt+1]-mt/bt*Pt)),dt.push(Ge[rt],Ge[rt+1])}ke.route=[];for(let rt=0;rt<dt.length;rt+=2){let ht=rt===0?dt[0]!==dt[2]:dt[rt]!==dt[rt-2];ke.route.push(ge(dt[rt],dt[rt+1]),xe(dt[rt],dt[rt+1]),ht?1-ie:ie)}return ke.labelW>0&&(ke.labelX=ge(tt,st),ke.labelY=xe(tt,st),_e[Ze]=[tt,st]),Ne[Le]=1,!0};if(Ke([pt+Oe*A[Qe]/2,ye,lt,ye,lt,Be-je*D[et]/2],2)||Ke([pt,ye+je*D[Qe]/2,pt,Be,lt-Oe*A[et]/2,Be],2)||ve>dp/$A)continue;let Je=[];for(let Ge of w[Qe]<w[et]?[w[et],w[Qe]]:[w[Qe],w[et]]){let Ye=Math.max(M[Ge]-OA,Math.min(M[Ge]/2,LA-OA));for(let tt of[ce[Ge]+Ye,ce[Ge+1]-Ye]){if(Math.abs(tt-pt)<A[Qe]/2+4||Math.abs(tt-lt)<A[et]/2+4)continue;let st=[pt+Math.sign(tt-pt)*A[Qe]/2,ye,tt,ye,tt,Be,lt+Math.sign(tt-lt)*A[et]/2,Be],St=(Pe(ge(st[0],st[1]),xe(st[0],st[1]),Ze)+Pe(ge(st[6],st[7]),xe(st[6],st[7]),Ze))*1e6;for(let dt=2;dt<st.length;dt+=2){let rt=ge(st[dt-2],st[dt-1]),ht=xe(st[dt-2],st[dt-1]),mt=ge(st[dt],st[dt+1]),bt=xe(st[dt],st[dt+1]);St+=$e(Math.min(rt,mt),Math.min(ht,bt),Math.max(rt,mt),Math.max(ht,bt),Ze)*1e6+Math.abs(mt-rt)+Math.abs(bt-ht)}Je.push({pts:st,cost:St,lane:Ge})}}Je.sort((Ge,Ye)=>Ge.cost-Ye.cost);for(let Ge of Je)if(Ke(Ge.pts,1)){T[Ge.lane]=1;break}}}return{width:a?Te:Me,height:a?Me:Te,routed:Ne,margins:T,work:ve}},C=new Uint8Array(v),Z=new Uint8Array(l),oe=K(C,Z);for(let H=0;H<n$&&oe.work<=dp/$A;H++){let z=H===0?oe.routed:C.map((M,T)=>M&oe.routed[T]);if(z.every((M,T)=>M===C[T])&&oe.margins.every((M,T)=>M===Z[T]))break;C=z,Z=oe.margins,oe=K(C,Z)}return C.some((H,z)=>H&&!oe.routed[z])&&(oe=K(new Uint8Array(v),new Uint8Array(l))),{width:oe.width,height:oe.height}}function DA(e,t){let n=t.x-e.x,r=t.y-e.y,i=Math.max(e.w/2,.5),s=Math.max(e.h/2,.5);if(Math.abs(n)<i&&Math.abs(r)<s){let o=i-Math.abs(n),c=s-Math.abs(r);return o<c?[e.x+(n<0?-i:i),t.y]:[t.x,e.y+(r<0?-s:s)]}let a=Math.min(n!==0?i/Math.abs(n):1/0,r!==0?s/Math.abs(r):1/0);return[e.x+n*a,e.y+r*a]}var PA="__swimlane_default__";function s$(e){let t=!1;for(let n of e.nodes)n.isGroup?n.dir=void 0:n.parentId===void 0&&(t=!0);if(t){for(let n of e.nodes)!n.isGroup&&n.parentId===void 0&&(n.parentId=PA);e.nodes.push({id:PA,label:void 0,labelType:"text",shape:"rect",isGroup:!0,parentId:void 0,cssStyles:[],cssCompiledStyles:[],cssClasses:"",dir:void 0})}}function i$(e,t,n,r,i,s,a){let o=e.x-e.w/2,c=e.y-e.h/2,l=s==="LR"||s==="RL",u=l?o+e.padTop/2:e.x,h=l?e.y:c+e.padTop/2,d=Ce(t,u,h,` class="pele-cluster-label"${Dt(n,"var(--_m)")}${n.text}`,a);return`<g class="pele-cluster pele-lane${r}" data-id="${i}"><rect x="${f(o)}" y="${f(c)}" width="${f(e.w)}" height="${f(e.h)}" fill="none" stroke="var(--_b)"/><rect x="${f(o)}" y="${f(c)}" width="${f(l?e.padTop:e.w)}" height="${f(l?e.h:e.padTop)}" fill="var(--_a)" stroke="var(--_b)"${n.shape}/>`+(l&&d?`<g transform="rotate(-90 ${f(u)} ${f(h)})">${d}</g>`:d)+"</g>"}function o$(e,t){let n=e.x-e.w/2,r=e.y-e.h/2;return t==="LR"||t==="RL"?[n,r,n+e.padTop,r+e.h]:[n,r,n+e.w,r+e.padTop]}var a$={type:"swimlane",prepare:s$,layout:(e,t,n,r,i)=>vA(e,t,n,r,i?12:void 0),drawGroup:i$,filledBox:o$},FA={type:"swimlane",math:!0,parse:ml.parse,render:(e,t,n)=>pl(e,t,n,a$)};var yd=class{type="timeline";title;accTitle;accDescr;direction="LR";sections=[];periods=[];currentSection="";getCommonDb(){return this}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
131
+ `)}setDirection(t){this.direction=t}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,n,r){this.periods.push({text:t,events:r?[r]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(t){let n=this.periods[this.periods.length-1];if(!n)throw new qe("An event needs a time period before it.","semantic",{type:"timeline"});n.events.push(t)}};var BA=["$end","EOF","INVALID","NEWLINE","timeline","timeline_lr","timeline_td","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","period","event"];function WA(e){let t=e.length,n=[],r=[],i=[],s={types:n,texts:r,starts:i},a=0,o=(c,l)=>{n.push(c),r.push(e.slice(a,l)),i.push(a),a=l};for(;a=Ol(e,a),!(a>=t);){let c=e.charCodeAt(a),l=a+1;if(c===10){for(;e.charCodeAt(l)===10;)l++;o(3,l);continue}if(tr(e,a,"timeline")){for(l=a+8;e.charCodeAt(l)===32||e.charCodeAt(l)===9;)l++;let u=tr(e,l,"lr");if(l>a+8&&(u||tr(e,l,"td"))&&!it(e.charCodeAt(l+2))){o(u?5:6,l+2);continue}if(!it(e.charCodeAt(a+8))){o(4,a+8);continue}}if(tr(e,a,"title")){for(l=a+5;e.charCodeAt(l)!==10&&Xe(e.charCodeAt(l));)l++;if(l===t||e.charCodeAt(l)===10){a=l;continue}let u=e.charCodeAt(a+5);if(u!==13&&Xe(u)){o(7,Sa(e,a+6));continue}}if(l=Dl(e,a,s,8),l!==a){a=l;continue}if(tr(e,a,"section")&&Xe(e.charCodeAt(a+7))){for(l=a+8;l<t&&e.charCodeAt(l)!==58&&e.charCodeAt(l)!==10;)l++;if(l>a+8){o(13,l);continue}}if(c!==58){l=a+1;for(let u=e.charCodeAt(l);l<t&&u!==35&&u!==58&&u!==10;u=e.charCodeAt(++l));o(14,l);continue}if(Xe(e.charCodeAt(a+1))){for(l=a+2;l<t;l++){let u=e.charCodeAt(l);if(u===10||u===58&&Xe(e.charCodeAt(l+1)))break}if(l>a+2){o(15,l);continue}}o(2,a+1)}return(i.length===0||i[i.length-1]<t)&&o(1,t),o(0,t),s}var c$="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'";function UA(e,t){let{types:n,texts:r,starts:i}=WA(e),s=(o,c)=>{let l=n[o]===0?"1":BA[n[o]];throw ut("timeline",e,i[o],`Expecting ${c}, got '${l}'`)},a=n[0];a!==4&&a!==5&&a!==6&&s(0,"'timeline', 'timeline_lr', 'timeline_td'"),a!==4&&t.setDirection(a===5?"LR":"TD");for(let o=1;;o++){let c=r[o];switch(n[o]){case 3:break;case 7:t.getCommonDb().setDiagramTitle(c.substring(6));break;case 8:t.getCommonDb().setAccTitle(r[++o].trim());break;case 10:t.getCommonDb().setAccDescription(r[++o].trim());break;case 12:t.getCommonDb().setAccDescription(c.trim());break;case 13:t.addSection(c.substring(8));break;case 14:t.addTask(c,0,"");break;case 15:t.addEvent(c.substring(2));break;case 1:return;default:s(o,c$)}}}var Ed=12,GA=8,l$=152,d$=216,u$=264,gi=20,mo=20,xd=14,Oa=8,fp=8,Ad=12,f$=' fill="var(--_bg)"',YA=' fill="none" stroke="var(--_b)"';function hp(e,t,n,r,i){return`<rect x="${f(e)}" y="${f(t)}" width="${f(n)}" height="${f(r)}"${xt(i)}/>`}function KA(e,t,n){return e.direction==="TD"?HA(e,t,n,!0):vt(n,r=>HA(e,t,n,r))}function HA(e,t,n,r){let i=n.fontSize??16,s=Math.round(i*.875),a=n.measurer??at(n.fontFamily,n.fontFamilyMono),o=n.padding??8,c=t.timeline?.disableMulticolor!==!0,l=e.periods,u=e.sections.length>0,h=e.sections.map((se,re)=>({section:re,periods:[]})),d={section:-1,periods:[]};l.forEach((se,re)=>(h[se.sectionIndex]??d).periods.push(re)),d.periods.length>0&&h.unshift(d);let m=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*o:1/0,p=mo+xd*2+4*Ed,y=Math.min(l$,Math.max(80,Math.round((m-p)*.38))),E=Math.min(u$,Math.max(110,m-p-y)),b=y,S=()=>r?E:b,x=l.map(se=>gr(se.text,a,i,b)),I=l.map(se=>se.events.map(re=>gr(re,a,s,S()))),L=0;for(let se of x)L=Math.max(L,se.width);if(!r)for(let se of I)for(let re of se)L=Math.max(L,re.width);let O=L>b;if(r)for(let se of I)for(let re of se)O||=re.width>E;O&&(b=Math.min(Math.max(Math.ceil(L),y),m===1/0?d$:y),x=l.map(se=>Bn(se.text,a,i,b)),I=l.map(se=>se.events.map(re=>Bn(re,a,s,S()))));let v=Math.round(i*1.5),G=b+2*Ed,K=S()+2*Ed,C=se=>Math.max(se.height,v)+2*GA,Z=se=>Math.max(se.height,Math.round(s*1.5))+2*GA,oe=(se,re)=>se.section>=0?se.section:u?void 0:c?re:0,H=(se,re)=>{let P=oe(se,re);return P===void 0?"var(--_m)":yt(P)},z=se=>(se===void 0?"":us(se))||f$,M=!1;for(let se of I)se.length>0&&(M=!0);let T=0;for(let se of h)T+=Math.max(se.periods.length,1);let R=G+gi,_=l.length>0,$=r?G+(M?mo+xd*2+K:_?mo+Ad:0):T>0?T*R-gi+(_?Ad+$t:0):0,g=Bn(e.title,a,i,Math.max($,320),1),N=g.height>0?g.height+16:0,w=Math.max($,g.width),A=o+(w-$)/2,D=o+N,U=(se,re)=>Bn(e.sections[se.section],a,i,re-2*Ed,1),B=(se,re,P,ee,ae,ue)=>hp(P,ee,ae,ue,` fill="${yt(se.section)}"`)+Ce(re,P+ae/2,ee+ue/2,' font-weight="var(--_hw)"'+z(se.section)),F=(se,re,P,ee,ae,ue)=>hp(ee,ae,G,ue,` fill="${P}"`)+Ce(x[se],ee+G/2,ae+ue/2,z(oe(re,se))),W=(se,re,P,ee,ae)=>'<g class="pele-node pele-event">'+hp(P,ee,K,ae,` fill="${re}" fill-opacity="0.16"`)+Ce(se,P+K/2,ee+ae/2,` font-size="${s}"`)+"</g>",j=(se,re,P)=>`<circle class="pele-dot" cx="${f(se)}" cy="${f(re)}" r="4" fill="${P}" stroke="var(--_bg)" stroke-width="2"/>`,Q=se=>se.section>=0?`<g class="pele-cluster pele-section" data-id="${We(e.sections[se.section].trim())}">`:"",Y=se=>`<g class="pele-node pele-period" data-id="${We(l[se].text.trim())}">`,ne="",q;if(r){let se=A+G+mo,re=se+xd,P=re+xd,ee=D;for(let ae of h){if(ne+=Q(ae),ae.section>=0){let ue=U(ae,$),ce=C(ue);ne+=B(ae,ue,A,ee,$,ce),ee+=ce+fp+4}for(let ue of ae.periods){let ce=H(ae,ue),he=C(x[ue]),V=I[ue].length>0?Z(I[ue][0]):he,X=ee+Math.max(he,V)/2,le=`M${f(A+G)},${f(X)}H${f(se)}`,de="",Ae=X-V/2,we=X;for(let Ee of I[ue]){let Te=Z(Ee);we=Ae+Te/2,le+=`M${f(re)},${f(we)}H${f(P)}`,de+=W(Ee,ce,P,Ae,Te),Ae+=Te+Oa}de&&(le+=`M${f(se)},${f(X)}H${f(re)}V${f(we)}`),ne+=Y(ue)+F(ue,ae,ce,A,X-he/2,he)+`<path class="pele-edge" d="${le}"${YA}/>`+j(se,X,ce)+de+"</g>",ee=Math.max(X+he/2,Ae-Oa)+gi}ae.periods.length===0&&(ee+=gi-fp-4),ae.section>=0&&(ne+="</g>")}if(h.length>0&&(ee-=gi),_){let ae=ee+Ad+$t;ne=`<path class="pele-axis" d="M${f(se)},${f(D)}V${f(ae-$t+1)}" fill="none" stroke="var(--_l)"/>`+wt("arrow_point",se,ae,0,1,"var(--_l)")+ne,ee=ae}q=ee+o}else{let se=0,re=h.map(V=>{if(V.section<0)return;let X=U(V,Math.max(V.periods.length,1)*R-gi);return se=Math.max(se,C(X)),X}),P=0;for(let V of x)P=Math.max(P,C(V));let ee=D+(u?se+fp:0),ae=ee+P+(P>0?mo:0),ue=ae+mo,ce=_?ae+Ad:D+se,he=0;if(h.forEach((V,X)=>{let le=Math.max(V.periods.length,1),de=A+he*R;ne+=Q(V);let Ae=re[X];Ae&&(ne+=B(V,Ae,de,D,le*R-gi,se)),V.periods.forEach((we,Ee)=>{let Te=H(V,we),Me=de+Ee*R,Ie=Me+G/2,ge=`M${f(Ie)},${f(ee+P)}V${f(I[we].length>0?ue:ae)}`,xe="",ie=ue;for(let pe of I[we]){let Re=Z(pe);ie>ue&&(ge+=`M${f(Ie)},${f(ie-Oa)}V${f(ie)}`),xe+=W(pe,Te,Me,ie,Re),ie+=Re+Oa}ce=Math.max(ce,ie-Oa),ne+=Y(we)+F(we,V,Te,Me,ee,P)+`<path class="pele-edge" d="${ge}"${YA}/>`+j(Ie,ae,Te)+xe+"</g>"}),V.section>=0&&(ne+="</g>"),he+=le}),_){let V=A+$;ne=`<path class="pele-axis" d="M${f(A)},${f(ae)}H${f(V-$t+1)}" fill="none" stroke="var(--_l)"/>`+wt("arrow_point",V,ae,1,0,"var(--_l)")+ne}q=ce+o}let k=Math.ceil(w+2*o),J=Math.ceil(Math.max(q,o*2)),te=Ce(g,k/2,o+g.height/2,' class="pele-title" font-weight="var(--_tw)"')+ne;return{svg:ot("timeline",k,J,i,n,e,te),width:k,height:J,links:[]}}var zA={type:"timeline",parse(e,t,n){let r=new yd;return r.title=n,UA(e,r),r},render:KA};var pp=/[─━│┃└┗├┣]/,XA=/[└┗├┣]/,h$=/[─━]/,VA=/^[\s│┃]+$/,p$=/^[\s─━│┃└┗├┣]+$/,m$=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,g$=/^\s*%%/,b$=" ";function y$(e){return e.some(t=>pp.test(t))}function E$(e){for(let t of e){let n=XA.exec(t);if(n?.index&&n.index>0)return n.index}return 4}function qA(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(n,r)=>{let i=t.get(parseInt(r,10));return i?`line ${i}`:n})}function mp(e,t){let n=0;for(let r=1;r<t;r++)n=e.indexOf(`
132
+ `,n)+1;return n}function jA(e,t,n){let{line:r}=ar(e,mp(e,t+1));throw new qe(`Line ${r}: ${n}`,"syntax",{type:"treeView",line:r})}function x$(e,t){let n=0;for(let r=0;n<e.length&&r<t;n++)r+=e[n]===" "?4:1;return n}function QA(e){let t=new Map,n=new Map;if(!pp.test(e))return{text:e,lineMap:t,columns:n};let r=e.split(`
133
+ `),i=-1;for(let u=0;u<r.length;u++)if(r[u].trim()==="treeView-beta"){i=u;break}if(i===-1)return{text:e,lineMap:t,columns:n};let s=u=>u.trim()===""||g$.test(u)||m$.test(u),a=[];for(let u=i+1;u<r.length;u++){let h=r[u];s(h)||VA.test(h)||a.push(h.replace(/\t/g," "))}if(!y$(a))return{text:e,lineMap:t,columns:n};let o=E$(a),c=[],l=(u,h,d)=>{c.push(u),t.set(c.length,h+1),d&&n.set(c.length,d)};for(let u=0;u<=i;u++)l(r[u],u);for(let u=i+1;u<r.length;u++){let h=r[u];if(s(h)){l(h,u);continue}if(VA.test(h))continue;let d=h.replace(/\t/g," "),m=XA.exec(d);if(m){let p=Math.round(m.index/o)+1,y=m.index+1;for(;y<d.length&&h$.test(d[y]);)y++;for(;y<d.length&&d[y]===" ";)y++;let E=d.slice(y).trimEnd();E||jA(e,u,"Empty node — expected a filename or directory name after the box-drawing prefix");let b=b$.repeat(p);l(b+E,u,S=>x$(h,y+Math.max(S-b.length,0)))}else{if(p$.test(d))continue;pp.test(d)?l(h,u):/^\s+/.test(d)?jA(e,u,"Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes."):l(h,u)}}return{text:c.join(`
134
+ `),lineMap:t,columns:n}}function A$(e,t){if(e.startsWith("##",t)||e.startsWith("icon(",t))return!0;if(!e.startsWith(":::",t))return!1;let n=t+3;for(;jn(e.charCodeAt(n));)n++;let r=e.charCodeAt(n);return r>=65&&r<=90||r>=97&&r<=122||r===95}function S$(e,t){let n=e.charCodeAt(t);if(jn(n)||n===10||n===13||n===34||n===39||e.startsWith(":::",t)||e.startsWith("icon(",t)||e.startsWith("##",t))return-1;let r=e.length,i=t+1;for(;i<r;){let s=e.charCodeAt(i);if(s===10||s===13)break;if(jn(s)){let a=i+1;for(;jn(e.charCodeAt(a));)a++;if(A$(e,a))break;i=a}else i++}return i}var ZA={name:"BARE_NAME",pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:S$},JA=[{...Zt("treeView-beta"),longer:[ZA]},Qi(),jt,Jn(String.raw`(?!%%)[^\n\r]`),{name:"CLASS_ANNOTATION",pattern:/[ \t]+:::[ \t]*[A-Za-z_][\w-]*/y},{name:"ICON_ANNOTATION",pattern:/[ \t]+icon\([\w-]*(?::[\w-]+)?\)/y},{name:"DESC_ANNOTATION",pattern:/[ \t]+##[^\n\r]*/y},{name:"INDENTATION",pattern:/[ \t]{1,}/y},{name:"QUOTED_NAME",pattern:/"[^"]*"|'[^']*'/y},{name:"WS",pattern:/[ \t]+/y,hidden:!0},{name:"ML_COMMENT",pattern:/\%\%[^\n]*/y,hidden:!0},{name:"NL",pattern:/\r?\n/y,hidden:!0},ZA];function eS(e){let t=e.length;for(;t>0&&jn(e.charCodeAt(t-1));)t--;return t===e.length?e:e.slice(0,t)}function gp(e,t){switch(e){case"INDENTATION":return t?.length||0;case"QUOTED_NAME":return t.substring(1,t.length-1);case"BARE_NAME":return eS(t);case"CLASS_ANNOTATION":return t.trim().substring(3).trim();case"ICON_ANNOTATION":{let n=t.trim();return n.substring(5,n.length-1)}case"DESC_ANNOTATION":return t.trim().substring(2).trim();default:return}}function tS(e){let t=new Wt(Gt(e,JA,"treeView"),JA,"treeView"),n={$type:"TreeView",nodes:[]};for(t.expect(0);;)if(t.kind===1)n.accDescr=zt(t.take());else if(t.kind===2)n.accTitle=Kt(t.take());else if(t.kind===3)n.title=Ht(t.take());else break;for(;t.kind!==-1;){let r={$type:"TreeNode",name:""};if(t.kind===7&&(r.indent=t.take().length),t.kind===8){let i=t.take();r.name=i.substring(1,i.length-1)}else t.kind===12?r.name=eS(t.take()):t.fail("a name");for(;;)if(t.kind===4)r.classAnnotation=gp("CLASS_ANNOTATION",t.take());else if(t.kind===5)r.iconAnnotation=gp("ICON_ANNOTATION",t.take());else if(t.kind===6)r.descAnnotation=gp("DESC_ANNOTATION",t.take());else break;n.nodes.push(r)}return n}var bp=class{count=1;root={id:0,level:-1,name:"/",nodeType:"directory",children:[]};stack=[this.root];addNode(t,n,r,i,s,a){let o=this.stack;for(;t<=o[o.length-1].level;)o.pop();let c={id:this.count++,level:t,name:n,nodeType:r,icon:s,cssClass:i,description:a,children:[]};o[o.length-1].children.push(c),o.push(c)}};function w$(e,t){for(let n of e.nodes){let r=typeof n.indent=="number"?n.indent:0,i=n.name,s=i.endsWith("/");s&&(i=i.slice(0,-1));let a=n.iconAnnotation;t.addNode(r,i,s?"directory":"file",n.classAnnotation||void 0,a!==void 0?a||"none":void 0,n.descAnnotation||void 0)}}function nS(e){let{text:t,lineMap:n,columns:r}=QA(e);try{return tS(t)}catch(i){if(!(i instanceof qe)||t===e)throw i;let s=n.get(i.line);if(s===void 0)throw i;let a=i.column>0?r.get(i.line)?.(i.column-1)??i.column-1:0,o=ar(e,mp(e,s)+a),c=i.message.includes(`
135
+ `)?i.message.indexOf(`
136
+ `):i.message.length,l=i.message.slice(c),u=qA(i.message.slice(0,c),new Map([[i.line,o.line]]))+(i.snippet?l.replace(i.snippet,()=>o.snippet):l);throw new qe(u,i.code,{type:i.type,line:o.line,column:i.column>0?o.column:0,snippet:i.snippet?o.snippet:""})}}function rS(e,t){let n=new bp;return w$(e,n),{type:"treeView",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
137
+ `):void 0,root:n.root,count:n.count}}var Da="mermaid-treeview",Sd=new Map([["folder","M3 6.5A1.5 1.5 0 0 1 4.5 5h4.6l2.4 2.5h8A1.5 1.5 0 0 1 21 9v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18z"],["file","M6.5 3h7L19 8.5v11a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 5 19.5v-15A1.5 1.5 0 0 1 6.5 3zM13.5 3v5.5H19"]]);function yp(e,t){if(e===void 0||!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t];return typeof n=="string"?n:void 0}function _$(e,t){let n=yp(t?.filenameIcons,e);if(n)return n;let r=e.lastIndexOf(".");if(r>0){let i=e.substring(r).toLowerCase();return yp(t?.extensionIcons,i)??yp(t?.extensionIcons,i.slice(1))}}function sS(e,t){return e.includes(":")?e:Sd.has(e)||!t?`${Da}:${e}`:`${t}:${e}`}function Ep(e,t){if(e.icon!=="none"){if(e.icon)return sS(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType==="file"){let n=_$(e.name,t);if(n==="none")return;if(n)return sS(n,t.defaultIconPack)}return`${Da}:${e.nodeType==="directory"?"folder":"file"}`}}}function iS(e){let t=r=>typeof r=="object"&&r!==null&&!Array.isArray(r)?r:void 0,n=t(e.treeView)??{};return{showIcons:!!n.showIcons,defaultIconPack:typeof n.defaultIconPack=="string"?n.defaultIconPack:"",filenameIcons:t(n.filenameIcons),extensionIcons:t(n.extensionIcons)}}var R$=6,T$=16,M$=7,C$=4,wd=4;function _d(e,t,n,r,i){let s=e.treeView?.[t];return typeof s=="number"&&s>=r&&s<=i?s:n}function N$(e){return{paddingX:_d(e,"paddingX",5,0,100),paddingY:_d(e,"paddingY",2,0,100),rowIndent:_d(e,"rowIndent",15,0,400),lineThickness:_d(e,"lineThickness",1,.25,12)}}function oS(e,t,n){return xn(n,r=>I$(e,t,n,r))}function I$(e,t,n,r){let i=n.fontSize??16,s=n.measurer??at(n.fontFamily,n.fontFamilyMono),a=n.padding??8,o=iS(t),c=Array.isArray(n.monospace)&&n.monospace.includes("files"),l=c?` font-family="${ur}"`:"",{paddingX:u,paddingY:h,rowIndent:d,lineThickness:m}=N$(t),p=0,y=e.root.children.map(A=>[A,0]);for(let A=0;r&&A<y.length;A++){let[D,U]=y[A];p=Math.max(p,U);for(let B of D.children)y.push([B,U+1])}let E=r?Math.min(d+u,Math.max(2,((n.maxWidth??320)-120)/Math.max(1,p))):d+u,b=Math.round(i*1.5)+2*h,S=i,x=Ue(e.title,!1,s,i,r?It(n):4e3,1),I=x.height>0?x.height+12:0,L=A=>A.some(D=>Ep(D,o)!==void 0),O=[],v=new Map,G=[],K=(A,D)=>{let U=L(A);for(let B=A.length-1;B>=0;B--)G.push([A[B],D,U])};K(e.root.children,0);let C=0,Z=!1,oe=0;for(;G.length>0;){let[A,D,U]=G.pop(),B=D*E,F=gt(A.name),W=B+(U?S+R$:0),j=Math.max(40,(n.maxWidth??320)-2*a-2*wd-W),Q=(A.nodeType==="directory"?1:0)|(c?4:0),Y=r?qs(F,s,i,j,Q):void 0,ne=r&&A.description?qs(gt(A.description),s,i,j,2):void 0,q=Y?Y.width:s.width(F,i,Q);W+q>C&&(C=W+q);let k=A.cssClass!==void 0&&A.cssClass.split(/\s+/).includes("highlight");k&&(Z=!0);let J=r?Math.max(b,(Y?.height??0)+(ne?.height??0)+2*h):b,te=oe+(r?h+Math.max(S,Y?.height??0)/2:J/2),se={node:A,x:B,cy:te,icon:Ep(A,o),text:F,labelX:W,highlighted:k,label:Y,description:ne,top:oe,height:J};oe+=J,O.push(se),v.set(A,se),K(A.children,D+1)}let H=C+T$,z=C;for(let A of O){let D=A.node.description;if(!D)continue;let U=A.description?A.description.width:s.width(gt(D),i,2);z=Math.max(z,(r?A.labelX:H)+U)}z=Math.max(z,x.width);let M=a+(Z?wd:0),T=a+I,R=Math.ceil(z+2*M),_=Math.ceil(T+oe+a),$="";for(let A of O){let D=A.node.children;if(D.length===0)continue;let U=M+A.x+M$,B=Math.max(U,M+A.x+E-u),F=T+v.get(D[D.length-1]).cy,W=Math.min(C$,B-U),j=`M${f(U)},${f(T+A.top+A.height-2)}V${f(F-W)}`;W>0&&(j+=`Q${f(U)},${f(F)} ${f(U+W)},${f(F)}H${f(B)}`);for(let Q=0;Q<D.length-1&&B>U;Q++)j+=`M${f(U)},${f(T+v.get(D[Q]).cy)}H${f(B)}`;$+=`<path d="${j}"/>`}let g=i*.35,N="";for(let A of O){let D=A.node,U=T+A.cy,B=D.nodeType==="directory",F="";if(A.highlighted){let W=M+A.x-wd;F+=`<rect class="pele-tree-highlight" x="${f(W)}" y="${f(T+A.top+1)}" width="${f(R-M+wd-W)}" height="${f(A.height-2)}" fill="var(--_c)" fill-opacity="0.14"${ft}/>`}if(A.icon!==void 0){let W=A.icon.startsWith(Da+":")?A.icon.slice(Da.length+1):"",j=Sd.get(W)??Sd.get(B?"folder":"file"),Q=n.icons?.(A.icon)??`<path d="${j}" stroke="var(--_m)" stroke-width="1.5"/>`;F+=`<svg class="pele-icon" data-icon="${We(A.icon)}" x="${f(M+A.x)}" y="${f(U-S/2)}" width="${f(S)}" height="${f(S)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${Q}</svg>`}A.label?F+=Qr(A.label,M+A.labelX,T+A.top+h,` class="pele-label"${B?' font-weight="var(--_hw)"':""}${l}`):A.text!==""&&(F+=`<text class="pele-label" x="${f(M+A.labelX)}" y="${f(U+g)}"${B?' font-weight="var(--_hw)"':""}${l} xml:space="preserve">${nt(A.text)}</text>`),A.description?F+=Qr(A.description,M+A.labelX,T+A.top+h+(A.label?.height??0),' class="pele-tree-description" font-style="italic" fill="var(--_m)"'):D.description&&(F+=`<text class="pele-tree-description" x="${f(M+H)}" y="${f(U+g)}" font-style="italic" fill="var(--_m)" xml:space="preserve">${nt(gt(D.description))}</text>`),N+=`<g class="pele-node pele-tree-${B?"dir":"file"}${Nt(D.cssClass??"")}" data-id="${We(D.name)}">${F}</g>`}let w=Ce(x,R/2,a+x.height/2,' class="pele-title" font-weight="var(--_tw)"')+($?`<g class="pele-tree-guides" fill="none" stroke="var(--_b)" stroke-width="${f(m)}">${$}</g>`:"")+N;return{svg:ot("treeView",R,_,i,n,e,w),width:R,height:_,links:[]}}var aS={type:"treeView",parse:(e,t,n)=>rS(nS(e),n),render:oS};function k$(e){let t=[],n=[];for(let r of e){let i=r.type==="Leaf",s={name:r.name,children:i?void 0:[]};for(s.classSelector=r.classSelector,r.cssCompiledStyles&&(s.cssCompiledStyles=r.cssCompiledStyles),i&&r.value!==void 0&&(s.value=r.value);n.length>0&&n[n.length-1].level>=r.level;)n.pop();n.length===0?t.push(s):n[n.length-1].node.children.push(s),i||n.push({node:s,level:r.level})}return t}function cS(e,t){let n=new Map;for(let i of e.TreemapRows){if(i.$type!=="ClassDefStatement")continue;let s=n.get(i.className);s||n.set(i.className,s=[]);let a=(i.styleText??"").replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",");for(let o of a.split(";"))s.push(o)}let r=[];for(let i of e.TreemapRows){if(i.$type!=="TreemapRow")continue;let s=i.item,a=s.classSelector?n.get(s.classSelector):void 0;r.push({level:i.indent??0,name:s.name,type:s.$type,value:s.$type==="Leaf"?s.value:void 0,classSelector:s.classSelector,cssCompiledStyles:a&&a.length>0?a:void 0})}return{type:"treemap",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
138
+ `):void 0,roots:k$(r),classes:n}}var lS=[rn,jt,Jn(String.raw`\w`),{name:"TREEMAP_KEYWORD",pattern:/treemap-beta|treemap/y},{name:"CLASS_DEF",pattern:/classDef\s+([a-zA-Z_][a-zA-Z0-9_]+)(?:\s+([^;\r\n]*))?(?:;)?/y},{name:"STYLE_SEPARATOR",pattern:/:::/y},{name:"SEPARATOR",pattern:/:/y},{name:"COMMA",pattern:/,/y},{name:"INDENTATION",pattern:/[ \t]{1,}/y},{name:"WS",pattern:/[ \t]+/y,hidden:!0},{name:"ML_COMMENT",pattern:/\%\%[^\n]*/y,hidden:!0},{name:"NL",pattern:/\r?\n/y,hidden:!0},{name:"ID2",pattern:/[a-zA-Z_][a-zA-Z0-9_]*/y},{name:"NUMBER2",pattern:/[0-9_\.\,]+/y},{name:"STRING2",pattern:/"[^"]*"|'[^']*'/y}],$$=/classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/;function dS(e){let t=new Wt(Gt(e,lS,"treemap"),lS,"treemap"),n=t.kinds,r={$type:"Treemap",TreemapRows:[]},i=()=>t.accept(5)?t.expect(12):void 0;for(t.expect(3);t.kind!==-1;){let s=t.kind;if(s===0){r.accDescr=zt(t.take());continue}if(s===1){r.accTitle=Kt(t.take());continue}if(s===2){r.title=Ht(t.take());continue}s!==8&&s!==14&&s!==4&&t.fail("a node, a class definition, or a title");let a=s===8?t.take().length:void 0;if(t.kind===4){let d=$$.exec(t.take()),m={$type:"ClassDefStatement",className:d[1]};d[2]&&(m.styleText=d[2]),a!==void 0&&(m.indent=a),r.TreemapRows.push(m);continue}let o=t.expect(14).slice(1,-1),c=n[t.i]===8?t.i+1:t.i,l;n[c]===6||n[c]===7?(t.i=c+1,t.accept(8),l={$type:"Leaf",name:o,value:parseFloat(t.expect(13).replace(/,/g,""))}):l={$type:"Section",name:o};let u=i();u!==void 0&&(l.classSelector=u);let h={$type:"TreemapRow",item:l};a!==void 0&&(h.indent=a),r.TreemapRows.push(h)}return r}var uS=/^(?:.?[<>=^])?([-+( ])?(\$)?0?\d*(,)?(?:\.(\d+))?(~)?([a-zA-Z%])?$/;function fS(e){let t="";for(let n=e.length;n>0;n-=3)t=e.slice(Math.max(0,n-3),n)+(t?","+t:"");return t}function hS(e){let t=uS.exec(e==="$0,0"?"$,":e)??uS.exec(","),n=t[1]==="+",r=t[3]!==void 0,i=t[4]===void 0?void 0:Math.min(Number(t[4]),20),s=t[6]??"";return a=>{let o=Math.abs(a),c,l="";if(s==="f"?c=o.toFixed(i??6):s==="%"?(c=(o*100).toFixed(i??6),l="%"):s==="d"?c=Math.round(o).toFixed(0):s==="e"?c=o.toExponential(i??6):c=String(Number(o.toPrecision(Math.max(1,i??12)))),t[5]&&c.includes(".")&&!c.includes("e")&&(c=c.replace(/\.?0+$/,"")),r&&!c.includes("e")){let u=c.indexOf(".");c=u===-1?fS(c):fS(c.slice(0,u))+c.slice(u)}return(a<0?"-":n?"+":"")+(t[2]??"")+c+l}}function pS(e,t,n){let r=e.children===void 0&&Number.isFinite(e.value)&&e.value>0?e.value:0;return{node:e,parent:t,series:n,value:r,children:[],headed:!1,header:0,x:0,y:0,w:0,h:0}}var Rd=(e,t,n)=>e>=t?Math.min(e,n):t;function L$(e,t,n,r,i,s,a){let o=t,c=0;for(;c<e.length;){let l=i*s/o,u=Math.min(i,s),h=e[c].value*l,d=h,m=Math.max(u*u*d/(h*h),h*h/(u*u*d)),p=c+1;for(;p<e.length;){let b=e[p].value*l,S=h+b,x=Math.max(u*u*d/(S*S),S*S/(u*u*b));if(x>m)break;m=x,h=S,p++}let y=h/u,E=0;for(let b=c;b<p;b++){let S=e[b],x=b===p-1?u-E:S.value*l/y,I=i>=s?n:n+E,L=i>=s?r+E:r,O=i>=s?y:x,v=i>=s?x:y,G=Math.round(I+O-a/2)>Math.round(I+a/2)?a/2:0,K=Math.round(L+v-a/2)>Math.round(L+a/2)?a/2:0;S.x=Math.round(I+G),S.y=Math.round(L+K),S.w=Math.round(I+O-G)-S.x,S.h=Math.round(L+v-K)-S.y,E+=x,o-=S.value}i>=s?(n+=y,i-=y):(r+=y,s-=y),c=p}}function mS(e,t,n,r){let i=e.map((d,m)=>pS(d,void 0,m)),s=i.slice();for(let d=0;d<s.length;d++){let m=s[d];for(let p of m.node.children??[]){let y=pS(p,m,m.series);m.children.push(y),s.push(y)}}for(let d=s.length-1;d>=0;d--){let m=s[d];m.parent&&(m.parent.value+=m.value)}let{gap:a,header:o,short:c,side:l}=r,u=[],h=(d,m,p,y,E)=>{let b=d.filter(x=>x.value>0).sort((x,I)=>I.value-x.value),S=0;for(let x of b)S+=x.value;if(!(b.length===0||!Number.isFinite(S))){y=Math.max(0,y),E=Math.max(0,E),y>0&&E>0&&L$(b,S,m-a/2,p-a/2,y+a,E+a,a);for(let x of b){let I=Rd(x.x,m,m+y),L=Rd(x.y,p,p+E);x.w=Rd(x.x+x.w,I,m+y)-I,x.h=Rd(x.y+x.h,L,p+E)-L,x.x=I,x.y=L,u.push(x)}}};h(i,0,0,t,n);for(let d=0;d<u.length;d++){let m=u[d];if(m.children.length===0)continue;let p=m.h-o-l>=12?o:c;m.headed=m.w>Math.max(24,2*l)&&m.h-p-l>=8,m.header=m.headed?p:0,m.headed?h(m.children,m.x+l,m.y+p,m.w-2*l,m.h-p-l):h(m.children,m.x,m.y,m.w,m.h)}return u}var xp=28,O$=18,Ap=6,bi=1.25,gS=e=>nt(gt(e).trim()).trim();function D$(e){let t=0,n=e.slice();for(;n.length>0;){let r=n.pop();r.children!==void 0?n.push(...r.children):Number.isFinite(r.value)&&r.value>0&&t++}return t}function bS(e,t){let n=Math.min(t.w,t.h)/4;return n<4?xt(e).replace("rx:var(--_r)",`rx:min(var(--_r),${f(n)}px)`):xt(e)}function Td(e,t,n,r,i){let s=e.treemap?.[t];return typeof s=="number"&&s>=r?Math.min(s,i):n}function yS(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),s=Math.round(r*.75),a=Math.round(r*.5625),o=n.measurer??at(n.fontFamily,n.fontFamilyMono),c=t.treemap??{},l=n.padding??Td(t,"diagramPadding",8,0,2e3),u=Math.round(ms(n,Td(t,"nodeWidth",64,1,400)*10,200,2*l)),h=Math.round(Td(t,"nodeHeight",40,1,400)*10),d=c.showValues!==!1,m=hS(typeof c.valueFormat=="string"?c.valueFormat:","),p=Math.min(1,Math.max(0,Math.log10(u*h/Math.max(1,D$(e.roots))/800))),y=mS(e.roots,u,h,{gap:Td(t,"padding",Math.round(2+2*p),0,200),header:xp,short:O$,side:Math.round(3+3*p)}),E=Ue(e.title,!1,o,r,It(n),1),b=E.height>0?E.height+8:0,S=l+Math.max(0,(E.width-u)/2),x=l+b,I="",L="";for(let K of y){let C=K.node,Z=Mt(C.cssCompiledStyles??[]),oe=yt(K.series),H=S+K.x,z=x+K.y,M=gt(C.name).trim(),T=d?m(K.value):"",R=`data-id="${We(C.name)}">`,_=gS(C.name),$=_===""?[]:[_];for(let Y=K.parent;Y!==void 0&&!Y.headed;Y=Y.parent){let ne=gS(Y.node.name);ne!==""&&$.unshift(ne)}let g=$.join(" › "),N=Y=>g===""||Y===M&&g===_?"":`<title>${g}</title>`,w=`<rect x="${f(H)}" y="${f(z)}" width="${f(K.w)}" height="${f(K.h)}" fill="${oe}"`,A=Z.fontSize,D=(Z.bold?1:0)|(Z.italic?2:0),U=Dn(Z.shape)?Dt(Z):us(K.series);if(C.children!==void 0){let Y="",ne;if(K.headed){let J=K.header<xp,te=A??(J?s:i),se=A??s,re=K.w-2*Ap-4,P=T?o.width(T,se,D):0,ee=!J&&P>0&&re-P-12>=3*te,ae=te*bi<K.header?Ta(M,ee?re-P-12:re,te,te,o,D|1):void 0,ue=z+K.header/2+1;ne=ae?.text,ae&&(Y+=`<text x="${f(H+Ap+2)}" y="${f(ue+te*.35)}" font-weight="var(--_hw)"${J?` font-size="${te}"`:""}${U}${Z.text}>${nt(ae.text)}</text>`),ee&&se*bi<=xp&&(Y+=`<text class="pele-value" x="${f(H+K.w-Ap-2)}" y="${f(ue+se*.35)}" font-size="${s}" text-anchor="end"${U||' fill="var(--_m)"'}${Z.text}>${nt(T)}</text>`)}let q=/[";]fill:/.test(Z.shape)?"":' fill-opacity="0.12"',k=K.headed?`${w}${bS(`${q} stroke="${oe}"${Z.shape}`,K)}/>`:`<rect x="${f(H)}" y="${f(z)}" width="${f(K.w)}" height="${f(K.h)}" fill="none"/>`;I+=`<g class="pele-node pele-section${Nt(C.classSelector??"")}" ${R}${N(ne)}${k}${Y}</g>`;continue}let B="",F=K.w-8,W=A??a,j=A===void 0?Math.min(r,Math.floor((K.h-4)/bi)):A*bi<=K.h-4?A:0,Q=j>=W?Ta(M,F,j,W,o,D):void 0;if(Q){let Y=f(H+K.w/2),ne=z+K.h/2,q=A??Math.max(a,Math.round(Q.size*.8)),k=(Q.size+q)*bi;if(T&&k<=K.h-4&&o.width(T,q,D)<=F){let J=ne-k/2+Q.size*bi/2,te=ne+k/2-q*bi/2;B=`<text x="${Y}" y="${f(J+Q.size*.35)}" font-size="${f(Q.size)}"${U}${Z.text}>${nt(Q.text)}</text><text class="pele-value" x="${Y}" y="${f(te+q*.35)}" font-size="${f(q)}"${U}${Z.text}>${nt(T)}</text>`}else B=`<text x="${Y}" y="${f(ne+Q.size*.35)}" font-size="${f(Q.size)}"${U}${Z.text}>${nt(Q.text)}</text>`}L+=`<g class="pele-node pele-leaf${Nt(C.classSelector??"")}" ${R}${N(Q?.text)}${w}${bS(Z.shape,K)}/>${B}</g>`}let O=Math.ceil(Math.max(u,E.width)+2*l),v=Math.ceil(h+b+2*l),G=Ce(E,O/2,l+E.height/2,' class="pele-title" font-weight="var(--_tw)"')+(I?`<g class="pele-sections" font-size="${i}">${I}</g>`:"")+(L?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${L}</g>`:"");return{svg:ot("treemap",O,v,r,n,e,G),width:O,height:v,links:[]}}var ES={type:"treemap",parse:(e,t,n)=>cS(dS(e),n),render:yS};var Sp="EOF USECASE ACTOR SYSTEM_BOUNDARY END DIRECTION TD TB BT LR RL NOTE FOR JSON CLASS_DEF CLASS STYLE INCLUDE EXTEND TRUE FALSE IDENTIFIER NUMBER AT COMMA COLON HASH_COLOR CSS_IDENTIFIER CSS_ESCAPED_COMMA DASH DOT PERCENT CSS_PUNCTUATION LABEL_PUNCTUATION LABEL_SYMBOL PLAIN_STRING MARKDOWN_STRING UNCLOSED_MARKDOWN_STRING COMMENT NEWLINE ACC_DESCR_BLOCK ACC_TITLE_LINE ACC_DESCR_LINE JSON_DECLARATION_START JSON_OBJECT_LITERAL UNCLOSED_JSON_OBJECT_LITERAL GENERALIZATION DEPENDENCY_ARROW STEREOTYPE_START STEREOTYPE_END STEREOTYPE_TEXT UNCLOSED_STEREOTYPE_TEXT CLASS_SEPARATOR FORWARD_SOLID BACKWARD_SOLID FORWARD_CIRCLE BACKWARD_CIRCLE FORWARD_CROSS BACKWARD_CROSS MARKERLESS_SOLID METADATA_START LBRACE RBRACE LBRACKET RBRACKET LPAREN RPAREN".split(" ");var va=1,SS=2,Ds=new Uint8Array(128);for(let e=48;e<=57;e++)Ds[e]=va;for(let e=65;e<=90;e++)Ds[e]=Ds[e+32]=va;Ds[95]=va;for(let e of"!#$&*+/=?^|~")Ds[e.charCodeAt(0)]=SS;var xS=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];function Md(e){return e<128&&(Ds[e]&va)!==0}function wp(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function v$(e,t,n){switch(n){case 97:return e.startsWith("actor",t)?2:0;case 115:return e.startsWith("systemBoundary",t)?3:e.startsWith("style",t)?16:0;case 101:return e.startsWith("end",t)?4:wp(e,t,"extend")?18:0;case 69:return wp(e,t,"extend")?18:0;case 100:return e.startsWith("direction",t)?5:0;case 84:return e.startsWith("TD",t)?6:e.startsWith("TB",t)?7:0;case 66:return e.startsWith("BT",t)?8:0;case 76:return e.startsWith("LR",t)?9:0;case 82:return e.startsWith("RL",t)?10:0;case 110:return e.startsWith("note",t)?11:0;case 102:return e.startsWith("for",t)?12:e.startsWith("false",t)?20:0;case 106:return e.startsWith("json",t)?13:0;case 99:return e.startsWith("classDef",t)?14:e.startsWith("class",t)?15:0;case 105:case 73:return wp(e,t,"include")?17:0;case 116:return e.startsWith("true",t)?19:0;case 117:return e.startsWith("usecase-beta",t)?1:0;default:return 0}}function yi(e,t){[e,t]=cs(e,t);let n=1,r=0;for(let i=0;i<t;i++){let s=e.charCodeAt(i);s!==10&&s!==13||(s===13&&i+1<t&&e.charCodeAt(i+1)===10&&i++,n++,r=i+1)}return[n,t-r+1]}function Cd(e,t,n){let[r,i]=yi(e,t);return`line ${r}, column ${i} [${cs(e,t)[1]},${cs(e,n)[1]})`}function wS(e,t,n){for(let r=t+1;r<e.length;r++){let i=e.charCodeAt(r);if(i===n)return r+1;if(i===10||i===13)return-1}return-1}function P$(e,t){let n=e.charCodeAt(t);return n!==34&&n!==39?!0:n===34&&e.charCodeAt(t+1)===96||wS(e,t,n)!==-1}function AS(e,t,n){let[r,i]=yi(e,t),[s,a]=[cs(e,t)[1],cs(e,t+n)[1]];return new qe(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${s}, skipped ${a-s} characters. at line ${r}, column ${i} [${s},${a})`,"syntax",{type:"usecase",line:r,column:i})}function _S(e){let t=[],n=[],r=[],i=e.length,s=0,a=!0,o=!1;for(;s<i;){let c=e.charCodeAt(s);if(c===32||c===9){s++;continue}let l,u=s+1,h=!1;if(c<128&&(Ds[c]&va)!==0){if(l=0,c===97&&a&&e.startsWith("acc",s)){let d=e.startsWith("Descr",s+3);if(d||e.startsWith("Title",s+3)){let m=s+8;for(;jn(e.charCodeAt(m));)m++;let p=e.charCodeAt(m);if(p===58)for(l=d?42:41,u=m+1;u<i&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;else if(p===123&&d&&!o){let y=e.indexOf("}",m+1);y===-1?o=!0:(l=40,u=y+1)}}}else if(c===106&&e.startsWith("json",s)&&jn(e.charCodeAt(s+4))){let d=s+5;for(;jn(e.charCodeAt(d));)d++;let m=d;for(;Md(e.charCodeAt(d));)d++;if(d>m){for(;jn(e.charCodeAt(d));)d++;if(e.charCodeAt(d)===64){for(d++;jn(e.charCodeAt(d));)d++;if(e.charCodeAt(d)===123){t.push(43),n.push(s),r.push(d),s=d;let p=0,y=!1,E=!1,b=d;for(;b<i;b++){let S=e.charCodeAt(b);if(y)E?E=!1:S===92?E=!0:S===34&&(y=!1);else if(S===34)y=!0;else if(S===123)p++;else if(S===125&&--p===0)break}t.push(b<i?44:45),n.push(d),s=b<i?b+1:i,r.push(s),a=!1;continue}}}}if(l===0){for(;u<i&&Md(e.charCodeAt(u));)u++;let d=v$(e,s,c);if(d!==0)d===1||u-s===xS[d]?(l=d,u=s+xS[d]):l=21;else if((c===111||c===120)&&e.charCodeAt(s+1)===45&&e.charCodeAt(s+2)===45)l=c===111?56:58,u=s+3;else if(Et(c)){let m=s+1;for(;Et(e.charCodeAt(m));)m++;if(e.charCodeAt(m)===46&&Et(e.charCodeAt(m+1))){for(l=22,u=m+2;Et(e.charCodeAt(u));)u++;for(;zr(e.charCodeAt(u));)u++}else l=21}else for(l=21;e.charCodeAt(u)===45&&Md(e.charCodeAt(u+1));)for(l=27,u+=2;Md(e.charCodeAt(u));)u++}}else if(c===10)l=39,h=!0;else if(c===13)l=39,h=!0,e.charCodeAt(u)===10&&u++;else if(c===34||c===39){if(c===34&&e.charCodeAt(s+1)===96){let d=e.indexOf('`"',s+2);l=d===-1?37:36,u=d===-1?i:d+2}else if(l=35,u=wS(e,s,c),u===-1){let d=s+1;for(;d<i&&!P$(e,d);)d++;throw AS(e,s,d-s)}}else if(c===37)if(a&&e.charCodeAt(u)===37)for(l=38;u<i&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;else l=31;else if(c===45)if(e.charCodeAt(u)!==45)l=29;else{for(;e.charCodeAt(u)===45;)u++;let d=e.charCodeAt(u),m=u-s===2;m&&d===124&&e.charCodeAt(u+1)===62?(l=46,u+=2):d===62?(l=53,u++):m&&(d===111||d===120)?(l=d===111?55:57,u++):l=59}else if(c===46){let d=e.charCodeAt(u);if(d===46&&e.charCodeAt(u+1)===62)l=47,u+=2;else if(Et(d)){for(l=22;Et(e.charCodeAt(u));)u++;for(;zr(e.charCodeAt(u));)u++}else l=30}else if(c===60)if(e.charCodeAt(u)===60){if(t.push(48),n.push(s),r.push(s+2),a=!1,s+=2,s>=i)break;if(e.charCodeAt(s)===62&&e.charCodeAt(s+1)===62)l=49,u=s+2;else{let d=s,m=!1;for(;d<i;d++){let p=e.charCodeAt(d);if(p===10||p===13)break;if(p===62&&e.charCodeAt(d+1)===62){m=!0;break}}if(m&&e.slice(s,d).trim()!=="")t.push(50),n.push(s),r.push(d),l=49,s=d,u=d+2;else{for(;d<i&&e.charCodeAt(d)!==10&&e.charCodeAt(d)!==13;)d++;if(d===s){for(;d<i&&(e.charCodeAt(d)===10||e.charCodeAt(d)===13);)d++;throw AS(e,s,d-s)}l=51,u=d}}}else if(e.charCodeAt(u)===45&&e.charCodeAt(u+1)===45)for(l=54,u+=2;e.charCodeAt(u)===45;)u++;else l=33;else if(c===58)e.charCodeAt(u)===58&&e.charCodeAt(u+1)===58?(l=52,u+=2):l=25;else if(c===64)e.charCodeAt(u)===123?(l=60,u++):l=23;else if(c===123)l=61;else if(c===125)l=62;else if(c===91)l=63;else if(c===93)l=64;else if(c===40)l=65;else if(c===41)l=66;else if(c===44)l=24;else if(c===35){for(;qa(e.charCodeAt(u));)u++;l=u>s+1?26:32}else if(c===92)e.charCodeAt(u)===44?(l=28,u++):l=33;else if(c<127&&c>32)l=(Ds[c]&SS)!==0?32:33;else for(l=34;u<i;){let d=e.charCodeAt(u);if(d>=32&&d<127||d===9||d===10||d===13)break;u++}t.push(l),n.push(s),r.push(u),s=u,a=h}for(let c=0;c<3;c++)t.push(0),n.push(i),r.push(i);return{types:t,starts:n,ends:r}}function RS(){return{type:"usecase",actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,direction:"LR",title:void 0,accTitle:"",accDescr:"",accDescription:"",source:"",headerSpan:[0,0],statements:[]}}function TS(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:"",accDescription:""}}function _p(e,t){if(t.length===0)return;let n=new Set(e);for(let r of t)n.has(r)||(n.add(r),e.push(r))}function F$(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let{key:n,value:r}of e)if(n==="icon")t.clear(),t.add("actor");else if(n==="animate"||n==="animation")t.clear(),t.add("edge");else if(n==="type")t.clear(),r==="rect"||r==="package"?t.add("boundary"):(r==="normal"||r==="hollow"||r==="awesome")&&t.add("actor");else if(n==="business")t.delete("boundary"),t.delete("edge");else return;return t.size===1?[...t][0]:void 0}function MS(e,t,n,r,i){let s=RS(),{actors:a,useCases:o,systemBoundaries:c}=s,l=new Map,u=new Map,h=new Map,d=new Map,m=new Map,p=g=>Cd(e,g[0],g[1]),y=(g,N)=>{let[w,A]=yi(e,N[0]);return new qe(g,"semantic",{type:"usecase",line:w,column:A})},E=(g,N)=>{throw y(`${g} at ${p(N)}`,N)},b=(g,N,w,A,D)=>{let U=B=>B===void 0?"":` (label "${B}")`;throw y(`${g} at ${p(N)}${U(A)}; previous declaration at ${p(w)}${U(D)}`,N)},S=(g,N,w)=>E(`Metadata property '${w.key}' is invalid for ${N} '${g}'`,w.keySpan),x=(g,N)=>{let w=m.get(g);(w===void 0||N<w)&&m.set(g,N)},I=g=>[...g].sort((N,w)=>(m.get(N.id)??0)-(m.get(w.id)??0)),L=(g,N)=>{l.set(g.id,{kind:N,span:g.span,generated:g.generated,label:g.label.text})},O=(g,N)=>{let w=l.get(g.id);if(!w)return;let A=g.generated?g.label.text:void 0,D=w.generated?w.label:void 0;w.kind!==N&&b(`ID '${g.id}' is declared as both ${w.kind} and ${N}`,g.span,w.span,A,D),(w.generated||g.generated)&&b(`Generated ID '${g.id}' collides with another declaration`,g.span,w.span,A,D)},v=(g,N,w)=>{let A=l.get(g);A&&b(`ID '${g}' is declared more than once (${A.kind} and ${N})`,w,A.span,void 0,A.generated?A.label:void 0),l.set(g,{kind:N,span:w,generated:!1})},G=(g,N,w)=>{let{key:A,value:D}=N,U=B=>{!w&&B!==void 0&&B!==D&&b(`Actor '${g.id}' has conflicting ${A} metadata`,N.keySpan,g.span)};A==="type"&&(D==="normal"||D==="hollow"||D==="awesome")?(U(g.actorType),g.actorType=D):A==="icon"&&typeof D=="string"?(U(g.icon),g.icon=D):A==="business"&&typeof D=="boolean"?(U(g.business),g.business=D):S(g.id,"actor",N)},K=(g,N,w)=>{for(let A of N??[])g.kind==="actor"?G(g,A,w):A.key==="business"&&typeof A.value=="boolean"?(!w&&g.business!==void 0&&g.business!==A.value&&b(`Use case '${g.id}' has conflicting business metadata`,A.keySpan,g.span),g.business=A.value):S(g.id,"usecase",A)},C=g=>{let N;if(g.kind==="actor"){o.delete(g.id);let w={id:g.id,label:g.label.text,labelType:g.label.type,business:g.business??!1,classes:[...g.classes],type:g.icon?"icon":g.actorType??"normal",styles:a.get(g.id)?.styles??[]};g.icon&&(w.icon=g.icon),a.set(g.id,w),N=w}else a.delete(g.id),N={id:g.id,label:g.label.text,labelType:g.label.type,business:g.business??!1,classes:[...g.classes],shape:g.shape??"ellipse",styles:o.get(g.id)?.styles??[]},o.set(g.id,N);g.stereotype&&(N.stereotype=g.stereotype),g.parent?.id&&(N.parentId=g.parent.id)},Z=g=>{O(g,g.kind);let N=g.parent?.id?g.parent:void 0,w=u.get(g.id);if(!w){let A={kind:g.kind,id:g.id,label:g.label,span:g.span,generated:g.generated,classes:[...g.classes],parent:N,shape:g.shape,stereotype:g.stereotype,stereotypeSpan:g.stereotype?g.span:void 0};K(A,g.metadata,!1),u.set(g.id,A),L(g,g.kind);return}(w.label.text!==g.label.text||w.label.type!==g.label.type)&&b(`ID '${g.id}' has conflicting labels`,g.span,w.span),g.shape&&w.shape&&g.shape!==w.shape&&b(`Use case '${g.id}' has conflicting shapes`,g.span,w.span),N&&w.parent?.id&&N.id!==w.parent.id&&b(`Element '${g.id}' belongs to more than one system boundary`,N.span,w.parent.span),g.stereotype&&w.stereotype&&g.stereotype!==w.stereotype&&b(`Element '${g.id}' has conflicting stereotypes`,g.span,w.stereotypeSpan??w.span),w.shape??=g.shape,w.parent??=g.parent,w.stereotype??=g.stereotype,w.stereotypeSpan??=g.stereotype?g.span:void 0,_p(w.classes,g.classes),K(w,g.metadata,!1)},oe=g=>{O(g,"boundary");let N=h.get(g.id);if(N){(N.label.text!==g.label.text||N.label.type!==g.label.type)&&b(`Boundary '${g.id}' has conflicting titles`,g.span,N.span),_p(N.classes,g.classes);return}h.set(g.id,{...g,classes:[...g.classes],members:[]}),L(g,"boundary")},H=g=>{g.classed&&!g.declares&&E(`Relationship endpoint '${g.id}' uses ::: without declaring the node`,g.span);let N=l.get(g.id);return N?N.kind:(u.set(g.id,{...g,kind:"usecase",shape:"ellipse",classes:[]}),L(g,"usecase"),x(g.id,g.span[0]),"usecase")},z=(g,N)=>{let w=l.get(g)?.kind;return(w==="actor"?a.get(g):w==="usecase"?o.get(g):w==="boundary"?c.get(g):w==="json"?s.jsonNodes.get(g):d.get(g))??E(`Class/style target '${g}' is unresolved or anonymous`,N)},M=[];for(let{source:g,target:N}of t.relationships)x(g.id,g.span[0]),x(N.id,N.span[0]);for(let g of t.elements)x(g.id,g.span[0]),M.push({offset:g.span[0],run:()=>Z(g)});for(let g of t.boundaries)x(g.id,g.span[0]),M.push({offset:g.span[0],run:()=>oe(g)});for(let g of t.jsons)x(g.id,g.span[0]),M.push({offset:g.span[0],run:()=>v(g.id,"json",g.span)});for(let{id:g,idSpan:N}of t.relationships)g&&N&&M.push({offset:N[0],run:()=>v(g,"edge",N)});M.sort((g,N)=>g.offset-N.offset);for(let g of M)g.run();for(let g of I(u.values()))C(g);for(let g of I(h.values()))c.set(g.id,{id:g.id,label:g.label.text,labelType:g.label.type,type:"rect",members:[],classes:[],styles:[]});for(let g of I(t.jsons))s.jsonNodes.set(g.id,{id:g.id,value:g.value,propertyOrder:g.propertyOrder,classes:[...g.classes],styles:[]});let T=0;for(let g of t.relationships){let{source:N,target:w,type:A}=g,D=H(N),U=H(w),B=j=>j==="actor"||j==="usecase"||j==="json";B(D)||b(`Relationship source '${N.id}' cannot be ${D}`,N.span,l.get(N.id).span),B(U)||b(`Relationship target '${w.id}' cannot be ${U}`,w.span,l.get(w.id).span),(A==="include"||A==="extend")&&(D!=="usecase"||U!=="usecase")&&E(`${A} relationship requires use-case endpoints`,g.span),A==="generalization"&&(D==="json"||D!==U)&&E("Generalization requires actor-to-actor or use-case-to-use-case endpoints",g.span),A==="association"&&(D==="json"||U==="json")&&g.arrowType>2&&E(`JSON relationship '${N.id}' to '${w.id}' permits only point, reversed-point, or markerless solid association`,g.span);let F=g.id??`edge-${T++}`,W={id:F,explicitId:!!g.id,source:N.id,target:w.id,type:A,arrowType:g.arrowType,minlen:g.minlen,classes:[],styles:[],animate:!1};g.label&&(W.label=g.label.text,W.labelType=g.label.type),s.relationships.push(W),d.set(F,W)}let R=new Map(a),_=new Map(o);a.clear(),o.clear();for(let g of I(u.values())){let N=R.get(g.id),w=_.get(g.id);N?a.set(g.id,N):w?o.set(g.id,w):C(g)}for(let{target:g,span:N,properties:w,statement:A}of t.metadata){let D=l.get(g);if(!D){let W=F$(w);return E(`Metadata target '${g}' is unresolved${W?` (metadata implies ${W})`:""}`,N)}let U=D.kind;U==="actor"||U==="usecase"?K(u.get(g),w,!0):U==="edge"&&(A.kind="edgeMetadata",A.edges=[{id:g,span:A.span,idSpan:N,metadata:A.metadata}],delete A.nodes);let B=h.get(g),F=d.get(g);for(let W of U==="actor"||U==="usecase"?[]:w){let{key:j,value:Q}=W;U==="boundary"&&B&&j==="type"&&(Q==="rect"||Q==="package")?B.type=Q:U==="edge"&&F&&j==="animate"&&typeof Q=="boolean"?F.animate=Q:U==="edge"&&F&&j==="animation"&&(Q==="fast"||Q==="slow")?(F.animation=Q,F.animate=!0):S(g,U,W)}}for(let g of s.relationships)g.animation&&(g.animate=!0);for(let g of u.values())g.kind==="actor"?(g.icon&&g.actorType&&g.actorType!=="normal"&&E(`Actor '${g.id}' cannot combine icon with type '${g.actorType}'`,g.span),g.business&&(g.icon||g.actorType==="awesome")&&E(`Business actor '${g.id}' must use normal or hollow geometry`,g.span)):g.shape==="rect"&&g.business&&E(`Rectangular use case '${g.id}' cannot be a business use case`,g.span),C(g);for(let g of[...t.elements].sort((N,w)=>N.span[0]-w.span[0])){if(!g.parent?.id)continue;let N=h.get(g.parent.id).members;N.includes(g.id)||N.push(g.id)}for(let g of h.values()){let N=c.get(g.id);N.type=g.type??"rect",N.members=g.members,N.classes=[...g.classes]}let $=0;for(let g of t.notes){let N=l.get(g.target);if(!N)return E(`Note target '${g.target}' is unresolved`,g.span);N.kind!=="actor"&&N.kind!=="usecase"&&b(`Note target '${g.target}' must be an actor or use case, not ${N.kind}`,g.span,N.span);let w=`note-${$++}`;s.notes.set(w,{id:w,target:g.target,label:g.label.text,labelType:g.label.type})}for(let g of t.classDefs)for(let N of g.ids)s.classDefs.set(N,{id:N,styles:[...g.styles]});for(let g of t.classes)for(let N of g.targets)_p(z(N.id,N.span).classes,g.classes);for(let g of t.styles)z(g.target,g.span).styles.push(...g.styles);return s.direction=t.direction??s.direction,s.title=i,s.accTitle=t.accTitle,s.accDescription=t.accDescription,s.accDescr=t.accDescription.replace(/\n\s+/g,`
139
+ `),s.source=e,s.headerSpan=n,s.statements=r,s}var _n=class extends Error{constructor(n){super("Invalid JSON token");this.offset=n}offset};function CS(e){let t=new Map,n=[],r=[],i=e.length,s=0,a="",o=0,c=()=>{for(;s<i;){let d=e.charCodeAt(s);if(d!==32&&d!==9&&d!==10&&d!==13)return;s++}},l=d=>{s++;let m="";for(;s<i;){let p=s,y=e[s++];if(y==='"')return m;if(y.charCodeAt(0)<32)throw new _n(p);if(y!=="\\"){d&&(m+=y);continue}let E=s,b=e[s++],S;if(b==='"'||b==="\\"||b==="/")S=b;else if(b==="b")S="\b";else if(b==="f")S="\f";else if(b==="n")S=`
140
+ `;else if(b==="r")S="\r";else if(b==="t")S=" ";else if(b==="u"){let x=e.slice(s,s+4);if(!/^[\dA-Fa-f]{4}$/.test(x))throw new _n(s);S=String.fromCharCode(parseInt(x,16)),s+=4}else throw new _n(E);d&&(m+=S)}throw new _n(s)},u=d=>{for(let m=0;m<d.length;m++)if(e[s+m]!==d[m])throw new _n(s+m);s+=d.length},h=()=>{if(e.charCodeAt(s)===45&&s++,e.charCodeAt(s)===48)s++;else if(Et(e.charCodeAt(s)))for(;Et(e.charCodeAt(s));)s++;else throw new _n(s);if(e.charCodeAt(s)===46){if(s++,!Et(e.charCodeAt(s)))throw new _n(s);for(;Et(e.charCodeAt(s));)s++}if((e.charCodeAt(s)|32)===101){if(s++,(e.charCodeAt(s)===43||e.charCodeAt(s)===45)&&s++,!Et(e.charCodeAt(s)))throw new _n(s);for(;Et(e.charCodeAt(s));)s++}};for(c();;)if(o===0){c();let d=e.charCodeAt(s);if(o=2,d===123){s++;let m=[];t.set(a,m),n.push(a),c(),e.charCodeAt(s)===125?s++:(r.push({object:!0,pointer:a,keys:m,ranges:new Map,key:"",from:0,index:0}),o=1)}else if(d===91)s++,c(),e.charCodeAt(s)===93?s++:(r.push({object:!1,pointer:a,keys:[],ranges:new Map,key:"",from:0,index:0}),a+="/0",o=0);else if(d===34)l(!1);else if(d===116)u("true");else if(d===102)u("false");else if(d===110)u("null");else if(d===45||Et(d))h();else throw new _n(s)}else if(o===1){let d=r[r.length-1];if(e.charCodeAt(s)!==34)throw new _n(s);let m=l(!0),p=d.ranges.get(m);if(p===void 0)d.keys.push(m);else for(let y=p[0];y<p[1];y++)t.delete(n[y]);if(d.key=m,d.from=n.length,c(),e.charCodeAt(s)!==58)throw new _n(s);s++,a=`${d.pointer}/${m.replaceAll("~","~0").replaceAll("/","~1")}`,o=0}else{let d=r[r.length-1];if(d===void 0)break;d.object?d.ranges.set(d.key,[d.from,n.length]):d.index++,c();let m=e.charCodeAt(s);if(m===(d.object?125:93))s++,r.pop();else{if(m!==44)throw new _n(s);s++,c(),a=`${d.pointer}/${d.index}`,o=d.object?1:0}}if(c(),s!==i)throw new _n(s);return t}function Rp(e,t,n,r){let i=Math.min(Math.max(t,0),e.length);for(let s=0;s<i;s++){let a=e.charCodeAt(s);a===13?(n++,r=1):a===10?(s===0||e.charCodeAt(s-1)!==13)&&(n++,r=1):r++}return[n,r]}function B$(e,t,n,r){let i=/\bposition (\d+)\b/.exec(e);if(i)return Rp(t,parseInt(i[1],10),n,r);let s=/\bline (\d+) column (\d+)\b/.exec(e);if(s){let a=parseInt(s[1],10),o=parseInt(s[2],10);return[n+a-1,a===1?r+o-1:o]}if(/unexpected end|end of json input/i.test(e))return Rp(t,t.length,n,r)}function NS(e,t,n){return new qe(`${e} (line ${t}, column ${n})`,"syntax",{type:"usecase",line:t,column:n})}function IS(e,t){let n;try{n=JSON.parse(e)}catch(r){let i=r instanceof Error?r.message:String(r),s=Eo(e);if(s!==e)try{JSON.parse(s)}catch(l){l instanceof Error&&(i=l.message)}let[a,o]=t(),c=B$(i,s,a,o);if(!c){let l=0;try{CS(s)}catch(u){u instanceof _n&&(l=u.offset)}c=Rp(s,l,a,o)}throw NS(`Invalid JSON: ${i}`,c[0],c[1])}if(typeof n!="object"||n===null||Array.isArray(n)){let[r,i]=t();throw NS("JSON value must have an object root",r,i)}return{value:n,propertyOrder:CS(e)}}var FS=1,Ip=2,Cp=4,BS=8,WS=16,US=32,GS=64,Ld="DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS",Od="IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING",W$="PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT",YS="ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE",HS="WORD|PLAIN_STRING|NUMBER|HASH_COLOR|CSS_IDENTIFIER|CSS_ESCAPED_COMMA|DASH|DOT|PERCENT|CSS_PUNCTUATION|COLON|LPAREN|RPAREN|LBRACKET|RBRACKET|LBRACE|RBRACE|AT|MARKERLESS_SOLID",xr=new Uint8Array(67);function Ai(e,t){for(let n of e.split("|"))if(n==="WORD")for(let r=1;r<=21;r++)xr[r]|=t;else xr[Sp.indexOf(n)]|=t}Ai(`NEWLINE|COMMENT|${YS}|${Od}`,FS);Ai(`IDENTIFIER|${Ld}`,Ip);Ai(HS,Cp);Ai(`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Ld}|NEWLINE|EOF`,BS);Ai(`NEWLINE|COMMENT|ACTOR|${Od}`,WS);Ai("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS",US);Ai("NEWLINE|IDENTIFIER|PLAIN_STRING|RBRACE",GS);var U$=new Set(["allowmixing","newpage","package","rectangle","skinparam"]),In="",ct=[],gn=[],kn=[],He=0,KS=0,mn,kd,Id=[],zS=0,VS=0;function nn(e){return In.slice(gn[e],kn[e])}function Kn(e){return[gn[e],kn[e]]}function Dd(e){let[t,n]=yi(In,gn[He]);throw new qe(`Error parsing usecase diagram: ${e} at ${Cd(In,gn[He],kn[He])}`,"syntax",{type:"usecase",line:t,column:n})}function jS(e){Dd(`Expecting token of type --> ${e} <-- but found --> '${nn(He)}' <--`)}function sn(e){return ct[He]!==e&&jS(Sp[e]),He++}function rr(e){let t=e.split("|").map((n,r)=>` ${r+1}. [${n}]`);Dd(`Expecting: one of these possible Token sequences:
141
+ ${t.join(`
142
+ `)}
143
+ but found: '${nn(He)}'`)}function kS(){let e=Od.split("|"),t=e.flatMap(i=>["NEWLINE","IDENTIFIER","PLAIN_STRING","RBRACE"].map(s=>`${i}, METADATA_START, ${s}`)),n=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Ld}|NEWLINE|EOF`.split("|"),r=e.flatMap((i,s)=>(s===0?["LPAREN","LBRACKET",...n]:n).map(a=>`${i}, ${a}`));return[YS,...t,...r,...t].join("|")}function $S(e){return e>=1&&e<=21}function LS(e){return e>=1&&e<=34}function xi(){KS=kn[He-1],ct[He]===39?He++:ct[He]!==0&&rr("NEWLINE|EOF")}function Ba(e){let t=ct[e]===36?2:ct[e]===35?1:0;return[gn[e]+t,kn[e]-t]}function Np(e){let t=Ba(e);return{text:In.slice(t[0],t[1]),type:ct[e]===36?"markdown":"text",span:t}}function XS(e){return e.replace(/\W/g,"_")}function Fa(){let e=ct[He];if(e===35||e===36)return Np(He++);LS(e)||rr(W$);let t=He;for(;LS(ct[He]);)He++;let n=[gn[t],kn[He-1]];return{text:In.slice(n[0],n[1]),type:"text",span:n}}function Ei(e){return e===21||e===35}function OS(){let e=He;Ei(ct[He])||rr("IDENTIFIER|PLAIN_STRING"),He++,sn(25);let t=He,n=ct[He];!Ei(n)&&n!==19&&n!==20&&rr("IDENTIFIER|PLAIN_STRING|TRUE|FALSE"),He++;let r=Ba(e),i=Ba(t);return{key:In.slice(r[0],r[1]),value:n===19?!0:n===20?!1:In.slice(i[0],i[1]),span:[gn[e],kn[t]],keySpan:r,valueSpan:i}}function G$(){let e=ct[He],t=ct[He+1],n=ct[He+2];return e===24?Ei(t)||t===39&&(n===39||Ei(n)):e!==39?!1:t===24||Ei(t)||t===39&&(n===39||n===24||Ei(n))}function kp(){sn(60);let e=[];for(;ct[He]===39;)He++;if(Ei(ct[He])){for(e.push(OS());G$();){if(ct[He]===24)He++;else{for(;ct[He]===39;)He++;ct[He]===24&&He++}for(;ct[He]===39;)He++;e.push(OS())}for(ct[He]===24&&He++;ct[He]===39;)He++}return sn(62),e}function $p(e){return e.map(({key:t,span:n,keySpan:r,valueSpan:i})=>({key:t,span:n,keySpan:r,valueSpan:i}))}function Lp(e,t){do{He++;let n=sn(21);e.push(nn(n)),t.push(Kn(n))}while(ct[He]===24)}function qS(e){let t=He,n=ct[He],r={id:"",label:void 0,span:Ba(t),generated:n!==21,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(n===21){He++,r.id=nn(t);let i=ct[He];i===65||e&&i===63?(He++,r.label=Fa(),sn(i===65?66:64),r.shape=i===65?"ellipse":"rect"):r.label=Np(t)}else n===35||n===36?(He++,r.label=Np(t),r.id=XS(r.label.text)):rr(Od);return r}function $d(e){let t=He,n=qS(!e);if(e&&(n.shape=void 0),ct[He]===60&&(n.metadata=kp()),ct[He]===48){He++;let r=sn(50);sn(49),n.stereotype=nn(r).trim(),n.stereotypeSpan=Kn(r)}return ct[He]===52&&Lp(n.classes,n.classSpans),n.explicit=!!(n.shape||n.metadata||n.stereotype),n.nodeSpan=[gn[t],kn[He-1]],n}function Op(e,t){return{id:e.id,kind:t,label:e.label,span:e.span,generated:e.generated,parent:kd,shape:e.shape,metadata:e.metadata,stereotype:e.stereotype,classes:e.classes}}function DS(e,t){return{id:e.id,label:e.label,span:e.span,generated:e.generated,declares:t,classed:e.classes.length>0}}function Dp(e,t){let n={id:e.id,span:e.nodeSpan,idSpan:e.span,labelSpan:e.label.span};return t&&(n.defines=!0),e.stereotypeSpan&&(n.stereotypeSpan=e.stereotypeSpan),e.metadata&&(n.metadata=$p(e.metadata)),e.classSpans.length>0&&(n.classSpans=e.classSpans),n}function Tp(e){if(ct[He]<1||ct[He]>36)return!1;for(let t=He+1;;t++){let n=ct[t];if(n===59||(xr[n]&e)!==0)return!0;if(n<1||n>36)return!1}}function Pa(e){let t=kn[e]-gn[e]-(ct[e]===59?0:1);return Math.max(1,t-1)}function QS(){let e=He,t={type:"association",arrowType:0,minlen:1,target:void 0,span:[0,0]};ct[He]===21&&ct[He+1]===23&&(t.explicitId=nn(He),t.explicitIdSpan=Kn(He),He+=2);let n=He,r=ct[He++];if(r===47)sn(25),ct[He]!==17&&ct[He]!==18&&rr("INCLUDE|EXTEND"),t.type=ct[He]===17?"include":"extend",t.label={text:t.type,type:"text",span:Kn(He)},He++;else if(r===46)t.type="generalization";else if(r===53)t.minlen=Pa(n);else if(r===54)t.arrowType=1,kn[n]-gn[n]===3&&Tp(0)?(t.label=Fa(),t.minlen=Pa(sn(59))):t.minlen=Pa(n);else if(r===59)if(t.arrowType=2,kn[n]-gn[n]===2&&Tp(US)){t.label=Fa();let i=ct[He];i===53?t.arrowType=0:i===55?t.arrowType=3:i===57?t.arrowType=4:i!==59&&rr("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS"),(t.arrowType===0||t.arrowType===2)&&(t.minlen=Pa(He)),He++}else t.minlen=Pa(n);else r===55?t.arrowType=3:r===57?t.arrowType=4:r===56||r===58?(t.arrowType=r===56?5:6,Tp(0)&&(t.label=Fa(),sn(59))):(He--,rr(Ld));return t.target=$d(!1),t.span=[gn[e],kn[He-1]],t}function Er(e){return{kind:e,span:[0,0]}}function ZS(e,t,n,r){let i=n.target;i.explicit&&mn.elements.push(Op(i,"usecase")),mn.relationships.push({source:DS(e,t),target:DS(i,i.explicit),span:n.span,id:n.explicitId,idSpan:n.explicitIdSpan,type:n.type,arrowType:n.arrowType,label:n.label,minlen:n.minlen}),r.push(Dp(i,i.explicit));let s=Er("edge");return s.nodes=r,s.edges=[{id:n.explicitId??`edge-${zS++}`,span:s.span}],n.explicitIdSpan&&(s.edges[0].idSpan=n.explicitIdSpan),n.label&&(s.edges[0].labelSpan=n.label.span),s}function JS(e){let t=Er("node");return t.nodes=e,t}function e1(e){He++;let t=[$d(!0)],n;if(ct[He]===24)do He++,t.push($d(!0));while(ct[He]===24);else e&&(xr[ct[He]]&Ip)!==0&&(n=QS());xi();for(let i of t)mn.elements.push(Op(i,"actor"));let r=t.map(i=>Dp(i,!0));return n?ZS(t[0],!0,n,r):JS(r)}function t1(e){let t=$d(!1),n=e&&(xr[ct[He]]&Ip)!==0?QS():void 0;xi(),n||(t.explicit=!0,t.shape??="ellipse"),t.explicit&&mn.elements.push(Op(t,"usecase"));let r=[Dp(t,t.explicit)];return n?ZS(t,t.explicit,n,r):JS(r)}function Y$(){He++;let e=qS(!0),t={id:e.id,label:e.label,span:e.span,generated:e.generated,classes:e.classes},n=ct[He]===60?kp():void 0;ct[He]===52&&Lp(e.classes,e.classSpans),xi(),mn.boundaries.push(t),kd=t;let r=[];for(;(xr[ct[He]]&WS)!==0;)r.push(n1(!1));kd=void 0;let i=sn(4);xi();let s=Er("group");return s.group=t.id,s.idSpan=t.span,s.titleSpan=t.label.span,s.endSpan=Kn(i),s.classSpans=e.classSpans,r.length>0&&(s.children=r),n&&(s.metadata=$p(n),mn.metadata.push({target:t.id,span:t.span,properties:n,statement:s})),s}function vS(){let e=He,t=ct[He];for($S(t)||t===27?He++:t===59?(He++,$S(ct[He])||jS("WORD"),He++):rr("WORD|CSS_IDENTIFIER|MARKERLESS_SOLID"),sn(25),(xr[ct[He]]&Cp)===0&&Dd(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
144
+ <[${HS.replaceAll("|","] ,[")}]>
145
+ but found: '${nn(He)}'`);(xr[ct[He]]&Cp)!==0;)He++;return In.slice(gn[e],kn[He-1]).replaceAll("\\,",",")}function PS(){let e=[vS()];for(;ct[He]===24;)He++,e.push(vS());return e}function Mp(){let e=[sn(21)];for(;ct[He]===24;)He++,e.push(sn(21));return e}function Nd(e){let t=Ba(e);return{id:nn(e),span:t,idSpan:t}}function H$(){let e=He,t=ct[He],n;if(t===41||t===42||t===40){He++;let r=nn(e);t===40?mn.accDescription=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim():t===42?mn.accDescription=r.slice(r.indexOf(":")+1).trim():mn.accTitle=r.slice(r.indexOf(":")+1).trim(),n=Er(t===41?"accTitle":"accDescr")}else if(t===5){He++;let r=ct[He];(r<6||r>10)&&rr("TD|TB|BT|LR|RL"),mn.direction=r===6?"TB":nn(He),He++,n=Er("direction")}else{if(t===2)return e1(!0);if(t===3)return Y$();if(t===11){He++,sn(12);let r=sn(21),i=Fa();mn.notes.push({target:nn(r),span:Kn(r),label:i}),n=Er("note"),n.ref=`note-${VS++}`,n.refSpan=i.span,n.nodes=[Nd(r)]}else if(t===43){He++;let r=sn(44),i=[],s=[];ct[He]===52&&Lp(i,s);let a=gn[e]+4;for(;In.charCodeAt(a)===32||In.charCodeAt(a)===9;)a++;let o=a;for(;/\w/.test(In.charAt(o));)o++;let c={id:In.slice(a,o),value:{},propertyOrder:new Map,span:[a,o],classes:i};mn.jsons.push(c),Id.push([c,r]),n=Er("json"),n.nodes=[{id:c.id,span:c.span,idSpan:c.span,defines:!0,classSpans:s}],n.classSpans=s}else if(t===14){He++;let r=Mp();mn.classDefs.push({ids:r.map(nn),styles:PS()}),n=Er("classDef"),n.ref=nn(r[0]),n.refSpan=Kn(r[0])}else if(t===15){He++;let r=Mp(),i=Mp();mn.classes.push({targets:r.map(s=>({id:nn(s),span:Kn(s)})),classes:i.map(nn)}),n=Er("classAssign"),n.ref=nn(i[0]),n.refSpan=Kn(i[0]),n.nodes=r.map(Nd)}else if(t===16){He++;let r=sn(21);mn.styles.push({target:nn(r),span:Kn(r),styles:PS()}),n=Er("style"),n.nodes=[Nd(r)]}else{let r=ct[He+1];if(r===60){(xr[ct[He+2]]&GS)===0&&rr(kS()),He++;let i=Nd(e);t!==21&&(i.id=XS(In.slice(i.span[0],i.span[1])));let s=kp();n=Er("metadata"),n.nodes=[i],n.metadata=$p(s),mn.metadata.push({target:i.id,span:i.span,properties:s,statement:n})}else return(!((xr[r]&BS)!==0||t===21&&(r===65||r===63))||t===21&&U$.has(nn(e).toLowerCase()))&&rr(kS()),t1(!0)}}return xi(),n}function n1(e){let t=He,n=ct[He];if(n===39)return He++,{kind:"blank",span:Kn(t)};if(n===38)return He++,xi(),{kind:"comment",span:Kn(t)};let r=e?H$():n===2?e1(!1):t1(!1);if(r.span=[gn[t],KS],r.edges)for(let i of r.edges)i.span=r.span;return r}function r1(e,t){In=e,{types:ct,starts:gn,ends:kn}=_S(e),He=0,mn=TS(),kd=void 0,Id=[],zS=0,VS=0;try{let n=sn(1);xi();let r=[];for(;(xr[ct[He]]&FS)!==0;)r.push(n1(!0));ct[He]!==0&&Dd(`Redundant input, expecting EOF but found: ${nn(He)}`);for(let[i,s]of Id){let a=IS(nn(s),()=>yi(e,gn[s]));i.value=a.value,i.propertyOrder=a.propertyOrder}return MS(e,mn,Kn(n),r,t)}finally{In="",ct=gn=kn=Id=[]}}var K$={normal:"usecaseActor",hollow:"usecaseActorHollow",awesome:"usecaseActorAwesome",icon:"usecaseActorIcon"},vp=[["none","arrow_point"],["arrow_point","none"],["none","none"],["none","arrow_circle"],["none","arrow_cross"],["arrow_circle","none"],["arrow_cross","none"]];function s1(e){return typeof e=="string"?e:e===null?"null":String(e)}function z$(e){let t=[],n=[[e.value,"",""]],r=[];for(;n.length>0;){let[i,s,a]=n.pop();if(r.length=0,Array.isArray(i))i.length===0?t.push({key:s,accessibleKey:s,value:"[]"}):i.every(o=>o===null||typeof o!="object")?i.forEach((o,c)=>t.push({key:c===0?s:"",accessibleKey:s,value:s1(o)})):i.forEach((o,c)=>r.push([o,`${s}[${c}]`,`${a}/${c}`]));else if(i!==null&&typeof i=="object"){let o=i,c=e.propertyOrder.get(a)??Object.keys(o);c.length===0&&t.push({key:s,accessibleKey:s,value:"{}"});for(let l of c)r.push([Object.prototype.hasOwnProperty.call(o,l)?o[l]:void 0,s?`${s}.${l}`:l,`${a}/${l.replaceAll("~","~0").replaceAll("/","~1")}`])}else t.push({key:s,accessibleKey:s,value:s1(i)});for(let o=r.length-1;o>=0;o--)n.push(r[o])}return t}function Wa(...e){return e.filter(Boolean).join(" ")}function V$(e){return e.type==="generalization"?["none","extension"]:e.type!=="association"?vp[0]:vp[e.arrowType]??vp[2]}function i1(e){let t=[],n=[],r=i=>{let s=new Map;for(let a of["default",...i]){let o=e.classDefs.get(a);if(o)for(let c of o.styles){let l=c.trim(),u=l.indexOf(":"),h=(u===-1?l:l.slice(0,u)).trim();h&&s.set(h,l)}}return[...s.values()]};for(let i of e.actors.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:K$[i.type],isGroup:!1,padding:10,cssClasses:Wa("default","usecase-actor",`usecase-actor-${i.type}`,i.business&&"usecase-business",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:r(i.classes),actorType:i.type,business:i.business,icon:i.icon||void 0,stereotype:i.stereotype||void 0,parentId:i.parentId||void 0});for(let i of e.useCases.values()){let s=i.shape==="ellipse";t.push({id:i.id,label:i.label,labelType:i.labelType,shape:s?i.business?"usecaseBusiness":"usecaseEllipse":"rect",isGroup:!1,padding:s?20:10,cssClasses:Wa("default","usecase-element",`usecase-${i.shape}`,i.business&&"usecase-business",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:r(i.classes),business:i.business,stereotype:i.stereotype||void 0,parentId:i.parentId||void 0})}for(let i of e.notes.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:"note",isGroup:!1,padding:10,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:r([]),noteTarget:i.target});for(let i of e.jsonNodes.values())t.push({id:i.id,label:i.id,labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,cssClasses:Wa("default","usecase-json-table",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:r(i.classes),jsonRows:z$(i)});for(let i of e.systemBoundaries.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,cssClasses:Wa("default","system-boundary",`system-boundary-${i.type}`,...i.classes),cssStyles:[...i.styles],cssCompiledStyles:r(i.classes),boundaryType:i.type});for(let i of e.relationships){let s=i.type==="include"||i.type==="extend",[a,o]=V$(i),c=i.animate||i.animation!==void 0,l={id:i.id,start:i.source,end:i.target,relationshipType:i.type,pattern:s?"dotted":"solid",arrowTypeStart:a,arrowTypeEnd:o,classes:Wa("default","relationship",`relationship-${i.type}`,...i.classes,c&&`edge-animation-${i.animation??"fast"}`),style:[...i.styles],cssCompiledStyles:r(i.classes),animate:i.animate,animation:i.animation,minlen:i.minlen,explicitId:i.explicitId,internal:!1};s?(l.label=i.type,l.labelType="text"):i.type==="association"&&(i.label&&(l.label=i.label),i.labelType&&(l.labelType=i.labelType)),n.push(l)}for(let i of e.notes.values())n.push({id:`${i.id}-edge`,start:i.id,end:i.target,relationshipType:"note",pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",classes:"default relationship relationship-note",style:[],cssCompiledStyles:r([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:n}}var j$=32,X$=16,q$=72,vd=20,Pp=26,Up=40,Ga=60,o1=6,Fp=6,Ua=10,Bp=8,Pd=9,Wd=12,Q$=14,Ya=' fill="var(--_s)" stroke="var(--_b)"';function a1(e,t,n){let r=e.usecase?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function Z$(e){return e.replace(/[&<>\\]/g,t=>`&#${t.charCodeAt(0)};`)}function vs(e,t,n,r,i,s=0){return Ue(e&&!t?Z$(e):e,t,n,r,i,s)}function Wp(e,t,n,r){let i=n===1||n===2?1:-1,s=n===1||n===3,a=(s?e.w:e.h)/2,o=0;if(e.kind===0)s?(a=Up/2+3,o=(Ga-e.h)/2):a+=2;else if(e.kind===1){let c=(s?e.h:e.w)/2;a*=Math.sqrt(Math.max(1-(r/c)**2,0))}return s?[t.x+i*a,t.y+o+r]:[t.x+r,t.y+i*a]}function l1(e,t){let n=t===1||t===3;if(e.kind===0)return n?Ga*.5:Up*.6;let r=n?e.h:e.w;return e.kind===1?r*.6:r-16}function J$(e,t,n){let r=new Map,i=(s,a,o,c)=>{let l=t[s];if(l.isGroup)return;let u=a[o]-l.x,h=a[o+1]-l.y,d;if(Math.abs(Math.abs(h)-l.h/2)<.5)d=h<0?0:2;else if(Math.abs(Math.abs(u)-l.w/2)<.5)d=u<0?3:1;else return;let m=s*4+d,p={route:a,at:o,toward:a[c+(d&1?1:0)]},y=r.get(m);y?y.push(p):r.set(m,[p])};for(let s of e){let a=s.route.length-3;s.src===s.dst||a<3||(i(s.src,s.route,0,3),i(s.dst,s.route,a,a-3))}for(let[s,a]of r){let o=s>>2,c=s&3,l=n[o],u=a.length>1?Math.min(Q$,l1(l,c)/(a.length-1)):0;a.sort((h,d)=>h.toward-d.toward);for(let h=0;h<a.length;h++){let[d,m]=Wp(l,t[o],c,(h-(a.length-1)/2)*u);a[h].route[a[h].at]=d,a[h].route[a[h].at+1]=m}}}function eL(e,t,n,r,i){let s=e-n*Wd,a=t-r*Wd,o=Wd*.5;return`<path class="pele-marker" d="M${f(e)},${f(t)}L${f(s-r*o)},${f(a+n*o)}L${f(s+r*o)},${f(a-n*o)}Z" fill="var(--_bg)" stroke="${i}" stroke-linejoin="round"/>`}function Fd(e){return e==="extension"?Wd:_t(e)}function Bd(e,t,n,r,i,s,a){return e==="extension"?eL(t,n,r,i,s):wt(e,t,n,r,i,s,a)}function tL(e,t){let n=e.node,r=e.style.shape,i=` fill="none" stroke="var(--_b)"${e.style.line}`,s=-21,a=9,o;return n.actorType==="hollow"?(a=8,o=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${r}/><path d="M-20,-9H20V0H5.5L20,15.5L12,25.5L0,12L-12,25.5L-20,15.5L-5.5,0H-20Z" fill="var(--_bg)" stroke="var(--_b)" stroke-linejoin="round"${r}/>`):n.actorType==="awesome"?o=`<path d="M0,-30A11,11 0 1 1 0,-8A11,11 0 1 1 0,-30ZM-20,25C-20,9 -12,-3 0,-3C12,-3 20,9 20,25C20,28 18,30 15,30H-15C-18,30 -20,28 -20,25Z" fill="var(--_b)"${r}/>`:n.actorType==="icon"?(s=-14,a=12,o=`<rect x="-22" y="-26" width="44" height="44"${xt(Ya+r)}/><svg class="pele-icon" data-icon="${We(n.icon??"")}" x="-14" y="-18" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t?.(n.icon??"")??""}</svg>`):o=`<circle cy="-21" r="9"${Ya}${r}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${i}/>`,n.business&&(o+=`<path class="pele-business" d="M${f(.12*a)},${f(s+.99*a)}L${f(.92*a)},${f(s-.39*a)}"${i}/>`),o}function d1(e,t,n){return vn(e.direction)?vt(n,r=>c1(e,t,n,r)):c1(e,t,n,!1)}function c1(e,t,n,r){let i=i1(e),s=n.fontSize??16,a=Math.round(s*.875),o=Math.round(s*.8125),c=n.measurer??at(n.fontFamily,n.fontFamilyMono),l=n.padding??8,u=n.icons,h=r?"TB":cn(e.direction),d=h==="LR"||h==="RL",m=new Map,p=[],y=[];i.nodes.forEach((g,N)=>m.set(g.id,N));for(let g of i.nodes){let N=Mt(g.cssStyles.length>0?g.cssCompiledStyles.concat(g.cssStyles):g.cssCompiledStyles),w=(N.bold?1:0)|(N.italic?2:0),A=N.fontSize??s,D=g.labelType==="markdown",U=vs(g.stereotype&&`«${g.stereotype}»`,!1,c,o,200,w),B={node:g,kind:2,style:N,label:U,stereotype:U,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},F;if(g.isGroup){B.kind=4,B.label=vs(g.label,D,c,A,4e3,w);let W=B.label.height;F=Ft(0,0),F.isGroup=!0,F.padX=vd,F.padBottom=vd,F.padTop=g.boundaryType==="package"?W+2*Fp+16:W>0?W+16:vd,F.minW=B.label.width+2*vd}else{if(g.jsonRows){B.kind=3,B.label=vs(g.label,!1,c,A,4e3,w|1);let W=0;for(let j of g.jsonRows){let Q=vs(j.key,!1,c,a,4e3,w),Y=vs(j.value,!1,c,a,260,w);B.rows.push([Q,Y]),B.keyW=Math.max(B.keyW,Q.width),W=Math.max(W,Y.width),B.h+=Math.max(Q.height,Y.height,Math.round(a*1.5))+Bp}B.keyW>0&&(B.keyW+=2*Ua),B.headH=Math.max(B.label.height,Math.round(A*1.5))+Bp,B.w=Math.max(B.label.width+2*Ua,B.rows.length>0?B.keyW+W+2*Ua:0,72),B.h+=B.headH}else if(g.actorType)B.kind=0,B.label=vs(g.label,D,c,A,140,w),B.w=Math.max(Up,B.label.width,U.width),B.h=Ga+o1+U.height+B.label.height;else{B.label=vs(g.label,D,c,g.shape==="note"?a:A,180,w);let W=Math.max(B.label.width,U.width),j=B.label.height+U.height;g.shape==="usecaseEllipse"||g.shape==="usecaseBusiness"?(B.kind=1,B.w=Math.max(W+2*g.padding+(g.business?16:4),88),B.h=Math.max(j+28,48)):g.shape==="note"?(B.w=W+2*g.padding+6,B.h=j+18):(B.w=Math.max(W+2*g.padding+12,80),B.h=Math.max(j+24,44))}F=Ft(B.w,B.h)}F.seq=p.length,p.push(B),y.push(F)}i.nodes.forEach((g,N)=>{y[N].parent=g.parentId!==void 0?m.get(g.parentId)??-1:-1});let E=[],b=[],S=[];for(let g of i.edges){let N=m.get(g.start),w=m.get(g.end);if(N===void 0||w===void 0)continue;let A=g.relationshipType==="include"||g.relationshipType==="extend",D=vs(A?`«${g.label}»`:g.label,g.labelType==="markdown",c,a,200);N===w&&(p[N].loops++,d?y[N].h+=2*(Pp+(D.height>0?D.height+8:0)):y[N].w+=2*(Pp+(D.width>0?D.width+12:0))),S.push(g),b.push(D),E.push({src:N,dst:w,minlen:g.minlen,labelW:D.width>0?D.width+12:0,labelH:D.height>0?D.height+4:0,route:[],labelX:0,labelY:0})}let x=Ln(y,E,h,{nodeSep:a1(t,"nodeSpacing",j$),edgeSep:X$,rankSep:a1(t,"rankSpacing",q$),portSep:20}),I=bn(e.title,c,s,4e3),L=I.height>0?I.height+12:0,O=Math.max(x.width,I.width),v=l+(O-x.width)/2,G=l+L;Rr(y,E,v,G);let K=Math.ceil(O+2*l),C=Math.ceil(x.height+L+2*l),Z=new Map;for(let g of E)dr(Z,g.route);J$(E,y,p);let oe="",H=[],z="";for(let g=0;g<p.length;g++){let N=p[g],w=y[g],A=N.node,D=Nt(A.cssClasses.replace(/^default\s?/,"")),U=We(A.id),B=N.style.text,F=N.style.shape,W=Dt(N.style),j=W||' fill="var(--_m)"',Q=N.w,Y=N.h;if(N.kind===4){let k=w.x-w.w/2,J=w.y-w.h/2;Tn(F)&&H.push({box:[k,J,k+w.w,J+w.h],shape:F});let te=` fill="var(--_a)"${Dn(F)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${F}`,se=` class="pele-cluster-label"${j}${B}`,re;if(A.boundaryType==="package"){let P=Math.min(N.label.width+2*Fp+8,w.w),ee=N.label.height+2*Fp;re=`<rect class="pele-boundary-tab" x="${f(k)}" y="${f(J)}" width="${f(P)}" height="${f(ee)}"${te}/><rect x="${f(k)}" y="${f(J+ee)}" width="${f(w.w)}" height="${f(w.h-ee)}"${te}/>`+Ce(N.label,k+P/2,J+ee/2,se,u)}else re=`<rect x="${f(k)}" y="${f(J)}" width="${f(w.w)}" height="${f(w.h)}"${xt(te)}/>`+Ce(N.label,nL(w,N.label.width,Z),J+8+N.label.height/2,se,u);oe+=`<g class="pele-cluster pele-boundary${D}" data-id="${U}">${re}</g>`;continue}let ne,q;if(N.kind===0){q="pele-actor";let k=-Y/2,J=k+Ga+o1+N.stereotype.height/2;ne=`<g class="pele-actor-figure" transform="translate(0,${f(k+Ga/2)})">${tL(N,u)}</g>`+Ce(N.stereotype,0,J,` class="pele-stereotype" font-size="${o}" fill="var(--_m)"`,u)+Ce(N.label,0,Y/2-N.label.height/2,` class="pele-label"${B}`,u)}else if(N.kind===3){q="pele-json";let k=-Q/2,J=-Y/2+N.headH,te="",se=`M${f(k)},${f(J)}H${f(k+Q)}`;N.keyW>0&&(se+=`M${f(k+N.keyW)},${f(J)}V${f(Y/2)}`);for(let[re,P]of N.rows){let ee=Math.max(re.height,P.height,Math.round(a*1.5))+Bp;te+=Ce(re,k+Ua+re.width/2,J+ee/2,` class="pele-json-key"${j}`,u)+rL(P,k+N.keyW+Ua,J+ee/2,` class="pele-json-value"${W}${B}`,u),J+=ee}ne=`<rect x="${f(k)}" y="${f(-Y/2)}" width="${f(Q)}" height="${f(Y)}"${xt(Ya+F)}/><path class="pele-json-lines" d="${se}" fill="none" stroke="var(--_b)"${N.style.line}/>`+Ce(N.label,0,-Y/2+N.headH/2,` class="pele-label" font-weight="var(--_hw)"${W}${B}`,u)+`<g font-size="${a}">${te}</g>`}else{let k=N.stereotype.height/2,J;if(N.kind===1){if(q="pele-usecase",J=`<ellipse rx="${f(Q/2)}" ry="${f(Y/2)}"${Ya}${F}/>`,A.business){let te=Q/2-15,se=Q/2-5,re=P=>Y/2*Math.sqrt(1-(P/(Q/2))**2);J+=`<path class="pele-business" d="M${f(te)},${f(re(te))}L${f(se)},${f(-re(se))}" fill="none" stroke="var(--_b)"${N.style.line}/>`}}else if(A.shape==="note"){q="pele-note";let te=Q/2,se=Y/2;J=`<path d="M${f(-te)},${f(-se)}H${f(te-Pd)}L${f(te)},${f(Pd-se)}V${f(se)}H${f(-te)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${F}/><path d="M${f(te-Pd)},${f(-se)}V${f(Pd-se)}H${f(te)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${N.style.line}/>`}else q="pele-usecase",J=`<rect x="${f(-Q/2)}" y="${f(-Y/2)}" width="${f(Q)}" height="${f(Y)}"${xt(Ya+F)}/>`;ne=J+Ce(N.stereotype,0,-N.label.height/2,` class="pele-stereotype" font-size="${o}"${j}`,u)+Ce(N.label,0,k,` class="pele-label"${A.shape==="note"?` font-size="${a}"`:""}${W}${B}`,u)}z+=`<g class="pele-node ${q}${D}" data-id="${U}" transform="translate(${f(w.x)},${f(w.y)})">${ne}</g>`}let M="",T="",R="",_=new Map;for(let g=0;g<E.length;g++){let N=E[g],w=S[g],A=b[g],D=w.style.length>0||w.cssCompiledStyles.length>0?Mt(w.cssCompiledStyles.concat(w.style)):void 0,U=w.arrowTypeStart,B=w.arrowTypeEnd,F;if(N.src===N.dst){let q=y[N.src],k=p[N.src],J=_.get(N.src)??0;_.set(N.src,J+1);let te=d?2:1,se=Math.min(l1(k,te)/2,8+J*6),re=Pp+J*8,[P,ee]=Wp(k,q,te,-se),[ae,ue]=Wp(k,q,te,se),ce=Math.hypot(re,se)||1,he=d?se/ce:re/ce,V=d?re/ce:se/ce,X=Fd(U),le=Fd(B),de=(Me,Ie,ge,xe)=>d?`${f(Me+ge*se*(xe?1:0))},${f(Ie+xe)}`:`${f(Me+xe)},${f(Ie+ge*se*(xe?1:0))}`,Ae=d?P-he*X:P+he*X,we=d?ee+V*X:ee-V*X,Ee=ae+he*le,Te=ue+V*le;F={d:`M${f(Ae)},${f(we)}C${de(P,ee,-1,re)} ${de(ae,ue,1,re)} ${f(Ee)},${f(Te)}`,sx:P,sy:ee,sdx:d?he:-he,sdy:d?-V:V,ex:ae,ey:ue,edx:-he,edy:-V},d?(N.labelX=q.x,N.labelY=Math.max(ee,ue)+re*.75+6+A.height/2):(N.labelX=Math.max(P,ae)+re*.75+8+A.width/2,N.labelY=q.y)}else{if(N.route.length<6)continue;F=Mn(N.route,void 0,Fd(U),Fd(B))}let W=Fo(F.d,[F.sx,F.sy,F.ex,F.ey],H,F.tokens),j=W&&Bo(W,D?.line),Q=j||(D?.stroke?nt(D.stroke):"var(--_l)");if(j===""){let q="var(--_bg)";M+=Uo(F.d,Bd(U,F.sx,F.sy,F.sdx,F.sdy,q,q)+Bd(B,F.ex,F.ey,F.edx,F.edy,q,q),D?.line)}let Y=w.internal?"2 3":w.pattern==="dotted"?"5 4":w.animate?"9 5":"",ne=Bd(U,F.sx,F.sy,F.sdx,F.sdy,Q)+Bd(B,F.ex,F.ey,F.edx,F.edy,Q);if(T+=`<g class="pele-edge pele-${w.relationshipType}${Nt(w.classes.replace(/^default relationship relationship-\S+\s?/,""))}" data-id="${We(w.id)}"${j?` stroke="${j}"`:""}${D?.line??""}><path d="${F.d}"${Y?` stroke-dasharray="${Y}"`:""}/>`+(W&&j?Wo(ne,W):ne)+"</g>",A.width>0){let q=N.labelX,k=N.labelY,J=w.relationshipType==="include"||w.relationshipType==="extend";R+=ln(w.id,A,q,k,(J?' fill="var(--_m)"':"")+(D?.text??""),u)}}return{svg:ot("usecase",K,C,s,n,e,Ce(I,K/2,l+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+(oe?`<g class="pele-clusters">${oe}</g>`:"")+On(M)+(T?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${T}</g>`:"")+(R?`<g class="pele-edge-labels" font-size="${a}">${R}</g>`:"")+`<g class="pele-nodes">${z}</g>`),width:K,height:C,links:[]}}function nL(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(t===0||r===void 0)return e.x;let i=e.x-e.w/2+6,s=e.x+e.w/2-6,a=r.filter(d=>d>i&&d<s).sort((d,m)=>d-m);a.push(s);let o=t/2+6,c=e.x,l=1/0,u=0,h=i;for(let d of a){if(d-h>=2*o){let m=Math.min(Math.max(e.x,h+o),d-o);Math.abs(m-e.x)<l&&(l=Math.abs(m-e.x),c=m)}else l===1/0&&d-h>u&&(u=d-h,c=(h+d)/2);h=d}return c}function rL(e,t,n,r,i){if(e.lines.length<2)return Ce(e,t+e.width/2,n,r,i);let s="";for(let a=0;a<e.lines.length;a++)s+=Ce(Nr(e,a),t+e.widths[a]/2,n-e.height/2+Cr(e,a),r,i);return s}var u1={type:"usecase",math:!0,parse:(e,t,n)=>r1(e,n),render:d1};function Ps(e){let t=e.trim();return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function Gp(e){return e.map(Ps).sort()}var Ud=class{type="venn";title;subsets=[];textNodes=[];styles=[];known=new Set;current;indent=!1;setDiagramTitle(t){this.title=t}addSubsetData(t,n,r){let i=Gp(t);this.current=i,i.length===1&&this.known.add(i[0]),this.subsets.push({sets:i,size:r??10/t.length**2,label:n?Ps(n):void 0})}addTextData(t,n,r){this.textNodes.push({sets:Gp(t),id:Ps(n),label:r?Ps(r):void 0})}addStyleData(t,n){let r=new Map;for(let[i,s]of n)r.set(i,s&&Ps(s));this.styles.push({targets:Gp(t),styles:r})}validateUnionIdentifiers(t){let n=t.map(Ps).filter(r=>!this.known.has(r));if(n.length>0)throw new qe(`unknown set identifier: ${n.join(", ")}`,"semantic",{type:"venn"})}getCurrentSets(){return this.current}getIndentMode(){return this.indent}setIndentMode(t){this.indent=t}};var Yp=["$end","INVALID","EOF","NEWLINE","VENN","TITLE","SET","UNION","TEXT","INDENT_TEXT","STYLE","BRACKET_LABEL","NUMERIC","HEXCOLOR","RGBCOLOR","RGBACOLOR","IDENTIFIER","STRING","COMMA","COLON"],sL=[["venn-beta",4],["set",6],["union",7],["text",8],["style",10]],Gd=class{constructor(t,n){this.src=t;this.host=n}src;host;text="";start=0;at=0;lineStart=!1;ended=!1;word(t,n){let r=this.src;for(let i=0;i<n.length;i++){let s=r.charCodeAt(t+i),a=n.charCodeAt(i);if(s!==a&&(s+32!==a||s<65||s>90))return!1}return!0}keyword(t,n){return this.word(t,n)&&!it(this.src.charCodeAt(t+n.length))}color(t,n){let r=this.src,i=t+1;for(let s=0;s<n;s++){for(;Xe(r.charCodeAt(i));)i++;let a=i;for(;Et(r.charCodeAt(i))||r.charCodeAt(i)===46;)i++;if(i===a)return-1;for(;Xe(r.charCodeAt(i));)i++;if(r.charCodeAt(i)!==(s===n-1?41:44))return-1;i++}return i}afterLineFeed(t){let n=t-1;for(;this.src.charCodeAt(n)===32||this.src.charCodeAt(n)===9;)n--;return this.src.charCodeAt(n)===10}lineEnd(t){let n=this.src.indexOf(`
146
+ `,t);return n===-1?this.src.length:n}next(){let t=this.src,n=t.length;for(;;){let r=this.at;if(this.start=r,this.text="",r>=n)return this.ended?0:(this.ended=!0,2);let i=t.charCodeAt(r);if(i===37&&t.charCodeAt(r+1)===37&&t.charCodeAt(r+2)!==123){this.at=this.lineEnd(r+2);continue}if(this.lineStart&&this.word(r,"title")&&this.afterLineFeed(r)&&t.slice(r+5,this.lineEnd(r+5)).trim()===""){let s=this.lineEnd(r+5);for(;t.charCodeAt(s)===10||t.charCodeAt(s)===13;)s++;this.at=s;continue}if(this.lineStart){if(i===32||i===9){let s=r+1;for(;t.charCodeAt(s)===32||t.charCodeAt(s)===9;)s++;if(this.at=s,this.keyword(s,"text")&&this.host.getIndentMode())return this.at=s+4,this.lineStart=!1,this.text=t.slice(r,s),9;continue}i!==10&&i!==13&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(i===10||i===13){for(r++;t.charCodeAt(r)===10||t.charCodeAt(r)===13;)r++;return this.lineStart=!0,this.token(3,r)}if(i===37&&t.charCodeAt(r+1)===37){this.at=this.lineEnd(r);continue}if(i===32||i===9){for(r++;t.charCodeAt(r)===32||t.charCodeAt(r)===9;)r++;this.at=r;continue}if((i|32)>=97&&(i|32)<=122||i===95){let s=t.charCodeAt(r+5);if(this.word(r,"title")&&Xe(s)&&s!==10&&s!==13){let a=r+6;for(;a<n;){let o=t.charCodeAt(a);if(o===35||o===10||o===59)break;a++}if(a>r+6)return this.token(5,a)}for(let[a,o]of sL)if(this.keyword(r,a)&&t.charCodeAt(r+a.length)!==45)return this.token(o,r+a.length);if(this.word(r,"rgb")){let a=(t.charCodeAt(r+3)|32)===97,o=r+(a?4:3),c=t.charCodeAt(o)===40?this.color(o,a?4:3):-1;if(c!==-1)return this.token(a?15:14,c)}for(r++;it(t.charCodeAt(r))||t.charCodeAt(r)===45;)r++;return this.token(16,r)}if(i===91){if(t.charCodeAt(r+1)===34){let a=t.indexOf('"',r+2);return a===-1||t.charCodeAt(a+1)!==93?1:(this.at=a+2,this.text=t.slice(r+2,a),11)}let s=r+1;for(;s<n&&t.charCodeAt(s)!==93&&t.charCodeAt(s)!==34;)s++;return s===r+1||t.charCodeAt(s)!==93?1:(this.at=s+1,this.text=t.slice(r+1,s).trim(),11)}if(Et(i)||i===46||i===43||i===45){(i===43||i===45)&&r++;let s=r;for(;Et(t.charCodeAt(r));)r++;if(r>s){if(t.charCodeAt(r)===46&&Et(t.charCodeAt(r+1)))for(r+=2;Et(t.charCodeAt(r));)r++}else if(t.charCodeAt(r)===46&&Et(t.charCodeAt(r+1)))for(r+=2;Et(t.charCodeAt(r));)r++;else return 1;return this.token(12,r)}if(i===35){let s=r+1;for(;s<r+9&&qa(t.charCodeAt(s));)s++;return s>=r+4?this.token(13,s):1}if(i===34){let s=t.indexOf('"',r+1);return s===-1?1:this.token(17,s+1)}return i===44?this.token(18,r+1):i===58?this.token(19,r+1):1}}token(t,n){return this.text=this.src.slice(this.at,n),this.at=n,t}};var iL="'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'",oL="'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'";function f1(e,t){let n=new Gd(e,t),r=-1,i=()=>r===-1?r=n.next():r,s=m=>{throw i()===1?ut("venn",e,n.start,"",!0):ut("venn",e,n.start,`Expecting ${m}, got '${Yp[r]}'`)},a=()=>(r=-1,n.text),o=m=>(i()!==m&&s(`'${Yp[m]}'`),a()),c=()=>(i()!==16&&r!==17&&s("'IDENTIFIER', 'STRING'"),a()),l=()=>{let m=[c()];for(;i()===18;)a(),m.push(c());return m},u=(m,p)=>{let y=i()===11?a():void 0,E;if(i()===19&&(a(),E=parseFloat(o(12))),p){if(m.length<2)throw new qe("union requires multiple identifiers","semantic",{type:"venn"});t.validateUnionIdentifiers(m)}t.addSubsetData(m,y,E),t.setIndentMode(!0)},h=m=>{let p=i();p!==16&&p!==17&&p!==12&&s("'NUMERIC', 'IDENTIFIER', 'STRING'");let y=a(),E=p!==12&&i()===11?a():void 0;t.addTextData(m(),y,E)},d=()=>{let m=l(),p=[];for(;;){let y=o(16);o(19);let E;if(i()===17)E=a();else{let b=[];for(;i()===16||r>=12&&r<=15;)b.push(a());b.length===0&&s(oL),E=b.join(" ")}if(p.push([y,E]),i()!==18)break;a()}t.addStyleData(m,p)};for(;i()===3;)a();for(o(4);;){let m=i();if(m===2)return;if((m<3||m>10||m===4)&&s(iL),a(),m===5)t.setDiagramTitle(n.text.slice(6));else if(m===6)u([c()],!1);else if(m===7)u(l(),!0);else if(m===8){let p=l();h(()=>p)}else m===9?h(()=>{let p=t.getCurrentSets();if(!p)throw new qe("text requires set","semantic",{type:"venn"});return p}):m===10&&d()}}var Yd=Math.PI*2;function aL(e){let t=new Set,n=new Map;for(let i of e)t.add(JSON.stringify([...i.sets].sort())),i.sets.length===1&&n.set(i.sets[0],i.size);let r=[];for(let i of e){if(i.sets.length<3)continue;let s=[...i.sets].sort();for(let a=0;a<s.length-1;a++)for(let o=a+1;o<s.length;o++){let c=[s[a],s[o]],l=JSON.stringify(c);if(t.has(l))continue;t.add(l);let u=n.get(c[0]),h=n.get(c[1]);r.push({sets:c,size:u!==void 0&&h!==void 0?Math.min(u,h)/4:2.5,label:""})}}return r.length>0?[...e,...r]:e}function cL(e,t,n){if(n>=e+t)return 0;let r=Math.min(e,t);if(n<=Math.abs(e-t))return Math.PI*r*r;let i=e*e*Math.acos((n*n+e*e-t*t)/(2*n*e)),s=t*t*Math.acos((n*n+t*t-e*e)/(2*n*t)),a=.5*Math.sqrt(Math.max((-n+e+t)*(n+e-t)*(n-e+t)*(n+e+t),0));return i+s-a}function lL(e,t,n){let r=Math.abs(e-t),i=e+t;if(!(n>0))return i;if(n>=Math.PI*Math.min(e,t)**2)return r;for(let s=0;s<48;s++){let a=(r+i)/2;cL(e,t,a)>n?r=a:i=a}return(r+i)/2}function h1(e,t,n,r,i,s){let a=1/0;for(let o of t){let c=e[o],l=r-c.x,u=i-c.y,h=c.r-Math.sqrt(l*l+u*u);if(h<a){if(h<s)return h;a=h}}for(let o of n){let c=e[o],l=r-c.x,u=i-c.y,h=Math.sqrt(l*l+u*u)-c.r;if(h<a){if(h<s)return h;a=h}}return a}function Hd(e,t,n){let r=0,i=0,s=e[t[0]];for(let p of t){let y=e[p];r+=y.x/t.length,i+=y.y/t.length,y.r<s.r&&(s=y)}let a=s.r,o=r,c=i,l=h1(e,t,n,o,c,-1/0),u=0,h=(p,y)=>{let E=h1(e,t,n,p,y,l-a*1e-9);if(!(E>l-a*1e-9))return!1;let b=Math.hypot(p-r,y-i);return E>l+a*1e-9||b<u-a*1e-9?(l=E,u=b,o=p,c=y,!0):!1},d=10;for(let p=-d;p<=d;p++)for(let y=-d;y<=d;y++)y*y+p*p<=d*d&&h(s.x+y*a/d,s.y+p*a/d);let m=a/d;for(let p=0;p<40&&m>a*1e-6;p++){let y=!1;for(let E=0;E<8;E++){let b=E*Yd/8;h(o+Math.cos(b)*m,c+Math.sin(b)*m)&&(y=!0)}y||(m/=2)}return{x:o,y:c,margin:l}}function p1(e){let t=new Map;for(let E of e)for(let b of E.sets)t.has(b)||t.set(b,10);for(let E of e)E.sets.length===1&&t.set(E.sets[0],E.size);let n=new Map,r=[],i=0;for(let E of t.values())Number.isFinite(E)&&E>i&&(i=E);i===0&&(i=10);let s=Math.sqrt(i/Math.PI);for(let[E,b]of t){n.set(E,r.length);let S=Number.isFinite(b)&&b>0?Math.sqrt(b/Math.PI):0;r.push({id:E,x:0,y:0,r:Math.max(S,s*.3)})}let a=r.length;if(a<2)return r;let o=new Map;for(let E of aL(e)){if(E.sets.length!==2)continue;let b=n.get(E.sets[0]),S=n.get(E.sets[1]);b!==S&&o.set(Math.min(b,S)*a+Math.max(b,S),E.size)}let c=new Map;for(let[E,b]of o)c.set(E,lL(r[Math.floor(E/a)].r,r[E%a].r,b));let l=s*.15,u=(E,b)=>c.get(E*a+b)??r[E].r+r[b].r+l;if(a===2)return r[1].x=u(0,1),r;if(a===3){let E=u(0,1),b=u(0,2),S=u(1,2),x=e.some(I=>new Set(I.sets).size===3);for(let I=0;I<40;I++){let L=E>0?(E*E+b*b-S*S)/(2*E):0;if(r[1].x=E,r[2].x=Math.max(-b,Math.min(b,L)),r[2].y=Math.sqrt(Math.max(b*b-L*L,0)),!x||Hd(r,[0,1,2],[]).margin>s*.12)break;E*=.94,b*=.94,S*=.94}return r}let h=0;for(let E of r)h+=2*E.r+l;let d=Math.min(300,Math.floor(3e6/(a*a)));if(a<=64){let E=h/Yd;r.forEach((b,S)=>{let x=S*Yd/a-Math.PI/2;b.x=Math.cos(x)*E,b.y=Math.sin(x)*E})}else{let E=Math.ceil(Math.sqrt(a)),b=2*s+l;r.forEach((S,x)=>{S.x=x%E*b,S.y=Math.floor(x/E)*b})}let m=new Float64Array(a),p=new Float64Array(a),y=new Int32Array(a);for(let E=0;E<d;E++){m.fill(0),p.fill(0),y.fill(0);for(let b=0;b<a;b++)for(let S=b+1;S<a;S++){let x=c.get(b*a+S),I=r[b].r+r[S].r+l,L=r[S].x-r[b].x,O=r[S].y-r[b].y,v=Math.hypot(L,O);if(x===void 0&&v>=I)continue;v<1e-9&&(L=Math.cos(b+S),O=Math.sin(b+S),v=1);let G=(v-(x??I))/2/v;m[b]+=L*G,p[b]+=O*G,m[S]-=L*G,p[S]-=O*G,y[b]++,y[S]++}for(let b=0;b<a;b++)y[b]!==0&&(r[b].x+=m[b]/y[b],r[b].y+=p[b]/y[b])}return r}function m1(e,t){let n=c=>`M${t(c.x-c.r)},${t(c.y)}A${t(c.r)},${t(c.r)} 0 1 1 ${t(c.x+c.r)},${t(c.y)}A${t(c.r)},${t(c.r)} 0 1 1 ${t(c.x-c.r)},${t(c.y)}Z`;if(e.length===1)return n(e[0]);let r=(c,l,u,h)=>{for(let d of e)if(d!==u&&d!==h&&Math.hypot(c-d.x,l-d.y)>d.r*(1+1e-9))return!1;return!0},i=[];for(let c=0;c<e.length;c++)for(let l=c+1;l<e.length;l++){let u=e[c],h=e[l],d=Math.hypot(h.x-u.x,h.y-u.y);if(d>=u.r+h.r||d<=Math.abs(u.r-h.r)||d===0)continue;let m=(u.r*u.r-h.r*h.r+d*d)/(2*d),p=Math.sqrt(Math.max(u.r*u.r-m*m,0)),y=u.x+(h.x-u.x)*m/d,E=u.y+(h.y-u.y)*m/d;for(let b of[1,-1]){let S=y+b*p*(h.y-u.y)/d,x=E-b*p*(h.x-u.x)/d;r(S,x,u,h)&&i.push({x:S,y:x,a:u,b:h})}}if(i.length<2){let c=e[0];for(let l of e)l.r<c.r&&(c=l);for(let l of e)if(l!==c&&Math.hypot(l.x-c.x,l.y-c.y)+c.r>l.r*(1+1e-9))return"";return n(c)}let s=0,a=0;for(let c of i)s+=c.x/i.length,a+=c.y/i.length;i.sort((c,l)=>Math.atan2(c.y-a,c.x-s)-Math.atan2(l.y-a,l.x-s));let o="";for(let c=0;c<i.length;c++){let l=i[c],u=i[(c+1)%i.length];c===0&&(o=`M${t(l.x)},${t(l.y)}`);let h,d=0,m=1/0;for(let p of[l.a,l.b]){if(p!==u.a&&p!==u.b)continue;let y=Math.atan2(l.y-p.y,l.x-p.x),E=Math.atan2(u.y-p.y,u.x-p.x)-y;E<=0&&(E+=Yd);let b=p.x+p.r*Math.cos(y+E/2),S=p.y+p.r*Math.sin(y+E/2),x=Math.hypot(b-(l.x+u.x)/2,S-(l.y+u.y)/2);x<m&&(m=x,h=p,d=E>Math.PI?1:0)}h===void 0?o+=`L${t(u.x)},${t(u.y)}`:o+=`A${t(h.r)},${t(h.r)} 0 ${d} 1 ${t(u.x)},${t(u.y)}`}return o+"Z"}var dL=100,uL=1.6,g1=Mt([]);function Hp(e){return e.length===1?e[0]:JSON.stringify(e)}function b1(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),s=Math.round(r*.8125),a=n.measurer??at(n.fontFamily,n.fontFamilyMono),o=n.padding??8,c=p1(e.subsets),l=new Map;c.forEach((g,N)=>l.set(g.id,N));let u=new Map;for(let{targets:g,styles:N}of e.styles){let w=Hp(g),A=u.get(w);A||u.set(w,A=new Map);for(let[D,U]of N)A.set(D,U)}let h=g=>{let N=u.get(g);if(!N)return g1;let w=[];for(let[A,D]of N)w.push(`${A}:${D}`);return Mt(w)},d=c.map(()=>[]);for(let g=0;g<c.length;g++)for(let N=g+1;N<c.length;N++)Math.hypot(c[g].x-c[N].x,c[g].y-c[N].y)<c[g].r+c[N].r&&(d[g].push(N),d[N].push(g));let m=new Map;for(let g of e.subsets)m.set(Hp(g.sets),g);let p=new Map;for(let[g,N]of m){let w=[...new Set(N.sets)],A=w.map(q=>l.get(q)),D=new Set(A),U=A[0];for(let q of A)c[q].r<c[U].r&&(U=q);let B=h(g),F=N.label??(N.sets.length===1?N.sets[0]:void 0),W=(B.bold?1:0)|(B.italic?2:0),j=d[U].filter(q=>!D.has(q)),Q=Hd(c,A,j),Y=j.length>0&&Q.margin<c[U].r*.2;Y&&(Q=Hd(c,A,[]));let ne={sets:w,inside:A,spot:Q,lines:[],style:B,across:Y};if(F){let q=w.length===1?r:i;ne.lines.push({id:void 0,raw:F,size:q,base:W,label:Ue(F,!1,a,q,4e3,W)})}p.set(g,ne)}for(let g of e.textNodes){let N=g.label??g.id;p.get(Hp(g.sets))?.lines.push({id:g.id,raw:N,size:s,base:0,label:Ue(N,!1,a,s,4e3)})}let y=0;for(let g of c)g.r>y&&(y=g.r);let E=y>0?dL/y:1,b=1;for(let g of p.values()){if(g.spot.margin<=0)continue;let N=0,w=0;for(let D of g.lines)N=Math.max(N,D.label.width),w+=D.label.height;let A=Math.hypot(N,w)/2+4;b=Math.max(b,Math.min(A/(g.spot.margin*E),uL))}E*=b;for(let g of p.values()){let N=Math.max(g.spot.margin*E*1.8,72);for(let w of g.lines)w.label.width>N&&(w.label=Ue(w.raw,!1,a,w.size,N,w.base))}let S=1/0,x=1/0,I=-1/0,L=-1/0;for(let g of c)S=Math.min(S,(g.x-g.r)*E),x=Math.min(x,(g.y-g.r)*E),I=Math.max(I,(g.x+g.r)*E),L=Math.max(L,(g.y+g.r)*E);for(let g of p.values()){let N=0,w=0;for(let A of g.lines)N=Math.max(N,A.label.width),w+=A.label.height;S=Math.min(S,g.spot.x*E-N/2),I=Math.max(I,g.spot.x*E+N/2),x=Math.min(x,g.spot.y*E-w/2),L=Math.max(L,g.spot.y*E+w/2)}c.length===0&&(S=x=I=L=0);let O=Ue(e.title&&Ps(e.title),!1,a,r,4e3,1),v=O.height>0?O.height+12:0,G=Math.max(I-S,O.width),K=o+(G-(I-S))/2-S,C=o+v-x,Z=Math.ceil(G+2*o),oe=Math.ceil(L-x+v+2*o),H=c.map(g=>({id:g.id,x:g.x*E+K,y:g.y*E+C,r:g.r*E})),z="";H.forEach((g,N)=>{let w=yt(N),A=p.get(g.id)?.style??g1;z+=`<circle class="pele-venn-set" data-id="${We(g.id)}" cx="${f(g.x)}" cy="${f(g.y)}" r="${f(g.r)}" fill="${w}" fill-opacity="0.2" stroke="${w}"${A.shape}/>`});let M=[...p.values()].filter(g=>g.sets.length>1&&g.style.shape!==""),T=g=>{if(g.across)return"";let N=g.sets.length===1&&/[";]fill-opacity:/.test(g.style.shape)?g.style.shape:"";for(let w of M)w.sets.every(A=>g.sets.includes(A))&&(N=w.style.shape);return N},R="",_="";for(let g of p.values()){let N=We(g.sets.join("|"));if(g.sets.length>1&&g.style.shape!==""){let F=m1(g.inside.map(W=>H[W]),f);F!==""&&(R+=`<path class="pele-venn-overlap" data-id="${N}" d="${F}" fill="none"${g.style.shape}/>`)}let w=0;for(let F of g.lines)w+=F.label.height;if(w===0)continue;let A=g.spot.x*E+K,D=g.spot.y*E+C-w/2,U=T(g),B="";for(let F of g.lines){let W=F.id===void 0?g.style.text:h(F.id).text,j=lr(U,W),Q=F.id===void 0?` class="pele-label"${F.size===r?"":` font-size="${F.size}"`}${j?` fill="${j}"`:""}${W}`:` class="pele-venn-text" data-id="${We(F.id)}" font-size="${s}" fill="${j??"var(--_m)"}"${W}`;B+=Ce(F.label,A,D+F.label.height/2,Q),D+=F.label.height}_+=`<g class="pele-venn-region" data-id="${N}">${B}</g>`}return{svg:ot("venn",Z,oe,r,n,{},Ce(O,Z/2,o+O.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-venn-sets">${z}</g>`+(R?`<g class="pele-venn-overlaps">${R}</g>`:"")+(_?`<g class="pele-venn-labels">${_}</g>`:"")),width:Z,height:oe,links:[]}}var y1={type:"venn",parse(e,t,n){let r=new Ud;return n&&(r.title=n),f1(e,r),r},render:b1};var Kd=class{nodes=new Map;labels;links=[];trends=new Map;pipelines=new Map;annotations=[];notes=[];accelerators=[];deaccelerators=[];annotationsBox;axes={};size;addNode(t){let n=this.nodes.get(t.id)??{id:t.id,label:t.label};this.nodes.set(t.id,{...n,...t,className:t.className??n.className,labelOffsetX:t.labelOffsetX??n.labelOffsetX,labelOffsetY:t.labelOffsetY??n.labelOffsetY}),this.labels=void 0}addLink(t){this.links.push(t)}addTrend(t){this.trends.set(t.nodeId,t)}startPipeline(t){this.pipelines.set(t,{nodeId:t,componentIds:[]});let n=this.nodes.get(t);n&&(n.isPipelineParent=!0)}addPipelineComponent(t,n){this.pipelines.get(t)?.componentIds.push(n);let r=this.nodes.get(n);r&&(r.inPipeline=!0)}addAnnotation(t){this.annotations.push(t)}addNote(t){this.notes.push(t)}addAccelerator(t){this.accelerators.push(t)}addDeaccelerator(t){this.deaccelerators.push(t)}setAnnotationsBox(t,n){this.annotationsBox={x:t,y:n}}setAxes(t){this.axes={...this.axes,...t}}setSize(t,n){this.size={width:t,height:n}}getNode(t){return this.nodes.get(t)}resolveNodeId(t){if(this.nodes.has(t))return t;if(!this.labels){this.labels=new Map;for(let[n,r]of this.nodes)this.labels.has(r.label)||this.labels.set(r.label,n)}return this.labels.get(t)??t}build(){let t=[];for(let n of this.nodes.values()){if(typeof n.x!="number"||typeof n.y!="number")throw new qe(`Node "${n.label}" is missing coordinates`,"semantic",{type:"wardley"});t.push(n)}return{nodes:t,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}};function zd(e,t){let n=e<=1?e*100:e;if(n<0||n>100)throw new qe(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,"semantic",{type:"wardley"});return n}function Si(e,t,n){return{x:zd(t,`${n} evolution`),y:zd(e,`${n} visibility`)}}function E1(e){return e==="+<>"?"bidirectional":e==="+<"?"backward":e==="+>"?"forward":void 0}function fL(e){if(!e?.startsWith("+"))return{};let t=e.indexOf("'",2),n=e[1]==="'"&&t!==-1?e.slice(2,t):void 0;return e.includes("<>")?{flow:"bidirectional",label:n}:e.includes("<")?{flow:"backward",label:n}:e.includes(">")?{flow:"forward",label:n}:{label:n}}function x1(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function hL(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map(n=>n.secondName?`${n.name.trim()} / ${n.secondName.trim()}`:n.name.trim()),stageBoundaries:e.evolution.stages.filter(n=>n.boundary!==void 0).map(n=>n.boundary)});for(let n of e.anchors){let r=Si(n.visibility,n.evolution,`Anchor "${n.name}"`);t.addNode({id:n.name,label:n.name,x:r.x,y:r.y,className:"anchor"})}for(let n of e.components){let r=Si(n.visibility,n.evolution,`Component "${n.name}"`),[i,s]=x1(n.label);t.addNode({id:n.name,label:n.name,x:r.x,y:r.y,className:"component",labelOffsetX:i,labelOffsetY:s,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of e.notes){let r=Si(n.visibility,n.evolution,`Note "${n.text}"`);t.addNote({text:n.text,x:r.x,y:r.y})}for(let n of e.pipelines){let r=t.getNode(n.parent);if(!r||typeof r.y!="number")throw new qe(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,"semantic",{type:"wardley"});let i=r.y;t.startPipeline(n.parent);for(let s of n.components){let a=`${n.parent}_${s.name}`,[o,c]=x1(s.label),l=zd(s.evolution,`Pipeline component "${s.name}" evolution`);t.addNode({id:a,label:s.name,x:l,y:i,className:"pipeline-component",labelOffsetX:o,labelOffsetY:c,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(n.parent,a)}}for(let n of e.links){let r=!!n.arrow&&(n.arrow.includes("-.->")||n.arrow.includes(".-.")),i=fL(n.arrow),s=E1(n.fromPort)??E1(n.toPort)??i.flow;t.addLink({source:t.resolveNodeId(n.from),target:t.resolveNodeId(n.to),dashed:r,label:i.label??n.linkLabel,flow:s})}for(let n of e.evolves){let r=t.getNode(n.component);r?.y!==void 0&&t.addTrend({nodeId:n.component,targetX:zd(n.target,`Evolve target for "${n.component}"`),targetY:r.y})}if(e.annotations.length>0){let n=Si(e.annotations[0].x,e.annotations[0].y,"Annotations box");t.setAnnotationsBox(n.x,n.y)}for(let n of e.annotation){let r=Si(n.x,n.y,`Annotation ${n.number}`);t.addAnnotation({number:n.number,coordinates:[{x:r.x,y:r.y}],text:n.text})}for(let n of e.accelerators){let r=Si(n.x,n.y,`Accelerator "${n.name}"`);t.addAccelerator({name:n.name,x:r.x,y:r.y})}for(let n of e.deaccelerators){let r=Si(n.x,n.y,`Deaccelerator "${n.name}"`);t.addDeaccelerator({name:n.name,x:r.x,y:r.y})}}function A1(e,t){let n=new Kd;return hL(e,n),{type:"wardley",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
147
+ `):void 0,...n.build()}}function S1(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function pL(){let e=0,t=0;return(n,r)=>{if((r<e||r>=t)&&(e=r,t=S1(n,r)),t===r||n.charCodeAt(t)!==46)return-1;let i=S1(n,t+1);return i>t+1?i:-1}}var w1={name:"ARROW",pattern:/->/y,first:"-"},_1={name:"LINK_ARROW",pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:"->+"},Wn=(e,t)=>({name:e,pattern:new RegExp(t,"y"),first:t[0]}),R1=[{name:"[",pattern:"["},{name:",",pattern:","},{name:"]",pattern:"]"},{name:"@",pattern:"@"},{name:"/",pattern:"/"},{name:"(",pattern:"("},{name:")",pattern:")"},{name:"-",pattern:"-",longer:[w1,_1,Yt]},{name:"{",pattern:"{"},{name:"}",pattern:"}"},{name:"WARDLEY_NUMBER",pattern:/[0-9]+\.[0-9]+/y,first:"0123456789",scanner:pL},w1,{name:"LINK_PORT",pattern:/\+<>|\+>|\+</y,first:"+"},_1,{name:"LINK_LABEL",pattern:/;[^\n\r]+/y,first:";"},{name:"STRATEGY",pattern:/build|buy|outsource|market/y,first:"bom"},Wn("KW_WARDLEY","wardley-beta"),Wn("KW_SIZE","size"),Wn("KW_EVOLUTION","evolution"),Wn("KW_ANCHOR","anchor"),Wn("KW_COMPONENT","component"),Wn("KW_LABEL","label"),Wn("KW_INERTIA","inertia"),Wn("KW_EVOLVE","evolve"),Wn("KW_PIPELINE","pipeline"),Wn("KW_NOTE","note"),Wn("KW_ANNOTATIONS","annotations"),Wn("KW_ANNOTATION","annotation"),Wn("KW_ACCELERATOR","accelerator"),Wn("KW_DEACCELERATOR","deaccelerator"),{name:"NAME_WITH_SPACES",pattern:/(?!title\s|accTitle|accDescr)[A-Za-z](?:[A-Za-z0-9_()&]|-(?!>))*(?:[ \t]+[A-Za-z(](?:[A-Za-z0-9_()&]|-(?!>))*)*/y,first:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},{name:"WS",pattern:/[ \t]+/y,hidden:!0,first:" "},Qi(),jt,hr,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y,first:"0123456789"},Pn,{name:"ID",pattern:/[\w]([-\w]*\w)?/y,first:"_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},An,Sn,Yt,qt,Qt];function T1(e){let t=new Wt(Gt(e,R1,"wardley"),R1,"wardley"),n={$type:"Wardley",anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},r=m=>t.kinds[t.i]===m,i=()=>r(36)||r(37)||r(30),s=()=>r(36)?dn(t.take()):r(37)||r(30)?t.take():t.fail("a name"),a=()=>Number(t.expect(10)),o=()=>parseInt(t.expect(35)),c=()=>r(10)?Number(t.take()):parseInt(t.expect(35)),l=()=>{if(!r(-1))for(r(38)||t.fail("a line break or the end of input");r(38);)t.i++},u=m=>{t.expect(0);let p=m();t.expect(1);let y=m();return t.expect(2),[p,y]},h=()=>{t.expect(21),t.expect(0);let m=t.accept(7),p=o();t.expect(1);let y=t.accept(7),E=o();return t.expect(2),{$type:"Label",negX:m,offsetX:p,negY:y,offsetY:E}},d=()=>{let m={$type:"EvolutionStage",name:s()};return t.accept(3)&&(m.boundary=a()),t.accept(4)&&(m.secondName=s()),m};for(;r(38);)t.i++;for(t.expect(16);!r(-1);)switch(t.kind){case 38:t.i++;break;case 32:n.accDescr=zt(t.take()),l();break;case 33:n.accTitle=Kt(t.take()),l();break;case 34:n.title=Ht(t.take()),l();break;case 17:{t.i++;let[m,p]=u(o);l(),n.size={$type:"Size",width:m,height:p};break}case 18:{t.i++;let m=[d()];for(t.expect(11),m.push(d());t.accept(11);)m.push(d());l(),n.evolution={$type:"Evolution",stages:m};break}case 19:{t.i++;let m=s(),[p,y]=u(a);l(),n.anchors.push({$type:"Anchor",name:m,visibility:p,evolution:y});break}case 20:{t.i++;let m={$type:"Component",name:s(),visibility:0,evolution:0,inertia:!1};[m.visibility,m.evolution]=u(a),r(21)&&(m.label=h()),r(5)&&t.kinds[t.i+1]===15&&(t.i++,m.decorator={$type:"Decorator",strategy:t.take()},t.expect(6)),t.accept(22)?m.inertia=!0:t.accept(5)&&(t.expect(22),t.expect(6),m.inertia=!0),l(),n.components.push(m);break}case 23:{t.i++;let m=s(),p=a();l(),n.evolves.push({$type:"Evolve",component:m,target:p});break}case 24:{t.i++;let m=s();for(t.expect(8),t.expect(38);r(38);)t.i++;let p=[];do{t.expect(20);let y={$type:"PipelineComponent",name:s(),evolution:0};t.expect(0),y.evolution=a(),t.expect(2),r(21)&&(y.label=h()),l(),p.push(y)}while(r(20));t.expect(9),l(),n.pipelines.push({$type:"Pipeline",parent:m,components:p});break}case 25:{t.i++;let m=dn(t.expect(36)),[p,y]=u(a);l(),n.notes.push({$type:"Note",text:m,visibility:p,evolution:y});break}case 26:{t.i++;let[m,p]=u(c);l(),n.annotations.push({$type:"Annotations",x:m,y:p});break}case 27:{t.i++;let m=o();t.expect(1);let[p,y]=u(c),E=dn(t.expect(36));l(),n.annotation.push({$type:"Annotation",number:m,x:p,y,text:E});break}case 28:case 29:{let m=t.kind===29;t.i++;let p=s(),[y,E]=u(a);l(),m?n.deaccelerators.push({$type:"Deaccelerator",name:p,x:y,y:E}):n.accelerators.push({$type:"Accelerator",name:p,x:y,y:E});break}default:{i()||t.fail("a statement");let m={$type:"Link",from:s(),to:""};r(12)&&(m.fromPort=t.take()),(r(13)||r(11))&&(m.arrow=t.take()),m.to=s(),r(12)&&(m.toPort=t.take()),r(14)&&(m.linkLabel=t.take().substring(1).trim()),l(),n.links.push(m)}}return n}var mL=["Genesis","Custom Built","Product","Commodity"],gL=48,Ut=6,wi=10,bL=8,Vd=15,Ha=60,yL=30,M1=20,Kp="var(--_c)",zn="var(--_l)";function EL(e,t,n,r,i){let s=e["wardley-beta"]?.[t];return typeof s=="number"&&s>=r&&s<=i?s:n}function go(e,t,n){return e<t?t:e>n?n:e}function C1(e,t,n,r){let i=jr(e),s="",a=n;for(let o of e.lines){let c=!0;for(let l of o){if(l.icon!==void 0)continue;let u=wr(l.style&~i);s+=`<tspan${c?` x="${f(t)}" y="${f(a)}"`:""}${u}>${nt(l.text)}</tspan>`,c=!1}a+=e.lineHeight}return s===""?"":`<text${Xn(r,i)} xml:space="preserve">${s}</text>`}function N1(e,t,n,r){let i=typeof t=="number"&&Number.isFinite(t)?t:EL(e,n,r,1,1e6);return go(i,200,1e4)-2*gL}function I1(e,t,n){let r=N1(t,e.size?.width,"width",900);return ps(n,r,160,(i,s)=>xL(e,t,n,i,r,s))}function xL(e,t,n,r,i,s){let a=n.fontSize??16,o=Math.round(a*.8125),c=Math.round(a*.6875),l=n.measurer??at(n.fontFamily,n.fontFamilyMono),u=n.padding??8,h=N1(t,e.size?.height,"height",600)*Math.max(.75,r/i),d=t["wardley-beta"]?.showGrid===!0,m=0,p=0,y=r,E=h,b=(V,X,le,de)=>{V<m&&(m=V),X<p&&(p=X),le>y&&(y=le),de>E&&(E=de)},S=(V,X,le,de)=>(b(X-V.width/2,le-V.height/2,X+V.width/2,le+V.height/2),Ce(V,X,le,de,n.icons)),x=(V,X,le,de)=>(b(X,le-V.size,X+V.width,le-V.size+V.height+4),C1(V,X,le,de)),I=(V,X,le=s?Math.max(64,Math.min(120,r/2)):4e3,de=0)=>Ue(V,!1,l,X,le,de),L=V=>V/100*r,O=V=>h-V/100*h,v=e.axes.stages&&e.axes.stages.length>0?e.axes.stages:mL,G=e.axes.stageBoundaries,K=G!==void 0&&G.length===v.length,C="",Z="",oe=h,H=0;if(v.forEach((V,X)=>{let le=K?H:X/v.length,de=K?go(G[X],0,1):(X+1)/v.length;H=de,X>0&&(C+=`<path class="pele-wardley-stage" d="M${f(le*r)},0V${f(h)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let Ae=I(V,o,Math.max(48,Math.abs(de-le)*r-12));Z+=S(Ae,(le+de)/2*r,h+8+Ae.height/2,` class="pele-wardley-stage-label" font-size="${o}" fill="var(--_m)"`),oe=Math.max(oe,h+8+Ae.height)}),d)for(let V=1;V<4;V++)C+=`<path class="pele-wardley-grid" d="M${f(r*V/4)},0V${f(h)}M0,${f(h*V/4)}H${f(r)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;C+=`<path class="pele-wardley-axis" d="M0,0V${f(h)}H${f(r)}" stroke="${zn}"/>`;let z=I(e.axes.xLabel??"Evolution",o),M=I(e.axes.yLabel??"Visibility",o),T=` class="pele-wardley-axis-label" font-size="${o}" font-weight="var(--_hw)"`,R=S(z,r/2,oe+6+z.height/2,T)+Ce(M,-16,h/2,`${T} transform="rotate(-90 -16 ${f(h/2)})"`);b(-16-M.height/2,0,0,0);let _=oe+6+z.height+10,$=new Map;for(let V of e.nodes)$.set(V.id,{x:L(V.x),y:O(V.y),node:V});let g="",N=new Map;for(let V of e.pipelines){N.set(V.nodeId,new Set(V.componentIds));let X=[];for(let Te of V.componentIds){let Me=$.get(Te);Me&&X.push(Me)}if(X.length===0)continue;X.sort((Te,Me)=>Te.x-Me.x);let le=X[0].x,de=X[X.length-1].x,Ae=X[0].y,we=Ae-2*Ut,Ee=$.get(V.nodeId);Ee&&(Ee.x=(le+de)/2,Ee.y=we-wi/6),b(le-Vd,we,de+Vd,we+4*Ut),g+=`<g class="pele-wardley-pipeline" data-id="${We(V.nodeId)}"><rect x="${f(le-Vd)}" y="${f(we)}" width="${f(de-le+2*Vd)}" height="${f(4*Ut)}" fill="var(--_s)" stroke="var(--_b)"${ft}/>`+(X.length>1?`<path d="M${f(le)},${f(Ae)}H${f(de)}" stroke="${zn}" stroke-dasharray="4 4"/>`:"")+"</g>"}let w=new Map,A=(V,X,le)=>{let de=V.node;if(de.className==="anchor"){let Ae=w.get(de);return Ae||w.set(de,Ae=I(de.label,o,s?Math.max(64,r/2):4e3,1)),1/Math.hypot(X/(Ae.width/2+5),le/(o*.8))}return de.isPipelineParent?wi/Math.SQRT2:de.sourceStrategy?2*Ut:Ut},D=new Map,U=(V,X,le)=>{Math.abs(X)<.25||Math.abs(le)<.25||D.set(V,(D.get(V)??0)|(X>0?le<0?1:2:le<0?4:8))},B="";for(let V of e.links){let X=$.get(V.source),le=$.get(V.target);if(!X||!le||X===le||N.get(V.target)?.has(V.source))continue;let de=le.x-X.x,Ae=le.y-X.y,we=Math.hypot(de,Ae);if(we<.01)continue;let Ee=de/we,Te=Ae/we,Me=A(X,Ee,Te),Ie=A(le,Ee,Te);if(Me+Ie>=we)continue;U(X,Ee,Te),U(le,-Ee,-Te);let ge=X.x+Ee*Me,xe=X.y+Te*Me,ie=le.x-Ee*Ie,pe=le.y-Te*Ie,Re="";(V.flow==="forward"||V.flow==="bidirectional")&&(Re+=wt("arrow_point",ie,pe,Ee,Te,zn),ie-=Ee*_t("arrow_point"),pe-=Te*_t("arrow_point")),(V.flow==="backward"||V.flow==="bidirectional")&&(Re+=wt("arrow_point",ge,xe,-Ee,-Te,zn),ge+=Ee*_t("arrow_point"),xe+=Te*_t("arrow_point"));let be="";if(V.label){let Se=I(V.label,c+1,200),Ne=Ee>=0?1:-1,De=Te*Ne,ve=-Ee*Ne,fe=5+Math.abs(De)*Se.width/2+Math.abs(ve)*Se.height/2;be=S(Se,(X.x+le.x)/2+De*fe,(X.y+le.y)/2+ve*fe,` class="pele-edge-label" font-size="${c+1}" fill="var(--_m)"`)}B+=`<g class="pele-edge${V.dashed?" pele-wardley-dashed":""}" data-id="${We(V.source)}-${We(V.target)}"><path d="M${f(ge)},${f(xe)}L${f(ie)},${f(pe)}" stroke="${zn}"${V.dashed?' stroke-dasharray="6 6"':""}/>`+Re+be+"</g>"}let F="";for(let V of e.trends){let X=$.get(V.nodeId);if(!X)continue;let le=L(V.targetX),de=O(V.targetY),Ae=le-X.x,we=de-X.y,Ee=Math.hypot(Ae,we),Te="",Me=Ee>0?A(X,Ae/Ee,we/Ee):0;if(Ee>Me+Ut+4){let Ie=Ae/Ee,ge=we/Ee,xe=le-Ie*(Ut+2),ie=de-ge*(Ut+2);Te=`<path d="M${f(X.x+Ie*Me)},${f(X.y+ge*Me)}L${f(xe-Ie*_t("arrow_point"))},${f(ie-ge*_t("arrow_point"))}" stroke="${Kp}" stroke-dasharray="4 4"/>`+wt("arrow_point",xe,ie,Ie,ge,Kp)}b(le-Ut,de-Ut,le+Ut,de+Ut),F+=`<g class="pele-wardley-trend" data-id="${We(V.nodeId)}">${Te}<circle cx="${f(le)}" cy="${f(de)}" r="${Ut}" fill="var(--_bg)" stroke="${Kp}"/></g>`}let W="",j=1.2*Ut,Q=.7*Ut;for(let V of $.values()){let X=V.node,{x:le,y:de}=V,Ae=X.className==="anchor",we=X.sourceStrategy,Ee="";if(we){let ge=we==="outsource"?"var(--_m)":we==="buy"?"var(--_a)":we==="build"?"var(--_s)":"var(--_bg)";Ee+=`<circle class="pele-wardley-${we}" cx="${f(le)}" cy="${f(de)}" r="${2*Ut}" fill="${ge}" stroke="${zn}"/>`}if(we==="market"){let ge=j*Math.cos(Math.PI/6),xe=de+j*Math.sin(Math.PI/6);Ee+=`<path d="M${f(le)},${f(de-j)}L${f(le-ge)},${f(xe)}H${f(le+ge)}Z" fill="none" stroke="${zn}"/>`;for(let[ie,pe]of[[le,de-j],[le-ge,xe],[le+ge,xe]])Ee+=`<circle cx="${f(ie)}" cy="${f(pe)}" r="${f(Q)}" fill="var(--_bg)" stroke="${zn}"/>`}else X.isPipelineParent?Ee+=`<rect x="${f(le-wi/2)}" y="${f(de-wi/2)}" width="${wi}" height="${wi}" fill="var(--_bg)" stroke="${zn}"/>`:Ae||(Ee+=`<circle cx="${f(le)}" cy="${f(de)}" r="${Ut}" fill="var(--_bg)" stroke="${zn}"/>`);if(X.inertia===!0){let ge=(X.isPipelineParent?wi/2:Ut)+10+(we?Ut+4:0);Ee+=`<rect class="pele-wardley-inertia" x="${f(le+ge)}" y="${f(de-Ut)}" width="4" height="${2*Ut}" fill="${zn}"/>`}let Te=X.labelOffsetX===void 0?void 0:go(X.labelOffsetX,-5e3,5e3),Me=X.labelOffsetY===void 0?void 0:go(X.labelOffsetY,-5e3,5e3),Ie;if(Ae){let ge=w.get(X)??I(X.label,o,s?Math.max(64,r/2):4e3,1);Ie=S(ge,le+(Te??0),de+(Me??-3),` class="pele-label" font-size="${o}" font-weight="var(--_hw)"`)}else{let ge=I(X.label,o),xe=` class="pele-label" font-size="${o}"`,ie=bL+(we?10:0);if(Te!==void 0||Me!==void 0)Ie=x(ge,le+(Te??ie),de+(Me??-ie),xe);else if(X.inPipeline)Ie=S(ge,le,de+2*Ut+4+ge.height/2,xe);else{let pe=D.get(V)??0,Re=(pe&1)===0?1:(pe&2)===0?2:(pe&4)===0?4:(pe&8)===0?8:1,be=Re===1||Re===2,Se=Re===1||Re===4;Ie=x(ge,be?le+ie:le-ie-ge.width,Se?de-ie:de+ie+o*.75,xe)}}b(le-2*Ut,de-2*Ut,le+2*Ut+20,de+2*Ut),W+=`<g class="pele-node pele-wardley-${Ae?"anchor":X.isPipelineParent?"pipeline-parent":X.inPipeline?"pipeline-component":"component"}" data-id="${We(X.id)}">${Ee}${Ie}</g>`}let Y="";for(let V of e.annotations){let X=I(String(V.number),c,4e3,1),le="";for(let de of V.coordinates){let Ae=L(de.x),we=O(de.y),Ee=Math.max(10,X.width/2+4);b(Ae-Ee,we-Ee,Ae+Ee,we+Ee),le+=`<circle cx="${f(Ae)}" cy="${f(we)}" r="${f(Ee)}" fill="var(--_bg)" stroke="${zn}"/>`+Ce(X,Ae,we,` font-size="${c}" font-weight="var(--_hw)"`)}Y+=`<g class="pele-wardley-annotation" data-id="${We(String(V.number))}">${le}</g>`}let ne=e.annotations.filter(V=>V.text).sort((V,X)=>V.number-X.number);if(ne.length>0){let V=ne.map(Me=>I(`${Me.number}. ${Me.text}`,o,s?Math.max(80,r-20):320)),X=0,le=0;for(let Me of V)X=Math.max(X,Me.width),le+=Me.height;X+=20,le+=14;let de=e.annotationsBox,Ae=de?go(L(de.x),0,Math.max(0,r-X)):0,we=de?go(O(de.y),0,Math.max(0,h-le)):_;b(Ae,we,Ae+X,we+le);let Ee="",Te=we+7;for(let Me of V)Ee+=C1(Me,Ae+10,Te+Me.lineHeight/2+o*.35,` font-size="${o}"`),Te+=Me.height;Y+=`<g class="pele-wardley-annotations"><rect x="${f(Ae)}" y="${f(we)}" width="${f(X)}" height="${f(le)}" fill="var(--_bg)" stroke="var(--_b)"${ft}/>${Ee}</g>`}let q="";for(let V of e.notes)q+=x(I(V.text,o,Math.min(360,r*.6),1),L(V.x),O(V.y),` class="pele-wardley-note" font-size="${o}" font-weight="var(--_hw)"`);let k="",J=(V,X,le,de)=>{let Ae=L(X),we=O(le),Ee=yL/2,Te=de?Ae+Ha:Ae,Me=de?Ae:Ae+Ha,Ie=de?Ae+Ha-M1:Ae+M1,ge=`M${f(Me)},${f(we-Ee)}H${f(Ie)}V${f(we-Ee-8)}L${f(Te)},${f(we)}L${f(Ie)},${f(we+Ee+8)}V${f(we+Ee)}H${f(Me)}Z`;b(Ae,we-Ee-8,Ae+Ha,we+Ee+8),k+=`<g class="pele-wardley-${de?"accelerator":"deaccelerator"}" data-id="${We(V)}"><path d="${ge}" fill="var(--_s)" stroke="${zn}"/>`+S(I(V,c+1,160,1),Ae+Ha/2,we+Ee+8+12,` font-size="${c+1}" font-weight="var(--_hw)"`)+"</g>"};for(let V of e.accelerators)J(V.name,V.x,V.y,!0);for(let V of e.deaccelerators)J(V.name,V.x,V.y,!1);let te=Ue(e.title,!1,l,a,s?Math.max(80,r):4e3,1),se=te.height>0?te.height+12:0,re=Math.min(m,r/2-te.width/2),P=Math.max(y,r/2+te.width/2),ee=u-re,ae=u+se-p,ue=Math.ceil(P-re+2*u),ce=Math.ceil(E-p+se+2*u),he=Ce(te,ee+r/2,u+te.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f(ee)},${f(ae)})"><g class="pele-wardley-frame" fill="none">${C}</g>`+Z+R+g+(B?`<g class="pele-edges" fill="none">${B}</g>`:"")+(F?`<g class="pele-wardley-trends" fill="none">${F}</g>`:"")+W+Y+q+k+"</g>";return{svg:ot("wardley",ue,ce,a,n,e,he),width:ue,height:ce,links:[]}}var k1={type:"wardley",section:"wardley-beta",parse:(e,t,n)=>A1(T1(e),n),render:I1};var jd=class{type="xychart";title;accTitle;accDescr;orientation;xAxis={type:"band",title:"",categories:[]};yAxis={type:"linear",title:"",min:1/0,max:-1/0};hasSetXAxis=!1;hasSetYAxis=!1;plots=[];setOrientation(t){this.orientation=t==="horizontal"?"horizontal":"vertical"}setXAxisTitle(t){this.xAxis.title=t.text.trim()}setXAxisRangeData(t,n){this.xAxis={type:"linear",title:this.xAxis.title,min:t,max:n},this.hasSetXAxis=!0}setXAxisBand(t){this.xAxis={type:"band",title:this.xAxis.title,categories:t.map(n=>n.text.trim())},this.hasSetXAxis=!0}setYAxisTitle(t){this.yAxis.title=t.text.trim()}setYAxisRangeData(t,n){this.yAxis={type:"linear",title:this.yAxis.title,min:t,max:n},this.hasSetYAxis=!0}plotData(t){if(t.length===0)return[];this.hasSetXAxis||this.setXAxisRangeData(1,t.length);let n=this.xAxis;if(n.type==="band"&&t.length>n.categories.length&&(t=t.slice(0,n.categories.length)),!this.hasSetYAxis){let{min:i,max:s}=this.yAxis;for(let a of t)a<i&&(i=a),a>s&&(s=a);this.yAxis={type:"linear",title:this.yAxis.title,min:i,max:s}}if(n.type==="band")return n.categories.map((i,s)=>[i,t[s]]);if(t.length===1)return[[`${n.min}`,t[0]]];let r=(n.max-n.min)/(t.length-1);return t.map((i,s)=>[`${n.min+s*r}`,i])}addPlot(t,n,r){let i={type:t,title:n.text.trim(),data:this.plotData(r.map(s=>s.value))};t==="line"&&r.some(s=>s.label.trim()!=="")&&(i.pointLabels=r.map(s=>s.label.trim())),this.plots.push(i)}setLineData(t,n){this.addPlot("line",t,n)}setBarData(t,n){this.addPlot("bar",t,n)}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
148
+ `)}};var zp=["$end","INVALID","NEWLINE","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","XYCHART","CHART_ORIENTATION","X_AXIS","Y_AXIS","ARROW_DELIMITER","LINE","BAR","NUMBER_WITH_DECIMAL","SQUARE_BRACES_START","SQUARE_BRACES_END","STR","ALPHA","COLON","PLUS","COMMA","EQUALS","MULT","BRKT","UNDERSCORE","DOT","AMP","MINUS","NUM","SEMI","EOF"];var $1=[33,33,33,33,33,19,5,7,8],L1="`)"+" ".repeat(36)+'{ this.pushstate(md_string); }\n<md_string>(?:(?!`").)+'+" ".repeat(18)+"{ return md_str; }\n<md_string>(?:`",Vp=new Uint8Array(128);for(let[e,t]of[[":",21],["+",22],[",",23],["=",24],["*",25],["#",26],["_",27],[".",28],["&",29],["-",30],[";",32]])Vp[e.charCodeAt(0)]=t;function O1(e){let t=e.length,n=[],r=[],i=[],s=[],a=0,o=0,c=(y,E,b)=>{n.push(y),r.push(e.slice(E,b)),i.push(E),o=b},l=y=>{s.push(a),a=y},u=()=>{s.length>0&&(a=s.pop())},h=y=>{let E=e.indexOf(`
149
+ `,y);return E===-1?t:E},d=y=>{for(;y<t&&Xe(e.charCodeAt(y));)y++;return y},m=y=>{for(;Et(e.charCodeAt(y));)y++;return y},p=y=>hn(e,o,y)&&!it(e.charCodeAt(o+y.length));for(;o<t;){let y=e.charCodeAt(o);if(a===5){if(y===34)o++,u();else{let b=e.indexOf('"',o);c(19,o,b===-1?t:b)}continue}if(a===6||a===7){c($1[a],o,h(o)),u();continue}if(a===8){if(y===125)o++,u();else{let b=e.indexOf("}",o);c(8,o,b===-1?t:b)}continue}let E=e.charCodeAt(o+1);if(y===37&&E===37){o=h(o+2);continue}if(y===10||y===13){if((a===1||a===3)&&(y===10||E===10)){c(2,o,y===10?o+1:o+2),u();continue}let b=o+1;for(let S=e.charCodeAt(b);S===10||S===13;S=e.charCodeAt(++b));c(2,o,b);continue}switch(y|32){case 116:if(p("title")){c(3,o,o+5);continue}break;case 97:if(hn(e,o,"acc")){let b=hn(e,o+3,"descr");if(b||hn(e,o+3,"title")){let S=d(o+8),x=e.charCodeAt(S);if(x===58){c(b?6:4,o,d(S+1)),l(b?7:6);continue}if(x===123&&b){o=d(S+1),l(8);continue}}}break;case 120:if(p("xychart-beta")){c(9,o,o+12);continue}if(p("xychart")){c(9,o,o+7);continue}if(p("x-axis")){c(11,o,o+6),l(1);continue}break;case 121:if(p("y-axis")){c(12,o,o+6),l(1);continue}break;case 118:if(hn(e,o,"vertical")){c(10,o,o+8);continue}break;case 104:if(hn(e,o,"horizontal")){c(10,o,o+10);continue}break;case 108:if(p("line")){c(14,o,o+4),l(3);continue}break;case 98:if(p("bar")){c(15,o,o+3),l(3);continue}break}if(y===91){a===1?l(2):a===3&&l(4),c(17,o,o+1);continue}if(y===93){(a===4||a===2)&&u(),c(18,o,o+1);continue}if(a===1&&y===45&&E===45&&e.charCodeAt(o+2)===62){c(13,o,o+3);continue}if(a===1||a===4){let b=y===43||y===45?o+1:o,S=e.charCodeAt(b),x=-1;if(Et(S)?(x=m(b+1),e.charCodeAt(x)===46&&Et(e.charCodeAt(x+1))&&(x=m(x+2))):S===46&&Et(e.charCodeAt(b+1))&&(x=m(b+2)),x!==-1){c(16,o,x);continue}}if(y===96&&hn(e,o,L1)){o+=L1.length,u();continue}if(y===34){o++,l(5);continue}if(zr(y)){let b=o+1;for(;zr(e.charCodeAt(b));)b++;c(20,o,b);continue}if(Et(y)){c(31,o,m(o+1));continue}if(Xe(y)){o=d(o+1);continue}if(y<128&&Vp[y]!==0){c(Vp[y],o,o+1);continue}break}return o<t?(n.push(1),r.push(""),i.push(o),{types:n,texts:r,starts:i}):(n.push($1[a]),r.push(""),i.push(t),n.push(0),r.push(""),i.push(t),{types:n,texts:r,starts:i})}function P1(...e){let t=new Uint8Array(34);for(let n of e)t[n]=1;return t}var D1=P1(29,31,20,22,24,25,28,26,30,27),v1=P1(2,32,33);function F1(e,t){let{types:n,texts:r,starts:i}=O1(e),s=0,a=d=>{let m=n[s];throw m===1?ut("xychart",e,i[s],"",!0):ut("xychart",e,i[s],`Expecting ${d}, got '${zp[m]}'`)},o=d=>(n[s]!==d&&a(`'${zp[d]}'`),r[s++]),c=d=>d===19||D1[d]===1,l=()=>{c(n[s])||a("'STR', 'ALPHA', 'NUM'");let d=r[s++];if(n[s-1]!==19)for(;D1[n[s]]===1;)d+=r[s++];return{text:d,type:"text"}},u=()=>{let d=Number(o(16));return o(13),[d,Number(o(16))]},h=()=>{let d=[];for(o(17);;){let m=Number(o(16));if(d.push({value:m,label:n[s]===19?r[s++]:""}),n[s]!==23)break;s++}return o(18),d};for(;;)if(v1[n[s]]===1)s++;else{if(n[s]!==9)break;n[++s]===10&&t.setOrientation(r[s++])}for(;n[s]!==0;){let d=n[s++];switch(d){case 3:t.setDiagramTitle(l().text.trim());break;case 11:case 12:{let m=c(n[s])?l():void 0;if(d===11&&n[s]===17){let p=[];do s++,p.push(l());while(n[s]===23);o(18),t.setXAxisBand(p)}else if(n[s]===16||m===void 0){let[p,y]=u();d===11?t.setXAxisRangeData(p,y):t.setYAxisRangeData(p,y)}d===11?t.setXAxisTitle(m??{type:"text",text:""}):t.setYAxisTitle(m??{type:"text",text:""});break}case 14:case 15:{let m=n[s]===17?{text:"",type:"text"}:l(),p=h();d===14?t.setLineData(m,p):t.setBarData(m,p);break}case 4:t.setAccTitle(o(5).trim());break;case 6:t.setAccDescription(o(7).trim());break;case 8:t.setAccDescription(r[s-1].trim());break;default:s--,a("'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'")}for(;v1[n[s]]===1;)s++}}function jp(e,t){let n=e/Math.max(t,1),r=Math.floor(Math.log10(n)),i=n/10**r,s=i>=7.07?10:i>=3.16?5:i>=1.41?2:1;return r<0?-(10**-r)/s:s*10**r}function Ka(e,t){return e>0?t/e:t*-e}function bo(e,t){return e>0?t*e:t/-e}function Xp(e,t,n){let r=Math.round(Ka(n,e));bo(n,r)<e&&r++;let i=Math.round(Ka(n,t));bo(n,i)>t&&i--;let s=[];for(let a=r;a<=i&&s.length<100;a++)s.push(bo(n,a));return s}var B1=4,yo=12,W1=26,U1=24,G1=1e300;function qp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function sr(e,t,n=!0){let r=e[t];return typeof r=="boolean"?r:n}function Y1(e,t){return typeof e=="number"&&e>0?Math.round(Math.min(Math.max(e,100),4e3)):t}function Fs(e){return typeof e=="number"&&isFinite(e)?Math.min(Math.max(e,-G1),G1):void 0}function AL(e){let t=0;for(let n of e)t=Math.max(t,n.label.width);return t}function Xd(e,t,n,r){let i=e.lines.length===1?e.lines[0]:void 0;return i&&i.length===1&&i[0].icon===void 0&&i[0].style===0?`<text x="${f(t)}" y="${f(n+e.size*.35)}" text-anchor="${r}">${nt(i[0].text)}</text>`:Ce(e,t+(r==="start"?e.width/2:r==="end"?-e.width/2:0),n,"")}function H1(e,t,n){if(e.plots.length===0)throw new qe("No Plot to render, please provide a plot with some data","semantic",{type:"xychart"});let r=qp(t.xyChart),i=n.fontSize??16,s=Math.round(i*.875),a=Math.round(i*.75),o=n.measurer??at(n.fontFamily,n.fontFamilyMono),c=n.padding??8,l=Y1(r.width,700),u=ms(n,l,240),h=Math.round(Y1(r.height,500)*Math.max(.6,u/l)),d=(e.orientation??r.chartOrientation)==="horizontal",m=sr(r,"showDataLabel",!1),p=e.xAxis,y=e.plots,E=(ke,Qe,et)=>Ue(ke,!1,o,Qe,et),b=E("0",s,4e3).height,S=E("0",a,4e3).height,x=Ue(sr(r,"showTitle")?e.title:void 0,!1,o,i,u-2*c,1),I=x.height>0?x.height+12:0,L=[],O=0;sr(r,"showLegend")&&y.forEach((ke,Qe)=>{if(ke.title==="")return;let et=E(ke.title,s,u*.3);L.push({index:Qe,label:et}),O=Math.max(O,et.width+yo+8)});let v=L.length>0?O+U1:0,G=y.filter(ke=>ke.type==="bar").length,K=Fs(e.yAxis.min)??1/0,C=Fs(e.yAxis.max)??-1/0,Z=e.hasSetYAxis&&isFinite(K)&&isFinite(C)&&K!==C;if(!Z){K=1/0,C=-1/0;for(let ke of y)for(let[,Qe]of ke.data){let et=Fs(Qe);et!==void 0&&(et<K&&(K=et),et>C&&(C=et))}K>C&&(K=C=0),G>0&&(K=Math.min(K,0),C=Math.max(C,0)),K===C&&(K===0?C=1:(K-=Math.abs(K)/2,C+=Math.abs(C)/2))}let oe=(ke,Qe)=>{let et=jp(Math.abs(C-K),Math.max(2,Math.min(10,Math.floor(ke/Qe))));return Z||(K=bo(et,Math.floor(Ka(et,K)+1e-9)),C=bo(et,Math.ceil(Ka(et,C)-1e-9))),Xp(Math.min(K,C),Math.max(K,C),et).map(pt=>({at:(pt-K)/(C-K),label:E(String(pt),s,4e3)}))},H=1;if(p.type==="band")H=Math.max(p.categories.length,1);else for(let ke of y)H=Math.max(H,ke.data.length);let z=1/H,M=p.type==="band"||G>0?z/2:0,T=Fs(p.type==="linear"?p.min:void 0),R=Fs(p.type==="linear"?p.max:void 0),_=T!==void 0&&R!==void 0&&T!==R,$=(ke,Qe)=>p.type==="band"?(ke+.5)*z:M+(Qe>1?ke/(Qe-1):_?0:.5)*(1-2*M),g=qp(r.xAxis),N=qp(r.yAxis),w=d?g:N,A=d?N:g,D=E(sr(w,"showTitle")?d?p.title:e.yAxis.title:void 0,s,h*.8),U=E(sr(A,"showTitle")?d?e.yAxis.title:p.title:void 0,s,u*.8),B=sr(w,"showTick")?B1:0,F=sr(A,"showTick")?B1:0,W=sr(w,"showLabel"),j=sr(A,"showLabel"),Q=d?u*.3:Math.max(48,(u-2*c-64-v)*z-8),Y=p.type==="band"&&sr(g,"showLabel")?p.categories.map(ke=>E(ke,s,Q)):[],ne=0,q=0;for(let ke of Y)ne=Math.max(ne,ke.width),q=Math.max(q,ke.height);let k=ke=>{let Qe=[];if(p.type==="band"){let et=Y.length===0?8:d?q:ne+12,pt=Math.max(1,Math.ceil(et/(ke*z)));for(let lt=0;lt<p.categories.length;lt+=pt)Qe.push({at:(lt+.5)*z,label:Y[lt]??E(void 0,s,0)})}else if(_){let et=jp(Math.abs(R-T),Math.max(2,Math.min(10,Math.floor(ke/(d?32:80)))));for(let pt of Xp(Math.min(T,R),Math.max(T,R),et))Qe.push({at:M+(pt-T)/(R-T)*(1-2*M),label:E(String(pt),s,4e3)})}else T!==void 0&&Qe.push({at:.5,label:E(String(T),s,4e3)});return Qe},J=0,te=0;for(let ke of y){for(let Qe of ke.pointLabels??[])J=Math.max(J,o.width(Qe,a,0));if(m&&d&&ke.type==="bar")for(let[,Qe]of ke.data)te=Math.max(te,o.width(String(Fs(Qe)??""),a,0))}let se=j?d||p.type!=="band"?b:q:0,re=F+(se>0?se+4:0)+(U.height>0?U.height+4:0),P=d?0:J>0||m?S+4:W?b/2:0,ee=c+I+P,ae=Math.max(1,h-c-re-ee),ue=ee+ae,ce=d?k(ae):oe(ae,56),he=W?AL(ce):0,V=c+(D.height>0?D.height+6:0)+(he>0?he+6:0)+B,X=Math.max(J>0?J+12:0,te>0?te+8:0),le=d?Math.min(u*.25,X):0,de=Math.max(1,u-c-V-v-le),Ae=d?oe(de,80):k(de);if(j&&v+le===0){let ke=0;for(let Qe of Ae)ke=Math.max(ke,Qe.at*de+Qe.label.width/2-de);de=Math.max(1,de-ke)}let we=V+de,Ee=(ke,Qe)=>d?V+Qe*de:V+ke*de,Te=(ke,Qe)=>d?ee+ke*ae:ue-Qe*ae,Me=ke=>(ke-K)/(C-K),Ie=ke=>Math.min(Math.max(ke,0),1),ge=ke=>d?`M${f(Ee(0,ke))},${f(ee)}V${f(ue)}`:`M${f(V)},${f(Te(0,ke))}H${f(we)}`,xe="";for(let ke of d?Ae:ce)xe+=ge(ke.at);let ie="",pe="";sr(w,"showAxisLine")&&(ie+=`M${f(V)},${f(ee)}V${f(ue)}`),sr(A,"showAxisLine")&&(ie+=`M${f(V)},${f(ue)}H${f(we)}`);for(let ke of ce){let Qe=d?ee+ke.at*ae:ue-ke.at*ae;B&&(ie+=`M${f(V)},${f(Qe)}h${-B}`),W&&(pe+=Xd(ke.label,V-B-6,Qe,"end"))}for(let ke of Ae){let Qe=V+ke.at*de;F&&(ie+=`M${f(Qe)},${f(ue)}v${F}`),j&&(pe+=Xd(ke.label,Qe,ue+F+4+ke.label.height/2,"middle"))}let Re=(d?ae:de)*z,Se=Re*.7/Math.max(G,1),Ne=G>1?Math.min(2,Se*.2):0,De=Ie(Me(0));G>0&&De>0&&De<1&&(ie+=ge(De));let ve="",fe="",_e="",Fe="",me=0;y.forEach((ke,Qe)=>{let et=yt(Qe),pt=ke.title?` data-id="${We(ke.title)}"`:"",lt=p.type==="band"?Math.min(ke.data.length,H):ke.data.length;if(ke.type==="bar"){let Je=(me++-(G-1)/2)*Se-(Se-Ne)/2,Ge="";for(let Ye=0;Ye<lt;Ye++){let tt=Fs(ke.data[Ye][1]);if(tt===void 0)continue;let st=$(Ye,lt),St=Ie(Me(tt)),dt=Math.min(De,St),rt=Math.max(De,St),ht=d?Ee(st,dt):Ee(st,0)+Je,mt=d?Te(st,0)+Je:Te(st,rt),bt=d?(rt-dt)*de:Se-Ne,Ct=d?Se-Ne:(rt-dt)*ae;if(Ge+=`<rect x="${f(ht)}" y="${f(mt)}" width="${f(bt)}" height="${f(Ct)}"/>`,!m)continue;let Pt=String(tt),Vn=o.width(Pt,a,0),yn=St>=De?1:-1,Ar=ht+bt/2,on=mt+Ct/2,an="middle";if(d){if(Ct<a)continue;Ar=(yn>0?ht+bt:ht)+yn*6,an=yn>0?"start":"end"}else{if(Vn+2>Re/G)continue;on=(yn>0?mt:mt+Ct)-yn*(S/2+2)}_e+=`<text x="${f(Ar)}" y="${f(on+a*.35)}" text-anchor="${an}">${Pt}</text>`}ve+=`<g class="pele-series pele-bars"${pt} fill="${et}">${Ge}</g>`;return}let ye="",Be="",Oe=!1,je=0,Ke=NaN;for(let Je=0;Je<lt;Je++){let Ge=Fs(ke.data[Je][1]);if(Ge===void 0){Ke=NaN;continue}let Ye=$(Je,lt),tt=Me(Ge),st=tt>=0&&tt<=1;if(Ke!==Ke)st&&(ye+=`M${f(Ee(Ye,tt))},${f(Te(Ye,tt))}`),Oe=st;else{let ht=tt-Ke,mt=0,bt=1;if(ht!==0){let Ct=-Ke/ht,Pt=(1-Ke)/ht;mt=Math.max(mt,Math.min(Ct,Pt)),bt=Math.min(bt,Math.max(Ct,Pt))}else st||(mt=2);if(mt<=bt){let Ct=je+(Ye-je)*mt,Pt=Ke+ht*mt,Vn=je+(Ye-je)*bt,yn=Ke+ht*bt;(!Oe||mt>0)&&(ye+=`M${f(Ee(Ct,Pt))},${f(Te(Ct,Pt))}`),ye+=`L${f(Ee(Vn,yn))},${f(Te(Vn,yn))}`}Oe=st}if(je=Ye,Ke=tt,!st)continue;let St=Ee(Ye,tt),dt=Te(Ye,tt);Re>=12&&(Be+=`<circle cx="${f(St)}" cy="${f(dt)}" r="3"/>`);let rt=E(ke.pointLabels?.[Je],a,4e3);if(rt.height>0){let ht=rt.width/2;Fe+=d?Xd(rt,St+10,dt,"start"):Xd(rt,Math.max(Math.min(St,we-ht),V+ht),dt-6-rt.height/2,"middle")}}fe+=`<g class="pele-series pele-line"${pt} fill="${et}">`+(ye?`<path d="${ye}" fill="none" stroke="${et}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:"")+Be+"</g>"});let $e="";D.height>0&&($e+=`<g transform="translate(${f(c+D.height/2)},${f(ee+ae/2)}) rotate(-90)">${Ce(D,0,0,"")}</g>`),$e+=Ce(U,V+de/2,h-c-U.height/2,"");let Pe="",ze=0;for(let ke of L)ze+=Math.max(W1,ke.label.height+6);let Le=ee+Math.max(0,(ae-ze)/2),Ve=we+le+U1;for(let{index:ke,label:Qe}of L){let et=Math.max(W1,Qe.height+6);if(Le+et>h)break;let pt=Le+et/2,lt=yt(ke);Pe+=`<g class="pele-legend-item" data-id="${We(y[ke].title)}">`+(y[ke].type==="bar"?`<rect x="${f(Ve)}" y="${f(pt-yo/2)}" width="${yo}" height="${yo}" rx="2" fill="${lt}"/>`:`<path d="M${f(Ve)},${f(pt)}h${yo}" stroke="${lt}" stroke-width="2" stroke-linecap="round"/>`)+Ce(Qe,Ve+yo+8+Qe.width/2,pt,"")+"</g>",Le+=et}let Ze=Ce(x,u/2,c+x.height/2,' class="pele-title" font-weight="var(--_tw)"')+(xe?`<path class="pele-grid" d="${xe}" stroke="var(--_a)"/>`:"")+`<g class="pele-plot">${ve}${fe}</g>`+(ie?`<path class="pele-axis" d="${ie}" fill="none" stroke="var(--_b)"/>`:"")+(pe?`<g class="pele-axis-labels" font-size="${s}" fill="var(--_m)">${pe}</g>`:"")+($e?`<g class="pele-axis-titles" font-size="${s}">${$e}</g>`:"")+(_e?`<g class="pele-data-labels" font-size="${a}">${_e}</g>`:"")+(Fe?`<g class="pele-point-labels" font-size="${a}">${Fe}</g>`:"")+(Pe?`<g class="pele-legend" font-size="${s}">${Pe}</g>`:"");return{svg:ot("xychart",u,h,i,n,e,Ze),width:u,height:h,links:[]}}var K1={type:"xychart",section:"xyChart",parse(e,t,n){let r=new jd;return r.title=n,F1(e,r),r},render:H1};var z1=[ml,M0,Cy,m0,o0,zA,e0,Qb,F0,K1,NA,SE,rb,Dx,Vx,x0,q0,ES,WE,gA,OE,Fb,Ab,Sx,Gg,aS,uy,k1,By,u1,y1,VE,FA];Lm(...z1);export{qe as PeleError,x_ as detectType,i_ as enableZoom,du as forgetTextWidths,oO as mount,A_ as parse,Lm as register,sO as registered,S_ as render,iO as supports};