@eventcatalogtest/studio
Version:
A drag and drop UI for distributed systems that keeps your diagrams where they belong – in your repo
24 lines • 4.15 kB
JavaScript
;exports.id=1212,exports.ids=[1212],exports.modules={1212:(a,b,c)=>{c.d(b,{diagram:()=>u});var d=c(87124),e=c(65299),f=c(58210),g=c(32892),h=c(66689),i={packet:[]},j=structuredClone(i),k=g.UI.packet,l=(0,g.K2)(()=>{let a=(0,e.$t)({...k,...(0,g.zj)().packet});return a.showBits&&(a.paddingY+=10),a},"getConfig"),m=(0,g.K2)(()=>j.packet,"getPacket"),n={pushWord:(0,g.K2)(a=>{a.length>0&&j.packet.push(a)},"pushWord"),getPacket:m,getConfig:l,clear:(0,g.K2)(()=>{(0,g.IU)(),j=structuredClone(i)},"clear"),setAccTitle:g.SV,getAccTitle:g.iN,setDiagramTitle:g.ke,getDiagramTitle:g.ab,getAccDescription:g.m7,setAccDescription:g.EI},o=(0,g.K2)(a=>{(0,d.S)(a,n);let b=-1,c=[],e=1,{bitsPerRow:f}=n.getConfig();for(let{start:d,end:h,bits:i,label:j}of a.blocks){if(void 0!==d&&void 0!==h&&h<d)throw Error(`Packet block ${d} - ${h} is invalid. End must be greater than start.`);if((d??=b+1)!==b+1)throw Error(`Packet block ${d} - ${h??d} is not contiguous. It should start from ${b+1}.`);if(0===i)throw Error(`Packet block ${d} is invalid. Cannot have a zero bit field.`);for(h??=d+(i??1)-1,i??=h-d+1,b=h,g.Rm.debug(`Packet block ${d} - ${b} with label ${j}`);c.length<=f+1&&n.getPacket().length<1e4;){let[a,b]=p({start:d,end:h,bits:i,label:j},e,f);if(c.push(a),a.end+1===e*f&&(n.pushWord(c),c=[],e++),!b)break;({start:d,end:h,bits:i,label:j}=b)}}n.pushWord(c)},"populate"),p=(0,g.K2)((a,b,c)=>{if(void 0===a.start)throw Error("start should have been set during first phase");if(void 0===a.end)throw Error("end should have been set during first phase");if(a.start>a.end)throw Error(`Block start ${a.start} is greater than block end ${a.end}.`);if(a.end+1<=b*c)return[a,void 0];let d=b*c-1,e=b*c;return[{start:a.start,end:d,label:a.label,bits:d-a.start},{start:e,end:a.end,label:a.label,bits:a.end-e}]},"getNextFittingBlock"),q={parse:(0,g.K2)(async a=>{let b=await (0,h.qg)("packet",a);g.Rm.debug(b),o(b)},"parse")},r=(0,g.K2)((a,b,c,d)=>{let e=d.db,h=e.getConfig(),{rowHeight:i,paddingY:j,bitWidth:k,bitsPerRow:l}=h,m=e.getPacket(),n=e.getDiagramTitle(),o=i+j,p=o*(m.length+1)-(n?0:i),q=k*l+2,r=(0,f.D)(b);for(let[a,b]of(r.attr("viewbox",`0 0 ${q} ${p}`),(0,g.a$)(r,p,q,h.useMaxWidth),m.entries()))s(r,b,a,h);r.append("text").text(n).attr("x",q/2).attr("y",p-o/2).attr("dominant-baseline","middle").attr("text-anchor","middle").attr("class","packetTitle")},"draw"),s=(0,g.K2)((a,b,c,{rowHeight:d,paddingX:e,paddingY:f,bitWidth:g,bitsPerRow:h,showBits:i})=>{let j=a.append("g"),k=c*(d+f)+f;for(let a of b){let b=a.start%h*g+1,c=(a.end-a.start+1)*g-e;if(j.append("rect").attr("x",b).attr("y",k).attr("width",c).attr("height",d).attr("class","packetBlock"),j.append("text").attr("x",b+c/2).attr("y",k+d/2).attr("class","packetLabel").attr("dominant-baseline","middle").attr("text-anchor","middle").text(a.label),!i)continue;let f=a.end===a.start,l=k-2;j.append("text").attr("x",b+(f?c/2:0)).attr("y",l).attr("class","packetByte start").attr("dominant-baseline","auto").attr("text-anchor",f?"middle":"start").text(a.start),f||j.append("text").attr("x",b+c).attr("y",l).attr("class","packetByte end").attr("dominant-baseline","auto").attr("text-anchor","end").text(a.end)}},"drawWord"),t={byteFontSize:"10px",startByteColor:"black",endByteColor:"black",labelColor:"black",labelFontSize:"12px",titleColor:"black",titleFontSize:"14px",blockStrokeColor:"black",blockStrokeWidth:"1",blockFillColor:"#efefef"},u={parser:q,db:n,renderer:{draw:r},styles:(0,g.K2)(({packet:a}={})=>{let b=(0,e.$t)(t,a);return`
.packetByte {
font-size: ${b.byteFontSize};
}
.packetByte.start {
fill: ${b.startByteColor};
}
.packetByte.end {
fill: ${b.endByteColor};
}
.packetLabel {
fill: ${b.labelColor};
font-size: ${b.labelFontSize};
}
.packetTitle {
fill: ${b.titleColor};
font-size: ${b.titleFontSize};
}
.packetBlock {
stroke: ${b.blockStrokeColor};
stroke-width: ${b.blockStrokeWidth};
fill: ${b.blockFillColor};
}
`},"styles")}},87124:(a,b,c)=>{function d(a,b){a.accDescr&&b.setAccDescription?.(a.accDescr),a.accTitle&&b.setAccTitle?.(a.accTitle),a.title&&b.setDiagramTitle?.(a.title)}c.d(b,{S:()=>d}),(0,c(32892).K2)(d,"populateCommonDb")}};