UNPKG

epic-designer-gold

Version:

基于vue3的设计器,可视化开发页面表单

66 lines (62 loc) 25.3 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("./chunk-4BX2VUAB-DbyyKMHq.cjs"),U=require("./chunk-QZHKN3VN-BxliQSjm.cjs"),o=require("./mermaid.core-amipJqhv.cjs"),V=require("./mermaid-parser.core-kpvzU35a.cjs");var m={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},X=o.defaultConfig_default.gitGraph,R=o.__name(()=>o.cleanAndMerge({...X,...o.getConfig().gitGraph}),"getConfig"),d=new U.ImperativeState(()=>{const t=R(),e=t.mainBranchName,a=t.mainBranchOrder;return{mainBranchName:e,commits:new Map,head:null,branchConfig:new Map([[e,{name:e,order:a}]]),branches:new Map([[e,null]]),currBranch:e,direction:"LR",seq:0,options:{}}});function P(){return o.random({length:7})}o.__name(P,"getID");function N(t,e){const a=Object.create(null);return t.reduce((s,r)=>{const n=e(r);return a[n]||(a[n]=!0,s.push(r)),s},[])}o.__name(N,"uniqBy");var Q=o.__name(function(t){d.records.direction=t},"setDirection"),J=o.__name(function(t){o.log.debug("options str",t),t=t==null?void 0:t.trim(),t=t||"{}";try{d.records.options=JSON.parse(t)}catch(e){o.log.error("error while parsing gitGraph options",e.message)}},"setOptions"),Z=o.__name(function(){return d.records.options},"getOptions"),ee=o.__name(function(t){let e=t.msg,a=t.id;const s=t.type;let r=t.tags;o.log.info("commit",e,a,s,r),o.log.debug("Entering commit:",e,a,s,r);const n=R();a=o.common_default.sanitizeText(a,n),e=o.common_default.sanitizeText(e,n),r=r==null?void 0:r.map(i=>o.common_default.sanitizeText(i,n));const c={id:a||d.records.seq+"-"+P(),message:e,seq:d.records.seq++,type:s??m.NORMAL,tags:r??[],parents:d.records.head==null?[]:[d.records.head.id],branch:d.records.currBranch};d.records.head=c,o.log.info("main branch",n.mainBranchName),d.records.commits.has(c.id)&&o.log.warn(`Commit ID ${c.id} already exists`),d.records.commits.set(c.id,c),d.records.branches.set(d.records.currBranch,c.id),o.log.debug("in pushCommit "+c.id)},"commit"),re=o.__name(function(t){let e=t.name;const a=t.order;if(e=o.common_default.sanitizeText(e,R()),d.records.branches.has(e))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 ${e}")`);d.records.branches.set(e,d.records.head!=null?d.records.head.id:null),d.records.branchConfig.set(e,{name:e,order:a}),F(e),o.log.debug("in createBranch")},"branch"),te=o.__name(t=>{let e=t.branch,a=t.id;const s=t.type,r=t.tags,n=R();e=o.common_default.sanitizeText(e,n),a&&(a=o.common_default.sanitizeText(a,n));const c=d.records.branches.get(d.records.currBranch),i=d.records.branches.get(e),l=c?d.records.commits.get(c):void 0,h=i?d.records.commits.get(i):void 0;if(l&&h&&l.branch===e)throw new Error(`Cannot merge branch '${e}' into itself.`);if(d.records.currBranch===e){const $=new Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw $.hash={text:`merge ${e}`,token:`merge ${e}`,expected:["branch abc"]},$}if(l===void 0||!l){const $=new Error(`Incorrect usage of "merge". Current branch (${d.records.currBranch})has no commits`);throw $.hash={text:`merge ${e}`,token:`merge ${e}`,expected:["commit"]},$}if(!d.records.branches.has(e)){const $=new Error('Incorrect usage of "merge". Branch to be merged ('+e+") does not exist");throw $.hash={text:`merge ${e}`,token:`merge ${e}`,expected:[`branch ${e}`]},$}if(h===void 0||!h){const $=new Error('Incorrect usage of "merge". Branch to be merged ('+e+") has no commits");throw $.hash={text:`merge ${e}`,token:`merge ${e}`,expected:['"commit"']},$}if(l===h){const $=new Error('Incorrect usage of "merge". Both branches have same head');throw $.hash={text:`merge ${e}`,token:`merge ${e}`,expected:["branch abc"]},$}if(a&&d.records.commits.has(a)){const $=new Error('Incorrect usage of "merge". Commit with id:'+a+" already exists, use different custom id");throw $.hash={text:`merge ${e} ${a} ${s} ${r==null?void 0:r.join(" ")}`,token:`merge ${e} ${a} ${s} ${r==null?void 0:r.join(" ")}`,expected:[`merge ${e} ${a}_UNIQUE ${s} ${r==null?void 0:r.join(" ")}`]},$}const f=i||"",g={id:a||`${d.records.seq}-${P()}`,message:`merged branch ${e} into ${d.records.currBranch}`,seq:d.records.seq++,parents:d.records.head==null?[]:[d.records.head.id,f],branch:d.records.currBranch,type:m.MERGE,customType:s,customId:!!a,tags:r??[]};d.records.head=g,d.records.commits.set(g.id,g),d.records.branches.set(d.records.currBranch,g.id),o.log.debug(d.records.branches),o.log.debug("in mergeBranch")},"merge"),ae=o.__name(function(t){let e=t.id,a=t.targetId,s=t.tags,r=t.parent;o.log.debug("Entering cherryPick:",e,a,s);const n=R();if(e=o.common_default.sanitizeText(e,n),a=o.common_default.sanitizeText(a,n),s=s==null?void 0:s.map(l=>o.common_default.sanitizeText(l,n)),r=o.common_default.sanitizeText(r,n),!e||!d.records.commits.has(e)){const l=new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw l.hash={text:`cherryPick ${e} ${a}`,token:`cherryPick ${e} ${a}`,expected:["cherry-pick abc"]},l}const c=d.records.commits.get(e);if(c===void 0||!c)throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(r&&!(Array.isArray(c.parents)&&c.parents.includes(r)))throw new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");const i=c.branch;if(c.type===m.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(!a||!d.records.commits.has(a)){if(i===d.records.currBranch){const g=new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw g.hash={text:`cherryPick ${e} ${a}`,token:`cherryPick ${e} ${a}`,expected:["cherry-pick abc"]},g}const l=d.records.branches.get(d.records.currBranch);if(l===void 0||!l){const g=new Error(`Incorrect usage of "cherry-pick". Current branch (${d.records.currBranch})has no commits`);throw g.hash={text:`cherryPick ${e} ${a}`,token:`cherryPick ${e} ${a}`,expected:["cherry-pick abc"]},g}const h=d.records.commits.get(l);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 ${e} ${a}`,token:`cherryPick ${e} ${a}`,expected:["cherry-pick abc"]},g}const f={id:d.records.seq+"-"+P(),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:m.CHERRY_PICK,tags:s?s.filter(Boolean):[`cherry-pick:${c.id}${c.type===m.MERGE?`|parent:${r}`:""}`]};d.records.head=f,d.records.commits.set(f.id,f),d.records.branches.set(d.records.currBranch,f.id),o.log.debug(d.records.branches),o.log.debug("in cherryPick")}},"cherryPick"),F=o.__name(function(t){if(t=o.common_default.sanitizeText(t,R()),d.records.branches.has(t)){d.records.currBranch=t;const e=d.records.branches.get(d.records.currBranch);e===void 0||!e?d.records.head=null:d.records.head=d.records.commits.get(e)??null}else{const e=new Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${t}")`);throw e.hash={text:`checkout ${t}`,token:`checkout ${t}`,expected:[`branch ${t}`]},e}},"checkout");function H(t,e,a){const s=t.indexOf(e);s===-1?t.push(a):t.splice(s,1,a)}o.__name(H,"upsert");function D(t){const e=t.reduce((r,n)=>r.seq>n.seq?r:n,t[0]);let a="";t.forEach(function(r){r===e?a+=" *":a+=" |"});const s=[a,e.id,e.seq];for(const r in d.records.branches)d.records.branches.get(r)===e.id&&s.push(r);if(o.log.debug(s.join(" ")),e.parents&&e.parents.length==2&&e.parents[0]&&e.parents[1]){const r=d.records.commits.get(e.parents[0]);H(t,e,r),e.parents[1]&&t.push(d.records.commits.get(e.parents[1]))}else{if(e.parents.length==0)return;if(e.parents[0]){const r=d.records.commits.get(e.parents[0]);H(t,e,r)}}t=N(t,r=>r.id),D(t)}o.__name(D,"prettyPrintCommitHistory");var ne=o.__name(function(){o.log.debug(d.records.commits);const t=S()[0];D([t])},"prettyPrint"),se=o.__name(function(){d.reset(),o.clear()},"clear"),oe=o.__name(function(){return[...d.records.branchConfig.values()].map((e,a)=>e.order!==null&&e.order!==void 0?e:{...e,order:parseFloat(`0.${a}`)}).sort((e,a)=>(e.order??0)-(a.order??0)).map(({name:e})=>({name:e}))},"getBranchesAsObjArray"),ce=o.__name(function(){return d.records.branches},"getBranches"),ie=o.__name(function(){return d.records.commits},"getCommits"),S=o.__name(function(){const t=[...d.records.commits.values()];return t.forEach(function(e){o.log.debug(e.id)}),t.sort((e,a)=>e.seq-a.seq),t},"getCommitsArray"),de=o.__name(function(){return d.records.currBranch},"getCurrentBranch"),le=o.__name(function(){return d.records.direction},"getDirection"),he=o.__name(function(){return d.records.head},"getHead"),W={commitType:m,getConfig:R,setDirection:Q,setOptions:J,getOptions:Z,commit:ee,branch:re,merge:te,cherryPick:ae,checkout:F,prettyPrint:ne,clear:se,getBranchesAsObjArray:oe,getBranches:ce,getCommits:ie,getCommitsArray:S,getCurrentBranch:de,getDirection:le,getHead:he,setAccTitle:o.setAccTitle,getAccTitle:o.getAccTitle,getAccDescription:o.getAccDescription,setAccDescription:o.setAccDescription,setDiagramTitle:o.setDiagramTitle,getDiagramTitle:o.getDiagramTitle},$e=o.__name((t,e)=>{Y.populateCommonDb(t,e),t.dir&&e.setDirection(t.dir);for(const a of t.statements)fe(a,e)},"populate"),fe=o.__name((t,e)=>{const s={Commit:o.__name(r=>e.commit(ge(r)),"Commit"),Branch:o.__name(r=>e.branch(ye(r)),"Branch"),Merge:o.__name(r=>e.merge(ue(r)),"Merge"),Checkout:o.__name(r=>e.checkout(xe(r)),"Checkout"),CherryPicking:o.__name(r=>e.cherryPick(me(r)),"CherryPicking")}[t.$type];s?s(t):o.log.error(`Unknown statement type: ${t.$type}`)},"parseStatement"),ge=o.__name(t=>({id:t.id,msg:t.message??"",type:t.type!==void 0?m[t.type]:m.NORMAL,tags:t.tags??void 0}),"parseCommit"),ye=o.__name(t=>({name:t.name,order:t.order??0}),"parseBranch"),ue=o.__name(t=>({branch:t.branch,id:t.id??"",type:t.type!==void 0?m[t.type]:void 0,tags:t.tags??void 0}),"parseMerge"),xe=o.__name(t=>t.branch,"parseCheckout"),me=o.__name(t=>{var a;return{id:t.id,targetId:"",tags:((a=t.tags)==null?void 0:a.length)===0?void 0:t.tags,parent:t.parent}},"parseCherryPicking"),pe={parse:o.__name(async t=>{const e=await V.parse("gitGraph",t);o.log.debug(e),$e(e,W)},"parse")},L=10,k=40,v=4,E=2,I=8,_=new Map,w=new Map,q=30,G=new Map,A=[],T=0,u="LR",be=o.__name(()=>{_.clear(),w.clear(),G.clear(),T=0,A=[],u="LR"},"clear"),j=o.__name(t=>{const e=document.createElementNS("http://www.w3.org/2000/svg","text");return(typeof t=="string"?t.split(/\\n|\n|<br\s*\/?>/gi):t).forEach(s=>{const r=document.createElementNS("http://www.w3.org/2000/svg","tspan");r.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),r.setAttribute("dy","1em"),r.setAttribute("x","0"),r.setAttribute("class","row"),r.textContent=s.trim(),e.appendChild(r)}),e},"drawText"),K=o.__name(t=>{let e,a,s;return u==="BT"?(a=o.__name((r,n)=>r<=n,"comparisonFunc"),s=1/0):(a=o.__name((r,n)=>r>=n,"comparisonFunc"),s=0),t.forEach(r=>{var c,i;const n=u==="TB"||u=="BT"?(c=w.get(r))==null?void 0:c.y:(i=w.get(r))==null?void 0:i.x;n!==void 0&&a(n,s)&&(e=r,s=n)}),e},"findClosestParent"),_e=o.__name(t=>{let e="",a=1/0;return t.forEach(s=>{const r=w.get(s).y;r<=a&&(e=s,a=r)}),e||void 0},"findClosestParentBT"),we=o.__name((t,e,a)=>{let s=a,r=a;const n=[];t.forEach(c=>{const i=e.get(c);if(!i)throw new Error(`Commit not found for key ${c}`);i.parents.length?(s=Ce(i),r=Math.max(s,r)):n.push(i),Ee(i,s)}),s=r,n.forEach(c=>{Be(c,s,a)}),t.forEach(c=>{const i=e.get(c);if(i!=null&&i.parents.length){const l=_e(i.parents);s=w.get(l).y-k,s<=r&&(r=s);const h=_.get(i.branch).pos,f=s-L;w.set(i.id,{x:h,y:f})}})},"setParallelBTPos"),ve=o.__name(t=>{var s;const e=K(t.parents.filter(r=>r!==null));if(!e)throw new Error(`Closest parent not found for commit ${t.id}`);const a=(s=w.get(e))==null?void 0:s.y;if(a===void 0)throw new Error(`Closest parent position not found for commit ${t.id}`);return a},"findClosestParentPos"),Ce=o.__name(t=>ve(t)+k,"calculateCommitPosition"),Ee=o.__name((t,e)=>{const a=_.get(t.branch);if(!a)throw new Error(`Branch not found for commit ${t.id}`);const s=a.pos,r=e+L;return w.set(t.id,{x:s,y:r}),{x:s,y:r}},"setCommitPosition"),Be=o.__name((t,e,a)=>{const s=_.get(t.branch);if(!s)throw new Error(`Branch not found for commit ${t.id}`);const r=e+a,n=s.pos;w.set(t.id,{x:n,y:r})},"setRootPosition"),Te=o.__name((t,e,a,s,r,n)=>{if(n===m.HIGHLIGHT)t.append("rect").attr("x",a.x-10).attr("y",a.y-10).attr("width",20).attr("height",20).attr("class",`commit ${e.id} commit-highlight${r%I} ${s}-outer`),t.append("rect").attr("x",a.x-6).attr("y",a.y-6).attr("width",12).attr("height",12).attr("class",`commit ${e.id} commit${r%I} ${s}-inner`);else if(n===m.CHERRY_PICK)t.append("circle").attr("cx",a.x).attr("cy",a.y).attr("r",10).attr("class",`commit ${e.id} ${s}`),t.append("circle").attr("cx",a.x-3).attr("cy",a.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${e.id} ${s}`),t.append("circle").attr("cx",a.x+3).attr("cy",a.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${e.id} ${s}`),t.append("line").attr("x1",a.x+3).attr("y1",a.y+1).attr("x2",a.x).attr("y2",a.y-5).attr("stroke","#fff").attr("class",`commit ${e.id} ${s}`),t.append("line").attr("x1",a.x-3).attr("y1",a.y+1).attr("x2",a.x).attr("y2",a.y-5).attr("stroke","#fff").attr("class",`commit ${e.id} ${s}`);else{const c=t.append("circle");if(c.attr("cx",a.x),c.attr("cy",a.y),c.attr("r",e.type===m.MERGE?9:10),c.attr("class",`commit ${e.id} commit${r%I}`),n===m.MERGE){const i=t.append("circle");i.attr("cx",a.x),i.attr("cy",a.y),i.attr("r",6),i.attr("class",`commit ${s} ${e.id} commit${r%I}`)}n===m.REVERSE&&t.append("path").attr("d",`M ${a.x-5},${a.y-5}L${a.x+5},${a.y+5}M${a.x-5},${a.y+5}L${a.x+5},${a.y-5}`).attr("class",`commit ${s} ${e.id} commit${r%I}`)}},"drawCommitBullet"),Le=o.__name((t,e,a,s,r)=>{var n;if(e.type!==m.CHERRY_PICK&&(e.customId&&e.type===m.MERGE||e.type!==m.MERGE)&&r.showCommitLabel){const c=t.append("g"),i=c.insert("rect").attr("class","commit-label-bkg"),l=c.append("text").attr("x",s).attr("y",a.y+25).attr("class","commit-label").text(e.id),h=(n=l.node())==null?void 0:n.getBBox();if(h&&(i.attr("x",a.posWithOffset-h.width/2-E).attr("y",a.y+13.5).attr("width",h.width+2*E).attr("height",h.height+2*E),u==="TB"||u==="BT"?(i.attr("x",a.x-(h.width+4*v+5)).attr("y",a.y-12),l.attr("x",a.x-(h.width+4*v)).attr("y",a.y+h.height-12)):l.attr("x",a.posWithOffset-h.width/2),r.rotateCommitLabel))if(u==="TB"||u==="BT")l.attr("transform","rotate(-45, "+a.x+", "+a.y+")"),i.attr("transform","rotate(-45, "+a.x+", "+a.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+", "+a.y+")")}}},"drawCommitLabel"),ke=o.__name((t,e,a,s)=>{var r;if(e.tags.length>0){let n=0,c=0,i=0;const l=[];for(const h of e.tags.reverse()){const f=t.insert("polygon"),g=t.append("circle"),$=t.append("text").attr("y",a.y-16-n).attr("class","tag-label").text(h),y=(r=$.node())==null?void 0:r.getBBox();if(!y)throw new Error("Tag bbox not found");c=Math.max(c,y.width),i=Math.max(i,y.height),$.attr("x",a.posWithOffset-y.width/2),l.push({tag:$,hole:g,rect:f,yOffset:n}),n+=20}for(const{tag:h,hole:f,rect:g,yOffset:$}of l){const y=i/2,x=a.y-19.2-$;if(g.attr("class","tag-label-bkg").attr("points",` ${s-c/2-v/2},${x+E} ${s-c/2-v/2},${x-E} ${a.posWithOffset-c/2-v},${x-y-E} ${a.posWithOffset+c/2+v},${x-y-E} ${a.posWithOffset+c/2+v},${x+y+E} ${a.posWithOffset-c/2-v},${x+y+E}`),f.attr("cy",x).attr("cx",s-c/2+v/2).attr("r",1.5).attr("class","tag-hole"),u==="TB"||u==="BT"){const p=s+$;g.attr("class","tag-label-bkg").attr("points",` ${a.x},${p+2} ${a.x},${p-2} ${a.x+L},${p-y-2} ${a.x+L+c+4},${p-y-2} ${a.x+L+c+4},${p+y+2} ${a.x+L},${p+y+2}`).attr("transform","translate(12,12) rotate(45, "+a.x+","+s+")"),f.attr("cx",a.x+v/2).attr("cy",p).attr("transform","translate(12,12) rotate(45, "+a.x+","+s+")"),h.attr("x",a.x+5).attr("y",p+3).attr("transform","translate(14,14) rotate(45, "+a.x+","+s+")")}}}},"drawCommitTags"),Me=o.__name(t=>{switch(t.customType??t.type){case m.NORMAL:return"commit-normal";case m.REVERSE:return"commit-reverse";case m.HIGHLIGHT:return"commit-highlight";case m.MERGE:return"commit-merge";case m.CHERRY_PICK:return"commit-cherry-pick";default:return"commit-normal"}},"getCommitClassType"),Ie=o.__name((t,e,a,s)=>{const r={x:0,y:0};if(t.parents.length>0){const n=K(t.parents);if(n){const c=s.get(n)??r;return e==="TB"?c.y+k:e==="BT"?(s.get(t.id)??r).y-k:c.x+k}}else return e==="TB"?q:e==="BT"?(s.get(t.id)??r).y-k:0;return 0},"calculatePosition"),Re=o.__name((t,e,a)=>{var c,i;const s=u==="BT"&&a?e:e+L,r=u==="TB"||u==="BT"?s:(c=_.get(t.branch))==null?void 0:c.pos,n=u==="TB"||u==="BT"?(i=_.get(t.branch))==null?void 0:i.pos:s;if(n===void 0||r===void 0)throw new Error(`Position were undefined for commit ${t.id}`);return{x:n,y:r,posWithOffset:s}},"getCommitPosition"),z=o.__name((t,e,a,s)=>{const r=t.append("g").attr("class","commit-bullets"),n=t.append("g").attr("class","commit-labels");let c=u==="TB"||u==="BT"?q:0;const i=[...e.keys()],l=s.parallelCommits??!1,h=o.__name((g,$)=>{var p,C;const y=(p=e.get(g))==null?void 0:p.seq,x=(C=e.get($))==null?void 0:C.seq;return y!==void 0&&x!==void 0?y-x:0},"sortKeys");let f=i.sort(h);u==="BT"&&(l&&we(f,e,c),f=f.reverse()),f.forEach(g=>{var x;const $=e.get(g);if(!$)throw new Error(`Commit not found for key ${g}`);l&&(c=Ie($,u,c,w));const y=Re($,c,l);if(a){const p=Me($),C=$.customType??$.type,M=((x=_.get($.branch))==null?void 0:x.index)??0;Te(r,$,y,p,M,C),Le(n,$,y,c,s),ke(n,$,y,c)}u==="TB"||u==="BT"?w.set($.id,{x:y.x,y:y.posWithOffset}):w.set($.id,{x:y.posWithOffset,y:y.y}),c=u==="BT"&&l?c+k:c+k+L,c>T&&(T=c)})},"drawCommits"),Ge=o.__name((t,e,a,s,r)=>{const c=(u==="TB"||u==="BT"?a.x<s.x:a.y<s.y)?e.branch:t.branch,i=o.__name(h=>h.branch===c,"isOnBranchToGetCurve"),l=o.__name(h=>h.seq>t.seq&&h.seq<e.seq,"isBetweenCommits");return[...r.values()].some(h=>l(h)&&i(h))},"shouldRerouteArrow"),O=o.__name((t,e,a=0)=>{const s=t+Math.abs(t-e)/2;if(a>5)return s;if(A.every(c=>Math.abs(c-s)>=10))return A.push(s),s;const n=Math.abs(t-e);return O(t,e-n/5,a+1)},"findLane"),Oe=o.__name((t,e,a,s)=>{var y,x,p,C,M;const r=w.get(e.id),n=w.get(a.id);if(r===void 0||n===void 0)throw new Error(`Commit positions not found for commits ${e.id} and ${a.id}`);const c=Ge(e,a,r,n,s);let i="",l="",h=0,f=0,g=(y=_.get(a.branch))==null?void 0:y.index;a.type===m.MERGE&&e.id!==a.parents[0]&&(g=(x=_.get(e.branch))==null?void 0:x.index);let $;if(c){i="A 10 10, 0, 0, 0,",l="A 10 10, 0, 0, 1,",h=10,f=10;const B=r.y<n.y?O(r.y,n.y):O(n.y,r.y),b=r.x<n.x?O(r.x,n.x):O(n.x,r.x);u==="TB"?r.x<n.x?$=`M ${r.x} ${r.y} L ${b-h} ${r.y} ${l} ${b} ${r.y+f} L ${b} ${n.y-h} ${i} ${b+f} ${n.y} L ${n.x} ${n.y}`:(g=(p=_.get(e.branch))==null?void 0:p.index,$=`M ${r.x} ${r.y} L ${b+h} ${r.y} ${i} ${b} ${r.y+f} L ${b} ${n.y-h} ${l} ${b-f} ${n.y} L ${n.x} ${n.y}`):u==="BT"?r.x<n.x?$=`M ${r.x} ${r.y} L ${b-h} ${r.y} ${i} ${b} ${r.y-f} L ${b} ${n.y+h} ${l} ${b+f} ${n.y} L ${n.x} ${n.y}`:(g=(C=_.get(e.branch))==null?void 0:C.index,$=`M ${r.x} ${r.y} L ${b+h} ${r.y} ${l} ${b} ${r.y-f} L ${b} ${n.y+h} ${i} ${b-f} ${n.y} L ${n.x} ${n.y}`):r.y<n.y?$=`M ${r.x} ${r.y} L ${r.x} ${B-h} ${i} ${r.x+f} ${B} L ${n.x-h} ${B} ${l} ${n.x} ${B+f} L ${n.x} ${n.y}`:(g=(M=_.get(e.branch))==null?void 0:M.index,$=`M ${r.x} ${r.y} L ${r.x} ${B+h} ${l} ${r.x+f} ${B} L ${n.x-h} ${B} ${i} ${n.x} ${B-f} L ${n.x} ${n.y}`)}else i="A 20 20, 0, 0, 0,",l="A 20 20, 0, 0, 1,",h=20,f=20,u==="TB"?(r.x<n.x&&(a.type===m.MERGE&&e.id!==a.parents[0]?$=`M ${r.x} ${r.y} L ${r.x} ${n.y-h} ${i} ${r.x+f} ${n.y} L ${n.x} ${n.y}`:$=`M ${r.x} ${r.y} L ${n.x-h} ${r.y} ${l} ${n.x} ${r.y+f} L ${n.x} ${n.y}`),r.x>n.x&&(i="A 20 20, 0, 0, 0,",l="A 20 20, 0, 0, 1,",h=20,f=20,a.type===m.MERGE&&e.id!==a.parents[0]?$=`M ${r.x} ${r.y} L ${r.x} ${n.y-h} ${l} ${r.x-f} ${n.y} L ${n.x} ${n.y}`:$=`M ${r.x} ${r.y} L ${n.x+h} ${r.y} ${i} ${n.x} ${r.y+f} L ${n.x} ${n.y}`),r.x===n.x&&($=`M ${r.x} ${r.y} L ${n.x} ${n.y}`)):u==="BT"?(r.x<n.x&&(a.type===m.MERGE&&e.id!==a.parents[0]?$=`M ${r.x} ${r.y} L ${r.x} ${n.y+h} ${l} ${r.x+f} ${n.y} L ${n.x} ${n.y}`:$=`M ${r.x} ${r.y} L ${n.x-h} ${r.y} ${i} ${n.x} ${r.y-f} L ${n.x} ${n.y}`),r.x>n.x&&(i="A 20 20, 0, 0, 0,",l="A 20 20, 0, 0, 1,",h=20,f=20,a.type===m.MERGE&&e.id!==a.parents[0]?$=`M ${r.x} ${r.y} L ${r.x} ${n.y+h} ${i} ${r.x-f} ${n.y} L ${n.x} ${n.y}`:$=`M ${r.x} ${r.y} L ${n.x+h} ${r.y} ${l} ${n.x} ${r.y-f} L ${n.x} ${n.y}`),r.x===n.x&&($=`M ${r.x} ${r.y} L ${n.x} ${n.y}`)):(r.y<n.y&&(a.type===m.MERGE&&e.id!==a.parents[0]?$=`M ${r.x} ${r.y} L ${n.x-h} ${r.y} ${l} ${n.x} ${r.y+f} L ${n.x} ${n.y}`:$=`M ${r.x} ${r.y} L ${r.x} ${n.y-h} ${i} ${r.x+f} ${n.y} L ${n.x} ${n.y}`),r.y>n.y&&(a.type===m.MERGE&&e.id!==a.parents[0]?$=`M ${r.x} ${r.y} L ${n.x-h} ${r.y} ${i} ${n.x} ${r.y-f} L ${n.x} ${n.y}`:$=`M ${r.x} ${r.y} L ${r.x} ${n.y+h} ${l} ${r.x+f} ${n.y} L ${n.x} ${n.y}`),r.y===n.y&&($=`M ${r.x} ${r.y} L ${n.x} ${n.y}`));if($===void 0)throw new Error("Line definition not found");t.append("path").attr("d",$).attr("class","arrow arrow"+g%I)},"drawArrow"),qe=o.__name((t,e)=>{const a=t.append("g").attr("class","commit-arrows");[...e.keys()].forEach(s=>{const r=e.get(s);r.parents&&r.parents.length>0&&r.parents.forEach(n=>{Oe(a,e.get(n),r,e)})})},"drawArrows"),Ae=o.__name((t,e,a)=>{const s=t.append("g");e.forEach((r,n)=>{var p;const c=n%I,i=(p=_.get(r.name))==null?void 0:p.pos;if(i===void 0)throw new Error(`Position not found for branch ${r.name}`);const l=s.append("line");l.attr("x1",0),l.attr("y1",i),l.attr("x2",T),l.attr("y2",i),l.attr("class","branch branch"+c),u==="TB"?(l.attr("y1",q),l.attr("x1",i),l.attr("y2",T),l.attr("x2",i)):u==="BT"&&(l.attr("y1",T),l.attr("x1",i),l.attr("y2",q),l.attr("x2",i)),A.push(i);const h=r.name,f=j(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-(a.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-(a.rotateCommitLabel===!0?30:0))+", "+(i-x.height/2-1)+")"),u==="TB"?(g.attr("x",i-x.width/2-10).attr("y",0),y.attr("transform","translate("+(i-x.width/2-5)+", 0)")):u==="BT"?(g.attr("x",i-x.width/2-10).attr("y",T),y.attr("transform","translate("+(i-x.width/2-5)+", "+T+")")):g.attr("transform","translate(-19, "+(i-x.height/2)+")")})},"drawBranches"),Pe=o.__name(function(t,e,a,s,r){return _.set(t,{pos:e,index:a}),e+=50+(r?40:0)+(u==="TB"||u==="BT"?s.width/2:0),e},"setBranchPosition"),He=o.__name(function(t,e,a,s){be(),o.log.debug("in gitgraph renderer",t+` `,"id:",e,a);const r=s.db;if(!r.getConfig){o.log.error("getConfig method is not available on db");return}const n=r.getConfig(),c=n.rotateCommitLabel??!1;G=r.getCommits();const i=r.getBranchesAsObjArray();u=r.getDirection();const l=o.select(`[id="${e}"]`);let h=0;i.forEach((f,g)=>{var M;const $=j(f.name),y=l.append("g"),x=y.insert("g").attr("class","branchLabel"),p=x.insert("g").attr("class","label branch-label");(M=p.node())==null||M.appendChild($);const C=$.getBBox();h=Pe(f.name,h,g,C,c),p.remove(),x.remove(),y.remove()}),z(l,G,!1,n),n.showBranches&&Ae(l,i,n),qe(l,G),z(l,G,!0,n),o.utils_default.insertTitle(l,"gitTitleText",n.titleTopMargin??0,r.getDiagramTitle()),o.setupGraphViewbox2(void 0,l,n.diagramPadding,n.useMaxWidth)},"draw"),De={draw:He},ze=o.__name(t=>` .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(e=>` .branch-label${e} { fill: ${t["gitBranchLabel"+e]}; } .commit${e} { stroke: ${t["git"+e]}; fill: ${t["git"+e]}; } .commit-highlight${e} { stroke: ${t["gitInv"+e]}; fill: ${t["gitInv"+e]}; } .label${e} { fill: ${t["git"+e]}; } .arrow${e} { stroke: ${t["git"+e]}; } `).join(` `)} .branch { stroke-width: 1; stroke: ${t.lineColor}; stroke-dasharray: 2; } .commit-label { font-size: ${t.commitLabelFontSize}; fill: ${t.commitLabelColor};} .commit-label-bkg { font-size: ${t.commitLabelFontSize}; fill: ${t.commitLabelBackground}; opacity: 0.5; } .tag-label { font-size: ${t.tagLabelFontSize}; fill: ${t.tagLabelColor};} .tag-label-bkg { fill: ${t.tagLabelBackground}; stroke: ${t.tagLabelBorder}; } .tag-hole { fill: ${t.textColor}; } .commit-merge { stroke: ${t.primaryColor}; fill: ${t.primaryColor}; } .commit-reverse { stroke: ${t.primaryColor}; fill: ${t.primaryColor}; stroke-width: 3; } .commit-highlight-outer { } .commit-highlight-inner { stroke: ${t.primaryColor}; fill: ${t.primaryColor}; } .arrow { stroke-width: 8; stroke-linecap: round; fill: none} .gitTitleText { text-anchor: middle; font-size: 18px; fill: ${t.textColor}; } `,"getStyles"),Ne=ze,Fe={parser:pe,db:W,renderer:De,styles:Ne};exports.diagram=Fe;