ruru
Version:
Grafast-flavoured GraphiQL distribution
2 lines • 31 kB
JavaScript
export const __webpack_esm_id__=3126;export const __webpack_esm_ids__=[3126];export const __webpack_esm_modules__={58165(t,e,r){r.r(e),r.d(e,{ImperativeState:()=>n});var o=r(79456),n=class{constructor(t){this.init=t,this.records=this.init()}static{(0,o.__name)(this,"ImperativeState")}reset(){this.records=this.init()}}},26637(t,e,r){function o(t,e){t.accDescr&&e.setAccDescription?.(t.accDescr),t.accTitle&&e.setAccTitle?.(t.accTitle),t.title&&e.setDiagramTitle?.(t.title)}r.r(e),r.d(e,{populateCommonDb:()=>o}),(0,r(79456).__name)(o,"populateCommonDb")},63126(t,e,r){r.r(e),r.d(e,{diagram:()=>It});var o=r(58165),n=r(26637),a=r(70848),i=r(39989),s=r(27166),c=r(79456),d=r(73744),m=r(79806),h={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},l=i.defaultConfig_default.gitGraph,$=(0,c.__name)(()=>(0,a.cleanAndMerge)({...l,...(0,i.getConfig)().gitGraph}),"getConfig"),g=new o.ImperativeState(()=>{const t=$(),e=t.mainBranchName,r=t.mainBranchOrder;return{mainBranchName:e,commits:new Map,head:null,branchConfig:new Map([[e,{name:e,order:r}]]),branches:new Map([[e,null]]),currBranch:e,direction:"LR",seq:0,options:{}}});function p(){return(0,a.random)({length:7})}function f(t,e){const r=Object.create(null);return t.reduce((t,o)=>{const n=e(o);return r[n]||(r[n]=!0,t.push(o)),t},[])}(0,c.__name)(p,"getID"),(0,c.__name)(f,"uniqBy");var y=(0,c.__name)(function(t){g.records.direction=t},"setDirection"),x=(0,c.__name)(function(t){s.log.debug("options str",t),t=t?.trim(),t=t||"{}";try{g.records.options=JSON.parse(t)}catch(t){s.log.error("error while parsing gitGraph options",t.message)}},"setOptions"),u=(0,c.__name)(function(){return g.records.options},"getOptions"),b=(0,c.__name)(function(t){let e=t.msg,r=t.id;const o=t.type;let n=t.tags;s.log.info("commit",e,r,o,n),s.log.debug("Entering commit:",e,r,o,n);const a=$();r=i.common_default.sanitizeText(r,a),e=i.common_default.sanitizeText(e,a),n=n?.map(t=>i.common_default.sanitizeText(t,a));const c={id:r||g.records.seq+"-"+p(),message:e,seq:g.records.seq++,type:o??h.NORMAL,tags:n??[],parents:null==g.records.head?[]:[g.records.head.id],branch:g.records.currBranch};g.records.head=c,s.log.info("main branch",a.mainBranchName),g.records.commits.has(c.id)&&s.log.warn(`Commit ID ${c.id} already exists`),g.records.commits.set(c.id,c),g.records.branches.set(g.records.currBranch,c.id),s.log.debug("in pushCommit "+c.id)},"commit"),_=(0,c.__name)(function(t){let e=t.name;const r=t.order;if(e=i.common_default.sanitizeText(e,$()),g.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}")`);g.records.branches.set(e,null!=g.records.head?g.records.head.id:null),g.records.branchConfig.set(e,{name:e,order:r}),B(e),s.log.debug("in createBranch")},"branch"),w=(0,c.__name)(t=>{let e=t.branch,r=t.id;const o=t.type,n=t.tags,a=$();e=i.common_default.sanitizeText(e,a),r&&(r=i.common_default.sanitizeText(r,a));const c=g.records.branches.get(g.records.currBranch),d=g.records.branches.get(e),m=c?g.records.commits.get(c):void 0,l=d?g.records.commits.get(d):void 0;if(m&&l&&m.branch===e)throw new Error(`Cannot merge branch '${e}' into itself.`);if(g.records.currBranch===e){const t=new Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:["branch abc"]},t}if(void 0===m||!m){const t=new Error(`Incorrect usage of "merge". Current branch (${g.records.currBranch})has no commits`);throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:["commit"]},t}if(!g.records.branches.has(e)){const t=new Error('Incorrect usage of "merge". Branch to be merged ('+e+") does not exist");throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:[`branch ${e}`]},t}if(void 0===l||!l){const t=new Error('Incorrect usage of "merge". Branch to be merged ('+e+") has no commits");throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:['"commit"']},t}if(m===l){const t=new Error('Incorrect usage of "merge". Both branches have same head');throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:["branch abc"]},t}if(r&&g.records.commits.has(r)){const t=new Error('Incorrect usage of "merge". Commit with id:'+r+" already exists, use different custom id");throw t.hash={text:`merge ${e} ${r} ${o} ${n?.join(" ")}`,token:`merge ${e} ${r} ${o} ${n?.join(" ")}`,expected:[`merge ${e} ${r}_UNIQUE ${o} ${n?.join(" ")}`]},t}const f=d||"",y={id:r||`${g.records.seq}-${p()}`,message:`merged branch ${e} into ${g.records.currBranch}`,seq:g.records.seq++,parents:null==g.records.head?[]:[g.records.head.id,f],branch:g.records.currBranch,type:h.MERGE,customType:o,customId:!!r,tags:n??[]};g.records.head=y,g.records.commits.set(y.id,y),g.records.branches.set(g.records.currBranch,y.id),s.log.debug(g.records.branches),s.log.debug("in mergeBranch")},"merge"),k=(0,c.__name)(function(t){let e=t.id,r=t.targetId,o=t.tags,n=t.parent;s.log.debug("Entering cherryPick:",e,r,o);const a=$();if(e=i.common_default.sanitizeText(e,a),r=i.common_default.sanitizeText(r,a),o=o?.map(t=>i.common_default.sanitizeText(t,a)),n=i.common_default.sanitizeText(n,a),!e||!g.records.commits.has(e)){const t=new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw t.hash={text:`cherryPick ${e} ${r}`,token:`cherryPick ${e} ${r}`,expected:["cherry-pick abc"]},t}const c=g.records.commits.get(e);if(void 0===c||!c)throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(n&&(!Array.isArray(c.parents)||!c.parents.includes(n)))throw new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");const d=c.branch;if(c.type===h.MERGE&&!n)throw new Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");if(!r||!g.records.commits.has(r)){if(d===g.records.currBranch){const t=new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw t.hash={text:`cherryPick ${e} ${r}`,token:`cherryPick ${e} ${r}`,expected:["cherry-pick abc"]},t}const t=g.records.branches.get(g.records.currBranch);if(void 0===t||!t){const t=new Error(`Incorrect usage of "cherry-pick". Current branch (${g.records.currBranch})has no commits`);throw t.hash={text:`cherryPick ${e} ${r}`,token:`cherryPick ${e} ${r}`,expected:["cherry-pick abc"]},t}const a=g.records.commits.get(t);if(void 0===a||!a){const t=new Error(`Incorrect usage of "cherry-pick". Current branch (${g.records.currBranch})has no commits`);throw t.hash={text:`cherryPick ${e} ${r}`,token:`cherryPick ${e} ${r}`,expected:["cherry-pick abc"]},t}const i={id:g.records.seq+"-"+p(),message:`cherry-picked ${c?.message} into ${g.records.currBranch}`,seq:g.records.seq++,parents:null==g.records.head?[]:[g.records.head.id,c.id],branch:g.records.currBranch,type:h.CHERRY_PICK,tags:o?o.filter(Boolean):[`cherry-pick:${c.id}${c.type===h.MERGE?`|parent:${n}`:""}`]};g.records.head=i,g.records.commits.set(i.id,i),g.records.branches.set(g.records.currBranch,i.id),s.log.debug(g.records.branches),s.log.debug("in cherryPick")}},"cherryPick"),B=(0,c.__name)(function(t){if(t=i.common_default.sanitizeText(t,$()),!g.records.branches.has(t)){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}{g.records.currBranch=t;const e=g.records.branches.get(g.records.currBranch);g.records.head=void 0!==e&&e?g.records.commits.get(e)??null:null}},"checkout");function C(t,e,r){const o=t.indexOf(e);-1===o?t.push(r):t.splice(o,1,r)}function E(t){const e=t.reduce((t,e)=>t.seq>e.seq?t:e,t[0]);let r="";t.forEach(function(t){r+=t===e?"\t*":"\t|"});const o=[r,e.id,e.seq];for(const t in g.records.branches)g.records.branches.get(t)===e.id&&o.push(t);if(s.log.debug(o.join(" ")),e.parents&&2==e.parents.length&&e.parents[0]&&e.parents[1]){const r=g.records.commits.get(e.parents[0]);C(t,e,r),e.parents[1]&&t.push(g.records.commits.get(e.parents[1]))}else{if(0==e.parents.length)return;if(e.parents[0]){const r=g.records.commits.get(e.parents[0]);C(t,e,r)}}E(t=f(t,t=>t.id))}(0,c.__name)(C,"upsert"),(0,c.__name)(E,"prettyPrintCommitHistory");var T=(0,c.__name)(function(){s.log.debug(g.records.commits),E([R()[0]])},"prettyPrint"),L=(0,c.__name)(function(){g.reset(),(0,i.clear)()},"clear"),M=(0,c.__name)(function(){return[...g.records.branchConfig.values()].map((t,e)=>null!==t.order&&void 0!==t.order?t:{...t,order:parseFloat(`0.${e}`)}).sort((t,e)=>(t.order??0)-(e.order??0)).map(({name:t})=>({name:t}))},"getBranchesAsObjArray"),v=(0,c.__name)(function(){return g.records.branches},"getBranches"),I=(0,c.__name)(function(){return g.records.commits},"getCommits"),R=(0,c.__name)(function(){const t=[...g.records.commits.values()];return t.forEach(function(t){s.log.debug(t.id)}),t.sort((t,e)=>t.seq-e.seq),t},"getCommitsArray"),A={commitType:h,getConfig:$,setDirection:y,setOptions:x,getOptions:u,commit:b,branch:_,merge:w,cherryPick:k,checkout:B,prettyPrint:T,clear:L,getBranchesAsObjArray:M,getBranches:v,getCommits:I,getCommitsArray:R,getCurrentBranch:(0,c.__name)(function(){return g.records.currBranch},"getCurrentBranch"),getDirection:(0,c.__name)(function(){return g.records.direction},"getDirection"),getHead:(0,c.__name)(function(){return g.records.head},"getHead"),setAccTitle:i.setAccTitle,getAccTitle:i.getAccTitle,getAccDescription:i.getAccDescription,setAccDescription:i.setAccDescription,setDiagramTitle:i.setDiagramTitle,getDiagramTitle:i.getDiagramTitle},P=(0,c.__name)((t,e)=>{(0,n.populateCommonDb)(t,e),t.dir&&e.setDirection(t.dir);for(const r of t.statements)O(r,e)},"populate"),O=(0,c.__name)((t,e)=>{const r={Commit:(0,c.__name)(t=>e.commit(G(t)),"Commit"),Branch:(0,c.__name)(t=>e.branch(S(t)),"Branch"),Merge:(0,c.__name)(t=>e.merge(D(t)),"Merge"),Checkout:(0,c.__name)(t=>e.checkout(H(t)),"Checkout"),CherryPicking:(0,c.__name)(t=>e.cherryPick(W(t)),"CherryPicking")}[t.$type];r?r(t):s.log.error(`Unknown statement type: ${t.$type}`)},"parseStatement"),G=(0,c.__name)(t=>({id:t.id,msg:t.message??"",type:void 0!==t.type?h[t.type]:h.NORMAL,tags:t.tags??void 0}),"parseCommit"),S=(0,c.__name)(t=>({name:t.name,order:t.order??0}),"parseBranch"),D=(0,c.__name)(t=>({branch:t.branch,id:t.id??"",type:void 0!==t.type?h[t.type]:void 0,tags:t.tags??void 0}),"parseMerge"),H=(0,c.__name)(t=>t.branch,"parseCheckout"),W=(0,c.__name)(t=>({id:t.id,targetId:"",tags:0===t.tags?.length?void 0:t.tags,parent:t.parent}),"parseCherryPicking"),q={parse:(0,c.__name)(async t=>{const e=await(0,d.parse)("gitGraph",t);s.log.debug(e),P(e,A)},"parse")},z=10,F=40,N=new Set(["redux","redux-dark","redux-color","redux-dark-color"]),j=new Set(["redux-color","redux-dark-color"]),V=new Set(["dark","redux-dark","redux-dark-color","neo-dark"]),K=(0,c.__name)((t,e,r=!1)=>r&&t>0?(t-1)%(e-1)+1:t%e,"calcColorIndex"),Y=new Map,U=new Map,J=new Map,Q=[],X=0,Z="LR",tt=(0,c.__name)(()=>{Y.clear(),U.clear(),J.clear(),X=0,Q=[],Z="LR"},"clear"),et=(0,c.__name)(t=>{const e=document.createElementNS("http://www.w3.org/2000/svg","text");return("string"==typeof t?t.split(/\\n|\n|<br\s*\/?>/gi):t).forEach(t=>{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=t.trim(),e.appendChild(r)}),e},"drawText"),rt=(0,c.__name)(t=>{let e,r,o;return"BT"===Z?(r=(0,c.__name)((t,e)=>t<=e,"comparisonFunc"),o=1/0):(r=(0,c.__name)((t,e)=>t>=e,"comparisonFunc"),o=0),t.forEach(t=>{const n="TB"===Z||"BT"==Z?U.get(t)?.y:U.get(t)?.x;void 0!==n&&r(n,o)&&(e=t,o=n)}),e},"findClosestParent"),ot=(0,c.__name)(t=>{let e="",r=1/0;return t.forEach(t=>{const o=U.get(t).y;o<=r&&(e=t,r=o)}),e||void 0},"findClosestParentBT"),nt=(0,c.__name)((t,e,r)=>{let o=r,n=r;const a=[];t.forEach(t=>{const r=e.get(t);if(!r)throw new Error(`Commit not found for key ${t}`);r.parents.length?(o=it(r),n=Math.max(o,n)):a.push(r),st(r,o)}),o=n,a.forEach(t=>{ct(t,o,r)}),t.forEach(t=>{const r=e.get(t);if(r?.parents.length){const t=ot(r.parents);o=U.get(t).y-F,o<=n&&(n=o);const e=Y.get(r.branch).pos,a=o-z;U.set(r.id,{x:e,y:a})}})},"setParallelBTPos"),at=(0,c.__name)(t=>{const e=rt(t.parents.filter(t=>null!==t));if(!e)throw new Error(`Closest parent not found for commit ${t.id}`);const r=U.get(e)?.y;if(void 0===r)throw new Error(`Closest parent position not found for commit ${t.id}`);return r},"findClosestParentPos"),it=(0,c.__name)(t=>at(t)+F,"calculateCommitPosition"),st=(0,c.__name)((t,e)=>{const r=Y.get(t.branch);if(!r)throw new Error(`Branch not found for commit ${t.id}`);const o=r.pos,n=e+z;return U.set(t.id,{x:o,y:n}),{x:o,y:n}},"setCommitPosition"),ct=(0,c.__name)((t,e,r)=>{const o=Y.get(t.branch);if(!o)throw new Error(`Branch not found for commit ${t.id}`);const n=e+r,a=o.pos;U.set(t.id,{x:a,y:n})},"setRootPosition"),dt=(0,c.__name)((t,e,r,o,n,a)=>{const{theme:s}=(0,i.getConfig2)(),c=N.has(s??""),d=j.has(s??""),m=V.has(s??"");if(a===h.HIGHLIGHT)t.append("rect").attr("x",r.x-10+(c?3:0)).attr("y",r.y-10+(c?3:0)).attr("width",c?14:20).attr("height",c?14:20).attr("class",`commit ${e.id} commit-highlight${K(n,8,d)} ${o}-outer`),t.append("rect").attr("x",r.x-6+(c?2:0)).attr("y",r.y-6+(c?2:0)).attr("width",c?8:12).attr("height",c?8:12).attr("class",`commit ${e.id} commit${K(n,8,d)} ${o}-inner`);else if(a===h.CHERRY_PICK)t.append("circle").attr("cx",r.x).attr("cy",r.y).attr("r",c?7:10).attr("class",`commit ${e.id} ${o}`),t.append("circle").attr("cx",r.x-3).attr("cy",r.y+2).attr("r",c?2.5:2.75).attr("fill",m?"#000000":"#fff").attr("class",`commit ${e.id} ${o}`),t.append("circle").attr("cx",r.x+3).attr("cy",r.y+2).attr("r",c?2.5:2.75).attr("fill",m?"#000000":"#fff").attr("class",`commit ${e.id} ${o}`),t.append("line").attr("x1",r.x+3).attr("y1",r.y+1).attr("x2",r.x).attr("y2",r.y-5).attr("stroke",m?"#000000":"#fff").attr("class",`commit ${e.id} ${o}`),t.append("line").attr("x1",r.x-3).attr("y1",r.y+1).attr("x2",r.x).attr("y2",r.y-5).attr("stroke",m?"#000000":"#fff").attr("class",`commit ${e.id} ${o}`);else{const i=t.append("circle");if(i.attr("cx",r.x),i.attr("cy",r.y),i.attr("r",c?7:10),i.attr("class",`commit ${e.id} commit${K(n,8,d)}`),a===h.MERGE){const a=t.append("circle");a.attr("cx",r.x),a.attr("cy",r.y),a.attr("r",c?5:6),a.attr("class",`commit ${o} ${e.id} commit${K(n,8,d)}`)}if(a===h.REVERSE){const a=c?4:5;t.append("path").attr("d",`M ${r.x-a},${r.y-a}L${r.x+a},${r.y+a}M${r.x-a},${r.y+a}L${r.x+a},${r.y-a}`).attr("class",`commit ${o} ${e.id} commit${K(n,8,d)}`)}}},"drawCommitBullet"),mt=(0,c.__name)((t,e,r,o,n)=>{if(e.type!==h.CHERRY_PICK&&(e.customId&&e.type===h.MERGE||e.type!==h.MERGE)&&n.showCommitLabel){const a=t.append("g"),i=a.insert("rect").attr("class","commit-label-bkg"),s=a.append("text").attr("x",o).attr("y",r.y+25).attr("class","commit-label").text(e.id),c=s.node()?.getBBox();if(c&&(i.attr("x",r.posWithOffset-c.width/2-2).attr("y",r.y+13.5).attr("width",c.width+4).attr("height",c.height+4),"TB"===Z||"BT"===Z?(i.attr("x",r.x-(c.width+16+5)).attr("y",r.y-12),s.attr("x",r.x-(c.width+16)).attr("y",r.y+c.height-12)):s.attr("x",r.posWithOffset-c.width/2),n.rotateCommitLabel))if("TB"===Z||"BT"===Z)s.attr("transform","rotate(-45, "+r.x+", "+r.y+")"),i.attr("transform","rotate(-45, "+r.x+", "+r.y+")");else{const t=-7.5-(c.width+10)/25*9.5,e=10+c.width/25*8.5;a.attr("transform","translate("+t+", "+e+") rotate(-45, "+o+", "+r.y+")")}}},"drawCommitLabel"),ht=(0,c.__name)((t,e,r,o)=>{if(e.tags.length>0){let n=0,a=0,i=0;const s=[];for(const o of e.tags.reverse()){const e=t.insert("polygon"),c=t.append("circle"),d=t.append("text").attr("y",r.y-16-n).attr("class","tag-label").text(o),m=d.node()?.getBBox();if(!m)throw new Error("Tag bbox not found");a=Math.max(a,m.width),i=Math.max(i,m.height),d.attr("x",r.posWithOffset-m.width/2),s.push({tag:d,hole:c,rect:e,yOffset:n}),n+=20}for(const{tag:t,hole:e,rect:n,yOffset:c}of s){const s=i/2,d=r.y-19.2-c;if(n.attr("class","tag-label-bkg").attr("points",`\n ${o-a/2-2},${d+2} \n ${o-a/2-2},${d-2}\n ${r.posWithOffset-a/2-4},${d-s-2}\n ${r.posWithOffset+a/2+4},${d-s-2}\n ${r.posWithOffset+a/2+4},${d+s+2}\n ${r.posWithOffset-a/2-4},${d+s+2}`),e.attr("cy",d).attr("cx",o-a/2+2).attr("r",1.5).attr("class","tag-hole"),"TB"===Z||"BT"===Z){const i=o+c;n.attr("class","tag-label-bkg").attr("points",`\n ${r.x},${i+2}\n ${r.x},${i-2}\n ${r.x+z},${i-s-2}\n ${r.x+z+a+4},${i-s-2}\n ${r.x+z+a+4},${i+s+2}\n ${r.x+z},${i+s+2}`).attr("transform","translate(12,12) rotate(45, "+r.x+","+o+")"),e.attr("cx",r.x+2).attr("cy",i).attr("transform","translate(12,12) rotate(45, "+r.x+","+o+")"),t.attr("x",r.x+5).attr("y",i+3).attr("transform","translate(14,14) rotate(45, "+r.x+","+o+")")}}}},"drawCommitTags"),lt=(0,c.__name)(t=>{switch(t.customType??t.type){case h.NORMAL:return"commit-normal";case h.REVERSE:return"commit-reverse";case h.HIGHLIGHT:return"commit-highlight";case h.MERGE:return"commit-merge";case h.CHERRY_PICK:return"commit-cherry-pick";default:return"commit-normal"}},"getCommitClassType"),$t=(0,c.__name)((t,e,r,o)=>{const n={x:0,y:0};if(!(t.parents.length>0))return"TB"===e?30:"BT"===e?(o.get(t.id)??n).y-F:0;{const r=rt(t.parents);if(r){const a=o.get(r)??n;return"TB"===e?a.y+F:"BT"===e?(o.get(t.id)??n).y-F:a.x+F}}return 0},"calculatePosition"),gt=(0,c.__name)((t,e,r)=>{const o="BT"===Z&&r?e:e+z,n=Y.get(t.branch)?.pos,a="TB"===Z||"BT"===Z?Y.get(t.branch)?.pos:o;if(void 0===a||void 0===n)throw new Error(`Position were undefined for commit ${t.id}`);const s=N.has((0,i.getConfig2)().theme??"");return{x:a,y:"TB"===Z||"BT"===Z?o:n+(s?7:-2),posWithOffset:o}},"getCommitPosition"),pt=(0,c.__name)((t,e,r,o)=>{const n=t.append("g").attr("class","commit-bullets"),a=t.append("g").attr("class","commit-labels");let i="TB"===Z||"BT"===Z?30:0;const s=[...e.keys()],d=o.parallelCommits??!1,m=(0,c.__name)((t,r)=>{const o=e.get(t)?.seq,n=e.get(r)?.seq;return void 0!==o&&void 0!==n?o-n:0},"sortKeys");let h=s.sort(m);"BT"===Z&&(d&&nt(h,e,i),h=h.reverse()),h.forEach(t=>{const s=e.get(t);if(!s)throw new Error(`Commit not found for key ${t}`);d&&(i=$t(s,Z,i,U));const c=gt(s,i,d);if(r){const t=lt(s),e=s.customType??s.type,r=Y.get(s.branch)?.index??0;dt(n,s,c,t,r,e),mt(a,s,c,i,o),ht(a,s,c,i)}"TB"===Z||"BT"===Z?U.set(s.id,{x:c.x,y:c.posWithOffset}):U.set(s.id,{x:c.posWithOffset,y:c.y}),i="BT"===Z&&d?i+F:i+F+z,i>X&&(X=i)})},"drawCommits"),ft=(0,c.__name)((t,e,r,o,n)=>{const a=("TB"===Z||"BT"===Z?r.x<o.x:r.y<o.y)?e.branch:t.branch,i=(0,c.__name)(t=>t.branch===a,"isOnBranchToGetCurve"),s=(0,c.__name)(r=>r.seq>t.seq&&r.seq<e.seq,"isBetweenCommits");return[...n.values()].some(t=>s(t)&&i(t))},"shouldRerouteArrow"),yt=(0,c.__name)((t,e,r=0)=>{const o=t+Math.abs(t-e)/2;if(r>5)return o;if(Q.every(t=>Math.abs(t-o)>=10))return Q.push(o),o;const n=Math.abs(t-e);return yt(t,e-n/5,r+1)},"findLane"),xt=(0,c.__name)((t,e,r,o)=>{const{theme:n}=(0,i.getConfig2)(),a=j.has(n??""),s=U.get(e.id),c=U.get(r.id);if(void 0===s||void 0===c)throw new Error(`Commit positions not found for commits ${e.id} and ${r.id}`);const d=ft(e,r,s,c,o);let m,l="",$="",g=0,p=0,f=Y.get(r.branch)?.index;if(r.type===h.MERGE&&e.id!==r.parents[0]&&(f=Y.get(e.branch)?.index),d){l="A 10 10, 0, 0, 0,",$="A 10 10, 0, 0, 1,",g=10,p=10;const t=s.y<c.y?yt(s.y,c.y):yt(c.y,s.y),r=s.x<c.x?yt(s.x,c.x):yt(c.x,s.x);"TB"===Z?s.x<c.x?m=`M ${s.x} ${s.y} L ${r-g} ${s.y} ${$} ${r} ${s.y+p} L ${r} ${c.y-g} ${l} ${r+p} ${c.y} L ${c.x} ${c.y}`:(f=Y.get(e.branch)?.index,m=`M ${s.x} ${s.y} L ${r+g} ${s.y} ${l} ${r} ${s.y+p} L ${r} ${c.y-g} ${$} ${r-p} ${c.y} L ${c.x} ${c.y}`):"BT"===Z?s.x<c.x?m=`M ${s.x} ${s.y} L ${r-g} ${s.y} ${l} ${r} ${s.y-p} L ${r} ${c.y+g} ${$} ${r+p} ${c.y} L ${c.x} ${c.y}`:(f=Y.get(e.branch)?.index,m=`M ${s.x} ${s.y} L ${r+g} ${s.y} ${$} ${r} ${s.y-p} L ${r} ${c.y+g} ${l} ${r-p} ${c.y} L ${c.x} ${c.y}`):s.y<c.y?m=`M ${s.x} ${s.y} L ${s.x} ${t-g} ${l} ${s.x+p} ${t} L ${c.x-g} ${t} ${$} ${c.x} ${t+p} L ${c.x} ${c.y}`:(f=Y.get(e.branch)?.index,m=`M ${s.x} ${s.y} L ${s.x} ${t+g} ${$} ${s.x+p} ${t} L ${c.x-g} ${t} ${l} ${c.x} ${t-p} L ${c.x} ${c.y}`)}else l="A 20 20, 0, 0, 0,",$="A 20 20, 0, 0, 1,",g=20,p=20,"TB"===Z?(s.x<c.x&&(m=r.type===h.MERGE&&e.id!==r.parents[0]?`M ${s.x} ${s.y} L ${s.x} ${c.y-g} ${l} ${s.x+p} ${c.y} L ${c.x} ${c.y}`:`M ${s.x} ${s.y} L ${c.x-g} ${s.y} ${$} ${c.x} ${s.y+p} L ${c.x} ${c.y}`),s.x>c.x&&(l="A 20 20, 0, 0, 0,",$="A 20 20, 0, 0, 1,",g=20,p=20,m=r.type===h.MERGE&&e.id!==r.parents[0]?`M ${s.x} ${s.y} L ${s.x} ${c.y-g} ${$} ${s.x-p} ${c.y} L ${c.x} ${c.y}`:`M ${s.x} ${s.y} L ${c.x+g} ${s.y} ${l} ${c.x} ${s.y+p} L ${c.x} ${c.y}`),s.x===c.x&&(m=`M ${s.x} ${s.y} L ${c.x} ${c.y}`)):"BT"===Z?(s.x<c.x&&(m=r.type===h.MERGE&&e.id!==r.parents[0]?`M ${s.x} ${s.y} L ${s.x} ${c.y+g} ${$} ${s.x+p} ${c.y} L ${c.x} ${c.y}`:`M ${s.x} ${s.y} L ${c.x-g} ${s.y} ${l} ${c.x} ${s.y-p} L ${c.x} ${c.y}`),s.x>c.x&&(l="A 20 20, 0, 0, 0,",$="A 20 20, 0, 0, 1,",g=20,p=20,m=r.type===h.MERGE&&e.id!==r.parents[0]?`M ${s.x} ${s.y} L ${s.x} ${c.y+g} ${l} ${s.x-p} ${c.y} L ${c.x} ${c.y}`:`M ${s.x} ${s.y} L ${c.x+g} ${s.y} ${$} ${c.x} ${s.y-p} L ${c.x} ${c.y}`),s.x===c.x&&(m=`M ${s.x} ${s.y} L ${c.x} ${c.y}`)):(s.y<c.y&&(m=r.type===h.MERGE&&e.id!==r.parents[0]?`M ${s.x} ${s.y} L ${c.x-g} ${s.y} ${$} ${c.x} ${s.y+p} L ${c.x} ${c.y}`:`M ${s.x} ${s.y} L ${s.x} ${c.y-g} ${l} ${s.x+p} ${c.y} L ${c.x} ${c.y}`),s.y>c.y&&(m=r.type===h.MERGE&&e.id!==r.parents[0]?`M ${s.x} ${s.y} L ${c.x-g} ${s.y} ${l} ${c.x} ${s.y-p} L ${c.x} ${c.y}`:`M ${s.x} ${s.y} L ${s.x} ${c.y+g} ${$} ${s.x+p} ${c.y} L ${c.x} ${c.y}`),s.y===c.y&&(m=`M ${s.x} ${s.y} L ${c.x} ${c.y}`));if(void 0===m)throw new Error("Line definition not found");t.append("path").attr("d",m).attr("class","arrow arrow"+K(f,8,a))},"drawArrow"),ut=(0,c.__name)((t,e)=>{const r=t.append("g").attr("class","commit-arrows");[...e.keys()].forEach(t=>{const o=e.get(t);o.parents&&o.parents.length>0&&o.parents.forEach(t=>{xt(r,e.get(t),o,e)})})},"drawArrows"),bt=(0,c.__name)((t,e,r,o)=>{const{look:n,theme:a,themeVariables:s}=(0,i.getConfig2)(),{dropShadow:c,THEME_COLOR_LIMIT:d}=s,m=N.has(a??""),h=j.has(a??""),l=t.append("g");e.forEach((t,e)=>{const a=K(e,m?d:8,h),i=Y.get(t.name)?.pos;if(void 0===i)throw new Error(`Position not found for branch ${t.name}`);const s="TB"===Z||"BT"===Z?i:m?i+6+1:i-2,$=l.append("line");$.attr("x1",0),$.attr("y1",s),$.attr("x2",X),$.attr("y2",s),$.attr("class","branch branch"+a),"TB"===Z?($.attr("y1",30),$.attr("x1",i),$.attr("y2",X),$.attr("x2",i)):"BT"===Z&&($.attr("y1",X),$.attr("x1",i),$.attr("y2",30),$.attr("x2",i)),Q.push(s);const g=t.name,p=et(g),f=l.insert("rect"),y=l.insert("g").attr("class","branchLabel").insert("g").attr("class","label branch-label"+a);y.node().appendChild(p);const x=p.getBBox(),u=m?0:4,b=m?16:0,_=m?12:0;"neo"===n&&f.attr("data-look","neo"),f.attr("class","branchLabelBkg label"+a).attr("style","neo"===n?`filter:${m?`url(#${o}-drop-shadow)`:c}`:"").attr("rx",u).attr("ry",u).attr("x",-x.width-4-(!0===r.rotateCommitLabel?30:0)).attr("y",-x.height/2+10).attr("width",x.width+18+b).attr("height",x.height+4+_),y.attr("transform","translate("+(-x.width-14-(!0===r.rotateCommitLabel?30:0)+b/2)+", "+(s-x.height/2-2)+")"),"TB"===Z?(f.attr("x",i-x.width/2-10).attr("y",0),y.attr("transform","translate("+(i-x.width/2-5)+", 0)"),m&&(f.attr("transform",`translate(${-b/2-3}, ${-_-10})`),y.attr("transform","translate("+(i-x.width/2-5)+", "+(2*-_+7)+")"))):"BT"===Z?(f.attr("x",i-x.width/2-10).attr("y",X),y.attr("transform","translate("+(i-x.width/2-5)+", "+X+")"),m&&(f.attr("transform",`translate(${-b/2-3}, ${_+10})`),y.attr("transform","translate("+(i-x.width/2-5)+", "+(X+2*_+4)+")"))):f.attr("transform","translate(-19, "+(s-12-_/2)+")")})},"drawBranches"),_t=(0,c.__name)(function(t,e,r,o,n){return Y.set(t,{pos:e,index:r}),e+(50+(n?40:0)+("TB"===Z||"BT"===Z?o.width/2:0))},"setBranchPosition"),wt={draw:(0,c.__name)(function(t,e,r,o){tt(),s.log.debug("in gitgraph renderer",t+"\n","id:",e,r);const n=o.db;if(!n.getConfig)return void s.log.error("getConfig method is not available on db");const c=n.getConfig(),d=c.rotateCommitLabel??!1;J=n.getCommits();const h=n.getBranchesAsObjArray();Z=n.getDirection();const l=(0,m.select)(`[id="${e}"]`),{look:$,theme:g,themeVariables:p}=(0,i.getConfig2)(),{useGradient:f,gradientStart:y,gradientStop:x,filterColor:u}=p;if(f){const t=l.append("defs").append("linearGradient").attr("id",e+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");t.append("stop").attr("offset","0%").attr("stop-color",y).attr("stop-opacity",1),t.append("stop").attr("offset","100%").attr("stop-color",x).attr("stop-opacity",1)}"neo"===$&&N.has(g??"")&&l.append("defs").append("filter").attr("id",e+"-drop-shadow").attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",u);let b=0;h.forEach((t,e)=>{const r=et(t.name),o=l.append("g"),n=o.insert("g").attr("class","branchLabel"),a=n.insert("g").attr("class","label branch-label");a.node()?.appendChild(r);const i=r.getBBox();b=_t(t.name,b,e,i,d),a.remove(),n.remove(),o.remove()}),pt(l,J,!1,c),c.showBranches&&bt(l,h,c,e),ut(l,J),pt(l,J,!0,c),a.utils_default.insertTitle(l,"gitTitleText",c.titleTopMargin??0,n.getDiagramTitle()),(0,i.setupGraphViewbox2)(void 0,l,c.diagramPadding,c.useMaxWidth)},"draw")},kt=new Set(["redux","redux-dark","redux-color","redux-dark-color"]),Bt=new Set(["redux-color","redux-dark-color"]),Ct=new Set(["neo","neo-dark"]),Et=new Set(["dark","redux-dark","redux-dark-color","neo-dark"]),Tt=new Set(["redux","redux-dark","redux-color","redux-dark-color","neo","neo-dark"]),Lt=(0,c.__name)(t=>{const{svgId:e}=t;let r="";if(t.useGradient&&e)for(let o=0;o<t.THEME_COLOR_LIMIT;o++)r+=`\n .label${o} { fill: ${t.mainBkg}; stroke: url(${e}-gradient); stroke-width: ${t.strokeWidth};}\n `;return r},"genGitGraphGradient"),Mt=(0,c.__name)(t=>{const e=(0,i.getConfig)(),{theme:r,themeVariables:o}=e,{borderColorArray:n}=o,a=kt.has(r);if(Ct.has(r)){let e="";for(let r=0;r<t.THEME_COLOR_LIMIT;r++)if(0===r)e+=`\n .branch-label${r} { fill: ${t.nodeBorder};}\n .commit${r} { stroke: ${t.nodeBorder}; }\n .commit-highlight${r} { stroke: ${t.nodeBorder}; fill: ${t.nodeBorder}; }\n .arrow${r} { stroke: ${t.nodeBorder}; }\n .commit-bullets { fill: ${t.nodeBorder}; }\n .commit-cherry-pick${r} { stroke: ${t.nodeBorder}; }\n ${Lt(t)}`;else{const o=r%8;e+=`\n .branch-label${r} { fill: ${t["gitBranchLabel"+o]}; }\n .commit${r} { stroke: ${t["git"+o]}; fill: ${t["git"+o]}; }\n .commit-highlight${r} { stroke: ${t["gitInv"+o]}; fill: ${t["gitInv"+o]}; }\n .arrow${r} { stroke: ${t["git"+o]}; }\n `}return e}if(Bt.has(r)){let e="";for(let o=0;o<t.THEME_COLOR_LIMIT;o++)if(0===o)e+=`\n .branch-label${o} { fill: ${t.nodeBorder}; ${a?`font-weight:${t.noteFontWeight}`:""} }\n .commit${o} { stroke: ${t.nodeBorder}; }\n .commit-highlight${o} { stroke: ${t.nodeBorder}; fill: ${t.mainBkg}; }\n .label${o} { fill: ${t.mainBkg}; stroke: ${t.nodeBorder}; stroke-width: ${t.strokeWidth}; ${a?`font-weight:${t.noteFontWeight}`:""} }\n .arrow${o} { stroke: ${t.nodeBorder}; }\n .commit-bullets { fill: ${t.nodeBorder}; }\n `;else{const i=o%n.length;e+=`\n .branch-label${o} { fill: ${t.nodeBorder}; ${a?`font-weight:${t.noteFontWeight}`:""} }\n .commit${o} { stroke: ${n[i]}; fill: ${n[i]}; }\n .commit-highlight${o} { stroke: ${n[i]}; fill: ${n[i]}; }\n .label${o} { fill: ${Et.has(r)?t.mainBkg:n[i]}; stroke: ${n[i]}; stroke-width: ${t.strokeWidth}; }\n .arrow${o} { stroke: ${n[i]}; }\n `}return e}{let e="";for(let r=0;r<t.THEME_COLOR_LIMIT;r++)e+=`\n .branch-label${r} { fill: ${t.nodeBorder}; ${a?`font-weight:${t.noteFontWeight}`:""} }\n .commit${r} { stroke: ${t.nodeBorder}; }\n .commit-highlight${r} { stroke: ${t.nodeBorder}; fill: ${t.nodeBorder}; }\n .label${r} { fill: ${t.mainBkg}; stroke: ${t.nodeBorder}; stroke-width: ${t.strokeWidth}; ${a?`font-weight:${t.noteFontWeight}`:""}}\n .arrow${r} { stroke: ${t.nodeBorder}; }\n .commit-bullets { fill: ${t.nodeBorder}; }\n .commit-cherry-pick${r} { stroke: ${t.nodeBorder}; }\n `;return e}},"genColor"),vt=(0,c.__name)(t=>`${Array.from({length:t.THEME_COLOR_LIMIT},(t,e)=>e).map(e=>{const r=e%8;return`\n .branch-label${e} { fill: ${t["gitBranchLabel"+r]}; }\n .commit${e} { stroke: ${t["git"+r]}; fill: ${t["git"+r]}; }\n .commit-highlight${e} { stroke: ${t["gitInv"+r]}; fill: ${t["gitInv"+r]}; }\n .label${e} { fill: ${t["git"+r]}; }\n .arrow${e} { stroke: ${t["git"+r]}; }\n `}).join("\n")}`,"normalTheme"),It={parser:q,db:A,renderer:wt,styles:(0,c.__name)(t=>{const e=(0,i.getConfig)(),{theme:r}=e,o=Tt.has(r);return`\n .commit-id,\n .commit-msg,\n .branch-label {\n fill: lightgrey;\n color: lightgrey;\n font-family: 'trebuchet ms', verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n }\n \n ${o?Mt(t):vt(t)}\n\n .branch {\n stroke-width: ${t.strokeWidth};\n stroke: ${t.commitLineColor??t.lineColor};\n stroke-dasharray: ${o?"4 2":"2"};\n }\n .commit-label { font-size: ${t.commitLabelFontSize}; fill: ${o?t.nodeBorder:t.commitLabelColor}; ${o?`font-weight:${t.noteFontWeight};`:""}}\n .commit-label-bkg { font-size: ${t.commitLabelFontSize}; fill: ${o?"transparent":t.commitLabelBackground}; opacity: ${o?"":.5}; }\n .tag-label { font-size: ${t.tagLabelFontSize}; fill: ${t.tagLabelColor};}\n .tag-label-bkg { fill: ${o?t.mainBkg:t.tagLabelBackground}; stroke: ${o?t.nodeBorder:t.tagLabelBorder}; ${o?`filter:${t.dropShadow}`:""} }\n .tag-hole { fill: ${t.textColor}; }\n\n .commit-merge {\n stroke: ${o?t.mainBkg:t.primaryColor};\n fill: ${o?t.mainBkg:t.primaryColor};\n }\n .commit-reverse {\n stroke: ${o?t.mainBkg:t.primaryColor};\n fill: ${o?t.mainBkg:t.primaryColor};\n stroke-width: ${o?t.strokeWidth:3};\n }\n .commit-highlight-outer {\n }\n .commit-highlight-inner {\n stroke: ${o?t.mainBkg:t.primaryColor};\n fill: ${o?t.mainBkg:t.primaryColor};\n }\n\n .arrow {\n /* Intentional: neo themes keep the bold 8px arrow (like classic themes); only redux-geometry themes use the thinner options.strokeWidth. */\n stroke-width: ${kt.has(r)?t.strokeWidth:8};\n stroke-linecap: round;\n fill: none\n }\n .gitTitleText {\n text-anchor: middle;\n font-size: 18px;\n fill: ${t.textColor};\n }\n`},"getStyles")}}};
//# sourceMappingURL=3126.js.map