mirror of
https://github.com/acid-info/codex.storage.git
synced 2026-08-31 04:31:09 +00:00
1 line
4.2 KiB
JavaScript
1 line
4.2 KiB
JavaScript
"use strict";(self.webpackChunkcodex_docusaurus_template=self.webpackChunkcodex_docusaurus_template||[]).push([[375],{50487:(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(41750).K2)(r,"populateCommonDb")},60375:(t,e,a)=>{a.d(e,{diagram:()=>x});var r=a(50487),o=a(46792),n=a(74505),l=a(41750),i=a(78731),s={packet:[]},c=structuredClone(s),d=l.UI.packet,b=(0,l.K2)((()=>{const t=(0,o.$t)({...d,...(0,l.zj)().packet});return t.showBits&&(t.paddingY+=10),t}),"getConfig"),p=(0,l.K2)((()=>c.packet),"getPacket"),k={pushWord:(0,l.K2)((t=>{t.length>0&&c.packet.push(t)}),"pushWord"),getPacket:p,getConfig:b,clear:(0,l.K2)((()=>{(0,l.IU)(),c=structuredClone(s)}),"clear"),setAccTitle:l.SV,getAccTitle:l.iN,setDiagramTitle:l.ke,getDiagramTitle:l.ab,getAccDescription:l.m7,setAccDescription:l.EI},h=(0,l.K2)((t=>{(0,r.S)(t,k);let e=-1,a=[],o=1;const{bitsPerRow:n}=k.getConfig();for(let{start:r,end:i,bits:s,label:c}of t.blocks){if(void 0!==r&&void 0!==i&&i<r)throw new Error(`Packet block ${r} - ${i} is invalid. End must be greater than start.`);if(r??=e+1,r!==e+1)throw new Error(`Packet block ${r} - ${i??r} is not contiguous. It should start from ${e+1}.`);if(0===s)throw new Error(`Packet block ${r} is invalid. Cannot have a zero bit field.`);for(i??=r+(s??1)-1,s??=i-r+1,e=i,l.Rm.debug(`Packet block ${r} - ${e} with label ${c}`);a.length<=n+1&&k.getPacket().length<1e4;){const[t,e]=g({start:r,end:i,bits:s,label:c},o,n);if(a.push(t),t.end+1===o*n&&(k.pushWord(a),a=[],o++),!e)break;({start:r,end:i,bits:s,label:c}=e)}}k.pushWord(a)}),"populate"),g=(0,l.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,o=e*a;return[{start:t.start,end:r,label:t.label,bits:r-t.start},{start:o,end:t.end,label:t.label,bits:t.end-o}]}),"getNextFittingBlock"),u={parse:(0,l.K2)((async t=>{const e=await(0,i.qg)("packet",t);l.Rm.debug(e),h(e)}),"parse")},f=(0,l.K2)(((t,e,a,r)=>{const o=r.db,i=o.getConfig(),{rowHeight:s,paddingY:c,bitWidth:d,bitsPerRow:b}=i,p=o.getPacket(),k=o.getDiagramTitle(),h=s+c,g=h*(p.length+1)-(k?0:s),u=d*b+2,f=(0,n.D)(e);f.attr("viewbox",`0 0 ${u} ${g}`),(0,l.a$)(f,g,u,i.useMaxWidth);for(const[n,l]of p.entries())w(f,l,n,i);f.append("text").text(k).attr("x",u/2).attr("y",g-h/2).attr("dominant-baseline","middle").attr("text-anchor","middle").attr("class","packetTitle")}),"draw"),w=(0,l.K2)(((t,e,a,{rowHeight:r,paddingX:o,paddingY:n,bitWidth:l,bitsPerRow:i,showBits:s})=>{const c=t.append("g"),d=a*(r+n)+n;for(const b of e){const t=b.start%i*l+1,e=(b.end-b.start+1)*l-o;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(b.label),!s)continue;const a=b.end===b.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(b.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(b.end)}}),"drawWord"),$={byteFontSize:"10px",startByteColor:"black",endByteColor:"black",labelColor:"black",labelFontSize:"12px",titleColor:"black",titleFontSize:"14px",blockStrokeColor:"black",blockStrokeWidth:"1",blockFillColor:"#efefef"},x={parser:u,db:k,renderer:{draw:f},styles:(0,l.K2)((({packet:t}={})=>{const e=(0,o.$t)($,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")}}}]); |