"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.pack=pack;const B_PROTOCOL=0,B_PROTOCOL_VERSION=1,B_FILEINFO_LEN=2,B_FILEDATA_LEN=3,B_PROTOCOL_END=4;function pack(t){const e=[Buffer.alloc(1),Buffer.alloc(4),Buffer.alloc(4),Buffer.alloc(4),Buffer.alloc(1)];e[0][0]=190,e[1].writeInt32BE(0,0),e[4][0]=237;const f=Object.keys(t),r=f.length,n=[],c=[];let o=0;for(const e of f){const f=e.replace(/\\/g,"/"),r=f.startsWith("/")?f:"/"+f,l=Buffer.from(r);n.push(l);const B=t[e];let a;if(B instanceof Buffer)a=B;else{if("string"!=typeof B)throw new Error("pack invalid data: "+e);a=Buffer.from(B,"utf8")}c.push(a),/\.js\.map$/.test(e)||(o+=a.length,o+=l.length)}let l=18+12*r+Buffer.concat(n).length;const B=n.map((t,e)=>{const f=Buffer.alloc(4);f.writeInt32BE(t.length,0);const r=Buffer.alloc(4),n=c[e].length,o=l;r.writeInt32BE(o,0),l+=n;const B=Buffer.alloc(4);return B.writeInt32BE(n,0),Buffer.concat([f,t,r,B])}),a=Buffer.alloc(4);a.writeInt32BE(r,0),B.unshift(a);const u=Buffer.concat(B),s=Buffer.concat(c);e[2].writeInt32BE(u.length,0),e[3].writeInt32BE(s.length,0);const i=Buffer.concat(e);return{validSize:o,buffer:Buffer.concat([i,u,s])}}