~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/knotless

git that lives in your Atmosphere account

Forked from chadtmiller.com/knotless

0
0
147 lines · 683.3 KB Raw History
/*! Pele 1.8.0 | MIT License | https://github.com/obsidianmd/pele */
"use strict";var pele=(()=>{var ca=Object.defineProperty;var bS=Object.getOwnPropertyDescriptor;var yS=Object.getOwnPropertyNames;var ES=Object.prototype.hasOwnProperty;var AS=(e,t,n)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var xS=(e,t)=>{for(var n in t)ca(e,n,{get:t[n],enumerable:!0})},SS=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of yS(t))!ES.call(e,o)&&o!==n&&ca(e,o,{get:()=>t[o],enumerable:!(r=bS(t,o))||r.enumerable});return e};var _S=e=>SS(ca({},"__esModule",{value:!0}),e);var de=(e,t,n)=>AS(e,typeof t!="symbol"?t+"":t,n);var pk={};xS(pk,{PeleError:()=>ze,detectType:()=>uh,enableZoom:()=>ih,forgetTextWidths:()=>ma,mount:()=>S1,parse:()=>fh,register:()=>Ad,registered:()=>g1,render:()=>ph,supports:()=>x1});var wS=[["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 od(e){for(let[t,n,r]of wS)if(r.test(e))return{type:t,mermaidType:n};return null}var ze=class extends Error{constructor(n,r="syntax",o={}){super(n);de(this,"code");de(this,"type");de(this,"mermaidType");de(this,"line");de(this,"column");de(this,"snippet");this.name="PeleError",this.code=r,this.type=o.type??null,this.mermaidType=o.mermaidType??null,this.line=o.line??0,this.column=o.column??0,this.snippet=o.snippet??""}};function Vi(e,t){let n=1,r=0;for(let i=e.indexOf(`
`);i!==-1&&i<t;i=e.indexOf(`
`,i+1))n++,r=i+1;let o=e.indexOf(`
`,t);o===-1&&(o=e.length);let s=t-r+1,a=e.slice(r,o);return{line:n,column:s,snippet:a+`
`+"-".repeat(s-1)+"^"}}function st(e,t,n,r,o=!1){let s=Vi(t,n),a=o?`Lexical error on line ${s.line}. Unrecognized text.`:`Parse error on line ${s.line}:`,i=o?`${a}
${s.snippet}`:`${a}
${s.snippet}
${r}`;return new ze(i,"syntax",{type:e,...s})}var RS="amp:38,lt:60,gt:62,quot:34,apos:39,nbsp:160,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",la;function TS(e){if(!la){la=new Map;for(let t of RS.split(",")){let n=t.indexOf(":");la.set(t.slice(0,n),String.fromCodePoint(Number(t.slice(n+1))))}}return la.get(e)}function Gp(e,t){return e>0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint(e):t}var CS=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|(\w+));/g,Yp="fl°",NS="¶ß";function MS(e){let t="",n=0,r=e.indexOf(Yp);for(;r!==-1;){let o=e.indexOf("¶",r+2);if(o===-1)break;if(e[o+1]==="ß"){let s=e[r+2]==="°";t+=e.slice(n,r)+(s?"&#":"&")+e.slice(r+(s?3:2),o)+";",n=o+2}r=e.indexOf(Yp,o+1)}return n===0?e:t+e.slice(n)}function yt(e){return e.includes(NS)&&(e=MS(e)),e.includes("&")&&(e=e.replace(CS,(t,n,r,o)=>n?Gp(Number(n),t):r?Gp(parseInt(r,16),t):TS(o)??t)),e}var ji,Xi=new Map;function Hp(e,t){let n=ji,r=Xi;ji=e,Xi=new Map;try{return t()}finally{ji=n,Xi=r}}function ni(e){if(ji===void 0)return"";let t=Xi.get(e);return t===void 0&&(t=ji(e)??"",Xi.set(e,t)),t}var or,ri=new Map;function zp(e,t){let n=or,r=ri;or=e,ri=new Map;try{return t()}finally{or=n,ri=r}}function Vp(){return or!==void 0}function Kp(e){return Number.isFinite(e)&&e>0}function jp(e,t){if(or===void 0)return;let n=t+`
`+e;if(ri.has(n))return ri.get(n);let r=or(e,t)??void 0,o=r&&Kp(r.width)&&Kp(r.height)&&typeof("svg"in r?r.svg:r.html)=="string"?r:void 0;return ri.set(n,o),o}function Xp(e){if(or===void 0)return e();let t=or;or=void 0;try{return e()}finally{or=t}}var Ur=class{constructor(t){de(this,"message",t)}},Zp=64;function da(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var ld=class{constructor(t){de(this,"lines");de(this,"i",0);this.lines=(t.includes("\r")?t.replace(/\r\n?/g,`
`):t).split(`
`)}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}},IS=/^[-+]?(?:0|[1-9][0-9]*)$/,kS=/^[-+]?0x[0-9a-fA-F]+$/,LS=/^[-+]?0o[0-7]+$/,$S=/^[-+]?0b[01]+$/,DS=/^[-+]?(?:[0-9][0-9]*(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/,OS=/[\s#:,[\]{}&*!|>'"%@`]/;function qi(e){return e===" "||e==="	"||e===`
`||e==="\r"}function ad(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;qi(e[r]);)r++;if(e[r]!==":")return null}else{if(t===void 0||OS.test(t)||t==="-"&&(e.length<2||qi(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;qi(e[n-1]);)n--}let o=r+1;if(o<e.length&&!qi(e[o]))return null;for(;qi(e[o]);)o++;return{key:e.slice(0,n),length:o}}function dd(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(IS.test(t)||DS.test(t))return Number(t);if(kS.test(t)||LS.test(t)||$S.test(t)){let r=t[0]==="-",o=Number(r||t[0]==="+"?t.slice(1):t);return r?-o:o}return/^[-+]?\.(?:inf|Inf|INF)$/.test(t)?t[0]==="-"?-1/0:1/0:/^\.(?:nan|NaN|NAN)$/.test(t)?NaN:t}var qp={0:"\0",a:"\x07",b:"\b",t:"	",n:`
`,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"…",_:" ",L:"\u2028",P:"\u2029"};function Qi(e){if(!e.includes(`
`))return e;let t=e.split(`
`),n=t.length-1;for(let r=0;r<=n;r++){let o=t[r],s=0,a=o.length;if(r>0)for(;s<a&&(o.charCodeAt(s)===32||o.charCodeAt(s)===9);)s++;if(r<n)for(;a>s&&(o.charCodeAt(a-1)===32||o.charCodeAt(a-1)===9);)a--;t[r]=o.slice(s,a)}return t.join(`
`).replace(/\n+/g,r=>r.length===1?" ":`
`.repeat(r.length-1))}function vS(e){if(!e.includes("\\"))return Qi(e);let t="",n=Qi(e.replace(/\\\n[ \t]*/g,""));for(let r=0;r<n.length;r++){let o=n[r];if(o!=="\\"){t+=o;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 qp)t+=qp[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===`
`||r==="	"||r==="\r"||n&&r===",")t++;else if(r==="#"&&(t===0||/\s/.test(e[t-1]))){let o=e.indexOf(`
`,t);t=o===-1?e.length:o}else break}return t}function Qp(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 si(e,t,n,r=0){if(r>Zp)throw new Error("YAML: nesting is too deep");t=bs(e,t,!1);let o=e[t];if(o==="{"){let a={};t++;let i=!0;for(;;){if(t=bs(e,t,!1),t>=e.length)throw new Ur("YAML: unexpected end of the stream within a flow collection");if(e[t]==="}")return[a,t+1];Qp(e[t],i);let c;[c,t]=si(e,t,":,}",r+1),t=bs(e,t,!1);let l=null;e[t]===":"&&([l,t]=si(e,t+1,",}",r+1)),da(a,String(c),l),t=bs(e,t,!1),i=e[t]===",",i&&t++}}if(o==="["){let a=[];t++;let i=!0;for(;;){if(t=bs(e,t,!1),t>=e.length)throw new Ur("YAML: unexpected end of the stream within a flow collection");if(e[t]==="]")return[a,t+1];Qp(e[t],i);let c;[c,t]=si(e,t,",]",r+1),a.push(c),t=bs(e,t,!1),i=e[t]===",",i&&t++}}if(o==='"'){let a=t+1;for(;a<e.length&&e[a]!=='"';)a+=e[a]==="\\"?2:1;if(a>=e.length)throw new Ur("YAML: unexpected end of the stream within a double quoted scalar");return[vS(e.slice(t+1,a)),a+1]}if(o==="'"){let a=t+1;for(;a<e.length;){if(e[a]==="'"){if(e[a+1]!=="'")break;a++}a++}if(a>=e.length)throw new Ur("YAML: unexpected end of the stream within a single quoted scalar");return[Qi(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 i=e.indexOf(`
`,s);return[dd(Qi(e.slice(t,s).trim())),i===-1?e.length:i]}s++}return[dd(Qi(e.slice(t,s).trim())),s]}function Zi(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 PS(e,t,n){let r=t[0]===">",o=t.includes("-")?"-":t.includes("+")?"+":"",s=/[1-9]/.exec(t),a=s?n+Number(s[0]):-1,i=[];for(;e.i<e.lines.length;){let f=e.lines[e.i];if(f.trim()===""){i.push(""),e.i++;continue}let p=f.length-f.trimStart().length;if(a===-1){if(p<=n)break;a=p}if(p<a)break;i.push(f.slice(a)),e.i++}let c=0;for(;i.length>0&&i[i.length-1]==="";)i.pop(),c++;let l;if(r){l="";for(let f=0;f<i.length;f++){let p=i[f];if(f>0){let u=i[f-1];p===""?l+=`
`:u!==""&&(l+=/^[ \t]/.test(u)||/^[ \t]/.test(p)?`
`:" ")}l+=p}}else l=i.join(`
`);return i.length===0?o==="+"?`
`.repeat(c):"":o==="-"?l:o==="+"?l+`
`.repeat(c+1):l+`
`}function cd(e,t,n){let r=t[0];if((r==="|"||r===">")&&/^[|>][-+0-9]*\s*(?:#.*)?$/.test(t))return PS(e,t,n);if(r==="{"||r==="["||r==='"'||r==="'"){let s=e.i,a=t,i=0,c=1;for(;;)try{let[l,f]=si(a,0,""),p=0;for(let m=a.indexOf(`
`);m!==-1&&m<f;m=a.indexOf(`
`,m+1))p++;let u=a.indexOf(`
`,f);if(Zi(a.slice(f,u===-1?a.length:u)).trim()!=="")throw new Error("YAML: unexpected content after a value");return e.i=s+p,l}catch(l){if(!(l instanceof Ur))throw l;if(s+i>=e.lines.length)throw new Error(l.message);let f=e.lines.slice(s+i,s+i+c);a+=`
`+f.join(`
`),i+=f.length,c*=2}}let o=Zi(t).trim();for(;e.i<e.lines.length;){let s=e.lines[e.i];if(s.trim()===""){let i=e.i;for(;i<e.lines.length&&e.lines[i].trim()==="";)i++;if(i>=e.lines.length||e.lines[i].length-e.lines[i].trimStart().length<=n)break;o+=`
`.repeat(i-e.i),e.i=i;continue}if(s.length-s.trimStart().length<=n)break;let a=Zi(s).trim();o+=(o.endsWith(`
`)?"":" ")+a,e.i++}return dd(o)}function ua(e,t,n=0){if(n>Zp)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 o=e.lines[e.i].slice(r);if(o==="-"||o.startsWith("- ")){let a=[];for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length||e.indent()!==r));){let i=e.lines[e.i].slice(r);if(i!=="-"&&!i.startsWith("- "))break;let c=i.slice(1),l=c.length-c.trimStart().length+1,f=Zi(c).trim();f===""?(e.i++,a.push(ua(e,r+1,n+1))):ad(f)!==null?(e.lines[e.i]=" ".repeat(r+l)+c.trimStart(),a.push(ua(e,r+l,n+1))):(e.i++,a.push(cd(e,c.trim(),r)))}return a}if(ad(o)===null)return e.i++,cd(e,o.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 i=e.lines[e.i].slice(r),c=ad(i);if(!c)throw new Error("YAML: can not read a block mapping entry");let l=String(si(c.key,0,"")[0]),f=i.slice(c.length);if(e.i++,Zi(f).trim()==="")if(e.skipBlank(),e.i<e.lines.length){let p=e.indent(),u=e.lines[e.i].slice(p),m=u==="-"||u.startsWith("- ");da(s,l,p>r||m&&p===r?ua(e,m?r:r+1,n+1):null)}else da(s,l,null);else da(s,l,cd(e,f.trim(),r))}return s}function Vn(e){let t=e.trim();if(t[0]==="{"||t[0]==="[")try{let[o,s]=si(t,0,"");if(bs(t,s,!1)===t.length)return o}catch(o){throw o instanceof Ur?new Error(o.message):o}let n=new ld(e),r=ua(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 He(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 Bn(e){return e===32||e===9}function ys(e){return e===10||e===13||e===8232||e===8233}function ft(e){return e>=48&&e<=57}function Rr(e){return e>=65&&e<=90||e>=97&&e<=122}function fa(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Qe(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95}var BS=/^\s*%%(?!{)[^\n]+\n?/gm,ii=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,FS=/<(\w+)([^>]*)>/g,WS=/="([^"]*)"/g,US=new Set(["__proto__","constructor","prototype"]);function GS(e){return(e.includes("%%")?e.replace(BS,""):e).trimStart()}function pa(e){return e===`
`||e==="\r"}function ud(e){return e!==void 0&&/\s/.test(e)}function YS(e){let t=0;for(;t<e.length&&ud(e[t])&&!pa(e[t]);)t++;let n=e.slice(0,t);if(!e.startsWith("---",t))return;let r=[];for(let p=t+3;p<e.length&&ud(e[p]);p++)pa(e[p])&&r.push(p);if(r.length===0)return;let o=n+"---",s=p=>{if(!pa(e[p])||!e.startsWith(o,p+1))return-1;let u=-1;for(let m=p+1+o.length;m<e.length&&ud(e[m]);m++)pa(e[m])&&(u=m);return u},a=`
`+o,i=-1;for(let p=e.lastIndexOf(a);p>r[0];p=e.lastIndexOf(a,p-1))if(s(p)!==-1){i=p;break}if(i===-1)return;let c=r[0];for(let p of r)p<i&&(c=p);let l=c+1,f=l>0?l-1:0;for(let p=e.indexOf(a,f);p!==-1&&p<=i;p=e.indexOf(a,p+1)){if(p<l)continue;let u=s(p);if(u!==-1)return{indent:n,body:e.slice(l,p),length:u+1}}}function Es(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ha(e,t){for(let n of Object.keys(t)){if(US.has(n))continue;let r=t[n],o=e[n];Es(r)&&Es(o)?ha(o,r):Es(r)?e[n]=ha({},r):e[n]=r}return e}function HS(e,t){if(!e.includes("%%{"))return e;let n=e.trim().replace(/'/g,'"');ii.lastIndex=0;let r;for(;(r=ii.exec(n))!==null;){r.index===ii.lastIndex&&ii.lastIndex++;let o=r[1]??r[2];if(o==="wrap")t.wrap=!0;else if((o==="init"||o==="initialize")&&r[4])try{let s=JSON.parse(r[4].trim());Es(s)&&ha(t,s)}catch{}}return ii.lastIndex=0,e.replace(ii,"")}function pd(e){let t=e.includes("\r")?e.replace(/\r\n?/g,`
`):e,n=t.includes("<")?t.lastIndexOf(">"):-1;n>0&&(t=t.slice(0,n+1).replace(FS,(i,c,l)=>"<"+c+l.replace(WS,"='$1'")+">")+t.slice(n+1));let r={},o,s=0,a=t.includes("---")?YS(t):void 0;if(a){let i=a.indent?a.body.split(`
`).map(l=>l.startsWith(a.indent)?l.slice(a.indent.length):l).join(`
`):a.body,c;try{c=Vn(i)}catch(l){throw new ze(`Front matter is not valid YAML. ${l.message}`,"syntax")}if(Es(c)&&(c.title&&(o=String(c.title)),Es(c.config)&&ha(r,c.config),c.displayMode)){let l=Es(r.gantt)?r.gantt:r.gantt={};l.displayMode=String(c.displayMode)}for(let l=t.indexOf(`
`);l!==-1&&l<a.length;l=t.indexOf(`
`,l+1))s++;t=t.slice(a.length)}return t=HS(t,r),{text:GS(t),title:o,config:r,withComments:t,lineOffset:s}}var KS=/#\w+;/g,zS=/^\+?\d+$/,fd=new RegExp("[\\n\\r\u2028\u2029]","g");function Jp(e,t){let n=e.indexOf(t);if(n===-1)return e;let r="",o=0;for(;n!==-1;){fd.lastIndex=n;let s=fd.test(e)?fd.lastIndex-1:e.length,a=!1,i=-1;for(let c=n+t.length;c<s;c++){let l=e.charCodeAt(c);if(l===58)a=!0;else if(l===35){if(a){i=c;break}}else He(l)&&(a=!1)}if(i!==-1){let c=e.lastIndexOf(";",s-1);c>i&&(r+=e.slice(o,c),o=c+1)}n=s>=e.length?-1:e.indexOf(t,s+1)}return o===0?e:r+e.slice(o)}function eh(e){return e.includes("#")?Jp(Jp(e,"style"),"classDef").replace(KS,t=>{let n=t.substring(1,t.length-1);return(zS.test(n)?"fl°°":"fl°")+n+"¶ß"}):e}var th="7q7q9vfgfgopij5b9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg7q7qg8g8g8fgs7ijijk2k2ijgzlmk27qdwijfgn5k2lmijlmk2ijgzk2ijq8ijijgz7q7q7qd1fg99fgfgdwfgfg7qfgfg6666dw66n5fgfgfgfg99dw7qfgdwk2dwdwdw9a789ag8",nh="7q99d6fgfgopk26m9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg9999g8g8g8gzr3k2k2k2k2ijgzlmk27qfgk2gzn5k2lmijlmk2ijgzk2ijq8ijijgz997q99g8fg99fggzfggzfg99gzgz7q7qfg7qopgzgzgzgzatfg99gzfglmfgfgdwat7satg8";function rh(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 VS,jS;function XS(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 qS(e){return e>=768&&e<=879||e>=8203&&e<=8207||e>=56320&&e<=57343||e>=65024&&e<=65039||e===65279}var QS={width(e,t,n){let r=(n&4)!==0,o=n&1?jS??=rh(nh):VS??=rh(th),s=0;for(let a=0;a<e.length;a++){let i=e.charCodeAt(a);if(!(i<32))if(i<127)s+=r?600:o[i-32];else{if(qS(i))continue;XS(i)?s+=r?1200:1e3:s+=r?600:580}}return s*t/1e3}};function ZS(){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 JS=2e4;function sh(){let e=globalThis;return e.document?.fonts??e.fonts}function e1(e,t,n){try{return e?.check(t,n)??!0}catch{return!0}}function t1(e,t="monospace"){let n=ZS();if(!n)return null;let r=new Map,o="",s=sh()?.size;return{width(a,i,c){let l=sh();l?.size!==s&&(s=l?.size,r.clear());let f=(c&2?"italic ":"")+(c&1?"bold ":"")+i+"px "+(c&4?t:e),p=r.get(f);p||r.set(f,p=new Map);let u=p.get(a);return u===void 0&&(f!==o&&(n.font=o=f),u=n.measureText(a).width,e1(l,f,a)&&(p.size>=JS&&p.clear(),p.set(a,u))),u}}}var hd=new Map;function et(e="sans-serif",t="monospace"){let n=e+`
`+t,r=hd.get(n);return r||(r=t1(e,t)??QS,hd.set(n,r)),r}function ma(){hd.clear()}function As(e){return e.ownerDocument?.defaultView??globalThis}function md(e,t){let n=e.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0);return n>0?n:0}function n1(e,t,n,r,o){let s=t.width/n,a=t.height/n,i=(c,l,f)=>l>=f?Math.min(Math.max(c,f-l),0):Math.min(Math.max(c,0),f-l);return{x:i(r,s,e.width),y:i(o,a,e.height),width:s,height:a}}var oi=1.25,ga=48,r1="--_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",s1="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:pointer",i1={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"},o1={zoomIn:"Zoom in",zoomOut:"Zoom out",reset:"Reset zoom"};function ih(e,t={}){return gd(e,t,!0)}function gd(e,t,n){let r=null,o={width:0,height:0},s={width:0,height:0},a={width:0,height:0},i=!1,c="",l={width:"",height:"",maxWidth:"",margin:"",display:""},f=0,p=0,u=0,m=0,h=()=>As(e),b=()=>o.width>0&&s.width>0?s.width/o.width:1,x=()=>Math.max(b(),t.maxScale??3),E=()=>r!==null&&o.width>0&&(t.always===!0||b()<.999),w=()=>{if(!r||f!==0)return;let Z=r.getBoundingClientRect();s={width:Z.width,height:Z.height},a={width:Math.max(s.width,e.clientWidth),height:Math.max(s.height,e.clientHeight)},i=a.width>s.width+1||a.height>s.height+1,i||(a=s);let Q=h().getComputedStyle(e);c=["Top","Right","Bottom","Left"].map(ie=>`${-(parseFloat(Q.getPropertyValue(`padding-${ie.toLowerCase()}`))||0)}px`).join(" ")},S,O={},D=!1,L=()=>{if(t.controls===!1)return;let Z=E();if(!S){if(!Z)return;let ie=e.ownerDocument;S=ie.createElement("div"),S.className="pele pele-zoom",S.setAttribute("style",r1);let me={zoomIn:()=>Y((f||b())*oi*oi),zoomOut:()=>Y((f||b())/(oi*oi)),reset:()=>W()};for(let re of["zoomIn","zoomOut","reset"]){let te=ie.createElement("button"),he=t.labels?.[re]??o1[re];te.type="button",te.className=`pele-zoom-${re==="zoomIn"?"in":re==="zoomOut"?"out":"reset"}`,te.setAttribute("style",s1),te.setAttribute("aria-label",he),te.title=he,te.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="${i1[re]}"/></svg>`,te.addEventListener("click",me[re]),O[re]=te,S.append(te)}}Z&&!D&&h().getComputedStyle(e).position==="static"&&(e.style.position="relative",D=!0),Z&&S.parentNode!==e&&e.append(S),S.hidden=!Z,S.style.display=Z?"flex":"none";let Q=(ie,me)=>{ie&&(ie.disabled=me,ie.style.opacity=me?"0.35":"",ie.style.cursor=me?"default":"pointer")};Q(O.zoomIn,(f||b())>=x()*.999),Q(O.zoomOut,f===0),O.reset&&(O.reset.style.display=f===0?"none":"grid")},B=Z=>S!==void 0&&Z.target instanceof h().Node&&S.contains(Z.target),W=()=>{r&&(f=0,r.setAttribute("viewBox",`0 0 ${o.width} ${o.height}`),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,r.style.cursor="",r.style.userSelect="",w(),r.style.touchAction=E()?"pan-y":"",E()?r.setAttribute("tabindex","0"):r.removeAttribute("tabindex"),ae(E()),L())},Y=(Z,Q,ie)=>{if(!r||(f===0&&w(),!E()))return;let me=f||b(),re=Math.min(Math.max(Z,b()),x());if(re<=b()*1.001){W();return}let te=r.getBoundingClientRect(),he=Q??te.left+te.width/2,oe=ie??te.top+te.height/2,ge=(f?p:0)+(he-te.left)/me,Ee=(f?u:0)+(oe-te.top)/me;f=re;let be=te;i&&(r.style.maxWidth="none",r.style.margin=c,r.style.display="block",r.style.width=`${a.width}px`,r.style.height=`${a.height}px`,be=r.getBoundingClientRect()),I(ge-(he-be.left)/f,Ee-(oe-be.top)/f),r.style.cursor="grab",r.style.userSelect="none",r.style.touchAction="none",L()},I=(Z,Q)=>{if(!r)return;let ie=n1(o,a,f,Z,Q);p=ie.x,u=ie.y,r.setAttribute("viewBox",`${p} ${u} ${ie.width} ${ie.height}`)},X=(Z,Q)=>{f!==0&&I(p-Z/f,u-Q/f)},ee=()=>{C();let Z=e.clientWidth+e.clientHeight;Z!==m&&(m=Z,W())},K,z,C=()=>{if(!n)return;let Z=h();Z!==z&&(K?.disconnect(),z=Z,K=Z.ResizeObserver?new Z.ResizeObserver(ee):void 0,K?.observe(e))},M=()=>{C();let Z=e.firstElementChild;if(r=Z&&Z.localName==="svg"?Z:null,f=0,!r){S?.remove(),ae(!1);return}o={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},W()},T=new Map,g=!1,_=0,y=0,R=()=>{let[Z,Q]=[...T.values()];return{distance:Math.hypot(Z.x-Q.x,Z.y-Q.y),x:(Z.x+Q.x)/2,y:(Z.y+Q.y)/2}},A=Z=>{!E()||B(Z)||Z.pointerType==="mouse"&&Z.button!==0||(T.set(Z.pointerId,{x:Z.clientX,y:Z.clientY}),_=0,T.size===2&&(y=R().distance),(T.size===2||f!==0)&&(e.setPointerCapture?.(Z.pointerId),r&&(r.style.cursor="grabbing")))},N=Z=>{let Q=T.get(Z.pointerId);if(Q){if(T.size===2){let ie=R();T.set(Z.pointerId,{x:Z.clientX,y:Z.clientY});let me=R();y>0&&me.distance>0&&Y((f||b())*(me.distance/ie.distance),me.x,me.y),X(me.x-ie.x,me.y-ie.y),g=!0;return}T.set(Z.pointerId,{x:Z.clientX,y:Z.clientY}),f!==0&&(_+=Math.abs(Z.clientX-Q.x)+Math.abs(Z.clientY-Q.y),_>4&&(g=!0),X(Z.clientX-Q.x,Z.clientY-Q.y))}},$=Z=>{T.delete(Z.pointerId)&&(y=0,T.size===0&&r&&f!==0&&(r.style.cursor="grab"))},U=Z=>{g&&(g=!1,Z.preventDefault(),Z.stopPropagation())},j=Z=>{if(!(Z.ctrlKey||Z.metaKey)||!E())return;Z.preventDefault(),f===0&&w();let Q=Math.min(Math.max(-Z.deltaY,-24),24);Y((f||b())*2**(Q*.02),Z.clientX,Z.clientY)},v=Z=>{!E()||B(Z)||(Z.preventDefault(),f!==0?W():Y(Math.max(1,b()*2),Z.clientX,Z.clientY))},k=Z=>{if(!E()||B(Z)||Z.ctrlKey||Z.metaKey||Z.altKey)return;let Q=Z.key;if(Q==="+"||Q==="=")Y((f||b())*oi);else if(Q==="-")Y((f||b())/oi);else{if(f===0)return;if(Q==="0"||Q==="Escape")W();else if(Q==="ArrowLeft")X(ga,0);else if(Q==="ArrowRight")X(-ga,0);else if(Q==="ArrowUp")X(0,ga);else if(Q==="ArrowDown")X(0,-ga);else return}Z.preventDefault()},F=Z=>{if(!r||Z.target!==r)return;let Q=!0;try{Q=r.matches(":focus-visible")}catch{}r.style.outline=Q?"":"none"},H=0,G=Z=>{E()&&(Z.preventDefault(),f===0&&w(),H=f||b())},se=Z=>{if(H===0)return;Z.preventDefault();let{scale:Q,clientX:ie,clientY:me}=Z;Y(H*Q,ie,me)},q=()=>{H=0},P=[["pointerdown",A],["pointermove",N],["pointerup",$],["pointercancel",$],["click",U,{capture:!0}],["dblclick",v],["keydown",k],["focusin",F]];for(let[Z,Q,ie]of P)e.addEventListener(Z,Q,ie);let V=[["wheel",j,{passive:!1}],["gesturestart",G,{passive:!1}],["gesturechange",se,{passive:!1}],["gestureend",q,{passive:!1}]],ne=!1;function ae(Z){if(Z!==ne){ne=Z;for(let[Q,ie,me]of V)Z?e.addEventListener(Q,ie,me):e.removeEventListener(Q,ie,me);Z||(H=0)}}return m=e.clientWidth+e.clientHeight,M(),{get scale(){return f||b()},get fit(){return b()},zoomBy(Z){Y((f||b())*Z)},zoomTo(Z){Y(Z)},reset:W,refresh:M,resized:ee,destroy(){W(),r&&(r.style.touchAction="",r.removeAttribute("tabindex")),S?.remove(),D&&(e.style.position=""),K?.disconnect(),ae(!1);for(let[Z,Q,ie]of P)e.removeEventListener(Z,Q,ie)}}}function bd(e,t){let n=t?As(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 a1(e){return[...new Set([e.ownerDocument?.fonts,globalThis.document?.fonts])].filter(n=>n!==void 0)}var yd=new WeakMap;function c1(e){let t=yd.get(e);return t||(t=e.ready.then(()=>{yd.delete(e),ma()}),yd.set(e,t)),t}var Ed=new WeakMap;function l1(e,t){Promise.all(e.map(c1)).then(()=>{let n=t.deref();n&&Ed.get(n)?.()})}var ba=new WeakMap,d1=0,u1=Math.random().toString(36).slice(2,7),f1="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;",p1="margin:0;font-size:0.8em;font-family:var(--pele-font-mono,monospace);color:var(--pele-error,#e45756);white-space:pre-wrap;";function h1(e){return e instanceof Error?e.message:String(e)}function m1(e){let t=e.split(`
`).filter(n=>n.trim()!=="");return t.length>1?`${t[0]} ${t[t.length-1]}`:t[0]??""}function oh(e,t,n,r={}){ba.get(t)?.destroy();let o=n,s=r,a,i,c=!1,l,f,p,u=`pele-${u1}-${++d1}`,m={},h,b=-1,x=!1,E=!1,w=!1,S=(R,A)=>{let{onRender:N,onError:$,sanitize:U,...j}=s,v={...j,idPrefix:j.idPrefix??u,fontFamily:j.fontFamily??m.family,fontFamilyMono:j.fontFamilyMono??m.mono,maxWidth:void 0};A&&(f=e.render(a,v),h=void 0);let k=s.maxWidth??md(t,R);return b=k,k>0&&k<f.width&&(h??=e.render(a,{...v,maxWidth:1}).svg!==f.svg,h)?e.render(a,{...v,maxWidth:k}):f},O=R=>{s.sanitize?t.replaceChildren(s.sanitize(R)):t.innerHTML=R},D,L=()=>{let R=p?t.firstElementChild:null;if(R?.style&&(R.style.opacity=l===void 0?"":"0.4"),l===void 0){D?.remove(),D=void 0;return}let A=t.ownerDocument;if(!A)return;D??=A.createElement("div"),D.className="pele pele-error";let N=h1(l);R?(D.textContent=m1(N),D.title=N,D.setAttribute("style",f1),D.parentNode!==t&&t.append(D)):(D.textContent=N,D.removeAttribute("title"),D.setAttribute("style",p1),t.replaceChildren(D))},B=R=>{l=R,L(),s.onError?.(R)},W=()=>{if(E||w)return;let R=a1(t).filter(A=>A.status==="loading");R.length!==0&&(E=!0,l1(R,new WeakRef(y)))},Y=()=>{E=!1,x=!0,M()},I=(R,A=!R)=>{let N=As(t).getComputedStyle(t),$=t.firstElementChild??null,U={fonts:m,natural:f,adapts:h,drawnFor:b,stale:x},j;try{if(R&&(m=bd(N,$),x=t.isConnected===!1),j=S(N,R),A&&j.svg===p?.svg){R&&(i=a),c&&l!==void 0&&(l=void 0,L());return}O(j.svg)}catch(v){throw{fonts:m,natural:f,adapts:h,drawnFor:b,stale:x}=U,v}if(R&&(i=a),R&&!$&&t.firstElementChild){let v=bd(N,t.firstElementChild);if(v.family!==m.family||v.mono!==m.mono){let k={fonts:m,natural:f,adapts:h,drawnFor:b};m=v;try{let F=S(N,!0);O(F.svg),j=F}catch{({fonts:m,natural:f,adapts:h,drawnFor:b}=k)}}}p=j,c&&(l=void 0),L(),X?.refresh(),W(),s.onRender?.(j)},X,ee=!1,K=()=>{let R=s.zoom??"auto";R!==ee&&(X?.destroy(),ee=R,X=R===!1?void 0:gd(t,typeof R=="object"?R:{always:R===!0},!1))},z=()=>t.isConnected===!1||!(t.clientWidth>0),C=()=>t.isConnected!==!1&&!(t.clientWidth>0),M=()=>{if(w||(_(),!a||z()))return;let R=As(t).getComputedStyle(t),A=bd(R,t.firstElementChild??null);try{if(x||A.family!==m.family||A.mono!==m.mono)I(!0,!0);else if(h!==!1&&s.maxWidth===void 0){let N=md(t,R);N!==b&&N!==p?.width&&I(!1)}}catch(N){x=!1,c&&(l=N),a!==i&&(a=i,c=!1),L(),s.onError?.(N)}X?.resized(),W()},T,g,_=()=>{let R=As(t);R!==T&&(g?.disconnect(),T=R,g=R.ResizeObserver?new R.ResizeObserver(M):void 0,g?.observe(t))},y={get result(){return p},get source(){return o},get error(){return l},get zoom(){return X},update(R,A=s){let N=!c||R!==o||A.limit!==s.limit||A.maxEdges!==s.maxEdges||A.config!==s.config;o=R,s=A;let $=a;if(N)try{$=e.parse(R,A)}catch(j){c=!1,B(j),K();return}let U=p;if(a=$,c=!0,C()){x=!0,K();return}try{I(!0)}catch(j){if(p!==U)throw K(),j;a=i,c=!1,B(j)}K()},refresh:M,destroy(){w=!0,g?.disconnect(),g=void 0,T=void 0,X?.destroy(),Ed.delete(y),ba.get(t)===y&&ba.delete(t)}};Ed.set(y,Y);try{a=e.parse(n,r),c=!0,I(!0)}catch(R){if(p)throw R;a=i,c=!1,B(R)}return K(),_(),ba.set(t,y),y}var ya=new Map;function Ad(...e){for(let t of e)ya.set(t.type,t)}function g1(e){return ya.has(e)}var b1=5e4,y1=4e6,E1=5e3;function ah(e){try{return e()}catch(t){throw t instanceof RangeError?new ze("Diagram is nested too deeply.","limit"):t}}function ch(e,t){try{return t()}catch(n){throw n instanceof RangeError?new ze("Diagram is nested too deeply.","limit",e):(n instanceof ze&&(n.type??=e.type,n.mermaidType??=e.mermaidType),n)}}var lh=new WeakMap;function dh(e,t=b1,n=E1,r){if(e.length>t)throw new ze(`Diagram source is longer than the limit of ${t} characters.`,"limit");let o=pd(e),s=od(o.text);if(s===null)throw new ze("No diagram type detected for the given text.","unsupported-diagram");let a=ya.get(s.type);if(a===void 0)throw new ze(`Diagram type "${s.type}" is not supported yet.`,"unsupported-diagram",s);let i=r?{...r,...o.config}:o.config,c=a.keepComments?o.withComments:o.text,l=ch(s,()=>a.parse(eh(c)+`
`,i,o.title,o.lineOffset,{maxEdges:n}));return{...s,diagram:a,model:l,config:i}}function A1(e,t){if(typeof e=="string")return dh(e,t.limit,t.maxEdges,t.config);let n=lh.get(e);if(n===void 0)throw new TypeError("render() takes diagram text or a model that parse() returned.");return n}function uh(e){return od(pd(e).text)?.type??null}function x1(e){try{let t=uh(e);return t!==null&&ya.has(t)}catch{return!1}}function fh(e,t={}){return ah(()=>{let n=dh(e,t.limit,t.maxEdges,t.config),r=n.model;return Object.defineProperty(r,"mermaidType",{value:n.mermaidType,enumerable:!0}),lh.set(r,n),r})}function ph(e,t={}){return ah(()=>{let{type:n,mermaidType:r,diagram:o,model:s,config:a}=A1(e,t),i=a[o.section??n],c=typeof i=="object"&&i!==null&&!Array.isArray(i)&&i.useMaxWidth===!1,l=t.responsive??!c,f=t.icons,p=f&&(h=>f(yt(h))),u=ch({type:n,mermaidType:r},()=>zp(o.math?t.math:void 0,()=>Hp(p,()=>o.render(s,a,{...t,responsive:l,icons:p})))),m=t.outputLimit??y1;if(u.svg.length>m)throw new ze(`Diagram output is longer than the limit of ${m} characters.`,"limit",{type:n,mermaidType:r});for(let h of u.links)h.id=yt(h.id);return{type:n,mermaidType:r,...u}})}function S1(e,t,n={}){return oh({parse:fh,render:ph},e,t,n)}var _1=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/,w1=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]+/g,R1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function je(e){return _1.test(e)?e.replace(w1,t=>R1[t]??""):e}function Fe(e){return je(yt(e))}var xd=[];for(let e=0;e<100;e++)xd.push(e===0?"":e%10===0?"."+e/10:"."+(e<10?"0"+e:e));function d(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+xd[t-n*100]}}else if(t>-1e11){let n=-t,r=Math.floor(n/100);return"-"+r+xd[n-r*100]}return String(t/100)}function De(e,t,n,r,o){let s=e.lines;if(s.length===0)return"";let a=e.lineHeight,i=e.heights,c=e.size*.35,l=n-e.height/2,f=s.length===1&&s[0].length===1?s[0][0]:void 0;if(f&&f.icon===void 0&&f.math===void 0&&f.style===0)return`<text${r} x="${d(t)}" y="${d(l+a/2+c)}" text-anchor="middle">${je(f.text)}</text>`;let p=Tr(e),u=r,m;r=jn(r,p);let h="",b="";for(let x=0;x<s.length;x++){let E=s[x],w=i?i[x]:a,S=l+w/2,O=S+c,D=!1;for(let L of E)(L.icon!==void 0||L.math)&&(D=!0);if(D){let L=t-e.widths[x]/2;for(let B of E){if(B.math){let W=`x="${d(L)}" y="${d(S-B.math.height/2)}" width="${d(B.math.width)}" height="${d(B.math.height)}"`;m??=k1(u),b+=m.halo===void 0?L1(B.math,W,e.size,m.attrs):`<rect ${W} rx="2" fill="${m.halo}"/>`}else if(B.icon!==void 0){let W=e.size*1.1,Y=o?.(B.icon)??"";b+=`<svg class="pele-icon" data-icon="${Fe(B.icon)}" x="${d(L)}" y="${d(S-W/2)}" width="${d(W)}" height="${d(W)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${Y}</svg>`}else B.text!==""&&(h+=`<tspan x="${d(L)}" y="${d(O)}" text-anchor="start"${ar(B.style&~p)}>${je(B.text)}</tspan>`);L+=B.width}}else{for(let L=0;L<E.length;L++){let B=E[L],W=L===0?` x="${d(t)}" y="${d(O)}"`:"";h+=`<tspan${W}${ar(B.style&~p)}>${je(B.text)}</tspan>`}E.length===0&&(h+=`<tspan x="${d(t)}" y="${d(O)}"> </tspan>`)}l+=w}return`<text${r} text-anchor="middle" xml:space="preserve">${h}</text>${b}`}var T1=/ fill="([^"]*)"/,C1=/ stroke="([^"]*)"/,N1=/ style="([^"]*)"/,M1=/(?:^|;)\s*fill:([^;]*)/,I1=/(?:^|;)\s*opacity:([^;]*)/;function k1(e){let t=N1.exec(e)?.[1]??"",n=(M1.exec(t)?.[1]??T1.exec(e)?.[1]??"").trim();if(n==="none")return{attrs:"",halo:C1.exec(e)?.[1]??"none"};let r=I1.exec(t)?.[1].trim();return{attrs:(n===""?"":` color="${n}"`)+(r?` opacity="${r}"`:"")}}function L1(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:${d(n)}px;line-height:normal;white-space:nowrap">${e.html}</div></foreignObject>`}var hh=' font-weight="var(--_w)"',mh=' font-style="italic"';function ar(e){return(e&1?hh:"")+(e&2?mh:"")}function Tr(e){let t=3,n=!1;for(let r of e.lines)for(let o of r)o.icon!==void 0||o.text===""||(t&=o.style,n=!0);return n?t:0}function jn(e,t){return e+(t&1&&!e.includes(' font-weight="')?hh:"")+(t&2&&!e.includes(' font-style="')?mh:"")}var Ji="about:blank",$1=/^([^\w]*)(javascript|data|vbscript)/im,gh=/&#(\w+)(^\w|;)?/g,bh=/&(newline|tab);/gi,Sd=/[\u0000-\u001F\u007F-\u009F -‍]/gim,D1=/^.+(:|&colon;)/gim,yh=/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;function Eh(e){try{return decodeURIComponent(e)}catch{return e}}function Xn(e){if(!e)return Ji;let t=Eh(e.trim()),n,r=0;do{if(++r>32)return Ji;t=t.replace(Sd,"").replace(gh,(c,l)=>String.fromCharCode(l)).replace(bh,"").replace(Sd,"").replace(yh,"").trim(),t=Eh(t),n=t.match(Sd)||t.match(gh)||t.match(bh)||t.match(yh)}while(n&&n.length>0);if(!t)return Ji;if(t[0]==="."||t[0]==="/")return t;let o=t.trimStart(),s=o.match(D1);if(!s)return t;let a=s[0].toLowerCase().trim();if($1.test(a))return Ji;let i=o.replace(/\\/g,"/");if(a==="mailto:"||a.includes("://"))return i;if(a==="http:"||a==="https:"){let c;try{c=new URL(i)}catch{return Ji}return c.protocol=c.protocol.toLowerCase(),c.hostname=c.hostname.toLowerCase(),c.toString()}return i}function Fn(e){return Xn(yt(e))}var O1=["http","https","mailto","tel"],v1=["http","https"],P1=/^([a-z][a-z0-9+.-]*):/i,B1=/^[\\/]{2}/;function Ah(e,t){if(B1.test(e))return;let n=P1.exec(e);return!n||t.includes(n[1].toLowerCase())?e:void 0}function Cr(e,t){return t.links===!1?void 0:Ah(e,t.linkSchemes??O1)}function xh(e,t){return t.images===!1?void 0:Ah(e,t.imageSchemes??v1)}function Wn(e,t,n,r,o,s=""){let a=Cr(t,o);return a===void 0?e:(r.push({id:n,href:a,internal:!1}),`<a href="${je(a)}"${s}${Nr(o)}>${e}</a>`)}function Nr(e){let t=e.linkRel??"noopener";return t?` rel="${je(t)}"`:""}var F1=[["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"]],W1=["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"],U1=new Map([["square","rect"],["round","rounded"],["ellipse","ellipse"],["hexagon","hex"],["diamond","diam"]]),Ea=new Map;for(let e of F1)for(let t of e)Ea.set(t,e[0]);for(let e of W1)Ea.set(e,e);function Aa(e){return Ea.has(e)}function xa(e){return e===void 0?"rect":U1.get(e)??Ea.get(e)??"rect"}var G1=new Map([["task","roundedRect"],["tool","subroutine"],["input","lean-right"],["decision","diamond"],["refdoc","lin-doc"],["action","hexagon"],["round","rect"]]),Y1=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"]),H1=new Set(["roundedRect","subroutine","subprocess","subproc","framed-rectangle","lean-right","diamond","lin-doc","lined-document","hexagon","hex","connector","collapsedGroup"]),eo="roundedRect";function ai(e){return e&&(G1.get(e)??e)}function Sh(e){return Aa(e)||e==="constructor"}function _h(e,t){for(let n of e)n.isGroup||((!n.shape||n.shape==="squareRect"||n.shape==="rect")&&(n.shape=eo),Y1.has(n.shape)?(t.emitError("SHAPE_REMOVED",`shape "${n.shape}" was removed in v0.8.1, using "${eo}"`,{nodeId:n.id}),n.shape=eo):H1.has(n.shape)||(t.emitWarning("SHAPE_UNSUPPORTED",`shape "${n.shape}" is not supported, using "${eo}"`,{nodeId:n.id}),n.shape=eo))}var K1=new Set(["shape","view","icon","img","form","pos","w","h","class","style","labelType"]),z1=new Set(["subroutine","subprocess","subproc","framed-rectangle","tool"]);function V1(e){return z1.has(e.type)}function _d(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function wh(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function wd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function j1(e){let t=o=>Array.isArray(o)?[]:wd(o)?{}:o,n=t(e),r=[[e,n]];for(;r.length>0;){let[o,s]=r.pop();if(Array.isArray(o))for(let a of o){let i=t(a);s.push(i),typeof a=="object"&&a!==null&&r.push([a,i])}else if(wd(o))for(let a of Object.keys(o)){if(a==="__proto__"||a==="constructor"||a==="prototype")continue;let i=o[a],c=t(i);s[a]=c,typeof i=="object"&&i!==null&&r.push([i,c])}}return n}function Sa(e,t){return Object.assign(e??{},t)}var X1=/:\s*[>|][\d+-]*\s*$/,q1=/,([\t ]*)$/;function Q1(e){let t=!1,n=!1,r=0,o,s=[];for(let a of e.split(`
`)){if(o!==void 0){let f=a.length-a.trimStart().length;if(a.trim()===""||f>o){s.push(a);continue}o=void 0}let i=-1;for(let f=0;f<a.length;f++){let p=a[f];if(n)p==="\\"?f++:p==='"'&&(n=!1);else if(t)p==="'"&&(t=!1);else if(p==='"')n=!0;else if(p==="'")t=!0;else if(p==="#"&&(f===0||a[f-1]===" "||a[f-1]==="	")){i=f;break}else p==="["||p==="{"?r++:(p==="]"||p==="}")&&(r=Math.max(0,r-1))}if(t||n||r>0){s.push(a);continue}let c=i>=0?a.slice(0,i):a,l=i>=0?a.slice(i):"";if(X1.test(c)){o=a.length-a.trimStart().length,s.push(a);continue}s.push(c.replace(q1,"$1")+l)}return s.join(`
`)}function Z1(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 J1(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 o="normal",s=n.length-1,a=0;for(let i=0;i<n.length;i++)n[i]==="."&&a++;return a>0&&(o="dotted",s=a),{type:r,stroke:o,length:s}}function Rh(e){if(!e)return;let t={},n=!1;for(let r of Object.keys(e))K1.has(r)||(t[r]=e[r],n=!0);return n?t:void 0}var _a=class{constructor(t={}){de(this,"type","agentflow");de(this,"direction");de(this,"nodes",new Map);de(this,"edges",[]);de(this,"subgraphs",[]);de(this,"connectors",new Map);de(this,"classes",new Map);de(this,"tooltips",new Map);de(this,"defaultEdgeStyle");de(this,"defaultInterpolate");de(this,"mappings",[]);de(this,"diagnostics",[]);de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"lineOffset");de(this,"subgraphLookup",new Map);de(this,"globalNodes",new Set);de(this,"members",new Set);de(this,"edgeById",new Map);de(this,"pairCount",new Map);de(this,"subCount",0);de(this,"bareMappings",new Set);de(this,"firstMapping",new Map);de(this,"reported",new Map);de(this,"options");this.options=t,this.lineOffset=t.lineOffset??0}metadata(t,n,r){let o=n.includes(`
`),s;try{s=Vn(o?n+`
`:`{
`+n+`
}`)}catch(a){let i=o?Q1(n):n,c;if(i!==n)try{c=Vn(i+`
`)}catch{c=void 0}if(c===void 0){let l=r?` (${r.first_line+this.lineOffset}:${r.first_column+1})`:"";throw new ze(`Metadata of "${t}" is not valid YAML. ${a.message}${l}`,"syntax",{type:"agentflow",line:r?r.first_line+this.lineOffset:0,column:r?r.first_column+1:0})}s=c}return j1(s??{})}shapeError(t,n){return new ze(t,"semantic",{type:"agentflow",line:n?n.first_line+this.lineOffset:0,column:n?n.first_column+1:0})}addVertex(t,n,r,o,s,a,i={},c,l){if(!t||t.trim().length===0)return;let f,p,u;c!==void 0&&(f=this.metadata(t,c,l),wd(f)&&(p=f,typeof f.shape=="string"&&(u=f.shape,f.shape=ai(f.shape))));let m=this.subgraphLookup.get(t);if(m&&f){m.metadata=Sa(m.metadata,f);return}let h=this.connectors.get(t);if(h&&f){h.metadata=Sa(h.metadata,f);return}if(t==="connectors")return;let b=this.edgeById.get(t);if(b){p?.animate!==void 0&&(b.animate=p.animate),p?.animation!==void 0&&(b.animation=p.animation),p?.curve!==void 0&&(b.interpolate=p.curve),f&&(b.metadata=Sa(b.metadata,f));return}let x=this.nodes.get(t);if(x===void 0&&(x={id:t,labelType:"text",styles:[],classes:[]},this.nodes.set(t,x)),n!==void 0?(x.labelType=n.type,x.text=wh(n.text.trim())):x.text===void 0&&(x.text=t),r!==void 0&&(x.type=r),o!=null)for(let E of o)x.styles.push(E);if(s!=null)for(let E of s)x.classes.push(E);if(a!==void 0&&(x.dir=a),x.props===void 0?x.props=i:i!==void 0&&Object.assign(x.props,i),!!f&&(x.metadata=Sa(x.metadata,f),p!==void 0)){if(p.shape){let E=u??p.shape;if(typeof E!="string")throw this.shapeError(`No such shape: ${JSON.stringify(E)}.`,l);if(E!==E.toLowerCase()||E.includes("_"))throw this.shapeError(`No such shape: ${E}. Shape names should be lowercase.`,l);let w=p.shape;if(!Sh(w))throw this.shapeError(`No such shape: ${w}.`,l);x.type=w}p.label&&(x.text=String(p.label),x.labelType=_d(p.labelType))}}addSingleLink(t,n,r,o){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=wh(a.text.trim()),s.labelType=_d(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 i=t+"\0"+n,c=this.pairCount.get(i)??0;o&&!this.edgeById.has(o)?(s.id=o,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 ze(`Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${l}.`,"limit",{type:"agentflow"});this.edges.push(s),this.pairCount.set(i,c+1),this.edgeById.has(s.id)||this.edgeById.set(s.id,s)}addLink(t,n,r){let o=typeof r?.id=="string"?r.id.replace("@",""):void 0,s=t[t.length-1],a=n[0];for(let i of t)for(let c of n)this.addSingleLink(i,c,r,i===s&&c===a?o: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 o=this.edgeAt(r);o.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 ze(`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 o of t.split(",")){let s=this.classes.get(o);s===void 0&&(s={id:o,styles:[],textStyles:[]},this.classes.set(o,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 o=n.trim();for(let s of t.split(",")){let a=this.nodes.get(s);a!==void 0&&(a.link=o?Fn(o):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,`
`)}addSubGraph(t,n,r,o){let s=t?.text?.trim(),a=r?.text||"";t!==void 0&&t===r&&/\s/.test(a)&&(s=void 0);let i=new Set,c=[],l;for(let h of n)if(typeof h=="string")h.trim()!==""&&!i.has(h)&&(i.add(h),c.push(h));else if(Array.isArray(h))for(let b of h)b.trim()!==""&&!i.has(b)&&(i.add(b),c.push(b));else l=h.value;l??=this.options.inheritDir?this.direction??this.options.direction:void 0,s??="subGraph"+this.subCount,this.subCount++;let f=this.members,p=c.filter(h=>h!==s&&!this.globalNodes.has(h)&&!f.has(h));for(let h of p)f.add(h);let u=this.subgraphLookup.get(s);if(u){for(let h of p)u.nodes.push(h);return a.trim()&&(u.title=a.trim()),l&&(u.dir=l),s}let m={id:s,nodes:p,title:a.trim(),classes:[],dir:l,labelType:_d(r?.type),type:"flow"};return this.subgraphs.push(m),this.subgraphLookup.set(s,m),s}addGlobal(t){let n=!1,r=o=>{let s=o.trim();s!==""&&(this.globalNodes.add(s),this.members.delete(s)&&(n=!0))};for(let o of t)if(typeof o=="string")r(o);else if(Array.isArray(o))for(let s of o)r(s);if(n)for(let o of this.subgraphs)o.nodes=o.nodes.filter(s=>!this.globalNodes.has(s))}addConnector(t,n){let r=t?.text?.trim();if(!r)return"";let o=n?.text?.trim()??"",s=this.connectors.get(r);if(s)o.length>0&&(s.text=o);else{let a={id:r,labelType:"text",styles:[],classes:[],isConnector:!0,text:o.length>0?o:r};this.connectors.set(r,a),this.nodes.set(r,a)}return r}destructLink(t,n){let r=J1(t);return n&&(n.includes(".")?"dotted":"normal")!==r.stroke?{type:"INVALID",stroke:"INVALID"}:{...r,edgeSemantic:Z1(r.type,r.stroke)}}subgraph(t){return this.subgraphLookup.get(t)}vertexKind(t){if(V1(t))return"tool";let n=ai(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,i]of this.nodes){if(this.subgraphLookup.has(a))continue;let c=Rh(i.metadata);if(i.isConnector){let p={id:a};i.text!==void 0&&i.text!==a&&(p.title=i.text),c&&(p.metadata=c),n.push(p);continue}let l={id:a};i.text!==void 0&&(l.label=i.text);let f=ai(i.type);f!==void 0&&(l.shape=f),l.vertexKind=this.vertexKind(i),c&&(l.metadata=c),t.push(l)}let r=this.edges.map(a=>{let i={start:a.start,end:a.end};return a.id!==void 0&&(i.id=a.id),a.text.length>0&&(i.label=a.text),a.type!==void 0&&(i.type=a.type),a.stroke!==void 0&&(i.stroke=a.stroke),a.edgeSemantic!==void 0&&(i.edgeSemantic=a.edgeSemantic),a.length!==void 0&&(i.length=a.length),a.metadata&&Object.keys(a.metadata).length>0&&(i.metadata={...a.metadata}),i}),o=this.subgraphs.map(a=>{let i={id:a.id,nodes:[...a.nodes],type:a.type,title:a.title};a.dir!==void 0&&(i.direction=a.dir);let c=Rh(a.metadata);return c&&(i.metadata=c),i}),s={vertices:t,edges:r,subGraphs:o,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 o={id:t,type:n,position:r};return this.mappings.push(o),this.firstMapping.has(t)||this.firstMapping.set(t,o),o}addVertexMapping(t,n,r,o){if(!t)return;let s=this.pushMapping(t,"vertex",this.position(o));r==null&&this.bareMappings.add(s)}extendVertexMapping(t,n){if(!t||!n)return;let r=this.position(n);for(let o=this.mappings.length-1;o>=0;o--){let s=this.mappings[o];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,o){let s=Array.isArray(n)?n.filter(a=>typeof a=="string"&&a!==""):[];this.pushMapping(s.length>0?s.join(">"):"edge","edge",this.position(o))}blockMapping(t,n,r,o){if(!t)return;let s=this.position(r),a=o?this.position(o):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,o){let s=typeof t=="string"?t:t?.text;this.blockMapping(s??"","subgraph",r,o)}addConnectorMapping(t,n,r,o){this.blockMapping(t?.text?.trim()??"","connector",r,o)}emit(t,n,r,o){let s=o?.nodeId??o?.edgeId,a={id:t,severity:n,message:r};o?.nodeId?a.nodeId=o.nodeId:o?.edgeId&&(a.edgeId=o.edgeId);let i=s?this.firstMapping.get(s):void 0;i&&(a.position=i.position);let c=s??"",l=this.reported.get(c);if(l===void 0)this.reported.set(c,[a]);else{for(let f of l)if(f.id===t&&f.severity===n&&f.message===r&&f.nodeId===a.nodeId&&f.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 e_="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",t_;function n_(){let e=e_.split(" "),t=new Uint16Array(e.length),n=0;for(let r=0;r<e.length;r+=2){let o=n+parseInt(e[r],36);n=o+parseInt(e[r+1],36),t[r]=o,t[r+1]=n}return t}function ci(e){if(e<170||e>65500)return!1;let t=t_??=n_(),n=0,r=(t.length>>1)-1;for(;n<=r;){let o=n+r>>1;if(e<t[o*2])r=o-1;else if(e>t[o*2+1])n=o+1;else return!0}return!1}var Rd=["$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 Th=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")Th[e.charCodeAt(0)]=1;var r_=/accTitle\s*:\s*/y,s_=/accDescr\s*:\s*/y,i_=/accDescr\s*\{\s*/y,o_=/call\s+/y,a_=/click\s+/y,c_=/(?:\r?\n)*\s*\n/y,l_=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,d_=/\s*[<>^]/y,u_=/\s*v\b/y,f_=[/.*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],Td=/[\n\r\u2028\u2029]/g,p_=/\(\s*\)/y,h_=/\n\s*/g;function Ch(e){let t=e.length,n=[],r=[],o=[],s=[],a=[],i=0,c=0,l=1,f=0,p=!0,u=e.indexOf("direction"),m=e.indexOf("@"),h=-1,b=0,x=0,E=-1,w=-1,S=-1,O=-1,D=-1,L=-1,B=-1,W=v=>{let k=-1;for(let F=c;F<v;F++){let H=e.charCodeAt(F);H===10?(l++,k=F):H===13&&(F+1<v&&e.charCodeAt(F+1)===10&&F++,l++,k=F)}if(k<0)f+=v-c;else{let F=k+1;for(;F<v;){let H=e.charCodeAt(F);if(H===8232||H===8233)break;F++}f=F-k-1}c=v},Y=(v,k)=>{n.push(v),r.push(e.slice(c,k)),o.push(c),s.push(l,f),W(k),s.push(l,f)},I=(v,k)=>{n.push(v),r.push(e.slice(c,k)),o.push(c),s.push(l,f),f+=k-c,c=k,s.push(l,f)},X=(v,k)=>{n.push(v),r.push(e.slice(c,k)),o.push(c),s.push(l,f);for(let F=c;F<k;F++){let H=e.charCodeAt(F);H===10||H===13?(l++,f=0):f++}c=k,s.push(l,f)},ee=(v,k,F)=>{n.push(v),r.push(k),o.push(c),s.push(l,f),W(F),s.push(l,f)},K=v=>{a.push(i),i=v},z=()=>{a.length>0&&(i=a.pop())},C=(v,k)=>(v.lastIndex=k,v.test(e)?v.lastIndex:-1),M=v=>e.startsWith(v,c)&&!Qe(e.charCodeAt(c+v.length)),T=v=>{if(v>=w&&v<=S)return S;let k=v;for(;k<t&&He(e.charCodeAt(k));)k++;return w=v,S=k,k},g=v=>{if(v>=O&&v<=D)return D;let k=v;for(;k<t;){let F=e.charCodeAt(k);if(F!==32&&F!==9)break;k++}return O=v,D=k,k},_=v=>{let k=T(v);if(k===B||e.charCodeAt(k)!==45||e.charCodeAt(k+1)!==45)return-1;let F=k+2;for(;e.charCodeAt(F)===45;)F++;let H=e.charCodeAt(F);return H===120||H===62?T(F+1):(B=k,-1)},y=()=>{let v=T(c);if(v===L||e.charCodeAt(v)!==45)return!1;let k=e.charCodeAt(v+1),F=v+2;if(k===45){for(;e.charCodeAt(F)===45;)F++;let H=e.charCodeAt(F);return H===120||H===62?Y(42,T(F+1)):(K(10),Y(43,T(v+2))),!0}if(k===46){for(;e.charCodeAt(F)===46;)F++;if(e.charCodeAt(F)===45)return Y(42,T(F+1)),!0}return L=v,!1},R=v=>{if(e.charCodeAt(v)!==37||e.charCodeAt(v+1)!==37||e.charCodeAt(v+2)===123)return-1;let k=e.indexOf(`
`,v+2);return k===-1?t:k},A=()=>{e.charCodeAt(c+1)===96?(K(2),W(c+2)):(K(1),W(c+1))},N=v=>{let k=e.charCodeAt(c+1);return v===40?(k===45?(K(8),I(47,c+2)):k===91?(K(7),I(49,c+2)):k===40&&e.charCodeAt(c+2)===40?(K(7),I(57,c+3)):(K(7),I(72,c+1)),!0):v===91?(k===91?(K(7),I(51,c+2)):k===40?(K(7),I(55,c+2)):k===47?(K(9),I(60,c+2)):k===92?(K(9),I(61,c+2)):(K(7),I(74,c+1)),!0):v===124?(K(7),I(70,c+1),!0):v===123?(K(7),I(76,c+1),!0):!1},$=()=>{let v=c;for(;v<t;){let k=e.charCodeAt(v);if(k<128&&Th[k]===1)v++;else if(k===45&&v+1<t){let F=e.charCodeAt(v+1);if(F===62||F===45||F===46)break;v++}else break}return v===c?!1:(I(67,v),!0)},U=v=>{let k=v;for(;k<t;){let F=e.charCodeAt(k);if(F!==32&&F!==9)break;k++}return k},j=v=>{let k;switch(v){case 97:if(e.startsWith("acc",c)){if((k=C(r_,c))>=0)return K(3),Y(2,k),!0;if((k=C(s_,c))>=0)return K(4),Y(4,k),!0;if((k=C(i_,c))>=0)return K(5),W(k),!0}if(M("agentflow-beta"))return p&&(p=!1,K(6)),I(20,c+14),!0;break;case 64:if(e.charCodeAt(c+1)===123)return K(14),ee(7,"",c+2),!0;break;case 99:if((k=C(o_,c))>=0)return K(12),W(k),!0;if(M("classDef"))return I(16,c+8),!0;if(M("class"))return I(17,c+5),!0;if((k=C(a_,c))>=0)return K(11),W(k),!0;if(M("connector"))return I(22,c+9),!0;break;case 34:return A(),!0;case 115:if(M("style"))return I(12,c+5),!0;break;case 100:if(M("default"))return I(13,c+7),!0;break;case 108:if(M("linkStyle"))return I(14,c+9),!0;break;case 105:if(M("interpolate"))return I(15,c+11),!0;break;case 104:if(e.startsWith("href",c)&&He(e.charCodeAt(c+4)))return Y(18,c+5),!0;break;case 102:if(M("flow"))return I(21,c+4),!0;break;case 103:if(M("global"))return I(23,U(c+6)),!0;break;case 101:if(M("end"))return I(24,U(c+3)),!0;break;case 95:if(M("_self"))return I(25,c+5),!0;if(M("_blank"))return I(25,c+6),!0;if(M("_parent"))return I(25,c+7),!0;if(M("_top"))return I(25,c+4),!0;break}if(u!==-1&&c>=b&&(u<c&&(u=e.indexOf("direction",c)),u!==-1&&(h<c&&(Td.lastIndex=c,h=Td.test(e)?Td.lastIndex-1:t),u<h))){for(let F=0;F<5;F++)if((k=C(f_[F],c))>=0)return Y(28+F,k),!0;b=h}if(m!==-1&&v!==34&&!He(v)){if(c>=x){m<c&&(m=e.indexOf("@",c));let F=c;for(;F<t;){let H=e.charCodeAt(F);if(H===34||He(H))break;F++}if(x=F,E=-1,m!==-1&&m<F)for(let H=Math.min(F,t-1)-1;H>=m;H--){if(e.charCodeAt(H)!==64)continue;let G=e.charCodeAt(H+1);if(G!==123&&G!==34){E=H;break}}}if(E>c)return I(33,E+1),!0}if(v>=48&&v<=57){let F=c+1;for(;F<t;){let H=e.charCodeAt(F);if(H<48||H>57)break;F++}return I(34,F),!0}switch(v){case 35:return I(35,c+1),!0;case 58:return e.charCodeAt(c+1)===58&&e.charCodeAt(c+2)===58?I(36,c+3):I(37,c+1),!0;case 38:return I(38,c+1),!0;case 59:return I(39,c+1),!0;case 44:return I(40,c+1),!0;case 42:return I(41,c+1),!0;case 60:return I(62,c+1),!0;case 45:return y()||$()||I(68,c+1),!0;case 40:return N(v);case 91:return e.charCodeAt(c+1)===124?(I(52,c+2),!0):N(v);case 124:case 123:return N(v);case 62:return K(7),I(53,c+1),!0;case 94:return I(63,c+1),!0;case 92:return e.charCodeAt(c+1)===124?(I(64,c+2),!0):$();case 118:return Qe(e.charCodeAt(c+1))?$():(I(65,c+1),!0);case 37:return(k=R(c))>=0?(Y(66,k),!0):$()}if(He(v)){if(y())return!0;if((v===32||v===9)&&(k=R(g(c)))>=0)return Y(66,k),!0;for(k=c;;){let F=e.charCodeAt(k);if(F===10)k++;else if(F===13&&e.charCodeAt(k+1)===10)k+=2;else break}return k>c?Y(77,k):Y(78,c+1),!0}return v<128?$():ci(v)?(I(69,c+1),!0):!1};e:for(;;){if(c>=t){let F=-1;switch(i){case 0:F=79;break;case 3:F=3;break;case 4:F=5;break;case 5:F=6;break;case 11:F=19;break;case 12:F=8;break;case 13:F=9;break}F!==-1&&I(F,t);break}let v=e.charCodeAt(c),k=!0;switch(i){case 0:k=j(v);break;case 1:if(v===34)e.charCodeAt(c+1)===96?(K(2),W(c+2)):(z(),W(c+1));else{let F=e.indexOf('"',c);Y(11,F===-1?t:F)}break;case 2:if(v===96)e.charCodeAt(c+1)===34?(z(),W(c+2)):k=!1;else if(v===34)A();else{let F=c+1;for(;F<t;){let H=e.charCodeAt(F);if(H===96||H===34)break;F++}Y(10,F)}break;case 3:case 4:{let F=e.indexOf(`
`,c);F===-1&&(F=t);let H=i===3?3:5;z(),Y(H,F);break}case 5:if(v===125)z(),W(c+1);else{let F=e.indexOf("}",c);F===-1&&(F=t),Y(6,F)}break;case 6:{let F;v===34?A():(F=C(c_,c))>=0?(z(),Y(26,F)):(F=C(l_,c))>=0||(F=C(d_,c))>=0||(F=C(u_,c))>=0?(z(),Y(27,F)):k=N(v);break}case 7:{let F=e.charCodeAt(c+1);switch(v){case 34:A();break;case 40:case 91:case 123:N(v);break;case 93:z(),F===41?I(48,c+2):F===93?I(50,c+2):I(73,c+1);break;case 41:z(),F===93?I(54,c+2):F===41&&e.charCodeAt(c+2)===41?I(56,c+3):I(71,c+1);break;case 124:z(),I(70,c+1);break;case 125:z(),I(75,c+1);break;case 37:{let H=R(c);H>=0?W(H):k=!1;break}default:{let H=c+1;for(;H<t;){let G=e.charCodeAt(H);if(G===91||G===93||G===40||G===41||G===123||G===125||G===124||G===34||G===37)break;H++}Y(46,H)}}break}case 8:{let F=e.charCodeAt(c+1),H;if(v===34)A();else if(v===37&&(H=R(c))>=0)W(H);else if((v===45||v===47||v===41)&&F===41)z(),I(45,c+2);else if(v===40||v===91||v===123)N(v);else if(v===41||v===93||v===125)k=!1;else{let G=c+1;for(;G<t;){let se=e.charCodeAt(G);if(se===34||se===40||se===41||se===91||se===93||se===123||se===125||(se===45||se===47)&&e.charCodeAt(G+1)===41||se===37&&e.charCodeAt(G+1)===37&&e.charCodeAt(G+2)!==123)break;G++}X(46,G)}break}case 9:{let F=e.charCodeAt(c+1);if(v===34){A();break}switch(v){case 40:F===45||F===91||F===40&&e.charCodeAt(c+2)===40?N(v):F===93?(z(),I(58,c+2)):N(v);break;case 91:case 123:N(v);break;case 92:F===93?(z(),I(58,c+2)):I(46,c+1);break;case 47:F===93?(z(),I(59,c+2)):I(46,c+1);break;case 93:case 41:F===93?(z(),I(58,c+2)):k=!1;break;case 125:k=!1;break;case 37:{let H=R(c);H>=0?W(H):k=!1;break}default:{if((v===63||v===61)&&F===93){z(),I(58,c+2);break}let H=c+1;for(;H<t;){let G=e.charCodeAt(H);if(G===92||G===91||G===93||G===40||G===41||G===123||G===125||G===47||G===37)break;H++}Y(46,H)}}break}case 10:{if(v===34){A();break}let F=_(c);if(F>=0){z(),Y(42,F);break}if(v===45&&e.charCodeAt(c+1)===45){k=!1;break}let H=c+1;for(;H<t;){let G=e.charCodeAt(H);if(G===34)break;if(G===45){if(e.charCodeAt(H+1)===45)break}else if(He(G)&&_(H)>=0)break;H++}X(44,H);break}case 11:if(v===34)A();else if(He(v))z(),W(c+1);else{let F=c+1;for(;F<t&&!He(e.charCodeAt(F));)F++;I(19,F)}break;case 12:if(v===40){let F=C(p_,c);z(),F>=0?W(F):(K(13),W(c+1))}else{let F=e.indexOf("(",c);F===-1&&(F=t),Y(8,F)}break;case 13:if(v===41)z(),W(c+1);else{let F=e.indexOf(")",c);F===-1&&(F=t),Y(9,F)}break;case 14:if(v===34)K(15),I(7,c+1);else if(v===125)z(),W(c+1);else if(v===94)k=!1;else{let F=c+1;for(;F<t;){let H=e.charCodeAt(F);if(H===125||H===94||H===34)break;F++}Y(7,F)}break;case 15:if(v===34)z(),I(7,c+1);else{let F=e.indexOf('"',c);F===-1&&(F=t),ee(7,e.slice(c,F).replace(h_,"<br/>"),F)}break}if(!k)return n.push(1),r.push(""),o.push(c),s.push(l,f,l,f),{types:n,texts:r,starts:o,locs:s};continue e}return n.push(0),r.push(""),o.push(t),s.push(l,f,l,f),{types:n,texts:r,starts:o,locs:s}}var wa=new Uint8Array(80);for(let e of[34,67,65,68,13,40,37,38,35,41,69])wa[e]=1;var Nd=new Uint8Array(80);for(let e of[34,69,67,27,65,68,40,37,38,35,41])Nd[e]=1;var Md=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])Md[e]=1;var Id=new Uint8Array(80);for(let e of[34,67,37,78,35,12])Id[e]=1;var Ra=new Uint8Array(80);for(let e of[77,39,79,66])Ra[e]=1;var Nh="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",Cd="'COMMENT', 'SEMI', 'NEWLINE', 'EOF'",to=[],m_=/}[^\S\n]*\n/g;function Ih(e,t,n=!1){let r=!n&&e.includes("}")?e.replace(m_,`}
`):e,{types:o,texts:s,starts:a,locs:i}=Ch(r),c=0,l,f=0,p=0,u=A=>{let N=o[c];throw N===1?st("agentflow",r,a[c],"",!0):st("agentflow",r,a[c],`Expecting ${A}, got '${Rd[N]}'`)},m=(A,N)=>({first_line:i[4*A],first_column:i[4*A+1],last_line:i[4*N+2],last_column:i[4*N+3]}),h=(A,N="")=>(o[c]!==A&&u(`'${Rd[A]}'${N?", "+N:""}`),s[c++]),b=()=>{Ra[o[c]]===0&&u(Cd),c++},x=()=>{wa[o[c]]===0&&u("'NODE_STRING'");let A=s[c++];for(;wa[o[c]]===1;)A+=s[c++];return A},E=()=>{Nd[o[c]]===0&&u("'NODE_STRING'");let A=s[c++];for(;Nd[o[c]]===1;)A+=s[c++];return A},w=()=>{let A=o[c],N;if(A===11)N="string";else if(A===10)N="markdown";else if(A===46||A===62||A===53||A===69)N="text";else return u(`${Nh}, 'TAGEND', 'STR', 'MD_STR'`);let $=s[c++];for(;;){let U=o[c];if(U!==46&&U!==62&&U!==53&&U!==69)break;$+=s[c++]}return{text:$,type:N}},S=A=>{h(A,Nh)},O=()=>{let A=o[c],N;if(A===11)N="string";else if(A===10)N="markdown";else if(A===44||A===69)N="text";else return u("'EDGE_TEXT', 'STR', 'MD_STR'");let $=s[c++];for(;o[c]===44||o[c]===69;)$+=s[c++];return{text:$,type:N}},D=()=>{let A=o[c],N;if(A===11)N="text";else if(A===10)N="markdown";else if(Md[A]===1)N="text";else return u("'NODE_STRING', 'STR', 'MD_STR'");let $=s[c++];for(;Md[o[c]]===1;)$+=s[c++];return{text:$,type:N}},L=()=>{f=c;let A=s[c++];for(;o[c]===7;)A+=s[c++];return p=c-1,A},B=(A,N,$,U)=>{let j=m($,U);t.addVertex(A,void 0,void 0,void 0,void 0,void 0,void 0,N,j),t.extendVertexMapping(A,j)},W=(A,N)=>{N.data!==void 0&&t.addVertex(A,void 0,void 0,void 0,void 0,void 0,void 0,N.data,m(N.dataFrom,N.dataTo))},Y=()=>{let A=c,N=x(),$,U,j;switch(o[c]){case 74:c++,$=w(),S(73),U="square";break;case 57:c++,$=w(),S(56),U="doublecircle";break;case 72:c++,o[c]===72?(c++,$=w(),S(71),h(71),U="circle"):($=w(),S(71),U="round");break;case 47:c++,$=w(),S(45),U="ellipse";break;case 49:c++,$=w(),S(48),U="stadium";break;case 51:c++,$=w(),S(50),U="subroutine";break;case 52:{c++;let v=h(67);h(37);let k=h(67);h(70),$=w(),S(73),U="rect",j={[v]:k};break}case 55:c++,$=w(),S(54),U="cylinder";break;case 76:c++,o[c]===76?(c++,$=w(),S(75),h(75),U="hexagon"):($=w(),S(75),U="diamond");break;case 53:c++,$=w(),S(73),U="odd";break;case 60:c++,$=w(),o[c]===59?(c++,U="lean_right"):(S(58),U="trapezoid");break;case 61:c++,$=w(),o[c]===58?(c++,U="lean_left"):(S(59),U="inv_trapezoid");break}return j!==void 0?t.addVertex(N,$,U,void 0,void 0,void 0,j):U!==void 0?t.addVertex(N,$,U):t.addVertex(N),t.addVertexMapping(N,$,U,m(A,c-1)),N},I=()=>{let A=Y();return o[c]===36&&(c++,t.setClass(A,x())),A},X=()=>{let A=[I()];for(l=void 0;;){let $=o[c]===7?L():void 0,U=f,j=p;if(o[c]!==78)return l=$,A;do c++;while(o[c]===78);if(o[c]!==38)return $!==void 0&&u("'AMP'"),A;c++,o[c]!==78&&u("'SPACE'");do c++;while(o[c]===78);let v=I();$!==void 0&&B(A[A.length-1],$,U,j),A.push(v)}},ee=()=>{let A;if(o[c]===33&&(A=s[c++]),o[c]===42){let N=t.destructLink(s[c++]);return A!==void 0&&(N.id=A),o[c]===70&&(c++,N.text=w(),S(70),o[c]===78&&c++),N}if(o[c]===43){let N=s[c++],$=O(),U=h(42,"'EDGE_TEXT'"),j=t.destructLink(U,N);return j.text=$,A!==void 0&&(j.id=A),j}return u("'LINK', 'START_LINK'")},K=()=>{let A=c,N=X();l!==void 0&&B(N[N.length-1],l,f,p);let $=N;for(;;){let U=o[c];if(U!==42&&U!==43&&U!==33)return $;let j=ee(),v=X();l!==void 0&&B(v[v.length-1],l,f,p),t.addLink(N,v,j),t.addEdgeMapping(N,v,j,m(A,c-1)),$=v.concat($),N=v}},z=()=>{Id[o[c]]===0&&u("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let A=s[c++];for(;Id[o[c]]===1;)A+=s[c++];return A},C=()=>{let A=[z()];for(;o[c]===40;)c++,A.push(z());return A},M=()=>{c++,h(78);let A;if(o[c]===13)A=[s[c++]];else for(A=[h(34,"'DEFAULT'")];o[c]===40;)c++,A.push(h(34));if(h(78),o[c]!==15){t.updateLink(A,C());return}c++,h(78);let N=E();if(o[c]===78){c++;let $=C();t.updateLinkInterpolate(A,N),t.updateLink(A,$)}else t.updateLinkInterpolate(A,N)},T=(A,N)=>{if(o[c]!==78){t.setLink(A,N);return}if(c++,o[c]===25){t.setLink(A,N,s[c++]);return}let $=h(11,"'LINK_TARGET'");o[c]===78?(c++,t.setLink(A,N,h(25))):t.setLink(A,N),t.setTooltip(A,$)},g=()=>{let A=s[c++];switch(o[c]){case 8:{let N=s[c++],$=o[c]===9,U=$?s[c++]:void 0,j;o[c]===78&&(c++,j=h(11)),$?t.setClickEvent(A,N,U):t.setClickEvent(A,N),j!==void 0&&t.setTooltip(A,j);return}case 18:c++,T(A,h(11));return;case 11:T(A,s[c++]);return;default:{let N=E();if(o[c]===78){c++;let $=h(11);t.setClickEvent(A,N),t.setTooltip(A,$)}else t.setClickEvent(A,N)}}},_=A=>{h(78,Cd);let N=D(),$={text:"",type:"text"};o[c]===74&&(c++,$=w(),S(73));let U=o[c]===7?L():void 0;return Ra[o[c]]===0&&u(`${Cd}, 'SHAPE_DATA'`),{global:!1,at:A,id:N,title:$,data:U,dataFrom:f,dataTo:p,list:[],collect:!1}},y=()=>{let A=o[c];switch(A){case 12:{c++,h(78);let N=x();return h(78),t.addVertex(N,void 0,void 0,C()),b(),to}case 14:return M(),b(),to;case 16:{c++,h(78);let N=x();return h(78),t.addClass(N,C()),b(),to}case 17:{c++,h(78);let N=x();return h(78),t.setClass(N,x()),b(),to}case 19:return g(),b(),to;case 22:{let N=_(c++),$=c++,U=t.addConnector(N.id,N.title);return W(U,N),t.addConnectorMapping(N.id,N.title,m(N.at,N.at),m($,$)),U}case 28:case 29:case 30:case 31:case 32:return c++,{stmt:"dir",value:g_[A-28]};case 2:{c++;let N=h(3).trim();return t.setAccTitle(N),N}case 4:{c++;let N=h(5).trim();return t.setAccDescription(N),N}case 6:{let N=s[c++].trim();return t.setAccDescription(N),N}default:{wa[A]===0&&u(Mh);let N=K();return b(),N}}},R=()=>{let A=[],N=[],$=!1;for(;;){let U=o[c];if(U===0)break;if(U===24){let j=A.pop();if(j===void 0)break;let v=c++;if(j.global){t.addGlobal(N),N=j.list,$=j.collect;continue}let k=t.addSubGraph(j.id,N,j.title,"flow");W(k,j),t.addSubgraphMapping(j.id,j.title,m(j.at,j.at),m(v,v)),N=j.list,$=j.collect,$&&N.push(k)}else if(U===39||U===77||U===78||U===79)$&&N.push(s[c]),c++;else if(U===66)c++;else if(U===21||U===23){let j=c++,v;U===23||Ra[o[c]]===1?(v={global:U===23,at:j,id:void 0,title:void 0,data:void 0,dataFrom:0,dataTo:0,list:N,collect:$},b()):(v=_(j),v.list=N,v.collect=$,c++),A.push(v),N=[],$=!0}else{let j=y();$&&(!Array.isArray(j)||j.length>0)&&N.push(j)}}A.length>0&&u("'end'")};for(;o[c]===78||o[c]===77||o[c]===66;)c++;if(h(20,"'SPACE', 'NEWLINE', 'COMMENT'"),o[c]===26)c++,t.setDirection("TB");else{let A=h(27,"'NODIR'"),N=o[c];if(N===78){do c++;while(o[c]===78);N=o[c],N!==77&&u("'NEWLINE', 'SPACE'")}else N!==39&&N!==77&&N!==66&&u("'COMMENT', 'SEMI', 'NEWLINE', 'SPACE'");c++,t.setDirection(A)}R(),o[c]!==0&&u(Mh)}var g_=["TB","BT","RL","LR","TD"],Mh="'COMMENT', 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'flow', 'global', 'connector', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";function xs(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 Ss(e,t,n=1,r=0,o=0){return{tail:e,head:t,minlen:n,labelW:r,labelH:o,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var b_=24,kh=2e4,$d=16,Lh=8,y_=.125,$h=3,E_=18,A_=10,x_=14,S_=2,__=28,Dh=12,w_=12,R_=8,T_=4,Oh=.5,cr=.5,vh=12,C_=40,Ph=400,li=16,kd=new Float64Array(2*li+2),Ld=new Float64Array(2*li+2);function di(e){return e===1||e===2}function Bh(e,t,n,r){for(let o=t+1;o<n;o++){let s=e[o],a=r[s],i=o-1;for(;i>=t&&(r[e[i]]>a||r[e[i]]===a&&e[i]>s);)e[i+1]=e[i],i--;e[i+1]=s}}function N_(e,t,n,r,o,s){let a=(f,p)=>n[f]<n[p]||n[f]===n[p]&&(o?r[f]>r[p]:r[f]<r[p]);for(let f=0;f<t;f+=8)for(let p=f+1,u=Math.min(t,f+8);p<u;p++){let m=e[p],h=p-1;for(;h>=f&&a(m,e[h]);)e[h+1]=e[h],h--;e[h+1]=m}let c=e,l=s;for(let f=8;f<t;f*=2){for(let u=0;u<t;u+=2*f){let m=Math.min(t,u+f),h=Math.min(t,u+2*f),b=u,x=m,E=u;for(;b<m&&x<h;)l[E++]=a(c[x],c[b])?c[x++]:c[b++];for(;b<m;)l[E++]=c[b++];for(;x<h;)l[E++]=c[x++]}let p=c;c=l,l=p}if(c!==e)for(let f=0;f<t;f++)e[f]=c[f]}function Ca(e,t,n){let r=e.length;if(r===0)return{width:0,height:0};let o=t.length;if(r===1&&o===0&&e[0].kind===0){let ce=e[0];return ce.rank=0,ce.x=ce.w/2,ce.y=ce.h/2,{width:ce.w,height:ce.h}}let s=1;if(o>0){let ce=new Set;for(let Se of t){let $e=Math.min(Se.tail,Se.head),Ae=Math.max(Se.tail,Se.head),xe=$e*r+Ae;if(Se.labelW>0||ce.has(xe)){s=2;break}ce.add(xe)}}no(e,t),ro(e,t,s);let a=new Int32Array(o),i=0;for(let ce=0;ce<o;ce++){let Se=t[ce];a[ce]=Math.abs(e[Se.head].rank-e[Se.tail].rank),a[ce]>1&&(i+=a[ce]-1)}let c=new Uint8Array(o);if(i>kh){let ce=[];for(let Se=0;Se<o;Se++)a[Se]>1&&ce.push(Se);ce.sort((Se,$e)=>a[$e]-a[Se]||Se-$e);for(let Se of ce){if(i<=kh)break;c[Se]=1,i-=a[Se]-1}}let l=r+i,f=new Float64Array(l),p=new Float64Array(l),u=new Uint8Array(l),m=new Int32Array(l),h=0;for(let ce=0;ce<r;ce++){let Se=e[ce];f[ce]=Se.w,p[ce]=Se.h,u[ce]=Se.kind,m[ce]=Se.rank,Se.rank>h&&(h=Se.rank)}let b=0;for(let ce=0;ce<o;ce++)c[ce]||(b+=a[ce]);let x=new Int32Array(b),E=new Int32Array(b),w=new Float64Array(b),S=new Float64Array(b),O=new Int32Array(o).fill(-1),D=new Uint8Array(h+1),L=new Int32Array(o).fill(-1),B=!1;for(let ce=0;ce<r;ce++)e[ce].span>0&&e[ce].kind===0&&(B=!0);let W=B?new Uint8Array(b):void 0,Y=B?new Uint8Array(b):void 0,I=new Int32Array(o).fill(-1),X=new Int32Array(o).fill(-1),ee=new Float64Array(l).fill(NaN);for(let ce=0;ce<r;ce++)ee[ce]=e[ce].key;let K=!1;{let ce=r,Se=0;for(let $e=0;$e<o;$e++){if(c[$e])continue;let Ae=t[$e],xe=Ae.reversed?Ae.head:Ae.tail,Oe=Ae.reversed?Ae.tail:Ae.head,ve=Ae.reversed?Ae.headDx:Ae.tailDx,Ge=Ae.reversed?Ae.tailDx:Ae.headDx;(ve!==0||Ge!==0)&&(K=!0);let pe=m[xe],J=m[Oe],_e=-1;Ae.labelW>0&&(_e=pe+(J-pe>>1),s===2&&J-pe>=4?(_e&1)===1&&(_e+=Ae.reversed?1:-1):s===2&&(_e&1)===0&&(_e+=Ae.reversed?1:-1));let le=xe;J-pe>1&&(O[$e]=ce),I[$e]=Se,W&&!(Ae.reversed?Ae.headFixed:Ae.tailFixed)&&(W[Se]=Ae.reversed?2:1);for(let we=pe+1;we<J;we++){let Te=ce++;m[Te]=we,ee[Te]=ee[xe]+(ee[Oe]-ee[xe])*(we-pe)/(J-pe),we===_e?(f[Te]=Ae.labelW,p[Te]=Ae.labelH,u[Te]=2,L[$e]=Te,D[we]|=Ae.reversed?2:1):u[Te]=1,x[Se]=le,E[Se]=Te,w[Se]=le===xe?ve:0,Se++,le=Te}x[Se]=le,E[Se]=Oe,w[Se]=le===xe?ve:0,S[Se]=Ge,Y&&!(Ae.reversed?Ae.tailFixed:Ae.headFixed)&&(Y[Se]=Ae.reversed?1:2),X[$e]=Se,Se++}}let z;if(n.groups){let{of:ce,parent:Se}=n.groups;z=new Int32Array(l);for(let xe=0;xe<r;xe++)z[xe]=ce[xe];let $e=xe=>{let Oe=0;for(;xe>=0;xe=Se[xe])Oe++;return Oe},Ae=(xe,Oe)=>{let ve=$e(xe),Ge=$e(Oe);for(;ve>Ge;ve--)xe=Se[xe];for(;Ge>ve;Ge--)Oe=Se[Oe];for(;xe!==Oe;)xe=Se[xe],Oe=Se[Oe];return xe};for(let xe=0;xe<o;xe++){if(O[xe]<0)continue;let Oe=t[xe],ve=Ae(ce[Oe.tail],ce[Oe.head]);for(let Ge=O[xe],pe=Ge+a[xe]-1;Ge<pe;Ge++)z[Ge]=ve}}let C=new Int32Array(l+1),M=new Int32Array(l+1);for(let ce=0;ce<b;ce++)C[x[ce]+1]++,M[E[ce]+1]++;for(let ce=0;ce<l;ce++)C[ce+1]+=C[ce],M[ce+1]+=M[ce];let T=new Int32Array(b),g=new Int32Array(b);{let ce=C.slice(0,l),Se=M.slice(0,l);for(let $e=0;$e<b;$e++)T[ce[x[$e]]++]=$e,g[Se[E[$e]]++]=$e}let _=new Int32Array(h+2);for(let ce=0;ce<l;ce++)_[m[ce]+1]++;for(let ce=0;ce<=h;ce++)_[ce+1]+=_[ce];let y=new Int32Array(l),R=new Int32Array(l);{let ce=new Int32Array(l),Se=_.slice(0,h+1);for(let xe=0;xe<l;xe++)ce[Se[m[xe]]++]=xe;for(let xe=0;xe<=h;xe++)Se[xe]=_[xe];let $e=new Uint8Array(l),Ae=[];for(let xe=0;xe<l;xe++)if(!$e[ce[xe]])for(Ae.push(ce[xe]);Ae.length>0;){let Oe=Ae.pop();if(!$e[Oe]){$e[Oe]=1,y[Se[m[Oe]]++]=Oe;for(let ve=C[Oe+1]-1;ve>=C[Oe];ve--){let Ge=E[T[ve]];$e[Ge]||Ae.push(Ge)}}}}let A=(ce,Se)=>{let $e=_[ce],Ae=_[ce+1];if(Ae-$e<2)return!1;for(let ve=$e;ve<Ae;ve++)if(Number.isNaN(Se(y[ve])))return!1;let xe=Array.from(y.subarray($e,Ae)),Oe=new Map;return xe.forEach((ve,Ge)=>Oe.set(ve,Ge)),xe.sort((ve,Ge)=>Se(ve)-Se(Ge)||Oe.get(ve)-Oe.get(Ge)),y.set(xe,$e),!0};for(let ce=0;ce<=h;ce++)A(ce,Se=>ee[Se]);let N=!1;for(let ce=0;ce<r;ce++)e[ce].pin!==0&&(N=!0);if(N)for(let ce=0;ce<=h;ce++){let Se=Array.from(y.subarray(_[ce],_[ce+1])),$e=new Map;Se.forEach((xe,Oe)=>$e.set(xe,Oe));let Ae=xe=>xe<r?e[xe].pin:0;Se.sort((xe,Oe)=>Ae(xe)-Ae(Oe)||$e.get(xe)-$e.get(Oe)),y.set(Se,_[ce])}let $=new Uint8Array(h+1),U=ce=>ce<r&&(e[ce].kind===3||e[ce].kind===4)?e[ce].hint:NaN;for(let ce of[0,h])A(ce,U)&&($[ce]=1);let j=()=>{for(let ce=0;ce<=h;ce++){let Se=_[ce];for(let $e=Se,Ae=_[ce+1];$e<Ae;$e++)R[y[$e]]=$e-Se}};j();let v={n:l,real:r,maxRank:h,W:f,KIND:u,RANK:m,EF:x,ET:E,EFD:w,ETD:S,succStart:C,succE:T,predStart:M,predE:g,layerStart:_,order:y,pos:R,offsets:K,fixed:$,GRP:z,groupParent:n.groups?.parent},k=0,F=0;if(b>0&&h>0&&([k,F]=B_(v,e),j()),n.orderOnly){let ce=Fh(v,n);for(let Se=0;Se<r;Se++)e[Se].x=ce[Se];for(let Se=0;Se<o;Se++){let $e=t[Se],Ae=$e.reversed?$e.head:$e.tail,xe=$e.reversed?$e.tail:$e.head,Oe=[m[Ae],ce[Ae]];if(!c[Se]&&O[Se]>=0)for(let ve=O[Se],Ge=ve+a[Se]-1;ve<Ge;ve++)Oe.push(m[ve],ce[ve]);Oe.push(m[xe],ce[xe]),$e.points=Oe}return{width:0,height:0,crossings:k,declared:F}}W&&Y&&M_(v,e,W,Y);let H=Fh(v,n),G=D_(v);if(W&&Y){let ce=I_(v,W,Y);k_(v,e,H,ce,n,G),L_(v,e,H,W,Y,ce,G),$_(v,H,G,n);for(let Se=0;Se<o;Se++){if(c[Se])continue;let $e=t[Se],Ae=w[I[Se]],xe=S[X[Se]];$e.tailDx=$e.reversed?xe:Ae,$e.headDx=$e.reversed?Ae:xe}}let se=new Uint8Array(l);G&&!n.tracks&&v_(v,H,G,O,a,n.apart?0:n.edgeSep,se),n.tracks||P_(v,H,O,a,n.edgeSep,se);let q=new Int32Array(o+1),P=n.tracks||W&&!n.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,V=new Int32Array(h+1);if(P){for(let ce=0;ce<o;ce++){if(q[ce]=P.from.length,c[ce])continue;let Se=O[ce],$e=!1;for(let Oe=Se,ve=Se<0?Se:Se+a[ce]-1;Oe<ve;Oe++){let Ge=G!==void 0&&G[m[Oe]]===1;!n.tracks&&Ge!==(se[Oe]===1)&&($e=!0)}if($e)continue;let Ae=H[x[I[ce]]]+w[I[ce]],xe=m[x[I[ce]]];for(let Oe=Se,ve=Se<0?Se:Se+a[ce]-1;Oe<ve;Oe++)G&&G[m[Oe]]||(P.from.push(Ae),P.to.push(H[Oe]),P.rank.push(xe),P.lower.push(Oe),Ae=H[Oe],xe=m[Oe]);P.from.push(Ae),P.to.push(H[E[X[ce]]]+S[X[ce]]),P.rank.push(xe),P.lower.push(-1)}q[o]=P.from.length}let ne=(ce,Se)=>{let $e=!1;for(let Ae=_[ce];Ae<_[ce+1];Ae++){let xe=u[y[Ae]];if(xe===Se)$e=!0;else if(xe!==1)return!1}return $e},ae=ne(0,3)?s:0,Z=ne(h,4)?s:0,Q=new Float64Array(h+1);for(let ce=0;ce<b;ce++){let Se=Math.abs(H[x[ce]]+w[ce]-H[E[ce]]-S[ce]);Se>Q[m[x[ce]]]&&(Q[m[x[ce]]]=Se)}let ie=new Float64Array(h+1),me=new Float64Array(h+1),re=ce=>(ce<ae||ce>=h-Z?n.portSep:n.rankSep)/s,te=new Float64Array(h+1);for(let ce=0;ce<h;ce++)te[ce]=P?re(ce):Math.max(re(ce),Math.min($h*n.rankSep/s,Q[ce]*y_));let he=new Uint8Array(h+1).fill(1);for(let ce=0;ce<r;ce++)he[m[ce]]=0;for(let ce=1;ce<h;ce++){if(n.tracks||!he[ce]||D[ce]!==1&&D[ce]!==2)continue;let Se=Math.min((n.headRoom??0)/2,te[D[ce]===1?ce-1:ce]/2);te[ce-1]+=D[ce]===1?-Se:Se,te[ce]+=D[ce]===1?Se:-Se}let oe=ce=>u[ce]===1&&he[m[ce]]&&!n.tracks?(me[m[ce]]-ie[m[ce]])/4:0,ge=n.tracks?E_:__,Ee=n.tracks?A_:Dh,be=n.tracks?x_:Dh,ye=new Int32Array(h+1);if(P){let ce=new Float64Array(h+1);for(let $e=0;$e<h;$e++){if(G&&G[$e])continue;let Ae=$e+1;for(ce[$e]=te[$e];Ae<h&&G&&G[Ae];)ce[$e]+=te[Ae++];ye[$e]=Ae}for(let $e=0;$e<P.from.length;$e++)P.wide.push(Math.abs(P.from[$e]-P.to[$e])>S_*ce[P.rank[$e]]?1:0);let Se=new Float64Array(h+1);O_(P,V,!n.tracks,ce,Se);for(let $e=0;$e<h;$e++)V[$e]>0?te[$e]+=Math.max(0,2*ge+(V[$e]-1)*Ee-ce[$e]):Se[$e]>0&&(te[$e]+=Math.max(0,Math.min($h*n.rankSep,Se[$e])-ce[$e]))}let Re=0;for(let ce=0;ce<=h;ce++){let Se=0;for(let $e=_[ce];$e<_[ce+1];$e++)p[y[$e]]>Se&&(Se=p[y[$e]]);ie[ce]=Re,me[ce]=Re+Se,Re+=Se+te[ce]}let Le=Re,ue=(ce,Se=P.track[ce])=>{let $e=P.rank[ce],Ae=me[$e],xe=ie[ye[$e]],Oe=n.tracks?V[$e]:P.levels[ce],ve=Oe>1?Math.min(be,(xe-Ae-2*ge)/(Oe-1)):0;return(Ae+xe)/2+(Se-(Oe-1)/2)*ve},fe=1/0,Me=-1/0;for(let ce=0;ce<l;ce++){let Se=f[ce]/2;H[ce]-Se<fe&&(fe=H[ce]-Se),H[ce]+Se>Me&&(Me=H[ce]+Se)}let Ne=new Uint8Array(h+1),Be=new Uint8Array(h+1);for(let ce=0;ce<r;ce++)u[ce]!==0||!W||(M[ce+1]>M[ce]&&(Ne[m[ce]]=1),C[ce+1]>C[ce]&&(Be[m[ce]]=1));for(let ce=0;ce<r;ce++){let Se=e[ce],$e=Se.rank;Se.x=H[ce]-fe,u[ce]===0&&Be[$e]&&!Ne[$e]?Se.y=me[$e]-Se.h/2:u[ce]===0&&Ne[$e]&&!Be[$e]?Se.y=ie[$e]+Se.h/2:Se.y=(ie[$e]+me[$e])/2}for(let ce=0;ce<o;ce++){let Se=t[ce],$e=e[Se.reversed?Se.head:Se.tail],Ae=e[Se.reversed?Se.tail:Se.head],xe=[$e.x+(Se.reversed?Se.headDx:Se.tailDx),$e.y+$e.h/2],Oe=O[ce];if(P&&q[ce+1]>q[ce])for(let Ge=q[ce];Ge<q[ce+1];Ge++){if(P.track[Ge]>=0&&(n.tracks||P.wide[Ge]===1)){let J=ue(Ge);xe.push(P.from[Ge]-fe,J,P.to[Ge]-fe,J)}else P.track[Ge]>0&&xe.push(P.from[Ge]-fe,ue(Ge,P.track[Ge]-1));let pe=P.lower[Ge];pe<0||(xe.push(H[pe]-fe,ie[m[pe]]+oe(pe)),me[m[pe]]>ie[m[pe]]&&xe.push(H[pe]-fe,me[m[pe]]-oe(pe)))}else if(Oe>=0)for(let Ge=Oe,pe=Oe+a[ce]-1;Ge<pe;Ge++){if(se[Ge])continue;let J=H[Ge]-fe,_e=ie[m[Ge]],le=me[m[Ge]];xe.push(J,_e+oe(Ge)),le>_e&&xe.push(J,le-oe(Ge))}if(xe.push(Ae.x+(Se.reversed?Se.tailDx:Se.headDx),Ae.y-Ae.h/2),Se.reversed)for(let Ge=0,pe=xe.length-2;Ge<pe;Ge+=2,pe-=2){let J=xe[Ge],_e=xe[Ge+1];xe[Ge]=xe[pe],xe[Ge+1]=xe[pe+1],xe[pe]=J,xe[pe+1]=_e}Se.points=xe;let ve=L[ce];ve>=0?(Se.labelX=H[ve]-fe,Se.labelY=(ie[m[ve]]+me[m[ve]])/2):Se.labelW>0&&(Se.labelX=(xe[0]+xe[xe.length-2])/2,Se.labelY=(xe[1]+xe[xe.length-1])/2)}return{width:Me-fe,height:Le}}function no(e,t){let n=e.length,r=t.length,o=new Int32Array(n+1);for(let l=0;l<r;l++){let f=t[l];f.reversed=e[f.head].kind===3||e[f.tail].kind===4,f.reversed||o[f.tail+1]++}for(let l=0;l<n;l++)o[l+1]+=o[l];let s=new Int32Array(o[n]);{let l=o.slice(0,n);for(let f=0;f<r;f++)t[f].reversed||(s[l[t[f].tail]++]=f)}let a=new Uint8Array(n),i=o.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 f=c[c.length-1];if(i[f]<o[f+1]){let p=t[s[i[f]++]],u=p.head;a[u]===1?p.reversed=!0:a[u]===0&&(a[u]=1,c.push(u))}else a[f]=2,c.pop()}}function ro(e,t,n){let r=e.length,o=t.length,s=new Int32Array(o),a=new Int32Array(o),i=new Int32Array(o),c=new Int32Array(r+1),l=new Int32Array(r+1);for(let S=0;S<o;S++){let O=t[S],D=O.reversed?O.head:O.tail,L=O.reversed?O.tail:O.head;s[S]=D,a[S]=L,i[S]=Math.max(1,O.minlen)*n,c[D+1]++,l[L+1]++}for(let S=0;S<r;S++)c[S+1]+=c[S],l[S+1]+=l[S];let f=new Int32Array(o),p=new Int32Array(o);{let S=c.slice(0,r),O=l.slice(0,r);for(let D=0;D<o;D++)f[S[s[D]]++]=D,p[O[a[D]]++]=D}let u=new Int32Array(r),m=new Int32Array(r);for(let S=0;S<r;S++)m[S]=l[S+1]-l[S];let h=new Int32Array(r),b=0;for(let S=0;S<r;S++)m[S]===0&&(h[b++]=S);for(let S=0;S<b;S++){let O=h[S];for(let D=c[O];D<c[O+1];D++){let L=f[D],B=a[L];u[O]+i[L]>u[B]&&(u[B]=u[O]+i[L]),--m[B]===0&&(h[b++]=B)}}for(let S=0;S<8;S++){let O=!1;for(let D=b-1;D>=0;D--){let L=h[D],B=l[L+1]-l[L],W=c[L+1]-c[L];if(B===0&&W===0)continue;let Y=-1/0,I=1/0;for(let ee=l[L];ee<l[L+1];ee++){let K=p[ee];Y=Math.max(Y,u[s[K]]+i[K])}for(let ee=c[L];ee<c[L+1];ee++){let K=f[ee];I=Math.min(I,u[a[K]]-i[K])}let X=u[L];W>B&&I!==1/0?X=I:B>W&&Y!==-1/0&&(X=Y),X!==u[L]&&(u[L]=X,O=!0)}if(!O)break}let x=1/0,E=-1/0,w=!1;for(let S=0;S<r;S++){let O=e[S].kind;O===3&&(w=!0),!(O===3||O===4)&&(u[S]<x&&(x=u[S]),u[S]>E&&(E=u[S]))}x===1/0&&(x=0,E=0);for(let S=0;S<r;S++)e[S].kind===3?u[S]=x-n:e[S].kind===4&&(u[S]=E+n);w&&(x-=n);for(let S=0;S<r;S++)e[S].rank=u[S]-x}function Wh(e,t,n,r,o,s,a){let i=n===0?e.predStart:e.succStart,c=n===0?e.predE:e.succE,l=n===0?e.EF:e.ET,f=e.pos;for(let h=i[t];h<i[t+1];h++)o[c[h]]!==0&&s.push(c[h]);if(s.length<2)return 0;s.sort((h,b)=>f[l[h]]-f[l[b]]||h-b);let p=h=>{let b=0;a[0]=0;for(let x=1;x<s.length;x++){let E=o[s[x]]===o[s[x-1]];a[x]=h(E&&o[s[x]]===1,E),b+=a[x]}return b},u=p(()=>1);if(r/u<Lh&&(u=p(h=>h?.5:1)),r/u<Lh&&(u=p((h,b)=>b?0:1)),u===0)return 0;let m=Math.min($d,r/u);for(let h=1;h<s.length;h++)a[h]*=m;return u*m}function M_(e,t,n,r){let{real:o,W:s,EFD:a,ETD:i}=e;for(let c=0;c<o;c++){let l=Math.min(t[c].span,s[c]);if(!(l<=0||t[c].kind!==0))for(let f=0;f<2;f++){let p=[],u=[],m=Wh(e,c,f,l,f===0?r:n,p,u);if(m===0)continue;let h=f===0?i:a,b=-m/2;for(let x=0;x<p.length;x++)b+=u[x],h[p[x]]=b}}}function Ta(e,t,n,r){if(!t)return n;let{KIND:o,RANK:s,EF:a,ET:i,succStart:c,succE:l,predStart:f,predE:p}=e;for(let u=0;u<1e5;u++){let m=r===0?a[n]:i[n];if(o[m]!==1||!t[s[m]])break;n=r===0?p[f[m]]:l[c[m]]}return n}function I_(e,t,n){let r=[new Int32Array(e.n),new Int32Array(e.n)];for(let o=0;o<e.EF.length;o++)n[o]!==0&&r[0][e.ET[o]]++,t[o]!==0&&r[1][e.EF[o]]++;return r}function ui(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function k_(e,t,n,r,o,s){let a=o.edgeSep,{n:i,real:c,maxRank:l,KIND:f,RANK:p,W:u,EF:m,ET:h,EFD:b,ETD:x,succStart:E,succE:w,predStart:S,predE:O,layerStart:D,order:L,pos:B}=e,W=z=>f[z]===2||f[z]===1&&!(s!==void 0&&s[p[z]]===1),Y=(z,C)=>{let M=C===0?m[z]:h[z];return[C===0?n[M]+b[z]:n[M]+x[z],M<c&&t[M].kind===0?r[1-C][M]:0]},I=z=>{let C=D[p[z]],M=C+B[z],T=g=>u[g]/2+u[z]/2+(f[g]===0?o.nodeSep/2+a/2:f[g]===f[z]?a:a/2);return[M>C?n[L[M-1]]+T(L[M-1]):-1/0,M+1<D[p[z]+1]?n[L[M+1]]-T(L[M+1]):1/0]},X=(z,C,M,T,g)=>{let y=(C[1]!==M[1]?C[1]<M[1]:Math.abs(C[0]-z)<=Math.abs(M[0]-z))?[C[0],M[0]]:[M[0],C[0]];return y.find(R=>R>=T&&R<=g)??Math.max(T,Math.min(g,y[0]))},ee=new Uint8Array(i),K=[];for(let z=1;z<l;z++)for(let C=D[z];C<D[z+1];C++){if(!W(L[C])||ee[L[C]])continue;let M=L[C];for(;di(f[m[O[S[M]]]]);)M=m[O[S[M]]];let T=M,g=-1/0,_=1/0;K.length=0;for(let y=M;di(f[y]);y=h[w[E[y]]]){if(T=y,!W(y))continue;ee[y]=1,K.push(y);let[R,A]=I(y);R>g&&(g=R),A<_&&(_=A)}if(g<=_){let y=X(n[K[0]],Y(O[S[M]],0),Y(w[E[T]],1),g,_);for(let R of K)n[R]=y;continue}for(let y of K){let[R,A]=I(y);R>A||(n[y]=X(n[y],Y(Ta(e,s,O[S[y]],0),0),Y(Ta(e,s,w[E[y]],1),1),R,A))}}}function L_(e,t,n,r,o,s,a){let{real:i,W:c,EF:l,ET:f,EFD:p,ETD:u,succStart:m,succE:h,predStart:b,predE:x,pos:E}=e,w=(O,D,L,B,W)=>{if(s[D][L]<2)return 0;O=Ta(e,a,O,D);let Y=D===0?l[O]:f[O],I=D===0?n[Y]+p[O]:n[Y]+u[O];if(W&&Math.abs(I-n[L])<=B/2+cr)return Math.max(-B/2,Math.min(B/2,I-n[L]));let X=I,ee=0;Y<i&&t[Y].kind===0&&(D===0?r:o)[O]!==0&&s[1-D][Y]>=2&&(ee=Math.max(0,Math.min(t[Y].span,c[Y])),ee>0&&(X=n[Y]));let K=Math.max(n[L]-B/2,X-ee/2),z=Math.min(n[L]+B/2,X+ee/2);if(K>z+cr){let M=Math.max(0,B/2-C_);return Math.max(-M,Math.min(M,I-n[L]))}let C=(n[L]*ee+X*B)/(ee+B);return Math.max(K,Math.min(z,C))-n[L]},S=[];for(let O=0;O<i;O++){let D=Math.min(t[O].span,c[O]);if(!(D<=0||t[O].kind!==0))for(let L=0;L<2;L++){let B=L===0?l:f,W=L===0?b:m,Y=L===0?x:h,I=[],X=[];if(Wh(e,O,L,D,L===0?o:r,I,X),I.length===0)continue;I.length===1&&(X[0]=0);let ee=[];for(let K=W[O];K<W[O+1];K++)ee.push(Y[K]);ee.sort((K,z)=>E[B[K]]-E[B[z]]||K-z),S.push({v:O,side:L,span:D,ids:I,room:X,all:ee})}}for(let O=0,D=!0;D&&O<6;O++){D=!1;for(let{v:L,side:B,span:W,ids:Y,room:I,all:X}of S){let ee=B===0?o:r,K=B===0?u:p,z=0,C=-W/2;for(let M=0;M<=X.length;M++){let T=M<X.length&&ee[X[M]]===0;if(M<X.length&&!T)continue;let g=0;for(let y=M-1;y>=0&&ee[X[y]]!==0;y--)g++;let _=T?K[X[M]]-$d:W/2;if(g>0){let y=[],R=[],A=0;for(let U=0;U<g;U++){U>0&&(A+=I[z+U]),y.push(w(Y[z+U],B,L,W,O>0)-A),R.push(1);let j=U>0&&I[z+U]===0;for(;y.length>1&&(j||y[y.length-2]/R[R.length-2]>y[y.length-1]/R[R.length-1]);){j=!1;let v=y.pop(),k=R.pop();y[y.length-1]+=v,R[R.length-1]+=k}}let N=A,$=0;A=0;for(let U=0;U<y.length;U++){let j=_-N<C?(C+_-N)/2:Math.max(C,Math.min(_-N,y[U]/R[U]));for(let v=0;v<R[U];v++,$++)$>0&&(A+=I[z+$]),Math.abs(K[Y[z+$]]-j-A)>.01&&(D=!0),K[Y[z+$]]=j+A}z+=g}T&&(C=K[X[M]]+$d)}}}}function $_(e,t,n,r){let{n:o,KIND:s,RANK:a,EF:i,ET:c,EFD:l,ETD:f,layerStart:p,order:u,pos:m}=e,h=I=>n!==void 0&&s[I]===1&&n[a[I]]===1,b=[],x=[],E=[],w=[];for(let I=0;I<i.length;I++){if(h(i[I]))continue;let X=Ta(e,n,I,1);b.push(i[I]),x.push(c[X]),E.push(l[I]),w.push(f[X])}let S=I=>t[x[I]]+w[I]-t[b[I]]-E[I],O=new Int32Array(o),D=[];for(let I=0;I<o;I++)O[I]=I,D.push([I]);let L=(I,X)=>{let ee=O[I],K=O[X];if(ee!==K){D[ee].length<D[K].length&&([ee,K]=[K,ee]);for(let z of D[K])O[z]=ee,D[ee].push(z);D[K]=[]}},B=[];for(let I=0;I<b.length;I++){let X=Math.abs(S(I));X<.01?L(b[I],x[I]):X<=vh&&B.push(I)}if(B.length===0)return;B.sort((I,X)=>Math.abs(S(I))-Math.abs(S(X))||I-X);let W=I=>Uh(e,r,I),Y=(I,X)=>{for(let ee of D[I]){let K=p[a[ee]],z=p[a[ee]+1],C=K+m[ee];if(C>K&&O[u[C-1]]!==I&&t[ee]+X-t[u[C-1]]<W(ee)+W(u[C-1])-.01||C+1<z&&O[u[C+1]]!==I&&t[u[C+1]]-t[ee]-X<W(ee)+W(u[C+1])-.01)return!1}return!0};for(let I of B){let X=S(I);if(Math.abs(X)<.01){L(b[I],x[I]);continue}if(Math.abs(X)>vh||O[b[I]]===O[x[I]])continue;let ee=O[b[I]],K=O[x[I]],z=D[ee].length<=D[K].length?ee:K;for(let C of[z,z===ee?K:ee]){let M=C===ee?X:-X;if(Y(C,M)){for(let T of D[C])t[T]+=M;L(b[I],x[I]);break}}}}function D_(e){let{maxRank:t,KIND:n,layerStart:r,order:o}=e,s=new Uint8Array(t+1),a=!1;for(let i=1;i<t;i++){let c=r[i+1]>r[i];for(let l=r[i];c&&l<r[i+1];l++)n[o[l]]!==1&&(c=!1);c&&(s[i]=1,a=!0)}return a?s:void 0}function O_(e,t,n,r,o){let{from:s,to:a,rank:i,track:c,levels:l,wide:f}=e,p=s.length,u=new Map;for(let I=0;I<p;I++){if(c.push(-1),l.push(0),Math.abs(s[I]-a[I])<cr)continue;let X=u.get(i[I]);X?X.push(I):u.set(i[I],[I])}if(u.size===0)return;let m=new Float64Array(p),h=new Float64Array(p);for(let I=0;I<p;I++)m[I]=Math.min(s[I],a[I]),h[I]=Math.max(s[I],a[I]);let b=(I,X)=>I>=m[X]-cr&&I<=h[X]+cr?1:0,x=(I,X)=>Math.abs(s[I]-s[X])<cr||Math.abs(a[I]-a[X])<cr,E=(I,X)=>m[I]<h[X]-cr&&m[X]<h[I]-cr,w=(I,X)=>E(I,X)&&!x(I,X),S=(I,X)=>E(I,X)||b(a[I],X)+b(s[X],I)+b(a[X],I)+b(s[I],X)>0,O=(I,X)=>b(a[I],X)+b(s[X],I),D=I=>{let X=I.map((K,z)=>z).sort((K,z)=>m[I[K]]-m[I[z]]),ee=[];for(let K=0;K<X.length;K++){let z=X[K],C=h[I[z]]+4*cr;for(let M=K+1;M<X.length&&m[I[X[M]]]<=C;M++){let T=X[M];ee.push(Math.min(z,T),Math.max(z,T))}}return ee},L=I=>{I.sort(($,U)=>h[U]-m[U]-(h[$]-m[$])||m[$]-m[U]||$-U);let X=I.length,ee=[],K=I.map(($,U)=>U),z=$=>{for(;K[$]!==$;)$=K[$]=K[K[$]];return $},C=X<=Ph,M=C?D(I):[],T=C?I.map(()=>[]):[];for(let $=0;$<M.length;$+=2){let U=M[$],j=M[$+1];w(I[U],I[j])&&(T[U].push(j),T[j].push(U))}let g=I.map(($,U)=>U);if(C){let $=new Int32Array(X),U=[];for(let v=0;v<X;v++)ee.push([]),U.push([]);for(let v=0;v<M.length;v+=2){let k=M[v],F=M[v+1],H=I[k],G=I[F];if(!S(H,G))continue;K[z(k)]=z(F);let se=O(H,G),q=O(G,H);if(se===q)continue;let P=se<q?k:F,V=se<q?F:k;ee[V].push(P),U[P].push(V),$[V]++}let j=new Uint8Array(X);g=[];for(let v=0;v<X;v++){let k=-1;for(let F=0;F<X&&!(!j[F]&&((k<0||$[F]<$[k])&&(k=F),$[F]===0));F++);j[k]=1,g.push(k);for(let F of U[k])$[F]--}}let _=new Set,y=[],R=0;for(let $ of g){let U=I[$],j=0;for(let v of ee[$]??[])c[I[v]]>=j&&(j=c[I[v]]+1);if(C){_.clear();for(let v of T[$])_.add(c[I[v]]);for(;_.has(j);)j++}else{for(;y[j]?.some(v=>w(U,v));)j++;(y[j]??=[]).push(U)}c[U]=j,j>=R&&(R=j+1)}let A=new Int32Array(X).fill(R),N=new Int32Array(X).fill(-1);for(let $=0;$<X;$++){let U=z($);A[U]=Math.min(A[U],c[I[$]]),N[U]=Math.max(N[U],c[I[$]])}for(let $=0;$<X;$++){let U=z($);l[I[$]]=N[U]-A[U]+1,n&&(c[I[$]]-=A[U])}return R},B=(I,X,ee)=>{let K=ui(a[I]-s[I],X);for(let z=0;z<=li;z++){let C=z/li,M=1-C;ee[2*z]=s[I]+(a[I]-s[I])*C*C*(3-2*C),ee[2*z+1]=X*(3*K*C*M*M+3*(1-K)*C*C*M+C*C*C)}},W=(I,X,ee)=>{let K=ee*ee*1.000000001;for(let z=0;z<=li;z++){let C=I[2*z],M=I[2*z+1];for(let T=0;T<li;T++){let g=X[2*T+2]-X[2*T],_=X[2*T+3]-X[2*T+1],y=Math.max(0,Math.min(1,((C-X[2*T])*g+(M-X[2*T+1])*_)/(g*g+_*_||1))),R=C-X[2*T]-y*g,A=M-X[2*T+1]-y*_;if(R*R+A*A<K&&Math.hypot(R,A)<ee)return!0}}return!1},Y=(I,X,ee,K)=>{let z=Math.max(ee/2,ee-2*w_);return B(I,z,kd),B(X,z,Ld),W(kd,Ld,K)||W(Ld,kd,K)};for(let[I,X]of u){if(!n){t[I]=L(X);continue}if(X.length>Ph)continue;let ee=X.filter(y=>f[y]===1);L(ee);let K=new Set(ee.filter(y=>l[y]>1)),z=D(X);for(let y=0;y<z.length;y+=2){let R=X[z[y]],A=X[z[y+1]];K.has(R)&&K.has(A)||!w(R,A)||s[R]<a[R]!=s[A]<a[A]||Y(R,A,r[I],f[R]===1||f[A]===1?R_:T_)&&K.add(R).add(A)}for(let y of ee)c[y]=-1,l[y]=0;if(K.size===0)continue;let C=0,M=0,T=new Set;for(let y=0;y<z.length;y+=2){let R=X[z[y]],A=X[z[y+1]];if(K.has(R)&&K.has(A)){if(!E(R,A))continue;s[R]<a[R]!=s[A]<a[A]?C++:x(R,A)||M++}else(K.has(R)||K.has(A))&&S(R,A)&&T.add(R).add(A)}if(C>M){for(let y of X)(h[y]-m[y])*Oh>o[I]&&(o[I]=(h[y]-m[y])*Oh);continue}let g=X.filter(y=>K.has(y)||f[y]!==1&&T.has(y));L(g);let _=0;for(let y of g)l[y]>_&&(_=l[y]);t[I]=_}}function v_(e,t,n,r,o,s,a){let{maxRank:i,EF:c,ET:l,EFD:f,ETD:p,succStart:u,succE:m,predStart:h,predE:b,layerStart:x,order:E}=e,w=new Float64Array(t.length),S=new Float64Array(t.length),O=new Float64Array(t.length);for(let L=0;L<r.length;L++){let B=r[L];if(B<0)continue;let W=B+o[L]-1,Y=e.RANK[B];for(let I=B;I<W;I++){if(!n[Y+I-B])continue;let X=I;for(;X+1<W&&n[Y+X+1-B];)X++;let ee=b[h[I]],K=m[u[X]],z=t[c[ee]]+f[ee],C=t[l[K]]+p[K],M=X-I+2;for(let T=I;T<=X;T++)w[T]=z+(C-z)*(T-I+1)/M,S[T]=z,O[T]=C;I=X}}let D=[];for(let L=1;L<i;L++){if(!n[L])continue;let B=x[L],W=x[L+1],Y=Array.from(E.subarray(B,W)).sort((I,X)=>S[I]-S[X]||O[I]-O[X]||I-X);for(let I=0;I<Y.length;){D.length=0;let X=I;for(;X<Y.length&&Math.abs(S[Y[X]]-S[Y[I]])<1&&Math.abs(O[Y[X]]-O[Y[I]])<1;X++)D.push(Y[X]);D.sort((ee,K)=>e.pos[ee]-e.pos[K]);for(let ee=0;ee<D.length;ee++){let K=D[ee];t[K]=w[K]+(ee-(D.length-1)/2)*s,(D.length===1||s===0)&&(a[K]=1)}I=X}}}function P_(e,t,n,r,o,s){let{maxRank:a,W:i,KIND:c,RANK:l,EF:f,ET:p,EFD:u,ETD:m,succStart:h,succE:b,predStart:x,predE:E,layerStart:w,order:S}=e,O=new Uint8Array(a+1),D=!1;for(let L=1;L<a;L++){let B=!1,W=!1;for(let Y=w[L];Y<w[L+1];Y++){let I=c[S[Y]];I===2?B=!0:I!==1&&(W=!0)}B&&!W&&(O[L]=1,D=!0)}if(D)for(let L=0;L<n.length;L++){let B=n[L];if(!(B<0))for(let W=B,Y=B+r[L]-1;W<Y;W++){if(c[W]!==1||!O[l[W]])continue;let I=W,X=W;for(;I>B&&s[I-1];)I--;for(;X+1<Y&&s[X+1];)X++;let ee=E[x[I]],K=b[h[X]],z=t[f[ee]]+u[ee],C=t[p[K]]+m[K],M=Math.min(z,C)-o,T=Math.max(z,C)+o,g=!0,_=l[W];for(let R=w[_];g&&R<w[_+1];R++){let A=S[R];c[A]===2&&t[A]+i[A]/2>M&&t[A]-i[A]/2<T&&(g=!1)}if(!g)continue;s[W]=1;let y=X-I+2;for(let R=I;R<=X;R++)t[R]=z+(C-z)*(R-I+1)/y}}}function B_(e,t){let{n,real:r,maxRank:o,W:s,EF:a,ET:i,EFD:c,ETD:l,succStart:f,succE:p,predStart:u,predE:m,layerStart:h,order:b,pos:x,offsets:E,fixed:w,GRP:S,groupParent:O}=e,D=0;for(let Q=0;Q<=o;Q++)D=Math.max(D,h[Q+1]-h[Q]);if(D<2)return[0,0];let L=E?new Int32Array(a.length):void 0,B=new Int32Array(L?a.length:0),W=new Int32Array(L?n:0),Y=L?p.slice():p,I=new Uint8Array(L?n:0);if(L){let Q=m.slice(),ie=(me,re,te,he)=>{for(let oe=re+1;oe<te;oe++)if(he[me[oe]]!==he[me[re]])return me.subarray(re,te).sort((ge,Ee)=>he[ge]-he[Ee]),!0;return!1};for(let me=0;me<n;me++){if(W[me]=1,ie(Q,u[me],u[me+1],l))for(let re=u[me]+1;re<u[me+1];re++)l[Q[re]]!==l[Q[re-1]]&&W[me]++,B[Q[re]]=W[me]-1;ie(Y,f[me],f[me+1],c)&&(I[me]=1)}}let X=1;for(;X<(L?D+a.length:D);)X<<=1;let ee=new Int32Array(2*X),K=new Int32Array(a.length),z=()=>{let Q=0;for(let ie=0;ie<o;ie++){let me=h[ie+2]-h[ie+1];if(L){let he=0;for(let oe=h[ie+1];oe<h[ie+2];oe++){let ge=b[oe];for(let Ee=u[ge];Ee<u[ge+1];Ee++)L[m[Ee]]=he+B[m[Ee]];he+=W[ge]}me=he}if(me<2)continue;let re=0;for(let he=h[ie];he<h[ie+1];he++){let oe=b[he],ge=f[oe],Ee=f[oe+1],be=re;for(let Re=ge;Re<Ee;Re++)K[re++]=L?L[Y[Re]]:x[i[p[Re]]];let ye=re-be;if(!(ye<2))if(L&&I[oe])for(let Re=be+1;Re<re;Re++){let Le=K[Re],ue=c[Y[ge+Re-be]],fe=Re-1;for(;fe>=be&&c[Y[ge+fe-be]]===ue&&K[fe]>Le;)K[fe+1]=K[fe],fe--;K[fe+1]=Le}else if(ye<=12)for(let Re=be+1;Re<re;Re++){let Le=K[Re],ue=Re-1;for(;ue>=be&&K[ue]>Le;)K[ue+1]=K[ue],ue--;K[ue+1]=Le}else K.subarray(be,re).sort()}if(re<2)continue;let te=1;for(;te<me;)te<<=1;ee.fill(0,0,2*te);for(let he=0;he<re;he++){let oe=K[he]+te;for(ee[oe]++;oe>1;)(oe&1)===0&&(Q+=ee[oe+1]),oe>>=1,ee[oe]++}}return Q},C=z(),M=new Float64Array(n),T=new Int32Array(D),g=new Int32Array(D),_=O?O.length:0,y=new Int32Array(_);for(let Q=0;Q<_;Q++)for(let ie=Q;ie>=0;ie=O[ie])y[Q]++;let R=new Float64Array(_),A=new Int32Array(_),N=new Int32Array(_),$=(Q,ie)=>{let me=h[Q],re=h[Q+1];for(let Ee=me;Ee<re;Ee++)for(let be=S[b[Ee]];be>=0;be=O[be])R[be]=0,A[be]=0;for(let Ee=me;Ee<re;Ee++){let be=b[Ee];for(let ye=S[be];ye>=0;ye=O[ye])A[ye]===0&&(N[ye]=Ee),R[ye]+=ie[be],A[ye]++}let te=Ee=>Ee>=n?R[Ee-n]/A[Ee-n]:ie[Ee],he=Ee=>Ee>=n?N[Ee-n]:me+x[Ee],oe=(Ee,be)=>{let ye=Ee,Re=be,Le=S[Ee],ue=S[be],fe=Le<0?0:y[Le],Me=ue<0?0:y[ue];for(;fe>Me;fe--)ye=n+Le,Le=O[Le];for(;Me>fe;Me--)Re=n+ue,ue=O[ue];for(;Le!==ue;)ye=n+Le,Le=O[Le],Re=n+ue,ue=O[ue];return te(ye)-te(Re)||he(ye)-he(Re)},ge=Array.from(b.subarray(me,re)).sort(oe);b.set(ge,me);for(let Ee=me;Ee<re;Ee++)x[b[Ee]]=Ee-me};if(S){let Q=new Float64Array(n);for(let ie=0;ie<=o;ie++){for(let me=h[ie];me<h[ie+1];me++)Q[b[me]]=me-h[ie];$(ie,Q)}}let U=S?z():C;if(U===0)return[0,C];let j=b.slice(),v=Math.min(U,C),k=(Q,ie)=>{let me=Q?u:f,re=Q?m:p,te=Q?a:i,he=Q?c:l;for(let oe=1;oe<=o;oe++){let ge=Q?oe:o-oe;if(w[ge])continue;let Ee=h[ge],be=h[ge+1],ye=0;for(let Le=Ee;Le<be;Le++){let ue=b[Le],fe=ue<r?t[ue].pin:0;if(fe!==0){M[ue]=fe*1e9,T[ye++]=ue;continue}let Me=me[ue],Ne=me[ue+1];if(Me===Ne){if(S){let ce=Q?h[ge]-h[ge-1]:h[ge+2]-h[ge+1];M[ue]=(Le-Ee)*ce/(be-Ee);continue}M[ue]=-1;continue}let Be=0;for(let ce=Me;ce<Ne;ce++){let Se=te[re[ce]];Be+=x[Se],E&&s[Se]>0&&(Be+=he[re[ce]]/s[Se])}M[ue]=Be/(Ne-Me),T[ye++]=ue}if(S){$(ge,M);continue}if(ye<2)continue;N_(T,ye,M,x,ie,g);let Re=0;for(let Le=Ee;Le<be;Le++)M[b[Le]]!==-1&&(b[Le]=T[Re++]);for(let Le=Ee;Le<be;Le++)x[b[Le]]=Le-Ee}},F=()=>{let Q=0;for(let ie=0;ie<=o;ie++)for(let me=h[ie];me<h[ie+1];me++)if(!(b[me]>=r))for(let re=me+1;re<h[ie+1];re++)b[re]<b[me]&&Q++;return Q},H=()=>{for(let Q=0;Q<=o;Q++)for(let ie=h[Q];ie<h[Q+1];ie++)x[b[ie]]=ie-h[Q]},G=Q=>Q<r?t[Q].pin:0,se=(Q,ie)=>{let me=ie?a[Q]:i[Q];return E&&s[me]>0?x[me]+(ie?c[Q]:l[Q])/s[me]:x[me]},q=(Q,ie)=>{let me=0;for(let re=u[Q];re<u[Q+1];re++){let te=se(m[re],!0);for(let he=u[ie];he<u[ie+1];he++)te>se(m[he],!0)&&me++}for(let re=f[Q];re<f[Q+1];re++){let te=se(p[re],!1);for(let he=f[ie];he<f[ie+1];he++)te>se(p[he],!1)&&me++}return me},P=()=>{for(let Q=0;Q<8;Q++){let ie=!1;for(let me=0;me<=o;me++){if(w[me])continue;let re=h[me];for(let te=re;te+1<h[me+1];te++){let he=b[te],oe=b[te+1];G(he)!==G(oe)||S&&S[he]!==S[oe]||q(oe,he)>=q(he,oe)||(b[te]=oe,b[te+1]=he,x[oe]=te-re,x[he]=te+1-re,ie=!0)}}if(!ie)break}},V=b.slice(),ne=n<=600,ae=j,Z=1/0;for(let Q=0;Q<(ne?2:1);Q++){Q>0&&(b.set(V),H());let ie=v,me=V.slice();for(let te=0,he=0;he<4&&te<b_;te++,he++){k((te+Q)%2===0,te%4>=2);let oe=z();if(oe<ie&&(ie=oe,me.set(b),he=0,oe===0))break}if(b.set(me),ne&&ie>0){H(),P();let te=z();te<ie&&(ie=te,me.set(b))}let re=ne?F():0;(Q===0||ie<U||ie===U&&re<Z)&&(U=ie,ae=me,Z=re)}if(b.set(ae),H(),j.set(ae),S&&(U=z()),!ne)return[U,C];for(let Q=0;Q<r;Q++)if(t[Q].pin!==0)return[U,C];if(Z===0||w[0]||w[o])return[U,C];for(let Q=0;Q<=o;Q++)b.subarray(h[Q],h[Q+1]).reverse();return H(),(z()>U||F()>=Z)&&b.set(j),[U,C]}function Uh(e,t,n){return e.W[n]/2+(e.KIND[n]===0?t.nodeSep:t.edgeSep)/2}function Fh(e,t){let{n,maxRank:r,W:o,KIND:s,EF:a,ET:i,EFD:c,ETD:l,succStart:f,succE:p,predStart:u,predE:m,layerStart:h,order:b,pos:x}=e,E=a.length,w=new Float64Array(n);for(let N=0;N<n;N++)w[N]=Uh(e,t,N);let S=new Int32Array(E);for(let N=0;N<E;N++)S[N]=x[i[N]];for(let N=0;N<n;N++)f[N+1]-f[N]>1&&Bh(p,f[N],f[N+1],S);for(let N=0;N<E;N++)S[N]=x[a[N]];for(let N=0;N<n;N++)u[N+1]-u[N]>1&&Bh(m,u[N],u[N+1],S);let O=new Uint8Array(E);for(let N=1;N<=r;N++){let $=h[N]-h[N-1],U=h[N],j=h[N+1],v=0,k=U;for(let F=U;F<j;F++){let H=b[F],G=-1;if(di(s[H])){let q=a[m[u[H]]];di(s[q])&&(G=q)}let se=G>=0?x[G]:$;if(G>=0||F===j-1){for(let q=k;q<=F;q++){let P=b[q],V=di(s[P]);for(let ne=u[P];ne<u[P+1];ne++){let ae=m[ne],Z=x[a[ae]];(Z<v||se<Z)&&!(V&&di(s[a[ae]]))&&(O[ae]=1)}}k=F+1,v=se}}}let D=[],L=new Int32Array(n),B=new Int32Array(n),W=new Float64Array(n),Y=new Int32Array(n),I=new Int32Array(n),X=new Float64Array(n),ee=new Int32Array(n),K=new Int32Array(n+1),z=new Int32Array(n),C=new Int32Array(n),M=new Int32Array(n),T=new Float64Array(n);for(let N=0;N<4;N++){let $=N<2,U=(N&1)===1,j=$?u:f,v=$?m:p,k=$?a:i,F=$?l:c,H=$?c:l;for(let P=0;P<n;P++)L[P]=P,B[P]=P,W[P]=0,ee[P]=0,K[P+1]=0,T[P]=0;for(let P=0;P<=r;P++){let V=$?P:r-P,ne=h[V],ae=h[V+1],Z=$?V-1:V+1,Q=Z>=0&&Z<=r?h[Z+1]-h[Z]-1:0,ie=-1;for(let me=U?ae-1:ne;U?me>=ne:me<ae;U?me--:me++){let re=b[me],te=j[re],he=j[re+1]-te;if(he===0)continue;let oe=te+(he-1>>1),ge=te+(he>>1);for(let Ee=0;Ee<2&&!(Ee===1&&oe===ge);Ee++){let be=v[Ee===0!==U?oe:ge],ye=k[be],Re=U?Q-x[ye]:x[ye];B[re]===re&&ie<Re&&O[be]===0&&(B[ye]=re,B[re]=L[re]=L[ye],W[re]=W[ye]+H[be]-F[be],ie=Re)}}}let G=0;for(let P=0;P<=r;P++){let V=h[P],ne=h[P+1];for(let ae=V+1;ae<ne;ae++){let Z=U?b[ae]:b[ae-1],Q=U?b[ae-1]:b[ae],ie=w[Z]+w[Q];Y[G]=L[Z],I[G]=L[Q],X[G]=U?ie-W[Z]+W[Q]:ie+W[Z]-W[Q],ee[L[Q]]++,K[L[Z]+1]++,G++}}for(let P=0;P<n;P++)K[P+1]+=K[P];for(let P=0;P<n;P++)C[P]=K[P];for(let P=0;P<G;P++)z[C[Y[P]]++]=P;let se=0;for(let P=0;P<n;P++)L[P]===P&&ee[P]===0&&(M[se++]=P);for(let P=0;P<se;P++){let V=M[P];for(let ne=K[V];ne<K[V+1];ne++){let ae=z[ne],Z=I[ae];T[V]+X[ae]>T[Z]&&(T[Z]=T[V]+X[ae]),--ee[Z]===0&&(M[se++]=Z)}}for(let P=se-1;P>=0;P--){let V=M[P],ne=1/0;for(let ae=K[V];ae<K[V+1];ae++){let Z=z[ae],Q=T[I[Z]]-X[Z];Q<ne&&(ne=Q)}ne!==1/0&&ne>T[V]&&(T[V]=ne)}let q=new Float64Array(n);for(let P=0;P<n;P++)q[P]=(U?-T[L[P]]:T[L[P]])+W[P];D.push(q)}let g=0,_=1/0,y=[],R=[];for(let N=0;N<4;N++){let $=1/0,U=-1/0,j=D[N];for(let v=0;v<n;v++){let k=o[v]/2;j[v]-k<$&&($=j[v]-k),j[v]+k>U&&(U=j[v]+k)}y.push($),R.push(U),U-$<_&&(_=U-$,g=N)}for(let N=0;N<4;N++){let $=(N&1)===0?y[g]-y[N]:R[g]-R[N];if($!==0){let U=D[N];for(let j=0;j<n;j++)U[j]+=$}}let A=new Float64Array(n);for(let N=0;N<n;N++){let $=D[0][N],U=D[1][N],j=D[2][N],v=D[3][N],k;$>U&&(k=$,$=U,U=k),j>v&&(k=j,j=v,v=k),$>j&&(k=$,$=j,j=k),U>v&&(k=U,U=v,v=k),U>j&&(k=U,U=j,j=k),A[N]=(U+j)/2}return A}function rn(e){return e==="BT"||e==="LR"||e==="RL"?e:"TB"}var F_=4e4,W_=400,U_=500,G_=1.5,Y_=4;function Gh(e,t,n,r){let o=[];for(let i of e)o.push(i.x,i.y,i.w,i.h);let s=[];for(let i of t)s.push(i.labelX,i.labelY);let a=[];for(let i of n){a.push(i.x,i.y);for(let c of i.ports)a.push(c.px,c.py)}return{nodes:o,routes:t.map(i=>i.route),labels:s,levels:a,total:r}}function Yh(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 o=0;for(let s of r){s.x=e.levels[o++],s.y=e.levels[o++];for(let a of s.ports)a.px=e.levels[o++],a.py=e.levels[o++]}return e.total}var Hh=24,fi=.5,Dd=3,Od=2,H_=Math.max(3,Dd,Od+1),Na=.62,K_=128;function z_(e){return e.tracks?1:e.straight?2:0}function Ma(e,t,n=0){let r=0;for(let C of t)C.src!==C.dst&&C.route.length>3&&(r+=(C.route.length/3-1)*H_);let o=new Float64Array(r),s=new Float64Array(r),a=new Float64Array(r),i=new Float64Array(r),c=new Float64Array(r),l=new Float64Array(r),f=new Int32Array(r),p=new Uint8Array(r),u=0,m=1/0,h=-1/0,b=NaN,x=NaN,E=NaN,w=NaN,S=(C,M,T,g,_,y)=>{let R=u-1;T===E&&g===w&&(y===g&&x===g||_===T&&b===T)&&f[R]===C&&p[R]===M&&(T-b)*(_-T)+(g-x)*(y-g)>0&&(u--,T=b,g=x),b=T,x=g,E=_,w=y,p[u]=M,o[u]=Math.min(T,_),a[u]=Math.max(T,_),s[u]=T<=_?g:y,i[u]=T<=_?y:g,c[u]=Math.min(g,y),l[u]=Math.max(g,y),c[u]<m&&(m=c[u]),l[u]>h&&(h=l[u]),f[u++]=C};for(let C=0;C<t.length;C++){let M=t[C];if(M.src===M.dst)continue;let T=M.route,g=N=>Math.abs(T[N]-T[N-3])<.01||Math.abs(T[N+1]-T[N-2])<.01,_=N=>Math.abs(T[N]-T[N-3])+Math.abs(T[N+1]-T[N-2]),y=N=>n===0&&N>0&&N<T.length-3&&g(N)&&g(N+3)&&_(N)>=.01&&_(N+3)>=.01&&Math.abs(T[N]-T[N-3])<.01!=Math.abs(T[N+3]-T[N])<.01,R=T[0],A=T[1];for(let N=3;N<T.length;N+=3){let $=(N===3?1:0)|(N===T.length-3?2:0),U=R,j=A,v=T[N],k=T[N+1];if(R=v,A=k,g(N)||n===2){if(!y(N)){S(C,$,U,j,v,k);continue}let q=y(N-3)?_(N)/2:_(N),P=y(N+3)?_(N+3)/2:_(N+3),V=(v-T[N-3])/_(N),ne=(k-T[N-2])/_(N),ae=(T[N+3]-v)/_(N+3),Z=(T[N+4]-k)/_(N+3),Q=v-V*q,ie=k-ne*q;S(C,$,U,j,Q,ie);let me=v-V*q*(1-Na),re=k-ne*q*(1-Na),te=v+ae*P*(1-Na),he=k+Z*P*(1-Na);R=v+ae*P,A=k+Z*P;let oe=$|(N+3===T.length-3?2:0),ge=Q,Ee=ie;for(let be=1;be<=Od;be++){let ye=be/Od,Re=1-ye,Le=Re*Re*Re*Q+3*Re*Re*ye*me+3*Re*ye*ye*te+ye*ye*ye*R,ue=Re*Re*Re*ie+3*Re*Re*ye*re+3*Re*ye*ye*he+ye*ye*ye*A;S(C,oe,ge,Ee,Le,ue),ge=Le,Ee=ue}continue}if(n===1){let q=T[N+2]===0,P=q?U:(U+v)/2,V=q?(j+k)/2:j;S(C,$,U,j,P,V),S(C,$,P,V,q?v:P,q?V:k),S(C,$,q?v:P,q?V:k,v,k);continue}let F=T[N+2]===0,H=F?ui(v-U,k-j):ui(k-j,v-U),G=U,se=j;for(let q=1;q<=Dd;q++){let P=q/Dd,V=1-P,ne=P*P*(3-2*P),ae=3*H*P*V*V+3*(1-H)*P*P*V+P*P*P,Z=U+(v-U)*(F?ne:ae),Q=j+(k-j)*(F?ae:ne);S(C,$,G,se,Z,Q),G=Z,se=Q}}}let O=h>m?Math.round(Math.sqrt(u)):1,D=h>m?O/(h-m):0,L=C=>Math.min(O-1,Math.floor((C-m)*D)),B=new Int32Array(u),W=new Int32Array(O+1);for(let C=0;C<u;C++){B[C]=L(c[C]);for(let M=B[C],T=L(l[C]);M<=T;M++)W[M+1]++}for(let C=0;C<O;C++)W[C+1]+=W[C];let Y=W.slice(0,O),I=new Int32Array(W[O]);for(let C=0;C<u;C++)for(let M=B[C],T=L(l[C]);M<=T;M++)I[Y[M]++]=C;let X=new Float64Array(t.length*8),ee=(C,M,T,g)=>Math.abs(C[M]-C[T])<fi&&Math.abs(C[M]-C[g])<fi||Math.abs(C[M+1]-C[T+1])<fi&&Math.abs(C[M+1]-C[g+1])<fi;for(let C=0;C<t.length;C++){let M=t[C].route;if(M.length<6)continue;let T=3;for(;T+3<M.length&&ee(M,0,T,T+3);)T+=3;let g=M.length-3,_=g-3;for(;_>=3&&ee(M,g,_,_-3);)_-=3;X.set([M[0],M[1],M[T],M[T+1],M[_],M[_+1],M[g],M[g+1]],C*8)}let K=(C,M,T,g)=>{let _=C*8+(M===1?0:4),y=X[_],R=X[_+1],A=X[_+2]-y,N=X[_+3]-R,$=A*A+N*N,U=$>0?Math.max(0,Math.min(1,((T-y)*A+(g-R)*N)/$)):0;return Math.hypot(T-y-U*A,g-R-U*N)<fi},z=0;for(let C=0;C<O;C++){let M=W[C+1];if(M-W[C]>K_)I.subarray(W[C],M).sort((T,g)=>o[T]-o[g]||T-g);else for(let T=W[C]+1;T<M;T++){let g=I[T],_=T;for(;_>W[C]&&o[I[_-1]]>o[g];_--)I[_]=I[_-1];I[_]=g}for(let T=W[C];T<M;T++){let g=I[T],_=a[g]-o[g],y=i[g]-s[g],R=B[g]===C;for(let A=T+1;A<M;A++){let N=I[A];if(o[N]>a[g])break;if(l[N]<c[g]||c[N]>l[g]||f[g]===f[N]||!R&&B[N]!==C)continue;let $=_*(s[N]-s[g])-y*(o[N]-o[g]),U=_*(i[N]-s[g])-y*(a[N]-o[g]);if($>0==U>0)continue;let j=a[N]-o[N],v=i[N]-s[N],k=j*(s[g]-s[N])-v*(o[g]-o[N]),F=j*(i[g]-s[N])-v*(a[g]-o[N]);if(k>0==F>0)continue;let H=t[f[g]],G=t[f[N]],se=k/(k-F),q=o[g]+se*_,P=s[g]+se*y,V=(ne,ae,Z)=>(p[g]&ae)!==0&&(p[N]&Z)!==0||Math.abs(q-e[ne].x)<e[ne].w/2+Hh&&Math.abs(P-e[ne].y)<e[ne].h/2+Hh||K(f[g],ae,q,P)&&K(f[N],Z,q,P);H.src===G.src&&V(H.src,1,1)||H.src===G.dst&&V(H.src,1,2)||H.dst===G.src&&V(H.dst,2,1)||H.dst===G.dst&&V(H.dst,2,2)||z++}}}return z}function Gr(e,t,n,r){for(let o of e)o.x+=n,o.y+=r;for(let o of t){for(let s=0;s<o.route.length;s+=3)o.route[s]+=n,o.route[s+1]+=r;o.labelX+=n,o.labelY+=r}}function Pt(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 Ia(e){return e==="TB"?0:e==="BT"?2:e==="LR"?3:1}function so(e){return e+2&3}function Rn(e,t,n,r){let o=e.length,s=new Map,a=[],i=(M,T)=>{let g={id:M,dir:T,items:[],edges:[],ports:[],portOf:new Map,routes:new Map,x:0,y:0};return s.set(M,g),g},c=i(-1,n),l=[];for(let M=0;M<o;M++)l.push([]);let f=[];for(let M=0;M<o;M++){let T=e[M].parent;T>=0&&T<o&&T!==M&&e[T].isGroup?l[T].push(M):(e[M].parent=-1,f.push(M))}c.items=f,a.push(c);let p=new Int32Array(o),u=new Uint8Array(o),m=M=>{for(let T=M;T<a.length;T++){let g=a[T];for(let _ of g.items)if(u[_]=1,p[_]=g.id<0?0:p[g.id]+1,e[_].isGroup){let y=i(_,e[_].dir??g.dir);y.items=l[_],a.push(y)}}};m(0);for(let M=0;M<o;M++){if(u[M])continue;let T=e[M].parent;if(l[T]=l[T].filter(g=>g!==M),e[M].parent=-1,c.items.push(M),u[M]=1,p[M]=0,e[M].isGroup){let g=a.length,_=i(M,e[M].dir??n);_.items=l[M],a.push(_),m(g)}}for(let M=a.length-1;M>0;M--){let T=a[M],g=1/0;for(let _ of T.items)e[_].seq<g&&(g=e[_].seq);g!==1/0&&(e[T.id].seq=g)}for(let M of a)M.items.sort((T,g)=>e[T].seq-e[g].seq||T-g);let h=0;for(let M of t){let T=M.src,g=M.dst,_=0;for(;p[T]>p[g];_++)T=e[T].parent;for(;p[g]>p[T];_++)g=e[g].parent;for(;T!==g&&e[T].parent!==e[g].parent;_+=2)T=e[T].parent,g=e[g].parent;T!==g&&(h+_>F_?(M.src=T,M.dst=g):h+=_)}let b=[],x=[];for(let M=0;M<t.length;M++){let T=t[M];if(T.route=[],T.src===T.dst){b.push(M);continue}let g=T.src,_=T.dst,y=[],R=[];for(;p[g]>p[_];)y.push(g),g=e[g].parent;for(;p[_]>p[g];)R.push(_),_=e[_].parent;if(g===_){x.push(M);continue}for(;e[g].parent!==e[_].parent;)y.push(g),R.push(_),g=e[g].parent,_=e[_].parent;s.get(e[g].parent).edges.push({e:M,a:g,b:_});for(let[A,N]of[[y,!0],[R,!1]])for(let $ of A){let U=s.get(e[$].parent),j={e:M,inner:$,out:N,side:0,hint:NaN,px:0,py:0,route:[]};U.ports.push(j),U.portOf.set(M*2+(N?0:1),j)}}let E=new Int32Array(o),w=(M,T,g)=>(g?T.src:T.dst)!==M,S=(M,T)=>{let g=M.dir==="TB"||M.dir==="BT",_=Ia(M.dir),y=[],R=[];M.items.forEach((U,j)=>{E[U]=j;let v=e[U],k=T?xs(g?v.w:v.h,g?v.h:v.w):xs(0,0);k.span=v.isGroup?Math.min(v.span,k.w-2*v.padX):v.span,k.key=L?D[U]:NaN,y.push(k)});let A=(U,j,v)=>e[U].isGroup&&w(U,t[j],v),N=(U,j,v)=>{if(!T||!e[U].isGroup||!w(U,t[j],v))return 0;let k=s.get(U).portOf.get(j*2+(v?0:1));return g?k.px-e[U].w/2:k.py-e[U].h/2};for(let U of M.edges){let j=t[U.e],v=Ss(E[U.a],E[U.b],j.minlen);T&&(v.labelW=g?j.labelW:j.labelH,v.labelH=g?j.labelH:j.labelW,v.tailDx=N(U.a,U.e,!0),v.headDx=N(U.b,U.e,!1),v.tailFixed=A(U.a,U.e,!0),v.headFixed=A(U.b,U.e,!1)),R.push(v)}let $=new Int32Array(M.ports.length).fill(-1);return M.ports.forEach((U,j)=>{if(U.side===_||U.side===so(_)){let v=y.length,k=xs(0,0,U.side===_?3:4);k.key=L?D[U.out?t[U.e].dst:t[U.e].src]:NaN,k.hint=Number.isNaN(U.hint)&&L&&W?W(M,U):U.hint,y.push(k),$[j]=v;let F=U.out?Ss(E[U.inner],v):Ss(v,E[U.inner]);U.out?(F.tailDx=N(U.inner,U.e,!0),F.tailFixed=A(U.inner,U.e,!0)):(F.headDx=N(U.inner,U.e,!1),F.headFixed=A(U.inner,U.e,!1)),R.push(F)}else y[E[U.inner]].pin=U.side===0||U.side===3?-1:1}),{lnodes:y,ledges:R,dummies:$}},O=h>1&&h<=W_&&t.length<=U_,D=new Float64Array(o).fill(NaN),L=!1,B=0,W,Y=a.length>1&&O;for(let M of a)M.dir!==n&&(Y=!1);if(Y){let M=n==="TB"||n==="BT",T=new Int32Array(o).fill(-1),g=new Int32Array(o).fill(-1),_=[],y=[],R=[];for(let k=0;k<o;k++)e[k].isGroup&&(g[k]=R.length,R.push(-1));for(let k=0;k<o;k++){let F=e[k].parent;e[k].isGroup?R[g[k]]=F>=0?g[F]:-1:(T[k]=_.length,_.push(xs(M?e[k].w:e[k].h,M?e[k].h:e[k].w)),y.push(F>=0?g[F]:-1))}let A=[],N=new Int32Array(t.length).fill(-1);t.forEach((k,F)=>{k.src===k.dst||T[k.src]<0||T[k.dst]<0||(N[F]=A.length,A.push(Ss(T[k.src],T[k.dst],k.minlen,M?k.labelW:k.labelH,M?k.labelH:k.labelW)))});let $=Ca(_,A,{...r,groups:{of:Int32Array.from(y),parent:Int32Array.from(R)},orderOnly:!0});B=Math.min($.crossings??0,$.declared??0);let U=new Float64Array(o),j=new Int32Array(o),v=new Int32Array(o).fill(-1);for(let k=0;k<o;k++)if(!(T[k]<0)){D[k]=_[T[k]].x;for(let F=e[k].parent;F>=0;F=e[F].parent)U[F]+=D[k],j[F]++,v[F]=Math.max(v[F],_[T[k]].rank)}for(let k=0;k<o;k++)j[k]>0&&(D[k]=U[k]/j[k]);W=(k,F)=>{let H=N[F.e];if(H<0||k.id<0||!F.out||F.side!==so(Ia(k.dir)))return NaN;let G=A[H].points,se=D[t[F.e].src],q=0;for(let P=0;P<G.length;P+=2)G[P]===v[k.id]&&(se=G[P+1]),G[P]===v[k.id]+1&&(q=G[P+1]);return se+q*1e-6}}let I=new Map,X=(M,T,g)=>{if(!O)return{lnodes:T,ledges:g,size:Ca(T,g,r)};let _=[];for(let A of T)_.push(A.w,A.h,A.kind,A.pin,A.hint,A.key,A.span);for(let A of g)_.push(A.tail,A.head,A.minlen,A.labelW,A.labelH,A.tailDx,A.headDx,+A.tailFixed,+A.headFixed);let y=I.get(M.id);y||I.set(M.id,y=[]);for(let A of y){let N=A.given.length===_.length;for(let $=0;N&&$<_.length;$++)N=Object.is(A.given[$],_[$]);if(N)return A}let R={given:_,lnodes:T,ledges:g,size:Ca(T,g,r)};return y.push(R),R},ee={width:0,height:0},K=()=>{for(let T of a){for(let A of T.ports)e[A.inner].isGroup&&w(A.inner,t[A.e],A.out)&&(s.get(A.inner).portOf.get(A.e*2+(A.out?0:1)).side=A.side);if(T.edges.length===0)continue;let g=!1;for(let A of T.edges){let N=t[A.e];(e[A.a].isGroup&&N.src!==A.a||e[A.b].isGroup&&N.dst!==A.b)&&(g=!0)}if(!g)continue;let{lnodes:_,ledges:y}=S(T,!1);no(_,y),ro(_,y,1);let R=Ia(T.dir);T.edges.forEach((A,N)=>{let $=t[A.e],U=!y[N].reversed;e[A.a].isGroup&&$.src!==A.a&&(s.get(A.a).portOf.get(A.e*2).side=U?so(R):R),e[A.b].isGroup&&$.dst!==A.b&&(s.get(A.b).portOf.get(A.e*2+1).side=U?R:so(R))})}for(let T=a.length-1;T>=0;T--){let g=a[T],_=g.id>=0?e[g.id]:void 0,y=g.dir==="TB"||g.dir==="BT",R=g.dir==="BT"||g.dir==="RL",A=S(g,!0),{lnodes:N,ledges:$,size:U}=X(g,A.lnodes,A.ledges),j=A.dummies,v=y?U.width:U.height,k=y?U.height:U.width,F=_?_.padX:0,H=_?_.padTop:0,G=Math.max(v+2*F,_?_.minW:0),se=k+H+(_?_.padBottom:0),q=(G-v)/2,P=H,V=(ie,me)=>q+(y?ie:R?U.height-me:me),ne=(ie,me)=>P+(y?R?U.height-me:me:ie),ae=y?0:1,Z=ie=>{let me=[];for(let re=0;re<ie.length;re+=2)me.push(V(ie[re],ie[re+1]),ne(ie[re],ie[re+1]),ae);return me};g.items.forEach((ie,me)=>{e[ie].x=V(N[me].x,N[me].y),e[ie].y=ne(N[me].x,N[me].y)}),g.edges.forEach((ie,me)=>{let re=$[me];g.routes.set(ie.e,Z(re.points));let te=t[ie.e];te.labelW>0&&(te.labelX=V(re.labelX,re.labelY),te.labelY=ne(re.labelX,re.labelY))});let Q=g.edges.length;g.ports.forEach((ie,me)=>{let re=e[ie.inner];if(j[me]>=0){let be=Z($[Q++].points),ye=ie.out?be.length-3:0,Re=be[ye],Le=be[ye+1];ie.side===0?Le=0:ie.side===2?Le=se:ie.side===3?Re=0:Re=G,ie.out?be.push(Re,Le,ae):be.unshift(Re,Le,ae),ie.px=Re,ie.py=Le,ie.route=be;return}let te=re.x,he=re.y;if(re.isGroup&&w(ie.inner,t[ie.e],ie.out)){let be=s.get(ie.inner).portOf.get(ie.e*2+(ie.out?0:1));te+=be.px-re.w/2,he+=be.py-re.h/2}else ie.side===0?he-=re.h/2:ie.side===2?he+=re.h/2:ie.side===3?te-=re.w/2:te+=re.w/2;let oe=te,ge=he;ie.side===0?ge=0:ie.side===2?ge=se:ie.side===3?oe=0:oe=G;let Ee=ie.side===0||ie.side===2?0:1;ie.px=oe,ie.py=ge,ie.route=ie.out?[te,he,Ee,oe,ge,Ee]:[oe,ge,Ee,te,he,Ee]}),_?(_.w=G,_.h=se):ee={width:G,height:se}}for(let T of a){let g=T.x,_=T.y;for(let y of T.items){let R=e[y];if(R.x+=g,R.y+=_,R.isGroup){let A=s.get(y);A.x=R.x-R.w/2,A.y=R.y-R.h/2}}}let M=(T,g,_,y)=>{for(let R=0;R<g.length;R+=3){let A=g[R]+_,N=g[R+1]+y,$=T.length;$>=3&&Math.abs(T[$-3]-A)<.01&&Math.abs(T[$-2]-N)<.01||T.push(A,N,g[R+2])}};for(let T of a)for(let g of T.edges){let _=t[g.e],y=[],R=[];for(let N=_.src;e[N].parent!==T.id;N=e[N].parent)R.push(s.get(e[N].parent));for(let N of R)M(y,N.portOf.get(g.e*2).route,N.x,N.y);M(y,T.routes.get(g.e),T.x,T.y);let A=[];for(let N=_.dst;e[N].parent!==T.id;N=e[N].parent)A.push(s.get(e[N].parent));for(let N=A.length-1;N>=0;N--)M(y,A[N].portOf.get(g.e*2+1).route,A[N].x,A[N].y);_.route=y,_.labelW>0&&(_.labelX+=T.x,_.labelY+=T.y)}},z=z_(r);L=Y,K();let C=-1;if(Y&&(C=Ma(e,t,z),C>B*G_+Y_)){let M=Gh(e,t,a,ee);L=!1,K();let T=Ma(e,t,z);T>=C?(L=!0,ee=Yh(M,e,t,a)):C=T}if(L===Y&&O){let M=!1;for(let T of a){if(T.id<0)continue;let g=e[T.id],_=T.dir==="TB"||T.dir==="BT",y=so(Ia(T.dir)),R=[];for(let A of T.ports){if(A.side!==y)continue;let N=t[A.e].route,$=T.x+A.px,U=T.y+A.py,j=-1;for(let F=0;F<N.length&&(j<0||A.out);F+=3)Math.abs(N[F]-$)<.01&&Math.abs(N[F+1]-U)<.01&&(j=F);if(j<0)continue;let v=_?0:1,k=A.out?j+3:j-3;for(;k>=0&&k<N.length&&Math.abs(N[k+v]-N[j+v])<fi;)k+=A.out?3:-3;k<0||k>=N.length||(A.hint=N[k+v]-(_?g.x-g.w/2:g.y-g.h/2),R.push([_?A.px:A.py,A.hint]))}R.sort((A,N)=>A[0]-N[0]);for(let A=1;A<R.length;A++)R[A-1][1]>R[A][1]&&(M=!0)}if(M){let T=C>=0?C:Ma(e,t,z),g=T>0?Gh(e,t,a,ee):void 0;g&&(K(),Ma(e,t,z)>=T&&(ee=Yh(g,e,t,a)))}}for(let M of x){let T=t[M],g=e[T.src],_=e[T.dst];T.route=[g.x,g.y,0,_.x,_.y,0],T.labelX=(g.x+_.x)/2,T.labelY=(g.y+_.y)/2}for(let M of b){let T=t[M],g=e[T.src];T.labelX=g.x+g.w/2+28+T.labelW/2,T.labelY=g.y}return ee}function qn(e,t){for(let n=0;n<t.length;n+=3){let r=Math.round(t[n+1]),o=e.get(r);o?o.push(t[n]):e.set(r,[t[n]])}}function Yr(e,t,n,r){if(t===0)return e.x;let o=e.y-e.h/2,s=e.x-e.w/2,a=t/2,i=[s+r-6+a,e.x,s+e.w-r+6-a],c=n.get(Math.round(o));if(c===void 0)return i[0];let l=i[0],f=-1;for(let p of i){let u=1/0;for(let m of c)m>s&&m<s+e.w&&(u=Math.min(u,Math.abs(m-p)-a));if(u>=6)return p;u>f+.5&&(f=u,l=p)}return l}function ka(e,t,n,r){let o=t>0?r.get(Math.round(e.y-e.h/2)):void 0;if(o===void 0)return!1;let s=e.x-e.w/2;for(let a of o)if(a>s&&a<s+e.w&&Math.abs(a-n)<t/2+4)return!0;return!1}function La(e,t,n,r,o,s,a,i){let c=1;for(let f=s[a].parent;f>=0&&c<8;f=s[f].parent)c++;let l=`color-mix(in srgb,var(--_a) ${d(100*(1-.5**c))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${o}">`+De(e,t,n,` fill="none" stroke="${l}" stroke-width="5" stroke-linejoin="round"`,i)+De(e,t,n,r,i)+"</g>"}var Ot=8,V_=12,$a=.62,io=6;function Da(){let e=new Map;return{add(t,n,r){let o=mt(r);n>=0&&o>0&&o+io>(e.get(t*4+n)??0)&&e.set(t*4+n,o+io)},of:(t,n)=>n>=0?e.get(t*4+n)??0:0}}function xn(e,t,n,r,o=n>0?n+io:0,s=r>0?r+io:0){let a=t==="linear",i=t==="step"||t==="stepBefore"||t==="stepAfter",c=[],l=[],f=[],p=(g,_,y,R)=>Math.abs(g-y)<.01&&Math.abs(_-R)<.01;for(let g=0;g<e.length;g+=3){let _=e[g],y=e[g+1],R=e[g+2],A=c.length-1;if(i&&A>=0&&Math.abs(_-c[A])>=.01&&Math.abs(y-l[A])>=.01){let N=c[A],$=l[A],U=t==="stepBefore"?$:t==="stepAfter"?y:($+y)/2,j=t==="stepBefore"?N:t==="stepAfter"?_:(N+_)/2,v=R===0?[N,U,_,U]:[j,$,j,y];for(let k=0;k<4;k+=2)p(v[k],v[k+1],N,$)||p(v[k],v[k+1],_,y)||(c.push(v[k]),l.push(v[k+1]),f.push(R))}c.push(_),l.push(y),f.push(R)}let u=c.length-1,m=g=>Math.abs(c[g]-c[g-1])<.01||Math.abs(l[g]-l[g-1])<.01,h=g=>a||m(g),b=(g,_,y)=>{if(!h(Math.max(g,_)))return y===0?[0,Math.sign(l[_]-l[g])||1]:[Math.sign(c[_]-c[g])||1,0];let R=c[_]-c[g],A=l[_]-l[g],N=Math.hypot(R,A)||1;return[R/N,A/N]},[x,E]=b(0,1,f[1]),[w,S]=b(u-1,u,f[u]),O=c[0],D=l[0],L=c[u],B=l[u];c[0]+=x*n,l[0]+=E*n,c[u]-=w*r,l[u]-=S*r;let W=g=>Math.abs(c[g]-c[g-1])+Math.abs(l[g]-l[g-1]),Y=g=>!a&&g>0&&g<u&&m(g)&&m(g+1)&&W(g)>=.01&&W(g+1)>=.01&&Math.abs(c[g]-c[g-1])<.01!=Math.abs(c[g+1]-c[g])<.01,I=(g,_,y)=>Math.abs(c[g]-c[g-1])*Math.abs(_)+Math.abs(l[g]-l[g-1])*Math.abs(y),X=(g,_,y)=>{let R=Math.min(Math.max(0,g-io-_),y/4);return R+Math.min(g-_-R,(y-R)/4)},ee=s>r&&(!h(u)||Y(u-1))?X(s,r,I(u,w,S)):0,K=o>n&&(!h(1)||Y(1))?X(o,n,I(1,x,E)):0;ee>=1&&(c.splice(u,0,c[u]-w*ee),l.splice(u,0,l[u]-S*ee),f.splice(u,0,f[u]),u++),K>=1&&(c.splice(1,0,c[0]+x*K),l.splice(1,0,l[0]+E*K),f.splice(1,0,f[1]),u++);let z=`M${d(c[0])},${d(l[0])}`,C=c[0],M=l[0],T=(g,_)=>{p(g,_,C,M)||(z+=`L${d(g)},${d(_)}`,C=g,M=_)};for(let g=1;g<=u;g++){let _=c[g],y=l[g];if(!h(g)){let v=f[g]===0,k=v?y-M:_-C,F=Math.abs(k)*ui(v?_-C:y-M,k),H=v?0:Math.sign(k)*F,G=v?Math.sign(k)*F:0;z+=`C${d(C+H)},${d(M+G)} ${d(_-H)},${d(y-G)} ${d(_)},${d(y)}`,C=_,M=y;continue}if(!Y(g)){if(g<u&&m(g)&&m(g+1)&&(_-c[g-1])*(c[g+1]-_)+(y-l[g-1])*(l[g+1]-y)>0)continue;T(_,y);continue}let R=Y(g-1)?W(g)/2:W(g),A=Y(g+1)?W(g+1)/2:W(g+1);i&&(R=A=Math.min(V_,R,A));let[N,$]=b(g-1,g,f[g]),[U,j]=b(g,g+1,f[g+1]);T(_-N*R,y-$*R),C=_+U*A,M=y+j*A,i?z+=`Q${d(_)},${d(y)} ${d(C)},${d(M)}`:z+=`C${d(_-N*R*(1-$a))},${d(y-$*R*(1-$a))} ${d(_+U*A*(1-$a))},${d(y+j*A*(1-$a))} ${d(C)},${d(M)}`}return{d:z,sx:O,sy:D,sdx:-x,sdy:-E,ex:L,ey:B,edx:w,edy:S}}function mt(e){return e==="arrow_point"?Ot-1:e==="arrow_circle"?Ot:e==="arrow_cross"?4:0}function Et(e,t,n,r,o,s){let a=-o,i=r;if(e==="arrow_point"){let c=t-r*Ot,l=n-o*Ot,f=Ot*.42;return`<path class="pele-marker" d="M${d(t)},${d(n)}L${d(c+a*f)},${d(l+i*f)}L${d(c-a*f)},${d(l-i*f)}Z" fill="${s}" stroke="none"/>`}if(e==="arrow_circle")return`<circle class="pele-marker" cx="${d(t-r*4)}" cy="${d(n-o*4)}" r="3.5" fill="${s}" stroke="none"/>`;if(e==="arrow_cross"){let c=t-r*4,l=n-o*4,f=3.5,p=(r+a)*f,u=(o+i)*f,m=(r-a)*f,h=(o-i)*f;return`<path class="pele-marker" d="M${d(c-p)},${d(l-u)}L${d(c+p)},${d(l+u)}M${d(c-m)},${d(l-h)}L${d(c+m)},${d(l+h)}"/>`}return""}function sn(e,t,n,r,o,s){let a=t.width+8,i=t.height;return`<g class="pele-edge-label" data-id="${Fe(e)}"><rect x="${d(n-a/2)}" y="${d(r-i/2)}" width="${d(a)}" height="${d(i)}" rx="3" fill="var(--_bg)"/>`+De(t,n,r,o,s)+"</g>"}function Oa(e,t,n,r,o,s,a,i){let c=(o?t:n)/2,l=Math.min(c-4,8+r*6),f=s+r*8,p=Math.hypot(f,l)||1,u=(b,x)=>o?`${d(e.x+x)},${d(e.y+n/2+b)}`:`${d(e.x+t/2+b)},${d(e.y+x)}`,m=f/p*a,h=l/p*a;return o?(i.labelX=e.x,i.labelY=e.y+n/2+f+4+i.labelH/2):(i.labelX=e.x+t/2+f+4+i.labelW/2,i.labelY=e.y),{d:`M${u(0,-l)}C${u(f,-l*2)} ${u(f,l*2)} ${u(m,l+h)}`,sx:o?e.x-l:e.x+t/2,sy:o?e.y+n/2:e.y-l,sdx:o?0:-1,sdy:o?-1:0,ex:o?e.x+l:e.x+t/2,ey:o?e.y+n/2:e.y+l,edx:o?-l/p:-f/p,edy:o?-f/p:-l/p}}var jh="--_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)",oo="var(--_fm)",Xh="var(--pele-radius,4px)",it=' style="rx:var(--_r)"';function pt(e){let t=e.indexOf(' style="');return t<0?e+it:`${e.slice(0,t+8)}rx:var(--_r);${e.slice(t+8)}`}var ao="var(--pele-critical,#e45756)",Kh=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,j_=new RegExp(String.raw`^\s*${Kh}(?:\s*,\s*${Kh})*\s*$`,"u");function zh(e,t){return e&&j_.test(e)?e:t}function qh(e,t,n){return`;--_fm:var(--pele-font-mono,${zh(n,"monospace")});font:${e}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${zh(t,"sans-serif")})`}var X_=new Set(["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","opacity","rx","ry"]),q_=new Set(["color","font-size","font-family","font-weight","font-style","text-decoration","letter-spacing","word-spacing","opacity"]),Q_=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,Vh={shape:"",line:"",text:"",stroke:void 0,bold:!1,italic:!1,fontSize:void 0};function St(e){if(e.length===0)return Vh;let t=new Map,n=new Map;for(let l of e){let f=l.indexOf(":");if(f<=0)continue;let p=l.slice(0,f).trim().toLowerCase(),u=l.slice(f+1).replace(/!important/gi,"").trim();u===""||Q_.test(u)||(X_.has(p)&&t.set(p,u),q_.has(p)&&n.set(p==="color"?"fill":p,u))}if(t.size===0&&n.size===0)return Vh;let r="",o="";for(let[l,f]of t)r+=`${l}:${f};`,l!=="fill"&&l!=="fill-opacity"&&(o+=`${l}:${f};`);let s="";for(let[l,f]of n)s+=`${l}:${f};`;let a=n.get("font-weight"),i=n.get("font-size"),c=i&&/^[\d.]+(px)?$/.test(i)?parseFloat(i):void 0;return{shape:r?` style="${je(r)}"`:"",line:o?` style="${je(o)}"`:"",text:s?` style="${je(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 Z_=/[^\w-]+/g;function Rt(e){let t=e.replace(Z_," ").trim();return t===""?"":" "+t}var J_=["#4c78a8","#f58518","#54a24b","#e45756","#72b7b2","#eeca3b","#b279a2","#9d755d"];function lt(e){let t=(e%8+8)%8;return`var(--pele-series-${t+1},${J_[t]})`}var ew=[["tw","title"],["hw","heading"],["w","bold"]],tw=/var\(--_(r|tw|hw|w)\)/g;function Ze(e,t,n,r,o,s,a){let i=je(o.idPrefix??"pele"),c="",l="";s.accTitle&&(c+=`<title id="${i}-title">${Fe(s.accTitle)}</title>`,l+=` aria-labelledby="${i}-title"`),s.accDescr&&(c+=`<desc id="${i}-desc">${Fe(s.accDescr)}</desc>`,l+=` aria-describedby="${i}-desc"`);let f=o.responsive===!1?"":"max-width:100%;height:auto;",p=new Set;for(let[,m]of a.matchAll(tw))if(p.add(m),p.size===4)break;let u=p.has("r")?`;--_r:${Xh}`:"";for(let[m,h]of ew)p.has(m)&&(u+=`;--_${m}:var(--pele-${h}-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="${f}${jh}${u}${je(qh(r,o.fontFamily,o.fontFamilyMono))}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${e}"${l}>`+c+a+"</svg>"}var gt=18,At=12,hi=12,Ln=(e,t,n)=>(n?t:e)-2*hi,co=e=>(t,n,r)=>r?0:t-2*e(n)-2*hi;function Fa(e,t,n){let r=Math.min(1,Math.abs(e)/t);return n*(1-Math.sqrt(1-r*r))}var _s=(e,t,n,r)=>n&1?Fa(r,t/2,e/2):Fa(r,e/2,t/2),ws=(e,t,n)=>(n?t:e)*.6,Qh=(e,t,n,r)=>n&1?0:Fa(r,e/2,Math.min(12,Math.max(6,e/14))),Rs=(e,t)=>()=>({w:e,h:t,dy:0});function Zh(e,t,n){let r=Math.max(1.6*e+40,80),o=(t+10)/(1-(e+8)/r),s=o/2-10-t/2;return{w:r,h:o,dy:n?-s:s}}function pi(e,t){return`<path d="${e}"${t}/>`}var va=(e,t,n)=>n&1?t/8:0,lo=(e,t)=>({w:Math.max(e+2*gt,2*gt+12),h:t+2*At,dy:0});function Sn(e,t){let n="";for(let r=0;r<e.length;r+=2)n+=(r?" ":"")+d(e[r])+","+d(e[r+1]);return`<polygon points="${n}"${t}/>`}function mn(e,t,n,r=""){return`<rect x="${d(-e/2)}" y="${d(-t/2)}" width="${d(e)}" height="${d(t)}"${r}${n}/>`}var Jh={rect:{size:lo,span:Ln,draw:(e,t,n)=>mn(e,t,pt(n))},rounded:{size:lo,span:Ln,draw:(e,t,n)=>mn(e,t,n,` rx="${d(Math.min(12,t/2))}"`)},stadium:{inset:(e,t,n,r)=>n&1?Fa(r,t/2,t/2):0,span:(e,t,n)=>n?t*.6:e-t,size:(e,t)=>{let n=t+2*At;return{w:e+n*.5+2*gt-8,h:n,dy:0}},draw:(e,t,n)=>mn(e,t,n,` rx="${d(t/2)}"`)},"fr-rect":{span:Ln,size:(e,t)=>({w:e+2*gt+16,h:t+2*At,dy:0}),draw:(e,t,n,r)=>{let o=e/2-8;return mn(e,t,pt(n))+`<path d="M${d(-o)},${d(-t/2)}V${d(t/2)}M${d(o)},${d(-t/2)}V${d(t/2)}" fill="none"${r}/>`}},cyl:{inset:Qh,span:(e,t,n)=>n?t-2*hi-12:e*.6,size:(e,t)=>{let n=Math.max(e+2*gt,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*At+2*r,dy:r/2}},draw:(e,t,n,r)=>{let o=e/2,s=Math.min(12,Math.max(6,e/14)),a=-t/2+s,i=t/2-s;return`<path d="M${d(-o)},${d(a)}A${d(o)},${d(s)} 0 0 1 ${d(o)},${d(a)}V${d(i)}A${d(o)},${d(s)} 0 0 1 ${d(-o)},${d(i)}Z"${n}/><path d="M${d(-o)},${d(a)}A${d(o)},${d(s)} 0 0 0 ${d(o)},${d(a)}" fill="none"${r}/>`}},circle:{inset:_s,span:ws,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="${d(e/2)}"${n}/>`},"dbl-circ":{inset:_s,span:ws,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="${d(e/2)}"${n}/><circle r="${d(e/2-5)}" fill="none"${r}/>`},ellipse:{inset:_s,span:ws,size:(e,t)=>({w:e*1.3+2*gt,h:t*1.2+2*At,dy:0}),draw:(e,t,n)=>`<ellipse rx="${d(e/2)}" ry="${d(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)=>Sn([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-hi,size:(e,t)=>{let n=t+2*At;return{w:e+2*gt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Sn([-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:co(()=>0),size:(e,t)=>{let n=t+2*At;return{w:e+2*gt+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Sn([-e/2,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2+r,0],n)}},"lean-r":{inset:va,span:co(e=>e/4),size:(e,t)=>{let n=t+2*At;return{w:e+2*gt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Sn([-e/2+r,-t/2,e/2,-t/2,e/2-r,t/2,-e/2,t/2],n)}},"lean-l":{inset:va,span:co(e=>e/4),size:(e,t)=>{let n=t+2*At;return{w:e+2*gt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Sn([-e/2,-t/2,e/2-r,-t/2,e/2,t/2,-e/2+r,t/2],n)}},"trap-b":{inset:va,span:co(e=>e/4),size:(e,t)=>{let n=t+2*At;return{w:e+2*gt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Sn([-e/2+r,-t/2,e/2-r,-t/2,e/2,t/2,-e/2,t/2],n)}},"trap-t":{inset:va,span:co(e=>e/4),size:(e,t)=>{let n=t+2*At;return{w:e+2*gt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return Sn([-e/2,-t/2,e/2,-t/2,e/2-r,t/2,-e/2+r,t/2],n)}},text:{span:Ln,size:(e,t)=>({w:e+8,h:t+8,dy:0}),draw:(e,t)=>mn(e,t,' fill="none" stroke="none"')},"sm-circ":{noLabel:!0,inset:_s,span:ws,size:Rs(14,14),draw:(e,t,n)=>`<circle r="${d(e/2)}"${n}/>`},"f-circ":{noLabel:!0,inset:_s,span:ws,size:Rs(14,14),draw:(e,t,n,r)=>`<circle r="${d(e/2)}" fill="var(--_l)"${r}/>`},"fr-circ":{noLabel:!0,inset:_s,span:ws,size:Rs(18,18),draw:(e,t,n,r)=>`<circle r="${d(e/2)}"${n}/><circle r="${d(e/2-4)}" fill="var(--_l)"${r}/>`},fork:{noLabel:!0,span:(e,t,n)=>(n?t:e)-8,size:Rs(72,8),draw:(e,t,n,r)=>mn(e,t,` fill="var(--_l)"${r}`,' rx="2"')},"notch-rect":{size:lo,span:Ln,draw:(e,t,n)=>Sn([-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:Ln,size:(e,t)=>({w:e+2*gt+8,h:t+2*At,dy:0}),draw:(e,t,n,r)=>mn(e,t,pt(n))+`<path d="M${d(-e/2+8)},${d(-t/2)}V${d(t/2)}" fill="none"${r}/>`},"div-rect":{span:Ln,size:(e,t)=>({w:e+2*gt,h:t+2*At+8,dy:4}),draw:(e,t,n,r)=>mn(e,t,pt(n))+`<path d="M${d(-e/2)},${d(-t/2+8)}H${d(e/2)}" fill="none"${r}/>`},"win-pane":{span:Ln,size:(e,t)=>({w:e+2*gt+8,h:t+2*At+8,dy:4}),draw:(e,t,n,r)=>mn(e,t,pt(n))+`<path d="M${d(-e/2+8)},${d(-t/2)}V${d(t/2)}M${d(-e/2)},${d(-t/2+8)}H${d(e/2)}" fill="none"${r}/>`},tri:{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>Zh(e,t,!1),draw:(e,t,n)=>Sn([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)=>Zh(e,t,!0),draw:(e,t,n)=>Sn([-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*gt,h:t+2*At+10,dy:5}),draw:(e,t,n)=>Sn([-e/2,-t/2+10,e/2,-t/2,e/2,t/2,-e/2,t/2],n)},"notch-pent":{span:Ln,size:(e,t)=>({w:e+2*gt,h:t+2*At,dy:0}),draw:(e,t,n)=>Sn([-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:Rs(32,40),draw:(e,t,n)=>Sn([-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*At;return{w:e+2*gt+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/2;return`<path d="M${d(-e/2)},${d(-r)}H${d(e/2-r)}A${d(r)},${d(r)} 0 0 1 ${d(e/2-r)},${d(r)}H${d(-e/2)}Z"${n}/>`}},"h-cyl":{size:(e,t)=>{let n=t+2*At,r=Math.min(12,n/4);return{w:e+2*gt+2*r,h:n,dy:0}},draw:(e,t,n,r)=>{let o=t/2,s=Math.min(12,t/4),a=-e/2+s,i=e/2-s;return`<path d="M${d(a)},${d(-o)}H${d(i)}A${d(s)},${d(o)} 0 0 1 ${d(i)},${d(o)}H${d(a)}A${d(s)},${d(o)} 0 0 1 ${d(a)},${d(-o)}Z"${n}/><path d="M${d(i)},${d(-o)}A${d(s)},${d(o)} 0 0 0 ${d(i)},${d(o)}" fill="none"${r}/>`}},"cross-circ":{noLabel:!0,inset:_s,span:ws,size:Rs(44,44),draw:(e,t,n,r)=>{let o=e/2,s=o*Math.SQRT1_2;return`<circle r="${d(o)}"${n}/><path d="M${d(-s)},${d(-s)}L${d(s)},${d(s)}M${d(s)},${d(-s)}L${d(-s)},${d(s)}" fill="none"${r}/>`}},"st-rect":{span:(e,t,n)=>(n?t:e)-2*hi-8,size:(e,t)=>({w:e+2*gt+8,h:t+2*At+8,dy:4}),draw:(e,t,n)=>{let r=e-8,o=t-8,s="";for(let a=0;a<3;a++){let i=-e/2+(2-a)*4,c=-t/2+a*4;s+=`<rect x="${d(i)}" y="${d(c)}" width="${d(r)}" height="${d(o)}"${pt(n)}/>`}return s}},doc:{inset:(e,t,n)=>n===2?10:0,size:(e,t)=>({w:e+2*gt,h:t+2*At+10,dy:-5}),draw:(e,t,n)=>Ba(e,t,n)},flag:{inset:(e,t,n)=>n&1?0:8,size:(e,t)=>({w:e+2*gt,h:t+2*At+16,dy:0}),draw:(e,t,n)=>{let r=e/2,o=t/2-8,s=e/4;return`<path d="M${d(-r)},${d(-o)}q${d(s)},-10 ${d(2*s)},0t${d(2*s)},0V${d(o)}q${d(-s)},10 ${d(-2*s)},0t${d(-2*s)},0Z"${n}/>`}},datastore:{size:lo,span:Ln,draw:(e,t,n,r)=>mn(e,t,n.replace('stroke="var(--_b)"','stroke="none"'))+`<path d="M${d(-e/2)},${d(-t/2)}H${d(e/2)}M${d(-e/2)},${d(t/2)}H${d(e/2)}" fill="none"${r}/>`},folder:{size:(e,t)=>({w:Math.max(e+2*gt,64),h:t+2*At+8,dy:4}),draw:(e,t,n)=>{let r=e/2,o=t/2,s=Math.min(e*.4,48);return pi(`M${d(-r)},${d(-o)}H${d(-r+s)}L${d(-r+s+8)},${d(-o+8)}H${d(r)}V${d(o)}H${d(-r)}Z`,n)}},bucket:{size:(e,t)=>({w:e+2*gt+20,h:t+2*At+10,dy:3}),inset:(e,t,n)=>n&1?t/12:0,draw:(e,t,n,r)=>{let o=e/2,s=t/2,a=5,i=t/6;return pi(`M${d(-o)},${d(-s+a)}A${d(o)},${d(a)} 0 0 1 ${d(o)},${d(-s+a)}L${d(o-i)},${d(s-a)}A${d(o-i)},${d(a)} 0 0 1 ${d(-o+i)},${d(s-a)}Z`,n)+`<path d="M${d(-o)},${d(-s+a)}A${d(o)},${d(a)} 0 0 0 ${d(o)},${d(-s+a)}" fill="none"${r}/>`}},console:{span:Ln,size:(e,t)=>({w:Math.max(e+2*gt,72),h:t+2*At+12,dy:6}),draw:(e,t,n,r)=>mn(e,t,pt(n))+`<path d="M${d(-e/2)},${d(-t/2+12)}H${d(e/2)}M${d(-e/2+7)},${d(-t/2+4)}l3,2.5l-3,2.5M${d(-e/2+13)},${d(-t/2+9)}h4" fill="none"${r}/>`},browser:{span:Ln,size:(e,t)=>({w:Math.max(e+2*gt,72),h:t+2*At+12,dy:6}),draw:(e,t,n,r)=>{let o="";for(let s=0;s<3;s++)o+=`<circle cx="${d(-e/2+8+s*7)}" cy="${d(-t/2+6)}" r="1.5" fill="none"${r}/>`;return mn(e,t,pt(n))+`<path d="M${d(-e/2)},${d(-t/2+12)}H${d(e/2)}" fill="none"${r}/>`+o}},person:{size:(e,t)=>({w:Math.max(e+2*gt,56),h:t+2*At+26,dy:13}),draw:(e,t,n)=>{let r=-t/2;return`<rect x="${d(-e/2)}" y="${d(r+26)}" width="${d(e)}" height="${d(t-26)}" rx="12"${n}/><circle cy="${d(r+14)}" r="13"${n}/>`}},bang:{size:(e,t)=>({w:e+2*gt+28,h:t+2*At+24,dy:0}),inset:()=>3,draw:(e,t,n)=>{let o=[];for(let s=0;s<28;s++){let a=Math.PI*s/14-Math.PI/2,i=s%2===0?1:.82;o.push(Math.cos(a)*(e/2)*i,Math.sin(a)*(t/2)*i)}return Sn(o,n)}},cloud:{size:(e,t)=>({w:e+2*gt+32,h:t+2*At+24,dy:0}),inset:(e,t,n)=>n&1?2:1,draw:(e,t,n)=>{let r=e/2,o=t/2,s=o*.55;return pi(`M${d(-r+s)},${d(o)}A${d(s)},${d(s)} 0 0 1 ${d(-r+s*.6)},${d(-o*.1)}A${d(r*.42)},${d(o*.7)} 0 0 1 ${d(-r*.1)},${d(-o*.72)}A${d(r*.4)},${d(o*.62)} 0 0 1 ${d(r*.62)},${d(-o*.42)}A${d(s*1.05)},${d(s*1.05)} 0 0 1 ${d(r-s)},${d(o)}Z`,n)}},brace:{size:(e,t)=>({w:e+2*gt+12,h:t+2*At,dy:0}),draw:(e,t,n,r)=>mn(e,t,' fill="none" stroke="none"')+Pa(-e/2+12,t,-1,r)},"brace-r":{size:(e,t)=>({w:e+2*gt+12,h:t+2*At,dy:0}),draw:(e,t,n,r)=>mn(e,t,' fill="none" stroke="none"')+Pa(e/2-12,t,1,r)},braces:{size:(e,t)=>({w:e+2*gt+24,h:t+2*At,dy:0}),draw:(e,t,n,r)=>mn(e,t,' fill="none" stroke="none"')+Pa(-e/2+12,t,-1,r)+Pa(e/2-12,t,1,r)},bolt:{noLabel:!0,size:Rs(36,56),inset:(e,t,n)=>n&1?e/4:0,draw:(e,t,n)=>Sn([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:Qh,span:(e,t,n)=>n?t-2*hi-20:e*.6,size:(e,t)=>{let n=Math.max(e+2*gt,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*At+2*r+8,dy:r/2+4}},draw:(e,t,n,r)=>{let o=e/2,s=Math.min(12,Math.max(6,e/14)),a=-t/2+s,i=t/2-s,c=l=>`M${d(-o)},${d(l)}A${d(o)},${d(s)} 0 0 0 ${d(o)},${d(l)}`;return pi(`M${d(-o)},${d(a)}A${d(o)},${d(s)} 0 0 1 ${d(o)},${d(a)}V${d(i)}A${d(o)},${d(s)} 0 0 1 ${d(-o)},${d(i)}Z`,n)+`<path d="${c(a)}${c(a+8)}" fill="none"${r}/>`}},"curv-trap":{size:(e,t)=>{let n=t+2*At;return{w:e+2*gt+n*.6,h:n,dy:0}},draw:(e,t,n)=>{let r=e/2,o=t/2,s=t*.3;return pi(`M${d(-r+s)},${d(-o)}H${d(r-s)}A${d(s)},${d(o)} 0 0 1 ${d(r-s)},${d(o)}H${d(-r+s)}L${d(-r)},0Z`,n)}},docs:{size:(e,t)=>({w:e+2*gt+8,h:t+2*At+18,dy:-1}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n)=>{let r="";for(let o=0;o<3;o++)r+=`<g transform="translate(${(1-o)*4},${(o-1)*4})">${Ba(e-8,t-8,n)}</g>`;return r}},"bow-rect":{size:(e,t)=>{let n=t+2*At;return{w:e+2*gt+n*.4,h:n,dy:0}},inset:(e,t,n)=>n===1?t*.2:0,draw:(e,t,n)=>{let r=e/2,o=t/2,s=t*.2;return pi(`M${d(-r+s)},${d(-o)}H${d(r)}A${d(s)},${d(o)} 0 0 0 ${d(r)},${d(o)}H${d(-r+s)}A${d(s)},${d(o)} 0 0 1 ${d(-r+s)},${d(-o)}Z`,n)}},"tag-rect":{size:lo,span:Ln,draw:(e,t,n,r)=>mn(e,t,pt(n))+`<path d="M${d(e/2-12)},${d(t/2)}L${d(e/2)},${d(t/2-12)}" fill="none"${r}/>`},"tag-doc":{size:(e,t)=>({w:e+2*gt,h:t+2*At+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>Ba(e,t,n)+`<path d="M${d(e/2-12)},${d(t/2-14)}L${d(e/2)},${d(t/2-26)}" fill="none"${r}/>`},"lin-doc":{size:(e,t)=>({w:e+2*gt+8,h:t+2*At+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>Ba(e,t,n)+`<path d="M${d(-e/2+8)},${d(-t/2)}V${d(t/2-6)}" fill="none"${r}/>`},collapsedGroup:{size:(e,t)=>({w:e+2*gt+8,h:t+2*At+8,dy:-2}),draw:(e,t,n)=>`<rect x="${d(-e/2+6)}" y="${d(-t/2+8)}" width="${d(e-12)}" height="${d(t-8)}"${pt(n)}/><rect x="${d(-e/2)}" y="${d(-t/2)}" width="${d(e)}" height="${d(t-4)}"${pt(n)}/>`}};function Pa(e,t,n,r){let o=t/2,s=6*n;return`<path d="M${d(e)},${d(-o)}q${d(s)},0 ${d(s)},6V-6q0,6 ${d(s)},6q${d(-s)},0 ${d(-s)},6V${d(o-6)}q0,6 ${d(-s)},6" fill="none"${r}/>`}function Ba(e,t,n){let r=e/2,o=-t/2,s=t/2-10,a=e/4;return`<path d="M${d(-r)},${d(o)}H${d(r)}V${d(s)}q${d(-a)},-12 ${d(-2*a)},0t${d(-2*a)},0Z"${n}/>`}var em=Jh.rect,uo=new Map(Object.entries(Jh));function Hr(e,t,n){return(uo.get(e)??em).size(t,n)}function Qn(e,t,n,r,o){return(uo.get(e)??em).draw(t,n,r,o)}function Mr(e,t,n,r,o=0){return uo.get(e)?.inset?.(t,n,r,o)??0}function tm(e,t,n,r){return Math.max(0,uo.get(e)?.span?.(t,n,r)??0)}function nm(e){return uo.get(e)?.noLabel!==!0}function Un(e,t,n){let r=e[t]-n.x,o=e[t+1]-n.y;return Math.abs(Math.abs(o)-n.h/2)<.5?o<0?0:2:Math.abs(Math.abs(r)-n.w/2)<.5?r<0?3:1:-1}function Ts(e,t,n,r){if(r.isGroup)return;let o=Un(e,t,r);if(o===0||o===2){let s=Mr(n.shape,n.w,n.h,o,e[t]-r.x)+(r.h-n.h)/2;e[t+1]+=o===0?s:-s}else if(o>=0){let s=Mr(n.shape,n.w,n.h,o,e[t+1]-r.y)+(r.w-n.w)/2;e[t]+=o===3?s:-s}}var nw=1.5,rw=/<br\s*\/?>|\\n|\n/gi,rm=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,sm=/(fa[bklrs]?):fa-([\w-]+)/g,sw=/[<\\\n*_]|fa[bklrs]?:fa-/,Bd="\\u2e80-\\u9fff\\uf900-\\ufaff\\uff00-\\uff60",im="、。,.:;!?)]}」』】〕〉》〙〗ー…‥・ゝゞぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ,.:;!?)\\]}",iw="([{「『【〔〈《〘〖([{",ow=new RegExp(`[${Bd}]`),aw=new RegExp(`\\s*(?:[${iw}]*[${Bd}][${im}]*|[^\\s${Bd}]+[${im}]*)\\s*|\\s+`,"g"),am=57344,cw=6400,lw=/\$\$(.+?)\$\$/g,cm=/[\ue000-\uf8ff]/,dw=/([\ue000-\uf8ff])/,fo,uw={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function fw(e){let t=e.split(`
`),n=1/0;for(let r of t){if(r.trim()==="")continue;let o=r.length-r.trimStart().length;o<n&&(n=o)}return n===1/0||n===0?e:t.map(r=>r.slice(Math.min(n,r.length-r.trimStart().length))).join(`
`)}function Wa(e){return e!==void 0&&e.icon===void 0&&e.math===void 0}function vd(e,t,n){if(t!==""){if(fo!==void 0&&cm.test(t)){let r=fo,o=t.split(dw);for(let s=0;s<o.length;s++){if(s%2===0){o[s]!==""&&Pd(e,o[s],n);continue}let a=o[s].charCodeAt(0)-am,i=r.math[a];i?e.push({text:"",style:n,math:i,width:i.width}):Pd(e,`$$${r.tex[a]}$$`,n)}return}Pd(e,t,n)}}function Pd(e,t,n){let r=yt(t),o=e[e.length-1];Wa(o)&&o.style===n?o.text+=r:e.push({text:r,style:n,width:0})}function pw(e,t,n){if(!t.includes(":fa-")){vd(e,t,n);return}let r=0;sm.lastIndex=0;let o;for(;(o=sm.exec(t))!==null;){let s=`${o[1]}:fa-${o[2]}`;if(vd(e,t.slice(r,o.index),n),r=o.index+o[0].length,ni(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];Wa(a)&&(a.text=a.text.trimEnd())}}vd(e,t.slice(r),n)}function hw(e,t,n,r,o){let s=o,a=0,i="",c=0,l=t.length,f=()=>{pw(e,i,s),i=""};for(;c<l;){let p=t[c];if(p==="<"){rm.lastIndex=c;let u=rm.exec(t);if(u&&u.index===c){let m=u[1].toLowerCase(),h=t[c+1]==="/",b=m==="b"||m==="strong"?1:m==="i"||m==="em"?2:0;b&&(f(),o=h?o&~b|r&b:o|b,s=h?s&~b|r&b:s|b),c+=u[0].length;continue}}else if(n&&(p==="*"||p==="_")){let u=t[c+1]===p,m=u?1:2,h=u?2:1,b=(a&m)===0,x=c>0?t[c-1]:" ",E=c+h<l?t[c+h]:" ",w=b&&E.trim()!==""&&t.indexOf(u?p+p:p,c+h)!==-1,S=!b&&x.trim()!=="",O=p==="_"&&/\w/.test(x)&&/\w/.test(E);if((w||S)&&!O){f(),a=w?a|m:a&~m,s=w?s|m:s&~m|r&m,c+=h;continue}}i+=p,c++}return f(),o}function mw(e,t,n){let r=0;for(let o of e)o.width=o.icon!==void 0?n*1.25:o.math?o.math.width:t.width(o.text,n,o.style),r+=o.width;return r}function lm(e,t,n,r,o,s){let a=[],i=0,c=()=>{let l=a[a.length-1];if(Wa(l)){let f=l.text.trimEnd();if(f!==l.text){l.text=f;let p=t.width(f,n,l.style);i+=p-l.width,l.width=p}}o.push(a),s.push(i),a=[],i=0};for(let l of e){if(l.icon!==void 0||l.math){let f=l.math?l.math.width:n*1.25;i>0&&i+f>r&&c(),a.push({...l,width:f}),i+=f;continue}for(let f of l.text.match(aw)??[]){let p=f;i>0&&i+t.width(p.trimEnd(),n,l.style)>r&&(c(),p=p.trimStart());let u=a[a.length-1];if(Wa(u)&&u.style===l.style){u.text+=p,u.width=t.width(u.text,n,u.style),i=0;for(let m of a)i+=m.width}else{let m=t.width(p,n,l.style);a.push({text:p,style:l.style,width:m}),i+=m}}}(a.length>0||o.length===0)&&c()}function We(e,t,n,r,o,s=0){if(e===void 0||e==="")return uw;let a=Math.round(r*nw);if(Vp()&&e.includes("$$")&&!cm.test(e)){let i={tex:[],math:[]},c=e.replace(lw,(l,f)=>i.tex.length===cw?l:(i.tex.push(f),String.fromCharCode(am+i.tex.length-1)));if(i.tex.length>0){for(let l of i.tex)i.math.push(jp(yt(l),r));return om(c,t,n,r,o,s,a,i)}}if(!sw.test(e)&&!e.includes("&")&&!e.includes("fl")){let i=e.trim(),c=n.width(i,r,s);if(c<=o||!(i.includes(" ")||ow.test(i)))return{lines:[[{text:i,style:s,width:c}]],widths:[c],width:c,height:a,size:r,lineHeight:a};let l=[],f=[];lm([{text:i,style:s,width:c}],n,r,o,l,f);let p=0;for(let u of f)u>p&&(p=u);return{lines:l,widths:f,width:p,height:l.length*a,size:r,lineHeight:a}}return om(e,t,n,r,o,s,a)}function om(e,t,n,r,o,s,a,i){let c=fo;fo=i;try{let l=gw(e,t,n,r,o,s,a);return i?po(l):l}finally{fo=c}}function gw(e,t,n,r,o,s,a){let i=t?fw(e.replace(/\r\n?/g,`
`)).trim():e.trim(),c=[],l=[],f=0,p=s;for(let u of i.split(rw)){let m=[];p=hw(m,u.trim(),t,s,p);let h=mw(m,n,r);h>o?lm(m,n,r,o,c,l):(c.push(m),l.push(h))}for(let u of l)u>f&&(f=u);return{lines:c,widths:l,width:f,height:c.length*a,size:r,lineHeight:a}}function po(e){let t;for(let r=0;r<e.lines.length;r++){let o=e.lineHeight;for(let s of e.lines[r])s.math&&(o=Math.max(o,Math.ceil(s.math.height+e.size/4)));o!==e.lineHeight&&t===void 0&&(t=e.lines.map(()=>e.lineHeight)),t&&(t[r]=o)}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 mi(e){for(let t of e)if(t.math)return!0;return!1}function lr(e,t){let n=e.heights;if(!n)return(t+.5)*e.lineHeight;let r=0;for(let o=0;o<t;o++)r+=n[o];return r+n[t]/2}function dr(e,t){let n=e.widths[t],r=e.heights?e.heights[t]:e.lineHeight,o={lines:[e.lines[t]],widths:[n],width:n,height:r,size:e.size,lineHeight:e.lineHeight};return r!==e.lineHeight&&(o.heights=[r]),o}function Kr(e,t,n,r){let o=r(t,!1),s=e.maxWidth;if(s===void 0||!(s>0)||o.width<=s)return o;let a=Math.min(n,t),i=t;o=r(i,!0);for(let c=0;c<3&&o.width>s&&i>a;c++)i=Math.max(a,i-(o.width-s)),o=r(i,!0);return o}function Tt(e){let t=e.maxWidth;return t!==void 0&&t>0?Math.max(80,t-2*(e.padding??8)):4e3}function zr(e,t,n,r=0){let o=e.maxWidth;return o===void 0||!(o>0)?t:Math.max(Math.min(n,t),Math.min(t,o-r))}var bw=640;function $t(e,t){let n=t(!1),r=e.maxWidth;if(e.autoDirection===!1||r===void 0||!(r>0)||n.width<=r)return n;let o=e.directionBreakpoint;if(r>=(o!==void 0&&o>0?o:bw))return n;let s=t(!0);return s.width<n.width?s:n}function Tn(e){return e==="LR"||e==="RL"}function gn(e,t){let n=t(!1),r=e.maxWidth;if(r===void 0||!(r>0)||n.width<=r)return n;let o=t(!0);return o.width<n.width?o:n}var Cs=new Map([["tool",0],["task",1],["decision",2],["input",3],["refdoc",4],["connector",5],["action",6]]),dm=Cs.size,yw=e=>Math.max(1,e-dm),Ew=(e,t)=>{let n=dm+e%yw(t);return t>0?n%t:n};function um(e,t,n,r){let o=n.size;for(let s of e){if(s.isGroup||s.shape==="collapsedGroup"){s.colorIndex=Ew(n.get(s.id)??o++,r);continue}let a=t(s.id);a&&Cs.has(a)&&(s.kind=a)}}function fm(e,t,n){let r=[],o=[],s=e.subgraphs,a=E=>{let w=[];for(let S of E){let O=e.classes.get(S);O?.styles&&(w=[...w,...O.styles].map(D=>D.trim())),O?.textStyles&&(w=[...w,...O.textStyles].map(D=>D.trim()))}return w},i=new Set,c=new Map,l=new Set;for(let E of s){if(E.metadata?.view!=="collapsed"||i.has(E.id))continue;let w=[E.id];for(;w.length>0;){let S=e.subgraph(w.pop())?.nodes;if(S!==void 0)for(let O of S)O===E.id||i.has(O)||(i.add(O),c.set(O,E.id),l.has(O)||w.push(O))}l.add(E.id)}let f=new Map;for(let E of i){let w=[E],S=c.get(E);for(;;){let O=f.get(S),D=O??c.get(S);if(D===void 0||(O===void 0&&w.push(S),S=D,O!==void 0))break}for(let O of w)f.set(O,S)}let p=new Map;s.forEach((E,w)=>p.set(E.id,w));let u=new Map,m=(E,w,S)=>{let O=p.get(E);if(O===void 0||O<S)return!1;let D=w;for(let L=0;D!==void 0&&L<=s.length;L++){if(D===E)return!0;D=u.get(D)}return!1};for(let E=s.length-1;E>=0;E--){let w=s[E];if(!i.has(w.id))for(let S of w.nodes){if(m(S,w.id,E)){e.emitWarning("CONTAINMENT_VIOLATION",`Container "${w.id}" cannot contain "${S}" because "${S}" already contains it. The nesting that would close the loop is dropped.`,{nodeId:S});continue}u.set(S,w.id)}}let h=new Map;for(let E=s.length-1;E>=0;E--){let w=s[E];if(i.has(w.id))continue;let S=w.metadata?.view==="collapsed",O={id:w.id,label:w.title,labelType:w.labelType,parentId:u.get(w.id),cssStyles:[],cssCompiledStyles:a(w.classes),cssClasses:w.classes.join(" "),shape:S?"collapsedGroup":"flowGroup",dir:w.dir,isGroup:!S,metadata:S?{...w.metadata,containerType:w.type}:w.metadata};r.push(O),h.set(w.id,O)}for(let E of e.nodes.values()){if(i.has(E.id))continue;let w=h.get(E.id);if(w){w.cssStyles=E.styles,w.cssCompiledStyles=a(E.classes),w.cssClasses=E.classes.join(" ");continue}let S=ai(E.type),O={id:E.id,label:E.text,labelType:E.labelType,parentId:u.get(E.id),cssStyles:E.styles,cssCompiledStyles:a(["default","node",...E.classes]),cssClasses:"default "+E.classes.join(" "),dir:E.dir,link:E.link,linkTarget:E.linkTarget,tooltip:e.tooltips.get(E.id),metadata:E.metadata,isGroup:!1,shape:S==="square"||S===void 0?"squareRect":S};r.push(O),h.set(E.id,O)}e.edges.forEach((E,w)=>{let S=f.get(E.start)??E.start,O=f.get(E.end)??E.end;if(S===O&&E.start!==E.end)return;let D=[...e.defaultEdgeStyle??[]];E.style&&D.push(...E.style);let L=E.type==="arrow_open"?"none":E.type==="arrow_cross"||E.type==="arrow_point"?E.type:"arrow_point";o.push({id:E.id||`L_${S}_${O}_${w}`,isUserDefinedId:E.isUserDefinedId,start:S,end:O,type:E.type??"normal",label:E.text,labelType:E.labelType,thickness:E.stroke,pattern:E.stroke,minlen:E.length,classes:"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:"none",arrowTypeEnd:L,cssCompiledStyles:a(E.classes),style:D,animate:E.animate,animation:E.animation,curve:E.interpolate||e.defaultInterpolate||n,metadata:E.metadata})}),_h(r,e);let b=new Map;for(let E of s){let w=u.get(E.id);if(w===void 0)continue;let S=b.get(w);S?S.push(E.id):b.set(w,[E.id])}let x=new Map;for(let E of s){if(u.get(E.id)!==void 0)continue;let w=[E.id];for(;w.length>0;){let S=w.pop();if(x.has(S))continue;x.set(S,x.size);let O=b.get(S);if(O)for(let D=O.length-1;D>=0;D--)w.push(O[D])}}return um(r,E=>{if(e.connectors.has(E))return"connector";let w=e.nodes.get(E);return w?e.vertexKind(w):void 0},x,t),{nodes:r,edges:o}}var Aw=8,xw=40,Sw=16,_w=48,ho=20,Fd=26,Ua=14,pm="collapsed",ww={TB:2,RL:3,BT:0,LR:1},hm=new WeakMap;function Gd(e,t){let n=hm.get(e);if(n===void 0){let r=t.flowchart?.curve;n=fm(e,Aw,typeof r=="string"?r:void 0),hm.set(e,n)}return n}function Ga(e,t,n){let r=e.agentflow?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}var Rw=/[";]fill:/;function Wd(e,t,n){let r=lt(e);return` fill="${r}"${Rw.test(n.shape)?"":` fill-opacity="${t}"`} stroke="${r}"`}function gm(e,t,n){return Tn(e.direction)?$t(n,r=>mm(e,t,n,r)):mm(e,t,n,!1)}function mm(e,t,n,r){let o=Gd(e,t),s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??et(n.fontFamily),c=Ga(t,"wrappingWidth",120),l=Ga(t,"minNodeWidth",120),f=n.padding??8,p=n.icons,u=new Map,m=[],h=[];o.nodes.forEach((H,G)=>u.set(H.id,G));for(let H of o.nodes){let G=H.cssStyles.length>0?H.cssCompiledStyles.concat(H.cssStyles):H.cssCompiledStyles,se=St(G),q=(se.bold?1:0)|(se.italic?2:0),P=H.labelType==="markdown",V=se.fontSize??s,ne,ae;if(H.isGroup){let Z=We(H.label,P,i,V,4e3,q);ne={node:H,style:se,label:Z,shape:"group",w:0,h:0,dy:0,loops:0},ae=Pt(0,0),ae.isGroup=!0,ae.dir=H.dir?rn(H.dir):void 0,ae.padX=ho,ae.padTop=Z.height>0?Z.height+16:ho,ae.padBottom=ho,ae.minW=Z.width+2*ho-12}else if(H.shape==="collapsedGroup"){let Z=We(H.label,P,i,V,c,q),Q=Math.max(Z.width,l)+2*gt,ie=Z.height+2*At+Ua;ne={node:H,style:se,label:Z,shape:pm,w:Q,h:ie,dy:-Ua/2,loops:0},ae=Pt(Q,ie)}else{let Z=xa(H.shape),Q=We(H.label,P,i,V,c,q),ie=Hr(Z,Z==="diam"?Q.width:Math.max(Q.width,l),Q.height);ne={node:H,style:se,label:Q,shape:Z,w:ie.w,h:ie.h,dy:ie.dy,loops:0},ae=Pt(ie.w,ie.h)}ae.seq=m.length,m.push(ne),h.push(ae)}o.nodes.forEach((H,G)=>{h[G].parent=H.parentId!==void 0?u.get(H.parentId)??-1:-1});let b=r?"TB":rn(e.direction),x=H=>{let G;for(let se=h[H].parent,q=0;se>=0&&G===void 0&&q<1e4;se=h[se].parent,q++)G=h[se].dir;return G??b},E=H=>{let G=x(H);return G==="LR"||G==="RL"},w=new Int32Array(h.length).fill(-1);for(let H=0;H<h.length;H++){let G=[],se=H;for(;se>=0&&w[se]<0&&G.length<=h.length;)G.push(se),se=h[se].parent;let q=se>=0?w[se]+1:0;for(let P=G.length-1;P>=0;P--)w[G[P]]=q++}let S=(H,G)=>{let se=G;for(let q=w[G];q>w[H];q--)se=h[se].parent;return se===H&&G!==H},O=[],D=[],L=[],B=[];for(let H of o.edges){let G=u.get(H.start),se=u.get(H.end);if(G===void 0||se===void 0)continue;let q=We(H.label,H.labelType==="markdown",i,a,c);if(S(G,se)||S(se,G)){B.push({edge:H,label:q,src:G,dst:se});continue}G===se&&(m[G].loops++,E(G)?h[G].h+=2*(Fd+(q.height>0?q.height+8:0)):h[G].w+=2*(Fd+(q.width>0?q.width+12:0))),L.push(H),D.push(q),O.push({src:G,dst:se,minlen:H.minlen??1,labelW:q.width>0?q.width+12:0,labelH:q.height>0?q.height+4:0,route:[],labelX:0,labelY:0})}let W=Rn(h,O,b,{nodeSep:Ga(t,"nodeSpacing",xw),edgeSep:Sw,rankSep:Ga(t,"rankSpacing",_w),portSep:20}),Y=We(e.title,!1,i,s,4e3,1),I=Y.height>0?Y.height+12:0,X=Math.max(W.width,Y.width),ee=f+(X-W.width)/2,K=f+I;Gr(h,O,ee,K);let z=Math.ceil(X+2*f),C=Math.ceil(W.height+I+2*f),M=[],T=[],g=[],_=[],y=B.length*h.length<2e6;for(let{edge:H,src:G,dst:se}of B){let q=S(se,G),P=q?se:G,V=q?G:se,ne=h[P],ae=h[V],Z=ww[ne.dir??x(P)],Q=q?Z:Z+2&3,ie=he=>{let oe=(he&1)===0,ge=he===0||he===3?-1:1,Ee=oe?ae.x:ae.x+ge*ae.w/2,be=oe?ae.y+ge*ae.h/2:ae.y,ye=oe?ae.x:ne.x+ge*ne.w/2,Re=oe?ne.y+ge*ne.h/2:ae.y,Le=oe?0:1;return q?[Ee,be,Le,ye,Re,Le]:[ye,Re,Le,Ee,be,Le]},me=he=>{for(let oe=0;oe<h.length;oe++){let ge=h[oe];if(oe!==V&&!ge.isGroup&&ge.x+ge.w/2>Math.min(he[0],he[3])-1&&ge.x-ge.w/2<Math.max(he[0],he[3])+1&&ge.y+ge.h/2>Math.min(he[1],he[4])-1&&ge.y-ge.h/2<Math.max(he[1],he[4])+1)return!0}return!1},re=ie(Q);if(y&&me(re))for(let he of[Q+1&3,Q+3&3,Q+2&3]){let oe=ie(he);if(!me(oe)){re=oe;break}}_.push(re),g.push((re[0]+re[3])/2,(re[1]+re[4])/2);let te=re.slice();Ts(te,q?0:3,m[V],ae),T.push(xn(te,"linear",0,mt(H.arrowTypeEnd)))}let R=new Map,A=!1;for(let H of h)H.isGroup&&(A=!0);if(A){for(let H of O)qn(R,H.route);for(let H of _)qn(R,H)}let N="",$="";for(let H=0;H<m.length;H++){let G=m[H],se=h[H],q=G.node,P=se.x,V=se.y,ne=Rt(q.cssClasses.replace(/^default\s?/,"")),ae=Fe(q.id);if(se.isGroup){let oe=Yr(se,G.label.width,R,ho);N+=`<g class="pele-cluster pele-flow${ne}" data-id="${ae}"><rect x="${d(P-se.w/2)}" y="${d(V-se.h/2)}" width="${d(se.w)}" height="${d(se.h)}"${pt(Wd(q.colorIndex??Cs.size,"0.06",G.style)+G.style.shape)}/>`+De(G.label,oe,V-se.h/2+8+G.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${G.style.text}`,p)+"</g>";continue}let Z=G.w,Q=G.h,ie="",me;if(G.shape===pm){let oe=lt(q.colorIndex??Cs.size),ge=Q/2-Ua-2,Ee=ge+(Ua+2)/2;me=`<rect x="${d(-Z/2)}" y="${d(-Q/2)}" width="${d(Z)}" height="${d(Q)}"${pt(Wd(q.colorIndex??Cs.size,"0.06",G.style)+G.style.shape)}/><path d="M${d(-Z/2+10)},${d(ge)}H${d(Z/2-10)}" fill="none" stroke="${oe}" stroke-dasharray="3 3"${G.style.line}/><path class="pele-collapsed-mark" d="${Ud(-9,Ee)}${Ud(0,Ee)}${Ud(9,Ee)}" fill="${oe}" stroke="none"/>`}else{let oe=Cs.get(q.kind??"task")??1;ie=` pele-kind-${q.kind??"task"}`,me=Qn(G.shape,Z,Q,Wd(oe,"0.14",G.style)+G.style.shape,` stroke="${lt(oe)}"`+G.style.line)}let re=De(G.label,0,G.dy,` class="pele-label"${G.style.text}`,p);if(/ internal-link(?: |$)/.test(ne+" ")&&q.label&&n.links!==!1){let oe=yt(q.label),ge=Cr(Xn(oe),n)!==void 0,Ee=je(oe);re=`<a class="internal-link"${ge?` href="${Ee}"${Nr(n)}`:""} data-href="${Ee}">${re}</a>`,M.push({id:q.id,href:oe,internal:!0})}let he=me+re;q.tooltip&&(he=`<title>${Fe(q.tooltip)}</title>`+he),q.link&&(he=Wn(he,q.link,q.id,M,n,q.linkTarget?` target="${je(q.linkTarget)}"`:"")),$+=`<g class="pele-node pele-shape-${G.shape}${ie}${ne}" data-id="${ae}" transform="translate(${d(P)},${d(V)})">${he}</g>`}let U="",j="",v=(H,G,se,q,P)=>{let V=H.style.length>0||H.cssCompiledStyles.length>0?St(H.cssCompiledStyles.concat(H.style)):void 0,ne=H.arrowTypeEnd,ae=V?.stroke?je(V.stroke):"var(--_l)",Z=H.thickness==="dotted"?"reference":ne==="arrow_cross"?"failure":"sequence",Q=Rt(H.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));U+=`<g class="pele-edge pele-edge-${Z}${Q}" data-id="${Fe(H.id)}"${V?.line??""}><path d="${se.d}"${H.thickness==="dotted"?' stroke-dasharray="3 4"':""}/>`+Et(ne,se.ex,se.ey,se.edx,se.edy,ae)+"</g>",G.width>0&&(j+=sn(H.id,G,q,P,V?.text??"",p))},k=new Map;for(let H=0;H<O.length;H++){let G=O[H],se=L[H],q=D[H],P=se.arrowTypeEnd,V;if(G.src===G.dst){let ne=m[G.src],ae=k.get(G.src)??0;k.set(G.src,ae+1),V=Oa(h[G.src],ne.w,ne.h,ae,E(G.src),Fd,mt(P),G)}else{let ne=G.route.slice();Ts(ne,0,m[G.src],h[G.src]),Ts(ne,ne.length-3,m[G.dst],h[G.dst]),V=xn(ne,se.curve,0,mt(P))}v(se,q,V,G.labelX,G.labelY)}return B.forEach((H,G)=>v(H.edge,H.label,T[G],g[2*G],g[2*G+1])),{svg:Ze("agentflow",z,C,s,n,e,De(Y,z/2,f+Y.height/2,' class="pele-title" font-weight="var(--_tw)"')+(N?`<g class="pele-clusters">${N}</g>`:"")+(U?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${U}</g>`:"")+(j?`<g class="pele-edge-labels" font-size="${a}">${j}</g>`:"")+`<g class="pele-nodes">${$}</g>`),width:z,height:C,links:M}}function Ud(e,t){return`M${d(e-1.75)},${d(t)}a1.75,1.75 0 1 0 3.5,0a1.75,1.75 0 1 0 -3.5,0Z`}var bm={type:"agentflow",keepComments:!0,parse(e,t,n,r,o){let s=t.flowchart??{},a=new _a({inheritDir:s.inheritDir===!0,direction:typeof t.direction=="string"?t.direction:void 0,lineOffset:r,maxEdges:o.maxEdges});return n&&(a.title=n),Ih(e,a),Gd(a,t),a},render:gm};function ur(e){throw new ze(e,"semantic",{type:"architecture"})}var Ya=class{constructor(){de(this,"type","architecture");de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"nodes",new Map);de(this,"groups",new Map);de(this,"edges",[]);de(this,"layoutHints",[]);de(this,"registered",new Map)}register(t,n,r){this.registered.has(n)&&ur(`The ${t} id [${n}] is already in use by another ${this.registered.get(n)}`),r!==void 0&&(n===r&&ur(`The ${t} [${n}] cannot be placed within itself`),this.registered.has(r)||ur(`The ${t} [${n}]'s parent does not exist. Please make sure the parent is created before this ${t}`),this.registered.get(r)==="node"&&ur(`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:o,in:s}){this.register("service",t,s),this.nodes.set(t,{id:t,type:"service",icon:n,iconText:r,title:o,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:o}){this.register("group",t,o),this.groups.set(t,{id:t,icon:n,title:r,in:o})}addEdge({lhsId:t,rhsId:n,lhsDir:r,rhsDir:o,lhsInto:s,rhsInto:a,lhsGroup:i,rhsGroup:c,title:l}){let f=[["left",t,i],["right",n,c]];for(let[u,m]of f)this.registered.has(m)||ur(`The ${u}-hand id [${m}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[u,m]of f)this.nodes.has(m)||ur(`The ${u}-hand id [${m}] is a group. Add {group} to a service inside it instead.`);let p=this.nodes.get(t).in;if(p!==void 0&&p===this.nodes.get(n).in)for(let[u,m,h]of f)h&&ur(`The ${u}-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:i,rhsId:n,rhsDir:o,rhsInto:a,rhsGroup:c,title:l})}addLayoutHint(t){t.members.length<2&&ur(`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"&&ur(`align ${t.direction} references [${r}], which is not a service or junction`),n.has(r)&&ur(`align ${t.direction} lists [${r}] more than once`),n.add(r);this.layoutHints.push(t)}};function ym(e,t){e.accDescr&&(t.accDescr=e.accDescr.replace(/\n\s+/g,`
`)),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 Em=new WeakMap;function Tw(e){let t=e.map((o,s)=>s),n=[];for(let o=0;o<128;o++){let s=String.fromCharCode(o);n.push(t.filter(a=>{let{pattern:i,first:c}=e[a];return typeof i=="string"?i[0]===s:c===void 0||c.includes(s)}))}let r={starting:n,every:t,longer:e.map(o=>o.longer?.map(s=>e.indexOf(s)))};return Em.set(e,r),r}function Wt(e,t,n){let r=[],o=[],s=[],a=new Uint8Array(t.length),{starting:i,every:c,longer:l}=Em.get(t)??Tw(t),f=[],p=e.length,u=(h,b)=>{if(a[h])return-1;let x=t[h];if(x.match!==void 0)return x.match(e,b);if(x.scanner!==void 0)return(f[h]??=x.scanner())(e,b);let E=x.pattern;return typeof E=="string"?e.startsWith(E,b)?b+E.length:-1:(E.lastIndex=b,E.test(e)?E.lastIndex:(x.opener!==void 0&&(x.opener.lastIndex=b,x.opener.test(e)&&(a[h]=1)),-1))},m=0;e:for(;m<p;){let h=e.charCodeAt(m);for(let b of h<128?i[h]:c){let x=u(b,m);if(x<=m)continue;let E=b,w=l[b];if(w!==void 0)for(let S of w){let O=u(S,m);if(O>x){E=S,x=O;break}}t[E].hidden||(r.push(E),o.push(m),s.push(x)),m=x;continue e}throw st(n,e,m,"",!0)}return r.push(-1),o.push(p),s.push(p),{kinds:r,starts:o,ends:s,src:e}}var tn={name:"ACC_DESCR",pattern:/[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"	 a"},zt={name:"ACC_TITLE",pattern:/[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"	 a"},Vt={name:"TITLE",pattern:/[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:"	 t"},Cn={name:"STRING",pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`},bn={name:"NEWLINE",pattern:/\r?\n/y,first:`\r
`},yn={name:"WHITESPACE",pattern:/[\t ]+/y,hidden:!0,first:"	 "},Ut={name:"YAML",pattern:/---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/y,hidden:!0,opener:/---[\t ]*\r?\n/y,first:"-"},jt={name:"DIRECTIVE",pattern:/[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/y,hidden:!0,opener:/[\t ]*%%{/y,first:"	 %"},Xt={name:"SINGLE_LINE_COMMENT",pattern:/[\t ]*%%[^\n\r]*/y,first:"	 %",hidden:!0};function qt(e){return{name:e,pattern:new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"(?:(?=%%)|(?!\\S))","y"),first:e[0]}}var Cw=/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,Nw=/accTitle[\t ]*:([^\n\r]*)/,Mw=/title([\t ][^\n\r]*|)/;function Yd(e){return e.trim().replace(/[\t ]{2,}/gm," ")}function Gt(e){return Yd(Mw.exec(e)[1])}function Yt(e){return Yd(Nw.exec(e)[1])}function Ht(e){let t=Cw.exec(e);return t[1]!==void 0?Yd(t[1]):t[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,`
`)}var Iw=new Map([["b","\b"],["f","\f"],["n",`
`],["r","\r"],["t","	"],["v","\v"],["0","\0"]]);function on(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 o=e[++n];t+=Iw.get(o)??o}else t+=r}return t}var Bt=class{constructor(t,n,r){de(this,"tokens",t);de(this,"types",n);de(this,"diagram",r);de(this,"i",0);de(this,"kinds");this.kinds=t.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()}\``;throw st(this.diagram,this.tokens.src,this.tokens.starts[this.i],`Expecting ${t} but found ${n}.`)}};var xm={name:"ID",pattern:/[\w]([-\w]*\w)?/y};function Vr(e){return{name:e,pattern:e,longer:[xm]}}var Am=[Vr("architecture-beta"),Vr("junction"),Vr("service"),Vr("column"),Vr("group"),Vr("align"),Vr("row"),{name:"--",pattern:"--",longer:[Ut]},Vr("in"),{name:":",pattern:":"},{name:"-",pattern:"-",longer:[Ut]},{name:"ARROW_DIRECTION",pattern:/L|R|T|B/y},{name:"ARROW_GROUP",pattern:/\{group\}/y},{name:"ARROW_INTO",pattern:/<|>/y},tn,zt,Vt,Cn,xm,bn,yn,Ut,jt,Xt,{name:"ARCH_ICON",pattern:/\([\w-:]+\)/y},{name:"ARCH_TITLE",pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];function Hd(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 Sm(e){let t=new Bt(Wt(e,Am,"architecture"),Am,"architecture"),n={$type:"Architecture",groups:[],services:[],junctions:[],edges:[],alignments:[]},r=s=>t.kinds[t.i]===s,o=()=>{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=Ht(t.take());break;case 15:n.accTitle=Yt(t.take());break;case 16:n.title=Gt(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=Hd(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=on(t.take()):r(24)&&(s.icon=t.take().slice(1,-1)),r(25)&&(s.title=Hd(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 i=t.expect(11),c=t.accept(13),l;t.accept(7)||(r(10)||t.fail("'--' or '-'"),t.i++,l=Hd(t.expect(25)),t.expect(10));let f=t.accept(13),p=t.expect(11);t.expect(9);let u=t.expect(18),m=t.accept(12);n.edges.push({$type:"Edge",lhsId:s,lhsGroup:a,lhsDir:i,lhsInto:c,title:l,rhsInto:f,rhsDir:p,rhsId:u,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")}o()}return n}var kw=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 _m(e){let t=kw.get(e);return t===void 0?"":`<path d="${t}" stroke="var(--_fg)" stroke-width="1.5"/>`}var mo=[-1,1,0,0],Ha=[0,0,-1,1];function go(e){return e==="L"?0:e==="R"?1:e==="T"?2:3}var wm=64,Ka=2**25,Rm=2**26;function Tm(e,t,n,r){let o=e.length,s=t.length,a=s,i=new Map,c=new Map,l=new Int32Array(o+s).fill(a),f=new Int32Array(s+1),p=[];for(let G=0;G<=s;G++)p.push([]);t.forEach((G,se)=>{c.set(G.id,se);let q=G.in===void 0?void 0:c.get(G.in);q!==void 0&&q!==se?(l[o+se]=q,f[se]=f[q]+1):f[se]=1}),e.forEach((G,se)=>{i.set(G.id,se);let q=G.in===void 0?void 0:c.get(G.in);q!==void 0&&(l[se]=q),p[l[se]].push(se)});for(let G=0;G<s;G++)p[l[o+G]].push(o+G);let u=[],m=[],h=[],b=[],x=[],E=[],w=new Array(o+s),S=new Array(o+s),O=(G,se,q,P,V)=>{if(G===se)return;let ne=G,ae=se,Z=l[G],Q=l[se];for(;Z!==Q;)f[Z]>=f[Q]?(ne=o+Z,Z=l[ne]):(ae=o+Q,Q=l[ae]);let ie=u.length;u.push(G),m.push(se),h.push(q),b.push(P),x.push(ne),E.push(ae),(V[ne]??=[]).push(ie),(V[ae]??=[]).push(ie)};for(let G of r){let se=G.direction==="row";for(let q=1;q<G.members.length;q++){let P=i.get(G.members[q-1]),V=i.get(G.members[q]);P!==void 0&&V!==void 0&&O(P,V,se?1:3,se?0:2,w)}}for(let G of[!1,!0])for(let se of n){if(se.lhsDir===se.rhsDir!==G)continue;let q=i.get(se.lhsId),P=i.get(se.rhsId);q!==void 0&&P!==void 0&&O(q,P,go(se.lhsDir),go(se.rhsDir),S)}let D=new Int32Array(o+s),L=new Int32Array(o+s),B=new Int32Array(o+s).fill(1),W=new Int32Array(o+s).fill(1),Y=new Uint8Array(o+s),I=[],X=new Map,ee=[],K=new Map,z=0,C=0,M=0,T=(G,se)=>{C=0,M=0;for(let q=G;q!==se;q=o+l[q])C+=D[q],M+=L[q]},g=(G,se,q)=>{if(D[G]=se,L[G]=q,Y[G]=1,I.push(G),B[G]*W[G]>wm){ee.push(G);return}for(let P=q;P<q+W[G];P++)for(let V=se;V<se+B[G];V++)X.set((V+Ka)*Rm+P+Ka,G)},_=(G,se,q,P,V)=>D[G]<se+P&&se<D[G]+B[G]&&L[G]<q+V&&q<L[G]+W[G],y=(G,se,q,P)=>{if(q*P>wm){for(let V=z;V<I.length;V++)if(_(I[V],G,se,q,P))return I[V];return-1}for(let V=se;V<se+P;V++)for(let ne=G;ne<G+q;ne++){let ae=X.get((ne+Ka)*Rm+V+Ka);if(ae!==void 0)return ae}for(let V of ee)if(_(V,G,se,q,P))return V;return-1},R=(G,se,q,P,V,ne)=>{let ae=`${G},${se},${q},${P},${V},${ne}`,Z=K.get(ae)??0;for(;;){let Q=y(G+Z*V,se+Z*ne,q,P);if(Q<0)break;Z=V>0?D[Q]+B[Q]-G:V<0?G+q-D[Q]:ne>0?L[Q]+W[Q]-se:se+P-L[Q]}return K.set(ae,Z),Z},A=(G,se)=>{let q=x[se]===G,P=q?E[se]:x[se];if(Y[P])return;let V=q?h[se]:b[se],ne=q?b[se]:h[se];T(q?u[se]:m[se],G);let ae=C,Z=M;T(q?m[se]:u[se],P);let Q=mo[V],ie=Ha[V],me=0,re=0,te=mo[V]+mo[ne]===0&&Ha[V]+Ha[ne]===0;V===ne?(Q=mo[V]===0?1:0,ie=1-Q):te||(me=-mo[ne],re=-Ha[ne]);let he,oe;if(Q!==0?(he=Q>0?D[G]+B[G]:D[G]-B[P],oe=L[G]+Z+re-M):(oe=ie>0?L[G]+W[G]:L[G]-W[P],he=D[G]+ae+me-C),te){let ge=S[P];if(ge!==void 0&&ge.length>1){let ue=[];for(let fe of ge){let Me=E[fe]===P,Ne=Me?x[fe]:E[fe];if(!Y[Ne]||(Me?h[fe]:b[fe])!==V||(Me?b[fe]:h[fe])!==ne)continue;T(Me?u[fe]:m[fe],Ne);let Be=Q!==0?L[Ne]+M:D[Ne]+C;T(Me?m[fe]:u[fe],P),ue.push(Be-(Q!==0?M:C))}ue.length>1&&(ue.sort((fe,Me)=>fe-Me),Q!==0?oe=ue[ue.length-1>>1]:he=ue[ue.length-1>>1])}let Ee=Q===0?1:0,be=1-Ee,ye=R(he,oe,B[P],W[P],Ee,be),Re=ye===0?0:R(he,oe,B[P],W[P],-Ee,-be),Le=ye<=Re?ye:-Re;he+=Ee*Le,oe+=be*Le}else{let ge=R(he,oe,B[P],W[P],Q,ie);he+=Q*ge,oe+=ie*ge}g(P,he,oe)},N=G=>{let se=p[G];if(se.length===0)return;I.length=0;let q=[];for(let ge of se){if(Y[ge])continue;z=I.length,q.push(z),X.clear(),ee.length=0,K.clear(),g(ge,0,0);let Ee=z,be=z,ye=0;for(;;){if(Ee<I.length){let Le=I[Ee++],ue=w[Le];if(ue!==void 0)for(let fe of ue)A(Le,fe);continue}if(be>=I.length)break;let Re=S[I[be]];if(Re===void 0||ye>=Re.length){be++,ye=0;continue}A(I[be],Re[ye++])}}q.push(I.length);let P=q.length-1,V=new Array(P),ne=new Array(P),ae=new Array(P),Z=new Array(P),Q=0,ie=0;for(let ge=0;ge<P;ge++){let Ee=1/0,be=1/0,ye=-1/0,Re=-1/0;for(let Le=q[ge];Le<q[ge+1];Le++){let ue=I[Le];Ee=Math.min(Ee,D[ue]),be=Math.min(be,L[ue]),ye=Math.max(ye,D[ue]+B[ue]),Re=Math.max(Re,L[ue]+W[ue])}V[ge]=Ee,ne[ge]=be,ae[ge]=ye-Ee,Z[ge]=Re-be,Q+=ae[ge]*Z[ge],ie=Math.max(ie,ae[ge])}let me=Math.max(ie,Math.ceil(Math.sqrt(Q*2))),re=0,te=0,he=0,oe=0;for(let ge=0;ge<P;ge++){re>0&&re+ae[ge]>me&&(te+=he,re=0,he=0);for(let Ee=q[ge];Ee<q[ge+1];Ee++)D[I[Ee]]+=re-V[ge],L[I[Ee]]+=te-ne[ge];re+=ae[ge],he=Math.max(he,Z[ge]),oe=Math.max(oe,re)}G<s&&(B[o+G]=oe,W[o+G]=te+he)};for(let G=s-1;G>=0;G--)N(G);N(a);let $=new Int32Array(s),U=new Int32Array(s),j=new Int32Array(s),v=new Uint8Array(s);for(let G=0;G<s;G++){let se=l[o+G];j[G]=se===a?-1:se,$[G]=D[o+G]+(se===a?0:$[se]),U[G]=L[o+G]+(se===a?0:U[se]),p[G].length===0&&(v[G]=1)}let k=new Int32Array(o),F=new Int32Array(o),H=new Int32Array(o);for(let G=0;G<o;G++){let se=l[G];H[G]=se===a?-1:se,k[G]=D[G]+(se===a?0:$[se]),F[G]=L[G]+(se===a?0:U[se])}return{col:k,row:F,groupCol:$,groupRow:U,groupCols:B.slice(o),groupRows:W.slice(o),groupParent:j,groupEmpty:v,nodeParent:H}}var _n=12,Lw=6,Cm=4,Nm=3,$w=[-1,1,0,0],Dw=[0,0,-1,1];function Kd(e,t,n,r,o){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(o,Math.max(r,a)):n}function Mm(e){let t=new Map;for(let n of e.sort((r,o)=>r-o))t.has(n)||t.set(n,t.size);return t}function Im(e,t,n,r,o){return`<svg class="pele-icon" data-icon="${Fe(e)}" x="${d(t)}" y="${d(n)}" width="${d(r)}" height="${d(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${o?.(e)??_m(e)}</svg>`}function Ow(e,t,n,r){let o=e.lines.length>n;if(!o&&e.width<=t)return e;let s=r.width("…",e.size,0),a=[],i=[],c=0;for(let l=0;l<Math.min(n,e.lines.length);l++){let f=e.lines[l].map(u=>({...u})),p=e.widths[l];if(p>t||o&&l===n-1)for(;;){let u=f[f.length-1];if(u===void 0){f.push({text:"…",style:0,width:s}),p=s;break}let m=p-u.width;if(u.icon===void 0&&m+s<t){let h=0,b=u.text.length;for(;h<b;){let E=h+b+1>>1;m+r.width(u.text.slice(0,E),e.size,u.style)+s<=t?h=E:b=E-1}let x=h>0?u.text.charCodeAt(h-1):0;x>=55296&&x<=56319&&h--,u.text=u.text.slice(0,h).trimEnd()+"…",u.width=r.width(u.text,e.size,u.style),p=m+u.width;break}f.pop(),p=m}a.push(f),i.push(p),c=Math.max(c,p)}return{...e,lines:a,widths:i,width:c,height:a.length*e.lineHeight}}function vw(e,t){let{x:n,y:r,dx:o,dy:s}=e,{x:a,y:i,dx:c,dy:l}=t,f=n+o*_n,p=r+s*_n,u=a+c*_n,m=i+l*_n;if(o*c+s*l===0){let E=o!==0?a:n,w=o!==0?r:i;return(E-n)*o+(w-r)*s>0&&(E-a)*c+(w-i)*l>0?[n,r,E,w,a,i]:o!==0?[n,r,f,p,f,m,u,m,a,i]:[n,r,f,p,u,p,u,m,a,i]}let h=o!==0,b=h?i-r:a-n;if(o===-c&&s===-l){if((a-n)*o+(i-r)*s>0){if(Math.abs(b)<.5)return[n,r,a,i];if(h){let D=o>0?e.x1:t.x1,L=o>0?t.x0:e.x0,B=D<L?(D+L)/2:(n+a)/2;return[n,r,B,r,B,i,a,i]}let w=s>0?e.y1:t.y1,S=s>0?t.y0:e.y0,O=w<S?(w+S)/2:(r+i)/2;return[n,r,n,O,a,O,a,i]}}else if(Math.abs(b)>=1){if(h){let w=o>0?Math.max(n,a)+_n:Math.min(n,a)-_n;return[n,r,w,r,w,i,a,i]}let E=s>0?Math.max(r,i)+_n:Math.min(r,i)-_n;return[n,r,n,E,a,E,a,i]}if(h){let E=e.y1+_n<=t.y0?(e.y1+t.y0)/2:t.y1+_n<=e.y0?(t.y1+e.y0)/2:Math.max(e.y1,t.y1)+_n;return[n,r,f,r,f,E,u,E,u,i,a,i]}let x=e.x1+_n<=t.x0?(e.x1+t.x0)/2:t.x1+_n<=e.x0?(t.x1+e.x0)/2:Math.max(e.x1,t.x1)+_n;return[n,r,n,p,x,p,x,m,a,m,a,i]}function Pw(e){let t=[e[0],e[1]];for(let n=2;n<e.length;n+=2){let r=e[n],o=e[n+1],s=t.length,a=Math.abs(r-t[s-2])<.01,i=Math.abs(o-t[s-1])<.01;a&&i||(s>=4&&(a&&Math.abs(t[s-4]-t[s-2])<.01||i&&Math.abs(t[s-3]-t[s-1])<.01)?(t[s-2]=r,t[s-1]=o):t.push(r,o))}return t}function Bw(e,t,n){let r=e.length/2,o=new Array(r),s=new Array(r);for(let c=0;c<r;c++)o[c]=e[c*2],s[c]=e[c*2+1];let a=(c,l,f)=>{let p=Math.hypot(o[l]-o[c],s[l]-s[c]),u=Math.min(f,Math.max(0,p-1));p>0&&u>0&&(o[c]+=(o[l]-o[c])/p*u,s[c]+=(s[l]-s[c])/p*u)};a(0,1,t),a(r-1,r-2,n);let i=`M${d(o[0])},${d(s[0])}`;for(let c=1;c<r-1;c++){let l=Math.hypot(o[c]-o[c-1],s[c]-s[c-1]),f=Math.hypot(o[c+1]-o[c],s[c+1]-s[c]),p=Math.min(Lw,l/2,f/2);if(p<.5){i+=`L${d(o[c])},${d(s[c])}`;continue}let u=o[c]-(o[c]-o[c-1])/l*p,m=s[c]-(s[c]-s[c-1])/l*p,h=o[c]+(o[c+1]-o[c])/f*p,b=s[c]+(s[c+1]-s[c])/f*p;i+=`L${d(u)},${d(m)}Q${d(o[c])},${d(s[c])} ${d(h)},${d(b)}`}return i+`L${d(o[r-1])},${d(s[r-1])}`}function km(e,t,n){return gn(n,r=>Fw(e,t,n,r))}function Fw(e,t,n,r){let o=Kd(t,"iconSize",48,8,512),s=Kd(t,"fontSize",n.fontSize??16,4,128),a=Math.min(Kd(t,"padding",20,0,256),r?12:1/0),i=Math.round(s*.875),c=n.measurer??et(n.fontFamily),l=n.padding??8,f=n.icons,p=o/2,u=[...e.nodes.values()],m=[...e.groups.values()],h=u.length,b=m.length,x=Tm(u,m,e.edges,e.layoutHints),E=new Map;u.forEach((le,we)=>E.set(le.id,we));let w=new Array(h),S=new Float64Array(h),O=new Float64Array(h),D=r?Math.max(o,64):Math.max(o*2.25,96);for(let le=0;le<h;le++){let we=u[le],Te=We(we.type==="service"?we.title:void 0,!0,c,s,D);w[le]=Te,S[le]=Math.max(o,2*Math.ceil(Te.width/2)),O[le]=o+(Te.height>0?Cm+Te.height:0)}let L=[],B=[];for(let le=0;le<h;le++)L.push(x.col[le]),B.push(x.row[le]);for(let le=0;le<b;le++)x.groupEmpty[le]&&(L.push(x.groupCol[le]),B.push(x.groupRow[le]));let W=Mm(L),Y=Mm(B),I=W.size,X=Y.size,ee=new Float64Array(I),K=new Float64Array(X),z=r?Math.max(24,2*_n):Math.max(40,Math.round(o*.75)),C=new Float64Array(I).fill(z),M=new Float64Array(X).fill(z),T=new Int32Array(h),g=new Int32Array(h);for(let le=0;le<h;le++){let we=T[le]=W.get(x.col[le]),Te=g[le]=Y.get(x.row[le]);ee[we]=Math.max(ee[we],S[le]),K[Te]=Math.max(K[Te],O[le])}for(let le=0;le<b;le++){if(!x.groupEmpty[le])continue;let we=W.get(x.groupCol[le]),Te=Y.get(x.groupRow[le]);ee[we]=Math.max(ee[we],o),K[Te]=Math.max(K[Te],p)}let _=e.edges.length,y=new Array(_),R=new Int32Array(_*2);for(let le=0;le<_;le++){let we=e.edges[le],Te=R[le*2]=E.get(we.lhsId)??-1,Ce=R[le*2+1]=E.get(we.rhsId)??-1,Ie=We(we.title,!0,c,i,160);if(y[le]=Ie,!(Ie.width===0||Te<0||Ce<0)){if(T[Te]!==T[Ce]){let Pe=Math.min(T[Te],T[Ce]);C[Pe]=Math.max(C[Pe],Math.ceil(Ie.width)+28)}else if(ee[T[Te]]=Math.max(ee[T[Te]],2*Math.ceil(Ie.width/2)+8),g[Te]!==g[Ce]){let Pe=Math.min(g[Te],g[Ce]);M[Pe]=Math.max(M[Pe],Math.ceil(Ie.height)+24)}}}let A=new Array(b),N=new Int32Array(b),$=new Int32Array(b),U=new Int32Array(b),j=new Int32Array(b),v=new Float64Array(b),k=new Float64Array(b),F=new Float64Array(b),H=new Float64Array(b),G=new Float64Array(b),se=new Float64Array(b),q=new Float64Array(I),P=new Float64Array(I),V=new Float64Array(X),ne=new Float64Array(X),ae=Math.round(s*1.25);for(let le=0;le<b;le++){N[le]=W.get(x.groupCol[le]),$[le]=W.get(x.groupCol[le]+x.groupCols[le]-1),U[le]=Y.get(x.groupRow[le]),j[le]=Y.get(x.groupRow[le]+x.groupRows[le]-1);let we=We(m[le].title,!0,c,s,r?Math.max(80,Tt(n)/2):320);A[le]=we;let Te=m[le].icon?ae:0;G[le]=we.width+Te+(we.width>0&&Te>0?6:0),se[le]=Math.max(we.height,Te)}for(let le=b-1;le>=0;le--){let we=a+v[le],Te=a+k[le],Ce=(se[le]>0?Math.max(a,se[le]+12):a)+F[le],Ie=a+H[le];if(G[le]>0){let Ue=we+Te;for(let ke=N[le];ke<=$[le];ke++)Ue+=ee[ke]+(ke<$[le]?P[ke]+C[ke]+q[ke+1]:0);G[le]+20>Ue&&(Te+=Math.ceil(G[le]+20-Ue))}v[le]=we,k[le]=Te,F[le]=Ce,H[le]=Ie,q[N[le]]=Math.max(q[N[le]],we),P[$[le]]=Math.max(P[$[le]],Te),V[U[le]]=Math.max(V[U[le]],Ce),ne[j[le]]=Math.max(ne[j[le]],Ie);let Pe=x.groupParent[le];Pe<0||(N[Pe]===N[le]&&(v[Pe]=Math.max(v[Pe],we)),$[Pe]===$[le]&&(k[Pe]=Math.max(k[Pe],Te)),U[Pe]===U[le]&&(F[Pe]=Math.max(F[Pe],Ce)),j[Pe]===j[le]&&(H[Pe]=Math.max(H[Pe],Ie)))}let Z=new Float64Array(I),Q=new Float64Array(X),ie=0;for(let le=0;le<I;le++)Z[le]=ie+q[le],ie=Z[le]+ee[le]+P[le]+(le<I-1?C[le]:0);let me=0;for(let le=0;le<X;le++)Q[le]=me+V[le],me=Q[le]+K[le]+ne[le]+(le<X-1?M[le]:0);let re=0,te=0,he=ie,oe=me,ge=le=>Z[N[le]]-v[le],Ee=le=>Z[$[le]]+ee[$[le]]+k[le],be=le=>Q[U[le]]-F[le],ye=le=>Q[j[le]]+K[j[le]]+H[le],Re=le=>Z[T[le]]+ee[T[le]]/2,Le=(le,we,Te)=>{let Ce=$w[we],Ie=Dw[we],Pe=Re(le),Ue=Q[g[le]],ke={x:Pe,y:Ue+p,dx:Ce,dy:Ie,x0:Pe-S[le]/2,y0:Ue,x1:Pe+S[le]/2,y1:Ue+O[le],gap:0,wire:!1};u[le].type==="junction"?(ke.x0=ke.x1=Pe,ke.y0=ke.y1=ke.y,ke.gap=Nm):Ce!==0?ke.x=Pe+Ce*p:ke.y=Ie<0?Ue:Ue+O[le]+(w[le].height>0?2:0);let Ke=Te?x.nodeParent[le]:-1;return Ke>=0&&(ke.x0=ge(Ke),ke.x1=Ee(Ke),ke.y0=be(Ke),ke.y1=ye(Ke),ke.gap=0,ke.wire=u[le].type==="junction",Ce!==0?ke.x=Ce<0?ke.x0:ke.x1:ke.y=Ie<0?ke.y0:ke.y1),ke},ue="",fe="",Me=[],Ne=mt("arrow_point");for(let le=0;le<_;le++){let we=e.edges[le],Te=R[le*2],Ce=R[le*2+1];if(Te<0||Ce<0)continue;let Ie=Le(Te,go(we.lhsDir),we.lhsGroup),Pe=Le(Ce,go(we.rhsDir),we.rhsGroup);Ie.x===Pe.x&&Ie.y===Pe.y&&Ie.dx===Pe.dx&&(Ie.x-=8*Math.abs(Ie.dy),Ie.y-=8*Math.abs(Ie.dx),Pe.x+=8*Math.abs(Ie.dy),Pe.y+=8*Math.abs(Ie.dx));let Ue=vw(Ie,Pe);Ie.wire&&Ue.unshift(Re(Te),Q[g[Te]]+p),Pe.wire&&Ue.push(Re(Ce),Q[g[Ce]]+p);let ke=Pw(Ue);if(ke.length<4)continue;let Ke=Fe(`${we.lhsId}-${we.rhsId}`);ue+=`<g class="pele-edge" data-id="${Ke}"><path d="${Bw(ke,we.lhsInto&&!Ie.wire?Ne+Ie.gap:0,we.rhsInto&&!Pe.wire?Ne+Pe.gap:0)}"/>`+(we.lhsInto?Et("arrow_point",Ie.x+Ie.dx*Ie.gap,Ie.y+Ie.dy*Ie.gap,-Ie.dx,-Ie.dy,"var(--_l)"):"")+(we.rhsInto?Et("arrow_point",Pe.x+Pe.dx*Pe.gap,Pe.y+Pe.dy*Pe.gap,-Pe.dx,-Pe.dy,"var(--_l)"):"")+"</g>";let Ve=-1,ct=-1,tt=-1,rt=-1,Ct=y[le];for(let dt=0;dt<ke.length;dt+=2)re=Math.min(re,ke[dt]-4),he=Math.max(he,ke[dt]+4),te=Math.min(te,ke[dt+1]-4),oe=Math.max(oe,ke[dt+1]+4);for(let dt=0;dt+3<ke.length;dt+=2){let It=Math.abs(ke[dt+1]-ke[dt+3])<.01,xt=Math.abs(ke[dt]-ke[dt+2])+Math.abs(ke[dt+1]-ke[dt+3]);It||Me.push(ke[dt],Math.min(ke[dt+1],ke[dt+3]),Math.max(ke[dt+1],ke[dt+3])),xt>ct&&(Ve=dt,ct=xt),It&&xt>rt&&(tt=dt,rt=xt)}if(Ct.width>0){let dt=rt>=Ct.width+8?tt:Ve,It=(ke[dt]+ke[dt+2])/2,xt=(ke[dt+1]+ke[dt+3])/2,_t=Ct.width+8,Xe=Math.abs(ke[dt]-ke[dt+2])<.01;for(let qe of[Ie,Pe])It+_t/2<=qe.x0||It-_t/2>=qe.x1||xt+Ct.height/2<=qe.y0||xt-Ct.height/2>=qe.y1||(Xe?It=It>=(qe.x0+qe.x1)/2?qe.x1+_t/2+4:qe.x0-_t/2-4:xt=xt>=(qe.y0+qe.y1)/2?qe.y1+Ct.height/2+4:qe.y0-Ct.height/2-4);re=Math.min(re,It-_t/2),he=Math.max(he,It+_t/2),te=Math.min(te,xt-Ct.height/2),oe=Math.max(oe,xt+Ct.height/2),fe+=sn(`${we.lhsId}-${we.rhsId}`,Ct,It,xt,"",f)}}let Be="";for(let le=0;le<b;le++){let we=m[le],Te=ge(le),Ce=be(le),Ie=Ee(le)-Te,Pe=A[le],Ue="";if(G[le]>0){let ke=Ce+se[le]+12,Ke=[];for(let rt=0;rt<Me.length;rt+=3)Me[rt+1]<ke&&Me[rt+2]>Ce&&Me[rt]>Te&&Me[rt]<Te+Ie&&Ke.push(Me[rt]);Ke.sort((rt,Ct)=>rt-Ct),Ke.push(Te+Ie-4);let Ve=Te+10;for(let rt of Ke){if(rt-6-Ve>=G[le])break;Ve=Math.max(Ve,rt+6)}Ve+G[le]>Te+Ie-4&&(Ve=Te+10);let ct=Ce+6+se[le]/2,tt=Ve;we.icon&&(Ue+=Im(we.icon,Ve,ct-ae/2,ae,f),tt+=ae+6),Ue+=De(Pe,tt+Pe.width/2,ct,' class="pele-cluster-label" fill="var(--_m)"',f)}Be+=`<g class="pele-cluster" data-id="${Fe(we.id)}"><rect x="${d(Te)}" y="${d(Ce)}" width="${d(Ie)}" height="${d(ye(le)-Ce)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${it}/>`+Ue+"</g>"}let ce="",Se=o*.5,$e=Math.max(6,Math.round(s*.75));for(let le=0;le<h;le++){let we=u[le],Te=`data-id="${Fe(we.id)}" transform="translate(${d(Re(le))},${d(Q[g[le]])})"`;if(we.type==="junction"){ce+=`<g class="pele-node pele-junction" ${Te}><circle cy="${d(p)}" r="${Nm}" fill="var(--_l)"/></g>`;continue}let Ce="";if(we.icon)Ce=Im(we.icon,-Se/2,(o-Se)/2,Se,f);else if(we.iconText){let Ie=We(we.iconText,!1,c,$e,o-8),Pe=Math.max(1,Math.floor((o-4)/(Ie.lineHeight||1)));Ce=De(Ow(Ie,o-8,Pe,c),0,p,` class="pele-icon-text" font-size="${$e}"`,f)}ce+=`<g class="pele-node pele-service" ${Te}><rect x="${d(-p)}" width="${d(o)}" height="${d(o)}" fill="var(--_s)" stroke="var(--_b)"${it}/>`+Ce+De(w[le],0,o+Cm+w[le].height/2,' class="pele-label"',f)+"</g>"}let Ae=We(e.title,!1,c,s,r?Tt(n):4e3,1),xe=Ae.height>0?Ae.height+12:0,Oe=Math.ceil(Math.max(he-re,Ae.width)+2*l),ve=Math.ceil(oe-te+xe+2*l),Ge=Math.round((Oe-(he-re))/2-re),pe=Math.round(l+xe-te),J=(Be?`<g class="pele-clusters">${Be}</g>`:"")+(ue?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${ue}</g>`:"")+(fe?`<g class="pele-edge-labels" font-size="${i}">${fe}</g>`:"")+(ce?`<g class="pele-nodes">${ce}</g>`:"");return{svg:Ze("architecture",Oe,ve,s,n,e,De(Ae,Oe/2,l+Ae.height/2,' class="pele-title" font-weight="var(--_tw)"')+(J?`<g transform="translate(${Ge},${pe})">${J}</g>`:"")),width:Oe,height:ve,links:[]}}var Lm={type:"architecture",parse(e,t,n){let r=new Ya;return n&&(r.title=n),ym(Sm(e),r),r},render:km};var $m=1e5;function Ww(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 Uw(e){switch(e.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}function Gw(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 Yw(e){return e.includes("==")?"thick":"normal"}function Hw(e){return e.includes(".-")?"dotted":"solid"}function Dm(e,t){let n=e.flat(),r=-1;for(let o of n)if(o.type==="column-setting"){r=o.columns??-1;break}return{list:n,at:0,parent:t,children:[],columns:r}}var za=class{constructor(t={}){de(this,"type","block");de(this,"title");de(this,"root",{id:"root",type:"composite",children:[],columns:-1});de(this,"blocks",[]);de(this,"edges",[]);de(this,"classes",new Map);de(this,"byId",new Map);de(this,"typeStr2Type",Ww);de(this,"edgeStrToEdgeData",Uw);de(this,"edgeStrToEdgeStartData",Gw);de(this,"edgeStrToThickness",Yw);de(this,"edgeStrToPattern",Hw);de(this,"warn");de(this,"pending",new Set);de(this,"edgeCount",new Map);de(this,"ids",0);de(this,"colors",0);de(this,"spaces",0);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 o of n.split(",")){let s=o.indexOf(";"),a=(s===-1?o:o.slice(0,s)+o.slice(s+1)).trim();o.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=[Dm(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 o=r.list[r.at++];switch(r.columns>0&&o.type!=="column-setting"&&typeof o.widthInColumns=="number"&&o.widthInColumns>r.columns&&this.warn?.(`Block ${o.id} width ${o.widthInColumns} exceeds configured column width ${r.columns}`),o.type){case"classDef":this.addStyleClass(o.id,o.css);continue;case"applyClass":this.setCssClass(o.id,o.styleClass??"");continue;case"applyStyles":o.stylesStr&&this.addStyle2Node(o.id,o.stylesStr);continue;case"column-setting":r.parent.columns=o.columns??-1;continue;case"edge":{let c=(this.edgeCount.get(o.id)??0)+1;this.edgeCount.set(o.id,c),o.id=c+"-"+o.id,this.edges.push(o);continue}}o.id??=this.generateId(),o.label||(o.label=o.type==="composite"?"":o.id);let s=this.byId.get(o.id),a=s===void 0||this.pending.delete(o.id);a?(s&&(o.classes=s.classes,o.styles=s.styles),o.type==="composite"&&(o.colorIndex=this.colors++),this.byId.set(o.id,o)):(o.type!=="na"&&(s.type=o.type),o.label!==o.id&&(s.label=o.label));let i=o.children;if(o.children=[],o.type==="space"){let c=o.width??1;if(!(c<=$m-this.spaces))throw new ze(`A block diagram can hold at most ${$m} space blocks.`,"limit",{type:"block"});this.spaces+=Math.max(c,0);for(let l=0;l<c;l++){let f={...o,id:o.id+"-"+l,children:[]};this.byId.set(f.id,f),r.children.push(f)}}else a&&r.children.push(o);i&&i.length>0&&n.push(Dm(i,o))}this.blocks=this.root.children??[]}};var zd=["$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 Kw=["right","left","x","y","up","down"],Om=new Uint8Array(128);for(let e of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])Om[e]=1;function vm(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=(Y,I,X)=>(n.push(Y),r.push(I),o.push(i),i=X,!0),l=(Y,I)=>c(Y,e.slice(i,I),I),f=Y=>{s.push(a),a=Y},p=()=>{s.length>0&&(a=s.pop())},u=Y=>{for(;Y<t&&He(e.charCodeAt(Y));)Y++;return Y},m=Y=>{for(;Y<t;){let I=e.charCodeAt(Y);if(I<48||I>57)break;Y++}return Y},h=Y=>{for(;Y<t&&Qe(e.charCodeAt(Y));)Y++;return Y},b=Y=>e.startsWith(Y,i)&&!Qe(e.charCodeAt(i+Y.length)),x=()=>(e.charCodeAt(i+1)===96?(f(2),i+=2):(f(1),i++),!0),E=Y=>{if(e.charCodeAt(Y)!==46)return-1;do Y++;while(e.charCodeAt(Y)===46);if(e.charCodeAt(Y)!==45)return-1;let I=e.charCodeAt(Y+1);return I===120||I===111||I===62?Y+2:Y+1},w=Y=>{let I=e.charCodeAt(Y);(I===120||I===111||I===60)&&Y++;let X=e.charCodeAt(Y);if(X===46)return E(Y);if(X!==45&&X!==61)return-1;let ee=Y+1;for(;e.charCodeAt(ee)===X;)ee++;if(ee-Y===1)return X===45?E(ee):-1;let K=e.charCodeAt(ee);return K===120||K===111||K===62?ee+1:ee-Y>=3?ee:-1},S=()=>{let Y=w(i);if(Y>=0)return l(33,u(Y));let I=e.charCodeAt(i)===60?i+1:i,X=e.charCodeAt(I),ee=e.charCodeAt(I+1);return X===45&&(ee===45||ee===46)||X===61&&ee===61?(f(6),l(34,u(I+2))):!1},O=Y=>{let I=e.indexOf(`
`,i);return I===-1&&(I=t),p(),l(Y,I)},D=(Y,I)=>{let X=h(i);if(X===i)return!1;for(;e.charCodeAt(X)===44;){let ee=u(X+1),K=h(ee);if(K===ee)break;X=K}return a=I,l(Y,X)},L=Y=>{if(He(Y))return i=u(i+1),!0;let I;switch(Y){case 98:if(e.startsWith("block",i)){if(b("block-beta"))return l(2,i+10);if(e.charCodeAt(i+5)===58)return l(3,i+6);if(!Qe(e.charCodeAt(i+5)))return l(2,i+5)}break;case 99:if(e.startsWith("columns",i)){if(I=u(i+7),I>i+7){if(e.startsWith("auto",I)&&!Qe(e.charCodeAt(I+4)))return c(4,"-1",I+4);let X=m(I);if(X>I)return c(4,e.slice(I,X),X)}}else if(e.startsWith("class",i)){let X=e.startsWith("Def",i+5),ee=X?i+8:i+5;if(I=u(ee),I>ee)return f(X?7:9),l(X?11:15,I)}break;case 34:return x();case 115:if(e.startsWith("space",i)){if(e.charCodeAt(i+5)===58){let X=m(i+6);if(X>i+6)return c(7,e.slice(i+6,X),X)}if(!Qe(e.charCodeAt(i+5)))return c(7,"1",i+5)}else if(e.startsWith("style",i)&&(I=u(i+5),I>i+5))return f(11),l(18,I);break;case 100:if(b("default"))return l(8,i+7);break;case 108:if(b("linkStyle"))return l(9,i+9);break;case 105:if(b("interpolate"))return l(10,i+11);break;case 97:if(e.startsWith("accTitle",i)){if(I=u(i+8),e.charCodeAt(I)===58)return f(13),l(21,u(I+1))}else if(e.startsWith("accDescr",i)){I=u(i+8);let X=e.charCodeAt(I);if(X===58)return f(14),l(23,u(I+1));if(X===123)return f(15),i=u(I+1),!0}break;case 101:if(b("end"))return l(26,u(i+3));break;case 45:return e.charCodeAt(i+1)===41?(f(3),l(27,i+2)):S();case 61:return S();case 60:return e.charCodeAt(i+1)===91?(f(4),l(29,i+2)):S();case 40:{let X=e.charCodeAt(i+1),ee=X===45||X===91?2:X===40?e.charCodeAt(i+2)===40?3:2:1;return f(3),l(27,i+ee)}case 41:case 123:return f(3),l(27,e.charCodeAt(i+1)===Y?i+2:i+1);case 62:return f(3),l(27,i+1);case 91:{let X=e.charCodeAt(i+1);return f(3),l(27,X===91||X===124||X===40||X===92||X===47?i+2:i+1)}case 58:{let X=m(i+1);return X>i+1?c(36,e.slice(i+1,X),X):!1}}for(I=i;I<t;){let X=e.charCodeAt(I);if(X<128?Om[X]===1:He(X))break;I++}return I>i&&l(32,I)},B=Y=>{let I=e.charCodeAt(i+1),X=0;switch(Y){case 34:return x();case 40:X=I===45?2:I===40?e.charCodeAt(i+2)===40?3:2:1;break;case 41:X=I===41?e.charCodeAt(i+2)===41?3:2:I===93?2:1;break;case 125:X=I===125?2:1;break;case 45:X=I===41?2:0;break;case 93:X=I===93||I===41||I===62?2:1;break;case 92:case 47:X=I===93?2:0;break}return X===0?!1:(p(),l(28,i+X))},W=Y=>{if(Y===41)return p(),p(),c(30,"]>",u(i+1));let I=u(Y===44?i+1:i);for(let X of Kw)if(e.startsWith(X,I)){let ee=u(I+X.length);return c(31,e.slice(Y===44?I:i,ee),ee)}return!1};for(;;){if(i>=t){let X=-1;switch(a){case 0:X=37;break;case 1:X=6;break;case 8:X=14;break;case 10:X=17;break;case 12:X=20;break;case 13:X=22;break;case 14:X=24;break;case 15:X=25;break}i=t,X!==-1&&c(X,"",t);break}let Y=e.charCodeAt(i),I=!0;switch(a){case 0:I=L(Y);break;case 1:if(Y===34)p(),i++;else{let X=e.indexOf('"',i);l(6,X===-1?t:X)}break;case 2:if(Y===96)I=e.charCodeAt(i+1)===34,I&&(p(),i+=2);else if(Y===34)I=!1;else{let X=i+1;for(;X<t;){let ee=e.charCodeAt(X);if(ee===96||ee===34)break;X++}l(5,X)}break;case 3:I=B(Y);break;case 4:if(Y===34)x();else if(Y===93&&e.charCodeAt(i+1)===62){let X=u(i+2);I=e.charCodeAt(X)===40,I&&(f(5),i=X+1)}else I=!1;break;case 5:I=W(Y);break;case 6:if(Y===34)e.charCodeAt(i+1)===96?x():(l(35,i+1),f(1));else{let X=w(u(i));I=X>=0,I&&(p(),l(33,u(X)))}break;case 7:{let X=12,ee=e.startsWith("DEFAULT",i)?i+7:i,K=u(ee);(ee===i||K===ee)&&(X=13,ee=h(i),K=u(ee)),I=ee>i&&K>ee,I&&(a=8,l(X,K));break}case 8:O(14);break;case 9:I=D(16,10);break;case 10:O(17);break;case 11:I=D(19,12);break;case 12:O(20);break;case 13:O(22);break;case 14:O(24);break;case 15:if(Y===125)p(),i++;else{let X=e.indexOf("}",i);l(25,X===-1?t:X)}break}if(!I)return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}}return n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var bo="'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'";function Pm(e){let t=e[e.length-1];return Array.isArray(t)?(e.pop(),e.concat(t)):e}function Bm(e,t){let{types:n,texts:r,starts:o}=vm(e),s=0,a=u=>{let m=n[s];throw m===1?st("block",e,o[s],"",!0):st("block",e,o[s],`Expecting ${u}, got '${zd[m]}'`)},i=u=>(n[s]!==u&&a(`'${zd[u]}'`),r[s++]),c=()=>{let u=i(32);if(n[s]===27){let m=r[s++],h=i(6);return{id:u,label:h,typeStr:m+i(28)}}if(n[s]===29){let m=r[s++],h=i(6),b=[i(31)];for(;n[s]===31;)b.push(r[s++]);return{id:u,label:h,typeStr:m+i(30),directions:b}}return{id:u}},l=()=>{let u=c(),m=n[s]===36?parseInt(r[s++],10):1,h={id:u.id,label:u.label,type:t.typeStr2Type(u.typeStr),directions:u.directions,widthInColumns:m},b;for(;n[s]===33||n[s]===34;){let x="";n[s++]===34&&(i(35),x=i(6),i(33));let E=r[s-1],w=c(),S=t.edgeStrToEdgeData(E),O=t.edgeStrToEdgeStartData(E),D=t.edgeStrToThickness(E),L=t.edgeStrToPattern(E);b??=[{id:h.id,label:h.label,type:h.type,directions:h.directions}],h={id:w.id,label:w.label,type:t.typeStr2Type(w.typeStr),directions:w.directions},b.push({id:b[b.length-1].id+"-"+w.id,start:b[b.length-1].id,end:w.id,label:x,type:"edge",thickness:D,pattern:L,directions:w.directions,arrowTypeEnd:S,arrowTypeStart:O},h)}return b??h};i(2);let f=[],p=[];for(;;)switch(n[s]){case 32:p.push(l());break;case 4:p.push({type:"column-setting",columns:parseInt(r[s++],10)});break;case 7:{let u=parseInt(r[s++],10);p.push({id:t.generateId(),type:"space",label:"",width:u,children:[]});break}case 2:s++,f.push({list:p,header:void 0}),p=[];break;case 3:s++,n[s]!==32&&a("'NODE_ID'"),f.push({list:p,header:l()}),p=[];break;case 26:{let u=f.pop();if(u===void 0||p.length===0)return a(bo);s++;let m=t.generateId(),h=Pm(p);p=u.list,p.push(u.header===void 0?{id:m,type:"composite",label:"",children:h}:{...u.header,type:"composite",children:h});break}case 11:{s++;let u=i(13).trim();p.push({type:"classDef",id:u,css:i(14).trim()});break}case 15:{s++;let u=i(16).trim();p.push({type:"applyClass",id:u,styleClass:i(17).trim()});break}case 18:{s++;let u=i(19).trim();p.push({type:"applyStyles",id:u,stylesStr:i(20).trim()});break}case 37:f.length>0&&a(bo+", 'end'"),p.length===0&&a(bo),t.setHierarchy(Pm(p));return;default:a(p.length===0?bo:bo+(f.length>0?", 'end'":", 'EOF'"))}}function hn(e,t,n,r){return Xp(()=>We(e,!1,t,n,r,1))}function Va(e,t,n,r,o,s,a){let i=hn(e,t,n,4e3);if(i.height===0)return{width:o,height:s,content:a};let c=i.height+12,l=Math.max(o,Math.ceil(i.width+2*r));return{width:l,height:Math.ceil(s+c),content:De(i,l/2,r+i.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d((l-o)/2)},${d(c)})">${a}</g>`}}var fr=1,pr=2,hr=4,mr=8,Ns=7,ja=20,Xr=12;function Fm(e){let t=0;if(e)for(let n of e)switch(n.trim()){case"right":t|=fr;break;case"left":t|=pr;break;case"up":t|=hr;break;case"down":t|=mr;break;case"x":t|=fr|pr;break;case"y":t|=hr|mr;break}return t}var jr=(e,t)=>e&t?1:0;function yo(e){return e!==0&&(e&(hr|mr))===0?"x":e!==0&&(e&(fr|pr))===0?"y":""}function Vd(e,t,n){let r=yo(e),o=jr(e,pr)-jr(e,fr),s=jr(e,hr)-jr(e,mr);if(r==="x"){let a=Math.max(n+8,14)+2*Ns,i=Math.min(a/2,ja);return{w:Math.max(t+12,16)+i*(e===(fr|pr)?2:1),h:a,dx:o*i/2,dy:0}}if(r==="y"){let a=Math.max(t+16,14)+2*Ns,i=Math.min(a/2,ja);return{w:a,h:Math.max(n+8,16)+i*(e===(hr|mr)?2:1),dx:0,dy:s*i/2}}return{w:Math.max(t+16,24)+Xr*(jr(e,pr)+jr(e,fr)),h:Math.max(n+8,24)+Xr*(jr(e,hr)+jr(e,mr)),dx:o*Xr/2,dy:s*Xr/2}}function Wm(e,t,n,r){let o=yo(e),s=t/2,a=n/2,i;if(o==="x"){let l=Math.min(a,ja),f=a-Ns,p=e&pr?-s+l:-s,u=e&fr?s-l:s;i=[p,-f,u,-f],e&fr&&i.push(u,-a,s,0,u,a),i.push(u,f,p,f),e&pr&&i.push(p,a,-s,0,p,-a)}else if(o==="y"){let l=Math.min(s,ja),f=s-Ns,p=e&hr?-a+l:-a,u=e&mr?a-l:a;i=[f,p,f,u],e&mr&&i.push(s,u,0,a,-s,u),i.push(-f,u,-f,p),e&hr&&i.push(-s,p,0,-a,s,p)}else{let l=e&pr?-s+Xr:-s,f=e&fr?s-Xr:s,p=e&hr?-a+Xr:-a,u=e&mr?a-Xr:a,m=(l+f)/2,h=(p+u)/2,b=Math.min(10,(f-l)/2),x=Math.min(10,(u-p)/2);i=[l,p],e&hr&&i.push(m-b,p,m,-a,m+b,p),i.push(f,p),e&fr&&i.push(f,h-x,s,h,f,h+x),i.push(f,u),e&mr&&i.push(m+b,u,m,a,m-b,u),i.push(l,u),e&pr&&i.push(l,h+x,-s,h,l,h-x)}let c="";for(let l=0;l<i.length;l+=2)c+=(l?" ":"")+d(i[l])+","+d(i[l+1]);return`<polygon points="${c}" stroke-linejoin="round"${r}/>`}var zw=1e3;function Vw(e,t){if(e===0||!Number.isInteger(e))throw new ze("Columns must be an integer !== 0.","semantic",{type:"block"});if(t<0||!Number.isInteger(t))throw new ze("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 jw(e,t,n){let r=e.columns,o=[],s=0,a=0,i=0,c=0;for(let f of e.children){let{px:p,py:u}=Vw(r,s),m=f.span>=1?Math.min(f.span,zw):1;if(r>0&&m>r-p&&(m=r-p),f.span=m,f.col=p,f.row=u,s+=m,p+m>a&&(a=p+m),u===o.length&&o.push(0),f.children.length===0?o[u]=-1:o[u]>=0&&f.nh>o[u]&&(o[u]=f.nh),f.space)continue;let h=(f.nw-t*(m-1))/m;h>i&&(i=h),f.nh>c&&(c=f.nh)}let l=(o.length-1)*t;for(let f=0;f<o.length;f++)o[f]<0&&(o[f]=c),l+=o[f];e.cols=a,e.heights=o,e.nw=Math.max(e.nw,a*i+(a-1)*t+2*n),e.nh=l+2*n+e.head}function Xw(e,t,n){let{cols:r,heights:o}=e,s=o.length,a=(e.w-2*n-(r-1)*t)/r,i=e.h-2*n-e.head-(s-1)*t,c=0;for(let h of o)c+=h;let l=c>0?i/c:0,f=c>0?0:i/s,p=e.x-e.w/2+n,u=e.y-e.h/2+n+e.head,m=0;for(let h of e.children){for(;m<h.row;m++)u+=o[m]*l+f+t;h.w=a*h.span+t*(h.span-1),h.h=o[m]*l+f,h.x=p+h.col*(a+t)+h.w/2,h.y=u+h.h/2}}function Um(e,t){let n=[e];for(let r=0;r<n.length;r++)for(let o of n[r].children)n.push(o);for(let r=n.length-1;r>=0;r--){let o=n[r];o.children.length>0&&jw(o,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 o=n[r];o.children.length>0&&Xw(o,t,r===0?0:t)}return{width:e.w,height:e.h}}var qw=12,Gm=200,Qw=8,Ym=' fill="var(--_s)" stroke="var(--_b)"',Zw=' stroke="var(--_b)"',Hm=[],Jw=[],eR=[],tR=["default"],nR=2e6,rR=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"]]),sR=new Set(["circle","dbl-circ","diam"]),iR=new Set(["stadium","hex","odd","lean-r","lean-l","trap-b","trap-t"]);function Xa(e){return e.kind===0&&(e.shape==="circle"||e.shape==="dbl-circ")}function gi(e,t,n){let r=e.bw/2,o=e.bh/2,s=Math.abs(t-e.x),a=o;return Xa(e)?a=Math.sqrt(Math.max(r*r-s*s,0)):e.kind===0&&e.shape==="diam"?a=o*Math.max(1-s/r,0):e.kind===0?a=o-Mr(e.shape,e.bw,e.bh,n>0?2:0):e.kind===1&&yo(e.mask)==="x"&&(a=o-Ns),e.y+n*a}function bi(e,t,n){let r=e.bw/2,o=e.bh/2,s=Math.abs(t-e.y),a=r;return Xa(e)?a=Math.sqrt(Math.max(o*o-s*s,0)):e.kind===0&&e.shape==="diam"?a=r*Math.max(1-s/o,0):e.kind===0?a=r-Mr(e.shape,e.bw,e.bh,n>0?1:3):e.kind===1&&yo(e.mask)==="y"&&(a=r-Ns),e.x+n*a}function Km(e,t,n,r){let o=t-e.x,s=n-e.y,a=e.bw/2,i=e.bh/2,c;Xa(e)?c=a/(Math.hypot(o,s)||1):e.kind===0&&e.shape==="diam"?c=1/(Math.abs(o)/a+Math.abs(s)/i||1):c=Math.min(o===0?1/0:a/Math.abs(o),s===0?1/0:i/Math.abs(s)),c===1/0&&(c=0),r.push(e.x+o*c,e.y+s*c)}function oR(e,t,n,r,o){let s=o.x-o.bw/2+1,a=o.x+o.bw/2-1,i=o.y-o.bh/2+1,c=o.y+o.bh/2-1;if(e<s&&n<s||e>a&&n>a||t<i&&r<i||t>c&&r>c)return!1;if(e===n||t===r)return!0;let l=n-e,f=r-t,p=(m,h)=>Math.sign(l*(h-t)-f*(m-e)),u=p(s,i);return u===0||p(a,i)!==u||p(a,c)!==u||p(s,c)!==u}function jd(e,t,n,r){let o=0;for(let s of r)if(!(s===t||s===n)){for(let a=0;a+3<e.length;a+=2)if(oR(e[a],e[a+1],e[a+2],e[a+3],s)){o++;break}}return o}function aR(e,t,n,r){let o=e.x-e.bw/2,s=e.x+e.bw/2,a=e.y-e.bh/2,i=e.y+e.bh/2,c=t.x-t.bw/2,l=t.x+t.bw/2,f=t.y-t.bh/2,p=t.y+t.bh/2,u=Math.max(o,c),m=Math.min(s,l),h=Math.max(a,f),b=Math.min(i,p),x=m-u>6,E=b-h>6;if(x&&E){let ee=e.bw*e.bh<=t.bw*t.bh?e:t,K=ee===e?t:e,z=ee.y-ee.bh/2-(K.y-K.bh/2),C=K.y+K.bh/2-(ee.y+ee.bh/2),M=ee.x-ee.bw/2-(K.x-K.bw/2),T=K.x+K.bw/2-(ee.x+ee.bw/2),g=Math.min(z,C,M,T),_;return g===C?_=[ee.x,gi(ee,ee.x,1),ee.x,K.y+K.bh/2]:g===z?_=[ee.x,gi(ee,ee.x,-1),ee.x,K.y-K.bh/2]:g===T?_=[bi(ee,ee.y,1),ee.y,K.x+K.bw/2,ee.y]:_=[bi(ee,ee.y,-1),ee.y,K.x-K.bw/2,ee.y],ee===e?_:[_[2],_[3],_[0],_[1]]}if(x){let ee=Math.min(6,(m-u)/2),K=Math.min(Math.max((u+m)/2+n,u+ee),m-ee),z=t.y>e.y?1:-1;return[K,gi(e,K,z),K,gi(t,K,-z)]}if(E){let ee=Math.min(6,(b-h)/2),K=Math.min(Math.max((h+b)/2+n,h+ee),b-ee),z=t.x>e.x?1:-1;return[bi(e,K,z),K,bi(t,K,-z),K]}let w=t.x>e.x?1:-1,S=t.y>e.y?1:-1,O=[bi(e,e.y,w),e.y,t.x,e.y,t.x,gi(t,t.x,-S)],D=[e.x,gi(e,e.x,S),e.x,t.y,bi(t,t.y,-w),t.y],L=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y),B=L?O:D;if(r===void 0)return B;let W=jd(B,e,t,r);if(W===0)return B;let Y=L?D:O,I=jd(Y,e,t,r);if(I<W&&(B=Y,W=I),W===0)return B;let X=[];return Km(e,t.x,t.y,X),Km(t,e.x,e.y,X),jd(X,e,t,r)<W?X:B}function cR(e,t,n){let r=e.length,o=e[0],s=e[1],a=e[r-2],i=e[r-1],c=e[2]-o,l=e[3]-s,f=Math.hypot(c,l);c/=f||1,l/=f||1;let p=a-e[r-4],u=i-e[r-3],m=Math.hypot(p,u);if(p/=m||1,u/=m||1,r===4&&t+n>f){let b=f/(t+n);t*=b,n*=b}t=Math.min(t,f),n=Math.min(n,m);let h=`M${d(o+c*t)},${d(s+l*t)}`;if(r===6){let b=Math.max(0,Math.min(Qw,f-t,m-n));h+=`L${d(e[2]-c*b)},${d(e[3]-l*b)}Q${d(e[2])},${d(e[3])} ${d(e[2]+p*b)},${d(e[3]+u*b)}`}return h+=`L${d(a-p*n)},${d(i-u*n)}`,{d:h,sx:o,sy:s,sdx:-c,sdy:-l,ex:a,ey:i,edx:p,edy:u}}function zm(e,t){let n=e.bw/2,r=e.bh/2,o=Math.max(1,Math.min(10+5*(t-1),n,r));if(Xa(e)){let s=e.x+n*Math.SQRT1_2,a=e.y-n*Math.SQRT1_2,i=2*Math.asin(Math.min(1,o/(2*n))),c=l=>Math.atan2(e.y-n*Math.sin(l)-a,e.x+n*Math.cos(l)-s);return[s,a,o,c(Math.PI/4+i),c(Math.PI/4-i)]}if(e.kind===0&&e.shape==="diam"){let s=Math.atan2(r,n);return[e.x+n/2,e.y-r/2,o,s+Math.PI,s]}return[e.x+n,e.y-r,o,Math.PI,Math.PI/2]}function lR(e,t,n,r){let[o,s,a,i,c]=zm(e,t),l=i+n/a,f=c-r/a,p=(f-l)%(2*Math.PI);p<=0&&(p+=2*Math.PI);let u=o+a*Math.cos(l),m=s+a*Math.sin(l),h=o+a*Math.cos(f),b=s+a*Math.sin(f),x=o+a*Math.cos(i),E=s+a*Math.sin(i),w=o+a*Math.cos(c),S=s+a*Math.sin(c),O=Math.hypot(x-u,E-m),D=Math.hypot(w-h,S-b);return{d:`M${d(u)},${d(m)}A${d(a)},${d(a)} 0 ${p>Math.PI?1:0} 1 ${d(h)},${d(b)}`,sx:x,sy:E,sdx:O>0?(x-u)/O:Math.sin(i),sdy:O>0?(E-m)/O:-Math.cos(i),ex:w,ey:S,edx:D>0?(w-h)/D:-Math.sin(c),edy:D>0?(S-b)/D:Math.cos(c)}}var dR=[.5,.3,.7,.15,.85];function uR(e,t,n,r,o,s,a){if(a===void 0)return .5;for(let i of dR){let c=e[t]+(e[t+2]-e[t])*i,l=e[t+1]+(e[t+3]-e[t+1])*i,f=!0;for(let p of a)if(p!==o&&p!==s&&Math.abs(c-p.x)<(n+p.bw)/2&&Math.abs(l-p.y)<(r+p.bh)/2){f=!1;break}if(f)return i}return .5}function Vm(e,t,n){return gn(n,r=>fR(e,t,n,r))}function fR(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=n.measurer??et(n.fontFamily),i=n.padding??8,c=n.icons,l=t.block?.padding,f=Math.min(typeof l=="number"&&l>=0?Math.min(l,200):qw,r?6:1/0),p=r?80:Gm,u=v=>{let k=[],F=H=>{for(let G of H)for(let se of G.split(";"))k.push(se)};for(let H of v.classes&&v.classes.length>0?v.classes:tR){let G=e.classes.get(H);G&&F(G.styles)}return v.styles&&F(v.styles),St(k)},m=(v,k)=>{let F=v.type,H=F==="space"?St(Hm):u(v),G=(H.bold?1:0)|(H.italic?2:0),se=H.fontSize??o,q=0,P="",V,ne=0,ae=0,Z=0,Q=0,ie=0,me=0;if(F==="space")q=3,V=We(void 0,!1,a,se,p);else if(F==="composite")q=2,V=We(v.label,!1,a,se,r?Tt(n):4e3,G),Z=V.height>0?V.height+4:0,ne=V.width+2*f,ae=Z+2*f;else if(F==="block_arrow"){q=1,V=We(v.label,!1,a,se,p,G);let re=!0;for(let he of V.lines)for(let oe of he)(oe.icon!==void 0||oe.text.trim()!=="")&&(re=!1);Q=Fm(v.directions);let te=re?Vd(Q,0,0):Vd(Q,V.width,V.height);ne=te.w,ae=te.h,ie=te.dx,me=te.dy}else{P=rR.get(F??"")??"rect",V=We(v.label,!1,a,se,p,G);let re=Hr(P,V.width,V.height);ne=re.w,ae=P==="cyl"?Math.max(re.h,V.height+40):re.h,me=re.dy}return{children:[],columns:q===2?v.columns??-1:-1,span:q===3?1:v.widthInColumns??1,space:q===3,head:Z,nw:ne,nh:ae,col:0,row:0,cols:0,heights:eR,x:0,y:0,w:0,h:0,block:v,kind:q,index:k,shape:P,label:V,style:H,mask:Q,dx:ie,dy:me,bw:0,bh:0}},h=m(e.root,0);h.nw=0,h.nh=0;let b=[h],x=new Map;for(let v=0;v<b.length;v++){let k=b[v];if(k.kind===2)for(let F of k.block.children??Jw){let H=m(F,b.length);k.children.push(H),b.push(H),H.kind!==3&&x.set(F.id,H)}}let E=Um(h,f),w=[];for(let v of b)v.kind===0&&sR.has(v.shape)?(v.bw=v.nw,v.bh=v.nh):v.kind===1?(v.bw=v.span>1?v.w:v.nw,v.bh=v.nh):(v.bw=v.w,v.bh=v.kind===0&&iR.has(v.shape)?v.nh:v.h),v.kind===0&&v.shape==="cyl"&&(v.dy=Math.min(12,Math.max(6,v.bw/14))/2),(v.kind===0||v.kind===1)&&w.push(v);let S=new Map,O=new Set,D=[],L=[];for(let v of e.edges){let k=x.get(v.start??""),F=x.get(v.end??"");if(k===void 0||F===void 0)continue;let H=Math.min(k.index,F.index)*b.length+Math.max(k.index,F.index);S.set(H,(S.get(H)??0)+1),v.label&&O.add(H),D.push([k,F]),L.push(v)}let B=L.length*w.length<=nR?w:void 0,W=new Map,Y=[],I=0,X=0,ee=E.width,K=E.height,z=(v,k,F,H)=>{v-F/2<I&&(I=v-F/2),v+F/2>ee&&(ee=v+F/2),k-H/2<X&&(X=k-H/2),k+H/2>K&&(K=k+H/2)};for(let v=0;v<L.length;v++){let[k,F]=D[v],H=Math.min(k.index,F.index)*b.length+Math.max(k.index,F.index),G=S.get(H)??1,se=W.get(H)??0;W.set(H,se+1);let q=We(L[v].label,!1,a,s,Gm),P,V,ne;if(k===F){let[ae,Z,Q]=zm(k,se+1);P=[],z(ae,Z,2*Q+2,2*Q+2),V=ae+Q+6+q.width/2,ne=Z-Q/2}else{let ae=O.has(H)?Math.round(s*1.5)+2:14;P=aR(k,F,(se-(G-1)/2)*ae,B);let Z=P.length,Q=Math.abs(P[2]-P[0])+Math.abs(P[3]-P[1]),ie=Math.abs(P[Z-2]-P[Z-4])+Math.abs(P[Z-1]-P[Z-3]),me=Z===6&&ie>Q?2:0,re=q.width>0?uR(P,me,q.width+8,q.height,k,F,B):.5;V=P[me]+(P[me+2]-P[me])*re,ne=P[me+1]+(P[me+3]-P[me+1])*re}q.width>0&&z(V,ne,q.width+8,q.height),Y.push({edge:L[v],points:P,loop:k===F?se+1:0,label:q,lx:V,ly:ne})}let C=hn(e.title,a,o,r?Tt(n):4e3),M=C.height>0?C.height+12:0,T=Math.max(ee-I,C.width),g=i-I+(T-(ee-I))/2,_=i+M-X;for(let v of b)v.x+=g,v.y+=_;let y=Math.ceil(T+2*i),R=Math.ceil(K-X+M+2*i),A="",N="";for(let v=1;v<b.length;v++){let k=b[v];if(k.kind===3)continue;let F=Rt((k.block.classes??Hm).join(" ")),H=Fe(k.block.id);if(k.kind===2){let se=k.y-k.h/2;A+=`<g class="pele-cluster${F}" data-id="${H}"><rect x="${d(k.x-k.w/2)}" y="${d(se)}" width="${d(k.w)}" height="${d(k.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${pt(k.style.shape)}/>`+De(k.label,k.x,se+(k.head+f)/2+2,` class="pele-cluster-label" fill="var(--_m)"${k.style.text}`,c)+"</g>";continue}let G=k.kind===1;N+=`<g class="pele-node pele-shape-${G?"block-arrow":k.shape}${F}" data-id="${H}" transform="translate(${d(k.x)},${d(k.y)})">`+(G?Wm(k.mask,k.bw,k.bh,Ym+k.style.shape):Qn(k.shape,k.bw,k.bh,Ym+k.style.shape,Zw+k.style.line))+De(k.label,k.dx,k.dy,` class="pele-label"${k.style.text}`,c)+"</g>"}let $="",U="";for(let v=0;v<Y.length;v++){let{edge:k,points:F,loop:H,label:G}=Y[v],se=k.arrowTypeStart??"",q=k.arrowTypeEnd??"",P;if(H>0)P=lR(D[v][0],H,mt(se),mt(q));else{for(let ne=0;ne<F.length;ne+=2)F[ne]+=g,F[ne+1]+=_;P=cR(F,mt(se),mt(q))}let V=Fe(k.id);if($+=`<g class="pele-edge" data-id="${V}"><path d="${P.d}"${k.thickness==="thick"?' stroke-width="2.5"':""}${k.pattern==="dotted"?' stroke-dasharray="3 4"':""}/>`+Et(se,P.sx,P.sy,P.sdx,P.sdy,"var(--_l)")+Et(q,P.ex,P.ey,P.edx,P.edy,"var(--_l)")+"</g>",G.width>0){let ne=Y[v].lx+g,ae=Y[v].ly+_;U+=sn(k.id,G,ne,ae,"",c)}}return{svg:Ze("block",y,R,o,n,e,De(C,y/2,i+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+(A?`<g class="pele-clusters">${A}</g>`:"")+($?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${$}</g>`:"")+`<g class="pele-nodes">${N}</g>`+(U?`<g class="pele-edge-labels" font-size="${s}">${U}</g>`:"")),width:y,height:R,links:[]}}var jm={type:"block",math:!0,parse(e,t,n){let r=new za;return r.title=n,Bm(e,r),r},render:Vm};var pR=new Set(["label","type","descr","techn","sprite","tags","link","bgColor","fontColor","borderColor","shadowing","shape","legendText","legendSprite"]),hR=new Set(["label","descr","techn","sprite","tags","link","textColor","lineColor"]);function Eo(e,t){let{key:n,value:r}=t;"from"in e&&(n==="offsetX"||n==="offsetY")?e[n]=parseInt(r):("from"in e?hR:pR).has(n)?e[n]=r:(e.extra??=new Map).set(n,r)}function Kt(e,t,n){n!==void 0&&(typeof n=="string"?e[t]=n:Eo(e,n))}function yi(e,t,n){n===void 0?e[t]??="":Kt(e,t,n)}function Xm(e,t){e.labelAttr=void 0,typeof t=="object"?(e.label="",e.labelAttr=t,Eo(e,t)):e.label=t??""}var qa=class{constructor(){de(this,"type","c4");de(this,"c4Type");de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"shapes",[]);de(this,"boundaries",[{alias:"global",label:"global",type:"global",parent:void 0}]);de(this,"rels",[]);de(this,"shapeInRow",4);de(this,"boundaryInRow",2);de(this,"shapeIndex",new Map);de(this,"boundaryIndex",new Map);de(this,"relIndex",new Map);de(this,"current",this.boundaries[0]);de(this,"stack",[])}setC4Type(t){this.c4Type=t}setTitle(t){this.title=t}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
`)}element(t,n,r,o){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,Eo(s,r))),Xm(s,o),s}addPersonOrSystem(t,n){let r=this.element(this.shapes,this.shapeIndex,n[0],n[1]);yi(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]);yi(r,"techn",n[2]),yi(r,"descr",n[3]),this.finishShape(r,t,n,4)}addComponent(t,n){this.addContainer(t,n)}finishShape(t,n,r,o){Kt(t,"sprite",r[o]),Kt(t,"tags",r[o+1]),Kt(t,"link",r[o+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:Kt(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);Kt(r,"tags",t[3]),Kt(r,"link",t[4]),this.open(r)}addContainerBoundary(t){this.addPersonOrSystemBoundary(t,"container")}addDeploymentNode(t,n){let r=this.boundary(n,"node");yi(r,"descr",n[3]),Kt(r,"sprite",n[4]),Kt(r,"tags",n[5]),Kt(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],o=n[1];if(r===void 0||o===void 0||n[2]===void 0)return;let s=typeof r=="string"&&typeof o=="string",a=s?this.relIndex.get(r)?.get(o):void 0;if(a===void 0){if(a={type:t,from:"",to:"",label:""},this.rels.push(a),s){let i=this.relIndex.get(r);i===void 0&&this.relIndex.set(r,i=new Map),i.set(o,a)}typeof r=="string"?a.from=r:a.fromAttr=r,typeof o=="string"?a.to=o:a.toAttr=o}a.type=t,Xm(a,n[2]),yi(a,"techn",n[3]),yi(a,"descr",n[4]),Kt(a,"sprite",n[5]),Kt(a,"tags",n[6]),Kt(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&&(Kt(r,"bgColor",n[1]),Kt(r,"fontColor",n[2]),Kt(r,"borderColor",n[3]),Kt(r,"shadowing",n[4]),Kt(r,"shape",n[5]),Kt(r,"sprite",n[6]),Kt(r,"techn",n[7]),Kt(r,"legendText",n[8]),Kt(r,"legendSprite",n[9]))}updateRelStyle(t,n){let r=n[0],o=n[1],s=typeof r=="string"&&typeof o=="string"?this.relIndex.get(r)?.get(o):void 0;if(s===void 0)return;Kt(s,"textColor",n[2]),Kt(s,"lineColor",n[3]);let a=n[4],i=n[5];typeof a=="string"?s.offsetX=parseInt(a):a!==void 0&&Eo(s,a),typeof i=="string"?s.offsetY=parseInt(i):i!==void 0&&Eo(s,i)}updateLayoutConfig(t,n){let r=a=>a===void 0?NaN:parseInt(typeof a=="string"?a:a.value),o=r(n[0]),s=r(n[1]);o>=1&&(this.shapeInRow=o),s>=1&&(this.boundaryInRow=s)}};var Xd=["$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 mR=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]]),qd=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],Qd=/[\n\r\u2028\u2029]/g;function qm(e){let t=e.length,n=[],r=[],o=[],s=0,a=9,i=0,c=!1,l=-2,f=-1,p=0,u=(x,E,w)=>{n.push(x),r.push(E),o.push(w),i=w},m=x=>{for(;x<t&&He(e.charCodeAt(x));)x++;return x},h=(x,E)=>{let w=e.indexOf(x,E);return w===-1?t:w},b=(x,E)=>{let w=i+x.length;if(!e.startsWith(x,i)||!He(e.charCodeAt(w)))return!1;let S=++w;for(;w<t;){let O=e.charCodeAt(w);if(O===35||O===10||O===59)break;w++}return w===S?!1:(u(E,i,w),!0)};for(;;){if(c){u(0,t,t);break}i>=t&&(c=!0);let x=e.charCodeAt(i);if(s===0){if(i>=t){u(64,t,t);continue}if(l!==-1&&i>=p&&(l<i&&(l=e.indexOf("direction",i)),l!==-1&&(f<i&&(Qd.lastIndex=i,f=Qd.test(e)?Qd.lastIndex-1:t),l<f))){let E=!1;for(let w=0;w<4&&!E;w++)qd[w].lastIndex=i,qd[w].test(e)&&(u(2+w,i,qd[w].lastIndex),E=!0);if(E)continue;p=f}if(x===116&&b("title",6))continue;if(x===97){if(b("accDescription",7))continue;let E=e.startsWith("accTitle",i);if(E||e.startsWith("accDescr",i)){let w=m(i+8),S=e.charCodeAt(w);if(S===58){u(E?8:10,i,m(w+1)),a=E?9:11,s=7;continue}if(S===123&&!E){i=m(w+1),s=8;continue}}}if(x===37&&e.charCodeAt(i+1)===37){let E=h(`
`,i+2);for(;E<t&&(e.charCodeAt(E)===10||e.charCodeAt(E)===13);)E++;i=E;continue}if(He(x)){let E=i,w=-1;for(;E<t;){let S=e.charCodeAt(E);if(!He(S))break;S===10&&(w=E),E++}w!==-1?u(13,i,w+1):i=E;continue}if(x===123){u(62,i,i+1);continue}if(x===125){u(63,i,i+1);continue}if(Qe(x)){let E=i+1;for(;E<t&&Qe(e.charCodeAt(E));)E++;let w=E-i<=19?mR.get(e.slice(i,E)):void 0;if(w!==void 0){w>18&&(s=1),u(w,i,E);continue}}u(1,i,i);break}if(s===1){if(i>=t)u(57,t,t);else if(x===40){let E=i+1;for(;e.charCodeAt(E)===32;)E++;e.charCodeAt(E)===44?u(58,i,E+1):i++,s=2}else if(x===41)i++,s=0;else{u(1,i,i);break}continue}if(s===2){if(i>=t)continue;if(x===41)i++,s=0;else if(x===44)e.charCodeAt(i+1)===44?u(58,i,i+2):i++;else{let E=i;for(;e.charCodeAt(E)===32;)E++;let w=e.charCodeAt(E);w===34?e.charCodeAt(E+1)===34?u(58,i,E+2):(i=E+1,s=3):w===36?(i=E+1,s=4):u(59,i,h(",",i))}continue}if(s===3){x===34?(i++,s=2):u(59,i,h('"',i));continue}if(s===4){u(60,i,h("=",i)),s=5;continue}if(s===5){if(i>=t)continue;let E=i+1;if(x===61)for(;e.charCodeAt(E)===32;)E++;if(x!==61||e.charCodeAt(E)!==34){u(1,i,i);break}i=E+1,s=6;continue}if(s===6){if(i>=t)continue;x===34?(i++,s=2):u(61,i,h('"',i));continue}if(s===7){u(a,i,h(`
`,i)),s=0;continue}x===125?(i++,s=0):u(12,i,h("}",i))}return{types:n,starts:r,ends:o}}var Zd=["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"],gR=["rel","birel","rel_u","rel_d","rel_l","rel_r","rel_b","rel"],bR=["node","nodeL","nodeR"],yR="'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'",ER="'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'";function AR(e){return e===6||e===7||e===8||e===10||e===12}function Qm(e){return e>=19&&e<=56}function Zm(e,t){let{types:n,starts:r,ends:o}=qm(e),s=0,a=b=>e.slice(r[b],o[b]),i=b=>{let x=n[s];throw x===1?st("c4",e,r[s],"",!0):st("c4",e,r[s],`Expecting ${b}, got '${Xd[x]}'`)},c=b=>{n[s]!==b&&i(`'${Xd[b]}'`),s++},l=()=>{let b=[];for(;;){let x=n[s];if(x===59)b.push(a(s++).trim());else if(x===58)b.push(""),s++;else if(x===60)s++,n[s]!==61&&i("'STR_VALUE'"),b.push({key:a(s-1).trim(),value:a(s).trim()}),s++;else break}return b.length===0&&i(ER),b},f=b=>{b===6?t.setTitle(a(s++).substring(6)):b===7?t.setAccDescription(a(s++).substring(15)):b===12?t.setAccDescription(a(s++).trim()):(s++,b===8?(n[s]!==9&&i("'acc_title_value'"),t.setTitle(a(s++).trim())):(n[s]!==11&&i("'acc_descr_value'"),t.setAccDescription(a(s++).trim())))},p=b=>{s++;let x=l();if(b<=26)t.addPersonOrSystem(Zd[b-19],x);else if(b<=32)t.addContainer(Zd[b-19],x);else if(b<=38)t.addComponent(Zd[b-19],x);else{if(b<=45)return b===39?x.splice(2,0,"ENTERPRISE"):b===40?x.splice(2,0,"SYSTEM"):b===42&&x.splice(2,0,"CONTAINER"),b>=43?t.addDeploymentNode(bR[b-43],x):b===42?t.addContainerBoundary(x):t.addPersonOrSystemBoundary(x),n[s]===62?(s++,c(13)):n[s]===13?(s++,c(62),n[s]===13&&s++):i("'NEWLINE', 'LBRACE'"),!0;b<=53?(b===53&&x.splice(0,1),t.addRel(gR[b-46],x)):b===54?t.updateElStyle("update_el_style",x):b===55?t.updateRelStyle("update_rel_style",x):t.updateLayoutConfig("update_layout_config",x)}return!1},u=n[s];(u<14||u>18)&&i(yR),s++,c(13);let m=0,h=0;for(;;){let b=n[s];if(h===3||h===4){if(b===13){s++,h=2;continue}if(h===3&&Qm(b)){h=1;continue}}else if(Qm(b)){p(b)?(m++,h=1):h=4;continue}else if(AR(b)&&h!==1){f(b),h=3;continue}else h!==2&&i("'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'");if(m>0)b!==63&&i("'NEWLINE', 'RBRACE'"),s++,t.popBoundaryParseStack(),m--,h=4;else{b!==64&&i("'NEWLINE', 'EOF'"),s++,c(0),t.setC4Type(a(0));return}}}var Jd=/\s/;function Ms(e,t,n,r,o=0){let s=[];for(let l of e.split(`
`)){let f=Array.from(l);f.length===0&&s.push("");let p=0;for(;p<f.length;){let u=w=>t.width(f.slice(p,p+w).join(""),n,o)<=r,m=1;for(;m<f.length-p&&u(m);)m=Math.min(f.length-p,m*2);let h=1;for(;h<m;){let w=Math.ceil((h+m)/2);u(w)?h=w:m=w-1}let b=h,x=p+b<f.length;if(x&&!Jd.test(f[p+b])){for(let w=b-1;w>0;w--)if(Jd.test(f[p+w])){b=w+1;break}}let E=f.slice(p,p+b).join("");for(s.push(x&&E.trimEnd()||E),p+=b;x&&p<f.length&&Jd.test(f[p]);)p++}}e===""&&(s.length=0);let a=s.map(l=>t.width(l,n,o)),i=0;for(let l of a)i=Math.max(i,l);let c=Math.round(n*1.5);return{lines:s.map((l,f)=>[{text:l,style:o,width:a[f]}]),widths:a,width:i,height:s.length*c,size:n,lineHeight:c}}function Is(e,t,n){if(e.width<=n)return e;let r=[],o=[];for(let i=0;i<e.lines.length;i++){if(e.widths[i]<=n){r.push(e.lines[i]),o.push(e.widths[i]);continue}let c=[],l=0,f=()=>{r.push(c),o.push(l),c=[],l=0};for(let p of e.lines[i]){if(p.icon!==void 0||p.math){c.length&&l+p.width>n&&f(),c.push(p),l+=p.width;continue}for(let u of Array.from(p.text)){let m=c[c.length-1],h=m&&m.icon===void 0&&m.math===void 0&&m.style===p.style,x=t.width(h?m.text+u:u,e.size,p.style)-(h?m.width:0);c.length&&l+x>n&&(f(),m=void 0,x=t.width(u,e.size,p.style)),m&&m.icon===void 0&&m.math===void 0&&m.style===p.style?(m.text+=u,m.width+=x):c.push({text:u,style:p.style,width:x}),l+=x}}(c.length||!e.lines[i].length)&&f()}let s=0;for(let i of o)s=Math.max(s,i);let a={...e,lines:r,widths:o,width:s,height:r.length*e.lineHeight};return e.heights?po(a):a}function Ir(e,t,n,r){let o=Tr(e),s="<text"+jn(r,o),a="";for(let i=0;i<e.lines.length;i++){let c=e.lines[i],l=n+(i+.5)*e.lineHeight;if(c.some(p=>p.icon!==void 0)){let p=e.widths[i];a+=De({...e,lines:[c],widths:[p],width:p,height:e.lineHeight},t+p/2,l,r);continue}let f="";for(let p of c){let u=ar(p.style&~o);f+=u?`<tspan${u}>${je(p.text)}</tspan>`:je(p.text)}f!==""&&(a+=`${s} x="${d(t)}" y="${d(l+e.size*.35)}" text-anchor="start" xml:space="preserve">${f}</text>`)}return a}var Ei=28,Ls=20,tg=7,xR=8,SR=30,eu=88,Qa=160,xo=26,nu=e=>Math.min(12,Math.max(6,e/14)),ru=e=>Math.min(12,e/4);function ks(e,t,n,r,o,s,a,i){let c=0,l=1;if(a===0){if(o<e||o>n)return 1/0}else{let f=(e-o)/a,p=(n-o)/a;c=Math.max(c,Math.min(f,p)),l=Math.min(l,Math.max(f,p))}if(i===0){if(s<t||s>r)return 1/0}else{let f=(t-s)/i,p=(r-s)/i;c=Math.max(c,Math.min(f,p)),l=Math.min(l,Math.max(f,p))}return c<=l?c:1/0}function Ao(e,t,n,r,o,s,a,i){let c=a/n,l=i/r,f=(o-e)/n,p=(s-t)/r,u=c*c+l*l,m=2*(c*f+l*p),h=f*f+p*p-1,b=m*m-4*u*h;if(u===0||b<0)return 1/0;let x=(-m-Math.sqrt(b))/(2*u);return x>=0&&x<=1?x:h<=0?0:1/0}function $n(e,t,n,r,o){let{x:s,y:a,w:i,h:c}=e,l=r-t,f=o-n;if(e.form==="person")return Math.min(ks(s,a+xo,s+i,a+c,t,n,l,f),Ao(s+i/2,a+14,13,13,t,n,l,f));if(e.form==="cyl"){let p=nu(i);return Math.min(ks(s,a+p,s+i,a+c-p,t,n,l,f),Ao(s+i/2,a+p,i/2,p,t,n,l,f),Ao(s+i/2,a+c-p,i/2,p,t,n,l,f))}if(e.form==="h-cyl"){let p=ru(c);return Math.min(ks(s+p,a,s+i-p,a+c,t,n,l,f),Ao(s+p,a+c/2,p,c/2,t,n,l,f),Ao(s+i-p,a+c/2,p,c/2,t,n,l,f))}return ks(s,a,s+i,a+c,t,n,l,f)}function su(e,t,n,r,o){for(let s=2;s<e.length;s+=2){let a=e[s-2],i=e[s-1];if(ks(t,n,r,o,a,i,e[s]-a,e[s+1]-i)<=1)return!0}return!1}function Za(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 _R(e,t,n){let r=e.x+e.w/2,o=e.y+e.h/2,s=t.x+t.w/2,a=t.y+t.h/2,i=Za(e,t);if(i||Za(t,e)){let D=i?e:t,L=i?t:e,B=L.x+L.w/2,W=L.y+L.h/2,Y=L.x-D.x,I=D.x+D.w-L.x-L.w,X=L.y-D.y,ee=D.y+D.h-L.y-L.h,K=Math.min(Y,I,X,ee),z=K===Y?D.x:K===I?D.x+D.w:B,C=K===Y||K===I?W:K===ee?D.y+D.h:D.y,M=Math.min($n(L,z,C,B,W),1),T=z+(B-z)*M,g=C+(W-C)*M;return i?[z,C,T,g]:[T,g,z,C]}let c=r,l=o,f=s,p=a,u=Math.max(e.x,t.x),m=Math.min(e.x+e.w,t.x+t.w),h=Math.max(e.y,t.y),b=Math.min(e.y+e.h,t.y+t.h);u<m?c=f=(u+m)/2:h<b&&(l=p=(h+b)/2);let x=Math.hypot(f-c,p-l)||1,E=-(p-l)/x*n,w=(f-c)/x*n,S=$n(e,f+E,p+w,c+E,l+w),O=$n(t,c+E,l+w,f+E,p+w);return S<=1&&O<=1?(c+=E,l+=w,f+=E,p+=w):(c=r,l=o,f=s,p=a,S=Math.min($n(e,f,p,c,l),1),O=Math.min($n(t,c,l,f,p),1)),[f+(c-f)*S,p+(l-p)*S,c+(f-c)*O,l+(p-l)*O]}var tu=6,wR=3,Jm=12,Ja=class{constructor(){de(this,"upright",[]);de(this,"level",[]);de(this,"frames",[[],[]]);de(this,"taken",new Map);de(this,"squeezed",0)}free(t,n,r,o){let s=Math.min(r,o),a=Math.max(r,o),i=(c,l)=>{for(let f=0;f<c.length;f+=3)if(Math.abs(c[f]-n)<l&&c[f+1]<a&&c[f+2]>s)return!0;return!1};return!i(t?this.upright:this.level,tu)&&!i(this.frames[t?0:1],wR)}crossings(t){let n=0;for(let r=2;r<t.length;r+=2){let o=t[r]===t[r-2],s=o?t[r]:t[r+1],a=Math.min(o?t[r-1]:t[r-2],o?t[r+1]:t[r]),i=Math.max(o?t[r-1]:t[r-2],o?t[r+1]:t[r]),c=o?this.level:this.upright;for(let l=0;l<c.length;l+=3)c[l]>a&&c[l]<i&&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,o,s){let a=this.taken.get(t)??[],i=[];for(let c=0;c<9&&i.length<4;c++){let l=r+(c&1?1:-1)*Math.ceil(c/2)*Jm;if(l<o||l>s)continue;let f=!0;for(let p=0;p<a.length;p+=2)a[p]===n&&Math.abs(a[p+1]-l)<Jm&&(f=!1);f&&i.push(l)}return i.length?i:[r]}claim(t,n,r){let o=this.taken.get(t);o?o.push(n,r):this.taken.set(t,[n,r])}};function RR(e,t,n){let r=e.length,o=Math.sign(e[2]-e[0]),s=Math.sign(e[3]-e[1]),a=`M${d(e[0]+o*t)},${d(e[1]+s*t)}`;for(let l=2;l<r-2;l+=2){let f=e[l],p=e[l+1],u=Math.sign(f-e[l-2]),m=Math.sign(p-e[l-1]),h=Math.sign(e[l+2]-f),b=Math.sign(e[l+3]-p),x=Math.min(xR,Math.abs(f-e[l-2]+p-e[l-1])/2,Math.abs(e[l+2]-f+e[l+3]-p)/2);a+=`${u?"H"+d(f-u*x):"V"+d(p-m*x)}Q${d(f)},${d(p)} ${d(f+h*x)},${d(p+b*x)}`}let i=Math.sign(e[r-2]-e[r-4]),c=Math.sign(e[r-1]-e[r-3]);return a+(i?"H"+d(e[r-2]-i*n):"V"+d(e[r-1]-c*n))}function ng(e,t,n,r){for(let o of t)if(o!==n&&o!==r&&su(e,o.x,o.y,o.x+o.w,o.y+o.h))return!1;return!0}function rg(e,t,n,r,o){let s=e.length;return{d:RR(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:Qa,...o,points:e}}function eg(e,t){let n=[],r=(e+t)/2,o=Math.max(tg,(t-e)/4);for(let s=0;s<9;s++){let a=r+(s&1?1:-1)*Math.ceil(s/2)*o;a>=e+tu&&a<=t-tu&&n.push(a)}return n}function TR(e,t,n,r,o,s){let a=e.x+e.w/2,i=e.y+e.h/2,c=t.x+t.w/2,l=t.y+t.h/2,f,p=(b,x,E)=>{if(!ng(b,n,e,t))return;for(let S=2;S<b.length;S+=2){let O=b[S]===b[S-2];if(!r.free(O,O?b[S]:b[S+1],O?b[S-1]:b[S-2],O?b[S+1]:b[S]))return}let w=r.crossings(b)*1e6;for(let S=2;S<b.length;S+=2)w+=Math.abs(b[S]-b[S-2])+Math.abs(b[S+1]-b[S-1]);(!f||w<f.cost)&&(f={points:b,cost:w,upright:x,sides:E})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let b=c>a,x=Math.sign(l-i),E=b?[1,0]:[0,1],w=eg(b?e.x+e.w:t.x+t.w,b?t.x:e.x);e:for(let S of r.ports(e,E[0],i+x*e.h/4,e.y+8,e.y+e.h-8))for(let O of r.ports(t,E[1],l-x*t.h/4,t.y+8,t.y+t.h-8))for(let D of w){let L=D+(a-D)*Math.min($n(e,D,S,a,S),1),B=D+(c-D)*Math.min($n(t,D,O,c,O),1),W=f;if(p([L,S,D,S,D,O,B,O],!0,E),f!==W)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let b=l>i,x=Math.sign(c-a),E=b?[3,2]:[2,3],w=eg(b?e.y+e.h:t.y+t.h,b?t.y:e.y);e:for(let S of r.ports(e,E[0],a+x*e.w/4,e.x+8,e.x+e.w-8))for(let O of r.ports(t,E[1],c-x*t.w/4,t.x+8,t.x+t.w-8))for(let D of w){let L=D+(i-D)*Math.min($n(e,S,D,S,i),1),B=D+(l-D)*Math.min($n(t,O,D,O,l),1),W=f;if(p([S,L,S,D,O,D,O,B],!1,E),f!==W)break e}}if(!f)return;let{points:u,upright:m,sides:h}=f;return r.take(u),r.claim(e,h[0],m?u[1]:u[0]),r.claim(t,h[1],m?u[7]:u[6]),rg(u,2,o,s,{room:m?eu:Qa})}function sg(e,t,n,r,o,s,a){if(e===t){let x=Math.min(e.h/2-4,10),E=Math.hypot(Ei,x),w=e.x+e.w,S=e.y+e.h/2,O=Ei/E,D=x/E;return{d:`M${d(w+O*s)},${d(S-x-D*s)}C${d(w+Ei)},${d(S-x*2)} ${d(w+Ei)},${d(S+x*2)} ${d(w+O*a)},${d(S+x+D*a)}`,sx:w,sy:S-x,sdx:-O,sdy:D,ex:w,ey:S+x,edx:-O,edy:-D,x0:w+Ei+4,y0:S,x1:w+Ei+4,y1:S,nx:1,ny:0,lean:0,room:64,points:[]}}let[i,c,l,f]=_R(e,t,n),p=i===l,u=!1;if(r&&!Za(e,t)&&!Za(t,e))for(let x of r)x!==e&&x!==t&&ks(x.x,x.y,x.x+x.w,x.y+x.h,i,c,l-i,f-c)<=1&&(u=!0);if(r&&u&&!p&&c!==f){let x=TR(e,t,r,o,s,a);if(x)return x;o.squeezed++}if(r&&u&&(p||c===f)){let x=N=>{let $=N?-1/0:1/0,U=j=>{let v=p?j.x:j.y;$=N?Math.max($,v+(p?j.w:j.h)):Math.min($,v)};U(e),U(t);for(let j of r)j!==e&&j!==t&&ks(j.x,j.y,j.x+j.w,j.y+j.h,i,c,l-i,f-c)<=1&&U(j);return $},E=p?Math.min(e.y,t.y):Math.min(e.x,t.x),w=p?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),S=(N,$)=>{for(let U of r){if(U===e||U===t)continue;let j=p?U.y<w&&U.y+U.h>E:U.x<w&&U.x+U.w>E,v=p?U.x:U.y,k=v+(p?U.w:U.h);if(j&&(N?k>$:v<$))return!1}return!0},O=e.x+e.w/2,D=e.y+e.h/2,L=t.x+t.w/2,B=t.y+t.h/2,W=Math.sign(p?B-D:L-O),Y=N=>{let $=x(N),U=N?1:-1,j=p?N?1:0:N?3:2,v=p?o.ports(e,j,D+W*e.h/4,e.y+8,e.y+e.h-8)[0]:o.ports(e,j,O+W*e.w/4,e.x+8,e.x+e.w-8)[0],k=p?o.ports(t,j,B-W*t.h/4,t.y+8,t.y+t.h-8)[0]:o.ports(t,j,L-W*t.w/4,t.x+8,t.x+t.w-8)[0],F=G=>{if(p){let P=G+(O-G)*Math.min($n(e,G,v,O,v),1),V=G+(L-G)*Math.min($n(t,G,k,L,k),1);return[P,v,G,v,G,k,V,k]}let se=G+(D-G)*Math.min($n(e,v,G,v,D),1),q=G+(B-G)*Math.min($n(t,k,G,k,B),1);return[v,se,v,G,k,G,k,q]},H=F($+U*Ls);for(let G=0;G<=4;G++){let se=$+U*(Ls+G*tg),q=F(se);if(ng(q,r,e,t)&&(H=q,o.free(p,se,v,k)))return{points:H,side:j,p0:v,p1:k,step:G}}return{points:H,side:j,p0:v,p1:k,step:5}},I=p?f>c:l<i,X=S(I,x(I)),ee=S(!I,x(!I)),K=Y(I),z=X===ee?Y(!I):void 0,C=N=>o.crossings(N.points)*8+N.step,M=ee&&!X||z&&C(z)<C(K)?!I:I,{points:T,side:g,p0:_,p1:y,step:R}=M===I?K:z??Y(!I),A=M?1:-1;return R>4&&o.squeezed++,o.take(T),o.claim(e,g,_),o.claim(t,g,y),rg(T,2,s,a,p?{nx:A,lean:SR,room:eu}:{room:Qa})}let m=Math.hypot(l-i,f-c)||1,h=(l-i)/m,b=(f-c)/m;return(p||c===f)&&o.take([i,c,l,f]),{d:`M${d(i+h*s)},${d(c+b*s)}L${d(l-h*a)},${d(f-b*a)}`,sx:i,sy:c,sdx:-h,sdy:-b,ex:l,ey:f,edx:h,edy:b,x0:i,y0:c,x1:l,y1:f,nx:n?-b:0,ny:n?h:0,lean:0,room:Math.abs(h)>Math.abs(b)?eu:Qa,points:[i,c,l,f]}}var ou=216,CR=64,ig=14,NR=12,MR=100,IR=88,og=Ls+8,ec=48,Ai=16,tc=10,iu=new Map([["person","person"],["box","rect"],["rounded","rect"],["component","rect"],["cylinder","cyl"],["database","cyl"],["db","cyl"],["queue","h-cyl"],["pipe","h-cyl"]]);function kR(e){let t=iu.get((e.shape??"").toLowerCase())??iu.get((e.sprite??"").toLowerCase());if(t)return t;if(e.tags)for(let r of e.tags.split(",")){let o=iu.get(r.trim().toLowerCase());if(o)return o}let n=e.kind;return n.endsWith("person")?"person":n.endsWith("_db")?"cyl":n.endsWith("_queue")?"h-cyl":"rect"}function LR(e,t,n,r,o=ou){let s=kR(e),a=s==="h-cyl"?36:0,i=s==="person"?xo:s==="cyl"?24:0,c=o-2*ig-a,l=[We("«"+e.kind.replace(/_/g," ")+"»",!1,t,r-1,c),We(e.label,!1,t,n,c,1),We(e.techn?`[${e.techn}]`:void 0,!1,t,r,c),We(e.descr,!1,t,r,c)],f=0,p=l[3].height>0?4:0;for(let u of l)f=Math.max(f,u.width),p+=u.height;return{shape:e,form:s,labels:l,textH:p,x:0,y:0,w:Math.max(o,f+2*ig+a),h:Math.max(CR,p+2*NR+i)}}function ag(e,t,n,r,o){let s=0,a=0;for(let i=0;i<e.length;i+=t){let c=Math.min(e.length,i+t),l=0,f=0;for(let p=i;p<c;p++)f=Math.max(f,e[p].h);for(let p=i;p<c;p++){let u=e[p];u.x=l,u.y=a,o&&(u.h=f),l+=u.w+n}s=Math.max(s,l-n),a+=f+r}return[s,e.length>0?a-r:0]}function cg(e,t,n,r,o,s){let a=o===void 0?og:12,i=new Map;for(let b of e.boundaries){let x=o===void 0?4e3:Math.max(80,o-2*Ai-2*og*2),E=b.parent?[We(b.label,!1,t,n,x,1),We(b.type?`[${b.type}]`:void 0,!1,t,r,x),We(b.descr,!1,t,r,x)]:[],w=0,S=0;for(let O of E)w+=O.height,S=Math.max(S,O.width);i.set(b,{boundary:b,kids:[],nodes:[],labels:E,head:w>0?w+tc+6+Ls:a,headW:S,headX:Ai,x:0,y:0,w:0,h:0,form:"rect"})}let c=i.get(e.boundaries[0]);for(let b of i.values()){let x=b.boundary.parent;x&&i.get(x)?.kids.push(b)}let l=[c],f=new Map([[c.boundary,0]]);for(let b=0;b<l.length;b++)for(let x of l[b].kids)f.set(x.boundary,f.get(l[b].boundary)+1),l.push(x);for(let b of e.shapes)if(b.parent){let x=f.get(b.parent)??0,E=o===void 0?ou:Math.max(100,Math.min(ou,o-2*x*a-32));i.get(b.parent)?.nodes.push(LR(b,t,n,r,E))}let p=Math.max(1,e.shapeInRow),u=Math.max(1,e.boundaryInRow),m=new Map;for(let b=l.length-1;b>=0;b--){let x=l[b],E=o===void 0?MR:s,w=(Y,I,X)=>{if(o===void 0)return I;let ee=1;for(let K of Y)ee=Math.max(ee,K.w);return Math.max(1,Math.min(I,Math.floor((o+X-2*a)/(ee+X))))},[S,O]=ag(x.nodes,w(x.nodes,p,E),E,IR,!0),[D,L]=ag(x.kids,w(x.kids,u,ec),ec,ec,!1),B=O>0&&L>0?ec:0,W=x===c?0:a;m.set(x,O+B),x.w=Math.max(S,D,x.headW+2*Ai-2*W)+2*W,x.h=(W&&x.head)+O+B+L+W}let h=new Map;for(let b of l){let x=b.x+(b===c?0:a),E=b.y+(b===c?0:b.head);for(let w of b.nodes)w.x+=x,w.y+=E,h.set(w.shape,w);for(let w of b.kids)w.x+=x,w.y+=E+m.get(b);b!==c&&h.set(b.boundary,b)}return{order:l,boxes:h}}var $R=7,sc=36,au=24,lg=2e3,nc=8,DR=[.5,.4,.6,.3,.7,.2,.8],OR=2e6;function rc(e,t,n){let r=[];return e&&r.push("fill:"+e),t&&r.push("stroke:"+t),n&&r.push("color:"+n),St(r)}function cu(e,t,n,r,o){return t?Wn(e,Xn(t.includes("¶ß")?t.replace(/\ufb02\u00b0\u00b0?/g,"#").replace(/\u00b6\u00df/g,";"):t),n,r,o):e}function dg(e,t,n){return gn(n,r=>{if(!r)return lu(e,t,n,!1)[0];let[o,s]=lu(e,t,n,!0,sc);for(let a=sc+au;s>0&&a<=sc+3*au;a+=au){let[i,c]=lu(e,t,n,!0,a);c<s&&([o,s]=[i,c])}return o})}function lu(e,t,n,r,o=sc){let s=n.fontSize??16,a=Math.round(s*.8125),i=n.measurer??et(n.fontFamily),c=n.padding??8,l=[],{order:f,boxes:p}=cg(e,i,s,a,r?Math.max(80,(n.maxWidth??320)-2*c):void 0,o),u=f[0],m=0,h=0,b=u.w,x=u.h,E=($,U,j,v)=>{m=Math.min(m,$),h=Math.min(h,U),b=Math.max(b,j),x=Math.max(x,v)},w=[],S=new Map;for(let $ of e.rels){let U=$.fromAttr?void 0:e.getC4Shape($.from),j=$.toAttr?void 0:e.getC4Shape($.to),v=U&&p.get(U),k=j&&p.get(j);if(!v||!k)throw new ze(`C4 rel "${$.from}" -> "${$.to}" references an unknown shape or boundary`,"semantic",{type:"c4"});w.push(v,k);let F=S.get(v);F||S.set(v,F=new Set),F.add(k)}let O=[],D=[];for(let $ of f)for(let U of $.nodes)O.push(U),D.push(U.x+nc,U.y+nc,U.x+U.w-nc,U.y+U.h-nc);let L=e.rels.length*(O.length+f.length+3*e.rels.length)<=OR,B=($,U,j,v)=>{let k=0;for(let F=0;F<D.length;F+=4){let H=Math.min(j,D[F+2])-Math.max($,D[F]);if(H<=0)continue;let G=Math.min(v,D[F+3])-Math.max(U,D[F+1]);G>0&&(k+=H*G)}return k},W=$=>$?Math.max(-lg,Math.min(lg,$)):0,Y="",I=mt("arrow_point"),X=new Ja;for(let $ of f)$!==u&&X.frame($);let ee=e.rels.map(($,U)=>{let j=w[U*2],v=w[U*2+1],k=rc(void 0,$.lineColor,void 0),F=k.stroke?je(k.stroke):"var(--_l)",H=$.type==="birel"||$.type==="rel_b",G=$.type!=="rel_b",se=j!==v&&S.get(v)?.has(j)===!0,q=sg(j,v,se?$R:0,L?O:void 0,X,H?I:0,G?I:0);return E(Math.min(q.x0,q.x1),Math.min(q.y0,q.y1),Math.max(q.x0,q.x1),Math.max(q.y0,q.y1)),H&&L&&D.push(q.sx-Ot,q.sy-Ot,q.sx+Ot,q.sy+Ot),G&&L&&D.push(q.ex-Ot,q.ey-Ot,q.ex+Ot,q.ey+Ot),Y+=`<g class="pele-edge" data-id="${Fe($.from+"-"+$.to)}"${k.line}><path d="${q.d}"/>`+(H?Et("arrow_point",q.sx,q.sy,q.sdx,q.sdy,F):"")+(G?Et("arrow_point",q.ex,q.ey,q.edx,q.edy,F):"")+"</g>",q});for(let $ of f){if(!L||$.headW===0)continue;let U=$.y+tc,j=$.y+$.head-Ls,v=1/0;for(let k of[Ai,($.w-$.headW)/2,$.w-Ai-$.headW]){let F=0;for(let H of ee)su(H.points,$.x+k-4,U,$.x+k+$.headW+4,j)&&F++;if(F<v&&(v=F,$.headX=k),F===0)break}D.push($.x+$.headX-4,U,$.x+$.headX+$.headW+4,j)}let K="";e.rels.forEach(($,U)=>{let j=ee[U],v=$.from+"-"+$.to,k=rc(void 0,void 0,$.textColor),F=(e.c4Type==="C4Dynamic"?U+1+": ":"")+$.label,H=We(F,!1,i,a,j.room),G=We($.techn?`[${$.techn}]`:void 0,!1,i,a,j.room,2),se=Math.max(H.width,G.width)+8,q=H.height+G.height;if(q===0)return;let P=Math.abs(j.nx)*(se/2)+Math.abs(j.ny)*(q/2)+2,V=j.lean?Math.max(0,Math.min(j.lean,P-14)):P,ne=j.nx*V+(r?0:W($.offsetX)),ae=j.ny*V+(r?0:W($.offsetY)),Z=.5;if(L){let me=1/0,re=ne!==j.nx*V||ae!==j.ny*V;for(let te=0;te<(re?2:1)&&me>0;te++){let he=te?j.nx*V:ne,oe=te?j.ny*V:ae;for(let ge of DR){let Ee=j.x0+(j.x1-j.x0)*ge+he,be=j.y0+(j.y1-j.y0)*ge+oe,ye=B(Ee-se/2,be-q/2,Ee+se/2,be+q/2);if(ye<me&&(me=ye,Z=ge,ne=he,ae=oe),ye===0)break}}}let Q=j.x0+(j.x1-j.x0)*Z+ne,ie=j.y0+(j.y1-j.y0)*Z+ae-q/2;L&&D.push(Q-se/2,ie,Q+se/2,ie+q),E(Q-se/2,ie,Q+se/2,ie+q),K+=`<g class="pele-edge-label" data-id="${Fe(v)}">`+($.descr?`<title>${Fe($.descr)}</title>`:"")+`<rect x="${d(Q-se/2)}" y="${d(ie)}" width="${d(se)}" height="${d(q)}" rx="3" fill="var(--_bg)"/>`+cu(De(H,Q,ie+H.height/2,k.text)+De(G,Q,ie+H.height+G.height/2,` class="pele-c4-techn" fill="var(--_m)"${k.text}`),$.link,v,l,n)+"</g>"});let z="",C="";for(let $ of f){if($!==u){let U=$.boundary,j=rc(U.bgColor,U.borderColor,U.fontColor),v=$.x+$.headX,k=$.y+tc,F=Ir($.labels[0],v,k,` class="pele-cluster-label" font-weight="var(--_hw)"${j.text}`);k+=$.labels[0].height,F+=Ir($.labels[1],v,k,` class="pele-c4-type" font-size="${a}" fill="var(--_m)"${j.text}`),k+=$.labels[1].height,F+=Ir($.labels[2],v,k,` class="pele-c4-descr" font-size="${a}" fill="var(--_m)"${j.text}`),z+=`<g class="pele-cluster pele-c4-${U.nodeType?"node":"boundary"}" data-id="${Fe(U.alias)}"><rect x="${d($.x)}" y="${d($.y)}" width="${d($.w)}" height="${d($.h)}" fill="none" stroke="var(--_b)"${U.nodeType?"":' stroke-dasharray="6 4"'}${pt(j.shape)}/>`+cu(F,U.link,U.alias,l,n)+"</g>"}for(let U of $.nodes){let j=U.shape,v=j.kind.startsWith("external"),k=rc(j.bgColor,j.borderColor,j.fontColor),F=' stroke="var(--_b)"'+(v?' stroke-dasharray="4 3"':""),{w:H,h:G,form:se,labels:q}=U,P=se==="h-cyl"?-ru(G)/2:0,V=se==="person"?xo/2:se==="cyl"?nu(H)/2:0,ne=` fill="var(--_m)"${k.text}`,ae=V-U.textH/2,Z=De(q[0],P,ae+q[0].height/2,` class="pele-c4-type" font-size="${a-1}"${ne}`);ae+=q[0].height,Z+=De(q[1],P,ae+q[1].height/2,` class="pele-label" font-weight="var(--_hw)"${k.text}`),ae+=q[1].height,Z+=De(q[2],P,ae+q[2].height/2,` class="pele-c4-techn" font-size="${a}"${ne}`),ae+=q[2].height+4,Z+=De(q[3],P,ae+q[3].height/2,` class="pele-c4-descr" font-size="${a}"${k.text}`),C+=`<g class="pele-node pele-shape-${se} pele-c4-${j.kind}${v?" pele-c4-external":""}" data-id="${Fe(j.alias)}" transform="translate(${d(U.x+H/2)},${d(U.y+G/2)})">`+cu(Qn(se,H,G,` fill="var(${v?"--_bg":"--_s"})"${F}${k.shape}`,F+k.line)+Z,j.link,j.alias,l,n)+"</g>"}}let M=We(e.title,!1,i,s,r?Tt(n):4e3,1),T=M.height>0?M.height+12:0,g=Math.max(b-m,M.width),_=Math.ceil(g+2*c),y=Math.ceil(x-h+T+2*c),R=c-m+(g-(b-m))/2,A=c+T-h;return[{svg:Ze("c4",_,y,s,n,e,De(M,_/2,c+M.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(R)},${d(A)})">`+(z?`<g class="pele-clusters">${z}</g>`:"")+(Y?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${Y}</g>`:"")+(C?`<g class="pele-nodes">${C}</g>`:"")+(K?`<g class="pele-edge-labels" font-size="${a}">${K}</g>`:"")+"</g>"),width:_,height:y,links:l},X.squeezed]}var ug={type:"c4",parse(e,t,n){let r=new qa;return n&&(r.title=n),Zm(e,r),r},render:dg};function du(e){let t=0;for(let n=e.indexOf("~");n!==-1;n=e.indexOf("~",n+1))t++;return t}function vR(e){let t=du(e);if(t<=1)return e;let n=t%2!==0&&e.startsWith("~"),r=e.split(""),o=[];for(let s=n?1:0;s<r.length;s++)r[s]==="~"&&o.push(s);for(let s=0,a=o.length-1;s<a;s++,a--)r[o[s]]="<",r[o[a]]=">";return r.join("")}function qr(e){if(!e.includes("~"))return e;let t=e.split(/(,)/),n=[];for(let r=0;r<t.length;r++){let o=t[r];o===","&&r>0&&r+1<t.length&&du(t[r-1])===1&&du(t[r+1])===1&&(o=t[r-1]+","+t[r+1],r++,n.pop()),n.push(vR(o))}return n.join("")}function fg(e){return e==="#"||e==="+"||e==="~"||e==="-"}var So=class{constructor(t,n){de(this,"id","");de(this,"memberType");de(this,"visibility","");de(this,"classifier","");de(this,"parameters","");de(this,"returnType","");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 o=r;for(;o<n&&!ys(t.charCodeAt(o));)o++;let s=o-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 i=t[r],c=fg(i)&&a>r+1;c&&(this.visibility=i),this.id=t.slice(c?r+1:r,a),this.parameters=t.slice(a+1,s).trim();let l=s+1,f="";if(l<n){let u=t[l];(u==="$"||u==="*"||u.trim()==="")&&(f=u.trim(),l++)}let p=l;for(;p<n&&!ys(t.charCodeAt(p));)p++;if(this.returnType=t.slice(l,p).trim(),f===""){let u=this.returnType.slice(-1);(u==="$"||u==="*")&&(f=u,this.returnType=this.returnType.slice(0,-1))}return this.classifier=f,!0}r=o+1}return this.memberType="attribute",!1}parseAttribute(t){let n=t.slice(0,1),r=t.slice(-1);fg(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+qr(this.id);return this.memberType==="method"&&(t+=`(${qr(this.parameters.trim())})`,this.returnType&&(t+=" : "+qr(this.returnType))),{displayText:t.trim(),cssStyle:this.parseClassifier()}}parseClassifier(){return this.classifier==="*"?"font-style:italic;":this.classifier==="$"?"text-decoration:underline;":""}};var PR={LINE:0,DOTTED_LINE:1},xi={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4},BR="classId-";function Qr(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 pg(e){let t=e.charCodeAt(0);return Qr(t>=48&&t<=57?BR+e:e).className}var ic=class{constructor(){de(this,"type","class");de(this,"lineType",PR);de(this,"relationType",xi);de(this,"direction","TB");de(this,"classes",new Map);de(this,"relations",[]);de(this,"notes",new Map);de(this,"namespaces",new Map);de(this,"interfaces",[]);de(this,"styleClasses",new Map);de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"namespaceStack",[]);de(this,"withCssClass",new Map)}addClass(t){let{className:n,type:r}=Qr(t);if(this.classes.has(n))return;let o={id:n,type:r,label:n,cssClasses:"default",methods:[],members:[],annotations:[],styles:[]};this.classes.set(n,o),this.tag(o,"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(Qr(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=Qr(t.id1).className,t.id2=Qr(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 o=n.trim();if(o.startsWith("<<")&&o.endsWith(">>"))r.annotations.push(o.substring(2,o.length-2));else if(o.indexOf(")")>0){let s=new So(o,"method");(s.memberType==="method"?r.methods:r.members).push(s)}else o&&r.members.push(new So(o,"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,o=`note${r}`;return this.notes.set(o,{id:o,class:n,text:t,index:r}),o}cleanupLabel(t){return(t.startsWith(":")?t.substring(1):t).trim()}setCssClass(t,n){for(let r of t.split(",")){let o=this.classes.get(pg(r));if(o!==void 0){o.cssClasses+=" "+n;for(let s of n.split(" "))this.tag(o,s)}}}defineClass(t,n){for(let r of t){let o=this.styleClasses.get(r);if(o===void 0&&(o={id:r,styles:[],textStyles:[]},this.styleClasses.set(r,o)),!n)continue;for(let i of n)i.includes("color")&&o.textStyles.push(i.replace("fill","bgFill")),o.styles.push(i);let s=this.withCssClass.get(r);if(s===void 0)continue;let a=n.flatMap(i=>i.split(","));for(let i of s)for(let c of a)i.styles.push(c)}}setTooltip(t,n){if(n!==void 0)for(let r of t.split(",")){let o=this.classes.get(Qr(r).className);o&&(o.tooltip=n)}}setLink(t,n,r){let o=yt(n).trim();for(let s of t.split(",")){let a=this.classes.get(pg(s));a&&(a.link=o?Xn(o):void 0,a.linkTarget=typeof r=="string"?r:"_blank")}this.setCssClass(t,"clickable")}setClickEvent(t,n,r){for(let o of t.split(",")){let s=this.classes.get(Qr(o).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,`
`)}addNamespace(t,n){let r=this.namespaceStack[this.namespaceStack.length-1],o=r?`${r}.${t}`:t;this.namespaceStack.push(o);let s=this.namespaces.get(o);if(s)return s.explicit=!0,n&&(s.label=n),o;let a=r||void 0,i=r?r.length+1:0;for(;;){let c=o.indexOf(".",i),l=c===-1,f=l?o:o.slice(0,c),p=this.namespaces.get(f);if(p===void 0){let m=o.slice(i,l?o.length:c);p={id:f,label:l&&n?n:m,classes:new Map,notes:new Map,children:new Map,parent:a,explicit:l},this.namespaces.set(f,p)}else l&&(p.explicit=!0);let u=a?this.namespaces.get(a):void 0;if(u&&(u.children.has(f)||u.children.set(f,p),p.parent??=a),l)return o;a=f,i=c+1}}popNamespace(){this.namespaceStack.pop()}addClassesToNamespace(t,n,r){let o=this.namespaces.get(t);if(o!==void 0){for(let s of n){let{className:a}=Qr(s),i=this.classes.get(a);i!==void 0&&(i.parent=t,o.classes.set(a,i))}for(let s of r){let a=this.notes.get(s);a!==void 0&&(a.parent=t,o.notes.set(s,a))}}}setCssStyle(t,n){let r=this.classes.get(t);if(!(!n||!r))for(let o of n)for(let s of o.split(","))r.styles.push(s)}};var uu=["$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 FR=[4,6,4,9,44,45,12,14,15,4,56,4,56],WR=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],fu=/[\n\r\u2028\u2029]/g;function hg(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=e.indexOf("direction"),l=-1,f=0,p=(L,B,W)=>(n.push(L),r.push(e.slice(B,W)),o.push(B),i=W,!0),u=L=>{s.push(a),a=L},m=()=>{s.length>0&&(a=s.pop())},h=L=>e.startsWith(L,i)&&!Qe(e.charCodeAt(i+L.length)),b=L=>{for(;L<t&&He(e.charCodeAt(L));)L++;return L},x=L=>{let B=e.indexOf(L,i);return B===-1?t:B},E=L=>{let B=i,W=-1;for(let Y=e.charCodeAt(B);B<t&&He(Y);Y=e.charCodeAt(++B))Y===10&&(W=B);if(W<0){i=B;return}L&&m(),p(3,i,W+1)},w=L=>{switch(L){case 99:if(h("cssClass"))return p(48,i,i+8);if(h("callback"))return p(40,i,i+8);if(h("click"))return p(43,i,i+5);break;case 108:if(h("link"))return p(41,i,i+4);break;case 110:if(h("note for"))return p(24,i,i+8);if(h("note"))return p(25,i,i+4);break;case 60:if(e.charCodeAt(i+1)===60)return p(20,i,i+2);break;case 62:if(e.charCodeAt(i+1)===62)return p(21,i,i+2);break;case 104:if(h("href"))return p(46,i,i+4);break}return!1},S=L=>{if(w(L))return!0;let B=e.charCodeAt(i+1);switch(L){case 34:return u(1),i++,!0;case 126:return u(3),i++,!0;case 96:return u(2),i++,!0;case 95:if(h("_self"))return p(42,i,i+5);if(h("_blank"))return p(42,i,i+6);if(h("_parent"))return p(42,i,i+7);if(h("_top"))return p(42,i,i+4);break;case 60:return B===124?p(34,i,i+2):p(36,i,i+1);case 124:return B===62&&p(34,i,i+2);case 62:return p(36,i,i+1);case 42:return p(35,i,i+1);case 111:if(!Qe(B))return p(33,i,i+1);break;case 40:return B===41&&p(37,i,i+2);case 45:return B===45?p(38,i,i+2):p(52,i,i+1);case 46:return B===46?p(39,i,i+2):p(8,i,i+1);case 58:{let W=i+1;for(;W<t;){let Y=e.charCodeAt(W);if(Y===58||Y===10||Y===59)break;W++}return W>i+1?p(10,i,W):B===58&&e.charCodeAt(i+2)===58&&p(19,i,i+3)}case 43:return p(58,i,i+1);case 37:return p(51,i,i+1);case 61:return p(59,i,i+1);case 91:return p(5,i,i+1);case 93:return p(7,i,i+1);case 33:case 35:case 36:case 38:case 39:case 44:case 63:case 92:case 47:return p(60,i,i+1)}if(Qe(L)){let W=i+1;for(;Qe(e.charCodeAt(W));)W++;return p(27,i,W)}return ci(L)&&p(53,i,i+1)},O=()=>{if(c===-1||i<f||(c<i&&(c=e.indexOf("direction",i)),c===-1)||(l<i&&(fu.lastIndex=i,l=fu.test(e)?fu.lastIndex-1:t),c>=l))return!1;for(let L=0;L<4;L++){let B=WR[L];if(B.lastIndex=i,B.test(e))return p(29+L,i,B.lastIndex)}return f=l,!1},D=L=>{if(O())return!0;if(He(L))return E(!1),!0;switch(L){case 37:if(e.charCodeAt(i+1)===37){let B=x(`
`);for(;B<t&&(e.charCodeAt(B)===10||e.charCodeAt(B)===13);)B++;return i=B,!0}break;case 97:{let B=e.startsWith("accTitle",i);if(!B&&!e.startsWith("accDescr",i))break;let W=b(i+8),Y=e.charCodeAt(W);if(Y===58)return p(B?11:13,i,b(W+1)),u(B?6:7),!0;if(Y===123&&!B)return i=b(W+1),u(8),!0;break}case 99:if(h("classDiagram-v2"))return p(2,i,i+15);if(h("classDiagram"))return p(2,i,i+12);if(e.startsWith("call",i)&&He(e.charCodeAt(i+4)))return i=b(i+4),u(4),!0;if(h("classDef"))return p(26,i,i+8);if(h("class"))return u(9),p(22,i,i+5);break;case 91:if(e.startsWith("*]",i+1))return p(55,i,i+3);break;case 115:if(h("style"))return p(47,i,i+5);break;case 110:if(h("namespace"))return u(11),p(18,i,i+9);break;case 44:return p(28,i,i+1);case 35:return p(50,i,i+1)}return S(L)||L===58&&p(49,i,i+1)};for(;;){if(i>=t){n.push(FR[a]),r.push(""),o.push(t);break}let L=e.charCodeAt(i),B=!0;switch(a){case 0:B=D(L);break;case 9:He(L)?E(!0):L===125?(m(),m(),p(17,i,i+1)):L===123?(u(10),p(16,i,i+1)):B=S(L);break;case 10:if(L===34)u(1),i++;else if(L===125)m(),p(17,i,i+1);else if(L===91&&e.startsWith("*]",i+1))p(55,i,i+3);else if(L===123)p(57,i,i+1);else if(L===10)i++;else{let W=i+1;for(;W<t;){let Y=e.charCodeAt(W);if(Y===123||Y===125||Y===10)break;W++}p(23,i,W)}break;case 11:He(L)?E(!0):L===123?(u(12),p(16,i,i+1)):L===125?m():L===110&&h("namespace")?(u(11),p(18,i,i+9)):B=S(L);break;case 12:He(L)?E(!1):L===125?(m(),p(17,i,i+1)):L===110&&h("namespace")?(u(11),p(18,i,i+9)):L===91&&e.startsWith("*]",i+1)?p(55,i,i+3):L===99&&h("class")?(u(9),p(22,i,i+5)):B=S(L);break;case 1:L===34?(m(),i++):p(6,i,x('"'));break;case 3:if(L===34)u(1),i++;else{if(w(L))break;L===126?(m(),i++):p(9,i,x("~"))}break;case 2:if(L===34)u(1),i++;else{if(w(L))break;L===126?(u(3),i++):L===96?(m(),i++):p(54,i,x("`"))}break;case 4:if(L===40){let W=b(i+1);m(),e.charCodeAt(W)===41?i=W+1:(u(5),i++)}else p(44,i,x("("));break;case 5:L===41?(m(),i++):p(45,i,x(")"));break;case 6:case 7:p(a===6?12:14,i,x(`
`)),m();break;case 8:L===125?(m(),i++):p(15,i,x("}"));break}if(!B)return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}}return n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var hu=61,oc=new Uint8Array(hu);for(let e of[53,27,52])oc[e]=1;var pu=new Uint8Array(hu);for(let e of[27,49,50,47,51,10])pu[e]=1;var $s=new Uint8Array(hu);$s[33]=1;$s[34]=2;$s[35]=3;$s[36]=4;$s[37]=5;var UR="'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS', 'BQUOTE_STR'";function mg(e,t){let{types:n,texts:r,starts:o}=hg(e),s=0,a=L=>{let B=n[s];throw B===1?st("class",e,o[s],"",!0):st("class",e,o[s],`Expecting ${L}, got '${uu[B]}'`)},i=L=>(n[s]!==L&&a(`'${uu[L]}'`),r[s++]),c=()=>(oc[n[s]]===0&&a("'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS'"),r[s++]),l=L=>{let B="";for(;;){if(n[s]===54){B+=r[s++];break}oc[n[s]]===0&&a(UR),B+=r[s++];let W=n[s];if(W===8)B+=".",s++;else if(oc[W]===0&&W!==54)break}return L&&n[s]===9&&(B+="~"+r[s++]+"~"),B},f=()=>{s++;let L=i(6);return i(7),L},p=()=>{n[s]!==23&&a("'STRUCT_STOP', 'MEMBER'");let L=[];for(;n[s]===23;)L.push(r[s++]);return i(17),L.reverse()},u=()=>{s++;let L=l(!0);switch(t.addClass(L),n[s]===5&&t.setClassLabel(L,f()),n[s]){case 19:{s++;let B=c();t.setCssClass(L,B),n[s]===16&&(s++,t.addMembers(L,p()));break}case 16:s++,n[s]===17?s++:t.addMembers(L,p());break;case 20:{s++;let B=c();i(21),t.addAnnotation(L,B),n[s]===16&&(s++,n[s]===17?s++:t.addMembers(L,p()));break}}return L},m=()=>{if(n[s++]===25)return t.addNote(i(6));let L=l(!0);return t.addNote(i(6),L)},h=()=>{let L=[];for(;;){s++;let B=l(!1),W=n[s]===5?t.addNamespace(B,f()):t.addNamespace(B);i(16),n[s]===3&&s++,L.push({id:W,classes:[],notes:[]});let Y=!0;for(;Y;){let I=L[L.length-1],X=n[s];if(X===18)break;for(X===22?I.classes.push(u()):X===25||X===24?I.notes.push(m()):a("'NAMESPACE', 'CLASS', 'NOTE_FOR', 'NOTE'");;){if(n[s]===3){let K=n[s+1];if(K===18||K===22||K===25||K===24){s++;break}s++}i(17);let ee=L.pop();if(t.addClassesToNamespace(ee.id,ee.classes,ee.notes),t.popNamespace(),L.length===0){Y=!1;break}}}if(L.length===0)return}},b=()=>{let L=$s[n[s]];return L===0?"none":(s++,L-1)},x=()=>{let L=l(!0),B=n[s];if(B===10){t.addMember(L,t.cleanupLabel(r[s++]));return}let W="none";if(B===6)W=r[s++],B=n[s];else if($s[B]===0&&B!==38&&B!==39)return;let Y=b();B=n[s],B!==38&&B!==39&&a("'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE'"),s++;let I=b(),X=n[s]===6?r[s++]:"none",ee=l(!0),K={id1:L,id2:ee,relation:{type1:Y,type2:I,lineType:B===38?0:1},relationTitle1:W,relationTitle2:X};n[s]===10&&(K.title=t.cleanupLabel(r[s++])),t.addRelation(K)},E=()=>{let L=[];for(;;){pu[n[s]]===0&&a("'ALPHA', 'NUM', 'COLON', 'UNIT', 'SPACE', 'BRKT', 'STYLE', 'PCT', 'LABEL'");let B=r[s++];for(;pu[n[s]]===1;)B+=r[s++];if(L.push(B),n[s]!==28)return L;s++}},w=L=>{n[s]===6&&t.setTooltip(L,r[s++])},S=L=>{let B=i(6),W=n[s]===6?r[s++]:void 0;n[s]===42?t.setLink(L,B,r[s++]):t.setLink(L,B),W!==void 0&&t.setTooltip(L,W)},O=()=>{let L=n[s];switch(L){case 53:case 27:case 52:case 54:x();return;case 18:h();return;case 22:u();return;case 23:s++;return;case 20:{s++;let B=c();i(21),t.addAnnotation(l(!0),B);return}case 40:{s++;let B=l(!0);t.setClickEvent(B,i(6)),w(B);return}case 41:s++,S(l(!0));return;case 43:{s++;let B=l(!0);if(n[s]===46){s++,S(B);return}let W=i(44);n[s]===45?t.setClickEvent(B,W,r[s++]):t.setClickEvent(B,W),w(B);return}case 47:{s++;let B=i(27);t.setCssStyle(B,E());return}case 48:{s++;let B=i(6);t.setCssClass(B,i(27));return}case 25:case 24:m();return;case 26:{s++;let B=[i(27)];for(;n[s]===28;)s++,B.push(i(27));t.defineClass(B,E());return}case 29:case 30:case 31:case 32:s++,t.setDirection(L===29?"TB":L===30?"BT":L===31?"RL":"LR");return;case 11:s++,t.setAccTitle(i(12).trim());return;case 13:s++,t.setAccDescription(i(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'")},D=n[s]===2;for(D&&(s++,i(3));O(),!(n[s]!==3||(s++,n[s]===4||n[s]===0)););D&&i(4),i(0)}var GR=["aggregation","extension","composition","dependency","lollipop"];function gg(e){return typeof e=="number"&&GR[e]||"none"}function bg(e,t=!0){let n=[],r=[],o=new Map,s=new Map,a=new Map,i=new Map,c=u=>{if(t||u===void 0)return u;let m=[],h=u,b;for(;h;){if(i.has(h)){b=i.get(h);break}let x=e.namespaces.get(h);if(x===void 0)break;if(x.explicit){b=h;break}m.push(h),h=x.parent}for(let x of m)i.set(x,b);return b},l=u=>u===void 0?-1:o.get(u)??-1;for(let u of e.namespaces.values())!t&&!u.explicit||(o.set(u.id,n.length),n.push({id:u.id,label:t?u.label:u.id,isGroup:!0,shape:"rect",parentId:t?u.parent:void 0,parent:-1}));for(let u of n)u.parent=l(u.parentId);let f=0;for(let u of e.classes.values()){let m=c(u.parent);s.set(u.id,n.length),n.push({id:u.id,label:u.label,isGroup:!1,shape:"classBox",parentId:m,parent:l(m),classNode:u,colorIndex:f++})}for(let u of e.notes.values()){let m=c(u.parent),h=u.class===void 0?void 0:s.get(u.class);h!==void 0&&r.push({id:`edgeNote${u.index}`,start:u.id,end:n[h].id,source:n.length,target:h,label:void 0,arrowTypeStart:"none",arrowTypeEnd:"none",startLabelRight:"",endLabelLeft:"",pattern:"dotted",classes:"relation"}),n.push({id:u.id,label:u.text,isGroup:!1,shape:"note",parentId:m,parent:l(m)})}for(let u of e.interfaces){let m=s.get(u.classId);a.set(u.id,n.length),n.push({id:u.id,label:u.label,isGroup:!1,shape:"interface",parentId:void 0,parent:m===void 0?-1:n[m].parent})}let p=0;for(let u of e.relations){p++;let{type1:m,type2:h}=u.relation,b=m===xi.LOLLIPOP&&h==="none"?a:s,x=b===s&&h===xi.LOLLIPOP&&m==="none"?a:s;r.push({id:`id_${u.id1}_${u.id2}_${p}`,start:u.id1,end:u.id2,source:b.get(u.id1)??-1,target:x.get(u.id2)??-1,label:u.title,arrowTypeStart:gg(m),arrowTypeEnd:gg(h),startLabelRight:u.relationTitle1==="none"?"":u.relationTitle1,endLabelLeft:u.relationTitle2==="none"?"":u.relationTitle2,pattern:u.relation.lineType===1?"dashed":"solid",classes:"relation"})}return{nodes:n,edges:r}}var mu=12,wo=16,_o=6,ac=5;function gu(e){switch(e){case"extension":return mu;case"composition":case"aggregation":return wo;case"lollipop":return 2*ac;case"dependency":return mt("arrow_point")}return 0}function bu(e,t,n,r,o,s){let a=-o,i=r;switch(e){case"extension":{let c=t-r*mu,l=n-o*mu;return`<path class="pele-marker" d="M${d(t)},${d(n)}L${d(c+a*_o)},${d(l+i*_o)}L${d(c-a*_o)},${d(l-i*_o)}Z" stroke-linejoin="round"/>`}case"composition":case"aggregation":{let c=t-r*wo/2,l=n-o*wo/2,f=_o-1;return`<path class="pele-marker" d="M${d(t)},${d(n)}L${d(c+a*f)},${d(l+i*f)}L${d(t-r*wo)},${d(n-o*wo)}L${d(c-a*f)},${d(l-i*f)}Z" stroke-linejoin="round"${e==="composition"?` fill="${s}"`:""}/>`}case"lollipop":return`<circle class="pele-marker" cx="${d(t-r*ac)}" cy="${d(n-o*ac)}" r="${ac}"/>`;case"dependency":return Et("arrow_point",t,n,r,o,s)}return""}var YR=40,HR=16,yg=56,Ds=20,Eg=26,yu=12,cc=8,Ag=6,KR=10,zR=64,lc=8,Eu="var(--_l)",VR=new Set(["_self","_blank","_parent","_top"]);function xg(e,t,n){let r=e[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}var dc=[],uc=[];function Sg(e,t,n){let r=yt(e.getDisplayDetails().displayText).trim();return{text:r,width:t.width(r,n,e.classifier==="*"?2:0),classifier:e.classifier}}function _g(e,t,n){let r=o=>gn(n,s=>jR(e,t,n,o,s));return Tn(e.direction)?$t(n,r):r(!1)}function jR(e,t,n,r,o){let s=t.class??{},a=bg(e,s.hierarchicalNamespaces!==!1),i=s.hideEmptyMembersBox===!0,c=n.fontSize??16,l=Math.round(c*.875),f=Math.round(c*.8),p=Math.round(f*1.4),u=n.measurer??et(n.fontFamily),m=n.padding??8,h=(ue,fe)=>{if(!ue.includes("$$"))return;let Me=We(ue,!1,u,fe,4e3);return Me.lines.some(mi)?Me:void 0},b=ue=>ue?h(ue,f)?.width??u.width(yt(ue),f,0):0,x=r?"TB":rn(e.direction),E=new Map,w=new Map,S=new Map,O=ue=>{let fe=E.get(ue);if(fe===void 0){let Me=St([ue]);fe=Me.shape===""&&Me.text===""?"":ue.slice(0,ue.indexOf(":")).trim().toLowerCase(),E.set(ue,fe)}fe!==""&&S.set(fe,ue)},D=ue=>{S.clear();let fe=w.get(ue.cssClasses);if(fe===void 0){for(let Me of ue.cssClasses.split(" ")){let Ne=e.styleClasses.get(Me);if(Ne)for(let Be of Ne.styles)for(let ce of Be.split(","))O(ce)}fe=[...S],w.set(ue.cssClasses,fe)}else for(let[Me,Ne]of fe)S.set(Me,Ne);for(let Me of ue.styles)O(Me);return St(S.size===0?uc:[...S.values()])},L=new Int32Array(a.nodes.length);for(let ue of a.nodes)ue.parent>=0&&L[ue.parent]++;let B=new Uint8Array(a.nodes.length);for(let ue of a.edges){if(ue.source<0||ue.target<0)continue;let fe=a.nodes[ue.source].parent,Me=a.nodes[ue.target].parent;if(fe!==Me){for(let Ne=fe;Ne>=0&&B[Ne]===0;Ne=a.nodes[Ne].parent)B[Ne]=1;for(let Ne=Me;Ne>=0&&B[Ne]===0;Ne=a.nodes[Ne].parent)B[Ne]=1}}let W=[],Y=[];a.nodes.forEach((ue,fe)=>{let Me,Ne;if(ue.isGroup){let Be=We(ue.label,!1,u,c,4e3);Me=I(ue,Be,0,0,c),L[fe]>0?(Ne=Pt(0,0),Ne.isGroup=!0,Ne.padX=Ds,Ne.padTop=Be.height>0?Be.height+16:Ds,Ne.padBottom=Ds,Ne.minW=Be.width+2*Ds-12+(B[fe]===1&&!o?Math.min(Be.width+24,240):0)):(Me.w=Math.max(Be.width+2*Ds,80),Me.h=Be.height+2*Ds,Ne=Pt(Me.w,Me.h))}else if(ue.classNode)Me=X(ue,ue.classNode),Ne=Pt(Me.w,Me.h);else if(ue.shape==="note"){let Be=We(ue.label,!0,u,l,260);Me=I(ue,Be,Math.max(Be.width+2*yu,40),Be.height+2*cc,l),Ne=Pt(Me.w,Me.h)}else{let Be=We(ue.label,!1,u,l,200);Me=I(ue,Be,Math.max(Be.width,12)+4,Math.max(Be.height,12),l),Ne=Pt(Me.w,Me.h)}Ne.parent=ue.parent,Ne.seq=fe,W.push(Me),Y.push(Ne)});function I(ue,fe,Me,Ne,Be){return{node:ue,style:St(uc),label:fe,w:Me,h:Ne,loops:0,annotations:uc,attributes:dc,methods:dc,titleH:0,attributesH:0,fontSize:Be}}function X(ue,fe){let Me=D(fe),Ne=Me.fontSize??c,Be=Math.round(Ne*.875),ce=Math.round(Be*1.5),Se=fe.type?"&lt;"+qr(fe.type).replace(/</g,"&lt;").replace(/>/g,"&gt;")+"&gt;":"",$e=We(fe.label+Se,!1,u,Ne,4e3,1|(Me.italic?2:0)),Ae=fe.annotations.length>0?fe.annotations.map(we=>h(`«${we.trim()}»`,f)??`«${yt(we).trim()}»`):uc,xe=fe.members.length>0?fe.members.map(we=>Sg(we,u,Be)):dc,Oe=fe.methods.length>0?fe.methods.map(we=>Sg(we,u,Be)):dc,ve=$e.width,Ge=0;for(let we of Ae)ve=Math.max(ve,typeof we=="string"?u.width(we,f,0):we.width),Ge+=typeof we=="string"?p:Math.max(p,we.height);for(let we of xe)ve=Math.max(ve,we.width);for(let we of Oe)ve=Math.max(ve,we.width);let pe=!(i&&xe.length===0&&Oe.length===0),J=we=>pe?we>0?2*Ag+we*ce:KR:0,_e=2*cc+Ge+Math.max($e.height,Math.round(Ne*1.5)),le=J(xe.length);return{node:ue,style:Me,label:$e,w:Math.max(ve+2*yu,zR),h:_e+le+J(Oe.length),loops:0,annotations:Ae,attributes:xe,methods:Oe,titleH:_e,attributesH:le,fontSize:Ne}}let ee=[],K=[],z=[],C=[],M=[],T=new Float64Array(W.length*4),g=(ue,fe,Me)=>{T[ue*4+fe]++,Me>T[ue*4+fe+1]&&(T[ue*4+fe+1]=Me)};for(let ue of a.edges){if(ue.source<0||ue.target<0)continue;let fe=We(ue.label,!0,u,l,200),Me=b(ue.startLabelRight),Ne=b(ue.endLabelLeft);ue.source===ue.target?(W[ue.source].loops++,Y[ue.source].w+=2*(Eg+(fe.width>0?fe.width+12:0))):(g(ue.source,0,Me),g(ue.target,2,Ne)),C.push(Me),M.push(Ne),K.push(ue),z.push(fe),ee.push({src:ue.source,dst:ue.target,minlen:1,labelW:fe.width>0?fe.width+12:0,labelH:fe.height>0?fe.height+4:0,route:[],labelX:0,labelY:0})}if(x==="TB"||x==="BT")for(let ue=0;ue<W.length;ue++){if(!W[ue].node.classNode)continue;let fe=0;for(let Me=0;Me<4;Me+=2){let Ne=T[ue*4+Me],Be=T[ue*4+Me+1];Ne>1&&(fe=Math.max(fe,(Ne-1)*(Be>0?Be+24:14)+24))}fe=Math.min(fe,480),fe>W[ue].w&&(Y[ue].w+=fe-W[ue].w,W[ue].w=fe)}let _=!1;for(let ue=0;ue<K.length&&!_;ue++)_=C[ue]>0||M[ue]>0;let y=0;if(x==="TB"||x==="BT"){let ue=fe=>fe?Math.max(p,h(fe,f)?.height??0):0;for(let fe of K)y=Math.max(y,ue(fe.startLabelRight)+ue(fe.endLabelLeft)-2*p)}let R=Rn(Y,ee,x,{nodeSep:xg(s,"nodeSpacing",YR),edgeSep:HR,rankSep:xg(s,"rankSpacing",_?yg+16:yg)+y,portSep:20,apart:!0}),A=new Map,N=[],$=(ue,fe,Me,Ne,Be)=>{let ce=ue.route,Se=Y[Me],$e=Un(ce,fe,Se);if($e<0)return;let Ae=(Se.w-W[Me].w)/2;$e===1?ce[fe]-=Ae:$e===3&&(ce[fe]+=Ae);let xe=$e&1,Oe=ce[(fe===0?3:fe-3)+xe],ve=Oe-ce[fe+xe],Ge={route:ce,at:fe,toward:Oe,order:Be,room:Ne,side:$e,after:xe?ve>0:ve>=0},pe=Me*4+$e,J=A.get(pe);return J?J.push(Ge):A.set(pe,[Ge]),Ge},U=[],j=[];for(let ue=0;ue<ee.length;ue++){let fe=ee[ue],Me=fe.src!==fe.dst&&fe.route.length>=6;U.push(Me?$(fe,0,fe.src,C[ue],ue):void 0),j.push(Me?$(fe,fe.route.length-3,fe.dst,M[ue],ue):void 0)}let v=(ue,fe,Me)=>{for(let Ne=Y[ue].parent,Be=0;Ne>=0&&Be<1e4;Ne=Y[Ne].parent,Be++){let ce=Y[Ne],Se=Math.abs(fe-ce.x),$e=Math.abs(Me-ce.y);if(Math.abs($e-ce.h/2)<.5&&Se<=ce.w/2+.5||Math.abs(Se-ce.w/2)<.5&&$e<=ce.h/2+.5)return!0}return!1},k=[];for(let[ue,fe]of A){if(fe.length<2)continue;let Me=ue>>2,Ne=ue&1,Be=Ne?W[Me].h:W[Me].w;fe.sort((Ae,xe)=>Ae.toward-xe.toward||Ae.order-xe.order);let ce=0;for(let Ae=0;Ae+1<fe.length;Ae++){let xe=fe[Ae],Oe=fe[Ae+1],ve=Ne?20:24;xe.room>0&&xe.after&&(ve+=Ne?p+6:xe.room),Oe.room>0&&!Oe.after&&(ve+=Ne?p+6:Oe.room),k[Ae]=ve,ce+=ve}let Se=Math.min(1,(Be-24)/ce);if(Se<=0)continue;let $e=(Ne?Y[Me].y:Y[Me].x)-ce*Se/2;for(let Ae=0;Ae<fe.length;Ae++){let{route:xe,at:Oe}=fe[Ae],ve=Oe===0?3:-3,Ge=Oe+ve,pe=-1;for(let J=Ge;J>=0&&J<xe.length&&Math.abs(xe[J+Ne]-xe[Ge+Ne])<.5;J+=ve)if(v(Me,xe[J],xe[J+1])){pe=J;break}if(pe>=0&&Math.abs(xe[Ge+Ne]-$e)<=24)for(let J=Ge;J!==pe+ve;J+=ve)xe[J+Ne]=$e;xe[Oe+Ne]=$e,$e+=k[Ae]*Se}}let F=(ue,fe,Me,Ne)=>{if(fe===void 0||Me<=0)return;let Be=fe.side&1,ce=Ne?0:ue.length-3,Se=ce+1-Be,$e=Math.abs(ue[(Ne?3:ce-3)+1-Be]-ue[Se]),Ae=Math.min(Be?Me+10:p+6,$e*.35);if(Ae<4)return;let xe=[ue[ce],ue[ce+1],ue[ce+2]];xe[1-Be]+=(fe.side===0||fe.side===3?-1:1)*Ae,ue.splice(Ne?3:ce,0,xe[0],xe[1],xe[2])};for(let ue=0;ue<ee.length;ue++)F(ee[ue].route,U[ue],C[ue],!0),F(ee[ue].route,j[ue],M[ue],!1);let H=0,G=0,se=R.width,q=R.height,P=(ue,fe,Me,Ne,Be,ce)=>{if(!ue)return;let Se=h(ue,f),$e=Se?Math.max(p,Se.height):p,Ae=Me,xe=Ne;Be&1?(Ae+=(Be===3?-1:1)*(5+fe/2),xe+=(ce?1:-1)*(7+$e/2)):(Ae+=(ce?1:-1)*(9+fe/2),xe+=(Be===0?-1:1)*(3+$e/2)),N.push({text:yt(ue),math:Se,x:Ae,y:xe}),H=Math.min(H,Ae-fe/2),se=Math.max(se,Ae+fe/2),G=Math.min(G,xe-$e/2),q=Math.max(q,xe+$e/2)},V=new Map,ne=new Int32Array(ee.length);for(let ue=0;ue<ee.length;ue++){let fe=ee[ue],Me=K[ue],Ne=fe.route;if(fe.src===fe.dst){let Be=V.get(fe.src)??0;V.set(fe.src,Be+1),ne[ue]=Be;let ce=Y[fe.src],Se=W[fe.src],$e=ce.x+Se.w/2,Ae=Math.min(Se.h/2-4,8+Be*6);P(Me.startLabelRight,C[ue],$e,ce.y-Ae,1,!1),P(Me.endLabelLeft,M[ue],$e,ce.y+Ae,1,!0)}else if(Ne.length>=6){let Be=Ne.length-3,ce=U[ue],Se=j[ue];P(Me.startLabelRight,C[ue],Ne[0],Ne[1],ce?ce.side:2,ce?ce.after:!0),P(Me.endLabelLeft,M[ue],Ne[Be],Ne[Be+1],Se?Se.side:0,Se?Se.after:!0)}}let ae=m-H,Z=m-G,Q=Math.ceil(se-H+2*m),ie=Math.ceil(q-G+2*m),me=[],re=new Map;if(a.nodes.length>0&&a.nodes[0].isGroup)for(let ue of ee)qn(re,ue.route);let te="",he="",oe="";for(let ue=0;ue<W.length;ue++){let fe=W[ue],Me=Y[ue],Ne=fe.node,Be=Me.x+ae,ce=Me.y+Z,Se=Fe(Ne.id),$e=Me.isGroup?Me.w:fe.w,Ae=Me.isGroup?Me.h:fe.h;if(Ne.isGroup){let Oe=Me.isGroup?Yr(Me,fe.label.width,re,Ds):Me.x,ve=ce-Ae/2+8+fe.label.height/2,Ge=' class="pele-cluster-label" fill="var(--_m)"',pe=Me.isGroup&&ka(Me,fe.label.width,Oe,re);pe&&(he+=La(fe.label,Oe+ae,ve,Ge,Se,a.nodes,ue)),te+=`<g class="pele-cluster pele-namespace" data-id="${Se}"><rect x="${d(Be-$e/2)}" y="${d(ce-Ae/2)}" width="${d($e)}" height="${d(Ae)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${it}/>`+(pe?"":De(fe.label,Oe+ae,ve,Ge))+"</g>";continue}let xe=` transform="translate(${d(Be)},${d(ce)})"`;if(Ne.classNode)oe+=ge(fe,Ne.classNode,Se,xe);else if(Ne.shape==="note"){let Oe=$e/2,ve=-Ae/2;oe+=`<g class="pele-node pele-note" data-id="${Se}"${xe}><path d="M${d(-Oe)},${d(ve)}H${d(Oe-lc)}L${d(Oe)},${d(ve+lc)}V${d(-ve)}H${d(-Oe)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"/><path d="M${d(Oe-lc)},${d(ve)}V${d(ve+lc)}H${d(Oe)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"/>`+De(fe.label,0,0,` class="pele-label" font-size="${l}"`,n.icons)+"</g>"}else oe+=`<g class="pele-node pele-interface" data-id="${Se}"${xe}>`+De(fe.label,0,0,` class="pele-label" font-size="${l}"`,n.icons)+"</g>"}function ge(ue,fe,Me,Ne){let{w:Be,h:ce,style:Se}=ue,$e=-Be/2,Ae=-ce/2,xe=Math.round(ue.fontSize*.875),Oe=Math.round(xe*1.5),ve=`<rect x="${d($e)}" y="${d(Ae)}" width="${d(Be)}" height="${d(ce)}" fill="var(--_s)" stroke="var(--_b)"${pt(Se.shape)}/>`,Ge=Ae+ue.titleH,pe=Ge+ue.attributesH;if(ce>ue.titleH){let we=Se.stroke?` style="stroke:${je(Se.stroke)}"`:"";ve+=`<path class="pele-divider" d="M${d($e)},${d(Ge)}H${d(-$e)}M${d($e)},${d(pe)}H${d(-$e)}" fill="none" stroke="var(--_b)"${we}/>`}let J=Ae+cc;for(let we of ue.annotations)if(typeof we=="string")ve+=`<text class="pele-annotation" x="0" y="${d(J+p/2+f*.35)}" text-anchor="middle" font-size="${f}" fill="var(--_m)">${je(we)}</text>`,J+=p;else{let Te=Math.max(p,we.height);ve+=De(we,0,J+Te/2,` class="pele-annotation" font-size="${f}" fill="var(--_m)"`,n.icons),J+=Te}let _e=ue.fontSize===c?"":` font-size="${d(ue.fontSize)}"`;ve+=De(ue.label,0,(J+Ge-cc)/2,` class="pele-label"${_e} font-weight="var(--_hw)"${Se.text}`,n.icons);let le=(we,Te,Ce)=>{let Ie="",Pe=Ce+Ag+Oe/2+xe*.35;for(let Ue of we){let ke=Ue.classifier==="$"?` pele-static"${Se.text?Se.text.slice(0,-1)+'text-decoration:underline"':' style="text-decoration:underline"'}`:Ue.classifier==="*"?` pele-abstract" font-style="italic"${Se.text}`:`"${Se.text}`;Ie+=`<text class="pele-member pele-${Te}${ke} x="${d($e+yu)}" y="${d(Pe)}">${je(Ue.text)}</text>`,Pe+=Oe}return Ie};return(ue.attributes.length>0||ue.methods.length>0)&&(ve+=`<g class="pele-members" font-size="${xe}">${le(ue.attributes,"attribute",Ge)}${le(ue.methods,"method",pe)}</g>`),fe.tooltip&&(ve=`<title>${Fe(fe.tooltip)}</title>`+ve),fe.link&&(ve=Wn(ve,fe.link,fe.id,me,n,fe.linkTarget&&VR.has(fe.linkTarget)?` target="${fe.linkTarget}"`:"")),`<g class="pele-node pele-class${Rt(fe.cssClasses.replace(/^default\s?/,""))}" data-id="${Me}"${Ne}>${ve}</g>`}let Ee="",be="";for(let ue=0;ue<ee.length;ue++){let fe=ee[ue],Me=K[ue],Ne=z[ue],Be=Me.arrowTypeStart,ce=Me.arrowTypeEnd,Se=gu(Be),$e=gu(ce),Ae;if(fe.src===fe.dst){let Oe=Y[fe.src],ve=W[fe.src],Ge=ne[ue],pe=Oe.x+ae+ve.w/2,J=Oe.y+Z,_e=Math.min(ve.h/2-4,8+Ge*6),le=Eg+Ge*8;Ae={d:`M${d(pe+Se)},${d(J-_e)}C${d(pe+le+Se)},${d(J-_e)} ${d(pe+le+$e)},${d(J+_e)} ${d(pe+$e)},${d(J+_e)}`,sx:pe,sy:J-_e,sdx:-1,sdy:0,ex:pe,ey:J+_e,edx:-1,edy:0},fe.labelX=Oe.x+ve.w/2+le+4+fe.labelW/2,fe.labelY=Oe.y}else{let Oe=fe.route;for(let ve=0;ve<Oe.length;ve+=3)Oe[ve]+=ae,Oe[ve+1]+=Z;Ae=xn(Oe,void 0,Se,$e)}let xe=Me.pattern==="dashed"?' stroke-dasharray="6 4"':Me.pattern==="dotted"?' stroke-dasharray="2 4"':"";if(Ee+=`<g class="pele-edge${Me.pattern==="dotted"?" pele-note-edge":" pele-relation"}" data-id="${Fe(Me.id)}"><path d="${Ae.d}"${xe}/>`+bu(Be,Ae.sx,Ae.sy,Ae.sdx,Ae.sdy,Eu)+bu(ce,Ae.ex,Ae.ey,Ae.edx,Ae.edy,Eu)+"</g>",Ne.width>0){let Oe=fe.labelX+ae,ve=fe.labelY+Z;be+=sn(Me.id,Ne,Oe,ve,"",n.icons)}}let ye="";for(let ue of N)ye+=ue.math?De(ue.math,ue.x+ae,ue.y+Z,' class="pele-cardinality"',n.icons):`<text class="pele-cardinality" x="${d(ue.x+ae)}" y="${d(ue.y+Z+f*.35)}" text-anchor="middle">${je(ue.text)}</text>`;let Re=Va(e.title,u,c,m,Q,ie,(te?`<g class="pele-clusters">${te}</g>`:"")+(Ee?`<g class="pele-edges" fill="none" stroke="${Eu}" stroke-linecap="round">${Ee}</g>`:"")+(he?`<g class="pele-cluster-titles">${he}</g>`:"")+(be?`<g class="pele-edge-labels" font-size="${l}">${be}</g>`:"")+(ye?`<g class="pele-cardinalities" font-size="${f}" fill="var(--_m)">${ye}</g>`:"")+`<g class="pele-nodes">${oe}</g>`);return{svg:Ze("class",Re.width,Re.height,c,n,e,Re.content),width:Re.width,height:Re.height,links:me}}var wg={type:"class",math:!0,parse(e,t,n){let r=new ic;return n&&(r.title=n),mg(e,r),r},render:_g};var Au=class{constructor(){de(this,"domains",new Map);de(this,"transitions",[])}setDomains(t){if(t)for(let n of t){let r=n.domain;this.domains.set(r,{name:r,items:(n.items??[]).map(o=>({label:o.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 Rg(e,t){let n=new Au;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,`
`):void 0,domains:n.domains,transitions:n.transitions}}var Tg=[{name:"cynefin-beta:",pattern:"cynefin-beta:"},qt("cynefin-beta"),{name:"-->",pattern:"-->"},{name:":",pattern:":"},{name:"DOMAIN_NAME",pattern:/complex|complicated|clear|chaotic|confusion/y},tn,zt,Vt,Cn,bn,yn,Ut,jt,Xt];function Cg(e){let t=new Bt(Wt(e,Tg,"cynefin"),Tg,"cynefin"),n={$type:"Cynefin",domains:[],transitions:[]},r=()=>{for(;t.kinds[t.i]===9;)t.i++},o=()=>{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=Ht(t.take()),o();break;case 6:n.accTitle=Yt(t.take()),o();break;case 7:n.title=Gt(t.take()),o();break;case 4:{let s=t.take();if(t.accept(2)){let i={$type:"Transition",from:s,to:t.expect(4)};t.accept(3)&&(i.label=on(t.expect(8))),o(),n.transitions.push(i);break}let a={$type:"DomainBlock",domain:s,items:[]};for(r();t.kinds[t.i]===8;)a.items.push({$type:"DomainItem",label:on(t.take())}),r();n.domains.push(a);break}default:t.fail("a domain, a transition, a title, or a line break")}return n}function Ng(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 XR(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}function Mg(e,t){return typeof e=="number"&&Number.isFinite(e)&&e!==0?e:XR(t)}var Ig={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},xu={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function fc(e,t,n,r,o,s){let a=(t-e)/s.segments,i=[],c=[];for(let f=0;f<=s.segments;f++){let p=f===0&&s.pinStart||f===s.segments&&s.pinEnd;i.push(e+f*a),c.push(p?n:n+Ng(r+f*s.pointStep)*o*2-o)}let l=s.vertical?[c[0],i[0]]:[i[0],c[0]];for(let f=0;f<s.segments;f++){let p=(i[f]+i[f+1])/2,u=o*1.5*(f%2===0?1:-1)*Ng(r+f*s.controlStep+s.controlShift);s.vertical?l.push(c[f]+u,p,c[f+1]-u,p,c[f+1],i[f+1]):l.push(p,c[f]+u,p,c[f+1]-u,i[f+1],c[f+1])}return l}function kg(e,t,n,r){let o=n-t;return[e,t,e+r,t+o*.2,e-r*1.5,t+o*.55,e+r*.5,t+o*.75,e-r,t+o*.85,e+r*.3,t+o*.95,e,n]}function Si(e){let t="";for(let n=2;n<e.length;n+=6)t+=`C${d(e[n])},${d(e[n+1])} ${d(e[n+2])},${d(e[n+3])} ${d(e[n+4])},${d(e[n+5])}`;return t}function Ro(e){let t="";for(let n=e.length-6;n>=2;n-=6)t+=`C${d(e[n+2])},${d(e[n+3])} ${d(e[n])},${d(e[n+1])} ${d(e[n-2])},${d(e[n-1])}`;return t}function To(e){return`M${d(e[0])},${d(e[1])}${Si(e)}`}function Lg(e,t,n,r){let o=`${d(n)},${d(r)}`;return`M${d(e-n)},${d(t)}A${o} 0 1,1 ${d(e+n)},${d(t)}A${o} 0 1,1 ${d(e-n)},${d(t)}Z`}var Su=[["complex",0,0,0],["complicated",1,0,1],["chaotic",0,1,3],["clear",1,1,2]],qR=4,QR=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"]]]),$g=3,Dg=200,ZR=10,JR=4,pc=6,Og=10,vg=20,hc=10;function mc(e,t,n,r,o){let s=e.cynefin?.[t];return typeof s=="number"&&s>=r&&s<=o?s:n}function Pg(e,t,n){let r=n.fontSize??16,o=Math.round(r*.8125),s=Math.round(r*.875),a=n.measurer??et(n.fontFamily),i=n.padding??8,c=n.icons,l=t.cynefin?.showDomainDescriptions!==!1,f=mc(t,"boundaryAmplitude",8,0,50),p=Mg(mc(t,"seed",0,-1e15,1e15),n.idPrefix??"pele"),u=Math.round(s*1.5),m=(P,V)=>{let ne=We(P,!1,a,s,Dg);return{text:P,label:ne,w:ne.width+2*ZR,h:Math.max(ne.height,u)+2*JR,overflow:V}},h=P=>{let V=QR.get(P),ne=We(V[0],!1,a,r,4e3,1),ae=[];if(l)for(let te of[V[1],V[2]])te&&ae.push(We(te,!1,a,o,4e3,2));let Z=e.domains.get(P)?.items??[],Q=P==="confusion"&&Z.length>$g?$g:Z.length,ie=[];for(let te=0;te<Q;te++)ie.push(m(Z[te].label,!1));Q<Z.length&&ie.push(m(`+${Z.length-Q} more`,!0));let me=ne.width,re=ne.height;for(let te of ae)me=Math.max(me,te.width),re+=te.height;ie.length>0&&(re+=Og-pc);for(let te of ie)me=Math.max(me,te.w),re+=pc+te.h;return{name:P,title:ne,subtitles:ae,badges:ie,w:me,h:re,cx:0,cy:0}},b=Su.map(([P])=>h(P)),x=h("confusion"),E=Math.max(88,x.w*.71+8),w=Math.max(64,x.h*.71+6),S=mc(t,"width",640,100,1e4)/2,O=mc(t,"height",440,100,1e4)/2;for(let P of b)S=Math.max(S,P.w+2*vg),O=Math.max(O,P.h+2*vg);for(let P of b){let V=(S-P.w)/2,ne=(O-P.h)/2;if((V/(E+hc))**2+(ne/(w+hc))**2>=1)continue;let ae=P.w+2*(E+hc),Z=P.h+2*(w+hc);ae*O<=S*Z?S=Math.max(S,ae):O=Math.max(O,Z)}let D=We(e.title,!1,a,r,4e3,1),L=D.height>0?D.height+12:0,B=2*S,W=2*O,Y=i,I=i+L,X=Y+S,ee=I+O,K=Y+B,z=I+W,C=fc(I,ee,X,p,f,{...Ig,segments:4,pinEnd:!0}),M=fc(Y,X,ee,p+100,f,{...xu,segments:4,pinEnd:!0}),T=fc(X,K,ee,p+200,f,{...xu,segments:4,pinStart:!0}),g=kg(X,ee,z,B*.03),_=(P,V)=>V?`${d(P[P.length-2])},${d(P[P.length-1])}`:`${d(P[0])},${d(P[1])}`,y=new Map([["complex",`M${d(Y)},${d(I)}L${_(C,!1)}${Si(C)}${Ro(M)}Z`],["complicated",`M${_(C,!1)}L${d(K)},${d(I)}L${_(T,!0)}${Ro(T)}${Ro(C)}Z`],["chaotic",`M${_(M,!1)}${Si(M)}${Si(g)}L${d(Y)},${d(z)}Z`],["clear",`M${_(T,!1)}${Si(T)}L${d(K)},${d(z)}L${_(g,!0)}${Ro(g)}Z`]]),R="";for(let[P,,,V]of Su)R+=`<path class="pele-cynefin-region" data-id="${P}" d="${y.get(P)}" fill="${lt(V)}" fill-opacity="0.14"/>`;let A=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${To(C)}"/><path d="${To(M)}"/><path d="${To(T)}"/><path class="pele-cynefin-cliff" d="${To(g)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,N=Lg(X,ee,E,w),$=`<path d="${N}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${N}" fill="${lt(qR)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,U=P=>{let V=P.cy-P.h/2,ne=De(P.title,P.cx,V+P.title.height/2,' class="pele-label" font-weight="var(--_hw)"');V+=P.title.height;for(let ae of P.subtitles)ne+=De(ae,P.cx,V+ae.height/2,` class="pele-cynefin-subtitle" font-size="${o}" font-style="italic" fill="var(--_m)"`),V+=ae.height;V+=Og-pc;for(let ae of P.badges)V+=pc,ne+=`<g class="pele-node${ae.overflow?" pele-cynefin-overflow":""}"${ae.overflow?"":` data-id="${Fe(ae.text)}"`}><rect x="${d(P.cx-ae.w/2)}" y="${d(V)}" width="${d(ae.w)}" height="${d(ae.h)}" fill="var(--_bg)" stroke="var(--_b)"${ae.overflow?' stroke-dasharray="3 2"':""}${it}/>`+De(ae.label,P.cx,V+ae.h/2,` class="pele-label" font-size="${s}"${ae.overflow?' fill="var(--_m)"':""}`,c)+"</g>",V+=ae.h;return`<g class="pele-cynefin-domain" data-id="${P.name}">${ne}</g>`},j=new Map,v="";Su.forEach(([P,V,ne],ae)=>{let Z=b[ae];Z.cx=Y+S*(V+.5),Z.cy=I+O*(ne+.5),j.set(P,Z),v+=U(Z)}),x.cx=X,x.cy=ee,j.set("confusion",x),v+=U(x);let k=(P,V,ne)=>P===x?((V-X)/(E+4))**2+((ne-ee)/(w+4))**2<=1:Math.abs(V-P.cx)<=P.w/2+8&&Math.abs(ne-P.cy)<=P.h/2+8,F="",H=new Map;for(let P of e.transitions){let V=j.get(P.from),ne=j.get(P.to);if(!V||!ne||V===ne)continue;let ae=P.from<P.to?`${P.from} ${P.to}`:`${P.to} ${P.from}`,Z=H.get(ae)??0;H.set(ae,Z+1);let Q=ne.cx-V.cx,ie=ne.cy-V.cy,me=Math.hypot(Q,ie)||1,re=(V.cx+ne.cx)/2,te=(V.cy+ne.cy)/2,he=-ie*(re-X)+Q*(te-ee)>=0?1:-1,oe=-ie/me*he,ge=Q/me*he,be=(V!==x&&ne!==x&&Math.abs(Q)>1&&Math.abs(ie)>1?2*(Math.hypot(E*oe,w*ge)+16):me*.15)+Z*56,ye=re+oe*be,Re=te+ge*be,Le=we=>{let Te=1-we;return[Te*Te*V.cx+2*Te*we*ye+we*we*ne.cx,Te*Te*V.cy+2*Te*we*Re+we*we*ne.cy]},ue=(we,Te,Ce,Ie)=>{for(let Pe=0;Pe<16;Pe++){let Ue=(Te+Ce)/2;k(we,...Le(Ue))===Ie?Te=Ue:Ce=Ue}return(Te+Ce)/2},fe=48,Me=1;for(;Me<=fe&&k(V,...Le(Me/fe));)Me++;if(Me>fe)continue;let Ne=ue(V,(Me-1)/fe,Me/fe,!0);for(;Me<=fe&&!k(ne,...Le(Me/fe));)Me++;let Be=Me>fe?1:ue(ne,(Me-1)/fe,Me/fe,!1),[ce,Se]=Le(Ne),[$e,Ae]=Le(Be),xe=(we,Te,Ce)=>(1-Ne)*(1-Be)*we+((1-Ne)*Be+Ne*(1-Be))*Te+Ne*Be*Ce,Oe=xe(V.cx,ye,ne.cx),ve=xe(V.cy,Re,ne.cy),Ge=Math.hypot($e-Oe,Ae-ve)||1,pe=($e-Oe)/Ge,J=(Ae-ve)/Ge,_e=Et("arrow_point",$e,Ae,pe,J,"var(--_l)");$e-=pe*mt("arrow_point"),Ae-=J*mt("arrow_point");let le="";if(P.label){let we=We(P.label,!1,a,o,Dg),[Te,Ce]=Le((Ne+Be)/2),Ie=Math.abs(oe)*we.width/2+Math.abs(ge)*we.height/2+6,Pe=we.width/2+4,Ue=Math.min(Math.max(Te+oe*Ie,Y+Pe),Math.max(K-Pe,Y+Pe));le=De(we,Ue,Ce+ge*Ie,` class="pele-edge-label" font-size="${o}"`,c)}F+=`<g class="pele-edge" data-id="${P.from}-${P.to}"><path d="M${d(ce)},${d(Se)}Q${d(Oe)},${d(ve)} ${d($e)},${d(Ae)}" fill="none" stroke="var(--_l)"/>`+_e+le+"</g>"}let G=Math.ceil(Math.max(B,D.width)+2*i),se=Math.ceil(W+L+2*i),q=De(D,Y+B/2,i+D.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-cynefin-regions">${R}</g>`+A+$+v+(F?`<g class="pele-edges">${F}</g>`:"");return{svg:Ze("cynefin",G,se,r,n,e,q),width:G,height:se,links:[]}}var Bg={type:"cynefin",parse:(e,t,n)=>Rg(Cg(e),n),render:Pg};function eT(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}var gc=class{constructor(){de(this,"type","er");de(this,"direction","TB");de(this,"entities",new Map);de(this,"relationships",[]);de(this,"classes",new Map);de(this,"subgraphs",[]);de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"subgraphLookup",new Map);de(this,"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 o=n.length-1;o>=0;o--){let s=n[o];s.keys??=[],s.comment??="",r.attributes.push(s)}}addRelationship(t,n,r,o){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:o})}setDirection(t){this.direction=t}addCssStyles(t,n){if(n)for(let r of t){let o=this.entities.get(r);if(o)for(let a of n)o.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 o=this.classes.get(r);if(o===void 0&&(o={id:r,styles:[],textStyles:[]},this.classes.set(r,o)),!!n)for(let s of n)s.includes("color")&&o.textStyles.push(s.replace("fill","bgFill")),o.styles.push(s)}}setClass(t,n){for(let r of t){let o=this.entities.get(r);if(o)for(let a of n)o.cssClasses+=" "+a;let s=this.subgraphLookup.get(r);if(s)for(let a of n)s.classes.push(a)}}addSubGraph(t,n,r){let o=t.text.trim(),s=new Set,a=[],i;for(let l of n.flat()){if(typeof l!="string"){l?.stmt==="dir"&&(i=l.value);continue}let f=l.trim();f===""||s.has(f)||(s.add(f),this.claimed.has(l)||a.push(l))}for(let l of a)this.claimed.add(l);let c={id:o,nodes:a,title:(r.text||"").trim(),classes:[],cssStyles:[],dir:i,labelType:eT(r.type)};return this.subgraphs.push(c),this.subgraphLookup.set(o,c),o}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
`)}};var _u=["$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 Co=1,bc=2,Tu=4,No=8,Zn=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&&(Zn[e]|=Co|bc|No),n&&(Zn[e]|=Tu)}for(let e of"-*")Zn[e.charCodeAt(0)]|=Co|bc|No;Zn[46]|=Co|No;Zn[42]|=Tu;for(let e of"[](),")Zn[e.charCodeAt(0)]|=No;var tT=/accTitle\s*:\s*/iy,nT=/accDescr\s*:\s*/iy,rT=/accDescr\s*\{\s*/iy,sT=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],wu=/direction/gi,Ru=/[\n\r\u2028\u2029]/g;function Fg(e,t){return e<128?(Zn[e]&t)!==0:e>=192||e===181}function Wg(e){let t=e.length,n=[],r=[],o=[],s=0,a=0,i=-2,c=0,l=-1,f=-2,p=-1,u=-1,m=-1,h=(K,z,C)=>{n.push(K),r.push(e.slice(z,C)),o.push(z),a=C},b=(K,z)=>(K.lastIndex=z,K.test(e)?K.lastIndex:-1),x=K=>{for(let z=0;z<K.length;z++){let C=K.charCodeAt(z),M=e.charCodeAt(a+z);if(M!==C&&(C<97||C>122||(M|32)!==C))return!1}return!0},E=K=>x(K)&&!Qe(e.charCodeAt(a+K.length)),w=K=>{let z=e.charCodeAt(K);return z>=65&&z<=90?z+32:z},S=K=>(Ru.lastIndex=K,Ru.test(e)?Ru.lastIndex-1:t),O=K=>{for(;ft(e.charCodeAt(K));)K++;return K},D=()=>{if(i===-1||i<a&&(wu.lastIndex=a,i=wu.test(e)?wu.lastIndex-9:-1,i===-1)||a<c||(l<a&&(l=S(a)),i>=l))return!1;for(let K=0;K<4;K++){let z=b(sT[K],a);if(z>=0)return h(18+K,a,z),!0}return c=l,!1},L=()=>{let K=e.indexOf('"',a+1);if(K===-1){h(45,a,a+1);return}let z=K>a+1;for(let C=a+1;z&&C<K;C++){let M=e.charCodeAt(C);(M===37||M===92||M===13||M===10||M===11||M===8)&&(z=!1)}h(z?31:44,a,K+1)},B=K=>{let z=e.charCodeAt(a+1);if(z===43&&(K===49||K===48)){h(K===49?39:38,a,a+2);return}let C=O(a+1);if(e.charCodeAt(C)===46&&ft(e.charCodeAt(C+1))){h(32,a,O(C+2));return}if(K===49){if(He(z)){let M=a+2;for(;He(e.charCodeAt(M));)M++;let T=e.charCodeAt(M);if(Qe(T)||T===34||T===39){h(40,a,a+1);return}}else if(z===45||z===46){let M=e.charCodeAt(a+2);if(M===45||M===46){h(40,a,a+1);return}}if(!Qe(z)){h(33,a,a+1);return}}h(29,a,C)},W=K=>{let z=e.charCodeAt(a+1);switch(K){case 101:if(E("erdiagram"))h(2,a,a+9);else if(E("end")){let C=a+3;for(;He(e.charCodeAt(C));)C++;h(16,a,C)}else return!1;return!0;case 115:if(E("style"))s=6,h(27,a,a+5);else if(E("subgraph"))h(17,a,a+8);else return!1;return!0;case 99:if(E("classdef"))s=6,h(22,a,a+8);else if(E("class"))h(26,a,a+5);else return!1;return!0;case 111:if(E("one or zero"))h(37,a,a+11);else if(E("one or more")||E("one or many"))h(39,a,a+11);else if(E("one"))h(40,a,a+3);else if(E("only one"))h(40,a,a+8);else if(z===124)h(37,a,a+2);else if(z===123)h(38,a,a+2);else if(E("optionally to"))h(42,a,a+13);else return!1;return!0;case 122:if(E("zero or one"))h(37,a,a+11);else if(E("zero or more")||E("zero or many"))h(38,a,a+12);else return!1;return!0;case 109:if(x("many(0)"))h(38,a,a+7);else if(x("many(1)"))h(39,a,a+7);else if(E("many"))h(38,a,a+4);else return!1;return!0;case 116:return E("to")?(h(43,a,a+2),!0):!1;case 117:return z!==46&&z!==45&&z!==124?!1:(h(41,a,a+1),!0);case 124:if(w(a+1)===111&&!Qe(e.charCodeAt(a+2)))h(37,a,a+2);else if(z===124)h(40,a,a+2);else if(z===123)h(39,a,a+2);else return!1;return!0;case 125:if(w(a+1)===111&&!Qe(e.charCodeAt(a+2)))h(38,a,a+2);else if(z===124)h(39,a,a+2);else return!1;return!0;case 46:return z!==46&&z!==45?!1:(h(42,a,a+2),!0);case 45:if(z===45)h(43,a,a+2);else if(z===46)h(42,a,a+2);else return!1;return!0}return!1},Y=K=>{let z;if((K===97||K===65)&&x("acc")){if((z=b(tT,a))>=0){s=3,h(11,a,z);return}if((z=b(nT,a))>=0){s=4,h(13,a,z);return}if((z=b(rT,a))>=0){s=5,a=z;return}}if(!D()){switch(K){case 32:case 9:case 13:z=a+1;for(let C=e.charCodeAt(z);C===32||C===9||C===13;C=e.charCodeAt(z))z++;a=z;return;case 10:for(z=a+1;e.charCodeAt(z)===10;)z++;h(4,a,z);return;case 34:L();return;case 123:s=1,h(7,a,a+1);return;case 35:h(30,a,a+1);return;case 44:h(25,a,a+1);return;case 58:e.charCodeAt(a+1)===58&&e.charCodeAt(a+2)===58?h(6,a,a+3):h(5,a,a+1);return;case 91:h(9,a,a+1);return;case 93:h(10,a,a+1);return}if(ft(K)){B(K);return}if(!W(K>=65&&K<=90?K+32:K)){if(K>=128||(Zn[K]&Co)!==0){z=a+1;for(let C=e.charCodeAt(z);C>=128||(Zn[C]&Co)!==0;C=e.charCodeAt(z))z++;h(23,a,z);return}h(45,a,a+1)}}},I=()=>{if(f===-1||f<a&&(f=e.indexOf("~",a),f===-1))return!1;if(m<a){let z=a;for(;z<t&&!He(e.charCodeAt(z));)z++;m=z}if(f>=m||(p<a&&(p=S(a),u=e.lastIndexOf("~",p-1)),u<=f))return!1;let K=u+1;for(;K<t&&!He(e.charCodeAt(K));)K++;return h(34,a,K),!0},X=K=>{if(He(K)){for(a++;He(e.charCodeAt(a));)a++;return}let z=K|32;if((z===112||z===102||z===117)&&(e.charCodeAt(a+1)|32)===107&&!Qe(e.charCodeAt(a+2))){h(35,a,a+2);return}if(!I()){if(Fg(K,Tu)){let C=a+1;for(;C<t&&Fg(e.charCodeAt(C),No);)C++;h(34,a,C);return}if(K===96){s=2,a++;return}if(K===34){let C=e.indexOf('"',a+1);if(C!==-1){h(36,a,C+1);return}}else if(K===125){s=0,h(8,a,a+1);return}h(45,a,a+1)}};for(;a<t;){let K=e.charCodeAt(a),z;switch(s){case 0:Y(K);break;case 1:X(K);break;case 2:K===96?(s=1,a++):(z=e.indexOf("`",a),h(34,a,z===-1?t:z));break;case 3:case 4:z=e.indexOf(`
`,a),h(s===3?12:14,a,z===-1?t:z),s=0;break;case 5:K===125?(s=0,a++):(z=e.indexOf("}",a),h(15,a,z===-1?t:z));break;case 6:if(K===10){for(z=a+1;e.charCodeAt(z)===10;)z++;s=0,h(4,a,z)}else if(He(K))for(a++;He(e.charCodeAt(a));)a++;else if(K===58)h(5,a,a+1);else if(K===44)h(25,a,a+1);else if(K===35)h(30,a,a+1);else if(K===59)h(28,a,a+1);else if(K>=128||(Zn[K]&bc)!==0){z=a+1;for(let C=e.charCodeAt(z);C>=128||(Zn[C]&bc)!==0;C=e.charCodeAt(z))z++;h(24,a,z)}else return n.push(1),r.push(""),o.push(a),{types:n,texts:r,starts:o};break}}let ee=s===0?3:s===3?12:s===4?14:s===5?15:-1;return ee!==-1&&(n.push(ee),r.push(""),o.push(t)),n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var Cu=new Map([[37,"ZERO_OR_ONE"],[38,"ZERO_OR_MORE"],[39,"ONE_OR_MORE"],[40,"ONLY_ONE"],[41,"MD_PARENT"]]),iT=["TB","BT","RL","LR"],Ug="'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'",oT="'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'",yc="'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', "+Ug;function Gg(e,t){let{types:n,texts:r,starts:o}=Wg(e),s=0,a=B=>{let W=n[s];throw W===1?st("er",e,o[s],"",!0):st("er",e,o[s],`Expecting ${B}, got '${W===45?r[s]:_u[W]}'`)},i=B=>(n[s]!==B&&a(`'${_u[B]}'`),r[s++]),c=()=>{let B=n[s];B!==4&&B!==28&&B!==3&&a("'EOF', 'NEWLINE', 'SEMI'"),s++},l=B=>B===23||B===31||B===29||B===32||B===33,f=()=>{let B=n[s];l(B)||a(Ug);let W=r[s++];return B===31?W.slice(1,-1):W},p=()=>{let B=[];for(;;){let W=n[s];if(W!==23&&W!==24&&a("'UNICODE_TEXT', 'STYLE_TEXT'"),B.push(r[s++]),n[s]!==25)return B;s++}},u=B=>B===24||B===29||B===5||B===30,m=()=>{let B=[];for(;;){u(n[s])||a("'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'");let W=r[s++];for(;u(n[s]);)W+=r[s++];if(B.push(W),n[s]!==25)return B;s++}},h=()=>{let B=Cu.get(n[s++]),W=n[s];W!==43&&W!==42&&a("'NON_IDENTIFYING', 'IDENTIFYING'");let Y=W===43?"IDENTIFYING":"NON_IDENTIFYING";s++;let I=Cu.get(n[s]);return I===void 0?a(oT):(s++,{cardA:I,relType:Y,cardB:B})},b=()=>{let B=n[s];B!==44&&B!==31&&B!==23&&a("'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'");let W=r[s++];return B===23?W:W.slice(1,-1)},x=B=>n[s]===45&&r[s]===B,E=()=>{let B=[];do{let W=i(34);x("?")&&(W+=r[s++]),n[s]!==34&&a(W.endsWith("?")?"'ATTRIBUTE_WORD'":"'ATTRIBUTE_WORD', '?'");let Y={type:W,name:r[s++]};if(n[s]===35){let I=[r[s++]];for(;x(",");)s++,I.push(i(35));Y.keys=I}n[s]===36&&(Y.comment=r[s++].slice(1,-1)),B.push(Y)}while(n[s]!==8);return B.reverse()},w=()=>{if(n[s]!==7)return;if(s++,n[s]===8){s++;return}let B=E();return s++,B},S=()=>{let B=f(),W=n[s];if(W===9){s++;let X=f();i(10);let ee;n[s]===6&&(s++,ee=p());let K=w();return t.addEntity(B,X),K&&t.addAttributes(B,K),ee&&t.setClass([B],ee),[B]}let Y;if(W===6&&(s++,Y=p(),W=n[s]),Cu.has(W)){let X=h(),ee=f(),K;n[s]===6&&(s++,K=p()),i(5);let z=b();return t.addEntity(B),t.addEntity(ee),t.addRelationship(B,z,ee,X),Y&&t.setClass([B],Y),K&&t.setClass([ee],K),[B,ee]}let I=w();return t.addEntity(B),I&&t.addAttributes(B,I),Y&&t.setClass([B],Y),[B]};i(2);let O=[{id:"",title:"",list:[]}],D=O[0],L=!1;for(;;){let B=n[s];switch(B){case 4:s++;break;case 3:s++,L&&a(`'END', ${yc}`);return;case 16:{L||a(yc),s++;let W=t.addSubGraph({text:D.id},D.list,{text:D.title});O.pop(),D=O[O.length-1],L=O.length>1,L&&D.list.push(W);break}case 17:{s++;let W=f(),Y=W;if(n[s]===9){for(s++,Y=f();l(n[s]);)Y+=" "+f();i(10)}c(),D={id:W,title:Y,list:[]},O.push(D),L=!0;break}case 11:{s++;let W=i(12).trim();t.setAccTitle(W),L&&D.list.push(W);break}case 13:{s++;let W=i(14).trim();t.setAccDescription(W),L&&D.list.push(W);break}case 15:{let W=r[s++].trim();t.setAccDescription(W),L&&D.list.push(W);break}case 18:case 19:case 20:case 21:{s++;let W=iT[B-18];L?D.list.push({stmt:"dir",value:W}):t.setDirection(W);break}case 22:{let W=r[s++],Y=p(),I=m();c(),t.addClass(Y,I),L&&D.list.push(W);break}case 26:{let W=r[s++],Y=p();t.setClass(Y,p()),L&&D.list.push(W);break}case 27:{let W=r[s++],Y=p(),I=m();c(),t.addCssStyles(Y,I),L&&D.list.push(W);break}default:{l(B)||a(L?`'END', ${yc}`:yc);let W=S();if(L)for(let Y of W)D.list.push(Y)}}}}var aT=[];function Yg(e){let t=[],n=[],r=e.subgraphs,o=c=>{let l=[];for(let f of c){let p=e.classes.get(f);if(p!==void 0){for(let u of p.styles)l.push(u.trim());for(let u of p.textStyles)l.push(u.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 f of l.nodes)s.set(f,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:aT,isGroup:!0,parentId:s.get(l.id),cssStyles:l.cssStyles,cssCompiledStyles:o(l.classes),cssClasses:l.classes.join(" "),dir:l.dir,labelType:l.labelType})}let i=new Map;for(let[c,l]of e.entities){if(a.has(c)){i.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:o(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:i.get(c.entityA)??c.entityA,end:i.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 gr=18,Hg=5,Kg=6,Nu=10,zg=3.5;function Os(e,t,n,r,o){let s=(f,p)=>d(t-r*f-o*p)+","+d(n-o*f+r*p),a=f=>`M${s(f,-Hg)}L${s(f,Hg)}`,i=`M${s(0,-Kg)}L${s(Nu,0)}L${s(0,Kg)}`,c=f=>`<circle class="pele-marker" cx="${d(t-r*f)}" cy="${d(n-o*f)}" r="${zg}" fill="var(--_bg)"/>`,l=f=>`<path class="pele-marker" d="${f}"/>`;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(i+a(Nu+3.5));case"zero_or_more":return l(i)+c(Nu+zg+.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 cT=48,lT=20,dT=64,Mo=20,Io=28,uT=38,Vg=96,jg=18,fT=12,pT=9,Mu=12,Xg=16,Iu=9,hT=260,ku=1e6,mT=[],gT=18,bT=14,qg=' fill="var(--_s)" stroke="var(--_b)"';function Qg(e,t,n){let r=e.er?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function Ec(e,t,n,r,o){let s=e.lines;if(s.length===0)return"";let a=s.length===1&&s[0].length===1?s[0][0]:void 0;if(a&&a.icon===void 0&&a.math===void 0&&a.style===0)return`<text${r} x="${d(t)}" y="${d(n)}">${je(a.text)}</text>`;let i=Tr(e),c=e.size*.35,l=n-c-e.lineHeight/2,f="",p="";for(let u=0;u<s.length;u++){let m=s[u],h=l+lr(e,u);if(mi(m)){p+=De(dr(e,u),t+e.widths[u]/2,h,r,o);continue}n=h+c;let b=!1;for(let w of m)w.icon!==void 0&&(b=!0);let x=t,E=!1;for(let w of m){if(w.icon!==void 0){let S=e.size*1.1;p+=`<svg class="pele-icon" data-icon="${Fe(w.icon)}" x="${d(x)}" y="${d(n-e.size*.35-S/2)}" width="${d(S)}" height="${d(S)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${o?.(w.icon)??""}</svg>`}else if(w.text!==""){let S=b||!E?` x="${d(x)}" y="${d(n)}"`:"";f+=`<tspan${S}${ar(w.style&~i)}>${je(w.text)}</tspan>`,E=!0}x+=w.width}}return`<text${jn(r,i)} xml:space="preserve">${f}</text>${p}`}function Lu(e){let t=qr(e);return t===e?e:t.replace(/</g,"&lt;").replace(/>/g,"&gt;")}function eb(e,t,n){return Tn(e.direction)?$t(n,r=>Zg(e,t,n,r)):Zg(e,t,n,!1)}function Zg(e,t,n,r){let o=Yg(e),s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??et(n.fontFamily),c=n.padding??8,l=n.icons,f=new Map,p=[],u=[];o.nodes.forEach((y,R)=>f.set(y.id,R));let m=[],h=[],b=[],x=new Map,E=[];for(let y of o.edges){let R=f.get(y.start),A=f.get(y.end);if(R===void 0||A===void 0)continue;let N=We(y.label,!0,i,a,200),$;if(R===A){$={label:N,band:0,at:0};let U=x.get(R);U?U.push($):x.set(R,[$])}E.push($),b.push(y),h.push(N),m.push({src:R,dst:A,minlen:1,labelW:N.width>0?N.width+12:0,labelH:N.height>0?N.height+4:0,route:[],labelX:0,labelY:0})}let w=y=>{let R=y;for(let A=0;A<o.nodes.length;A++){let N=o.nodes[R].parentId,$=N===void 0?void 0:f.get(N);if($===void 0)break;let U=o.nodes[$].dir;if(U)return U==="LR"||U==="RL";R=$}return e.direction==="LR"||e.direction==="RL"};for(let y=0;y<o.nodes.length;y++){let R=o.nodes[y],A=St(R.cssStyles.length>0?R.cssCompiledStyles.concat(R.cssStyles):R.cssCompiledStyles),N=(A.bold?1:0)|(A.italic?2:0),$=A.fontSize??s,U=A.fontSize??a,j=A.fontSize??Math.round(s*.75),v=R.isGroup?We(R.label,!0,i,$,4e3,N):We(R.alias||R.label,!0,i,$,240,N),k=x.get(y)??mT,F=k.length>0&&!R.isGroup&&w(y),H={node:R,style:A,label:v,w:0,h:0,headH:0,rows:[],cols:[],rowSize:U,keySize:j,below:F},G=0,se=0;for(let V of k)V.band=Math.max(uT,F?V.label.width+12:V.label.height+6),se+=V.band,G=Math.max(G,F?V.label.height:V.label.width);let q=Math.max(Vg,F?se+8:0),P;if(R.isGroup)P=Pt(0,0),P.isGroup=!0,P.dir=R.dir?rn(R.dir):void 0,P.padX=Mo,P.padTop=H.label.height>0?H.label.height+16:Mo,P.padBottom=Mo,P.minW=Math.max(H.label.width+2*Mo-12,Vg);else{let V=Math.max(v.height,Math.round($*1.5));if(R.attributes.length===0)H.w=Math.max(v.width+2*jg,q),H.h=Math.max(V+2*fT,F?0:se+8);else{let ae=Math.round(U*1.5),Z=[0,0,0,0];for(let te of R.attributes){let he=[We(Lu(te.type),!0,i,U,ku,N),We(Lu(te.name),!0,i,U,ku,N),We(te.keys.join(", "),!1,i,j,ku,N),We(Lu(te.comment),!0,i,U,hT,N)],oe=ae;for(let ge=0;ge<4;ge++)he[ge].width>Z[ge]&&(Z[ge]=he[ge].width),he[ge].height>oe&&(oe=he[ge].height);H.rows.push({cells:he,h:oe+Iu}),H.h+=oe+Iu}let Q=0,ie=0;for(let te of Z)te!==0&&(ie+=te+(Q>0?Xg:0),Q++);H.w=Math.max(ie+2*Mu,v.width+2*jg,q);let me=Q>0?(H.w-ie-2*Mu)/Q:0,re=Mu;for(let te of Z)H.cols.push(re),te>0&&(re+=te+me+Xg);H.headH=V+2*pT,H.h+=H.headH}let ne=k.length>0?2*(gr+Io*.75+10+G):0;P=F?Pt(H.w,H.h+ne):Pt(H.w+ne,H.h)}P.seq=p.length,p.push(H),u.push(P)}o.nodes.forEach((y,R)=>{u[R].parent=y.parentId!==void 0?f.get(y.parentId)??-1:-1});let S=Rn(u,m,r?"TB":rn(e.direction),{nodeSep:Qg(t,"nodeSpacing",cT),edgeSep:lT,rankSep:Qg(t,"rankSpacing",dT),portSep:24});ET(m,u,p);let O=S.width;for(let[y,R]of x){let A=u[y];if(!A.isGroup)continue;let N=0;for(let $ of R)N=Math.max(N,$.label.width);O=Math.max(O,A.x+A.w/2+gr+Io*.75+10+N)}let D=hn(e.title,i,s,4e3),L=D.height>0?D.height+12:0,B=Math.max(O,D.width),W=c+(B-O)/2,Y=c+L;Gr(u,m,W,Y);let I=Math.ceil(B+2*c),X=Math.ceil(S.height+L+2*c),ee=[],K=new Map,z=!1;for(let y of u)y.isGroup&&(z=!0);if(z)for(let y of m)qn(K,y.route);let C="",M="";for(let y=0;y<p.length;y++){let R=p[y],A=u[y],N=R.node,$=Rt(N.cssClasses.replace(/^default\s?/,""));if(A.isGroup){R.w=A.w,R.h=A.h;let P=A.x-A.w/2,V=A.y-A.h/2,ne=Yr(A,R.label.width,K,Mo);C+=`<g class="pele-cluster${$}" data-id="${Fe(N.id)}"><rect x="${d(P)}" y="${d(V)}" width="${d(A.w)}" height="${d(A.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${pt(R.style.shape)}/>`+De(R.label,ne,V+8+R.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${R.style.text}`,l)+"</g>";continue}let U=R.w,j=R.h,v=-U/2,k=-j/2,F=R.style.text,H=`x="${d(v)}" y="${d(k)}" width="${d(U)}" height="${d(j)}"`,G=De(R.label,0,R.rows.length>0?k+R.headH/2:0,` class="pele-label"${F}`,l),se=yt(N.alias||N.label);if(/ internal-link(?: |$)/.test($+" ")&&G!==""&&n.links!==!1){let P=Cr(Xn(se),n)!==void 0,V=je(se);G=`<a class="internal-link"${P?` href="${V}"${Nr(n)}`:""} data-href="${V}">${G}</a>`,ee.push({id:N.label,href:se,internal:!0})}let q;if(R.rows.length===0)q=`<rect ${H}${pt(qg+R.style.shape)}/>`+G;else{let P=Math.round(R.rowSize*1.5),V=R.style.stroke?je(R.style.stroke):"var(--_b)",ne="",ae="",Z=k+R.headH;for(let ie=0;ie<R.rows.length;ie++){let me=R.rows[ie];if(ie%2===0){let Ee=`x="${d(v)}" width="${d(U)}"`;ie===R.rows.length-1?ne+=`<rect ${Ee} y="${d(Z)}" height="${d(me.h)}"${it}/><rect ${Ee} y="${d(Z)}" height="${d(me.h/2)}"/>`:ne+=`<rect ${Ee} y="${d(Z)}" height="${d(me.h)}"/>`}let re=Z+Iu/2+P/2+R.rowSize*.35,[te,he,oe,ge]=me.cells;ae+=Ec(te,v+R.cols[0],re,` class="pele-er-type" fill="var(--_m)"${F}`,l)+Ec(he,v+R.cols[1],re,` class="pele-er-name"${F}`,l)+Ec(oe,v+R.cols[2],re,` class="pele-er-keys" font-size="${R.keySize}" fill="var(--_m)"${F}`,l)+Ec(ge,v+R.cols[3],re,` class="pele-er-comment" fill="var(--_m)"${F}`,l),Z+=me.h}let Q=d(k+R.headH);q=`<rect ${H}${pt(qg+R.style.shape)}/><g class="pele-er-stripes" fill="var(--_bg)"${R.style.shape.includes("fill:")?' opacity="0.6"':""}>${ne}</g><path class="pele-er-divider" d="M${d(v)},${Q}H${d(v+U)}" stroke="${V}"/><rect ${H} fill="none" stroke="var(--_b)"${pt(R.style.line)}/>`+G+`<g class="pele-er-attributes" font-size="${R.rowSize}">${ae}</g>`}M+=`<g class="pele-node pele-entity${$}" data-id="${Fe(N.label)}" transform="translate(${d(A.x)},${d(A.y)})">${q}</g>`}for(let[y,R]of x){let A=p[y],N=0;for(let j of R)N+=j.band;let $=Math.min(1,Math.max((A.below?A.w:A.h)-8,0)/N),U=-N*$/2;for(let j of R)j.band*=$,j.at=U+j.band/2,U+=j.band}let T="",g="";for(let y=0;y<m.length;y++){let R=m[y],A=b[y],N=h[y],$,U,j,v=E[y];if(v){let F=u[R.src],H=p[R.src],G=Math.max(Math.min(v.band/2-6,13),1),se=gr+Io*.75+6;if(H.below){let q=F.x+v.at,P=F.y+H.h/2,V=d(P+gr),ne=d(P+gr+Io);$=`M${d(q-G)},${d(P)}V${V}C${d(q-G)},${ne} ${d(q+G)},${ne} ${d(q+G)},${V}V${d(P)}`,U=Os(A.arrowTypeStart,q-G,P,0,-1),j=Os(A.arrowTypeEnd,q+G,P,0,-1),R.labelX=q,R.labelY=P+se+N.height/2}else{let q=F.x+H.w/2,P=F.y+v.at,V=d(q+gr),ne=d(q+gr+Io);$=`M${d(q)},${d(P-G)}H${V}C${ne},${d(P-G)} ${ne},${d(P+G)} ${V},${d(P+G)}H${d(q)}`,U=Os(A.arrowTypeStart,q,P-G,-1,0),j=Os(A.arrowTypeEnd,q,P+G,-1,0),R.labelX=q+se+N.width/2,R.labelY=P}}else{let F=yT(R.route);if(F.length<6)continue;Jg(F,0,p[R.src],u[R.src]),Jg(F,F.length-3,p[R.dst],u[R.dst]);let H=Math.abs(F[F.length-3]-F[0]),G=Math.abs(F[F.length-2]-F[1]),q=F.length===6&&(H<.01||G<.01||Math.hypot(H,G)<=3*gr)?0:gr,P=xn(F,void 0,q,q);$=q>0?`M${d(P.sx)},${d(P.sy)}L${P.d.slice(1)}L${d(P.ex)},${d(P.ey)}`:P.d,U=Os(A.arrowTypeStart,P.sx,P.sy,P.sdx,P.sdy),j=Os(A.arrowTypeEnd,P.ex,P.ey,P.edx,P.edy)}let k=A.pattern==="dashed";if(T+=`<g class="pele-edge pele-er-${k?"non-identifying":"identifying"}" data-id="${Fe(A.id)}"><path d="${$}"${k?' stroke-dasharray="4 3"':""}/>`+U+j+"</g>",N.width>0){let F=R.labelX,H=R.labelY;g+=sn(A.id,N,F,H,"",l)}}return{svg:Ze("er",I,X,s,n,e,De(D,I/2,c+D.height/2,' class="pele-title" font-weight="var(--_tw)"')+(C?`<g class="pele-clusters">${C}</g>`:"")+(T?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${T}</g>`:"")+(g?`<g class="pele-edge-labels" font-size="${a}">${g}</g>`:"")+`<g class="pele-nodes">${M}</g>`),width:I,height:X,links:ee}}function yT(e){let t=e.slice(0,3);for(let n=3;n<e.length;n+=3){let r=t.length-3,o=s=>Math.abs(t[r+s]-e[n+s])<.01&&Math.abs(e[n+s]-e[n+3+s])<.01;n+3<e.length&&(o(0)||o(1))||t.push(e[n],e[n+1],e[n+2])}return t}function ET(e,t,n){let r=new Map,o=(s,a,i,c)=>{let l=t[s],f=a[i]-l.x,p=a[i+1]-l.y,u;if(Math.abs(Math.abs(p)-l.h/2)<.5)u=p<0?0:2;else if(Math.abs(Math.abs(f)-l.w/2)<.5)u=f<0?3:1;else return;let m=s*4+u,h={route:a,at:i,toward:a[c+(u&1?1:0)]},b=r.get(m);b?b.push(h):r.set(m,[h])};for(let s of e){let a=s.route.length-3;s.src===s.dst||a<3||(o(s.src,s.route,0,3),o(s.dst,s.route,a,a-3))}for(let[s,a]of r){if(a.length<2)continue;let i=s>>2,c=(s&1)===1,l=t[i].isGroup?t[i]:n[i],f=c?l.h:l.w,p=Math.max(Math.min(gT,(f-2*bT)/(a.length-1)),0),u=c?t[i].y:t[i].x;a.sort((m,h)=>m.toward-h.toward);for(let m=0;m<a.length;m++)a[m].route[a[m].at+(c?1:0)]=u+(m-(a.length-1)/2)*p}}function Jg(e,t,n,r){if(r.isGroup)return;let o=e[t]-r.x,s=e[t+1]-r.y;r.w!==n.w&&Math.abs(Math.abs(o)-r.w/2)<.5&&(e[t]-=Math.sign(o)*(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 tb={type:"er",math:!0,parse(e,t,n){let r=new gc;return n&&(r.title=n),Gg(e,r),r},render:eb};var AT=new Map([["ui","ui"],["pcr","processor"],["processor","processor"],["rmo","readmodel"],["readmodel","readmodel"],["cmd","command"],["command","command"],["evt","event"],["event","event"]]),xT=new Map([["trigger",[0,"UI/Automation","UI/A: "]],["state",[100,"Command/Read Model","C/RM: "]],["stream",[200,"Events","Stream: "]]]);function ST(e){return e==="ui"||e==="processor"?"trigger":e==="event"?"stream":"state"}function $u(e){let t=e.indexOf("{"),n=e.lastIndexOf("}"),o=(t!==-1&&n>t?e.slice(t+1,n):t===-1&&e.length>=2?e.slice(1,-1):"").replace(/\r/g,"").split(`
`);for(;o.length>0&&o[0].trim()==="";)o.shift();for(;o.length>0&&o[o.length-1].trim()==="";)o.pop();let s=1/0;for(let a of o)a.trim()!==""&&(s=Math.min(s,a.length-a.trimStart().length));return o.map(a=>a.slice(Math.min(s,a.length)).trimEnd()).join(`
`)}function nb(e,t){let n=new Set;for(let p of e.frames){if(n.has(p.name)){let u=Vi(e.$source,p.$offset).line;throw new ze(`Duplicate event modeling frame ID "${p.name}" on line ${u}`,"semantic",{type:"eventmodeling",line:u})}n.add(p.name)}let r=new Map;for(let p of e.dataEntities)r.has(p.name)||r.set(p.name,p.dataBlockValue);let o=new Map,s=new Map,a=(p,u)=>{let m=ST(p),h=u===void 0?m:`${m} ${u}`,b=o.get(h);if(!b){let[x,E,w]=xT.get(m),S=x;u!==void 0&&(S=s.get(m)??x+1,s.set(m,S+1)),b={index:S,label:u===void 0?E:w+u,group:m,namespace:u},o.set(h,b)}return b},i=[],c=new Map,l=[];e.frames.forEach((p,u)=>{let m=p.entityIdentifier.split("."),h=m.length===2?m[0]:void 0,b=AT.get(p.modelEntityType)??"event",x=p.dataInlineValue===void 0?void 0:$u(p.dataInlineValue);if(p.dataReference){let w=r.get(p.dataReference.$refText);w!==void 0&&(x=$u(w))}let E={id:p.name,kind:b,entity:p.entityIdentifier,name:m.length===2?m[1]:p.entityIdentifier,namespace:h,reset:p.$type==="EmResetFrame",lane:a(b,h),data:x,dataType:p.dataType};if(i.push(E),c.set(E.id,E),p.sourceFrames.length>0){let w=new Set(p.sourceFrames.map(S=>S.$refText));for(let S of i)w.has(S.id)&&l.push({source:S,target:E})}else if(u>0&&!E.reset){for(let w=u-1;w>=0;w--)if(i[w].lane!==E.lane){l.push({source:i[w],target:E});break}}});let f=p=>p.map(u=>u.entityIdentifier.$refText);return{type:"eventmodeling",title:e.title&&Gt(e.title)||t,accTitle:e.accTitle?Yt(e.accTitle).replace(/^\s+/g,""):void 0,accDescr:e.accDescr?Ht(e.accDescr).replace(/\n\s+/g,`
`):void 0,boxes:i,lanes:[...o.values()].sort((p,u)=>p.index-u.index),relations:l,notes:e.noteEntities.map(p=>({frame:p.sourceFrame.$refText,text:$u(p.dataBlockValue),dataType:p.dataType})),specifications:e.gwtEntities.map(p=>({frame:p.sourceFrame.$refText,given:f(p.givenStatements),when:f(p.whenStatements),then:f(p.thenStatements)})),entities:e.modelEntities.map(p=>p.name)}}var Du=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y;function _T(){let e=!1;return(t,n)=>{Du.lastIndex=n;let r=Du.exec(t);if(r===null)return-1;let o=Du.lastIndex;if(r[1]===void 0)return o;if(e)return-1;let s=t.indexOf("}",o);return e=s===-1,s+1||-1}}function _i(e="ACC_DESCR"){return{...tn,name:e,scanner:_T}}var vu={name:"EM_ID",pattern:/[_a-zA-Z][\w_]*/y},wi=e=>({name:e,pattern:e,longer:[vu]}),ko=e=>({name:e,pattern:e}),wT=["resetframe","readmodel","processor","timeframe","command","entity","event","jsobj","figma","given","json","salt","html","text","data","note","when","then","rmo","cmd","evt","pcr","uri"],Pu=[{...qt("eventmodeling"),longer:[vu]},...wT.map(wi),ko("->>"),wi("gwt"),wi("ui"),wi("md"),wi("tf"),ko("[["),ko("]]"),wi("rf"),ko("`"),ko("."),vu,{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},_i("EM_ACC_DESCR"),{...zt,name:"EM_ACC_TITLE"},{...Vt,name:"EM_TITLE"},{name:"EM_WS",pattern:/\s+/y,hidden:!0},{...Ut,name:"EM_YAML"},{...jt,name:"EM_DIRECTIVE"},{...Xt,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}],Qt=e=>Pu.findIndex(t=>t.name===e),Ac=e=>new Set(e.map(Qt)),Mt={keyword:0,arrow:Qt("->>"),open:Qt("[["),close:Qt("]]"),tick:Qt("`"),dot:Qt("."),id:Qt("EM_ID"),frameId:Qt("EM_FID"),inline:Qt("EM_DATA_INLINE"),block:Qt("EM_DATA_BLOCK"),accDescr:Qt("EM_ACC_DESCR"),accTitle:Qt("EM_ACC_TITLE"),title:Qt("EM_TITLE"),entity:Qt("entity"),data:Qt("data"),note:Qt("note"),gwt:Qt("gwt"),given:Qt("given"),when:Qt("when"),then:Qt("then")},rb=Ac(["tf","timeframe"]),RT=Ac(["rf","resetframe"]),Ou=Ac(["rmo","readmodel","ui","cmd","command","evt","event","pcr","processor"]),TT=Ac(["json","jsobj","figma","salt","uri","md","html","text"]);function sb(e){let t=new Bt(Wt(e,Pu,"eventmodeling"),Pu,"eventmodeling"),n={$type:"EventModel",modelEntities:[],frames:[],dataEntities:[],noteEntities:[],gwtEntities:[],$source:e},r=c=>t.kinds[t.i]===c,o=(c,l)=>c.has(t.kinds[t.i])?t.take():t.fail(l),s=()=>{let c=t.expect(Mt.id);for(;t.accept(Mt.dot);)c+="."+t.expect(Mt.id);return c},a=()=>{if(!t.accept(Mt.tick))return;let c=o(TT,"a data type");return t.expect(Mt.tick),c},i=()=>{let c=[];do o(Ou,"an entity type"),c.push({$type:"EmGwtStatement",entityIdentifier:{$refText:t.expect(Mt.id)}});while(Ou.has(t.kinds[t.i]));return c};for(t.expect(Mt.keyword);!r(-1);){let c=t.kinds[t.i];if(c===Mt.accDescr)n.accDescr=t.take();else if(c===Mt.accTitle)n.accTitle=t.take();else if(c===Mt.title)n.title=t.take();else if(c===Mt.entity)t.i++,n.modelEntities.push({$type:"EmModelEntity",name:s()});else if(rb.has(c)||RT.has(c)){let l={$type:rb.has(c)?"EmTimeFrame":"EmResetFrame",name:"",modelEntityType:"",entityIdentifier:"",sourceFrames:[],$offset:t.tokens.starts[t.i]};for(t.i++,l.name=t.expect(Mt.frameId),l.modelEntityType=o(Ou,"an entity type"),l.entityIdentifier=s();t.accept(Mt.arrow);)l.sourceFrames.push({$refText:t.expect(Mt.frameId)});if(t.accept(Mt.open)&&(l.dataReference={$refText:t.expect(Mt.id)},t.expect(Mt.close)),r(Mt.tick)||r(Mt.inline)){let f=a();f!==void 0&&(l.dataType=f),l.dataInlineValue=t.expect(Mt.inline)}n.frames.push(l)}else if(c===Mt.data){t.i++;let l={$type:"EmDataEntity",name:t.expect(Mt.id),dataBlockValue:""},f=a();f!==void 0&&(l.dataType=f),l.dataBlockValue=t.expect(Mt.block),n.dataEntities.push(l)}else if(c===Mt.note){t.i++;let l={$type:"EmNoteEntity",sourceFrame:{$refText:t.expect(Mt.frameId)},dataBlockValue:""},f=a();f!==void 0&&(l.dataType=f),l.dataBlockValue=t.expect(Mt.block),n.noteEntities.push(l)}else if(c===Mt.gwt){t.i++;let l={$type:"EmGwt",sourceFrame:{$refText:t.expect(Mt.frameId)},givenStatements:[],whenStatements:[],thenStatements:[]};t.expect(Mt.given),l.givenStatements=i(),t.accept(Mt.when)&&(l.whenStatements=i()),t.expect(Mt.then),l.thenStatements=i(),n.gwtEntities.push(l)}else t.fail("a frame, an entity, a data block, a note, or a specification")}return n}var lb=new Map([["command",0],["event",1],["readmodel",2],["processor",6]]),an=12,Dn=10,CT=96,ib=16,NT=80,xc=12,ob=8,MT=48,ab=80,db=8;function Bu(e,t){let n=[];for(let r of yt(e).split(`
`)){if(r.length<=t){n.push(r);continue}for(let o=0;o<r.length;o+=t)n.push(r.slice(o,o+t))}return n}function Sc(e,t,n,r,o){let s="";for(let a=0;a<e.length;a++)e[a]!==""&&(s+=`<tspan x="${d(t)}" y="${d(n+a*r)}">${je(e[a])}</tspan>`);return s===""?"":`<text${o} xml:space="preserve">${s}</text>`}function ub(e,t,n){return $t(n,r=>IT(e,t,n,r))}function IT(e,t,n,r){if(r)return $T(e,n);let o=n.fontSize??16,s=Math.round(o*.875),a=Math.round(o*.8125),i=Math.round(o*.75),c=Math.round(i*1.4),l=Math.round(a*1.5),f=n.measurer??et(n.fontFamily,n.fontFamilyMono),p=n.padding??8,u=(A,N,$)=>{let U=0;for(let j of A)U=Math.max(U,f.width(j,N,$));return U},m=new Map,h=0;for(let A of e.lanes){let N=We(A.label,!1,f,a,4e3,1);h=Math.max(h,N.width),m.set(A,{lane:A,label:N,right:-1/0,y:0,h:0})}h+=2*xc;let b=[],x=new Map,E;for(let A of e.boxes){let N=m.get(A.lane),$=We(A.name,!1,f,s,4e3,1),U=A.data?Bu(A.data,MT):[],j=Math.max(CT,Math.max($.width,u(U,i,4))+2*an),v=2*Dn+$.height+(U.length>0?6+U.length*c:0),k=0;if(E){let H=E.x+Math.max(E.w/2,E.w-NT);k=E.box.lane===A.lane?N.right+ib:Math.max(H,N.right+ib)}let F={box:A,name:$,data:U,x:k,y:0,w:j,h:v};N.right=k+j,N.h=Math.max(N.h,v),b.push(F),x.set(A,F),E=F}let w=0;for(let A of b)w=Math.max(w,A.x+A.w);let S=h+w+xc,O=We(e.title,!1,f,o,4e3,1),D=O.height>0?O.height+12:0,L=p,B=p+D,W=B,Y="";for(let A of m.values())A.y=W,A.h+=2*xc,Y+=`<g class="pele-cluster pele-em-lane" data-id="${Fe(A.lane.label)}"><rect x="${d(L)}" y="${d(W)}" width="${d(S)}" height="${d(A.h)}" fill="var(--_s)"${it}/>`+De(A.label,L+xc+A.label.width/2,W+A.h/2,` class="pele-cluster-label" font-size="${a}" font-weight="var(--_hw)" fill="var(--_m)"`)+"</g>",W+=A.h+ob;let I=m.size>0?W-ob:B,X="";for(let A of b){let N=m.get(A.box.lane);A.x+=L+h,A.y=N.y+(N.h-A.h)/2;let $=lb.get(A.box.kind),U=`x="${d(A.x)}" y="${d(A.y)}" width="${d(A.w)}" height="${d(A.h)}"`,j=$===void 0?`<rect ${U} fill="var(--_bg)" stroke="var(--_b)"${it}/>`:`<rect ${U} fill="var(--_bg)"${it}/><rect ${U} fill="${lt($)}" fill-opacity="0.22" stroke="${lt($)}"${it}/>`,v=A.y+Dn+A.name.height/2,k=De(A.name,A.x+A.w/2,v,` class="pele-label" font-size="${s}" font-weight="var(--_hw)"`)+Sc(A.data,A.x+an,A.y+Dn+A.name.height+6+c/2+i*.35,c,` class="pele-em-data" font-family="${oo}" font-size="${i}"`);X+=`<g class="pele-node pele-em-${A.box.kind}${A.box.reset?" pele-em-reset":""}" data-id="${Fe(A.box.id)}">${j}${k}</g>`}let ee="",K=mt("arrow_point");for(let A of e.relations){let N=x.get(A.source),$=x.get(A.target);if(!N||!$||N===$)continue;let U,j;if(N.box.lane===$.box.lane){let v=$.x>=N.x,k=v?N.x+N.w:N.x,F=v?$.x:$.x+$.w,H=N.y+N.h/2,G=$.y+$.h/2,se=F>=k?1:-1;U=`M${d(k)},${d(H)}L${d(F-se*K)},${d(G)}`,j=Et("arrow_point",F,G,se,0,"var(--_l)")}else{let v=$.y>N.y,k=Math.max(N.x,$.x),F=Math.min(N.x+N.w,$.x+$.w),H=Z=>Math.min(24,Z/4),G=F-k>=16?(k+F)/2:$.x>N.x?N.x+N.w-H(N.w):N.x+H(N.w),se=F-k>=16?G:$.x>N.x?$.x+H($.w):$.x+$.w-H($.w),q=v?N.y+N.h:N.y,P=v?$.y:$.y+$.h,V=v?1:-1,ne=P-V*K,ae=(q+ne)/2;U=G===se?`M${d(G)},${d(q)}V${d(ne)}`:`M${d(G)},${d(q)}C${d(G)},${d(ae)} ${d(se)},${d(ae)} ${d(se)},${d(ne)}`,j=Et("arrow_point",se,P,0,V,"var(--_l)")}ee+=`<g class="pele-edge" data-id="${Fe(A.source.id)}-${Fe(A.target.id)}"><path d="${U}" fill="none" stroke="var(--_l)"/>${j}</g>`}let z=new Map;for(let A of e.boxes)z.set(A.id,A.name);let C="",M=0,T=(A,N,$,U)=>{let j=We(`${N} · ${$}${z.has($)?" "+z.get($):""}`,!1,f,a,4e3,1),v=Math.max(j.width,u(U,a,0))+2*an,k=2*Dn+j.height+U.length*l,F=I+(C===""&&m.size===0?0:db);C+=`<g class="pele-em-${A}" data-id="${Fe($)}"><rect x="${d(L)}" y="${d(F)}" width="${d(v)}" height="${d(k)}" fill="var(--_bg)" stroke="var(--_b)"${it}/>`+De(j,L+an+j.width/2,F+Dn+j.height/2,` font-size="${a}" font-weight="var(--_hw)"`)+Sc(U,L+an,F+Dn+j.height+l/2+a*.35,l,` font-size="${a}"`)+"</g>",I=F+k,M=Math.max(M,v)};for(let A of e.notes)T("note","Note",A.frame,Bu(A.text,ab));for(let A of e.specifications){let N=[`Given  ${A.given.join(", ")}`];A.when.length>0&&N.push(`When  ${A.when.join(", ")}`),N.push(`Then  ${A.then.join(", ")}`),T("specification","Given / When / Then",A.frame,N.flatMap($=>Bu($,ab)))}let g=Math.max(m.size>0?S:0,M,O.width),_=Math.ceil(g+2*p),y=Math.ceil(I+p),R=De(O,_/2,p+O.height/2,' class="pele-title" font-weight="var(--_tw)"')+Y+ee+X+C;return{svg:Ze("eventmodeling",_,y,o,n,e,R),width:_,height:y,links:[]}}var cb=8,kT=120,LT=20;function $T(e,t){let n=t.fontSize??16,r=Math.round(n*.875),o=Math.round(n*.75),s=t.padding??8,a=t.measurer??et(t.fontFamily,t.fontFamilyMono),i=Math.max(160,(t.maxWidth??320)-2*s),c=new Map(e.boxes.map((z,C)=>[z,C])),l=new Map,f=new Set;for(let z of e.relations){let C=c.get(z.source),M=c.get(z.target);if(C===void 0||M===void 0||C===M)continue;if(Math.abs(C-M)<2){f.add(e.boxes[Math.max(C,M)]);continue}let T=l.get(z.target);T?(T[0]=Math.min(T[0],C),T[1]=Math.max(T[1],C)):l.set(z.target,[Math.min(C,M),Math.max(C,M)])}let p=new Map,u=[];for(let[z,[C,M]]of[...l].sort((T,g)=>T[1][0]-g[1][0])){let T=u.findIndex(g=>g<C);T<0&&(T=u.length),u[T]=M,p.set(z,T)}let m=24+cb*Math.max(0,u.length-1),h=Math.max(kT,i-m),b=h-2*an,x=We(e.title,!1,a,n,i,1),E=s+(x.height?x.height+12:0),w=s+x.height,S=Math.max(x.width,h+m),O="",D="",L="",B=new Map,W=(z,C,M=0)=>Ms(yt(z),a,C,b,M);e.boxes.forEach((z,C)=>{let M=f.has(z)?b-LT:b,T=Is(We(z.lane.label,!1,a,r,M,1),a,M),g=We(z.name,!1,a,r,b-36,1),_=z.data?W(z.data,o,4):void 0,y=Math.max(h,T.width+2*an,g.width+2*an+36,(_?.width??0)+2*an),R=T.height+12,A=2*Dn+g.height+(_?_.height+6:0),N=lb.get(z.kind),$=E+R,U=`x="${d(s)}" y="${d($)}" width="${d(y)}" height="${d(A)}"`;O+=`<g class="pele-cluster pele-em-lane" data-id="${Fe(z.lane.label)}">`+Ir(T,s+an,E,` 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="${Fe(z.id)}"><rect ${U} fill="var(--_bg)" stroke="var(--_b)"${it}/>`+(N===void 0?"":`<rect ${U} fill="${lt(N)}" fill-opacity="0.22" stroke="${lt(N)}"${it}/>`)+De(g,s+an+g.width/2,$+Dn+g.height/2,` class="pele-label" font-size="${r}" font-weight="var(--_hw)"`)+`<text class="pele-em-frame" x="${d(s+y-an)}" y="${d($+Dn+r)}" text-anchor="end" font-size="${o}" fill="var(--_m)">${je(z.id)}</text>`+(_?Sc(_.lines.map(j=>j.map(v=>v.text).join("")),s+an,$+Dn+g.height+6+_.lineHeight/2+o*.35,_.lineHeight,` class="pele-em-data" font-family="${oo}" font-size="${o}"`):"")+"</g></g>",B.set(z,{y:$,h:A,w:y,index:C,lane:T.width}),S=Math.max(S,y+m),w=$+A,E=w+28});for(let z of e.relations){let C=B.get(z.source),M=B.get(z.target);if(!C||!M||C===M)continue;let T=M.y>C.y,g=T?1:-1,_=T?C.y+C.h:C.y,y=T?M.y:M.y+M.h,R,A;if(Math.abs(C.index-M.index)===1){let N=s+Math.max(Math.min(C.w,M.w)/2,an+(T?M:C).lane+16);R=`M${d(N)},${d(_)}V${d(y-g*mt("arrow_point"))}`,A=Et("arrow_point",N,y,0,g,"var(--_l)")}else{let N=s+S-m+12+cb*(p.get(z.target)??0),$=C.y+C.h/2-5,U=M.y+M.h/2+5;R=`M${d(s+C.w)},${d($)}H${d(N)}V${d(U)}H${d(s+M.w+mt("arrow_point"))}`,A=Et("arrow_point",s+M.w,U,-1,0,"var(--_l)")}D+=`<g class="pele-edge" data-id="${Fe(z.source.id)}-${Fe(z.target.id)}"><path d="${R}" fill="none" stroke="var(--_l)"/>${A}</g>`}let Y=new Map(e.boxes.map(z=>[z.id,z.name])),I=(z,C,M,T)=>{let g=We(`${C} · ${M}${Y.has(M)?" "+Y.get(M):""}`,!1,a,r,b,1),_=W(T,r),y=Math.max(h,g.width+2*an,_.width+2*an),R=2*Dn+g.height+_.height;L+=`<g class="pele-em-${z}" data-id="${Fe(M)}"><rect x="${d(s)}" y="${d(E)}" width="${d(y)}" height="${d(R)}" fill="var(--_bg)" stroke="var(--_b)"${it}/>`+De(g,s+an+g.width/2,E+Dn+g.height/2,` font-size="${r}" font-weight="var(--_hw)"`)+Sc(_.lines.map(A=>A.map(N=>N.text).join("")),s+an,E+Dn+g.height+_.lineHeight/2+r*.35,_.lineHeight,` font-size="${r}"`)+"</g>",w=E+R,E=w+db,S=Math.max(S,y)};for(let z of e.notes)I("note","Note",z.frame,z.text);for(let z of e.specifications){let C=[`Given  ${z.given.join(", ")}`];z.when.length&&C.push(`When  ${z.when.join(", ")}`),C.push(`Then  ${z.then.join(", ")}`),I("specification","Given / When / Then",z.frame,C.join(`
`))}let X=Math.ceil(S+2*s),ee=Math.ceil(w+s),K=De(x,X/2,s+x.height/2,' class="pele-title" font-weight="var(--_tw)"')+D+O+L;return{svg:Ze("eventmodeling",X,ee,n,t,e,K),width:X,height:ee,links:[]}}var fb={type:"eventmodeling",keepComments:!0,parse:(e,t,n)=>nb(sb(e),n),render:ub};function Fu(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function pb(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function DT(e,t){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}function OT(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 vT(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 o="normal",s=n.length-1;n.startsWith("=")&&(o="thick"),n.startsWith("~")&&(o="invisible");let a=DT(".",n);return a&&(o="dotted",s=a),{type:r,stroke:o,length:s}}var _c=class{constructor(t={}){de(this,"type","flowchart");de(this,"direction");de(this,"nodes",new Map);de(this,"edges",[]);de(this,"subgraphs",[]);de(this,"classes",new Map);de(this,"tooltips",new Map);de(this,"defaultEdgeStyle");de(this,"defaultInterpolate");de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"subgraphLookup",new Map);de(this,"members",new Set);de(this,"edgeById",new Map);de(this,"pairCount",new Map);de(this,"subCount",0);de(this,"options");this.options=t}addVertex(t,n,r,o,s,a,i,c){if(!t||t.trim().length===0)return;let l;if(c!==void 0){let h=c.includes(`
`)?c+`
`:`{
`+c+`
}`,b;try{b=Vn(h)}catch(x){throw new ze(`Metadata of "${t}" is not valid YAML. ${x.message}`,"syntax",{type:"flowchart"})}l=b!==null&&typeof b=="object"&&!Array.isArray(b)?b:void 0}let f=this.subgraphLookup.get(t);if(f&&l){f.metadata={...f.metadata,...l};return}let p=this.edgeById.get(t);if(p){l?.animate!==void 0&&(p.animate=l.animate),l?.animation!==void 0&&(p.animation=l.animation),l?.curve!==void 0&&(p.interpolate=l.curve);return}let u=this.nodes.get(t);if(u===void 0&&(n===void 0&&r===void 0&&o!==void 0&&o!==null&&this.options.warn?.(`Style applied to unknown node "${t}". This may indicate a typo. The node will be created automatically.`),u={id:t,labelType:"text",styles:[],classes:[]},this.nodes.set(t,u)),n!==void 0?(u.labelType=n.type,u.text=pb(n.text.trim())):u.text===void 0&&(u.text=t),r!==void 0&&(u.type=r),o!=null)for(let h of o)u.styles.push(h);if(s!=null)for(let h of s)u.classes.push(h);if(a!==void 0&&(u.dir=a),u.props===void 0?u.props=i??{}:i!==void 0&&Object.assign(u.props,i),l===void 0)return;if(l.shape){let h=String(l.shape);if(h!==h.toLowerCase()||h.includes("_"))throw new ze(`No such shape: ${h}. Shape names should be lowercase.`,"semantic",{type:"flowchart"});if(!Aa(h))throw new ze(`No such shape: ${h}.`,"semantic",{type:"flowchart"});u.type=h}let m=typeof l.label=="string"?l.label:void 0;l.label&&(u.text=String(l.label),u.labelType=Fu(l.labelType)),l.icon&&(u.icon=String(l.icon),!m?.trim()&&u.text===t&&(u.text="")),l.form&&(u.form=String(l.form)),l.pos&&(u.pos=String(l.pos)),l.img&&(u.img=String(l.img),!m?.trim()&&u.text===t&&(u.text="")),l.constraint&&(u.constraint=String(l.constraint)),l.w&&(u.assetWidth=Number(l.w)),l.h&&(u.assetHeight=Number(l.h))}addSingleLink(t,n,r,o){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=pb(a.text.trim()),s.labelType=Fu(a.type)),r!==void 0&&(s.type=r.type,s.stroke=r.stroke,s.length=r.length>10?10:r.length);let i=t+"\0"+n,c=this.pairCount.get(i)??0;o&&!this.edgeById.has(o)?(s.id=o,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 ze(`Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${l}.`,"limit",{type:"flowchart"});this.edges.push(s),this.pairCount.set(i,c+1),this.edgeById.has(s.id)||this.edgeById.set(s.id,s)}addLink(t,n,r){let o=typeof r?.id=="string"?r.id.replace("@",""):void 0,s=t[t.length-1],a=n[0];for(let i of t)for(let c of n)this.addSingleLink(i,c,r,i===s&&c===a?o: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 o=this.edgeAt(r);o.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 ze(`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 o of t.split(",")){let s=this.classes.get(o);s===void 0&&(s={id:o,styles:[],textStyles:[]},this.classes.set(o,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 o=n.trim();for(let s of t.split(",")){let a=this.nodes.get(s);a!==void 0&&(a.link=o?Fn(o):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,`
`)}addSubGraph(t,n,r){let o=t?.text.trim(),s=r?.text??"";t!==void 0&&t===r&&/\s/.test(s)&&(o=void 0);let a=new Set,i=[],c;for(let u of n)if(typeof u=="string")u.trim()!==""&&!a.has(u)&&(a.add(u),i.push(u));else if(Array.isArray(u))for(let m of u)m.trim()!==""&&!a.has(m)&&(a.add(m),i.push(m));else c=u.value;c??=this.options.inheritDir?this.direction??this.options.direction:void 0,o??="subGraph"+this.subCount,s=s||"",this.subCount++;let l={id:o,nodes:i,title:s.trim(),classes:[],dir:c,labelType:Fu(r?.type)},f=this.members;l.nodes=i.filter(u=>!f.has(u)&&u!==o);for(let u of l.nodes)f.add(u);let p=this.subgraphLookup.get(o);if(p)for(let u of l.nodes)p.nodes.push(u);else this.subgraphs.push(l);return this.subgraphLookup.set(o,p??l),o}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 o of n)for(let s of o.nodes)r.add(s);return{nodes:t.nodes.filter(o=>!r.has(o))}}destructLink(t,n){let r=vT(t);if(!n)return r;let o=OT(n);if(o.stroke!==r.stroke)return{type:"INVALID",stroke:"INVALID"};if(o.type==="arrow_open")o.type=r.type;else{if(o.type!==r.type)return{type:"INVALID",stroke:"INVALID"};o.type="double_"+o.type}return o.type==="double_arrow"&&(o.type="double_arrow_point"),o.length=r.length,o}subgraph(t){return this.subgraphLookup.get(t)}};var Wu=["$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 bb=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")bb[e.charCodeAt(0)]=1;var PT=/accTitle\s*:\s*/y,BT=/accDescr\s*:\s*/y,FT=/accDescr\s*\{\s*/y,WT=/call\s+/y,UT=/click\s+/y,GT=/(?:\r?\n)*\s*\n/y,YT=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,HT=/\s*[<>^]/y,KT=/\s*v\b/y,zT=[/.*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],Uu=/[\n\r\u2028\u2029]/g,hb=/\s*[xo<]?--+[-xo>]\s*/y,VT=/\s*[xo<]?--\s*/y,mb=/\s*[xo<]?==+[=xo>]\s*/y,jT=/\s*[xo<]?==\s*/y,Gu=/\s*[xo<]?-?\.+-[xo>]?\s*/y,XT=/\s*[xo<]?-\.\s*/y,gb=/\s*~~~+\s*/y,qT=/(?:\r?\n)+/y,QT=/[^\S\n\r]+/y,ZT=/\(\s*\)/y,JT=/\n\s*/g;function yb(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=!0,l=e.indexOf("direction"),f=e.indexOf("@"),p=-1,u=0,m=0,h=-1,b=-1,x=-1,E=(M,T,g)=>{n.push(M),r.push(e.slice(T,g)),o.push(T),i=g},w=M=>{s.push(a),a=M},S=()=>{s.length>0&&(a=s.pop())},O=(M,T)=>(M.lastIndex=T,M.test(e)?M.lastIndex:-1),D=M=>e.startsWith(M,i)&&!Qe(e.charCodeAt(i+M.length)),L=M=>{let T=M;if(M>=b&&M<=x)T=x;else if(He(e.charCodeAt(M))){for(;T<t&&He(e.charCodeAt(T));)T++;b=M,x=T}let g=e.charCodeAt(T);return g===120||g===111||g===60?e.charCodeAt(T+1):g},B=M=>{let T=M;if(M>=b&&M<=x)T=x;else if(He(e.charCodeAt(M))){for(;T<t&&He(e.charCodeAt(T));)T++;b=M,x=T}return e.charCodeAt(T)===126},W=()=>{e.charCodeAt(i+1)===96?(w(2),i+=2):(w(1),i++)},Y=()=>{if(!B(i))return!1;let M=O(gb,i);return M<0?!1:(E(40,i,M),!0)},I=M=>{let T=e.charCodeAt(i+1);return M===40?(T===45?(w(8),E(45,i,i+2)):T===91?(w(7),E(47,i,i+2)):T===40&&e.charCodeAt(i+2)===40?(w(7),E(55,i,i+3)):(w(7),E(69,i,i+1)),!0):M===91?(T===91?(w(7),E(49,i,i+2)):T===40?(w(7),E(53,i,i+2)):T===47?(w(9),E(58,i,i+2)):T===92?(w(9),E(59,i,i+2)):(w(7),E(71,i,i+1)),!0):M===124?(w(7),E(67,i,i+1),!0):M===123?(w(7),E(73,i,i+1),!0):!1},X=M=>{c&&(c=!1,w(6)),E(20,i,i+M)},ee=()=>{let M=i;for(;M<t;){let T=e.charCodeAt(M);if(T<128&&bb[T]===1)M++;else if(T===45&&M+1<t){let g=e.charCodeAt(M+1);if(g===62||g===45||g===46)break;M++}else break}return M===i?!1:(E(64,i,M),!0)},K=M=>{let T=L(i),g;if(T===45){if((g=O(hb,i))>=0)return E(40,i,g),!0;if((g=O(VT,i))>=0)return w(10),E(41,i,g),!0;if((g=O(Gu,i))>=0)return E(40,i,g),!0;if((g=O(XT,i))>=0)return w(12),E(41,i,g),!0}else if(T===61){if((g=O(mb,i))>=0)return E(40,i,g),!0;if((g=O(jT,i))>=0)return w(11),E(41,i,g),!0}else if(T===46&&(g=O(Gu,i))>=0)return E(40,i,g),!0;return M!==45&&M!==61&&M!==46&&Y()},z=M=>{let T;switch(M){case 97:if(e.startsWith("acc",i)){if((T=O(PT,i))>=0)return w(3),E(2,i,T),!0;if((T=O(BT,i))>=0)return w(4),E(4,i,T),!0;if((T=O(FT,i))>=0)return w(5),i=T,!0}break;case 64:if(e.charCodeAt(i+1)===123)return w(16),n.push(7),r.push(""),o.push(i),i+=2,!0;break;case 99:if((T=O(WT,i))>=0)return w(14),i=T,!0;if(D("classDef"))return E(16,i,i+8),!0;if(D("class"))return E(17,i,i+5),!0;if((T=O(UT,i))>=0)return w(13),i=T,!0;break;case 34:return W(),!0;case 115:if(D("style"))return E(12,i,i+5),!0;if(D("swimlane-beta"))return X(13),!0;if(D("subgraph"))return E(21,i,i+8),!0;break;case 100:if(D("default"))return E(13,i,i+7),!0;break;case 108:if(D("linkStyle"))return E(14,i,i+9),!0;break;case 105:if(D("interpolate"))return E(15,i,i+11),!0;break;case 104:if(e.startsWith("href",i)&&He(e.charCodeAt(i+4)))return E(18,i,i+5),!0;break;case 102:if(D("flowchart-elk"))return X(13),!0;if(D("flowchart"))return X(9),!0;break;case 103:if(D("graph"))return X(5),!0;break;case 101:if(D("end")){for(T=i+3;T<t&&He(e.charCodeAt(T));)T++;return E(22,i,T),!0}break;case 95:if(D("_self"))return E(23,i,i+5),!0;if(D("_blank"))return E(23,i,i+6),!0;if(D("_parent"))return E(23,i,i+7),!0;if(D("_top"))return E(23,i,i+4),!0;break}if(l!==-1&&i>=u&&(l<i&&(l=e.indexOf("direction",i)),l!==-1&&(p<i&&(Uu.lastIndex=i,p=Uu.test(e)?Uu.lastIndex-1:t),l<p))){for(let g=0;g<5;g++)if((T=O(zT[g],i))>=0)return E(26+g,i,T),!0;u=p}if(f!==-1&&M!==34&&!He(M)){if(i>=m){f<i&&(f=e.indexOf("@",i));let g=i;for(;g<t;){let _=e.charCodeAt(g);if(_===34||He(_))break;g++}if(m=g,h=-1,f!==-1&&f<g)for(let _=Math.min(g,t-1)-1;_>=f;_--){if(e.charCodeAt(_)!==64)continue;let y=e.charCodeAt(_+1);if(y!==123&&y!==34){h=_;break}}}if(h>i)return E(31,i,h+1),!0}if(M>=48&&M<=57){let g=i+1;for(;g<t;){let _=e.charCodeAt(g);if(_<48||_>57)break;g++}return E(32,i,g),!0}switch(M){case 35:return E(33,i,i+1),!0;case 58:return e.charCodeAt(i+1)===58&&e.charCodeAt(i+2)===58?E(34,i,i+3):E(35,i,i+1),!0;case 38:return E(36,i,i+1),!0;case 59:return E(37,i,i+1),!0;case 44:return E(38,i,i+1),!0;case 42:return E(39,i,i+1),!0;case 120:case 111:return K(M)||ee();case 60:return K(M)||E(60,i,i+1),!0;case 45:return K(M)||ee()||E(65,i,i+1),!0;case 61:return K(M);case 46:return K(M)||ee();case 126:return Y();case 40:return I(M);case 91:return e.charCodeAt(i+1)===124?(E(50,i,i+2),!0):I(M);case 124:case 123:return I(M);case 62:return w(7),E(51,i,i+1),!0;case 94:return E(61,i,i+1),!0;case 92:return e.charCodeAt(i+1)===124?(E(62,i,i+2),!0):ee();case 118:return Qe(e.charCodeAt(i+1))?ee():(E(63,i,i+1),!0)}return He(M)?K(M)?!0:(T=O(qT,i))>=0?(E(74,i,T),!0):(T=O(QT,i))>=0?(E(75,i,T),!0):!1:M<128?ee():ci(M)?(E(66,i,i+1),!0):!1},C=(M,T,g,_)=>{if(M===34)return W(),!0;let y=L(i);if(y===g||y===_){let A=O(T,i);if(A>=0)return S(),E(40,i,A),!0}if(M===g&&(g!==45||e.charCodeAt(i+1)===45))return!1;let R=i+1;for(;R<t;){let A=e.charCodeAt(R);if(A===34)break;if(A===g){if(g!==45||e.charCodeAt(R+1)===45)break}else if(A===120||A===111||A===60||A===_||He(A)){let N=L(R);if((N===g||N===_)&&O(T,R)>=0)break}R++}return E(42,i,R),!0};e:for(;;){if(i>=t){let g=-1;switch(a){case 0:g=76;break;case 3:g=3;break;case 4:g=5;break;case 5:g=6;break;case 13:g=19;break;case 14:g=8;break;case 15:g=9;break}g!==-1&&E(g,t,t);break}let M=e.charCodeAt(i),T=!0;switch(a){case 0:T=z(M);break;case 1:if(M===34)e.charCodeAt(i+1)===96?(w(2),i+=2):(S(),i++);else{let g=e.indexOf('"',i);E(11,i,g===-1?t:g)}break;case 2:if(M===96)e.charCodeAt(i+1)===34?(S(),i+=2):T=!1;else if(M===34)W();else{let g=i+1;for(;g<t;){let _=e.charCodeAt(g);if(_===96||_===34)break;g++}E(10,i,g)}break;case 3:case 4:{let g=e.indexOf(`
`,i);g===-1&&(g=t);let _=a===3?3:5;S(),E(_,i,g);break}case 5:if(M===125)S(),i++;else{let g=e.indexOf("}",i);g===-1&&(g=t),E(6,i,g)}break;case 6:{let g;M===34?W():(g=O(GT,i))>=0?(S(),E(24,i,g)):(g=O(YT,i))>=0||(g=O(HT,i))>=0||(g=O(KT,i))>=0?(S(),E(25,i,g)):T=Y()||I(M);break}case 7:{let g=e.charCodeAt(i+1);switch(M){case 34:W();break;case 40:case 91:case 123:I(M);break;case 93:S(),g===41?E(46,i,i+2):g===93?E(48,i,i+2):E(70,i,i+1);break;case 41:S(),g===93?E(52,i,i+2):g===41&&e.charCodeAt(i+2)===41?E(54,i,i+3):E(68,i,i+1);break;case 124:S(),E(67,i,i+1);break;case 125:S(),E(72,i,i+1);break;default:{if((M===126||He(M))&&Y())break;let _=i+1;for(;_<t;){let y=e.charCodeAt(_);if(y===91||y===93||y===40||y===41||y===123||y===125||y===124||y===34)break;_++}E(44,i,_)}}break}case 8:{let g=e.charCodeAt(i+1);if(M===34)W();else{if((M===126||He(M))&&Y())break;if((M===45||M===47||M===41)&&g===41)S(),E(43,i,i+2);else if(M===40||M===91||M===123)I(M);else if(M===41||M===93||M===125)T=!1;else{let _=i+1;for(;_<t;){let y=e.charCodeAt(_);if(y===34||y===40||y===41||y===91||y===93||y===123||y===125||(y===45||y===47)&&e.charCodeAt(_+1)===41||(y===126||He(y))&&B(_)&&O(gb,_)>=0)break;_++}E(44,i,_)}}break}case 9:{let g=e.charCodeAt(i+1);if(M===34){W();break}if((M===126||He(M))&&Y())break;switch(M){case 40:g===45||g===91||g===40&&e.charCodeAt(i+2)===40?I(M):g===93?(S(),E(56,i,i+2)):I(M);break;case 91:case 123:I(M);break;case 92:g===93?(S(),E(56,i,i+2)):E(44,i,i+1);break;case 47:g===93?(S(),E(57,i,i+2)):E(44,i,i+1);break;case 93:case 41:g===93?(S(),E(56,i,i+2)):T=!1;break;case 125:T=!1;break;default:{if((M===63||M===61)&&g===93){S(),E(56,i,i+2);break}let _=i+1;for(;_<t;){let y=e.charCodeAt(_);if(y===92||y===91||y===93||y===40||y===41||y===123||y===125||y===47)break;_++}E(44,i,_)}}break}case 10:T=C(M,hb,45,-1);break;case 11:T=C(M,mb,61,-1);break;case 12:T=C(M,Gu,46,45);break;case 13:if(M===34)W();else if(He(M))S(),i++;else{let g=i+1;for(;g<t&&!He(e.charCodeAt(g));)g++;E(19,i,g)}break;case 14:if(M===40){let g=O(ZT,i);S(),g>=0?i=g:(w(15),i++)}else{let g=e.indexOf("(",i);g===-1&&(g=t),E(8,i,g)}break;case 15:if(M===41)S(),i++;else{let g=e.indexOf(")",i);g===-1&&(g=t),E(9,i,g)}break;case 16:if(M===34)w(17),E(7,i,i+1);else if(M===125)S(),i++;else if(M===94)T=!1;else{let g=i+1;for(;g<t;){let _=e.charCodeAt(g);if(_===125||_===94||_===34)break;g++}E(7,i,g)}break;case 17:if(M===34)S(),E(7,i,i+1);else{let g=e.indexOf('"',i);g===-1&&(g=t),n.push(7),r.push(e.slice(i,g).replace(JT,"<br/>")),o.push(i),i=g}break}if(!T)return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o};continue e}return n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var wc=new Uint8Array(77);for(let e of[32,64,63,65,13,38,35,36,33,39,66])wc[e]=1;var Yu=new Uint8Array(77);for(let e of[32,66,64,25,63,65,38,35,36,33,39])Yu[e]=1;var Hu=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])Hu[e]=1;var Ku=new Uint8Array(77);for(let e of[32,64,35,75,33,12])Ku[e]=1;var Eb="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",Lo=[],e2=/}\s*\n/g;function xb(e,t){let n=e.includes("}")?e.replace(e2,`}
`):e,{types:r,texts:o,starts:s}=yb(n),a=0,i,c=C=>{let M=r[a];throw M===1?st("flowchart",n,s[a],"",!0):st("flowchart",n,s[a],`Expecting ${C}, got '${Wu[M]}'`)},l=(C,M="")=>(r[a]!==C&&c(`'${Wu[C]}'${M?", "+M:""}`),o[a++]),f=()=>{let C=r[a];C!==74&&C!==37&&C!==76&&c("'SEMI', 'NEWLINE', 'EOF'"),a++},p=()=>{wc[r[a]]===0&&c("'NODE_STRING'");let C=o[a++];for(;wc[r[a]]===1;)C+=o[a++];return C},u=()=>{Yu[r[a]]===0&&c("'NODE_STRING'");let C=o[a++];for(;Yu[r[a]]===1;)C+=o[a++];return C},m=()=>{let C=r[a],M;if(C===11)M="string";else if(C===10)M="markdown";else if(C===44||C===60||C===51||C===66)M="text";else return c(`${Eb}, 'TAGEND', 'STR', 'MD_STR'`);let T=o[a++];for(;;){let g=r[a];if(g!==44&&g!==60&&g!==51&&g!==66)break;T+=o[a++]}return{text:T,type:M}},h=C=>{l(C,Eb)},b=()=>{let C=r[a],M;if(C===11)M="string";else if(C===10)M="markdown";else if(C===42||C===66)M="text";else return c("'EDGE_TEXT', 'STR', 'MD_STR'");let T=o[a++];for(;r[a]===42||r[a]===66;)T+=o[a++];return{text:T,type:M}},x=()=>{let C=r[a],M;if(C===11)M="text";else if(C===10)M="markdown";else if(Hu[C]===1)M="text";else return c("'NODE_STRING', 'STR', 'MD_STR'");let T=o[a++];for(;Hu[r[a]]===1;)T+=o[a++];return{text:T,type:M}},E=()=>{let C=o[a++];for(;r[a]===7;)C+=o[a++];return C},w=()=>{let C=p(),M;switch(r[a]){case 71:a++,M=m(),h(70),t.addVertex(C,M,"square");break;case 55:a++,M=m(),h(54),t.addVertex(C,M,"doublecircle");break;case 69:a++,r[a]===69?(a++,M=m(),h(68),l(68),t.addVertex(C,M,"circle")):(M=m(),h(68),t.addVertex(C,M,"round"));break;case 45:a++,M=m(),h(43),t.addVertex(C,M,"ellipse");break;case 47:a++,M=m(),h(46),t.addVertex(C,M,"stadium");break;case 49:a++,M=m(),h(48),t.addVertex(C,M,"subroutine");break;case 50:{a++;let T=l(64);l(35);let g=l(64);l(67),M=m(),h(70),t.addVertex(C,M,"rect",void 0,void 0,void 0,{[T]:g});break}case 53:a++,M=m(),h(52),t.addVertex(C,M,"cylinder");break;case 73:a++,r[a]===73?(a++,M=m(),h(72),l(72),t.addVertex(C,M,"hexagon")):(M=m(),h(72),t.addVertex(C,M,"diamond"));break;case 51:a++,M=m(),h(70),t.addVertex(C,M,"odd");break;case 58:a++,M=m(),r[a]===57?(a++,t.addVertex(C,M,"lean_right")):(h(56),t.addVertex(C,M,"trapezoid"));break;case 59:a++,M=m(),r[a]===56?(a++,t.addVertex(C,M,"lean_left")):(h(57),t.addVertex(C,M,"inv_trapezoid"));break;default:t.addVertex(C)}return C},S=()=>{let C=w();return r[a]===34&&(a++,t.setClass(C,p())),C},O=()=>{let C=[S()];for(i=void 0;;){let M=r[a]===7?E():void 0;if(r[a]!==75)return i=M,C;do a++;while(r[a]===75);if(r[a]!==36)return M!==void 0&&c("'AMP'"),C;a++,r[a]!==75&&c("'SPACE'");do a++;while(r[a]===75);let T=S();M!==void 0&&t.addVertex(C[C.length-1],void 0,void 0,void 0,void 0,void 0,void 0,M),C.push(T)}},D=()=>{let C;if(r[a]===31&&(C=o[a++]),r[a]===40){let M=t.destructLink(o[a++]);return C!==void 0&&(M.id=C),r[a]===67&&(a++,M.text=m(),h(67),r[a]===75&&a++),M}if(r[a]===41){let M=o[a++],T=b(),g=l(40,"'EDGE_TEXT'"),_=t.destructLink(g,M);return _.text=T,C!==void 0&&(_.id=C),_}return c("'LINK', 'START_LINK'")},L=C=>{let M=O();i!==void 0&&t.addVertex(M[M.length-1],void 0,void 0,void 0,void 0,void 0,void 0,i);let T=M;for(;;){let g=r[a];if(g!==40&&g!==41&&g!==31)return T;let _=D(),y=O();i!==void 0&&t.addVertex(y[y.length-1],void 0,void 0,void 0,void 0,void 0,void 0,i),t.addLink(M,y,_),C&&(T=y.concat(T)),M=y}},B=()=>{Ku[r[a]]===0&&c("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let C=o[a++];for(;Ku[r[a]]===1;)C+=o[a++];return C},W=()=>{let C=[B()];for(;r[a]===38;)a++,C.push(B());return C},Y=()=>{a++,l(75);let C;if(r[a]===13)C=[o[a++]];else for(C=[l(32,"'DEFAULT'")];r[a]===38;)a++,C.push(l(32));if(l(75),r[a]!==15){t.updateLink(C,W());return}a++,l(75);let M=u();if(r[a]===75){a++;let T=W();t.updateLinkInterpolate(C,M),t.updateLink(C,T)}else t.updateLinkInterpolate(C,M)},I=(C,M)=>{if(r[a]!==75){t.setLink(C,M);return}if(a++,r[a]===23){t.setLink(C,M,o[a++]);return}let T=l(11,"'LINK_TARGET'");r[a]===75?(a++,t.setLink(C,M,l(23))):t.setLink(C,M),t.setTooltip(C,T)},X=()=>{let C=o[a++];switch(r[a]){case 8:{let M=o[a++],T=r[a]===9,g=T?o[a++]:void 0,_;r[a]===75&&(a++,_=l(11)),T?t.setClickEvent(C,M,g):t.setClickEvent(C,M),_!==void 0&&t.setTooltip(C,_);return}case 18:a++,I(C,l(11));return;case 11:I(C,o[a++]);return;default:{let M=u();if(r[a]===75){a++;let T=l(11);t.setClickEvent(C,M),t.setTooltip(C,T)}else t.setClickEvent(C,M)}}},ee=()=>{a++;let C=r[a];if(C===74||C===37||C===76)return a++,{id:void 0,title:void 0,list:[],collect:!1};l(75,"'SEMI', 'NEWLINE', 'EOF'");let M=x(),T=M;return r[a]===71&&(a++,T=m(),h(70)),C=r[a],C!==74&&C!==37&&C!==76&&c("'SEMI', 'NEWLINE', 'EOF', 'SQS'"),a++,{id:M,title:T,list:[],collect:!1}},K=C=>{let M=r[a];switch(M){case 12:{a++,l(75);let T=p();return l(75),t.addVertex(T,void 0,void 0,W()),f(),Lo}case 14:return Y(),f(),Lo;case 16:{a++,l(75);let T=p();return l(75),t.addClass(T,W()),f(),Lo}case 17:{a++,l(75);let T=p();return l(75),t.setClass(T,p()),f(),Lo}case 19:return X(),f(),Lo;case 26:case 27:case 28:case 29:case 30:return a++,{stmt:"dir",value:t2[M-26]};case 2:{a++;let T=l(3).trim();return t.setAccTitle(T),T}case 4:{a++;let T=l(5).trim();return t.setAccDescription(T),T}case 6:{let T=o[a++].trim();return t.setAccDescription(T),T}default:{wc[M]===0&&c(Ab);let T=L(C);return f(),T}}},z=()=>{let C=[],M=[],T=!1;for(;;){let g=r[a];if(g===0)break;if(g===22){let _=C.pop();if(_===void 0)break;a++;let y=t.addSubGraph(_.id,M,_.title);M=_.list,T=_.collect,T&&M.push(y)}else if(g===37||g===74||g===75||g===76)T&&M.push(o[a]),a++;else if(g===21){let _=ee();_.list=M,_.collect=T,C.push(_),M=[],T=!0}else{let _=K(T);T&&(!Array.isArray(_)||_.length>0)&&M.push(_)}}C.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 C=l(25,"'NODIR'"),M=r[a];if(M===75){do a++;while(r[a]===75);M=r[a],M!==74&&c("'NEWLINE', 'SPACE'")}else M!==37&&M!==74&&c("'SEMI', 'NEWLINE', 'SPACE'");a++,t.setDirection(C)}z(),r[a]!==0&&c(Ab)}var t2=["TB","BT","RL","LR","TD"],Ab="'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";function n2(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 r2(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 Sb(e,t){let n=[],r=[],o=e.subgraphs,s=S=>{let O=[];for(let D of S){let L=e.classes.get(D);if(L!==void 0){for(let B of L.styles)O.push(B.trim());for(let B of L.textStyles)O.push(B.trim())}}return O},a=new Map;for(let S of o)for(let O of S.nodes)e.subgraph(O)&&a.set(O,S.id);let i=new Map,c=new Map;for(let S of o){let O=a.get(S.id);if(O===void 0)continue;let D=c.get(O);D?D.push(S.id):c.set(O,[S.id])}let l=0;for(let S of o){if(a.has(S.id))continue;let O=[S.id];for(;O.length>0;){let D=O.pop();if(i.has(D))continue;i.set(D,l++);let L=c.get(D);if(L)for(let B=L.length-1;B>=0;B--)O.push(L[B])}}let f=S=>e.subgraph(S)?.metadata?.view==="collapsed",p=!1;for(let S of o)S.metadata?.view==="collapsed"&&(p=!0);let u=new Map,m=S=>{let O=[],D=new Set,L=S;for(;L!==void 0&&!u.has(L)&&!D.has(L);)D.add(L),O.push(L),L=a.get(L);let B=L!==void 0?u.get(L):void 0;for(let W=O.length-1;W>=0;W--)B===void 0&&f(O[W])&&(B=O[W]),u.set(O[W],B);return B},h=new Set,b=new Map;for(let S of p?o:[]){let O=m(S.id);if(O!==void 0){S.id!==O&&(h.add(S.id),b.set(S.id,O));for(let D of S.nodes)D!==O&&(h.add(D),b.set(D,O))}}let x=new Map,E=new Set;for(let S=o.length-1;S>=0;S--){let O=o[S];if(!h.has(O.id)){O.nodes.length>0&&E.add(O.id);for(let D of O.nodes)x.set(D,O.id)}}let w=new Map;for(let S=o.length-1;S>=0;S--){let O=o[S];if(h.has(O.id))continue;let D=O.metadata?.view==="collapsed",L={id:O.id,label:O.title,labelType:O.labelType,parentId:x.get(O.id),cssStyles:[],cssCompiledStyles:s(O.classes),cssClasses:O.classes.join(" "),shape:D?"collapsedGroup":"rect",dir:O.dir,isGroup:!D,colorIndex:i.get(O.id)};D||(L.metadata=O.metadata),n.push(L),w.set(O.id,L)}for(let S of e.nodes.values()){if(h.has(S.id))continue;let O=w.get(S.id);if(O){O.cssStyles=S.styles,O.cssCompiledStyles=s(S.classes),O.cssClasses=S.classes.join(" ");continue}let D=E.has(S.id),L={id:S.id,label:S.text,labelType:S.labelType,parentId:x.get(S.id),cssStyles:S.styles,cssCompiledStyles:s(["default","node",...S.classes]),cssClasses:"default "+S.classes.join(" "),dir:S.dir,link:S.link,linkTarget:S.linkTarget,tooltip:e.tooltips.get(S.id),icon:S.icon,pos:S.pos,img:S.img,assetWidth:S.assetWidth,assetHeight:S.assetHeight,constraint:S.constraint,isGroup:D,shape:D?"rect":n2(S)};n.push(L)}return e.edges.forEach((S,O)=>{let D=b.get(S.start)??S.start,L=b.get(S.end)??S.end;if(D===L&&(b.has(S.start)||b.has(S.end)))return;let[B,W]=r2(S.type),Y=[...e.defaultEdgeStyle??[]];S.style&&Y.push(...S.style);let I=S.stroke==="invisible"||S.type==="arrow_open";r.push({id:S.id||`L_${D}_${L}_${O}`,isUserDefinedId:S.isUserDefinedId,start:D,end:L,type:S.type??"normal",label:S.text,labelType:S.labelType,thickness:S.stroke,pattern:S.stroke,minlen:S.length,classes:S.stroke==="invisible"?"":"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:I?"none":B,arrowTypeEnd:I?"none":W,cssCompiledStyles:s(S.classes),style:Y,animate:S.animate,animation:S.animation,curve:S.interpolate||e.defaultInterpolate||t})}),{nodes:n,edges:r}}var s2=40,i2=16,o2=48,_b=20,zu=26,Vu=' fill="var(--_s)" stroke="var(--_b)"',a2=' stroke="var(--_b)"';function ju(e,t,n){let r=e[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function $o(e,t){return e!==void 0&&e>0&&e<=4e3?e:t}function Rc(e,t,n,r){let o=s=>gn(n,a=>c2(e,t,n,r,s,a));return Tn(e.direction)?$t(n,o):o(!1)}function c2(e,t,n,r,o,s){let a=s?12:_b,i=r?t[r.type]:void 0,c=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:t.flowchart??{},l=Sb(e,typeof c.curve=="string"?c.curve:void 0);r?.prepare(l);let f=n.fontSize??16,p=Math.round(f*.875),u=n.measurer??et(n.fontFamily),m=Math.min(ju(c,"wrappingWidth",200),r&&s?100:1/0),h=n.padding??8,b=n.icons,x=new Map,E=[],w=[];l.nodes.forEach((k,F)=>x.set(k.id,F));for(let k of l.nodes){let F=St(k.cssStyles.length>0?k.cssCompiledStyles.concat(k.cssStyles):k.cssCompiledStyles),H=(F.bold?1:0)|(F.italic?2:0),G=k.labelType==="markdown",se=F.fontSize??f,q,P;if(k.isGroup){let V=We(k.label,G,u,se,r&&s?Math.max(80,Tt(n)/2):4e3,H);q={node:k,style:F,label:V,shape:"group",w:0,h:0,dy:0,loops:0},P=Pt(0,0),P.isGroup=!0,P.dir=k.dir?rn(k.dir):void 0,P.padX=a,P.padTop=V.height>0?V.height+16:_b,P.padBottom=a,P.minW=V.width+2*a-12}else{let V=xa(k.shape),ne=k.img||k.icon||nm(V)?k.label:void 0,ae=We(ne,G,u,se,m,H),Z,Q,ie=0;if(k.img||k.icon){let me=k.img?80:48,re=$o(k.assetWidth,me),te=$o(k.assetHeight,me);Z=Math.max(re,ae.width+8),Q=te+(ae.height>0?ae.height+6:0),ie=k.pos==="t"?-te/2:te/2,ae.height===0&&(ie=0)}else{let me=Hr(V,ae.width,ae.height);Z=me.w,Q=me.h,ie=me.dy}q={node:k,style:F,label:ae,shape:V,w:Z,h:Q,dy:ie,loops:0},P=Pt(Z,Q)}P.seq=E.length,E.push(q),w.push(P)}l.nodes.forEach((k,F)=>{w[F].parent=k.parentId!==void 0?x.get(k.parentId)??-1:-1});let S=o?"TB":rn(e.direction),O=k=>{let F;for(let H=w[k].parent,G=0;H>=0&&F===void 0&&G<1e4;H=w[H].parent,G++)F=w[H].dir;return F??=S,F==="LR"||F==="RL"};E.forEach((k,F)=>{k.node.isGroup?w[F].span=1/0:!k.node.img&&!k.node.icon&&(w[F].span=tm(k.shape,k.w,k.h,O(F)))});let D=[],L=[],B=[];for(let k of l.edges){let F=x.get(k.start),H=x.get(k.end);if(F===void 0||H===void 0)continue;let G=We(k.label,k.labelType==="markdown",u,p,m);F===H&&(E[F].loops++,O(F)?w[F].h+=2*(zu+(G.height>0?G.height+8:0)):w[F].w+=2*(zu+(G.width>0?G.width+12:0))),B.push(k),L.push(G),D.push({src:F,dst:H,minlen:k.minlen??1,labelW:G.width>0?G.width+12:0,labelH:G.height>0?G.height+4:0,route:[],labelX:0,labelY:0})}let W={nodeSep:ju(c,"nodeSpacing",s2)*(s?.5:1),edgeSep:i2,rankSep:ju(c,"rankSpacing",o2)*(s?.75:1),portSep:20,tracks:typeof c.curve=="string"&&/^step/.test(c.curve),straight:c.curve==="linear",headRoom:mt("arrow_point")},Y=r?r.layout(w,D,S,W,s):Rn(w,D,S,W),I=hn(e.title,u,f,s?Tt(n):4e3),X=I.height>0?I.height+12:0,ee=Math.max(Y.width,I.width),K=h+(ee-Y.width)/2,z=h+X;Gr(w,D,K,z);let C=Math.ceil(ee+2*h),M=Math.ceil(Y.height+X+2*h),T=[],g=new Map,_=!1;for(let k of w)k.isGroup&&(_=!0);if(_)for(let k of D)qn(g,k.route);let y="",R="",A="";for(let k=0;k<E.length;k++){let F=E[k],H=w[k],G=F.node,se=H.x,q=H.y,P=Rt(G.cssClasses.replace(/^default\s?/,"")),V=Fe(G.id);if(H.isGroup&&r?.drawGroup&&H.parent<0){y+=r.drawGroup(H,F.label,F.style,P,V,S,b);continue}if(H.isGroup){let re=Yr(H,F.label.width,g,a),te=q-H.h/2+8+F.label.height/2,he=` class="pele-cluster-label" fill="var(--_m)"${F.style.text}`,oe=ka(H,F.label.width,re,g);oe&&(R+=La(F.label,re,te,he,V,w,k,b)),y+=`<g class="pele-cluster${P}" data-id="${V}"><rect x="${d(se-H.w/2)}" y="${d(q-H.h/2)}" width="${d(H.w)}" height="${d(H.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${pt(F.style.shape)}/>`+(oe?"":De(F.label,re,te,he,b))+"</g>";continue}let ne=F.w,ae=F.h,Z;if(G.img){let re=$o(G.assetWidth,80),te=$o(G.assetHeight,80),he=F.label.height>0?G.pos==="t"?ae/2-te:-ae/2:-te/2,oe=xh(Fn(G.img),n);Z=oe===void 0?"":`<image href="${je(oe)}" x="${d(-re/2)}" y="${d(he)}" width="${d(re)}" height="${d(te)}" preserveAspectRatio="${G.constraint==="on"?"xMidYMid meet":"none"}"/>`}else if(G.icon){let re=$o(G.assetHeight,48),te=F.label.height>0?G.pos==="t"?ae/2-re:-ae/2:-re/2,he=G.shape==="icon"?"":G.shape==="iconCircle"?`<circle cy="${d(te+re/2)}" r="${d(re/2)}"${Vu}${F.style.shape}/>`:`<rect x="${d(-re/2)}" y="${d(te)}" width="${d(re)}" height="${d(re)}" rx="${G.shape==="iconRounded"?8:0}"${Vu}${F.style.shape}/>`,oe=re*.6;Z=he+`<svg class="pele-icon" data-icon="${Fe(G.icon)}" x="${d(-oe/2)}" y="${d(te+(re-oe)/2)}" width="${d(oe)}" height="${d(oe)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${b?.(G.icon)??""}</svg>`}else Z=Qn(F.shape,ne,ae,Vu+F.style.shape,a2+F.style.line);let Q=De(F.label,0,F.dy,` class="pele-label"${F.style.text}`,b);if(/ internal-link(?: |$)/.test(P+" ")&&G.label&&n.links!==!1){let re=yt(G.label),te=Cr(Xn(re),n)!==void 0,he=je(re);Q=`<a class="internal-link"${te?` href="${he}"${Nr(n)}`:""} data-href="${he}">${Q}</a>`,T.push({id:G.id,href:re,internal:!0})}let me=Z+Q;G.tooltip&&(me=`<title>${Fe(G.tooltip)}</title>`+me),G.link&&(me=Wn(me,G.link,G.id,T,n,G.linkTarget?` target="${je(G.linkTarget)}"`:"")),A+=`<g class="pele-node pele-shape-${F.shape}${P}" data-id="${V}" transform="translate(${d(se)},${d(q)})">${me}</g>`}let N=Da();for(let k=0;k<D.length;k++){let F=D[k];F.src===F.dst||B[k].thickness==="invisible"||F.route.length<6||(N.add(F.src,Un(F.route,0,w[F.src]),B[k].arrowTypeStart),N.add(F.dst,Un(F.route,F.route.length-3,w[F.dst]),B[k].arrowTypeEnd))}let $="",U="",j=new Map;for(let k=0;k<D.length;k++){let F=D[k],H=B[k],G=L[k],se=H.style.length>0||H.cssCompiledStyles.length>0?St(H.cssCompiledStyles.concat(H.style)):void 0;if(H.thickness!=="invisible"){let q=H.arrowTypeStart,P=H.arrowTypeEnd,V;if(F.src===F.dst){let Q=E[F.src],ie=j.get(F.src)??0;j.set(F.src,ie+1),V=Oa(w[F.src],Q.w,Q.h,ie,O(F.src),zu,mt(P),F)}else{let Q=F.route.slice(),ie=N.of(F.src,Un(Q,0,w[F.src])),me=N.of(F.dst,Un(Q,Q.length-3,w[F.dst]));Ts(Q,0,E[F.src],w[F.src]),Ts(Q,Q.length-3,E[F.dst],w[F.dst]),V=xn(Q,H.curve,mt(q),mt(P),ie,me)}let ne=se?.stroke&&H.thickness!=="invisible"?je(se.stroke):"var(--_l)",ae="";H.thickness==="thick"?ae+=' stroke-width="2.5"':H.thickness==="dotted"&&(ae+=' stroke-dasharray="3 4"');let Z=Rt(H.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));$+=`<g class="pele-edge${Z}" data-id="${Fe(H.id)}"${se?.line??""}><path d="${V.d}"${ae}/>`+Et(q,V.sx,V.sy,V.sdx,V.sdy,ne)+Et(P,V.ex,V.ey,V.edx,V.edy,ne)+"</g>"}if(G.width>0){let q=F.labelX,P=F.labelY;U+=sn(H.id,G,q,P,se?.text??"",b)}}return{svg:Ze(r?.type??"flowchart",C,M,f,n,e,De(I,C/2,h+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+(y?`<g class="pele-clusters">${y}</g>`:"")+($?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${$}</g>`:"")+(R?`<g class="pele-cluster-titles">${R}</g>`:"")+(U?`<g class="pele-edge-labels" font-size="${p}">${U}</g>`:"")+`<g class="pele-nodes">${A}</g>`),width:C,height:M,links:T}}var Tc={type:"flowchart",math:!0,parse(e,t,n,r,o){let s=t.flowchart??{},a=new _c({inheritDir:s.inheritDir===!0,maxEdges:o.maxEdges});return n&&(a.title=n),xb(e,a),a},render:Rc};var vs=["January","February","March","April","May","June","July","August","September","October","November","December"],kr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Ri(e){return!Number.isNaN(e.getTime())}function On(e,t){let n=String(e);return n.length>=t?n:"0".repeat(t-n.length)+n}function Lb(e){let t=["th","st","nd","rd"],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])}function Xu(e){let t=-Math.round(e.getTimezoneOffset()/15)*15;return t===0?0:t}function wb(e){let t=Xu(e),n=Math.abs(t);return(t>=0?"+":"-")+On(Math.floor(n/60),2)+":"+On(n%60,2)}function $b(e){return e.getDay()||7}function br(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function l2(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t.getDate()}function Rb(e,t){let n=new Date(e);return n.setDate(1),t(n),n.setDate(Math.min(e.getDate(),l2(n))),n}function Nc(e,t,n){switch(n){case"M":return Rb(e,r=>r.setMonth(e.getMonth()+t));case"y":return Rb(e,r=>r.setFullYear(e.getFullYear()+t));case"d":return br(e,Math.round(t));case"w":return br(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 Db(e){return br(e,4-$b(e))}function Tb(e){let t=Db(e),n=new Date(t.getFullYear(),0,1),r=$b(n),o=br(n,4-r+(r>4?7:0)),s=(Xu(o)-Xu(t))*6e4,a=(t.getTime()-o.getTime()-s)/6048e5;return(a<0?Math.ceil(a)||0:Math.floor(a))+1}var d2=/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,u2=/\[([^\]]+)]|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,f2="YYYY-MM-DDTHH:mm:ssZ";function qu(e,t){if(!Ri(e))return"Invalid Date";let n=t||f2;if(n==="YYYY-MM-DD")return Qu(e);let r=!1,o=n.replace(d2,a=>{switch(a){case"Q":return String(Math.ceil((e.getMonth()+1)/3));case"Do":return"["+Lb(e.getDate())+"]";case"GGGG":return String(Db(e).getFullYear());case"W":return String(Tb(e));case"WW":return On(Tb(e),2);case"k":return String(e.getHours()||24);case"kk":return On(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 o.replace(u2,(a,i)=>{if(i)return i;switch(a){case"YY":return String(e.getFullYear()).slice(-2);case"YYYY":return On(e.getFullYear(),4);case"M":return String(e.getMonth()+1);case"MM":return On(e.getMonth()+1,2);case"MMM":return vs[e.getMonth()].slice(0,3);case"MMMM":return vs[e.getMonth()];case"D":return String(e.getDate());case"DD":return On(e.getDate(),2);case"d":return String(e.getDay());case"dd":return kr[e.getDay()].slice(0,2);case"ddd":return kr[e.getDay()].slice(0,3);case"dddd":return kr[e.getDay()];case"H":return String(s);case"HH":return On(s,2);case"h":return String(s%12||12);case"hh":return On(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 On(e.getMinutes(),2);case"s":return String(e.getSeconds());case"ss":return On(e.getSeconds(),2);case"SSS":return On(e.getMilliseconds(),3);case"Z":return wb(e);default:return wb(e).replace(":","")}})}function Qu(e){let t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate();return(t>=1e3&&t<=9999?t:On(t,4))+(n<10?"-0":"-")+n+(r<10?"-0":"-")+r}var p2=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,h2=/\[[^\]]+]/g,Cb=/\d/,Do=/\d\d/,m2=/\d{3}/,g2=/\d{4}/,Jn=/\d\d?/,b2=/[+-]?\d+/,Nb=/[+-]\d\d:?(\d\d)?|Z/,Oo=/\d*[^-_:/,()\s\d]+/;function En(e){return(t,n)=>(t[e]=+n,!0)}var Mb=(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 Ib(e){return(t,n)=>{let r=e.indexOf(n)+1;return r<1?!1:(t.month=r%12||r,!0)}}var y2=new Map([["A",{re:Oo,read:(e,t)=>(e.afternoon=t==="PM",!0)}],["a",{re:Oo,read:(e,t)=>(e.afternoon=t==="pm",!0)}],["Q",{re:Cb,read:(e,t)=>(e.month=(+t-1)*3+1,!0)}],["S",{re:Cb,read:(e,t)=>(e.milliseconds=+t*100,!0)}],["SS",{re:Do,read:(e,t)=>(e.milliseconds=+t*10,!0)}],["SSS",{re:m2,read:(e,t)=>(e.milliseconds=+t,!0)}],["s",{re:Jn,read:En("seconds")}],["ss",{re:Jn,read:En("seconds")}],["m",{re:Jn,read:En("minutes")}],["mm",{re:Jn,read:En("minutes")}],["H",{re:Jn,read:En("hours")}],["h",{re:Jn,read:En("hours")}],["HH",{re:Jn,read:En("hours")}],["hh",{re:Jn,read:En("hours")}],["D",{re:Jn,read:En("day")}],["DD",{re:Do,read:En("day")}],["Do",{re:Oo,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++)Lb(r)===t&&(e.day=r);return!0}}],["w",{re:Jn,read:En("week")}],["ww",{re:Do,read:En("week")}],["M",{re:Jn,read:En("month")}],["MM",{re:Do,read:En("month")}],["MMM",{re:Oo,read:Ib(vs.map(e=>e.slice(0,3)))}],["MMMM",{re:Oo,read:Ib(vs)}],["Y",{re:b2,read:En("year")}],["YY",{re:Do,read:(e,t)=>(e.year=+t+(+t>68?1900:2e3),!0)}],["YYYY",{re:g2,read:En("year")}],["Z",{re:Nb,read:Mb}],["ZZ",{re:Nb,read:Mb}]]),kb,Cc=null;function E2(e){if(e===kb)return Cc;if(kb=e,Cc=null,/[Ll]/.test(e.replace(h2,"")))return null;let t=e.match(p2);return t?(Cc=t.map(n=>y2.get(n)??n.replace(/^\[|\]$/g,"")),Cc):null}function A2(e,t,n){if(t==="x"||t==="X")return new Date((t==="X"?1e3:1)*Number(e));let r=E2(t);if(!r)return;let o={},s=e,a=0;for(let h of r){if(typeof h=="string"){a+=h.length;continue}let b=h.re.exec(s.slice(a));if(!b||!h.read(o,b[0]))return;s=s.replace(b[0],"")}o.afternoon!==void 0&&o.hours!==void 0&&(o.afternoon?o.hours<12&&(o.hours+=12):o.hours===12&&(o.hours=0));let i=o.dayGiven||o.day?o.day:!o.year&&!o.month?n.getDate():1,c=o.year||n.getFullYear(),l=0;o.year&&!o.month||(l=o.month>0?o.month-1:n.getMonth());let f=o.hours||0,p=o.minutes||0,u=o.seconds||0,m=o.milliseconds||0;if(o.offset!==void 0)return new Date(Date.UTC(c,l,i,f,p,u,m+o.offset*6e4));if(!o.week)return new Date(c,l,i,f,p,u,m)}function Ob(e,t,n){let r=A2(e,t,n);return r&&Ri(r)&&qu(r,t)===e?r:void 0}var x2=/^[YMDHhmsSZXx\-/.:, T]*$/,S2=/^\s*(active|done|crit|milestone|vert)\s*$/,_2=/^after\s+([\d\w- ]+)/,w2=/^until\s+([\d\w- ]+)/,R2=/^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/,T2=/[\s,]+/,C2=/^\d+$/,N2=new Set(kr.map(e=>e.toLowerCase())),M2=4e8,I2=400,k2=200,L2=400;function Zu(e){let t=e===void 0?NaN:+e;return Number.isFinite(t)?t:Date.now()}function $2(e){let t=R2.exec(e.trim());return t?[Number.parseFloat(t[1]),t[2]]:[NaN,"ms"]}function vb(e,t){let n=new Set(e);for(let r of t.toLowerCase().split(T2))r!==""&&n.add(r);return[...n]}var Mc=class{constructor(t={}){de(this,"type","gantt");de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"dateFormat","");de(this,"axisFormat","");de(this,"tickInterval");de(this,"todayMarker","");de(this,"includes",[]);de(this,"excludes",[]);de(this,"inclusiveEndDates",!1);de(this,"topAxis",!1);de(this,"displayMode","");de(this,"weekday");de(this,"weekend","saturday");de(this,"sections",[]);de(this,"links",new Map);de(this,"tasks",[]);de(this,"byId",new Map);de(this,"currentSection","");de(this,"taskCount",0);de(this,"lastOrder",0);de(this,"lastTaskId");de(this,"options");de(this,"now",0);de(this,"work",0);de(this,"includeSet",new Set);de(this,"excludeSet",new Set);de(this,"excludedDays",[]);de(this,"datedTokens",!1);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=vb(this.includes,t)}setExcludes(t){this.excludes=vb(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,`
`)}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,n){let r=(n.startsWith(":")?n.slice(1):n).split(","),o={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=S2.exec(r[0]))!==null;)o[s[1]]=!0,r.shift();if(r.length===0)throw new ze(`Task "${t.trim()}" needs a duration or an end date.`,"semantic",{type:"gantt"});if(r.length>3)throw new ze(`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?o.id=r[0]:(this.taskCount++,o.id="task"+this.taskCount),r.length>1&&(o.raw.start=r[r.length-2]),o.raw.end=r[r.length-1],o.vert||(o.order=this.lastOrder++),this.tasks.push(o),this.lastTaskId=o.id,this.byId.set(o.id,o)}setLink(t,n){let r=Fn(n);for(let o of t.split(","))this.byId.has(o)&&this.links.set(o,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=Zu(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=kr.map((s,a)=>{let i=a||7;return r&&(i===n||i===n+1)||this.excludeSet.has(s.toLowerCase())}),this.datedTokens=this.includes.length>0||!x2.test(this.dateFormat.trim());for(let s of this.excludes)s!=="weekends"&&!N2.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 o=this.compileTasks();for(let s=0;!o&&s<10;s++)o=this.compileTasks();return this.tasks}isInvalidDate(t){let n=this.excludedDays[t.getDay()];if(!this.datedTokens)return n;let r=this.dateFormat.trim(),o=Qu(t),s=o;this.spend(k2),r!=="YYYY-MM-DD"&&(this.spend(L2+r.length*8),s=qu(t,r));let a=i=>i.has(o)||s!==void 0&&i.has(s);return a(this.includeSet)?!1:n||a(this.excludeSet)}spend(t){if(this.work+=t,this.work>M2)throw new ze("The gantt chart takes too much work to schedule.","limit",{type:"gantt"})}parse(t,n){return this.spend((n.length+1)*(t.length+1)),Ob(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=[],o;for(let s of n.split(" ")){if(s==="")continue;let a=this.byId.get(s);a?r.push(a):(o??=[]).push(s)}if(o){let s=o;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")&&C2.test(n))return this.checked(new Date(Number(n)),n);let o=_2.exec(n);if(o!==null){let i=this.references("after",o[1]),c;for(let l of i)(!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(!Ri(a)||a.getFullYear()<-1e4||a.getFullYear()>1e4)throw new ze("Invalid date:"+n,"semantic",{type:"gantt"});return a}checked(t,n){if(!Ri(t))throw new ze("Invalid date:"+n,"semantic",{type:"gantt"});return t}getEndDate(t,n){let r=n.trim(),o=w2.exec(r);if(o!==null){let f=this.references("until",o[1]),p;for(let u of f)(!p||u.startTime<p.startTime)&&(p=u);return p?p.startTime:this.today()}let s=this.dateFormat.trim(),a=this.parse(r,s);if(a)return this.inclusiveEndDates?br(a,1):a;let[i,c]=$2(r);if(Number.isNaN(i))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=Nc(t,i,c);return Ri(l)?l:new Date(t)}checkTaskDates(t){if(this.excludes.length===0||t.manualEndTime)return;let n=br(t.startTime,1),r=new Date(t.endTime),o=+br(r,1e4),s=!1,a=null;for(;+n<=+r;){if(this.spend(I2),s||(a=+r),s=this.isInvalidDate(n),s&&(r.setDate(r.getDate()+1),+r>o))throw new ze("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 Pb=["$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 D2=/accTitle\s*:\s*/iy,O2=/accDescr\s*:\s*/iy,v2=/accDescr\s*\{\s*/iy,P2=/href\s+"/iy,B2=/call\s+/iy,F2=/click\s+/iy,W2=/\(\s*\)/y,Ju=/weekday\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/iy,U2=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],ef=/weekend\s+(?:(friday)|saturday)\b/iy,G2=/\d\d\d\d-\d\d-\d\d\b/y,Y2=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[^\n]+/iy,32]]],[101,[[/excludes\s[^#\n;]+/iy,20]]],[115,[[/section\s[^\n]+/iy,34]]]]);function Bb(e){let t=e.length,n=[],r=[],o=[],s=0,a=0,i=(p,u,m)=>{n.push(p),r.push(e.slice(u,m)),o.push(u),a=m},c=p=>(p.lastIndex=a,p.test(e)?p.lastIndex:-1),l=(p,u)=>{let m=e.indexOf(p,u);return m===-1?t:m},f=p=>{let u;switch(p|32){case 97:if((u=c(D2))>=0)return s=1,i(3,a,u),!0;if((u=c(O2))>=0)return s=2,i(5,a,u),!0;if((u=c(v2))>=0)return s=3,a=u,!0;break;case 104:if((u=c(P2))>=0)return s=4,a=u,!0;break;case 99:if((u=c(B2))>=0)return s=5,a=u,!0;if((u=c(F2))>=0)return s=7,a=u,!0;break;case 119:{Ju.lastIndex=a;let h=Ju.exec(e);if(h)return i(22+U2.indexOf(h[1].toLowerCase()),a,Ju.lastIndex),!0;if(ef.lastIndex=a,h=ef.exec(e),h)return i(h[1]!==void 0?29:30,a,ef.lastIndex),!0;break}}let m=Y2.get(p|32);if(m){for(let[h,b]of m)if((u=c(h))>=0)return i(b,a,u),!0}return!1};for(;;){if(a>=t){let u=38;switch(s){case 1:u=4;break;case 2:u=6;break;case 3:u=7;break;case 4:u=9;break;case 5:u=10;break;case 6:u=11;break;case 7:u=12;break}i(u,t,t);break}let p=e.charCodeAt(a);switch(s){case 0:{let u=e.charCodeAt(a+1);if(p===37)if(u!==37){let m=l(`
`,a+1);for(;e.charCodeAt(m)===10;)m++;a=m}else{if(e.charCodeAt(a+2)===123)return i(2,a,a+3),i(1,a,a),{types:n,texts:r,starts:o};a=l(`
`,a+2)}else if(p!==125&&u===37)a=l(`
`,a+2);else if(p===10){let m=a+1;for(;e.charCodeAt(m)===10;)m++;i(8,a,m)}else if(He(p))for(a++;a<t&&He(e.charCodeAt(a));)a++;else{if(f(p))break;if(p>=48&&p<=57&&c(G2)>=0)i(31,a,a+10);else if(p!==58){let m=a+1;for(;m<t;){let h=e.charCodeAt(m);if(h===58||h===10)break;m++}i(35,a,m)}else{let m=a+1;for(;m<t;){let h=e.charCodeAt(m);if(h===35||h===10||h===59)break;m++}i(m>a+1?36:37,a,m)}}break}case 1:case 2:{let u=s===1?4:6;s=0,i(u,a,l(`
`,a));break}case 3:p===125?(s=0,a++):i(7,a,l("}",a));break;case 4:p===34?(s=0,a++):i(9,a,l('"',a));break;case 5:if(p===40){let u=c(W2);u>=0?(s=0,a=u):(s=6,a++)}else i(10,a,l("(",a));break;case 6:p===41?(s=0,a++):i(11,a,l(")",a));break;case 7:if(He(p))s=0,a++;else{let u=a+1;for(;u<t&&!He(e.charCodeAt(u));)u++;i(12,a,u)}break}}return n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var H2=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Fb="'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'",Ic=new Uint8Array(39);for(let e=22;e<=30;e++)Ic[e]=1;for(let e of[38,8,14,15,16,17,18,20,19,21,32,3,5,7,34,35,12])Ic[e]=1;function Wb(e,t){let{types:n,texts:r,starts:o}=Bb(e),s=0,a=c=>{let l=n[s];throw st("gantt",e,o[s],`Expecting ${c}, got '${l===0?"1":Pb[l]}'`)},i=(c="")=>{Ic[n[s]]!==1&&a(Fb+c)};for(n[s]!==13&&a("'gantt'"),s++;;){let c=n[s],l=r[s];switch(Ic[c]!==1&&a(Fb),s++,c){case 38:if(n[s]===0)return;i();break;case 8:break;case 14:i(),t.setDateFormat(l.slice(11));break;case 15:i(),t.enableInclusiveEndDates();break;case 16:i(),t.TopAxis();break;case 17:i(),t.setAxisFormat(l.slice(11));break;case 18:i(),t.setTickInterval(l.slice(13));break;case 20:i(),t.setExcludes(l.slice(9));break;case 19:i(),t.setIncludes(l.slice(9));break;case 21:i(),t.setTodayMarker(l.slice(12));break;case 29:i(),t.setWeekend("friday");break;case 30:i(),t.setWeekend("saturday");break;case 32:i(),t.setDiagramTitle(l.slice(6));break;case 3:{n[s]!==4&&a("'acc_title_value'");let f=r[s++];i(),t.setAccTitle(f.trim());break}case 5:{n[s]!==6&&a("'acc_descr_value'");let f=r[s++];i(),t.setAccDescription(f.trim());break}case 7:i(),t.setAccDescription(l.trim());break;case 34:i(),t.addSection(l.slice(8));break;case 35:{n[s]!==36&&a("'taskData'");let f=r[s++];i(),t.addTask(l,f);break}case 12:{let f,p=null,u;n[s]===10?(f=r[s++],n[s]===11&&(p=r[s++]),n[s]===9?(u=r[s++],i()):i(p===null?", 'callbackargs', 'href'":", 'href'")):n[s]===9?(u=r[s++],n[s]===10?(f=r[s++],n[s]===11?(p=r[s++],i()):i(", 'callbackargs'")):i(", 'callbackname'")):a("'callbackname', 'href'"),f!==void 0&&t.setClickEvent(l,f,p),u!==void 0&&t.setLink(l,u);break}default:i(),t.setWeekday(H2[c-22])}}}var Lr=1e3,$r=60*Lr,Ps=60*$r,Bs=24*Ps,Bo=7*Bs,nf=30*Bs,$c=365*Bs;function kc(e){e.setHours(0,0,0,0)}function Oc(e){return{floor(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),kc(t)},offset:(t,n)=>t.setDate(t.getDate()+n*7),cycle:1/0,ms:Bo}}var vo={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*Lr),field:e=>e.getUTCSeconds(),cycle:60,ms:Lr},minute:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*Lr),offset:(e,t)=>e.setTime(+e+t*$r),field:e=>e.getMinutes(),cycle:60,ms:$r},hour:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*Lr-e.getMinutes()*$r),offset:(e,t)=>e.setTime(+e+t*Ps),field:e=>e.getHours(),cycle:24,ms:Ps},day:{floor:kc,offset:(e,t)=>e.setDate(e.getDate()+t),field:e=>e.getDate()-1,cycle:31,ms:Bs},month:{floor(e){e.setDate(1),kc(e)},offset:(e,t)=>e.setMonth(e.getMonth()+t),field:e=>e.getMonth(),cycle:12,ms:nf},year:{floor(e){e.setMonth(0,1),kc(e)},offset:(e,t)=>e.setFullYear(e.getFullYear()+t),cycle:1/0,ms:$c}};function Dc(e,t,n){return Math.floor((+t-+e-(t.getTimezoneOffset()-e.getTimezoneOffset())*$r)/n)}function K2(e,t){return(e%t+t)%t}function Lc(e,t,n){let r=e==="week"?Oc(n):vo[e];if(t<=1)return r;if(e==="millisecond")return{...r,floor:a=>a.setTime(Math.floor(+a/t)*t),offset:(a,i)=>a.setTime(+a+i*t)};if(e==="year")return{...r,floor(a){a.setFullYear(Math.floor(a.getFullYear()/t)*t),r.floor(a)},offset:(a,i)=>a.setFullYear(a.getFullYear()+i*t)};if(e==="week"){let a=new Date(0);return r.floor(a),{...r,floor(i){r.floor(i),r.offset(i,-K2(Dc(a,i,Bo),t))},offset:(i,c)=>r.offset(i,c*t)}}let o=r.field,s=a=>o(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,i){for(let c=0;c<i&&Number.isFinite(+a);c++)do r.offset(a,1);while(Number.isFinite(+a)&&!s(a))}}}function Yb(e,t,n,r){let o=new Date(t-1);e.floor(o),e.offset(o,1),e.floor(o);let s=[],a=-1/0;for(;+o<=n&&+o>a;){if(s.length>=r)return;a=+o,s.push(a),e.offset(o,1),e.floor(o)}return s}function Ub(e,t,n){let r=(t-e)/Math.max(0,n),o=Math.floor(Math.log10(r)),s=r/Math.pow(10,o),a=s>=Math.sqrt(50)?10:s>=Math.sqrt(10)?5:s>=Math.SQRT2?2:1;return Math.pow(10,o)*a}var Ti=[["second",1,Lr],["second",5,5*Lr],["second",15,15*Lr],["second",30,30*Lr],["minute",1,$r],["minute",5,5*$r],["minute",15,15*$r],["minute",30,30*$r],["hour",1,Ps],["hour",3,3*Ps],["hour",6,6*Ps],["hour",12,12*Ps],["day",1,Bs],["day",2,2*Bs],["week",1,Bo],["month",1,nf],["month",3,3*nf],["year",1,$c]];function Hb(e,t,n){let r=(t-e)/n,o=0;for(;o<Ti.length&&Ti[o][2]<=r;)o++;let s;if(o===Ti.length)s=Lc("year",Math.max(1,Ub(e/$c,t/$c,n)),0);else if(o===0)s=Lc("millisecond",Math.max(Ub(e,t,n),1),0);else{let[a,i]=Ti[r/Ti[o-1][2]<Ti[o][2]/r?o-1:o];s=Lc(a,i,0)}return Yb(s,e,t,4*n+8)??[]}var z2=/^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/,V2=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Kb(e,t,n,r,o){let s=z2.exec(e);if(!s)return;let a=parseInt(s[1],10),i=s[2],c=Lc(i,a,Math.max(0,V2.indexOf(t)));if(!((r-n)/(Math.min(a,c.cycle)*c.ms)>o))return Yb(c,n,r,o)}function cn(e,t,n){let r=e<0?"-":"",o=String(r?-e:e);return r+(o.length<n?t.repeat(n-o.length)+o:o)}function Zr(e,t){let n=new Date(+e);return t.floor(n),n}function Gb(e,t){let n=Oc(t),r=Zr(e,vo.year);return Dc(Zr(new Date(+r-1),n),Zr(e,n),Bo)}function tf(e){let t=Oc(4),n=e.getDay(),r=Zr(n>=4||n===0?e:new Date(+e-1),t);return n>=4||n===0||(t.offset(r,1),t.floor(r)),r}var j2=new Map([["-",""],["_"," "],["0","0"]]);function Po(e,t){let n="",r=0,o=e.length;for(let s=0;s<o;s++){if(e.charCodeAt(s)!==37)continue;n+=e.slice(r,s);let a=e.charAt(++s),i=j2.get(a);i!==void 0?a=e.charAt(++s):i=a==="e"?" ":"0",n+=X2(a,t,i),r=s+1}return n+e.slice(r)}function X2(e,t,n){switch(e){case"a":return kr[t.getDay()].slice(0,3);case"A":return kr[t.getDay()];case"b":return vs[t.getMonth()].slice(0,3);case"B":return vs[t.getMonth()];case"c":return Po("%x, %X",t);case"d":case"e":return cn(t.getDate(),n,2);case"f":return cn(t.getMilliseconds(),n,3)+"000";case"g":return cn(tf(t).getFullYear()%100,n,2);case"G":return cn(tf(t).getFullYear()%1e4,n,4);case"H":return cn(t.getHours(),n,2);case"I":return cn(t.getHours()%12||12,n,2);case"j":return cn(1+Dc(Zr(t,vo.year),Zr(t,vo.day),Bs),n,3);case"L":return cn(t.getMilliseconds(),n,3);case"m":return cn(t.getMonth()+1,n,2);case"M":return cn(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 cn(t.getSeconds(),n,2);case"u":return String(t.getDay()||7);case"U":return cn(Gb(t,0),n,2);case"V":{let r=tf(t),o=Zr(r,vo.year),s=Zr(o,Oc(4));return cn(Dc(s,r,Bo)+(o.getDay()===4?1:0),n,2)}case"w":return String(t.getDay());case"W":return cn(Gb(t,1),n,2);case"x":return Po("%-m/%-d/%Y",t);case"X":return Po("%-I:%M:%S %p",t);case"y":return cn(t.getFullYear()%100,n,2);case"Y":return cn(t.getFullYear()%1e4,n,4);case"Z":{let r=t.getTimezoneOffset(),o=Math.abs(r);return(r>0?"-":"+")+cn(Math.floor(o/60),"0",2)+cn(o%60,"0",2)}case"%":return"%";default:return e}}var q2=800,Q2=240,Ci=8,Z2=/<br\s*\/?>/gi;function yr(e,t,n,r){let o=e.gantt?.[t];return typeof o=="number"&&Number.isFinite(o)?Math.min(r,Math.max(n,o)):void 0}function rf(e,t){let n=e.gantt?.[t];return typeof n=="string"?n:void 0}function J2(e,t){return e.gantt?.[t]===!0}function zb(e,t,n){let r=We(e.replace(Z2," "),!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 vc(e){return Number.isFinite(+e.startTime)&&Number.isFinite(+e.endTime)}function eC(e,t,n){let r=e.filter(vc).sort((a,i)=>+a.startTime-+i.startTime||a.order-i.order),o=[];for(let a of r){let i=+a.startTime,c=0;for(;c<o.length&&i<o[c];)c++;o[c]=+a.endTime,n.set(a,t+c)}let s=o.length;for(let a of e)n.has(a)||n.set(a,t+s++);return Math.max(s,1)}function Vb(e,t,n){let r=n.fontSize??16,o=n.measurer??et(n.fontFamily),s=n.padding??8,a=Zu(n.now),i=yr(t,"fontSize",4,72)??Math.round(r*.8125),c=yr(t,"sectionFontSize",4,72)??i,l=Math.round(r*.75),f=yr(t,"barHeight",4,400)??Math.round(i*1.85),p=yr(t,"barGap",0,400)??Math.round(f/4),u=f+p,m=Math.round(yr(t,"numberSectionStyles",1,1e3)??4),h=e.displayMode==="compact",b=e.topAxis||J2(t,"topAxis"),x=e.getTasks(a),E=x.filter(Ae=>!Ae.vert),w=x.filter(Ae=>Ae.vert&&vc(Ae)),S=new Map;for(let Ae of E)S.has(Ae.section)||S.set(Ae.section,S.size);let O=new Map,D=[];if(h){let Ae=new Map;for(let xe of E){let Oe=Ae.get(xe.section);Oe?Oe.push(xe):Ae.set(xe.section,[xe])}for(let[xe,Oe]of Ae){let ve=eC(Oe,D.length,O);for(let Ge=0;Ge<ve;Ge++)D.push(xe)}}else for(let Ae of E)O.set(Ae,D.length),D.push(Ae.section);let L=D.length,B=1/0,W=-1/0;for(let Ae of x)vc(Ae)&&(B=Math.min(B,+Ae.startTime),W=Math.max(W,+Ae.endTime));let Y=B<=W,I=We(e.title,!1,o,r,4e3,1),X=I.height>0?I.height+16:0;if(!Y){let Ae=Math.ceil(Math.max(I.width,1)+2*s),xe=Math.ceil(Math.max(I.height,1)+2*s),Oe=De(I,Ae/2,s+I.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:Ze("gantt",Ae,xe,r,n,e,Oe),width:Ae,height:xe,links:[]}}let ee=new Map,K=0;for(let Ae of S.keys()){let xe=We(Ae,!1,o,c,180);ee.set(Ae,xe),K=Math.max(K,xe.width)}let z=e.axisFormat||(e.dateFormat==="D"?"%d":rf(t,"axisFormat")??"%Y-%m-%d"),C=Ae=>Po(z,new Date(Ae)),M=Math.max(o.width(C(B),l,0),o.width(C(W),l,0)),T=s+(yr(t,"leftPadding",0,2e3)??Math.max(K>0?K+24:0,M/2)),g=yr(t,"rightPadding",0,2e3)??Math.max(16,M/2),_=zr(n,yr(t,"useWidth",100,2e4)??q2,280),y=Math.max(Q2,_-T-g-s),R=T+y,A=W>B?y/(W-B):0,N=Ae=>A===0?T+y/2:T+(Ae-B)*A,$=Math.round(l*1.75),U=yr(t,"topPadding",0,2e3),j=yr(t,"gridLineStartPadding",0,2e3),v=s+X+(b?$:0),k=Math.max(v,U??0),F=U!==void 0&&j!==void 0?Math.max(0,Math.min(U-j,k-v)):0,H=Math.max(L,1)*u,G=k+H,se=[],q=R+g;for(let Ae of E){let xe=zb(Ae.task,o,i),Oe=O.get(Ae);if(!vc(Ae)){let _e=T+Ci+xe.width/2;q=Math.max(q,_e+xe.width/2),se.push({task:Ae,label:xe,row:Oe,x0:NaN,x1:NaN,labelX:_e,inside:!1});continue}let ve=N(+Ae.startTime),Ge=Math.max(N(+(Ae.renderEndTime??Ae.endTime)),ve+(Ae.milestone?0:2));if(Ae.milestone){let _e=ve+(N(+Ae.endTime)-ve)/2;ve=_e-f/2,Ge=_e+f/2}let pe=!Ae.milestone&&xe.width+2*Ci<=Ge-ve,J=(ve+Ge)/2;if(!pe){let _e=Ge+Ci+xe.width<=R+g,le=ve-Ci-xe.width>=T;J=_e||!le?Ge+Ci+xe.width/2:ve-Ci-xe.width/2,q=Math.max(q,J+xe.width/2)}se.push({task:Ae,label:xe,row:Oe,x0:ve,x1:Ge,labelX:J,inside:pe})}let P=e.tickInterval||rf(t,"tickInterval")||"",V=e.weekday??rf(t,"weekday")??"sunday",ne=Math.max(2,Math.min(10,Math.floor(y/(M+24)))),ae=Kb(P,V,B,W,Math.ceil(y/3))??Hb(B,W,ne),Z="",Q="",ie="",me=-1/0,re="",te=G+$/2+2,he=k-F-$/2-2;for(let Ae of ae){let xe=N(Ae);Z+=`M${d(xe)},${d(k-F)}V${d(G)}`;let Oe=C(Ae),ve=o.width(Oe,l,0);if(xe-ve/2<me+8||Oe===re)continue;me=xe+ve/2,re=Oe,q=Math.max(q,me);let Ge=`text-anchor="middle">${je(Oe)}</text>`;Q+=`<text x="${d(xe)}" y="${d(te+l*.35)}" ${Ge}`,b&&(ie+=`<text x="${d(xe)}" y="${d(he+l*.35)}" ${Ge}`)}let oe="",ge="",Ee=[],be=G+$+4,ye=Math.round(i*1.5);for(let Ae of[...w].sort((xe,Oe)=>+xe.startTime-+Oe.startTime)){let xe=N(+Ae.startTime),Oe=zb(Ae.task,o,i),ve=Math.max(s+Oe.width/2,xe),Ge=0;for(;Ge<Ee.length&&ve-Oe.width/2<Ee[Ge]+8;)Ge++;Ee[Ge]=ve+Oe.width/2,q=Math.max(q,Ee[Ge]),oe+=`<path class="pele-vert" data-id="${Fe(Ae.id)}" d="M${d(xe)},${d(k-F)}V${d(G)}"/>`,ge+=De(Oe,ve,be+Ge*ye+ye/2,` class="pele-vert-label" data-id="${Fe(Ae.id)}"`)}let Re=Math.ceil(Math.max(q,s+I.width)+s),Le=Math.ceil(G+$+(Ee.length>0?4+Ee.length*ye:0)+s),ue="",fe="";for(let Ae=0;Ae<L;){let xe=D[Ae],Oe=Ae+1;for(;Oe<L&&D[Oe]===xe;)Oe++;let ve=S.get(xe)%m,Ge=k+Ae*u,pe=(Oe-Ae)*u;(S.size>1||xe!=="")&&(ue+=`<rect class="pele-section pele-section-${ve}" x="0" y="${d(Ge)}" width="${Re}" height="${d(pe)}" fill="${ve%2===0?"var(--_s)":"none"}"/>`);let J=ee.get(xe);fe+=De(J,s+8+J.width/2,Ge+pe/2,` class="pele-section-label" data-id="${Fe(xe)}"`,n.icons),Ae=Oe}let Me="";if((e.excludes.length>0||e.includes.length>0)&&+Nc(new Date(B),6,"y")>W){let Ae,xe,Oe=()=>{if(!Ae||!xe)return;let ve=new Date(Ae);ve.setHours(0,0,0,0);let Ge=new Date(xe);Ge.setHours(23,59,59,999);let pe=Math.max(T,N(+ve)),J=Math.min(R,N(+Ge));J>pe&&(Me+=`<rect x="${d(pe)}" y="${d(k)}" width="${d(J-pe)}" height="${d(H)}"/>`),Ae=xe=void 0};for(let ve=new Date(B);+ve<=W;ve=br(ve,1))e.isInvalidDate(ve)?(Ae??=ve,xe=ve):Oe();Oe()}let Ne=[],Be="";for(let Ae of se){let xe=Ae.task,Oe=k+Ae.row*u+u/2,ve=xe.active?"active":xe.done?"done":"",Ge="pele-task";ve&&(Ge+=" pele-"+ve),xe.crit&&(Ge+=" pele-crit"),xe.milestone&&(Ge+=" pele-milestone"),xe.classes.includes("clickable")&&(Ge+=" pele-clickable");let pe="",J="";if(Number.isNaN(Ae.x0))Ge+=" pele-unscheduled",J=' fill="var(--_m)"';else{let we=xe.crit?ao:"var(--_c)",Te=ve==="done"?'fill="var(--_a)"':ve==="active"?`fill="${we}" fill-opacity="0.25"`:`fill="${we}"`,Ce=`stroke="${ve==="done"&&!xe.crit?"var(--_b)":we}"`;if(xe.milestone){let Ie=(Ae.x0+Ae.x1)/2,Pe=f/2;pe=`<path d="M${d(Ie)},${d(Oe-Pe)}L${d(Ie+Pe)},${d(Oe)}L${d(Ie)},${d(Oe+Pe)}L${d(Ie-Pe)},${d(Oe)}Z" ${Te} ${Ce} stroke-linejoin="round"/>`}else pe=`<rect x="${d(Ae.x0)}" y="${d(Oe-f/2)}" width="${d(Ae.x1-Ae.x0)}" height="${d(f)}" ${Te} ${Ce}${it}/>`;Ae.inside?J=ve===""?' fill="var(--_bg)"':"":ve==="done"&&(J=' fill="var(--_m)"')}let _e=pe+De(Ae.label,Ae.labelX,Oe,` class="pele-label"${J}`),le=e.links.get(xe.id);le!==void 0&&(_e=Wn(_e,le,xe.id,Ne,n)),Be+=`<g class="${Ge}" data-id="${Fe(xe.id)}">${_e}</g>`}let ce="";if(e.todayMarker!=="off"&&a>=B&&a<=W&&W>B){let Ae=N(a),xe=k-F,Oe=e.todayMarker?St(e.todayMarker.split(",")).line:"";ce=`<g class="pele-today"><path d="M${d(Ae)},${d(xe)}V${d(G)}" fill="none" stroke="var(--_c)" stroke-width="2"${Oe}/>`+(Oe?"":`<path d="M${d(Ae-4)},${d(xe-5)}H${d(Ae+4)}L${d(Ae)},${d(xe+1)}Z" fill="var(--_c)"/>`)+"</g>"}let Se=`M${d(T)},${d(G)}H${d(R)}`+(b?`M${d(T)},${d(k-F)}H${d(R)}`:""),$e=De(I,Re/2,s+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ue?`<g class="pele-sections">${ue}</g>`:"")+(Me?`<g class="pele-excluded" fill="var(--_a)">${Me}</g>`:"")+`<g class="pele-grid" fill="none"><path d="${Z}" stroke="var(--_b)" stroke-dasharray="1 3"/><path d="${Se}" stroke="var(--_b)"/></g>`+(oe?`<g class="pele-verts" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-dasharray="4 3">${oe}</g>`:"")+ce+`<g class="pele-tasks" font-size="${d(i)}">${Be}</g><g class="pele-section-labels" font-size="${d(c)}">${fe}</g><g class="pele-axis" font-size="${l}" fill="var(--_m)">${Q}${ie}</g>`+(ge?`<g class="pele-vert-labels" font-size="${d(i)}">${ge}</g>`:"");return{svg:Ze("gantt",Re,Le,r,n,e,$e),width:Re,height:Le,links:Ne}}var jb={type:"gantt",parse(e,t,n){let r=new Mc;n&&(r.title=n);let o=t.gantt?.displayMode;return typeof o=="string"&&(r.displayMode=o),Wb(e,r),r},render:Vb};var Zt={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4};function Nn(e){throw new ze(e,"semantic",{type:"gitGraph"})}function Xb(e){return e==="REVERSE"?Zt.REVERSE:e==="HIGHLIGHT"?Zt.HIGHLIGHT:Zt.NORMAL}function tC(e,t){e.dir&&t.setDirection(e.dir);for(let n of e.statements)nC(n,t)}function nC(e,t){switch(e.$type){case"Commit":t.commit({id:e.id,msg:e.message??"",type:e.type!==void 0?Xb(e.type):Zt.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?Xb(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 qb(e,t,n){let r=t.gitGraph,o=typeof r?.mainBranchName=="string"?r.mainBranchName:"main",s=typeof r?.mainBranchOrder=="number"?r.mainBranchOrder:0,a=new Map,i=new Map([[o,null]]),c=new Map([[o,s]]),l=[],f=null,p=o,u="LR",m=0,h=()=>{for(let w=m+1;;w+=2654435761){let S=`${m}-${(Math.imul(w,2654435761)>>>0).toString(16).padStart(8,"0").slice(0,7)}`;if(!a.has(S))return S}},b=w=>{f=w,a.set(w.id,w),i.set(p,w.id)},x=w=>{i.has(w)||Nn(`Trying to checkout branch which is not yet created. (Help try using "branch ${w}")`),p=w;let S=i.get(w);f=S?a.get(S)??null:null};tC(e,{setDirection(w){u=w},commit({msg:w,id:S,type:O,tags:D}){let L={id:S||h(),message:w,seq:m++,type:O??Zt.NORMAL,tags:D?[...D]:[],parents:f===null?[]:[f.id],branch:p};a.has(L.id)&&l.push(`Commit ID ${L.id} already exists`),b(L)},branch({name:w,order:S}){i.has(w)&&Nn(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${w}")`),i.set(w,f!==null?f.id:null),c.set(w,S),x(w)},merge({branch:w,id:S,type:O,tags:D}){let L=i.get(p),B=i.get(w),W=L?a.get(L):void 0,Y=B?a.get(B):void 0;W&&Y&&W.branch===w&&Nn(`Cannot merge branch '${w}' into itself.`),p===w&&Nn('Incorrect usage of "merge". Cannot merge a branch to itself'),W===void 0&&Nn(`Incorrect usage of "merge". Current branch (${p})has no commits`),i.has(w)||Nn(`Incorrect usage of "merge". Branch to be merged (${w}) does not exist`),Y===void 0&&Nn(`Incorrect usage of "merge". Branch to be merged (${w}) has no commits`),W===Y&&Nn('Incorrect usage of "merge". Both branches have same head'),S&&a.has(S)&&Nn(`Incorrect usage of "merge". Commit with id:${S} already exists, use different custom id`),b({id:S||h(),message:`merged branch ${w} into ${p}`,seq:m++,parents:f===null?[]:[f.id,B||""],branch:p,type:Zt.MERGE,customType:O,customId:!!S,tags:D?[...D]:[]})},cherryPick({id:w,targetId:S,tags:O,parent:D}){let L=w?a.get(w):void 0;if(L===void 0&&Nn('Incorrect usage of "cherryPick". Source commit id should exist and provided'),D&&!L.parents.includes(D)&&Nn("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."),L.type===Zt.MERGE&&!D&&Nn("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."),S&&a.has(S))return;L.branch===p&&Nn('Incorrect usage of "cherryPick". Source commit is already on current branch');let B=i.get(p);(!B||!a.has(B))&&Nn(`Incorrect usage of "cherry-pick". Current branch (${p})has no commits`),b({id:h(),message:`cherry-picked ${L.message} into ${p}`,seq:m++,parents:f===null?[]:[f.id,L.id],branch:p,type:Zt.CHERRY_PICK,tags:O?O.filter(Boolean):[`cherry-pick:${L.id}${L.type===Zt.MERGE?`|parent:${D}`:""}`]})},checkout:x});let E=[...c].map(([w,S],O)=>({name:w,order:S??parseFloat(`0.${O}`)})).sort((w,S)=>w.order-S.order).map(w=>w.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,`
`):void 0,direction:u,commits:a,branches:i,lanes:E,currentBranch:p,head:f,warnings:l}}var Zb={name:"REFERENCE",pattern:/\w([-\./\w]*[-\w])?/y},Jb=[Zb];function Gn(e){return{name:e,pattern:e,longer:Jb}}var Qb=[Gn("cherry-pick"),{name:"gitGraph:",pattern:"gitGraph:"},Gn("HIGHLIGHT"),{...qt("gitGraph"),longer:Jb},Gn("checkout"),Gn("REVERSE"),{name:"parent:",pattern:"parent:"},Gn("commit"),Gn("NORMAL"),Gn("branch"),{name:"order:",pattern:"order:"},Gn("switch"),{name:"type:",pattern:"type:"},Gn("merge"),{name:"msg:",pattern:"msg:"},{name:"tag:",pattern:"tag:"},{name:"id:",pattern:"id:"},Gn("LR"),Gn("TB"),Gn("BT"),{name:":",pattern:":"},{...tn,opener:/[\t ]*accDescr\s*{/y},zt,Vt,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Cn,bn,yn,Ut,jt,Xt,Zb];function ey(e){let t=new Bt(Wt(e,Qb,"gitGraph"),Qb,"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++},o=()=>t.kind===31?t.take():t.kind===25?on(t.take()):t.fail("a branch name"),s=()=>on(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 i=t.kinds[t.i+1];(t.kind===17||t.kind===18||t.kind===19)&&i===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=Ht(t.take()),r();break;case 22:n.accTitle=Yt(t.take()),r();break;case 23:n.title=Gt(t.take()),r();break;case 7:{t.i++;let i={$type:"Commit",tags:[]};for(;;)if(t.accept(16))i.id=s();else if(t.accept(15))i.tags.push(s());else if(t.accept(12))i.type=a();else if(t.accept(14)||t.kinds[t.i]===25)i.message=s();else break;r(),n.statements.push(i);break}case 9:{t.i++;let i={$type:"Branch",name:o()};t.accept(10)&&(i.order=parseInt(t.expect(24))),r(),n.statements.push(i);break}case 13:{t.i++;let i={$type:"Merge",branch:o(),tags:[]};for(;;)if(t.accept(16))i.id=s();else if(t.accept(15))i.tags.push(s());else if(t.accept(12))i.type=a();else break;r(),n.statements.push(i);break}case 4:case 11:{t.i++;let i={$type:"Checkout",branch:o()};r(),n.statements.push(i);break}case 0:{t.i++;let i={$type:"CherryPicking",tags:[]};for(;;)if(t.accept(16))i.id=s();else if(t.accept(15))i.tags.push(s());else if(t.accept(6))i.parent=s();else break;r(),n.statements.push(i);break}default:t.fail("a statement, a title, or a line break")}return n}var rC=/<(?!br\s*\/?>)/gi,sC=/:fa-/g,iC=/<br\s*\/?>|fl°°?\w+¶ß|&#?\w+;|[\ud800-\udbff][\udc00-\udfff]|[\s\S]/gi;function er(e,t,n,r,o=0){let s=e;return s!==void 0&&(s.includes("<")&&(s=s.replace(rC,"&lt;")),s.includes(":fa-")&&(s=s.replace(sC,"&colon;fa-"))),We(s,!1,t,n,r,o)}function Mn(e,t,n,r,o=0){let s=er(e,t,n,r,o);if(e===void 0||s.width<=r)return s;let a="",i=0;for(let c of e.match(iC)??[]){if(c.trim()===""||c.length>2&&c[0]==="<")i=0;else{let l=t.width(c.length>2?"x":c,n,o);i>0&&i+l>r&&(a+=`
`,i=0),i+=l}a+=c}return er(a,t,n,r,o)}var Jt=7,oC=44,aC=44,Pc=36,Bc=8,Fs=20,Fo=20,Wo=7,ty=6,sf=Math.SQRT1_2,ny=["normal","reverse","highlight","merge","cherry-pick"];function Fc(e,t,n){let r=e.gitGraph?.[t];return typeof r=="boolean"?r:n}function ry(e){return Wo+4+e.width+6}function cC(e,t,n,r){let o=`cx="${d(t)}" cy="${d(n)}"`;if(e===Zt.HIGHLIGHT)return`<rect x="${d(t-Jt-1)}" y="${d(n-Jt-1)}" width="${2*Jt+2}" height="${2*Jt+2}" rx="2" fill="${r}"/>`;if(e===Zt.MERGE)return`<circle ${o} r="${Jt-1}" fill="var(--_bg)" stroke="${r}" stroke-width="2"/><circle ${o} r="2.5" fill="${r}"/>`;let s=`<circle ${o} r="${Jt}" fill="${r}"/>`;return e===Zt.REVERSE?s+`<path d="M${d(t-3)},${d(n-3)}l6,6M${d(t-3)},${d(n+3)}l6,-6" fill="none" stroke="var(--_bg)" stroke-width="1.5" stroke-linecap="round"/>`:e===Zt.CHERRY_PICK?s+`<path d="M${d(t-2.6)},${d(n+1)}L${d(t+.8)},${d(n-4.2)}L${d(t+2.6)},${d(n+1)}" fill="none" stroke="var(--_bg)" stroke-linejoin="round"/><circle cx="${d(t-2.6)}" cy="${d(n+2.2)}" r="1.8" fill="var(--_bg)"/><circle cx="${d(t+2.6)}" cy="${d(n+2.2)}" r="1.8" fill="var(--_bg)"/>`:s}function iy(e,t,n){return e.direction!=="LR"?sy(e,t,n,e.direction):$t(n,r=>sy(e,t,n,r?"TB":"LR"))}function sy(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.75),a=n.measurer??et(n.fontFamily),i=n.padding??8,c=Fc(t,"showBranches",!0),l=Fc(t,"showCommitLabel",!0),f=Fc(t,"rotateCommitLabel",!0),p=Fc(t,"parallelCommits",!1),u=r!=="LR",m=r==="BT",h=new Map;e.lanes.forEach((P,V)=>h.set(P,V));let b=e.lanes.length,x=Math.round(o*.875),E=e.lanes.map(P=>er(c?P:"",a,x,4e3)),w=[],S=new Map;for(let P of[...e.commits.values()].sort((V,ne)=>V.seq-ne.seq)){let V=l&&P.type!==Zt.CHERRY_PICK&&(P.type!==Zt.MERGE||P.customId===!0),ne=[];for(let Z of P.tags){let Q=er(Z,a,s,4e3);Q.lines.length>0&&ne.push(Q)}let ae={commit:P,index:w.length,lane:h.get(P.branch)??0,m:0,label:V?er(P.id,a,s,4e3):void 0,tags:ne};w.push(ae),S.set(P.id,ae)}let O=new Float64Array(w.length),D=new Float64Array(w.length),L=new Float64Array(b).fill(Jt),B=new Float64Array(b).fill(Jt);w.forEach((P,V)=>{let{label:ne,tags:ae}=P,Z=0,Q=0;for(let oe of ae){let ge=ry(oe);u?(Z=Math.max(Z,oe.height),Q+=ge+4):(Z=Math.max(Z,ge),Q+=oe.height+3)}let ie=0,me=0;ne!==void 0&&ne.lines.length>0&&(f?me=3+sf*(ne.width+ne.height):(ie=u?ne.height:ne.width,me=6+(u?ne.width:ne.height))),O[V]=Math.max(Jt,Z/2,ie/2),D[V]=Z/2;let re=Jt+(ae.length>0?ty+Q:0),te=Jt+me,he=P.lane;L[he]=Math.max(L[he],u?te:re),B[he]=Math.max(B[he],u?re:te)});let W=new Float64Array(w.length);u||w.forEach((P,V)=>{if(D[V]!==0)for(let ne of P.commit.parents){let ae=S.get(ne);ae!==void 0&&ae.lane<P.lane&&(W[V]=D[V]+4)}});let Y=(P,V)=>Math.max(oC,O[P]+O[V]+Bc,W[V]>0?O[P]+Pc+W[V]:0);w.forEach((P,V)=>{if(!p){P.m=V===0?0:w[V-1].m+Y(V-1,V);return}let ne=0;for(let ae of P.commit.parents){let Z=S.get(ae);Z===void 0||Z.index>=V||(ne=Math.max(ne,Z.m+Y(Z.index,V)))}P.m=ne});let I=0;for(let P of w)I=Math.max(I,P.m);let X=new Float64Array(b);for(let P=0;P<b;P++){let V=E[P],ne=V.lines.length===0?0:u?V.width/2+8:V.height/2+2;L[P]=Math.max(L[P],ne),B[P]=Math.max(B[P],ne),P>0&&(X[P]=X[P-1]+Math.max(aC,B[P-1]+L[P]+Bc))}let ee=(P,V)=>u?V:P,K=(P,V)=>u?m?-P:P:V,z=(P,V)=>`${d(ee(P,V))},${d(K(P,V))}`,C=1/0,M=1/0,T=-1/0,g=-1/0,_=(P,V,ne,ae)=>{P<C&&(C=P),V<M&&(M=V),ne>T&&(T=ne),ae>g&&(g=ae)},y="";if(c)for(let P=0;P<b;P++){let V=E[P],ne=lt(P),ae=X[P],Z=V.width+16,Q=V.height+4,ie=V.lines.length===0?-Fs:-Fs-(u?Q:Z),me=ee(ie+(u?Q:Z)/2,ae),re=K(ie+(u?Q:Z)/2,ae);_(ee(-Fs,ae),K(-Fs,ae),ee(-Fs,ae),K(-Fs,ae)),_(ee(I+Fo,ae),K(I+Fo,ae),ee(I+Fo,ae),K(I+Fo,ae)),y+=`<g class="pele-branch" data-id="${Fe(e.lanes[P])}"><path class="pele-lane" d="M${z(-Fs,ae)}L${z(I+Fo,ae)}" stroke="${ne}" stroke-dasharray="2 4"/>`,V.lines.length>0&&(_(me-Z/2,re-Q/2,me+Z/2,re+Q/2),y+=`<rect x="${d(me-Z/2)}" y="${d(re-Q/2)}" width="${d(Z)}" height="${d(Q)}" fill="${ne}"${it}/>`+De(V,me,re,' class="pele-label" fill="var(--_bg)"')),y+="</g>"}let R=Array.from({length:b},()=>[]);for(let P of w)R[P.lane].push(P.m);if(p)for(let P of R)P.sort((V,ne)=>V-ne);let A=(P,V,ne)=>{let ae=R[P],Z=0,Q=ae.length;for(;Z<Q;){let ie=Z+Q>>1;ae[ie]<=V?Z=ie+1:Q=ie}return Z<ae.length&&ae[Z]<ne},N="",$="";for(let P of w){let{commit:V}=P,ne=X[P.lane],ae=P.m;for(let Z=0;Z<V.parents.length;Z++){let Q=S.get(V.parents[Z]);if(Q===void 0||Q===P)continue;let ie=X[Q.lane],me=Q.m;if(Q.lane===P.lane){$+=`<path class="pele-edge" d="M${z(me,ie)}L${z(ae,ne)}" stroke="${lt(P.lane)}"/>`;continue}let re=Z>0&&V.type===Zt.MERGE,te=Z>0&&!re,he=`M${z(me,ie)}`;if(ae<=me){let oe=(me+ae)/2;he+=`C${z(oe,ie)} ${z(oe,ne)} ${z(ae,ne)}`}else if(!re&&!A(P.lane,me,ae)){let oe=Math.min(Pc,ae-me);he+=`C${z(me+oe/2,ie)} ${z(me+oe/2,ne)} ${z(me+oe,ne)}L${z(ae,ne)}`}else{let oe=Q.lane<P.lane&&ae-W[P.index]>me?ae-W[P.index]:ae,ge=Math.min(Pc,oe-me),Ee=ie;(!re||A(Q.lane,me,ae))&&(Ee=ie>ne?ne+B[P.lane]+Bc/2:ne-L[P.lane]-Bc/2,ge=Math.min(Pc,(oe-me)/2),he+=`C${z(me+ge/2,ie)} ${z(me+ge/2,Ee)} ${z(me+ge,Ee)}`),he+=`L${z(oe-ge,Ee)}C${z(oe-ge/2,Ee)} ${z(oe-ge/2,ne)} ${z(oe,ne)}`,oe<ae&&(he+=`L${z(ae,ne)}`)}N+=`<path class="pele-edge${re?" pele-edge-merge":te?" pele-edge-cherry-pick":""}" d="${he}" stroke="${lt(re?Q.lane:P.lane)}"${te?' stroke-dasharray="4 3"':""}/>`}}let U="";for(let P of w){let{commit:V,label:ne,tags:ae}=P,Z=ee(P.m,X[P.lane]),Q=K(P.m,X[P.lane]),ie=V.customType??V.type;_(Z-Jt-1,Q-Jt-1,Z+Jt+1,Q+Jt+1);let re=V.type<Zt.MERGE&&V.message!==""?`<title>${Fe(V.message)}</title>`:"";if(re+=cC(ie,Z,Q,lt(P.lane)),ne!==void 0&&ne.lines.length>0){let oe=ne.width,ge=ne.height,Ee=(be,ye)=>`<rect x="${d(be-oe/2-2)}" y="${d(ye-ge/2+2)}" width="${d(oe+4)}" height="${d(ge-4)}" rx="3" fill="var(--_bg)"/>`;if(f){let be=sf*ge/2,ye=u?Z-Jt-3-be:Z+3,Re=u?Q:Q+Jt+3+be,Le=sf*oe+be;_(ye-Le,m?Re-Le:Re-be,ye+be,m?Re+be:Re+Le),re+=`<g class="pele-commit-label" transform="rotate(${m?45:-45} ${d(ye)} ${d(Re)})">`+Ee(ye-oe/2,Re)+De(ne,ye-oe/2,Re,"")+"</g>"}else{let be=u?Z-Jt-6-oe/2:Z,ye=u?Q:Q+Jt+6+ge/2;_(be-oe/2,ye-ge/2,be+oe/2,ye+ge/2),re+=`<g class="pele-commit-label">${Ee(be,ye)}${De(ne,be,ye,"")}</g>`}}let te=Jt+ty;for(let oe=u?0:ae.length-1;oe>=0&&oe<ae.length;oe+=u?1:-1){let ge=ae[oe],Ee=ry(ge),be=ge.height,ye=u?Z+te:Z-Ee/2,Re=u?Q:Q-te-be/2;te+=u?Ee+4:be+3,_(ye,Re-be/2,ye+Ee,Re+be/2),re+=`<g class="pele-tag"><path d="M${d(ye)},${d(Re)}L${d(ye+Wo)},${d(Re-be/2)}H${d(ye+Ee)}V${d(Re+be/2)}H${d(ye+Wo)}Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/><circle cx="${d(ye+Wo)}" cy="${d(Re)}" r="1.5" fill="var(--_b)"/>`+De(ge,ye+Wo+4+ge.width/2,Re,' fill="var(--_fg)"')+"</g>"}let he=V.type===Zt.MERGE&&ie!==Zt.MERGE?" pele-commit-merge":"";U+=`<g class="pele-commit pele-commit-${ny[ie]??ny[0]}${he}" data-id="${Fe(V.id)}">${re}</g>`}C>T&&_(0,0,0,0);let j=We(e.title,!1,a,o,4e3,1),v=j.height>0?j.height+16:0,k=Math.max(T-C,j.width),F=Math.ceil(k+2*i),H=Math.ceil(g-M+v+2*i),G=i-C+(k-(T-C))/2,se=i+v-M,q=De(j,F/2,i+j.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(G)},${d(se)})">`+(y?`<g class="pele-branches" fill="none" font-size="${x}">${y}</g>`:"")+(N||$?`<g class="pele-edges" fill="none" stroke-width="2" stroke-linecap="round">${N}${$}</g>`:"")+(U?`<g class="pele-commits" font-size="${s}" fill="var(--_m)">${U}</g>`:"")+"</g>";return{svg:Ze("gitGraph",F,H,o,n,e,q),width:F,height:H,links:[]}}var oy={type:"gitGraph",parse:(e,t,n)=>qb(ey(e),t,n),render:iy};function ay(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,`
`):void 0}}var cy=[qt("showInfo"),qt("info"),tn,zt,Vt,bn,yn,Ut,jt,Xt];function ly(e){let t=new Bt(Wt(e,cy,"info"),cy,"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=Ht(t.take()):r===3?n.accTitle=Yt(t.take()):r===4?n.title=Gt(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 dy="1.8.0";function uy(e,t,n){let r=n.fontSize??16,o=n.measurer??et(n.fontFamily),s=n.padding??8,a=We(e.title,!1,o,r,4e3,1),i=a.height>0?a.height+8:0,c=We(`Pele v${dy}`,!1,o,r,4e3),l=Math.ceil(Math.max(a.width,c.width)+2*s),f=Math.ceil(i+c.height+2*s),p=De(a,l/2,s+a.height/2,' class="pele-title" font-weight="var(--_tw)"')+De(c,l/2,s+i+c.height/2,' class="pele-version" fill="var(--_m)"');return{svg:Ze("info",l,f,r,n,e,p),width:l,height:f,links:[]}}var fy={type:"info",parse:(e,t,n)=>ay(ly(e),n),render:uy};var Wc=class{constructor(){de(this,"type","ishikawa");de(this,"title");de(this,"root");de(this,"stack",[]);de(this,"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 o=Math.max(t-this.baseLevel+1,1),s=this.stack;for(;s.length>1&&s[s.length-1].level>=o;)s.pop();s[s.length-1].node.children.push(r),s.push({level:o,node:r})}};var py=["$end","EOF","SPACELINE","NL","ISHIKAWA","SPACELIST","TEXT"];function dC(e,t){let n="ishikawa-beta",r=0;for(;r<13;){let o=e.charCodeAt(t+r),s=n.charCodeAt(r);if(o!==s&&(o+32!==s||o<65||o>90))break;r++}return r===13&&!Qe(e.charCodeAt(t+13))?13:r>=8&&!Qe(e.charCodeAt(t+8))?8:0}function hy(e){let t=[],n=[],r=[],o=e.length,s=0;for(;s<o;){let a=s,i=-1;for(;a<o&&He(e.charCodeAt(a));)e.charCodeAt(a)===10&&(i=a),a++;let c,l;if(e.charCodeAt(a)===37&&e.charCodeAt(a+1)===37)for(c=2,l=a+2;l<o;){let f=e.charCodeAt(l);if(f===10||f===13||f===8232||f===8233)break;l++}else if(a===s){let f=dC(e,s);f>0?(c=4,l=s+f):(c=6,l=e.indexOf(`
`,s),l===-1&&(l=o))}else i>s?(c=2,l=i+1):i===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(o,o),r.push(o,o),{types:t,starts:n,ends:r}}var of="'SPACELINE', 'NL', 'EOF'";function my(e,t){let{types:n,starts:r,ends:o}=hy(e),s=0,a=i=>{throw st("ishikawa",e,r[s],`Expecting ${i}, got '${py[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 i=n[s];if(i===6||i===5&&n[s+1]===6){let c=i===6?s:s+1;s=c+1,n[s]!==2&&n[s]!==3&&n[s]!==1&&a(of),t.addNode(i===6?0:o[c-1]-r[c-1],e.slice(r[c],o[c]).trim())}else i===2||i===5?(s++,n[s]!==2&&n[s]!==3&&n[s]!==1&&a(i===5?`${of}, 'TEXT'`:of)):a("'SPACELINE', 'SPACELIST', 'TEXT'");for(s++;n[s]===3||n[s]===1;)s++;if(n[s]===0)return}}var Gc=.5,Uc=Math.hypot(Gc,1),uC=14,fC=6,pC=8,gy=22,hC=18,af=5,mC=26,by=34,gC=28,bC=10,yC=5;function EC(e,t,n,r,o){let s=We(e.text,!1,n,r,180),a=Math.round(o*1.5),i=[],c=[],l=[],f=(h,b,x)=>{let E=h.length;for(let w=E-1;w>=0;w--)l.push({node:h[t?E-1-w:w],depth:b,parent:x,slot:w,bone:-1})};for(f(e.children,2,-1);l.length>0;){let h=l.pop();if(h.bone!==-1){c.push(h.bone);continue}let b=i.length;i.push({label:We(h.node.text,!1,n,o,200),depth:h.depth,parent:h.parent,slot:h.slot,kids:h.node.children.length,rise:0,at:0,textEnd:0}),h.depth%2===0?c.push(b):(h.bone=b,l.push(h)),f(h.node.children,h.depth+1,b)}let p=uC;for(let h of c){let b=Math.max(i[h].label.height,a)+fC;i[h].rise=p+b/2,p+=b}let u=s.width+2*bC,m=u/2;for(let h of i){let b=h.parent===-1?void 0:i[h.parent];h.depth%2===0?(h.at=b?b.at:0,h.textEnd=h.at-(h.kids>0?(h.kids+1)*gy:hC)-af):(h.at=b.at-(b.kids-h.slot)*gy,h.textEnd=h.at-af),m=Math.max(m,h.label.width-h.textEnd)}return{node:e,label:s,boxW:u,boxH:s.height+2*yC,bones:i,rise:p+pC,reach:m}}function yy(e,t,n){return $t(n,r=>AC(e,t,n,r))}function AC(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=n.measurer??et(n.fontFamily),i=n.padding??8;if(r)return xC(e,n);let c=e.root,l=We(e.title,!1,a,o,4e3,1),f=l.height>0?l.height+12:0,p="",u=0,m=0,h=0,b=0;if(c){let L=We(c.text,!1,a,o,200,1),B=Math.max(L.height+24,48),W=L.width+24+B/2,Y=c.children.map((C,M)=>EC(C,M%2===0,a,o,s));for(let C of Y)C.rise=Math.max(C.rise,B/2+14);let I=[],X=-by;for(let C=0;C<Y.length;C+=2){if(C>0){let M=0;for(let T=0;T<2;T++){let g=Y[C-2+T],_=Y[C+T];g&&(M=Math.max(M,g.reach+(_?_.boxW/2:0)))}X-=M+mC}I.push(X,X)}let ee=Y.length>0?X-gC:-by;m=W,u=ee,h=-B/2,b=B/2;let K="";Y.forEach((C,M)=>{let T=M%2===0?-1:1,g=I[M],_=(j,v)=>g+j-v*Gc,y=_(0,C.rise),R=T*C.rise,A=Ot-1,N=`M${d(g-Gc/Uc*A)},${d(T*A/Uc)}L${d(y)},${d(R)}`,$="";for(let j of C.bones){let v=T*j.rise;if(j.depth%2===0)N+=`M${d(_(j.at,j.rise))},${d(v)}H${d(_(j.textEnd+af,j.rise))}`;else{let F=C.bones[j.parent].rise;N+=`M${d(_(j.at,F))},${d(T*F)}L${d(_(j.at,j.rise))},${d(v)}`}let k=_(j.textEnd,j.rise);$+=De(j.label,k-j.label.width/2,v,j.depth>2?' fill="var(--_m)"':""),u=Math.min(u,k-j.label.width)}let U=R+T*(C.boxH/2);u=Math.min(u,y-C.boxW/2),m=Math.max(m,y+C.boxW/2),h=Math.min(h,U-C.boxH/2),b=Math.max(b,U+C.boxH/2),K+=`<g class="pele-ishikawa-category" data-id="${Fe(C.node.text)}"><path class="pele-ishikawa-bones" d="${N}" fill="none" stroke="var(--_l)"/>`+Et("arrow_point",g,0,Gc/Uc,-T/Uc,"var(--_l)")+`<rect x="${d(y-C.boxW/2)}" y="${d(U-C.boxH/2)}" width="${d(C.boxW)}" height="${d(C.boxH)}" fill="var(--_s)" stroke="var(--_b)"${it}/>`+De(C.label,y,U,' class="pele-label"')+($?`<g class="pele-ishikawa-causes" font-size="${s}">${$}</g>`:"")+"</g>"});let z=B/2;p=`<path class="pele-ishikawa-spine" d="M${d(ee)},0H${d(-(Ot-1))}" fill="none" stroke="var(--_l)"/>`+Et("arrow_point",0,0,1,0,"var(--_l)")+K+`<g class="pele-ishikawa-head" data-id="${Fe(c.text)}"><path d="M0,${d(-z)}H${d(W-z)}A${d(z)},${d(z)} 0 0 1 ${d(W-z)},${d(z)}H0Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/>`+De(L,12+L.width/2,0,' class="pele-label" font-weight="var(--_hw)"')+"</g>"}let x=Math.max(m-u,l.width),E=Math.ceil(x+2*i),w=Math.ceil(b-h+f+2*i),S=i+(x-(m-u))/2-u,O=i+f-h;return{svg:Ze("ishikawa",E,w,o,n,{},De(l,E/2,i+l.height/2,' class="pele-title" font-weight="var(--_tw)"')+(p?`<g transform="translate(${d(S)},${d(O)})">${p}</g>`:"")),width:E,height:w,links:[]}}function xC(e,t){let n=t.fontSize??16,r=Math.round(n*.875),o=t.measurer??et(t.fontFamily),s=t.padding??8,a=Math.max(140,(t.maxWidth??320)-2*s),i=We(e.title,!1,o,n,Tt(t),1),c=[],l=e.root?[{node:e.root,depth:0,parent:-1}]:[],f=0;for(;l.length;){let S=l.pop(),O=c.length;c.push({...S,x:0,y:0,w:0,h:0}),f=Math.max(f,S.depth);for(let D=S.node.children.length-1;D>=0;D--)l.push({node:S.node.children[D],depth:S.depth+1,parent:O})}let p=Math.min(20,Math.max(2,(a-120)/Math.max(1,f))),u=s+(i.height?i.height+12:0),m=i.width,h="",b="";for(let S of c){S.x=s+S.depth*p;let O=Math.max(60,a-S.depth*p-20);S.label=Is(We(S.node.text,!1,o,S.depth<2?n:r,O,S.depth<2?1:0),o,O),S.w=S.label.width+20,S.h=S.label.height+12,S.y=u,u+=S.h+12,m=Math.max(m,S.x-s+S.w);let D=S.depth<2;if(h+=`<g class="pele-node ${S.depth===0?"pele-ishikawa-head":S.depth===1?"pele-ishikawa-category":"pele-ishikawa-cause"}" data-id="${Fe(S.node.text)}">`+(D?`<rect x="${d(S.x)}" y="${d(S.y)}" width="${d(S.w)}" height="${d(S.h)}" rx="${S.depth===0?12:4}" fill="var(--_s)" stroke="var(--_b)"/>`:"")+De(S.label,S.x+S.w/2,S.y+S.h/2,` class="pele-label"${S.depth<2?' font-weight="var(--_hw)"':""}${S.depth>1?` font-size="${r}"`:""}`)+"</g>",S.parent>=0){let L=c[S.parent],B=L.x+p/2;b+=`<path class="pele-edge" d="M${d(B)},${d(L.y+L.h)}V${d(S.y+S.h/2)}H${d(S.x)}" fill="none" stroke="var(--_b)"/>`}}let x=Math.ceil(m+2*s),E=Math.ceil(Math.max(s+i.height,u-12)+s),w=De(i,x/2,s+i.height/2,' class="pele-title" font-weight="var(--_tw)"')+b+h;return{svg:Ze("ishikawa",x,E,n,t,{},w),width:x,height:E,links:[]}}var Ey={type:"ishikawa",parse(e,t,n){let r=new Wc;return r.title=n,my(e,r),r},render:yy};function Hc(e){let t=new Set;for(let n of e)for(let r of n.people)t.add(r);return[...t].sort()}var Yc=class{constructor(){de(this,"type","journey");de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"sections",[]);de(this,"tasks",[]);de(this,"currentSection","")}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
`)}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,n){let r=n.substring(1).split(":"),o=r.length===1?[]:r[1].split(",").map(s=>s.trim());this.tasks.push({task:t,score:Number(r[0]),people:o,section:this.currentSection})}getActors(){return Hc(this.tasks)}};function Ni(e,t){let n=e.indexOf(`
`,t);return n===-1?e.length:n}function Yn(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 Kc(e,t){let n=e.length,r=t;for(;r<n;){let o=e.charCodeAt(r);if(o===37&&e.charCodeAt(r+1)!==123)r=Ni(e,r);else if(o!==125&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)===37)r=Ni(e,r+3);else{if(o===10)return r;if(He(o))do r++;while(r<n&&He(e.charCodeAt(r)));else if(o===35)r=Ni(e,r);else return r}}return r}function cf(e,t){let n=t;for(;He(e.charCodeAt(n));)n++;return n}function zc(e,t,n,r){let o=Yn(e,t,"accdescr");if(!o&&!Yn(e,t,"acctitle"))return t;let s=e.length,a=cf(e,t+8),i=e.charCodeAt(a),c=(l,f,p)=>{n.types.push(l),n.texts.push(e.slice(f,p)),n.starts.push(f)};if(i===58){a=cf(e,a+1);let l=Ni(e,a);return c(o?r+2:r,t,a),c(o?r+3:r+1,a,l),l}if(!o||i!==123)return t;for(a=cf(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 Ay=["$end","EOF","INVALID","NEWLINE","journey","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","taskName","taskData",":"];function Vc(e,t,n){let r=e.length,o=t;for(;o<r;o++){let s=e.charCodeAt(o);if(s===35||s===10||s===59||n&&s===58)break}return o}function xy(e){let t=e.length,n=[],r=[],o=[],s={types:n,texts:r,starts:o},a=0,i=(c,l)=>{n.push(c),r.push(e.slice(a,l)),o.push(a),a=l};for(;a=Kc(e,a),!(a>=t);){let c=e.charCodeAt(a),l=a+1;if(c===10){for(;e.charCodeAt(l)===10;)l++;i(3,l);continue}if(Yn(e,a,"journey")&&!Qe(e.charCodeAt(a+7))){i(4,a+7);continue}if(Yn(e,a,"title")&&He(e.charCodeAt(a+5))&&(l=Vc(e,a+6,!1),l>a+6)){i(5,l);continue}if(l=zc(e,a,s,6),l!==a){a=l;continue}if(Yn(e,a,"section")&&He(e.charCodeAt(a+7))&&(l=Vc(e,a+8,!0),l>a+8)){i(11,l);continue}c===58?(l=Vc(e,a+1,!1),i(l>a+1?13:14,l>a+1?l:a+1)):c===59?i(2,a+1):i(12,Vc(e,a+1,!0))}return(o.length===0||o[o.length-1]<t)&&i(1,t),i(0,t),s}var SC="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'";function Sy(e,t){let{types:n,texts:r,starts:o}=xy(e),s=(a,i)=>{let c=n[a]===0?"1":Ay[n[a]];throw st("journey",e,o[a],`Expecting ${i}, got '${c}'`)};n[0]!==4&&s(0,"'journey'");for(let a=1;;a++){let i=r[a];switch(n[a]){case 3:break;case 5:t.setDiagramTitle(i.substring(6));break;case 6:t.setAccTitle(r[++a].trim());break;case 8:t.setAccDescription(r[++a].trim());break;case 10:t.setAccDescription(i.trim());break;case 11:t.addSection(i.substring(8));break;case 12:n[++a]!==13&&s(a,"'taskData'"),t.addTask(i,r[a]);break;case 1:return;default:s(a,SC)}}}var Xc=10,Jr=8,_C=124,wC=200,jc=12,_y=6,lf=24,df=26,Mi=11,Er=5,RC=13,TC=20,CC='<circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/>',NC={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 wy(e,t,n){return`<g class="pele-face pele-face-${n}" transform="translate(${d(e)},${d(t)})"><circle r="${Mi}" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)">${CC}</g><path d="${NC[n]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}function Ry(e,t,n){return $t(n,r=>MC(e,t,n,r))}function MC(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=Math.round(o*.75),i=n.measurer??et(n.fontFamily),c=n.padding??8;if(r)return IC(e,n);let l=e.tasks,f=l.length,p=Hc(l).filter(F=>F!==""),u=new Map;p.forEach((F,H)=>u.set(F,H));let m=_C,h=l.map(F=>er(F.task,i,s,m)),b=0;for(let F of h)b=Math.max(b,F.width);b>m&&(m=Math.min(Math.ceil(b),wC),h=l.map(F=>Mn(F.task,i,s,m)));let x=m+2*Xc,E=x+jc,w=f>0?f*E-jc:0,S=Math.round(s*1.5),O=Math.max(w,240),D=[],L=0,B=0,W=0;for(let F of p){let H=Mn(F,i,s,O-2*Er-6),G=2*Er+6+H.width;W>0&&W+G>O&&(W=0,B+=4);let se=W>0?D[D.length-1].y:B,q=Math.max(H.height,S);D.push({name:F,label:H,x:W,y:se,h:q}),W+=G,L=Math.max(L,W),B=Math.max(B,se+q),W+=TC}let Y=f>0?lf+w:0,I=Mn(e.title,i,o,Math.max(Y,320),1),X=I.height>0?I.height+16:0,ee=Math.max(Y,I.width,f>0?lf+L:0),K=c+(ee-Y)/2+lf,z=c+X,C=[],M=0;for(let F=0;F<f;){let H=F+1;for(;H<f&&l[H].section===l[F].section;)H++;let G;l[F].section!==""&&(G=Mn(l[F].section,i,s,(H-F)*E-jc-2*Xc,1),M=Math.max(M,Math.max(G.height,S)+2*_y)),C.push({start:F,count:H-F,label:G}),F=H}let T=S;for(let F of h)T=Math.max(T,F.height);let g=p.length>0?2*Er+6:0,_=T+g+2*Jr,y=z+(M>0?M+_y:0),R=y+_+Mi+16,A=R+4*df,N=K+w,$="",U=z;if(f>0){let F="",H="";for(let V=5;V>=1;V--){let ne=R+(5-V)*df;F+=`M${d(K-6)},${d(ne)}H${d(N)}`,H+=`<text x="${d(K-12)}" y="${d(ne+a*.35)}">${V}</text>`}$+=`<path class="pele-grid" d="${F}" fill="none" stroke="var(--_a)"/><g class="pele-scale" font-size="${a}" text-anchor="end" fill="var(--_m)">${H}</g>`;let G="",se="",q="",P=[];l.forEach((V,ne)=>{let ae=K+ne*E,Z=ae+x/2,Q=V.score,ie=Number.isNaN(Q)?3:Math.min(5,Math.max(1,Q)),me=R+(5-ie)*df;G+=`${ne===0?"M":"L"}${d(Z)},${d(me)}`,se+=`M${d(Z)},${d(y+_)}V${d(me-Mi)}`,q+=wy(Z,me,Q>3?"happy":Q<3?"sad":"neutral");let re="",te=V.people.filter(oe=>oe!==""),he=Math.min(RC,(x-2*Xc-2*Er)/Math.max(te.length-1,1));te.forEach((oe,ge)=>{re+=`<circle class="pele-actor" cx="${d(Z+(ge-(te.length-1)/2)*he)}" cy="${d(y+_-Jr-Er)}" r="${Er}" fill="${lt(u.get(oe)??0)}" stroke="var(--_s)"><title>${Fe(oe)}</title></circle>`}),P.push(`<g class="pele-node pele-task" data-id="${Fe(V.task.trim())}"><rect x="${d(ae)}" y="${d(y)}" width="${d(x)}" height="${d(_)}" fill="var(--_s)" stroke="var(--_b)"${it}/>`+De(h[ne],Z,y+Jr+T/2,` font-size="${s}"`)+re+"</g>")}),$+=`<path class="pele-stems" d="${se}" fill="none" stroke="var(--_b)" stroke-dasharray="2 3"/>`+(f>1?`<path class="pele-edge" d="${G}" fill="none" stroke="var(--_l)" stroke-linejoin="round"/>`:"")+q;for(let V of C){let ne=P.slice(V.start,V.start+V.count).join("");if(!V.label){$+=ne;continue}let ae=K+V.start*E,Z=V.count*E-jc;$+=`<g class="pele-cluster pele-section" data-id="${Fe(l[V.start].section.trim())}"><rect x="${d(ae)}" y="${d(z)}" width="${d(Z)}" height="${d(M)}" fill="var(--_a)"${it}/>`+De(V.label,ae+Z/2,z+M/2,` font-size="${s}" font-weight="var(--_hw)"`)+ne+"</g>"}if(U=A+Mi,D.length>0){let V=K+(w-L)/2,ne=U+16,ae="";for(let Z of D){let Q=ne+Z.y+Z.h/2;ae+=`<g class="pele-legend-item" data-id="${Fe(Z.name)}"><circle cx="${d(V+Z.x+Er)}" cy="${d(Q)}" r="${Er}" fill="${lt(u.get(Z.name)??0)}"/>`+De(Z.label,V+Z.x+2*Er+6+Z.label.width/2,Q,"")+"</g>"}$+=`<g class="pele-legend" font-size="${s}">${ae}</g>`,U=ne+B}}let j=Math.ceil(ee+2*c),v=Math.ceil(Math.max(U,c)+c),k=De(I,c+ee/2,c+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+$;return{svg:Ze("journey",j,v,o,n,e,k),width:j,height:v,links:[]}}function IC(e,t){let n=t.fontSize??16,r=Math.round(n*.875),o=t.measurer??et(t.fontFamily),s=t.padding??8,a=Math.max(140,(t.maxWidth??320)-2*s),i=Mn(e.title,o,n,a,1),c=Hc(e.tasks).filter(E=>E!==""),l=new Map(c.map((E,w)=>[E,w])),f=s+(i.height?i.height+16:0),p,u="",m=i.width;e.tasks.forEach((E,w)=>{if(E.section!==p){p=E.section;let I=Mn(p,o,n,a-16,1);I.height&&(u+=De(I,s+8+I.width/2,f+I.height/2,' class="pele-cluster-label" font-weight="var(--_hw)"'),m=Math.max(m,I.width+16),f+=I.height+8)}let S=Mn(E.task,o,r,a-72),O=E.people.filter(I=>I!=="").map(I=>({name:I,label:Mn(I,o,r,a-44)})),D=Math.max(S.height,42),L=2*Jr+D;for(let I of O)L+=Math.max(16,I.label.height)+4;let B=Math.max(a,S.width+72);u+=`<g class="pele-node pele-journey-step" data-id="${w}"><rect x="${d(s)}" y="${d(f)}" width="${d(B)}" height="${d(L)}" fill="var(--_s)" stroke="var(--_b)"${it}/>`,u+=De(S,s+Xc+S.width/2,f+Jr+S.height/2,' class="pele-label"');let W=s+B-28;u+=wy(W,f+Jr+Mi,E.score>3?"happy":E.score<3?"sad":"neutral"),Number.isNaN(E.score)||(u+=`<text class="pele-journey-score" x="${d(W)}" y="${d(f+Jr+2*Mi+r)}" font-size="${r}" text-anchor="middle">${d(Math.min(5,Math.max(1,E.score)))}</text>`);let Y=f+Jr+D+4;for(let I of O){let X=Math.max(16,I.label.height);u+=`<circle class="pele-actor" cx="${d(s+16)}" cy="${d(Y+X/2)}" r="${Er}" fill="${lt(l.get(I.name))}"/>`+De(I.label,s+28+I.label.width/2,Y+X/2,` class="pele-journey-actor" font-size="${r}"`),Y+=X+4}u+="</g>",f+=L,w+1<e.tasks.length&&(u+=`<path class="pele-edge" d="M${d(s+B/2)},${d(f)}v16" fill="none" stroke="var(--_l)"/>`),f+=16,m=Math.max(m,B)});let h=Math.ceil(m+2*s),b=Math.ceil(Math.max(s+i.height,f-(e.tasks.length?16:0))+s),x=De(i,h/2,s+i.height/2,' class="pele-title" font-weight="var(--_tw)"')+u;return{svg:Ze("journey",h,b,n,t,e,x),width:h,height:b,links:[]}}var Ty={type:"journey",parse(e,t,n){let r=new Yc;return r.title=n,Sy(e,r),r},render:Ry};var kC=["1","INVALID","SPACELINE","NL","EOF","","SPACELIST","ICON","CLASS","NODE_DSTART","NODE_ID","NODE_DESCR","NODE_DEND","SHAPE_DATA"];function Cy(e,t){return e===5?t?"KANBAN":"MINDMAP":kC[e]}var es={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6};function qc(e,t){switch(e){case"[":return es.RECT;case"(":return t===")"?es.ROUNDED_RECT:es.CLOUD;case"((":return es.CIRCLE;case")":return es.CLOUD;case"))":return es.BANG;case"{{":return es.HEXAGON;default:return es.DEFAULT}}var LC=/\s+/y,uf=/.+/y,$C=/[^([\n){}]+/y,DC=/[^([\n){}@]+/y,OC=/[^)\](}]+/y,vC=/[^`"]+/y,PC=/[^}^"]+/y,BC=/\n\s*/g;function Ny(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 ff(e,t){let n=e.length,r=[],o=[],s=[],a=t?"kanban":"mindmap",i=t?DC:$C,c=0,l=0,f=-1,p=(b,x,E)=>{r.push(b),o.push(x),s.push(l),l=E},u=(b,x,E)=>{p(b,e.slice(l,x),x),c=E},m=(b,x)=>(b.lastIndex=x,b.test(e)?b.lastIndex:-1),h=b=>{let x=e.indexOf(b,l);return x===-1?n:x};for(;l<n;){let b=e.charCodeAt(l),x=e.charCodeAt(l+1),E;if(c===0){let w=b<=32||b>=160?Math.max(m(LC,l),l):l;if(t&&b===64&&x===123)p(13,"",l+2),c=6;else if(e.charCodeAt(w)===37&&e.charCodeAt(w+1)===37)u(2,m(uf,w),0);else if(w>l)f<l&&(f=h(`
`)),f>=w?u(6,w,0):(E=e.lastIndexOf(`
`,w-1))>l?u(2,E+1,0):u(3,l+1,0);else if(Ny(e,l,a)&&!Qe(e.charCodeAt(l+a.length)))u(5,l+a.length,0);else if(b===58&&x===58&&e.charCodeAt(l+2)===58)l+=3,c=1;else if(b===58&&x===58&&Ny(e,l+2,"icon")&&e.charCodeAt(l+6)===40)l+=7,c=2;else if(b===45&&x===41||b===40&&(x===45||x===40)||(b===41||b===123)&&x===b)u(9,l+2,3);else if(b===41||b===40||b===91)u(9,l+1,3);else if((E=m(i,l))!==-1)u(10,E,0);else break}else if(c===3)b===34?(c=x===96?5:4,l+=x===96?2:1):b===41||b===40?u(12,x===b||b===40&&x===45?l+2:l+1,0):b===93?u(12,l+1,0):b===125&&x===125||b===45&&x===41?u(12,l+2,0):u(11,m(b===125?uf:OC,l),3);else if(c===4)b===34?(l++,c=3):u(11,h('"'),4);else if(c===5)if(b===96&&x===34)l+=2,c=3;else if((E=m(vC,l))!==-1)u(11,E,5);else break;else if(c===1)if((E=m(uf,l))!==-1)u(8,E,0);else if(b===10)l++,c=0;else break;else if(c===2)b===41?(l++,c=0):u(7,h(")"),2);else if(c===6)if(b===34)u(13,l+1,7);else if(b===125)l++,c=0;else if((E=m(PC,l))!==-1)u(13,E,6);else break;else b===34?u(13,l+1,6):(E=h('"'),p(13,e.slice(l,E).replace(BC,"<br/>"),E))}return l<n?p(1,"",l):(c===0&&p(4,"",n),p(0,"",n)),{types:r,texts:o,starts:s}}var Ws="'SPACELINE', 'NL', 'EOF'",My=new Uint8Array(14);for(let e of[2,6,7,8,9,10])My[e]=1;function Ii(e){return e===2||e===3||e===4}function Qc(e,t,n){let r=n?"kanban":"mindmap",{types:o,texts:s,starts:a}=ff(e,n),i=n?", 'SHAPE_DATA'":"",c=0,l=u=>{let m=o[c];throw m===1?st(r,e,a[c],"",!0):st(r,e,a[c],`Expecting ${u}, got '${Cy(m,n)}'`)},f=`'${Cy(5,n)}'`;if(o[c]===2){for(c++;o[c]===2||o[c]===3;)c++;o[c]!==5&&l(`'SPACELINE', 'NL', ${f}`)}else o[c]!==5&&l(`'SPACELINE', ${f}`);c++;let p="'SPACELINE', 'NL', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'";for(o[c]===3&&(c++,p="'SPACELINE', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'");;){let u=o[c],m=0,h=u===6;if(h&&(m=s[c++].length,u=o[c]),u===10||u===9){let b,x,E=0;if(u===10&&(b=s[c++]),o[c]===9){let w=s[c++];o[c]!==11&&l("'NODE_DESCR'"),x=s[c++],o[c]!==12&&l("'NODE_DEND'");let S=s[c++];!Ii(o[c])&&o[c]!==13&&l(Ws+i),E=t.getType(w,S)}else!Ii(o[c])&&o[c]!==13&&l(Ws+", 'NODE_DSTART'"+i),x=b;if(o[c]===13){let w=s[c++];for(;o[c]===13;)w+=s[c++];Ii(o[c])||l(Ws+i),t.addNode(m,b??x,x,E,w)}else t.addNode(m,b??x,x,E)}else if(u===7||u===8){let b=s[c++];Ii(o[c])||l(Ws),t.decorateNode(u===7?{icon:b}:{class:b})}else h?Ii(u)||l(Ws+", 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'"):u===2?Ii(o[++c])||l(Ws):l(p);for(c++;o[c]===3||o[c]===4;)c++;if(o[c]===0)return;My[o[c]]===0&&l(Ws+", 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'")}}var Zc=class{constructor(){de(this,"type","kanban");de(this,"title");de(this,"sections",[]);de(this,"getType",qc);de(this,"last");de(this,"sectionLevel",0);de(this,"misplaced")}addNode(t,n,r,o,s){let a={id:n,level:t,label:r};if(s!==void 0){let c=s.includes(`
`)?s+`
`:`{
`+s+`
}`,l;try{l=Vn(c)}catch(f){throw new ze(`Metadata of "${a.id}" is not valid YAML. ${f.message}`,"syntax",{type:"kanban"})}if(l!==null&&typeof l=="object"&&!Array.isArray(l)){let f=l.shape?String(l.shape):"";if(f!==f.toLowerCase()||f.includes("_"))throw new ze(`No such shape: ${f}. 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 ze(`Items without section detected, found section ("${this.misplaced.label}")`,"semantic",{type:"kanban"});let i=this.sections;if(i.length===0&&(this.sectionLevel=t),this.last=a,t===this.sectionLevel){let c=a;c.items=[],i.push(c)}else i[i.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 Iy(e,t){Qc(e,t,!0)}function Uo(e,t,n,r,o){return`<svg class="pele-icon" data-icon="${Fe(e)}" x="${d(t)}" y="${d(n)}" width="${d(r)}" height="${d(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${o?.(e)??""}</svg>`}var Ar=12,xr=8,tr=10,pf=8,FC=4,Go=6,WC=new Map([["very high",`stroke="${ao}"`],["high",`stroke="${ao}" opacity="0.5"`],["low",'stroke="var(--_m)" opacity="0.5"'],["very low",'stroke="var(--_m)"']]);function Jc(e,t,n,r,o,s=0){let a=We(e,t,n,r,o,s);if(a.width<=o)return a;let i=[],c=[],l=0,f=[],p=0,u=()=>{i.push(f),c.push(p),l=Math.max(l,p),f=[],p=0};for(let h=0;h<a.lines.length;h++){if(a.widths[h]<=o){f=a.lines[h],p=a.widths[h],u();continue}for(let b of a.lines[h]){if(b.icon!==void 0||b.math){p>0&&p+b.width>o&&u(),f.push(b),p+=b.width;continue}let x="",E=p;for(let w of b.text){let S=n.width(w,r,b.style);p>0&&p+S>o&&(x&&f.push({text:x,style:b.style,width:p-E}),u(),x="",E=0),x+=w,p+=S}x&&f.push({text:x,style:b.style,width:p-E})}u()}let m={...a,lines:i,widths:c,width:l,height:i.length*a.lineHeight};return a.heights?po(m):m}function Yo(e,t,n,r,o,s=!1){let a="";for(let i=0;i<e.lines.length;i++){let c=e.lines[i],l=n+lr(e,i);if(c.length===1&&c[0].icon===void 0&&c[0].math===void 0)a+=`<text${jn(r,c[0].style)} x="${d(t)}" y="${d(l+e.size*.35)}"${s?' text-anchor="end"':""}>${je(c[0].text)}</text>`;else{let f=e.widths[i];a+=De(dr(e,i),t+(s?-f:f)/2,l,r,o)}}return a}var ki=e=>!!e&&ni(e)!=="";function ky(e,t,n){let r=n.fontSize??16,o=Math.round(r*.875),s=Math.round(r*1.5),a=Math.round(o*1.5),i=n.measurer??et(n.fontFamily),c=n.padding??8,l=n.icons,f=t.kanban??{},p=f.sectionWidth,u=o*1.25,m=0,h=(k,F,H)=>{if(!(!k||!k.includes("$$")))for(let G of We(k,!0,i,F,1/0).lines)for(let se of G)se.math&&(m=Math.max(m,se.math.width+H))};for(let k of e.sections){let F=i.width(String(k.items.length),o,0);h(k.label,r,2*xr+8+F+12+(ki(k.icon)?u+Go:0));for(let H of k.items){let G=2*(xr+tr);h(H.label,o,G+(ki(H.icon)?u+Go:0)),h(H.ticket,o,G),h(H.assigned,o,G)}}let b=Math.max(typeof p=="number"&&p>0?Math.min(Math.max(p,80),2e3):200,Math.ceil(m)),x=n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*c:1/0,E=e.sections.length,w=E*(b+Ar)-Ar<=x,S=w?Math.max(E,1):Math.max(1,Math.floor((x+Ar)/(b+Ar))),O=w?b:Math.max(Math.min(b,x),Math.min(Math.floor((x+Ar)/S)-Ar,b*2),Math.ceil(m)),D=typeof f.ticketBaseUrl=="string"?f.ticketBaseUrl:"",L=O-2*xr,B=L-2*tr,W=[],Y=e.sections,I=[],X=[],ee=[],K=s,z=[];for(let k of Y){let F=i.width(String(k.items.length),o,0),H=F+12+(ki(k.icon)?u+Go:0),G=Jc(k.label,!0,i,r,L-8-H,1);K=Math.max(K,G.height),X.push(F),I.push(G);let se=[],q=0;for(let P of k.items){let V=Jc(P.label,!0,i,o,B-(ki(P.icon)?u+Go:0)),ne=Jc(P.ticket,!1,i,o,B),ae=Jc(P.assigned,!1,i,o,B),Z=ne.width+ae.width+8>B?ne.height+ae.height:Math.max(ne.height,ae.height),Q=2*tr+Math.max(V.height,a)+(Z?FC+Z:0);se.push({item:P,label:V,ticket:ne,assigned:ae,meta:Z,height:Q}),q+=Q+pf}ee.push(se),z.push(q)}K+=2*xr;let C=[],M=[];for(let k=0,F=0;k<Y.length;k+=S){let H=pf;for(let G=k;G<Math.min(k+S,Y.length);G++)H=Math.max(H,z[G]);M.push(F),C.push(K+H),F+=K+H+Ar}let T=C.length>0?M[M.length-1]+C[C.length-1]:0,g=hn(e.title,i,r,Tt(n)),_=g.height>0?g.height+16:0,y=Math.max(Math.min(Y.length,S)*(O+Ar)-Ar,0),R=Math.max(y,g.width),A=c+(R-y)/2,N=O-xr-4,$="";for(let k=0;k<Y.length;k++){let F=Y[k],H=Math.floor(k/S),G=`<rect width="${O}" height="${d(C[H])}" fill="var(--_s)"${it}/>`+Yo(I[k],xr+4,xr,' class="pele-cluster-label" font-weight="var(--_hw)"',l)+`<text class="pele-count" x="${N}" y="${d(xr+s/2+o*.35)}" text-anchor="end" font-size="${o}" fill="var(--_m)">${F.items.length}</text>`;ki(F.icon)&&(G+=Uo(F.icon,N-X[k]-Go-u,xr+(s-u)/2,u,l));let se=K;for(let q of ee[k]){let P=q.item,V=(P.priority??"").trim().toLowerCase(),ne=WC.get(V),ae=`<rect width="${L}" height="${d(q.height)}" fill="var(--_bg)" stroke="var(--_b)"${it}/>`;ne!==void 0&&(ae+=`<path class="pele-priority" d="M2.5,5V${d(q.height-5)}" fill="none" ${ne} stroke-width="3" stroke-linecap="round"/>`),ae+=Yo(q.label,tr,tr,' class="pele-label"',l),ki(P.icon)&&(ae+=Uo(P.icon,L-tr-u,tr+(a-u)/2,u,l));let Z=q.height-tr;if(P.ticket){let Q=Z-q.meta,ie=D?Cr(Fn(D.replace("#TICKET#",()=>P.ticket)),n):void 0;ie===void 0?ae+=Yo(q.ticket,tr,Q,' class="pele-ticket" fill="var(--_m)"',l):(ae+=`<a href="${je(ie)}" target="_blank"${Nr(n)}>`+Yo(q.ticket,tr,Q,' class="pele-ticket" fill="var(--_c)"',l)+"</a>",W.push({id:P.id,href:ie,internal:!1}))}P.assigned&&(ae+=Yo(q.assigned,L-tr,Z-q.assigned.height,' class="pele-assigned" fill="var(--_m)"',l,!0)),G+=`<g class="pele-node pele-card${ne===void 0?"":" pele-priority-"+V.replace(" ","-")}${Rt(P.cssClasses??"")}" data-id="${Fe(P.id)}" transform="translate(${xr},${d(se)})" font-size="${o}">${ae}</g>`,se+=q.height+pf}$+=`<g class="pele-cluster pele-column${Rt(F.cssClasses??"")}" data-id="${Fe(F.id)}" transform="translate(${d(A+k%S*(O+Ar))},${d(c+_+M[H])})">${G}</g>`}let U=Math.ceil(R+2*c),j=Math.ceil(T+_+2*c),v=De(g,U/2,c+g.height/2,' class="pele-title" font-weight="var(--_tw)"')+$;return{svg:Ze("kanban",U,j,r,n,{},v),width:U,height:j,links:W}}var Ly={type:"kanban",math:!0,parse(e,t,n){let r=new Zc;return r.title=n,Iy(e,r),r},render:ky};var UC=11,el=class{constructor(){de(this,"type","mindmap");de(this,"title");de(this,"nodes",[]);de(this,"getType",qc);de(this,"baseLevel",0);de(this,"open",[])}addNode(t,n,r,o){let s=this.nodes.length===0;s&&(this.baseLevel=t),t-=this.baseLevel;let a=this.open,i=a.length;for(;i>0&&a[i-1].level>=t;)i--;let c=a[i-1];if(!c&&!s)throw new ze(`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:o,children:[],isRoot:s};c&&(l.section=c.isRoot?c.children.length%UC:c.section,c.children.push(l)),a.length=i,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 $y(e,t){Qc(e,t,!1)}var GC=["","rounded","rect","circle","cloud","bang","hex"],Dy="stadium",YC=36,HC=8,KC=18,zC=52,Oy=28,vy=6,VC=12,jC=.22,hf=6,mf=28,Py=12,By=8,Fy=10;function XC(e,t,n,r){if(e.lines.length<2)return De(e,t+e.width/2,n,' class="pele-label"',r);let o="",s=n-e.height/2;for(let a=0;a<e.lines.length;a++)o+=De(dr(e,a),t+e.widths[a]/2,s+lr(e,a),' class="pele-label"',r);return o}function Wy(e,t,n){return $t(n,r=>qC(e,t,n,r))}function qC(e,t,n,r){let o=n.fontSize??16,s=n.measurer??et(n.fontFamily),a=n.padding??8,i=n.icons,c=t.mindmap?.maxNodeWidth,l=typeof c=="number"&&c>0?Math.min(c,2e3):200,f=o*1.25,p=e.nodes,u=p.length,m=new Int32Array(u),h=new Int32Array(u);for(let q=0;q<u;q++)for(let P of p[q].children)m[P.id]=q,h[P.id]=h[q]+1;let b=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*a:1/0,x=new Array(u),E=new Array(u),w=new Float64Array(u),S=new Float64Array(u),O=new Float64Array(u),D=new Float64Array(u),L=new Uint8Array(u);for(let q=0;q<u;q++){let P=p[q];L[q]=P.icon!==void 0&&ni(P.icon)!==""?1:0;let V=Math.min(l,Math.max(72,b-h[q]*mf-2*vy-(L[q]?f+hf:0))),ne=x[q]=We(P.descr,!0,s,o,V),ae=ne.width+(L[q]?f+(ne.width>0?hf:0):0),Z=Math.max(ne.height,Math.round(o*1.5)),Q=GC[P.type]||(q===0?Dy:"");if(r&&q===0&&Q!=="rect"&&Q!=="rounded"&&(Q=Dy),E[q]=Q,Q===""){let ie=P.children.length>0;w[q]=ae+2*(ie?VC:vy),S[q]=Z+(ie?6:0),D[q]=S[q]/2}else{let ie=Hr(Q,ae,Z);w[q]=ie.w,S[q]=ie.h,O[q]=ie.dy,D[q]=ie.h/2}}let B=new Float64Array(u),W=new Float64Array(u),Y=new Float64Array(u),I=new Float64Array(u),X=0,ee=(q,P,V,ne)=>{let ae=0,Z=0;for(let me=P;me<V;me++){let re=q[me].id;W[re]=ae,Z=q[me].children.length>0||me+1<V&&q[me+1].children.length>0?Math.max(ne,KC):ne,ae+=B[re]+Z}X=ae-Z;let Q=q[P].id,ie=q[V-1].id;return(W[Q]+Y[Q]+D[Q]+W[ie]+Y[ie]+D[ie])/2};for(let q=u-1;q>0;q--){let P=p[q].children;if(P.length===0){B[q]=S[q];continue}let V=ee(P,0,P.length,HC)-D[q],ne=Math.min(0,V);B[q]=Math.max(X,V+S[q])-ne,Y[q]=V-ne,I[q]=-ne}let K=new Float64Array(u),z=new Float64Array(u),C=new Float64Array(u),M=new Int8Array(u),T=new Float64Array(u);if(r){let q=0;for(let P=0;P<u;P++)P>0&&m[P]===0&&(q+=Fy),K[P]=h[P]*mf+w[P]/2,z[P]=q,q+=S[P]+Fy}else if(u>0){let q=p[0].children,P=q.length,V=0;for(let Q of q)V+=B[Q.id];let ne=P,ae=1/0,Z=0;for(let Q=1;Q<P;Q++){Z+=B[q[Q-1].id];let ie=Math.abs(2*Z-V+(2*Q-P)*Oy);ie<ae&&(ae=ie,ne=Q)}for(let Q=0,ie=ne,me=1;Q<P;Q=ie,ie=P,me=-1){let re=ee(q,Q,ie,Oy);for(let te=Q;te<ie;te++){let he=q[te].id;C[he]=W[he]-re,M[he]=me}}z[0]=-S[0]/2;for(let Q=0;Q<u;Q++){Q>0&&(z[Q]=C[Q]+Y[Q]);for(let ie of p[Q].children){let me=ie.id;Q>0&&(M[me]=M[Q],C[me]=C[Q]+I[Q]+W[me]),K[me]=K[Q]+M[me]*(w[Q]/2+(Q>0?YC:zC)+w[me]/2)}}}let g=0,_=0,y=0,R=0,A="",N="",$="",U="",j=q=>{$!==""&&(A+=`<g class="pele-branch pele-section-${q??0}"><g class="pele-edges" fill="none" stroke="${U}" stroke-width="1.5">${N}</g>${$}</g>`,N=$="")};for(let q=1;q<=u;q++){let P=q%u,V=p[P],ne=E[P],ae=x[P],Z=K[P],Q=z[P];if(g=Math.min(g,Z-w[P]/2),_=Math.max(_,Z+w[P]/2),y=Math.min(y,Q),R=Math.max(R,Q+S[P]),(P===0||m[P]===0)&&j(p[q-1].section),P>0&&r){m[P]===0&&(U=lt(V.section??0));let oe=m[P],ge=oe===0?Math.min(Math.max(Py,S[0]/2),mf-By):Py,Ee=K[oe]-w[oe]/2+Math.min(ge,w[oe]/2),be=T[oe]||z[oe]+S[oe],Re=Z-w[P]/2+(ne?Mr(ne,w[P],S[P],3):0),Le=Q+D[P],ue=Math.max(0,Math.min(By,Re-Ee,Le-be));T[oe]=Le-ue,N+=`<path class="pele-edge" d="M${d(Ee)},${d(be)}V${d(Le-ue)}Q${d(Ee)},${d(Le)} ${d(Ee+ue)},${d(Le)}H${d(Re)}"/>`}else if(P>0){m[P]===0&&(U=lt(V.section??0));let oe=m[P],ge=M[P],Ee=ge>0?1:3,be=K[oe]+ge*(w[oe]/2-(E[oe]?Mr(E[oe],w[oe],S[oe],Ee):0)),ye=z[oe]+D[oe],Le=Z-ge*w[P]/2+(ne?ge*Mr(ne,w[P],S[P],4-Ee):0),ue=Q+D[P],fe=d((be+Le)/2);N+=`<path class="pele-edge" d="M${d(be)},${d(ye)}C${fe},${d(ye)} ${fe},${d(ue)} ${d(Le)},${d(ue)}"/>`}let ie=!ne&&V.children.length>0,me=` fill="${U}" fill-opacity="${jC}" stroke="${U}"`,re="";ne?re=P>0?Qn(ne,w[P],S[P],me,` stroke="${U}"`):Qn(ne,w[P],S[P],' fill="var(--_s)" stroke="var(--_b)"',' stroke="var(--_b)"'):ie&&(re=`<rect x="${d(-w[P]/2)}" y="${d(-S[P]/2)}" width="${d(w[P])}" height="${d(S[P])}" rx="${d(S[P]/2)}"${me}/>`);let te=0;V.icon&&L[P]&&(te=(f+(ae.width>0?hf:0))/2,re+=Uo(V.icon,-te-ae.width/2,O[P]-f/2,f,i));let he=`<g class="pele-node pele-shape-${ne||(ie?"branch":"text")}${P>0?"":" pele-root"}${Rt(V.class??"")}" data-id="${Fe(V.nodeId)}" transform="translate(${d(Z)},${d(Q+S[P]/2)})">`+re+(r&&!ne?XC(ae,te-ae.width/2,O[P],i):De(ae,te,O[P],' class="pele-label"',i))+"</g>";P>0?$+=he:A+=he}let v=hn(e.title,s,o,Tt(n)),k=v.height>0?v.height+16:0,F=Math.max(_-g,v.width),H=Math.ceil(F+2*a),G=Math.ceil(R-y+k+2*a),se=De(v,H/2,a+v.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(a-g+(F-_+g)/2)},${d(a+k-y)})">${A}</g>`;return{svg:Ze("mindmap",H,G,o,n,{},se),width:H,height:G,links:[]}}var Uy={type:"mindmap",math:!0,parse(e,t,n){let r=new el;return r.title=n,$y(e,r),r},render:Wy};var QC=1e4;function Li(e,t,n,r,o){let s=e.packet?.[t];return typeof s=="number"&&s>=r?Math.min(s,o):n}function gf(e){return new ze(e,"semantic",{type:"packet"})}function Gy(e,t,n){let r=Math.floor(Li(t,"bitsPerRow",32,1,4096)),o=[],s=-1,a=[],i=1;for(let c of e.blocks){let{start:l,end:f,bits:p}=c;if(l!==void 0&&f!==void 0&&f<l)throw gf(`Packet block ${l} - ${f} is invalid. End must be greater than start.`);if(l??=s+1,l!==s+1)throw gf(`Packet block ${l} - ${f??l} is not contiguous. It should start from ${s+1}.`);if(p===0)throw gf(`Packet block ${l} is invalid. Cannot have a zero bit field.`);for(f??=l+(p??1)-1,p??=f-l+1,s=f;a.length<=r+1&&o.length<QC;){let u=i*r-1;if(f<=u){a.push({start:l,end:f,bits:p,label:c.label}),f===u&&(o.push(a),a=[],i++);break}a.push({start:l,end:u,bits:u-l,label:c.label}),o.push(a),a=[],i++,l=u+1,p=f-l}}return a.length>0&&o.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,`
`):void 0,bitsPerRow:r,rows:o}}var Yy=[{name:"packet-beta",pattern:"packet-beta"},qt("packet"),{name:"-",pattern:"-",longer:[Ut]},{name:"+",pattern:"+"},{name:":",pattern:":"},tn,zt,Vt,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Cn,bn,yn,Ut,jt,Xt];function Hy(e){let t=new Bt(Wt(e,Yy,"packet"),Yy,"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=Ht(t.take()),r();break;case 6:n.accTitle=Yt(t.take()),r();break;case 7:n.title=Gt(t.take()),r();break;case 8:case 3:{let o={$type:"PacketBlock",label:""};t.accept(3)?o.bits=Number(t.expect(8)):(o.start=Number(t.take()),t.accept(2)&&(o.end=Number(t.expect(8)))),t.expect(4),o.label=on(t.expect(9)),n.blocks.push(o),r();break}default:t.fail("a field, a title, or a line break")}return n}function Ho(e,t,n,r,o,s=0){if(e===""||t<=0)return;let a=o.width(e,n,s);if(a<=t)return{text:e,size:n,width:a};let i=Math.max(r,Math.floor(n*t/a));for(;i>=r;){if(a=o.width(e,i,s),a<=t)return{text:e,size:i,width:a};i--}let c=Array.from(e),l=0,f=c.length-1;for(;l<f;){let u=l+f+1>>1;o.width(c.slice(0,u).join("").trimEnd()+"…",r,s)<=t?l=u:f=u-1}if(l===0)return;let p=c.slice(0,l).join("").trimEnd()+"…";return a=o.width(p,r,s),a<=t?{text:p,size:r,width:a}:void 0}function Ky(e,t,n){return $t(n,r=>ZC(e,t,n,r))}function ZC(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=Math.round(o*.625),i=n.measurer??et(n.fontFamily),c=n.padding??8,l=t.packet??{},f=Li(t,"rowHeight",32,1,400),p=Li(t,"bitWidth",32,1,400),u=Li(t,"paddingX",5,0,400),m=Li(t,"paddingY",5,0,400),h=l.showBits!==!1,b=l.bitOrder==="descending",x=e.bitsPerRow,E=e.rows;if(r){let _=Math.max(1,Math.floor(((n.maxWidth??320)-2*c)/Math.min(p,18)));x=Math.min(x,Math.max(8,2**Math.floor(Math.log2(_))));let y=e.rows[e.rows.length-1],R=y?.[y.length-1]?.end??0;Math.ceil((R+1)/x)>1e4&&(x=e.bitsPerRow),p=Math.min(p,Math.max(18,((n.maxWidth??320)-2*c)/x));let A=$=>$.bits===$.end-$.start,N=[];for(let $ of e.rows)for(let U of $){let j=N[N.length-1];j&&A(j)&&A(U)&&j.label===U.label&&U.start===j.end+1&&U.start%e.bitsPerRow===0?(j.end=U.end,j.bits=j.end-j.start):N.push({...U})}E=[];for(let $ of N)for(let U=$.start;U<=$.end;){let j=Math.min($.end,(Math.floor(U/x)+1)*x-1),v=Math.floor(U/x);(E[v]??(E[v]=[])).push({...$,start:U,end:j}),U=j+1}}let w=new Map;if(r)for(let _ of E)for(let y of _){let R=Math.max(1,(y.end-y.start+1)*p-Math.min(u,p-1)-6),A=Ms(yt(y.label).trim(),i,s,R);w.set(y,A)}let S=h?a+4:0,O=E.map(_=>{let y=f;if(r)for(let R of _)y=Math.max(y,w.get(R).height+10);return y}),D=[],L=0;for(let _ of O)D.push(L),L+=S+_+m;E.length&&(L-=m);let B=Math.min(u,p-1),W=E.length>0?x*p-B:0,Y=We(e.title,!1,i,o,r?Tt(n):4e3,1),I=Y.height>0?Y.height+(L>0?12:0):0,X=new Map,ee=(_,y)=>{let R=X.get(_);return R||X.set(_,R=new Map),R.has(y)||R.set(y,Ho(yt(_).trim(),y,s,Math.round(o*.5),i)),R.get(y)},K=c+Math.max(0,(Y.width-W)/2),z="",C="";E.forEach((_,y)=>{let R=c+D[y]+S,A=O[y];for(let N of _){let $=N.end-N.start+1,U=N.start%x,j=K+(b?x-U-$:U)*p,v=$*p-B,k=r?void 0:ee(N.label,v-6);if(z+=`<g class="pele-node" data-id="${N.start}-${N.end}"><rect x="${d(j)}" y="${d(R)}" width="${d(v)}" height="${d(A)}" fill="var(--_s)" stroke="var(--_b)"${it}/>`+(r?De(w.get(N),j+v/2,R+A/2,""):k&&k.size<=A?`<text x="${d(j+v/2)}" y="${d(R+A/2+k.size*.35)}"${k.size===s?"":` font-size="${d(k.size)}"`}>${je(k.text)}</text>`:"")+"</g>",!h)continue;let F=b?N.end:N.start,H=b?N.start:N.end;$===1?C+=`<text x="${d(j+v/2)}" y="${d(R-4)}" text-anchor="middle">${F}</text>`:C+=`<text x="${d(j)}" y="${d(R-4)}">${F}</text><text x="${d(j+v)}" y="${d(R-4)}" text-anchor="end">${H}</text>`}});let M=Math.ceil(Math.max(W,Y.width)+2*c),T=Math.ceil(L+I+2*c),g=(z?`<g class="pele-packet-fields" font-size="${s}" text-anchor="middle">${z}</g>`:"")+(C?`<g class="pele-packet-bits" font-size="${a}" fill="var(--_m)">${C}</g>`:"")+De(Y,M/2,T-c-Y.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:Ze("packet",M,T,o,n,e,g),width:M,height:T,links:[]}}var zy={type:"packet",parse:(e,t,n)=>Gy(Hy(e),t,n),render:Ky};function Vy(e,t){let n=new Map;for(let{label:r,value:o}of e.sections){if(o<0)throw new ze(`"${r}" has invalid value: ${o}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,"semantic",{type:"pie"});n.has(r)||n.set(r,o)}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,`
`):void 0,showData:e.showData,sections:n}}function jy(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function JC(){let e=0,t=0,n=-1;return(r,o)=>{let s=r.charCodeAt(o)===45?o+1:o;if((s<e||s>=t)&&(e=s,t=jy(r,s),n=-1,t>s&&r.charCodeAt(t)===46)){let a=jy(r,t+1),i=a-t-1;i>0&&r.charCodeAt(a)!==46?n=a:i>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 Xy=[qt("showData"),qt("pie"),{name:":",pattern:":"},{name:"NUMBER_PIE",pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:JC,first:"-0123456789"},tn,zt,Vt,Cn,bn,yn,Ut,jt,Xt];function qy(e){let t=new Bt(Wt(e,Xy,"pie"),Xy,"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=Ht(t.take()),r();break;case 5:n.accTitle=Yt(t.take()),r();break;case 6:n.title=Gt(t.take()),r();break;case 7:{let o=on(t.take());t.expect(2);let s=Number(t.expect(3));n.sections.push({$type:"PieSection",label:o,value:s}),r();break}default:t.fail("a section, a title, or a line break")}return n}var eN=120,Ko=12,bf=26,yf=32,Qy=28;function Ef(e,t){return e.pie?.[t]}function $i(e,t){return`${d(Math.sin(e)*t)},${d(-Math.cos(e)*t)}`}function tN(e,t,n,r){if(t-e>=Math.PI*2-1e-9){let s=(a,i)=>`M0,${d(-a)}A${d(a)},${d(a)} 0 1 ${i} 0,${d(a)}A${d(a)},${d(a)} 0 1 ${i} 0,${d(-a)}Z`;return s(n,1)+(r>0?s(r,0):"")}let o=t-e>Math.PI?1:0;return r<=0?`M0,0L${$i(e,n)}A${d(n)},${d(n)} 0 ${o} 1 ${$i(t,n)}Z`:`M${$i(e,n)}A${d(n)},${d(n)} 0 ${o} 1 ${$i(t,n)}L${$i(t,r)}A${d(r)},${d(r)} 0 ${o} 0 ${$i(e,r)}Z`}function Zy(e,t,n){return Kr(n,eN*2,140,(r,o)=>nN(e,t,n,r/2,o))}function nN(e,t,n,r,o){let s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??et(n.fontFamily),c=n.padding??8,l=Ef(t,"textPosition"),f=typeof l=="number"&&l>=0&&l<=1?l:.75,p=Ef(t,"donutHole"),u=typeof p=="number"&&p>0&&p<=.9?p*r:0,m=String(Ef(t,"legendPosition")??"right"),h=o&&(m==="left"||m==="right")?"bottom":m,b=[...e.sections],x=0;for(let[,H]of b)x+=H;let E=b.map(([H,G])=>We(e.showData?`${H} [${G}]`:H,!1,i,a,4e3)),w=0;for(let H of E)w=Math.max(w,H.width);w+=E.length>0?Ko+8:0;let S=E.length*bf,O=We(e.title,!1,i,s,Tt(n),1),D=O.height>0?O.height+16:0,L=b.map(([,H])=>{let G=x>0?H/x:0;return G*100>=1&&(G*100).toFixed(0)!=="0"?G:0}),B=L.map(H=>H===0||H>=.5?!1:2*r*f*Math.sin(H*Math.PI)<i.width((H*100).toFixed(0)+"%",a,0)+6),W=B.includes(!0)?Qy:0,Y=h==="left"||h==="right"||h==="center"?h:"",I=h==="top"||h==="bottom",X=(r+W)*2,ee=X,K=X;Y==="left"||Y==="right"?(ee+=w>0?yf+w:0,K=Math.max(K,S)):I&&(ee=Math.max(ee,w),K+=S>0?20+S:0),ee=Math.max(ee,O.width);let z=c+(Y==="left"?w+yf+X/2:Y==="right"?X/2:ee/2),C=c+D,M=C+(h==="top"?S+20+X/2:I?X/2:K/2),T="",g="",_="",y=0,R=r+Qy/2,A=[],N=(H,G,se)=>A.every(q=>Math.abs(H-q.x)>=(se+q.width)/2+2||Math.abs(G-q.y)>=a+2);b.forEach(([H],G)=>{let se=L[G];if(se===0)return;let q=y+se*Math.PI*2;T+=`<path class="pele-slice" data-id="${Fe(H)}" d="${tN(y,q,r,u)}" fill="${lt(G)}"/>`;let P=(y+q)/2,V=(se*100).toFixed(0)+"%";if(B[G]){let ne=i.width(V,a,0),ae=P;for(let ie=0;ie<360&&!N(Math.sin(ae)*R,-Math.cos(ae)*R,ne);ie++)ae+=2/R;let Z=Math.sin(ae)*R,Q=-Math.cos(ae)*R;A.push({x:Z,y:Q,width:ne}),_+=`<text x="${d(Z)}" y="${d(Q+a*.35)}">${V}</text>`}else{let ne=r*f;g+=`<text x="${d(Math.sin(P)*ne)}" y="${d(-Math.cos(P)*ne+a*.35)}">${V}</text>`}y=q}),T===""&&(T=`<circle class="pele-slice" r="${r}" fill="none" stroke="var(--_b)"/>`);let $="",U,j;Y==="right"?(U=z+X/2+yf,j=C+(K-S)/2):Y==="left"?(U=c,j=C+(K-S)/2):Y==="center"?(U=z-w/2,j=M-S/2):(U=c+(ee-w)/2,j=h==="top"?C:C+X+20),E.forEach((H,G)=>{let se=j+G*bf+bf/2;$+=`<g class="pele-legend-item" data-id="${Fe(b[G][0])}"><rect x="${d(U)}" y="${d(se-Ko/2)}" width="${Ko}" height="${Ko}" rx="2" fill="${lt(G)}"/>`+De(H,U+Ko+8+H.width/2,se,"")+"</g>"});let v=Math.ceil(ee+2*c),k=Math.ceil(K+D+2*c),F=De(O,v/2,c+O.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-slices" transform="translate(${d(z)},${d(M)})" stroke="var(--_bg)" stroke-width="1" stroke-linejoin="round">${T}</g>`+(g?`<g class="pele-slice-labels" transform="translate(${d(z)},${d(M)})" font-size="${a}" text-anchor="middle" fill="var(--_bg)">${g}</g>`:"")+(_?`<g class="pele-slice-labels" transform="translate(${d(z)},${d(M)})" font-size="${a}" text-anchor="middle">${_}</g>`:"")+($?`<g class="pele-legend" font-size="${a}">${$}</g>`:"");return{svg:Ze("pie",v,k,s,n,e,F),width:v,height:k,links:[]}}var Jy={type:"pie",parse:(e,t,n)=>Vy(qy(e),n),render:Zy};var rN=/^\d+$/,eE=/^#?([\dA-Fa-f]{6}|[\dA-Fa-f]{3})$/,sN=/^\d+px$/;function tl(e,t,n){return new ze(`value for ${e} ${t} is invalid, please use a valid ${n}`,"semantic",{type:"quadrantChart"})}function iN(e){let t=e.trim(),n=t.indexOf(":");if(n===-1)return[t,"undefined"];let r=t.slice(n+1).trimStart(),o=r.indexOf(":");return[t.slice(0,n).trimEnd(),o===-1?r:r.slice(0,o).trimEnd()]}function tE(e){let t={};for(let n of e){let[r,o]=iN(n);if(r==="radius"){if(!rN.test(o))throw tl(r,o,"number");t.radius=parseInt(o)}else if(r==="color"){if(!eE.test(o))throw tl(r,o,"hex code");t.color=o}else if(r==="stroke-color"){if(!eE.test(o))throw tl(r,o,"hex code");t.strokeColor=o}else if(r==="stroke-width"){if(!sN.test(o))throw tl(r,o,"number of pixels (eg. 10px)");t.strokeWidth=o}else throw new ze(`style named ${r} is not supported.`,"semantic",{type:"quadrantChart"})}return t}function Dr(e){return{text:e.text.trim(),type:e.type}}var nl=class{constructor(){de(this,"type","quadrantChart");de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"quadrants",[void 0,void 0,void 0,void 0]);de(this,"xAxisLeft");de(this,"xAxisRight");de(this,"yAxisBottom");de(this,"yAxisTop");de(this,"points",[]);de(this,"classes",new Map)}setQuadrant1Text(t){this.quadrants[0]=Dr(t)}setQuadrant2Text(t){this.quadrants[1]=Dr(t)}setQuadrant3Text(t){this.quadrants[2]=Dr(t)}setQuadrant4Text(t){this.quadrants[3]=Dr(t)}setXAxisLeftText(t){this.xAxisLeft=Dr(t)}setXAxisRightText(t){this.xAxisRight=Dr(t)}setYAxisBottomText(t){this.yAxisBottom=Dr(t)}setYAxisTopText(t){this.yAxisTop=Dr(t)}addPoint(t,n,r,o,s){this.points.push({x:Number(r),y:Number(o),text:Dr(t),className:n,...tE(s)})}addClass(t,n){this.classes.set(t,tE(n))}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
`)}};function ln(e,t,n){for(let r=0;r<n.length;r++){let o=e.charCodeAt(t+r),s=n.charCodeAt(r);if(o!==s&&!(s>=97&&s<=122&&o===s-32))return!1}return!0}var Af=["$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 xf=[41,4,6,8,9,19],Sf=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++)Sf[e.charCodeAt(n)]=t;function nE(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=0,l=0,f=0,p=0,u=0,m=0,h=0,b=0,x=(B,W,Y)=>{n.push(B),r.push(e.slice(W,Y)),o.push(W),i=Y},E=B=>{s.push(a),a=B},w=()=>{s.length>0&&(a=s.pop())},S=B=>{let W=e.indexOf(`
`,B);return W===-1?t:W},O=B=>{for(;e.charCodeAt(B)===32;)B++;return B},D=B=>{for(;B<t&&He(e.charCodeAt(B));)B++;return B},L=B=>{let W=e.charCodeAt(B);if(W===49)return B+1;if(W!==48)return-1;let Y=B+1;if(Y<t&&!ys(e.charCodeAt(Y))&&ft(e.charCodeAt(Y+1)))for(Y+=2;ft(e.charCodeAt(Y));)Y++;return Y};e:for(;i<t;){let B=e.charCodeAt(i),W=e.charCodeAt(i+1);switch(a){case 0:break;case 1:case 2:case 3:x(xf[a],i,S(i)),w();continue;case 4:if(B===125)i++,w();else{let C=e.indexOf("}",i);x(9,i,C===-1?t:C)}continue;case 5:if(B===34)i++,w();else{let C=e.indexOf('"',i);x(19,i,C===-1?t:C)}continue;case 6:if(B===96&&W===34){i+=2,w();continue}if(B!==96&&B!==34){let C=i+1;for(let M=e.charCodeAt(C);C<t&&M!==96&&M!==34;M=e.charCodeAt(++C));x(18,i,C);continue}break e;case 7:if(Qe(B)){let C=i+1;for(;Qe(e.charCodeAt(C));)C++;x(20,i,C),w();continue}break e;case 8:{let C=L(i);if(C!==-1){x(22,i,C),E(9);continue}let M=D(i);if(e.charCodeAt(M)===93){i=O(M+1),w();continue}break e}case 9:{let C=D(i);if(e.charCodeAt(C)===44){i=D(C+1),a=10;continue}break e}case 10:{let C=L(i);if(C!==-1){x(23,i,C),w();continue}break e}}if(B===37&&W===37){i=S(i+2);continue}if(B!==125&&W===37&&e.charCodeAt(i+2)===37){i=S(i+3);continue}if(B===10||B===13){let C=i+1;for(let M=e.charCodeAt(C);M===10||M===13;M=e.charCodeAt(++C));x(2,i,C);continue}let Y=B|32;if(Y===116&&ln(e,i,"title")&&!Qe(e.charCodeAt(i+5))){x(3,i,i+5),E(1);continue}if(Y===97&&ln(e,i,"acc")){let C=ln(e,i+3,"descr");if(C||ln(e,i+3,"title")){let M=D(i+8),T=e.charCodeAt(M);if(T===58){x(C?7:5,i,D(M+1)),E(C?3:2);continue}if(T===123&&C){i=D(M+1),E(4);continue}}}let I=i;B===32&&((i<c||i>=l)&&(c=i,l=O(i)),I=l);let X=e.charCodeAt(I),ee=X|32,K=0,z=0;if(ee===120&&ln(e,I,"x-axis"))K=10,z=I+6;else if(ee===121&&ln(e,I,"y-axis"))K=11,z=I+6;else if(X===45){if(I<f||I>=p)for(f=I,p=I;e.charCodeAt(p)===45;)p++;p-I>=2&&e.charCodeAt(p)===62&&(K=12,z=p+1)}else if(ee===113&&ln(e,I,"quadrant")){let C=e.charCodeAt(I+9);e.charCodeAt(I+8)===45&&C>=49&&C<=52?(K=13+C-49,z=I+10):ln(e,I+8,"chart")&&(K=24,z=I+13)}if(K!==0){x(K,i,O(z));continue}if(Y===99&&ln(e,i,"classdef")&&!Qe(e.charCodeAt(i+8))){x(17,i,i+8);continue}if(B===34){W===96?(i+=2,E(6)):(i++,E(5));continue}if(B===58&&W===58&&e.charCodeAt(i+2)===58){i+=3,E(7);continue}if(B===58||He(B)){let C=i;if(B!==58&&((i<u||i>=m)&&(u=i,m=D(i)),C=m),e.charCodeAt(C)===58&&((C+1<h||C+1>=b)&&(h=C+1,b=D(C+1)),e.charCodeAt(b)===91)){x(21,i,D(b+1)),E(8);continue}}if(Rr(B)){let C=i+1;for(;Rr(e.charCodeAt(C));)C++;x(25,i,C);continue}if(B>=128){let C=i+1;for(;e.charCodeAt(C)>=128;)C++;x(26,i,C);continue}if(ft(B)){let C=i+1;for(;ft(e.charCodeAt(C));)C++;x(37,i,C);continue}if(Sf[B]!==0){x(Sf[B],i,i+1);continue}break}return i<t?(n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}):(a<xf.length&&(n.push(xf[a]),r.push(""),o.push(t)),n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o})}function rl(...e){let t=new Uint8Array(42);for(let n of e)t[n]=1;return t}var rE=rl(40,35,37,25,29,28,30,31,34,32,33,26),sE=rl(25,37,36,29,27,35,32,31,26),_f=rl(25,37,27,38,32,36),iE=rl(2,39,41),oN=["setQuadrant1Text","setQuadrant2Text","setQuadrant3Text","setQuadrant4Text"],aN="'STR', 'MD_STR', 'ALPHA', 'NUM', 'UNICODE_TEXT', 'PUNCTUATION'";function oE(e,t){let{types:n,texts:r,starts:o}=nE(e),s=0,a=p=>{let u=n[s];throw u===1?st("quadrantChart",e,o[s],"",!0):st("quadrantChart",e,o[s],`Expecting ${p}, got '${Af[u]}'`)},i=p=>(n[s]!==p&&a(`'${Af[p]}'`),r[s++]),c=p=>p===19||p===18||rE[p]===1,l=()=>{let p=n[s];c(p)||a(aN);let u=r[s++];for(;rE[n[s]]===1||n[s]===38||n[s]===36;)u+=r[s++];return{text:u,type:p===18?"markdown":"text"}},f=()=>{let p=[];for(;;){_f[n[s]]===0&&a("'ALPHA', 'NUM', 'COLON', 'SPACE', 'BRKT', 'MINUS'");let u=r[s++];for(;_f[n[s]]===1;)u+=r[s++];if(p.push(u.trim()),n[s]!==29)return p;s++}};for(;iE[n[s]]===1||n[s]===38;)s++;for(i(24);n[s]!==0;){for(;n[s]===38;)s++;let p=n[s];switch(p){case 17:{s++,i(38),sE[n[s]]===0&&a("'ALPHA', 'NUM', 'UNICODE_TEXT'");let u=r[s++];for(;sE[n[s]]===1;)u+=r[s++];i(38),t.addClass(u,f());break}case 10:case 11:{s++;let u=l(),m;n[s]===12&&(s++,c(n[s])?m=l():u.text+=" ⟶ "),p===10?(t.setXAxisLeftText(u),m&&t.setXAxisRightText(m)):(t.setYAxisBottomText(u),m&&t.setYAxisTopText(m));break}case 13:case 14:case 15:case 16:s++,t[oN[p-13]](l());break;case 3:s++,t.setDiagramTitle(i(4).trim());break;case 5:s++,t.setAccTitle(i(6).trim());break;case 7:s++,t.setAccDescription(i(8).trim());break;case 9:t.setAccDescription(r[s++].trim());break;default:if(c(p)){let u=l(),m=n[s]===20?r[s++]:"";i(21);let h=i(22),b=i(23);t.addPoint(u,m,h,b,_f[n[s]]===1?f():[])}}iE[n[s]]===0&&a("'NEWLINE', 'SEMI', 'EOF'"),s++}}var aE=4,cN=300;function wf(e,t){return e.quadrantChart?.[t]}function Or(e,t,n,r){let o=wf(e,t);return typeof o=="number"&&o>=0?Math.min(o,r):n}function cE(e){return e.startsWith("#")?e:"#"+e}function lE(e,t,n){let r=n.fontSize??16,o=Math.round(r*.875),s=Math.round(r*.75),a=n.measurer??et(n.fontFamily),i=Math.round(Math.max(100,Or(t,"chartWidth",500,4e3))),c=Math.round(zr(n,i,280)),l=Math.round(Math.max(100,Or(t,"chartHeight",500,4e3))*c/i),f=Or(t,"quadrantPadding",n.padding??8,200),p=Or(t,"xAxisLabelPadding",5,200),u=Or(t,"yAxisLabelPadding",5,200),m=e.points.length>0,h=(V,ne,ae)=>We(V?.text,V?.type==="markdown",a,ne,Math.max(ae,40)),b=We(e.title,!1,a,r,Math.max(c-2*f,40),1),x=Or(t,"titlePadding",10,200),E=b.height>0?b.height+x:0,w=!!(e.xAxisLeft?.text||e.xAxisRight?.text),S=!!(e.yAxisBottom?.text||e.yAxisTop?.text),O=m||wf(t,"xAxisPosition")==="bottom",D=wf(t,"yAxisPosition")==="right",L=c-2*f,B=h(e.xAxisLeft,o,e.xAxisRight?L/2-16:L),W=h(e.xAxisRight,o,L/2-16),Y=Math.max(B.height,W.height),I=w?Y+p:0,X=l-2*f-E-I,ee=h(e.yAxisBottom,o,e.yAxisTop?X/2-16:X),K=h(e.yAxisTop,o,X/2-16),z=Math.max(ee.height,K.height),C=S?z+u:0,M=f+(D?0:C),T=f+E+(O?0:I),g=Math.max(0,L-C),_=Math.max(0,X),y=Math.max(0,(g-aE)/2),R=Math.max(0,(_-aE)/2),A=[M+y,T,M+g-y,T+_,M,T+R,M+g,T+_-R],N=(V,ne,ae,Z,Q)=>{for(let ie=V;ie<A.length;ie+=4)if(ne<A[ie+2]&&Z>A[ie]&&ae<A[ie+3]&&Q>A[ie+1])return!1;return!0},$=Or(t,"quadrantTextTopPadding",5,200),U="";for(let V=0;V<4;V++){let ne=V===0||V===3?M+g-y:M,ae=V<2?T:T+_-R,Z=h(e.quadrants[V],r,y-16),Q=ne+y/2,ie=m?ae+$+Z.height/2:ae+R/2;A.push(Q-Z.width/2,ie-Z.height/2,Q+Z.width/2,ie+Z.height/2),U+=`<g class="pele-quadrant" data-id="${V+1}"><rect x="${d(ne)}" y="${d(ae)}" width="${d(y)}" height="${d(R)}"${it}/>`+De(Z,Q,ie,' class="pele-label" fill="var(--_fg)" stroke="none"')+"</g>"}let j="";if(w){let V=O?T+_+p+Y/2:T-p-Y/2;j+=De(B,W.height>0?M+g/4:M+B.width/2,V,"")+De(W,M+g*3/4,V,"")}if(S){let V=D?M+g+u+z/2:M-u-z/2,ne=(ae,Z)=>ae.height>0?`<g transform="translate(${d(V)},${d(Z)}) rotate(-90)">${De(ae,0,0,"")}</g>`:"";j+=ne(ee,K.height>0?T+_*3/4:T+_-ee.width/2)+ne(K,T+_/4)}let v=Or(t,"pointRadius",5,200),k=Or(t,"pointTextPadding",5,200),F=lt(0),H=[],G=[];for(let V of e.points){if(!(V.x>=0&&V.x<=1&&V.y>=0&&V.y<=1))continue;let ne=e.classes.get(V.className),ae=Math.min(V.radius??ne?.radius??v,2e3),Z=V.color??ne?.color,Q=V.strokeColor??ne?.strokeColor,ie=V.strokeWidth??ne?.strokeWidth,me=[];Z&&me.push("fill:"+cE(Z)),ie&&(Q&&me.push("stroke:"+cE(Q)),me.push("stroke-width:"+ie));let re=M+V.x*g,te=T+(1-V.y)*_;H.push({cx:re,cy:te,reach:ae+(ie?Math.min(parseInt(ie),400)/2:0),text:h(V.text,s,200)}),G.push(`<circle class="pele-point${Rt(V.className)}" data-id="${Fe(V.text.text)}" cx="${d(re)}" cy="${d(te)}" r="${d(ae)}"${ie&&!Q?` stroke="${F}"`:""}${St(me).shape}/>`)}let se=H.length<=cN;if(se)for(let{cx:V,cy:ne,reach:ae}of H)A.push(V-ae,ne-ae,V+ae,ne+ae);let q="";for(let{cx:V,cy:ne,reach:ae,text:Z}of H){let Q=Z.width/2,ie=Z.size*.6+(Z.height-Z.lineHeight)/2,me=ae+k,re=[V,ne+me+ie,V,ne-me-ie,V+me+Q,ne,V-me-Q,ne],te=V,he=re[1],oe=!1;for(let ge=0;ge<16;ge+=2){let Ee=ge%8,be=Ee<4&&Z.width<g?Math.min(Math.max(re[Ee],M+Q),M+g-Q):re[Ee],ye=re[Ee+1];if(be-Q<M||be+Q>M+g||ye-ie<T||ye+ie>T+_)continue;let Re=!se||N(ge<8?0:8,be-Q,ye-ie,be+Q,ye+ie);if((!oe||Re)&&(te=be,he=ye,oe=!0),Re)break}se&&A.push(te-Q,he-ie,te+Q,he+ie),q+=De(Z,te,he,' class="pele-label"')}let P=De(b,c/2,x/2+b.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-quadrants" fill="var(--_s)" stroke="var(--_b)">${U}</g>`+(j?`<g class="pele-axis-labels" font-size="${o}" fill="var(--_m)">${j}</g>`:"")+(H.length>0?`<g class="pele-points" fill="${F}">${G.reverse().join("")}</g><g class="pele-point-labels" font-size="${s}">${q}</g>`:"");return{svg:Ze("quadrantChart",c,l,r,n,e,P),width:c,height:l,links:[]}}var dE={type:"quadrantChart",parse(e,t,n){let r=new nl;return r.title=n,oE(e,r),r},render:lE};var uE=32;function fE(e){return new ze(e,"semantic",{type:"radar"})}function pE(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(i=>i.value);else{if(n.length===0)throw fE("Axes must be populated before curves for reference entries");let i=new Map;for(let c of s.entries)c.axis!==void 0&&!i.has(c.axis.$refText)&&i.set(c.axis.$refText,c.value);a=n.map(c=>{let l=i.get(c.name);if(l===void 0)throw fE("Missing entry for axis "+c.label);return l})}return{name:s.name,label:s.label??s.name,entries:a}}),o={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"};for(let s of e.options)s.name==="showLegend"?o.showLegend=s.value:s.name==="graticule"?o.graticule=s.value:o[s.name]=s.value;return o.ticks>uE&&(o.ticks=uE),{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,`
`):void 0,axes:n,curves:r,options:o}}var Cf=0,sl=0;function hE(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function lN(e,t){(t<Cf||t>=sl)&&(Cf=t,sl=hE(e,t));let n=sl;if(n===t)return-1;let r=e.charCodeAt(n)===46;if(r){let o=hE(e,n+1),s=o-n-1;if(s>0&&e.charCodeAt(o)!==46)return o;if(s>1)return o-1}return e.charCodeAt(t)===48?t+1:r?n-1>t?n-1:-1:n}var Rf=tn.pattern,Tf=/[\t ]*accDescr\s*{/y,il=-2;function dN(e,t){return Tf.lastIndex=t,Tf.test(e)&&(il===-2&&(il=e.lastIndexOf("}")),Tf.lastIndex>il)?-1:(Rf.lastIndex=t,Rf.test(e)?Rf.lastIndex:-1)}var Nf={name:"ID",pattern:/[\w]([-\w]*\w)?/y},Us=e=>({name:e,pattern:e,longer:[Nf]}),Gs=e=>({name:e,pattern:e}),mE=[Gs("radar-beta:"),{...qt("radar-beta"),longer:[Nf]},Us("showLegend"),Us("graticule"),Us("curve"),Us("ticks"),Us("axis"),Us("max"),Us("min"),Gs(":"),Gs(","),Gs("["),Gs("]"),Gs("{"),Gs("}"),{name:"GRATICULE",pattern:/circle|polygon/y},{name:"BOOLEAN",pattern:/true|false/y},{...tn,match:dN},zt,Vt,{name:"NUMBER",pattern:/(?:[0-9]+\.[0-9]+(?!\.))|(?:0|[1-9][0-9]*(?!\.))/y,match:lN},Cn,Nf,bn,yn,Ut,jt,Xt];function uN(e){return Cf=sl=0,il=-2,Wt(e,mE,"radar")}function gE(e){let t=new Bt(uN(e),mE,"radar"),n={$type:"Radar",axes:[],curves:[],options:[]},r=()=>{for(;t.kind===23;)t.i++},o=()=>{t.kind!==-1&&(t.kind!==23&&t.fail("a line break or the end of input"),r())},s=()=>{if(!t.accept(11))return;let p=on(t.expect(21));return t.expect(12),p},a=p=>{if(!p)return{$type:"Entry",value:Number(t.expect(20))};let u={$refText:t.expect(22)};return t.accept(9),{$type:"Entry",axis:u,value:Number(t.expect(20))}},i=()=>{let p=t.expect(22),u=s(),m={$type:"Curve",name:p,entries:[]};u!==void 0&&(m.label=u),t.expect(13),r(),t.kind!==20&&t.kind!==22&&t.fail("a number or an axis name");let h=t.kind===22;for(m.entries.push(a(h));t.accept(10);)r(),m.entries.push(a(h));return r(),t.expect(14),m},c=()=>{let p={$type:"Axis",name:t.expect(22)},u=s();return u!==void 0&&(p.label=u),p},l=()=>{let p=t.kind,u=t.take(),m;return p===2?m=t.expect(16)==="true":p===3?m=t.expect(15):m=Number(t.expect(20)),{$type:"Option",name:u,value:m}},f=()=>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=Ht(t.take()),o();break;case 18:n.accTitle=Yt(t.take()),o();break;case 19:n.title=Gt(t.take()),o();break;case 6:t.i++;do n.axes.push(c());while(t.accept(10));break;case 4:t.i++;do n.curves.push(i());while(t.accept(10));break;default:for(f()||t.fail("an axis, a curve, an option, a title, or a line break"),n.options.push(l());t.accept(10);)f()||t.fail("an option"),n.options.push(l())}return n}var Di=12,Mf=26,bE=24;function vr(e,t,n,r,o){let s=e.radar?.[t];return typeof s=="number"&&s>=r?Math.min(s,o):n}function fN(e,t,n,r){let o=Math.min(Math.max(e,t),n);return r*(o-t)/(n-t)}function pN(e,t){let n=e.length,r=`M${d(e[0].x)},${d(e[0].y)}`;for(let o=0;o<n;o++){let s=e[(o-1+n)%n],a=e[o],i=e[(o+1)%n],c=e[(o+2)%n];r+=` C${d(a.x+(i.x-s.x)*t)},${d(a.y+(i.y-s.y)*t)} ${d(i.x-(c.x-a.x)*t)},${d(i.y-(c.y-a.y)*t)} ${d(i.x)},${d(i.y)}`}return r+" Z"}function yE(e){let t="";for(let n of e)t+=(t?" ":"")+d(n.x)+","+d(n.y);return t}function EE(e,t,n){let r=vr(t,"width",320,1,4e3);return Kr(n,r,160,(o,s)=>hN(e,t,n,o,vr(t,"height",320,1,4e3)*o/r,s))}function hN(e,t,n,r,o,s){let a=n.fontSize??16,i=Math.round(a*.875),c=n.measurer??et(n.fontFamily),l=n.padding??8,f=vr(t,"axisScaleFactor",1,0,10),p=vr(t,"axisLabelFactor",1.05,0,10),u=vr(t,"curveTension",.17,0,1),m=Math.min(r,o)/2,{axes:h,curves:b}=e,{ticks:x,graticule:E,min:w}=e.options,S=h.length,O=h.map((v,k)=>{let F=2*Math.PI*k/S-Math.PI/2;return{x:Math.cos(F),y:Math.sin(F)}}),D=e.options.max;if(D===null){D=-1/0;for(let v of b)for(let k of v.entries)k>D&&(D=k)}let L=-r/2-vr(t,"marginLeft",16,0,2e3),B=r/2+vr(t,"marginRight",16,0,2e3),W=-o/2-vr(t,"marginTop",16,0,2e3),Y=o/2+vr(t,"marginBottom",16,0,2e3),I="";for(let v=0;v<x;v++){let k=Math.min(m,m*(v+1)/x);E==="circle"?I+=`<circle r="${d(k)}"/>`:I+=`<polygon points="${yE(O.map(F=>({x:F.x*k,y:F.y*k})))}"/>`}let X="",ee="";O.forEach((v,k)=>{let F=m*f;X+=`M0,0L${d(v.x*F)},${d(v.y*F)}`;let H=We(h[k].label,!1,c,i,4e3),G=m*p+6,se=v.x*G+(v.x>.01?H.width/2:v.x<-.01?-H.width/2:0),q=v.y*G+(v.y>.01?H.height/2:v.y<-.01?-H.height/2:0);ee+=`<g class="pele-axis-label" data-id="${Fe(h[k].name)}">${De(H,se,q,"")}</g>`,L=Math.min(L,se-H.width/2),B=Math.max(B,se+H.width/2),W=Math.min(W,q-H.height/2),Y=Math.max(Y,q+H.height/2)});let K="";b.forEach((v,k)=>{if(v.entries.length!==S)return;let F=v.entries.map((se,q)=>{let P=fN(se,w,D,m),V=Number.isFinite(P)?P:0;return{x:O[q].x*V,y:O[q].y*V}}),H=lt(k),G=` class="pele-curve" data-id="${Fe(v.name)}" fill="${H}" stroke="${H}"`;K+=E==="circle"?`<path${G} d="${pN(F,u)}"/>`:`<polygon${G} points="${yE(F)}"/>`});let z=e.options.showLegend?b.map(v=>We(v.label,!1,c,i,4e3)):[],C=0;for(let v of z)C=Math.max(C,v.width);let M=z.length*Mf,T=s?-(Di+8+C)/2:B+bE,g=s?Y+bE/2:-M/2;z.length>0&&s?(L=Math.min(L,T),B=Math.max(B,-T),Y=g+M):z.length>0&&(B=T+Di+8+C,W=Math.min(W,-M/2),Y=Math.max(Y,M/2));let _="";z.forEach((v,k)=>{let F=g+k*Mf+Mf/2,H=lt(k);_+=`<g class="pele-legend-item" data-id="${Fe(b[k].name)}"><rect x="${d(T)}" y="${d(F-Di/2)}" width="${Di}" height="${Di}" rx="2" fill="${H}" fill-opacity="0.4" stroke="${H}"/>`+De(v,T+Di+8+v.width/2,F,"")+"</g>"});let y=We(e.title,!1,c,a,Tt(n),1),R=y.height>0?y.height+8:0,A=Math.max(B-L,y.width),N=Math.ceil(A+2*l),$=Math.ceil(Y-W+R+2*l),U=`translate(${d(l+(A-(B-L))/2-L)},${d(l+R-W)})`,j=De(y,N/2,l+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="${U}">`+(I?`<g class="pele-graticule" fill="none" stroke="var(--_a)">${I}</g>`:"")+(X?`<path class="pele-axes" d="${X}" fill="none" stroke="var(--_b)"/>`:"")+(K?`<g class="pele-curves" fill-opacity="0.2" stroke-width="1.5" stroke-linejoin="round">${K}</g>`:"")+(ee?`<g class="pele-axis-labels" font-size="${i}">${ee}</g>`:"")+(_?`<g class="pele-legend" font-size="${i}">${_}</g>`:"")+"</g>";return{svg:Ze("radar",N,$,a,n,e,j),width:N,height:$,links:[]}}var AE={type:"radar",parse:(e,t,n)=>pE(gE(e),n),render:EE};function If(e){return e===32||e>=9&&e<=13||e>127&&/\s/.test(String.fromCharCode(e))}function mN(){let e=1/0;return(t,n)=>{if(!t.startsWith("accDescr",n))return-1;let r=t.length,o=n+8;for(;o<r&&(t.charCodeAt(o)===32||t.charCodeAt(o)===9);)o++;if(t.charCodeAt(o)===58){for(o++;o<r;o++){let a=t.charCodeAt(o);if(a===10||a===13||a===37&&t.charCodeAt(o+1)===37)break}return o}for(;o<r&&If(t.charCodeAt(o));)o++;if(t.charCodeAt(o)!==123||o>=e)return-1;let s=t.indexOf("}",o+1);return s===-1&&(e=o),s+1||-1}}var kf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ts={name:"TITLE",pattern:/title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:"t"},ns={name:"ACC_TITLE",pattern:/accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"a"},rs={name:"ACC_DESCR",pattern:/accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"a",scanner:mN};function ht(e,t){return{name:e,pattern:e,longer:t}}function ss(e,t){return{...qt(e),longer:[t]}}function Oi(e){return{name:e,pattern:/[A-Z_a-z][\w-]*/y,first:kf+"_"}}function vi(e){return{name:e,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`}}function is(e){return[{name:e+"_WHITESPACE",pattern:/[\t \r\n]+/y,hidden:!0,first:`	 \r
`},{...Ut,name:e+"_YAML",first:"-"},{...jt,name:e+"_DIRECTIVE",first:"	 %"},{...Xt,name:e+"_SINGLE_LINE_COMMENT",first:"	 %"}]}function Pr(e){if(!e.includes("\\"))return e.slice(1,-1);let t=e.length-1,n="";for(let r=1;r<t;r++){let o=e[r];o==="\\"&&r+1<t?(o=e[++r],n+=o==="n"?`
`:o==="r"?"\r":o==="t"?"	":o):n+=o}return n}function os(e,t,n,r,o,s){let a=new Bt(Wt(e,t,"railroad"),t,"railroad"),i={$type:n,rules:[]};for(a.expect(0);;){let c=a.kind;if(c===r){let l=Gt(a.take()),f=l[0];i.title=(f==='"'||f==="'")&&l.endsWith(f)?o(l):l}else if(c===r+1)i.accTitle=Yt(a.take());else if(c===r+2)i.accDescr=Ht(a.take());else break}for(;a.kind!==-1;)i.rules.push(s(a));return i}var Lf=[];function ol(e){let t=e,n=t.element??t.primary??t.suffix,r=t.alternatives??t.elements??(n?[n]:Lf);if(t.base){r=[t.base];for(let o of t.postfixes)o.except&&r.push(o.except)}return r}var Br=e=>({type:"terminal",value:e}),as=e=>({type:"nonterminal",name:e}),Ys=e=>({type:"special",text:e}),Sr=e=>({type:"optional",element:e}),Fr=(e,t,n=1/0)=>({type:"repetition",element:e,min:t,max:n});function cs(e){return e.length===1?e[0]:{type:"sequence",elements:e}}function ls(e){return e.length===1?e[0]:{type:"choice",alternatives:e}}function ds(e,t){return e.rules.map(n=>({name:n.name,definition:$f(n.definition,ol,t)}))}function $f(e,t,n){let r=[e],o=[t(e)],s=[[]];for(;;){let a=r.length-1,i=s[a];if(i.length<o[a].length){let c=o[a][i.length];r.push(c),o.push(t(c)),s.push([])}else{let c=n(r[a],i);if(a===0)return c;r.pop(),o.pop(),s.pop(),s[a-1].push(c)}}}var xE="0123456789",SE={name:"ABNF_RULENAME",pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:kf},_E={name:"ABNF_COMMENT",pattern:/;[^\n\r]*/y,hidden:!0,first:";"},RE=[ss("railroad-abnf-beta",SE),ht("="),ht(";",[_E]),ht("/"),ht("("),ht(")"),ht("["),ht("]"),ts,ns,rs,SE,{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:xE+"*"},{name:"ABNF_EXACT_REPEAT",pattern:/[0-9]+/y,first:xE},...is("ABNF"),_E];function wE(e,t,n,r){let o={$type:"AbnfConcatenation",elements:[]};return t.alternatives.push(o),{alternation:t,concatenation:o,node:e,close:n,repeat:r}}function gN(e){let t=[],n=wE(void 0,{$type:"AbnfAlternation",alternatives:[]},-2,void 0);for(;;){let r=e.kind===14||e.kind===15?e.take():void 0,o,s=e.kind;switch(s){case 12:o={$type:"AbnfStringLiteral",value:e.take().slice(1,-1)};break;case 13:o={$type:"AbnfNumVal",value:e.take()};break;case 11:o={$type:"AbnfRuleName",name:e.take()};break;case 4:case 6:{e.i++;let a={$type:"AbnfAlternation",alternatives:[]};t.push(n),n=wE({$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:o}:{$type:"AbnfElement",repeat:r,primary:o});let a=e.kind;if(a===n.close){e.i++,o=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 '${RE[n.close].name}'`)}break}}}function TE(e){return os(e,RE,"RailroadAbnf",8,t=>t.slice(1,-1),t=>{let n=t.expect(11);t.expect(1);let r=gN(t);return t.expect(2),{$type:"AbnfRule",name:n,definition:r}})}function bN(e,t){switch(e.$type){case"AbnfAlternation":return ls(t);case"AbnfConcatenation":return cs(t);case"AbnfElement":{let n=e.repeat;if(!n)return t[0];let r=n.indexOf("*"),o=r===-1,s=r>0||o?parseInt(n,10):0,a=o?s:r<n.length-1?parseInt(n.slice(r+1),10):1/0;return s===0&&a===1?Sr(t[0]):Fr(t[0],s,a)}case"AbnfStringLiteral":case"AbnfNumVal":return Br(e.value);case"AbnfRuleName":return as(e.name);case"AbnfGroup":return t[0];case"AbnfOptionalGroup":return Sr(t[0])}}var CE=e=>ds(e,bN);function yN(e,t){if(e.charCodeAt(t)!==63)return-1;let n=!1;for(let r=t+1;r<e.length;r++){let o=e.charCodeAt(r);if(o===63)return n?r+1:-1;if(o===59)return-1;n||=!If(o)}return-1}var NE=Oi("EBNF_ID"),ME={name:"EBNF_SPECIAL_SEQUENCE",pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:"?",scanner:()=>yN},IE=is("EBNF"),kE={name:"EBNF_ISO_COMMENT",pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:"(",opener:/\(\*/y},$E=[ss("railroad-ebnf-beta",NE),ht("::="),ht("="),ht(";"),ht("|"),ht(","),ht("(",[kE]),ht(")"),ht("["),ht("]"),ht("{"),ht("}"),ht("?",[ME]),ht("*"),ht("+"),ht("-",[IE[1]]),ts,ns,rs,NE,vi("EBNF_STRING"),ME,...IE,{name:"EBNF_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y},kE];function LE(e,t,n,r){let o={$type:"EbnfSequence",elements:[]};return t.alternatives.push(o),{choice:t,sequence:o,term:void 0,node:e,close:n,except:r}}var EN=["EbnfGroup","EbnfOptional","EbnfRepetition"];function AN(e){let t=[],n=LE(void 0,{$type:"EbnfChoice",alternatives:[]},-2,!1),r=!1;for(;;){let o,s=e.kind;switch(s){case 20:o={$type:"EbnfTerminal",value:Pr(e.take())};break;case 19:o={$type:"EbnfNonTerminal",name:e.take()};break;case 21:o={$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=LE({$type:EN[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:o}),r=!1):(n.term={$type:"EbnfTerm",base:o,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 i=e.kind;if(i===n.close){e.i++,o=n.node,r=n.except,n=t.pop();continue}if(i===15)e.i++,r=!0;else if(i===5)e.i++;else if(i===4)e.i++,n.sequence={$type:"EbnfSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(i!==20&&i!==19&&i!==21&&i!==6&&i!==8&&i!==10){if(t.length===0)return n.choice;e.fail(`token of type '${$E[n.close].name}'`)}break}}}function DE(e){return os(e,$E,"RailroadEbnf",16,Pr,t=>{let n=t.expect(19);t.accept(2)||t.expect(1);let r={$type:"EbnfRule",name:n,definition:AN(t)};return t.expect(3),r})}function xN(e,t){switch(e.$type){case"EbnfChoice":return ls(t);case"EbnfSequence":return cs(t);case"EbnfTerm":{let n=t[0],r=1;for(let o of e.postfixes)o.$type==="EbnfOptionalPostfix"?n=Sr(n):o.$type==="EbnfExceptionPostfix"?n={type:"sequence",elements:[n,Br("-"),t[r++]]}:n=Fr(n,o.$type==="EbnfOneOrMorePostfix"?1:0);return n}case"EbnfTerminal":return Br(e.value);case"EbnfNonTerminal":return as(e.name);case"EbnfSpecial":return Ys(e.text);case"EbnfGroup":return t[0];case"EbnfOptional":return Sr(t[0]);case"EbnfRepetition":return Fr(t[0],0)}}var OE=e=>ds(e,xN);var vf=Oi("RR_ID"),us=e=>ht(e,[vf]),SN=[ss("railroad-beta",vf),us("nonterminal"),us("zeroOrMore"),us("oneOrMore"),us("sequence"),us("optional"),us("terminal"),us("special"),us("choice"),ht("="),ht(";"),ht("("),ht(","),ht(")"),ts,ns,rs,vf,vi("RR_STRING"),...is("RR"),{name:"RR_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y}];function Df(e){e.i++,e.expect(11);let t=Pr(e.expect(18));return e.expect(13),t}function Of(e){return{$type:e,element:void 0}}function _N(e){let t=[];for(;;){let n;switch(e.kind){case 6:n={$type:"RailroadTerminalExpr",value:Df(e)};break;case 1:n={$type:"RailroadNonTerminalExpr",name:Df(e)};break;case 7:n={$type:"RailroadSpecialExpr",text:Df(e)};break;case 4:n={$type:"RailroadSequenceExpr",elements:[]};break;case 8:n={$type:"RailroadChoiceExpr",alternatives:[]};break;case 5:n=Of("RailroadOptionalExpr");break;case 3:n=Of("RailroadOneOrMoreExpr");break;case 2:n=Of("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 vE(e){return os(e,SN,"Railroad",14,Pr,t=>{let n=t.expect(17);t.expect(9);let r=_N(t);return t.expect(10),{$type:"RailroadRule",name:n,definition:r}})}function wN(e,t){switch(e.$type){case"RailroadTerminalExpr":return Br(e.value);case"RailroadNonTerminalExpr":return as(e.name);case"RailroadSpecialExpr":return Ys(e.text);case"RailroadSequenceExpr":return cs(t);case"RailroadChoiceExpr":return ls(t);case"RailroadOptionalExpr":return Sr(t[0]);default:return Fr(t[0],e.$type==="RailroadOneOrMoreExpr"?1:0)}}var PE=e=>ds(e,wN);var BE=Oi("PEG_ID"),RN=[ss("railroad-peg-beta",BE),ht("<-"),ht(";"),ht("/"),ht("&"),ht("!"),ht("?"),ht("*"),ht("+"),ht("("),ht(")"),ht("."),ts,ns,rs,BE,vi("PEG_STRING"),...is("PEG"),{name:"PEG_LINE_COMMENT",pattern:/#[^\n\r]*/y,hidden:!0,first:"#"}];function FE(e,t,n){let r={$type:"PegSequence",elements:[]};return t.alternatives.push(r),{choice:t,sequence:r,node:e,operator:n}}function TN(e){let t=[],n=FE(void 0,{$type:"PegOrderedChoice",alternatives:[]},void 0);for(;;){let r=e.kind===4||e.kind===5?e.take():void 0,o;switch(e.kind){case 16:o={$type:"PegLiteral",value:Pr(e.take())};break;case 15:o={$type:"PegIdentifier",name:e.take()};break;case 11:o={$type:"PegAny",dot:e.take()};break;case 9:{e.i++;let a={$type:"PegOrderedChoice",alternatives:[]};t.push(n),n=FE({$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:o};(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 i=e.kind;if(i===10&&t.length>0){e.i++,o=n.node,r=n.operator,n=t.pop();continue}if(i===3)e.i++,n.sequence={$type:"PegSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(i!==4&&i!==5&&i!==16&&i!==15&&i!==11&&i!==9){if(t.length===0)return n.choice;e.fail("token of type ')'")}break}}}function WE(e){return os(e,RN,"RailroadPeg",12,Pr,t=>{let n=t.expect(15);t.expect(1);let r={$type:"PegRule",name:n,definition:TN(t)};return t.expect(2),r})}function CN(e){switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}}function NN(e,t){let n=t[0];switch(e.$type){case"PegOrderedChoice":return ls(t);case"PegSequence":return cs(t);case"PegPrefix":return e.operator?Ys(e.operator+CN(n)):n;case"PegSuffix":return e.operator?e.operator==="?"?Sr(n):Fr(n,e.operator==="+"?1:0):n;case"PegLiteral":return Br(e.value);case"PegIdentifier":return as(e.name);case"PegAny":return Ys(e.dot);case"PegGroup":return n}}var UE=e=>ds(e,NN);var Pf=class{constructor(){de(this,"type","railroad");de(this,"notation","railroad");de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"rules",[]);de(this,"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,`
`)}addRule(t){this.rules.push(t),this.byName.set(t.name,t)}getRule(t){return this.byName.get(t)}},MN=/^\s*railroad-(ebnf-|abnf-|peg-)?beta/i;function IN(e){let t=MN.exec(e);if(t===null)return;let n=t[1]?.toLowerCase();return n==="ebnf-"?"ebnf":n==="abnf-"?"abnf":n==="peg-"?"peg":"railroad"}function kN(e,t){switch(t){case"ebnf":{let n=DE(e);return[n,OE(n)]}case"abnf":{let n=TE(e);return[n,CE(n)]}case"peg":{let n=WE(e);return[n,UE(n)]}default:{let n=vE(e);return[n,PE(n)]}}}function LN(e,t,n){let[r,o]=kN(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 o)e.addRule(s)}function GE(e,t){let n=IN(e);if(n===void 0)throw new ze("No railroad diagram keyword found.","syntax",{type:"railroad"});let r=new Pf;return t&&(r.title=t),LN(r,e,n),r}var Bf=12,$N=6,DN=18,ll=12,nr=7;function Hs(e,t,n,r){let o=e.railroad?.[t];return typeof o=="number"&&o>=0?Math.min(o,r):n}var ON=/[\n\r\t]/g;function cl(e){return(e.includes("¶ß")?yt(e.replace(/&/g,"&amp;")):e).replace(ON,n=>n===`
`?"\\n":n==="\r"?"\\r":"\\t")}function al(e,t){for(let n=t,r=e.length-1;n<r;n++,r--){let o=e[n];e[n]=e[r],e[r]=o}}function Wf(e){return Math.ceil(e/2)*2}function Ff(e,t,n,r,o){let s=o.height/2,a=Math.max(Wf(o.measurer.width(t,o.size,r)+2*o.padding),o.height);return{kind:e,width:a,up:s,down:s,kids:Lf,text:t,id:n,reach:0}}function vN(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 HE(e,t,n,r){return Math.max(e+t.down+r.sep+n.up,2*r.arc)}function YE(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 PN(e,t,n=1/0){let r=new Map,o=[[e,n]];for(let s=0;n!==1/0&&s<o.length;s++){let[a,i]=o[s];r.set(a,i);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 ol(a))o.push([l,Math.max(40,i-c)])}return $f(e,ol,(s,a)=>{let i=r.get(s)??1/0;switch(s.type){case"terminal":{let c=cl(s.value);return Ff(0,/^ +$/.test(c)?"␣".repeat(c.length):c,"",4,t)}case"nonterminal":return Ff(1,cl(s.name),s.name,0,t);case"special":return Ff(2,"? "+cl(s.text)+" ?","",2,t);case"sequence":{let c=Math.max(0,a.length-1)*t.gap,l=0,f=0;for(let w of a)c+=w.width,l=Math.max(l,w.up),f=Math.max(f,w.down);let p={kind:3,width:c,up:l,down:f,kids:a,text:"",id:"",reach:0};if(c<=i||a.length<2)return p;let u=[],m=[],h=0,b=()=>{let w=0,S=0;for(let O of m)w=Math.max(w,O.up),S=Math.max(S,O.down);u.push({kind:3,width:h,up:w,down:S,kids:m,text:"",id:"",reach:0}),m=[],h=0};for(let w of a)m.length&&h+t.gap+w.width>Math.max(40,i-6*t.arc)&&b(),h+=(m.length?t.gap:0)+w.width,m.push(w);if(b(),u.length<2)return p;let x=0,E=0;for(let w=0;w<u.length;w++)x=Math.max(x,u[w].width),w&&(E+=u[w-1].down+Math.max(t.sep,2*t.arc)+u[w].up);return{kind:7,width:x+6*t.arc,up:u[0].up,down:E+u[u.length-1].down,kids:u,text:"",id:"",reach:0}}case"choice":{let c=0,l=0;for(let p=0;p<a.length;p++)c=Math.max(c,a[p].width),p>0&&(l=HE(l,a[p-1],a[p],t));let f=a[a.length-1];return{kind:4,width:c+4*t.arc,up:a.length>0?a[0].up:0,down:f?l+f.down:0,kids:a,text:"",id:"",reach:0}}case"optional":return YE(a[0],t);case"repetition":{let{min:c,max:l}=s,f=a[0];if(c===1&&l===1)return f;let p=vN(c,l),u=Math.max(f.down+t.sep,2*t.arc),m=p===""?0:Wf(t.measurer.width(p,ll,0)),h={kind:6,width:Math.max(f.width,m)+2*t.arc,up:f.up,down:u+(p===""?nr/2+1:ll+6),kids:[f],text:p,id:"",reach:u};return c===0?YE(h,t):h}}})}function KE(e,t,n){return gn(n,r=>BN(e,t,n,r))}function BN(e,t,n,r){let o=n.fontSize??16,s=Hs(t,"fontSize",0,200),a=s||Math.round(o*.875),i=s||o,c=Hs(t,"padding",-1,200),l=Math.round(a*1.5),f={measurer:n.measurer??et(n.fontFamily,n.fontFamilyMono),size:a,padding:c<0?12:c,height:Wf(l+(c<0?9:2*c)),gap:Math.min(Hs(t,"horizontalSeparation",16,500),r?12:1/0),sep:Hs(t,"verticalSeparation",10,500),arc:Math.min(Hs(t,"arcRadius",10,200),r?6:1/0)},p=t.railroad?.showMarkers===!1?0:Hs(t,"markerRadius",4,50),u=Hs(t,"strokeWidth",0,20),m=u>0?` stroke-width="${d(u)}"`:"",h=n.padding??8,{arc:b}=f,x=d(b),E=(U,j,v)=>`a${x},${x} 0 0 ${U} ${j}${x},${v}${x}`,w=E(1,"",""),S=E(0,"",""),O=E(0,"","-"),D=E(1,"","-"),L=E(0,"-",""),B=E(0,"-","-"),W=We(e.title,!1,f.measurer,o,r?Tt(n):4e3,1),Y=W.height>0?W.height+16:0,I=Math.round(i*1.5),X=a*.35,ee=f.height/2,K="",z="",C="",M=(U,j,v)=>{v>U&&(K+=`M${d(U)},${d(j)}H${d(v)}`)},T=(U,j,v)=>{let k=[U],F=[j,v];for(;k.length>0;){let H=k.pop(),G=F.pop(),se=F.pop(),q=H.kids,P=se+H.width;switch(H.kind){case 3:{let V=P;for(let ne=q.length-1;ne>=0;ne--)V-=q[ne].width,k.push(q[ne]),F.push(V,G),ne>0&&M(V-f.gap,G,V),V-=f.gap;break}case 7:{let V=se+2*b,ne=k.length,ae=0;M(se,G,V);for(let Z=0;Z<q.length;Z++){let Q=q[Z],ie=G+ae;if(k.push(Q),F.push(ie,V),Z+1<q.length){let me=q[Z+1],re=ae+Q.down+Math.max(f.sep,2*b)+me.up,te=G+ae+Q.down+Math.max(f.sep,2*b)/2;K+=`M${d(V+Q.width)},${d(ie)}H${d(P-2*b)}V${d(te)}H${d(se+b)}V${d(G+re)}H${d(V)}`,z+=`M${d(V-nr)},${d(G+re-nr/2)}l${nr},${nr/2}l${-nr},${nr/2}z`,ae=re}else K+=`M${d(V+Q.width)},${d(ie)}H${d(P-b)}V${d(G)}H${d(P)}`}al(k,ne),al(F,2*ne);break}case 4:{let V=H.width-4*b,ne=se+b,ae=P-b,Z=k.length,Q=0;for(let ie=0;ie<q.length;ie++){let me=q[ie];ie>0&&(Q=HE(Q,q[ie-1],me,f));let re=G+Q,te=se+2*b+(V-me.width)/2,he=ie===q.length-1;ie===0?(M(se,G,te),M(te+me.width,G,P)):K+=(he?`M${d(se)},${d(G)}${w}V${d(re-b)}`:`M${d(ne)},${d(re-b)}`)+S+(te>ne+b?`H${d(te)}`:"")+`M${d(te+me.width)},${d(re)}`+(te>ne+b?`H${d(ae-b)}`:"")+O+(he?`V${d(G+b)}${D}`:""),k.push(me),F.push(re,te)}al(k,Z),al(F,2*Z);break}case 5:{let V=q[0],ne=se+2*b;M(se,G,ne),M(ne+V.width,G,P),K+=`M${d(se)},${d(G)}${O}V${d(G-H.reach+b)}${D}H${d(P-2*b)}${w}V${d(G-b)}${S}`,k.push(V),F.push(ne,G);break}case 6:{let V=q[0],ne=se+(H.width-V.width)/2,ae=G+H.reach,Z=se+H.width/2;M(se,G,ne),M(ne+V.width,G,P),K+=`M${d(se+b)},${d(G)}${L}V${d(ae-b)}${S}H${d(P-b)}${O}V${d(G+b)}${B}`,z+=`M${d(Z-nr/2)},${d(ae)}l${nr},${-nr/2}v${nr}z`,H.text!==""&&(C+=`<text class="pele-edge-label pele-count" x="${d(Z)}" y="${d(ae+ll+3)}" font-size="${ll}" fill="var(--_m)">${je(H.text)}</text>`),k.push(V),F.push(ne,G);break}default:{let V=H.text,ne=V.startsWith(" ")||V.endsWith(" ")||V.includes("  ")?' xml:space="preserve"':"",ae=`<rect x="${d(se)}" y="${d(G-ee)}" width="${d(H.width)}" height="${d(f.height)}"`,Z=`<text x="${d(se+H.width/2)}" y="${d(G+X)}"${ne}`;H.kind===0?C+=`<g class="pele-node pele-terminal">${ae} rx="${d(ee)}" fill="var(--_s)" stroke="var(--_b)"${m}/>${Z} font-family="${oo}">${je(V)}</text></g>`:H.kind===1?C+=`<g class="pele-node pele-nonterminal" data-id="${Fe(H.id)}">${ae} fill="var(--_bg)" stroke="var(--_b)"${m}${it}/>${Z}>${je(V)}</text></g>`:C+=`<g class="pele-node pele-special">${ae} fill="var(--_bg)" stroke="var(--_b)" stroke-dasharray="4 3"${m}${it}/>${Z} font-style="italic"><tspan fill="var(--_m)">? </tspan>${je(V.slice(2,-2))}<tspan fill="var(--_m)"> ?</tspan></text></g>`}}}},g="",_=W.width,y=h+Y,R=h+W.height;for(let U of e.rules){let j=PN(U.definition,f,r?Math.max(80,(n.maxWidth??320)-2*h-4*p-2*Bf-1):1/0),v=cl(U.name),k=y+I+$N+j.up,F=h+2*p,H=F+Bf,G=H+j.width+Bf;K="",z="",C="",M(F,k,H),M(H+j.width,k,G),T(j,H,k);let se=p>0?`<circle class="pele-marker pele-start" cx="${d(h+p)}" cy="${d(k)}" r="${d(p)}" fill="var(--_l)"/><circle class="pele-marker pele-end" cx="${d(G+p)}" cy="${d(k)}" r="${d(p)}" fill="var(--_l)"/>`:"";g+=`<g class="pele-rule" data-id="${Fe(U.name)}"><text class="pele-rule-name" x="${d(h)}" y="${d(y+I/2+i*.35)}" font-size="${d(i)}" font-weight="var(--_hw)" text-anchor="start">${je(v)}</text><path class="pele-edge pele-track" d="${K}" fill="none" stroke="var(--_l)"${m}/>`+(z?`<path class="pele-marker" d="${z}" fill="var(--_l)"/>`:"")+se+C+"</g>",_=Math.max(_,G+2*p-h,f.measurer.width(v,i,1)),R=k+j.down,y=R+f.sep+DN}let A=Math.ceil(_+2*h),N=Math.ceil(R+h),$=De(W,A/2,h+W.height/2,' class="pele-title" font-weight="var(--_tw)"')+(g?`<g class="pele-rules" transform="translate(0.5,0.5)" font-size="${d(a)}" text-anchor="middle">${g}</g>`:"");return{svg:Ze("railroad",A,N,o,n,e,$),width:A,height:N,links:[]}}var zE={type:"railroad",parse:(e,t,n)=>GE(e,n),render:KE};var Ks={REQUIREMENT:"Requirement",FUNCTIONAL_REQUIREMENT:"Functional Requirement",INTERFACE_REQUIREMENT:"Interface Requirement",PERFORMANCE_REQUIREMENT:"Performance Requirement",PHYSICAL_REQUIREMENT:"Physical Requirement",DESIGN_CONSTRAINT:"Design Constraint"},ul={LOW_RISK:"Low",MED_RISK:"Medium",HIGH_RISK:"High"},zo={VERIFY_ANALYSIS:"Analysis",VERIFY_DEMONSTRATION:"Demonstration",VERIFY_INSPECTION:"Inspection",VERIFY_TEST:"Test"},_r={CONTAINS:"contains",COPIES:"copies",DERIVES:"derives",SATISFIES:"satisfies",VERIFIES:"verifies",REFINES:"refines",TRACES:"traces"},FN=1e6,dl=class{constructor(){de(this,"type","requirement");de(this,"direction","TB");de(this,"requirements",new Map);de(this,"elements",new Map);de(this,"relations",[]);de(this,"classes",new Map);de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"newId","");de(this,"newText","");de(this,"newRisk","");de(this,"newVerifyMethod","");de(this,"newElementType","");de(this,"newDocRef","");de(this,"styleCopies",0)}copy(t,n){if(this.styleCopies+=n.length,this.styleCopies>FN)throw new ze("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 o=this.node(r);if(!n||!o)return;for(let s of n)this.copy(o.cssStyles,s.includes(",")?s.split(","):[s])}}setClass(t,n){for(let r of t){let o=this.node(r);if(o)for(let s of n){o.classes.push(s);let a=this.classes.get(s)?.styles;a&&this.copy(o.cssStyles,a)}}}defineClass(t,n){for(let r of t){let o=this.classes.get(r);o===void 0&&(o={id:r,styles:[],textStyles:[]},this.classes.set(r,o));for(let a of n)a.includes("color")&&o.textStyles.push(a.replace("fill","bgFill")),o.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,`
`)}};var Uf=["$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"],VE=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 UN=/accTitle\s*:\s*/iy,GN=/accDescr\s*:\s*/iy,YN=/accDescr\s*\{\s*/iy,fl=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi,Gf=/[\n\r\u2028\u2029]/g,HN=22,jE=new Uint8Array(128);for(let e of`:,\r
{<>-=`)jE[e.charCodeAt(0)]=1;function XE(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=[[],[],[],[]],l=[[],[],[],[]],f=[0,0,0,0],p=!1,u=-1;fl.lastIndex=0;for(let L=fl.exec(e);L!==null;L=fl.exec(e)){let B=L[1]!==void 0?0:L[2]!==void 0?1:L[3]!==void 0?2:3;c[B].push(L.index),l[B].push(fl.lastIndex),p=!0}let m=(L,B,W)=>{n.push(L),r.push(e.slice(B,W)),o.push(B),i=W},h=L=>{s.push(a),a=L},b=()=>{s.length>0&&(a=s.pop())},x=(L,B)=>(L.lastIndex=B,L.test(e)?L.lastIndex:-1),E=L=>{let B=e.indexOf(`
`,L);return B===-1?t:B},w=()=>{if(u<i){Gf.lastIndex=i,u=Gf.test(e)?Gf.lastIndex-1:t;for(let L=0;L<4;L++){let B=c[L],W=f[L];for(;W<B.length&&B[W]<=u;)W++;f[L]=W}}for(let L=0;L<4;L++){let B=f[L]-1;if(B>=0&&c[L][B]>=i)return m(8+L,i,E(l[L][B])),!0}return!1},S=L=>{let B=L|32;if(B===116&&e.slice(i+1,i+5).toLowerCase()==="itle"&&He(e.charCodeAt(i+5))){let W=i+6;for(;W<t;){let Y=e.charCodeAt(W);if(Y===35||Y===10||Y===59)break;W++}if(W>i+6)return m(2,i,W),!0}if(B===97&&(e.charCodeAt(i+1)|32)===99&&(e.charCodeAt(i+2)|32)===99){let W;if((W=x(UN,i))>=0)return h(3),m(3,i,W),!0;if((W=x(GN,i))>=0)return h(4),m(5,i,W),!0;if((W=x(YN,i))>=0)return h(5),i=W,!0}if(p&&!ys(L)&&w())return!0;if(L===10||L===13&&e.charCodeAt(i+1)===10){let W=i;for(;W<t;){let Y=e.charCodeAt(W);if(Y===10)W++;else if(Y===13&&e.charCodeAt(W+1)===10)W+=2;else break}return m(12,i,W),!0}if(He(L)){for(i++;i<t&&He(e.charCodeAt(i));)i++;return!0}if(L===35||L===37)return i=E(i),!0;if(Qe(L)){let W=i+1;for(;W<t&&Qe(e.charCodeAt(W));)W++;if(W-i<=HN){let Y=VE.get(e.slice(i,W).toLowerCase());if(Y!==void 0)return(Y===46||Y===47||Y===48)&&h(2),m(Y,i,W),!0}for(;W<t;){let Y=e.charCodeAt(W);if(Y<128&&jE[Y]===1)break;W++}return n.push(59),r.push(e.slice(i,W).trim()),o.push(i),i=W,!0}switch(L){case 123:return m(15,i,i+1),!0;case 125:return m(16,i,i+1),!0;case 58:return e.charCodeAt(i+1)===58&&e.charCodeAt(i+2)===58?m(17,i,i+3):m(18,i,i+1),!0;case 60:return e.charCodeAt(i+1)!==45?!1:(m(55,i,i+2),!0);case 45:return e.charCodeAt(i+1)===62?m(56,i,i+2):m(57,i,i+1),!0;case 34:return h(1),i++,!0;case 44:return m(60,i,i+1),!0}return!1},O=L=>{if(Qe(L)){let B=i+1;for(;B<t&&Qe(e.charCodeAt(B));)B++;return m(49,i,B),!0}switch(L){case 58:return m(50,i,i+1),!0;case 59:return m(51,i,i+1),!0;case 37:return m(52,i,i+1),!0;case 45:return m(53,i,i+1),!0;case 35:return m(54,i,i+1),!0;case 32:return i++,!0;case 34:return h(1),i++,!0;case 10:return b(),i++,!0;case 44:return m(60,i,i+1),!0}return!1};for(;i<t;){let L=e.charCodeAt(i),B=!0;switch(a){case 0:B=S(L);break;case 2:B=O(L);break;case 1:if(L===34)b(),i++;else{let W=e.indexOf('"',i);m(58,i,W===-1?t:W)}break;case 3:b(),m(4,i,E(i));break;case 4:b(),m(6,i,E(i));break;case 5:if(L===125)b(),i++;else{let W=e.indexOf("}",i);m(7,i,W===-1?t:W)}break}if(!B)return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}}let D=a===0?13:a===1?58:a===3?4:a===4?6:a===5?7:-1;return D!==-1&&m(D,t,t),m(0,t,t),{types:n,texts:r,starts:o}}var KN=[Ks.REQUIREMENT,Ks.FUNCTIONAL_REQUIREMENT,Ks.INTERFACE_REQUIREMENT,Ks.PERFORMANCE_REQUIREMENT,Ks.PHYSICAL_REQUIREMENT,Ks.DESIGN_CONSTRAINT,ul.LOW_RISK,ul.MED_RISK,ul.HIGH_RISK,zo.VERIFY_ANALYSIS,zo.VERIFY_DEMONSTRATION,zo.VERIFY_INSPECTION,zo.VERIFY_TEST,"",_r.CONTAINS,_r.COPIES,_r.DERIVES,_r.SATISFIES,_r.VERIFIES,_r.REFINES,_r.TRACES];function qE(e){return e===49||e===50||e===54||e===53||e===51}function QE(e,t){let{types:n,texts:r,starts:o}=XE(e),s=0,a=[],i=[],c=(E,w=E,...S)=>{let O=n[s];if(O===1)throw st("requirement",e,o[s],"",!0);for(let L=w;L>=E;L--)S.unshift(L);let D=S.map(L=>`'${Uf[L]}'`).join(", ");throw st("requirement",e,o[s],`Expecting ${D}, got '${Uf[O]}'`)},l=E=>(n[s]!==E&&c(E),r[s++]),f=(E,w)=>{let S=n[s];return(S<E||S>w)&&c(E,w),s++,KN[S-23]},p=()=>{let E=n[s];return E!==59&&E!==58&&c(58,59),r[s++]},u=()=>{let E=n[s];if(E===3)s++,t.setAccTitle(l(4).trim());else if(E===5)s++,t.setAccDescription(l(6).trim());else if(E===7)t.setAccDescription(r[s++].trim());else return!1;return!0},m=()=>{let E=[];for(;;){let w=n[s];if(w!==49&&w!==59&&w!==58&&c(58,59,49),E.push(r[s++]),n[s]!==60)return E;s++}},h=()=>{let E=[];for(;;){qE(n[s])||c(49,51,53,54);let w=r[s++];for(;qE(n[s]);)w+=r[s++];if(E.push(w),n[s]!==60)return E;s++}},b=()=>{let E;return n[s]===17?(s++,E=m(),l(15)):n[s]===15?s++:c(15,15,17),l(12),E},x=E=>{for(a.length=0,i.length=0;;){let w=n[s];if(w===16){s++;break}if(w===12){s++;continue}(E?w<19||w>22:w!==44&&w!==45)&&(E&&c(19,22,12,16),c(44,45,12,16)),s++,l(18),i.push(w===21?f(29,31):w===22?f(32,35):p()),a.push(w),l(12)}for(let w=a.length-1;w>=0;w--){let S=i[w];switch(a[w]){case 19:t.setNewReqId(S);break;case 20:t.setNewReqText(S);break;case 21:t.setNewReqRisk(S);break;case 22:t.setNewReqVerifyMethod(S);break;case 44:t.setNewElementType(S);break;default:t.setNewElementDocRef(S)}}};for(;u();)n[s]===12&&s++;for(n[s]!==14&&c(14,14,3,5,7),s++,l(12);;){let E=n[s];if(E===13)return;if(E===12)s++;else{if(u())continue;if(E>=8&&E<=11)s++,t.setDirection(E===8?"TB":E===9?"BT":E===10?"RL":"LR");else if(E>=23&&E<=28){let w=f(23,28),S=p(),O=b();x(!0),t.addRequirement(S,w),O&&t.setClass([S],O)}else if(E===36){s++;let w=p(),S=b();x(!1),t.addElement(w),S&&t.setClass([w],S)}else if(E===46){s++;let w=m();t.setCssStyle(w,h())}else if(E===47){s++;let w=m();t.defineClass(w,h())}else if(E===48){s++;let w=m();t.setClass(w,m())}else if(E===59||E===58){let w=r[s++],S=n[s];if(S===17)s++,t.setClass([w],m());else if(S===55||S===57){s++;let O=f(37,43);l(S===57?56:57);let D=p();S===57?t.addRelationship(O,w,D):t.addRelationship(O,D,w)}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 ZE(e){let t=[];for(let o of e.requirements.values())t.push({id:o.name,requirement:o,element:void 0,cssStyles:o.cssStyles,cssClasses:o.classes.join(" ")});for(let o of e.elements.values())t.push({id:o.name,requirement:void 0,element:o,cssStyles:o.cssStyles,cssClasses:o.classes.join(" ")});let n=o=>e.requirements.has(o)||e.elements.has(o)?o:void 0,r=e.relations.map((o,s)=>({id:`${o.src}-${o.dst}-${s}`,start:n(o.src),end:n(o.dst),type:o.type,contains:o.type===_r.CONTAINS}));return{nodes:t,edges:r,direction:e.direction}}var zN=40,VN=16,jN=56,pl=14,Vo=10,Yf=2,JE=12,XN=120,qN=280,QN=240,Hf=26,r0=6,e0=9,hl=4.5,ZN=28,JN=14;function ml(e,t,n){if(t===0||e.lines.length===0)return e;let r=0,o=[],s=e.lines.map(a=>{let i=0,c=a.map(l=>{let f=l.style|t,p=l.icon!==void 0||l.math?l.width:n.width(l.text,e.size,f);return i+=p,{...l,style:f,width:p}});return o.push(i),i>r&&(r=i),c});return{...e,lines:s,widths:o,width:r}}function t0(e,t,n,r){let o=Tr(e),s="",a="";for(let i=0;i<e.lines.length;i++){let c=e.lines[i],l=n+lr(e,i);if(mi(c)){a+=De(dr(e,i),t+e.widths[i]/2,l,r);continue}let f=l+e.size*.35,p=!0;for(let u of c)u.icon!==void 0||u.text===""||(s+=`<tspan${p?` x="${d(t)}" y="${d(f)}"`:""}${ar(u.style&~o)}>${je(u.text)}</tspan>`,p=!1)}return(s===""?"":`<text${jn(r,o)} text-anchor="start" xml:space="preserve">${s}</text>`)+a}function eM(e,t,n,r){let o=r0,s=e-n*o,a=t-r*o;return`<circle class="pele-marker" cx="${d(s)}" cy="${d(a)}" r="${o}"/><path class="pele-marker" d="M${d(s-n*o)},${d(a-r*o)}L${d(s+n*o)},${d(a+r*o)}M${d(s+r*o)},${d(a-n*o)}L${d(s-r*o)},${d(a+n*o)}"/>`}function tM(e,t,n,r){let o=e-n*e0,s=t-r*e0;return`<path class="pele-marker" d="M${d(o-r*hl)},${d(s+n*hl)}L${d(e)},${d(t)}L${d(o+r*hl)},${d(s-n*hl)}" stroke-linejoin="round"/>`}function nM(e,t,n){let r=new Map;for(let o of t){let s=o.route;if(!(o.src===o.dst||s.length<6))for(let a of[0,s.length-3]){let i=a===0?o.src:o.dst,c=e[i],l=s[a]-c.x,f=s[a+1]-c.y,p=a===0?3:a-3,u;if(Math.abs(Math.abs(f)-c.h/2)<.5)u=f<0?0:2;else if(Math.abs(Math.abs(l)-c.w/2)<.5)u=l<0?3:1;else continue;let m=i*4+u,h={route:s,at:a,toward:s[u%2===0?p:p+1]},b=r.get(m);b?b.push(h):r.set(m,[h])}}for(let[o,s]of r){if(s.length<2)continue;let a=o>>2,i=o%2===1,c=(i?n[a].h:n[a].w)-2*JN,l=Math.max(0,Math.min(ZN,c/(s.length-1)));s.sort((f,p)=>f.toward-p.toward);for(let f=0;f<s.length;f++){let p=(f-(s.length-1)/2)*l;i?s[f].route[s[f].at+1]=e[a].y+p:s[f].route[s[f].at]=e[a].x+p}}}function s0(e,t,n){return Tn(e.direction)?$t(n,r=>n0(e,t,n,r)):n0(e,t,n,!1)}function n0(e,t,n,r){let o=ZE(e),s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??et(n.fontFamily),c=n.padding??8,l=new Map,f=[],p=[];for(let z of o.nodes){let C=St(z.cssStyles),M=(C.bold?1:0)|(C.italic?2:0),T=C.fontSize??s,g=C.fontSize??a,_=z.requirement,y=z.element,R=ml(We(`«${_?_.type:"Element"}»`,!1,i,g,4e3),M,i),A=ml(We(z.id,!0,i,T,qN),M|1,i),N=_?[["ID",_.requirementId],["Text",_.text],["Risk",_.risk],["Verification",_.verifyMethod]]:[["Type",y.type],["Doc Ref",y.docRef]],$=[],U=0,j=0,v=0;for(let[G,se]of N){if(!se)continue;let q=ml(We(G,!1,i,g,4e3),M,i),P=ml(We(se,!0,i,g,QN),M,i),V=Math.max(q.height,P.height);$.push({key:q,value:P,height:V}),U=Math.max(U,q.width),j=Math.max(j,P.width),v+=V+Yf}$.length>0&&(v+=2*Vo-Yf);let k=2*Vo+R.height+A.height,F=Math.max(XN,Math.max(R.width,A.width)+2*pl,$.length>0?U+JE+j+2*pl:0);l.has(z.id)||l.set(z.id,f.length);let H=Pt(F,k+v);H.seq=f.length,f.push({node:z,style:C,kind:R,name:A,rows:$,keyWidth:U,headHeight:k,w:F,h:k+v}),p.push(H)}let u=r?"TB":rn(o.direction),m=u==="LR"||u==="RL",h=[],b=[],x=[];for(let z of o.edges){let C=z.start===void 0?void 0:l.get(z.start),M=z.end===void 0?void 0:l.get(z.end);if(C===void 0||M===void 0)continue;let T=We(`«${z.type}»`,!1,i,a,4e3);C===M&&(m?p[C].h+=2*(Hf+T.height+8):p[C].w+=2*(Hf+T.width+12)),x.push(z),b.push(T),h.push({src:C,dst:M,minlen:1,labelW:T.width+12,labelH:T.height+4,route:[],labelX:0,labelY:0})}let E=Rn(p,h,u,{nodeSep:zN,edgeSep:VN,rankSep:jN,portSep:20});nM(p,h,f);let w=hn(e.title,i,s,4e3),S=w.height>0?w.height+12:0,O=Math.max(E.width,w.width),D=c+(O-E.width)/2,L=c+S,B=Math.ceil(O+2*c),W=Math.ceil(E.height+S+2*c),Y="";for(let z=0;z<f.length;z++){let C=f[z],{w:M,h:T,style:g}=C,_=-M/2,y=-T/2,R=`<rect x="${d(_)}" y="${d(y)}" width="${d(M)}" height="${d(T)}" fill="var(--_s)" stroke="var(--_b)"${pt(g.shape)}/>`+De(C.kind,0,y+Vo+C.kind.height/2,` class="pele-stereotype" font-size="${C.kind.size}" fill="var(--_m)"${g.text}`)+De(C.name,0,y+Vo+C.kind.height+C.name.height/2,` class="pele-label" font-size="${C.name.size}" font-weight="var(--_hw)"${g.text}`);if(C.rows.length>0){let A=y+C.headHeight;R+=`<path class="pele-divider" d="M${d(_)},${d(A)}H${d(-_)}" stroke="var(--_b)"${g.line}/>`;let N=A+Vo,$="";for(let U of C.rows)$+=t0(U.key,_+pl,N,` class="pele-field" fill="var(--_m)"${g.text}`)+t0(U.value,_+pl+C.keyWidth+JE,N,` class="pele-value"${g.text}`),N+=U.height+Yf;R+=`<g class="pele-fields" font-size="${C.rows[0].key.size}">${$}</g>`}Y+=`<g class="pele-node ${C.node.requirement?"pele-requirement":"pele-element"}${Rt(C.node.cssClasses.replace(/^default\s?/,""))}" data-id="${Fe(C.node.id)}" transform="translate(${d(p[z].x+D)},${d(p[z].y+L)})">${R}</g>`}let I="",X="",ee=new Map;for(let z=0;z<h.length;z++){let C=h[z],M=x[z],T=b[z],g=M.contains?2*r0:0,_,y=C.labelX+D,R=C.labelY+L;if(C.src===C.dst){let A=f[C.src],N=p[C.src].x+D,$=p[C.src].y+L,U=ee.get(C.src)??0;ee.set(C.src,U+1);let j=(m?A.w:A.h)/2,v=Math.min(j-4,12+U*6),k=Hf+U*8,F=(G,se)=>m?`${d(N+se)},${d($+A.h/2+G)}`:`${d(N+A.w/2+G)},${d($+se)}`,H=k/.75;_={d:`M${F(g,-v)}C${F(H,-v)} ${F(H,v)} ${F(0,v)}`,sx:m?N-v:N+A.w/2,sy:m?$+A.h/2:$-v,sdx:m?0:-1,sdy:m?-1:0,ex:m?N+v:N+A.w/2,ey:m?$+A.h/2:$+v,edx:m?0:-1,edy:m?-1:0},m?(y=N,R=$+A.h/2+k+4+C.labelH/2):(y=N+A.w/2+k+4+C.labelW/2,R=$)}else{let A=C.route.slice();for(let N=0;N<A.length;N+=3)A[N]+=D,A[N+1]+=L;_=xn(A,void 0,g,0)}I+=`<g class="pele-edge pele-relationship-${M.contains?"contains":"arrow"}" data-id="${Fe(M.id)}"><path d="${_.d}"${M.contains?"":' stroke-dasharray="5 4"'}/>`+(M.contains?eM(_.sx,_.sy,_.sdx,_.sdy):tM(_.ex,_.ey,_.edx,_.edy))+"</g>",X+=sn(M.id,T,y,R,"")}return{svg:Ze("requirement",B,W,s,n,e,De(w,B/2,c+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+(I?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${I}</g>`:"")+(X?`<g class="pele-edge-labels" font-size="${a}" fill="var(--_m)">${X}</g>`:"")+`<g class="pele-nodes">${Y}</g>`),width:B,height:W,links:[]}}var i0={type:"requirement",math:!0,parse(e,t,n){let r=new dl;return n&&(r.title=n),QE(e,r),r},render:s0};var gl=class{constructor(){de(this,"type","sankey");de(this,"nodes",[]);de(this,"links",[]);de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"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 bl=["$end","STUCK","SANKEY","NEWLINE","COMMA","DQUOTE","NON_ESCAPED_TEXT","ESCAPED_TEXT","EOF"];function o0(e){return e>=32&&e<=126&&e!==34&&e!==44}function a0(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=(f,p,u)=>{n.push(f),r.push(e.slice(p,u)),o.push(p),i=u},l=f=>e.slice(i,i+f.length).toLowerCase()===f&&!Qe(e.charCodeAt(i+f.length));for(;i<t;){let f=e.charCodeAt(i),p=i,u=i;if(a===2){if(f===34&&e.charCodeAt(i+1)!==34){s.length>0&&(a=s.pop()),c(5,i,i+1);continue}for(;u<t;){let m=e.charCodeAt(u);if(o0(m)||m===44||m===13||m===10)u++;else if(m===34&&e.charCodeAt(u+1)===34)u+=2;else break}c(7,i,u)}else{if(a===0&&(f|32)===115){let m=l("sankey-beta")?11:l("sankey")?6:0;if(m>0){s.push(a),a=1,c(2,i,i+m);continue}}if(f===10||f===13&&e.charCodeAt(i+1)===10){c(3,i,f===10?i+1:i+2);continue}if(f===44){c(4,i,i+1);continue}if(f===34){s.push(a),a=2,c(5,i,i+1);continue}for(;u<t&&o0(e.charCodeAt(u));)u++;c(6,i,u)}if(u===p)return c(1,i,i),{types:n,texts:r,starts:o}}return c(a===2?7:8,t,t),c(0,t,t),{types:n,texts:r,starts:o}}var rM=/[\n\r]+/g;function c0(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 l0(e){let t=0,n=e.length;for(;t<n&&c0(e.charCodeAt(t));)t++;for(;n>t&&c0(e.charCodeAt(n-1));)n--;return e.slice(t,n).replace(rM,`
`).trim()}function d0(e,t){let{types:n,texts:r,starts:o}=a0(e),s=0,a=f=>{let p=n[s],u=p===1?bl[n[s-1]]:bl[p];throw st("sankey",e,o[s],`Expecting ${f}, got '${u}'`)},i=(f,p="")=>{n[s]!==f&&a(`'${bl[f]}'${p}`),s++},c=()=>{if(n[s]===6)return r[s++];n[s]!==5&&a("'DQUOTE', 'NON_ESCAPED_TEXT'"),s++,n[s]!==7&&a("'ESCAPED_TEXT'");let f=r[s++];return i(5),f},l=()=>c().trim().replaceAll('""','"');for(i(2),i(3);;){let f=l();i(4,", 'NEWLINE', 'EOF'");let p=l();i(4,", 'NEWLINE', 'EOF'");let u=c(),m=t.findOrCreateNode(f),h=t.findOrCreateNode(p);if(t.addLink(m,h,parseFloat(u.trim())),n[s]!==3)break;s++}n[s]===8&&s++,n[s]!==0&&a("'NEWLINE', 'EOF'")}var sM=6;function Kf(e,t){if(e.length>8){e.sort(t);return}for(let n=1;n<e.length;n++){let r=e[n],o=n-1;for(;o>=0&&t(e[o],r)>0;)e[o+1]=e[o],o--;e[o+1]=r}}function u0(e,t){let n=e.nodes.length,r=e.links.map(T=>({source:T.source.index,target:T.target.index,value:Number.isFinite(T.value)&&T.value>0?T.value:0,thickness:0,sourceY:0,targetY:0})),o=[],s=[];for(let T=0;T<n;T++)o.push([]),s.push([]);r.forEach((T,g)=>{o[T.source].push(g),s[T.target].push(g)});let a=new Int32Array(n),i=new Int32Array(n),c=[];for(let T=0;T<n;T++)i[T]=s[T].length,i[T]===0&&c.push(T);for(let T=0;T<c.length;T++){let g=c[T];for(let _ of o[g]){let y=r[_].target;a[y]<a[g]+1&&(a[y]=a[g]+1),--i[y]===0&&c.push(y)}}if(c.length<n){let T=0;for(;i[T]===0;)T++;let g=new Uint8Array(n);for(;g[T]===0;){g[T]=1;for(let _ of s[T])if(i[r[_].source]>0){T=r[_].source;break}}throw new ze(`Sankey diagrams cannot have circular links, and "${e.nodes[T].id}" is part of one.`,"semantic",{type:"sankey"})}let l=1;for(let T=0;T<n;T++)a[T]+1>l&&(l=a[T]+1);let f=new Int32Array(n);for(let T=n-1;T>=0;T--){let g=c[T];for(let _ of o[g])f[g]<f[r[_].target]+1&&(f[g]=f[r[_].target]+1)}let p=0;for(let T of r)T.value>p&&(p=T.value);let u=p>0?1/p:0,m=[],h=new Float64Array(n),b=[];for(let T=0;T<l;T++)b.push([]);let x=l>1?(t.width-t.nodeWidth)/(l-1):0;for(let T=0;T<n;T++){let g;if(t.alignment==="left")g=a[T];else if(t.alignment==="right")g=l-1-f[T];else if(t.alignment==="center"){if(g=a[T],s[T].length===0&&o[T].length>0){g=l;for(let N of o[T])a[r[N].target]-1<g&&(g=a[r[N].target]-1)}}else g=o[T].length>0?a[T]:l-1;let _=0,y=0,R=0,A=0;for(let N of s[T])_+=r[N].value*u,R+=r[N].value;for(let N of o[T])y+=r[N].value*u,A+=r[N].value;h[T]=Math.max(_,y),m.push({layer:g,value:Math.max(R,A),x:g*x,y:0,height:0}),b[g].push(T)}let E=1;for(let T of b)T.length>E&&(E=T.length);let w=E>1?Math.min(t.nodePadding,t.height/(E-1)):t.nodePadding,S=1/0;for(let T of b){let g=0;for(let _ of T)g+=h[_];g>0&&(S=Math.min(S,(t.height-(T.length-1)*w)/g))}(!Number.isFinite(S)||S<0)&&(S=0);let O=Math.max(0,t.labelHeight-w),D=T=>{for(let g of b){let _=(g.length-1)*w;for(let y of g)_+=Math.max(h[y]*T,O);if(_>t.height+1e-6)return!1}return!0};if(O>0&&!D(S))if(D(0)){let T=0;for(let g=0;g<40;g++){let _=(T+S)/2;D(_)?T=_:S=_}S=T}else O=0;let L=new Float64Array(n);for(let T of r)T.thickness=T.value*u*S;for(let T of b){let g=0;for(let y of T)m[y].height=h[y]*S,L[y]=Math.max(0,O-m[y].height)/2,m[y].y=g+L[y],g+=m[y].height+2*L[y]+w;let _=(t.height-g+w)/(T.length+1);T.forEach((y,R)=>m[y].y+=_*(R+1))}let B=T=>m[T].y+m[T].height/2,W=new Float64Array(r.length),Y=new Float64Array(r.length),I=(T,g)=>B(r[T].target)-B(r[g].target)||T-g,X=(T,g)=>B(r[T].source)-B(r[g].source)||T-g,ee=(T,g)=>B(T)-B(g)||T-g,K=T=>{let g=0;Kf(o[T],I);for(let _ of o[T])W[_]=g+r[_].thickness/2,g+=r[_].thickness},z=T=>{let g=0;Kf(s[T],X);for(let _ of s[T])Y[_]=g+r[_].thickness/2,g+=r[_].thickness},C=()=>{for(let T=0;T<n;T++)K(T),z(T)},M=(T,g,_)=>{for(let R of T){let A=_?s[R]:o[R];if(A.length===0)continue;_?z(R):K(R);let N=0,$=0,U=0;for(let v of A){let k=_?m[r[v].source].y+W[v]-Y[v]:m[r[v].target].y+Y[v]-W[v];N+=k*r[v].thickness,$+=r[v].thickness,U+=B(_?r[v].source:r[v].target)-m[R].height/2}let j=$>0?N/$:U/A.length;m[R].y+=(j-m[R].y)*g}Kf(T,ee);let y=0;for(let R of T)m[R].y-L[R]<y&&(m[R].y=y+L[R]),y=m[R].y+m[R].height+L[R]+w;y=t.height;for(let R=T.length-1;R>=0;R--){let A=T[R];m[A].y+m[A].height+L[A]>y&&(m[A].y=y-m[A].height-L[A]),y=m[A].y-L[A]-w}};C();for(let T=0;T<sM;T++){let g=Math.pow(.99,T);for(let _=l-2;_>=0;_--)M(b[_],g,!1);C();for(let _=1;_<l;_++)M(b[_],g,!0);C()}for(let T=0;T<r.length;T++)r[T].sourceY=m[r[T].source].y+W[T],r[T].targetY=m[r[T].target].y+Y[T];return{nodes:m,links:r}}var f0=6,iM=15;function g0(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function yl(e,t,n,r,o){let s=e[t];return typeof s=="number"&&s>=r?Math.min(s,o):n}function p0(e,t){let n=e[t];return typeof n=="string"||typeof n=="number"&&Number.isFinite(n)?String(n):""}function h0(e){return Math.abs(e)<1e15?Math.round(e*100)/100:e}function m0(e){return typeof e=="string"?St([`fill:${e}`]).shape:""}function b0(e,t,n){let r=g0(t.sankey)?t.sankey:{};return Kr(n,yl(r,"width",600,1,1e4),160,o=>oM(e,r,n,o))}function oM(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=n.measurer??et(n.fontFamily),i=n.padding??8,c=yl(t,"height",400,1,1e4),l=Math.min(yl(t,"nodeWidth",10,1,200),r),f=t.showValues!==!1,p=p0(t,"prefix"),u=p0(t,"suffix"),m=t.labelStyle==="outlined",h=t.nodeAlignment==="left"||t.nodeAlignment==="right"||t.nodeAlignment==="center"?t.nodeAlignment:"justify",b=typeof t.linkColor=="string"?t.linkColor:"gradient",{nodes:x,links:E}=u0(e,{width:r,height:c,nodeWidth:l,nodePadding:yl(t,"nodePadding",12,0,200)+(f?iM:0),labelHeight:s*1.15,alignment:h}),w=new Map;if(g0(t.nodeColors))for(let[A,N]of Object.entries(t.nodeColors)){let $=m0(N);$&&w.set(A,$)}let S=A=>w.get(e.nodes[A].id)??"",O=0,D=0;x.forEach(A=>{A.value>D&&(D=A.value,O=A.layer)});let L=0,B=r,W=0,Y=c,I="",X="";x.forEach((A,N)=>{let $=e.nodes[N].id,U=Math.max(A.height,1);X+=`<rect class="pele-sankey-node" data-id="${Fe($)}" x="${d(A.x)}" y="${d(A.y)}" width="${d(l)}" height="${d(U)}" rx="${d(Math.min(2,U/2))}" fill="${lt(N)}"${S(N)}/>`;let j=f?`${p}${h0(A.value)}${u}`:"",v=m?A.layer>=O:A.x<r/2,k=a.width(j?`${$} ${j}`:$,s,0),F=v?A.x+l+f0:A.x-f0,H=A.y+A.height/2;L=Math.min(L,v?F:F-k),B=Math.max(B,v?F+k:F),W=Math.min(W,H-s*.75),Y=Math.max(Y,H+s*.75);let G=` x="${d(F)}" y="${d(H+s*.35)}" text-anchor="${v?"start":"end"}"`,se=je($)+(j?` <tspan class="pele-sankey-value" fill="var(--_m)">${je(j)}</tspan>`:"");I+=`<g class="pele-label" data-id="${Fe($)}">`+(m?`<text${G} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${je($)}${j?" "+je(j):""}</text>`:"")+`<text${G}>${se}</text></g>`});let ee=b==="gradient"||b==="source"||b==="target"?"":m0(b),K="";for(let A of E){let N=b==="target"?A.target:A.source,$=Math.max(A.thickness,1)/2,U=x[A.source].x+l,j=x[A.target].x,v=d((U+j)/2),k=Fe(e.nodes[A.source].id),F=Fe(e.nodes[A.target].id);K+=`<path class="pele-sankey-link" data-id="${k}-&gt;${F}" d="M${d(U)},${d(A.sourceY-$)}C${v},${d(A.sourceY-$)} ${v},${d(A.targetY-$)} ${d(j)},${d(A.targetY-$)}L${d(j)},${d(A.targetY+$)}C${v},${d(A.targetY+$)} ${v},${d(A.sourceY+$)} ${d(U)},${d(A.sourceY+$)}Z" fill="${lt(N)}"${ee||S(N)}><title>${k} → ${F}: ${Fe(p)}${h0(A.value)}${Fe(u)}</title></path>`}let z=We(e.title,!1,a,o,Tt(n),1),C=z.height>0?z.height+12:0,M=Math.max(B-L,z.width),T=i-L+(M-(B-L))/2,g=i+C-W,_=Math.ceil(M+2*i),y=Math.ceil(Y-W+C+2*i);return{svg:Ze("sankey",_,y,o,n,e,De(z,_/2,i+z.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(T)},${d(g)})"><g class="pele-sankey-links" fill-opacity="0.4">${K}</g><g class="pele-sankey-nodes">${X}</g><g class="pele-labels" font-size="${s}">${I}</g></g>`),width:_,height:y,links:[]}}var y0={type:"sankey",parse(e,t,n){let r=new gl;return n&&(r.title=n),d0(l0(e),r),r},render:b0};var aM="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",E0,cM=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;function A0(e){if(e.toLowerCase()==="none")return 4;let t=cM.exec(e);return t?t[1]===void 0?1:t[1]==="%"?2:3:0}function lM(e,t){let n=A0(e);return n===1||n===2||t&&n===4}function dM(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 o=e.slice(n+1,-1).trim(),s,a,i=o.includes(",");if(i)s=o.split(",").map(l=>l.trim()),s.length===4&&(a=s.pop());else{let l=o.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&&!lM(a,!i))return!1;let c=s.map(A0);if(i)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 f=c[l];if(!(f===1||f===4||(t&&l===0?f===3:f===2)))return!1}return!0}function x0(e){return e.includes("(")?dM(e):(E0??=new Set(aM.split(" ")),E0.has(e.toLowerCase()))}var uM=/^:?wrap:/,fM=/^:?nowrap:/,pM=/^:?(?:no)?wrap:/,hM=/^(?:rgba?|hsla?)\s*\(/,S0=/[\r\u2028\u2029]/,mM=/^\w*/;function jo(e){throw new ze(e,"semantic",{type:"sequence"})}function _0(e){let t=e.trim(),n=uM.test(t)?!0:fM.test(t)?!1:void 0;return{text:(n===void 0?t:t.replace(pM,"")).trim(),wrap:n}}function gM(e){let t=hM.exec(e);if(t){let r=e.lastIndexOf(")");if(r>=t[0].length)return S0.test(e.slice(t[0].length))?void 0:[e.slice(0,r+1),e.slice(r+1)]}if(S0.test(e))return;let n=mM.exec(e)[0];return[n,e.slice(n.length)]}function w0(e){return typeof e=="string"?[...e].map((t,n)=>[String(n),t]):e!==null&&typeof e=="object"?Object.entries(e):[]}var El=class{constructor(t={}){de(this,"type","sequence");de(this,"actors",new Map);de(this,"createdActors",new Map);de(this,"destroyedActors",new Map);de(this,"boxes",[]);de(this,"messages",[]);de(this,"notes",[]);de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"prevActor");de(this,"currentBox");de(this,"lastCreated");de(this,"lastDestroyed");de(this,"wrapEnabled");de(this,"sequenceWrap");de(this,"active",new Map);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,`
`)}setDiagramTitle(t){this.title=t}parseMessage(t){return _0(t)}parseBoxData(t){let n=gM(t),r=n?.[0]?n[0].trim():"transparent",o=n?.[1]?n[1].trim():void 0;if(x0(r)||(r="transparent",o=t.trim()),o===void 0)return{text:void 0,color:r,wrap:void 0};let{text:s,wrap:a}=_0(o);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,o,s){let a=this.currentBox,i;if(s!==void 0){let p;try{p=Vn(s.includes(`
`)?s+`
`:`{
`+s+`
}`)}catch(u){throw new ze(`Config of participant "${t}" is not valid YAML. ${u.message}`,"syntax",{type:"sequence"})}p!==null&&typeof p=="object"&&!Array.isArray(p)&&(i=p)}let c=i&&Object.prototype.hasOwnProperty.call(i,"type")?i.type:void 0,l=i&&Object.prototype.hasOwnProperty.call(i,"alias")?i.alias:void 0;c!=null&&(o=String(c)),l&&(!r||r.text===n)&&(r={text:String(l),wrap:r?.wrap,type:o});let f=this.actors.get(t);if(!(f&&(this.currentBox&&f.box&&this.currentBox!==f.box&&jo(`A same participant should only be defined in one Box: ${f.name} can't be in '${f.box.name}' and in '${this.currentBox.name}' at the same time.`),a=f.box?f.box:this.currentBox,f.box=a,n===f.name&&r==null))){if((r?.text==null||o==null)&&(r={text:n,type:o}),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:o??"participant"}),this.prevActor){let p=this.actors.get(this.prevActor);p&&(p.nextActor=t)}this.currentBox&&this.currentBox.actorKeys.push(t),this.prevActor=t}}addMessage(t,n,r,o){this.messages.push({id:String(this.messages.length),from:t,to:n,message:r.text,wrap:r.wrap??this.autoWrap(),answer:o})}addSignal(t,n,r,o,s=!1,a){if(o===18){let i=t?this.active.get(t)??0:0;i<1&&jo(`Trying to inactivate an inactive participant (${t})`),this.active.set(t,i-1)}else o===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:o,activate:s,centralConnection:a??0}),!0}addNote(t,n,r){let o=r.wrap??this.autoWrap(),s={actor:t,placement:n,message:r.text,wrap:o},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:o,type:2,placement:n})}addLinks(t,n){let r=this.actors.get(t);if(r)try{let o=JSON.parse(n.text);for(let[s,a]of w0(o))r.links.set(s,a)}catch{return}}addALink(t,n){let r=this.actors.get(t);if(!r)return;let o=n.text.indexOf("@");r.links.set(n.text.slice(0,o-1).trim(),n.text.slice(o+1).trim())}addProperties(t,n){let r=this.actors.get(t);if(r)try{let o=JSON.parse(n.text);for(let[s,a]of w0(o))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=[],o=t;for(;;){o!==void 0&&(Array.isArray(o)?(n.push(o),r.push(0)):typeof o!="string"&&this.applyOne(o));let s=n.length-1;if(s<0)return;let a=n[s];r[s]<a.length?o=a[r[s]++]:(n.pop(),r.pop(),o=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)&&jo("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&&jo(`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&&jo(`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 zf=["$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 R0=new Uint8Array(128);for(let e=0;e<128;e++){let t=String.fromCharCode(e),n=e===32||e>=9&&e<=13,r=0;`/\\+()<->:
,;`.includes(t)||(r|=1),`+<->:
,;`.includes(t)||(r|=2),`<>:
,;@`.includes(t)||(r|=8|(n?0:4)),`#
;`.includes(t)||(r|=16),!`/\\+()<>:
,;-`.includes(t)&&!n&&(r|=32),R0[e]=r}function T0(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=-1,l=(g,_,y)=>{n.push(g),r.push(e.slice(_,y)),o.push(_),i=y},f=(g,_,y,R)=>{n.push(g),r.push(R),o.push(_),i=y},p=g=>{s.push(a),a=g},u=()=>{s.length>0&&(a=s.pop())},m=g=>(c<g&&(c=e.indexOf(`
`,g),c===-1&&(c=t)),c),h=(g,_)=>{let y=e.charCodeAt(g);return y<128?(R0[y]&_)!==0:_===4||_===32?!He(y):!0},b=(g,_)=>{for(let y=0;y<_.length;y++){let R=_.charCodeAt(y),A=e.charCodeAt(g+y);if(R>=97&&R<=122?(A|32)!==R:A!==R)return!1}return!0},x=g=>b(i,g)&&!Qe(e.charCodeAt(i+g.length)),E=g=>{for(;g<t&&He(e.charCodeAt(g));)g++;return g},w=()=>{let g=i;for(;g<t;){let _=e.charCodeAt(g);if(_===10||!He(_))break;g++}return g===i?!1:(i=g,!0)},S=g=>{for(;g<t&&h(g,16);)g++;return g},O=(g,_,y)=>{l(g,i,i+_),p(y)},D=(g,_,y=-1)=>x(g)?(l(_,i,i+g.length),y>=0&&p(y),!0):!1,L=(g,_)=>{if(!b(i,g))return!1;let y=i+g.length,R=e.charCodeAt(y);if(R!==32&&R!==9)return!1;for(;R===32||R===9;)R=e.charCodeAt(++y);return y>=t||!h(y,32)?!1:(l(_,i,i+g.length),!0)},B=g=>{let _=e.charCodeAt(g),y=e.charCodeAt(g+1);if(_===45){if(y===120||y===88||y===41||y===92||y===47||y===45)return!0;let R=e.charCodeAt(g+2);return y===124&&(R===92||R===47)}return _===47||_===92?(y===124||y===_)&&e.charCodeAt(g+2)===45:_===40&&y===41},W=()=>{let g=i+1;for(;g<t&&h(g,1);)g++;for(;g<t&&!B(g);){let _=g;for(;e.charCodeAt(_)===45;)_++;if(_>=t||!h(_,2))break;for(_++;_<t&&h(_,2);)_++;g=_}f(48,i,g,e.slice(i,g).trim())},Y=()=>{let g=i;for(;ft(e.charCodeAt(g));)g++;let _=g>i;if(e.charCodeAt(g)===46&&ft(e.charCodeAt(g+1))){let R=ft(e.charCodeAt(g+2))?g+3:g+2,A=e.charCodeAt(R);if(A===32||A===10)return l(10,i,R),!0}let y=e.charCodeAt(g);return _&&(y===32||y===10)?(l(10,i,g),!0):!1},I=()=>{let g=e.charCodeAt(i+1),_=e.charCodeAt(i+2);if(g===62)l(_===62?55:53,i,i+(_===62?3:2));else if(g===120||g===88)l(59,i,i+2);else if(g===41)l(61,i,i+2);else if(g===124&&_===92)l(63,i,i+3);else if(g===124&&_===47)l(64,i,i+3);else if(g===92&&_===92)l(65,i,i+3);else if(g===47&&_===47)l(66,i,i+3);else if(g===45){let y=e.charCodeAt(i+3);_===62?l(y===62?57:54,i,i+(y===62?4:3)):_===120||_===88?l(60,i,i+3):_===41?l(62,i,i+3):_===124&&y===92?l(67,i,i+4):_===124&&y===47?l(68,i,i+4):_===92&&y===92?l(69,i,i+4):_===47&&y===47?l(70,i,i+4):l(46,i,i+1)}else l(46,i,i+1)},X=g=>{let _=e.charCodeAt(i+1);if(_!==124&&_!==g||e.charCodeAt(i+2)!==45)return!1;let y=e.charCodeAt(i+3)===45,R=g===47,A;return _===124?y?A=R?75:76:A=R?71:72:y?A=R?77:78:A=R?73:74,l(A,i,i+(y?4:3)),!0},ee=()=>{if(!b(i,"title"))return!1;let g=i+5,_=e.charCodeAt(g)===58;return _&&g++,!He(e.charCodeAt(g))||g+1>=t||!h(g+1,16)?!1:(l(_?15:14,i,S(g+1)),!0)},K=()=>{let g=b(i,"accdescr");if(!g&&!b(i,"acctitle"))return!1;let _=E(i+8),y=e.charCodeAt(_);return y===58?(l(g?18:16,i,E(_+1)),p(g?6:5),!0):g&&y===123?(i=E(_+1),p(7),!0):!1},z=g=>{switch(g|32){case 97:return D("actor",34,1)||D("alt",24,3)||D("and",30,3)||D("activate",12,1)||K()||D("autonumber",9);case 98:return D("box",6,3)||D("break",28,3);case 99:return D("create",5)||D("critical",27,3);case 100:return D("destroy",35,1)||L("details",41)||D("deactivate",13,1);case 101:return D("else",31,3)||D("end",8);case 108:return D("loop",21,3)||D("left of",43)||L("links",38)||L("link",39);case 110:return D("note",36);case 111:return D("opt",23,3)||D("option",29,3)||D("over",37)||D("off",11);case 112:return D("participant",32,1)||D("par",25,3)||D("par_over",26,3)||L("properties",40);case 114:return D("rect",22,3)||D("right of",44);case 115:return D("sequencediagram",4);case 116:return ee();default:return!1}},C=()=>{let g=e.charCodeAt(i);if(g===10){let _=i+1;for(;e.charCodeAt(_)===10;)_++;l(3,i,_);return}if(He(g)){i=E(i+1);return}if(g===35||g===37&&e.charCodeAt(i+1)!==123){i=m(i);return}if(g!==125&&e.charCodeAt(i+1)===37&&e.charCodeAt(i+2)===37){i=m(i);return}if(!((ft(g)||g===46)&&Y())&&!(g<128&&(g|32)>=97&&(g|32)<=122&&z(g)))if(g===44)l(42,i,i+1);else if(g===59)l(3,i,i+1);else if(h(i,1))W();else if(g===45)I();else if(g===60&&e.startsWith("<<->>",i))l(56,i,i+5);else if(g===60&&e.startsWith("<<-->>",i))l(58,i,i+6);else{if((g===47||g===92)&&X(g))return;g===58?l(52,i,S(i+1)):g===43?l(45,i,i+1):g===40&&e.charCodeAt(i+1)===41?l(47,i,i+2):l(2,i,i+1)}},M=()=>{if(w())return!0;let g=e.charCodeAt(i);if(g===35)return i=m(i),!0;if(g===64&&e.charCodeAt(i+1)===123)return O(49,2,4),!0;let _=i;for(;_<t&&h(_,4);)_++;if(_>i){let R=E(_);if(e.charCodeAt(R)===64&&e.charCodeAt(R+1)===123)return l(48,i,_),!0;if(R>_&&b(R,"as")&&He(e.charCodeAt(R+2)))return l(48,i,_),p(2),!0}let y=_;for(;y<t&&h(y,8);)y++;if(y>i){let R=e.charCodeAt(y),A=y;if(y<t&&R!==10&&R!==59)for(A--;A>i&&e.charCodeAt(A)!==35;)A--;if(A>i)return f(48,i,A,e.slice(i,A).trim()),u(),!0}if(e.charCodeAt(y)===60)return l(2,i,m(i)),u(),!0;if(g!==10){let R=m(i);return f(2,i,R,e.slice(i,R).trim()),u(),!0}return!1},T=()=>{switch(a){case 0:return C(),!0;case 1:return M();case 2:return w()?!0:e.charCodeAt(i)===35?(i=m(i),!0):(u(),u(),x("as")?O(33,2,3):l(3,i,i),!0);case 3:return w()?!0:e.charCodeAt(i)===35?(i=m(i),!0):(l(7,i,S(i)),u(),!0);case 4:if(e.charCodeAt(i)!==125){let g=e.indexOf("}",i);return g===-1&&(g=t),l(50,i,g),!0}else{let g=E(i+1),_=g>i+1&&b(g,"as")&&He(e.charCodeAt(g+2));return l(51,i,i+1),u(),_?p(2):u(),!0}case 5:case 6:return l(a===5?17:19,i,m(i)),u(),!0;default:if(e.charCodeAt(i)===125)i++,u();else{let g=e.indexOf("}",i);g===-1&&(g=t),l(20,i,g)}return!0}};for(;i<t;)if(!T())return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o};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(""),o.push(t),{types:n,texts:r,starts:o}}var vt=new Int8Array(79).fill(-1);vt[53]=5;vt[54]=6;vt[55]=0;vt[57]=1;vt[56]=33;vt[58]=34;vt[59]=3;vt[60]=4;vt[61]=24;vt[62]=25;vt[63]=41;vt[64]=42;vt[65]=43;vt[66]=44;vt[67]=51;vt[68]=52;vt[69]=53;vt[70]=54;vt[71]=45;vt[72]=46;vt[73]=47;vt[74]=48;vt[75]=55;vt[76]=56;vt[77]=57;vt[78]=58;var wr=new Int8Array(79).fill(-1);wr[21]=2;wr[22]=3;wr[23]=4;wr[28]=5;wr[24]=6;wr[25]=7;wr[26]=7;wr[27]=8;wr[6]=1;var bM="'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'";function C0(e,t){let{types:n,texts:r,starts:o}=T0(e),s=0,a=S=>{let O=n[s];throw O===1?st("sequence",e,o[s],"",!0):st("sequence",e,o[s],`Expecting ${S}, got '${zf[O]}'`)},i=S=>(n[s]!==S&&a(`'${zf[S]}'`),r[s++]),c=()=>{let S=n[s];return S!==48&&S!==39&&a("'ACTOR'"),{type:"addParticipant",actor:r[s++]}},l=()=>t.parseMessage(i(52).trim().substring(1)),f=()=>{let S=n[s++];if(S===35){let D=c();return i(3),D.type="destroyParticipant",D}let O=c();if(n[s]===49&&n[s-1]===48){s++;let D=i(50);i(51),O.config=D.trim()}if(O.draw=S===32?"participant":"actor",n[s]===33){s++;let D=i(7);i(3),O.description=t.parseMessage(D)}else n[s]===3?s++:a("'AS', 'NEWLINE'");return O},p=S=>{let O=!1;n[s]===47&&(O=!0,s++);let D=vt[n[s]];D<0&&a(bM),s++;let L=n[s];(L===47||!O&&(L===45||L===46))&&s++;let B=c(),W=l(),Y={type:"addMessage",from:S.actor,to:B.actor,signalType:D,msg:W},I=[S,B,Y];if(O){let X=L===47;Y.activate=X,Y.centralConnection=X?61:60,X&&I.push({type:"centralConnection",signalType:59,actor:B.actor}),I.push({type:"centralConnectionReverse",signalType:60,actor:S.actor})}else L===45?(Y.activate=!0,I.push({type:"activeStart",signalType:17,actor:B.actor})):L===46?I.push({type:"activeEnd",signalType:18,actor:S.actor}):L===47&&(Y.activate=!0,Y.centralConnection=59,I.push({type:"centralConnection",signalType:59,actor:B.actor}));return I},u=S=>{s++;let O=c();return[O,{type:S,actor:O.actor,text:l()}]},m=()=>{s++;let S=n[s];if(S===37){s++;let L=c(),B=L,W=[L.actor,L.actor];if(n[s]===42){s++;let Y=c();B=[L,Y],W=[L.actor,Y.actor]}return[B,{type:"addNote",placement:2,actor:W,text:l()}]}S!==43&&S!==44&&a("'over', 'left_of', 'right_of'"),s++;let O=c(),D=S===43?0:1;return[O,{type:"addNote",placement:D,actor:O.actor,text:l()}]},h=()=>{s++;let S={type:"sequenceIndex",sequenceVisible:!0,signalType:26};return n[s]===10?(S.sequenceIndex=Number(r[s++]),S.sequenceIndexStep=n[s]===10?Number(r[s++]):1):n[s]===11&&(s++,S.sequenceVisible=!1),n[s]!==3&&a("'NEWLINE', 'NUM', 'off'"),s++,S},b=(S,O,D,L)=>{let B=S.list,W=S.sections;if(W)for(let Y=W.length-2;Y>=0;Y-=2){let I={type:O,signalType:L};I[D]=t.parseMessage(W[Y+1]),B=W[Y].concat([I,B])}return B},x=S=>{let O=S.text,D=S.list;switch(S.kind){case 1:D[0]={type:"boxStart",boxData:t.parseBoxData(O)},D.push({type:"boxEnd",boxText:O});break;case 2:D[0]={type:"loopStart",loopText:t.parseMessage(O),signalType:10},D.push({type:"loopEnd",loopText:O,signalType:11});break;case 3:D[0]={type:"rectStart",color:t.parseMessage(O),signalType:22},D.push({type:"rectEnd",color:t.parseMessage(O),signalType:23});break;case 4:D[0]={type:"optStart",optText:t.parseMessage(O),signalType:15},D.push({type:"optEnd",optText:t.parseMessage(O),signalType:16});break;case 5:D[0]={type:"breakStart",breakText:t.parseMessage(O),signalType:30},D.push({type:"breakEnd",optText:t.parseMessage(O),signalType:31});break;case 6:D=b(S,"else","altText",13),D[0]={type:"altStart",altText:t.parseMessage(O),signalType:12},D.push({type:"altEnd",signalType:14});break;case 7:D=b(S,"and","parText",20),D[0]={type:"parStart",parText:t.parseMessage(O),signalType:S.startType},D.push({type:"parEnd",signalType:21});break;default:D=b(S,"option","optionText",28),D[0]={type:"criticalStart",criticalText:t.parseMessage(O),signalType:27},D.push({type:"criticalEnd",signalType:29})}return D};for(;n[s]===3;)s++;i(4);let E=[],w={kind:0,text:"",startType:0,list:[],sections:void 0};for(;;){let S=n[s],O=w.list;if(w.kind===1){if(S===32||S===34||S===35)O.push(f());else if(S===3)O.push([]),s++;else if(S===8){s++;let D=x(w);w=E.pop(),w.list.push(D)}else a("'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'");continue}switch(S){case 3:case 2:O.push([]),s++;break;case 32:case 34:case 35:O.push(f());break;case 5:{s++;let D=n[s];D!==32&&D!==34&&D!==35&&a("'participant', 'participant_actor', 'destroy'");let L=f();L.type="createParticipant",O.push(L);break}case 48:O.push(p(c())),i(3);break;case 39:{let D=n[s+1];O.push(D===48||D===39?u("addALink"):p(c())),i(3);break}case 38:O.push(u("addLinks")),i(3);break;case 40:O.push(u("addProperties")),i(3);break;case 41:O.push(u("addDetails")),i(3);break;case 36:O.push(m()),i(3);break;case 9:O.push(h());break;case 12:case 13:{s++;let D=c();i(3),O.push(S===12?{type:"activeStart",signalType:17,actor:D.actor}:{type:"activeEnd",signalType:18,actor:D.actor});break}case 14:case 15:{let D=r[s++].substring(S===14?6:7);t.setDiagramTitle(D),O.push(D);break}case 16:{s++;let D=i(17).trim();t.setAccTitle(D),O.push(D);break}case 18:{s++;let D=i(19).trim();t.setAccDescription(D),O.push(D);break}case 20:{let D=r[s++].trim();t.setAccDescription(D),O.push(D);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{s++;let D=i(7);E.push(w),w={kind:wr[S],text:D,startType:S===26?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{w.kind!==(S===31?6:S===30?7:8)&&a("'end'"),s++;let L=i(7);(w.sections??=[]).push(O,L),w.list=[];break}case 8:{w.kind===0&&a("'NEWLINE', 'EOF'"),s++;let D=x(w);w=E.pop(),w.list.push(D);break}case 0:w.kind!==0&&a("'end'"),t.apply(O);return;default:a("'NEWLINE', 'ACTOR', 'participant', 'note', 'end'")}}}var yM=16,EM=10,N0=34,M0=4,Vs=5,zs=6,Wr=' fill="var(--_s)" stroke="var(--_b)"',Pi=' fill="none" stroke="var(--_b)"',AM=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]),xM=new Set(["actor","boundary","control","entity","database"]);function I0(e){return AM.has(e)?e:"participant"}function Al(e){return xM.has(e)}function k0(e,t,n,r,o=yM){if(Al(e))return{w:Math.max(40,t.width+8),h:N0+(t.height>0?M0+t.height:0)};let s=e==="collections"?Vs:e==="queue"?2*zs:0;return{w:Math.max(n,t.width+2*o)+s,h:Math.max(r,t.height+2*EM)+(e==="collections"?Vs:0)}}function SM(e,t,n){let r=d(t),o=s=>d(n+s);switch(e){case"actor":return`<circle cx="${r}" cy="${o(7)}" r="6"${Wr}/><path d="M${r},${o(13)}V${o(24)}M${d(t-10)},${o(17)}H${d(t+10)}M${d(t-8)},${o(34)}L${r},${o(24)}L${d(t+8)},${o(34)}"${Pi}/>`;case"boundary":return`<path d="M${d(t-19)},${o(6)}V${o(28)}M${d(t-19)},${o(17)}H${d(t-8)}"${Pi}/><circle cx="${d(t+3)}" cy="${o(17)}" r="11"${Wr}/>`;case"control":return`<circle cx="${r}" cy="${o(21)}" r="11"${Wr}/><path d="M${d(t+5)},${o(5)}L${d(t-1)},${o(10)}L${d(t+5)},${o(15)}"${Pi}/>`;case"entity":return`<circle cx="${r}" cy="${o(15)}" r="11"${Wr}/><path d="M${d(t-11)},${o(30)}H${d(t+11)}"${Pi}/>`;default:{let s=d(t-14),a=d(t+14);return`<path d="M${s},${o(7)}V${o(27)}A14,5 0 0 0 ${a},${o(27)}V${o(7)}A14,5 0 0 0 ${s},${o(7)}Z"${Wr}/><path d="M${s},${o(7)}A14,5 0 0 0 ${a},${o(7)}"${Pi}/>`}}}function L0(e,t,n,r,o,s){let{w:a,h:i}=r,c=' class="pele-label"';if(Al(e))return SM(e,t,n)+De(o,t,n+N0+M0+o.height/2,c,s);let l=t-a/2;if(e==="collections"){let f=a-Vs,p=i-Vs,u=`<rect x="${d(l+Vs)}" y="${d(n)}" width="${d(f)}" height="${d(p)}"${Wr}${it}/>`,m=`<rect x="${d(l)}" y="${d(n+Vs)}" width="${d(f)}" height="${d(p)}"${Wr}${it}/>`;return u+m+De(o,l+f/2,n+Vs+p/2,c,s)}if(e==="queue"){let f=d(l+zs),p=d(l+a-zs),u=d(n+i),m=d(i/2);return`<path d="M${f},${d(n)}H${p}A${zs},${m} 0 0 1 ${p},${u}H${f}A${zs},${m} 0 0 1 ${f},${d(n)}Z"${Wr}/><path d="M${p},${d(n)}A${zs},${m} 0 0 0 ${p},${u}"${Pi}/>`+De(o,t-zs/2,n+i/2,c,s)}return`<rect x="${d(l)}" y="${d(n)}" width="${d(a)}" height="${d(i)}"${Wr}${it}/>`+De(o,t,n+i/2,c,s)}var Xf=[];function dn(e,t,n,r=1,o=!1){Xf[e]={dotted:t,head:n,atStart:r!==1,atEnd:r!==0,bottom:o}}dn(0,!1,1);dn(1,!0,1);dn(3,!1,2);dn(4,!0,2);dn(5,!1,0);dn(6,!0,0);dn(24,!1,3);dn(25,!0,3);dn(33,!1,1,2);dn(34,!0,1,2);for(let e of[!1,!0]){let t=e?10:0;dn(41+t,e,4),dn(42+t,e,4,1,!0),dn(43+t,e,5),dn(44+t,e,5,1,!0),dn(45+t,e,4,0),dn(46+t,e,4,0,!0),dn(47+t,e,5,0),dn(48+t,e,5,0,!0)}var _M=new Map([[10,"loop"],[12,"alt"],[15,"opt"],[19,"par"],[32,"par"],[27,"critical"],[30,"break"],[22,"rect"]]),wM=12,Vf=28,$0=22,rr=10,D0=4,RM=14,Bi=10,TM=16,CM=20,NM=10,xl=20,O0=240,Sl=16,Fi=4,v0=' stroke-dasharray="4 4"';function jf(e){return e!==void 0&&Xf[e]!==void 0}function MM(e,t){let n=new Array(e.length),r=new Array(e.length),o=1,s=1,a=!1;for(let i=0;i<e.length;i++){let c=e[i];if(n[i]=NaN,r[i]=!1,c.type===26){let l=c.message;o=l.start||o,s=l.step||s,a=l.visible}else jf(c.type)&&(n[i]=o,r[i]=a||t,o=Math.round((o+s)*100)/100)}return{index:n,shown:r,visible:a}}var P0={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function js(e,t,n){let r=e[t];return typeof r=="number"&&r>=0&&r<=2e3?r:n}function B0(e,t,n,r,o){let s=d(e-n*Ot);return o?`<path class="pele-marker" d="M${d(e)},${d(t)}L${s},${d(t+r*5)}"/>`:`<path class="pele-marker" d="M${d(e)},${d(t)}L${s},${d(t+r*4.5)}V${d(t)}Z" fill="var(--_l)" stroke="none"/>`}function _l(e,t,n,r,o){switch(e){case 1:return Et("arrow_point",t,n,r,0,"var(--_l)");case 2:return Et("arrow_cross",t,n,r,0,"var(--_l)");case 3:return`<path class="pele-marker" d="M${d(t-r*Ot)},${d(n-4.5)}L${d(t)},${d(n)}L${d(t-r*Ot)},${d(n+4.5)}" stroke-linejoin="round"/>`;case 4:return B0(t,n,r,o,!1);case 5:return B0(t,n,r,o,!0);default:return""}}function IM(e){return e===1?Ot-1:e===2?4:0}function F0(e,t,n){return gn(n,r=>kM(e,t,n,r))}function kM(e,t,n,r){let o=t.sequence??{},s=n.fontSize??16,a=Math.round(s*.875),i=Math.round(s*.75),c=n.measurer??et(n.fontFamily),l=n.icons,f=n.padding??8,p=o.mirrorActors!==!1,u=o.rightAngles===!0,m=Math.min(js(o,"actorMargin",40),r?8:1/0),h=Math.min(js(o,"width",64),r?48:1/0),b=js(o,"height",Math.round(s*1.5)+20),x=Math.min(js(o,"width",160),r?Math.max(32,((n.maxWidth??320)-2*f)/Math.max(1,e.actors.size)-m-24):1/0),E=Math.max(4,14+js(o,"messageMargin",35)-35),w=Math.min(js(o,"noteMargin",10),r?6:1/0),S=Math.min(js(o,"boxMargin",10),r?6:1/0),O=o.messageAlign==="left"?-1:o.messageAlign==="right"?1:0,D=r?6:wM,L=r?8:TM,B=r?12:CM,W=r?6:NM,Y=e.messages,I=Y.length,X=MM(Y,o.showSequenceNumbers===!0),ee=(J,_e,le,we=x,Te=0)=>{let Ce=We(J,!1,c,_e,r||le?we:1/0,Te);return r?Is(Ce,c,Math.max(120,we)):Ce},K;if(o.hideUnusedParticipants===!0){K=new Set;for(let J of Y)K.add(J.from).add(J.to)}let z=new Int32Array(I+1);z[I]=-1;for(let J=I-1;J>=0;J--)z[J]=jf(Y[J].type)?J:z[J+1];let C=[],M=new Map;for(let[J,_e]of e.actors){if(K&&!K.has(J))continue;let le=I0(_e.type),we=ee(_e.description,s,_e.wrap),Te=e.createdActors.get(J),Ce=e.destroyedActors.get(J),Ie=Te===void 0?-1:z[Math.min(Te,I)];Ie>=0&&Y[Ie].to!==J&&(Ie=-1);let Pe=Ce===void 0?-1:z[Math.min(Ce,I)];Pe>=0&&Y[Pe].to!==J&&Y[Pe].from!==J&&(Pe=-1),M.set(J,C.length),C.push({id:J,actor:_e,kind:le,label:we,size:k0(le,we,h,b,r?8:void 0),x:0,createAt:Ie,destroyAt:Pe,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let T=C.length-1,g=new Map,_=(J,_e,le)=>{if(J<0||_e>T)return;let we=J*C.length+_e;(g.get(we)??0)<le&&g.set(we,le)},y=J=>X.shown[J]?Math.max(Sl,c.width(String(X.index[J]),i,0)+8):0,R=new Array(I);for(let J=0;J<I;J++){let _e=Y[J],le=_e.from===void 0?void 0:M.get(_e.from),we=_e.to===void 0?void 0:M.get(_e.to);if(!(le===void 0||we===void 0||typeof _e.message!="string")){if(_e.type===2){let Te=ee(_e.message,a,_e.wrap),Ce=Te.width+2*w;_e.placement===0?_(le-1,le,Ce+2*Bi+rr):_e.placement===1?_(le,le+1,Ce+2*Bi+rr):le===we?(_(le-1,le,Ce/2+Bi),_(le,le+1,Ce/2+Bi)):_(Math.min(le,we),Math.max(le,we),Ce-2*L),R[J]={kind:2,a:le,b:we,label:Te,x:0,w:Ce}}else if(jf(_e.type)){let Te=ee(_e.message,a,_e.wrap),Ce=y(J);if(le===we)_(le,le+1,Vf+8+Te.width+16+rr+Ce),R[J]={kind:1,a:le,b:we,label:Te,x:0,w:0};else{let Ie=C[we].createAt===J?C[we].size.w/2:0,Pe=_e.centralConnection?4*Fi:0;_(Math.min(le,we),Math.max(le,we),(r?Math.min(Te.width,Math.max(16,x-16)):Te.width)+2*D+rr+Ce+Ie+Pe),R[J]={kind:0,a:le,b:we,label:Te,x:0,w:0}}}}}let A=[];for(let J=0;J<=T;J++){let _e=C[J].actor.box,le=A[A.length-1];_e&&le&&le.box===_e&&le.last===J-1?le.last=J:_e&&A.push({box:_e,first:J,last:J,title:ee(_e.name,a,_e.wrap),grow:0})}let N=new Array(Math.max(T,0));for(let J=0;J<T;J++){let _e=C[J],le=C[J+1],we=_e.actor.box!==le.actor.box?(_e.actor.box?S:0)+(le.actor.box?S:0):0;N[J]=Math.max(_e.size.w/2+le.size.w/2+m+we,g.get(J*C.length+J+1)??0)}let $=[];for(let[J,_e]of g){let le=Math.floor(J/C.length),we=J%C.length;we-le>1&&$.push([le,we,_e])}$.sort((J,_e)=>J[1]-J[0]-(_e[1]-_e[0])||J[0]-_e[0]);for(let[J,_e,le]of $){let we=0;for(let Ce=J;Ce<_e;Ce++)we+=N[Ce];if(we>=le)continue;let Te=(le-we)/(_e-J);for(let Ce=J;Ce<_e;Ce++)N[Ce]+=Te}let U=()=>{for(let J=1;J<=T;J++)C[J].x=C[J-1].x+N[J-1]};U();for(let J of A){let _e=C[J.last].x+C[J.last].size.w/2-(C[J.first].x-C[J.first].size.w/2);J.grow=Math.max(0,(J.title.width-_e)/2),J.grow!==0&&(J.first>0&&(N[J.first-1]+=J.grow),J.last<T&&(N[J.last]+=J.grow))}U();let j=1/0,v=-1/0,k=(J,_e)=>{J<j&&(j=J),_e>v&&(v=_e)};for(let J of C)k(J.x-J.size.w/2,J.x+J.size.w/2);for(let J of A)k(C[J.first].x-C[J.first].size.w/2-S-J.grow,C[J.last].x+C[J.last].size.w/2+S+J.grow);let F=new Array(I),H=[],G=()=>T<0?[0,120]:[C[0].x-B,C[T].x+B];for(let J=0;J<I;J++){let _e=Y[J],le=_e.type,we=le===void 0?void 0:_M.get(le),Te=R[J];if(we!==void 0){let Ce={kind:we,x0:1/0,x1:-1/0,top:0,title:P0,tabW:0,fill:we==="rect"&&typeof _e.message=="string"?_e.message:"",dividers:[J],dividerY:[],dividerLabels:[]};F[J]=Ce,H.push(Ce)}else if(le===13||le===20||le===28)H[H.length-1]?.dividers.push(J);else if(le===11||le===14||le===16||le===21||le===29||le===31||le===23){let Ce=H.pop();if(!Ce)continue;if(F[J]=Ce,Ce.x0>Ce.x1&&([Ce.x0,Ce.x1]=G()),Ce.kind!=="rect"){Ce.tabW=c.width(Ce.kind,i,1)+14;for(let Pe=0;Pe<Ce.dividers.length;Pe++){let Ue=Y[Ce.dividers[Pe]].message,ke=Pe===0?Ce.tabW+8:0,Ke=Ce.x1-Ce.x0-16-ke,Ve=Ue?ee(`[${Ue}]`,a,!0,Math.max(Ke,r?Math.min(O0,x):O0)):P0;Ve.width>Ke&&(Ce.x1+=Ve.width-Ke),Pe===0?Ce.title=Ve:Ce.dividerLabels.push(Ve)}}k(Ce.x0,Ce.x1);let Ie=H[H.length-1];Ie&&(Ie.x0=Math.min(Ie.x0,Ce.x0-W),Ie.x1=Math.max(Ie.x1,Ce.x1+W))}else if(Te){let Ce=C[Te.a],Ie=C[Te.b],Pe,Ue;if(Te.kind===2){if(_e.placement===0)Te.x=Ce.x-Bi-Te.w;else if(_e.placement===1)Te.x=Ce.x+Bi;else if(Te.a===Te.b)Te.x=Ce.x-Te.w/2;else{let Ke=Math.min(Ce.x,Ie.x)-L,Ve=Math.max(Ce.x,Ie.x)+L;(r||_e.wrap)&&(Te.label=ee(_e.message,a,!0,Math.max(x,Ve-Ke-2*w))),Te.w=Math.max(Ve-Ke,Te.label.width+2*w),Te.x=(Ke+Ve-Te.w)/2}Pe=Te.x,Ue=Te.x+Te.w}else Te.kind===1?(Pe=Ce.x,Ue=Ce.x+rr+Vf+8+Te.label.width+y(J)):(Pe=Math.min(Ce.x,Ie.x),Ue=Math.max(Ce.x,Ie.x),(r||_e.wrap)&&(Te.label=ee(_e.message,a,!0,Math.max(x,Ue-Pe-2*D-rr))),Ie.createAt===J&&(Ie.x>Ce.x?Ue+=Ie.size.w/2:Pe-=Ie.size.w/2));k(Pe,Ue);let ke=H[H.length-1];ke&&(ke.x0=Math.min(ke.x0,Pe-B),ke.x1=Math.max(ke.x1,Ue+B))}}let se=0;for(let J of A)se=Math.max(se,J.title.height);let q=A.length>0?S+(se>0?se+4:0):0,P=0;for(let J of C)J.createAt<0&&(P=Math.max(P,J.size.h));let V=q+P;for(let J of C)J.top=V-J.size.h,J.lifeStart=V;let ne=C.map(J=>J.x),ae=(J,_e)=>{let le=0,we=ne.length;for(;le<we;){let Te=le+we>>1;ne[Te]<=J?le=Te+1:we=Te}return le<ne.length&&ne[le]<_e},Z=(J,_e,le,we)=>{if(J.width===0)return"";let Te=_e-J.width/2;return(ae(Te,Te+J.width)?`<rect x="${d(Te-3)}" y="${d(le-J.height/2+2)}" width="${d(J.width+6)}" height="${d(J.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:"")+De(J,_e,le,we,l)},Q=(J,_e=0)=>J.activations.length+_e>0?J.x-rr/2:J.x,ie=(J,_e=0)=>{let le=J.activations.length+_e;return le>0?J.x+rr/2+(le-1)*D0:J.x},me=[],re=[],te="",he="",oe="",ge="",Ee="",be="",ye=(J,_e)=>{let le=J.activations.pop(),we=Math.max(_e,le+RM),Te=J.x-rr/2+J.activations.length*D0;return k(Te,Te+rr),re.push(`<rect class="pele-activation" data-id="${Fe(J.id)}" x="${d(Te)}" y="${d(le)}" width="${rr}" height="${d(we-le)}" rx="2"/>`),we},Re=(J,_e)=>{let le=J.x,we=_e+16;return J.lifeEnd=we,be+=`<path class="pele-destroy" data-id="${Fe(J.id)}" d="M${d(le-6)},${d(we-6)}L${d(le+6)},${d(we+6)}M${d(le+6)},${d(we-6)}L${d(le-6)},${d(we+6)}"/>`,we+6},Le=(J,_e,le)=>{let we=J.actor.properties.get("class");return`<g class="pele-node pele-actor pele-actor-${J.kind}${le?" pele-actor-footer":""}${typeof we=="string"?Rt(we):""}" data-id="${Fe(J.id)}">`+L0(J.kind,J.x,_e,J.size,J.label,l)+"</g>"},ue=(J,_e,le,we)=>`<g class="pele-sequence-number"><rect x="${d(_e-we/2)}" y="${d(le-Sl/2)}" width="${d(we)}" height="${Sl}" rx="${Sl/2}" fill="var(--_l)" stroke="none"/><text x="${d(_e)}" y="${d(le+i*.35)}" text-anchor="middle" font-size="${i}" fill="var(--_bg)" stroke="none">${je(String(X.index[J]))}</text></g>`,fe=V+6,Me=[];for(let J=0;J<I;J++){let _e=Y[J],le=_e.type,we=R[J],Te=F[J];if(le===17){let Ce=_e.from===void 0?void 0:M.get(_e.from);Ce!==void 0&&C[Ce].activations.push(fe)}else if(le===18){let Ce=_e.from===void 0?void 0:M.get(_e.from);Ce!==void 0&&C[Ce].activations.length>0&&(fe=Math.max(fe,ye(C[Ce],fe)))}else if(Te&&Te.dividers[0]===J)Me.push(Te),Te.kind==="rect"?(Te.top=fe+8,fe=Te.top):(Te.top=fe+12,fe=Te.top+Math.max(xl,Te.title.height+2));else if(Te){Me.pop();let Ce=fe+12,Ie=d(Te.x0),Pe=d(Te.x1-Te.x0);if(Te.kind==="rect"){let Ue=Te.fill?St([`fill:${Te.fill}`]).shape:"";me.push(`<rect class="pele-rect" x="${Ie}" y="${d(Te.top)}" width="${Pe}" height="${d(Ce-Te.top)}"${pt((Ue?"":' fill-opacity="0.5"')+Ue)}/>`)}else{let Ue=`<rect x="${Ie}" y="${d(Te.top)}" width="${Pe}" height="${d(Ce-Te.top)}" fill="none"${it}/>`;for(let ke=0;ke<Te.dividerY.length;ke++){let Ke=Te.dividerY[ke],Ve=Te.dividerLabels[ke];Ue+=`<path d="M${Ie},${d(Ke)}H${d(Te.x1)}"${v0}/>`+Z(Ve,Te.x0+8+Ve.width/2,Ke+2+Ve.height/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"')}Ue+=`<rect x="${Ie}" y="${d(Te.top)}" width="${d(Te.tabW)}" height="${xl}" fill="var(--_s)"${it}/><text class="pele-frame-kind" x="${d(Te.x0+Te.tabW/2)}" y="${d(Te.top+xl/2+i*.35)}" text-anchor="middle" font-size="${i}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${Te.kind}</text>`+Z(Te.title,Te.x0+Te.tabW+8+Te.title.width/2,Te.top+Math.max(xl,Te.title.height)/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"'),te+=`<g class="pele-frame pele-frame-${Te.kind}">${Ue}</g>`}fe=Ce}else if(le===13||le===20||le===28){let Ce=Me[Me.length-1];if(Ce){let Ie=Ce.dividerLabels[Ce.dividerY.length];Ce.dividerY.push(fe+12),fe+=12+(Ie.height>0?Ie.height:0)}}else if(we&&we.kind===2){let Ce=C[we.a],Ie=we.label.height+2*Math.max(4,w-4),Pe=fe+10,Ue=we.x;_e.placement===1?Ue+=ie(Ce)-Ce.x:_e.placement===0&&(Ue+=Q(Ce)-Ce.x),k(Ue,Ue+we.w),ge+=`<g class="pele-note" data-id="i${Fe(_e.id)}"><rect x="${d(Ue)}" y="${d(Pe)}" width="${d(we.w)}" height="${d(Ie)}"${it}/>`+De(we.label,Ue+we.w/2,Pe+Ie/2,' class="pele-label" stroke="none" fill="var(--_fg)"',l)+"</g>",fe=Pe+Ie}else if(we){let Ce=Xf[le],Ie=C[we.a],Pe=C[we.b],Ue=we.label,ke=y(J),Ke=0;for(let qe=J+1;qe<I;qe++){let at=Y[qe].type;if(at===17)Y[qe].from===_e.to&&Ke++;else if(at!==18&&at!==59&&at!==60)break}let Ve=Ce.bottom?1:-1,ct=Ce.dotted?v0:"",tt=_e.centralConnection,rt=tt===59||tt===61,Ct=tt===60||tt===61,dt=(qe,at)=>`<circle class="pele-central" cx="${d(qe)}" cy="${d(at)}" r="${Fi}" fill="var(--_l)" stroke="none"/>`,It=Ce.atStart&&!Ce.atEnd,xt=IM(Ce.head),_t="",Xe;if(we.kind===1){let qe=fe+E+Math.max(0,(Ue.height-$0)/2),at=qe+$0,ot=Ct?Ie.x+Fi:ie(Ie),kt=rt?Ie.x+Fi:ie(Ie,Ke),bt=Math.max(ot,kt)+Vf+ke/2;Ct&&(_t+=dt(Ie.x,qe)),rt&&(_t+=dt(Ie.x,at)),ke>0&&(_t+=ue(J,It?kt:ot,It?at:qe,ke),It?kt+=ke/2:ot+=ke/2);let Je=(Ce.atStart?_l(Ce.head,ot,qe,-1,Ve):"")+(Ce.atEnd?_l(Ce.head,kt,at,-1,-Ve):""),wt=d(ot+(Ce.atStart?xt:0)),ut=d(kt+(Ce.atEnd?xt:0));_t=`<path d="${u?`M${wt},${d(qe)}H${d(bt)}V${d(at)}H${ut}`:`M${wt},${d(qe)}H${d(bt-6)}A6,6 0 0 1 ${d(bt)},${d(qe+6)}V${d(at-6)}A6,6 0 0 1 ${d(bt-6)},${d(at)}H${ut}`}"${ct}/>`+Je+_t,k(Ie.x,bt+8+Ue.width),Ue.width>0&&(oe+=`<g class="pele-edge-label" data-id="i${Fe(_e.id)}">${De(Ue,bt+8+Ue.width/2,(qe+at)/2,"",l)}</g>`),Xe=Math.max(at,(qe+at)/2+Ue.height/2)}else{let qe=Pe.x>Ie.x?1:-1,at=Pe.createAt===J;Xe=fe+E+Math.max(Ue.height>0?Ue.height+2:6,at?Pe.size.h/2-E+6:0);let ot=qe>0?ie(Ie):Q(Ie),kt=qe>0?Q(Pe,Ke):ie(Pe,Ke);if(at&&(Pe.top=Xe-Pe.size.h/2,Pe.lifeStart=Pe.top+Pe.size.h,kt=Pe.x-qe*(Al(Pe.kind)?18:Pe.size.w/2+1)),Ct&&(_t+=dt(Ie.x,Xe),ot=Ie.x+qe*Fi),rt&&(_t+=dt(Pe.x,Xe),kt=Pe.x-qe*Fi),ke>0)if(It){let ut=rt?kt-qe*(ke/2+2):kt;_t+=ue(J,ut,Xe,ke),kt=ut-qe*ke/2}else{let ut=Ct?ot+qe*(ke/2+2):ot;_t+=ue(J,ut,Xe,ke),ot=ut+qe*ke/2}let bt=(Ce.atStart?_l(Ce.head,ot,Xe,-qe,Ve*qe):"")+(Ce.atEnd?_l(Ce.head,kt,Xe,qe,Ve*qe):""),Je=ot+(Ce.atStart?qe*xt:0),wt=kt-(Ce.atEnd?qe*xt:0);if(_t=`<path d="M${d(Je)},${d(Xe)}H${d(wt)}"${ct}/>`+bt+_t,Ue.width>0){let ut=Math.min(ot,kt),Nt=Math.max(ot,kt),Dt=O<0?ut+D+Ue.width/2:O>0?Nt-D-Ue.width/2:(ut+Nt)/2;k(Dt-Ue.width/2,Dt+Ue.width/2),oe+=`<g class="pele-edge-label" data-id="i${Fe(_e.id)}">${Z(Ue,Dt,Xe-4-Ue.height/2,"")}</g>`}at&&(fe=Xe+Pe.size.h/2-6)}he+=`<g class="pele-edge pele-message" data-id="i${Fe(_e.id)}">${_t}</g>`,fe=Math.max(fe,Xe),Ie.destroyAt===J&&(fe=Math.max(fe,Re(Ie,Xe))),Pe.destroyAt===J&&Pe!==Ie&&(fe=Math.max(fe,Re(Pe,Xe)))}}fe+=20;for(let J of C)for(;J.activations.length>0;)ye(J,fe);let Ne=fe;if(p){let J=0;for(let _e of C)_e.lifeEnd>=0||(J=Math.max(J,_e.size.h),Ee+=Le(_e,fe,!0));Ne=fe+J}let Be="";for(let J of C){Ee+=Le(J,J.top,!1);let _e=J.lifeEnd>=0?J.lifeEnd:fe;_e>J.lifeStart&&(Be+=`<path class="pele-lifeline" data-id="${Fe(J.id)}" d="M${d(J.x)},${d(J.lifeStart)}V${d(_e)}"/>`)}let ce="";for(let J of A){let _e=C[J.first].x-C[J.first].size.w/2-S-J.grow,le=C[J.last].x+C[J.last].size.w/2+S+J.grow,we=J.box.fill==="transparent"?"":St([`fill:${J.box.fill}`]).shape;ce+=`<g class="pele-cluster pele-box"${J.box.name?` data-id="${Fe(J.box.name)}"`:""}><rect x="${d(_e)}" y="0" width="${d(le-_e)}" height="${d(Ne+S)}" fill="var(--_a)" stroke="var(--_b)"${pt((we?"":' fill-opacity="0.5"')+we)}/>`+De(J.title,(_e+le)/2,S/2+2+J.title.height/2,' class="pele-cluster-label" fill="var(--_m)"',l)+"</g>"}A.length>0&&(Ne+=S);let Se=0,$e="",Ae=Tt(n),xe=hn(e.title,c,s,r?Ae:1/0),Oe=r?Is(xe,c,Math.max(120,Ae)):xe;if(j>v&&k(0,Math.max(Oe.width,40)),Oe.width>0){let J=(j+v)/2;k(J-Oe.width/2,J+Oe.width/2),Se=-Oe.height-12,$e=De(Oe,J,Se+Oe.height/2,' class="pele-title" font-weight="var(--_tw)"',l)}let ve=Math.ceil(v-j+2*f),Ge=Math.ceil(Ne-Se+2*f);return{svg:Ze("sequence",ve,Ge,s,n,e,`<g transform="translate(${d(f-j)},${d(f-Se)})">`+$e+(ce?`<g class="pele-boxes" font-size="${a}">${ce}</g>`:"")+(me.length>0?`<g class="pele-rects" fill="var(--_a)">${me.reverse().join("")}</g>`:"")+(Be?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${Be}</g>`:"")+(re.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${re.reverse().join("")}</g>`:"")+(te?`<g class="pele-frames" font-size="${a}" stroke="var(--_b)">${te}</g>`:"")+(he?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${he}</g>`:"")+(be?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${be}</g>`:"")+(oe?`<g class="pele-edge-labels" font-size="${a}">${oe}</g>`:"")+(ge?`<g class="pele-notes" font-size="${a}" fill="var(--_a)" stroke="var(--_b)">${ge}</g>`:"")+(Ee?`<g class="pele-nodes">${Ee}</g>`:"")+"</g>"),width:ve,height:Ge,links:[]}}var W0={type:"sequence",math:!0,parse(e,t,n){let r=t.sequence??{},o=new El({wrap:typeof t.wrap=="boolean"?t.wrap:void 0,sequenceWrap:r.wrap===!0});return n&&o.setDiagramTitle(n),C0(e,o),o},render:F0};function LM(e){let t="TB";for(let n of e)typeof n!="string"&&n.stmt==="dir"&&(t=n.value);return t}function U0(e,t,n){let r=[],o=[],s=new Map,a=new Map,i=new Map,c=0,l=0,f=m=>{if(!m.id||m.id==="</join></fork>"||m.id==="</choice>")return;if(m.cssClasses){let b;for(let x of m.cssClasses.split(" ")){let E=n.get(x);if(E){b??=m.cssCompiledStyles.slice();for(let w of E.styles)b.push(w)}}b&&(m.cssCompiledStyles=b)}let h=s.get(m.id);if(h){let b=m.parentId??h.parentId;Object.assign(h,m),b!==void 0&&(h.parentId=b)}else s.set(m.id,m),r.push(m)},p=(m,h,b)=>{let x=h.id;if(x==="root")return;let E=t.get(x),w=E?.classes?.join(" ")??"",S=E?.styles??[],O=a.get(x);if(!O){let K="rect";h.start===!0?K="stateStart":h.start===!1&&(K="stateEnd"),h.type!=="default"&&(K=h.type),O={shape:K,description:x,cssClasses:`${w} statediagram-state`,cssStyles:S,type:void 0,dir:void 0,colorIndex:void 0},a.set(x,O)}if(h.description&&(Array.isArray(O.description)?(O.shape="rectWithTitle",O.description=O.description.concat(h.description)):O.description.length>0?(O.shape="rectWithTitle",O.description=O.description===x?[h.description].flat():[O.description,h.description].flat()):(O.shape="rect",O.description=Array.isArray(h.description)?h.description.slice():h.description)),O.description.length===1&&O.shape==="rectWithTitle"&&(O.shape=O.type==="group"?"roundedWithTitle":"rect"),!O.type&&h.doc){if(O.type="group",O.dir=LM(h.doc),O.shape=h.type==="divider"?"divider":"roundedWithTitle",O.shape==="divider"&&m?.id!==void 0&&i.has(m.id))O.colorIndex=i.get(m.id);else{let K=l++;O.colorIndex=w.trim()!==""||S.length>0?void 0:K}i.set(x,O.colorIndex),O.cssClasses=`${O.cssClasses} statediagram-cluster ${b?"statediagram-cluster-alt":""}`}let D=O.description,L={id:x,shape:O.shape,label:Array.isArray(D)?D[0]:D,description:Array.isArray(D)?D.slice(1):[],cssClasses:O.cssClasses,cssCompiledStyles:[],cssStyles:O.cssStyles,type:O.type,isGroup:O.type==="group",dir:O.dir,colorIndex:O.colorIndex};L.shape==="divider"&&(L.label=""),m&&m.id!=="root"&&(L.parentId=m.id);let B=h.note;if(!B){f(L);return}let W=(K,z,C,M)=>({id:K,shape:z,label:B.text,description:[],cssClasses:C,cssCompiledStyles:[],cssStyles:[],type:M?"group":"node",isGroup:M,dir:void 0,position:B.position}),Y=W(`${x}----note-${c++}`,"note","statediagram-note",!1);Y.parentId=`${x}----parent`,Y.noteFor=x,f(W(Y.parentId,"noteGroup",O.cssClasses,!0)),f(Y),f(L);let I=B.position==="left of",X=I?Y.id:x,ee=I?x:Y.id;o.push({id:`${X}-${ee}`,start:X,end:ee,label:"",classes:"transition note-edge",pattern:"dashed"})},u=[{item:void 0,doc:e,at:0,alt:!0}];for(;u.length>0;){let m=u[u.length-1];if(m.at>=m.doc.length){u.pop();continue}let h=m.doc[m.at++];typeof h!="string"&&(h.stmt==="state"?(p(m.item,h,m.alt),h.doc&&u.push({item:h,doc:h.doc,at:0,alt:!m.alt})):h.stmt==="relation"&&(p(m.item,h.state1,m.alt),p(m.item,h.state2,m.alt),o.push({id:`edge${c++}`,start:h.state1.id,end:h.state2.id,label:h.description??"",classes:"transition"})))}for(let m of r)if(m.isGroup&&m.description.length>0)throw new ze(`Group nodes can only have label. Remove the additional description for node [${m.id}]`,"semantic",{type:"state"});return{nodes:r,edges:o}}var wl=class{constructor(){de(this,"type","state");de(this,"rootDoc",[]);de(this,"states",new Map);de(this,"relations",[]);de(this,"classes",new Map);de(this,"links",new Map);de(this,"graph",{nodes:[],edges:[]});de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"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 o=r.styleClass.split(",").map(s=>s.replace(/;/g,"").trim());for(let s of this.named(r.id.trim()))s.styles=o.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=U0(n,this.states,this.classes)}translate(){let t=[["root",{stmt:"root",id:"root",doc:this.rootDoc},!0]];for(;t.length>0;){let[n,r,o]=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+(o?"_start":"_end"),r.start=o):r.id=r.id.trim();else if(r.stmt!=="root")continue;if(!r.doc)continue;let s=[],a=[];for(let i of r.doc)typeof i!="string"&&i.stmt==="state"&&i.type==="divider"&&!i.doc?(s.push({...i,doc:a}),a=[]):a.push(i);s.length>0&&(a.length>0&&s.push({stmt:"state",id:this.getDividerId(),type:"divider",doc:a}),r.doc=s);for(let i=r.doc.length-1;i>=0;i--)t.push([r.id,r.doc[i],!0])}}addState(t,n="default",r,o,s,a){let i=t.trim(),c=this.states.get(i);if(c?(c.doc||(c.doc=r),c.type||(c.type=n)):(c={stmt:"state",id:i,descriptions:[],type:n,doc:r,note:s,classes:[],styles:[],textStyles:[]},this.states.set(i,c)),o)for(let l of Array.isArray(o)?o:[o])this.addDescription(i,l.trim());if(s&&(c.note=s),a)for(let l of a)this.setCssClass(i,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 o of[t,n])this.addState(o.id,o.type,o.doc,o.description,o.note,o.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 o of n.split(",")){let s=o.replace(";","").trim();o.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,`
`)}named(t){let n=[];for(let r of t.split(",")){let o=this.states.get(r);o||(this.addState(r),o=this.states.get(r.trim())),o&&n.push(o)}return n}};var qf=["$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 $M=/direction/gi,DM=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,OM=/[\n\r\u2028\u2029]/g,vM=/%%/g,PM=/\{/g;function Xo(e,t){let n=0,r=-2;return o=>{if(r===-2||o<n||r!==-1&&o>r){e.lastIndex=o;let s=e.exec(t);r=s?s.index:-1,n=o}return r}}function G0(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c,l=Xo($M,e),f=Xo(DM,e),p=Xo(OM,e),u=Xo(vM,e),m=Xo(PM,e),h=-1,b=-1,x=[-1,-1,-1,-1],E=[0,0,0,0],w=-1,S=-1,O=[-1,-1,-1,-1,-1,-1],D=(g,_,y)=>{n.push(g),r.push(e.slice(_,y)),o.push(_),i=y},L=(g,_,y,R)=>{n.push(g),r.push(_),o.push(y),i=R},B=g=>{s.push(a),a=g},W=()=>{s.length>0&&(a=s.pop())},Y=(g,_)=>{for(let y=0;y<g.length;y++){let R=g.charCodeAt(y),A=e.charCodeAt(_+y);if(A!==R&&!(R>=97&&R<=122&&A===R-32))return!1}return!0},I=g=>{let _=g;for(;_<t&&He(e.charCodeAt(_));)_++;return _},X=g=>{let _=g;for(;_<t&&Qe(e.charCodeAt(_));)_++;return _},ee=g=>{let _=e.indexOf(`
`,g);return _===-1?t:_},K=g=>{let _=p(g);return _===-1?t:_},z=g=>{if(g<h||g>b){let _=l(g),y=_===-1?t:K(g);h=g,b=y,x[0]=x[1]=x[2]=x[3]=-1;for(let R=_;R!==-1&&R<y;R=l(R+1)){let A=I(R+9);if(A===R+9)continue;let N=Y("tb",A)?0:Y("bt",A)?1:Y("rl",A)?2:Y("lr",A)?3:-1;N!==-1&&(x[N]=R,E[N]=A+2)}}for(let _=0;_<4;_++)if(x[_]>=g)return _;return-1},C=g=>{if(g<w||g>S){let _=f(g),y=_===-1?t:K(g);w=g,S=y,O.fill(-1);for(let R=_;R!==-1&&R<y;R=f(R+1)){let A=e.charCodeAt(R+2)|32;O[(e.charCodeAt(R)===60?0:3)+(A===102?0:A===106?1:2)]=R}}for(let _=0;_<6;_++)if(O[_]>=g)return _;return-1},M=(g,_)=>{let y=u(g);return y===-1||y+2>_?(D(14,g,_),!0):y===g?(i=_,!1):(D(14,g,y),!0)},T=g=>(n.push(g),r.push(""),o.push(i),{types:n,texts:r,starts:o,error:c});for(;;){if(i>=t){switch(a){case 0:D(2,t,t);break;case 6:D(22,t,t);break;case 7:D(24,t,t);break;case 8:D(25,t,t);break;case 10:D(32,t,t);break;case 12:D(39,t,t);break;case 14:D(36,t,t);break;case 3:D(12,t,t);break;case 18:D(20,t,t);break;case 4:case 19:D(14,t,t);break}return T(0)}let g=e.charCodeAt(i);switch(a){case 0:case 1:{let _=a===0,y=g|32;if(_){if(y===99&&Y("click",i)&&!Qe(e.charCodeAt(i+5))){D(26,i,i+5);continue}if(y===104&&Y("href",i)&&!Qe(e.charCodeAt(i+4))){D(28,i,i+4);continue}if(g===34){let N=e.indexOf('"',i+1);if(N!==-1){D(27,i,N+1);continue}}if(y===100&&Y("default",i)&&!Qe(e.charCodeAt(i+7))){D(33,i,i+7);continue}let A=z(i);if(A!==-1){D(40+A,i,ee(E[A]));continue}if(g===10){let N=i+1;for(;e.charCodeAt(N)===10;)N++;D(2,i,N);continue}if(He(g)){i=I(i);continue}}else if(g!==10&&He(g)){let A=i+1;for(;A<t&&e.charCodeAt(A)!==10&&He(e.charCodeAt(A));)A++;i=A;continue}if(g===35||g===37&&e.charCodeAt(i+1)===37&&e.charCodeAt(i+2)!==123){i=ee(i);continue}if(y===115){if(_&&Y("scale",i)){let A=I(i+5);if(A>i+5){D(7,i,A),B(5);continue}}if(Y("style",i)){let A=I(i+5);if(A>i+5){D(34,i,A),B(13);continue}}if(Y("state",i)){let A=I(i+5);if(A>i+5){i=A,B(2);continue}if(_&&Y("diagram",i+5)){let N=Y("-v2",i+12)?i+15:i+12;if(A=I(N),A>N){D(3,i,A);continue}}}}else if(y===99){if(Y("class",i)){let A=Y("def",i+5),N=A?i+8:i+5,$=I(N);if($>N){D(A?29:37,i,$),B(A?9:11);continue}}}else if(y===97&&_&&(Y("acctitle",i)||Y("accdescr",i))){let A=(e.charCodeAt(i+3)|32)===116,N=I(i+8),$=e.charCodeAt(N);if($===58){D(A?21:23,i,I(N+1)),B(A?6:7);continue}if($===123&&!A){i=I(N+1),B(8);continue}}if(_){if(g===123){D(10,i,i+1),B(1);continue}}else{let A=z(i);if(A!==-1){D(40+A,i,ee(E[A]));continue}if(g===125){D(11,i,i+1),W();continue}if(g===10){i++;continue}}if(y===110&&Y("note",i)){let A=I(i+4);if(A>i+4){D(19,i,A),B(15);continue}}if(_&&y===104&&Y("hide empty description",i)&&!Qe(e.charCodeAt(i+22))){D(6,i,i+22);continue}if(g===91&&e.charCodeAt(i+1)===42&&e.charCodeAt(i+2)===93){D(44,i,i+3);continue}let R=i;for(;R<t;){let A=e.charCodeAt(R);if(A===58||A===45||A===123||He(A))break;R++}if(R>i){M(i,R);continue}if(g===58){for(R=i+1;R<t;){let A=e.charCodeAt(R);if(A===10||A===59)break;if(A===58){let N=e.charCodeAt(R+1);if(R+1>=t||N===58||N===10||N===59)break;R++}R++}if(R>i+1){L(4,e.slice(i,R).trim(),i,R);continue}if(e.charCodeAt(i+1)===58&&e.charCodeAt(i+2)===58){D(45,i,i+3);continue}}else if(g===45&&e.charCodeAt(i+1)===45){if(e.charCodeAt(i+2)===62){D(5,i,i+3);continue}if(!_){D(18,i,i+2);continue}}if(!_)return T(1);D(48,i,i+1);continue}case 2:{if(g!==10&&He(g)){let A=i+1;for(;A<t&&e.charCodeAt(A)!==10&&He(e.charCodeAt(A));)A++;i=A;continue}if(g===35||g===37&&e.charCodeAt(i+1)===37&&e.charCodeAt(i+2)!==123){i=ee(i);continue}let _=C(i);if(_!==-1){let A=O[_],N=_===2||_===5;L(N?17:_%3===0?15:16,e.slice(i,A).trim(),i,A+(N?10:8)),W();continue}if(g===34){i++,B(3);continue}let y=g===10?I(i):i;if(Y("as",y)){let A=I(y+2);if(A>y+2){D(13,i,A),B(4);continue}}if(g===10){i++,W();continue}if(g===123){D(10,i,i+1),W(),B(1);continue}if(Qe(g)){let A=X(i),N=I(A);if(N>A&&Qe(e.charCodeAt(N))){let $=m(N+1);if($!==-1&&$<K(N))return c=`Error: State name must be a single word. Found: "${e.slice(i,$+1).trim()}"`,T(1)}}let R=i+1;for(;R<t;){let A=e.charCodeAt(R);if(A===123||He(A))break;R++}D(9,i,R);continue}case 3:{if(g===34){i++,W();continue}let _=e.indexOf('"',i);D(12,i,_===-1?t:_);continue}case 4:{let _=i;for(;_<t;){let y=e.charCodeAt(_);if(y===10||y===123)break;_++}M(i,_)&&W();continue}case 5:{if(g>=48&&g<=57){let y=i+1;for(;y<t&&e.charCodeAt(y)>=48&&e.charCodeAt(y)<=57;)y++;D(8,i,y);continue}let _=I(i);if(_>i&&Y("width",_)&&!Qe(e.charCodeAt(_+5))){i=_+5,W();continue}return T(1)}case 6:D(22,i,ee(i)),W();continue;case 7:D(24,i,ee(i)),W();continue;case 8:{if(g===125){i++,W();continue}let _=e.indexOf("}",i);D(25,i,_===-1?t:_);continue}case 9:{let _=Y("default",i)&&I(i+7)>i+7,y=_?i+7:X(i),R=I(y);if(y===i||R===y)return T(1);D(_?31:30,i,R),W(),B(10);continue}case 10:D(32,i,ee(i)),W();continue;case 11:{let _=X(i);if(_===i)return T(1);for(;e.charCodeAt(_)===44;){let y=I(_+1),R=X(y);if(R===y)break;_=R}D(38,i,_),W(),B(12);continue}case 12:D(39,i,ee(i)),W();continue;case 13:{let _=i;for(;_<t&&(Qe(e.charCodeAt(_))||e.charCodeAt(_)===44);)_++;let y=I(_);if(_===i||y===_)return T(1);D(35,i,y),W(),B(14);continue}case 14:D(36,i,ee(i)),W();continue;case 15:{if(Y("left of",i)&&!Qe(e.charCodeAt(i+7))){D(46,i,i+7),W(),B(16);continue}if(Y("right of",i)&&!Qe(e.charCodeAt(i+8))){D(47,i,i+8),W(),B(16);continue}if(g===34){i++,W(),B(18);continue}return T(1)}case 16:{let _=I(i),y=_;for(;y<t;){let R=e.charCodeAt(y);if(R===58||R===45||He(R))break;y++}if(y===_)return T(1);M(i,y)&&(W(),B(17));continue}case 17:{let _=I(i);if(e.charCodeAt(_)===58){let A=_+1;for(;A<t;){let N=e.charCodeAt(A);if(N===58||N===10||N===59)break;A++}if(A>_+1){L(20,e.slice(i+2,A).trim(),i,A),W();continue}}let y=e.indexOf(`
`,i),R=-1;for(;y!==-1&&(R=I(y),!(Y("end note",R)&&!Qe(e.charCodeAt(R+8))));)y=e.indexOf(`
`,R);if(y===-1)return T(1);L(20,e.slice(i,R).trim(),i,R+8),W();continue}case 18:{let _=I(i);if(Y("as",_)){D(13,i,I(_+2)),W(),B(19);continue}if(g===34){i++;continue}let y=e.indexOf('"',i);D(20,i,y===-1?t:y);continue}case 19:M(i,ee(i))&&W();continue}}}var BM=["TB","BT","RL","LR"],Rl="'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 Y0(e,t){let{types:n,texts:r,starts:o,error:s}=G0(e),a=0,i=h=>{let b=n[a];throw b===1?s!==void 0?new ze(s,"syntax",{type:"state",...Vi(e,o[a])}):st("state",e,o[a],"",!0):st("state",e,o[a],`Expecting ${h}, got '${qf[b]}'`)},c=h=>(n[a]!==h&&i(`'${qf[h]}'`),r[a++]),l=()=>{let h=n[a];h!==14&&h!==44&&i("'ID', 'EDGE_STATE'");let b=r[a++].trim();return n[a]!==45?{stmt:"state",id:b,type:"default",description:""}:(a++,{stmt:"state",id:b,classes:[c(14).trim()],type:"default",description:""})};for(;n[a]===2;)a++;n[a]!==3&&i("'NL', 'SD'"),a++;let f=[],p=[],u=h=>{h!=="nl"&&f.push(h)},m=(h,b)=>{a++;let x=[];f.push({stmt:"state",id:h,type:"default",description:b,doc:x}),p.push(f),f=x};for(;;){let h=n[a];switch(h){case 2:a++;break;case 14:case 44:{let b=l();if(n[a]===4)b.description=t.trimColon(r[a++]),u(b);else if(n[a]===5){a++;let x=l();n[a]===4?u({stmt:"relation",state1:b,state2:x,description:t.trimColon(r[a++])}):u({stmt:"relation",state1:b,state2:x})}else u(b);break}case 6:u(r[a++]);break;case 7:a++,c(8),u(r[a-2]);break;case 9:n[a+1]===10?m(r[a++],""):u(r[a++]);break;case 12:{let b=r[a++];c(13);let x=c(14);if(n[a]===10)m(x,b);else if(x.includes(":")){let E=x.split(":");u({stmt:"state",id:E[0],type:"default",description:[b.trim(),E[1]]})}else u({stmt:"state",id:x,type:"default",description:b.trim()});break}case 15:u({stmt:"state",id:r[a++],type:"fork"});break;case 16:u({stmt:"state",id:r[a++],type:"join"});break;case 17:u({stmt:"state",id:r[a++],type:"choice"});break;case 18:a++,u({stmt:"state",id:t.getDividerId(),type:"divider"});break;case 19:{let b=r[a++];if(n[a]===46||n[a]===47){let x=r[a++].trim(),E=c(14).trim();u({stmt:"state",id:E,note:{position:x,text:c(20).trim()}})}else n[a]!==20&&i("'NOTE_TEXT', 'left_of', 'right_of'"),a++,c(13),c(14),u(b);break}case 40:case 41:case 42:case 43:{let b=BM[h-40];a++,t.setDirection(b),u({stmt:"dir",value:b});break}case 21:{a++;let b=c(22).trim();t.setAccTitle(b),u(b);break}case 23:{a++;let b=c(24).trim();t.setAccDescription(b),u(b);break}case 25:{let b=r[a++].trim();t.setAccDescription(b),u(b);break}case 26:{a++;let b=l(),x,E="";n[a]===28?(a++,x=c(27)):(n[a]!==27&&i("'STRING', 'HREF'"),x=r[a++],E=c(27)),c(2),u({stmt:"click",id:b,url:x,tooltip:E});break}case 29:{a++;let b=c(30).trim();u({stmt:"classDef",id:b,classes:c(32).trim()});break}case 34:{a++;let b=c(35).trim();u({stmt:"style",id:b,styleClass:c(36).trim()});break}case 37:{a++;let b=c(38).trim();u({stmt:"applyClass",id:b,styleClass:c(39).trim()});break}case 11:p.length===0&&i(`'$end', ${Rl}`),a++,f=p.pop();break;case 0:return p.length>0&&i(`'STRUCT_STOP', ${Rl}`),t.setRootDoc(f),f;default:i(p.length>0?`'STRUCT_STOP', ${Rl}`:`'$end', ${Rl}`)}}}var FM=40,WM=16,UM=44,Wi=16,Qf=10,GM=16,H0=10,Zf=26,K0=8,YM=320,Jf=10,z0=8,V0=' fill="var(--_s)" stroke="var(--_b)"',Tl=' fill="none" stroke="var(--_b)"',HM=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g;var KM=new Map([["rectWithTitle",1],["stateStart",2],["stateEnd",3],["choice",4],["fork",5],["join",6],["note",7],["divider",10]]),zM=["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 j0(e){return e==="TB"||e==="BT"}function ep(e,t,n){let r=e.state?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function X0(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 q0(e,t,n){return e<t?t:e>n?n:e}function Cl(e,t,n,r,o){return`<rect x="${d(e)}" y="${d(t)}" width="${d(n)}" height="${d(r)}"${o}/>`}function Nl(e,t,n,r){let o=Pt(0,0);return o.isGroup=!0,o.dir=e,o.padX=t,o.padTop=n,o.padBottom=r,o}function Z0(e,t,n){return Tn(e.direction)?$t(n,r=>Q0(e,t,n,r)):Q0(e,t,n,!1)}function Q0(e,t,n,r){let o=e.graph,s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??et(n.fontFamily),c=ep(t,"wrappingWidth",200),l=n.padding??8,f=n.icons,p=r?"TB":rn(e.direction),u=We(void 0,!1,i,s,0),m=(re,te,he,oe=0)=>We(re,!0,i,te,he,oe),h=new Map,b=[],x=[],E=(re,te,he)=>(b.push({node:re,kind:te,style:void 0,label:u,lines:[],w:0,h:0,titleH:0}),he&&x.push(he),b.length-1);for(let re of o.nodes){if(re.shape==="noteGroup")continue;let te=re.isGroup?re.shape==="divider"?9:8:KM.get(re.shape)??0;h.set(re.id,E(re,te,void 0))}let w=b.length,S=[];for(let re=0;re<w;re++){let te=b[re].node.parentId,he=te===void 0?void 0:h.get(te);S.push(he!==void 0&&he!==re&&b[he].node.isGroup?he:-1)}{let re=[];for(let be=0;be<w;be++)re.push([]);let te=[],he=new Uint8Array(w);for(let be=0;be<w;be++)S[be]===-1?(he[be]=1,te.push(be)):re[S[be]].push(be);let oe=0,ge=()=>{for(;oe<te.length;oe++)for(let be of re[te[oe]])he[be]||(he[be]=1,te.push(be))};ge();let Ee=new Int32Array(w).fill(-1);for(let be=0;be<w;be++){if(he[be])continue;let ye=be;for(;Ee[ye]!==be;)Ee[ye]=be,ye=S[ye];S[ye]=-1,he[ye]=1,te.push(ye),ge()}}let O=new Int32Array(w).fill(-1);for(let re=0;re<w;re++){let te=b[re].node.noteFor,he=te===void 0?void 0:h.get(te);he!==void 0&&(O[re]=he,S[re]=S[he])}let D=re=>rn(b[re].node.dir),L=re=>j0(S[re]===-1?p:D(S[re])),B=new Int32Array(w),W=new Uint8Array(w),Y=new Array(w).fill(1/0),I=0,X=new Int32Array(2*w);for(let re of o.edges){let te=h.get(re.start),he=h.get(re.end);if(!(te===void 0||he===void 0)){if(re.pattern==="dashed"){W[b[te].kind===7?he:te]=1;continue}B[te]=Math.max(B[te],++X[2*te]),B[he]=Math.max(B[he],++X[2*he+1]),Y[te]===1/0&&(Y[te]=I++),Y[he]===1/0&&(Y[he]=I++)}}for(let re=0;re<w;re++){let te=b[re],he=te.node,oe=St(he.cssStyles.length>0?he.cssCompiledStyles.concat(he.cssStyles):he.cssCompiledStyles),ge=(oe.bold?1:0)|(oe.italic?2:0),Ee=oe.fontSize??s;te.style=oe;let be;switch(te.kind){case 8:te.label=m(he.label,Ee,4e3,ge),te.titleH=te.label.height>0?te.label.height+12:0,be=Nl(D(re),Wi,te.titleH+Wi,Wi),be.minW=te.label.width+2*Wi;break;case 9:be=Nl(D(re),Qf,Qf,Qf);break;case 2:te.w=te.h=14;break;case 3:te.w=te.h=18;break;case 4:te.w=te.h=30;break;case 5:case 6:{let ye=q0(40*B[re]+16,72,320);te.w=L(re)?ye:z0,te.h=L(re)?z0:ye;break}case 10:break;case 7:te.label=m(he.label,a,Math.max(c,YM)),te.w=te.label.width+24,te.h=te.label.height+16;break;default:{te.label=m(he.label,Ee,c,ge);let ye=te.label.width,Re=te.label.height+2*H0;if(te.kind===1){Re+=14;for(let Le of he.description){let ue=m(Le===""?" ":Le,a,c,ge);te.lines.push(ue),ue.width>ye&&(ye=ue.width),Re+=ue.height}}te.w=Math.max(ye+2*GM,56),te.h=Re}}be??=Pt(te.w,te.h),(te.kind===0||te.kind===1)&&(be.span=(L(re)?te.w:te.h)-24),x.push(be)}let ee=[],K=[],z=[],C=new Int32Array(w),M=new Float64Array(w),T=new Float64Array(w),g=new Map,_=(re,te)=>{if(!x[re].isGroup)return!1;for(let he=S[te];he!==-1;he=S[he])if(he===re)return!0;return!1},y=(re,te)=>(g.set(ee.length,re),Y.push(te?-1:1/0),E(void 0,10,Pt(0,0,re)));for(let re of o.edges){let te=h.get(re.start),he=h.get(re.end);if(te===void 0||he===void 0)continue;let oe=m(re.label,a,c),ge=oe.width>0?oe.width+12:0;te===he?(C[te]++,M[te]=Math.max(M[te],ge),T[te]+=oe.height):_(te,he)?te=y(te,!0):_(he,te)&&(he=y(he,!1)),z.push(re),K.push(oe),ee.push({src:te,dst:he,minlen:1,labelW:ge,labelH:oe.height>0?oe.height+4:0,route:[],labelX:0,labelY:0})}for(let re=0;re<w;re++){if(O[re]!==-1)continue;let te=x[re],he=0;if(C[re]>0){let ge=Zf+(C[re]-1)*8;he=L(re)?ge+M[re]:ge*.75+4+T[re],te.isGroup||(L(re)?(te.w+=2*he,te.h=Math.max(te.h,T[re])):(te.h+=2*he,te.w=Math.max(te.w,M[re])),he=0)}if(!W[re]&&he===0){te.parent=S[re];continue}let oe=L(re)?Nl("LR",he,0,0):Nl("TB",0,he,he);oe.parent=S[re],Y.push(Y[re]),x[re].parent=E(void 0,10,oe)}for(let re=0;re<w;re++)O[re]!==-1&&(x[re].parent=x[O[re]].parent);{let re=[];for(let be=0;be<x.length;be++)re.push([]);let te=[];for(let be=0;be<x.length;be++){let ye=x[be].parent;ye>=0?re[ye].push(be):te.push(be)}let he=be=>b[be].kind===2?0:1,oe=(be,ye)=>he(be)-he(ye)||(Y[be]===Y[ye]?0:Y[be]<Y[ye]?-1:1)||be-ye,ge=0,Ee=te.sort(oe).reverse();for(;Ee.length>0;){let be=Ee.pop();x[be].seq=ge++;let ye=re[be].sort(oe);for(let Re=ye.length-1;Re>=0;Re--)Ee.push(ye[Re])}}let R=Rn(x,ee,p,{nodeSep:ep(t,"nodeSpacing",FM),edgeSep:WM,rankSep:ep(t,"rankSpacing",UM),portSep:20,headRoom:mt("arrow_point")}),A=Math.ceil(R.width+2*l),N=Math.ceil(R.height+2*l),$=[],U=new Map;for(let re of ee){let te=re.route;for(let he=3;he<te.length-3;he+=3){let oe=Math.round(te[he+1]),ge=U.get(oe);ge?ge.push(te[he]):U.set(oe,[te[he]])}}let j=[];for(let re=0;re<x.length;re++)j.push([]);let v=[];for(let re=0;re<x.length;re++){let te=x[re].parent;te>=0?j[te].push(re):v.push(re)}let k=v.slice();for(let re=0;re<v.length;re++)for(let te of j[v[re]])v.push(te);let F="",H="",G="",se="",q=(re,te,he,oe,ge)=>{let Ee=re.filter(Re=>b[Re].kind===9);if(Ee.length<2)return;let be=(Re,Le)=>Le?x[Re].x-x[Re].w/2:x[Re].y-x[Re].h/2,ye=(Re,Le)=>Le?x[Re].x+x[Re].w/2:x[Re].y+x[Re].h/2;for(let Re of[!0,!1]){let Le=Ee.slice().sort((fe,Me)=>be(fe,Re)-be(Me,Re)||fe-Me),ue=!0;for(let fe=1;fe<Le.length;fe++)ye(Le[fe-1],Re)>be(Le[fe],Re)+.5&&(ue=!1);if(ue){for(let fe=1;fe<Le.length;fe++){let Me=d((ye(Le[fe-1],Re)+be(Le[fe],Re))/2+l);H+=`<path class="pele-divider" d="M${Re?`${Me},${d(he)}V${d(ge)}`:`${d(te)},${Me}H${d(oe)}`}"/>`}return}}for(let Re of Ee){let Le=x[Re];H+=Cl(Le.x-Le.w/2+l,Le.y-Le.h/2+l,Le.w,Le.h,` class="pele-divider" rx="${Jf}"`)}};q(k,l/2,l/2,A-l/2,N-l/2);for(let re of v){let te=b[re],he=te.node,oe=te.style;if(he===void 0||oe===void 0||te.kind>=9)continue;let ge=x[re],Ee=ge.x+l,be=ge.y+l,ye=te.w,Re=te.h,Le=` class="pele-label"${oe.text}`,ue;switch(te.kind){case 8:{let Ne=Ee-ge.w/2,Be=be-ge.h/2;ue=Cl(Ne,Be,ge.w,ge.h,` rx="${Jf}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${oe.shape}`),te.titleH>0&&(ue+=`<path d="M${d(Ne)},${d(Be+te.titleH)}H${d(Ne+ge.w)}"${Tl}${oe.line}/>`+De(te.label,VM(ge,te.label.width,U)+l,Be+te.titleH/2,` class="pele-cluster-label"${oe.text}`,f)),q(j[re],Ne,Be+te.titleH,Ne+ge.w,Be+ge.h);break}case 2:ue=`<circle r="7" fill="var(--_l)"${oe.shape}/>`;break;case 3:ue=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${oe.line}/><circle r="5" fill="var(--_l)"${oe.shape}/>`;break;case 4:ue=`<polygon points="0,${d(-Re/2)} ${d(ye/2)},0 0,${d(Re/2)} ${d(-ye/2)},0"${V0}${oe.shape}/>`;break;case 5:case 6:ue=Cl(-ye/2,-Re/2,ye,Re,` rx="2" fill="var(--_l)"${oe.shape}`);break;case 7:{let Ne=d(ye/2),Be=d(Re/2),ce=d(ye/2-K0),Se=d(K0-Re/2);ue=`<path d="M-${Ne},-${Be}H${ce}L${Ne},${Se}V${Be}H-${Ne}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${ce},-${Be}V${Se}H${Ne}"${Tl}/>`+De(te.label,0,0,` class="pele-label" font-size="${a}" fill="var(--_m)"`,f);break}default:{if(ue=Cl(-ye/2,-Re/2,ye,Re,` rx="${d(Math.min(Jf,Re/2))}"${V0}${oe.shape}`),te.kind===0){ue+=De(te.label,0,0,Le,f);break}let Ne=H0-Re/2+te.label.height;ue+=`<path d="M${d(-ye/2)},${d(Ne+6)}H${d(ye/2)}"${Tl}${oe.line}/>`+De(te.label,0,Ne-te.label.height/2,Le,f),Ne+=14;for(let Be of te.lines)ue+=De(Be,0,Ne+Be.height/2,` class="pele-state-description" font-size="${a}"${oe.text}`,f),Ne+=Be.height}}let fe=e.links.get(he.id);if(fe){let Ne=yt(X0(fe.tooltip));Ne&&(ue=`<title>${je(Ne)}</title>`+ue),ue=Wn(ue,Fn(X0(fe.url)),he.id,$,n,' target="_blank"')}let Me=`<g class="${zM[te.kind]}${Rt(he.cssClasses.replace(HM,""))}" data-id="${Fe(he.id)}"`;te.kind===8?F+=`${Me}>${ue}</g>`:te.kind===7?se+=`${Me} transform="translate(${d(Ee)},${d(be)})">${ue}</g>`:G+=`${Me} transform="translate(${d(Ee)},${d(be)})">${ue}</g>`}let P=(re,te,he)=>{let oe=x[he];if(oe.isGroup)return;let ge=b[he],Ee=ge.kind===5||ge.kind===6,be=te===0?3:te-3;for(let ye of[1,0]){let Re=ye?oe.h:oe.w,Le=ye?ge.h:ge.w,ue=ye?ge.w:ge.h,fe=(ye?oe.y:oe.x)+l,Me=(ye?oe.x:oe.y)+l,Ne=re[te+ye]-fe;if(!(Math.abs(Math.abs(Ne)-Re/2)>=.5)){re[te+ye]-=Math.sign(Ne)*(Re-Le)/2,Ee&&ue>Le&&(re[te+1-ye]=q0(re[be+1-ye],Me-ue/2+6,Me+ue/2-6));return}}},V=Da();for(let re=0;re<ee.length;re++){let te=ee[re];te.src===te.dst||te.route.length<6||z[re].pattern==="dashed"||V.add(te.dst,Un(te.route,te.route.length-3,x[te.dst]),"arrow_point")}let ne="",ae="",Z=new Int32Array(w),Q=new Float64Array(w);for(let re=0;re<ee.length;re++){let te=ee[re],he=z[re],oe=K[re],ge=he.pattern==="dashed",Ee=ge?"none":"arrow_point",be;if(te.src===te.dst){let ye=x[te.src],Re=b[te.src],Le=Z[te.src]++,ue=L(te.src),fe=ye.isGroup?ye.w:Re.w,Me=ye.isGroup?ye.h:Re.h,Ne=(ue?fe:Me)/2,Be=Math.max(Math.min((ue?Me:fe)/2-4,8+Le*6),2),ce=Zf+Le*8,Se=mt(Ee)/(Math.hypot(ce,Be)||1),$e=(pe,J)=>ye.x+l+(ue?Ne+pe:-J),Ae=(pe,J)=>ye.y+l+(ue?J:Ne+pe),xe=(pe,J)=>`${d($e(pe,J))},${d(Ae(pe,J))}`;be={d:`M${xe(0,-Be)}C${xe(ce,-2*Be)} ${xe(ce,2*Be)} ${xe(ce*Se,Be+Be*Se)}`,sx:0,sy:0,sdx:0,sdy:0,ex:$e(0,Be),ey:Ae(0,Be),edx:$e(-ce,-Be)-$e(0,0),edy:Ae(-ce,-Be)-Ae(0,0)};let Oe=Math.hypot(be.edx,be.edy)||1;be.edx/=Oe,be.edy/=Oe;let ve=Zf+(C[te.src]-1)*8,Ge=Q[te.src]+oe.height/2;Q[te.src]+=oe.height,te.labelX=ue?ye.x+Ne+ve+4+te.labelW/2:ye.x,te.labelY=ue?ye.y-T[te.src]/2+Ge:ye.y+Ne+ve*.75+4+Ge}else{let ye=te.route.slice(),Re=V.of(te.src,Un(ye,0,x[te.src])),Le=V.of(te.dst,Un(ye,ye.length-3,x[te.dst]));for(let fe=0;fe<ye.length;fe+=3)ye[fe]+=l,ye[fe+1]+=l;P(ye,0,te.src),P(ye,ye.length-3,te.dst);let ue=g.get(re);if(ue!==void 0&&ye.length>=6){let fe=x[ue],Me=b[te.src].kind===10,Ne=Me?0:ye.length-3,Be=(fe.dir==="TB"||fe.dir==="LR")===Me,ce=j0(fe.dir)?[ye[Ne],fe.y+l+(Be?b[ue].titleH-fe.h/2:fe.h/2),0]:[fe.x+l+(Be?-fe.w/2:fe.w/2),ye[Ne+1],1];ye=Me?ce.concat(ye):ye.concat(ce)}be=xn(ye,void 0,0,mt(Ee),Re,Le)}if(ne+=`<g class="pele-edge ${ge?'pele-note-edge" stroke="var(--_b)" stroke-dasharray="3 4':"pele-transition"}" data-id="${Fe(he.id)}"><path d="${be.d}"/>`+Et(Ee,be.ex,be.ey,be.edx,be.edy,"var(--_l)")+"</g>",oe.width>0){let ye=te.labelX+l,Re=te.labelY+l;ae+=sn(he.id,oe,ye,Re,"",f)}}let ie=Va(e.title,i,s,l,A,N,(F?`<g class="pele-clusters">${F}</g>`:"")+(H?`<g class="pele-dividers" stroke-dasharray="4 4"${Tl}>${H}</g>`:"")+(ne?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ne}</g>`:"")+(ae?`<g class="pele-edge-labels" font-size="${a}">${ae}</g>`:"")+`<g class="pele-nodes">${G}${se}</g>`);return{svg:Ze("state",ie.width,ie.height,s,n,e,ie.content),width:ie.width,height:ie.height,links:$}}function VM(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(r===void 0||t===0)return e.x;let o=e.x-e.w/2,s=t/2,a=e.x,i=-1;for(let c of[e.x,o+Wi+s,o+e.w-Wi-s]){let l=1/0;for(let f of r)f>o&&f<o+e.w&&(l=Math.min(l,Math.abs(f-c)-s));if(l>=6)return c;l>i+.5&&(i=l,a=c)}return a}var J0={type:"state",math:!0,parse(e,t,n){let r=new wl;return n&&(r.title=n),Y0(e,r),r},render:Z0};var jM=34,XM=24,qM=8,QM=2e4,eA=1e4,tp=2e6,tA=4,ZM=3,nA=8,np=20,rA=20,sA=14,JM=3;function oA(e,t,n,r,o=XM){let s=e.length;if(s===0)return{width:0,height:0};let a=n==="LR"||n==="RL",i=n==="BT"||n==="RL",c=[];for(let K=s-1;K>=0;K--)e[K].parent<0&&e[K].isGroup&&c.push(K);let l=Math.max(1,c.length),f=new Int32Array(s).fill(-1);c.forEach((K,z)=>f[K]=z);let p=new Uint8Array(s);for(let K=0;K<s;K++)e[K].parent>=0&&(p[e[K].parent]=1);let u=new Float64Array(l).fill(o),m=o,h=K=>{let z=K,C=o;for(let T=0;e[z].parent>=0&&T<eA;T++)z=e[z].parent,f[z]<0&&(C+=Math.max(e[z].padX,e[z].padTop,e[z].padBottom));let M=Math.max(0,f[z]);return C>u[M]&&(u[M]=C),C>m&&(m=C),M},b=new Int32Array(s).fill(-1),x=[];for(let K=0;K<s;K++)f[K]>=0||(!e[K].isGroup||!p[K])&&(b[K]=x.length,x.push(K));let E=K=>a?K.w:K.h,w=K=>a?K.h:K.w,S=x.map(K=>xs(w(e[K]),E(e[K]))),O=[],D=[],L=1;{let K=new Set;for(let z=0;z<t.length;z++){let C=t[z],M=b[C.src],T=b[C.dst];if(M<0||T<0||M===T)continue;let g=Math.min(M,T)*x.length+Math.max(M,T);(C.labelW>0||K.has(g))&&(L=2),K.add(g),O.push(Ss(M,T,C.minlen,a?C.labelH:C.labelW,a?C.labelW:C.labelH)),D.push(z)}}no(S,O),ro(S,O,L);let B=O.length,W=Int32Array.from(x,h),Y=(K,z)=>{let C=u.map((pe,J)=>z[J]?Math.max(pe,rA):pe),M=new Uint8Array(l),T=0,g=new Int32Array(B);for(let pe=0;pe<B;pe++)g[pe]=Math.abs(S[O[pe].head].rank-S[O[pe].tail].rank),K[pe]||(T+=g[pe]-1);let _=T>QM,y=x.length+(_?0:T),R=new Int32Array(y),A=new Int32Array(y),N=new Float64Array(y),$=new Float64Array(y),U=new Uint8Array(y),j=0;for(let pe=0;pe<x.length;pe++)R[pe]=S[pe].rank,A[pe]=W[pe],N[pe]=S[pe].w,$[pe]=S[pe].h,R[pe]>j&&(j=R[pe]);let v=new Int32Array(B).fill(-1),k=new Int32Array(B).fill(-1),F=[];{let pe=x.length;for(let J=0;J<B;J++){let _e=O[J],le=_e.reversed?_e.head:_e.tail,we=_e.reversed?_e.tail:_e.head;if(_||g[J]<2||K[J]){F.push(le,we);continue}let Te=R[le],Ce=R[we],Ie=-1;_e.labelW>0&&(Ie=Te+(Ce-Te>>1),L===2&&(Ie&1)===0&&Ie--),v[J]=pe;let Pe=le;for(let Ue=Te+1;Ue<Ce;Ue++){let ke=pe++;R[ke]=Ue,A[ke]=A[le]+Math.round((A[we]-A[le])*(Ue-Te)/(Ce-Te)),U[ke]=1,Ue===Ie&&(N[ke]=_e.labelW,$[ke]=_e.labelH,k[J]=ke),F.push(Pe,ke),Pe=ke}F.push(Pe,we)}}let H=new Int32Array(y+1),G=new Int32Array(y+1);for(let pe=0;pe<F.length;pe+=2)G[F[pe]+1]++,H[F[pe+1]+1]++;for(let pe=0;pe<y;pe++)H[pe+1]+=H[pe],G[pe+1]+=G[pe];let se=new Int32Array(F.length/2),q=new Int32Array(F.length/2);{let pe=H.slice(0,y),J=G.slice(0,y);for(let _e=0;_e<F.length;_e+=2)q[J[F[_e]]++]=F[_e+1],se[pe[F[_e+1]]++]=F[_e]}let P=[];for(let pe=0;pe<=j;pe++)P.push([]);for(let pe=0;pe<y;pe++)P[R[pe]].push(pe);let V=new Float64Array(y),ne=new Float64Array(y),ae=pe=>{pe.sort((J,_e)=>A[J]-A[_e]||ne[J]-ne[_e]||J-_e);for(let J=0;J<pe.length;J++)V[pe[J]]=J};for(let pe of P){for(let J=0;J<pe.length;J++)ne[pe[J]]=J;ae(pe)}for(let pe=0;pe<qM&&j>0;pe++){let J=(pe&1)===0;for(let _e=1;_e<=j;_e++){let le=P[J?_e:j-_e],we=J?H:G,Te=J?se:q;for(let Ce of le){let Ie=0,Pe=we[Ce+1]-we[Ce];for(let Ue=we[Ce];Ue<we[Ce+1];Ue++)Ie+=V[Te[Ue]];ne[Ce]=Pe>0?Ie/Pe:V[Ce]}ae(le)}}let Z=(pe,J)=>U[pe]||U[J]?r.edgeSep:r.nodeSep,Q=(pe,J)=>{let _e=0;for(;_e<pe.length;){let le=_e;for(;le+1<pe.length&&A[pe[le+1]]===A[pe[_e]];)le++;J(pe,_e,le),_e=le+1}},ie=(pe,J,_e)=>{let le=N[pe[J]];for(let we=J;we<_e;we++)le+=Z(pe[we],pe[we+1])+N[pe[we+1]];return le},me=new Float64Array(l),re=c.length>0?jM:0;for(let pe=0;pe<c.length;pe++){let J=e[c[pe]];me[pe]=Math.max(0,J.minW-2*C[pe]),J.padTop>re&&(re=J.padTop)}for(let pe of P)Q(pe,(J,_e,le)=>{let we=ie(pe,_e,le);we>me[A[pe[_e]]]&&(me[A[pe[_e]]]=we)});let te=new Float64Array(l+1);for(let pe=0;pe<l;pe++)te[pe+1]=te[pe]+me[pe]+2*C[pe];let he=new Float64Array(y),oe=new Float64Array(y),ge=(pe,J,_e)=>{let le=A[pe[J]],we=(te[le]+C[le]+(te[le+1]-C[le])-ie(pe,J,_e))/2;for(let Te=J;Te<=_e;Te++)he[pe[Te]]=we+N[pe[Te]]/2,Te<_e&&(we+=N[pe[Te]]+Z(pe[Te],pe[Te+1]))},Ee=(pe,J,_e)=>{let le=A[pe[J]],we=te[le]+C[le];for(let Ce=J;Ce<=_e;Ce++){let Ie=pe[Ce];he[Ie]=Math.max(oe[Ie],we+N[Ie]/2),Ce<_e&&(we=he[Ie]+N[Ie]/2+Z(Ie,pe[Ce+1]))}let Te=te[le+1]-C[le];for(let Ce=_e;Ce>=J;Ce--){let Ie=pe[Ce];he[Ie]=Math.min(he[Ie],Te-N[Ie]/2),Ce>J&&(Te=he[Ie]-N[Ie]/2-Z(pe[Ce-1],Ie))}};for(let pe of P)Q(pe,ge);for(let pe=0;pe<4&&j>0;pe++){let J=(pe&1)===0;for(let _e=1;_e<=j;_e++){let le=P[J?_e:j-_e],we=J?H:G,Te=J?se:q;for(let Ce of le){let Ie=0,Pe=0;for(let Ue=we[Ce];Ue<we[Ce+1];Ue++)A[Te[Ue]]===A[Ce]&&(Ie+=he[Te[Ue]],Pe++);oe[Ce]=Pe>0?Ie/Pe:he[Ce]}Q(le,Ee)}}let be=new Float64Array(j+1),ye=new Float64Array(j+1),Re=new Float64Array(j+1).fill(r.rankSep/L);if(K.some(pe=>pe===1)){let pe=r.rankSep/L;Re.fill(pe/JM);for(let J=0;J<B;J++){let _e=O[J],le=_e.reversed?_e.head:_e.tail,we=_e.reversed?_e.tail:_e.head;if(K[J]){if(_e.labelH<=0||g[J]>L)continue;let Ce=Math.min(pe,(_e.labelH+2*np-Math.min($[le],$[we])/2)/g[J]);for(let Ie=R[le];Ie<R[we];Ie++)Ce>Re[Ie]&&(Re[Ie]=Ce);continue}let Te=v[J];if(Te<0||g[J]<=L*_e.minlen){for(let Ce=R[le];Ce<R[we];Ce++)Re[Ce]=pe;continue}for(let Ce=Te-1;Ce<Te+g[J]-1;Ce++){let Ie=Ce<Te?le:Ce,Pe=Ce+1<Te+g[J]-1?Ce+1:we;(A[Ie]!==A[Pe]||Math.abs(he[Ie]-he[Pe])>=.5)&&(Re[R[Ie]]=pe)}}}let Le=re+m;for(let pe=0;pe<=j;pe++){let J=0;for(let _e of P[pe])$[_e]>J&&(J=$[_e]);be[pe]=Le,ye[pe]=Le+J,Le+=J+(pe===j?0:Re[pe])}let ue=Le+m,fe=te[l],Me=pe=>i?re+ue-pe:pe,Ne=(pe,J)=>a?Me(J):pe,Be=(pe,J)=>a?pe:Me(J),ce=a?1:0;for(let pe=0;pe<x.length;pe++){let J=e[x[pe]],_e=(be[R[pe]]+ye[R[pe]])/2;J.x=Ne(he[pe],_e),J.y=Be(he[pe],_e)}for(let pe=0;pe<c.length;pe++){let J=e[c[pe]],_e=(te[pe]+te[pe+1])/2,le=te[pe+1]-te[pe];J.x=a?ue/2:_e,J.y=a?_e:ue/2,J.w=a?ue:le,J.h=a?le:ue,J.padTop=re}let Se=new Int32Array(s),$e=[];for(let pe=0;pe<s;pe++){if(!e[pe].isGroup||f[pe]>=0||b[pe]>=0)continue;let J=0;for(let _e=e[pe].parent;_e>=0&&J<eA;_e=e[_e].parent)J++;Se[pe]=J,$e.push(pe)}$e.sort((pe,J)=>Se[J]-Se[pe]||pe-J);let Ae=new Float64Array(s*4);for(let pe=0;pe<s;pe++)Ae[pe*4]=1/0,Ae[pe*4+1]=1/0,Ae[pe*4+2]=-1/0,Ae[pe*4+3]=-1/0;let xe=(pe,J)=>{J.x-J.w/2<Ae[pe*4]&&(Ae[pe*4]=J.x-J.w/2),J.y-J.h/2<Ae[pe*4+1]&&(Ae[pe*4+1]=J.y-J.h/2),J.x+J.w/2>Ae[pe*4+2]&&(Ae[pe*4+2]=J.x+J.w/2),J.y+J.h/2>Ae[pe*4+3]&&(Ae[pe*4+3]=J.y+J.h/2)};for(let pe of x)e[pe].parent>=0&&f[e[pe].parent]<0&&xe(e[pe].parent,e[pe]);for(let pe of $e){let J=e[pe];if(Ae[pe*4]===1/0)continue;let _e=Math.max(Ae[pe*4+2]-Ae[pe*4]+2*J.padX,J.minW);J.x=(Ae[pe*4]+Ae[pe*4+2])/2,J.w=_e,J.y=(Ae[pe*4+1]-J.padTop+Ae[pe*4+3]+J.padBottom)/2,J.h=Ae[pe*4+3]-Ae[pe*4+1]+J.padTop+J.padBottom,J.parent>=0&&f[J.parent]<0&&xe(J.parent,J)}for(let pe of t)pe.route=[];for(let pe=0;pe<B;pe++){let J=O[pe],_e=t[D[pe]],le=J.reversed?J.head:J.tail,we=J.reversed?J.tail:J.head,Te=[he[le],ye[R[le]]-(ye[R[le]]-be[R[le]]-$[le])/2],Ce=v[pe];if(Ce>=0)for(let Ue=Ce;Ue<Ce+g[pe]-1;Ue++)Te.push(he[Ue],be[R[Ue]]),ye[R[Ue]]>be[R[Ue]]&&Te.push(he[Ue],ye[R[Ue]]);Te.push(he[we],be[R[we]]+(ye[R[we]]-be[R[we]]-$[we])/2);let Ie=[];for(let Ue=0;Ue<Te.length;Ue+=2)Ie.push(Ne(Te[Ue],Te[Ue+1]),Be(Te[Ue],Te[Ue+1]),ce);if(J.reversed)for(let Ue=0,ke=Ie.length-3;Ue<ke;Ue+=3,ke-=3)for(let Ke=0;Ke<2;Ke++){let Ve=Ie[Ue+Ke];Ie[Ue+Ke]=Ie[ke+Ke],Ie[ke+Ke]=Ve}_e.route=Ie;let Pe=k[pe];if(Pe>=0){let Ue=(be[R[Pe]]+ye[R[Pe]])/2;_e.labelX=Ne(he[Pe],Ue),_e.labelY=Be(he[Pe],Ue)}else _e.labelX=(Ie[0]+Ie[Ie.length-3])/2,_e.labelY=(Ie[1]+Ie[Ie.length-2])/2}for(let pe of t){if(pe.route.length>0||pe.src===pe.dst)continue;let J=e[pe.src],_e=e[pe.dst],[le,we]=iA(J,_e),[Te,Ce]=iA(_e,J),Ie=Math.abs(Te-le)>Math.abs(Ce-we)?1:0;pe.route=[le,we,Ie,Te,Ce,Ie],pe.labelX=(le+Te)/2,pe.labelY=(we+Ce)/2}let Oe=new Uint8Array(B),ve=t.reduce((pe,J)=>pe+J.route.length/3,0),Ge=B*(x.length+t.length+ve);if(Ge<=tp){let pe=Ie=>(be[R[Ie]]+ye[R[Ie]])/2,J=t.map(Ie=>[a?Ie.labelY:Ie.labelX,Me(a?Ie.labelX:Ie.labelY)]),_e=(Ie,Pe,Ue,ke,Ke,Ve,ct,tt)=>Ue>Ke-ct/2&&Ie<Ke+ct/2&&ke>Ve-tt/2&&Pe<Ve+tt/2,le=(Ie,Pe,Ue,ke,Ke,Ve,ct)=>{for(let tt=0;tt<x.length;tt++)if(tt!==Ke&&tt!==Ve&&_e(Ie,Pe,Ue,ke,he[tt],pe(tt),N[tt]+8,$[tt]+8))return!1;for(let tt=0;tt<t.length;tt++){let rt=t[tt];if(tt!==ct&&rt.labelW>0&&rt.src!==rt.dst&&_e(Ie,Pe,Ue,ke,J[tt][0],J[tt][1],a?rt.labelH:rt.labelW,a?rt.labelW:rt.labelH))return!1}return!0},we=(Ie,Pe,Ue,ke,Ke)=>{let Ve=0;for(let ct=0;ct<t.length;ct++){if(ct===Ke)continue;let tt=t[ct].route;for(let rt=3;rt<tt.length;rt+=3)if(Math.max(tt[rt-3],tt[rt])>Ie&&Math.min(tt[rt-3],tt[rt])<Ue&&Math.max(tt[rt-2],tt[rt+1])>Pe&&Math.min(tt[rt-2],tt[rt+1])<ke){Ve++;break}}return Ve},Te=(Ie,Pe,Ue)=>{let ke=0;for(let Ke=0;Ke<t.length;Ke++){let Ve=t[Ke].route;if(Ke===Ue||Ve.length===0)continue;let ct=Ve.length-3;(Math.abs(Ve[0]-Ie)<1&&Math.abs(Ve[1]-Pe)<1||Math.abs(Ve[ct]-Ie)<1&&Math.abs(Ve[ct+1]-Pe)<1)&&ke++}return ke},Ce=(Ie,Pe,Ue,ke,Ke)=>{let Ve=Math.abs(Ue-Ie)<.5,ct=Ve?Math.min(Pe,ke):Math.min(Ie,Ue),tt=Ve?Math.max(Pe,ke):Math.max(Ie,Ue),rt=Ve?Ie:Pe;for(let Ct=0;Ct<t.length;Ct++){let dt=t[Ct];if(Ct===Ke||dt.src===t[Ke].src||dt.dst===t[Ke].dst)continue;let It=dt.route;for(let xt=3;xt<It.length;xt+=3){let _t=It[xt-3+(Ve?0:1)],Xe=It[xt+(Ve?0:1)];if(Math.abs(_t-rt)>=tA||Math.abs(Xe-rt)>=tA)continue;let qe=It[xt-3+(Ve?1:0)],at=It[xt+(Ve?1:0)];if(Math.min(tt,Math.max(qe,at))-Math.max(ct,Math.min(qe,at))>1)return!0}}return!1};for(let Ie=0;Ie<B;Ie++){let Pe=O[Ie],Ue=D[Ie],ke=t[Ue],Ke=Pe.tail,Ve=Pe.head;if(A[Ke]===A[Ve]||Math.abs(he[Ve]-he[Ke])<1)continue;let ct=he[Ke],tt=he[Ve],rt=pe(Ke),Ct=pe(Ve),dt=Math.sign(tt-ct),It=Math.sign(Ct-rt),xt=(Xe,qe)=>{for(let Je=2;Je<Xe.length;Je+=2)if(!le(Math.min(Xe[Je-2],Xe[Je])-qe,Math.min(Xe[Je-1],Xe[Je+1])-qe,Math.max(Xe[Je-2],Xe[Je])+qe,Math.max(Xe[Je-1],Xe[Je+1])+qe,Ke,Ve,Ue)||Ce(Ne(Xe[Je-2],Xe[Je-1]),Be(Xe[Je-2],Xe[Je-1]),Ne(Xe[Je],Xe[Je+1]),Be(Xe[Je],Xe[Je+1]),Ue))return!1;let at=0,ot=0,kt=-1;if(ke.labelW>0){let Je=Pe.labelW,wt=Pe.labelH;for(let ut=2;ut<Xe.length;ut+=2){let Nt=(Xe[ut-2]+Xe[ut])/2,Dt=(Xe[ut-1]+Xe[ut+1])/2,pn=Math.abs(Xe[ut]-Xe[ut-2]),gs=Math.abs(Xe[ut+1]-Xe[ut-1]),zn=pn+gs;if(zn<=kt||(pn>0?pn<Je+8:gs<wt+8)||Nt-Je/2<0||Nt+Je/2>fe||Dt-wt/2<0||Dt+wt/2>ue||!le(Nt-Je/2,Dt-wt/2,Nt+Je/2,Dt+wt/2,-1,-1,Ue))continue;let Ki=Ne(Nt,Dt),zi=Be(Nt,Dt);we(Ki-ke.labelW/2,zi-ke.labelH/2,Ki+ke.labelW/2,zi+ke.labelH/2,Ue)>0||(at=Nt,ot=Dt,kt=zn)}if(kt<0)return!1}let bt=[Xe[0],Xe[1]];for(let Je=2;Je<Xe.length;Je+=2){let wt=Xe[Je]-Xe[Je-2],ut=Xe[Je+1]-Xe[Je-1],Nt=Math.abs(wt)+Math.abs(ut),Dt=Je>2?np:0,pn=Je+2<Xe.length?np:0;Nt>Dt+pn+1&&(Dt&&bt.push(Xe[Je-2]+wt/Nt*Dt,Xe[Je-1]+ut/Nt*Dt),pn&&bt.push(Xe[Je]-wt/Nt*pn,Xe[Je+1]-ut/Nt*pn)),bt.push(Xe[Je],Xe[Je+1])}ke.route=[];for(let Je=0;Je<bt.length;Je+=2){let wt=Je===0?bt[0]!==bt[2]:bt[Je]!==bt[Je-2];ke.route.push(Ne(bt[Je],bt[Je+1]),Be(bt[Je],bt[Je+1]),wt?1-ce:ce)}return ke.labelW>0&&(ke.labelX=Ne(at,ot),ke.labelY=Be(at,ot),J[Ue]=[at,ot]),Oe[Ie]=1,!0};if(xt([ct+dt*N[Ke]/2,rt,tt,rt,tt,Ct-It*$[Ve]/2],2)||xt([ct,rt+It*$[Ke]/2,ct,Ct,tt-dt*N[Ve]/2,Ct],2)||Ge>tp/nA)continue;let _t=[];for(let Xe of A[Ke]<A[Ve]?[A[Ve],A[Ke]]:[A[Ke],A[Ve]]){let qe=Math.max(C[Xe]-sA,Math.min(C[Xe]/2,rA-sA));for(let at of[te[Xe]+qe,te[Xe+1]-qe]){if(Math.abs(at-ct)<N[Ke]/2+4||Math.abs(at-tt)<N[Ve]/2+4)continue;let ot=[ct+Math.sign(at-ct)*N[Ke]/2,rt,at,rt,at,Ct,tt+Math.sign(at-tt)*N[Ve]/2,Ct],kt=(Te(Ne(ot[0],ot[1]),Be(ot[0],ot[1]),Ue)+Te(Ne(ot[6],ot[7]),Be(ot[6],ot[7]),Ue))*1e6;for(let bt=2;bt<ot.length;bt+=2){let Je=Ne(ot[bt-2],ot[bt-1]),wt=Be(ot[bt-2],ot[bt-1]),ut=Ne(ot[bt],ot[bt+1]),Nt=Be(ot[bt],ot[bt+1]);kt+=we(Math.min(Je,ut),Math.min(wt,Nt),Math.max(Je,ut),Math.max(wt,Nt),Ue)*1e6+Math.abs(ut-Je)+Math.abs(Nt-wt)}_t.push({pts:ot,cost:kt,lane:Xe})}}_t.sort((Xe,qe)=>Xe.cost-qe.cost);for(let Xe of _t)if(xt(Xe.pts,1)){M[Xe.lane]=1;break}}}return{width:a?ue:fe,height:a?fe:ue,routed:Oe,margins:M,work:Ge}},I=new Uint8Array(B),X=new Uint8Array(l),ee=Y(I,X);for(let K=0;K<ZM&&ee.work<=tp/nA;K++){let z=K===0?ee.routed:I.map((C,M)=>C&ee.routed[M]);if(z.every((C,M)=>C===I[M])&&ee.margins.every((C,M)=>C===X[M]))break;I=z,X=ee.margins,ee=Y(I,X)}return I.some((K,z)=>K&&!ee.routed[z])&&(ee=Y(new Uint8Array(B),new Uint8Array(l))),{width:ee.width,height:ee.height}}function iA(e,t){let n=t.x-e.x,r=t.y-e.y,o=Math.max(e.w/2,.5),s=Math.max(e.h/2,.5);if(Math.abs(n)<o&&Math.abs(r)<s){let i=o-Math.abs(n),c=s-Math.abs(r);return i<c?[e.x+(n<0?-o:o),t.y]:[t.x,e.y+(r<0?-s:s)]}let a=Math.min(n!==0?o/Math.abs(n):1/0,r!==0?s/Math.abs(r):1/0);return[e.x+n*a,e.y+r*a]}var aA="__swimlane_default__";function eI(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=aA);e.nodes.push({id:aA,label:void 0,labelType:"text",shape:"rect",isGroup:!0,parentId:void 0,cssStyles:[],cssCompiledStyles:[],cssClasses:"",dir:void 0})}}function tI(e,t,n,r,o,s,a){let i=e.x-e.w/2,c=e.y-e.h/2,l=s==="LR"||s==="RL",f=l?i+e.padTop/2:e.x,p=l?e.y:c+e.padTop/2,u=De(t,f,p,` class="pele-cluster-label" fill="var(--_m)"${n.text}`,a);return`<g class="pele-cluster pele-lane${r}" data-id="${o}"><rect x="${d(i)}" y="${d(c)}" width="${d(e.w)}" height="${d(e.h)}" fill="none" stroke="var(--_b)"/><rect x="${d(i)}" y="${d(c)}" width="${d(l?e.padTop:e.w)}" height="${d(l?e.h:e.padTop)}" fill="var(--_a)" stroke="var(--_b)"${n.shape}/>`+(l&&u?`<g transform="rotate(-90 ${d(f)} ${d(p)})">${u}</g>`:u)+"</g>"}var nI={type:"swimlane",prepare:eI,layout:(e,t,n,r,o)=>oA(e,t,n,r,o?12:void 0),drawGroup:tI},cA={type:"swimlane",math:!0,parse:Tc.parse,render:(e,t,n)=>Rc(e,t,n,nI)};var Ml=class{constructor(){de(this,"type","timeline");de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"direction","LR");de(this,"sections",[]);de(this,"periods",[]);de(this,"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,`
`)}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 ze("An event needs a time period before it.","semantic",{type:"timeline"});n.events.push(t)}};var lA=["$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 dA(e){let t=e.length,n=[],r=[],o=[],s={types:n,texts:r,starts:o},a=0,i=(c,l)=>{n.push(c),r.push(e.slice(a,l)),o.push(a),a=l};for(;a=Kc(e,a),!(a>=t);){let c=e.charCodeAt(a),l=a+1;if(c===10){for(;e.charCodeAt(l)===10;)l++;i(3,l);continue}if(Yn(e,a,"timeline")){for(l=a+8;e.charCodeAt(l)===32||e.charCodeAt(l)===9;)l++;let f=Yn(e,l,"lr");if(l>a+8&&(f||Yn(e,l,"td"))&&!Qe(e.charCodeAt(l+2))){i(f?5:6,l+2);continue}if(!Qe(e.charCodeAt(a+8))){i(4,a+8);continue}}if(Yn(e,a,"title")&&He(e.charCodeAt(a+5))&&a+6<t&&e.charCodeAt(a+6)!==10){i(7,Ni(e,a+6));continue}if(l=zc(e,a,s,8),l!==a){a=l;continue}if(Yn(e,a,"section")&&He(e.charCodeAt(a+7))){for(l=a+8;l<t&&e.charCodeAt(l)!==58&&e.charCodeAt(l)!==10;)l++;if(l>a+8){i(13,l);continue}}if(c!==58){l=a+1;for(let f=e.charCodeAt(l);l<t&&f!==35&&f!==58&&f!==10;f=e.charCodeAt(++l));i(14,l);continue}if(He(e.charCodeAt(a+1))){for(l=a+2;l<t;l++){let f=e.charCodeAt(l);if(f===10||f===58&&He(e.charCodeAt(l+1)))break}if(l>a+2){i(15,l);continue}}i(2,a+1)}return(o.length===0||o[o.length-1]<t)&&i(1,t),i(0,t),s}var rI="'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:o}=dA(e),s=(i,c)=>{let l=n[i]===0?"1":lA[n[i]];throw st("timeline",e,o[i],`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 i=1;;i++){let c=r[i];switch(n[i]){case 3:break;case 7:t.getCommonDb().setDiagramTitle(c.substring(6));break;case 8:t.getCommonDb().setAccTitle(r[++i].trim());break;case 10:t.getCommonDb().setAccDescription(r[++i].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(i,rI)}}}var Il=12,fA=8,sI=152,iI=216,oI=264,Xs=20,Ui=20,kl=14,qo=8,rp=8,Ll=12,pA=' fill="var(--_bg)"',hA=' fill="none" stroke="var(--_b)"';function sp(e,t,n,r,o){return`<rect x="${d(e)}" y="${d(t)}" width="${d(n)}" height="${d(r)}"${pt(o)}/>`}function gA(e,t,n){return e.direction==="TD"?mA(e,t,n,!0):$t(n,r=>mA(e,t,n,r))}function mA(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=n.measurer??et(n.fontFamily),i=n.padding??8,c=t.timeline?.disableMulticolor!==!0,l=e.periods,f=e.sections.length>0,p=e.sections.map((V,ne)=>({section:ne,periods:[]})),u={section:-1,periods:[]};l.forEach((V,ne)=>(p[V.sectionIndex]??u).periods.push(ne)),u.periods.length>0&&p.unshift(u);let m=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*i:1/0,h=Ui+kl*2+4*Il,b=Math.min(sI,Math.max(80,Math.round((m-h)*.38))),x=Math.min(oI,Math.max(110,m-h-b)),E=b,w=()=>r?x:E,S=l.map(V=>er(V.text,a,o,E)),O=l.map(V=>V.events.map(ne=>er(ne,a,s,w()))),D=0;for(let V of S)D=Math.max(D,V.width);if(!r)for(let V of O)for(let ne of V)D=Math.max(D,ne.width);let L=D>E;if(r)for(let V of O)for(let ne of V)L||=ne.width>x;L&&(E=Math.min(Math.max(Math.ceil(D),b),m===1/0?iI:b),S=l.map(V=>Mn(V.text,a,o,E)),O=l.map(V=>V.events.map(ne=>Mn(ne,a,s,w()))));let B=Math.round(o*1.5),W=E+2*Il,Y=w()+2*Il,I=V=>Math.max(V.height,B)+2*fA,X=V=>Math.max(V.height,Math.round(s*1.5))+2*fA,ee=(V,ne)=>V.section>=0?lt(V.section):f?"var(--_m)":lt(c?ne:0),K=!1;for(let V of O)V.length>0&&(K=!0);let z=0;for(let V of p)z+=Math.max(V.periods.length,1);let C=W+Xs,M=l.length>0,T=r?W+(K?Ui+kl*2+Y:M?Ui+Ll:0):z>0?z*C-Xs+(M?Ll+Ot:0):0,g=Mn(e.title,a,o,Math.max(T,320),1),_=g.height>0?g.height+16:0,y=Math.max(T,g.width),R=i+(y-T)/2,A=i+_,N=(V,ne)=>Mn(e.sections[V.section],a,o,ne-2*Il,1),$=(V,ne,ae,Z,Q,ie)=>sp(ae,Z,Q,ie,` fill="${lt(V.section)}"`)+De(ne,ae+Q/2,Z+ie/2,' font-weight="var(--_hw)"'+pA),U=(V,ne,ae,Z,Q)=>sp(ae,Z,W,Q,` fill="${ne}"`)+De(S[V],ae+W/2,Z+Q/2,pA),j=(V,ne,ae,Z,Q)=>'<g class="pele-node pele-event">'+sp(ae,Z,Y,Q,` fill="${ne}" fill-opacity="0.16"`)+De(V,ae+Y/2,Z+Q/2,` font-size="${s}"`)+"</g>",v=(V,ne,ae)=>`<circle class="pele-dot" cx="${d(V)}" cy="${d(ne)}" r="4" fill="${ae}" stroke="var(--_bg)" stroke-width="2"/>`,k=V=>V.section>=0?`<g class="pele-cluster pele-section" data-id="${Fe(e.sections[V.section].trim())}">`:"",F=V=>`<g class="pele-node pele-period" data-id="${Fe(l[V].text.trim())}">`,H="",G;if(r){let V=R+W+Ui,ne=V+kl,ae=ne+kl,Z=A;for(let Q of p){if(H+=k(Q),Q.section>=0){let ie=N(Q,T),me=I(ie);H+=$(Q,ie,R,Z,T,me),Z+=me+rp+4}for(let ie of Q.periods){let me=ee(Q,ie),re=I(S[ie]),te=O[ie].length>0?X(O[ie][0]):re,he=Z+Math.max(re,te)/2,oe=`M${d(R+W)},${d(he)}H${d(V)}`,ge="",Ee=he-te/2,be=he;for(let ye of O[ie]){let Re=X(ye);be=Ee+Re/2,oe+=`M${d(ne)},${d(be)}H${d(ae)}`,ge+=j(ye,me,ae,Ee,Re),Ee+=Re+qo}ge&&(oe+=`M${d(V)},${d(he)}H${d(ne)}V${d(be)}`),H+=F(ie)+U(ie,me,R,he-re/2,re)+`<path class="pele-edge" d="${oe}"${hA}/>`+v(V,he,me)+ge+"</g>",Z=Math.max(he+re/2,Ee-qo)+Xs}Q.periods.length===0&&(Z+=Xs-rp-4),Q.section>=0&&(H+="</g>")}if(p.length>0&&(Z-=Xs),M){let Q=Z+Ll+Ot;H=`<path class="pele-axis" d="M${d(V)},${d(A)}V${d(Q-Ot+1)}" fill="none" stroke="var(--_l)"/>`+Et("arrow_point",V,Q,0,1,"var(--_l)")+H,Z=Q}G=Z+i}else{let V=0,ne=p.map(te=>{if(te.section<0)return;let he=N(te,Math.max(te.periods.length,1)*C-Xs);return V=Math.max(V,I(he)),he}),ae=0;for(let te of S)ae=Math.max(ae,I(te));let Z=A+(f?V+rp:0),Q=Z+ae+(ae>0?Ui:0),ie=Q+Ui,me=M?Q+Ll:A+V,re=0;if(p.forEach((te,he)=>{let oe=Math.max(te.periods.length,1),ge=R+re*C;H+=k(te);let Ee=ne[he];Ee&&(H+=$(te,Ee,ge,A,oe*C-Xs,V)),te.periods.forEach((be,ye)=>{let Re=ee(te,be),Le=ge+ye*C,ue=Le+W/2,fe=`M${d(ue)},${d(Z+ae)}V${d(O[be].length>0?ie:Q)}`,Me="",Ne=ie;for(let Be of O[be]){let ce=X(Be);Ne>ie&&(fe+=`M${d(ue)},${d(Ne-qo)}V${d(Ne)}`),Me+=j(Be,Re,Le,Ne,ce),Ne+=ce+qo}me=Math.max(me,Ne-qo),H+=F(be)+U(be,Re,Le,Z,ae)+`<path class="pele-edge" d="${fe}"${hA}/>`+v(ue,Q,Re)+Me+"</g>"}),te.section>=0&&(H+="</g>"),re+=oe}),M){let te=R+T;H=`<path class="pele-axis" d="M${d(R)},${d(Q)}H${d(te-Ot+1)}" fill="none" stroke="var(--_l)"/>`+Et("arrow_point",te,Q,1,0,"var(--_l)")+H}G=me+i}let se=Math.ceil(y+2*i),q=Math.ceil(Math.max(G,i*2)),P=De(g,se/2,i+g.height/2,' class="pele-title" font-weight="var(--_tw)"')+H;return{svg:Ze("timeline",se,q,o,n,e,P),width:se,height:q,links:[]}}var bA={type:"timeline",parse(e,t,n){let r=new Ml;return r.title=n,uA(e,r),r},render:gA};var ip=/[─━│┃└┗├┣]/,AA=/[└┗├┣]/,aI=/[─━]/,yA=/^[\s│┃]+$/,cI=/^[\s─━│┃└┗├┣]+$/,lI=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,dI=/^\s*%%/,uI="    ";function fI(e){return e.some(t=>ip.test(t))}function pI(e){for(let t of e){let n=AA.exec(t);if(n?.index&&n.index>0)return n.index}return 4}function op(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(n,r)=>{let o=t.get(parseInt(r,10));return o?`line ${o}`:n})}function EA(e,t){throw new ze(`Line ${e}: ${t}`,"syntax",{type:"treeView",line:e})}function xA(e){let t=new Map;if(!ip.test(e))return{text:e,lineMap:t};let n=e.split(`
`),r=-1;for(let l=0;l<n.length;l++)if(n[l].trim()==="treeView-beta"){r=l;break}if(r===-1)return{text:e,lineMap:t};let o=l=>l.trim()===""||dI.test(l)||lI.test(l),s=[];for(let l=r+1;l<n.length;l++){let f=n[l];o(f)||yA.test(f)||s.push(f.replace(/\t/g,"    "))}if(!fI(s))return{text:e,lineMap:t};let a=pI(s),i=[],c=(l,f)=>{i.push(l),t.set(i.length,f+1)};for(let l=0;l<=r;l++)c(n[l],l);for(let l=r+1;l<n.length;l++){let f=n[l];if(o(f)){c(f,l);continue}if(yA.test(f))continue;let p=f.replace(/\t/g,"    "),u=AA.exec(p);if(u){let m=Math.round(u.index/a)+1,h=u.index+1;for(;h<p.length&&aI.test(p[h]);)h++;for(;h<p.length&&p[h]===" ";)h++;let b=p.slice(h).trimEnd();b||EA(l+1,"Empty node — expected a filename or directory name after the box-drawing prefix"),c(uI.repeat(m)+b,l)}else{if(cI.test(p))continue;ip.test(p)?c(f,l):/^\s+/.test(p)?EA(l+1,"Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes."):c(f,l)}}return{text:i.join(`
`),lineMap:t}}function hI(e,t){if(e.startsWith("##",t)||e.startsWith("icon(",t))return!0;if(!e.startsWith(":::",t))return!1;let n=t+3;for(;Bn(e.charCodeAt(n));)n++;let r=e.charCodeAt(n);return r>=65&&r<=90||r>=97&&r<=122||r===95}function mI(e,t){let n=e.charCodeAt(t);if(Bn(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,o=t+1;for(;o<r;){let s=e.charCodeAt(o);if(s===10||s===13)break;if(Bn(s)){let a=o+1;for(;Bn(e.charCodeAt(a));)a++;if(hI(e,a))break;o=a}else o++}return o}var SA={name:"BARE_NAME",pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:mI},_A=[{...qt("treeView-beta"),longer:[SA]},_i(),zt,Vt,{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},SA];function wA(e){let t=e.length;for(;t>0&&Bn(e.charCodeAt(t-1));)t--;return t===e.length?e:e.slice(0,t)}function ap(e,t){switch(e){case"INDENTATION":return t?.length||0;case"QUOTED_NAME":return t.substring(1,t.length-1);case"BARE_NAME":return wA(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 RA(e){let t=new Bt(Wt(e,_A,"treeView"),_A,"treeView"),n={$type:"TreeView",nodes:[]};for(t.expect(0);;)if(t.kind===1)n.accDescr=Ht(t.take());else if(t.kind===2)n.accTitle=Yt(t.take());else if(t.kind===3)n.title=Gt(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 o=t.take();r.name=o.substring(1,o.length-1)}else t.kind===12?r.name=wA(t.take()):t.fail("a name");for(;;)if(t.kind===4)r.classAnnotation=ap("CLASS_ANNOTATION",t.take());else if(t.kind===5)r.iconAnnotation=ap("ICON_ANNOTATION",t.take());else if(t.kind===6)r.descAnnotation=ap("DESC_ANNOTATION",t.take());else break;n.nodes.push(r)}return n}var cp=class{constructor(){de(this,"count",1);de(this,"root",{id:0,level:-1,name:"/",nodeType:"directory",children:[]});de(this,"stack",[this.root])}addNode(t,n,r,o,s,a){let i=this.stack;for(;t<=i[i.length-1].level;)i.pop();let c={id:this.count++,level:t,name:n,nodeType:r,icon:s,cssClass:o,description:a,children:[]};i[i.length-1].children.push(c),i.push(c)}};function gI(e,t){for(let n of e.nodes){let r=typeof n.indent=="number"?n.indent:0,o=n.name,s=o.endsWith("/");s&&(o=o.slice(0,-1));let a=n.iconAnnotation;t.addNode(r,o,s?"directory":"file",n.classAnnotation||void 0,a!==void 0?a||"none":void 0,n.descAnnotation||void 0)}}function TA(e){let{text:t,lineMap:n}=xA(e);try{return RA(t)}catch(r){if(n.size===0||!(r instanceof ze))throw r;let o=r.message.indexOf(`
`),s=o===-1?op(r.message,n):op(r.message.slice(0,o),n)+r.message.slice(o);throw new ze(s,r.code,{type:r.type,line:n.get(r.line)??r.line,column:r.column,snippet:r.snippet})}}function CA(e,t){let n=new cp;return gI(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,`
`):void 0,root:n.root,count:n.count}}var Qo="mermaid-treeview",$l=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 lp(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 bI(e,t){let n=lp(t?.filenameIcons,e);if(n)return n;let r=e.lastIndexOf(".");if(r>0){let o=e.substring(r).toLowerCase();return lp(t?.extensionIcons,o)??lp(t?.extensionIcons,o.slice(1))}}function NA(e,t){return e.includes(":")?e:$l.has(e)||!t?`${Qo}:${e}`:`${t}:${e}`}function dp(e,t){if(e.icon!=="none"){if(e.icon)return NA(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType==="file"){let n=bI(e.name,t);if(n==="none")return;if(n)return NA(n,t.defaultIconPack)}return`${Qo}:${e.nodeType==="directory"?"folder":"file"}`}}}function MA(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 yI=6,EI=16,AI=7,xI=4,Dl=4;function Ol(e,t,n,r,o){let s=e.treeView?.[t];return typeof s=="number"&&s>=r&&s<=o?s:n}function SI(e){return{paddingX:Ol(e,"paddingX",5,0,100),paddingY:Ol(e,"paddingY",2,0,100),rowIndent:Ol(e,"rowIndent",15,0,400),lineThickness:Ol(e,"lineThickness",1,.25,12)}}function IA(e,t,n){return gn(n,r=>_I(e,t,n,r))}function _I(e,t,n,r){let o=n.fontSize??16,s=n.measurer??et(n.fontFamily),a=n.padding??8,i=MA(t),{paddingX:c,paddingY:l,rowIndent:f,lineThickness:p}=SI(t),u=0,m=e.root.children.map(R=>[R,0]);for(let R=0;r&&R<m.length;R++){let[A,N]=m[R];u=Math.max(u,N);for(let $ of A.children)m.push([$,N+1])}let h=r?Math.min(f+c,Math.max(2,((n.maxWidth??320)-120)/Math.max(1,u))):f+c,b=Math.round(o*1.5)+2*l,x=o,E=We(e.title,!1,s,o,r?Tt(n):4e3,1),w=E.height>0?E.height+12:0,S=R=>R.some(A=>dp(A,i)!==void 0),O=[],D=new Map,L=[],B=(R,A)=>{let N=S(R);for(let $=R.length-1;$>=0;$--)L.push([R[$],A,N])};B(e.root.children,0);let W=0,Y=!1,I=0;for(;L.length>0;){let[R,A,N]=L.pop(),$=A*h,U=yt(R.name),j=$+(N?x+yI:0),v=Math.max(40,(n.maxWidth??320)-2*a-2*Dl-j),k=r?Ms(U,s,o,v,R.nodeType==="directory"?1:0):void 0,F=r&&R.description?Ms(yt(R.description),s,o,v,2):void 0,H=k?k.width:s.width(U,o,R.nodeType==="directory"?1:0);j+H>W&&(W=j+H);let G=R.cssClass!==void 0&&R.cssClass.split(/\s+/).includes("highlight");G&&(Y=!0);let se=r?Math.max(b,(k?.height??0)+(F?.height??0)+2*l):b,q=I+(r?l+Math.max(x,k?.height??0)/2:se/2),P={node:R,x:$,cy:q,icon:dp(R,i),text:U,labelX:j,highlighted:G,label:k,description:F,top:I,height:se};I+=se,O.push(P),D.set(R,P),B(R.children,A+1)}let X=W+EI,ee=W;for(let R of O){let A=R.node.description;if(!A)continue;let N=R.description?R.description.width:s.width(yt(A),o,2);ee=Math.max(ee,(r?R.labelX:X)+N)}ee=Math.max(ee,E.width);let K=a+(Y?Dl:0),z=a+w,C=Math.ceil(ee+2*K),M=Math.ceil(z+I+a),T="";for(let R of O){let A=R.node.children;if(A.length===0)continue;let N=K+R.x+AI,$=Math.max(N,K+R.x+h-c),U=z+D.get(A[A.length-1]).cy,j=Math.min(xI,$-N),v=`M${d(N)},${d(z+R.top+R.height-2)}V${d(U-j)}`;j>0&&(v+=`Q${d(N)},${d(U)} ${d(N+j)},${d(U)}H${d($)}`);for(let k=0;k<A.length-1&&$>N;k++)v+=`M${d(N)},${d(z+D.get(A[k]).cy)}H${d($)}`;T+=`<path d="${v}"/>`}let g=o*.35,_="";for(let R of O){let A=R.node,N=z+R.cy,$=A.nodeType==="directory",U="";if(R.highlighted){let j=K+R.x-Dl;U+=`<rect class="pele-tree-highlight" x="${d(j)}" y="${d(z+R.top+1)}" width="${d(C-K+Dl-j)}" height="${d(R.height-2)}" fill="var(--_c)" fill-opacity="0.14"${it}/>`}if(R.icon!==void 0){let j=R.icon.startsWith(Qo+":")?R.icon.slice(Qo.length+1):"",v=$l.get(j)??$l.get($?"folder":"file"),k=n.icons?.(R.icon)??`<path d="${v}" stroke="var(--_m)" stroke-width="1.5"/>`;U+=`<svg class="pele-icon" data-icon="${Fe(R.icon)}" x="${d(K+R.x)}" y="${d(N-x/2)}" width="${d(x)}" height="${d(x)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${k}</svg>`}R.label?U+=Ir(R.label,K+R.labelX,z+R.top+l,` class="pele-label"${$?' font-weight="var(--_hw)"':""}`):R.text!==""&&(U+=`<text class="pele-label" x="${d(K+R.labelX)}" y="${d(N+g)}"${$?' font-weight="var(--_hw)"':""} xml:space="preserve">${je(R.text)}</text>`),R.description?U+=Ir(R.description,K+R.labelX,z+R.top+l+(R.label?.height??0),' class="pele-tree-description" font-style="italic" fill="var(--_m)"'):A.description&&(U+=`<text class="pele-tree-description" x="${d(K+X)}" y="${d(N+g)}" font-style="italic" fill="var(--_m)" xml:space="preserve">${je(yt(A.description))}</text>`),_+=`<g class="pele-node pele-tree-${$?"dir":"file"}${Rt(A.cssClass??"")}" data-id="${Fe(A.name)}">${U}</g>`}let y=De(E,C/2,a+E.height/2,' class="pele-title" font-weight="var(--_tw)"')+(T?`<g class="pele-tree-guides" fill="none" stroke="var(--_b)" stroke-width="${d(p)}">${T}</g>`:"")+_;return{svg:Ze("treeView",C,M,o,n,e,y),width:C,height:M,links:[]}}var kA={type:"treeView",parse:(e,t,n)=>CA(TA(e),n),render:IA};function wI(e){let t=[],n=[];for(let r of e){let o=r.type==="Leaf",s={name:r.name,children:o?void 0:[]};for(s.classSelector=r.classSelector,r.cssCompiledStyles&&(s.cssCompiledStyles=r.cssCompiledStyles),o&&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),o||n.push({node:s,level:r.level})}return t}function LA(e,t){let n=new Map;for(let o of e.TreemapRows){if(o.$type!=="ClassDefStatement")continue;let s=n.get(o.className);s||n.set(o.className,s=[]);let a=(o.styleText??"").replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",");for(let i of a.split(";"))s.push(i)}let r=[];for(let o of e.TreemapRows){if(o.$type!=="TreemapRow")continue;let s=o.item,a=s.classSelector?n.get(s.classSelector):void 0;r.push({level:o.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,`
`):void 0,roots:wI(r),classes:n}}var $A=[tn,zt,Vt,{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}],RI=/classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/;function DA(e){let t=new Bt(Wt(e,$A,"treemap"),$A,"treemap"),n=t.kinds,r={$type:"Treemap",TreemapRows:[]},o=()=>t.accept(5)?t.expect(12):void 0;for(t.expect(3);t.kind!==-1;){let s=t.kind;if(s===0){r.accDescr=Ht(t.take());continue}if(s===1){r.accTitle=Yt(t.take());continue}if(s===2){r.title=Gt(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 u=RI.exec(t.take()),m={$type:"ClassDefStatement",className:u[1]};u[2]&&(m.styleText=u[2]),a!==void 0&&(m.indent=a),r.TreemapRows.push(m);continue}let i=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:i,value:parseFloat(t.expect(13).replace(/,/g,""))}):l={$type:"Section",name:i};let f=o();f!==void 0&&(l.classSelector=f);let p={$type:"TreemapRow",item:l};a!==void 0&&(p.indent=a),r.TreemapRows.push(p)}return r}var OA=/^(?:.?[<>=^])?([-+( ])?(\$)?0?\d*(,)?(?:\.(\d+))?(~)?([a-zA-Z%])?$/;function vA(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 PA(e){let t=OA.exec(e==="$0,0"?"$,":e)??OA.exec(","),n=t[1]==="+",r=t[3]!==void 0,o=t[4]===void 0?void 0:Math.min(Number(t[4]),20),s=t[6]??"";return a=>{let i=Math.abs(a),c,l="";if(s==="f"?c=i.toFixed(o??6):s==="%"?(c=(i*100).toFixed(o??6),l="%"):s==="d"?c=Math.round(i).toFixed(0):s==="e"?c=i.toExponential(o??6):c=String(Number(i.toPrecision(Math.max(1,o??12)))),t[5]&&c.includes(".")&&!c.includes("e")&&(c=c.replace(/\.?0+$/,"")),r&&!c.includes("e")){let f=c.indexOf(".");c=f===-1?vA(c):vA(c.slice(0,f))+c.slice(f)}return(a<0?"-":n?"+":"")+(t[2]??"")+c+l}}function BA(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:[],x:0,y:0,w:0,h:0}}function TI(e,t,n,r,o,s,a){let i=t,c=0;for(;c<e.length;){let l=o*s/i,f=Math.min(o,s),p=e[c].value*l,u=p,m=Math.max(f*f*u/(p*p),p*p/(f*f*u)),h=c+1;for(;h<e.length;){let E=e[h].value*l,w=p+E,S=Math.max(f*f*u/(w*w),w*w/(f*f*E));if(S>m)break;m=S,p=w,h++}let b=p/f,x=0;for(let E=c;E<h;E++){let w=e[E],S=E===h-1?f-x:w.value*l/b,O=o>=s?n:n+x,D=o>=s?r+x:r,L=Math.round(O+a/2),B=Math.round(D+a/2);w.x=L,w.y=B,w.w=Math.round(O+(o>=s?b:S)-a/2)-L,w.h=Math.round(D+(o>=s?S:b)-a/2)-B,x+=S,i-=w.value}o>=s?(n+=b,o-=b):(r+=b,s-=b),c=h}}function FA(e,t,n,r){let o=e.map((p,u)=>BA(p,void 0,u)),s=o.slice();for(let p=0;p<s.length;p++){let u=s[p];for(let m of u.node.children??[]){let h=BA(m,u,u.series);u.children.push(h),s.push(h)}}for(let p=s.length-1;p>=0;p--){let u=s[p];u.parent&&(u.parent.value+=u.value)}let{gap:a,header:i,side:c}=r,l=[],f=(p,u,m,h,b)=>{if(h<=0||b<=0)return;let x=p.filter(w=>w.value>0).sort((w,S)=>S.value-w.value),E=0;for(let w of x)E+=w.value;if(!(x.length===0||!Number.isFinite(E))){TI(x,E,u-a/2,m-a/2,h+a,b+a,a);for(let w of x)w.w>0&&w.h>0&&l.push(w)}};f(o,0,0,t,n);for(let p=0;p<l.length;p++){let u=l[p];u.children.length>0&&f(u.children,u.x+c,u.y+i,u.w-2*c,u.h-i-c)}return l}var up=28,vl=6,Pl=1.25;function Bl(e,t,n,r,o){let s=e.treemap?.[t];return typeof s=="number"&&s>=r?Math.min(s,o):n}function WA(e,t,n){let r=n.fontSize??16,o=Math.round(r*.875),s=Math.round(r*.75),a=Math.round(r*.5625),i=n.measurer??et(n.fontFamily),c=t.treemap??{},l=n.padding??Bl(t,"diagramPadding",8,0,2e3),f=Math.round(zr(n,Bl(t,"nodeWidth",64,1,400)*10,200,2*l)),p=Math.round(Bl(t,"nodeHeight",40,1,400)*10),u=c.showValues!==!1,m=PA(typeof c.valueFormat=="string"?c.valueFormat:","),h=FA(e.roots,f,p,{gap:Bl(t,"padding",4,0,200),header:up,side:vl}),b=We(e.title,!1,i,r,Tt(n),1),x=b.height>0?b.height+8:0,E=l+Math.max(0,(b.width-f)/2),w=l+x,S="",O="";for(let W of h){let Y=W.node,I=St(Y.cssCompiledStyles??[]),X=lt(W.series),ee=E+W.x,K=w+W.y,z=yt(Y.name).trim(),C=u?m(W.value):"",M=`data-id="${Fe(Y.name)}">`,T=`<rect x="${d(ee)}" y="${d(K)}" width="${d(W.w)}" height="${d(W.h)}" fill="${X}"`;if(Y.children!==void 0){let A="";if(W.h>=up){let $=W.w-2*vl-4,U=C?i.width(C,s,0):0,j=U>0&&$-U-12>=3*o,v=Ho(z,j?$-U-12:$,o,o,i,1),k=K+up/2+1;v&&(A+=`<text x="${d(ee+vl+2)}" y="${d(k+o*.35)}" font-weight="var(--_hw)"${I.text}>${je(v.text)}</text>`),j&&(A+=`<text class="pele-value" x="${d(ee+W.w-vl-2)}" y="${d(k+s*.35)}" font-size="${s}" text-anchor="end" fill="var(--_m)"${I.text}>${je(C)}</text>`)}let N=/[";]fill:/.test(I.shape)?"":' fill-opacity="0.12"';S+=`<g class="pele-node pele-section${Rt(Y.classSelector??"")}" ${M}${T}${pt(`${N} stroke="${X}"${I.shape}`)}/>${A}</g>`;continue}let g="",_=W.w-8,y=Math.min(r,Math.floor((W.h-4)/Pl)),R=y>=a?Ho(z,_,y,a,i):void 0;if(R){let A=d(ee+W.w/2),N=K+W.h/2,$=Math.max(a,Math.round(R.size*.8)),U=(R.size+$)*Pl;if(C&&U<=W.h-4&&i.width(C,$,0)<=_){let j=N-U/2+R.size*Pl/2,v=N+U/2-$*Pl/2;g=`<text x="${A}" y="${d(j+R.size*.35)}" font-size="${d(R.size)}"${I.text}>${je(R.text)}</text><text class="pele-value" x="${A}" y="${d(v+$*.35)}" font-size="${d($)}"${I.text}>${je(C)}</text>`}else g=`<text x="${A}" y="${d(N+R.size*.35)}" font-size="${d(R.size)}"${I.text}>${je(R.text)}</text>`}O+=`<g class="pele-node pele-leaf${Rt(Y.classSelector??"")}" ${M}${T}${pt(I.shape)}/>${g}</g>`}let D=Math.ceil(Math.max(f,b.width)+2*l),L=Math.ceil(p+x+2*l),B=De(b,D/2,l+b.height/2,' class="pele-title" font-weight="var(--_tw)"')+(S?`<g class="pele-sections" font-size="${o}">${S}</g>`:"")+(O?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${O}</g>`:"");return{svg:Ze("treemap",D,L,r,n,e,B),width:D,height:L,links:[]}}var UA={type:"treemap",parse:(e,t,n)=>LA(DA(e),n),render:WA};var fp="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 Zo=1,HA=2,fs=new Uint8Array(128);for(let e=48;e<=57;e++)fs[e]=Zo;for(let e=65;e<=90;e++)fs[e]=fs[e+32]=Zo;fs[95]=Zo;for(let e of"!#$&*+/=?^|~")fs[e.charCodeAt(0)]=HA;var GA=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];function Fl(e){return e<128&&(fs[e]&Zo)!==0}function pp(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 CI(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:pp(e,t,"extend")?18:0;case 69:return pp(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 pp(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 qs(e,t){let n=1,r=0;for(let o=0;o<t;o++){let s=e.charCodeAt(o);s!==10&&s!==13||(s===13&&o+1<t&&e.charCodeAt(o+1)===10&&o++,n++,r=o+1)}return[n,t-r+1]}function KA(e,t,n){let[r,o]=qs(e,t);return`line ${r}, column ${o} [${t},${n})`}function zA(e,t,n){for(let r=t+1;r<e.length;r++){let o=e.charCodeAt(r);if(o===n)return r+1;if(o===10||o===13)return-1}return-1}function NI(e,t){let n=e.charCodeAt(t);return n!==34&&n!==39?!0:n===34&&e.charCodeAt(t+1)===96||zA(e,t,n)!==-1}function YA(e,t,n){let[r,o]=qs(e,t);return new ze(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters. at line ${r}, column ${o} [${t},${t+n})`,"syntax",{type:"usecase",line:r,column:o})}function VA(e){let t=[],n=[],r=[],o=e.length,s=0,a=!0,i=!1;for(;s<o;){let c=e.charCodeAt(s);if(c===32||c===9){s++;continue}let l,f=s+1,p=!1;if(c<128&&(fs[c]&Zo)!==0){if(l=0,c===97&&a&&e.startsWith("acc",s)){let u=e.startsWith("Descr",s+3);if(u||e.startsWith("Title",s+3)){let m=s+8;for(;Bn(e.charCodeAt(m));)m++;let h=e.charCodeAt(m);if(h===58)for(l=u?42:41,f=m+1;f<o&&e.charCodeAt(f)!==10&&e.charCodeAt(f)!==13;)f++;else if(h===123&&u&&!i){let b=e.indexOf("}",m+1);b===-1?i=!0:(l=40,f=b+1)}}}else if(c===106&&e.startsWith("json",s)&&Bn(e.charCodeAt(s+4))){let u=s+5;for(;Bn(e.charCodeAt(u));)u++;let m=u;for(;Fl(e.charCodeAt(u));)u++;if(u>m){for(;Bn(e.charCodeAt(u));)u++;if(e.charCodeAt(u)===64){for(u++;Bn(e.charCodeAt(u));)u++;if(e.charCodeAt(u)===123){t.push(43),n.push(s),r.push(u),s=u;let h=0,b=!1,x=!1,E=u;for(;E<o;E++){let w=e.charCodeAt(E);if(b)x?x=!1:w===92?x=!0:w===34&&(b=!1);else if(w===34)b=!0;else if(w===123)h++;else if(w===125&&--h===0)break}t.push(E<o?44:45),n.push(u),s=E<o?E+1:o,r.push(s),a=!1;continue}}}}if(l===0){for(;f<o&&Fl(e.charCodeAt(f));)f++;let u=CI(e,s,c);if(u!==0)u===1||f-s===GA[u]?(l=u,f=s+GA[u]):l=21;else if((c===111||c===120)&&e.charCodeAt(s+1)===45&&e.charCodeAt(s+2)===45)l=c===111?56:58,f=s+3;else if(ft(c)){let m=s+1;for(;ft(e.charCodeAt(m));)m++;if(e.charCodeAt(m)===46&&ft(e.charCodeAt(m+1))){for(l=22,f=m+2;ft(e.charCodeAt(f));)f++;for(;Rr(e.charCodeAt(f));)f++}else l=21}else for(l=21;e.charCodeAt(f)===45&&Fl(e.charCodeAt(f+1));)for(l=27,f+=2;Fl(e.charCodeAt(f));)f++}}else if(c===10)l=39,p=!0;else if(c===13)l=39,p=!0,e.charCodeAt(f)===10&&f++;else if(c===34||c===39){if(c===34&&e.charCodeAt(s+1)===96){let u=e.indexOf('`"',s+2);l=u===-1?37:36,f=u===-1?o:u+2}else if(l=35,f=zA(e,s,c),f===-1){let u=s+1;for(;u<o&&!NI(e,u);)u++;throw YA(e,s,u-s)}}else if(c===37)if(a&&e.charCodeAt(f)===37)for(l=38;f<o&&e.charCodeAt(f)!==10&&e.charCodeAt(f)!==13;)f++;else l=31;else if(c===45)if(e.charCodeAt(f)!==45)l=29;else{for(;e.charCodeAt(f)===45;)f++;let u=e.charCodeAt(f),m=f-s===2;m&&u===124&&e.charCodeAt(f+1)===62?(l=46,f+=2):u===62?(l=53,f++):m&&(u===111||u===120)?(l=u===111?55:57,f++):l=59}else if(c===46){let u=e.charCodeAt(f);if(u===46&&e.charCodeAt(f+1)===62)l=47,f+=2;else if(ft(u)){for(l=22;ft(e.charCodeAt(f));)f++;for(;Rr(e.charCodeAt(f));)f++}else l=30}else if(c===60)if(e.charCodeAt(f)===60){if(t.push(48),n.push(s),r.push(s+2),a=!1,s+=2,s>=o)break;if(e.charCodeAt(s)===62&&e.charCodeAt(s+1)===62)l=49,f=s+2;else{let u=s,m=!1;for(;u<o;u++){let h=e.charCodeAt(u);if(h===10||h===13)break;if(h===62&&e.charCodeAt(u+1)===62){m=!0;break}}if(m&&e.slice(s,u).trim()!=="")t.push(50),n.push(s),r.push(u),l=49,s=u,f=u+2;else{for(;u<o&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;if(u===s){for(;u<o&&(e.charCodeAt(u)===10||e.charCodeAt(u)===13);)u++;throw YA(e,s,u-s)}l=51,f=u}}}else if(e.charCodeAt(f)===45&&e.charCodeAt(f+1)===45)for(l=54,f+=2;e.charCodeAt(f)===45;)f++;else l=33;else if(c===58)e.charCodeAt(f)===58&&e.charCodeAt(f+1)===58?(l=52,f+=2):l=25;else if(c===64)e.charCodeAt(f)===123?(l=60,f++):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(;fa(e.charCodeAt(f));)f++;l=f>s+1?26:32}else if(c===92)e.charCodeAt(f)===44?(l=28,f++):l=33;else if(c<127&&c>32)l=(fs[c]&HA)!==0?32:33;else for(l=34;f<o;){let u=e.charCodeAt(f);if(u>=32&&u<127||u===9||u===10||u===13)break;f++}t.push(l),n.push(s),r.push(f),s=f,a=p}for(let c=0;c<3;c++)t.push(0),n.push(o),r.push(o);return{types:t,starts:n,ends:r}}function jA(){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 XA(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:"",accDescription:""}}function hp(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 MI(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 qA(e,t,n,r,o){let s=jA(),{actors:a,useCases:i,systemBoundaries:c}=s,l=new Map,f=new Map,p=new Map,u=new Map,m=new Map,h=y=>KA(e,y[0],y[1]),b=(y,R)=>{let[A,N]=qs(e,R[0]);return new ze(y,"semantic",{type:"usecase",line:A,column:N})},x=(y,R)=>{throw b(`${y} at ${h(R)}`,R)},E=(y,R,A,N,$)=>{let U=j=>j===void 0?"":` (label "${j}")`;throw b(`${y} at ${h(R)}${U(N)}; previous declaration at ${h(A)}${U($)}`,R)},w=(y,R,A)=>x(`Metadata property '${A.key}' is invalid for ${R} '${y}'`,A.keySpan),S=(y,R)=>{let A=m.get(y);(A===void 0||R<A)&&m.set(y,R)},O=y=>[...y].sort((R,A)=>(m.get(R.id)??0)-(m.get(A.id)??0)),D=(y,R)=>{l.set(y.id,{kind:R,span:y.span,generated:y.generated,label:y.label.text})},L=(y,R)=>{let A=l.get(y.id);if(!A)return;let N=y.generated?y.label.text:void 0,$=A.generated?A.label:void 0;A.kind!==R&&E(`ID '${y.id}' is declared as both ${A.kind} and ${R}`,y.span,A.span,N,$),(A.generated||y.generated)&&E(`Generated ID '${y.id}' collides with another declaration`,y.span,A.span,N,$)},B=(y,R,A)=>{let N=l.get(y);N&&E(`ID '${y}' is declared more than once (${N.kind} and ${R})`,A,N.span,void 0,N.generated?N.label:void 0),l.set(y,{kind:R,span:A,generated:!1})},W=(y,R,A)=>{let{key:N,value:$}=R,U=j=>{!A&&j!==void 0&&j!==$&&E(`Actor '${y.id}' has conflicting ${N} metadata`,R.keySpan,y.span)};N==="type"&&($==="normal"||$==="hollow"||$==="awesome")?(U(y.actorType),y.actorType=$):N==="icon"&&typeof $=="string"?(U(y.icon),y.icon=$):N==="business"&&typeof $=="boolean"?(U(y.business),y.business=$):w(y.id,"actor",R)},Y=(y,R,A)=>{for(let N of R??[])y.kind==="actor"?W(y,N,A):N.key==="business"&&typeof N.value=="boolean"?(!A&&y.business!==void 0&&y.business!==N.value&&E(`Use case '${y.id}' has conflicting business metadata`,N.keySpan,y.span),y.business=N.value):w(y.id,"usecase",N)},I=y=>{let R;if(y.kind==="actor"){i.delete(y.id);let A={id:y.id,label:y.label.text,labelType:y.label.type,business:y.business??!1,classes:[...y.classes],type:y.icon?"icon":y.actorType??"normal",styles:a.get(y.id)?.styles??[]};y.icon&&(A.icon=y.icon),a.set(y.id,A),R=A}else a.delete(y.id),R={id:y.id,label:y.label.text,labelType:y.label.type,business:y.business??!1,classes:[...y.classes],shape:y.shape??"ellipse",styles:i.get(y.id)?.styles??[]},i.set(y.id,R);y.stereotype&&(R.stereotype=y.stereotype),y.parent?.id&&(R.parentId=y.parent.id)},X=y=>{L(y,y.kind);let R=y.parent?.id?y.parent:void 0,A=f.get(y.id);if(!A){let N={kind:y.kind,id:y.id,label:y.label,span:y.span,generated:y.generated,classes:[...y.classes],parent:R,shape:y.shape,stereotype:y.stereotype,stereotypeSpan:y.stereotype?y.span:void 0};Y(N,y.metadata,!1),f.set(y.id,N),D(y,y.kind);return}(A.label.text!==y.label.text||A.label.type!==y.label.type)&&E(`ID '${y.id}' has conflicting labels`,y.span,A.span),y.shape&&A.shape&&y.shape!==A.shape&&E(`Use case '${y.id}' has conflicting shapes`,y.span,A.span),R&&A.parent?.id&&R.id!==A.parent.id&&E(`Element '${y.id}' belongs to more than one system boundary`,R.span,A.parent.span),y.stereotype&&A.stereotype&&y.stereotype!==A.stereotype&&E(`Element '${y.id}' has conflicting stereotypes`,y.span,A.stereotypeSpan??A.span),A.shape??=y.shape,A.parent??=y.parent,A.stereotype??=y.stereotype,A.stereotypeSpan??=y.stereotype?y.span:void 0,hp(A.classes,y.classes),Y(A,y.metadata,!1)},ee=y=>{L(y,"boundary");let R=p.get(y.id);if(R){(R.label.text!==y.label.text||R.label.type!==y.label.type)&&E(`Boundary '${y.id}' has conflicting titles`,y.span,R.span),hp(R.classes,y.classes);return}p.set(y.id,{...y,classes:[...y.classes],members:[]}),D(y,"boundary")},K=y=>{y.classed&&!y.declares&&x(`Relationship endpoint '${y.id}' uses ::: without declaring the node`,y.span);let R=l.get(y.id);return R?R.kind:(f.set(y.id,{...y,kind:"usecase",shape:"ellipse",classes:[]}),D(y,"usecase"),S(y.id,y.span[0]),"usecase")},z=(y,R)=>{let A=l.get(y)?.kind;return(A==="actor"?a.get(y):A==="usecase"?i.get(y):A==="boundary"?c.get(y):A==="json"?s.jsonNodes.get(y):u.get(y))??x(`Class/style target '${y}' is unresolved or anonymous`,R)},C=[];for(let{source:y,target:R}of t.relationships)S(y.id,y.span[0]),S(R.id,R.span[0]);for(let y of t.elements)S(y.id,y.span[0]),C.push({offset:y.span[0],run:()=>X(y)});for(let y of t.boundaries)S(y.id,y.span[0]),C.push({offset:y.span[0],run:()=>ee(y)});for(let y of t.jsons)S(y.id,y.span[0]),C.push({offset:y.span[0],run:()=>B(y.id,"json",y.span)});for(let{id:y,idSpan:R}of t.relationships)y&&R&&C.push({offset:R[0],run:()=>B(y,"edge",R)});C.sort((y,R)=>y.offset-R.offset);for(let y of C)y.run();for(let y of O(f.values()))I(y);for(let y of O(p.values()))c.set(y.id,{id:y.id,label:y.label.text,labelType:y.label.type,type:"rect",members:[],classes:[],styles:[]});for(let y of O(t.jsons))s.jsonNodes.set(y.id,{id:y.id,value:y.value,propertyOrder:y.propertyOrder,classes:[...y.classes],styles:[]});let M=0;for(let y of t.relationships){let{source:R,target:A,type:N}=y,$=K(R),U=K(A),j=F=>F==="actor"||F==="usecase"||F==="json";j($)||E(`Relationship source '${R.id}' cannot be ${$}`,R.span,l.get(R.id).span),j(U)||E(`Relationship target '${A.id}' cannot be ${U}`,A.span,l.get(A.id).span),(N==="include"||N==="extend")&&($!=="usecase"||U!=="usecase")&&x(`${N} relationship requires use-case endpoints`,y.span),N==="generalization"&&($==="json"||$!==U)&&x("Generalization requires actor-to-actor or use-case-to-use-case endpoints",y.span),N==="association"&&($==="json"||U==="json")&&y.arrowType>2&&x(`JSON relationship '${R.id}' to '${A.id}' permits only point, reversed-point, or markerless solid association`,y.span);let v=y.id??`edge-${M++}`,k={id:v,explicitId:!!y.id,source:R.id,target:A.id,type:N,arrowType:y.arrowType,minlen:y.minlen,classes:[],styles:[],animate:!1};y.label&&(k.label=y.label.text,k.labelType=y.label.type),s.relationships.push(k),u.set(v,k)}let T=new Map(a),g=new Map(i);a.clear(),i.clear();for(let y of O(f.values())){let R=T.get(y.id),A=g.get(y.id);R?a.set(y.id,R):A?i.set(y.id,A):I(y)}for(let{target:y,span:R,properties:A,statement:N}of t.metadata){let $=l.get(y);if(!$){let k=MI(A);return x(`Metadata target '${y}' is unresolved${k?` (metadata implies ${k})`:""}`,R)}let U=$.kind;U==="actor"||U==="usecase"?Y(f.get(y),A,!0):U==="edge"&&(N.kind="edgeMetadata",N.edges=[{id:y,span:N.span,idSpan:R,metadata:N.metadata}],delete N.nodes);let j=p.get(y),v=u.get(y);for(let k of U==="actor"||U==="usecase"?[]:A){let{key:F,value:H}=k;U==="boundary"&&j&&F==="type"&&(H==="rect"||H==="package")?j.type=H:U==="edge"&&v&&F==="animate"&&typeof H=="boolean"?v.animate=H:U==="edge"&&v&&F==="animation"&&(H==="fast"||H==="slow")?(v.animation=H,v.animate=!0):w(y,U,k)}}for(let y of s.relationships)y.animation&&(y.animate=!0);for(let y of f.values())y.kind==="actor"?(y.icon&&y.actorType&&y.actorType!=="normal"&&x(`Actor '${y.id}' cannot combine icon with type '${y.actorType}'`,y.span),y.business&&(y.icon||y.actorType==="awesome")&&x(`Business actor '${y.id}' must use normal or hollow geometry`,y.span)):y.shape==="rect"&&y.business&&x(`Rectangular use case '${y.id}' cannot be a business use case`,y.span),I(y);for(let y of[...t.elements].sort((R,A)=>R.span[0]-A.span[0])){if(!y.parent?.id)continue;let R=p.get(y.parent.id).members;R.includes(y.id)||R.push(y.id)}for(let y of p.values()){let R=c.get(y.id);R.type=y.type??"rect",R.members=y.members,R.classes=[...y.classes]}let _=0;for(let y of t.notes){let R=l.get(y.target);if(!R)return x(`Note target '${y.target}' is unresolved`,y.span);R.kind!=="actor"&&R.kind!=="usecase"&&E(`Note target '${y.target}' must be an actor or use case, not ${R.kind}`,y.span,R.span);let A=`note-${_++}`;s.notes.set(A,{id:A,target:y.target,label:y.label.text,labelType:y.label.type})}for(let y of t.classDefs)for(let R of y.ids)s.classDefs.set(R,{id:R,styles:[...y.styles]});for(let y of t.classes)for(let R of y.targets)hp(z(R.id,R.span).classes,y.classes);for(let y of t.styles)z(y.target,y.span).styles.push(...y.styles);return s.direction=t.direction??s.direction,s.title=o,s.accTitle=t.accTitle,s.accDescription=t.accDescription,s.accDescr=t.accDescription.replace(/\n\s+/g,`
`),s.source=e,s.headerSpan=n,s.statements=r,s}var An=class extends Error{constructor(n){super("Invalid JSON token");de(this,"offset",n)}};function QA(e){let t=new Map,n=[],r=[],o=e.length,s=0,a="",i=0,c=()=>{for(;s<o;){let u=e.charCodeAt(s);if(u!==32&&u!==9&&u!==10&&u!==13)return;s++}},l=u=>{s++;let m="";for(;s<o;){let h=s,b=e[s++];if(b==='"')return m;if(b.charCodeAt(0)<32)throw new An(h);if(b!=="\\"){u&&(m+=b);continue}let x=s,E=e[s++],w;if(E==='"'||E==="\\"||E==="/")w=E;else if(E==="b")w="\b";else if(E==="f")w="\f";else if(E==="n")w=`
`;else if(E==="r")w="\r";else if(E==="t")w="	";else if(E==="u"){let S=e.slice(s,s+4);if(!/^[\dA-Fa-f]{4}$/.test(S))throw new An(s);w=String.fromCharCode(parseInt(S,16)),s+=4}else throw new An(x);u&&(m+=w)}throw new An(s)},f=u=>{for(let m=0;m<u.length;m++)if(e[s+m]!==u[m])throw new An(s+m);s+=u.length},p=()=>{if(e.charCodeAt(s)===45&&s++,e.charCodeAt(s)===48)s++;else if(ft(e.charCodeAt(s)))for(;ft(e.charCodeAt(s));)s++;else throw new An(s);if(e.charCodeAt(s)===46){if(s++,!ft(e.charCodeAt(s)))throw new An(s);for(;ft(e.charCodeAt(s));)s++}if((e.charCodeAt(s)|32)===101){if(s++,(e.charCodeAt(s)===43||e.charCodeAt(s)===45)&&s++,!ft(e.charCodeAt(s)))throw new An(s);for(;ft(e.charCodeAt(s));)s++}};for(c();;)if(i===0){c();let u=e.charCodeAt(s);if(i=2,u===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}),i=1)}else if(u===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",i=0);else if(u===34)l(!1);else if(u===116)f("true");else if(u===102)f("false");else if(u===110)f("null");else if(u===45||ft(u))p();else throw new An(s)}else if(i===1){let u=r[r.length-1];if(e.charCodeAt(s)!==34)throw new An(s);let m=l(!0),h=u.ranges.get(m);if(h===void 0)u.keys.push(m);else for(let b=h[0];b<h[1];b++)t.delete(n[b]);if(u.key=m,u.from=n.length,c(),e.charCodeAt(s)!==58)throw new An(s);s++,a=`${u.pointer}/${m.replaceAll("~","~0").replaceAll("/","~1")}`,i=0}else{let u=r[r.length-1];if(u===void 0)break;u.object?u.ranges.set(u.key,[u.from,n.length]):u.index++,c();let m=e.charCodeAt(s);if(m===(u.object?125:93))s++,r.pop();else{if(m!==44)throw new An(s);s++,c(),a=`${u.pointer}/${u.index}`,i=u.object?1:0}}if(c(),s!==o)throw new An(s);return t}function mp(e,t,n,r){let o=Math.min(Math.max(t,0),e.length);for(let s=0;s<o;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 II(e,t,n,r){let o=/\bposition (\d+)\b/.exec(e);if(o)return mp(t,parseInt(o[1],10),n,r);let s=/\bline (\d+) column (\d+)\b/.exec(e);if(s){let a=parseInt(s[1],10),i=parseInt(s[2],10);return[n+a-1,a===1?r+i-1:i]}if(/unexpected end|end of json input/i.test(e))return mp(t,t.length,n,r)}function ZA(e,t,n){return new ze(`${e} (line ${t}, column ${n})`,"syntax",{type:"usecase",line:t,column:n})}function JA(e,t){let n;try{n=JSON.parse(e)}catch(r){let o=r instanceof Error?r.message:String(r),[s,a]=t(),i=II(o,e,s,a);if(!i){let c=0;try{QA(e)}catch(l){l instanceof An&&(c=l.offset)}i=mp(e,c,s,a)}throw ZA(`Invalid JSON: ${o}`,i[0],i[1])}if(typeof n!="object"||n===null||Array.isArray(n)){let[r,o]=t();throw ZA("JSON value must have an object root",r,o)}return{value:n,propertyOrder:QA(e)}}var ax=1,Ap=2,yp=4,cx=8,lx=16,dx=32,ux=64,Hl="DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS",Kl="IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING",kI="PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT",fx="ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE",px="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",ir=new Uint8Array(67);function Js(e,t){for(let n of e.split("|"))if(n==="WORD")for(let r=1;r<=21;r++)ir[r]|=t;else ir[fp.indexOf(n)]|=t}Js(`NEWLINE|COMMENT|${fx}|${Kl}`,ax);Js(`IDENTIFIER|${Hl}`,Ap);Js(px,yp);Js(`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Hl}|NEWLINE|EOF`,cx);Js(`NEWLINE|COMMENT|ACTOR|${Kl}`,lx);Js("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS",dx);Js("NEWLINE|IDENTIFIER|PLAIN_STRING|RBRACE",ux);var LI=new Set(["allowmixing","newpage","package","rectangle","skinparam"]),In="",nt=[],fn=[],wn=[],Ye=0,hx=0,un,Gl,Ul=[],mx=0,gx=0;function en(e){return In.slice(fn[e],wn[e])}function vn(e){return[fn[e],wn[e]]}function zl(e){let[t,n]=qs(In,fn[Ye]);throw new ze(`Error parsing usecase diagram: ${e} at line ${t}, column ${n} [${fn[Ye]},${wn[Ye]})`,"syntax",{type:"usecase",line:t,column:n})}function bx(e){zl(`Expecting token of type --> ${e} <-- but found --> '${en(Ye)}' <--`)}function nn(e){return nt[Ye]!==e&&bx(fp[e]),Ye++}function Hn(e){let t=e.split("|").map((n,r)=>`  ${r+1}. [${n}]`);zl(`Expecting: one of these possible Token sequences:
${t.join(`
`)}
but found: '${en(Ye)}'`)}function ex(){let e=Kl.split("|"),t=e.flatMap(o=>["NEWLINE","IDENTIFIER","PLAIN_STRING","RBRACE"].map(s=>`${o}, METADATA_START, ${s}`)),n=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Hl}|NEWLINE|EOF`.split("|"),r=e.flatMap((o,s)=>(s===0?["LPAREN","LBRACKET",...n]:n).map(a=>`${o}, ${a}`));return[fx,...t,...r,...t].join("|")}function tx(e){return e>=1&&e<=21}function nx(e){return e>=1&&e<=34}function Zs(){hx=wn[Ye-1],nt[Ye]===39?Ye++:nt[Ye]!==0&&Hn("NEWLINE|EOF")}function ta(e){let t=nt[e]===36?2:nt[e]===35?1:0;return[fn[e]+t,wn[e]-t]}function Ep(e){let t=ta(e);return{text:In.slice(t[0],t[1]),type:nt[e]===36?"markdown":"text",span:t}}function yx(e){return e.replace(/\W/g,"_")}function ea(){let e=nt[Ye];if(e===35||e===36)return Ep(Ye++);nx(e)||Hn(kI);let t=Ye;for(;nx(nt[Ye]);)Ye++;let n=[fn[t],wn[Ye-1]];return{text:In.slice(n[0],n[1]),type:"text",span:n}}function Qs(e){return e===21||e===35}function rx(){let e=Ye;Qs(nt[Ye])||Hn("IDENTIFIER|PLAIN_STRING"),Ye++,nn(25);let t=Ye,n=nt[Ye];!Qs(n)&&n!==19&&n!==20&&Hn("IDENTIFIER|PLAIN_STRING|TRUE|FALSE"),Ye++;let r=ta(e),o=ta(t);return{key:In.slice(r[0],r[1]),value:n===19?!0:n===20?!1:In.slice(o[0],o[1]),span:[fn[e],wn[t]],keySpan:r,valueSpan:o}}function $I(){let e=nt[Ye],t=nt[Ye+1],n=nt[Ye+2];return e===24?Qs(t)||t===39&&(n===39||Qs(n)):e!==39?!1:t===24||Qs(t)||t===39&&(n===39||n===24||Qs(n))}function xp(){nn(60);let e=[];for(;nt[Ye]===39;)Ye++;if(Qs(nt[Ye])){for(e.push(rx());$I();){if(nt[Ye]===24)Ye++;else{for(;nt[Ye]===39;)Ye++;nt[Ye]===24&&Ye++}for(;nt[Ye]===39;)Ye++;e.push(rx())}for(nt[Ye]===24&&Ye++;nt[Ye]===39;)Ye++}return nn(62),e}function Sp(e){return e.map(({key:t,span:n,keySpan:r,valueSpan:o})=>({key:t,span:n,keySpan:r,valueSpan:o}))}function _p(e,t){do{Ye++;let n=nn(21);e.push(en(n)),t.push(vn(n))}while(nt[Ye]===24)}function Ex(e){let t=Ye,n=nt[Ye],r={id:"",label:void 0,span:ta(t),generated:n!==21,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(n===21){Ye++,r.id=en(t);let o=nt[Ye];o===65||e&&o===63?(Ye++,r.label=ea(),nn(o===65?66:64),r.shape=o===65?"ellipse":"rect"):r.label=Ep(t)}else n===35||n===36?(Ye++,r.label=Ep(t),r.id=yx(r.label.text)):Hn(Kl);return r}function Yl(e){let t=Ye,n=Ex(!e);if(e&&(n.shape=void 0),nt[Ye]===60&&(n.metadata=xp()),nt[Ye]===48){Ye++;let r=nn(50);nn(49),n.stereotype=en(r).trim(),n.stereotypeSpan=vn(r)}return nt[Ye]===52&&_p(n.classes,n.classSpans),n.explicit=!!(n.shape||n.metadata||n.stereotype),n.nodeSpan=[fn[t],wn[Ye-1]],n}function wp(e,t){return{id:e.id,kind:t,label:e.label,span:e.span,generated:e.generated,parent:Gl,shape:e.shape,metadata:e.metadata,stereotype:e.stereotype,classes:e.classes}}function sx(e,t){return{id:e.id,label:e.label,span:e.span,generated:e.generated,declares:t,classed:e.classes.length>0}}function Rp(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=Sp(e.metadata)),e.classSpans.length>0&&(n.classSpans=e.classSpans),n}function gp(e){if(nt[Ye]<1||nt[Ye]>36)return!1;for(let t=Ye+1;;t++){let n=nt[t];if(n===59||(ir[n]&e)!==0)return!0;if(n<1||n>36)return!1}}function Jo(e){let t=wn[e]-fn[e]-(nt[e]===59?0:1);return Math.max(1,t-1)}function Ax(){let e=Ye,t={type:"association",arrowType:0,minlen:1,target:void 0,span:[0,0]};nt[Ye]===21&&nt[Ye+1]===23&&(t.explicitId=en(Ye),t.explicitIdSpan=vn(Ye),Ye+=2);let n=Ye,r=nt[Ye++];if(r===47)nn(25),nt[Ye]!==17&&nt[Ye]!==18&&Hn("INCLUDE|EXTEND"),t.type=nt[Ye]===17?"include":"extend",t.label={text:t.type,type:"text",span:vn(Ye)},Ye++;else if(r===46)t.type="generalization";else if(r===53)t.minlen=Jo(n);else if(r===54)t.arrowType=1,wn[n]-fn[n]===3&&gp(0)?(t.label=ea(),t.minlen=Jo(nn(59))):t.minlen=Jo(n);else if(r===59)if(t.arrowType=2,wn[n]-fn[n]===2&&gp(dx)){t.label=ea();let o=nt[Ye];o===53?t.arrowType=0:o===55?t.arrowType=3:o===57?t.arrowType=4:o!==59&&Hn("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS"),(t.arrowType===0||t.arrowType===2)&&(t.minlen=Jo(Ye)),Ye++}else t.minlen=Jo(n);else r===55?t.arrowType=3:r===57?t.arrowType=4:r===56||r===58?(t.arrowType=r===56?5:6,gp(0)&&(t.label=ea(),nn(59))):(Ye--,Hn(Hl));return t.target=Yl(!1),t.span=[fn[e],wn[Ye-1]],t}function sr(e){return{kind:e,span:[0,0]}}function xx(e,t,n,r){let o=n.target;o.explicit&&un.elements.push(wp(o,"usecase")),un.relationships.push({source:sx(e,t),target:sx(o,o.explicit),span:n.span,id:n.explicitId,idSpan:n.explicitIdSpan,type:n.type,arrowType:n.arrowType,label:n.label,minlen:n.minlen}),r.push(Rp(o,o.explicit));let s=sr("edge");return s.nodes=r,s.edges=[{id:n.explicitId??`edge-${mx++}`,span:s.span}],n.explicitIdSpan&&(s.edges[0].idSpan=n.explicitIdSpan),n.label&&(s.edges[0].labelSpan=n.label.span),s}function Sx(e){let t=sr("node");return t.nodes=e,t}function _x(e){Ye++;let t=[Yl(!0)],n;if(nt[Ye]===24)do Ye++,t.push(Yl(!0));while(nt[Ye]===24);else e&&(ir[nt[Ye]]&Ap)!==0&&(n=Ax());Zs();for(let o of t)un.elements.push(wp(o,"actor"));let r=t.map(o=>Rp(o,!0));return n?xx(t[0],!0,n,r):Sx(r)}function wx(e){let t=Yl(!1),n=e&&(ir[nt[Ye]]&Ap)!==0?Ax():void 0;Zs(),n||(t.explicit=!0,t.shape??="ellipse"),t.explicit&&un.elements.push(wp(t,"usecase"));let r=[Rp(t,t.explicit)];return n?xx(t,t.explicit,n,r):Sx(r)}function DI(){Ye++;let e=Ex(!0),t={id:e.id,label:e.label,span:e.span,generated:e.generated,classes:e.classes},n=nt[Ye]===60?xp():void 0;nt[Ye]===52&&_p(e.classes,e.classSpans),Zs(),un.boundaries.push(t),Gl=t;let r=[];for(;(ir[nt[Ye]]&lx)!==0;)r.push(Rx(!1));Gl=void 0;let o=nn(4);Zs();let s=sr("group");return s.group=t.id,s.idSpan=t.span,s.titleSpan=t.label.span,s.endSpan=vn(o),s.classSpans=e.classSpans,r.length>0&&(s.children=r),n&&(s.metadata=Sp(n),un.metadata.push({target:t.id,span:t.span,properties:n,statement:s})),s}function ix(){let e=Ye,t=nt[Ye];for(tx(t)||t===27?Ye++:t===59?(Ye++,tx(nt[Ye])||bx("WORD"),Ye++):Hn("WORD|CSS_IDENTIFIER|MARKERLESS_SOLID"),nn(25),(ir[nt[Ye]]&yp)===0&&zl(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
  <[${px.replaceAll("|","] ,[")}]>
but found: '${en(Ye)}'`);(ir[nt[Ye]]&yp)!==0;)Ye++;return In.slice(fn[e],wn[Ye-1]).replaceAll("\\,",",")}function ox(){let e=[ix()];for(;nt[Ye]===24;)Ye++,e.push(ix());return e}function bp(){let e=[nn(21)];for(;nt[Ye]===24;)Ye++,e.push(nn(21));return e}function Wl(e){let t=ta(e);return{id:en(e),span:t,idSpan:t}}function OI(){let e=Ye,t=nt[Ye],n;if(t===41||t===42||t===40){Ye++;let r=en(e);t===40?un.accDescription=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim():t===42?un.accDescription=r.slice(r.indexOf(":")+1).trim():un.accTitle=r.slice(r.indexOf(":")+1).trim(),n=sr(t===41?"accTitle":"accDescr")}else if(t===5){Ye++;let r=nt[Ye];(r<6||r>10)&&Hn("TD|TB|BT|LR|RL"),un.direction=r===6?"TB":en(Ye),Ye++,n=sr("direction")}else{if(t===2)return _x(!0);if(t===3)return DI();if(t===11){Ye++,nn(12);let r=nn(21),o=ea();un.notes.push({target:en(r),span:vn(r),label:o}),n=sr("note"),n.ref=`note-${gx++}`,n.refSpan=o.span,n.nodes=[Wl(r)]}else if(t===43){Ye++;let r=nn(44),o=[],s=[];nt[Ye]===52&&_p(o,s);let a=fn[e]+4;for(;In.charCodeAt(a)===32||In.charCodeAt(a)===9;)a++;let i=a;for(;/\w/.test(In.charAt(i));)i++;let c={id:In.slice(a,i),value:{},propertyOrder:new Map,span:[a,i],classes:o};un.jsons.push(c),Ul.push([c,r]),n=sr("json"),n.nodes=[{id:c.id,span:c.span,idSpan:c.span,defines:!0,classSpans:s}],n.classSpans=s}else if(t===14){Ye++;let r=bp();un.classDefs.push({ids:r.map(en),styles:ox()}),n=sr("classDef"),n.ref=en(r[0]),n.refSpan=vn(r[0])}else if(t===15){Ye++;let r=bp(),o=bp();un.classes.push({targets:r.map(s=>({id:en(s),span:vn(s)})),classes:o.map(en)}),n=sr("classAssign"),n.ref=en(o[0]),n.refSpan=vn(o[0]),n.nodes=r.map(Wl)}else if(t===16){Ye++;let r=nn(21);un.styles.push({target:en(r),span:vn(r),styles:ox()}),n=sr("style"),n.nodes=[Wl(r)]}else{let r=nt[Ye+1];if(r===60){(ir[nt[Ye+2]]&ux)===0&&Hn(ex()),Ye++;let o=Wl(e);t!==21&&(o.id=yx(In.slice(o.span[0],o.span[1])));let s=xp();n=sr("metadata"),n.nodes=[o],n.metadata=Sp(s),un.metadata.push({target:o.id,span:o.span,properties:s,statement:n})}else return(!((ir[r]&cx)!==0||t===21&&(r===65||r===63))||t===21&&LI.has(en(e).toLowerCase()))&&Hn(ex()),wx(!0)}}return Zs(),n}function Rx(e){let t=Ye,n=nt[Ye];if(n===39)return Ye++,{kind:"blank",span:vn(t)};if(n===38)return Ye++,Zs(),{kind:"comment",span:vn(t)};let r=e?OI():n===2?_x(!1):wx(!1);if(r.span=[fn[t],hx],r.edges)for(let o of r.edges)o.span=r.span;return r}function Tx(e,t){In=e,{types:nt,starts:fn,ends:wn}=VA(e),Ye=0,un=XA(),Gl=void 0,Ul=[],mx=0,gx=0;try{let n=nn(1);Zs();let r=[];for(;(ir[nt[Ye]]&ax)!==0;)r.push(Rx(!0));nt[Ye]!==0&&zl(`Redundant input, expecting EOF but found: ${en(Ye)}`);for(let[o,s]of Ul){let a=JA(en(s),()=>qs(e,fn[s]));o.value=a.value,o.propertyOrder=a.propertyOrder}return qA(e,un,vn(n),r,t)}finally{In="",nt=fn=wn=Ul=[]}}var vI={normal:"usecaseActor",hollow:"usecaseActorHollow",awesome:"usecaseActorAwesome",icon:"usecaseActorIcon"},Tp=[["none","arrow_point"],["arrow_point","none"],["none","none"],["none","arrow_circle"],["none","arrow_cross"],["arrow_circle","none"],["arrow_cross","none"]];function Cx(e){return typeof e=="string"?e:e===null?"null":String(e)}function PI(e){let t=[],n=[[e.value,"",""]],r=[];for(;n.length>0;){let[o,s,a]=n.pop();if(r.length=0,Array.isArray(o))o.length===0?t.push({key:s,accessibleKey:s,value:"[]"}):o.every(i=>i===null||typeof i!="object")?o.forEach((i,c)=>t.push({key:c===0?s:"",accessibleKey:s,value:Cx(i)})):o.forEach((i,c)=>r.push([i,`${s}[${c}]`,`${a}/${c}`]));else if(o!==null&&typeof o=="object"){let i=o,c=e.propertyOrder.get(a)??Object.keys(i);c.length===0&&t.push({key:s,accessibleKey:s,value:"{}"});for(let l of c)r.push([Object.prototype.hasOwnProperty.call(i,l)?i[l]:void 0,s?`${s}.${l}`:l,`${a}/${l.replaceAll("~","~0").replaceAll("/","~1")}`])}else t.push({key:s,accessibleKey:s,value:Cx(o)});for(let i=r.length-1;i>=0;i--)n.push(r[i])}return t}function na(...e){return e.filter(Boolean).join(" ")}function BI(e){return e.type==="generalization"?["none","extension"]:e.type!=="association"?Tp[0]:Tp[e.arrowType]??Tp[2]}function Nx(e){let t=[],n=[],r=o=>{let s=new Map;for(let a of["default",...o]){let i=e.classDefs.get(a);if(i)for(let c of i.styles){let l=c.trim(),f=l.indexOf(":"),p=(f===-1?l:l.slice(0,f)).trim();p&&s.set(p,l)}}return[...s.values()]};for(let o of e.actors.values())t.push({id:o.id,label:o.label,labelType:o.labelType,shape:vI[o.type],isGroup:!1,padding:10,cssClasses:na("default","usecase-actor",`usecase-actor-${o.type}`,o.business&&"usecase-business",...o.classes),cssStyles:[...o.styles],cssCompiledStyles:r(o.classes),actorType:o.type,business:o.business,icon:o.icon||void 0,stereotype:o.stereotype||void 0,parentId:o.parentId||void 0});for(let o of e.useCases.values()){let s=o.shape==="ellipse";t.push({id:o.id,label:o.label,labelType:o.labelType,shape:s?o.business?"usecaseBusiness":"usecaseEllipse":"rect",isGroup:!1,padding:s?20:10,cssClasses:na("default","usecase-element",`usecase-${o.shape}`,o.business&&"usecase-business",...o.classes),cssStyles:[...o.styles],cssCompiledStyles:r(o.classes),business:o.business,stereotype:o.stereotype||void 0,parentId:o.parentId||void 0})}for(let o of e.notes.values())t.push({id:o.id,label:o.label,labelType:o.labelType,shape:"note",isGroup:!1,padding:10,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:r([]),noteTarget:o.target});for(let o of e.jsonNodes.values())t.push({id:o.id,label:o.id,labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,cssClasses:na("default","usecase-json-table",...o.classes),cssStyles:[...o.styles],cssCompiledStyles:r(o.classes),jsonRows:PI(o)});for(let o of e.systemBoundaries.values())t.push({id:o.id,label:o.label,labelType:o.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,cssClasses:na("default","system-boundary",`system-boundary-${o.type}`,...o.classes),cssStyles:[...o.styles],cssCompiledStyles:r(o.classes),boundaryType:o.type});for(let o of e.relationships){let s=o.type==="include"||o.type==="extend",[a,i]=BI(o),c=o.animate||o.animation!==void 0,l={id:o.id,start:o.source,end:o.target,relationshipType:o.type,pattern:s?"dotted":"solid",arrowTypeStart:a,arrowTypeEnd:i,classes:na("default","relationship",`relationship-${o.type}`,...o.classes,c&&`edge-animation-${o.animation??"fast"}`),style:[...o.styles],cssCompiledStyles:r(o.classes),animate:o.animate,animation:o.animation,minlen:o.minlen,explicitId:o.explicitId,internal:!1};s?(l.label=o.type,l.labelType="text"):o.type==="association"&&(o.label&&(l.label=o.label),o.labelType&&(l.labelType=o.labelType)),n.push(l)}for(let o of e.notes.values())n.push({id:`${o.id}-edge`,start:o.id,end:o.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 FI=32,WI=16,UI=72,Vl=20,Cp=26,kp=40,sa=60,Mx=6,Np=6,ra=10,Mp=8,jl=9,ql=12,GI=14,ia=' fill="var(--_s)" stroke="var(--_b)"';function Ix(e,t,n){let r=e.usecase?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function YI(e){return e.replace(/[&<>\\]/g,t=>`&#${t.charCodeAt(0)};`)}function ps(e,t,n,r,o,s=0){return We(e&&!t?YI(e):e,t,n,r,o,s)}function Ip(e,t,n,r){let o=n===1||n===2?1:-1,s=n===1||n===3,a=(s?e.w:e.h)/2,i=0;if(e.kind===0)s?(a=kp/2+3,i=(sa-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+o*a,t.y+i+r]:[t.x+r,t.y+o*a]}function $x(e,t){let n=t===1||t===3;if(e.kind===0)return n?sa*.5:kp*.6;let r=n?e.h:e.w;return e.kind===1?r*.6:r-16}function HI(e,t,n){let r=new Map,o=(s,a,i,c)=>{let l=t[s];if(l.isGroup)return;let f=a[i]-l.x,p=a[i+1]-l.y,u;if(Math.abs(Math.abs(p)-l.h/2)<.5)u=p<0?0:2;else if(Math.abs(Math.abs(f)-l.w/2)<.5)u=f<0?3:1;else return;let m=s*4+u,h={route:a,at:i,toward:a[c+(u&1?1:0)]},b=r.get(m);b?b.push(h):r.set(m,[h])};for(let s of e){let a=s.route.length-3;s.src===s.dst||a<3||(o(s.src,s.route,0,3),o(s.dst,s.route,a,a-3))}for(let[s,a]of r){let i=s>>2,c=s&3,l=n[i],f=a.length>1?Math.min(GI,$x(l,c)/(a.length-1)):0;a.sort((p,u)=>p.toward-u.toward);for(let p=0;p<a.length;p++){let[u,m]=Ip(l,t[i],c,(p-(a.length-1)/2)*f);a[p].route[a[p].at]=u,a[p].route[a[p].at+1]=m}}}function KI(e,t,n,r,o){let s=e-n*ql,a=t-r*ql,i=ql*.5;return`<path class="pele-marker" d="M${d(e)},${d(t)}L${d(s-r*i)},${d(a+n*i)}L${d(s+r*i)},${d(a-n*i)}Z" fill="var(--_bg)" stroke="${o}" stroke-linejoin="round"/>`}function Xl(e){return e==="extension"?ql:mt(e)}function kx(e,t,n,r,o,s){return e==="extension"?KI(t,n,r,o,s):Et(e,t,n,r,o,s)}function zI(e,t){let n=e.node,r=e.style.shape,o=` fill="none" stroke="var(--_b)"${e.style.line}`,s=-21,a=9,i;return n.actorType==="hollow"?(a=8,i=`<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"?i=`<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,i=`<rect x="-22" y="-26" width="44" height="44"${pt(ia+r)}/><svg class="pele-icon" data-icon="${Fe(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>`):i=`<circle cy="-21" r="9"${ia}${r}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${o}/>`,n.business&&(i+=`<path class="pele-business" d="M${d(.12*a)},${d(s+.99*a)}L${d(.92*a)},${d(s-.39*a)}"${o}/>`),i}function Dx(e,t,n){return Tn(e.direction)?$t(n,r=>Lx(e,t,n,r)):Lx(e,t,n,!1)}function Lx(e,t,n,r){let o=Nx(e),s=n.fontSize??16,a=Math.round(s*.875),i=Math.round(s*.8125),c=n.measurer??et(n.fontFamily),l=n.padding??8,f=n.icons,p=r?"TB":rn(e.direction),u=p==="LR"||p==="RL",m=new Map,h=[],b=[];o.nodes.forEach((g,_)=>m.set(g.id,_));for(let g of o.nodes){let _=St(g.cssStyles.length>0?g.cssCompiledStyles.concat(g.cssStyles):g.cssCompiledStyles),y=(_.bold?1:0)|(_.italic?2:0),R=_.fontSize??s,A=g.labelType==="markdown",N=ps(g.stereotype&&`«${g.stereotype}»`,!1,c,i,200,y),$={node:g,kind:2,style:_,label:N,stereotype:N,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},U;if(g.isGroup){$.kind=4,$.label=ps(g.label,A,c,R,4e3,y);let j=$.label.height;U=Pt(0,0),U.isGroup=!0,U.padX=Vl,U.padBottom=Vl,U.padTop=g.boundaryType==="package"?j+2*Np+16:j>0?j+16:Vl,U.minW=$.label.width+2*Vl}else{if(g.jsonRows){$.kind=3,$.label=ps(g.label,!1,c,R,4e3,y|1);let j=0;for(let v of g.jsonRows){let k=ps(v.key,!1,c,a,4e3,y),F=ps(v.value,!1,c,a,260,y);$.rows.push([k,F]),$.keyW=Math.max($.keyW,k.width),j=Math.max(j,F.width),$.h+=Math.max(k.height,F.height,Math.round(a*1.5))+Mp}$.keyW>0&&($.keyW+=2*ra),$.headH=Math.max($.label.height,Math.round(R*1.5))+Mp,$.w=Math.max($.label.width+2*ra,$.rows.length>0?$.keyW+j+2*ra:0,72),$.h+=$.headH}else if(g.actorType)$.kind=0,$.label=ps(g.label,A,c,R,140,y),$.w=Math.max(kp,$.label.width,N.width),$.h=sa+Mx+N.height+$.label.height;else{$.label=ps(g.label,A,c,g.shape==="note"?a:R,180,y);let j=Math.max($.label.width,N.width),v=$.label.height+N.height;g.shape==="usecaseEllipse"||g.shape==="usecaseBusiness"?($.kind=1,$.w=Math.max(j+2*g.padding+(g.business?16:4),88),$.h=Math.max(v+28,48)):g.shape==="note"?($.w=j+2*g.padding+6,$.h=v+18):($.w=Math.max(j+2*g.padding+12,80),$.h=Math.max(v+24,44))}U=Pt($.w,$.h)}U.seq=h.length,h.push($),b.push(U)}o.nodes.forEach((g,_)=>{b[_].parent=g.parentId!==void 0?m.get(g.parentId)??-1:-1});let x=[],E=[],w=[];for(let g of o.edges){let _=m.get(g.start),y=m.get(g.end);if(_===void 0||y===void 0)continue;let R=g.relationshipType==="include"||g.relationshipType==="extend",A=ps(R?`«${g.label}»`:g.label,g.labelType==="markdown",c,a,200);_===y&&(h[_].loops++,u?b[_].h+=2*(Cp+(A.height>0?A.height+8:0)):b[_].w+=2*(Cp+(A.width>0?A.width+12:0))),w.push(g),E.push(A),x.push({src:_,dst:y,minlen:g.minlen,labelW:A.width>0?A.width+12:0,labelH:A.height>0?A.height+4:0,route:[],labelX:0,labelY:0})}let S=Rn(b,x,p,{nodeSep:Ix(t,"nodeSpacing",FI),edgeSep:WI,rankSep:Ix(t,"rankSpacing",UI),portSep:20}),O=hn(e.title,c,s,4e3),D=O.height>0?O.height+12:0,L=Math.max(S.width,O.width),B=l+(L-S.width)/2,W=l+D;Gr(b,x,B,W);let Y=Math.ceil(L+2*l),I=Math.ceil(S.height+D+2*l),X=new Map;for(let g of x)qn(X,g.route);HI(x,b,h);let ee="",K="";for(let g=0;g<h.length;g++){let _=h[g],y=b[g],R=_.node,A=Rt(R.cssClasses.replace(/^default\s?/,"")),N=Fe(R.id),$=_.style.text,U=_.style.shape,j=_.w,v=_.h;if(_.kind===4){let H=y.x-y.w/2,G=y.y-y.h/2,se=` fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${U}`,q=` class="pele-cluster-label" fill="var(--_m)"${$}`,P;if(R.boundaryType==="package"){let V=Math.min(_.label.width+2*Np+8,y.w),ne=_.label.height+2*Np;P=`<rect class="pele-boundary-tab" x="${d(H)}" y="${d(G)}" width="${d(V)}" height="${d(ne)}"${se}/><rect x="${d(H)}" y="${d(G+ne)}" width="${d(y.w)}" height="${d(y.h-ne)}"${se}/>`+De(_.label,H+V/2,G+ne/2,q,f)}else P=`<rect x="${d(H)}" y="${d(G)}" width="${d(y.w)}" height="${d(y.h)}"${pt(se)}/>`+De(_.label,VI(y,_.label.width,X),G+8+_.label.height/2,q,f);ee+=`<g class="pele-cluster pele-boundary${A}" data-id="${N}">${P}</g>`;continue}let k,F;if(_.kind===0){F="pele-actor";let H=-v/2,G=H+sa+Mx+_.stereotype.height/2;k=`<g class="pele-actor-figure" transform="translate(0,${d(H+sa/2)})">${zI(_,f)}</g>`+De(_.stereotype,0,G,` class="pele-stereotype" font-size="${i}" fill="var(--_m)"`,f)+De(_.label,0,v/2-_.label.height/2,` class="pele-label"${$}`,f)}else if(_.kind===3){F="pele-json";let H=-j/2,G=-v/2+_.headH,se="",q=`M${d(H)},${d(G)}H${d(H+j)}`;_.keyW>0&&(q+=`M${d(H+_.keyW)},${d(G)}V${d(v/2)}`);for(let[P,V]of _.rows){let ne=Math.max(P.height,V.height,Math.round(a*1.5))+Mp;se+=De(P,H+ra+P.width/2,G+ne/2,' class="pele-json-key" fill="var(--_m)"',f)+jI(V,H+_.keyW+ra,G+ne/2,` class="pele-json-value"${$}`,f),G+=ne}k=`<rect x="${d(H)}" y="${d(-v/2)}" width="${d(j)}" height="${d(v)}"${pt(ia+U)}/><path class="pele-json-lines" d="${q}" fill="none" stroke="var(--_b)"${_.style.line}/>`+De(_.label,0,-v/2+_.headH/2,` class="pele-label" font-weight="var(--_hw)"${$}`,f)+`<g font-size="${a}">${se}</g>`}else{let H=_.stereotype.height/2,G;if(_.kind===1){if(F="pele-usecase",G=`<ellipse rx="${d(j/2)}" ry="${d(v/2)}"${ia}${U}/>`,R.business){let se=j/2-15,q=j/2-5,P=V=>v/2*Math.sqrt(1-(V/(j/2))**2);G+=`<path class="pele-business" d="M${d(se)},${d(P(se))}L${d(q)},${d(-P(q))}" fill="none" stroke="var(--_b)"${_.style.line}/>`}}else if(R.shape==="note"){F="pele-note";let se=j/2,q=v/2;G=`<path d="M${d(-se)},${d(-q)}H${d(se-jl)}L${d(se)},${d(jl-q)}V${d(q)}H${d(-se)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${U}/><path d="M${d(se-jl)},${d(-q)}V${d(jl-q)}H${d(se)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${_.style.line}/>`}else F="pele-usecase",G=`<rect x="${d(-j/2)}" y="${d(-v/2)}" width="${d(j)}" height="${d(v)}"${pt(ia+U)}/>`;k=G+De(_.stereotype,0,-_.label.height/2,` class="pele-stereotype" font-size="${i}" fill="var(--_m)"`,f)+De(_.label,0,H,` class="pele-label"${R.shape==="note"?` font-size="${a}"`:""}${$}`,f)}K+=`<g class="pele-node ${F}${A}" data-id="${N}" transform="translate(${d(y.x)},${d(y.y)})">${k}</g>`}let z="",C="",M=new Map;for(let g=0;g<x.length;g++){let _=x[g],y=w[g],R=E[g],A=y.style.length>0||y.cssCompiledStyles.length>0?St(y.cssCompiledStyles.concat(y.style)):void 0,N=y.arrowTypeStart,$=y.arrowTypeEnd,U;if(_.src===_.dst){let k=b[_.src],F=h[_.src],H=M.get(_.src)??0;M.set(_.src,H+1);let G=u?2:1,se=Math.min($x(F,G)/2,8+H*6),q=Cp+H*8,[P,V]=Ip(F,k,G,-se),[ne,ae]=Ip(F,k,G,se),Z=Math.hypot(q,se)||1,Q=u?se/Z:q/Z,ie=u?q/Z:se/Z,me=Xl(N),re=Xl($),te=(be,ye,Re,Le)=>u?`${d(be+Re*se*(Le?1:0))},${d(ye+Le)}`:`${d(be+Le)},${d(ye+Re*se*(Le?1:0))}`,he=u?P-Q*me:P+Q*me,oe=u?V+ie*me:V-ie*me,ge=ne+Q*re,Ee=ae+ie*re;U={d:`M${d(he)},${d(oe)}C${te(P,V,-1,q)} ${te(ne,ae,1,q)} ${d(ge)},${d(Ee)}`,sx:P,sy:V,sdx:u?Q:-Q,sdy:u?-ie:ie,ex:ne,ey:ae,edx:-Q,edy:-ie},u?(_.labelX=k.x,_.labelY=Math.max(V,ae)+q*.75+6+R.height/2):(_.labelX=Math.max(P,ne)+q*.75+8+R.width/2,_.labelY=k.y)}else{if(_.route.length<6)continue;U=xn(_.route,void 0,Xl(N),Xl($))}let j=A?.stroke?je(A.stroke):"var(--_l)",v=y.internal?"2 3":y.pattern==="dotted"?"5 4":y.animate?"9 5":"";if(z+=`<g class="pele-edge pele-${y.relationshipType}${Rt(y.classes.replace(/^default relationship relationship-\S+\s?/,""))}" data-id="${Fe(y.id)}"${A?.line??""}><path d="${U.d}"${v?` stroke-dasharray="${v}"`:""}/>`+kx(N,U.sx,U.sy,U.sdx,U.sdy,j)+kx($,U.ex,U.ey,U.edx,U.edy,j)+"</g>",R.width>0){let k=_.labelX,F=_.labelY,H=y.relationshipType==="include"||y.relationshipType==="extend";C+=sn(y.id,R,k,F,(H?' fill="var(--_m)"':"")+(A?.text??""),f)}}return{svg:Ze("usecase",Y,I,s,n,e,De(O,Y/2,l+O.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ee?`<g class="pele-clusters">${ee}</g>`:"")+(z?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${z}</g>`:"")+(C?`<g class="pele-edge-labels" font-size="${a}">${C}</g>`:"")+`<g class="pele-nodes">${K}</g>`),width:Y,height:I,links:[]}}function VI(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(t===0||r===void 0)return e.x;let o=e.x-e.w/2+6,s=e.x+e.w/2-6,a=r.filter(u=>u>o&&u<s).sort((u,m)=>u-m);a.push(s);let i=t/2+6,c=e.x,l=1/0,f=0,p=o;for(let u of a){if(u-p>=2*i){let m=Math.min(Math.max(e.x,p+i),u-i);Math.abs(m-e.x)<l&&(l=Math.abs(m-e.x),c=m)}else l===1/0&&u-p>f&&(f=u-p,c=(p+u)/2);p=u}return c}function jI(e,t,n,r,o){if(e.lines.length<2)return De(e,t+e.width/2,n,r,o);let s="";for(let a=0;a<e.lines.length;a++)s+=De(dr(e,a),t+e.widths[a]/2,n-e.height/2+lr(e,a),r,o);return s}var Ox={type:"usecase",math:!0,parse:(e,t,n)=>Tx(e,n),render:Dx};function hs(e){let t=e.trim();return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function Lp(e){return e.map(hs).sort()}var Ql=class{constructor(){de(this,"type","venn");de(this,"title");de(this,"subsets",[]);de(this,"textNodes",[]);de(this,"styles",[]);de(this,"known",new Set);de(this,"current");de(this,"indent",!1)}setDiagramTitle(t){this.title=t}addSubsetData(t,n,r){let o=Lp(t);this.current=o,o.length===1&&this.known.add(o[0]),this.subsets.push({sets:o,size:r??10/t.length**2,label:n?hs(n):void 0})}addTextData(t,n,r){this.textNodes.push({sets:Lp(t),id:hs(n),label:r?hs(r):void 0})}addStyleData(t,n){let r=new Map;for(let[o,s]of n)r.set(o,s&&hs(s));this.styles.push({targets:Lp(t),styles:r})}validateUnionIdentifiers(t){let n=t.map(hs).filter(r=>!this.known.has(r));if(n.length>0)throw new ze(`unknown set identifier: ${n.join(", ")}`,"semantic",{type:"venn"})}getCurrentSets(){return this.current}getIndentMode(){return this.indent}setIndentMode(t){this.indent=t}};var $p=["$end","INVALID","EOF","NEWLINE","VENN","TITLE","SET","UNION","TEXT","INDENT_TEXT","STYLE","BRACKET_LABEL","NUMERIC","HEXCOLOR","RGBCOLOR","RGBACOLOR","IDENTIFIER","STRING","COMMA","COLON"],XI=[["venn-beta",4],["set",6],["union",7],["text",8],["style",10]],Zl=class{constructor(t,n){de(this,"src",t);de(this,"host",n);de(this,"text","");de(this,"start",0);de(this,"at",0);de(this,"lineStart",!1);de(this,"ended",!1)}word(t,n){let r=this.src;for(let o=0;o<n.length;o++){let s=r.charCodeAt(t+o),a=n.charCodeAt(o);if(s!==a&&(s+32!==a||s<65||s>90))return!1}return!0}keyword(t,n){return this.word(t,n)&&!Qe(this.src.charCodeAt(t+n.length))}color(t,n){let r=this.src,o=t+1;for(let s=0;s<n;s++){for(;He(r.charCodeAt(o));)o++;let a=o;for(;ft(r.charCodeAt(o))||r.charCodeAt(o)===46;)o++;if(o===a)return-1;for(;He(r.charCodeAt(o));)o++;if(r.charCodeAt(o)!==(s===n-1?41:44))return-1;o++}return o}lineEnd(t){let n=this.src.indexOf(`
`,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 o=t.charCodeAt(r);if(o===37&&t.charCodeAt(r+1)===37&&t.charCodeAt(r+2)!==123||o!==125&&t.charCodeAt(r+1)===37&&t.charCodeAt(r+2)===37){this.at=this.lineEnd(r+2);continue}if(this.lineStart){if(o===32||o===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}o!==10&&o!==13&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(o===10||o===13){for(r++;t.charCodeAt(r)===10||t.charCodeAt(r)===13;)r++;return this.lineStart=!0,this.token(3,r)}if(o===37&&t.charCodeAt(r+1)===37){this.at=this.lineEnd(r);continue}if(o===32||o===9){for(r++;t.charCodeAt(r)===32||t.charCodeAt(r)===9;)r++;this.at=r;continue}if((o|32)>=97&&(o|32)<=122||o===95){if(this.word(r,"title")&&He(t.charCodeAt(r+5))){let s=r+6;for(;s<n;){let a=t.charCodeAt(s);if(a===35||a===10||a===59)break;s++}if(s>r+6)return this.token(5,s)}for(let[s,a]of XI)if(this.keyword(r,s))return this.token(a,r+s.length);if(this.word(r,"rgb")){let s=(t.charCodeAt(r+3)|32)===97,a=r+(s?4:3),i=t.charCodeAt(a)===40?this.color(a,s?4:3):-1;if(i!==-1)return this.token(s?15:14,i)}for(r++;Qe(t.charCodeAt(r))||t.charCodeAt(r)===45;)r++;return this.token(16,r)}if(o===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(ft(o)||o===46||o===43||o===45){(o===43||o===45)&&r++;let s=r;for(;ft(t.charCodeAt(r));)r++;if(r>s){if(t.charCodeAt(r)===46&&ft(t.charCodeAt(r+1)))for(r+=2;ft(t.charCodeAt(r));)r++}else if(t.charCodeAt(r)===46&&ft(t.charCodeAt(r+1)))for(r+=2;ft(t.charCodeAt(r));)r++;else return 1;return this.token(12,r)}if(o===35){let s=r+1;for(;s<r+9&&fa(t.charCodeAt(s));)s++;return s>=r+4?this.token(13,s):1}if(o===34){let s=t.indexOf('"',r+1);return s===-1?1:this.token(17,s+1)}return o===44?this.token(18,r+1):o===58?this.token(19,r+1):1}}token(t,n){return this.text=this.src.slice(this.at,n),this.at=n,t}};var qI="'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'",QI="'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'";function vx(e,t){let n=new Zl(e,t),r=-1,o=()=>r===-1?r=n.next():r,s=m=>{throw o()===1?st("venn",e,n.start,"",!0):st("venn",e,n.start,`Expecting ${m}, got '${$p[r]}'`)},a=()=>(r=-1,n.text),i=m=>(o()!==m&&s(`'${$p[m]}'`),a()),c=()=>(o()!==16&&r!==17&&s("'IDENTIFIER', 'STRING'"),a()),l=()=>{let m=[c()];for(;o()===18;)a(),m.push(c());return m},f=(m,h)=>{let b=o()===11?a():void 0,x;if(o()===19&&(a(),x=parseFloat(i(12))),h){if(m.length<2)throw new ze("union requires multiple identifiers","semantic",{type:"venn"});t.validateUnionIdentifiers(m)}t.addSubsetData(m,b,x),t.setIndentMode(!0)},p=m=>{let h=o();h!==16&&h!==17&&h!==12&&s("'NUMERIC', 'IDENTIFIER', 'STRING'");let b=a(),x=h!==12&&o()===11?a():void 0;t.addTextData(m(),b,x)},u=()=>{let m=l(),h=[];for(;;){let b=i(16);i(19);let x;if(o()===17)x=a();else{let E=[];for(;o()===16||r>=12&&r<=15;)E.push(a());E.length===0&&s(QI),x=E.join(" ")}if(h.push([b,x]),o()!==18)break;a()}t.addStyleData(m,h)};for(;o()===3;)a();for(i(4);;){let m=o();if(m===2)return;if((m<3||m>10||m===4)&&s(qI),a(),m===5)t.setDiagramTitle(n.text.slice(6));else if(m===6)f([c()],!1);else if(m===7)f(l(),!0);else if(m===8){let h=l();p(()=>h)}else m===9?p(()=>{let h=t.getCurrentSets();if(!h)throw new ze("text requires set","semantic",{type:"venn"});return h}):m===10&&u()}}var Jl=Math.PI*2;function ZI(e){let t=new Set,n=new Map;for(let o of e)t.add(JSON.stringify([...o.sets].sort())),o.sets.length===1&&n.set(o.sets[0],o.size);let r=[];for(let o of e){if(o.sets.length<3)continue;let s=[...o.sets].sort();for(let a=0;a<s.length-1;a++)for(let i=a+1;i<s.length;i++){let c=[s[a],s[i]],l=JSON.stringify(c);if(t.has(l))continue;t.add(l);let f=n.get(c[0]),p=n.get(c[1]);r.push({sets:c,size:f!==void 0&&p!==void 0?Math.min(f,p)/4:2.5,label:""})}}return r.length>0?[...e,...r]:e}function JI(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 o=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 o+s-a}function ek(e,t,n){let r=Math.abs(e-t),o=e+t;if(!(n>0))return o;if(n>=Math.PI*Math.min(e,t)**2)return r;for(let s=0;s<48;s++){let a=(r+o)/2;JI(e,t,a)>n?r=a:o=a}return(r+o)/2}function Px(e,t,n,r,o,s){let a=1/0;for(let i of t){let c=e[i],l=r-c.x,f=o-c.y,p=c.r-Math.sqrt(l*l+f*f);if(p<a){if(p<s)return p;a=p}}for(let i of n){let c=e[i],l=r-c.x,f=o-c.y,p=Math.sqrt(l*l+f*f)-c.r;if(p<a){if(p<s)return p;a=p}}return a}function ed(e,t,n){let r=0,o=0,s=e[t[0]];for(let h of t){let b=e[h];r+=b.x/t.length,o+=b.y/t.length,b.r<s.r&&(s=b)}let a=s.r,i=r,c=o,l=Px(e,t,n,i,c,-1/0),f=0,p=(h,b)=>{let x=Px(e,t,n,h,b,l-a*1e-9);if(!(x>l-a*1e-9))return!1;let E=Math.hypot(h-r,b-o);return x>l+a*1e-9||E<f-a*1e-9?(l=x,f=E,i=h,c=b,!0):!1},u=10;for(let h=-u;h<=u;h++)for(let b=-u;b<=u;b++)b*b+h*h<=u*u&&p(s.x+b*a/u,s.y+h*a/u);let m=a/u;for(let h=0;h<40&&m>a*1e-6;h++){let b=!1;for(let x=0;x<8;x++){let E=x*Jl/8;p(i+Math.cos(E)*m,c+Math.sin(E)*m)&&(b=!0)}b||(m/=2)}return{x:i,y:c,margin:l}}function Bx(e){let t=new Map;for(let x of e)for(let E of x.sets)t.has(E)||t.set(E,10);for(let x of e)x.sets.length===1&&t.set(x.sets[0],x.size);let n=new Map,r=[],o=0;for(let x of t.values())Number.isFinite(x)&&x>o&&(o=x);o===0&&(o=10);let s=Math.sqrt(o/Math.PI);for(let[x,E]of t){n.set(x,r.length);let w=Number.isFinite(E)&&E>0?Math.sqrt(E/Math.PI):0;r.push({id:x,x:0,y:0,r:Math.max(w,s*.3)})}let a=r.length;if(a<2)return r;let i=new Map;for(let x of ZI(e)){if(x.sets.length!==2)continue;let E=n.get(x.sets[0]),w=n.get(x.sets[1]);E!==w&&i.set(Math.min(E,w)*a+Math.max(E,w),x.size)}let c=new Map;for(let[x,E]of i)c.set(x,ek(r[Math.floor(x/a)].r,r[x%a].r,E));let l=s*.15,f=(x,E)=>c.get(x*a+E)??r[x].r+r[E].r+l;if(a===2)return r[1].x=f(0,1),r;if(a===3){let x=f(0,1),E=f(0,2),w=f(1,2),S=e.some(O=>new Set(O.sets).size===3);for(let O=0;O<40;O++){let D=x>0?(x*x+E*E-w*w)/(2*x):0;if(r[1].x=x,r[2].x=Math.max(-E,Math.min(E,D)),r[2].y=Math.sqrt(Math.max(E*E-D*D,0)),!S||ed(r,[0,1,2],[]).margin>s*.12)break;x*=.94,E*=.94,w*=.94}return r}let p=0;for(let x of r)p+=2*x.r+l;let u=Math.min(300,Math.floor(3e6/(a*a)));if(a<=64){let x=p/Jl;r.forEach((E,w)=>{let S=w*Jl/a-Math.PI/2;E.x=Math.cos(S)*x,E.y=Math.sin(S)*x})}else{let x=Math.ceil(Math.sqrt(a)),E=2*s+l;r.forEach((w,S)=>{w.x=S%x*E,w.y=Math.floor(S/x)*E})}let m=new Float64Array(a),h=new Float64Array(a),b=new Int32Array(a);for(let x=0;x<u;x++){m.fill(0),h.fill(0),b.fill(0);for(let E=0;E<a;E++)for(let w=E+1;w<a;w++){let S=c.get(E*a+w),O=r[E].r+r[w].r+l,D=r[w].x-r[E].x,L=r[w].y-r[E].y,B=Math.hypot(D,L);if(S===void 0&&B>=O)continue;B<1e-9&&(D=Math.cos(E+w),L=Math.sin(E+w),B=1);let W=(B-(S??O))/2/B;m[E]+=D*W,h[E]+=L*W,m[w]-=D*W,h[w]-=L*W,b[E]++,b[w]++}for(let E=0;E<a;E++)b[E]!==0&&(r[E].x+=m[E]/b[E],r[E].y+=h[E]/b[E])}return r}function Fx(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,f,p)=>{for(let u of e)if(u!==f&&u!==p&&Math.hypot(c-u.x,l-u.y)>u.r*(1+1e-9))return!1;return!0},o=[];for(let c=0;c<e.length;c++)for(let l=c+1;l<e.length;l++){let f=e[c],p=e[l],u=Math.hypot(p.x-f.x,p.y-f.y);if(u>=f.r+p.r||u<=Math.abs(f.r-p.r)||u===0)continue;let m=(f.r*f.r-p.r*p.r+u*u)/(2*u),h=Math.sqrt(Math.max(f.r*f.r-m*m,0)),b=f.x+(p.x-f.x)*m/u,x=f.y+(p.y-f.y)*m/u;for(let E of[1,-1]){let w=b+E*h*(p.y-f.y)/u,S=x-E*h*(p.x-f.x)/u;r(w,S,f,p)&&o.push({x:w,y:S,a:f,b:p})}}if(o.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 o)s+=c.x/o.length,a+=c.y/o.length;o.sort((c,l)=>Math.atan2(c.y-a,c.x-s)-Math.atan2(l.y-a,l.x-s));let i="";for(let c=0;c<o.length;c++){let l=o[c],f=o[(c+1)%o.length];c===0&&(i=`M${t(l.x)},${t(l.y)}`);let p,u=0,m=1/0;for(let h of[l.a,l.b]){if(h!==f.a&&h!==f.b)continue;let b=Math.atan2(l.y-h.y,l.x-h.x),x=Math.atan2(f.y-h.y,f.x-h.x)-b;x<=0&&(x+=Jl);let E=h.x+h.r*Math.cos(b+x/2),w=h.y+h.r*Math.sin(b+x/2),S=Math.hypot(E-(l.x+f.x)/2,w-(l.y+f.y)/2);S<m&&(m=S,p=h,u=x>Math.PI?1:0)}p===void 0?i+=`L${t(f.x)},${t(f.y)}`:i+=`A${t(p.r)},${t(p.r)} 0 ${u} 1 ${t(f.x)},${t(f.y)}`}return i+"Z"}var tk=100,nk=1.6,Wx=St([]);function Dp(e){return e.length===1?e[0]:JSON.stringify(e)}function Ux(e,t,n){let r=n.fontSize??16,o=Math.round(r*.875),s=Math.round(r*.8125),a=n.measurer??et(n.fontFamily),i=n.padding??8,c=Bx(e.subsets),l=new Map;c.forEach((g,_)=>l.set(g.id,_));let f=new Map;for(let{targets:g,styles:_}of e.styles){let y=Dp(g),R=f.get(y);R||f.set(y,R=new Map);for(let[A,N]of _)R.set(A,N)}let p=g=>{let _=f.get(g);if(!_)return Wx;let y=[];for(let[R,A]of _)y.push(`${R}:${A}`);return St(y)},u=c.map(()=>[]);for(let g=0;g<c.length;g++)for(let _=g+1;_<c.length;_++)Math.hypot(c[g].x-c[_].x,c[g].y-c[_].y)<c[g].r+c[_].r&&(u[g].push(_),u[_].push(g));let m=new Map;for(let g of e.subsets)m.set(Dp(g.sets),g);let h=new Map;for(let[g,_]of m){let y=[...new Set(_.sets)],R=y.map(F=>l.get(F)),A=new Set(R),N=R[0];for(let F of R)c[F].r<c[N].r&&(N=F);let $=p(g),U=_.label??(_.sets.length===1?_.sets[0]:void 0),j=($.bold?1:0)|($.italic?2:0),v=ed(c,R,u[N].filter(F=>!A.has(F)));v.margin<c[N].r*.2&&(v=ed(c,R,[]));let k={sets:y,inside:R,spot:v,lines:[],style:$};if(U){let F=y.length===1?r:o;k.lines.push({id:void 0,raw:U,size:F,base:j,label:We(U,!1,a,F,4e3,j)})}h.set(g,k)}for(let g of e.textNodes){let _=g.label??g.id;h.get(Dp(g.sets))?.lines.push({id:g.id,raw:_,size:s,base:0,label:We(_,!1,a,s,4e3)})}let b=0;for(let g of c)g.r>b&&(b=g.r);let x=b>0?tk/b:1,E=1;for(let g of h.values()){if(g.spot.margin<=0)continue;let _=0,y=0;for(let A of g.lines)_=Math.max(_,A.label.width),y+=A.label.height;let R=Math.hypot(_,y)/2+4;E=Math.max(E,Math.min(R/(g.spot.margin*x),nk))}x*=E;for(let g of h.values()){let _=Math.max(g.spot.margin*x*1.8,72);for(let y of g.lines)y.label.width>_&&(y.label=We(y.raw,!1,a,y.size,_,y.base))}let w=1/0,S=1/0,O=-1/0,D=-1/0;for(let g of c)w=Math.min(w,(g.x-g.r)*x),S=Math.min(S,(g.y-g.r)*x),O=Math.max(O,(g.x+g.r)*x),D=Math.max(D,(g.y+g.r)*x);for(let g of h.values()){let _=0,y=0;for(let R of g.lines)_=Math.max(_,R.label.width),y+=R.label.height;w=Math.min(w,g.spot.x*x-_/2),O=Math.max(O,g.spot.x*x+_/2),S=Math.min(S,g.spot.y*x-y/2),D=Math.max(D,g.spot.y*x+y/2)}c.length===0&&(w=S=O=D=0);let L=We(e.title&&hs(e.title),!1,a,r,4e3,1),B=L.height>0?L.height+12:0,W=Math.max(O-w,L.width),Y=i+(W-(O-w))/2-w,I=i+B-S,X=Math.ceil(W+2*i),ee=Math.ceil(D-S+B+2*i),K=c.map(g=>({id:g.id,x:g.x*x+Y,y:g.y*x+I,r:g.r*x})),z="";K.forEach((g,_)=>{let y=lt(_),R=h.get(g.id)?.style??Wx;z+=`<circle class="pele-venn-set" data-id="${Fe(g.id)}" cx="${d(g.x)}" cy="${d(g.y)}" r="${d(g.r)}" fill="${y}" fill-opacity="0.2" stroke="${y}"${R.shape}/>`});let C="",M="";for(let g of h.values()){let _=Fe(g.sets.join("|"));if(g.sets.length>1&&g.style.shape!==""){let $=Fx(g.inside.map(U=>K[U]),d);$!==""&&(C+=`<path class="pele-venn-overlap" data-id="${_}" d="${$}" fill="none"${g.style.shape}/>`)}let y=0;for(let $ of g.lines)y+=$.label.height;if(y===0)continue;let R=g.spot.x*x+Y,A=g.spot.y*x+I-y/2,N="";for(let $ of g.lines){let U=$.id===void 0?` class="pele-label"${$.size===r?"":` font-size="${$.size}"`}${g.style.text}`:` class="pele-venn-text" data-id="${Fe($.id)}" font-size="${s}" fill="var(--_m)"${p($.id).text}`;N+=De($.label,R,A+$.label.height/2,U),A+=$.label.height}M+=`<g class="pele-venn-region" data-id="${_}">${N}</g>`}return{svg:Ze("venn",X,ee,r,n,{},De(L,X/2,i+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-venn-sets">${z}</g>`+(C?`<g class="pele-venn-overlaps">${C}</g>`:"")+(M?`<g class="pele-venn-labels">${M}</g>`:"")),width:X,height:ee,links:[]}}var Gx={type:"venn",parse(e,t,n){let r=new Ql;return n&&(r.title=n),vx(e,r),r},render:Ux};var td=class{constructor(){de(this,"nodes",new Map);de(this,"labels");de(this,"links",[]);de(this,"trends",new Map);de(this,"pipelines",new Map);de(this,"annotations",[]);de(this,"notes",[]);de(this,"accelerators",[]);de(this,"deaccelerators",[]);de(this,"annotationsBox");de(this,"axes",{});de(this,"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 ze(`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 nd(e,t){let n=e<=1?e*100:e;if(n<0||n>100)throw new ze(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,"semantic",{type:"wardley"});return n}function ei(e,t,n){return{x:nd(t,`${n} evolution`),y:nd(e,`${n} visibility`)}}function Yx(e){return e==="+<>"?"bidirectional":e==="+<"?"backward":e==="+>"?"forward":void 0}function rk(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 Hx(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function sk(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=ei(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=ei(n.visibility,n.evolution,`Component "${n.name}"`),[o,s]=Hx(n.label);t.addNode({id:n.name,label:n.name,x:r.x,y:r.y,className:"component",labelOffsetX:o,labelOffsetY:s,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of e.notes){let r=ei(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 ze(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,"semantic",{type:"wardley"});let o=r.y;t.startPipeline(n.parent);for(let s of n.components){let a=`${n.parent}_${s.name}`,[i,c]=Hx(s.label),l=nd(s.evolution,`Pipeline component "${s.name}" evolution`);t.addNode({id:a,label:s.name,x:l,y:o,className:"pipeline-component",labelOffsetX:i,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(".-.")),o=rk(n.arrow),s=Yx(n.fromPort)??Yx(n.toPort)??o.flow;t.addLink({source:t.resolveNodeId(n.from),target:t.resolveNodeId(n.to),dashed:r,label:o.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:nd(n.target,`Evolve target for "${n.component}"`),targetY:r.y})}if(e.annotations.length>0){let n=ei(e.annotations[0].x,e.annotations[0].y,"Annotations box");t.setAnnotationsBox(n.x,n.y)}for(let n of e.annotation){let r=ei(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=ei(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=ei(n.x,n.y,`Deaccelerator "${n.name}"`);t.addDeaccelerator({name:n.name,x:r.x,y:r.y})}}function Kx(e,t){let n=new td;return sk(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,`
`):void 0,...n.build()}}function zx(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function ik(){let e=0,t=0;return(n,r)=>{if((r<e||r>=t)&&(e=r,t=zx(n,r)),t===r||n.charCodeAt(t)!==46)return-1;let o=zx(n,t+1);return o>t+1?o:-1}}var Vx={name:"ARROW",pattern:/->/y,first:"-"},jx={name:"LINK_ARROW",pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:"->+"},kn=(e,t)=>({name:e,pattern:new RegExp(t,"y"),first:t[0]}),Xx=[{name:"[",pattern:"["},{name:",",pattern:","},{name:"]",pattern:"]"},{name:"@",pattern:"@"},{name:"/",pattern:"/"},{name:"(",pattern:"("},{name:")",pattern:")"},{name:"-",pattern:"-",longer:[Vx,jx,Ut]},{name:"{",pattern:"{"},{name:"}",pattern:"}"},{name:"WARDLEY_NUMBER",pattern:/[0-9]+\.[0-9]+/y,first:"0123456789",scanner:ik},Vx,{name:"LINK_PORT",pattern:/\+<>|\+>|\+</y,first:"+"},jx,{name:"LINK_LABEL",pattern:/;[^\n\r]+/y,first:";"},{name:"STRATEGY",pattern:/build|buy|outsource|market/y,first:"bom"},kn("KW_WARDLEY","wardley-beta"),kn("KW_SIZE","size"),kn("KW_EVOLUTION","evolution"),kn("KW_ANCHOR","anchor"),kn("KW_COMPONENT","component"),kn("KW_LABEL","label"),kn("KW_INERTIA","inertia"),kn("KW_EVOLVE","evolve"),kn("KW_PIPELINE","pipeline"),kn("KW_NOTE","note"),kn("KW_ANNOTATIONS","annotations"),kn("KW_ANNOTATION","annotation"),kn("KW_ACCELERATOR","accelerator"),kn("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:"	 "},_i(),zt,Vt,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y,first:"0123456789"},Cn,{name:"ID",pattern:/[\w]([-\w]*\w)?/y,first:"_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},bn,yn,Ut,jt,Xt];function qx(e){let t=new Bt(Wt(e,Xx,"wardley"),Xx,"wardley"),n={$type:"Wardley",anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},r=m=>t.kinds[t.i]===m,o=()=>r(36)||r(37)||r(30),s=()=>r(36)?on(t.take()):r(37)||r(30)?t.take():t.fail("a name"),a=()=>Number(t.expect(10)),i=()=>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++},f=m=>{t.expect(0);let h=m();t.expect(1);let b=m();return t.expect(2),[h,b]},p=()=>{t.expect(21),t.expect(0);let m=t.accept(7),h=i();t.expect(1);let b=t.accept(7),x=i();return t.expect(2),{$type:"Label",negX:m,offsetX:h,negY:b,offsetY:x}},u=()=>{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=Ht(t.take()),l();break;case 33:n.accTitle=Yt(t.take()),l();break;case 34:n.title=Gt(t.take()),l();break;case 17:{t.i++;let[m,h]=f(i);l(),n.size={$type:"Size",width:m,height:h};break}case 18:{t.i++;let m=[u()];for(t.expect(11),m.push(u());t.accept(11);)m.push(u());l(),n.evolution={$type:"Evolution",stages:m};break}case 19:{t.i++;let m=s(),[h,b]=f(a);l(),n.anchors.push({$type:"Anchor",name:m,visibility:h,evolution:b});break}case 20:{t.i++;let m={$type:"Component",name:s(),visibility:0,evolution:0,inertia:!1};[m.visibility,m.evolution]=f(a),r(21)&&(m.label=p()),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(),h=a();l(),n.evolves.push({$type:"Evolve",component:m,target:h});break}case 24:{t.i++;let m=s();for(t.expect(8),t.expect(38);r(38);)t.i++;let h=[];do{t.expect(20);let b={$type:"PipelineComponent",name:s(),evolution:0};t.expect(0),b.evolution=a(),t.expect(2),r(21)&&(b.label=p()),l(),h.push(b)}while(r(20));t.expect(9),l(),n.pipelines.push({$type:"Pipeline",parent:m,components:h});break}case 25:{t.i++;let m=on(t.expect(36)),[h,b]=f(a);l(),n.notes.push({$type:"Note",text:m,visibility:h,evolution:b});break}case 26:{t.i++;let[m,h]=f(c);l(),n.annotations.push({$type:"Annotations",x:m,y:h});break}case 27:{t.i++;let m=i();t.expect(1);let[h,b]=f(c),x=on(t.expect(36));l(),n.annotation.push({$type:"Annotation",number:m,x:h,y:b,text:x});break}case 28:case 29:{let m=t.kind===29;t.i++;let h=s(),[b,x]=f(a);l(),m?n.deaccelerators.push({$type:"Deaccelerator",name:h,x:b,y:x}):n.accelerators.push({$type:"Accelerator",name:h,x:b,y:x});break}default:{o()||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 ok=["Genesis","Custom Built","Product","Commodity"],ak=48,Ft=6,ti=10,ck=8,rd=15,oa=60,lk=30,Qx=20,Op="var(--_c)",Pn="var(--_l)";function dk(e,t,n,r,o){let s=e["wardley-beta"]?.[t];return typeof s=="number"&&s>=r&&s<=o?s:n}function Gi(e,t,n){return e<t?t:e>n?n:e}function Zx(e,t,n,r){let o=Tr(e),s="",a=n;for(let i of e.lines){let c=!0;for(let l of i){if(l.icon!==void 0)continue;let f=ar(l.style&~o);s+=`<tspan${c?` x="${d(t)}" y="${d(a)}"`:""}${f}>${je(l.text)}</tspan>`,c=!1}a+=e.lineHeight}return s===""?"":`<text${jn(r,o)} xml:space="preserve">${s}</text>`}function Jx(e,t,n,r){let o=typeof t=="number"&&Number.isFinite(t)?t:dk(e,n,r,1,1e6);return Gi(o,200,1e4)-2*ak}function eS(e,t,n){let r=Jx(t,e.size?.width,"width",900);return Kr(n,r,160,(o,s)=>uk(e,t,n,o,r,s))}function uk(e,t,n,r,o,s){let a=n.fontSize??16,i=Math.round(a*.8125),c=Math.round(a*.6875),l=n.measurer??et(n.fontFamily),f=n.padding??8,p=Jx(t,e.size?.height,"height",600)*Math.max(.75,r/o),u=t["wardley-beta"]?.showGrid===!0,m=0,h=0,b=r,x=p,E=(oe,ge,Ee,be)=>{oe<m&&(m=oe),ge<h&&(h=ge),Ee>b&&(b=Ee),be>x&&(x=be)},w=(oe,ge,Ee,be)=>(E(ge-oe.width/2,Ee-oe.height/2,ge+oe.width/2,Ee+oe.height/2),De(oe,ge,Ee,be,n.icons)),S=(oe,ge,Ee,be)=>(E(ge,Ee-oe.size,ge+oe.width,Ee-oe.size+oe.height+4),Zx(oe,ge,Ee,be)),O=(oe,ge,Ee=s?Math.max(64,Math.min(120,r/2)):4e3,be=0)=>We(oe,!1,l,ge,Ee,be),D=oe=>oe/100*r,L=oe=>p-oe/100*p,B=e.axes.stages&&e.axes.stages.length>0?e.axes.stages:ok,W=e.axes.stageBoundaries,Y=W!==void 0&&W.length===B.length,I="",X="",ee=p,K=0;if(B.forEach((oe,ge)=>{let Ee=Y?K:ge/B.length,be=Y?Gi(W[ge],0,1):(ge+1)/B.length;K=be,ge>0&&(I+=`<path class="pele-wardley-stage" d="M${d(Ee*r)},0V${d(p)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let ye=O(oe,i,Math.max(48,Math.abs(be-Ee)*r-12));X+=w(ye,(Ee+be)/2*r,p+8+ye.height/2,` class="pele-wardley-stage-label" font-size="${i}" fill="var(--_m)"`),ee=Math.max(ee,p+8+ye.height)}),u)for(let oe=1;oe<4;oe++)I+=`<path class="pele-wardley-grid" d="M${d(r*oe/4)},0V${d(p)}M0,${d(p*oe/4)}H${d(r)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;I+=`<path class="pele-wardley-axis" d="M0,0V${d(p)}H${d(r)}" stroke="${Pn}"/>`;let z=O(e.axes.xLabel??"Evolution",i),C=O(e.axes.yLabel??"Visibility",i),M=` class="pele-wardley-axis-label" font-size="${i}" font-weight="var(--_hw)"`,T=w(z,r/2,ee+6+z.height/2,M)+De(C,-16,p/2,`${M} transform="rotate(-90 -16 ${d(p/2)})"`);E(-16-C.height/2,0,0,0);let g=ee+6+z.height+10,_=new Map;for(let oe of e.nodes)_.set(oe.id,{x:D(oe.x),y:L(oe.y),node:oe});let y="",R=new Map;for(let oe of e.pipelines){R.set(oe.nodeId,new Set(oe.componentIds));let ge=[];for(let ue of oe.componentIds){let fe=_.get(ue);fe&&ge.push(fe)}if(ge.length===0)continue;ge.sort((ue,fe)=>ue.x-fe.x);let Ee=ge[0].x,be=ge[ge.length-1].x,ye=ge[0].y,Re=ye-2*Ft,Le=_.get(oe.nodeId);Le&&(Le.x=(Ee+be)/2,Le.y=Re-ti/6),E(Ee-rd,Re,be+rd,Re+4*Ft),y+=`<g class="pele-wardley-pipeline" data-id="${Fe(oe.nodeId)}"><rect x="${d(Ee-rd)}" y="${d(Re)}" width="${d(be-Ee+2*rd)}" height="${d(4*Ft)}" fill="var(--_s)" stroke="var(--_b)"${it}/>`+(ge.length>1?`<path d="M${d(Ee)},${d(ye)}H${d(be)}" stroke="${Pn}" stroke-dasharray="4 4"/>`:"")+"</g>"}let A=new Map,N=(oe,ge,Ee)=>{let be=oe.node;if(be.className==="anchor"){let ye=A.get(be);return ye||A.set(be,ye=O(be.label,i,s?Math.max(64,r/2):4e3,1)),1/Math.hypot(ge/(ye.width/2+5),Ee/(i*.8))}return be.isPipelineParent?ti/Math.SQRT2:be.sourceStrategy?2*Ft:Ft},$=new Map,U=(oe,ge,Ee)=>{Math.abs(ge)<.25||Math.abs(Ee)<.25||$.set(oe,($.get(oe)??0)|(ge>0?Ee<0?1:2:Ee<0?4:8))},j="";for(let oe of e.links){let ge=_.get(oe.source),Ee=_.get(oe.target);if(!ge||!Ee||ge===Ee||R.get(oe.target)?.has(oe.source))continue;let be=Ee.x-ge.x,ye=Ee.y-ge.y,Re=Math.hypot(be,ye);if(Re<.01)continue;let Le=be/Re,ue=ye/Re,fe=N(ge,Le,ue),Me=N(Ee,Le,ue);if(fe+Me>=Re)continue;U(ge,Le,ue),U(Ee,-Le,-ue);let Ne=ge.x+Le*fe,Be=ge.y+ue*fe,ce=Ee.x-Le*Me,Se=Ee.y-ue*Me,$e="";(oe.flow==="forward"||oe.flow==="bidirectional")&&($e+=Et("arrow_point",ce,Se,Le,ue,Pn),ce-=Le*mt("arrow_point"),Se-=ue*mt("arrow_point")),(oe.flow==="backward"||oe.flow==="bidirectional")&&($e+=Et("arrow_point",Ne,Be,-Le,-ue,Pn),Ne+=Le*mt("arrow_point"),Be+=ue*mt("arrow_point"));let Ae="";if(oe.label){let xe=O(oe.label,c+1,200),Oe=Le>=0?1:-1,ve=ue*Oe,Ge=-Le*Oe,pe=5+Math.abs(ve)*xe.width/2+Math.abs(Ge)*xe.height/2;Ae=w(xe,(ge.x+Ee.x)/2+ve*pe,(ge.y+Ee.y)/2+Ge*pe,` class="pele-edge-label" font-size="${c+1}" fill="var(--_m)"`)}j+=`<g class="pele-edge${oe.dashed?" pele-wardley-dashed":""}" data-id="${Fe(oe.source)}-${Fe(oe.target)}"><path d="M${d(Ne)},${d(Be)}L${d(ce)},${d(Se)}" stroke="${Pn}"${oe.dashed?' stroke-dasharray="6 6"':""}/>`+$e+Ae+"</g>"}let v="";for(let oe of e.trends){let ge=_.get(oe.nodeId);if(!ge)continue;let Ee=D(oe.targetX),be=L(oe.targetY),ye=Ee-ge.x,Re=be-ge.y,Le=Math.hypot(ye,Re),ue="",fe=Le>0?N(ge,ye/Le,Re/Le):0;if(Le>fe+Ft+4){let Me=ye/Le,Ne=Re/Le,Be=Ee-Me*(Ft+2),ce=be-Ne*(Ft+2);ue=`<path d="M${d(ge.x+Me*fe)},${d(ge.y+Ne*fe)}L${d(Be-Me*mt("arrow_point"))},${d(ce-Ne*mt("arrow_point"))}" stroke="${Op}" stroke-dasharray="4 4"/>`+Et("arrow_point",Be,ce,Me,Ne,Op)}E(Ee-Ft,be-Ft,Ee+Ft,be+Ft),v+=`<g class="pele-wardley-trend" data-id="${Fe(oe.nodeId)}">${ue}<circle cx="${d(Ee)}" cy="${d(be)}" r="${Ft}" fill="var(--_bg)" stroke="${Op}"/></g>`}let k="",F=1.2*Ft,H=.7*Ft;for(let oe of _.values()){let ge=oe.node,{x:Ee,y:be}=oe,ye=ge.className==="anchor",Re=ge.sourceStrategy,Le="";if(Re){let Ne=Re==="outsource"?"var(--_m)":Re==="buy"?"var(--_a)":Re==="build"?"var(--_s)":"var(--_bg)";Le+=`<circle class="pele-wardley-${Re}" cx="${d(Ee)}" cy="${d(be)}" r="${2*Ft}" fill="${Ne}" stroke="${Pn}"/>`}if(Re==="market"){let Ne=F*Math.cos(Math.PI/6),Be=be+F*Math.sin(Math.PI/6);Le+=`<path d="M${d(Ee)},${d(be-F)}L${d(Ee-Ne)},${d(Be)}H${d(Ee+Ne)}Z" fill="none" stroke="${Pn}"/>`;for(let[ce,Se]of[[Ee,be-F],[Ee-Ne,Be],[Ee+Ne,Be]])Le+=`<circle cx="${d(ce)}" cy="${d(Se)}" r="${d(H)}" fill="var(--_bg)" stroke="${Pn}"/>`}else ge.isPipelineParent?Le+=`<rect x="${d(Ee-ti/2)}" y="${d(be-ti/2)}" width="${ti}" height="${ti}" fill="var(--_bg)" stroke="${Pn}"/>`:ye||(Le+=`<circle cx="${d(Ee)}" cy="${d(be)}" r="${Ft}" fill="var(--_bg)" stroke="${Pn}"/>`);if(ge.inertia===!0){let Ne=(ge.isPipelineParent?ti/2:Ft)+10+(Re?Ft+4:0);Le+=`<rect class="pele-wardley-inertia" x="${d(Ee+Ne)}" y="${d(be-Ft)}" width="4" height="${2*Ft}" fill="${Pn}"/>`}let ue=ge.labelOffsetX===void 0?void 0:Gi(ge.labelOffsetX,-5e3,5e3),fe=ge.labelOffsetY===void 0?void 0:Gi(ge.labelOffsetY,-5e3,5e3),Me;if(ye){let Ne=A.get(ge)??O(ge.label,i,s?Math.max(64,r/2):4e3,1);Me=w(Ne,Ee+(ue??0),be+(fe??-3),` class="pele-label" font-size="${i}" font-weight="var(--_hw)"`)}else{let Ne=O(ge.label,i),Be=` class="pele-label" font-size="${i}"`,ce=ck+(Re?10:0);if(ue!==void 0||fe!==void 0)Me=S(Ne,Ee+(ue??ce),be+(fe??-ce),Be);else if(ge.inPipeline)Me=w(Ne,Ee,be+2*Ft+4+Ne.height/2,Be);else{let Se=$.get(oe)??0,$e=(Se&1)===0?1:(Se&2)===0?2:(Se&4)===0?4:(Se&8)===0?8:1,Ae=$e===1||$e===2,xe=$e===1||$e===4;Me=S(Ne,Ae?Ee+ce:Ee-ce-Ne.width,xe?be-ce:be+ce+i*.75,Be)}}E(Ee-2*Ft,be-2*Ft,Ee+2*Ft+20,be+2*Ft),k+=`<g class="pele-node pele-wardley-${ye?"anchor":ge.isPipelineParent?"pipeline-parent":ge.inPipeline?"pipeline-component":"component"}" data-id="${Fe(ge.id)}">${Le}${Me}</g>`}let G="";for(let oe of e.annotations){let ge=O(String(oe.number),c,4e3,1),Ee="";for(let be of oe.coordinates){let ye=D(be.x),Re=L(be.y),Le=Math.max(10,ge.width/2+4);E(ye-Le,Re-Le,ye+Le,Re+Le),Ee+=`<circle cx="${d(ye)}" cy="${d(Re)}" r="${d(Le)}" fill="var(--_bg)" stroke="${Pn}"/>`+De(ge,ye,Re,` font-size="${c}" font-weight="var(--_hw)"`)}G+=`<g class="pele-wardley-annotation" data-id="${Fe(String(oe.number))}">${Ee}</g>`}let se=e.annotations.filter(oe=>oe.text).sort((oe,ge)=>oe.number-ge.number);if(se.length>0){let oe=se.map(fe=>O(`${fe.number}. ${fe.text}`,i,s?Math.max(80,r-20):320)),ge=0,Ee=0;for(let fe of oe)ge=Math.max(ge,fe.width),Ee+=fe.height;ge+=20,Ee+=14;let be=e.annotationsBox,ye=be?Gi(D(be.x),0,Math.max(0,r-ge)):0,Re=be?Gi(L(be.y),0,Math.max(0,p-Ee)):g;E(ye,Re,ye+ge,Re+Ee);let Le="",ue=Re+7;for(let fe of oe)Le+=Zx(fe,ye+10,ue+fe.lineHeight/2+i*.35,` font-size="${i}"`),ue+=fe.height;G+=`<g class="pele-wardley-annotations"><rect x="${d(ye)}" y="${d(Re)}" width="${d(ge)}" height="${d(Ee)}" fill="var(--_bg)" stroke="var(--_b)"${it}/>${Le}</g>`}let q="";for(let oe of e.notes)q+=S(O(oe.text,i,Math.min(360,r*.6),1),D(oe.x),L(oe.y),` class="pele-wardley-note" font-size="${i}" font-weight="var(--_hw)"`);let P="",V=(oe,ge,Ee,be)=>{let ye=D(ge),Re=L(Ee),Le=lk/2,ue=be?ye+oa:ye,fe=be?ye:ye+oa,Me=be?ye+oa-Qx:ye+Qx,Ne=`M${d(fe)},${d(Re-Le)}H${d(Me)}V${d(Re-Le-8)}L${d(ue)},${d(Re)}L${d(Me)},${d(Re+Le+8)}V${d(Re+Le)}H${d(fe)}Z`;E(ye,Re-Le-8,ye+oa,Re+Le+8),P+=`<g class="pele-wardley-${be?"accelerator":"deaccelerator"}" data-id="${Fe(oe)}"><path d="${Ne}" fill="var(--_s)" stroke="${Pn}"/>`+w(O(oe,c+1,160,1),ye+oa/2,Re+Le+8+12,` font-size="${c+1}" font-weight="var(--_hw)"`)+"</g>"};for(let oe of e.accelerators)V(oe.name,oe.x,oe.y,!0);for(let oe of e.deaccelerators)V(oe.name,oe.x,oe.y,!1);let ne=We(e.title,!1,l,a,s?Math.max(80,r):4e3,1),ae=ne.height>0?ne.height+12:0,Z=Math.min(m,r/2-ne.width/2),Q=Math.max(b,r/2+ne.width/2),ie=f-Z,me=f+ae-h,re=Math.ceil(Q-Z+2*f),te=Math.ceil(x-h+ae+2*f),he=De(ne,ie+r/2,f+ne.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(ie)},${d(me)})"><g class="pele-wardley-frame" fill="none">${I}</g>`+X+T+y+(j?`<g class="pele-edges" fill="none">${j}</g>`:"")+(v?`<g class="pele-wardley-trends" fill="none">${v}</g>`:"")+k+G+q+P+"</g>";return{svg:Ze("wardley",re,te,a,n,e,he),width:re,height:te,links:[]}}var tS={type:"wardley",section:"wardley-beta",parse:(e,t,n)=>Kx(qx(e),n),render:eS};var sd=class{constructor(){de(this,"type","xychart");de(this,"title");de(this,"accTitle");de(this,"accDescr");de(this,"orientation");de(this,"xAxis",{type:"band",title:"",categories:[]});de(this,"yAxis",{type:"linear",title:"",min:1/0,max:-1/0});de(this,"hasSetXAxis",!1);de(this,"hasSetYAxis",!1);de(this,"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:o,max:s}=this.yAxis;for(let a of t)a<o&&(o=a),a>s&&(s=a);this.yAxis={type:"linear",title:this.yAxis.title,min:o,max:s}}if(n.type==="band")return n.categories.map((o,s)=>[o,t[s]]);if(t.length===1)return[[`${n.min}`,t[0]]];let r=(n.max-n.min)/(t.length-1);return t.map((o,s)=>[`${n.min+s*r}`,o])}addPlot(t,n,r){let o={type:t,title:n.text.trim(),data:this.plotData(r.map(s=>s.value))};t==="line"&&r.some(s=>s.label.trim()!=="")&&(o.pointLabels=r.map(s=>s.label.trim())),this.plots.push(o)}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,`
`)}};var vp=["$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 nS=[33,33,33,33,33,19,5,7,8],rS="`)"+" ".repeat(36)+'{ this.pushstate(md_string); }\n<md_string>(?:(?!`").)+'+" ".repeat(18)+"{ return md_str; }\n<md_string>(?:`",Pp=new Uint8Array(128);for(let[e,t]of[[":",21],["+",22],[",",23],["=",24],["*",25],["#",26],["_",27],[".",28],["&",29],["-",30],[";",32]])Pp[e.charCodeAt(0)]=t;function sS(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=(b,x,E)=>{n.push(b),r.push(e.slice(x,E)),o.push(x),i=E},l=b=>{s.push(a),a=b},f=()=>{s.length>0&&(a=s.pop())},p=b=>{let x=e.indexOf(`
`,b);return x===-1?t:x},u=b=>{for(;b<t&&He(e.charCodeAt(b));)b++;return b},m=b=>{for(;ft(e.charCodeAt(b));)b++;return b},h=b=>ln(e,i,b)&&!Qe(e.charCodeAt(i+b.length));for(;i<t;){let b=e.charCodeAt(i);if(a===5){if(b===34)i++,f();else{let E=e.indexOf('"',i);c(19,i,E===-1?t:E)}continue}if(a===6||a===7){c(nS[a],i,p(i)),f();continue}if(a===8){if(b===125)i++,f();else{let E=e.indexOf("}",i);c(8,i,E===-1?t:E)}continue}let x=e.charCodeAt(i+1);if(b===37&&x===37){i=p(i+2);continue}if(b!==125&&x===37&&e.charCodeAt(i+2)===37){i=p(i+3);continue}if(b===10||b===13){if((a===1||a===3)&&(b===10||x===10)){c(2,i,b===10?i+1:i+2),f();continue}let E=i+1;for(let w=e.charCodeAt(E);w===10||w===13;w=e.charCodeAt(++E));c(2,i,E);continue}switch(b|32){case 116:if(h("title")){c(3,i,i+5);continue}break;case 97:if(ln(e,i,"acc")){let E=ln(e,i+3,"descr");if(E||ln(e,i+3,"title")){let w=u(i+8),S=e.charCodeAt(w);if(S===58){c(E?6:4,i,u(w+1)),l(E?7:6);continue}if(S===123&&E){i=u(w+1),l(8);continue}}}break;case 120:if(h("xychart-beta")){c(9,i,i+12);continue}if(h("xychart")){c(9,i,i+7);continue}if(h("x-axis")){c(11,i,i+6),l(1);continue}break;case 121:if(h("y-axis")){c(12,i,i+6),l(1);continue}break;case 118:if(ln(e,i,"vertical")){c(10,i,i+8);continue}break;case 104:if(ln(e,i,"horizontal")){c(10,i,i+10);continue}break;case 108:if(h("line")){c(14,i,i+4),l(3);continue}break;case 98:if(h("bar")){c(15,i,i+3),l(3);continue}break}if(b===91){a===1?l(2):a===3&&l(4),c(17,i,i+1);continue}if(b===93){(a===4||a===2)&&f(),c(18,i,i+1);continue}if(a===1&&b===45&&x===45&&e.charCodeAt(i+2)===62){c(13,i,i+3);continue}if(a===1||a===4){let E=b===43||b===45?i+1:i,w=e.charCodeAt(E),S=-1;if(ft(w)?(S=m(E+1),e.charCodeAt(S)===46&&ft(e.charCodeAt(S+1))&&(S=m(S+2))):w===46&&ft(e.charCodeAt(E+1))&&(S=m(E+2)),S!==-1){c(16,i,S);continue}}if(b===96&&ln(e,i,rS)){i+=rS.length,f();continue}if(b===34){i++,l(5);continue}if(Rr(b)){let E=i+1;for(;Rr(e.charCodeAt(E));)E++;c(20,i,E);continue}if(ft(b)){c(31,i,m(i+1));continue}if(He(b)){i=u(i+1);continue}if(b<128&&Pp[b]!==0){c(Pp[b],i,i+1);continue}break}return i<t?(n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}):(n.push(nS[a]),r.push(""),o.push(t),n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o})}function aS(...e){let t=new Uint8Array(34);for(let n of e)t[n]=1;return t}var iS=aS(29,31,20,22,24,25,28,26,30,27),oS=aS(2,32,33);function cS(e,t){let{types:n,texts:r,starts:o}=sS(e),s=0,a=u=>{let m=n[s];throw m===1?st("xychart",e,o[s],"",!0):st("xychart",e,o[s],`Expecting ${u}, got '${vp[m]}'`)},i=u=>(n[s]!==u&&a(`'${vp[u]}'`),r[s++]),c=u=>u===19||iS[u]===1,l=()=>{c(n[s])||a("'STR', 'ALPHA', 'NUM'");let u=r[s++];if(n[s-1]!==19)for(;iS[n[s]]===1;)u+=r[s++];return{text:u,type:"text"}},f=()=>{let u=Number(i(16));return i(13),[u,Number(i(16))]},p=()=>{let u=[];for(i(17);;){let m=Number(i(16));if(u.push({value:m,label:n[s]===19?r[s++]:""}),n[s]!==23)break;s++}return i(18),u};for(;;)if(oS[n[s]]===1)s++;else{if(n[s]!==9)break;n[++s]===10&&t.setOrientation(r[s++])}for(;n[s]!==0;){let u=n[s++];switch(u){case 3:t.setDiagramTitle(l().text.trim());break;case 11:case 12:{let m=c(n[s])?l():void 0;if(u===11&&n[s]===17){let h=[];do s++,h.push(l());while(n[s]===23);i(18),t.setXAxisBand(h)}else if(n[s]===16||m===void 0){let[h,b]=f();u===11?t.setXAxisRangeData(h,b):t.setYAxisRangeData(h,b)}u===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(),h=p();u===14?t.setLineData(m,h):t.setBarData(m,h);break}case 4:t.setAccTitle(i(5).trim());break;case 6:t.setAccDescription(i(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(;oS[n[s]]===1;)s++}}function Bp(e,t){let n=e/Math.max(t,1),r=Math.floor(Math.log10(n)),o=n/10**r,s=o>=7.07?10:o>=3.16?5:o>=1.41?2:1;return r<0?-(10**-r)/s:s*10**r}function aa(e,t){return e>0?t/e:t*-e}function Yi(e,t){return e>0?t*e:t/-e}function Fp(e,t,n){let r=Math.round(aa(n,e));Yi(n,r)<e&&r++;let o=Math.round(aa(n,t));Yi(n,o)>t&&o--;let s=[];for(let a=r;a<=o&&s.length<100;a++)s.push(Yi(n,a));return s}var lS=4,Hi=12,dS=26,uS=24,fS=1e300;function Wp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function Kn(e,t,n=!0){let r=e[t];return typeof r=="boolean"?r:n}function pS(e,t){return typeof e=="number"&&e>0?Math.round(Math.min(Math.max(e,100),4e3)):t}function ms(e){return typeof e=="number"&&isFinite(e)?Math.min(Math.max(e,-fS),fS):void 0}function fk(e){let t=0;for(let n of e)t=Math.max(t,n.label.width);return t}function id(e,t,n,r){let o=e.lines.length===1?e.lines[0]:void 0;return o&&o.length===1&&o[0].icon===void 0&&o[0].style===0?`<text x="${d(t)}" y="${d(n+e.size*.35)}" text-anchor="${r}">${je(o[0].text)}</text>`:De(e,t+(r==="start"?e.width/2:r==="end"?-e.width/2:0),n,"")}function hS(e,t,n){if(e.plots.length===0)throw new ze("No Plot to render, please provide a plot with some data","semantic",{type:"xychart"});let r=Wp(t.xyChart),o=n.fontSize??16,s=Math.round(o*.875),a=Math.round(o*.75),i=n.measurer??et(n.fontFamily),c=n.padding??8,l=pS(r.width,700),f=zr(n,l,240),p=Math.round(pS(r.height,500)*Math.max(.6,f/l)),u=(e.orientation??r.chartOrientation)==="horizontal",m=Kn(r,"showDataLabel",!1),h=e.xAxis,b=e.plots,x=(ke,Ke,Ve)=>We(ke,!1,i,Ke,Ve),E=x("0",s,4e3).height,w=x("0",a,4e3).height,S=We(Kn(r,"showTitle")?e.title:void 0,!1,i,o,f-2*c,1),O=S.height>0?S.height+12:0,D=[],L=0;Kn(r,"showLegend")&&b.forEach((ke,Ke)=>{if(ke.title==="")return;let Ve=x(ke.title,s,f*.3);D.push({index:Ke,label:Ve}),L=Math.max(L,Ve.width+Hi+8)});let B=D.length>0?L+uS:0,W=b.filter(ke=>ke.type==="bar").length,Y=e.yAxis.min,I=e.yAxis.max,X=e.hasSetYAxis&&isFinite(Y)&&isFinite(I)&&Y!==I;if(X)Y=ms(Y),I=ms(I);else{Y=1/0,I=-1/0;for(let ke of b)for(let[,Ke]of ke.data){let Ve=ms(Ke);Ve!==void 0&&(Ve<Y&&(Y=Ve),Ve>I&&(I=Ve))}Y>I&&(Y=I=0),W>0&&(Y=Math.min(Y,0),I=Math.max(I,0)),Y===I&&(Y===0?I=1:(Y-=Math.abs(Y)/2,I+=Math.abs(I)/2))}let ee=(ke,Ke)=>{let Ve=Bp(Math.abs(I-Y),Math.max(2,Math.min(10,Math.floor(ke/Ke))));return X||(Y=Yi(Ve,Math.floor(aa(Ve,Y)+1e-9)),I=Yi(Ve,Math.ceil(aa(Ve,I)-1e-9))),Fp(Math.min(Y,I),Math.max(Y,I),Ve).map(ct=>({at:(ct-Y)/(I-Y),label:x(String(ct),s,4e3)}))},K=1;if(h.type==="band")K=Math.max(h.categories.length,1);else for(let ke of b)K=Math.max(K,ke.data.length);let z=1/K,C=h.type==="band"||W>0?z/2:0,M=ms(h.type==="linear"?h.min:void 0),T=ms(h.type==="linear"?h.max:void 0),g=M!==void 0&&T!==void 0&&M!==T,_=(ke,Ke)=>h.type==="band"?(ke+.5)*z:C+(Ke>1?ke/(Ke-1):g?0:.5)*(1-2*C),y=Wp(r.xAxis),R=Wp(r.yAxis),A=u?y:R,N=u?R:y,$=x(Kn(A,"showTitle")?u?h.title:e.yAxis.title:void 0,s,p*.8),U=x(Kn(N,"showTitle")?u?e.yAxis.title:h.title:void 0,s,f*.8),j=Kn(A,"showTick")?lS:0,v=Kn(N,"showTick")?lS:0,k=Kn(A,"showLabel"),F=Kn(N,"showLabel"),H=u?f*.3:Math.max(48,(f-2*c-64-B)*z-8),G=h.type==="band"&&Kn(y,"showLabel")?h.categories.map(ke=>x(ke,s,H)):[],se=0,q=0;for(let ke of G)se=Math.max(se,ke.width),q=Math.max(q,ke.height);let P=ke=>{let Ke=[];if(h.type==="band"){let Ve=G.length===0?8:u?q:se+12,ct=Math.max(1,Math.ceil(Ve/(ke*z)));for(let tt=0;tt<h.categories.length;tt+=ct)Ke.push({at:(tt+.5)*z,label:G[tt]??x(void 0,s,0)})}else if(g){let Ve=Bp(Math.abs(T-M),Math.max(2,Math.min(10,Math.floor(ke/(u?32:80)))));for(let ct of Fp(Math.min(M,T),Math.max(M,T),Ve))Ke.push({at:C+(ct-M)/(T-M)*(1-2*C),label:x(String(ct),s,4e3)})}else M!==void 0&&Ke.push({at:.5,label:x(String(M),s,4e3)});return Ke},V=0,ne=0;for(let ke of b){for(let Ke of ke.pointLabels??[])V=Math.max(V,i.width(Ke,a,0));if(m&&u&&ke.type==="bar")for(let[,Ke]of ke.data)ne=Math.max(ne,i.width(String(ms(Ke)??""),a,0))}let ae=F?u||h.type!=="band"?E:q:0,Z=v+(ae>0?ae+4:0)+(U.height>0?U.height+4:0),Q=u?0:V>0||m?w+4:k?E/2:0,ie=c+O+Q,me=Math.max(1,p-c-Z-ie),re=ie+me,te=u?P(me):ee(me,56),he=k?fk(te):0,oe=c+($.height>0?$.height+6:0)+(he>0?he+6:0)+j,ge=Math.max(V>0?V+12:0,ne>0?ne+8:0),Ee=u?Math.min(f*.25,ge):0,be=Math.max(1,f-c-oe-B-Ee),ye=u?ee(be,80):P(be);if(F&&B+Ee===0){let ke=0;for(let Ke of ye)ke=Math.max(ke,Ke.at*be+Ke.label.width/2-be);be=Math.max(1,be-ke)}let Re=oe+be,Le=(ke,Ke)=>u?oe+Ke*be:oe+ke*be,ue=(ke,Ke)=>u?ie+ke*me:re-Ke*me,fe=ke=>(ke-Y)/(I-Y),Me=ke=>Math.min(Math.max(ke,0),1),Ne=ke=>u?`M${d(Le(0,ke))},${d(ie)}V${d(re)}`:`M${d(oe)},${d(ue(0,ke))}H${d(Re)}`,Be="";for(let ke of u?ye:te)Be+=Ne(ke.at);let ce="",Se="";Kn(A,"showAxisLine")&&(ce+=`M${d(oe)},${d(ie)}V${d(re)}`),Kn(N,"showAxisLine")&&(ce+=`M${d(oe)},${d(re)}H${d(Re)}`);for(let ke of te){let Ke=u?ie+ke.at*me:re-ke.at*me;j&&(ce+=`M${d(oe)},${d(Ke)}h${-j}`),k&&(Se+=id(ke.label,oe-j-6,Ke,"end"))}for(let ke of ye){let Ke=oe+ke.at*be;v&&(ce+=`M${d(Ke)},${d(re)}v${v}`),F&&(Se+=id(ke.label,Ke,re+v+4+ke.label.height/2,"middle"))}let $e=(u?me:be)*z,xe=$e*.7/Math.max(W,1),Oe=W>1?Math.min(2,xe*.2):0,ve=Me(fe(0));W>0&&ve>0&&ve<1&&(ce+=Ne(ve));let Ge="",pe="",J="",_e="",le=0;b.forEach((ke,Ke)=>{let Ve=lt(Ke),ct=ke.title?` data-id="${Fe(ke.title)}"`:"",tt=h.type==="band"?Math.min(ke.data.length,K):ke.data.length;if(ke.type==="bar"){let _t=(le++-(W-1)/2)*xe-(xe-Oe)/2,Xe="";for(let qe=0;qe<tt;qe++){let at=ms(ke.data[qe][1]);if(at===void 0)continue;let ot=_(qe,tt),kt=Me(fe(at)),bt=Math.min(ve,kt),Je=Math.max(ve,kt),wt=u?Le(ot,bt):Le(ot,0)+_t,ut=u?ue(ot,0)+_t:ue(ot,Je),Nt=u?(Je-bt)*be:xe-Oe,Dt=u?xe-Oe:(Je-bt)*me;if(Xe+=`<rect x="${d(wt)}" y="${d(ut)}" width="${d(Nt)}" height="${d(Dt)}"/>`,!m)continue;let pn=String(at),gs=i.width(pn,a,0),zn=kt>=ve?1:-1,Ki=wt+Nt/2,zi=ut+Dt/2,Up="middle";if(u){if(Dt<a)continue;Ki=(zn>0?wt+Nt:wt)+zn*6,Up=zn>0?"start":"end"}else{if(gs+2>$e/W)continue;zi=(zn>0?ut:ut+Dt)-zn*(w/2+2)}J+=`<text x="${d(Ki)}" y="${d(zi+a*.35)}" text-anchor="${Up}">${pn}</text>`}Ge+=`<g class="pele-series pele-bars"${ct} fill="${Ve}">${Xe}</g>`;return}let rt="",Ct="",dt=!1,It=0,xt=NaN;for(let _t=0;_t<tt;_t++){let Xe=ms(ke.data[_t][1]);if(Xe===void 0){xt=NaN;continue}let qe=_(_t,tt),at=fe(Xe),ot=at>=0&&at<=1;if(xt!==xt)ot&&(rt+=`M${d(Le(qe,at))},${d(ue(qe,at))}`),dt=ot;else{let wt=at-xt,ut=0,Nt=1;if(wt!==0){let Dt=-xt/wt,pn=(1-xt)/wt;ut=Math.max(ut,Math.min(Dt,pn)),Nt=Math.min(Nt,Math.max(Dt,pn))}else ot||(ut=2);if(ut<=Nt){let Dt=It+(qe-It)*ut,pn=xt+wt*ut,gs=It+(qe-It)*Nt,zn=xt+wt*Nt;(!dt||ut>0)&&(rt+=`M${d(Le(Dt,pn))},${d(ue(Dt,pn))}`),rt+=`L${d(Le(gs,zn))},${d(ue(gs,zn))}`}dt=ot}if(It=qe,xt=at,!ot)continue;let kt=Le(qe,at),bt=ue(qe,at);$e>=12&&(Ct+=`<circle cx="${d(kt)}" cy="${d(bt)}" r="3"/>`);let Je=x(ke.pointLabels?.[_t],a,4e3);if(Je.height>0){let wt=Je.width/2;_e+=u?id(Je,kt+10,bt,"start"):id(Je,Math.max(Math.min(kt,Re-wt),oe+wt),bt-6-Je.height/2,"middle")}}pe+=`<g class="pele-series pele-line"${ct} fill="${Ve}">`+(rt?`<path d="${rt}" fill="none" stroke="${Ve}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:"")+Ct+"</g>"});let we="";$.height>0&&(we+=`<g transform="translate(${d(c+$.height/2)},${d(ie+me/2)}) rotate(-90)">${De($,0,0,"")}</g>`),we+=De(U,oe+be/2,p-c-U.height/2,"");let Te="",Ce=0;for(let ke of D)Ce+=Math.max(dS,ke.label.height+6);let Ie=ie+Math.max(0,(me-Ce)/2),Pe=Re+Ee+uS;for(let{index:ke,label:Ke}of D){let Ve=Math.max(dS,Ke.height+6);if(Ie+Ve>p)break;let ct=Ie+Ve/2,tt=lt(ke);Te+=`<g class="pele-legend-item" data-id="${Fe(b[ke].title)}">`+(b[ke].type==="bar"?`<rect x="${d(Pe)}" y="${d(ct-Hi/2)}" width="${Hi}" height="${Hi}" rx="2" fill="${tt}"/>`:`<path d="M${d(Pe)},${d(ct)}h${Hi}" stroke="${tt}" stroke-width="2" stroke-linecap="round"/>`)+De(Ke,Pe+Hi+8+Ke.width/2,ct,"")+"</g>",Ie+=Ve}let Ue=De(S,f/2,c+S.height/2,' class="pele-title" font-weight="var(--_tw)"')+(Be?`<path class="pele-grid" d="${Be}" stroke="var(--_a)"/>`:"")+`<g class="pele-plot">${Ge}${pe}</g>`+(ce?`<path class="pele-axis" d="${ce}" fill="none" stroke="var(--_b)"/>`:"")+(Se?`<g class="pele-axis-labels" font-size="${s}" fill="var(--_m)">${Se}</g>`:"")+(we?`<g class="pele-axis-titles" font-size="${s}">${we}</g>`:"")+(J?`<g class="pele-data-labels" font-size="${a}">${J}</g>`:"")+(_e?`<g class="pele-point-labels" font-size="${a}">${_e}</g>`:"")+(Te?`<g class="pele-legend" font-size="${s}">${Te}</g>`:"");return{svg:Ze("xychart",f,p,o,n,e,Ue),width:f,height:p,links:[]}}var mS={type:"xychart",section:"xyChart",parse(e,t,n){let r=new sd;return r.title=n,cS(e,r),r},render:hS};var gS=[Tc,Jy,tb,Uy,Ly,bA,Ty,wg,dE,mS,J0,jb,Lm,i0,y0,zy,AE,UA,fy,W0,oy,ug,jm,zE,bm,kA,Bg,tS,fb,Ox,Gx,Ey,cA];Ad(...gS);return _S(pk);})();