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 u=require("./chunk-Y2CYZVJY-DPaYLFFP.cjs"),U=require("./src-D8aDujwE.cjs"),C=require("./chunk-I66GZJ75-BzqGKy7F.cjs"),J=require("./chunk-NSK5VX7P-DcRXFc-R.cjs"),vt=require("./chunk-3NCLNEKW-CHPh0zzA.cjs"),St=require("./chunk-JWPE2WC7-D8EnWK1B.cjs"),Mt=require("./mermaid-parser.core-DQClw8Il.cjs");var R=u.__name((e,n)=>{const r=e<=1?e*100:e;if(r<0||r>100)throw new Error(`${n} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`);return r},"toPercent"),L=u.__name((e,n,r)=>({x:R(n,`${r} evolution`),y:R(e,`${r} visibility`)}),"toCoordinates"),K=u.__name(e=>{if(e){if(e==="+<>")return"bidirectional";if(e==="+<")return"backward";if(e==="+>")return"forward"}},"getFlowFromPort"),Nt=u.__name(e=>{if(!e?.startsWith("+"))return{};const n=/^\+'([^']*)'/.exec(e)?.[1];return e.includes("<>")?{flow:"bidirectional",label:n}:e.includes("<")?{flow:"backward",label:n}:e.includes(">")?{flow:"forward",label:n}:{label:n}},"extractFlowFromArrow"),Tt=u.__name((e,n)=>{if(St.populateCommonDb(e,n),e.size&&n.setSize(e.size.width,e.size.height),e.evolution){const r=e.evolution.stages.map(a=>a.secondName?`${a.name.trim()} / ${a.secondName.trim()}`:a.name.trim()),h=e.evolution.stages.filter(a=>a.boundary!==void 0).map(a=>a.boundary);n.updateAxes({stages:r,stageBoundaries:h})}if(e.anchors.forEach(r=>{const h=L(r.visibility,r.evolution,`Anchor "${r.name}"`);n.addNode(r.name,r.name,h.x,h.y,"anchor")}),e.components.forEach(r=>{const h=L(r.visibility,r.evolution,`Component "${r.name}"`),a=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;n.addNode(r.name,r.name,h.x,h.y,"component",a,l,r.inertia,y)}),e.notes.forEach(r=>{const h=L(r.visibility,r.evolution,`Note "${r.text}"`);n.addNote(r.text,h.x,h.y)}),e.pipelines.forEach(r=>{const h=n.getNode(r.parent);if(!h||typeof h.y!="number")throw new Error(`Pipeline "${r.parent}" must reference an existing component with coordinates.`);const a=h.y;n.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=R(l.evolution,`Pipeline component "${l.name}" evolution`);n.addNode(y,l.name,F,a,"pipeline-component",v,g),n.addPipelineComponent(r.parent,y)})}),e.links.forEach(r=>{const h=!!r.arrow&&(r.arrow.includes("-.->")||r.arrow.includes(".-."));let a=K(r.fromPort)??K(r.toPort);const{flow:l,label:y}=Nt(r.arrow);!a&&l&&(a=l);const v=r.linkLabel,g=y??v;n.addLink(n.resolveNodeId(r.from),n.resolveNodeId(r.to),h,g,a)}),e.evolves.forEach(r=>{const h=n.getNode(r.component);if(h?.y!==void 0){const a=R(r.target,`Evolve target for "${r.component}"`);n.addTrend(r.component,a,h.y)}}),e.annotations.length>0){const r=e.annotations[0],h=L(r.x,r.y,"Annotations box");n.setAnnotationsBox(h.x,h.y)}e.annotation.forEach(r=>{const h=L(r.x,r.y,`Annotation ${r.number}`);n.addAnnotation(r.number,[{x:h.x,y:h.y}],r.text)}),e.accelerators.forEach(r=>{const h=L(r.x,r.y,`Accelerator "${r.name}"`);n.addAccelerator(r.name,h.x,h.y)}),e.deaccelerators.forEach(r=>{const h=L(r.x,r.y,`Deaccelerator "${r.name}"`);n.addDeaccelerator(r.name,h.x,h.y)})},"populateDb"),Q={parser:{yy:void 0},parse:u.__name(async e=>{const n=await Mt.parse("wardley",e);U.log.debug(n);const r=Q.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.");Tt(n,r)},"parse")},At=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 n=this.nodes.get(e.id)??{id:e.id,label:e.label},r={...n,...e,className:e.className??n.className,labelOffsetX:e.labelOffsetX??n.labelOffsetX,labelOffsetY:e.labelOffsetY??n.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 n=this.nodes.get(e);n&&(n.isPipelineParent=!0)}addPipelineComponent(e,n){const r=this.pipelines.get(e);r&&r.componentIds.push(n);const h=this.nodes.get(n);h&&(h.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,n){this.annotationsBox={x:e,y:n}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,n){this.size={width:e,height:n}}getNode(e){return this.nodes.get(e)}resolveNodeId(e){if(this.nodes.has(e))return e;for(const[n,r]of this.nodes)if(r.label===e)return n;return e}build(){const e=[];for(const n of this.nodes.values()){if(typeof n.x!="number"||typeof n.y!="number")throw new Error(`Node "${n.label}" is missing coordinates`);e.push(n)}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 At;function tt(){return C.getConfig2()["wardley-beta"]}u.__name(tt,"getConfig");function et(e,n,r,h,a,l,y,v,g){k.addNode({id:e,label:n,x:r,y:h,className:a,labelOffsetX:l,labelOffsetY:y,inertia:v,sourceStrategy:g})}u.__name(et,"addNode");function at(e,n,r=!1,h,a){k.addLink({source:e,target:n,dashed:r,label:h,flow:a})}u.__name(at,"addLink");function rt(e,n,r){k.addTrend({nodeId:e,targetX:n,targetY:r})}u.__name(rt,"addTrend");function ot(e,n,r){k.addAnnotation({number:e,coordinates:n,text:r})}u.__name(ot,"addAnnotation");function nt(e,n,r){k.addNote({text:e,x:n,y:r})}u.__name(nt,"addNote");function st(e,n,r){k.addAccelerator({name:e,x:n,y:r})}u.__name(st,"addAccelerator");function it(e,n,r){k.addDeaccelerator({name:e,x:n,y:r})}u.__name(it,"addDeaccelerator");function lt(e,n){k.setAnnotationsBox(e,n)}u.__name(lt,"setAnnotationsBox");function dt(e,n){k.setSize(e,n)}u.__name(dt,"setSize");function ct(e){k.startPipeline(e)}u.__name(ct,"startPipeline");function pt(e,n){k.addPipelineComponent(e,n)}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 Lt={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},zt=["Genesis","Custom Built","Product","Commodity"],Et=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"),Xt=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:Q,db:Lt,renderer:{draw:u.__name((e,n,r,h)=>{U.log.debug(`Rendering Wardley map
`+e);const a=Xt(),l=Et(),y=a.nodeRadius*1.6,v=h.db,g=v.getWardleyData(),F=v.getDiagramTitle(),S=g.size?.width??a.width,b=g.size?.height??a.height,X=vt.selectSvgElement(n);X.selectAll("*").remove(),C.configureSvgSize(X,b,S,a.useMaxWidth),X.attr("viewBox",`0 0 ${S} ${b}`);const _=X.append("g").attr("class","wardley-map"),D=X.append("defs");D.append("marker").attr("id",`arrow-${n}`).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-${n}`).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-${n}`).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-a.padding*2,I=b-a.padding*2;F&&_.append("text").attr("class","wardley-title").attr("x",S/2).attr("y",a.padding/2).attr("fill",l.axisTextColor).attr("font-size",a.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(F);const N=u.__name(t=>a.padding+t/100*Y,"projectX"),T=u.__name(t=>b-a.padding-t/100*I,"projectY"),q=_.append("g").attr("class","wardley-axes");q.append("line").attr("x1",a.padding).attr("x2",S-a.padding).attr("y1",b-a.padding).attr("y2",b-a.padding).attr("stroke",l.axisColor).attr("stroke-width",1),q.append("line").attr("x1",a.padding).attr("x2",a.padding).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke",l.axisColor).attr("stroke-width",1);const yt=g.axes.xLabel??"Evolution",mt=g.axes.yLabel??"Visibility";q.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",a.padding+Y/2).attr("y",b-a.padding/4).attr("fill",l.axisTextColor).attr("font-size",a.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(yt),q.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",a.padding/3).attr("y",a.padding+I/2).attr("fill",l.axisTextColor).attr("font-size",a.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${a.padding/3} ${a.padding+I/2})`).text(mt);const B=g.axes.stages&&g.axes.stages.length>0?g.axes.stages:zt;if(B.length>0){const t=_.append("g").attr("class","wardley-stages"),s=g.axes.stageBoundaries,o=[];if(s&&s.length===B.length){let i=0;s.forEach(d=>{o.push({start:i,end:d}),i=d})}else{const i=1/B.length;B.forEach((d,c)=>{o.push({start:c*i,end:(c+1)*i})})}B.forEach((i,d)=>{const c=o[d],f=a.padding+c.start*Y,x=(f+(a.padding+c.end*Y))/2;d>0&&t.append("line").attr("x1",f).attr("x2",f).attr("y1",a.padding).attr("y2",b-a.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",x).attr("y",b-a.padding/1.5).attr("fill",l.axisTextColor).attr("font-size",a.axisFontSize-2).attr("text-anchor","middle").text(i)})}if(a.showGrid){const t=_.append("g").attr("class","wardley-grid");for(let s=1;s<4;s++){const o=s/4,i=a.padding+Y*o;t.append("line").attr("x1",i).attr("x2",i).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke",l.gridColor).attr("stroke-dasharray","2 6"),t.append("line").attr("x1",a.padding).attr("x2",S-a.padding).attr("y1",b-a.padding-I*o).attr("y2",b-a.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:N(t.x),y:T(t.y),node:t})}),g.pipelines.length>0){const t=_.append("g").attr("class","wardley-pipelines"),s=_.append("g").attr("class","wardley-pipeline-links");g.pipelines.forEach(o=>{if(o.componentIds.length===0)return;const i=o.componentIds.map(x=>({id:x,pos:p.get(x),node:g.nodes.find(m=>m.id===x)})).filter(x=>x.pos&&x.node).sort((x,m)=>x.node.x-m.node.x);for(let x=0;x<i.length-1;x++){const m=i[x],w=i[x+1];s.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(x=>{const m=p.get(x);m&&(d=Math.min(d,m.x),c=Math.max(c,m.x),f=m.y)}),d!==1/0&&c!==-1/0){const m=a.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 s=p.get(t.source),o=p.get(t.target),i=g.nodes.find(x=>x.id===t.source).isPipelineParent?y/Math.sqrt(2):a.nodeRadius,d=o.x-s.x,c=o.y-s.y,f=Math.sqrt(d*d+c*c);return s.x+d/f*i}).attr("y1",t=>{const s=p.get(t.source),o=p.get(t.target),i=g.nodes.find(x=>x.id===t.source).isPipelineParent?y/Math.sqrt(2):a.nodeRadius,d=o.x-s.x,c=o.y-s.y,f=Math.sqrt(d*d+c*c);return s.y+c/f*i}).attr("x2",t=>{const s=p.get(t.source),o=p.get(t.target),i=g.nodes.find(x=>x.id===t.target).isPipelineParent?y/Math.sqrt(2):a.nodeRadius,d=s.x-o.x,c=s.y-o.y,f=Math.sqrt(d*d+c*c);return o.x+d/f*i}).attr("y2",t=>{const s=p.get(t.source),o=p.get(t.target),i=g.nodes.find(x=>x.id===t.target).isPipelineParent?y/Math.sqrt(2):a.nodeRadius,d=s.x-o.x,c=s.y-o.y,f=Math.sqrt(d*d+c*c);return o.y+c/f*i}).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-${n})`:null).attr("marker-start",t=>t.flow==="backward"||t.flow==="bidirectional"?`url(#link-arrow-start-${n})`:null),j.selectAll("text").data(Z.filter(t=>t.label)).enter().append("text").attr("class","wardley-link-label").attr("x",t=>{const s=p.get(t.source),o=p.get(t.target),i=(s.x+o.x)/2,d=o.y-s.y,c=o.x-s.x;return i+d/Math.sqrt(c*c+d*d)*8}).attr("y",t=>{const s=p.get(t.source),o=p.get(t.target),i=(s.y+o.y)/2,d=o.x-s.x,c=o.y-s.y,f=Math.sqrt(d*d+c*c);return i+-d/f*8}).attr("fill",l.axisTextColor).attr("font-size",a.labelFontSize).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("transform",t=>{const s=p.get(t.source),o=p.get(t.target),i=(s.x+o.x)/2,d=(s.y+o.y)/2,c=o.x-s.x,f=o.y-s.y,x=Math.sqrt(c*c+f*f),m=8,w=f/x,P=-c/x,z=i+w*m,W=d+P*m;let E=Math.atan2(f,c)*180/Math.PI;return(E>90||E<-90)&&(E+=180),`rotate(${E} ${z} ${W})`}).text(t=>t.label);const wt=_.append("g").attr("class","wardley-trends"),kt=g.trends.map(t=>{const s=p.get(t.nodeId);if(!s)return null;const o=N(t.targetX),i=T(t.targetY),d=o-s.x,c=i-s.y,f=Math.sqrt(d*d+c*c),x=a.nodeRadius+2;return{origin:s,targetX:o,targetY:i,adjustedX2:f>x?o-d/f*x:o,adjustedY2:f>x?i-c/f*x:i}}).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-${n})`);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",a.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",a.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",a.nodeRadius*2).attr("fill","#eee").attr("stroke","#000").attr("stroke-width",1);const A=M.filter(t=>t.sourceStrategy==="market");A.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",a.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",a.nodeRadius).attr("fill",l.componentFill).attr("stroke",l.componentStroke).attr("stroke-width",1);const G=a.nodeRadius*.7,$=a.nodeRadius*1.2;if(A.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),A.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),A.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),A.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),A.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),A.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 s=p.get(t.id);let o=t.isPipelineParent?y/2+15:a.nodeRadius+15;return t.sourceStrategy&&(o+=a.nodeRadius+10),s.x+o}).attr("y1",t=>{const s=p.get(t.id),o=t.isPipelineParent?y:a.nodeRadius*2;return s.y-o/2}).attr("x2",t=>{const s=p.get(t.id);let o=t.isPipelineParent?y/2+15:a.nodeRadius+15;return t.sourceStrategy&&(o+=a.nodeRadius+10),s.x+o}).attr("y2",t=>{const s=p.get(t.id),o=t.isPipelineParent?y:a.nodeRadius*2;return s.y+o/2}).attr("stroke",l.componentStroke).attr("stroke-width",6),M.append("text").attr("x",t=>{const s=p.get(t.id);if(t.className==="anchor")return t.labelOffsetX!==void 0?s.x+t.labelOffsetX:s.x;let o=a.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetX===void 0&&(o+=10);const i=t.labelOffsetX??o;return s.x+i}).attr("y",t=>{const s=p.get(t.id);if(t.className==="anchor")return t.labelOffsetY!==void 0?s.y+t.labelOffsetY:s.y-3;let o=-a.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetY===void 0&&(o-=10);const i=t.labelOffsetY??o;return s.y+i}).attr("class","wardley-node-label").attr("fill",t=>t.className==="evolved"?l.evolutionStroke:t.className==="anchor"?"#000":l.componentLabelColor).attr("font-size",a.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(s=>{const o=s.coordinates.map(i=>({x:N(i.x),y:T(i.y)}));if(o.length>1)for(let i=0;i<o.length-1;i++)t.append("line").attr("class","wardley-annotation-line").attr("x1",o[i].x).attr("y1",o[i].y).attr("x2",o[i+1].x).attr("y2",o[i+1].y).attr("stroke",l.axisColor).attr("stroke-width",1.5).attr("stroke-dasharray","4 4");o.forEach(i=>{const d=t.append("g").attr("class","wardley-annotation");d.append("circle").attr("cx",i.x).attr("cy",i.y).attr("r",10).attr("fill","white").attr("stroke",l.axisColor).attr("stroke-width",1.5),d.append("text").attr("x",i.x).attr("y",i.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",10).attr("fill",l.axisTextColor).attr("font-weight","bold").text(s.number)})}),g.annotationsBox){let s=N(g.annotationsBox.x),o=T(g.annotationsBox.y);const i=10,d=16,c=11,f=t.append("g").attr("class","wardley-annotations-box"),x=[...g.annotations].filter(w=>w.text).sort((w,P)=>w.number-P.number),m=[];if(x.forEach((w,P)=>{const z=f.append("text").attr("x",s+i).attr("y",o+i+(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(z)}),m.length>0){let w=0,P=0;m.forEach(H=>{const O=H.node(),Pt=O.getComputedTextLength();w=Math.max(w,Pt);const Ct=O.getBBox();P=Math.max(P,Ct.height)});const z=w+20+105,W=x.length*d+20+P/2,E=a.padding,bt=S-a.padding-z,$t=a.padding,_t=b-a.padding-W;s=Math.max(E,Math.min(s,bt)),o=Math.max($t,Math.min(o,_t)),m.forEach((H,O)=>{H.attr("x",s+i).attr("y",o+i+(O+1)*d)}),f.insert("rect","text").attr("x",s).attr("y",o).attr("width",z).attr("height",W).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(s=>{const o=N(s.x),i=T(s.y);t.append("text").attr("x",o).attr("y",i).attr("text-anchor","start").attr("font-size",11).attr("fill",l.axisTextColor).attr("font-weight","bold").text(s.text)})}if(g.accelerators.length>0){const t=_.append("g").attr("class","wardley-accelerators");g.accelerators.forEach(s=>{const o=N(s.x),i=T(s.y),d=60,c=30,f=20,x=`
M ${o} ${i-c/2}
L ${o+d-f} ${i-c/2}
L ${o+d-f} ${i-c/2-8}
L ${o+d} ${i}
L ${o+d-f} ${i+c/2+8}
L ${o+d-f} ${i+c/2}
L ${o} ${i+c/2}
Z
`;t.append("path").attr("d",x).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+d/2).attr("y",i+c/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",l.axisTextColor).attr("font-weight","bold").text(s.name)})}if(g.deaccelerators.length>0){const t=_.append("g").attr("class","wardley-deaccelerators");g.deaccelerators.forEach(s=>{const o=N(s.x),i=T(s.y),d=60,c=30,f=20,x=`
M ${o+d} ${i-c/2}
L ${o+f} ${i-c/2}
L ${o+f} ${i-c/2-8}
L ${o} ${i}
L ${o+f} ${i+c/2+8}
L ${o+f} ${i+c/2}
L ${o+d} ${i+c/2}
Z
`;t.append("path").attr("d",x).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+d/2).attr("y",i+c/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",l.axisTextColor).attr("font-weight","bold").text(s.name)})}},"draw")},styles:u.__name(({wardley:e}={})=>{const n=C.getThemeVariables3(),r=C.getConfig(),h=J.cleanAndMerge(n,r.themeVariables),a=J.cleanAndMerge(h.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;