mirror of
https://github.com/logos-messaging/docs.waku.org.git
synced 2026-01-03 05:13:09 +00:00
1 line
4.4 KiB
JavaScript
1 line
4.4 KiB
JavaScript
"use strict";(self.webpackChunkwaku_guide=self.webpackChunkwaku_guide||[]).push([[6567],{16567:(t,e,a)=>{a.d(e,{diagram:()=>m});var r=a(73590),i=a(25871),n=a(13226),s=a(67633),o=a(40797),l=a(78731),c=s.UI.packet,d=class{constructor(){this.packet=[],this.setAccTitle=s.SV,this.getAccTitle=s.iN,this.setDiagramTitle=s.ke,this.getDiagramTitle=s.ab,this.getAccDescription=s.m7,this.setAccDescription=s.EI}static{(0,o.K2)(this,"PacketDB")}getConfig(){const t=(0,n.$t)({...c,...(0,s.zj)().packet});return t.showBits&&(t.paddingY+=10),t}getPacket(){return this.packet}pushWord(t){t.length>0&&this.packet.push(t)}clear(){(0,s.IU)(),this.packet=[]}},p=(0,o.K2)((t,e)=>{(0,i.S)(t,e);let a=-1,r=[],n=1;const{bitsPerRow:s}=e.getConfig();for(let{start:i,end:l,bits:c,label:d}of t.blocks){if(void 0!==i&&void 0!==l&&l<i)throw new Error(`Packet block ${i} - ${l} is invalid. End must be greater than start.`);if(i??=a+1,i!==a+1)throw new Error(`Packet block ${i} - ${l??i} is not contiguous. It should start from ${a+1}.`);if(0===c)throw new Error(`Packet block ${i} is invalid. Cannot have a zero bit field.`);for(l??=i+(c??1)-1,c??=l-i+1,a=l,o.Rm.debug(`Packet block ${i} - ${a} with label ${d}`);r.length<=s+1&&e.getPacket().length<1e4;){const[t,a]=b({start:i,end:l,bits:c,label:d},n,s);if(r.push(t),t.end+1===n*s&&(e.pushWord(r),r=[],n++),!a)break;({start:i,end:l,bits:c,label:d}=a)}}e.pushWord(r)},"populate"),b=(0,o.K2)((t,e,a)=>{if(void 0===t.start)throw new Error("start should have been set during first phase");if(void 0===t.end)throw new Error("end should have been set during first phase");if(t.start>t.end)throw new Error(`Block start ${t.start} is greater than block end ${t.end}.`);if(t.end+1<=e*a)return[t,void 0];const r=e*a-1,i=e*a;return[{start:t.start,end:r,label:t.label,bits:r-t.start},{start:i,end:t.end,label:t.label,bits:t.end-i}]},"getNextFittingBlock"),h={parser:{yy:void 0},parse:(0,o.K2)(async t=>{const e=await(0,l.qg)("packet",t),a=h.parser?.yy;if(!(a instanceof d))throw new Error("parser.parser?.yy was not a PacketDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");o.Rm.debug(e),p(e,a)},"parse")},k=(0,o.K2)((t,e,a,i)=>{const n=i.db,o=n.getConfig(),{rowHeight:l,paddingY:c,bitWidth:d,bitsPerRow:p}=o,b=n.getPacket(),h=n.getDiagramTitle(),k=l+c,u=k*(b.length+1)-(h?0:l),f=d*p+2,w=(0,r.D)(e);w.attr("viewbox",`0 0 ${f} ${u}`),(0,s.a$)(w,u,f,o.useMaxWidth);for(const[r,s]of b.entries())g(w,s,r,o);w.append("text").text(h).attr("x",f/2).attr("y",u-k/2).attr("dominant-baseline","middle").attr("text-anchor","middle").attr("class","packetTitle")},"draw"),g=(0,o.K2)((t,e,a,{rowHeight:r,paddingX:i,paddingY:n,bitWidth:s,bitsPerRow:o,showBits:l})=>{const c=t.append("g"),d=a*(r+n)+n;for(const p of e){const t=p.start%o*s+1,e=(p.end-p.start+1)*s-i;if(c.append("rect").attr("x",t).attr("y",d).attr("width",e).attr("height",r).attr("class","packetBlock"),c.append("text").attr("x",t+e/2).attr("y",d+r/2).attr("class","packetLabel").attr("dominant-baseline","middle").attr("text-anchor","middle").text(p.label),!l)continue;const a=p.end===p.start,n=d-2;c.append("text").attr("x",t+(a?e/2:0)).attr("y",n).attr("class","packetByte start").attr("dominant-baseline","auto").attr("text-anchor",a?"middle":"start").text(p.start),a||c.append("text").attr("x",t+e).attr("y",n).attr("class","packetByte end").attr("dominant-baseline","auto").attr("text-anchor","end").text(p.end)}},"drawWord"),u={draw:k},f={byteFontSize:"10px",startByteColor:"black",endByteColor:"black",labelColor:"black",labelFontSize:"12px",titleColor:"black",titleFontSize:"14px",blockStrokeColor:"black",blockStrokeWidth:"1",blockFillColor:"#efefef"},w=(0,o.K2)(({packet:t}={})=>{const e=(0,n.$t)(f,t);return`\n\t.packetByte {\n\t\tfont-size: ${e.byteFontSize};\n\t}\n\t.packetByte.start {\n\t\tfill: ${e.startByteColor};\n\t}\n\t.packetByte.end {\n\t\tfill: ${e.endByteColor};\n\t}\n\t.packetLabel {\n\t\tfill: ${e.labelColor};\n\t\tfont-size: ${e.labelFontSize};\n\t}\n\t.packetTitle {\n\t\tfill: ${e.titleColor};\n\t\tfont-size: ${e.titleFontSize};\n\t}\n\t.packetBlock {\n\t\tstroke: ${e.blockStrokeColor};\n\t\tstroke-width: ${e.blockStrokeWidth};\n\t\tfill: ${e.blockFillColor};\n\t}\n\t`},"styles"),m={parser:h,get db(){return new d},renderer:u,styles:w}},25871:(t,e,a)=>{function r(t,e){t.accDescr&&e.setAccDescription?.(t.accDescr),t.accTitle&&e.setAccTitle?.(t.accTitle),t.title&&e.setDiagramTitle?.(t.title)}a.d(e,{S:()=>r}),(0,a(40797).K2)(r,"populateCommonDb")}}]); |