livebook/static/assets/chunk-FIA6NTGC.js
2024-12-05 05:49:36 +00:00

15 lines
113 KiB
JavaScript

import{a as Gt}from"./chunk-VW6A6SAT.js";import{c as Mt}from"./chunk-NCYNIMJ4.js";import{d as dt}from"./chunk-ZPWCXWQI.js";import{i as ms,k as ds,o as kt,q as st}from"./chunk-47P5NBBB.js";import{D as _t,H as zt,I as tt,K as jt,M as fs,N as us,Z as Q,aa as ys,h as $,ia as J,j as Z,v as ps}from"./chunk-KRX7QNR4.js";import{a as at,b as nt}from"./chunk-MGYUK2XN.js";function Ft(c,t,r){if(c&&c.length){let[a,e]=t,i=Math.PI/180*r,h=Math.cos(i),s=Math.sin(i);for(let o of c){let[n,l]=o;o[0]=(n-a)*h-(l-e)*s+a,o[1]=(n-a)*s+(l-e)*h+e}}}function Qe(c,t){return c[0]===t[0]&&c[1]===t[1]}function Je(c,t,r,a=1){let e=r,i=Math.max(t,.1),h=c[0]&&c[0][0]&&typeof c[0][0]=="number"?[c]:c,s=[0,0];if(e)for(let n of h)Ft(n,s,e);let o=function(n,l,g){let p=[];for(let x of n){let b=[...x];Qe(b[0],b[b.length-1])||b.push([b[0][0],b[0][1]]),b.length>2&&p.push(b)}let f=[];l=Math.max(l,.1);let u=[];for(let x of p)for(let b=0;b<x.length-1;b++){let S=x[b],w=x[b+1];if(S[1]!==w[1]){let M=Math.min(S[1],w[1]);u.push({ymin:M,ymax:Math.max(S[1],w[1]),x:M===S[1]?S[0]:w[0],islope:(w[0]-S[0])/(w[1]-S[1])})}}if(u.sort((x,b)=>x.ymin<b.ymin?-1:x.ymin>b.ymin?1:x.x<b.x?-1:x.x>b.x?1:x.ymax===b.ymax?0:(x.ymax-b.ymax)/Math.abs(x.ymax-b.ymax)),!u.length)return f;let y=[],d=u[0].ymin,m=0;for(;y.length||u.length;){if(u.length){let x=-1;for(let b=0;b<u.length&&!(u[b].ymin>d);b++)x=b;u.splice(0,x+1).forEach(b=>{y.push({s:d,edge:b})})}if(y=y.filter(x=>!(x.edge.ymax<=d)),y.sort((x,b)=>x.edge.x===b.edge.x?0:(x.edge.x-b.edge.x)/Math.abs(x.edge.x-b.edge.x)),(g!==1||m%l==0)&&y.length>1)for(let x=0;x<y.length;x+=2){let b=x+1;if(b>=y.length)break;let S=y[x].edge,w=y[b].edge;f.push([[Math.round(S.x),d],[Math.round(w.x),d]])}d+=g,y.forEach(x=>{x.edge.x=x.edge.x+g*x.edge.islope}),m++}return f}(h,i,a);if(e){for(let n of h)Ft(n,s,-e);(function(n,l,g){let p=[];n.forEach(f=>p.push(...f)),Ft(p,l,g)})(o,s,-e)}return o}function Pt(c,t){var r;let a=t.hachureAngle+90,e=t.hachureGap;e<0&&(e=4*t.strokeWidth),e=Math.round(Math.max(e,.1));let i=1;return t.roughness>=1&&(((r=t.randomizer)===null||r===void 0?void 0:r.next())||Math.random())>.7&&(i=e),Je(c,e,a,i||1)}var Dt=class{constructor(t){this.helper=t}fillPolygons(t,r){return this._fillPolygons(t,r)}_fillPolygons(t,r){let a=Pt(t,r);return{type:"fillSketch",ops:this.renderLines(a,r)}}renderLines(t,r){let a=[];for(let e of t)a.push(...this.helper.doubleLineOps(e[0][0],e[0][1],e[1][0],e[1][1],r));return a}};function It(c){let t=c[0],r=c[1];return Math.sqrt(Math.pow(t[0]-r[0],2)+Math.pow(t[1]-r[1],2))}var Zt=class extends Dt{fillPolygons(t,r){let a=r.hachureGap;a<0&&(a=4*r.strokeWidth),a=Math.max(a,.1);let e=Pt(t,Object.assign({},r,{hachureGap:a})),i=Math.PI/180*r.hachureAngle,h=[],s=.5*a*Math.cos(i),o=.5*a*Math.sin(i);for(let[n,l]of e)It([n,l])&&h.push([[n[0]-s,n[1]+o],[...l]],[[n[0]+s,n[1]-o],[...l]]);return{type:"fillSketch",ops:this.renderLines(h,r)}}},Qt=class extends Dt{fillPolygons(t,r){let a=this._fillPolygons(t,r),e=Object.assign({},r,{hachureAngle:r.hachureAngle+90}),i=this._fillPolygons(t,e);return a.ops=a.ops.concat(i.ops),a}},Jt=class{constructor(t){this.helper=t}fillPolygons(t,r){let a=Pt(t,r=Object.assign({},r,{hachureAngle:0}));return this.dotsOnLines(a,r)}dotsOnLines(t,r){let a=[],e=r.hachureGap;e<0&&(e=4*r.strokeWidth),e=Math.max(e,.1);let i=r.fillWeight;i<0&&(i=r.strokeWidth/2);let h=e/4;for(let s of t){let o=It(s),n=o/e,l=Math.ceil(n)-1,g=o-l*e,p=(s[0][0]+s[1][0])/2-e/4,f=Math.min(s[0][1],s[1][1]);for(let u=0;u<l;u++){let y=f+g+u*e,d=p-h+2*Math.random()*h,m=y-h+2*Math.random()*h,x=this.helper.ellipse(d,m,i,i,r);a.push(...x.ops)}}return{type:"fillSketch",ops:a}}},Ut=class{constructor(t){this.helper=t}fillPolygons(t,r){let a=Pt(t,r);return{type:"fillSketch",ops:this.dashedLine(a,r)}}dashedLine(t,r){let a=r.dashOffset<0?r.hachureGap<0?4*r.strokeWidth:r.hachureGap:r.dashOffset,e=r.dashGap<0?r.hachureGap<0?4*r.strokeWidth:r.hachureGap:r.dashGap,i=[];return t.forEach(h=>{let s=It(h),o=Math.floor(s/(a+e)),n=(s+e-o*(a+e))/2,l=h[0],g=h[1];l[0]>g[0]&&(l=h[1],g=h[0]);let p=Math.atan((g[1]-l[1])/(g[0]-l[0]));for(let f=0;f<o;f++){let u=f*(a+e),y=u+a,d=[l[0]+u*Math.cos(p)+n*Math.cos(p),l[1]+u*Math.sin(p)+n*Math.sin(p)],m=[l[0]+y*Math.cos(p)+n*Math.cos(p),l[1]+y*Math.sin(p)+n*Math.sin(p)];i.push(...this.helper.doubleLineOps(d[0],d[1],m[0],m[1],r))}}),i}},Kt=class{constructor(t){this.helper=t}fillPolygons(t,r){let a=r.hachureGap<0?4*r.strokeWidth:r.hachureGap,e=r.zigzagOffset<0?a:r.zigzagOffset,i=Pt(t,r=Object.assign({},r,{hachureGap:a+e}));return{type:"fillSketch",ops:this.zigzagLines(i,e,r)}}zigzagLines(t,r,a){let e=[];return t.forEach(i=>{let h=It(i),s=Math.round(h/(2*r)),o=i[0],n=i[1];o[0]>n[0]&&(o=i[1],n=i[0]);let l=Math.atan((n[1]-o[1])/(n[0]-o[0]));for(let g=0;g<s;g++){let p=2*g*r,f=2*(g+1)*r,u=Math.sqrt(2*Math.pow(r,2)),y=[o[0]+p*Math.cos(l),o[1]+p*Math.sin(l)],d=[o[0]+f*Math.cos(l),o[1]+f*Math.sin(l)],m=[y[0]+u*Math.cos(l+Math.PI/4),y[1]+u*Math.sin(l+Math.PI/4)];e.push(...this.helper.doubleLineOps(y[0],y[1],m[0],m[1],a),...this.helper.doubleLineOps(m[0],m[1],d[0],d[1],a))}}),e}},rt={},ts=class{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}},Ue=0,qt=1,xs=2,Bt={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function Xt(c,t){return c.type===t}function ns(c){let t=[],r=function(h){let s=new Array;for(;h!=="";)if(h.match(/^([ \t\r\n,]+)/))h=h.substr(RegExp.$1.length);else if(h.match(/^([aAcChHlLmMqQsStTvVzZ])/))s[s.length]={type:Ue,text:RegExp.$1},h=h.substr(RegExp.$1.length);else{if(!h.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))return[];s[s.length]={type:qt,text:`${parseFloat(RegExp.$1)}`},h=h.substr(RegExp.$1.length)}return s[s.length]={type:xs,text:""},s}(c),a="BOD",e=0,i=r[e];for(;!Xt(i,xs);){let h=0,s=[];if(a==="BOD"){if(i.text!=="M"&&i.text!=="m")return ns("M0,0"+c);e++,h=Bt[i.text],a=i.text}else Xt(i,qt)?h=Bt[a]:(e++,h=Bt[i.text],a=i.text);if(!(e+h<r.length))throw new Error("Path data ended short");for(let o=e;o<e+h;o++){let n=r[o];if(!Xt(n,qt))throw new Error("Param not a number: "+a+","+n.text);s[s.length]=+n.text}if(typeof Bt[a]!="number")throw new Error("Bad segment: "+a);{let o={key:a,data:s};t.push(o),e+=h,i=r[e],a==="M"&&(a="L"),a==="m"&&(a="l")}}return t}function Ds(c){let t=0,r=0,a=0,e=0,i=[];for(let{key:h,data:s}of c)switch(h){case"M":i.push({key:"M",data:[...s]}),[t,r]=s,[a,e]=s;break;case"m":t+=s[0],r+=s[1],i.push({key:"M",data:[t,r]}),a=t,e=r;break;case"L":i.push({key:"L",data:[...s]}),[t,r]=s;break;case"l":t+=s[0],r+=s[1],i.push({key:"L",data:[t,r]});break;case"C":i.push({key:"C",data:[...s]}),t=s[4],r=s[5];break;case"c":{let o=s.map((n,l)=>l%2?n+r:n+t);i.push({key:"C",data:o}),t=o[4],r=o[5];break}case"Q":i.push({key:"Q",data:[...s]}),t=s[2],r=s[3];break;case"q":{let o=s.map((n,l)=>l%2?n+r:n+t);i.push({key:"Q",data:o}),t=o[2],r=o[3];break}case"A":i.push({key:"A",data:[...s]}),t=s[5],r=s[6];break;case"a":t+=s[5],r+=s[6],i.push({key:"A",data:[s[0],s[1],s[2],s[3],s[4],t,r]});break;case"H":i.push({key:"H",data:[...s]}),t=s[0];break;case"h":t+=s[0],i.push({key:"H",data:[t]});break;case"V":i.push({key:"V",data:[...s]}),r=s[0];break;case"v":r+=s[0],i.push({key:"V",data:[r]});break;case"S":i.push({key:"S",data:[...s]}),t=s[2],r=s[3];break;case"s":{let o=s.map((n,l)=>l%2?n+r:n+t);i.push({key:"S",data:o}),t=o[2],r=o[3];break}case"T":i.push({key:"T",data:[...s]}),t=s[0],r=s[1];break;case"t":t+=s[0],r+=s[1],i.push({key:"T",data:[t,r]});break;case"Z":case"z":i.push({key:"Z",data:[]}),t=a,r=e}return i}function Ps(c){let t=[],r="",a=0,e=0,i=0,h=0,s=0,o=0;for(let{key:n,data:l}of c){switch(n){case"M":t.push({key:"M",data:[...l]}),[a,e]=l,[i,h]=l;break;case"C":t.push({key:"C",data:[...l]}),a=l[4],e=l[5],s=l[2],o=l[3];break;case"L":t.push({key:"L",data:[...l]}),[a,e]=l;break;case"H":a=l[0],t.push({key:"L",data:[a,e]});break;case"V":e=l[0],t.push({key:"L",data:[a,e]});break;case"S":{let g=0,p=0;r==="C"||r==="S"?(g=a+(a-s),p=e+(e-o)):(g=a,p=e),t.push({key:"C",data:[g,p,...l]}),s=l[0],o=l[1],a=l[2],e=l[3];break}case"T":{let[g,p]=l,f=0,u=0;r==="Q"||r==="T"?(f=a+(a-s),u=e+(e-o)):(f=a,u=e);let y=a+2*(f-a)/3,d=e+2*(u-e)/3,m=g+2*(f-g)/3,x=p+2*(u-p)/3;t.push({key:"C",data:[y,d,m,x,g,p]}),s=f,o=u,a=g,e=p;break}case"Q":{let[g,p,f,u]=l,y=a+2*(g-a)/3,d=e+2*(p-e)/3,m=f+2*(g-f)/3,x=u+2*(p-u)/3;t.push({key:"C",data:[y,d,m,x,f,u]}),s=g,o=p,a=f,e=u;break}case"A":{let g=Math.abs(l[0]),p=Math.abs(l[1]),f=l[2],u=l[3],y=l[4],d=l[5],m=l[6];g===0||p===0?(t.push({key:"C",data:[a,e,d,m,d,m]}),a=d,e=m):(a!==d||e!==m)&&(Cs(a,e,d,m,g,p,f,u,y).forEach(function(x){t.push({key:"C",data:x})}),a=d,e=m);break}case"Z":t.push({key:"Z",data:[]}),a=i,e=h}r=n}return t}function vt(c,t,r){return[c*Math.cos(r)-t*Math.sin(r),c*Math.sin(r)+t*Math.cos(r)]}function Cs(c,t,r,a,e,i,h,s,o,n){let l=(g=h,Math.PI*g/180);var g;let p=[],f=0,u=0,y=0,d=0;if(n)[f,u,y,d]=n;else{[c,t]=vt(c,t,-l),[r,a]=vt(r,a,-l);let E=(c-r)/2,W=(t-a)/2,T=E*E/(e*e)+W*W/(i*i);T>1&&(T=Math.sqrt(T),e*=T,i*=T);let O=e*e,R=i*i,Y=O*R-O*W*W-R*E*E,_=O*W*W+R*E*E,L=(s===o?-1:1)*Math.sqrt(Math.abs(Y/_));y=L*e*W/i+(c+r)/2,d=L*-i*E/e+(t+a)/2,f=Math.asin(parseFloat(((t-d)/i).toFixed(9))),u=Math.asin(parseFloat(((a-d)/i).toFixed(9))),c<y&&(f=Math.PI-f),r<y&&(u=Math.PI-u),f<0&&(f=2*Math.PI+f),u<0&&(u=2*Math.PI+u),o&&f>u&&(f-=2*Math.PI),!o&&u>f&&(u-=2*Math.PI)}let m=u-f;if(Math.abs(m)>120*Math.PI/180){let E=u,W=r,T=a;u=o&&u>f?f+120*Math.PI/180*1:f+120*Math.PI/180*-1,p=Cs(r=y+e*Math.cos(u),a=d+i*Math.sin(u),W,T,e,i,h,0,o,[u,E,y,d])}m=u-f;let x=Math.cos(f),b=Math.sin(f),S=Math.cos(u),w=Math.sin(u),M=Math.tan(m/4),k=4/3*e*M,v=4/3*i*M,P=[c,t],C=[c+k*b,t-v*x],B=[r+k*w,a-v*S],X=[r,a];if(C[0]=2*P[0]-C[0],C[1]=2*P[1]-C[1],n)return[C,B,X].concat(p);{p=[C,B,X].concat(p);let E=[];for(let W=0;W<p.length;W+=3){let T=vt(p[W][0],p[W][1],l),O=vt(p[W+1][0],p[W+1][1],l),R=vt(p[W+2][0],p[W+2][1],l);E.push([T[0],T[1],O[0],O[1],R[0],R[1]])}return E}}var Ke={randOffset:function(c,t){return j(c,t)},randOffsetWithRange:function(c,t,r){return Tt(c,t,r)},ellipse:function(c,t,r,a,e){let i=Rs(r,a,e);return ss(c,t,e,i).opset},doubleLineOps:function(c,t,r,a,e){return ft(c,t,r,a,e,!0)}};function Bs(c,t,r,a,e){return{type:"path",ops:ft(c,t,r,a,e)}}function Nt(c,t,r){let a=(c||[]).length;if(a>2){let e=[];for(let i=0;i<a-1;i++)e.push(...ft(c[i][0],c[i][1],c[i+1][0],c[i+1][1],r));return t&&e.push(...ft(c[a-1][0],c[a-1][1],c[0][0],c[0][1],r)),{type:"path",ops:e}}return a===2?Bs(c[0][0],c[0][1],c[1][0],c[1][1],r):{type:"path",ops:[]}}function ta(c,t,r,a,e){return function(i,h){return Nt(i,!0,h)}([[c,t],[c+r,t],[c+r,t+a],[c,t+a]],e)}function bs(c,t){if(c.length){let r=typeof c[0][0]=="number"?[c]:c,a=Rt(r[0],1*(1+.2*t.roughness),t),e=t.disableMultiStroke?[]:Rt(r[0],1.5*(1+.22*t.roughness),Ms(t));for(let i=1;i<r.length;i++){let h=r[i];if(h.length){let s=Rt(h,1*(1+.2*t.roughness),t),o=t.disableMultiStroke?[]:Rt(h,1.5*(1+.22*t.roughness),Ms(t));for(let n of s)n.op!=="move"&&a.push(n);for(let n of o)n.op!=="move"&&e.push(n)}}return{type:"path",ops:a.concat(e)}}return{type:"path",ops:[]}}function Rs(c,t,r){let a=Math.sqrt(2*Math.PI*Math.sqrt((Math.pow(c/2,2)+Math.pow(t/2,2))/2)),e=Math.ceil(Math.max(r.curveStepCount,r.curveStepCount/Math.sqrt(200)*a)),i=2*Math.PI/e,h=Math.abs(c/2),s=Math.abs(t/2),o=1-r.curveFitting;return h+=j(h*o,r),s+=j(s*o,r),{increment:i,rx:h,ry:s}}function ss(c,t,r,a){let[e,i]=ks(a.increment,c,t,a.rx,a.ry,1,a.increment*Tt(.1,Tt(.4,1,r),r),r),h=Wt(e,null,r);if(!r.disableMultiStroke&&r.roughness!==0){let[s]=ks(a.increment,c,t,a.rx,a.ry,1.5,0,r),o=Wt(s,null,r);h=h.concat(o)}return{estimatedPoints:i,opset:{type:"path",ops:h}}}function ws(c,t,r,a,e,i,h,s,o){let n=c,l=t,g=Math.abs(r/2),p=Math.abs(a/2);g+=j(.01*g,o),p+=j(.01*p,o);let f=e,u=i;for(;f<0;)f+=2*Math.PI,u+=2*Math.PI;u-f>2*Math.PI&&(f=0,u=2*Math.PI);let y=2*Math.PI/o.curveStepCount,d=Math.min(y/2,(u-f)/2),m=vs(d,n,l,g,p,f,u,1,o);if(!o.disableMultiStroke){let x=vs(d,n,l,g,p,f,u,1.5,o);m.push(...x)}return h&&(s?m.push(...ft(n,l,n+g*Math.cos(f),l+p*Math.sin(f),o),...ft(n,l,n+g*Math.cos(u),l+p*Math.sin(u),o)):m.push({op:"lineTo",data:[n,l]},{op:"lineTo",data:[n+g*Math.cos(f),l+p*Math.sin(f)]})),{type:"path",ops:m}}function Ss(c,t){let r=Ps(Ds(ns(c))),a=[],e=[0,0],i=[0,0];for(let{key:h,data:s}of r)switch(h){case"M":i=[s[0],s[1]],e=[s[0],s[1]];break;case"L":a.push(...ft(i[0],i[1],s[0],s[1],t)),i=[s[0],s[1]];break;case"C":{let[o,n,l,g,p,f]=s;a.push(...sa(o,n,l,g,p,f,i,t)),i=[p,f];break}case"Z":a.push(...ft(i[0],i[1],e[0],e[1],t)),i=[e[0],e[1]]}return{type:"path",ops:a}}function Yt(c,t){let r=[];for(let a of c)if(a.length){let e=t.maxRandomnessOffset||0,i=a.length;if(i>2){r.push({op:"move",data:[a[0][0]+j(e,t),a[0][1]+j(e,t)]});for(let h=1;h<i;h++)r.push({op:"lineTo",data:[a[h][0]+j(e,t),a[h][1]+j(e,t)]})}}return{type:"fillPath",ops:r}}function xt(c,t){return function(r,a){let e=r.fillStyle||"hachure";if(!rt[e])switch(e){case"zigzag":rt[e]||(rt[e]=new Zt(a));break;case"cross-hatch":rt[e]||(rt[e]=new Qt(a));break;case"dots":rt[e]||(rt[e]=new Jt(a));break;case"dashed":rt[e]||(rt[e]=new Ut(a));break;case"zigzag-line":rt[e]||(rt[e]=new Kt(a));break;default:e="hachure",rt[e]||(rt[e]=new Dt(a))}return rt[e]}(t,Ke).fillPolygons(c,t)}function Ms(c){let t=Object.assign({},c);return t.randomizer=void 0,c.seed&&(t.seed=c.seed+1),t}function Ls(c){return c.randomizer||(c.randomizer=new ts(c.seed||0)),c.randomizer.next()}function Tt(c,t,r,a=1){return r.roughness*a*(Ls(r)*(t-c)+c)}function j(c,t,r=1){return Tt(-c,c,t,r)}function ft(c,t,r,a,e,i=!1){let h=i?e.disableMultiStrokeFill:e.disableMultiStroke,s=es(c,t,r,a,e,!0,!1);if(h)return s;let o=es(c,t,r,a,e,!0,!0);return s.concat(o)}function es(c,t,r,a,e,i,h){let s=Math.pow(c-r,2)+Math.pow(t-a,2),o=Math.sqrt(s),n=1;n=o<200?1:o>500?.4:-.0016668*o+1.233334;let l=e.maxRandomnessOffset||0;l*l*100>s&&(l=o/10);let g=l/2,p=.2+.2*Ls(e),f=e.bowing*e.maxRandomnessOffset*(a-t)/200,u=e.bowing*e.maxRandomnessOffset*(c-r)/200;f=j(f,e,n),u=j(u,e,n);let y=[],d=()=>j(g,e,n),m=()=>j(l,e,n),x=e.preserveVertices;return i&&(h?y.push({op:"move",data:[c+(x?0:d()),t+(x?0:d())]}):y.push({op:"move",data:[c+(x?0:j(l,e,n)),t+(x?0:j(l,e,n))]})),h?y.push({op:"bcurveTo",data:[f+c+(r-c)*p+d(),u+t+(a-t)*p+d(),f+c+2*(r-c)*p+d(),u+t+2*(a-t)*p+d(),r+(x?0:d()),a+(x?0:d())]}):y.push({op:"bcurveTo",data:[f+c+(r-c)*p+m(),u+t+(a-t)*p+m(),f+c+2*(r-c)*p+m(),u+t+2*(a-t)*p+m(),r+(x?0:m()),a+(x?0:m())]}),y}function Rt(c,t,r){if(!c.length)return[];let a=[];a.push([c[0][0]+j(t,r),c[0][1]+j(t,r)]),a.push([c[0][0]+j(t,r),c[0][1]+j(t,r)]);for(let e=1;e<c.length;e++)a.push([c[e][0]+j(t,r),c[e][1]+j(t,r)]),e===c.length-1&&a.push([c[e][0]+j(t,r),c[e][1]+j(t,r)]);return Wt(a,null,r)}function Wt(c,t,r){let a=c.length,e=[];if(a>3){let i=[],h=1-r.curveTightness;e.push({op:"move",data:[c[1][0],c[1][1]]});for(let s=1;s+2<a;s++){let o=c[s];i[0]=[o[0],o[1]],i[1]=[o[0]+(h*c[s+1][0]-h*c[s-1][0])/6,o[1]+(h*c[s+1][1]-h*c[s-1][1])/6],i[2]=[c[s+1][0]+(h*c[s][0]-h*c[s+2][0])/6,c[s+1][1]+(h*c[s][1]-h*c[s+2][1])/6],i[3]=[c[s+1][0],c[s+1][1]],e.push({op:"bcurveTo",data:[i[1][0],i[1][1],i[2][0],i[2][1],i[3][0],i[3][1]]})}if(t&&t.length===2){let s=r.maxRandomnessOffset;e.push({op:"lineTo",data:[t[0]+j(s,r),t[1]+j(s,r)]})}}else a===3?(e.push({op:"move",data:[c[1][0],c[1][1]]}),e.push({op:"bcurveTo",data:[c[1][0],c[1][1],c[2][0],c[2][1],c[2][0],c[2][1]]})):a===2&&e.push(...es(c[0][0],c[0][1],c[1][0],c[1][1],r,!0,!0));return e}function ks(c,t,r,a,e,i,h,s){let o=[],n=[];if(s.roughness===0){c/=4,n.push([t+a*Math.cos(-c),r+e*Math.sin(-c)]);for(let l=0;l<=2*Math.PI;l+=c){let g=[t+a*Math.cos(l),r+e*Math.sin(l)];o.push(g),n.push(g)}n.push([t+a*Math.cos(0),r+e*Math.sin(0)]),n.push([t+a*Math.cos(c),r+e*Math.sin(c)])}else{let l=j(.5,s)-Math.PI/2;n.push([j(i,s)+t+.9*a*Math.cos(l-c),j(i,s)+r+.9*e*Math.sin(l-c)]);let g=2*Math.PI+l-.01;for(let p=l;p<g;p+=c){let f=[j(i,s)+t+a*Math.cos(p),j(i,s)+r+e*Math.sin(p)];o.push(f),n.push(f)}n.push([j(i,s)+t+a*Math.cos(l+2*Math.PI+.5*h),j(i,s)+r+e*Math.sin(l+2*Math.PI+.5*h)]),n.push([j(i,s)+t+.98*a*Math.cos(l+h),j(i,s)+r+.98*e*Math.sin(l+h)]),n.push([j(i,s)+t+.9*a*Math.cos(l+.5*h),j(i,s)+r+.9*e*Math.sin(l+.5*h)])}return[n,o]}function vs(c,t,r,a,e,i,h,s,o){let n=i+j(.1,o),l=[];l.push([j(s,o)+t+.9*a*Math.cos(n-c),j(s,o)+r+.9*e*Math.sin(n-c)]);for(let g=n;g<=h;g+=c)l.push([j(s,o)+t+a*Math.cos(g),j(s,o)+r+e*Math.sin(g)]);return l.push([t+a*Math.cos(h),r+e*Math.sin(h)]),l.push([t+a*Math.cos(h),r+e*Math.sin(h)]),Wt(l,null,o)}function sa(c,t,r,a,e,i,h,s){let o=[],n=[s.maxRandomnessOffset||1,(s.maxRandomnessOffset||1)+.3],l=[0,0],g=s.disableMultiStroke?1:2,p=s.preserveVertices;for(let f=0;f<g;f++)f===0?o.push({op:"move",data:[h[0],h[1]]}):o.push({op:"move",data:[h[0]+(p?0:j(n[0],s)),h[1]+(p?0:j(n[0],s))]}),l=p?[e,i]:[e+j(n[f],s),i+j(n[f],s)],o.push({op:"bcurveTo",data:[c+j(n[f],s),t+j(n[f],s),r+j(n[f],s),a+j(n[f],s),l[0],l[1]]});return o}function $t(c){return[...c]}function $s(c,t=0){let r=c.length;if(r<3)throw new Error("A curve must have at least three points.");let a=[];if(r===3)a.push($t(c[0]),$t(c[1]),$t(c[2]),$t(c[2]));else{let e=[];e.push(c[0],c[0]);for(let s=1;s<c.length;s++)e.push(c[s]),s===c.length-1&&e.push(c[s]);let i=[],h=1-t;a.push($t(e[0]));for(let s=1;s+2<e.length;s++){let o=e[s];i[0]=[o[0],o[1]],i[1]=[o[0]+(h*e[s+1][0]-h*e[s-1][0])/6,o[1]+(h*e[s+1][1]-h*e[s-1][1])/6],i[2]=[e[s+1][0]+(h*e[s][0]-h*e[s+2][0])/6,e[s+1][1]+(h*e[s][1]-h*e[s+2][1])/6],i[3]=[e[s+1][0],e[s+1][1]],a.push(i[1],i[2],i[3])}}return a}function At(c,t){return Math.pow(c[0]-t[0],2)+Math.pow(c[1]-t[1],2)}function ea(c,t,r){let a=At(t,r);if(a===0)return At(c,t);let e=((c[0]-t[0])*(r[0]-t[0])+(c[1]-t[1])*(r[1]-t[1]))/a;return e=Math.max(0,Math.min(1,e)),At(c,mt(t,r,e))}function mt(c,t,r){return[c[0]+(t[0]-c[0])*r,c[1]+(t[1]-c[1])*r]}function as(c,t,r,a){let e=a||[];if(function(s,o){let n=s[o+0],l=s[o+1],g=s[o+2],p=s[o+3],f=3*l[0]-2*n[0]-p[0];f*=f;let u=3*l[1]-2*n[1]-p[1];u*=u;let y=3*g[0]-2*p[0]-n[0];y*=y;let d=3*g[1]-2*p[1]-n[1];return d*=d,f<y&&(f=y),u<d&&(u=d),f+u}(c,t)<r){let s=c[t+0];e.length?(i=e[e.length-1],h=s,Math.sqrt(At(i,h))>1&&e.push(s)):e.push(s),e.push(c[t+3])}else{let o=c[t+0],n=c[t+1],l=c[t+2],g=c[t+3],p=mt(o,n,.5),f=mt(n,l,.5),u=mt(l,g,.5),y=mt(p,f,.5),d=mt(f,u,.5),m=mt(y,d,.5);as([o,p,y,m],0,r,e),as([m,d,u,g],0,r,e)}var i,h;return e}function aa(c,t){return Ht(c,0,c.length,t)}function Ht(c,t,r,a,e){let i=e||[],h=c[t],s=c[r-1],o=0,n=1;for(let l=t+1;l<r-1;++l){let g=ea(c[l],h,s);g>o&&(o=g,n=l)}return Math.sqrt(o)>a?(Ht(c,t,n+1,a,i),Ht(c,n,r,a,i)):(i.length||i.push(h),i.push(s)),i}function Vt(c,t=.15,r){let a=[],e=(c.length-1)/3;for(let i=0;i<e;i++)as(c,3*i,t,a);return r&&r>0?Ht(a,0,a.length,r):a}var it="none",bt=class{constructor(t){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=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,r,a){return{shape:t,sets:r||[],options:a||this.defaultOptions}}line(t,r,a,e,i){let h=this._o(i);return this._d("line",[Bs(t,r,a,e,h)],h)}rectangle(t,r,a,e,i){let h=this._o(i),s=[],o=ta(t,r,a,e,h);if(h.fill){let n=[[t,r],[t+a,r],[t+a,r+e],[t,r+e]];h.fillStyle==="solid"?s.push(Yt([n],h)):s.push(xt([n],h))}return h.stroke!==it&&s.push(o),this._d("rectangle",s,h)}ellipse(t,r,a,e,i){let h=this._o(i),s=[],o=Rs(a,e,h),n=ss(t,r,h,o);if(h.fill)if(h.fillStyle==="solid"){let l=ss(t,r,h,o).opset;l.type="fillPath",s.push(l)}else s.push(xt([n.estimatedPoints],h));return h.stroke!==it&&s.push(n.opset),this._d("ellipse",s,h)}circle(t,r,a,e){let i=this.ellipse(t,r,a,a,e);return i.shape="circle",i}linearPath(t,r){let a=this._o(r);return this._d("linearPath",[Nt(t,!1,a)],a)}arc(t,r,a,e,i,h,s=!1,o){let n=this._o(o),l=[],g=ws(t,r,a,e,i,h,s,!0,n);if(s&&n.fill)if(n.fillStyle==="solid"){let p=Object.assign({},n);p.disableMultiStroke=!0;let f=ws(t,r,a,e,i,h,!0,!1,p);f.type="fillPath",l.push(f)}else l.push(function(p,f,u,y,d,m,x){let b=p,S=f,w=Math.abs(u/2),M=Math.abs(y/2);w+=j(.01*w,x),M+=j(.01*M,x);let k=d,v=m;for(;k<0;)k+=2*Math.PI,v+=2*Math.PI;v-k>2*Math.PI&&(k=0,v=2*Math.PI);let P=(v-k)/x.curveStepCount,C=[];for(let B=k;B<=v;B+=P)C.push([b+w*Math.cos(B),S+M*Math.sin(B)]);return C.push([b+w*Math.cos(v),S+M*Math.sin(v)]),C.push([b,S]),xt([C],x)}(t,r,a,e,i,h,n));return n.stroke!==it&&l.push(g),this._d("arc",l,n)}curve(t,r){let a=this._o(r),e=[],i=bs(t,a);if(a.fill&&a.fill!==it)if(a.fillStyle==="solid"){let h=bs(t,Object.assign(Object.assign({},a),{disableMultiStroke:!0,roughness:a.roughness?a.roughness+a.fillShapeRoughnessGain:0}));e.push({type:"fillPath",ops:this._mergedShape(h.ops)})}else{let h=[],s=t;if(s.length){let o=typeof s[0][0]=="number"?[s]:s;for(let n of o)n.length<3?h.push(...n):n.length===3?h.push(...Vt($s([n[0],n[0],n[1],n[2]]),10,(1+a.roughness)/2)):h.push(...Vt($s(n),10,(1+a.roughness)/2))}h.length&&e.push(xt([h],a))}return a.stroke!==it&&e.push(i),this._d("curve",e,a)}polygon(t,r){let a=this._o(r),e=[],i=Nt(t,!0,a);return a.fill&&(a.fillStyle==="solid"?e.push(Yt([t],a)):e.push(xt([t],a))),a.stroke!==it&&e.push(i),this._d("polygon",e,a)}path(t,r){let a=this._o(r),e=[];if(!t)return this._d("path",e,a);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let i=a.fill&&a.fill!=="transparent"&&a.fill!==it,h=a.stroke!==it,s=!!(a.simplification&&a.simplification<1),o=function(l,g,p){let f=Ps(Ds(ns(l))),u=[],y=[],d=[0,0],m=[],x=()=>{m.length>=4&&y.push(...Vt(m,g)),m=[]},b=()=>{x(),y.length&&(u.push(y),y=[])};for(let{key:w,data:M}of f)switch(w){case"M":b(),d=[M[0],M[1]],y.push(d);break;case"L":x(),y.push([M[0],M[1]]);break;case"C":if(!m.length){let k=y.length?y[y.length-1]:d;m.push([k[0],k[1]])}m.push([M[0],M[1]]),m.push([M[2],M[3]]),m.push([M[4],M[5]]);break;case"Z":x(),y.push([d[0],d[1]])}if(b(),!p)return u;let S=[];for(let w of u){let M=aa(w,p);M.length&&S.push(M)}return S}(t,1,s?4-4*(a.simplification||1):(1+a.roughness)/2),n=Ss(t,a);if(i)if(a.fillStyle==="solid")if(o.length===1){let l=Ss(t,Object.assign(Object.assign({},a),{disableMultiStroke:!0,roughness:a.roughness?a.roughness+a.fillShapeRoughnessGain:0}));e.push({type:"fillPath",ops:this._mergedShape(l.ops)})}else e.push(Yt(o,a));else e.push(xt(o,a));return h&&(s?o.forEach(l=>{e.push(Nt(l,!1,a))}):e.push(n)),this._d("path",e,a)}opsToPath(t,r){let a="";for(let e of t.ops){let i=typeof r=="number"&&r>=0?e.data.map(h=>+h.toFixed(r)):e.data;switch(e.op){case"move":a+=`M${i[0]} ${i[1]} `;break;case"bcurveTo":a+=`C${i[0]} ${i[1]}, ${i[2]} ${i[3]}, ${i[4]} ${i[5]} `;break;case"lineTo":a+=`L${i[0]} ${i[1]} `}}return a.trim()}toPaths(t){let r=t.sets||[],a=t.options||this.defaultOptions,e=[];for(let i of r){let h=null;switch(i.type){case"path":h={d:this.opsToPath(i),stroke:a.stroke,strokeWidth:a.strokeWidth,fill:it};break;case"fillPath":h={d:this.opsToPath(i),stroke:it,strokeWidth:0,fill:a.fill||it};break;case"fillSketch":h=this.fillSketch(i,a)}h&&e.push(h)}return e}fillSketch(t,r){let a=r.fillWeight;return a<0&&(a=r.strokeWidth/2),{d:this.opsToPath(t),stroke:r.fill||it,strokeWidth:a,fill:it}}_mergedShape(t){return t.filter((r,a)=>a===0||r.op!=="move")}},rs=class{constructor(t,r){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new bt(r)}draw(t){let r=t.sets||[],a=t.options||this.getDefaultOptions(),e=this.ctx,i=t.options.fixedDecimalPlaceDigits;for(let h of r)switch(h.type){case"path":e.save(),e.strokeStyle=a.stroke==="none"?"transparent":a.stroke,e.lineWidth=a.strokeWidth,a.strokeLineDash&&e.setLineDash(a.strokeLineDash),a.strokeLineDashOffset&&(e.lineDashOffset=a.strokeLineDashOffset),this._drawToContext(e,h,i),e.restore();break;case"fillPath":{e.save(),e.fillStyle=a.fill||"";let s=t.shape==="curve"||t.shape==="polygon"||t.shape==="path"?"evenodd":"nonzero";this._drawToContext(e,h,i,s),e.restore();break}case"fillSketch":this.fillSketch(e,h,a)}}fillSketch(t,r,a){let e=a.fillWeight;e<0&&(e=a.strokeWidth/2),t.save(),a.fillLineDash&&t.setLineDash(a.fillLineDash),a.fillLineDashOffset&&(t.lineDashOffset=a.fillLineDashOffset),t.strokeStyle=a.fill||"",t.lineWidth=e,this._drawToContext(t,r,a.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,r,a,e="nonzero"){t.beginPath();for(let i of r.ops){let h=typeof a=="number"&&a>=0?i.data.map(s=>+s.toFixed(a)):i.data;switch(i.op){case"move":t.moveTo(h[0],h[1]);break;case"bcurveTo":t.bezierCurveTo(h[0],h[1],h[2],h[3],h[4],h[5]);break;case"lineTo":t.lineTo(h[0],h[1])}}r.type==="fillPath"?t.fill(e):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,r,a,e,i){let h=this.gen.line(t,r,a,e,i);return this.draw(h),h}rectangle(t,r,a,e,i){let h=this.gen.rectangle(t,r,a,e,i);return this.draw(h),h}ellipse(t,r,a,e,i){let h=this.gen.ellipse(t,r,a,e,i);return this.draw(h),h}circle(t,r,a,e){let i=this.gen.circle(t,r,a,e);return this.draw(i),i}linearPath(t,r){let a=this.gen.linearPath(t,r);return this.draw(a),a}polygon(t,r){let a=this.gen.polygon(t,r);return this.draw(a),a}arc(t,r,a,e,i,h,s=!1,o){let n=this.gen.arc(t,r,a,e,i,h,s,o);return this.draw(n),n}curve(t,r){let a=this.gen.curve(t,r);return this.draw(a),a}path(t,r){let a=this.gen.path(t,r);return this.draw(a),a}},Lt="http://www.w3.org/2000/svg",is=class{constructor(t,r){this.svg=t,this.gen=new bt(r)}draw(t){let r=t.sets||[],a=t.options||this.getDefaultOptions(),e=this.svg.ownerDocument||window.document,i=e.createElementNS(Lt,"g"),h=t.options.fixedDecimalPlaceDigits;for(let s of r){let o=null;switch(s.type){case"path":o=e.createElementNS(Lt,"path"),o.setAttribute("d",this.opsToPath(s,h)),o.setAttribute("stroke",a.stroke),o.setAttribute("stroke-width",a.strokeWidth+""),o.setAttribute("fill","none"),a.strokeLineDash&&o.setAttribute("stroke-dasharray",a.strokeLineDash.join(" ").trim()),a.strokeLineDashOffset&&o.setAttribute("stroke-dashoffset",`${a.strokeLineDashOffset}`);break;case"fillPath":o=e.createElementNS(Lt,"path"),o.setAttribute("d",this.opsToPath(s,h)),o.setAttribute("stroke","none"),o.setAttribute("stroke-width","0"),o.setAttribute("fill",a.fill||""),t.shape!=="curve"&&t.shape!=="polygon"||o.setAttribute("fill-rule","evenodd");break;case"fillSketch":o=this.fillSketch(e,s,a)}o&&i.appendChild(o)}return i}fillSketch(t,r,a){let e=a.fillWeight;e<0&&(e=a.strokeWidth/2);let i=t.createElementNS(Lt,"path");return i.setAttribute("d",this.opsToPath(r,a.fixedDecimalPlaceDigits)),i.setAttribute("stroke",a.fill||""),i.setAttribute("stroke-width",e+""),i.setAttribute("fill","none"),a.fillLineDash&&i.setAttribute("stroke-dasharray",a.fillLineDash.join(" ").trim()),a.fillLineDashOffset&&i.setAttribute("stroke-dashoffset",`${a.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,r){return this.gen.opsToPath(t,r)}line(t,r,a,e,i){let h=this.gen.line(t,r,a,e,i);return this.draw(h)}rectangle(t,r,a,e,i){let h=this.gen.rectangle(t,r,a,e,i);return this.draw(h)}ellipse(t,r,a,e,i){let h=this.gen.ellipse(t,r,a,e,i);return this.draw(h)}circle(t,r,a,e){let i=this.gen.circle(t,r,a,e);return this.draw(i)}linearPath(t,r){let a=this.gen.linearPath(t,r);return this.draw(a)}polygon(t,r){let a=this.gen.polygon(t,r);return this.draw(a)}arc(t,r,a,e,i,h,s=!1,o){let n=this.gen.arc(t,r,a,e,i,h,s,o);return this.draw(n)}curve(t,r){let a=this.gen.curve(t,r);return this.draw(a)}path(t,r){let a=this.gen.path(t,r);return this.draw(a)}},D={canvas:(c,t)=>new rs(c,t),svg:(c,t)=>new is(c,t),generator:c=>new bt(c),newSeed:()=>bt.newSeed()};var q=$(async(c,t,r)=>{var g,p,f;let a,e=t.useHtmlLabels||tt((g=Q())==null?void 0:g.htmlLabels);r?a=r:a="node default";let i=c.insert("g").attr("class",a).attr("id",t.domId||t.id),h=i.insert("g").attr("class","label").attr("style",st(t.labelStyle)),s;t.label===void 0?s="":s=typeof t.label=="string"?t.label:t.label[0];let o=await dt(h,zt(kt(s),Q()),{useHtmlLabels:e,width:t.width||((p=Q().flowchart)==null?void 0:p.wrappingWidth),cssClasses:"markdown-node-label",style:t.labelStyle,addSvgBackground:!!t.icon||!!t.img}),n=o.getBBox(),l=((f=t==null?void 0:t.padding)!=null?f:0)/2;if(e){let u=o.children[0],y=J(o),d=u.getElementsByTagName("img");if(d){let m=s.replace(/<img[^>]*>/g,"").trim()==="";await Promise.all([...d].map(x=>new Promise(b=>{function S(){if(x.style.display="flex",x.style.flexDirection="column",m){let w=Q().fontSize?Q().fontSize:window.getComputedStyle(document.body).fontSize,M=5,[k=ps.fontSize]=ds(w),v=k*M+"px";x.style.minWidth=v,x.style.maxWidth=v}else x.style.width="100%";b(x)}$(S,"setupImage"),setTimeout(()=>{x.complete&&S()}),x.addEventListener("error",S),x.addEventListener("load",S)})))}n=u.getBoundingClientRect(),y.attr("width",n.width),y.attr("height",n.height)}return e?h.attr("transform","translate("+-n.width/2+", "+-n.height/2+")"):h.attr("transform","translate(0, "+-n.height/2+")"),t.centerLabel&&h.attr("transform","translate("+-n.width/2+", "+-n.height/2+")"),h.insert("rect",":first-child"),{shapeSvg:i,bbox:n,halfPadding:l,label:h}},"labelHelper"),ls=$(async(c,t,r)=>{var o,n,l,g,p,f;let a=r.useHtmlLabels||tt((n=(o=Q())==null?void 0:o.flowchart)==null?void 0:n.htmlLabels),e=c.insert("g").attr("class","label").attr("style",r.labelStyle||""),i=await dt(e,zt(kt(t),Q()),{useHtmlLabels:a,width:r.width||((g=(l=Q())==null?void 0:l.flowchart)==null?void 0:g.wrappingWidth),style:r.labelStyle,addSvgBackground:!!r.icon||!!r.img}),h=i.getBBox(),s=r.padding/2;if(tt((f=(p=Q())==null?void 0:p.flowchart)==null?void 0:f.htmlLabels)){let u=i.children[0],y=J(i);h=u.getBoundingClientRect(),y.attr("width",h.width),y.attr("height",h.height)}return a?e.attr("transform","translate("+-h.width/2+", "+-h.height/2+")"):e.attr("transform","translate(0, "+-h.height/2+")"),r.centerLabel&&e.attr("transform","translate("+-h.width/2+", "+-h.height/2+")"),e.insert("rect",":first-child"),{shapeSvg:c,bbox:h,halfPadding:s,label:e}},"insertLabel"),H=$((c,t)=>{let r=t.node().getBBox();c.width=r.width,c.height=r.height},"updateNodeBounds"),F=$((c,t)=>(c.look==="handDrawn"?"rough-node":"node")+" "+c.cssClasses+" "+(t||""),"getNodeClasses");function V(c){let t=c.map((r,a)=>`${a===0?"M":"L"}${r.x},${r.y}`);return t.push("Z"),t.join(" ")}$(V,"createPathFromPoints");function ut(c,t,r,a,e,i){let h=[],o=r-c,n=a-t,l=o/i,g=2*Math.PI/l,p=t+n/2;for(let f=0;f<=50;f++){let u=f/50,y=c+u*o,d=p+e*Math.sin(g*(y-c));h.push({x:y,y:d})}return h}$(ut,"generateFullSineWavePoints");function gs(c,t,r,a,e,i){let h=[],s=e*Math.PI/180,l=(i*Math.PI/180-s)/(a-1);for(let g=0;g<a;g++){let p=s+g*l,f=c+r*Math.cos(p),u=t+r*Math.sin(p);h.push({x:-f,y:-u})}return h}$(gs,"generateCirclePoints");var ra=$((c,t)=>{var r=c.x,a=c.y,e=t.x-r,i=t.y-a,h=c.width/2,s=c.height/2,o,n;return Math.abs(i)*h>Math.abs(e)*s?(i<0&&(s=-s),o=i===0?0:s*e/i,n=s):(e<0&&(h=-h),o=h,n=e===0?0:h*i/e),{x:r+o,y:a+n}},"intersectRect"),wt=ra;function Ns(c,t){t&&c.attr("style",t)}$(Ns,"applyStyle");async function As(c){let t=J(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")),r=t.append("xhtml:div"),a=c.label;c.label&&jt(c.label)&&(a=await fs(c.label.replace(us.lineBreakRegex,`
`),Q()));let e=c.isNode?"nodeLabel":"edgeLabel";return r.html('<span class="'+e+'" '+(c.labelStyle?'style="'+c.labelStyle+'"':"")+">"+a+"</span>"),Ns(r,c.labelStyle),r.style("display","inline-block"),r.style("padding-right","1px"),r.style("white-space","nowrap"),r.attr("xmlns","http://www.w3.org/1999/xhtml"),t.node()}$(As,"addHtmlLabel");var ia=$(async(c,t,r,a)=>{let e=c||"";if(typeof e=="object"&&(e=e[0]),tt(Q().flowchart.htmlLabels)){e=e.replace(/\\n|\n/g,"<br />"),Z.info("vertexText"+e);let i={isNode:a,label:kt(e).replace(/fa[blrs]?:fa-[\w-]+/g,s=>`<i class='${s.replace(":"," ")}'></i>`),labelStyle:t&&t.replace("fill:","color:")};return await As(i)}else{let i=document.createElementNS("http://www.w3.org/2000/svg","text");i.setAttribute("style",t.replace("color:","fill:"));let h=[];typeof e=="string"?h=e.split(/\\n|\n|<br\s*\/?>/gi):Array.isArray(e)?h=e:h=[];for(let s of h){let o=document.createElementNS("http://www.w3.org/2000/svg","tspan");o.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),o.setAttribute("dy","1em"),o.setAttribute("x","0"),r?o.setAttribute("class","title-row"):o.setAttribute("class","row"),o.textContent=s.trim(),i.appendChild(o)}return i}},"createLabel"),cs=ia,ht=$((c,t,r,a,e)=>["M",c+e,t,"H",c+r-e,"A",e,e,0,0,1,c+r,t+e,"V",t+a-e,"A",e,e,0,0,1,c+r-e,t+a,"H",c+e,"A",e,e,0,0,1,c,t+a-e,"V",t+e,"A",e,e,0,0,1,c+e,t,"Z"].join(" "),"createRoundedRectPathD"),na=$(c=>{let{handDrawnSeed:t}=Q();return{fill:c,hachureAngle:120,hachureGap:4,fillWeight:2,roughness:.7,stroke:c,seed:t}},"solidStateFill"),St=$(c=>{let t=la([...c.cssCompiledStyles||[],...c.cssStyles||[]]);return{stylesMap:t,stylesArray:[...t]}},"compileStyles"),la=$(c=>{let t=new Map;return c.forEach(r=>{let[a,e]=r.split(":");t.set(a.trim(),e==null?void 0:e.trim())}),t},"styles2Map"),I=$(c=>{let{stylesArray:t}=St(c),r=[],a=[],e=[],i=[];return t.forEach(h=>{let s=h[0];s==="color"||s==="font-size"||s==="font-family"||s==="font-weight"||s==="font-style"||s==="text-decoration"||s==="text-align"||s==="text-transform"||s==="line-height"||s==="letter-spacing"||s==="word-spacing"||s==="text-shadow"||s==="text-overflow"||s==="white-space"||s==="word-wrap"||s==="word-break"||s==="overflow-wrap"||s==="hyphens"?r.push(h.join(":")+" !important"):(a.push(h.join(":")+" !important"),s.includes("stroke")&&e.push(h.join(":")+" !important"),s==="fill"&&i.push(h.join(":")+" !important"))}),{labelStyles:r.join(";"),nodeStyles:a.join(";"),stylesArray:t,borderStyles:e,backgroundStyles:i}},"styles2String"),A=$((c,t)=>{var o;let{themeVariables:r,handDrawnSeed:a}=Q(),{nodeBorder:e,mainBkg:i}=r,{stylesMap:h}=St(c);return Object.assign({roughness:.7,fill:h.get("fill")||i,fillStyle:"hachure",fillWeight:4,hachureGap:5.2,stroke:h.get("stroke")||e,seed:a,strokeWidth:((o=h.get("stroke-width"))==null?void 0:o.replace("px",""))||1.3,fillLineDash:[0,0]},t)},"userNodeOverrides"),Ts=$(async(c,t)=>{Z.info("Creating subgraph rect for ",t.id,t);let r=Q(),{themeVariables:a,handDrawnSeed:e}=r,{clusterBkg:i,clusterBorder:h}=a,{labelStyles:s,nodeStyles:o,borderStyles:n,backgroundStyles:l}=I(t),g=c.insert("g").attr("class","cluster "+t.cssClasses).attr("id",t.id).attr("data-look",t.look),p=tt(r.flowchart.htmlLabels),f=g.insert("g").attr("class","cluster-label "),u=await dt(f,t.label,{style:t.labelStyle,useHtmlLabels:p,isNode:!0}),y=u.getBBox();if(tt(r.flowchart.htmlLabels)){let k=u.children[0],v=J(u);y=k.getBoundingClientRect(),v.attr("width",y.width),v.attr("height",y.height)}let d=t.width<=y.width+t.padding?y.width+t.padding:t.width;t.width<=y.width+t.padding?t.diff=(d-t.width)/2-t.padding:t.diff=-t.padding;let m=t.height,x=t.x-d/2,b=t.y-m/2;Z.trace("Data ",t,JSON.stringify(t));let S;if(t.look==="handDrawn"){let k=D.svg(g),v=A(t,{roughness:.7,fill:i,stroke:h,fillWeight:3,seed:e}),P=k.path(ht(x,b,d,m,0),v);S=g.insert(()=>(Z.debug("Rough node insert CXC",P),P),":first-child"),S.select("path:nth-child(2)").attr("style",n.join(";")),S.select("path").attr("style",l.join(";").replace("fill","stroke"))}else S=g.insert("rect",":first-child"),S.attr("style",o).attr("rx",t.rx).attr("ry",t.ry).attr("x",x).attr("y",b).attr("width",d).attr("height",m);let{subGraphTitleTopMargin:w}=Gt(r);if(f.attr("transform",`translate(${t.x-y.width/2}, ${t.y-t.height/2+w})`),s){let k=f.select("span");k&&k.attr("style",s)}let M=S.node().getBBox();return t.offsetX=0,t.width=M.width,t.height=M.height,t.offsetY=y.height-t.padding/2,t.intersect=function(k){return wt(t,k)},{cluster:g,labelBBox:y}},"rect"),ca=$((c,t)=>{let r=c.insert("g").attr("class","note-cluster").attr("id",t.id),a=r.insert("rect",":first-child"),e=0*t.padding,i=e/2;a.attr("rx",t.rx).attr("ry",t.ry).attr("x",t.x-t.width/2-i).attr("y",t.y-t.height/2-i).attr("width",t.width+e).attr("height",t.height+e).attr("fill","none");let h=a.node().getBBox();return t.width=h.width,t.height=h.height,t.intersect=function(s){return wt(t,s)},{cluster:r,labelBBox:{width:0,height:0}}},"noteGroup"),oa=$(async(c,t)=>{let r=Q(),{themeVariables:a,handDrawnSeed:e}=r,{altBackground:i,compositeBackground:h,compositeTitleBackground:s,nodeBorder:o}=a,n=c.insert("g").attr("class",t.cssClasses).attr("id",t.id).attr("data-id",t.id).attr("data-look",t.look),l=n.insert("g",":first-child"),g=n.insert("g").attr("class","cluster-label"),p=n.append("rect"),f=g.node().appendChild(await cs(t.label,t.labelStyle,void 0,!0)),u=f.getBBox();if(tt(r.flowchart.htmlLabels)){let P=f.children[0],C=J(f);u=P.getBoundingClientRect(),C.attr("width",u.width),C.attr("height",u.height)}let y=0*t.padding,d=y/2,m=(t.width<=u.width+t.padding?u.width+t.padding:t.width)+y;t.width<=u.width+t.padding?t.diff=(m-t.width)/2-t.padding:t.diff=-t.padding;let x=t.height+y,b=t.height+y-u.height-6,S=t.x-m/2,w=t.y-x/2;t.width=m;let M=t.y-t.height/2-d+u.height+2,k;if(t.look==="handDrawn"){let P=t.cssClasses.includes("statediagram-cluster-alt"),C=D.svg(n),B=t.rx||t.ry?C.path(ht(S,w,m,x,10),{roughness:.7,fill:s,fillStyle:"solid",stroke:o,seed:e}):C.rectangle(S,w,m,x,{seed:e});k=n.insert(()=>B,":first-child");let X=C.rectangle(S,M,m,b,{fill:P?i:h,fillStyle:P?"hachure":"solid",stroke:o,seed:e});k=n.insert(()=>B,":first-child"),p=n.insert(()=>X)}else k=l.insert("rect",":first-child"),k.attr("class","outer").attr("x",S).attr("y",w).attr("width",m).attr("height",x).attr("data-look",t.look),p.attr("class","inner").attr("x",S).attr("y",M).attr("width",m).attr("height",b);g.attr("transform",`translate(${t.x-u.width/2}, ${w+1-(tt(r.flowchart.htmlLabels)?0:3)})`);let v=k.node().getBBox();return t.height=v.height,t.offsetX=0,t.offsetY=u.height-t.padding/2,t.labelBBox=u,t.intersect=function(P){return wt(t,P)},{cluster:n,labelBBox:u}},"roundedWithTitle"),ha=$(async(c,t)=>{Z.info("Creating subgraph rect for ",t.id,t);let r=Q(),{themeVariables:a,handDrawnSeed:e}=r,{clusterBkg:i,clusterBorder:h}=a,{labelStyles:s,nodeStyles:o,borderStyles:n,backgroundStyles:l}=I(t),g=c.insert("g").attr("class","cluster "+t.cssClasses).attr("id",t.id).attr("data-look",t.look),p=tt(r.flowchart.htmlLabels),f=g.insert("g").attr("class","cluster-label "),u=await dt(f,t.label,{style:t.labelStyle,useHtmlLabels:p,isNode:!0,width:t.width}),y=u.getBBox();if(tt(r.flowchart.htmlLabels)){let k=u.children[0],v=J(u);y=k.getBoundingClientRect(),v.attr("width",y.width),v.attr("height",y.height)}let d=t.width<=y.width+t.padding?y.width+t.padding:t.width;t.width<=y.width+t.padding?t.diff=(d-t.width)/2-t.padding:t.diff=-t.padding;let m=t.height,x=t.x-d/2,b=t.y-m/2;Z.trace("Data ",t,JSON.stringify(t));let S;if(t.look==="handDrawn"){let k=D.svg(g),v=A(t,{roughness:.7,fill:i,stroke:h,fillWeight:4,seed:e}),P=k.path(ht(x,b,d,m,t.rx),v);S=g.insert(()=>(Z.debug("Rough node insert CXC",P),P),":first-child"),S.select("path:nth-child(2)").attr("style",n.join(";")),S.select("path").attr("style",l.join(";").replace("fill","stroke"))}else S=g.insert("rect",":first-child"),S.attr("style",o).attr("rx",t.rx).attr("ry",t.ry).attr("x",x).attr("y",b).attr("width",d).attr("height",m);let{subGraphTitleTopMargin:w}=Gt(r);if(f.attr("transform",`translate(${t.x-y.width/2}, ${t.y-t.height/2+w})`),s){let k=f.select("span");k&&k.attr("style",s)}let M=S.node().getBBox();return t.offsetX=0,t.width=M.width,t.height=M.height,t.offsetY=y.height-t.padding/2,t.intersect=function(k){return wt(t,k)},{cluster:g,labelBBox:y}},"kanbanSection"),ga=$((c,t)=>{let r=Q(),{themeVariables:a,handDrawnSeed:e}=r,{nodeBorder:i}=a,h=c.insert("g").attr("class",t.cssClasses).attr("id",t.id).attr("data-look",t.look),s=h.insert("g",":first-child"),o=0*t.padding,n=t.width+o;t.diff=-t.padding;let l=t.height+o,g=t.x-n/2,p=t.y-l/2;t.width=n;let f;if(t.look==="handDrawn"){let d=D.svg(h).rectangle(g,p,n,l,{fill:"lightgrey",roughness:.5,strokeLineDash:[5],stroke:i,seed:e});f=h.insert(()=>d,":first-child")}else f=s.insert("rect",":first-child"),f.attr("class","divider").attr("x",g).attr("y",p).attr("width",n).attr("height",l).attr("data-look",t.look);let u=f.node().getBBox();return t.height=u.height,t.offsetX=0,t.offsetY=0,t.intersect=function(y){return wt(t,y)},{cluster:h,labelBBox:{}}},"divider"),pa=Ts,fa={rect:Ts,squareRect:pa,roundedWithTitle:oa,noteGroup:ca,divider:ga,kanbanSection:ha},Ws=new Map,Fa=$(async(c,t)=>{let r=t.shape||"rect",a=await fa[r](c,t);return Ws.set(t.id,a),a},"insertCluster"),qa=$(()=>{Ws=new Map},"clear");function Hs(c,t){return c.intersect(t)}$(Hs,"intersectNode");var ua=Hs;function Is(c,t,r,a){var e=c.x,i=c.y,h=e-a.x,s=i-a.y,o=Math.sqrt(t*t*s*s+r*r*h*h),n=Math.abs(t*r*h/o);a.x<e&&(n=-n);var l=Math.abs(t*r*s/o);return a.y<i&&(l=-l),{x:e+n,y:i+l}}$(Is,"intersectEllipse");var Es=Is;function Os(c,t,r){return Es(c,t,t,r)}$(Os,"intersectCircle");var ya=Os;function _s(c,t,r,a){var e,i,h,s,o,n,l,g,p,f,u,y,d,m,x;if(e=t.y-c.y,h=c.x-t.x,o=t.x*c.y-c.x*t.y,p=e*r.x+h*r.y+o,f=e*a.x+h*a.y+o,!(p!==0&&f!==0&&os(p,f))&&(i=a.y-r.y,s=r.x-a.x,n=a.x*r.y-r.x*a.y,l=i*c.x+s*c.y+n,g=i*t.x+s*t.y+n,!(l!==0&&g!==0&&os(l,g))&&(u=e*s-i*h,u!==0)))return y=Math.abs(u/2),d=h*n-s*o,m=d<0?(d-y)/u:(d+y)/u,d=i*o-e*n,x=d<0?(d-y)/u:(d+y)/u,{x:m,y:x}}$(_s,"intersectLine");function os(c,t){return c*t>0}$(os,"sameSign");var ma=_s;function zs(c,t,r){let a=c.x,e=c.y,i=[],h=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY;typeof t.forEach=="function"?t.forEach(function(l){h=Math.min(h,l.x),s=Math.min(s,l.y)}):(h=Math.min(h,t.x),s=Math.min(s,t.y));let o=a-c.width/2-h,n=e-c.height/2-s;for(let l=0;l<t.length;l++){let g=t[l],p=t[l<t.length-1?l+1:0],f=ma(c,r,{x:o+g.x,y:n+g.y},{x:o+p.x,y:n+p.y});f&&i.push(f)}return i.length?(i.length>1&&i.sort(function(l,g){let p=l.x-r.x,f=l.y-r.y,u=Math.sqrt(p*p+f*f),y=g.x-r.x,d=g.y-r.y,m=Math.sqrt(y*y+d*d);return u<m?-1:u===m?0:1}),i[0]):c}$(zs,"intersectPolygon");var da=zs,N={node:ua,circle:ya,ellipse:Es,polygon:da,rect:wt};function js(c,t){let{labelStyles:r}=I(t);t.labelStyle=r;let a=F(t),e=a;a||(e="anchor");let i=c.insert("g").attr("class",e).attr("id",t.domId||t.id),h=1,{cssStyles:s}=t,o=D.svg(i),n=A(t,{fill:"black",stroke:"none",fillStyle:"solid"});t.look!=="handDrawn"&&(n.roughness=0);let l=o.circle(0,0,h*2,n),g=i.insert(()=>l,":first-child");return g.attr("class","anchor").attr("style",st(s)),H(t,g),t.intersect=function(p){return Z.info("Circle intersect",t,h,p),N.circle(t,h,p)},i}$(js,"anchor");function hs(c,t,r,a,e,i,h){let o=(c+r)/2,n=(t+a)/2,l=Math.atan2(a-t,r-c),g=(r-c)/2,p=(a-t)/2,f=g/e,u=p/i,y=Math.sqrt(f**2+u**2);if(y>1)throw new Error("The given radii are too small to create an arc between the points.");let d=Math.sqrt(1-y**2),m=o+d*i*Math.sin(l)*(h?-1:1),x=n-d*e*Math.cos(l)*(h?-1:1),b=Math.atan2((t-x)/i,(c-m)/e),w=Math.atan2((a-x)/i,(r-m)/e)-b;h&&w<0&&(w+=2*Math.PI),!h&&w>0&&(w-=2*Math.PI);let M=[];for(let k=0;k<20;k++){let v=k/19,P=b+v*w,C=m+e*Math.cos(P),B=x+i*Math.sin(P);M.push({x:C,y:B})}return M}$(hs,"generateArcPoints");async function Gs(c,t){let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=i.width+t.padding+20,s=i.height+t.padding,o=s/2,n=o/(2.5+s/50),{cssStyles:l}=t,g=[{x:h/2,y:-s/2},{x:-h/2,y:-s/2},...hs(-h/2,-s/2,-h/2,s/2,n,o,!1),{x:h/2,y:s/2},...hs(h/2,s/2,h/2,-s/2,n,o,!0)],p=D.svg(e),f=A(t,{});t.look!=="handDrawn"&&(f.roughness=0,f.fillStyle="solid");let u=V(g),y=p.path(u,f),d=e.insert(()=>y,":first-child");return d.attr("class","basic label-container"),l&&t.look!=="handDrawn"&&d.selectAll("path").attr("style",l),a&&t.look!=="handDrawn"&&d.selectAll("path").attr("style",a),d.attr("transform",`translate(${n/2}, 0)`),H(t,d),t.intersect=function(m){return N.polygon(t,g,m)},e}$(Gs,"bowTieRect");function gt(c,t,r,a){return c.insert("polygon",":first-child").attr("points",a.map(function(e){return e.x+","+e.y}).join(" ")).attr("class","label-container").attr("transform","translate("+-t/2+","+r/2+")")}$(gt,"insertPolygonShape");async function Fs(c,t){let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=i.height+t.padding,s=12,o=i.width+t.padding+s,n=0,l=o,g=-h,p=0,f=[{x:n+s,y:g},{x:l,y:g},{x:l,y:p},{x:n,y:p},{x:n,y:g+s},{x:n+s,y:g}],u,{cssStyles:y}=t;if(t.look==="handDrawn"){let d=D.svg(e),m=A(t,{}),x=V(f),b=d.path(x,m);u=e.insert(()=>b,":first-child").attr("transform",`translate(${-o/2}, ${h/2})`),y&&u.attr("style",y)}else u=gt(e,o,h,f);return a&&u.attr("style",a),H(t,u),t.intersect=function(d){return N.polygon(t,f,d)},e}$(Fs,"card");function qs(c,t){var p,f;let{nodeStyles:r}=I(t);t.label="";let a=c.insert("g").attr("class",F(t)).attr("id",(p=t.domId)!=null?p:t.id),{cssStyles:e}=t,i=Math.max(28,(f=t.width)!=null?f:0),h=[{x:0,y:i/2},{x:i/2,y:0},{x:0,y:-i/2},{x:-i/2,y:0}],s=D.svg(a),o=A(t,{});t.look!=="handDrawn"&&(o.roughness=0,o.fillStyle="solid");let n=V(h),l=s.path(n,o),g=a.insert(()=>l,":first-child");return e&&t.look!=="handDrawn"&&g.selectAll("path").attr("style",e),r&&t.look!=="handDrawn"&&g.selectAll("path").attr("style",r),t.width=28,t.height=28,t.intersect=function(u){return N.polygon(t,h,u)},a}$(qs,"choice");async function Xs(c,t){let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,halfPadding:h}=await q(c,t,F(t)),s=i.width/2+h,o,{cssStyles:n}=t;if(t.look==="handDrawn"){let l=D.svg(e),g=A(t,{}),p=l.circle(0,0,s*2,g);o=e.insert(()=>p,":first-child"),o.attr("class","basic label-container").attr("style",st(n))}else o=e.insert("circle",":first-child").attr("class","basic label-container").attr("style",a).attr("r",s).attr("cx",0).attr("cy",0);return H(t,o),t.intersect=function(l){return Z.info("Circle intersect",t,s,l),N.circle(t,s,l)},e}$(Xs,"circle");function Ys(c){let t=Math.cos(Math.PI/4),r=Math.sin(Math.PI/4),a=c*2,e={x:a/2*t,y:a/2*r},i={x:-(a/2)*t,y:a/2*r},h={x:-(a/2)*t,y:-(a/2)*r},s={x:a/2*t,y:-(a/2)*r};return`M ${i.x},${i.y} L ${s.x},${s.y}
M ${e.x},${e.y} L ${h.x},${h.y}`}$(Ys,"createLine");function Vs(c,t){var f,u;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r,t.label="";let e=c.insert("g").attr("class",F(t)).attr("id",(f=t.domId)!=null?f:t.id),i=Math.max(30,(u=t==null?void 0:t.width)!=null?u:0),{cssStyles:h}=t,s=D.svg(e),o=A(t,{});t.look!=="handDrawn"&&(o.roughness=0,o.fillStyle="solid");let n=s.circle(0,0,i*2,o),l=Ys(i),g=s.path(l,o),p=e.insert(()=>n,":first-child");return p.insert(()=>g),h&&t.look!=="handDrawn"&&p.selectAll("path").attr("style",h),a&&t.look!=="handDrawn"&&p.selectAll("path").attr("style",a),H(t,p),t.intersect=function(y){return Z.info("crossedCircle intersect",t,{radius:i,point:y}),N.circle(t,i,y)},e}$(Vs,"crossedCircle");function ct(c,t,r,a=100,e=0,i=180){let h=[],s=e*Math.PI/180,l=(i*Math.PI/180-s)/(a-1);for(let g=0;g<a;g++){let p=s+g*l,f=c+r*Math.cos(p),u=t+r*Math.sin(p);h.push({x:-f,y:-u})}return h}$(ct,"generateCirclePoints");async function Zs(c,t){var w,M,k,v,P;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=i.width+((w=t.padding)!=null?w:0),o=i.height+((M=t.padding)!=null?M:0),n=Math.max(5,o*.1),{cssStyles:l}=t,g=[...ct(s/2,-o/2,n,30,-90,0),{x:-s/2-n,y:n},...ct(s/2+n*2,-n,n,20,-180,-270),...ct(s/2+n*2,n,n,20,-90,-180),{x:-s/2-n,y:-o/2},...ct(s/2,o/2,n,20,0,90)],p=[{x:s/2,y:-o/2-n},{x:-s/2,y:-o/2-n},...ct(s/2,-o/2,n,20,-90,0),{x:-s/2-n,y:-n},...ct(s/2+s*.1,-n,n,20,-180,-270),...ct(s/2+s*.1,n,n,20,-90,-180),{x:-s/2-n,y:o/2},...ct(s/2,o/2,n,20,0,90),{x:-s/2,y:o/2+n},{x:s/2,y:o/2+n}],f=D.svg(e),u=A(t,{fill:"none"});t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let d=V(g).replace("Z",""),m=f.path(d,u),x=V(p),b=f.path(x,at({},u)),S=e.insert("g",":first-child");return S.insert(()=>b,":first-child").attr("stroke-opacity",0),S.insert(()=>m,":first-child"),S.attr("class","text"),l&&t.look!=="handDrawn"&&S.selectAll("path").attr("style",l),a&&t.look!=="handDrawn"&&S.selectAll("path").attr("style",a),S.attr("transform",`translate(${n}, 0)`),h.attr("transform",`translate(${-s/2+n-(i.x-((k=i.left)!=null?k:0))},${-o/2+((v=t.padding)!=null?v:0)/2-(i.y-((P=i.top)!=null?P:0))})`),H(t,S),t.intersect=function(C){return N.polygon(t,p,C)},e}$(Zs,"curlyBraceLeft");function ot(c,t,r,a=100,e=0,i=180){let h=[],s=e*Math.PI/180,l=(i*Math.PI/180-s)/(a-1);for(let g=0;g<a;g++){let p=s+g*l,f=c+r*Math.cos(p),u=t+r*Math.sin(p);h.push({x:f,y:u})}return h}$(ot,"generateCirclePoints");async function Qs(c,t){var w,M,k,v,P,C;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=i.width+((w=t.padding)!=null?w:0),o=i.height+((M=t.padding)!=null?M:0),n=Math.max(5,o*.1),{cssStyles:l}=t,g=[...ot(s/2,-o/2,n,20,-90,0),{x:s/2+n,y:-n},...ot(s/2+n*2,-n,n,20,-180,-270),...ot(s/2+n*2,n,n,20,-90,-180),{x:s/2+n,y:o/2},...ot(s/2,o/2,n,20,0,90)],p=[{x:-s/2,y:-o/2-n},{x:s/2,y:-o/2-n},...ot(s/2,-o/2,n,20,-90,0),{x:s/2+n,y:-n},...ot(s/2+n*2,-n,n,20,-180,-270),...ot(s/2+n*2,n,n,20,-90,-180),{x:s/2+n,y:o/2},...ot(s/2,o/2,n,20,0,90),{x:s/2,y:o/2+n},{x:-s/2,y:o/2+n}],f=D.svg(e),u=A(t,{fill:"none"});t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let d=V(g).replace("Z",""),m=f.path(d,u),x=V(p),b=f.path(x,at({},u)),S=e.insert("g",":first-child");return S.insert(()=>b,":first-child").attr("stroke-opacity",0),S.insert(()=>m,":first-child"),S.attr("class","text"),l&&t.look!=="handDrawn"&&S.selectAll("path").attr("style",l),a&&t.look!=="handDrawn"&&S.selectAll("path").attr("style",a),S.attr("transform",`translate(${-n}, 0)`),h.attr("transform",`translate(${-s/2+((k=t.padding)!=null?k:0)/2-(i.x-((v=i.left)!=null?v:0))},${-o/2+((P=t.padding)!=null?P:0)/2-(i.y-((C=i.top)!=null?C:0))})`),H(t,S),t.intersect=function(B){return N.polygon(t,p,B)},e}$(Qs,"curlyBraceRight");function K(c,t,r,a=100,e=0,i=180){let h=[],s=e*Math.PI/180,l=(i*Math.PI/180-s)/(a-1);for(let g=0;g<a;g++){let p=s+g*l,f=c+r*Math.cos(p),u=t+r*Math.sin(p);h.push({x:-f,y:-u})}return h}$(K,"generateCirclePoints");async function Js(c,t){var P,C,B,X,E,W;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=i.width+((P=t.padding)!=null?P:0),o=i.height+((C=t.padding)!=null?C:0),n=Math.max(5,o*.1),{cssStyles:l}=t,g=[...K(s/2,-o/2,n,30,-90,0),{x:-s/2-n,y:n},...K(s/2+n*2,-n,n,20,-180,-270),...K(s/2+n*2,n,n,20,-90,-180),{x:-s/2-n,y:-o/2},...K(s/2,o/2,n,20,0,90)],p=[...K(-s/2+n+n/2,-o/2,n,20,-90,-180),{x:s/2-n/2,y:n},...K(-s/2-n/2,-n,n,20,0,90),...K(-s/2-n/2,n,n,20,-90,0),{x:s/2-n/2,y:-n},...K(-s/2+n+n/2,o/2,n,30,-180,-270)],f=[{x:s/2,y:-o/2-n},{x:-s/2,y:-o/2-n},...K(s/2,-o/2,n,20,-90,0),{x:-s/2-n,y:-n},...K(s/2+n*2,-n,n,20,-180,-270),...K(s/2+n*2,n,n,20,-90,-180),{x:-s/2-n,y:o/2},...K(s/2,o/2,n,20,0,90),{x:-s/2,y:o/2+n},{x:s/2-n-n/2,y:o/2+n},...K(-s/2+n+n/2,-o/2,n,20,-90,-180),{x:s/2-n/2,y:n},...K(-s/2-n/2,-n,n,20,0,90),...K(-s/2-n/2,n,n,20,-90,0),{x:s/2-n/2,y:-n},...K(-s/2+n+n/2,o/2,n,30,-180,-270)],u=D.svg(e),y=A(t,{fill:"none"});t.look!=="handDrawn"&&(y.roughness=0,y.fillStyle="solid");let m=V(g).replace("Z",""),x=u.path(m,y),S=V(p).replace("Z",""),w=u.path(S,y),M=V(f),k=u.path(M,at({},y)),v=e.insert("g",":first-child");return v.insert(()=>k,":first-child").attr("stroke-opacity",0),v.insert(()=>x,":first-child"),v.insert(()=>w,":first-child"),v.attr("class","text"),l&&t.look!=="handDrawn"&&v.selectAll("path").attr("style",l),a&&t.look!=="handDrawn"&&v.selectAll("path").attr("style",a),v.attr("transform",`translate(${n-n/4}, 0)`),h.attr("transform",`translate(${-s/2+((B=t.padding)!=null?B:0)/2-(i.x-((X=i.left)!=null?X:0))},${-o/2+((E=t.padding)!=null?E:0)/2-(i.y-((W=i.top)!=null?W:0))})`),H(t,v),t.intersect=function(T){return N.polygon(t,f,T)},e}$(Js,"curlyBraces");async function Us(c,t){var M,k,v,P;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=80,s=20,o=Math.max(h,(i.width+((M=t.padding)!=null?M:0)*2)*1.25,(k=t==null?void 0:t.width)!=null?k:0),n=Math.max(s,i.height+((v=t.padding)!=null?v:0)*2,(P=t==null?void 0:t.height)!=null?P:0),l=n/2,{cssStyles:g}=t,p=D.svg(e),f=A(t,{});t.look!=="handDrawn"&&(f.roughness=0,f.fillStyle="solid");let u=o,y=n,d=u-l,m=y/4,x=[{x:d,y:0},{x:m,y:0},{x:0,y:y/2},{x:m,y},{x:d,y},...gs(-d,-y/2,l,50,270,90)],b=V(x),S=p.path(b,f),w=e.insert(()=>S,":first-child");return w.attr("class","basic label-container"),g&&t.look!=="handDrawn"&&w.selectChildren("path").attr("style",g),a&&t.look!=="handDrawn"&&w.selectChildren("path").attr("style",a),w.attr("transform",`translate(${-o/2}, ${-n/2})`),H(t,w),t.intersect=function(C){return N.polygon(t,x,C)},e}$(Us,"curvedTrapezoid");var xa=$((c,t,r,a,e,i)=>[`M${c},${t+i}`,`a${e},${i} 0,0,0 ${r},0`,`a${e},${i} 0,0,0 ${-r},0`,`l0,${a}`,`a${e},${i} 0,0,0 ${r},0`,`l0,${-a}`].join(" "),"createCylinderPathD"),ba=$((c,t,r,a,e,i)=>[`M${c},${t+i}`,`M${c+r},${t+i}`,`a${e},${i} 0,0,0 ${-r},0`,`l0,${a}`,`a${e},${i} 0,0,0 ${r},0`,`l0,${-a}`].join(" "),"createOuterCylinderPathD"),wa=$((c,t,r,a,e,i)=>[`M${c-r/2},${-a/2}`,`a${e},${i} 0,0,0 ${r},0`].join(" "),"createInnerCylinderPathD");async function Ks(c,t){var f,u,y,d,m;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+t.padding,(f=t.width)!=null?f:0),o=s/2,n=o/(2.5+s/50),l=Math.max(i.height+n+t.padding,(u=t.height)!=null?u:0),g,{cssStyles:p}=t;if(t.look==="handDrawn"){let x=D.svg(e),b=ba(0,0,s,l,o,n),S=wa(0,n,s,l,o,n),w=x.path(b,A(t,{})),M=x.path(S,A(t,{fill:"none"}));g=e.insert(()=>M,":first-child"),g=e.insert(()=>w,":first-child"),g.attr("class","basic label-container"),p&&g.attr("style",p)}else{let x=xa(0,0,s,l,o,n);g=e.insert("path",":first-child").attr("d",x).attr("class","basic label-container").attr("style",st(p)).attr("style",a)}return g.attr("label-offset-y",n),g.attr("transform",`translate(${-s/2}, ${-(l/2+n)})`),H(t,g),h.attr("transform",`translate(${-(i.width/2)-(i.x-((y=i.left)!=null?y:0))}, ${-(i.height/2)+((d=t.padding)!=null?d:0)/1.5-(i.y-((m=i.top)!=null?m:0))})`),t.intersect=function(x){var w,M,k,v,P,C;let b=N.rect(t,x),S=b.x-((w=t.x)!=null?w:0);if(o!=0&&(Math.abs(S)<((M=t.width)!=null?M:0)/2||Math.abs(S)==((k=t.width)!=null?k:0)/2&&Math.abs(b.y-((v=t.y)!=null?v:0))>((P=t.height)!=null?P:0)/2-n)){let B=n*n*(1-S*S/(o*o));B>0&&(B=Math.sqrt(B)),B=n-B,x.y-((C=t.y)!=null?C:0)>0&&(B=-B),b.y+=B}return b},e}$(Ks,"cylinder");async function te(c,t){var x,b,S,w;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=i.width+t.padding,o=i.height+t.padding,n=o*.2,l=-s/2,g=-o/2-n/2,{cssStyles:p}=t,f=D.svg(e),u=A(t,{});t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let y=[{x:l,y:g+n},{x:-l,y:g+n},{x:-l,y:-g},{x:l,y:-g},{x:l,y:g},{x:-l,y:g},{x:-l,y:g+n}],d=f.polygon(y.map(M=>[M.x,M.y]),u),m=e.insert(()=>d,":first-child");return m.attr("class","basic label-container"),p&&t.look!=="handDrawn"&&m.selectAll("path").attr("style",p),a&&t.look!=="handDrawn"&&m.selectAll("path").attr("style",a),h.attr("transform",`translate(${l+((x=t.padding)!=null?x:0)/2-(i.x-((b=i.left)!=null?b:0))}, ${g+n+((S=t.padding)!=null?S:0)/2-(i.y-((w=i.top)!=null?w:0))})`),H(t,m),t.intersect=function(M){return N.rect(t,M)},e}$(te,"dividedRectangle");async function se(c,t){var p,f;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,halfPadding:h}=await q(c,t,F(t)),o=i.width/2+h+5,n=i.width/2+h,l,{cssStyles:g}=t;if(t.look==="handDrawn"){let u=D.svg(e),y=A(t,{roughness:.2,strokeWidth:2.5}),d=A(t,{roughness:.2,strokeWidth:1.5}),m=u.circle(0,0,o*2,y),x=u.circle(0,0,n*2,d);l=e.insert("g",":first-child"),l.attr("class",st(t.cssClasses)).attr("style",st(g)),(p=l.node())==null||p.appendChild(m),(f=l.node())==null||f.appendChild(x)}else{l=e.insert("g",":first-child");let u=l.insert("circle",":first-child"),y=l.insert("circle");l.attr("class","basic label-container").attr("style",a),u.attr("class","outer-circle").attr("style",a).attr("r",o).attr("cx",0).attr("cy",0),y.attr("class","inner-circle").attr("style",a).attr("r",n).attr("cx",0).attr("cy",0)}return H(t,l),t.intersect=function(u){return Z.info("DoubleCircle intersect",t,o,u),N.circle(t,o,u)},e}$(se,"doublecircle");function ee(c,t,{config:{themeVariables:r}}){var f;let{labelStyles:a,nodeStyles:e}=I(t);t.label="",t.labelStyle=a;let i=c.insert("g").attr("class",F(t)).attr("id",(f=t.domId)!=null?f:t.id),h=7,{cssStyles:s}=t,o=D.svg(i),{nodeBorder:n}=r,l=A(t,{fillStyle:"solid"});t.look!=="handDrawn"&&(l.roughness=0);let g=o.circle(0,0,h*2,l),p=i.insert(()=>g,":first-child");return p.selectAll("path").attr("style",`fill: ${n} !important;`),s&&s.length>0&&t.look!=="handDrawn"&&p.selectAll("path").attr("style",s),e&&t.look!=="handDrawn"&&p.selectAll("path").attr("style",e),H(t,p),t.intersect=function(u){return Z.info("filledCircle intersect",t,{radius:h,point:u}),N.circle(t,h,u)},i}$(ee,"filledCircle");async function ae(c,t){var m,x,b,S;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=i.width+((m=t.padding)!=null?m:0),o=s+i.height,n=s+i.height,l=[{x:0,y:-o},{x:n,y:-o},{x:n/2,y:0}],{cssStyles:g}=t,p=D.svg(e),f=A(t,{});t.look!=="handDrawn"&&(f.roughness=0,f.fillStyle="solid");let u=V(l),y=p.path(u,f),d=e.insert(()=>y,":first-child").attr("transform",`translate(${-o/2}, ${o/2})`);return g&&t.look!=="handDrawn"&&d.selectChildren("path").attr("style",g),a&&t.look!=="handDrawn"&&d.selectChildren("path").attr("style",a),t.width=s,t.height=o,H(t,d),h.attr("transform",`translate(${-i.width/2-(i.x-((x=i.left)!=null?x:0))}, ${-o/2+((b=t.padding)!=null?b:0)/2+(i.y-((S=i.top)!=null?S:0))})`),t.intersect=function(w){return Z.info("Triangle intersect",t,l,w),N.polygon(t,l,w)},e}$(ae,"flippedTriangle");function re(c,t,{dir:r,config:{state:a,themeVariables:e}}){var m,x,b,S,w,M;let{nodeStyles:i}=I(t);t.label="";let h=c.insert("g").attr("class",F(t)).attr("id",(m=t.domId)!=null?m:t.id),{cssStyles:s}=t,o=Math.max(70,(x=t==null?void 0:t.width)!=null?x:0),n=Math.max(10,(b=t==null?void 0:t.height)!=null?b:0);r==="LR"&&(o=Math.max(10,(S=t==null?void 0:t.width)!=null?S:0),n=Math.max(70,(w=t==null?void 0:t.height)!=null?w:0));let l=-1*o/2,g=-1*n/2,p=D.svg(h),f=A(t,{stroke:e.lineColor,fill:e.lineColor});t.look!=="handDrawn"&&(f.roughness=0,f.fillStyle="solid");let u=p.rectangle(l,g,o,n,f),y=h.insert(()=>u,":first-child");s&&t.look!=="handDrawn"&&y.selectAll("path").attr("style",s),i&&t.look!=="handDrawn"&&y.selectAll("path").attr("style",i),H(t,y);let d=(M=a==null?void 0:a.padding)!=null?M:0;return t.width&&t.height&&(t.width+=d/2||0,t.height+=d/2||0),t.intersect=function(k){return N.rect(t,k)},h}$(re,"forkJoin");async function ie(c,t){var x,b,S,w;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let e=80,i=50,{shapeSvg:h,bbox:s}=await q(c,t,F(t)),o=Math.max(e,s.width+((x=t.padding)!=null?x:0)*2,(b=t==null?void 0:t.width)!=null?b:0),n=Math.max(i,s.height+((S=t.padding)!=null?S:0)*2,(w=t==null?void 0:t.height)!=null?w:0),l=n/2,{cssStyles:g}=t,p=D.svg(h),f=A(t,{});t.look!=="handDrawn"&&(f.roughness=0,f.fillStyle="solid");let u=[{x:-o/2,y:-n/2},{x:o/2-l,y:-n/2},...gs(-o/2+l,0,l,50,90,270),{x:o/2-l,y:n/2},{x:-o/2,y:n/2}],y=V(u),d=p.path(y,f),m=h.insert(()=>d,":first-child");return m.attr("class","basic label-container"),g&&t.look!=="handDrawn"&&m.selectChildren("path").attr("style",g),a&&t.look!=="handDrawn"&&m.selectChildren("path").attr("style",a),H(t,m),t.intersect=function(M){return Z.info("Pill intersect",t,{radius:l,point:M}),N.polygon(t,u,M)},h}$(ie,"halfRoundedRectangle");var Sa=$((c,t,r,a,e)=>[`M${c+e},${t}`,`L${c+r-e},${t}`,`L${c+r},${t-a/2}`,`L${c+r-e},${t-a}`,`L${c+e},${t-a}`,`L${c},${t-a/2}`,"Z"].join(" "),"createHexagonPathD");async function ne(c,t){let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=4,s=i.height+t.padding,o=s/h,n=i.width+2*o+t.padding,l=[{x:o,y:0},{x:n-o,y:0},{x:n,y:-s/2},{x:n-o,y:-s},{x:o,y:-s},{x:0,y:-s/2}],g,{cssStyles:p}=t;if(t.look==="handDrawn"){let f=D.svg(e),u=A(t,{}),y=Sa(0,0,n,s,o),d=f.path(y,u);g=e.insert(()=>d,":first-child").attr("transform",`translate(${-n/2}, ${s/2})`),p&&g.attr("style",p)}else g=gt(e,n,s,l);return a&&g.attr("style",a),t.width=n,t.height=s,H(t,g),t.intersect=function(f){return N.polygon(t,l,f)},e}$(ne,"hexagon");async function le(c,t){var u,y;let{labelStyles:r,nodeStyles:a}=I(t);t.label="",t.labelStyle=r;let{shapeSvg:e}=await q(c,t,F(t)),i=Math.max(30,(u=t==null?void 0:t.width)!=null?u:0),h=Math.max(30,(y=t==null?void 0:t.height)!=null?y:0),{cssStyles:s}=t,o=D.svg(e),n=A(t,{});t.look!=="handDrawn"&&(n.roughness=0,n.fillStyle="solid");let l=[{x:0,y:0},{x:i,y:0},{x:0,y:h},{x:i,y:h}],g=V(l),p=o.path(g,n),f=e.insert(()=>p,":first-child");return f.attr("class","basic label-container"),s&&t.look!=="handDrawn"&&f.selectChildren("path").attr("style",s),a&&t.look!=="handDrawn"&&f.selectChildren("path").attr("style",a),f.attr("transform",`translate(${-i/2}, ${-h/2})`),H(t,f),t.intersect=function(d){return Z.info("Pill intersect",t,{points:l}),N.polygon(t,l,d)},e}$(le,"hourglass");async function ce(c,t,{config:{themeVariables:r,flowchart:a}}){var X,E,W,T;let{labelStyles:e}=I(t);t.labelStyle=e;let i=(X=t.assetHeight)!=null?X:48,h=(E=t.assetWidth)!=null?E:48,s=Math.max(i,h),o=a==null?void 0:a.wrappingWidth;t.width=Math.max(s,o!=null?o:0);let{shapeSvg:n,bbox:l,label:g}=await q(c,t,"icon-shape default"),p=t.pos==="t",f=s,u=s,{nodeBorder:y}=r,{stylesMap:d}=St(t),m=-u/2,x=-f/2,b=t.label?8:0,S=D.svg(n),w=A(t,{stroke:"none",fill:"none"});t.look!=="handDrawn"&&(w.roughness=0,w.fillStyle="solid");let M=S.rectangle(m,x,u,f,w),k=Math.max(u,l.width),v=f+l.height+b,P=S.rectangle(-k/2,-v/2,k,v,nt(at({},w),{fill:"transparent",stroke:"none"})),C=n.insert(()=>M,":first-child"),B=n.insert(()=>P);if(t.icon){let O=n.append("g");O.html(`<g>${await Mt(t.icon,{height:s,width:s,fallbackPrefix:""})}</g>`);let R=O.node().getBBox(),Y=R.width,_=R.height,L=R.x,G=R.y;O.attr("transform",`translate(${-Y/2-L},${p?l.height/2+b/2-_/2-G:-l.height/2-b/2-_/2-G})`),O.attr("style",`color: ${(W=d.get("stroke"))!=null?W:y};`)}return g.attr("transform",`translate(${-l.width/2-(l.x-((T=l.left)!=null?T:0))},${p?-v/2:v/2-l.height})`),C.attr("transform",`translate(0,${p?l.height/2+b/2:-l.height/2-b/2})`),H(t,B),t.intersect=function(O){var z,U,et;if(Z.info("iconSquare intersect",t,O),!t.label)return N.rect(t,O);let R=(z=t.x)!=null?z:0,Y=(U=t.y)!=null?U:0,_=(et=t.height)!=null?et:0,L=[];return p?L=[{x:R-l.width/2,y:Y-_/2},{x:R+l.width/2,y:Y-_/2},{x:R+l.width/2,y:Y-_/2+l.height+b},{x:R+u/2,y:Y-_/2+l.height+b},{x:R+u/2,y:Y+_/2},{x:R-u/2,y:Y+_/2},{x:R-u/2,y:Y-_/2+l.height+b},{x:R-l.width/2,y:Y-_/2+l.height+b}]:L=[{x:R-u/2,y:Y-_/2},{x:R+u/2,y:Y-_/2},{x:R+u/2,y:Y-_/2+f},{x:R+l.width/2,y:Y-_/2+f},{x:R+l.width/2/2,y:Y+_/2},{x:R-l.width/2,y:Y+_/2},{x:R-l.width/2,y:Y-_/2+f},{x:R-u/2,y:Y-_/2+f}],N.polygon(t,L,O)},n}$(ce,"icon");async function oe(c,t,{config:{themeVariables:r,flowchart:a}}){var Y,_,L,G;let{labelStyles:e}=I(t);t.labelStyle=e;let i=(Y=t.assetHeight)!=null?Y:48,h=(_=t.assetWidth)!=null?_:48,s=Math.max(i,h),o=a==null?void 0:a.wrappingWidth;t.width=Math.max(s,o!=null?o:0);let{shapeSvg:n,bbox:l,label:g}=await q(c,t,"icon-shape default"),p=20,f=t.label?8:0,u=t.pos==="t",{nodeBorder:y,mainBkg:d}=r,{stylesMap:m}=St(t),x=D.svg(n),b=A(t,{});t.look!=="handDrawn"&&(b.roughness=0,b.fillStyle="solid");let S=m.get("fill");b.stroke=S!=null?S:d;let w=n.append("g");t.icon&&w.html(`<g>${await Mt(t.icon,{height:s,width:s,fallbackPrefix:""})}</g>`);let M=w.node().getBBox(),k=M.width,v=M.height,P=M.x,C=M.y,B=Math.max(k,v)*Math.SQRT2+p*2,X=x.circle(0,0,B,b),E=Math.max(B,l.width),W=B+l.height+f,T=x.rectangle(-E/2,-W/2,E,W,nt(at({},b),{fill:"transparent",stroke:"none"})),O=n.insert(()=>X,":first-child"),R=n.insert(()=>T);return w.attr("transform",`translate(${-k/2-P},${u?l.height/2+f/2-v/2-C:-l.height/2-f/2-v/2-C})`),w.attr("style",`color: ${(L=m.get("stroke"))!=null?L:y};`),g.attr("transform",`translate(${-l.width/2-(l.x-((G=l.left)!=null?G:0))},${u?-W/2:W/2-l.height})`),O.attr("transform",`translate(0,${u?l.height/2+f/2:-l.height/2-f/2})`),H(t,R),t.intersect=function(z){return Z.info("iconSquare intersect",t,z),N.rect(t,z)},n}$(oe,"iconCircle");async function he(c,t,{config:{themeVariables:r,flowchart:a}}){var T,O,R,Y;let{labelStyles:e}=I(t);t.labelStyle=e;let i=(T=t.assetHeight)!=null?T:48,h=(O=t.assetWidth)!=null?O:48,s=Math.max(i,h),o=a==null?void 0:a.wrappingWidth;t.width=Math.max(s,o!=null?o:0);let{shapeSvg:n,bbox:l,halfPadding:g,label:p}=await q(c,t,"icon-shape default"),f=t.pos==="t",u=s+g*2,y=s+g*2,{nodeBorder:d,mainBkg:m}=r,{stylesMap:x}=St(t),b=-y/2,S=-u/2,w=t.label?8:0,M=D.svg(n),k=A(t,{});t.look!=="handDrawn"&&(k.roughness=0,k.fillStyle="solid");let v=x.get("fill");k.stroke=v!=null?v:m;let P=M.path(ht(b,S,y,u,5),k),C=Math.max(y,l.width),B=u+l.height+w,X=M.rectangle(-C/2,-B/2,C,B,nt(at({},k),{fill:"transparent",stroke:"none"})),E=n.insert(()=>P,":first-child").attr("class","icon-shape2"),W=n.insert(()=>X);if(t.icon){let _=n.append("g");_.html(`<g>${await Mt(t.icon,{height:s,width:s,fallbackPrefix:""})}</g>`);let L=_.node().getBBox(),G=L.width,z=L.height,U=L.x,et=L.y;_.attr("transform",`translate(${-G/2-U},${f?l.height/2+w/2-z/2-et:-l.height/2-w/2-z/2-et})`),_.attr("style",`color: ${(R=x.get("stroke"))!=null?R:d};`)}return p.attr("transform",`translate(${-l.width/2-(l.x-((Y=l.left)!=null?Y:0))},${f?-B/2:B/2-l.height})`),E.attr("transform",`translate(0,${f?l.height/2+w/2:-l.height/2-w/2})`),H(t,W),t.intersect=function(_){var pt,yt,lt;if(Z.info("iconSquare intersect",t,_),!t.label)return N.rect(t,_);let L=(pt=t.x)!=null?pt:0,G=(yt=t.y)!=null?yt:0,z=(lt=t.height)!=null?lt:0,U=[];return f?U=[{x:L-l.width/2,y:G-z/2},{x:L+l.width/2,y:G-z/2},{x:L+l.width/2,y:G-z/2+l.height+w},{x:L+y/2,y:G-z/2+l.height+w},{x:L+y/2,y:G+z/2},{x:L-y/2,y:G+z/2},{x:L-y/2,y:G-z/2+l.height+w},{x:L-l.width/2,y:G-z/2+l.height+w}]:U=[{x:L-y/2,y:G-z/2},{x:L+y/2,y:G-z/2},{x:L+y/2,y:G-z/2+u},{x:L+l.width/2,y:G-z/2+u},{x:L+l.width/2/2,y:G+z/2},{x:L-l.width/2,y:G+z/2},{x:L-l.width/2,y:G-z/2+u},{x:L-y/2,y:G-z/2+u}],N.polygon(t,U,_)},n}$(he,"iconRounded");async function ge(c,t,{config:{themeVariables:r,flowchart:a}}){var T,O,R,Y;let{labelStyles:e}=I(t);t.labelStyle=e;let i=(T=t.assetHeight)!=null?T:48,h=(O=t.assetWidth)!=null?O:48,s=Math.max(i,h),o=a==null?void 0:a.wrappingWidth;t.width=Math.max(s,o!=null?o:0);let{shapeSvg:n,bbox:l,halfPadding:g,label:p}=await q(c,t,"icon-shape default"),f=t.pos==="t",u=s+g*2,y=s+g*2,{nodeBorder:d,mainBkg:m}=r,{stylesMap:x}=St(t),b=-y/2,S=-u/2,w=t.label?8:0,M=D.svg(n),k=A(t,{});t.look!=="handDrawn"&&(k.roughness=0,k.fillStyle="solid");let v=x.get("fill");k.stroke=v!=null?v:m;let P=M.path(ht(b,S,y,u,.1),k),C=Math.max(y,l.width),B=u+l.height+w,X=M.rectangle(-C/2,-B/2,C,B,nt(at({},k),{fill:"transparent",stroke:"none"})),E=n.insert(()=>P,":first-child"),W=n.insert(()=>X);if(t.icon){let _=n.append("g");_.html(`<g>${await Mt(t.icon,{height:s,width:s,fallbackPrefix:""})}</g>`);let L=_.node().getBBox(),G=L.width,z=L.height,U=L.x,et=L.y;_.attr("transform",`translate(${-G/2-U},${f?l.height/2+w/2-z/2-et:-l.height/2-w/2-z/2-et})`),_.attr("style",`color: ${(R=x.get("stroke"))!=null?R:d};`)}return p.attr("transform",`translate(${-l.width/2-(l.x-((Y=l.left)!=null?Y:0))},${f?-B/2:B/2-l.height})`),E.attr("transform",`translate(0,${f?l.height/2+w/2:-l.height/2-w/2})`),H(t,W),t.intersect=function(_){var pt,yt,lt;if(Z.info("iconSquare intersect",t,_),!t.label)return N.rect(t,_);let L=(pt=t.x)!=null?pt:0,G=(yt=t.y)!=null?yt:0,z=(lt=t.height)!=null?lt:0,U=[];return f?U=[{x:L-l.width/2,y:G-z/2},{x:L+l.width/2,y:G-z/2},{x:L+l.width/2,y:G-z/2+l.height+w},{x:L+y/2,y:G-z/2+l.height+w},{x:L+y/2,y:G+z/2},{x:L-y/2,y:G+z/2},{x:L-y/2,y:G-z/2+l.height+w},{x:L-l.width/2,y:G-z/2+l.height+w}]:U=[{x:L-y/2,y:G-z/2},{x:L+y/2,y:G-z/2},{x:L+y/2,y:G-z/2+u},{x:L+l.width/2,y:G-z/2+u},{x:L+l.width/2/2,y:G+z/2},{x:L-l.width/2,y:G+z/2},{x:L-l.width/2,y:G-z/2+u},{x:L-y/2,y:G-z/2+u}],N.polygon(t,U,_)},n}$(ge,"iconSquare");async function pe(c,t,{config:{flowchart:r}}){var C,B,X,E;let a=new Image;a.src=(C=t==null?void 0:t.img)!=null?C:"",await a.decode();let e=Number(a.naturalWidth.toString().replace("px","")),i=Number(a.naturalHeight.toString().replace("px",""));t.imageAspectRatio=e/i;let{labelStyles:h}=I(t);t.labelStyle=h;let s=r==null?void 0:r.wrappingWidth;t.defaultWidth=r==null?void 0:r.wrappingWidth;let o=Math.max(t.label&&s!=null?s:0,(B=t==null?void 0:t.assetWidth)!=null?B:e),n=t.constraint==="on"&&t!=null&&t.assetHeight?t.assetHeight*t.imageAspectRatio:o,l=t.constraint==="on"?n/t.imageAspectRatio:(X=t==null?void 0:t.assetHeight)!=null?X:i;t.width=Math.max(n,s!=null?s:0);let{shapeSvg:g,bbox:p,label:f}=await q(c,t,"image-shape default"),u=t.pos==="t",y=-n/2,d=-l/2,m=t.label?8:0,x=D.svg(g),b=A(t,{});t.look!=="handDrawn"&&(b.roughness=0,b.fillStyle="solid");let S=x.rectangle(y,d,n,l,b),w=Math.max(n,p.width),M=l+p.height+m,k=x.rectangle(-w/2,-M/2,w,M,nt(at({},b),{fill:"none",stroke:"none"})),v=g.insert(()=>S,":first-child"),P=g.insert(()=>k);if(t.img){let W=g.append("image");W.attr("href",t.img),W.attr("width",n),W.attr("height",l),W.attr("preserveAspectRatio","none"),W.attr("transform",`translate(${-n/2},${u?M/2-l:-M/2})`)}return f.attr("transform",`translate(${-p.width/2-(p.x-((E=p.left)!=null?E:0))},${u?-l/2-p.height/2-m/2:l/2-p.height/2+m/2})`),v.attr("transform",`translate(0,${u?p.height/2+m/2:-p.height/2-m/2})`),H(t,P),t.intersect=function(W){var L,G,z;if(Z.info("iconSquare intersect",t,W),!t.label)return N.rect(t,W);let T=(L=t.x)!=null?L:0,O=(G=t.y)!=null?G:0,R=(z=t.height)!=null?z:0,Y=[];return u?Y=[{x:T-p.width/2,y:O-R/2},{x:T+p.width/2,y:O-R/2},{x:T+p.width/2,y:O-R/2+p.height+m},{x:T+n/2,y:O-R/2+p.height+m},{x:T+n/2,y:O+R/2},{x:T-n/2,y:O+R/2},{x:T-n/2,y:O-R/2+p.height+m},{x:T-p.width/2,y:O-R/2+p.height+m}]:Y=[{x:T-n/2,y:O-R/2},{x:T+n/2,y:O-R/2},{x:T+n/2,y:O-R/2+l},{x:T+p.width/2,y:O-R/2+l},{x:T+p.width/2/2,y:O+R/2},{x:T-p.width/2,y:O+R/2},{x:T-p.width/2,y:O-R/2+l},{x:T-n/2,y:O-R/2+l}],N.polygon(t,Y,W)},g}$(pe,"imageSquare");async function fe(c,t){var g,p,f,u;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=Math.max(i.width+((g=t.padding)!=null?g:0)*2,(p=t==null?void 0:t.width)!=null?p:0),s=Math.max(i.height+((f=t.padding)!=null?f:0)*2,(u=t==null?void 0:t.height)!=null?u:0),o=[{x:0,y:0},{x:h,y:0},{x:h+3*s/6,y:-s},{x:-3*s/6,y:-s}],n,{cssStyles:l}=t;if(t.look==="handDrawn"){let y=D.svg(e),d=A(t,{}),m=V(o),x=y.path(m,d);n=e.insert(()=>x,":first-child").attr("transform",`translate(${-h/2}, ${s/2})`),l&&n.attr("style",l)}else n=gt(e,h,s,o);return a&&n.attr("style",a),t.width=h,t.height=s,H(t,n),t.intersect=function(y){return N.polygon(t,o,y)},e}$(fe,"inv_trapezoid");async function Et(c,t,r){let{labelStyles:a,nodeStyles:e}=I(t);t.labelStyle=a;let{shapeSvg:i,bbox:h}=await q(c,t,F(t)),s=Math.max(h.width+r.labelPaddingX*2,(t==null?void 0:t.width)||0),o=Math.max(h.height+r.labelPaddingY*2,(t==null?void 0:t.height)||0),n=-s/2,l=-o/2,g,{rx:p,ry:f}=t,{cssStyles:u}=t;if(r!=null&&r.rx&&r.ry&&(p=r.rx,f=r.ry),t.look==="handDrawn"){let y=D.svg(i),d=A(t,{}),m=p||f?y.path(ht(n,l,s,o,p||0),d):y.rectangle(n,l,s,o,d);g=i.insert(()=>m,":first-child"),g.attr("class","basic label-container").attr("style",st(u))}else g=i.insert("rect",":first-child"),g.attr("class","basic label-container").attr("style",e).attr("rx",st(p)).attr("ry",st(f)).attr("x",n).attr("y",l).attr("width",s).attr("height",o);return H(t,g),t.intersect=function(y){return N.rect(t,y)},i}$(Et,"drawRect");async function ue(c,t){var o,n;let{shapeSvg:r,bbox:a,label:e}=await q(c,t,"label"),i=r.insert("rect",":first-child");return i.attr("width",.1).attr("height",.1),r.attr("class","label edgeLabel"),e.attr("transform",`translate(${-(a.width/2)-(a.x-((o=a.left)!=null?o:0))}, ${-(a.height/2)-(a.y-((n=a.top)!=null?n:0))})`),H(t,i),t.intersect=function(l){return N.rect(t,l)},r}$(ue,"labelRect");async function ye(c,t){var g,p,f,u;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=Math.max(i.width+((g=t.padding)!=null?g:0),(p=t==null?void 0:t.width)!=null?p:0),s=Math.max(i.height+((f=t.padding)!=null?f:0),(u=t==null?void 0:t.height)!=null?u:0),o=[{x:0,y:0},{x:h+3*s/6,y:0},{x:h,y:-s},{x:-(3*s)/6,y:-s}],n,{cssStyles:l}=t;if(t.look==="handDrawn"){let y=D.svg(e),d=A(t,{}),m=V(o),x=y.path(m,d);n=e.insert(()=>x,":first-child").attr("transform",`translate(${-h/2}, ${s/2})`),l&&n.attr("style",l)}else n=gt(e,h,s,o);return a&&n.attr("style",a),t.width=h,t.height=s,H(t,n),t.intersect=function(y){return N.polygon(t,o,y)},e}$(ye,"lean_left");async function me(c,t){var g,p,f,u;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=Math.max(i.width+((g=t.padding)!=null?g:0),(p=t==null?void 0:t.width)!=null?p:0),s=Math.max(i.height+((f=t.padding)!=null?f:0),(u=t==null?void 0:t.height)!=null?u:0),o=[{x:-3*s/6,y:0},{x:h,y:0},{x:h+3*s/6,y:-s},{x:0,y:-s}],n,{cssStyles:l}=t;if(t.look==="handDrawn"){let y=D.svg(e),d=A(t,{}),m=V(o),x=y.path(m,d);n=e.insert(()=>x,":first-child").attr("transform",`translate(${-h/2}, ${s/2})`),l&&n.attr("style",l)}else n=gt(e,h,s,o);return a&&n.attr("style",a),t.width=h,t.height=s,H(t,n),t.intersect=function(y){return N.polygon(t,o,y)},e}$(me,"lean_right");function de(c,t){var y,d,m;let{labelStyles:r,nodeStyles:a}=I(t);t.label="",t.labelStyle=r;let e=c.insert("g").attr("class",F(t)).attr("id",(y=t.domId)!=null?y:t.id),{cssStyles:i}=t,h=Math.max(35,(d=t==null?void 0:t.width)!=null?d:0),s=Math.max(35,(m=t==null?void 0:t.height)!=null?m:0),o=7,n=[{x:h,y:0},{x:0,y:s+o/2},{x:h-2*o,y:s+o/2},{x:0,y:2*s},{x:h,y:s-o/2},{x:2*o,y:s-o/2}],l=D.svg(e),g=A(t,{});t.look!=="handDrawn"&&(g.roughness=0,g.fillStyle="solid");let p=V(n),f=l.path(p,g),u=e.insert(()=>f,":first-child");return i&&t.look!=="handDrawn"&&u.selectAll("path").attr("style",i),a&&t.look!=="handDrawn"&&u.selectAll("path").attr("style",a),u.attr("transform",`translate(-${h/2},${-s})`),H(t,u),t.intersect=function(x){return Z.info("lightningBolt intersect",t,x),N.polygon(t,n,x)},e}$(de,"lightningBolt");var Ma=$((c,t,r,a,e,i,h)=>[`M${c},${t+i}`,`a${e},${i} 0,0,0 ${r},0`,`a${e},${i} 0,0,0 ${-r},0`,`l0,${a}`,`a${e},${i} 0,0,0 ${r},0`,`l0,${-a}`,`M${c},${t+i+h}`,`a${e},${i} 0,0,0 ${r},0`].join(" "),"createCylinderPathD"),ka=$((c,t,r,a,e,i,h)=>[`M${c},${t+i}`,`M${c+r},${t+i}`,`a${e},${i} 0,0,0 ${-r},0`,`l0,${a}`,`a${e},${i} 0,0,0 ${r},0`,`l0,${-a}`,`M${c},${t+i+h}`,`a${e},${i} 0,0,0 ${r},0`].join(" "),"createOuterCylinderPathD"),va=$((c,t,r,a,e,i)=>[`M${c-r/2},${-a/2}`,`a${e},${i} 0,0,0 ${r},0`].join(" "),"createInnerCylinderPathD");async function xe(c,t){var u,y,d,m,x,b;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+((u=t.padding)!=null?u:0),(y=t.width)!=null?y:0),o=s/2,n=o/(2.5+s/50),l=Math.max(i.height+n+((d=t.padding)!=null?d:0),(m=t.height)!=null?m:0),g=l*.1,p,{cssStyles:f}=t;if(t.look==="handDrawn"){let S=D.svg(e),w=ka(0,0,s,l,o,n,g),M=va(0,n,s,l,o,n),k=A(t,{}),v=S.path(w,k),P=S.path(M,k);e.insert(()=>P,":first-child").attr("class","line"),p=e.insert(()=>v,":first-child"),p.attr("class","basic label-container"),f&&p.attr("style",f)}else{let S=Ma(0,0,s,l,o,n,g);p=e.insert("path",":first-child").attr("d",S).attr("class","basic label-container").attr("style",st(f)).attr("style",a)}return p.attr("label-offset-y",n),p.attr("transform",`translate(${-s/2}, ${-(l/2+n)})`),H(t,p),h.attr("transform",`translate(${-(i.width/2)-(i.x-((x=i.left)!=null?x:0))}, ${-(i.height/2)+n-(i.y-((b=i.top)!=null?b:0))})`),t.intersect=function(S){var k,v,P,C,B,X;let w=N.rect(t,S),M=w.x-((k=t.x)!=null?k:0);if(o!=0&&(Math.abs(M)<((v=t.width)!=null?v:0)/2||Math.abs(M)==((P=t.width)!=null?P:0)/2&&Math.abs(w.y-((C=t.y)!=null?C:0))>((B=t.height)!=null?B:0)/2-n)){let E=n*n*(1-M*M/(o*o));E>0&&(E=Math.sqrt(E)),E=n-E,S.y-((X=t.y)!=null?X:0)>0&&(E=-E),w.y+=E}return w},e}$(xe,"linedCylinder");async function be(c,t){var m,x,b,S,w,M,k,v;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+((m=t.padding)!=null?m:0)*2,(x=t==null?void 0:t.width)!=null?x:0),o=Math.max(i.height+((b=t.padding)!=null?b:0)*2,(S=t==null?void 0:t.height)!=null?S:0),n=o/4,l=o+n,{cssStyles:g}=t,p=D.svg(e),f=A(t,{});t.look!=="handDrawn"&&(f.roughness=0,f.fillStyle="solid");let u=[{x:-s/2-s/2*.1,y:-l/2},{x:-s/2-s/2*.1,y:l/2},...ut(-s/2-s/2*.1,l/2,s/2+s/2*.1,l/2,n,.8),{x:s/2+s/2*.1,y:-l/2},{x:-s/2-s/2*.1,y:-l/2},{x:-s/2,y:-l/2},{x:-s/2,y:l/2*1.1},{x:-s/2,y:-l/2}],y=p.polygon(u.map(P=>[P.x,P.y]),f),d=e.insert(()=>y,":first-child");return d.attr("class","basic label-container"),g&&t.look!=="handDrawn"&&d.selectAll("path").attr("style",g),a&&t.look!=="handDrawn"&&d.selectAll("path").attr("style",a),d.attr("transform",`translate(0,${-n/2})`),h.attr("transform",`translate(${-s/2+((w=t.padding)!=null?w:0)+s/2*.1/2-(i.x-((M=i.left)!=null?M:0))},${-o/2+((k=t.padding)!=null?k:0)-n/2-(i.y-((v=i.top)!=null?v:0))})`),H(t,d),t.intersect=function(P){return N.polygon(t,u,P)},e}$(be,"linedWaveEdgedRect");async function we(c,t){var M,k,v,P,C,B;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+((M=t.padding)!=null?M:0)*2,(k=t==null?void 0:t.width)!=null?k:0),o=Math.max(i.height+((v=t.padding)!=null?v:0)*2,(P=t==null?void 0:t.height)!=null?P:0),n=5,l=-s/2,g=-o/2,{cssStyles:p}=t,f=D.svg(e),u=A(t,{}),y=[{x:l-n,y:g+n},{x:l-n,y:g+o+n},{x:l+s-n,y:g+o+n},{x:l+s-n,y:g+o},{x:l+s,y:g+o},{x:l+s,y:g+o-n},{x:l+s+n,y:g+o-n},{x:l+s+n,y:g-n},{x:l+n,y:g-n},{x:l+n,y:g},{x:l,y:g},{x:l,y:g+n}],d=[{x:l,y:g+n},{x:l+s-n,y:g+n},{x:l+s-n,y:g+o},{x:l+s,y:g+o},{x:l+s,y:g},{x:l,y:g}];t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let m=V(y),x=f.path(m,u),b=V(d),S=f.path(b,nt(at({},u),{fill:"none"})),w=e.insert(()=>S,":first-child");return w.insert(()=>x,":first-child"),w.attr("class","basic label-container"),p&&t.look!=="handDrawn"&&w.selectAll("path").attr("style",p),a&&t.look!=="handDrawn"&&w.selectAll("path").attr("style",a),h.attr("transform",`translate(${-(i.width/2)-n-(i.x-((C=i.left)!=null?C:0))}, ${-(i.height/2)+n-(i.y-((B=i.top)!=null?B:0))})`),H(t,w),t.intersect=function(X){return N.polygon(t,y,X)},e}$(we,"multiRect");async function Se(c,t){var C,B,X,E,W,T;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+((C=t.padding)!=null?C:0)*2,(B=t==null?void 0:t.width)!=null?B:0),o=Math.max(i.height+((X=t.padding)!=null?X:0)*2,(E=t==null?void 0:t.height)!=null?E:0),n=o/4,l=o+n,g=-s/2,p=-l/2,f=5,{cssStyles:u}=t,y=ut(g-f,p+l+f,g+s-f,p+l+f,n,.8),d=y==null?void 0:y[y.length-1],m=[{x:g-f,y:p+f},{x:g-f,y:p+l+f},...y,{x:g+s-f,y:d.y-f},{x:g+s,y:d.y-f},{x:g+s,y:d.y-2*f},{x:g+s+f,y:d.y-2*f},{x:g+s+f,y:p-f},{x:g+f,y:p-f},{x:g+f,y:p},{x:g,y:p},{x:g,y:p+f}],x=[{x:g,y:p+f},{x:g+s-f,y:p+f},{x:g+s-f,y:d.y-f},{x:g+s,y:d.y-f},{x:g+s,y:p},{x:g,y:p}],b=D.svg(e),S=A(t,{});t.look!=="handDrawn"&&(S.roughness=0,S.fillStyle="solid");let w=V(m),M=b.path(w,S),k=V(x),v=b.path(k,S),P=e.insert(()=>M,":first-child");return P.insert(()=>v),P.attr("class","basic label-container"),u&&t.look!=="handDrawn"&&P.selectAll("path").attr("style",u),a&&t.look!=="handDrawn"&&P.selectAll("path").attr("style",a),P.attr("transform",`translate(0,${-n/2})`),h.attr("transform",`translate(${-(i.width/2)-f-(i.x-((W=i.left)!=null?W:0))}, ${-(i.height/2)+f-n/2-(i.y-((T=i.top)!=null?T:0))})`),H(t,P),t.intersect=function(O){return N.polygon(t,m,O)},e}$(Se,"multiWaveEdgedRectangle");async function Me(c,t,{config:{themeVariables:r}}){var m,x,b,S,w;let{labelStyles:a,nodeStyles:e}=I(t);t.labelStyle=a,t.useHtmlLabels||((m=_t().flowchart)==null?void 0:m.htmlLabels)!==!1||(t.centerLabel=!0);let{shapeSvg:h,bbox:s}=await q(c,t,F(t)),o=Math.max(s.width+((x=t.padding)!=null?x:0)*2,(b=t==null?void 0:t.width)!=null?b:0),n=Math.max(s.height+((S=t.padding)!=null?S:0)*2,(w=t==null?void 0:t.height)!=null?w:0),l=-o/2,g=-n/2,{cssStyles:p}=t,f=D.svg(h),u=A(t,{fill:r.noteBkgColor,stroke:r.noteBorderColor});t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let y=f.rectangle(l,g,o,n,u),d=h.insert(()=>y,":first-child");return d.attr("class","basic label-container"),p&&t.look!=="handDrawn"&&d.selectAll("path").attr("style",p),e&&t.look!=="handDrawn"&&d.selectAll("path").attr("style",e),H(t,d),t.intersect=function(M){return N.rect(t,M)},h}$(Me,"note");var $a=$((c,t,r)=>[`M${c+r/2},${t}`,`L${c+r},${t-r/2}`,`L${c+r/2},${t-r}`,`L${c},${t-r/2}`,"Z"].join(" "),"createDecisionBoxPathD");async function ke(c,t){let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=i.width+t.padding,s=i.height+t.padding,o=h+s,n=[{x:o/2,y:0},{x:o,y:-o/2},{x:o/2,y:-o},{x:0,y:-o/2}],l,{cssStyles:g}=t;if(t.look==="handDrawn"){let p=D.svg(e),f=A(t,{}),u=$a(0,0,o),y=p.path(u,f);l=e.insert(()=>y,":first-child").attr("transform",`translate(${-o/2}, ${o/2})`),g&&l.attr("style",g)}else l=gt(e,o,o,n);return a&&l.attr("style",a),H(t,l),t.intersect=function(p){return Z.debug(`APA12 Intersect called SPLIT
point:`,p,`
node:
`,t,`
res:`,N.polygon(t,n,p)),N.polygon(t,n,p)},e}$(ke,"question");async function ve(c,t){var b,S,w,M,k,v;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+((b=t.padding)!=null?b:0),(S=t==null?void 0:t.width)!=null?S:0),o=Math.max(i.height+((w=t.padding)!=null?w:0),(M=t==null?void 0:t.height)!=null?M:0),n=-s/2,l=-o/2,g=l/2,p=[{x:n+g,y:l},{x:n,y:0},{x:n+g,y:-l},{x:-n,y:-l},{x:-n,y:l}],{cssStyles:f}=t,u=D.svg(e),y=A(t,{});t.look!=="handDrawn"&&(y.roughness=0,y.fillStyle="solid");let d=V(p),m=u.path(d,y),x=e.insert(()=>m,":first-child");return x.attr("class","basic label-container"),f&&t.look!=="handDrawn"&&x.selectAll("path").attr("style",f),a&&t.look!=="handDrawn"&&x.selectAll("path").attr("style",a),x.attr("transform",`translate(${-g/2},0)`),h.attr("transform",`translate(${-g/2-i.width/2-(i.x-((k=i.left)!=null?k:0))}, ${-(i.height/2)-(i.y-((v=i.top)!=null?v:0))})`),H(t,x),t.intersect=function(P){return N.polygon(t,p,P)},e}$(ve,"rect_left_inv_arrow");async function $e(c,t){var v,P;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let e;t.cssClasses?e="node "+t.cssClasses:e="node default";let i=c.insert("g").attr("class",e).attr("id",t.domId||t.id),h=i.insert("g"),s=i.insert("g").attr("class","label").attr("style",a),o=t.description,n=t.label,l=s.node().appendChild(await cs(n,t.labelStyle,!0,!0)),g={width:0,height:0};if(tt((P=(v=Q())==null?void 0:v.flowchart)==null?void 0:P.htmlLabels)){let C=l.children[0],B=J(l);g=C.getBoundingClientRect(),B.attr("width",g.width),B.attr("height",g.height)}Z.info("Text 2",o);let p=o||[],f=l.getBBox(),u=s.node().appendChild(await cs(p.join?p.join("<br/>"):p,t.labelStyle,!0,!0)),y=u.children[0],d=J(u);g=y.getBoundingClientRect(),d.attr("width",g.width),d.attr("height",g.height);let m=(t.padding||0)/2;J(u).attr("transform","translate( "+(g.width>f.width?0:(f.width-g.width)/2)+", "+(f.height+m+5)+")"),J(l).attr("transform","translate( "+(g.width<f.width?0:-(f.width-g.width)/2)+", 0)"),g=s.node().getBBox(),s.attr("transform","translate("+-g.width/2+", "+(-g.height/2-m+3)+")");let x=g.width+(t.padding||0),b=g.height+(t.padding||0),S=-g.width/2-m,w=-g.height/2-m,M,k;if(t.look==="handDrawn"){let C=D.svg(i),B=A(t,{}),X=C.path(ht(S,w,x,b,t.rx||0),B),E=C.line(-g.width/2-m,-g.height/2-m+f.height+m,g.width/2+m,-g.height/2-m+f.height+m,B);k=i.insert(()=>(Z.debug("Rough node insert CXC",X),E),":first-child"),M=i.insert(()=>(Z.debug("Rough node insert CXC",X),X),":first-child")}else M=h.insert("rect",":first-child"),k=h.insert("line"),M.attr("class","outer title-state").attr("style",a).attr("x",-g.width/2-m).attr("y",-g.height/2-m).attr("width",g.width+(t.padding||0)).attr("height",g.height+(t.padding||0)),k.attr("class","divider").attr("x1",-g.width/2-m).attr("x2",g.width/2+m).attr("y1",-g.height/2-m+f.height+m).attr("y2",-g.height/2-m+f.height+m);return H(t,M),t.intersect=function(C){return N.rect(t,C)},i}$($e,"rectWithTitle");async function De(c,t){let r={rx:5,ry:5,classes:"",labelPaddingX:((t==null?void 0:t.padding)||0)*1,labelPaddingY:((t==null?void 0:t.padding)||0)*1};return Et(c,t,r)}$(De,"roundedRect");async function Pe(c,t){var x,b,S,w,M,k,v,P,C;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=(x=t==null?void 0:t.padding)!=null?x:0,o=Math.max(i.width+((b=t.padding)!=null?b:0)*2,(S=t==null?void 0:t.width)!=null?S:0),n=Math.max(i.height+((w=t.padding)!=null?w:0)*2,(M=t==null?void 0:t.height)!=null?M:0),l=-i.width/2-s,g=-i.height/2-s,{cssStyles:p}=t,f=D.svg(e),u=A(t,{});t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let y=[{x:l,y:g},{x:l+o+8,y:g},{x:l+o+8,y:g+n},{x:l-8,y:g+n},{x:l-8,y:g},{x:l,y:g},{x:l,y:g+n}],d=f.polygon(y.map(B=>[B.x,B.y]),u),m=e.insert(()=>d,":first-child");return m.attr("class","basic label-container").attr("style",st(p)),a&&t.look!=="handDrawn"&&m.selectAll("path").attr("style",a),p&&t.look!=="handDrawn"&&m.selectAll("path").attr("style",a),h.attr("transform",`translate(${-o/2+4+((k=t.padding)!=null?k:0)-(i.x-((v=i.left)!=null?v:0))},${-n/2+((P=t.padding)!=null?P:0)-(i.y-((C=i.top)!=null?C:0))})`),H(t,m),t.intersect=function(B){return N.rect(t,B)},e}$(Pe,"shadedProcess");async function Ce(c,t){var x,b,S,w,M,k,v,P;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+((x=t.padding)!=null?x:0)*2,(b=t==null?void 0:t.width)!=null?b:0),o=Math.max(i.height+((S=t.padding)!=null?S:0)*2,(w=t==null?void 0:t.height)!=null?w:0),n=-s/2,l=-o/2,{cssStyles:g}=t,p=D.svg(e),f=A(t,{});t.look!=="handDrawn"&&(f.roughness=0,f.fillStyle="solid");let u=[{x:n,y:l},{x:n,y:l+o},{x:n+s,y:l+o},{x:n+s,y:l-o/2}],y=V(u),d=p.path(y,f),m=e.insert(()=>d,":first-child");return m.attr("class","basic label-container"),g&&t.look!=="handDrawn"&&m.selectChildren("path").attr("style",g),a&&t.look!=="handDrawn"&&m.selectChildren("path").attr("style",a),m.attr("transform",`translate(0, ${o/4})`),h.attr("transform",`translate(${-s/2+((M=t.padding)!=null?M:0)-(i.x-((k=i.left)!=null?k:0))}, ${-o/4+((v=t.padding)!=null?v:0)-(i.y-((P=i.top)!=null?P:0))})`),H(t,m),t.intersect=function(C){return N.polygon(t,u,C)},e}$(Ce,"slopedRect");async function Be(c,t){let r={rx:0,ry:0,classes:"",labelPaddingX:((t==null?void 0:t.padding)||0)*2,labelPaddingY:((t==null?void 0:t.padding)||0)*1};return Et(c,t,r)}$(Be,"squareRect");async function Re(c,t){let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=i.height+t.padding,s=i.width+h/4+t.padding,o,{cssStyles:n}=t;if(t.look==="handDrawn"){let l=D.svg(e),g=A(t,{}),p=ht(-s/2,-h/2,s,h,h/2),f=l.path(p,g);o=e.insert(()=>f,":first-child"),o.attr("class","basic label-container").attr("style",st(n))}else o=e.insert("rect",":first-child"),o.attr("class","basic label-container").attr("style",a).attr("rx",h/2).attr("ry",h/2).attr("x",-s/2).attr("y",-h/2).attr("width",s).attr("height",h);return H(t,o),t.intersect=function(l){return N.rect(t,l)},e}$(Re,"stadium");async function Le(c,t){return Et(c,t,{rx:5,ry:5,classes:"flowchart-node"})}$(Le,"state");function Ne(c,t,{config:{themeVariables:r}}){let{labelStyles:a,nodeStyles:e}=I(t);t.labelStyle=a;let{cssStyles:i}=t,{lineColor:h,stateBorder:s,nodeBorder:o}=r,n=c.insert("g").attr("class","node default").attr("id",t.domId||t.id),l=D.svg(n),g=A(t,{});t.look!=="handDrawn"&&(g.roughness=0,g.fillStyle="solid");let p=l.circle(0,0,14,nt(at({},g),{stroke:h,strokeWidth:2})),f=s!=null?s:o,u=l.circle(0,0,5,nt(at({},g),{fill:f,stroke:f,strokeWidth:2,fillStyle:"solid"})),y=n.insert(()=>p,":first-child");return y.insert(()=>u),i&&y.selectAll("path").attr("style",i),e&&y.selectAll("path").attr("style",e),H(t,y),t.intersect=function(d){return N.circle(t,7,d)},n}$(Ne,"stateEnd");function Ae(c,t,{config:{themeVariables:r}}){let{lineColor:a}=r,e=c.insert("g").attr("class","node default").attr("id",t.domId||t.id),i;if(t.look==="handDrawn"){let s=D.svg(e).circle(0,0,14,na(a));i=e.insert(()=>s),i.attr("class","state-start").attr("r",7).attr("width",14).attr("height",14)}else i=e.insert("circle",":first-child"),i.attr("class","state-start").attr("r",7).attr("width",14).attr("height",14);return H(t,i),t.intersect=function(h){return N.circle(t,7,h)},e}$(Ae,"stateStart");async function Te(c,t){let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=((t==null?void 0:t.padding)||0)/2,s=i.width+t.padding,o=i.height+t.padding,n=-i.width/2-h,l=-i.height/2-h,g=[{x:0,y:0},{x:s,y:0},{x:s,y:-o},{x:0,y:-o},{x:0,y:0},{x:-8,y:0},{x:s+8,y:0},{x:s+8,y:-o},{x:-8,y:-o},{x:-8,y:0}];if(t.look==="handDrawn"){let p=D.svg(e),f=A(t,{}),u=p.rectangle(n-8,l,s+16,o,f),y=p.line(n,l,n,l+o,f),d=p.line(n+s,l,n+s,l+o,f);e.insert(()=>y,":first-child"),e.insert(()=>d,":first-child");let m=e.insert(()=>u,":first-child"),{cssStyles:x}=t;m.attr("class","basic label-container").attr("style",st(x)),H(t,m)}else{let p=gt(e,s,o,g);a&&p.attr("style",a),H(t,p)}return t.intersect=function(p){return N.polygon(t,g,p)},e}$(Te,"subroutine");async function We(c,t){var M,k,v,P;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=Math.max(i.width+((M=t.padding)!=null?M:0)*2,(k=t==null?void 0:t.width)!=null?k:0),s=Math.max(i.height+((v=t.padding)!=null?v:0)*2,(P=t==null?void 0:t.height)!=null?P:0),o=-h/2,n=-s/2,l=.2*s,g=.2*s,{cssStyles:p}=t,f=D.svg(e),u=A(t,{}),y=[{x:o-l/2,y:n},{x:o+h+l/2,y:n},{x:o+h+l/2,y:n+s},{x:o-l/2,y:n+s}],d=[{x:o+h-l/2,y:n+s},{x:o+h+l/2,y:n+s},{x:o+h+l/2,y:n+s-g}];t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let m=V(y),x=f.path(m,u),b=V(d),S=f.path(b,nt(at({},u),{fillStyle:"solid"})),w=e.insert(()=>S,":first-child");return w.insert(()=>x,":first-child"),w.attr("class","basic label-container"),p&&t.look!=="handDrawn"&&w.selectAll("path").attr("style",p),a&&t.look!=="handDrawn"&&w.selectAll("path").attr("style",a),H(t,w),t.intersect=function(C){return N.polygon(t,y,C)},e}$(We,"taggedRect");async function He(c,t){var P,C,B,X,E,W,T,O;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+((P=t.padding)!=null?P:0)*2,(C=t==null?void 0:t.width)!=null?C:0),o=Math.max(i.height+((B=t.padding)!=null?B:0)*2,(X=t==null?void 0:t.height)!=null?X:0),n=o/4,l=.2*s,g=.2*o,p=o+n,{cssStyles:f}=t,u=D.svg(e),y=A(t,{});t.look!=="handDrawn"&&(y.roughness=0,y.fillStyle="solid");let d=[{x:-s/2-s/2*.1,y:p/2},...ut(-s/2-s/2*.1,p/2,s/2+s/2*.1,p/2,n,.8),{x:s/2+s/2*.1,y:-p/2},{x:-s/2-s/2*.1,y:-p/2}],m=-s/2+s/2*.1,x=-p/2-g*.4,b=[{x:m+s-l,y:(x+o)*1.4},{x:m+s,y:x+o-g},{x:m+s,y:(x+o)*.9},...ut(m+s,(x+o)*1.3,m+s-l,(x+o)*1.5,-o*.03,.5)],S=V(d),w=u.path(S,y),M=V(b),k=u.path(M,nt(at({},y),{fillStyle:"solid"})),v=e.insert(()=>k,":first-child");return v.insert(()=>w,":first-child"),v.attr("class","basic label-container"),f&&t.look!=="handDrawn"&&v.selectAll("path").attr("style",f),a&&t.look!=="handDrawn"&&v.selectAll("path").attr("style",a),v.attr("transform",`translate(0,${-n/2})`),h.attr("transform",`translate(${-s/2+((E=t.padding)!=null?E:0)-(i.x-((W=i.left)!=null?W:0))},${-o/2+((T=t.padding)!=null?T:0)-n/2-(i.y-((O=i.top)!=null?O:0))})`),H(t,v),t.intersect=function(R){return N.polygon(t,d,R)},e}$(He,"taggedWaveEdgedRectangle");async function Ie(c,t){let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=Math.max(i.width+t.padding,(t==null?void 0:t.width)||0),s=Math.max(i.height+t.padding,(t==null?void 0:t.height)||0),o=-h/2,n=-s/2,l=e.insert("rect",":first-child");return l.attr("class","text").attr("style",a).attr("rx",0).attr("ry",0).attr("x",o).attr("y",n).attr("width",h).attr("height",s),H(t,l),t.intersect=function(g){return N.rect(t,g)},e}$(Ie,"text");var Da=$((c,t,r,a,e,i)=>`M${c},${t}
a${e},${i} 0,0,1 0,${-a}
l${r},0
a${e},${i} 0,0,1 0,${a}
M${r},${-a}
a${e},${i} 0,0,0 0,${a}
l${-r},0`,"createCylinderPathD"),Pa=$((c,t,r,a,e,i)=>[`M${c},${t}`,`M${c+r},${t}`,`a${e},${i} 0,0,0 0,${-a}`,`l${-r},0`,`a${e},${i} 0,0,0 0,${a}`,`l${r},0`].join(" "),"createOuterCylinderPathD"),Ca=$((c,t,r,a,e,i)=>[`M${c+r/2},${-a/2}`,`a${e},${i} 0,0,0 0,${a}`].join(" "),"createInnerCylinderPathD");async function Ee(c,t){var y,d;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h,halfPadding:s}=await q(c,t,F(t)),o=t.look==="neo"?s*2:s,n=i.height+o,l=n/2,g=l/(2.5+n/50),p=i.width+g+o,{cssStyles:f}=t,u;if(t.look==="handDrawn"){let m=D.svg(e),x=Pa(0,0,p,n,g,l),b=Ca(0,0,p,n,g,l),S=m.path(x,A(t,{})),w=m.path(b,A(t,{fill:"none"}));u=e.insert(()=>w,":first-child"),u=e.insert(()=>S,":first-child"),u.attr("class","basic label-container"),f&&u.attr("style",f)}else{let m=Da(0,0,p,n,g,l);u=e.insert("path",":first-child").attr("d",m).attr("class","basic label-container").attr("style",st(f)).attr("style",a),u.attr("class","basic label-container"),f&&u.selectAll("path").attr("style",f),a&&u.selectAll("path").attr("style",a)}return u.attr("label-offset-x",g),u.attr("transform",`translate(${-p/2}, ${n/2} )`),h.attr("transform",`translate(${-(i.width/2)-g-(i.x-((y=i.left)!=null?y:0))}, ${-(i.height/2)-(i.y-((d=i.top)!=null?d:0))})`),H(t,u),t.intersect=function(m){var S,w,M,k,v,P;let x=N.rect(t,m),b=x.y-((S=t.y)!=null?S:0);if(l!=0&&(Math.abs(b)<((w=t.height)!=null?w:0)/2||Math.abs(b)==((M=t.height)!=null?M:0)/2&&Math.abs(x.x-((k=t.x)!=null?k:0))>((v=t.width)!=null?v:0)/2-g)){let C=g*g*(1-b*b/(l*l));C!=0&&(C=Math.sqrt(Math.abs(C))),C=g-C,m.x-((P=t.x)!=null?P:0)>0&&(C=-C),x.x+=C}return x},e}$(Ee,"tiltedCylinder");async function Oe(c,t){let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=i.width+t.padding,s=i.height+t.padding,o=[{x:-3*s/6,y:0},{x:h+3*s/6,y:0},{x:h,y:-s},{x:0,y:-s}],n,{cssStyles:l}=t;if(t.look==="handDrawn"){let g=D.svg(e),p=A(t,{}),f=V(o),u=g.path(f,p);n=e.insert(()=>u,":first-child").attr("transform",`translate(${-h/2}, ${s/2})`),l&&n.attr("style",l)}else n=gt(e,h,s,o);return a&&n.attr("style",a),t.width=h,t.height=s,H(t,n),t.intersect=function(g){return N.polygon(t,o,g)},e}$(Oe,"trapezoid");async function _e(c,t){var m,x,b,S;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=60,s=20,o=Math.max(h,i.width+((m=t.padding)!=null?m:0)*2,(x=t==null?void 0:t.width)!=null?x:0),n=Math.max(s,i.height+((b=t.padding)!=null?b:0)*2,(S=t==null?void 0:t.height)!=null?S:0),{cssStyles:l}=t,g=D.svg(e),p=A(t,{});t.look!=="handDrawn"&&(p.roughness=0,p.fillStyle="solid");let f=[{x:-o/2*.8,y:-n/2},{x:o/2*.8,y:-n/2},{x:o/2,y:-n/2*.6},{x:o/2,y:n/2},{x:-o/2,y:n/2},{x:-o/2,y:-n/2*.6}],u=V(f),y=g.path(u,p),d=e.insert(()=>y,":first-child");return d.attr("class","basic label-container"),l&&t.look!=="handDrawn"&&d.selectChildren("path").attr("style",l),a&&t.look!=="handDrawn"&&d.selectChildren("path").attr("style",a),H(t,d),t.intersect=function(w){return N.polygon(t,f,w)},e}$(_e,"trapezoidalPentagon");async function ze(c,t){var x,b,S,w,M;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=tt((x=Q().flowchart)==null?void 0:x.htmlLabels),o=i.width+((b=t.padding)!=null?b:0),n=o+i.height,l=o+i.height,g=[{x:0,y:0},{x:l,y:0},{x:l/2,y:-n}],{cssStyles:p}=t,f=D.svg(e),u=A(t,{});t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let y=V(g),d=f.path(y,u),m=e.insert(()=>d,":first-child").attr("transform",`translate(${-n/2}, ${n/2})`);return p&&t.look!=="handDrawn"&&m.selectChildren("path").attr("style",p),a&&t.look!=="handDrawn"&&m.selectChildren("path").attr("style",a),t.width=o,t.height=n,H(t,m),h.attr("transform",`translate(${-i.width/2-(i.x-((S=i.left)!=null?S:0))}, ${n/2-(i.height+((w=t.padding)!=null?w:0)/(s?2:1)-(i.y-((M=i.top)!=null?M:0)))})`),t.intersect=function(k){return Z.info("Triangle intersect",t,g,k),N.polygon(t,g,k)},e}$(ze,"triangle");async function je(c,t){var w,M,k,v,P,C,B,X;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+((w=t.padding)!=null?w:0)*2,(M=t==null?void 0:t.width)!=null?M:0),o=Math.max(i.height+((k=t.padding)!=null?k:0)*2,(v=t==null?void 0:t.height)!=null?v:0),n=o/8,l=o+n,{cssStyles:g}=t,f=70-s,u=f>0?f/2:0,y=D.svg(e),d=A(t,{});t.look!=="handDrawn"&&(d.roughness=0,d.fillStyle="solid");let m=[{x:-s/2-u,y:l/2},...ut(-s/2-u,l/2,s/2+u,l/2,n,.8),{x:s/2+u,y:-l/2},{x:-s/2-u,y:-l/2}],x=V(m),b=y.path(x,d),S=e.insert(()=>b,":first-child");return S.attr("class","basic label-container"),g&&t.look!=="handDrawn"&&S.selectAll("path").attr("style",g),a&&t.look!=="handDrawn"&&S.selectAll("path").attr("style",a),S.attr("transform",`translate(0,${-n/2})`),h.attr("transform",`translate(${-s/2+((P=t.padding)!=null?P:0)-(i.x-((C=i.left)!=null?C:0))},${-o/2+((B=t.padding)!=null?B:0)-n-(i.y-((X=i.top)!=null?X:0))})`),H(t,S),t.intersect=function(E){return N.polygon(t,m,E)},e}$(je,"waveEdgedRectangle");async function Ge(c,t){var M,k,v,P;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i}=await q(c,t,F(t)),h=100,s=50,o=Math.max(i.width+((M=t.padding)!=null?M:0)*2,(k=t==null?void 0:t.width)!=null?k:0),n=Math.max(i.height+((v=t.padding)!=null?v:0)*2,(P=t==null?void 0:t.height)!=null?P:0),l=o/n,g=o,p=n;g>p*l?p=g/l:g=p*l,g=Math.max(g,h),p=Math.max(p,s);let f=Math.min(p*.2,p/4),u=p+f*2,{cssStyles:y}=t,d=D.svg(e),m=A(t,{});t.look!=="handDrawn"&&(m.roughness=0,m.fillStyle="solid");let x=[{x:-g/2,y:u/2},...ut(-g/2,u/2,g/2,u/2,f,1),{x:g/2,y:-u/2},...ut(g/2,-u/2,-g/2,-u/2,f,-1)],b=V(x),S=d.path(b,m),w=e.insert(()=>S,":first-child");return w.attr("class","basic label-container"),y&&t.look!=="handDrawn"&&w.selectAll("path").attr("style",y),a&&t.look!=="handDrawn"&&w.selectAll("path").attr("style",a),H(t,w),t.intersect=function(C){return N.polygon(t,x,C)},e}$(Ge,"waveRectangle");async function Fe(c,t){var b,S,w,M,k,v;let{labelStyles:r,nodeStyles:a}=I(t);t.labelStyle=r;let{shapeSvg:e,bbox:i,label:h}=await q(c,t,F(t)),s=Math.max(i.width+((b=t.padding)!=null?b:0)*2,(S=t==null?void 0:t.width)!=null?S:0),o=Math.max(i.height+((w=t.padding)!=null?w:0)*2,(M=t==null?void 0:t.height)!=null?M:0),n=5,l=-s/2,g=-o/2,{cssStyles:p}=t,f=D.svg(e),u=A(t,{}),y=[{x:l-n,y:g-n},{x:l-n,y:g+o},{x:l+s,y:g+o},{x:l+s,y:g-n}],d=`M${l-n},${g-n} L${l+s},${g-n} L${l+s},${g+o} L${l-n},${g+o} L${l-n},${g-n}
M${l-n},${g} L${l+s},${g}
M${l},${g-n} L${l},${g+o}`;t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let m=f.path(d,u),x=e.insert(()=>m,":first-child");return x.attr("transform",`translate(${n/2}, ${n/2})`),x.attr("class","basic label-container"),p&&t.look!=="handDrawn"&&x.selectAll("path").attr("style",p),a&&t.look!=="handDrawn"&&x.selectAll("path").attr("style",a),h.attr("transform",`translate(${-(i.width/2)+n/2-(i.x-((k=i.left)!=null?k:0))}, ${-(i.height/2)+n/2-(i.y-((v=i.top)!=null?v:0))})`),H(t,x),t.intersect=function(P){return N.polygon(t,y,P)},e}$(Fe,"windowPane");async function qe(c,t,r,a,e=(i=>(i=r.class.padding)!=null?i:12)()){let h=a?0:3,s=c.insert("g").attr("class",F(t)).attr("id",t.domId||t.id),o=null,n=null,l=null,g=null,p=0,f=0,u=0;if(o=s.insert("g").attr("class","annotation-group text"),t.annotations.length>0){let b=t.annotations[0];await Ct(o,{text:`\xAB${b}\xBB`},0),p=o.node().getBBox().height}n=s.insert("g").attr("class","label-group text"),await Ct(n,t,0,["font-weight: bolder"]);let y=n.node().getBBox();f=y.height,l=s.insert("g").attr("class","members-group text");let d=0;for(let b of t.members){let S=await Ct(l,b,d,[b.parseClassifier()]);d+=S+h}u=l.node().getBBox().height,u<=0&&(u=e/2),g=s.insert("g").attr("class","methods-group text");let m=0;for(let b of t.methods){let S=await Ct(g,b,m,[b.parseClassifier()]);m+=S+h}let x=s.node().getBBox();if(o!==null){let b=o.node().getBBox();o.attr("transform",`translate(${-b.width/2})`)}return n.attr("transform",`translate(${-y.width/2}, ${p})`),x=s.node().getBBox(),l.attr("transform",`translate(0, ${p+f+e*2})`),x=s.node().getBBox(),g.attr("transform",`translate(0, ${p+f+(u?u+e*4:e*2)})`),x=s.node().getBBox(),{shapeSvg:s,bbox:x}}$(qe,"textHelper");async function Ct(c,t,r,a=[]){var g;let e=c.insert("g").attr("class","label").attr("style",a.join("; ")),i=_t(),h="useHtmlLabels"in t?t.useHtmlLabels:(g=tt(i.htmlLabels))!=null?g:!0,s="";"text"in t?s=t.text:s=t.label,!h&&s.startsWith("\\")&&(s=s.substring(1)),jt(s)&&(h=!0);let o=await dt(e,ys(kt(s)),{width:ms(s,i)+50,classes:"markdown-node-label",useHtmlLabels:h},i),n,l=1;if(h){let p=o.children[0],f=J(o);l=p.innerHTML.split("<br>").length,p.innerHTML.includes("</math>")&&(l+=p.innerHTML.split("<mrow>").length-1);let u=p.getElementsByTagName("img");if(u){let y=s.replace(/<img[^>]*>/g,"").trim()==="";await Promise.all([...u].map(d=>new Promise(m=>{function x(){var b,S;if(d.style.display="flex",d.style.flexDirection="column",y){let w=(S=(b=i.fontSize)==null?void 0:b.toString())!=null?S:window.getComputedStyle(document.body).fontSize,k=parseInt(w,10)*5+"px";d.style.minWidth=k,d.style.maxWidth=k}else d.style.width="100%";m(d)}$(x,"setupImage"),setTimeout(()=>{d.complete&&x()}),d.addEventListener("error",x),d.addEventListener("load",x)})))}n=p.getBoundingClientRect(),f.attr("width",n.width),f.attr("height",n.height)}else{a.includes("font-weight: bolder")&&J(o).selectAll("tspan").attr("font-weight",""),l=o.children.length;let p=o.children[0];(o.textContent===""||o.textContent.includes("&gt"))&&(p.textContent=s[0]+s.substring(1).replaceAll("&gt;",">").replaceAll("&lt;","<").trim(),s[1]===" "&&(p.textContent=p.textContent[0]+" "+p.textContent.substring(1))),p.textContent==="undefined"&&(p.textContent=""),n=o.getBBox()}return e.attr("transform","translate(0,"+(-n.height/(2*l)+r)+")"),n.height}$(Ct,"addText");async function Xe(c,t){var P,C,B,X,E,W,T,O;let r=Q(),a=(P=r.class.padding)!=null?P:12,e=a,i=(B=(C=t.useHtmlLabels)!=null?C:tt(r.htmlLabels))!=null?B:!0,h=t;h.annotations=(X=h.annotations)!=null?X:[],h.members=(E=h.members)!=null?E:[],h.methods=(W=h.methods)!=null?W:[];let{shapeSvg:s,bbox:o}=await qe(c,t,r,i,e),{labelStyles:n,nodeStyles:l}=I(t);t.labelStyle=n,t.cssStyles=h.styles||"";let g=((T=h.styles)==null?void 0:T.join(";"))||l||"";t.cssStyles||(t.cssStyles=g.replaceAll("!important","").split(";"));let p=h.members.length===0&&h.methods.length===0&&!((O=r.class)!=null&&O.hideEmptyMembersBox),f=D.svg(s),u=A(t,{});t.look!=="handDrawn"&&(u.roughness=0,u.fillStyle="solid");let y=o.width,d=o.height;h.members.length===0&&h.methods.length===0?d+=e:h.members.length>0&&h.methods.length===0&&(d+=e*2);let m=-y/2,x=-d/2,b=f.rectangle(m-a,x-a-(p?a:h.members.length===0&&h.methods.length===0?-a/2:0),y+2*a,d+2*a+(p?a*2:h.members.length===0&&h.methods.length===0?-a:0),u),S=s.insert(()=>b,":first-child");S.attr("class","basic label-container");let w=S.node().getBBox();s.selectAll(".text").each((R,Y,_)=>{var pt;let L=J(_[Y]),G=L.attr("transform"),z=0;if(G){let lt=RegExp(/translate\(([^,]+),([^)]+)\)/).exec(G);lt&&(z=parseFloat(lt[2]))}let U=z+x+a-(p?a:h.members.length===0&&h.methods.length===0?-a/2:0);i||(U-=4);let et=m;(L.attr("class").includes("label-group")||L.attr("class").includes("annotation-group"))&&(et=-((pt=L.node())==null?void 0:pt.getBBox().width)/2||0,s.selectAll("text").each(function(yt,lt,Ze){window.getComputedStyle(Ze[lt]).textAnchor==="middle"&&(et=0)})),L.attr("transform",`translate(${et}, ${U})`)});let M=s.select(".annotation-group").node().getBBox().height-(p?a/2:0)||0,k=s.select(".label-group").node().getBBox().height-(p?a/2:0)||0,v=s.select(".members-group").node().getBBox().height-(p?a/2:0)||0;if(h.members.length>0||h.methods.length>0||p){let R=f.line(w.x,M+k+x+a,w.x+w.width,M+k+x+a,u);s.insert(()=>R).attr("class","divider").attr("style",g)}if(p||h.members.length>0||h.methods.length>0){let R=f.line(w.x,M+k+v+x+e*2+a,w.x+w.width,M+k+v+x+a+e*2,u);s.insert(()=>R).attr("class","divider").attr("style",g)}if(h.look!=="handDrawn"&&s.selectAll("path").attr("style",g),S.select(":nth-child(2)").attr("style",g),s.selectAll(".divider").select("path").attr("style",g),t.labelStyle?s.selectAll("span").attr("style",t.labelStyle):s.selectAll("span").attr("style",g),!i){let R=RegExp(/color\s*:\s*([^;]*)/),Y=R.exec(g);if(Y){let _=Y[0].replace("color","fill");s.selectAll("tspan").attr("style",_)}else if(n){let _=R.exec(n);if(_){let L=_[0].replace("color","fill");s.selectAll("tspan").attr("style",L)}}}return H(t,S),t.intersect=function(R){return N.rect(t,R)},s}$(Xe,"classBox");var Ba=$(c=>{switch(c){case"Very High":return"red";case"High":return"orange";case"Medium":return null;case"Low":return"blue";case"Very Low":return"lightblue"}},"colorFromPriority");async function Ye(c,t,{config:r}){var X,E,W;let{labelStyles:a,nodeStyles:e}=I(t);t.labelStyle=a||"";let i=10,h=t.width;t.width=((X=t.width)!=null?X:200)-10;let{shapeSvg:s,bbox:o,label:n}=await q(c,t,F(t)),l=t.padding||10,g="",p;"ticket"in t&&t.ticket&&((E=r==null?void 0:r.kanban)!=null&&E.ticketBaseUrl)&&(g=(W=r==null?void 0:r.kanban)==null?void 0:W.ticketBaseUrl.replace("#TICKET#",t.ticket),p=s.insert("svg:a",":first-child").attr("class","kanban-ticket-link").attr("xlink:href",g).attr("target","_blank"));let f={useHtmlLabels:t.useHtmlLabels,labelStyle:t.labelStyle||"",width:t.width,img:t.img,padding:t.padding||8,centerLabel:!1},u,y;p?{label:u,bbox:y}=await ls(p,"ticket"in t&&t.ticket||"",f):{label:u,bbox:y}=await ls(s,"ticket"in t&&t.ticket||"",f);let{label:d,bbox:m}=await ls(s,"assigned"in t&&t.assigned||"",f);t.width=h;let x=10,b=(t==null?void 0:t.width)||0,S=Math.max(y.height,m.height)/2,w=Math.max(o.height+x*2,(t==null?void 0:t.height)||0)+S,M=-b/2,k=-w/2;n.attr("transform","translate("+(l-b/2)+", "+(-S-o.height/2)+")"),u.attr("transform","translate("+(l-b/2)+", "+(-S+o.height/2)+")"),d.attr("transform","translate("+(l+b/2-m.width-2*i)+", "+(-S+o.height/2)+")");let v,{rx:P,ry:C}=t,{cssStyles:B}=t;if(t.look==="handDrawn"){let T=D.svg(s),O=A(t,{}),R=P||C?T.path(ht(M,k,b,w,P||0),O):T.rectangle(M,k,b,w,O);v=s.insert(()=>R,":first-child"),v.attr("class","basic label-container").attr("style",B||null)}else{v=s.insert("rect",":first-child"),v.attr("class","basic label-container __APA__").attr("style",e).attr("rx",P!=null?P:5).attr("ry",C!=null?C:5).attr("x",M).attr("y",k).attr("width",b).attr("height",w);let T="priority"in t&&t.priority;if(T){let O=s.append("line"),R=M+2,Y=k+Math.floor((P!=null?P:0)/2),_=k+w-Math.floor((P!=null?P:0)/2);O.attr("x1",R).attr("y1",Y).attr("x2",R).attr("y2",_).attr("stroke-width","4").attr("stroke",Ba(T))}}return H(t,v),t.height=w,t.intersect=function(T){return N.rect(t,T)},s}$(Ye,"kanbanItem");var Ra=[{semanticName:"Process",name:"Rectangle",shortName:"rect",description:"Standard process shape",aliases:["proc","process","rectangle"],internalAliases:["squareRect"],handler:Be},{semanticName:"Event",name:"Rounded Rectangle",shortName:"rounded",description:"Represents an event",aliases:["event"],internalAliases:["roundedRect"],handler:De},{semanticName:"Terminal Point",name:"Stadium",shortName:"stadium",description:"Terminal point",aliases:["terminal","pill"],handler:Re},{semanticName:"Subprocess",name:"Framed Rectangle",shortName:"fr-rect",description:"Subprocess",aliases:["subprocess","subproc","framed-rectangle","subroutine"],handler:Te},{semanticName:"Database",name:"Cylinder",shortName:"cyl",description:"Database storage",aliases:["db","database","cylinder"],handler:Ks},{semanticName:"Start",name:"Circle",shortName:"circle",description:"Starting point",aliases:["circ"],handler:Xs},{semanticName:"Decision",name:"Diamond",shortName:"diam",description:"Decision-making step",aliases:["decision","diamond","question"],handler:ke},{semanticName:"Prepare Conditional",name:"Hexagon",shortName:"hex",description:"Preparation or condition step",aliases:["hexagon","prepare"],handler:ne},{semanticName:"Data Input/Output",name:"Lean Right",shortName:"lean-r",description:"Represents input or output",aliases:["lean-right","in-out"],internalAliases:["lean_right"],handler:me},{semanticName:"Data Input/Output",name:"Lean Left",shortName:"lean-l",description:"Represents output or input",aliases:["lean-left","out-in"],internalAliases:["lean_left"],handler:ye},{semanticName:"Priority Action",name:"Trapezoid Base Bottom",shortName:"trap-b",description:"Priority action",aliases:["priority","trapezoid-bottom","trapezoid"],handler:Oe},{semanticName:"Manual Operation",name:"Trapezoid Base Top",shortName:"trap-t",description:"Represents a manual task",aliases:["manual","trapezoid-top","inv-trapezoid"],internalAliases:["inv_trapezoid"],handler:fe},{semanticName:"Stop",name:"Double Circle",shortName:"dbl-circ",description:"Represents a stop point",aliases:["double-circle"],internalAliases:["doublecircle"],handler:se},{semanticName:"Text Block",name:"Text Block",shortName:"text",description:"Text block",handler:Ie},{semanticName:"Card",name:"Notched Rectangle",shortName:"notch-rect",description:"Represents a card",aliases:["card","notched-rectangle"],handler:Fs},{semanticName:"Lined/Shaded Process",name:"Lined Rectangle",shortName:"lin-rect",description:"Lined process shape",aliases:["lined-rectangle","lined-process","lin-proc","shaded-process"],handler:Pe},{semanticName:"Start",name:"Small Circle",shortName:"sm-circ",description:"Small starting point",aliases:["start","small-circle"],internalAliases:["stateStart"],handler:Ae},{semanticName:"Stop",name:"Framed Circle",shortName:"fr-circ",description:"Stop point",aliases:["stop","framed-circle"],internalAliases:["stateEnd"],handler:Ne},{semanticName:"Fork/Join",name:"Filled Rectangle",shortName:"fork",description:"Fork or join in process flow",aliases:["join"],internalAliases:["forkJoin"],handler:re},{semanticName:"Collate",name:"Hourglass",shortName:"hourglass",description:"Represents a collate operation",aliases:["hourglass","collate"],handler:le},{semanticName:"Comment",name:"Curly Brace",shortName:"brace",description:"Adds a comment",aliases:["comment","brace-l"],handler:Zs},{semanticName:"Comment Right",name:"Curly Brace",shortName:"brace-r",description:"Adds a comment",handler:Qs},{semanticName:"Comment with braces on both sides",name:"Curly Braces",shortName:"braces",description:"Adds a comment",handler:Js},{semanticName:"Com Link",name:"Lightning Bolt",shortName:"bolt",description:"Communication link",aliases:["com-link","lightning-bolt"],handler:de},{semanticName:"Document",name:"Document",shortName:"doc",description:"Represents a document",aliases:["doc","document"],handler:je},{semanticName:"Delay",name:"Half-Rounded Rectangle",shortName:"delay",description:"Represents a delay",aliases:["half-rounded-rectangle"],handler:ie},{semanticName:"Direct Access Storage",name:"Horizontal Cylinder",shortName:"h-cyl",description:"Direct access storage",aliases:["das","horizontal-cylinder"],handler:Ee},{semanticName:"Disk Storage",name:"Lined Cylinder",shortName:"lin-cyl",description:"Disk storage",aliases:["disk","lined-cylinder"],handler:xe},{semanticName:"Display",name:"Curved Trapezoid",shortName:"curv-trap",description:"Represents a display",aliases:["curved-trapezoid","display"],handler:Us},{semanticName:"Divided Process",name:"Divided Rectangle",shortName:"div-rect",description:"Divided process shape",aliases:["div-proc","divided-rectangle","divided-process"],handler:te},{semanticName:"Extract",name:"Triangle",shortName:"tri",description:"Extraction process",aliases:["extract","triangle"],handler:ze},{semanticName:"Internal Storage",name:"Window Pane",shortName:"win-pane",description:"Internal storage",aliases:["internal-storage","window-pane"],handler:Fe},{semanticName:"Junction",name:"Filled Circle",shortName:"f-circ",description:"Junction point",aliases:["junction","filled-circle"],handler:ee},{semanticName:"Loop Limit",name:"Trapezoidal Pentagon",shortName:"notch-pent",description:"Loop limit step",aliases:["loop-limit","notched-pentagon"],handler:_e},{semanticName:"Manual File",name:"Flipped Triangle",shortName:"flip-tri",description:"Manual file operation",aliases:["manual-file","flipped-triangle"],handler:ae},{semanticName:"Manual Input",name:"Sloped Rectangle",shortName:"sl-rect",description:"Manual input step",aliases:["manual-input","sloped-rectangle"],handler:Ce},{semanticName:"Multi-Document",name:"Stacked Document",shortName:"docs",description:"Multiple documents",aliases:["documents","st-doc","stacked-document"],handler:Se},{semanticName:"Multi-Process",name:"Stacked Rectangle",shortName:"st-rect",description:"Multiple processes",aliases:["procs","processes","stacked-rectangle"],handler:we},{semanticName:"Stored Data",name:"Bow Tie Rectangle",shortName:"bow-rect",description:"Stored data",aliases:["stored-data","bow-tie-rectangle"],handler:Gs},{semanticName:"Summary",name:"Crossed Circle",shortName:"cross-circ",description:"Summary",aliases:["summary","crossed-circle"],handler:Vs},{semanticName:"Tagged Document",name:"Tagged Document",shortName:"tag-doc",description:"Tagged document",aliases:["tag-doc","tagged-document"],handler:He},{semanticName:"Tagged Process",name:"Tagged Rectangle",shortName:"tag-rect",description:"Tagged process",aliases:["tagged-rectangle","tag-proc","tagged-process"],handler:We},{semanticName:"Paper Tape",name:"Flag",shortName:"flag",description:"Paper tape",aliases:["paper-tape"],handler:Ge},{semanticName:"Odd",name:"Odd",shortName:"odd",description:"Odd shape",internalAliases:["rect_left_inv_arrow"],handler:ve},{semanticName:"Lined Document",name:"Lined Document",shortName:"lin-doc",description:"Lined document",aliases:["lined-document"],handler:be}],La=$(()=>{let t=[...Object.entries({state:Le,choice:qs,note:Me,rectWithTitle:$e,labelRect:ue,iconSquare:ge,iconCircle:oe,icon:ce,iconRounded:he,imageSquare:pe,anchor:js,kanbanItem:Ye,classBox:Xe}),...Ra.flatMap(r=>[r.shortName,..."aliases"in r?r.aliases:[],..."internalAliases"in r?r.internalAliases:[]].map(e=>[e,r.handler]))];return Object.fromEntries(t)},"generateShapeMap"),Ve=La();function Na(c){return c in Ve}$(Na,"isValidShape");var Ot=new Map;async function Aa(c,t,r){let a,e;t.shape==="rect"&&(t.rx&&t.ry?t.shape="roundedRect":t.shape="squareRect");let i=t.shape?Ve[t.shape]:void 0;if(!i)throw new Error(`No such shape: ${t.shape}. Please check your syntax.`);if(t.link){let h;r.config.securityLevel==="sandbox"?h="_top":t.linkTarget&&(h=t.linkTarget||"_blank"),a=c.insert("svg:a").attr("xlink:href",t.link).attr("target",h!=null?h:null),e=await i(a,t,r)}else e=await i(c,t,r),a=e;return t.tooltip&&e.attr("title",t.tooltip),Ot.set(t.id,a),t.haveCallback&&a.attr("class",a.attr("class")+" clickable"),a}$(Aa,"insertNode");var Zr=$((c,t)=>{Ot.set(t.id,c)},"setNodeElem"),Qr=$(()=>{Ot.clear()},"clear"),Jr=$(c=>{let t=Ot.get(c.id);Z.trace("Transforming node",c.diff,c,"translate("+(c.x-c.width/2-5)+", "+c.width/2+")");let r=8,a=c.diff||0;return c.clusterNode?t.attr("transform","translate("+(c.x+a-c.width/2)+", "+(c.y-c.height/2-r)+")"):t.attr("transform","translate("+c.x+", "+c.y+")"),a},"positionNode");export{D as a,q as b,H as c,cs as d,Fa as e,qa as f,Na as g,Aa as h,Zr as i,Qr as j,Jr as k};