f7cloud_client/apps/whiteboard/js/stateDiagram-587899a1-C7Y_63j0.chunk.mjs
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

4 lines
10 KiB
JavaScript

/*! third party licenses: js/vendor.LICENSE.txt */
import{s as L,d as N,p as A}from"./styles-6aaf32cf-myQJNStM.chunk.mjs";import{s as S,l as D}from"./isEmpty-nTVdZyYD.chunk.mjs";import{G as O}from"./graph-BOKMr-rC.chunk.mjs";import{l as P}from"./layout-_kSBx-Bz.chunk.mjs";import{g as t,l as k,d as U,i as z,u as R}from"./index-CyCAgei9.chunk.mjs";import"./percentages-BXMCSKIN-Cw9SI0WV.chunk.mjs";import{l as I}from"./line-2ECJkxIB.chunk.mjs";import"./vendor-BeFBwUwf.chunk.mjs";import"./index-vg7q3Iku.chunk.mjs";import"./has-DJswI7NS.chunk.mjs";import"./_baseUniq-CE6homwJ.chunk.mjs";import"./union-S9f8F22c.chunk.mjs";import"./_basePickBy-0DU--7tw.chunk.mjs";import"./zipObject-D21phg5E.chunk.mjs";import"./whiteboard-main.mjs";import"./index-Anv74-sp.chunk.mjs";import"./index-Bn0s6V7w.chunk.mjs";import"./array-Cg_lHFoG.chunk.mjs";import"./path-i7Zvihw6.chunk.mjs";const C=e=>e.append("circle").attr("class","start-state").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit).attr("cy",t().state.padding+t().state.sizeUnit),W=e=>e.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",t().state.textHeight).attr("class","divider").attr("x2",t().state.textHeight*2).attr("y1",0).attr("y2",0),F=(e,i)=>{const p=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+2*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),s=p.node().getBBox();return e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",s.width+2*t().state.padding).attr("height",s.height+2*t().state.padding).attr("rx",t().state.radius),p},J=(e,i)=>{const p=function(o,f,b){const m=o.append("tspan").attr("x",2*t().state.padding).text(f);b||m.attr("dy",t().state.textHeight)},s=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+1.3*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.descriptions[0]).node().getBBox(),d=s.height,h=e.append("text").attr("x",t().state.padding).attr("y",d+t().state.padding*.4+t().state.dividerMargin+t().state.textHeight).attr("class","state-description");let l=!0,a=!0;i.descriptions.forEach(function(o){l||(p(h,o,a),a=!1),l=!1});const n=e.append("line").attr("x1",t().state.padding).attr("y1",t().state.padding+d+t().state.dividerMargin/2).attr("y2",t().state.padding+d+t().state.dividerMargin/2).attr("class","descr-divider"),x=h.node().getBBox(),c=Math.max(x.width,s.width);return n.attr("x2",c+3*t().state.padding),e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",c+2*t().state.padding).attr("height",x.height+d+2*t().state.padding).attr("rx",t().state.radius),e},Y=(e,i,p)=>{const s=t().state.padding,d=2*t().state.padding,h=e.node().getBBox(),l=h.width,a=h.x,n=e.append("text").attr("x",0).attr("y",t().state.titleShift).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),x=n.node().getBBox().width+d;let c=Math.max(x,l);c===l&&(c=c+d);let o;const f=e.node().getBBox();i.doc,o=a-s,x>l&&(o=(l-c)/2+s),Math.abs(a-f.x)<s&&x>l&&(o=a-(x-l)/2);const b=1-t().state.textHeight;return e.insert("rect",":first-child").attr("x",o).attr("y",b).attr("class",p?"alt-composit":"composit").attr("width",c).attr("height",f.height+t().state.textHeight+t().state.titleShift+1).attr("rx","0"),n.attr("x",o+s),x<=l&&n.attr("x",a+(c-d)/2-x/2+s),e.insert("rect",":first-child").attr("x",o).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",c).attr("height",t().state.textHeight*3).attr("rx",t().state.radius),e.insert("rect",":first-child").attr("x",o).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",c).attr("height",f.height+3+2*t().state.textHeight).attr("rx",t().state.radius),e},$=e=>(e.append("circle").attr("class","end-state-outer").attr("r",t().state.sizeUnit+t().state.miniPadding).attr("cx",t().state.padding+t().state.sizeUnit+t().state.miniPadding).attr("cy",t().state.padding+t().state.sizeUnit+t().state.miniPadding),e.append("circle").attr("class","end-state-inner").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit+2).attr("cy",t().state.padding+t().state.sizeUnit+2)),j=(e,i)=>{let p=t().state.forkWidth,s=t().state.forkHeight;if(i.parentId){let d=p;p=s,s=d}return e.append("rect").style("stroke","black").style("fill","black").attr("width",p).attr("height",s).attr("x",t().state.padding).attr("y",t().state.padding)},X=(e,i,p,s)=>{let d=0;const h=s.append("text");h.style("text-anchor","start"),h.attr("class","noteText");let l=e.replace(/\r\n/g,"<br/>");l=l.replace(/\n/g,"<br/>");const a=l.split(z.lineBreakRegex);let n=1.25*t().state.noteMargin;for(const x of a){const c=x.trim();if(c.length>0){const o=h.append("tspan");if(o.text(c),n===0){const f=o.node().getBBox();n+=f.height}d+=n,o.attr("x",i+t().state.noteMargin),o.attr("y",p+d+1.25*t().state.noteMargin)}}return{textWidth:h.node().getBBox().width,textHeight:d}},q=(e,i)=>{i.attr("class","state-note");const p=i.append("rect").attr("x",0).attr("y",t().state.padding),s=i.append("g"),{textWidth:d,textHeight:h}=X(e,0,0,s);return p.attr("height",h+2*t().state.noteMargin),p.attr("width",d+t().state.noteMargin*2),p},H=function(e,i){const p=i.id,s={id:p,label:i.id,width:0,height:0},d=e.append("g").attr("id",p).attr("class","stateGroup");i.type==="start"&&C(d),i.type==="end"&&$(d),(i.type==="fork"||i.type==="join")&&j(d,i),i.type==="note"&&q(i.note.text,d),i.type==="divider"&&W(d),i.type==="default"&&i.descriptions.length===0&&F(d,i),i.type==="default"&&i.descriptions.length>0&&J(d,i);const h=d.node().getBBox();return s.width=h.width+2*t().state.padding,s.height=h.height+2*t().state.padding,s};let T=0;const Z=function(e,i,p){const s=function(n){switch(n){case N.relationType.AGGREGATION:return"aggregation";case N.relationType.EXTENSION:return"extension";case N.relationType.COMPOSITION:return"composition";case N.relationType.DEPENDENCY:return"dependency"}};i.points=i.points.filter(n=>!Number.isNaN(n.y));const d=i.points,h=I().x(function(n){return n.x}).y(function(n){return n.y}).curve(D),l=e.append("path").attr("d",h(d)).attr("id","edge"+T).attr("class","transition");let a="";if(t().state.arrowMarkerAbsolute&&(a=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,a=a.replace(/\(/g,"\\("),a=a.replace(/\)/g,"\\)")),l.attr("marker-end","url("+a+"#"+s(N.relationType.DEPENDENCY)+"End)"),p.title!==void 0){const n=e.append("g").attr("class","stateLabel"),{x,y:c}=R.calcLabelPosition(i.points),o=z.getRows(p.title);let f=0;const b=[];let m=0,M=0;for(let u=0;u<=o.length;u++){const g=n.append("text").attr("text-anchor","middle").text(o[u]).attr("x",x).attr("y",c+f),y=g.node().getBBox();m=Math.max(m,y.width),M=Math.min(M,y.x),k.info(y.x,x,c+f),f===0&&(f=g.node().getBBox().height,k.info("Title height",f,c)),b.push(g)}let E=f*o.length;if(o.length>1){const u=(o.length-1)*f*.5;b.forEach((g,y)=>g.attr("y",c+y*f-u)),E=f*o.length}const r=n.node().getBBox();n.insert("rect",":first-child").attr("class","box").attr("x",x-m/2-t().state.padding/2).attr("y",c-E/2-t().state.padding/2-3.5).attr("width",m+t().state.padding).attr("height",E+t().state.padding),k.info(r)}T++};let w;const v={},K=function(){},Q=function(e){e.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},V=function(e,i,p,s){w=t().state;const d=t().securityLevel;let h;d==="sandbox"&&(h=S("#i"+i));const l=d==="sandbox"?S(h.nodes()[0].contentDocument.body):S("body"),a=d==="sandbox"?h.nodes()[0].contentDocument:document;k.debug("Rendering diagram "+e);const n=l.select(`[id='${i}']`);Q(n);const x=s.db.getRootDoc();G(x,n,void 0,!1,l,a,s);const c=w.padding,o=n.node().getBBox(),f=o.width+c*2,b=o.height+c*2,m=f*1.75;U(n,b,m,w.useMaxWidth),n.attr("viewBox",`${o.x-w.padding} ${o.y-w.padding} `+f+" "+b)},_=e=>e?e.length*w.fontSizeFactor:1,G=(e,i,p,s,d,h,l)=>{const a=new O({compound:!0,multigraph:!0});let n,x=!0;for(n=0;n<e.length;n++)if(e[n].stmt==="relation"){x=!1;break}p?a.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:x?1:w.edgeLengthFactor,nodeSep:x?1:50,isMultiGraph:!0}):a.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:x?1:w.edgeLengthFactor,nodeSep:x?1:50,ranker:"tight-tree",isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}}),l.db.extract(e);const c=l.db.getStates(),o=l.db.getRelations(),f=Object.keys(c);for(const r of f){const u=c[r];p&&(u.parentId=p);let g;if(u.doc){let y=i.append("g").attr("id",u.id).attr("class","stateGroup");g=G(u.doc,y,u.id,!s,d,h,l);{y=Y(y,u,s);let B=y.node().getBBox();g.width=B.width,g.height=B.height+w.padding/2,v[u.id]={y:w.compositTitleSize}}}else g=H(i,u);if(u.note){const y={descriptions:[],id:u.id+"-note",note:u.note,type:"note"},B=H(i,y);u.note.position==="left of"?(a.setNode(g.id+"-note",B),a.setNode(g.id,g)):(a.setNode(g.id,g),a.setNode(g.id+"-note",B)),a.setParent(g.id,g.id+"-group"),a.setParent(g.id+"-note",g.id+"-group")}else a.setNode(g.id,g)}k.debug("Count=",a.nodeCount(),a);let b=0;o.forEach(function(r){b++,k.debug("Setting edge",r),a.setEdge(r.id1,r.id2,{relation:r,width:_(r.title),height:w.labelHeight*z.getRows(r.title).length,labelpos:"c"},"id"+b)}),P(a),k.debug("Graph after layout",a.nodes());const m=i.node();a.nodes().forEach(function(r){r!==void 0&&a.node(r)!==void 0?(k.warn("Node "+r+": "+JSON.stringify(a.node(r))),d.select("#"+m.id+" #"+r).attr("transform","translate("+(a.node(r).x-a.node(r).width/2)+","+(a.node(r).y+(v[r]?v[r].y:0)-a.node(r).height/2)+" )"),d.select("#"+m.id+" #"+r).attr("data-x-shift",a.node(r).x-a.node(r).width/2),h.querySelectorAll("#"+m.id+" #"+r+" .divider").forEach(u=>{const g=u.parentElement;let y=0,B=0;g&&(g.parentElement&&(y=g.parentElement.getBBox().width),B=parseInt(g.getAttribute("data-x-shift"),10),Number.isNaN(B)&&(B=0)),u.setAttribute("x1",0-B+8),u.setAttribute("x2",y-B-8)})):k.debug("No Node "+r+": "+JSON.stringify(a.node(r)))});let M=m.getBBox();a.edges().forEach(function(r){r!==void 0&&a.edge(r)!==void 0&&(k.debug("Edge "+r.v+" -> "+r.w+": "+JSON.stringify(a.edge(r))),Z(i,a.edge(r),a.edge(r).relation))}),M=m.getBBox();const E={id:p||"root",label:p||"root",width:0,height:0};return E.width=M.width+2*w.padding,E.height=M.height+2*w.padding,k.debug("Doc rendered",E,a),E},tt={setConf:K,draw:V},bt={parser:A,db:N,renderer:tt,styles:L,init:e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute,N.clear()}};export{bt as diagram};
//# sourceMappingURL=stateDiagram-587899a1-C7Y_63j0.chunk.mjs.map