"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["node_modules_mermaid_dist_chunks_mermaid_core_diagram-QW4FP2JN_mjs"],{"./node_modules/mermaid/dist/chunks/mermaid.core/diagram-QW4FP2JN.mjs":function(U,E,_){_.d(E,{diagram:function(){return A}});var x=_("./node_modules/mermaid/dist/chunks/mermaid.core/chunk-TMUBEWPD.mjs"),v=_("./node_modules/mermaid/dist/chunks/mermaid.core/chunk-7DKRZKHE.mjs"),B=_("./node_modules/mermaid/dist/chunks/mermaid.core/chunk-EJ4ZWXGL.mjs"),a=_("./node_modules/mermaid/dist/chunks/mermaid.core/chunk-6DBFFHIP.mjs"),P=_("./node_modules/@mermaid-js/parser/dist/mermaid-parser.core.mjs"),C={packet:[]},b=structuredClone(C),$=a.UI.packet,D=(0,a.K2)(()=>{const t=(0,v.$t)({...$,...(0,a.zj)().packet});return t.showBits&&(t.paddingY+=10),t},"getConfig"),y=(0,a.K2)(()=>b.packet,"getPacket"),W=(0,a.K2)(t=>{t.length>0&&b.packet.push(t)},"pushWord"),K=(0,a.K2)(()=>{(0,a.IU)(),b=structuredClone(C)},"clear"),g={pushWord:W,getPacket:y,getConfig:D,clear:K,setAccTitle:a.SV,getAccTitle:a.iN,setDiagramTitle:a.ke,getDiagramTitle:a.ab,getAccDescription:a.m7,setAccDescription:a.EI},w=1e4,F=(0,a.K2)(t=>{(0,x.S)(t,g);let e=-1,s=[],i=1;const{bitsPerRow:l}=g.getConfig();for(let{start:r,end:o,label:m}of t.blocks){if(o&&o<r)throw new Error(`Packet block ${r} - ${o} is invalid. End must be greater than start.`);if(r!==e+1)throw new Error(`Packet block ${r} - ${o??r} is not contiguous. It should start from ${e+1}.`);for(e=o??r,a.Rm.debug(`Packet block ${r} - ${e} with label ${m}`);s.length<=l+1&&g.getPacket().length<w;){const[h,d]=T({start:r,end:o,label:m},i,l);if(s.push(h),h.end+1===i*l&&(g.pushWord(s),s=[],i++),!d)break;({start:r,end:o,label:m}=d)}}g.pushWord(s)},"populate"),T=(0,a.K2)((t,e,s)=>{if(t.end===void 0&&(t.end=t.start),t.start>t.end)throw new Error(`Block start ${t.start} is greater than block end ${t.end}.`);return t.end+1<=e*s?[t,void 0]:[{start:t.start,end:e*s-1,label:t.label},{start:e*s,end:t.end,label:t.label}]},"getNextFittingBlock"),S={parse:(0,a.K2)(async t=>{const e=await(0,P.qg)("packet",t);a.Rm.debug(e),F(e)},"parse")},j=(0,a.K2)((t,e,s,i)=>{const l=i.db,r=l.getConfig(),{rowHeight:o,paddingY:m,bitWidth:h,bitsPerRow:d}=r,f=l.getPacket(),n=l.getDiagramTitle(),k=o+m,c=k*(f.length+1)-(n?0:o),u=h*d+2,p=(0,B.D)(e);p.attr("viewbox",`0 0 ${u} ${c}`),(0,a.a$)(p,c,u,r.useMaxWidth);for(const[L,R]of f.entries())M(p,R,L,r);p.append("text").text(n).attr("x",u/2).attr("y",c-k/2).attr("dominant-baseline","middle").attr("text-anchor","middle").attr("class","packetTitle")},"draw"),M=(0,a.K2)((t,e,s,{rowHeight:i,paddingX:l,paddingY:r,bitWidth:o,bitsPerRow:m,showBits:h})=>{const d=t.append("g"),f=s*(i+r)+r;for(const n of e){const k=n.start%m*o+1,c=(n.end-n.start+1)*o-l;if(d.append("rect").attr("x",k).attr("y",f).attr("width",c).attr("height",i).attr("class","packetBlock"),d.append("text").attr("x",k+c/2).attr("y",f+i/2).attr("class","packetLabel").attr("dominant-baseline","middle").attr("text-anchor","middle").text(n.label),!h)continue;const u=n.end===n.start,p=f-2;d.append("text").attr("x",k+(u?c/2:0)).attr("y",p).attr("class","packetByte start").attr("dominant-baseline","auto").attr("text-anchor",u?"middle":"start").text(n.start),u||d.append("text").attr("x",k+c).attr("y",p).attr("class","packetByte end").attr("dominant-baseline","auto").attr("text-anchor","end").text(n.end)}},"drawWord"),I={draw:j},O={byteFontSize:"10px",startByteColor:"black",endByteColor:"black",labelColor:"black",labelFontSize:"12px",titleColor:"black",titleFontSize:"14px",blockStrokeColor:"black",blockStrokeWidth:"1",blockFillColor:"#efefef"},z=(0,a.K2)(({packet:t}={})=>{const e=(0,v.$t)(O,t);return`
	.packetByte {
		font-size: ${e.byteFontSize};
	}
	.packetByte.start {
		fill: ${e.startByteColor};
	}
	.packetByte.end {
		fill: ${e.endByteColor};
	}
	.packetLabel {
		fill: ${e.labelColor};
		font-size: ${e.labelFontSize};
	}
	.packetTitle {
		fill: ${e.titleColor};
		font-size: ${e.titleFontSize};
	}
	.packetBlock {
		stroke: ${e.blockStrokeColor};
		stroke-width: ${e.blockStrokeWidth};
		fill: ${e.blockFillColor};
	}
	`},"styles"),A={parser:S,db:g,renderer:I,styles:z}}}]);
