(function(a,b){"object"==typeofexports&&"undefined"!=typeofmodule?b(exports):"function"==typeofdefine&&define.amd?define(["exports"],b):(a=a||self,b(a.msgpackr={}))})(this,function(a){'use strict';varb=Math.floor;functionc(){try{if(!H.trusted&&!O){leta=C.sharedLength||0;a<C.length&&(C.length=a)}leta=e();if(G==B)C.restoreStructures&&d(),C=null,A=null,E&&(E=null);elseif(G>B){// over read
leta=newError("Unexpected end of MessagePack data");throwa.incomplete=!0,a}elseif(!O)thrownewError("Data read, but end of buffer not reached");// else more to read, but we are reading sequentially, so don't clear source yet
returna}catch(a){throwC.restoreStructures&&d(),q(),(ainstanceofRangeError||a.message.startsWith("Unexpected end of buffer"))&&(a.incomplete=!0),a}}functiond(){for(letainC.restoreStructures)C[a]=C.restoreStructures[a];C.restoreStructures=null}functione(){leta=A[G++];if(160>a){if(!(128>a)){if(!(144>a)){a-=144;letb=Array(a);for(letc=0;c<a;c++)b[c]=e();returnb}if(a-=128,H.mapsAsObjects){letb={};for(letc=0;c<a;c++)b[o()]=e();returnb}else{letb=newMap;for(letc=0;c<a;c++)b.set(e(),e());returnb}}elseif(64>a)returna;else{letb=C[63&a]||H.getStructures&&g()[63&a];returnb?(b.read||(b.read=f(b,63&a)),b.read()):a}}elseif(192>a){// fixstr
letb=a-160;if(J>=G)returnD.slice(G-I,(G+=b)-I);if(0==J&&140>B){// for small blocks, avoiding the overhead of the extract call is helpful
leta=16>b?l(b):k(b);if(null!=a)returna}returnS(b)}else{letb;switch(a){case192:returnnull;case193:returnN;// "never-used", return special object to denote that
returnn(A[G++]);case200:returnb=F.getUint16(G),G+=2,n(b);case201:returnb=F.getUint32(G),G+=4,n(b);case202:if(b=F.getFloat32(G),2<H.useFloat32){// this does rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
case204:returnA[G++];case205:returnb=F.getUint16(G),G+=2,b;case206:returnb=F.getUint32(G),G+=4,b;case207:returnH.uint64AsNumber?72057594037927940*A[G++]+281474976710656*A[G++]+1099511627776*A[G++]+4294967296*A[G++]+16777216*A[G++]+(A[G++]<<16)+(A[G++]<<8)+A[G++]:(b=F.getBigUint64(G),G+=8,b);// int handlers
returnn(16);case217:returnb=A[G++],J>=G?D.slice(G-I,(G+=b)-I):T(b);case218:returnb=F.getUint16(G),G+=2,J>=G?D.slice(G-I,(G+=b)-I):U(b);case219:returnb=F.getUint32(G),G+=4,J>=G?D.slice(G-I,(G+=b)-I):V(b);case220:returnb=F.getUint16(G),G+=2,i(b);case221:returnb=F.getUint32(G),G+=4,i(b);case222:returnb=F.getUint16(G),G+=2,j(b);case223:returnb=F.getUint32(G),G+=4,j(b);default:// negative int
if(224<=a)returna-256;if(void0===a){leta=newError("Unexpected end of MessagePack data");throwa.incomplete=!0,a}thrownewError("Unknown MessagePack token "+a);}}}functionf(a,b){functionc(){// This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function
if(2<c.count++){letc=a.read=newFunction("r","return function(){return {"+a.map(a=>Q.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(e);return0===a.highByte&&(a.read=R(b,a.read)),c();// second byte is already read, if there is one so immediately read object
constb=63&A[G++],c=63&A[G++],e=63&A[G++];letf=(7&a)<<18|b<<12|c<<6|e;65535<f&&(f-=65536,d.push(55296|1023&f>>>10),f=56320|1023&f),d.push(f)}elsed.push(a);4096<=d.length&&(b+=W.apply(String,d),d.length=0)}return0<d.length&&(b+=W.apply(String,d)),b}functioni(a){letb=Array(a);for(letc=0;c<a;c++)b[c]=e();returnb}functionj(a){if(H.mapsAsObjects){letb={};for(letc=0;c<a;c++)b[o()]=e();returnb}else{letb=newMap;for(letc=0;c<a;c++)b.set(e(),e());returnb}}functionk(a){letb=G,c=Array(a);for(letd=0;d<a;d++){consta=A[G++];if(0<(128&a))returnvoid(G=b);c[d]=a}returnW.apply(String,c)}functionl(p){if(4>p){if(!(2>p)){letd=A[G++],a=A[G++];if(0<(128&d)||0<(128&a))returnvoid(G-=2);if(3>p)returnW(d,a);letb=A[G++];return0<(128&b)?void(G-=3):W(d,a,b)}if(0===p)return"";else{letb=A[G++];return1<(128&b)?void(G-=1):W(b)}}else{letq=A[G++],a=A[G++],b=A[G++],c=A[G++];if(0<(128&q)||0<(128&a)||0<(128&b)||0<(128&c))returnvoid(G-=4);if(6>p){if(4===p)returnW(q,a,b,c);else{letd=A[G++];return0<(128&d)?void(G-=5):W(q,a,b,c,d)}}elseif(8>p){letd=A[G++],e=A[G++];if(0<(128&d)||0<(128&e))returnvoid(G-=6);if(7>p)returnW(q,a,b,c,d,e);letf=A[G++];return0<(128&f)?void(G-=7):W(q,a,b,c,d,e,f)}else{letd=A[G++],e=A[G++],f=A[G++],g=A[G++];if(0<(128&d)||0<(128&e)||0<(128&f)||0<(128&g))returnvoid(G-=8);if(10>p){if(8===p)returnW(q,a,b,c,d,e,f,g);else{leth=A[G++];return0<(128&h)?void(G-=9):W(q,a,b,c,d,e,f,g,h)}}elseif(12>p){leth=A[G++],i=A[G++];if(0<(128&h)||0<(128&i))returnvoid(G-=10);if(11>p)returnW(q,a,b,c,d,e,f,g,h,i);letj=A[G++];return0<(128&j)?void(G-=11):W(q,a,b,c,d,e,f,g,h,i,j)}else{leth=A[G++],i=A[G++],j=A[G++],k=A[G++];if(0<(128&h)||0<(128&i)||0<(128&j)||0<(128&k))returnvoid(G-=12);if(!(14>p)){letl=A[G++],m=A[G++];if(0<(128&l)||0<(128&m))returnvoid(G-=14);if(15>p)returnW(q,a,b,c,d,e,f,g,h,i,j,k,l,m);letn=A[G++];return0<(128&n)?void(G-=15):W(q,a,b,c,d,e,f,g,h,i,j,k,l,m,n)}if(12===p)returnW(q,a,b,c,d,e,f,g,h,i,j,k);else{letl=A[G++];return0<(128&l)?void(G-=13):W(q,a,b,c,d,e,f,g,h,i,j,k,l)}}}}}functionm(a){returnH.copyBuffers?// specifically use the copying slice (not the node one)
Uint8Array.prototype.slice.call(A,G,G+=a):A.subarray(G,G+=a)}functionn(a){letb=A[G++];if(K[b])returnK[b](A.subarray(G,G+=a));thrownewError("Unknown extension type "+b)}functiono(){leta=A[G++];if(160<=a&&192>a){if(a-=160,J>=G)// if it has been extracted, must use it (and faster anyway)
returnD.slice(G-I,(G+=a)-I);if(!(0==J&&180>B))returnS(a)}elsereturnG--,e();letb,c=4095&(a<<5^(1<a?F.getUint16(G):0<a?A[G]:0)),d=X[c],f=G,g=G+a-3,h=0;if(d&&d.bytes==a){for(;f<g;){if(b=F.getUint32(f),b!=d[h++]){f=1879048192;break}f+=4}for(g+=3;f<g;)if(b=A[f++],b!=d[h++]){f=1879048192;break}if(f===g)returnG=f,d.string;g-=3,f=G}for(d=[],X[c]=d,d.bytes=a;f<g;)b=F.getUint32(f),d.push(b),f+=4;for(g+=3;f<g;)b=A[f++],d.push(b);// for small blocks, avoiding the overhead of the extract call is helpful
letj=16>a?l(a):k(a);returnnull==j?d.string=S(a):d.string=j}// the registration of the record definition extension (as "r")
functionp(a){letb=B,c=G,d=I,e=J,f=D,g=E,h=newUint8Array(A.slice(0,B)),i=C,j=C.slice(0,C.length),k=H,l=O,m=a();returnB=b,G=c,I=d,J=e,D=f,E=g,A=h,O=l,C=i,C.splice(0,C.length,...j),H=k,F=newDataView(A.buffer,A.byteOffset,A.byteLength),m}functionq(){A=null,E=null,C=null}functionr(a){K[a.type]=a.unpack?a.unpack:a}functions(a,b,c){letd=a.byteLength;if(256>d+1){var{target:e,position:f}=c(4+d);e[f++]=199,e[f++]=d+1}elseif(65536>d+1){var{target:e,position:f}=c(5+d);e[f++]=200,e[f++]=d+1>>8,e[f++]=255&d+1}else{var{target:e,position:f,targetView:g}=c(7+d);// plus one for the type byte
e[f++]=201,g.setUint32(f,d+1),f+=4}// "t" for typed array
e[f++]=116,e[f++]=b,e.set(newUint8Array(a.buffer,a.byteOffset,a.byteLength),f)}functiont(a,b){letc=a.byteLength;vard,e;if(256>c){var{target:d,position:e}=b(c+2);d[e++]=196,d[e++]=c}elseif(65536>c){var{target:d,position:e}=b(c+3);d[e++]=197,d[e++]=c>>8,d[e++]=255&c}else{var{target:d,position:e,targetView:f}=b(c+5);d[e++]=198,f.setUint32(e,c),e+=4}d.set(a,e)}functionu(a,b,c,d){lete=a.length;return1===e?b[c++]=212:2===e?b[c++]=213:4===e?b[c++]=214:8===e?b[c++]=215:16===e?b[c++]=216:256>e?(b[c++]=199,b[c++]=e):65536>e?(b[c++]=200,b[c++]=e>>8,b[c++]=255&e):(b[c++]=201,b[c++]=e>>24,b[c++]=255&e>>16,b[c++]=255&e>>8,b[c++]=255&e),b[c++]=d,b.set(a,c),c+=e,c}functionv(a,b){// insert the ids that need to be referenced for structured clones
a[g++]=214,a[g++]=105,a[g++]=f>>24,a[g++]=255&f>>16,a[g++]=255&f>>8,a[g++]=255&f,e=b}returna}functionw(a){if(a.Class){if(!a.pack&&!a.write)thrownewError("Extension has no pack or write function");if(a.pack&&!a.type)thrownewError("Extension has no type (numeric code to identify the extension)");ja.unshift(a.Class),ia.unshift(a)}r(a)}function*x(a,b){constc=newta(b);for(constdofa)yieldc.pack(d)}asyncfunction*y(a,b){constc=newta(b);forawait(constdofa)yieldc.pack(d)}/**
returnp(()=>(q(),this?this.unpack(a,b):P.prototype.unpack.call(L,a,b)));if(B=-1<b?b:a.length,G=0,J=0,D=null,A=a,F=a.dataView||(a.dataView=newDataView(a.buffer,a.byteOffset,a.byteLength)),this){if(H=this,this.structures)returnC=this.structures,c();(!C||0<C.length)&&(C=[])}elseH=L,(!C||0<C.length)&&(C=[]);returnc()}unpackMultiple(a,b){letd,e=0;try{O=!0;letf=a.length,g=this?this.unpack(a,f):aa.unpack(a,f);if(b){for(b(g);G<f;)if(e=G,!1===b(c()))return;}else{for(d=[g];G<f;)e=G,d.push(c());returnd}}catch(a){throwa.lastPosition=e,a.values=d,a}finally{O=!1,q()}}_mergeStructures(a,b){a=a||[];for(letc,d=0,e=a.length;d<e;d++)c=a[d],c&&(c.isShared=!0,32<=d&&(c.highByte=d-32>>5));for(letcina.sharedLength=a.length,b||[])if(0<=c){letd=a[c],e=b[c];e&&(d&&((a.restoreStructures||(a.restoreStructures=[]))[c]=d),a[c]=e)}returnthis.structures=a}decode(a,b){returnthis.unpack(a,b)}}constQ=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,R=(a,b)=>function(){letc=A[G++];if(0===c)returnb();letd=32>a?-(a+(c<<5)):a+(c<<5),e=C[d]||g()[d];if(!e)thrownewError("Record id is not defined for "+d);returne.read||(e.read=f(e,a)),e.read()};varS=h,T=h,U=h,V=h,W=String.fromCharCode,X=Array(4096);constY=(a,b)=>{varc=e();letd=a;void0!==b&&(a=32>a?-((b<<5)+a):(b<<5)+a,c.highByte=b);letg=C[a];returng&&g.isShared&&((C.restoreStructures||(C.restoreStructures=[]))[a]=g),C[a]=c,c.read=f(c,d),c.read()};varZ="object"==typeofself?self:global;K[0]=()=>{},K[0].noBuffer=!0,K[101]=()=>{leta=e();return(Z[a[0]]||Error)(a[1])},K[105]=()=>{// id extension (for structured clones)
leta=F.getUint32(G-4);E||(E=newMap);letb,c=A[G];b=144<=c&&160>c||220==c||221==c?[]:{};letd={target:b};// a placeholder object
E.set(a,d);letf=e();// read the next value as the target object to id
returnd.used?Object.assign(b,f):(d.target=f,f);// no cycle, can just use the returned read object
leta=F.getUint32(G-4),b=E.get(a);returnb.used=!0,b.target},K[115]=()=>newSet(e());const$=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(a=>a+"Array");K[116]=a=>{letb=a[0],c=$[b];if(!c)thrownewError("Could not find typed array for code "+b);// we have to always slice/copy here to get a new ArrayBuffer that is word/byte aligned
returnnewZ[c](Uint8Array.prototype.slice.call(a,1).buffer)},K[120]=()=>{leta=e();returnnewRegExp(a[0],a[1])},K[255]=a=>{// 32-bit date extension
if(4==a.length)returnnewDate(1e3*(16777216*a[0]+(a[1]<<16)+(a[2]<<8)+a[3]));if(8==a.length)returnnewDate(((a[0]<<22)+(a[1]<<14)+(a[2]<<6)+(a[3]>>2))/1e6+1e3*(4294967296*(3&a[3])+16777216*a[4]+(a[5]<<16)+(a[6]<<8)+a[7]));if(12==a.length)// TODO: Implement support for negative
returnnewDate(((a[0]<<24)+(a[1]<<16)+(a[2]<<8)+a[3])/1e6+1e3*((128&a[4]?-281474976710656:0)+1099511627776*a[6]+4294967296*a[7]+16777216*a[8]+(a[9]<<16)+(a[10]<<8)+a[11]));thrownewError("Invalid timestamp length")};const_=Array(147);// this is a table matching binary exponents to the multiplier to determine significant digit rounding
for(letc=0;256>c;c++)_[c]=+("1e"+b(45.15-.30103*c));varaa=newP({useRecords:!1});constba=aa.unpack,ca=aa.unpackMultiple,da=aa.unpack,ea={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};letfa,ga=newFloat32Array(1),ha=newUint8Array(ga.buffer,0,4);try{fa=newTextEncoder}catch(a){}letia,ja;constka="undefined"!=typeofBuffer,la=ka?Buffer.allocUnsafeSlow:Uint8Array,ma=ka?Buffer:Uint8Array,na=ka?4294967296:2144337920;letoa,pa,qa,ra=0;constsa=Symbol("record-id");classtaextendsP{constructor(a){super(a),this.offset=0;letb,c,d,e,f,g=0,h=ma.prototype.utf8Write?function(a,b,c){returnoa.utf8Write(a,b,c)}:!!(fa&&fa.encodeInto)&&function(a,b){returnfa.encodeInto(a,oa.subarray(b)).written},i=this;a||(a={});letj=a&&a.sequential,k=a.structures||a.saveStructures,l=a.maxSharedStructures;if(null==l&&(l=k?32:0),8160<l)thrownewError("Maximum maxSharedStructure is 8160");letm=a.maxOwnStructures;null==m&&(m=k?32:64),j&&!a.saveStructures&&(this.structures=[]);// two byte record ids for shared structures
letn=32<l||64<m+l,o=l+64,p=l+m+64;if(8256<p)thrownewError("Maximum maxSharedStructure + maxOwnStructure is 8192");letq=[],r=0,s=0;this.pack=this.encode=function(a,h){if(oa||(oa=newla(8192),pa=newDataView(oa.buffer,0,8192),ra=0),qa=oa.length-10,2048>qa-ra?(oa=newla(oa.length),pa=newDataView(oa.buffer,0,oa.length),qa=oa.length-10,ra=0):ra=2147483640&ra+7,b=ra,f=i.structuredClone?newMap:null,c=i.structures,c){c.uninitialized&&(c=i._mergeStructures(i.getStructures()));leta=c.sharedLength||0;if(a>l)//if (maxSharedStructures <= 32 && sharedStructures.sharedLength > 32) // TODO: could support this, but would need to update the limit ids
thrownewError("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+c.sharedLength);if(!c.transitions){c.transitions=Object.create(null);for(letb,d=0;d<a;d++){if(b=c[d],!b)continue;leta,e=c.transitions;for(letc,d=0,f=b.length;d<f;d++)c=b[d],a=e[c],a||(a=e[c]=Object.create(null)),e=a;e[sa]=d+64}g=a}j||(c.nextId=a+64)}d&&(d=!1),e=c||[];try{// update the offset so next serialization doesn't write over our buffer, but can continue writing to same buffer sequentially
if(t(a),i.offset=ra,f&&f.idsToInsert){ra+=6*f.idsToInsert.length,ra>qa&&x(ra),i.offset=ra;leta=v(oa.subarray(b,ra),f.idsToInsert);returnf=null,a}returnh===Ba?(oa.start=b,oa.end=ra,oa):oa.subarray(b,ra);// position can change if we call pack again in saveStructures, so we get the buffer now
}finally{if(c){if(10>s&&s++,1e4<r)c.transitions=null,s=0,r=0,0<q.length&&(q=[]);elseif(0<q.length&&!j){for(leta=0,b=q.length;a<b;a++)q[a][sa]=0;q=[]}if(d&&i.saveStructures){letd=c.sharedLength||l;c.length>d&&(c=c.slice(0,d));// we can't rely on start/end with REUSE_BUFFER_MODE since they will (probably) change when we save
lete=oa.subarray(b,ra);return!1===i.saveStructures(c,g)?(i._mergeStructures(i.getStructures()),i.pack(a)):(g=d,e)}}}};constt=a=>{ra>qa&&(oa=x(ra));varc,d=typeofa;if("string"==d){letb,d=a.length;b=32>d?1:256>d?2:65536>d?3:5;lete=3*d;if(ra+e>qa&&(oa=x(ra+e)),64>d||!h){lete,f,g,h=ra+b;for(e=0;e<d;e++)f=a.charCodeAt(e),128>f?oa[h++]=f:2048>f?(oa[h++]=192|f>>6,oa[h++]=128|63&f):55296==(64512&f)&&56320==(64512&(g=a.charCodeAt(e+1)))?(f=65536+((1023&f)<<10)+(1023&g),e++,oa[h++]=240|f>>18,oa[h++]=128|63&f>>12,oa[h++]=128|63&f>>6,oa[h++]=128|63&f):(oa[h++]=224|f>>12,oa[h++]=128|63&f>>6,oa[h++]=128|63&f);c=h-ra-b}elsec=h(a,ra+b,e);32>c?oa[ra++]=160|c:256>c?(2>b&&oa.copyWithin(ra+2,ra+1,ra+1+c),oa[ra++]=217,oa[ra++]=c):65536>c?(3>b&&oa.copyWithin(ra+3,ra+2,ra+2+c),oa[ra++]=218,oa[ra++]=c>>8,oa[ra++]=255&c):(5>b&&oa.copyWithin(ra+5,ra+3,ra+3+c),oa[ra++]=219,pa.setUint32(ra,c),ra+=4),ra+=c}elseif("number"===d){if(a>>>0===a)64>a?oa[ra++]=a:256>a?(oa[ra++]=204,oa[ra++]=a):65536>a?(oa[ra++]=205,oa[ra++]=a>>8,oa[ra++]=255&a):(oa[ra++]=206,pa.setUint32(ra,a),ra+=4);elseif(a>>0===a)-32<=a?oa[ra++]=256+a:-128<=a?(oa[ra++]=208,oa[ra++]=a+256):-32768<=a?(oa[ra++]=209,pa.setInt16(ra,a),ra+=2):(oa[ra++]=210,pa.setInt32(ra,a),ra+=4);else{letb;if(0<(b=this.useFloat32)&&4294967296>a&&-2147483648<=a){oa[ra++]=202,pa.setFloat32(ra,a);letc;if(4>b||// this checks for rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
(c=a*_[(127&oa[ra])<<1|oa[ra+1]>>7])>>0===c)returnvoid(ra+=4);// move back into position for writing a double
ra--}oa[ra++]=203,pa.setFloat64(ra,a),ra+=8}}elseif("object"===d){if(!a)oa[ra++]=192;else{if(f){letc=f.get(a);if(c){if(!c.id){leta=f.idsToInsert||(f.idsToInsert=[]);c.id=a.push(c)}returnoa[ra++]=214,oa[ra++]=112,pa.setUint32(ra,c.id),void(ra+=4)}f.set(a,{offset:ra-b})}letd=a.constructor;if(d===Object)w(a,!0);elseif(d===Array){c=a.length,16>c?oa[ra++]=144|c:65536>c?(oa[ra++]=220,oa[ra++]=c>>8,oa[ra++]=255&c):(oa[ra++]=221,pa.setUint32(ra,c),ra+=4);for(letb=0;b<c;b++)t(a[b])}elseif(d===Map){c=a.size,16>c?oa[ra++]=128|c:65536>c?(oa[ra++]=222,oa[ra++]=c>>8,oa[ra++]=255&c):(oa[ra++]=223,pa.setUint32(ra,c),ra+=4);for(let[b,c]ofa)t(b),t(c)}else{for(letb,c=0,d=ia.length;c<d;c++)if(b=ja[c],ainstanceofb){letb=ia[c];if(b.write)returnb.type&&(oa[ra++]=212,oa[ra++]=b.type,oa[ra++]=0),voidt(b.write.call(this,a));letd=oa,e=pa,f=ra;oa=null;letg;try{g=b.pack.call(this,a,a=>(oa=d,d=null,ra+=a,ra>qa&&x(ra),{target:oa,targetView:pa,position:ra-a}),t)}finally{d&&(oa=d,pa=e,ra=f,qa=oa.length-10)}returnvoid(g&&(g.length+ra>qa&&x(g.length+ra),ra=u(g,oa,ra,b.type)))}// no extension found, write as object
if(this.largeBigIntToFloat)oa[ra++]=203,pa.setFloat64(ra,+a);elsethrownewRangeError(a+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ra+=8}elseif("undefined"===d)this.encodeUndefinedAsNil?oa[ra++]=192:(oa[ra++]=212,oa[ra++]=0,oa[ra++]=0);elseif("function"===d)t(this.writeFunction&&this.writeFunction());elsethrownewError("Unknown type: "+d)},w=!1===this.useRecords?this.variableMapSize?a=>{// this method is slightly slower, but generates "preferred serialization" (optimally small for smaller objects)
letb=Object.keys(a),c=b.length;16>c?oa[ra++]=128|c:65536>c?(oa[ra++]=222,oa[ra++]=c>>8,oa[ra++]=255&c):(oa[ra++]=223,pa.setUint32(ra,c),ra+=4);letd;for(lete=0;e<c;e++)t(d=b[e]),t(a[d])}:(a,c)=>{oa[ra++]=222;// always using map 16, so we can preallocate and set the length afterwards
h=o),e.nextId=h+1);leta=c.highByte=96<=h&&n?h-96>>5:-1;f[sa]=h,e[h-64]=c,h<o?(c.isShared=!0,e.sharedLength=h-63,d=!0,0<=a?(oa[ra++]=(31&h)+96,oa[ra++]=a):oa[ra++]=h):(0<=a?(oa[ra++]=213,oa[ra++]=114,oa[ra++]=(31&h)+96,oa[ra++]=a):(oa[ra++]=212,oa[ra++]=114,oa[ra++]=h),g&&(r+=s*g),q.length>=m&&(q.shift()[sa]=0),q.push(f),t(c))}// now write the values
for(letb=0,d=c.length;b<d;b++)t(a[c[b]])},x=a=>{varc=Math.min,d=Math.round,e=Math.max;letf;if(16777216<a){// special handling for really large buffers
if(a-b>na)thrownewError("Packed buffer would be larger than maximum buffer size");f=c(na,4096*d(e((a-b)*(67108864<a?1.25:2),16777216)/4096))}else// faster handling for smaller buffers
f=(e(a-b<<2,oa.length-1)>>12)+1<<12;letg=newla(f);returnpa=newDataView(g.buffer,0,f),oa.copy?oa.copy(g,0,b,a):g.set(oa.slice(b,a)),ra-=b,b=0,qa=g.length-10,oa=g}}useBuffer(a){// this means we are finished using our own buffer and we can write over it safely
let{target:e,targetView:f,position:g}=c(15);e[g++]=199,e[g++]=12,e[g++]=255,f.setUint32(g,1e6*a.getMilliseconds()),f.setBigInt64(g+4,BigInt(b(d)))}}},{pack(a,b,c){letd=Array.from(a),{target:e,position:f}=b(this.structuredClone?3:0);this.structuredClone&&(e[f++]=212,e[f++]=115,e[f++]=0),c(d)}},{pack(a,b,c){let{target:d,position:e}=b(this.structuredClone?3:0);this.structuredClone&&(d[e++]=212,d[e++]=101,d[e++]=0),c([a.name,a.message])}},{pack(a,b,c){let{target:d,position:e}=b(this.structuredClone?3:0);this.structuredClone&&(d[e++]=212,d[e++]=120,d[e++]=0),c([a.source,a.flags])}},{pack(a,b){this.structuredClone?s(a,16,b):t(ka?Buffer.from(a):newUint8Array(a),b)}},{pack(a,b){letc=a.constructor;c!==ma&&this.structuredClone?s(a,$.indexOf(c.name),b):t(a,b)}},{pack(a,b){// specific 0xC1 object
let{target:c,position:d}=b(1);c[d]=193}}];letua=newta({useRecords:!1});constva=ua.pack,wa=ua.pack,{NEVER:xa,ALWAYS:ya,DECIMAL_ROUND:za,DECIMAL_FIT:Aa}=ea,Ba=1e3;a.ALWAYS=ya,a.C1=N,a.DECIMAL_FIT=Aa,a.DECIMAL_ROUND=za,a.Decoder=P,a.Encoder=ta,a.FLOAT32_OPTIONS=ea,a.NEVER=xa,a.Packr=ta,a.REUSE_BUFFER_MODE=Ba,a.Unpackr=P,a.addExtension=w,a.clearSource=q,a.decode=da,a.decodeIter=function(a,b={}){if(!a||"object"!=typeofa)thrownewError("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise");constc=newP(b);letd;conste=a=>{letb;// if there's incomplete data from previous chunk, concatinate and try again