/g,`
+`)),a+=d+n[l+1]}),a}function cke(t,{markdownAutoWrap:e}){const n=t.replace(/
/g,`
`).replace(/\n{2,}/g,`
-`);return rke(n)}w(nke,"preprocessMarkdown");function ike(t){return t.split(/\\n|\n|
/gi).map(e=>{var r;return((r=e.trim().match(/<[^>]+>|[^\s<>]+/g))==null?void 0:r.map(n=>({content:n,type:"normal"})))??[]})}w(ike,"nonMarkdownToLines");function ske(t,e={}){const r=nke(t,e),n=di.lexer(r),i=[[]];let s=0;function a(o,l="normal"){o.type==="text"?o.text.split(`
-`).forEach((h,d)=>{d!==0&&(s++,i.push([])),h.split(" ").forEach(f=>{f=f.replace(/'/g,"'"),f&&i[s].push({content:f,type:l})})}):o.type==="strong"||o.type==="em"?o.tokens.forEach(u=>{a(u,o.type)}):o.type==="html"&&i[s].push({content:o.text,type:"normal"})}return w(a,"processNode"),n.forEach(o=>{var l;o.type==="paragraph"?(l=o.tokens)==null||l.forEach(u=>{a(u)}):o.type==="html"?i[s].push({content:o.text,type:"normal"}):i[s].push({content:o.raw,type:"normal"})}),i}w(ske,"markdownToLines");function ake(t){return t?`${t.replace(/\\n|\n/g,"
")}
`:""}w(ake,"nonMarkdownToHTML");function oke(t,{markdownAutoWrap:e}={}){const r=di.lexer(t);function n(i){var s,a,o;return i.type==="text"?e===!1?i.text.replace(/\n */g,"
").replace(/ /g," "):i.text.replace(/\n */g,"
"):i.type==="strong"?`${(s=i.tokens)==null?void 0:s.map(n).join("")}`:i.type==="em"?`${(a=i.tokens)==null?void 0:a.map(n).join("")}`:i.type==="paragraph"?`${(o=i.tokens)==null?void 0:o.map(n).join("")}
`:i.type==="space"?"":i.type==="html"?`${i.text}`:i.type==="escape"?i.text:(de.warn(`Unsupported markdown: ${i.type}`),i.raw)}return w(n,"output"),r.map(n).join("")}w(oke,"markdownToHTML");function lke(t){return Intl.Segmenter?[...new Intl.Segmenter().segment(t)].map(e=>e.segment):[...t]}w(lke,"splitTextToChars");function cke(t,e){const r=lke(e.content);return bZ(t,[],r,e.type)}w(cke,"splitWordToFitWidth");function bZ(t,e,r,n){if(r.length===0)return[{content:e.join(""),type:n},{content:"",type:n}];const[i,...s]=r,a=[...e,i];return t([{content:a.join(""),type:n}])?bZ(t,a,s,n):(e.length===0&&i&&(e.push(i),r.shift()),[{content:e.join(""),type:n},{content:r.join(""),type:n}])}w(bZ,"splitWordToFitWidthRecursion");function uke(t,e){if(t.some(({content:r})=>r.includes(`
-`)))throw new Error("splitLineToFitWidth does not support newlines in the line");return s_(t,e)}w(uke,"splitLineToFitWidth");function s_(t,e,r=[],n=[]){if(t.length===0)return n.length>0&&r.push(n),r.length>0?r:[];let i="";t[0].content===" "&&(i=" ",t.shift());const s=t.shift()??{content:" ",type:"normal"},a=[...n];if(i!==""&&a.push({content:i,type:"normal"}),a.push(s),e(a))return s_(t,e,r,a);if(n.length>0)r.push(n),t.unshift(s);else if(s.content){const[o,l]=cke(e,s);r.push([o]),l.content&&t.unshift(l)}return s_(t,e,r)}w(s_,"splitLineToFitWidthRecursion");function wG(t,e){e&&t.attr("style",e)}w(wG,"applyStyle");var oce=16384;async function hke(t,e,r,n,i=!1,s=vr()){const a=t.append("foreignObject");a.attr("width",`${Math.min(10*r,oce)}px`),a.attr("height",`${Math.min(10*r,oce)}px`);const o=a.append("xhtml:div"),l=Ks(e.label)?await BN(e.label.replace(Vt.lineBreakRegex,`
-`),s):Ln(e.label,s),u=e.isNode?"nodeLabel":"edgeLabel",h=o.append("span");h.html(l),wG(h,e.labelStyle),h.attr("class",`${u} ${n}`),wG(o,e.labelStyle),o.style("display","table-cell"),o.style("white-space","nowrap"),o.style("line-height","1.5"),r!==Number.POSITIVE_INFINITY&&(o.style("max-width",r+"px"),o.style("text-align","center")),o.attr("xmlns","http://www.w3.org/1999/xhtml"),i&&o.attr("class","labelBkg");let d=o.node().getBoundingClientRect();return d.width===r&&(o.style("display","table"),o.style("white-space","break-spaces"),o.style("width",r+"px"),d=o.node().getBoundingClientRect()),a.node()}w(hke,"addHtmlSpan");function tD(t,e,r,n=!1){const i=t.append("tspan").attr("class","text-outer-tspan").attr("x",0).attr("y",e*r-.1+"em").attr("dy",r+"em");return n&&i.attr("text-anchor","middle"),i}w(tD,"createTspan");function dke(t,e,r){const n=t.append("text"),i=tD(n,1,e);rD(i,r);const s=i.node().getComputedTextLength();return n.remove(),s}w(dke,"computeWidthOfText");function fke(t,e,r){var a;const n=t.append("text"),i=tD(n,1,e);rD(i,[{content:r,type:"normal"}]);const s=(a=i.node())==null?void 0:a.getBoundingClientRect();return s&&n.remove(),s}w(fke,"computeDimensionOfText");function pke(t,e,r,n=!1,i=!1){const a=e.append("g"),o=a.insert("rect").attr("class","background").attr("style","stroke: none"),l=a.append("text").attr("y","-10.1");i&&l.attr("text-anchor","middle");let u=0;for(const h of r){const d=w(p=>dke(a,1.1,p)<=t,"checkWidth"),f=d(h)?[h]:uke(h,d);for(const p of f){const g=tD(l,u,1.1,i);rD(g,p),u++}}if(n){const h=l.node().getBBox(),d=2;return o.attr("x",h.x-d).attr("y",h.y-d).attr("width",h.width+2*d).attr("height",h.height+2*d),a.node()}else return l.node()}w(pke,"createFormattedText");function TG(t){const e=/&(amp|lt|gt);/g;return t.replace(e,(r,n)=>{switch(n){case"amp":return"&";case"lt":return"<";case"gt":return">";default:return r}})}w(TG,"decodeHTMLEntities");function rD(t,e){t.text(""),e.forEach((r,n)=>{const i=t.append("tspan").attr("font-style",r.type==="em"?"italic":"normal").attr("class","text-inner-tspan").attr("font-weight",r.type==="strong"?"bold":"normal");n===0?i.text(TG(r.content)):i.text(" "+TG(r.content))})}w(rD,"updateTextContentAndStyles");async function gke(t,e={}){const r=[];t.replace(/(fa[bklrs]?):fa-([\w-]+)/g,(i,s,a)=>(r.push((async()=>{const o=`${s}:${a}`;return await MTt(o)?await d0(o,void 0,{class:"label-icon"}):``})()),i));const n=await Promise.all(r);return t.replace(/(fa[bklrs]?):fa-([\w-]+)/g,()=>n.shift()??"")}w(gke,"replaceIconSubstring");var Zo=w(async(t,e="",{style:r="",isTitle:n=!1,classes:i="",useHtmlLabels:s=!0,markdown:a=!0,isNode:o=!0,width:l=200,addSvgBackground:u=!1}={},h)=>{if(de.debug("XYZ createText",e,r,n,i,s,o,"addSvgBackground: ",u),s){const d=a?oke(e,h):ake(e),f=await gke(h0(d),h),p=e.replace(/\\\\/g,"\\"),g={isNode:o,label:Ks(e)?p:f,labelStyle:r.replace("fill:","color:")};return await hke(t,g,l,i,u,h)}else{const d=h0(e.replace(/
/g,"
")),f=a?ske(d.replace("
","
"),h):ike(d),p=pke(l,t,f,e?u:!1,!o);if(o){/stroke:/.exec(r)&&(r=r.replace("stroke:","lineColor:"));const g=r.replace(/stroke:[^;]+;?/g,"").replace(/stroke-width:[^;]+;?/g,"").replace(/fill:[^;]+;?/g,"").replace(/color:/g,"fill:");wt(p).attr("style",g)}else{const g=r.replace(/stroke:[^;]+;?/g,"").replace(/stroke-width:[^;]+;?/g,"").replace(/fill:[^;]+;?/g,"").replace(/background:/g,"fill:");wt(p).select("rect").attr("style",g.replace(/background:/g,"fill:"));const m=r.replace(/stroke:[^;]+;?/g,"").replace(/stroke-width:[^;]+;?/g,"").replace(/fill:[^;]+;?/g,"").replace(/color:/g,"fill:");wt(p).select("text").attr("style",m)}return n?wt(p).selectAll("tspan.text-outer-tspan").classed("title-row",!0):wt(p).selectAll("tspan.text-outer-tspan").classed("row",!0),p}},"createText");function K$(t,e,r){if(t&&t.length){const[n,i]=e,s=Math.PI/180*r,a=Math.cos(s),o=Math.sin(s);for(const l of t){const[u,h]=l;l[0]=(u-n)*a-(h-i)*o+n,l[1]=(u-n)*o+(h-i)*a+i}}}function d5t(t,e){return t[0]===e[0]&&t[1]===e[1]}function f5t(t,e,r,n=1){const i=r,s=Math.max(e,.1),a=t[0]&&t[0][0]&&typeof t[0][0]=="number"?[t]:t,o=[0,0];if(i)for(const u of a)K$(u,o,i);const l=(function(u,h,d){const f=[];for(const x of u){const b=[...x];d5t(b[0],b[b.length-1])||b.push([b[0][0],b[0][1]]),b.length>2&&f.push(b)}const p=[];h=Math.max(h,.1);const g=[];for(const x of f)for(let b=0;bx.yminb.ymin?1:x.xb.x?1:x.ymax===b.ymax?0:(x.ymax-b.ymax)/Math.abs(x.ymax-b.ymax))),!g.length)return p;let m=[],y=g[0].ymin,v=0;for(;m.length||g.length;){if(g.length){let x=-1;for(let b=0;by);b++)x=b;g.splice(0,x+1).forEach((b=>{m.push({s:y,edge:b})}))}if(m=m.filter((x=>!(x.edge.ymax<=y))),m.sort(((x,b)=>x.edge.x===b.edge.x?0:(x.edge.x-b.edge.x)/Math.abs(x.edge.x-b.edge.x))),(d!==1||v%h==0)&&m.length>1)for(let x=0;x=m.length)break;const T=m[x].edge,C=m[b].edge;p.push([[Math.round(T.x),y],[Math.round(C.x),y]])}y+=d,m.forEach((x=>{x.edge.x=x.edge.x+d*x.edge.islope})),v++}return p})(a,s,n);if(i){for(const u of a)K$(u,o,-i);(function(u,h,d){const f=[];u.forEach((p=>f.push(...p))),K$(f,h,d)})(l,o,-i)}return l}function t7(t,e){var r;const n=e.hachureAngle+90;let i=e.hachureGap;i<0&&(i=4*e.strokeWidth),i=Math.round(Math.max(i,.1));let s=1;return e.roughness>=1&&(((r=e.randomizer)===null||r===void 0?void 0:r.next())||Math.random())>.7&&(s=i),f5t(t,i,n,s||1)}class xZ{constructor(e){this.helper=e}fillPolygons(e,r){return this._fillPolygons(e,r)}_fillPolygons(e,r){const n=t7(e,r);return{type:"fillSketch",ops:this.renderLines(n,r)}}renderLines(e,r){const n=[];for(const i of e)n.push(...this.helper.doubleLineOps(i[0][0],i[0][1],i[1][0],i[1][1],r));return n}}function nD(t){const e=t[0],r=t[1];return Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2))}let p5t=class extends xZ{fillPolygons(e,r){let n=r.hachureGap;n<0&&(n=4*r.strokeWidth),n=Math.max(n,.1);const i=t7(e,Object.assign({},r,{hachureGap:n})),s=Math.PI/180*r.hachureAngle,a=[],o=.5*n*Math.cos(s),l=.5*n*Math.sin(s);for(const[u,h]of i)nD([u,h])&&a.push([[u[0]-o,u[1]+l],[...h]],[[u[0]+o,u[1]-l],[...h]]);return{type:"fillSketch",ops:this.renderLines(a,r)}}};class g5t extends xZ{fillPolygons(e,r){const n=this._fillPolygons(e,r),i=Object.assign({},r,{hachureAngle:r.hachureAngle+90}),s=this._fillPolygons(e,i);return n.ops=n.ops.concat(s.ops),n}}let m5t=class{constructor(e){this.helper=e}fillPolygons(e,r){const n=t7(e,r=Object.assign({},r,{hachureAngle:0}));return this.dotsOnLines(n,r)}dotsOnLines(e,r){const n=[];let i=r.hachureGap;i<0&&(i=4*r.strokeWidth),i=Math.max(i,.1);let s=r.fillWeight;s<0&&(s=r.strokeWidth/2);const a=i/4;for(const o of e){const l=nD(o),u=l/i,h=Math.ceil(u)-1,d=l-h*i,f=(o[0][0]+o[1][0])/2-i/4,p=Math.min(o[0][1],o[1][1]);for(let g=0;g{const o=nD(a),l=Math.floor(o/(n+i)),u=(o+i-l*(n+i))/2;let h=a[0],d=a[1];h[0]>d[0]&&(h=a[1],d=a[0]);const f=Math.atan((d[1]-h[1])/(d[0]-h[0]));for(let p=0;p{const a=nD(s),o=Math.round(a/(2*r));let l=s[0],u=s[1];l[0]>u[0]&&(l=s[1],u=s[0]);const h=Math.atan((u[1]-l[1])/(u[0]-l[0]));for(let d=0;dh%2?u+r:u+e));s.push({key:"C",data:l}),e=l[4],r=l[5];break}case"Q":s.push({key:"Q",data:[...o]}),e=o[2],r=o[3];break;case"q":{const l=o.map(((u,h)=>h%2?u+r:u+e));s.push({key:"Q",data:l}),e=l[2],r=l[3];break}case"A":s.push({key:"A",data:[...o]}),e=o[5],r=o[6];break;case"a":e+=o[5],r+=o[6],s.push({key:"A",data:[o[0],o[1],o[2],o[3],o[4],e,r]});break;case"H":s.push({key:"H",data:[...o]}),e=o[0];break;case"h":e+=o[0],s.push({key:"H",data:[e]});break;case"V":s.push({key:"V",data:[...o]}),r=o[0];break;case"v":r+=o[0],s.push({key:"V",data:[r]});break;case"S":s.push({key:"S",data:[...o]}),e=o[2],r=o[3];break;case"s":{const l=o.map(((u,h)=>h%2?u+r:u+e));s.push({key:"S",data:l}),e=l[2],r=l[3];break}case"T":s.push({key:"T",data:[...o]}),e=o[0],r=o[1];break;case"t":e+=o[0],r+=o[1],s.push({key:"T",data:[e,r]});break;case"Z":case"z":s.push({key:"Z",data:[]}),e=n,r=i}return s}function yke(t){const e=[];let r="",n=0,i=0,s=0,a=0,o=0,l=0;for(const{key:u,data:h}of t){switch(u){case"M":e.push({key:"M",data:[...h]}),[n,i]=h,[s,a]=h;break;case"C":e.push({key:"C",data:[...h]}),n=h[4],i=h[5],o=h[2],l=h[3];break;case"L":e.push({key:"L",data:[...h]}),[n,i]=h;break;case"H":n=h[0],e.push({key:"L",data:[n,i]});break;case"V":i=h[0],e.push({key:"L",data:[n,i]});break;case"S":{let d=0,f=0;r==="C"||r==="S"?(d=n+(n-o),f=i+(i-l)):(d=n,f=i),e.push({key:"C",data:[d,f,...h]}),o=h[0],l=h[1],n=h[2],i=h[3];break}case"T":{const[d,f]=h;let p=0,g=0;r==="Q"||r==="T"?(p=n+(n-o),g=i+(i-l)):(p=n,g=i);const m=n+2*(p-n)/3,y=i+2*(g-i)/3,v=d+2*(p-d)/3,x=f+2*(g-f)/3;e.push({key:"C",data:[m,y,v,x,d,f]}),o=p,l=g,n=d,i=f;break}case"Q":{const[d,f,p,g]=h,m=n+2*(d-n)/3,y=i+2*(f-i)/3,v=p+2*(d-p)/3,x=g+2*(f-g)/3;e.push({key:"C",data:[m,y,v,x,p,g]}),o=d,l=f,n=p,i=g;break}case"A":{const d=Math.abs(h[0]),f=Math.abs(h[1]),p=h[2],g=h[3],m=h[4],y=h[5],v=h[6];d===0||f===0?(e.push({key:"C",data:[n,i,y,v,y,v]}),n=y,i=v):(n!==y||i!==v)&&(vke(n,i,y,v,d,f,p,g,m).forEach((function(x){e.push({key:"C",data:x})})),n=y,i=v);break}case"Z":e.push({key:"Z",data:[]}),n=s,i=a}r=u}return e}function J3(t,e,r){return[t*Math.cos(r)-e*Math.sin(r),t*Math.sin(r)+e*Math.cos(r)]}function vke(t,e,r,n,i,s,a,o,l,u){const h=(d=a,Math.PI*d/180);var d;let f=[],p=0,g=0,m=0,y=0;if(u)[p,g,m,y]=u;else{[t,e]=J3(t,e,-h),[r,n]=J3(r,n,-h);const N=(t-r)/2,L=(e-n)/2;let I=N*N/(i*i)+L*L/(s*s);I>1&&(I=Math.sqrt(I),i*=I,s*=I);const $=i*i,O=s*s,D=$*O-$*L*L-O*N*N,F=$*L*L+O*N*N,z=(o===l?-1:1)*Math.sqrt(Math.abs(D/F));m=z*i*L/s+(t+r)/2,y=z*-s*N/i+(e+n)/2,p=Math.asin(parseFloat(((e-y)/s).toFixed(9))),g=Math.asin(parseFloat(((n-y)/s).toFixed(9))),tg&&(p-=2*Math.PI),!l&&g>p&&(g-=2*Math.PI)}let v=g-p;if(Math.abs(v)>120*Math.PI/180){const N=g,L=r,I=n;g=l&&g>p?p+120*Math.PI/180*1:p+120*Math.PI/180*-1,f=vke(r=m+i*Math.cos(g),n=y+s*Math.sin(g),L,I,i,s,a,0,l,[g,N,m,y])}v=g-p;const x=Math.cos(p),b=Math.sin(p),T=Math.cos(g),C=Math.sin(g),S=Math.tan(v/4),k=4/3*i*S,E=4/3*s*S,A=[t,e],R=[t+k*b,e-E*x],_=[r+k*C,n-E*T],P=[r,n];if(R[0]=2*A[0]-R[0],R[1]=2*A[1]-R[1],u)return[R,_,P].concat(f);{f=[R,_,P].concat(f);const N=[];for(let L=0;L2){const i=[];for(let s=0;s2*Math.PI&&(p=0,g=2*Math.PI);const m=2*Math.PI/l.curveStepCount,y=Math.min(m/2,(g-p)/2),v=pce(y,u,h,d,f,p,g,1,l);if(!l.disableMultiStroke){const x=pce(y,u,h,d,f,p,g,1.5,l);v.push(...x)}return a&&(o?v.push(...gg(u,h,u+d*Math.cos(p),h+f*Math.sin(p),l),...gg(u,h,u+d*Math.cos(g),h+f*Math.sin(g),l)):v.push({op:"lineTo",data:[u,h]},{op:"lineTo",data:[u+d*Math.cos(p),h+f*Math.sin(p)]})),{type:"path",ops:v}}function hce(t,e){const r=yke(mke(wZ(t))),n=[];let i=[0,0],s=[0,0];for(const{key:a,data:o}of r)switch(a){case"M":s=[o[0],o[1]],i=[o[0],o[1]];break;case"L":n.push(...gg(s[0],s[1],o[0],o[1],e)),s=[o[0],o[1]];break;case"C":{const[l,u,h,d,f,p]=o;n.push(...C5t(l,u,h,d,f,p,s,e)),s=[f,p];break}case"Z":n.push(...gg(s[0],s[1],i[0],i[1],e)),s=[i[0],i[1]]}return{type:"path",ops:n}}function J$(t,e){const r=[];for(const n of t)if(n.length){const i=e.maxRandomnessOffset||0,s=n.length;if(s>2){r.push({op:"move",data:[n[0][0]+en(i,e),n[0][1]+en(i,e)]});for(let a=1;a500?.4:-.0016668*l+1.233334;let h=i.maxRandomnessOffset||0;h*h*100>o&&(h=l/10);const d=h/2,f=.2+.2*wke(i);let p=i.bowing*i.maxRandomnessOffset*(n-e)/200,g=i.bowing*i.maxRandomnessOffset*(t-r)/200;p=en(p,i,u),g=en(g,i,u);const m=[],y=()=>en(d,i,u),v=()=>en(h,i,u),x=i.preserveVertices;return a?m.push({op:"move",data:[t+(x?0:y()),e+(x?0:y())]}):m.push({op:"move",data:[t+(x?0:en(h,i,u)),e+(x?0:en(h,i,u))]}),a?m.push({op:"bcurveTo",data:[p+t+(r-t)*f+y(),g+e+(n-e)*f+y(),p+t+2*(r-t)*f+y(),g+e+2*(n-e)*f+y(),r+(x?0:y()),n+(x?0:y())]}):m.push({op:"bcurveTo",data:[p+t+(r-t)*f+v(),g+e+(n-e)*f+v(),p+t+2*(r-t)*f+v(),g+e+2*(n-e)*f+v(),r+(x?0:v()),n+(x?0:v())]}),m}function NA(t,e,r){if(!t.length)return[];const n=[];n.push([t[0][0]+en(e,r),t[0][1]+en(e,r)]),n.push([t[0][0]+en(e,r),t[0][1]+en(e,r)]);for(let i=1;i3){const s=[],a=1-r.curveTightness;i.push({op:"move",data:[t[1][0],t[1][1]]});for(let o=1;o+21&&i.push(o)):i.push(o),i.push(t[e+3])}else{const l=t[e+0],u=t[e+1],h=t[e+2],d=t[e+3],f=Wm(l,u,.5),p=Wm(u,h,.5),g=Wm(h,d,.5),m=Wm(f,p,.5),y=Wm(p,g,.5),v=Wm(m,y,.5);SG([l,f,m,v],0,r,i),SG([v,y,g,d],0,r,i)}var s,a;return i}function S5t(t,e){return l_(t,0,t.length,e)}function l_(t,e,r,n,i){const s=i||[],a=t[e],o=t[r-1];let l=0,u=1;for(let h=e+1;hl&&(l=d,u=h)}return Math.sqrt(l)>n?(l_(t,e,u+1,n,s),l_(t,u,r,n,s)):(s.length||s.push(a),s.push(o)),s}function eB(t,e=.15,r){const n=[],i=(t.length-1)/3;for(let s=0;s0?l_(n,0,n.length,r):n}const Tc="none";let c_=class{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,r,n){return{shape:e,sets:r||[],options:n||this.defaultOptions}}line(e,r,n,i,s){const a=this._o(s);return this._d("line",[bke(e,r,n,i,a)],a)}rectangle(e,r,n,i,s){const a=this._o(s),o=[],l=T5t(e,r,n,i,a);if(a.fill){const u=[[e,r],[e+n,r],[e+n,r+i],[e,r+i]];a.fillStyle==="solid"?o.push(J$([u],a)):o.push(Bv([u],a))}return a.stroke!==Tc&&o.push(l),this._d("rectangle",o,a)}ellipse(e,r,n,i,s){const a=this._o(s),o=[],l=xke(n,i,a),u=CG(e,r,a,l);if(a.fill)if(a.fillStyle==="solid"){const h=CG(e,r,a,l).opset;h.type="fillPath",o.push(h)}else o.push(Bv([u.estimatedPoints],a));return a.stroke!==Tc&&o.push(u.opset),this._d("ellipse",o,a)}circle(e,r,n,i){const s=this.ellipse(e,r,n,n,i);return s.shape="circle",s}linearPath(e,r){const n=this._o(r);return this._d("linearPath",[LM(e,!1,n)],n)}arc(e,r,n,i,s,a,o=!1,l){const u=this._o(l),h=[],d=uce(e,r,n,i,s,a,o,!0,u);if(o&&u.fill)if(u.fillStyle==="solid"){const f=Object.assign({},u);f.disableMultiStroke=!0;const p=uce(e,r,n,i,s,a,!0,!1,f);p.type="fillPath",h.push(p)}else h.push((function(f,p,g,m,y,v,x){const b=f,T=p;let C=Math.abs(g/2),S=Math.abs(m/2);C+=en(.01*C,x),S+=en(.01*S,x);let k=y,E=v;for(;k<0;)k+=2*Math.PI,E+=2*Math.PI;E-k>2*Math.PI&&(k=0,E=2*Math.PI);const A=(E-k)/x.curveStepCount,R=[];for(let _=k;_<=E;_+=A)R.push([b+C*Math.cos(_),T+S*Math.sin(_)]);return R.push([b+C*Math.cos(E),T+S*Math.sin(E)]),R.push([b,T]),Bv([R],x)})(e,r,n,i,s,a,u));return u.stroke!==Tc&&h.push(d),this._d("arc",h,u)}curve(e,r){const n=this._o(r),i=[],s=cce(e,n);if(n.fill&&n.fill!==Tc)if(n.fillStyle==="solid"){const a=cce(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(a.ops)})}else{const a=[],o=e;if(o.length){const l=typeof o[0][0]=="number"?[o]:o;for(const u of l)u.length<3?a.push(...u):u.length===3?a.push(...eB(gce([u[0],u[0],u[1],u[2]]),10,(1+n.roughness)/2)):a.push(...eB(gce(u),10,(1+n.roughness)/2))}a.length&&i.push(Bv([a],n))}return n.stroke!==Tc&&i.push(s),this._d("curve",i,n)}polygon(e,r){const n=this._o(r),i=[],s=LM(e,!0,n);return n.fill&&(n.fillStyle==="solid"?i.push(J$([e],n)):i.push(Bv([e],n))),n.stroke!==Tc&&i.push(s),this._d("polygon",i,n)}path(e,r){const n=this._o(r),i=[];if(!e)return this._d("path",i,n);e=(e||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");const s=n.fill&&n.fill!=="transparent"&&n.fill!==Tc,a=n.stroke!==Tc,o=!!(n.simplification&&n.simplification<1),l=(function(h,d,f){const p=yke(mke(wZ(h))),g=[];let m=[],y=[0,0],v=[];const x=()=>{v.length>=4&&m.push(...eB(v,d)),v=[]},b=()=>{x(),m.length&&(g.push(m),m=[])};for(const{key:C,data:S}of p)switch(C){case"M":b(),y=[S[0],S[1]],m.push(y);break;case"L":x(),m.push([S[0],S[1]]);break;case"C":if(!v.length){const k=m.length?m[m.length-1]:y;v.push([k[0],k[1]])}v.push([S[0],S[1]]),v.push([S[2],S[3]]),v.push([S[4],S[5]]);break;case"Z":x(),m.push([y[0],y[1]])}if(b(),!f)return g;const T=[];for(const C of g){const S=S5t(C,f);S.length&&T.push(S)}return T})(e,1,o?4-4*(n.simplification||1):(1+n.roughness)/2),u=hce(e,n);if(s)if(n.fillStyle==="solid")if(l.length===1){const h=hce(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(h.ops)})}else i.push(J$(l,n));else i.push(Bv(l,n));return a&&(o?l.forEach((h=>{i.push(LM(h,!1,n))})):i.push(u)),this._d("path",i,n)}opsToPath(e,r){let n="";for(const i of e.ops){const s=typeof r=="number"&&r>=0?i.data.map((a=>+a.toFixed(r))):i.data;switch(i.op){case"move":n+=`M${s[0]} ${s[1]} `;break;case"bcurveTo":n+=`C${s[0]} ${s[1]}, ${s[2]} ${s[3]}, ${s[4]} ${s[5]} `;break;case"lineTo":n+=`L${s[0]} ${s[1]} `}}return n.trim()}toPaths(e){const r=e.sets||[],n=e.options||this.defaultOptions,i=[];for(const s of r){let a=null;switch(s.type){case"path":a={d:this.opsToPath(s),stroke:n.stroke,strokeWidth:n.strokeWidth,fill:Tc};break;case"fillPath":a={d:this.opsToPath(s),stroke:Tc,strokeWidth:0,fill:n.fill||Tc};break;case"fillSketch":a=this.fillSketch(s,n)}a&&i.push(a)}return i}fillSketch(e,r){let n=r.fillWeight;return n<0&&(n=r.strokeWidth/2),{d:this.opsToPath(e),stroke:r.fill||Tc,strokeWidth:n,fill:Tc}}_mergedShape(e){return e.filter(((r,n)=>n===0||r.op!=="move"))}};class E5t{constructor(e,r){this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.gen=new c_(r)}draw(e){const r=e.sets||[],n=e.options||this.getDefaultOptions(),i=this.ctx,s=e.options.fixedDecimalPlaceDigits;for(const a of r)switch(a.type){case"path":i.save(),i.strokeStyle=n.stroke==="none"?"transparent":n.stroke,i.lineWidth=n.strokeWidth,n.strokeLineDash&&i.setLineDash(n.strokeLineDash),n.strokeLineDashOffset&&(i.lineDashOffset=n.strokeLineDashOffset),this._drawToContext(i,a,s),i.restore();break;case"fillPath":{i.save(),i.fillStyle=n.fill||"";const o=e.shape==="curve"||e.shape==="polygon"||e.shape==="path"?"evenodd":"nonzero";this._drawToContext(i,a,s,o),i.restore();break}case"fillSketch":this.fillSketch(i,a,n)}}fillSketch(e,r,n){let i=n.fillWeight;i<0&&(i=n.strokeWidth/2),e.save(),n.fillLineDash&&e.setLineDash(n.fillLineDash),n.fillLineDashOffset&&(e.lineDashOffset=n.fillLineDashOffset),e.strokeStyle=n.fill||"",e.lineWidth=i,this._drawToContext(e,r,n.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,r,n,i="nonzero"){e.beginPath();for(const s of r.ops){const a=typeof n=="number"&&n>=0?s.data.map((o=>+o.toFixed(n))):s.data;switch(s.op){case"move":e.moveTo(a[0],a[1]);break;case"bcurveTo":e.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"lineTo":e.lineTo(a[0],a[1])}}r.type==="fillPath"?e.fill(i):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,r,n,i,s){const a=this.gen.line(e,r,n,i,s);return this.draw(a),a}rectangle(e,r,n,i,s){const a=this.gen.rectangle(e,r,n,i,s);return this.draw(a),a}ellipse(e,r,n,i,s){const a=this.gen.ellipse(e,r,n,i,s);return this.draw(a),a}circle(e,r,n,i){const s=this.gen.circle(e,r,n,i);return this.draw(s),s}linearPath(e,r){const n=this.gen.linearPath(e,r);return this.draw(n),n}polygon(e,r){const n=this.gen.polygon(e,r);return this.draw(n),n}arc(e,r,n,i,s,a,o=!1,l){const u=this.gen.arc(e,r,n,i,s,a,o,l);return this.draw(u),u}curve(e,r){const n=this.gen.curve(e,r);return this.draw(n),n}path(e,r){const n=this.gen.path(e,r);return this.draw(n),n}}const DA="http://www.w3.org/2000/svg";class A5t{constructor(e,r){this.svg=e,this.gen=new c_(r)}draw(e){const r=e.sets||[],n=e.options||this.getDefaultOptions(),i=this.svg.ownerDocument||window.document,s=i.createElementNS(DA,"g"),a=e.options.fixedDecimalPlaceDigits;for(const o of r){let l=null;switch(o.type){case"path":l=i.createElementNS(DA,"path"),l.setAttribute("d",this.opsToPath(o,a)),l.setAttribute("stroke",n.stroke),l.setAttribute("stroke-width",n.strokeWidth+""),l.setAttribute("fill","none"),n.strokeLineDash&&l.setAttribute("stroke-dasharray",n.strokeLineDash.join(" ").trim()),n.strokeLineDashOffset&&l.setAttribute("stroke-dashoffset",`${n.strokeLineDashOffset}`);break;case"fillPath":l=i.createElementNS(DA,"path"),l.setAttribute("d",this.opsToPath(o,a)),l.setAttribute("stroke","none"),l.setAttribute("stroke-width","0"),l.setAttribute("fill",n.fill||""),e.shape!=="curve"&&e.shape!=="polygon"||l.setAttribute("fill-rule","evenodd");break;case"fillSketch":l=this.fillSketch(i,o,n)}l&&s.appendChild(l)}return s}fillSketch(e,r,n){let i=n.fillWeight;i<0&&(i=n.strokeWidth/2);const s=e.createElementNS(DA,"path");return s.setAttribute("d",this.opsToPath(r,n.fixedDecimalPlaceDigits)),s.setAttribute("stroke",n.fill||""),s.setAttribute("stroke-width",i+""),s.setAttribute("fill","none"),n.fillLineDash&&s.setAttribute("stroke-dasharray",n.fillLineDash.join(" ").trim()),n.fillLineDashOffset&&s.setAttribute("stroke-dashoffset",`${n.fillLineDashOffset}`),s}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,r){return this.gen.opsToPath(e,r)}line(e,r,n,i,s){const a=this.gen.line(e,r,n,i,s);return this.draw(a)}rectangle(e,r,n,i,s){const a=this.gen.rectangle(e,r,n,i,s);return this.draw(a)}ellipse(e,r,n,i,s){const a=this.gen.ellipse(e,r,n,i,s);return this.draw(a)}circle(e,r,n,i){const s=this.gen.circle(e,r,n,i);return this.draw(s)}linearPath(e,r){const n=this.gen.linearPath(e,r);return this.draw(n)}polygon(e,r){const n=this.gen.polygon(e,r);return this.draw(n)}arc(e,r,n,i,s,a,o=!1,l){const u=this.gen.arc(e,r,n,i,s,a,o,l);return this.draw(u)}curve(e,r){const n=this.gen.curve(e,r);return this.draw(n)}path(e,r){const n=this.gen.path(e,r);return this.draw(n)}}var dr={canvas:(t,e)=>new E5t(t,e),svg:(t,e)=>new A5t(t,e),generator:t=>new c_(t),newSeed:()=>c_.newSeed()},Qr=w(async(t,e,r)=>{var p,g;let n;const i=e.useHtmlLabels||zd((p=Ve())==null?void 0:p.htmlLabels);r?n=r:n="node default";const s=t.insert("g").attr("class",n).attr("id",e.domId||e.id),a=s.insert("g").attr("class","label").attr("style",ja(e.labelStyle));let o;e.label===void 0?o="":o=typeof e.label=="string"?e.label:e.label[0];const l=!!e.icon||!!e.img,u=e.labelType==="markdown",h=await Zo(a,Ln(h0(o),Ve()),{useHtmlLabels:i,width:e.width||((g=Ve().flowchart)==null?void 0:g.wrappingWidth),classes:u?"markdown-node-label":"",style:e.labelStyle,addSvgBackground:l,markdown:u},Ve());let d=h.getBBox();const f=((e==null?void 0:e.padding)??0)/2;if(i){const m=h.children[0],y=wt(h);await lZ(m,o),d=m.getBoundingClientRect(),y.attr("width",d.width),y.attr("height",d.height)}return i?a.attr("transform","translate("+-d.width/2+", "+-d.height/2+")"):a.attr("transform","translate(0, "+-d.height/2+")"),e.centerLabel&&a.attr("transform","translate("+-d.width/2+", "+-d.height/2+")"),a.insert("rect",":first-child"),{shapeSvg:s,bbox:d,halfPadding:f,label:a}},"labelHelper"),tB=w(async(t,e,r)=>{var l,u;const n=r.useHtmlLabels??ui(Ve()),i=t.insert("g").attr("class","label").attr("style",r.labelStyle||""),s=await Zo(i,Ln(h0(e),Ve()),{useHtmlLabels:n,width:r.width||((u=(l=Ve())==null?void 0:l.flowchart)==null?void 0:u.wrappingWidth),style:r.labelStyle,addSvgBackground:!!r.icon||!!r.img});let a=s.getBBox();const o=r.padding/2;if(ui(Ve())){const h=s.children[0],d=wt(s);a=h.getBoundingClientRect(),d.attr("width",a.width),d.attr("height",a.height)}return n?i.attr("transform","translate("+-a.width/2+", "+-a.height/2+")"):i.attr("transform","translate(0, "+-a.height/2+")"),r.centerLabel&&i.attr("transform","translate("+-a.width/2+", "+-a.height/2+")"),i.insert("rect",":first-child"),{shapeSvg:t,bbox:a,halfPadding:o,label:i}},"insertLabel"),wr=w((t,e)=>{const r=e.node().getBBox();t.width=r.width,t.height=r.height},"updateNodeBounds"),Wr=w((t,e)=>(t.look==="handDrawn"?"rough-node":"node")+" "+t.cssClasses+" "+(e||""),"getNodeClasses");function Fn(t){const e=t.map((r,n)=>`${n===0?"M":"L"}${r.x},${r.y}`);return e.push("Z"),e.join(" ")}w(Fn,"createPathFromPoints");function mg(t,e,r,n,i,s){const a=[],l=r-t,u=n-e,h=l/s,d=2*Math.PI/h,f=e+u/2;for(let p=0;p<=50;p++){const g=p/50,m=t+g*l,y=f+i*Math.sin(d*(m-t));a.push({x:m,y})}return a}w(mg,"generateFullSineWavePoints");function w6(t,e,r,n,i,s){const a=[],o=i*Math.PI/180,h=(s*Math.PI/180-o)/(n-1);for(let d=0;dl.tagName==="path"),r=document.createElementNS("http://www.w3.org/2000/svg","path"),n=e.map(l=>l.getAttribute("d")).filter(l=>l!==null).join(" ");r.setAttribute("d",n);const i=e.find(l=>l.getAttribute("fill")!=="none"),s=e.find(l=>l.getAttribute("stroke")!=="none"),a=w((l,u)=>(l==null?void 0:l.getAttribute(u))??void 0,"getAttr");if(i){const l={fill:a(i,"fill"),"fill-opacity":a(i,"fill-opacity")??"1"};Object.entries(l).forEach(([u,h])=>{h&&r.setAttribute(u,h)})}if(s){const l={stroke:a(s,"stroke"),"stroke-width":a(s,"stroke-width")??"1","stroke-opacity":a(s,"stroke-opacity")??"1"};Object.entries(l).forEach(([u,h])=>{h&&r.setAttribute(u,h)})}const o=document.createElementNS("http://www.w3.org/2000/svg","g");return o.appendChild(r),o}w(EG,"mergePaths");var M5t=w((t,e)=>{var r=t.x,n=t.y,i=e.x-r,s=e.y-n,a=t.width/2,o=t.height/2,l,u;return Math.abs(s)*a>Math.abs(i)*o?(s<0&&(o=-o),l=s===0?0:o*i/s,u=o):(i<0&&(a=-a),l=a,u=i===0?0:a*s/i),{x:r+l,y:n+u}},"intersectRect"),Zy=M5t,R5t=w(async(t,e,r,n=!1,i=!1)=>{let s=e||"";typeof s=="object"&&(s=s[0]);const a=Ve(),o=ui(a);return await Zo(t,s,{style:r,isTitle:n,useHtmlLabels:o,markdown:!1,isNode:i,width:Number.POSITIVE_INFINITY},a)},"createLabel"),$p=R5t,jg=w((t,e,r,n,i)=>["M",t+i,e,"H",t+r-i,"A",i,i,0,0,1,t+r,e+i,"V",e+n-i,"A",i,i,0,0,1,t+r-i,e+n,"H",t+i,"A",i,i,0,0,1,t,e+n-i,"V",e+i,"A",i,i,0,0,1,t+i,e,"Z"].join(" "),"createRoundedRectPathD"),_5t=w(async(t,e)=>{const r=Ve(),{themeVariables:n,handDrawnSeed:i}=r,{clusterBkg:s,clusterBorder:a}=n,o=a,{labelStyles:l,nodeStyles:u,borderStyles:h,backgroundStyles:d}=cr(e),f=t.insert("g").attr("class","cluster swimlane "+(e.cssClasses||"")).attr("id",e.id).attr("data-id",e.id).attr("data-et","cluster").attr("data-look",e.look),p=zd(r.flowchart.htmlLabels),g=e.direction==="LR",m=f.insert("g").attr("class","cluster-label swimlane-label"),y=await Zo(m,e.label,{style:e.labelStyle,useHtmlLabels:p,isNode:!0,width:e.width});let v=y.getBBox();if(p){const N=y.children[0],L=wt(y);v=N.getBoundingClientRect(),L.attr("width",v.width),L.attr("height",v.height)}const x=e.padding??0,b=e.width<=v.width+x?v.width+x:e.width;e.width<=v.width+x?e.diff=(b-e.width)/2-x:e.diff=-x;const T=e.height,C=e.y-T/2,S=e.y+T/2,k=e.x-b/2,E=e.swimlaneContentTop!==void 0?e.swimlaneContentTop:C+T/3,A=g?4:0,R=v.height+2*A;let _,P;if(g){const N=Math.max(R,v.height+2*A),L=k+N,I=Math.max(0,b-N);if(e.look==="handDrawn"){const D=dr.svg(f),F=fr(e,{roughness:.7,fill:s,stroke:o,fillWeight:3,seed:i}),z=fr(e,{roughness:.7,fill:"none",stroke:o,seed:i}),V=D.rectangle(k,C,N,T,F);_=f.insert(()=>V,":first-child");const B=D.rectangle(L,C,I,T,z);P=f.insert(()=>B,":first-child"),_.select("path:nth-child(2)").attr("style",h.join(";")),_.select("path").attr("style",d.join(";").replace("fill","stroke"))}else _=f.insert("rect",":first-child"),P=f.insert("rect",":first-child"),_.attr("class","swimlane-title").attr("style",u).attr("x",k).attr("y",C).attr("width",N).attr("height",T).attr("fill",s).attr("stroke",o),P.attr("class","swimlane-body").attr("style",u).attr("x",L).attr("y",C).attr("width",I).attr("height",T).attr("fill","none").attr("stroke",o);const $=k+N/2,O=e.y;m.attr("transform",`translate(${$}, ${O}) rotate(-90) translate(${-v.width/2}, ${-v.height/2})`)}else{const N=Math.max(0,E-C),L=Math.min(R,N),I=C+L,$=Math.max(0,S-I),O=e.x-b/2;if(e.look==="handDrawn"){const z=dr.svg(f),V=fr(e,{roughness:.7,fill:s,stroke:o,fillWeight:3,seed:i}),B=fr(e,{roughness:.7,fill:"none",stroke:o,seed:i}),H=z.rectangle(O,C,b,L,V);_=f.insert(()=>H,":first-child");const G=z.rectangle(O,I,b,$,B);P=f.insert(()=>G,":first-child"),_.select("path:nth-child(2)").attr("style",h.join(";")),_.select("path").attr("style",d.join(";").replace("fill","stroke"))}else _=f.insert("rect",":first-child"),P=f.insert("rect",":first-child"),_.attr("class","swimlane-title").attr("style",u).attr("x",O).attr("y",C).attr("width",b).attr("height",L).attr("fill",s).attr("stroke",o),P.attr("class","swimlane-body").attr("style",u).attr("x",O).attr("y",I).attr("width",b).attr("height",$).attr("fill","none").attr("stroke",o);const D=e.x-v.width/2,F=C+(L-v.height)/2;m.attr("transform",`translate(${D}, ${F})`)}if(de.trace("Swimlane data ",e,JSON.stringify(e)),l){const N=m.select("span");N&&N.attr("style",l)}return e.offsetX=0,e.width=b,e.height=T,e.offsetY=v.height-x/2,e.intersect=function(N){return Zy(e,N)},{cluster:f,labelBBox:v}},"swimlane"),Tke=w(async(t,e)=>{de.info("Creating subgraph rect for ",e.id,e);const r=Ve(),{themeVariables:n,handDrawnSeed:i}=r,{clusterBkg:s,clusterBorder:a}=n,{labelStyles:o,nodeStyles:l,borderStyles:u,backgroundStyles:h}=cr(e),d=t.insert("g").attr("class","cluster "+e.cssClasses).attr("id",e.domId).attr("data-look",e.look),f=ui(r),p=d.insert("g").attr("class","cluster-label ");let g;e.labelType==="markdown"?g=await Zo(p,e.label,{style:e.labelStyle,useHtmlLabels:f,isNode:!0,width:e.width}):g=await $p(p,e.label,e.labelStyle||"",!1,!0);let m=g.getBBox();if(ui(r)){const k=g.children[0],E=wt(g);m=k.getBoundingClientRect(),E.attr("width",m.width),E.attr("height",m.height)}const y=e.width<=m.width+e.padding?m.width+e.padding:e.width;e.width<=m.width+e.padding?e.diff=(y-e.width)/2-e.padding:e.diff=-e.padding;const v=e.height,x=e.x-y/2,b=e.y-v/2;de.trace("Data ",e,JSON.stringify(e));let T;if(e.look==="handDrawn"){const k=dr.svg(d),E=fr(e,{roughness:.7,fill:s,stroke:a,fillWeight:3,seed:i}),A=k.path(jg(x,b,y,v,0),E);T=d.insert(()=>(de.debug("Rough node insert CXC",A),A),":first-child"),T.select("path:nth-child(2)").attr("style",u.join(";")),T.select("path").attr("style",h.join(";").replace("fill","stroke"))}else T=d.insert("rect",":first-child"),T.attr("style",l).attr("rx",e.rx).attr("ry",e.ry).attr("x",x).attr("y",b).attr("width",y).attr("height",v);const{subGraphTitleTopMargin:C}=s3(r);if(p.attr("transform",`translate(${e.x-m.width/2}, ${e.y-e.height/2+C})`),o){const k=p.select("span");k&&k.attr("style",o)}const S=T.node().getBBox();return e.offsetX=0,e.width=S.width,e.height=S.height,e.offsetY=m.height-e.padding/2,e.intersect=function(k){return Zy(e,k)},{cluster:d,labelBBox:m}},"rect"),L5t=w((t,e)=>{const r=t.insert("g").attr("class","note-cluster").attr("id",e.domId),n=r.insert("rect",":first-child"),i=0*e.padding,s=i/2;n.attr("rx",e.rx).attr("ry",e.ry).attr("x",e.x-e.width/2-s).attr("y",e.y-e.height/2-s).attr("width",e.width+i).attr("height",e.height+i).attr("fill","none");const a=n.node().getBBox();return e.width=a.width,e.height=a.height,e.intersect=function(o){return Zy(e,o)},{cluster:r,labelBBox:{width:0,height:0}}},"noteGroup"),I5t=w(async(t,e)=>{const r=Ve(),{themeVariables:n,handDrawnSeed:i}=r,{altBackground:s,compositeBackground:a,compositeTitleBackground:o,nodeBorder:l}=n,u=t.insert("g").attr("class",e.cssClasses).attr("id",e.domId).attr("data-id",e.id).attr("data-look",e.look),h=u.insert("g",":first-child"),d=u.insert("g").attr("class","cluster-label");let f=u.append("rect");const p=await $p(d,e.label,e.labelStyle,void 0,!0);let g=p.getBBox();if(ui(r)){const A=p.children[0],R=wt(p);g=A.getBoundingClientRect(),R.attr("width",g.width),R.attr("height",g.height)}const m=0*e.padding,y=m/2,v=(e.width<=g.width+e.padding?g.width+e.padding:e.width)+m;e.width<=g.width+e.padding?e.diff=(v-e.width)/2-e.padding:e.diff=-e.padding;const x=e.height+m,b=e.height+m-g.height-6,T=e.x-v/2,C=e.y-x/2;e.width=v;const S=e.y-e.height/2-y+g.height+2;let k;if(e.look==="handDrawn"){const A=e.cssClasses.includes("statediagram-cluster-alt"),R=dr.svg(u),_=e.rx||e.ry?R.path(jg(T,C,v,x,10),{roughness:.7,fill:o,fillStyle:"solid",stroke:l,seed:i}):R.rectangle(T,C,v,x,{seed:i});k=u.insert(()=>_,":first-child");const P=R.rectangle(T,S,v,b,{fill:A?s:a,fillStyle:A?"hachure":"solid",stroke:l,seed:i});k=u.insert(()=>_,":first-child"),f=u.insert(()=>P)}else k=h.insert("rect",":first-child"),k.attr("class","outer").attr("x",T).attr("y",C).attr("width",v).attr("height",x).attr("data-look",e.look),f.attr("class","inner").attr("x",T).attr("y",S).attr("width",v).attr("height",b);d.attr("transform",`translate(${e.x-g.width/2}, ${C+1-(ui(r)?0:3)})`);const E=k.node().getBBox();return e.height=E.height,e.offsetX=0,e.offsetY=g.height-e.padding/2,e.labelBBox=g,e.intersect=function(A){return Zy(e,A)},{cluster:u,labelBBox:g}},"roundedWithTitle"),N5t=w(async(t,e)=>{de.info("Creating subgraph rect for ",e.id,e);const r=Ve(),{themeVariables:n,handDrawnSeed:i}=r,{clusterBkg:s,clusterBorder:a}=n,{labelStyles:o,nodeStyles:l,borderStyles:u,backgroundStyles:h}=cr(e),d=t.insert("g").attr("class","cluster "+e.cssClasses).attr("id",e.domId).attr("data-look",e.look),f=ui(r),p=d.insert("g").attr("class","cluster-label "),g=await Zo(p,e.label,{style:e.labelStyle,useHtmlLabels:f,isNode:!0,width:e.width});let m=g.getBBox();if(ui(r)){const k=g.children[0],E=wt(g);m=k.getBoundingClientRect(),E.attr("width",m.width),E.attr("height",m.height)}const y=e.width<=m.width+e.padding?m.width+e.padding:e.width;e.width<=m.width+e.padding?e.diff=(y-e.width)/2-e.padding:e.diff=-e.padding;const v=e.height,x=e.x-y/2,b=e.y-v/2;de.trace("Data ",e,JSON.stringify(e));let T;if(e.look==="handDrawn"){const k=dr.svg(d),E=fr(e,{roughness:.7,fill:s,stroke:a,fillWeight:4,seed:i}),A=k.path(jg(x,b,y,v,e.rx),E);T=d.insert(()=>(de.debug("Rough node insert CXC",A),A),":first-child"),T.select("path:nth-child(2)").attr("style",u.join(";")),T.select("path").attr("style",h.join(";").replace("fill","stroke"))}else T=d.insert("rect",":first-child"),T.attr("style",l).attr("rx",e.rx).attr("ry",e.ry).attr("x",x).attr("y",b).attr("width",y).attr("height",v);const{subGraphTitleTopMargin:C}=s3(r);if(p.attr("transform",`translate(${e.x-m.width/2}, ${e.y-e.height/2+C})`),o){const k=p.select("span");k&&k.attr("style",o)}const S=T.node().getBBox();return e.offsetX=0,e.width=S.width,e.height=S.height,e.offsetY=m.height-e.padding/2,e.intersect=function(k){return Zy(e,k)},{cluster:d,labelBBox:m}},"kanbanSection"),D5t=w((t,e)=>{const r=Ve(),{themeVariables:n,handDrawnSeed:i}=r,{nodeBorder:s}=n,a=t.insert("g").attr("class",e.cssClasses).attr("id",e.domId).attr("data-look",e.look),o=a.insert("g",":first-child"),l=0*e.padding,u=e.width+l;e.diff=-e.padding;const h=e.height+l,d=e.x-u/2,f=e.y-h/2;e.width=u;let p;if(e.look==="handDrawn"){const y=dr.svg(a).rectangle(d,f,u,h,{fill:"lightgrey",roughness:.5,strokeLineDash:[5],stroke:s,seed:i});p=a.insert(()=>y,":first-child")}else{p=o.insert("rect",":first-child");let m="outer";e.look,m="divider",p.attr("class",m).attr("x",d).attr("y",f).attr("width",u).attr("height",h).attr("data-look",e.look)}const g=p.node().getBBox();return e.height=g.height,e.offsetX=0,e.offsetY=0,e.intersect=function(m){return Zy(e,m)},{cluster:a,labelBBox:{}}},"divider"),O5t=Tke,P5t={rect:Tke,squareRect:O5t,roundedWithTitle:I5t,noteGroup:L5t,divider:D5t,kanbanSection:N5t,swimlane:_5t},Cke=new Map,iD=w(async(t,e)=>{const r=e.shape||"rect",n=await P5t[r](t,e);return Cke.set(e.id,n),n},"insertCluster"),kke=w(()=>{Cke=new Map},"clear");function Ske(t,e){return t.intersect(e)}w(Ske,"intersectNode");var $5t=Ske;function Eke(t,e,r,n){var i=t.x,s=t.y,a=i-n.x,o=s-n.y,l=Math.sqrt(e*e*o*o+r*r*a*a),u=Math.abs(e*r*a/l);n.x0}w(AG,"sameSign");var F5t=Rke;function _ke(t,e,r){let n=t.x,i=t.y,s=[],a=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY;typeof e.forEach=="function"?e.forEach(function(h){a=Math.min(a,h.x),o=Math.min(o,h.y)}):(a=Math.min(a,e.x),o=Math.min(o,e.y));let l=n-t.width/2-a,u=i-t.height/2-o;for(let h=0;h