chalk-talk 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/assets/player.html +120 -101
- package/embed-mermaid.d.ts +3 -0
- package/embed-mermaid.js +181 -0
- package/embed.d.ts +26 -0
- package/embed.js +127 -0
- package/package.json +47 -7
- package/player.js +127 -108
- package/scripts/build.mjs +42 -11
- package/scripts/contract.mjs +1 -1
- package/scripts/mermaid.mjs +48 -48
package/embed-mermaid.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/*! chalk-talk Mermaid (engine v0.244.1) — MIT; mermaid-to-excalidraw and Mermaid (MIT) */
|
|
2
|
+
var ck=Object.create;var eo=Object.defineProperty;var hk=Object.getOwnPropertyDescriptor;var dk=Object.getOwnPropertyNames;var fk=Object.getPrototypeOf,pk=Object.prototype.hasOwnProperty;var uk=(e,t,r)=>t in e?eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Ve=(e,t)=>()=>(e&&(t=e(e=0)),t);var gk=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ct=(e,t)=>{for(var r in t)eo(e,r,{get:t[r],enumerable:!0})},mk=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of dk(t))!pk.call(e,i)&&i!==r&&eo(e,i,{get:()=>t[i],enumerable:!(a=hk(t,i))||a.enumerable});return e};var yk=(e,t,r)=>(r=e!=null?ck(fk(e)):{},mk(t||!e||!e.__esModule?eo(r,"default",{value:e,enumerable:!0}):r,e));var ce=(e,t,r)=>uk(e,typeof t!="symbol"?t+"":t,r);var Au=gk(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.removeMarkdown=void 0;var xk=function(e,t){t===void 0&&(t={listUnicodeChar:""}),t=t||{},t.listUnicodeChar=t.hasOwnProperty("listUnicodeChar")?t.listUnicodeChar:!1,t.stripListLeaders=t.hasOwnProperty("stripListLeaders")?t.stripListLeaders:!0,t.gfm=t.hasOwnProperty("gfm")?t.gfm:!0,t.useImgAltText=t.hasOwnProperty("useImgAltText")?t.useImgAltText:!0,t.preserveLinks=t.hasOwnProperty("preserveLinks")?t.preserveLinks:!1;var r=e||"";r=r.replace(/^(-\s*?|\*\s*?|_\s*?){3,}\s*$/gm,"");try{t.stripListLeaders&&(t.listUnicodeChar?r=r.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,t.listUnicodeChar+" $1"):r=r.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,"$1")),t.gfm&&(r=r.replace(/\n={2,}/g,`
|
|
3
|
+
`).replace(/~{3}.*\n/g,"").replace(/~~/g,"").replace(/`{3}.*\n/g,"")),t.preserveLinks&&(r=r.replace(/\[(.*?)\][\[\(](.*?)[\]\)]/g,"$1 ($2)")),r=r.replace(/<[^>]*>/g,"").replace(/^[=\-]{2,}\s*$/g,"").replace(/\[\^.+?\](\: .*?$)?/g,"").replace(/\s{0,2}\[.*?\]: .*?$/g,"").replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g,t.useImgAltText?"$1":"").replace(/\[(.*?)\][\[\(].*?[\]\)]/g,"$1").replace(/^\s{0,3}>\s?/g,"").replace(/(^|\n)\s{0,3}>\s?/g,`
|
|
4
|
+
|
|
5
|
+
`).replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g,"").replace(/^(\n)?\s{0,}#{1,6}\s+| {0,}(\n)?\s{0,}#{0,} {0,}(\n)?\s{0,}$/gm,"$1$2$3").replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g,"$2").replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g,"$2").replace(/(`{3,})(.*?)\1/gm,"$2").replace(/`(.+?)`/g,"$1").replace(/\n{2,}/g,`
|
|
6
|
+
|
|
7
|
+
`)}catch(a){return console.error(a),e}return r};ro.removeMarkdown=xk});function so(e,t,r){t==="__proto__"?Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0}):e[t]=r}function On(e){return e===" "||e===" "||e===`
|
|
8
|
+
`||e==="\r"}function nd(e){let t=e[0],r,a;if(t==='"'||t==="'"){let s=1;for(;;){if(s>=e.length)return null;let l=e[s];if(t==='"'&&l==="\\")s+=2;else if(l===t){if(t==='"'||e[s+1]!=="'")break;s+=2}else s++}for(r=s+1,a=r;On(e[a]);)a++;if(e[a]!==":")return null}else{if(t===void 0||lM.test(t)||t==="-"&&(e.length<2||On(e[1])||e[1]===":"||e[1]==="#"))return null;for(a=1;a<e.length&&e[a]!==":"&&e[a]!=="#";)a++;if(e[a]!==":")return null;for(r=a;On(e[r-1]);)r--}let i=a+1;if(i<e.length&&!On(e[i]))return null;for(;On(e[i]);)i++;return{key:e.slice(0,r),length:i}}function od(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 r=t[0];if(r!=="-"&&r!=="+"&&r!=="."&&(r<"0"||r>"9"))return t;if(rM.test(t)||nM.test(t))return Number(t);if(aM.test(t)||iM.test(t)||sM.test(t)){let a=t[0]==="-",i=Number(a||t[0]==="+"?t.slice(1):t);return a?-i:i}return/^[-+]?\.(?:inf|Inf|INF)$/.test(t)?t[0]==="-"?-1/0:1/0:/^\.(?:nan|NaN|NAN)$/.test(t)?NaN:t}function Pn(e){if(!e.includes(`
|
|
9
|
+
`))return e;let t=e.split(`
|
|
10
|
+
`),r=t.length-1;for(let a=0;a<=r;a++){let i=t[a],s=0,l=i.length;if(a>0)for(;s<l&&(i.charCodeAt(s)===32||i.charCodeAt(s)===9);)s++;if(a<r)for(;l>s&&(i.charCodeAt(l-1)===32||i.charCodeAt(l-1)===9);)l--;t[a]=i.slice(s,l)}return t.join(`
|
|
11
|
+
`).replace(/\n+/g,a=>a.length===1?" ":`
|
|
12
|
+
`.repeat(a.length-1))}function oM(e){if(!e.includes("\\"))return Pn(e);let t="",r=Pn(e.replace(/\\\n[ \t]*/g,""));for(let a=0;a<r.length;a++){let i=r[a];if(i!=="\\"){t+=i;continue}let s=r[++a];if(s==="x"||s==="u"||s==="U"){let l=s==="x"?2:s==="u"?4:8;t+=String.fromCodePoint(parseInt(r.slice(a+1,a+1+l),16)),a+=l}else if(s in a0)t+=a0[s];else throw new Error("YAML: unknown escape sequence")}return t}function Vi(e,t,r){for(;t<e.length;){let a=e[t];if(a===" "||a===`
|
|
13
|
+
`||a===" "||a==="\r"||r&&a===",")t++;else if(a==="#"&&(t===0||/\s/.test(e[t-1]))){let i=e.indexOf(`
|
|
14
|
+
`,t);t=i===-1?e.length:i}else break}return t}function i0(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 Ns(e,t,r,a=0){if(a>s0)throw new Error("YAML: nesting is too deep");t=Vi(e,t,!1);let i=e[t];if(i==="{"){let l={};t++;let n=!0;for(;;){if(t=Vi(e,t,!1),t>=e.length)throw new Is("YAML: unexpected end of the stream within a flow collection");if(e[t]==="}")return[l,t+1];i0(e[t],n);let o;[o,t]=Ns(e,t,":,}",a+1),t=Vi(e,t,!1);let c=null;e[t]===":"&&([c,t]=Ns(e,t+1,",}",a+1)),so(l,String(o),c),t=Vi(e,t,!1),n=e[t]===",",n&&t++}}if(i==="["){let l=[];t++;let n=!0;for(;;){if(t=Vi(e,t,!1),t>=e.length)throw new Is("YAML: unexpected end of the stream within a flow collection");if(e[t]==="]")return[l,t+1];i0(e[t],n);let o;[o,t]=Ns(e,t,",]",a+1),l.push(o),t=Vi(e,t,!1),n=e[t]===",",n&&t++}}if(i==='"'){let l=t+1;for(;l<e.length&&e[l]!=='"';)l+=e[l]==="\\"?2:1;if(l>=e.length)throw new Is("YAML: unexpected end of the stream within a double quoted scalar");return[oM(e.slice(t+1,l)),l+1]}if(i==="'"){let l=t+1;for(;l<e.length;){if(e[l]==="'"){if(e[l+1]!=="'")break;l++}l++}if(l>=e.length)throw new Is("YAML: unexpected end of the stream within a single quoted scalar");return[Pn(e.slice(t+1,l)).replace(/''/g,"'"),l+1]}let s=t;for(;s<e.length;){let l=e[s];if(r.includes(l)&&(l!==":"||s+1>=e.length||/[\s,[\]{}]/.test(e[s+1])))break;if(l==="#"&&s>t&&/\s/.test(e[s-1])){let n=e.indexOf(`
|
|
15
|
+
`,s);return[od(Pn(e.slice(t,s).trim())),n===-1?e.length:n]}s++}return[od(Pn(e.slice(t,s).trim())),s]}function zn(e){let t="";for(let r=0;r<e.length;r++){let a=e[r];if(t)a==="\\"&&t==='"'?r++:a===t&&(t="");else if(a==='"'||a==="'")t=a;else if(a==="#"&&(r===0||e[r-1]===" "||e[r-1]===" "))return e.slice(0,r)}return e}function cM(e,t,r){let a=t[0]===">",i=t.includes("-")?"-":t.includes("+")?"+":"",s=/[1-9]/.exec(t),l=s?r+Number(s[0]):-1,n=[];for(;e.i<e.lines.length;){let f=e.lines[e.i];if(f.trim()===""){n.push(""),e.i++;continue}let p=f.length-f.trimStart().length;if(l===-1){if(p<=r)break;l=p}if(p<l)break;n.push(f.slice(l)),e.i++}let o=0;for(;n.length>0&&n[n.length-1]==="";)n.pop(),o++;let c;if(a){c="";for(let f=0;f<n.length;f++){let p=n[f];if(f>0){let d=n[f-1];p===""?c+=`
|
|
16
|
+
`:d!==""&&(c+=/^[ \t]/.test(d)||/^[ \t]/.test(p)?`
|
|
17
|
+
`:" ")}c+=p}}else c=n.join(`
|
|
18
|
+
`);return n.length===0?i==="+"?`
|
|
19
|
+
`.repeat(o):"":i==="-"?c:i==="+"?c+`
|
|
20
|
+
`.repeat(o+1):c+`
|
|
21
|
+
`}function ld(e,t,r){let a=t[0];if((a==="|"||a===">")&&/^[|>][-+0-9]*\s*(?:#.*)?$/.test(t))return cM(e,t,r);if(a==="{"||a==="["||a==='"'||a==="'"){let s=e.i,l=t,n=0,o=1;for(;;)try{let[c,f]=Ns(l,0,""),p=0;for(let g=l.indexOf(`
|
|
22
|
+
`);g!==-1&&g<f;g=l.indexOf(`
|
|
23
|
+
`,g+1))p++;let d=l.indexOf(`
|
|
24
|
+
`,f);if(zn(l.slice(f,d===-1?l.length:d)).trim()!=="")throw new Error("YAML: unexpected content after a value");return e.i=s+p,c}catch(c){if(!(c instanceof Is))throw c;if(s+n>=e.lines.length)throw new Error(c.message);let f=e.lines.slice(s+n,s+n+o);l+=`
|
|
25
|
+
`+f.join(`
|
|
26
|
+
`),n+=f.length,o*=2}}let i=zn(t).trim();for(;e.i<e.lines.length;){let s=e.lines[e.i];if(s.trim()===""){let n=e.i;for(;n<e.lines.length&&e.lines[n].trim()==="";)n++;if(n>=e.lines.length||e.lines[n].length-e.lines[n].trimStart().length<=r)break;i+=`
|
|
27
|
+
`.repeat(n-e.i),e.i=n;continue}if(s.length-s.trimStart().length<=r)break;let l=zn(s).trim();i+=(i.endsWith(`
|
|
28
|
+
`)?"":" ")+l,e.i++}return od(i)}function no(e,t,r=0){if(r>s0)throw new Error("YAML: nesting is too deep");if(e.skipBlank(),e.i>=e.lines.length)return null;let a=e.indent();if(a<t)return null;let i=e.lines[e.i].slice(a);if(i==="-"||i.startsWith("- ")){let l=[];for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length||e.indent()!==a));){let n=e.lines[e.i].slice(a);if(n!=="-"&&!n.startsWith("- "))break;let o=n.slice(1),c=o.length-o.trimStart().length+1,f=zn(o).trim();f===""?(e.i++,l.push(no(e,a+1,r+1))):nd(f)!==null?(e.lines[e.i]=" ".repeat(a+c)+o.trimStart(),l.push(no(e,a+c,r+1))):(e.i++,l.push(ld(e,o.trim(),a)))}return l}if(nd(i)===null)return e.i++,ld(e,i.trim(),a-1);let s={};for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length));){let l=e.indent();if(l<a)break;if(l>a)throw new Error("YAML: bad indentation of a mapping entry");let n=e.lines[e.i].slice(a),o=nd(n);if(!o)throw new Error("YAML: can not read a block mapping entry");let c=String(Ns(o.key,0,"")[0]),f=n.slice(o.length);if(e.i++,zn(f).trim()==="")if(e.skipBlank(),e.i<e.lines.length){let p=e.indent(),d=e.lines[e.i].slice(p),g=d==="-"||d.startsWith("- ");so(s,c,p>a||g&&p===a?no(e,g?a:a+1,r+1):null)}else so(s,c,null);else so(s,c,ld(e,f.trim(),a))}return s}function Ma(e){let t=e.trim();if(t[0]==="{"||t[0]==="[")try{let[i,s]=Ns(t,0,"");if(Vi(t,s,!1)===t.length)return i}catch(i){throw i instanceof Is?new Error(i.message):i}let r=new tM(e),a=no(r,0);if(r.skipBlank(),r.i<r.lines.length&&r.lines[r.i].trim()!=="...")throw new Error("YAML: end of the stream or a document separator is expected");return a}var Is,s0,tM,rM,aM,iM,sM,nM,lM,a0,Rs=Ve(()=>{Is=class{constructor(e){ce(this,"message");this.message=e}},s0=64;tM=class{constructor(e){ce(this,"lines");ce(this,"i",0);this.lines=(e.includes("\r")?e.replace(/\r\n?/g,`
|
|
29
|
+
`):e).split(`
|
|
30
|
+
`)}skipBlank(){for(;this.i<this.lines.length;){let e=this.lines[this.i].trim();if(e!==""&&e[0]!=="#"&&e!=="---")break;this.i++}}indent(){let e=this.lines[this.i],t=0;for(;t<e.length&&e[t]===" ";)t++;if(e[t]===" ")throw new Error("YAML: tabs are not allowed for indentation");return t}},rM=/^[-+]?(?:0|[1-9][0-9]*)$/,aM=/^[-+]?0x[0-9a-fA-F]+$/,iM=/^[-+]?0o[0-7]+$/,sM=/^[-+]?0b[01]+$/,nM=/^[-+]?(?:[0-9][0-9]*(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/,lM=/[\s#:,[\]{}&*!|>'"%@`]/;a0={0:"\0",a:"\x07",b:"\b",t:" ",n:`
|
|
31
|
+
`,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"}});function Ue(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 pa(e){return e===32||e===9}function Xi(e){return e===10||e===13||e===8232||e===8233}function pt(e){return e>=48&&e<=57}function ni(e){return e>=65&&e<=90||e>=97&&e<=122}function lo(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 tr=Ve(()=>{});function Bn(e,t){let r=1,a=0;for(let n=e.indexOf(`
|
|
32
|
+
`);n!==-1&&n<t;n=e.indexOf(`
|
|
33
|
+
`,n+1))r++,a=n+1;let i=e.indexOf(`
|
|
34
|
+
`,t);i===-1&&(i=e.length);let s=t-a+1,l=e.slice(a,i);return{line:r,column:s,snippet:l+`
|
|
35
|
+
`+"-".repeat(s-1)+"^"}}function it(e,t,r,a,i=!1){let s=Bn(t,r),l=i?`Lexical error on line ${s.line}. Unrecognized text.`:`Parse error on line ${s.line}:`,n=i?`${l}
|
|
36
|
+
${s.snippet}`:`${l}
|
|
37
|
+
${s.snippet}
|
|
38
|
+
${a}`;return new je(n,"syntax",{type:e,...s})}function dM(e){if(!oo){oo=new Map;for(let t of hM.split(",")){let r=t.indexOf(":");oo.set(t.slice(0,r),String.fromCodePoint(Number(t.slice(r+1))))}}return oo.get(e)}function n0(e,t){return e>0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint(e):t}function uM(e){let t="",r=0,a=e.indexOf(l0);for(;a!==-1;){let i=e.indexOf("\xB6",a+2);if(i===-1)break;if(e[i+1]==="\xDF"){let s=e[a+2]==="\xB0";t+=e.slice(r,a)+(s?"&#":"&")+e.slice(a+(s?3:2),i)+";",r=i+2}a=e.indexOf(l0,i+1)}return r===0?e:t+e.slice(r)}function At(e){return e.includes(pM)&&(e=uM(e)),e.includes("&")&&(e=e.replace(fM,(t,r,a,i)=>r?n0(Number(r),t):a?n0(parseInt(a,16),t):dM(i)??t)),e}function f0(e,t){let r=Fn,a=Wn;Fn=e,Wn=new Map;try{return t()}finally{Fn=r,Wn=a}}function Ds(e){if(Fn===void 0)return"";let t=Wn.get(e);return t===void 0&&(t=Fn(e)??"",Wn.set(e,t)),t}function p0(e,t){let r=Ba,a=Ls;Ba=e,Ls=new Map;try{return t()}finally{Ba=r,Ls=a}}function u0(){return Ba!==void 0}function o0(e){return Number.isFinite(e)&&e>0}function g0(e,t){if(Ba===void 0)return;let r=t+`
|
|
39
|
+
`+e;if(Ls.has(r))return Ls.get(r);let a=Ba(e,t)??void 0,i=a&&o0(a.width)&&o0(a.height)&&typeof("svg"in a?a.svg:a.html)=="string"?a:void 0;return Ls.set(r,i),i}function m0(e){if(Ba===void 0)return e();let t=Ba;Ba=void 0;try{return e()}finally{Ba=t}}function c0(e){let t=new Uint16Array(95);for(let r=0;r<95;r++)t[r]=parseInt(e.substr(r*2,2),36);return t}function wM(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 bM(e){return e>=768&&e<=879||e>=8203&&e<=8207||e>=56320&&e<=57343||e>=65024&&e<=65039||e===65279}function kM(){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}function h0(){let e=globalThis;return e.document?.fonts??e.fonts}function AM(e,t,r){try{return e?.check(t,r)??!0}catch{return!0}}function vM(e,t="monospace"){let r=kM();if(!r)return null;let a=new Map,i="",s=h0()?.size;return{width(l,n,o){let c=h0();c?.size!==s&&(s=c?.size,a.clear());let f=(o&2?"italic ":"")+(o&1?"bold ":"")+n+"px "+(o&4?t:e),p=a.get(f);p||a.set(f,p=new Map);let d=p.get(l);return d===void 0&&(f!==i&&(r.font=i=f),d=r.measureText(l).width,AM(c,f,l)&&(p.size>=MM&&p.clear(),p.set(l,d))),d}}}function et(e="sans-serif",t="monospace"){let r=e+`
|
|
40
|
+
`+t,a=d0.get(r);return a||(a=vM(e,t)??$M,d0.set(r,a)),a}var je,hM,oo,fM,l0,pM,Fn,Wn,Ba,Ls,gM,mM,yM,xM,$M,MM,d0,wt=Ve(()=>{je=class extends Error{constructor(t,r="syntax",a={}){super(t);ce(this,"code");ce(this,"type");ce(this,"mermaidType");ce(this,"line");ce(this,"column");ce(this,"snippet");this.name="PeleError",this.code=r,this.type=a.type??null,this.mermaidType=a.mermaidType??null,this.line=a.line??0,this.column=a.column??0,this.snippet=a.snippet??""}};hM="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";fM=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|(\w+));/g,l0="\uFB02\xB0",pM="\xB6\xDF";Wn=new Map;Ls=new Map;gM="7q7q9vfgfgopij5b9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg7q7qg8g8g8fgs7ijijk2k2ijgzlmk27qdwijfgn5k2lmijlmk2ijgzk2ijq8ijijgz7q7q7qd1fg99fgfgdwfgfg7qfgfg6666dw66n5fgfgfgfg99dw7qfgdwk2dwdwdw9a789ag8",mM="7q99d6fgfgopk26m9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg9999g8g8g8gzr3k2k2k2k2ijgzlmk27qfgk2gzn5k2lmijlmk2ijgzk2ijq8ijijgz997q99g8fg99fggzfggzfg99gzgz7q7qfg7qopgzgzgzgzatfg99gzfglmfgfgdwat7satg8";$M={width(e,t,r){let a=(r&4)!==0,i=r&1?xM??(xM=c0(mM)):yM??(yM=c0(gM)),s=0;for(let l=0;l<e.length;l++){let n=e.charCodeAt(l);if(!(n<32))if(n<127)s+=a?600:i[n-32];else{if(bM(n))continue;wM(n)?s+=a?1200:1e3:s+=a?600:580}}return s*t/1e3}};MM=2e4;d0=new Map});function po(e){return fo.has(e)}function uo(e){return e===void 0?"rect":UM.get(e)??fo.get(e)??"rect"}var HM,YM,UM,fo,ud=Ve(()=>{HM=[["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"]],YM=["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"],UM=new Map([["square","rect"],["round","rounded"],["ellipse","ellipse"],["hexagon","hex"],["diamond","diam"]]),fo=new Map;for(let e of HM)for(let t of e)fo.set(t,e[0]);for(let e of YM)fo.set(e,e)});function jM(){let e=qM.split(" "),t=new Uint16Array(e.length),r=0;for(let a=0;a<e.length;a+=2){let i=r+parseInt(e[a],36);r=i+parseInt(e[a+1],36),t[a]=i,t[a+1]=r}return t}function Ps(e){if(e<170||e>65500)return!1;let t=GM??(GM=jM()),r=0,a=(t.length>>1)-1;for(;r<=a;){let i=r+a>>1;if(e<t[i*2])a=i-1;else if(e>t[i*2+1])r=i+1;else return!0}return!1}var qM,GM,go=Ve(()=>{qM="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"});function Xe(e){return VM.test(e)?e.replace(XM,t=>KM[t]??""):e}function Oe(e){return Xe(At(e))}function h(e){let t=Math.round(e*100);if(t===0)return"0";if(t>0){if(t<1e11){let r=Math.floor(t/100);return r+yd[t-r*100]}}else if(t>-1e11){let r=-t,a=Math.floor(r/100);return"-"+a+yd[r-a*100]}return String(t/100)}function Re(e,t,r,a,i){let s=e.lines;if(s.length===0)return"";let l=e.lineHeight,n=e.heights,o=e.size*.35,c=r-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${a} x="${h(t)}" y="${h(c+l/2+o)}" text-anchor="middle">${Xe(f.text)}</text>`;let p=li(e),d=a,g;a=Aa(a,p);let u="",m="";for(let b=0;b<s.length;b++){let w=s[b],v=n?n[b]:l,k=c+v/2,L=k+o,I=!1;for(let N of w)(N.icon!==void 0||N.math)&&(I=!0);if(I){let N=t-e.widths[b]/2;for(let O of w){if(O.math){let W=`x="${h(N)}" y="${h(k-O.math.height/2)}" width="${h(O.math.width)}" height="${h(O.math.height)}"`;g??(g=rA(d)),m+=g.halo===void 0?aA(O.math,W,e.size,g.attrs):`<rect ${W} rx="2" fill="${g.halo}"/>`}else if(O.icon!==void 0){let W=e.size*1.1,U=i?.(O.icon)??"";m+=`<svg class="pele-icon" data-icon="${Oe(O.icon)}" x="${h(N)}" y="${h(k-W/2)}" width="${h(W)}" height="${h(W)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${U}</svg>`}else O.text!==""&&(u+=`<tspan x="${h(N)}" y="${h(L)}" text-anchor="start"${Ha(O.style&~p)}>${Xe(O.text)}</tspan>`);N+=O.width}}else{for(let N=0;N<w.length;N++){let O=w[N],W=N===0?` x="${h(t)}" y="${h(L)}"`:"";u+=`<tspan${W}${Ha(O.style&~p)}>${Xe(O.text)}</tspan>`}w.length===0&&(u+=`<tspan x="${h(t)}" y="${h(L)}"> </tspan>`)}c+=v}return`<text${a} text-anchor="middle" xml:space="preserve">${u}</text>${m}`}function rA(e){let t=JM.exec(e)?.[1]??"",r=(eA.exec(t)?.[1]??ZM.exec(e)?.[1]??"").trim();if(r==="none")return{attrs:"",halo:QM.exec(e)?.[1]??"none"};let a=tA.exec(t)?.[1].trim();return{attrs:(r===""?"":` color="${r}"`)+(a?` opacity="${a}"`:"")}}function aA(e,t,r,a){return"svg"in e?`<svg class="pele-math" ${t} overflow="visible"${a}>${e.svg}</svg>`:`<foreignObject class="pele-math" ${t} overflow="visible"${a}><div xmlns="http://www.w3.org/1999/xhtml" style="display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:${h(r)}px;line-height:normal;white-space:nowrap">${e.html}</div></foreignObject>`}function Ha(e){return(e&1?R0:"")+(e&2?L0:"")}function li(e){let t=3,r=!1;for(let a of e.lines)for(let i of a)i.icon!==void 0||i.text===""||(t&=i.style,r=!0);return r?t:0}function Aa(e,t){return e+(t&1&&!e.includes(' font-weight="')?R0:"")+(t&2&&!e.includes(' font-style="')?L0:"")}function uA(e){let t=e.split(`
|
|
41
|
+
`),r=1/0;for(let a of t){if(a.trim()==="")continue;let i=a.length-a.trimStart().length;i<r&&(r=i)}return r===1/0||r===0?e:t.map(a=>a.slice(Math.min(r,a.length-a.trimStart().length))).join(`
|
|
42
|
+
`)}function mo(e){return e!==void 0&&e.icon===void 0&&e.math===void 0}function gd(e,t,r){if(t!==""){if(Hn!==void 0&&O0.test(t)){let a=Hn,i=t.split(fA);for(let s=0;s<i.length;s++){if(s%2===0){i[s]!==""&&md(e,i[s],r);continue}let l=i[s].charCodeAt(0)-D0,n=a.math[l];n?e.push({text:"",style:r,math:n,width:n.width}):md(e,`$$${a.tex[l]}$$`,r)}return}md(e,t,r)}}function md(e,t,r){let a=At(t),i=e[e.length-1];mo(i)&&i.style===r?i.text+=a:e.push({text:a,style:r,width:0})}function gA(e,t,r){if(!t.includes(":fa-")){gd(e,t,r);return}let a=0;S0.lastIndex=0;let i;for(;(i=S0.exec(t))!==null;){let s=`${i[1]}:fa-${i[2]}`;if(gd(e,t.slice(a,i.index),r),a=i.index+i[0].length,Ds(s)!=="")e.push({text:"",style:r,icon:s,width:0});else if(t[a]===" ")a++;else if(a===t.length){let l=e[e.length-1];mo(l)&&(l.text=l.text.trimEnd())}}gd(e,t.slice(a),r)}function mA(e,t,r,a,i){let s=i,l=0,n="",o=0,c=t.length,f=()=>{gA(e,n,s),n=""};for(;o<c;){let p=t[o];if(p==="<"){E0.lastIndex=o;let d=E0.exec(t);if(d&&d.index===o){let g=d[1].toLowerCase(),u=t[o+1]==="/",m=g==="b"||g==="strong"?1:g==="i"||g==="em"?2:0;m&&(f(),i=u?i&~m|a&m:i|m,s=u?s&~m|a&m:s|m),o+=d[0].length;continue}}else if(r&&(p==="*"||p==="_")){let d=t[o+1]===p,g=d?1:2,u=d?2:1,m=(l&g)===0,b=o>0?t[o-1]:" ",w=o+u<c?t[o+u]:" ",v=m&&w.trim()!==""&&t.indexOf(d?p+p:p,o+u)!==-1,k=!m&&b.trim()!=="",L=p==="_"&&/\w/.test(b)&&/\w/.test(w);if((v||k)&&!L){f(),l=v?l|g:l&~g,s=v?s|g:s&~g|a&g,o+=u;continue}}n+=p,o++}return f(),i}function yA(e,t,r){let a=0;for(let i of e)i.width=i.icon!==void 0?r*1.25:i.math?i.math.width:t.width(i.text,r,i.style),a+=i.width;return a}function P0(e,t,r,a,i,s){let l=[],n=0,o=()=>{let c=l[l.length-1];if(mo(c)){let f=c.text.trimEnd();if(f!==c.text){c.text=f;let p=t.width(f,r,c.style);n+=p-c.width,c.width=p}}i.push(l),s.push(n),l=[],n=0};for(let c of e){if(c.icon!==void 0||c.math){let f=c.math?c.math.width:r*1.25;n>0&&n+f>a&&o(),l.push({...c,width:f}),n+=f;continue}for(let f of c.text.match(cA)??[]){let p=f;n>0&&n+t.width(p.trimEnd(),r,c.style)>a&&(o(),p=p.trimStart());let d=l[l.length-1];if(mo(d)&&d.style===c.style){d.text+=p,d.width=t.width(d.text,r,d.style),n=0;for(let g of l)n+=g.width}else{let g=t.width(p,r,c.style);l.push({text:p,style:c.style,width:g}),n+=g}}}(l.length>0||i.length===0)&&o()}function ze(e,t,r,a,i,s=0){if(e===void 0||e==="")return pA;let l=Math.round(a*iA);if(u0()&&e.includes("$$")&&!O0.test(e)){let n={tex:[],math:[]},o=e.replace(dA,(c,f)=>n.tex.length===hA?c:(n.tex.push(f),String.fromCharCode(D0+n.tex.length-1)));if(n.tex.length>0){for(let c of n.tex)n.math.push(g0(At(c),a));return C0(o,t,r,a,i,s,l,n)}}if(!nA.test(e)&&!e.includes("&")&&!e.includes("\uFB02")){let n=e.trim(),o=r.width(n,a,s);if(o<=i||!(n.includes(" ")||oA.test(n)))return{lines:[[{text:n,style:s,width:o}]],widths:[o],width:o,height:l,size:a,lineHeight:l};let c=[],f=[];P0([{text:n,style:s,width:o}],r,a,i,c,f);let p=0;for(let d of f)d>p&&(p=d);return{lines:c,widths:f,width:p,height:c.length*l,size:a,lineHeight:l}}return C0(e,t,r,a,i,s,l)}function C0(e,t,r,a,i,s,l,n){let o=Hn;Hn=n;try{let c=xA(e,t,r,a,i,s,l);return n?Yn(c):c}finally{Hn=o}}function xA(e,t,r,a,i,s,l){let n=t?uA(e.replace(/\r\n?/g,`
|
|
43
|
+
`)).trim():e.trim(),o=[],c=[],f=0,p=s;for(let d of n.split(sA)){let g=[];p=mA(g,d.trim(),t,s,p);let u=yA(g,r,a);u>i?P0(g,r,a,i,o,c):(o.push(g),c.push(u))}for(let d of c)d>f&&(f=d);return{lines:o,widths:c,width:f,height:o.length*l,size:a,lineHeight:l}}function Yn(e){let t;for(let a=0;a<e.lines.length;a++){let i=e.lineHeight;for(let s of e.lines[a])s.math&&(i=Math.max(i,Math.ceil(s.math.height+e.size/4)));i!==e.lineHeight&&t===void 0&&(t=e.lines.map(()=>e.lineHeight)),t&&(t[a]=i)}if(t===void 0)return e.heights===void 0?e:{...e,heights:void 0,height:e.lines.length*e.lineHeight};let r=0;for(let a of t)r+=a;return{...e,heights:t,height:r}}function zs(e){for(let t of e)if(t.math)return!0;return!1}function Ya(e,t){let r=e.heights;if(!r)return(t+.5)*e.lineHeight;let a=0;for(let i=0;i<t;i++)a+=r[i];return a+r[t]/2}function Ua(e,t){let r=e.widths[t],a=e.heights?e.heights[t]:e.lineHeight,i={lines:[e.lines[t]],widths:[r],width:r,height:a,size:e.size,lineHeight:e.lineHeight};return a!==e.lineHeight&&(i.heights=[a]),i}function ft(e){let t=e.indexOf(' style="');return t<0?e+st:`${e.slice(0,t+8)}rx:var(--_r);${e.slice(t+8)}`}function I0(e,t){return e&&$A.test(e)?e:t}function kA(e,t,r){return`;--_fm:var(--pele-font-mono,${I0(r,"monospace")});font:${e}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${I0(t,"sans-serif")})`}function vt(e){if(e.length===0)return N0;let t=new Map,r=new Map;for(let c of e){let f=c.indexOf(":");if(f<=0)continue;let p=c.slice(0,f).trim().toLowerCase(),d=c.slice(f+1).replace(/!important/gi,"").trim();d===""||vA.test(d)||(MA.has(p)&&t.set(p,d),AA.has(p)&&r.set(p==="color"?"fill":p,d))}if(t.size===0&&r.size===0)return N0;let a="",i="";for(let[c,f]of t)a+=`${c}:${f};`,c!=="fill"&&c!=="fill-opacity"&&(i+=`${c}:${f};`);let s="";for(let[c,f]of r)s+=`${c}:${f};`;let l=r.get("font-weight"),n=r.get("font-size"),o=n&&/^[\d.]+(px)?$/.test(n)?parseFloat(n):void 0;return{shape:a?` style="${Xe(a)}"`:"",line:i?` style="${Xe(i)}"`:"",text:s?` style="${Xe(s)}"`:"",stroke:t.get("stroke"),bold:l==="bold"||l==="bolder"||Number(l)>=600,italic:r.get("font-style")==="italic",fontSize:o!==void 0&&o>0&&o<=200?o:void 0}}function _t(e){let t=e.replace(EA," ").trim();return t===""?"":" "+t}function dt(e){let t=(e%8+8)%8;return`var(--pele-series-${t+1},${SA[t]})`}function Je(e,t,r,a,i,s,l){let n=Xe(i.idPrefix??"pele"),o="",c="";s.accTitle&&(o+=`<title id="${n}-title">${Oe(s.accTitle)}</title>`,c+=` aria-labelledby="${n}-title"`),s.accDescr&&(o+=`<desc id="${n}-desc">${Oe(s.accDescr)}</desc>`,c+=` aria-describedby="${n}-desc"`);let f=i.responsive===!1?"":"max-width:100%;height:auto;",p=new Set;for(let[,g]of l.matchAll(CA))if(p.add(g),p.size===4)break;let d=p.has("r")?`;--_r:${bA}`:"";for(let[g,u]of TA)p.has(g)&&(d+=`;--_${g}:var(--pele-${u}-weight,bold)`);return`<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-${e}" viewBox="0 0 ${t} ${r}" width="${t}" height="${r}" style="${f}${wA}${d}${Xe(kA(a,i.fontFamily,i.fontFamilyMono))}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${e}"${c}>`+o+l+"</svg>"}var VM,XM,KM,yd,ZM,QM,JM,eA,tA,R0,L0,iA,sA,E0,S0,nA,xd,T0,lA,oA,cA,D0,hA,dA,O0,fA,Hn,pA,wA,Un,bA,st,qn,_0,$A,MA,AA,vA,N0,EA,SA,TA,CA,ut=Ve(()=>{wt();VM=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/,XM=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]+/g,KM={"&":"&","<":"<",">":">",'"':"""};yd=[];for(let e=0;e<100;e++)yd.push(e===0?"":e%10===0?"."+e/10:"."+(e<10?"0"+e:e));ZM=/ fill="([^"]*)"/,QM=/ stroke="([^"]*)"/,JM=/ style="([^"]*)"/,eA=/(?:^|;)\s*fill:([^;]*)/,tA=/(?:^|;)\s*opacity:([^;]*)/;R0=' font-weight="var(--_w)"',L0=' font-style="italic"';iA=1.5,sA=/<br\s*\/?>|\\n|\n/gi,E0=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,S0=/(fa[bklrs]?):fa-([\w-]+)/g,nA=/[<\\\n*_]|fa[bklrs]?:fa-/,xd="\\u2e80-\\u9fff\\uf900-\\ufaff\\uff00-\\uff60",T0="\u3001\u3002\uFF0C\uFF0E\uFF1A\uFF1B\uFF01\uFF1F\uFF09\uFF3D\uFF5D\u300D\u300F\u3011\u3015\u3009\u300B\u3019\u3017\u30FC\u2026\u2025\u30FB\u309D\u309E\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE,.:;!?)\\]}",lA="\uFF08\uFF3B\uFF5B\u300C\u300E\u3010\u3014\u3008\u300A\u3018\u3016([{",oA=new RegExp(`[${xd}]`),cA=new RegExp(`\\s*(?:[${lA}]*[${xd}][${T0}]*|[^\\s${xd}]+[${T0}]*)\\s*|\\s+`,"g"),D0=57344,hA=6400,dA=/\$\$(.+?)\$\$/g,O0=/[\ue000-\uf8ff]/,fA=/([\ue000-\uf8ff])/,pA={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};wA="--_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)",Un="var(--_fm)",bA="var(--pele-radius,4px)",st=' style="rx:var(--_r)"';qn="var(--pele-critical,#e45756)",_0=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,$A=new RegExp(String.raw`^\s*${_0}(?:\s*,\s*${_0})*\s*$`,"u");MA=new Set(["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","opacity","rx","ry"]),AA=new Set(["color","font-size","font-family","font-weight","font-style","text-decoration","letter-spacing","word-spacing","opacity"]),vA=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,N0={shape:"",line:"",text:"",stroke:void 0,bold:!1,italic:!1,fontSize:void 0};EA=/[^\w-]+/g;SA=["#4c78a8","#f58518","#54a24b","#e45756","#72b7b2","#eeca3b","#b279a2","#9d755d"];TA=[["tw","title"],["hw","heading"],["w","bold"]],CA=/var\(--_(r|tw|hw|w)\)/g});function va(e,t){for(let r=0;r<t.length;r+=3){let a=Math.round(t[r+1]),i=e.get(a);i?i.push(t[r]):e.set(a,[t[r]])}}function Ai(e,t,r,a){if(t===0)return e.x;let i=e.y-e.h/2,s=e.x-e.w/2,l=t/2,n=[s+a-6+l,e.x,s+e.w-a+6-l],o=r.get(Math.round(i));if(o===void 0)return n[0];let c=n[0],f=-1;for(let p of n){let d=1/0;for(let g of o)g>s&&g<s+e.w&&(d=Math.min(d,Math.abs(g-p)-l));if(d>=6)return p;d>f+.5&&(f=d,c=p)}return c}function yo(e,t,r,a){let i=t>0?a.get(Math.round(e.y-e.h/2)):void 0;if(i===void 0)return!1;let s=e.x-e.w/2;for(let l of i)if(l>s&&l<s+e.w&&Math.abs(l-r)<t/2+4)return!0;return!1}function xo(e,t,r,a,i,s,l,n){let o=1;for(let f=s[l].parent;f>=0&&o<8;f=s[f].parent)o++;let c=`color-mix(in srgb,var(--_a) ${h(100*(1-.5**o))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${i}">`+Re(e,t,r,` fill="none" stroke="${c}" stroke-width="5" stroke-linejoin="round"`,n)+Re(e,t,r,a,n)+"</g>"}var Fs=Ve(()=>{ut()});function Zi(e,t,r=0){return{w:e,h:t,kind:r,pin:0,hint:NaN,key:NaN,span:0,x:0,y:0,rank:0}}function Qi(e,t,r=1,a=0,i=0){return{tail:e,head:t,minlen:r,labelW:a,labelH:i,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}function Bs(e){return e===1||e===2}function q0(e,t,r,a){for(let i=t+1;i<r;i++){let s=e[i],l=a[s],n=i-1;for(;n>=t&&(a[e[n]]>l||a[e[n]]===l&&e[n]>s);)e[n+1]=e[n],n--;e[n+1]=s}}function BA(e,t,r,a,i,s){let l=(c,f)=>r[c]<r[f]||r[c]===r[f]&&(i?a[c]>a[f]:a[c]<a[f]);for(let c=0;c<t;c+=8)for(let f=c+1,p=Math.min(t,c+8);f<p;f++){let d=e[f],g=f-1;for(;g>=c&&l(d,e[g]);)e[g+1]=e[g],g--;e[g+1]=d}let n=e,o=s;for(let c=8;c<t;c*=2){for(let p=0;p<t;p+=2*c){let d=Math.min(t,p+c),g=Math.min(t,p+2*c),u=p,m=d,b=p;for(;u<d&&m<g;)o[b++]=l(n[m],n[u])?n[m++]:n[u++];for(;u<d;)o[b++]=n[u++];for(;m<g;)o[b++]=n[m++]}let f=n;n=o,o=f}if(n!==e)for(let c=0;c<t;c++)e[c]=n[c]}function $o(e,t,r){let a=e.length;if(a===0)return{width:0,height:0};let i=t.length;if(a===1&&i===0&&e[0].kind===0){let he=e[0];return he.rank=0,he.x=he.w/2,he.y=he.h/2,{width:he.w,height:he.h}}let s=1;if(i>0){let he=new Set;for(let ke of t){let Ce=Math.min(ke.tail,ke.head),be=Math.max(ke.tail,ke.head),Me=Ce*a+be;if(ke.labelW>0||he.has(Me)){s=2;break}he.add(Me)}}jn(e,t),Vn(e,t,s);let l=new Int32Array(i),n=0;for(let he=0;he<i;he++){let ke=t[he];l[he]=Math.abs(e[ke.head].rank-e[ke.tail].rank),l[he]>1&&(n+=l[he]-1)}let o=new Uint8Array(i);if(n>z0){let he=[];for(let ke=0;ke<i;ke++)l[ke]>1&&he.push(ke);he.sort((ke,Ce)=>l[Ce]-l[ke]||ke-Ce);for(let ke of he){if(n<=z0)break;o[ke]=1,n-=l[ke]-1}}let c=a+n,f=new Float64Array(c),p=new Float64Array(c),d=new Uint8Array(c),g=new Int32Array(c),u=0;for(let he=0;he<a;he++){let ke=e[he];f[he]=ke.w,p[he]=ke.h,d[he]=ke.kind,g[he]=ke.rank,ke.rank>u&&(u=ke.rank)}let m=0;for(let he=0;he<i;he++)o[he]||(m+=l[he]);let b=new Int32Array(m),w=new Int32Array(m),v=new Float64Array(m),k=new Float64Array(m),L=new Int32Array(i).fill(-1),I=new Uint8Array(u+1),N=new Int32Array(i).fill(-1),O=!1;for(let he=0;he<a;he++)e[he].span>0&&e[he].kind===0&&(O=!0);let W=O?new Uint8Array(m):void 0,U=O?new Uint8Array(m):void 0,_=new Int32Array(i).fill(-1),j=new Int32Array(i).fill(-1),Z=new Float64Array(c).fill(NaN);for(let he=0;he<a;he++)Z[he]=e[he].key;let H=!1;{let he=a,ke=0;for(let Ce=0;Ce<i;Ce++){if(o[Ce])continue;let be=t[Ce],Me=be.reversed?be.head:be.tail,Ne=be.reversed?be.tail:be.head,Be=be.reversed?be.headDx:be.tailDx,Pe=be.reversed?be.tailDx:be.headDx;(Be!==0||Pe!==0)&&(H=!0);let V=g[Me],me=g[Ne],ae=-1;be.labelW>0&&(ae=V+(me-V>>1),s===2&&me-V>=4?(ae&1)===1&&(ae+=be.reversed?1:-1):s===2&&!(ae&1)&&(ae+=be.reversed?1:-1));let $e=Me;me-V>1&&(L[Ce]=he),_[Ce]=ke,W&&!(be.reversed?be.headFixed:be.tailFixed)&&(W[ke]=be.reversed?2:1);for(let ve=V+1;ve<me;ve++){let Te=he++;g[Te]=ve,Z[Te]=Z[Me]+(Z[Ne]-Z[Me])*(ve-V)/(me-V),ve===ae?(f[Te]=be.labelW,p[Te]=be.labelH,d[Te]=2,N[Ce]=Te,I[ve]|=be.reversed?2:1):d[Te]=1,b[ke]=$e,w[ke]=Te,v[ke]=$e===Me?Be:0,ke++,$e=Te}b[ke]=$e,w[ke]=Ne,v[ke]=$e===Me?Be:0,k[ke]=Pe,U&&!(be.reversed?be.tailFixed:be.headFixed)&&(U[ke]=be.reversed?1:2),j[Ce]=ke,ke++}}let z;if(r.groups){let{of:he,parent:ke}=r.groups;z=new Int32Array(c);for(let Me=0;Me<a;Me++)z[Me]=he[Me];let Ce=Me=>{let Ne=0;for(;Me>=0;Me=ke[Me])Ne++;return Ne},be=(Me,Ne)=>{let Be=Ce(Me),Pe=Ce(Ne);for(;Be>Pe;Be--)Me=ke[Me];for(;Pe>Be;Pe--)Ne=ke[Ne];for(;Me!==Ne;)Me=ke[Me],Ne=ke[Ne];return Me};for(let Me=0;Me<i;Me++){if(L[Me]<0)continue;let Ne=t[Me],Be=be(he[Ne.tail],he[Ne.head]);for(let Pe=L[Me],V=Pe+l[Me]-1;Pe<V;Pe++)z[Pe]=Be}}let C=new Int32Array(c+1),S=new Int32Array(c+1);for(let he=0;he<m;he++)C[b[he]+1]++,S[w[he]+1]++;for(let he=0;he<c;he++)C[he+1]+=C[he],S[he+1]+=S[he];let $=new Int32Array(m),y=new Int32Array(m);{let he=C.slice(0,c),ke=S.slice(0,c);for(let Ce=0;Ce<m;Ce++)$[he[b[Ce]]++]=Ce,y[ke[w[Ce]]++]=Ce}let E=new Int32Array(u+2);for(let he=0;he<c;he++)E[g[he]+1]++;for(let he=0;he<=u;he++)E[he+1]+=E[he];let x=new Int32Array(c),T=new Int32Array(c);{let he=new Int32Array(c),ke=E.slice(0,u+1);for(let Me=0;Me<c;Me++)he[ke[g[Me]]++]=Me;for(let Me=0;Me<=u;Me++)ke[Me]=E[Me];let Ce=new Uint8Array(c),be=[];for(let Me=0;Me<c;Me++)if(!Ce[he[Me]])for(be.push(he[Me]);be.length>0;){let Ne=be.pop();if(!Ce[Ne]){Ce[Ne]=1,x[ke[g[Ne]]++]=Ne;for(let Be=C[Ne+1]-1;Be>=C[Ne];Be--){let Pe=w[$[Be]];Ce[Pe]||be.push(Pe)}}}}let A=(he,ke)=>{let Ce=E[he],be=E[he+1];if(be-Ce<2)return!1;for(let Be=Ce;Be<be;Be++)if(Number.isNaN(ke(x[Be])))return!1;let Me=Array.from(x.subarray(Ce,be)),Ne=new Map;return Me.forEach((Be,Pe)=>Ne.set(Be,Pe)),Me.sort((Be,Pe)=>ke(Be)-ke(Pe)||Ne.get(Be)-Ne.get(Pe)),x.set(Me,Ce),!0};for(let he=0;he<=u;he++)A(he,ke=>Z[ke]);let M=!1;for(let he=0;he<a;he++)e[he].pin!==0&&(M=!0);if(M)for(let he=0;he<=u;he++){let ke=Array.from(x.subarray(E[he],E[he+1])),Ce=new Map;ke.forEach((Me,Ne)=>Ce.set(Me,Ne));let be=Me=>Me<a?e[Me].pin:0;ke.sort((Me,Ne)=>be(Me)-be(Ne)||Ce.get(Me)-Ce.get(Ne)),x.set(ke,E[he])}let Y=new Uint8Array(u+1),B=he=>he<a&&(e[he].kind===3||e[he].kind===4)?e[he].hint:NaN;for(let he of[0,u])A(he,B)&&(Y[he]=1);let q=()=>{for(let he=0;he<=u;he++){let ke=E[he];for(let Ce=ke,be=E[he+1];Ce<be;Ce++)T[x[Ce]]=Ce-ke}};q();let D={n:c,real:a,maxRank:u,W:f,KIND:d,RANK:g,EF:b,ET:w,EFD:v,ETD:k,succStart:C,succE:$,predStart:S,predE:y,layerStart:E,order:x,pos:T,offsets:H,fixed:Y,GRP:z,groupParent:r.groups?.parent},R=0,P=0;if(m>0&&u>0&&([R,P]=ZA(D,e),q()),r.orderOnly){let he=G0(D,r);for(let ke=0;ke<a;ke++)e[ke].x=he[ke];for(let ke=0;ke<i;ke++){let Ce=t[ke],be=Ce.reversed?Ce.head:Ce.tail,Me=Ce.reversed?Ce.tail:Ce.head,Ne=[g[be],he[be]];if(!o[ke]&&L[ke]>=0)for(let Be=L[ke],Pe=Be+l[ke]-1;Be<Pe;Be++)Ne.push(g[Be],he[Be]);Ne.push(g[Me],he[Me]),Ce.points=Ne}return{width:0,height:0,crossings:R,declared:P}}W&&U&&HA(D,e,W,U);let G=G0(D,r),X=jA(D);if(W&&U){let he=YA(D,W,U);UA(D,e,G,he,r,X),qA(D,e,G,W,U,he,X),GA(D,G,X,r);for(let ke=0;ke<i;ke++){if(o[ke])continue;let Ce=t[ke],be=v[_[ke]],Me=k[j[ke]];Ce.tailDx=Ce.reversed?Me:be,Ce.headDx=Ce.reversed?be:Me}}let Q=new Uint8Array(c);X&&!r.tracks&&XA(D,G,X,L,l,r.apart?0:r.edgeSep,Q),r.tracks||KA(D,G,L,l,r.edgeSep,Q);let J=new Int32Array(i+1),F=r.tracks||W&&!r.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,K=new Int32Array(u+1);if(F){for(let he=0;he<i;he++){if(J[he]=F.from.length,o[he])continue;let ke=L[he],Ce=!1;for(let Ne=ke,Be=ke<0?ke:ke+l[he]-1;Ne<Be;Ne++){let Pe=X!==void 0&&X[g[Ne]]===1;!r.tracks&&Pe!==(Q[Ne]===1)&&(Ce=!0)}if(Ce)continue;let be=G[b[_[he]]]+v[_[he]],Me=g[b[_[he]]];for(let Ne=ke,Be=ke<0?ke:ke+l[he]-1;Ne<Be;Ne++)X&&X[g[Ne]]||(F.from.push(be),F.to.push(G[Ne]),F.rank.push(Me),F.lower.push(Ne),be=G[Ne],Me=g[Ne]);F.from.push(be),F.to.push(G[w[j[he]]]+k[j[he]]),F.rank.push(Me),F.lower.push(-1)}J[i]=F.from.length}let re=(he,ke)=>{let Ce=!1;for(let be=E[he];be<E[he+1];be++){let Me=d[x[be]];if(Me===ke)Ce=!0;else if(Me!==1)return!1}return Ce},ne=re(0,3)?s:0,de=re(u,4)?s:0,ie=new Float64Array(u+1);for(let he=0;he<m;he++){let ke=Math.abs(G[b[he]]+v[he]-G[w[he]]-k[he]);ke>ie[g[b[he]]]&&(ie[g[b[he]]]=ke)}let se=new Float64Array(u+1),ee=new Float64Array(u+1),te=he=>(he<ne||he>=u-de?r.portSep:r.rankSep)/s,fe=new Float64Array(u+1);for(let he=0;he<u;he++)fe[he]=F?te(he):Math.max(te(he),Math.min(W0*r.rankSep/s,ie[he]*IA));let ye=new Uint8Array(u+1).fill(1);for(let he=0;he<a;he++)ye[g[he]]=0;for(let he=1;he<u;he++){if(r.tracks||!ye[he]||I[he]!==1&&I[he]!==2)continue;let ke=Math.min((r.headRoom??0)/2,fe[I[he]===1?he-1:he]/2);fe[he-1]+=I[he]===1?-ke:ke,fe[he]+=I[he]===1?ke:-ke}let le=he=>d[he]===1&&ye[g[he]]&&!r.tracks?(ee[g[he]]-se[g[he]])/4:0,we=r.tracks?NA:OA,pe=r.tracks?RA:B0,ge=r.tracks?LA:B0,Ae=new Int32Array(u+1);if(F){let he=new Float64Array(u+1);for(let Ce=0;Ce<u;Ce++){if(X&&X[Ce])continue;let be=Ce+1;for(he[Ce]=fe[Ce];be<u&&X&&X[be];)he[Ce]+=fe[be++];Ae[Ce]=be}for(let Ce=0;Ce<F.from.length;Ce++)F.wide.push(Math.abs(F.from[Ce]-F.to[Ce])>DA*he[F.rank[Ce]]?1:0);let ke=new Float64Array(u+1);VA(F,K,!r.tracks,he,ke);for(let Ce=0;Ce<u;Ce++)K[Ce]>0?fe[Ce]+=Math.max(0,2*we+(K[Ce]-1)*pe-he[Ce]):ke[Ce]>0&&(fe[Ce]+=Math.max(0,Math.min(W0*r.rankSep,ke[Ce])-he[Ce]))}let Se=0;for(let he=0;he<=u;he++){let ke=0;for(let Ce=E[he];Ce<E[he+1];Ce++)p[x[Ce]]>ke&&(ke=p[x[Ce]]);se[he]=Se,ee[he]=Se+ke,Se+=ke+fe[he]}let oe=Se,ue=(he,ke=F.track[he])=>{let Ce=F.rank[he],be=ee[Ce],Me=se[Ae[Ce]],Ne=r.tracks?K[Ce]:F.levels[he],Be=Ne>1?Math.min(ge,(Me-be-2*we)/(Ne-1)):0;return(be+Me)/2+(ke-(Ne-1)/2)*Be},xe=1/0,Ie=-1/0;for(let he=0;he<c;he++){let ke=f[he]/2;G[he]-ke<xe&&(xe=G[he]-ke),G[he]+ke>Ie&&(Ie=G[he]+ke)}let Le=new Uint8Array(u+1),We=new Uint8Array(u+1);for(let he=0;he<a;he++)d[he]!==0||!W||(S[he+1]>S[he]&&(Le[g[he]]=1),C[he+1]>C[he]&&(We[g[he]]=1));for(let he=0;he<a;he++){let ke=e[he],Ce=ke.rank;ke.x=G[he]-xe,d[he]===0&&We[Ce]&&!Le[Ce]?ke.y=ee[Ce]-ke.h/2:d[he]===0&&Le[Ce]&&!We[Ce]?ke.y=se[Ce]+ke.h/2:ke.y=(se[Ce]+ee[Ce])/2}for(let he=0;he<i;he++){let ke=t[he],Ce=e[ke.reversed?ke.head:ke.tail],be=e[ke.reversed?ke.tail:ke.head],Me=[Ce.x+(ke.reversed?ke.headDx:ke.tailDx),Ce.y+Ce.h/2],Ne=L[he];if(F&&J[he+1]>J[he])for(let Pe=J[he];Pe<J[he+1];Pe++){if(F.track[Pe]>=0&&(r.tracks||F.wide[Pe]===1)){let me=ue(Pe);Me.push(F.from[Pe]-xe,me,F.to[Pe]-xe,me)}else F.track[Pe]>0&&Me.push(F.from[Pe]-xe,ue(Pe,F.track[Pe]-1));let V=F.lower[Pe];V<0||(Me.push(G[V]-xe,se[g[V]]+le(V)),ee[g[V]]>se[g[V]]&&Me.push(G[V]-xe,ee[g[V]]-le(V)))}else if(Ne>=0)for(let Pe=Ne,V=Ne+l[he]-1;Pe<V;Pe++){if(Q[Pe])continue;let me=G[Pe]-xe,ae=se[g[Pe]],$e=ee[g[Pe]];Me.push(me,ae+le(Pe)),$e>ae&&Me.push(me,$e-le(Pe))}if(Me.push(be.x+(ke.reversed?ke.tailDx:ke.headDx),be.y-be.h/2),ke.reversed)for(let Pe=0,V=Me.length-2;Pe<V;Pe+=2,V-=2){let me=Me[Pe],ae=Me[Pe+1];Me[Pe]=Me[V],Me[Pe+1]=Me[V+1],Me[V]=me,Me[V+1]=ae}ke.points=Me;let Be=N[he];Be>=0?(ke.labelX=G[Be]-xe,ke.labelY=(se[g[Be]]+ee[g[Be]])/2):ke.labelW>0&&(ke.labelX=(Me[0]+Me[Me.length-2])/2,ke.labelY=(Me[1]+Me[Me.length-1])/2)}return{width:Ie-xe,height:oe}}function jn(e,t){let r=e.length,a=t.length,i=new Int32Array(r+1);for(let c=0;c<a;c++){let f=t[c];f.reversed=e[f.head].kind===3||e[f.tail].kind===4,f.reversed||i[f.tail+1]++}for(let c=0;c<r;c++)i[c+1]+=i[c];let s=new Int32Array(i[r]);{let c=i.slice(0,r);for(let f=0;f<a;f++)t[f].reversed||(s[c[t[f].tail]++]=f)}let l=new Uint8Array(r),n=i.slice(0,r),o=[];for(let c=0;c<r;c++)if(l[c]===0)for(o.push(c),l[c]=1;o.length>0;){let f=o[o.length-1];if(n[f]<i[f+1]){let p=t[s[n[f]++]],d=p.head;l[d]===1?p.reversed=!0:l[d]===0&&(l[d]=1,o.push(d))}else l[f]=2,o.pop()}}function Vn(e,t,r){let a=e.length,i=t.length,s=new Int32Array(i),l=new Int32Array(i),n=new Int32Array(i),o=new Int32Array(a+1),c=new Int32Array(a+1);for(let k=0;k<i;k++){let L=t[k],I=L.reversed?L.head:L.tail,N=L.reversed?L.tail:L.head;s[k]=I,l[k]=N,n[k]=Math.max(1,L.minlen)*r,o[I+1]++,c[N+1]++}for(let k=0;k<a;k++)o[k+1]+=o[k],c[k+1]+=c[k];let f=new Int32Array(i),p=new Int32Array(i);{let k=o.slice(0,a),L=c.slice(0,a);for(let I=0;I<i;I++)f[k[s[I]]++]=I,p[L[l[I]]++]=I}let d=new Int32Array(a),g=new Int32Array(a);for(let k=0;k<a;k++)g[k]=c[k+1]-c[k];let u=new Int32Array(a),m=0;for(let k=0;k<a;k++)g[k]===0&&(u[m++]=k);for(let k=0;k<m;k++){let L=u[k];for(let I=o[L];I<o[L+1];I++){let N=f[I],O=l[N];d[L]+n[N]>d[O]&&(d[O]=d[L]+n[N]),--g[O]===0&&(u[m++]=O)}}for(let k=0;k<8;k++){let L=!1;for(let I=m-1;I>=0;I--){let N=u[I],O=c[N+1]-c[N],W=o[N+1]-o[N];if(O===0&&W===0)continue;let U=-1/0,_=1/0;for(let Z=c[N];Z<c[N+1];Z++){let H=p[Z];U=Math.max(U,d[s[H]]+n[H])}for(let Z=o[N];Z<o[N+1];Z++){let H=f[Z];_=Math.min(_,d[l[H]]-n[H])}let j=d[N];W>O&&_!==1/0?j=_:O>W&&U!==-1/0&&(j=U),j!==d[N]&&(d[N]=j,L=!0)}if(!L)break}let b=1/0,w=-1/0,v=!1;for(let k=0;k<a;k++){let L=e[k].kind;L===3&&(v=!0),!(L===3||L===4)&&(d[k]<b&&(b=d[k]),d[k]>w&&(w=d[k]))}b===1/0&&(b=0,w=0);for(let k=0;k<a;k++)e[k].kind===3?d[k]=b-r:e[k].kind===4&&(d[k]=w+r);v&&(b-=r);for(let k=0;k<a;k++)e[k].rank=d[k]-b}function j0(e,t,r,a,i,s,l){let n=r===0?e.predStart:e.succStart,o=r===0?e.predE:e.succE,c=r===0?e.EF:e.ET,f=e.pos;for(let u=n[t];u<n[t+1];u++)i[o[u]]!==0&&s.push(o[u]);if(s.length<2)return 0;s.sort((u,m)=>f[c[u]]-f[c[m]]||u-m);let p=u=>{let m=0;l[0]=0;for(let b=1;b<s.length;b++){let w=i[s[b]]===i[s[b-1]];l[b]=u(w&&i[s[b]]===1,w),m+=l[b]}return m},d=p(()=>1);if(a/d<F0&&(d=p(u=>u?.5:1)),a/d<F0&&(d=p((u,m)=>m?0:1)),d===0)return 0;let g=Math.min($d,a/d);for(let u=1;u<s.length;u++)l[u]*=g;return d*g}function HA(e,t,r,a){let{real:i,W:s,EFD:l,ETD:n}=e;for(let o=0;o<i;o++){let c=Math.min(t[o].span,s[o]);if(!(c<=0||t[o].kind!==0))for(let f=0;f<2;f++){let p=[],d=[],g=j0(e,o,f,c,f===0?a:r,p,d);if(g===0)continue;let u=f===0?n:l,m=-g/2;for(let b=0;b<p.length;b++)m+=d[b],u[p[b]]=m}}}function bo(e,t,r,a){if(!t)return r;let{KIND:i,RANK:s,EF:l,ET:n,succStart:o,succE:c,predStart:f,predE:p}=e;for(let d=0;d<1e5;d++){let g=a===0?l[r]:n[r];if(i[g]!==1||!t[s[g]])break;r=a===0?p[f[g]]:c[o[g]]}return r}function YA(e,t,r){let a=[new Int32Array(e.n),new Int32Array(e.n)];for(let i=0;i<e.EF.length;i++)r[i]!==0&&a[0][e.ET[i]]++,t[i]!==0&&a[1][e.EF[i]]++;return a}function Xn(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function UA(e,t,r,a,i,s){let l=i.edgeSep,{n,real:o,maxRank:c,KIND:f,RANK:p,W:d,EF:g,ET:u,EFD:m,ETD:b,succStart:w,succE:v,predStart:k,predE:L,layerStart:I,order:N,pos:O}=e,W=z=>f[z]===2||f[z]===1&&!(s!==void 0&&s[p[z]]===1),U=(z,C)=>{let S=C===0?g[z]:u[z];return[C===0?r[S]+m[z]:r[S]+b[z],S<o&&t[S].kind===0?a[1-C][S]:0]},_=z=>{let C=I[p[z]],S=C+O[z],$=y=>d[y]/2+d[z]/2+(f[y]===0?i.nodeSep/2+l/2:f[y]===f[z]?l:l/2);return[S>C?r[N[S-1]]+$(N[S-1]):-1/0,S+1<I[p[z]+1]?r[N[S+1]]-$(N[S+1]):1/0]},j=(z,C,S,$,y)=>{let E=(C[1]!==S[1]?C[1]<S[1]:Math.abs(C[0]-z)<=Math.abs(S[0]-z))?[C[0],S[0]]:[S[0],C[0]];return E.find(x=>x>=$&&x<=y)??Math.max($,Math.min(y,E[0]))},Z=new Uint8Array(n),H=[];for(let z=1;z<c;z++)for(let C=I[z];C<I[z+1];C++){if(!W(N[C])||Z[N[C]])continue;let S=N[C];for(;Bs(f[g[L[k[S]]]]);)S=g[L[k[S]]];let $=S,y=-1/0,E=1/0;H.length=0;for(let x=S;Bs(f[x]);x=u[v[w[x]]]){if($=x,!W(x))continue;Z[x]=1,H.push(x);let[T,A]=_(x);T>y&&(y=T),A<E&&(E=A)}if(y<=E){let x=j(r[H[0]],U(L[k[S]],0),U(v[w[$]],1),y,E);for(let T of H)r[T]=x;continue}for(let x of H){let[T,A]=_(x);T>A||(r[x]=j(r[x],U(bo(e,s,L[k[x]],0),0),U(bo(e,s,v[w[x]],1),1),T,A))}}}function qA(e,t,r,a,i,s,l){let{real:n,W:o,EF:c,ET:f,EFD:p,ETD:d,succStart:g,succE:u,predStart:m,predE:b,pos:w}=e,v=(L,I,N,O,W)=>{if(s[I][N]<2)return 0;L=bo(e,l,L,I);let U=I===0?c[L]:f[L],_=I===0?r[U]+p[L]:r[U]+d[L];if(W&&Math.abs(_-r[N])<=O/2+qa)return Math.max(-O/2,Math.min(O/2,_-r[N]));let j=_,Z=0;U<n&&t[U].kind===0&&(I===0?a:i)[L]!==0&&s[1-I][U]>=2&&(Z=Math.max(0,Math.min(t[U].span,o[U])),Z>0&&(j=r[U]));let H=Math.max(r[N]-O/2,j-Z/2),z=Math.min(r[N]+O/2,j+Z/2);if(H>z+qa){let S=Math.max(0,O/2-WA);return Math.max(-S,Math.min(S,_-r[N]))}let C=(r[N]*Z+j*O)/(Z+O);return Math.max(H,Math.min(z,C))-r[N]},k=[];for(let L=0;L<n;L++){let I=Math.min(t[L].span,o[L]);if(!(I<=0||t[L].kind!==0))for(let N=0;N<2;N++){let O=N===0?c:f,W=N===0?m:g,U=N===0?b:u,_=[],j=[];if(j0(e,L,N,I,N===0?i:a,_,j),_.length===0)continue;_.length===1&&(j[0]=0);let Z=[];for(let H=W[L];H<W[L+1];H++)Z.push(U[H]);Z.sort((H,z)=>w[O[H]]-w[O[z]]||H-z),k.push({v:L,side:N,span:I,ids:_,room:j,all:Z})}}for(let L=0,I=!0;I&&L<6;L++){I=!1;for(let{v:N,side:O,span:W,ids:U,room:_,all:j}of k){let Z=O===0?i:a,H=O===0?d:p,z=0,C=-W/2;for(let S=0;S<=j.length;S++){let $=S<j.length&&Z[j[S]]===0;if(S<j.length&&!$)continue;let y=0;for(let x=S-1;x>=0&&Z[j[x]]!==0;x--)y++;let E=$?H[j[S]]-$d:W/2;if(y>0){let x=[],T=[],A=0;for(let B=0;B<y;B++){B>0&&(A+=_[z+B]),x.push(v(U[z+B],O,N,W,L>0)-A),T.push(1);let q=B>0&&_[z+B]===0;for(;x.length>1&&(q||x[x.length-2]/T[T.length-2]>x[x.length-1]/T[T.length-1]);){q=!1;let D=x.pop(),R=T.pop();x[x.length-1]+=D,T[T.length-1]+=R}}let M=A,Y=0;A=0;for(let B=0;B<x.length;B++){let q=E-M<C?(C+E-M)/2:Math.max(C,Math.min(E-M,x[B]/T[B]));for(let D=0;D<T[B];D++,Y++)Y>0&&(A+=_[z+Y]),Math.abs(H[U[z+Y]]-q-A)>.01&&(I=!0),H[U[z+Y]]=q+A}z+=y}$&&(C=H[j[S]]+$d)}}}}function GA(e,t,r,a){let{n:i,KIND:s,RANK:l,EF:n,ET:o,EFD:c,ETD:f,layerStart:p,order:d,pos:g}=e,u=_=>r!==void 0&&s[_]===1&&r[l[_]]===1,m=[],b=[],w=[],v=[];for(let _=0;_<n.length;_++){if(u(n[_]))continue;let j=bo(e,r,_,1);m.push(n[_]),b.push(o[j]),w.push(c[_]),v.push(f[j])}let k=_=>t[b[_]]+v[_]-t[m[_]]-w[_],L=new Int32Array(i),I=[];for(let _=0;_<i;_++)L[_]=_,I.push([_]);let N=(_,j)=>{let Z=L[_],H=L[j];if(Z!==H){I[Z].length<I[H].length&&([Z,H]=[H,Z]);for(let z of I[H])L[z]=Z,I[Z].push(z);I[H]=[]}},O=[];for(let _=0;_<m.length;_++){let j=Math.abs(k(_));j<.01?N(m[_],b[_]):j<=Y0&&O.push(_)}if(O.length===0)return;O.sort((_,j)=>Math.abs(k(_))-Math.abs(k(j))||_-j);let W=_=>V0(e,a,_),U=(_,j)=>{for(let Z of I[_]){let H=p[l[Z]],z=p[l[Z]+1],C=H+g[Z];if(C>H&&L[d[C-1]]!==_&&t[Z]+j-t[d[C-1]]<W(Z)+W(d[C-1])-.01||C+1<z&&L[d[C+1]]!==_&&t[d[C+1]]-t[Z]-j<W(Z)+W(d[C+1])-.01)return!1}return!0};for(let _ of O){let j=k(_);if(Math.abs(j)<.01){N(m[_],b[_]);continue}if(Math.abs(j)>Y0||L[m[_]]===L[b[_]])continue;let Z=L[m[_]],H=L[b[_]],z=I[Z].length<=I[H].length?Z:H;for(let C of[z,z===Z?H:Z]){let S=C===Z?j:-j;if(U(C,S)){for(let $ of I[C])t[$]+=S;N(m[_],b[_]);break}}}}function jA(e){let{maxRank:t,KIND:r,layerStart:a,order:i}=e,s=new Uint8Array(t+1),l=!1;for(let n=1;n<t;n++){let o=a[n+1]>a[n];for(let c=a[n];o&&c<a[n+1];c++)r[i[c]]!==1&&(o=!1);o&&(s[n]=1,l=!0)}return l?s:void 0}function VA(e,t,r,a,i){let{from:s,to:l,rank:n,track:o,levels:c,wide:f}=e,p=s.length,d=new Map;for(let _=0;_<p;_++){if(o.push(-1),c.push(0),Math.abs(s[_]-l[_])<qa)continue;let j=d.get(n[_]);j?j.push(_):d.set(n[_],[_])}if(d.size===0)return;let g=new Float64Array(p),u=new Float64Array(p);for(let _=0;_<p;_++)g[_]=Math.min(s[_],l[_]),u[_]=Math.max(s[_],l[_]);let m=(_,j)=>_>=g[j]-qa&&_<=u[j]+qa?1:0,b=(_,j)=>Math.abs(s[_]-s[j])<qa||Math.abs(l[_]-l[j])<qa,w=(_,j)=>g[_]<u[j]-qa&&g[j]<u[_]-qa,v=(_,j)=>w(_,j)&&!b(_,j),k=(_,j)=>w(_,j)||m(l[_],j)+m(s[j],_)+m(l[j],_)+m(s[_],j)>0,L=(_,j)=>m(l[_],j)+m(s[j],_),I=_=>{let j=_.map((H,z)=>z).sort((H,z)=>g[_[H]]-g[_[z]]),Z=[];for(let H=0;H<j.length;H++){let z=j[H],C=u[_[z]]+4*qa;for(let S=H+1;S<j.length&&g[_[j[S]]]<=C;S++){let $=j[S];Z.push(Math.min(z,$),Math.max(z,$))}}return Z},N=_=>{_.sort((Y,B)=>u[B]-g[B]-(u[Y]-g[Y])||g[Y]-g[B]||Y-B);let j=_.length,Z=[],H=_.map((Y,B)=>B),z=Y=>{for(;H[Y]!==Y;)Y=H[Y]=H[H[Y]];return Y},C=j<=U0,S=C?I(_):[],$=C?_.map(()=>[]):[];for(let Y=0;Y<S.length;Y+=2){let B=S[Y],q=S[Y+1];v(_[B],_[q])&&($[B].push(q),$[q].push(B))}let y=_.map((Y,B)=>B);if(C){let Y=new Int32Array(j),B=[];for(let D=0;D<j;D++)Z.push([]),B.push([]);for(let D=0;D<S.length;D+=2){let R=S[D],P=S[D+1],G=_[R],X=_[P];if(!k(G,X))continue;H[z(R)]=z(P);let Q=L(G,X),J=L(X,G);if(Q===J)continue;let F=Q<J?R:P,K=Q<J?P:R;Z[K].push(F),B[F].push(K),Y[K]++}let q=new Uint8Array(j);y=[];for(let D=0;D<j;D++){let R=-1;for(let P=0;P<j&&!(!q[P]&&((R<0||Y[P]<Y[R])&&(R=P),Y[P]===0));P++);q[R]=1,y.push(R);for(let P of B[R])Y[P]--}}let E=new Set,x=[],T=0;for(let Y of y){let B=_[Y],q=0;for(let D of Z[Y]??[])o[_[D]]>=q&&(q=o[_[D]]+1);if(C){E.clear();for(let D of $[Y])E.add(o[_[D]]);for(;E.has(q);)q++}else{for(;x[q]?.some(D=>v(B,D));)q++;(x[q]??(x[q]=[])).push(B)}o[B]=q,q>=T&&(T=q+1)}let A=new Int32Array(j).fill(T),M=new Int32Array(j).fill(-1);for(let Y=0;Y<j;Y++){let B=z(Y);A[B]=Math.min(A[B],o[_[Y]]),M[B]=Math.max(M[B],o[_[Y]])}for(let Y=0;Y<j;Y++){let B=z(Y);c[_[Y]]=M[B]-A[B]+1,r&&(o[_[Y]]-=A[B])}return T},O=(_,j,Z)=>{let H=Xn(l[_]-s[_],j);for(let z=0;z<=Ws;z++){let C=z/Ws,S=1-C;Z[2*z]=s[_]+(l[_]-s[_])*C*C*(3-2*C),Z[2*z+1]=j*(3*H*C*S*S+3*(1-H)*C*C*S+C*C*C)}},W=(_,j,Z)=>{let H=Z*Z*1.000000001;for(let z=0;z<=Ws;z++){let C=_[2*z],S=_[2*z+1];for(let $=0;$<Ws;$++){let y=j[2*$+2]-j[2*$],E=j[2*$+3]-j[2*$+1],x=Math.max(0,Math.min(1,((C-j[2*$])*y+(S-j[2*$+1])*E)/(y*y+E*E||1))),T=C-j[2*$]-x*y,A=S-j[2*$+1]-x*E;if(T*T+A*A<H&&Math.hypot(T,A)<Z)return!0}}return!1},U=(_,j,Z,H)=>{let z=Math.max(Z/2,Z-2*PA);return O(_,z,wd),O(j,z,bd),W(wd,bd,H)||W(bd,wd,H)};for(let[_,j]of d){if(!r){t[_]=N(j);continue}if(j.length>U0)continue;let Z=j.filter(x=>f[x]===1);N(Z);let H=new Set(Z.filter(x=>c[x]>1)),z=I(j);for(let x=0;x<z.length;x+=2){let T=j[z[x]],A=j[z[x+1]];H.has(T)&&H.has(A)||!v(T,A)||s[T]<l[T]!=s[A]<l[A]||U(T,A,a[_],f[T]===1||f[A]===1?zA:FA)&&H.add(T).add(A)}for(let x of Z)o[x]=-1,c[x]=0;if(H.size===0)continue;let C=0,S=0,$=new Set;for(let x=0;x<z.length;x+=2){let T=j[z[x]],A=j[z[x+1]];if(H.has(T)&&H.has(A)){if(!w(T,A))continue;s[T]<l[T]!=s[A]<l[A]?C++:b(T,A)||S++}else(H.has(T)||H.has(A))&&k(T,A)&&$.add(T).add(A)}if(C>S){for(let x of j)(u[x]-g[x])*H0>i[_]&&(i[_]=(u[x]-g[x])*H0);continue}let y=j.filter(x=>H.has(x)||f[x]!==1&&$.has(x));N(y);let E=0;for(let x of y)c[x]>E&&(E=c[x]);t[_]=E}}function XA(e,t,r,a,i,s,l){let{maxRank:n,EF:o,ET:c,EFD:f,ETD:p,succStart:d,succE:g,predStart:u,predE:m,layerStart:b,order:w}=e,v=new Float64Array(t.length),k=new Float64Array(t.length),L=new Float64Array(t.length);for(let N=0;N<a.length;N++){let O=a[N];if(O<0)continue;let W=O+i[N]-1,U=e.RANK[O];for(let _=O;_<W;_++){if(!r[U+_-O])continue;let j=_;for(;j+1<W&&r[U+j+1-O];)j++;let Z=m[u[_]],H=g[d[j]],z=t[o[Z]]+f[Z],C=t[c[H]]+p[H],S=j-_+2;for(let $=_;$<=j;$++)v[$]=z+(C-z)*($-_+1)/S,k[$]=z,L[$]=C;_=j}}let I=[];for(let N=1;N<n;N++){if(!r[N])continue;let O=b[N],W=b[N+1],U=Array.from(w.subarray(O,W)).sort((_,j)=>k[_]-k[j]||L[_]-L[j]||_-j);for(let _=0;_<U.length;){I.length=0;let j=_;for(;j<U.length&&Math.abs(k[U[j]]-k[U[_]])<1&&Math.abs(L[U[j]]-L[U[_]])<1;j++)I.push(U[j]);I.sort((Z,H)=>e.pos[Z]-e.pos[H]);for(let Z=0;Z<I.length;Z++){let H=I[Z];t[H]=v[H]+(Z-(I.length-1)/2)*s,(I.length===1||s===0)&&(l[H]=1)}_=j}}}function KA(e,t,r,a,i,s){let{maxRank:l,W:n,KIND:o,RANK:c,EF:f,ET:p,EFD:d,ETD:g,succStart:u,succE:m,predStart:b,predE:w,layerStart:v,order:k}=e,L=new Uint8Array(l+1),I=!1;for(let N=1;N<l;N++){let O=!1,W=!1;for(let U=v[N];U<v[N+1];U++){let _=o[k[U]];_===2?O=!0:_!==1&&(W=!0)}O&&!W&&(L[N]=1,I=!0)}if(I)for(let N=0;N<r.length;N++){let O=r[N];if(!(O<0))for(let W=O,U=O+a[N]-1;W<U;W++){if(o[W]!==1||!L[c[W]])continue;let _=W,j=W;for(;_>O&&s[_-1];)_--;for(;j+1<U&&s[j+1];)j++;let Z=w[b[_]],H=m[u[j]],z=t[f[Z]]+d[Z],C=t[p[H]]+g[H],S=Math.min(z,C)-i,$=Math.max(z,C)+i,y=!0,E=c[W];for(let T=v[E];y&&T<v[E+1];T++){let A=k[T];o[A]===2&&t[A]+n[A]/2>S&&t[A]-n[A]/2<$&&(y=!1)}if(!y)continue;s[W]=1;let x=j-_+2;for(let T=_;T<=j;T++)t[T]=z+(C-z)*(T-_+1)/x}}}function ZA(e,t){let{n:r,real:a,maxRank:i,W:s,EF:l,ET:n,EFD:o,ETD:c,succStart:f,succE:p,predStart:d,predE:g,layerStart:u,order:m,pos:b,offsets:w,fixed:v,GRP:k,groupParent:L}=e,I=0;for(let ie=0;ie<=i;ie++)I=Math.max(I,u[ie+1]-u[ie]);if(I<2)return[0,0];let N=w?new Int32Array(l.length):void 0,O=new Int32Array(N?l.length:0),W=new Int32Array(N?r:0),U=N?p.slice():p,_=new Uint8Array(N?r:0);if(N){let ie=g.slice(),se=(ee,te,fe,ye)=>{for(let le=te+1;le<fe;le++)if(ye[ee[le]]!==ye[ee[te]])return ee.subarray(te,fe).sort((we,pe)=>ye[we]-ye[pe]),!0;return!1};for(let ee=0;ee<r;ee++){if(W[ee]=1,se(ie,d[ee],d[ee+1],c))for(let te=d[ee]+1;te<d[ee+1];te++)c[ie[te]]!==c[ie[te-1]]&&W[ee]++,O[ie[te]]=W[ee]-1;se(U,f[ee],f[ee+1],o)&&(_[ee]=1)}}let j=1;for(;j<(N?I+l.length:I);)j<<=1;let Z=new Int32Array(2*j),H=new Int32Array(l.length),z=()=>{let ie=0;for(let se=0;se<i;se++){let ee=u[se+2]-u[se+1];if(N){let ye=0;for(let le=u[se+1];le<u[se+2];le++){let we=m[le];for(let pe=d[we];pe<d[we+1];pe++)N[g[pe]]=ye+O[g[pe]];ye+=W[we]}ee=ye}if(ee<2)continue;let te=0;for(let ye=u[se];ye<u[se+1];ye++){let le=m[ye],we=f[le],pe=f[le+1],ge=te;for(let Se=we;Se<pe;Se++)H[te++]=N?N[U[Se]]:b[n[p[Se]]];let Ae=te-ge;if(!(Ae<2))if(N&&_[le])for(let Se=ge+1;Se<te;Se++){let oe=H[Se],ue=o[U[we+Se-ge]],xe=Se-1;for(;xe>=ge&&o[U[we+xe-ge]]===ue&&H[xe]>oe;)H[xe+1]=H[xe],xe--;H[xe+1]=oe}else if(Ae<=12)for(let Se=ge+1;Se<te;Se++){let oe=H[Se],ue=Se-1;for(;ue>=ge&&H[ue]>oe;)H[ue+1]=H[ue],ue--;H[ue+1]=oe}else H.subarray(ge,te).sort()}if(te<2)continue;let fe=1;for(;fe<ee;)fe<<=1;Z.fill(0,0,2*fe);for(let ye=0;ye<te;ye++){let le=H[ye]+fe;for(Z[le]++;le>1;)!(le&1)&&(ie+=Z[le+1]),le>>=1,Z[le]++}}return ie},C=z(),S=new Float64Array(r),$=new Int32Array(I),y=new Int32Array(I),E=L?L.length:0,x=new Int32Array(E);for(let ie=0;ie<E;ie++)for(let se=ie;se>=0;se=L[se])x[ie]++;let T=new Float64Array(E),A=new Int32Array(E),M=new Int32Array(E),Y=(ie,se)=>{let ee=u[ie],te=u[ie+1];for(let pe=ee;pe<te;pe++)for(let ge=k[m[pe]];ge>=0;ge=L[ge])T[ge]=0,A[ge]=0;for(let pe=ee;pe<te;pe++){let ge=m[pe];for(let Ae=k[ge];Ae>=0;Ae=L[Ae])A[Ae]===0&&(M[Ae]=pe),T[Ae]+=se[ge],A[Ae]++}let fe=pe=>pe>=r?T[pe-r]/A[pe-r]:se[pe],ye=pe=>pe>=r?M[pe-r]:ee+b[pe],le=(pe,ge)=>{let Ae=pe,Se=ge,oe=k[pe],ue=k[ge],xe=oe<0?0:x[oe],Ie=ue<0?0:x[ue];for(;xe>Ie;xe--)Ae=r+oe,oe=L[oe];for(;Ie>xe;Ie--)Se=r+ue,ue=L[ue];for(;oe!==ue;)Ae=r+oe,oe=L[oe],Se=r+ue,ue=L[ue];return fe(Ae)-fe(Se)||ye(Ae)-ye(Se)},we=Array.from(m.subarray(ee,te)).sort(le);m.set(we,ee);for(let pe=ee;pe<te;pe++)b[m[pe]]=pe-ee};if(k){let ie=new Float64Array(r);for(let se=0;se<=i;se++){for(let ee=u[se];ee<u[se+1];ee++)ie[m[ee]]=ee-u[se];Y(se,ie)}}let B=k?z():C;if(B===0)return[0,C];let q=m.slice(),D=Math.min(B,C),R=(ie,se)=>{let ee=ie?d:f,te=ie?g:p,fe=ie?l:n,ye=ie?o:c;for(let le=1;le<=i;le++){let we=ie?le:i-le;if(v[we])continue;let pe=u[we],ge=u[we+1],Ae=0;for(let oe=pe;oe<ge;oe++){let ue=m[oe],xe=ue<a?t[ue].pin:0;if(xe!==0){S[ue]=xe*1e9,$[Ae++]=ue;continue}let Ie=ee[ue],Le=ee[ue+1];if(Ie===Le){if(k){let he=ie?u[we]-u[we-1]:u[we+2]-u[we+1];S[ue]=(oe-pe)*he/(ge-pe);continue}S[ue]=-1;continue}let We=0;for(let he=Ie;he<Le;he++){let ke=fe[te[he]];We+=b[ke],w&&s[ke]>0&&(We+=ye[te[he]]/s[ke])}S[ue]=We/(Le-Ie),$[Ae++]=ue}if(k){Y(we,S);continue}if(Ae<2)continue;BA($,Ae,S,b,se,y);let Se=0;for(let oe=pe;oe<ge;oe++)S[m[oe]]!==-1&&(m[oe]=$[Se++]);for(let oe=pe;oe<ge;oe++)b[m[oe]]=oe-pe}},P=()=>{let ie=0;for(let se=0;se<=i;se++)for(let ee=u[se];ee<u[se+1];ee++)if(!(m[ee]>=a))for(let te=ee+1;te<u[se+1];te++)m[te]<m[ee]&&ie++;return ie},G=()=>{for(let ie=0;ie<=i;ie++)for(let se=u[ie];se<u[ie+1];se++)b[m[se]]=se-u[ie]},X=ie=>ie<a?t[ie].pin:0,Q=(ie,se)=>{let ee=se?l[ie]:n[ie];return w&&s[ee]>0?b[ee]+(se?o[ie]:c[ie])/s[ee]:b[ee]},J=(ie,se)=>{let ee=0;for(let te=d[ie];te<d[ie+1];te++){let fe=Q(g[te],!0);for(let ye=d[se];ye<d[se+1];ye++)fe>Q(g[ye],!0)&&ee++}for(let te=f[ie];te<f[ie+1];te++){let fe=Q(p[te],!1);for(let ye=f[se];ye<f[se+1];ye++)fe>Q(p[ye],!1)&&ee++}return ee},F=()=>{for(let ie=0;ie<8;ie++){let se=!1;for(let ee=0;ee<=i;ee++){if(v[ee])continue;let te=u[ee];for(let fe=te;fe+1<u[ee+1];fe++){let ye=m[fe],le=m[fe+1];X(ye)!==X(le)||k&&k[ye]!==k[le]||J(le,ye)>=J(ye,le)||(m[fe]=le,m[fe+1]=ye,b[le]=fe-te,b[ye]=fe+1-te,se=!0)}}if(!se)break}},K=m.slice(),re=r<=600,ne=q,de=1/0;for(let ie=0;ie<(re?2:1);ie++){ie>0&&(m.set(K),G());let se=D,ee=K.slice();for(let fe=0,ye=0;ye<4&&fe<_A;fe++,ye++){R((fe+ie)%2===0,fe%4>=2);let le=z();if(le<se&&(se=le,ee.set(m),ye=0,le===0))break}if(m.set(ee),re&&se>0){G(),F();let fe=z();fe<se&&(se=fe,ee.set(m))}let te=re?P():0;(ie===0||se<B||se===B&&te<de)&&(B=se,ne=ee,de=te)}if(m.set(ne),G(),q.set(ne),k&&(B=z()),!re)return[B,C];for(let ie=0;ie<a;ie++)if(t[ie].pin!==0)return[B,C];if(de===0||v[0]||v[i])return[B,C];for(let ie=0;ie<=i;ie++)m.subarray(u[ie],u[ie+1]).reverse();return G(),(z()>B||P()>=de)&&m.set(q),[B,C]}function V0(e,t,r){return e.W[r]/2+(e.KIND[r]===0?t.nodeSep:t.edgeSep)/2}function G0(e,t){let{n:r,maxRank:a,W:i,KIND:s,EF:l,ET:n,EFD:o,ETD:c,succStart:f,succE:p,predStart:d,predE:g,layerStart:u,order:m,pos:b}=e,w=l.length,v=new Float64Array(r);for(let M=0;M<r;M++)v[M]=V0(e,t,M);let k=new Int32Array(w);for(let M=0;M<w;M++)k[M]=b[n[M]];for(let M=0;M<r;M++)f[M+1]-f[M]>1&&q0(p,f[M],f[M+1],k);for(let M=0;M<w;M++)k[M]=b[l[M]];for(let M=0;M<r;M++)d[M+1]-d[M]>1&&q0(g,d[M],d[M+1],k);let L=new Uint8Array(w);for(let M=1;M<=a;M++){let Y=u[M]-u[M-1],B=u[M],q=u[M+1],D=0,R=B;for(let P=B;P<q;P++){let G=m[P],X=-1;if(Bs(s[G])){let J=l[g[d[G]]];Bs(s[J])&&(X=J)}let Q=X>=0?b[X]:Y;if(X>=0||P===q-1){for(let J=R;J<=P;J++){let F=m[J],K=Bs(s[F]);for(let re=d[F];re<d[F+1];re++){let ne=g[re],de=b[l[ne]];(de<D||Q<de)&&!(K&&Bs(s[l[ne]]))&&(L[ne]=1)}}R=P+1,D=Q}}}let I=[],N=new Int32Array(r),O=new Int32Array(r),W=new Float64Array(r),U=new Int32Array(r),_=new Int32Array(r),j=new Float64Array(r),Z=new Int32Array(r),H=new Int32Array(r+1),z=new Int32Array(r),C=new Int32Array(r),S=new Int32Array(r),$=new Float64Array(r);for(let M=0;M<4;M++){let Y=M<2,B=(M&1)===1,q=Y?d:f,D=Y?g:p,R=Y?l:n,P=Y?c:o,G=Y?o:c;for(let F=0;F<r;F++)N[F]=F,O[F]=F,W[F]=0,Z[F]=0,H[F+1]=0,$[F]=0;for(let F=0;F<=a;F++){let K=Y?F:a-F,re=u[K],ne=u[K+1],de=Y?K-1:K+1,ie=de>=0&&de<=a?u[de+1]-u[de]-1:0,se=-1;for(let ee=B?ne-1:re;B?ee>=re:ee<ne;B?ee--:ee++){let te=m[ee],fe=q[te],ye=q[te+1]-fe;if(ye===0)continue;let le=fe+(ye-1>>1),we=fe+(ye>>1);for(let pe=0;pe<2&&!(pe===1&&le===we);pe++){let ge=D[pe===0!==B?le:we],Ae=R[ge],Se=B?ie-b[Ae]:b[Ae];O[te]===te&&se<Se&&L[ge]===0&&(O[Ae]=te,O[te]=N[te]=N[Ae],W[te]=W[Ae]+G[ge]-P[ge],se=Se)}}}let X=0;for(let F=0;F<=a;F++){let K=u[F],re=u[F+1];for(let ne=K+1;ne<re;ne++){let de=B?m[ne]:m[ne-1],ie=B?m[ne-1]:m[ne],se=v[de]+v[ie];U[X]=N[de],_[X]=N[ie],j[X]=B?se-W[de]+W[ie]:se+W[de]-W[ie],Z[N[ie]]++,H[N[de]+1]++,X++}}for(let F=0;F<r;F++)H[F+1]+=H[F];for(let F=0;F<r;F++)C[F]=H[F];for(let F=0;F<X;F++)z[C[U[F]]++]=F;let Q=0;for(let F=0;F<r;F++)N[F]===F&&Z[F]===0&&(S[Q++]=F);for(let F=0;F<Q;F++){let K=S[F];for(let re=H[K];re<H[K+1];re++){let ne=z[re],de=_[ne];$[K]+j[ne]>$[de]&&($[de]=$[K]+j[ne]),--Z[de]===0&&(S[Q++]=de)}}for(let F=Q-1;F>=0;F--){let K=S[F],re=1/0;for(let ne=H[K];ne<H[K+1];ne++){let de=z[ne],ie=$[_[de]]-j[de];ie<re&&(re=ie)}re!==1/0&&re>$[K]&&($[K]=re)}let J=new Float64Array(r);for(let F=0;F<r;F++)J[F]=(B?-$[N[F]]:$[N[F]])+W[F];I.push(J)}let y=0,E=1/0,x=[],T=[];for(let M=0;M<4;M++){let Y=1/0,B=-1/0,q=I[M];for(let D=0;D<r;D++){let R=i[D]/2;q[D]-R<Y&&(Y=q[D]-R),q[D]+R>B&&(B=q[D]+R)}x.push(Y),T.push(B),B-Y<E&&(E=B-Y,y=M)}for(let M=0;M<4;M++){let Y=M&1?T[y]-T[M]:x[y]-x[M];if(Y!==0){let B=I[M];for(let q=0;q<r;q++)B[q]+=Y}}let A=new Float64Array(r);for(let M=0;M<r;M++){let Y=I[0][M],B=I[1][M],q=I[2][M],D=I[3][M],R;Y>B&&(R=Y,Y=B,B=R),q>D&&(R=q,q=D,D=R),Y>q&&(R=Y,Y=q,q=R),B>D&&(R=B,B=D,D=R),B>q&&(R=B,B=q,q=R),A[M]=(B+q)/2}return A}function ko(){let e=new Map;return{add(t,r,a){let i=gt(a);r>=0&&i>0&&i+Gn>(e.get(t*4+r)??0)&&e.set(t*4+r,i+Gn)},of:(t,r)=>r>=0?e.get(t*4+r)??0:0}}function zr(e,t,r,a,i=r>0?r+Gn:0,s=a>0?a+Gn:0){let l=t==="linear",n=t==="step"||t==="stepBefore"||t==="stepAfter",o=[],c=[],f=[],p=(y,E,x,T)=>Math.abs(y-x)<.01&&Math.abs(E-T)<.01;for(let y=0;y<e.length;y+=3){let E=e[y],x=e[y+1],T=e[y+2],A=o.length-1;if(n&&A>=0&&Math.abs(E-o[A])>=.01&&Math.abs(x-c[A])>=.01){let M=o[A],Y=c[A],B=t==="stepBefore"?Y:t==="stepAfter"?x:(Y+x)/2,q=t==="stepBefore"?M:t==="stepAfter"?E:(M+E)/2,D=T===0?[M,B,E,B]:[q,Y,q,x];for(let R=0;R<4;R+=2)p(D[R],D[R+1],M,Y)||p(D[R],D[R+1],E,x)||(o.push(D[R]),c.push(D[R+1]),f.push(T))}o.push(E),c.push(x),f.push(T)}let d=o.length-1,g=y=>Math.abs(o[y]-o[y-1])<.01||Math.abs(c[y]-c[y-1])<.01,u=y=>l||g(y),m=(y,E,x)=>{if(!u(Math.max(y,E)))return x===0?[0,Math.sign(c[E]-c[y])||1]:[Math.sign(o[E]-o[y])||1,0];let T=o[E]-o[y],A=c[E]-c[y],M=Math.hypot(T,A)||1;return[T/M,A/M]},[b,w]=m(0,1,f[1]),[v,k]=m(d-1,d,f[d]),L=o[0],I=c[0],N=o[d],O=c[d];o[0]+=b*r,c[0]+=w*r,o[d]-=v*a,c[d]-=k*a;let W=y=>Math.abs(o[y]-o[y-1])+Math.abs(c[y]-c[y-1]),U=y=>!l&&y>0&&y<d&&g(y)&&g(y+1)&&W(y)>=.01&&W(y+1)>=.01&&Math.abs(o[y]-o[y-1])<.01!=Math.abs(o[y+1]-o[y])<.01,_=(y,E,x)=>Math.abs(o[y]-o[y-1])*Math.abs(E)+Math.abs(c[y]-c[y-1])*Math.abs(x),j=(y,E,x)=>{let T=Math.min(Math.max(0,y-Gn-E),x/4);return T+Math.min(y-E-T,(x-T)/4)},Z=s>a&&(!u(d)||U(d-1))?j(s,a,_(d,v,k)):0,H=i>r&&(!u(1)||U(1))?j(i,r,_(1,b,w)):0;Z>=1&&(o.splice(d,0,o[d]-v*Z),c.splice(d,0,c[d]-k*Z),f.splice(d,0,f[d]),d++),H>=1&&(o.splice(1,0,o[0]+b*H),c.splice(1,0,c[0]+w*H),f.splice(1,0,f[1]),d++);let z=`M${h(o[0])},${h(c[0])}`,C=o[0],S=c[0],$=(y,E)=>{p(y,E,C,S)||(z+=`L${h(y)},${h(E)}`,C=y,S=E)};for(let y=1;y<=d;y++){let E=o[y],x=c[y];if(!u(y)){let D=f[y]===0,R=D?x-S:E-C,P=Math.abs(R)*Xn(D?E-C:x-S,R),G=D?0:Math.sign(R)*P,X=D?Math.sign(R)*P:0;z+=`C${h(C+G)},${h(S+X)} ${h(E-G)},${h(x-X)} ${h(E)},${h(x)}`,C=E,S=x;continue}if(!U(y)){if(y<d&&g(y)&&g(y+1)&&(E-o[y-1])*(o[y+1]-E)+(x-c[y-1])*(c[y+1]-x)>0)continue;$(E,x);continue}let T=U(y-1)?W(y)/2:W(y),A=U(y+1)?W(y+1)/2:W(y+1);n&&(T=A=Math.min(QA,T,A));let[M,Y]=m(y-1,y,f[y]),[B,q]=m(y,y+1,f[y+1]);$(E-M*T,x-Y*T),C=E+B*A,S=x+q*A,n?z+=`Q${h(E)},${h(x)} ${h(C)},${h(S)}`:z+=`C${h(E-M*T*(1-wo))},${h(x-Y*T*(1-wo))} ${h(E+B*A*(1-wo))},${h(x+q*A*(1-wo))} ${h(C)},${h(S)}`}return{d:z,sx:L,sy:I,sdx:-b,sdy:-w,ex:N,ey:O,edx:v,edy:k}}function gt(e){return e==="arrow_point"?Ht-1:e==="arrow_circle"?Ht:e==="arrow_cross"?4:0}function bt(e,t,r,a,i,s){let l=-i,n=a;if(e==="arrow_point"){let o=t-a*Ht,c=r-i*Ht,f=Ht*.42;return`<path class="pele-marker" d="M${h(t)},${h(r)}L${h(o+l*f)},${h(c+n*f)}L${h(o-l*f)},${h(c-n*f)}Z" fill="${s}" stroke="none"/>`}if(e==="arrow_circle")return`<circle class="pele-marker" cx="${h(t-a*4)}" cy="${h(r-i*4)}" r="3.5" fill="${s}" stroke="none"/>`;if(e==="arrow_cross"){let o=t-a*4,c=r-i*4,f=3.5,p=(a+l)*f,d=(i+n)*f,g=(a-l)*f,u=(i-n)*f;return`<path class="pele-marker" d="M${h(o-p)},${h(c-d)}L${h(o+p)},${h(c+d)}M${h(o-g)},${h(c-u)}L${h(o+g)},${h(c+u)}"/>`}return""}function wr(e,t,r,a,i,s){let l=t.width+8,n=t.height;return`<g class="pele-edge-label" data-id="${Oe(e)}"><rect x="${h(r-l/2)}" y="${h(a-n/2)}" width="${h(l)}" height="${h(n)}" rx="3" fill="var(--_bg)"/>`+Re(t,r,a,i,s)+"</g>"}function Mo(e,t,r,a,i,s,l,n){let o=(i?t:r)/2,c=Math.min(o-4,8+a*6),f=s+a*8,p=Math.hypot(f,c)||1,d=(m,b)=>i?`${h(e.x+b)},${h(e.y+r/2+m)}`:`${h(e.x+t/2+m)},${h(e.y+b)}`,g=f/p*l,u=c/p*l;return i?(n.labelX=e.x,n.labelY=e.y+r/2+f+4+n.labelH/2):(n.labelX=e.x+t/2+f+4+n.labelW/2,n.labelY=e.y),{d:`M${d(0,-c)}C${d(f,-c*2)} ${d(f,c*2)} ${d(g,c+u)}`,sx:i?e.x-c:e.x+t/2,sy:i?e.y+r/2:e.y-c,sdx:i?0:-1,sdy:i?-1:0,ex:i?e.x+c:e.x+t/2,ey:i?e.y+r/2:e.y+c,edx:i?-c/p:-f/p,edy:i?-f/p:-c/p}}var _A,z0,$d,F0,IA,W0,NA,RA,LA,DA,OA,B0,PA,zA,FA,H0,qa,Y0,WA,U0,Ws,wd,bd,Ht,QA,wo,Gn,pr=Ve(()=>{ut();_A=24,z0=2e4,$d=16,F0=8,IA=.125,W0=3,NA=18,RA=10,LA=14,DA=2,OA=28,B0=12,PA=12,zA=8,FA=4,H0=.5,qa=.5,Y0=12,WA=40,U0=400,Ws=16,wd=new Float64Array(2*Ws+2),bd=new Float64Array(2*Ws+2);Ht=8,QA=12,wo=.62,Gn=6});function br(e){return e==="BT"||e==="LR"||e==="RL"?e:"TB"}function X0(e,t,r,a){let i=[];for(let n of e)i.push(n.x,n.y,n.w,n.h);let s=[];for(let n of t)s.push(n.labelX,n.labelY);let l=[];for(let n of r){l.push(n.x,n.y);for(let o of n.ports)l.push(o.px,o.py)}return{nodes:i,routes:t.map(n=>n.route),labels:s,levels:l,total:a}}function K0(e,t,r,a){t.forEach((s,l)=>{s.x=e.nodes[4*l],s.y=e.nodes[4*l+1],s.w=e.nodes[4*l+2],s.h=e.nodes[4*l+3]}),r.forEach((s,l)=>{s.route=e.routes[l],s.labelX=e.labels[2*l],s.labelY=e.labels[2*l+1]});let i=0;for(let s of a){s.x=e.levels[i++],s.y=e.levels[i++];for(let l of s.ports)l.px=e.levels[i++],l.py=e.levels[i++]}return e.total}function nv(e){return e.tracks?1:e.straight?2:0}function vo(e,t,r=0){let a=0;for(let C of t)C.src!==C.dst&&C.route.length>3&&(a+=(C.route.length/3-1)*iv);let i=new Float64Array(a),s=new Float64Array(a),l=new Float64Array(a),n=new Float64Array(a),o=new Float64Array(a),c=new Float64Array(a),f=new Int32Array(a),p=new Uint8Array(a),d=0,g=1/0,u=-1/0,m=NaN,b=NaN,w=NaN,v=NaN,k=(C,S,$,y,E,x)=>{let T=d-1;$===w&&y===v&&(x===y&&b===y||E===$&&m===$)&&f[T]===C&&p[T]===S&&($-m)*(E-$)+(y-b)*(x-y)>0&&(d--,$=m,y=b),m=$,b=y,w=E,v=x,p[d]=S,i[d]=Math.min($,E),l[d]=Math.max($,E),s[d]=$<=E?y:x,n[d]=$<=E?x:y,o[d]=Math.min(y,x),c[d]=Math.max(y,x),o[d]<g&&(g=o[d]),c[d]>u&&(u=c[d]),f[d++]=C};for(let C=0;C<t.length;C++){let S=t[C];if(S.src===S.dst)continue;let $=S.route,y=M=>Math.abs($[M]-$[M-3])<.01||Math.abs($[M+1]-$[M-2])<.01,E=M=>Math.abs($[M]-$[M-3])+Math.abs($[M+1]-$[M-2]),x=M=>r===0&&M>0&&M<$.length-3&&y(M)&&y(M+3)&&E(M)>=.01&&E(M+3)>=.01&&Math.abs($[M]-$[M-3])<.01!=Math.abs($[M+3]-$[M])<.01,T=$[0],A=$[1];for(let M=3;M<$.length;M+=3){let Y=(M===3?1:0)|(M===$.length-3?2:0),B=T,q=A,D=$[M],R=$[M+1];if(T=D,A=R,y(M)||r===2){if(!x(M)){k(C,Y,B,q,D,R);continue}let J=x(M-3)?E(M)/2:E(M),F=x(M+3)?E(M+3)/2:E(M+3),K=(D-$[M-3])/E(M),re=(R-$[M-2])/E(M),ne=($[M+3]-D)/E(M+3),de=($[M+4]-R)/E(M+3),ie=D-K*J,se=R-re*J;k(C,Y,B,q,ie,se);let ee=D-K*J*(1-Ao),te=R-re*J*(1-Ao),fe=D+ne*F*(1-Ao),ye=R+de*F*(1-Ao);T=D+ne*F,A=R+de*F;let le=Y|(M+3===$.length-3?2:0),we=ie,pe=se;for(let ge=1;ge<=Md;ge++){let Ae=ge/Md,Se=1-Ae,oe=Se*Se*Se*ie+3*Se*Se*Ae*ee+3*Se*Ae*Ae*fe+Ae*Ae*Ae*T,ue=Se*Se*Se*se+3*Se*Se*Ae*te+3*Se*Ae*Ae*ye+Ae*Ae*Ae*A;k(C,le,we,pe,oe,ue),we=oe,pe=ue}continue}if(r===1){let J=$[M+2]===0,F=J?B:(B+D)/2,K=J?(q+R)/2:q;k(C,Y,B,q,F,K),k(C,Y,F,K,J?D:F,J?K:R),k(C,Y,J?D:F,J?K:R,D,R);continue}let P=$[M+2]===0,G=P?Xn(D-B,R-q):Xn(R-q,D-B),X=B,Q=q;for(let J=1;J<=kd;J++){let F=J/kd,K=1-F,re=F*F*(3-2*F),ne=3*G*F*K*K+3*(1-G)*F*F*K+F*F*F,de=B+(D-B)*(P?re:ne),ie=q+(R-q)*(P?ne:re);k(C,Y,X,Q,de,ie),X=de,Q=ie}}}let L=u>g?Math.round(Math.sqrt(d)):1,I=u>g?L/(u-g):0,N=C=>Math.min(L-1,Math.floor((C-g)*I)),O=new Int32Array(d),W=new Int32Array(L+1);for(let C=0;C<d;C++){O[C]=N(o[C]);for(let S=O[C],$=N(c[C]);S<=$;S++)W[S+1]++}for(let C=0;C<L;C++)W[C+1]+=W[C];let U=W.slice(0,L),_=new Int32Array(W[L]);for(let C=0;C<d;C++)for(let S=O[C],$=N(c[C]);S<=$;S++)_[U[S]++]=C;let j=new Float64Array(t.length*8),Z=(C,S,$,y)=>Math.abs(C[S]-C[$])<Hs&&Math.abs(C[S]-C[y])<Hs||Math.abs(C[S+1]-C[$+1])<Hs&&Math.abs(C[S+1]-C[y+1])<Hs;for(let C=0;C<t.length;C++){let S=t[C].route;if(S.length<6)continue;let $=3;for(;$+3<S.length&&Z(S,0,$,$+3);)$+=3;let y=S.length-3,E=y-3;for(;E>=3&&Z(S,y,E,E-3);)E-=3;j.set([S[0],S[1],S[$],S[$+1],S[E],S[E+1],S[y],S[y+1]],C*8)}let H=(C,S,$,y)=>{let E=C*8+(S===1?0:4),x=j[E],T=j[E+1],A=j[E+2]-x,M=j[E+3]-T,Y=A*A+M*M,B=Y>0?Math.max(0,Math.min(1,(($-x)*A+(y-T)*M)/Y)):0;return Math.hypot($-x-B*A,y-T-B*M)<Hs},z=0;for(let C=0;C<L;C++){let S=W[C+1];if(S-W[C]>sv)_.subarray(W[C],S).sort(($,y)=>i[$]-i[y]||$-y);else for(let $=W[C]+1;$<S;$++){let y=_[$],E=$;for(;E>W[C]&&i[_[E-1]]>i[y];E--)_[E]=_[E-1];_[E]=y}for(let $=W[C];$<S;$++){let y=_[$],E=l[y]-i[y],x=n[y]-s[y],T=O[y]===C;for(let A=$+1;A<S;A++){let M=_[A];if(i[M]>l[y])break;if(c[M]<o[y]||o[M]>c[y]||f[y]===f[M]||!T&&O[M]!==C)continue;let Y=E*(s[M]-s[y])-x*(i[M]-i[y]),B=E*(n[M]-s[y])-x*(l[M]-i[y]);if(Y>0==B>0)continue;let q=l[M]-i[M],D=n[M]-s[M],R=q*(s[y]-s[M])-D*(i[y]-i[M]),P=q*(n[y]-s[M])-D*(l[y]-i[M]);if(R>0==P>0)continue;let G=t[f[y]],X=t[f[M]],Q=R/(R-P),J=i[y]+Q*E,F=s[y]+Q*x,K=(re,ne,de)=>(p[y]&ne)!==0&&(p[M]&de)!==0||Math.abs(J-e[re].x)<e[re].w/2+Z0&&Math.abs(F-e[re].y)<e[re].h/2+Z0||H(f[y],ne,J,F)&&H(f[M],de,J,F);G.src===X.src&&K(G.src,1,1)||G.src===X.dst&&K(G.src,1,2)||G.dst===X.src&&K(G.dst,2,1)||G.dst===X.dst&&K(G.dst,2,2)||z++}}}return z}function vi(e,t,r,a){for(let i of e)i.x+=r,i.y+=a;for(let i of t){for(let s=0;s<i.route.length;s+=3)i.route[s]+=r,i.route[s+1]+=a;i.labelX+=r,i.labelY+=a}}function Ut(e,t,r=-1){return{w:e,h:t,parent:r,isGroup:!1,dir:void 0,padX:0,padTop:0,padBottom:0,minW:0,seq:0,span:0,x:0,y:0}}function Eo(e){return e==="TB"?0:e==="BT"?2:e==="LR"?3:1}function Kn(e){return e+2&3}function Gr(e,t,r,a){let i=e.length,s=new Map,l=[],n=(S,$)=>{let y={id:S,dir:$,items:[],edges:[],ports:[],portOf:new Map,routes:new Map,x:0,y:0};return s.set(S,y),y},o=n(-1,r),c=[];for(let S=0;S<i;S++)c.push([]);let f=[];for(let S=0;S<i;S++){let $=e[S].parent;$>=0&&$<i&&$!==S&&e[$].isGroup?c[$].push(S):(e[S].parent=-1,f.push(S))}o.items=f,l.push(o);let p=new Int32Array(i),d=new Uint8Array(i),g=S=>{for(let $=S;$<l.length;$++){let y=l[$];for(let E of y.items)if(d[E]=1,p[E]=y.id<0?0:p[y.id]+1,e[E].isGroup){let x=n(E,e[E].dir??y.dir);x.items=c[E],l.push(x)}}};g(0);for(let S=0;S<i;S++){if(d[S])continue;let $=e[S].parent;if(c[$]=c[$].filter(y=>y!==S),e[S].parent=-1,o.items.push(S),d[S]=1,p[S]=0,e[S].isGroup){let y=l.length,E=n(S,e[S].dir??r);E.items=c[S],l.push(E),g(y)}}for(let S=l.length-1;S>0;S--){let $=l[S],y=1/0;for(let E of $.items)e[E].seq<y&&(y=e[E].seq);y!==1/0&&(e[$.id].seq=y)}for(let S of l)S.items.sort(($,y)=>e[$].seq-e[y].seq||$-y);let u=0;for(let S of t){let $=S.src,y=S.dst,E=0;for(;p[$]>p[y];E++)$=e[$].parent;for(;p[y]>p[$];E++)y=e[y].parent;for(;$!==y&&e[$].parent!==e[y].parent;E+=2)$=e[$].parent,y=e[y].parent;$!==y&&(u+E>JA?(S.src=$,S.dst=y):u+=E)}let m=[],b=[];for(let S=0;S<t.length;S++){let $=t[S];if($.route=[],$.src===$.dst){m.push(S);continue}let y=$.src,E=$.dst,x=[],T=[];for(;p[y]>p[E];)x.push(y),y=e[y].parent;for(;p[E]>p[y];)T.push(E),E=e[E].parent;if(y===E){b.push(S);continue}for(;e[y].parent!==e[E].parent;)x.push(y),T.push(E),y=e[y].parent,E=e[E].parent;s.get(e[y].parent).edges.push({e:S,a:y,b:E});for(let[A,M]of[[x,!0],[T,!1]])for(let Y of A){let B=s.get(e[Y].parent),q={e:S,inner:Y,out:M,side:0,hint:NaN,px:0,py:0,route:[]};B.ports.push(q),B.portOf.set(S*2+(M?0:1),q)}}let w=new Int32Array(i),v=(S,$,y)=>(y?$.src:$.dst)!==S,k=(S,$)=>{let y=S.dir==="TB"||S.dir==="BT",E=Eo(S.dir),x=[],T=[];S.items.forEach((B,q)=>{w[B]=q;let D=e[B],R=$?Zi(y?D.w:D.h,y?D.h:D.w):Zi(0,0);R.span=D.isGroup?Math.min(D.span,R.w-2*D.padX):D.span,R.key=N?I[B]:NaN,x.push(R)});let A=(B,q,D)=>e[B].isGroup&&v(B,t[q],D),M=(B,q,D)=>{if(!$||!e[B].isGroup||!v(B,t[q],D))return 0;let R=s.get(B).portOf.get(q*2+(D?0:1));return y?R.px-e[B].w/2:R.py-e[B].h/2};for(let B of S.edges){let q=t[B.e],D=Qi(w[B.a],w[B.b],q.minlen);$&&(D.labelW=y?q.labelW:q.labelH,D.labelH=y?q.labelH:q.labelW,D.tailDx=M(B.a,B.e,!0),D.headDx=M(B.b,B.e,!1),D.tailFixed=A(B.a,B.e,!0),D.headFixed=A(B.b,B.e,!1)),T.push(D)}let Y=new Int32Array(S.ports.length).fill(-1);return S.ports.forEach((B,q)=>{if(B.side===E||B.side===Kn(E)){let D=x.length,R=Zi(0,0,B.side===E?3:4);R.key=N?I[B.out?t[B.e].dst:t[B.e].src]:NaN,R.hint=Number.isNaN(B.hint)&&N&&W?W(S,B):B.hint,x.push(R),Y[q]=D;let P=B.out?Qi(w[B.inner],D):Qi(D,w[B.inner]);B.out?(P.tailDx=M(B.inner,B.e,!0),P.tailFixed=A(B.inner,B.e,!0)):(P.headDx=M(B.inner,B.e,!1),P.headFixed=A(B.inner,B.e,!1)),T.push(P)}else x[w[B.inner]].pin=B.side===0||B.side===3?-1:1}),{lnodes:x,ledges:T,dummies:Y}},L=u>1&&u<=ev&&t.length<=tv,I=new Float64Array(i).fill(NaN),N=!1,O=0,W,U=l.length>1&&L;for(let S of l)S.dir!==r&&(U=!1);if(U){let S=r==="TB"||r==="BT",$=new Int32Array(i).fill(-1),y=new Int32Array(i).fill(-1),E=[],x=[],T=[];for(let R=0;R<i;R++)e[R].isGroup&&(y[R]=T.length,T.push(-1));for(let R=0;R<i;R++){let P=e[R].parent;e[R].isGroup?T[y[R]]=P>=0?y[P]:-1:($[R]=E.length,E.push(Zi(S?e[R].w:e[R].h,S?e[R].h:e[R].w)),x.push(P>=0?y[P]:-1))}let A=[],M=new Int32Array(t.length).fill(-1);t.forEach((R,P)=>{R.src===R.dst||$[R.src]<0||$[R.dst]<0||(M[P]=A.length,A.push(Qi($[R.src],$[R.dst],R.minlen,S?R.labelW:R.labelH,S?R.labelH:R.labelW)))});let Y=$o(E,A,{...a,groups:{of:Int32Array.from(x),parent:Int32Array.from(T)},orderOnly:!0});O=Math.min(Y.crossings??0,Y.declared??0);let B=new Float64Array(i),q=new Int32Array(i),D=new Int32Array(i).fill(-1);for(let R=0;R<i;R++)if(!($[R]<0)){I[R]=E[$[R]].x;for(let P=e[R].parent;P>=0;P=e[P].parent)B[P]+=I[R],q[P]++,D[P]=Math.max(D[P],E[$[R]].rank)}for(let R=0;R<i;R++)q[R]>0&&(I[R]=B[R]/q[R]);W=(R,P)=>{let G=M[P.e];if(G<0||R.id<0||!P.out||P.side!==Kn(Eo(R.dir)))return NaN;let X=A[G].points,Q=I[t[P.e].src],J=0;for(let F=0;F<X.length;F+=2)X[F]===D[R.id]&&(Q=X[F+1]),X[F]===D[R.id]+1&&(J=X[F+1]);return Q+J*1e-6}}let _=new Map,j=(S,$,y)=>{if(!L)return{lnodes:$,ledges:y,size:$o($,y,a)};let E=[];for(let A of $)E.push(A.w,A.h,A.kind,A.pin,A.hint,A.key,A.span);for(let A of y)E.push(A.tail,A.head,A.minlen,A.labelW,A.labelH,A.tailDx,A.headDx,+A.tailFixed,+A.headFixed);let x=_.get(S.id);x||_.set(S.id,x=[]);for(let A of x){let M=A.given.length===E.length;for(let Y=0;M&&Y<E.length;Y++)M=Object.is(A.given[Y],E[Y]);if(M)return A}let T={given:E,lnodes:$,ledges:y,size:$o($,y,a)};return x.push(T),T},Z={width:0,height:0},H=()=>{for(let $ of l){for(let A of $.ports)e[A.inner].isGroup&&v(A.inner,t[A.e],A.out)&&(s.get(A.inner).portOf.get(A.e*2+(A.out?0:1)).side=A.side);if($.edges.length===0)continue;let y=!1;for(let A of $.edges){let M=t[A.e];(e[A.a].isGroup&&M.src!==A.a||e[A.b].isGroup&&M.dst!==A.b)&&(y=!0)}if(!y)continue;let{lnodes:E,ledges:x}=k($,!1);jn(E,x),Vn(E,x,1);let T=Eo($.dir);$.edges.forEach((A,M)=>{let Y=t[A.e],B=!x[M].reversed;e[A.a].isGroup&&Y.src!==A.a&&(s.get(A.a).portOf.get(A.e*2).side=B?Kn(T):T),e[A.b].isGroup&&Y.dst!==A.b&&(s.get(A.b).portOf.get(A.e*2+1).side=B?T:Kn(T))})}for(let $=l.length-1;$>=0;$--){let y=l[$],E=y.id>=0?e[y.id]:void 0,x=y.dir==="TB"||y.dir==="BT",T=y.dir==="BT"||y.dir==="RL",A=k(y,!0),{lnodes:M,ledges:Y,size:B}=j(y,A.lnodes,A.ledges),q=A.dummies,D=x?B.width:B.height,R=x?B.height:B.width,P=E?E.padX:0,G=E?E.padTop:0,X=Math.max(D+2*P,E?E.minW:0),Q=R+G+(E?E.padBottom:0),J=(X-D)/2,F=G,K=(se,ee)=>J+(x?se:T?B.height-ee:ee),re=(se,ee)=>F+(x?T?B.height-ee:ee:se),ne=x?0:1,de=se=>{let ee=[];for(let te=0;te<se.length;te+=2)ee.push(K(se[te],se[te+1]),re(se[te],se[te+1]),ne);return ee};y.items.forEach((se,ee)=>{e[se].x=K(M[ee].x,M[ee].y),e[se].y=re(M[ee].x,M[ee].y)}),y.edges.forEach((se,ee)=>{let te=Y[ee];y.routes.set(se.e,de(te.points));let fe=t[se.e];fe.labelW>0&&(fe.labelX=K(te.labelX,te.labelY),fe.labelY=re(te.labelX,te.labelY))});let ie=y.edges.length;y.ports.forEach((se,ee)=>{let te=e[se.inner];if(q[ee]>=0){let ge=de(Y[ie++].points),Ae=se.out?ge.length-3:0,Se=ge[Ae],oe=ge[Ae+1];se.side===0?oe=0:se.side===2?oe=Q:se.side===3?Se=0:Se=X,se.out?ge.push(Se,oe,ne):ge.unshift(Se,oe,ne),se.px=Se,se.py=oe,se.route=ge;return}let fe=te.x,ye=te.y;if(te.isGroup&&v(se.inner,t[se.e],se.out)){let ge=s.get(se.inner).portOf.get(se.e*2+(se.out?0:1));fe+=ge.px-te.w/2,ye+=ge.py-te.h/2}else se.side===0?ye-=te.h/2:se.side===2?ye+=te.h/2:se.side===3?fe-=te.w/2:fe+=te.w/2;let le=fe,we=ye;se.side===0?we=0:se.side===2?we=Q:se.side===3?le=0:le=X;let pe=se.side===0||se.side===2?0:1;se.px=le,se.py=we,se.route=se.out?[fe,ye,pe,le,we,pe]:[le,we,pe,fe,ye,pe]}),E?(E.w=X,E.h=Q):Z={width:X,height:Q}}for(let $ of l){let y=$.x,E=$.y;for(let x of $.items){let T=e[x];if(T.x+=y,T.y+=E,T.isGroup){let A=s.get(x);A.x=T.x-T.w/2,A.y=T.y-T.h/2}}}let S=($,y,E,x)=>{for(let T=0;T<y.length;T+=3){let A=y[T]+E,M=y[T+1]+x,Y=$.length;Y>=3&&Math.abs($[Y-3]-A)<.01&&Math.abs($[Y-2]-M)<.01||$.push(A,M,y[T+2])}};for(let $ of l)for(let y of $.edges){let E=t[y.e],x=[],T=[];for(let M=E.src;e[M].parent!==$.id;M=e[M].parent)T.push(s.get(e[M].parent));for(let M of T)S(x,M.portOf.get(y.e*2).route,M.x,M.y);S(x,$.routes.get(y.e),$.x,$.y);let A=[];for(let M=E.dst;e[M].parent!==$.id;M=e[M].parent)A.push(s.get(e[M].parent));for(let M=A.length-1;M>=0;M--)S(x,A[M].portOf.get(y.e*2+1).route,A[M].x,A[M].y);E.route=x,E.labelW>0&&(E.labelX+=$.x,E.labelY+=$.y)}},z=nv(a);N=U,H();let C=-1;if(U&&(C=vo(e,t,z),C>O*rv+av)){let S=X0(e,t,l,Z);N=!1,H();let $=vo(e,t,z);$>=C?(N=!0,Z=K0(S,e,t,l)):C=$}if(N===U&&L){let S=!1;for(let $ of l){if($.id<0)continue;let y=e[$.id],E=$.dir==="TB"||$.dir==="BT",x=Kn(Eo($.dir)),T=[];for(let A of $.ports){if(A.side!==x)continue;let M=t[A.e].route,Y=$.x+A.px,B=$.y+A.py,q=-1;for(let P=0;P<M.length&&(q<0||A.out);P+=3)Math.abs(M[P]-Y)<.01&&Math.abs(M[P+1]-B)<.01&&(q=P);if(q<0)continue;let D=E?0:1,R=A.out?q+3:q-3;for(;R>=0&&R<M.length&&Math.abs(M[R+D]-M[q+D])<Hs;)R+=A.out?3:-3;R<0||R>=M.length||(A.hint=M[R+D]-(E?y.x-y.w/2:y.y-y.h/2),T.push([E?A.px:A.py,A.hint]))}T.sort((A,M)=>A[0]-M[0]);for(let A=1;A<T.length;A++)T[A-1][1]>T[A][1]&&(S=!0)}if(S){let $=C>=0?C:vo(e,t,z),y=$>0?X0(e,t,l,Z):void 0;y&&(H(),vo(e,t,z)>=$&&(Z=K0(y,e,t,l)))}}for(let S of b){let $=t[S],y=e[$.src],E=e[$.dst];$.route=[y.x,y.y,0,E.x,E.y,0],$.labelX=(y.x+E.x)/2,$.labelY=(y.y+E.y)/2}for(let S of m){let $=t[S],y=e[$.src];$.labelX=y.x+y.w/2+28+$.labelW/2,$.labelY=y.y}return Z}var JA,ev,tv,rv,av,Z0,Hs,kd,Md,iv,Ao,sv,Ei=Ve(()=>{pr();JA=4e4,ev=400,tv=500,rv=1.5,av=4;Z0=24,Hs=.5,kd=3,Md=2,iv=Math.max(3,kd,Md+1),Ao=.62,sv=128});function Cr(e,t,r,a){return m0(()=>ze(e,!1,t,r,a,1))}function So(e,t,r,a,i,s,l){let n=Cr(e,t,r,4e3);if(n.height===0)return{width:i,height:s,content:l};let o=n.height+12,c=Math.max(i,Math.ceil(n.width+2*a));return{width:c,height:Math.ceil(s+o),content:Re(n,c/2,a+n.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${h((c-i)/2)},${h(o)})">${l}</g>`}}var Ea=Ve(()=>{ut();wt()});function t1(e){try{return decodeURIComponent(e)}catch{return e}}function Sa(e){if(!e)return Zn;let t=t1(e.trim()),r,a=0;do{if(++a>32)return Zn;t=t.replace(Ad,"").replace(Q0,(o,c)=>String.fromCharCode(c)).replace(J0,"").replace(Ad,"").replace(e1,"").trim(),t=t1(t),r=t.match(Ad)||t.match(Q0)||t.match(J0)||t.match(e1)}while(r&&r.length>0);if(!t)return Zn;if(t[0]==="."||t[0]==="/")return t;let i=t.trimStart(),s=i.match(ov);if(!s)return t;let l=s[0].toLowerCase().trim();if(lv.test(l))return Zn;let n=i.replace(/\\/g,"/");if(l==="mailto:"||l.includes("://"))return n;if(l==="http:"||l==="https:"){let o;try{o=new URL(n)}catch{return Zn}return o.protocol=o.protocol.toLowerCase(),o.hostname=o.hostname.toLowerCase(),o.toString()}return n}function Ta(e){return Sa(At(e))}function r1(e,t){if(fv.test(e))return;let r=dv.exec(e);return!r||t.includes(r[1].toLowerCase())?e:void 0}function oi(e,t){return t.links===!1?void 0:r1(e,t.linkSchemes??cv)}function a1(e,t){return t.images===!1?void 0:r1(e,t.imageSchemes??hv)}function ua(e,t,r,a,i,s=""){let l=oi(t,i);return l===void 0?e:(a.push({id:r,href:l,internal:!1}),`<a href="${Xe(l)}"${s}${ci(i)}>${e}</a>`)}function ci(e){let t=e.linkRel??"noopener";return t?` rel="${Xe(t)}"`:""}var Zn,lv,Q0,J0,Ad,ov,e1,cv,hv,dv,fv,hi=Ve(()=>{ut();wt();Zn="about:blank",lv=/^([^\w]*)(javascript|data|vbscript)/im,Q0=/&#(\w+)(^\w|;)?/g,J0=/&(newline|tab);/gi,Ad=/[\u0000-\u001F\u007F-\u009F -]/gim,ov=/^.+(:|:)/gim,e1=/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;cv=["http","https","mailto","tel"],hv=["http","https"],dv=/^([a-z][a-z0-9+.-]*):/i,fv=/^[\\/]{2}/});function Io(e,t,r){let a=Math.min(1,Math.abs(e)/t);return r*(1-Math.sqrt(1-a*a))}function s1(e,t,r){let a=Math.max(1.6*e+40,80),i=(t+10)/(1-(e+8)/a),s=i/2-10-t/2;return{w:a,h:i,dy:r?-s:s}}function Ys(e,t){return`<path d="${e}"${t}/>`}function Fr(e,t){let r="";for(let a=0;a<e.length;a+=2)r+=(a?" ":"")+h(e[a])+","+h(e[a+1]);return`<polygon points="${r}"${t}/>`}function Ir(e,t,r,a=""){return`<rect x="${h(-e/2)}" y="${h(-t/2)}" width="${h(e)}" height="${h(t)}"${a}${r}/>`}function Co(e,t,r,a){let i=t/2,s=6*r;return`<path d="M${h(e)},${h(-i)}q${h(s)},0 ${h(s)},6V-6q0,6 ${h(s)},6q${h(-s)},0 ${h(-s)},6V${h(i-6)}q0,6 ${h(-s)},6" fill="none"${a}/>`}function _o(e,t,r){let a=e/2,i=-t/2,s=t/2-10,l=e/4;return`<path d="M${h(-a)},${h(i)}H${h(a)}V${h(s)}q${h(-l)},-12 ${h(-2*l)},0t${h(-2*l)},0Z"${r}/>`}function Si(e,t,r){return(el.get(e)??l1).size(t,r)}function Ca(e,t,r,a,i){return(el.get(e)??l1).draw(t,r,a,i)}function di(e,t,r,a,i=0){return el.get(e)?.inset?.(t,r,a,i)??0}function o1(e,t,r,a){return Math.max(0,el.get(e)?.span?.(t,r,a)??0)}function c1(e){return el.get(e)?.noLabel!==!0}function ga(e,t,r){let a=e[t]-r.x,i=e[t+1]-r.y;return Math.abs(Math.abs(i)-r.h/2)<.5?i<0?0:2:Math.abs(Math.abs(a)-r.w/2)<.5?a<0?3:1:-1}function rs(e,t,r,a){if(a.isGroup)return;let i=ga(e,t,a);if(i===0||i===2){let s=di(r.shape,r.w,r.h,i,e[t]-a.x)+(a.h-r.h)/2;e[t+1]+=i===0?s:-s}else if(i>=0){let s=di(r.shape,r.w,r.h,i,e[t+1]-a.y)+(a.w-r.w)/2;e[t]+=i===3?s:-s}}var mt,$t,Us,sa,Qn,Ji,es,i1,ts,To,Jn,n1,l1,el,Ti=Ve(()=>{ut();mt=18,$t=12,Us=12,sa=(e,t,r)=>(r?t:e)-2*Us,Qn=e=>(t,r,a)=>a?0:t-2*e(r)-2*Us;Ji=(e,t,r,a)=>r&1?Io(a,t/2,e/2):Io(a,e/2,t/2),es=(e,t,r)=>(r?t:e)*.6,i1=(e,t,r,a)=>r&1?0:Io(a,e/2,Math.min(12,Math.max(6,e/14))),ts=(e,t)=>()=>({w:e,h:t,dy:0});To=(e,t,r)=>r&1?t/8:0,Jn=(e,t)=>({w:Math.max(e+2*mt,2*mt+12),h:t+2*$t,dy:0});n1={rect:{size:Jn,span:sa,draw:(e,t,r)=>Ir(e,t,ft(r))},rounded:{size:Jn,span:sa,draw:(e,t,r)=>Ir(e,t,r,` rx="${h(Math.min(12,t/2))}"`)},stadium:{inset:(e,t,r,a)=>r&1?Io(a,t/2,t/2):0,span:(e,t,r)=>r?t*.6:e-t,size:(e,t)=>{let r=t+2*$t;return{w:e+r*.5+2*mt-8,h:r,dy:0}},draw:(e,t,r)=>Ir(e,t,r,` rx="${h(t/2)}"`)},"fr-rect":{span:sa,size:(e,t)=>({w:e+2*mt+16,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>{let i=e/2-8;return Ir(e,t,ft(r))+`<path d="M${h(-i)},${h(-t/2)}V${h(t/2)}M${h(i)},${h(-t/2)}V${h(t/2)}" fill="none"${a}/>`}},cyl:{inset:i1,span:(e,t,r)=>r?t-2*Us-12:e*.6,size:(e,t)=>{let r=Math.max(e+2*mt,56),a=Math.min(12,Math.max(6,r/14));return{w:r,h:t+2*$t+2*a,dy:a/2}},draw:(e,t,r,a)=>{let i=e/2,s=Math.min(12,Math.max(6,e/14)),l=-t/2+s,n=t/2-s;return`<path d="M${h(-i)},${h(l)}A${h(i)},${h(s)} 0 0 1 ${h(i)},${h(l)}V${h(n)}A${h(i)},${h(s)} 0 0 1 ${h(-i)},${h(n)}Z"${r}/><path d="M${h(-i)},${h(l)}A${h(i)},${h(s)} 0 0 0 ${h(i)},${h(l)}" fill="none"${a}/>`}},circle:{inset:Ji,span:es,size:(e,t)=>{let r=Math.max(Math.sqrt(e*e+t*t)+16,44);return{w:r,h:r,dy:0}},draw:(e,t,r)=>`<circle r="${h(e/2)}"${r}/>`},"dbl-circ":{inset:Ji,span:es,size:(e,t)=>{let r=Math.max(Math.sqrt(e*e+t*t)+26,54);return{w:r,h:r,dy:0}},draw:(e,t,r,a)=>`<circle r="${h(e/2)}"${r}/><circle r="${h(e/2-5)}" fill="none"${a}/>`},ellipse:{inset:Ji,span:es,size:(e,t)=>({w:e*1.3+2*mt,h:t*1.2+2*$t,dy:0}),draw:(e,t,r)=>`<ellipse rx="${h(e/2)}" ry="${h(t/2)}"${r}/>`},diam:{inset:(e,t,r,a)=>r&1?Math.abs(a)*e/t:Math.abs(a)*t/e,span:(e,t,r)=>(r?t:e)*.6,size:(e,t)=>{let r=e+16,a=t+8;return{w:r+1.6*a,h:r/1.6+a,dy:0}},draw:(e,t,r)=>Fr([0,-t/2,e/2,0,0,t/2,-e/2,0],r)},hex:{inset:(e,t,r,a)=>r&1?Math.abs(a)/2:0,span:(e,t,r)=>r?t*.5:e-t/2-Us,size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2+a,-t/2,e/2-a,-t/2,e/2,0,e/2-a,t/2,-e/2+a,t/2,-e/2,0],r)}},odd:{inset:(e,t,r)=>r===3?t/4:0,span:Qn(()=>0),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/4,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2+a,0],r)}},"lean-r":{inset:To,span:Qn(e=>e/4),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2+a,-t/2,e/2,-t/2,e/2-a,t/2,-e/2,t/2],r)}},"lean-l":{inset:To,span:Qn(e=>e/4),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2,-t/2,e/2-a,-t/2,e/2,t/2,-e/2+a,t/2],r)}},"trap-b":{inset:To,span:Qn(e=>e/4),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2+a,-t/2,e/2-a,-t/2,e/2,t/2,-e/2,t/2],r)}},"trap-t":{inset:To,span:Qn(e=>e/4),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2,-t/2,e/2,-t/2,e/2-a,t/2,-e/2+a,t/2],r)}},text:{span:sa,size:(e,t)=>({w:e+8,h:t+8,dy:0}),draw:(e,t)=>Ir(e,t,' fill="none" stroke="none"')},"sm-circ":{noLabel:!0,inset:Ji,span:es,size:ts(14,14),draw:(e,t,r)=>`<circle r="${h(e/2)}"${r}/>`},"f-circ":{noLabel:!0,inset:Ji,span:es,size:ts(14,14),draw:(e,t,r,a)=>`<circle r="${h(e/2)}" fill="var(--_l)"${a}/>`},"fr-circ":{noLabel:!0,inset:Ji,span:es,size:ts(18,18),draw:(e,t,r,a)=>`<circle r="${h(e/2)}"${r}/><circle r="${h(e/2-4)}" fill="var(--_l)"${a}/>`},fork:{noLabel:!0,span:(e,t,r)=>(r?t:e)-8,size:ts(72,8),draw:(e,t,r,a)=>Ir(e,t,` fill="var(--_l)"${a}`,' rx="2"')},"notch-rect":{size:Jn,span:sa,draw:(e,t,r)=>Fr([-e/2+10,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],r)},"lin-rect":{span:sa,size:(e,t)=>({w:e+2*mt+8,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${h(-e/2+8)},${h(-t/2)}V${h(t/2)}" fill="none"${a}/>`},"div-rect":{span:sa,size:(e,t)=>({w:e+2*mt,h:t+2*$t+8,dy:4}),draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${h(-e/2)},${h(-t/2+8)}H${h(e/2)}" fill="none"${a}/>`},"win-pane":{span:sa,size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+8,dy:4}),draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${h(-e/2+8)},${h(-t/2)}V${h(t/2)}M${h(-e/2)},${h(-t/2+8)}H${h(e/2)}" fill="none"${a}/>`},tri:{inset:(e,t,r)=>r&1?e/4:0,size:(e,t)=>s1(e,t,!1),draw:(e,t,r)=>Fr([0,-t/2,e/2,t/2,-e/2,t/2],r)},"flip-tri":{inset:(e,t,r)=>r&1?e/4:0,size:(e,t)=>s1(e,t,!0),draw:(e,t,r)=>Fr([-e/2,-t/2,e/2,-t/2,0,t/2],r)},"sl-rect":{inset:(e,t,r)=>r===0?5:0,size:(e,t)=>({w:e+2*mt,h:t+2*$t+10,dy:5}),draw:(e,t,r)=>Fr([-e/2,-t/2+10,e/2,-t/2,e/2,t/2,-e/2,t/2],r)},"notch-pent":{span:sa,size:(e,t)=>({w:e+2*mt,h:t+2*$t,dy:0}),draw:(e,t,r)=>Fr([-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],r)},hourglass:{noLabel:!0,inset:(e,t,r)=>r&1?e/2:0,size:ts(32,40),draw:(e,t,r)=>Fr([-e/2,-t/2,e/2,-t/2,-e/2,t/2,e/2,t/2],r)},delay:{size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/4,h:r,dy:0}},draw:(e,t,r)=>{let a=t/2;return`<path d="M${h(-e/2)},${h(-a)}H${h(e/2-a)}A${h(a)},${h(a)} 0 0 1 ${h(e/2-a)},${h(a)}H${h(-e/2)}Z"${r}/>`}},"h-cyl":{size:(e,t)=>{let r=t+2*$t,a=Math.min(12,r/4);return{w:e+2*mt+2*a,h:r,dy:0}},draw:(e,t,r,a)=>{let i=t/2,s=Math.min(12,t/4),l=-e/2+s,n=e/2-s;return`<path d="M${h(l)},${h(-i)}H${h(n)}A${h(s)},${h(i)} 0 0 1 ${h(n)},${h(i)}H${h(l)}A${h(s)},${h(i)} 0 0 1 ${h(l)},${h(-i)}Z"${r}/><path d="M${h(n)},${h(-i)}A${h(s)},${h(i)} 0 0 0 ${h(n)},${h(i)}" fill="none"${a}/>`}},"cross-circ":{noLabel:!0,inset:Ji,span:es,size:ts(44,44),draw:(e,t,r,a)=>{let i=e/2,s=i*Math.SQRT1_2;return`<circle r="${h(i)}"${r}/><path d="M${h(-s)},${h(-s)}L${h(s)},${h(s)}M${h(s)},${h(-s)}L${h(-s)},${h(s)}" fill="none"${a}/>`}},"st-rect":{span:(e,t,r)=>(r?t:e)-2*Us-8,size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+8,dy:4}),draw:(e,t,r)=>{let a=e-8,i=t-8,s="";for(let l=0;l<3;l++){let n=-e/2+(2-l)*4,o=-t/2+l*4;s+=`<rect x="${h(n)}" y="${h(o)}" width="${h(a)}" height="${h(i)}"${ft(r)}/>`}return s}},doc:{inset:(e,t,r)=>r===2?10:0,size:(e,t)=>({w:e+2*mt,h:t+2*$t+10,dy:-5}),draw:(e,t,r)=>_o(e,t,r)},flag:{inset:(e,t,r)=>r&1?0:8,size:(e,t)=>({w:e+2*mt,h:t+2*$t+16,dy:0}),draw:(e,t,r)=>{let a=e/2,i=t/2-8,s=e/4;return`<path d="M${h(-a)},${h(-i)}q${h(s)},-10 ${h(2*s)},0t${h(2*s)},0V${h(i)}q${h(-s)},10 ${h(-2*s)},0t${h(-2*s)},0Z"${r}/>`}},datastore:{size:Jn,span:sa,draw:(e,t,r,a)=>Ir(e,t,r.replace('stroke="var(--_b)"','stroke="none"'))+`<path d="M${h(-e/2)},${h(-t/2)}H${h(e/2)}M${h(-e/2)},${h(t/2)}H${h(e/2)}" fill="none"${a}/>`},folder:{size:(e,t)=>({w:Math.max(e+2*mt,64),h:t+2*$t+8,dy:4}),draw:(e,t,r)=>{let a=e/2,i=t/2,s=Math.min(e*.4,48);return Ys(`M${h(-a)},${h(-i)}H${h(-a+s)}L${h(-a+s+8)},${h(-i+8)}H${h(a)}V${h(i)}H${h(-a)}Z`,r)}},bucket:{size:(e,t)=>({w:e+2*mt+20,h:t+2*$t+10,dy:3}),inset:(e,t,r)=>r&1?t/12:0,draw:(e,t,r,a)=>{let i=e/2,s=t/2,l=5,n=t/6;return Ys(`M${h(-i)},${h(-s+l)}A${h(i)},${h(l)} 0 0 1 ${h(i)},${h(-s+l)}L${h(i-n)},${h(s-l)}A${h(i-n)},${h(l)} 0 0 1 ${h(-i+n)},${h(s-l)}Z`,r)+`<path d="M${h(-i)},${h(-s+l)}A${h(i)},${h(l)} 0 0 0 ${h(i)},${h(-s+l)}" fill="none"${a}/>`}},console:{span:sa,size:(e,t)=>({w:Math.max(e+2*mt,72),h:t+2*$t+12,dy:6}),draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${h(-e/2)},${h(-t/2+12)}H${h(e/2)}M${h(-e/2+7)},${h(-t/2+4)}l3,2.5l-3,2.5M${h(-e/2+13)},${h(-t/2+9)}h4" fill="none"${a}/>`},browser:{span:sa,size:(e,t)=>({w:Math.max(e+2*mt,72),h:t+2*$t+12,dy:6}),draw:(e,t,r,a)=>{let i="";for(let s=0;s<3;s++)i+=`<circle cx="${h(-e/2+8+s*7)}" cy="${h(-t/2+6)}" r="1.5" fill="none"${a}/>`;return Ir(e,t,ft(r))+`<path d="M${h(-e/2)},${h(-t/2+12)}H${h(e/2)}" fill="none"${a}/>`+i}},person:{size:(e,t)=>({w:Math.max(e+2*mt,56),h:t+2*$t+26,dy:13}),draw:(e,t,r)=>{let a=-t/2;return`<rect x="${h(-e/2)}" y="${h(a+26)}" width="${h(e)}" height="${h(t-26)}" rx="12"${r}/><circle cy="${h(a+14)}" r="13"${r}/>`}},bang:{size:(e,t)=>({w:e+2*mt+28,h:t+2*$t+24,dy:0}),inset:()=>3,draw:(e,t,r)=>{let a=[];for(let i=0;i<28;i++){let s=Math.PI*i/14-Math.PI/2,l=i%2===0?1:.82;a.push(Math.cos(s)*(e/2)*l,Math.sin(s)*(t/2)*l)}return Fr(a,r)}},cloud:{size:(e,t)=>({w:e+2*mt+32,h:t+2*$t+24,dy:0}),inset:(e,t,r)=>r&1?2:1,draw:(e,t,r)=>{let a=e/2,i=t/2,s=i*.55;return Ys(`M${h(-a+s)},${h(i)}A${h(s)},${h(s)} 0 0 1 ${h(-a+s*.6)},${h(-i*.1)}A${h(a*.42)},${h(i*.7)} 0 0 1 ${h(-a*.1)},${h(-i*.72)}A${h(a*.4)},${h(i*.62)} 0 0 1 ${h(a*.62)},${h(-i*.42)}A${h(s*1.05)},${h(s*1.05)} 0 0 1 ${h(a-s)},${h(i)}Z`,r)}},brace:{size:(e,t)=>({w:e+2*mt+12,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>Ir(e,t,' fill="none" stroke="none"')+Co(-e/2+12,t,-1,a)},"brace-r":{size:(e,t)=>({w:e+2*mt+12,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>Ir(e,t,' fill="none" stroke="none"')+Co(e/2-12,t,1,a)},braces:{size:(e,t)=>({w:e+2*mt+24,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>Ir(e,t,' fill="none" stroke="none"')+Co(-e/2+12,t,-1,a)+Co(e/2-12,t,1,a)},bolt:{noLabel:!0,size:ts(36,56),inset:(e,t,r)=>r&1?e/4:0,draw:(e,t,r)=>Fr([e*.15,-t/2,-e/2,t*.08,-e*.05,t*.08,-e*.15,t/2,e/2,-t*.08,e*.05,-t*.08],r)},"lin-cyl":{inset:i1,span:(e,t,r)=>r?t-2*Us-20:e*.6,size:(e,t)=>{let r=Math.max(e+2*mt,56),a=Math.min(12,Math.max(6,r/14));return{w:r,h:t+2*$t+2*a+8,dy:a/2+4}},draw:(e,t,r,a)=>{let i=e/2,s=Math.min(12,Math.max(6,e/14)),l=-t/2+s,n=t/2-s,o=c=>`M${h(-i)},${h(c)}A${h(i)},${h(s)} 0 0 0 ${h(i)},${h(c)}`;return Ys(`M${h(-i)},${h(l)}A${h(i)},${h(s)} 0 0 1 ${h(i)},${h(l)}V${h(n)}A${h(i)},${h(s)} 0 0 1 ${h(-i)},${h(n)}Z`,r)+`<path d="${o(l)}${o(l+8)}" fill="none"${a}/>`}},"curv-trap":{size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r*.6,h:r,dy:0}},draw:(e,t,r)=>{let a=e/2,i=t/2,s=t*.3;return Ys(`M${h(-a+s)},${h(-i)}H${h(a-s)}A${h(s)},${h(i)} 0 0 1 ${h(a-s)},${h(i)}H${h(-a+s)}L${h(-a)},0Z`,r)}},docs:{size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+18,dy:-1}),inset:(e,t,r)=>r===2?10:0,draw:(e,t,r)=>{let a="";for(let i=0;i<3;i++)a+=`<g transform="translate(${(1-i)*4},${(i-1)*4})">${_o(e-8,t-8,r)}</g>`;return a}},"bow-rect":{size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r*.4,h:r,dy:0}},inset:(e,t,r)=>r===1?t*.2:0,draw:(e,t,r)=>{let a=e/2,i=t/2,s=t*.2;return Ys(`M${h(-a+s)},${h(-i)}H${h(a)}A${h(s)},${h(i)} 0 0 0 ${h(a)},${h(i)}H${h(-a+s)}A${h(s)},${h(i)} 0 0 1 ${h(-a+s)},${h(-i)}Z`,r)}},"tag-rect":{size:Jn,span:sa,draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${h(e/2-12)},${h(t/2)}L${h(e/2)},${h(t/2-12)}" fill="none"${a}/>`},"tag-doc":{size:(e,t)=>({w:e+2*mt,h:t+2*$t+10,dy:-5}),inset:(e,t,r)=>r===2?10:0,draw:(e,t,r,a)=>_o(e,t,r)+`<path d="M${h(e/2-12)},${h(t/2-14)}L${h(e/2)},${h(t/2-26)}" fill="none"${a}/>`},"lin-doc":{size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+10,dy:-5}),inset:(e,t,r)=>r===2?10:0,draw:(e,t,r,a)=>_o(e,t,r)+`<path d="M${h(-e/2+8)},${h(-t/2)}V${h(t/2-6)}" fill="none"${a}/>`},collapsedGroup:{size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+8,dy:-2}),draw:(e,t,r)=>`<rect x="${h(-e/2+6)}" y="${h(-t/2+8)}" width="${h(e-12)}" height="${h(t-8)}"${ft(r)}/><rect x="${h(-e/2)}" y="${h(-t/2)}" width="${h(e)}" height="${h(t-4)}"${ft(r)}/>`}};l1=n1.rect,el=new Map(Object.entries(n1))});function Ci(e,t,r,a){let i=a(t,!1),s=e.maxWidth;if(s===void 0||!(s>0)||i.width<=s)return i;let l=Math.min(r,t),n=t;i=a(n,!0);for(let o=0;o<3&&i.width>s&&n>l;o++)n=Math.max(l,n-(i.width-s)),i=a(n,!0);return i}function It(e){let t=e.maxWidth;return t!==void 0&&t>0?Math.max(80,t-2*(e.padding??8)):4e3}function _i(e,t,r,a=0){let i=e.maxWidth;return i===void 0||!(i>0)?t:Math.max(Math.min(r,t),Math.min(t,i-a))}function Bt(e,t){let r=t(!1),a=e.maxWidth;if(e.autoDirection===!1||a===void 0||!(a>0)||r.width<=a)return r;let i=e.directionBreakpoint;if(a>=(i!==void 0&&i>0?i:pv))return r;let s=t(!0);return s.width<r.width?s:r}function jr(e){return e==="LR"||e==="RL"}function Nr(e,t){let r=t(!1),a=e.maxWidth;if(a===void 0||!(a>0)||r.width<=a)return r;let i=t(!0);return i.width<r.width?i:r}var pv,zt=Ve(()=>{pv=640});function vd(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function h1(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function uv(e,t){let r=0;for(let a=0;a<t.length;a++)t[a]===e&&r++;return r}function gv(e){let t=e.trim(),r="arrow_open";switch(t[0]){case"<":r="arrow_point",t=t.slice(1);break;case"x":r="arrow_cross",t=t.slice(1);break;case"o":r="arrow_circle",t=t.slice(1);break}let a="normal";return t.includes("=")&&(a="thick"),t.includes(".")&&(a="dotted"),{type:r,stroke:a}}function mv(e){let t=e.trim(),r=t.slice(0,-1),a="arrow_open";switch(t.slice(-1)){case"x":a="arrow_cross",t.startsWith("x")&&(a="double_"+a,r=r.slice(1));break;case">":a="arrow_point",t.startsWith("<")&&(a="double_"+a,r=r.slice(1));break;case"o":a="arrow_circle",t.startsWith("o")&&(a="double_"+a,r=r.slice(1));break}let i="normal",s=r.length-1;r.startsWith("=")&&(i="thick"),r.startsWith("~")&&(i="invisible");let l=uv(".",r);return l&&(i="dotted",s=l),{type:a,stroke:i,length:s}}function Dv(e){let t=e.length,r=[],a=[],i=[],s=[],l=0,n=0,o=!0,c=e.indexOf("direction"),f=e.indexOf("@"),p=-1,d=0,g=0,u=-1,m=-1,b=-1,w=(S,$,y)=>{r.push(S),a.push(e.slice($,y)),i.push($),n=y},v=S=>{s.push(l),l=S},k=()=>{s.length>0&&(l=s.pop())},L=(S,$)=>(S.lastIndex=$,S.test(e)?S.lastIndex:-1),I=S=>e.startsWith(S,n)&&!Qe(e.charCodeAt(n+S.length)),N=S=>{let $=S;if(S>=m&&S<=b)$=b;else if(Ue(e.charCodeAt(S))){for(;$<t&&Ue(e.charCodeAt($));)$++;m=S,b=$}let y=e.charCodeAt($);return y===120||y===111||y===60?e.charCodeAt($+1):y},O=S=>{let $=S;if(S>=m&&S<=b)$=b;else if(Ue(e.charCodeAt(S))){for(;$<t&&Ue(e.charCodeAt($));)$++;m=S,b=$}return e.charCodeAt($)===126},W=()=>{e.charCodeAt(n+1)===96?(v(2),n+=2):(v(1),n++)},U=()=>{if(!O(n))return!1;let S=L(u1,n);return S<0?!1:(w(40,n,S),!0)},_=S=>{let $=e.charCodeAt(n+1);return S===40?($===45?(v(8),w(45,n,n+2)):$===91?(v(7),w(47,n,n+2)):$===40&&e.charCodeAt(n+2)===40?(v(7),w(55,n,n+3)):(v(7),w(69,n,n+1)),!0):S===91?($===91?(v(7),w(49,n,n+2)):$===40?(v(7),w(53,n,n+2)):$===47?(v(9),w(58,n,n+2)):$===92?(v(9),w(59,n,n+2)):(v(7),w(71,n,n+1)),!0):S===124?(v(7),w(67,n,n+1),!0):S===123?(v(7),w(73,n,n+1),!0):!1},j=S=>{o&&(o=!1,v(6)),w(20,n,n+S)},Z=()=>{let S=n;for(;S<t;){let $=e.charCodeAt(S);if($<128&&x1[$]===1)S++;else if($===45&&S+1<t){let y=e.charCodeAt(S+1);if(y===62||y===45||y===46)break;S++}else break}return S===n?!1:(w(64,n,S),!0)},H=S=>{let $=N(n),y;if($===45){if((y=L(f1,n))>=0)return w(40,n,y),!0;if((y=L(Tv,n))>=0)return v(10),w(41,n,y),!0;if((y=L(Sd,n))>=0)return w(40,n,y),!0;if((y=L(_v,n))>=0)return v(12),w(41,n,y),!0}else if($===61){if((y=L(p1,n))>=0)return w(40,n,y),!0;if((y=L(Cv,n))>=0)return v(11),w(41,n,y),!0}else if($===46&&(y=L(Sd,n))>=0)return w(40,n,y),!0;return S!==45&&S!==61&&S!==46&&U()},z=S=>{let $;switch(S){case 97:if(e.startsWith("acc",n)){if(($=L(xv,n))>=0)return v(3),w(2,n,$),!0;if(($=L(wv,n))>=0)return v(4),w(4,n,$),!0;if(($=L(bv,n))>=0)return v(5),n=$,!0}break;case 64:if(e.charCodeAt(n+1)===123)return v(16),r.push(7),a.push(""),i.push(n),n+=2,!0;break;case 99:if(($=L($v,n))>=0)return v(14),n=$,!0;if(I("classDef"))return w(16,n,n+8),!0;if(I("class"))return w(17,n,n+5),!0;if(($=L(kv,n))>=0)return v(13),n=$,!0;break;case 34:return W(),!0;case 115:if(I("style"))return w(12,n,n+5),!0;if(I("swimlane-beta"))return j(13),!0;if(I("subgraph"))return w(21,n,n+8),!0;break;case 100:if(I("default"))return w(13,n,n+7),!0;break;case 108:if(I("linkStyle"))return w(14,n,n+9),!0;break;case 105:if(I("interpolate"))return w(15,n,n+11),!0;break;case 104:if(e.startsWith("href",n)&&Ue(e.charCodeAt(n+4)))return w(18,n,n+5),!0;break;case 102:if(I("flowchart-elk"))return j(13),!0;if(I("flowchart"))return j(9),!0;break;case 103:if(I("graph"))return j(5),!0;break;case 101:if(I("end")){for($=n+3;$<t&&Ue(e.charCodeAt($));)$++;return w(22,n,$),!0}break;case 95:if(I("_self"))return w(23,n,n+5),!0;if(I("_blank"))return w(23,n,n+6),!0;if(I("_parent"))return w(23,n,n+7),!0;if(I("_top"))return w(23,n,n+4),!0;break}if(c!==-1&&n>=d&&(c<n&&(c=e.indexOf("direction",n)),c!==-1&&(p<n&&(Ed.lastIndex=n,p=Ed.test(e)?Ed.lastIndex-1:t),c<p))){for(let y=0;y<5;y++)if(($=L(Sv[y],n))>=0)return w(26+y,n,$),!0;d=p}if(f!==-1&&S!==34&&!Ue(S)){if(n>=g){f<n&&(f=e.indexOf("@",n));let y=n;for(;y<t;){let E=e.charCodeAt(y);if(E===34||Ue(E))break;y++}if(g=y,u=-1,f!==-1&&f<y)for(let E=Math.min(y,t-1)-1;E>=f;E--){if(e.charCodeAt(E)!==64)continue;let x=e.charCodeAt(E+1);if(x!==123&&x!==34){u=E;break}}}if(u>n)return w(31,n,u+1),!0}if(S>=48&&S<=57){let y=n+1;for(;y<t;){let E=e.charCodeAt(y);if(E<48||E>57)break;y++}return w(32,n,y),!0}switch(S){case 35:return w(33,n,n+1),!0;case 58:return e.charCodeAt(n+1)===58&&e.charCodeAt(n+2)===58?w(34,n,n+3):w(35,n,n+1),!0;case 38:return w(36,n,n+1),!0;case 59:return w(37,n,n+1),!0;case 44:return w(38,n,n+1),!0;case 42:return w(39,n,n+1),!0;case 120:case 111:return H(S)||Z();case 60:return H(S)||w(60,n,n+1),!0;case 45:return H(S)||Z()||w(65,n,n+1),!0;case 61:return H(S);case 46:return H(S)||Z();case 126:return U();case 40:return _(S);case 91:return e.charCodeAt(n+1)===124?(w(50,n,n+2),!0):_(S);case 124:case 123:return _(S);case 62:return v(7),w(51,n,n+1),!0;case 94:return w(61,n,n+1),!0;case 92:return e.charCodeAt(n+1)===124?(w(62,n,n+2),!0):Z();case 118:return Qe(e.charCodeAt(n+1))?Z():(w(63,n,n+1),!0)}return Ue(S)?H(S)?!0:($=L(Iv,n))>=0?(w(74,n,$),!0):($=L(Nv,n))>=0?(w(75,n,$),!0):!1:S<128?Z():Ps(S)?(w(66,n,n+1),!0):!1},C=(S,$,y,E)=>{if(S===34)return W(),!0;let x=N(n);if(x===y||x===E){let A=L($,n);if(A>=0)return k(),w(40,n,A),!0}if(S===y&&(y!==45||e.charCodeAt(n+1)===45))return!1;let T=n+1;for(;T<t;){let A=e.charCodeAt(T);if(A===34)break;if(A===y){if(y!==45||e.charCodeAt(T+1)===45)break}else if(A===120||A===111||A===60||A===E||Ue(A)){let M=N(T);if((M===y||M===E)&&L($,T)>=0)break}T++}return w(42,n,T),!0};e:for(;;){if(n>=t){let y=-1;switch(l){case 0:y=76;break;case 3:y=3;break;case 4:y=5;break;case 5:y=6;break;case 13:y=19;break;case 14:y=8;break;case 15:y=9;break}y!==-1&&w(y,t,t);break}let S=e.charCodeAt(n),$=!0;switch(l){case 0:$=z(S);break;case 1:if(S===34)e.charCodeAt(n+1)===96?(v(2),n+=2):(k(),n++);else{let y=e.indexOf('"',n);w(11,n,y===-1?t:y)}break;case 2:if(S===96)e.charCodeAt(n+1)===34?(k(),n+=2):$=!1;else if(S===34)W();else{let y=n+1;for(;y<t;){let E=e.charCodeAt(y);if(E===96||E===34)break;y++}w(10,n,y)}break;case 3:case 4:{let y=e.indexOf(`
|
|
44
|
+
`,n);y===-1&&(y=t);let E=l===3?3:5;k(),w(E,n,y);break}case 5:if(S===125)k(),n++;else{let y=e.indexOf("}",n);y===-1&&(y=t),w(6,n,y)}break;case 6:{let y;S===34?W():(y=L(Mv,n))>=0?(k(),w(24,n,y)):(y=L(Av,n))>=0||(y=L(vv,n))>=0||(y=L(Ev,n))>=0?(k(),w(25,n,y)):$=U()||_(S);break}case 7:{let y=e.charCodeAt(n+1);switch(S){case 34:W();break;case 40:case 91:case 123:_(S);break;case 93:k(),y===41?w(46,n,n+2):y===93?w(48,n,n+2):w(70,n,n+1);break;case 41:k(),y===93?w(52,n,n+2):y===41&&e.charCodeAt(n+2)===41?w(54,n,n+3):w(68,n,n+1);break;case 124:k(),w(67,n,n+1);break;case 125:k(),w(72,n,n+1);break;default:{if((S===126||Ue(S))&&U())break;let E=n+1;for(;E<t;){let x=e.charCodeAt(E);if(x===91||x===93||x===40||x===41||x===123||x===125||x===124||x===34)break;E++}w(44,n,E)}}break}case 8:{let y=e.charCodeAt(n+1);if(S===34)W();else{if((S===126||Ue(S))&&U())break;if((S===45||S===47||S===41)&&y===41)k(),w(43,n,n+2);else if(S===40||S===91||S===123)_(S);else if(S===41||S===93||S===125)$=!1;else{let E=n+1;for(;E<t;){let x=e.charCodeAt(E);if(x===34||x===40||x===41||x===91||x===93||x===123||x===125||(x===45||x===47)&&e.charCodeAt(E+1)===41||(x===126||Ue(x))&&O(E)&&L(u1,E)>=0)break;E++}w(44,n,E)}}break}case 9:{let y=e.charCodeAt(n+1);if(S===34){W();break}if((S===126||Ue(S))&&U())break;switch(S){case 40:y===45||y===91||y===40&&e.charCodeAt(n+2)===40?_(S):y===93?(k(),w(56,n,n+2)):_(S);break;case 91:case 123:_(S);break;case 92:y===93?(k(),w(56,n,n+2)):w(44,n,n+1);break;case 47:y===93?(k(),w(57,n,n+2)):w(44,n,n+1);break;case 93:case 41:y===93?(k(),w(56,n,n+2)):$=!1;break;case 125:$=!1;break;default:{if((S===63||S===61)&&y===93){k(),w(56,n,n+2);break}let E=n+1;for(;E<t;){let x=e.charCodeAt(E);if(x===92||x===91||x===93||x===40||x===41||x===123||x===125||x===47)break;E++}w(44,n,E)}}break}case 10:$=C(S,f1,45,-1);break;case 11:$=C(S,p1,61,-1);break;case 12:$=C(S,Sd,46,45);break;case 13:if(S===34)W();else if(Ue(S))k(),n++;else{let y=n+1;for(;y<t&&!Ue(e.charCodeAt(y));)y++;w(19,n,y)}break;case 14:if(S===40){let y=L(Rv,n);k(),y>=0?n=y:(v(15),n++)}else{let y=e.indexOf("(",n);y===-1&&(y=t),w(8,n,y)}break;case 15:if(S===41)k(),n++;else{let y=e.indexOf(")",n);y===-1&&(y=t),w(9,n,y)}break;case 16:if(S===34)v(17),w(7,n,n+1);else if(S===125)k(),n++;else if(S===94)$=!1;else{let y=n+1;for(;y<t;){let E=e.charCodeAt(y);if(E===125||E===94||E===34)break;y++}w(7,n,y)}break;case 17:if(S===34)k(),w(7,n,n+1);else{let y=e.indexOf('"',n);y===-1&&(y=t),r.push(7),a.push(e.slice(n,y).replace(Lv,"<br/>")),i.push(n),n=y}break}if(!$)return r.push(1),a.push(""),i.push(n),{types:r,texts:a,starts:i};continue e}return r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function Pv(e,t){let r=e.includes("}")?e.replace(Ov,`}
|
|
45
|
+
`):e,{types:a,texts:i,starts:s}=Dv(r),l=0,n,o=C=>{let S=a[l];throw S===1?it("flowchart",r,s[l],"",!0):it("flowchart",r,s[l],`Expecting ${C}, got '${d1[S]}'`)},c=(C,S="")=>(a[l]!==C&&o(`'${d1[C]}'${S?", "+S:""}`),i[l++]),f=()=>{let C=a[l];C!==74&&C!==37&&C!==76&&o("'SEMI', 'NEWLINE', 'EOF'"),l++},p=()=>{No[a[l]]===0&&o("'NODE_STRING'");let C=i[l++];for(;No[a[l]]===1;)C+=i[l++];return C},d=()=>{Id[a[l]]===0&&o("'NODE_STRING'");let C=i[l++];for(;Id[a[l]]===1;)C+=i[l++];return C},g=()=>{let C=a[l],S;if(C===11)S="string";else if(C===10)S="markdown";else if(C===44||C===60||C===51||C===66)S="text";else return o(`${g1}, 'TAGEND', 'STR', 'MD_STR'`);let $=i[l++];for(;;){let y=a[l];if(y!==44&&y!==60&&y!==51&&y!==66)break;$+=i[l++]}return{text:$,type:S}},u=C=>{c(C,g1)},m=()=>{let C=a[l],S;if(C===11)S="string";else if(C===10)S="markdown";else if(C===42||C===66)S="text";else return o("'EDGE_TEXT', 'STR', 'MD_STR'");let $=i[l++];for(;a[l]===42||a[l]===66;)$+=i[l++];return{text:$,type:S}},b=()=>{let C=a[l],S;if(C===11)S="text";else if(C===10)S="markdown";else if(Nd[C]===1)S="text";else return o("'NODE_STRING', 'STR', 'MD_STR'");let $=i[l++];for(;Nd[a[l]]===1;)$+=i[l++];return{text:$,type:S}},w=()=>{let C=i[l++];for(;a[l]===7;)C+=i[l++];return C},v=()=>{let C=p(),S;switch(a[l]){case 71:l++,S=g(),u(70),t.addVertex(C,S,"square");break;case 55:l++,S=g(),u(54),t.addVertex(C,S,"doublecircle");break;case 69:l++,a[l]===69?(l++,S=g(),u(68),c(68),t.addVertex(C,S,"circle")):(S=g(),u(68),t.addVertex(C,S,"round"));break;case 45:l++,S=g(),u(43),t.addVertex(C,S,"ellipse");break;case 47:l++,S=g(),u(46),t.addVertex(C,S,"stadium");break;case 49:l++,S=g(),u(48),t.addVertex(C,S,"subroutine");break;case 50:{l++;let $=c(64);c(35);let y=c(64);c(67),S=g(),u(70),t.addVertex(C,S,"rect",void 0,void 0,void 0,{[$]:y});break}case 53:l++,S=g(),u(52),t.addVertex(C,S,"cylinder");break;case 73:l++,a[l]===73?(l++,S=g(),u(72),c(72),t.addVertex(C,S,"hexagon")):(S=g(),u(72),t.addVertex(C,S,"diamond"));break;case 51:l++,S=g(),u(70),t.addVertex(C,S,"odd");break;case 58:l++,S=g(),a[l]===57?(l++,t.addVertex(C,S,"lean_right")):(u(56),t.addVertex(C,S,"trapezoid"));break;case 59:l++,S=g(),a[l]===56?(l++,t.addVertex(C,S,"lean_left")):(u(57),t.addVertex(C,S,"inv_trapezoid"));break;default:t.addVertex(C)}return C},k=()=>{let C=v();return a[l]===34&&(l++,t.setClass(C,p())),C},L=()=>{let C=[k()];for(n=void 0;;){let S=a[l]===7?w():void 0;if(a[l]!==75)return n=S,C;do l++;while(a[l]===75);if(a[l]!==36)return S!==void 0&&o("'AMP'"),C;l++,a[l]!==75&&o("'SPACE'");do l++;while(a[l]===75);let $=k();S!==void 0&&t.addVertex(C[C.length-1],void 0,void 0,void 0,void 0,void 0,void 0,S),C.push($)}},I=()=>{let C;if(a[l]===31&&(C=i[l++]),a[l]===40){let S=t.destructLink(i[l++]);return C!==void 0&&(S.id=C),a[l]===67&&(l++,S.text=g(),u(67),a[l]===75&&l++),S}if(a[l]===41){let S=i[l++],$=m(),y=c(40,"'EDGE_TEXT'"),E=t.destructLink(y,S);return E.text=$,C!==void 0&&(E.id=C),E}return o("'LINK', 'START_LINK'")},N=C=>{let S=L();n!==void 0&&t.addVertex(S[S.length-1],void 0,void 0,void 0,void 0,void 0,void 0,n);let $=S;for(;;){let y=a[l];if(y!==40&&y!==41&&y!==31)return $;let E=I(),x=L();n!==void 0&&t.addVertex(x[x.length-1],void 0,void 0,void 0,void 0,void 0,void 0,n),t.addLink(S,x,E),C&&($=x.concat($)),S=x}},O=()=>{Rd[a[l]]===0&&o("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let C=i[l++];for(;Rd[a[l]]===1;)C+=i[l++];return C},W=()=>{let C=[O()];for(;a[l]===38;)l++,C.push(O());return C},U=()=>{l++,c(75);let C;if(a[l]===13)C=[i[l++]];else for(C=[c(32,"'DEFAULT'")];a[l]===38;)l++,C.push(c(32));if(c(75),a[l]!==15){t.updateLink(C,W());return}l++,c(75);let S=d();if(a[l]===75){l++;let $=W();t.updateLinkInterpolate(C,S),t.updateLink(C,$)}else t.updateLinkInterpolate(C,S)},_=(C,S)=>{if(a[l]!==75){t.setLink(C,S);return}if(l++,a[l]===23){t.setLink(C,S,i[l++]);return}let $=c(11,"'LINK_TARGET'");a[l]===75?(l++,t.setLink(C,S,c(23))):t.setLink(C,S),t.setTooltip(C,$)},j=()=>{let C=i[l++];switch(a[l]){case 8:{let S=i[l++],$=a[l]===9,y=$?i[l++]:void 0,E;a[l]===75&&(l++,E=c(11)),$?t.setClickEvent(C,S,y):t.setClickEvent(C,S),E!==void 0&&t.setTooltip(C,E);return}case 18:l++,_(C,c(11));return;case 11:_(C,i[l++]);return;default:{let S=d();if(a[l]===75){l++;let $=c(11);t.setClickEvent(C,S),t.setTooltip(C,$)}else t.setClickEvent(C,S)}}},Z=()=>{l++;let C=a[l];if(C===74||C===37||C===76)return l++,{id:void 0,title:void 0,list:[],collect:!1};c(75,"'SEMI', 'NEWLINE', 'EOF'");let S=b(),$=S;return a[l]===71&&(l++,$=g(),u(70)),C=a[l],C!==74&&C!==37&&C!==76&&o("'SEMI', 'NEWLINE', 'EOF', 'SQS'"),l++,{id:S,title:$,list:[],collect:!1}},H=C=>{let S=a[l];switch(S){case 12:{l++,c(75);let $=p();return c(75),t.addVertex($,void 0,void 0,W()),f(),tl}case 14:return U(),f(),tl;case 16:{l++,c(75);let $=p();return c(75),t.addClass($,W()),f(),tl}case 17:{l++,c(75);let $=p();return c(75),t.setClass($,p()),f(),tl}case 19:return j(),f(),tl;case 26:case 27:case 28:case 29:case 30:return l++,{stmt:"dir",value:zv[S-26]};case 2:{l++;let $=c(3).trim();return t.setAccTitle($),$}case 4:{l++;let $=c(5).trim();return t.setAccDescription($),$}case 6:{let $=i[l++].trim();return t.setAccDescription($),$}default:{No[S]===0&&o(m1);let $=N(C);return f(),$}}},z=()=>{let C=[],S=[],$=!1;for(;;){let y=a[l];if(y===0)break;if(y===22){let E=C.pop();if(E===void 0)break;l++;let x=t.addSubGraph(E.id,S,E.title);S=E.list,$=E.collect,$&&S.push(x)}else if(y===37||y===74||y===75||y===76)$&&S.push(i[l]),l++;else if(y===21){let E=Z();E.list=S,E.collect=$,C.push(E),S=[],$=!0}else{let E=H($);$&&(!Array.isArray(E)||E.length>0)&&S.push(E)}}C.length>0&&o("'end'")};for(;a[l]===75||a[l]===74;)l++;if(c(20,"'SPACE', 'NEWLINE'"),a[l]===24)l++,t.setDirection("TB");else{let C=c(25,"'NODIR'"),S=a[l];if(S===75){do l++;while(a[l]===75);S=a[l],S!==74&&o("'NEWLINE', 'SPACE'")}else S!==37&&S!==74&&o("'SEMI', 'NEWLINE', 'SPACE'");l++,t.setDirection(C)}z(),a[l]!==0&&o(m1)}function Fv(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 Wv(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 Bv(e,t){let r=[],a=[],i=e.subgraphs,s=k=>{let L=[];for(let I of k){let N=e.classes.get(I);if(N!==void 0){for(let O of N.styles)L.push(O.trim());for(let O of N.textStyles)L.push(O.trim())}}return L},l=new Map;for(let k of i)for(let L of k.nodes)e.subgraph(L)&&l.set(L,k.id);let n=new Map,o=new Map;for(let k of i){let L=l.get(k.id);if(L===void 0)continue;let I=o.get(L);I?I.push(k.id):o.set(L,[k.id])}let c=0;for(let k of i){if(l.has(k.id))continue;let L=[k.id];for(;L.length>0;){let I=L.pop();if(n.has(I))continue;n.set(I,c++);let N=o.get(I);if(N)for(let O=N.length-1;O>=0;O--)L.push(N[O])}}let f=k=>e.subgraph(k)?.metadata?.view==="collapsed",p=!1;for(let k of i)k.metadata?.view==="collapsed"&&(p=!0);let d=new Map,g=k=>{let L=[],I=new Set,N=k;for(;N!==void 0&&!d.has(N)&&!I.has(N);)I.add(N),L.push(N),N=l.get(N);let O=N!==void 0?d.get(N):void 0;for(let W=L.length-1;W>=0;W--)O===void 0&&f(L[W])&&(O=L[W]),d.set(L[W],O);return O},u=new Set,m=new Map;for(let k of p?i:[]){let L=g(k.id);if(L!==void 0){k.id!==L&&(u.add(k.id),m.set(k.id,L));for(let I of k.nodes)I!==L&&(u.add(I),m.set(I,L))}}let b=new Map,w=new Set;for(let k=i.length-1;k>=0;k--){let L=i[k];if(!u.has(L.id)){L.nodes.length>0&&w.add(L.id);for(let I of L.nodes)b.set(I,L.id)}}let v=new Map;for(let k=i.length-1;k>=0;k--){let L=i[k];if(u.has(L.id))continue;let I=L.metadata?.view==="collapsed",N={id:L.id,label:L.title,labelType:L.labelType,parentId:b.get(L.id),cssStyles:[],cssCompiledStyles:s(L.classes),cssClasses:L.classes.join(" "),shape:I?"collapsedGroup":"rect",dir:L.dir,isGroup:!I,colorIndex:n.get(L.id)};I||(N.metadata=L.metadata),r.push(N),v.set(L.id,N)}for(let k of e.nodes.values()){if(u.has(k.id))continue;let L=v.get(k.id);if(L){L.cssStyles=k.styles,L.cssCompiledStyles=s(k.classes),L.cssClasses=k.classes.join(" ");continue}let I=w.has(k.id),N={id:k.id,label:k.text,labelType:k.labelType,parentId:b.get(k.id),cssStyles:k.styles,cssCompiledStyles:s(["default","node",...k.classes]),cssClasses:"default "+k.classes.join(" "),dir:k.dir,link:k.link,linkTarget:k.linkTarget,tooltip:e.tooltips.get(k.id),icon:k.icon,pos:k.pos,img:k.img,assetWidth:k.assetWidth,assetHeight:k.assetHeight,constraint:k.constraint,isGroup:I,shape:I?"rect":Fv(k)};r.push(N)}return e.edges.forEach((k,L)=>{let I=m.get(k.start)??k.start,N=m.get(k.end)??k.end;if(I===N&&(m.has(k.start)||m.has(k.end)))return;let[O,W]=Wv(k.type),U=[...e.defaultEdgeStyle??[]];k.style&&U.push(...k.style);let _=k.stroke==="invisible"||k.type==="arrow_open";a.push({id:k.id||`L_${I}_${N}_${L}`,isUserDefinedId:k.isUserDefinedId,start:I,end:N,type:k.type??"normal",label:k.text,labelType:k.labelType,thickness:k.stroke,pattern:k.stroke,minlen:k.length,classes:k.stroke==="invisible"?"":"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:_?"none":O,arrowTypeEnd:_?"none":W,cssCompiledStyles:s(k.classes),style:U,animate:k.animate,animation:k.animation,curve:k.interpolate||e.defaultInterpolate||t})}),{nodes:r,edges:a}}function _d(e,t,r){let a=e[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function rl(e,t){return e!==void 0&&e>0&&e<=4e3?e:t}function Ld(e,t,r,a){let i=s=>Nr(r,l=>Gv(e,t,r,a,s,l));return jr(e.direction)?Bt(r,i):i(!1)}function Gv(e,t,r,a,i,s){let l=s?12:y1,n=a?t[a.type]:void 0,o=typeof n=="object"&&n!==null&&!Array.isArray(n)?n:t.flowchart??{},c=Bv(e,typeof o.curve=="string"?o.curve:void 0);a?.prepare(c);let f=r.fontSize??16,p=Math.round(f*.875),d=r.measurer??et(r.fontFamily),g=Math.min(_d(o,"wrappingWidth",200),a&&s?100:1/0),u=r.padding??8,m=r.icons,b=new Map,w=[],v=[];c.nodes.forEach((D,R)=>b.set(D.id,R));for(let D of c.nodes){let R=vt(D.cssStyles.length>0?D.cssCompiledStyles.concat(D.cssStyles):D.cssCompiledStyles),P=(R.bold?1:0)|(R.italic?2:0),G=D.labelType==="markdown",X=R.fontSize??f,Q,J;if(D.isGroup){let F=ze(D.label,G,d,X,a&&s?Math.max(80,It(r)/2):4e3,P);Q={node:D,style:R,label:F,shape:"group",w:0,h:0,dy:0,loops:0},J=Ut(0,0),J.isGroup=!0,J.dir=D.dir?br(D.dir):void 0,J.padX=l,J.padTop=F.height>0?F.height+16:y1,J.padBottom=l,J.minW=F.width+2*l-12}else{let F=uo(D.shape),K=D.img||D.icon||c1(F)?D.label:void 0,re=ze(K,G,d,X,g,P),ne,de,ie=0;if(D.img||D.icon){let se=D.img?80:48,ee=rl(D.assetWidth,se),te=rl(D.assetHeight,se);ne=Math.max(ee,re.width+8),de=te+(re.height>0?re.height+6:0),ie=D.pos==="t"?-te/2:te/2,re.height===0&&(ie=0)}else{let se=Si(F,re.width,re.height);ne=se.w,de=se.h,ie=se.dy}Q={node:D,style:R,label:re,shape:F,w:ne,h:de,dy:ie,loops:0},J=Ut(ne,de)}J.seq=w.length,w.push(Q),v.push(J)}c.nodes.forEach((D,R)=>{v[R].parent=D.parentId!==void 0?b.get(D.parentId)??-1:-1});let k=i?"TB":br(e.direction),L=D=>{let R;for(let P=v[D].parent,G=0;P>=0&&R===void 0&&G<1e4;P=v[P].parent,G++)R=v[P].dir;return R??(R=k),R==="LR"||R==="RL"};w.forEach((D,R)=>{D.node.isGroup?v[R].span=1/0:!D.node.img&&!D.node.icon&&(v[R].span=o1(D.shape,D.w,D.h,L(R)))});let I=[],N=[],O=[];for(let D of c.edges){let R=b.get(D.start),P=b.get(D.end);if(R===void 0||P===void 0)continue;let G=ze(D.label,D.labelType==="markdown",d,p,g);R===P&&(w[R].loops++,L(R)?v[R].h+=2*(Td+(G.height>0?G.height+8:0)):v[R].w+=2*(Td+(G.width>0?G.width+12:0))),O.push(D),N.push(G),I.push({src:R,dst:P,minlen:D.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:_d(o,"nodeSpacing",Hv)*(s?.5:1),edgeSep:Yv,rankSep:_d(o,"rankSpacing",Uv)*(s?.75:1),portSep:20,tracks:typeof o.curve=="string"&&/^step/.test(o.curve),straight:o.curve==="linear",headRoom:gt("arrow_point")},U=a?a.layout(v,I,k,W,s):Gr(v,I,k,W),_=Cr(e.title,d,f,s?It(r):4e3),j=_.height>0?_.height+12:0,Z=Math.max(U.width,_.width),H=u+(Z-U.width)/2,z=u+j;vi(v,I,H,z);let C=Math.ceil(Z+2*u),S=Math.ceil(U.height+j+2*u),$=[],y=new Map,E=!1;for(let D of v)D.isGroup&&(E=!0);if(E)for(let D of I)va(y,D.route);let x="",T="",A="";for(let D=0;D<w.length;D++){let R=w[D],P=v[D],G=R.node,X=P.x,Q=P.y,J=_t(G.cssClasses.replace(/^default\s?/,"")),F=Oe(G.id);if(P.isGroup&&a?.drawGroup&&P.parent<0){x+=a.drawGroup(P,R.label,R.style,J,F,k,m);continue}if(P.isGroup){let se=Ai(P,R.label.width,y,l),ee=Q-P.h/2+8+R.label.height/2,te=` class="pele-cluster-label" fill="var(--_m)"${R.style.text}`,fe=yo(P,R.label.width,se,y);fe&&(T+=xo(R.label,se,ee,te,F,v,D,m)),x+=`<g class="pele-cluster${J}" data-id="${F}"><rect x="${h(X-P.w/2)}" y="${h(Q-P.h/2)}" width="${h(P.w)}" height="${h(P.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ft(R.style.shape)}/>`+(fe?"":Re(R.label,se,ee,te,m))+"</g>";continue}let K=R.w,re=R.h,ne;if(G.img){let se=rl(G.assetWidth,80),ee=rl(G.assetHeight,80),te=R.label.height>0?G.pos==="t"?re/2-ee:-re/2:-ee/2,fe=a1(Ta(G.img),r);ne=fe===void 0?"":`<image href="${Xe(fe)}" x="${h(-se/2)}" y="${h(te)}" width="${h(se)}" height="${h(ee)}" preserveAspectRatio="${G.constraint==="on"?"xMidYMid meet":"none"}"/>`}else if(G.icon){let se=rl(G.assetHeight,48),ee=R.label.height>0?G.pos==="t"?re/2-se:-re/2:-se/2,te=G.shape==="icon"?"":G.shape==="iconCircle"?`<circle cy="${h(ee+se/2)}" r="${h(se/2)}"${Cd}${R.style.shape}/>`:`<rect x="${h(-se/2)}" y="${h(ee)}" width="${h(se)}" height="${h(se)}" rx="${G.shape==="iconRounded"?8:0}"${Cd}${R.style.shape}/>`,fe=se*.6;ne=te+`<svg class="pele-icon" data-icon="${Oe(G.icon)}" x="${h(-fe/2)}" y="${h(ee+(se-fe)/2)}" width="${h(fe)}" height="${h(fe)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${m?.(G.icon)??""}</svg>`}else ne=Ca(R.shape,K,re,Cd+R.style.shape,qv+R.style.line);let de=Re(R.label,0,R.dy,` class="pele-label"${R.style.text}`,m);if(/ internal-link(?: |$)/.test(J+" ")&&G.label&&r.links!==!1){let se=At(G.label),ee=oi(Sa(se),r)!==void 0,te=Xe(se);de=`<a class="internal-link"${ee?` href="${te}"${ci(r)}`:""} data-href="${te}">${de}</a>`,$.push({id:G.id,href:se,internal:!0})}let ie=ne+de;G.tooltip&&(ie=`<title>${Oe(G.tooltip)}</title>`+ie),G.link&&(ie=ua(ie,G.link,G.id,$,r,G.linkTarget?` target="${Xe(G.linkTarget)}"`:"")),A+=`<g class="pele-node pele-shape-${R.shape}${J}" data-id="${F}" transform="translate(${h(X)},${h(Q)})">${ie}</g>`}let M=ko();for(let D=0;D<I.length;D++){let R=I[D];R.src===R.dst||O[D].thickness==="invisible"||R.route.length<6||(M.add(R.src,ga(R.route,0,v[R.src]),O[D].arrowTypeStart),M.add(R.dst,ga(R.route,R.route.length-3,v[R.dst]),O[D].arrowTypeEnd))}let Y="",B="",q=new Map;for(let D=0;D<I.length;D++){let R=I[D],P=O[D],G=N[D],X=P.style.length>0||P.cssCompiledStyles.length>0?vt(P.cssCompiledStyles.concat(P.style)):void 0;if(P.thickness!=="invisible"){let Q=P.arrowTypeStart,J=P.arrowTypeEnd,F;if(R.src===R.dst){let de=w[R.src],ie=q.get(R.src)??0;q.set(R.src,ie+1),F=Mo(v[R.src],de.w,de.h,ie,L(R.src),Td,gt(J),R)}else{let de=R.route.slice(),ie=M.of(R.src,ga(de,0,v[R.src])),se=M.of(R.dst,ga(de,de.length-3,v[R.dst]));rs(de,0,w[R.src],v[R.src]),rs(de,de.length-3,w[R.dst],v[R.dst]),F=zr(de,P.curve,gt(Q),gt(J),ie,se)}let K=X?.stroke&&P.thickness!=="invisible"?Xe(X.stroke):"var(--_l)",re="";P.thickness==="thick"?re+=' stroke-width="2.5"':P.thickness==="dotted"&&(re+=' stroke-dasharray="3 4"');let ne=_t(P.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));Y+=`<g class="pele-edge${ne}" data-id="${Oe(P.id)}"${X?.line??""}><path d="${F.d}"${re}/>`+bt(Q,F.sx,F.sy,F.sdx,F.sdy,K)+bt(J,F.ex,F.ey,F.edx,F.edy,K)+"</g>"}if(G.width>0){let Q=R.labelX,J=R.labelY;B+=wr(P.id,G,Q,J,X?.text??"",m)}}return{svg:Je(a?.type??"flowchart",C,S,f,r,e,Re(_,C/2,u+_.height/2,' class="pele-title" font-weight="var(--_tw)"')+(x?`<g class="pele-clusters">${x}</g>`:"")+(Y?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${Y}</g>`:"")+(T?`<g class="pele-cluster-titles">${T}</g>`:"")+(B?`<g class="pele-edge-labels" font-size="${p}">${B}</g>`:"")+`<g class="pele-nodes">${A}</g>`),width:C,height:S,links:$}}var yv,d1,x1,xv,wv,bv,$v,kv,Mv,Av,vv,Ev,Sv,Ed,f1,Tv,p1,Cv,Sd,_v,u1,Iv,Nv,Rv,Lv,No,Id,Nd,Rd,g1,tl,Ov,zv,m1,Hv,Yv,Uv,y1,Td,Cd,qv,Ro,Dd=Ve(()=>{ud();Rs();go();Fs();Ei();Ea();hi();Ti();tr();zt();pr();ut();wt();yv=class{constructor(e={}){ce(this,"type","flowchart");ce(this,"direction");ce(this,"nodes",new Map);ce(this,"edges",[]);ce(this,"subgraphs",[]);ce(this,"classes",new Map);ce(this,"tooltips",new Map);ce(this,"defaultEdgeStyle");ce(this,"defaultInterpolate");ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"subgraphLookup",new Map);ce(this,"members",new Set);ce(this,"edgeById",new Map);ce(this,"pairCount",new Map);ce(this,"subCount",0);ce(this,"options");this.options=e}addVertex(e,t,r,a,i,s,l,n){if(!e||e.trim().length===0)return;let o;if(n!==void 0){let g=n.includes(`
|
|
46
|
+
`)?n+`
|
|
47
|
+
`:`{
|
|
48
|
+
`+n+`
|
|
49
|
+
}`,u;try{u=Ma(g)}catch(m){throw new je(`Metadata of "${e}" is not valid YAML. ${m.message}`,"syntax",{type:"flowchart"})}o=u!==null&&typeof u=="object"&&!Array.isArray(u)?u:void 0}let c=this.subgraphLookup.get(e);if(c&&o){c.metadata={...c.metadata,...o};return}let f=this.edgeById.get(e);if(f){o?.animate!==void 0&&(f.animate=o.animate),o?.animation!==void 0&&(f.animation=o.animation),o?.curve!==void 0&&(f.interpolate=o.curve);return}let p=this.nodes.get(e);if(p===void 0&&(t===void 0&&r===void 0&&a!==void 0&&a!==null&&this.options.warn?.(`Style applied to unknown node "${e}". This may indicate a typo. The node will be created automatically.`),p={id:e,labelType:"text",styles:[],classes:[]},this.nodes.set(e,p)),t!==void 0?(p.labelType=t.type,p.text=h1(t.text.trim())):p.text===void 0&&(p.text=e),r!==void 0&&(p.type=r),a!=null)for(let g of a)p.styles.push(g);if(i!=null)for(let g of i)p.classes.push(g);if(s!==void 0&&(p.dir=s),p.props===void 0?p.props=l??{}:l!==void 0&&Object.assign(p.props,l),o===void 0)return;if(o.shape){let g=String(o.shape);if(g!==g.toLowerCase()||g.includes("_"))throw new je(`No such shape: ${g}. Shape names should be lowercase.`,"semantic",{type:"flowchart"});if(!po(g))throw new je(`No such shape: ${g}.`,"semantic",{type:"flowchart"});p.type=g}let d=typeof o.label=="string"?o.label:void 0;o.label&&(p.text=String(o.label),p.labelType=vd(o.labelType)),o.icon&&(p.icon=String(o.icon),!d?.trim()&&p.text===e&&(p.text="")),o.form&&(p.form=String(o.form)),o.pos&&(p.pos=String(o.pos)),o.img&&(p.img=String(o.img),!d?.trim()&&p.text===e&&(p.text="")),o.constraint&&(p.constraint=String(o.constraint)),o.w&&(p.assetWidth=Number(o.w)),o.h&&(p.assetHeight=Number(o.h))}addSingleLink(e,t,r,a){let i={start:e,end:t,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},s=r?.text;s!==void 0&&(i.text=h1(s.text.trim()),i.labelType=vd(s.type)),r!==void 0&&(i.type=r.type,i.stroke=r.stroke,i.length=r.length>10?10:r.length);let l=e+"\0"+t,n=this.pairCount.get(l)??0;a&&!this.edgeById.has(a)?(i.id=a,i.isUserDefinedId=!0):i.id=`L_${e}_${t}_${n===0?0:n+1}`;let o=this.options.maxEdges;if(o!==void 0&&this.edges.length>=o)throw new je(`Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${o}.`,"limit",{type:"flowchart"});this.edges.push(i),this.pairCount.set(l,n+1),this.edgeById.has(i.id)||this.edgeById.set(i.id,i)}addLink(e,t,r){let a=typeof r?.id=="string"?r.id.replace("@",""):void 0,i=e[e.length-1],s=t[0];for(let l of e)for(let n of t)this.addSingleLink(l,n,r,l===i&&n===s?a:void 0)}updateLinkInterpolate(e,t){for(let r of e)r==="default"?this.defaultInterpolate=t:this.edgeAt(r).interpolate=t}updateLink(e,t){for(let r of e){if(r==="default"){this.defaultEdgeStyle=t;continue}let a=this.edgeAt(r);a.style=t,t.length>0&&!t.some(i=>i?.startsWith("fill"))&&t.push("fill:none")}}edgeAt(e){let t=this.edges[Number(e)];if(t===void 0)throw new je(`The index ${e} 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 t}addClass(e,t){let r=t.join().replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let a of e.split(",")){let i=this.classes.get(a);i===void 0&&(i={id:a,styles:[],textStyles:[]},this.classes.set(a,i));for(let s of r)s.includes("color")&&i.textStyles.push(s.replace("fill","bgFill")),i.styles.push(s)}}setDirection(e){let t=e.trim();t.includes("<")&&(t="RL"),t.includes("^")&&(t="BT"),t.includes(">")&&(t="LR"),t.includes("v")&&(t="TB"),t==="TD"&&(t="TB"),this.direction=t}setClass(e,t){for(let r of e.split(","))this.nodes.get(r)?.classes.push(t),this.edgeById.get(r)?.classes.push(t),this.subgraphLookup.get(r)?.classes.push(t)}setTooltip(e,t){if(t!==void 0)for(let r of e.split(","))this.tooltips.set(r,t)}setLink(e,t,r){let a=t.trim();for(let i of e.split(",")){let s=this.nodes.get(i);s!==void 0&&(s.link=a?Ta(a):void 0,s.linkTarget=r)}this.setClass(e,"clickable")}setClickEvent(e,t,r){this.setClass(e,"clickable")}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
50
|
+
`)}addSubGraph(e,t,r){let a=e?.text.trim(),i=r?.text??"";e!==void 0&&e===r&&/\s/.test(i)&&(a=void 0);let s=new Set,l=[],n;for(let p of t)if(typeof p=="string")p.trim()!==""&&!s.has(p)&&(s.add(p),l.push(p));else if(Array.isArray(p))for(let d of p)d.trim()!==""&&!s.has(d)&&(s.add(d),l.push(d));else n=p.value;n??(n=this.options.inheritDir?this.direction??this.options.direction:void 0),a??(a="subGraph"+this.subCount),i=i||"",this.subCount++;let o={id:a,nodes:l,title:i.trim(),classes:[],dir:n,labelType:vd(r?.type)},c=this.members;o.nodes=l.filter(p=>!c.has(p)&&p!==a);for(let p of o.nodes)c.add(p);let f=this.subgraphLookup.get(a);if(f)for(let p of o.nodes)f.nodes.push(p);else this.subgraphs.push(o);return this.subgraphLookup.set(a,f??o),a}exists(e,t){for(let r of e)if(r.nodes.includes(t))return!0;return!1}makeUniq(e,t){let r=new Set;for(let a of t)for(let i of a.nodes)r.add(i);return{nodes:e.nodes.filter(a=>!r.has(a))}}destructLink(e,t){let r=mv(e);if(!t)return r;let a=gv(t);if(a.stroke!==r.stroke)return{type:"INVALID",stroke:"INVALID"};if(a.type==="arrow_open")a.type=r.type;else{if(a.type!==r.type)return{type:"INVALID",stroke:"INVALID"};a.type="double_"+a.type}return a.type==="double_arrow"&&(a.type="double_arrow_point"),a.length=r.length,a}subgraph(e){return this.subgraphLookup.get(e)}},d1=["$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"],x1=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")x1[e.charCodeAt(0)]=1;xv=/accTitle\s*:\s*/y,wv=/accDescr\s*:\s*/y,bv=/accDescr\s*\{\s*/y,$v=/call\s+/y,kv=/click\s+/y,Mv=/(?:\r?\n)*\s*\n/y,Av=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,vv=/\s*[<>^]/y,Ev=/\s*v\b/y,Sv=[/.*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],Ed=/[\n\r\u2028\u2029]/g,f1=/\s*[xo<]?--+[-xo>]\s*/y,Tv=/\s*[xo<]?--\s*/y,p1=/\s*[xo<]?==+[=xo>]\s*/y,Cv=/\s*[xo<]?==\s*/y,Sd=/\s*[xo<]?-?\.+-[xo>]?\s*/y,_v=/\s*[xo<]?-\.\s*/y,u1=/\s*~~~+\s*/y,Iv=/(?:\r?\n)+/y,Nv=/[^\S\n\r]+/y,Rv=/\(\s*\)/y,Lv=/\n\s*/g;No=new Uint8Array(77);for(let e of[32,64,63,65,13,38,35,36,33,39,66])No[e]=1;Id=new Uint8Array(77);for(let e of[32,66,64,25,63,65,38,35,36,33,39])Id[e]=1;Nd=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])Nd[e]=1;Rd=new Uint8Array(77);for(let e of[32,64,35,75,33,12])Rd[e]=1;g1="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",tl=[],Ov=/}\s*\n/g;zv=["TB","BT","RL","LR","TD"],m1="'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";Hv=40,Yv=16,Uv=48,y1=20,Td=26,Cd=' fill="var(--_s)" stroke="var(--_b)"',qv=' stroke="var(--_b)"';Ro={type:"flowchart",math:!0,parse(e,t,r,a,i){let s=t.flowchart??{},l=new yv({inheritDir:s.inheritDir===!0,maxEdges:i.maxEdges});return r&&(l.title=r),Pv(e,l),l},render:Ld}});var w1={};Ct(w1,{flowchart:()=>Ro});var b1=Ve(()=>{Dd()});function jv(e){let t=e.map((i,s)=>s),r=[];for(let i=0;i<128;i++){let s=String.fromCharCode(i);r.push(t.filter(l=>{let{pattern:n,first:o}=e[l];return typeof n=="string"?n[0]===s:o===void 0||o.includes(s)}))}let a={starting:r,every:t,longer:e.map(i=>i.longer?.map(s=>e.indexOf(s)))};return $1.set(e,a),a}function Gt(e,t,r){let a=[],i=[],s=[],l=new Uint8Array(t.length),{starting:n,every:o,longer:c}=$1.get(t)??jv(t),f=[],p=e.length,d=(u,m)=>{if(l[u])return-1;let b=t[u];if(b.match!==void 0)return b.match(e,m);if(b.scanner!==void 0)return(f[u]??(f[u]=b.scanner()))(e,m);let w=b.pattern;return typeof w=="string"?e.startsWith(w,m)?m+w.length:-1:(w.lastIndex=m,w.test(e)?w.lastIndex:(b.opener!==void 0&&(b.opener.lastIndex=m,b.opener.test(e)&&(l[u]=1)),-1))},g=0;e:for(;g<p;){let u=e.charCodeAt(g);for(let m of u<128?n[u]:o){let b=d(m,g);if(b<=g)continue;let w=m,v=c[m];if(v!==void 0)for(let k of v){let L=d(k,g);if(L>b){w=k,b=L;break}}t[w].hidden||(a.push(w),i.push(g),s.push(b)),g=b;continue e}throw it(r,e,g,"",!0)}return a.push(-1),i.push(p),s.push(p),{kinds:a,starts:i,ends:s,src:e}}function or(e){return{name:e,pattern:new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"(?:(?=%%)|(?!\\S))","y"),first:e[0]}}function Od(e){return e.trim().replace(/[\t ]{2,}/gm," ")}function Vt(e){return Od(Kv.exec(e)[1])}function Xt(e){return Od(Xv.exec(e)[1])}function Kt(e){let t=Vv.exec(e);return t[1]!==void 0?Od(t[1]):t[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,`
|
|
51
|
+
`)}function $r(e){if(!e.includes("\\"))return e.slice(1,-1);let t="";for(let r=1;r<e.length-1;r++){let a=e[r];if(a==="\\"){let i=e[++r];t+=Zv.get(i)??i}else t+=a}return t}var $1,ur,rr,ar,Vr,Rr,Lr,jt,nr,lr,Vv,Xv,Kv,Zv,Zt,Xr=Ve(()=>{wt();$1=new WeakMap;ur={name:"ACC_DESCR",pattern:/[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:" a"},rr={name:"ACC_TITLE",pattern:/[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:" a"},ar={name:"TITLE",pattern:/[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:" t"},Vr={name:"STRING",pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`},Rr={name:"NEWLINE",pattern:/\r?\n/y,first:`\r
|
|
52
|
+
`},Lr={name:"WHITESPACE",pattern:/[\t ]+/y,hidden:!0,first:" "},jt={name:"YAML",pattern:/---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/y,hidden:!0,opener:/---[\t ]*\r?\n/y,first:"-"},nr={name:"DIRECTIVE",pattern:/[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/y,hidden:!0,opener:/[\t ]*%%{/y,first:" %"},lr={name:"SINGLE_LINE_COMMENT",pattern:/[\t ]*%%[^\n\r]*/y,first:" %",hidden:!0};Vv=/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,Xv=/accTitle[\t ]*:([^\n\r]*)/,Kv=/title([\t ][^\n\r]*|)/;Zv=new Map([["b","\b"],["f","\f"],["n",`
|
|
53
|
+
`],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);Zt=class{constructor(e,t,r){ce(this,"tokens");ce(this,"types");ce(this,"diagram");ce(this,"i",0);ce(this,"kinds");this.tokens=e,this.types=t,this.diagram=r,this.kinds=e.kinds}get kind(){return this.kinds[this.i]}text(e=this.i){return this.tokens.src.slice(this.tokens.starts[e],this.tokens.ends[e])}take(){return this.text(this.i++)}accept(e){return this.kinds[this.i]!==e?!1:(this.i++,!0)}expect(e){return this.kinds[this.i]!==e&&this.fail(`token of type '${this.types[e].name}'`),this.take()}fail(e){let t=this.kind===-1?"end of input":`\`${this.text()}\``;throw it(this.diagram,this.tokens.src,this.tokens.starts[this.i],`Expecting ${e} but found ${t}.`)}}});function Qv(e,t){let r=new Map;for(let{label:a,value:i}of e.sections){if(i<0)throw new je(`"${a}" has invalid value: ${i}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,"semantic",{type:"pie"});r.has(a)||r.set(a,i)}return{type:"pie",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
54
|
+
`):void 0,showData:e.showData,sections:r}}function k1(e,t){let r=t;for(let a=e.charCodeAt(r);a>=48&&a<=57;a=e.charCodeAt(r))r++;return r}function Jv(){let e=0,t=0,r=-1;return(a,i)=>{let s=a.charCodeAt(i)===45?i+1:i;if((s<e||s>=t)&&(e=s,t=k1(a,s),r=-1,t>s&&a.charCodeAt(t)===46)){let l=k1(a,t+1),n=l-t-1;n>0&&a.charCodeAt(l)!==46?r=l:n>1&&(r=l-1)}return t===s?-1:r>=0?r:a.charCodeAt(s)===48?a.charCodeAt(s+1)===46?-1:s+1:a.charCodeAt(t)!==46?t:t-1>s?t-1:-1}}function eE(e){let t=new Zt(Gt(e,M1,"pie"),M1,"pie"),r={$type:"Pie",showData:!1,sections:[]},a=()=>{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),r.showData=t.accept(0);t.kind!==-1;)switch(t.kind){case 8:t.i++;break;case 4:r.accDescr=Kt(t.take()),a();break;case 5:r.accTitle=Xt(t.take()),a();break;case 6:r.title=Vt(t.take()),a();break;case 7:{let i=$r(t.take());t.expect(2);let s=Number(t.expect(3));r.sections.push({$type:"PieSection",label:i,value:s}),a();break}default:t.fail("a section, a title, or a line break")}return r}function Fd(e,t){return e.pie?.[t]}function qs(e,t){return`${h(Math.sin(e)*t)},${h(-Math.cos(e)*t)}`}function rE(e,t,r,a){if(t-e>=Math.PI*2-1e-9){let s=(l,n)=>`M0,${h(-l)}A${h(l)},${h(l)} 0 1 ${n} 0,${h(l)}A${h(l)},${h(l)} 0 1 ${n} 0,${h(-l)}Z`;return s(r,1)+(a>0?s(a,0):"")}let i=t-e>Math.PI?1:0;return a<=0?`M0,0L${qs(e,r)}A${h(r)},${h(r)} 0 ${i} 1 ${qs(t,r)}Z`:`M${qs(e,r)}A${h(r)},${h(r)} 0 ${i} 1 ${qs(t,r)}L${qs(t,a)}A${h(a)},${h(a)} 0 ${i} 0 ${qs(e,a)}Z`}function aE(e,t,r){return Ci(r,tE*2,140,(a,i)=>iE(e,t,r,a/2,i))}function iE(e,t,r,a,i){let s=r.fontSize??16,l=Math.round(s*.875),n=r.measurer??et(r.fontFamily),o=r.padding??8,c=Fd(t,"textPosition"),f=typeof c=="number"&&c>=0&&c<=1?c:.75,p=Fd(t,"donutHole"),d=typeof p=="number"&&p>0&&p<=.9?p*a:0,g=String(Fd(t,"legendPosition")??"right"),u=i&&(g==="left"||g==="right")?"bottom":g,m=[...e.sections],b=0;for(let[,G]of m)b+=G;let w=m.map(([G,X])=>ze(e.showData?`${G} [${X}]`:G,!1,n,l,4e3)),v=0;for(let G of w)v=Math.max(v,G.width);v+=w.length>0?al+8:0;let k=w.length*Pd,L=ze(e.title,!1,n,s,It(r),1),I=L.height>0?L.height+16:0,N=m.map(([,G])=>{let X=b>0?G/b:0;return X*100>=1&&(X*100).toFixed(0)!=="0"?X:0}),O=N.map(G=>G===0||G>=.5?!1:2*a*f*Math.sin(G*Math.PI)<n.width((G*100).toFixed(0)+"%",l,0)+6),W=O.includes(!0)?A1:0,U=u==="left"||u==="right"||u==="center"?u:"",_=u==="top"||u==="bottom",j=(a+W)*2,Z=j,H=j;U==="left"||U==="right"?(Z+=v>0?zd+v:0,H=Math.max(H,k)):_&&(Z=Math.max(Z,v),H+=k>0?20+k:0),Z=Math.max(Z,L.width);let z=o+(U==="left"?v+zd+j/2:U==="right"?j/2:Z/2),C=o+I,S=C+(u==="top"?k+20+j/2:_?j/2:H/2),$="",y="",E="",x=0,T=a+A1/2,A=[],M=(G,X,Q)=>A.every(J=>Math.abs(G-J.x)>=(Q+J.width)/2+2||Math.abs(X-J.y)>=l+2);m.forEach(([G],X)=>{let Q=N[X];if(Q===0)return;let J=x+Q*Math.PI*2;$+=`<path class="pele-slice" data-id="${Oe(G)}" d="${rE(x,J,a,d)}" fill="${dt(X)}"/>`;let F=(x+J)/2,K=(Q*100).toFixed(0)+"%";if(O[X]){let re=n.width(K,l,0),ne=F;for(let se=0;se<360&&!M(Math.sin(ne)*T,-Math.cos(ne)*T,re);se++)ne+=2/T;let de=Math.sin(ne)*T,ie=-Math.cos(ne)*T;A.push({x:de,y:ie,width:re}),E+=`<text x="${h(de)}" y="${h(ie+l*.35)}">${K}</text>`}else{let re=a*f;y+=`<text x="${h(Math.sin(F)*re)}" y="${h(-Math.cos(F)*re+l*.35)}">${K}</text>`}x=J}),$===""&&($=`<circle class="pele-slice" r="${a}" fill="none" stroke="var(--_b)"/>`);let Y="",B,q;U==="right"?(B=z+j/2+zd,q=C+(H-k)/2):U==="left"?(B=o,q=C+(H-k)/2):U==="center"?(B=z-v/2,q=S-k/2):(B=o+(Z-v)/2,q=u==="top"?C:C+j+20),w.forEach((G,X)=>{let Q=q+X*Pd+Pd/2;Y+=`<g class="pele-legend-item" data-id="${Oe(m[X][0])}"><rect x="${h(B)}" y="${h(Q-al/2)}" width="${al}" height="${al}" rx="2" fill="${dt(X)}"/>`+Re(G,B+al+8+G.width/2,Q,"")+"</g>"});let D=Math.ceil(Z+2*o),R=Math.ceil(H+I+2*o),P=Re(L,D/2,o+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-slices" transform="translate(${h(z)},${h(S)})" stroke="var(--_bg)" stroke-width="1" stroke-linejoin="round">${$}</g>`+(y?`<g class="pele-slice-labels" transform="translate(${h(z)},${h(S)})" font-size="${l}" text-anchor="middle" fill="var(--_bg)">${y}</g>`:"")+(E?`<g class="pele-slice-labels" transform="translate(${h(z)},${h(S)})" font-size="${l}" text-anchor="middle">${E}</g>`:"")+(Y?`<g class="pele-legend" font-size="${l}">${Y}</g>`:"");return{svg:Je("pie",D,R,s,r,e,P),width:D,height:R,links:[]}}var M1,tE,al,Pd,zd,A1,v1,E1=Ve(()=>{zt();Xr();ut();wt();M1=[or("showData"),or("pie"),{name:":",pattern:":"},{name:"NUMBER_PIE",pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:Jv,first:"-0123456789"},ur,rr,ar,Vr,Rr,Lr,jt,nr,lr];tE=120,al=12,Pd=26,zd=32,A1=28;v1={type:"pie",parse:(e,t,r)=>Qv(eE(e),r),render:aE}});var S1={};Ct(S1,{pie:()=>v1});var T1=Ve(()=>{E1()});function Wd(e){let t=0;for(let r=e.indexOf("~");r!==-1;r=e.indexOf("~",r+1))t++;return t}function sE(e){let t=Wd(e);if(t<=1)return e;let r=t%2!==0&&e.startsWith("~"),a=e.split(""),i=[];for(let s=r?1:0;s<a.length;s++)a[s]==="~"&&i.push(s);for(let s=0,l=i.length-1;s<l;s++,l--)a[i[s]]="<",a[i[l]]=">";return a.join("")}function as(e){if(!e.includes("~"))return e;let t=e.split(/(,)/),r=[];for(let a=0;a<t.length;a++){let i=t[a];i===","&&a>0&&a+1<t.length&&Wd(t[a-1])===1&&Wd(t[a+1])===1&&(i=t[a-1]+","+t[a+1],a++,r.pop()),r.push(sE(i))}return r.join("")}var Bd=Ve(()=>{});function nE(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function _1(e,t){return e<128?(_a[e]&t)!==0:e>=192||e===181}function fE(e){let t=e.length,r=[],a=[],i=[],s=0,l=0,n=-2,o=0,c=-1,f=-2,p=-1,d=-1,g=-1,u=(H,z,C)=>{r.push(H),a.push(e.slice(z,C)),i.push(z),l=C},m=(H,z)=>(H.lastIndex=z,H.test(e)?H.lastIndex:-1),b=H=>{for(let z=0;z<H.length;z++){let C=H.charCodeAt(z),S=e.charCodeAt(l+z);if(S!==C&&(C<97||C>122||(S|32)!==C))return!1}return!0},w=H=>b(H)&&!Qe(e.charCodeAt(l+H.length)),v=H=>{let z=e.charCodeAt(H);return z>=65&&z<=90?z+32:z},k=H=>(Yd.lastIndex=H,Yd.test(e)?Yd.lastIndex-1:t),L=H=>{for(;pt(e.charCodeAt(H));)H++;return H},I=()=>{if(n===-1||n<l&&(Hd.lastIndex=l,n=Hd.test(e)?Hd.lastIndex-9:-1,n===-1)||l<o||(c<l&&(c=k(l)),n>=c))return!1;for(let H=0;H<4;H++){let z=m(dE[H],l);if(z>=0)return u(18+H,l,z),!0}return o=c,!1},N=()=>{let H=e.indexOf('"',l+1);if(H===-1){u(45,l,l+1);return}let z=H>l+1;for(let C=l+1;z&&C<H;C++){let S=e.charCodeAt(C);(S===37||S===92||S===13||S===10||S===11||S===8)&&(z=!1)}u(z?31:44,l,H+1)},O=H=>{let z=e.charCodeAt(l+1);if(z===43&&(H===49||H===48)){u(H===49?39:38,l,l+2);return}let C=L(l+1);if(e.charCodeAt(C)===46&&pt(e.charCodeAt(C+1))){u(32,l,L(C+2));return}if(H===49){if(Ue(z)){let S=l+2;for(;Ue(e.charCodeAt(S));)S++;let $=e.charCodeAt(S);if(Qe($)||$===34||$===39){u(40,l,l+1);return}}else if(z===45||z===46){let S=e.charCodeAt(l+2);if(S===45||S===46){u(40,l,l+1);return}}if(!Qe(z)){u(33,l,l+1);return}}u(29,l,C)},W=H=>{let z=e.charCodeAt(l+1);switch(H){case 101:if(w("erdiagram"))u(2,l,l+9);else if(w("end")){let C=l+3;for(;Ue(e.charCodeAt(C));)C++;u(16,l,C)}else return!1;return!0;case 115:if(w("style"))s=6,u(27,l,l+5);else if(w("subgraph"))u(17,l,l+8);else return!1;return!0;case 99:if(w("classdef"))s=6,u(22,l,l+8);else if(w("class"))u(26,l,l+5);else return!1;return!0;case 111:if(w("one or zero"))u(37,l,l+11);else if(w("one or more")||w("one or many"))u(39,l,l+11);else if(w("one"))u(40,l,l+3);else if(w("only one"))u(40,l,l+8);else if(z===124)u(37,l,l+2);else if(z===123)u(38,l,l+2);else if(w("optionally to"))u(42,l,l+13);else return!1;return!0;case 122:if(w("zero or one"))u(37,l,l+11);else if(w("zero or more")||w("zero or many"))u(38,l,l+12);else return!1;return!0;case 109:if(b("many(0)"))u(38,l,l+7);else if(b("many(1)"))u(39,l,l+7);else if(w("many"))u(38,l,l+4);else return!1;return!0;case 116:return w("to")?(u(43,l,l+2),!0):!1;case 117:return z!==46&&z!==45&&z!==124?!1:(u(41,l,l+1),!0);case 124:if(v(l+1)===111&&!Qe(e.charCodeAt(l+2)))u(37,l,l+2);else if(z===124)u(40,l,l+2);else if(z===123)u(39,l,l+2);else return!1;return!0;case 125:if(v(l+1)===111&&!Qe(e.charCodeAt(l+2)))u(38,l,l+2);else if(z===124)u(39,l,l+2);else return!1;return!0;case 46:return z!==46&&z!==45?!1:(u(42,l,l+2),!0);case 45:if(z===45)u(43,l,l+2);else if(z===46)u(42,l,l+2);else return!1;return!0}return!1},U=H=>{let z;if((H===97||H===65)&&b("acc")){if((z=m(oE,l))>=0){s=3,u(11,l,z);return}if((z=m(cE,l))>=0){s=4,u(13,l,z);return}if((z=m(hE,l))>=0){s=5,l=z;return}}if(!I()){switch(H){case 32:case 9:case 13:z=l+1;for(let C=e.charCodeAt(z);C===32||C===9||C===13;C=e.charCodeAt(z))z++;l=z;return;case 10:for(z=l+1;e.charCodeAt(z)===10;)z++;u(4,l,z);return;case 34:N();return;case 123:s=1,u(7,l,l+1);return;case 35:u(30,l,l+1);return;case 44:u(25,l,l+1);return;case 58:e.charCodeAt(l+1)===58&&e.charCodeAt(l+2)===58?u(6,l,l+3):u(5,l,l+1);return;case 91:u(9,l,l+1);return;case 93:u(10,l,l+1);return}if(pt(H)){O(H);return}if(!W(H>=65&&H<=90?H+32:H)){if(H>=128||_a[H]&nl){z=l+1;for(let C=e.charCodeAt(z);C>=128||_a[C]&nl;C=e.charCodeAt(z))z++;u(23,l,z);return}u(45,l,l+1)}}},_=()=>{if(f===-1||f<l&&(f=e.indexOf("~",l),f===-1))return!1;if(g<l){let z=l;for(;z<t&&!Ue(e.charCodeAt(z));)z++;g=z}if(f>=g||(p<l&&(p=k(l),d=e.lastIndexOf("~",p-1)),d<=f))return!1;let H=d+1;for(;H<t&&!Ue(e.charCodeAt(H));)H++;return u(34,l,H),!0},j=H=>{if(Ue(H)){for(l++;Ue(e.charCodeAt(l));)l++;return}let z=H|32;if((z===112||z===102||z===117)&&(e.charCodeAt(l+1)|32)===107&&!Qe(e.charCodeAt(l+2))){u(35,l,l+2);return}if(!_()){if(_1(H,Kd)){let C=l+1;for(;C<t&&_1(e.charCodeAt(C),ll);)C++;u(34,l,C);return}if(H===96){s=2,l++;return}if(H===34){let C=e.indexOf('"',l+1);if(C!==-1){u(36,l,C+1);return}}else if(H===125){s=0,u(8,l,l+1);return}u(45,l,l+1)}};for(;l<t;){let H=e.charCodeAt(l),z;switch(s){case 0:U(H);break;case 1:j(H);break;case 2:H===96?(s=1,l++):(z=e.indexOf("`",l),u(34,l,z===-1?t:z));break;case 3:case 4:z=e.indexOf(`
|
|
55
|
+
`,l),u(s===3?12:14,l,z===-1?t:z),s=0;break;case 5:H===125?(s=0,l++):(z=e.indexOf("}",l),u(15,l,z===-1?t:z));break;case 6:if(H===10){for(z=l+1;e.charCodeAt(z)===10;)z++;s=0,u(4,l,z)}else if(Ue(H))for(l++;Ue(e.charCodeAt(l));)l++;else if(H===58)u(5,l,l+1);else if(H===44)u(25,l,l+1);else if(H===35)u(30,l,l+1);else if(H===59)u(28,l,l+1);else if(H>=128||_a[H]&Oo){z=l+1;for(let C=e.charCodeAt(z);C>=128||_a[C]&Oo;C=e.charCodeAt(z))z++;u(24,l,z)}else return r.push(1),a.push(""),i.push(l),{types:r,texts:a,starts:i};break}}let Z=s===0?3:s===3?12:s===4?14:s===5?15:-1;return Z!==-1&&(r.push(Z),a.push(""),i.push(t)),r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function gE(e,t){let{types:r,texts:a,starts:i}=fE(e),s=0,l=O=>{let W=r[s];throw W===1?it("er",e,i[s],"",!0):it("er",e,i[s],`Expecting ${O}, got '${W===45?a[s]:C1[W]}'`)},n=O=>(r[s]!==O&&l(`'${C1[O]}'`),a[s++]),o=()=>{let O=r[s];O!==4&&O!==28&&O!==3&&l("'EOF', 'NEWLINE', 'SEMI'"),s++},c=O=>O===23||O===31||O===29||O===32||O===33,f=()=>{let O=r[s];c(O)||l(B1);let W=a[s++];return O===31?W.slice(1,-1):W},p=()=>{let O=[];for(;;){let W=r[s];if(W!==23&&W!==24&&l("'UNICODE_TEXT', 'STYLE_TEXT'"),O.push(a[s++]),r[s]!==25)return O;s++}},d=O=>O===24||O===29||O===5||O===30,g=()=>{let O=[];for(;;){d(r[s])||l("'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'");let W=a[s++];for(;d(r[s]);)W+=a[s++];if(O.push(W),r[s]!==25)return O;s++}},u=()=>{let O=Ud.get(r[s++]),W=r[s];W!==43&&W!==42&&l("'NON_IDENTIFYING', 'IDENTIFYING'");let U=W===43?"IDENTIFYING":"NON_IDENTIFYING";s++;let _=Ud.get(r[s]);return _===void 0?l(uE):(s++,{cardA:_,relType:U,cardB:O})},m=()=>{let O=r[s];O!==44&&O!==31&&O!==23&&l("'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'");let W=a[s++];return O===23?W:W.slice(1,-1)},b=O=>r[s]===45&&a[s]===O,w=()=>{let O=[];do{let W=n(34);b("?")&&(W+=a[s++]),r[s]!==34&&l(W.endsWith("?")?"'ATTRIBUTE_WORD'":"'ATTRIBUTE_WORD', '?'");let U={type:W,name:a[s++]};if(r[s]===35){let _=[a[s++]];for(;b(",");)s++,_.push(n(35));U.keys=_}r[s]===36&&(U.comment=a[s++].slice(1,-1)),O.push(U)}while(r[s]!==8);return O.reverse()},v=()=>{if(r[s]!==7)return;if(s++,r[s]===8){s++;return}let O=w();return s++,O},k=()=>{let O=f(),W=r[s];if(W===9){s++;let j=f();n(10);let Z;r[s]===6&&(s++,Z=p());let H=v();return t.addEntity(O,j),H&&t.addAttributes(O,H),Z&&t.setClass([O],Z),[O]}let U;if(W===6&&(s++,U=p(),W=r[s]),Ud.has(W)){let j=u(),Z=f(),H;r[s]===6&&(s++,H=p()),n(5);let z=m();return t.addEntity(O),t.addEntity(Z),t.addRelationship(O,z,Z,j),U&&t.setClass([O],U),H&&t.setClass([Z],H),[O,Z]}let _=v();return t.addEntity(O),_&&t.addAttributes(O,_),U&&t.setClass([O],U),[O]};n(2);let L=[{id:"",title:"",list:[]}],I=L[0],N=!1;for(;;){let O=r[s];switch(O){case 4:s++;break;case 3:s++,N&&l(`'END', ${Lo}`);return;case 16:{N||l(Lo),s++;let W=t.addSubGraph({text:I.id},I.list,{text:I.title});L.pop(),I=L[L.length-1],N=L.length>1,N&&I.list.push(W);break}case 17:{s++;let W=f(),U=W;if(r[s]===9){for(s++,U=f();c(r[s]);)U+=" "+f();n(10)}o(),I={id:W,title:U,list:[]},L.push(I),N=!0;break}case 11:{s++;let W=n(12).trim();t.setAccTitle(W),N&&I.list.push(W);break}case 13:{s++;let W=n(14).trim();t.setAccDescription(W),N&&I.list.push(W);break}case 15:{let W=a[s++].trim();t.setAccDescription(W),N&&I.list.push(W);break}case 18:case 19:case 20:case 21:{s++;let W=pE[O-18];N?I.list.push({stmt:"dir",value:W}):t.setDirection(W);break}case 22:{let W=a[s++],U=p(),_=g();o(),t.addClass(U,_),N&&I.list.push(W);break}case 26:{let W=a[s++],U=p();t.setClass(U,p()),N&&I.list.push(W);break}case 27:{let W=a[s++],U=p(),_=g();o(),t.addCssStyles(U,_),N&&I.list.push(W);break}default:{c(O)||l(N?`'END', ${Lo}`:Lo);let W=k();if(N)for(let U of W)I.list.push(U)}}}}function yE(e){let t=[],r=[],a=e.subgraphs,i=o=>{let c=[];for(let f of o){let p=e.classes.get(f);if(p!==void 0){for(let d of p.styles)c.push(d.trim());for(let d of p.textStyles)c.push(d.trim())}}return c},s=new Map,l=new Set;for(let o=a.length-1;o>=0;o--){let c=a[o];l.add(c.id);for(let f of c.nodes)s.set(f,c.id)}for(let o=a.length-1;o>=0;o--){let c=a[o];t.push({id:c.id,label:c.title,alias:"",attributes:mE,isGroup:!0,parentId:s.get(c.id),cssStyles:c.cssStyles,cssCompiledStyles:i(c.classes),cssClasses:c.classes.join(" "),dir:c.dir,labelType:c.labelType})}let n=new Map;for(let[o,c]of e.entities){if(l.has(o)){n.set(c.id,o);continue}t.push({id:c.id,label:c.label,alias:c.alias,attributes:c.attributes,isGroup:!1,parentId:s.get(o),cssStyles:c.cssStyles,cssCompiledStyles:i(c.cssClasses.split(" ")),cssClasses:c.cssClasses,dir:void 0,labelType:"markdown"})}return e.relationships.forEach((o,c)=>{r.push({id:`id_${o.entityA}_${o.entityB}_${c}`,start:n.get(o.entityA)??o.entityA,end:n.get(o.entityB)??o.entityB,label:o.roleA,arrowTypeStart:o.relSpec.cardB.toLowerCase(),arrowTypeEnd:o.relSpec.cardA.toLowerCase(),pattern:o.relSpec.relType==="IDENTIFYING"?"solid":"dashed"})}),{nodes:t,edges:r}}function Gs(e,t,r,a,i){let s=(f,p)=>h(t-a*f-i*p)+","+h(r-i*f+a*p),l=f=>`M${s(f,-I1)}L${s(f,I1)}`,n=`M${s(0,-N1)}L${s(qd,0)}L${s(0,N1)}`,o=f=>`<circle class="pele-marker" cx="${h(t-a*f)}" cy="${h(r-i*f)}" r="${R1}" fill="var(--_bg)"/>`,c=f=>`<path class="pele-marker" d="${f}"/>`;switch(e){case"only_one":return c(l(6)+l(10));case"zero_or_one":return c(l(6))+o(13.5);case"one_or_more":return c(n+l(qd+3.5));case"zero_or_more":return c(n)+o(qd+R1+.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""}function z1(e,t,r){let a=e.er?.[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function Do(e,t,r,a,i){let s=e.lines;if(s.length===0)return"";let l=s.length===1&&s[0].length===1?s[0][0]:void 0;if(l&&l.icon===void 0&&l.math===void 0&&l.style===0)return`<text${a} x="${h(t)}" y="${h(r)}">${Xe(l.text)}</text>`;let n=li(e),o=e.size*.35,c=r-o-e.lineHeight/2,f="",p="";for(let d=0;d<s.length;d++){let g=s[d],u=c+Ya(e,d);if(zs(g)){p+=Re(Ua(e,d),t+e.widths[d]/2,u,a,i);continue}r=u+o;let m=!1;for(let v of g)v.icon!==void 0&&(m=!0);let b=t,w=!1;for(let v of g){if(v.icon!==void 0){let k=e.size*1.1;p+=`<svg class="pele-icon" data-icon="${Oe(v.icon)}" x="${h(b)}" y="${h(r-e.size*.35-k/2)}" width="${h(k)}" height="${h(k)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(v.icon)??""}</svg>`}else if(v.text!==""){let k=m||!w?` x="${h(b)}" y="${h(r)}"`:"";f+=`<tspan${k}${Ha(v.style&~n)}>${Xe(v.text)}</tspan>`,w=!0}b+=v.width}}return`<text${Aa(a,n)} xml:space="preserve">${f}</text>${p}`}function Xd(e){let t=as(e);return t===e?e:t.replace(/</g,"<").replace(/>/g,">")}function TE(e,t,r){return jr(e.direction)?Bt(r,a=>F1(e,t,r,a)):F1(e,t,r,!1)}function F1(e,t,r,a){let i=yE(e),s=r.fontSize??16,l=Math.round(s*.875),n=r.measurer??et(r.fontFamily),o=r.padding??8,c=r.icons,f=new Map,p=[],d=[];i.nodes.forEach((E,x)=>f.set(E.id,x));let g=[],u=[],m=[],b=new Map,w=[];for(let E of i.edges){let x=f.get(E.start),T=f.get(E.end);if(x===void 0||T===void 0)continue;let A=ze(E.label,!0,n,l,200),M;if(x===T){M={label:A,band:0,at:0};let Y=b.get(x);Y?Y.push(M):b.set(x,[M])}w.push(M),m.push(E),u.push(A),g.push({src:x,dst:T,minlen:1,labelW:A.width>0?A.width+12:0,labelH:A.height>0?A.height+4:0,route:[],labelX:0,labelY:0})}let v=E=>{let x=E;for(let T=0;T<i.nodes.length;T++){let A=i.nodes[x].parentId,M=A===void 0?void 0:f.get(A);if(M===void 0)break;let Y=i.nodes[M].dir;if(Y)return Y==="LR"||Y==="RL";x=M}return e.direction==="LR"||e.direction==="RL"};for(let E=0;E<i.nodes.length;E++){let x=i.nodes[E],T=vt(x.cssStyles.length>0?x.cssCompiledStyles.concat(x.cssStyles):x.cssCompiledStyles),A=(T.bold?1:0)|(T.italic?2:0),M=T.fontSize??s,Y=T.fontSize??l,B=T.fontSize??Math.round(s*.75),q=x.isGroup?ze(x.label,!0,n,M,4e3,A):ze(x.alias||x.label,!0,n,M,240,A),D=b.get(E)??vE,R=D.length>0&&!x.isGroup&&v(E),P={node:x,style:T,label:q,w:0,h:0,headH:0,rows:[],cols:[],rowSize:Y,keySize:B,below:R},G=0,X=0;for(let F of D)F.band=Math.max($E,R?F.label.width+12:F.label.height+6),X+=F.band,G=Math.max(G,R?F.label.height:F.label.width);let Q=Math.max(L1,R?X+8:0),J;if(x.isGroup)J=Ut(0,0),J.isGroup=!0,J.dir=x.dir?br(x.dir):void 0,J.padX=il,J.padTop=P.label.height>0?P.label.height+16:il,J.padBottom=il,J.minW=Math.max(P.label.width+2*il-12,L1);else{let F=Math.max(q.height,Math.round(M*1.5));if(x.attributes.length===0)P.w=Math.max(q.width+2*D1,Q),P.h=Math.max(F+2*kE,R?0:X+8);else{let re=Math.round(Y*1.5),ne=[0,0,0,0];for(let te of x.attributes){let fe=[ze(Xd(te.type),!0,n,Y,Vd,A),ze(Xd(te.name),!0,n,Y,Vd,A),ze(te.keys.join(", "),!1,n,B,Vd,A),ze(Xd(te.comment),!0,n,Y,AE,A)],ye=re;for(let le=0;le<4;le++)fe[le].width>ne[le]&&(ne[le]=fe[le].width),fe[le].height>ye&&(ye=fe[le].height);P.rows.push({cells:fe,h:ye+jd}),P.h+=ye+jd}let de=0,ie=0;for(let te of ne)te!==0&&(ie+=te+(de>0?O1:0),de++);P.w=Math.max(ie+2*Gd,q.width+2*D1,Q);let se=de>0?(P.w-ie-2*Gd)/de:0,ee=Gd;for(let te of ne)P.cols.push(ee),te>0&&(ee+=te+se+O1);P.headH=F+2*ME,P.h+=P.headH}let K=D.length>0?2*(fi+sl*.75+10+G):0;J=R?Ut(P.w,P.h+K):Ut(P.w+K,P.h)}J.seq=p.length,p.push(P),d.push(J)}i.nodes.forEach((E,x)=>{d[x].parent=E.parentId!==void 0?f.get(E.parentId)??-1:-1});let k=Gr(d,g,a?"TB":br(e.direction),{nodeSep:z1(t,"nodeSpacing",xE),edgeSep:wE,rankSep:z1(t,"rankSpacing",bE),portSep:24});_E(g,d,p);let L=k.width;for(let[E,x]of b){let T=d[E];if(!T.isGroup)continue;let A=0;for(let M of x)A=Math.max(A,M.label.width);L=Math.max(L,T.x+T.w/2+fi+sl*.75+10+A)}let I=Cr(e.title,n,s,4e3),N=I.height>0?I.height+12:0,O=Math.max(L,I.width),W=o+(O-L)/2,U=o+N;vi(d,g,W,U);let _=Math.ceil(O+2*o),j=Math.ceil(k.height+N+2*o),Z=[],H=new Map,z=!1;for(let E of d)E.isGroup&&(z=!0);if(z)for(let E of g)va(H,E.route);let C="",S="";for(let E=0;E<p.length;E++){let x=p[E],T=d[E],A=x.node,M=_t(A.cssClasses.replace(/^default\s?/,""));if(T.isGroup){x.w=T.w,x.h=T.h;let J=T.x-T.w/2,F=T.y-T.h/2,K=Ai(T,x.label.width,H,il);C+=`<g class="pele-cluster${M}" data-id="${Oe(A.id)}"><rect x="${h(J)}" y="${h(F)}" width="${h(T.w)}" height="${h(T.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ft(x.style.shape)}/>`+Re(x.label,K,F+8+x.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${x.style.text}`,c)+"</g>";continue}let Y=x.w,B=x.h,q=-Y/2,D=-B/2,R=x.style.text,P=`x="${h(q)}" y="${h(D)}" width="${h(Y)}" height="${h(B)}"`,G=Re(x.label,0,x.rows.length>0?D+x.headH/2:0,` class="pele-label"${R}`,c),X=At(A.alias||A.label);if(/ internal-link(?: |$)/.test(M+" ")&&G!==""&&r.links!==!1){let J=oi(Sa(X),r)!==void 0,F=Xe(X);G=`<a class="internal-link"${J?` href="${F}"${ci(r)}`:""} data-href="${F}">${G}</a>`,Z.push({id:A.label,href:X,internal:!0})}let Q;if(x.rows.length===0)Q=`<rect ${P}${ft(P1+x.style.shape)}/>`+G;else{let J=Math.round(x.rowSize*1.5),F=x.style.stroke?Xe(x.style.stroke):"var(--_b)",K="",re="",ne=D+x.headH;for(let ie=0;ie<x.rows.length;ie++){let se=x.rows[ie];if(ie%2===0){let we=`x="${h(q)}" width="${h(Y)}"`;ie===x.rows.length-1?K+=`<rect ${we} y="${h(ne)}" height="${h(se.h)}"${st}/><rect ${we} y="${h(ne)}" height="${h(se.h/2)}"/>`:K+=`<rect ${we} y="${h(ne)}" height="${h(se.h)}"/>`}let ee=ne+jd/2+J/2+x.rowSize*.35,[te,fe,ye,le]=se.cells;re+=Do(te,q+x.cols[0],ee,` class="pele-er-type" fill="var(--_m)"${R}`,c)+Do(fe,q+x.cols[1],ee,` class="pele-er-name"${R}`,c)+Do(ye,q+x.cols[2],ee,` class="pele-er-keys" font-size="${x.keySize}" fill="var(--_m)"${R}`,c)+Do(le,q+x.cols[3],ee,` class="pele-er-comment" fill="var(--_m)"${R}`,c),ne+=se.h}let de=h(D+x.headH);Q=`<rect ${P}${ft(P1+x.style.shape)}/><g class="pele-er-stripes" fill="var(--_bg)"${x.style.shape.includes("fill:")?' opacity="0.6"':""}>${K}</g><path class="pele-er-divider" d="M${h(q)},${de}H${h(q+Y)}" stroke="${F}"/><rect ${P} fill="none" stroke="var(--_b)"${ft(x.style.line)}/>`+G+`<g class="pele-er-attributes" font-size="${x.rowSize}">${re}</g>`}S+=`<g class="pele-node pele-entity${M}" data-id="${Oe(A.label)}" transform="translate(${h(T.x)},${h(T.y)})">${Q}</g>`}for(let[E,x]of b){let T=p[E],A=0;for(let B of x)A+=B.band;let M=Math.min(1,Math.max((T.below?T.w:T.h)-8,0)/A),Y=-A*M/2;for(let B of x)B.band*=M,B.at=Y+B.band/2,Y+=B.band}let $="",y="";for(let E=0;E<g.length;E++){let x=g[E],T=m[E],A=u[E],M,Y,B,q=w[E];if(q){let R=d[x.src],P=p[x.src],G=Math.max(Math.min(q.band/2-6,13),1),X=fi+sl*.75+6;if(P.below){let Q=R.x+q.at,J=R.y+P.h/2,F=h(J+fi),K=h(J+fi+sl);M=`M${h(Q-G)},${h(J)}V${F}C${h(Q-G)},${K} ${h(Q+G)},${K} ${h(Q+G)},${F}V${h(J)}`,Y=Gs(T.arrowTypeStart,Q-G,J,0,-1),B=Gs(T.arrowTypeEnd,Q+G,J,0,-1),x.labelX=Q,x.labelY=J+X+A.height/2}else{let Q=R.x+P.w/2,J=R.y+q.at,F=h(Q+fi),K=h(Q+fi+sl);M=`M${h(Q)},${h(J-G)}H${F}C${K},${h(J-G)} ${K},${h(J+G)} ${F},${h(J+G)}H${h(Q)}`,Y=Gs(T.arrowTypeStart,Q,J-G,-1,0),B=Gs(T.arrowTypeEnd,Q,J+G,-1,0),x.labelX=Q+X+A.width/2,x.labelY=J}}else{let R=CE(x.route);if(R.length<6)continue;W1(R,0,p[x.src],d[x.src]),W1(R,R.length-3,p[x.dst],d[x.dst]);let P=Math.abs(R[R.length-3]-R[0]),G=Math.abs(R[R.length-2]-R[1]),X=R.length===6&&(P<.01||G<.01||Math.hypot(P,G)<=3*fi)?0:fi,Q=zr(R,void 0,X,X);M=X>0?`M${h(Q.sx)},${h(Q.sy)}L${Q.d.slice(1)}L${h(Q.ex)},${h(Q.ey)}`:Q.d,Y=Gs(T.arrowTypeStart,Q.sx,Q.sy,Q.sdx,Q.sdy),B=Gs(T.arrowTypeEnd,Q.ex,Q.ey,Q.edx,Q.edy)}let D=T.pattern==="dashed";if($+=`<g class="pele-edge pele-er-${D?"non-identifying":"identifying"}" data-id="${Oe(T.id)}"><path d="${M}"${D?' stroke-dasharray="4 3"':""}/>`+Y+B+"</g>",A.width>0){let R=x.labelX,P=x.labelY;y+=wr(T.id,A,R,P,"",c)}}return{svg:Je("er",_,j,s,r,e,Re(I,_/2,o+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+(C?`<g class="pele-clusters">${C}</g>`:"")+($?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${$}</g>`:"")+(y?`<g class="pele-edge-labels" font-size="${l}">${y}</g>`:"")+`<g class="pele-nodes">${S}</g>`),width:_,height:j,links:Z}}function CE(e){let t=e.slice(0,3);for(let r=3;r<e.length;r+=3){let a=t.length-3,i=s=>Math.abs(t[a+s]-e[r+s])<.01&&Math.abs(e[r+s]-e[r+3+s])<.01;r+3<e.length&&(i(0)||i(1))||t.push(e[r],e[r+1],e[r+2])}return t}function _E(e,t,r){let a=new Map,i=(s,l,n,o)=>{let c=t[s],f=l[n]-c.x,p=l[n+1]-c.y,d;if(Math.abs(Math.abs(p)-c.h/2)<.5)d=p<0?0:2;else if(Math.abs(Math.abs(f)-c.w/2)<.5)d=f<0?3:1;else return;let g=s*4+d,u={route:l,at:n,toward:l[o+(d&1?1:0)]},m=a.get(g);m?m.push(u):a.set(g,[u])};for(let s of e){let l=s.route.length-3;s.src===s.dst||l<3||(i(s.src,s.route,0,3),i(s.dst,s.route,l,l-3))}for(let[s,l]of a){if(l.length<2)continue;let n=s>>2,o=(s&1)===1,c=t[n].isGroup?t[n]:r[n],f=o?c.h:c.w,p=Math.max(Math.min(EE,(f-2*SE)/(l.length-1)),0),d=o?t[n].y:t[n].x;l.sort((g,u)=>g.toward-u.toward);for(let g=0;g<l.length;g++)l[g].route[l[g].at+(o?1:0)]=d+(g-(l.length-1)/2)*p}}function W1(e,t,r,a){if(a.isGroup)return;let i=e[t]-a.x,s=e[t+1]-a.y;a.w!==r.w&&Math.abs(Math.abs(i)-a.w/2)<.5&&(e[t]-=Math.sign(i)*(a.w-r.w)/2),a.h!==r.h&&Math.abs(Math.abs(s)-a.h/2)<.5&&(e[t+1]-=Math.sign(s)*(a.h-r.h)/2)}var lE,C1,nl,Oo,Kd,ll,_a,oE,cE,hE,dE,Hd,Yd,Ud,pE,B1,uE,Lo,mE,fi,I1,N1,qd,R1,xE,wE,bE,il,sl,$E,L1,D1,kE,ME,Gd,O1,jd,AE,Vd,vE,EE,SE,P1,H1,Y1=Ve(()=>{Bd();Fs();Ei();Ea();hi();tr();zt();pr();ut();wt();lE=class{constructor(){ce(this,"type","er");ce(this,"direction","TB");ce(this,"entities",new Map);ce(this,"relationships",[]);ce(this,"classes",new Map);ce(this,"subgraphs",[]);ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"subgraphLookup",new Map);ce(this,"claimed",new Set)}addEntity(e,t=""){let r=this.entities.get(e);return r===void 0?(r={id:`entity-${e}-${this.entities.size}`,label:e,alias:t,attributes:[],cssClasses:"default",cssStyles:[]},this.entities.set(e,r)):!r.alias&&t&&(r.alias=t),r}addAttributes(e,t){let r=this.addEntity(e);for(let a=t.length-1;a>=0;a--){let i=t[a];i.keys??(i.keys=[]),i.comment??(i.comment=""),r.attributes.push(i)}}addRelationship(e,t,r,a){let i=this.subgraphLookup.has(e)?e:this.addEntity(e).id,s=this.subgraphLookup.has(r)?r:this.addEntity(r).id;this.relationships.push({entityA:i,roleA:t,entityB:s,relSpec:a})}setDirection(e){this.direction=e}addCssStyles(e,t){if(t)for(let r of e){let a=this.entities.get(r);if(a)for(let s of t)a.cssStyles.push(s);let i=this.subgraphLookup.get(r);if(i)for(let s of t)i.cssStyles.push(s)}}addClass(e,t){for(let r of e){let a=this.classes.get(r);if(a===void 0&&(a={id:r,styles:[],textStyles:[]},this.classes.set(r,a)),!!t)for(let i of t)i.includes("color")&&a.textStyles.push(i.replace("fill","bgFill")),a.styles.push(i)}}setClass(e,t){for(let r of e){let a=this.entities.get(r);if(a)for(let s of t)a.cssClasses+=" "+s;let i=this.subgraphLookup.get(r);if(i)for(let s of t)i.classes.push(s)}}addSubGraph(e,t,r){let a=e.text.trim(),i=new Set,s=[],l;for(let o of t.flat()){if(typeof o!="string"){o?.stmt==="dir"&&(l=o.value);continue}let c=o.trim();c===""||i.has(c)||(i.add(c),this.claimed.has(o)||s.push(o))}for(let o of s)this.claimed.add(o);let n={id:a,nodes:s,title:(r.text||"").trim(),classes:[],cssStyles:[],dir:l,labelType:nE(r.type)};return this.subgraphs.push(n),this.subgraphLookup.set(a,n),a}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
56
|
+
`)}},C1=["$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"],nl=1,Oo=2,Kd=4,ll=8,_a=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,r=t&&(e<48||e>57);t&&(_a[e]|=nl|Oo|ll),r&&(_a[e]|=Kd)}for(let e of"-*")_a[e.charCodeAt(0)]|=nl|Oo|ll;_a[46]|=nl|ll;_a[42]|=Kd;for(let e of"[](),")_a[e.charCodeAt(0)]|=ll;oE=/accTitle\s*:\s*/iy,cE=/accDescr\s*:\s*/iy,hE=/accDescr\s*\{\s*/iy,dE=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],Hd=/direction/gi,Yd=/[\n\r\u2028\u2029]/g;Ud=new Map([[37,"ZERO_OR_ONE"],[38,"ZERO_OR_MORE"],[39,"ONE_OR_MORE"],[40,"ONLY_ONE"],[41,"MD_PARENT"]]),pE=["TB","BT","RL","LR"],B1="'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'",uE="'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'",Lo="'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', "+B1;mE=[];fi=18,I1=5,N1=6,qd=10,R1=3.5;xE=48,wE=20,bE=64,il=20,sl=28,$E=38,L1=96,D1=18,kE=12,ME=9,Gd=12,O1=16,jd=9,AE=260,Vd=1e6,vE=[],EE=18,SE=14,P1=' fill="var(--_s)" stroke="var(--_b)"';H1={type:"er",math:!0,parse(e,t,r){let a=new lE;return r&&(a.title=r),gE(e,a),a},render:TE}});var U1={};Ct(U1,{er:()=>H1});var q1=Ve(()=>{Y1()});function G1(e,t){return e===5?t?"KANBAN":"MINDMAP":IE[e]}function Po(e,t){switch(e){case"[":return Ii.RECT;case"(":return t===")"?Ii.ROUNDED_RECT:Ii.CLOUD;case"((":return Ii.CIRCLE;case")":return Ii.CLOUD;case"))":return Ii.BANG;case"{{":return Ii.HEXAGON;default:return Ii.DEFAULT}}function j1(e,t,r){for(let a=0;a<r.length;a++)if((e.charCodeAt(t+a)|32)!==r.charCodeAt(a))return!1;return!0}function FE(e,t){let r=e.length,a=[],i=[],s=[],l=t?"kanban":"mindmap",n=t?LE:RE,o=0,c=0,f=-1,p=(m,b,w)=>{a.push(m),i.push(b),s.push(c),c=w},d=(m,b,w)=>{p(m,e.slice(c,b),b),o=w},g=(m,b)=>(m.lastIndex=b,m.test(e)?m.lastIndex:-1),u=m=>{let b=e.indexOf(m,c);return b===-1?r:b};for(;c<r;){let m=e.charCodeAt(c),b=e.charCodeAt(c+1),w;if(o===0){let v=m<=32||m>=160?Math.max(g(NE,c),c):c;if(t&&m===64&&b===123)p(13,"",c+2),o=6;else if(e.charCodeAt(v)===37&&e.charCodeAt(v+1)===37)d(2,g(Zd,v),0);else if(v>c)f<c&&(f=u(`
|
|
57
|
+
`)),f>=v?d(6,v,0):(w=e.lastIndexOf(`
|
|
58
|
+
`,v-1))>c?d(2,w+1,0):d(3,c+1,0);else if(j1(e,c,l)&&!Qe(e.charCodeAt(c+l.length)))d(5,c+l.length,0);else if(m===58&&b===58&&e.charCodeAt(c+2)===58)c+=3,o=1;else if(m===58&&b===58&&j1(e,c+2,"icon")&&e.charCodeAt(c+6)===40)c+=7,o=2;else if(m===45&&b===41||m===40&&(b===45||b===40)||(m===41||m===123)&&b===m)d(9,c+2,3);else if(m===41||m===40||m===91)d(9,c+1,3);else if((w=g(n,c))!==-1)d(10,w,0);else break}else if(o===3)m===34?(o=b===96?5:4,c+=b===96?2:1):m===41||m===40?d(12,b===m||m===40&&b===45?c+2:c+1,0):m===93?d(12,c+1,0):m===125&&b===125||m===45&&b===41?d(12,c+2,0):d(11,g(m===125?Zd:DE,c),3);else if(o===4)m===34?(c++,o=3):d(11,u('"'),4);else if(o===5)if(m===96&&b===34)c+=2,o=3;else if((w=g(OE,c))!==-1)d(11,w,5);else break;else if(o===1)if((w=g(Zd,c))!==-1)d(8,w,0);else if(m===10)c++,o=0;else break;else if(o===2)m===41?(c++,o=0):d(7,u(")"),2);else if(o===6)if(m===34)d(13,c+1,7);else if(m===125)c++,o=0;else if((w=g(PE,c))!==-1)d(13,w,6);else break;else m===34?d(13,c+1,6):(w=u('"'),p(13,e.slice(c,w).replace(zE,"<br/>"),w))}return c<r?p(1,"",c):(o===0&&p(4,"",r),p(0,"",r)),{types:a,texts:i,starts:s}}function js(e){return e===2||e===3||e===4}function zo(e,t,r){let a=r?"kanban":"mindmap",{types:i,texts:s,starts:l}=FE(e,r),n=r?", 'SHAPE_DATA'":"",o=0,c=d=>{let g=i[o];throw g===1?it(a,e,l[o],"",!0):it(a,e,l[o],`Expecting ${d}, got '${G1(g,r)}'`)},f=`'${G1(5,r)}'`;if(i[o]===2){for(o++;i[o]===2||i[o]===3;)o++;i[o]!==5&&c(`'SPACELINE', 'NL', ${f}`)}else i[o]!==5&&c(`'SPACELINE', ${f}`);o++;let p="'SPACELINE', 'NL', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'";for(i[o]===3&&(o++,p="'SPACELINE', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'");;){let d=i[o],g=0,u=d===6;if(u&&(g=s[o++].length,d=i[o]),d===10||d===9){let m,b,w=0;if(d===10&&(m=s[o++]),i[o]===9){let v=s[o++];i[o]!==11&&c("'NODE_DESCR'"),b=s[o++],i[o]!==12&&c("'NODE_DEND'");let k=s[o++];!js(i[o])&&i[o]!==13&&c(is+n),w=t.getType(v,k)}else!js(i[o])&&i[o]!==13&&c(is+", 'NODE_DSTART'"+n),b=m;if(i[o]===13){let v=s[o++];for(;i[o]===13;)v+=s[o++];js(i[o])||c(is+n),t.addNode(g,m??b,b,w,v)}else t.addNode(g,m??b,b,w)}else if(d===7||d===8){let m=s[o++];js(i[o])||c(is),t.decorateNode(d===7?{icon:m}:{class:m})}else u?js(d)||c(is+", 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'"):d===2?js(i[++o])||c(is):c(p);for(o++;i[o]===3||i[o]===4;)o++;if(i[o]===0)return;V1[i[o]]===0&&c(is+", 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'")}}function ol(e,t,r,a,i){return`<svg class="pele-icon" data-icon="${Oe(e)}" x="${h(t)}" y="${h(r)}" width="${h(a)}" height="${h(a)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??""}</svg>`}var IE,Ii,NE,Zd,RE,LE,DE,OE,PE,zE,is,V1,Qd=Ve(()=>{tr();ut();wt();IE=["1","INVALID","SPACELINE","NL","EOF","","SPACELIST","ICON","CLASS","NODE_DSTART","NODE_ID","NODE_DESCR","NODE_DEND","SHAPE_DATA"];Ii={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6};NE=/\s+/y,Zd=/.+/y,RE=/[^([\n){}]+/y,LE=/[^([\n){}@]+/y,DE=/[^)\](}]+/y,OE=/[^`"]+/y,PE=/[^}^"]+/y,zE=/\n\s*/g;is="'SPACELINE', 'NL', 'EOF'",V1=new Uint8Array(14);for(let e of[2,6,7,8,9,10])V1[e]=1});function HE(e,t){zo(e,t,!1)}function KE(e,t,r,a){if(e.lines.length<2)return Re(e,t+e.width/2,r,' class="pele-label"',a);let i="",s=r-e.height/2;for(let l=0;l<e.lines.length;l++)i+=Re(Ua(e,l),t+e.widths[l]/2,s+Ya(e,l),' class="pele-label"',a);return i}function ZE(e,t,r){return Bt(r,a=>QE(e,t,r,a))}function QE(e,t,r,a){let i=r.fontSize??16,s=r.measurer??et(r.fontFamily),l=r.padding??8,n=r.icons,o=t.mindmap?.maxNodeWidth,c=typeof o=="number"&&o>0?Math.min(o,2e3):200,f=i*1.25,p=e.nodes,d=p.length,g=new Int32Array(d),u=new Int32Array(d);for(let J=0;J<d;J++)for(let F of p[J].children)g[F.id]=J,u[F.id]=u[J]+1;let m=a&&r.maxWidth!==void 0&&r.maxWidth>0?r.maxWidth-2*l:1/0,b=new Array(d),w=new Array(d),v=new Float64Array(d),k=new Float64Array(d),L=new Float64Array(d),I=new Float64Array(d),N=new Uint8Array(d);for(let J=0;J<d;J++){let F=p[J];N[J]=F.icon!==void 0&&Ds(F.icon)!==""?1:0;let K=Math.min(c,Math.max(72,m-u[J]*ef-2*Z1-(N[J]?f+Jd:0))),re=b[J]=ze(F.descr,!0,s,i,K),ne=re.width+(N[J]?f+(re.width>0?Jd:0):0),de=Math.max(re.height,Math.round(i*1.5)),ie=YE[F.type]||(J===0?X1:"");if(a&&J===0&&ie!=="rect"&&ie!=="rounded"&&(ie=X1),w[J]=ie,ie===""){let se=F.children.length>0;v[J]=ne+2*(se?VE:Z1),k[J]=de+(se?6:0),I[J]=k[J]/2}else{let se=Si(ie,ne,de);v[J]=se.w,k[J]=se.h,L[J]=se.dy,I[J]=se.h/2}}let O=new Float64Array(d),W=new Float64Array(d),U=new Float64Array(d),_=new Float64Array(d),j=0,Z=(J,F,K,re)=>{let ne=0,de=0;for(let ee=F;ee<K;ee++){let te=J[ee].id;W[te]=ne,de=J[ee].children.length>0||ee+1<K&&J[ee+1].children.length>0?Math.max(re,GE):re,ne+=O[te]+de}j=ne-de;let ie=J[F].id,se=J[K-1].id;return(W[ie]+U[ie]+I[ie]+W[se]+U[se]+I[se])/2};for(let J=d-1;J>0;J--){let F=p[J].children;if(F.length===0){O[J]=k[J];continue}let K=Z(F,0,F.length,qE)-I[J],re=Math.min(0,K);O[J]=Math.max(j,K+k[J])-re,U[J]=K-re,_[J]=-re}let H=new Float64Array(d),z=new Float64Array(d),C=new Float64Array(d),S=new Int8Array(d),$=new Float64Array(d);if(a){let J=0;for(let F=0;F<d;F++)F>0&&g[F]===0&&(J+=eg),H[F]=u[F]*ef+v[F]/2,z[F]=J,J+=k[F]+eg}else if(d>0){let J=p[0].children,F=J.length,K=0;for(let ie of J)K+=O[ie.id];let re=F,ne=1/0,de=0;for(let ie=1;ie<F;ie++){de+=O[J[ie-1].id];let se=Math.abs(2*de-K+(2*ie-F)*K1);se<ne&&(ne=se,re=ie)}for(let ie=0,se=re,ee=1;ie<F;ie=se,se=F,ee=-1){let te=Z(J,ie,se,K1);for(let fe=ie;fe<se;fe++){let ye=J[fe].id;C[ye]=W[ye]-te,S[ye]=ee}}z[0]=-k[0]/2;for(let ie=0;ie<d;ie++){ie>0&&(z[ie]=C[ie]+U[ie]);for(let se of p[ie].children){let ee=se.id;ie>0&&(S[ee]=S[ie],C[ee]=C[ie]+_[ie]+W[ee]),H[ee]=H[ie]+S[ee]*(v[ie]/2+(ie>0?UE:jE)+v[ee]/2)}}}let y=0,E=0,x=0,T=0,A="",M="",Y="",B="",q=J=>{Y!==""&&(A+=`<g class="pele-branch pele-section-${J??0}"><g class="pele-edges" fill="none" stroke="${B}" stroke-width="1.5">${M}</g>${Y}</g>`,M=Y="")};for(let J=1;J<=d;J++){let F=J%d,K=p[F],re=w[F],ne=b[F],de=H[F],ie=z[F];if(y=Math.min(y,de-v[F]/2),E=Math.max(E,de+v[F]/2),x=Math.min(x,ie),T=Math.max(T,ie+k[F]),(F===0||g[F]===0)&&q(p[J-1].section),F>0&&a){g[F]===0&&(B=dt(K.section??0));let le=g[F],we=le===0?Math.min(Math.max(Q1,k[0]/2),ef-J1):Q1,pe=H[le]-v[le]/2+Math.min(we,v[le]/2),ge=$[le]||z[le]+k[le],Ae=de-v[F]/2+(re?di(re,v[F],k[F],3):0),Se=ie+I[F],oe=Math.max(0,Math.min(J1,Ae-pe,Se-ge));$[le]=Se-oe,M+=`<path class="pele-edge" d="M${h(pe)},${h(ge)}V${h(Se-oe)}Q${h(pe)},${h(Se)} ${h(pe+oe)},${h(Se)}H${h(Ae)}"/>`}else if(F>0){g[F]===0&&(B=dt(K.section??0));let le=g[F],we=S[F],pe=we>0?1:3,ge=H[le]+we*(v[le]/2-(w[le]?di(w[le],v[le],k[le],pe):0)),Ae=z[le]+I[le],Se=de-we*v[F]/2+(re?we*di(re,v[F],k[F],4-pe):0),oe=ie+I[F],ue=h((ge+Se)/2);M+=`<path class="pele-edge" d="M${h(ge)},${h(Ae)}C${ue},${h(Ae)} ${ue},${h(oe)} ${h(Se)},${h(oe)}"/>`}let se=!re&&K.children.length>0,ee=` fill="${B}" fill-opacity="${XE}" stroke="${B}"`,te="";re?te=F>0?Ca(re,v[F],k[F],ee,` stroke="${B}"`):Ca(re,v[F],k[F],' fill="var(--_s)" stroke="var(--_b)"',' stroke="var(--_b)"'):se&&(te=`<rect x="${h(-v[F]/2)}" y="${h(-k[F]/2)}" width="${h(v[F])}" height="${h(k[F])}" rx="${h(k[F]/2)}"${ee}/>`);let fe=0;K.icon&&N[F]&&(fe=(f+(ne.width>0?Jd:0))/2,te+=ol(K.icon,-fe-ne.width/2,L[F]-f/2,f,n));let ye=`<g class="pele-node pele-shape-${re||(se?"branch":"text")}${F>0?"":" pele-root"}${_t(K.class??"")}" data-id="${Oe(K.nodeId)}" transform="translate(${h(de)},${h(ie+k[F]/2)})">`+te+(a&&!re?KE(ne,fe-ne.width/2,L[F],n):Re(ne,fe,L[F],' class="pele-label"',n))+"</g>";F>0?Y+=ye:A+=ye}let D=Cr(e.title,s,i,It(r)),R=D.height>0?D.height+16:0,P=Math.max(E-y,D.width),G=Math.ceil(P+2*l),X=Math.ceil(T-x+R+2*l),Q=Re(D,G/2,l+D.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${h(l-y+(P-E+y)/2)},${h(l+R-x)})">${A}</g>`;return{svg:Je("mindmap",G,X,i,r,{},Q),width:G,height:X,links:[]}}var WE,BE,YE,X1,UE,qE,GE,jE,K1,Z1,VE,XE,Jd,ef,Q1,J1,eg,tg,rg=Ve(()=>{Qd();Ea();Ti();zt();ut();wt();WE=11,BE=class{constructor(){ce(this,"type","mindmap");ce(this,"title");ce(this,"nodes",[]);ce(this,"getType",Po);ce(this,"baseLevel",0);ce(this,"open",[])}addNode(e,t,r,a){let i=this.nodes.length===0;i&&(this.baseLevel=e),e-=this.baseLevel;let s=this.open,l=s.length;for(;l>0&&s[l-1].level>=e;)l--;let n=s[l-1];if(!n&&!i)throw new je(`There can be only one root. No parent could be found for ("${r}")`,"semantic",{type:"mindmap"});let o={id:this.nodes.length,nodeId:t,level:e,descr:r,type:a,children:[],isRoot:i};n&&(o.section=n.isRoot?n.children.length%WE:n.section,n.children.push(o)),s.length=l,s.push(o),this.nodes.push(o)}decorateNode(e){let t=this.nodes[this.nodes.length-1];!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.class=e.class))}};YE=["","rounded","rect","circle","cloud","bang","hex"],X1="stadium",UE=36,qE=8,GE=18,jE=52,K1=28,Z1=6,VE=12,XE=.22,Jd=6,ef=28,Q1=12,J1=8,eg=10;tg={type:"mindmap",math:!0,parse(e,t,r){let a=new BE;return a.title=r,HE(e,a),a},render:ZE}});var ag={};Ct(ag,{mindmap:()=>tg});var ig=Ve(()=>{rg()});function e3(e,t){zo(e,t,!0)}function Fo(e,t,r,a,i,s=0){let l=ze(e,t,r,a,i,s);if(l.width<=i)return l;let n=[],o=[],c=0,f=[],p=0,d=()=>{n.push(f),o.push(p),c=Math.max(c,p),f=[],p=0};for(let u=0;u<l.lines.length;u++){if(l.widths[u]<=i){f=l.lines[u],p=l.widths[u],d();continue}for(let m of l.lines[u]){if(m.icon!==void 0||m.math){p>0&&p+m.width>i&&d(),f.push(m),p+=m.width;continue}let b="",w=p;for(let v of m.text){let k=r.width(v,a,m.style);p>0&&p+k>i&&(b&&f.push({text:b,style:m.style,width:p-w}),d(),b="",w=0),b+=v,p+=k}b&&f.push({text:b,style:m.style,width:p-w})}d()}let g={...l,lines:n,widths:o,width:c,height:n.length*l.lineHeight};return l.heights?Yn(g):g}function hl(e,t,r,a,i,s=!1){let l="";for(let n=0;n<e.lines.length;n++){let o=e.lines[n],c=r+Ya(e,n);if(o.length===1&&o[0].icon===void 0&&o[0].math===void 0)l+=`<text${Aa(a,o[0].style)} x="${h(t)}" y="${h(c+e.size*.35)}"${s?' text-anchor="end"':""}>${Xe(o[0].text)}</text>`;else{let f=e.widths[n];l+=Re(Ua(e,n),t+(s?-f:f)/2,c,a,i)}}return l}function a3(e,t,r){let a=r.fontSize??16,i=Math.round(a*.875),s=Math.round(a*1.5),l=Math.round(i*1.5),n=r.measurer??et(r.fontFamily),o=r.padding??8,c=r.icons,f=t.kanban??{},p=f.sectionWidth,d=i*1.25,g=0,u=(R,P,G)=>{if(!(!R||!R.includes("$$")))for(let X of ze(R,!0,n,P,1/0).lines)for(let Q of X)Q.math&&(g=Math.max(g,Q.math.width+G))};for(let R of e.sections){let P=n.width(String(R.items.length),i,0);u(R.label,a,2*ja+8+P+12+(Vs(R.icon)?d+cl:0));for(let G of R.items){let X=2*(ja+Ia);u(G.label,i,X+(Vs(G.icon)?d+cl:0)),u(G.ticket,i,X),u(G.assigned,i,X)}}let m=Math.max(typeof p=="number"&&p>0?Math.min(Math.max(p,80),2e3):200,Math.ceil(g)),b=r.maxWidth!==void 0&&r.maxWidth>0?r.maxWidth-2*o:1/0,w=e.sections.length,v=w*(m+Ga)-Ga<=b,k=v?Math.max(w,1):Math.max(1,Math.floor((b+Ga)/(m+Ga))),L=v?m:Math.max(Math.min(m,b),Math.min(Math.floor((b+Ga)/k)-Ga,m*2),Math.ceil(g)),I=typeof f.ticketBaseUrl=="string"?f.ticketBaseUrl:"",N=L-2*ja,O=N-2*Ia,W=[],U=e.sections,_=[],j=[],Z=[],H=s,z=[];for(let R of U){let P=n.width(String(R.items.length),i,0),G=P+12+(Vs(R.icon)?d+cl:0),X=Fo(R.label,!0,n,a,N-8-G,1);H=Math.max(H,X.height),j.push(P),_.push(X);let Q=[],J=0;for(let F of R.items){let K=Fo(F.label,!0,n,i,O-(Vs(F.icon)?d+cl:0)),re=Fo(F.ticket,!1,n,i,O),ne=Fo(F.assigned,!1,n,i,O),de=re.width+ne.width+8>O?re.height+ne.height:Math.max(re.height,ne.height),ie=2*Ia+Math.max(K.height,l)+(de?t3+de:0);Q.push({item:F,label:K,ticket:re,assigned:ne,meta:de,height:ie}),J+=ie+tf}Z.push(Q),z.push(J)}H+=2*ja;let C=[],S=[];for(let R=0,P=0;R<U.length;R+=k){let G=tf;for(let X=R;X<Math.min(R+k,U.length);X++)G=Math.max(G,z[X]);S.push(P),C.push(H+G),P+=H+G+Ga}let $=C.length>0?S[S.length-1]+C[C.length-1]:0,y=Cr(e.title,n,a,It(r)),E=y.height>0?y.height+16:0,x=Math.max(Math.min(U.length,k)*(L+Ga)-Ga,0),T=Math.max(x,y.width),A=o+(T-x)/2,M=L-ja-4,Y="";for(let R=0;R<U.length;R++){let P=U[R],G=Math.floor(R/k),X=`<rect width="${L}" height="${h(C[G])}" fill="var(--_s)"${st}/>`+hl(_[R],ja+4,ja,' class="pele-cluster-label" font-weight="var(--_hw)"',c)+`<text class="pele-count" x="${M}" y="${h(ja+s/2+i*.35)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${P.items.length}</text>`;Vs(P.icon)&&(X+=ol(P.icon,M-j[R]-cl-d,ja+(s-d)/2,d,c));let Q=H;for(let J of Z[R]){let F=J.item,K=(F.priority??"").trim().toLowerCase(),re=r3.get(K),ne=`<rect width="${N}" height="${h(J.height)}" fill="var(--_bg)" stroke="var(--_b)"${st}/>`;re!==void 0&&(ne+=`<path class="pele-priority" d="M2.5,5V${h(J.height-5)}" fill="none" ${re} stroke-width="3" stroke-linecap="round"/>`),ne+=hl(J.label,Ia,Ia,' class="pele-label"',c),Vs(F.icon)&&(ne+=ol(F.icon,N-Ia-d,Ia+(l-d)/2,d,c));let de=J.height-Ia;if(F.ticket){let ie=de-J.meta,se=I?oi(Ta(I.replace("#TICKET#",()=>F.ticket)),r):void 0;se===void 0?ne+=hl(J.ticket,Ia,ie,' class="pele-ticket" fill="var(--_m)"',c):(ne+=`<a href="${Xe(se)}" target="_blank"${ci(r)}>`+hl(J.ticket,Ia,ie,' class="pele-ticket" fill="var(--_c)"',c)+"</a>",W.push({id:F.id,href:se,internal:!1}))}F.assigned&&(ne+=hl(J.assigned,N-Ia,de-J.assigned.height,' class="pele-assigned" fill="var(--_m)"',c,!0)),X+=`<g class="pele-node pele-card${re===void 0?"":" pele-priority-"+K.replace(" ","-")}${_t(F.cssClasses??"")}" data-id="${Oe(F.id)}" transform="translate(${ja},${h(Q)})" font-size="${i}">${ne}</g>`,Q+=J.height+tf}Y+=`<g class="pele-cluster pele-column${_t(P.cssClasses??"")}" data-id="${Oe(P.id)}" transform="translate(${h(A+R%k*(L+Ga))},${h(o+E+S[G])})">${X}</g>`}let B=Math.ceil(T+2*o),q=Math.ceil($+E+2*o),D=Re(y,B/2,o+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+Y;return{svg:Je("kanban",B,q,a,r,{},D),width:B,height:q,links:W}}var JE,Ga,ja,Ia,tf,t3,cl,r3,Vs,sg,ng=Ve(()=>{Qd();Rs();Ea();hi();zt();ut();wt();JE=class{constructor(){ce(this,"type","kanban");ce(this,"title");ce(this,"sections",[]);ce(this,"getType",Po);ce(this,"last");ce(this,"sectionLevel",0);ce(this,"misplaced")}addNode(e,t,r,a,i){let s={id:t,level:e,label:r};if(i!==void 0){let n=i.includes(`
|
|
59
|
+
`)?i+`
|
|
60
|
+
`:`{
|
|
61
|
+
`+i+`
|
|
62
|
+
}`,o;try{o=Ma(n)}catch(c){throw new je(`Metadata of "${s.id}" is not valid YAML. ${c.message}`,"syntax",{type:"kanban"})}if(o!==null&&typeof o=="object"&&!Array.isArray(o)){let c=o.shape?String(o.shape):"";if(c!==c.toLowerCase()||c.includes("_"))throw new je(`No such shape: ${c}. Shape names should be lowercase.`,"semantic",{type:"kanban"});o.label&&(s.label=String(o.label)),o.icon&&(s.icon=String(o.icon)),o.assigned&&(s.assigned=String(o.assigned)),o.ticket&&(s.ticket=String(o.ticket)),o.priority&&(s.priority=String(o.priority))}}if(this.misplaced)throw new je(`Items without section detected, found section ("${this.misplaced.label}")`,"semantic",{type:"kanban"});let l=this.sections;if(l.length===0&&(this.sectionLevel=e),this.last=s,e===this.sectionLevel){let n=s;n.items=[],l.push(n)}else l[l.length-1].items.push(s),e<this.sectionLevel&&(this.misplaced=s)}decorateNode(e){let t=this.last;!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.cssClasses=e.class))}};Ga=12,ja=8,Ia=10,tf=8,t3=4,cl=6,r3=new Map([["very high",`stroke="${qn}"`],["high",`stroke="${qn}" opacity="0.5"`],["low",'stroke="var(--_m)" opacity="0.5"'],["very low",'stroke="var(--_m)"']]);Vs=e=>!!e&&Ds(e)!=="";sg={type:"kanban",math:!0,parse(e,t,r){let a=new JE;return a.title=r,e3(e,a),a},render:a3}});var lg={};Ct(lg,{kanban:()=>sg});var og=Ve(()=>{ng()});function Xs(e,t){let r=e.indexOf(`
|
|
63
|
+
`,t);return r===-1?e.length:r}function ma(e,t,r){for(let a=0;a<r.length;a++)if((e.charCodeAt(t+a)|32)!==r.charCodeAt(a))return!1;return!0}function Wo(e,t){let r=e.length,a=t;for(;a<r;){let i=e.charCodeAt(a);if(i===37&&e.charCodeAt(a+1)!==123)a=Xs(e,a);else if(i!==125&&e.charCodeAt(a+1)===37&&e.charCodeAt(a+2)===37)a=Xs(e,a+3);else{if(i===10)return a;if(Ue(i))do a++;while(a<r&&Ue(e.charCodeAt(a)));else if(i===35)a=Xs(e,a);else return a}}return a}function rf(e,t){let r=t;for(;Ue(e.charCodeAt(r));)r++;return r}function Bo(e,t,r,a){let i=ma(e,t,"accdescr");if(!i&&!ma(e,t,"acctitle"))return t;let s=e.length,l=rf(e,t+8),n=e.charCodeAt(l),o=(c,f,p)=>{r.types.push(c),r.texts.push(e.slice(f,p)),r.starts.push(f)};if(n===58){l=rf(e,l+1);let c=Xs(e,l);return o(i?a+2:a,t,l),o(i?a+3:a+1,l,c),c}if(!i||n!==123)return t;for(l=rf(e,l+1);e.charCodeAt(l)!==125;){let c=e.indexOf("}",l);if(c===-1&&(c=s),o(a+4,l,c),l===s)return s;l=c}return l+1}var af=Ve(()=>{tr()});function Na(e,t,r,a,i=0){let s=e;return s!==void 0&&(s.includes("<")&&(s=s.replace(i3,"<")),s.includes(":fa-")&&(s=s.replace(s3,":fa-"))),ze(s,!1,t,r,a,i)}function Kr(e,t,r,a,i=0){let s=Na(e,t,r,a,i);if(e===void 0||s.width<=a)return s;let l="",n=0;for(let o of e.match(n3)??[]){if(o.trim()===""||o.length>2&&o[0]==="<")n=0;else{let c=t.width(o.length>2?"x":o,r,i);n>0&&n+c>a&&(l+=`
|
|
64
|
+
`,n=0),n+=c}l+=o}return Na(l,t,r,a,i)}var i3,s3,n3,Ho=Ve(()=>{ut();i3=/<(?!br\s*\/?>)/gi,s3=/:fa-/g,n3=/<br\s*\/?>|fl°°?\w+¶ß|&#?\w+;|[\ud800-\udbff][\udc00-\udfff]|[\s\S]/gi});function c3(e){let t=e.length,r=[],a=[],i=[],s={types:r,texts:a,starts:i},l=0,n=(o,c)=>{r.push(o),a.push(e.slice(l,c)),i.push(l),l=c};for(;l=Wo(e,l),!(l>=t);){let o=e.charCodeAt(l),c=l+1;if(o===10){for(;e.charCodeAt(c)===10;)c++;n(3,c);continue}if(ma(e,l,"timeline")){for(c=l+8;e.charCodeAt(c)===32||e.charCodeAt(c)===9;)c++;let f=ma(e,c,"lr");if(c>l+8&&(f||ma(e,c,"td"))&&!Qe(e.charCodeAt(c+2))){n(f?5:6,c+2);continue}if(!Qe(e.charCodeAt(l+8))){n(4,l+8);continue}}if(ma(e,l,"title")&&Ue(e.charCodeAt(l+5))&&l+6<t&&e.charCodeAt(l+6)!==10){n(7,Xs(e,l+6));continue}if(c=Bo(e,l,s,8),c!==l){l=c;continue}if(ma(e,l,"section")&&Ue(e.charCodeAt(l+7))){for(c=l+8;c<t&&e.charCodeAt(c)!==58&&e.charCodeAt(c)!==10;)c++;if(c>l+8){n(13,c);continue}}if(o!==58){c=l+1;for(let f=e.charCodeAt(c);c<t&&f!==35&&f!==58&&f!==10;f=e.charCodeAt(++c));n(14,c);continue}if(Ue(e.charCodeAt(l+1))){for(c=l+2;c<t;c++){let f=e.charCodeAt(c);if(f===10||f===58&&Ue(e.charCodeAt(c+1)))break}if(c>l+2){n(15,c);continue}}n(2,l+1)}return(i.length===0||i[i.length-1]<t)&&n(1,t),n(0,t),s}function d3(e,t){let{types:r,texts:a,starts:i}=c3(e),s=(n,o)=>{let c=r[n]===0?"1":o3[r[n]];throw it("timeline",e,i[n],`Expecting ${o}, got '${c}'`)},l=r[0];l!==4&&l!==5&&l!==6&&s(0,"'timeline', 'timeline_lr', 'timeline_td'"),l!==4&&t.setDirection(l===5?"LR":"TD");for(let n=1;;n++){let o=a[n];switch(r[n]){case 3:break;case 7:t.getCommonDb().setDiagramTitle(o.substring(6));break;case 8:t.getCommonDb().setAccTitle(a[++n].trim());break;case 10:t.getCommonDb().setAccDescription(a[++n].trim());break;case 12:t.getCommonDb().setAccDescription(o.trim());break;case 13:t.addSection(o.substring(8));break;case 14:t.addTask(o,0,"");break;case 15:t.addEvent(o.substring(2));break;case 1:return;default:s(n,h3)}}}function nf(e,t,r,a,i){return`<rect x="${h(e)}" y="${h(t)}" width="${h(r)}" height="${h(a)}"${ft(i)}/>`}function g3(e,t,r){return e.direction==="TD"?fg(e,t,r,!0):Bt(r,a=>fg(e,t,r,a))}function fg(e,t,r,a){let i=r.fontSize??16,s=Math.round(i*.875),l=r.measurer??et(r.fontFamily),n=r.padding??8,o=t.timeline?.disableMulticolor!==!0,c=e.periods,f=e.sections.length>0,p=e.sections.map((K,re)=>({section:re,periods:[]})),d={section:-1,periods:[]};c.forEach((K,re)=>(p[K.sectionIndex]??d).periods.push(re)),d.periods.length>0&&p.unshift(d);let g=a&&r.maxWidth!==void 0&&r.maxWidth>0?r.maxWidth-2*n:1/0,u=Ks+Uo*2+4*Yo,m=Math.min(f3,Math.max(80,Math.round((g-u)*.38))),b=Math.min(u3,Math.max(110,g-u-m)),w=m,v=()=>a?b:w,k=c.map(K=>Na(K.text,l,i,w)),L=c.map(K=>K.events.map(re=>Na(re,l,s,v()))),I=0;for(let K of k)I=Math.max(I,K.width);if(!a)for(let K of L)for(let re of K)I=Math.max(I,re.width);let N=I>w;if(a)for(let K of L)for(let re of K)N||(N=re.width>b);N&&(w=Math.min(Math.max(Math.ceil(I),m),g===1/0?p3:m),k=c.map(K=>Kr(K.text,l,i,w)),L=c.map(K=>K.events.map(re=>Kr(re,l,s,v()))));let O=Math.round(i*1.5),W=w+2*Yo,U=v()+2*Yo,_=K=>Math.max(K.height,O)+2*cg,j=K=>Math.max(K.height,Math.round(s*1.5))+2*cg,Z=(K,re)=>K.section>=0?dt(K.section):f?"var(--_m)":dt(o?re:0),H=!1;for(let K of L)K.length>0&&(H=!0);let z=0;for(let K of p)z+=Math.max(K.periods.length,1);let C=W+ss,S=c.length>0,$=a?W+(H?Ks+Uo*2+U:S?Ks+qo:0):z>0?z*C-ss+(S?qo+Ht:0):0,y=Kr(e.title,l,i,Math.max($,320),1),E=y.height>0?y.height+16:0,x=Math.max($,y.width),T=n+(x-$)/2,A=n+E,M=(K,re)=>Kr(e.sections[K.section],l,i,re-2*Yo,1),Y=(K,re,ne,de,ie,se)=>nf(ne,de,ie,se,` fill="${dt(K.section)}"`)+Re(re,ne+ie/2,de+se/2,' font-weight="var(--_hw)"'+hg),B=(K,re,ne,de,ie)=>nf(ne,de,W,ie,` fill="${re}"`)+Re(k[K],ne+W/2,de+ie/2,hg),q=(K,re,ne,de,ie)=>'<g class="pele-node pele-event">'+nf(ne,de,U,ie,` fill="${re}" fill-opacity="0.16"`)+Re(K,ne+U/2,de+ie/2,` font-size="${s}"`)+"</g>",D=(K,re,ne)=>`<circle class="pele-dot" cx="${h(K)}" cy="${h(re)}" r="4" fill="${ne}" stroke="var(--_bg)" stroke-width="2"/>`,R=K=>K.section>=0?`<g class="pele-cluster pele-section" data-id="${Oe(e.sections[K.section].trim())}">`:"",P=K=>`<g class="pele-node pele-period" data-id="${Oe(c[K].text.trim())}">`,G="",X;if(a){let K=T+W+Ks,re=K+Uo,ne=re+Uo,de=A;for(let ie of p){if(G+=R(ie),ie.section>=0){let se=M(ie,$),ee=_(se);G+=Y(ie,se,T,de,$,ee),de+=ee+sf+4}for(let se of ie.periods){let ee=Z(ie,se),te=_(k[se]),fe=L[se].length>0?j(L[se][0]):te,ye=de+Math.max(te,fe)/2,le=`M${h(T+W)},${h(ye)}H${h(K)}`,we="",pe=ye-fe/2,ge=ye;for(let Ae of L[se]){let Se=j(Ae);ge=pe+Se/2,le+=`M${h(re)},${h(ge)}H${h(ne)}`,we+=q(Ae,ee,ne,pe,Se),pe+=Se+dl}we&&(le+=`M${h(K)},${h(ye)}H${h(re)}V${h(ge)}`),G+=P(se)+B(se,ee,T,ye-te/2,te)+`<path class="pele-edge" d="${le}"${dg}/>`+D(K,ye,ee)+we+"</g>",de=Math.max(ye+te/2,pe-dl)+ss}ie.periods.length===0&&(de+=ss-sf-4),ie.section>=0&&(G+="</g>")}if(p.length>0&&(de-=ss),S){let ie=de+qo+Ht;G=`<path class="pele-axis" d="M${h(K)},${h(A)}V${h(ie-Ht+1)}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",K,ie,0,1,"var(--_l)")+G,de=ie}X=de+n}else{let K=0,re=p.map(fe=>{if(fe.section<0)return;let ye=M(fe,Math.max(fe.periods.length,1)*C-ss);return K=Math.max(K,_(ye)),ye}),ne=0;for(let fe of k)ne=Math.max(ne,_(fe));let de=A+(f?K+sf:0),ie=de+ne+(ne>0?Ks:0),se=ie+Ks,ee=S?ie+qo:A+K,te=0;if(p.forEach((fe,ye)=>{let le=Math.max(fe.periods.length,1),we=T+te*C;G+=R(fe);let pe=re[ye];pe&&(G+=Y(fe,pe,we,A,le*C-ss,K)),fe.periods.forEach((ge,Ae)=>{let Se=Z(fe,ge),oe=we+Ae*C,ue=oe+W/2,xe=`M${h(ue)},${h(de+ne)}V${h(L[ge].length>0?se:ie)}`,Ie="",Le=se;for(let We of L[ge]){let he=j(We);Le>se&&(xe+=`M${h(ue)},${h(Le-dl)}V${h(Le)}`),Ie+=q(We,Se,oe,Le,he),Le+=he+dl}ee=Math.max(ee,Le-dl),G+=P(ge)+B(ge,Se,oe,de,ne)+`<path class="pele-edge" d="${xe}"${dg}/>`+D(ue,ie,Se)+Ie+"</g>"}),fe.section>=0&&(G+="</g>"),te+=le}),S){let fe=T+$;G=`<path class="pele-axis" d="M${h(T)},${h(ie)}H${h(fe-Ht+1)}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",fe,ie,1,0,"var(--_l)")+G}X=ee+n}let Q=Math.ceil(x+2*n),J=Math.ceil(Math.max(X,n*2)),F=Re(y,Q/2,n+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+G;return{svg:Je("timeline",Q,J,i,r,e,F),width:Q,height:J,links:[]}}var l3,o3,h3,Yo,cg,f3,p3,u3,ss,Ks,Uo,dl,sf,qo,hg,dg,pg,ug=Ve(()=>{af();Ho();tr();zt();pr();ut();wt();l3=class{constructor(){ce(this,"type","timeline");ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"direction","LR");ce(this,"sections",[]);ce(this,"periods",[]);ce(this,"currentSection","")}getCommonDb(){return this}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
65
|
+
`)}setDirection(e){this.direction=e}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t,r){this.periods.push({text:e,events:r?[r]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(e){let t=this.periods[this.periods.length-1];if(!t)throw new je("An event needs a time period before it.","semantic",{type:"timeline"});t.events.push(e)}},o3=["$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"];h3="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'";Yo=12,cg=8,f3=152,p3=216,u3=264,ss=20,Ks=20,Uo=14,dl=8,sf=8,qo=12,hg=' fill="var(--_bg)"',dg=' fill="none" stroke="var(--_b)"';pg={type:"timeline",parse(e,t,r){let a=new l3;return a.title=r,d3(e,a),a},render:g3}});var gg={};Ct(gg,{timeline:()=>pg});var mg=Ve(()=>{ug()});function cf(e){let t=new Set;for(let r of e)for(let a of r.people)t.add(a);return[...t].sort()}function Go(e,t,r){let a=e.length,i=t;for(;i<a;i++){let s=e.charCodeAt(i);if(s===35||s===10||s===59||r&&s===58)break}return i}function x3(e){let t=e.length,r=[],a=[],i=[],s={types:r,texts:a,starts:i},l=0,n=(o,c)=>{r.push(o),a.push(e.slice(l,c)),i.push(l),l=c};for(;l=Wo(e,l),!(l>=t);){let o=e.charCodeAt(l),c=l+1;if(o===10){for(;e.charCodeAt(c)===10;)c++;n(3,c);continue}if(ma(e,l,"journey")&&!Qe(e.charCodeAt(l+7))){n(4,l+7);continue}if(ma(e,l,"title")&&Ue(e.charCodeAt(l+5))&&(c=Go(e,l+6,!1),c>l+6)){n(5,c);continue}if(c=Bo(e,l,s,6),c!==l){l=c;continue}if(ma(e,l,"section")&&Ue(e.charCodeAt(l+7))&&(c=Go(e,l+8,!0),c>l+8)){n(11,c);continue}o===58?(c=Go(e,l+1,!1),n(c>l+1?13:14,c>l+1?c:l+1)):o===59?n(2,l+1):n(12,Go(e,l+1,!0))}return(i.length===0||i[i.length-1]<t)&&n(1,t),n(0,t),s}function b3(e,t){let{types:r,texts:a,starts:i}=x3(e),s=(l,n)=>{let o=r[l]===0?"1":y3[r[l]];throw it("journey",e,i[l],`Expecting ${n}, got '${o}'`)};r[0]!==4&&s(0,"'journey'");for(let l=1;;l++){let n=a[l];switch(r[l]){case 3:break;case 5:t.setDiagramTitle(n.substring(6));break;case 6:t.setAccTitle(a[++l].trim());break;case 8:t.setAccDescription(a[++l].trim());break;case 10:t.setAccDescription(n.trim());break;case 11:t.addSection(n.substring(8));break;case 12:r[++l]!==13&&s(l,"'taskData'"),t.addTask(n,a[l]);break;case 1:return;default:s(l,w3)}}}function xg(e,t,r){return`<g class="pele-face pele-face-${r}" transform="translate(${h(e)},${h(t)})"><circle r="${Zs}" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)">${v3}</g><path d="${E3[r]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}function S3(e,t,r){return Bt(r,a=>T3(e,t,r,a))}function T3(e,t,r,a){let i=r.fontSize??16,s=Math.round(i*.875),l=Math.round(i*.75),n=r.measurer??et(r.fontFamily),o=r.padding??8;if(a)return C3(e,r);let c=e.tasks,f=c.length,p=cf(c).filter(P=>P!==""),d=new Map;p.forEach((P,G)=>d.set(P,G));let g=$3,u=c.map(P=>Na(P.task,n,s,g)),m=0;for(let P of u)m=Math.max(m,P.width);m>g&&(g=Math.min(Math.ceil(m),k3),u=c.map(P=>Kr(P.task,n,s,g)));let b=g+2*Vo,w=b+jo,v=f>0?f*w-jo:0,k=Math.round(s*1.5),L=Math.max(v,240),I=[],N=0,O=0,W=0;for(let P of p){let G=Kr(P,n,s,L-2*Va-6),X=2*Va+6+G.width;W>0&&W+X>L&&(W=0,O+=4);let Q=W>0?I[I.length-1].y:O,J=Math.max(G.height,k);I.push({name:P,label:G,x:W,y:Q,h:J}),W+=X,N=Math.max(N,W),O=Math.max(O,Q+J),W+=A3}let U=f>0?lf+v:0,_=Kr(e.title,n,i,Math.max(U,320),1),j=_.height>0?_.height+16:0,Z=Math.max(U,_.width,f>0?lf+N:0),H=o+(Z-U)/2+lf,z=o+j,C=[],S=0;for(let P=0;P<f;){let G=P+1;for(;G<f&&c[G].section===c[P].section;)G++;let X;c[P].section!==""&&(X=Kr(c[P].section,n,s,(G-P)*w-jo-2*Vo,1),S=Math.max(S,Math.max(X.height,k)+2*yg)),C.push({start:P,count:G-P,label:X}),P=G}let $=k;for(let P of u)$=Math.max($,P.height);let y=p.length>0?2*Va+6:0,E=$+y+2*Ni,x=z+(S>0?S+yg:0),T=x+E+Zs+16,A=T+4*of,M=H+v,Y="",B=z;if(f>0){let P="",G="";for(let K=5;K>=1;K--){let re=T+(5-K)*of;P+=`M${h(H-6)},${h(re)}H${h(M)}`,G+=`<text x="${h(H-12)}" y="${h(re+l*.35)}">${K}</text>`}Y+=`<path class="pele-grid" d="${P}" fill="none" stroke="var(--_a)"/><g class="pele-scale" font-size="${l}" text-anchor="end" fill="var(--_m)">${G}</g>`;let X="",Q="",J="",F=[];c.forEach((K,re)=>{let ne=H+re*w,de=ne+b/2,ie=K.score,se=Number.isNaN(ie)?3:Math.min(5,Math.max(1,ie)),ee=T+(5-se)*of;X+=`${re===0?"M":"L"}${h(de)},${h(ee)}`,Q+=`M${h(de)},${h(x+E)}V${h(ee-Zs)}`,J+=xg(de,ee,ie>3?"happy":ie<3?"sad":"neutral");let te="",fe=K.people.filter(le=>le!==""),ye=Math.min(M3,(b-2*Vo-2*Va)/Math.max(fe.length-1,1));fe.forEach((le,we)=>{te+=`<circle class="pele-actor" cx="${h(de+(we-(fe.length-1)/2)*ye)}" cy="${h(x+E-Ni-Va)}" r="${Va}" fill="${dt(d.get(le)??0)}" stroke="var(--_s)"><title>${Oe(le)}</title></circle>`}),F.push(`<g class="pele-node pele-task" data-id="${Oe(K.task.trim())}"><rect x="${h(ne)}" y="${h(x)}" width="${h(b)}" height="${h(E)}" fill="var(--_s)" stroke="var(--_b)"${st}/>`+Re(u[re],de,x+Ni+$/2,` font-size="${s}"`)+te+"</g>")}),Y+=`<path class="pele-stems" d="${Q}" fill="none" stroke="var(--_b)" stroke-dasharray="2 3"/>`+(f>1?`<path class="pele-edge" d="${X}" fill="none" stroke="var(--_l)" stroke-linejoin="round"/>`:"")+J;for(let K of C){let re=F.slice(K.start,K.start+K.count).join("");if(!K.label){Y+=re;continue}let ne=H+K.start*w,de=K.count*w-jo;Y+=`<g class="pele-cluster pele-section" data-id="${Oe(c[K.start].section.trim())}"><rect x="${h(ne)}" y="${h(z)}" width="${h(de)}" height="${h(S)}" fill="var(--_a)"${st}/>`+Re(K.label,ne+de/2,z+S/2,` font-size="${s}" font-weight="var(--_hw)"`)+re+"</g>"}if(B=A+Zs,I.length>0){let K=H+(v-N)/2,re=B+16,ne="";for(let de of I){let ie=re+de.y+de.h/2;ne+=`<g class="pele-legend-item" data-id="${Oe(de.name)}"><circle cx="${h(K+de.x+Va)}" cy="${h(ie)}" r="${Va}" fill="${dt(d.get(de.name)??0)}"/>`+Re(de.label,K+de.x+2*Va+6+de.label.width/2,ie,"")+"</g>"}Y+=`<g class="pele-legend" font-size="${s}">${ne}</g>`,B=re+O}}let q=Math.ceil(Z+2*o),D=Math.ceil(Math.max(B,o)+o),R=Re(_,o+Z/2,o+_.height/2,' class="pele-title" font-weight="var(--_tw)"')+Y;return{svg:Je("journey",q,D,i,r,e,R),width:q,height:D,links:[]}}function C3(e,t){let r=t.fontSize??16,a=Math.round(r*.875),i=t.measurer??et(t.fontFamily),s=t.padding??8,l=Math.max(140,(t.maxWidth??320)-2*s),n=Kr(e.title,i,r,l,1),o=cf(e.tasks).filter(w=>w!==""),c=new Map(o.map((w,v)=>[w,v])),f=s+(n.height?n.height+16:0),p,d="",g=n.width;e.tasks.forEach((w,v)=>{if(w.section!==p){p=w.section;let _=Kr(p,i,r,l-16,1);_.height&&(d+=Re(_,s+8+_.width/2,f+_.height/2,' class="pele-cluster-label" font-weight="var(--_hw)"'),g=Math.max(g,_.width+16),f+=_.height+8)}let k=Kr(w.task,i,a,l-72),L=w.people.filter(_=>_!=="").map(_=>({name:_,label:Kr(_,i,a,l-44)})),I=Math.max(k.height,42),N=2*Ni+I;for(let _ of L)N+=Math.max(16,_.label.height)+4;let O=Math.max(l,k.width+72);d+=`<g class="pele-node pele-journey-step" data-id="${v}"><rect x="${h(s)}" y="${h(f)}" width="${h(O)}" height="${h(N)}" fill="var(--_s)" stroke="var(--_b)"${st}/>`,d+=Re(k,s+Vo+k.width/2,f+Ni+k.height/2,' class="pele-label"');let W=s+O-28;d+=xg(W,f+Ni+Zs,w.score>3?"happy":w.score<3?"sad":"neutral"),Number.isNaN(w.score)||(d+=`<text class="pele-journey-score" x="${h(W)}" y="${h(f+Ni+2*Zs+a)}" font-size="${a}" text-anchor="middle">${h(Math.min(5,Math.max(1,w.score)))}</text>`);let U=f+Ni+I+4;for(let _ of L){let j=Math.max(16,_.label.height);d+=`<circle class="pele-actor" cx="${h(s+16)}" cy="${h(U+j/2)}" r="${Va}" fill="${dt(c.get(_.name))}"/>`+Re(_.label,s+28+_.label.width/2,U+j/2,` class="pele-journey-actor" font-size="${a}"`),U+=j+4}d+="</g>",f+=N,v+1<e.tasks.length&&(d+=`<path class="pele-edge" d="M${h(s+O/2)},${h(f)}v16" fill="none" stroke="var(--_l)"/>`),f+=16,g=Math.max(g,O)});let u=Math.ceil(g+2*s),m=Math.ceil(Math.max(s+n.height,f-(e.tasks.length?16:0))+s),b=Re(n,u/2,s+n.height/2,' class="pele-title" font-weight="var(--_tw)"')+d;return{svg:Je("journey",u,m,r,t,e,b),width:u,height:m,links:[]}}var m3,y3,w3,Vo,Ni,$3,k3,jo,yg,lf,of,Zs,Va,M3,A3,v3,E3,wg,bg=Ve(()=>{af();Ho();tr();zt();ut();wt();m3=class{constructor(){ce(this,"type","journey");ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"sections",[]);ce(this,"tasks",[]);ce(this,"currentSection","")}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
66
|
+
`)}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t){let r=t.substring(1).split(":"),a=r.length===1?[]:r[1].split(",").map(i=>i.trim());this.tasks.push({task:e,score:Number(r[0]),people:a,section:this.currentSection})}getActors(){return cf(this.tasks)}},y3=["$end","EOF","INVALID","NEWLINE","journey","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","taskName","taskData",":"];w3="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'";Vo=10,Ni=8,$3=124,k3=200,jo=12,yg=6,lf=24,of=26,Zs=11,Va=5,M3=13,A3=20,v3='<circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/>',E3={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"};wg={type:"journey",parse(e,t,r){let a=new m3;return a.title=r,b3(e,a),a},render:S3}});var $g={};Ct($g,{journey:()=>wg});var kg=Ve(()=>{bg()});function Mg(e){return e==="#"||e==="+"||e==="~"||e==="-"}function Ri(e){let t=e.indexOf("~");if(t<=0)return{className:e,type:""};let r=e.indexOf("~",t+1);return{className:e.slice(0,t),type:e.slice(t+1,r===-1?e.length:r)}}function vg(e){let t=e.charCodeAt(0);return Ri(t>=48&&t<=57?I3+e:e).className}function D3(e){let t=e.length,r=[],a=[],i=[],s=[],l=0,n=0,o=e.indexOf("direction"),c=-1,f=0,p=(N,O,W)=>(r.push(N),a.push(e.slice(O,W)),i.push(O),n=W,!0),d=N=>{s.push(l),l=N},g=()=>{s.length>0&&(l=s.pop())},u=N=>e.startsWith(N,n)&&!Qe(e.charCodeAt(n+N.length)),m=N=>{for(;N<t&&Ue(e.charCodeAt(N));)N++;return N},b=N=>{let O=e.indexOf(N,n);return O===-1?t:O},w=N=>{let O=n,W=-1;for(let U=e.charCodeAt(O);O<t&&Ue(U);U=e.charCodeAt(++O))U===10&&(W=O);if(W<0){n=O;return}N&&g(),p(3,n,W+1)},v=N=>{switch(N){case 99:if(u("cssClass"))return p(48,n,n+8);if(u("callback"))return p(40,n,n+8);if(u("click"))return p(43,n,n+5);break;case 108:if(u("link"))return p(41,n,n+4);break;case 110:if(u("note for"))return p(24,n,n+8);if(u("note"))return p(25,n,n+4);break;case 60:if(e.charCodeAt(n+1)===60)return p(20,n,n+2);break;case 62:if(e.charCodeAt(n+1)===62)return p(21,n,n+2);break;case 104:if(u("href"))return p(46,n,n+4);break}return!1},k=N=>{if(v(N))return!0;let O=e.charCodeAt(n+1);switch(N){case 34:return d(1),n++,!0;case 126:return d(3),n++,!0;case 96:return d(2),n++,!0;case 95:if(u("_self"))return p(42,n,n+5);if(u("_blank"))return p(42,n,n+6);if(u("_parent"))return p(42,n,n+7);if(u("_top"))return p(42,n,n+4);break;case 60:return O===124?p(34,n,n+2):p(36,n,n+1);case 124:return O===62&&p(34,n,n+2);case 62:return p(36,n,n+1);case 42:return p(35,n,n+1);case 111:if(!Qe(O))return p(33,n,n+1);break;case 40:return O===41&&p(37,n,n+2);case 45:return O===45?p(38,n,n+2):p(52,n,n+1);case 46:return O===46?p(39,n,n+2):p(8,n,n+1);case 58:{let W=n+1;for(;W<t;){let U=e.charCodeAt(W);if(U===58||U===10||U===59)break;W++}return W>n+1?p(10,n,W):O===58&&e.charCodeAt(n+2)===58&&p(19,n,n+3)}case 43:return p(58,n,n+1);case 37:return p(51,n,n+1);case 61:return p(59,n,n+1);case 91:return p(5,n,n+1);case 93:return p(7,n,n+1);case 33:case 35:case 36:case 38:case 39:case 44:case 63:case 92:case 47:return p(60,n,n+1)}if(Qe(N)){let W=n+1;for(;Qe(e.charCodeAt(W));)W++;return p(27,n,W)}return Ps(N)&&p(53,n,n+1)},L=()=>{if(o===-1||n<f||(o<n&&(o=e.indexOf("direction",n)),o===-1)||(c<n&&(hf.lastIndex=n,c=hf.test(e)?hf.lastIndex-1:t),o>=c))return!1;for(let N=0;N<4;N++){let O=L3[N];if(O.lastIndex=n,O.test(e))return p(29+N,n,O.lastIndex)}return f=c,!1},I=N=>{if(L())return!0;if(Ue(N))return w(!1),!0;switch(N){case 37:if(e.charCodeAt(n+1)===37){let O=b(`
|
|
67
|
+
`);for(;O<t&&(e.charCodeAt(O)===10||e.charCodeAt(O)===13);)O++;return n=O,!0}break;case 97:{let O=e.startsWith("accTitle",n);if(!O&&!e.startsWith("accDescr",n))break;let W=m(n+8),U=e.charCodeAt(W);if(U===58)return p(O?11:13,n,m(W+1)),d(O?6:7),!0;if(U===123&&!O)return n=m(W+1),d(8),!0;break}case 99:if(u("classDiagram-v2"))return p(2,n,n+15);if(u("classDiagram"))return p(2,n,n+12);if(e.startsWith("call",n)&&Ue(e.charCodeAt(n+4)))return n=m(n+4),d(4),!0;if(u("classDef"))return p(26,n,n+8);if(u("class"))return d(9),p(22,n,n+5);break;case 91:if(e.startsWith("*]",n+1))return p(55,n,n+3);break;case 115:if(u("style"))return p(47,n,n+5);break;case 110:if(u("namespace"))return d(11),p(18,n,n+9);break;case 44:return p(28,n,n+1);case 35:return p(50,n,n+1)}return k(N)||N===58&&p(49,n,n+1)};for(;;){if(n>=t){r.push(R3[l]),a.push(""),i.push(t);break}let N=e.charCodeAt(n),O=!0;switch(l){case 0:O=I(N);break;case 9:Ue(N)?w(!0):N===125?(g(),g(),p(17,n,n+1)):N===123?(d(10),p(16,n,n+1)):O=k(N);break;case 10:if(N===34)d(1),n++;else if(N===125)g(),p(17,n,n+1);else if(N===91&&e.startsWith("*]",n+1))p(55,n,n+3);else if(N===123)p(57,n,n+1);else if(N===10)n++;else{let W=n+1;for(;W<t;){let U=e.charCodeAt(W);if(U===123||U===125||U===10)break;W++}p(23,n,W)}break;case 11:Ue(N)?w(!0):N===123?(d(12),p(16,n,n+1)):N===125?g():N===110&&u("namespace")?(d(11),p(18,n,n+9)):O=k(N);break;case 12:Ue(N)?w(!1):N===125?(g(),p(17,n,n+1)):N===110&&u("namespace")?(d(11),p(18,n,n+9)):N===91&&e.startsWith("*]",n+1)?p(55,n,n+3):N===99&&u("class")?(d(9),p(22,n,n+5)):O=k(N);break;case 1:N===34?(g(),n++):p(6,n,b('"'));break;case 3:if(N===34)d(1),n++;else{if(v(N))break;N===126?(g(),n++):p(9,n,b("~"))}break;case 2:if(N===34)d(1),n++;else{if(v(N))break;N===126?(d(3),n++):N===96?(g(),n++):p(54,n,b("`"))}break;case 4:if(N===40){let W=m(n+1);g(),e.charCodeAt(W)===41?n=W+1:(d(5),n++)}else p(44,n,b("("));break;case 5:N===41?(g(),n++):p(45,n,b(")"));break;case 6:case 7:p(l===6?12:14,n,b(`
|
|
68
|
+
`)),g();break;case 8:N===125?(g(),n++):p(15,n,b("}"));break}if(!O)return r.push(1),a.push(""),i.push(n),{types:r,texts:a,starts:i}}return r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function P3(e,t){let{types:r,texts:a,starts:i}=D3(e),s=0,l=N=>{let O=r[s];throw O===1?it("class",e,i[s],"",!0):it("class",e,i[s],`Expecting ${N}, got '${Eg[O]}'`)},n=N=>(r[s]!==N&&l(`'${Eg[N]}'`),a[s++]),o=()=>(Jo[r[s]]===0&&l("'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS'"),a[s++]),c=N=>{let O="";for(;;){if(r[s]===54){O+=a[s++];break}Jo[r[s]]===0&&l(O3),O+=a[s++];let W=r[s];if(W===8)O+=".",s++;else if(Jo[W]===0&&W!==54)break}return N&&r[s]===9&&(O+="~"+a[s++]+"~"),O},f=()=>{s++;let N=n(6);return n(7),N},p=()=>{r[s]!==23&&l("'STRUCT_STOP', 'MEMBER'");let N=[];for(;r[s]===23;)N.push(a[s++]);return n(17),N.reverse()},d=()=>{s++;let N=c(!0);switch(t.addClass(N),r[s]===5&&t.setClassLabel(N,f()),r[s]){case 19:{s++;let O=o();t.setCssClass(N,O),r[s]===16&&(s++,t.addMembers(N,p()));break}case 16:s++,r[s]===17?s++:t.addMembers(N,p());break;case 20:{s++;let O=o();n(21),t.addAnnotation(N,O),r[s]===16&&(s++,r[s]===17?s++:t.addMembers(N,p()));break}}return N},g=()=>{if(r[s++]===25)return t.addNote(n(6));let N=c(!0);return t.addNote(n(6),N)},u=()=>{let N=[];for(;;){s++;let O=c(!1),W=r[s]===5?t.addNamespace(O,f()):t.addNamespace(O);n(16),r[s]===3&&s++,N.push({id:W,classes:[],notes:[]});let U=!0;for(;U;){let _=N[N.length-1],j=r[s];if(j===18)break;for(j===22?_.classes.push(d()):j===25||j===24?_.notes.push(g()):l("'NAMESPACE', 'CLASS', 'NOTE_FOR', 'NOTE'");;){if(r[s]===3){let H=r[s+1];if(H===18||H===22||H===25||H===24){s++;break}s++}n(17);let Z=N.pop();if(t.addClassesToNamespace(Z.id,Z.classes,Z.notes),t.popNamespace(),N.length===0){U=!1;break}}}if(N.length===0)return}},m=()=>{let N=ls[r[s]];return N===0?"none":(s++,N-1)},b=()=>{let N=c(!0),O=r[s];if(O===10){t.addMember(N,t.cleanupLabel(a[s++]));return}let W="none";if(O===6)W=a[s++],O=r[s];else if(ls[O]===0&&O!==38&&O!==39)return;let U=m();O=r[s],O!==38&&O!==39&&l("'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE'"),s++;let _=m(),j=r[s]===6?a[s++]:"none",Z=c(!0),H={id1:N,id2:Z,relation:{type1:U,type2:_,lineType:O===38?0:1},relationTitle1:W,relationTitle2:j};r[s]===10&&(H.title=t.cleanupLabel(a[s++])),t.addRelation(H)},w=()=>{let N=[];for(;;){pf[r[s]]===0&&l("'ALPHA', 'NUM', 'COLON', 'UNIT', 'SPACE', 'BRKT', 'STYLE', 'PCT', 'LABEL'");let O=a[s++];for(;pf[r[s]]===1;)O+=a[s++];if(N.push(O),r[s]!==28)return N;s++}},v=N=>{r[s]===6&&t.setTooltip(N,a[s++])},k=N=>{let O=n(6),W=r[s]===6?a[s++]:void 0;r[s]===42?t.setLink(N,O,a[s++]):t.setLink(N,O),W!==void 0&&t.setTooltip(N,W)},L=()=>{let N=r[s];switch(N){case 53:case 27:case 52:case 54:b();return;case 18:u();return;case 22:d();return;case 23:s++;return;case 20:{s++;let O=o();n(21),t.addAnnotation(c(!0),O);return}case 40:{s++;let O=c(!0);t.setClickEvent(O,n(6)),v(O);return}case 41:s++,k(c(!0));return;case 43:{s++;let O=c(!0);if(r[s]===46){s++,k(O);return}let W=n(44);r[s]===45?t.setClickEvent(O,W,a[s++]):t.setClickEvent(O,W),v(O);return}case 47:{s++;let O=n(27);t.setCssStyle(O,w());return}case 48:{s++;let O=n(6);t.setCssClass(O,n(27));return}case 25:case 24:g();return;case 26:{s++;let O=[n(27)];for(;r[s]===28;)s++,O.push(n(27));t.defineClass(O,w());return}case 29:case 30:case 31:case 32:s++,t.setDirection(N===29?"TB":N===30?"BT":N===31?"RL":"LR");return;case 11:s++,t.setAccTitle(n(12).trim());return;case 13:s++,t.setAccDescription(n(14).trim());return;case 15:t.setAccDescription(a[s++].trim());return}l("'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'")},I=r[s]===2;for(I&&(s++,n(3));L(),!(r[s]!==3||(s++,r[s]===4||r[s]===0)););I&&n(4),n(0)}function Sg(e){return typeof e=="number"&&z3[e]||"none"}function F3(e,t=!0){let r=[],a=[],i=new Map,s=new Map,l=new Map,n=new Map,o=d=>{if(t||d===void 0)return d;let g=[],u=d,m;for(;u;){if(n.has(u)){m=n.get(u);break}let b=e.namespaces.get(u);if(b===void 0)break;if(b.explicit){m=u;break}g.push(u),u=b.parent}for(let b of g)n.set(b,m);return m},c=d=>d===void 0?-1:i.get(d)??-1;for(let d of e.namespaces.values())!t&&!d.explicit||(i.set(d.id,r.length),r.push({id:d.id,label:t?d.label:d.id,isGroup:!0,shape:"rect",parentId:t?d.parent:void 0,parent:-1}));for(let d of r)d.parent=c(d.parentId);let f=0;for(let d of e.classes.values()){let g=o(d.parent);s.set(d.id,r.length),r.push({id:d.id,label:d.label,isGroup:!1,shape:"classBox",parentId:g,parent:c(g),classNode:d,colorIndex:f++})}for(let d of e.notes.values()){let g=o(d.parent),u=d.class===void 0?void 0:s.get(d.class);u!==void 0&&a.push({id:`edgeNote${d.index}`,start:d.id,end:r[u].id,source:r.length,target:u,label:void 0,arrowTypeStart:"none",arrowTypeEnd:"none",startLabelRight:"",endLabelLeft:"",pattern:"dotted",classes:"relation"}),r.push({id:d.id,label:d.text,isGroup:!1,shape:"note",parentId:g,parent:c(g)})}for(let d of e.interfaces){let g=s.get(d.classId);l.set(d.id,r.length),r.push({id:d.id,label:d.label,isGroup:!1,shape:"interface",parentId:void 0,parent:g===void 0?-1:r[g].parent})}let p=0;for(let d of e.relations){p++;let{type1:g,type2:u}=d.relation,m=g===ul.LOLLIPOP&&u==="none"?l:s,b=m===s&&u===ul.LOLLIPOP&&g==="none"?l:s;a.push({id:`id_${d.id1}_${d.id2}_${p}`,start:d.id1,end:d.id2,source:m.get(d.id1)??-1,target:b.get(d.id2)??-1,label:d.title,arrowTypeStart:Sg(g),arrowTypeEnd:Sg(u),startLabelRight:d.relationTitle1==="none"?"":d.relationTitle1,endLabelLeft:d.relationTitle2==="none"?"":d.relationTitle2,pattern:d.relation.lineType===1?"dashed":"solid",classes:"relation"})}return{nodes:r,edges:a}}function Tg(e){switch(e){case"extension":return uf;case"composition":case"aggregation":return pl;case"lollipop":return 2*ec;case"dependency":return gt("arrow_point")}return 0}function Cg(e,t,r,a,i,s){let l=-i,n=a;switch(e){case"extension":{let o=t-a*uf,c=r-i*uf;return`<path class="pele-marker" d="M${h(t)},${h(r)}L${h(o+l*fl)},${h(c+n*fl)}L${h(o-l*fl)},${h(c-n*fl)}Z" stroke-linejoin="round"/>`}case"composition":case"aggregation":{let o=t-a*pl/2,c=r-i*pl/2,f=fl-1;return`<path class="pele-marker" d="M${h(t)},${h(r)}L${h(o+l*f)},${h(c+n*f)}L${h(t-a*pl)},${h(r-i*pl)}L${h(o-l*f)},${h(c-n*f)}Z" stroke-linejoin="round"${e==="composition"?` fill="${s}"`:""}/>`}case"lollipop":return`<circle class="pele-marker" cx="${h(t-a*ec)}" cy="${h(r-i*ec)}" r="${ec}"/>`;case"dependency":return bt("arrow_point",t,r,a,i,s)}return""}function Rg(e,t,r){let a=e[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function Lg(e,t,r){let a=At(e.getDisplayDetails().displayText).trim();return{text:a,width:t.width(a,r,e.classifier==="*"?2:0),classifier:e.classifier}}function q3(e,t,r){let a=i=>Nr(r,s=>G3(e,t,r,i,s));return jr(e.direction)?Bt(r,a):a(!1)}function G3(e,t,r,a,i){let s=t.class??{},l=F3(e,s.hierarchicalNamespaces!==!1),n=s.hideEmptyMembersBox===!0,o=r.fontSize??16,c=Math.round(o*.875),f=Math.round(o*.8),p=Math.round(f*1.4),d=r.measurer??et(r.fontFamily),g=r.padding??8,u=(oe,ue)=>{if(!oe.includes("$$"))return;let xe=ze(oe,!1,d,ue,4e3);return xe.lines.some(zs)?xe:void 0},m=oe=>oe?u(oe,f)?.width??d.width(At(oe),f,0):0,b=a?"TB":br(e.direction),w=new Map,v=new Map,k=new Map,L=oe=>{let ue=w.get(oe);if(ue===void 0){let xe=vt([oe]);ue=xe.shape===""&&xe.text===""?"":oe.slice(0,oe.indexOf(":")).trim().toLowerCase(),w.set(oe,ue)}ue!==""&&k.set(ue,oe)},I=oe=>{k.clear();let ue=v.get(oe.cssClasses);if(ue===void 0){for(let xe of oe.cssClasses.split(" ")){let Ie=e.styleClasses.get(xe);if(Ie)for(let Le of Ie.styles)for(let We of Le.split(","))L(We)}ue=[...k],v.set(oe.cssClasses,ue)}else for(let[xe,Ie]of ue)k.set(xe,Ie);for(let xe of oe.styles)L(xe);return vt(k.size===0?Qo:[...k.values()])},N=new Int32Array(l.nodes.length);for(let oe of l.nodes)oe.parent>=0&&N[oe.parent]++;let O=new Uint8Array(l.nodes.length);for(let oe of l.edges){if(oe.source<0||oe.target<0)continue;let ue=l.nodes[oe.source].parent,xe=l.nodes[oe.target].parent;if(ue!==xe){for(let Ie=ue;Ie>=0&&O[Ie]===0;Ie=l.nodes[Ie].parent)O[Ie]=1;for(let Ie=xe;Ie>=0&&O[Ie]===0;Ie=l.nodes[Ie].parent)O[Ie]=1}}let W=[],U=[];l.nodes.forEach((oe,ue)=>{let xe,Ie;if(oe.isGroup){let Le=ze(oe.label,!1,d,o,4e3);xe=_(oe,Le,0,0,o),N[ue]>0?(Ie=Ut(0,0),Ie.isGroup=!0,Ie.padX=ns,Ie.padTop=Le.height>0?Le.height+16:ns,Ie.padBottom=ns,Ie.minW=Le.width+2*ns-12+(O[ue]===1&&!i?Math.min(Le.width+24,240):0)):(xe.w=Math.max(Le.width+2*ns,80),xe.h=Le.height+2*ns,Ie=Ut(xe.w,xe.h))}else if(oe.classNode)xe=j(oe,oe.classNode),Ie=Ut(xe.w,xe.h);else if(oe.shape==="note"){let Le=ze(oe.label,!0,d,c,260);xe=_(oe,Le,Math.max(Le.width+2*df,40),Le.height+2*Xo,c),Ie=Ut(xe.w,xe.h)}else{let Le=ze(oe.label,!1,d,c,200);xe=_(oe,Le,Math.max(Le.width,12)+4,Math.max(Le.height,12),c),Ie=Ut(xe.w,xe.h)}Ie.parent=oe.parent,Ie.seq=ue,W.push(xe),U.push(Ie)});function _(oe,ue,xe,Ie,Le){return{node:oe,style:vt(Qo),label:ue,w:xe,h:Ie,loops:0,annotations:Qo,attributes:Zo,methods:Zo,titleH:0,attributesH:0,fontSize:Le}}function j(oe,ue){let xe=I(ue),Ie=xe.fontSize??o,Le=Math.round(Ie*.875),We=Math.round(Le*1.5),he=ue.type?"<"+as(ue.type).replace(/</g,"<").replace(/>/g,">")+">":"",ke=ze(ue.label+he,!1,d,Ie,4e3,1|(xe.italic?2:0)),Ce=ue.annotations.length>0?ue.annotations.map($e=>u(`\xAB${$e.trim()}\xBB`,f)??`\xAB${At($e).trim()}\xBB`):Qo,be=ue.members.length>0?ue.members.map($e=>Lg($e,d,Le)):Zo,Me=ue.methods.length>0?ue.methods.map($e=>Lg($e,d,Le)):Zo,Ne=ke.width,Be=0;for(let $e of Ce)Ne=Math.max(Ne,typeof $e=="string"?d.width($e,f,0):$e.width),Be+=typeof $e=="string"?p:Math.max(p,$e.height);for(let $e of be)Ne=Math.max(Ne,$e.width);for(let $e of Me)Ne=Math.max(Ne,$e.width);let Pe=!(n&&be.length===0&&Me.length===0),V=$e=>Pe?$e>0?2*Ng+$e*We:H3:0,me=2*Xo+Be+Math.max(ke.height,Math.round(Ie*1.5)),ae=V(be.length);return{node:oe,style:xe,label:ke,w:Math.max(Ne+2*df,Y3),h:me+ae+V(Me.length),loops:0,annotations:Ce,attributes:be,methods:Me,titleH:me,attributesH:ae,fontSize:Ie}}let Z=[],H=[],z=[],C=[],S=[],$=new Float64Array(W.length*4),y=(oe,ue,xe)=>{$[oe*4+ue]++,xe>$[oe*4+ue+1]&&($[oe*4+ue+1]=xe)};for(let oe of l.edges){if(oe.source<0||oe.target<0)continue;let ue=ze(oe.label,!0,d,c,200),xe=m(oe.startLabelRight),Ie=m(oe.endLabelLeft);oe.source===oe.target?(W[oe.source].loops++,U[oe.source].w+=2*(Ig+(ue.width>0?ue.width+12:0))):(y(oe.source,0,xe),y(oe.target,2,Ie)),C.push(xe),S.push(Ie),H.push(oe),z.push(ue),Z.push({src:oe.source,dst:oe.target,minlen:1,labelW:ue.width>0?ue.width+12:0,labelH:ue.height>0?ue.height+4:0,route:[],labelX:0,labelY:0})}if(b==="TB"||b==="BT")for(let oe=0;oe<W.length;oe++){if(!W[oe].node.classNode)continue;let ue=0;for(let xe=0;xe<4;xe+=2){let Ie=$[oe*4+xe],Le=$[oe*4+xe+1];Ie>1&&(ue=Math.max(ue,(Ie-1)*(Le>0?Le+24:14)+24))}ue=Math.min(ue,480),ue>W[oe].w&&(U[oe].w+=ue-W[oe].w,W[oe].w=ue)}let E=!1;for(let oe=0;oe<H.length&&!E;oe++)E=C[oe]>0||S[oe]>0;let x=0;if(b==="TB"||b==="BT"){let oe=ue=>ue?Math.max(p,u(ue,f)?.height??0):0;for(let ue of H)x=Math.max(x,oe(ue.startLabelRight)+oe(ue.endLabelLeft)-2*p)}let T=Gr(U,Z,b,{nodeSep:Rg(s,"nodeSpacing",W3),edgeSep:B3,rankSep:Rg(s,"rankSpacing",E?_g+16:_g)+x,portSep:20,apart:!0}),A=new Map,M=[],Y=(oe,ue,xe,Ie,Le)=>{let We=oe.route,he=U[xe],ke=ga(We,ue,he);if(ke<0)return;let Ce=(he.w-W[xe].w)/2;ke===1?We[ue]-=Ce:ke===3&&(We[ue]+=Ce);let be=ke&1,Me=We[(ue===0?3:ue-3)+be],Ne=Me-We[ue+be],Be={route:We,at:ue,toward:Me,order:Le,room:Ie,side:ke,after:be?Ne>0:Ne>=0},Pe=xe*4+ke,V=A.get(Pe);return V?V.push(Be):A.set(Pe,[Be]),Be},B=[],q=[];for(let oe=0;oe<Z.length;oe++){let ue=Z[oe],xe=ue.src!==ue.dst&&ue.route.length>=6;B.push(xe?Y(ue,0,ue.src,C[oe],oe):void 0),q.push(xe?Y(ue,ue.route.length-3,ue.dst,S[oe],oe):void 0)}let D=(oe,ue,xe)=>{for(let Ie=U[oe].parent,Le=0;Ie>=0&&Le<1e4;Ie=U[Ie].parent,Le++){let We=U[Ie],he=Math.abs(ue-We.x),ke=Math.abs(xe-We.y);if(Math.abs(ke-We.h/2)<.5&&he<=We.w/2+.5||Math.abs(he-We.w/2)<.5&&ke<=We.h/2+.5)return!0}return!1},R=[];for(let[oe,ue]of A){if(ue.length<2)continue;let xe=oe>>2,Ie=oe&1,Le=Ie?W[xe].h:W[xe].w;ue.sort((Ce,be)=>Ce.toward-be.toward||Ce.order-be.order);let We=0;for(let Ce=0;Ce+1<ue.length;Ce++){let be=ue[Ce],Me=ue[Ce+1],Ne=Ie?20:24;be.room>0&&be.after&&(Ne+=Ie?p+6:be.room),Me.room>0&&!Me.after&&(Ne+=Ie?p+6:Me.room),R[Ce]=Ne,We+=Ne}let he=Math.min(1,(Le-24)/We);if(he<=0)continue;let ke=(Ie?U[xe].y:U[xe].x)-We*he/2;for(let Ce=0;Ce<ue.length;Ce++){let{route:be,at:Me}=ue[Ce],Ne=Me===0?3:-3,Be=Me+Ne,Pe=-1;for(let V=Be;V>=0&&V<be.length&&Math.abs(be[V+Ie]-be[Be+Ie])<.5;V+=Ne)if(D(xe,be[V],be[V+1])){Pe=V;break}if(Pe>=0&&Math.abs(be[Be+Ie]-ke)<=24)for(let V=Be;V!==Pe+Ne;V+=Ne)be[V+Ie]=ke;be[Me+Ie]=ke,ke+=R[Ce]*he}}let P=(oe,ue,xe,Ie)=>{if(ue===void 0||xe<=0)return;let Le=ue.side&1,We=Ie?0:oe.length-3,he=We+1-Le,ke=Math.abs(oe[(Ie?3:We-3)+1-Le]-oe[he]),Ce=Math.min(Le?xe+10:p+6,ke*.35);if(Ce<4)return;let be=[oe[We],oe[We+1],oe[We+2]];be[1-Le]+=(ue.side===0||ue.side===3?-1:1)*Ce,oe.splice(Ie?3:We,0,be[0],be[1],be[2])};for(let oe=0;oe<Z.length;oe++)P(Z[oe].route,B[oe],C[oe],!0),P(Z[oe].route,q[oe],S[oe],!1);let G=0,X=0,Q=T.width,J=T.height,F=(oe,ue,xe,Ie,Le,We)=>{if(!oe)return;let he=u(oe,f),ke=he?Math.max(p,he.height):p,Ce=xe,be=Ie;Le&1?(Ce+=(Le===3?-1:1)*(5+ue/2),be+=(We?1:-1)*(7+ke/2)):(Ce+=(We?1:-1)*(9+ue/2),be+=(Le===0?-1:1)*(3+ke/2)),M.push({text:At(oe),math:he,x:Ce,y:be}),G=Math.min(G,Ce-ue/2),Q=Math.max(Q,Ce+ue/2),X=Math.min(X,be-ke/2),J=Math.max(J,be+ke/2)},K=new Map,re=new Int32Array(Z.length);for(let oe=0;oe<Z.length;oe++){let ue=Z[oe],xe=H[oe],Ie=ue.route;if(ue.src===ue.dst){let Le=K.get(ue.src)??0;K.set(ue.src,Le+1),re[oe]=Le;let We=U[ue.src],he=W[ue.src],ke=We.x+he.w/2,Ce=Math.min(he.h/2-4,8+Le*6);F(xe.startLabelRight,C[oe],ke,We.y-Ce,1,!1),F(xe.endLabelLeft,S[oe],ke,We.y+Ce,1,!0)}else if(Ie.length>=6){let Le=Ie.length-3,We=B[oe],he=q[oe];F(xe.startLabelRight,C[oe],Ie[0],Ie[1],We?We.side:2,We?We.after:!0),F(xe.endLabelLeft,S[oe],Ie[Le],Ie[Le+1],he?he.side:0,he?he.after:!0)}}let ne=g-G,de=g-X,ie=Math.ceil(Q-G+2*g),se=Math.ceil(J-X+2*g),ee=[],te=new Map;if(l.nodes.length>0&&l.nodes[0].isGroup)for(let oe of Z)va(te,oe.route);let fe="",ye="",le="";for(let oe=0;oe<W.length;oe++){let ue=W[oe],xe=U[oe],Ie=ue.node,Le=xe.x+ne,We=xe.y+de,he=Oe(Ie.id),ke=xe.isGroup?xe.w:ue.w,Ce=xe.isGroup?xe.h:ue.h;if(Ie.isGroup){let Me=xe.isGroup?Ai(xe,ue.label.width,te,ns):xe.x,Ne=We-Ce/2+8+ue.label.height/2,Be=' class="pele-cluster-label" fill="var(--_m)"',Pe=xe.isGroup&&yo(xe,ue.label.width,Me,te);Pe&&(ye+=xo(ue.label,Me+ne,Ne,Be,he,l.nodes,oe)),fe+=`<g class="pele-cluster pele-namespace" data-id="${he}"><rect x="${h(Le-ke/2)}" y="${h(We-Ce/2)}" width="${h(ke)}" height="${h(Ce)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${st}/>`+(Pe?"":Re(ue.label,Me+ne,Ne,Be))+"</g>";continue}let be=` transform="translate(${h(Le)},${h(We)})"`;if(Ie.classNode)le+=we(ue,Ie.classNode,he,be);else if(Ie.shape==="note"){let Me=ke/2,Ne=-Ce/2;le+=`<g class="pele-node pele-note" data-id="${he}"${be}><path d="M${h(-Me)},${h(Ne)}H${h(Me-Ko)}L${h(Me)},${h(Ne+Ko)}V${h(-Ne)}H${h(-Me)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"/><path d="M${h(Me-Ko)},${h(Ne)}V${h(Ne+Ko)}H${h(Me)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"/>`+Re(ue.label,0,0,` class="pele-label" font-size="${c}"`,r.icons)+"</g>"}else le+=`<g class="pele-node pele-interface" data-id="${he}"${be}>`+Re(ue.label,0,0,` class="pele-label" font-size="${c}"`,r.icons)+"</g>"}function we(oe,ue,xe,Ie){let{w:Le,h:We,style:he}=oe,ke=-Le/2,Ce=-We/2,be=Math.round(oe.fontSize*.875),Me=Math.round(be*1.5),Ne=`<rect x="${h(ke)}" y="${h(Ce)}" width="${h(Le)}" height="${h(We)}" fill="var(--_s)" stroke="var(--_b)"${ft(he.shape)}/>`,Be=Ce+oe.titleH,Pe=Be+oe.attributesH;if(We>oe.titleH){let $e=he.stroke?` style="stroke:${Xe(he.stroke)}"`:"";Ne+=`<path class="pele-divider" d="M${h(ke)},${h(Be)}H${h(-ke)}M${h(ke)},${h(Pe)}H${h(-ke)}" fill="none" stroke="var(--_b)"${$e}/>`}let V=Ce+Xo;for(let $e of oe.annotations)if(typeof $e=="string")Ne+=`<text class="pele-annotation" x="0" y="${h(V+p/2+f*.35)}" text-anchor="middle" font-size="${f}" fill="var(--_m)">${Xe($e)}</text>`,V+=p;else{let ve=Math.max(p,$e.height);Ne+=Re($e,0,V+ve/2,` class="pele-annotation" font-size="${f}" fill="var(--_m)"`,r.icons),V+=ve}let me=oe.fontSize===o?"":` font-size="${h(oe.fontSize)}"`;Ne+=Re(oe.label,0,(V+Be-Xo)/2,` class="pele-label"${me} font-weight="var(--_hw)"${he.text}`,r.icons);let ae=($e,ve,Te)=>{let De="",_e=Te+Ng+Me/2+be*.35;for(let He of $e){let Ee=He.classifier==="$"?` pele-static"${he.text?he.text.slice(0,-1)+'text-decoration:underline"':' style="text-decoration:underline"'}`:He.classifier==="*"?` pele-abstract" font-style="italic"${he.text}`:`"${he.text}`;De+=`<text class="pele-member pele-${ve}${Ee} x="${h(ke+df)}" y="${h(_e)}">${Xe(He.text)}</text>`,_e+=Me}return De};return(oe.attributes.length>0||oe.methods.length>0)&&(Ne+=`<g class="pele-members" font-size="${be}">${ae(oe.attributes,"attribute",Be)}${ae(oe.methods,"method",Pe)}</g>`),ue.tooltip&&(Ne=`<title>${Oe(ue.tooltip)}</title>`+Ne),ue.link&&(Ne=ua(Ne,ue.link,ue.id,ee,r,ue.linkTarget&&U3.has(ue.linkTarget)?` target="${ue.linkTarget}"`:"")),`<g class="pele-node pele-class${_t(ue.cssClasses.replace(/^default\s?/,""))}" data-id="${xe}"${Ie}>${Ne}</g>`}let pe="",ge="";for(let oe=0;oe<Z.length;oe++){let ue=Z[oe],xe=H[oe],Ie=z[oe],Le=xe.arrowTypeStart,We=xe.arrowTypeEnd,he=Tg(Le),ke=Tg(We),Ce;if(ue.src===ue.dst){let Me=U[ue.src],Ne=W[ue.src],Be=re[oe],Pe=Me.x+ne+Ne.w/2,V=Me.y+de,me=Math.min(Ne.h/2-4,8+Be*6),ae=Ig+Be*8;Ce={d:`M${h(Pe+he)},${h(V-me)}C${h(Pe+ae+he)},${h(V-me)} ${h(Pe+ae+ke)},${h(V+me)} ${h(Pe+ke)},${h(V+me)}`,sx:Pe,sy:V-me,sdx:-1,sdy:0,ex:Pe,ey:V+me,edx:-1,edy:0},ue.labelX=Me.x+Ne.w/2+ae+4+ue.labelW/2,ue.labelY=Me.y}else{let Me=ue.route;for(let Ne=0;Ne<Me.length;Ne+=3)Me[Ne]+=ne,Me[Ne+1]+=de;Ce=zr(Me,void 0,he,ke)}let be=xe.pattern==="dashed"?' stroke-dasharray="6 4"':xe.pattern==="dotted"?' stroke-dasharray="2 4"':"";if(pe+=`<g class="pele-edge${xe.pattern==="dotted"?" pele-note-edge":" pele-relation"}" data-id="${Oe(xe.id)}"><path d="${Ce.d}"${be}/>`+Cg(Le,Ce.sx,Ce.sy,Ce.sdx,Ce.sdy,ff)+Cg(We,Ce.ex,Ce.ey,Ce.edx,Ce.edy,ff)+"</g>",Ie.width>0){let Me=ue.labelX+ne,Ne=ue.labelY+de;ge+=wr(xe.id,Ie,Me,Ne,"",r.icons)}}let Ae="";for(let oe of M)Ae+=oe.math?Re(oe.math,oe.x+ne,oe.y+de,' class="pele-cardinality"',r.icons):`<text class="pele-cardinality" x="${h(oe.x+ne)}" y="${h(oe.y+de+f*.35)}" text-anchor="middle">${Xe(oe.text)}</text>`;let Se=So(e.title,d,o,g,ie,se,(fe?`<g class="pele-clusters">${fe}</g>`:"")+(pe?`<g class="pele-edges" fill="none" stroke="${ff}" stroke-linecap="round">${pe}</g>`:"")+(ye?`<g class="pele-cluster-titles">${ye}</g>`:"")+(ge?`<g class="pele-edge-labels" font-size="${c}">${ge}</g>`:"")+(Ae?`<g class="pele-cardinalities" font-size="${f}" fill="var(--_m)">${Ae}</g>`:"")+`<g class="pele-nodes">${le}</g>`);return{svg:Je("class",Se.width,Se.height,o,r,e,Se.content),width:Se.width,height:Se.height,links:ee}}var Ag,_3,ul,I3,N3,Eg,R3,L3,hf,gf,Jo,pf,ls,O3,z3,uf,pl,fl,ec,W3,B3,_g,ns,Ig,df,Xo,Ng,H3,Y3,Ko,ff,U3,Zo,Qo,Dg,Og=Ve(()=>{Bd();go();Fs();Ei();Ea();hi();Ti();tr();zt();pr();ut();wt();Ag=class{constructor(e,t){ce(this,"id","");ce(this,"memberType");ce(this,"visibility","");ce(this,"classifier","");ce(this,"parameters","");ce(this,"returnType","");this.memberType=t,(t!=="method"||!this.parseMethod(e))&&this.parseAttribute(e),this.id=this.id.startsWith(" ")?" "+this.id.trim():this.id.trim()}parseMethod(e){let t=e.length;for(let r=0;r<t;){let a=r;for(;a<t&&!Xi(e.charCodeAt(a));)a++;let i=a-1;for(;i>r&&e.charCodeAt(i)!==41;)i--;let s=i-1;for(;s>r&&e.charCodeAt(s)!==40;)s--;if(s>r){let l=e[r],n=Mg(l)&&s>r+1;n&&(this.visibility=l),this.id=e.slice(n?r+1:r,s),this.parameters=e.slice(s+1,i).trim();let o=i+1,c="";if(o<t){let p=e[o];(p==="$"||p==="*"||p.trim()==="")&&(c=p.trim(),o++)}let f=o;for(;f<t&&!Xi(e.charCodeAt(f));)f++;if(this.returnType=e.slice(o,f).trim(),c===""){let p=this.returnType.slice(-1);(p==="$"||p==="*")&&(c=p,this.returnType=this.returnType.slice(0,-1))}return this.classifier=c,!0}r=a+1}return this.memberType="attribute",!1}parseAttribute(e){let t=e.slice(0,1),r=e.slice(-1);Mg(t)&&(this.visibility=t),(r==="$"||r==="*")&&(this.classifier=r),this.id=e.substring(this.visibility===""?0:1,this.classifier===""?e.length:e.length-1)}getDisplayDetails(){let e=this.visibility+as(this.id);return this.memberType==="method"&&(e+=`(${as(this.parameters.trim())})`,this.returnType&&(e+=" : "+as(this.returnType))),{displayText:e.trim(),cssStyle:this.parseClassifier()}}parseClassifier(){return this.classifier==="*"?"font-style:italic;":this.classifier==="$"?"text-decoration:underline;":""}},_3={LINE:0,DOTTED_LINE:1},ul={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4},I3="classId-";N3=class{constructor(){ce(this,"type","class");ce(this,"lineType",_3);ce(this,"relationType",ul);ce(this,"direction","TB");ce(this,"classes",new Map);ce(this,"relations",[]);ce(this,"notes",new Map);ce(this,"namespaces",new Map);ce(this,"interfaces",[]);ce(this,"styleClasses",new Map);ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"namespaceStack",[]);ce(this,"withCssClass",new Map)}addClass(e){let{className:t,type:r}=Ri(e);if(this.classes.has(t))return;let a={id:t,type:r,label:t,cssClasses:"default",methods:[],members:[],annotations:[],styles:[]};this.classes.set(t,a),this.tag(a,"default")}tag(e,t){let r=this.withCssClass.get(t);r?r.add(e):this.withCssClass.set(t,new Set([e]))}ensure(e){return this.addClass(e),this.classes.get(Ri(e).className)}setClassLabel(e,t){this.ensure(e).label=t}addRelation(e){let{type1:t,type2:r}=e.relation;t===ul.LOLLIPOP&&r==="none"?(this.addClass(e.id2),e.id1=this.addInterface(e.id1,e.id2)):r===ul.LOLLIPOP&&t==="none"?(this.addClass(e.id1),e.id2=this.addInterface(e.id2,e.id1)):(this.addClass(e.id1),this.addClass(e.id2)),e.id1=Ri(e.id1).className,e.id2=Ri(e.id2).className,e.relationTitle1=e.relationTitle1.trim(),e.relationTitle2=e.relationTitle2.trim(),this.relations.push(e)}addInterface(e,t){let r=`interface${this.interfaces.length}`;return this.interfaces.push({id:r,label:e,classId:t}),r}addAnnotation(e,t){this.ensure(e).annotations.push(t)}addMember(e,t){let r=this.ensure(e);if(typeof t!="string")return;let a=t.trim();if(a.startsWith("<<")&&a.endsWith(">>"))r.annotations.push(a.substring(2,a.length-2));else if(a.indexOf(")")>0){let i=new Ag(a,"method");(i.memberType==="method"?r.methods:r.members).push(i)}else a&&r.members.push(new Ag(a,"attribute"))}addMembers(e,t){if(Array.isArray(t)){t.reverse();for(let r of t)this.addMember(e,r)}}addNote(e,t){let r=this.notes.size,a=`note${r}`;return this.notes.set(a,{id:a,class:t,text:e,index:r}),a}cleanupLabel(e){return(e.startsWith(":")?e.substring(1):e).trim()}setCssClass(e,t){for(let r of e.split(",")){let a=this.classes.get(vg(r));if(a!==void 0){a.cssClasses+=" "+t;for(let i of t.split(" "))this.tag(a,i)}}}defineClass(e,t){for(let r of e){let a=this.styleClasses.get(r);if(a===void 0&&(a={id:r,styles:[],textStyles:[]},this.styleClasses.set(r,a)),!t)continue;for(let l of t)l.includes("color")&&a.textStyles.push(l.replace("fill","bgFill")),a.styles.push(l);let i=this.withCssClass.get(r);if(i===void 0)continue;let s=t.flatMap(l=>l.split(","));for(let l of i)for(let n of s)l.styles.push(n)}}setTooltip(e,t){if(t!==void 0)for(let r of e.split(",")){let a=this.classes.get(Ri(r).className);a&&(a.tooltip=t)}}setLink(e,t,r){let a=At(t).trim();for(let i of e.split(",")){let s=this.classes.get(vg(i));s&&(s.link=a?Sa(a):void 0,s.linkTarget=typeof r=="string"?r:"_blank")}this.setCssClass(e,"clickable")}setClickEvent(e,t,r){for(let a of e.split(",")){let i=this.classes.get(Ri(a).className);i&&(i.haveCallback=!0)}this.setCssClass(e,"clickable")}setDirection(e){this.direction=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
69
|
+
`)}addNamespace(e,t){let r=this.namespaceStack[this.namespaceStack.length-1],a=r?`${r}.${e}`:e;this.namespaceStack.push(a);let i=this.namespaces.get(a);if(i)return i.explicit=!0,t&&(i.label=t),a;let s=r||void 0,l=r?r.length+1:0;for(;;){let n=a.indexOf(".",l),o=n===-1,c=o?a:a.slice(0,n),f=this.namespaces.get(c);if(f===void 0){let d=a.slice(l,o?a.length:n);f={id:c,label:o&&t?t:d,classes:new Map,notes:new Map,children:new Map,parent:s,explicit:o},this.namespaces.set(c,f)}else o&&(f.explicit=!0);let p=s?this.namespaces.get(s):void 0;if(p&&(p.children.has(c)||p.children.set(c,f),f.parent??(f.parent=s)),o)return a;s=c,l=n+1}}popNamespace(){this.namespaceStack.pop()}addClassesToNamespace(e,t,r){let a=this.namespaces.get(e);if(a!==void 0){for(let i of t){let{className:s}=Ri(i),l=this.classes.get(s);l!==void 0&&(l.parent=e,a.classes.set(s,l))}for(let i of r){let s=this.notes.get(i);s!==void 0&&(s.parent=e,a.notes.set(i,s))}}}setCssStyle(e,t){let r=this.classes.get(e);if(!(!t||!r))for(let a of t)for(let i of a.split(","))r.styles.push(i)}},Eg=["$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"],R3=[4,6,4,9,44,45,12,14,15,4,56,4,56],L3=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],hf=/[\n\r\u2028\u2029]/g;gf=61,Jo=new Uint8Array(gf);for(let e of[53,27,52])Jo[e]=1;pf=new Uint8Array(gf);for(let e of[27,49,50,47,51,10])pf[e]=1;ls=new Uint8Array(gf);ls[33]=1;ls[34]=2;ls[35]=3;ls[36]=4;ls[37]=5;O3="'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS', 'BQUOTE_STR'";z3=["aggregation","extension","composition","dependency","lollipop"];uf=12,pl=16,fl=6,ec=5;W3=40,B3=16,_g=56,ns=20,Ig=26,df=12,Xo=8,Ng=6,H3=10,Y3=64,Ko=8,ff="var(--_l)",U3=new Set(["_self","_blank","_parent","_top"]);Zo=[],Qo=[];Dg={type:"class",math:!0,parse(e,t,r){let a=new N3;return r&&(a.title=r),P3(e,a),a},render:q3}});var Pg={};Ct(Pg,{classDiagram:()=>Dg});var zg=Ve(()=>{Og()});function kr(e,t,r){for(let a=0;a<r.length;a++){let i=e.charCodeAt(t+a),s=r.charCodeAt(a);if(i!==s&&!(s>=97&&s<=122&&i===s-32))return!1}return!0}var mf=Ve(()=>{});function tc(e,t,r){return new je(`value for ${e} ${t} is invalid, please use a valid ${r}`,"semantic",{type:"quadrantChart"})}function X3(e){let t=e.trim(),r=t.indexOf(":");if(r===-1)return[t,"undefined"];let a=t.slice(r+1).trimStart(),i=a.indexOf(":");return[t.slice(0,r).trimEnd(),i===-1?a:a.slice(0,i).trimEnd()]}function Wg(e){let t={};for(let r of e){let[a,i]=X3(r);if(a==="radius"){if(!j3.test(i))throw tc(a,i,"number");t.radius=parseInt(i)}else if(a==="color"){if(!Fg.test(i))throw tc(a,i,"hex code");t.color=i}else if(a==="stroke-color"){if(!Fg.test(i))throw tc(a,i,"hex code");t.strokeColor=i}else if(a==="stroke-width"){if(!V3.test(i))throw tc(a,i,"number of pixels (eg. 10px)");t.strokeWidth=i}else throw new je(`style named ${a} is not supported.`,"semantic",{type:"quadrantChart"})}return t}function pi(e){return{text:e.text.trim(),type:e.type}}function Z3(e){let t=e.length,r=[],a=[],i=[],s=[],l=0,n=0,o=0,c=0,f=0,p=0,d=0,g=0,u=0,m=0,b=(O,W,U)=>{r.push(O),a.push(e.slice(W,U)),i.push(W),n=U},w=O=>{s.push(l),l=O},v=()=>{s.length>0&&(l=s.pop())},k=O=>{let W=e.indexOf(`
|
|
70
|
+
`,O);return W===-1?t:W},L=O=>{for(;e.charCodeAt(O)===32;)O++;return O},I=O=>{for(;O<t&&Ue(e.charCodeAt(O));)O++;return O},N=O=>{let W=e.charCodeAt(O);if(W===49)return O+1;if(W!==48)return-1;let U=O+1;if(U<t&&!Xi(e.charCodeAt(U))&&pt(e.charCodeAt(U+1)))for(U+=2;pt(e.charCodeAt(U));)U++;return U};e:for(;n<t;){let O=e.charCodeAt(n),W=e.charCodeAt(n+1);switch(l){case 0:break;case 1:case 2:case 3:b(yf[l],n,k(n)),v();continue;case 4:if(O===125)n++,v();else{let C=e.indexOf("}",n);b(9,n,C===-1?t:C)}continue;case 5:if(O===34)n++,v();else{let C=e.indexOf('"',n);b(19,n,C===-1?t:C)}continue;case 6:if(O===96&&W===34){n+=2,v();continue}if(O!==96&&O!==34){let C=n+1;for(let S=e.charCodeAt(C);C<t&&S!==96&&S!==34;S=e.charCodeAt(++C));b(18,n,C);continue}break e;case 7:if(Qe(O)){let C=n+1;for(;Qe(e.charCodeAt(C));)C++;b(20,n,C),v();continue}break e;case 8:{let C=N(n);if(C!==-1){b(22,n,C),w(9);continue}let S=I(n);if(e.charCodeAt(S)===93){n=L(S+1),v();continue}break e}case 9:{let C=I(n);if(e.charCodeAt(C)===44){n=I(C+1),l=10;continue}break e}case 10:{let C=N(n);if(C!==-1){b(23,n,C),v();continue}break e}}if(O===37&&W===37){n=k(n+2);continue}if(O!==125&&W===37&&e.charCodeAt(n+2)===37){n=k(n+3);continue}if(O===10||O===13){let C=n+1;for(let S=e.charCodeAt(C);S===10||S===13;S=e.charCodeAt(++C));b(2,n,C);continue}let U=O|32;if(U===116&&kr(e,n,"title")&&!Qe(e.charCodeAt(n+5))){b(3,n,n+5),w(1);continue}if(U===97&&kr(e,n,"acc")){let C=kr(e,n+3,"descr");if(C||kr(e,n+3,"title")){let S=I(n+8),$=e.charCodeAt(S);if($===58){b(C?7:5,n,I(S+1)),w(C?3:2);continue}if($===123&&C){n=I(S+1),w(4);continue}}}let _=n;O===32&&((n<o||n>=c)&&(o=n,c=L(n)),_=c);let j=e.charCodeAt(_),Z=j|32,H=0,z=0;if(Z===120&&kr(e,_,"x-axis"))H=10,z=_+6;else if(Z===121&&kr(e,_,"y-axis"))H=11,z=_+6;else if(j===45){if(_<f||_>=p)for(f=_,p=_;e.charCodeAt(p)===45;)p++;p-_>=2&&e.charCodeAt(p)===62&&(H=12,z=p+1)}else if(Z===113&&kr(e,_,"quadrant")){let C=e.charCodeAt(_+9);e.charCodeAt(_+8)===45&&C>=49&&C<=52?(H=13+C-49,z=_+10):kr(e,_+8,"chart")&&(H=24,z=_+13)}if(H!==0){b(H,n,L(z));continue}if(U===99&&kr(e,n,"classdef")&&!Qe(e.charCodeAt(n+8))){b(17,n,n+8);continue}if(O===34){W===96?(n+=2,w(6)):(n++,w(5));continue}if(O===58&&W===58&&e.charCodeAt(n+2)===58){n+=3,w(7);continue}if(O===58||Ue(O)){let C=n;if(O!==58&&((n<d||n>=g)&&(d=n,g=I(n)),C=g),e.charCodeAt(C)===58&&((C+1<u||C+1>=m)&&(u=C+1,m=I(C+1)),e.charCodeAt(m)===91)){b(21,n,I(m+1)),w(8);continue}}if(ni(O)){let C=n+1;for(;ni(e.charCodeAt(C));)C++;b(25,n,C);continue}if(O>=128){let C=n+1;for(;e.charCodeAt(C)>=128;)C++;b(26,n,C);continue}if(pt(O)){let C=n+1;for(;pt(e.charCodeAt(C));)C++;b(37,n,C);continue}if(wf[O]!==0){b(wf[O],n,n+1);continue}break}return n<t?(r.push(1),a.push(""),i.push(n),{types:r,texts:a,starts:i}):(l<yf.length&&(r.push(yf[l]),a.push(""),i.push(t)),r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i})}function rc(...e){let t=new Uint8Array(42);for(let r of e)t[r]=1;return t}function e4(e,t){let{types:r,texts:a,starts:i}=Z3(e),s=0,l=p=>{let d=r[s];throw d===1?it("quadrantChart",e,i[s],"",!0):it("quadrantChart",e,i[s],`Expecting ${p}, got '${Bg[d]}'`)},n=p=>(r[s]!==p&&l(`'${Bg[p]}'`),a[s++]),o=p=>p===19||p===18||Hg[p]===1,c=()=>{let p=r[s];o(p)||l(J3);let d=a[s++];for(;Hg[r[s]]===1||r[s]===38||r[s]===36;)d+=a[s++];return{text:d,type:p===18?"markdown":"text"}},f=()=>{let p=[];for(;;){xf[r[s]]===0&&l("'ALPHA', 'NUM', 'COLON', 'SPACE', 'BRKT', 'MINUS'");let d=a[s++];for(;xf[r[s]]===1;)d+=a[s++];if(p.push(d.trim()),r[s]!==29)return p;s++}};for(;Ug[r[s]]===1||r[s]===38;)s++;for(n(24);r[s]!==0;){for(;r[s]===38;)s++;let p=r[s];switch(p){case 17:{s++,n(38),Yg[r[s]]===0&&l("'ALPHA', 'NUM', 'UNICODE_TEXT'");let d=a[s++];for(;Yg[r[s]]===1;)d+=a[s++];n(38),t.addClass(d,f());break}case 10:case 11:{s++;let d=c(),g;r[s]===12&&(s++,o(r[s])?g=c():d.text+=" \u27F6 "),p===10?(t.setXAxisLeftText(d),g&&t.setXAxisRightText(g)):(t.setYAxisBottomText(d),g&&t.setYAxisTopText(g));break}case 13:case 14:case 15:case 16:s++,t[Q3[p-13]](c());break;case 3:s++,t.setDiagramTitle(n(4).trim());break;case 5:s++,t.setAccTitle(n(6).trim());break;case 7:s++,t.setAccDescription(n(8).trim());break;case 9:t.setAccDescription(a[s++].trim());break;default:if(o(p)){let d=c(),g=r[s]===20?a[s++]:"";n(21);let u=n(22),m=n(23);t.addPoint(d,g,u,m,xf[r[s]]===1?f():[])}}Ug[r[s]]===0&&l("'NEWLINE', 'SEMI', 'EOF'"),s++}}function bf(e,t){return e.quadrantChart?.[t]}function ui(e,t,r,a){let i=bf(e,t);return typeof i=="number"&&i>=0?Math.min(i,a):r}function Gg(e){return e.startsWith("#")?e:"#"+e}function r4(e,t,r){let a=r.fontSize??16,i=Math.round(a*.875),s=Math.round(a*.75),l=r.measurer??et(r.fontFamily),n=Math.round(Math.max(100,ui(t,"chartWidth",500,4e3))),o=Math.round(_i(r,n,280)),c=Math.round(Math.max(100,ui(t,"chartHeight",500,4e3))*o/n),f=ui(t,"quadrantPadding",r.padding??8,200),p=ui(t,"xAxisLabelPadding",5,200),d=ui(t,"yAxisLabelPadding",5,200),g=e.points.length>0,u=(K,re,ne)=>ze(K?.text,K?.type==="markdown",l,re,Math.max(ne,40)),m=ze(e.title,!1,l,a,Math.max(o-2*f,40),1),b=ui(t,"titlePadding",10,200),w=m.height>0?m.height+b:0,v=!!(e.xAxisLeft?.text||e.xAxisRight?.text),k=!!(e.yAxisBottom?.text||e.yAxisTop?.text),L=g||bf(t,"xAxisPosition")==="bottom",I=bf(t,"yAxisPosition")==="right",N=o-2*f,O=u(e.xAxisLeft,i,e.xAxisRight?N/2-16:N),W=u(e.xAxisRight,i,N/2-16),U=Math.max(O.height,W.height),_=v?U+p:0,j=c-2*f-w-_,Z=u(e.yAxisBottom,i,e.yAxisTop?j/2-16:j),H=u(e.yAxisTop,i,j/2-16),z=Math.max(Z.height,H.height),C=k?z+d:0,S=f+(I?0:C),$=f+w+(L?0:_),y=Math.max(0,N-C),E=Math.max(0,j),x=Math.max(0,(y-qg)/2),T=Math.max(0,(E-qg)/2),A=[S+x,$,S+y-x,$+E,S,$+T,S+y,$+E-T],M=(K,re,ne,de,ie)=>{for(let se=K;se<A.length;se+=4)if(re<A[se+2]&&de>A[se]&&ne<A[se+3]&&ie>A[se+1])return!1;return!0},Y=ui(t,"quadrantTextTopPadding",5,200),B="";for(let K=0;K<4;K++){let re=K===0||K===3?S+y-x:S,ne=K<2?$:$+E-T,de=u(e.quadrants[K],a,x-16),ie=re+x/2,se=g?ne+Y+de.height/2:ne+T/2;A.push(ie-de.width/2,se-de.height/2,ie+de.width/2,se+de.height/2),B+=`<g class="pele-quadrant" data-id="${K+1}"><rect x="${h(re)}" y="${h(ne)}" width="${h(x)}" height="${h(T)}"${st}/>`+Re(de,ie,se,' class="pele-label" fill="var(--_fg)" stroke="none"')+"</g>"}let q="";if(v){let K=L?$+E+p+U/2:$-p-U/2;q+=Re(O,W.height>0?S+y/4:S+O.width/2,K,"")+Re(W,S+y*3/4,K,"")}if(k){let K=I?S+y+d+z/2:S-d-z/2,re=(ne,de)=>ne.height>0?`<g transform="translate(${h(K)},${h(de)}) rotate(-90)">${Re(ne,0,0,"")}</g>`:"";q+=re(Z,H.height>0?$+E*3/4:$+E-Z.width/2)+re(H,$+E/4)}let D=ui(t,"pointRadius",5,200),R=ui(t,"pointTextPadding",5,200),P=dt(0),G=[],X=[];for(let K of e.points){if(!(K.x>=0&&K.x<=1&&K.y>=0&&K.y<=1))continue;let re=e.classes.get(K.className),ne=Math.min(K.radius??re?.radius??D,2e3),de=K.color??re?.color,ie=K.strokeColor??re?.strokeColor,se=K.strokeWidth??re?.strokeWidth,ee=[];de&&ee.push("fill:"+Gg(de)),se&&(ie&&ee.push("stroke:"+Gg(ie)),ee.push("stroke-width:"+se));let te=S+K.x*y,fe=$+(1-K.y)*E;G.push({cx:te,cy:fe,reach:ne+(se?Math.min(parseInt(se),400)/2:0),text:u(K.text,s,200)}),X.push(`<circle class="pele-point${_t(K.className)}" data-id="${Oe(K.text.text)}" cx="${h(te)}" cy="${h(fe)}" r="${h(ne)}"${se&&!ie?` stroke="${P}"`:""}${vt(ee).shape}/>`)}let Q=G.length<=t4;if(Q)for(let{cx:K,cy:re,reach:ne}of G)A.push(K-ne,re-ne,K+ne,re+ne);let J="";for(let{cx:K,cy:re,reach:ne,text:de}of G){let ie=de.width/2,se=de.size*.6+(de.height-de.lineHeight)/2,ee=ne+R,te=[K,re+ee+se,K,re-ee-se,K+ee+ie,re,K-ee-ie,re],fe=K,ye=te[1],le=!1;for(let we=0;we<16;we+=2){let pe=we%8,ge=pe<4&&de.width<y?Math.min(Math.max(te[pe],S+ie),S+y-ie):te[pe],Ae=te[pe+1];if(ge-ie<S||ge+ie>S+y||Ae-se<$||Ae+se>$+E)continue;let Se=!Q||M(we<8?0:8,ge-ie,Ae-se,ge+ie,Ae+se);if((!le||Se)&&(fe=ge,ye=Ae,le=!0),Se)break}Q&&A.push(fe-ie,ye-se,fe+ie,ye+se),J+=Re(de,fe,ye,' class="pele-label"')}let F=Re(m,o/2,b/2+m.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-quadrants" fill="var(--_s)" stroke="var(--_b)">${B}</g>`+(q?`<g class="pele-axis-labels" font-size="${i}" fill="var(--_m)">${q}</g>`:"")+(G.length>0?`<g class="pele-points" fill="${P}">${X.reverse().join("")}</g><g class="pele-point-labels" font-size="${s}">${J}</g>`:"");return{svg:Je("quadrantChart",o,c,a,r,e,F),width:o,height:c,links:[]}}var j3,Fg,V3,K3,Bg,yf,wf,Hg,Yg,xf,Ug,Q3,J3,qg,t4,jg,Vg=Ve(()=>{mf();tr();zt();ut();wt();j3=/^\d+$/,Fg=/^#?([\dA-Fa-f]{6}|[\dA-Fa-f]{3})$/,V3=/^\d+px$/;K3=class{constructor(){ce(this,"type","quadrantChart");ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"quadrants",[void 0,void 0,void 0,void 0]);ce(this,"xAxisLeft");ce(this,"xAxisRight");ce(this,"yAxisBottom");ce(this,"yAxisTop");ce(this,"points",[]);ce(this,"classes",new Map)}setQuadrant1Text(e){this.quadrants[0]=pi(e)}setQuadrant2Text(e){this.quadrants[1]=pi(e)}setQuadrant3Text(e){this.quadrants[2]=pi(e)}setQuadrant4Text(e){this.quadrants[3]=pi(e)}setXAxisLeftText(e){this.xAxisLeft=pi(e)}setXAxisRightText(e){this.xAxisRight=pi(e)}setYAxisBottomText(e){this.yAxisBottom=pi(e)}setYAxisTopText(e){this.yAxisTop=pi(e)}addPoint(e,t,r,a,i){this.points.push({x:Number(r),y:Number(a),text:pi(e),className:t,...Wg(i)})}addClass(e,t){this.classes.set(e,Wg(t))}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
71
|
+
`)}},Bg=["$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"],yf=[41,4,6,8,9,19],wf=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 r=0;r<e.length;r++)wf[e.charCodeAt(r)]=t;Hg=rc(40,35,37,25,29,28,30,31,34,32,33,26),Yg=rc(25,37,36,29,27,35,32,31,26),xf=rc(25,37,27,38,32,36),Ug=rc(2,39,41),Q3=["setQuadrant1Text","setQuadrant2Text","setQuadrant3Text","setQuadrant4Text"],J3="'STR', 'MD_STR', 'ALPHA', 'NUM', 'UNICODE_TEXT', 'PUNCTUATION'";qg=4,t4=300;jg={type:"quadrantChart",parse(e,t,r){let a=new K3;return a.title=r,e4(e,a),a},render:r4}});var Xg={};Ct(Xg,{quadrantChart:()=>jg});var Kg=Ve(()=>{Vg()});function i4(e){let t=e.length,r=[],a=[],i=[],s=[],l=0,n=0,o=(m,b,w)=>{r.push(m),a.push(e.slice(b,w)),i.push(b),n=w},c=m=>{s.push(l),l=m},f=()=>{s.length>0&&(l=s.pop())},p=m=>{let b=e.indexOf(`
|
|
72
|
+
`,m);return b===-1?t:b},d=m=>{for(;m<t&&Ue(e.charCodeAt(m));)m++;return m},g=m=>{for(;pt(e.charCodeAt(m));)m++;return m},u=m=>kr(e,n,m)&&!Qe(e.charCodeAt(n+m.length));for(;n<t;){let m=e.charCodeAt(n);if(l===5){if(m===34)n++,f();else{let w=e.indexOf('"',n);o(19,n,w===-1?t:w)}continue}if(l===6||l===7){o(Qg[l],n,p(n)),f();continue}if(l===8){if(m===125)n++,f();else{let w=e.indexOf("}",n);o(8,n,w===-1?t:w)}continue}let b=e.charCodeAt(n+1);if(m===37&&b===37){n=p(n+2);continue}if(m!==125&&b===37&&e.charCodeAt(n+2)===37){n=p(n+3);continue}if(m===10||m===13){if((l===1||l===3)&&(m===10||b===10)){o(2,n,m===10?n+1:n+2),f();continue}let w=n+1;for(let v=e.charCodeAt(w);v===10||v===13;v=e.charCodeAt(++w));o(2,n,w);continue}switch(m|32){case 116:if(u("title")){o(3,n,n+5);continue}break;case 97:if(kr(e,n,"acc")){let w=kr(e,n+3,"descr");if(w||kr(e,n+3,"title")){let v=d(n+8),k=e.charCodeAt(v);if(k===58){o(w?6:4,n,d(v+1)),c(w?7:6);continue}if(k===123&&w){n=d(v+1),c(8);continue}}}break;case 120:if(u("xychart-beta")){o(9,n,n+12);continue}if(u("xychart")){o(9,n,n+7);continue}if(u("x-axis")){o(11,n,n+6),c(1);continue}break;case 121:if(u("y-axis")){o(12,n,n+6),c(1);continue}break;case 118:if(kr(e,n,"vertical")){o(10,n,n+8);continue}break;case 104:if(kr(e,n,"horizontal")){o(10,n,n+10);continue}break;case 108:if(u("line")){o(14,n,n+4),c(3);continue}break;case 98:if(u("bar")){o(15,n,n+3),c(3);continue}break}if(m===91){l===1?c(2):l===3&&c(4),o(17,n,n+1);continue}if(m===93){(l===4||l===2)&&f(),o(18,n,n+1);continue}if(l===1&&m===45&&b===45&&e.charCodeAt(n+2)===62){o(13,n,n+3);continue}if(l===1||l===4){let w=m===43||m===45?n+1:n,v=e.charCodeAt(w),k=-1;if(pt(v)?(k=g(w+1),e.charCodeAt(k)===46&&pt(e.charCodeAt(k+1))&&(k=g(k+2))):v===46&&pt(e.charCodeAt(w+1))&&(k=g(w+2)),k!==-1){o(16,n,k);continue}}if(m===96&&kr(e,n,Jg)){n+=Jg.length,f();continue}if(m===34){n++,c(5);continue}if(ni(m)){let w=n+1;for(;ni(e.charCodeAt(w));)w++;o(20,n,w);continue}if(pt(m)){o(31,n,g(n+1));continue}if(Ue(m)){n=d(n+1);continue}if(m<128&&kf[m]!==0){o(kf[m],n,n+1);continue}break}return n<t?(r.push(1),a.push(""),i.push(n),{types:r,texts:a,starts:i}):(r.push(Qg[l]),a.push(""),i.push(t),r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i})}function cm(...e){let t=new Uint8Array(34);for(let r of e)t[r]=1;return t}function s4(e,t){let{types:r,texts:a,starts:i}=i4(e),s=0,l=d=>{let g=r[s];throw g===1?it("xychart",e,i[s],"",!0):it("xychart",e,i[s],`Expecting ${d}, got '${Zg[g]}'`)},n=d=>(r[s]!==d&&l(`'${Zg[d]}'`),a[s++]),o=d=>d===19||em[d]===1,c=()=>{o(r[s])||l("'STR', 'ALPHA', 'NUM'");let d=a[s++];if(r[s-1]!==19)for(;em[r[s]]===1;)d+=a[s++];return{text:d,type:"text"}},f=()=>{let d=Number(n(16));return n(13),[d,Number(n(16))]},p=()=>{let d=[];for(n(17);;){let g=Number(n(16));if(d.push({value:g,label:r[s]===19?a[s++]:""}),r[s]!==23)break;s++}return n(18),d};for(;;)if(tm[r[s]]===1)s++;else{if(r[s]!==9)break;r[++s]===10&&t.setOrientation(a[s++])}for(;r[s]!==0;){let d=r[s++];switch(d){case 3:t.setDiagramTitle(c().text.trim());break;case 11:case 12:{let g=o(r[s])?c():void 0;if(d===11&&r[s]===17){let u=[];do s++,u.push(c());while(r[s]===23);n(18),t.setXAxisBand(u)}else if(r[s]===16||g===void 0){let[u,m]=f();d===11?t.setXAxisRangeData(u,m):t.setYAxisRangeData(u,m)}d===11?t.setXAxisTitle(g??{type:"text",text:""}):t.setYAxisTitle(g??{type:"text",text:""});break}case 14:case 15:{let g=r[s]===17?{text:"",type:"text"}:c(),u=p();d===14?t.setLineData(g,u):t.setBarData(g,u);break}case 4:t.setAccTitle(n(5).trim());break;case 6:t.setAccDescription(n(7).trim());break;case 8:t.setAccDescription(a[s-1].trim());break;default:s--,l("'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'")}for(;tm[r[s]]===1;)s++}}function rm(e,t){let r=e/Math.max(t,1),a=Math.floor(Math.log10(r)),i=r/10**a,s=i>=7.07?10:i>=3.16?5:i>=1.41?2:1;return a<0?-(10**-a)/s:s*10**a}function ic(e,t){return e>0?t/e:t*-e}function gl(e,t){return e>0?t*e:t/-e}function am(e,t,r){let a=Math.round(ic(r,e));gl(r,a)<e&&a++;let i=Math.round(ic(r,t));gl(r,i)>t&&i--;let s=[];for(let l=a;l<=i&&s.length<100;l++)s.push(gl(r,l));return s}function $f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function ya(e,t,r=!0){let a=e[t];return typeof a=="boolean"?a:r}function om(e,t){return typeof e=="number"&&e>0?Math.round(Math.min(Math.max(e,100),4e3)):t}function Li(e){return typeof e=="number"&&isFinite(e)?Math.min(Math.max(e,-lm),lm):void 0}function n4(e){let t=0;for(let r of e)t=Math.max(t,r.label.width);return t}function ac(e,t,r,a){let i=e.lines.length===1?e.lines[0]:void 0;return i&&i.length===1&&i[0].icon===void 0&&i[0].style===0?`<text x="${h(t)}" y="${h(r+e.size*.35)}" text-anchor="${a}">${Xe(i[0].text)}</text>`:Re(e,t+(a==="start"?e.width/2:a==="end"?-e.width/2:0),r,"")}function l4(e,t,r){if(e.plots.length===0)throw new je("No Plot to render, please provide a plot with some data","semantic",{type:"xychart"});let a=$f(t.xyChart),i=r.fontSize??16,s=Math.round(i*.875),l=Math.round(i*.75),n=r.measurer??et(r.fontFamily),o=r.padding??8,c=om(a.width,700),f=_i(r,c,240),p=Math.round(om(a.height,500)*Math.max(.6,f/c)),d=(e.orientation??a.chartOrientation)==="horizontal",g=ya(a,"showDataLabel",!1),u=e.xAxis,m=e.plots,b=(Ee,qe,Ge)=>ze(Ee,!1,n,qe,Ge),w=b("0",s,4e3).height,v=b("0",l,4e3).height,k=ze(ya(a,"showTitle")?e.title:void 0,!1,n,i,f-2*o,1),L=k.height>0?k.height+12:0,I=[],N=0;ya(a,"showLegend")&&m.forEach((Ee,qe)=>{if(Ee.title==="")return;let Ge=b(Ee.title,s,f*.3);I.push({index:qe,label:Ge}),N=Math.max(N,Ge.width+Qs+8)});let O=I.length>0?N+nm:0,W=m.filter(Ee=>Ee.type==="bar").length,U=e.yAxis.min,_=e.yAxis.max,j=e.hasSetYAxis&&isFinite(U)&&isFinite(_)&&U!==_;if(j)U=Li(U),_=Li(_);else{U=1/0,_=-1/0;for(let Ee of m)for(let[,qe]of Ee.data){let Ge=Li(qe);Ge!==void 0&&(Ge<U&&(U=Ge),Ge>_&&(_=Ge))}U>_&&(U=_=0),W>0&&(U=Math.min(U,0),_=Math.max(_,0)),U===_&&(U===0?_=1:(U-=Math.abs(U)/2,_+=Math.abs(_)/2))}let Z=(Ee,qe)=>{let Ge=rm(Math.abs(_-U),Math.max(2,Math.min(10,Math.floor(Ee/qe))));return j||(U=gl(Ge,Math.floor(ic(Ge,U)+1e-9)),_=gl(Ge,Math.ceil(ic(Ge,_)-1e-9))),am(Math.min(U,_),Math.max(U,_),Ge).map(rt=>({at:(rt-U)/(_-U),label:b(String(rt),s,4e3)}))},H=1;if(u.type==="band")H=Math.max(u.categories.length,1);else for(let Ee of m)H=Math.max(H,Ee.data.length);let z=1/H,C=u.type==="band"||W>0?z/2:0,S=Li(u.type==="linear"?u.min:void 0),$=Li(u.type==="linear"?u.max:void 0),y=S!==void 0&&$!==void 0&&S!==$,E=(Ee,qe)=>u.type==="band"?(Ee+.5)*z:C+(qe>1?Ee/(qe-1):y?0:.5)*(1-2*C),x=$f(a.xAxis),T=$f(a.yAxis),A=d?x:T,M=d?T:x,Y=b(ya(A,"showTitle")?d?u.title:e.yAxis.title:void 0,s,p*.8),B=b(ya(M,"showTitle")?d?e.yAxis.title:u.title:void 0,s,f*.8),q=ya(A,"showTick")?im:0,D=ya(M,"showTick")?im:0,R=ya(A,"showLabel"),P=ya(M,"showLabel"),G=d?f*.3:Math.max(48,(f-2*o-64-O)*z-8),X=u.type==="band"&&ya(x,"showLabel")?u.categories.map(Ee=>b(Ee,s,G)):[],Q=0,J=0;for(let Ee of X)Q=Math.max(Q,Ee.width),J=Math.max(J,Ee.height);let F=Ee=>{let qe=[];if(u.type==="band"){let Ge=X.length===0?8:d?J:Q+12,rt=Math.max(1,Math.ceil(Ge/(Ee*z)));for(let ct=0;ct<u.categories.length;ct+=rt)qe.push({at:(ct+.5)*z,label:X[ct]??b(void 0,s,0)})}else if(y){let Ge=rm(Math.abs($-S),Math.max(2,Math.min(10,Math.floor(Ee/(d?32:80)))));for(let rt of am(Math.min(S,$),Math.max(S,$),Ge))qe.push({at:C+(rt-S)/($-S)*(1-2*C),label:b(String(rt),s,4e3)})}else S!==void 0&&qe.push({at:.5,label:b(String(S),s,4e3)});return qe},K=0,re=0;for(let Ee of m){for(let qe of Ee.pointLabels??[])K=Math.max(K,n.width(qe,l,0));if(g&&d&&Ee.type==="bar")for(let[,qe]of Ee.data)re=Math.max(re,n.width(String(Li(qe)??""),l,0))}let ne=P?d||u.type!=="band"?w:J:0,de=D+(ne>0?ne+4:0)+(B.height>0?B.height+4:0),ie=d?0:K>0||g?v+4:R?w/2:0,se=o+L+ie,ee=Math.max(1,p-o-de-se),te=se+ee,fe=d?F(ee):Z(ee,56),ye=R?n4(fe):0,le=o+(Y.height>0?Y.height+6:0)+(ye>0?ye+6:0)+q,we=Math.max(K>0?K+12:0,re>0?re+8:0),pe=d?Math.min(f*.25,we):0,ge=Math.max(1,f-o-le-O-pe),Ae=d?Z(ge,80):F(ge);if(P&&O+pe===0){let Ee=0;for(let qe of Ae)Ee=Math.max(Ee,qe.at*ge+qe.label.width/2-ge);ge=Math.max(1,ge-Ee)}let Se=le+ge,oe=(Ee,qe)=>d?le+qe*ge:le+Ee*ge,ue=(Ee,qe)=>d?se+Ee*ee:te-qe*ee,xe=Ee=>(Ee-U)/(_-U),Ie=Ee=>Math.min(Math.max(Ee,0),1),Le=Ee=>d?`M${h(oe(0,Ee))},${h(se)}V${h(te)}`:`M${h(le)},${h(ue(0,Ee))}H${h(Se)}`,We="";for(let Ee of d?Ae:fe)We+=Le(Ee.at);let he="",ke="";ya(A,"showAxisLine")&&(he+=`M${h(le)},${h(se)}V${h(te)}`),ya(M,"showAxisLine")&&(he+=`M${h(le)},${h(te)}H${h(Se)}`);for(let Ee of fe){let qe=d?se+Ee.at*ee:te-Ee.at*ee;q&&(he+=`M${h(le)},${h(qe)}h${-q}`),R&&(ke+=ac(Ee.label,le-q-6,qe,"end"))}for(let Ee of Ae){let qe=le+Ee.at*ge;D&&(he+=`M${h(qe)},${h(te)}v${D}`),P&&(ke+=ac(Ee.label,qe,te+D+4+Ee.label.height/2,"middle"))}let Ce=(d?ee:ge)*z,be=Ce*.7/Math.max(W,1),Me=W>1?Math.min(2,be*.2):0,Ne=Ie(xe(0));W>0&&Ne>0&&Ne<1&&(he+=Le(Ne));let Be="",Pe="",V="",me="",ae=0;m.forEach((Ee,qe)=>{let Ge=dt(qe),rt=Ee.title?` data-id="${Oe(Ee.title)}"`:"",ct=u.type==="band"?Math.min(Ee.data.length,H):Ee.data.length;if(Ee.type==="bar"){let kt=(ae++-(W-1)/2)*be-(be-Me)/2,Ft="";for(let Ye=0;Ye<ct;Ye++){let ht=Li(Ee.data[Ye][1]);if(ht===void 0)continue;let yt=E(Ye,ct),ot=Ie(xe(ht)),er=Math.min(Ne,ot),Et=Math.max(Ne,ot),Ze=d?oe(yt,er):oe(yt,0)+kt,xt=d?ue(yt,0)+kt:ue(yt,Et),Dt=d?(Et-er)*ge:be-Me,Nt=d?be-Me:(Et-er)*ee;if(Ft+=`<rect x="${h(Ze)}" y="${h(xt)}" width="${h(Dt)}" height="${h(Nt)}"/>`,!g)continue;let ir=String(ht),ia=n.width(ir,l,0),ka=ot>=Ne?1:-1,Tn=Ze+Dt/2,Cn=xt+Nt/2,_n="middle";if(d){if(Nt<l)continue;Tn=(ka>0?Ze+Dt:Ze)+ka*6,_n=ka>0?"start":"end"}else{if(ia+2>Ce/W)continue;Cn=(ka>0?xt:xt+Nt)-ka*(v/2+2)}V+=`<text x="${h(Tn)}" y="${h(Cn+l*.35)}" text-anchor="${_n}">${ir}</text>`}Be+=`<g class="pele-series pele-bars"${rt} fill="${Ge}">${Ft}</g>`;return}let tt="",lt="",nt=!1,Wt=0,Tt=NaN;for(let kt=0;kt<ct;kt++){let Ft=Li(Ee.data[kt][1]);if(Ft===void 0){Tt=NaN;continue}let Ye=E(kt,ct),ht=xe(Ft),yt=ht>=0&&ht<=1;if(Tt!==Tt)yt&&(tt+=`M${h(oe(Ye,ht))},${h(ue(Ye,ht))}`),nt=yt;else{let Ze=ht-Tt,xt=0,Dt=1;if(Ze!==0){let Nt=-Tt/Ze,ir=(1-Tt)/Ze;xt=Math.max(xt,Math.min(Nt,ir)),Dt=Math.min(Dt,Math.max(Nt,ir))}else yt||(xt=2);if(xt<=Dt){let Nt=Wt+(Ye-Wt)*xt,ir=Tt+Ze*xt,ia=Wt+(Ye-Wt)*Dt,ka=Tt+Ze*Dt;(!nt||xt>0)&&(tt+=`M${h(oe(Nt,ir))},${h(ue(Nt,ir))}`),tt+=`L${h(oe(ia,ka))},${h(ue(ia,ka))}`}nt=yt}if(Wt=Ye,Tt=ht,!yt)continue;let ot=oe(Ye,ht),er=ue(Ye,ht);Ce>=12&&(lt+=`<circle cx="${h(ot)}" cy="${h(er)}" r="3"/>`);let Et=b(Ee.pointLabels?.[kt],l,4e3);if(Et.height>0){let Ze=Et.width/2;me+=d?ac(Et,ot+10,er,"start"):ac(Et,Math.max(Math.min(ot,Se-Ze),le+Ze),er-6-Et.height/2,"middle")}}Pe+=`<g class="pele-series pele-line"${rt} fill="${Ge}">`+(tt?`<path d="${tt}" fill="none" stroke="${Ge}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:"")+lt+"</g>"});let $e="";Y.height>0&&($e+=`<g transform="translate(${h(o+Y.height/2)},${h(se+ee/2)}) rotate(-90)">${Re(Y,0,0,"")}</g>`),$e+=Re(B,le+ge/2,p-o-B.height/2,"");let ve="",Te=0;for(let Ee of I)Te+=Math.max(sm,Ee.label.height+6);let De=se+Math.max(0,(ee-Te)/2),_e=Se+pe+nm;for(let{index:Ee,label:qe}of I){let Ge=Math.max(sm,qe.height+6);if(De+Ge>p)break;let rt=De+Ge/2,ct=dt(Ee);ve+=`<g class="pele-legend-item" data-id="${Oe(m[Ee].title)}">`+(m[Ee].type==="bar"?`<rect x="${h(_e)}" y="${h(rt-Qs/2)}" width="${Qs}" height="${Qs}" rx="2" fill="${ct}"/>`:`<path d="M${h(_e)},${h(rt)}h${Qs}" stroke="${ct}" stroke-width="2" stroke-linecap="round"/>`)+Re(qe,_e+Qs+8+qe.width/2,rt,"")+"</g>",De+=Ge}let He=Re(k,f/2,o+k.height/2,' class="pele-title" font-weight="var(--_tw)"')+(We?`<path class="pele-grid" d="${We}" stroke="var(--_a)"/>`:"")+`<g class="pele-plot">${Be}${Pe}</g>`+(he?`<path class="pele-axis" d="${he}" fill="none" stroke="var(--_b)"/>`:"")+(ke?`<g class="pele-axis-labels" font-size="${s}" fill="var(--_m)">${ke}</g>`:"")+($e?`<g class="pele-axis-titles" font-size="${s}">${$e}</g>`:"")+(V?`<g class="pele-data-labels" font-size="${l}">${V}</g>`:"")+(me?`<g class="pele-point-labels" font-size="${l}">${me}</g>`:"")+(ve?`<g class="pele-legend" font-size="${s}">${ve}</g>`:"");return{svg:Je("xychart",f,p,i,r,e,He),width:f,height:p,links:[]}}var a4,Zg,Qg,Jg,kf,em,tm,im,Qs,sm,nm,lm,hm,dm=Ve(()=>{mf();tr();zt();ut();wt();a4=class{constructor(){ce(this,"type","xychart");ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"orientation");ce(this,"xAxis",{type:"band",title:"",categories:[]});ce(this,"yAxis",{type:"linear",title:"",min:1/0,max:-1/0});ce(this,"hasSetXAxis",!1);ce(this,"hasSetYAxis",!1);ce(this,"plots",[])}setOrientation(e){this.orientation=e==="horizontal"?"horizontal":"vertical"}setXAxisTitle(e){this.xAxis.title=e.text.trim()}setXAxisRangeData(e,t){this.xAxis={type:"linear",title:this.xAxis.title,min:e,max:t},this.hasSetXAxis=!0}setXAxisBand(e){this.xAxis={type:"band",title:this.xAxis.title,categories:e.map(t=>t.text.trim())},this.hasSetXAxis=!0}setYAxisTitle(e){this.yAxis.title=e.text.trim()}setYAxisRangeData(e,t){this.yAxis={type:"linear",title:this.yAxis.title,min:e,max:t},this.hasSetYAxis=!0}plotData(e){if(e.length===0)return[];this.hasSetXAxis||this.setXAxisRangeData(1,e.length);let t=this.xAxis;if(t.type==="band"&&e.length>t.categories.length&&(e=e.slice(0,t.categories.length)),!this.hasSetYAxis){let{min:a,max:i}=this.yAxis;for(let s of e)s<a&&(a=s),s>i&&(i=s);this.yAxis={type:"linear",title:this.yAxis.title,min:a,max:i}}if(t.type==="band")return t.categories.map((a,i)=>[a,e[i]]);if(e.length===1)return[[`${t.min}`,e[0]]];let r=(t.max-t.min)/(e.length-1);return e.map((a,i)=>[`${t.min+i*r}`,a])}addPlot(e,t,r){let a={type:e,title:t.text.trim(),data:this.plotData(r.map(i=>i.value))};e==="line"&&r.some(i=>i.label.trim()!=="")&&(a.pointLabels=r.map(i=>i.label.trim())),this.plots.push(a)}setLineData(e,t){this.addPlot("line",e,t)}setBarData(e,t){this.addPlot("bar",e,t)}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
73
|
+
`)}},Zg=["$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"],Qg=[33,33,33,33,33,19,5,7,8],Jg="`)"+" ".repeat(36)+'{ this.pushstate(md_string); }\n<md_string>(?:(?!`").)+'+" ".repeat(18)+"{ return md_str; }\n<md_string>(?:`",kf=new Uint8Array(128);for(let[e,t]of[[":",21],["+",22],[",",23],["=",24],["*",25],["#",26],["_",27],[".",28],["&",29],["-",30],[";",32]])kf[e.charCodeAt(0)]=t;em=cm(29,31,20,22,24,25,28,26,30,27),tm=cm(2,32,33);im=4,Qs=12,sm=26,nm=24,lm=1e300;hm={type:"xychart",section:"xyChart",parse(e,t,r){let a=new a4;return a.title=r,s4(e,a),a},render:l4}});var fm={};Ct(fm,{xychart:()=>hm});var pm=Ve(()=>{dm()});function o4(e){let t="TB";for(let r of e)typeof r!="string"&&r.stmt==="dir"&&(t=r.value);return t}function c4(e,t,r){let a=[],i=[],s=new Map,l=new Map,n=new Map,o=0,c=0,f=g=>{if(!g.id||g.id==="</join></fork>"||g.id==="</choice>")return;if(g.cssClasses){let m;for(let b of g.cssClasses.split(" ")){let w=r.get(b);if(w){m??(m=g.cssCompiledStyles.slice());for(let v of w.styles)m.push(v)}}m&&(g.cssCompiledStyles=m)}let u=s.get(g.id);if(u){let m=g.parentId??u.parentId;Object.assign(u,g),m!==void 0&&(u.parentId=m)}else s.set(g.id,g),a.push(g)},p=(g,u,m)=>{let b=u.id;if(b==="root")return;let w=t.get(b),v=w?.classes?.join(" ")??"",k=w?.styles??[],L=l.get(b);if(!L){let H="rect";u.start===!0?H="stateStart":u.start===!1&&(H="stateEnd"),u.type!=="default"&&(H=u.type),L={shape:H,description:b,cssClasses:`${v} statediagram-state`,cssStyles:k,type:void 0,dir:void 0,colorIndex:void 0},l.set(b,L)}if(u.description&&(Array.isArray(L.description)?(L.shape="rectWithTitle",L.description=L.description.concat(u.description)):L.description.length>0?(L.shape="rectWithTitle",L.description=L.description===b?[u.description].flat():[L.description,u.description].flat()):(L.shape="rect",L.description=Array.isArray(u.description)?u.description.slice():u.description)),L.description.length===1&&L.shape==="rectWithTitle"&&(L.shape=L.type==="group"?"roundedWithTitle":"rect"),!L.type&&u.doc){if(L.type="group",L.dir=o4(u.doc),L.shape=u.type==="divider"?"divider":"roundedWithTitle",L.shape==="divider"&&g?.id!==void 0&&n.has(g.id))L.colorIndex=n.get(g.id);else{let H=c++;L.colorIndex=v.trim()!==""||k.length>0?void 0:H}n.set(b,L.colorIndex),L.cssClasses=`${L.cssClasses} statediagram-cluster ${m?"statediagram-cluster-alt":""}`}let I=L.description,N={id:b,shape:L.shape,label:Array.isArray(I)?I[0]:I,description:Array.isArray(I)?I.slice(1):[],cssClasses:L.cssClasses,cssCompiledStyles:[],cssStyles:L.cssStyles,type:L.type,isGroup:L.type==="group",dir:L.dir,colorIndex:L.colorIndex};N.shape==="divider"&&(N.label=""),g&&g.id!=="root"&&(N.parentId=g.id);let O=u.note;if(!O){f(N);return}let W=(H,z,C,S)=>({id:H,shape:z,label:O.text,description:[],cssClasses:C,cssCompiledStyles:[],cssStyles:[],type:S?"group":"node",isGroup:S,dir:void 0,position:O.position}),U=W(`${b}----note-${o++}`,"note","statediagram-note",!1);U.parentId=`${b}----parent`,U.noteFor=b,f(W(U.parentId,"noteGroup",L.cssClasses,!0)),f(U),f(N);let _=O.position==="left of",j=_?U.id:b,Z=_?b:U.id;i.push({id:`${j}-${Z}`,start:j,end:Z,label:"",classes:"transition note-edge",pattern:"dashed"})},d=[{item:void 0,doc:e,at:0,alt:!0}];for(;d.length>0;){let g=d[d.length-1];if(g.at>=g.doc.length){d.pop();continue}let u=g.doc[g.at++];typeof u!="string"&&(u.stmt==="state"?(p(g.item,u,g.alt),u.doc&&d.push({item:u,doc:u.doc,at:0,alt:!g.alt})):u.stmt==="relation"&&(p(g.item,u.state1,g.alt),p(g.item,u.state2,g.alt),i.push({id:`edge${o++}`,start:u.state1.id,end:u.state2.id,label:u.description??"",classes:"transition"})))}for(let g of a)if(g.isGroup&&g.description.length>0)throw new je(`Group nodes can only have label. Remove the additional description for node [${g.id}]`,"semantic",{type:"state"});return{nodes:a,edges:i}}function ml(e,t){let r=0,a=-2;return i=>{if(a===-2||i<r||a!==-1&&i>a){e.lastIndex=i;let s=e.exec(t);a=s?s.index:-1,r=i}return a}}function m4(e){let t=e.length,r=[],a=[],i=[],s=[],l=0,n=0,o,c=ml(d4,e),f=ml(f4,e),p=ml(p4,e),d=ml(u4,e),g=ml(g4,e),u=-1,m=-1,b=[-1,-1,-1,-1],w=[0,0,0,0],v=-1,k=-1,L=[-1,-1,-1,-1,-1,-1],I=(y,E,x)=>{r.push(y),a.push(e.slice(E,x)),i.push(E),n=x},N=(y,E,x,T)=>{r.push(y),a.push(E),i.push(x),n=T},O=y=>{s.push(l),l=y},W=()=>{s.length>0&&(l=s.pop())},U=(y,E)=>{for(let x=0;x<y.length;x++){let T=y.charCodeAt(x),A=e.charCodeAt(E+x);if(A!==T&&!(T>=97&&T<=122&&A===T-32))return!1}return!0},_=y=>{let E=y;for(;E<t&&Ue(e.charCodeAt(E));)E++;return E},j=y=>{let E=y;for(;E<t&&Qe(e.charCodeAt(E));)E++;return E},Z=y=>{let E=e.indexOf(`
|
|
74
|
+
`,y);return E===-1?t:E},H=y=>{let E=p(y);return E===-1?t:E},z=y=>{if(y<u||y>m){let E=c(y),x=E===-1?t:H(y);u=y,m=x,b[0]=b[1]=b[2]=b[3]=-1;for(let T=E;T!==-1&&T<x;T=c(T+1)){let A=_(T+9);if(A===T+9)continue;let M=U("tb",A)?0:U("bt",A)?1:U("rl",A)?2:U("lr",A)?3:-1;M!==-1&&(b[M]=T,w[M]=A+2)}}for(let E=0;E<4;E++)if(b[E]>=y)return E;return-1},C=y=>{if(y<v||y>k){let E=f(y),x=E===-1?t:H(y);v=y,k=x,L.fill(-1);for(let T=E;T!==-1&&T<x;T=f(T+1)){let A=e.charCodeAt(T+2)|32;L[(e.charCodeAt(T)===60?0:3)+(A===102?0:A===106?1:2)]=T}}for(let E=0;E<6;E++)if(L[E]>=y)return E;return-1},S=(y,E)=>{let x=d(y);return x===-1||x+2>E?(I(14,y,E),!0):x===y?(n=E,!1):(I(14,y,x),!0)},$=y=>(r.push(y),a.push(""),i.push(n),{types:r,texts:a,starts:i,error:o});for(;;){if(n>=t){switch(l){case 0:I(2,t,t);break;case 6:I(22,t,t);break;case 7:I(24,t,t);break;case 8:I(25,t,t);break;case 10:I(32,t,t);break;case 12:I(39,t,t);break;case 14:I(36,t,t);break;case 3:I(12,t,t);break;case 18:I(20,t,t);break;case 4:case 19:I(14,t,t);break}return $(0)}let y=e.charCodeAt(n);switch(l){case 0:case 1:{let E=l===0,x=y|32;if(E){if(x===99&&U("click",n)&&!Qe(e.charCodeAt(n+5))){I(26,n,n+5);continue}if(x===104&&U("href",n)&&!Qe(e.charCodeAt(n+4))){I(28,n,n+4);continue}if(y===34){let M=e.indexOf('"',n+1);if(M!==-1){I(27,n,M+1);continue}}if(x===100&&U("default",n)&&!Qe(e.charCodeAt(n+7))){I(33,n,n+7);continue}let A=z(n);if(A!==-1){I(40+A,n,Z(w[A]));continue}if(y===10){let M=n+1;for(;e.charCodeAt(M)===10;)M++;I(2,n,M);continue}if(Ue(y)){n=_(n);continue}}else if(y!==10&&Ue(y)){let A=n+1;for(;A<t&&e.charCodeAt(A)!==10&&Ue(e.charCodeAt(A));)A++;n=A;continue}if(y===35||y===37&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)!==123){n=Z(n);continue}if(x===115){if(E&&U("scale",n)){let A=_(n+5);if(A>n+5){I(7,n,A),O(5);continue}}if(U("style",n)){let A=_(n+5);if(A>n+5){I(34,n,A),O(13);continue}}if(U("state",n)){let A=_(n+5);if(A>n+5){n=A,O(2);continue}if(E&&U("diagram",n+5)){let M=U("-v2",n+12)?n+15:n+12;if(A=_(M),A>M){I(3,n,A);continue}}}}else if(x===99){if(U("class",n)){let A=U("def",n+5),M=A?n+8:n+5,Y=_(M);if(Y>M){I(A?29:37,n,Y),O(A?9:11);continue}}}else if(x===97&&E&&(U("acctitle",n)||U("accdescr",n))){let A=(e.charCodeAt(n+3)|32)===116,M=_(n+8),Y=e.charCodeAt(M);if(Y===58){I(A?21:23,n,_(M+1)),O(A?6:7);continue}if(Y===123&&!A){n=_(M+1),O(8);continue}}if(E){if(y===123){I(10,n,n+1),O(1);continue}}else{let A=z(n);if(A!==-1){I(40+A,n,Z(w[A]));continue}if(y===125){I(11,n,n+1),W();continue}if(y===10){n++;continue}}if(x===110&&U("note",n)){let A=_(n+4);if(A>n+4){I(19,n,A),O(15);continue}}if(E&&x===104&&U("hide empty description",n)&&!Qe(e.charCodeAt(n+22))){I(6,n,n+22);continue}if(y===91&&e.charCodeAt(n+1)===42&&e.charCodeAt(n+2)===93){I(44,n,n+3);continue}let T=n;for(;T<t;){let A=e.charCodeAt(T);if(A===58||A===45||A===123||Ue(A))break;T++}if(T>n){S(n,T);continue}if(y===58){for(T=n+1;T<t;){let A=e.charCodeAt(T);if(A===10||A===59)break;if(A===58){let M=e.charCodeAt(T+1);if(T+1>=t||M===58||M===10||M===59)break;T++}T++}if(T>n+1){N(4,e.slice(n,T).trim(),n,T);continue}if(e.charCodeAt(n+1)===58&&e.charCodeAt(n+2)===58){I(45,n,n+3);continue}}else if(y===45&&e.charCodeAt(n+1)===45){if(e.charCodeAt(n+2)===62){I(5,n,n+3);continue}if(!E){I(18,n,n+2);continue}}if(!E)return $(1);I(48,n,n+1);continue}case 2:{if(y!==10&&Ue(y)){let A=n+1;for(;A<t&&e.charCodeAt(A)!==10&&Ue(e.charCodeAt(A));)A++;n=A;continue}if(y===35||y===37&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)!==123){n=Z(n);continue}let E=C(n);if(E!==-1){let A=L[E],M=E===2||E===5;N(M?17:E%3===0?15:16,e.slice(n,A).trim(),n,A+(M?10:8)),W();continue}if(y===34){n++,O(3);continue}let x=y===10?_(n):n;if(U("as",x)){let A=_(x+2);if(A>x+2){I(13,n,A),O(4);continue}}if(y===10){n++,W();continue}if(y===123){I(10,n,n+1),W(),O(1);continue}if(Qe(y)){let A=j(n),M=_(A);if(M>A&&Qe(e.charCodeAt(M))){let Y=g(M+1);if(Y!==-1&&Y<H(M))return o=`Error: State name must be a single word. Found: "${e.slice(n,Y+1).trim()}"`,$(1)}}let T=n+1;for(;T<t;){let A=e.charCodeAt(T);if(A===123||Ue(A))break;T++}I(9,n,T);continue}case 3:{if(y===34){n++,W();continue}let E=e.indexOf('"',n);I(12,n,E===-1?t:E);continue}case 4:{let E=n;for(;E<t;){let x=e.charCodeAt(E);if(x===10||x===123)break;E++}S(n,E)&&W();continue}case 5:{if(y>=48&&y<=57){let x=n+1;for(;x<t&&e.charCodeAt(x)>=48&&e.charCodeAt(x)<=57;)x++;I(8,n,x);continue}let E=_(n);if(E>n&&U("width",E)&&!Qe(e.charCodeAt(E+5))){n=E+5,W();continue}return $(1)}case 6:I(22,n,Z(n)),W();continue;case 7:I(24,n,Z(n)),W();continue;case 8:{if(y===125){n++,W();continue}let E=e.indexOf("}",n);I(25,n,E===-1?t:E);continue}case 9:{let E=U("default",n)&&_(n+7)>n+7,x=E?n+7:j(n),T=_(x);if(x===n||T===x)return $(1);I(E?31:30,n,T),W(),O(10);continue}case 10:I(32,n,Z(n)),W();continue;case 11:{let E=j(n);if(E===n)return $(1);for(;e.charCodeAt(E)===44;){let x=_(E+1),T=j(x);if(T===x)break;E=T}I(38,n,E),W(),O(12);continue}case 12:I(39,n,Z(n)),W();continue;case 13:{let E=n;for(;E<t&&(Qe(e.charCodeAt(E))||e.charCodeAt(E)===44);)E++;let x=_(E);if(E===n||x===E)return $(1);I(35,n,x),W(),O(14);continue}case 14:I(36,n,Z(n)),W();continue;case 15:{if(U("left of",n)&&!Qe(e.charCodeAt(n+7))){I(46,n,n+7),W(),O(16);continue}if(U("right of",n)&&!Qe(e.charCodeAt(n+8))){I(47,n,n+8),W(),O(16);continue}if(y===34){n++,W(),O(18);continue}return $(1)}case 16:{let E=_(n),x=E;for(;x<t;){let T=e.charCodeAt(x);if(T===58||T===45||Ue(T))break;x++}if(x===E)return $(1);S(n,x)&&(W(),O(17));continue}case 17:{let E=_(n);if(e.charCodeAt(E)===58){let A=E+1;for(;A<t;){let M=e.charCodeAt(A);if(M===58||M===10||M===59)break;A++}if(A>E+1){N(20,e.slice(n+2,A).trim(),n,A),W();continue}}let x=e.indexOf(`
|
|
75
|
+
`,n),T=-1;for(;x!==-1&&(T=_(x),!(U("end note",T)&&!Qe(e.charCodeAt(T+8))));)x=e.indexOf(`
|
|
76
|
+
`,T);if(x===-1)return $(1);N(20,e.slice(n,T).trim(),n,T+8),W();continue}case 18:{let E=_(n);if(U("as",E)){I(13,n,_(E+2)),W(),O(19);continue}if(y===34){n++;continue}let x=e.indexOf('"',n);I(20,n,x===-1?t:x);continue}case 19:S(n,Z(n))&&W();continue}}}function x4(e,t){let{types:r,texts:a,starts:i,error:s}=m4(e),l=0,n=u=>{let m=r[l];throw m===1?s!==void 0?new je(s,"syntax",{type:"state",...Bn(e,i[l])}):it("state",e,i[l],"",!0):it("state",e,i[l],`Expecting ${u}, got '${um[m]}'`)},o=u=>(r[l]!==u&&n(`'${um[u]}'`),a[l++]),c=()=>{let u=r[l];u!==14&&u!==44&&n("'ID', 'EDGE_STATE'");let m=a[l++].trim();return r[l]!==45?{stmt:"state",id:m,type:"default",description:""}:(l++,{stmt:"state",id:m,classes:[o(14).trim()],type:"default",description:""})};for(;r[l]===2;)l++;r[l]!==3&&n("'NL', 'SD'"),l++;let f=[],p=[],d=u=>{u!=="nl"&&f.push(u)},g=(u,m)=>{l++;let b=[];f.push({stmt:"state",id:u,type:"default",description:m,doc:b}),p.push(f),f=b};for(;;){let u=r[l];switch(u){case 2:l++;break;case 14:case 44:{let m=c();if(r[l]===4)m.description=t.trimColon(a[l++]),d(m);else if(r[l]===5){l++;let b=c();r[l]===4?d({stmt:"relation",state1:m,state2:b,description:t.trimColon(a[l++])}):d({stmt:"relation",state1:m,state2:b})}else d(m);break}case 6:d(a[l++]);break;case 7:l++,o(8),d(a[l-2]);break;case 9:r[l+1]===10?g(a[l++],""):d(a[l++]);break;case 12:{let m=a[l++];o(13);let b=o(14);if(r[l]===10)g(b,m);else if(b.includes(":")){let w=b.split(":");d({stmt:"state",id:w[0],type:"default",description:[m.trim(),w[1]]})}else d({stmt:"state",id:b,type:"default",description:m.trim()});break}case 15:d({stmt:"state",id:a[l++],type:"fork"});break;case 16:d({stmt:"state",id:a[l++],type:"join"});break;case 17:d({stmt:"state",id:a[l++],type:"choice"});break;case 18:l++,d({stmt:"state",id:t.getDividerId(),type:"divider"});break;case 19:{let m=a[l++];if(r[l]===46||r[l]===47){let b=a[l++].trim(),w=o(14).trim();d({stmt:"state",id:w,note:{position:b,text:o(20).trim()}})}else r[l]!==20&&n("'NOTE_TEXT', 'left_of', 'right_of'"),l++,o(13),o(14),d(m);break}case 40:case 41:case 42:case 43:{let m=y4[u-40];l++,t.setDirection(m),d({stmt:"dir",value:m});break}case 21:{l++;let m=o(22).trim();t.setAccTitle(m),d(m);break}case 23:{l++;let m=o(24).trim();t.setAccDescription(m),d(m);break}case 25:{let m=a[l++].trim();t.setAccDescription(m),d(m);break}case 26:{l++;let m=c(),b,w="";r[l]===28?(l++,b=o(27)):(r[l]!==27&&n("'STRING', 'HREF'"),b=a[l++],w=o(27)),o(2),d({stmt:"click",id:m,url:b,tooltip:w});break}case 29:{l++;let m=o(30).trim();d({stmt:"classDef",id:m,classes:o(32).trim()});break}case 34:{l++;let m=o(35).trim();d({stmt:"style",id:m,styleClass:o(36).trim()});break}case 37:{l++;let m=o(38).trim();d({stmt:"applyClass",id:m,styleClass:o(39).trim()});break}case 11:p.length===0&&n(`'$end', ${sc}`),l++,f=p.pop();break;case 0:return p.length>0&&n(`'STRUCT_STOP', ${sc}`),t.setRootDoc(f),f;default:n(p.length>0?`'STRUCT_STOP', ${sc}`:`'$end', ${sc}`)}}}function wm(e){return e==="TB"||e==="BT"}function Ef(e,t,r){let a=e.state?.[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function bm(e){let t=0,r=e.length;for(;t<r&&e.charCodeAt(t)===34;)t++;for(;r>t&&e.charCodeAt(r-1)===34;)r--;return e.slice(t,r)}function $m(e,t,r){return e<t?t:e>r?r:e}function lc(e,t,r,a,i){return`<rect x="${h(e)}" y="${h(t)}" width="${h(r)}" height="${h(a)}"${i}/>`}function oc(e,t,r,a){let i=Ut(0,0);return i.isGroup=!0,i.dir=e,i.padX=t,i.padTop=r,i.padBottom=a,i}function S4(e,t,r){return jr(e.direction)?Bt(r,a=>km(e,t,r,a)):km(e,t,r,!1)}function km(e,t,r,a){let i=e.graph,s=r.fontSize??16,l=Math.round(s*.875),n=r.measurer??et(r.fontFamily),o=Ef(t,"wrappingWidth",200),c=r.padding??8,f=r.icons,p=a?"TB":br(e.direction),d=ze(void 0,!1,n,s,0),g=(ee,te,fe,ye=0)=>ze(ee,!0,n,te,fe,ye),u=new Map,m=[],b=[],w=(ee,te,fe)=>(m.push({node:ee,kind:te,style:void 0,label:d,lines:[],w:0,h:0,titleH:0}),fe&&b.push(fe),m.length-1);for(let ee of i.nodes){if(ee.shape==="noteGroup")continue;let te=ee.isGroup?ee.shape==="divider"?9:8:v4.get(ee.shape)??0;u.set(ee.id,w(ee,te,void 0))}let v=m.length,k=[];for(let ee=0;ee<v;ee++){let te=m[ee].node.parentId,fe=te===void 0?void 0:u.get(te);k.push(fe!==void 0&&fe!==ee&&m[fe].node.isGroup?fe:-1)}{let ee=[];for(let pe=0;pe<v;pe++)ee.push([]);let te=[],fe=new Uint8Array(v);for(let pe=0;pe<v;pe++)k[pe]===-1?(fe[pe]=1,te.push(pe)):ee[k[pe]].push(pe);let ye=0,le=()=>{for(;ye<te.length;ye++)for(let pe of ee[te[ye]])fe[pe]||(fe[pe]=1,te.push(pe))};le();let we=new Int32Array(v).fill(-1);for(let pe=0;pe<v;pe++){if(fe[pe])continue;let ge=pe;for(;we[ge]!==pe;)we[ge]=pe,ge=k[ge];k[ge]=-1,fe[ge]=1,te.push(ge),le()}}let L=new Int32Array(v).fill(-1);for(let ee=0;ee<v;ee++){let te=m[ee].node.noteFor,fe=te===void 0?void 0:u.get(te);fe!==void 0&&(L[ee]=fe,k[ee]=k[fe])}let I=ee=>br(m[ee].node.dir),N=ee=>wm(k[ee]===-1?p:I(k[ee])),O=new Int32Array(v),W=new Uint8Array(v),U=new Array(v).fill(1/0),_=0,j=new Int32Array(2*v);for(let ee of i.edges){let te=u.get(ee.start),fe=u.get(ee.end);if(!(te===void 0||fe===void 0)){if(ee.pattern==="dashed"){W[m[te].kind===7?fe:te]=1;continue}O[te]=Math.max(O[te],++j[2*te]),O[fe]=Math.max(O[fe],++j[2*fe+1]),U[te]===1/0&&(U[te]=_++),U[fe]===1/0&&(U[fe]=_++)}}for(let ee=0;ee<v;ee++){let te=m[ee],fe=te.node,ye=vt(fe.cssStyles.length>0?fe.cssCompiledStyles.concat(fe.cssStyles):fe.cssCompiledStyles),le=(ye.bold?1:0)|(ye.italic?2:0),we=ye.fontSize??s;te.style=ye;let pe;switch(te.kind){case 8:te.label=g(fe.label,we,4e3,le),te.titleH=te.label.height>0?te.label.height+12:0,pe=oc(I(ee),Js,te.titleH+Js,Js),pe.minW=te.label.width+2*Js;break;case 9:pe=oc(I(ee),Mf,Mf,Mf);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 ge=$m(40*O[ee]+16,72,320);te.w=N(ee)?ge:ym,te.h=N(ee)?ym:ge;break}case 10:break;case 7:te.label=g(fe.label,l,Math.max(o,M4)),te.w=te.label.width+24,te.h=te.label.height+16;break;default:{te.label=g(fe.label,we,o,le);let ge=te.label.width,Ae=te.label.height+2*gm;if(te.kind===1){Ae+=14;for(let Se of fe.description){let oe=g(Se===""?" ":Se,l,o,le);te.lines.push(oe),oe.width>ge&&(ge=oe.width),Ae+=oe.height}}te.w=Math.max(ge+2*k4,56),te.h=Ae}}pe??(pe=Ut(te.w,te.h)),(te.kind===0||te.kind===1)&&(pe.span=(N(ee)?te.w:te.h)-24),b.push(pe)}let Z=[],H=[],z=[],C=new Int32Array(v),S=new Float64Array(v),$=new Float64Array(v),y=new Map,E=(ee,te)=>{if(!b[ee].isGroup)return!1;for(let fe=k[te];fe!==-1;fe=k[fe])if(fe===ee)return!0;return!1},x=(ee,te)=>(y.set(Z.length,ee),U.push(te?-1:1/0),w(void 0,10,Ut(0,0,ee)));for(let ee of i.edges){let te=u.get(ee.start),fe=u.get(ee.end);if(te===void 0||fe===void 0)continue;let ye=g(ee.label,l,o),le=ye.width>0?ye.width+12:0;te===fe?(C[te]++,S[te]=Math.max(S[te],le),$[te]+=ye.height):E(te,fe)?te=x(te,!0):E(fe,te)&&(fe=x(fe,!1)),z.push(ee),H.push(ye),Z.push({src:te,dst:fe,minlen:1,labelW:le,labelH:ye.height>0?ye.height+4:0,route:[],labelX:0,labelY:0})}for(let ee=0;ee<v;ee++){if(L[ee]!==-1)continue;let te=b[ee],fe=0;if(C[ee]>0){let le=Af+(C[ee]-1)*8;fe=N(ee)?le+S[ee]:le*.75+4+$[ee],te.isGroup||(N(ee)?(te.w+=2*fe,te.h=Math.max(te.h,$[ee])):(te.h+=2*fe,te.w=Math.max(te.w,S[ee])),fe=0)}if(!W[ee]&&fe===0){te.parent=k[ee];continue}let ye=N(ee)?oc("LR",fe,0,0):oc("TB",0,fe,fe);ye.parent=k[ee],U.push(U[ee]),b[ee].parent=w(void 0,10,ye)}for(let ee=0;ee<v;ee++)L[ee]!==-1&&(b[ee].parent=b[L[ee]].parent);{let ee=[];for(let pe=0;pe<b.length;pe++)ee.push([]);let te=[];for(let pe=0;pe<b.length;pe++){let ge=b[pe].parent;ge>=0?ee[ge].push(pe):te.push(pe)}let fe=pe=>m[pe].kind===2?0:1,ye=(pe,ge)=>fe(pe)-fe(ge)||(U[pe]===U[ge]?0:U[pe]<U[ge]?-1:1)||pe-ge,le=0,we=te.sort(ye).reverse();for(;we.length>0;){let pe=we.pop();b[pe].seq=le++;let ge=ee[pe].sort(ye);for(let Ae=ge.length-1;Ae>=0;Ae--)we.push(ge[Ae])}}let T=Gr(b,Z,p,{nodeSep:Ef(t,"nodeSpacing",w4),edgeSep:b4,rankSep:Ef(t,"rankSpacing",$4),portSep:20,headRoom:gt("arrow_point")}),A=Math.ceil(T.width+2*c),M=Math.ceil(T.height+2*c),Y=[],B=new Map;for(let ee of Z){let te=ee.route;for(let fe=3;fe<te.length-3;fe+=3){let ye=Math.round(te[fe+1]),le=B.get(ye);le?le.push(te[fe]):B.set(ye,[te[fe]])}}let q=[];for(let ee=0;ee<b.length;ee++)q.push([]);let D=[];for(let ee=0;ee<b.length;ee++){let te=b[ee].parent;te>=0?q[te].push(ee):D.push(ee)}let R=D.slice();for(let ee=0;ee<D.length;ee++)for(let te of q[D[ee]])D.push(te);let P="",G="",X="",Q="",J=(ee,te,fe,ye,le)=>{let we=ee.filter(Ae=>m[Ae].kind===9);if(we.length<2)return;let pe=(Ae,Se)=>Se?b[Ae].x-b[Ae].w/2:b[Ae].y-b[Ae].h/2,ge=(Ae,Se)=>Se?b[Ae].x+b[Ae].w/2:b[Ae].y+b[Ae].h/2;for(let Ae of[!0,!1]){let Se=we.slice().sort((ue,xe)=>pe(ue,Ae)-pe(xe,Ae)||ue-xe),oe=!0;for(let ue=1;ue<Se.length;ue++)ge(Se[ue-1],Ae)>pe(Se[ue],Ae)+.5&&(oe=!1);if(oe){for(let ue=1;ue<Se.length;ue++){let xe=h((ge(Se[ue-1],Ae)+pe(Se[ue],Ae))/2+c);G+=`<path class="pele-divider" d="M${Ae?`${xe},${h(fe)}V${h(le)}`:`${h(te)},${xe}H${h(ye)}`}"/>`}return}}for(let Ae of we){let Se=b[Ae];G+=lc(Se.x-Se.w/2+c,Se.y-Se.h/2+c,Se.w,Se.h,` class="pele-divider" rx="${vf}"`)}};J(R,c/2,c/2,A-c/2,M-c/2);for(let ee of D){let te=m[ee],fe=te.node,ye=te.style;if(fe===void 0||ye===void 0||te.kind>=9)continue;let le=b[ee],we=le.x+c,pe=le.y+c,ge=te.w,Ae=te.h,Se=` class="pele-label"${ye.text}`,oe;switch(te.kind){case 8:{let Ie=we-le.w/2,Le=pe-le.h/2;oe=lc(Ie,Le,le.w,le.h,` rx="${vf}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ye.shape}`),te.titleH>0&&(oe+=`<path d="M${h(Ie)},${h(Le+te.titleH)}H${h(Ie+le.w)}"${nc}${ye.line}/>`+Re(te.label,T4(le,te.label.width,B)+c,Le+te.titleH/2,` class="pele-cluster-label"${ye.text}`,f)),J(q[ee],Ie,Le+te.titleH,Ie+le.w,Le+le.h);break}case 2:oe=`<circle r="7" fill="var(--_l)"${ye.shape}/>`;break;case 3:oe=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${ye.line}/><circle r="5" fill="var(--_l)"${ye.shape}/>`;break;case 4:oe=`<polygon points="0,${h(-Ae/2)} ${h(ge/2)},0 0,${h(Ae/2)} ${h(-ge/2)},0"${xm}${ye.shape}/>`;break;case 5:case 6:oe=lc(-ge/2,-Ae/2,ge,Ae,` rx="2" fill="var(--_l)"${ye.shape}`);break;case 7:{let Ie=h(ge/2),Le=h(Ae/2),We=h(ge/2-mm),he=h(mm-Ae/2);oe=`<path d="M-${Ie},-${Le}H${We}L${Ie},${he}V${Le}H-${Ie}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${We},-${Le}V${he}H${Ie}"${nc}/>`+Re(te.label,0,0,` class="pele-label" font-size="${l}" fill="var(--_m)"`,f);break}default:{if(oe=lc(-ge/2,-Ae/2,ge,Ae,` rx="${h(Math.min(vf,Ae/2))}"${xm}${ye.shape}`),te.kind===0){oe+=Re(te.label,0,0,Se,f);break}let Ie=gm-Ae/2+te.label.height;oe+=`<path d="M${h(-ge/2)},${h(Ie+6)}H${h(ge/2)}"${nc}${ye.line}/>`+Re(te.label,0,Ie-te.label.height/2,Se,f),Ie+=14;for(let Le of te.lines)oe+=Re(Le,0,Ie+Le.height/2,` class="pele-state-description" font-size="${l}"${ye.text}`,f),Ie+=Le.height}}let ue=e.links.get(fe.id);if(ue){let Ie=At(bm(ue.tooltip));Ie&&(oe=`<title>${Xe(Ie)}</title>`+oe),oe=ua(oe,Ta(bm(ue.url)),fe.id,Y,r,' target="_blank"')}let xe=`<g class="${E4[te.kind]}${_t(fe.cssClasses.replace(A4,""))}" data-id="${Oe(fe.id)}"`;te.kind===8?P+=`${xe}>${oe}</g>`:te.kind===7?Q+=`${xe} transform="translate(${h(we)},${h(pe)})">${oe}</g>`:X+=`${xe} transform="translate(${h(we)},${h(pe)})">${oe}</g>`}let F=(ee,te,fe)=>{let ye=b[fe];if(ye.isGroup)return;let le=m[fe],we=le.kind===5||le.kind===6,pe=te===0?3:te-3;for(let ge of[1,0]){let Ae=ge?ye.h:ye.w,Se=ge?le.h:le.w,oe=ge?le.w:le.h,ue=(ge?ye.y:ye.x)+c,xe=(ge?ye.x:ye.y)+c,Ie=ee[te+ge]-ue;if(!(Math.abs(Math.abs(Ie)-Ae/2)>=.5)){ee[te+ge]-=Math.sign(Ie)*(Ae-Se)/2,we&&oe>Se&&(ee[te+1-ge]=$m(ee[pe+1-ge],xe-oe/2+6,xe+oe/2-6));return}}},K=ko();for(let ee=0;ee<Z.length;ee++){let te=Z[ee];te.src===te.dst||te.route.length<6||z[ee].pattern==="dashed"||K.add(te.dst,ga(te.route,te.route.length-3,b[te.dst]),"arrow_point")}let re="",ne="",de=new Int32Array(v),ie=new Float64Array(v);for(let ee=0;ee<Z.length;ee++){let te=Z[ee],fe=z[ee],ye=H[ee],le=fe.pattern==="dashed",we=le?"none":"arrow_point",pe;if(te.src===te.dst){let ge=b[te.src],Ae=m[te.src],Se=de[te.src]++,oe=N(te.src),ue=ge.isGroup?ge.w:Ae.w,xe=ge.isGroup?ge.h:Ae.h,Ie=(oe?ue:xe)/2,Le=Math.max(Math.min((oe?xe:ue)/2-4,8+Se*6),2),We=Af+Se*8,he=gt(we)/(Math.hypot(We,Le)||1),ke=(Pe,V)=>ge.x+c+(oe?Ie+Pe:-V),Ce=(Pe,V)=>ge.y+c+(oe?V:Ie+Pe),be=(Pe,V)=>`${h(ke(Pe,V))},${h(Ce(Pe,V))}`;pe={d:`M${be(0,-Le)}C${be(We,-2*Le)} ${be(We,2*Le)} ${be(We*he,Le+Le*he)}`,sx:0,sy:0,sdx:0,sdy:0,ex:ke(0,Le),ey:Ce(0,Le),edx:ke(-We,-Le)-ke(0,0),edy:Ce(-We,-Le)-Ce(0,0)};let Me=Math.hypot(pe.edx,pe.edy)||1;pe.edx/=Me,pe.edy/=Me;let Ne=Af+(C[te.src]-1)*8,Be=ie[te.src]+ye.height/2;ie[te.src]+=ye.height,te.labelX=oe?ge.x+Ie+Ne+4+te.labelW/2:ge.x,te.labelY=oe?ge.y-$[te.src]/2+Be:ge.y+Ie+Ne*.75+4+Be}else{let ge=te.route.slice(),Ae=K.of(te.src,ga(ge,0,b[te.src])),Se=K.of(te.dst,ga(ge,ge.length-3,b[te.dst]));for(let ue=0;ue<ge.length;ue+=3)ge[ue]+=c,ge[ue+1]+=c;F(ge,0,te.src),F(ge,ge.length-3,te.dst);let oe=y.get(ee);if(oe!==void 0&&ge.length>=6){let ue=b[oe],xe=m[te.src].kind===10,Ie=xe?0:ge.length-3,Le=(ue.dir==="TB"||ue.dir==="LR")===xe,We=wm(ue.dir)?[ge[Ie],ue.y+c+(Le?m[oe].titleH-ue.h/2:ue.h/2),0]:[ue.x+c+(Le?-ue.w/2:ue.w/2),ge[Ie+1],1];ge=xe?We.concat(ge):ge.concat(We)}pe=zr(ge,void 0,0,gt(we),Ae,Se)}if(re+=`<g class="pele-edge ${le?'pele-note-edge" stroke="var(--_b)" stroke-dasharray="3 4':"pele-transition"}" data-id="${Oe(fe.id)}"><path d="${pe.d}"/>`+bt(we,pe.ex,pe.ey,pe.edx,pe.edy,"var(--_l)")+"</g>",ye.width>0){let ge=te.labelX+c,Ae=te.labelY+c;ne+=wr(fe.id,ye,ge,Ae,"",f)}}let se=So(e.title,n,s,c,A,M,(P?`<g class="pele-clusters">${P}</g>`:"")+(G?`<g class="pele-dividers" stroke-dasharray="4 4"${nc}>${G}</g>`:"")+(re?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${re}</g>`:"")+(ne?`<g class="pele-edge-labels" font-size="${l}">${ne}</g>`:"")+`<g class="pele-nodes">${X}${Q}</g>`);return{svg:Je("state",se.width,se.height,s,r,e,se.content),width:se.width,height:se.height,links:Y}}function T4(e,t,r){let a=r.get(Math.round(e.y-e.h/2));if(a===void 0||t===0)return e.x;let i=e.x-e.w/2,s=t/2,l=e.x,n=-1;for(let o of[e.x,i+Js+s,i+e.w-Js-s]){let c=1/0;for(let f of a)f>i&&f<i+e.w&&(c=Math.min(c,Math.abs(f-o)-s));if(c>=6)return o;c>n+.5&&(n=c,l=o)}return l}var h4,um,d4,f4,p4,u4,g4,y4,sc,w4,b4,$4,Js,Mf,k4,gm,Af,mm,M4,vf,ym,xm,nc,A4,v4,E4,Mm,Am=Ve(()=>{Ei();Ea();hi();Ti();tr();zt();pr();ut();wt();h4=class{constructor(){ce(this,"type","state");ce(this,"rootDoc",[]);ce(this,"states",new Map);ce(this,"relations",[]);ce(this,"classes",new Map);ce(this,"links",new Map);ce(this,"graph",{nodes:[],edges:[]});ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"dividerCount",0)}get direction(){let e="TB";for(let t of this.rootDoc)typeof t!="string"&&t.stmt==="dir"&&(e=t.value);return e}setRootDoc(e){this.rootDoc=e,this.translate(),this.extract(e)}extract(e){this.states=new Map,this.relations=[],this.classes=new Map;let t=Array.isArray(e)?e:e.doc;for(let r of t)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 a=r.styleClass.split(",").map(i=>i.replace(/;/g,"").trim());for(let i of this.named(r.id.trim()))i.styles=a.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=c4(t,this.states,this.classes)}translate(){let e=[["root",{stmt:"root",id:"root",doc:this.rootDoc},!0]];for(;e.length>0;){let[t,r,a]=e.pop();if(typeof r=="string")continue;if(r.stmt==="relation"){e.push([t,r.state2,!1],[t,r.state1,!0]);continue}if(r.stmt==="state")r.id==="[*]"?(r.id=t+(a?"_start":"_end"),r.start=a):r.id=r.id.trim();else if(r.stmt!=="root")continue;if(!r.doc)continue;let i=[],s=[];for(let l of r.doc)typeof l!="string"&&l.stmt==="state"&&l.type==="divider"&&!l.doc?(i.push({...l,doc:s}),s=[]):s.push(l);i.length>0&&(s.length>0&&i.push({stmt:"state",id:this.getDividerId(),type:"divider",doc:s}),r.doc=i);for(let l=r.doc.length-1;l>=0;l--)e.push([r.id,r.doc[l],!0])}}addState(e,t="default",r,a,i,s){let l=e.trim(),n=this.states.get(l);if(n?(n.doc||(n.doc=r),n.type||(n.type=t)):(n={stmt:"state",id:l,descriptions:[],type:t,doc:r,note:i,classes:[],styles:[],textStyles:[]},this.states.set(l,n)),a)for(let o of Array.isArray(a)?a:[a])this.addDescription(l,o.trim());if(i&&(n.note=i),s)for(let o of s)this.setCssClass(l,o.trim())}getState(e){return this.states.get(e)}addLink(e,t,r){this.links.set(e,{url:t,tooltip:r})}addRelation(e,t,r=""){for(let a of[e,t])this.addState(a.id,a.type,a.doc,a.description,a.note,a.classes);this.relations.push({id1:e.id.trim(),id2:t.id.trim(),relationTitle:r})}addDescription(e,t){this.states.get(e)?.descriptions?.push(t.startsWith(":")?t.replace(":","").trim():t)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(e,t=""){let r=this.classes.get(e);if(r||(r={id:e,styles:[],textStyles:[]},this.classes.set(e,r)),!!t)for(let a of t.split(",")){let i=a.replace(";","").trim();a.includes("color")&&r.textStyles.push(i.replace("fill","bgFill").replace("color","fill")),r.styles.push(i)}}setCssClass(e,t){for(let r of this.named(e))r.classes?.push(t)}getDirection(){for(let e of this.rootDoc)if(typeof e!="string"&&e.stmt==="dir")return e.value;return"TB"}setDirection(e){for(let t of this.rootDoc)if(typeof t!="string"&&t.stmt==="dir"){t.value=e;return}this.rootDoc.unshift({stmt:"dir",value:e})}trimColon(e){return e.startsWith(":")?e.slice(1).trim():e.trim()}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
77
|
+
`)}named(e){let t=[];for(let r of e.split(",")){let a=this.states.get(r);a||(this.addState(r),a=this.states.get(r.trim())),a&&t.push(a)}return t}},um=["$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"],d4=/direction/gi,f4=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,p4=/[\n\r\u2028\u2029]/g,u4=/%%/g,g4=/\{/g;y4=["TB","BT","RL","LR"],sc="'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'";w4=40,b4=16,$4=44,Js=16,Mf=10,k4=16,gm=10,Af=26,mm=8,M4=320,vf=10,ym=8,xm=' fill="var(--_s)" stroke="var(--_b)"',nc=' fill="none" stroke="var(--_b)"',A4=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g,v4=new Map([["rectWithTitle",1],["stateStart",2],["stateEnd",3],["choice",4],["fork",5],["join",6],["note",7],["divider",10]]),E4=["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"];Mm={type:"state",math:!0,parse(e,t,r){let a=new h4;return r&&(a.title=r),x4(e,a),a},render:S4}});var vm={};Ct(vm,{state:()=>Mm});var Em=Ve(()=>{Am()});function wl(e){return!Number.isNaN(e.getTime())}function na(e,t){let r=String(e);return r.length>=t?r:"0".repeat(t-r.length)+r}function Wm(e){let t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}function If(e){let t=-Math.round(e.getTimezoneOffset()/15)*15;return t===0?0:t}function Sm(e){let t=If(e),r=Math.abs(t);return(t>=0?"+":"-")+na(Math.floor(r/60),2)+":"+na(r%60,2)}function Bm(e){return e.getDay()||7}function Oi(e,t){let r=new Date(e);return r.setDate(r.getDate()+t),r}function C4(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t.getDate()}function Tm(e,t){let r=new Date(e);return r.setDate(1),t(r),r.setDate(Math.min(e.getDate(),C4(r))),r}function Hm(e,t,r){switch(r){case"M":return Tm(e,a=>a.setMonth(e.getMonth()+t));case"y":return Tm(e,a=>a.setFullYear(e.getFullYear()+t));case"d":return Oi(e,Math.round(t));case"w":return Oi(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 Ym(e){return Oi(e,4-Bm(e))}function Cm(e){let t=Ym(e),r=new Date(t.getFullYear(),0,1),a=Bm(r),i=Oi(r,4-a+(a>4?7:0)),s=(If(i)-If(t))*6e4,l=(t.getTime()-i.getTime()-s)/6048e5;return(l<0?Math.ceil(l)||0:Math.floor(l))+1}function Um(e,t){if(!wl(e))return"Invalid Date";let r=t||N4;if(r==="YYYY-MM-DD")return qm(e);let a=!1,i=r.replace(_4,l=>{switch(l){case"Q":return String(Math.ceil((e.getMonth()+1)/3));case"Do":return"["+Wm(e.getDate())+"]";case"GGGG":return String(Ym(e).getFullYear());case"W":return String(Cm(e));case"WW":return na(Cm(e),2);case"k":return String(e.getHours()||24);case"kk":return na(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 a=!0,l;default:return l}});if(a)return;let s=e.getHours();return i.replace(I4,(l,n)=>{if(n)return n;switch(l){case"YY":return String(e.getFullYear()).slice(-2);case"YYYY":return na(e.getFullYear(),4);case"M":return String(e.getMonth()+1);case"MM":return na(e.getMonth()+1,2);case"MMM":return rn[e.getMonth()].slice(0,3);case"MMMM":return rn[e.getMonth()];case"D":return String(e.getDate());case"DD":return na(e.getDate(),2);case"d":return String(e.getDay());case"dd":return cs[e.getDay()].slice(0,2);case"ddd":return cs[e.getDay()].slice(0,3);case"dddd":return cs[e.getDay()];case"H":return String(s);case"HH":return na(s,2);case"h":return String(s%12||12);case"hh":return na(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 na(e.getMinutes(),2);case"s":return String(e.getSeconds());case"ss":return na(e.getSeconds(),2);case"SSS":return na(e.getMilliseconds(),3);case"Z":return Sm(e);default:return Sm(e).replace(":","")}})}function qm(e){let t=e.getFullYear(),r=e.getMonth()+1,a=e.getDate();return(t>=1e3&&t<=9999?t:na(t,4))+(r<10?"-0":"-")+r+(a<10?"-0":"-")+a}function Dr(e){return(t,r)=>(t[e]=+r,!0)}function Rm(e){return(t,r)=>{let a=e.indexOf(r)+1;return a<1?!1:(t.month=a%12||a,!0)}}function F4(e){if(e===Lm)return cc;if(Lm=e,cc=null,/[Ll]/.test(e.replace(L4,"")))return null;let t=e.match(R4);return t?(cc=t.map(r=>z4.get(r)??r.replace(/^\[|\]$/g,"")),cc):null}function W4(e,t,r){if(t==="x"||t==="X")return new Date((t==="X"?1e3:1)*Number(e));let a=F4(t);if(!a)return;let i={},s=e,l=0;for(let u of a){if(typeof u=="string"){l+=u.length;continue}let m=u.re.exec(s.slice(l));if(!m||!u.read(i,m[0]))return;s=s.replace(m[0],"")}i.afternoon!==void 0&&i.hours!==void 0&&(i.afternoon?i.hours<12&&(i.hours+=12):i.hours===12&&(i.hours=0));let n=i.dayGiven||i.day?i.day:!i.year&&!i.month?r.getDate():1,o=i.year||r.getFullYear(),c=0;i.year&&!i.month||(c=i.month>0?i.month-1:r.getMonth());let f=i.hours||0,p=i.minutes||0,d=i.seconds||0,g=i.milliseconds||0;if(i.offset!==void 0)return new Date(Date.UTC(o,c,n,f,p,d,g+i.offset*6e4));if(!i.week)return new Date(o,c,n,f,p,d,g)}function B4(e,t,r){let a=W4(e,t,r);return a&&wl(a)&&Um(a,t)===e?a:void 0}function Gm(e){let t=e===void 0?NaN:+e;return Number.isFinite(t)?t:Date.now()}function eS(e){let t=G4.exec(e.trim());return t?[Number.parseFloat(t[1]),t[2]]:[NaN,"ms"]}function Dm(e,t){let r=new Set(e);for(let a of t.toLowerCase().split(j4))a!==""&&r.add(a);return[...r]}function pS(e){let t=e.length,r=[],a=[],i=[],s=0,l=0,n=(p,d,g)=>{r.push(p),a.push(e.slice(d,g)),i.push(d),l=g},o=p=>(p.lastIndex=l,p.test(e)?p.lastIndex:-1),c=(p,d)=>{let g=e.indexOf(p,d);return g===-1?t:g},f=p=>{let d;switch(p|32){case 97:if((d=o(aS))>=0)return s=1,n(3,l,d),!0;if((d=o(iS))>=0)return s=2,n(5,l,d),!0;if((d=o(sS))>=0)return s=3,l=d,!0;break;case 104:if((d=o(nS))>=0)return s=4,l=d,!0;break;case 99:if((d=o(lS))>=0)return s=5,l=d,!0;if((d=o(oS))>=0)return s=7,l=d,!0;break;case 119:{Sf.lastIndex=l;let u=Sf.exec(e);if(u)return n(22+hS.indexOf(u[1].toLowerCase()),l,Sf.lastIndex),!0;if(Tf.lastIndex=l,u=Tf.exec(e),u)return n(u[1]!==void 0?29:30,l,Tf.lastIndex),!0;break}}let g=fS.get(p|32);if(g){for(let[u,m]of g)if((d=o(u))>=0)return n(m,l,d),!0}return!1};for(;;){if(l>=t){let d=38;switch(s){case 1:d=4;break;case 2:d=6;break;case 3:d=7;break;case 4:d=9;break;case 5:d=10;break;case 6:d=11;break;case 7:d=12;break}n(d,t,t);break}let p=e.charCodeAt(l);switch(s){case 0:{let d=e.charCodeAt(l+1);if(p===37)if(d!==37){let g=c(`
|
|
78
|
+
`,l+1);for(;e.charCodeAt(g)===10;)g++;l=g}else{if(e.charCodeAt(l+2)===123)return n(2,l,l+3),n(1,l,l),{types:r,texts:a,starts:i};l=c(`
|
|
79
|
+
`,l+2)}else if(p!==125&&d===37)l=c(`
|
|
80
|
+
`,l+2);else if(p===10){let g=l+1;for(;e.charCodeAt(g)===10;)g++;n(8,l,g)}else if(Ue(p))for(l++;l<t&&Ue(e.charCodeAt(l));)l++;else{if(f(p))break;if(p>=48&&p<=57&&o(dS)>=0)n(31,l,l+10);else if(p!==58){let g=l+1;for(;g<t;){let u=e.charCodeAt(g);if(u===58||u===10)break;g++}n(35,l,g)}else{let g=l+1;for(;g<t;){let u=e.charCodeAt(g);if(u===35||u===10||u===59)break;g++}n(g>l+1?36:37,l,g)}}break}case 1:case 2:{let d=s===1?4:6;s=0,n(d,l,c(`
|
|
81
|
+
`,l));break}case 3:p===125?(s=0,l++):n(7,l,c("}",l));break;case 4:p===34?(s=0,l++):n(9,l,c('"',l));break;case 5:if(p===40){let d=o(cS);d>=0?(s=0,l=d):(s=6,l++)}else n(10,l,c("(",l));break;case 6:p===41?(s=0,l++):n(11,l,c(")",l));break;case 7:if(Ue(p))s=0,l++;else{let d=l+1;for(;d<t&&!Ue(e.charCodeAt(d));)d++;n(12,l,d)}break}}return r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function gS(e,t){let{types:r,texts:a,starts:i}=pS(e),s=0,l=o=>{let c=r[s];throw it("gantt",e,i[s],`Expecting ${o}, got '${c===0?"1":rS[c]}'`)},n=(o="")=>{uc[r[s]]!==1&&l(Om+o)};for(r[s]!==13&&l("'gantt'"),s++;;){let o=r[s],c=a[s];switch(uc[o]!==1&&l(Om),s++,o){case 38:if(r[s]===0)return;n();break;case 8:break;case 14:n(),t.setDateFormat(c.slice(11));break;case 15:n(),t.enableInclusiveEndDates();break;case 16:n(),t.TopAxis();break;case 17:n(),t.setAxisFormat(c.slice(11));break;case 18:n(),t.setTickInterval(c.slice(13));break;case 20:n(),t.setExcludes(c.slice(9));break;case 19:n(),t.setIncludes(c.slice(9));break;case 21:n(),t.setTodayMarker(c.slice(12));break;case 29:n(),t.setWeekend("friday");break;case 30:n(),t.setWeekend("saturday");break;case 32:n(),t.setDiagramTitle(c.slice(6));break;case 3:{r[s]!==4&&l("'acc_title_value'");let f=a[s++];n(),t.setAccTitle(f.trim());break}case 5:{r[s]!==6&&l("'acc_descr_value'");let f=a[s++];n(),t.setAccDescription(f.trim());break}case 7:n(),t.setAccDescription(c.trim());break;case 34:n(),t.addSection(c.slice(8));break;case 35:{r[s]!==36&&l("'taskData'");let f=a[s++];n(),t.addTask(c,f);break}case 12:{let f,p=null,d;r[s]===10?(f=a[s++],r[s]===11&&(p=a[s++]),r[s]===9?(d=a[s++],n()):n(p===null?", 'callbackargs', 'href'":", 'href'")):r[s]===9?(d=a[s++],r[s]===10?(f=a[s++],r[s]===11?(p=a[s++],n()):n(", 'callbackargs'")):n(", 'callbackname'")):l("'callbackname', 'href'"),f!==void 0&&t.setClickEvent(c,f,p),d!==void 0&&t.setLink(c,d);break}default:n(),t.setWeekday(uS[o-22])}}}function hc(e){e.setHours(0,0,0,0)}function yc(e){return{floor(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),hc(t)},offset:(t,r)=>t.setDate(t.getDate()+r*7),cycle:1/0,ms:$l}}function mc(e,t,r){return Math.floor((+t-+e-(t.getTimezoneOffset()-e.getTimezoneOffset())*mi)/r)}function mS(e,t){return(e%t+t)%t}function dc(e,t,r){let a=e==="week"?yc(r):bl[e];if(t<=1)return a;if(e==="millisecond")return{...a,floor:l=>l.setTime(Math.floor(+l/t)*t),offset:(l,n)=>l.setTime(+l+n*t)};if(e==="year")return{...a,floor(l){l.setFullYear(Math.floor(l.getFullYear()/t)*t),a.floor(l)},offset:(l,n)=>l.setFullYear(l.getFullYear()+n*t)};if(e==="week"){let l=new Date(0);return a.floor(l),{...a,floor(n){a.floor(n),a.offset(n,-mS(mc(l,n,$l),t))},offset:(n,o)=>a.offset(n,o*t)}}let i=a.field,s=l=>i(l)%t===0;return{...a,floor(l){for(a.floor(l);Number.isFinite(+l)&&!s(l);a.floor(l))l.setTime(+l-1)},offset(l,n){for(let o=0;o<n&&Number.isFinite(+l);o++)do a.offset(l,1);while(Number.isFinite(+l)&&!s(l))}}}function jm(e,t,r,a){let i=new Date(t-1);e.floor(i),e.offset(i,1),e.floor(i);let s=[],l=-1/0;for(;+i<=r&&+i>l;){if(s.length>=a)return;l=+i,s.push(l),e.offset(i,1),e.floor(i)}return s}function Pm(e,t,r){let a=(t-e)/Math.max(0,r),i=Math.floor(Math.log10(a)),s=a/Math.pow(10,i),l=s>=Math.sqrt(50)?10:s>=Math.sqrt(10)?5:s>=Math.SQRT2?2:1;return Math.pow(10,i)*l}function yS(e,t,r){let a=(t-e)/r,i=0;for(;i<en.length&&en[i][2]<=a;)i++;let s;if(i===en.length)s=dc("year",Math.max(1,Pm(e/gc,t/gc,r)),0);else if(i===0)s=dc("millisecond",Math.max(Pm(e,t,r),1),0);else{let[l,n]=en[a/en[i-1][2]<en[i][2]/a?i-1:i];s=dc(l,n,0)}return jm(s,e,t,4*r+8)??[]}function bS(e,t,r,a,i){let s=xS.exec(e);if(!s)return;let l=parseInt(s[1],10),n=s[2],o=dc(n,l,Math.max(0,wS.indexOf(t)));if(!((a-r)/(Math.min(l,o.cycle)*o.ms)>i))return jm(o,r,a,i)}function Mr(e,t,r){let a=e<0?"-":"",i=String(a?-e:e);return a+(i.length<r?t.repeat(r-i.length)+i:i)}function Di(e,t){let r=new Date(+e);return t.floor(r),r}function zm(e,t){let r=yc(t),a=Di(e,bl.year);return mc(Di(new Date(+a-1),r),Di(e,r),$l)}function Cf(e){let t=yc(4),r=e.getDay(),a=Di(r>=4||r===0?e:new Date(+e-1),t);return r>=4||r===0||(t.offset(a,1),t.floor(a)),a}function fc(e,t){let r="",a=0,i=e.length;for(let s=0;s<i;s++){if(e.charCodeAt(s)!==37)continue;r+=e.slice(a,s);let l=e.charAt(++s),n=$S.get(l);n!==void 0?l=e.charAt(++s):n=l==="e"?" ":"0",r+=kS(l,t,n),a=s+1}return r+e.slice(a)}function kS(e,t,r){switch(e){case"a":return cs[t.getDay()].slice(0,3);case"A":return cs[t.getDay()];case"b":return rn[t.getMonth()].slice(0,3);case"B":return rn[t.getMonth()];case"c":return fc("%x, %X",t);case"d":case"e":return Mr(t.getDate(),r,2);case"f":return Mr(t.getMilliseconds(),r,3)+"000";case"g":return Mr(Cf(t).getFullYear()%100,r,2);case"G":return Mr(Cf(t).getFullYear()%1e4,r,4);case"H":return Mr(t.getHours(),r,2);case"I":return Mr(t.getHours()%12||12,r,2);case"j":return Mr(1+mc(Di(t,bl.year),Di(t,bl.day),hs),r,3);case"L":return Mr(t.getMilliseconds(),r,3);case"m":return Mr(t.getMonth()+1,r,2);case"M":return Mr(t.getMinutes(),r,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 Mr(t.getSeconds(),r,2);case"u":return String(t.getDay()||7);case"U":return Mr(zm(t,0),r,2);case"V":{let a=Cf(t),i=Di(a,bl.year),s=Di(i,yc(4));return Mr(mc(s,a,$l)+(i.getDay()===4?1:0),r,2)}case"w":return String(t.getDay());case"W":return Mr(zm(t,1),r,2);case"x":return fc("%-m/%-d/%Y",t);case"X":return fc("%-I:%M:%S %p",t);case"y":return Mr(t.getFullYear()%100,r,2);case"Y":return Mr(t.getFullYear()%1e4,r,4);case"Z":{let a=t.getTimezoneOffset(),i=Math.abs(a);return(a>0?"-":"+")+Mr(Math.floor(i/60),"0",2)+Mr(i%60,"0",2)}case"%":return"%";default:return e}}function Xa(e,t,r,a){let i=e.gantt?.[t];return typeof i=="number"&&Number.isFinite(i)?Math.min(a,Math.max(r,i)):void 0}function _f(e,t){let r=e.gantt?.[t];return typeof r=="string"?r:void 0}function ES(e,t){return e.gantt?.[t]===!0}function Fm(e,t,r){let a=ze(e.replace(vS," "),!1,t,r,4e3);return a.lines.length<=1?a:{...a,lines:[a.lines[0]],widths:[a.widths[0]],width:a.widths[0],height:a.lineHeight}}function pc(e){return Number.isFinite(+e.startTime)&&Number.isFinite(+e.endTime)}function SS(e,t,r){let a=e.filter(pc).sort((l,n)=>+l.startTime-+n.startTime||l.order-n.order),i=[];for(let l of a){let n=+l.startTime,o=0;for(;o<i.length&&n<i[o];)o++;i[o]=+l.endTime,r.set(l,t+o)}let s=i.length;for(let l of e)r.has(l)||r.set(l,t+s++);return Math.max(s,1)}function TS(e,t,r){let a=r.fontSize??16,i=r.measurer??et(r.fontFamily),s=r.padding??8,l=Gm(r.now),n=Xa(t,"fontSize",4,72)??Math.round(a*.8125),o=Xa(t,"sectionFontSize",4,72)??n,c=Math.round(a*.75),f=Xa(t,"barHeight",4,400)??Math.round(n*1.85),p=Xa(t,"barGap",0,400)??Math.round(f/4),d=f+p,g=Math.round(Xa(t,"numberSectionStyles",1,1e3)??4),u=e.displayMode==="compact",m=e.topAxis||ES(t,"topAxis"),b=e.getTasks(l),w=b.filter(be=>!be.vert),v=b.filter(be=>be.vert&&pc(be)),k=new Map;for(let be of w)k.has(be.section)||k.set(be.section,k.size);let L=new Map,I=[];if(u){let be=new Map;for(let Me of w){let Ne=be.get(Me.section);Ne?Ne.push(Me):be.set(Me.section,[Me])}for(let[Me,Ne]of be){let Be=SS(Ne,I.length,L);for(let Pe=0;Pe<Be;Pe++)I.push(Me)}}else for(let be of w)L.set(be,I.length),I.push(be.section);let N=I.length,O=1/0,W=-1/0;for(let be of b)pc(be)&&(O=Math.min(O,+be.startTime),W=Math.max(W,+be.endTime));let U=O<=W,_=ze(e.title,!1,i,a,4e3,1),j=_.height>0?_.height+16:0;if(!U){let be=Math.ceil(Math.max(_.width,1)+2*s),Me=Math.ceil(Math.max(_.height,1)+2*s),Ne=Re(_,be/2,s+_.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:Je("gantt",be,Me,a,r,e,Ne),width:be,height:Me,links:[]}}let Z=new Map,H=0;for(let be of k.keys()){let Me=ze(be,!1,i,o,180);Z.set(be,Me),H=Math.max(H,Me.width)}let z=e.axisFormat||(e.dateFormat==="D"?"%d":_f(t,"axisFormat")??"%Y-%m-%d"),C=be=>fc(z,new Date(be)),S=Math.max(i.width(C(O),c,0),i.width(C(W),c,0)),$=s+(Xa(t,"leftPadding",0,2e3)??Math.max(H>0?H+24:0,S/2)),y=Xa(t,"rightPadding",0,2e3)??Math.max(16,S/2),E=_i(r,Xa(t,"useWidth",100,2e4)??MS,280),x=Math.max(AS,E-$-y-s),T=$+x,A=W>O?x/(W-O):0,M=be=>A===0?$+x/2:$+(be-O)*A,Y=Math.round(c*1.75),B=Xa(t,"topPadding",0,2e3),q=Xa(t,"gridLineStartPadding",0,2e3),D=s+j+(m?Y:0),R=Math.max(D,B??0),P=B!==void 0&&q!==void 0?Math.max(0,Math.min(B-q,R-D)):0,G=Math.max(N,1)*d,X=R+G,Q=[],J=T+y;for(let be of w){let Me=Fm(be.task,i,n),Ne=L.get(be);if(!pc(be)){let ae=$+tn+Me.width/2;J=Math.max(J,ae+Me.width/2),Q.push({task:be,label:Me,row:Ne,x0:NaN,x1:NaN,labelX:ae,inside:!1});continue}let Be=M(+be.startTime),Pe=Math.max(M(+(be.renderEndTime??be.endTime)),Be+(be.milestone?0:2));if(be.milestone){let ae=Be+(M(+be.endTime)-Be)/2;Be=ae-f/2,Pe=ae+f/2}let V=!be.milestone&&Me.width+2*tn<=Pe-Be,me=(Be+Pe)/2;if(!V){let ae=Pe+tn+Me.width<=T+y,$e=Be-tn-Me.width>=$;me=ae||!$e?Pe+tn+Me.width/2:Be-tn-Me.width/2,J=Math.max(J,me+Me.width/2)}Q.push({task:be,label:Me,row:Ne,x0:Be,x1:Pe,labelX:me,inside:V})}let F=e.tickInterval||_f(t,"tickInterval")||"",K=e.weekday??_f(t,"weekday")??"sunday",re=Math.max(2,Math.min(10,Math.floor(x/(S+24)))),ne=bS(F,K,O,W,Math.ceil(x/3))??yS(O,W,re),de="",ie="",se="",ee=-1/0,te="",fe=X+Y/2+2,ye=R-P-Y/2-2;for(let be of ne){let Me=M(be);de+=`M${h(Me)},${h(R-P)}V${h(X)}`;let Ne=C(be),Be=i.width(Ne,c,0);if(Me-Be/2<ee+8||Ne===te)continue;ee=Me+Be/2,te=Ne,J=Math.max(J,ee);let Pe=`text-anchor="middle">${Xe(Ne)}</text>`;ie+=`<text x="${h(Me)}" y="${h(fe+c*.35)}" ${Pe}`,m&&(se+=`<text x="${h(Me)}" y="${h(ye+c*.35)}" ${Pe}`)}let le="",we="",pe=[],ge=X+Y+4,Ae=Math.round(n*1.5);for(let be of[...v].sort((Me,Ne)=>+Me.startTime-+Ne.startTime)){let Me=M(+be.startTime),Ne=Fm(be.task,i,n),Be=Math.max(s+Ne.width/2,Me),Pe=0;for(;Pe<pe.length&&Be-Ne.width/2<pe[Pe]+8;)Pe++;pe[Pe]=Be+Ne.width/2,J=Math.max(J,pe[Pe]),le+=`<path class="pele-vert" data-id="${Oe(be.id)}" d="M${h(Me)},${h(R-P)}V${h(X)}"/>`,we+=Re(Ne,Be,ge+Pe*Ae+Ae/2,` class="pele-vert-label" data-id="${Oe(be.id)}"`)}let Se=Math.ceil(Math.max(J,s+_.width)+s),oe=Math.ceil(X+Y+(pe.length>0?4+pe.length*Ae:0)+s),ue="",xe="";for(let be=0;be<N;){let Me=I[be],Ne=be+1;for(;Ne<N&&I[Ne]===Me;)Ne++;let Be=k.get(Me)%g,Pe=R+be*d,V=(Ne-be)*d;(k.size>1||Me!=="")&&(ue+=`<rect class="pele-section pele-section-${Be}" x="0" y="${h(Pe)}" width="${Se}" height="${h(V)}" fill="${Be%2===0?"var(--_s)":"none"}"/>`);let me=Z.get(Me);xe+=Re(me,s+8+me.width/2,Pe+V/2,` class="pele-section-label" data-id="${Oe(Me)}"`,r.icons),be=Ne}let Ie="";if((e.excludes.length>0||e.includes.length>0)&&+Hm(new Date(O),6,"y")>W){let be,Me,Ne=()=>{if(!be||!Me)return;let Be=new Date(be);Be.setHours(0,0,0,0);let Pe=new Date(Me);Pe.setHours(23,59,59,999);let V=Math.max($,M(+Be)),me=Math.min(T,M(+Pe));me>V&&(Ie+=`<rect x="${h(V)}" y="${h(R)}" width="${h(me-V)}" height="${h(G)}"/>`),be=Me=void 0};for(let Be=new Date(O);+Be<=W;Be=Oi(Be,1))e.isInvalidDate(Be)?(be??(be=Be),Me=Be):Ne();Ne()}let Le=[],We="";for(let be of Q){let Me=be.task,Ne=R+be.row*d+d/2,Be=Me.active?"active":Me.done?"done":"",Pe="pele-task";Be&&(Pe+=" pele-"+Be),Me.crit&&(Pe+=" pele-crit"),Me.milestone&&(Pe+=" pele-milestone"),Me.classes.includes("clickable")&&(Pe+=" pele-clickable");let V="",me="";if(Number.isNaN(be.x0))Pe+=" pele-unscheduled",me=' fill="var(--_m)"';else{let ve=Me.crit?qn:"var(--_c)",Te=Be==="done"?'fill="var(--_a)"':Be==="active"?`fill="${ve}" fill-opacity="0.25"`:`fill="${ve}"`,De=`stroke="${Be==="done"&&!Me.crit?"var(--_b)":ve}"`;if(Me.milestone){let _e=(be.x0+be.x1)/2,He=f/2;V=`<path d="M${h(_e)},${h(Ne-He)}L${h(_e+He)},${h(Ne)}L${h(_e)},${h(Ne+He)}L${h(_e-He)},${h(Ne)}Z" ${Te} ${De} stroke-linejoin="round"/>`}else V=`<rect x="${h(be.x0)}" y="${h(Ne-f/2)}" width="${h(be.x1-be.x0)}" height="${h(f)}" ${Te} ${De}${st}/>`;be.inside?me=Be===""?' fill="var(--_bg)"':"":Be==="done"&&(me=' fill="var(--_m)"')}let ae=V+Re(be.label,be.labelX,Ne,` class="pele-label"${me}`),$e=e.links.get(Me.id);$e!==void 0&&(ae=ua(ae,$e,Me.id,Le,r)),We+=`<g class="${Pe}" data-id="${Oe(Me.id)}">${ae}</g>`}let he="";if(e.todayMarker!=="off"&&l>=O&&l<=W&&W>O){let be=M(l),Me=R-P,Ne=e.todayMarker?vt(e.todayMarker.split(",")).line:"";he=`<g class="pele-today"><path d="M${h(be)},${h(Me)}V${h(X)}" fill="none" stroke="var(--_c)" stroke-width="2"${Ne}/>`+(Ne?"":`<path d="M${h(be-4)},${h(Me-5)}H${h(be+4)}L${h(be)},${h(Me+1)}Z" fill="var(--_c)"/>`)+"</g>"}let ke=`M${h($)},${h(X)}H${h(T)}`+(m?`M${h($)},${h(R-P)}H${h(T)}`:""),Ce=Re(_,Se/2,s+_.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ue?`<g class="pele-sections">${ue}</g>`:"")+(Ie?`<g class="pele-excluded" fill="var(--_a)">${Ie}</g>`:"")+`<g class="pele-grid" fill="none"><path d="${de}" stroke="var(--_b)" stroke-dasharray="1 3"/><path d="${ke}" stroke="var(--_b)"/></g>`+(le?`<g class="pele-verts" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-dasharray="4 3">${le}</g>`:"")+he+`<g class="pele-tasks" font-size="${h(n)}">${We}</g><g class="pele-section-labels" font-size="${h(o)}">${xe}</g><g class="pele-axis" font-size="${c}" fill="var(--_m)">${ie}${se}</g>`+(we?`<g class="pele-vert-labels" font-size="${h(n)}">${we}</g>`:"");return{svg:Je("gantt",Se,oe,a,r,e,Ce),width:Se,height:oe,links:Le}}var rn,cs,_4,I4,N4,R4,L4,_m,yl,D4,O4,Ra,P4,Im,xl,Nm,z4,Lm,cc,H4,Y4,U4,q4,G4,j4,V4,X4,K4,Z4,Q4,J4,tS,rS,aS,iS,sS,nS,lS,oS,cS,Sf,hS,Tf,dS,fS,uS,Om,uc,gi,mi,os,hs,$l,Nf,gc,bl,en,xS,wS,$S,MS,AS,tn,vS,Vm,Xm=Ve(()=>{hi();tr();zt();ut();wt();rn=["January","February","March","April","May","June","July","August","September","October","November","December"],cs=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];_4=/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,I4=/\[([^\]]+)]|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,N4="YYYY-MM-DDTHH:mm:ssZ";R4=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,L4=/\[[^\]]+]/g,_m=/\d/,yl=/\d\d/,D4=/\d{3}/,O4=/\d{4}/,Ra=/\d\d?/,P4=/[+-]?\d+/,Im=/[+-]\d\d:?(\d\d)?|Z/,xl=/\d*[^-_:/,()\s\d]+/;Nm=(e,t)=>{if(t==="Z")return e.offset=0,!0;let r=t.match(/([+-]|\d\d)/g),a=+r[1]*60+(+r[2]||0);return e.offset=a===0?0:r[0]==="+"?-a:a,!0};z4=new Map([["A",{re:xl,read:(e,t)=>(e.afternoon=t==="PM",!0)}],["a",{re:xl,read:(e,t)=>(e.afternoon=t==="pm",!0)}],["Q",{re:_m,read:(e,t)=>(e.month=(+t-1)*3+1,!0)}],["S",{re:_m,read:(e,t)=>(e.milliseconds=+t*100,!0)}],["SS",{re:yl,read:(e,t)=>(e.milliseconds=+t*10,!0)}],["SSS",{re:D4,read:(e,t)=>(e.milliseconds=+t,!0)}],["s",{re:Ra,read:Dr("seconds")}],["ss",{re:Ra,read:Dr("seconds")}],["m",{re:Ra,read:Dr("minutes")}],["mm",{re:Ra,read:Dr("minutes")}],["H",{re:Ra,read:Dr("hours")}],["h",{re:Ra,read:Dr("hours")}],["HH",{re:Ra,read:Dr("hours")}],["hh",{re:Ra,read:Dr("hours")}],["D",{re:Ra,read:Dr("day")}],["DD",{re:yl,read:Dr("day")}],["Do",{re:xl,read:(e,t)=>{let r=t.match(/\d+/);if(!r)return!1;e.day=+r[0],e.dayGiven=!0;for(let a=1;a<=31;a++)Wm(a)===t&&(e.day=a);return!0}}],["w",{re:Ra,read:Dr("week")}],["ww",{re:yl,read:Dr("week")}],["M",{re:Ra,read:Dr("month")}],["MM",{re:yl,read:Dr("month")}],["MMM",{re:xl,read:Rm(rn.map(e=>e.slice(0,3)))}],["MMMM",{re:xl,read:Rm(rn)}],["Y",{re:P4,read:Dr("year")}],["YY",{re:yl,read:(e,t)=>(e.year=+t+(+t>68?1900:2e3),!0)}],["YYYY",{re:O4,read:Dr("year")}],["Z",{re:Im,read:Nm}],["ZZ",{re:Im,read:Nm}]]),cc=null;H4=/^[YMDHhmsSZXx\-/.:, T]*$/,Y4=/^\s*(active|done|crit|milestone|vert)\s*$/,U4=/^after\s+([\d\w- ]+)/,q4=/^until\s+([\d\w- ]+)/,G4=/^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/,j4=/[\s,]+/,V4=/^\d+$/,X4=new Set(cs.map(e=>e.toLowerCase())),K4=4e8,Z4=400,Q4=200,J4=400;tS=class{constructor(e={}){ce(this,"type","gantt");ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"dateFormat","");ce(this,"axisFormat","");ce(this,"tickInterval");ce(this,"todayMarker","");ce(this,"includes",[]);ce(this,"excludes",[]);ce(this,"inclusiveEndDates",!1);ce(this,"topAxis",!1);ce(this,"displayMode","");ce(this,"weekday");ce(this,"weekend","saturday");ce(this,"sections",[]);ce(this,"links",new Map);ce(this,"tasks",[]);ce(this,"byId",new Map);ce(this,"currentSection","");ce(this,"taskCount",0);ce(this,"lastOrder",0);ce(this,"lastTaskId");ce(this,"options");ce(this,"now",0);ce(this,"work",0);ce(this,"includeSet",new Set);ce(this,"excludeSet",new Set);ce(this,"excludedDays",[]);ce(this,"datedTokens",!1);this.options=e}setDateFormat(e){this.dateFormat=e}enableInclusiveEndDates(){this.inclusiveEndDates=!0}TopAxis(){this.topAxis=!0}setAxisFormat(e){this.axisFormat=e}setTickInterval(e){this.tickInterval=e}setTodayMarker(e){this.todayMarker=e}setIncludes(e){this.includes=Dm(this.includes,e)}setExcludes(e){this.excludes=Dm(this.excludes,e)}setWeekday(e){this.weekday=e}setWeekend(e){this.weekend=e}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
82
|
+
`)}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t){let r=(t.startsWith(":")?t.slice(1):t).split(","),a={id:"",task:e,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:t,start:void 0,end:""}},i;for(;r.length>0&&(i=Y4.exec(r[0]))!==null;)a[i[1]]=!0,r.shift();if(r.length===0)throw new je(`Task "${e.trim()}" needs a duration or an end date.`,"semantic",{type:"gantt"});if(r.length>3)throw new je(`Task "${e.trim()}" has too many fields. A task takes an id, a start, and an end or duration.`,"semantic",{type:"gantt"});for(let s=0;s<r.length;s++)r[s]=r[s].trim();r.length===3?a.id=r[0]:(this.taskCount++,a.id="task"+this.taskCount),r.length>1&&(a.raw.start=r[r.length-2]),a.raw.end=r[r.length-1],a.vert||(a.order=this.lastOrder++),this.tasks.push(a),this.lastTaskId=a.id,this.byId.set(a.id,a)}setLink(e,t){let r=Ta(t);for(let a of e.split(","))this.byId.has(a)&&this.links.set(a,r);this.setClass(e,"clickable")}setClickEvent(e,t,r){this.setClass(e,"clickable")}setClass(e,t){for(let r of e.split(","))this.byId.get(r)?.classes.push(t)}getTasks(e){this.now=Gm(e),this.work=0,this.includeSet=new Set(this.includes),this.excludeSet=new Set(this.excludes);let t=this.weekend==="friday"?5:this.weekend==="saturday"?6:NaN,r=this.excludeSet.has("weekends");this.excludedDays=cs.map((i,s)=>{let l=s||7;return r&&(l===t||l===t+1)||this.excludeSet.has(i.toLowerCase())}),this.datedTokens=this.includes.length>0||!H4.test(this.dateFormat.trim());for(let i of this.excludes)i!=="weekends"&&!X4.has(i)&&(this.datedTokens=!0);for(let i of this.tasks)i.startTime=i.endTime=void 0,i.renderEndTime=null,i.processed=i.manualEndTime=!1;let a=this.compileTasks();for(let i=0;!a&&i<10;i++)a=this.compileTasks();return this.tasks}isInvalidDate(e){let t=this.excludedDays[e.getDay()];if(!this.datedTokens)return t;let r=this.dateFormat.trim(),a=qm(e),i=a;this.spend(Q4),r!=="YYYY-MM-DD"&&(this.spend(J4+r.length*8),i=Um(e,r));let s=l=>l.has(a)||i!==void 0&&l.has(i);return s(this.includeSet)?!1:t||s(this.excludeSet)}spend(e){if(this.work+=e,this.work>K4)throw new je("The gantt chart takes too much work to schedule.","limit",{type:"gantt"})}parse(e,t){return this.spend((t.length+1)*(e.length+1)),B4(e,t,new Date(this.now))}today(){let e=new Date(this.now);return e.setHours(0,0,0,0),e}warn(e){this.options.warn&&this.options.warn(e())}compileTasks(){let e=!0;for(let t of this.tasks)this.compileTask(t),e=e&&t.processed;return e}compileTask(e){let t=e.raw.start;if(t===void 0){let r=e.prevTaskId===void 0?void 0:this.byId.get(e.prevTaskId);e.startTime=r?r.endTime:this.today()}else{let r=this.getStartDate(t);r&&(e.startTime=r)}e.startTime&&(e.endTime=this.getEndDate(e.startTime,e.raw.end),e.endTime&&(e.processed=!0,e.manualEndTime=this.parse(e.raw.end,"YYYY-MM-DD")!==void 0,this.checkTaskDates(e)))}references(e,t){let r=[],a;for(let i of t.split(" ")){if(i==="")continue;let s=this.byId.get(i);s?r.push(s):(a??(a=[])).push(i)}if(a){let i=a;this.warn(()=>`Gantt: "${e}" refers to task ids that do not exist: ${i.join(", ")}.`)}return r}getStartDate(e){let t=e.trim(),r=this.dateFormat.trim();if((r==="x"||r==="X")&&V4.test(t))return this.checked(new Date(Number(t)),t);let a=U4.exec(t);if(a!==null){let l=this.references("after",a[1]),n;for(let o of l)(!n||o.endTime>n.endTime)&&(n=o);return n?n.endTime:this.today()}let i=this.parse(t,r);if(i)return i;let s=new Date(t);if(!wl(s)||s.getFullYear()<-1e4||s.getFullYear()>1e4)throw new je("Invalid date:"+t,"semantic",{type:"gantt"});return s}checked(e,t){if(!wl(e))throw new je("Invalid date:"+t,"semantic",{type:"gantt"});return e}getEndDate(e,t){let r=t.trim(),a=q4.exec(r);if(a!==null){let c=this.references("until",a[1]),f;for(let p of c)(!f||p.startTime<f.startTime)&&(f=p);return f?f.startTime:this.today()}let i=this.dateFormat.trim(),s=this.parse(r,i);if(s)return this.inclusiveEndDates?Oi(s,1):s;let[l,n]=eS(r);if(Number.isNaN(l))return this.warn(()=>`Gantt: "${r}" is neither a date in the "${i}" format nor a duration such as "3d", so the task gets no duration.`),new Date(e);let o=Hm(e,l,n);return wl(o)?o:new Date(e)}checkTaskDates(e){if(this.excludes.length===0||e.manualEndTime)return;let t=Oi(e.startTime,1),r=new Date(e.endTime),a=+Oi(r,1e4),i=!1,s=null;for(;+t<=+r;){if(this.spend(Z4),i||(s=+r),i=this.isInvalidDate(t),i&&(r.setDate(r.getDate()+1),+r>a))throw new je("Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.","semantic",{type:"gantt"});t.setDate(t.getDate()+1)}e.endTime=r,e.renderEndTime=s===null?null:new Date(s)}},rS=["$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"],aS=/accTitle\s*:\s*/iy,iS=/accDescr\s*:\s*/iy,sS=/accDescr\s*\{\s*/iy,nS=/href\s+"/iy,lS=/call\s+/iy,oS=/click\s+/iy,cS=/\(\s*\)/y,Sf=/weekday\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/iy,hS=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Tf=/weekend\s+(?:(friday)|saturday)\b/iy,dS=/\d\d\d\d-\d\d-\d\d\b/y,fS=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]]]]);uS=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Om="'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'",uc=new Uint8Array(39);for(let e=22;e<=30;e++)uc[e]=1;for(let e of[38,8,14,15,16,17,18,20,19,21,32,3,5,7,34,35,12])uc[e]=1;gi=1e3,mi=60*gi,os=60*mi,hs=24*os,$l=7*hs,Nf=30*hs,gc=365*hs;bl={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*gi),field:e=>e.getUTCSeconds(),cycle:60,ms:gi},minute:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*gi),offset:(e,t)=>e.setTime(+e+t*mi),field:e=>e.getMinutes(),cycle:60,ms:mi},hour:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*gi-e.getMinutes()*mi),offset:(e,t)=>e.setTime(+e+t*os),field:e=>e.getHours(),cycle:24,ms:os},day:{floor:hc,offset:(e,t)=>e.setDate(e.getDate()+t),field:e=>e.getDate()-1,cycle:31,ms:hs},month:{floor(e){e.setDate(1),hc(e)},offset:(e,t)=>e.setMonth(e.getMonth()+t),field:e=>e.getMonth(),cycle:12,ms:Nf},year:{floor(e){e.setMonth(0,1),hc(e)},offset:(e,t)=>e.setFullYear(e.getFullYear()+t),cycle:1/0,ms:gc}};en=[["second",1,gi],["second",5,5*gi],["second",15,15*gi],["second",30,30*gi],["minute",1,mi],["minute",5,5*mi],["minute",15,15*mi],["minute",30,30*mi],["hour",1,os],["hour",3,3*os],["hour",6,6*os],["hour",12,12*os],["day",1,hs],["day",2,2*hs],["week",1,$l],["month",1,Nf],["month",3,3*Nf],["year",1,gc]];xS=/^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/,wS=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];$S=new Map([["-",""],["_"," "],["0","0"]]);MS=800,AS=240,tn=8,vS=/<br\s*\/?>/gi;Vm={type:"gantt",parse(e,t,r){let a=new tS;r&&(a.title=r);let i=t.gantt?.displayMode;return typeof i=="string"&&(a.displayMode=i),gS(e,a),a},render:TS}});var Km={};Ct(Km,{gantt:()=>Vm});var Zm=Ve(()=>{Xm()});function Ka(e){throw new je(e,"semantic",{type:"architecture"})}function _S(e,t){e.accDescr&&(t.accDescr=e.accDescr.replace(/\n\s+/g,`
|
|
83
|
+
`)),e.accTitle&&(t.accTitle=e.accTitle.replace(/^\s+/g,"")),e.title&&(t.title=e.title);for(let r of e.groups)t.addGroup(r);for(let r of e.services)t.addService(r);for(let r of e.junctions)t.addJunction(r);for(let r of e.edges)t.addEdge(r);for(let r of e.alignments)t.addLayoutHint({direction:r.direction,members:[...r.members]})}function Pi(e){return{name:e,pattern:e,longer:[s2]}}function Rf(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 IS(e){let t=new Zt(Gt(e,Qm,"architecture"),Qm,"architecture"),r={$type:"Architecture",groups:[],services:[],junctions:[],edges:[],alignments:[]},a=s=>t.kinds[t.i]===s,i=()=>{if(t.kind!==-1)for(t.kind!==19&&t.fail("a line break or the end of input");t.kind===19;)t.i++};for(;t.kind===19;)t.i++;for(t.expect(0);t.kind!==-1;){switch(t.kind){case 19:t.i++;continue;case 14:r.accDescr=Kt(t.take());break;case 15:r.accTitle=Xt(t.take());break;case 16:r.title=Vt(t.take());break;case 4:{t.i++;let s={$type:"Group",id:t.expect(18)};a(24)&&(s.icon=t.take().slice(1,-1)),a(25)&&(s.title=Rf(t.take())),t.accept(8)&&(s.in=t.expect(18)),r.groups.push(s);break}case 2:{t.i++;let s={$type:"Service",id:t.expect(18)};a(17)?s.iconText=$r(t.take()):a(24)&&(s.icon=t.take().slice(1,-1)),a(25)&&(s.title=Rf(t.take())),t.accept(8)&&(s.in=t.expect(18)),r.services.push(s);break}case 1:{t.i++;let s={$type:"Junction",id:t.expect(18)};t.accept(8)&&(s.in=t.expect(18)),r.junctions.push(s);break}case 18:{let s=t.take(),l=t.accept(12);t.expect(9);let n=t.expect(11),o=t.accept(13),c;t.accept(7)||(a(10)||t.fail("'--' or '-'"),t.i++,c=Rf(t.expect(25)),t.expect(10));let f=t.accept(13),p=t.expect(11);t.expect(9);let d=t.expect(18),g=t.accept(12);r.edges.push({$type:"Edge",lhsId:s,lhsGroup:l,lhsDir:n,lhsInto:o,title:c,rhsInto:f,rhsDir:p,rhsId:d,rhsGroup:g});break}case 5:{t.i++,!a(6)&&!a(3)&&t.fail("'row' or 'column'");let s=t.take(),l=[t.expect(18),t.expect(18)];for(;a(18);)l.push(t.take());r.alignments.push({$type:"Alignment",direction:s,members:l});break}default:t.fail("a group, a service, a junction, an edge, an alignment, a title, or a line break")}i()}return r}function RS(e){let t=NS.get(e);return t===void 0?"":`<path d="${t}" stroke="var(--_fg)" stroke-width="1.5"/>`}function bc(e){return e==="L"?0:e==="R"?1:e==="T"?2:3}function LS(e,t,r,a){let i=e.length,s=t.length,l=s,n=new Map,o=new Map,c=new Int32Array(i+s).fill(l),f=new Int32Array(s+1),p=[];for(let X=0;X<=s;X++)p.push([]);t.forEach((X,Q)=>{o.set(X.id,Q);let J=X.in===void 0?void 0:o.get(X.in);J!==void 0&&J!==Q?(c[i+Q]=J,f[Q]=f[J]+1):f[Q]=1}),e.forEach((X,Q)=>{n.set(X.id,Q);let J=X.in===void 0?void 0:o.get(X.in);J!==void 0&&(c[Q]=J),p[c[Q]].push(Q)});for(let X=0;X<s;X++)p[c[i+X]].push(i+X);let d=[],g=[],u=[],m=[],b=[],w=[],v=new Array(i+s),k=new Array(i+s),L=(X,Q,J,F,K)=>{if(X===Q)return;let re=X,ne=Q,de=c[X],ie=c[Q];for(;de!==ie;)f[de]>=f[ie]?(re=i+de,de=c[re]):(ne=i+ie,ie=c[ne]);let se=d.length;d.push(X),g.push(Q),u.push(J),m.push(F),b.push(re),w.push(ne),(K[re]??(K[re]=[])).push(se),(K[ne]??(K[ne]=[])).push(se)};for(let X of a){let Q=X.direction==="row";for(let J=1;J<X.members.length;J++){let F=n.get(X.members[J-1]),K=n.get(X.members[J]);F!==void 0&&K!==void 0&&L(F,K,Q?1:3,Q?0:2,v)}}for(let X of[!1,!0])for(let Q of r){if(Q.lhsDir===Q.rhsDir!==X)continue;let J=n.get(Q.lhsId),F=n.get(Q.rhsId);J!==void 0&&F!==void 0&&L(J,F,bc(Q.lhsDir),bc(Q.rhsDir),k)}let I=new Int32Array(i+s),N=new Int32Array(i+s),O=new Int32Array(i+s).fill(1),W=new Int32Array(i+s).fill(1),U=new Uint8Array(i+s),_=[],j=new Map,Z=[],H=new Map,z=0,C=0,S=0,$=(X,Q)=>{C=0,S=0;for(let J=X;J!==Q;J=i+c[J])C+=I[J],S+=N[J]},y=(X,Q,J)=>{if(I[X]=Q,N[X]=J,U[X]=1,_.push(X),O[X]*W[X]>Jm){Z.push(X);return}for(let F=J;F<J+W[X];F++)for(let K=Q;K<Q+O[X];K++)j.set((K+wc)*e2+F+wc,X)},E=(X,Q,J,F,K)=>I[X]<Q+F&&Q<I[X]+O[X]&&N[X]<J+K&&J<N[X]+W[X],x=(X,Q,J,F)=>{if(J*F>Jm){for(let K=z;K<_.length;K++)if(E(_[K],X,Q,J,F))return _[K];return-1}for(let K=Q;K<Q+F;K++)for(let re=X;re<X+J;re++){let ne=j.get((re+wc)*e2+K+wc);if(ne!==void 0)return ne}for(let K of Z)if(E(K,X,Q,J,F))return K;return-1},T=(X,Q,J,F,K,re)=>{let ne=`${X},${Q},${J},${F},${K},${re}`,de=H.get(ne)??0;for(;;){let ie=x(X+de*K,Q+de*re,J,F);if(ie<0)break;de=K>0?I[ie]+O[ie]-X:K<0?X+J-I[ie]:re>0?N[ie]+W[ie]-Q:Q+F-N[ie]}return H.set(ne,de),de},A=(X,Q)=>{let J=b[Q]===X,F=J?w[Q]:b[Q];if(U[F])return;let K=J?u[Q]:m[Q],re=J?m[Q]:u[Q];$(J?d[Q]:g[Q],X);let ne=C,de=S;$(J?g[Q]:d[Q],F);let ie=kl[K],se=xc[K],ee=0,te=0,fe=kl[K]+kl[re]===0&&xc[K]+xc[re]===0;K===re?(ie=kl[K]===0?1:0,se=1-ie):fe||(ee=-kl[re],te=-xc[re]);let ye,le;if(ie!==0?(ye=ie>0?I[X]+O[X]:I[X]-O[F],le=N[X]+de+te-S):(le=se>0?N[X]+W[X]:N[X]-W[F],ye=I[X]+ne+ee-C),fe){let we=k[F];if(we!==void 0&&we.length>1){let ue=[];for(let xe of we){let Ie=w[xe]===F,Le=Ie?b[xe]:w[xe];if(!U[Le]||(Ie?u[xe]:m[xe])!==K||(Ie?m[xe]:u[xe])!==re)continue;$(Ie?d[xe]:g[xe],Le);let We=ie!==0?N[Le]+S:I[Le]+C;$(Ie?g[xe]:d[xe],F),ue.push(We-(ie!==0?S:C))}ue.length>1&&(ue.sort((xe,Ie)=>xe-Ie),ie!==0?le=ue[ue.length-1>>1]:ye=ue[ue.length-1>>1])}let pe=ie===0?1:0,ge=1-pe,Ae=T(ye,le,O[F],W[F],pe,ge),Se=Ae===0?0:T(ye,le,O[F],W[F],-pe,-ge),oe=Ae<=Se?Ae:-Se;ye+=pe*oe,le+=ge*oe}else{let we=T(ye,le,O[F],W[F],ie,se);ye+=ie*we,le+=se*we}y(F,ye,le)},M=X=>{let Q=p[X];if(Q.length===0)return;_.length=0;let J=[];for(let we of Q){if(U[we])continue;z=_.length,J.push(z),j.clear(),Z.length=0,H.clear(),y(we,0,0);let pe=z,ge=z,Ae=0;for(;;){if(pe<_.length){let oe=_[pe++],ue=v[oe];if(ue!==void 0)for(let xe of ue)A(oe,xe);continue}if(ge>=_.length)break;let Se=k[_[ge]];if(Se===void 0||Ae>=Se.length){ge++,Ae=0;continue}A(_[ge],Se[Ae++])}}J.push(_.length);let F=J.length-1,K=new Array(F),re=new Array(F),ne=new Array(F),de=new Array(F),ie=0,se=0;for(let we=0;we<F;we++){let pe=1/0,ge=1/0,Ae=-1/0,Se=-1/0;for(let oe=J[we];oe<J[we+1];oe++){let ue=_[oe];pe=Math.min(pe,I[ue]),ge=Math.min(ge,N[ue]),Ae=Math.max(Ae,I[ue]+O[ue]),Se=Math.max(Se,N[ue]+W[ue])}K[we]=pe,re[we]=ge,ne[we]=Ae-pe,de[we]=Se-ge,ie+=ne[we]*de[we],se=Math.max(se,ne[we])}let ee=Math.max(se,Math.ceil(Math.sqrt(ie*2))),te=0,fe=0,ye=0,le=0;for(let we=0;we<F;we++){te>0&&te+ne[we]>ee&&(fe+=ye,te=0,ye=0);for(let pe=J[we];pe<J[we+1];pe++)I[_[pe]]+=te-K[we],N[_[pe]]+=fe-re[we];te+=ne[we],ye=Math.max(ye,de[we]),le=Math.max(le,te)}X<s&&(O[i+X]=le,W[i+X]=fe+ye)};for(let X=s-1;X>=0;X--)M(X);M(l);let Y=new Int32Array(s),B=new Int32Array(s),q=new Int32Array(s),D=new Uint8Array(s);for(let X=0;X<s;X++){let Q=c[i+X];q[X]=Q===l?-1:Q,Y[X]=I[i+X]+(Q===l?0:Y[Q]),B[X]=N[i+X]+(Q===l?0:B[Q]),p[X].length===0&&(D[X]=1)}let R=new Int32Array(i),P=new Int32Array(i),G=new Int32Array(i);for(let X=0;X<i;X++){let Q=c[X];G[X]=Q===l?-1:Q,R[X]=I[X]+(Q===l?0:Y[Q]),P[X]=N[X]+(Q===l?0:B[Q])}return{col:R,row:P,groupCol:Y,groupRow:B,groupCols:O.slice(i),groupRows:W.slice(i),groupParent:q,groupEmpty:D,nodeParent:G}}function Lf(e,t,r,a,i){let s=e.architecture,l=s!==null&&typeof s=="object"&&!Array.isArray(s)?s[t]:void 0;return typeof l=="number"&&Number.isFinite(l)?Math.min(i,Math.max(a,l)):r}function a2(e){let t=new Map;for(let r of e.sort((a,i)=>a-i))t.has(r)||t.set(r,t.size);return t}function i2(e,t,r,a,i){return`<svg class="pele-icon" data-icon="${Oe(e)}" x="${h(t)}" y="${h(r)}" width="${h(a)}" height="${h(a)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??RS(e)}</svg>`}function zS(e,t,r,a){let i=e.lines.length>r;if(!i&&e.width<=t)return e;let s=a.width("\u2026",e.size,0),l=[],n=[],o=0;for(let c=0;c<Math.min(r,e.lines.length);c++){let f=e.lines[c].map(d=>({...d})),p=e.widths[c];if(p>t||i&&c===r-1)for(;;){let d=f[f.length-1];if(d===void 0){f.push({text:"\u2026",style:0,width:s}),p=s;break}let g=p-d.width;if(d.icon===void 0&&g+s<t){let u=0,m=d.text.length;for(;u<m;){let w=u+m+1>>1;g+a.width(d.text.slice(0,w),e.size,d.style)+s<=t?u=w:m=w-1}let b=u>0?d.text.charCodeAt(u-1):0;b>=55296&&b<=56319&&u--,d.text=d.text.slice(0,u).trimEnd()+"\u2026",d.width=a.width(d.text,e.size,d.style),p=g+d.width;break}f.pop(),p=g}l.push(f),n.push(p),o=Math.max(o,p)}return{...e,lines:l,widths:n,width:o,height:l.length*e.lineHeight}}function FS(e,t){let{x:r,y:a,dx:i,dy:s}=e,{x:l,y:n,dx:o,dy:c}=t,f=r+i*Wr,p=a+s*Wr,d=l+o*Wr,g=n+c*Wr;if(i*o+s*c===0){let w=i!==0?l:r,v=i!==0?a:n;return(w-r)*i+(v-a)*s>0&&(w-l)*o+(v-n)*c>0?[r,a,w,v,l,n]:i!==0?[r,a,f,p,f,g,d,g,l,n]:[r,a,f,p,d,p,d,g,l,n]}let u=i!==0,m=u?n-a:l-r;if(i===-o&&s===-c){if((l-r)*i+(n-a)*s>0){if(Math.abs(m)<.5)return[r,a,l,n];if(u){let L=i>0?e.x1:t.x1,I=i>0?t.x0:e.x0,N=L<I?(L+I)/2:(r+l)/2;return[r,a,N,a,N,n,l,n]}let w=s>0?e.y1:t.y1,v=s>0?t.y0:e.y0,k=w<v?(w+v)/2:(a+n)/2;return[r,a,r,k,l,k,l,n]}}else if(Math.abs(m)>=1){if(u){let v=i>0?Math.max(r,l)+Wr:Math.min(r,l)-Wr;return[r,a,v,a,v,n,l,n]}let w=s>0?Math.max(a,n)+Wr:Math.min(a,n)-Wr;return[r,a,r,w,l,w,l,n]}if(u){let w=e.y1+Wr<=t.y0?(e.y1+t.y0)/2:t.y1+Wr<=e.y0?(t.y1+e.y0)/2:Math.max(e.y1,t.y1)+Wr;return[r,a,f,a,f,w,d,w,d,n,l,n]}let b=e.x1+Wr<=t.x0?(e.x1+t.x0)/2:t.x1+Wr<=e.x0?(t.x1+e.x0)/2:Math.max(e.x1,t.x1)+Wr;return[r,a,r,p,b,p,b,g,l,g,l,n]}function WS(e){let t=[e[0],e[1]];for(let r=2;r<e.length;r+=2){let a=e[r],i=e[r+1],s=t.length,l=Math.abs(a-t[s-2])<.01,n=Math.abs(i-t[s-1])<.01;l&&n||(s>=4&&(l&&Math.abs(t[s-4]-t[s-2])<.01||n&&Math.abs(t[s-3]-t[s-1])<.01)?(t[s-2]=a,t[s-1]=i):t.push(a,i))}return t}function BS(e,t,r){let a=e.length/2,i=new Array(a),s=new Array(a);for(let o=0;o<a;o++)i[o]=e[o*2],s[o]=e[o*2+1];let l=(o,c,f)=>{let p=Math.hypot(i[c]-i[o],s[c]-s[o]),d=Math.min(f,Math.max(0,p-1));p>0&&d>0&&(i[o]+=(i[c]-i[o])/p*d,s[o]+=(s[c]-s[o])/p*d)};l(0,1,t),l(a-1,a-2,r);let n=`M${h(i[0])},${h(s[0])}`;for(let o=1;o<a-1;o++){let c=Math.hypot(i[o]-i[o-1],s[o]-s[o-1]),f=Math.hypot(i[o+1]-i[o],s[o+1]-s[o]),p=Math.min(DS,c/2,f/2);if(p<.5){n+=`L${h(i[o])},${h(s[o])}`;continue}let d=i[o]-(i[o]-i[o-1])/c*p,g=s[o]-(s[o]-s[o-1])/c*p,u=i[o]+(i[o+1]-i[o])/f*p,m=s[o]+(s[o+1]-s[o])/f*p;n+=`L${h(d)},${h(g)}Q${h(i[o])},${h(s[o])} ${h(u)},${h(m)}`}return n+`L${h(i[a-1])},${h(s[a-1])}`}function HS(e,t,r){return Nr(r,a=>YS(e,t,r,a))}function YS(e,t,r,a){let i=Lf(t,"iconSize",48,8,512),s=Lf(t,"fontSize",r.fontSize??16,4,128),l=Math.min(Lf(t,"padding",20,0,256),a?12:1/0),n=Math.round(s*.875),o=r.measurer??et(r.fontFamily),c=r.padding??8,f=r.icons,p=i/2,d=[...e.nodes.values()],g=[...e.groups.values()],u=d.length,m=g.length,b=LS(d,g,e.edges,e.layoutHints),w=new Map;d.forEach((ae,$e)=>w.set(ae.id,$e));let v=new Array(u),k=new Float64Array(u),L=new Float64Array(u),I=a?Math.max(i,64):Math.max(i*2.25,96);for(let ae=0;ae<u;ae++){let $e=d[ae],ve=ze($e.type==="service"?$e.title:void 0,!0,o,s,I);v[ae]=ve,k[ae]=Math.max(i,2*Math.ceil(ve.width/2)),L[ae]=i+(ve.height>0?t2+ve.height:0)}let N=[],O=[];for(let ae=0;ae<u;ae++)N.push(b.col[ae]),O.push(b.row[ae]);for(let ae=0;ae<m;ae++)b.groupEmpty[ae]&&(N.push(b.groupCol[ae]),O.push(b.groupRow[ae]));let W=a2(N),U=a2(O),_=W.size,j=U.size,Z=new Float64Array(_),H=new Float64Array(j),z=a?Math.max(24,2*Wr):Math.max(40,Math.round(i*.75)),C=new Float64Array(_).fill(z),S=new Float64Array(j).fill(z),$=new Int32Array(u),y=new Int32Array(u);for(let ae=0;ae<u;ae++){let $e=$[ae]=W.get(b.col[ae]),ve=y[ae]=U.get(b.row[ae]);Z[$e]=Math.max(Z[$e],k[ae]),H[ve]=Math.max(H[ve],L[ae])}for(let ae=0;ae<m;ae++){if(!b.groupEmpty[ae])continue;let $e=W.get(b.groupCol[ae]),ve=U.get(b.groupRow[ae]);Z[$e]=Math.max(Z[$e],i),H[ve]=Math.max(H[ve],p)}let E=e.edges.length,x=new Array(E),T=new Int32Array(E*2);for(let ae=0;ae<E;ae++){let $e=e.edges[ae],ve=T[ae*2]=w.get($e.lhsId)??-1,Te=T[ae*2+1]=w.get($e.rhsId)??-1,De=ze($e.title,!0,o,n,160);if(x[ae]=De,!(De.width===0||ve<0||Te<0)){if($[ve]!==$[Te]){let _e=Math.min($[ve],$[Te]);C[_e]=Math.max(C[_e],Math.ceil(De.width)+28)}else if(Z[$[ve]]=Math.max(Z[$[ve]],2*Math.ceil(De.width/2)+8),y[ve]!==y[Te]){let _e=Math.min(y[ve],y[Te]);S[_e]=Math.max(S[_e],Math.ceil(De.height)+24)}}}let A=new Array(m),M=new Int32Array(m),Y=new Int32Array(m),B=new Int32Array(m),q=new Int32Array(m),D=new Float64Array(m),R=new Float64Array(m),P=new Float64Array(m),G=new Float64Array(m),X=new Float64Array(m),Q=new Float64Array(m),J=new Float64Array(_),F=new Float64Array(_),K=new Float64Array(j),re=new Float64Array(j),ne=Math.round(s*1.25);for(let ae=0;ae<m;ae++){M[ae]=W.get(b.groupCol[ae]),Y[ae]=W.get(b.groupCol[ae]+b.groupCols[ae]-1),B[ae]=U.get(b.groupRow[ae]),q[ae]=U.get(b.groupRow[ae]+b.groupRows[ae]-1);let $e=ze(g[ae].title,!0,o,s,a?Math.max(80,It(r)/2):320);A[ae]=$e;let ve=g[ae].icon?ne:0;X[ae]=$e.width+ve+($e.width>0&&ve>0?6:0),Q[ae]=Math.max($e.height,ve)}for(let ae=m-1;ae>=0;ae--){let $e=l+D[ae],ve=l+R[ae],Te=(Q[ae]>0?Math.max(l,Q[ae]+12):l)+P[ae],De=l+G[ae];if(X[ae]>0){let He=$e+ve;for(let Ee=M[ae];Ee<=Y[ae];Ee++)He+=Z[Ee]+(Ee<Y[ae]?F[Ee]+C[Ee]+J[Ee+1]:0);X[ae]+20>He&&(ve+=Math.ceil(X[ae]+20-He))}D[ae]=$e,R[ae]=ve,P[ae]=Te,G[ae]=De,J[M[ae]]=Math.max(J[M[ae]],$e),F[Y[ae]]=Math.max(F[Y[ae]],ve),K[B[ae]]=Math.max(K[B[ae]],Te),re[q[ae]]=Math.max(re[q[ae]],De);let _e=b.groupParent[ae];_e<0||(M[_e]===M[ae]&&(D[_e]=Math.max(D[_e],$e)),Y[_e]===Y[ae]&&(R[_e]=Math.max(R[_e],ve)),B[_e]===B[ae]&&(P[_e]=Math.max(P[_e],Te)),q[_e]===q[ae]&&(G[_e]=Math.max(G[_e],De)))}let de=new Float64Array(_),ie=new Float64Array(j),se=0;for(let ae=0;ae<_;ae++)de[ae]=se+J[ae],se=de[ae]+Z[ae]+F[ae]+(ae<_-1?C[ae]:0);let ee=0;for(let ae=0;ae<j;ae++)ie[ae]=ee+K[ae],ee=ie[ae]+H[ae]+re[ae]+(ae<j-1?S[ae]:0);let te=0,fe=0,ye=se,le=ee,we=ae=>de[M[ae]]-D[ae],pe=ae=>de[Y[ae]]+Z[Y[ae]]+R[ae],ge=ae=>ie[B[ae]]-P[ae],Ae=ae=>ie[q[ae]]+H[q[ae]]+G[ae],Se=ae=>de[$[ae]]+Z[$[ae]]/2,oe=(ae,$e,ve)=>{let Te=OS[$e],De=PS[$e],_e=Se(ae),He=ie[y[ae]],Ee={x:_e,y:He+p,dx:Te,dy:De,x0:_e-k[ae]/2,y0:He,x1:_e+k[ae]/2,y1:He+L[ae],gap:0,wire:!1};d[ae].type==="junction"?(Ee.x0=Ee.x1=_e,Ee.y0=Ee.y1=Ee.y,Ee.gap=r2):Te!==0?Ee.x=_e+Te*p:Ee.y=De<0?He:He+L[ae]+(v[ae].height>0?2:0);let qe=ve?b.nodeParent[ae]:-1;return qe>=0&&(Ee.x0=we(qe),Ee.x1=pe(qe),Ee.y0=ge(qe),Ee.y1=Ae(qe),Ee.gap=0,Ee.wire=d[ae].type==="junction",Te!==0?Ee.x=Te<0?Ee.x0:Ee.x1:Ee.y=De<0?Ee.y0:Ee.y1),Ee},ue="",xe="",Ie=[],Le=gt("arrow_point");for(let ae=0;ae<E;ae++){let $e=e.edges[ae],ve=T[ae*2],Te=T[ae*2+1];if(ve<0||Te<0)continue;let De=oe(ve,bc($e.lhsDir),$e.lhsGroup),_e=oe(Te,bc($e.rhsDir),$e.rhsGroup);De.x===_e.x&&De.y===_e.y&&De.dx===_e.dx&&(De.x-=8*Math.abs(De.dy),De.y-=8*Math.abs(De.dx),_e.x+=8*Math.abs(De.dy),_e.y+=8*Math.abs(De.dx));let He=FS(De,_e);De.wire&&He.unshift(Se(ve),ie[y[ve]]+p),_e.wire&&He.push(Se(Te),ie[y[Te]]+p);let Ee=WS(He);if(Ee.length<4)continue;let qe=Oe(`${$e.lhsId}-${$e.rhsId}`);ue+=`<g class="pele-edge" data-id="${qe}"><path d="${BS(Ee,$e.lhsInto&&!De.wire?Le+De.gap:0,$e.rhsInto&&!_e.wire?Le+_e.gap:0)}"/>`+($e.lhsInto?bt("arrow_point",De.x+De.dx*De.gap,De.y+De.dy*De.gap,-De.dx,-De.dy,"var(--_l)"):"")+($e.rhsInto?bt("arrow_point",_e.x+_e.dx*_e.gap,_e.y+_e.dy*_e.gap,-_e.dx,-_e.dy,"var(--_l)"):"")+"</g>";let Ge=-1,rt=-1,ct=-1,tt=-1,lt=x[ae];for(let nt=0;nt<Ee.length;nt+=2)te=Math.min(te,Ee[nt]-4),ye=Math.max(ye,Ee[nt]+4),fe=Math.min(fe,Ee[nt+1]-4),le=Math.max(le,Ee[nt+1]+4);for(let nt=0;nt+3<Ee.length;nt+=2){let Wt=Math.abs(Ee[nt+1]-Ee[nt+3])<.01,Tt=Math.abs(Ee[nt]-Ee[nt+2])+Math.abs(Ee[nt+1]-Ee[nt+3]);Wt||Ie.push(Ee[nt],Math.min(Ee[nt+1],Ee[nt+3]),Math.max(Ee[nt+1],Ee[nt+3])),Tt>rt&&(Ge=nt,rt=Tt),Wt&&Tt>tt&&(ct=nt,tt=Tt)}if(lt.width>0){let nt=tt>=lt.width+8?ct:Ge,Wt=(Ee[nt]+Ee[nt+2])/2,Tt=(Ee[nt+1]+Ee[nt+3])/2,kt=lt.width+8,Ft=Math.abs(Ee[nt]-Ee[nt+2])<.01;for(let Ye of[De,_e])Wt+kt/2<=Ye.x0||Wt-kt/2>=Ye.x1||Tt+lt.height/2<=Ye.y0||Tt-lt.height/2>=Ye.y1||(Ft?Wt=Wt>=(Ye.x0+Ye.x1)/2?Ye.x1+kt/2+4:Ye.x0-kt/2-4:Tt=Tt>=(Ye.y0+Ye.y1)/2?Ye.y1+lt.height/2+4:Ye.y0-lt.height/2-4);te=Math.min(te,Wt-kt/2),ye=Math.max(ye,Wt+kt/2),fe=Math.min(fe,Tt-lt.height/2),le=Math.max(le,Tt+lt.height/2),xe+=wr(`${$e.lhsId}-${$e.rhsId}`,lt,Wt,Tt,"",f)}}let We="";for(let ae=0;ae<m;ae++){let $e=g[ae],ve=we(ae),Te=ge(ae),De=pe(ae)-ve,_e=A[ae],He="";if(X[ae]>0){let Ee=Te+Q[ae]+12,qe=[];for(let tt=0;tt<Ie.length;tt+=3)Ie[tt+1]<Ee&&Ie[tt+2]>Te&&Ie[tt]>ve&&Ie[tt]<ve+De&&qe.push(Ie[tt]);qe.sort((tt,lt)=>tt-lt),qe.push(ve+De-4);let Ge=ve+10;for(let tt of qe){if(tt-6-Ge>=X[ae])break;Ge=Math.max(Ge,tt+6)}Ge+X[ae]>ve+De-4&&(Ge=ve+10);let rt=Te+6+Q[ae]/2,ct=Ge;$e.icon&&(He+=i2($e.icon,Ge,rt-ne/2,ne,f),ct+=ne+6),He+=Re(_e,ct+_e.width/2,rt,' class="pele-cluster-label" fill="var(--_m)"',f)}We+=`<g class="pele-cluster" data-id="${Oe($e.id)}"><rect x="${h(ve)}" y="${h(Te)}" width="${h(De)}" height="${h(Ae(ae)-Te)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${st}/>`+He+"</g>"}let he="",ke=i*.5,Ce=Math.max(6,Math.round(s*.75));for(let ae=0;ae<u;ae++){let $e=d[ae],ve=`data-id="${Oe($e.id)}" transform="translate(${h(Se(ae))},${h(ie[y[ae]])})"`;if($e.type==="junction"){he+=`<g class="pele-node pele-junction" ${ve}><circle cy="${h(p)}" r="${r2}" fill="var(--_l)"/></g>`;continue}let Te="";if($e.icon)Te=i2($e.icon,-ke/2,(i-ke)/2,ke,f);else if($e.iconText){let De=ze($e.iconText,!1,o,Ce,i-8),_e=Math.max(1,Math.floor((i-4)/(De.lineHeight||1)));Te=Re(zS(De,i-8,_e,o),0,p,` class="pele-icon-text" font-size="${Ce}"`,f)}he+=`<g class="pele-node pele-service" ${ve}><rect x="${h(-p)}" width="${h(i)}" height="${h(i)}" fill="var(--_s)" stroke="var(--_b)"${st}/>`+Te+Re(v[ae],0,i+t2+v[ae].height/2,' class="pele-label"',f)+"</g>"}let be=ze(e.title,!1,o,s,a?It(r):4e3,1),Me=be.height>0?be.height+12:0,Ne=Math.ceil(Math.max(ye-te,be.width)+2*c),Be=Math.ceil(le-fe+Me+2*c),Pe=Math.round((Ne-(ye-te))/2-te),V=Math.round(c+Me-fe),me=(We?`<g class="pele-clusters">${We}</g>`:"")+(ue?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${ue}</g>`:"")+(xe?`<g class="pele-edge-labels" font-size="${n}">${xe}</g>`:"")+(he?`<g class="pele-nodes">${he}</g>`:"");return{svg:Je("architecture",Ne,Be,s,r,e,Re(be,Ne/2,c+be.height/2,' class="pele-title" font-weight="var(--_tw)"')+(me?`<g transform="translate(${Pe},${V})">${me}</g>`:"")),width:Ne,height:Be,links:[]}}var CS,s2,Qm,NS,kl,xc,Jm,wc,e2,Wr,DS,t2,r2,OS,PS,n2,l2=Ve(()=>{zt();Xr();pr();ut();wt();CS=class{constructor(){ce(this,"type","architecture");ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"nodes",new Map);ce(this,"groups",new Map);ce(this,"edges",[]);ce(this,"layoutHints",[]);ce(this,"registered",new Map)}register(e,t,r){this.registered.has(t)&&Ka(`The ${e} id [${t}] is already in use by another ${this.registered.get(t)}`),r!==void 0&&(t===r&&Ka(`The ${e} [${t}] cannot be placed within itself`),this.registered.has(r)||Ka(`The ${e} [${t}]'s parent does not exist. Please make sure the parent is created before this ${e}`),this.registered.get(r)==="node"&&Ka(`The ${e} [${t}]'s parent is not a group`)),this.registered.set(t,e==="group"?"group":"node")}addService({id:e,icon:t,iconText:r,title:a,in:i}){this.register("service",e,i),this.nodes.set(e,{id:e,type:"service",icon:t,iconText:r,title:a,in:i})}addJunction({id:e,in:t}){this.register("junction",e,t),this.nodes.set(e,{id:e,type:"junction",in:t})}addGroup({id:e,icon:t,title:r,in:a}){this.register("group",e,a),this.groups.set(e,{id:e,icon:t,title:r,in:a})}addEdge({lhsId:e,rhsId:t,lhsDir:r,rhsDir:a,lhsInto:i,rhsInto:s,lhsGroup:l,rhsGroup:n,title:o}){let c=[["left",e,l],["right",t,n]];for(let[p,d]of c)this.registered.has(d)||Ka(`The ${p}-hand id [${d}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[p,d]of c)this.nodes.has(d)||Ka(`The ${p}-hand id [${d}] is a group. Add {group} to a service inside it instead.`);let f=this.nodes.get(e).in;if(f!==void 0&&f===this.nodes.get(t).in)for(let[p,d,g]of c)g&&Ka(`The ${p}-hand id [${d}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);this.edges.push({lhsId:e,lhsDir:r,lhsInto:i,lhsGroup:l,rhsId:t,rhsDir:a,rhsInto:s,rhsGroup:n,title:o})}addLayoutHint(e){e.members.length<2&&Ka(`An align directive requires at least two members; got ${e.members.length}`);let t=new Set;for(let r of e.members)this.registered.get(r)!=="node"&&Ka(`align ${e.direction} references [${r}], which is not a service or junction`),t.has(r)&&Ka(`align ${e.direction} lists [${r}] more than once`),t.add(r);this.layoutHints.push(e)}};s2={name:"ID",pattern:/[\w]([-\w]*\w)?/y};Qm=[Pi("architecture-beta"),Pi("junction"),Pi("service"),Pi("column"),Pi("group"),Pi("align"),Pi("row"),{name:"--",pattern:"--",longer:[jt]},Pi("in"),{name:":",pattern:":"},{name:"-",pattern:"-",longer:[jt]},{name:"ARROW_DIRECTION",pattern:/L|R|T|B/y},{name:"ARROW_GROUP",pattern:/\{group\}/y},{name:"ARROW_INTO",pattern:/<|>/y},ur,rr,ar,Vr,s2,Rr,Lr,jt,nr,lr,{name:"ARCH_ICON",pattern:/\([\w-:]+\)/y},{name:"ARCH_TITLE",pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];NS=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"]]);kl=[-1,1,0,0],xc=[0,0,-1,1];Jm=64,wc=2**25,e2=2**26;Wr=12,DS=6,t2=4,r2=3,OS=[-1,1,0,0],PS=[0,0,-1,1];n2={type:"architecture",parse(e,t,r){let a=new CS;return r&&(a.title=r),_S(IS(e),a),a},render:HS}});var o2={};Ct(o2,{architecture:()=>n2});var c2=Ve(()=>{l2()});function ZS(e){let t=e.length,r=[],a=[],i=[],s=[],l=0,n=0,o=[[],[],[],[]],c=[[],[],[],[]],f=[0,0,0,0],p=!1,d=-1;kc.lastIndex=0;for(let N=kc.exec(e);N!==null;N=kc.exec(e)){let O=N[1]!==void 0?0:N[2]!==void 0?1:N[3]!==void 0?2:3;o[O].push(N.index),c[O].push(kc.lastIndex),p=!0}let g=(N,O,W)=>{r.push(N),a.push(e.slice(O,W)),i.push(O),n=W},u=N=>{s.push(l),l=N},m=()=>{s.length>0&&(l=s.pop())},b=(N,O)=>(N.lastIndex=O,N.test(e)?N.lastIndex:-1),w=N=>{let O=e.indexOf(`
|
|
84
|
+
`,N);return O===-1?t:O},v=()=>{if(d<n){Of.lastIndex=n,d=Of.test(e)?Of.lastIndex-1:t;for(let N=0;N<4;N++){let O=o[N],W=f[N];for(;W<O.length&&O[W]<=d;)W++;f[N]=W}}for(let N=0;N<4;N++){let O=f[N]-1;if(O>=0&&o[N][O]>=n)return g(8+N,n,w(c[N][O])),!0}return!1},k=N=>{let O=N|32;if(O===116&&e.slice(n+1,n+5).toLowerCase()==="itle"&&Ue(e.charCodeAt(n+5))){let W=n+6;for(;W<t;){let U=e.charCodeAt(W);if(U===35||U===10||U===59)break;W++}if(W>n+6)return g(2,n,W),!0}if(O===97&&(e.charCodeAt(n+1)|32)===99&&(e.charCodeAt(n+2)|32)===99){let W;if((W=b(jS,n))>=0)return u(3),g(3,n,W),!0;if((W=b(VS,n))>=0)return u(4),g(5,n,W),!0;if((W=b(XS,n))>=0)return u(5),n=W,!0}if(p&&!Xi(N)&&v())return!0;if(N===10||N===13&&e.charCodeAt(n+1)===10){let W=n;for(;W<t;){let U=e.charCodeAt(W);if(U===10)W++;else if(U===13&&e.charCodeAt(W+1)===10)W+=2;else break}return g(12,n,W),!0}if(Ue(N)){for(n++;n<t&&Ue(e.charCodeAt(n));)n++;return!0}if(N===35||N===37)return n=w(n),!0;if(Qe(N)){let W=n+1;for(;W<t&&Qe(e.charCodeAt(W));)W++;if(W-n<=KS){let U=GS.get(e.slice(n,W).toLowerCase());if(U!==void 0)return(U===46||U===47||U===48)&&u(2),g(U,n,W),!0}for(;W<t;){let U=e.charCodeAt(W);if(U<128&&m2[U]===1)break;W++}return r.push(59),a.push(e.slice(n,W).trim()),i.push(n),n=W,!0}switch(N){case 123:return g(15,n,n+1),!0;case 125:return g(16,n,n+1),!0;case 58:return e.charCodeAt(n+1)===58&&e.charCodeAt(n+2)===58?g(17,n,n+3):g(18,n,n+1),!0;case 60:return e.charCodeAt(n+1)!==45?!1:(g(55,n,n+2),!0);case 45:return e.charCodeAt(n+1)===62?g(56,n,n+2):g(57,n,n+1),!0;case 34:return u(1),n++,!0;case 44:return g(60,n,n+1),!0}return!1},L=N=>{if(Qe(N)){let O=n+1;for(;O<t&&Qe(e.charCodeAt(O));)O++;return g(49,n,O),!0}switch(N){case 58:return g(50,n,n+1),!0;case 59:return g(51,n,n+1),!0;case 37:return g(52,n,n+1),!0;case 45:return g(53,n,n+1),!0;case 35:return g(54,n,n+1),!0;case 32:return n++,!0;case 34:return u(1),n++,!0;case 10:return m(),n++,!0;case 44:return g(60,n,n+1),!0}return!1};for(;n<t;){let N=e.charCodeAt(n),O=!0;switch(l){case 0:O=k(N);break;case 2:O=L(N);break;case 1:if(N===34)m(),n++;else{let W=e.indexOf('"',n);g(58,n,W===-1?t:W)}break;case 3:m(),g(4,n,w(n));break;case 4:m(),g(6,n,w(n));break;case 5:if(N===125)m(),n++;else{let W=e.indexOf("}",n);g(7,n,W===-1?t:W)}break}if(!O)return r.push(1),a.push(""),i.push(n),{types:r,texts:a,starts:i}}let I=l===0?13:l===1?58:l===3?4:l===4?6:l===5?7:-1;return I!==-1&&g(I,t,t),g(0,t,t),{types:r,texts:a,starts:i}}function d2(e){return e===49||e===50||e===54||e===53||e===51}function JS(e,t){let{types:r,texts:a,starts:i}=ZS(e),s=0,l=[],n=[],o=(w,v=w,...k)=>{let L=r[s];if(L===1)throw it("requirement",e,i[s],"",!0);for(let N=v;N>=w;N--)k.unshift(N);let I=k.map(N=>`'${h2[N]}'`).join(", ");throw it("requirement",e,i[s],`Expecting ${I}, got '${h2[L]}'`)},c=w=>(r[s]!==w&&o(w),a[s++]),f=(w,v)=>{let k=r[s];return(k<w||k>v)&&o(w,v),s++,QS[k-23]},p=()=>{let w=r[s];return w!==59&&w!==58&&o(58,59),a[s++]},d=()=>{let w=r[s];if(w===3)s++,t.setAccTitle(c(4).trim());else if(w===5)s++,t.setAccDescription(c(6).trim());else if(w===7)t.setAccDescription(a[s++].trim());else return!1;return!0},g=()=>{let w=[];for(;;){let v=r[s];if(v!==49&&v!==59&&v!==58&&o(58,59,49),w.push(a[s++]),r[s]!==60)return w;s++}},u=()=>{let w=[];for(;;){d2(r[s])||o(49,51,53,54);let v=a[s++];for(;d2(r[s]);)v+=a[s++];if(w.push(v),r[s]!==60)return w;s++}},m=()=>{let w;return r[s]===17?(s++,w=g(),c(15)):r[s]===15?s++:o(15,15,17),c(12),w},b=w=>{for(l.length=0,n.length=0;;){let v=r[s];if(v===16){s++;break}if(v===12){s++;continue}(w?v<19||v>22:v!==44&&v!==45)&&(w&&o(19,22,12,16),o(44,45,12,16)),s++,c(18),n.push(v===21?f(29,31):v===22?f(32,35):p()),l.push(v),c(12)}for(let v=l.length-1;v>=0;v--){let k=n[v];switch(l[v]){case 19:t.setNewReqId(k);break;case 20:t.setNewReqText(k);break;case 21:t.setNewReqRisk(k);break;case 22:t.setNewReqVerifyMethod(k);break;case 44:t.setNewElementType(k);break;default:t.setNewElementDocRef(k)}}};for(;d();)r[s]===12&&s++;for(r[s]!==14&&o(14,14,3,5,7),s++,c(12);;){let w=r[s];if(w===13)return;if(w===12)s++;else{if(d())continue;if(w>=8&&w<=11)s++,t.setDirection(w===8?"TB":w===9?"BT":w===10?"RL":"LR");else if(w>=23&&w<=28){let v=f(23,28),k=p(),L=m();b(!0),t.addRequirement(k,v),L&&t.setClass([k],L)}else if(w===36){s++;let v=p(),k=m();b(!1),t.addElement(v),k&&t.setClass([v],k)}else if(w===46){s++;let v=g();t.setCssStyle(v,u())}else if(w===47){s++;let v=g();t.defineClass(v,u())}else if(w===48){s++;let v=g();t.setClass(v,g())}else if(w===59||w===58){let v=a[s++],k=r[s];if(k===17)s++,t.setClass([v],g());else if(k===55||k===57){s++;let L=f(37,43);c(k===57?56:57);let I=p();k===57?t.addRelationship(L,v,I):t.addRelationship(L,I,v)}else o(17,17,55,57)}else o(12,13,3,5,7,8,9,10,11,23,24,25,26,27,28,36,47,48,46,59,58)}}}function eT(e){let t=[];for(let i of e.requirements.values())t.push({id:i.name,requirement:i,element:void 0,cssStyles:i.cssStyles,cssClasses:i.classes.join(" ")});for(let i of e.elements.values())t.push({id:i.name,requirement:void 0,element:i,cssStyles:i.cssStyles,cssClasses:i.classes.join(" ")});let r=i=>e.requirements.has(i)||e.elements.has(i)?i:void 0,a=e.relations.map((i,s)=>({id:`${i.src}-${i.dst}-${s}`,start:r(i.src),end:r(i.dst),type:i.type,contains:i.type===zi.CONTAINS}));return{nodes:t,edges:a,direction:e.direction}}function vc(e,t,r){if(t===0||e.lines.length===0)return e;let a=0,i=[],s=e.lines.map(l=>{let n=0,o=l.map(c=>{let f=c.style|t,p=c.icon!==void 0||c.math?c.width:r.width(c.text,e.size,f);return n+=p,{...c,style:f,width:p}});return i.push(n),n>a&&(a=n),o});return{...e,lines:s,widths:i,width:a}}function u2(e,t,r,a){let i=li(e),s="",l="";for(let n=0;n<e.lines.length;n++){let o=e.lines[n],c=r+Ya(e,n);if(zs(o)){l+=Re(Ua(e,n),t+e.widths[n]/2,c,a);continue}let f=c+e.size*.35,p=!0;for(let d of o)d.icon!==void 0||d.text===""||(s+=`<tspan${p?` x="${h(t)}" y="${h(f)}"`:""}${Ha(d.style&~i)}>${Xe(d.text)}</tspan>`,p=!1)}return(s===""?"":`<text${Aa(a,i)} text-anchor="start" xml:space="preserve">${s}</text>`)+l}function cT(e,t,r,a){let i=y2,s=e-r*i,l=t-a*i;return`<circle class="pele-marker" cx="${h(s)}" cy="${h(l)}" r="${i}"/><path class="pele-marker" d="M${h(s-r*i)},${h(l-a*i)}L${h(s+r*i)},${h(l+a*i)}M${h(s+a*i)},${h(l-r*i)}L${h(s-a*i)},${h(l+r*i)}"/>`}function hT(e,t,r,a){let i=e-r*p2,s=t-a*p2;return`<path class="pele-marker" d="M${h(i-a*Ac)},${h(s+r*Ac)}L${h(e)},${h(t)}L${h(i+a*Ac)},${h(s-r*Ac)}" stroke-linejoin="round"/>`}function dT(e,t,r){let a=new Map;for(let i of t){let s=i.route;if(!(i.src===i.dst||s.length<6))for(let l of[0,s.length-3]){let n=l===0?i.src:i.dst,o=e[n],c=s[l]-o.x,f=s[l+1]-o.y,p=l===0?3:l-3,d;if(Math.abs(Math.abs(f)-o.h/2)<.5)d=f<0?0:2;else if(Math.abs(Math.abs(c)-o.w/2)<.5)d=c<0?3:1;else continue;let g=n*4+d,u={route:s,at:l,toward:s[d%2===0?p:p+1]},m=a.get(g);m?m.push(u):a.set(g,[u])}}for(let[i,s]of a){if(s.length<2)continue;let l=i>>2,n=i%2===1,o=(n?r[l].h:r[l].w)-2*oT,c=Math.max(0,Math.min(lT,o/(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)*c;n?s[f].route[s[f].at+1]=e[l].y+p:s[f].route[s[f].at]=e[l].x+p}}}function fT(e,t,r){return jr(e.direction)?Bt(r,a=>g2(e,t,r,a)):g2(e,t,r,!1)}function g2(e,t,r,a){let i=eT(e),s=r.fontSize??16,l=Math.round(s*.875),n=r.measurer??et(r.fontFamily),o=r.padding??8,c=new Map,f=[],p=[];for(let H of i.nodes){let z=vt(H.cssStyles),C=(z.bold?1:0)|(z.italic?2:0),S=z.fontSize??s,$=z.fontSize??l,y=H.requirement,E=H.element,x=vc(ze(`\xAB${y?y.type:"Element"}\xBB`,!1,n,$,4e3),C,n),T=vc(ze(H.id,!0,n,S,sT),C|1,n),A=y?[["ID",y.requirementId],["Text",y.text],["Risk",y.risk],["Verification",y.verifyMethod]]:[["Type",E.type],["Doc Ref",E.docRef]],M=[],Y=0,B=0,q=0;for(let[G,X]of A){if(!X)continue;let Q=vc(ze(G,!1,n,$,4e3),C,n),J=vc(ze(X,!0,n,$,nT),C,n),F=Math.max(Q.height,J.height);M.push({key:Q,value:J,height:F}),Y=Math.max(Y,Q.width),B=Math.max(B,J.width),q+=F+Pf}M.length>0&&(q+=2*Ml-Pf);let D=2*Ml+x.height+T.height,R=Math.max(iT,Math.max(x.width,T.width)+2*Mc,M.length>0?Y+f2+B+2*Mc:0);c.has(H.id)||c.set(H.id,f.length);let P=Ut(R,D+q);P.seq=f.length,f.push({node:H,style:z,kind:x,name:T,rows:M,keyWidth:Y,headHeight:D,w:R,h:D+q}),p.push(P)}let d=a?"TB":br(i.direction),g=d==="LR"||d==="RL",u=[],m=[],b=[];for(let H of i.edges){let z=H.start===void 0?void 0:c.get(H.start),C=H.end===void 0?void 0:c.get(H.end);if(z===void 0||C===void 0)continue;let S=ze(`\xAB${H.type}\xBB`,!1,n,l,4e3);z===C&&(g?p[z].h+=2*(zf+S.height+8):p[z].w+=2*(zf+S.width+12)),b.push(H),m.push(S),u.push({src:z,dst:C,minlen:1,labelW:S.width+12,labelH:S.height+4,route:[],labelX:0,labelY:0})}let w=Gr(p,u,d,{nodeSep:tT,edgeSep:rT,rankSep:aT,portSep:20});dT(p,u,f);let v=Cr(e.title,n,s,4e3),k=v.height>0?v.height+12:0,L=Math.max(w.width,v.width),I=o+(L-w.width)/2,N=o+k,O=Math.ceil(L+2*o),W=Math.ceil(w.height+k+2*o),U="";for(let H=0;H<f.length;H++){let z=f[H],{w:C,h:S,style:$}=z,y=-C/2,E=-S/2,x=`<rect x="${h(y)}" y="${h(E)}" width="${h(C)}" height="${h(S)}" fill="var(--_s)" stroke="var(--_b)"${ft($.shape)}/>`+Re(z.kind,0,E+Ml+z.kind.height/2,` class="pele-stereotype" font-size="${z.kind.size}" fill="var(--_m)"${$.text}`)+Re(z.name,0,E+Ml+z.kind.height+z.name.height/2,` class="pele-label" font-size="${z.name.size}" font-weight="var(--_hw)"${$.text}`);if(z.rows.length>0){let T=E+z.headHeight;x+=`<path class="pele-divider" d="M${h(y)},${h(T)}H${h(-y)}" stroke="var(--_b)"${$.line}/>`;let A=T+Ml,M="";for(let Y of z.rows)M+=u2(Y.key,y+Mc,A,` class="pele-field" fill="var(--_m)"${$.text}`)+u2(Y.value,y+Mc+z.keyWidth+f2,A,` class="pele-value"${$.text}`),A+=Y.height+Pf;x+=`<g class="pele-fields" font-size="${z.rows[0].key.size}">${M}</g>`}U+=`<g class="pele-node ${z.node.requirement?"pele-requirement":"pele-element"}${_t(z.node.cssClasses.replace(/^default\s?/,""))}" data-id="${Oe(z.node.id)}" transform="translate(${h(p[H].x+I)},${h(p[H].y+N)})">${x}</g>`}let _="",j="",Z=new Map;for(let H=0;H<u.length;H++){let z=u[H],C=b[H],S=m[H],$=C.contains?2*y2:0,y,E=z.labelX+I,x=z.labelY+N;if(z.src===z.dst){let T=f[z.src],A=p[z.src].x+I,M=p[z.src].y+N,Y=Z.get(z.src)??0;Z.set(z.src,Y+1);let B=(g?T.w:T.h)/2,q=Math.min(B-4,12+Y*6),D=zf+Y*8,R=(G,X)=>g?`${h(A+X)},${h(M+T.h/2+G)}`:`${h(A+T.w/2+G)},${h(M+X)}`,P=D/.75;y={d:`M${R($,-q)}C${R(P,-q)} ${R(P,q)} ${R(0,q)}`,sx:g?A-q:A+T.w/2,sy:g?M+T.h/2:M-q,sdx:g?0:-1,sdy:g?-1:0,ex:g?A+q:A+T.w/2,ey:g?M+T.h/2:M+q,edx:g?0:-1,edy:g?-1:0},g?(E=A,x=M+T.h/2+D+4+z.labelH/2):(E=A+T.w/2+D+4+z.labelW/2,x=M)}else{let T=z.route.slice();for(let A=0;A<T.length;A+=3)T[A]+=I,T[A+1]+=N;y=zr(T,void 0,$,0)}_+=`<g class="pele-edge pele-relationship-${C.contains?"contains":"arrow"}" data-id="${Oe(C.id)}"><path d="${y.d}"${C.contains?"":' stroke-dasharray="5 4"'}/>`+(C.contains?cT(y.sx,y.sy,y.sdx,y.sdy):hT(y.ex,y.ey,y.edx,y.edy))+"</g>",j+=wr(C.id,S,E,x,"")}return{svg:Je("requirement",O,W,s,r,e,Re(v,O/2,o+v.height/2,' class="pele-title" font-weight="var(--_tw)"')+(_?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${_}</g>`:"")+(j?`<g class="pele-edge-labels" font-size="${l}" fill="var(--_m)">${j}</g>`:"")+`<g class="pele-nodes">${U}</g>`),width:O,height:W,links:[]}}var an,Df,$c,zi,US,qS,h2,GS,jS,VS,XS,kc,Of,KS,m2,QS,tT,rT,aT,Mc,Ml,Pf,f2,iT,sT,nT,zf,y2,p2,Ac,lT,oT,x2,w2=Ve(()=>{Ei();Ea();tr();zt();pr();ut();wt();an={REQUIREMENT:"Requirement",FUNCTIONAL_REQUIREMENT:"Functional Requirement",INTERFACE_REQUIREMENT:"Interface Requirement",PERFORMANCE_REQUIREMENT:"Performance Requirement",PHYSICAL_REQUIREMENT:"Physical Requirement",DESIGN_CONSTRAINT:"Design Constraint"},Df={LOW_RISK:"Low",MED_RISK:"Medium",HIGH_RISK:"High"},$c={VERIFY_ANALYSIS:"Analysis",VERIFY_DEMONSTRATION:"Demonstration",VERIFY_INSPECTION:"Inspection",VERIFY_TEST:"Test"},zi={CONTAINS:"contains",COPIES:"copies",DERIVES:"derives",SATISFIES:"satisfies",VERIFIES:"verifies",REFINES:"refines",TRACES:"traces"},US=1e6,qS=class{constructor(){ce(this,"type","requirement");ce(this,"direction","TB");ce(this,"requirements",new Map);ce(this,"elements",new Map);ce(this,"relations",[]);ce(this,"classes",new Map);ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"newId","");ce(this,"newText","");ce(this,"newRisk","");ce(this,"newVerifyMethod","");ce(this,"newElementType","");ce(this,"newDocRef","");ce(this,"styleCopies",0)}copy(e,t){if(this.styleCopies+=t.length,this.styleCopies>US)throw new je("Requirement diagram applies too many style declarations.","limit",{type:"requirement"});for(let r of t)e.push(r)}setDirection(e){this.direction=e}addRequirement(e,t){let r=this.requirements.get(e);return r===void 0&&(r={name:e,type:t,requirementId:this.newId,text:this.newText,risk:this.newRisk,verifyMethod:this.newVerifyMethod,cssStyles:[],classes:["default"]},this.requirements.set(e,r)),this.newId=this.newText=this.newRisk=this.newVerifyMethod="",r}setNewReqId(e){this.newId=e}setNewReqText(e){this.newText=e}setNewReqRisk(e){this.newRisk=e}setNewReqVerifyMethod(e){this.newVerifyMethod=e}addElement(e){let t=this.elements.get(e);return t===void 0&&(t={name:e,type:this.newElementType,docRef:this.newDocRef,cssStyles:[],classes:["default"]},this.elements.set(e,t)),this.newElementType=this.newDocRef="",t}setNewElementType(e){this.newElementType=e}setNewElementDocRef(e){this.newDocRef=e}addRelationship(e,t,r){this.relations.push({type:e,src:t,dst:r})}node(e){return this.requirements.get(e)??this.elements.get(e)}setCssStyle(e,t){for(let r of e){let a=this.node(r);if(!t||!a)return;for(let i of t)this.copy(a.cssStyles,i.includes(",")?i.split(","):[i])}}setClass(e,t){for(let r of e){let a=this.node(r);if(a)for(let i of t){a.classes.push(i);let s=this.classes.get(i)?.styles;s&&this.copy(a.cssStyles,s)}}}defineClass(e,t){for(let r of e){let a=this.classes.get(r);a===void 0&&(a={id:r,styles:[],textStyles:[]},this.classes.set(r,a));for(let s of t)s.includes("color")&&a.textStyles.push(s.replace("fill","bgFill")),a.styles.push(s);let i=t.flatMap(s=>s.split(","));for(let s of this.requirements.values())s.classes.includes(r)&&this.copy(s.cssStyles,i);for(let s of this.elements.values())s.classes.includes(r)&&this.copy(s.cssStyles,i)}}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
85
|
+
`)}},h2=["$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"],GS=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]]),jS=/accTitle\s*:\s*/iy,VS=/accDescr\s*:\s*/iy,XS=/accDescr\s*\{\s*/iy,kc=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi,Of=/[\n\r\u2028\u2029]/g,KS=22,m2=new Uint8Array(128);for(let e of`:,\r
|
|
86
|
+
{<>-=`)m2[e.charCodeAt(0)]=1;QS=[an.REQUIREMENT,an.FUNCTIONAL_REQUIREMENT,an.INTERFACE_REQUIREMENT,an.PERFORMANCE_REQUIREMENT,an.PHYSICAL_REQUIREMENT,an.DESIGN_CONSTRAINT,Df.LOW_RISK,Df.MED_RISK,Df.HIGH_RISK,$c.VERIFY_ANALYSIS,$c.VERIFY_DEMONSTRATION,$c.VERIFY_INSPECTION,$c.VERIFY_TEST,"",zi.CONTAINS,zi.COPIES,zi.DERIVES,zi.SATISFIES,zi.VERIFIES,zi.REFINES,zi.TRACES];tT=40,rT=16,aT=56,Mc=14,Ml=10,Pf=2,f2=12,iT=120,sT=280,nT=240,zf=26,y2=6,p2=9,Ac=4.5,lT=28,oT=14;x2={type:"requirement",math:!0,parse(e,t,r){let a=new qS;return r&&(a.title=r),JS(e,a),a},render:fT}});var b2={};Ct(b2,{requirement:()=>x2});var $2=Ve(()=>{w2()});function k2(e){return e>=32&&e<=126&&e!==34&&e!==44}function uT(e){let t=e.length,r=[],a=[],i=[],s=[],l=0,n=0,o=(f,p,d)=>{r.push(f),a.push(e.slice(p,d)),i.push(p),n=d},c=f=>e.slice(n,n+f.length).toLowerCase()===f&&!Qe(e.charCodeAt(n+f.length));for(;n<t;){let f=e.charCodeAt(n),p=n,d=n;if(l===2){if(f===34&&e.charCodeAt(n+1)!==34){s.length>0&&(l=s.pop()),o(5,n,n+1);continue}for(;d<t;){let g=e.charCodeAt(d);if(k2(g)||g===44||g===13||g===10)d++;else if(g===34&&e.charCodeAt(d+1)===34)d+=2;else break}o(7,n,d)}else{if(l===0&&(f|32)===115){let g=c("sankey-beta")?11:c("sankey")?6:0;if(g>0){s.push(l),l=1,o(2,n,n+g);continue}}if(f===10||f===13&&e.charCodeAt(n+1)===10){o(3,n,f===10?n+1:n+2);continue}if(f===44){o(4,n,n+1);continue}if(f===34){s.push(l),l=2,o(5,n,n+1);continue}for(;d<t&&k2(e.charCodeAt(d));)d++;o(6,n,d)}if(d===p)return o(1,n,n),{types:r,texts:a,starts:i}}return o(l===2?7:8,t,t),o(0,t,t),{types:r,texts:a,starts:i}}function M2(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 mT(e){let t=0,r=e.length;for(;t<r&&M2(e.charCodeAt(t));)t++;for(;r>t&&M2(e.charCodeAt(r-1));)r--;return e.slice(t,r).replace(gT,`
|
|
87
|
+
`).trim()}function yT(e,t){let{types:r,texts:a,starts:i}=uT(e),s=0,l=f=>{let p=r[s],d=p===1?Ff[r[s-1]]:Ff[p];throw it("sankey",e,i[s],`Expecting ${f}, got '${d}'`)},n=(f,p="")=>{r[s]!==f&&l(`'${Ff[f]}'${p}`),s++},o=()=>{if(r[s]===6)return a[s++];r[s]!==5&&l("'DQUOTE', 'NON_ESCAPED_TEXT'"),s++,r[s]!==7&&l("'ESCAPED_TEXT'");let f=a[s++];return n(5),f},c=()=>o().trim().replaceAll('""','"');for(n(2),n(3);;){let f=c();n(4,", 'NEWLINE', 'EOF'");let p=c();n(4,", 'NEWLINE', 'EOF'");let d=o(),g=t.findOrCreateNode(f),u=t.findOrCreateNode(p);if(t.addLink(g,u,parseFloat(d.trim())),r[s]!==3)break;s++}r[s]===8&&s++,r[s]!==0&&l("'NEWLINE', 'EOF'")}function Wf(e,t){if(e.length>8){e.sort(t);return}for(let r=1;r<e.length;r++){let a=e[r],i=r-1;for(;i>=0&&t(e[i],a)>0;)e[i+1]=e[i],i--;e[i+1]=a}}function wT(e,t){let r=e.nodes.length,a=e.links.map($=>({source:$.source.index,target:$.target.index,value:Number.isFinite($.value)&&$.value>0?$.value:0,thickness:0,sourceY:0,targetY:0})),i=[],s=[];for(let $=0;$<r;$++)i.push([]),s.push([]);a.forEach(($,y)=>{i[$.source].push(y),s[$.target].push(y)});let l=new Int32Array(r),n=new Int32Array(r),o=[];for(let $=0;$<r;$++)n[$]=s[$].length,n[$]===0&&o.push($);for(let $=0;$<o.length;$++){let y=o[$];for(let E of i[y]){let x=a[E].target;l[x]<l[y]+1&&(l[x]=l[y]+1),--n[x]===0&&o.push(x)}}if(o.length<r){let $=0;for(;n[$]===0;)$++;let y=new Uint8Array(r);for(;y[$]===0;){y[$]=1;for(let E of s[$])if(n[a[E].source]>0){$=a[E].source;break}}throw new je(`Sankey diagrams cannot have circular links, and "${e.nodes[$].id}" is part of one.`,"semantic",{type:"sankey"})}let c=1;for(let $=0;$<r;$++)l[$]+1>c&&(c=l[$]+1);let f=new Int32Array(r);for(let $=r-1;$>=0;$--){let y=o[$];for(let E of i[y])f[y]<f[a[E].target]+1&&(f[y]=f[a[E].target]+1)}let p=0;for(let $ of a)$.value>p&&(p=$.value);let d=p>0?1/p:0,g=[],u=new Float64Array(r),m=[];for(let $=0;$<c;$++)m.push([]);let b=c>1?(t.width-t.nodeWidth)/(c-1):0;for(let $=0;$<r;$++){let y;if(t.alignment==="left")y=l[$];else if(t.alignment==="right")y=c-1-f[$];else if(t.alignment==="center"){if(y=l[$],s[$].length===0&&i[$].length>0){y=c;for(let M of i[$])l[a[M].target]-1<y&&(y=l[a[M].target]-1)}}else y=i[$].length>0?l[$]:c-1;let E=0,x=0,T=0,A=0;for(let M of s[$])E+=a[M].value*d,T+=a[M].value;for(let M of i[$])x+=a[M].value*d,A+=a[M].value;u[$]=Math.max(E,x),g.push({layer:y,value:Math.max(T,A),x:y*b,y:0,height:0}),m[y].push($)}let w=1;for(let $ of m)$.length>w&&(w=$.length);let v=w>1?Math.min(t.nodePadding,t.height/(w-1)):t.nodePadding,k=1/0;for(let $ of m){let y=0;for(let E of $)y+=u[E];y>0&&(k=Math.min(k,(t.height-($.length-1)*v)/y))}(!Number.isFinite(k)||k<0)&&(k=0);let L=Math.max(0,t.labelHeight-v),I=$=>{for(let y of m){let E=(y.length-1)*v;for(let x of y)E+=Math.max(u[x]*$,L);if(E>t.height+1e-6)return!1}return!0};if(L>0&&!I(k))if(I(0)){let $=0;for(let y=0;y<40;y++){let E=($+k)/2;I(E)?$=E:k=E}k=$}else L=0;let N=new Float64Array(r);for(let $ of a)$.thickness=$.value*d*k;for(let $ of m){let y=0;for(let x of $)g[x].height=u[x]*k,N[x]=Math.max(0,L-g[x].height)/2,g[x].y=y+N[x],y+=g[x].height+2*N[x]+v;let E=(t.height-y+v)/($.length+1);$.forEach((x,T)=>g[x].y+=E*(T+1))}let O=$=>g[$].y+g[$].height/2,W=new Float64Array(a.length),U=new Float64Array(a.length),_=($,y)=>O(a[$].target)-O(a[y].target)||$-y,j=($,y)=>O(a[$].source)-O(a[y].source)||$-y,Z=($,y)=>O($)-O(y)||$-y,H=$=>{let y=0;Wf(i[$],_);for(let E of i[$])W[E]=y+a[E].thickness/2,y+=a[E].thickness},z=$=>{let y=0;Wf(s[$],j);for(let E of s[$])U[E]=y+a[E].thickness/2,y+=a[E].thickness},C=()=>{for(let $=0;$<r;$++)H($),z($)},S=($,y,E)=>{for(let T of $){let A=E?s[T]:i[T];if(A.length===0)continue;E?z(T):H(T);let M=0,Y=0,B=0;for(let D of A){let R=E?g[a[D].source].y+W[D]-U[D]:g[a[D].target].y+U[D]-W[D];M+=R*a[D].thickness,Y+=a[D].thickness,B+=O(E?a[D].source:a[D].target)-g[T].height/2}let q=Y>0?M/Y:B/A.length;g[T].y+=(q-g[T].y)*y}Wf($,Z);let x=0;for(let T of $)g[T].y-N[T]<x&&(g[T].y=x+N[T]),x=g[T].y+g[T].height+N[T]+v;x=t.height;for(let T=$.length-1;T>=0;T--){let A=$[T];g[A].y+g[A].height+N[A]>x&&(g[A].y=x-g[A].height-N[A]),x=g[A].y-N[A]-v}};C();for(let $=0;$<xT;$++){let y=Math.pow(.99,$);for(let E=c-2;E>=0;E--)S(m[E],y,!1);C();for(let E=1;E<c;E++)S(m[E],y,!0);C()}for(let $=0;$<a.length;$++)a[$].sourceY=g[a[$].source].y+W[$],a[$].targetY=g[a[$].target].y+U[$];return{nodes:g,links:a}}function T2(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ec(e,t,r,a,i){let s=e[t];return typeof s=="number"&&s>=a?Math.min(s,i):r}function v2(e,t){let r=e[t];return typeof r=="string"||typeof r=="number"&&Number.isFinite(r)?String(r):""}function E2(e){return Math.abs(e)<1e15?Math.round(e*100)/100:e}function S2(e){return typeof e=="string"?vt([`fill:${e}`]).shape:""}function $T(e,t,r){let a=T2(t.sankey)?t.sankey:{};return Ci(r,Ec(a,"width",600,1,1e4),160,i=>kT(e,a,r,i))}function kT(e,t,r,a){let i=r.fontSize??16,s=Math.round(i*.875),l=r.measurer??et(r.fontFamily),n=r.padding??8,o=Ec(t,"height",400,1,1e4),c=Math.min(Ec(t,"nodeWidth",10,1,200),a),f=t.showValues!==!1,p=v2(t,"prefix"),d=v2(t,"suffix"),g=t.labelStyle==="outlined",u=t.nodeAlignment==="left"||t.nodeAlignment==="right"||t.nodeAlignment==="center"?t.nodeAlignment:"justify",m=typeof t.linkColor=="string"?t.linkColor:"gradient",{nodes:b,links:w}=wT(e,{width:a,height:o,nodeWidth:c,nodePadding:Ec(t,"nodePadding",12,0,200)+(f?bT:0),labelHeight:s*1.15,alignment:u}),v=new Map;if(T2(t.nodeColors))for(let[T,A]of Object.entries(t.nodeColors)){let M=S2(A);M&&v.set(T,M)}let k=T=>v.get(e.nodes[T].id)??"",L=0,I=0;b.forEach(T=>{T.value>I&&(I=T.value,L=T.layer)});let N=0,O=a,W=0,U=o,_="",j="";b.forEach((T,A)=>{let M=e.nodes[A].id,Y=Math.max(T.height,1);j+=`<rect class="pele-sankey-node" data-id="${Oe(M)}" x="${h(T.x)}" y="${h(T.y)}" width="${h(c)}" height="${h(Y)}" rx="${h(Math.min(2,Y/2))}" fill="${dt(A)}"${k(A)}/>`;let B=f?`${p}${E2(T.value)}${d}`:"",q=g?T.layer>=L:T.x<a/2,D=l.width(B?`${M} ${B}`:M,s,0),R=q?T.x+c+A2:T.x-A2,P=T.y+T.height/2;N=Math.min(N,q?R:R-D),O=Math.max(O,q?R+D:R),W=Math.min(W,P-s*.75),U=Math.max(U,P+s*.75);let G=` x="${h(R)}" y="${h(P+s*.35)}" text-anchor="${q?"start":"end"}"`,X=Xe(M)+(B?` <tspan class="pele-sankey-value" fill="var(--_m)">${Xe(B)}</tspan>`:"");_+=`<g class="pele-label" data-id="${Oe(M)}">`+(g?`<text${G} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${Xe(M)}${B?" "+Xe(B):""}</text>`:"")+`<text${G}>${X}</text></g>`});let Z=m==="gradient"||m==="source"||m==="target"?"":S2(m),H="";for(let T of w){let A=m==="target"?T.target:T.source,M=Math.max(T.thickness,1)/2,Y=b[T.source].x+c,B=b[T.target].x,q=h((Y+B)/2),D=Oe(e.nodes[T.source].id),R=Oe(e.nodes[T.target].id);H+=`<path class="pele-sankey-link" data-id="${D}->${R}" d="M${h(Y)},${h(T.sourceY-M)}C${q},${h(T.sourceY-M)} ${q},${h(T.targetY-M)} ${h(B)},${h(T.targetY-M)}L${h(B)},${h(T.targetY+M)}C${q},${h(T.targetY+M)} ${q},${h(T.sourceY+M)} ${h(Y)},${h(T.sourceY+M)}Z" fill="${dt(A)}"${Z||k(A)}><title>${D} \u2192 ${R}: ${Oe(p)}${E2(T.value)}${Oe(d)}</title></path>`}let z=ze(e.title,!1,l,i,It(r),1),C=z.height>0?z.height+12:0,S=Math.max(O-N,z.width),$=n-N+(S-(O-N))/2,y=n+C-W,E=Math.ceil(S+2*n),x=Math.ceil(U-W+C+2*n);return{svg:Je("sankey",E,x,i,r,e,Re(z,E/2,n+z.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${h($)},${h(y)})"><g class="pele-sankey-links" fill-opacity="0.4">${H}</g><g class="pele-sankey-nodes">${j}</g><g class="pele-labels" font-size="${s}">${_}</g></g>`),width:E,height:x,links:[]}}var pT,Ff,gT,xT,A2,bT,C2,_2=Ve(()=>{tr();zt();ut();wt();pT=class{constructor(){ce(this,"type","sankey");ce(this,"nodes",[]);ce(this,"links",[]);ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"lookup",new Map)}findOrCreateNode(e){let t=this.lookup.get(e);return t===void 0&&(t={id:e,index:this.nodes.length},this.lookup.set(e,t),this.nodes.push(t)),t}addLink(e,t,r){this.links.push({source:e,target:t,value:r})}},Ff=["$end","STUCK","SANKEY","NEWLINE","COMMA","DQUOTE","NON_ESCAPED_TEXT","ESCAPED_TEXT","EOF"];gT=/[\n\r]+/g;xT=6;A2=6,bT=15;C2={type:"sankey",parse(e,t,r){let a=new pT;return r&&(a.title=r),yT(mT(e),a),a},render:$T}});var I2={};Ct(I2,{sankey:()=>C2});var N2=Ve(()=>{_2()});function Al(e,t,r,a,i,s=0){if(e===""||t<=0)return;let l=i.width(e,r,s);if(l<=t)return{text:e,size:r,width:l};let n=Math.max(a,Math.floor(r*t/l));for(;n>=a;){if(l=i.width(e,n,s),l<=t)return{text:e,size:n,width:l};n--}let o=Array.from(e),c=0,f=o.length-1;for(;c<f;){let d=c+f+1>>1;i.width(o.slice(0,d).join("").trimEnd()+"\u2026",a,s)<=t?c=d:f=d-1}if(c===0)return;let p=o.slice(0,c).join("").trimEnd()+"\u2026";return l=i.width(p,a,s),l<=t?{text:p,size:a,width:l}:void 0}var Bf=Ve(()=>{});function ds(e,t,r,a,i=0){let s=[];for(let c of e.split(`
|
|
88
|
+
`)){let f=Array.from(c);f.length===0&&s.push("");let p=0;for(;p<f.length;){let d=v=>t.width(f.slice(p,p+v).join(""),r,i)<=a,g=1;for(;g<f.length-p&&d(g);)g=Math.min(f.length-p,g*2);let u=1;for(;u<g;){let v=Math.ceil((u+g)/2);d(v)?u=v:g=v-1}let m=u,b=p+m<f.length;if(b&&!Hf.test(f[p+m])){for(let v=m-1;v>0;v--)if(Hf.test(f[p+v])){m=v+1;break}}let w=f.slice(p,p+m).join("");for(s.push(b&&w.trimEnd()||w),p+=m;b&&p<f.length&&Hf.test(f[p]);)p++}}e===""&&(s.length=0);let l=s.map(c=>t.width(c,r,i)),n=0;for(let c of l)n=Math.max(n,c);let o=Math.round(r*1.5);return{lines:s.map((c,f)=>[{text:c,style:i,width:l[f]}]),widths:l,width:n,height:s.length*o,size:r,lineHeight:o}}function fs(e,t,r){if(e.width<=r)return e;let a=[],i=[];for(let n=0;n<e.lines.length;n++){if(e.widths[n]<=r){a.push(e.lines[n]),i.push(e.widths[n]);continue}let o=[],c=0,f=()=>{a.push(o),i.push(c),o=[],c=0};for(let p of e.lines[n]){if(p.icon!==void 0||p.math){o.length&&c+p.width>r&&f(),o.push(p),c+=p.width;continue}for(let d of Array.from(p.text)){let g=o[o.length-1],u=g&&g.icon===void 0&&g.math===void 0&&g.style===p.style,m=t.width(u?g.text+d:d,e.size,p.style)-(u?g.width:0);o.length&&c+m>r&&(f(),g=void 0,m=t.width(d,e.size,p.style)),g&&g.icon===void 0&&g.math===void 0&&g.style===p.style?(g.text+=d,g.width+=m):o.push({text:d,style:p.style,width:m}),c+=m}}(o.length||!e.lines[n].length)&&f()}let s=0;for(let n of i)s=Math.max(s,n);let l={...e,lines:a,widths:i,width:s,height:a.length*e.lineHeight};return e.heights?Yn(l):l}function yi(e,t,r,a){let i=li(e),s="<text"+Aa(a,i),l="";for(let n=0;n<e.lines.length;n++){let o=e.lines[n],c=r+(n+.5)*e.lineHeight;if(o.some(p=>p.icon!==void 0)){let p=e.widths[n];l+=Re({...e,lines:[o],widths:[p],width:p,height:e.lineHeight},t+p/2,c,a);continue}let f="";for(let p of o){let d=Ha(p.style&~i);f+=d?`<tspan${d}>${Xe(p.text)}</tspan>`:Xe(p.text)}f!==""&&(l+=`${s} x="${h(t)}" y="${h(c+e.size*.35)}" text-anchor="start" xml:space="preserve">${f}</text>`)}return l}var Hf,ps=Ve(()=>{ut();Hf=/\s/});function vl(e,t,r,a,i){let s=e.packet?.[t];return typeof s=="number"&&s>=a?Math.min(s,i):r}function Yf(e){return new je(e,"semantic",{type:"packet"})}function AT(e,t,r){let a=Math.floor(vl(t,"bitsPerRow",32,1,4096)),i=[],s=-1,l=[],n=1;for(let o of e.blocks){let{start:c,end:f,bits:p}=o;if(c!==void 0&&f!==void 0&&f<c)throw Yf(`Packet block ${c} - ${f} is invalid. End must be greater than start.`);if(c??(c=s+1),c!==s+1)throw Yf(`Packet block ${c} - ${f??c} is not contiguous. It should start from ${s+1}.`);if(p===0)throw Yf(`Packet block ${c} is invalid. Cannot have a zero bit field.`);for(f??(f=c+(p??1)-1),p??(p=f-c+1),s=f;l.length<=a+1&&i.length<MT;){let d=n*a-1;if(f<=d){l.push({start:c,end:f,bits:p,label:o.label}),f===d&&(i.push(l),l=[],n++);break}l.push({start:c,end:d,bits:d-c,label:o.label}),i.push(l),l=[],n++,c=d+1,p=f-c}}return l.length>0&&i.push(l),{type:"packet",title:e.title||r,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
89
|
+
`):void 0,bitsPerRow:a,rows:i}}function vT(e){let t=new Zt(Gt(e,R2,"packet"),R2,"packet"),r={$type:"Packet",blocks:[]},a=()=>{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:r.accDescr=Kt(t.take()),a();break;case 6:r.accTitle=Xt(t.take()),a();break;case 7:r.title=Vt(t.take()),a();break;case 8:case 3:{let i={$type:"PacketBlock",label:""};t.accept(3)?i.bits=Number(t.expect(8)):(i.start=Number(t.take()),t.accept(2)&&(i.end=Number(t.expect(8)))),t.expect(4),i.label=$r(t.expect(9)),r.blocks.push(i),a();break}default:t.fail("a field, a title, or a line break")}return r}function ET(e,t,r){return Bt(r,a=>ST(e,t,r,a))}function ST(e,t,r,a){let i=r.fontSize??16,s=Math.round(i*.875),l=Math.round(i*.625),n=r.measurer??et(r.fontFamily),o=r.padding??8,c=t.packet??{},f=vl(t,"rowHeight",32,1,400),p=vl(t,"bitWidth",32,1,400),d=vl(t,"paddingX",5,0,400),g=vl(t,"paddingY",5,0,400),u=c.showBits!==!1,m=c.bitOrder==="descending",b=e.bitsPerRow,w=e.rows;if(a){let E=Math.max(1,Math.floor(((r.maxWidth??320)-2*o)/Math.min(p,18)));b=Math.min(b,Math.max(8,2**Math.floor(Math.log2(E))));let x=e.rows[e.rows.length-1],T=x?.[x.length-1]?.end??0;Math.ceil((T+1)/b)>1e4&&(b=e.bitsPerRow),p=Math.min(p,Math.max(18,((r.maxWidth??320)-2*o)/b));let A=Y=>Y.bits===Y.end-Y.start,M=[];for(let Y of e.rows)for(let B of Y){let q=M[M.length-1];q&&A(q)&&A(B)&&q.label===B.label&&B.start===q.end+1&&B.start%e.bitsPerRow===0?(q.end=B.end,q.bits=q.end-q.start):M.push({...B})}w=[];for(let Y of M)for(let B=Y.start;B<=Y.end;){let q=Math.min(Y.end,(Math.floor(B/b)+1)*b-1),D=Math.floor(B/b);(w[D]??(w[D]=[])).push({...Y,start:B,end:q}),B=q+1}}let v=new Map;if(a)for(let E of w)for(let x of E){let T=Math.max(1,(x.end-x.start+1)*p-Math.min(d,p-1)-6),A=ds(At(x.label).trim(),n,s,T);v.set(x,A)}let k=u?l+4:0,L=w.map(E=>{let x=f;if(a)for(let T of E)x=Math.max(x,v.get(T).height+10);return x}),I=[],N=0;for(let E of L)I.push(N),N+=k+E+g;w.length&&(N-=g);let O=Math.min(d,p-1),W=w.length>0?b*p-O:0,U=ze(e.title,!1,n,i,a?It(r):4e3,1),_=U.height>0?U.height+(N>0?12:0):0,j=new Map,Z=(E,x)=>{let T=j.get(E);return T||j.set(E,T=new Map),T.has(x)||T.set(x,Al(At(E).trim(),x,s,Math.round(i*.5),n)),T.get(x)},H=o+Math.max(0,(U.width-W)/2),z="",C="";w.forEach((E,x)=>{let T=o+I[x]+k,A=L[x];for(let M of E){let Y=M.end-M.start+1,B=M.start%b,q=H+(m?b-B-Y:B)*p,D=Y*p-O,R=a?void 0:Z(M.label,D-6);if(z+=`<g class="pele-node" data-id="${M.start}-${M.end}"><rect x="${h(q)}" y="${h(T)}" width="${h(D)}" height="${h(A)}" fill="var(--_s)" stroke="var(--_b)"${st}/>`+(a?Re(v.get(M),q+D/2,T+A/2,""):R&&R.size<=A?`<text x="${h(q+D/2)}" y="${h(T+A/2+R.size*.35)}"${R.size===s?"":` font-size="${h(R.size)}"`}>${Xe(R.text)}</text>`:"")+"</g>",!u)continue;let P=m?M.end:M.start,G=m?M.start:M.end;Y===1?C+=`<text x="${h(q+D/2)}" y="${h(T-4)}" text-anchor="middle">${P}</text>`:C+=`<text x="${h(q)}" y="${h(T-4)}">${P}</text><text x="${h(q+D)}" y="${h(T-4)}" text-anchor="end">${G}</text>`}});let S=Math.ceil(Math.max(W,U.width)+2*o),$=Math.ceil(N+_+2*o),y=(z?`<g class="pele-packet-fields" font-size="${s}" text-anchor="middle">${z}</g>`:"")+(C?`<g class="pele-packet-bits" font-size="${l}" fill="var(--_m)">${C}</g>`:"")+Re(U,S/2,$-o-U.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:Je("packet",S,$,i,r,e,y),width:S,height:$,links:[]}}var MT,R2,L2,D2=Ve(()=>{Bf();ps();zt();Xr();ut();wt();MT=1e4;R2=[{name:"packet-beta",pattern:"packet-beta"},or("packet"),{name:"-",pattern:"-",longer:[jt]},{name:"+",pattern:"+"},{name:":",pattern:":"},ur,rr,ar,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Vr,Rr,Lr,jt,nr,lr];L2={type:"packet",parse:(e,t,r)=>AT(vT(e),t,r),render:ET}});var O2={};Ct(O2,{packet:()=>L2});var P2=Ve(()=>{D2()});function F2(e){return new je(e,"semantic",{type:"radar"})}function TT(e,t){let r=e.axes.map(s=>({name:s.name,label:s.label??s.name})),a=e.curves.map(s=>{let l;if(s.entries[0].axis===void 0)l=s.entries.map(n=>n.value);else{if(r.length===0)throw F2("Axes must be populated before curves for reference entries");let n=new Map;for(let o of s.entries)o.axis!==void 0&&!n.has(o.axis.$refText)&&n.set(o.axis.$refText,o.value);l=r.map(o=>{let c=n.get(o.name);if(c===void 0)throw F2("Missing entry for axis "+o.label);return c})}return{name:s.name,label:s.label??s.name,entries:l}}),i={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"};for(let s of e.options)s.name==="showLegend"?i.showLegend=s.value:s.name==="graticule"?i.graticule=s.value:i[s.name]=s.value;return i.ticks>z2&&(i.ticks=z2),{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,`
|
|
90
|
+
`):void 0,axes:r,curves:a,options:i}}function W2(e,t){let r=t;for(let a=e.charCodeAt(r);a>=48&&a<=57;a=e.charCodeAt(r))r++;return r}function CT(e,t){(t<jf||t>=Sc)&&(jf=t,Sc=W2(e,t));let r=Sc;if(r===t)return-1;let a=e.charCodeAt(r)===46;if(a){let i=W2(e,r+1),s=i-r-1;if(s>0&&e.charCodeAt(i)!==46)return i;if(s>1)return i-1}return e.charCodeAt(t)===48?t+1:a?r-1>t?r-1:-1:r}function _T(e,t){return qf.lastIndex=t,qf.test(e)&&(Tc===-2&&(Tc=e.lastIndexOf("}")),qf.lastIndex>Tc)?-1:(Uf.lastIndex=t,Uf.test(e)?Uf.lastIndex:-1)}function IT(e){return jf=Sc=0,Tc=-2,Gt(e,Y2,"radar")}function NT(e){let t=new Zt(IT(e),Y2,"radar"),r={$type:"Radar",axes:[],curves:[],options:[]},a=()=>{for(;t.kind===23;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==23&&t.fail("a line break or the end of input"),a())},s=()=>{if(!t.accept(11))return;let p=$r(t.expect(21));return t.expect(12),p},l=p=>{if(!p)return{$type:"Entry",value:Number(t.expect(20))};let d={$refText:t.expect(22)};return t.accept(9),{$type:"Entry",axis:d,value:Number(t.expect(20))}},n=()=>{let p=t.expect(22),d=s(),g={$type:"Curve",name:p,entries:[]};d!==void 0&&(g.label=d),t.expect(13),a(),t.kind!==20&&t.kind!==22&&t.fail("a number or an axis name");let u=t.kind===22;for(g.entries.push(l(u));t.accept(10);)a(),g.entries.push(l(u));return a(),t.expect(14),g},o=()=>{let p={$type:"Axis",name:t.expect(22)},d=s();return d!==void 0&&(p.label=d),p},c=()=>{let p=t.kind,d=t.take(),g;return p===2?g=t.expect(16)==="true":p===3?g=t.expect(15):g=Number(t.expect(20)),{$type:"Option",name:d,value:g}},f=()=>t.kind===2||t.kind===5||t.kind===7||t.kind===8||t.kind===3;for(a(),t.accept(0)||(t.expect(1),t.accept(9)),a();t.kind!==-1;)switch(t.kind){case 23:t.i++;break;case 17:r.accDescr=Kt(t.take()),i();break;case 18:r.accTitle=Xt(t.take()),i();break;case 19:r.title=Vt(t.take()),i();break;case 6:t.i++;do r.axes.push(o());while(t.accept(10));break;case 4:t.i++;do r.curves.push(n());while(t.accept(10));break;default:for(f()||t.fail("an axis, a curve, an option, a title, or a line break"),r.options.push(c());t.accept(10);)f()||t.fail("an option"),r.options.push(c())}return r}function xi(e,t,r,a,i){let s=e.radar?.[t];return typeof s=="number"&&s>=a?Math.min(s,i):r}function RT(e,t,r,a){let i=Math.min(Math.max(e,t),r);return a*(i-t)/(r-t)}function LT(e,t){let r=e.length,a=`M${h(e[0].x)},${h(e[0].y)}`;for(let i=0;i<r;i++){let s=e[(i-1+r)%r],l=e[i],n=e[(i+1)%r],o=e[(i+2)%r];a+=` C${h(l.x+(n.x-s.x)*t)},${h(l.y+(n.y-s.y)*t)} ${h(n.x-(o.x-l.x)*t)},${h(n.y-(o.y-l.y)*t)} ${h(n.x)},${h(n.y)}`}return a+" Z"}function H2(e){let t="";for(let r of e)t+=(t?" ":"")+h(r.x)+","+h(r.y);return t}function DT(e,t,r){let a=xi(t,"width",320,1,4e3);return Ci(r,a,160,(i,s)=>OT(e,t,r,i,xi(t,"height",320,1,4e3)*i/a,s))}function OT(e,t,r,a,i,s){let l=r.fontSize??16,n=Math.round(l*.875),o=r.measurer??et(r.fontFamily),c=r.padding??8,f=xi(t,"axisScaleFactor",1,0,10),p=xi(t,"axisLabelFactor",1.05,0,10),d=xi(t,"curveTension",.17,0,1),g=Math.min(a,i)/2,{axes:u,curves:m}=e,{ticks:b,graticule:w,min:v}=e.options,k=u.length,L=u.map((D,R)=>{let P=2*Math.PI*R/k-Math.PI/2;return{x:Math.cos(P),y:Math.sin(P)}}),I=e.options.max;if(I===null){I=-1/0;for(let D of m)for(let R of D.entries)R>I&&(I=R)}let N=-a/2-xi(t,"marginLeft",16,0,2e3),O=a/2+xi(t,"marginRight",16,0,2e3),W=-i/2-xi(t,"marginTop",16,0,2e3),U=i/2+xi(t,"marginBottom",16,0,2e3),_="";for(let D=0;D<b;D++){let R=Math.min(g,g*(D+1)/b);w==="circle"?_+=`<circle r="${h(R)}"/>`:_+=`<polygon points="${H2(L.map(P=>({x:P.x*R,y:P.y*R})))}"/>`}let j="",Z="";L.forEach((D,R)=>{let P=g*f;j+=`M0,0L${h(D.x*P)},${h(D.y*P)}`;let G=ze(u[R].label,!1,o,n,4e3),X=g*p+6,Q=D.x*X+(D.x>.01?G.width/2:D.x<-.01?-G.width/2:0),J=D.y*X+(D.y>.01?G.height/2:D.y<-.01?-G.height/2:0);Z+=`<g class="pele-axis-label" data-id="${Oe(u[R].name)}">${Re(G,Q,J,"")}</g>`,N=Math.min(N,Q-G.width/2),O=Math.max(O,Q+G.width/2),W=Math.min(W,J-G.height/2),U=Math.max(U,J+G.height/2)});let H="";m.forEach((D,R)=>{if(D.entries.length!==k)return;let P=D.entries.map((Q,J)=>{let F=RT(Q,v,I,g),K=Number.isFinite(F)?F:0;return{x:L[J].x*K,y:L[J].y*K}}),G=dt(R),X=` class="pele-curve" data-id="${Oe(D.name)}" fill="${G}" stroke="${G}"`;H+=w==="circle"?`<path${X} d="${LT(P,d)}"/>`:`<polygon${X} points="${H2(P)}"/>`});let z=e.options.showLegend?m.map(D=>ze(D.label,!1,o,n,4e3)):[],C=0;for(let D of z)C=Math.max(C,D.width);let S=z.length*Gf,$=s?-(sn+8+C)/2:O+B2,y=s?U+B2/2:-S/2;z.length>0&&s?(N=Math.min(N,$),O=Math.max(O,-$),U=y+S):z.length>0&&(O=$+sn+8+C,W=Math.min(W,-S/2),U=Math.max(U,S/2));let E="";z.forEach((D,R)=>{let P=y+R*Gf+Gf/2,G=dt(R);E+=`<g class="pele-legend-item" data-id="${Oe(m[R].name)}"><rect x="${h($)}" y="${h(P-sn/2)}" width="${sn}" height="${sn}" rx="2" fill="${G}" fill-opacity="0.4" stroke="${G}"/>`+Re(D,$+sn+8+D.width/2,P,"")+"</g>"});let x=ze(e.title,!1,o,l,It(r),1),T=x.height>0?x.height+8:0,A=Math.max(O-N,x.width),M=Math.ceil(A+2*c),Y=Math.ceil(U-W+T+2*c),B=`translate(${h(c+(A-(O-N))/2-N)},${h(c+T-W)})`,q=Re(x,M/2,c+x.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="${B}">`+(_?`<g class="pele-graticule" fill="none" stroke="var(--_a)">${_}</g>`:"")+(j?`<path class="pele-axes" d="${j}" fill="none" stroke="var(--_b)"/>`:"")+(H?`<g class="pele-curves" fill-opacity="0.2" stroke-width="1.5" stroke-linejoin="round">${H}</g>`:"")+(Z?`<g class="pele-axis-labels" font-size="${n}">${Z}</g>`:"")+(E?`<g class="pele-legend" font-size="${n}">${E}</g>`:"")+"</g>";return{svg:Je("radar",M,Y,l,r,e,q),width:M,height:Y,links:[]}}var z2,jf,Sc,Uf,qf,Tc,Vf,us,gs,Y2,sn,Gf,B2,U2,q2=Ve(()=>{zt();Xr();ut();wt();z2=32;jf=0,Sc=0;Uf=ur.pattern,qf=/[\t ]*accDescr\s*{/y,Tc=-2;Vf={name:"ID",pattern:/[\w]([-\w]*\w)?/y},us=e=>({name:e,pattern:e,longer:[Vf]}),gs=e=>({name:e,pattern:e}),Y2=[gs("radar-beta:"),{...or("radar-beta"),longer:[Vf]},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},{...ur,match:_T},rr,ar,{name:"NUMBER",pattern:/(?:[0-9]+\.[0-9]+(?!\.))|(?:0|[1-9][0-9]*(?!\.))/y,match:CT},Vr,Vf,Rr,Lr,jt,nr,lr];sn=12,Gf=26,B2=24;U2={type:"radar",parse:(e,t,r)=>TT(NT(e),r),render:DT}});var G2={};Ct(G2,{radar:()=>U2});var j2=Ve(()=>{q2()});function PT(e){let t=[],r=[];for(let a of e){let i=a.type==="Leaf",s={name:a.name,children:i?void 0:[]};for(s.classSelector=a.classSelector,a.cssCompiledStyles&&(s.cssCompiledStyles=a.cssCompiledStyles),i&&a.value!==void 0&&(s.value=a.value);r.length>0&&r[r.length-1].level>=a.level;)r.pop();r.length===0?t.push(s):r[r.length-1].node.children.push(s),i||r.push({node:s,level:a.level})}return t}function zT(e,t){let r=new Map;for(let i of e.TreemapRows){if(i.$type!=="ClassDefStatement")continue;let s=r.get(i.className);s||r.set(i.className,s=[]);let l=(i.styleText??"").replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/§§§/g,",");for(let n of l.split(";"))s.push(n)}let a=[];for(let i of e.TreemapRows){if(i.$type!=="TreemapRow")continue;let s=i.item,l=s.classSelector?r.get(s.classSelector):void 0;a.push({level:i.indent??0,name:s.name,type:s.$type,value:s.$type==="Leaf"?s.value:void 0,classSelector:s.classSelector,cssCompiledStyles:l&&l.length>0?l: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,`
|
|
91
|
+
`):void 0,roots:PT(a),classes:r}}function WT(e){let t=new Zt(Gt(e,V2,"treemap"),V2,"treemap"),r=t.kinds,a={$type:"Treemap",TreemapRows:[]},i=()=>t.accept(5)?t.expect(12):void 0;for(t.expect(3);t.kind!==-1;){let s=t.kind;if(s===0){a.accDescr=Kt(t.take());continue}if(s===1){a.accTitle=Xt(t.take());continue}if(s===2){a.title=Vt(t.take());continue}s!==8&&s!==14&&s!==4&&t.fail("a node, a class definition, or a title");let l=s===8?t.take().length:void 0;if(t.kind===4){let d=FT.exec(t.take()),g={$type:"ClassDefStatement",className:d[1]};d[2]&&(g.styleText=d[2]),l!==void 0&&(g.indent=l),a.TreemapRows.push(g);continue}let n=t.expect(14).slice(1,-1),o=r[t.i]===8?t.i+1:t.i,c;r[o]===6||r[o]===7?(t.i=o+1,t.accept(8),c={$type:"Leaf",name:n,value:parseFloat(t.expect(13).replace(/,/g,""))}):c={$type:"Section",name:n};let f=i();f!==void 0&&(c.classSelector=f);let p={$type:"TreemapRow",item:c};l!==void 0&&(p.indent=l),a.TreemapRows.push(p)}return a}function K2(e){let t="";for(let r=e.length;r>0;r-=3)t=e.slice(Math.max(0,r-3),r)+(t?","+t:"");return t}function BT(e){let t=X2.exec(e==="$0,0"?"$,":e)??X2.exec(","),r=t[1]==="+",a=t[3]!==void 0,i=t[4]===void 0?void 0:Math.min(Number(t[4]),20),s=t[6]??"";return l=>{let n=Math.abs(l),o,c="";if(s==="f"?o=n.toFixed(i??6):s==="%"?(o=(n*100).toFixed(i??6),c="%"):s==="d"?o=Math.round(n).toFixed(0):s==="e"?o=n.toExponential(i??6):o=String(Number(n.toPrecision(Math.max(1,i??12)))),t[5]&&o.includes(".")&&!o.includes("e")&&(o=o.replace(/\.?0+$/,"")),a&&!o.includes("e")){let f=o.indexOf(".");o=f===-1?K2(o):K2(o.slice(0,f))+o.slice(f)}return(l<0?"-":r?"+":"")+(t[2]??"")+o+c}}function Z2(e,t,r){let a=e.children===void 0&&Number.isFinite(e.value)&&e.value>0?e.value:0;return{node:e,parent:t,series:r,value:a,children:[],x:0,y:0,w:0,h:0}}function HT(e,t,r,a,i,s,l){let n=t,o=0;for(;o<e.length;){let c=i*s/n,f=Math.min(i,s),p=e[o].value*c,d=p,g=Math.max(f*f*d/(p*p),p*p/(f*f*d)),u=o+1;for(;u<e.length;){let w=e[u].value*c,v=p+w,k=Math.max(f*f*d/(v*v),v*v/(f*f*w));if(k>g)break;g=k,p=v,u++}let m=p/f,b=0;for(let w=o;w<u;w++){let v=e[w],k=w===u-1?f-b:v.value*c/m,L=i>=s?r:r+b,I=i>=s?a+b:a,N=Math.round(L+l/2),O=Math.round(I+l/2);v.x=N,v.y=O,v.w=Math.round(L+(i>=s?m:k)-l/2)-N,v.h=Math.round(I+(i>=s?k:m)-l/2)-O,b+=k,n-=v.value}i>=s?(r+=m,i-=m):(a+=m,s-=m),o=u}}function YT(e,t,r,a){let i=e.map((p,d)=>Z2(p,void 0,d)),s=i.slice();for(let p=0;p<s.length;p++){let d=s[p];for(let g of d.node.children??[]){let u=Z2(g,d,d.series);d.children.push(u),s.push(u)}}for(let p=s.length-1;p>=0;p--){let d=s[p];d.parent&&(d.parent.value+=d.value)}let{gap:l,header:n,side:o}=a,c=[],f=(p,d,g,u,m)=>{if(u<=0||m<=0)return;let b=p.filter(v=>v.value>0).sort((v,k)=>k.value-v.value),w=0;for(let v of b)w+=v.value;if(!(b.length===0||!Number.isFinite(w))){HT(b,w,d-l/2,g-l/2,u+l,m+l,l);for(let v of b)v.w>0&&v.h>0&&c.push(v)}};f(i,0,0,t,r);for(let p=0;p<c.length;p++){let d=c[p];d.children.length>0&&f(d.children,d.x+o,d.y+n,d.w-2*o,d.h-n-o)}return c}function Ic(e,t,r,a,i){let s=e.treemap?.[t];return typeof s=="number"&&s>=a?Math.min(s,i):r}function UT(e,t,r){let a=r.fontSize??16,i=Math.round(a*.875),s=Math.round(a*.75),l=Math.round(a*.5625),n=r.measurer??et(r.fontFamily),o=t.treemap??{},c=r.padding??Ic(t,"diagramPadding",8,0,2e3),f=Math.round(_i(r,Ic(t,"nodeWidth",64,1,400)*10,200,2*c)),p=Math.round(Ic(t,"nodeHeight",40,1,400)*10),d=o.showValues!==!1,g=BT(typeof o.valueFormat=="string"?o.valueFormat:","),u=YT(e.roots,f,p,{gap:Ic(t,"padding",4,0,200),header:Xf,side:Cc}),m=ze(e.title,!1,n,a,It(r),1),b=m.height>0?m.height+8:0,w=c+Math.max(0,(m.width-f)/2),v=c+b,k="",L="";for(let W of u){let U=W.node,_=vt(U.cssCompiledStyles??[]),j=dt(W.series),Z=w+W.x,H=v+W.y,z=At(U.name).trim(),C=d?g(W.value):"",S=`data-id="${Oe(U.name)}">`,$=`<rect x="${h(Z)}" y="${h(H)}" width="${h(W.w)}" height="${h(W.h)}" fill="${j}"`;if(U.children!==void 0){let A="";if(W.h>=Xf){let Y=W.w-2*Cc-4,B=C?n.width(C,s,0):0,q=B>0&&Y-B-12>=3*i,D=Al(z,q?Y-B-12:Y,i,i,n,1),R=H+Xf/2+1;D&&(A+=`<text x="${h(Z+Cc+2)}" y="${h(R+i*.35)}" font-weight="var(--_hw)"${_.text}>${Xe(D.text)}</text>`),q&&(A+=`<text class="pele-value" x="${h(Z+W.w-Cc-2)}" y="${h(R+s*.35)}" font-size="${s}" text-anchor="end" fill="var(--_m)"${_.text}>${Xe(C)}</text>`)}let M=/[";]fill:/.test(_.shape)?"":' fill-opacity="0.12"';k+=`<g class="pele-node pele-section${_t(U.classSelector??"")}" ${S}${$}${ft(`${M} stroke="${j}"${_.shape}`)}/>${A}</g>`;continue}let y="",E=W.w-8,x=Math.min(a,Math.floor((W.h-4)/_c)),T=x>=l?Al(z,E,x,l,n):void 0;if(T){let A=h(Z+W.w/2),M=H+W.h/2,Y=Math.max(l,Math.round(T.size*.8)),B=(T.size+Y)*_c;if(C&&B<=W.h-4&&n.width(C,Y,0)<=E){let q=M-B/2+T.size*_c/2,D=M+B/2-Y*_c/2;y=`<text x="${A}" y="${h(q+T.size*.35)}" font-size="${h(T.size)}"${_.text}>${Xe(T.text)}</text><text class="pele-value" x="${A}" y="${h(D+Y*.35)}" font-size="${h(Y)}"${_.text}>${Xe(C)}</text>`}else y=`<text x="${A}" y="${h(M+T.size*.35)}" font-size="${h(T.size)}"${_.text}>${Xe(T.text)}</text>`}L+=`<g class="pele-node pele-leaf${_t(U.classSelector??"")}" ${S}${$}${ft(_.shape)}/>${y}</g>`}let I=Math.ceil(Math.max(f,m.width)+2*c),N=Math.ceil(p+b+2*c),O=Re(m,I/2,c+m.height/2,' class="pele-title" font-weight="var(--_tw)"')+(k?`<g class="pele-sections" font-size="${i}">${k}</g>`:"")+(L?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${L}</g>`:"");return{svg:Je("treemap",I,N,a,r,e,O),width:I,height:N,links:[]}}var V2,FT,X2,Xf,Cc,_c,Q2,J2=Ve(()=>{Bf();zt();Xr();ut();wt();V2=[ur,rr,ar,{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}],FT=/classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/;X2=/^(?:.?[<>=^])?([-+( ])?(\$)?0?\d*(,)?(?:\.(\d+))?(~)?([a-zA-Z%])?$/;Xf=28,Cc=6,_c=1.25;Q2={type:"treemap",parse:(e,t,r)=>zT(WT(e),r),render:UT}});var ey={};Ct(ey,{treemap:()=>Q2});var ty=Ve(()=>{J2()});function qT(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,`
|
|
92
|
+
`):void 0}}function GT(e){let t=new Zt(Gt(e,ry,"info"),ry,"info"),r={$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 a=t.kind;if(a===2?r.accDescr=Kt(t.take()):a===3?r.accTitle=Xt(t.take()):a===4?r.title=Vt(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 r}function VT(e,t,r){let a=r.fontSize??16,i=r.measurer??et(r.fontFamily),s=r.padding??8,l=ze(e.title,!1,i,a,4e3,1),n=l.height>0?l.height+8:0,o=ze(`Pele v${jT}`,!1,i,a,4e3),c=Math.ceil(Math.max(l.width,o.width)+2*s),f=Math.ceil(n+o.height+2*s),p=Re(l,c/2,s+l.height/2,' class="pele-title" font-weight="var(--_tw)"')+Re(o,c/2,s+n+o.height/2,' class="pele-version" fill="var(--_m)"');return{svg:Je("info",c,f,a,r,e,p),width:c,height:f,links:[]}}var ry,jT,ay,iy=Ve(()=>{Xr();ut();wt();ry=[or("showInfo"),or("info"),ur,rr,ar,Rr,Lr,jt,nr,lr];jT="1.8.0";ay={type:"info",parse:(e,t,r)=>qT(GT(e),r),render:VT}});var sy={};Ct(sy,{info:()=>ay});var ny=Ve(()=>{iy()});function xy(e){if(e.toLowerCase()==="none")return 4;let t=KT.exec(e);return t?t[1]===void 0?1:t[1]==="%"?2:3:0}function ZT(e,t){let r=xy(e);return r===1||r===2||t&&r===4}function QT(e){let t=e.startsWith("hsl"),r=e.indexOf("("),a=e.slice(0,r);if(a!=="rgb"&&a!=="rgba"&&a!=="hsl"&&a!=="hsla"||e.length>120||e.indexOf(")")!==e.length-1)return!1;let i=e.slice(r+1,-1).trim(),s,l,n=i.includes(",");if(n)s=i.split(",").map(c=>c.trim()),s.length===4&&(l=s.pop());else{let c=i.split("/");if(c.length>2)return!1;s=c[0].trim().split(/\s+/),c.length===2&&(l=c[1].trim())}if(s.length!==3||l!==void 0&&!ZT(l,!n))return!1;let o=s.map(xy);if(n)return t?(o[0]===1||o[0]===3)&&o[1]===2&&o[2]===2:(o[0]===1||o[0]===2)&&o[1]===o[0]&&o[2]===o[0];for(let c=0;c<3;c++){let f=o[c];if(!(f===1||f===4||(t&&c===0?f===3:f===2)))return!1}return!0}function JT(e){return e.includes("(")?QT(e):(ly??(ly=new Set(XT.split(" "))),ly.has(e.toLowerCase()))}function El(e){throw new je(e,"semantic",{type:"sequence"})}function cy(e){let t=e.trim(),r=eC.test(t)?!0:tC.test(t)?!1:void 0;return{text:(r===void 0?t:t.replace(rC,"")).trim(),wrap:r}}function sC(e){let t=aC.exec(e);if(t){let a=e.lastIndexOf(")");if(a>=t[0].length)return oy.test(e.slice(t[0].length))?void 0:[e.slice(0,a+1),e.slice(a+1)]}if(oy.test(e))return;let r=iC.exec(e)[0];return[r,e.slice(r.length)]}function hy(e){return typeof e=="string"?[...e].map((t,r)=>[String(r),t]):e!==null&&typeof e=="object"?Object.entries(e):[]}function lC(e){let t=e.length,r=[],a=[],i=[],s=[],l=0,n=0,o=-1,c=(y,E,x)=>{r.push(y),a.push(e.slice(E,x)),i.push(E),n=x},f=(y,E,x,T)=>{r.push(y),a.push(T),i.push(E),n=x},p=y=>{s.push(l),l=y},d=()=>{s.length>0&&(l=s.pop())},g=y=>(o<y&&(o=e.indexOf(`
|
|
93
|
+
`,y),o===-1&&(o=t)),o),u=(y,E)=>{let x=e.charCodeAt(y);return x<128?(wy[x]&E)!==0:E===4||E===32?!Ue(x):!0},m=(y,E)=>{for(let x=0;x<E.length;x++){let T=E.charCodeAt(x),A=e.charCodeAt(y+x);if(T>=97&&T<=122?(A|32)!==T:A!==T)return!1}return!0},b=y=>m(n,y)&&!Qe(e.charCodeAt(n+y.length)),w=y=>{for(;y<t&&Ue(e.charCodeAt(y));)y++;return y},v=()=>{let y=n;for(;y<t;){let E=e.charCodeAt(y);if(E===10||!Ue(E))break;y++}return y===n?!1:(n=y,!0)},k=y=>{for(;y<t&&u(y,16);)y++;return y},L=(y,E,x)=>{c(y,n,n+E),p(x)},I=(y,E,x=-1)=>b(y)?(c(E,n,n+y.length),x>=0&&p(x),!0):!1,N=(y,E)=>{if(!m(n,y))return!1;let x=n+y.length,T=e.charCodeAt(x);if(T!==32&&T!==9)return!1;for(;T===32||T===9;)T=e.charCodeAt(++x);return x>=t||!u(x,32)?!1:(c(E,n,n+y.length),!0)},O=y=>{let E=e.charCodeAt(y),x=e.charCodeAt(y+1);if(E===45){if(x===120||x===88||x===41||x===92||x===47||x===45)return!0;let T=e.charCodeAt(y+2);return x===124&&(T===92||T===47)}return E===47||E===92?(x===124||x===E)&&e.charCodeAt(y+2)===45:E===40&&x===41},W=()=>{let y=n+1;for(;y<t&&u(y,1);)y++;for(;y<t&&!O(y);){let E=y;for(;e.charCodeAt(E)===45;)E++;if(E>=t||!u(E,2))break;for(E++;E<t&&u(E,2);)E++;y=E}f(48,n,y,e.slice(n,y).trim())},U=()=>{let y=n;for(;pt(e.charCodeAt(y));)y++;let E=y>n;if(e.charCodeAt(y)===46&&pt(e.charCodeAt(y+1))){let T=pt(e.charCodeAt(y+2))?y+3:y+2,A=e.charCodeAt(T);if(A===32||A===10)return c(10,n,T),!0}let x=e.charCodeAt(y);return E&&(x===32||x===10)?(c(10,n,y),!0):!1},_=()=>{let y=e.charCodeAt(n+1),E=e.charCodeAt(n+2);if(y===62)c(E===62?55:53,n,n+(E===62?3:2));else if(y===120||y===88)c(59,n,n+2);else if(y===41)c(61,n,n+2);else if(y===124&&E===92)c(63,n,n+3);else if(y===124&&E===47)c(64,n,n+3);else if(y===92&&E===92)c(65,n,n+3);else if(y===47&&E===47)c(66,n,n+3);else if(y===45){let x=e.charCodeAt(n+3);E===62?c(x===62?57:54,n,n+(x===62?4:3)):E===120||E===88?c(60,n,n+3):E===41?c(62,n,n+3):E===124&&x===92?c(67,n,n+4):E===124&&x===47?c(68,n,n+4):E===92&&x===92?c(69,n,n+4):E===47&&x===47?c(70,n,n+4):c(46,n,n+1)}else c(46,n,n+1)},j=y=>{let E=e.charCodeAt(n+1);if(E!==124&&E!==y||e.charCodeAt(n+2)!==45)return!1;let x=e.charCodeAt(n+3)===45,T=y===47,A;return E===124?x?A=T?75:76:A=T?71:72:x?A=T?77:78:A=T?73:74,c(A,n,n+(x?4:3)),!0},Z=()=>{if(!m(n,"title"))return!1;let y=n+5,E=e.charCodeAt(y)===58;return E&&y++,!Ue(e.charCodeAt(y))||y+1>=t||!u(y+1,16)?!1:(c(E?15:14,n,k(y+1)),!0)},H=()=>{let y=m(n,"accdescr");if(!y&&!m(n,"acctitle"))return!1;let E=w(n+8),x=e.charCodeAt(E);return x===58?(c(y?18:16,n,w(E+1)),p(y?6:5),!0):y&&x===123?(n=w(E+1),p(7),!0):!1},z=y=>{switch(y|32){case 97:return I("actor",34,1)||I("alt",24,3)||I("and",30,3)||I("activate",12,1)||H()||I("autonumber",9);case 98:return I("box",6,3)||I("break",28,3);case 99:return I("create",5)||I("critical",27,3);case 100:return I("destroy",35,1)||N("details",41)||I("deactivate",13,1);case 101:return I("else",31,3)||I("end",8);case 108:return I("loop",21,3)||I("left of",43)||N("links",38)||N("link",39);case 110:return I("note",36);case 111:return I("opt",23,3)||I("option",29,3)||I("over",37)||I("off",11);case 112:return I("participant",32,1)||I("par",25,3)||I("par_over",26,3)||N("properties",40);case 114:return I("rect",22,3)||I("right of",44);case 115:return I("sequencediagram",4);case 116:return Z();default:return!1}},C=()=>{let y=e.charCodeAt(n);if(y===10){let E=n+1;for(;e.charCodeAt(E)===10;)E++;c(3,n,E);return}if(Ue(y)){n=w(n+1);return}if(y===35||y===37&&e.charCodeAt(n+1)!==123){n=g(n);return}if(y!==125&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)===37){n=g(n);return}if(!((pt(y)||y===46)&&U())&&!(y<128&&(y|32)>=97&&(y|32)<=122&&z(y)))if(y===44)c(42,n,n+1);else if(y===59)c(3,n,n+1);else if(u(n,1))W();else if(y===45)_();else if(y===60&&e.startsWith("<<->>",n))c(56,n,n+5);else if(y===60&&e.startsWith("<<-->>",n))c(58,n,n+6);else{if((y===47||y===92)&&j(y))return;y===58?c(52,n,k(n+1)):y===43?c(45,n,n+1):y===40&&e.charCodeAt(n+1)===41?c(47,n,n+2):c(2,n,n+1)}},S=()=>{if(v())return!0;let y=e.charCodeAt(n);if(y===35)return n=g(n),!0;if(y===64&&e.charCodeAt(n+1)===123)return L(49,2,4),!0;let E=n;for(;E<t&&u(E,4);)E++;if(E>n){let T=w(E);if(e.charCodeAt(T)===64&&e.charCodeAt(T+1)===123)return c(48,n,E),!0;if(T>E&&m(T,"as")&&Ue(e.charCodeAt(T+2)))return c(48,n,E),p(2),!0}let x=E;for(;x<t&&u(x,8);)x++;if(x>n){let T=e.charCodeAt(x),A=x;if(x<t&&T!==10&&T!==59)for(A--;A>n&&e.charCodeAt(A)!==35;)A--;if(A>n)return f(48,n,A,e.slice(n,A).trim()),d(),!0}if(e.charCodeAt(x)===60)return c(2,n,g(n)),d(),!0;if(y!==10){let T=g(n);return f(2,n,T,e.slice(n,T).trim()),d(),!0}return!1},$=()=>{switch(l){case 0:return C(),!0;case 1:return S();case 2:return v()?!0:e.charCodeAt(n)===35?(n=g(n),!0):(d(),d(),b("as")?L(33,2,3):c(3,n,n),!0);case 3:return v()?!0:e.charCodeAt(n)===35?(n=g(n),!0):(c(7,n,k(n)),d(),!0);case 4:if(e.charCodeAt(n)!==125){let y=e.indexOf("}",n);return y===-1&&(y=t),c(50,n,y),!0}else{let y=w(n+1),E=y>n+1&&m(y,"as")&&Ue(e.charCodeAt(y+2));return c(51,n,n+1),d(),E?p(2):d(),!0}case 5:case 6:return c(l===5?17:19,n,g(n)),d(),!0;default:if(e.charCodeAt(n)===125)n++,d();else{let y=e.indexOf("}",n);y===-1&&(y=t),c(20,n,y)}return!0}};for(;n<t;)if(!$())return r.push(1),a.push(""),i.push(n),{types:r,texts:a,starts:i};return l===0||l===2?c(3,t,t):l===3?c(7,t,t):l===5?c(17,t,t):l===6?c(19,t,t):l===7&&c(20,t,t),r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function cC(e,t){let{types:r,texts:a,starts:i}=lC(e),s=0,l=k=>{let L=r[s];throw L===1?it("sequence",e,i[s],"",!0):it("sequence",e,i[s],`Expecting ${k}, got '${dy[L]}'`)},n=k=>(r[s]!==k&&l(`'${dy[k]}'`),a[s++]),o=()=>{let k=r[s];return k!==48&&k!==39&&l("'ACTOR'"),{type:"addParticipant",actor:a[s++]}},c=()=>t.parseMessage(n(52).trim().substring(1)),f=()=>{let k=r[s++];if(k===35){let I=o();return n(3),I.type="destroyParticipant",I}let L=o();if(r[s]===49&&r[s-1]===48){s++;let I=n(50);n(51),L.config=I.trim()}if(L.draw=k===32?"participant":"actor",r[s]===33){s++;let I=n(7);n(3),L.description=t.parseMessage(I)}else r[s]===3?s++:l("'AS', 'NEWLINE'");return L},p=k=>{let L=!1;r[s]===47&&(L=!0,s++);let I=Yt[r[s]];I<0&&l(oC),s++;let N=r[s];(N===47||!L&&(N===45||N===46))&&s++;let O=o(),W=c(),U={type:"addMessage",from:k.actor,to:O.actor,signalType:I,msg:W},_=[k,O,U];if(L){let j=N===47;U.activate=j,U.centralConnection=j?61:60,j&&_.push({type:"centralConnection",signalType:59,actor:O.actor}),_.push({type:"centralConnectionReverse",signalType:60,actor:k.actor})}else N===45?(U.activate=!0,_.push({type:"activeStart",signalType:17,actor:O.actor})):N===46?_.push({type:"activeEnd",signalType:18,actor:k.actor}):N===47&&(U.activate=!0,U.centralConnection=59,_.push({type:"centralConnection",signalType:59,actor:O.actor}));return _},d=k=>{s++;let L=o();return[L,{type:k,actor:L.actor,text:c()}]},g=()=>{s++;let k=r[s];if(k===37){s++;let N=o(),O=N,W=[N.actor,N.actor];if(r[s]===42){s++;let U=o();O=[N,U],W=[N.actor,U.actor]}return[O,{type:"addNote",placement:2,actor:W,text:c()}]}k!==43&&k!==44&&l("'over', 'left_of', 'right_of'"),s++;let L=o();return[L,{type:"addNote",placement:k===43?0:1,actor:L.actor,text:c()}]},u=()=>{s++;let k={type:"sequenceIndex",sequenceVisible:!0,signalType:26};return r[s]===10?(k.sequenceIndex=Number(a[s++]),k.sequenceIndexStep=r[s]===10?Number(a[s++]):1):r[s]===11&&(s++,k.sequenceVisible=!1),r[s]!==3&&l("'NEWLINE', 'NUM', 'off'"),s++,k},m=(k,L,I,N)=>{let O=k.list,W=k.sections;if(W)for(let U=W.length-2;U>=0;U-=2){let _={type:L,signalType:N};_[I]=t.parseMessage(W[U+1]),O=W[U].concat([_,O])}return O},b=k=>{let L=k.text,I=k.list;switch(k.kind){case 1:I[0]={type:"boxStart",boxData:t.parseBoxData(L)},I.push({type:"boxEnd",boxText:L});break;case 2:I[0]={type:"loopStart",loopText:t.parseMessage(L),signalType:10},I.push({type:"loopEnd",loopText:L,signalType:11});break;case 3:I[0]={type:"rectStart",color:t.parseMessage(L),signalType:22},I.push({type:"rectEnd",color:t.parseMessage(L),signalType:23});break;case 4:I[0]={type:"optStart",optText:t.parseMessage(L),signalType:15},I.push({type:"optEnd",optText:t.parseMessage(L),signalType:16});break;case 5:I[0]={type:"breakStart",breakText:t.parseMessage(L),signalType:30},I.push({type:"breakEnd",optText:t.parseMessage(L),signalType:31});break;case 6:I=m(k,"else","altText",13),I[0]={type:"altStart",altText:t.parseMessage(L),signalType:12},I.push({type:"altEnd",signalType:14});break;case 7:I=m(k,"and","parText",20),I[0]={type:"parStart",parText:t.parseMessage(L),signalType:k.startType},I.push({type:"parEnd",signalType:21});break;default:I=m(k,"option","optionText",28),I[0]={type:"criticalStart",criticalText:t.parseMessage(L),signalType:27},I.push({type:"criticalEnd",signalType:29})}return I};for(;r[s]===3;)s++;n(4);let w=[],v={kind:0,text:"",startType:0,list:[],sections:void 0};for(;;){let k=r[s],L=v.list;if(v.kind===1){if(k===32||k===34||k===35)L.push(f());else if(k===3)L.push([]),s++;else if(k===8){s++;let I=b(v);v=w.pop(),v.list.push(I)}else l("'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'");continue}switch(k){case 3:case 2:L.push([]),s++;break;case 32:case 34:case 35:L.push(f());break;case 5:{s++;let I=r[s];I!==32&&I!==34&&I!==35&&l("'participant', 'participant_actor', 'destroy'");let N=f();N.type="createParticipant",L.push(N);break}case 48:L.push(p(o())),n(3);break;case 39:{let I=r[s+1];L.push(I===48||I===39?d("addALink"):p(o())),n(3);break}case 38:L.push(d("addLinks")),n(3);break;case 40:L.push(d("addProperties")),n(3);break;case 41:L.push(d("addDetails")),n(3);break;case 36:L.push(g()),n(3);break;case 9:L.push(u());break;case 12:case 13:{s++;let I=o();n(3),L.push(k===12?{type:"activeStart",signalType:17,actor:I.actor}:{type:"activeEnd",signalType:18,actor:I.actor});break}case 14:case 15:{let I=a[s++].substring(k===14?6:7);t.setDiagramTitle(I),L.push(I);break}case 16:{s++;let I=n(17).trim();t.setAccTitle(I),L.push(I);break}case 18:{s++;let I=n(19).trim();t.setAccDescription(I),L.push(I);break}case 20:{let I=a[s++].trim();t.setAccDescription(I),L.push(I);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{s++;let I=n(7);w.push(v),v={kind:Za[k],text:I,startType:k===26?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{v.kind!==(k===31?6:k===30?7:8)&&l("'end'"),s++;let I=n(7);(v.sections??(v.sections=[])).push(L,I),v.list=[];break}case 8:{v.kind===0&&l("'NEWLINE', 'EOF'"),s++;let I=b(v);v=w.pop(),v.list.push(I);break}case 0:v.kind!==0&&l("'end'"),t.apply(L);return;default:l("'NEWLINE', 'ACTOR', 'participant', 'note', 'end'")}}}function uC(e){return fC.has(e)?e:"participant"}function Qf(e){return pC.has(e)}function gC(e,t,r,a,i=hC){if(Qf(e))return{w:Math.max(40,t.width+8),h:by+(t.height>0?$y+t.height:0)};let s=e==="collections"?xs:e==="queue"?2*ys:0;return{w:Math.max(r,t.width+2*i)+s,h:Math.max(a,t.height+2*dC)+(e==="collections"?xs:0)}}function mC(e,t,r){let a=h(t),i=s=>h(r+s);switch(e){case"actor":return`<circle cx="${a}" cy="${i(7)}" r="6"${wi}/><path d="M${a},${i(13)}V${i(24)}M${h(t-10)},${i(17)}H${h(t+10)}M${h(t-8)},${i(34)}L${a},${i(24)}L${h(t+8)},${i(34)}"${on}/>`;case"boundary":return`<path d="M${h(t-19)},${i(6)}V${i(28)}M${h(t-19)},${i(17)}H${h(t-8)}"${on}/><circle cx="${h(t+3)}" cy="${i(17)}" r="11"${wi}/>`;case"control":return`<circle cx="${a}" cy="${i(21)}" r="11"${wi}/><path d="M${h(t+5)},${i(5)}L${h(t-1)},${i(10)}L${h(t+5)},${i(15)}"${on}/>`;case"entity":return`<circle cx="${a}" cy="${i(15)}" r="11"${wi}/><path d="M${h(t-11)},${i(30)}H${h(t+11)}"${on}/>`;default:{let s=h(t-14),l=h(t+14);return`<path d="M${s},${i(7)}V${i(27)}A14,5 0 0 0 ${l},${i(27)}V${i(7)}A14,5 0 0 0 ${s},${i(7)}Z"${wi}/><path d="M${s},${i(7)}A14,5 0 0 0 ${l},${i(7)}"${on}/>`}}}function yC(e,t,r,a,i,s){let{w:l,h:n}=a,o=' class="pele-label"';if(Qf(e))return mC(e,t,r)+Re(i,t,r+by+$y+i.height/2,o,s);let c=t-l/2;if(e==="collections"){let f=l-xs,p=n-xs,d=`<rect x="${h(c+xs)}" y="${h(r)}" width="${h(f)}" height="${h(p)}"${wi}${st}/>`,g=`<rect x="${h(c)}" y="${h(r+xs)}" width="${h(f)}" height="${h(p)}"${wi}${st}/>`;return d+g+Re(i,c+f/2,r+xs+p/2,o,s)}if(e==="queue"){let f=h(c+ys),p=h(c+l-ys),d=h(r+n),g=h(n/2);return`<path d="M${f},${h(r)}H${p}A${ys},${g} 0 0 1 ${p},${d}H${f}A${ys},${g} 0 0 1 ${f},${h(r)}Z"${wi}/><path d="M${p},${h(r)}A${ys},${g} 0 0 0 ${p},${d}"${on}/>`+Re(i,t-ys/2,r+n/2,o,s)}return`<rect x="${h(c)}" y="${h(r)}" width="${h(l)}" height="${h(n)}"${wi}${st}/>`+Re(i,t,r+n/2,o,s)}function Ar(e,t,r,a=1,i=!1){Jf[e]={dotted:t,head:r,atStart:a!==1,atEnd:a!==0,bottom:i}}function Zf(e){return e!==void 0&&Jf[e]!==void 0}function AC(e,t){let r=new Array(e.length),a=new Array(e.length),i=1,s=1,l=!1;for(let n=0;n<e.length;n++){let o=e[n];if(r[n]=NaN,a[n]=!1,o.type===26){let c=o.message;i=c.start||i,s=c.step||s,l=c.visible}else Zf(o.type)&&(r[n]=i,a[n]=l||t,i=Math.round((i+s)*100)/100)}return{index:r,shown:a,visible:l}}function ms(e,t,r){let a=e[t];return typeof a=="number"&&a>=0&&a<=2e3?a:r}function yy(e,t,r,a,i){let s=h(e-r*Ht);return i?`<path class="pele-marker" d="M${h(e)},${h(t)}L${s},${h(t+a*5)}"/>`:`<path class="pele-marker" d="M${h(e)},${h(t)}L${s},${h(t+a*4.5)}V${h(t)}Z" fill="var(--_l)" stroke="none"/>`}function Lc(e,t,r,a,i){switch(e){case 1:return bt("arrow_point",t,r,a,0,"var(--_l)");case 2:return bt("arrow_cross",t,r,a,0,"var(--_l)");case 3:return`<path class="pele-marker" d="M${h(t-a*Ht)},${h(r-4.5)}L${h(t)},${h(r)}L${h(t-a*Ht)},${h(r+4.5)}" stroke-linejoin="round"/>`;case 4:return yy(t,r,a,i,!1);case 5:return yy(t,r,a,i,!0);default:return""}}function vC(e){return e===1?Ht-1:e===2?4:0}function EC(e,t,r){return Nr(r,a=>SC(e,t,r,a))}function SC(e,t,r,a){let i=t.sequence??{},s=r.fontSize??16,l=Math.round(s*.875),n=Math.round(s*.75),o=r.measurer??et(r.fontFamily),c=r.icons,f=r.padding??8,p=i.mirrorActors!==!1,d=i.rightAngles===!0,g=Math.min(ms(i,"actorMargin",40),a?8:1/0),u=Math.min(ms(i,"width",64),a?48:1/0),m=ms(i,"height",Math.round(s*1.5)+20),b=Math.min(ms(i,"width",160),a?Math.max(32,((r.maxWidth??320)-2*f)/Math.max(1,e.actors.size)-g-24):1/0),w=Math.max(4,14+ms(i,"messageMargin",35)-35),v=Math.min(ms(i,"noteMargin",10),a?6:1/0),k=Math.min(ms(i,"boxMargin",10),a?6:1/0),L=i.messageAlign==="left"?-1:i.messageAlign==="right"?1:0,I=a?6:wC,N=a?8:$C,O=a?12:kC,W=a?6:MC,U=e.messages,_=U.length,j=AC(U,i.showSequenceNumbers===!0),Z=(V,me,ae,$e=b,ve=0)=>{let Te=ze(V,!1,o,me,a||ae?$e:1/0,ve);return a?fs(Te,o,Math.max(120,$e)):Te},H;if(i.hideUnusedParticipants===!0){H=new Set;for(let V of U)H.add(V.from).add(V.to)}let z=new Int32Array(_+1);z[_]=-1;for(let V=_-1;V>=0;V--)z[V]=Zf(U[V].type)?V:z[V+1];let C=[],S=new Map;for(let[V,me]of e.actors){if(H&&!H.has(V))continue;let ae=uC(me.type),$e=Z(me.description,s,me.wrap),ve=e.createdActors.get(V),Te=e.destroyedActors.get(V),De=ve===void 0?-1:z[Math.min(ve,_)];De>=0&&U[De].to!==V&&(De=-1);let _e=Te===void 0?-1:z[Math.min(Te,_)];_e>=0&&U[_e].to!==V&&U[_e].from!==V&&(_e=-1),S.set(V,C.length),C.push({id:V,actor:me,kind:ae,label:$e,size:gC(ae,$e,u,m,a?8:void 0),x:0,createAt:De,destroyAt:_e,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let $=C.length-1,y=new Map,E=(V,me,ae)=>{if(V<0||me>$)return;let $e=V*C.length+me;(y.get($e)??0)<ae&&y.set($e,ae)},x=V=>j.shown[V]?Math.max(Rc,o.width(String(j.index[V]),n,0)+8):0,T=new Array(_);for(let V=0;V<_;V++){let me=U[V],ae=me.from===void 0?void 0:S.get(me.from),$e=me.to===void 0?void 0:S.get(me.to);if(!(ae===void 0||$e===void 0||typeof me.message!="string")){if(me.type===2){let ve=Z(me.message,l,me.wrap),Te=ve.width+2*v;me.placement===0?E(ae-1,ae,Te+2*nn+La):me.placement===1?E(ae,ae+1,Te+2*nn+La):ae===$e?(E(ae-1,ae,Te/2+nn),E(ae,ae+1,Te/2+nn)):E(Math.min(ae,$e),Math.max(ae,$e),Te-2*N),T[V]={kind:2,a:ae,b:$e,label:ve,x:0,w:Te}}else if(Zf(me.type)){let ve=Z(me.message,l,me.wrap),Te=x(V);if(ae===$e)E(ae,ae+1,Kf+8+ve.width+16+La+Te),T[V]={kind:1,a:ae,b:$e,label:ve,x:0,w:0};else{let De=C[$e].createAt===V?C[$e].size.w/2:0,_e=me.centralConnection?4*ln:0;E(Math.min(ae,$e),Math.max(ae,$e),(a?Math.min(ve.width,Math.max(16,b-16)):ve.width)+2*I+La+Te+De+_e),T[V]={kind:0,a:ae,b:$e,label:ve,x:0,w:0}}}}}let A=[];for(let V=0;V<=$;V++){let me=C[V].actor.box,ae=A[A.length-1];me&&ae&&ae.box===me&&ae.last===V-1?ae.last=V:me&&A.push({box:me,first:V,last:V,title:Z(me.name,l,me.wrap),grow:0})}let M=new Array(Math.max($,0));for(let V=0;V<$;V++){let me=C[V],ae=C[V+1],$e=me.actor.box!==ae.actor.box?(me.actor.box?k:0)+(ae.actor.box?k:0):0;M[V]=Math.max(me.size.w/2+ae.size.w/2+g+$e,y.get(V*C.length+V+1)??0)}let Y=[];for(let[V,me]of y){let ae=Math.floor(V/C.length),$e=V%C.length;$e-ae>1&&Y.push([ae,$e,me])}Y.sort((V,me)=>V[1]-V[0]-(me[1]-me[0])||V[0]-me[0]);for(let[V,me,ae]of Y){let $e=0;for(let Te=V;Te<me;Te++)$e+=M[Te];if($e>=ae)continue;let ve=(ae-$e)/(me-V);for(let Te=V;Te<me;Te++)M[Te]+=ve}let B=()=>{for(let V=1;V<=$;V++)C[V].x=C[V-1].x+M[V-1]};B();for(let V of A){let me=C[V.last].x+C[V.last].size.w/2-(C[V.first].x-C[V.first].size.w/2);V.grow=Math.max(0,(V.title.width-me)/2),V.grow!==0&&(V.first>0&&(M[V.first-1]+=V.grow),V.last<$&&(M[V.last]+=V.grow))}B();let q=1/0,D=-1/0,R=(V,me)=>{V<q&&(q=V),me>D&&(D=me)};for(let V of C)R(V.x-V.size.w/2,V.x+V.size.w/2);for(let V of A)R(C[V.first].x-C[V.first].size.w/2-k-V.grow,C[V.last].x+C[V.last].size.w/2+k+V.grow);let P=new Array(_),G=[],X=()=>$<0?[0,120]:[C[0].x-O,C[$].x+O];for(let V=0;V<_;V++){let me=U[V],ae=me.type,$e=ae===void 0?void 0:xC.get(ae),ve=T[V];if($e!==void 0){let Te={kind:$e,x0:1/0,x1:-1/0,top:0,title:my,tabW:0,fill:$e==="rect"&&typeof me.message=="string"?me.message:"",dividers:[V],dividerY:[],dividerLabels:[]};P[V]=Te,G.push(Te)}else if(ae===13||ae===20||ae===28)G[G.length-1]?.dividers.push(V);else if(ae===11||ae===14||ae===16||ae===21||ae===29||ae===31||ae===23){let Te=G.pop();if(!Te)continue;if(P[V]=Te,Te.x0>Te.x1&&([Te.x0,Te.x1]=X()),Te.kind!=="rect"){Te.tabW=o.width(Te.kind,n,1)+14;for(let _e=0;_e<Te.dividers.length;_e++){let He=U[Te.dividers[_e]].message,Ee=_e===0?Te.tabW+8:0,qe=Te.x1-Te.x0-16-Ee,Ge=He?Z(`[${He}]`,l,!0,Math.max(qe,a?Math.min(uy,b):uy)):my;Ge.width>qe&&(Te.x1+=Ge.width-qe),_e===0?Te.title=Ge:Te.dividerLabels.push(Ge)}}R(Te.x0,Te.x1);let De=G[G.length-1];De&&(De.x0=Math.min(De.x0,Te.x0-W),De.x1=Math.max(De.x1,Te.x1+W))}else if(ve){let Te=C[ve.a],De=C[ve.b],_e,He;if(ve.kind===2){if(me.placement===0)ve.x=Te.x-nn-ve.w;else if(me.placement===1)ve.x=Te.x+nn;else if(ve.a===ve.b)ve.x=Te.x-ve.w/2;else{let qe=Math.min(Te.x,De.x)-N,Ge=Math.max(Te.x,De.x)+N;(a||me.wrap)&&(ve.label=Z(me.message,l,!0,Math.max(b,Ge-qe-2*v))),ve.w=Math.max(Ge-qe,ve.label.width+2*v),ve.x=(qe+Ge-ve.w)/2}_e=ve.x,He=ve.x+ve.w}else ve.kind===1?(_e=Te.x,He=Te.x+La+Kf+8+ve.label.width+x(V)):(_e=Math.min(Te.x,De.x),He=Math.max(Te.x,De.x),(a||me.wrap)&&(ve.label=Z(me.message,l,!0,Math.max(b,He-_e-2*I-La))),De.createAt===V&&(De.x>Te.x?He+=De.size.w/2:_e-=De.size.w/2));R(_e,He);let Ee=G[G.length-1];Ee&&(Ee.x0=Math.min(Ee.x0,_e-O),Ee.x1=Math.max(Ee.x1,He+O))}}let Q=0;for(let V of A)Q=Math.max(Q,V.title.height);let J=A.length>0?k+(Q>0?Q+4:0):0,F=0;for(let V of C)V.createAt<0&&(F=Math.max(F,V.size.h));let K=J+F;for(let V of C)V.top=K-V.size.h,V.lifeStart=K;let re=C.map(V=>V.x),ne=(V,me)=>{let ae=0,$e=re.length;for(;ae<$e;){let ve=ae+$e>>1;re[ve]<=V?ae=ve+1:$e=ve}return ae<re.length&&re[ae]<me},de=(V,me,ae,$e)=>{if(V.width===0)return"";let ve=me-V.width/2;return(ne(ve,ve+V.width)?`<rect x="${h(ve-3)}" y="${h(ae-V.height/2+2)}" width="${h(V.width+6)}" height="${h(V.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:"")+Re(V,me,ae,$e,c)},ie=(V,me=0)=>V.activations.length+me>0?V.x-La/2:V.x,se=(V,me=0)=>{let ae=V.activations.length+me;return ae>0?V.x+La/2+(ae-1)*py:V.x},ee=[],te=[],fe="",ye="",le="",we="",pe="",ge="",Ae=(V,me)=>{let ae=V.activations.pop(),$e=Math.max(me,ae+bC),ve=V.x-La/2+V.activations.length*py;return R(ve,ve+La),te.push(`<rect class="pele-activation" data-id="${Oe(V.id)}" x="${h(ve)}" y="${h(ae)}" width="${La}" height="${h($e-ae)}" rx="2"/>`),$e},Se=(V,me)=>{let ae=V.x,$e=me+16;return V.lifeEnd=$e,ge+=`<path class="pele-destroy" data-id="${Oe(V.id)}" d="M${h(ae-6)},${h($e-6)}L${h(ae+6)},${h($e+6)}M${h(ae+6)},${h($e-6)}L${h(ae-6)},${h($e+6)}"/>`,$e+6},oe=(V,me,ae)=>{let $e=V.actor.properties.get("class");return`<g class="pele-node pele-actor pele-actor-${V.kind}${ae?" pele-actor-footer":""}${typeof $e=="string"?_t($e):""}" data-id="${Oe(V.id)}">`+yC(V.kind,V.x,me,V.size,V.label,c)+"</g>"},ue=(V,me,ae,$e)=>`<g class="pele-sequence-number"><rect x="${h(me-$e/2)}" y="${h(ae-Rc/2)}" width="${h($e)}" height="${Rc}" rx="${Rc/2}" fill="var(--_l)" stroke="none"/><text x="${h(me)}" y="${h(ae+n*.35)}" text-anchor="middle" font-size="${n}" fill="var(--_bg)" stroke="none">${Xe(String(j.index[V]))}</text></g>`,xe=K+6,Ie=[];for(let V=0;V<_;V++){let me=U[V],ae=me.type,$e=T[V],ve=P[V];if(ae===17){let Te=me.from===void 0?void 0:S.get(me.from);Te!==void 0&&C[Te].activations.push(xe)}else if(ae===18){let Te=me.from===void 0?void 0:S.get(me.from);Te!==void 0&&C[Te].activations.length>0&&(xe=Math.max(xe,Ae(C[Te],xe)))}else if(ve&&ve.dividers[0]===V)Ie.push(ve),ve.kind==="rect"?(ve.top=xe+8,xe=ve.top):(ve.top=xe+12,xe=ve.top+Math.max(Nc,ve.title.height+2));else if(ve){Ie.pop();let Te=xe+12,De=h(ve.x0),_e=h(ve.x1-ve.x0);if(ve.kind==="rect"){let He=ve.fill?vt([`fill:${ve.fill}`]).shape:"";ee.push(`<rect class="pele-rect" x="${De}" y="${h(ve.top)}" width="${_e}" height="${h(Te-ve.top)}"${ft((He?"":' fill-opacity="0.5"')+He)}/>`)}else{let He=`<rect x="${De}" y="${h(ve.top)}" width="${_e}" height="${h(Te-ve.top)}" fill="none"${st}/>`;for(let Ee=0;Ee<ve.dividerY.length;Ee++){let qe=ve.dividerY[Ee],Ge=ve.dividerLabels[Ee];He+=`<path d="M${De},${h(qe)}H${h(ve.x1)}"${gy}/>`+de(Ge,ve.x0+8+Ge.width/2,qe+2+Ge.height/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"')}He+=`<rect x="${De}" y="${h(ve.top)}" width="${h(ve.tabW)}" height="${Nc}" fill="var(--_s)"${st}/><text class="pele-frame-kind" x="${h(ve.x0+ve.tabW/2)}" y="${h(ve.top+Nc/2+n*.35)}" text-anchor="middle" font-size="${n}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${ve.kind}</text>`+de(ve.title,ve.x0+ve.tabW+8+ve.title.width/2,ve.top+Math.max(Nc,ve.title.height)/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"'),fe+=`<g class="pele-frame pele-frame-${ve.kind}">${He}</g>`}xe=Te}else if(ae===13||ae===20||ae===28){let Te=Ie[Ie.length-1];if(Te){let De=Te.dividerLabels[Te.dividerY.length];Te.dividerY.push(xe+12),xe+=12+(De.height>0?De.height:0)}}else if($e&&$e.kind===2){let Te=C[$e.a],De=$e.label.height+2*Math.max(4,v-4),_e=xe+10,He=$e.x;me.placement===1?He+=se(Te)-Te.x:me.placement===0&&(He+=ie(Te)-Te.x),R(He,He+$e.w),we+=`<g class="pele-note" data-id="i${Oe(me.id)}"><rect x="${h(He)}" y="${h(_e)}" width="${h($e.w)}" height="${h(De)}"${st}/>`+Re($e.label,He+$e.w/2,_e+De/2,' class="pele-label" stroke="none" fill="var(--_fg)"',c)+"</g>",xe=_e+De}else if($e){let Te=Jf[ae],De=C[$e.a],_e=C[$e.b],He=$e.label,Ee=x(V),qe=0;for(let Ye=V+1;Ye<_;Ye++){let ht=U[Ye].type;if(ht===17)U[Ye].from===me.to&&qe++;else if(ht!==18&&ht!==59&&ht!==60)break}let Ge=Te.bottom?1:-1,rt=Te.dotted?gy:"",ct=me.centralConnection,tt=ct===59||ct===61,lt=ct===60||ct===61,nt=(Ye,ht)=>`<circle class="pele-central" cx="${h(Ye)}" cy="${h(ht)}" r="${ln}" fill="var(--_l)" stroke="none"/>`,Wt=Te.atStart&&!Te.atEnd,Tt=vC(Te.head),kt="",Ft;if($e.kind===1){let Ye=xe+w+Math.max(0,(He.height-fy)/2),ht=Ye+fy,yt=lt?De.x+ln:se(De),ot=tt?De.x+ln:se(De,qe),er=Math.max(yt,ot)+Kf+Ee/2;lt&&(kt+=nt(De.x,Ye)),tt&&(kt+=nt(De.x,ht)),Ee>0&&(kt+=ue(V,Wt?ot:yt,Wt?ht:Ye,Ee),Wt?ot+=Ee/2:yt+=Ee/2);let Et=(Te.atStart?Lc(Te.head,yt,Ye,-1,Ge):"")+(Te.atEnd?Lc(Te.head,ot,ht,-1,-Ge):""),Ze=h(yt+(Te.atStart?Tt:0)),xt=h(ot+(Te.atEnd?Tt:0));kt=`<path d="${d?`M${Ze},${h(Ye)}H${h(er)}V${h(ht)}H${xt}`:`M${Ze},${h(Ye)}H${h(er-6)}A6,6 0 0 1 ${h(er)},${h(Ye+6)}V${h(ht-6)}A6,6 0 0 1 ${h(er-6)},${h(ht)}H${xt}`}"${rt}/>`+Et+kt,R(De.x,er+8+He.width),He.width>0&&(le+=`<g class="pele-edge-label" data-id="i${Oe(me.id)}">${Re(He,er+8+He.width/2,(Ye+ht)/2,"",c)}</g>`),Ft=Math.max(ht,(Ye+ht)/2+He.height/2)}else{let Ye=_e.x>De.x?1:-1,ht=_e.createAt===V;Ft=xe+w+Math.max(He.height>0?He.height+2:6,ht?_e.size.h/2-w+6:0);let yt=Ye>0?se(De):ie(De),ot=Ye>0?ie(_e,qe):se(_e,qe);if(ht&&(_e.top=Ft-_e.size.h/2,_e.lifeStart=_e.top+_e.size.h,ot=_e.x-Ye*(Qf(_e.kind)?18:_e.size.w/2+1)),lt&&(kt+=nt(De.x,Ft),yt=De.x+Ye*ln),tt&&(kt+=nt(_e.x,Ft),ot=_e.x-Ye*ln),Ee>0)if(Wt){let xt=tt?ot-Ye*(Ee/2+2):ot;kt+=ue(V,xt,Ft,Ee),ot=xt-Ye*Ee/2}else{let xt=lt?yt+Ye*(Ee/2+2):yt;kt+=ue(V,xt,Ft,Ee),yt=xt+Ye*Ee/2}let er=(Te.atStart?Lc(Te.head,yt,Ft,-Ye,Ge*Ye):"")+(Te.atEnd?Lc(Te.head,ot,Ft,Ye,Ge*Ye):""),Et=yt+(Te.atStart?Ye*Tt:0),Ze=ot-(Te.atEnd?Ye*Tt:0);if(kt=`<path d="M${h(Et)},${h(Ft)}H${h(Ze)}"${rt}/>`+er+kt,He.width>0){let xt=Math.min(yt,ot),Dt=Math.max(yt,ot),Nt=L<0?xt+I+He.width/2:L>0?Dt-I-He.width/2:(xt+Dt)/2;R(Nt-He.width/2,Nt+He.width/2),le+=`<g class="pele-edge-label" data-id="i${Oe(me.id)}">${de(He,Nt,Ft-4-He.height/2,"")}</g>`}ht&&(xe=Ft+_e.size.h/2-6)}ye+=`<g class="pele-edge pele-message" data-id="i${Oe(me.id)}">${kt}</g>`,xe=Math.max(xe,Ft),De.destroyAt===V&&(xe=Math.max(xe,Se(De,Ft))),_e.destroyAt===V&&_e!==De&&(xe=Math.max(xe,Se(_e,Ft)))}}xe+=20;for(let V of C)for(;V.activations.length>0;)Ae(V,xe);let Le=xe;if(p){let V=0;for(let me of C)me.lifeEnd>=0||(V=Math.max(V,me.size.h),pe+=oe(me,xe,!0));Le=xe+V}let We="";for(let V of C){pe+=oe(V,V.top,!1);let me=V.lifeEnd>=0?V.lifeEnd:xe;me>V.lifeStart&&(We+=`<path class="pele-lifeline" data-id="${Oe(V.id)}" d="M${h(V.x)},${h(V.lifeStart)}V${h(me)}"/>`)}let he="";for(let V of A){let me=C[V.first].x-C[V.first].size.w/2-k-V.grow,ae=C[V.last].x+C[V.last].size.w/2+k+V.grow,$e=V.box.fill==="transparent"?"":vt([`fill:${V.box.fill}`]).shape;he+=`<g class="pele-cluster pele-box"${V.box.name?` data-id="${Oe(V.box.name)}"`:""}><rect x="${h(me)}" y="0" width="${h(ae-me)}" height="${h(Le+k)}" fill="var(--_a)" stroke="var(--_b)"${ft(($e?"":' fill-opacity="0.5"')+$e)}/>`+Re(V.title,(me+ae)/2,k/2+2+V.title.height/2,' class="pele-cluster-label" fill="var(--_m)"',c)+"</g>"}A.length>0&&(Le+=k);let ke=0,Ce="",be=It(r),Me=Cr(e.title,o,s,a?be:1/0),Ne=a?fs(Me,o,Math.max(120,be)):Me;if(q>D&&R(0,Math.max(Ne.width,40)),Ne.width>0){let V=(q+D)/2;R(V-Ne.width/2,V+Ne.width/2),ke=-Ne.height-12,Ce=Re(Ne,V,ke+Ne.height/2,' class="pele-title" font-weight="var(--_tw)"',c)}let Be=Math.ceil(D-q+2*f),Pe=Math.ceil(Le-ke+2*f);return{svg:Je("sequence",Be,Pe,s,r,e,`<g transform="translate(${h(f-q)},${h(f-ke)})">`+Ce+(he?`<g class="pele-boxes" font-size="${l}">${he}</g>`:"")+(ee.length>0?`<g class="pele-rects" fill="var(--_a)">${ee.reverse().join("")}</g>`:"")+(We?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${We}</g>`:"")+(te.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${te.reverse().join("")}</g>`:"")+(fe?`<g class="pele-frames" font-size="${l}" stroke="var(--_b)">${fe}</g>`:"")+(ye?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ye}</g>`:"")+(ge?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${ge}</g>`:"")+(le?`<g class="pele-edge-labels" font-size="${l}">${le}</g>`:"")+(we?`<g class="pele-notes" font-size="${l}" fill="var(--_a)" stroke="var(--_b)">${we}</g>`:"")+(pe?`<g class="pele-nodes">${pe}</g>`:"")+"</g>"),width:Be,height:Pe,links:[]}}var XT,ly,KT,eC,tC,rC,aC,oy,iC,nC,dy,wy,Yt,Za,oC,hC,dC,by,$y,xs,ys,wi,on,fC,pC,Jf,xC,wC,Kf,fy,La,py,bC,nn,$C,kC,MC,Nc,uy,Rc,ln,gy,my,ky,My=Ve(()=>{Rs();ps();Ea();tr();zt();pr();ut();wt();XT="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",KT=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;eC=/^:?wrap:/,tC=/^:?nowrap:/,rC=/^:?(?:no)?wrap:/,aC=/^(?:rgba?|hsla?)\s*\(/,oy=/[\r\u2028\u2029]/,iC=/^\w*/;nC=class{constructor(e={}){ce(this,"type","sequence");ce(this,"actors",new Map);ce(this,"createdActors",new Map);ce(this,"destroyedActors",new Map);ce(this,"boxes",[]);ce(this,"messages",[]);ce(this,"notes",[]);ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"prevActor");ce(this,"currentBox");ce(this,"lastCreated");ce(this,"lastDestroyed");ce(this,"wrapEnabled");ce(this,"sequenceWrap");ce(this,"active",new Map);this.wrapEnabled=e.wrap,this.sequenceWrap=e.sequenceWrap??!1}autoWrap(){return this.wrapEnabled??this.sequenceWrap}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
94
|
+
`)}setDiagramTitle(e){this.title=e}parseMessage(e){return cy(e)}parseBoxData(e){let t=sC(e),r=t?.[0]?t[0].trim():"transparent",a=t?.[1]?t[1].trim():void 0;if(JT(r)||(r="transparent",a=e.trim()),a===void 0)return{text:void 0,color:r,wrap:void 0};let{text:i,wrap:s}=cy(a);return{text:i||void 0,color:r,wrap:s}}addBox(e){this.currentBox={name:e.text,wrap:e.wrap??this.autoWrap(),fill:e.color,actorKeys:[]},this.boxes.push(this.currentBox)}addActor(e,t,r,a,i){let s=this.currentBox,l;if(i!==void 0){let f;try{f=Ma(i.includes(`
|
|
95
|
+
`)?i+`
|
|
96
|
+
`:`{
|
|
97
|
+
`+i+`
|
|
98
|
+
}`)}catch(p){throw new je(`Config of participant "${e}" is not valid YAML. ${p.message}`,"syntax",{type:"sequence"})}f!==null&&typeof f=="object"&&!Array.isArray(f)&&(l=f)}let n=l&&Object.prototype.hasOwnProperty.call(l,"type")?l.type:void 0,o=l&&Object.prototype.hasOwnProperty.call(l,"alias")?l.alias:void 0;n!=null&&(a=String(n)),o&&(!r||r.text===t)&&(r={text:String(o),wrap:r?.wrap,type:a});let c=this.actors.get(e);if(!(c&&(this.currentBox&&c.box&&this.currentBox!==c.box&&El(`A same participant should only be defined in one Box: ${c.name} can't be in '${c.box.name}' and in '${this.currentBox.name}' at the same time.`),s=c.box?c.box:this.currentBox,c.box=s,t===c.name&&r==null))){if((r?.text==null||a==null)&&(r={text:t,type:a}),this.actors.set(e,{box:s,name:t,description:r.text,wrap:r.wrap??this.autoWrap(),prevActor:this.prevActor,links:new Map,properties:new Map,type:a??"participant"}),this.prevActor){let f=this.actors.get(this.prevActor);f&&(f.nextActor=e)}this.currentBox&&this.currentBox.actorKeys.push(e),this.prevActor=e}}addMessage(e,t,r,a){this.messages.push({id:String(this.messages.length),from:e,to:t,message:r.text,wrap:r.wrap??this.autoWrap(),answer:a})}addSignal(e,t,r,a,i=!1,s){if(a===18){let l=e?this.active.get(e)??0:0;l<1&&El(`Trying to inactivate an inactive participant (${e})`),this.active.set(e,l-1)}else a===17&&e&&this.active.set(e,(this.active.get(e)??0)+1);return this.messages.push({id:String(this.messages.length),from:e,to:t,message:r?.text??"",wrap:r?.wrap??this.autoWrap(),type:a,activate:i,centralConnection:s??0}),!0}addNote(e,t,r){let a=r.wrap??this.autoWrap(),i={actor:e,placement:t,message:r.text,wrap:a},s=typeof e=="string"?[e,e]:e;this.notes.push(i),this.messages.push({id:String(this.messages.length),from:s[0],to:s[1],message:r.text,wrap:a,type:2,placement:t})}addLinks(e,t){let r=this.actors.get(e);if(r)try{let a=JSON.parse(t.text);for(let[i,s]of hy(a))r.links.set(i,s)}catch{return}}addALink(e,t){let r=this.actors.get(e);if(!r)return;let a=t.text.indexOf("@");r.links.set(t.text.slice(0,a-1).trim(),t.text.slice(a+1).trim())}addProperties(e,t){let r=this.actors.get(e);if(r)try{let a=JSON.parse(t.text);for(let[i,s]of hy(a))r.properties.set(i,s)}catch{return}}addDetails(e,t){let r=this.actors.get(e);r&&(r.details=t.text)}apply(e){let t=[],r=[],a=e;for(;;){a!==void 0&&(Array.isArray(a)?(t.push(a),r.push(0)):typeof a!="string"&&this.applyOne(a));let i=t.length-1;if(i<0)return;let s=t[i];r[i]<s.length?a=s[r[i]++]:(t.pop(),r.pop(),a=void 0)}}applyOne(e){let t=e.actor;switch(e.type){case"sequenceIndex":this.messages.push({id:String(this.messages.length),from:void 0,to:void 0,message:{start:e.sequenceIndex,step:e.sequenceIndexStep,visible:e.sequenceVisible===!0},wrap:!1,type:e.signalType});break;case"addParticipant":this.addActor(t,t,e.description,e.draw,e.config);break;case"createParticipant":this.actors.has(t)&&El("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=t,this.addActor(t,t,e.description,e.draw,e.config),this.createdActors.set(t,this.messages.length);break;case"destroyParticipant":this.lastDestroyed=t,this.destroyedActors.set(t,this.messages.length);break;case"activeStart":case"activeEnd":case"centralConnection":case"centralConnectionReverse":this.addSignal(t,void 0,void 0,e.signalType);break;case"addNote":this.addNote(e.actor,e.placement,e.text);break;case"addLinks":this.addLinks(t,e.text);break;case"addALink":this.addALink(t,e.text);break;case"addProperties":this.addProperties(t,e.text);break;case"addDetails":this.addDetails(t,e.text);break;case"addMessage":this.lastCreated?(e.to!==this.lastCreated&&El(`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&&(e.to!==this.lastDestroyed&&e.from!==this.lastDestroyed&&El(`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(e.from,e.to,e.msg,e.signalType,e.activate,e.centralConnection);break;case"boxStart":this.addBox(e.boxData);break;case"boxEnd":this.currentBox=void 0;break;case"loopStart":this.addSignal(void 0,void 0,e.loopText,e.signalType);break;case"rectStart":this.addSignal(void 0,void 0,e.color,e.signalType);break;case"optStart":this.addSignal(void 0,void 0,e.optText,e.signalType);break;case"altStart":case"else":this.addSignal(void 0,void 0,e.altText,e.signalType);break;case"parStart":case"and":this.addSignal(void 0,void 0,e.parText,e.signalType);break;case"criticalStart":this.addSignal(void 0,void 0,e.criticalText,e.signalType);break;case"option":this.addSignal(void 0,void 0,e.optionText,e.signalType);break;case"breakStart":this.addSignal(void 0,void 0,e.breakText,e.signalType);break;case"loopEnd":case"rectEnd":case"optEnd":case"altEnd":case"parEnd":case"criticalEnd":case"breakEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break}}},dy=["$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"],wy=new Uint8Array(128);for(let e=0;e<128;e++){let t=String.fromCharCode(e),r=e===32||e>=9&&e<=13,a=0;`/\\+()<->:
|
|
99
|
+
,;`.includes(t)||(a|=1),`+<->:
|
|
100
|
+
,;`.includes(t)||(a|=2),`<>:
|
|
101
|
+
,;@`.includes(t)||(a|=8|(r?0:4)),`#
|
|
102
|
+
;`.includes(t)||(a|=16),!`/\\+()<>:
|
|
103
|
+
,;-`.includes(t)&&!r&&(a|=32),wy[e]=a}Yt=new Int8Array(79).fill(-1);Yt[53]=5;Yt[54]=6;Yt[55]=0;Yt[57]=1;Yt[56]=33;Yt[58]=34;Yt[59]=3;Yt[60]=4;Yt[61]=24;Yt[62]=25;Yt[63]=41;Yt[64]=42;Yt[65]=43;Yt[66]=44;Yt[67]=51;Yt[68]=52;Yt[69]=53;Yt[70]=54;Yt[71]=45;Yt[72]=46;Yt[73]=47;Yt[74]=48;Yt[75]=55;Yt[76]=56;Yt[77]=57;Yt[78]=58;Za=new Int8Array(79).fill(-1);Za[21]=2;Za[22]=3;Za[23]=4;Za[28]=5;Za[24]=6;Za[25]=7;Za[26]=7;Za[27]=8;Za[6]=1;oC="'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'";hC=16,dC=10,by=34,$y=4,xs=5,ys=6,wi=' fill="var(--_s)" stroke="var(--_b)"',on=' fill="none" stroke="var(--_b)"',fC=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]),pC=new Set(["actor","boundary","control","entity","database"]);Jf=[];Ar(0,!1,1);Ar(1,!0,1);Ar(3,!1,2);Ar(4,!0,2);Ar(5,!1,0);Ar(6,!0,0);Ar(24,!1,3);Ar(25,!0,3);Ar(33,!1,1,2);Ar(34,!0,1,2);for(let e of[!1,!0]){let t=e?10:0;Ar(41+t,e,4),Ar(42+t,e,4,1,!0),Ar(43+t,e,5),Ar(44+t,e,5,1,!0),Ar(45+t,e,4,0),Ar(46+t,e,4,0,!0),Ar(47+t,e,5,0),Ar(48+t,e,5,0,!0)}xC=new Map([[10,"loop"],[12,"alt"],[15,"opt"],[19,"par"],[32,"par"],[27,"critical"],[30,"break"],[22,"rect"]]),wC=12,Kf=28,fy=22,La=10,py=4,bC=14,nn=10,$C=16,kC=20,MC=10,Nc=20,uy=240,Rc=16,ln=4,gy=' stroke-dasharray="4 4"';my={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};ky={type:"sequence",math:!0,parse(e,t,r){let a=t.sequence??{},i=new nC({wrap:typeof t.wrap=="boolean"?t.wrap:void 0,sequenceWrap:a.wrap===!0});return r&&i.setDiagramTitle(r),cC(e,i),i},render:EC}});var Ay={};Ct(Ay,{sequence:()=>ky});var vy=Ve(()=>{My()});function Zr(e){throw new je(e,"semantic",{type:"gitGraph"})}function Ey(e){return e==="REVERSE"?gr.REVERSE:e==="HIGHLIGHT"?gr.HIGHLIGHT:gr.NORMAL}function TC(e,t){e.dir&&t.setDirection(e.dir);for(let r of e.statements)CC(r,t)}function CC(e,t){switch(e.$type){case"Commit":t.commit({id:e.id,msg:e.message??"",type:e.type!==void 0?Ey(e.type):gr.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?Ey(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 _C(e,t,r){let a=t.gitGraph,i=typeof a?.mainBranchName=="string"?a.mainBranchName:"main",s=typeof a?.mainBranchOrder=="number"?a.mainBranchOrder:0,l=new Map,n=new Map([[i,null]]),o=new Map([[i,s]]),c=[],f=null,p=i,d="LR",g=0,u=()=>{for(let v=g+1;;v+=2654435761){let k=`${g}-${(Math.imul(v,2654435761)>>>0).toString(16).padStart(8,"0").slice(0,7)}`;if(!l.has(k))return k}},m=v=>{f=v,l.set(v.id,v),n.set(p,v.id)},b=v=>{n.has(v)||Zr(`Trying to checkout branch which is not yet created. (Help try using "branch ${v}")`),p=v;let k=n.get(v);f=k?l.get(k)??null:null};TC(e,{setDirection(v){d=v},commit({msg:v,id:k,type:L,tags:I}){let N={id:k||u(),message:v,seq:g++,type:L??gr.NORMAL,tags:I?[...I]:[],parents:f===null?[]:[f.id],branch:p};l.has(N.id)&&c.push(`Commit ID ${N.id} already exists`),m(N)},branch({name:v,order:k}){n.has(v)&&Zr(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${v}")`),n.set(v,f!==null?f.id:null),o.set(v,k),b(v)},merge({branch:v,id:k,type:L,tags:I}){let N=n.get(p),O=n.get(v),W=N?l.get(N):void 0,U=O?l.get(O):void 0;W&&U&&W.branch===v&&Zr(`Cannot merge branch '${v}' into itself.`),p===v&&Zr('Incorrect usage of "merge". Cannot merge a branch to itself'),W===void 0&&Zr(`Incorrect usage of "merge". Current branch (${p})has no commits`),n.has(v)||Zr(`Incorrect usage of "merge". Branch to be merged (${v}) does not exist`),U===void 0&&Zr(`Incorrect usage of "merge". Branch to be merged (${v}) has no commits`),W===U&&Zr('Incorrect usage of "merge". Both branches have same head'),k&&l.has(k)&&Zr(`Incorrect usage of "merge". Commit with id:${k} already exists, use different custom id`),m({id:k||u(),message:`merged branch ${v} into ${p}`,seq:g++,parents:f===null?[]:[f.id,O||""],branch:p,type:gr.MERGE,customType:L,customId:!!k,tags:I?[...I]:[]})},cherryPick({id:v,targetId:k,tags:L,parent:I}){let N=v?l.get(v):void 0;if(N===void 0&&Zr('Incorrect usage of "cherryPick". Source commit id should exist and provided'),I&&!N.parents.includes(I)&&Zr("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."),N.type===gr.MERGE&&!I&&Zr("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."),k&&l.has(k))return;N.branch===p&&Zr('Incorrect usage of "cherryPick". Source commit is already on current branch');let O=n.get(p);(!O||!l.has(O))&&Zr(`Incorrect usage of "cherry-pick". Current branch (${p})has no commits`),m({id:u(),message:`cherry-picked ${N.message} into ${p}`,seq:g++,parents:f===null?[]:[f.id,N.id],branch:p,type:gr.CHERRY_PICK,tags:L?L.filter(Boolean):[`cherry-pick:${N.id}${N.type===gr.MERGE?`|parent:${I}`:""}`]})},checkout:b});let w=[...o].map(([v,k],L)=>({name:v,order:k??parseFloat(`0.${L}`)})).sort((v,k)=>v.order-k.order).map(v=>v.name);return{type:"gitGraph",title:e.title||r,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
104
|
+
`):void 0,direction:d,commits:l,branches:n,lanes:w,currentBranch:p,head:f,warnings:c}}function xa(e){return{name:e,pattern:e,longer:Ry}}function IC(e){let t=new Zt(Gt(e,Sy,"gitGraph"),Sy,"gitGraph"),r={$type:"GitGraph",statements:[]},a=()=>{if(t.kind!==-1)for(t.kind!==26&&t.fail("a line break or the end of input");t.kind===26;)t.i++},i=()=>t.kind===31?t.take():t.kind===25?$r(t.take()):t.fail("a branch name"),s=()=>$r(t.expect(25)),l=()=>(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 n=t.kinds[t.i+1];(t.kind===17||t.kind===18||t.kind===19)&&n===20?(r.$type="Direction",r.dir=t.take(),t.i++):t.accept(20)}for(;t.kind!==-1;)switch(t.kind){case 26:t.i++;break;case 21:r.accDescr=Kt(t.take()),a();break;case 22:r.accTitle=Xt(t.take()),a();break;case 23:r.title=Vt(t.take()),a();break;case 7:{t.i++;let n={$type:"Commit",tags:[]};for(;;)if(t.accept(16))n.id=s();else if(t.accept(15))n.tags.push(s());else if(t.accept(12))n.type=l();else if(t.accept(14)||t.kinds[t.i]===25)n.message=s();else break;a(),r.statements.push(n);break}case 9:{t.i++;let n={$type:"Branch",name:i()};t.accept(10)&&(n.order=parseInt(t.expect(24))),a(),r.statements.push(n);break}case 13:{t.i++;let n={$type:"Merge",branch:i(),tags:[]};for(;;)if(t.accept(16))n.id=s();else if(t.accept(15))n.tags.push(s());else if(t.accept(12))n.type=l();else break;a(),r.statements.push(n);break}case 4:case 11:{t.i++;let n={$type:"Checkout",branch:i()};a(),r.statements.push(n);break}case 0:{t.i++;let n={$type:"CherryPicking",tags:[]};for(;;)if(t.accept(16))n.id=s();else if(t.accept(15))n.tags.push(s());else if(t.accept(6))n.parent=s();else break;a(),r.statements.push(n);break}default:t.fail("a statement, a title, or a line break")}return r}function Pc(e,t,r){let a=e.gitGraph?.[t];return typeof a=="boolean"?a:r}function _y(e){return Tl+4+e.width+6}function LC(e,t,r,a){let i=`cx="${h(t)}" cy="${h(r)}"`;if(e===gr.HIGHLIGHT)return`<rect x="${h(t-cr-1)}" y="${h(r-cr-1)}" width="${2*cr+2}" height="${2*cr+2}" rx="2" fill="${a}"/>`;if(e===gr.MERGE)return`<circle ${i} r="${cr-1}" fill="var(--_bg)" stroke="${a}" stroke-width="2"/><circle ${i} r="2.5" fill="${a}"/>`;let s=`<circle ${i} r="${cr}" fill="${a}"/>`;return e===gr.REVERSE?s+`<path d="M${h(t-3)},${h(r-3)}l6,6M${h(t-3)},${h(r+3)}l6,-6" fill="none" stroke="var(--_bg)" stroke-width="1.5" stroke-linecap="round"/>`:e===gr.CHERRY_PICK?s+`<path d="M${h(t-2.6)},${h(r+1)}L${h(t+.8)},${h(r-4.2)}L${h(t+2.6)},${h(r+1)}" fill="none" stroke="var(--_bg)" stroke-linejoin="round"/><circle cx="${h(t-2.6)}" cy="${h(r+2.2)}" r="1.8" fill="var(--_bg)"/><circle cx="${h(t+2.6)}" cy="${h(r+2.2)}" r="1.8" fill="var(--_bg)"/>`:s}function DC(e,t,r){return e.direction!=="LR"?Iy(e,t,r,e.direction):Bt(r,a=>Iy(e,t,r,a?"TB":"LR"))}function Iy(e,t,r,a){let i=r.fontSize??16,s=Math.round(i*.75),l=r.measurer??et(r.fontFamily),n=r.padding??8,o=Pc(t,"showBranches",!0),c=Pc(t,"showCommitLabel",!0),f=Pc(t,"rotateCommitLabel",!0),p=Pc(t,"parallelCommits",!1),d=a!=="LR",g=a==="BT",u=new Map;e.lanes.forEach((F,K)=>u.set(F,K));let m=e.lanes.length,b=Math.round(i*.875),w=e.lanes.map(F=>Na(o?F:"",l,b,4e3)),v=[],k=new Map;for(let F of[...e.commits.values()].sort((K,re)=>K.seq-re.seq)){let K=c&&F.type!==gr.CHERRY_PICK&&(F.type!==gr.MERGE||F.customId===!0),re=[];for(let de of F.tags){let ie=Na(de,l,s,4e3);ie.lines.length>0&&re.push(ie)}let ne={commit:F,index:v.length,lane:u.get(F.branch)??0,m:0,label:K?Na(F.id,l,s,4e3):void 0,tags:re};v.push(ne),k.set(F.id,ne)}let L=new Float64Array(v.length),I=new Float64Array(v.length),N=new Float64Array(m).fill(cr),O=new Float64Array(m).fill(cr);v.forEach((F,K)=>{let{label:re,tags:ne}=F,de=0,ie=0;for(let le of ne){let we=_y(le);d?(de=Math.max(de,le.height),ie+=we+4):(de=Math.max(de,we),ie+=le.height+3)}let se=0,ee=0;re!==void 0&&re.lines.length>0&&(f?ee=3+ep*(re.width+re.height):(se=d?re.height:re.width,ee=6+(d?re.width:re.height))),L[K]=Math.max(cr,de/2,se/2),I[K]=de/2;let te=cr+(ne.length>0?Ty+ie:0),fe=cr+ee,ye=F.lane;N[ye]=Math.max(N[ye],d?fe:te),O[ye]=Math.max(O[ye],d?te:fe)});let W=new Float64Array(v.length);d||v.forEach((F,K)=>{if(I[K]!==0)for(let re of F.commit.parents){let ne=k.get(re);ne!==void 0&&ne.lane<F.lane&&(W[K]=I[K]+4)}});let U=(F,K)=>Math.max(NC,L[F]+L[K]+Oc,W[K]>0?L[F]+Dc+W[K]:0);v.forEach((F,K)=>{if(!p){F.m=K===0?0:v[K-1].m+U(K-1,K);return}let re=0;for(let ne of F.commit.parents){let de=k.get(ne);de===void 0||de.index>=K||(re=Math.max(re,de.m+U(de.index,K)))}F.m=re});let _=0;for(let F of v)_=Math.max(_,F.m);let j=new Float64Array(m);for(let F=0;F<m;F++){let K=w[F],re=K.lines.length===0?0:d?K.width/2+8:K.height/2+2;N[F]=Math.max(N[F],re),O[F]=Math.max(O[F],re),F>0&&(j[F]=j[F-1]+Math.max(RC,O[F-1]+N[F]+Oc))}let Z=(F,K)=>d?K:F,H=(F,K)=>d?g?-F:F:K,z=(F,K)=>`${h(Z(F,K))},${h(H(F,K))}`,C=1/0,S=1/0,$=-1/0,y=-1/0,E=(F,K,re,ne)=>{F<C&&(C=F),K<S&&(S=K),re>$&&($=re),ne>y&&(y=ne)},x="";if(o)for(let F=0;F<m;F++){let K=w[F],re=dt(F),ne=j[F],de=K.width+16,ie=K.height+4,se=K.lines.length===0?-ws:-ws-(d?ie:de),ee=Z(se+(d?ie:de)/2,ne),te=H(se+(d?ie:de)/2,ne);E(Z(-ws,ne),H(-ws,ne),Z(-ws,ne),H(-ws,ne)),E(Z(_+Sl,ne),H(_+Sl,ne),Z(_+Sl,ne),H(_+Sl,ne)),x+=`<g class="pele-branch" data-id="${Oe(e.lanes[F])}"><path class="pele-lane" d="M${z(-ws,ne)}L${z(_+Sl,ne)}" stroke="${re}" stroke-dasharray="2 4"/>`,K.lines.length>0&&(E(ee-de/2,te-ie/2,ee+de/2,te+ie/2),x+=`<rect x="${h(ee-de/2)}" y="${h(te-ie/2)}" width="${h(de)}" height="${h(ie)}" fill="${re}"${st}/>`+Re(K,ee,te,' class="pele-label" fill="var(--_bg)"')),x+="</g>"}let T=Array.from({length:m},()=>[]);for(let F of v)T[F.lane].push(F.m);if(p)for(let F of T)F.sort((K,re)=>K-re);let A=(F,K,re)=>{let ne=T[F],de=0,ie=ne.length;for(;de<ie;){let se=de+ie>>1;ne[se]<=K?de=se+1:ie=se}return de<ne.length&&ne[de]<re},M="",Y="";for(let F of v){let{commit:K}=F,re=j[F.lane],ne=F.m;for(let de=0;de<K.parents.length;de++){let ie=k.get(K.parents[de]);if(ie===void 0||ie===F)continue;let se=j[ie.lane],ee=ie.m;if(ie.lane===F.lane){Y+=`<path class="pele-edge" d="M${z(ee,se)}L${z(ne,re)}" stroke="${dt(F.lane)}"/>`;continue}let te=de>0&&K.type===gr.MERGE,fe=de>0&&!te,ye=`M${z(ee,se)}`;if(ne<=ee){let le=(ee+ne)/2;ye+=`C${z(le,se)} ${z(le,re)} ${z(ne,re)}`}else if(!te&&!A(F.lane,ee,ne)){let le=Math.min(Dc,ne-ee);ye+=`C${z(ee+le/2,se)} ${z(ee+le/2,re)} ${z(ee+le,re)}L${z(ne,re)}`}else{let le=ie.lane<F.lane&&ne-W[F.index]>ee?ne-W[F.index]:ne,we=Math.min(Dc,le-ee),pe=se;(!te||A(ie.lane,ee,ne))&&(pe=se>re?re+O[F.lane]+Oc/2:re-N[F.lane]-Oc/2,we=Math.min(Dc,(le-ee)/2),ye+=`C${z(ee+we/2,se)} ${z(ee+we/2,pe)} ${z(ee+we,pe)}`),ye+=`L${z(le-we,pe)}C${z(le-we/2,pe)} ${z(le-we/2,re)} ${z(le,re)}`,le<ne&&(ye+=`L${z(ne,re)}`)}M+=`<path class="pele-edge${te?" pele-edge-merge":fe?" pele-edge-cherry-pick":""}" d="${ye}" stroke="${dt(te?ie.lane:F.lane)}"${fe?' stroke-dasharray="4 3"':""}/>`}}let B="";for(let F of v){let{commit:K,label:re,tags:ne}=F,de=Z(F.m,j[F.lane]),ie=H(F.m,j[F.lane]),se=K.customType??K.type;E(de-cr-1,ie-cr-1,de+cr+1,ie+cr+1);let ee=K.type<gr.MERGE&&K.message!==""?`<title>${Oe(K.message)}</title>`:"";if(ee+=LC(se,de,ie,dt(F.lane)),re!==void 0&&re.lines.length>0){let ye=re.width,le=re.height,we=(pe,ge)=>`<rect x="${h(pe-ye/2-2)}" y="${h(ge-le/2+2)}" width="${h(ye+4)}" height="${h(le-4)}" rx="3" fill="var(--_bg)"/>`;if(f){let pe=ep*le/2,ge=d?de-cr-3-pe:de+3,Ae=d?ie:ie+cr+3+pe,Se=ep*ye+pe;E(ge-Se,g?Ae-Se:Ae-pe,ge+pe,g?Ae+pe:Ae+Se),ee+=`<g class="pele-commit-label" transform="rotate(${g?45:-45} ${h(ge)} ${h(Ae)})">`+we(ge-ye/2,Ae)+Re(re,ge-ye/2,Ae,"")+"</g>"}else{let pe=d?de-cr-6-ye/2:de,ge=d?ie:ie+cr+6+le/2;E(pe-ye/2,ge-le/2,pe+ye/2,ge+le/2),ee+=`<g class="pele-commit-label">${we(pe,ge)}${Re(re,pe,ge,"")}</g>`}}let te=cr+Ty;for(let ye=d?0:ne.length-1;ye>=0&&ye<ne.length;ye+=d?1:-1){let le=ne[ye],we=_y(le),pe=le.height,ge=d?de+te:de-we/2,Ae=d?ie:ie-te-pe/2;te+=d?we+4:pe+3,E(ge,Ae-pe/2,ge+we,Ae+pe/2),ee+=`<g class="pele-tag"><path d="M${h(ge)},${h(Ae)}L${h(ge+Tl)},${h(Ae-pe/2)}H${h(ge+we)}V${h(Ae+pe/2)}H${h(ge+Tl)}Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/><circle cx="${h(ge+Tl)}" cy="${h(Ae)}" r="1.5" fill="var(--_b)"/>`+Re(le,ge+Tl+4+le.width/2,Ae,' fill="var(--_fg)"')+"</g>"}let fe=K.type===gr.MERGE&&se!==gr.MERGE?" pele-commit-merge":"";B+=`<g class="pele-commit pele-commit-${Cy[se]??Cy[0]}${fe}" data-id="${Oe(K.id)}">${ee}</g>`}C>$&&E(0,0,0,0);let q=ze(e.title,!1,l,i,4e3,1),D=q.height>0?q.height+16:0,R=Math.max($-C,q.width),P=Math.ceil(R+2*n),G=Math.ceil(y-S+D+2*n),X=n-C+(R-($-C))/2,Q=n+D-S,J=Re(q,P/2,n+q.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${h(X)},${h(Q)})">`+(x?`<g class="pele-branches" fill="none" font-size="${b}">${x}</g>`:"")+(M||Y?`<g class="pele-edges" fill="none" stroke-width="2" stroke-linecap="round">${M}${Y}</g>`:"")+(B?`<g class="pele-commits" font-size="${s}" fill="var(--_m)">${B}</g>`:"")+"</g>";return{svg:Je("gitGraph",P,G,i,r,e,J),width:P,height:G,links:[]}}var gr,Ny,Ry,Sy,cr,NC,RC,Dc,Oc,ws,Sl,Tl,Ty,ep,Cy,Ly,Dy=Ve(()=>{Ho();zt();Xr();ut();wt();gr={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4};Ny={name:"REFERENCE",pattern:/\w([-\./\w]*[-\w])?/y},Ry=[Ny];Sy=[xa("cherry-pick"),{name:"gitGraph:",pattern:"gitGraph:"},xa("HIGHLIGHT"),{...or("gitGraph"),longer:Ry},xa("checkout"),xa("REVERSE"),{name:"parent:",pattern:"parent:"},xa("commit"),xa("NORMAL"),xa("branch"),{name:"order:",pattern:"order:"},xa("switch"),{name:"type:",pattern:"type:"},xa("merge"),{name:"msg:",pattern:"msg:"},{name:"tag:",pattern:"tag:"},{name:"id:",pattern:"id:"},xa("LR"),xa("TB"),xa("BT"),{name:":",pattern:":"},{...ur,opener:/[\t ]*accDescr\s*{/y},rr,ar,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Vr,Rr,Lr,jt,nr,lr,Ny];cr=7,NC=44,RC=44,Dc=36,Oc=8,ws=20,Sl=20,Tl=7,Ty=6,ep=Math.SQRT1_2,Cy=["normal","reverse","highlight","merge","cherry-pick"];Ly={type:"gitGraph",parse:(e,t,r)=>_C(IC(e),t,r),render:DC}});var Oy={};Ct(Oy,{gitGraph:()=>Ly});var Py=Ve(()=>{Dy()});function _l(e,t){let{key:r,value:a}=t;"from"in e&&(r==="offsetX"||r==="offsetY")?e[r]=parseInt(a):("from"in e?PC:OC).has(r)?e[r]=a:(e.extra??(e.extra=new Map)).set(r,a)}function Qt(e,t,r){r!==void 0&&(typeof r=="string"?e[t]=r:_l(e,r))}function cn(e,t,r){r===void 0?e[t]??(e[t]=""):Qt(e,t,r)}function zy(e,t){e.labelAttr=void 0,typeof t=="object"?(e.label="",e.labelAttr=t,_l(e,t)):e.label=t??""}function WC(e){let t=e.length,r=[],a=[],i=[],s=0,l=9,n=0,o=!1,c=-2,f=-1,p=0,d=(b,w,v)=>{r.push(b),a.push(w),i.push(v),n=v},g=b=>{for(;b<t&&Ue(e.charCodeAt(b));)b++;return b},u=(b,w)=>{let v=e.indexOf(b,w);return v===-1?t:v},m=(b,w)=>{let v=n+b.length;if(!e.startsWith(b,n)||!Ue(e.charCodeAt(v)))return!1;let k=++v;for(;v<t;){let L=e.charCodeAt(v);if(L===35||L===10||L===59)break;v++}return v===k?!1:(d(w,n,v),!0)};for(;;){if(o){d(0,t,t);break}n>=t&&(o=!0);let b=e.charCodeAt(n);if(s===0){if(n>=t){d(64,t,t);continue}if(c!==-1&&n>=p&&(c<n&&(c=e.indexOf("direction",n)),c!==-1&&(f<n&&(rp.lastIndex=n,f=rp.test(e)?rp.lastIndex-1:t),c<f))){let w=!1;for(let v=0;v<4&&!w;v++)tp[v].lastIndex=n,tp[v].test(e)&&(d(2+v,n,tp[v].lastIndex),w=!0);if(w)continue;p=f}if(b===116&&m("title",6))continue;if(b===97){if(m("accDescription",7))continue;let w=e.startsWith("accTitle",n);if(w||e.startsWith("accDescr",n)){let v=g(n+8),k=e.charCodeAt(v);if(k===58){d(w?8:10,n,g(v+1)),l=w?9:11,s=7;continue}if(k===123&&!w){n=g(v+1),s=8;continue}}}if(b===37&&e.charCodeAt(n+1)===37){let w=u(`
|
|
105
|
+
`,n+2);for(;w<t&&(e.charCodeAt(w)===10||e.charCodeAt(w)===13);)w++;n=w;continue}if(Ue(b)){let w=n,v=-1;for(;w<t;){let k=e.charCodeAt(w);if(!Ue(k))break;k===10&&(v=w),w++}v!==-1?d(13,n,v+1):n=w;continue}if(b===123){d(62,n,n+1);continue}if(b===125){d(63,n,n+1);continue}if(Qe(b)){let w=n+1;for(;w<t&&Qe(e.charCodeAt(w));)w++;let v=w-n<=19?FC.get(e.slice(n,w)):void 0;if(v!==void 0){v>18&&(s=1),d(v,n,w);continue}}d(1,n,n);break}if(s===1){if(n>=t)d(57,t,t);else if(b===40){let w=n+1;for(;e.charCodeAt(w)===32;)w++;e.charCodeAt(w)===44?d(58,n,w+1):n++,s=2}else if(b===41)n++,s=0;else{d(1,n,n);break}continue}if(s===2){if(n>=t)continue;if(b===41)n++,s=0;else if(b===44)e.charCodeAt(n+1)===44?d(58,n,n+2):n++;else{let w=n;for(;e.charCodeAt(w)===32;)w++;let v=e.charCodeAt(w);v===34?e.charCodeAt(w+1)===34?d(58,n,w+2):(n=w+1,s=3):v===36?(n=w+1,s=4):d(59,n,u(",",n))}continue}if(s===3){b===34?(n++,s=2):d(59,n,u('"',n));continue}if(s===4){d(60,n,u("=",n)),s=5;continue}if(s===5){if(n>=t)continue;let w=n+1;if(b===61)for(;e.charCodeAt(w)===32;)w++;if(b!==61||e.charCodeAt(w)!==34){d(1,n,n);break}n=w+1,s=6;continue}if(s===6){if(n>=t)continue;b===34?(n++,s=2):d(61,n,u('"',n));continue}if(s===7){d(l,n,u(`
|
|
106
|
+
`,n)),s=0;continue}b===125?(n++,s=0):d(12,n,u("}",n))}return{types:r,starts:a,ends:i}}function qC(e){return e===6||e===7||e===8||e===10||e===12}function Wy(e){return e>=19&&e<=56}function GC(e,t){let{types:r,starts:a,ends:i}=WC(e),s=0,l=m=>e.slice(a[m],i[m]),n=m=>{let b=r[s];throw b===1?it("c4",e,a[s],"",!0):it("c4",e,a[s],`Expecting ${m}, got '${Fy[b]}'`)},o=m=>{r[s]!==m&&n(`'${Fy[m]}'`),s++},c=()=>{let m=[];for(;;){let b=r[s];if(b===59)m.push(l(s++).trim());else if(b===58)m.push(""),s++;else if(b===60)s++,r[s]!==61&&n("'STR_VALUE'"),m.push({key:l(s-1).trim(),value:l(s).trim()}),s++;else break}return m.length===0&&n(UC),m},f=m=>{m===6?t.setTitle(l(s++).substring(6)):m===7?t.setAccDescription(l(s++).substring(15)):m===12?t.setAccDescription(l(s++).trim()):(s++,m===8?(r[s]!==9&&n("'acc_title_value'"),t.setTitle(l(s++).trim())):(r[s]!==11&&n("'acc_descr_value'"),t.setAccDescription(l(s++).trim())))},p=m=>{s++;let b=c();if(m<=26)t.addPersonOrSystem(ap[m-19],b);else if(m<=32)t.addContainer(ap[m-19],b);else if(m<=38)t.addComponent(ap[m-19],b);else{if(m<=45)return m===39?b.splice(2,0,"ENTERPRISE"):m===40?b.splice(2,0,"SYSTEM"):m===42&&b.splice(2,0,"CONTAINER"),m>=43?t.addDeploymentNode(HC[m-43],b):m===42?t.addContainerBoundary(b):t.addPersonOrSystemBoundary(b),r[s]===62?(s++,o(13)):r[s]===13?(s++,o(62),r[s]===13&&s++):n("'NEWLINE', 'LBRACE'"),!0;m<=53?(m===53&&b.splice(0,1),t.addRel(BC[m-46],b)):m===54?t.updateElStyle("update_el_style",b):m===55?t.updateRelStyle("update_rel_style",b):t.updateLayoutConfig("update_layout_config",b)}return!1},d=r[s];(d<14||d>18)&&n(YC),s++,o(13);let g=0,u=0;for(;;){let m=r[s];if(u===3||u===4){if(m===13){s++,u=2;continue}if(u===3&&Wy(m)){u=1;continue}}else if(Wy(m)){p(m)?(g++,u=1):u=4;continue}else if(qC(m)&&u!==1){f(m),u=3;continue}else u!==2&&n("'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'");if(g>0)m!==63&&n("'NEWLINE', 'RBRACE'"),s++,t.popBoundaryParseStack(),g--,u=4;else{m!==64&&n("'NEWLINE', 'EOF'"),s++,o(0),t.setC4Type(l(0));return}}}function bs(e,t,r,a,i,s,l,n){let o=0,c=1;if(l===0){if(i<e||i>r)return 1/0}else{let f=(e-i)/l,p=(r-i)/l;o=Math.max(o,Math.min(f,p)),c=Math.min(c,Math.max(f,p))}if(n===0){if(s<t||s>a)return 1/0}else{let f=(t-s)/n,p=(a-s)/n;o=Math.max(o,Math.min(f,p)),c=Math.min(c,Math.max(f,p))}return o<=c?o:1/0}function Cl(e,t,r,a,i,s,l,n){let o=l/r,c=n/a,f=(i-e)/r,p=(s-t)/a,d=o*o+c*c,g=2*(o*f+c*p),u=f*f+p*p-1,m=g*g-4*d*u;if(d===0||m<0)return 1/0;let b=(-g-Math.sqrt(m))/(2*d);return b>=0&&b<=1?b:u<=0?0:1/0}function la(e,t,r,a,i){let{x:s,y:l,w:n,h:o}=e,c=a-t,f=i-r;if(e.form==="person")return Math.min(bs(s,l+fp,s+n,l+o,t,r,c,f),Cl(s+n/2,l+14,13,13,t,r,c,f));if(e.form==="cyl"){let p=Vy(n);return Math.min(bs(s,l+p,s+n,l+o-p,t,r,c,f),Cl(s+n/2,l+p,n/2,p,t,r,c,f),Cl(s+n/2,l+o-p,n/2,p,t,r,c,f))}if(e.form==="h-cyl"){let p=Xy(o);return Math.min(bs(s+p,l,s+n-p,l+o,t,r,c,f),Cl(s+p,l+o/2,p,o/2,t,r,c,f),Cl(s+n-p,l+o/2,p,o/2,t,r,c,f))}return bs(s,l,s+n,l+o,t,r,c,f)}function Ky(e,t,r,a,i){for(let s=2;s<e.length;s+=2){let l=e[s-2],n=e[s-1];if(bs(t,r,a,i,l,n,e[s]-l,e[s+1]-n)<=1)return!0}return!1}function Yc(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 XC(e,t,r){let a=e.x+e.w/2,i=e.y+e.h/2,s=t.x+t.w/2,l=t.y+t.h/2,n=Yc(e,t);if(n||Yc(t,e)){let I=n?e:t,N=n?t:e,O=N.x+N.w/2,W=N.y+N.h/2,U=N.x-I.x,_=I.x+I.w-N.x-N.w,j=N.y-I.y,Z=I.y+I.h-N.y-N.h,H=Math.min(U,_,j,Z),z=H===U?I.x:H===_?I.x+I.w:O,C=H===U||H===_?W:H===Z?I.y+I.h:I.y,S=Math.min(la(N,z,C,O,W),1),$=z+(O-z)*S,y=C+(W-C)*S;return n?[z,C,$,y]:[$,y,z,C]}let o=a,c=i,f=s,p=l,d=Math.max(e.x,t.x),g=Math.min(e.x+e.w,t.x+t.w),u=Math.max(e.y,t.y),m=Math.min(e.y+e.h,t.y+t.h);d<g?o=f=(d+g)/2:u<m&&(c=p=(u+m)/2);let b=Math.hypot(f-o,p-c)||1,w=-(p-c)/b*r,v=(f-o)/b*r,k=la(e,f+w,p+v,o+w,c+v),L=la(t,o+w,c+v,f+w,p+v);return k<=1&&L<=1?(o+=w,c+=v,f+=w,p+=v):(o=a,c=i,f=s,p=l,k=Math.min(la(e,f,p,o,c),1),L=Math.min(la(t,o,c,f,p),1)),[f+(o-f)*k,p+(c-p)*k,o+(f-o)*L,c+(p-c)*L]}function QC(e,t,r){let a=e.length,i=Math.sign(e[2]-e[0]),s=Math.sign(e[3]-e[1]),l=`M${h(e[0]+i*t)},${h(e[1]+s*t)}`;for(let c=2;c<a-2;c+=2){let f=e[c],p=e[c+1],d=Math.sign(f-e[c-2]),g=Math.sign(p-e[c-1]),u=Math.sign(e[c+2]-f),m=Math.sign(e[c+3]-p),b=Math.min(jC,Math.abs(f-e[c-2]+p-e[c-1])/2,Math.abs(e[c+2]-f+e[c+3]-p)/2);l+=`${d?"H"+h(f-d*b):"V"+h(p-g*b)}Q${h(f)},${h(p)} ${h(f+u*b)},${h(p+m*b)}`}let n=Math.sign(e[a-2]-e[a-4]),o=Math.sign(e[a-1]-e[a-3]);return l+(n?"H"+h(e[a-2]-n*r):"V"+h(e[a-1]-o*r))}function Zy(e,t,r,a){for(let i of t)if(i!==r&&i!==a&&Ky(e,i.x,i.y,i.x+i.w,i.y+i.h))return!1;return!0}function Qy(e,t,r,a,i){let s=e.length;return{d:QC(e,r,a),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:Hc,...i,points:e}}function Hy(e,t){let r=[],a=(e+t)/2,i=Math.max(jy,(t-e)/4);for(let s=0;s<9;s++){let l=a+(s&1?1:-1)*Math.ceil(s/2)*i;l>=e+cp&&l<=t-cp&&r.push(l)}return r}function JC(e,t,r,a,i,s){let l=e.x+e.w/2,n=e.y+e.h/2,o=t.x+t.w/2,c=t.y+t.h/2,f,p=(m,b,w)=>{if(!Zy(m,r,e,t))return;for(let k=2;k<m.length;k+=2){let L=m[k]===m[k-2];if(!a.free(L,L?m[k]:m[k+1],L?m[k-1]:m[k-2],L?m[k+1]:m[k]))return}let v=a.crossings(m)*1e6;for(let k=2;k<m.length;k+=2)v+=Math.abs(m[k]-m[k-2])+Math.abs(m[k+1]-m[k-1]);(!f||v<f.cost)&&(f={points:m,cost:v,upright:b,sides:w})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let m=o>l,b=Math.sign(c-n),w=m?[1,0]:[0,1],v=Hy(m?e.x+e.w:t.x+t.w,m?t.x:e.x);e:for(let k of a.ports(e,w[0],n+b*e.h/4,e.y+8,e.y+e.h-8))for(let L of a.ports(t,w[1],c-b*t.h/4,t.y+8,t.y+t.h-8))for(let I of v){let N=I+(l-I)*Math.min(la(e,I,k,l,k),1),O=I+(o-I)*Math.min(la(t,I,L,o,L),1),W=f;if(p([N,k,I,k,I,L,O,L],!0,w),f!==W)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let m=c>n,b=Math.sign(o-l),w=m?[3,2]:[2,3],v=Hy(m?e.y+e.h:t.y+t.h,m?t.y:e.y);e:for(let k of a.ports(e,w[0],l+b*e.w/4,e.x+8,e.x+e.w-8))for(let L of a.ports(t,w[1],o-b*t.w/4,t.x+8,t.x+t.w-8))for(let I of v){let N=I+(n-I)*Math.min(la(e,k,I,k,n),1),O=I+(c-I)*Math.min(la(t,L,I,L,c),1),W=f;if(p([k,N,k,I,L,I,L,O],!1,w),f!==W)break e}}if(!f)return;let{points:d,upright:g,sides:u}=f;return a.take(d),a.claim(e,u[0],g?d[1]:d[0]),a.claim(t,u[1],g?d[7]:d[6]),Qy(d,2,i,s,{room:g?op:Hc})}function e_(e,t,r,a,i,s,l){if(e===t){let b=Math.min(e.h/2-4,10),w=Math.hypot(hn,b),v=e.x+e.w,k=e.y+e.h/2,L=hn/w,I=b/w;return{d:`M${h(v+L*s)},${h(k-b-I*s)}C${h(v+hn)},${h(k-b*2)} ${h(v+hn)},${h(k+b*2)} ${h(v+L*l)},${h(k+b+I*l)}`,sx:v,sy:k-b,sdx:-L,sdy:I,ex:v,ey:k+b,edx:-L,edy:-I,x0:v+hn+4,y0:k,x1:v+hn+4,y1:k,nx:1,ny:0,lean:0,room:64,points:[]}}let[n,o,c,f]=XC(e,t,r),p=n===c,d=!1;if(a&&!Yc(e,t)&&!Yc(t,e))for(let b of a)b!==e&&b!==t&&bs(b.x,b.y,b.x+b.w,b.y+b.h,n,o,c-n,f-o)<=1&&(d=!0);if(a&&d&&!p&&o!==f){let b=JC(e,t,a,i,s,l);if(b)return b;i.squeezed++}if(a&&d&&(p||o===f)){let b=M=>{let Y=M?-1/0:1/0,B=q=>{let D=p?q.x:q.y;Y=M?Math.max(Y,D+(p?q.w:q.h)):Math.min(Y,D)};B(e),B(t);for(let q of a)q!==e&&q!==t&&bs(q.x,q.y,q.x+q.w,q.y+q.h,n,o,c-n,f-o)<=1&&B(q);return Y},w=p?Math.min(e.y,t.y):Math.min(e.x,t.x),v=p?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),k=(M,Y)=>{for(let B of a){if(B===e||B===t)continue;let q=p?B.y<v&&B.y+B.h>w:B.x<v&&B.x+B.w>w,D=p?B.x:B.y,R=D+(p?B.w:B.h);if(q&&(M?R>Y:D<Y))return!1}return!0},L=e.x+e.w/2,I=e.y+e.h/2,N=t.x+t.w/2,O=t.y+t.h/2,W=Math.sign(p?O-I:N-L),U=M=>{let Y=b(M),B=M?1:-1,q=p?M?1:0:M?3:2,D=p?i.ports(e,q,I+W*e.h/4,e.y+8,e.y+e.h-8)[0]:i.ports(e,q,L+W*e.w/4,e.x+8,e.x+e.w-8)[0],R=p?i.ports(t,q,O-W*t.h/4,t.y+8,t.y+t.h-8)[0]:i.ports(t,q,N-W*t.w/4,t.x+8,t.x+t.w-8)[0],P=X=>{if(p){let F=X+(L-X)*Math.min(la(e,X,D,L,D),1),K=X+(N-X)*Math.min(la(t,X,R,N,R),1);return[F,D,X,D,X,R,K,R]}let Q=X+(I-X)*Math.min(la(e,D,X,D,I),1),J=X+(O-X)*Math.min(la(t,R,X,R,O),1);return[D,Q,D,X,R,X,R,J]},G=P(Y+B*Nl);for(let X=0;X<=4;X++){let Q=Y+B*(Nl+X*jy),J=P(Q);if(Zy(J,a,e,t)&&(G=J,i.free(p,Q,D,R)))return{points:G,side:q,p0:D,p1:R,step:X}}return{points:G,side:q,p0:D,p1:R,step:5}},_=p?f>o:c<n,j=k(_,b(_)),Z=k(!_,b(!_)),H=U(_),z=j===Z?U(!_):void 0,C=M=>i.crossings(M.points)*8+M.step,S=Z&&!j||z&&C(z)<C(H)?!_:_,{points:$,side:y,p0:E,p1:x,step:T}=S===_?H:z??U(!_),A=S?1:-1;return T>4&&i.squeezed++,i.take($),i.claim(e,y,E),i.claim(t,y,x),Qy($,2,s,l,p?{nx:A,lean:VC,room:op}:{room:Hc})}let g=Math.hypot(c-n,f-o)||1,u=(c-n)/g,m=(f-o)/g;return(p||o===f)&&i.take([n,o,c,f]),{d:`M${h(n+u*s)},${h(o+m*s)}L${h(c-u*l)},${h(f-m*l)}`,sx:n,sy:o,sdx:-u,sdy:-m,ex:c,ey:f,edx:u,edy:m,x0:n,y0:o,x1:c,y1:f,nx:r?-m:0,ny:r?u:0,lean:0,room:Math.abs(u)>Math.abs(m)?op:Hc,points:[n,o,c,f]}}function s_(e){let t=ip.get((e.shape??"").toLowerCase())??ip.get((e.sprite??"").toLowerCase());if(t)return t;if(e.tags)for(let a of e.tags.split(",")){let i=ip.get(a.trim().toLowerCase());if(i)return i}let r=e.kind;return r.endsWith("person")?"person":r.endsWith("_db")?"cyl":r.endsWith("_queue")?"h-cyl":"rect"}function n_(e,t,r,a,i=hp){let s=s_(e),l=s==="h-cyl"?36:0,n=s==="person"?fp:s==="cyl"?24:0,o=i-2*Yy-l,c=[ze("\xAB"+e.kind.replace(/_/g," ")+"\xBB",!1,t,a-1,o),ze(e.label,!1,t,r,o,1),ze(e.techn?`[${e.techn}]`:void 0,!1,t,a,o),ze(e.descr,!1,t,a,o)],f=0,p=c[3].height>0?4:0;for(let d of c)f=Math.max(f,d.width),p+=d.height;return{shape:e,form:s,labels:c,textH:p,x:0,y:0,w:Math.max(i,f+2*Yy+l),h:Math.max(t_,p+2*r_+n)}}function qy(e,t,r,a,i){let s=0,l=0;for(let n=0;n<e.length;n+=t){let o=Math.min(e.length,n+t),c=0,f=0;for(let p=n;p<o;p++)f=Math.max(f,e[p].h);for(let p=n;p<o;p++){let d=e[p];d.x=c,d.y=l,i&&(d.h=f),c+=d.w+r}s=Math.max(s,c-r),l+=f+a}return[s,e.length>0?l-a:0]}function l_(e,t,r,a,i,s){let l=i===void 0?Uy:12,n=new Map;for(let m of e.boundaries){let b=i===void 0?4e3:Math.max(80,i-2*Il-2*Uy*2),w=m.parent?[ze(m.label,!1,t,r,b,1),ze(m.type?`[${m.type}]`:void 0,!1,t,a,b),ze(m.descr,!1,t,a,b)]:[],v=0,k=0;for(let L of w)v+=L.height,k=Math.max(k,L.width);n.set(m,{boundary:m,kids:[],nodes:[],labels:w,head:v>0?v+dp+6+Nl:l,headW:k,headX:Il,x:0,y:0,w:0,h:0,form:"rect"})}let o=n.get(e.boundaries[0]);for(let m of n.values()){let b=m.boundary.parent;b&&n.get(b)?.kids.push(m)}let c=[o],f=new Map([[o.boundary,0]]);for(let m=0;m<c.length;m++)for(let b of c[m].kids)f.set(b.boundary,f.get(c[m].boundary)+1),c.push(b);for(let m of e.shapes)if(m.parent){let b=f.get(m.parent)??0,w=i===void 0?hp:Math.max(100,Math.min(hp,i-2*b*l-32));n.get(m.parent)?.nodes.push(n_(m,t,r,a,w))}let p=Math.max(1,e.shapeInRow),d=Math.max(1,e.boundaryInRow),g=new Map;for(let m=c.length-1;m>=0;m--){let b=c[m],w=i===void 0?a_:s,v=(U,_,j)=>{if(i===void 0)return _;let Z=1;for(let H of U)Z=Math.max(Z,H.w);return Math.max(1,Math.min(_,Math.floor((i+j-2*l)/(Z+j))))},[k,L]=qy(b.nodes,v(b.nodes,p,w),w,i_,!0),[I,N]=qy(b.kids,v(b.kids,d,zc),zc,zc,!1),O=L>0&&N>0?zc:0,W=b===o?0:l;g.set(b,L+O),b.w=Math.max(k,I,b.headW+2*Il-2*W)+2*W,b.h=(W&&b.head)+L+O+N+W}let u=new Map;for(let m of c){let b=m.x+(m===o?0:l),w=m.y+(m===o?0:m.head);for(let v of m.nodes)v.x+=b,v.y+=w,u.set(v.shape,v);for(let v of m.kids)v.x+=b,v.y+=w+g.get(m);m!==o&&u.set(m.boundary,m)}return{order:c,boxes:u}}function Wc(e,t,r){let a=[];return e&&a.push("fill:"+e),t&&a.push("stroke:"+t),r&&a.push("color:"+r),vt(a)}function np(e,t,r,a,i){return t?ua(e,Sa(t.includes("\xB6\xDF")?t.replace(/\ufb02\u00b0\u00b0?/g,"#").replace(/\u00b6\u00df/g,";"):t),r,a,i):e}function d_(e,t,r){return Nr(r,a=>{if(!a)return lp(e,t,r,!1)[0];let[i,s]=lp(e,t,r,!0,Bc);for(let l=Bc+sp;s>0&&l<=Bc+3*sp;l+=sp){let[n,o]=lp(e,t,r,!0,l);o<s&&([i,s]=[n,o])}return i})}function lp(e,t,r,a,i=Bc){let s=r.fontSize??16,l=Math.round(s*.8125),n=r.measurer??et(r.fontFamily),o=r.padding??8,c=[],{order:f,boxes:p}=l_(e,n,s,l,a?Math.max(80,(r.maxWidth??320)-2*o):void 0,i),d=f[0],g=0,u=0,m=d.w,b=d.h,w=(M,Y,B,q)=>{g=Math.min(g,M),u=Math.min(u,Y),m=Math.max(m,B),b=Math.max(b,q)},v=[],k=new Map;for(let M of e.rels){let Y=M.fromAttr?void 0:e.getC4Shape(M.from),B=M.toAttr?void 0:e.getC4Shape(M.to),q=Y&&p.get(Y),D=B&&p.get(B);if(!q||!D)throw new je(`C4 rel "${M.from}" -> "${M.to}" references an unknown shape or boundary`,"semantic",{type:"c4"});v.push(q,D);let R=k.get(q);R||k.set(q,R=new Set),R.add(D)}let L=[],I=[];for(let M of f)for(let Y of M.nodes)L.push(Y),I.push(Y.x+Fc,Y.y+Fc,Y.x+Y.w-Fc,Y.y+Y.h-Fc);let N=e.rels.length*(L.length+f.length+3*e.rels.length)<=h_,O=(M,Y,B,q)=>{let D=0;for(let R=0;R<I.length;R+=4){let P=Math.min(B,I[R+2])-Math.max(M,I[R]);if(P<=0)continue;let G=Math.min(q,I[R+3])-Math.max(Y,I[R+1]);G>0&&(D+=P*G)}return D},W=M=>M?Math.max(-Gy,Math.min(Gy,M)):0,U="",_=gt("arrow_point"),j=new ZC;for(let M of f)M!==d&&j.frame(M);let Z=e.rels.map((M,Y)=>{let B=v[Y*2],q=v[Y*2+1],D=Wc(void 0,M.lineColor,void 0),R=D.stroke?Xe(D.stroke):"var(--_l)",P=M.type==="birel"||M.type==="rel_b",G=M.type!=="rel_b",X=B!==q&&k.get(q)?.has(B)===!0,Q=e_(B,q,X?o_:0,N?L:void 0,j,P?_:0,G?_:0);return w(Math.min(Q.x0,Q.x1),Math.min(Q.y0,Q.y1),Math.max(Q.x0,Q.x1),Math.max(Q.y0,Q.y1)),P&&N&&I.push(Q.sx-Ht,Q.sy-Ht,Q.sx+Ht,Q.sy+Ht),G&&N&&I.push(Q.ex-Ht,Q.ey-Ht,Q.ex+Ht,Q.ey+Ht),U+=`<g class="pele-edge" data-id="${Oe(M.from+"-"+M.to)}"${D.line}><path d="${Q.d}"/>`+(P?bt("arrow_point",Q.sx,Q.sy,Q.sdx,Q.sdy,R):"")+(G?bt("arrow_point",Q.ex,Q.ey,Q.edx,Q.edy,R):"")+"</g>",Q});for(let M of f){if(!N||M.headW===0)continue;let Y=M.y+dp,B=M.y+M.head-Nl,q=1/0;for(let D of[Il,(M.w-M.headW)/2,M.w-Il-M.headW]){let R=0;for(let P of Z)Ky(P.points,M.x+D-4,Y,M.x+D+M.headW+4,B)&&R++;if(R<q&&(q=R,M.headX=D),R===0)break}I.push(M.x+M.headX-4,Y,M.x+M.headX+M.headW+4,B)}let H="";e.rels.forEach((M,Y)=>{let B=Z[Y],q=M.from+"-"+M.to,D=Wc(void 0,void 0,M.textColor),R=(e.c4Type==="C4Dynamic"?Y+1+": ":"")+M.label,P=ze(R,!1,n,l,B.room),G=ze(M.techn?`[${M.techn}]`:void 0,!1,n,l,B.room,2),X=Math.max(P.width,G.width)+8,Q=P.height+G.height;if(Q===0)return;let J=Math.abs(B.nx)*(X/2)+Math.abs(B.ny)*(Q/2)+2,F=B.lean?Math.max(0,Math.min(B.lean,J-14)):J,K=B.nx*F+(a?0:W(M.offsetX)),re=B.ny*F+(a?0:W(M.offsetY)),ne=.5;if(N){let se=1/0,ee=K!==B.nx*F||re!==B.ny*F;for(let te=0;te<(ee?2:1)&&se>0;te++){let fe=te?B.nx*F:K,ye=te?B.ny*F:re;for(let le of c_){let we=B.x0+(B.x1-B.x0)*le+fe,pe=B.y0+(B.y1-B.y0)*le+ye,ge=O(we-X/2,pe-Q/2,we+X/2,pe+Q/2);if(ge<se&&(se=ge,ne=le,K=fe,re=ye),ge===0)break}}}let de=B.x0+(B.x1-B.x0)*ne+K,ie=B.y0+(B.y1-B.y0)*ne+re-Q/2;N&&I.push(de-X/2,ie,de+X/2,ie+Q),w(de-X/2,ie,de+X/2,ie+Q),H+=`<g class="pele-edge-label" data-id="${Oe(q)}">`+(M.descr?`<title>${Oe(M.descr)}</title>`:"")+`<rect x="${h(de-X/2)}" y="${h(ie)}" width="${h(X)}" height="${h(Q)}" rx="3" fill="var(--_bg)"/>`+np(Re(P,de,ie+P.height/2,D.text)+Re(G,de,ie+P.height+G.height/2,` class="pele-c4-techn" fill="var(--_m)"${D.text}`),M.link,q,c,r)+"</g>"});let z="",C="";for(let M of f){if(M!==d){let Y=M.boundary,B=Wc(Y.bgColor,Y.borderColor,Y.fontColor),q=M.x+M.headX,D=M.y+dp,R=yi(M.labels[0],q,D,` class="pele-cluster-label" font-weight="var(--_hw)"${B.text}`);D+=M.labels[0].height,R+=yi(M.labels[1],q,D,` class="pele-c4-type" font-size="${l}" fill="var(--_m)"${B.text}`),D+=M.labels[1].height,R+=yi(M.labels[2],q,D,` class="pele-c4-descr" font-size="${l}" fill="var(--_m)"${B.text}`),z+=`<g class="pele-cluster pele-c4-${Y.nodeType?"node":"boundary"}" data-id="${Oe(Y.alias)}"><rect x="${h(M.x)}" y="${h(M.y)}" width="${h(M.w)}" height="${h(M.h)}" fill="none" stroke="var(--_b)"${Y.nodeType?"":' stroke-dasharray="6 4"'}${ft(B.shape)}/>`+np(R,Y.link,Y.alias,c,r)+"</g>"}for(let Y of M.nodes){let B=Y.shape,q=B.kind.startsWith("external"),D=Wc(B.bgColor,B.borderColor,B.fontColor),R=' stroke="var(--_b)"'+(q?' stroke-dasharray="4 3"':""),{w:P,h:G,form:X,labels:Q}=Y,J=X==="h-cyl"?-Xy(G)/2:0,F=X==="person"?fp/2:X==="cyl"?Vy(P)/2:0,K=` fill="var(--_m)"${D.text}`,re=F-Y.textH/2,ne=Re(Q[0],J,re+Q[0].height/2,` class="pele-c4-type" font-size="${l-1}"${K}`);re+=Q[0].height,ne+=Re(Q[1],J,re+Q[1].height/2,` class="pele-label" font-weight="var(--_hw)"${D.text}`),re+=Q[1].height,ne+=Re(Q[2],J,re+Q[2].height/2,` class="pele-c4-techn" font-size="${l}"${K}`),re+=Q[2].height+4,ne+=Re(Q[3],J,re+Q[3].height/2,` class="pele-c4-descr" font-size="${l}"${D.text}`),C+=`<g class="pele-node pele-shape-${X} pele-c4-${B.kind}${q?" pele-c4-external":""}" data-id="${Oe(B.alias)}" transform="translate(${h(Y.x+P/2)},${h(Y.y+G/2)})">`+np(Ca(X,P,G,` fill="var(${q?"--_bg":"--_s"})"${R}${D.shape}`,R+D.line)+ne,B.link,B.alias,c,r)+"</g>"}}let S=ze(e.title,!1,n,s,a?It(r):4e3,1),$=S.height>0?S.height+12:0,y=Math.max(m-g,S.width),E=Math.ceil(y+2*o),x=Math.ceil(b-u+$+2*o),T=o-g+(y-(m-g))/2,A=o+$-u;return[{svg:Je("c4",E,x,s,r,e,Re(S,E/2,o+S.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${h(T)},${h(A)})">`+(z?`<g class="pele-clusters">${z}</g>`:"")+(U?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${U}</g>`:"")+(C?`<g class="pele-nodes">${C}</g>`:"")+(H?`<g class="pele-edge-labels" font-size="${l}">${H}</g>`:"")+"</g>"),width:E,height:x,links:c},j.squeezed]}var OC,PC,zC,Fy,FC,tp,rp,ap,BC,HC,YC,UC,hn,Nl,jy,jC,VC,op,Hc,fp,Vy,Xy,cp,KC,By,ZC,hp,t_,Yy,r_,a_,i_,Uy,zc,Il,dp,ip,o_,Bc,sp,Gy,Fc,c_,h_,Jy,ex=Ve(()=>{ps();hi();Ti();tr();zt();pr();ut();wt();OC=new Set(["label","type","descr","techn","sprite","tags","link","bgColor","fontColor","borderColor","shadowing","shape","legendText","legendSprite"]),PC=new Set(["label","descr","techn","sprite","tags","link","textColor","lineColor"]);zC=class{constructor(){ce(this,"type","c4");ce(this,"c4Type");ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"shapes",[]);ce(this,"boundaries",[{alias:"global",label:"global",type:"global",parent:void 0}]);ce(this,"rels",[]);ce(this,"shapeInRow",4);ce(this,"boundaryInRow",2);ce(this,"shapeIndex",new Map);ce(this,"boundaryIndex",new Map);ce(this,"relIndex",new Map);ce(this,"current",this.boundaries[0]);ce(this,"stack",[])}setC4Type(e){this.c4Type=e}setTitle(e){this.title=e}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
107
|
+
`)}element(e,t,r,a){let i=typeof r=="string"?t.get(r):void 0;return i===void 0&&(i={alias:"",label:"",parent:void 0},e.push(i),typeof r=="string"?(i.alias=r,t.set(r,i)):(i.aliasAttr=r,_l(i,r))),zy(i,a),i}addPersonOrSystem(e,t){let r=this.element(this.shapes,this.shapeIndex,t[0],t[1]);cn(r,"descr",t[2]),this.finishShape(r,e,t,3)}addContainer(e,t){let r=this.element(this.shapes,this.shapeIndex,t[0],t[1]);cn(r,"techn",t[2]),cn(r,"descr",t[3]),this.finishShape(r,e,t,4)}addComponent(e,t){this.addContainer(e,t)}finishShape(e,t,r,a){Qt(e,"sprite",r[a]),Qt(e,"tags",r[a+1]),Qt(e,"link",r[a+2]),e.kind=t,e.parent=this.current}boundary(e,t){let r=this.element(this.boundaries,this.boundaryIndex,e[0],e[1]);return e[2]===void 0?r.type=t:Qt(r,"type",e[2]),r}open(e){e.parent=this.current,this.stack.push(this.current),this.current=e}addPersonOrSystemBoundary(e,t="system"){let r=this.boundary(e,t);Qt(r,"tags",e[3]),Qt(r,"link",e[4]),this.open(r)}addContainerBoundary(e){this.addPersonOrSystemBoundary(e,"container")}addDeploymentNode(e,t){let r=this.boundary(t,"node");cn(r,"descr",t[3]),Qt(r,"sprite",t[4]),Qt(r,"tags",t[5]),Qt(r,"link",t[6]),r.nodeType=e,this.open(r)}popBoundaryParseStack(){this.current=this.stack.pop()??this.boundaries[0]}addRel(e,t){let r=t[0],a=t[1];if(r===void 0||a===void 0||t[2]===void 0)return;let i=typeof r=="string"&&typeof a=="string",s=i?this.relIndex.get(r)?.get(a):void 0;if(s===void 0){if(s={type:e,from:"",to:"",label:""},this.rels.push(s),i){let l=this.relIndex.get(r);l===void 0&&this.relIndex.set(r,l=new Map),l.set(a,s)}typeof r=="string"?s.from=r:s.fromAttr=r,typeof a=="string"?s.to=a:s.toAttr=a}s.type=e,zy(s,t[2]),cn(s,"techn",t[3]),cn(s,"descr",t[4]),Qt(s,"sprite",t[5]),Qt(s,"tags",t[6]),Qt(s,"link",t[7])}getC4Shape(e){return this.shapeIndex.get(e)??this.boundaryIndex.get(e)}updateElStyle(e,t){let r=typeof t[0]=="string"?this.getC4Shape(t[0]):void 0;r!==void 0&&(Qt(r,"bgColor",t[1]),Qt(r,"fontColor",t[2]),Qt(r,"borderColor",t[3]),Qt(r,"shadowing",t[4]),Qt(r,"shape",t[5]),Qt(r,"sprite",t[6]),Qt(r,"techn",t[7]),Qt(r,"legendText",t[8]),Qt(r,"legendSprite",t[9]))}updateRelStyle(e,t){let r=t[0],a=t[1],i=typeof r=="string"&&typeof a=="string"?this.relIndex.get(r)?.get(a):void 0;if(i===void 0)return;Qt(i,"textColor",t[2]),Qt(i,"lineColor",t[3]);let s=t[4],l=t[5];typeof s=="string"?i.offsetX=parseInt(s):s!==void 0&&_l(i,s),typeof l=="string"?i.offsetY=parseInt(l):l!==void 0&&_l(i,l)}updateLayoutConfig(e,t){let r=s=>s===void 0?NaN:parseInt(typeof s=="string"?s:s.value),a=r(t[0]),i=r(t[1]);a>=1&&(this.shapeInRow=a),i>=1&&(this.boundaryInRow=i)}},Fy=["$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"],FC=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]]),tp=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],rp=/[\n\r\u2028\u2029]/g;ap=["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"],BC=["rel","birel","rel_u","rel_d","rel_l","rel_r","rel_b","rel"],HC=["node","nodeL","nodeR"],YC="'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'",UC="'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'";hn=28,Nl=20,jy=7,jC=8,VC=30,op=88,Hc=160,fp=26,Vy=e=>Math.min(12,Math.max(6,e/14)),Xy=e=>Math.min(12,e/4);cp=6,KC=3,By=12,ZC=class{constructor(){ce(this,"upright",[]);ce(this,"level",[]);ce(this,"frames",[[],[]]);ce(this,"taken",new Map);ce(this,"squeezed",0)}free(e,t,r,a){let i=Math.min(r,a),s=Math.max(r,a),l=(n,o)=>{for(let c=0;c<n.length;c+=3)if(Math.abs(n[c]-t)<o&&n[c+1]<s&&n[c+2]>i)return!0;return!1};return!l(e?this.upright:this.level,cp)&&!l(this.frames[e?0:1],KC)}crossings(e){let t=0;for(let r=2;r<e.length;r+=2){let a=e[r]===e[r-2],i=a?e[r]:e[r+1],s=Math.min(a?e[r-1]:e[r-2],a?e[r+1]:e[r]),l=Math.max(a?e[r-1]:e[r-2],a?e[r+1]:e[r]),n=a?this.level:this.upright;for(let o=0;o<n.length;o+=3)n[o]>s&&n[o]<l&&n[o+1]<i&&n[o+2]>i&&t++}return t}frame(e){this.frames[0].push(e.x,e.y,e.y+e.h,e.x+e.w,e.y,e.y+e.h),this.frames[1].push(e.y,e.x,e.x+e.w,e.y+e.h,e.x,e.x+e.w)}take(e){for(let t=2;t<e.length;t+=2)e[t]===e[t-2]?this.upright.push(e[t],Math.min(e[t-1],e[t+1]),Math.max(e[t-1],e[t+1])):e[t+1]===e[t-1]&&this.level.push(e[t+1],Math.min(e[t-2],e[t]),Math.max(e[t-2],e[t]))}ports(e,t,r,a,i){let s=this.taken.get(e)??[],l=[];for(let n=0;n<9&&l.length<4;n++){let o=r+(n&1?1:-1)*Math.ceil(n/2)*By;if(o<a||o>i)continue;let c=!0;for(let f=0;f<s.length;f+=2)s[f]===t&&Math.abs(s[f+1]-o)<By&&(c=!1);c&&l.push(o)}return l.length?l:[r]}claim(e,t,r){let a=this.taken.get(e);a?a.push(t,r):this.taken.set(e,[t,r])}};hp=216,t_=64,Yy=14,r_=12,a_=100,i_=88,Uy=Nl+8,zc=48,Il=16,dp=10,ip=new Map([["person","person"],["box","rect"],["rounded","rect"],["component","rect"],["cylinder","cyl"],["database","cyl"],["db","cyl"],["queue","h-cyl"],["pipe","h-cyl"]]);o_=7,Bc=36,sp=24,Gy=2e3,Fc=8,c_=[.5,.4,.6,.3,.7,.2,.8],h_=2e6;Jy={type:"c4",parse(e,t,r){let a=new zC;return r&&(a.title=r),GC(e,a),a},render:d_}});var tx={};Ct(tx,{c4:()=>Jy});var rx=Ve(()=>{ex()});function f_(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 p_(e){switch(e.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}function u_(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 g_(e){return e.includes("==")?"thick":"normal"}function m_(e){return e.includes(".-")?"dotted":"solid"}function ix(e,t){let r=e.flat(),a=-1;for(let i of r)if(i.type==="column-setting"){a=i.columns??-1;break}return{list:r,at:0,parent:t,children:[],columns:a}}function w_(e){let t=e.length,r=[],a=[],i=[],s=[],l=0,n=0,o=(U,_,j)=>(r.push(U),a.push(_),i.push(n),n=j,!0),c=(U,_)=>o(U,e.slice(n,_),_),f=U=>{s.push(l),l=U},p=()=>{s.length>0&&(l=s.pop())},d=U=>{for(;U<t&&Ue(e.charCodeAt(U));)U++;return U},g=U=>{for(;U<t;){let _=e.charCodeAt(U);if(_<48||_>57)break;U++}return U},u=U=>{for(;U<t&&Qe(e.charCodeAt(U));)U++;return U},m=U=>e.startsWith(U,n)&&!Qe(e.charCodeAt(n+U.length)),b=()=>(e.charCodeAt(n+1)===96?(f(2),n+=2):(f(1),n++),!0),w=U=>{if(e.charCodeAt(U)!==46)return-1;do U++;while(e.charCodeAt(U)===46);if(e.charCodeAt(U)!==45)return-1;let _=e.charCodeAt(U+1);return _===120||_===111||_===62?U+2:U+1},v=U=>{let _=e.charCodeAt(U);(_===120||_===111||_===60)&&U++;let j=e.charCodeAt(U);if(j===46)return w(U);if(j!==45&&j!==61)return-1;let Z=U+1;for(;e.charCodeAt(Z)===j;)Z++;if(Z-U===1)return j===45?w(Z):-1;let H=e.charCodeAt(Z);return H===120||H===111||H===62?Z+1:Z-U>=3?Z:-1},k=()=>{let U=v(n);if(U>=0)return c(33,d(U));let _=e.charCodeAt(n)===60?n+1:n,j=e.charCodeAt(_),Z=e.charCodeAt(_+1);return j===45&&(Z===45||Z===46)||j===61&&Z===61?(f(6),c(34,d(_+2))):!1},L=U=>{let _=e.indexOf(`
|
|
108
|
+
`,n);return _===-1&&(_=t),p(),c(U,_)},I=(U,_)=>{let j=u(n);if(j===n)return!1;for(;e.charCodeAt(j)===44;){let Z=d(j+1),H=u(Z);if(H===Z)break;j=H}return l=_,c(U,j)},N=U=>{if(Ue(U))return n=d(n+1),!0;let _;switch(U){case 98:if(e.startsWith("block",n)){if(m("block-beta"))return c(2,n+10);if(e.charCodeAt(n+5)===58)return c(3,n+6);if(!Qe(e.charCodeAt(n+5)))return c(2,n+5)}break;case 99:if(e.startsWith("columns",n)){if(_=d(n+7),_>n+7){if(e.startsWith("auto",_)&&!Qe(e.charCodeAt(_+4)))return o(4,"-1",_+4);let j=g(_);if(j>_)return o(4,e.slice(_,j),j)}}else if(e.startsWith("class",n)){let j=e.startsWith("Def",n+5),Z=j?n+8:n+5;if(_=d(Z),_>Z)return f(j?7:9),c(j?11:15,_)}break;case 34:return b();case 115:if(e.startsWith("space",n)){if(e.charCodeAt(n+5)===58){let j=g(n+6);if(j>n+6)return o(7,e.slice(n+6,j),j)}if(!Qe(e.charCodeAt(n+5)))return o(7,"1",n+5)}else if(e.startsWith("style",n)&&(_=d(n+5),_>n+5))return f(11),c(18,_);break;case 100:if(m("default"))return c(8,n+7);break;case 108:if(m("linkStyle"))return c(9,n+9);break;case 105:if(m("interpolate"))return c(10,n+11);break;case 97:if(e.startsWith("accTitle",n)){if(_=d(n+8),e.charCodeAt(_)===58)return f(13),c(21,d(_+1))}else if(e.startsWith("accDescr",n)){_=d(n+8);let j=e.charCodeAt(_);if(j===58)return f(14),c(23,d(_+1));if(j===123)return f(15),n=d(_+1),!0}break;case 101:if(m("end"))return c(26,d(n+3));break;case 45:return e.charCodeAt(n+1)===41?(f(3),c(27,n+2)):k();case 61:return k();case 60:return e.charCodeAt(n+1)===91?(f(4),c(29,n+2)):k();case 40:{let j=e.charCodeAt(n+1),Z=j===45||j===91?2:j===40?e.charCodeAt(n+2)===40?3:2:1;return f(3),c(27,n+Z)}case 41:case 123:return f(3),c(27,e.charCodeAt(n+1)===U?n+2:n+1);case 62:return f(3),c(27,n+1);case 91:{let j=e.charCodeAt(n+1);return f(3),c(27,j===91||j===124||j===40||j===92||j===47?n+2:n+1)}case 58:{let j=g(n+1);return j>n+1?o(36,e.slice(n+1,j),j):!1}}for(_=n;_<t;){let j=e.charCodeAt(_);if(j<128?fx[j]===1:Ue(j))break;_++}return _>n&&c(32,_)},O=U=>{let _=e.charCodeAt(n+1),j=0;switch(U){case 34:return b();case 40:j=_===45?2:_===40?e.charCodeAt(n+2)===40?3:2:1;break;case 41:j=_===41?e.charCodeAt(n+2)===41?3:2:_===93?2:1;break;case 125:j=_===125?2:1;break;case 45:j=_===41?2:0;break;case 93:j=_===93||_===41||_===62?2:1;break;case 92:case 47:j=_===93?2:0;break}return j===0?!1:(p(),c(28,n+j))},W=U=>{if(U===41)return p(),p(),o(30,"]>",d(n+1));let _=d(U===44?n+1:n);for(let j of x_)if(e.startsWith(j,_)){let Z=d(_+j.length);return o(31,e.slice(U===44?_:n,Z),Z)}return!1};for(;;){if(n>=t){let j=-1;switch(l){case 0:j=37;break;case 1:j=6;break;case 8:j=14;break;case 10:j=17;break;case 12:j=20;break;case 13:j=22;break;case 14:j=24;break;case 15:j=25;break}n=t,j!==-1&&o(j,"",t);break}let U=e.charCodeAt(n),_=!0;switch(l){case 0:_=N(U);break;case 1:if(U===34)p(),n++;else{let j=e.indexOf('"',n);c(6,j===-1?t:j)}break;case 2:if(U===96)_=e.charCodeAt(n+1)===34,_&&(p(),n+=2);else if(U===34)_=!1;else{let j=n+1;for(;j<t;){let Z=e.charCodeAt(j);if(Z===96||Z===34)break;j++}c(5,j)}break;case 3:_=O(U);break;case 4:if(U===34)b();else if(U===93&&e.charCodeAt(n+1)===62){let j=d(n+2);_=e.charCodeAt(j)===40,_&&(f(5),n=j+1)}else _=!1;break;case 5:_=W(U);break;case 6:if(U===34)e.charCodeAt(n+1)===96?b():(c(35,n+1),f(1));else{let j=v(d(n));_=j>=0,_&&(p(),c(33,d(j)))}break;case 7:{let j=12,Z=e.startsWith("DEFAULT",n)?n+7:n,H=d(Z);(Z===n||H===Z)&&(j=13,Z=u(n),H=d(Z)),_=Z>n&&H>Z,_&&(l=8,c(j,H));break}case 8:L(14);break;case 9:_=I(16,10);break;case 10:L(17);break;case 11:_=I(19,12);break;case 12:L(20);break;case 13:L(22);break;case 14:L(24);break;case 15:if(U===125)p(),n++;else{let j=e.indexOf("}",n);c(25,j===-1?t:j)}break}if(!_)return r.push(1),a.push(""),i.push(n),{types:r,texts:a,starts:i}}return r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function nx(e){let t=e[e.length-1];return Array.isArray(t)?(e.pop(),e.concat(t)):e}function b_(e,t){let{types:r,texts:a,starts:i}=w_(e),s=0,l=d=>{let g=r[s];throw g===1?it("block",e,i[s],"",!0):it("block",e,i[s],`Expecting ${d}, got '${sx[g]}'`)},n=d=>(r[s]!==d&&l(`'${sx[d]}'`),a[s++]),o=()=>{let d=n(32);if(r[s]===27){let g=a[s++],u=n(6);return{id:d,label:u,typeStr:g+n(28)}}if(r[s]===29){let g=a[s++],u=n(6),m=[n(31)];for(;r[s]===31;)m.push(a[s++]);return{id:d,label:u,typeStr:g+n(30),directions:m}}return{id:d}},c=()=>{let d=o(),g=r[s]===36?parseInt(a[s++],10):1,u={id:d.id,label:d.label,type:t.typeStr2Type(d.typeStr),directions:d.directions,widthInColumns:g},m;for(;r[s]===33||r[s]===34;){let b="";r[s++]===34&&(n(35),b=n(6),n(33));let w=a[s-1],v=o(),k=t.edgeStrToEdgeData(w),L=t.edgeStrToEdgeStartData(w),I=t.edgeStrToThickness(w),N=t.edgeStrToPattern(w);m??(m=[{id:u.id,label:u.label,type:u.type,directions:u.directions}]),u={id:v.id,label:v.label,type:t.typeStr2Type(v.typeStr),directions:v.directions},m.push({id:m[m.length-1].id+"-"+v.id,start:m[m.length-1].id,end:v.id,label:b,type:"edge",thickness:I,pattern:N,directions:v.directions,arrowTypeEnd:k,arrowTypeStart:L},u)}return m??u};n(2);let f=[],p=[];for(;;)switch(r[s]){case 32:p.push(c());break;case 4:p.push({type:"column-setting",columns:parseInt(a[s++],10)});break;case 7:{let d=parseInt(a[s++],10);p.push({id:t.generateId(),type:"space",label:"",width:d,children:[]});break}case 2:s++,f.push({list:p,header:void 0}),p=[];break;case 3:s++,r[s]!==32&&l("'NODE_ID'"),f.push({list:p,header:c()}),p=[];break;case 26:{let d=f.pop();if(d===void 0||p.length===0)return l(Rl);s++;let g=t.generateId(),u=nx(p);p=d.list,p.push(d.header===void 0?{id:g,type:"composite",label:"",children:u}:{...d.header,type:"composite",children:u});break}case 11:{s++;let d=n(13).trim();p.push({type:"classDef",id:d,css:n(14).trim()});break}case 15:{s++;let d=n(16).trim();p.push({type:"applyClass",id:d,styleClass:n(17).trim()});break}case 18:{s++;let d=n(19).trim();p.push({type:"applyStyles",id:d,stylesStr:n(20).trim()});break}case 37:f.length>0&&l(Rl+", 'end'"),p.length===0&&l(Rl),t.setHierarchy(nx(p));return;default:l(p.length===0?Rl:Rl+(f.length>0?", 'end'":", 'EOF'"))}}function $_(e){let t=0;if(e)for(let r of e)switch(r.trim()){case"right":t|=Qa;break;case"left":t|=Ja;break;case"up":t|=ei;break;case"down":t|=ti;break;case"x":t|=Qa|Ja;break;case"y":t|=ei|ti;break}return t}function qc(e){return e!==0&&!(e&(ei|ti))?"x":e!==0&&!(e&(Qa|Ja))?"y":""}function lx(e,t,r){let a=qc(e),i=Fi(e,Ja)-Fi(e,Qa),s=Fi(e,ei)-Fi(e,ti);if(a==="x"){let l=Math.max(r+8,14)+2*pn,n=Math.min(l/2,Uc);return{w:Math.max(t+12,16)+n*(e===(Qa|Ja)?2:1),h:l,dx:i*n/2,dy:0}}if(a==="y"){let l=Math.max(t+16,14)+2*pn,n=Math.min(l/2,Uc);return{w:l,h:Math.max(r+8,16)+n*(e===(ei|ti)?2:1),dx:0,dy:s*n/2}}return{w:Math.max(t+16,24)+Wi*(Fi(e,Ja)+Fi(e,Qa)),h:Math.max(r+8,24)+Wi*(Fi(e,ei)+Fi(e,ti)),dx:i*Wi/2,dy:s*Wi/2}}function k_(e,t,r,a){let i=qc(e),s=t/2,l=r/2,n;if(i==="x"){let c=Math.min(l,Uc),f=l-pn,p=e&Ja?-s+c:-s,d=e&Qa?s-c:s;n=[p,-f,d,-f],e&Qa&&n.push(d,-l,s,0,d,l),n.push(d,f,p,f),e&Ja&&n.push(p,l,-s,0,p,-l)}else if(i==="y"){let c=Math.min(s,Uc),f=s-pn,p=e&ei?-l+c:-l,d=e&ti?l-c:l;n=[f,p,f,d],e&ti&&n.push(s,d,0,l,-s,d),n.push(-f,d,-f,p),e&ei&&n.push(-s,p,0,-l,s,p)}else{let c=e&Ja?-s+Wi:-s,f=e&Qa?s-Wi:s,p=e&ei?-l+Wi:-l,d=e&ti?l-Wi:l,g=(c+f)/2,u=(p+d)/2,m=Math.min(10,(f-c)/2),b=Math.min(10,(d-p)/2);n=[c,p],e&ei&&n.push(g-m,p,g,-l,g+m,p),n.push(f,p),e&Qa&&n.push(f,u-b,s,u,f,u+b),n.push(f,d),e&ti&&n.push(g+m,d,g,l,g-m,d),n.push(c,d),e&Ja&&n.push(c,u+b,-s,u,c,u-b)}let o="";for(let c=0;c<n.length;c+=2)o+=(c?" ":"")+h(n[c])+","+h(n[c+1]);return`<polygon points="${o}" stroke-linejoin="round"${a}/>`}function A_(e,t){if(e===0||!Number.isInteger(e))throw new je("Columns must be an integer !== 0.","semantic",{type:"block"});if(t<0||!Number.isInteger(t))throw new je("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 v_(e,t,r){let a=e.columns,i=[],s=0,l=0,n=0,o=0;for(let f of e.children){let{px:p,py:d}=A_(a,s),g=f.span>=1?Math.min(f.span,M_):1;if(a>0&&g>a-p&&(g=a-p),f.span=g,f.col=p,f.row=d,s+=g,p+g>l&&(l=p+g),d===i.length&&i.push(0),f.children.length===0?i[d]=-1:i[d]>=0&&f.nh>i[d]&&(i[d]=f.nh),f.space)continue;let u=(f.nw-t*(g-1))/g;u>n&&(n=u),f.nh>o&&(o=f.nh)}let c=(i.length-1)*t;for(let f=0;f<i.length;f++)i[f]<0&&(i[f]=o),c+=i[f];e.cols=l,e.heights=i,e.nw=Math.max(e.nw,l*n+(l-1)*t+2*r),e.nh=c+2*r+e.head}function E_(e,t,r){let{cols:a,heights:i}=e,s=i.length,l=(e.w-2*r-(a-1)*t)/a,n=e.h-2*r-e.head-(s-1)*t,o=0;for(let u of i)o+=u;let c=o>0?n/o:0,f=o>0?0:n/s,p=e.x-e.w/2+r,d=e.y-e.h/2+r+e.head,g=0;for(let u of e.children){for(;g<u.row;g++)d+=i[g]*c+f+t;u.w=l*u.span+t*(u.span-1),u.h=i[g]*c+f,u.x=p+u.col*(l+t)+u.w/2,u.y=d+u.h/2}}function S_(e,t){let r=[e];for(let a=0;a<r.length;a++)for(let i of r[a].children)r.push(i);for(let a=r.length-1;a>=0;a--){let i=r[a];i.children.length>0&&v_(i,t,a===0?0:t)}e.w=e.nw,e.h=e.nh,e.x=e.w/2,e.y=e.h/2;for(let a=0;a<r.length;a++){let i=r[a];i.children.length>0&&E_(i,t,a===0?0:t)}return{width:e.w,height:e.h}}function Gc(e){return e.kind===0&&(e.shape==="circle"||e.shape==="dbl-circ")}function dn(e,t,r){let a=e.bw/2,i=e.bh/2,s=Math.abs(t-e.x),l=i;return Gc(e)?l=Math.sqrt(Math.max(a*a-s*s,0)):e.kind===0&&e.shape==="diam"?l=i*Math.max(1-s/a,0):e.kind===0?l=i-di(e.shape,e.bw,e.bh,r>0?2:0):e.kind===1&&qc(e.mask)==="x"&&(l=i-pn),e.y+r*l}function fn(e,t,r){let a=e.bw/2,i=e.bh/2,s=Math.abs(t-e.y),l=a;return Gc(e)?l=Math.sqrt(Math.max(i*i-s*s,0)):e.kind===0&&e.shape==="diam"?l=a*Math.max(1-s/i,0):e.kind===0?l=a-di(e.shape,e.bw,e.bh,r>0?1:3):e.kind===1&&qc(e.mask)==="y"&&(l=a-pn),e.x+r*l}function dx(e,t,r,a){let i=t-e.x,s=r-e.y,l=e.bw/2,n=e.bh/2,o;Gc(e)?o=l/(Math.hypot(i,s)||1):e.kind===0&&e.shape==="diam"?o=1/(Math.abs(i)/l+Math.abs(s)/n||1):o=Math.min(i===0?1/0:l/Math.abs(i),s===0?1/0:n/Math.abs(s)),o===1/0&&(o=0),a.push(e.x+i*o,e.y+s*o)}function z_(e,t,r,a,i){let s=i.x-i.bw/2+1,l=i.x+i.bw/2-1,n=i.y-i.bh/2+1,o=i.y+i.bh/2-1;if(e<s&&r<s||e>l&&r>l||t<n&&a<n||t>o&&a>o)return!1;if(e===r||t===a)return!0;let c=r-e,f=a-t,p=(g,u)=>Math.sign(c*(u-t)-f*(g-e)),d=p(s,n);return d===0||p(l,n)!==d||p(l,o)!==d||p(s,o)!==d}function pp(e,t,r,a){let i=0;for(let s of a)if(!(s===t||s===r)){for(let l=0;l+3<e.length;l+=2)if(z_(e[l],e[l+1],e[l+2],e[l+3],s)){i++;break}}return i}function F_(e,t,r,a){let i=e.x-e.bw/2,s=e.x+e.bw/2,l=e.y-e.bh/2,n=e.y+e.bh/2,o=t.x-t.bw/2,c=t.x+t.bw/2,f=t.y-t.bh/2,p=t.y+t.bh/2,d=Math.max(i,o),g=Math.min(s,c),u=Math.max(l,f),m=Math.min(n,p),b=g-d>6,w=m-u>6;if(b&&w){let Z=e.bw*e.bh<=t.bw*t.bh?e:t,H=Z===e?t:e,z=Z.y-Z.bh/2-(H.y-H.bh/2),C=H.y+H.bh/2-(Z.y+Z.bh/2),S=Z.x-Z.bw/2-(H.x-H.bw/2),$=H.x+H.bw/2-(Z.x+Z.bw/2),y=Math.min(z,C,S,$),E;return y===C?E=[Z.x,dn(Z,Z.x,1),Z.x,H.y+H.bh/2]:y===z?E=[Z.x,dn(Z,Z.x,-1),Z.x,H.y-H.bh/2]:y===$?E=[fn(Z,Z.y,1),Z.y,H.x+H.bw/2,Z.y]:E=[fn(Z,Z.y,-1),Z.y,H.x-H.bw/2,Z.y],Z===e?E:[E[2],E[3],E[0],E[1]]}if(b){let Z=Math.min(6,(g-d)/2),H=Math.min(Math.max((d+g)/2+r,d+Z),g-Z),z=t.y>e.y?1:-1;return[H,dn(e,H,z),H,dn(t,H,-z)]}if(w){let Z=Math.min(6,(m-u)/2),H=Math.min(Math.max((u+m)/2+r,u+Z),m-Z),z=t.x>e.x?1:-1;return[fn(e,H,z),H,fn(t,H,-z),H]}let v=t.x>e.x?1:-1,k=t.y>e.y?1:-1,L=[fn(e,e.y,v),e.y,t.x,e.y,t.x,dn(t,t.x,-k)],I=[e.x,dn(e,e.x,k),e.x,t.y,fn(t,t.y,-v),t.y],N=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y),O=N?L:I;if(a===void 0)return O;let W=pp(O,e,t,a);if(W===0)return O;let U=N?I:L,_=pp(U,e,t,a);if(_<W&&(O=U,W=_),W===0)return O;let j=[];return dx(e,t.x,t.y,j),dx(t,e.x,e.y,j),pp(j,e,t,a)<W?j:O}function W_(e,t,r){let a=e.length,i=e[0],s=e[1],l=e[a-2],n=e[a-1],o=e[2]-i,c=e[3]-s,f=Math.hypot(o,c);o/=f||1,c/=f||1;let p=l-e[a-4],d=n-e[a-3],g=Math.hypot(p,d);if(p/=g||1,d/=g||1,a===4&&t+r>f){let m=f/(t+r);t*=m,r*=m}t=Math.min(t,f),r=Math.min(r,g);let u=`M${h(i+o*t)},${h(s+c*t)}`;if(a===6){let m=Math.max(0,Math.min(C_,f-t,g-r));u+=`L${h(e[2]-o*m)},${h(e[3]-c*m)}Q${h(e[2])},${h(e[3])} ${h(e[2]+p*m)},${h(e[3]+d*m)}`}return u+=`L${h(l-p*r)},${h(n-d*r)}`,{d:u,sx:i,sy:s,sdx:-o,sdy:-c,ex:l,ey:n,edx:p,edy:d}}function px(e,t){let r=e.bw/2,a=e.bh/2,i=Math.max(1,Math.min(10+5*(t-1),r,a));if(Gc(e)){let s=e.x+r*Math.SQRT1_2,l=e.y-r*Math.SQRT1_2,n=2*Math.asin(Math.min(1,i/(2*r))),o=c=>Math.atan2(e.y-r*Math.sin(c)-l,e.x+r*Math.cos(c)-s);return[s,l,i,o(Math.PI/4+n),o(Math.PI/4-n)]}if(e.kind===0&&e.shape==="diam"){let s=Math.atan2(a,r);return[e.x+r/2,e.y-a/2,i,s+Math.PI,s]}return[e.x+r,e.y-a,i,Math.PI,Math.PI/2]}function B_(e,t,r,a){let[i,s,l,n,o]=px(e,t),c=n+r/l,f=o-a/l,p=(f-c)%(2*Math.PI);p<=0&&(p+=2*Math.PI);let d=i+l*Math.cos(c),g=s+l*Math.sin(c),u=i+l*Math.cos(f),m=s+l*Math.sin(f),b=i+l*Math.cos(n),w=s+l*Math.sin(n),v=i+l*Math.cos(o),k=s+l*Math.sin(o),L=Math.hypot(b-d,w-g),I=Math.hypot(v-u,k-m);return{d:`M${h(d)},${h(g)}A${h(l)},${h(l)} 0 ${p>Math.PI?1:0} 1 ${h(u)},${h(m)}`,sx:b,sy:w,sdx:L>0?(b-d)/L:Math.sin(n),sdy:L>0?(w-g)/L:-Math.cos(n),ex:v,ey:k,edx:I>0?(v-u)/I:-Math.sin(o),edy:I>0?(k-m)/I:Math.cos(o)}}function Y_(e,t,r,a,i,s,l){if(l===void 0)return .5;for(let n of H_){let o=e[t]+(e[t+2]-e[t])*n,c=e[t+1]+(e[t+3]-e[t+1])*n,f=!0;for(let p of l)if(p!==i&&p!==s&&Math.abs(o-p.x)<(r+p.bw)/2&&Math.abs(c-p.y)<(a+p.bh)/2){f=!1;break}if(f)return n}return .5}function U_(e,t,r){return Nr(r,a=>q_(e,t,r,a))}function q_(e,t,r,a){let i=r.fontSize??16,s=Math.round(i*.875),l=r.measurer??et(r.fontFamily),n=r.padding??8,o=r.icons,c=t.block?.padding,f=Math.min(typeof c=="number"&&c>=0?Math.min(c,200):T_,a?6:1/0),p=a?80:ox,d=q=>{let D=[],R=P=>{for(let G of P)for(let X of G.split(";"))D.push(X)};for(let P of q.classes&&q.classes.length>0?q.classes:R_){let G=e.classes.get(P);G&&R(G.styles)}return q.styles&&R(q.styles),vt(D)},g=(q,D)=>{let R=q.type,P=R==="space"?vt(hx):d(q),G=(P.bold?1:0)|(P.italic?2:0),X=P.fontSize??i,Q=0,J="",F,K=0,re=0,ne=0,de=0,ie=0,se=0;if(R==="space")Q=3,F=ze(void 0,!1,l,X,p);else if(R==="composite")Q=2,F=ze(q.label,!1,l,X,a?It(r):4e3,G),ne=F.height>0?F.height+4:0,K=F.width+2*f,re=ne+2*f;else if(R==="block_arrow"){Q=1,F=ze(q.label,!1,l,X,p,G);let ee=!0;for(let fe of F.lines)for(let ye of fe)(ye.icon!==void 0||ye.text.trim()!=="")&&(ee=!1);de=$_(q.directions);let te=ee?lx(de,0,0):lx(de,F.width,F.height);K=te.w,re=te.h,ie=te.dx,se=te.dy}else{J=D_.get(R??"")??"rect",F=ze(q.label,!1,l,X,p,G);let ee=Si(J,F.width,F.height);K=ee.w,re=J==="cyl"?Math.max(ee.h,F.height+40):ee.h,se=ee.dy}return{children:[],columns:Q===2?q.columns??-1:-1,span:Q===3?1:q.widthInColumns??1,space:Q===3,head:ne,nw:K,nh:re,col:0,row:0,cols:0,heights:N_,x:0,y:0,w:0,h:0,block:q,kind:Q,index:D,shape:J,label:F,style:P,mask:de,dx:ie,dy:se,bw:0,bh:0}},u=g(e.root,0);u.nw=0,u.nh=0;let m=[u],b=new Map;for(let q=0;q<m.length;q++){let D=m[q];if(D.kind===2)for(let R of D.block.children??I_){let P=g(R,m.length);D.children.push(P),m.push(P),P.kind!==3&&b.set(R.id,P)}}let w=S_(u,f),v=[];for(let q of m)q.kind===0&&O_.has(q.shape)?(q.bw=q.nw,q.bh=q.nh):q.kind===1?(q.bw=q.span>1?q.w:q.nw,q.bh=q.nh):(q.bw=q.w,q.bh=q.kind===0&&P_.has(q.shape)?q.nh:q.h),q.kind===0&&q.shape==="cyl"&&(q.dy=Math.min(12,Math.max(6,q.bw/14))/2),(q.kind===0||q.kind===1)&&v.push(q);let k=new Map,L=new Set,I=[],N=[];for(let q of e.edges){let D=b.get(q.start??""),R=b.get(q.end??"");if(D===void 0||R===void 0)continue;let P=Math.min(D.index,R.index)*m.length+Math.max(D.index,R.index);k.set(P,(k.get(P)??0)+1),q.label&&L.add(P),I.push([D,R]),N.push(q)}let O=N.length*v.length<=L_?v:void 0,W=new Map,U=[],_=0,j=0,Z=w.width,H=w.height,z=(q,D,R,P)=>{q-R/2<_&&(_=q-R/2),q+R/2>Z&&(Z=q+R/2),D-P/2<j&&(j=D-P/2),D+P/2>H&&(H=D+P/2)};for(let q=0;q<N.length;q++){let[D,R]=I[q],P=Math.min(D.index,R.index)*m.length+Math.max(D.index,R.index),G=k.get(P)??1,X=W.get(P)??0;W.set(P,X+1);let Q=ze(N[q].label,!1,l,s,ox),J,F,K;if(D===R){let[re,ne,de]=px(D,X+1);J=[],z(re,ne,2*de+2,2*de+2),F=re+de+6+Q.width/2,K=ne-de/2}else{let re=L.has(P)?Math.round(s*1.5)+2:14;J=F_(D,R,(X-(G-1)/2)*re,O);let ne=J.length,de=Math.abs(J[2]-J[0])+Math.abs(J[3]-J[1]),ie=Math.abs(J[ne-2]-J[ne-4])+Math.abs(J[ne-1]-J[ne-3]),se=ne===6&&ie>de?2:0,ee=Q.width>0?Y_(J,se,Q.width+8,Q.height,D,R,O):.5;F=J[se]+(J[se+2]-J[se])*ee,K=J[se+1]+(J[se+3]-J[se+1])*ee}Q.width>0&&z(F,K,Q.width+8,Q.height),U.push({edge:N[q],points:J,loop:D===R?X+1:0,label:Q,lx:F,ly:K})}let C=Cr(e.title,l,i,a?It(r):4e3),S=C.height>0?C.height+12:0,$=Math.max(Z-_,C.width),y=n-_+($-(Z-_))/2,E=n+S-j;for(let q of m)q.x+=y,q.y+=E;let x=Math.ceil($+2*n),T=Math.ceil(H-j+S+2*n),A="",M="";for(let q=1;q<m.length;q++){let D=m[q];if(D.kind===3)continue;let R=_t((D.block.classes??hx).join(" ")),P=Oe(D.block.id);if(D.kind===2){let X=D.y-D.h/2;A+=`<g class="pele-cluster${R}" data-id="${P}"><rect x="${h(D.x-D.w/2)}" y="${h(X)}" width="${h(D.w)}" height="${h(D.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ft(D.style.shape)}/>`+Re(D.label,D.x,X+(D.head+f)/2+2,` class="pele-cluster-label" fill="var(--_m)"${D.style.text}`,o)+"</g>";continue}let G=D.kind===1;M+=`<g class="pele-node pele-shape-${G?"block-arrow":D.shape}${R}" data-id="${P}" transform="translate(${h(D.x)},${h(D.y)})">`+(G?k_(D.mask,D.bw,D.bh,cx+D.style.shape):Ca(D.shape,D.bw,D.bh,cx+D.style.shape,__+D.style.line))+Re(D.label,D.dx,D.dy,` class="pele-label"${D.style.text}`,o)+"</g>"}let Y="",B="";for(let q=0;q<U.length;q++){let{edge:D,points:R,loop:P,label:G}=U[q],X=D.arrowTypeStart??"",Q=D.arrowTypeEnd??"",J;if(P>0)J=B_(I[q][0],P,gt(X),gt(Q));else{for(let K=0;K<R.length;K+=2)R[K]+=y,R[K+1]+=E;J=W_(R,gt(X),gt(Q))}let F=Oe(D.id);if(Y+=`<g class="pele-edge" data-id="${F}"><path d="${J.d}"${D.thickness==="thick"?' stroke-width="2.5"':""}${D.pattern==="dotted"?' stroke-dasharray="3 4"':""}/>`+bt(X,J.sx,J.sy,J.sdx,J.sdy,"var(--_l)")+bt(Q,J.ex,J.ey,J.edx,J.edy,"var(--_l)")+"</g>",G.width>0){let K=U[q].lx+y,re=U[q].ly+E;B+=wr(D.id,G,K,re,"",o)}}return{svg:Je("block",x,T,i,r,e,Re(C,x/2,n+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+(A?`<g class="pele-clusters">${A}</g>`:"")+(Y?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${Y}</g>`:"")+`<g class="pele-nodes">${M}</g>`+(B?`<g class="pele-edge-labels" font-size="${s}">${B}</g>`:"")),width:x,height:T,links:[]}}var ax,y_,sx,x_,fx,Rl,Qa,Ja,ei,ti,pn,Uc,Wi,Fi,M_,T_,ox,C_,cx,__,hx,I_,N_,R_,L_,D_,O_,P_,H_,ux,gx=Ve(()=>{Ea();Ti();tr();zt();pr();ut();wt();ax=1e5;y_=class{constructor(e={}){ce(this,"type","block");ce(this,"title");ce(this,"root",{id:"root",type:"composite",children:[],columns:-1});ce(this,"blocks",[]);ce(this,"edges",[]);ce(this,"classes",new Map);ce(this,"byId",new Map);ce(this,"typeStr2Type",f_);ce(this,"edgeStrToEdgeData",p_);ce(this,"edgeStrToEdgeStartData",u_);ce(this,"edgeStrToThickness",g_);ce(this,"edgeStrToPattern",m_);ce(this,"warn");ce(this,"pending",new Set);ce(this,"edgeCount",new Map);ce(this,"ids",0);ce(this,"colors",0);ce(this,"spaces",0);this.warn=e.warn}generateId(){return"id-"+ ++this.ids}addStyleClass(e,t=""){let r=this.classes.get(e);r||(r={id:e,styles:[],textStyles:[]},this.classes.set(e,r));for(let a of t.split(",")){let i=a.indexOf(";"),s=(i===-1?a:a.slice(0,i)+a.slice(i+1)).trim();a.includes("color")&&r.textStyles.push(s.replace("fill","bgFill").replace("color","fill")),r.styles.push(s)}}addStyle2Node(e,t=""){this.named(e).styles=t.split(",")}setCssClass(e,t){var r;for(let a of e.split(","))((r=this.named(a.trim())).classes??(r.classes=[])).push(t)}named(e){let t=this.byId.get(e);return t===void 0&&(t={id:e,type:"na",children:[]},this.byId.set(e,t),this.pending.add(e)),t}setHierarchy(e){let t=[ix(e,this.root)];for(;t.length>0;){let r=t[t.length-1];if(r.at===r.list.length){r.parent.children=r.children,t.pop();continue}let a=r.list[r.at++];switch(r.columns>0&&a.type!=="column-setting"&&typeof a.widthInColumns=="number"&&a.widthInColumns>r.columns&&this.warn?.(`Block ${a.id} width ${a.widthInColumns} exceeds configured column width ${r.columns}`),a.type){case"classDef":this.addStyleClass(a.id,a.css);continue;case"applyClass":this.setCssClass(a.id,a.styleClass??"");continue;case"applyStyles":a.stylesStr&&this.addStyle2Node(a.id,a.stylesStr);continue;case"column-setting":r.parent.columns=a.columns??-1;continue;case"edge":{let n=(this.edgeCount.get(a.id)??0)+1;this.edgeCount.set(a.id,n),a.id=n+"-"+a.id,this.edges.push(a);continue}}a.id??(a.id=this.generateId()),a.label||(a.label=a.type==="composite"?"":a.id);let i=this.byId.get(a.id),s=i===void 0||this.pending.delete(a.id);s?(i&&(a.classes=i.classes,a.styles=i.styles),a.type==="composite"&&(a.colorIndex=this.colors++),this.byId.set(a.id,a)):(a.type!=="na"&&(i.type=a.type),a.label!==a.id&&(i.label=a.label));let l=a.children;if(a.children=[],a.type==="space"){let n=a.width??1;if(!(n<=ax-this.spaces))throw new je(`A block diagram can hold at most ${ax} space blocks.`,"limit",{type:"block"});this.spaces+=Math.max(n,0);for(let o=0;o<n;o++){let c={...a,id:a.id+"-"+o,children:[]};this.byId.set(c.id,c),r.children.push(c)}}else s&&r.children.push(a);l&&l.length>0&&t.push(ix(l,a))}this.blocks=this.root.children??[]}},sx=["$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"],x_=["right","left","x","y","up","down"],fx=new Uint8Array(128);for(let e of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])fx[e]=1;Rl="'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'";Qa=1,Ja=2,ei=4,ti=8,pn=7,Uc=20,Wi=12;Fi=(e,t)=>e&t?1:0;M_=1e3;T_=12,ox=200,C_=8,cx=' fill="var(--_s)" stroke="var(--_b)"',__=' stroke="var(--_b)"',hx=[],I_=[],N_=[],R_=["default"],L_=2e6,D_=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"]]),O_=new Set(["circle","dbl-circ","diam"]),P_=new Set(["stadium","hex","odd","lean-r","lean-l","trap-b","trap-t"]);H_=[.5,.3,.7,.15,.85];ux={type:"block",math:!0,parse(e,t,r){let a=new y_;return a.title=r,b_(e,a),a},render:U_}});var mx={};Ct(mx,{block:()=>ux});var yx=Ve(()=>{gx()});function _x(e){return e===32||e>=9&&e<=13||e>127&&/\s/.test(String.fromCharCode(e))}function G_(){let e=1/0;return(t,r)=>{if(!t.startsWith("accDescr",r))return-1;let a=t.length,i=r+8;for(;i<a&&(t.charCodeAt(i)===32||t.charCodeAt(i)===9);)i++;if(t.charCodeAt(i)===58){for(i++;i<a;i++){let l=t.charCodeAt(i);if(l===10||l===13||l===37&&t.charCodeAt(i+1)===37)break}return i}for(;i<a&&_x(t.charCodeAt(i));)i++;if(t.charCodeAt(i)!==123||i>=e)return-1;let s=t.indexOf("}",i+1);return s===-1&&(e=i),s+1||-1}}function Mt(e,t){return{name:e,pattern:e,longer:t}}function eh(e,t){return{...or(e),longer:[t]}}function bp(e){return{name:e,pattern:/[A-Z_a-z][\w-]*/y,first:Ix+"_"}}function $p(e){return{name:e,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`}}function th(e){return[{name:e+"_WHITESPACE",pattern:/[\t \r\n]+/y,hidden:!0,first:` \r
|
|
109
|
+
`},{...jt,name:e+"_YAML",first:"-"},{...nr,name:e+"_DIRECTIVE",first:" %"},{...lr,name:e+"_SINGLE_LINE_COMMENT",first:" %"}]}function gn(e){if(!e.includes("\\"))return e.slice(1,-1);let t=e.length-1,r="";for(let a=1;a<t;a++){let i=e[a];i==="\\"&&a+1<t?(i=e[++a],r+=i==="n"?`
|
|
110
|
+
`:i==="r"?"\r":i==="t"?" ":i):r+=i}return r}function rh(e,t,r,a,i,s){let l=new Zt(Gt(e,t,"railroad"),t,"railroad"),n={$type:r,rules:[]};for(l.expect(0);;){let o=l.kind;if(o===a){let c=Vt(l.take()),f=c[0];n.title=(f==='"'||f==="'")&&c.endsWith(f)?i(c):c}else if(o===a+1)n.accTitle=Xt(l.take());else if(o===a+2)n.accDescr=Kt(l.take());else break}for(;l.kind!==-1;)n.rules.push(s(l));return n}function xp(e){let t=e,r=t.element??t.primary??t.suffix,a=t.alternatives??t.elements??(r?[r]:Nx);if(t.base){a=[t.base];for(let i of t.postfixes)i.except&&a.push(i.except)}return a}function ih(e){return e.length===1?e[0]:{type:"sequence",elements:e}}function sh(e){return e.length===1?e[0]:{type:"choice",alternatives:e}}function nh(e,t){return e.rules.map(r=>({name:r.name,definition:Rx(r.definition,xp,t)}))}function Rx(e,t,r){let a=[e],i=[t(e)],s=[[]];for(;;){let l=a.length-1,n=s[l];if(n.length<i[l].length){let o=i[l][n.length];a.push(o),i.push(t(o)),s.push([])}else{let o=r(a[l],n);if(l===0)return o;a.pop(),i.pop(),s.pop(),s[l-1].push(o)}}}function $x(e,t,r,a){let i={$type:"AbnfConcatenation",elements:[]};return t.alternatives.push(i),{alternation:t,concatenation:i,node:e,close:r,repeat:a}}function j_(e){let t=[],r=$x(void 0,{$type:"AbnfAlternation",alternatives:[]},-2,void 0);for(;;){let a=e.kind===14||e.kind===15?e.take():void 0,i,s=e.kind;switch(s){case 12:i={$type:"AbnfStringLiteral",value:e.take().slice(1,-1)};break;case 13:i={$type:"AbnfNumVal",value:e.take()};break;case 11:i={$type:"AbnfRuleName",name:e.take()};break;case 4:case 6:{e.i++;let l={$type:"AbnfAlternation",alternatives:[]};t.push(r),r=$x({$type:s===4?"AbnfGroup":"AbnfOptionalGroup",element:l},l,s+1,a);continue}default:e.fail("a string, a number, a name, or an opening bracket")}for(;;){r.concatenation.elements.push(a===void 0?{$type:"AbnfElement",primary:i}:{$type:"AbnfElement",repeat:a,primary:i});let l=e.kind;if(l===r.close){e.i++,i=r.node,a=r.repeat,r=t.pop();continue}if(l===3)e.i++,r.concatenation={$type:"AbnfConcatenation",elements:[]},r.alternation.alternatives.push(r.concatenation);else if(l!==12&&l!==13&&l!==11&&l!==4&&l!==6&&l!==14&&l!==15){if(t.length===0)return r.alternation;e.fail(`token of type '${Lx[r.close].name}'`)}break}}}function V_(e){return rh(e,Lx,"RailroadAbnf",8,t=>t.slice(1,-1),t=>{let r=t.expect(11);t.expect(1);let a=j_(t);return t.expect(2),{$type:"AbnfRule",name:r,definition:a}})}function X_(e,t){switch(e.$type){case"AbnfAlternation":return sh(t);case"AbnfConcatenation":return ih(t);case"AbnfElement":{let r=e.repeat;if(!r)return t[0];let a=r.indexOf("*"),i=a===-1,s=a>0||i?parseInt(r,10):0,l=i?s:a<r.length-1?parseInt(r.slice(a+1),10):1/0;return s===0&&l===1?un(t[0]):Dl(t[0],s,l)}case"AbnfStringLiteral":case"AbnfNumVal":return Ll(e.value);case"AbnfRuleName":return ah(e.name);case"AbnfGroup":return t[0];case"AbnfOptionalGroup":return un(t[0])}}function Z_(e,t){if(e.charCodeAt(t)!==63)return-1;let r=!1;for(let a=t+1;a<e.length;a++){let i=e.charCodeAt(a);if(i===63)return r?a+1:-1;if(i===59)return-1;r||(r=!_x(i))}return-1}function Ex(e,t,r,a){let i={$type:"EbnfSequence",elements:[]};return t.alternatives.push(i),{choice:t,sequence:i,term:void 0,node:e,close:r,except:a}}function J_(e){let t=[],r=Ex(void 0,{$type:"EbnfChoice",alternatives:[]},-2,!1),a=!1;for(;;){let i,s=e.kind;switch(s){case 20:i={$type:"EbnfTerminal",value:gn(e.take())};break;case 19:i={$type:"EbnfNonTerminal",name:e.take()};break;case 21:i={$type:"EbnfSpecial",text:e.take().slice(1,-1).trim()};break;case 6:case 8:case 10:{e.i++;let l={$type:"EbnfChoice",alternatives:[]};t.push(r),r=Ex({$type:Q_[s-6>>1],element:l},l,s+1,a),a=!1;continue}default:e.fail("a terminal, a name, or an opening bracket")}for(;;){a?(r.term.postfixes.push({$type:"EbnfExceptionPostfix",except:i}),a=!1):(r.term={$type:"EbnfTerm",base:i,postfixes:[]},r.sequence.elements.push(r.term));let l=r.term.postfixes;for(;;){let o=e.kind;if(o===12)l.push({$type:"EbnfOptionalPostfix",operator:e.take()});else if(o===13)l.push({$type:"EbnfZeroOrMorePostfix",operator:e.take()});else if(o===14)l.push({$type:"EbnfOneOrMorePostfix",operator:e.take()});else break}let n=e.kind;if(n===r.close){e.i++,i=r.node,a=r.except,r=t.pop();continue}if(n===15)e.i++,a=!0;else if(n===5)e.i++;else if(n===4)e.i++,r.sequence={$type:"EbnfSequence",elements:[]},r.choice.alternatives.push(r.sequence);else if(n!==20&&n!==19&&n!==21&&n!==6&&n!==8&&n!==10){if(t.length===0)return r.choice;e.fail(`token of type '${Dx[r.close].name}'`)}break}}}function eI(e){return rh(e,Dx,"RailroadEbnf",16,gn,t=>{let r=t.expect(19);t.accept(2)||t.expect(1);let a={$type:"EbnfRule",name:r,definition:J_(t)};return t.expect(3),a})}function tI(e,t){switch(e.$type){case"EbnfChoice":return sh(t);case"EbnfSequence":return ih(t);case"EbnfTerm":{let r=t[0],a=1;for(let i of e.postfixes)i.$type==="EbnfOptionalPostfix"?r=un(r):i.$type==="EbnfExceptionPostfix"?r={type:"sequence",elements:[r,Ll("-"),t[a++]]}:r=Dl(r,i.$type==="EbnfOneOrMorePostfix"?1:0);return r}case"EbnfTerminal":return Ll(e.value);case"EbnfNonTerminal":return ah(e.name);case"EbnfSpecial":return Xc(e.text);case"EbnfGroup":return t[0];case"EbnfOptional":return un(t[0]);case"EbnfRepetition":return Dl(t[0],0)}}function up(e){e.i++,e.expect(11);let t=gn(e.expect(18));return e.expect(13),t}function gp(e){return{$type:e,element:void 0}}function iI(e){let t=[];for(;;){let r;switch(e.kind){case 6:r={$type:"RailroadTerminalExpr",value:up(e)};break;case 1:r={$type:"RailroadNonTerminalExpr",name:up(e)};break;case 7:r={$type:"RailroadSpecialExpr",text:up(e)};break;case 4:r={$type:"RailroadSequenceExpr",elements:[]};break;case 8:r={$type:"RailroadChoiceExpr",alternatives:[]};break;case 5:r=gp("RailroadOptionalExpr");break;case 3:r=gp("RailroadOneOrMoreExpr");break;case 2:r=gp("RailroadZeroOrMoreExpr");break;default:e.fail("an expression")}if("elements"in r||"alternatives"in r||"element"in r){e.i++,e.expect(11),t.push(r);continue}for(;;){let a=t[t.length-1];if(a===void 0)return r;if("element"in a)a.element=r;else if(("elements"in a?a.elements:a.alternatives).push(r),e.accept(12))break;e.expect(13),t.pop(),r=a}}}function sI(e){return rh(e,aI,"Railroad",14,gn,t=>{let r=t.expect(17);t.expect(9);let a=iI(t);return t.expect(10),{$type:"RailroadRule",name:r,definition:a}})}function nI(e,t){switch(e.$type){case"RailroadTerminalExpr":return Ll(e.value);case"RailroadNonTerminalExpr":return ah(e.name);case"RailroadSpecialExpr":return Xc(e.text);case"RailroadSequenceExpr":return ih(t);case"RailroadChoiceExpr":return sh(t);case"RailroadOptionalExpr":return un(t[0]);default:return Dl(t[0],e.$type==="RailroadOneOrMoreExpr"?1:0)}}function Tx(e,t,r){let a={$type:"PegSequence",elements:[]};return t.alternatives.push(a),{choice:t,sequence:a,node:e,operator:r}}function cI(e){let t=[],r=Tx(void 0,{$type:"PegOrderedChoice",alternatives:[]},void 0);for(;;){let a=e.kind===4||e.kind===5?e.take():void 0,i;switch(e.kind){case 16:i={$type:"PegLiteral",value:gn(e.take())};break;case 15:i={$type:"PegIdentifier",name:e.take()};break;case 11:i={$type:"PegAny",dot:e.take()};break;case 9:{e.i++;let s={$type:"PegOrderedChoice",alternatives:[]};t.push(r),r=Tx({$type:"PegGroup",element:s},s,a);continue}default:e.fail("a literal, a name, a dot, or an opening parenthesis")}for(;;){let s={$type:"PegSuffix",primary:i};(e.kind===6||e.kind===7||e.kind===8)&&(s.operator=e.take()),r.sequence.elements.push(a===void 0?{$type:"PegPrefix",suffix:s}:{$type:"PegPrefix",operator:a,suffix:s});let l=e.kind;if(l===10&&t.length>0){e.i++,i=r.node,a=r.operator,r=t.pop();continue}if(l===3)e.i++,r.sequence={$type:"PegSequence",elements:[]},r.choice.alternatives.push(r.sequence);else if(l!==4&&l!==5&&l!==16&&l!==15&&l!==11&&l!==9){if(t.length===0)return r.choice;e.fail("token of type ')'")}break}}}function hI(e){return rh(e,oI,"RailroadPeg",12,gn,t=>{let r=t.expect(15);t.expect(1);let a={$type:"PegRule",name:r,definition:cI(t)};return t.expect(2),a})}function dI(e){switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}}function fI(e,t){let r=t[0];switch(e.$type){case"PegOrderedChoice":return sh(t);case"PegSequence":return ih(t);case"PegPrefix":return e.operator?Xc(e.operator+dI(r)):r;case"PegSuffix":return e.operator?e.operator==="?"?un(r):Dl(r,e.operator==="+"?1:0):r;case"PegLiteral":return Ll(e.value);case"PegIdentifier":return ah(e.name);case"PegAny":return Xc(e.dot);case"PegGroup":return r}}function mI(e){let t=gI.exec(e);if(t===null)return;let r=t[1]?.toLowerCase();return r==="ebnf-"?"ebnf":r==="abnf-"?"abnf":r==="peg-"?"peg":"railroad"}function yI(e,t){switch(t){case"ebnf":{let r=eI(e);return[r,rI(r)]}case"abnf":{let r=V_(e);return[r,K_(r)]}case"peg":{let r=hI(e);return[r,pI(r)]}default:{let r=sI(e);return[r,lI(r)]}}}function xI(e,t,r){let[a,i]=yI(t,r);e.notation=r,a.accDescr&&e.setAccDescription(a.accDescr),a.accTitle&&e.setAccTitle(a.accTitle),a.title&&e.setTitle(a.title);for(let s of i)e.addRule(s)}function wI(e,t){let r=mI(e);if(r===void 0)throw new je("No railroad diagram keyword found.","syntax",{type:"railroad"});let a=new uI;return t&&(a.title=t),xI(a,e,r),a}function $s(e,t,r,a){let i=e.railroad?.[t];return typeof i=="number"&&i>=0?Math.min(i,a):r}function Vc(e){return(e.includes("\xB6\xDF")?At(e.replace(/&/g,"&")):e).replace(kI,t=>t===`
|
|
111
|
+
`?"\\n":t==="\r"?"\\r":"\\t")}function jc(e,t){for(let r=t,a=e.length-1;r<a;r++,a--){let i=e[r];e[r]=e[a],e[a]=i}}function kp(e){return Math.ceil(e/2)*2}function yp(e,t,r,a,i){let s=i.height/2,l=Math.max(kp(i.measurer.width(t,i.size,a)+2*i.padding),i.height);return{kind:e,width:l,up:s,down:s,kids:Nx,text:t,id:r,reach:0}}function MI(e,t){if(t===1/0&&e<=1)return"";let r=a=>Number.isFinite(a)?String(a):"\u221E";return e===t?r(e)+"\xD7":t===1/0?"\u2265"+r(e)+"\xD7":e===0?"\u2264"+r(t)+"\xD7":r(e)+"\u2013"+r(t)+"\xD7"}function Ox(e,t,r,a){return Math.max(e+t.down+a.sep+r.up,2*a.arc)}function Cx(e,t){let r=Math.max(e.up+t.sep,2*t.arc);return{kind:5,width:e.width+4*t.arc,up:r,down:e.down,kids:[e],text:"",id:"",reach:r}}function AI(e,t,r=1/0){let a=new Map,i=[[e,r]];for(let s=0;r!==1/0&&s<i.length;s++){let[l,n]=i[s];a.set(l,n);let o=l.type==="choice"||l.type==="optional"?4*t.arc:l.type==="repetition"?(l.min===0?6:2)*t.arc:l.type==="sequence"?6*t.arc:0;for(let c of xp(l))i.push([c,Math.max(40,n-o)])}return Rx(e,xp,(s,l)=>{let n=a.get(s)??1/0;switch(s.type){case"terminal":{let o=Vc(s.value);return yp(0,/^ +$/.test(o)?"\u2423".repeat(o.length):o,"",4,t)}case"nonterminal":return yp(1,Vc(s.name),s.name,0,t);case"special":return yp(2,"? "+Vc(s.text)+" ?","",2,t);case"sequence":{let o=Math.max(0,l.length-1)*t.gap,c=0,f=0;for(let v of l)o+=v.width,c=Math.max(c,v.up),f=Math.max(f,v.down);let p={kind:3,width:o,up:c,down:f,kids:l,text:"",id:"",reach:0};if(o<=n||l.length<2)return p;let d=[],g=[],u=0,m=()=>{let v=0,k=0;for(let L of g)v=Math.max(v,L.up),k=Math.max(k,L.down);d.push({kind:3,width:u,up:v,down:k,kids:g,text:"",id:"",reach:0}),g=[],u=0};for(let v of l)g.length&&u+t.gap+v.width>Math.max(40,n-6*t.arc)&&m(),u+=(g.length?t.gap:0)+v.width,g.push(v);if(m(),d.length<2)return p;let b=0,w=0;for(let v=0;v<d.length;v++)b=Math.max(b,d[v].width),v&&(w+=d[v-1].down+Math.max(t.sep,2*t.arc)+d[v].up);return{kind:7,width:b+6*t.arc,up:d[0].up,down:w+d[d.length-1].down,kids:d,text:"",id:"",reach:0}}case"choice":{let o=0,c=0;for(let p=0;p<l.length;p++)o=Math.max(o,l[p].width),p>0&&(c=Ox(c,l[p-1],l[p],t));let f=l[l.length-1];return{kind:4,width:o+4*t.arc,up:l.length>0?l[0].up:0,down:f?c+f.down:0,kids:l,text:"",id:"",reach:0}}case"optional":return Cx(l[0],t);case"repetition":{let{min:o,max:c}=s,f=l[0];if(o===1&&c===1)return f;let p=MI(o,c),d=Math.max(f.down+t.sep,2*t.arc),g=p===""?0:kp(t.measurer.width(p,Kc,0)),u={kind:6,width:Math.max(f.width,g)+2*t.arc,up:f.up,down:d+(p===""?Da/2+1:Kc+6),kids:[f],text:p,id:"",reach:d};return o===0?Cx(u,t):u}}})}function vI(e,t,r){return Nr(r,a=>EI(e,t,r,a))}function EI(e,t,r,a){let i=r.fontSize??16,s=$s(t,"fontSize",0,200),l=s||Math.round(i*.875),n=s||i,o=$s(t,"padding",-1,200),c=Math.round(l*1.5),f={measurer:r.measurer??et(r.fontFamily,r.fontFamilyMono),size:l,padding:o<0?12:o,height:kp(c+(o<0?9:2*o)),gap:Math.min($s(t,"horizontalSeparation",16,500),a?12:1/0),sep:$s(t,"verticalSeparation",10,500),arc:Math.min($s(t,"arcRadius",10,200),a?6:1/0)},p=t.railroad?.showMarkers===!1?0:$s(t,"markerRadius",4,50),d=$s(t,"strokeWidth",0,20),g=d>0?` stroke-width="${h(d)}"`:"",u=r.padding??8,{arc:m}=f,b=h(m),w=(B,q,D)=>`a${b},${b} 0 0 ${B} ${q}${b},${D}${b}`,v=w(1,"",""),k=w(0,"",""),L=w(0,"","-"),I=w(1,"","-"),N=w(0,"-",""),O=w(0,"-","-"),W=ze(e.title,!1,f.measurer,i,a?It(r):4e3,1),U=W.height>0?W.height+16:0,_=Math.round(n*1.5),j=l*.35,Z=f.height/2,H="",z="",C="",S=(B,q,D)=>{D>B&&(H+=`M${h(B)},${h(q)}H${h(D)}`)},$=(B,q,D)=>{let R=[B],P=[q,D];for(;R.length>0;){let G=R.pop(),X=P.pop(),Q=P.pop(),J=G.kids,F=Q+G.width;switch(G.kind){case 3:{let K=F;for(let re=J.length-1;re>=0;re--)K-=J[re].width,R.push(J[re]),P.push(K,X),re>0&&S(K-f.gap,X,K),K-=f.gap;break}case 7:{let K=Q+2*m,re=R.length,ne=0;S(Q,X,K);for(let de=0;de<J.length;de++){let ie=J[de],se=X+ne;if(R.push(ie),P.push(se,K),de+1<J.length){let ee=J[de+1],te=ne+ie.down+Math.max(f.sep,2*m)+ee.up,fe=X+ne+ie.down+Math.max(f.sep,2*m)/2;H+=`M${h(K+ie.width)},${h(se)}H${h(F-2*m)}V${h(fe)}H${h(Q+m)}V${h(X+te)}H${h(K)}`,z+=`M${h(K-Da)},${h(X+te-Da/2)}l${Da},${Da/2}l${-Da},${Da/2}z`,ne=te}else H+=`M${h(K+ie.width)},${h(se)}H${h(F-m)}V${h(X)}H${h(F)}`}jc(R,re),jc(P,2*re);break}case 4:{let K=G.width-4*m,re=Q+m,ne=F-m,de=R.length,ie=0;for(let se=0;se<J.length;se++){let ee=J[se];se>0&&(ie=Ox(ie,J[se-1],ee,f));let te=X+ie,fe=Q+2*m+(K-ee.width)/2,ye=se===J.length-1;se===0?(S(Q,X,fe),S(fe+ee.width,X,F)):H+=(ye?`M${h(Q)},${h(X)}${v}V${h(te-m)}`:`M${h(re)},${h(te-m)}`)+k+(fe>re+m?`H${h(fe)}`:"")+`M${h(fe+ee.width)},${h(te)}`+(fe>re+m?`H${h(ne-m)}`:"")+L+(ye?`V${h(X+m)}${I}`:""),R.push(ee),P.push(te,fe)}jc(R,de),jc(P,2*de);break}case 5:{let K=J[0],re=Q+2*m;S(Q,X,re),S(re+K.width,X,F),H+=`M${h(Q)},${h(X)}${L}V${h(X-G.reach+m)}${I}H${h(F-2*m)}${v}V${h(X-m)}${k}`,R.push(K),P.push(re,X);break}case 6:{let K=J[0],re=Q+(G.width-K.width)/2,ne=X+G.reach,de=Q+G.width/2;S(Q,X,re),S(re+K.width,X,F),H+=`M${h(Q+m)},${h(X)}${N}V${h(ne-m)}${k}H${h(F-m)}${L}V${h(X+m)}${O}`,z+=`M${h(de-Da/2)},${h(ne)}l${Da},${-Da/2}v${Da}z`,G.text!==""&&(C+=`<text class="pele-edge-label pele-count" x="${h(de)}" y="${h(ne+Kc+3)}" font-size="${Kc}" fill="var(--_m)">${Xe(G.text)}</text>`),R.push(K),P.push(re,X);break}default:{let K=G.text,re=K.startsWith(" ")||K.endsWith(" ")||K.includes(" ")?' xml:space="preserve"':"",ne=`<rect x="${h(Q)}" y="${h(X-Z)}" width="${h(G.width)}" height="${h(f.height)}"`,de=`<text x="${h(Q+G.width/2)}" y="${h(X+j)}"${re}`;G.kind===0?C+=`<g class="pele-node pele-terminal">${ne} rx="${h(Z)}" fill="var(--_s)" stroke="var(--_b)"${g}/>${de} font-family="${Un}">${Xe(K)}</text></g>`:G.kind===1?C+=`<g class="pele-node pele-nonterminal" data-id="${Oe(G.id)}">${ne} fill="var(--_bg)" stroke="var(--_b)"${g}${st}/>${de}>${Xe(K)}</text></g>`:C+=`<g class="pele-node pele-special">${ne} fill="var(--_bg)" stroke="var(--_b)" stroke-dasharray="4 3"${g}${st}/>${de} font-style="italic"><tspan fill="var(--_m)">? </tspan>${Xe(K.slice(2,-2))}<tspan fill="var(--_m)"> ?</tspan></text></g>`}}}},y="",E=W.width,x=u+U,T=u+W.height;for(let B of e.rules){let q=AI(B.definition,f,a?Math.max(80,(r.maxWidth??320)-2*u-4*p-2*mp-1):1/0),D=Vc(B.name),R=x+_+bI+q.up,P=u+2*p,G=P+mp,X=G+q.width+mp;H="",z="",C="",S(P,R,G),S(G+q.width,R,X),$(q,G,R);let Q=p>0?`<circle class="pele-marker pele-start" cx="${h(u+p)}" cy="${h(R)}" r="${h(p)}" fill="var(--_l)"/><circle class="pele-marker pele-end" cx="${h(X+p)}" cy="${h(R)}" r="${h(p)}" fill="var(--_l)"/>`:"";y+=`<g class="pele-rule" data-id="${Oe(B.name)}"><text class="pele-rule-name" x="${h(u)}" y="${h(x+_/2+n*.35)}" font-size="${h(n)}" font-weight="var(--_hw)" text-anchor="start">${Xe(D)}</text><path class="pele-edge pele-track" d="${H}" fill="none" stroke="var(--_l)"${g}/>`+(z?`<path class="pele-marker" d="${z}" fill="var(--_l)"/>`:"")+Q+C+"</g>",E=Math.max(E,X+2*p-u,f.measurer.width(D,n,1)),T=R+q.down,x=T+f.sep+$I}let A=Math.ceil(E+2*u),M=Math.ceil(T+u),Y=Re(W,A/2,u+W.height/2,' class="pele-title" font-weight="var(--_tw)"')+(y?`<g class="pele-rules" transform="translate(0.5,0.5)" font-size="${h(l)}" text-anchor="middle">${y}</g>`:"");return{svg:Je("railroad",A,M,i,r,e,Y),width:A,height:M,links:[]}}var Ix,Zc,Qc,Jc,Nx,Ll,ah,Xc,un,Dl,xx,wx,bx,Lx,K_,kx,Mx,Ax,vx,Dx,Q_,rI,wp,Bi,aI,lI,Sx,oI,pI,uI,gI,mp,bI,$I,Kc,Da,kI,Px,zx=Ve(()=>{zt();Xr();ut();wt();Ix="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Zc={name:"TITLE",pattern:/title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:"t"},Qc={name:"ACC_TITLE",pattern:/accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"a"},Jc={name:"ACC_DESCR",pattern:/accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"a",scanner:G_};Nx=[];Ll=e=>({type:"terminal",value:e}),ah=e=>({type:"nonterminal",name:e}),Xc=e=>({type:"special",text:e}),un=e=>({type:"optional",element:e}),Dl=(e,t,r=1/0)=>({type:"repetition",element:e,min:t,max:r});xx="0123456789",wx={name:"ABNF_RULENAME",pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:Ix},bx={name:"ABNF_COMMENT",pattern:/;[^\n\r]*/y,hidden:!0,first:";"},Lx=[eh("railroad-abnf-beta",wx),Mt("="),Mt(";",[bx]),Mt("/"),Mt("("),Mt(")"),Mt("["),Mt("]"),Zc,Qc,Jc,wx,{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:xx+"*"},{name:"ABNF_EXACT_REPEAT",pattern:/[0-9]+/y,first:xx},...th("ABNF"),bx];K_=e=>nh(e,X_);kx=bp("EBNF_ID"),Mx={name:"EBNF_SPECIAL_SEQUENCE",pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:"?",scanner:()=>Z_},Ax=th("EBNF"),vx={name:"EBNF_ISO_COMMENT",pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:"(",opener:/\(\*/y},Dx=[eh("railroad-ebnf-beta",kx),Mt("::="),Mt("="),Mt(";"),Mt("|"),Mt(","),Mt("(",[vx]),Mt(")"),Mt("["),Mt("]"),Mt("{"),Mt("}"),Mt("?",[Mx]),Mt("*"),Mt("+"),Mt("-",[Ax[1]]),Zc,Qc,Jc,kx,$p("EBNF_STRING"),Mx,...Ax,{name:"EBNF_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y},vx];Q_=["EbnfGroup","EbnfOptional","EbnfRepetition"];rI=e=>nh(e,tI),wp=bp("RR_ID"),Bi=e=>Mt(e,[wp]),aI=[eh("railroad-beta",wp),Bi("nonterminal"),Bi("zeroOrMore"),Bi("oneOrMore"),Bi("sequence"),Bi("optional"),Bi("terminal"),Bi("special"),Bi("choice"),Mt("="),Mt(";"),Mt("("),Mt(","),Mt(")"),Zc,Qc,Jc,wp,$p("RR_STRING"),...th("RR"),{name:"RR_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y}];lI=e=>nh(e,nI),Sx=bp("PEG_ID"),oI=[eh("railroad-peg-beta",Sx),Mt("<-"),Mt(";"),Mt("/"),Mt("&"),Mt("!"),Mt("?"),Mt("*"),Mt("+"),Mt("("),Mt(")"),Mt("."),Zc,Qc,Jc,Sx,$p("PEG_STRING"),...th("PEG"),{name:"PEG_LINE_COMMENT",pattern:/#[^\n\r]*/y,hidden:!0,first:"#"}];pI=e=>nh(e,fI),uI=class{constructor(){ce(this,"type","railroad");ce(this,"notation","railroad");ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"rules",[]);ce(this,"byName",new Map)}setTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
112
|
+
`)}addRule(e){this.rules.push(e),this.byName.set(e.name,e)}getRule(e){return this.byName.get(e)}},gI=/^\s*railroad-(ebnf-|abnf-|peg-)?beta/i;mp=12,bI=6,$I=18,Kc=12,Da=7;kI=/[\n\r\t]/g;Px={type:"railroad",parse:(e,t,r)=>wI(e,r),render:vI}});var Fx={};Ct(Fx,{railroad:()=>Px});var Wx=Ve(()=>{zx()});function hh(e){return e&&(SI.get(e)??e)}function _I(e){return po(e)||e==="constructor"}function II(e,t){for(let r of e)r.isGroup||((!r.shape||r.shape==="squareRect"||r.shape==="rect")&&(r.shape=Ol),TI.has(r.shape)?(t.emitError("SHAPE_REMOVED",`shape "${r.shape}" was removed in v0.8.1, using "${Ol}"`,{nodeId:r.id}),r.shape=Ol):CI.has(r.shape)||(t.emitWarning("SHAPE_UNSUPPORTED",`shape "${r.shape}" is not supported, using "${Ol}"`,{nodeId:r.id}),r.shape=Ol))}function LI(e){return RI.has(e.type)}function Mp(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function Bx(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function Cp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function DI(e){let t=i=>Array.isArray(i)?[]:Cp(i)?{}:i,r=t(e),a=[[e,r]];for(;a.length>0;){let[i,s]=a.pop();if(Array.isArray(i))for(let l of i){let n=t(l);s.push(n),typeof l=="object"&&l!==null&&a.push([l,n])}else if(Cp(i))for(let l of Object.keys(i)){if(l==="__proto__"||l==="constructor"||l==="prototype")continue;let n=i[l],o=t(n);s[l]=o,typeof n=="object"&&n!==null&&a.push([n,o])}}return r}function lh(e,t){return Object.assign(e??{},t)}function zI(e){let t=!1,r=!1,a=0,i,s=[];for(let l of e.split(`
|
|
113
|
+
`)){if(i!==void 0){let f=l.length-l.trimStart().length;if(l.trim()===""||f>i){s.push(l);continue}i=void 0}let n=-1;for(let f=0;f<l.length;f++){let p=l[f];if(r)p==="\\"?f++:p==='"'&&(r=!1);else if(t)p==="'"&&(t=!1);else if(p==='"')r=!0;else if(p==="'")t=!0;else if(p==="#"&&(f===0||l[f-1]===" "||l[f-1]===" ")){n=f;break}else p==="["||p==="{"?a++:(p==="]"||p==="}")&&(a=Math.max(0,a-1))}if(t||r||a>0){s.push(l);continue}let o=n>=0?l.slice(0,n):l,c=n>=0?l.slice(n):"";if(OI.test(o)){i=l.length-l.trimStart().length,s.push(l);continue}s.push(o.replace(PI,"$1")+c)}return s.join(`
|
|
114
|
+
`)}function FI(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 WI(e){let t=e.trim(),r=t.slice(0,-1),a="arrow_open";switch(t.slice(-1)){case"x":a="arrow_cross";break;case">":a="arrow_point";break;case"-":case".":r=t;break}let i="normal",s=r.length-1,l=0;for(let n=0;n<r.length;n++)r[n]==="."&&l++;return l>0&&(i="dotted",s=l),{type:a,stroke:i,length:s}}function Hx(e){if(!e)return;let t={},r=!1;for(let a of Object.keys(e))NI.has(a)||(t[a]=e[a],r=!0);return r?t:void 0}function e5(e){let t=e.length,r=[],a=[],i=[],s=[],l=[],n=0,o=0,c=1,f=0,p=!0,d=e.indexOf("direction"),g=e.indexOf("@"),u=-1,m=0,b=0,w=-1,v=-1,k=-1,L=-1,I=-1,N=-1,O=-1,W=D=>{let R=-1;for(let P=o;P<D;P++){let G=e.charCodeAt(P);G===10?(c++,R=P):G===13&&(P+1<D&&e.charCodeAt(P+1)===10&&P++,c++,R=P)}if(R<0)f+=D-o;else{let P=R+1;for(;P<D;){let G=e.charCodeAt(P);if(G===8232||G===8233)break;P++}f=P-R-1}o=D},U=(D,R)=>{r.push(D),a.push(e.slice(o,R)),i.push(o),s.push(c,f),W(R),s.push(c,f)},_=(D,R)=>{r.push(D),a.push(e.slice(o,R)),i.push(o),s.push(c,f),f+=R-o,o=R,s.push(c,f)},j=(D,R)=>{r.push(D),a.push(e.slice(o,R)),i.push(o),s.push(c,f);for(let P=o;P<R;P++){let G=e.charCodeAt(P);G===10||G===13?(c++,f=0):f++}o=R,s.push(c,f)},Z=(D,R,P)=>{r.push(D),a.push(R),i.push(o),s.push(c,f),W(P),s.push(c,f)},H=D=>{l.push(n),n=D},z=()=>{l.length>0&&(n=l.pop())},C=(D,R)=>(D.lastIndex=R,D.test(e)?D.lastIndex:-1),S=D=>e.startsWith(D,o)&&!Qe(e.charCodeAt(o+D.length)),$=D=>{if(D>=v&&D<=k)return k;let R=D;for(;R<t&&Ue(e.charCodeAt(R));)R++;return v=D,k=R,R},y=D=>{if(D>=L&&D<=I)return I;let R=D;for(;R<t;){let P=e.charCodeAt(R);if(P!==32&&P!==9)break;R++}return L=D,I=R,R},E=D=>{let R=$(D);if(R===O||e.charCodeAt(R)!==45||e.charCodeAt(R+1)!==45)return-1;let P=R+2;for(;e.charCodeAt(P)===45;)P++;let G=e.charCodeAt(P);return G===120||G===62?$(P+1):(O=R,-1)},x=()=>{let D=$(o);if(D===N||e.charCodeAt(D)!==45)return!1;let R=e.charCodeAt(D+1),P=D+2;if(R===45){for(;e.charCodeAt(P)===45;)P++;let G=e.charCodeAt(P);return G===120||G===62?U(42,$(P+1)):(H(10),U(43,$(D+2))),!0}if(R===46){for(;e.charCodeAt(P)===46;)P++;if(e.charCodeAt(P)===45)return U(42,$(P+1)),!0}return N=D,!1},T=D=>{if(e.charCodeAt(D)!==37||e.charCodeAt(D+1)!==37||e.charCodeAt(D+2)===123)return-1;let R=e.indexOf(`
|
|
115
|
+
`,D+2);return R===-1?t:R},A=()=>{e.charCodeAt(o+1)===96?(H(2),W(o+2)):(H(1),W(o+1))},M=D=>{let R=e.charCodeAt(o+1);return D===40?(R===45?(H(8),_(47,o+2)):R===91?(H(7),_(49,o+2)):R===40&&e.charCodeAt(o+2)===40?(H(7),_(57,o+3)):(H(7),_(72,o+1)),!0):D===91?(R===91?(H(7),_(51,o+2)):R===40?(H(7),_(55,o+2)):R===47?(H(9),_(60,o+2)):R===92?(H(9),_(61,o+2)):(H(7),_(74,o+1)),!0):D===124?(H(7),_(70,o+1),!0):D===123?(H(7),_(76,o+1),!0):!1},Y=()=>{let D=o;for(;D<t;){let R=e.charCodeAt(D);if(R<128&&Xx[R]===1)D++;else if(R===45&&D+1<t){let P=e.charCodeAt(D+1);if(P===62||P===45||P===46)break;D++}else break}return D===o?!1:(_(67,D),!0)},B=D=>{let R=D;for(;R<t;){let P=e.charCodeAt(R);if(P!==32&&P!==9)break;R++}return R},q=D=>{let R;switch(D){case 97:if(e.startsWith("acc",o)){if((R=C(HI,o))>=0)return H(3),U(2,R),!0;if((R=C(YI,o))>=0)return H(4),U(4,R),!0;if((R=C(UI,o))>=0)return H(5),W(R),!0}if(S("agentflow-beta"))return p&&(p=!1,H(6)),_(20,o+14),!0;break;case 64:if(e.charCodeAt(o+1)===123)return H(14),Z(7,"",o+2),!0;break;case 99:if((R=C(qI,o))>=0)return H(12),W(R),!0;if(S("classDef"))return _(16,o+8),!0;if(S("class"))return _(17,o+5),!0;if((R=C(GI,o))>=0)return H(11),W(R),!0;if(S("connector"))return _(22,o+9),!0;break;case 34:return A(),!0;case 115:if(S("style"))return _(12,o+5),!0;break;case 100:if(S("default"))return _(13,o+7),!0;break;case 108:if(S("linkStyle"))return _(14,o+9),!0;break;case 105:if(S("interpolate"))return _(15,o+11),!0;break;case 104:if(e.startsWith("href",o)&&Ue(e.charCodeAt(o+4)))return U(18,o+5),!0;break;case 102:if(S("flow"))return _(21,o+4),!0;break;case 103:if(S("global"))return _(23,B(o+6)),!0;break;case 101:if(S("end"))return _(24,B(o+3)),!0;break;case 95:if(S("_self"))return _(25,o+5),!0;if(S("_blank"))return _(25,o+6),!0;if(S("_parent"))return _(25,o+7),!0;if(S("_top"))return _(25,o+4),!0;break}if(d!==-1&&o>=m&&(d<o&&(d=e.indexOf("direction",o)),d!==-1&&(u<o&&(Ap.lastIndex=o,u=Ap.test(e)?Ap.lastIndex-1:t),d<u))){for(let P=0;P<5;P++)if((R=C(ZI[P],o))>=0)return U(28+P,R),!0;m=u}if(g!==-1&&D!==34&&!Ue(D)){if(o>=b){g<o&&(g=e.indexOf("@",o));let P=o;for(;P<t;){let G=e.charCodeAt(P);if(G===34||Ue(G))break;P++}if(b=P,w=-1,g!==-1&&g<P)for(let G=Math.min(P,t-1)-1;G>=g;G--){if(e.charCodeAt(G)!==64)continue;let X=e.charCodeAt(G+1);if(X!==123&&X!==34){w=G;break}}}if(w>o)return _(33,w+1),!0}if(D>=48&&D<=57){let P=o+1;for(;P<t;){let G=e.charCodeAt(P);if(G<48||G>57)break;P++}return _(34,P),!0}switch(D){case 35:return _(35,o+1),!0;case 58:return e.charCodeAt(o+1)===58&&e.charCodeAt(o+2)===58?_(36,o+3):_(37,o+1),!0;case 38:return _(38,o+1),!0;case 59:return _(39,o+1),!0;case 44:return _(40,o+1),!0;case 42:return _(41,o+1),!0;case 60:return _(62,o+1),!0;case 45:return x()||Y()||_(68,o+1),!0;case 40:return M(D);case 91:return e.charCodeAt(o+1)===124?(_(52,o+2),!0):M(D);case 124:case 123:return M(D);case 62:return H(7),_(53,o+1),!0;case 94:return _(63,o+1),!0;case 92:return e.charCodeAt(o+1)===124?(_(64,o+2),!0):Y();case 118:return Qe(e.charCodeAt(o+1))?Y():(_(65,o+1),!0);case 37:return(R=T(o))>=0?(U(66,R),!0):Y()}if(Ue(D)){if(x())return!0;if((D===32||D===9)&&(R=T(y(o)))>=0)return U(66,R),!0;for(R=o;;){let P=e.charCodeAt(R);if(P===10)R++;else if(P===13&&e.charCodeAt(R+1)===10)R+=2;else break}return R>o?U(77,R):U(78,o+1),!0}return D<128?Y():Ps(D)?(_(69,o+1),!0):!1};e:for(;;){if(o>=t){let P=-1;switch(n){case 0:P=79;break;case 3:P=3;break;case 4:P=5;break;case 5:P=6;break;case 11:P=19;break;case 12:P=8;break;case 13:P=9;break}P!==-1&&_(P,t);break}let D=e.charCodeAt(o),R=!0;switch(n){case 0:R=q(D);break;case 1:if(D===34)e.charCodeAt(o+1)===96?(H(2),W(o+2)):(z(),W(o+1));else{let P=e.indexOf('"',o);U(11,P===-1?t:P)}break;case 2:if(D===96)e.charCodeAt(o+1)===34?(z(),W(o+2)):R=!1;else if(D===34)A();else{let P=o+1;for(;P<t;){let G=e.charCodeAt(P);if(G===96||G===34)break;P++}U(10,P)}break;case 3:case 4:{let P=e.indexOf(`
|
|
116
|
+
`,o);P===-1&&(P=t);let G=n===3?3:5;z(),U(G,P);break}case 5:if(D===125)z(),W(o+1);else{let P=e.indexOf("}",o);P===-1&&(P=t),U(6,P)}break;case 6:{let P;D===34?A():(P=C(jI,o))>=0?(z(),U(26,P)):(P=C(VI,o))>=0||(P=C(XI,o))>=0||(P=C(KI,o))>=0?(z(),U(27,P)):R=M(D);break}case 7:{let P=e.charCodeAt(o+1);switch(D){case 34:A();break;case 40:case 91:case 123:M(D);break;case 93:z(),P===41?_(48,o+2):P===93?_(50,o+2):_(73,o+1);break;case 41:z(),P===93?_(54,o+2):P===41&&e.charCodeAt(o+2)===41?_(56,o+3):_(71,o+1);break;case 124:z(),_(70,o+1);break;case 125:z(),_(75,o+1);break;case 37:{let G=T(o);G>=0?W(G):R=!1;break}default:{let G=o+1;for(;G<t;){let X=e.charCodeAt(G);if(X===91||X===93||X===40||X===41||X===123||X===125||X===124||X===34||X===37)break;G++}U(46,G)}}break}case 8:{let P=e.charCodeAt(o+1),G;if(D===34)A();else if(D===37&&(G=T(o))>=0)W(G);else if((D===45||D===47||D===41)&&P===41)z(),_(45,o+2);else if(D===40||D===91||D===123)M(D);else if(D===41||D===93||D===125)R=!1;else{let X=o+1;for(;X<t;){let Q=e.charCodeAt(X);if(Q===34||Q===40||Q===41||Q===91||Q===93||Q===123||Q===125||(Q===45||Q===47)&&e.charCodeAt(X+1)===41||Q===37&&e.charCodeAt(X+1)===37&&e.charCodeAt(X+2)!==123)break;X++}j(46,X)}break}case 9:{let P=e.charCodeAt(o+1);if(D===34){A();break}switch(D){case 40:P===45||P===91||P===40&&e.charCodeAt(o+2)===40?M(D):P===93?(z(),_(58,o+2)):M(D);break;case 91:case 123:M(D);break;case 92:P===93?(z(),_(58,o+2)):_(46,o+1);break;case 47:P===93?(z(),_(59,o+2)):_(46,o+1);break;case 93:case 41:P===93?(z(),_(58,o+2)):R=!1;break;case 125:R=!1;break;case 37:{let G=T(o);G>=0?W(G):R=!1;break}default:{if((D===63||D===61)&&P===93){z(),_(58,o+2);break}let G=o+1;for(;G<t;){let X=e.charCodeAt(G);if(X===92||X===91||X===93||X===40||X===41||X===123||X===125||X===47||X===37)break;G++}U(46,G)}}break}case 10:{if(D===34){A();break}let P=E(o);if(P>=0){z(),U(42,P);break}if(D===45&&e.charCodeAt(o+1)===45){R=!1;break}let G=o+1;for(;G<t;){let X=e.charCodeAt(G);if(X===34)break;if(X===45){if(e.charCodeAt(G+1)===45)break}else if(Ue(X)&&E(G)>=0)break;G++}j(44,G);break}case 11:if(D===34)A();else if(Ue(D))z(),W(o+1);else{let P=o+1;for(;P<t&&!Ue(e.charCodeAt(P));)P++;_(19,P)}break;case 12:if(D===40){let P=C(QI,o);z(),P>=0?W(P):(H(13),W(o+1))}else{let P=e.indexOf("(",o);P===-1&&(P=t),U(8,P)}break;case 13:if(D===41)z(),W(o+1);else{let P=e.indexOf(")",o);P===-1&&(P=t),U(9,P)}break;case 14:if(D===34)H(15),_(7,o+1);else if(D===125)z(),W(o+1);else if(D===94)R=!1;else{let P=o+1;for(;P<t;){let G=e.charCodeAt(P);if(G===125||G===94||G===34)break;P++}U(7,P)}break;case 15:if(D===34)z(),_(7,o+1);else{let P=e.indexOf('"',o);P===-1&&(P=t),Z(7,e.slice(o,P).replace(JI,"<br/>"),P)}break}if(!R)return r.push(1),a.push(""),i.push(o),s.push(c,f,c,f),{types:r,texts:a,starts:i,locs:s};continue e}return r.push(0),a.push(""),i.push(t),s.push(c,f,c,f),{types:r,texts:a,starts:i,locs:s}}function r5(e,t,r=!1){let a=!r&&e.includes("}")?e.replace(t5,`}
|
|
117
|
+
`):e,{types:i,texts:s,starts:l,locs:n}=e5(a),o=0,c,f=0,p=0,d=A=>{let M=i[o];throw M===1?it("agentflow",a,l[o],"",!0):it("agentflow",a,l[o],`Expecting ${A}, got '${Yx[M]}'`)},g=(A,M)=>({first_line:n[4*A],first_column:n[4*A+1],last_line:n[4*M+2],last_column:n[4*M+3]}),u=(A,M="")=>(i[o]!==A&&d(`'${Yx[A]}'${M?", "+M:""}`),s[o++]),m=()=>{fh[i[o]]===0&&d(vp),o++},b=()=>{dh[i[o]]===0&&d("'NODE_STRING'");let A=s[o++];for(;dh[i[o]]===1;)A+=s[o++];return A},w=()=>{_p[i[o]]===0&&d("'NODE_STRING'");let A=s[o++];for(;_p[i[o]]===1;)A+=s[o++];return A},v=()=>{let A=i[o],M;if(A===11)M="string";else if(A===10)M="markdown";else if(A===46||A===62||A===53||A===69)M="text";else return d(`${Ux}, 'TAGEND', 'STR', 'MD_STR'`);let Y=s[o++];for(;;){let B=i[o];if(B!==46&&B!==62&&B!==53&&B!==69)break;Y+=s[o++]}return{text:Y,type:M}},k=A=>{u(A,Ux)},L=()=>{let A=i[o],M;if(A===11)M="string";else if(A===10)M="markdown";else if(A===44||A===69)M="text";else return d("'EDGE_TEXT', 'STR', 'MD_STR'");let Y=s[o++];for(;i[o]===44||i[o]===69;)Y+=s[o++];return{text:Y,type:M}},I=()=>{let A=i[o],M;if(A===11)M="text";else if(A===10)M="markdown";else if(Ip[A]===1)M="text";else return d("'NODE_STRING', 'STR', 'MD_STR'");let Y=s[o++];for(;Ip[i[o]]===1;)Y+=s[o++];return{text:Y,type:M}},N=()=>{f=o;let A=s[o++];for(;i[o]===7;)A+=s[o++];return p=o-1,A},O=(A,M,Y,B)=>{let q=g(Y,B);t.addVertex(A,void 0,void 0,void 0,void 0,void 0,void 0,M,q),t.extendVertexMapping(A,q)},W=(A,M)=>{M.data!==void 0&&t.addVertex(A,void 0,void 0,void 0,void 0,void 0,void 0,M.data,g(M.dataFrom,M.dataTo))},U=()=>{let A=o,M=b(),Y,B,q;switch(i[o]){case 74:o++,Y=v(),k(73),B="square";break;case 57:o++,Y=v(),k(56),B="doublecircle";break;case 72:o++,i[o]===72?(o++,Y=v(),k(71),u(71),B="circle"):(Y=v(),k(71),B="round");break;case 47:o++,Y=v(),k(45),B="ellipse";break;case 49:o++,Y=v(),k(48),B="stadium";break;case 51:o++,Y=v(),k(50),B="subroutine";break;case 52:{o++;let D=u(67);u(37);let R=u(67);u(70),Y=v(),k(73),B="rect",q={[D]:R};break}case 55:o++,Y=v(),k(54),B="cylinder";break;case 76:o++,i[o]===76?(o++,Y=v(),k(75),u(75),B="hexagon"):(Y=v(),k(75),B="diamond");break;case 53:o++,Y=v(),k(73),B="odd";break;case 60:o++,Y=v(),i[o]===59?(o++,B="lean_right"):(k(58),B="trapezoid");break;case 61:o++,Y=v(),i[o]===58?(o++,B="lean_left"):(k(59),B="inv_trapezoid");break}return q!==void 0?t.addVertex(M,Y,B,void 0,void 0,void 0,q):B!==void 0?t.addVertex(M,Y,B):t.addVertex(M),t.addVertexMapping(M,Y,B,g(A,o-1)),M},_=()=>{let A=U();return i[o]===36&&(o++,t.setClass(A,b())),A},j=()=>{let A=[_()];for(c=void 0;;){let M=i[o]===7?N():void 0,Y=f,B=p;if(i[o]!==78)return c=M,A;do o++;while(i[o]===78);if(i[o]!==38)return M!==void 0&&d("'AMP'"),A;o++,i[o]!==78&&d("'SPACE'");do o++;while(i[o]===78);let q=_();M!==void 0&&O(A[A.length-1],M,Y,B),A.push(q)}},Z=()=>{let A;if(i[o]===33&&(A=s[o++]),i[o]===42){let M=t.destructLink(s[o++]);return A!==void 0&&(M.id=A),i[o]===70&&(o++,M.text=v(),k(70),i[o]===78&&o++),M}if(i[o]===43){let M=s[o++],Y=L(),B=u(42,"'EDGE_TEXT'"),q=t.destructLink(B,M);return q.text=Y,A!==void 0&&(q.id=A),q}return d("'LINK', 'START_LINK'")},H=()=>{let A=o,M=j();c!==void 0&&O(M[M.length-1],c,f,p);let Y=M;for(;;){let B=i[o];if(B!==42&&B!==43&&B!==33)return Y;let q=Z(),D=j();c!==void 0&&O(D[D.length-1],c,f,p),t.addLink(M,D,q),t.addEdgeMapping(M,D,q,g(A,o-1)),Y=D.concat(Y),M=D}},z=()=>{Np[i[o]]===0&&d("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let A=s[o++];for(;Np[i[o]]===1;)A+=s[o++];return A},C=()=>{let A=[z()];for(;i[o]===40;)o++,A.push(z());return A},S=()=>{o++,u(78);let A;if(i[o]===13)A=[s[o++]];else for(A=[u(34,"'DEFAULT'")];i[o]===40;)o++,A.push(u(34));if(u(78),i[o]!==15){t.updateLink(A,C());return}o++,u(78);let M=w();if(i[o]===78){o++;let Y=C();t.updateLinkInterpolate(A,M),t.updateLink(A,Y)}else t.updateLinkInterpolate(A,M)},$=(A,M)=>{if(i[o]!==78){t.setLink(A,M);return}if(o++,i[o]===25){t.setLink(A,M,s[o++]);return}let Y=u(11,"'LINK_TARGET'");i[o]===78?(o++,t.setLink(A,M,u(25))):t.setLink(A,M),t.setTooltip(A,Y)},y=()=>{let A=s[o++];switch(i[o]){case 8:{let M=s[o++],Y=i[o]===9,B=Y?s[o++]:void 0,q;i[o]===78&&(o++,q=u(11)),Y?t.setClickEvent(A,M,B):t.setClickEvent(A,M),q!==void 0&&t.setTooltip(A,q);return}case 18:o++,$(A,u(11));return;case 11:$(A,s[o++]);return;default:{let M=w();if(i[o]===78){o++;let Y=u(11);t.setClickEvent(A,M),t.setTooltip(A,Y)}else t.setClickEvent(A,M)}}},E=A=>{u(78,vp);let M=I(),Y={text:"",type:"text"};i[o]===74&&(o++,Y=v(),k(73));let B=i[o]===7?N():void 0;return fh[i[o]]===0&&d(`${vp}, 'SHAPE_DATA'`),{global:!1,at:A,id:M,title:Y,data:B,dataFrom:f,dataTo:p,list:[],collect:!1}},x=()=>{let A=i[o];switch(A){case 12:{o++,u(78);let M=b();return u(78),t.addVertex(M,void 0,void 0,C()),m(),Pl}case 14:return S(),m(),Pl;case 16:{o++,u(78);let M=b();return u(78),t.addClass(M,C()),m(),Pl}case 17:{o++,u(78);let M=b();return u(78),t.setClass(M,b()),m(),Pl}case 19:return y(),m(),Pl;case 22:{let M=E(o++),Y=o++,B=t.addConnector(M.id,M.title);return W(B,M),t.addConnectorMapping(M.id,M.title,g(M.at,M.at),g(Y,Y)),B}case 28:case 29:case 30:case 31:case 32:return o++,{stmt:"dir",value:a5[A-28]};case 2:{o++;let M=u(3).trim();return t.setAccTitle(M),M}case 4:{o++;let M=u(5).trim();return t.setAccDescription(M),M}case 6:{let M=s[o++].trim();return t.setAccDescription(M),M}default:{dh[A]===0&&d(qx);let M=H();return m(),M}}},T=()=>{let A=[],M=[],Y=!1;for(;;){let B=i[o];if(B===0)break;if(B===24){let q=A.pop();if(q===void 0)break;let D=o++;if(q.global){t.addGlobal(M),M=q.list,Y=q.collect;continue}let R=t.addSubGraph(q.id,M,q.title,"flow");W(R,q),t.addSubgraphMapping(q.id,q.title,g(q.at,q.at),g(D,D)),M=q.list,Y=q.collect,Y&&M.push(R)}else if(B===39||B===77||B===78||B===79)Y&&M.push(s[o]),o++;else if(B===66)o++;else if(B===21||B===23){let q=o++,D;B===23||fh[i[o]]===1?(D={global:B===23,at:q,id:void 0,title:void 0,data:void 0,dataFrom:0,dataTo:0,list:M,collect:Y},m()):(D=E(q),D.list=M,D.collect=Y,o++),A.push(D),M=[],Y=!0}else{let q=x();Y&&(!Array.isArray(q)||q.length>0)&&M.push(q)}}A.length>0&&d("'end'")};for(;i[o]===78||i[o]===77||i[o]===66;)o++;if(u(20,"'SPACE', 'NEWLINE', 'COMMENT'"),i[o]===26)o++,t.setDirection("TB");else{let A=u(27,"'NODIR'"),M=i[o];if(M===78){do o++;while(i[o]===78);M=i[o],M!==77&&d("'NEWLINE', 'SPACE'")}else M!==39&&M!==77&&M!==66&&d("'COMMENT', 'SEMI', 'NEWLINE', 'SPACE'");o++,t.setDirection(A)}T(),i[o]!==0&&d(qx)}function n5(e,t,r,a){let i=r.size;for(let s of e){if(s.isGroup||s.shape==="collapsedGroup"){s.colorIndex=s5(r.get(s.id)??i++,a);continue}let l=t(s.id);l&&mn.has(l)&&(s.kind=l)}}function l5(e,t,r){let a=[],i=[],s=e.subgraphs,l=w=>{let v=[];for(let k of w){let L=e.classes.get(k);L?.styles&&(v=[...v,...L.styles].map(I=>I.trim())),L?.textStyles&&(v=[...v,...L.textStyles].map(I=>I.trim()))}return v},n=new Set,o=new Map,c=new Set;for(let w of s){if(w.metadata?.view!=="collapsed"||n.has(w.id))continue;let v=[w.id];for(;v.length>0;){let k=e.subgraph(v.pop())?.nodes;if(k!==void 0)for(let L of k)L===w.id||n.has(L)||(n.add(L),o.set(L,w.id),c.has(L)||v.push(L))}c.add(w.id)}let f=new Map;for(let w of n){let v=[w],k=o.get(w);for(;;){let L=f.get(k),I=L??o.get(k);if(I===void 0||(L===void 0&&v.push(k),k=I,L!==void 0))break}for(let L of v)f.set(L,k)}let p=new Map;s.forEach((w,v)=>p.set(w.id,v));let d=new Map,g=(w,v,k)=>{let L=p.get(w);if(L===void 0||L<k)return!1;let I=v;for(let N=0;I!==void 0&&N<=s.length;N++){if(I===w)return!0;I=d.get(I)}return!1};for(let w=s.length-1;w>=0;w--){let v=s[w];if(!n.has(v.id))for(let k of v.nodes){if(g(k,v.id,w)){e.emitWarning("CONTAINMENT_VIOLATION",`Container "${v.id}" cannot contain "${k}" because "${k}" already contains it. The nesting that would close the loop is dropped.`,{nodeId:k});continue}d.set(k,v.id)}}let u=new Map;for(let w=s.length-1;w>=0;w--){let v=s[w];if(n.has(v.id))continue;let k=v.metadata?.view==="collapsed",L={id:v.id,label:v.title,labelType:v.labelType,parentId:d.get(v.id),cssStyles:[],cssCompiledStyles:l(v.classes),cssClasses:v.classes.join(" "),shape:k?"collapsedGroup":"flowGroup",dir:v.dir,isGroup:!k,metadata:k?{...v.metadata,containerType:v.type}:v.metadata};a.push(L),u.set(v.id,L)}for(let w of e.nodes.values()){if(n.has(w.id))continue;let v=u.get(w.id);if(v){v.cssStyles=w.styles,v.cssCompiledStyles=l(w.classes),v.cssClasses=w.classes.join(" ");continue}let k=hh(w.type),L={id:w.id,label:w.text,labelType:w.labelType,parentId:d.get(w.id),cssStyles:w.styles,cssCompiledStyles:l(["default","node",...w.classes]),cssClasses:"default "+w.classes.join(" "),dir:w.dir,link:w.link,linkTarget:w.linkTarget,tooltip:e.tooltips.get(w.id),metadata:w.metadata,isGroup:!1,shape:k==="square"||k===void 0?"squareRect":k};a.push(L),u.set(w.id,L)}e.edges.forEach((w,v)=>{let k=f.get(w.start)??w.start,L=f.get(w.end)??w.end;if(k===L&&w.start!==w.end)return;let I=[...e.defaultEdgeStyle??[]];w.style&&I.push(...w.style);let N=w.type==="arrow_open"?"none":w.type==="arrow_cross"||w.type==="arrow_point"?w.type:"arrow_point";i.push({id:w.id||`L_${k}_${L}_${v}`,isUserDefinedId:w.isUserDefinedId,start:k,end:L,type:w.type??"normal",label:w.text,labelType:w.labelType,thickness:w.stroke,pattern:w.stroke,minlen:w.length,classes:"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:"none",arrowTypeEnd:N,cssCompiledStyles:l(w.classes),style:I,animate:w.animate,animation:w.animation,curve:w.interpolate||e.defaultInterpolate||r,metadata:w.metadata})}),II(a,e);let m=new Map;for(let w of s){let v=d.get(w.id);if(v===void 0)continue;let k=m.get(v);k?k.push(w.id):m.set(v,[w.id])}let b=new Map;for(let w of s){if(d.get(w.id)!==void 0)continue;let v=[w.id];for(;v.length>0;){let k=v.pop();if(b.has(k))continue;b.set(k,b.size);let L=m.get(k);if(L)for(let I=L.length-1;I>=0;I--)v.push(L[I])}}return n5(a,w=>{if(e.connectors.has(w))return"connector";let v=e.nodes.get(w);return v?e.vertexKind(v):void 0},b,t),{nodes:a,edges:i}}function Zx(e,t){let r=jx.get(e);if(r===void 0){let a=t.flowchart?.curve;r=l5(e,o5,typeof a=="string"?a:void 0),jx.set(e,r)}return r}function ch(e,t,r){let a=e.agentflow?.[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function Sp(e,t,r){let a=dt(e);return` fill="${a}"${p5.test(r.shape)?"":` fill-opacity="${t}"`} stroke="${a}"`}function u5(e,t,r){return jr(e.direction)?Bt(r,a=>Vx(e,t,r,a)):Vx(e,t,r,!1)}function Vx(e,t,r,a){let i=Zx(e,t),s=r.fontSize??16,l=Math.round(s*.875),n=r.measurer??et(r.fontFamily),o=ch(t,"wrappingWidth",120),c=ch(t,"minNodeWidth",120),f=r.padding??8,p=r.icons,d=new Map,g=[],u=[];i.nodes.forEach((P,G)=>d.set(P.id,G));for(let P of i.nodes){let G=P.cssStyles.length>0?P.cssCompiledStyles.concat(P.cssStyles):P.cssCompiledStyles,X=vt(G),Q=(X.bold?1:0)|(X.italic?2:0),J=P.labelType==="markdown",F=X.fontSize??s,K,re;if(P.isGroup){let ne=ze(P.label,J,n,F,4e3,Q);K={node:P,style:X,label:ne,shape:"group",w:0,h:0,dy:0,loops:0},re=Ut(0,0),re.isGroup=!0,re.dir=P.dir?br(P.dir):void 0,re.padX=zl,re.padTop=ne.height>0?ne.height+16:zl,re.padBottom=zl,re.minW=ne.width+2*zl-12}else if(P.shape==="collapsedGroup"){let ne=ze(P.label,J,n,F,o,Q),de=Math.max(ne.width,c)+2*mt,ie=ne.height+2*$t+oh;K={node:P,style:X,label:ne,shape:Gx,w:de,h:ie,dy:-oh/2,loops:0},re=Ut(de,ie)}else{let ne=uo(P.shape),de=ze(P.label,J,n,F,o,Q),ie=Si(ne,ne==="diam"?de.width:Math.max(de.width,c),de.height);K={node:P,style:X,label:de,shape:ne,w:ie.w,h:ie.h,dy:ie.dy,loops:0},re=Ut(ie.w,ie.h)}re.seq=g.length,g.push(K),u.push(re)}i.nodes.forEach((P,G)=>{u[G].parent=P.parentId!==void 0?d.get(P.parentId)??-1:-1});let m=a?"TB":br(e.direction),b=P=>{let G;for(let X=u[P].parent,Q=0;X>=0&&G===void 0&&Q<1e4;X=u[X].parent,Q++)G=u[X].dir;return G??m},w=P=>{let G=b(P);return G==="LR"||G==="RL"},v=new Int32Array(u.length).fill(-1);for(let P=0;P<u.length;P++){let G=[],X=P;for(;X>=0&&v[X]<0&&G.length<=u.length;)G.push(X),X=u[X].parent;let Q=X>=0?v[X]+1:0;for(let J=G.length-1;J>=0;J--)v[G[J]]=Q++}let k=(P,G)=>{let X=G;for(let Q=v[G];Q>v[P];Q--)X=u[X].parent;return X===P&&G!==P},L=[],I=[],N=[],O=[];for(let P of i.edges){let G=d.get(P.start),X=d.get(P.end);if(G===void 0||X===void 0)continue;let Q=ze(P.label,P.labelType==="markdown",n,l,o);if(k(G,X)||k(X,G)){O.push({edge:P,label:Q,src:G,dst:X});continue}G===X&&(g[G].loops++,w(G)?u[G].h+=2*(Ep+(Q.height>0?Q.height+8:0)):u[G].w+=2*(Ep+(Q.width>0?Q.width+12:0))),N.push(P),I.push(Q),L.push({src:G,dst:X,minlen:P.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=Gr(u,L,m,{nodeSep:ch(t,"nodeSpacing",c5),edgeSep:h5,rankSep:ch(t,"rankSpacing",d5),portSep:20}),U=ze(e.title,!1,n,s,4e3,1),_=U.height>0?U.height+12:0,j=Math.max(W.width,U.width),Z=f+(j-W.width)/2,H=f+_;vi(u,L,Z,H);let z=Math.ceil(j+2*f),C=Math.ceil(W.height+_+2*f),S=[],$=[],y=[],E=[],x=O.length*u.length<2e6;for(let{edge:P,src:G,dst:X}of O){let Q=k(X,G),J=Q?X:G,F=Q?G:X,K=u[J],re=u[F],ne=f5[K.dir??b(J)],de=Q?ne:ne+2&3,ie=fe=>{let ye=(fe&1)===0,le=fe===0||fe===3?-1:1,we=ye?re.x:re.x+le*re.w/2,pe=ye?re.y+le*re.h/2:re.y,ge=ye?re.x:K.x+le*K.w/2,Ae=ye?K.y+le*K.h/2:re.y,Se=ye?0:1;return Q?[we,pe,Se,ge,Ae,Se]:[ge,Ae,Se,we,pe,Se]},se=fe=>{for(let ye=0;ye<u.length;ye++){let le=u[ye];if(ye!==F&&!le.isGroup&&le.x+le.w/2>Math.min(fe[0],fe[3])-1&&le.x-le.w/2<Math.max(fe[0],fe[3])+1&&le.y+le.h/2>Math.min(fe[1],fe[4])-1&&le.y-le.h/2<Math.max(fe[1],fe[4])+1)return!0}return!1},ee=ie(de);if(x&&se(ee))for(let fe of[de+1&3,de+3&3,de+2&3]){let ye=ie(fe);if(!se(ye)){ee=ye;break}}E.push(ee),y.push((ee[0]+ee[3])/2,(ee[1]+ee[4])/2);let te=ee.slice();rs(te,Q?0:3,g[F],re),$.push(zr(te,"linear",0,gt(P.arrowTypeEnd)))}let T=new Map,A=!1;for(let P of u)P.isGroup&&(A=!0);if(A){for(let P of L)va(T,P.route);for(let P of E)va(T,P)}let M="",Y="";for(let P=0;P<g.length;P++){let G=g[P],X=u[P],Q=G.node,J=X.x,F=X.y,K=_t(Q.cssClasses.replace(/^default\s?/,"")),re=Oe(Q.id);if(X.isGroup){let fe=Ai(X,G.label.width,T,zl);M+=`<g class="pele-cluster pele-flow${K}" data-id="${re}"><rect x="${h(J-X.w/2)}" y="${h(F-X.h/2)}" width="${h(X.w)}" height="${h(X.h)}"${ft(Sp(Q.colorIndex??mn.size,"0.06",G.style)+G.style.shape)}/>`+Re(G.label,fe,F-X.h/2+8+G.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${G.style.text}`,p)+"</g>";continue}let ne=G.w,de=G.h,ie="",se;if(G.shape===Gx){let fe=dt(Q.colorIndex??mn.size),ye=de/2-oh-2,le=ye+(oh+2)/2;se=`<rect x="${h(-ne/2)}" y="${h(-de/2)}" width="${h(ne)}" height="${h(de)}"${ft(Sp(Q.colorIndex??mn.size,"0.06",G.style)+G.style.shape)}/><path d="M${h(-ne/2+10)},${h(ye)}H${h(ne/2-10)}" fill="none" stroke="${fe}" stroke-dasharray="3 3"${G.style.line}/><path class="pele-collapsed-mark" d="${Tp(-9,le)}${Tp(0,le)}${Tp(9,le)}" fill="${fe}" stroke="none"/>`}else{let fe=mn.get(Q.kind??"task")??1;ie=` pele-kind-${Q.kind??"task"}`,se=Ca(G.shape,ne,de,Sp(fe,"0.14",G.style)+G.style.shape,` stroke="${dt(fe)}"`+G.style.line)}let ee=Re(G.label,0,G.dy,` class="pele-label"${G.style.text}`,p);if(/ internal-link(?: |$)/.test(K+" ")&&Q.label&&r.links!==!1){let fe=At(Q.label),ye=oi(Sa(fe),r)!==void 0,le=Xe(fe);ee=`<a class="internal-link"${ye?` href="${le}"${ci(r)}`:""} data-href="${le}">${ee}</a>`,S.push({id:Q.id,href:fe,internal:!0})}let te=se+ee;Q.tooltip&&(te=`<title>${Oe(Q.tooltip)}</title>`+te),Q.link&&(te=ua(te,Q.link,Q.id,S,r,Q.linkTarget?` target="${Xe(Q.linkTarget)}"`:"")),Y+=`<g class="pele-node pele-shape-${G.shape}${ie}${K}" data-id="${re}" transform="translate(${h(J)},${h(F)})">${te}</g>`}let B="",q="",D=(P,G,X,Q,J)=>{let F=P.style.length>0||P.cssCompiledStyles.length>0?vt(P.cssCompiledStyles.concat(P.style)):void 0,K=P.arrowTypeEnd,re=F?.stroke?Xe(F.stroke):"var(--_l)",ne=P.thickness==="dotted"?"reference":K==="arrow_cross"?"failure":"sequence",de=_t(P.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));B+=`<g class="pele-edge pele-edge-${ne}${de}" data-id="${Oe(P.id)}"${F?.line??""}><path d="${X.d}"${P.thickness==="dotted"?' stroke-dasharray="3 4"':""}/>`+bt(K,X.ex,X.ey,X.edx,X.edy,re)+"</g>",G.width>0&&(q+=wr(P.id,G,Q,J,F?.text??"",p))},R=new Map;for(let P=0;P<L.length;P++){let G=L[P],X=N[P],Q=I[P],J=X.arrowTypeEnd,F;if(G.src===G.dst){let K=g[G.src],re=R.get(G.src)??0;R.set(G.src,re+1),F=Mo(u[G.src],K.w,K.h,re,w(G.src),Ep,gt(J),G)}else{let K=G.route.slice();rs(K,0,g[G.src],u[G.src]),rs(K,K.length-3,g[G.dst],u[G.dst]),F=zr(K,X.curve,0,gt(J))}D(X,Q,F,G.labelX,G.labelY)}return O.forEach((P,G)=>D(P.edge,P.label,$[G],y[2*G],y[2*G+1])),{svg:Je("agentflow",z,C,s,r,e,Re(U,z/2,f+U.height/2,' class="pele-title" font-weight="var(--_tw)"')+(M?`<g class="pele-clusters">${M}</g>`:"")+(B?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${B}</g>`:"")+(q?`<g class="pele-edge-labels" font-size="${l}">${q}</g>`:"")+`<g class="pele-nodes">${Y}</g>`),width:z,height:C,links:S}}function Tp(e,t){return`M${h(e-1.75)},${h(t)}a1.75,1.75 0 1 0 3.5,0a1.75,1.75 0 1 0 -3.5,0Z`}var SI,TI,CI,Ol,NI,RI,OI,PI,BI,Yx,Xx,HI,YI,UI,qI,GI,jI,VI,XI,KI,ZI,Ap,QI,JI,dh,_p,Ip,Np,fh,Ux,vp,Pl,t5,a5,qx,mn,Kx,i5,s5,o5,c5,h5,d5,zl,Ep,oh,Gx,f5,jx,p5,Qx,Jx=Ve(()=>{ud();Rs();go();Fs();Ei();hi();Ti();tr();zt();pr();ut();wt();SI=new Map([["task","roundedRect"],["tool","subroutine"],["input","lean-right"],["decision","diamond"],["refdoc","lin-doc"],["action","hexagon"],["round","rect"]]),TI=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"]),CI=new Set(["roundedRect","subroutine","subprocess","subproc","framed-rectangle","lean-right","diamond","lin-doc","lined-document","hexagon","hex","connector","collapsedGroup"]),Ol="roundedRect";NI=new Set(["shape","view","icon","img","form","pos","w","h","class","style","labelType"]),RI=new Set(["subroutine","subprocess","subproc","framed-rectangle","tool"]);OI=/:\s*[>|][\d+-]*\s*$/,PI=/,([\t ]*)$/;BI=class{constructor(e={}){ce(this,"type","agentflow");ce(this,"direction");ce(this,"nodes",new Map);ce(this,"edges",[]);ce(this,"subgraphs",[]);ce(this,"connectors",new Map);ce(this,"classes",new Map);ce(this,"tooltips",new Map);ce(this,"defaultEdgeStyle");ce(this,"defaultInterpolate");ce(this,"mappings",[]);ce(this,"diagnostics",[]);ce(this,"title");ce(this,"accTitle");ce(this,"accDescr");ce(this,"lineOffset");ce(this,"subgraphLookup",new Map);ce(this,"globalNodes",new Set);ce(this,"members",new Set);ce(this,"edgeById",new Map);ce(this,"pairCount",new Map);ce(this,"subCount",0);ce(this,"bareMappings",new Set);ce(this,"firstMapping",new Map);ce(this,"reported",new Map);ce(this,"options");this.options=e,this.lineOffset=e.lineOffset??0}metadata(e,t,r){let a=t.includes(`
|
|
118
|
+
`),i;try{i=Ma(a?t+`
|
|
119
|
+
`:`{
|
|
120
|
+
`+t+`
|
|
121
|
+
}`)}catch(s){let l=a?zI(t):t,n;if(l!==t)try{n=Ma(l+`
|
|
122
|
+
`)}catch{n=void 0}if(n===void 0){let o=r?` (${r.first_line+this.lineOffset}:${r.first_column+1})`:"";throw new je(`Metadata of "${e}" is not valid YAML. ${s.message}${o}`,"syntax",{type:"agentflow",line:r?r.first_line+this.lineOffset:0,column:r?r.first_column+1:0})}i=n}return DI(i??{})}shapeError(e,t){return new je(e,"semantic",{type:"agentflow",line:t?t.first_line+this.lineOffset:0,column:t?t.first_column+1:0})}addVertex(e,t,r,a,i,s,l={},n,o){if(!e||e.trim().length===0)return;let c,f,p;n!==void 0&&(c=this.metadata(e,n,o),Cp(c)&&(f=c,typeof c.shape=="string"&&(p=c.shape,c.shape=hh(c.shape))));let d=this.subgraphLookup.get(e);if(d&&c){d.metadata=lh(d.metadata,c);return}let g=this.connectors.get(e);if(g&&c){g.metadata=lh(g.metadata,c);return}if(e==="connectors")return;let u=this.edgeById.get(e);if(u){f?.animate!==void 0&&(u.animate=f.animate),f?.animation!==void 0&&(u.animation=f.animation),f?.curve!==void 0&&(u.interpolate=f.curve),c&&(u.metadata=lh(u.metadata,c));return}let m=this.nodes.get(e);if(m===void 0&&(m={id:e,labelType:"text",styles:[],classes:[]},this.nodes.set(e,m)),t!==void 0?(m.labelType=t.type,m.text=Bx(t.text.trim())):m.text===void 0&&(m.text=e),r!==void 0&&(m.type=r),a!=null)for(let b of a)m.styles.push(b);if(i!=null)for(let b of i)m.classes.push(b);if(s!==void 0&&(m.dir=s),m.props===void 0?m.props=l:l!==void 0&&Object.assign(m.props,l),!!c&&(m.metadata=lh(m.metadata,c),f!==void 0)){if(f.shape){let b=p??f.shape;if(typeof b!="string")throw this.shapeError(`No such shape: ${JSON.stringify(b)}.`,o);if(b!==b.toLowerCase()||b.includes("_"))throw this.shapeError(`No such shape: ${b}. Shape names should be lowercase.`,o);let w=f.shape;if(!_I(w))throw this.shapeError(`No such shape: ${w}.`,o);m.type=w}f.label&&(m.text=String(f.label),m.labelType=Mp(f.labelType))}}addSingleLink(e,t,r,a){let i={start:e,end:t,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},s=r?.text;s!==void 0&&(i.text=Bx(s.text.trim()),i.labelType=Mp(s.type)),r!==void 0&&(i.type=r.type,i.stroke=r.stroke,i.length=r.length>10?10:r.length,r.edgeSemantic&&(i.edgeSemantic=r.edgeSemantic));let l=e+"\0"+t,n=this.pairCount.get(l)??0;a&&!this.edgeById.has(a)?(i.id=a,i.isUserDefinedId=!0):i.id=`L_${e}_${t}_${n===0?0:n+1}`;let o=this.options.maxEdges;if(o!==void 0&&this.edges.length>=o)throw new je(`Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${o}.`,"limit",{type:"agentflow"});this.edges.push(i),this.pairCount.set(l,n+1),this.edgeById.has(i.id)||this.edgeById.set(i.id,i)}addLink(e,t,r){let a=typeof r?.id=="string"?r.id.replace("@",""):void 0,i=e[e.length-1],s=t[0];for(let l of e)for(let n of t)this.addSingleLink(l,n,r,l===i&&n===s?a:void 0)}updateLinkInterpolate(e,t){for(let r of e)r==="default"?this.defaultInterpolate=t:this.edgeAt(r).interpolate=t}updateLink(e,t){for(let r of e){if(r==="default"){this.defaultEdgeStyle=t;continue}let a=this.edgeAt(r);a.style=t,t.length>0&&!t.some(i=>i?.startsWith("fill"))&&t.push("fill:none")}}edgeAt(e){let t=this.edges[Number(e)];if(t===void 0)throw new je(`The index ${e} 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 t}addClass(e,t){let r=t.join().replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let a of e.split(",")){let i=this.classes.get(a);i===void 0&&(i={id:a,styles:[],textStyles:[]},this.classes.set(a,i));for(let s of r)s.includes("color")&&i.textStyles.push(s.replace("fill","bgFill")),i.styles.push(s)}}setDirection(e){let t=e.trim();t.includes("<")&&(t="RL"),t.includes("^")&&(t="BT"),t.includes(">")&&(t="LR"),t.includes("v")&&(t="TB"),t==="TD"&&(t="TB"),this.direction=t}setClass(e,t){for(let r of e.split(","))this.nodes.get(r)?.classes.push(t),this.edgeById.get(r)?.classes.push(t),this.subgraphLookup.get(r)?.classes.push(t)}setTooltip(e,t){if(t!==void 0)for(let r of e.split(","))this.tooltips.set(r,t)}setLink(e,t,r){let a=t.trim();for(let i of e.split(",")){let s=this.nodes.get(i);s!==void 0&&(s.link=a?Ta(a):void 0,s.linkTarget=r)}this.setClass(e,"clickable")}setClickEvent(e,t,r){this.setClass(e,"clickable")}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
123
|
+
`)}addSubGraph(e,t,r,a){let i=e?.text?.trim(),s=r?.text||"";e!==void 0&&e===r&&/\s/.test(s)&&(i=void 0);let l=new Set,n=[],o;for(let g of t)if(typeof g=="string")g.trim()!==""&&!l.has(g)&&(l.add(g),n.push(g));else if(Array.isArray(g))for(let u of g)u.trim()!==""&&!l.has(u)&&(l.add(u),n.push(u));else o=g.value;o??(o=this.options.inheritDir?this.direction??this.options.direction:void 0),i??(i="subGraph"+this.subCount),this.subCount++;let c=this.members,f=n.filter(g=>g!==i&&!this.globalNodes.has(g)&&!c.has(g));for(let g of f)c.add(g);let p=this.subgraphLookup.get(i);if(p){for(let g of f)p.nodes.push(g);return s.trim()&&(p.title=s.trim()),o&&(p.dir=o),i}let d={id:i,nodes:f,title:s.trim(),classes:[],dir:o,labelType:Mp(r?.type),type:"flow"};return this.subgraphs.push(d),this.subgraphLookup.set(i,d),i}addGlobal(e){let t=!1,r=a=>{let i=a.trim();i!==""&&(this.globalNodes.add(i),this.members.delete(i)&&(t=!0))};for(let a of e)if(typeof a=="string")r(a);else if(Array.isArray(a))for(let i of a)r(i);if(t)for(let a of this.subgraphs)a.nodes=a.nodes.filter(i=>!this.globalNodes.has(i))}addConnector(e,t){let r=e?.text?.trim();if(!r)return"";let a=t?.text?.trim()??"",i=this.connectors.get(r);if(i)a.length>0&&(i.text=a);else{let s={id:r,labelType:"text",styles:[],classes:[],isConnector:!0,text:a.length>0?a:r};this.connectors.set(r,s),this.nodes.set(r,s)}return r}destructLink(e,t){let r=WI(e);return t&&(t.includes(".")?"dotted":"normal")!==r.stroke?{type:"INVALID",stroke:"INVALID"}:{...r,edgeSemantic:FI(r.type,r.stroke)}}subgraph(e){return this.subgraphLookup.get(e)}vertexKind(e){if(LI(e))return"tool";let t=hh(e.type);return t==="hexagon"||t==="hex"?"action":t==="lean-right"||t==="lean_right"?"input":t==="lin-doc"||t==="lined-document"?"refdoc":t==="diamond"?"decision":"task"}semanticModel(){let e=[],t=[];for(let[s,l]of this.nodes){if(this.subgraphLookup.has(s))continue;let n=Hx(l.metadata);if(l.isConnector){let f={id:s};l.text!==void 0&&l.text!==s&&(f.title=l.text),n&&(f.metadata=n),t.push(f);continue}let o={id:s};l.text!==void 0&&(o.label=l.text);let c=hh(l.type);c!==void 0&&(o.shape=c),o.vertexKind=this.vertexKind(l),n&&(o.metadata=n),e.push(o)}let r=this.edges.map(s=>{let l={start:s.start,end:s.end};return s.id!==void 0&&(l.id=s.id),s.text.length>0&&(l.label=s.text),s.type!==void 0&&(l.type=s.type),s.stroke!==void 0&&(l.stroke=s.stroke),s.edgeSemantic!==void 0&&(l.edgeSemantic=s.edgeSemantic),s.length!==void 0&&(l.length=s.length),s.metadata&&Object.keys(s.metadata).length>0&&(l.metadata={...s.metadata}),l}),a=this.subgraphs.map(s=>{let l={id:s.id,nodes:[...s.nodes],type:s.type,title:s.title};s.dir!==void 0&&(l.direction=s.dir);let n=Hx(s.metadata);return n&&(l.metadata=n),l}),i={vertices:e,edges:r,subGraphs:a,connectors:t,diagnostics:this.diagnostics};return this.direction!==void 0&&(i.direction=this.direction),i}position(e){let t=e?.first_line??0,r=e?.first_column??0;return{startLine:t+this.lineOffset,startColumn:r,endLine:(e?.last_line??t)+this.lineOffset,endColumn:e?.last_column??r,startIndex:0,endIndex:0}}pushMapping(e,t,r){let a={id:e,type:t,position:r};return this.mappings.push(a),this.firstMapping.has(e)||this.firstMapping.set(e,a),a}addVertexMapping(e,t,r,a){if(!e)return;let i=this.pushMapping(e,"vertex",this.position(a));r==null&&this.bareMappings.add(i)}extendVertexMapping(e,t){if(!e||!t)return;let r=this.position(t);for(let a=this.mappings.length-1;a>=0;a--){let i=this.mappings[a];if(i.type!=="vertex"||i.id!==e)continue;this.bareMappings.delete(i)&&(i.type="attachment");let s=i.position;(r.endLine>s.endLine||r.endLine===s.endLine&&r.endColumn>s.endColumn)&&(s.endLine=r.endLine,s.endColumn=r.endColumn);return}this.pushMapping(e,"attachment",r)}addEdgeMapping(e,t,r,a){let i=Array.isArray(t)?t.filter(s=>typeof s=="string"&&s!==""):[];this.pushMapping(i.length>0?i.join(">"):"edge","edge",this.position(a))}blockMapping(e,t,r,a){if(!e)return;let i=this.position(r),s=a?this.position(a):i;this.pushMapping(e,t,{startLine:i.startLine,startColumn:i.startColumn,endLine:s.endLine,endColumn:s.endColumn,startIndex:0,endIndex:0})}addSubgraphMapping(e,t,r,a){let i=typeof e=="string"?e:e?.text;this.blockMapping(i??"","subgraph",r,a)}addConnectorMapping(e,t,r,a){this.blockMapping(e?.text?.trim()??"","connector",r,a)}emit(e,t,r,a){let i=a?.nodeId??a?.edgeId,s={id:e,severity:t,message:r};a?.nodeId?s.nodeId=a.nodeId:a?.edgeId&&(s.edgeId=a.edgeId);let l=i?this.firstMapping.get(i):void 0;l&&(s.position=l.position);let n=i??"",o=this.reported.get(n);if(o===void 0)this.reported.set(n,[s]);else{for(let c of o)if(c.id===e&&c.severity===t&&c.message===r&&c.nodeId===s.nodeId&&c.edgeId===s.edgeId)return;o.push(s)}this.diagnostics.push(s),this.options.log?.(t,`agentflow[${e}]: ${r}`)}emitWarning(e,t,r){this.emit(e,"warning",t,r)}emitError(e,t,r){this.emit(e,"error",t,r)}},Yx=["$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"],Xx=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")Xx[e.charCodeAt(0)]=1;HI=/accTitle\s*:\s*/y,YI=/accDescr\s*:\s*/y,UI=/accDescr\s*\{\s*/y,qI=/call\s+/y,GI=/click\s+/y,jI=/(?:\r?\n)*\s*\n/y,VI=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,XI=/\s*[<>^]/y,KI=/\s*v\b/y,ZI=[/.*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],Ap=/[\n\r\u2028\u2029]/g,QI=/\(\s*\)/y,JI=/\n\s*/g;dh=new Uint8Array(80);for(let e of[34,67,65,68,13,40,37,38,35,41,69])dh[e]=1;_p=new Uint8Array(80);for(let e of[34,69,67,27,65,68,40,37,38,35,41])_p[e]=1;Ip=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])Ip[e]=1;Np=new Uint8Array(80);for(let e of[34,67,37,78,35,12])Np[e]=1;fh=new Uint8Array(80);for(let e of[77,39,79,66])fh[e]=1;Ux="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",vp="'COMMENT', 'SEMI', 'NEWLINE', 'EOF'",Pl=[],t5=/}[^\S\n]*\n/g;a5=["TB","BT","RL","LR","TD"],qx="'COMMENT', 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'flow', 'global', 'connector', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'",mn=new Map([["tool",0],["task",1],["decision",2],["input",3],["refdoc",4],["connector",5],["action",6]]),Kx=mn.size,i5=e=>Math.max(1,e-Kx),s5=(e,t)=>{let r=Kx+e%i5(t);return t>0?r%t:r};o5=8,c5=40,h5=16,d5=48,zl=20,Ep=26,oh=14,Gx="collapsed",f5={TB:2,RL:3,BT:0,LR:1},jx=new WeakMap;p5=/[";]fill:/;Qx={type:"agentflow",keepComments:!0,parse(e,t,r,a,i){let s=t.flowchart??{},l=new BI({inheritDir:s.inheritDir===!0,direction:typeof t.direction=="string"?t.direction:void 0,lineOffset:a,maxEdges:i.maxEdges});return r&&(l.title=r),r5(e,l),Zx(l,t),l},render:u5}});var ew={};Ct(ew,{agentflow:()=>Qx});var tw=Ve(()=>{Jx()});function g5(){let e=!1;return(t,r)=>{Rp.lastIndex=r;let a=Rp.exec(t);if(a===null)return-1;let i=Rp.lastIndex;if(a[1]===void 0)return i;if(e)return-1;let s=t.indexOf("}",i);return e=s===-1,s+1||-1}}function yn(e="ACC_DESCR"){return{...ur,name:e,scanner:g5}}var Rp,ph=Ve(()=>{Xr();Rp=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y});function $5(e){return e.some(t=>Op.test(t))}function k5(e){for(let t of e){let r=cw.exec(t);if(r?.index&&r.index>0)return r.index}return 4}function aw(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(r,a)=>{let i=t.get(parseInt(a,10));return i?`line ${i}`:r})}function iw(e,t){throw new je(`Line ${e}: ${t}`,"syntax",{type:"treeView",line:e})}function M5(e){let t=new Map;if(!Op.test(e))return{text:e,lineMap:t};let r=e.split(`
|
|
124
|
+
`),a=-1;for(let c=0;c<r.length;c++)if(r[c].trim()==="treeView-beta"){a=c;break}if(a===-1)return{text:e,lineMap:t};let i=c=>c.trim()===""||w5.test(c)||x5.test(c),s=[];for(let c=a+1;c<r.length;c++){let f=r[c];i(f)||rw.test(f)||s.push(f.replace(/\t/g," "))}if(!$5(s))return{text:e,lineMap:t};let l=k5(s),n=[],o=(c,f)=>{n.push(c),t.set(n.length,f+1)};for(let c=0;c<=a;c++)o(r[c],c);for(let c=a+1;c<r.length;c++){let f=r[c];if(i(f)){o(f,c);continue}if(rw.test(f))continue;let p=f.replace(/\t/g," "),d=cw.exec(p);if(d){let g=Math.round(d.index/l)+1,u=d.index+1;for(;u<p.length&&m5.test(p[u]);)u++;for(;u<p.length&&p[u]===" ";)u++;let m=p.slice(u).trimEnd();m||iw(c+1,"Empty node \u2014 expected a filename or directory name after the box-drawing prefix"),o(b5.repeat(g)+m,c)}else{if(y5.test(p))continue;Op.test(p)?o(f,c):/^\s+/.test(p)?iw(c+1,"Unexpected indentation without box-drawing characters. In box-drawing format, use \u251C\u2500\u2500 or \u2514\u2500\u2500 prefixes for indented nodes."):o(f,c)}}return{text:n.join(`
|
|
125
|
+
`),lineMap:t}}function A5(e,t){if(e.startsWith("##",t)||e.startsWith("icon(",t))return!0;if(!e.startsWith(":::",t))return!1;let r=t+3;for(;pa(e.charCodeAt(r));)r++;let a=e.charCodeAt(r);return a>=65&&a<=90||a>=97&&a<=122||a===95}function v5(e,t){let r=e.charCodeAt(t);if(pa(r)||r===10||r===13||r===34||r===39||e.startsWith(":::",t)||e.startsWith("icon(",t)||e.startsWith("##",t))return-1;let a=e.length,i=t+1;for(;i<a;){let s=e.charCodeAt(i);if(s===10||s===13)break;if(pa(s)){let l=i+1;for(;pa(e.charCodeAt(l));)l++;if(A5(e,l))break;i=l}else i++}return i}function hw(e){let t=e.length;for(;t>0&&pa(e.charCodeAt(t-1));)t--;return t===e.length?e:e.slice(0,t)}function Lp(e,t){switch(e){case"INDENTATION":return t?.length||0;case"QUOTED_NAME":return t.substring(1,t.length-1);case"BARE_NAME":return hw(t);case"CLASS_ANNOTATION":return t.trim().substring(3).trim();case"ICON_ANNOTATION":{let r=t.trim();return r.substring(5,r.length-1)}case"DESC_ANNOTATION":return t.trim().substring(2).trim();default:return}}function E5(e){let t=new Zt(Gt(e,nw,"treeView"),nw,"treeView"),r={$type:"TreeView",nodes:[]};for(t.expect(0);;)if(t.kind===1)r.accDescr=Kt(t.take());else if(t.kind===2)r.accTitle=Xt(t.take());else if(t.kind===3)r.title=Vt(t.take());else break;for(;t.kind!==-1;){let a={$type:"TreeNode",name:""};if(t.kind===7&&(a.indent=t.take().length),t.kind===8){let i=t.take();a.name=i.substring(1,i.length-1)}else t.kind===12?a.name=hw(t.take()):t.fail("a name");for(;;)if(t.kind===4)a.classAnnotation=Lp("CLASS_ANNOTATION",t.take());else if(t.kind===5)a.iconAnnotation=Lp("ICON_ANNOTATION",t.take());else if(t.kind===6)a.descAnnotation=Lp("DESC_ANNOTATION",t.take());else break;r.nodes.push(a)}return r}function T5(e,t){for(let r of e.nodes){let a=typeof r.indent=="number"?r.indent:0,i=r.name,s=i.endsWith("/");s&&(i=i.slice(0,-1));let l=r.iconAnnotation;t.addNode(a,i,s?"directory":"file",r.classAnnotation||void 0,l!==void 0?l||"none":void 0,r.descAnnotation||void 0)}}function C5(e){let{text:t,lineMap:r}=M5(e);try{return E5(t)}catch(a){if(r.size===0||!(a instanceof je))throw a;let i=a.message.indexOf(`
|
|
126
|
+
`),s=i===-1?aw(a.message,r):aw(a.message.slice(0,i),r)+a.message.slice(i);throw new je(s,a.code,{type:a.type,line:r.get(a.line)??a.line,column:a.column,snippet:a.snippet})}}function _5(e,t){let r=new S5;return T5(e,r),{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,`
|
|
127
|
+
`):void 0,root:r.root,count:r.count}}function Dp(e,t){if(e===void 0||!Object.prototype.hasOwnProperty.call(e,t))return;let r=e[t];return typeof r=="string"?r:void 0}function I5(e,t){let r=Dp(t?.filenameIcons,e);if(r)return r;let a=e.lastIndexOf(".");if(a>0){let i=e.substring(a).toLowerCase();return Dp(t?.extensionIcons,i)??Dp(t?.extensionIcons,i.slice(1))}}function lw(e,t){return e.includes(":")?e:Pp.has(e)||!t?`${mh}:${e}`:`${t}:${e}`}function ow(e,t){if(e.icon!=="none"){if(e.icon)return lw(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType==="file"){let r=I5(e.name,t);if(r==="none")return;if(r)return lw(r,t.defaultIconPack)}return`${mh}:${e.nodeType==="directory"?"folder":"file"}`}}}function N5(e){let t=a=>typeof a=="object"&&a!==null&&!Array.isArray(a)?a:void 0,r=t(e.treeView)??{};return{showIcons:!!r.showIcons,defaultIconPack:typeof r.defaultIconPack=="string"?r.defaultIconPack:"",filenameIcons:t(r.filenameIcons),extensionIcons:t(r.extensionIcons)}}function gh(e,t,r,a,i){let s=e.treeView?.[t];return typeof s=="number"&&s>=a&&s<=i?s:r}function P5(e){return{paddingX:gh(e,"paddingX",5,0,100),paddingY:gh(e,"paddingY",2,0,100),rowIndent:gh(e,"rowIndent",15,0,400),lineThickness:gh(e,"lineThickness",1,.25,12)}}function z5(e,t,r){return Nr(r,a=>F5(e,t,r,a))}function F5(e,t,r,a){let i=r.fontSize??16,s=r.measurer??et(r.fontFamily),l=r.padding??8,n=N5(t),{paddingX:o,paddingY:c,rowIndent:f,lineThickness:p}=P5(t),d=0,g=e.root.children.map(T=>[T,0]);for(let T=0;a&&T<g.length;T++){let[A,M]=g[T];d=Math.max(d,M);for(let Y of A.children)g.push([Y,M+1])}let u=a?Math.min(f+o,Math.max(2,((r.maxWidth??320)-120)/Math.max(1,d))):f+o,m=Math.round(i*1.5)+2*c,b=i,w=ze(e.title,!1,s,i,a?It(r):4e3,1),v=w.height>0?w.height+12:0,k=T=>T.some(A=>ow(A,n)!==void 0),L=[],I=new Map,N=[],O=(T,A)=>{let M=k(T);for(let Y=T.length-1;Y>=0;Y--)N.push([T[Y],A,M])};O(e.root.children,0);let W=0,U=!1,_=0;for(;N.length>0;){let[T,A,M]=N.pop(),Y=A*u,B=At(T.name),q=Y+(M?b+R5:0),D=Math.max(40,(r.maxWidth??320)-2*l-2*uh-q),R=a?ds(B,s,i,D,T.nodeType==="directory"?1:0):void 0,P=a&&T.description?ds(At(T.description),s,i,D,2):void 0,G=R?R.width:s.width(B,i,T.nodeType==="directory"?1:0);q+G>W&&(W=q+G);let X=T.cssClass!==void 0&&T.cssClass.split(/\s+/).includes("highlight");X&&(U=!0);let Q=a?Math.max(m,(R?.height??0)+(P?.height??0)+2*c):m,J=_+(a?c+Math.max(b,R?.height??0)/2:Q/2),F={node:T,x:Y,cy:J,icon:ow(T,n),text:B,labelX:q,highlighted:X,label:R,description:P,top:_,height:Q};_+=Q,L.push(F),I.set(T,F),O(T.children,A+1)}let j=W+L5,Z=W;for(let T of L){let A=T.node.description;if(!A)continue;let M=T.description?T.description.width:s.width(At(A),i,2);Z=Math.max(Z,(a?T.labelX:j)+M)}Z=Math.max(Z,w.width);let H=l+(U?uh:0),z=l+v,C=Math.ceil(Z+2*H),S=Math.ceil(z+_+l),$="";for(let T of L){let A=T.node.children;if(A.length===0)continue;let M=H+T.x+D5,Y=Math.max(M,H+T.x+u-o),B=z+I.get(A[A.length-1]).cy,q=Math.min(O5,Y-M),D=`M${h(M)},${h(z+T.top+T.height-2)}V${h(B-q)}`;q>0&&(D+=`Q${h(M)},${h(B)} ${h(M+q)},${h(B)}H${h(Y)}`);for(let R=0;R<A.length-1&&Y>M;R++)D+=`M${h(M)},${h(z+I.get(A[R]).cy)}H${h(Y)}`;$+=`<path d="${D}"/>`}let y=i*.35,E="";for(let T of L){let A=T.node,M=z+T.cy,Y=A.nodeType==="directory",B="";if(T.highlighted){let q=H+T.x-uh;B+=`<rect class="pele-tree-highlight" x="${h(q)}" y="${h(z+T.top+1)}" width="${h(C-H+uh-q)}" height="${h(T.height-2)}" fill="var(--_c)" fill-opacity="0.14"${st}/>`}if(T.icon!==void 0){let q=T.icon.startsWith(mh+":")?T.icon.slice(mh.length+1):"",D=Pp.get(q)??Pp.get(Y?"folder":"file"),R=r.icons?.(T.icon)??`<path d="${D}" stroke="var(--_m)" stroke-width="1.5"/>`;B+=`<svg class="pele-icon" data-icon="${Oe(T.icon)}" x="${h(H+T.x)}" y="${h(M-b/2)}" width="${h(b)}" height="${h(b)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${R}</svg>`}T.label?B+=yi(T.label,H+T.labelX,z+T.top+c,` class="pele-label"${Y?' font-weight="var(--_hw)"':""}`):T.text!==""&&(B+=`<text class="pele-label" x="${h(H+T.labelX)}" y="${h(M+y)}"${Y?' font-weight="var(--_hw)"':""} xml:space="preserve">${Xe(T.text)}</text>`),T.description?B+=yi(T.description,H+T.labelX,z+T.top+c+(T.label?.height??0),' class="pele-tree-description" font-style="italic" fill="var(--_m)"'):A.description&&(B+=`<text class="pele-tree-description" x="${h(H+j)}" y="${h(M+y)}" font-style="italic" fill="var(--_m)" xml:space="preserve">${Xe(At(A.description))}</text>`),E+=`<g class="pele-node pele-tree-${Y?"dir":"file"}${_t(A.cssClass??"")}" data-id="${Oe(A.name)}">${B}</g>`}let x=Re(w,C/2,l+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+($?`<g class="pele-tree-guides" fill="none" stroke="var(--_b)" stroke-width="${h(p)}">${$}</g>`:"")+E;return{svg:Je("treeView",C,S,i,r,e,x),width:C,height:S,links:[]}}var Op,cw,m5,rw,y5,x5,w5,b5,sw,nw,S5,mh,Pp,R5,L5,D5,O5,uh,dw,fw=Ve(()=>{ph();ps();tr();zt();Xr();ut();wt();Op=/[─━│┃└┗├┣]/,cw=/[└┗├┣]/,m5=/[─━]/,rw=/^[\s│┃]+$/,y5=/^[\s─━│┃└┗├┣]+$/,x5=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,w5=/^\s*%%/,b5=" ";sw={name:"BARE_NAME",pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:v5},nw=[{...or("treeView-beta"),longer:[sw]},yn(),rr,ar,{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},sw];S5=class{constructor(){ce(this,"count",1);ce(this,"root",{id:0,level:-1,name:"/",nodeType:"directory",children:[]});ce(this,"stack",[this.root])}addNode(e,t,r,a,i,s){let l=this.stack;for(;e<=l[l.length-1].level;)l.pop();let n={id:this.count++,level:e,name:t,nodeType:r,icon:i,cssClass:a,description:s,children:[]};l[l.length-1].children.push(n),l.push(n)}};mh="mermaid-treeview",Pp=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"]]);R5=6,L5=16,D5=7,O5=4,uh=4;dw={type:"treeView",parse:(e,t,r)=>_5(C5(e),r),render:z5}});var pw={};Ct(pw,{treeView:()=>dw});var uw=Ve(()=>{fw()});function B5(e,t){let r=new W5;return r.setDomains(e.domains),r.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,`
|
|
128
|
+
`):void 0,domains:r.domains,transitions:r.transitions}}function H5(e){let t=new Zt(Gt(e,gw,"cynefin"),gw,"cynefin"),r={$type:"Cynefin",domains:[],transitions:[]},a=()=>{for(;t.kinds[t.i]===9;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==9&&t.fail("a line break or the end of input"),a())};for(a(),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:r.accDescr=Kt(t.take()),i();break;case 6:r.accTitle=Xt(t.take()),i();break;case 7:r.title=Vt(t.take()),i();break;case 4:{let s=t.take();if(t.accept(2)){let n={$type:"Transition",from:s,to:t.expect(4)};t.accept(3)&&(n.label=$r(t.expect(8))),i(),r.transitions.push(n);break}let l={$type:"DomainBlock",domain:s,items:[]};for(a();t.kinds[t.i]===8;)l.items.push({$type:"DomainItem",label:$r(t.take())}),a();r.domains.push(l);break}default:t.fail("a domain, a transition, a title, or a line break")}return r}function mw(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 Y5(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t}function U5(e,t){return typeof e=="number"&&Number.isFinite(e)&&e!==0?e:Y5(t)}function zp(e,t,r,a,i,s){let l=(t-e)/s.segments,n=[],o=[];for(let f=0;f<=s.segments;f++){let p=f===0&&s.pinStart||f===s.segments&&s.pinEnd;n.push(e+f*l),o.push(p?r:r+mw(a+f*s.pointStep)*i*2-i)}let c=s.vertical?[o[0],n[0]]:[n[0],o[0]];for(let f=0;f<s.segments;f++){let p=(n[f]+n[f+1])/2,d=i*1.5*(f%2===0?1:-1)*mw(a+f*s.controlStep+s.controlShift);s.vertical?c.push(o[f]+d,p,o[f+1]-d,p,o[f+1],n[f+1]):c.push(p,o[f]+d,p,o[f+1]-d,n[f+1],o[f+1])}return c}function G5(e,t,r,a){let i=r-t;return[e,t,e+a,t+i*.2,e-a*1.5,t+i*.55,e+a*.5,t+i*.75,e-a,t+i*.85,e+a*.3,t+i*.95,e,r]}function Fl(e){let t="";for(let r=2;r<e.length;r+=6)t+=`C${h(e[r])},${h(e[r+1])} ${h(e[r+2])},${h(e[r+3])} ${h(e[r+4])},${h(e[r+5])}`;return t}function yh(e){let t="";for(let r=e.length-6;r>=2;r-=6)t+=`C${h(e[r+2])},${h(e[r+3])} ${h(e[r])},${h(e[r+1])} ${h(e[r-2])},${h(e[r-1])}`;return t}function xh(e){return`M${h(e[0])},${h(e[1])}${Fl(e)}`}function j5(e,t,r,a){let i=`${h(r)},${h(a)}`;return`M${h(e-r)},${h(t)}A${i} 0 1,1 ${h(e+r)},${h(t)}A${i} 0 1,1 ${h(e-r)},${h(t)}Z`}function $h(e,t,r,a,i){let s=e.cynefin?.[t];return typeof s=="number"&&s>=a&&s<=i?s:r}function Q5(e,t,r){let a=r.fontSize??16,i=Math.round(a*.8125),s=Math.round(a*.875),l=r.measurer??et(r.fontFamily),n=r.padding??8,o=r.icons,c=t.cynefin?.showDomainDescriptions!==!1,f=$h(t,"boundaryAmplitude",8,0,50),p=U5($h(t,"seed",0,-1e15,1e15),r.idPrefix??"pele"),d=Math.round(s*1.5),g=(F,K)=>{let re=ze(F,!1,l,s,ww);return{text:F,label:re,w:re.width+2*K5,h:Math.max(re.height,d)+2*Z5,overflow:K}},u=F=>{let K=X5.get(F),re=ze(K[0],!1,l,a,4e3,1),ne=[];if(c)for(let fe of[K[1],K[2]])fe&&ne.push(ze(fe,!1,l,i,4e3,2));let de=e.domains.get(F)?.items??[],ie=F==="confusion"&&de.length>xw?xw:de.length,se=[];for(let fe=0;fe<ie;fe++)se.push(g(de[fe].label,!1));ie<de.length&&se.push(g(`+${de.length-ie} more`,!0));let ee=re.width,te=re.height;for(let fe of ne)ee=Math.max(ee,fe.width),te+=fe.height;se.length>0&&(te+=bw-wh);for(let fe of se)ee=Math.max(ee,fe.w),te+=wh+fe.h;return{name:F,title:re,subtitles:ne,badges:se,w:ee,h:te,cx:0,cy:0}},m=Fp.map(([F])=>u(F)),b=u("confusion"),w=Math.max(88,b.w*.71+8),v=Math.max(64,b.h*.71+6),k=$h(t,"width",640,100,1e4)/2,L=$h(t,"height",440,100,1e4)/2;for(let F of m)k=Math.max(k,F.w+2*$w),L=Math.max(L,F.h+2*$w);for(let F of m){let K=(k-F.w)/2,re=(L-F.h)/2;if((K/(w+bh))**2+(re/(v+bh))**2>=1)continue;let ne=F.w+2*(w+bh),de=F.h+2*(v+bh);ne*L<=k*de?k=Math.max(k,ne):L=Math.max(L,de)}let I=ze(e.title,!1,l,a,4e3,1),N=I.height>0?I.height+12:0,O=2*k,W=2*L,U=n,_=n+N,j=U+k,Z=_+L,H=U+O,z=_+W,C=zp(_,Z,j,p,f,{...q5,segments:4,pinEnd:!0}),S=zp(U,j,Z,p+100,f,{...yw,segments:4,pinEnd:!0}),$=zp(j,H,Z,p+200,f,{...yw,segments:4,pinStart:!0}),y=G5(j,Z,z,O*.03),E=(F,K)=>K?`${h(F[F.length-2])},${h(F[F.length-1])}`:`${h(F[0])},${h(F[1])}`,x=new Map([["complex",`M${h(U)},${h(_)}L${E(C,!1)}${Fl(C)}${yh(S)}Z`],["complicated",`M${E(C,!1)}L${h(H)},${h(_)}L${E($,!0)}${yh($)}${yh(C)}Z`],["chaotic",`M${E(S,!1)}${Fl(S)}${Fl(y)}L${h(U)},${h(z)}Z`],["clear",`M${E($,!1)}${Fl($)}L${h(H)},${h(z)}L${E(y,!0)}${yh(y)}Z`]]),T="";for(let[F,,,K]of Fp)T+=`<path class="pele-cynefin-region" data-id="${F}" d="${x.get(F)}" fill="${dt(K)}" fill-opacity="0.14"/>`;let A=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${xh(C)}"/><path d="${xh(S)}"/><path d="${xh($)}"/><path class="pele-cynefin-cliff" d="${xh(y)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,M=j5(j,Z,w,v),Y=`<path d="${M}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${M}" fill="${dt(V5)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,B=F=>{let K=F.cy-F.h/2,re=Re(F.title,F.cx,K+F.title.height/2,' class="pele-label" font-weight="var(--_hw)"');K+=F.title.height;for(let ne of F.subtitles)re+=Re(ne,F.cx,K+ne.height/2,` class="pele-cynefin-subtitle" font-size="${i}" font-style="italic" fill="var(--_m)"`),K+=ne.height;K+=bw-wh;for(let ne of F.badges)K+=wh,re+=`<g class="pele-node${ne.overflow?" pele-cynefin-overflow":""}"${ne.overflow?"":` data-id="${Oe(ne.text)}"`}><rect x="${h(F.cx-ne.w/2)}" y="${h(K)}" width="${h(ne.w)}" height="${h(ne.h)}" fill="var(--_bg)" stroke="var(--_b)"${ne.overflow?' stroke-dasharray="3 2"':""}${st}/>`+Re(ne.label,F.cx,K+ne.h/2,` class="pele-label" font-size="${s}"${ne.overflow?' fill="var(--_m)"':""}`,o)+"</g>",K+=ne.h;return`<g class="pele-cynefin-domain" data-id="${F.name}">${re}</g>`},q=new Map,D="";Fp.forEach(([F,K,re],ne)=>{let de=m[ne];de.cx=U+k*(K+.5),de.cy=_+L*(re+.5),q.set(F,de),D+=B(de)}),b.cx=j,b.cy=Z,q.set("confusion",b),D+=B(b);let R=(F,K,re)=>F===b?((K-j)/(w+4))**2+((re-Z)/(v+4))**2<=1:Math.abs(K-F.cx)<=F.w/2+8&&Math.abs(re-F.cy)<=F.h/2+8,P="",G=new Map;for(let F of e.transitions){let K=q.get(F.from),re=q.get(F.to);if(!K||!re||K===re)continue;let ne=F.from<F.to?`${F.from} ${F.to}`:`${F.to} ${F.from}`,de=G.get(ne)??0;G.set(ne,de+1);let ie=re.cx-K.cx,se=re.cy-K.cy,ee=Math.hypot(ie,se)||1,te=(K.cx+re.cx)/2,fe=(K.cy+re.cy)/2,ye=-se*(te-j)+ie*(fe-Z)>=0?1:-1,le=-se/ee*ye,we=ie/ee*ye,pe=(K!==b&&re!==b&&Math.abs(ie)>1&&Math.abs(se)>1?2*(Math.hypot(w*le,v*we)+16):ee*.15)+de*56,ge=te+le*pe,Ae=fe+we*pe,Se=$e=>{let ve=1-$e;return[ve*ve*K.cx+2*ve*$e*ge+$e*$e*re.cx,ve*ve*K.cy+2*ve*$e*Ae+$e*$e*re.cy]},oe=($e,ve,Te,De)=>{for(let _e=0;_e<16;_e++){let He=(ve+Te)/2;R($e,...Se(He))===De?ve=He:Te=He}return(ve+Te)/2},ue=48,xe=1;for(;xe<=ue&&R(K,...Se(xe/ue));)xe++;if(xe>ue)continue;let Ie=oe(K,(xe-1)/ue,xe/ue,!0);for(;xe<=ue&&!R(re,...Se(xe/ue));)xe++;let Le=xe>ue?1:oe(re,(xe-1)/ue,xe/ue,!1),[We,he]=Se(Ie),[ke,Ce]=Se(Le),be=($e,ve,Te)=>(1-Ie)*(1-Le)*$e+((1-Ie)*Le+Ie*(1-Le))*ve+Ie*Le*Te,Me=be(K.cx,ge,re.cx),Ne=be(K.cy,Ae,re.cy),Be=Math.hypot(ke-Me,Ce-Ne)||1,Pe=(ke-Me)/Be,V=(Ce-Ne)/Be,me=bt("arrow_point",ke,Ce,Pe,V,"var(--_l)");ke-=Pe*gt("arrow_point"),Ce-=V*gt("arrow_point");let ae="";if(F.label){let $e=ze(F.label,!1,l,i,ww),[ve,Te]=Se((Ie+Le)/2),De=Math.abs(le)*$e.width/2+Math.abs(we)*$e.height/2+6,_e=$e.width/2+4,He=Math.min(Math.max(ve+le*De,U+_e),Math.max(H-_e,U+_e));ae=Re($e,He,Te+we*De,` class="pele-edge-label" font-size="${i}"`,o)}P+=`<g class="pele-edge" data-id="${F.from}-${F.to}"><path d="M${h(We)},${h(he)}Q${h(Me)},${h(Ne)} ${h(ke)},${h(Ce)}" fill="none" stroke="var(--_l)"/>`+me+ae+"</g>"}let X=Math.ceil(Math.max(O,I.width)+2*n),Q=Math.ceil(W+N+2*n),J=Re(I,U+O/2,n+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-cynefin-regions">${T}</g>`+A+Y+D+(P?`<g class="pele-edges">${P}</g>`:"");return{svg:Je("cynefin",X,Q,a,r,e,J),width:X,height:Q,links:[]}}var W5,gw,q5,yw,Fp,V5,X5,xw,ww,K5,Z5,wh,bw,$w,bh,kw,Mw=Ve(()=>{Xr();pr();ut();wt();W5=class{constructor(){ce(this,"domains",new Map);ce(this,"transitions",[])}setDomains(e){if(e)for(let t of e){let r=t.domain;this.domains.set(r,{name:r,items:(t.items??[]).map(a=>({label:a.label}))})}}setTransitions(e){e&&(this.transitions=e.filter(t=>t.from!==t.to).map(t=>({from:t.from,to:t.to,label:t.label||void 0})))}};gw=[{name:"cynefin-beta:",pattern:"cynefin-beta:"},or("cynefin-beta"),{name:"-->",pattern:"-->"},{name:":",pattern:":"},{name:"DOMAIN_NAME",pattern:/complex|complicated|clear|chaotic|confusion/y},ur,rr,ar,Vr,Rr,Lr,jt,nr,lr];q5={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},yw={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};Fp=[["complex",0,0,0],["complicated",1,0,1],["chaotic",0,1,3],["clear",1,1,2]],V5=4,X5=new Map([["complex",["Complex","Probe \u2192 Sense \u2192 Respond","Emergent Practices"]],["complicated",["Complicated","Sense \u2192 Analyse \u2192 Respond","Good Practices"]],["clear",["Clear","Sense \u2192 Categorise \u2192 Respond","Best Practices"]],["chaotic",["Chaotic","Act \u2192 Sense \u2192 Respond","Novel Practices"]],["confusion",["Confusion","","Disorder"]]]),xw=3,ww=200,K5=10,Z5=4,wh=6,bw=10,$w=20,bh=10;kw={type:"cynefin",parse:(e,t,r)=>B5(H5(e),r),render:Q5}});var Aw={};Ct(Aw,{cynefin:()=>kw});var vw=Ve(()=>{Mw()});function Mh(e,t){let r=e<=1?e*100:e;if(r<0||r>100)throw new je(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,"semantic",{type:"wardley"});return r}function ks(e,t,r){return{x:Mh(t,`${r} evolution`),y:Mh(e,`${r} visibility`)}}function Ew(e){return e==="+<>"?"bidirectional":e==="+<"?"backward":e==="+>"?"forward":void 0}function e6(e){if(!e?.startsWith("+"))return{};let t=e.indexOf("'",2),r=e[1]==="'"&&t!==-1?e.slice(2,t):void 0;return e.includes("<>")?{flow:"bidirectional",label:r}:e.includes("<")?{flow:"backward",label:r}:e.includes(">")?{flow:"forward",label:r}:{label:r}}function Sw(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function t6(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map(r=>r.secondName?`${r.name.trim()} / ${r.secondName.trim()}`:r.name.trim()),stageBoundaries:e.evolution.stages.filter(r=>r.boundary!==void 0).map(r=>r.boundary)});for(let r of e.anchors){let a=ks(r.visibility,r.evolution,`Anchor "${r.name}"`);t.addNode({id:r.name,label:r.name,x:a.x,y:a.y,className:"anchor"})}for(let r of e.components){let a=ks(r.visibility,r.evolution,`Component "${r.name}"`),[i,s]=Sw(r.label);t.addNode({id:r.name,label:r.name,x:a.x,y:a.y,className:"component",labelOffsetX:i,labelOffsetY:s,inertia:r.inertia,sourceStrategy:r.decorator?.strategy})}for(let r of e.notes){let a=ks(r.visibility,r.evolution,`Note "${r.text}"`);t.addNote({text:r.text,x:a.x,y:a.y})}for(let r of e.pipelines){let a=t.getNode(r.parent);if(!a||typeof a.y!="number")throw new je(`Pipeline "${r.parent}" must reference an existing component with coordinates.`,"semantic",{type:"wardley"});let i=a.y;t.startPipeline(r.parent);for(let s of r.components){let l=`${r.parent}_${s.name}`,[n,o]=Sw(s.label),c=Mh(s.evolution,`Pipeline component "${s.name}" evolution`);t.addNode({id:l,label:s.name,x:c,y:i,className:"pipeline-component",labelOffsetX:n,labelOffsetY:o,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(r.parent,l)}}for(let r of e.links){let a=!!r.arrow&&(r.arrow.includes("-.->")||r.arrow.includes(".-.")),i=e6(r.arrow),s=Ew(r.fromPort)??Ew(r.toPort)??i.flow;t.addLink({source:t.resolveNodeId(r.from),target:t.resolveNodeId(r.to),dashed:a,label:i.label??r.linkLabel,flow:s})}for(let r of e.evolves){let a=t.getNode(r.component);a?.y!==void 0&&t.addTrend({nodeId:r.component,targetX:Mh(r.target,`Evolve target for "${r.component}"`),targetY:a.y})}if(e.annotations.length>0){let r=ks(e.annotations[0].x,e.annotations[0].y,"Annotations box");t.setAnnotationsBox(r.x,r.y)}for(let r of e.annotation){let a=ks(r.x,r.y,`Annotation ${r.number}`);t.addAnnotation({number:r.number,coordinates:[{x:a.x,y:a.y}],text:r.text})}for(let r of e.accelerators){let a=ks(r.x,r.y,`Accelerator "${r.name}"`);t.addAccelerator({name:r.name,x:a.x,y:a.y})}for(let r of e.deaccelerators){let a=ks(r.x,r.y,`Deaccelerator "${r.name}"`);t.addDeaccelerator({name:r.name,x:a.x,y:a.y})}}function r6(e,t){let r=new J5;return t6(e,r),{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,`
|
|
129
|
+
`):void 0,...r.build()}}function Tw(e,t){let r=t;for(let a=e.charCodeAt(r);a>=48&&a<=57;a=e.charCodeAt(r))r++;return r}function a6(){let e=0,t=0;return(r,a)=>{if((a<e||a>=t)&&(e=a,t=Tw(r,a)),t===a||r.charCodeAt(t)!==46)return-1;let i=Tw(r,t+1);return i>t+1?i:-1}}function i6(e){let t=new Zt(Gt(e,Iw,"wardley"),Iw,"wardley"),r={$type:"Wardley",anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},a=g=>t.kinds[t.i]===g,i=()=>a(36)||a(37)||a(30),s=()=>a(36)?$r(t.take()):a(37)||a(30)?t.take():t.fail("a name"),l=()=>Number(t.expect(10)),n=()=>parseInt(t.expect(35)),o=()=>a(10)?Number(t.take()):parseInt(t.expect(35)),c=()=>{if(!a(-1))for(a(38)||t.fail("a line break or the end of input");a(38);)t.i++},f=g=>{t.expect(0);let u=g();t.expect(1);let m=g();return t.expect(2),[u,m]},p=()=>{t.expect(21),t.expect(0);let g=t.accept(7),u=n();t.expect(1);let m=t.accept(7),b=n();return t.expect(2),{$type:"Label",negX:g,offsetX:u,negY:m,offsetY:b}},d=()=>{let g={$type:"EvolutionStage",name:s()};return t.accept(3)&&(g.boundary=l()),t.accept(4)&&(g.secondName=s()),g};for(;a(38);)t.i++;for(t.expect(16);!a(-1);)switch(t.kind){case 38:t.i++;break;case 32:r.accDescr=Kt(t.take()),c();break;case 33:r.accTitle=Xt(t.take()),c();break;case 34:r.title=Vt(t.take()),c();break;case 17:{t.i++;let[g,u]=f(n);c(),r.size={$type:"Size",width:g,height:u};break}case 18:{t.i++;let g=[d()];for(t.expect(11),g.push(d());t.accept(11);)g.push(d());c(),r.evolution={$type:"Evolution",stages:g};break}case 19:{t.i++;let g=s(),[u,m]=f(l);c(),r.anchors.push({$type:"Anchor",name:g,visibility:u,evolution:m});break}case 20:{t.i++;let g={$type:"Component",name:s(),visibility:0,evolution:0,inertia:!1};[g.visibility,g.evolution]=f(l),a(21)&&(g.label=p()),a(5)&&t.kinds[t.i+1]===15&&(t.i++,g.decorator={$type:"Decorator",strategy:t.take()},t.expect(6)),t.accept(22)?g.inertia=!0:t.accept(5)&&(t.expect(22),t.expect(6),g.inertia=!0),c(),r.components.push(g);break}case 23:{t.i++;let g=s(),u=l();c(),r.evolves.push({$type:"Evolve",component:g,target:u});break}case 24:{t.i++;let g=s();for(t.expect(8),t.expect(38);a(38);)t.i++;let u=[];do{t.expect(20);let m={$type:"PipelineComponent",name:s(),evolution:0};t.expect(0),m.evolution=l(),t.expect(2),a(21)&&(m.label=p()),c(),u.push(m)}while(a(20));t.expect(9),c(),r.pipelines.push({$type:"Pipeline",parent:g,components:u});break}case 25:{t.i++;let g=$r(t.expect(36)),[u,m]=f(l);c(),r.notes.push({$type:"Note",text:g,visibility:u,evolution:m});break}case 26:{t.i++;let[g,u]=f(o);c(),r.annotations.push({$type:"Annotations",x:g,y:u});break}case 27:{t.i++;let g=n();t.expect(1);let[u,m]=f(o),b=$r(t.expect(36));c(),r.annotation.push({$type:"Annotation",number:g,x:u,y:m,text:b});break}case 28:case 29:{let g=t.kind===29;t.i++;let u=s(),[m,b]=f(l);c(),g?r.deaccelerators.push({$type:"Deaccelerator",name:u,x:m,y:b}):r.accelerators.push({$type:"Accelerator",name:u,x:m,y:b});break}default:{i()||t.fail("a statement");let g={$type:"Link",from:s(),to:""};a(12)&&(g.fromPort=t.take()),(a(13)||a(11))&&(g.arrow=t.take()),g.to=s(),a(12)&&(g.toPort=t.take()),a(14)&&(g.linkLabel=t.take().substring(1).trim()),c(),r.links.push(g)}}return r}function c6(e,t,r,a,i){let s=e["wardley-beta"]?.[t];return typeof s=="number"&&s>=a&&s<=i?s:r}function xn(e,t,r){return e<t?t:e>r?r:e}function Rw(e,t,r,a){let i=li(e),s="",l=r;for(let n of e.lines){let o=!0;for(let c of n){if(c.icon!==void 0)continue;let f=Ha(c.style&~i);s+=`<tspan${o?` x="${h(t)}" y="${h(l)}"`:""}${f}>${Xe(c.text)}</tspan>`,o=!1}l+=e.lineHeight}return s===""?"":`<text${Aa(a,i)} xml:space="preserve">${s}</text>`}function Lw(e,t,r,a){let i=typeof t=="number"&&Number.isFinite(t)?t:c6(e,r,a,1,1e6);return xn(i,200,1e4)-2*n6}function h6(e,t,r){let a=Lw(t,e.size?.width,"width",900);return Ci(r,a,160,(i,s)=>d6(e,t,r,i,a,s))}function d6(e,t,r,a,i,s){let l=r.fontSize??16,n=Math.round(l*.8125),o=Math.round(l*.6875),c=r.measurer??et(r.fontFamily),f=r.padding??8,p=Lw(t,e.size?.height,"height",600)*Math.max(.75,a/i),d=t["wardley-beta"]?.showGrid===!0,g=0,u=0,m=a,b=p,w=(le,we,pe,ge)=>{le<g&&(g=le),we<u&&(u=we),pe>m&&(m=pe),ge>b&&(b=ge)},v=(le,we,pe,ge)=>(w(we-le.width/2,pe-le.height/2,we+le.width/2,pe+le.height/2),Re(le,we,pe,ge,r.icons)),k=(le,we,pe,ge)=>(w(we,pe-le.size,we+le.width,pe-le.size+le.height+4),Rw(le,we,pe,ge)),L=(le,we,pe=s?Math.max(64,Math.min(120,a/2)):4e3,ge=0)=>ze(le,!1,c,we,pe,ge),I=le=>le/100*a,N=le=>p-le/100*p,O=e.axes.stages&&e.axes.stages.length>0?e.axes.stages:s6,W=e.axes.stageBoundaries,U=W!==void 0&&W.length===O.length,_="",j="",Z=p,H=0;if(O.forEach((le,we)=>{let pe=U?H:we/O.length,ge=U?xn(W[we],0,1):(we+1)/O.length;H=ge,we>0&&(_+=`<path class="pele-wardley-stage" d="M${h(pe*a)},0V${h(p)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let Ae=L(le,n,Math.max(48,Math.abs(ge-pe)*a-12));j+=v(Ae,(pe+ge)/2*a,p+8+Ae.height/2,` class="pele-wardley-stage-label" font-size="${n}" fill="var(--_m)"`),Z=Math.max(Z,p+8+Ae.height)}),d)for(let le=1;le<4;le++)_+=`<path class="pele-wardley-grid" d="M${h(a*le/4)},0V${h(p)}M0,${h(p*le/4)}H${h(a)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;_+=`<path class="pele-wardley-axis" d="M0,0V${h(p)}H${h(a)}" stroke="${oa}"/>`;let z=L(e.axes.xLabel??"Evolution",n),C=L(e.axes.yLabel??"Visibility",n),S=` class="pele-wardley-axis-label" font-size="${n}" font-weight="var(--_hw)"`,$=v(z,a/2,Z+6+z.height/2,S)+Re(C,-16,p/2,`${S} transform="rotate(-90 -16 ${h(p/2)})"`);w(-16-C.height/2,0,0,0);let y=Z+6+z.height+10,E=new Map;for(let le of e.nodes)E.set(le.id,{x:I(le.x),y:N(le.y),node:le});let x="",T=new Map;for(let le of e.pipelines){T.set(le.nodeId,new Set(le.componentIds));let we=[];for(let ue of le.componentIds){let xe=E.get(ue);xe&&we.push(xe)}if(we.length===0)continue;we.sort((ue,xe)=>ue.x-xe.x);let pe=we[0].x,ge=we[we.length-1].x,Ae=we[0].y,Se=Ae-2*qt,oe=E.get(le.nodeId);oe&&(oe.x=(pe+ge)/2,oe.y=Se-Ms/6),w(pe-kh,Se,ge+kh,Se+4*qt),x+=`<g class="pele-wardley-pipeline" data-id="${Oe(le.nodeId)}"><rect x="${h(pe-kh)}" y="${h(Se)}" width="${h(ge-pe+2*kh)}" height="${h(4*qt)}" fill="var(--_s)" stroke="var(--_b)"${st}/>`+(we.length>1?`<path d="M${h(pe)},${h(Ae)}H${h(ge)}" stroke="${oa}" stroke-dasharray="4 4"/>`:"")+"</g>"}let A=new Map,M=(le,we,pe)=>{let ge=le.node;if(ge.className==="anchor"){let Ae=A.get(ge);return Ae||A.set(ge,Ae=L(ge.label,n,s?Math.max(64,a/2):4e3,1)),1/Math.hypot(we/(Ae.width/2+5),pe/(n*.8))}return ge.isPipelineParent?Ms/Math.SQRT2:ge.sourceStrategy?2*qt:qt},Y=new Map,B=(le,we,pe)=>{Math.abs(we)<.25||Math.abs(pe)<.25||Y.set(le,(Y.get(le)??0)|(we>0?pe<0?1:2:pe<0?4:8))},q="";for(let le of e.links){let we=E.get(le.source),pe=E.get(le.target);if(!we||!pe||we===pe||T.get(le.target)?.has(le.source))continue;let ge=pe.x-we.x,Ae=pe.y-we.y,Se=Math.hypot(ge,Ae);if(Se<.01)continue;let oe=ge/Se,ue=Ae/Se,xe=M(we,oe,ue),Ie=M(pe,oe,ue);if(xe+Ie>=Se)continue;B(we,oe,ue),B(pe,-oe,-ue);let Le=we.x+oe*xe,We=we.y+ue*xe,he=pe.x-oe*Ie,ke=pe.y-ue*Ie,Ce="";(le.flow==="forward"||le.flow==="bidirectional")&&(Ce+=bt("arrow_point",he,ke,oe,ue,oa),he-=oe*gt("arrow_point"),ke-=ue*gt("arrow_point")),(le.flow==="backward"||le.flow==="bidirectional")&&(Ce+=bt("arrow_point",Le,We,-oe,-ue,oa),Le+=oe*gt("arrow_point"),We+=ue*gt("arrow_point"));let be="";if(le.label){let Me=L(le.label,o+1,200),Ne=oe>=0?1:-1,Be=ue*Ne,Pe=-oe*Ne,V=5+Math.abs(Be)*Me.width/2+Math.abs(Pe)*Me.height/2;be=v(Me,(we.x+pe.x)/2+Be*V,(we.y+pe.y)/2+Pe*V,` class="pele-edge-label" font-size="${o+1}" fill="var(--_m)"`)}q+=`<g class="pele-edge${le.dashed?" pele-wardley-dashed":""}" data-id="${Oe(le.source)}-${Oe(le.target)}"><path d="M${h(Le)},${h(We)}L${h(he)},${h(ke)}" stroke="${oa}"${le.dashed?' stroke-dasharray="6 6"':""}/>`+Ce+be+"</g>"}let D="";for(let le of e.trends){let we=E.get(le.nodeId);if(!we)continue;let pe=I(le.targetX),ge=N(le.targetY),Ae=pe-we.x,Se=ge-we.y,oe=Math.hypot(Ae,Se),ue="",xe=oe>0?M(we,Ae/oe,Se/oe):0;if(oe>xe+qt+4){let Ie=Ae/oe,Le=Se/oe,We=pe-Ie*(qt+2),he=ge-Le*(qt+2);ue=`<path d="M${h(we.x+Ie*xe)},${h(we.y+Le*xe)}L${h(We-Ie*gt("arrow_point"))},${h(he-Le*gt("arrow_point"))}" stroke="${Wp}" stroke-dasharray="4 4"/>`+bt("arrow_point",We,he,Ie,Le,Wp)}w(pe-qt,ge-qt,pe+qt,ge+qt),D+=`<g class="pele-wardley-trend" data-id="${Oe(le.nodeId)}">${ue}<circle cx="${h(pe)}" cy="${h(ge)}" r="${qt}" fill="var(--_bg)" stroke="${Wp}"/></g>`}let R="",P=1.2*qt,G=.7*qt;for(let le of E.values()){let we=le.node,{x:pe,y:ge}=le,Ae=we.className==="anchor",Se=we.sourceStrategy,oe="";if(Se){let Le=Se==="outsource"?"var(--_m)":Se==="buy"?"var(--_a)":Se==="build"?"var(--_s)":"var(--_bg)";oe+=`<circle class="pele-wardley-${Se}" cx="${h(pe)}" cy="${h(ge)}" r="${2*qt}" fill="${Le}" stroke="${oa}"/>`}if(Se==="market"){let Le=P*Math.cos(Math.PI/6),We=ge+P*Math.sin(Math.PI/6);oe+=`<path d="M${h(pe)},${h(ge-P)}L${h(pe-Le)},${h(We)}H${h(pe+Le)}Z" fill="none" stroke="${oa}"/>`;for(let[he,ke]of[[pe,ge-P],[pe-Le,We],[pe+Le,We]])oe+=`<circle cx="${h(he)}" cy="${h(ke)}" r="${h(G)}" fill="var(--_bg)" stroke="${oa}"/>`}else we.isPipelineParent?oe+=`<rect x="${h(pe-Ms/2)}" y="${h(ge-Ms/2)}" width="${Ms}" height="${Ms}" fill="var(--_bg)" stroke="${oa}"/>`:Ae||(oe+=`<circle cx="${h(pe)}" cy="${h(ge)}" r="${qt}" fill="var(--_bg)" stroke="${oa}"/>`);if(we.inertia===!0){let Le=(we.isPipelineParent?Ms/2:qt)+10+(Se?qt+4:0);oe+=`<rect class="pele-wardley-inertia" x="${h(pe+Le)}" y="${h(ge-qt)}" width="4" height="${2*qt}" fill="${oa}"/>`}let ue=we.labelOffsetX===void 0?void 0:xn(we.labelOffsetX,-5e3,5e3),xe=we.labelOffsetY===void 0?void 0:xn(we.labelOffsetY,-5e3,5e3),Ie;if(Ae){let Le=A.get(we)??L(we.label,n,s?Math.max(64,a/2):4e3,1);Ie=v(Le,pe+(ue??0),ge+(xe??-3),` class="pele-label" font-size="${n}" font-weight="var(--_hw)"`)}else{let Le=L(we.label,n),We=` class="pele-label" font-size="${n}"`,he=l6+(Se?10:0);if(ue!==void 0||xe!==void 0)Ie=k(Le,pe+(ue??he),ge+(xe??-he),We);else if(we.inPipeline)Ie=v(Le,pe,ge+2*qt+4+Le.height/2,We);else{let ke=Y.get(le)??0,Ce=ke&1?ke&2?ke&4?ke&8?1:8:4:2:1,be=Ce===1||Ce===2,Me=Ce===1||Ce===4;Ie=k(Le,be?pe+he:pe-he-Le.width,Me?ge-he:ge+he+n*.75,We)}}w(pe-2*qt,ge-2*qt,pe+2*qt+20,ge+2*qt),R+=`<g class="pele-node pele-wardley-${Ae?"anchor":we.isPipelineParent?"pipeline-parent":we.inPipeline?"pipeline-component":"component"}" data-id="${Oe(we.id)}">${oe}${Ie}</g>`}let X="";for(let le of e.annotations){let we=L(String(le.number),o,4e3,1),pe="";for(let ge of le.coordinates){let Ae=I(ge.x),Se=N(ge.y),oe=Math.max(10,we.width/2+4);w(Ae-oe,Se-oe,Ae+oe,Se+oe),pe+=`<circle cx="${h(Ae)}" cy="${h(Se)}" r="${h(oe)}" fill="var(--_bg)" stroke="${oa}"/>`+Re(we,Ae,Se,` font-size="${o}" font-weight="var(--_hw)"`)}X+=`<g class="pele-wardley-annotation" data-id="${Oe(String(le.number))}">${pe}</g>`}let Q=e.annotations.filter(le=>le.text).sort((le,we)=>le.number-we.number);if(Q.length>0){let le=Q.map(xe=>L(`${xe.number}. ${xe.text}`,n,s?Math.max(80,a-20):320)),we=0,pe=0;for(let xe of le)we=Math.max(we,xe.width),pe+=xe.height;we+=20,pe+=14;let ge=e.annotationsBox,Ae=ge?xn(I(ge.x),0,Math.max(0,a-we)):0,Se=ge?xn(N(ge.y),0,Math.max(0,p-pe)):y;w(Ae,Se,Ae+we,Se+pe);let oe="",ue=Se+7;for(let xe of le)oe+=Rw(xe,Ae+10,ue+xe.lineHeight/2+n*.35,` font-size="${n}"`),ue+=xe.height;X+=`<g class="pele-wardley-annotations"><rect x="${h(Ae)}" y="${h(Se)}" width="${h(we)}" height="${h(pe)}" fill="var(--_bg)" stroke="var(--_b)"${st}/>${oe}</g>`}let J="";for(let le of e.notes)J+=k(L(le.text,n,Math.min(360,a*.6),1),I(le.x),N(le.y),` class="pele-wardley-note" font-size="${n}" font-weight="var(--_hw)"`);let F="",K=(le,we,pe,ge)=>{let Ae=I(we),Se=N(pe),oe=o6/2,ue=ge?Ae+Wl:Ae,xe=ge?Ae:Ae+Wl,Ie=ge?Ae+Wl-Nw:Ae+Nw,Le=`M${h(xe)},${h(Se-oe)}H${h(Ie)}V${h(Se-oe-8)}L${h(ue)},${h(Se)}L${h(Ie)},${h(Se+oe+8)}V${h(Se+oe)}H${h(xe)}Z`;w(Ae,Se-oe-8,Ae+Wl,Se+oe+8),F+=`<g class="pele-wardley-${ge?"accelerator":"deaccelerator"}" data-id="${Oe(le)}"><path d="${Le}" fill="var(--_s)" stroke="${oa}"/>`+v(L(le,o+1,160,1),Ae+Wl/2,Se+oe+8+12,` font-size="${o+1}" font-weight="var(--_hw)"`)+"</g>"};for(let le of e.accelerators)K(le.name,le.x,le.y,!0);for(let le of e.deaccelerators)K(le.name,le.x,le.y,!1);let re=ze(e.title,!1,c,l,s?Math.max(80,a):4e3,1),ne=re.height>0?re.height+12:0,de=Math.min(g,a/2-re.width/2),ie=Math.max(m,a/2+re.width/2),se=f-de,ee=f+ne-u,te=Math.ceil(ie-de+2*f),fe=Math.ceil(b-u+ne+2*f),ye=Re(re,se+a/2,f+re.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${h(se)},${h(ee)})"><g class="pele-wardley-frame" fill="none">${_}</g>`+j+$+x+(q?`<g class="pele-edges" fill="none">${q}</g>`:"")+(D?`<g class="pele-wardley-trends" fill="none">${D}</g>`:"")+R+X+J+F+"</g>";return{svg:Je("wardley",te,fe,l,r,e,ye),width:te,height:fe,links:[]}}var J5,Cw,_w,Qr,Iw,s6,n6,qt,Ms,l6,kh,Wl,o6,Nw,Wp,oa,Dw,Ow=Ve(()=>{ph();zt();Xr();pr();ut();wt();J5=class{constructor(){ce(this,"nodes",new Map);ce(this,"labels");ce(this,"links",[]);ce(this,"trends",new Map);ce(this,"pipelines",new Map);ce(this,"annotations",[]);ce(this,"notes",[]);ce(this,"accelerators",[]);ce(this,"deaccelerators",[]);ce(this,"annotationsBox");ce(this,"axes",{});ce(this,"size")}addNode(e){let t=this.nodes.get(e.id)??{id:e.id,label:e.label};this.nodes.set(e.id,{...t,...e,className:e.className??t.className,labelOffsetX:e.labelOffsetX??t.labelOffsetX,labelOffsetY:e.labelOffsetY??t.labelOffsetY}),this.labels=void 0}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});let t=this.nodes.get(e);t&&(t.isPipelineParent=!0)}addPipelineComponent(e,t){this.pipelines.get(e)?.componentIds.push(t);let r=this.nodes.get(t);r&&(r.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,t){this.annotationsBox={x:e,y:t}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,t){this.size={width:e,height:t}}getNode(e){return this.nodes.get(e)}resolveNodeId(e){if(this.nodes.has(e))return e;if(!this.labels){this.labels=new Map;for(let[t,r]of this.nodes)this.labels.has(r.label)||this.labels.set(r.label,t)}return this.labels.get(e)??e}build(){let e=[];for(let t of this.nodes.values()){if(typeof t.x!="number"||typeof t.y!="number")throw new je(`Node "${t.label}" is missing coordinates`,"semantic",{type:"wardley"});e.push(t)}return{nodes:e,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}}};Cw={name:"ARROW",pattern:/->/y,first:"-"},_w={name:"LINK_ARROW",pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:"->+"},Qr=(e,t)=>({name:e,pattern:new RegExp(t,"y"),first:t[0]}),Iw=[{name:"[",pattern:"["},{name:",",pattern:","},{name:"]",pattern:"]"},{name:"@",pattern:"@"},{name:"/",pattern:"/"},{name:"(",pattern:"("},{name:")",pattern:")"},{name:"-",pattern:"-",longer:[Cw,_w,jt]},{name:"{",pattern:"{"},{name:"}",pattern:"}"},{name:"WARDLEY_NUMBER",pattern:/[0-9]+\.[0-9]+/y,first:"0123456789",scanner:a6},Cw,{name:"LINK_PORT",pattern:/\+<>|\+>|\+</y,first:"+"},_w,{name:"LINK_LABEL",pattern:/;[^\n\r]+/y,first:";"},{name:"STRATEGY",pattern:/build|buy|outsource|market/y,first:"bom"},Qr("KW_WARDLEY","wardley-beta"),Qr("KW_SIZE","size"),Qr("KW_EVOLUTION","evolution"),Qr("KW_ANCHOR","anchor"),Qr("KW_COMPONENT","component"),Qr("KW_LABEL","label"),Qr("KW_INERTIA","inertia"),Qr("KW_EVOLVE","evolve"),Qr("KW_PIPELINE","pipeline"),Qr("KW_NOTE","note"),Qr("KW_ANNOTATIONS","annotations"),Qr("KW_ANNOTATION","annotation"),Qr("KW_ACCELERATOR","accelerator"),Qr("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:" "},yn(),rr,ar,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y,first:"0123456789"},Vr,{name:"ID",pattern:/[\w]([-\w]*\w)?/y,first:"_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},Rr,Lr,jt,nr,lr];s6=["Genesis","Custom Built","Product","Commodity"],n6=48,qt=6,Ms=10,l6=8,kh=15,Wl=60,o6=30,Nw=20,Wp="var(--_c)",oa="var(--_l)";Dw={type:"wardley",section:"wardley-beta",parse:(e,t,r)=>r6(i6(e),r),render:h6}});var Pw={};Ct(Pw,{wardley:()=>Dw});var zw=Ve(()=>{Ow()});function u6(e){return e==="ui"||e==="processor"?"trigger":e==="event"?"stream":"state"}function Bp(e){let t=e.indexOf("{"),r=e.lastIndexOf("}"),a=(t!==-1&&r>t?e.slice(t+1,r):t===-1&&e.length>=2?e.slice(1,-1):"").replace(/\r/g,"").split(`
|
|
130
|
+
`);for(;a.length>0&&a[0].trim()==="";)a.shift();for(;a.length>0&&a[a.length-1].trim()==="";)a.pop();let i=1/0;for(let s of a)s.trim()!==""&&(i=Math.min(i,s.length-s.trimStart().length));return a.map(s=>s.slice(Math.min(i,s.length)).trimEnd()).join(`
|
|
131
|
+
`)}function g6(e,t){let r=new Set;for(let p of e.frames){if(r.has(p.name)){let d=Bn(e.$source,p.$offset).line;throw new je(`Duplicate event modeling frame ID "${p.name}" on line ${d}`,"semantic",{type:"eventmodeling",line:d})}r.add(p.name)}let a=new Map;for(let p of e.dataEntities)a.has(p.name)||a.set(p.name,p.dataBlockValue);let i=new Map,s=new Map,l=(p,d)=>{let g=u6(p),u=d===void 0?g:`${g} ${d}`,m=i.get(u);if(!m){let[b,w,v]=p6.get(g),k=b;d!==void 0&&(k=s.get(g)??b+1,s.set(g,k+1)),m={index:k,label:d===void 0?w:v+d,group:g,namespace:d},i.set(u,m)}return m},n=[],o=new Map,c=[];e.frames.forEach((p,d)=>{let g=p.entityIdentifier.split("."),u=g.length===2?g[0]:void 0,m=f6.get(p.modelEntityType)??"event",b=p.dataInlineValue===void 0?void 0:Bp(p.dataInlineValue);if(p.dataReference){let v=a.get(p.dataReference.$refText);v!==void 0&&(b=Bp(v))}let w={id:p.name,kind:m,entity:p.entityIdentifier,name:g.length===2?g[1]:p.entityIdentifier,namespace:u,reset:p.$type==="EmResetFrame",lane:l(m,u),data:b,dataType:p.dataType};if(n.push(w),o.set(w.id,w),p.sourceFrames.length>0){let v=new Set(p.sourceFrames.map(k=>k.$refText));for(let k of n)v.has(k.id)&&c.push({source:k,target:w})}else if(d>0&&!w.reset){for(let v=d-1;v>=0;v--)if(n[v].lane!==w.lane){c.push({source:n[v],target:w});break}}});let f=p=>p.map(d=>d.entityIdentifier.$refText);return{type:"eventmodeling",title:e.title&&Vt(e.title)||t,accTitle:e.accTitle?Xt(e.accTitle).replace(/^\s+/g,""):void 0,accDescr:e.accDescr?Kt(e.accDescr).replace(/\n\s+/g,`
|
|
132
|
+
`):void 0,boxes:n,lanes:[...i.values()].sort((p,d)=>p.index-d.index),relations:c,notes:e.noteEntities.map(p=>({frame:p.sourceFrame.$refText,text:Bp(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)}}function w6(e){let t=new Zt(Gt(e,qp,"eventmodeling"),qp,"eventmodeling"),r={$type:"EventModel",modelEntities:[],frames:[],dataEntities:[],noteEntities:[],gwtEntities:[],$source:e},a=o=>t.kinds[t.i]===o,i=(o,c)=>o.has(t.kinds[t.i])?t.take():t.fail(c),s=()=>{let o=t.expect(Ot.id);for(;t.accept(Ot.dot);)o+="."+t.expect(Ot.id);return o},l=()=>{if(!t.accept(Ot.tick))return;let o=i(x6,"a data type");return t.expect(Ot.tick),o},n=()=>{let o=[];do i(Hp,"an entity type"),o.push({$type:"EmGwtStatement",entityIdentifier:{$refText:t.expect(Ot.id)}});while(Hp.has(t.kinds[t.i]));return o};for(t.expect(Ot.keyword);!a(-1);){let o=t.kinds[t.i];if(o===Ot.accDescr)r.accDescr=t.take();else if(o===Ot.accTitle)r.accTitle=t.take();else if(o===Ot.title)r.title=t.take();else if(o===Ot.entity)t.i++,r.modelEntities.push({$type:"EmModelEntity",name:s()});else if(Fw.has(o)||y6.has(o)){let c={$type:Fw.has(o)?"EmTimeFrame":"EmResetFrame",name:"",modelEntityType:"",entityIdentifier:"",sourceFrames:[],$offset:t.tokens.starts[t.i]};for(t.i++,c.name=t.expect(Ot.frameId),c.modelEntityType=i(Hp,"an entity type"),c.entityIdentifier=s();t.accept(Ot.arrow);)c.sourceFrames.push({$refText:t.expect(Ot.frameId)});if(t.accept(Ot.open)&&(c.dataReference={$refText:t.expect(Ot.id)},t.expect(Ot.close)),a(Ot.tick)||a(Ot.inline)){let f=l();f!==void 0&&(c.dataType=f),c.dataInlineValue=t.expect(Ot.inline)}r.frames.push(c)}else if(o===Ot.data){t.i++;let c={$type:"EmDataEntity",name:t.expect(Ot.id),dataBlockValue:""},f=l();f!==void 0&&(c.dataType=f),c.dataBlockValue=t.expect(Ot.block),r.dataEntities.push(c)}else if(o===Ot.note){t.i++;let c={$type:"EmNoteEntity",sourceFrame:{$refText:t.expect(Ot.frameId)},dataBlockValue:""},f=l();f!==void 0&&(c.dataType=f),c.dataBlockValue=t.expect(Ot.block),r.noteEntities.push(c)}else if(o===Ot.gwt){t.i++;let c={$type:"EmGwt",sourceFrame:{$refText:t.expect(Ot.frameId)},givenStatements:[],whenStatements:[],thenStatements:[]};t.expect(Ot.given),c.givenStatements=n(),t.accept(Ot.when)&&(c.whenStatements=n()),t.expect(Ot.then),c.thenStatements=n(),r.gwtEntities.push(c)}else t.fail("a frame, an entity, a data block, a note, or a specification")}return r}function Yp(e,t){let r=[];for(let a of At(e).split(`
|
|
133
|
+
`)){if(a.length<=t){r.push(a);continue}for(let i=0;i<a.length;i+=t)r.push(a.slice(i,i+t))}return r}function vh(e,t,r,a,i){let s="";for(let l=0;l<e.length;l++)e[l]!==""&&(s+=`<tspan x="${h(t)}" y="${h(r+l*a)}">${Xe(e[l])}</tspan>`);return s===""?"":`<text${i} xml:space="preserve">${s}</text>`}function M6(e,t,r){return Bt(r,a=>A6(e,t,r,a))}function A6(e,t,r,a){if(a)return S6(e,r);let i=r.fontSize??16,s=Math.round(i*.875),l=Math.round(i*.8125),n=Math.round(i*.75),o=Math.round(n*1.4),c=Math.round(l*1.5),f=r.measurer??et(r.fontFamily,r.fontFamilyMono),p=r.padding??8,d=(A,M,Y)=>{let B=0;for(let q of A)B=Math.max(B,f.width(q,M,Y));return B},g=new Map,u=0;for(let A of e.lanes){let M=ze(A.label,!1,f,l,4e3,1);u=Math.max(u,M.width),g.set(A,{lane:A,label:M,right:-1/0,y:0,h:0})}u+=2*Ah;let m=[],b=new Map,w;for(let A of e.boxes){let M=g.get(A.lane),Y=ze(A.name,!1,f,s,4e3,1),B=A.data?Yp(A.data,k6):[],q=Math.max(b6,Math.max(Y.width,d(B,n,4))+2*vr),D=2*ca+Y.height+(B.length>0?6+B.length*o:0),R=0;if(w){let G=w.x+Math.max(w.w/2,w.w-$6);R=w.box.lane===A.lane?M.right+Ww:Math.max(G,M.right+Ww)}let P={box:A,name:Y,data:B,x:R,y:0,w:q,h:D};M.right=R+q,M.h=Math.max(M.h,D),m.push(P),b.set(A,P),w=P}let v=0;for(let A of m)v=Math.max(v,A.x+A.w);let k=u+v+Ah,L=ze(e.title,!1,f,i,4e3,1),I=L.height>0?L.height+12:0,N=p,O=p+I,W=O,U="";for(let A of g.values())A.y=W,A.h+=2*Ah,U+=`<g class="pele-cluster pele-em-lane" data-id="${Oe(A.lane.label)}"><rect x="${h(N)}" y="${h(W)}" width="${h(k)}" height="${h(A.h)}" fill="var(--_s)"${st}/>`+Re(A.label,N+Ah+A.label.width/2,W+A.h/2,` class="pele-cluster-label" font-size="${l}" font-weight="var(--_hw)" fill="var(--_m)"`)+"</g>",W+=A.h+Bw;let _=g.size>0?W-Bw:O,j="";for(let A of m){let M=g.get(A.box.lane);A.x+=N+u,A.y=M.y+(M.h-A.h)/2;let Y=Uw.get(A.box.kind),B=`x="${h(A.x)}" y="${h(A.y)}" width="${h(A.w)}" height="${h(A.h)}"`,q=Y===void 0?`<rect ${B} fill="var(--_bg)" stroke="var(--_b)"${st}/>`:`<rect ${B} fill="var(--_bg)"${st}/><rect ${B} fill="${dt(Y)}" fill-opacity="0.22" stroke="${dt(Y)}"${st}/>`,D=A.y+ca+A.name.height/2,R=Re(A.name,A.x+A.w/2,D,` class="pele-label" font-size="${s}" font-weight="var(--_hw)"`)+vh(A.data,A.x+vr,A.y+ca+A.name.height+6+o/2+n*.35,o,` class="pele-em-data" font-family="${Un}" font-size="${n}"`);j+=`<g class="pele-node pele-em-${A.box.kind}${A.box.reset?" pele-em-reset":""}" data-id="${Oe(A.box.id)}">${q}${R}</g>`}let Z="",H=gt("arrow_point");for(let A of e.relations){let M=b.get(A.source),Y=b.get(A.target);if(!M||!Y||M===Y)continue;let B,q;if(M.box.lane===Y.box.lane){let D=Y.x>=M.x,R=D?M.x+M.w:M.x,P=D?Y.x:Y.x+Y.w,G=M.y+M.h/2,X=Y.y+Y.h/2,Q=P>=R?1:-1;B=`M${h(R)},${h(G)}L${h(P-Q*H)},${h(X)}`,q=bt("arrow_point",P,X,Q,0,"var(--_l)")}else{let D=Y.y>M.y,R=Math.max(M.x,Y.x),P=Math.min(M.x+M.w,Y.x+Y.w),G=de=>Math.min(24,de/4),X=P-R>=16?(R+P)/2:Y.x>M.x?M.x+M.w-G(M.w):M.x+G(M.w),Q=P-R>=16?X:Y.x>M.x?Y.x+G(Y.w):Y.x+Y.w-G(Y.w),J=D?M.y+M.h:M.y,F=D?Y.y:Y.y+Y.h,K=D?1:-1,re=F-K*H,ne=(J+re)/2;B=X===Q?`M${h(X)},${h(J)}V${h(re)}`:`M${h(X)},${h(J)}C${h(X)},${h(ne)} ${h(Q)},${h(ne)} ${h(Q)},${h(re)}`,q=bt("arrow_point",Q,F,0,K,"var(--_l)")}Z+=`<g class="pele-edge" data-id="${Oe(A.source.id)}-${Oe(A.target.id)}"><path d="${B}" fill="none" stroke="var(--_l)"/>${q}</g>`}let z=new Map;for(let A of e.boxes)z.set(A.id,A.name);let C="",S=0,$=(A,M,Y,B)=>{let q=ze(`${M} \xB7 ${Y}${z.has(Y)?" "+z.get(Y):""}`,!1,f,l,4e3,1),D=Math.max(q.width,d(B,l,0))+2*vr,R=2*ca+q.height+B.length*c,P=_+(C===""&&g.size===0?0:qw);C+=`<g class="pele-em-${A}" data-id="${Oe(Y)}"><rect x="${h(N)}" y="${h(P)}" width="${h(D)}" height="${h(R)}" fill="var(--_bg)" stroke="var(--_b)"${st}/>`+Re(q,N+vr+q.width/2,P+ca+q.height/2,` font-size="${l}" font-weight="var(--_hw)"`)+vh(B,N+vr,P+ca+q.height+c/2+l*.35,c,` font-size="${l}"`)+"</g>",_=P+R,S=Math.max(S,D)};for(let A of e.notes)$("note","Note",A.frame,Yp(A.text,Hw));for(let A of e.specifications){let M=[`Given ${A.given.join(", ")}`];A.when.length>0&&M.push(`When ${A.when.join(", ")}`),M.push(`Then ${A.then.join(", ")}`),$("specification","Given / When / Then",A.frame,M.flatMap(Y=>Yp(Y,Hw)))}let y=Math.max(g.size>0?k:0,S,L.width),E=Math.ceil(y+2*p),x=Math.ceil(_+p),T=Re(L,E/2,p+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+U+Z+j+C;return{svg:Je("eventmodeling",E,x,i,r,e,T),width:E,height:x,links:[]}}function S6(e,t){let r=t.fontSize??16,a=Math.round(r*.875),i=Math.round(r*.75),s=t.padding??8,l=t.measurer??et(t.fontFamily,t.fontFamilyMono),n=Math.max(160,(t.maxWidth??320)-2*s),o=new Map(e.boxes.map((z,C)=>[z,C])),c=new Map,f=new Set;for(let z of e.relations){let C=o.get(z.source),S=o.get(z.target);if(C===void 0||S===void 0||C===S)continue;if(Math.abs(C-S)<2){f.add(e.boxes[Math.max(C,S)]);continue}let $=c.get(z.target);$?($[0]=Math.min($[0],C),$[1]=Math.max($[1],C)):c.set(z.target,[Math.min(C,S),Math.max(C,S)])}let p=new Map,d=[];for(let[z,[C,S]]of[...c].sort(($,y)=>$[1][0]-y[1][0])){let $=d.findIndex(y=>y<C);$<0&&($=d.length),d[$]=S,p.set(z,$)}let g=24+Yw*Math.max(0,d.length-1),u=Math.max(v6,n-g),m=u-2*vr,b=ze(e.title,!1,l,r,n,1),w=s+(b.height?b.height+12:0),v=s+b.height,k=Math.max(b.width,u+g),L="",I="",N="",O=new Map,W=(z,C,S=0)=>ds(At(z),l,C,m,S);e.boxes.forEach((z,C)=>{let S=f.has(z)?m-E6:m,$=fs(ze(z.lane.label,!1,l,a,S,1),l,S),y=ze(z.name,!1,l,a,m-36,1),E=z.data?W(z.data,i,4):void 0,x=Math.max(u,$.width+2*vr,y.width+2*vr+36,(E?.width??0)+2*vr),T=$.height+12,A=2*ca+y.height+(E?E.height+6:0),M=Uw.get(z.kind),Y=w+T,B=`x="${h(s)}" y="${h(Y)}" width="${h(x)}" height="${h(A)}"`;L+=`<g class="pele-cluster pele-em-lane" data-id="${Oe(z.lane.label)}">`+yi($,s+vr,w,` class="pele-cluster-label" font-size="${a}" font-weight="var(--_hw)" fill="var(--_m)"`)+`<g class="pele-node pele-em-${z.kind}${z.reset?" pele-em-reset":""}" data-id="${Oe(z.id)}"><rect ${B} fill="var(--_bg)" stroke="var(--_b)"${st}/>`+(M===void 0?"":`<rect ${B} fill="${dt(M)}" fill-opacity="0.22" stroke="${dt(M)}"${st}/>`)+Re(y,s+vr+y.width/2,Y+ca+y.height/2,` class="pele-label" font-size="${a}" font-weight="var(--_hw)"`)+`<text class="pele-em-frame" x="${h(s+x-vr)}" y="${h(Y+ca+a)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${Xe(z.id)}</text>`+(E?vh(E.lines.map(q=>q.map(D=>D.text).join("")),s+vr,Y+ca+y.height+6+E.lineHeight/2+i*.35,E.lineHeight,` class="pele-em-data" font-family="${Un}" font-size="${i}"`):"")+"</g></g>",O.set(z,{y:Y,h:A,w:x,index:C,lane:$.width}),k=Math.max(k,x+g),v=Y+A,w=v+28});for(let z of e.relations){let C=O.get(z.source),S=O.get(z.target);if(!C||!S||C===S)continue;let $=S.y>C.y,y=$?1:-1,E=$?C.y+C.h:C.y,x=$?S.y:S.y+S.h,T,A;if(Math.abs(C.index-S.index)===1){let M=s+Math.max(Math.min(C.w,S.w)/2,vr+($?S:C).lane+16);T=`M${h(M)},${h(E)}V${h(x-y*gt("arrow_point"))}`,A=bt("arrow_point",M,x,0,y,"var(--_l)")}else{let M=s+k-g+12+Yw*(p.get(z.target)??0),Y=C.y+C.h/2-5,B=S.y+S.h/2+5;T=`M${h(s+C.w)},${h(Y)}H${h(M)}V${h(B)}H${h(s+S.w+gt("arrow_point"))}`,A=bt("arrow_point",s+S.w,B,-1,0,"var(--_l)")}I+=`<g class="pele-edge" data-id="${Oe(z.source.id)}-${Oe(z.target.id)}"><path d="${T}" fill="none" stroke="var(--_l)"/>${A}</g>`}let U=new Map(e.boxes.map(z=>[z.id,z.name])),_=(z,C,S,$)=>{let y=ze(`${C} \xB7 ${S}${U.has(S)?" "+U.get(S):""}`,!1,l,a,m,1),E=W($,a),x=Math.max(u,y.width+2*vr,E.width+2*vr),T=2*ca+y.height+E.height;N+=`<g class="pele-em-${z}" data-id="${Oe(S)}"><rect x="${h(s)}" y="${h(w)}" width="${h(x)}" height="${h(T)}" fill="var(--_bg)" stroke="var(--_b)"${st}/>`+Re(y,s+vr+y.width/2,w+ca+y.height/2,` font-size="${a}" font-weight="var(--_hw)"`)+vh(E.lines.map(A=>A.map(M=>M.text).join("")),s+vr,w+ca+y.height+E.lineHeight/2+a*.35,E.lineHeight,` font-size="${a}"`)+"</g>",v=w+T,w=v+qw,k=Math.max(k,x)};for(let z of e.notes)_("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(", ")}`),_("specification","Given / When / Then",z.frame,C.join(`
|
|
134
|
+
`))}let j=Math.ceil(k+2*s),Z=Math.ceil(v+s),H=Re(b,j/2,s+b.height/2,' class="pele-title" font-weight="var(--_tw)"')+I+L+N;return{svg:Je("eventmodeling",j,Z,r,t,e,H),width:j,height:Z,links:[]}}var f6,p6,Up,wn,Bl,m6,qp,hr,Eh,Ot,Fw,y6,Hp,x6,Uw,vr,ca,b6,Ww,$6,Ah,Bw,k6,Hw,qw,Yw,v6,E6,Gw,jw=Ve(()=>{ph();ps();zt();Xr();pr();ut();wt();f6=new Map([["ui","ui"],["pcr","processor"],["processor","processor"],["rmo","readmodel"],["readmodel","readmodel"],["cmd","command"],["command","command"],["evt","event"],["event","event"]]),p6=new Map([["trigger",[0,"UI/Automation","UI/A: "]],["state",[100,"Command/Read Model","C/RM: "]],["stream",[200,"Events","Stream: "]]]);Up={name:"EM_ID",pattern:/[_a-zA-Z][\w_]*/y},wn=e=>({name:e,pattern:e,longer:[Up]}),Bl=e=>({name:e,pattern:e}),m6=["resetframe","readmodel","processor","timeframe","command","entity","event","jsobj","figma","given","json","salt","html","text","data","note","when","then","rmo","cmd","evt","pcr","uri"],qp=[{...or("eventmodeling"),longer:[Up]},...m6.map(wn),Bl("->>"),wn("gwt"),wn("ui"),wn("md"),wn("tf"),Bl("[["),Bl("]]"),wn("rf"),Bl("`"),Bl("."),Up,{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},yn("EM_ACC_DESCR"),{...rr,name:"EM_ACC_TITLE"},{...ar,name:"EM_TITLE"},{name:"EM_WS",pattern:/\s+/y,hidden:!0},{...jt,name:"EM_YAML"},{...nr,name:"EM_DIRECTIVE"},{...lr,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}],hr=e=>qp.findIndex(t=>t.name===e),Eh=e=>new Set(e.map(hr)),Ot={keyword:0,arrow:hr("->>"),open:hr("[["),close:hr("]]"),tick:hr("`"),dot:hr("."),id:hr("EM_ID"),frameId:hr("EM_FID"),inline:hr("EM_DATA_INLINE"),block:hr("EM_DATA_BLOCK"),accDescr:hr("EM_ACC_DESCR"),accTitle:hr("EM_ACC_TITLE"),title:hr("EM_TITLE"),entity:hr("entity"),data:hr("data"),note:hr("note"),gwt:hr("gwt"),given:hr("given"),when:hr("when"),then:hr("then")},Fw=Eh(["tf","timeframe"]),y6=Eh(["rf","resetframe"]),Hp=Eh(["rmo","readmodel","ui","cmd","command","evt","event","pcr","processor"]),x6=Eh(["json","jsobj","figma","salt","uri","md","html","text"]);Uw=new Map([["command",0],["event",1],["readmodel",2],["processor",6]]),vr=12,ca=10,b6=96,Ww=16,$6=80,Ah=12,Bw=8,k6=48,Hw=80,qw=8;Yw=8,v6=120,E6=20;Gw={type:"eventmodeling",keepComments:!0,parse:(e,t,r)=>g6(w6(e),r),render:M6}});var Vw={};Ct(Vw,{eventmodeling:()=>Gw});var Xw=Ve(()=>{jw()});function Sh(e){return e<128&&(Yi[e]&Xl)!==0}function Gp(e,t,r){for(let a=0;a<r.length;a++)if((e.charCodeAt(t+a)|32)!==r.charCodeAt(a))return!1;return!0}function T6(e,t,r){switch(r){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:Gp(e,t,"extend")?18:0;case 69:return Gp(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 Gp(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 Kl(e,t){let r=1,a=0;for(let i=0;i<t;i++){let s=e.charCodeAt(i);s!==10&&s!==13||(s===13&&i+1<t&&e.charCodeAt(i+1)===10&&i++,r++,a=i+1)}return[r,t-a+1]}function C6(e,t,r){let[a,i]=Kl(e,t);return`line ${a}, column ${i} [${t},${r})`}function ub(e,t,r){for(let a=t+1;a<e.length;a++){let i=e.charCodeAt(a);if(i===r)return a+1;if(i===10||i===13)return-1}return-1}function _6(e,t){let r=e.charCodeAt(t);return r!==34&&r!==39?!0:r===34&&e.charCodeAt(t+1)===96||ub(e,t,r)!==-1}function Zw(e,t,r){let[a,i]=Kl(e,t);return new je(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters. at line ${a}, column ${i} [${t},${t+r})`,"syntax",{type:"usecase",line:a,column:i})}function I6(e){let t=[],r=[],a=[],i=e.length,s=0,l=!0,n=!1;for(;s<i;){let o=e.charCodeAt(s);if(o===32||o===9){s++;continue}let c,f=s+1,p=!1;if(o<128&&Yi[o]&Xl){if(c=0,o===97&&l&&e.startsWith("acc",s)){let d=e.startsWith("Descr",s+3);if(d||e.startsWith("Title",s+3)){let g=s+8;for(;pa(e.charCodeAt(g));)g++;let u=e.charCodeAt(g);if(u===58)for(c=d?42:41,f=g+1;f<i&&e.charCodeAt(f)!==10&&e.charCodeAt(f)!==13;)f++;else if(u===123&&d&&!n){let m=e.indexOf("}",g+1);m===-1?n=!0:(c=40,f=m+1)}}}else if(o===106&&e.startsWith("json",s)&&pa(e.charCodeAt(s+4))){let d=s+5;for(;pa(e.charCodeAt(d));)d++;let g=d;for(;Sh(e.charCodeAt(d));)d++;if(d>g){for(;pa(e.charCodeAt(d));)d++;if(e.charCodeAt(d)===64){for(d++;pa(e.charCodeAt(d));)d++;if(e.charCodeAt(d)===123){t.push(43),r.push(s),a.push(d),s=d;let u=0,m=!1,b=!1,w=d;for(;w<i;w++){let v=e.charCodeAt(w);if(m)b?b=!1:v===92?b=!0:v===34&&(m=!1);else if(v===34)m=!0;else if(v===123)u++;else if(v===125&&--u===0)break}t.push(w<i?44:45),r.push(d),s=w<i?w+1:i,a.push(s),l=!1;continue}}}}if(c===0){for(;f<i&&Sh(e.charCodeAt(f));)f++;let d=T6(e,s,o);if(d!==0)d===1||f-s===Kw[d]?(c=d,f=s+Kw[d]):c=21;else if((o===111||o===120)&&e.charCodeAt(s+1)===45&&e.charCodeAt(s+2)===45)c=o===111?56:58,f=s+3;else if(pt(o)){let g=s+1;for(;pt(e.charCodeAt(g));)g++;if(e.charCodeAt(g)===46&&pt(e.charCodeAt(g+1))){for(c=22,f=g+2;pt(e.charCodeAt(f));)f++;for(;ni(e.charCodeAt(f));)f++}else c=21}else for(c=21;e.charCodeAt(f)===45&&Sh(e.charCodeAt(f+1));)for(c=27,f+=2;Sh(e.charCodeAt(f));)f++}}else if(o===10)c=39,p=!0;else if(o===13)c=39,p=!0,e.charCodeAt(f)===10&&f++;else if(o===34||o===39){if(o===34&&e.charCodeAt(s+1)===96){let d=e.indexOf('`"',s+2);c=d===-1?37:36,f=d===-1?i:d+2}else if(c=35,f=ub(e,s,o),f===-1){let d=s+1;for(;d<i&&!_6(e,d);)d++;throw Zw(e,s,d-s)}}else if(o===37)if(l&&e.charCodeAt(f)===37)for(c=38;f<i&&e.charCodeAt(f)!==10&&e.charCodeAt(f)!==13;)f++;else c=31;else if(o===45)if(e.charCodeAt(f)!==45)c=29;else{for(;e.charCodeAt(f)===45;)f++;let d=e.charCodeAt(f),g=f-s===2;g&&d===124&&e.charCodeAt(f+1)===62?(c=46,f+=2):d===62?(c=53,f++):g&&(d===111||d===120)?(c=d===111?55:57,f++):c=59}else if(o===46){let d=e.charCodeAt(f);if(d===46&&e.charCodeAt(f+1)===62)c=47,f+=2;else if(pt(d)){for(c=22;pt(e.charCodeAt(f));)f++;for(;ni(e.charCodeAt(f));)f++}else c=30}else if(o===60)if(e.charCodeAt(f)===60){if(t.push(48),r.push(s),a.push(s+2),l=!1,s+=2,s>=i)break;if(e.charCodeAt(s)===62&&e.charCodeAt(s+1)===62)c=49,f=s+2;else{let d=s,g=!1;for(;d<i;d++){let u=e.charCodeAt(d);if(u===10||u===13)break;if(u===62&&e.charCodeAt(d+1)===62){g=!0;break}}if(g&&e.slice(s,d).trim()!=="")t.push(50),r.push(s),a.push(d),c=49,s=d,f=d+2;else{for(;d<i&&e.charCodeAt(d)!==10&&e.charCodeAt(d)!==13;)d++;if(d===s){for(;d<i&&(e.charCodeAt(d)===10||e.charCodeAt(d)===13);)d++;throw Zw(e,s,d-s)}c=51,f=d}}}else if(e.charCodeAt(f)===45&&e.charCodeAt(f+1)===45)for(c=54,f+=2;e.charCodeAt(f)===45;)f++;else c=33;else if(o===58)e.charCodeAt(f)===58&&e.charCodeAt(f+1)===58?(c=52,f+=2):c=25;else if(o===64)e.charCodeAt(f)===123?(c=60,f++):c=23;else if(o===123)c=61;else if(o===125)c=62;else if(o===91)c=63;else if(o===93)c=64;else if(o===40)c=65;else if(o===41)c=66;else if(o===44)c=24;else if(o===35){for(;lo(e.charCodeAt(f));)f++;c=f>s+1?26:32}else if(o===92)e.charCodeAt(f)===44?(c=28,f++):c=33;else if(o<127&&o>32)c=Yi[o]&pb?32:33;else for(c=34;f<i;){let d=e.charCodeAt(f);if(d>=32&&d<127||d===9||d===10||d===13)break;f++}t.push(c),r.push(s),a.push(f),s=f,l=p}for(let o=0;o<3;o++)t.push(0),r.push(i),a.push(i);return{types:t,starts:r,ends:a}}function N6(){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 R6(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:"",accDescription:""}}function jp(e,t){if(t.length===0)return;let r=new Set(e);for(let a of t)r.has(a)||(r.add(a),e.push(a))}function L6(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let{key:r,value:a}of e)if(r==="icon")t.clear(),t.add("actor");else if(r==="animate"||r==="animation")t.clear(),t.add("edge");else if(r==="type")t.clear(),a==="rect"||a==="package"?t.add("boundary"):(a==="normal"||a==="hollow"||a==="awesome")&&t.add("actor");else if(r==="business")t.delete("boundary"),t.delete("edge");else return;return t.size===1?[...t][0]:void 0}function D6(e,t,r,a,i){let s=N6(),{actors:l,useCases:n,systemBoundaries:o}=s,c=new Map,f=new Map,p=new Map,d=new Map,g=new Map,u=x=>C6(e,x[0],x[1]),m=(x,T)=>{let[A,M]=Kl(e,T[0]);return new je(x,"semantic",{type:"usecase",line:A,column:M})},b=(x,T)=>{throw m(`${x} at ${u(T)}`,T)},w=(x,T,A,M,Y)=>{let B=q=>q===void 0?"":` (label "${q}")`;throw m(`${x} at ${u(T)}${B(M)}; previous declaration at ${u(A)}${B(Y)}`,T)},v=(x,T,A)=>b(`Metadata property '${A.key}' is invalid for ${T} '${x}'`,A.keySpan),k=(x,T)=>{let A=g.get(x);(A===void 0||T<A)&&g.set(x,T)},L=x=>[...x].sort((T,A)=>(g.get(T.id)??0)-(g.get(A.id)??0)),I=(x,T)=>{c.set(x.id,{kind:T,span:x.span,generated:x.generated,label:x.label.text})},N=(x,T)=>{let A=c.get(x.id);if(!A)return;let M=x.generated?x.label.text:void 0,Y=A.generated?A.label:void 0;A.kind!==T&&w(`ID '${x.id}' is declared as both ${A.kind} and ${T}`,x.span,A.span,M,Y),(A.generated||x.generated)&&w(`Generated ID '${x.id}' collides with another declaration`,x.span,A.span,M,Y)},O=(x,T,A)=>{let M=c.get(x);M&&w(`ID '${x}' is declared more than once (${M.kind} and ${T})`,A,M.span,void 0,M.generated?M.label:void 0),c.set(x,{kind:T,span:A,generated:!1})},W=(x,T,A)=>{let{key:M,value:Y}=T,B=q=>{!A&&q!==void 0&&q!==Y&&w(`Actor '${x.id}' has conflicting ${M} metadata`,T.keySpan,x.span)};M==="type"&&(Y==="normal"||Y==="hollow"||Y==="awesome")?(B(x.actorType),x.actorType=Y):M==="icon"&&typeof Y=="string"?(B(x.icon),x.icon=Y):M==="business"&&typeof Y=="boolean"?(B(x.business),x.business=Y):v(x.id,"actor",T)},U=(x,T,A)=>{for(let M of T??[])x.kind==="actor"?W(x,M,A):M.key==="business"&&typeof M.value=="boolean"?(!A&&x.business!==void 0&&x.business!==M.value&&w(`Use case '${x.id}' has conflicting business metadata`,M.keySpan,x.span),x.business=M.value):v(x.id,"usecase",M)},_=x=>{let T;if(x.kind==="actor"){n.delete(x.id);let A={id:x.id,label:x.label.text,labelType:x.label.type,business:x.business??!1,classes:[...x.classes],type:x.icon?"icon":x.actorType??"normal",styles:l.get(x.id)?.styles??[]};x.icon&&(A.icon=x.icon),l.set(x.id,A),T=A}else l.delete(x.id),T={id:x.id,label:x.label.text,labelType:x.label.type,business:x.business??!1,classes:[...x.classes],shape:x.shape??"ellipse",styles:n.get(x.id)?.styles??[]},n.set(x.id,T);x.stereotype&&(T.stereotype=x.stereotype),x.parent?.id&&(T.parentId=x.parent.id)},j=x=>{N(x,x.kind);let T=x.parent?.id?x.parent:void 0,A=f.get(x.id);if(!A){let M={kind:x.kind,id:x.id,label:x.label,span:x.span,generated:x.generated,classes:[...x.classes],parent:T,shape:x.shape,stereotype:x.stereotype,stereotypeSpan:x.stereotype?x.span:void 0};U(M,x.metadata,!1),f.set(x.id,M),I(x,x.kind);return}(A.label.text!==x.label.text||A.label.type!==x.label.type)&&w(`ID '${x.id}' has conflicting labels`,x.span,A.span),x.shape&&A.shape&&x.shape!==A.shape&&w(`Use case '${x.id}' has conflicting shapes`,x.span,A.span),T&&A.parent?.id&&T.id!==A.parent.id&&w(`Element '${x.id}' belongs to more than one system boundary`,T.span,A.parent.span),x.stereotype&&A.stereotype&&x.stereotype!==A.stereotype&&w(`Element '${x.id}' has conflicting stereotypes`,x.span,A.stereotypeSpan??A.span),A.shape??(A.shape=x.shape),A.parent??(A.parent=x.parent),A.stereotype??(A.stereotype=x.stereotype),A.stereotypeSpan??(A.stereotypeSpan=x.stereotype?x.span:void 0),jp(A.classes,x.classes),U(A,x.metadata,!1)},Z=x=>{N(x,"boundary");let T=p.get(x.id);if(T){(T.label.text!==x.label.text||T.label.type!==x.label.type)&&w(`Boundary '${x.id}' has conflicting titles`,x.span,T.span),jp(T.classes,x.classes);return}p.set(x.id,{...x,classes:[...x.classes],members:[]}),I(x,"boundary")},H=x=>{x.classed&&!x.declares&&b(`Relationship endpoint '${x.id}' uses ::: without declaring the node`,x.span);let T=c.get(x.id);return T?T.kind:(f.set(x.id,{...x,kind:"usecase",shape:"ellipse",classes:[]}),I(x,"usecase"),k(x.id,x.span[0]),"usecase")},z=(x,T)=>{let A=c.get(x)?.kind;return(A==="actor"?l.get(x):A==="usecase"?n.get(x):A==="boundary"?o.get(x):A==="json"?s.jsonNodes.get(x):d.get(x))??b(`Class/style target '${x}' is unresolved or anonymous`,T)},C=[];for(let{source:x,target:T}of t.relationships)k(x.id,x.span[0]),k(T.id,T.span[0]);for(let x of t.elements)k(x.id,x.span[0]),C.push({offset:x.span[0],run:()=>j(x)});for(let x of t.boundaries)k(x.id,x.span[0]),C.push({offset:x.span[0],run:()=>Z(x)});for(let x of t.jsons)k(x.id,x.span[0]),C.push({offset:x.span[0],run:()=>O(x.id,"json",x.span)});for(let{id:x,idSpan:T}of t.relationships)x&&T&&C.push({offset:T[0],run:()=>O(x,"edge",T)});C.sort((x,T)=>x.offset-T.offset);for(let x of C)x.run();for(let x of L(f.values()))_(x);for(let x of L(p.values()))o.set(x.id,{id:x.id,label:x.label.text,labelType:x.label.type,type:"rect",members:[],classes:[],styles:[]});for(let x of L(t.jsons))s.jsonNodes.set(x.id,{id:x.id,value:x.value,propertyOrder:x.propertyOrder,classes:[...x.classes],styles:[]});let S=0;for(let x of t.relationships){let{source:T,target:A,type:M}=x,Y=H(T),B=H(A),q=P=>P==="actor"||P==="usecase"||P==="json";q(Y)||w(`Relationship source '${T.id}' cannot be ${Y}`,T.span,c.get(T.id).span),q(B)||w(`Relationship target '${A.id}' cannot be ${B}`,A.span,c.get(A.id).span),(M==="include"||M==="extend")&&(Y!=="usecase"||B!=="usecase")&&b(`${M} relationship requires use-case endpoints`,x.span),M==="generalization"&&(Y==="json"||Y!==B)&&b("Generalization requires actor-to-actor or use-case-to-use-case endpoints",x.span),M==="association"&&(Y==="json"||B==="json")&&x.arrowType>2&&b(`JSON relationship '${T.id}' to '${A.id}' permits only point, reversed-point, or markerless solid association`,x.span);let D=x.id??`edge-${S++}`,R={id:D,explicitId:!!x.id,source:T.id,target:A.id,type:M,arrowType:x.arrowType,minlen:x.minlen,classes:[],styles:[],animate:!1};x.label&&(R.label=x.label.text,R.labelType=x.label.type),s.relationships.push(R),d.set(D,R)}let $=new Map(l),y=new Map(n);l.clear(),n.clear();for(let x of L(f.values())){let T=$.get(x.id),A=y.get(x.id);T?l.set(x.id,T):A?n.set(x.id,A):_(x)}for(let{target:x,span:T,properties:A,statement:M}of t.metadata){let Y=c.get(x);if(!Y){let R=L6(A);return b(`Metadata target '${x}' is unresolved${R?` (metadata implies ${R})`:""}`,T)}let B=Y.kind;B==="actor"||B==="usecase"?U(f.get(x),A,!0):B==="edge"&&(M.kind="edgeMetadata",M.edges=[{id:x,span:M.span,idSpan:T,metadata:M.metadata}],delete M.nodes);let q=p.get(x),D=d.get(x);for(let R of B==="actor"||B==="usecase"?[]:A){let{key:P,value:G}=R;B==="boundary"&&q&&P==="type"&&(G==="rect"||G==="package")?q.type=G:B==="edge"&&D&&P==="animate"&&typeof G=="boolean"?D.animate=G:B==="edge"&&D&&P==="animation"&&(G==="fast"||G==="slow")?(D.animation=G,D.animate=!0):v(x,B,R)}}for(let x of s.relationships)x.animation&&(x.animate=!0);for(let x of f.values())x.kind==="actor"?(x.icon&&x.actorType&&x.actorType!=="normal"&&b(`Actor '${x.id}' cannot combine icon with type '${x.actorType}'`,x.span),x.business&&(x.icon||x.actorType==="awesome")&&b(`Business actor '${x.id}' must use normal or hollow geometry`,x.span)):x.shape==="rect"&&x.business&&b(`Rectangular use case '${x.id}' cannot be a business use case`,x.span),_(x);for(let x of[...t.elements].sort((T,A)=>T.span[0]-A.span[0])){if(!x.parent?.id)continue;let T=p.get(x.parent.id).members;T.includes(x.id)||T.push(x.id)}for(let x of p.values()){let T=o.get(x.id);T.type=x.type??"rect",T.members=x.members,T.classes=[...x.classes]}let E=0;for(let x of t.notes){let T=c.get(x.target);if(!T)return b(`Note target '${x.target}' is unresolved`,x.span);T.kind!=="actor"&&T.kind!=="usecase"&&w(`Note target '${x.target}' must be an actor or use case, not ${T.kind}`,x.span,T.span);let A=`note-${E++}`;s.notes.set(A,{id:A,target:x.target,label:x.label.text,labelType:x.label.type})}for(let x of t.classDefs)for(let T of x.ids)s.classDefs.set(T,{id:T,styles:[...x.styles]});for(let x of t.classes)for(let T of x.targets)jp(z(T.id,T.span).classes,x.classes);for(let x of t.styles)z(x.target,x.span).styles.push(...x.styles);return s.direction=t.direction??s.direction,s.title=i,s.accTitle=t.accTitle,s.accDescription=t.accDescription,s.accDescr=t.accDescription.replace(/\n\s+/g,`
|
|
135
|
+
`),s.source=e,s.headerSpan=r,s.statements=a,s}function Qw(e){let t=new Map,r=[],a=[],i=e.length,s=0,l="",n=0,o=()=>{for(;s<i;){let d=e.charCodeAt(s);if(d!==32&&d!==9&&d!==10&&d!==13)return;s++}},c=d=>{s++;let g="";for(;s<i;){let u=s,m=e[s++];if(m==='"')return g;if(m.charCodeAt(0)<32)throw new Jr(u);if(m!=="\\"){d&&(g+=m);continue}let b=s,w=e[s++],v;if(w==='"'||w==="\\"||w==="/")v=w;else if(w==="b")v="\b";else if(w==="f")v="\f";else if(w==="n")v=`
|
|
136
|
+
`;else if(w==="r")v="\r";else if(w==="t")v=" ";else if(w==="u"){let k=e.slice(s,s+4);if(!/^[\dA-Fa-f]{4}$/.test(k))throw new Jr(s);v=String.fromCharCode(parseInt(k,16)),s+=4}else throw new Jr(b);d&&(g+=v)}throw new Jr(s)},f=d=>{for(let g=0;g<d.length;g++)if(e[s+g]!==d[g])throw new Jr(s+g);s+=d.length},p=()=>{if(e.charCodeAt(s)===45&&s++,e.charCodeAt(s)===48)s++;else if(pt(e.charCodeAt(s)))for(;pt(e.charCodeAt(s));)s++;else throw new Jr(s);if(e.charCodeAt(s)===46){if(s++,!pt(e.charCodeAt(s)))throw new Jr(s);for(;pt(e.charCodeAt(s));)s++}if((e.charCodeAt(s)|32)===101){if(s++,(e.charCodeAt(s)===43||e.charCodeAt(s)===45)&&s++,!pt(e.charCodeAt(s)))throw new Jr(s);for(;pt(e.charCodeAt(s));)s++}};for(o();;)if(n===0){o();let d=e.charCodeAt(s);if(n=2,d===123){s++;let g=[];t.set(l,g),r.push(l),o(),e.charCodeAt(s)===125?s++:(a.push({object:!0,pointer:l,keys:g,ranges:new Map,key:"",from:0,index:0}),n=1)}else if(d===91)s++,o(),e.charCodeAt(s)===93?s++:(a.push({object:!1,pointer:l,keys:[],ranges:new Map,key:"",from:0,index:0}),l+="/0",n=0);else if(d===34)c(!1);else if(d===116)f("true");else if(d===102)f("false");else if(d===110)f("null");else if(d===45||pt(d))p();else throw new Jr(s)}else if(n===1){let d=a[a.length-1];if(e.charCodeAt(s)!==34)throw new Jr(s);let g=c(!0),u=d.ranges.get(g);if(u===void 0)d.keys.push(g);else for(let m=u[0];m<u[1];m++)t.delete(r[m]);if(d.key=g,d.from=r.length,o(),e.charCodeAt(s)!==58)throw new Jr(s);s++,l=`${d.pointer}/${g.replaceAll("~","~0").replaceAll("/","~1")}`,n=0}else{let d=a[a.length-1];if(d===void 0)break;d.object?d.ranges.set(d.key,[d.from,r.length]):d.index++,o();let g=e.charCodeAt(s);if(g===(d.object?125:93))s++,a.pop();else{if(g!==44)throw new Jr(s);s++,o(),l=`${d.pointer}/${d.index}`,n=d.object?1:0}}if(o(),s!==i)throw new Jr(s);return t}function eu(e,t,r,a){let i=Math.min(Math.max(t,0),e.length);for(let s=0;s<i;s++){let l=e.charCodeAt(s);l===13?(r++,a=1):l===10?(s===0||e.charCodeAt(s-1)!==13)&&(r++,a=1):a++}return[r,a]}function O6(e,t,r,a){let i=/\bposition (\d+)\b/.exec(e);if(i)return eu(t,parseInt(i[1],10),r,a);let s=/\bline (\d+) column (\d+)\b/.exec(e);if(s){let l=parseInt(s[1],10),n=parseInt(s[2],10);return[r+l-1,l===1?a+n-1:n]}if(/unexpected end|end of json input/i.test(e))return eu(t,t.length,r,a)}function Jw(e,t,r){return new je(`${e} (line ${t}, column ${r})`,"syntax",{type:"usecase",line:t,column:r})}function P6(e,t){let r;try{r=JSON.parse(e)}catch(a){let i=a instanceof Error?a.message:String(a),[s,l]=t(),n=O6(i,e,s,l);if(!n){let o=0;try{Qw(e)}catch(c){c instanceof Jr&&(o=c.offset)}n=eu(e,o,s,l)}throw Jw(`Invalid JSON: ${i}`,n[0],n[1])}if(typeof r!="object"||r===null||Array.isArray(r)){let[a,i]=t();throw Jw("JSON value must have an object root",a,i)}return{value:r,propertyOrder:Qw(e)}}function Es(e,t){for(let r of e.split("|"))if(r==="WORD")for(let a=1;a<=21;a++)Pa[a]|=t;else Pa[fb.indexOf(r)]|=t}function dr(e){return ea.slice(Sr[e],Br[e])}function ha(e){return[Sr[e],Br[e]]}function zh(e){let[t,r]=Kl(ea,Sr[Fe]);throw new je(`Error parsing usecase diagram: ${e} at line ${t}, column ${r} [${Sr[Fe]},${Br[Fe]})`,"syntax",{type:"usecase",line:t,column:r})}function vb(e){zh(`Expecting token of type --> ${e} <-- but found --> '${dr(Fe)}' <--`)}function mr(e){return at[Fe]!==e&&vb(fb[e]),Fe++}function wa(e){let t=e.split("|").map((r,a)=>` ${a+1}. [${r}]`);zh(`Expecting: one of these possible Token sequences:
|
|
137
|
+
${t.join(`
|
|
138
|
+
`)}
|
|
139
|
+
but found: '${dr(Fe)}'`)}function eb(){let e=Ph.split("|"),t=e.flatMap(i=>["NEWLINE","IDENTIFIER","PLAIN_STRING","RBRACE"].map(s=>`${i}, METADATA_START, ${s}`)),r=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Oh}|NEWLINE|EOF`.split("|"),a=e.flatMap((i,s)=>(s===0?["LPAREN","LBRACKET",...r]:r).map(l=>`${i}, ${l}`));return[bb,...t,...a,...t].join("|")}function tb(e){return e>=1&&e<=21}function rb(e){return e>=1&&e<=34}function vs(){kb=Br[Fe-1],at[Fe]===39?Fe++:at[Fe]!==0&&wa("NEWLINE|EOF")}function Vl(e){let t=at[e]===36?2:at[e]===35?1:0;return[Sr[e]+t,Br[e]-t]}function ru(e){let t=Vl(e);return{text:ea.slice(t[0],t[1]),type:at[e]===36?"markdown":"text",span:t}}function Eb(e){return e.replace(/\W/g,"_")}function ql(){let e=at[Fe];if(e===35||e===36)return ru(Fe++);rb(e)||wa(z6);let t=Fe;for(;rb(at[Fe]);)Fe++;let r=[Sr[t],Br[Fe-1]];return{text:ea.slice(r[0],r[1]),type:"text",span:r}}function As(e){return e===21||e===35}function ab(){let e=Fe;As(at[Fe])||wa("IDENTIFIER|PLAIN_STRING"),Fe++,mr(25);let t=Fe,r=at[Fe];!As(r)&&r!==19&&r!==20&&wa("IDENTIFIER|PLAIN_STRING|TRUE|FALSE"),Fe++;let a=Vl(e),i=Vl(t);return{key:ea.slice(a[0],a[1]),value:r===19?!0:r===20?!1:ea.slice(i[0],i[1]),span:[Sr[e],Br[t]],keySpan:a,valueSpan:i}}function W6(){let e=at[Fe],t=at[Fe+1],r=at[Fe+2];return e===24?As(t)||t===39&&(r===39||As(r)):e!==39?!1:t===24||As(t)||t===39&&(r===39||r===24||As(r))}function su(){mr(60);let e=[];for(;at[Fe]===39;)Fe++;if(As(at[Fe])){for(e.push(ab());W6();){if(at[Fe]===24)Fe++;else{for(;at[Fe]===39;)Fe++;at[Fe]===24&&Fe++}for(;at[Fe]===39;)Fe++;e.push(ab())}for(at[Fe]===24&&Fe++;at[Fe]===39;)Fe++}return mr(62),e}function nu(e){return e.map(({key:t,span:r,keySpan:a,valueSpan:i})=>({key:t,span:r,keySpan:a,valueSpan:i}))}function lu(e,t){do{Fe++;let r=mr(21);e.push(dr(r)),t.push(ha(r))}while(at[Fe]===24)}function Sb(e){let t=Fe,r=at[Fe],a={id:"",label:void 0,span:Vl(t),generated:r!==21,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(r===21){Fe++,a.id=dr(t);let i=at[Fe];i===65||e&&i===63?(Fe++,a.label=ql(),mr(i===65?66:64),a.shape=i===65?"ellipse":"rect"):a.label=ru(t)}else r===35||r===36?(Fe++,a.label=ru(t),a.id=Eb(a.label.text)):wa(Ph);return a}function Dh(e){let t=Fe,r=Sb(!e);if(e&&(r.shape=void 0),at[Fe]===60&&(r.metadata=su()),at[Fe]===48){Fe++;let a=mr(50);mr(49),r.stereotype=dr(a).trim(),r.stereotypeSpan=ha(a)}return at[Fe]===52&&lu(r.classes,r.classSpans),r.explicit=!!(r.shape||r.metadata||r.stereotype),r.nodeSpan=[Sr[t],Br[Fe-1]],r}function ou(e,t){return{id:e.id,kind:t,label:e.label,span:e.span,generated:e.generated,parent:Lh,shape:e.shape,metadata:e.metadata,stereotype:e.stereotype,classes:e.classes}}function ib(e,t){return{id:e.id,label:e.label,span:e.span,generated:e.generated,declares:t,classed:e.classes.length>0}}function cu(e,t){let r={id:e.id,span:e.nodeSpan,idSpan:e.span,labelSpan:e.label.span};return t&&(r.defines=!0),e.stereotypeSpan&&(r.stereotypeSpan=e.stereotypeSpan),e.metadata&&(r.metadata=nu(e.metadata)),e.classSpans.length>0&&(r.classSpans=e.classSpans),r}function Vp(e){if(at[Fe]<1||at[Fe]>36)return!1;for(let t=Fe+1;;t++){let r=at[t];if(r===59||Pa[r]&e)return!0;if(r<1||r>36)return!1}}function Hl(e){let t=Br[e]-Sr[e]-(at[e]===59?0:1);return Math.max(1,t-1)}function Tb(){let e=Fe,t={type:"association",arrowType:0,minlen:1,target:void 0,span:[0,0]};at[Fe]===21&&at[Fe+1]===23&&(t.explicitId=dr(Fe),t.explicitIdSpan=ha(Fe),Fe+=2);let r=Fe,a=at[Fe++];if(a===47)mr(25),at[Fe]!==17&&at[Fe]!==18&&wa("INCLUDE|EXTEND"),t.type=at[Fe]===17?"include":"extend",t.label={text:t.type,type:"text",span:ha(Fe)},Fe++;else if(a===46)t.type="generalization";else if(a===53)t.minlen=Hl(r);else if(a===54)t.arrowType=1,Br[r]-Sr[r]===3&&Vp(0)?(t.label=ql(),t.minlen=Hl(mr(59))):t.minlen=Hl(r);else if(a===59)if(t.arrowType=2,Br[r]-Sr[r]===2&&Vp(xb)){t.label=ql();let i=at[Fe];i===53?t.arrowType=0:i===55?t.arrowType=3:i===57?t.arrowType=4:i!==59&&wa("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS"),(t.arrowType===0||t.arrowType===2)&&(t.minlen=Hl(Fe)),Fe++}else t.minlen=Hl(r);else a===55?t.arrowType=3:a===57?t.arrowType=4:a===56||a===58?(t.arrowType=a===56?5:6,Vp(0)&&(t.label=ql(),mr(59))):(Fe--,wa(Oh));return t.target=Dh(!1),t.span=[Sr[e],Br[Fe-1]],t}function Oa(e){return{kind:e,span:[0,0]}}function Cb(e,t,r,a){let i=r.target;i.explicit&&Er.elements.push(ou(i,"usecase")),Er.relationships.push({source:ib(e,t),target:ib(i,i.explicit),span:r.span,id:r.explicitId,idSpan:r.explicitIdSpan,type:r.type,arrowType:r.arrowType,label:r.label,minlen:r.minlen}),a.push(cu(i,i.explicit));let s=Oa("edge");return s.nodes=a,s.edges=[{id:r.explicitId??`edge-${Mb++}`,span:s.span}],r.explicitIdSpan&&(s.edges[0].idSpan=r.explicitIdSpan),r.label&&(s.edges[0].labelSpan=r.label.span),s}function _b(e){let t=Oa("node");return t.nodes=e,t}function Ib(e){Fe++;let t=[Dh(!0)],r;if(at[Fe]===24)do Fe++,t.push(Dh(!0));while(at[Fe]===24);else e&&Pa[at[Fe]]&iu&&(r=Tb());vs();for(let i of t)Er.elements.push(ou(i,"actor"));let a=t.map(i=>cu(i,!0));return r?Cb(t[0],!0,r,a):_b(a)}function Nb(e){let t=Dh(!1),r=e&&Pa[at[Fe]]&iu?Tb():void 0;vs(),r||(t.explicit=!0,t.shape??(t.shape="ellipse")),t.explicit&&Er.elements.push(ou(t,"usecase"));let a=[cu(t,t.explicit)];return r?Cb(t,t.explicit,r,a):_b(a)}function B6(){Fe++;let e=Sb(!0),t={id:e.id,label:e.label,span:e.span,generated:e.generated,classes:e.classes},r=at[Fe]===60?su():void 0;at[Fe]===52&&lu(e.classes,e.classSpans),vs(),Er.boundaries.push(t),Lh=t;let a=[];for(;Pa[at[Fe]]&yb;)a.push(Rb(!1));Lh=void 0;let i=mr(4);vs();let s=Oa("group");return s.group=t.id,s.idSpan=t.span,s.titleSpan=t.label.span,s.endSpan=ha(i),s.classSpans=e.classSpans,a.length>0&&(s.children=a),r&&(s.metadata=nu(r),Er.metadata.push({target:t.id,span:t.span,properties:r,statement:s})),s}function sb(){let e=Fe,t=at[Fe];for(tb(t)||t===27?Fe++:t===59?(Fe++,tb(at[Fe])||vb("WORD"),Fe++):wa("WORD|CSS_IDENTIFIER|MARKERLESS_SOLID"),mr(25),(Pa[at[Fe]]&tu)===0&&zh(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
|
|
140
|
+
<[${$b.replaceAll("|","] ,[")}]>
|
|
141
|
+
but found: '${dr(Fe)}'`);Pa[at[Fe]]&tu;)Fe++;return ea.slice(Sr[e],Br[Fe-1]).replaceAll("\\,",",")}function nb(){let e=[sb()];for(;at[Fe]===24;)Fe++,e.push(sb());return e}function Xp(){let e=[mr(21)];for(;at[Fe]===24;)Fe++,e.push(mr(21));return e}function Th(e){let t=Vl(e);return{id:dr(e),span:t,idSpan:t}}function H6(){let e=Fe,t=at[Fe],r;if(t===41||t===42||t===40){Fe++;let a=dr(e);t===40?Er.accDescription=a.slice(a.indexOf("{")+1,a.lastIndexOf("}")).trim():t===42?Er.accDescription=a.slice(a.indexOf(":")+1).trim():Er.accTitle=a.slice(a.indexOf(":")+1).trim(),r=Oa(t===41?"accTitle":"accDescr")}else if(t===5){Fe++;let a=at[Fe];(a<6||a>10)&&wa("TD|TB|BT|LR|RL"),Er.direction=a===6?"TB":dr(Fe),Fe++,r=Oa("direction")}else{if(t===2)return Ib(!0);if(t===3)return B6();if(t===11){Fe++,mr(12);let a=mr(21),i=ql();Er.notes.push({target:dr(a),span:ha(a),label:i}),r=Oa("note"),r.ref=`note-${Ab++}`,r.refSpan=i.span,r.nodes=[Th(a)]}else if(t===43){Fe++;let a=mr(44),i=[],s=[];at[Fe]===52&&lu(i,s);let l=Sr[e]+4;for(;ea.charCodeAt(l)===32||ea.charCodeAt(l)===9;)l++;let n=l;for(;/\w/.test(ea.charAt(n));)n++;let o={id:ea.slice(l,n),value:{},propertyOrder:new Map,span:[l,n],classes:i};Er.jsons.push(o),Nh.push([o,a]),r=Oa("json"),r.nodes=[{id:o.id,span:o.span,idSpan:o.span,defines:!0,classSpans:s}],r.classSpans=s}else if(t===14){Fe++;let a=Xp();Er.classDefs.push({ids:a.map(dr),styles:nb()}),r=Oa("classDef"),r.ref=dr(a[0]),r.refSpan=ha(a[0])}else if(t===15){Fe++;let a=Xp(),i=Xp();Er.classes.push({targets:a.map(s=>({id:dr(s),span:ha(s)})),classes:i.map(dr)}),r=Oa("classAssign"),r.ref=dr(i[0]),r.refSpan=ha(i[0]),r.nodes=a.map(Th)}else if(t===16){Fe++;let a=mr(21);Er.styles.push({target:dr(a),span:ha(a),styles:nb()}),r=Oa("style"),r.nodes=[Th(a)]}else{let a=at[Fe+1];if(a===60){!(Pa[at[Fe+2]]&wb)&&wa(eb()),Fe++;let i=Th(e);t!==21&&(i.id=Eb(ea.slice(i.span[0],i.span[1])));let s=su();r=Oa("metadata"),r.nodes=[i],r.metadata=nu(s),Er.metadata.push({target:i.id,span:i.span,properties:s,statement:r})}else return(!(Pa[a]&mb||t===21&&(a===65||a===63))||t===21&&F6.has(dr(e).toLowerCase()))&&wa(eb()),Nb(!0)}}return vs(),r}function Rb(e){let t=Fe,r=at[Fe];if(r===39)return Fe++,{kind:"blank",span:ha(t)};if(r===38)return Fe++,vs(),{kind:"comment",span:ha(t)};let a=e?H6():r===2?Ib(!1):Nb(!1);if(a.span=[Sr[t],kb],a.edges)for(let i of a.edges)i.span=a.span;return a}function Y6(e,t){ea=e,{types:at,starts:Sr,ends:Br}=I6(e),Fe=0,Er=R6(),Lh=void 0,Nh=[],Mb=0,Ab=0;try{let r=mr(1);vs();let a=[];for(;Pa[at[Fe]]&gb;)a.push(Rb(!0));at[Fe]!==0&&zh(`Redundant input, expecting EOF but found: ${dr(Fe)}`);for(let[i,s]of Nh){let l=P6(dr(s),()=>Kl(e,Sr[s]));i.value=l.value,i.propertyOrder=l.propertyOrder}return D6(e,Er,ha(r),a,t)}finally{ea="",at=Sr=Br=Nh=[]}}function lb(e){return typeof e=="string"?e:e===null?"null":String(e)}function q6(e){let t=[],r=[[e.value,"",""]],a=[];for(;r.length>0;){let[i,s,l]=r.pop();if(a.length=0,Array.isArray(i))i.length===0?t.push({key:s,accessibleKey:s,value:"[]"}):i.every(n=>n===null||typeof n!="object")?i.forEach((n,o)=>t.push({key:o===0?s:"",accessibleKey:s,value:lb(n)})):i.forEach((n,o)=>a.push([n,`${s}[${o}]`,`${l}/${o}`]));else if(i!==null&&typeof i=="object"){let n=i,o=e.propertyOrder.get(l)??Object.keys(n);o.length===0&&t.push({key:s,accessibleKey:s,value:"{}"});for(let c of o)a.push([Object.prototype.hasOwnProperty.call(n,c)?n[c]:void 0,s?`${s}.${c}`:c,`${l}/${c.replaceAll("~","~0").replaceAll("/","~1")}`])}else t.push({key:s,accessibleKey:s,value:lb(i)});for(let n=a.length-1;n>=0;n--)r.push(a[n])}return t}function Yl(...e){return e.filter(Boolean).join(" ")}function G6(e){return e.type==="generalization"?["none","extension"]:e.type!=="association"?Kp[0]:Kp[e.arrowType]??Kp[2]}function j6(e){let t=[],r=[],a=i=>{let s=new Map;for(let l of["default",...i]){let n=e.classDefs.get(l);if(n)for(let o of n.styles){let c=o.trim(),f=c.indexOf(":"),p=(f===-1?c:c.slice(0,f)).trim();p&&s.set(p,c)}}return[...s.values()]};for(let i of e.actors.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:U6[i.type],isGroup:!1,padding:10,cssClasses:Yl("default","usecase-actor",`usecase-actor-${i.type}`,i.business&&"usecase-business",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:a(i.classes),actorType:i.type,business:i.business,icon:i.icon||void 0,stereotype:i.stereotype||void 0,parentId:i.parentId||void 0});for(let i of e.useCases.values()){let s=i.shape==="ellipse";t.push({id:i.id,label:i.label,labelType:i.labelType,shape:s?i.business?"usecaseBusiness":"usecaseEllipse":"rect",isGroup:!1,padding:s?20:10,cssClasses:Yl("default","usecase-element",`usecase-${i.shape}`,i.business&&"usecase-business",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:a(i.classes),business:i.business,stereotype:i.stereotype||void 0,parentId:i.parentId||void 0})}for(let i of e.notes.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:"note",isGroup:!1,padding:10,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:a([]),noteTarget:i.target});for(let i of e.jsonNodes.values())t.push({id:i.id,label:i.id,labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,cssClasses:Yl("default","usecase-json-table",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:a(i.classes),jsonRows:q6(i)});for(let i of e.systemBoundaries.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,cssClasses:Yl("default","system-boundary",`system-boundary-${i.type}`,...i.classes),cssStyles:[...i.styles],cssCompiledStyles:a(i.classes),boundaryType:i.type});for(let i of e.relationships){let s=i.type==="include"||i.type==="extend",[l,n]=G6(i),o=i.animate||i.animation!==void 0,c={id:i.id,start:i.source,end:i.target,relationshipType:i.type,pattern:s?"dotted":"solid",arrowTypeStart:l,arrowTypeEnd:n,classes:Yl("default","relationship",`relationship-${i.type}`,...i.classes,o&&`edge-animation-${i.animation??"fast"}`),style:[...i.styles],cssCompiledStyles:a(i.classes),animate:i.animate,animation:i.animation,minlen:i.minlen,explicitId:i.explicitId,internal:!1};s?(c.label=i.type,c.labelType="text"):i.type==="association"&&(i.label&&(c.label=i.label),i.labelType&&(c.labelType=i.labelType)),r.push(c)}for(let i of e.notes.values())r.push({id:`${i.id}-edge`,start:i.id,end:i.target,relationshipType:"note",pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",classes:"default relationship relationship-note",style:[],cssCompiledStyles:a([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:r}}function cb(e,t,r){let a=e.usecase?.[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function Q6(e){return e.replace(/[&<>\\]/g,t=>`&#${t.charCodeAt(0)};`)}function Hi(e,t,r,a,i,s=0){return ze(e&&!t?Q6(e):e,t,r,a,i,s)}function au(e,t,r,a){let i=r===1||r===2?1:-1,s=r===1||r===3,l=(s?e.w:e.h)/2,n=0;if(e.kind===0)s?(l=hu/2+3,n=(Gl-e.h)/2):l+=2;else if(e.kind===1){let o=(s?e.h:e.w)/2;l*=Math.sqrt(Math.max(1-(a/o)**2,0))}return s?[t.x+i*l,t.y+n+a]:[t.x+a,t.y+i*l]}function Lb(e,t){let r=t===1||t===3;if(e.kind===0)return r?Gl*.5:hu*.6;let a=r?e.h:e.w;return e.kind===1?a*.6:a-16}function J6(e,t,r){let a=new Map,i=(s,l,n,o)=>{let c=t[s];if(c.isGroup)return;let f=l[n]-c.x,p=l[n+1]-c.y,d;if(Math.abs(Math.abs(p)-c.h/2)<.5)d=p<0?0:2;else if(Math.abs(Math.abs(f)-c.w/2)<.5)d=f<0?3:1;else return;let g=s*4+d,u={route:l,at:n,toward:l[o+(d&1?1:0)]},m=a.get(g);m?m.push(u):a.set(g,[u])};for(let s of e){let l=s.route.length-3;s.src===s.dst||l<3||(i(s.src,s.route,0,3),i(s.dst,s.route,l,l-3))}for(let[s,l]of a){let n=s>>2,o=s&3,c=r[n],f=l.length>1?Math.min(Z6,Lb(c,o)/(l.length-1)):0;l.sort((p,d)=>p.toward-d.toward);for(let p=0;p<l.length;p++){let[d,g]=au(c,t[n],o,(p-(l.length-1)/2)*f);l[p].route[l[p].at]=d,l[p].route[l[p].at+1]=g}}}function eN(e,t,r,a,i){let s=e-r*Rh,l=t-a*Rh,n=Rh*.5;return`<path class="pele-marker" d="M${h(e)},${h(t)}L${h(s-a*n)},${h(l+r*n)}L${h(s+a*n)},${h(l-r*n)}Z" fill="var(--_bg)" stroke="${i}" stroke-linejoin="round"/>`}function Ih(e){return e==="extension"?Rh:gt(e)}function hb(e,t,r,a,i,s){return e==="extension"?eN(t,r,a,i,s):bt(e,t,r,a,i,s)}function tN(e,t){let r=e.node,a=e.style.shape,i=` fill="none" stroke="var(--_b)"${e.style.line}`,s=-21,l=9,n;return r.actorType==="hollow"?(l=8,n=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${a}/><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"${a}/>`):r.actorType==="awesome"?n=`<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)"${a}/>`:r.actorType==="icon"?(s=-14,l=12,n=`<rect x="-22" y="-26" width="44" height="44"${ft(jl+a)}/><svg class="pele-icon" data-icon="${Oe(r.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?.(r.icon??"")??""}</svg>`):n=`<circle cy="-21" r="9"${jl}${a}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${i}/>`,r.business&&(n+=`<path class="pele-business" d="M${h(.12*l)},${h(s+.99*l)}L${h(.92*l)},${h(s-.39*l)}"${i}/>`),n}function rN(e,t,r){return jr(e.direction)?Bt(r,a=>db(e,t,r,a)):db(e,t,r,!1)}function db(e,t,r,a){let i=j6(e),s=r.fontSize??16,l=Math.round(s*.875),n=Math.round(s*.8125),o=r.measurer??et(r.fontFamily),c=r.padding??8,f=r.icons,p=a?"TB":br(e.direction),d=p==="LR"||p==="RL",g=new Map,u=[],m=[];i.nodes.forEach(($,y)=>g.set($.id,y));for(let $ of i.nodes){let y=vt($.cssStyles.length>0?$.cssCompiledStyles.concat($.cssStyles):$.cssCompiledStyles),E=(y.bold?1:0)|(y.italic?2:0),x=y.fontSize??s,T=$.labelType==="markdown",A=Hi($.stereotype&&`\xAB${$.stereotype}\xBB`,!1,o,n,200,E),M={node:$,kind:2,style:y,label:A,stereotype:A,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},Y;if($.isGroup){M.kind=4,M.label=Hi($.label,T,o,x,4e3,E);let B=M.label.height;Y=Ut(0,0),Y.isGroup=!0,Y.padX=Ch,Y.padBottom=Ch,Y.padTop=$.boundaryType==="package"?B+2*Qp+16:B>0?B+16:Ch,Y.minW=M.label.width+2*Ch}else{if($.jsonRows){M.kind=3,M.label=Hi($.label,!1,o,x,4e3,E|1);let B=0;for(let q of $.jsonRows){let D=Hi(q.key,!1,o,l,4e3,E),R=Hi(q.value,!1,o,l,260,E);M.rows.push([D,R]),M.keyW=Math.max(M.keyW,D.width),B=Math.max(B,R.width),M.h+=Math.max(D.height,R.height,Math.round(l*1.5))+Jp}M.keyW>0&&(M.keyW+=2*Ul),M.headH=Math.max(M.label.height,Math.round(x*1.5))+Jp,M.w=Math.max(M.label.width+2*Ul,M.rows.length>0?M.keyW+B+2*Ul:0,72),M.h+=M.headH}else if($.actorType)M.kind=0,M.label=Hi($.label,T,o,x,140,E),M.w=Math.max(hu,M.label.width,A.width),M.h=Gl+ob+A.height+M.label.height;else{M.label=Hi($.label,T,o,$.shape==="note"?l:x,180,E);let B=Math.max(M.label.width,A.width),q=M.label.height+A.height;$.shape==="usecaseEllipse"||$.shape==="usecaseBusiness"?(M.kind=1,M.w=Math.max(B+2*$.padding+($.business?16:4),88),M.h=Math.max(q+28,48)):$.shape==="note"?(M.w=B+2*$.padding+6,M.h=q+18):(M.w=Math.max(B+2*$.padding+12,80),M.h=Math.max(q+24,44))}Y=Ut(M.w,M.h)}Y.seq=u.length,u.push(M),m.push(Y)}i.nodes.forEach(($,y)=>{m[y].parent=$.parentId!==void 0?g.get($.parentId)??-1:-1});let b=[],w=[],v=[];for(let $ of i.edges){let y=g.get($.start),E=g.get($.end);if(y===void 0||E===void 0)continue;let x=$.relationshipType==="include"||$.relationshipType==="extend",T=Hi(x?`\xAB${$.label}\xBB`:$.label,$.labelType==="markdown",o,l,200);y===E&&(u[y].loops++,d?m[y].h+=2*(Zp+(T.height>0?T.height+8:0)):m[y].w+=2*(Zp+(T.width>0?T.width+12:0))),v.push($),w.push(T),b.push({src:y,dst:E,minlen:$.minlen,labelW:T.width>0?T.width+12:0,labelH:T.height>0?T.height+4:0,route:[],labelX:0,labelY:0})}let k=Gr(m,b,p,{nodeSep:cb(t,"nodeSpacing",V6),edgeSep:X6,rankSep:cb(t,"rankSpacing",K6),portSep:20}),L=Cr(e.title,o,s,4e3),I=L.height>0?L.height+12:0,N=Math.max(k.width,L.width),O=c+(N-k.width)/2,W=c+I;vi(m,b,O,W);let U=Math.ceil(N+2*c),_=Math.ceil(k.height+I+2*c),j=new Map;for(let $ of b)va(j,$.route);J6(b,m,u);let Z="",H="";for(let $=0;$<u.length;$++){let y=u[$],E=m[$],x=y.node,T=_t(x.cssClasses.replace(/^default\s?/,"")),A=Oe(x.id),M=y.style.text,Y=y.style.shape,B=y.w,q=y.h;if(y.kind===4){let P=E.x-E.w/2,G=E.y-E.h/2,X=` fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${Y}`,Q=` class="pele-cluster-label" fill="var(--_m)"${M}`,J;if(x.boundaryType==="package"){let F=Math.min(y.label.width+2*Qp+8,E.w),K=y.label.height+2*Qp;J=`<rect class="pele-boundary-tab" x="${h(P)}" y="${h(G)}" width="${h(F)}" height="${h(K)}"${X}/><rect x="${h(P)}" y="${h(G+K)}" width="${h(E.w)}" height="${h(E.h-K)}"${X}/>`+Re(y.label,P+F/2,G+K/2,Q,f)}else J=`<rect x="${h(P)}" y="${h(G)}" width="${h(E.w)}" height="${h(E.h)}"${ft(X)}/>`+Re(y.label,aN(E,y.label.width,j),G+8+y.label.height/2,Q,f);Z+=`<g class="pele-cluster pele-boundary${T}" data-id="${A}">${J}</g>`;continue}let D,R;if(y.kind===0){R="pele-actor";let P=-q/2,G=P+Gl+ob+y.stereotype.height/2;D=`<g class="pele-actor-figure" transform="translate(0,${h(P+Gl/2)})">${tN(y,f)}</g>`+Re(y.stereotype,0,G,` class="pele-stereotype" font-size="${n}" fill="var(--_m)"`,f)+Re(y.label,0,q/2-y.label.height/2,` class="pele-label"${M}`,f)}else if(y.kind===3){R="pele-json";let P=-B/2,G=-q/2+y.headH,X="",Q=`M${h(P)},${h(G)}H${h(P+B)}`;y.keyW>0&&(Q+=`M${h(P+y.keyW)},${h(G)}V${h(q/2)}`);for(let[J,F]of y.rows){let K=Math.max(J.height,F.height,Math.round(l*1.5))+Jp;X+=Re(J,P+Ul+J.width/2,G+K/2,' class="pele-json-key" fill="var(--_m)"',f)+iN(F,P+y.keyW+Ul,G+K/2,` class="pele-json-value"${M}`,f),G+=K}D=`<rect x="${h(P)}" y="${h(-q/2)}" width="${h(B)}" height="${h(q)}"${ft(jl+Y)}/><path class="pele-json-lines" d="${Q}" fill="none" stroke="var(--_b)"${y.style.line}/>`+Re(y.label,0,-q/2+y.headH/2,` class="pele-label" font-weight="var(--_hw)"${M}`,f)+`<g font-size="${l}">${X}</g>`}else{let P=y.stereotype.height/2,G;if(y.kind===1){if(R="pele-usecase",G=`<ellipse rx="${h(B/2)}" ry="${h(q/2)}"${jl}${Y}/>`,x.business){let X=B/2-15,Q=B/2-5,J=F=>q/2*Math.sqrt(1-(F/(B/2))**2);G+=`<path class="pele-business" d="M${h(X)},${h(J(X))}L${h(Q)},${h(-J(Q))}" fill="none" stroke="var(--_b)"${y.style.line}/>`}}else if(x.shape==="note"){R="pele-note";let X=B/2,Q=q/2;G=`<path d="M${h(-X)},${h(-Q)}H${h(X-_h)}L${h(X)},${h(_h-Q)}V${h(Q)}H${h(-X)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${Y}/><path d="M${h(X-_h)},${h(-Q)}V${h(_h-Q)}H${h(X)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${y.style.line}/>`}else R="pele-usecase",G=`<rect x="${h(-B/2)}" y="${h(-q/2)}" width="${h(B)}" height="${h(q)}"${ft(jl+Y)}/>`;D=G+Re(y.stereotype,0,-y.label.height/2,` class="pele-stereotype" font-size="${n}" fill="var(--_m)"`,f)+Re(y.label,0,P,` class="pele-label"${x.shape==="note"?` font-size="${l}"`:""}${M}`,f)}H+=`<g class="pele-node ${R}${T}" data-id="${A}" transform="translate(${h(E.x)},${h(E.y)})">${D}</g>`}let z="",C="",S=new Map;for(let $=0;$<b.length;$++){let y=b[$],E=v[$],x=w[$],T=E.style.length>0||E.cssCompiledStyles.length>0?vt(E.cssCompiledStyles.concat(E.style)):void 0,A=E.arrowTypeStart,M=E.arrowTypeEnd,Y;if(y.src===y.dst){let D=m[y.src],R=u[y.src],P=S.get(y.src)??0;S.set(y.src,P+1);let G=d?2:1,X=Math.min(Lb(R,G)/2,8+P*6),Q=Zp+P*8,[J,F]=au(R,D,G,-X),[K,re]=au(R,D,G,X),ne=Math.hypot(Q,X)||1,de=d?X/ne:Q/ne,ie=d?Q/ne:X/ne,se=Ih(A),ee=Ih(M),te=(pe,ge,Ae,Se)=>d?`${h(pe+Ae*X*(Se?1:0))},${h(ge+Se)}`:`${h(pe+Se)},${h(ge+Ae*X*(Se?1:0))}`,fe=d?J-de*se:J+de*se,ye=d?F+ie*se:F-ie*se,le=K+de*ee,we=re+ie*ee;Y={d:`M${h(fe)},${h(ye)}C${te(J,F,-1,Q)} ${te(K,re,1,Q)} ${h(le)},${h(we)}`,sx:J,sy:F,sdx:d?de:-de,sdy:d?-ie:ie,ex:K,ey:re,edx:-de,edy:-ie},d?(y.labelX=D.x,y.labelY=Math.max(F,re)+Q*.75+6+x.height/2):(y.labelX=Math.max(J,K)+Q*.75+8+x.width/2,y.labelY=D.y)}else{if(y.route.length<6)continue;Y=zr(y.route,void 0,Ih(A),Ih(M))}let B=T?.stroke?Xe(T.stroke):"var(--_l)",q=E.internal?"2 3":E.pattern==="dotted"?"5 4":E.animate?"9 5":"";if(z+=`<g class="pele-edge pele-${E.relationshipType}${_t(E.classes.replace(/^default relationship relationship-\S+\s?/,""))}" data-id="${Oe(E.id)}"${T?.line??""}><path d="${Y.d}"${q?` stroke-dasharray="${q}"`:""}/>`+hb(A,Y.sx,Y.sy,Y.sdx,Y.sdy,B)+hb(M,Y.ex,Y.ey,Y.edx,Y.edy,B)+"</g>",x.width>0){let D=y.labelX,R=y.labelY,P=E.relationshipType==="include"||E.relationshipType==="extend";C+=wr(E.id,x,D,R,(P?' fill="var(--_m)"':"")+(T?.text??""),f)}}return{svg:Je("usecase",U,_,s,r,e,Re(L,U/2,c+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+(Z?`<g class="pele-clusters">${Z}</g>`:"")+(z?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${z}</g>`:"")+(C?`<g class="pele-edge-labels" font-size="${l}">${C}</g>`:"")+`<g class="pele-nodes">${H}</g>`),width:U,height:_,links:[]}}function aN(e,t,r){let a=r.get(Math.round(e.y-e.h/2));if(t===0||a===void 0)return e.x;let i=e.x-e.w/2+6,s=e.x+e.w/2-6,l=a.filter(d=>d>i&&d<s).sort((d,g)=>d-g);l.push(s);let n=t/2+6,o=e.x,c=1/0,f=0,p=i;for(let d of l){if(d-p>=2*n){let g=Math.min(Math.max(e.x,p+n),d-n);Math.abs(g-e.x)<c&&(c=Math.abs(g-e.x),o=g)}else c===1/0&&d-p>f&&(f=d-p,o=(p+d)/2);p=d}return o}function iN(e,t,r,a,i){if(e.lines.length<2)return Re(e,t+e.width/2,r,a,i);let s="";for(let l=0;l<e.lines.length;l++)s+=Re(Ua(e,l),t+e.widths[l]/2,r-e.height/2+Ya(e,l),a,i);return s}var fb,Xl,pb,Yi,Kw,Jr,gb,iu,tu,mb,yb,xb,wb,Oh,Ph,z6,bb,$b,Pa,F6,ea,at,Sr,Br,Fe,kb,Er,Lh,Nh,Mb,Ab,U6,Kp,V6,X6,K6,Ch,Zp,hu,Gl,ob,Qp,Ul,Jp,_h,Rh,Z6,jl,Db,Ob=Ve(()=>{Fs();Ei();Ea();tr();zt();pr();ut();wt();fb="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(" "),Xl=1,pb=2,Yi=new Uint8Array(128);for(let e=48;e<=57;e++)Yi[e]=Xl;for(let e=65;e<=90;e++)Yi[e]=Yi[e+32]=Xl;Yi[95]=Xl;for(let e of"!#$&*+/=?^|~")Yi[e.charCodeAt(0)]=pb;Kw=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];Jr=class extends Error{constructor(t){super("Invalid JSON token");ce(this,"offset");this.offset=t}};gb=1,iu=2,tu=4,mb=8,yb=16,xb=32,wb=64,Oh="DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS",Ph="IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING",z6="PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT",bb="ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE",$b="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",Pa=new Uint8Array(67);Es(`NEWLINE|COMMENT|${bb}|${Ph}`,gb);Es(`IDENTIFIER|${Oh}`,iu);Es($b,tu);Es(`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Oh}|NEWLINE|EOF`,mb);Es(`NEWLINE|COMMENT|ACTOR|${Ph}`,yb);Es("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS",xb);Es("NEWLINE|IDENTIFIER|PLAIN_STRING|RBRACE",wb);F6=new Set(["allowmixing","newpage","package","rectangle","skinparam"]),ea="",at=[],Sr=[],Br=[],Fe=0,kb=0,Nh=[],Mb=0,Ab=0;U6={normal:"usecaseActor",hollow:"usecaseActorHollow",awesome:"usecaseActorAwesome",icon:"usecaseActorIcon"},Kp=[["none","arrow_point"],["arrow_point","none"],["none","none"],["none","arrow_circle"],["none","arrow_cross"],["arrow_circle","none"],["arrow_cross","none"]];V6=32,X6=16,K6=72,Ch=20,Zp=26,hu=40,Gl=60,ob=6,Qp=6,Ul=10,Jp=8,_h=9,Rh=12,Z6=14,jl=' fill="var(--_s)" stroke="var(--_b)"';Db={type:"usecase",math:!0,parse:(e,t,r)=>Y6(e,r),render:rN}});var Pb={};Ct(Pb,{usecase:()=>Db});var zb=Ve(()=>{Ob()});function Ss(e){let t=e.trim();return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function du(e){return e.map(Ss).sort()}function hN(e,t){let r=new lN(e,t),a=-1,i=()=>a===-1?a=r.next():a,s=g=>{throw i()===1?it("venn",e,r.start,"",!0):it("venn",e,r.start,`Expecting ${g}, got '${Fb[a]}'`)},l=()=>(a=-1,r.text),n=g=>(i()!==g&&s(`'${Fb[g]}'`),l()),o=()=>(i()!==16&&a!==17&&s("'IDENTIFIER', 'STRING'"),l()),c=()=>{let g=[o()];for(;i()===18;)l(),g.push(o());return g},f=(g,u)=>{let m=i()===11?l():void 0,b;if(i()===19&&(l(),b=parseFloat(n(12))),u){if(g.length<2)throw new je("union requires multiple identifiers","semantic",{type:"venn"});t.validateUnionIdentifiers(g)}t.addSubsetData(g,m,b),t.setIndentMode(!0)},p=g=>{let u=i();u!==16&&u!==17&&u!==12&&s("'NUMERIC', 'IDENTIFIER', 'STRING'");let m=l(),b=u!==12&&i()===11?l():void 0;t.addTextData(g(),m,b)},d=()=>{let g=c(),u=[];for(;;){let m=n(16);n(19);let b;if(i()===17)b=l();else{let w=[];for(;i()===16||a>=12&&a<=15;)w.push(l());w.length===0&&s(cN),b=w.join(" ")}if(u.push([m,b]),i()!==18)break;l()}t.addStyleData(g,u)};for(;i()===3;)l();for(n(4);;){let g=i();if(g===2)return;if((g<3||g>10||g===4)&&s(oN),l(),g===5)t.setDiagramTitle(r.text.slice(6));else if(g===6)f([o()],!1);else if(g===7)f(c(),!0);else if(g===8){let u=c();p(()=>u)}else g===9?p(()=>{let u=t.getCurrentSets();if(!u)throw new je("text requires set","semantic",{type:"venn"});return u}):g===10&&d()}}function dN(e){let t=new Set,r=new Map;for(let i of e)t.add(JSON.stringify([...i.sets].sort())),i.sets.length===1&&r.set(i.sets[0],i.size);let a=[];for(let i of e){if(i.sets.length<3)continue;let s=[...i.sets].sort();for(let l=0;l<s.length-1;l++)for(let n=l+1;n<s.length;n++){let o=[s[l],s[n]],c=JSON.stringify(o);if(t.has(c))continue;t.add(c);let f=r.get(o[0]),p=r.get(o[1]);a.push({sets:o,size:f!==void 0&&p!==void 0?Math.min(f,p)/4:2.5,label:""})}}return a.length>0?[...e,...a]:e}function fN(e,t,r){if(r>=e+t)return 0;let a=Math.min(e,t);if(r<=Math.abs(e-t))return Math.PI*a*a;let i=e*e*Math.acos((r*r+e*e-t*t)/(2*r*e)),s=t*t*Math.acos((r*r+t*t-e*e)/(2*r*t)),l=.5*Math.sqrt(Math.max((-r+e+t)*(r+e-t)*(r-e+t)*(r+e+t),0));return i+s-l}function pN(e,t,r){let a=Math.abs(e-t),i=e+t;if(!(r>0))return i;if(r>=Math.PI*Math.min(e,t)**2)return a;for(let s=0;s<48;s++){let l=(a+i)/2;fN(e,t,l)>r?a=l:i=l}return(a+i)/2}function Wb(e,t,r,a,i,s){let l=1/0;for(let n of t){let o=e[n],c=a-o.x,f=i-o.y,p=o.r-Math.sqrt(c*c+f*f);if(p<l){if(p<s)return p;l=p}}for(let n of r){let o=e[n],c=a-o.x,f=i-o.y,p=Math.sqrt(c*c+f*f)-o.r;if(p<l){if(p<s)return p;l=p}}return l}function pu(e,t,r){let a=0,i=0,s=e[t[0]];for(let u of t){let m=e[u];a+=m.x/t.length,i+=m.y/t.length,m.r<s.r&&(s=m)}let l=s.r,n=a,o=i,c=Wb(e,t,r,n,o,-1/0),f=0,p=(u,m)=>{let b=Wb(e,t,r,u,m,c-l*1e-9);if(!(b>c-l*1e-9))return!1;let w=Math.hypot(u-a,m-i);return b>c+l*1e-9||w<f-l*1e-9?(c=b,f=w,n=u,o=m,!0):!1},d=10;for(let u=-d;u<=d;u++)for(let m=-d;m<=d;m++)m*m+u*u<=d*d&&p(s.x+m*l/d,s.y+u*l/d);let g=l/d;for(let u=0;u<40&&g>l*1e-6;u++){let m=!1;for(let b=0;b<8;b++){let w=b*Fh/8;p(n+Math.cos(w)*g,o+Math.sin(w)*g)&&(m=!0)}m||(g/=2)}return{x:n,y:o,margin:c}}function uN(e){let t=new Map;for(let b of e)for(let w of b.sets)t.has(w)||t.set(w,10);for(let b of e)b.sets.length===1&&t.set(b.sets[0],b.size);let r=new Map,a=[],i=0;for(let b of t.values())Number.isFinite(b)&&b>i&&(i=b);i===0&&(i=10);let s=Math.sqrt(i/Math.PI);for(let[b,w]of t){r.set(b,a.length);let v=Number.isFinite(w)&&w>0?Math.sqrt(w/Math.PI):0;a.push({id:b,x:0,y:0,r:Math.max(v,s*.3)})}let l=a.length;if(l<2)return a;let n=new Map;for(let b of dN(e)){if(b.sets.length!==2)continue;let w=r.get(b.sets[0]),v=r.get(b.sets[1]);w!==v&&n.set(Math.min(w,v)*l+Math.max(w,v),b.size)}let o=new Map;for(let[b,w]of n)o.set(b,pN(a[Math.floor(b/l)].r,a[b%l].r,w));let c=s*.15,f=(b,w)=>o.get(b*l+w)??a[b].r+a[w].r+c;if(l===2)return a[1].x=f(0,1),a;if(l===3){let b=f(0,1),w=f(0,2),v=f(1,2),k=e.some(L=>new Set(L.sets).size===3);for(let L=0;L<40;L++){let I=b>0?(b*b+w*w-v*v)/(2*b):0;if(a[1].x=b,a[2].x=Math.max(-w,Math.min(w,I)),a[2].y=Math.sqrt(Math.max(w*w-I*I,0)),!k||pu(a,[0,1,2],[]).margin>s*.12)break;b*=.94,w*=.94,v*=.94}return a}let p=0;for(let b of a)p+=2*b.r+c;let d=Math.min(300,Math.floor(3e6/(l*l)));if(l<=64){let b=p/Fh;a.forEach((w,v)=>{let k=v*Fh/l-Math.PI/2;w.x=Math.cos(k)*b,w.y=Math.sin(k)*b})}else{let b=Math.ceil(Math.sqrt(l)),w=2*s+c;a.forEach((v,k)=>{v.x=k%b*w,v.y=Math.floor(k/b)*w})}let g=new Float64Array(l),u=new Float64Array(l),m=new Int32Array(l);for(let b=0;b<d;b++){g.fill(0),u.fill(0),m.fill(0);for(let w=0;w<l;w++)for(let v=w+1;v<l;v++){let k=o.get(w*l+v),L=a[w].r+a[v].r+c,I=a[v].x-a[w].x,N=a[v].y-a[w].y,O=Math.hypot(I,N);if(k===void 0&&O>=L)continue;O<1e-9&&(I=Math.cos(w+v),N=Math.sin(w+v),O=1);let W=(O-(k??L))/2/O;g[w]+=I*W,u[w]+=N*W,g[v]-=I*W,u[v]-=N*W,m[w]++,m[v]++}for(let w=0;w<l;w++)m[w]!==0&&(a[w].x+=g[w]/m[w],a[w].y+=u[w]/m[w])}return a}function gN(e,t){let r=o=>`M${t(o.x-o.r)},${t(o.y)}A${t(o.r)},${t(o.r)} 0 1 1 ${t(o.x+o.r)},${t(o.y)}A${t(o.r)},${t(o.r)} 0 1 1 ${t(o.x-o.r)},${t(o.y)}Z`;if(e.length===1)return r(e[0]);let a=(o,c,f,p)=>{for(let d of e)if(d!==f&&d!==p&&Math.hypot(o-d.x,c-d.y)>d.r*(1+1e-9))return!1;return!0},i=[];for(let o=0;o<e.length;o++)for(let c=o+1;c<e.length;c++){let f=e[o],p=e[c],d=Math.hypot(p.x-f.x,p.y-f.y);if(d>=f.r+p.r||d<=Math.abs(f.r-p.r)||d===0)continue;let g=(f.r*f.r-p.r*p.r+d*d)/(2*d),u=Math.sqrt(Math.max(f.r*f.r-g*g,0)),m=f.x+(p.x-f.x)*g/d,b=f.y+(p.y-f.y)*g/d;for(let w of[1,-1]){let v=m+w*u*(p.y-f.y)/d,k=b-w*u*(p.x-f.x)/d;a(v,k,f,p)&&i.push({x:v,y:k,a:f,b:p})}}if(i.length<2){let o=e[0];for(let c of e)c.r<o.r&&(o=c);for(let c of e)if(c!==o&&Math.hypot(c.x-o.x,c.y-o.y)+o.r>c.r*(1+1e-9))return"";return r(o)}let s=0,l=0;for(let o of i)s+=o.x/i.length,l+=o.y/i.length;i.sort((o,c)=>Math.atan2(o.y-l,o.x-s)-Math.atan2(c.y-l,c.x-s));let n="";for(let o=0;o<i.length;o++){let c=i[o],f=i[(o+1)%i.length];o===0&&(n=`M${t(c.x)},${t(c.y)}`);let p,d=0,g=1/0;for(let u of[c.a,c.b]){if(u!==f.a&&u!==f.b)continue;let m=Math.atan2(c.y-u.y,c.x-u.x),b=Math.atan2(f.y-u.y,f.x-u.x)-m;b<=0&&(b+=Fh);let w=u.x+u.r*Math.cos(m+b/2),v=u.y+u.r*Math.sin(m+b/2),k=Math.hypot(w-(c.x+f.x)/2,v-(c.y+f.y)/2);k<g&&(g=k,p=u,d=b>Math.PI?1:0)}p===void 0?n+=`L${t(f.x)},${t(f.y)}`:n+=`A${t(p.r)},${t(p.r)} 0 ${d} 1 ${t(f.x)},${t(f.y)}`}return n+"Z"}function fu(e){return e.length===1?e[0]:JSON.stringify(e)}function xN(e,t,r){let a=r.fontSize??16,i=Math.round(a*.875),s=Math.round(a*.8125),l=r.measurer??et(r.fontFamily),n=r.padding??8,o=uN(e.subsets),c=new Map;o.forEach(($,y)=>c.set($.id,y));let f=new Map;for(let{targets:$,styles:y}of e.styles){let E=fu($),x=f.get(E);x||f.set(E,x=new Map);for(let[T,A]of y)x.set(T,A)}let p=$=>{let y=f.get($);if(!y)return Bb;let E=[];for(let[x,T]of y)E.push(`${x}:${T}`);return vt(E)},d=o.map(()=>[]);for(let $=0;$<o.length;$++)for(let y=$+1;y<o.length;y++)Math.hypot(o[$].x-o[y].x,o[$].y-o[y].y)<o[$].r+o[y].r&&(d[$].push(y),d[y].push($));let g=new Map;for(let $ of e.subsets)g.set(fu($.sets),$);let u=new Map;for(let[$,y]of g){let E=[...new Set(y.sets)],x=E.map(R=>c.get(R)),T=new Set(x),A=x[0];for(let R of x)o[R].r<o[A].r&&(A=R);let M=p($),Y=y.label??(y.sets.length===1?y.sets[0]:void 0),B=(M.bold?1:0)|(M.italic?2:0),q=pu(o,x,d[A].filter(R=>!T.has(R)));q.margin<o[A].r*.2&&(q=pu(o,x,[]));let D={sets:E,inside:x,spot:q,lines:[],style:M};if(Y){let R=E.length===1?a:i;D.lines.push({id:void 0,raw:Y,size:R,base:B,label:ze(Y,!1,l,R,4e3,B)})}u.set($,D)}for(let $ of e.textNodes){let y=$.label??$.id;u.get(fu($.sets))?.lines.push({id:$.id,raw:y,size:s,base:0,label:ze(y,!1,l,s,4e3)})}let m=0;for(let $ of o)$.r>m&&(m=$.r);let b=m>0?mN/m:1,w=1;for(let $ of u.values()){if($.spot.margin<=0)continue;let y=0,E=0;for(let T of $.lines)y=Math.max(y,T.label.width),E+=T.label.height;let x=Math.hypot(y,E)/2+4;w=Math.max(w,Math.min(x/($.spot.margin*b),yN))}b*=w;for(let $ of u.values()){let y=Math.max($.spot.margin*b*1.8,72);for(let E of $.lines)E.label.width>y&&(E.label=ze(E.raw,!1,l,E.size,y,E.base))}let v=1/0,k=1/0,L=-1/0,I=-1/0;for(let $ of o)v=Math.min(v,($.x-$.r)*b),k=Math.min(k,($.y-$.r)*b),L=Math.max(L,($.x+$.r)*b),I=Math.max(I,($.y+$.r)*b);for(let $ of u.values()){let y=0,E=0;for(let x of $.lines)y=Math.max(y,x.label.width),E+=x.label.height;v=Math.min(v,$.spot.x*b-y/2),L=Math.max(L,$.spot.x*b+y/2),k=Math.min(k,$.spot.y*b-E/2),I=Math.max(I,$.spot.y*b+E/2)}o.length===0&&(v=k=L=I=0);let N=ze(e.title&&Ss(e.title),!1,l,a,4e3,1),O=N.height>0?N.height+12:0,W=Math.max(L-v,N.width),U=n+(W-(L-v))/2-v,_=n+O-k,j=Math.ceil(W+2*n),Z=Math.ceil(I-k+O+2*n),H=o.map($=>({id:$.id,x:$.x*b+U,y:$.y*b+_,r:$.r*b})),z="";H.forEach(($,y)=>{let E=dt(y),x=u.get($.id)?.style??Bb;z+=`<circle class="pele-venn-set" data-id="${Oe($.id)}" cx="${h($.x)}" cy="${h($.y)}" r="${h($.r)}" fill="${E}" fill-opacity="0.2" stroke="${E}"${x.shape}/>`});let C="",S="";for(let $ of u.values()){let y=Oe($.sets.join("|"));if($.sets.length>1&&$.style.shape!==""){let M=gN($.inside.map(Y=>H[Y]),h);M!==""&&(C+=`<path class="pele-venn-overlap" data-id="${y}" d="${M}" fill="none"${$.style.shape}/>`)}let E=0;for(let M of $.lines)E+=M.label.height;if(E===0)continue;let x=$.spot.x*b+U,T=$.spot.y*b+_-E/2,A="";for(let M of $.lines){let Y=M.id===void 0?` class="pele-label"${M.size===a?"":` font-size="${M.size}"`}${$.style.text}`:` class="pele-venn-text" data-id="${Oe(M.id)}" font-size="${s}" fill="var(--_m)"${p(M.id).text}`;A+=Re(M.label,x,T+M.label.height/2,Y),T+=M.label.height}S+=`<g class="pele-venn-region" data-id="${y}">${A}</g>`}return{svg:Je("venn",j,Z,a,r,{},Re(N,j/2,n+N.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-venn-sets">${z}</g>`+(C?`<g class="pele-venn-overlaps">${C}</g>`:"")+(S?`<g class="pele-venn-labels">${S}</g>`:"")),width:j,height:Z,links:[]}}var sN,Fb,nN,lN,oN,cN,Fh,mN,yN,Bb,Hb,Yb=Ve(()=>{tr();ut();wt();sN=class{constructor(){ce(this,"type","venn");ce(this,"title");ce(this,"subsets",[]);ce(this,"textNodes",[]);ce(this,"styles",[]);ce(this,"known",new Set);ce(this,"current");ce(this,"indent",!1)}setDiagramTitle(e){this.title=e}addSubsetData(e,t,r){let a=du(e);this.current=a,a.length===1&&this.known.add(a[0]),this.subsets.push({sets:a,size:r??10/e.length**2,label:t?Ss(t):void 0})}addTextData(e,t,r){this.textNodes.push({sets:du(e),id:Ss(t),label:r?Ss(r):void 0})}addStyleData(e,t){let r=new Map;for(let[a,i]of t)r.set(a,i&&Ss(i));this.styles.push({targets:du(e),styles:r})}validateUnionIdentifiers(e){let t=e.map(Ss).filter(r=>!this.known.has(r));if(t.length>0)throw new je(`unknown set identifier: ${t.join(", ")}`,"semantic",{type:"venn"})}getCurrentSets(){return this.current}getIndentMode(){return this.indent}setIndentMode(e){this.indent=e}},Fb=["$end","INVALID","EOF","NEWLINE","VENN","TITLE","SET","UNION","TEXT","INDENT_TEXT","STYLE","BRACKET_LABEL","NUMERIC","HEXCOLOR","RGBCOLOR","RGBACOLOR","IDENTIFIER","STRING","COMMA","COLON"],nN=[["venn-beta",4],["set",6],["union",7],["text",8],["style",10]],lN=class{constructor(e,t){ce(this,"src");ce(this,"host");ce(this,"text","");ce(this,"start",0);ce(this,"at",0);ce(this,"lineStart",!1);ce(this,"ended",!1);this.src=e,this.host=t}word(e,t){let r=this.src;for(let a=0;a<t.length;a++){let i=r.charCodeAt(e+a),s=t.charCodeAt(a);if(i!==s&&(i+32!==s||i<65||i>90))return!1}return!0}keyword(e,t){return this.word(e,t)&&!Qe(this.src.charCodeAt(e+t.length))}color(e,t){let r=this.src,a=e+1;for(let i=0;i<t;i++){for(;Ue(r.charCodeAt(a));)a++;let s=a;for(;pt(r.charCodeAt(a))||r.charCodeAt(a)===46;)a++;if(a===s)return-1;for(;Ue(r.charCodeAt(a));)a++;if(r.charCodeAt(a)!==(i===t-1?41:44))return-1;a++}return a}lineEnd(e){let t=this.src.indexOf(`
|
|
142
|
+
`,e);return t===-1?this.src.length:t}next(){let e=this.src,t=e.length;for(;;){let r=this.at;if(this.start=r,this.text="",r>=t)return this.ended?0:(this.ended=!0,2);let a=e.charCodeAt(r);if(a===37&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)!==123||a!==125&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)===37){this.at=this.lineEnd(r+2);continue}if(this.lineStart){if(a===32||a===9){let i=r+1;for(;e.charCodeAt(i)===32||e.charCodeAt(i)===9;)i++;if(this.at=i,this.keyword(i,"text")&&this.host.getIndentMode())return this.at=i+4,this.lineStart=!1,this.text=e.slice(r,i),9;continue}a!==10&&a!==13&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(a===10||a===13){for(r++;e.charCodeAt(r)===10||e.charCodeAt(r)===13;)r++;return this.lineStart=!0,this.token(3,r)}if(a===37&&e.charCodeAt(r+1)===37){this.at=this.lineEnd(r);continue}if(a===32||a===9){for(r++;e.charCodeAt(r)===32||e.charCodeAt(r)===9;)r++;this.at=r;continue}if((a|32)>=97&&(a|32)<=122||a===95){if(this.word(r,"title")&&Ue(e.charCodeAt(r+5))){let i=r+6;for(;i<t;){let s=e.charCodeAt(i);if(s===35||s===10||s===59)break;i++}if(i>r+6)return this.token(5,i)}for(let[i,s]of nN)if(this.keyword(r,i))return this.token(s,r+i.length);if(this.word(r,"rgb")){let i=(e.charCodeAt(r+3)|32)===97,s=r+(i?4:3),l=e.charCodeAt(s)===40?this.color(s,i?4:3):-1;if(l!==-1)return this.token(i?15:14,l)}for(r++;Qe(e.charCodeAt(r))||e.charCodeAt(r)===45;)r++;return this.token(16,r)}if(a===91){if(e.charCodeAt(r+1)===34){let s=e.indexOf('"',r+2);return s===-1||e.charCodeAt(s+1)!==93?1:(this.at=s+2,this.text=e.slice(r+2,s),11)}let i=r+1;for(;i<t&&e.charCodeAt(i)!==93&&e.charCodeAt(i)!==34;)i++;return i===r+1||e.charCodeAt(i)!==93?1:(this.at=i+1,this.text=e.slice(r+1,i).trim(),11)}if(pt(a)||a===46||a===43||a===45){(a===43||a===45)&&r++;let i=r;for(;pt(e.charCodeAt(r));)r++;if(r>i){if(e.charCodeAt(r)===46&&pt(e.charCodeAt(r+1)))for(r+=2;pt(e.charCodeAt(r));)r++}else if(e.charCodeAt(r)===46&&pt(e.charCodeAt(r+1)))for(r+=2;pt(e.charCodeAt(r));)r++;else return 1;return this.token(12,r)}if(a===35){let i=r+1;for(;i<r+9&&lo(e.charCodeAt(i));)i++;return i>=r+4?this.token(13,i):1}if(a===34){let i=e.indexOf('"',r+1);return i===-1?1:this.token(17,i+1)}return a===44?this.token(18,r+1):a===58?this.token(19,r+1):1}}token(e,t){return this.text=this.src.slice(this.at,t),this.at=t,e}},oN="'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'",cN="'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'";Fh=Math.PI*2;mN=100,yN=1.6,Bb=vt([]);Hb={type:"venn",parse(e,t,r){let a=new sN;return r&&(a.title=r),hN(e,a),a},render:xN}});var Ub={};Ct(Ub,{venn:()=>Hb});var qb=Ve(()=>{Yb()});function $N(e,t){let r="ishikawa-beta",a=0;for(;a<13;){let i=e.charCodeAt(t+a),s=r.charCodeAt(a);if(i!==s&&(i+32!==s||i<65||i>90))break;a++}return a===13&&!Qe(e.charCodeAt(t+13))?13:a>=8&&!Qe(e.charCodeAt(t+8))?8:0}function kN(e){let t=[],r=[],a=[],i=e.length,s=0;for(;s<i;){let l=s,n=-1;for(;l<i&&Ue(e.charCodeAt(l));)e.charCodeAt(l)===10&&(n=l),l++;let o,c;if(e.charCodeAt(l)===37&&e.charCodeAt(l+1)===37)for(o=2,c=l+2;c<i;){let f=e.charCodeAt(c);if(f===10||f===13||f===8232||f===8233)break;c++}else if(l===s){let f=$N(e,s);f>0?(o=4,c=s+f):(o=6,c=e.indexOf(`
|
|
143
|
+
`,s),c===-1&&(c=i))}else n>s?(o=2,c=n+1):n===s?(o=3,c=s+1):(o=5,c=l);t.push(o),r.push(s),a.push(c),s=c}return t.push(1,0),r.push(i,i),a.push(i,i),{types:t,starts:r,ends:a}}function MN(e,t){let{types:r,starts:a,ends:i}=kN(e),s=0,l=n=>{throw it("ishikawa",e,a[s],`Expecting ${n}, got '${bN[r[s]]}'`)};if(r[s]===2){for(s++;r[s]===2||r[s]===3;)s++;r[s]!==4&&l("'SPACELINE', 'NL', 'ISHIKAWA'")}else r[s]!==4&&l("'SPACELINE', 'ISHIKAWA'");for(s++,r[s]===3&&s++;;){let n=r[s];if(n===6||n===5&&r[s+1]===6){let o=n===6?s:s+1;s=o+1,r[s]!==2&&r[s]!==3&&r[s]!==1&&l(uu),t.addNode(n===6?0:i[o-1]-a[o-1],e.slice(a[o],i[o]).trim())}else n===2||n===5?(s++,r[s]!==2&&r[s]!==3&&r[s]!==1&&l(n===5?`${uu}, 'TEXT'`:uu)):l("'SPACELINE', 'SPACELIST', 'TEXT'");for(s++;r[s]===3||r[s]===1;)s++;if(r[s]===0)return}}function NN(e,t,r,a,i){let s=ze(e.text,!1,r,a,180),l=Math.round(i*1.5),n=[],o=[],c=[],f=(u,m,b)=>{let w=u.length;for(let v=w-1;v>=0;v--)c.push({node:u[t?w-1-v:v],depth:m,parent:b,slot:v,bone:-1})};for(f(e.children,2,-1);c.length>0;){let u=c.pop();if(u.bone!==-1){o.push(u.bone);continue}let m=n.length;n.push({label:ze(u.node.text,!1,r,i,200),depth:u.depth,parent:u.parent,slot:u.slot,kids:u.node.children.length,rise:0,at:0,textEnd:0}),u.depth%2===0?o.push(m):(u.bone=m,c.push(u)),f(u.node.children,u.depth+1,m)}let p=AN;for(let u of o){let m=Math.max(n[u].label.height,l)+vN;n[u].rise=p+m/2,p+=m}let d=s.width+2*_N,g=d/2;for(let u of n){let m=u.parent===-1?void 0:n[u.parent];u.depth%2===0?(u.at=m?m.at:0,u.textEnd=u.at-(u.kids>0?(u.kids+1)*Gb:SN)-gu):(u.at=m.at-(m.kids-u.slot)*Gb,u.textEnd=u.at-gu),g=Math.max(g,u.label.width-u.textEnd)}return{node:e,label:s,boxW:d,boxH:s.height+2*IN,bones:n,rise:p+EN,reach:g}}function RN(e,t,r){return Bt(r,a=>LN(e,t,r,a))}function LN(e,t,r,a){let i=r.fontSize??16,s=Math.round(i*.875),l=r.measurer??et(r.fontFamily),n=r.padding??8;if(a)return DN(e,r);let o=e.root,c=ze(e.title,!1,l,i,4e3,1),f=c.height>0?c.height+12:0,p="",d=0,g=0,u=0,m=0;if(o){let I=ze(o.text,!1,l,i,200,1),N=Math.max(I.height+24,48),O=I.width+24+N/2,W=o.children.map((z,C)=>NN(z,C%2===0,l,i,s));for(let z of W)z.rise=Math.max(z.rise,N/2+14);let U=[],_=-jb;for(let z=0;z<W.length;z+=2){if(z>0){let C=0;for(let S=0;S<2;S++){let $=W[z-2+S],y=W[z+S];$&&(C=Math.max(C,$.reach+(y?y.boxW/2:0)))}_-=C+TN}U.push(_,_)}let j=W.length>0?_-CN:-jb;g=O,d=j,u=-N/2,m=N/2;let Z="";W.forEach((z,C)=>{let S=C%2===0?-1:1,$=U[C],y=(B,q)=>$+B-q*Bh,E=y(0,z.rise),x=S*z.rise,T=Ht-1,A=`M${h($-Bh/Wh*T)},${h(S*T/Wh)}L${h(E)},${h(x)}`,M="";for(let B of z.bones){let q=S*B.rise;if(B.depth%2===0)A+=`M${h(y(B.at,B.rise))},${h(q)}H${h(y(B.textEnd+gu,B.rise))}`;else{let R=z.bones[B.parent].rise;A+=`M${h(y(B.at,R))},${h(S*R)}L${h(y(B.at,B.rise))},${h(q)}`}let D=y(B.textEnd,B.rise);M+=Re(B.label,D-B.label.width/2,q,B.depth>2?' fill="var(--_m)"':""),d=Math.min(d,D-B.label.width)}let Y=x+S*(z.boxH/2);d=Math.min(d,E-z.boxW/2),g=Math.max(g,E+z.boxW/2),u=Math.min(u,Y-z.boxH/2),m=Math.max(m,Y+z.boxH/2),Z+=`<g class="pele-ishikawa-category" data-id="${Oe(z.node.text)}"><path class="pele-ishikawa-bones" d="${A}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",$,0,Bh/Wh,-S/Wh,"var(--_l)")+`<rect x="${h(E-z.boxW/2)}" y="${h(Y-z.boxH/2)}" width="${h(z.boxW)}" height="${h(z.boxH)}" fill="var(--_s)" stroke="var(--_b)"${st}/>`+Re(z.label,E,Y,' class="pele-label"')+(M?`<g class="pele-ishikawa-causes" font-size="${s}">${M}</g>`:"")+"</g>"});let H=N/2;p=`<path class="pele-ishikawa-spine" d="M${h(j)},0H${h(-(Ht-1))}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",0,0,1,0,"var(--_l)")+Z+`<g class="pele-ishikawa-head" data-id="${Oe(o.text)}"><path d="M0,${h(-H)}H${h(O-H)}A${h(H)},${h(H)} 0 0 1 ${h(O-H)},${h(H)}H0Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/>`+Re(I,12+I.width/2,0,' class="pele-label" font-weight="var(--_hw)"')+"</g>"}let b=Math.max(g-d,c.width),w=Math.ceil(b+2*n),v=Math.ceil(m-u+f+2*n),k=n+(b-(g-d))/2-d,L=n+f-u;return{svg:Je("ishikawa",w,v,i,r,{},Re(c,w/2,n+c.height/2,' class="pele-title" font-weight="var(--_tw)"')+(p?`<g transform="translate(${h(k)},${h(L)})">${p}</g>`:"")),width:w,height:v,links:[]}}function DN(e,t){let r=t.fontSize??16,a=Math.round(r*.875),i=t.measurer??et(t.fontFamily),s=t.padding??8,l=Math.max(140,(t.maxWidth??320)-2*s),n=ze(e.title,!1,i,r,It(t),1),o=[],c=e.root?[{node:e.root,depth:0,parent:-1}]:[],f=0;for(;c.length;){let k=c.pop(),L=o.length;o.push({...k,x:0,y:0,w:0,h:0}),f=Math.max(f,k.depth);for(let I=k.node.children.length-1;I>=0;I--)c.push({node:k.node.children[I],depth:k.depth+1,parent:L})}let p=Math.min(20,Math.max(2,(l-120)/Math.max(1,f))),d=s+(n.height?n.height+12:0),g=n.width,u="",m="";for(let k of o){k.x=s+k.depth*p;let L=Math.max(60,l-k.depth*p-20);k.label=fs(ze(k.node.text,!1,i,k.depth<2?r:a,L,k.depth<2?1:0),i,L),k.w=k.label.width+20,k.h=k.label.height+12,k.y=d,d+=k.h+12,g=Math.max(g,k.x-s+k.w);let I=k.depth<2;if(u+=`<g class="pele-node ${k.depth===0?"pele-ishikawa-head":k.depth===1?"pele-ishikawa-category":"pele-ishikawa-cause"}" data-id="${Oe(k.node.text)}">`+(I?`<rect x="${h(k.x)}" y="${h(k.y)}" width="${h(k.w)}" height="${h(k.h)}" rx="${k.depth===0?12:4}" fill="var(--_s)" stroke="var(--_b)"/>`:"")+Re(k.label,k.x+k.w/2,k.y+k.h/2,` class="pele-label"${k.depth<2?' font-weight="var(--_hw)"':""}${k.depth>1?` font-size="${a}"`:""}`)+"</g>",k.parent>=0){let N=o[k.parent],O=N.x+p/2;m+=`<path class="pele-edge" d="M${h(O)},${h(N.y+N.h)}V${h(k.y+k.h/2)}H${h(k.x)}" fill="none" stroke="var(--_b)"/>`}}let b=Math.ceil(g+2*s),w=Math.ceil(Math.max(s+n.height,d-12)+s),v=Re(n,b/2,s+n.height/2,' class="pele-title" font-weight="var(--_tw)"')+m+u;return{svg:Je("ishikawa",b,w,r,t,{},v),width:b,height:w,links:[]}}var wN,bN,uu,Bh,Wh,AN,vN,EN,Gb,SN,gu,TN,jb,CN,_N,IN,Vb,Xb=Ve(()=>{ps();tr();zt();pr();ut();wt();wN=class{constructor(){ce(this,"type","ishikawa");ce(this,"title");ce(this,"root");ce(this,"stack",[]);ce(this,"baseLevel")}addNode(e,t){let r={text:t,children:[]};if(!this.root){this.root=r,this.stack=[{level:0,node:r}];return}this.baseLevel??(this.baseLevel=e);let a=Math.max(e-this.baseLevel+1,1),i=this.stack;for(;i.length>1&&i[i.length-1].level>=a;)i.pop();i[i.length-1].node.children.push(r),i.push({level:a,node:r})}},bN=["$end","EOF","SPACELINE","NL","ISHIKAWA","SPACELIST","TEXT"];uu="'SPACELINE', 'NL', 'EOF'";Bh=.5,Wh=Math.hypot(Bh,1),AN=14,vN=6,EN=8,Gb=22,SN=18,gu=5,TN=26,jb=34,CN=28,_N=10,IN=5;Vb={type:"ishikawa",parse(e,t,r){let a=new wN;return a.title=r,MN(e,a),a},render:RN}});var Kb={};Ct(Kb,{ishikawa:()=>Vb});var Zb=Ve(()=>{Xb()});function HN(e,t,r,a,i=PN){let s=e.length;if(s===0)return{width:0,height:0};let l=r==="LR"||r==="RL",n=r==="BT"||r==="RL",o=[];for(let H=s-1;H>=0;H--)e[H].parent<0&&e[H].isGroup&&o.push(H);let c=Math.max(1,o.length),f=new Int32Array(s).fill(-1);o.forEach((H,z)=>f[H]=z);let p=new Uint8Array(s);for(let H=0;H<s;H++)e[H].parent>=0&&(p[e[H].parent]=1);let d=new Float64Array(c).fill(i),g=i,u=H=>{let z=H,C=i;for(let $=0;e[z].parent>=0&&$<Qb;$++)z=e[z].parent,f[z]<0&&(C+=Math.max(e[z].padX,e[z].padTop,e[z].padBottom));let S=Math.max(0,f[z]);return C>d[S]&&(d[S]=C),C>g&&(g=C),S},m=new Int32Array(s).fill(-1),b=[];for(let H=0;H<s;H++)f[H]>=0||(!e[H].isGroup||!p[H])&&(m[H]=b.length,b.push(H));let w=H=>l?H.w:H.h,v=H=>l?H.h:H.w,k=b.map(H=>Zi(v(e[H]),w(e[H]))),L=[],I=[],N=1;{let H=new Set;for(let z=0;z<t.length;z++){let C=t[z],S=m[C.src],$=m[C.dst];if(S<0||$<0||S===$)continue;let y=Math.min(S,$)*b.length+Math.max(S,$);(C.labelW>0||H.has(y))&&(N=2),H.add(y),L.push(Qi(S,$,C.minlen,l?C.labelH:C.labelW,l?C.labelW:C.labelH)),I.push(z)}}jn(k,L),Vn(k,L,N);let O=L.length,W=Int32Array.from(b,u),U=(H,z)=>{let C=d.map((V,me)=>z[me]?Math.max(V,t$):V),S=new Uint8Array(c),$=0,y=new Int32Array(O);for(let V=0;V<O;V++)y[V]=Math.abs(k[L[V].head].rank-k[L[V].tail].rank),H[V]||($+=y[V]-1);let E=$>FN,x=b.length+(E?0:$),T=new Int32Array(x),A=new Int32Array(x),M=new Float64Array(x),Y=new Float64Array(x),B=new Uint8Array(x),q=0;for(let V=0;V<b.length;V++)T[V]=k[V].rank,A[V]=W[V],M[V]=k[V].w,Y[V]=k[V].h,T[V]>q&&(q=T[V]);let D=new Int32Array(O).fill(-1),R=new Int32Array(O).fill(-1),P=[];{let V=b.length;for(let me=0;me<O;me++){let ae=L[me],$e=ae.reversed?ae.head:ae.tail,ve=ae.reversed?ae.tail:ae.head;if(E||y[me]<2||H[me]){P.push($e,ve);continue}let Te=T[$e],De=T[ve],_e=-1;ae.labelW>0&&(_e=Te+(De-Te>>1),N===2&&!(_e&1)&&_e--),D[me]=V;let He=$e;for(let Ee=Te+1;Ee<De;Ee++){let qe=V++;T[qe]=Ee,A[qe]=A[$e]+Math.round((A[ve]-A[$e])*(Ee-Te)/(De-Te)),B[qe]=1,Ee===_e&&(M[qe]=ae.labelW,Y[qe]=ae.labelH,R[me]=qe),P.push(He,qe),He=qe}P.push(He,ve)}}let G=new Int32Array(x+1),X=new Int32Array(x+1);for(let V=0;V<P.length;V+=2)X[P[V]+1]++,G[P[V+1]+1]++;for(let V=0;V<x;V++)G[V+1]+=G[V],X[V+1]+=X[V];let Q=new Int32Array(P.length/2),J=new Int32Array(P.length/2);{let V=G.slice(0,x),me=X.slice(0,x);for(let ae=0;ae<P.length;ae+=2)J[me[P[ae]]++]=P[ae+1],Q[V[P[ae+1]]++]=P[ae]}let F=[];for(let V=0;V<=q;V++)F.push([]);for(let V=0;V<x;V++)F[T[V]].push(V);let K=new Float64Array(x),re=new Float64Array(x),ne=V=>{V.sort((me,ae)=>A[me]-A[ae]||re[me]-re[ae]||me-ae);for(let me=0;me<V.length;me++)K[V[me]]=me};for(let V of F){for(let me=0;me<V.length;me++)re[V[me]]=me;ne(V)}for(let V=0;V<zN&&q>0;V++){let me=(V&1)===0;for(let ae=1;ae<=q;ae++){let $e=F[me?ae:q-ae],ve=me?G:X,Te=me?Q:J;for(let De of $e){let _e=0,He=ve[De+1]-ve[De];for(let Ee=ve[De];Ee<ve[De+1];Ee++)_e+=K[Te[Ee]];re[De]=He>0?_e/He:K[De]}ne($e)}}let de=(V,me)=>B[V]||B[me]?a.edgeSep:a.nodeSep,ie=(V,me)=>{let ae=0;for(;ae<V.length;){let $e=ae;for(;$e+1<V.length&&A[V[$e+1]]===A[V[ae]];)$e++;me(V,ae,$e),ae=$e+1}},se=(V,me,ae)=>{let $e=M[V[me]];for(let ve=me;ve<ae;ve++)$e+=de(V[ve],V[ve+1])+M[V[ve+1]];return $e},ee=new Float64Array(c),te=o.length>0?ON:0;for(let V=0;V<o.length;V++){let me=e[o[V]];ee[V]=Math.max(0,me.minW-2*C[V]),me.padTop>te&&(te=me.padTop)}for(let V of F)ie(V,(me,ae,$e)=>{let ve=se(V,ae,$e);ve>ee[A[V[ae]]]&&(ee[A[V[ae]]]=ve)});let fe=new Float64Array(c+1);for(let V=0;V<c;V++)fe[V+1]=fe[V]+ee[V]+2*C[V];let ye=new Float64Array(x),le=new Float64Array(x),we=(V,me,ae)=>{let $e=A[V[me]],ve=(fe[$e]+C[$e]+(fe[$e+1]-C[$e])-se(V,me,ae))/2;for(let Te=me;Te<=ae;Te++)ye[V[Te]]=ve+M[V[Te]]/2,Te<ae&&(ve+=M[V[Te]]+de(V[Te],V[Te+1]))},pe=(V,me,ae)=>{let $e=A[V[me]],ve=fe[$e]+C[$e];for(let De=me;De<=ae;De++){let _e=V[De];ye[_e]=Math.max(le[_e],ve+M[_e]/2),De<ae&&(ve=ye[_e]+M[_e]/2+de(_e,V[De+1]))}let Te=fe[$e+1]-C[$e];for(let De=ae;De>=me;De--){let _e=V[De];ye[_e]=Math.min(ye[_e],Te-M[_e]/2),De>me&&(Te=ye[_e]-M[_e]/2-de(V[De-1],_e))}};for(let V of F)ie(V,we);for(let V=0;V<4&&q>0;V++){let me=(V&1)===0;for(let ae=1;ae<=q;ae++){let $e=F[me?ae:q-ae],ve=me?G:X,Te=me?Q:J;for(let De of $e){let _e=0,He=0;for(let Ee=ve[De];Ee<ve[De+1];Ee++)A[Te[Ee]]===A[De]&&(_e+=ye[Te[Ee]],He++);le[De]=He>0?_e/He:ye[De]}ie($e,pe)}}let ge=new Float64Array(q+1),Ae=new Float64Array(q+1),Se=new Float64Array(q+1).fill(a.rankSep/N);if(H.some(V=>V===1)){let V=a.rankSep/N;Se.fill(V/BN);for(let me=0;me<O;me++){let ae=L[me],$e=ae.reversed?ae.head:ae.tail,ve=ae.reversed?ae.tail:ae.head;if(H[me]){if(ae.labelH<=0||y[me]>N)continue;let De=Math.min(V,(ae.labelH+2*yu-Math.min(Y[$e],Y[ve])/2)/y[me]);for(let _e=T[$e];_e<T[ve];_e++)De>Se[_e]&&(Se[_e]=De);continue}let Te=D[me];if(Te<0||y[me]<=N*ae.minlen){for(let De=T[$e];De<T[ve];De++)Se[De]=V;continue}for(let De=Te-1;De<Te+y[me]-1;De++){let _e=De<Te?$e:De,He=De+1<Te+y[me]-1?De+1:ve;(A[_e]!==A[He]||Math.abs(ye[_e]-ye[He])>=.5)&&(Se[T[_e]]=V)}}}let oe=te+g;for(let V=0;V<=q;V++){let me=0;for(let ae of F[V])Y[ae]>me&&(me=Y[ae]);ge[V]=oe,Ae[V]=oe+me,oe+=me+(V===q?0:Se[V])}let ue=oe+g,xe=fe[c],Ie=V=>n?te+ue-V:V,Le=(V,me)=>l?Ie(me):V,We=(V,me)=>l?V:Ie(me),he=l?1:0;for(let V=0;V<b.length;V++){let me=e[b[V]],ae=(ge[T[V]]+Ae[T[V]])/2;me.x=Le(ye[V],ae),me.y=We(ye[V],ae)}for(let V=0;V<o.length;V++){let me=e[o[V]],ae=(fe[V]+fe[V+1])/2,$e=fe[V+1]-fe[V];me.x=l?ue/2:ae,me.y=l?ae:ue/2,me.w=l?ue:$e,me.h=l?$e:ue,me.padTop=te}let ke=new Int32Array(s),Ce=[];for(let V=0;V<s;V++){if(!e[V].isGroup||f[V]>=0||m[V]>=0)continue;let me=0;for(let ae=e[V].parent;ae>=0&&me<Qb;ae=e[ae].parent)me++;ke[V]=me,Ce.push(V)}Ce.sort((V,me)=>ke[me]-ke[V]||V-me);let be=new Float64Array(s*4);for(let V=0;V<s;V++)be[V*4]=1/0,be[V*4+1]=1/0,be[V*4+2]=-1/0,be[V*4+3]=-1/0;let Me=(V,me)=>{me.x-me.w/2<be[V*4]&&(be[V*4]=me.x-me.w/2),me.y-me.h/2<be[V*4+1]&&(be[V*4+1]=me.y-me.h/2),me.x+me.w/2>be[V*4+2]&&(be[V*4+2]=me.x+me.w/2),me.y+me.h/2>be[V*4+3]&&(be[V*4+3]=me.y+me.h/2)};for(let V of b)e[V].parent>=0&&f[e[V].parent]<0&&Me(e[V].parent,e[V]);for(let V of Ce){let me=e[V];if(be[V*4]===1/0)continue;let ae=Math.max(be[V*4+2]-be[V*4]+2*me.padX,me.minW);me.x=(be[V*4]+be[V*4+2])/2,me.w=ae,me.y=(be[V*4+1]-me.padTop+be[V*4+3]+me.padBottom)/2,me.h=be[V*4+3]-be[V*4+1]+me.padTop+me.padBottom,me.parent>=0&&f[me.parent]<0&&Me(me.parent,me)}for(let V of t)V.route=[];for(let V=0;V<O;V++){let me=L[V],ae=t[I[V]],$e=me.reversed?me.head:me.tail,ve=me.reversed?me.tail:me.head,Te=[ye[$e],Ae[T[$e]]-(Ae[T[$e]]-ge[T[$e]]-Y[$e])/2],De=D[V];if(De>=0)for(let Ee=De;Ee<De+y[V]-1;Ee++)Te.push(ye[Ee],ge[T[Ee]]),Ae[T[Ee]]>ge[T[Ee]]&&Te.push(ye[Ee],Ae[T[Ee]]);Te.push(ye[ve],ge[T[ve]]+(Ae[T[ve]]-ge[T[ve]]-Y[ve])/2);let _e=[];for(let Ee=0;Ee<Te.length;Ee+=2)_e.push(Le(Te[Ee],Te[Ee+1]),We(Te[Ee],Te[Ee+1]),he);if(me.reversed)for(let Ee=0,qe=_e.length-3;Ee<qe;Ee+=3,qe-=3)for(let Ge=0;Ge<2;Ge++){let rt=_e[Ee+Ge];_e[Ee+Ge]=_e[qe+Ge],_e[qe+Ge]=rt}ae.route=_e;let He=R[V];if(He>=0){let Ee=(ge[T[He]]+Ae[T[He]])/2;ae.labelX=Le(ye[He],Ee),ae.labelY=We(ye[He],Ee)}else ae.labelX=(_e[0]+_e[_e.length-3])/2,ae.labelY=(_e[1]+_e[_e.length-2])/2}for(let V of t){if(V.route.length>0||V.src===V.dst)continue;let me=e[V.src],ae=e[V.dst],[$e,ve]=a$(me,ae),[Te,De]=a$(ae,me),_e=Math.abs(Te-$e)>Math.abs(De-ve)?1:0;V.route=[$e,ve,_e,Te,De,_e],V.labelX=($e+Te)/2,V.labelY=(ve+De)/2}let Ne=new Uint8Array(O),Be=t.reduce((V,me)=>V+me.route.length/3,0),Pe=O*(b.length+t.length+Be);if(Pe<=mu){let V=_e=>(ge[T[_e]]+Ae[T[_e]])/2,me=t.map(_e=>[l?_e.labelY:_e.labelX,Ie(l?_e.labelX:_e.labelY)]),ae=(_e,He,Ee,qe,Ge,rt,ct,tt)=>Ee>Ge-ct/2&&_e<Ge+ct/2&&qe>rt-tt/2&&He<rt+tt/2,$e=(_e,He,Ee,qe,Ge,rt,ct)=>{for(let tt=0;tt<b.length;tt++)if(tt!==Ge&&tt!==rt&&ae(_e,He,Ee,qe,ye[tt],V(tt),M[tt]+8,Y[tt]+8))return!1;for(let tt=0;tt<t.length;tt++){let lt=t[tt];if(tt!==ct&<.labelW>0&<.src!==lt.dst&&ae(_e,He,Ee,qe,me[tt][0],me[tt][1],l?lt.labelH:lt.labelW,l?lt.labelW:lt.labelH))return!1}return!0},ve=(_e,He,Ee,qe,Ge)=>{let rt=0;for(let ct=0;ct<t.length;ct++){if(ct===Ge)continue;let tt=t[ct].route;for(let lt=3;lt<tt.length;lt+=3)if(Math.max(tt[lt-3],tt[lt])>_e&&Math.min(tt[lt-3],tt[lt])<Ee&&Math.max(tt[lt-2],tt[lt+1])>He&&Math.min(tt[lt-2],tt[lt+1])<qe){rt++;break}}return rt},Te=(_e,He,Ee)=>{let qe=0;for(let Ge=0;Ge<t.length;Ge++){let rt=t[Ge].route;if(Ge===Ee||rt.length===0)continue;let ct=rt.length-3;(Math.abs(rt[0]-_e)<1&&Math.abs(rt[1]-He)<1||Math.abs(rt[ct]-_e)<1&&Math.abs(rt[ct+1]-He)<1)&&qe++}return qe},De=(_e,He,Ee,qe,Ge)=>{let rt=Math.abs(Ee-_e)<.5,ct=rt?Math.min(He,qe):Math.min(_e,Ee),tt=rt?Math.max(He,qe):Math.max(_e,Ee),lt=rt?_e:He;for(let nt=0;nt<t.length;nt++){let Wt=t[nt];if(nt===Ge||Wt.src===t[Ge].src||Wt.dst===t[Ge].dst)continue;let Tt=Wt.route;for(let kt=3;kt<Tt.length;kt+=3){let Ft=Tt[kt-3+(rt?0:1)],Ye=Tt[kt+(rt?0:1)];if(Math.abs(Ft-lt)>=Jb||Math.abs(Ye-lt)>=Jb)continue;let ht=Tt[kt-3+(rt?1:0)],yt=Tt[kt+(rt?1:0)];if(Math.min(tt,Math.max(ht,yt))-Math.max(ct,Math.min(ht,yt))>1)return!0}}return!1};for(let _e=0;_e<O;_e++){let He=L[_e],Ee=I[_e],qe=t[Ee],Ge=He.tail,rt=He.head;if(A[Ge]===A[rt]||Math.abs(ye[rt]-ye[Ge])<1)continue;let ct=ye[Ge],tt=ye[rt],lt=V(Ge),nt=V(rt),Wt=Math.sign(tt-ct),Tt=Math.sign(nt-lt),kt=(Ye,ht)=>{for(let Ze=2;Ze<Ye.length;Ze+=2)if(!$e(Math.min(Ye[Ze-2],Ye[Ze])-ht,Math.min(Ye[Ze-1],Ye[Ze+1])-ht,Math.max(Ye[Ze-2],Ye[Ze])+ht,Math.max(Ye[Ze-1],Ye[Ze+1])+ht,Ge,rt,Ee)||De(Le(Ye[Ze-2],Ye[Ze-1]),We(Ye[Ze-2],Ye[Ze-1]),Le(Ye[Ze],Ye[Ze+1]),We(Ye[Ze],Ye[Ze+1]),Ee))return!1;let yt=0,ot=0,er=-1;if(qe.labelW>0){let Ze=He.labelW,xt=He.labelH;for(let Dt=2;Dt<Ye.length;Dt+=2){let Nt=(Ye[Dt-2]+Ye[Dt])/2,ir=(Ye[Dt-1]+Ye[Dt+1])/2,ia=Math.abs(Ye[Dt]-Ye[Dt-2]),ka=Math.abs(Ye[Dt+1]-Ye[Dt-1]),Tn=ia+ka;if(Tn<=er||(ia>0?ia<Ze+8:ka<xt+8)||Nt-Ze/2<0||Nt+Ze/2>xe||ir-xt/2<0||ir+xt/2>ue||!$e(Nt-Ze/2,ir-xt/2,Nt+Ze/2,ir+xt/2,-1,-1,Ee))continue;let Cn=Le(Nt,ir),_n=We(Nt,ir);ve(Cn-qe.labelW/2,_n-qe.labelH/2,Cn+qe.labelW/2,_n+qe.labelH/2,Ee)>0||(yt=Nt,ot=ir,er=Tn)}if(er<0)return!1}let Et=[Ye[0],Ye[1]];for(let Ze=2;Ze<Ye.length;Ze+=2){let xt=Ye[Ze]-Ye[Ze-2],Dt=Ye[Ze+1]-Ye[Ze-1],Nt=Math.abs(xt)+Math.abs(Dt),ir=Ze>2?yu:0,ia=Ze+2<Ye.length?yu:0;Nt>ir+ia+1&&(ir&&Et.push(Ye[Ze-2]+xt/Nt*ir,Ye[Ze-1]+Dt/Nt*ir),ia&&Et.push(Ye[Ze]-xt/Nt*ia,Ye[Ze+1]-Dt/Nt*ia)),Et.push(Ye[Ze],Ye[Ze+1])}qe.route=[];for(let Ze=0;Ze<Et.length;Ze+=2){let xt=Ze===0?Et[0]!==Et[2]:Et[Ze]!==Et[Ze-2];qe.route.push(Le(Et[Ze],Et[Ze+1]),We(Et[Ze],Et[Ze+1]),xt?1-he:he)}return qe.labelW>0&&(qe.labelX=Le(yt,ot),qe.labelY=We(yt,ot),me[Ee]=[yt,ot]),Ne[_e]=1,!0};if(kt([ct+Wt*M[Ge]/2,lt,tt,lt,tt,nt-Tt*Y[rt]/2],2)||kt([ct,lt+Tt*Y[Ge]/2,ct,nt,tt-Wt*M[rt]/2,nt],2)||Pe>mu/e$)continue;let Ft=[];for(let Ye of A[Ge]<A[rt]?[A[rt],A[Ge]]:[A[Ge],A[rt]]){let ht=Math.max(C[Ye]-r$,Math.min(C[Ye]/2,t$-r$));for(let yt of[fe[Ye]+ht,fe[Ye+1]-ht]){if(Math.abs(yt-ct)<M[Ge]/2+4||Math.abs(yt-tt)<M[rt]/2+4)continue;let ot=[ct+Math.sign(yt-ct)*M[Ge]/2,lt,yt,lt,yt,nt,tt+Math.sign(yt-tt)*M[rt]/2,nt],er=(Te(Le(ot[0],ot[1]),We(ot[0],ot[1]),Ee)+Te(Le(ot[6],ot[7]),We(ot[6],ot[7]),Ee))*1e6;for(let Et=2;Et<ot.length;Et+=2){let Ze=Le(ot[Et-2],ot[Et-1]),xt=We(ot[Et-2],ot[Et-1]),Dt=Le(ot[Et],ot[Et+1]),Nt=We(ot[Et],ot[Et+1]);er+=ve(Math.min(Ze,Dt),Math.min(xt,Nt),Math.max(Ze,Dt),Math.max(xt,Nt),Ee)*1e6+Math.abs(Dt-Ze)+Math.abs(Nt-xt)}Ft.push({pts:ot,cost:er,lane:Ye})}}Ft.sort((Ye,ht)=>Ye.cost-ht.cost);for(let Ye of Ft)if(kt(Ye.pts,1)){S[Ye.lane]=1;break}}}return{width:l?ue:xe,height:l?xe:ue,routed:Ne,margins:S,work:Pe}},_=new Uint8Array(O),j=new Uint8Array(c),Z=U(_,j);for(let H=0;H<WN&&Z.work<=mu/e$;H++){let z=H===0?Z.routed:_.map((C,S)=>C&Z.routed[S]);if(z.every((C,S)=>C===_[S])&&Z.margins.every((C,S)=>C===j[S]))break;_=z,j=Z.margins,Z=U(_,j)}return _.some((H,z)=>H&&!Z.routed[z])&&(Z=U(new Uint8Array(O),new Uint8Array(c))),{width:Z.width,height:Z.height}}function a$(e,t){let r=t.x-e.x,a=t.y-e.y,i=Math.max(e.w/2,.5),s=Math.max(e.h/2,.5);if(Math.abs(r)<i&&Math.abs(a)<s){let n=i-Math.abs(r),o=s-Math.abs(a);return n<o?[e.x+(r<0?-i:i),t.y]:[t.x,e.y+(a<0?-s:s)]}let l=Math.min(r!==0?i/Math.abs(r):1/0,a!==0?s/Math.abs(a):1/0);return[e.x+r*l,e.y+a*l]}function YN(e){let t=!1;for(let r of e.nodes)r.isGroup?r.dir=void 0:r.parentId===void 0&&(t=!0);if(t){for(let r of e.nodes)!r.isGroup&&r.parentId===void 0&&(r.parentId=i$);e.nodes.push({id:i$,label:void 0,labelType:"text",shape:"rect",isGroup:!0,parentId:void 0,cssStyles:[],cssCompiledStyles:[],cssClasses:"",dir:void 0})}}function UN(e,t,r,a,i,s,l){let n=e.x-e.w/2,o=e.y-e.h/2,c=s==="LR"||s==="RL",f=c?n+e.padTop/2:e.x,p=c?e.y:o+e.padTop/2,d=Re(t,f,p,` class="pele-cluster-label" fill="var(--_m)"${r.text}`,l);return`<g class="pele-cluster pele-lane${a}" data-id="${i}"><rect x="${h(n)}" y="${h(o)}" width="${h(e.w)}" height="${h(e.h)}" fill="none" stroke="var(--_b)"/><rect x="${h(n)}" y="${h(o)}" width="${h(c?e.padTop:e.w)}" height="${h(c?e.h:e.padTop)}" fill="var(--_a)" stroke="var(--_b)"${r.shape}/>`+(c&&d?`<g transform="rotate(-90 ${h(f)} ${h(p)})">${d}</g>`:d)+"</g>"}var ON,PN,zN,FN,Qb,mu,Jb,WN,e$,yu,t$,r$,BN,i$,qN,s$,n$=Ve(()=>{Dd();pr();ut();ON=34,PN=24,zN=8,FN=2e4,Qb=1e4,mu=2e6,Jb=4,WN=3,e$=8,yu=20,t$=20,r$=14,BN=3;i$="__swimlane_default__";qN={type:"swimlane",prepare:YN,layout:(e,t,r,a,i)=>HN(e,t,r,a,i?12:void 0),drawGroup:UN},s$={type:"swimlane",math:!0,parse:Ro.parse,render:(e,t,r)=>Ld(e,t,r,qN)}});var l$={};Ct(l$,{swimlane:()=>s$});var o$=Ve(()=>{n$()});var Fa="#ffffff";var In="#1e1e1e",to={flowchart:{curve:"linear"},maxEdges:500,maxTextSize:5e4};var Ur=class{constructor({converter:t}){this.convert=(r,a)=>this.converter(r,{...a,fontSize:a.fontSize||20}),this.converter=t}};var _r;(function(e){e.ROUND="round",e.STADIUM="stadium",e.DOUBLECIRCLE="doublecircle",e.CIRCLE="circle",e.DIAMOND="diamond",e.CYLINDER="cylinder"})(_r||(_r={}));var ai;(function(e){e.COLOR="color"})(ai||(ai={}));var Tr;(function(e){e.FILL="fill",e.STROKE="stroke",e.STROKE_WIDTH="stroke-width",e.STROKE_DASHARRAY="stroke-dasharray"})(Tr||(Tr={}));var vu=yk(Au(),1),wk=e=>{let t="\uE000";for(;e.includes(t);)t+="\uE000";return(0,vu.removeMarkdown)(e.replace(/\n/g,t)).replace(new RegExp(t,"g"),`
|
|
144
|
+
`)},ji,bk=()=>{if(ji!==void 0)return ji;if(typeof document>"u")return ji=null,ji;try{ji=document.createElement("canvas").getContext("2d")}catch{ji=null}return ji},Wa=(e,t)=>{let r=bk();return r?(r.font=`${t}px Excalifont, sans-serif`,r.measureText(e).width):e.length*t*.6},$k={arrow_circle:{endArrowhead:"circle"},arrow_cross:{endArrowhead:"bar"},arrow_open:{endArrowhead:null,startArrowhead:null},double_arrow_circle:{endArrowhead:"circle",startArrowhead:"circle"},double_arrow_cross:{endArrowhead:"bar",startArrowhead:"bar"},double_arrow_point:{endArrowhead:"arrow",startArrowhead:"arrow"}},Eu=e=>$k[e],ii=e=>{let t=e.text;return e.labelType==="markdown"&&(t=wk(t)),kk(t)},kk=e=>{let t=/\s?(fa|fab):[a-zA-Z0-9-]+/g;return e.replace(t,"")},ki=e=>{let t={};return Object.keys(e).forEach(r=>{switch(r){case Tr.FILL:{t.backgroundColor=e[r],t.fillStyle="solid";break}case Tr.STROKE:{t.strokeColor=e[r];break}case Tr.STROKE_WIDTH:{t.strokeWidth=Number(e[r]?.split("px")[0]);break}case Tr.STROKE_DASHARRAY:{t.strokeStyle="dashed";break}}}),t},Nn=e=>{let t={};return Object.keys(e).forEach(r=>{switch(r){case ai.COLOR:{t.strokeColor=e[r];break}}}),t};var Rn=(e,t)=>[e,t],qr=e=>{let t={type:"line",x:e.startX,y:e.startY,points:[Rn(0,0),Rn(e.endX-e.startX,e.endY-e.startY)],width:e.endX-e.startX,height:e.endY-e.startY,strokeStyle:e.strokeStyle||"solid",strokeColor:e.strokeColor||"#000",strokeWidth:e.strokeWidth||1};return e.groupId&&Object.assign(t,{groupIds:[e.groupId]}),e.id&&Object.assign(t,{id:e.id}),t},fa=e=>{let t={type:"text",x:e.x,y:e.y,width:e.width,height:e.height,text:e.text||"",fontSize:e.fontSize,verticalAlign:"top",strokeColor:e.color};return e.textAlign&&Object.assign(t,{textAlign:e.textAlign}),e.groupId&&Object.assign(t,{groupIds:[e.groupId]}),e.id&&Object.assign(t,{id:e.id}),t},si=e=>{let t={text:e?.label?.text||"",fontSize:e?.label?.fontSize,textAlign:e.label?.textAlign,verticalAlign:e.label?.verticalAlign||"middle",strokeColor:e.label?.color||"#000",...e.groupId?{groupIds:[e.groupId]}:{}},r={};e.type==="rectangle"&&e.subtype==="activation"&&(r={backgroundColor:"#e9ecef",fillStyle:"solid"});let a={id:e.id,type:e.type,x:e.x,y:e.y,width:e.width,height:e.height,label:t,strokeStyle:e?.strokeStyle,strokeWidth:e?.strokeWidth,strokeColor:e?.strokeColor,backgroundColor:e?.bgColor,fillStyle:"solid",...r};return e.groupId&&Object.assign(a,{groupIds:[e.groupId]}),a},Cs=e=>{let t={type:"arrow",x:e.startX,y:e.startY,points:e.points?.map(([r,a])=>Rn(r,a))||[Rn(0,0),Rn(e.endX-e.startX,e.endY-e.startY)],width:e.endX-e.startX,height:e.endY-e.startY,strokeStyle:e?.strokeStyle||"solid",endArrowhead:e?.endArrowhead||null,startArrowhead:e?.startArrowhead||null,label:{text:e?.label?.text||"",fontSize:16,textAlign:e?.label?.textAlign,verticalAlign:e?.label?.verticalAlign,...e?.label?.labelPosition!==void 0?{labelPosition:e.label.labelPosition}:{}},roundness:e.roundness===void 0?{type:2}:e.roundness,start:e.start,end:e.end};return e.groupId&&Object.assign(t,{groupIds:[e.groupId]}),t};var Mk=(e,t)=>[e,t],Ak=32,_u=.62,vk=12,Ek=12,Iu=1.25,Dn=5,Sk=8,Su=3*Math.PI/2,Nu=(e,t)=>{let r=Math.max(...e.split(`
|
|
145
|
+
`).map(a=>a.length));return Math.max(20,Math.ceil(r*t*_u))},Ru=e=>({x:e.x??0,y:e.y??0,width:e.width||0,height:e.height||0}),rd=e=>{let{x:t,y:r,width:a,height:i}=Ru(e);return{x:t+a/2,y:r+i/2}},Tk=(e,t)=>{let{x:r,y:a,width:i,height:s}=Ru(t);return e.x>=r&&e.x<=r+i&&e.y>=a&&e.y<=a+s},Tu=(e,t)=>{let r=rd(e),a=t.x-r.x,i=t.y-r.y,s=(e.width||0)/2,l=(e.height||0)/2,n=Math.min(a?s/Math.abs(a):Number.POSITIVE_INFINITY,i?l/Math.abs(i):Number.POSITIVE_INFINITY);return Number.isFinite(n)?{x:r.x+a*n,y:r.y+i*n}:r},Cu=(e,t,r,a)=>{let i=r==="start"?e:e.slice().reverse(),s=i.findIndex(n=>!Tk(n,t));if(s===-1){let n=[...i];return n[0]=Tu(t,a),r==="start"?n:n.reverse()}let l=[Tu(t,i[s]),...i.slice(s)];return r==="start"?l:l.reverse()},Ck=(e,t)=>new Map(e.subGraphs.map(r=>{let a=Nu(ii(r),t),i=r.laneHeader?0:a+Ak*2,s=Math.max(r.width,i),l=r.x-(s-r.width)/2;return[r.id,{x:l,width:s,leftExpansion:r.x-l,rightExpansion:l+s-(r.x+r.width)}]})),_k=(e,t)=>{let r=new Map;e.subGraphs.forEach(n=>{n.nodeIds.forEach(o=>r.set(o,n.id))});let a=[...Object.keys(e.vertices),...e.subGraphs.map(n=>n.id)],i=n=>{let o=new Set,c=n;for(;r.has(c)&&!o.has(c);)o.add(c),c=r.get(c);return c},s=new Map;a.forEach(n=>{let o=i(n),c=s.get(o)||[];c.push(n),s.set(o,c)});let l=new Map(a.map(n=>[n,0]));return e.subGraphs.forEach(n=>{if(r.has(n.id)||!ii(n).includes(`
|
|
146
|
+
`))return;let o=t.get(n.id);if(!o||!o.leftExpansion&&!o.rightExpansion)return;let c=n.x+n.width/2;s.forEach((f,p)=>{if(p===n.id)return;let d=e.subGraphs.find(b=>b.id===p),g=e.vertices[p],m=(d?d.x+d.width/2:g?g.x+g.width/2:c)<c?-o.leftExpansion:o.rightExpansion;f.forEach(b=>l.set(b,(l.get(b)||0)+m))})}),l},Ik=(e,t,r)=>Math.min(...r.map(a=>{let i=e.vertices[a];return i?i.y:e.subGraphs.find(s=>s.id===a&&s.id!==t)?.y??Number.POSITIVE_INFINITY})),Lu=(e,t)=>{let r=e.split(`
|
|
147
|
+
`).length;return r<2?0:Math.ceil(r*t*Iu+Dn*2)},Nk=(e,t)=>{let r=[];return e.subGraphs.forEach(a=>{let i=a.laneHeader?0:Lu(ii(a),t);if(!i)return;let s=Ik(e,a.id,a.nodeIds);if(!Number.isFinite(s))return;let l=Math.ceil(i-(s-a.y));if(l<=0)return;let n=r.find(o=>Math.abs(o.y-s)<.5);if(n){n.y=Math.min(n.y,s),n.amount=Math.max(n.amount,l);return}r.push({y:s,amount:l})}),r.sort((a,i)=>a.y-i.y)},Ln=(e,t)=>e.reduce((r,a)=>a.y<=t?r+a.amount:r,0),Rk=(e,t,r)=>{let a=new Map,i=new Map(e.subGraphs.map(l=>[l.id,l])),s=l=>{let n=a.get(l);if(n)return n;let o=i.get(l);if(!o)return null;let c=o.y+Ln(t,o.y),f=o.laneHeader?0:Lu(ii(o),r),p=c+Math.max(o.height,f);o.nodeIds.forEach(g=>{let u=e.vertices[g];if(u){let b=u.y+Ln(t,u.y)+u.height;b>p&&(p=b+Dn*2);return}if(g===l)return;let m=s(g);m&&m.y+m.height>p&&(p=m.y+m.height+Dn*2)});let d={y:c,height:p-c};return a.set(l,d),d};return e.subGraphs.forEach(l=>s(l.id)),a},Lk=(e,t,r,a)=>{let i=a||20;if(e!==_r.CYLINDER||!t)return i;let s=Math.max(20,r-vk);if(Nu(t,i)<=s)return i;let n=Math.max(...t.split(`
|
|
148
|
+
`).map(o=>o.length));return Math.max(Ek,Math.floor(s/(n*_u)))},Dk=e=>({elbowed:!0,roundness:null,fixedSegments:e.slice(2,-1).map((t,r)=>({start:e[r+1],end:t,index:r+2}))}),Ok=({width:e,height:t,vertical:r},a)=>{let i=r?{x:a.x,y:a.y,width:e,height:a.height}:{x:a.x,y:a.y,width:a.width,height:t},s=a.containerStyle.strokeColor??In,l=[qr({type:"line",startX:r?i.x+i.width:i.x,startY:r?i.y:i.y+i.height,endX:i.x+i.width,endY:i.y+i.height,strokeColor:s,strokeWidth:a.containerStyle.strokeWidth??2,strokeStyle:a.containerStyle.strokeStyle})];if(a.text){let[n,o]=r?[i.height,i.width]:[i.width,i.height];l.unshift({id:a.id,type:"rectangle",x:i.x+(i.width-n)/2,y:i.y+(i.height-o)/2,width:n,height:o,...r?{angle:Su}:{},strokeColor:"transparent",backgroundColor:"transparent",label:{text:a.text,fontSize:a.fontSize,strokeColor:s,...a.labelStyle,...r?{angle:Su}:{}}})}return l},Du=new Ur({converter:(e,t)=>{let r=[],a=[],i=[],s=[],l=t.fontSize,n=l||20,o=Nk(e,n),c=Rk(e,o,n),f=Ck(e,n),p=_k(e,f),d=new Set(e.subGraphs.map(u=>u.id)),g=new Set(e.subGraphs.filter(u=>{let m=f.get(u.id),b=c.get(u.id);return ii(u).includes(`
|
|
149
|
+
`)&&m?.width!==u.width||b?.height!==u.height}).map(u=>u.id));return e.subGraphs.slice().reverse().forEach(u=>{let m=[],b=ii(u),w=n,v=f.get(u.id)||{x:u.x,width:u.width},k=v.width,L=v.x+(p.get(u.id)||0),I=c.get(u.id)||u,N=ki(u.containerStyle),O=Nn(u.labelStyle),W={id:u.id,type:"rectangle",groupIds:m,x:L,y:I.y,width:k,height:I.height,...N};if(r.push(W),u.laneHeader)s.push(...Ok(u.laneHeader,{id:`${u.id}__title`,x:L,y:I.y,width:k,height:I.height,text:b,fontSize:w,containerStyle:N,labelStyle:O}));else if(b){let U=N.strokeWidth??2,_=b.split(`
|
|
150
|
+
`),j=Math.min(k-U*2,Math.max(..._.map(Z=>Wa(Z,w)))+(Dn+Sk)*2+2);s.push({id:`${u.id}__title`,type:"rectangle",groupIds:m,x:L+(k-j)/2,y:I.y+U+4,width:Math.max(1,j),height:_.length*w*Iu+Dn*2,strokeColor:"transparent",backgroundColor:N.backgroundColor??Fa,fillStyle:"solid",roughness:0,label:{groupIds:m,text:b,fontSize:w,strokeColor:N.strokeColor??In,...O}})}}),Object.values(e.vertices).forEach(u=>{if(!u)return;let m=[],b=ii(u),w=u.x+(p.get(u.id)||0),v=u.y+Ln(o,u.y),k=Lk(u.type,b,u.width,l),L=ki(u.containerStyle),I=Nn(u.labelStyle),N={id:u.id,type:"rectangle",groupIds:m,x:w,y:v,width:u.width,height:u.height,strokeWidth:2,...u.type!==_r.DOUBLECIRCLE&&{label:{groupIds:m,text:b,fontSize:k,...I}},link:u.link||null,backgroundColor:Fa,fillStyle:"solid",...L},O;switch(u.type){case _r.STADIUM:{N={...N,roundness:{type:3}};break}case _r.ROUND:{N={...N,roundness:{type:3}};break}case _r.DOUBLECIRCLE:{m.push(`doublecircle_${u.id}}`),O={type:"ellipse",groupIds:m,x:w+5,y:v+5,width:u.width-5*2,height:u.height-5*2,strokeWidth:2,roundness:{type:3},label:{groupIds:m,text:b,fontSize:k,...I}},N={...N,groupIds:m,type:"ellipse"};break}case _r.CIRCLE:{N.type="ellipse";break}case _r.DIAMOND:{N.type="diamond";break}}i.push(N),O&&i.push(O)}),e.edges.forEach(u=>{let m=[],{startX:b,startY:w,reflectionPoints:v}=u,k=p.get(u.start)||0,L=p.get(u.end)||0,I=v.map((z,C)=>{let S=v.length>1?C/(v.length-1):0;return{...z,x:z.x+k+(L-k)*S,y:z.y+Ln(o,z.y)}}),N=Eu(u.type||"arrow_point"),O=[...i,...r].find(z=>z.id===u.start),W=[...i,...r].find(z=>z.id===u.end);if(!O||!W)return;let U=d.has(u.start);g.has(u.start)&&(I=Cu(I,O,"start",rd(W))),g.has(u.end)&&(I=Cu(I,W,"end",rd(O)));let _=I.map(z=>Mk(z.x-I[0].x,z.y-I[0].y)),j=U?I[0].y:w+Ln(o,w),H={id:`${u.start}_${u.end}`,type:"arrow",groupIds:m,x:U?I[0].x:b+k,y:j,strokeWidth:u.stroke==="thick"?4:2,strokeStyle:u.stroke==="dotted"?"dashed":void 0,points:_,...u.text?{label:{text:ii(u),fontSize:l,groupIds:m,...u.labelPosition!==void 0?{labelPosition:u.labelPosition}:{}}}:{},roundness:{type:2},...u.orthogonal?Dk(_):{},...N,start:{id:O.id||""},end:{id:W.id||""}};a.push(H)}),{elements:[...r,...a,...s,...i]}}});var xr=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");var Ou=new Ur({converter:e=>{let t=xr(),{width:r,height:a}=e,i={type:"image",x:0,y:0,width:r,height:a,status:"saved",fileId:t};return{files:{[t]:{id:t,mimeType:e.mimeType,dataURL:e.dataURL}},elements:[i]}}});var _s=10,ad=16,Pk=24,zk=4,Fk=1.25,Wk=e=>{if(!e)return!0;let t=e.trim().toLowerCase();return t==="transparent"||t==="none"||t==="rgba(0,0,0,0)"||t==="rgba(0, 0, 0, 0)"},Bk=(e,t)=>{let r=Math.max(...e.split(`
|
|
151
|
+
`).map(a=>a.length));return Math.max(20,Math.round(r*t*.6))},Hk=(e,t)=>Math.max(Pk,e.split(`
|
|
152
|
+
`).length*t*Fk),Pu=new Ur({converter:e=>{let t=[],r=[],a=[];Object.values(e.nodes).forEach(s=>{!s||!s.length||s.forEach(l=>{let n;switch(l.type){case"line":n=qr(l);break;case"rectangle":case"ellipse":n=si(l);break;case"text":n=fa(l);break;default:throw`unknown type ${l.type}`}l.type==="rectangle"&&l?.subtype==="activation"?r.push(n):l.type==="rectangle"&&l.subtype==="note"?a.push(n):t.push(n)})}),Object.values(e.lines).forEach(s=>{s&&t.push(qr(s))});let i=[];if(Object.values(e.arrows).forEach(s=>{s&&(t.push(Cs(s)),s.sequenceNumber&&i.push(si(s.sequenceNumber)))}),t.push(...r),t.push(...a),t.push(...i),e.loops){let{lines:s,texts:l,nodes:n}=e.loops;s.forEach(o=>{t.push(qr(o))}),l.forEach(o=>{t.push(fa(o))}),n.forEach(o=>{t.push(si(o))})}return e.groups&&e.groups.forEach(s=>{let{actorKeys:l,name:n}=s,o=n?Hk(n,ad):0,c=n?Bk(n,ad):0,f,p,d,g;if(s.bounds)({x:f,y:p,width:d,height:g}=s.bounds);else{if(!l.length)return;let m=t.filter(I=>{if(I.id){let N=I.id.indexOf("-"),O=I.id.substring(0,N);return l.includes(O)}return!1});if(!m.length)return;let b=1/0,w=1/0,v=0,k=0;if(m.forEach(I=>{I.x===void 0||I.y===void 0||I.width===void 0||I.height===void 0||(b=Math.min(b,I.x),w=Math.min(w,I.y),v=Math.max(v,I.x+I.width),k=Math.max(k,I.y+I.height))}),!Number.isFinite(b)||!Number.isFinite(w)||!Number.isFinite(v)||!Number.isFinite(k))return;let L=v-b+_s*2;d=Math.max(L,c+_s*2),f=b-_s-(d-L)/2,p=w-_s-o,g=k-w+_s*2+o}let u=si({type:"rectangle",x:f,y:p,width:d,height:g,bgColor:Wk(s.fill)?void 0:s.fill,strokeColor:"#1f1f1f",strokeWidth:1,id:xr()});if(t.unshift(u),n){let m=fa({type:"text",id:xr(),text:n,x:f+zk,y:p+_s,width:c,height:o,fontSize:ad,color:"#1f1f1f"});t.push(m)}}),{elements:t}}});var zu=new Ur({converter:e=>{let t=[];return Object.values(e.arrows).forEach(r=>{if(!r)return;let a=Cs(r);t.push(a)}),e.nodes.forEach(r=>{!r||!r.length||r.forEach(a=>{let i;switch(a.type){case"line":i=qr(a);break;case"rectangle":case"ellipse":i=si({...a,bgColor:a.bgColor??Fa});break;case"text":i=fa(a);break;default:throw`unknown type ${a.type}`}t.push(i)})}),Object.values(e.lines).forEach(r=>{r&&t.push(qr(r))}),Object.values(e.text).forEach(r=>{let a=fa(r);t.push(a)}),Object.values(e.namespaces).forEach(r=>{let a=Object.keys(r.classes),i=[...a],s=[...e.lines,...e.arrows,...e.text];a.forEach(n=>{let o=s.filter(c=>c.metadata&&c.metadata.classId===n).map(c=>c.id);o.length&&i.push(...o)});let l={type:"frame",id:xr(),name:r.id,children:i};t.push(l)}),{elements:t}}});var Fu=new Ur({converter:e=>{let t=[];return e.arrows.forEach(r=>{t.push(Cs(r))}),e.nodes.forEach(r=>{!r||!r.length||r.forEach(a=>{let i;switch(a.type){case"line":i=qr(a);break;case"rectangle":case"ellipse":i=si({...a,bgColor:a.bgColor??Fa});break;case"text":i=fa(a);break;default:throw`unknown type ${a.type}`}t.push(i)})}),e.lines.forEach(r=>{t.push(qr(r))}),e.text.forEach(r=>{t.push(fa(r))}),{elements:t}}});var io=(e,t)=>[e,t],Uu=16,qu=14,Yk=1,id="#000000",Gu=5,ju=Gu*2,Vu=Gu*2,Xu=1.25,Ku=new Set(["choice","fork","join","stateStart","stateEnd","divider"]),sd=e=>e.shape==="stateEnd"?[`state_end_group_${e.id}`]:void 0,Zu=e=>e.shape==="rectWithTitle"&&e.description.length?[e.text,...e.description].join(`
|
|
153
|
+
`):e.text,Uk=(e,t,r)=>{if(Wa(e,t)<=r)return[e];let a=[],i="";for(let s of e){let l=`${i}${s}`;if(i&&Wa(l,t)>r){a.push(i),i=s;continue}i=l}return i&&a.push(i),a},qk=(e,t,r)=>{if(!e.trim()||Wa(e,t)<=r)return e;let a=e.split(/\s+/).filter(Boolean),i=[],s="";for(let l of a){let n=Uk(l,t,r);for(let[o,c]of n.entries()){let p=s?`${s}${s&&o===0?" ":""}${c}`:c;if(Wa(p,t)<=r){s=p;continue}s&&i.push(s),s=c}n.length>1}return i.push(s),i.join(`
|
|
154
|
+
`)},Gk=(e,t,r)=>{let i=e.map(n=>qk(n,t,r)).join(`
|
|
155
|
+
`).split(`
|
|
156
|
+
`),s=Math.max(...i.map(n=>Wa(n,t))),l=i.length*t*Xu;return{width:s,height:l}},jk=(e,t,r,a,i)=>{let s=e.split(`
|
|
157
|
+
`);for(let l=i;l>=qu;l-=Yk){let{height:n}=Gk(s,l,t);if(n<=r)return l}return a},Vk=e=>{let t=Zu(e),r=e.fontSize??Uu;if(!t||Ku.has(e.shape))return r;let a=Math.max(1,e.width-ju),i=Math.max(1,e.height-Vu),s=t.split(`
|
|
158
|
+
`);return s.length>1&&Math.max(...s.map(n=>Wa(n,r)))<=a?r:jk(t,a,i,s.length===1?r:qu,r)},Qu=e=>{if(Ku.has(e.shape))return;let t=Zu(e);if(t)return{text:t,fontSize:Vk(e),verticalAlign:e.shape==="rectWithTitle"||e.shape==="roundedWithTitle"?"top":"middle",...Nn(e.labelStyle)}},Wu=(e,{withLabel:t=!0}={})=>{let r=ki(e.containerStyle),a=t?Qu(e):void 0,i=e.shape==="choice"?"diamond":e.shape==="stateStart"||e.shape==="stateEnd"?"ellipse":"rectangle",s=e.shape==="rect"||e.shape==="rectWithTitle"||e.shape==="roundedWithTitle",l=e.shape==="stateStart"||e.shape==="fork"||e.shape==="join",n=e.shape==="rect"||e.shape==="rectWithTitle"||e.shape==="choice"||e.shape==="note",o=r.backgroundColor||r.strokeColor||id,c=r.strokeColor||r.backgroundColor||id;return{id:e.id,type:i,...sd(e)?{groupIds:sd(e)}:{},x:e.x,y:e.y,width:e.width,height:e.height,...a?{label:a}:{},...n?{backgroundColor:Fa,fillStyle:"solid"}:{},...r,...s?{roundness:{type:3}}:{},...l?{backgroundColor:o,strokeColor:c,fillStyle:"solid"}:{}}},Bu=32,Hu=.25,Xk=(e,t)=>{let r=Math.min(e,t);return r<=Bu/Hu?r*Hu:Bu},Kk=e=>{let t=Qu(e);if(!t)return null;let r=ki(e.containerStyle),a=r.strokeWidth??2,i=t.fontSize??Uu,s=t.text.split(`
|
|
159
|
+
`),l=e.dividerLine?.startY??e.y+s.length*i*Xu+Vu,n=Math.max(...s.map(c=>Wa(c,i)))+ju+2,o=Math.min(e.width-a*2,Math.max(e.width-Xk(e.width,e.height)*2,n));return{id:`${e.id}__title`,type:"rectangle",x:e.x+(e.width-o)/2,y:e.y+a+4,width:o,height:Math.max(1,l-e.y-a-4),label:{strokeColor:r.strokeColor??In,...t,verticalAlign:"middle"},strokeColor:"transparent",backgroundColor:r.backgroundColor??Fa,fillStyle:"solid",roughness:0}},Yu=e=>{if(!e.dividerLine)return null;let t=ki(e.containerStyle);return{id:`${e.id}__divider`,type:"line",x:e.dividerLine.startX,y:e.dividerLine.startY,width:e.dividerLine.endX-e.dividerLine.startX,height:e.dividerLine.endY-e.dividerLine.startY,points:[io(0,0),io(e.dividerLine.endX-e.dividerLine.startX,e.dividerLine.endY-e.dividerLine.startY)],strokeColor:t.strokeColor||"#000",strokeWidth:t.strokeWidth||1}},Zk=e=>{let t=ki(e.containerStyle),r=Math.max(2,Math.min(e.width,e.height)*.32),a=e.endInnerColor||t.strokeColor||t.backgroundColor||id;return{id:`${e.id}__inner`,type:"ellipse",groupIds:sd(e),x:e.x+r,y:e.y+r,width:Math.max(1,e.width-r*2),height:Math.max(1,e.height-r*2),backgroundColor:a,strokeColor:a,fillStyle:"solid",strokeWidth:1}},Qk=e=>{let t=e.reflectionPoints.map((r,a,i)=>{let s=i[0];return a===0?io(0,0):io(r.x-s.x,r.y-s.y)});return{id:e.id,type:"arrow",x:e.startX,y:e.startY,width:e.endX-e.startX,height:e.endY-e.startY,points:t,strokeColor:e.strokeColor||"#000",strokeWidth:e.strokeWidth||2,strokeStyle:e.strokeStyle||"solid",endArrowhead:e.isNoteEdge?null:"triangle",roundness:{type:2},start:{id:e.start},end:{id:e.end},...e.text?{label:{text:e.text,fontSize:16,...e.labelPosition!==void 0?{labelPosition:e.labelPosition}:{}}}:{}}},Ju=new Ur({converter:e=>{let t=[],r=l=>{let n=Wu(l);t.push(n);let o=Yu(l);o&&t.push(o),l.shape==="stateEnd"&&t.push(Zk(l))},a=e.nodes.filter(l=>l.isRenderable),i=l=>l.shape==="roundedWithTitle",s=a.filter(i);return s.forEach(l=>{t.push(Wu(l,{withLabel:!1}))}),e.lines?.forEach(l=>{t.push(qr(l))}),e.edges.forEach(l=>{t.push(Qk(l))}),s.forEach(l=>{let n=Kk(l);n&&t.push(n);let o=Yu(l);o&&t.push(o)}),a.filter(l=>!i(l)).forEach(r),e.texts?.forEach(l=>{t.push(fa(l))}),{elements:t}}});var Jk=e=>e.replace(/fl°°/g,"#").replace(/fl°/g,"&").replace(/¶ß/g,";"),e0=e=>{e=Jk(e);let t=e.replace(/#(\d+);/g,"&#$1;").replace(/#([a-z]+);/g,"&$1;"),r=document.createElement("textarea");return r.innerHTML=t,r.value};var t0=(e,t=.5)=>{let r=[];return e.forEach(a=>{let i=r[r.length-1];if(!i){r.push(a);return}Math.hypot(a[0]-i[0],a[1]-i[1])<=t||r.push(a)}),r};var eM=e=>({...e,elements:e.elements.map(t=>{if(!("points"in t)||!Array.isArray(t.points))return t;let r=t.points;if(r.length<2)return t;let a=t0(r);return a.length===r.length?t:{...t,points:a}})}),r0=(e,t={})=>{let r=(()=>{switch(e.type){case"graphImage":return Ou.convert(e,t);case"flowchart":return Du.convert(e,t);case"sequence":return Pu.convert(e,t);case"class":return zu.convert(e,t);case"erd":return Fu.convert(e,t);case"state":return Ju.convert(e,t);default:throw new Error(`graphToExcalidraw: unknown graph type "${e.type}, only flowcharts are supported!"`)}})();return eM(r)};Rs();tr();wt();var SM=[["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 x0(e){for(let[t,r,a]of SM)if(a.test(e))return{type:t,mermaidType:r};return null}var TM=/^\s*%%(?!{)[^\n]+\n?/gm,Os=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,CM=/<(\w+)([^>]*)>/g,_M=/="([^"]*)"/g,IM=new Set(["__proto__","constructor","prototype"]);function NM(e){return(e.includes("%%")?e.replace(TM,""):e).trimStart()}function co(e){return e===`
|
|
160
|
+
`||e==="\r"}function cd(e){return e!==void 0&&/\s/.test(e)}function RM(e){let t=0;for(;t<e.length&&cd(e[t])&&!co(e[t]);)t++;let r=e.slice(0,t);if(!e.startsWith("---",t))return;let a=[];for(let p=t+3;p<e.length&&cd(e[p]);p++)co(e[p])&&a.push(p);if(a.length===0)return;let i=r+"---",s=p=>{if(!co(e[p])||!e.startsWith(i,p+1))return-1;let d=-1;for(let g=p+1+i.length;g<e.length&&cd(e[g]);g++)co(e[g])&&(d=g);return d},l=`
|
|
161
|
+
`+i,n=-1;for(let p=e.lastIndexOf(l);p>a[0];p=e.lastIndexOf(l,p-1))if(s(p)!==-1){n=p;break}if(n===-1)return;let o=a[0];for(let p of a)p<n&&(o=p);let c=o+1,f=c>0?c-1:0;for(let p=e.indexOf(l,f);p!==-1&&p<=n;p=e.indexOf(l,p+1)){if(p<c)continue;let d=s(p);if(d!==-1)return{indent:r,body:e.slice(c,p),length:d+1}}}function Ki(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ho(e,t){for(let r of Object.keys(t)){if(IM.has(r))continue;let a=t[r],i=e[r];Ki(a)&&Ki(i)?ho(i,a):Ki(a)?e[r]=ho({},a):e[r]=a}return e}function LM(e,t){if(!e.includes("%%{"))return e;let r=e.trim().replace(/'/g,'"');Os.lastIndex=0;let a;for(;(a=Os.exec(r))!==null;){a.index===Os.lastIndex&&Os.lastIndex++;let i=a[1]??a[2];if(i==="wrap")t.wrap=!0;else if((i==="init"||i==="initialize")&&a[4])try{let s=JSON.parse(a[4].trim());Ki(s)&&ho(t,s)}catch{}}return Os.lastIndex=0,e.replace(Os,"")}function w0(e){let t=e.includes("\r")?e.replace(/\r\n?/g,`
|
|
162
|
+
`):e,r=t.includes("<")?t.lastIndexOf(">"):-1;r>0&&(t=t.slice(0,r+1).replace(CM,(n,o,c)=>"<"+o+c.replace(_M,"='$1'")+">")+t.slice(r+1));let a={},i,s=0,l=t.includes("---")?RM(t):void 0;if(l){let n=l.indent?l.body.split(`
|
|
163
|
+
`).map(c=>c.startsWith(l.indent)?c.slice(l.indent.length):c).join(`
|
|
164
|
+
`):l.body,o;try{o=Ma(n)}catch(c){throw new je(`Front matter is not valid YAML. ${c.message}`,"syntax")}if(Ki(o)&&(o.title&&(i=String(o.title)),Ki(o.config)&&ho(a,o.config),o.displayMode)){let c=Ki(a.gantt)?a.gantt:a.gantt={};c.displayMode=String(o.displayMode)}for(let c=t.indexOf(`
|
|
165
|
+
`);c!==-1&&c<l.length;c=t.indexOf(`
|
|
166
|
+
`,c+1))s++;t=t.slice(l.length)}return t=LM(t,a),{text:NM(t),title:i,config:a,withComments:t,lineOffset:s}}var DM=/#\w+;/g,OM=/^\+?\d+$/,hd=new RegExp("[\\n\\r\u2028\u2029]","g");function y0(e,t){let r=e.indexOf(t);if(r===-1)return e;let a="",i=0;for(;r!==-1;){hd.lastIndex=r;let s=hd.test(e)?hd.lastIndex-1:e.length,l=!1,n=-1;for(let o=r+t.length;o<s;o++){let c=e.charCodeAt(o);if(c===58)l=!0;else if(c===35){if(l){n=o;break}}else Ue(c)&&(l=!1)}if(n!==-1){let o=e.lastIndexOf(";",s-1);o>n&&(a+=e.slice(i,o),i=o+1)}r=s>=e.length?-1:e.indexOf(t,s+1)}return i===0?e:a+e.slice(i)}function PM(e){return e.includes("#")?y0(y0(e,"style"),"classDef").replace(DM,t=>{let r=t.substring(1,t.length-1);return(OM.test(r)?"\uFB02\xB0\xB0":"\uFB02\xB0")+r+"\xB6\xDF"}):e}var aD=Math.random().toString(36).slice(2,7);var dd=new Map;function b0(...e){for(let t of e)dd.set(t.type,t)}function $0(e){return dd.has(e)}var zM=5e4,FM=4e6,WM=5e3;function k0(e){try{return e()}catch(t){throw t instanceof RangeError?new je("Diagram is nested too deeply.","limit"):t}}function M0(e,t){try{return t()}catch(r){throw r instanceof RangeError?new je("Diagram is nested too deeply.","limit",e):(r instanceof je&&(r.type??(r.type=e.type),r.mermaidType??(r.mermaidType=e.mermaidType)),r)}}var A0=new WeakMap;function v0(e,t=zM,r=WM,a){if(e.length>t)throw new je(`Diagram source is longer than the limit of ${t} characters.`,"limit");let i=w0(e),s=x0(i.text);if(s===null)throw new je("No diagram type detected for the given text.","unsupported-diagram");let l=dd.get(s.type);if(l===void 0)throw new je(`Diagram type "${s.type}" is not supported yet.`,"unsupported-diagram",s);let n=a?{...a,...i.config}:i.config,o=l.keepComments?i.withComments:i.text,c=M0(s,()=>l.parse(PM(o)+`
|
|
167
|
+
`,n,i.title,i.lineOffset,{maxEdges:r}));return{...s,diagram:l,model:c,config:n}}function BM(e,t){if(typeof e=="string")return v0(e,t.limit,t.maxEdges,t.config);let r=A0.get(e);if(r===void 0)throw new TypeError("render() takes diagram text or a model that parse() returned.");return r}function fd(e){return x0(w0(e).text)?.type??null}function pd(e,t={}){return k0(()=>{let r=v0(e,t.limit,t.maxEdges,t.config),a=r.model;return Object.defineProperty(a,"mermaidType",{value:r.mermaidType,enumerable:!0}),A0.set(a,r),a})}function Mi(e,t={}){return k0(()=>{let{type:r,mermaidType:a,diagram:i,model:s,config:l}=BM(e,t),n=l[i.section??r],o=typeof n=="object"&&n!==null&&!Array.isArray(n)&&n.useMaxWidth===!1,c=t.responsive??!o,f=t.icons,p=f&&(u=>f(At(u))),d=M0({type:r,mermaidType:a},()=>p0(i.math?t.math:void 0,()=>f0(p,()=>i.render(s,l,{...t,responsive:c,icons:p})))),g=t.outputLimit??FM;if(d.svg.length>g)throw new je(`Diagram output is longer than the limit of ${g} characters.`,"limit",{type:r,mermaidType:a});for(let u of d.links)u.id=At(u.id);return{type:r,mermaidType:a,...d}})}wt();var GN=new Map([["flowchart",()=>Promise.resolve().then(()=>(b1(),w1)).then(e=>e.flowchart)],["pie",()=>Promise.resolve().then(()=>(T1(),S1)).then(e=>e.pie)],["er",()=>Promise.resolve().then(()=>(q1(),U1)).then(e=>e.er)],["mindmap",()=>Promise.resolve().then(()=>(ig(),ag)).then(e=>e.mindmap)],["kanban",()=>Promise.resolve().then(()=>(og(),lg)).then(e=>e.kanban)],["timeline",()=>Promise.resolve().then(()=>(mg(),gg)).then(e=>e.timeline)],["journey",()=>Promise.resolve().then(()=>(kg(),$g)).then(e=>e.journey)],["class",()=>Promise.resolve().then(()=>(zg(),Pg)).then(e=>e.classDiagram)],["quadrantChart",()=>Promise.resolve().then(()=>(Kg(),Xg)).then(e=>e.quadrantChart)],["xychart",()=>Promise.resolve().then(()=>(pm(),fm)).then(e=>e.xychart)],["state",()=>Promise.resolve().then(()=>(Em(),vm)).then(e=>e.state)],["gantt",()=>Promise.resolve().then(()=>(Zm(),Km)).then(e=>e.gantt)],["architecture",()=>Promise.resolve().then(()=>(c2(),o2)).then(e=>e.architecture)],["requirement",()=>Promise.resolve().then(()=>($2(),b2)).then(e=>e.requirement)],["sankey",()=>Promise.resolve().then(()=>(N2(),I2)).then(e=>e.sankey)],["packet",()=>Promise.resolve().then(()=>(P2(),O2)).then(e=>e.packet)],["radar",()=>Promise.resolve().then(()=>(j2(),G2)).then(e=>e.radar)],["treemap",()=>Promise.resolve().then(()=>(ty(),ey)).then(e=>e.treemap)],["info",()=>Promise.resolve().then(()=>(ny(),sy)).then(e=>e.info)],["sequence",()=>Promise.resolve().then(()=>(vy(),Ay)).then(e=>e.sequence)],["gitGraph",()=>Promise.resolve().then(()=>(Py(),Oy)).then(e=>e.gitGraph)],["c4",()=>Promise.resolve().then(()=>(rx(),tx)).then(e=>e.c4)],["block",()=>Promise.resolve().then(()=>(yx(),mx)).then(e=>e.block)],["railroad",()=>Promise.resolve().then(()=>(Wx(),Fx)).then(e=>e.railroad)],["agentflow",()=>Promise.resolve().then(()=>(tw(),ew)).then(e=>e.agentflow)],["treeView",()=>Promise.resolve().then(()=>(uw(),pw)).then(e=>e.treeView)],["cynefin",()=>Promise.resolve().then(()=>(vw(),Aw)).then(e=>e.cynefin)],["wardley",()=>Promise.resolve().then(()=>(zw(),Pw)).then(e=>e.wardley)],["eventmodeling",()=>Promise.resolve().then(()=>(Xw(),Vw)).then(e=>e.eventmodeling)],["usecase",()=>Promise.resolve().then(()=>(zb(),Pb)).then(e=>e.usecase)],["venn",()=>Promise.resolve().then(()=>(qb(),Ub)).then(e=>e.venn)],["ishikawa",()=>Promise.resolve().then(()=>(Zb(),Kb)).then(e=>e.ishikawa)],["swimlane",()=>Promise.resolve().then(()=>(o$(),l$)).then(e=>e.swimlane)]]),xu=new Map;function c$(e){if(e===null)return Promise.resolve(!1);if($0(e))return Promise.resolve(!0);let t=xu.get(e);if(t===void 0){let r=GN.get(e);if(r===void 0)return Promise.resolve(!1);t=r().then(a=>(b0(a),!0),a=>{throw xu.delete(e),a}),xu.set(e,t)}return t}var h$=/<br\s*\/?>/gi,jN=/\\+n/g,VN=(e,t)=>e.replace(jN,r=>{let a=r.length-1,i="\\".repeat(Math.floor(a/2));return a%2?`${i}${t}`:`${i}n`}),XN=e=>VN(e.replace(h$,`
|
|
168
|
+
`),`
|
|
169
|
+
`),KN=/<\/?(?:a|abbr|b|big|cite|code|del|em|font|i|ins|kbd|mark|q|s|samp|small|span|strike|strong|sub|sup|tt|u|var)(?:\s[^<>]*)?\/?>/g,ta=e=>e0(XN(e).replace(KN,"")),d$=async(e,t)=>{try{return await t(e)}catch(r){let a=e.replace(h$,"\\n");if(a===e)throw r;try{return await t(a)}catch{throw r}}};var f$=e=>e.replace(/\s*!important\s*$/i,"").trim(),ZN=(e,t)=>{let r=t;for(;r<e.length&&/\s/.test(e[r]);)r+=1;let a=r;for(;r<e.length&&/[a-z-]/i.test(e[r]);)r+=1;if(r===a)return!1;for(;r<e.length&&/\s/.test(e[r]);)r+=1;return e[r]===":"},Zl=e=>{let t=[],r=0;for(;r<e.length;){for(;r<e.length&&/[\s;,]/.test(e[r]);)r+=1;if(r>=e.length)break;let a=r;for(;r<e.length&&e[r]!==":"&&!(e[r]===";"||e[r]===",");)r+=1;if(r>=e.length||e[r]!==":")break;let i=e.substring(a,r).trim().toLowerCase();r+=1;let s=r,l=0,n=null;for(;r<e.length;){let c=e[r];if(n){c===n&&e[r-1]!=="\\"&&(n=null),r+=1;continue}if(c==='"'||c==="'"){n=c,r+=1;continue}if(c==="("){l+=1,r+=1;continue}if(c===")"){l=Math.max(0,l-1),r+=1;continue}if(l===0&&(c===";"||c===","||/\s/.test(c)&&ZN(e,r)))break;r+=1}let o=f$(e.substring(s,r));i&&o&&t.push({property:i,value:o}),r<e.length&&(e[r]===";"||e[r]===",")&&(r+=1)}return t},Hh=e=>{let t=f$(e);if(!t)return!1;if(typeof CSS<"u"&&typeof CSS.supports=="function")return CSS.supports("color",t);if(typeof document<"u"){let r=document.createElement("div");return r.style.color="",r.style.color=t,r.style.color!==""}return!1};var bn=e=>{let t=new DOMParser().parseFromString(e,"image/svg+xml").documentElement;if(t.tagName!=="svg")throw new Error("Pele returned an invalid SVG");return t},sr=(e,t)=>{let r=new Map;return e.querySelectorAll(t).forEach(a=>{let i=a.getAttribute("data-id");i!==null&&!r.has(i)&&r.set(i,a)}),r},QN=/translate\(\s*([^\s,)]+)(?:[\s,]+([^\s,)]+))?\s*\)/,$n=(e,t)=>{let r={x:0,y:0};for(let a=e;a&&a!==t;a=a.parentElement){let i=a.getAttribute("transform")?.match(QN);i&&(r.x+=Number(i[1])||0,r.y+=Number(i[2])||0)}return r},da=(e,t)=>Number(e.getAttribute(t))||0,JN=/[a-zA-Z]|-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi,Yh=e=>{let t=e.match(JN)||[],r=[],a=0,i="",s={x:0,y:0},l={x:0,y:0},n=c=>c!==void 0&&/^[a-zA-Z]$/.test(c),o=()=>Number(t[a++]);for(;a<t.length;){if(n(t[a]))i=t[a++];else if(!i||i.toUpperCase()==="Z")break;let c=i===i.toLowerCase(),f=(g,u)=>c?{x:s.x+g,y:s.y+u}:{x:g,y:u},p,d;switch(i.toUpperCase()){case"M":case"L":case"T":p=[f(o(),o())];break;case"H":{let g=o();p=[{x:c?s.x+g:g,y:s.y}];break}case"V":{let g=o();p=[{x:s.x,y:c?s.y+g:g}];break}case"C":p=[f(o(),o()),f(o(),o()),f(o(),o())];break;case"S":case"Q":p=[f(o(),o()),f(o(),o())];break;case"A":{d={rx:o(),ry:o(),rotation:o(),largeArc:o()!==0,sweep:o()!==0},p=[f(o(),o())];break}case"Z":p=[l];break;default:throw new Error(`Unsupported SVG path command "${i}"`)}if(p.some(g=>!Number.isFinite(g.x)||!Number.isFinite(g.y)))break;r.push({command:i.toUpperCase(),points:p,...d?{arc:d}:{}}),s=p[p.length-1],i.toUpperCase()==="M"&&(l=s,i=c?"l":"L")}return r},y$=e=>{if(!e.length)return null;let t=e.map(s=>s.x),r=e.map(s=>s.y),a=Math.min(...t),i=Math.min(...r);return{x:a,y:i,width:Math.max(...t)-a,height:Math.max(...r)-i}},p$=24,eR=(e,t,{rx:r,ry:a,rotation:i,largeArc:s,sweep:l})=>{if(!r||!a)return[];let n=i*Math.PI/180,o=Math.cos(n),c=Math.sin(n),f=(e.x-t.x)/2,p=(e.y-t.y)/2,d=o*f+c*p,g=-c*f+o*p,u=d*d/(r*r)+g*g/(a*a),m=Math.max(1,Math.sqrt(u));r=Math.abs(r)*m,a=Math.abs(a)*m;let b=(s!==l?1:-1)*Math.sqrt(Math.max(0,(r*r*a*a-r*r*g*g-a*a*d*d)/(r*r*g*g+a*a*d*d))),w=b*r*g/a,v=-b*a*d/r,k=o*w-c*v+(e.x+t.x)/2,L=c*w+o*v+(e.y+t.y)/2,I=(W,U)=>Math.atan2(U,W),N=I((d-w)/r,(g-v)/a),O=I((-d-w)/r,(-g-v)/a)-N;return l&&O<0?O+=Math.PI*2:!l&&O>0&&(O-=Math.PI*2),Array.from({length:p$+1},(W,U)=>{let _=N+O*U/p$;return{x:k+r*o*Math.cos(_)-a*c*Math.sin(_),y:L+r*c*Math.cos(_)+a*o*Math.sin(_)}})},x$=e=>{switch(e.tagName.toLowerCase()){case"rect":case"image":{let t=da(e,"x"),r=da(e,"y");return[{x:t,y:r},{x:t+da(e,"width"),y:r+da(e,"height")}]}case"circle":case"ellipse":{let t=da(e,"cx"),r=da(e,"cy"),a=da(e,e.hasAttribute("r")?"r":"rx"),i=da(e,e.hasAttribute("r")?"r":"ry");return[{x:t-a,y:r-i},{x:t+a,y:r+i}]}case"polygon":case"polyline":{let t=(e.getAttribute("points")||"").split(/[\s,]+/).filter(Boolean).map(Number),r=[];for(let a=0;a+1<t.length;a+=2)r.push({x:t[a],y:t[a+1]});return r}case"path":{let t={x:0,y:0};return Yh(e.getAttribute("d")||"").flatMap(({points:r,arc:a})=>{let i=t;return t=r[r.length-1],a?[...eR(i,t,a),...r]:r})}default:return[]}},w$="rect, circle, ellipse, polygon, polyline, path, image",tR=new Set(w$.split(", ")),yr=(e,t)=>{let a=(tR.has(e.tagName.toLowerCase())?[e]:Array.from(e.querySelectorAll(w$))).flatMap(i=>{let s=$n(i,t);return x$(i).map(l=>({x:l.x+s.x,y:l.y+s.y}))});return y$(a)},Ui=(e,t)=>{let r=$n(e,t),a={x:0,y:0};return Yh(e.getAttribute("d")||"").flatMap(({command:i,points:s})=>{let l=a;if(a=s[s.length-1],i==="Q")return s;if(i==="C"){let[n,o,c]=s;return[{x:(l.x+3*n.x+3*o.x+c.x)/8,y:(l.y+3*n.y+3*o.y+c.y)/8},c]}return[a]}).map(i=>({x:i.x+r.x,y:i.y+r.y}))},kn=(e,t=.5)=>{let r=e.filter((a,i)=>i===0||Math.hypot(a.x-e[i-1].x,a.y-e[i-1].y)>t);return r.filter((a,i)=>{if(i===0||i===r.length-1)return!0;let s=r[i-1],l=r[i+1],n=(a.x-s.x)*(l.y-s.y)-(a.y-s.y)*(l.x-s.x),o=Math.hypot(l.x-s.x,l.y-s.y);return!o||Math.abs(n)/o>t})},u$=(e,t)=>{let r=e[e.length-1],a=e[e.length-2],i=r.x-a.x,s=r.y-a.y,l=Math.hypot(i,s),n=Math.abs(i)<.5;if(l>=t||!l||!n&&Math.abs(s)>=.5)return e;let o=g=>n?(r.y-g.y)*Math.sign(s):(r.x-g.x)*Math.sign(i),c=-1;for(let g=e.length-2;g>0;g--){let u=e[g-1],m=e[g];if(Math.hypot(m.x-u.x,m.y-u.y)<t)continue;if(n?Math.abs(m.x-u.x)<.5:Math.abs(m.y-u.y)<.5){c=g;break}if(o(u)>=t+4){c=g-1;break}}if(c<0)return e;let f=o(e[c]),p=Math.min(t,f-4);if(p<=l)return e;let d=(f-p)/(f-l);return e.map((g,u)=>{if(u<=c||u===e.length-1)return g;let m=p+(o(g)-l)*d;return n?{x:g.x,y:r.y-Math.sign(s)*m}:{x:r.x-Math.sign(i)*m,y:g.y}})},Uh=(e,t=30)=>e.length<3?e:u$(u$(e,t).slice().reverse(),t).reverse(),qh=(e,t=3)=>{let r=[...e];for(let a=0;a<e.length*8;a++){let i=r.slice(1).map((d,g)=>Math.hypot(d.x-r[g].x,d.y-r[g].y)),s=i.findIndex((d,g)=>g>0&&Math.min(d,i[g-1])>1&&Math.max(d,i[g-1])>t*Math.min(d,i[g-1]));if(s===-1)break;let l=i[s]>i[s-1],n=r[s],o=r[l?s+1:s-1],c=i[l?s:s-1],p=2*i[l?s-1:s]/c;r.splice(l?s+1:s,0,{x:n.x+(o.x-n.x)*p,y:n.y+(o.y-n.y)*p})}return r},Mn=(e,t)=>{let r=0,a={distance:1/0,length:0};for(let i=1;i<e.length;i++){let s=e[i-1],l=e[i].x-s.x,n=e[i].y-s.y,o=Math.hypot(l,n),c=o?Math.min(1,Math.max(0,((t.x-s.x)*l+(t.y-s.y)*n)/o**2)):0,f=Math.hypot(s.x+c*l-t.x,s.y+c*n-t.y);f<a.distance&&(a={distance:f,length:r+c*o}),r+=o}return r?a.length/r:.5},rR=(e,t)=>{let r=$n(e,t),a=e.tagName.toLowerCase()==="circle";return{points:(a?[{x:da(e,"cx"),y:da(e,"cy")}]:x$(e)).map(s=>({x:s.x+r.x,y:s.y+r.y})),radius:a?da(e,"r"):0}},g$=(e,t,r)=>{let a=Math.hypot(e.x-t.x,e.y-t.y);if(!a||!r.length)return e;let i={x:(e.x-t.x)/a,y:(e.y-t.y)/a},s=Math.max(0,...r.flatMap(({points:l,radius:n})=>l.map(o=>(o.x-e.x)*i.x+(o.y-e.y)*i.y+n)));return{x:e.x+i.x*s,y:e.y+i.y*s}},wu=(e,t,r)=>{let a=[],i=[];if(!e.length)return{startMarkers:a,endMarkers:i};let s=e[0],l=e[e.length-1];return t.forEach(n=>{let o=rR(n,r),c=y$(o.points);if(!c)return;let f=c.x+c.width/2,p=c.y+c.height/2,d=Math.hypot(f-s.x,p-s.y),g=Math.hypot(f-l.x,p-l.y);(d<g?a:i).push(o)}),{startMarkers:a,endMarkers:i}},m$=(e,t,r)=>{let a={x:t.x-e.x,y:t.y-e.y},i={x:r.x-t.x,y:r.y-t.y};return Math.abs(a.x*i.y-a.y*i.x)<.01*Math.hypot(a.x,a.y)&&a.x*i.x+a.y*i.y<0},aR=e=>{let t=e;for(;t.length>2&&m$(t[t.length-3],t[t.length-2],t.at(-1));)t=[...t.slice(0,-2),t.at(-1)];for(;t.length>2&&m$(t[2],t[1],t[0]);)t=[t[0],...t.slice(2)];return t},Gh=(e,t,r)=>{if(e.length<2||!t.length)return e;let a=aR(e),i=a[0],s=a[a.length-1],{startMarkers:l,endMarkers:n}=wu(a,t,r),o=[...a];return o[0]=g$(i,a[1],l),o[o.length-1]=g$(s,a[a.length-2],n),o},b$=e=>`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(e)))}`,ba=(e,t,r)=>{for(let a=e;a&&a!==t;a=a.parentElement){let i=Number(a.getAttribute("font-size"));if(i)return i}return r},ra=e=>{if(!e)return[];let t=Array.from(e.querySelectorAll("tspan"));return t.length?t.reduce((r,a)=>((a.hasAttribute("y")||!r.length)&&r.push(""),r[r.length-1]+=a.textContent||"",r),[]):[e.textContent||""]},iR=.35,sR=1.25,$$=(e,t,r)=>{let a=$n(e,t),i=ba(e,t,r),s=[e,...Array.from(e.querySelectorAll("tspan"))].filter(d=>d.hasAttribute("y")),l=s.map(d=>da(d,"y")),n=s.length?da(s[0],"x"):0,o=ra(e),c=l.length?(Math.min(...l)+Math.max(...l))/2-iR*i:0,f=o.length*i*sR,p=e.getAttribute("text-anchor");return{text:o.join(`
|
|
170
|
+
`),x:n+a.x,y:c-f/2+a.y,height:f,fontSize:i,textAlign:p==="middle"?"center":p==="end"?"right":"left"}},nR=e=>!/\bvar\(/i.test(e)&&Hh(e),fr=(e,t)=>{let r=ri(e,t);return r&&nR(r)?r:void 0},ri=(e,t)=>Zl(e?.getAttribute("style")||"").find(r=>r.property===t)?.value;var qi=(e,t)=>{let r=ra(t),a=i=>i.replace(/\s+/g," ").trim();return r.length>e.split(`
|
|
171
|
+
`).length&&a(r.join(" "))===a(e)?r.join(`
|
|
172
|
+
`):e},bi=(e,t)=>(e.getAttribute("class")||"").split(/\s+/).includes(t),Hr=(e,t,r,a={})=>{let{text:i,x:s,y:l,height:n,fontSize:o,textAlign:c}=$$(e,t,r);return{type:"text",text:i,x:s,y:l,height:n,fontSize:o,textAlign:c,color:fr(e,"fill"),...a}},jh=(e,t,r={})=>({type:"line",startX:e.x,startY:e.y,endX:t.x,endY:t.y,...r}),za=(e,t,r={})=>{let a=$n(e,t),i=[],s;return Yh(e.getAttribute("d")||"").forEach(({command:l,points:n})=>{let o=n[n.length-1];l!=="M"&&s&&i.push(jh({x:s.x+a.x,y:s.y+a.y},{x:o.x+a.x,y:o.y+a.y},r)),s=o}),i},Gi=(e,t)=>{let r=Array.from(e.children).find(n=>n.tagName.toLowerCase()==="path"&&!bi(n,"pele-marker"));if(!r)return;let a=Array.from(e.querySelectorAll(".pele-marker")),i=Ui(r,t),{startMarkers:s,endMarkers:l}=wu(i,a,t);return{line:r,route:kn(Gh(i,a,t)),hasStartMarker:s.length>0,hasEndMarker:l.length>0}},k$=(e,t)=>Math.hypot(Math.max(t.x-e.x,0,e.x-(t.x+t.width)),Math.max(t.y-e.y,0,e.y-(t.y+t.height))),Vh=(e,t,r)=>{let a=t??r;if(!a||e.length<2)return e;let i=k$(e[0],a),s=k$(e[e.length-1],a);return(t?i>s:i<s)?[...e].reverse():e},Ts=(e,t={})=>{let[r]=e,a=e[e.length-1];return{type:"arrow",startX:r.x,startY:r.y,endX:a.x,endY:a.y,points:e.map(i=>[i.x-r.x,i.y-r.y]),...t}},Xh=(e,t,r)=>{let a=t&&yr(t,r);return a?Mn(e,{x:a.x+a.width/2,y:a.y+a.height/2}):void 0},An=e=>({x:e.x,y:e.y,width:e.width??0,height:e.height??0});var E$="rect, circle, ellipse, polygon, path",S$=5,T$=1.25,C$=e=>!/\bvar\(/i.test(e)&&Hh(e),_$=e=>{let t={};return Zl(e?.getAttribute("style")||"").forEach(({property:r,value:a})=>{switch(r){case Tr.FILL:case Tr.STROKE:C$(a)&&(t[r]=a);break;case Tr.STROKE_WIDTH:case Tr.STROKE_DASHARRAY:t[r]=a;break}}),t},I$=e=>{let t={};return Zl(e?.getAttribute("style")||"").forEach(({property:r,value:a})=>{(r==="fill"||r===ai.COLOR)&&C$(a)&&(t[ai.COLOR]=a)}),t},lR=(e,t,r)=>{let a=yr(t,r);if(a)return{id:e.id,type:e.type,labelType:e.labelType,text:e.type===_r.DIAMOND?ta(e.text??e.id):qi(ta(e.text??e.id),t.querySelector(".pele-label")),...a,link:t.querySelector("a[href]")?.getAttribute("href")||void 0,containerStyle:_$(t.querySelector(E$)),labelStyle:I$(t.querySelector(".pele-label"))}},oR=(e,t)=>Math.abs(t.x-(e.x+e.width/2))/(e.width/2)+Math.abs(t.y-(e.y+e.height/2))/(e.height/2),M$=(e,t)=>Math.hypot((t.x-(e.x+e.width/2))/(e.width/2),(t.y-(e.y+e.height/2))/(e.height/2)),cR=5,N$={[_r.DIAMOND]:{ratio:2,inset:0,getDistance:oR},[_r.CIRCLE]:{ratio:Math.SQRT2,inset:0,getDistance:M$},[_r.DOUBLECIRCLE]:{ratio:Math.SQRT2,inset:cR*2,getDistance:M$}},A$=4,hR=1.35,dR=.02,fR=1/4,pR=(e,t,r)=>{let a=[];for(let i of e.split(`
|
|
173
|
+
`)){let s=[],l="",n=0;for(let o of i.split(" ").filter(Boolean)){let c=l?`${l} ${o}`:o,f=r(c);if(f===null)return null;if(f<=t){l=c,n=f;continue}let p=r(o)??1/0;if(p>t)return null;l&&s.push(n),l=o,n=p}s.push(n),a.push(s)}return a},uR=(e,{fontSize:t,measureText:r})=>{if(!e.text||!r||r(e.text)===null)return e;let a=S$*2,i=t*T$,s=(f,{withoutOrphans:p=!1}={})=>{let d=Math.round(e.width*f/2)-a-1,g=Math.round(e.height*f/2)-a,u=pR(e.text,d,r);return!!u&&u.flat().length*i<=g&&(!p||u.every(m=>m.length<2||m[m.length-1]>=d*fR))},l=(f,p)=>{for(let d=1;d<=f;d+=dR)if(s(d,p))return d;return null},n=l(hR,{withoutOrphans:!0})??l(A$)??A$,o=e.width*n,c=e.height*n;return{...e,x:e.x-(o-e.width)/2,y:e.y-(c-e.height)/2,width:o,height:c}},gR=(e,t,r)=>{if(e.type===_r.DIAMOND)return uR(e,r);let{fontSize:a,measureText:i}=r,s=N$[e.type];if(!s||!t.length)return e;let l=t.map(g=>i?.(g)??null);if(l.some(g=>g===null))return e;let n=S$*2,o=Math.max(...l),c=t.length*a*T$,f=Math.max(e.width,e.height,s.ratio*(o+n+1)+s.inset,s.ratio*(c+n+1)+s.inset),p=f,d=f;return{...e,x:e.x-(p-e.width)/2,y:e.y-(d-e.height)/2,width:p,height:d}},mR=(e,t,r,a)=>{let i=yr(t,a);if(!i)return;let s=bi(t,"pele-lane")?Array.from(t.children).filter(n=>n.tagName.toLowerCase()==="rect")[1]:void 0,l=s&&yr(s,a);return{id:e.id,nodeIds:e.nodes,text:ta(e.title),labelType:e.labelType,...i,containerStyle:_$(t.querySelector(E$)),labelStyle:I$(t.querySelector(".pele-cluster-label")||r?.querySelector(".pele-cluster-label")||null),...l?{laneHeader:{...l,vertical:l.height>=i.height-1}}:{}}},v$=(e,t)=>{let r=N$[t.type];if(!r)return e;let a=e.findIndex((o,c)=>c>0&&r.getDistance(t,o)>1.01);if(a===-1)return e;let i=e[a],s=t.x+t.width/2,l=t.y+t.height/2,n=1/r.getDistance(t,i);return[{x:s+(i.x-s)*n,y:l+(i.y-l)*n},...e.slice(a)]},yR=(e,t,r,a,i,{inSwimlanes:s=!1}={})=>{let n=Array.from(t.querySelectorAll("path")).find(m=>!m.getAttribute("class")?.includes("pele-marker"));if(!n)return;let o=Gh(Ui(n,a),Array.from(t.querySelectorAll(".pele-marker")),a),c=i[e.start];c&&(o=v$(o,c));let f=i[e.end];if(f&&(o=v$(o.reverse(),f).reverse()),o=kn(o),o.length<2)return;let p=s&&o.every((m,b)=>b===0||Math.abs(m.x-o[b-1].x)<.5||Math.abs(m.y-o[b-1].y)<.5),d=o[0],g=o[o.length-1],u=r&&yr(r,a);return{id:e.id,start:e.start,end:e.end,type:e.type,text:qi(ta(e.text),r?.querySelector("text")??null),labelType:e.labelType,stroke:e.stroke,startX:d.x,startY:d.y,endX:g.x,endY:g.y,reflectionPoints:p?o:qh(o),...p?{orthogonal:p}:{},...e.text&&u?{labelPosition:Mn(o,{x:u.x+u.width/2,y:u.y+u.height/2})}:{}}},R$=(e,t,r)=>{let a=sr(t,"g.pele-node[data-id]"),i=sr(t,"g.pele-edge[data-id]"),s=sr(t,"g.pele-edge-label[data-id]"),l=sr(t,"g.pele-cluster[data-id]"),n=sr(t,"g.pele-cluster-title[data-id]"),o={};e.nodes.forEach((u,m)=>{let b=a.get(m),w=b&&lR(u,b,t);w&&(o[m]=gR(w,ra(b.querySelector(".pele-label")),r))});let c=new Map;e.subgraphs.forEach(u=>u.nodes.forEach(m=>c.set(m,u.id)));let f=(u,m)=>{let b=new Set;for(let w=c.get(u);w!==void 0&&!b.has(w);w=c.get(w)){if(w===m)return!0;b.add(w)}return!1},p=e.mermaidType==="swimlane",d=e.edges.flatMap(u=>{if(f(u.start,u.end)||f(u.end,u.start))return[];let m=u.id!==void 0&&i.get(u.id),b=m&&yR(u,m,s.get(u.id)??void 0,t,o,{inSwimlanes:p});return b?[b]:[]});return{type:"flowchart",subGraphs:e.subgraphs.flatMap(u=>{let m=l.get(u.id),b=m&&mR(u,m,n.get(u.id)||null,t);return b?[b]:[]}),vertices:o,edges:d}};var xR="#999",L$="#adb5bd",wR="#e9ecef",bR="#e9ecef",bu=14,D$=28,$R=2*5+4,kR="#ffffff",Kh=16,MR=1.25,vn=yr,AR=(e,t,r)=>{let a=yr(e,t);if(!a)return[];let{x:i,y:s,width:l,height:n}=a,o=[{x:i,y:s},{x:i+l,y:s},{x:i+l,y:s+n},{x:i,y:s+n}];return o.map((c,f)=>jh(c,o[(f+1)%o.length],r))},vR=(e,t,r)=>{let a=[];return t.querySelectorAll("g.pele-node.pele-actor[data-id]").forEach(i=>{let s=i.getAttribute("data-id"),l=bi(i,"pele-actor-footer")?"bottom":"top",n=`${s}-${l}`,o=i.querySelector(".pele-label");if(bi(i,"pele-actor-actor")){let d=xr(),g=[];Array.from(i.children).forEach(u=>{let m=`${n}-${g.length}`;switch(u.tagName.toLowerCase()){case"circle":{let b=vn(u,t);b&&g.push({type:"ellipse",id:m,...b,groupId:d});break}case"path":case"line":g.push(...za(u,t,{groupId:d}).map((b,w)=>({...b,id:`${m}-${w}`})));break;case"text":g.push(Hr(u,t,r.fontSize,{id:m,groupId:d}));break}}),a.push(g);return}let c=vn(i,t);if(!c)return;let f=i.querySelector("rect, path, polygon, circle"),p=e.actors.get(s);a.push([{type:"rectangle",id:n,...c,label:{text:qi(ta(p?.description??s),o),fontSize:o?ba(o,t,r.fontSize):r.fontSize},bgColor:f?fr(f,"fill"):void 0,strokeColor:f?fr(f,"stroke"):void 0,subtype:"actor"}])}),a},ER=e=>Array.from(e.querySelectorAll("path.pele-lifeline")).flatMap(t=>{let r=Ui(t,e);return r.length<2?[]:[jh(r[0],r[r.length-1],{strokeColor:xR,strokeWidth:1})]}),P$=e=>typeof e.message=="string"?ta(e.message):"",SR=(e,t,r)=>{let a=new Map(e.messages.map(n=>[`i${n.id}`,n])),i=sr(t,"g.pele-edge-label[data-id]"),s=[],l=[];return sr(t,"g.pele-edge.pele-message[data-id]").forEach((n,o)=>{let c=a.get(o),f=Gi(n,t);if(!c||!f||f.route.length<2)return;let p=c.from!==void 0&&c.from===c.to&&i.get(o)?.querySelector("text");if(p){let k=Hr(p,t,r.fontSize),{height:L=0}=k,I=L*Kh/k.fontSize;l.push({...k,fontSize:Kh,y:k.y+(L-I)/2,height:I})}let d=p?"":P$(c),g=d?d.split(`
|
|
174
|
+
`).length*Kh*MR/2:0,u=f.route.map(k=>({x:k.x,y:k.y-g})),m=Ts(u,{label:d?{text:d}:void 0,strokeStyle:f.line.hasAttribute("stroke-dasharray")?"dotted":"solid",startArrowhead:f.hasStartMarker?"arrow":null,endArrowhead:f.hasEndMarker?"arrow":null}),b=n.querySelector(".pele-sequence-number"),w=b?.querySelector("rect, circle"),v=w&&yr(w,t);if(b&&v){let k=b.textContent||"",L=D$,I=r.measureText?.(k,bu)??k.length*bu*.7,N=Math.max(D$,I+$R);m.sequenceNumber={type:"rectangle",x:v.x+v.width/2-N/2,y:v.y+v.height/2-g-L/2,width:N,height:L,label:{text:k,fontSize:bu},bgColor:bR,subtype:"sequence"}}s.push(m)}),{arrows:s,texts:l}},TR=(e,t,r)=>{let a=new Map(e.messages.map(i=>[`i${i.id}`,i]));return Array.from(sr(t,"g.pele-note[data-id]")).flatMap(([i,s])=>{let l=s.querySelector("rect"),n=l&&vn(l,t),o=a.get(i);if(!l||!n)return[];let c=s.querySelector(".pele-label");return[{type:"rectangle",...n,label:{text:o?qi(P$(o),c):c?.textContent||"",fontSize:c?ba(c,t,r.fontSize):r.fontSize},bgColor:fr(l,"fill")??kR,strokeStyle:"dashed",subtype:"note"}]})},O$=(e,t,r)=>Array.from(e.querySelectorAll(t)).flatMap(a=>{let i=vn(a,e);return i?[{type:"rectangle",...i,label:{text:"",fontSize:Kh},...r==="highlight"?{bgColor:fr(a,"fill"),strokeColor:"transparent"}:{},subtype:r}]:[]}),CR=(e,t)=>{let r=[],a=[],i=[],s={strokeStyle:"dotted",strokeColor:L$,strokeWidth:2};return e.querySelectorAll("g.pele-frame").forEach(l=>{let n=Array.from(l.children).find(p=>p.tagName.toLowerCase()==="rect"&&p.getAttribute("fill")==="none");n&&r.push(...AR(n,e,s)),Array.from(l.children).filter(p=>p.tagName.toLowerCase()==="path"&&p.hasAttribute("stroke-dasharray")).forEach(p=>r.push(...za(p,e,s)));let o=l.querySelector(".pele-frame-kind"),c=o?.previousElementSibling,f=c&&vn(c,e);o&&f&&i.push({type:"rectangle",x:f.x,y:f.y,height:f.height,label:{text:o.textContent||"",fontSize:ba(o,e,t.fontSize)},strokeColor:L$,bgColor:wR}),l.querySelectorAll(".pele-frame-label").forEach(p=>a.push(Hr(p,e,t.fontSize)))}),{lines:r,texts:a,nodes:i}},z$=(e,t,r)=>{let a=vR(e,t,r),i=Array.from(t.querySelectorAll("g.pele-box")),s=Array.from(t.querySelectorAll("path.pele-destroy")).flatMap(n=>za(n,t)),l=SR(e,t,r);return{type:"sequence",nodes:[O$(t,"rect.pele-rect","highlight"),...a,TR(e,t,r),O$(t,"rect.pele-activation","activation"),s,l.texts],lines:ER(t),arrows:l.arrows,loops:CR(t,r),groups:e.boxes.map((n,o)=>{let c=i[o]?.querySelector("rect"),f=c&&vn(c,t);return{name:ta(n.name??""),actorKeys:n.actorKeys,fill:n.fill,...f?{bounds:f}:{}}})}};var _R={0:"diamond_outline",1:"triangle_outline",2:"diamond",3:"arrow",4:"circle_outline"},IR=1,NR=(e,t,r)=>{let a=e.getAttribute("data-id"),i=e.querySelector("rect"),s=i&&yr(i,t);if(!i||!s)return;let l=xr(),n={classId:a},o=fr(i,"stroke"),c=parseFloat(ri(i,"stroke-width")||""),f=ri(i,"stroke-dasharray")?"dashed":void 0,p=e.querySelector(".pele-label"),d=Array.from(e.querySelectorAll(".pele-annotation")),g=d.length?[...d,...p?[p]:[]].map(w=>Hr(w,t,r.fontSize,{id:xr(),groupId:l,metadata:n})):[],u={type:"rectangle",id:a,groupId:l,metadata:n,...s,label:d.length?void 0:{text:ra(p).join(`
|
|
175
|
+
`),fontSize:p?ba(p,t,r.fontSize):r.fontSize,color:fr(p,"fill"),verticalAlign:"top"},bgColor:fr(i,"fill"),strokeColor:o,strokeWidth:Number.isFinite(c)?c:void 0,strokeStyle:f},m=Array.from(e.querySelectorAll(".pele-divider")).flatMap(w=>za(w,t).map(v=>({...v,id:xr(),strokeColor:o,strokeWidth:u.strokeWidth,strokeStyle:f,groupId:l,metadata:n}))),b=[...g,...Array.from(e.querySelectorAll(".pele-member")).map(w=>Hr(w,t,r.fontSize,{id:xr(),groupId:l,metadata:n}))];return{container:u,lines:m,text:b}},RR=(e,t,r,a)=>{let i=sr(t,"g.pele-edge-label[data-id]"),s=[],l=new Map(Array.from(sr(t,"g.pele-edge.pele-relation[data-id]")).map(([o,c])=>[o.match(/_(\d+)$/)?.[1],c]).filter(([o])=>o!==void 0));return{arrows:e.relations.flatMap((o,c)=>{let f=l.get(String(c+1)),p=f&&Gi(f,t),d=r.get(o.id1),g=r.get(o.id2);if(!f||!p||p.route.length<2||!d&&!g)return[];let u=o.id1===o.id2,m=u?p.route:Vh(p.route,d&&An(d),g&&An(g)),b=L=>L==="none"?null:_R[L]??"arrow",w=o.title?ta(o.title):"",v=i.get(f.getAttribute("data-id")),k=u&&v?.querySelector("text");return k&&s.push(Hr(k,t,a.fontSize)),[Ts(m,{label:w&&!k?{text:w,labelPosition:Xh(m,v,t)}:void 0,strokeStyle:o.relation.lineType===IR?"dotted":"solid",startArrowhead:b(o.relation.type1),endArrowhead:b(o.relation.type2),...d?{start:{type:"rectangle",id:o.id1}}:{},...g?{end:{type:"rectangle",id:o.id2}}:{},...m.length>2&&!u?{roundness:null}:{}})]}),labels:s}},LR=(e,t,r)=>{let a=[],i=[],s=sr(t,"g.pele-note-edge[data-id]");return sr(t,"g.pele-node.pele-note[data-id]").forEach((l,n)=>{let o=yr(l,t),c=e.notes.get(n);if(!o)return;let f=l.querySelector(".pele-label");a.push({type:"rectangle",id:n,...o,label:{text:c?qi(ta(c.text),f):ra(f).join(`
|
|
176
|
+
`),fontSize:f?ba(f,t,r.fontSize):r.fontSize},strokeStyle:"dashed",subtype:"note"});let d=s.get(`edgeNote${n.replace(/^note/,"")}`)?.querySelector("path"),g=d&&kn(Ui(d,t));!c?.class||!g||g.length<2||i.push(Ts(g,{strokeStyle:"dotted",startArrowhead:null,endArrowhead:null,start:{type:"rectangle",id:n},end:{type:"rectangle",id:c.class}}))}),{notes:a,connectors:i}},F$=(e,t,r)=>{let a=[],i=[],s=[],l=new Map;t.querySelectorAll("g.pele-node.pele-interface .pele-label").forEach(p=>s.push(Hr(p,t,r.fontSize))),t.querySelectorAll("g.pele-node.pele-class[data-id]").forEach(p=>{let d=NR(p,t,r);d&&(a.push(d.container),i.push(...d.lines),s.push(...d.text),l.set(d.container.id,d.container))});let{arrows:n,labels:o}=RR(e,t,l,r),{notes:c,connectors:f}=LR(e,t,r);return t.querySelectorAll(".pele-cardinality").forEach(p=>s.push(Hr(p,t,r.fontSize))),s.push(...o),{type:"class",nodes:[a,c],lines:i,arrows:[...n,...f],text:s,namespaces:Array.from(e.namespaces.values()).map(p=>({id:p.id,classes:Object.fromEntries(p.classes)}))}};var W$={ONLY_ONE:"cardinality_exactly_one",ZERO_OR_ONE:"cardinality_zero_or_one",ZERO_OR_MORE:"cardinality_zero_or_many",ONE_OR_MORE:"cardinality_one_or_many",MD_PARENT:"cardinality_one"},DR=(e,t,r,a)=>{let i=Array.from(t.children).find(b=>b.tagName.toLowerCase()==="rect"),s=i&&yr(i,r);if(!i||!s)return;let l=e.attributes.length>0,n=l?xr():void 0,o={entityId:e.id,entityLabel:e.label,entityAlias:e.alias},c=fr(i,"stroke"),f=parseFloat(ri(i,"stroke-width")||""),p=ri(i,"stroke-dasharray")?"dashed":void 0,d=Array.from(t.children).find(b=>(b.getAttribute("class")||"").includes("pele-label")),g={type:"rectangle",id:e.id,groupId:n,metadata:o,...s,label:{text:ra(d??null).join(`
|
|
177
|
+
`),fontSize:d?ba(d,r,a.fontSize):a.fontSize,color:fr(d,"fill"),textAlign:"center",verticalAlign:l?"top":"middle"},bgColor:fr(i,"fill"),strokeColor:c,strokeWidth:Number.isFinite(f)?f:void 0,strokeStyle:p},u=Array.from(t.querySelectorAll(".pele-er-divider")).flatMap(b=>za(b,r).map(w=>({...w,id:xr(),strokeColor:c,strokeWidth:g.strokeWidth,strokeStyle:p,groupId:n,metadata:{entityId:e.id}}))),m=Array.from(t.querySelectorAll(".pele-er-attributes text")).map(b=>Hr(b,r,a.fontSize,{id:xr(),groupId:n,metadata:{entityId:e.id}}));return{container:g,lines:u,text:m}},OR=(e,t,r,a)=>{let i=sr(t,"g.pele-edge-label[data-id]"),s=[],l=new Map(Array.from(sr(t,"g.pele-edges > g.pele-edge[data-id]")).map(([o,c])=>[o.match(/_(\d+)$/)?.[1],c]).filter(([o])=>o!==void 0));return{arrows:e.relationships.flatMap((o,c)=>{let f=l.get(String(c)),p=f&&Gi(f,t),d=r.get(o.entityA),g=r.get(o.entityB);if(!f||!p||p.route.length<2||!d||!g)return[];let u=o.entityA===o.entityB,m=u?p.route:Uh(Vh(p.route,An(d),An(g))),b=ta(o.roleA||""),w=i.get(f.getAttribute("data-id")),v=u&&w?.querySelector("text");return v&&s.push(Hr(v,t,a.fontSize)),[Ts(m,{label:b&&!v?{text:b,textAlign:"center",labelPosition:Xh(m,w,t)}:void 0,strokeStyle:o.relSpec.relType==="NON_IDENTIFYING"?"dashed":"solid",startArrowhead:W$[o.relSpec.cardB]??null,endArrowhead:W$[o.relSpec.cardA]??null,start:{type:"rectangle",id:o.entityA},end:{type:"rectangle",id:o.entityB},...m.length>2&&!u?{roundness:null}:{}})]}),labels:s}},B$=(e,t,r)=>{let a=[],i=[],s=[],l=new Map,n=sr(t,"g.pele-node.pele-entity[data-id]");e.entities.forEach((f,p)=>{let d=n.get(p),g=d&&DR(f,d,t,r);g&&(a.push(g.container),i.push(...g.lines),s.push(...g.text),l.set(f.id,g.container))});let{arrows:o,labels:c}=OR(e,t,l,r);return{type:"erd",nodes:[a],lines:i,arrows:o,text:[...s,...c]}};var PR=[["pele-state-start","stateStart"],["pele-state-end","stateEnd"],["pele-state-choice","choice"],["pele-state-fork","fork"],["pele-state-join","join"],["pele-note","note"]],zR=e=>{let t={},r=fr(e,"fill"),a=fr(e,"stroke"),i=ri(e,"stroke-width"),s=ri(e,"stroke-dasharray");return r&&(t[Tr.FILL]=r),a&&(t[Tr.STROKE]=a),i&&(t[Tr.STROKE_WIDTH]=i),s&&(t[Tr.STROKE_DASHARRAY]=s),t},FR=e=>{let t={},r=fr(e,"fill");return r&&(t[ai.COLOR]=r),t},WR=(e,t)=>{let r=Array.from(e.children).find(i=>i.tagName.toLowerCase()==="path"&&!i.getAttribute("class")&&i.getAttribute("fill")==="none"),[a]=r?za(r,t):[];return a?{startX:a.startX,startY:a.startY,endX:a.endX,endY:a.endY}:void 0},H$=(e,t,r,a)=>{let i=e.getAttribute("data-id"),s=e.querySelector("rect, circle, polygon, path"),l=yr(e,t);if(i===null||!l)return;let n=e.querySelectorAll(".pele-state-description"),o=r?"roundedWithTitle":PR.find(([f])=>bi(e,f))?.[1]??(n.length?"rectWithTitle":"rect"),c=e.querySelector(".pele-label, .pele-cluster-label");return{fontSize:c?ba(c,t,a):a,id:i,shape:o,text:ra(c).join(`
|
|
178
|
+
`),description:Array.from(n).flatMap(ra),...l,containerStyle:zR(s),labelStyle:FR(c),dividerLine:o==="rectWithTitle"||o==="roundedWithTitle"?WR(e,t):void 0,isRenderable:!0}},BR=(e,t)=>{let r=t.x+t.width,a=t.y+t.height;return e.x>=t.x&&e.x<=r&&e.y>=t.y&&e.y<=a?Math.min(e.x-t.x,r-e.x,e.y-t.y,a-e.y):Math.hypot(Math.max(t.x-e.x,0,e.x-r),Math.max(t.y-e.y,0,e.y-a))},Y$=(e,t)=>t.reduce((r,a)=>{let i=BR(e,a);return!r||i<r.distance-.5||i<r.distance+.5&&a.width*a.height<r.node.width*r.node.height?{node:a,distance:i}:r},void 0)?.node,U$=(e,t,r)=>{let a=Array.from(t.querySelectorAll("g.pele-cluster.pele-state-composite[data-id]")).flatMap(f=>H$(f,t,!0,r.fontSize)??[]),i=Array.from(t.querySelectorAll("g.pele-nodes > g.pele-node[data-id], g.pele-nodes > g.pele-note[data-id]")).flatMap(f=>H$(f,t,!1,r.fontSize)??[]),s=[...a,...i],l=sr(t,"g.pele-edge-label[data-id]"),n=[],o=Array.from(t.querySelectorAll("g.pele-edges > g.pele-edge[data-id]")).flatMap(f=>{let p=f.getAttribute("data-id"),d=Gi(f,t);if(!d||d.route.length<2)return[];let g=Uh(d.route),u=Y$(g[0],s),m=Y$(g[g.length-1],s);if(!u||!m)return[];let b=l.get(p)?.querySelector("text"),w=u===m;b&&w&&n.push(Hr(b,t,r.fontSize));let v=bi(f,"pele-note-edge"),k=g[0],L=g[g.length-1],I=b&&!w?yr(l.get(p),t):null;return[{id:p,start:u.id,end:m.id,text:b&&!w?ra(b).join(`
|
|
179
|
+
`):"",startX:k.x,startY:k.y,endX:L.x,endY:L.y,reflectionPoints:qh(g),strokeColor:fr(f,"stroke"),strokeStyle:v?"dashed":void 0,isNoteEdge:v,...I?{labelPosition:Mn(g,{x:I.x+I.width/2,y:I.y+I.height/2})}:{}}]}),c=Array.from(t.querySelectorAll("path.pele-divider")).flatMap(f=>za(f,t,{strokeStyle:"dashed"}));return{type:"state",nodes:s,edges:o,lines:c,texts:n}};var G$="Excalifont, Xiaolai, sans-serif, Segoe UI Emoji",En,q$=(e,t)=>{if(En===void 0)try{En=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"?document.createElement("canvas").getContext("2d"):null}catch{En=null}return En?(En.font=`${t}px ${G$}`,En.measureText(e).width):null},Qh=1.5,Zh=(e,t)=>({nodeSpacing:e*Qh,rankSpacing:t*Qh}),j$=e=>({flowchart:{curve:e.curve??to.flowchart.curve,...Zh(40,48)},class:Zh(40,56),er:Zh(48,64),state:Zh(40,44),sequence:{actorMargin:40*Qh,messageMargin:35*Qh}}),$u=e=>({fontSize:e.fontSize??20,responsive:!1,autoDirection:!1,config:j$(e)}),HR=new Set(["flowchart","sequence","class","er","state"]),Ql=(e,t)=>HR.has(e.type)?{...$u(t),fontFamily:G$}:$u(t),YR=(e,t)=>{if(!(e instanceof je)||e.code!=="syntax"||e.snippet.split(`
|
|
180
|
+
`)[0].trim())return e;let r=t.split(/\r?\n/),a=r.length-1;for(;a>=0&&!r[a].trim();)a--;let i=e.line-1-(r.length-1-a);if(a<0||i<1)return e;let s=r[a],l=`${s}
|
|
181
|
+
${"-".repeat(s.length)}^`;return e.message=e.message.replace(`on line ${e.line}`,`on line ${i}`).replace(e.snippet,l),e.line=i,e.column=s.length+1,e.snippet=l,e},UR=async e=>{let t=null;try{t=fd(e)}catch{}await c$(t)},qR=async(e,t)=>{try{return await UR(e),await d$(e,async r=>pd(r,{limit:t.maxTextSize??to.maxTextSize,maxEdges:t.maxEdges??to.maxEdges,config:j$(t)}))}catch(r){throw YR(r,e)}},GR=(e,t)=>{let{svg:r,width:a,height:i}=Mi(e,$u(t));return{type:"graphImage",mimeType:"image/svg+xml",dataURL:b$(r),width:a,height:i}};var V$=async(e,t={})=>{let r=await qR(e,t);try{switch(r.type){case"flowchart":{let{svg:a}=Mi(r,Ql(r,t)),i=t.fontSize??20;return R$(r,bn(a),{fontSize:i,measureText:s=>q$(s,i)})}case"sequence":{let{svg:a}=Mi(r,Ql(r,t));return z$(r,bn(a),{fontSize:t.fontSize??20,measureText:q$})}case"class":{let{svg:a}=Mi(r,Ql(r,t));return F$(r,bn(a),{fontSize:t.fontSize??20})}case"er":{let{svg:a}=Mi(r,Ql(r,t));return B$(r,bn(a),{fontSize:t.fontSize??20})}case"state":{let{svg:a}=Mi(r,Ql(r,t));return U$(r,bn(a),{fontSize:t.fontSize??20})}}}catch(a){console.error("Error processing Pele diagram:",a)}return GR(r,t)};var X$=(e,t={})=>V$(e,{fontSize:parseInt(t.themeVariables?.fontSize??"")||20,maxEdges:t.maxEdges,maxTextSize:t.maxTextSize,curve:t.flowchart?.curve});var K$=async(e,t)=>{let r=parseInt(t?.themeVariables?.fontSize??"")||20,a=await X$(e,t);return r0(a,{fontSize:r})};var jR=/(<?-->|<?==>|<?-\.->|---|-\.-|===|~~~|--[ox]|<-->)/g;function VR(e){let t=new Map,r,a=0,i={},s=e.match(/^---\s*\n([\s\S]*?)\n---[^\n]*\n?/);s&&(r=s[1].match(/^\s*title:\s*(.+)$/m)?.[1]?.trim());for(let l of e.slice(s?.[0].length??0).split(/\r?\n/)){let n=l.trim(),o=n.match(/^%%\s*([#>]|title\b)\s*(.*)$/);if(o){o[1]==="#"?i.chapter=o[2].trim():o[1]===">"?i.say=o[2].trim():r=o[2].trim();continue}if(n.startsWith("%%"))continue;let c=(n.match(jR)??[]).length;c&&(i.chapter||i.say)&&(t.set(a,i),i={}),a+=c}return{notes:t,title:r}}var ku=e=>(typeof e.label=="string"?e.label:e.label?.text)??"",Z$=e=>/^[A-Za-z_][\w-]*$/.test(e)?e:`n_${e.replace(/[^\w-]/g,"_")}`,Rt=e=>Math.round(e*10)/10;async function Q$(e,t,r={}){let a=(await t(e)).elements,{notes:i,title:s}=VR(e),l=a.filter(j=>j.type==="arrow"),n=new Map(a.filter(j=>j.id?.endsWith("__title")).map(j=>[j.id.slice(0,-7),ku(j)])),o=a.filter(j=>j.type!=="arrow"&&!j.id?.endsWith("__title"));if(!o.length)throw new Error("This Mermaid diagram has no shapes chalk-talk can draw yet (flowcharts first).");let c=o.flatMap(j=>[j.x,j.x+(j.width??0)]).concat(l.flatMap(j=>(j.points??[]).map(Z=>j.x+Z[0]))),f=o.flatMap(j=>[j.y,j.y+(j.height??0)]).concat(l.flatMap(j=>(j.points??[]).map(Z=>j.y+Z[1]))),[p,d,g,u]=[Math.min(...c),Math.max(...c),Math.min(...f),Math.max(...f)],m=s?100:50,b=Math.min(780/Math.max(1,d-p),(720-m-50)/Math.max(1,u-g),2.4),w=Math.round(Math.max(300,Math.min(720,(u-g)*b+m+50))),v=(900-(d-p)*b)/2-p*b,k=(j,Z)=>[Rt(v+j*b),Rt(m+(Z-g)*b)],L=Math.round(Math.max(18,Math.min(30,15*b))),I=[];s&&I.push({type:"text",at:[40,60],text:s,size:36});let N=new Set,O=o.filter(j=>j.id&&n.has(j.id)),W=j=>{let[Z,H]=k(j.x,j.y),[z,C]=[Rt((j.width??0)*b),Rt((j.height??0)*b)],S=Z$(j.id??`n${I.length}`),$=j.type==="ellipse"?{type:"ellipse",center:[Rt(Z+z/2),Rt(H+C/2)],rx:Rt(z/2),ry:Rt(C/2),id:S}:j.type==="diamond"?{type:"polygon",points:[[Rt(Z+z/2),H],[Rt(Z+z),Rt(H+C/2)],[Rt(Z+z/2),Rt(H+C)],[Z,Rt(H+C/2)]],id:S}:{type:"polygon",points:[[Z,H],[Rt(Z+z),H],[Rt(Z+z),Rt(H+C)],[Z,Rt(H+C)]],id:S},y=ku(j);return y?[$,{type:"text",at:[Rt(Z+z/2),Rt(H+C/2+L*.35)],text:y,size:L,anchor:"middle"}]:[$]},U=j=>{if(!j||N.has(j))return[];let Z=o.find(H=>H.id===j);return Z?(N.add(j),W(Z)):[]};for(let j of O){let[Z,H]=k(j.x,j.y),[z,C]=[Rt((j.width??0)*b),Rt((j.height??0)*b)];N.add(j.id),I.push({type:"polygon",points:[[Z,H],[Rt(Z+z),H],[Rt(Z+z),Rt(H+C)],[Z,Rt(H+C)]],id:Z$(j.id),style:{dashed:!0,color:"#8C8578"}}),n.get(j.id)&&I.push({type:"text",at:[Rt(Z+10),Rt(H+L+6)],text:n.get(j.id),size:Math.round(L*.85),style:{color:"#5E5A52"}})}l.forEach((j,Z)=>{let H=[...U(j.start?.id)],z=(j.points??[]).map($=>k(j.x+$[0],j.y+$[1])),C=j.strokeStyle==="dashed"||j.strokeStyle==="dotted"?{style:{dashed:!0}}:{};if(z.length>=2){z.length>2&&H.push({type:"polyline",points:z.slice(0,-1),...C}),H.push({type:"arrow",from:z[z.length-2],to:z[z.length-1],...C});let $=ku(j);if($){let y=Math.round(L*.8),E=q=>{let[D,R]=[Math.abs(z[q+1][0]-z[q][0]),Math.abs(z[q+1][1]-z[q][1])];return Math.hypot(D,R)*(Math.min(D,R)<2?2:1)},x=0;for(let q=1;q<z.length-1;q++)E(q)>E(x)&&(x=q);let[T,A]=[z[x],z[x+1]],[M,Y]=[(T[0]+A[0])/2,(T[1]+A[1])/2],B=Math.abs(A[0]-T[0])>=Math.abs(A[1]-T[1]);H.push(B?{type:"text",at:[Rt(M),Rt(Y-y*.55)],text:$,size:y,anchor:"middle"}:{type:"text",at:[Rt(M+y*.5),Rt(Y+y*.35)],text:$,size:y,anchor:"start"})}}H.push(...U(j.end?.id));let S=i.get(Z);S&&H.length&&Object.assign(H[0],S.chapter?{chapter:S.chapter}:{},S.say?{say:S.say}:{}),I.push(...H)});for(let j of o)j.id&&!N.has(j.id)&&I.push(...U(j.id));let _=I.findIndex(j=>j.chapter);if(_>0){let{chapter:j,say:Z}=I[_];Object.assign(I[0],{chapter:j},Z?{say:Z}:{}),delete I[_].chapter,delete I[_].say}return{id:(s??"mermaid").toLowerCase().normalize("NFD").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60)||"mermaid",title:s??"Mermaid",width:900,height:w,background:"plain",...r.locale?{locale:r.locale}:{},steps:I}}var J$=["and","or","not"];var Mu=["person","person-pointing","person-sitting","house","car","bus","coin","phone","document","server","bank","cloud","queue","desk","computer","clock","lock","money-arrow","tree","school","hospital","factory","truck","cart","safe","bulb","gear","database","robot"],ek={pessoa:"person","pessoa-apontando":"person-pointing","pessoa-sentada":"person-sitting",casa:"house",carro:"car",onibus:"bus",moeda:"coin",celular:"phone",documento:"document",servidor:"server",banco:"bank",nuvem:"cloud",fila:"queue",mesa:"desk",computador:"computer",relogio:"clock",cadeado:"lock","seta-dinheiro":"money-arrow"},rk=e=>Mu.includes(e)?e:typeof e=="string"&&Object.hasOwn(ek,e)?ek[e]:void 0;var ak=e=>rk(e)!==void 0,Ke={skin:"#E8C6A5",shirt:"#A9BCC3",wood:"#D8C29C",gold:"#F2C94C",paper:"#FFFFFF",screen:"#DCE8F0",device:"#5B6B7C",roof:"#D9785F",wall:"#F3E3C3",car:"#7FA7C9",bus:"#E9C46A",green:"#7DBE8A",dark:"#4A4A4A",metal:"#C9D3DD"},St=(e,t,r,a,i,s)=>({kind:"polygon",points:[[e,t],[e+r,t],[e+r,t+a],[e,t+a]],fill:i,main:s}),Lt=(...e)=>({kind:"polyline",points:e});function ik(e){return[{kind:"polygon",points:[[-.15,-.72],[.15,-.72],[.19,-.38],[-.19,-.38]],fill:Ke.shirt,main:!0},{kind:"circle",c:[0,-.87],r:.11,fill:Ke.skin},...e,Lt([-.08,-.38],[-.1,0]),Lt([.08,-.38],[.1,0])]}var tk=ik([Lt([-.15,-.7],[-.25,-.42]),Lt([.15,-.7],[.25,-.42])]);function XR(e,t,r){let a=([i,s])=>[r+i*t,s*t];return e.map(i=>i.kind==="circle"?{...i,c:a(i.c),r:i.r*t}:{...i,points:i.points.map(a)})}function KR(){let e=[[-.28,-.3,.18],[-.06,-.45,.25],[.2,-.4,.21],[.37,-.27,.13]],t=[];for(let r=0;r<=24;r++){let a=-.46+.96*r/24,i=e.filter(([s,,l])=>Math.abs(a-s)<=l).map(([s,l,n])=>l-Math.sqrt(Math.max(0,n*n-(a-s)**2)));i.length&&t.push([a,Math.min(...i)])}return[...t,[.42,-.12],[-.4,-.12]]}var JF={person:tk,"person-pointing":ik([Lt([-.15,-.7],[-.25,-.42]),Lt([.15,-.69],[.47,-.73])]),"person-sitting":[Lt([-.3,-.8],[-.27,-.4]),Lt([-.32,-.4],[.2,-.4]),Lt([-.27,-.4],[-.27,0]),Lt([.16,-.4],[.16,0]),{kind:"polygon",points:[[-.22,-.77],[.04,-.77],[.06,-.44],[-.22,-.44]],fill:Ke.shirt,main:!0},{kind:"circle",c:[-.08,-.9],r:.1,fill:Ke.skin},Lt([-.1,-.44],[.3,-.44],[.32,0]),Lt([0,-.74],[.18,-.55],[.3,-.58])],house:[St(-.4,-.6,.8,.6,Ke.wall,!0),{kind:"polygon",points:[[-.5,-.58],[0,-1],[.5,-.58]],fill:Ke.roof},St(-.08,-.32,.16,.32,Ke.wood),St(.16,-.46,.16,.14,Ke.screen)],car:[{kind:"polygon",fill:Ke.car,main:!0,points:[[-.5,-.14],[-.5,-.32],[-.3,-.36],[-.18,-.56],[.2,-.56],[.32,-.36],[.5,-.32],[.5,-.14]]},{kind:"polygon",points:[[-.14,-.51],[.17,-.51],[.25,-.37],[-.22,-.37]],fill:Ke.screen},{kind:"circle",c:[-.28,-.12],r:.1,fill:Ke.dark},{kind:"circle",c:[.28,-.12],r:.1,fill:Ke.dark}],bus:[St(-.5,-.66,1,.52,Ke.bus,!0),...[-.42,-.21,0,.21].map(e=>St(e,-.6,.15,.16,Ke.screen)),Lt([-.5,-.3],[.5,-.3]),{kind:"circle",c:[-.3,-.12],r:.1,fill:Ke.dark},{kind:"circle",c:[.3,-.12],r:.1,fill:Ke.dark}],coin:[{kind:"circle",c:[0,-.42],r:.4,fill:Ke.gold,main:!0},{kind:"circle",c:[0,-.42],r:.3},{kind:"curve",points:[[.1,-.56],[-.08,-.57],[-.09,-.46],[.08,-.39],[.08,-.29],[-.11,-.28]]},Lt([0,-.64],[0,-.2])],phone:[St(-.26,-1,.52,1,Ke.device,!0),St(-.2,-.92,.4,.76,Ke.screen),{kind:"circle",c:[0,-.08],r:.035,fill:Ke.paper}],document:[{kind:"polygon",points:[[-.36,-1],[.16,-1],[.36,-.8],[.36,0],[-.36,0]],fill:Ke.paper,main:!0},Lt([.16,-1],[.16,-.8],[.36,-.8]),...[-.66,-.5,-.34,-.18].map(e=>Lt([-.22,e],[.22,e]))],server:[-1,-.66,-.32].flatMap(e=>[St(-.36,e,.72,.3,Ke.metal,!0),Lt([-.26,e+.15],[.06,e+.15]),{kind:"circle",c:[.22,e+.15],r:.035,fill:Ke.green}]),bank:[{kind:"polygon",points:[[-.5,-.74],[0,-1],[.5,-.74]],fill:Ke.wall,main:!0},St(-.45,-.74,.9,.08,Ke.wall),...[-.33,-.11,.11,.33].map(e=>St(e-.04,-.66,.08,.56,Ke.paper)),St(-.5,-.1,1,.1,Ke.wall)],cloud:[{kind:"polygon",points:KR(),fill:Ke.paper,main:!0}],queue:[-.32,0,.32].flatMap(e=>XR(tk,.7,e)),desk:[St(-.5,-.5,1,.07,Ke.wood,!0),Lt([-.42,-.43],[-.42,0]),Lt([.42,-.43],[.42,0])],computer:[St(-.45,-1,.9,.6,Ke.device,!0),St(-.39,-.94,.78,.48,Ke.screen),{kind:"polygon",points:[[-.06,-.4],[.06,-.4],[.1,-.1],[-.1,-.1]],fill:Ke.device},St(-.25,-.1,.5,.08,Ke.device)],clock:[{kind:"circle",c:[0,-.48],r:.45,fill:Ke.paper,main:!0},...[[0,-.9,0,-.82],[.42,-.48,.34,-.48],[0,-.06,0,-.14],[-.42,-.48,-.34,-.48]].map(([e,t,r,a])=>Lt([e,t],[r,a])),Lt([0,-.48],[0,-.78]),Lt([0,-.48],[.2,-.48])],lock:[{kind:"curve",points:[[-.22,-.52],[-.22,-.76],[0,-.96],[.22,-.76],[.22,-.52]]},St(-.36,-.54,.72,.54,Ke.bus,!0),{kind:"circle",c:[0,-.32],r:.06,fill:Ke.dark},Lt([0,-.28],[0,-.14])],"money-arrow":[{kind:"polygon",fill:Ke.green,main:!0,points:[[-.5,-.4],[.12,-.4],[.12,-.56],[.5,-.3],[.12,-.04],[.12,-.2],[-.5,-.2]]},{kind:"circle",c:[-.2,-.3],r:.16,fill:Ke.gold},Lt([-.2,-.4],[-.2,-.2])],tree:[St(-.07,-.36,.14,.36,Ke.wood),{kind:"circle",c:[0,-.64],r:.3,fill:Ke.green,main:!0}],school:[St(-.45,-.6,.9,.6,Ke.wall,!0),{kind:"polygon",points:[[-.5,-.6],[0,-.82],[.5,-.6]],fill:Ke.roof},St(-.08,-.28,.16,.28,Ke.wood),St(-.36,-.48,.16,.12,Ke.screen),St(.2,-.48,.16,.12,Ke.screen),Lt([0,-.82],[0,-1]),{kind:"polygon",points:[[0,-1],[.17,-.95],[0,-.9]],fill:Ke.roof}],hospital:[St(-.4,-.8,.8,.8,Ke.paper,!0),St(-.045,-.7,.09,.26,"#C8442C"),St(-.13,-.615,.26,.09,"#C8442C"),St(-.1,-.24,.2,.24,Ke.metal)],factory:[{kind:"polygon",points:[[-.5,0],[-.5,-.5],[-.25,-.65],[-.25,-.5],[0,-.65],[0,-.5],[.25,-.65],[.25,-.5],[.5,-.5],[.5,0]],fill:Ke.wall,main:!0},St(.3,-.95,.12,.3,Ke.dark),St(-.38,-.32,.16,.12,Ke.screen),St(-.08,-.32,.16,.12,Ke.screen),St(.22,-.32,.16,.12,Ke.screen)],truck:[St(-.5,-.62,.62,.46,Ke.metal,!0),{kind:"polygon",points:[[.12,-.16],[.12,-.5],[.34,-.5],[.48,-.32],[.48,-.16]],fill:Ke.bus},{kind:"polygon",points:[[.18,-.46],[.32,-.46],[.42,-.33],[.18,-.33]],fill:Ke.screen},{kind:"circle",c:[-.3,-.1],r:.1,fill:Ke.dark},{kind:"circle",c:[.3,-.1],r:.1,fill:Ke.dark}],cart:[Lt([-.48,-.78],[-.4,-.62]),{kind:"polygon",points:[[-.4,-.62],[.42,-.62],[.32,-.26],[-.3,-.26]],fill:Ke.metal,main:!0},Lt([-.3,-.26],[-.3,-.14],[.32,-.14]),{kind:"circle",c:[-.22,-.07],r:.06,fill:Ke.dark},{kind:"circle",c:[.24,-.07],r:.06,fill:Ke.dark}],safe:[St(-.4,-.82,.8,.82,Ke.device,!0),St(-.3,-.72,.6,.62,Ke.metal),{kind:"circle",c:[0,-.41],r:.13,fill:Ke.paper},Lt([0,-.41],[.08,-.47])],bulb:[{kind:"circle",c:[0,-.62],r:.3,fill:Ke.gold,main:!0},St(-.13,-.33,.26,.2,Ke.metal),{kind:"curve",points:[[-.09,-.52],[0,-.66],[.09,-.52]]},Lt([-.08,-.08],[.08,-.08])],gear:[{kind:"polygon",points:[[.42,-.5],[.296,-.378],[.297,-.203],[.122,-.204],[0,-.08],[-.122,-.204],[-.297,-.203],[-.296,-.378],[-.42,-.5],[-.296,-.622],[-.297,-.797],[-.122,-.796],[-0,-.92],[.122,-.796],[.297,-.797],[.296,-.622]],fill:Ke.metal,main:!0},{kind:"circle",c:[0,-.5],r:.12,fill:Ke.paper}],database:[{kind:"polygon",points:[[-.35,-.8],[.35,-.8],[.35,-.16],[-.35,-.16]],fill:Ke.screen,main:!0},{kind:"polygon",points:[[.35,-.8],[.303,-.755],[.175,-.722],[0,-.71],[-.175,-.722],[-.303,-.755],[-.35,-.8],[-.303,-.845],[-.175,-.878],[-0,-.89],[.175,-.878],[.303,-.845]],fill:Ke.metal},{kind:"curve",points:[[-.35,-.16],[0,-.06],[.35,-.16]]},{kind:"curve",points:[[-.35,-.58],[0,-.48],[.35,-.58]]},{kind:"curve",points:[[-.35,-.37],[0,-.27],[.35,-.37]]}],robot:[Lt([0,-.95],[0,-1]),St(-.22,-.95,.44,.3,Ke.metal),{kind:"circle",c:[-.09,-.81],r:.045,fill:Ke.screen},{kind:"circle",c:[.09,-.81],r:.045,fill:Ke.screen},St(-.28,-.62,.56,.42,Ke.metal,!0),Lt([-.28,-.55],[-.42,-.35]),Lt([.28,-.55],[.42,-.35]),St(-.2,-.2,.12,.2,Ke.device),St(.08,-.2,.12,.2,Ke.device)]},sk=["happy","sad","surprised","worried","idea"],ZR={person:[0,-.87,.11],"person-pointing":[0,-.87,.11],"person-sitting":[-.08,-.9,.1]},nk=e=>{let t=rk(e);return!!t&&t in ZR};var QR=["card","line","arrow","polyline","polygon","curve","circle","ellipse","plot","text","highlight","pause","prop","repeat","when","move","link","counter","row","column","grid","axis","timeline","balloon","brace","note","table","bars"],Jh=["text","prop","card","counter","circle","ellipse"],lk=["row","column","grid"],JR=50;function Or(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}: expected an object.`)}function Jt(e,t){if(typeof e!="string"||!e.trim()||e.length>2e3)throw new Error(`${t}: expected text of 1 to 2000 characters.`)}function Pt(e,t,r=-1e4,a=1e4){if(typeof e!="number"||!Number.isFinite(e)||e<r||e>a)throw new Error(`${t}: expected a number between ${r} and ${a}.`)}function aa(e,t){if(typeof e=="string"){if(Jt(e,t),e.length>300)throw new Error(`${t}: expression too long.`)}else Pt(e,t)}function Yr(e,t){if(!Array.isArray(e)||e.length!==2)throw new Error(`${t}: expected [x, y].`);e.forEach((r,a)=>aa(r,`${t}[${a}]`))}function $i(e,t){e!==void 0&&Jt(e,t)}function $a(e,t,r){if(e!==void 0&&(typeof e!="string"||!t.includes(e)))throw new Error(`${r}: choose one of ${t.join(", ")}.`)}function ed(e){if(!/^[A-Za-z_][A-Za-z_0-9]*$/.test(e)||["__proto__","constructor","prototype",...J$].includes(e))throw new Error(`Invalid variable name: "${e}".`)}var Jl=(e,t)=>t.includes("{")||e.exact.has(t)||[...e.repeated].some(r=>t.startsWith(`${r}-`)&&/^\d+$/.test(t.slice(r.length+1)));function Sn(e,t,r,a){a&&e[t]===void 0&&(e[t]=[0,0]),Yr(e[t],`${r}.${t}`)}function td(e,t,r,a,i=!1){if(Or(e,t),++r.count>500)throw new Error(`${t}: a recipe draws at most 500 steps, counting those inside repeat and when.`);if(a){for(let n of["chapter","say","duration"])if(e[n]!==void 0)throw new Error(`${t}.${n}: put it on the ${a} step itself, not on a step inside it.`);if(e.type==="pause")throw new Error(`${t}: a pause cannot go inside ${a}.`);if(e.type==="repeat"&&a==="repeat")throw new Error(`${t}: a repeat cannot go inside another repeat.`);if(lk.includes(a)&&e.place!==void 0)throw new Error(`${t}.place: the ${a} places the steps inside it.`)}if(!QR.includes(e.type))throw new Error(`${t}: unknown type "${e.type}".`);for(let n of["id","say","chapter"])$i(e[n],`${t}.${n}`);if(e.duration!==void 0&&Pt(e.duration,`${t}.duration`,0,3e4),e.nudge!==void 0){if(["pause","move","link"].includes(e.type))throw new Error(`${t}.nudge: a ${e.type} has no place of its own to move.`);if(!Array.isArray(e.nudge)||e.nudge.length!==2)throw new Error(`${t}.nudge: use [dx, dy].`);e.nudge.forEach((n,o)=>Pt(n,`${t}.nudge[${o}]`,-900,900))}let s=a!==null&&lk.includes(a)||i;if(e.place!==void 0){if(!Jh.includes(e.type))throw new Error(`${t}.place: only ${Jh.join(", ")} can be placed.`);if(Or(e.place,`${t}.place`),Jt(e.place.to,`${t}.place.to`),!Jl(r,String(e.place.to)))throw new Error(`${t}.place.to: no earlier step has the id "${e.place.to}".`);if(!["below","above","left","right"].includes(e.place.side))throw new Error(`${t}.place.side: choose one of below, above, left, right.`);e.place.gap!==void 0&&Pt(e.place.gap,`${t}.place.gap`,-200,400),$a(e.place.align,["center","start","end"],`${t}.place.align`)}let l=s||e.place!==void 0;if(e.style!==void 0){Or(e.style,`${t}.style`);for(let n of["color","fill"]){let o=e.style[n];if(o!==void 0&&(typeof o!="string"||!/^(#[\da-f]{3,8}|[a-z]+)$/i.test(o)))throw new Error(`${t}.style.${n}: use a hex colour or a colour name, no URLs.`)}for(let n of["width","roughness","bowing"])e.style[n]!==void 0&&Pt(e.style[n],`${t}.style.${n}`,0,20);if(e.style.opacity!==void 0&&Pt(e.style.opacity,`${t}.style.opacity`,0,1),e.style.dashed!==void 0&&typeof e.style.dashed!="boolean")throw new Error(`${t}: dashed must be a boolean.`);$a(e.style.fillStyle,["hachure","solid","zigzag","cross-hatch","dots"],`${t}.style.fillStyle`)}switch(e.type){case"line":case"arrow":case"highlight":Yr(e.from,`${t}.from`),Yr(e.to,`${t}.to`),e.thickness!==void 0&&Pt(e.thickness,`${t}.thickness`,1,200);break;case"polyline":case"polygon":case"curve":if(!Array.isArray(e.points)||e.points.length<(e.type==="polygon"?3:2)||e.points.length>500)throw new Error(`${t}: points needs ${e.type==="polygon"?3:2} to 500 points.`);e.points.forEach((n,o)=>Yr(n,`${t}.points[${o}]`));break;case"circle":case"ellipse":Sn(e,"center",t,l);for(let n of e.type==="circle"?["r"]:["rx","ry"])aa(e[n],`${t}.${n}`),typeof e[n]=="number"&&Pt(e[n],`${t}.${n}`,0);break;case"text":Sn(e,"at",t,l),Jt(e.text,`${t}.text`),e.size!==void 0&&Pt(e.size,`${t}.size`,1,200),e.rotate!==void 0&&Pt(e.rotate,`${t}.rotate`,-360,360),$a(e.font,["hand","body"],`${t}.font`),$a(e.anchor,["start","middle","end"],`${t}.anchor`);break;case"card":Sn(e,"at",t,l),aa(e.w,`${t}.w`),aa(e.h,`${t}.h`);for(let n of["w","h"])typeof e[n]=="number"&&Pt(e[n],`${t}.${n}`,40);if(Jt(e.title,`${t}.title`),e.lines!==void 0){if(!Array.isArray(e.lines)||e.lines.length>6)throw new Error(`${t}: at most 6 lines per card.`);e.lines.forEach((n,o)=>Jt(n,`${t}.lines[${o}]`))}break;case"plot":Jt(e.fn,`${t}.fn`),e.var!==void 0&&(Jt(e.var,`${t}.var`),ed(String(e.var))),Yr(e.domain,`${t}.domain`),Yr(e.range,`${t}.range`),Or(e.box,`${t}.box`);for(let n of["x","y","w","h"])aa(e.box[n],`${t}.box.${n}`);if(e.samples!==void 0&&(Pt(e.samples,`${t}.samples`,2,1e3),!Number.isInteger(e.samples)))throw new Error(`${t}: samples must be an integer.`);break;case"pause":Pt(e.ms,`${t}.ms`,0,3e4),$i(e.ask,`${t}.ask`);break;case"prop":if(!ak(e.name))throw new Error(`${t}.name: unknown prop "${String(e.name)}"; use one of ${Mu.join(", ")}.`);if(Sn(e,"at",t,l),e.size!==void 0&&(aa(e.size,`${t}.size`),typeof e.size=="number"&&Pt(e.size,`${t}.size`,10,1e3)),$i(e.label,`${t}.label`),e.flip!==void 0&&typeof e.flip!="boolean")throw new Error(`${t}.flip: expected true or false.`);if(e.mood!==void 0){if(!nk(e.name))throw new Error(`${t}.mood: only a person (person, person-pointing, person-sitting) has a face.`);$a(e.mood,sk,`${t}.mood`)}break;case"repeat":if(aa(e.times,`${t}.times`),typeof e.times=="number"&&(Pt(e.times,`${t}.times`,0,JR),!Number.isInteger(e.times)))throw new Error(`${t}.times: expected a whole number.`);td(e.step,`${t}.step`,r,"repeat",s);break;case"when":if(aa(e.if,`${t}.if`),!Array.isArray(e.steps)||e.steps.length===0||e.steps.length>50)throw new Error(`${t}.steps: expected 1 to 50 steps.`);e.steps.forEach((n,o)=>td(n,`${t}.steps[${o}]`,r,a??"when"));break;case"move":if(Jt(e.target,`${t}.target`),!Jl(r,String(e.target)))throw new Error(`${t}.target: no earlier step has the id "${e.target}".`);Yr(e.to,`${t}.to`),$a(e.along,["line","curve"],`${t}.along`),e.ms!==void 0&&Pt(e.ms,`${t}.ms`,200,5e3);break;case"link":for(let n of["from","to"])if(Jt(e[n],`${t}.${n}`),!Jl(r,String(e[n])))throw new Error(`${t}.${n}: no earlier step has the id "${e[n]}".`);$i(e.label,`${t}.label`);break;case"counter":if(Sn(e,"at",t,l),aa(e.value,`${t}.value`),e.format!==void 0&&(Jt(e.format,`${t}.format`),!String(e.format).includes("{v")))throw new Error(`${t}.format: show the number as {v}, e.g. "R$ {v:0}".`);e.size!==void 0&&Pt(e.size,`${t}.size`,1,200),$a(e.anchor,["start","middle","end"],`${t}.anchor`);break;case"row":case"column":case"grid":if(s)throw new Error(`${t}: a ${e.type} cannot go inside another ${a}.`);if(Sn(e,"at",t,!1),e.gap!==void 0&&Pt(e.gap,`${t}.gap`,0,400),e.type==="grid"){if(Pt(e.columns,`${t}.columns`,1,12),!Number.isInteger(e.columns))throw new Error(`${t}.columns: expected a whole number.`)}else $a(e.align,["center","start","end"],`${t}.align`);if(!Array.isArray(e.steps)||e.steps.length===0||e.steps.length>50)throw new Error(`${t}.steps: expected 1 to 50 steps.`);e.steps.forEach((n,o)=>{Or(n,`${t}.steps[${o}]`);let c=n.type==="repeat"?n.step?.type:n.type;if(!Jh.includes(c))throw new Error(`${t}.steps[${o}]: a ${e.type} holds only ${Jh.join(", ")} (or a repeat of one).`);td(n,`${t}.steps[${o}]`,r,e.type)});break;case"axis":case"timeline":if(Yr(e.from,`${t}.from`),Yr(e.to,`${t}.to`),Yr(e.domain,`${t}.domain`),e.type==="axis"){if(e.ticks!==void 0){if(Array.isArray(e.ticks)){if(e.ticks.length>30)throw new Error(`${t}.ticks: at most 30 marks.`);e.ticks.forEach((n,o)=>Pt(n,`${t}.ticks[${o}]`))}else if(Pt(e.ticks,`${t}.ticks`,0,30),!Number.isInteger(e.ticks))throw new Error(`${t}.ticks: expected a whole number.`)}if($i(e.label,`${t}.label`),e.format!==void 0&&(Jt(e.format,`${t}.format`),!String(e.format).includes("{v")))throw new Error(`${t}.format: show the number as {v}, e.g. "{v} km".`)}else{if(!Array.isArray(e.marks)||e.marks.length===0||e.marks.length>20)throw new Error(`${t}.marks: expected 1 to 20 marks.`);e.marks.forEach((n,o)=>{Or(n,`${t}.marks[${o}]`),aa(n.at,`${t}.marks[${o}].at`),$i(n.label,`${t}.marks[${o}].label`),$i(n.text,`${t}.marks[${o}].text`)})}break;case"balloon":if(Jt(e.to,`${t}.to`),!Jl(r,String(e.to)))throw new Error(`${t}.to: no earlier step has the id "${e.to}".`);if(Jt(e.text,`${t}.text`),String(e.text).length>300)throw new Error(`${t}.text: keep a balloon under 300 characters.`);$a(e.side,["below","above","left","right"],`${t}.side`),$a(e.kind,["speech","thought"],`${t}.kind`),e.width!==void 0&&Pt(e.width,`${t}.width`,80,600),e.size!==void 0&&Pt(e.size,`${t}.size`,12,60);break;case"brace":if(Yr(e.from,`${t}.from`),Yr(e.to,`${t}.to`),$i(e.label,`${t}.label`),e.flip!==void 0&&typeof e.flip!="boolean")throw new Error(`${t}.flip: expected true or false.`);break;case"note":if(Yr(e.at,`${t}.at`),Jt(e.text,`${t}.text`),e.to===void 0==(e.point===void 0))throw new Error(`${t}: a note points either to an element (to) or to a point (point).`);if(e.to!==void 0){if(Jt(e.to,`${t}.to`),!Jl(r,String(e.to)))throw new Error(`${t}.to: no earlier step has the id "${e.to}".`)}else Yr(e.point,`${t}.point`);e.size!==void 0&&Pt(e.size,`${t}.size`,12,60);break;case"table":if(Yr(e.at,`${t}.at`),!Array.isArray(e.rows)||e.rows.length===0||e.rows.length>12)throw new Error(`${t}.rows: expected 1 to 12 rows.`);if(e.rows.forEach((n,o)=>{if(!Array.isArray(n)||n.length===0||n.length>6)throw new Error(`${t}.rows[${o}]: expected 1 to 6 cells.`);n.forEach((c,f)=>{if(typeof c!="string"||c.length>120)throw new Error(`${t}.rows[${o}][${f}]: expected text of up to 120 characters.`)})}),e.header!==void 0&&typeof e.header!="boolean")throw new Error(`${t}.header: expected true or false.`);e.size!==void 0&&Pt(e.size,`${t}.size`,12,40);break;case"bars":Or(e.box,`${t}.box`);for(let n of["x","y","w","h"])aa(e.box[n],`${t}.box.${n}`);if(!Array.isArray(e.values)||e.values.length===0||e.values.length>12)throw new Error(`${t}.values: expected 1 to 12 values.`);if(e.values.forEach((n,o)=>aa(n,`${t}.values[${o}]`)),e.labels!==void 0){if(!Array.isArray(e.labels)||e.labels.length>e.values.length)throw new Error(`${t}.labels: at most one label per value.`);e.labels.forEach((n,o)=>Jt(n,`${t}.labels[${o}]`))}if(e.max!==void 0&&aa(e.max,`${t}.max`),e.format!==void 0&&(Jt(e.format,`${t}.format`),!String(e.format).includes("{v")))throw new Error(`${t}.format: show the number as {v}, e.g. "{v}%".`);break}typeof e.id=="string"&&(a==="repeat"?r.repeated:r.exact).add(e.id)}function ok(e){Or(e,"The recipe");let t=e;Pt(t.width,"width",100,4e3),Pt(t.height,"height",100,4e3);for(let a of["id","title","category"])$i(t[a],a);if(t.locale!==void 0&&!(typeof t.locale=="string"&&/^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$/.test(t.locale)&&Intl.NumberFormat.supportedLocalesOf([t.locale]).length>0))throw new Error('locale: expected a language tag such as "en-US" or "pt-BR".');if($a(t.background,["dots","grid","plain"],"background"),$a(t.theme,["paper","chalkboard"],"theme"),t.quiz!==void 0){if(Or(t.quiz,"quiz"),Jt(t.quiz.question,"quiz.question"),!Array.isArray(t.quiz.options)||t.quiz.options.length<2||t.quiz.options.length>4)throw new Error("quiz.options: expected 2 to 4 options.");if(t.quiz.options.forEach((a,i)=>{if(Or(a,`quiz.options[${i}]`),Jt(a.text,`quiz.options[${i}].text`),Jt(a.why,`quiz.options[${i}].why`),typeof a.right!="boolean")throw new Error(`quiz.options[${i}].right: expected true or false.`)}),t.quiz.options.filter(a=>a.right===!0).length!==1)throw new Error("quiz.options: exactly one option is right.")}if(t.learning!==void 0){Or(t.learning,"learning");for(let a of["goal","question","answer","caveat"])Jt(t.learning[a],`learning.${a}`)}if(t.params!==void 0){Or(t.params,"params");for(let[a,i]of Object.entries(t.params))if(ed(a),Or(i,`params.${a}`),Jt(i.label,`params.${a}.label`),Pt(i.min,`${a}.min`),Pt(i.max,`${a}.max`),Pt(i.step,`${a}.step`,1e-6),Pt(i.value,`${a}.value`,i.min,i.max),i.max<=i.min)throw new Error(`${a}: max must be greater than min.`)}if(t.vars!==void 0){Or(t.vars,"vars");for(let[a,i]of Object.entries(t.vars))ed(a),aa(i,`vars.${a}`)}if(t.switches!==void 0){Or(t.switches,"switches");let a=Object.entries(t.switches);if(a.length>8)throw new Error("switches: at most 8.");for(let[i,s]of a){if(ed(i),Object.hasOwn(t.params??{},i)||Object.hasOwn(t.vars??{},i))throw new Error(`switches.${i}: the name is already a param or a var.`);if(Or(s,`switches.${i}`),Jt(s.label,`switches.${i}.label`),typeof s.on!="boolean")throw new Error(`switches.${i}.on: expected true or false.`)}}if(!Array.isArray(t.steps)||t.steps.length===0||t.steps.length>250)throw new Error("A recipe needs 1 to 250 steps.");let r={exact:new Set,repeated:new Set,count:0};return t.steps.forEach((a,i)=>td(a,`Step ${i+1}`,r,null)),{...t,id:t.id??"pasted",title:t.title??"",background:t.background??"dots"}}async function lW(e,t={}){return ok(await Q$(e,K$,t))}export{lW as readMermaid};
|