Files
countbot-ai__countbot/frontend/dist/assets/js/gitGraphDiagram-K3NZZRJ6-DgVaw30m.js
T

66 lines
25 KiB
JavaScript

var er=Object.defineProperty,tr=Object.defineProperties;var ar=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var nr=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable;var S=(a,r,t)=>r in a?er(a,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[r]=t,P=(a,r)=>{for(var t in r||(r={}))nr.call(r,t)&&S(a,t,r[t]);if(W)for(var t of W(r))sr.call(r,t)&&S(a,t,r[t]);return a},j=(a,r)=>tr(a,ar(r));var Y=(a,r,t)=>new Promise((s,e)=>{var n=i=>{try{o(t.next(i))}catch(h){e(h)}},c=i=>{try{o(t.throw(i))}catch(h){e(h)}},o=i=>i.done?s(i.value):Promise.resolve(i.value).then(n,c);o((t=t.apply(a,r)).next())});import{p as or}from"./chunk-4BX2VUAB-B2pNyGEj.js";import{I as cr}from"./chunk-QZHKN3VN-D22FYu60.js";import{q as ir,p as dr,s as hr,g as lr,a as $r,b as fr,_ as l,l as w,d as yr,u as gr,D as xr,z as ur,k as T,E as pr,F as br,G as mr,H as wr}from"./mermaid.core-I0hlAH9H.js";import{p as vr}from"./treemap-KZPCXAKY-B9TZtgs7.js";import"./index-XQkOl0bk.js";import"./ChatWindow-N4atnSdm.js";import"./countbot-logo-CNglRKg-.js";import"./_baseUniq-BmBO8S86.js";import"./_basePickBy-Czakf3o4.js";import"./clone-FNhPvOrp.js";var p={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},Cr=br.gitGraph,q=l(()=>pr(P(P({},Cr),mr().gitGraph)),"getConfig"),d=new cr(()=>{const a=q(),r=a.mainBranchName,t=a.mainBranchOrder;return{mainBranchName:r,commits:new Map,head:null,branchConfig:new Map([[r,{name:r,order:t}]]),branches:new Map([[r,null]]),currBranch:r,direction:"LR",seq:0,options:{}}});function D(){return wr({length:7})}l(D,"getID");function U(a,r){const t=Object.create(null);return a.reduce((s,e)=>{const n=r(e);return t[n]||(t[n]=!0,s.push(e)),s},[])}l(U,"uniqBy");var Er=l(function(a){d.records.direction=a},"setDirection"),Br=l(function(a){w.debug("options str",a),a=a==null?void 0:a.trim(),a=a||"{}";try{d.records.options=JSON.parse(a)}catch(r){w.error("error while parsing gitGraph options",r.message)}},"setOptions"),Lr=l(function(){return d.records.options},"getOptions"),Tr=l(function(a){let r=a.msg,t=a.id;const s=a.type;let e=a.tags;w.info("commit",r,t,s,e),w.debug("Entering commit:",r,t,s,e);const n=q();t=T.sanitizeText(t,n),r=T.sanitizeText(r,n),e=e==null?void 0:e.map(o=>T.sanitizeText(o,n));const c={id:t||d.records.seq+"-"+D(),message:r,seq:d.records.seq++,type:s!=null?s:p.NORMAL,tags:e!=null?e:[],parents:d.records.head==null?[]:[d.records.head.id],branch:d.records.currBranch};d.records.head=c,w.info("main branch",n.mainBranchName),d.records.commits.has(c.id)&&w.warn(`Commit ID ${c.id} already exists`),d.records.commits.set(c.id,c),d.records.branches.set(d.records.currBranch,c.id),w.debug("in pushCommit "+c.id)},"commit"),kr=l(function(a){let r=a.name;const t=a.order;if(r=T.sanitizeText(r,q()),d.records.branches.has(r))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 ${r}")`);d.records.branches.set(r,d.records.head!=null?d.records.head.id:null),d.records.branchConfig.set(r,{name:r,order:t}),V(r),w.debug("in createBranch")},"branch"),Mr=l(a=>{let r=a.branch,t=a.id;const s=a.type,e=a.tags,n=q();r=T.sanitizeText(r,n),t&&(t=T.sanitizeText(t,n));const c=d.records.branches.get(d.records.currBranch),o=d.records.branches.get(r),i=c?d.records.commits.get(c):void 0,h=o?d.records.commits.get(o):void 0;if(i&&h&&i.branch===r)throw new Error(`Cannot merge branch '${r}' into itself.`);if(d.records.currBranch===r){const $=new Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw $.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},$}if(i===void 0||!i){const $=new Error(`Incorrect usage of "merge". Current branch (${d.records.currBranch})has no commits`);throw $.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["commit"]},$}if(!d.records.branches.has(r)){const $=new Error('Incorrect usage of "merge". Branch to be merged ('+r+") does not exist");throw $.hash={text:`merge ${r}`,token:`merge ${r}`,expected:[`branch ${r}`]},$}if(h===void 0||!h){const $=new Error('Incorrect usage of "merge". Branch to be merged ('+r+") has no commits");throw $.hash={text:`merge ${r}`,token:`merge ${r}`,expected:['"commit"']},$}if(i===h){const $=new Error('Incorrect usage of "merge". Both branches have same head');throw $.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},$}if(t&&d.records.commits.has(t)){const $=new Error('Incorrect usage of "merge". Commit with id:'+t+" already exists, use different custom id");throw $.hash={text:`merge ${r} ${t} ${s} ${e==null?void 0:e.join(" ")}`,token:`merge ${r} ${t} ${s} ${e==null?void 0:e.join(" ")}`,expected:[`merge ${r} ${t}_UNIQUE ${s} ${e==null?void 0:e.join(" ")}`]},$}const f=o||"",g={id:t||`${d.records.seq}-${D()}`,message:`merged branch ${r} into ${d.records.currBranch}`,seq:d.records.seq++,parents:d.records.head==null?[]:[d.records.head.id,f],branch:d.records.currBranch,type:p.MERGE,customType:s,customId:!!t,tags:e!=null?e:[]};d.records.head=g,d.records.commits.set(g.id,g),d.records.branches.set(d.records.currBranch,g.id),w.debug(d.records.branches),w.debug("in mergeBranch")},"merge"),Ir=l(function(a){let r=a.id,t=a.targetId,s=a.tags,e=a.parent;w.debug("Entering cherryPick:",r,t,s);const n=q();if(r=T.sanitizeText(r,n),t=T.sanitizeText(t,n),s=s==null?void 0:s.map(i=>T.sanitizeText(i,n)),e=T.sanitizeText(e,n),!r||!d.records.commits.has(r)){const i=new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw i.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},i}const c=d.records.commits.get(r);if(c===void 0||!c)throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(e&&!(Array.isArray(c.parents)&&c.parents.includes(e)))throw new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");const o=c.branch;if(c.type===p.MERGE&&!e)throw new Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");if(!t||!d.records.commits.has(t)){if(o===d.records.currBranch){const g=new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw g.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},g}const i=d.records.branches.get(d.records.currBranch);if(i===void 0||!i){const g=new Error(`Incorrect usage of "cherry-pick". Current branch (${d.records.currBranch})has no commits`);throw g.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},g}const h=d.records.commits.get(i);if(h===void 0||!h){const g=new Error(`Incorrect usage of "cherry-pick". Current branch (${d.records.currBranch})has no commits`);throw g.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},g}const f={id:d.records.seq+"-"+D(),message:`cherry-picked ${c==null?void 0:c.message} into ${d.records.currBranch}`,seq:d.records.seq++,parents:d.records.head==null?[]:[d.records.head.id,c.id],branch:d.records.currBranch,type:p.CHERRY_PICK,tags:s?s.filter(Boolean):[`cherry-pick:${c.id}${c.type===p.MERGE?`|parent:${e}`:""}`]};d.records.head=f,d.records.commits.set(f.id,f),d.records.branches.set(d.records.currBranch,f.id),w.debug(d.records.branches),w.debug("in cherryPick")}},"cherryPick"),V=l(function(a){var r;if(a=T.sanitizeText(a,q()),d.records.branches.has(a)){d.records.currBranch=a;const t=d.records.branches.get(d.records.currBranch);t===void 0||!t?d.records.head=null:d.records.head=(r=d.records.commits.get(t))!=null?r:null}else{const t=new Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${a}")`);throw t.hash={text:`checkout ${a}`,token:`checkout ${a}`,expected:[`branch ${a}`]},t}},"checkout");function F(a,r,t){const s=a.indexOf(r);s===-1?a.push(t):a.splice(s,1,t)}l(F,"upsert");function N(a){const r=a.reduce((e,n)=>e.seq>n.seq?e:n,a[0]);let t="";a.forEach(function(e){e===r?t+=" *":t+=" |"});const s=[t,r.id,r.seq];for(const e in d.records.branches)d.records.branches.get(e)===r.id&&s.push(e);if(w.debug(s.join(" ")),r.parents&&r.parents.length==2&&r.parents[0]&&r.parents[1]){const e=d.records.commits.get(r.parents[0]);F(a,r,e),r.parents[1]&&a.push(d.records.commits.get(r.parents[1]))}else{if(r.parents.length==0)return;if(r.parents[0]){const e=d.records.commits.get(r.parents[0]);F(a,r,e)}}a=U(a,e=>e.id),N(a)}l(N,"prettyPrintCommitHistory");var Rr=l(function(){w.debug(d.records.commits);const a=X()[0];N([a])},"prettyPrint"),Gr=l(function(){d.reset(),ur()},"clear"),Or=l(function(){return[...d.records.branchConfig.values()].map((r,t)=>r.order!==null&&r.order!==void 0?r:j(P({},r),{order:parseFloat(`0.${t}`)})).sort((r,t)=>{var s,e;return((s=r.order)!=null?s:0)-((e=t.order)!=null?e:0)}).map(({name:r})=>({name:r}))},"getBranchesAsObjArray"),qr=l(function(){return d.records.branches},"getBranches"),Hr=l(function(){return d.records.commits},"getCommits"),X=l(function(){const a=[...d.records.commits.values()];return a.forEach(function(r){w.debug(r.id)}),a.sort((r,t)=>r.seq-t.seq),a},"getCommitsArray"),Ar=l(function(){return d.records.currBranch},"getCurrentBranch"),Pr=l(function(){return d.records.direction},"getDirection"),_r=l(function(){return d.records.head},"getHead"),J={commitType:p,getConfig:q,setDirection:Er,setOptions:Br,getOptions:Lr,commit:Tr,branch:kr,merge:Mr,cherryPick:Ir,checkout:V,prettyPrint:Rr,clear:Gr,getBranchesAsObjArray:Or,getBranches:qr,getCommits:Hr,getCommitsArray:X,getCurrentBranch:Ar,getDirection:Pr,getHead:_r,setAccTitle:fr,getAccTitle:$r,getAccDescription:lr,setAccDescription:hr,setDiagramTitle:dr,getDiagramTitle:ir},zr=l((a,r)=>{or(a,r),a.dir&&r.setDirection(a.dir);for(const t of a.statements)Dr(t,r)},"populate"),Dr=l((a,r)=>{const s={Commit:l(e=>r.commit(Fr(e)),"Commit"),Branch:l(e=>r.branch(Nr(e)),"Branch"),Merge:l(e=>r.merge(Wr(e)),"Merge"),Checkout:l(e=>r.checkout(Sr(e)),"Checkout"),CherryPicking:l(e=>r.cherryPick(jr(e)),"CherryPicking")}[a.$type];s?s(a):w.error(`Unknown statement type: ${a.$type}`)},"parseStatement"),Fr=l(a=>{var t,s;return{id:a.id,msg:(t=a.message)!=null?t:"",type:a.type!==void 0?p[a.type]:p.NORMAL,tags:(s=a.tags)!=null?s:void 0}},"parseCommit"),Nr=l(a=>{var t;return{name:a.name,order:(t=a.order)!=null?t:0}},"parseBranch"),Wr=l(a=>{var t,s;return{branch:a.branch,id:(t=a.id)!=null?t:"",type:a.type!==void 0?p[a.type]:void 0,tags:(s=a.tags)!=null?s:void 0}},"parseMerge"),Sr=l(a=>a.branch,"parseCheckout"),jr=l(a=>{var t;return{id:a.id,targetId:"",tags:((t=a.tags)==null?void 0:t.length)===0?void 0:a.tags,parent:a.parent}},"parseCherryPicking"),Yr={parse:l(a=>Y(void 0,null,function*(){const r=yield vr("gitGraph",a);w.debug(r),zr(r,J)}),"parse")},R=10,G=40,k=4,M=2,O=8,v=new Map,C=new Map,_=30,H=new Map,z=[],I=0,u="LR",Kr=l(()=>{v.clear(),C.clear(),H.clear(),I=0,z=[],u="LR"},"clear"),Q=l(a=>{const r=document.createElementNS("http://www.w3.org/2000/svg","text");return(typeof a=="string"?a.split(/\\n|\n|<br\s*\/?>/gi):a).forEach(s=>{const e=document.createElementNS("http://www.w3.org/2000/svg","tspan");e.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),e.setAttribute("dy","1em"),e.setAttribute("x","0"),e.setAttribute("class","row"),e.textContent=s.trim(),r.appendChild(e)}),r},"drawText"),Z=l(a=>{let r,t,s;return u==="BT"?(t=l((e,n)=>e<=n,"comparisonFunc"),s=1/0):(t=l((e,n)=>e>=n,"comparisonFunc"),s=0),a.forEach(e=>{var c,o;const n=u==="TB"||u=="BT"?(c=C.get(e))==null?void 0:c.y:(o=C.get(e))==null?void 0:o.x;n!==void 0&&t(n,s)&&(r=e,s=n)}),r},"findClosestParent"),Ur=l(a=>{let r="",t=1/0;return a.forEach(s=>{const e=C.get(s).y;e<=t&&(r=s,t=e)}),r||void 0},"findClosestParentBT"),Vr=l((a,r,t)=>{let s=t,e=t;const n=[];a.forEach(c=>{const o=r.get(c);if(!o)throw new Error(`Commit not found for key ${c}`);o.parents.length?(s=Jr(o),e=Math.max(s,e)):n.push(o),Qr(o,s)}),s=e,n.forEach(c=>{Zr(c,s,t)}),a.forEach(c=>{const o=r.get(c);if(o!=null&&o.parents.length){const i=Ur(o.parents);s=C.get(i).y-G,s<=e&&(e=s);const h=v.get(o.branch).pos,f=s-R;C.set(o.id,{x:h,y:f})}})},"setParallelBTPos"),Xr=l(a=>{var s;const r=Z(a.parents.filter(e=>e!==null));if(!r)throw new Error(`Closest parent not found for commit ${a.id}`);const t=(s=C.get(r))==null?void 0:s.y;if(t===void 0)throw new Error(`Closest parent position not found for commit ${a.id}`);return t},"findClosestParentPos"),Jr=l(a=>Xr(a)+G,"calculateCommitPosition"),Qr=l((a,r)=>{const t=v.get(a.branch);if(!t)throw new Error(`Branch not found for commit ${a.id}`);const s=t.pos,e=r+R;return C.set(a.id,{x:s,y:e}),{x:s,y:e}},"setCommitPosition"),Zr=l((a,r,t)=>{const s=v.get(a.branch);if(!s)throw new Error(`Branch not found for commit ${a.id}`);const e=r+t,n=s.pos;C.set(a.id,{x:n,y:e})},"setRootPosition"),re=l((a,r,t,s,e,n)=>{if(n===p.HIGHLIGHT)a.append("rect").attr("x",t.x-10).attr("y",t.y-10).attr("width",20).attr("height",20).attr("class",`commit ${r.id} commit-highlight${e%O} ${s}-outer`),a.append("rect").attr("x",t.x-6).attr("y",t.y-6).attr("width",12).attr("height",12).attr("class",`commit ${r.id} commit${e%O} ${s}-inner`);else if(n===p.CHERRY_PICK)a.append("circle").attr("cx",t.x).attr("cy",t.y).attr("r",10).attr("class",`commit ${r.id} ${s}`),a.append("circle").attr("cx",t.x-3).attr("cy",t.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${r.id} ${s}`),a.append("circle").attr("cx",t.x+3).attr("cy",t.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${r.id} ${s}`),a.append("line").attr("x1",t.x+3).attr("y1",t.y+1).attr("x2",t.x).attr("y2",t.y-5).attr("stroke","#fff").attr("class",`commit ${r.id} ${s}`),a.append("line").attr("x1",t.x-3).attr("y1",t.y+1).attr("x2",t.x).attr("y2",t.y-5).attr("stroke","#fff").attr("class",`commit ${r.id} ${s}`);else{const c=a.append("circle");if(c.attr("cx",t.x),c.attr("cy",t.y),c.attr("r",r.type===p.MERGE?9:10),c.attr("class",`commit ${r.id} commit${e%O}`),n===p.MERGE){const o=a.append("circle");o.attr("cx",t.x),o.attr("cy",t.y),o.attr("r",6),o.attr("class",`commit ${s} ${r.id} commit${e%O}`)}n===p.REVERSE&&a.append("path").attr("d",`M ${t.x-5},${t.y-5}L${t.x+5},${t.y+5}M${t.x-5},${t.y+5}L${t.x+5},${t.y-5}`).attr("class",`commit ${s} ${r.id} commit${e%O}`)}},"drawCommitBullet"),ee=l((a,r,t,s,e)=>{var n;if(r.type!==p.CHERRY_PICK&&(r.customId&&r.type===p.MERGE||r.type!==p.MERGE)&&e.showCommitLabel){const c=a.append("g"),o=c.insert("rect").attr("class","commit-label-bkg"),i=c.append("text").attr("x",s).attr("y",t.y+25).attr("class","commit-label").text(r.id),h=(n=i.node())==null?void 0:n.getBBox();if(h&&(o.attr("x",t.posWithOffset-h.width/2-M).attr("y",t.y+13.5).attr("width",h.width+2*M).attr("height",h.height+2*M),u==="TB"||u==="BT"?(o.attr("x",t.x-(h.width+4*k+5)).attr("y",t.y-12),i.attr("x",t.x-(h.width+4*k)).attr("y",t.y+h.height-12)):i.attr("x",t.posWithOffset-h.width/2),e.rotateCommitLabel))if(u==="TB"||u==="BT")i.attr("transform","rotate(-45, "+t.x+", "+t.y+")"),o.attr("transform","rotate(-45, "+t.x+", "+t.y+")");else{const f=-7.5-(h.width+10)/25*9.5,g=10+h.width/25*8.5;c.attr("transform","translate("+f+", "+g+") rotate(-45, "+s+", "+t.y+")")}}},"drawCommitLabel"),te=l((a,r,t,s)=>{var e;if(r.tags.length>0){let n=0,c=0,o=0;const i=[];for(const h of r.tags.reverse()){const f=a.insert("polygon"),g=a.append("circle"),$=a.append("text").attr("y",t.y-16-n).attr("class","tag-label").text(h),y=(e=$.node())==null?void 0:e.getBBox();if(!y)throw new Error("Tag bbox not found");c=Math.max(c,y.width),o=Math.max(o,y.height),$.attr("x",t.posWithOffset-y.width/2),i.push({tag:$,hole:g,rect:f,yOffset:n}),n+=20}for(const{tag:h,hole:f,rect:g,yOffset:$}of i){const y=o/2,x=t.y-19.2-$;if(g.attr("class","tag-label-bkg").attr("points",`
${s-c/2-k/2},${x+M}
${s-c/2-k/2},${x-M}
${t.posWithOffset-c/2-k},${x-y-M}
${t.posWithOffset+c/2+k},${x-y-M}
${t.posWithOffset+c/2+k},${x+y+M}
${t.posWithOffset-c/2-k},${x+y+M}`),f.attr("cy",x).attr("cx",s-c/2+k/2).attr("r",1.5).attr("class","tag-hole"),u==="TB"||u==="BT"){const b=s+$;g.attr("class","tag-label-bkg").attr("points",`
${t.x},${b+2}
${t.x},${b-2}
${t.x+R},${b-y-2}
${t.x+R+c+4},${b-y-2}
${t.x+R+c+4},${b+y+2}
${t.x+R},${b+y+2}`).attr("transform","translate(12,12) rotate(45, "+t.x+","+s+")"),f.attr("cx",t.x+k/2).attr("cy",b).attr("transform","translate(12,12) rotate(45, "+t.x+","+s+")"),h.attr("x",t.x+5).attr("y",b+3).attr("transform","translate(14,14) rotate(45, "+t.x+","+s+")")}}}},"drawCommitTags"),ae=l(a=>{var t;switch((t=a.customType)!=null?t:a.type){case p.NORMAL:return"commit-normal";case p.REVERSE:return"commit-reverse";case p.HIGHLIGHT:return"commit-highlight";case p.MERGE:return"commit-merge";case p.CHERRY_PICK:return"commit-cherry-pick";default:return"commit-normal"}},"getCommitClassType"),ne=l((a,r,t,s)=>{var n,c,o;const e={x:0,y:0};if(a.parents.length>0){const i=Z(a.parents);if(i){const h=(n=s.get(i))!=null?n:e;return r==="TB"?h.y+G:r==="BT"?((c=s.get(a.id))!=null?c:e).y-G:h.x+G}}else return r==="TB"?_:r==="BT"?((o=s.get(a.id))!=null?o:e).y-G:0;return 0},"calculatePosition"),se=l((a,r,t)=>{var c,o;const s=u==="BT"&&t?r:r+R,e=u==="TB"||u==="BT"?s:(c=v.get(a.branch))==null?void 0:c.pos,n=u==="TB"||u==="BT"?(o=v.get(a.branch))==null?void 0:o.pos:s;if(n===void 0||e===void 0)throw new Error(`Position were undefined for commit ${a.id}`);return{x:n,y:e,posWithOffset:s}},"getCommitPosition"),K=l((a,r,t,s)=>{var g;const e=a.append("g").attr("class","commit-bullets"),n=a.append("g").attr("class","commit-labels");let c=u==="TB"||u==="BT"?_:0;const o=[...r.keys()],i=(g=s.parallelCommits)!=null?g:!1,h=l(($,y)=>{var B,L;const x=(B=r.get($))==null?void 0:B.seq,b=(L=r.get(y))==null?void 0:L.seq;return x!==void 0&&b!==void 0?x-b:0},"sortKeys");let f=o.sort(h);u==="BT"&&(i&&Vr(f,r,c),f=f.reverse()),f.forEach($=>{var b,B,L;const y=r.get($);if(!y)throw new Error(`Commit not found for key ${$}`);i&&(c=ne(y,u,c,C));const x=se(y,c,i);if(t){const E=ae(y),m=(b=y.customType)!=null?b:y.type,rr=(L=(B=v.get(y.branch))==null?void 0:B.index)!=null?L:0;re(e,y,x,E,rr,m),ee(n,y,x,c,s),te(n,y,x,c)}u==="TB"||u==="BT"?C.set(y.id,{x:x.x,y:x.posWithOffset}):C.set(y.id,{x:x.posWithOffset,y:x.y}),c=u==="BT"&&i?c+G:c+G+R,c>I&&(I=c)})},"drawCommits"),oe=l((a,r,t,s,e)=>{const c=(u==="TB"||u==="BT"?t.x<s.x:t.y<s.y)?r.branch:a.branch,o=l(h=>h.branch===c,"isOnBranchToGetCurve"),i=l(h=>h.seq>a.seq&&h.seq<r.seq,"isBetweenCommits");return[...e.values()].some(h=>i(h)&&o(h))},"shouldRerouteArrow"),A=l((a,r,t=0)=>{const s=a+Math.abs(a-r)/2;if(t>5)return s;if(z.every(c=>Math.abs(c-s)>=10))return z.push(s),s;const n=Math.abs(a-r);return A(a,r-n/5,t+1)},"findLane"),ce=l((a,r,t,s)=>{var y,x,b,B,L;const e=C.get(r.id),n=C.get(t.id);if(e===void 0||n===void 0)throw new Error(`Commit positions not found for commits ${r.id} and ${t.id}`);const c=oe(r,t,e,n,s);let o="",i="",h=0,f=0,g=(y=v.get(t.branch))==null?void 0:y.index;t.type===p.MERGE&&r.id!==t.parents[0]&&(g=(x=v.get(r.branch))==null?void 0:x.index);let $;if(c){o="A 10 10, 0, 0, 0,",i="A 10 10, 0, 0, 1,",h=10,f=10;const E=e.y<n.y?A(e.y,n.y):A(n.y,e.y),m=e.x<n.x?A(e.x,n.x):A(n.x,e.x);u==="TB"?e.x<n.x?$=`M ${e.x} ${e.y} L ${m-h} ${e.y} ${i} ${m} ${e.y+f} L ${m} ${n.y-h} ${o} ${m+f} ${n.y} L ${n.x} ${n.y}`:(g=(b=v.get(r.branch))==null?void 0:b.index,$=`M ${e.x} ${e.y} L ${m+h} ${e.y} ${o} ${m} ${e.y+f} L ${m} ${n.y-h} ${i} ${m-f} ${n.y} L ${n.x} ${n.y}`):u==="BT"?e.x<n.x?$=`M ${e.x} ${e.y} L ${m-h} ${e.y} ${o} ${m} ${e.y-f} L ${m} ${n.y+h} ${i} ${m+f} ${n.y} L ${n.x} ${n.y}`:(g=(B=v.get(r.branch))==null?void 0:B.index,$=`M ${e.x} ${e.y} L ${m+h} ${e.y} ${i} ${m} ${e.y-f} L ${m} ${n.y+h} ${o} ${m-f} ${n.y} L ${n.x} ${n.y}`):e.y<n.y?$=`M ${e.x} ${e.y} L ${e.x} ${E-h} ${o} ${e.x+f} ${E} L ${n.x-h} ${E} ${i} ${n.x} ${E+f} L ${n.x} ${n.y}`:(g=(L=v.get(r.branch))==null?void 0:L.index,$=`M ${e.x} ${e.y} L ${e.x} ${E+h} ${i} ${e.x+f} ${E} L ${n.x-h} ${E} ${o} ${n.x} ${E-f} L ${n.x} ${n.y}`)}else o="A 20 20, 0, 0, 0,",i="A 20 20, 0, 0, 1,",h=20,f=20,u==="TB"?(e.x<n.x&&(t.type===p.MERGE&&r.id!==t.parents[0]?$=`M ${e.x} ${e.y} L ${e.x} ${n.y-h} ${o} ${e.x+f} ${n.y} L ${n.x} ${n.y}`:$=`M ${e.x} ${e.y} L ${n.x-h} ${e.y} ${i} ${n.x} ${e.y+f} L ${n.x} ${n.y}`),e.x>n.x&&(o="A 20 20, 0, 0, 0,",i="A 20 20, 0, 0, 1,",h=20,f=20,t.type===p.MERGE&&r.id!==t.parents[0]?$=`M ${e.x} ${e.y} L ${e.x} ${n.y-h} ${i} ${e.x-f} ${n.y} L ${n.x} ${n.y}`:$=`M ${e.x} ${e.y} L ${n.x+h} ${e.y} ${o} ${n.x} ${e.y+f} L ${n.x} ${n.y}`),e.x===n.x&&($=`M ${e.x} ${e.y} L ${n.x} ${n.y}`)):u==="BT"?(e.x<n.x&&(t.type===p.MERGE&&r.id!==t.parents[0]?$=`M ${e.x} ${e.y} L ${e.x} ${n.y+h} ${i} ${e.x+f} ${n.y} L ${n.x} ${n.y}`:$=`M ${e.x} ${e.y} L ${n.x-h} ${e.y} ${o} ${n.x} ${e.y-f} L ${n.x} ${n.y}`),e.x>n.x&&(o="A 20 20, 0, 0, 0,",i="A 20 20, 0, 0, 1,",h=20,f=20,t.type===p.MERGE&&r.id!==t.parents[0]?$=`M ${e.x} ${e.y} L ${e.x} ${n.y+h} ${o} ${e.x-f} ${n.y} L ${n.x} ${n.y}`:$=`M ${e.x} ${e.y} L ${n.x+h} ${e.y} ${i} ${n.x} ${e.y-f} L ${n.x} ${n.y}`),e.x===n.x&&($=`M ${e.x} ${e.y} L ${n.x} ${n.y}`)):(e.y<n.y&&(t.type===p.MERGE&&r.id!==t.parents[0]?$=`M ${e.x} ${e.y} L ${n.x-h} ${e.y} ${i} ${n.x} ${e.y+f} L ${n.x} ${n.y}`:$=`M ${e.x} ${e.y} L ${e.x} ${n.y-h} ${o} ${e.x+f} ${n.y} L ${n.x} ${n.y}`),e.y>n.y&&(t.type===p.MERGE&&r.id!==t.parents[0]?$=`M ${e.x} ${e.y} L ${n.x-h} ${e.y} ${o} ${n.x} ${e.y-f} L ${n.x} ${n.y}`:$=`M ${e.x} ${e.y} L ${e.x} ${n.y+h} ${i} ${e.x+f} ${n.y} L ${n.x} ${n.y}`),e.y===n.y&&($=`M ${e.x} ${e.y} L ${n.x} ${n.y}`));if($===void 0)throw new Error("Line definition not found");a.append("path").attr("d",$).attr("class","arrow arrow"+g%O)},"drawArrow"),ie=l((a,r)=>{const t=a.append("g").attr("class","commit-arrows");[...r.keys()].forEach(s=>{const e=r.get(s);e.parents&&e.parents.length>0&&e.parents.forEach(n=>{ce(t,r.get(n),e,r)})})},"drawArrows"),de=l((a,r,t)=>{const s=a.append("g");r.forEach((e,n)=>{var b;const c=n%O,o=(b=v.get(e.name))==null?void 0:b.pos;if(o===void 0)throw new Error(`Position not found for branch ${e.name}`);const i=s.append("line");i.attr("x1",0),i.attr("y1",o),i.attr("x2",I),i.attr("y2",o),i.attr("class","branch branch"+c),u==="TB"?(i.attr("y1",_),i.attr("x1",o),i.attr("y2",I),i.attr("x2",o)):u==="BT"&&(i.attr("y1",I),i.attr("x1",o),i.attr("y2",_),i.attr("x2",o)),z.push(o);const h=e.name,f=Q(h),g=s.insert("rect"),y=s.insert("g").attr("class","branchLabel").insert("g").attr("class","label branch-label"+c);y.node().appendChild(f);const x=f.getBBox();g.attr("class","branchLabelBkg label"+c).attr("rx",4).attr("ry",4).attr("x",-x.width-4-(t.rotateCommitLabel===!0?30:0)).attr("y",-x.height/2+8).attr("width",x.width+18).attr("height",x.height+4),y.attr("transform","translate("+(-x.width-14-(t.rotateCommitLabel===!0?30:0))+", "+(o-x.height/2-1)+")"),u==="TB"?(g.attr("x",o-x.width/2-10).attr("y",0),y.attr("transform","translate("+(o-x.width/2-5)+", 0)")):u==="BT"?(g.attr("x",o-x.width/2-10).attr("y",I),y.attr("transform","translate("+(o-x.width/2-5)+", "+I+")")):g.attr("transform","translate(-19, "+(o-x.height/2)+")")})},"drawBranches"),he=l(function(a,r,t,s,e){return v.set(a,{pos:r,index:t}),r+=50+(e?40:0)+(u==="TB"||u==="BT"?s.width/2:0),r},"setBranchPosition"),le=l(function(a,r,t,s){var f,g;Kr(),w.debug("in gitgraph renderer",a+`
`,"id:",r,t);const e=s.db;if(!e.getConfig){w.error("getConfig method is not available on db");return}const n=e.getConfig(),c=(f=n.rotateCommitLabel)!=null?f:!1;H=e.getCommits();const o=e.getBranchesAsObjArray();u=e.getDirection();const i=yr(`[id="${r}"]`);let h=0;o.forEach(($,y)=>{var m;const x=Q($.name),b=i.append("g"),B=b.insert("g").attr("class","branchLabel"),L=B.insert("g").attr("class","label branch-label");(m=L.node())==null||m.appendChild(x);const E=x.getBBox();h=he($.name,h,y,E,c),L.remove(),B.remove(),b.remove()}),K(i,H,!1,n),n.showBranches&&de(i,o,n),ie(i,H),K(i,H,!0,n),gr.insertTitle(i,"gitTitleText",(g=n.titleTopMargin)!=null?g:0,e.getDiagramTitle()),xr(void 0,i,n.diagramPadding,n.useMaxWidth)},"draw"),$e={draw:le},fe=l(a=>`
.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(r=>`
.branch-label${r} { fill: ${a["gitBranchLabel"+r]}; }
.commit${r} { stroke: ${a["git"+r]}; fill: ${a["git"+r]}; }
.commit-highlight${r} { stroke: ${a["gitInv"+r]}; fill: ${a["gitInv"+r]}; }
.label${r} { fill: ${a["git"+r]}; }
.arrow${r} { stroke: ${a["git"+r]}; }
`).join(`
`)}
.branch {
stroke-width: 1;
stroke: ${a.lineColor};
stroke-dasharray: 2;
}
.commit-label { font-size: ${a.commitLabelFontSize}; fill: ${a.commitLabelColor};}
.commit-label-bkg { font-size: ${a.commitLabelFontSize}; fill: ${a.commitLabelBackground}; opacity: 0.5; }
.tag-label { font-size: ${a.tagLabelFontSize}; fill: ${a.tagLabelColor};}
.tag-label-bkg { fill: ${a.tagLabelBackground}; stroke: ${a.tagLabelBorder}; }
.tag-hole { fill: ${a.textColor}; }
.commit-merge {
stroke: ${a.primaryColor};
fill: ${a.primaryColor};
}
.commit-reverse {
stroke: ${a.primaryColor};
fill: ${a.primaryColor};
stroke-width: 3;
}
.commit-highlight-outer {
}
.commit-highlight-inner {
stroke: ${a.primaryColor};
fill: ${a.primaryColor};
}
.arrow { stroke-width: 8; stroke-linecap: round; fill: none}
.gitTitleText {
text-anchor: middle;
font-size: 18px;
fill: ${a.textColor};
}
`,"getStyles"),ye=fe,Le={parser:Yr,db:J,renderer:$e,styles:ye};export{Le as diagram};