ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
79 lines (78 loc) • 25.9 kB
JavaScript
const vt=require("./mermaid-parser.core-DYumW1vq.cjs"),u=require("./chunk-Y2CYZVJY-DPaYLFFP.cjs"),Q=require("./src-C9EhKhbk.cjs"),C=require("./chunk-WYO6CB5R-u4mJNOcO.cjs"),J=require("./chunk-ICXQ74PX-BbT9JaEW.cjs"),St=require("./chunk-VAUOI2AC-DfQf5L2_.cjs"),Mt=require("./chunk-JWPE2WC7-D8EnWK1B.cjs");var W=u.__name((e,a)=>{const r=e<=1?e*100:e;if(r<0||r>100)throw new Error(`${a} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`);return r},"toPercent"),z=u.__name((e,a,r)=>({x:W(a,`${r} evolution`),y:W(e,`${r} visibility`)}),"toCoordinates"),U=u.__name(e=>{if(e){if(e==="+<>")return"bidirectional";if(e==="+<")return"backward";if(e==="+>")return"forward"}},"getFlowFromPort"),At=u.__name(e=>{if(!e?.startsWith("+"))return{};const a=/^\+'([^']*)'/.exec(e)?.[1];return e.includes("<>")?{flow:"bidirectional",label:a}:e.includes("<")?{flow:"backward",label:a}:e.includes(">")?{flow:"forward",label:a}:{label:a}},"extractFlowFromArrow"),Nt=u.__name((e,a)=>{if(Mt.populateCommonDb(e,a),e.size&&a.setSize(e.size.width,e.size.height),e.evolution){const r=e.evolution.stages.map(n=>n.secondName?`${n.name.trim()} / ${n.secondName.trim()}`:n.name.trim()),x=e.evolution.stages.filter(n=>n.boundary!==void 0).map(n=>n.boundary);a.updateAxes({stages:r,stageBoundaries:x})}if(e.anchors.forEach(r=>{const x=z(r.visibility,r.evolution,`Anchor "${r.name}"`);a.addNode(r.name,r.name,x.x,x.y,"anchor")}),e.components.forEach(r=>{const x=z(r.visibility,r.evolution,`Component "${r.name}"`),n=r.label?(r.label.negX?-1:1)*r.label.offsetX:void 0,l=r.label?(r.label.negY?-1:1)*r.label.offsetY:void 0,y=r.decorator?.strategy;a.addNode(r.name,r.name,x.x,x.y,"component",n,l,r.inertia,y)}),e.notes.forEach(r=>{const x=z(r.visibility,r.evolution,`Note "${r.text}"`);a.addNote(r.text,x.x,x.y)}),e.pipelines.forEach(r=>{const x=a.getNode(r.parent);if(!x||typeof x.y!="number")throw new Error(`Pipeline "${r.parent}" must reference an existing component with coordinates.`);const n=x.y;a.startPipeline(r.parent),r.components.forEach(l=>{const y=`${r.parent}_${l.name}`,v=l.label?(l.label.negX?-1:1)*l.label.offsetX:void 0,g=l.label?(l.label.negY?-1:1)*l.label.offsetY:void 0,F=W(l.evolution,`Pipeline component "${l.name}" evolution`);a.addNode(y,l.name,F,n,"pipeline-component",v,g),a.addPipelineComponent(r.parent,y)})}),e.links.forEach(r=>{const x=!!r.arrow&&(r.arrow.includes("-.->")||r.arrow.includes(".-."));let n=U(r.fromPort)??U(r.toPort);const{flow:l,label:y}=At(r.arrow);!n&&l&&(n=l);const v=r.linkLabel,g=y??v;a.addLink(a.resolveNodeId(r.from),a.resolveNodeId(r.to),x,g,n)}),e.evolves.forEach(r=>{const x=a.getNode(r.component);if(x?.y!==void 0){const n=W(r.target,`Evolve target for "${r.component}"`);a.addTrend(r.component,n,x.y)}}),e.annotations.length>0){const r=e.annotations[0],x=z(r.x,r.y,"Annotations box");a.setAnnotationsBox(x.x,x.y)}e.annotation.forEach(r=>{const x=z(r.x,r.y,`Annotation ${r.number}`);a.addAnnotation(r.number,[{x:x.x,y:x.y}],r.text)}),e.accelerators.forEach(r=>{const x=z(r.x,r.y,`Accelerator "${r.name}"`);a.addAccelerator(r.name,x.x,x.y)}),e.deaccelerators.forEach(r=>{const x=z(r.x,r.y,`Deaccelerator "${r.name}"`);a.addDeaccelerator(r.name,x.x,x.y)})},"populateDb"),K={parser:{yy:void 0},parse:u.__name(async e=>{const a=await vt.parse("wardley",e);Q.log.debug(a);const r=K.parser?.yy;if(!r||typeof r.addNode!="function")throw new Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Nt(a,r)},"parse")},Tt=class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}static{u.__name(this,"WardleyBuilder")}addNode(e){const a=this.nodes.get(e.id)??{id:e.id,label:e.label},r={...a,...e,className:e.className??a.className,labelOffsetX:e.labelOffsetX??a.labelOffsetX,labelOffsetY:e.labelOffsetY??a.labelOffsetY};this.nodes.set(e.id,r)}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});const a=this.nodes.get(e);a&&(a.isPipelineParent=!0)}addPipelineComponent(e,a){const r=this.pipelines.get(e);r&&r.componentIds.push(a);const x=this.nodes.get(a);x&&(x.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,a){this.annotationsBox={x:e,y:a}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,a){this.size={width:e,height:a}}getNode(e){return this.nodes.get(e)}resolveNodeId(e){if(this.nodes.has(e))return e;for(const[a,r]of this.nodes)if(r.label===e)return a;return e}build(){const e=[];for(const a of this.nodes.values()){if(typeof a.x!="number"||typeof a.y!="number")throw new Error(`Node "${a.label}" is missing coordinates`);e.push(a)}return{nodes:e,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}},k=new Tt;function tt(){return C.getConfig2()["wardley-beta"]}u.__name(tt,"getConfig");function et(e,a,r,x,n,l,y,v,g){k.addNode({id:e,label:a,x:r,y:x,className:n,labelOffsetX:l,labelOffsetY:y,inertia:v,sourceStrategy:g})}u.__name(et,"addNode");function at(e,a,r=!1,x,n){k.addLink({source:e,target:a,dashed:r,label:x,flow:n})}u.__name(at,"addLink");function rt(e,a,r){k.addTrend({nodeId:e,targetX:a,targetY:r})}u.__name(rt,"addTrend");function ot(e,a,r){k.addAnnotation({number:e,coordinates:a,text:r})}u.__name(ot,"addAnnotation");function nt(e,a,r){k.addNote({text:e,x:a,y:r})}u.__name(nt,"addNote");function st(e,a,r){k.addAccelerator({name:e,x:a,y:r})}u.__name(st,"addAccelerator");function it(e,a,r){k.addDeaccelerator({name:e,x:a,y:r})}u.__name(it,"addDeaccelerator");function lt(e,a){k.setAnnotationsBox(e,a)}u.__name(lt,"setAnnotationsBox");function dt(e,a){k.setSize(e,a)}u.__name(dt,"setSize");function ct(e){k.startPipeline(e)}u.__name(ct,"startPipeline");function pt(e,a){k.addPipelineComponent(e,a)}u.__name(pt,"addPipelineComponent");function ht(e){k.setAxes(e)}u.__name(ht,"updateAxes");function xt(e){return k.getNode(e)}u.__name(xt,"getNode");function ft(e){return k.resolveNodeId(e)}u.__name(ft,"resolveNodeId");function gt(){return k.build()}u.__name(gt,"getWardleyData");function ut(){k.clear(),C.clear()}u.__name(ut,"clear");var zt={getConfig:tt,addNode:et,addLink:at,addTrend:rt,addAnnotation:ot,addNote:nt,addAccelerator:st,addDeaccelerator:it,setAnnotationsBox:lt,setSize:dt,startPipeline:ct,addPipelineComponent:pt,updateAxes:ht,getNode:xt,resolveNodeId:ft,getWardleyData:gt,clear:ut,setAccTitle:C.setAccTitle,getAccTitle:C.getAccTitle,setDiagramTitle:C.setDiagramTitle,getDiagramTitle:C.getDiagramTitle,getAccDescription:C.getAccDescription,setAccDescription:C.setAccDescription},Lt=["Genesis","Custom Built","Product","Commodity"],Xt=u.__name(()=>{const{themeVariables:e}=C.getConfig2();return{backgroundColor:e.wardley?.backgroundColor??e.background??"#fff",axisColor:e.wardley?.axisColor??"#000",axisTextColor:e.wardley?.axisTextColor??e.primaryTextColor??"#222",gridColor:e.wardley?.gridColor??"rgba(100, 100, 100, 0.2)",componentFill:e.wardley?.componentFill??"#fff",componentStroke:e.wardley?.componentStroke??"#000",componentLabelColor:e.wardley?.componentLabelColor??e.primaryTextColor??"#222",linkStroke:e.wardley?.linkStroke??"#000",evolutionStroke:e.wardley?.evolutionStroke??"#dc3545",annotationStroke:e.wardley?.annotationStroke??"#000",annotationTextColor:e.wardley?.annotationTextColor??e.primaryTextColor??"#222",annotationFill:e.wardley?.annotationFill??e.background??"#fff"}},"getTheme"),Et=u.__name(()=>{const e=C.getConfig2()["wardley-beta"];return{width:e?.width??900,height:e?.height??600,padding:e?.padding??48,nodeRadius:e?.nodeRadius??6,nodeLabelOffset:e?.nodeLabelOffset??8,axisFontSize:e?.axisFontSize??12,labelFontSize:e?.labelFontSize??10,showGrid:e?.showGrid??!1,useMaxWidth:e?.useMaxWidth??!0}},"getConfigValues"),Yt={parser:K,db:zt,renderer:{draw:u.__name((e,a,r,x)=>{Q.log.debug(`Rendering Wardley map
`+e);const n=Et(),l=Xt(),y=n.nodeRadius*1.6,v=x.db,g=v.getWardleyData(),F=v.getDiagramTitle(),S=g.size?.width??n.width,b=g.size?.height??n.height,E=St.selectSvgElement(a);E.selectAll("*").remove(),C.configureSvgSize(E,b,S,n.useMaxWidth),E.attr("viewBox",`0 0 ${S} ${b}`);const _=E.append("g").attr("class","wardley-map"),D=E.append("defs");D.append("marker").attr("id",`arrow-${a}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",l.evolutionStroke).attr("stroke","none"),D.append("marker").attr("id",`link-arrow-end-${a}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",l.linkStroke).attr("stroke","none"),D.append("marker").attr("id",`link-arrow-start-${a}`).attr("viewBox","0 0 10 10").attr("refX",1).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z").attr("fill",l.linkStroke).attr("stroke","none"),_.append("rect").attr("class","wardley-background").attr("width",S).attr("height",b).attr("fill",l.backgroundColor);const Y=S-n.padding*2,I=b-n.padding*2;F&&_.append("text").attr("class","wardley-title").attr("x",S/2).attr("y",n.padding/2).attr("fill",l.axisTextColor).attr("font-size",n.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(F);const A=u.__name(t=>n.padding+t/100*Y,"projectX"),N=u.__name(t=>b-n.padding-t/100*I,"projectY"),O=_.append("g").attr("class","wardley-axes");O.append("line").attr("x1",n.padding).attr("x2",S-n.padding).attr("y1",b-n.padding).attr("y2",b-n.padding).attr("stroke",l.axisColor).attr("stroke-width",1),O.append("line").attr("x1",n.padding).attr("x2",n.padding).attr("y1",n.padding).attr("y2",b-n.padding).attr("stroke",l.axisColor).attr("stroke-width",1);const yt=g.axes.xLabel??"Evolution",mt=g.axes.yLabel??"Visibility";O.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",n.padding+Y/2).attr("y",b-n.padding/4).attr("fill",l.axisTextColor).attr("font-size",n.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(yt),O.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",n.padding/3).attr("y",n.padding+I/2).attr("fill",l.axisTextColor).attr("font-size",n.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${n.padding/3} ${n.padding+I/2})`).text(mt);const B=g.axes.stages&&g.axes.stages.length>0?g.axes.stages:Lt;if(B.length>0){const t=_.append("g").attr("class","wardley-stages"),i=g.axes.stageBoundaries,o=[];if(i&&i.length===B.length){let s=0;i.forEach(d=>{o.push({start:s,end:d}),s=d})}else{const s=1/B.length;B.forEach((d,c)=>{o.push({start:c*s,end:(c+1)*s})})}B.forEach((s,d)=>{const c=o[d],f=n.padding+c.start*Y,h=(f+(n.padding+c.end*Y))/2;d>0&&t.append("line").attr("x1",f).attr("x2",f).attr("y1",n.padding).attr("y2",b-n.padding).attr("stroke","#000").attr("stroke-width",1).attr("stroke-dasharray","5 5").attr("opacity",.8),t.append("text").attr("class","wardley-stage-label").attr("x",h).attr("y",b-n.padding/1.5).attr("fill",l.axisTextColor).attr("font-size",n.axisFontSize-2).attr("text-anchor","middle").text(s)})}if(n.showGrid){const t=_.append("g").attr("class","wardley-grid");for(let i=1;i<4;i++){const o=i/4,s=n.padding+Y*o;t.append("line").attr("x1",s).attr("x2",s).attr("y1",n.padding).attr("y2",b-n.padding).attr("stroke",l.gridColor).attr("stroke-dasharray","2 6"),t.append("line").attr("x1",n.padding).attr("x2",S-n.padding).attr("y1",b-n.padding-I*o).attr("y2",b-n.padding-I*o).attr("stroke",l.gridColor).attr("stroke-dasharray","2 6")}}const p=new Map;if(g.nodes.forEach(t=>{p.set(t.id,{x:A(t.x),y:N(t.y),node:t})}),g.pipelines.length>0){const t=_.append("g").attr("class","wardley-pipelines"),i=_.append("g").attr("class","wardley-pipeline-links");g.pipelines.forEach(o=>{if(o.componentIds.length===0)return;const s=o.componentIds.map(h=>({id:h,pos:p.get(h),node:g.nodes.find(m=>m.id===h)})).filter(h=>h.pos&&h.node).sort((h,m)=>h.node.x-m.node.x);for(let h=0;h<s.length-1;h++){const m=s[h],w=s[h+1];i.append("line").attr("class","wardley-pipeline-evolution-link").attr("x1",m.pos.x).attr("y1",m.pos.y).attr("x2",w.pos.x).attr("y2",w.pos.y).attr("stroke",l.linkStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4")}let d=1/0,c=-1/0,f=0;if(o.componentIds.forEach(h=>{const m=p.get(h);m&&(d=Math.min(d,m.x),c=Math.max(c,m.x),f=m.y)}),d!==1/0&&c!==-1/0){const m=n.nodeRadius*4,w=f-m/2,P=p.get(o.nodeId);P&&(P.x=(d+c)/2,P.y=w-y/6),t.append("rect").attr("class","wardley-pipeline-box").attr("x",d-15).attr("y",w).attr("width",c-d+30).attr("height",m).attr("fill","none").attr("stroke",l.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}})}const j=_.append("g").attr("class","wardley-links"),V=new Map;g.pipelines.forEach(t=>{V.set(t.nodeId,new Set(t.componentIds))});const Z=g.links.filter(t=>!(!p.has(t.source)||!p.has(t.target)||V.get(t.target)?.has(t.source)));j.selectAll("line").data(Z).enter().append("line").attr("class",t=>`wardley-link${t.dashed?" wardley-link--dashed":""}`).attr("x1",t=>{const i=p.get(t.source),o=p.get(t.target),s=g.nodes.find(h=>h.id===t.source).isPipelineParent?y/Math.sqrt(2):n.nodeRadius,d=o.x-i.x,c=o.y-i.y,f=Math.sqrt(d*d+c*c);return i.x+d/f*s}).attr("y1",t=>{const i=p.get(t.source),o=p.get(t.target),s=g.nodes.find(h=>h.id===t.source).isPipelineParent?y/Math.sqrt(2):n.nodeRadius,d=o.x-i.x,c=o.y-i.y,f=Math.sqrt(d*d+c*c);return i.y+c/f*s}).attr("x2",t=>{const i=p.get(t.source),o=p.get(t.target),s=g.nodes.find(h=>h.id===t.target).isPipelineParent?y/Math.sqrt(2):n.nodeRadius,d=i.x-o.x,c=i.y-o.y,f=Math.sqrt(d*d+c*c);return o.x+d/f*s}).attr("y2",t=>{const i=p.get(t.source),o=p.get(t.target),s=g.nodes.find(h=>h.id===t.target).isPipelineParent?y/Math.sqrt(2):n.nodeRadius,d=i.x-o.x,c=i.y-o.y,f=Math.sqrt(d*d+c*c);return o.y+c/f*s}).attr("stroke",l.linkStroke).attr("stroke-width",1).attr("stroke-dasharray",t=>t.dashed?"6 6":null).attr("marker-end",t=>t.flow==="forward"||t.flow==="bidirectional"?`url(#link-arrow-end-${a})`:null).attr("marker-start",t=>t.flow==="backward"||t.flow==="bidirectional"?`url(#link-arrow-start-${a})`:null),j.selectAll("text").data(Z.filter(t=>t.label)).enter().append("text").attr("class","wardley-link-label").attr("x",t=>{const i=p.get(t.source),o=p.get(t.target),s=(i.x+o.x)/2,d=o.y-i.y,c=o.x-i.x;return s+d/Math.sqrt(c*c+d*d)*8}).attr("y",t=>{const i=p.get(t.source),o=p.get(t.target),s=(i.y+o.y)/2,d=o.x-i.x,c=o.y-i.y,f=Math.sqrt(d*d+c*c);return s+-d/f*8}).attr("fill",l.axisTextColor).attr("font-size",n.labelFontSize).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("transform",t=>{const i=p.get(t.source),o=p.get(t.target),s=(i.x+o.x)/2,d=(i.y+o.y)/2,c=o.x-i.x,f=o.y-i.y,h=Math.sqrt(c*c+f*f),m=8,w=f/h,P=-c/h,L=s+w*m,q=d+P*m;let X=Math.atan2(f,c)*180/Math.PI;return(X>90||X<-90)&&(X+=180),`rotate(${X} ${L} ${q})`}).text(t=>t.label);const wt=_.append("g").attr("class","wardley-trends"),kt=g.trends.map(t=>{const i=p.get(t.nodeId);if(!i)return null;const o=A(t.targetX),s=N(t.targetY),d=o-i.x,c=s-i.y,f=Math.sqrt(d*d+c*c),h=n.nodeRadius+2;return{origin:i,targetX:o,targetY:s,adjustedX2:f>h?o-d/f*h:o,adjustedY2:f>h?s-c/f*h:s}}).filter(t=>t!==null);wt.selectAll("line").data(kt).enter().append("line").attr("class","wardley-trend").attr("x1",t=>t.origin.x).attr("y1",t=>t.origin.y).attr("x2",t=>t.adjustedX2).attr("y2",t=>t.adjustedY2).attr("stroke",l.evolutionStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4").attr("marker-end",`url(#arrow-${a})`);const M=_.append("g").attr("class","wardley-nodes").selectAll("g").data(g.nodes).enter().append("g").attr("class",t=>["wardley-node",t.className?`wardley-node--${t.className}`:""].filter(Boolean).join(" "));M.filter(t=>t.sourceStrategy==="outsource").append("circle").attr("class","wardley-outsource-overlay").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius*2).attr("fill","#666").attr("stroke",l.componentStroke).attr("stroke-width",1),M.filter(t=>t.sourceStrategy==="buy").append("circle").attr("class","wardley-buy-overlay").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius*2).attr("fill","#ccc").attr("stroke",l.componentStroke).attr("stroke-width",1),M.filter(t=>t.sourceStrategy==="build").append("circle").attr("class","wardley-build-overlay").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius*2).attr("fill","#eee").attr("stroke","#000").attr("stroke-width",1);const T=M.filter(t=>t.sourceStrategy==="market");T.append("circle").attr("class","wardley-market-overlay").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius*2).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",1),M.filter(t=>!t.isPipelineParent&&t.sourceStrategy!=="market"&&t.className!=="anchor").append("circle").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius).attr("fill",l.componentFill).attr("stroke",l.componentStroke).attr("stroke-width",1);const G=n.nodeRadius*.7,$=n.nodeRadius*1.2;if(T.append("line").attr("class","wardley-market-line").attr("x1",t=>p.get(t.id).x).attr("y1",t=>p.get(t.id).y-$).attr("x2",t=>p.get(t.id).x-$*Math.cos(Math.PI/6)).attr("y2",t=>p.get(t.id).y+$*Math.sin(Math.PI/6)).attr("stroke",l.componentStroke).attr("stroke-width",1),T.append("line").attr("class","wardley-market-line").attr("x1",t=>p.get(t.id).x-$*Math.cos(Math.PI/6)).attr("y1",t=>p.get(t.id).y+$*Math.sin(Math.PI/6)).attr("x2",t=>p.get(t.id).x+$*Math.cos(Math.PI/6)).attr("y2",t=>p.get(t.id).y+$*Math.sin(Math.PI/6)).attr("stroke",l.componentStroke).attr("stroke-width",1),T.append("line").attr("class","wardley-market-line").attr("x1",t=>p.get(t.id).x+$*Math.cos(Math.PI/6)).attr("y1",t=>p.get(t.id).y+$*Math.sin(Math.PI/6)).attr("x2",t=>p.get(t.id).x).attr("y2",t=>p.get(t.id).y-$).attr("stroke",l.componentStroke).attr("stroke-width",1),T.append("circle").attr("class","wardley-market-dot").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y-$).attr("r",G).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",2),T.append("circle").attr("class","wardley-market-dot").attr("cx",t=>p.get(t.id).x-$*Math.cos(Math.PI/6)).attr("cy",t=>p.get(t.id).y+$*Math.sin(Math.PI/6)).attr("r",G).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",2),T.append("circle").attr("class","wardley-market-dot").attr("cx",t=>p.get(t.id).x+$*Math.cos(Math.PI/6)).attr("cy",t=>p.get(t.id).y+$*Math.sin(Math.PI/6)).attr("r",G).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",2),M.filter(t=>t.isPipelineParent===!0).append("rect").attr("x",t=>p.get(t.id).x-y/2).attr("y",t=>p.get(t.id).y-y/2).attr("width",y).attr("height",y).attr("fill",l.componentFill).attr("stroke",l.componentStroke).attr("stroke-width",1),M.filter(t=>t.inertia===!0).append("line").attr("class","wardley-inertia").attr("x1",t=>{const i=p.get(t.id);let o=t.isPipelineParent?y/2+15:n.nodeRadius+15;return t.sourceStrategy&&(o+=n.nodeRadius+10),i.x+o}).attr("y1",t=>{const i=p.get(t.id),o=t.isPipelineParent?y:n.nodeRadius*2;return i.y-o/2}).attr("x2",t=>{const i=p.get(t.id);let o=t.isPipelineParent?y/2+15:n.nodeRadius+15;return t.sourceStrategy&&(o+=n.nodeRadius+10),i.x+o}).attr("y2",t=>{const i=p.get(t.id),o=t.isPipelineParent?y:n.nodeRadius*2;return i.y+o/2}).attr("stroke",l.componentStroke).attr("stroke-width",6),M.append("text").attr("x",t=>{const i=p.get(t.id);if(t.className==="anchor")return t.labelOffsetX!==void 0?i.x+t.labelOffsetX:i.x;let o=n.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetX===void 0&&(o+=10);const s=t.labelOffsetX??o;return i.x+s}).attr("y",t=>{const i=p.get(t.id);if(t.className==="anchor")return t.labelOffsetY!==void 0?i.y+t.labelOffsetY:i.y-3;let o=-n.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetY===void 0&&(o-=10);const s=t.labelOffsetY??o;return i.y+s}).attr("class","wardley-node-label").attr("fill",t=>t.className==="evolved"?l.evolutionStroke:t.className==="anchor"?"#000":l.componentLabelColor).attr("font-size",n.labelFontSize).attr("font-weight",t=>t.className==="anchor"?"bold":"normal").attr("text-anchor",t=>t.className==="anchor"?"middle":"start").attr("dominant-baseline",t=>t.className==="anchor"?"middle":"auto").text(t=>t.label),g.annotations.length>0){const t=_.append("g").attr("class","wardley-annotations");if(g.annotations.forEach(i=>{const o=i.coordinates.map(s=>({x:A(s.x),y:N(s.y)}));if(o.length>1)for(let s=0;s<o.length-1;s++)t.append("line").attr("class","wardley-annotation-line").attr("x1",o[s].x).attr("y1",o[s].y).attr("x2",o[s+1].x).attr("y2",o[s+1].y).attr("stroke",l.axisColor).attr("stroke-width",1.5).attr("stroke-dasharray","4 4");o.forEach(s=>{const d=t.append("g").attr("class","wardley-annotation");d.append("circle").attr("cx",s.x).attr("cy",s.y).attr("r",10).attr("fill","white").attr("stroke",l.axisColor).attr("stroke-width",1.5),d.append("text").attr("x",s.x).attr("y",s.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",10).attr("fill",l.axisTextColor).attr("font-weight","bold").text(i.number)})}),g.annotationsBox){let i=A(g.annotationsBox.x),o=N(g.annotationsBox.y);const s=10,d=16,c=11,f=t.append("g").attr("class","wardley-annotations-box"),h=[...g.annotations].filter(w=>w.text).sort((w,P)=>w.number-P.number),m=[];if(h.forEach((w,P)=>{const L=f.append("text").attr("x",i+s).attr("y",o+s+(P+1)*d).attr("font-size",c).attr("fill",l.axisTextColor).attr("text-anchor","start").attr("dominant-baseline","middle").text(`${w.number}. ${w.text}`);m.push(L)}),m.length>0){let w=0,P=0;m.forEach(H=>{const R=H.node(),Pt=R.getComputedTextLength();w=Math.max(w,Pt);const Ct=R.getBBox();P=Math.max(P,Ct.height)});const L=w+s*2+105,q=h.length*d+s*2+P/2,X=n.padding,bt=S-n.padding-L,$t=n.padding,_t=b-n.padding-q;i=Math.max(X,Math.min(i,bt)),o=Math.max($t,Math.min(o,_t)),m.forEach((H,R)=>{H.attr("x",i+s).attr("y",o+s+(R+1)*d)}),f.insert("rect","text").attr("x",i).attr("y",o).attr("width",L).attr("height",q).attr("fill","white").attr("stroke",l.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}}}if(g.notes.length>0){const t=_.append("g").attr("class","wardley-notes");g.notes.forEach(i=>{const o=A(i.x),s=N(i.y);t.append("text").attr("x",o).attr("y",s).attr("text-anchor","start").attr("font-size",11).attr("fill",l.axisTextColor).attr("font-weight","bold").text(i.text)})}if(g.accelerators.length>0){const t=_.append("g").attr("class","wardley-accelerators");g.accelerators.forEach(i=>{const o=A(i.x),s=N(i.y),d=60,c=30,f=20,h=`
M ${o} ${s-c/2}
L ${o+d-f} ${s-c/2}
L ${o+d-f} ${s-c/2-8}
L ${o+d} ${s}
L ${o+d-f} ${s+c/2+8}
L ${o+d-f} ${s+c/2}
L ${o} ${s+c/2}
Z
`;t.append("path").attr("d",h).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+d/2).attr("y",s+c/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",l.axisTextColor).attr("font-weight","bold").text(i.name)})}if(g.deaccelerators.length>0){const t=_.append("g").attr("class","wardley-deaccelerators");g.deaccelerators.forEach(i=>{const o=A(i.x),s=N(i.y),d=60,c=30,f=20,h=`
M ${o+d} ${s-c/2}
L ${o+f} ${s-c/2}
L ${o+f} ${s-c/2-8}
L ${o} ${s}
L ${o+f} ${s+c/2+8}
L ${o+f} ${s+c/2}
L ${o+d} ${s+c/2}
Z
`;t.append("path").attr("d",h).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+d/2).attr("y",s+c/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",l.axisTextColor).attr("font-weight","bold").text(i.name)})}},"draw")},styles:u.__name(({wardley:e}={})=>{const a=J.cleanAndMerge(J.cleanAndMerge(C.getThemeVariables3(),C.getConfig().themeVariables).wardley,e);return`
.wardley-background {
fill: ${a.backgroundColor};
}
.wardley-axes line, .wardley-axes path {
stroke: ${a.axisColor};
}
.wardley-axis-label {
fill: ${a.axisTextColor};
}
.wardley-stage-label {
fill: ${a.axisTextColor};
}
.wardley-grid line {
stroke: ${a.gridColor};
}
.wardley-node circle {
fill: ${a.componentFill};
stroke: ${a.componentStroke};
}
.wardley-node-label {
fill: ${a.componentLabelColor};
}
.wardley-link {
stroke: ${a.linkStroke};
}
.wardley-link--dashed {
stroke-dasharray: 4 4;
}
.wardley-link-label {
fill: ${a.axisTextColor};
}
.wardley-trend line {
stroke: ${a.evolutionStroke};
}
.wardley-annotation-line {
stroke: ${a.annotationStroke};
}
.wardley-annotation circle {
fill: ${a.annotationFill};
stroke: ${a.annotationStroke};
}
.wardley-annotation text {
fill: ${a.annotationTextColor};
}
.wardley-annotations-box rect {
fill: ${a.annotationFill};
stroke: ${a.annotationStroke};
}
.wardley-annotations-box text {
fill: ${a.annotationTextColor};
}
.wardley-pipeline-box {
stroke: ${a.componentStroke};
}
.wardley-notes text {
fill: ${a.axisTextColor};
}
`},"styles")};exports.diagram=Yt;