mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-12-27 01:42:11 +08:00
5 lines
14 KiB
JavaScript
5 lines
14 KiB
JavaScript
|
import{a as U,d as w}from"./chunk-24CS6DUF.js";import{a as O}from"./chunk-YJYNUSAM.js";import{a as H}from"./chunk-5JJWRCP3.js";import{d as Y}from"./chunk-MCENFELV.js";import{m as u}from"./chunk-HFFTYNMA.js";import{Fa as R,I as W,Ja as X,Z as y,h as d,ia as T,j as f}from"./chunk-3QLLRM5L.js";var G=d((r,t,a,i,o)=>{t.arrowTypeStart&&A(r,"start",t.arrowTypeStart,a,i,o),t.arrowTypeEnd&&A(r,"end",t.arrowTypeEnd,a,i,o)},"addEdgeMarkers"),P={arrow_cross:"cross",arrow_point:"point",arrow_barb:"barb",arrow_circle:"circle",aggregation:"aggregation",extension:"extension",composition:"composition",dependency:"dependency",lollipop:"lollipop"},A=d((r,t,a,i,o,l)=>{let s=P[a];if(!s){f.warn(`Unknown arrow type: ${a}`);return}let n=t==="start"?"Start":"End";r.attr(`marker-${t}`,`url(${i}#${o}_${l}-${s}${n})`)},"addEdgeMarker"),_=new Map,k=new Map,gt=d(()=>{_.clear(),k.clear()},"clear"),M=d(r=>r?r.reduce((a,i)=>a+";"+i,""):"","getLabelStyles"),ut=d(async(r,t)=>{let a=W(y().flowchart.htmlLabels),i=await Y(r,t.label,{style:M(t.labelStyle),useHtmlLabels:a,addSvgBackground:!0,isNode:!1});f.info("abc82",t,t.labelType);let o=r.insert("g").attr("class","edgeLabel"),l=o.insert("g").attr("class","label");l.node().appendChild(i);let s=i.getBBox();if(a){let e=i.children[0],h=T(i);s=e.getBoundingClientRect(),h.attr("width",s.width),h.attr("height",s.height)}l.attr("transform","translate("+-s.width/2+", "+-s.height/2+")"),_.set(t.id,o),t.width=s.width,t.height=s.height;let n;if(t.startLabelLeft){let e=await w(t.startLabelLeft,M(t.labelStyle)),h=r.insert("g").attr("class","edgeTerminals"),p=h.insert("g").attr("class","inner");n=p.node().appendChild(e);let c=e.getBBox();p.attr("transform","translate("+-c.width/2+", "+-c.height/2+")"),k.get(t.id)||k.set(t.id,{}),k.get(t.id).startLeft=h,v(n,t.startLabelLeft)}if(t.startLabelRight){let e=await w(t.startLabelRight,M(t.labelStyle)),h=r.insert("g").attr("class","edgeTerminals"),p=h.insert("g").attr("class","inner");n=h.node().appendChild(e),p.node().appendChild(e);let c=e.getBBox();p.attr("transform","translate("+-c.width/2+", "+-c.height/2+")"),k.get(t.id)||k.set(t.id,{}),k.get(t.id).startRight=h,v(n,t.startLabelRight)}if(t.endLabelLeft){let e=await w(t.endLabelLeft,M(t.labelStyle)),h=r.insert("g").attr("class","edgeTerminals"),p=h.insert("g").attr("class","inner");n=p.node().appendChild(e);let c=e.getBBox();p.attr("transform","translate("+-c.width/2+", "+-c.height/2+")"),h.node().appendChild(e),k.get(t.id)||k.set(t.id,{}),k.get(t.id).endLeft=h,v(n,t.endLabelLeft)}if(t.endLabelRight){let e=await w(t.endLabelRight,M(t.labelStyle)),h=r.insert("g").attr("class","edgeTerminals"),p=h.insert("g").attr("class","inner");n=p.node().appendChild(e);let c=e.getBBox();p.attr("transform","translate("+-c.width/2+", "+-c.height/2+")"),h.node().appendChild(e),k.get(t.id)||k.set(t.id,{}),k.get(t.id).endRight=h,v(n,t.endLabelRight)}return i},"insertEdgeLabel");function v(r,t){y().flowchart.htmlLabels&&r&&(r.style.width=t.length*9+"px",r.style.height="12px")}d(v,"setTerminalWidth");var Lt=d((r,t)=>{f.debug("Moving label abc88 ",r.id,r.label,_.get(r.id),t);let a=t.updatedPath?t.updatedPath:t.originalPath,i=y(),{subGraphTitleTotalMargin:o}=H(i);if(r.label){let l=_.get(r.id),s=r.x,n=r.y;if(a){let e=u.calcLabelPosition(a);f.debug("Moving label "+r.label+" from (",s,",",n,") to (",e.x,",",e.y,") abc88"),t.updatedPath&&(s=e.x,n=e.y)}l.attr("transform",`translate(${s}, ${n+o/2})`)}if(r.startLabelLeft){let l=k.get(r.id).startLeft,s=r.x,n=r.y;if(a){let e=u.calcTerminalLabelPosition(r.arrowTypeStart?10:0,"start_left",a);s=e.x,n=e.y}l.attr("transform",`translate(${s}, ${n})`)}if(r.startLabelRight){let l=k.get(r.id).startRight,s=r.x,n=r.y;if(a){let e=u.calcTerminalLabelPosition(r.arrowTypeStart?10:0,"start_right",a);s=e.x,n=e.y}l.attr("transform",`translate(${s}, ${n})`)}if(r.endLabelLeft){let l=k.get(r.id).endLeft,s=r.x,n=r.y;if(a){let e=u.calcTerminalLabelPosition(r.arrowTypeEnd?10:0,"end_left",a);s=e.x,n=e.y}l.attr("transform",`translate(${s}, ${n})`)}if(r.endLabelRight){let l=k.get(r.id).endRight,s=r.x,n=r.y;if(a){let e=u.calcTerminalLab
|
||
|
outsidePoint: ${JSON.stringify(t)}
|
||
|
insidePoint : ${JSON.stringify(a)}
|
||
|
node : x:${r.x} y:${r.y} w:${r.width} h:${r.height}`);let i=r.x,o=r.y,l=Math.abs(i-a.x),s=r.width/2,n=a.x<t.x?s-l:s+l,e=r.height/2,h=Math.abs(t.y-a.y),p=Math.abs(t.x-a.x);if(Math.abs(o-t.y)*s>Math.abs(i-t.x)*e){let c=a.y<t.y?t.y-e-o:o-e-t.y;n=p*c/h;let x={x:a.x<t.x?a.x+n:a.x-p+n,y:a.y<t.y?a.y+h-c:a.y-h+c};return n===0&&(x.x=t.x,x.y=t.y),p===0&&(x.x=t.x),h===0&&(x.y=t.y),f.debug(`abc89 top/bottom calc, Q ${h}, q ${c}, R ${p}, r ${n}`,x),x}else{a.x<t.x?n=t.x-s-i:n=i-s-t.x;let c=h*n/p,x=a.x<t.x?a.x+p-n:a.x-p+n,m=a.y<t.y?a.y+c:a.y-c;return f.debug(`sides calc abc89, Q ${h}, q ${c}, R ${p}, r ${n}`,{_x:x,_y:m}),n===0&&(x=t.x,m=t.y),p===0&&(x=t.x),h===0&&(m=t.y),{x,y:m}}},"intersection"),Z=d((r,t)=>{f.warn("abc88 cutPathAtIntersect",r,t);let a=[],i=r[0],o=!1;return r.forEach(l=>{if(f.info("abc88 checking point",l,t),!V(t,l)&&!o){let s=D(t,i,l);f.debug("abc88 inside",l,i,s),f.debug("abc88 intersection",s,t);let n=!1;a.forEach(e=>{n=n||e.x===s.x&&e.y===s.y}),a.some(e=>e.x===s.x&&e.y===s.y)?f.warn("abc88 no intersect",s,a):a.push(s),o=!0}else f.warn("abc88 outside",l,i),i=l,o||a.push(l)}),f.debug("returning points",a),a},"cutPathAtIntersect");function q(r){let t=[],a=[];for(let i=1;i<r.length-1;i++){let o=r[i-1],l=r[i],s=r[i+1];(o.x===l.x&&l.y===s.y&&Math.abs(l.x-s.x)>5&&Math.abs(l.y-o.y)>5||o.y===l.y&&l.x===s.x&&Math.abs(l.x-o.x)>5&&Math.abs(l.y-s.y)>5)&&(t.push(l),a.push(i))}return{cornerPoints:t,cornerPointPositions:a}}d(q,"extractCornerPoints");var N=d(function(r,t,a){let i=t.x-r.x,o=t.y-r.y,l=Math.sqrt(i*i+o*o),s=a/l;return{x:t.x-s*i,y:t.y-s*o}},"findAdjacentPoint"),K=d(function(r){let{cornerPointPositions:t}=q(r),a=[];for(let i=0;i<r.length;i++)if(t.includes(i)){let o=r[i-1],l=r[i+1],s=r[i],n=N(o,s,5),e=N(l,s,5),h=e.x-n.x,p=e.y-n.y;a.push(n);let c=Math.sqrt(2)*2,x={x:s.x,y:s.y};if(Math.abs(l.x-o.x)>10&&Math.abs(l.y-o.y)>=10){f.debug("Corner point fixing",Math.abs(l.x-o.x),Math.abs(l.y-o.y));let m=5;s.x===n.x?x={x:h<0?n.x-m+c:n.x+m-c,y:p<0?n.y-c:n.y+c}:x={x:h<0?n.x-c:n.x+c,y:p<0?n.y-m+c:n.y+m-c}}else f.debug("Corner point skipping fixing",Math.abs(l.x-o.x),Math.abs(l.y-o.y));a.push(x,e)}else a.push(r[i]);return a},"fixCorners"),wt=d(function(r,t,a,i,o,l,s){let{handDrawnSeed:n}=y(),e=t.points,h=!1,p=o;var c=l;c.intersect&&p.intersect&&(e=e.slice(1,t.points.length-1),e.unshift(p.intersect(e[0])),f.debug("Last point APA12",t.start,"-->",t.end,e[e.length-1],c,c.intersect(e[e.length-1])),e.push(c.intersect(e[e.length-1]))),t.toCluster&&(f.info("to cluster abc88",a.get(t.toCluster)),e=Z(t.points,a.get(t.toCluster).node),h=!0),t.fromCluster&&(f.debug("from cluster abc88",a.get(t.fromCluster),JSON.stringify(e,null,2)),e=Z(e.reverse(),a.get(t.fromCluster).node).reverse(),h=!0);let x=e.filter(L=>!Number.isNaN(L.y));x=K(x);let m=X;t.curve&&(m=t.curve);let{x:I,y:j}=O(t),J=R().x(I).y(j).curve(m),b;switch(t.thickness){case"normal":b="edge-thickness-normal";break;case"thick":b="edge-thickness-thick";break;case"invisible":b="edge-thickness-invisible";break;default:b="edge-thickness-normal"}switch(t.pattern){case"solid":b+=" edge-pattern-solid";break;case"dotted":b+=" edge-pattern-dotted";break;case"dashed":b+=" edge-pattern-dashed";break;default:b+=" edge-pattern-solid"}let g,B=J(x),E=Array.isArray(t.style)?t.style:[t.style];if(t.look==="handDrawn"){let L=U.svg(r);Object.assign([],x);let C=L.path(B,{roughness:.3,seed:n});b+=" transition",g=T(C).select("path").attr("id",t.id).attr("class"," "+b+(t.classes?" "+t.classes:"")).attr("style",E?E.reduce((z,F)=>z+";"+F,""):"");let Q=g.attr("d");g.attr("d",Q),r.node().appendChild(g.node())}else g=r.append("path").attr("d",B).attr("id",t.id).attr("class"," "+b+(t.classes?" "+t.classes:"")).attr("style",E?E.reduce((L,C)=>L+";"+C,""):"");let S="";(y().flowchart.arrowMarkerAbsolute||y().state.arrowMarkerAbsolute)&&(S=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,S=S.replace(/\(/g,"\\(").replace(/\)/g,"\\)")),f.info("arrowTypeStart",t.arrowTypeStart),f.info("arrowTypeEnd",t.arrowTypeEnd),G(g,t,S,s,i);let $={};return h&&($.updatedPath=e),$.ori
|