Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ipld/dag-cbor

Package Overview
Dependencies
Maintainers
9
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipld/dag-cbor - npm Package Compare versions

Comparing version 8.0.0 to 8.0.1

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpldDagCbor = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var IpldDagCbor=(()=>{var Ae=Object.defineProperty;var ar=Object.getOwnPropertyDescriptor;var ur=Object.getOwnPropertyNames;var dr=Object.prototype.hasOwnProperty;var fr=(e,t)=>{for(var r in t)Ae(e,r,{get:t[r],enumerable:!0})},lr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ur(t))!dr.call(e,o)&&o!==r&&Ae(e,o,{get:()=>t[o],enumerable:!(n=ar(t,o))||n.enumerable});return e};var pr=e=>lr(Ae({},"__esModule",{value:!0}),e);var Nn={};fr(Nn,{code:()=>Sn,decode:()=>_n,encode:()=>Bn,name:()=>kn});var hr=["string","number","bigint","symbol"],mr=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Pe(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(hr.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(yr(e))return"Buffer";let r=gr(e);return r||"Object"}function yr(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function gr(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(mr.includes(t))return t}var s=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(7,"break",!0);var a=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var J=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",wr=new TextDecoder,br=new TextEncoder;function he(e){return J&&globalThis.Buffer.isBuffer(e)}function Te(e){return e instanceof Uint8Array?he(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Je=J?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):qe(e,t,r):(e,t,r)=>r-t>64?wr.decode(e.subarray(t,r)):qe(e,t,r),Xe=J?e=>e.length>64?globalThis.Buffer.from(e):je(e):e=>e.length>64?br.encode(e):je(e),z=e=>Uint8Array.from(e),X=J?(e,t,r)=>he(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),He=J?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Te(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Ke=J?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function We(e,t){if(he(e)&&he(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function je(e,t=1/0){let r,n=e.length,o=null,i=[];for(let u=0;u<n;++u){if(r=e.charCodeAt(u),r>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}else if(u+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return i}function qe(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,u=o>239?4:o>223?3:o>191?2:1;if(t+u<=r){let d,p,b,h;switch(u){case 1:o<128&&(i=o);break;case 2:d=e[t+1],(d&192)===128&&(h=(o&31)<<6|d&63,h>127&&(i=h));break;case 3:d=e[t+1],p=e[t+2],(d&192)===128&&(p&192)===128&&(h=(o&15)<<12|(d&63)<<6|p&63,h>2047&&(h<55296||h>57343)&&(i=h));break;case 4:d=e[t+1],p=e[t+2],b=e[t+3],(d&192)===128&&(p&192)===128&&(b&192)===128&&(h=(o&15)<<18|(d&63)<<12|(p&63)<<6|b&63,h>65535&&h<1114112&&(i=h))}}i===null?(i=65533,u=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=u}return xr(n)}var Ge=4096;function xr(e){let t=e.length;if(t<=Ge)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Ge));return r}var Er=256,re=class{constructor(t=Er){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Ke(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=X(n,0,this.cursor)}else r=He(this.chunks,this.cursor);return t&&this.reset(),r}};var f="CBOR decode error:",ke="CBOR encode error:",ne=[];ne[23]=1;ne[24]=2;ne[25]=3;ne[26]=5;ne[27]=9;function D(e,t,r){if(e.length-t<r)throw new Error(`${f} not enough data for type`)}var g=[24,256,65536,4294967296,BigInt("18446744073709551616")];function E(e,t,r){D(e,t,1);let n=e[t];if(r.strict===!0&&n<g[0])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){D(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<g[1])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function U(e,t,r){D(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<g[2])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){D(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<g[3])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${f} integers outside of the safe integer range are not supported`)}function Qe(e,t,r,n){return new a(s.uint,E(e,t+1,n),2)}function Ze(e,t,r,n){return new a(s.uint,v(e,t+1,n),3)}function Ye(e,t,r,n){return new a(s.uint,U(e,t+1,n),5)}function et(e,t,r,n){return new a(s.uint,A(e,t+1,n),9)}function k(e,t){return w(e,0,t.value)}function w(e,t,r){if(r<g[0]){let n=Number(r);e.push([t|n])}else if(r<g[1]){let n=Number(r);e.push([t|24,n])}else if(r<g[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<g[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<g[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),u=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=u&255,u=u>>8,o[3]=u&255,u=u>>8,o[2]=u&255,u=u>>8,o[1]=u&255,e.push(o)}else throw new Error(`${f} encountered BigInt larger than allowable range`)}}k.encodedSize=function(t){return w.encodedSize(t.value)};w.encodedSize=function(t){return t<g[0]?1:t<g[1]?2:t<g[2]?3:t<g[3]?5:9};k.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function tt(e,t,r,n){return new a(s.negint,-1-E(e,t+1,n),2)}function rt(e,t,r,n){return new a(s.negint,-1-v(e,t+1,n),3)}function nt(e,t,r,n){return new a(s.negint,-1-U(e,t+1,n),5)}var Se=BigInt(-1),ot=BigInt(1);function it(e,t,r,n){let o=A(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new a(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${f} integers outside of the safe integer range are not supported`);return new a(s.negint,Se-BigInt(o),9)}function me(e,t){let r=t.value,n=typeof r=="bigint"?r*Se-ot:r*-1-1;w(e,t.type.majorEncoded,n)}me.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Se-ot:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};me.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function oe(e,t,r,n){D(e,t,r+n);let o=X(e,t+r,t+r+n);return new a(s.bytes,o,r+n)}function st(e,t,r,n){return oe(e,t,1,r)}function ct(e,t,r,n){return oe(e,t,2,E(e,t+1,n))}function at(e,t,r,n){return oe(e,t,3,v(e,t+1,n))}function ut(e,t,r,n){return oe(e,t,5,U(e,t+1,n))}function dt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer bytes lengths not supported`);return oe(e,t,9,o)}function ye(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?Xe(e.value):e.value),e.encodedBytes}function H(e,t){let r=ye(t);w(e,t.type.majorEncoded,r.length),e.push(r)}H.encodedSize=function(t){let r=ye(t);return w.encodedSize(r.length)+r.length};H.compareTokens=function(t,r){return Ur(ye(t),ye(r))};function Ur(e,t){return e.length<t.length?-1:e.length>t.length?1:We(e,t)}function ie(e,t,r,n,o){let i=r+n;D(e,t,i);let u=new a(s.string,Je(e,t+r,t+i),i);return o.retainStringBytes===!0&&(u.byteValue=X(e,t+r,t+i)),u}function ft(e,t,r,n){return ie(e,t,1,r,n)}function lt(e,t,r,n){return ie(e,t,2,E(e,t+1,n),n)}function pt(e,t,r,n){return ie(e,t,3,v(e,t+1,n),n)}function ht(e,t,r,n){return ie(e,t,5,U(e,t+1,n),n)}function mt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer string lengths not supported`);return ie(e,t,9,o,n)}var yt=H;function K(e,t,r,n){return new a(s.array,n,r)}function gt(e,t,r,n){return K(e,t,1,r)}function wt(e,t,r,n){return K(e,t,2,E(e,t+1,n))}function bt(e,t,r,n){return K(e,t,3,v(e,t+1,n))}function xt(e,t,r,n){return K(e,t,5,U(e,t+1,n))}function Et(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer array lengths not supported`);return K(e,t,9,o)}function vt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return K(e,t,1,1/0)}function ge(e,t){w(e,s.array.majorEncoded,t.value)}ge.compareTokens=k.compareTokens;ge.encodedSize=function(t){return w.encodedSize(t.value)};function W(e,t,r,n){return new a(s.map,n,r)}function Ut(e,t,r,n){return W(e,t,1,r)}function At(e,t,r,n){return W(e,t,2,E(e,t+1,n))}function Tt(e,t,r,n){return W(e,t,3,v(e,t+1,n))}function kt(e,t,r,n){return W(e,t,5,U(e,t+1,n))}function St(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer map lengths not supported`);return W(e,t,9,o)}function Bt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return W(e,t,1,1/0)}function we(e,t){w(e,s.map.majorEncoded,t.value)}we.compareTokens=k.compareTokens;we.encodedSize=function(t){return w.encodedSize(t.value)};function _t(e,t,r,n){return new a(s.tag,r,1)}function Nt(e,t,r,n){return new a(s.tag,E(e,t+1,n),2)}function It(e,t,r,n){return new a(s.tag,v(e,t+1,n),3)}function $t(e,t,r,n){return new a(s.tag,U(e,t+1,n),5)}function Ct(e,t,r,n){return new a(s.tag,A(e,t+1,n),9)}function be(e,t){w(e,s.tag.majorEncoded,t.value)}be.compareTokens=k.compareTokens;be.encodedSize=function(t){return w.encodedSize(t.value)};var _r=20,Nr=21,Ir=22,$r=23;function Mt(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${f} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new a(s.null,null,1):new a(s.undefined,void 0,1)}function zt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return new a(s.break,void 0,1)}function Be(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${f} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${f} Infinity values are not supported`)}return new a(s.float,e,t)}function Ot(e,t,r,n){return Be(_e(e,t+1),3,n)}function Ft(e,t,r,n){return Be(Ne(e,t+1),5,n)}function Dt(e,t,r,n){return Be(Pt(e,t+1),9,n)}function xe(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|_r]);else if(n===!0)e.push([s.float.majorEncoded|Nr]);else if(n===null)e.push([s.float.majorEncoded|Ir]);else if(n===void 0)e.push([s.float.majorEncoded|$r]);else{let o,i=!1;(!r||r.float64!==!0)&&(Lt(n),o=_e(N,1),n===o||Number.isNaN(n)?(N[0]=249,e.push(N.slice(0,3)),i=!0):(Rt(n),o=Ne(N,1),n===o&&(N[0]=250,e.push(N.slice(0,5)),i=!0))),i||(Cr(n),o=Pt(N,1),N[0]=251,e.push(N.slice(0,9)))}}xe.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Lt(n);let o=_e(N,1);if(n===o||Number.isNaN(n))return 3;if(Rt(n),o=Ne(N,1),n===o)return 5}return 9};var Vt=new ArrayBuffer(9),S=new DataView(Vt,1),N=new Uint8Array(Vt,0);function Lt(e){if(e===1/0)S.setUint16(0,31744,!1);else if(e===-1/0)S.setUint16(0,64512,!1);else if(Number.isNaN(e))S.setUint16(0,32256,!1);else{S.setFloat32(0,e);let t=S.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)S.setUint16(0,31744,!1);else if(r===0)S.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?S.setUint16(0,0):o<-14?S.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):S.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function _e(e,t){if(e.length-t<2)throw new Error(`${f} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Rt(e){S.setFloat32(0,e,!1)}function Ne(e,t){if(e.length-t<4)throw new Error(`${f} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Cr(e){S.setFloat64(0,e,!1)}function Pt(e,t){if(e.length-t<8)throw new Error(`${f} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}xe.compareTokens=k.compareTokens;function l(e,t,r){throw new Error(`${f} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Ee(e){return()=>{throw new Error(`${f} ${e}`)}}var c=[];for(let e=0;e<=23;e++)c[e]=l;c[24]=Qe;c[25]=Ze;c[26]=Ye;c[27]=et;c[28]=l;c[29]=l;c[30]=l;c[31]=l;for(let e=32;e<=55;e++)c[e]=l;c[56]=tt;c[57]=rt;c[58]=nt;c[59]=it;c[60]=l;c[61]=l;c[62]=l;c[63]=l;for(let e=64;e<=87;e++)c[e]=st;c[88]=ct;c[89]=at;c[90]=ut;c[91]=dt;c[92]=l;c[93]=l;c[94]=l;c[95]=Ee("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)c[e]=ft;c[120]=lt;c[121]=pt;c[122]=ht;c[123]=mt;c[124]=l;c[125]=l;c[126]=l;c[127]=Ee("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)c[e]=gt;c[152]=wt;c[153]=bt;c[154]=xt;c[155]=Et;c[156]=l;c[157]=l;c[158]=l;c[159]=vt;for(let e=160;e<=183;e++)c[e]=Ut;c[184]=At;c[185]=Tt;c[186]=kt;c[187]=St;c[188]=l;c[189]=l;c[190]=l;c[191]=Bt;for(let e=192;e<=215;e++)c[e]=_t;c[216]=Nt;c[217]=It;c[218]=$t;c[219]=Ct;c[220]=l;c[221]=l;c[222]=l;c[223]=l;for(let e=224;e<=243;e++)c[e]=Ee("simple values are not supported");c[244]=l;c[245]=l;c[246]=l;c[247]=Mt;c[248]=Ee("simple values are not supported");c[249]=Ot;c[250]=Ft;c[251]=Dt;c[252]=l;c[253]=l;c[254]=l;c[255]=zt;var I=[];for(let e=0;e<24;e++)I[e]=new a(s.uint,e,1);for(let e=-1;e>=-24;e--)I[31-e]=new a(s.negint,e,1);I[64]=new a(s.bytes,new Uint8Array(0),1);I[96]=new a(s.string,"",1);I[128]=new a(s.array,0,1);I[160]=new a(s.map,0,1);I[244]=new a(s.false,!1,1);I[245]=new a(s.true,!0,1);I[246]=new a(s.null,null,1);function jt(e){switch(e.type){case s.false:return z([244]);case s.true:return z([245]);case s.null:return z([246]);case s.bytes:return e.value.length?void 0:z([64]);case s.string:return e.value===""?z([96]):void 0;case s.array:return e.value===0?z([128]):void 0;case s.map:return e.value===0?z([160]):void 0;case s.uint:return e.value<24?z([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return z([31-Number(e.value)])}}var zr={float64:!1,mapSorter:Dr,quickEncodeToken:jt};function Or(){let e=[];return e[s.uint.major]=k,e[s.negint.major]=me,e[s.bytes.major]=H,e[s.string.major]=yt,e[s.array.major]=ge,e[s.map.major]=we,e[s.tag.major]=be,e[s.float.major]=xe,e}var qt=Or(),Ie=new re,Q=class{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${ke} object contains circular references`);return new Q(r,t)}},R={null:new a(s.null,null),undefined:new a(s.undefined,void 0),true:new a(s.true,!0),false:new a(s.false,!1),emptyArray:new a(s.array,0),emptyMap:new a(s.map,0)},P={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new a(s.float,e):e>=0?new a(s.uint,e):new a(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new a(s.uint,e):new a(s.negint,e)},Uint8Array(e,t,r,n){return new a(s.bytes,e)},string(e,t,r,n){return new a(s.string,e)},boolean(e,t,r,n){return e?R.true:R.false},null(e,t,r,n){return R.null},undefined(e,t,r,n){return R.undefined},ArrayBuffer(e,t,r,n){return new a(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new a(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[R.emptyArray,new a(s.break)]:R.emptyArray;n=Q.createCheck(n,e);let o=[],i=0;for(let u of e)o[i++]=ve(u,r,n);return r.addBreakTokens?[new a(s.array,e.length),o,new a(s.break)]:[new a(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),u=o?e.size:i.length;if(!u)return r.addBreakTokens===!0?[R.emptyMap,new a(s.break)]:R.emptyMap;n=Q.createCheck(n,e);let d=[],p=0;for(let b of i)d[p++]=[ve(b,r,n),ve(o?e.get(b):e[b],r,n)];return Fr(d,r),r.addBreakTokens?[new a(s.map,u),d,new a(s.break)]:[new a(s.map,u),d]}};P.Map=P.Object;P.Buffer=P.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))P[`${e}Array`]=P.DataView;function ve(e,t={},r){let n=Pe(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||P[n];if(typeof o=="function"){let u=o(e,n,t,r);if(u!=null)return u}let i=P[n];if(!i)throw new Error(`${ke} unsupported type: ${n}`);return i(e,n,t,r)}function Fr(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Dr(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=qt[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Gt(e,t,r,n){if(Array.isArray(t))for(let o of t)Gt(e,o,r,n);else r[t.type.major](e,t,n)}function Vr(e,t,r){let n=ve(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let u=i.encodedSize(n,r),d=new re(u);if(i(d,n,r),d.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Te(d.chunks[0])}}return Ie.reset(),Gt(Ie,n,t,r),Ie.toBytes(!0)}function $e(e,t){return t=Object.assign({},zr,t),Vr(e,qt,t)}var Lr={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ce=class{constructor(t,r={}){this.pos=0,this.data=t,this.options=r}done(){return this.pos>=this.data.length}next(){let t=this.data[this.pos],r=I[t];if(r===void 0){let n=c[t];if(!n)throw new Error(`${f} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this.pos,o,this.options)}return this.pos+=r.encodedLength,r}},se=Symbol.for("DONE"),Ue=Symbol.for("BREAK");function Rr(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=ce(t,r);if(i===Ue){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed array`)}if(i===se)throw new Error(`${f} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function Pr(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let u=0;u<e.value;u++){let d=ce(t,r);if(d===Ue){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(d===se)throw new Error(`${f} found map but not enough entries (got ${u} [no key], expected ${e.value})`);if(n!==!0&&typeof d!="string")throw new Error(`${f} non-string keys not supported (got ${typeof d})`);let p=ce(t,r);if(p===se)throw new Error(`${f} found map but not enough entries (got ${u} [no value], expected ${e.value})`);n?i.set(d,p):o[d]=p}return n?i:o}function ce(e,t){if(e.done())return se;let r=e.next();if(r.type===s.break)return Ue;if(r.type.terminal)return r.value;if(r.type===s.array)return Rr(r,e,t);if(r.type===s.map)return Pr(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=ce(e,t);return t.tags[r.value](n)}throw new Error(`${f} tag not supported (${r.value})`)}throw new Error("unsupported")}function Me(e,t){if(!(e instanceof Uint8Array))throw new Error(`${f} data to decode must be a Uint8Array`);t=Object.assign({},Lr,t);let r=t.tokenizer||new Ce(e,t),n=ce(r,t);if(n===se)throw new Error(`${f} did not find any content to decode`);if(n===Ue)throw new Error(`${f} got unexpected break`);if(!r.done())throw new Error(`${f} too many terminals, data makes no sense`);return n}var qr=Ht,Jt=128,Gr=127,Jr=~Gr,Xr=Math.pow(2,31);function Ht(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Xr;)t[r++]=e&255|Jt,e/=128;for(;e&Jr;)t[r++]=e&255|Jt,e>>>=7;return t[r]=e|0,Ht.bytes=r-n+1,t}var Hr=ze,Kr=128,Xt=127;function ze(e,n){var r=0,n=n||0,o=0,i=n,u,d=e.length;do{if(i>=d)throw ze.bytes=0,new RangeError("Could not decode varint");u=e[i++],r+=o<28?(u&Xt)<<o:(u&Xt)*Math.pow(2,o),o+=7}while(u>=Kr);return ze.bytes=i-n,r}var Wr=Math.pow(2,7),Qr=Math.pow(2,14),Zr=Math.pow(2,21),Yr=Math.pow(2,28),en=Math.pow(2,35),tn=Math.pow(2,42),rn=Math.pow(2,49),nn=Math.pow(2,56),on=Math.pow(2,63),sn=function(e){return e<Wr?1:e<Qr?2:e<Zr?3:e<Yr?4:e<en?5:e<tn?6:e<rn?7:e<nn?8:e<on?9:10},cn={encode:qr,decode:Hr,encodingLength:sn},an=cn,ae=an;var ue=(e,t=0)=>[ae.decode(e,t),ae.decode.bytes],Z=(e,t,r=0)=>(ae.encode(e,t,r),t),Y=e=>ae.encodingLength(e);var $o=new Uint8Array(0);var Wt=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},ee=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var Qt=(e,t)=>{let r=t.byteLength,n=Y(e),o=n+Y(r),i=new Uint8Array(o+r);return Z(e,i,0),Z(r,i,n),i.set(t,o),new te(e,r,t,i)},Zt=e=>{let t=ee(e),[r,n]=ue(t),[o,i]=ue(t.subarray(n)),u=t.subarray(n+i);if(u.byteLength!==o)throw new Error("Incorrect length");return new te(r,o,u,t)},Yt=(e,t)=>{if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Wt(e.bytes,r.bytes)}},te=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function dn(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),u=i.charCodeAt(0);if(r[u]!==255)throw new TypeError(i+" is ambiguous");r[u]=o}var d=e.length,p=e.charAt(0),b=Math.log(d)/Math.log(256),h=Math.log(256)/Math.log(d);function G(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var x=0,j=0,B=0,$=m.length;B!==$&&m[B]===0;)B++,x++;for(var C=($-B)*h+1>>>0,T=new Uint8Array(C);B!==$;){for(var M=m[B],L=0,_=C-1;(M!==0||L<j)&&_!==-1;_--,L++)M+=256*T[_]>>>0,T[_]=M%d>>>0,M=M/d>>>0;if(M!==0)throw new Error("Non-zero carry");j=L,B++}for(var F=C-j;F!==C&&T[F]===0;)F++;for(var pe=p.repeat(x);F<C;++F)pe+=e.charAt(T[F]);return pe}function le(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var x=0;if(m[x]!==" "){for(var j=0,B=0;m[x]===p;)j++,x++;for(var $=(m.length-x)*b+1>>>0,C=new Uint8Array($);m[x];){var T=r[m.charCodeAt(x)];if(T===255)return;for(var M=0,L=$-1;(T!==0||M<B)&&L!==-1;L--,M++)T+=d*C[L]>>>0,C[L]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");B=M,x++}if(m[x]!==" "){for(var _=$-B;_!==$&&C[_]===0;)_++;for(var F=new Uint8Array(j+($-_)),pe=j;_!==$;)F[pe++]=C[_++];return F}}}function cr(m){var x=le(m);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:G,decodeUnsafe:le,decode:cr}}var fn=dn,ln=fn,er=ln;var Oe=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Fe=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return tr(this,t)}},De=class{constructor(t){this.decoders=t}or(t){return tr(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},tr=(e,t)=>new De({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),Ve=class{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Oe(t,r,n),this.decoder=new Fe(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},rr=({name:e,prefix:t,encode:r,decode:n})=>new Ve(e,t,r,n),Le=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=er(r,t);return rr({prefix:e,name:t,encode:n,decode:i=>ee(o(i))})},pn=(e,t,r,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=e.length;for(;e[i-1]==="=";)--i;let u=new Uint8Array(i*r/8|0),d=0,p=0,b=0;for(let h=0;h<i;++h){let G=o[e[h]];if(G===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|G,d+=r,d>=8&&(d-=8,u[b++]=255&p>>d)}if(d>=r||255&p<<8-d)throw new SyntaxError("Unexpected end of data");return u},hn=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,i="",u=0,d=0;for(let p=0;p<e.length;++p)for(d=d<<8|e[p],u+=8;u>r;)u-=r,i+=t[o&d>>u];if(u&&(i+=t[o&d<<r-u]),n)for(;i.length*r&7;)i+="=";return i},O=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>rr({prefix:t,name:e,encode(o){return hn(o,n,r)},decode(o){return pn(o,n,r,e)}});var V=Le({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lo=Le({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var de=O({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jo=O({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qo=O({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Go=O({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jo=O({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xo=O({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ho=O({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ko=O({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wo=O({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mn=(e,t)=>{let{bytes:r,version:n}=e;switch(n){case 0:return gn(r,Re(e),t||V.encoder);default:return wn(r,Re(e),t||de.encoder)}},nr=new WeakMap,Re=e=>{let t=nr.get(e);if(t==null){let r=new Map;return nr.set(e,r),r}return t},y=class{constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==fe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==bn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Qt(t,r);return y.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return y.equals(this,t)}static equals(t,r){let n=r;return n&&t.code===n.code&&t.version===n.version&&Yt(t.multihash,n.multihash)}toString(t){return mn(this,t)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof y)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:u}=r;return new y(n,o,i,u||or(n,o,i.bytes))}else if(r[xn]===!0){let{version:n,multihash:o,code:i}=r,u=Zt(o);return y.create(n,i,u)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==fe)throw new Error(`Version 0 CID must use dag-pb (code: ${fe}) block encoding`);return new y(t,r,n,n.bytes)}case 1:{let o=or(t,r,n.bytes);return new y(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return y.create(0,fe,t)}static createV1(t,r){return y.create(1,t,r)}static decode(t){let[r,n]=y.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=y.inspectBytes(t),n=r.size-r.multihashSize,o=ee(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),u=new te(r.multihashCode,r.digestSize,i,o);return[r.version===0?y.createV0(u):y.createV1(r.codec,u),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[G,le]=ue(t.subarray(r));return r+=le,G},o=n(),i=fe;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let u=r,d=n(),p=n(),b=r+p,h=b-u;return{version:o,codec:i,multihashCode:d,digestSize:p,multihashSize:h,size:b}}static parse(t,r){let[n,o]=yn(t,r),i=y.decode(o);return Re(i).set(n,t),i}},yn=(e,t)=>{switch(e[0]){case"Q":{let r=t||V;return[V.prefix,r.decode(`${V.prefix}${e}`)]}case V.prefix:{let r=t||V;return[V.prefix,r.decode(e)]}case de.prefix:{let r=t||de;return[de.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},gn=(e,t,r)=>{let{prefix:n}=r;if(n!==V.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o},wn=(e,t,r)=>{let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o},fe=112,bn=18,or=(e,t,r)=>{let n=Y(e),o=n+Y(t),i=new Uint8Array(o+r.byteLength);return Z(e,i,0),Z(t,i,n),i.set(r,o),i},xn=Symbol.for("@ipld/js-cid/CID");var ir=42;function En(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=y.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new a(s.tag,ir),new a(s.bytes,r)]}function vn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Un(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var An={float64:!0,typeEncoders:{Object:En,undefined:vn,number:Un}};function Tn(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return y.decode(e.subarray(1))}var sr={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};sr.tags[ir]=Tn;var kn="dag-cbor",Sn=113,Bn=e=>$e(e,An),_n=e=>Me(e,sr);return pr(Nn);})();
"use strict";var IpldDagCbor=(()=>{var Ae=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var dr=Object.getOwnPropertyNames;var fr=Object.prototype.hasOwnProperty;var lr=(e,t)=>{for(var r in t)Ae(e,r,{get:t[r],enumerable:!0})},pr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of dr(t))!fr.call(e,o)&&o!==r&&Ae(e,o,{get:()=>t[o],enumerable:!(n=ur(t,o))||n.enumerable});return e};var hr=e=>pr(Ae({},"__esModule",{value:!0}),e);var _n={};lr(_n,{code:()=>Sn,decode:()=>Nn,encode:()=>Bn,name:()=>kn});var mr=["string","number","bigint","symbol"],yr=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Pe(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(mr.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(gr(e))return"Buffer";let r=wr(e);return r||"Object"}function gr(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function wr(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(yr.includes(t))return t}var s=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(7,"break",!0);var a=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var J=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",br=new TextDecoder,xr=new TextEncoder;function he(e){return J&&globalThis.Buffer.isBuffer(e)}function Te(e){return e instanceof Uint8Array?he(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Je=J?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):qe(e,t,r):(e,t,r)=>r-t>64?br.decode(e.subarray(t,r)):qe(e,t,r),Xe=J?e=>e.length>64?globalThis.Buffer.from(e):je(e):e=>e.length>64?xr.encode(e):je(e),z=e=>Uint8Array.from(e),X=J?(e,t,r)=>he(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),He=J?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Te(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Ke=J?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function We(e,t){if(he(e)&&he(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function je(e,t=1/0){let r,n=e.length,o=null,i=[];for(let u=0;u<n;++u){if(r=e.charCodeAt(u),r>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}else if(u+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return i}function qe(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,u=o>239?4:o>223?3:o>191?2:1;if(t+u<=r){let d,p,b,h;switch(u){case 1:o<128&&(i=o);break;case 2:d=e[t+1],(d&192)===128&&(h=(o&31)<<6|d&63,h>127&&(i=h));break;case 3:d=e[t+1],p=e[t+2],(d&192)===128&&(p&192)===128&&(h=(o&15)<<12|(d&63)<<6|p&63,h>2047&&(h<55296||h>57343)&&(i=h));break;case 4:d=e[t+1],p=e[t+2],b=e[t+3],(d&192)===128&&(p&192)===128&&(b&192)===128&&(h=(o&15)<<18|(d&63)<<12|(p&63)<<6|b&63,h>65535&&h<1114112&&(i=h))}}i===null?(i=65533,u=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=u}return Er(n)}var Ge=4096;function Er(e){let t=e.length;if(t<=Ge)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Ge));return r}var Ur=256,re=class{constructor(t=Ur){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Ke(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=X(n,0,this.cursor)}else r=He(this.chunks,this.cursor);return t&&this.reset(),r}};var f="CBOR decode error:",ke="CBOR encode error:",ne=[];ne[23]=1;ne[24]=2;ne[25]=3;ne[26]=5;ne[27]=9;function D(e,t,r){if(e.length-t<r)throw new Error(`${f} not enough data for type`)}var g=[24,256,65536,4294967296,BigInt("18446744073709551616")];function E(e,t,r){D(e,t,1);let n=e[t];if(r.strict===!0&&n<g[0])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function U(e,t,r){D(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<g[1])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){D(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<g[2])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){D(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<g[3])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${f} integers outside of the safe integer range are not supported`)}function Qe(e,t,r,n){return new a(s.uint,E(e,t+1,n),2)}function Ze(e,t,r,n){return new a(s.uint,U(e,t+1,n),3)}function Ye(e,t,r,n){return new a(s.uint,v(e,t+1,n),5)}function et(e,t,r,n){return new a(s.uint,A(e,t+1,n),9)}function k(e,t){return w(e,0,t.value)}function w(e,t,r){if(r<g[0]){let n=Number(r);e.push([t|n])}else if(r<g[1]){let n=Number(r);e.push([t|24,n])}else if(r<g[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<g[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<g[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),u=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=u&255,u=u>>8,o[3]=u&255,u=u>>8,o[2]=u&255,u=u>>8,o[1]=u&255,e.push(o)}else throw new Error(`${f} encountered BigInt larger than allowable range`)}}k.encodedSize=function(t){return w.encodedSize(t.value)};w.encodedSize=function(t){return t<g[0]?1:t<g[1]?2:t<g[2]?3:t<g[3]?5:9};k.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function tt(e,t,r,n){return new a(s.negint,-1-E(e,t+1,n),2)}function rt(e,t,r,n){return new a(s.negint,-1-U(e,t+1,n),3)}function nt(e,t,r,n){return new a(s.negint,-1-v(e,t+1,n),5)}var Se=BigInt(-1),ot=BigInt(1);function it(e,t,r,n){let o=A(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new a(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${f} integers outside of the safe integer range are not supported`);return new a(s.negint,Se-BigInt(o),9)}function me(e,t){let r=t.value,n=typeof r=="bigint"?r*Se-ot:r*-1-1;w(e,t.type.majorEncoded,n)}me.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Se-ot:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};me.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function oe(e,t,r,n){D(e,t,r+n);let o=X(e,t+r,t+r+n);return new a(s.bytes,o,r+n)}function st(e,t,r,n){return oe(e,t,1,r)}function ct(e,t,r,n){return oe(e,t,2,E(e,t+1,n))}function at(e,t,r,n){return oe(e,t,3,U(e,t+1,n))}function ut(e,t,r,n){return oe(e,t,5,v(e,t+1,n))}function dt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer bytes lengths not supported`);return oe(e,t,9,o)}function ye(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?Xe(e.value):e.value),e.encodedBytes}function H(e,t){let r=ye(t);w(e,t.type.majorEncoded,r.length),e.push(r)}H.encodedSize=function(t){let r=ye(t);return w.encodedSize(r.length)+r.length};H.compareTokens=function(t,r){return Ar(ye(t),ye(r))};function Ar(e,t){return e.length<t.length?-1:e.length>t.length?1:We(e,t)}function ie(e,t,r,n,o){let i=r+n;D(e,t,i);let u=new a(s.string,Je(e,t+r,t+i),i);return o.retainStringBytes===!0&&(u.byteValue=X(e,t+r,t+i)),u}function ft(e,t,r,n){return ie(e,t,1,r,n)}function lt(e,t,r,n){return ie(e,t,2,E(e,t+1,n),n)}function pt(e,t,r,n){return ie(e,t,3,U(e,t+1,n),n)}function ht(e,t,r,n){return ie(e,t,5,v(e,t+1,n),n)}function mt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer string lengths not supported`);return ie(e,t,9,o,n)}var yt=H;function K(e,t,r,n){return new a(s.array,n,r)}function gt(e,t,r,n){return K(e,t,1,r)}function wt(e,t,r,n){return K(e,t,2,E(e,t+1,n))}function bt(e,t,r,n){return K(e,t,3,U(e,t+1,n))}function xt(e,t,r,n){return K(e,t,5,v(e,t+1,n))}function Et(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer array lengths not supported`);return K(e,t,9,o)}function Ut(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return K(e,t,1,1/0)}function ge(e,t){w(e,s.array.majorEncoded,t.value)}ge.compareTokens=k.compareTokens;ge.encodedSize=function(t){return w.encodedSize(t.value)};function W(e,t,r,n){return new a(s.map,n,r)}function vt(e,t,r,n){return W(e,t,1,r)}function At(e,t,r,n){return W(e,t,2,E(e,t+1,n))}function Tt(e,t,r,n){return W(e,t,3,U(e,t+1,n))}function kt(e,t,r,n){return W(e,t,5,v(e,t+1,n))}function St(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer map lengths not supported`);return W(e,t,9,o)}function Bt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return W(e,t,1,1/0)}function we(e,t){w(e,s.map.majorEncoded,t.value)}we.compareTokens=k.compareTokens;we.encodedSize=function(t){return w.encodedSize(t.value)};function Nt(e,t,r,n){return new a(s.tag,r,1)}function _t(e,t,r,n){return new a(s.tag,E(e,t+1,n),2)}function It(e,t,r,n){return new a(s.tag,U(e,t+1,n),3)}function $t(e,t,r,n){return new a(s.tag,v(e,t+1,n),5)}function Ct(e,t,r,n){return new a(s.tag,A(e,t+1,n),9)}function be(e,t){w(e,s.tag.majorEncoded,t.value)}be.compareTokens=k.compareTokens;be.encodedSize=function(t){return w.encodedSize(t.value)};var _r=20,Ir=21,$r=22,Cr=23;function Mt(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${f} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new a(s.null,null,1):new a(s.undefined,void 0,1)}function zt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return new a(s.break,void 0,1)}function Be(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${f} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${f} Infinity values are not supported`)}return new a(s.float,e,t)}function Ot(e,t,r,n){return Be(Ne(e,t+1),3,n)}function Ft(e,t,r,n){return Be(_e(e,t+1),5,n)}function Dt(e,t,r,n){return Be(Pt(e,t+1),9,n)}function xe(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|_r]);else if(n===!0)e.push([s.float.majorEncoded|Ir]);else if(n===null)e.push([s.float.majorEncoded|$r]);else if(n===void 0)e.push([s.float.majorEncoded|Cr]);else{let o,i=!1;(!r||r.float64!==!0)&&(Lt(n),o=Ne(_,1),n===o||Number.isNaN(n)?(_[0]=249,e.push(_.slice(0,3)),i=!0):(Rt(n),o=_e(_,1),n===o&&(_[0]=250,e.push(_.slice(0,5)),i=!0))),i||(Mr(n),o=Pt(_,1),_[0]=251,e.push(_.slice(0,9)))}}xe.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Lt(n);let o=Ne(_,1);if(n===o||Number.isNaN(n))return 3;if(Rt(n),o=_e(_,1),n===o)return 5}return 9};var Vt=new ArrayBuffer(9),S=new DataView(Vt,1),_=new Uint8Array(Vt,0);function Lt(e){if(e===1/0)S.setUint16(0,31744,!1);else if(e===-1/0)S.setUint16(0,64512,!1);else if(Number.isNaN(e))S.setUint16(0,32256,!1);else{S.setFloat32(0,e);let t=S.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)S.setUint16(0,31744,!1);else if(r===0)S.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?S.setUint16(0,0):o<-14?S.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):S.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ne(e,t){if(e.length-t<2)throw new Error(`${f} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Rt(e){S.setFloat32(0,e,!1)}function _e(e,t){if(e.length-t<4)throw new Error(`${f} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Mr(e){S.setFloat64(0,e,!1)}function Pt(e,t){if(e.length-t<8)throw new Error(`${f} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}xe.compareTokens=k.compareTokens;function l(e,t,r){throw new Error(`${f} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Ee(e){return()=>{throw new Error(`${f} ${e}`)}}var c=[];for(let e=0;e<=23;e++)c[e]=l;c[24]=Qe;c[25]=Ze;c[26]=Ye;c[27]=et;c[28]=l;c[29]=l;c[30]=l;c[31]=l;for(let e=32;e<=55;e++)c[e]=l;c[56]=tt;c[57]=rt;c[58]=nt;c[59]=it;c[60]=l;c[61]=l;c[62]=l;c[63]=l;for(let e=64;e<=87;e++)c[e]=st;c[88]=ct;c[89]=at;c[90]=ut;c[91]=dt;c[92]=l;c[93]=l;c[94]=l;c[95]=Ee("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)c[e]=ft;c[120]=lt;c[121]=pt;c[122]=ht;c[123]=mt;c[124]=l;c[125]=l;c[126]=l;c[127]=Ee("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)c[e]=gt;c[152]=wt;c[153]=bt;c[154]=xt;c[155]=Et;c[156]=l;c[157]=l;c[158]=l;c[159]=Ut;for(let e=160;e<=183;e++)c[e]=vt;c[184]=At;c[185]=Tt;c[186]=kt;c[187]=St;c[188]=l;c[189]=l;c[190]=l;c[191]=Bt;for(let e=192;e<=215;e++)c[e]=Nt;c[216]=_t;c[217]=It;c[218]=$t;c[219]=Ct;c[220]=l;c[221]=l;c[222]=l;c[223]=l;for(let e=224;e<=243;e++)c[e]=Ee("simple values are not supported");c[244]=l;c[245]=l;c[246]=l;c[247]=Mt;c[248]=Ee("simple values are not supported");c[249]=Ot;c[250]=Ft;c[251]=Dt;c[252]=l;c[253]=l;c[254]=l;c[255]=zt;var I=[];for(let e=0;e<24;e++)I[e]=new a(s.uint,e,1);for(let e=-1;e>=-24;e--)I[31-e]=new a(s.negint,e,1);I[64]=new a(s.bytes,new Uint8Array(0),1);I[96]=new a(s.string,"",1);I[128]=new a(s.array,0,1);I[160]=new a(s.map,0,1);I[244]=new a(s.false,!1,1);I[245]=new a(s.true,!0,1);I[246]=new a(s.null,null,1);function jt(e){switch(e.type){case s.false:return z([244]);case s.true:return z([245]);case s.null:return z([246]);case s.bytes:return e.value.length?void 0:z([64]);case s.string:return e.value===""?z([96]):void 0;case s.array:return e.value===0?z([128]):void 0;case s.map:return e.value===0?z([160]):void 0;case s.uint:return e.value<24?z([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return z([31-Number(e.value)])}}var Or={float64:!1,mapSorter:Vr,quickEncodeToken:jt};function Fr(){let e=[];return e[s.uint.major]=k,e[s.negint.major]=me,e[s.bytes.major]=H,e[s.string.major]=yt,e[s.array.major]=ge,e[s.map.major]=we,e[s.tag.major]=be,e[s.float.major]=xe,e}var qt=Fr(),Ie=new re,Q=class{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${ke} object contains circular references`);return new Q(r,t)}},R={null:new a(s.null,null),undefined:new a(s.undefined,void 0),true:new a(s.true,!0),false:new a(s.false,!1),emptyArray:new a(s.array,0),emptyMap:new a(s.map,0)},P={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new a(s.float,e):e>=0?new a(s.uint,e):new a(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new a(s.uint,e):new a(s.negint,e)},Uint8Array(e,t,r,n){return new a(s.bytes,e)},string(e,t,r,n){return new a(s.string,e)},boolean(e,t,r,n){return e?R.true:R.false},null(e,t,r,n){return R.null},undefined(e,t,r,n){return R.undefined},ArrayBuffer(e,t,r,n){return new a(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new a(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[R.emptyArray,new a(s.break)]:R.emptyArray;n=Q.createCheck(n,e);let o=[],i=0;for(let u of e)o[i++]=Ue(u,r,n);return r.addBreakTokens?[new a(s.array,e.length),o,new a(s.break)]:[new a(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),u=o?e.size:i.length;if(!u)return r.addBreakTokens===!0?[R.emptyMap,new a(s.break)]:R.emptyMap;n=Q.createCheck(n,e);let d=[],p=0;for(let b of i)d[p++]=[Ue(b,r,n),Ue(o?e.get(b):e[b],r,n)];return Dr(d,r),r.addBreakTokens?[new a(s.map,u),d,new a(s.break)]:[new a(s.map,u),d]}};P.Map=P.Object;P.Buffer=P.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))P[`${e}Array`]=P.DataView;function Ue(e,t={},r){let n=Pe(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||P[n];if(typeof o=="function"){let u=o(e,n,t,r);if(u!=null)return u}let i=P[n];if(!i)throw new Error(`${ke} unsupported type: ${n}`);return i(e,n,t,r)}function Dr(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Vr(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=qt[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Gt(e,t,r,n){if(Array.isArray(t))for(let o of t)Gt(e,o,r,n);else r[t.type.major](e,t,n)}function Lr(e,t,r){let n=Ue(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let u=i.encodedSize(n,r),d=new re(u);if(i(d,n,r),d.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Te(d.chunks[0])}}return Ie.reset(),Gt(Ie,n,t,r),Ie.toBytes(!0)}function $e(e,t){return t=Object.assign({},Or,t),Lr(e,qt,t)}var Rr={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ce=class{constructor(t,r={}){this.pos=0,this.data=t,this.options=r}done(){return this.pos>=this.data.length}next(){let t=this.data[this.pos],r=I[t];if(r===void 0){let n=c[t];if(!n)throw new Error(`${f} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this.pos,o,this.options)}return this.pos+=r.encodedLength,r}},se=Symbol.for("DONE"),ve=Symbol.for("BREAK");function Pr(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=ce(t,r);if(i===ve){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed array`)}if(i===se)throw new Error(`${f} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function jr(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let u=0;u<e.value;u++){let d=ce(t,r);if(d===ve){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(d===se)throw new Error(`${f} found map but not enough entries (got ${u} [no key], expected ${e.value})`);if(n!==!0&&typeof d!="string")throw new Error(`${f} non-string keys not supported (got ${typeof d})`);let p=ce(t,r);if(p===se)throw new Error(`${f} found map but not enough entries (got ${u} [no value], expected ${e.value})`);n?i.set(d,p):o[d]=p}return n?i:o}function ce(e,t){if(e.done())return se;let r=e.next();if(r.type===s.break)return ve;if(r.type.terminal)return r.value;if(r.type===s.array)return Pr(r,e,t);if(r.type===s.map)return jr(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=ce(e,t);return t.tags[r.value](n)}throw new Error(`${f} tag not supported (${r.value})`)}throw new Error("unsupported")}function Me(e,t){if(!(e instanceof Uint8Array))throw new Error(`${f} data to decode must be a Uint8Array`);t=Object.assign({},Rr,t);let r=t.tokenizer||new Ce(e,t),n=ce(r,t);if(n===se)throw new Error(`${f} did not find any content to decode`);if(n===ve)throw new Error(`${f} got unexpected break`);if(!r.done())throw new Error(`${f} too many terminals, data makes no sense`);return n}var Gr=Ht,Jt=128,Jr=127,Xr=~Jr,Hr=Math.pow(2,31);function Ht(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Hr;)t[r++]=e&255|Jt,e/=128;for(;e&Xr;)t[r++]=e&255|Jt,e>>>=7;return t[r]=e|0,Ht.bytes=r-n+1,t}var Kr=ze,Wr=128,Xt=127;function ze(e,n){var r=0,n=n||0,o=0,i=n,u,d=e.length;do{if(i>=d)throw ze.bytes=0,new RangeError("Could not decode varint");u=e[i++],r+=o<28?(u&Xt)<<o:(u&Xt)*Math.pow(2,o),o+=7}while(u>=Wr);return ze.bytes=i-n,r}var Qr=Math.pow(2,7),Zr=Math.pow(2,14),Yr=Math.pow(2,21),en=Math.pow(2,28),tn=Math.pow(2,35),rn=Math.pow(2,42),nn=Math.pow(2,49),on=Math.pow(2,56),sn=Math.pow(2,63),cn=function(e){return e<Qr?1:e<Zr?2:e<Yr?3:e<en?4:e<tn?5:e<rn?6:e<nn?7:e<on?8:e<sn?9:10},an={encode:Gr,decode:Kr,encodingLength:cn},un=an,ae=un;var ue=(e,t=0)=>[ae.decode(e,t),ae.decode.bytes],Z=(e,t,r=0)=>(ae.encode(e,t,r),t),Y=e=>ae.encodingLength(e);var $o=new Uint8Array(0);var Wt=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},ee=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var Qt=(e,t)=>{let r=t.byteLength,n=Y(e),o=n+Y(r),i=new Uint8Array(o+r);return Z(e,i,0),Z(r,i,n),i.set(t,o),new te(e,r,t,i)},Zt=e=>{let t=ee(e),[r,n]=ue(t),[o,i]=ue(t.subarray(n)),u=t.subarray(n+i);if(u.byteLength!==o)throw new Error("Incorrect length");return new te(r,o,u,t)},Yt=(e,t)=>{if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Wt(e.bytes,r.bytes)}},te=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function fn(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),u=i.charCodeAt(0);if(r[u]!==255)throw new TypeError(i+" is ambiguous");r[u]=o}var d=e.length,p=e.charAt(0),b=Math.log(d)/Math.log(256),h=Math.log(256)/Math.log(d);function G(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var x=0,j=0,B=0,$=m.length;B!==$&&m[B]===0;)B++,x++;for(var C=($-B)*h+1>>>0,T=new Uint8Array(C);B!==$;){for(var M=m[B],L=0,N=C-1;(M!==0||L<j)&&N!==-1;N--,L++)M+=256*T[N]>>>0,T[N]=M%d>>>0,M=M/d>>>0;if(M!==0)throw new Error("Non-zero carry");j=L,B++}for(var F=C-j;F!==C&&T[F]===0;)F++;for(var pe=p.repeat(x);F<C;++F)pe+=e.charAt(T[F]);return pe}function le(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var x=0;if(m[x]!==" "){for(var j=0,B=0;m[x]===p;)j++,x++;for(var $=(m.length-x)*b+1>>>0,C=new Uint8Array($);m[x];){var T=r[m.charCodeAt(x)];if(T===255)return;for(var M=0,L=$-1;(T!==0||M<B)&&L!==-1;L--,M++)T+=d*C[L]>>>0,C[L]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");B=M,x++}if(m[x]!==" "){for(var N=$-B;N!==$&&C[N]===0;)N++;for(var F=new Uint8Array(j+($-N)),pe=j;N!==$;)F[pe++]=C[N++];return F}}}function ar(m){var x=le(m);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:G,decodeUnsafe:le,decode:ar}}var ln=fn,pn=ln,er=pn;var Oe=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Fe=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return tr(this,t)}},De=class{constructor(t){this.decoders=t}or(t){return tr(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},tr=(e,t)=>new De({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),Ve=class{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Oe(t,r,n),this.decoder=new Fe(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},rr=({name:e,prefix:t,encode:r,decode:n})=>new Ve(e,t,r,n),Le=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=er(r,t);return rr({prefix:e,name:t,encode:n,decode:i=>ee(o(i))})},hn=(e,t,r,n)=>{let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let i=e.length;for(;e[i-1]==="=";)--i;let u=new Uint8Array(i*r/8|0),d=0,p=0,b=0;for(let h=0;h<i;++h){let G=o[e[h]];if(G===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|G,d+=r,d>=8&&(d-=8,u[b++]=255&p>>d)}if(d>=r||255&p<<8-d)throw new SyntaxError("Unexpected end of data");return u},mn=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,i="",u=0,d=0;for(let p=0;p<e.length;++p)for(d=d<<8|e[p],u+=8;u>r;)u-=r,i+=t[o&d>>u];if(u&&(i+=t[o&d<<r-u]),n)for(;i.length*r&7;)i+="=";return i},O=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>rr({prefix:t,name:e,encode(o){return mn(o,n,r)},decode(o){return hn(o,n,r,e)}});var V=Le({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lo=Le({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var de=O({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jo=O({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qo=O({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Go=O({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jo=O({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xo=O({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ho=O({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ko=O({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wo=O({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var nr=(e,t)=>{let{bytes:r,version:n}=e;switch(n){case 0:return gn(r,Re(e),t||V.encoder);default:return wn(r,Re(e),t||de.encoder)}};var or=new WeakMap,Re=e=>{let t=or.get(e);if(t==null){let r=new Map;return or.set(e,r),r}return t},y=class{constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==fe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==bn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Qt(t,r);return y.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return y.equals(this,t)}static equals(t,r){let n=r;return n&&t.code===n.code&&t.version===n.version&&Yt(t.multihash,n.multihash)}toString(t){return nr(this,t)}toJSON(){return{"/":nr(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof y)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:u}=r;return new y(n,o,i,u||ir(n,o,i.bytes))}else if(r[xn]===!0){let{version:n,multihash:o,code:i}=r,u=Zt(o);return y.create(n,i,u)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==fe)throw new Error(`Version 0 CID must use dag-pb (code: ${fe}) block encoding`);return new y(t,r,n,n.bytes)}case 1:{let o=ir(t,r,n.bytes);return new y(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return y.create(0,fe,t)}static createV1(t,r){return y.create(1,t,r)}static decode(t){let[r,n]=y.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=y.inspectBytes(t),n=r.size-r.multihashSize,o=ee(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),u=new te(r.multihashCode,r.digestSize,i,o);return[r.version===0?y.createV0(u):y.createV1(r.codec,u),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[G,le]=ue(t.subarray(r));return r+=le,G},o=n(),i=fe;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let u=r,d=n(),p=n(),b=r+p,h=b-u;return{version:o,codec:i,multihashCode:d,digestSize:p,multihashSize:h,size:b}}static parse(t,r){let[n,o]=yn(t,r),i=y.decode(o);return Re(i).set(n,t),i}},yn=(e,t)=>{switch(e[0]){case"Q":{let r=t||V;return[V.prefix,r.decode(`${V.prefix}${e}`)]}case V.prefix:{let r=t||V;return[V.prefix,r.decode(e)]}case de.prefix:{let r=t||de;return[de.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},gn=(e,t,r)=>{let{prefix:n}=r;if(n!==V.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o},wn=(e,t,r)=>{let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o},fe=112,bn=18,ir=(e,t,r)=>{let n=Y(e),o=n+Y(t),i=new Uint8Array(o+r.byteLength);return Z(e,i,0),Z(t,i,n),i.set(r,o),i},xn=Symbol.for("@ipld/js-cid/CID");var sr=42;function En(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=y.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new a(s.tag,sr),new a(s.bytes,r)]}function Un(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function vn(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var An={float64:!0,typeEncoders:{Object:En,undefined:Un,number:vn}};function Tn(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return y.decode(e.subarray(1))}var cr={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};cr.tags[sr]=Tn;var kn="dag-cbor",Sn=113,Bn=e=>$e(e,An),Nn=e=>Me(e,cr);return hr(_n);})();
return IpldDagCbor}));
{
"name": "@ipld/dag-cbor",
"version": "8.0.0",
"version": "8.0.1",
"description": "JS implementation of DAG-CBOR",

@@ -165,3 +165,3 @@ "author": "Rod <rod@vagg.org> (http://r.va.gg/)",

"cborg": "^1.6.0",
"multiformats": "^10.0.2"
"multiformats": "^11.0.0"
},

@@ -168,0 +168,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc