12 |
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).msgpackr={})}(this,(function(t){"use strict";var e,r,n;try{e=new TextDecoder}catch(t){}var i,s,o,u,a,l=0,c={},f=0,h=0,g=[],p={useRecords:!1,mapsAsObjects:!0};class d{}const y=new d;y.name="MessagePack 0xC1";var w=!1,b=2;try{new Function("")}catch(t){b=1/0}class m{constructor(t){t&&(!1===t.useRecords&&void 0===t.mapsAsObjects&&(t.mapsAsObjects=!0),t.sequential&&!1!==t.trusted&&(t.trusted=!0,t.structures||0==t.useRecords||(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,e){if(r)return K((()=>(Z(),this?this.unpack(t,e):m.prototype.unpack.call(p,t,e))));t.buffer||t.constructor!==ArrayBuffer||(t="undefined"!=typeof Buffer?Buffer.from(t):new Uint8Array(t)),"object"==typeof e?(n=e.end||t.length,l=e.start||0):(l=0,n=e>-1?e:t.length),h=0,s=null,o=null,r=t;try{a=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){if(r=null,t instanceof Uint8Array)throw e;throw new Error("Source must be a Uint8Array or Buffer but was a "+(t&&"object"==typeof t?t.constructor.name:typeof t))}if(this instanceof m){if(c=this,this.structures)return i=this.structures,S(e);(!i||i.length>0)&&(i=[])}else c=p,(!i||i.length>0)&&(i=[]);return S(e)}unpackMultiple(t,e){let r,n=0;try{w=!0;let i=t.length,s=this?this.unpack(t,i):Q.unpack(t,i);if(!e){for(r=[s];l<i;)n=l,r.push(S());return r}if(!1===e(s,n,l))return;for(;l<i;)if(n=l,!1===e(S(),n,l))return}catch(t){throw t.lastPosition=n,t.values=r,t}finally{w=!1,Z()}}_mergeStructures(t,e){t=t||[],Object.isFrozen(t)&&(t=t.map((t=>t.slice(0))));for(let e=0,r=t.length;e<r;e++){let r=t[e];r&&(r.isShared=!0,e>=32&&(r.highByte=e-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let n=t[r],i=e[r];i&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[r]=n),t[r]=i)}return this.structures=t}decode(t,e){return this.unpack(t,e)}}function S(t){try{if(!c.trusted&&!w){let t=i.sharedLength||0;t<i.length&&(i.length=t)}let t;if(c.randomAccessStructure&&r[l]<64&&r[l],t=U(),o&&(l=o.postBundlePosition,o=null),w&&(i.restoreStructures=null),l==n)i&&i.restoreStructures&&I(),i=null,r=null,u&&(u=null);else{if(l>n)throw new Error("Unexpected end of MessagePack data");if(!w){let e;try{e=JSON.stringify(t,((t,e)=>"bigint"==typeof e?`${e}n`:e)).slice(0,100)}catch(t){e="(JSON view not available "+t+")"}throw new Error("Data read, but end of buffer not reached "+e)}}return t}catch(t){throw i&&i.restoreStructures&&I(),Z(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||l>n)&&(t.incomplete=!0),t}}function I(){for(let t in i.restoreStructures)i[t]=i.restoreStructures[t];i.restoreStructures=null}function U(){let t=r[l++];if(t<160){if(t<128){if(t<64)return t;{let e=i[63&t]||c.getStructures&&k()[63&t];return e?(e.read||(e.read=E(e,63&t)),e.read()):t}}if(t<144){if(t-=128,c.mapsAsObjects){let e={};for(let r=0;r<t;r++){let t=z();"__proto__"===t&&(t="__proto_"),e[t]=U()}return e}{let e=new Map;for(let r=0;r<t;r++)e.set(U(),U());return e}}{t-=144;let e=new Array(t);for(let r=0;r<t;r++)e[r]=U();return c.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(h>=l)return s.slice(l-f,(l+=e)-f);if(0==h&&n<140){let t=e<16?V(e):R(e);if(null!=t)return t}return v(e)}{let e;switch(t){case 192:return null;case 193:return o?(e=U(),e>0?o[1].slice(o.position1,o.position1+=e):o[0].slice(o.position0,o.position0-=e)):y;case 194:return!1;case 195:return!0;case 196:if(e=r[l++],void 0===e)throw new Error("Unexpected end of buffer");return L(e);case 197:return e=a.getUint16(l),l+=2,L(e);case 198:return e=a.getUint32(l),l+=4,L(e);case 199:return N(r[l++]);case 200:return e=a.getUint16(l),l+=2,N(e);case 201:return e=a.getUint32(l),l+=4,N(e);case 202:if(e=a.getFloat32(l),c.useFloat32>2){let t=G[(127&r[l])<<1|r[l+1]>>7];return l+=4,(t*e+(e>0?.5:-.5)>>0)/t}return l+=4,e;case 203:return e=a.getFloat64(l),l+=8,e;case 204:return r[l++];case 205:return e=a.getUint16(l),l+=2,e;case 206:return e=a.getUint32(l),l+=4,e;case 207:return"number"===c.int64AsType?(e=4294967296*a.getUint32(l),e+=a.getUint32(l+4)):"string"===c.int64AsType?e=a.getBigUint64(l).toString():"auto"===c.int64AsType?(e=a.getBigUint64(l),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=a.getBigUint64(l),l+=8,e;case 208:return a.getInt8(l++);case 209:return e=a.getInt16(l),l+=2,e;case 210:return e=a.getInt32(l),l+=4,e;case 211:return"number"===c.int64AsType?(e=4294967296*a.getInt32(l),e+=a.getUint32(l+4)):"string"===c.int64AsType?e=a.getBigInt64(l).toString():"auto"===c.int64AsType?(e=a.getBigInt64(l),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=a.getBigInt64(l),l+=8,e;case 212:if(e=r[l++],114==e)return W(63&r[l++]);{let t=g[e];if(t)return t.read?(l++,t.read(U())):t.noBuffer?(l++,t()):t(r.subarray(l,++l));throw new Error("Unknown extension "+e)}case 213:return e=r[l],114==e?(l++,W(63&r[l++],r[l++])):N(2);case 214:return N(4);case 215:return N(8);case 216:return N(16);case 217:return e=r[l++],h>=l?s.slice(l-f,(l+=e)-f):O(e);case 218:return e=a.getUint16(l),h>=(l+=2)?s.slice(l-f,(l+=e)-f):_(e);case 219:return e=a.getUint32(l),h>=(l+=4)?s.slice(l-f,(l+=e)-f):x(e);case 220:return e=a.getUint16(l),l+=2,j(e);case 221:return e=a.getUint32(l),l+=4,j(e);case 222:return e=a.getUint16(l),l+=2,M(e);case 223:return e=a.getUint32(l),l+=4,M(e);default:if(t>=224)return t-256;if(void 0===t){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+t)}}}const A=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function E(t,e){function r(){if(r.count++>b){let r=t.read=new Function("r","return function(){return "+(c.freezeData?"Object.freeze":"")+"({"+t.map((t=>"__proto__"===t?"__proto_:r()":A.test(t)?t+":r()":"["+JSON.stringify(t)+"]:r()")).join(",")+"})}")(U);return 0===t.highByte&&(t.read=B(e,t.read)),r()}let n={};for(let e=0,r=t.length;e<r;e++){let r=t[e];"__proto__"===r&&(r="__proto_"),n[r]=U()}return c.freezeData?Object.freeze(n):n}return r.count=0,0===t.highByte?B(e,r):r}const B=(t,e)=>function(){let n=r[l++];if(0===n)return e();let s=t<32?-(t+(n<<5)):t+(n<<5),o=i[s]||k()[s];if(!o)throw new Error("Record id is not defined for "+s);return o.read||(o.read=E(o,t)),o.read()};function k(){let t=K((()=>(r=null,c.getStructures())));return i=c._mergeStructures(t,i)}var v=T,O=T,_=T,x=T;function T(t){let n;if(t<16&&(n=V(t)))return n;if(t>64&&e)return e.decode(r.subarray(l,l+=t));const i=l+t,s=[];for(n="";l<i;){const t=r[l++];if(0==(128&t))s.push(t);else if(192==(224&t)){const e=63&r[l++];s.push((31&t)<<6|e)}else if(224==(240&t)){const e=63&r[l++],n=63&r[l++];s.push((31&t)<<12|e<<6|n)}else if(240==(248&t)){let e=(7&t)<<18|(63&r[l++])<<12|(63&r[l++])<<6|63&r[l++];e>65535&&(e-=65536,s.push(e>>>10&1023|55296),e=56320|1023&e),s.push(e)}else s.push(t);s.length>=4096&&(n+=D.apply(String,s),s.length=0)}return s.length>0&&(n+=D.apply(String,s)),n}function j(t){let e=new Array(t);for(let r=0;r<t;r++)e[r]=U();return c.freezeData?Object.freeze(e):e}function M(t){if(c.mapsAsObjects){let e={};for(let r=0;r<t;r++){let t=z();"__proto__"===t&&(t="__proto_"),e[t]=U()}return e}{let e=new Map;for(let r=0;r<t;r++)e.set(U(),U());return e}}var D=String.fromCharCode;function R(t){let e=l,n=new Array(t);for(let i=0;i<t;i++){const t=r[l++];if((128&t)>0)return void(l=e);n[i]=t}return D.apply(String,n)}function V(t){if(t<4){if(t<2){if(0===t)return"";{let t=r[l++];return(128&t)>1?void(l-=1):D(t)}}{let e=r[l++],n=r[l++];if((128&e)>0||(128&n)>0)return void(l-=2);if(t<3)return D(e,n);let i=r[l++];return(128&i)>0?void(l-=3):D(e,n,i)}}{let e=r[l++],n=r[l++],i=r[l++],s=r[l++];if((128&e)>0||(128&n)>0||(128&i)>0||(128&s)>0)return void(l-=4);if(t<6){if(4===t)return D(e,n,i,s);{let t=r[l++];return(128&t)>0?void(l-=5):D(e,n,i,s,t)}}if(t<8){let o=r[l++],u=r[l++];if((128&o)>0||(128&u)>0)return void(l-=6);if(t<7)return D(e,n,i,s,o,u);let a=r[l++];return(128&a)>0?void(l-=7):D(e,n,i,s,o,u,a)}{let o=r[l++],u=r[l++],a=r[l++],c=r[l++];if((128&o)>0||(128&u)>0||(128&a)>0||(128&c)>0)return void(l-=8);if(t<10){if(8===t)return D(e,n,i,s,o,u,a,c);{let t=r[l++];return(128&t)>0?void(l-=9):D(e,n,i,s,o,u,a,c,t)}}if(t<12){let f=r[l++],h=r[l++];if((128&f)>0||(128&h)>0)return void(l-=10);if(t<11)return D(e,n,i,s,o,u,a,c,f,h);let g=r[l++];return(128&g)>0?void(l-=11):D(e,n,i,s,o,u,a,c,f,h,g)}{let f=r[l++],h=r[l++],g=r[l++],p=r[l++];if((128&f)>0||(128&h)>0||(128&g)>0||(128&p)>0)return void(l-=12);if(t<14){if(12===t)return D(e,n,i,s,o,u,a,c,f,h,g,p);{let t=r[l++];return(128&t)>0?void(l-=13):D(e,n,i,s,o,u,a,c,f,h,g,p,t)}}{let d=r[l++],y=r[l++];if((128&d)>0||(128&y)>0)return void(l-=14);if(t<15)return D(e,n,i,s,o,u,a,c,f,h,g,p,d,y);let w=r[l++];return(128&w)>0?void(l-=15):D(e,n,i,s,o,u,a,c,f,h,g,p,d,y,w)}}}}}function F(){let t,e=r[l++];if(e<192)t=e-160;else switch(e){case 217:t=r[l++];break;case 218:t=a.getUint16(l),l+=2;break;case 219:t=a.getUint32(l),l+=4;break;default:throw new Error("Expected string")}return T(t)}function L(t){return c.copyBuffers?Uint8Array.prototype.slice.call(r,l,l+=t):r.subarray(l,l+=t)}function N(t){let e=r[l++];if(g[e]){let n;return g[e](r.subarray(l,n=l+=t),(t=>{l=t;try{return U()}finally{l=n}}))}throw new Error("Unknown extension type "+e)}var P=new Array(4096);function z(){let t=r[l++];if(!(t>=160&&t<192))return l--,C(U());if(t-=160,h>=l)return s.slice(l-f,(l+=t)-f);if(!(0==h&&n<180))return v(t);let e,i=4095&(t<<5^(t>1?a.getUint16(l):t>0?r[l]:0)),o=P[i],u=l,c=l+t-3,g=0;if(o&&o.bytes==t){for(;u<c;){if(e=a.getUint32(u),e!=o[g++]){u=1879048192;break}u+=4}for(c+=3;u<c;)if(e=r[u++],e!=o[g++]){u=1879048192;break}if(u===c)return l=u,o.string;c-=3,u=l}for(o=[],P[i]=o,o.bytes=t;u<c;)e=a.getUint32(u),o.push(e),u+=4;for(c+=3;u<c;)e=r[u++],o.push(e);let p=t<16?V(t):R(t);return o.string=null!=p?p:v(t)}function C(t){if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)return t.toString();if(null==t)return t+"";throw new Error("Invalid property type for record",typeof t)}const W=(t,e)=>{let r=U().map(C),n=t;void 0!==e&&(t=t<32?-((e<<5)+t):(e<<5)+t,r.highByte=e);let s=i[t];return s&&(s.isShared||w)&&((i.restoreStructures||(i.restoreStructures=[]))[t]=s),i[t]=r,r.read=E(r,n),r.read()};g[0]=()=>{},g[0].noBuffer=!0,g[66]=t=>{let e=t.length,r=BigInt(128&t[0]?t[0]-256:t[0]);for(let n=1;n<e;n++)r<<=BigInt(8),r+=BigInt(t[n]);return r};let J={Error:Error,TypeError:TypeError,ReferenceError:ReferenceError};g[101]=()=>{let t=U();return(J[t[0]]||Error)(t[1],{cause:t[2]})},g[105]=t=>{if(!1===c.structuredClone)throw new Error("Structured clone extension is disabled");let e=a.getUint32(l-4);u||(u=new Map);let n,i=r[l];n=i>=144&&i<160||220==i||221==i?[]:{};let s={target:n};u.set(e,s);let o=U();return s.used?Object.assign(n,o):(s.target=o,o)},g[112]=t=>{if(!1===c.structuredClone)throw new Error("Structured clone extension is disabled");let e=a.getUint32(l-4),r=u.get(e);return r.used=!0,r.target},g[115]=()=>new Set(U());const $=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((t=>t+"Array"));let Y="object"==typeof globalThis?globalThis:window;g[116]=t=>{let e=t[0],r=$[e];if(!r){if(16===e){let e=new ArrayBuffer(t.length-1);return new Uint8Array(e).set(t.subarray(1)),e}throw new Error("Could not find typed array for code "+e)}return new Y[r](Uint8Array.prototype.slice.call(t,1).buffer)},g[120]=()=>{let t=U();return new RegExp(t[0],t[1])};const q=[];function K(t){let e=n,g=l,p=f,d=h,y=s,b=u,m=o,S=new Uint8Array(r.slice(0,n)),I=i,U=i.slice(0,i.length),A=c,E=w,B=t();return n=e,l=g,f=p,h=d,s=y,u=b,o=m,r=S,w=E,(i=I).splice(0,i.length,...U),c=A,a=new DataView(r.buffer,r.byteOffset,r.byteLength),B}function Z(){r=null,u=null,i=null}g[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],r=l;return l+=e-t.length,o=q,(o=[F(),F()]).position0=0,o.position1=0,o.postBundlePosition=l,l=r,U()},g[255]=t=>4==t.length?new Date(1e3*(16777216*t[0]+(t[1]<<16)+(t[2]<<8)+t[3])):8==t.length?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+1e3*(4294967296*(3&t[3])+16777216*t[4]+(t[5]<<16)+(t[6]<<8)+t[7])):12==t.length?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+1e3*((128&t[4]?-281474976710656:0)+1099511627776*t[6]+4294967296*t[7]+16777216*t[8]+(t[9]<<16)+(t[10]<<8)+t[11])):new Date("invalid");const G=new Array(147);for(let t=0;t<256;t++)G[t]=+("1e"+Math.floor(45.15-.30103*t));const H=m;var Q=new m({useRecords:!1});const X=Q.unpack,tt=Q.unpackMultiple,et=Q.unpack,rt={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let nt,it,st,ot=new Float32Array(1),ut=new Uint8Array(ot.buffer,0,4);try{nt=new TextEncoder}catch(t){}const at="undefined"!=typeof Buffer,lt=at?function(t){return Buffer.allocUnsafeSlow(t)}:Uint8Array,ct=at?Buffer:Uint8Array,ft=at?4294967296:2144337920;let ht,gt,pt,dt,yt=0,wt=null;const bt=/[\u0080-\uFFFF]/,mt=Symbol("record-id");class St extends m{constructor(t){let e,r,n,i;super(t),this.offset=0;let s=ct.prototype.utf8Write?function(t,e){return ht.utf8Write(t,e,ht.byteLength-e)}:!(!nt||!nt.encodeInto)&&function(t,e){return nt.encodeInto(t,ht.subarray(e)).written},o=this;t||(t={});let u=t&&t.sequential,a=t.structures||t.saveStructures,l=t.maxSharedStructures;if(null==l&&(l=a?32:0),l>8160)throw new Error("Maximum maxSharedStructure is 8160");t.structuredClone&&null==t.moreTypes&&(this.moreTypes=!0);let c=t.maxOwnStructures;null==c&&(c=a?32:64),this.structures||0==t.useRecords||(this.structures=[]);let f=l>32||c+l>64,h=l+64,g=l+c+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let p=[],d=0,y=0;this.pack=this.encode=function(t,s){if(ht||(ht=new lt(8192),pt=ht.dataView||(ht.dataView=new DataView(ht.buffer,0,8192)),yt=0),dt=ht.length-10,dt-yt<2048?(ht=new lt(ht.length),pt=ht.dataView||(ht.dataView=new DataView(ht.buffer,0,ht.length)),dt=ht.length-10,yt=0):yt=yt+7&2147483640,e=yt,s&Rt&&(yt+=255&s),i=o.structuredClone?new Map:null,o.bundleStrings&&"string"!=typeof t?(wt=[],wt.size=1/0):wt=null,n=o.structures,n){n.uninitialized&&(n=o._mergeStructures(o.getStructures()));let t=n.sharedLength||0;if(t>l)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let e=0;e<t;e++){let t=n[e];if(!t)continue;let r,i=n.transitions;for(let e=0,n=t.length;e<n;e++){let n=t[e];r=i[n],r||(r=i[n]=Object.create(null)),i=r}i[mt]=e+64}this.lastNamedStructuresLength=t}u||(n.nextId=t+64)}let a;r&&(r=!1);try{o.randomAccessStructure&&t&&t.constructor&&t.constructor===Object?v(t):m(t);let u=wt;if(wt&&Et(e,m,0),i&&i.idsToInsert){let t=i.idsToInsert.sort(((t,e)=>t.offset>e.offset?1:-1)),r=t.length,n=-1;for(;u&&r>0;){let i=t[--r].offset+e;i<u.stringsPosition+e&&-1===n&&(n=0),i>u.position+e?n>=0&&(n+=6):(n>=0&&(pt.setUint32(u.position+e,pt.getUint32(u.position+e)+n),n=-1),u=u.previous,r++)}n>=0&&u&&pt.setUint32(u.position+e,pt.getUint32(u.position+e)+n),yt+=6*t.length,yt>dt&&E(yt),o.offset=yt;let s=function(t,e){let r,n=6*e.length,i=t.length-n;for(;r=e.pop();){let e=r.offset,s=r.id;t.copyWithin(e+n,e,i),n-=6;let o=e+n;t[o++]=214,t[o++]=105,t[o++]=s>>24,t[o++]=s>>16&255,t[o++]=s>>8&255,t[o++]=255&s,i=e}return t}(ht.subarray(e,yt),t);return i=null,s}return o.offset=yt,s&Mt?(ht.start=e,ht.end=yt,ht):ht.subarray(e,yt)}catch(t){throw a=t,t}finally{if(n&&(w(),r&&o.saveStructures)){let r=n.sharedLength||0,i=ht.subarray(e,yt),u=function(t,e){return t.isCompatible=t=>{let r=!t||(e.lastNamedStructuresLength||0)===t.length;return r||e._mergeStructures(t),r},t}(n,o);if(!a)return!1===o.saveStructures(u,u.isCompatible)?o.pack(t,s):(o.lastNamedStructuresLength=r,ht.length>1073741824&&(ht=null),i)}ht.length>1073741824&&(ht=null),s&Dt&&(yt=e)}};const w=()=>{y<10&&y++;let t=n.sharedLength||0;if(n.length>t&&!u&&(n.length=t),d>1e4)n.transitions=null,y=0,d=0,p.length>0&&(p=[]);else if(p.length>0&&!u){for(let t=0,e=p.length;t<e;t++)p[t][mt]=0;p=[]}},b=t=>{var e=t.length;e<16?ht[yt++]=144|e:e<65536?(ht[yt++]=220,ht[yt++]=e>>8,ht[yt++]=255&e):(ht[yt++]=221,pt.setUint32(yt,e),yt+=4);for(let r=0;r<e;r++)m(t[r])},m=t=>{yt>dt&&(ht=E(yt));var r,n=typeof t;if("string"===n){let n,i=t.length;if(wt&&i>=4&&i<4096){if((wt.size+=i)>21760){let t,r,n=(wt[0]?3*wt[0].length+wt[1].length:0)+10;yt+n>dt&&(ht=E(yt+n)),wt.position?(r=wt,ht[yt]=200,yt+=3,ht[yt++]=98,t=yt-e,yt+=4,Et(e,m,0),pt.setUint16(t+e-3,yt-e-t)):(ht[yt++]=214,ht[yt++]=98,t=yt-e,yt+=4),wt=["",""],wt.previous=r,wt.size=0,wt.position=t}let r=bt.test(t);return wt[r?0:1]+=t,ht[yt++]=193,void m(r?-i:i)}n=i<32?1:i<256?2:i<65536?3:5;let o=3*i;if(yt+o>dt&&(ht=E(yt+o)),i<64||!s){let e,s,o,u=yt+n;for(e=0;e<i;e++)s=t.charCodeAt(e),s<128?ht[u++]=s:s<2048?(ht[u++]=s>>6|192,ht[u++]=63&s|128):55296==(64512&s)&&56320==(64512&(o=t.charCodeAt(e+1)))?(s=65536+((1023&s)<<10)+(1023&o),e++,ht[u++]=s>>18|240,ht[u++]=s>>12&63|128,ht[u++]=s>>6&63|128,ht[u++]=63&s|128):(ht[u++]=s>>12|224,ht[u++]=s>>6&63|128,ht[u++]=63&s|128);r=u-yt-n}else r=s(t,yt+n);r<32?ht[yt++]=160|r:r<256?(n<2&&ht.copyWithin(yt+2,yt+1,yt+1+r),ht[yt++]=217,ht[yt++]=r):r<65536?(n<3&&ht.copyWithin(yt+3,yt+2,yt+2+r),ht[yt++]=218,ht[yt++]=r>>8,ht[yt++]=255&r):(n<5&&ht.copyWithin(yt+5,yt+3,yt+3+r),ht[yt++]=219,pt.setUint32(yt,r),yt+=4),yt+=r}else if("number"===n)if(t>>>0===t)t<32||t<128&&!1===this.useRecords||t<64&&!this.randomAccessStructure?ht[yt++]=t:t<256?(ht[yt++]=204,ht[yt++]=t):t<65536?(ht[yt++]=205,ht[yt++]=t>>8,ht[yt++]=255&t):(ht[yt++]=206,pt.setUint32(yt,t),yt+=4);else if(t>>0===t)t>=-32?ht[yt++]=256+t:t>=-128?(ht[yt++]=208,ht[yt++]=t+256):t>=-32768?(ht[yt++]=209,pt.setInt16(yt,t),yt+=2):(ht[yt++]=210,pt.setInt32(yt,t),yt+=4);else{let e;if((e=this.useFloat32)>0&&t<4294967296&&t>=-2147483648){let r;if(ht[yt++]=202,pt.setFloat32(yt,t),e<4||(r=t*G[(127&ht[yt])<<1|ht[yt+1]>>7])>>0===r)return void(yt+=4);yt--}ht[yt++]=203,pt.setFloat64(yt,t),yt+=8}else if("object"===n||"function"===n)if(t){if(i){let r=i.get(t);if(r){if(!r.id){let t=i.idsToInsert||(i.idsToInsert=[]);r.id=t.push(r)}return ht[yt++]=214,ht[yt++]=112,pt.setUint32(yt,r.id),void(yt+=4)}i.set(t,{offset:yt-e})}let s=t.constructor;if(s===Object)A(t);else if(s===Array)b(t);else if(s===Map)if(this.mapAsEmptyObject)ht[yt++]=128;else{(r=t.size)<16?ht[yt++]=128|r:r<65536?(ht[yt++]=222,ht[yt++]=r>>8,ht[yt++]=255&r):(ht[yt++]=223,pt.setUint32(yt,r),yt+=4);for(let[e,r]of t)m(e),m(r)}else{for(let e=0,r=it.length;e<r;e++){if(t instanceof st[e]){let r=it[e];if(r.write){r.type&&(ht[yt++]=212,ht[yt++]=r.type,ht[yt++]=0);let e=r.write.call(this,t);return void(e===t?Array.isArray(t)?b(t):A(t):m(e))}let n,i=ht,s=pt,o=yt;ht=null;try{n=r.pack.call(this,t,(t=>(ht=i,i=null,yt+=t,yt>dt&&E(yt),{target:ht,targetView:pt,position:yt-t})),m)}finally{i&&(ht=i,pt=s,yt=o,dt=ht.length-10)}return void(n&&(n.length+yt>dt&&E(n.length+yt),yt=At(n,ht,yt,r.type)))}}if(Array.isArray(t))b(t);else{if(t.toJSON){const e=t.toJSON();if(e!==t)return m(e)}if("function"===n)return m(this.writeFunction&&this.writeFunction(t));A(t)}}}else ht[yt++]=192;else if("boolean"===n)ht[yt++]=t?195:194;else if("bigint"===n){if(t<BigInt(1)<<BigInt(63)&&t>=-(BigInt(1)<<BigInt(63)))ht[yt++]=211,pt.setBigInt64(yt,t);else if(t<BigInt(1)<<BigInt(64)&&t>0)ht[yt++]=207,pt.setBigUint64(yt,t);else{if(!this.largeBigIntToFloat){if(this.largeBigIntToString)return m(t.toString());if(this.useBigIntExtension&&t<BigInt(2)**BigInt(1023)&&t>-(BigInt(2)**BigInt(1023))){ht[yt++]=199,yt++,ht[yt++]=66;let e,r=[];do{let n=t&BigInt(255);e=(n&BigInt(128))===(t<BigInt(0)?BigInt(128):BigInt(0)),r.push(n),t>>=BigInt(8)}while(t!==BigInt(0)&&t!==BigInt(-1)||!e);ht[yt-2]=r.length;for(let t=r.length;t>0;)ht[yt++]=Number(r[--t]);return}throw new RangeError(t+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}ht[yt++]=203,pt.setFloat64(yt,Number(t))}yt+=8}else{if("undefined"!==n)throw new Error("Unknown type: "+n);this.encodeUndefinedAsNil?ht[yt++]=192:(ht[yt++]=212,ht[yt++]=0,ht[yt++]=0)}},S=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?t=>{let e;if(this.skipValues){e=[];for(let r in t)"function"==typeof t.hasOwnProperty&&!t.hasOwnProperty(r)||this.skipValues.includes(t[r])||e.push(r)}else e=Object.keys(t);let r,n=e.length;if(n<16?ht[yt++]=128|n:n<65536?(ht[yt++]=222,ht[yt++]=n>>8,ht[yt++]=255&n):(ht[yt++]=223,pt.setUint32(yt,n),yt+=4),this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=e[i];let n=Number(r);m(isNaN(n)?r:n),m(t[r])}else for(let i=0;i<n;i++)m(r=e[i]),m(t[r])}:t=>{ht[yt++]=222;let r=yt-e;yt+=2;let n=0;for(let e in t)("function"!=typeof t.hasOwnProperty||t.hasOwnProperty(e))&&(m(e),m(t[e]),n++);if(n>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');ht[r+++e]=n>>8,ht[r+e]=255&n},I=!1===this.useRecords?S:t.progressiveRecords&&!f?t=>{let r,i,s=n.transitions||(n.transitions=Object.create(null)),o=yt++-e;for(let u in t)if("function"!=typeof t.hasOwnProperty||t.hasOwnProperty(u)){if(r=s[u],r)s=r;else{let a=Object.keys(t),l=s;s=n.transitions;let c=0;for(let t=0,e=a.length;t<e;t++){let e=a[t];r=s[e],r||(r=s[e]=Object.create(null),c++),s=r}o+e+1==yt?(yt--,B(s,a,c)):k(s,a,o,c),i=!0,s=l[u]}m(t[u])}if(!i){let r=s[mt];r?ht[o+e]=r:k(s,Object.keys(t),o,0)}}:t=>{let e,r=n.transitions||(n.transitions=Object.create(null)),i=0;for(let n in t)("function"!=typeof t.hasOwnProperty||t.hasOwnProperty(n))&&(e=r[n],e||(e=r[n]=Object.create(null),i++),r=e);let s=r[mt];s?s>=96&&f?(ht[yt++]=96+(31&(s-=96)),ht[yt++]=s>>5):ht[yt++]=s:B(r,r.__keys__||Object.keys(t),i);for(let e in t)("function"!=typeof t.hasOwnProperty||t.hasOwnProperty(e))&&m(t[e])},U="function"==typeof this.useRecords&&this.useRecords,A=U?t=>{U(t)?I(t):S(t)}:I,E=t=>{let r;if(t>16777216){if(t-e>ft)throw new Error("Packed buffer would be larger than maximum buffer size");r=Math.min(ft,4096*Math.round(Math.max((t-e)*(t>67108864?1.25:2),4194304)/4096))}else r=1+(Math.max(t-e<<2,ht.length-1)>>12)<<12;let n=new lt(r);return pt=n.dataView||(n.dataView=new DataView(n.buffer,0,r)),t=Math.min(t,ht.length),ht.copy?ht.copy(n,0,e,t):n.set(ht.slice(e,t)),yt-=e,e=0,dt=n.length-10,ht=n},B=(t,e,i)=>{let s=n.nextId;s||(s=64),s<h&&this.shouldShareStructure&&!this.shouldShareStructure(e)?(s=n.nextOwnId,s<g||(s=h),n.nextOwnId=s+1):(s>=g&&(s=h),n.nextId=s+1);let o=e.highByte=s>=96&&f?s-96>>5:-1;t[mt]=s,t.__keys__=e,n[s-64]=e,s<h?(e.isShared=!0,n.sharedLength=s-63,r=!0,o>=0?(ht[yt++]=96+(31&s),ht[yt++]=o):ht[yt++]=s):(o>=0?(ht[yt++]=213,ht[yt++]=114,ht[yt++]=96+(31&s),ht[yt++]=o):(ht[yt++]=212,ht[yt++]=114,ht[yt++]=s),i&&(d+=y*i),p.length>=c&&(p.shift()[mt]=0),p.push(t),m(e))},k=(t,r,n,i)=>{let s=ht,o=yt,u=dt,a=e;ht=gt,yt=0,e=0,ht||(gt=ht=new lt(8192)),dt=ht.length-10,B(t,r,i),gt=ht;let l=yt;if(ht=s,yt=o,dt=u,e=a,l>1){let t=yt+l-1;t>dt&&E(t);let r=n+e;ht.copyWithin(r+l,r+1,yt),ht.set(gt.slice(0,l),r),yt=t}else ht[n+e]=gt[0]},v=t=>{let i=undefined(t,ht,e,yt,n,E,((t,e,n)=>{if(n)return r=!0;yt=e;let i=ht;return m(t),w(),i!==ht?{position:yt,targetView:pt,target:ht}:yt}),this);if(0===i)return A(t);yt=i}}useBuffer(t){ht=t,ht.dataView||(ht.dataView=new DataView(ht.buffer,ht.byteOffset,ht.byteLength)),yt=0}set position(t){yt=t}get position(){return yt}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}function It(t,e,r,n){let i=t.byteLength;if(i+1<256){var{target:s,position:o}=r(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=r(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:u}=r(7+i);s[o++]=201,u.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=e,t.buffer||(t=new Uint8Array(t)),s.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o)}function Ut(t,e){let r=t.byteLength;var n,i;if(r<256){var{target:n,position:i}=e(r+2);n[i++]=196,n[i++]=r}else if(r<65536){var{target:n,position:i}=e(r+3);n[i++]=197,n[i++]=r>>8,n[i++]=255&r}else{var{target:n,position:i,targetView:s}=e(r+5);n[i++]=198,s.setUint32(i,r),i+=4}n.set(t,i)}function At(t,e,r,n){let i=t.length;switch(i){case 1:e[r++]=212;break;case 2:e[r++]=213;break;case 4:e[r++]=214;break;case 8:e[r++]=215;break;case 16:e[r++]=216;break;default:i<256?(e[r++]=199,e[r++]=i):i<65536?(e[r++]=200,e[r++]=i>>8,e[r++]=255&i):(e[r++]=201,e[r++]=i>>24,e[r++]=i>>16&255,e[r++]=i>>8&255,e[r++]=255&i)}return e[r++]=n,e.set(t,r),r+=i}function Et(t,e,r){if(wt.length>0){pt.setUint32(wt.position+t,yt+r-wt.position-t),wt.stringsPosition=yt-t;let n=wt;wt=null,e(n[0]),e(n[1])}}st=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,d],it=[{pack(t,e,r){let n=t.getTime()/1e3;if((this.useTimestamp32||0===t.getMilliseconds())&&n>=0&&n<4294967296){let{target:t,targetView:r,position:i}=e(6);t[i++]=214,t[i++]=255,r.setUint32(i,n)}else if(n>0&&n<4294967296){let{target:r,targetView:i,position:s}=e(10);r[s++]=215,r[s++]=255,i.setUint32(s,4e6*t.getMilliseconds()+(n/1e3/4294967296>>0)),i.setUint32(s+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),r(this.onInvalidDate());let{target:t,targetView:n,position:i}=e(3);t[i++]=212,t[i++]=255,t[i++]=255}else{let{target:r,targetView:i,position:s}=e(15);r[s++]=199,r[s++]=12,r[s++]=255,i.setUint32(s,1e6*t.getMilliseconds()),i.setBigInt64(s+4,BigInt(Math.floor(n)))}}},{pack(t,e,r){if(this.setAsEmptyObject)return e(0),r({});let n=Array.from(t),{target:i,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(i[s++]=212,i[s++]=115,i[s++]=0),r(n)}},{pack(t,e,r){let{target:n,position:i}=e(this.moreTypes?3:0);this.moreTypes&&(n[i++]=212,n[i++]=101,n[i++]=0),r([t.name,t.message,t.cause])}},{pack(t,e,r){let{target:n,position:i}=e(this.moreTypes?3:0);this.moreTypes&&(n[i++]=212,n[i++]=120,n[i++]=0),r([t.source,t.flags])}},{pack(t,e){this.moreTypes?It(t,16,e):Ut(at?Buffer.from(t):new Uint8Array(t),e)}},{pack(t,e){let r=t.constructor;r!==ct&&this.moreTypes?It(t,$.indexOf(r.name),e):Ut(t,e)}},{pack(t,e){let{target:r,position:n}=e(1);r[n]=193}}];let Bt=new St({useRecords:!1});const kt=Bt.pack,vt=Bt.pack,Ot=St,{NEVER:_t,ALWAYS:xt,DECIMAL_ROUND:Tt,DECIMAL_FIT:jt}=rt,Mt=512,Dt=1024,Rt=2048;const Vt=function(t,e={}){if(!t||"object"!=typeof t)throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise");const r=new m(e);let n;const i=t=>{let e;n&&(t=Buffer.concat([n,t]),n=void 0);try{e=r.unpackMultiple(t)}catch(r){if(!r.incomplete)throw r;n=t.slice(r.lastPosition),e=r.values}return e};return"function"==typeof t[Symbol.iterator]?function*(){for(const e of t)yield*i(e)}():"function"==typeof t[Symbol.asyncIterator]?async function*(){for await(const e of t)yield*i(e)}():void 0},Ft=function(t,e={}){if(t&&"object"==typeof t){if("function"==typeof t[Symbol.iterator])return function*(t,e){const r=new St(e);for(const e of t)yield r.pack(e)}(t,e);if("function"==typeof t.then||"function"==typeof t[Symbol.asyncIterator])return async function*(t,e){const r=new St(e);for await(const e of t)yield r.pack(e)}(t,e);throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise")}throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable")};t.ALWAYS=xt,t.C1=y,t.DECIMAL_FIT=jt,t.DECIMAL_ROUND=Tt,t.Decoder=H,t.Encoder=Ot,t.FLOAT32_OPTIONS=rt,t.NEVER=_t,t.Packr=St,t.RESERVE_START_SPACE=Rt,t.RESET_BUFFER_MODE=Dt,t.REUSE_BUFFER_MODE=Mt,t.Unpackr=m,t.addExtension=function(t){if(t.Class){if(!t.pack&&!t.write)throw new Error("Extension has no pack or write function");if(t.pack&&!t.type)throw new Error("Extension has no type (numeric code to identify the extension)");st.unshift(t.Class),it.unshift(t)}!function(t){t.unpack?g[t.type]=t.unpack:g[t.type]=t}(t)},t.clearSource=Z,t.decode=et,t.decodeIter=Vt,t.encode=vt,t.encodeIter=Ft,t.isNativeAccelerationEnabled=!1,t.mapsAsObjects=!0,t.pack=kt,t.roundFloat32=function(t){ot[0]=t;let e=G[(127&ut[3])<<1|ut[2]>>7];return(e*t+(t>0?.5:-.5)>>0)/e},t.unpack=X,t.unpackMultiple=tt,t.useRecords=!1}));
- //# sourceMappingURL=index.min.js.map
|