import{_ as k,F as m,K as B,e as C,l as w,b as S,a as D,q as E,t as T,g as z,s as F,G as P,H as _,z as A}from"./mermaid.core-CVhassan.js";import{p as W}from"./chunk-4BX2VUAB-CujZm1R1.js";import{p as I}from"./treemap-KMMF4GRG-8-j8RoA6.js";import"./preload-helper-DqNgO5-4.js";import"./misc-DRDyxdMg.js";import"./jsx-runtime-C4_65a1U.js";import"./index-B9zr-vzA.js";import"./chunk-JZWAC4HX-5kJHQiQ9.js";import"./_baseUniq-DdZcSuTs.js";import"./_basePickBy-CQpyTSb0.js";import"./clone-z8f4YUjj.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"8a6db0ac5fe78363b0c97fe458a96ce773bf357c"};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8a706860-c5a3-4054-8e07-29dcf1e2af22",e._sentryDebugIdIdentifier="sentry-dbid-8a706860-c5a3-4054-8e07-29dcf1e2af22")}catch{}})();var N=_.packet,u,y=(u=class{constructor(){this.packet=[],this.setAccTitle=S,this.getAccTitle=D,this.setDiagramTitle=E,this.getDiagramTitle=T,this.getAccDescription=z,this.setAccDescription=F}getConfig(){const t=m({...N,...P().packet});return t.showBits&&(t.paddingY+=10),t}getPacket(){return this.packet}pushWord(t){t.length>0&&this.packet.push(t)}clear(){A(),this.packet=[]}},k(u,"PacketDB"),u),L=1e4,Y=k((e,t)=>{W(e,t);let r=-1,o=[],n=1;const{bitsPerRow:l}=t.getConfig();for(let{start:a,end:i,bits:d,label:c}of e.blocks){if(a!==void 0&&i!==void 0&&i<a)throw new Error(`Packet block ${a} - ${i} is invalid. End must be greater than start.`);if(a??=r+1,a!==r+1)throw new Error(`Packet block ${a} - ${i??a} is not contiguous. It should start from ${r+1}.`);if(d===0)throw new Error(`Packet block ${a} is invalid. Cannot have a zero bit field.`);for(i??=a+(d??1)-1,d??=i-a+1,r=i,w.debug(`Packet block ${a} - ${r} with label ${c}`);o.length<=l+1&&t.getPacket().length<L;){const[p,s]=M({start:a,end:i,bits:d,label:c},n,l);if(o.push(p),p.end+1===n*l&&(t.pushWord(o),o=[],n++),!s)break;({start:a,end:i,bits:d,label:c}=s)}}t.pushWord(o)},"populate"),M=k((e,t,r)=>{if(e.start===void 0)throw new Error("start should have been set during first phase");if(e.end===void 0)throw new Error("end should have been set during first phase");if(e.start>e.end)throw new Error(`Block start ${e.start} is greater than block end ${e.end}.`);if(e.end+1<=t*r)return[e,void 0];const o=t*r-1,n=t*r;return[{start:e.start,end:o,label:e.label,bits:o-e.start},{start:n,end:e.end,label:e.label,bits:e.end-n}]},"getNextFittingBlock"),v={parser:{yy:void 0},parse:k(async e=>{const t=await I("packet",e),r=v.parser?.yy;if(!(r instanceof y))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.");w.debug(t),Y(t,r)},"parse")},R=k((e,t,r,o)=>{const n=o.db,l=n.getConfig(),{rowHeight:a,paddingY:i,bitWidth:d,bitsPerRow:c}=l,p=n.getPacket(),s=n.getDiagramTitle(),g=a+i,f=g*(p.length+1)-(s?0:a),h=d*c+2,b=B(t);b.attr("viewbox",`0 0 ${h} ${f}`),C(b,f,h,l.useMaxWidth);for(const[x,$]of p.entries())G(b,$,x,l);b.append("text").text(s).attr("x",h/2).attr("y",f-g/2).attr("dominant-baseline","middle").attr("text-anchor","middle").attr("class","packetTitle")},"draw"),G=k((e,t,r,{rowHeight:o,paddingX:n,paddingY:l,bitWidth:a,bitsPerRow:i,showBits:d})=>{const c=e.append("g"),p=r*(o+l)+l;for(const s of t){const g=s.start%i*a+1,f=(s.end-s.start+1)*a-n;if(c.append("rect").attr("x",g).attr("y",p).attr("width",f).attr("height",o).attr("class","packetBlock"),c.append("text").attr("x",g+f/2).attr("y",p+o/2).attr("class","packetLabel").attr("dominant-baseline","middle").attr("text-anchor","middle").text(s.label),!d)continue;const h=s.end===s.start,b=p-2;c.append("text").attr("x",g+(h?f/2:0)).attr("y",b).attr("class","packetByte start").attr("dominant-baseline","auto").attr("text-anchor",h?"middle":"start").text(s.start),h||c.append("text").attr("x",g+f).attr("y",b).attr("class","packetByte end").attr("dominant-baseline","auto").attr("text-anchor","end").text(s.end)}},"drawWord"),H={draw:R},K={byteFontSize:"10px",startByteColor:"black",endByteColor:"black",labelColor:"black",labelFontSize:"12px",titleColor:"black",titleFontSize:"14px",blockStrokeColor:"black",blockStrokeWidth:"1",blockFillColor:"#efefef"},O=k(({packet:e}={})=>{const t=m(K,e);return`
	.packetByte {
		font-size: ${t.byteFontSize};
	}
	.packetByte.start {
		fill: ${t.startByteColor};
	}
	.packetByte.end {
		fill: ${t.endByteColor};
	}
	.packetLabel {
		fill: ${t.labelColor};
		font-size: ${t.labelFontSize};
	}
	.packetTitle {
		fill: ${t.titleColor};
		font-size: ${t.titleFontSize};
	}
	.packetBlock {
		stroke: ${t.blockStrokeColor};
		stroke-width: ${t.blockStrokeWidth};
		fill: ${t.blockFillColor};
	}
	`},"styles"),rt={parser:v,get db(){return new y},renderer:H,styles:O};export{rt as diagram};
//# sourceMappingURL=diagram-S2PKOQOG-B1GpBwOq.js.map
