import{c as F}from"./chunk-AEOMTBSW-B2mxm9r_.js";import{p as _}from"./treemap-KZPCXAKY-RU5UWGQG-kaNIxUTr.js";import{s as V}from"./chunk-TU3PZOEN-CzPipCr2.js";import{Z as U,K as X,Y as Z,X as J,V as Q,j as tt,m,p as u,i as et,e as rt,t as at,$ as ot,a as B,L as it,n as st,o as ct,w as nt}from"./mermaid.esm.min-BbAqstPk.js";import"./chunk-H3VCZNTA-nEiogkTg.js";import"./app-DTJ1dk4L.js";var f={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},dt=st.gitGraph,M=m(()=>it({...dt,...ct().gitGraph}),"getConfig"),c=new V(()=>{let e=M(),t=e.mainBranchName,o=e.mainBranchOrder;return{mainBranchName:t,commits:new Map,head:null,branchConfig:new Map([[t,{name:t,order:o}]]),branches:new Map([[t,null]]),currBranch:t,direction:"LR",seq:0,options:{}}});function G(){return nt({length:7})}m(G,"getID");function S(e,t){let o=Object.create(null);return e.reduce((i,r)=>{let a=t(r);return o[a]||(o[a]=!0,i.push(r)),i},[])}m(S,"uniqBy");var ht=m(function(e){c.records.direction=e},"setDirection"),mt=m(function(e){u.debug("options str",e),e=e?.trim(),e=e||"{}";try{c.records.options=JSON.parse(e)}catch(t){u.error("error while parsing gitGraph options",t.message)}},"setOptions"),lt=m(function(){return c.records.options},"getOptions"),$t=m(function(e){let t=e.msg,o=e.id,i=e.type,r=e.tags;u.info("commit",t,o,i,r),u.debug("Entering commit:",t,o,i,r);let a=M();o=B.sanitizeText(o,a),t=B.sanitizeText(t,a),r=r?.map(d=>B.sanitizeText(d,a));let h={id:o||c.records.seq+"-"+G(),message:t,seq:c.records.seq++,type:i??f.NORMAL,tags:r??[],parents:c.records.head==null?[]:[c.records.head.id],branch:c.records.currBranch};c.records.head=h,u.info("main branch",a.mainBranchName),c.records.commits.has(h.id)&&u.warn(`Commit ID ${h.id} already exists`),c.records.commits.set(h.id,h),c.records.branches.set(c.records.currBranch,h.id),u.debug("in pushCommit "+h.id)},"commit"),gt=m(function(e){let t=e.name,o=e.order;if(t=B.sanitizeText(t,M()),c.records.branches.has(t))throw new Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${t}")`);c.records.branches.set(t,c.records.head!=null?c.records.head.id:null),c.records.branchConfig.set(t,{name:t,order:o}),N(t),u.debug("in createBranch")},"branch"),yt=m(e=>{let t=e.branch,o=e.id,i=e.type,r=e.tags,a=M();t=B.sanitizeText(t,a),o&&(o=B.sanitizeText(o,a));let h=c.records.branches.get(c.records.currBranch),d=c.records.branches.get(t),s=h?c.records.commits.get(h):void 0,$=d?c.records.commits.get(d):void 0;if(s&&$&&s.branch===t)throw new Error(`Cannot merge branch '${t}' into itself.`);if(c.records.currBranch===t){let n=new Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw n.hash={text:`merge ${t}`,token:`merge ${t}`,expected:["branch abc"]},n}if(s===void 0||!s){let n=new Error(`Incorrect usage of "merge". Current branch (${c.records.currBranch})has no commits`);throw n.hash={text:`merge ${t}`,token:`merge ${t}`,expected:["commit"]},n}if(!c.records.branches.has(t)){let n=new Error('Incorrect usage of "merge". Branch to be merged ('+t+") does not exist");throw n.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`branch ${t}`]},n}if($===void 0||!$){let n=new Error('Incorrect usage of "merge". Branch to be merged ('+t+") has no commits");throw n.hash={text:`merge ${t}`,token:`merge ${t}`,expected:['"commit"']},n}if(s===$){let n=new Error('Incorrect usage of "merge". Both branches have same head');throw n.hash={text:`merge ${t}`,token:`merge ${t}`,expected:["branch abc"]},n}if(o&&c.records.commits.has(o)){let n=new Error('Incorrect usage of "merge". Commit with id:'+o+" already exists, use different custom id");throw n.hash={text:`merge ${t} ${o} ${i} ${r?.join(" ")}`,token:`merge ${t} ${o} ${i} ${r?.join(" ")}`,expected:[`merge ${t} ${o}_UNIQUE ${i} ${r?.join(" ")}`]},n}let l=d||"",y={id:o||`${c.records.seq}-${G()}`,message:`merged branch ${t} into ${c.records.currBranch}`,seq:c.records.seq++,parents:c.records.head==null?[]:[c.records.head.id,l],branch:c.records.currBranch,type:f.MERGE,customType:i,customId:!!o,tags:r??[]};c.records.head=y,c.records.commits.set(y.id,y),c.records.branches.set(c.records.currBranch,y.id),u.debug(c.records.branches),u.debug("in mergeBranch")},"merge"),pt=m(function(e){let t=e.id,o=e.targetId,i=e.tags,r=e.parent;u.debug("Entering cherryPick:",t,o,i);let a=M();if(t=B.sanitizeText(t,a),o=B.sanitizeText(o,a),i=i?.map(s=>B.sanitizeText(s,a)),r=B.sanitizeText(r,a),!t||!c.records.commits.has(t)){let s=new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw s.hash={text:`cherryPick ${t} ${o}`,token:`cherryPick ${t} ${o}`,expected:["cherry-pick abc"]},s}let h=c.records.commits.get(t);if(h===void 0||!h)throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(r&&!(Array.isArray(h.parents)&&h.parents.includes(r)))throw new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");let d=h.branch;if(h.type===f.MERGE&&!r)throw new Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");if(!o||!c.records.commits.has(o)){if(d===c.records.currBranch){let y=new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw y.hash={text:`cherryPick ${t} ${o}`,token:`cherryPick ${t} ${o}`,expected:["cherry-pick abc"]},y}let s=c.records.branches.get(c.records.currBranch);if(s===void 0||!s){let y=new Error(`Incorrect usage of "cherry-pick". Current branch (${c.records.currBranch})has no commits`);throw y.hash={text:`cherryPick ${t} ${o}`,token:`cherryPick ${t} ${o}`,expected:["cherry-pick abc"]},y}let $=c.records.commits.get(s);if($===void 0||!$){let y=new Error(`Incorrect usage of "cherry-pick". Current branch (${c.records.currBranch})has no commits`);throw y.hash={text:`cherryPick ${t} ${o}`,token:`cherryPick ${t} ${o}`,expected:["cherry-pick abc"]},y}let l={id:c.records.seq+"-"+G(),message:`cherry-picked ${h?.message} into ${c.records.currBranch}`,seq:c.records.seq++,parents:c.records.head==null?[]:[c.records.head.id,h.id],branch:c.records.currBranch,type:f.CHERRY_PICK,tags:i?i.filter(Boolean):[`cherry-pick:${h.id}${h.type===f.MERGE?`|parent:${r}`:""}`]};c.records.head=l,c.records.commits.set(l.id,l),c.records.branches.set(c.records.currBranch,l.id),u.debug(c.records.branches),u.debug("in cherryPick")}},"cherryPick"),N=m(function(e){if(e=B.sanitizeText(e,M()),c.records.branches.has(e)){c.records.currBranch=e;let t=c.records.branches.get(c.records.currBranch);t===void 0||!t?c.records.head=null:c.records.head=c.records.commits.get(t)??null}else{let t=new Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`);throw t.hash={text:`checkout ${e}`,token:`checkout ${e}`,expected:[`branch ${e}`]},t}},"checkout");function H(e,t,o){let i=e.indexOf(t);i===-1?e.push(o):e.splice(i,1,o)}m(H,"upsert");function z(e){let t=e.reduce((r,a)=>r.seq>a.seq?r:a,e[0]),o="";e.forEach(function(r){r===t?o+=" *":o+=" |"});let i=[o,t.id,t.seq];for(let r in c.records.branches)c.records.branches.get(r)===t.id&&i.push(r);if(u.debug(i.join(" ")),t.parents&&t.parents.length==2&&t.parents[0]&&t.parents[1]){let r=c.records.commits.get(t.parents[0]);H(e,t,r),t.parents[1]&&e.push(c.records.commits.get(t.parents[1]))}else{if(t.parents.length==0)return;if(t.parents[0]){let r=c.records.commits.get(t.parents[0]);H(e,t,r)}}e=S(e,r=>r.id),z(e)}m(z,"prettyPrintCommitHistory");var xt=m(function(){u.debug(c.records.commits);let e=j()[0];z([e])},"prettyPrint"),ft=m(function(){c.reset(),ot()},"clear"),ut=m(function(){return[...c.records.branchConfig.values()].map((e,t)=>e.order!==null&&e.order!==void 0?e:{...e,order:parseFloat(`0.${t}`)}).sort((e,t)=>(e.order??0)-(t.order??0)).map(({name:e})=>({name:e}))},"getBranchesAsObjArray"),bt=m(function(){return c.records.branches},"getBranches"),wt=m(function(){return c.records.commits},"getCommits"),j=m(function(){let e=[...c.records.commits.values()];return e.forEach(function(t){u.debug(t.id)}),e.sort((t,o)=>t.seq-o.seq),e},"getCommitsArray"),Bt=m(function(){return c.records.currBranch},"getCurrentBranch"),Et=m(function(){return c.records.direction},"getDirection"),Ct=m(function(){return c.records.head},"getHead"),W={commitType:f,getConfig:M,setDirection:ht,setOptions:mt,getOptions:lt,commit:$t,branch:gt,merge:yt,cherryPick:pt,checkout:N,prettyPrint:xt,clear:ft,getBranchesAsObjArray:ut,getBranches:bt,getCommits:wt,getCommitsArray:j,getCurrentBranch:Bt,getDirection:Et,getHead:Ct,setAccTitle:tt,getAccTitle:Q,getAccDescription:J,setAccDescription:Z,setDiagramTitle:X,getDiagramTitle:U},Lt=m((e,t)=>{F(e,t),e.dir&&t.setDirection(e.dir);for(let o of e.statements)kt(o,t)},"populate"),kt=m((e,t)=>{let o={Commit:m(i=>t.commit(Tt(i)),"Commit"),Branch:m(i=>t.branch(vt(i)),"Branch"),Merge:m(i=>t.merge(Mt(i)),"Merge"),Checkout:m(i=>t.checkout(Pt(i)),"Checkout"),CherryPicking:m(i=>t.cherryPick(Rt(i)),"CherryPicking")}[e.$type];o?o(e):u.error(`Unknown statement type: ${e.$type}`)},"parseStatement"),Tt=m(e=>({id:e.id,msg:e.message??"",type:e.type!==void 0?f[e.type]:f.NORMAL,tags:e.tags??void 0}),"parseCommit"),vt=m(e=>({name:e.name,order:e.order??0}),"parseBranch"),Mt=m(e=>({branch:e.branch,id:e.id??"",type:e.type!==void 0?f[e.type]:void 0,tags:e.tags??void 0}),"parseMerge"),Pt=m(e=>e.branch,"parseCheckout"),Rt=m(e=>({id:e.id,targetId:"",tags:e.tags?.length===0?void 0:e.tags,parent:e.parent}),"parseCherryPicking"),It={parse:m(async e=>{let t=await _("gitGraph",e);u.debug(t),Lt(t,W)},"parse")},k=10,T=40,E=4,C=2,v=8,b=new Map,w=new Map,A=30,P=new Map,O=[],L=0,p="LR",At=m(()=>{b.clear(),w.clear(),P.clear(),L=0,O=[],p="LR"},"clear"),K=m(e=>{let t=document.createElementNS("http://www.w3.org/2000/svg","text");return(typeof e=="string"?e.split(/\\n|\n|/gi):e).forEach(o=>{let i=document.createElementNS("http://www.w3.org/2000/svg","tspan");i.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),i.setAttribute("dy","1em"),i.setAttribute("x","0"),i.setAttribute("class","row"),i.textContent=o.trim(),t.appendChild(i)}),t},"drawText"),Y=m(e=>{let t,o,i;return p==="BT"?(o=m((r,a)=>r<=a,"comparisonFunc"),i=1/0):(o=m((r,a)=>r>=a,"comparisonFunc"),i=0),e.forEach(r=>{let a=p==="TB"||p=="BT"?w.get(r)?.y:w.get(r)?.x;a!==void 0&&o(a,i)&&(t=r,i=a)}),t},"findClosestParent"),Ot=m(e=>{let t="",o=1/0;return e.forEach(i=>{let r=w.get(i).y;r<=o&&(t=i,o=r)}),t||void 0},"findClosestParentBT"),Gt=m((e,t,o)=>{let i=o,r=o,a=[];e.forEach(h=>{let d=t.get(h);if(!d)throw new Error(`Commit not found for key ${h}`);d.parents.length?(i=Ht(d),r=Math.max(i,r)):a.push(d),zt(d,i)}),i=r,a.forEach(h=>{Dt(h,i,o)}),e.forEach(h=>{let d=t.get(h);if(d?.parents.length){let s=Ot(d.parents);i=w.get(s).y-T,i<=r&&(r=i);let $=b.get(d.branch).pos,l=i-k;w.set(d.id,{x:$,y:l})}})},"setParallelBTPos"),qt=m(e=>{let t=Y(e.parents.filter(i=>i!==null));if(!t)throw new Error(`Closest parent not found for commit ${e.id}`);let o=w.get(t)?.y;if(o===void 0)throw new Error(`Closest parent position not found for commit ${e.id}`);return o},"findClosestParentPos"),Ht=m(e=>qt(e)+T,"calculateCommitPosition"),zt=m((e,t)=>{let o=b.get(e.branch);if(!o)throw new Error(`Branch not found for commit ${e.id}`);let i=o.pos,r=t+k;return w.set(e.id,{x:i,y:r}),{x:i,y:r}},"setCommitPosition"),Dt=m((e,t,o)=>{let i=b.get(e.branch);if(!i)throw new Error(`Branch not found for commit ${e.id}`);let r=t+o,a=i.pos;w.set(e.id,{x:a,y:r})},"setRootPosition"),St=m((e,t,o,i,r,a)=>{if(a===f.HIGHLIGHT)e.append("rect").attr("x",o.x-10).attr("y",o.y-10).attr("width",20).attr("height",20).attr("class",`commit ${t.id} commit-highlight${r%v} ${i}-outer`),e.append("rect").attr("x",o.x-6).attr("y",o.y-6).attr("width",12).attr("height",12).attr("class",`commit ${t.id} commit${r%v} ${i}-inner`);else if(a===f.CHERRY_PICK)e.append("circle").attr("cx",o.x).attr("cy",o.y).attr("r",10).attr("class",`commit ${t.id} ${i}`),e.append("circle").attr("cx",o.x-3).attr("cy",o.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${t.id} ${i}`),e.append("circle").attr("cx",o.x+3).attr("cy",o.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${t.id} ${i}`),e.append("line").attr("x1",o.x+3).attr("y1",o.y+1).attr("x2",o.x).attr("y2",o.y-5).attr("stroke","#fff").attr("class",`commit ${t.id} ${i}`),e.append("line").attr("x1",o.x-3).attr("y1",o.y+1).attr("x2",o.x).attr("y2",o.y-5).attr("stroke","#fff").attr("class",`commit ${t.id} ${i}`);else{let h=e.append("circle");if(h.attr("cx",o.x),h.attr("cy",o.y),h.attr("r",t.type===f.MERGE?9:10),h.attr("class",`commit ${t.id} commit${r%v}`),a===f.MERGE){let d=e.append("circle");d.attr("cx",o.x),d.attr("cy",o.y),d.attr("r",6),d.attr("class",`commit ${i} ${t.id} commit${r%v}`)}a===f.REVERSE&&e.append("path").attr("d",`M ${o.x-5},${o.y-5}L${o.x+5},${o.y+5}M${o.x-5},${o.y+5}L${o.x+5},${o.y-5}`).attr("class",`commit ${i} ${t.id} commit${r%v}`)}},"drawCommitBullet"),Nt=m((e,t,o,i,r)=>{if(t.type!==f.CHERRY_PICK&&(t.customId&&t.type===f.MERGE||t.type!==f.MERGE)&&r.showCommitLabel){let a=e.append("g"),h=a.insert("rect").attr("class","commit-label-bkg"),d=a.append("text").attr("x",i).attr("y",o.y+25).attr("class","commit-label").text(t.id),s=d.node()?.getBBox();if(s&&(h.attr("x",o.posWithOffset-s.width/2-C).attr("y",o.y+13.5).attr("width",s.width+2*C).attr("height",s.height+2*C),p==="TB"||p==="BT"?(h.attr("x",o.x-(s.width+4*E+5)).attr("y",o.y-12),d.attr("x",o.x-(s.width+4*E)).attr("y",o.y+s.height-12)):d.attr("x",o.posWithOffset-s.width/2),r.rotateCommitLabel))if(p==="TB"||p==="BT")d.attr("transform","rotate(-45, "+o.x+", "+o.y+")"),h.attr("transform","rotate(-45, "+o.x+", "+o.y+")");else{let $=-7.5-(s.width+10)/25*9.5,l=10+s.width/25*8.5;a.attr("transform","translate("+$+", "+l+") rotate(-45, "+i+", "+o.y+")")}}},"drawCommitLabel"),jt=m((e,t,o,i)=>{if(t.tags.length>0){let r=0,a=0,h=0,d=[];for(let s of t.tags.reverse()){let $=e.insert("polygon"),l=e.append("circle"),y=e.append("text").attr("y",o.y-16-r).attr("class","tag-label").text(s),n=y.node()?.getBBox();if(!n)throw new Error("Tag bbox not found");a=Math.max(a,n.width),h=Math.max(h,n.height),y.attr("x",o.posWithOffset-n.width/2),d.push({tag:y,hole:l,rect:$,yOffset:r}),r+=20}for(let{tag:s,hole:$,rect:l,yOffset:y}of d){let n=h/2,g=o.y-19.2-y;if(l.attr("class","tag-label-bkg").attr("points",` ${i-a/2-E/2},${g+C} ${i-a/2-E/2},${g-C} ${o.posWithOffset-a/2-E},${g-n-C} ${o.posWithOffset+a/2+E},${g-n-C} ${o.posWithOffset+a/2+E},${g+n+C} ${o.posWithOffset-a/2-E},${g+n+C}`),$.attr("cy",g).attr("cx",i-a/2+E/2).attr("r",1.5).attr("class","tag-hole"),p==="TB"||p==="BT"){let x=i+y;l.attr("class","tag-label-bkg").attr("points",` ${o.x},${x+2} ${o.x},${x-2} ${o.x+k},${x-n-2} ${o.x+k+a+4},${x-n-2} ${o.x+k+a+4},${x+n+2} ${o.x+k},${x+n+2}`).attr("transform","translate(12,12) rotate(45, "+o.x+","+i+")"),$.attr("cx",o.x+E/2).attr("cy",x).attr("transform","translate(12,12) rotate(45, "+o.x+","+i+")"),s.attr("x",o.x+5).attr("y",x+3).attr("transform","translate(14,14) rotate(45, "+o.x+","+i+")")}}}},"drawCommitTags"),Wt=m(e=>{switch(e.customType??e.type){case f.NORMAL:return"commit-normal";case f.REVERSE:return"commit-reverse";case f.HIGHLIGHT:return"commit-highlight";case f.MERGE:return"commit-merge";case f.CHERRY_PICK:return"commit-cherry-pick";default:return"commit-normal"}},"getCommitClassType"),Kt=m((e,t,o,i)=>{let r={x:0,y:0};if(e.parents.length>0){let a=Y(e.parents);if(a){let h=i.get(a)??r;return t==="TB"?h.y+T:t==="BT"?(i.get(e.id)??r).y-T:h.x+T}}else return t==="TB"?A:t==="BT"?(i.get(e.id)??r).y-T:0;return 0},"calculatePosition"),Yt=m((e,t,o)=>{let i=p==="BT"&&o?t:t+k,r=p==="TB"||p==="BT"?i:b.get(e.branch)?.pos,a=p==="TB"||p==="BT"?b.get(e.branch)?.pos:i;if(a===void 0||r===void 0)throw new Error(`Position were undefined for commit ${e.id}`);return{x:a,y:r,posWithOffset:i}},"getCommitPosition"),D=m((e,t,o,i)=>{let r=e.append("g").attr("class","commit-bullets"),a=e.append("g").attr("class","commit-labels"),h=p==="TB"||p==="BT"?A:0,d=[...t.keys()],s=i.parallelCommits??!1,$=m((y,n)=>{let g=t.get(y)?.seq,x=t.get(n)?.seq;return g!==void 0&&x!==void 0?g-x:0},"sortKeys"),l=d.sort($);p==="BT"&&(s&&Gt(l,t,h),l=l.reverse()),l.forEach(y=>{let n=t.get(y);if(!n)throw new Error(`Commit not found for key ${y}`);s&&(h=Kt(n,p,h,w));let g=Yt(n,h,s);if(o){let x=Wt(n),I=n.customType??n.type,q=b.get(n.branch)?.index??0;St(r,n,g,x,q,I),Nt(a,n,g,h,i),jt(a,n,g,h)}p==="TB"||p==="BT"?w.set(n.id,{x:g.x,y:g.posWithOffset}):w.set(n.id,{x:g.posWithOffset,y:g.y}),h=p==="BT"&&s?h+T:h+T+k,h>L&&(L=h)})},"drawCommits"),Ft=m((e,t,o,i,r)=>{let a=(p==="TB"||p==="BT"?o.xs.branch===a,"isOnBranchToGetCurve"),d=m(s=>s.seq>e.seq&&s.seqd(s)&&h(s))},"shouldRerouteArrow"),R=m((e,t,o=0)=>{let i=e+Math.abs(e-t)/2;if(o>5)return i;if(O.every(a=>Math.abs(a-i)>=10))return O.push(i),i;let r=Math.abs(e-t);return R(e,t-r/5,o+1)},"findLane"),_t=m((e,t,o,i)=>{let r=w.get(t.id),a=w.get(o.id);if(r===void 0||a===void 0)throw new Error(`Commit positions not found for commits ${t.id} and ${o.id}`);let h=Ft(t,o,r,a,i),d="",s="",$=0,l=0,y=b.get(o.branch)?.index;o.type===f.MERGE&&t.id!==o.parents[0]&&(y=b.get(t.branch)?.index);let n;if(h){d="A 10 10, 0, 0, 0,",s="A 10 10, 0, 0, 1,",$=10,l=10;let g=r.ya.x&&(d="A 20 20, 0, 0, 0,",s="A 20 20, 0, 0, 1,",$=20,l=20,o.type===f.MERGE&&t.id!==o.parents[0]?n=`M ${r.x} ${r.y} L ${r.x} ${a.y-$} ${s} ${r.x-l} ${a.y} L ${a.x} ${a.y}`:n=`M ${r.x} ${r.y} L ${a.x+$} ${r.y} ${d} ${a.x} ${r.y+l} L ${a.x} ${a.y}`),r.x===a.x&&(n=`M ${r.x} ${r.y} L ${a.x} ${a.y}`)):p==="BT"?(r.xa.x&&(d="A 20 20, 0, 0, 0,",s="A 20 20, 0, 0, 1,",$=20,l=20,o.type===f.MERGE&&t.id!==o.parents[0]?n=`M ${r.x} ${r.y} L ${r.x} ${a.y+$} ${d} ${r.x-l} ${a.y} L ${a.x} ${a.y}`:n=`M ${r.x} ${r.y} L ${a.x+$} ${r.y} ${s} ${a.x} ${r.y-l} L ${a.x} ${a.y}`),r.x===a.x&&(n=`M ${r.x} ${r.y} L ${a.x} ${a.y}`)):(r.ya.y&&(o.type===f.MERGE&&t.id!==o.parents[0]?n=`M ${r.x} ${r.y} L ${a.x-$} ${r.y} ${d} ${a.x} ${r.y-l} L ${a.x} ${a.y}`:n=`M ${r.x} ${r.y} L ${r.x} ${a.y+$} ${s} ${r.x+l} ${a.y} L ${a.x} ${a.y}`),r.y===a.y&&(n=`M ${r.x} ${r.y} L ${a.x} ${a.y}`));if(n===void 0)throw new Error("Line definition not found");e.append("path").attr("d",n).attr("class","arrow arrow"+y%v)},"drawArrow"),Vt=m((e,t)=>{let o=e.append("g").attr("class","commit-arrows");[...t.keys()].forEach(i=>{let r=t.get(i);r.parents&&r.parents.length>0&&r.parents.forEach(a=>{_t(o,t.get(a),r,t)})})},"drawArrows"),Ut=m((e,t,o)=>{let i=e.append("g");t.forEach((r,a)=>{let h=a%v,d=b.get(r.name)?.pos;if(d===void 0)throw new Error(`Position not found for branch ${r.name}`);let s=i.append("line");s.attr("x1",0),s.attr("y1",d),s.attr("x2",L),s.attr("y2",d),s.attr("class","branch branch"+h),p==="TB"?(s.attr("y1",A),s.attr("x1",d),s.attr("y2",L),s.attr("x2",d)):p==="BT"&&(s.attr("y1",L),s.attr("x1",d),s.attr("y2",A),s.attr("x2",d)),O.push(d);let $=r.name,l=K($),y=i.insert("rect"),n=i.insert("g").attr("class","branchLabel").insert("g").attr("class","label branch-label"+h);n.node().appendChild(l);let g=l.getBBox();y.attr("class","branchLabelBkg label"+h).attr("rx",4).attr("ry",4).attr("x",-g.width-4-(o.rotateCommitLabel===!0?30:0)).attr("y",-g.height/2+8).attr("width",g.width+18).attr("height",g.height+4),n.attr("transform","translate("+(-g.width-14-(o.rotateCommitLabel===!0?30:0))+", "+(d-g.height/2-1)+")"),p==="TB"?(y.attr("x",d-g.width/2-10).attr("y",0),n.attr("transform","translate("+(d-g.width/2-5)+", 0)")):p==="BT"?(y.attr("x",d-g.width/2-10).attr("y",L),n.attr("transform","translate("+(d-g.width/2-5)+", "+L+")")):y.attr("transform","translate(-19, "+(d-g.height/2)+")")})},"drawBranches"),Xt=m(function(e,t,o,i,r){return b.set(e,{pos:t,index:o}),t+=50+(r?40:0)+(p==="TB"||p==="BT"?i.width/2:0),t},"setBranchPosition"),Zt=m(function(e,t,o,i){At(),u.debug("in gitgraph renderer",e+` `,"id:",t,o);let r=i.db;if(!r.getConfig){u.error("getConfig method is not available on db");return}let a=r.getConfig(),h=a.rotateCommitLabel??!1;P=r.getCommits();let d=r.getBranchesAsObjArray();p=r.getDirection();let s=et(`[id="${t}"]`),$=0;d.forEach((l,y)=>{let n=K(l.name),g=s.append("g"),x=g.insert("g").attr("class","branchLabel"),I=x.insert("g").attr("class","label branch-label");I.node()?.appendChild(n);let q=n.getBBox();$=Xt(l.name,$,y,q,h),I.remove(),x.remove(),g.remove()}),D(s,P,!1,a),a.showBranches&&Ut(s,d,a),Vt(s,P),D(s,P,!0,a),rt.insertTitle(s,"gitTitleText",a.titleTopMargin??0,r.getDiagramTitle()),at(void 0,s,a.diagramPadding,a.useMaxWidth)},"draw"),Jt={draw:Zt},Qt=m(e=>` .commit-id, .commit-msg, .branch-label { fill: lightgrey; color: lightgrey; font-family: 'trebuchet ms', verdana, arial, sans-serif; font-family: var(--mermaid-font-family); } ${[0,1,2,3,4,5,6,7].map(t=>` .branch-label${t} { fill: ${e["gitBranchLabel"+t]}; } .commit${t} { stroke: ${e["git"+t]}; fill: ${e["git"+t]}; } .commit-highlight${t} { stroke: ${e["gitInv"+t]}; fill: ${e["gitInv"+t]}; } .label${t} { fill: ${e["git"+t]}; } .arrow${t} { stroke: ${e["git"+t]}; } `).join(` `)} .branch { stroke-width: 1; stroke: ${e.lineColor}; stroke-dasharray: 2; } .commit-label { font-size: ${e.commitLabelFontSize}; fill: ${e.commitLabelColor};} .commit-label-bkg { font-size: ${e.commitLabelFontSize}; fill: ${e.commitLabelBackground}; opacity: 0.5; } .tag-label { font-size: ${e.tagLabelFontSize}; fill: ${e.tagLabelColor};} .tag-label-bkg { fill: ${e.tagLabelBackground}; stroke: ${e.tagLabelBorder}; } .tag-hole { fill: ${e.textColor}; } .commit-merge { stroke: ${e.primaryColor}; fill: ${e.primaryColor}; } .commit-reverse { stroke: ${e.primaryColor}; fill: ${e.primaryColor}; stroke-width: 3; } .commit-highlight-outer { } .commit-highlight-inner { stroke: ${e.primaryColor}; fill: ${e.primaryColor}; } .arrow { stroke-width: 8; stroke-linecap: round; fill: none} .gitTitleText { text-anchor: middle; font-size: 18px; fill: ${e.textColor}; } `,"getStyles"),te=Qt,ce={parser:It,db:W,renderer:Jt,styles:te};export{ce as diagram};