29 lines
136 KiB
JavaScript
29 lines
136 KiB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Ipns = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
"use strict";var Ipns=(()=>{var Hc=Object.create;var Or=Object.defineProperty;var zc=Object.getOwnPropertyDescriptor;var Zc=Object.getOwnPropertyNames;var jc=Object.getPrototypeOf,Yc=Object.prototype.hasOwnProperty;var Gc=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),mt=(e,t)=>{for(var r in t)Or(e,r,{get:t[r],enumerable:!0})},Ei=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zc(t))!Yc.call(e,o)&&o!==r&&Or(e,o,{get:()=>t[o],enumerable:!(n=zc(t,o))||n.enumerable});return e};var Xc=(e,t,r)=>(r=e!=null?Hc(jc(e)):{},Ei(t||!e||!e.__esModule?Or(r,"default",{value:e,enumerable:!0}):r,e)),Wc=e=>Ei(Or({},"__esModule",{value:!0}),e);var va=Gc((my,ni)=>{var py=(function(){typeof ni<"u"&&(ni.exports=C);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(p){var m=p-p%1;return m==0&&(p<0||p===0&&1/p!=1/0)?-0:m},u=C.prototype,l=(C.fromDate=function(p){return new C(+p)},C.fromInt64BE=k(0,1,2,3,0,4),C.fromInt64LE=k(3,2,1,0,4,0),C.fromString=function(U){var m,_=new C,U=(U+="").replace(/^\s*[+\-]?\d+/,function(y){var y=+y,g=1970+(y-1970)%400;return _.year=y-g,g}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(A,y,g){return y<0&&(g*=-1),m=6e4*(60*+y+ +g),""}).replace(/\.\d+$/,function(A){return _.nano=+(A+c).substr(1,9),""}).split(/\D+/);if(1<U.length?U[1]--:U[1]=0,_.time=m=Date.UTC.apply(Date,U)-(m||0),isNaN(m))throw new TypeError("Invalid Date");return v(_)},C.fromTimeT=function(p){return T(p,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(p){return this.nano+=+p||0,this},u.getNano=function(){var p=v(this);return(p.time%1e3*a+ +p.nano+1e9)%1e9},u.getTimeT=function(){var m=v(this),p=Math.floor(m.time/1e3),m=m.year;return m&&(p+=m*r*e/t),p},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return x(v(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(p){var m=this,_=m.toDate(),U={H:function(){return F(_.getUTCHours())},L:function(){return P(_.getUTCMilliseconds(),3)},M:function(){return F(_.getUTCMinutes())},N:function(){return P(m.getNano(),9)},S:function(){return F(_.getUTCSeconds())},Y:function(){var A=m.getYear();return 999999<A?"+"+A:9999<A?"+"+P(A,6):0<=A?P(A,4):-999999<=A?"-"+P(-A,6):A},a:function(){return B[_.getUTCDay()]},b:function(){return w[_.getUTCMonth()]},d:function(){return F(_.getUTCDate())},e:function(){return(function(A){return(9<A?"":" ")+(0|A)})(_.getUTCDate())},m:function(){return F(_.getUTCMonth()+1)}};return(function A(y){return y.replace(/%./g,function(g){var E=g[1],h=b[E],E=U[E];return h?A(h):E?E():g})})(p||l)},u.writeInt64BE=S(0,1,2,3,0,4),u.writeInt64LE=S(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],b={"%":"%",F:"%Y-%m-%d",n:`
|
|
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return C;function C(p,m,_){var U=this;if(!(U instanceof C))return new C(p,m,_);U.time=+p||0,U.nano=+m||0,U.year=+_||0,v(U)}function v(p){var m,_,U,A=p.year,y=p.time,g=p.nano,h=((g<0||a<=g)&&(g-=(_=Math.floor(g/a))*a,y+=_,_=1),A%t);return(y<-i||i<y||h)&&((m=f(y/o))&&(A+=m*t,y-=m*o),(U=x(y)).setUTCFullYear(h+U.getUTCFullYear()),U=(y=+U)+(m=f((A-=h)/t))*o,m&&-i<=U&&U<=i&&(A-=m*t,y=U),_=1),_&&(p.year=A,p.time=y,p.nano=g),p}function x(p){var m=new Date(0);return m.setTime(p),m}function T(A,U){A=+A||0;var _=f((U=(U|0)*s)/n)+f(A/n),U=U%n+A%n,A=f(U/n);return A&&(_+=A,U-=A*n),new C(1e3*U,0,_*t)}function S(p,m,_,U,A,y){return function(h,E){var R=v(this);h=h||new Array(8),O(h,E|=0);var N=Math.floor(R.time/1e3),R=R.year*(r*e/t),L=f(R/s)+f(N/s),R=R%s+N%s,N=Math.floor(R/s);return N&&(L+=N,R-=N*s),g(h,E+A,L),g(h,E+y,R),h};function g(h,E,L){h[E+p]=L>>24&255,h[E+m]=L>>16&255,h[E+_]=L>>8&255,h[E+U]=255&L}}function k(p,m,_,U,A,y){return function(h,E){O(h,E|=0);var L=g(h,E+A);return T(g(h,E+y),L)};function g(h,E){return 16777216*h[E+p]+(h[E+m]<<16|h[E+_]<<8|h[E+U])}}function O(p,m){if(p=p&&p.length,p==null)throw new TypeError("Invalid Buffer");if(p<m+8)throw new RangeError("Out of range")}function F(p){return(9<p?"":"0")+(0|p)}function P(p,m){return(c+(0|p)).substr(-m)}})()});var Dd={};mt(Dd,{createIPNSRecord:()=>Id,createIPNSRecordWithExpiration:()=>_d,extractPublicKeyFromIPNSRecord:()=>Lc,marshalIPNSRecord:()=>Nc,multihashFromIPNSRoutingKey:()=>Mc,multihashToIPNSRoutingKey:()=>Oc,namespace:()=>$c,namespaceLength:()=>Td,unmarshalIPNSRecord:()=>Kc});var ot=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},_e=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Mr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Vr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Rn={};mt(Rn,{base58btc:()=>rt,base58flickr:()=>ou});var kd=new Uint8Array(0);function Si(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}function Ft(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")}function Ai(e){return new TextEncoder().encode(e)}function vi(e){return new TextDecoder().decode(e)}function Jc(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),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var C=0,v=0,x=0,T=b.length;x!==T&&b[x]===0;)x++,C++;for(var S=(T-x)*u+1>>>0,k=new Uint8Array(S);x!==T;){for(var O=b[x],F=0,P=S-1;(O!==0||F<v)&&P!==-1;P--,F++)O+=256*k[P]>>>0,k[P]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");v=F,x++}for(var p=S-v;p!==S&&k[p]===0;)p++;for(var m=c.repeat(C);p<S;++p)m+=e.charAt(k[p]);return m}function w(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var C=0;if(b[C]!==" "){for(var v=0,x=0;b[C]===c;)v++,C++;for(var T=(b.length-C)*f+1>>>0,S=new Uint8Array(T);b[C];){var k=r[b.charCodeAt(C)];if(k===255)return;for(var O=0,F=T-1;(k!==0||O<x)&&F!==-1;F--,O++)k+=a*S[F]>>>0,S[F]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");x=O,C++}if(b[C]!==" "){for(var P=T-x;P!==T&&S[P]===0;)P++;for(var p=new Uint8Array(v+(T-P)),m=v;P!==T;)p[m++]=S[P++];return p}}}function B(b){var C=w(b);if(C)return C;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:w,decode:B}}var Qc=Jc,tu=Qc,Ci=tu;var _n=class{name;prefix;baseEncode;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")}},Un=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 Ti(this,t)}},Dn=class{decoders;constructor(t){this.decoders=t}or(t){return Ti(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ti(e,t){return new Dn({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Ln=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new _n(t,r,n),this.decoder=new Un(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ue({name:e,prefix:t,encode:r,decode:n}){return new Ln(e,t,r,n)}function te({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ci(r,e);return Ue({prefix:t,name:e,encode:n,decode:i=>Ft(o(i))})}function eu(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let f=0;f<o;++f){let u=t[e[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function ru(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function nu(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function Q({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=nu(n);return Ue({prefix:t,name:e,encode(i){return ru(i,n,r)},decode(i){return eu(i,o,r,e)}})}var rt=te({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ou=te({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kn={};mt(kn,{base32:()=>ee,base32hex:()=>cu,base32hexpad:()=>fu,base32hexpadupper:()=>lu,base32hexupper:()=>uu,base32pad:()=>su,base32padupper:()=>au,base32upper:()=>iu,base32z:()=>du});var ee=Q({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),iu=Q({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),su=Q({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),au=Q({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),cu=Q({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),uu=Q({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),fu=Q({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),lu=Q({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),du=Q({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Nn={};mt(Nn,{base36:()=>re,base36upper:()=>hu});var re=te({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hu=te({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var pu=Ui,Ii=128,mu=127,yu=~mu,gu=Math.pow(2,31);function Ui(e,t,r){t=t||[],r=r||0;for(var n=r;e>=gu;)t[r++]=e&255|Ii,e/=128;for(;e&yu;)t[r++]=e&255|Ii,e>>>=7;return t[r]=e|0,Ui.bytes=r-n+1,t}var bu=Kn,xu=128,_i=127;function Kn(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw Kn.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&_i)<<o:(s&_i)*Math.pow(2,o),o+=7}while(s>=xu);return Kn.bytes=i-n,r}var wu=Math.pow(2,7),Eu=Math.pow(2,14),Su=Math.pow(2,21),Au=Math.pow(2,28),vu=Math.pow(2,35),Bu=Math.pow(2,42),Cu=Math.pow(2,49),Tu=Math.pow(2,56),Iu=Math.pow(2,63),_u=function(e){return e<wu?1:e<Eu?2:e<Su?3:e<Au?4:e<vu?5:e<Bu?6:e<Cu?7:e<Tu?8:e<Iu?9:10},Uu={encode:pu,decode:bu,encodingLength:_u},Du=Uu,nr=Du;function or(e,t=0){return[nr.decode(e,t),nr.decode.bytes]}function De(e,t,r=0){return nr.encode(e,t,r),t}function Le(e){return nr.encodingLength(e)}function Kt(e,t){let r=t.byteLength,n=Le(e),o=n+Le(r),i=new Uint8Array(o+r);return De(e,i,0),De(r,i,n),i.set(t,o),new Re(e,r,t,i)}function Fr(e){let t=Ft(e),[r,n]=or(t),[o,i]=or(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Re(r,o,s,t)}function Di(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Si(e.bytes,r.bytes)}}var Re=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Li(e,t){let{bytes:r,version:n}=e;return n===0?Ru(r,On(e),t??rt.encoder):ku(r,On(e),t??ee.encoder)}var Ri=new WeakMap;function On(e){let t=Ri.get(e);if(t==null){let r=new Map;return Ri.set(e,r),r}return t}var ut=class e{code;version;multihash;bytes;"/";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!==ir)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Nu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.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=Kt(t,r);return e.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 e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Di(t.multihash,n.multihash)}toString(t){return Li(this,t)}toJSON(){return{"/":Li(this)}}link(){return this}[Symbol.toStringTag]="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 e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??ki(n,o,i.bytes))}else if(r[Ku]===!0){let{version:n,multihash:o,code:i}=r,s=Fr(o);return e.create(n,i,s)}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!==ir)throw new Error(`Version 0 CID must use dag-pb (code: ${ir}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ki(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ir,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Ft(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Re(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,w]=or(t.subarray(r));return r+=w,l},o=n(),i=ir;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),f=r+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,r){let[n,o]=Lu(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return On(i).set(n,t),i}};function Lu(e,t){switch(e[0]){case"Q":{let r=t??rt;return[rt.prefix,r.decode(`${rt.prefix}${e}`)]}case rt.prefix:{let r=t??rt;return[rt.prefix,r.decode(e)]}case ee.prefix:{let r=t??ee;return[ee.prefix,r.decode(e)]}case re.prefix:{let r=t??re;return[re.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Ru(e,t,r){let{prefix:n}=r;if(n!==rt.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}function ku(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}var ir=112,Nu=18;function ki(e,t,r){let n=Le(e),o=n+Le(t),i=new Uint8Array(o+r.byteLength);return De(e,i,0),De(t,i,n),i.set(r,o),i}var Ku=Symbol.for("@ipld/js-cid/CID");var Mn={};mt(Mn,{identity:()=>ge});var Ni=0,Ou="identity",Ki=Ft;function Mu(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return Kt(Ni,Ki(e))}var ge={code:Ni,name:Ou,encode:Ki,digest:Mu};function yt(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}function $t(e=0){return new Uint8Array(e)}function wt(e=0){return new Uint8Array(e)}function ne(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=wt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var Mi=Symbol.for("@achingbrain/uint8arraylist");function Oi(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function $r(e){return!!e?.[Mi]}var Et=class e{bufs;length;[Mi]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if($r(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if($r(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=Oi(this.bufs,t);return r.buf[r.index]}set(t,r){let n=Oi(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if($r(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return ne(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:ne(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let f=t>=a&&t<c,u=r>a&&r<=c;if(f&&u){if(t===a&&r===c){n.push(s);break}let l=t-a;n.push(s.subarray(l,l+(r-t)));break}if(f){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!$r(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=c;l+=u){u=0;for(let w=f;w>=0;w--){let B=this.get(l+w);if(n[w]!==B){u=Math.max(1,w-a[B]);break}}if(u===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=wt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=$t(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=$t(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=$t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=wt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=$t(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=$t(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=$t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=$t(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=$t(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!yt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var Vn={};mt(Vn,{base10:()=>Vu});var Vu=te({prefix:"9",name:"base10",alphabet:"0123456789"});var Pn={};mt(Pn,{base16:()=>Pu,base16upper:()=>Fu});var Pu=Q({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fu=Q({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Fn={};mt(Fn,{base2:()=>$u});var $u=Q({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var $n={};mt($n,{base256emoji:()=>ju});var Vi=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),qu=Vi.reduce((e,t,r)=>(e[r]=t,e),[]),Hu=Vi.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function zu(e){return e.reduce((t,r)=>(t+=qu[r],t),"")}function Zu(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Hu[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var ju=Ue({prefix:"\u{1F680}",name:"base256emoji",encode:zu,decode:Zu});var Hn={};mt(Hn,{base64:()=>qn,base64pad:()=>Yu,base64url:()=>Gu,base64urlpad:()=>Xu});var qn=Q({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yu=Q({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Gu=Q({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xu=Q({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zn={};mt(zn,{base8:()=>Wu});var Wu=Q({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Zn={};mt(Zn,{identity:()=>Ju});var Ju=Ue({prefix:"\0",name:"identity",encode:e=>vi(e),decode:e=>Ai(e)});var gh=new TextEncoder,bh=new TextDecoder;var Xn={};mt(Xn,{sha256:()=>Gn,sha512:()=>rf});var ef=20;function Yn({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new jn(e,t,r,n,o)}var jn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??ef,this.maxDigestLength=i}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Pi(n,this.code,r?.truncate):n.then(o=>Pi(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Pi(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Kt(t,e)}function $i(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Gn=Yn({name:"sha2-256",code:18,encode:$i("SHA-256")}),rf=Yn({name:"sha2-512",code:19,encode:$i("SHA-512")});var Wn={...Zn,...Fn,...zn,...Vn,...Pn,...kn,...Nn,...Rn,...Hn,...$n},Uh={...Xn,...Mn};function Hi(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var qi=Hi("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Jn=Hi("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=wt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),nf={utf8:qi,"utf-8":qi,hex:Wn.base16,latin1:Jn,ascii:Jn,binary:Jn,...Wn},qr=nf;function Z(e,t="utf8"){let r=qr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function tt(e,t="utf8"){let r=qr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var of=parseInt("11111",2),Qn=parseInt("10000000",2),sf=parseInt("01111111",2),zi={0:sr,1:sr,2:af,3:ff,4:lf,5:uf,6:cf,16:sr,22:sr,48:sr};function qt(e,t={offset:0}){let r=e[t.offset]&of;if(t.offset++,zi[r]!=null)return zi[r](e,t);throw new Error("No decoder for tag "+r)}function ar(e,t){let r=0;if((e[t.offset]&Qn)===Qn){let n=e[t.offset]&sf,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function sr(e,t){ar(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=qt(e,t);if(n===null)break;r.push(n)}return r}function af(e,t){let r=ar(e,t),n=t.offset,o=t.offset+r,i=[];for(let s=n;s<o;s++)s===n&&e[s]===0||i.push(e[s]);return t.offset+=r,Uint8Array.from(i)}function cf(e,t){let r=ar(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let f=e[t.offset];if(t.offset++,c.push(f&127),f<128){c.reverse();let u=0;for(let l=0;l<c.length;l++)u+=c[l]<<l*7;a+=`.${u}`,c=[]}}return a}function uf(e,t){return t.offset++,null}function ff(e,t){let r=ar(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function lf(e,t){let r=ar(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function df(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Et;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function to(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=df(e.byteLength);return new Et(Uint8Array.from([t.byteLength|Qn]),t)}function gt(e){let t=new Et,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Et(Uint8Array.from([2]),to(t),t)}function Hr(e){let t=Uint8Array.from([0]),r=new Et(t,e);return new Et(Uint8Array.from([3]),to(r),r)}function oe(e,t=48){let r=new Et;for(let n of e)r.append(n);return new Et(Uint8Array.from([t]),to(r),r)}async function Zi(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),i}var hf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),pf=Uint8Array.from([6,5,43,129,4,0,34]),mf=Uint8Array.from([6,5,43,129,4,0,35]),yf={ext:!0,kty:"EC",crv:"P-256"},gf={ext:!0,kty:"EC",crv:"P-384"},bf={ext:!0,kty:"EC",crv:"P-521"},eo=32,ro=48,no=66;function ji(e){let t=qt(e);return Yi(t)}function Yi(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===eo*2+1)return n=tt(t.subarray(r,r+eo),"base64url"),o=tt(t.subarray(r+eo),"base64url"),new Ne({...yf,key_ops:["verify"],x:n,y:o});if(t.byteLength===ro*2+1)return n=tt(t.subarray(r,r+ro),"base64url"),o=tt(t.subarray(r+ro),"base64url"),new Ne({...gf,key_ops:["verify"],x:n,y:o});if(t.byteLength===no*2+1)return n=tt(t.subarray(r,r+no),"base64url"),o=tt(t.subarray(r+no),"base64url"),new Ne({...bf,key_ops:["verify"],x:n,y:o});throw new ot(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Gi(e){return oe([gt(Uint8Array.from([1])),oe([xf(e.crv)],160),oe([Hr(new Et(Uint8Array.from([4]),Z(e.x??"","base64url"),Z(e.y??"","base64url")))],161)]).subarray()}function xf(e){if(e==="P-256")return hf;if(e==="P-384")return pf;if(e==="P-521")return mf;throw new ot(`Invalid curve ${e}`)}var Ne=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Gi(this.jwk)),this._raw}toMultihash(){return ge.digest(ie(this))}toCID(){return ut.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}async verify(t,r,n){return Zi(this.jwk,r,t,n)}};function be(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ot(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function q(e,t,r=""){let n=be(e),o=e?.length,i=t!==void 0;if(!n||i&&o!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=n?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return e}function zr(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Ot(e.outputLen),Ot(e.blockLen)}function Ke(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Wi(e,t){q(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function zt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Zr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Dt(e,t){return e<<32-t|e>>>t}var Ji=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",wf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Zt(e){if(q(e),Ji)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=wf[e[r]];return t}var Ht={_0:48,_9:57,A:65,F:70,a:97,f:102};function Xi(e){if(e>=Ht._0&&e<=Ht._9)return e-Ht._0;if(e>=Ht.A&&e<=Ht.F)return e-(Ht.A-10);if(e>=Ht.a&&e<=Ht.f)return e-(Ht.a-10)}function jt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ji)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Xi(e.charCodeAt(i)),a=Xi(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function bt(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];q(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}function oo(e,t={}){let r=(o,i)=>e(i).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function Oe(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var io=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Qi(e,t,r){return e&t^~e&r}function ts(e,t,r){return e&t^e&r^t&r}var cr=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Zr(this.buffer)}update(t){Ke(this),q(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Zr(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ke(this),Wi(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,zt(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=Zr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Yt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ft=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var jr=BigInt(4294967295),es=BigInt(32);function Ef(e,t=!1){return t?{h:Number(e&jr),l:Number(e>>es&jr)}:{h:Number(e>>es&jr)|0,l:Number(e&jr)|0}}function rs(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=Ef(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var so=(e,t,r)=>e>>>r,ao=(e,t,r)=>e<<32-r|t>>>r,xe=(e,t,r)=>e>>>r|t<<32-r,we=(e,t,r)=>e<<32-r|t>>>r,ur=(e,t,r)=>e<<64-r|t>>>r-32,fr=(e,t,r)=>e>>>r-32|t<<64-r;function Mt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ns=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),os=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,is=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),ss=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,as=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),cs=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Af=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),se=new Uint32Array(64),co=class extends cr{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let l=0;l<16;l++,r+=4)se[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let w=se[l-15],B=se[l-2],b=Dt(w,7)^Dt(w,18)^w>>>3,C=Dt(B,17)^Dt(B,19)^B>>>10;se[l]=C+se[l-7]+b+se[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let w=Dt(a,6)^Dt(a,11)^Dt(a,25),B=u+w+Qi(a,c,f)+Af[l]+se[l]|0,C=(Dt(n,2)^Dt(n,13)^Dt(n,22))+ts(n,o,i)|0;u=f,f=c,c=a,a=s+B|0,s=i,i=o,o=n,n=B+C|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){zt(se)}destroy(){this.set(0,0,0,0,0,0,0,0),zt(this.buffer)}},uo=class extends co{A=Yt[0]|0;B=Yt[1]|0;C=Yt[2]|0;D=Yt[3]|0;E=Yt[4]|0;F=Yt[5]|0;G=Yt[6]|0;H=Yt[7]|0;constructor(){super(32)}};var us=rs(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),vf=us[0],Bf=us[1],ae=new Uint32Array(80),ce=new Uint32Array(80),fo=class extends cr{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:w,Gh:B,Gl:b,Hh:C,Hl:v}=this;return[t,r,n,o,i,s,a,c,f,u,l,w,B,b,C,v]}set(t,r,n,o,i,s,a,c,f,u,l,w,B,b,C,v){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=w|0,this.Gh=B|0,this.Gl=b|0,this.Hh=C|0,this.Hl=v|0}process(t,r){for(let S=0;S<16;S++,r+=4)ae[S]=t.getUint32(r),ce[S]=t.getUint32(r+=4);for(let S=16;S<80;S++){let k=ae[S-15]|0,O=ce[S-15]|0,F=xe(k,O,1)^xe(k,O,8)^so(k,O,7),P=we(k,O,1)^we(k,O,8)^ao(k,O,7),p=ae[S-2]|0,m=ce[S-2]|0,_=xe(p,m,19)^ur(p,m,61)^so(p,m,6),U=we(p,m,19)^fr(p,m,61)^ao(p,m,6),A=is(P,U,ce[S-7],ce[S-16]),y=ss(A,F,_,ae[S-7],ae[S-16]);ae[S]=y|0,ce[S]=A|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:w,Fh:B,Fl:b,Gh:C,Gl:v,Hh:x,Hl:T}=this;for(let S=0;S<80;S++){let k=xe(l,w,14)^xe(l,w,18)^ur(l,w,41),O=we(l,w,14)^we(l,w,18)^fr(l,w,41),F=l&B^~l&C,P=w&b^~w&v,p=as(T,O,P,Bf[S],ce[S]),m=cs(p,x,k,F,vf[S],ae[S]),_=p|0,U=xe(n,o,28)^ur(n,o,34)^ur(n,o,39),A=we(n,o,28)^fr(n,o,34)^fr(n,o,39),y=n&i^n&a^i&a,g=o&s^o&c^s&c;x=C|0,T=v|0,C=B|0,v=b|0,B=l|0,b=w|0,{h:l,l:w}=Mt(f|0,u|0,m|0,_|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let h=ns(_,A,g);n=os(h,m,U,y),o=h|0}({h:n,l:o}=Mt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Mt(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Mt(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Mt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:w}=Mt(this.Eh|0,this.El|0,l|0,w|0),{h:B,l:b}=Mt(this.Fh|0,this.Fl|0,B|0,b|0),{h:C,l:v}=Mt(this.Gh|0,this.Gl|0,C|0,v|0),{h:x,l:T}=Mt(this.Hh|0,this.Hl|0,x|0,T|0),this.set(n,o,i,s,a,c,f,u,l,w,B,b,C,v,x,T)}roundClean(){zt(ae,ce)}destroy(){zt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},lo=class extends fo{Ah=ft[0]|0;Al=ft[1]|0;Bh=ft[2]|0;Bl=ft[3]|0;Ch=ft[4]|0;Cl=ft[5]|0;Dh=ft[6]|0;Dl=ft[7]|0;Eh=ft[8]|0;El=ft[9]|0;Fh=ft[10]|0;Fl=ft[11]|0;Gh=ft[12]|0;Gl=ft[13]|0;Hh=ft[14]|0;Hl=ft[15]|0;constructor(){super(64)}};var Me=oo(()=>new uo,io(1));var fs=oo(()=>new lo,io(3));var po=BigInt(0),ho=BigInt(1);function Gt(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function ls(e){if(typeof e=="bigint"){if(!Yr(e))throw new Error("positive bigint expected, got "+e)}else Ot(e);return e}function lr(e){let t=ls(e).toString(16);return t.length&1?"0"+t:t}function ds(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?po:BigInt("0x"+e)}function Ve(e){return ds(Zt(e))}function Ee(e){return ds(Zt(Xr(q(e)).reverse()))}function Gr(e,t){Ot(t),e=ls(e);let r=jt(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function mo(e,t){return Gr(e,t).reverse()}function Xr(e){return Uint8Array.from(e)}var Yr=e=>typeof e=="bigint"&&po<=e;function Cf(e,t,r){return Yr(e)&&Yr(t)&&Yr(r)&&t<=e&&e<r}function dr(e,t,r,n){if(!Cf(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function yo(e){let t;for(t=0;e>po;e>>=ho,t+=1);return t}var hr=e=>(ho<<BigInt(e))-ho;function hs(e,t,r){if(Ot(e,"hashLen"),Ot(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=v=>new Uint8Array(v),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),f=n(e),u=0,l=()=>{c.fill(1),f.fill(0),u=0},w=(...v)=>r(f,bt(c,...v)),B=(v=o)=>{f=w(i,v),c=w(),v.length!==0&&(f=w(s,v),c=w())},b=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let v=0,x=[];for(;v<t;){c=w();let T=c.slice();x.push(T),v+=c.length}return bt(...x)};return(v,x)=>{l(),B(v);let T;for(;!(T=x(b()));)B();return l(),T}}function ue(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(i,s,a){let c=e[i];if(a&&c===void 0)return;let f=typeof c;if(f!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${f}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(t,!1),o(r,!0)}function Pe(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var ht=BigInt(0),it=BigInt(1),Se=BigInt(2),ys=BigInt(3),gs=BigInt(4),bs=BigInt(5),Tf=BigInt(7),xs=BigInt(8),If=BigInt(9),ws=BigInt(16);function et(e,t){let r=e%t;return r>=ht?r:t+r}function G(e,t,r){let n=e;for(;t-- >ht;)n*=n,n%=r;return n}function ps(e,t){if(e===ht)throw new Error("invert: expected non-zero number");if(t<=ht)throw new Error("invert: expected positive modulus, got "+t);let r=et(e,t),n=t,o=ht,i=it,s=it,a=ht;for(;r!==ht;){let f=n/r,u=n%r,l=o-s*f,w=i-a*f;n=r,r=u,o=s,i=a,s=l,a=w}if(n!==it)throw new Error("invert: does not exist");return et(o,t)}function bo(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function Es(e,t){let r=(e.ORDER+it)/gs,n=e.pow(t,r);return bo(e,n,t),n}function _f(e,t){let r=(e.ORDER-bs)/xs,n=e.mul(t,Se),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Se),o),a=e.mul(i,e.sub(s,e.ONE));return bo(e,a,t),a}function Uf(e){let t=Fe(e),r=Ss(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+Tf)/ws;return(a,c)=>{let f=a.pow(c,s),u=a.mul(f,n),l=a.mul(f,o),w=a.mul(f,i),B=a.eql(a.sqr(u),c),b=a.eql(a.sqr(l),c);f=a.cmov(f,u,B),u=a.cmov(w,l,b);let C=a.eql(a.sqr(u),c),v=a.cmov(f,u,C);return bo(a,v,c),v}}function Ss(e){if(e<ys)throw new Error("sqrt is not defined for small field");let t=e-it,r=0;for(;t%Se===ht;)t/=Se,r++;let n=Se,o=Fe(e);for(;ms(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Es;let i=o.pow(n,t),s=(t+it)/Se;return function(c,f){if(c.is0(f))return f;if(ms(c,f)!==1)throw new Error("Cannot find square root");let u=r,l=c.mul(c.ONE,i),w=c.pow(f,t),B=c.pow(f,s);for(;!c.eql(w,c.ONE);){if(c.is0(w))return c.ZERO;let b=1,C=c.sqr(w);for(;!c.eql(C,c.ONE);)if(b++,C=c.sqr(C),b===u)throw new Error("Cannot find square root");let v=it<<BigInt(u-b-1),x=c.pow(l,v);u=b,l=c.sqr(x),w=c.mul(w,l),B=c.mul(B,x)}return B}}function Df(e){return e%gs===ys?Es:e%xs===bs?_f:e%ws===If?Uf(e):Ss(e)}var As=(e,t)=>(et(e,t)&it)===it,Lf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xo(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Lf.reduce((n,o)=>(n[o]="function",n),t);return ue(e,r),e}function Rf(e,t,r){if(r<ht)throw new Error("invalid exponent, negatives unsupported");if(r===ht)return e.ONE;if(r===it)return t;let n=e.ONE,o=t;for(;r>ht;)r&it&&(n=e.mul(n,o)),o=e.sqr(o),r>>=it;return n}function pr(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function ms(e,t){let r=(e.ORDER-it)/Se,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function kf(e,t){t!==void 0&&Ot(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var go=class{ORDER;BITS;BYTES;isLE;ZERO=ht;ONE=it;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=ht)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=kf(t,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return et(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return ht<=t&&t<this.ORDER}is0(t){return t===ht}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&it)===it}neg(t){return et(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return et(t*t,this.ORDER)}add(t,r){return et(t+r,this.ORDER)}sub(t,r){return et(t-r,this.ORDER)}mul(t,r){return et(t*r,this.ORDER)}pow(t,r){return Rf(this,t,r)}div(t,r){return et(t*ps(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return ps(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=Df(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?mo(t,this.BYTES):Gr(t,this.BYTES)}fromBytes(t,r=!1){q(t);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,i?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=i?Ee(t):Ve(t);if(a&&(c=et(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return pr(this,t)}cmov(t,r,n){return n?r:t}};function Fe(e,t={}){return new go(e,t)}function vs(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function wo(e){let t=vs(e);return t+Math.ceil(t/2)}function Eo(e,t,r=!1){q(e);let n=e.length,o=vs(t),i=wo(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ee(e):Ve(e),a=et(s,t-it)+it;return r?mo(a,o):Gr(a,o)}var $e=BigInt(0),Ae=BigInt(1);function mr(e,t){let r=t.negate();return e?r:t}function ve(e,t){let r=pr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function Is(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function So(e,t){Is(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=hr(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Bs(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=Ae);let f=t*n,u=f+Math.abs(a)-1,l=a===0,w=a<0,B=t%2!==0;return{nextN:c,offset:u,isZero:l,isNeg:w,isNegF:B,offsetF:f}}var Ao=new WeakMap,_s=new WeakMap;function vo(e){return _s.get(e)||1}function Cs(e){if(e!==$e)throw new Error("invalid wNAF")}var qe=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>$e;)r&Ae&&(n=n.add(o)),o=o.double(),r>>=Ae;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=So(r,this.bits),i=[],s=t,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let f=1;f<o;f++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=So(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:f,isZero:u,isNeg:l,isNegF:w,offsetF:B}=Bs(n,a,s);n=c,u?i=i.add(mr(w,r[B])):o=o.add(mr(l,r[f]))}return Cs(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=So(t,this.bits);for(let s=0;s<i.windows&&n!==$e;s++){let{nextN:a,offset:c,isZero:f,isNeg:u}=Bs(n,s,i);if(n=a,!f){let l=r[c];o=o.add(u?l.negate():l)}}return Cs(n),o}getPrecomputes(t,r,n){let o=Ao.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),Ao.set(r,o))),o}cached(t,r,n){let o=vo(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=vo(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){Is(r,this.bits),_s.set(t,r),Ao.delete(t)}hasCache(t){return vo(t)!==1}};function Us(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>$e||n>$e;)r&Ae&&(i=i.add(o)),n&Ae&&(s=s.add(o)),o=o.double(),r>>=Ae,n>>=Ae;return{p1:i,p2:s}}function Ts(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return xo(t),t}else return Fe(e,{isLE:r})}function Wr(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let f=t[c];if(!(typeof f=="bigint"&&f>$e))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Ts(t.p,r.Fp,n),i=Ts(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}function Jr(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var fe=BigInt(0),st=BigInt(1),Bo=BigInt(2),Nf=BigInt(8);function Kf(e,t,r,n){let o=e.sqr(r),i=e.sqr(n),s=e.add(e.mul(t.a,o),i),a=e.add(e.ONE,e.mul(t.d,e.mul(o,i)));return e.eql(s,a)}function Ds(e,t={}){let r=Wr("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;ue(t,{},{uvRatio:"function"});let a=Bo<<BigInt(o.BYTES*8)-st,c=v=>n.create(v),f=t.uvRatio||((v,x)=>{try{return{isValid:!0,value:n.sqrt(n.div(v,x))}}catch{return{isValid:!1,value:fe}}});if(!Kf(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(v,x,T=!1){let S=T?st:fe;return dr("coordinate "+v,x,S,a),x}function l(v){if(!(v instanceof b))throw new Error("EdwardsPoint expected")}let w=Pe((v,x)=>{let{X:T,Y:S,Z:k}=v,O=v.is0();x==null&&(x=O?Nf:n.inv(k));let F=c(T*x),P=c(S*x),p=n.mul(k,x);if(O)return{x:fe,y:st};if(p!==st)throw new Error("invZ was invalid");return{x:F,y:P}}),B=Pe(v=>{let{a:x,d:T}=i;if(v.is0())throw new Error("bad point: ZERO");let{X:S,Y:k,Z:O,T:F}=v,P=c(S*S),p=c(k*k),m=c(O*O),_=c(m*m),U=c(P*x),A=c(m*c(U+p)),y=c(_+c(T*c(P*p)));if(A!==y)throw new Error("bad point: equation left != right (1)");let g=c(S*k),h=c(O*F);if(g!==h)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(i.Gx,i.Gy,st,c(i.Gx*i.Gy));static ZERO=new b(fe,st,st,fe);static Fp=n;static Fn=o;X;Y;Z;T;constructor(x,T,S,k){this.X=u("x",x),this.Y=u("y",T),this.Z=u("z",S,!0),this.T=u("t",k),Object.freeze(this)}static CURVE(){return i}static fromAffine(x){if(x instanceof b)throw new Error("extended point not allowed");let{x:T,y:S}=x||{};return u("x",T),u("y",S),new b(T,S,st,c(T*S))}static fromBytes(x,T=!1){let S=n.BYTES,{a:k,d:O}=i;x=Xr(q(x,S,"point")),Gt(T,"zip215");let F=Xr(x),P=x[S-1];F[S-1]=P&-129;let p=Ee(F),m=T?a:n.ORDER;dr("point.y",p,fe,m);let _=c(p*p),U=c(_-st),A=c(O*_-k),{isValid:y,value:g}=f(U,A);if(!y)throw new Error("bad point: invalid y coordinate");let h=(g&st)===st,E=(P&128)!==0;if(!T&&g===fe&&E)throw new Error("bad point: x=0 and x_0=1");return E!==h&&(g=c(-g)),b.fromAffine({x:g,y:p})}static fromHex(x,T=!1){return b.fromBytes(jt(x),T)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,T=!0){return C.createCache(this,x),T||this.multiply(Bo),this}assertValidity(){B(this)}equals(x){l(x);let{X:T,Y:S,Z:k}=this,{X:O,Y:F,Z:P}=x,p=c(T*P),m=c(O*k),_=c(S*P),U=c(F*k);return p===m&&_===U}is0(){return this.equals(b.ZERO)}negate(){return new b(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:x}=i,{X:T,Y:S,Z:k}=this,O=c(T*T),F=c(S*S),P=c(Bo*c(k*k)),p=c(x*O),m=T+S,_=c(c(m*m)-O-F),U=p+F,A=U-P,y=p-F,g=c(_*A),h=c(U*y),E=c(_*y),L=c(A*U);return new b(g,h,L,E)}add(x){l(x);let{a:T,d:S}=i,{X:k,Y:O,Z:F,T:P}=this,{X:p,Y:m,Z:_,T:U}=x,A=c(k*p),y=c(O*m),g=c(P*S*U),h=c(F*_),E=c((k+O)*(p+m)-A-y),L=h-g,R=h+g,N=c(y-T*A),K=c(E*L),V=c(R*N),$=c(E*N),X=c(L*R);return new b(K,V,X,$)}subtract(x){return this.add(x.negate())}multiply(x){if(!o.isValidNot0(x))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:T,f:S}=C.cached(this,x,k=>ve(b,k));return ve(b,[T,S])[0]}multiplyUnsafe(x,T=b.ZERO){if(!o.isValid(x))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return x===fe?b.ZERO:this.is0()||x===st?this:C.unsafe(this,x,S=>ve(b,S),T)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return C.unsafe(this,i.n).is0()}toAffine(x){return w(this,x)}clearCofactor(){return s===st?this:this.multiplyUnsafe(s)}toBytes(){let{x,y:T}=this.toAffine(),S=n.toBytes(T);return S[S.length-1]|=x&st?128:0,S}toHex(){return Zt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let C=new qe(b,o.BITS);return b.BASE.precompute(8),b}function Ls(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');ue(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:i,Fn:s}=e,a=r.randomBytes||Oe,c=r.adjustScalarBytes||(p=>p),f=r.domain||((p,m,_)=>{if(Gt(_,"phflag"),m.length||_)throw new Error("Contexts/pre-hash are not supported");return p});function u(p){return s.create(Ee(p))}function l(p){let m=S.secretKey;q(p,S.secretKey,"secretKey");let _=q(t(p),2*m,"hashedSecretKey"),U=c(_.slice(0,m)),A=_.slice(m,2*m),y=u(U);return{head:U,prefix:A,scalar:y}}function w(p){let{head:m,prefix:_,scalar:U}=l(p),A=o.multiply(U),y=A.toBytes();return{head:m,prefix:_,scalar:U,point:A,pointBytes:y}}function B(p){return w(p).pointBytes}function b(p=Uint8Array.of(),...m){let _=bt(...m);return u(t(f(_,q(p,void 0,"context"),!!n)))}function C(p,m,_={}){p=q(p,void 0,"message"),n&&(p=n(p));let{prefix:U,scalar:A,pointBytes:y}=w(m),g=b(_.context,U,p),h=o.multiply(g).toBytes(),E=b(_.context,h,y,p),L=s.create(g+E*A);if(!s.isValid(L))throw new Error("sign failed: invalid s");let R=bt(h,s.toBytes(L));return q(R,S.signature,"result")}let v={zip215:!0};function x(p,m,_,U=v){let{context:A,zip215:y}=U,g=S.signature;p=q(p,g,"signature"),m=q(m,void 0,"message"),_=q(_,S.publicKey,"publicKey"),y!==void 0&&Gt(y,"zip215"),n&&(m=n(m));let h=g/2,E=p.subarray(0,h),L=Ee(p.subarray(h,g)),R,N,K;try{R=e.fromBytes(_,y),N=e.fromBytes(E,y),K=o.multiplyUnsafe(L)}catch{return!1}if(!y&&R.isSmallOrder())return!1;let V=b(A,N.toBytes(),R.toBytes(),m);return N.add(R.multiplyUnsafe(V)).subtract(K).clearCofactor().is0()}let T=i.BYTES,S={secretKey:T,publicKey:T,signature:2*T,seed:T};function k(p=a(S.seed)){return q(p,S.seed,"seed")}function O(p){return be(p)&&p.length===s.BYTES}function F(p,m){try{return!!e.fromBytes(p,m)}catch{return!1}}let P={getExtendedPublicKey:w,randomSecretKey:k,isValidSecretKey:O,isValidPublicKey:F,toMontgomery(p){let{y:m}=e.fromBytes(p),_=S.publicKey,U=_===32;if(!U&&_!==57)throw new Error("only defined for 25519 and 448");let A=U?i.div(st+m,st-m):i.div(m-st,m+st);return i.toBytes(A)},toMontgomerySecret(p){let m=S.secretKey;q(p,m);let _=t(p.subarray(0,m));return c(_).subarray(0,m)}};return Object.freeze({keygen:Jr(k,B),getPublicKey:B,sign:C,verify:x,utils:P,Point:e,lengths:S})}var Of=BigInt(1),Rs=BigInt(2);var Mf=BigInt(5),Vf=BigInt(8),Co=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Pf={p:Co,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Vf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Ff(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Co,a=e*e%i*e%i,c=G(a,Rs,i)*a%i,f=G(c,Of,i)*e%i,u=G(f,Mf,i)*f%i,l=G(u,t,i)*u%i,w=G(l,r,i)*l%i,B=G(w,n,i)*w%i,b=G(B,o,i)*B%i,C=G(b,o,i)*B%i,v=G(C,t,i)*u%i;return{pow_p_5_8:G(v,Rs,i)*e%i,b2:a}}function $f(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var ks=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function qf(e,t){let r=Co,n=et(t*t*t,r),o=et(n*n*t,r),i=Ff(e*o).pow_p_5_8,s=et(e*n*i,r),a=et(t*s*s,r),c=s,f=et(s*ks,r),u=a===e,l=a===et(-e,r),w=a===et(-e*ks,r);return u&&(s=c),(l||w)&&(s=f),As(s,r)&&(s=et(-s,r)),{isValid:u||l,value:s}}var Hf=Ds(Pf,{uvRatio:qf});function zf(e){return Ls(Hf,fs,Object.assign({adjustScalarBytes:$f},e))}var Ns=zf({});var yr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Qr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Ks={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Qr("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var It=Ks;var tn=32;var To,Zf=(async()=>{try{return await It.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function jf(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await It.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await It.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Yf(e,t,r){return Ns.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Os(e,t,r){return To==null&&(To=await Zf),To?jf(e,t,r):Yf(e,t,r)}function en(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var rn=class{type="Ed25519";raw;constructor(t){this.raw=Io(t,tn)}toMultihash(){return ge.digest(ie(this))}toCID(){return ut.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Os(this.raw,r,t);return en(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Vs(e){return e=Io(e,tn),new rn(e)}function Io(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new ot(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Xf=Math.pow(2,7),Wf=Math.pow(2,14),Jf=Math.pow(2,21),Ps=Math.pow(2,28),Fs=Math.pow(2,35),$s=Math.pow(2,42),qs=Math.pow(2,49),pt=128,le=127;function gr(e){if(e<Xf)return 1;if(e<Wf)return 2;if(e<Jf)return 3;if(e<Ps)return 4;if(e<Fs)return 5;if(e<$s)return 6;if(e<qs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Hs(e,t,r=0){switch(gr(e)){case 8:t[r++]=e&255|pt,e/=128;case 7:t[r++]=e&255|pt,e/=128;case 6:t[r++]=e&255|pt,e/=128;case 5:t[r++]=e&255|pt,e/=128;case 4:t[r++]=e&255|pt,e>>>=7;case 3:t[r++]=e&255|pt,e>>>=7;case 2:t[r++]=e&255|pt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function zs(e,t){let r=e[t],n=0;if(n+=r&le,r<pt||(r=e[t+1],n+=(r&le)<<7,r<pt)||(r=e[t+2],n+=(r&le)<<14,r<pt)||(r=e[t+3],n+=(r&le)<<21,r<pt)||(r=e[t+4],n+=(r&le)*Ps,r<pt)||(r=e[t+5],n+=(r&le)*Fs,r<pt)||(r=e[t+6],n+=(r&le)*$s,r<pt)||(r=e[t+7],n+=(r&le)*qs,r<pt))return n;throw new RangeError("Could not decode varint")}var _o=new Float32Array([-0]),de=new Uint8Array(_o.buffer);function Zs(e,t,r){_o[0]=e,t[r]=de[0],t[r+1]=de[1],t[r+2]=de[2],t[r+3]=de[3]}function js(e,t){return de[0]=e[t],de[1]=e[t+1],de[2]=e[t+2],de[3]=e[t+3],_o[0]}var Uo=new Float64Array([-0]),dt=new Uint8Array(Uo.buffer);function Ys(e,t,r){Uo[0]=e,t[r]=dt[0],t[r+1]=dt[1],t[r+2]=dt[2],t[r+3]=dt[3],t[r+4]=dt[4],t[r+5]=dt[5],t[r+6]=dt[6],t[r+7]=dt[7]}function Gs(e,t){return dt[0]=e[t],dt[1]=e[t+1],dt[2]=e[t+2],dt[3]=e[t+3],dt[4]=e[t+4],dt[5]=e[t+5],dt[6]=e[t+6],dt[7]=e[t+7],Uo[0]}var Qf=BigInt(Number.MAX_SAFE_INTEGER),tl=BigInt(Number.MIN_SAFE_INTEGER),St=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Be;if(t<Qf&&t>tl)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Xs&&(o=0n,++n>Xs&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Be;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Be}},Be=new St(0,0);Be.toBigInt=function(){return 0n};Be.zzEncode=Be.zzDecode=function(){return this};Be.length=function(){return 1};var Xs=4294967296n;function Ws(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Js(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Do(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Lt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function nn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Lo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Lt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Lt(this,4);return nn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Lt(this,4);return nn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Lt(this,4);let t=js(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Lt(this,4);let t=Gs(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Lt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Js(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new St(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Lt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Lt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Lt(this,8);let t=nn(this.buf,this.pos+=4),r=nn(this.buf,this.pos+=4);return new St(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=zs(this.buf,this.pos);return this.pos+=gr(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function br(e){return new Lo(e instanceof Uint8Array?e:e.subarray())}function He(e,t,r){let n=br(e);return t.decode(n,void 0,r)}function Ro(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return wt(s);o+s>t&&(n=wt(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Ce=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function ko(){}var Ko=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},el=Ro();function rl(e){return globalThis.Buffer!=null?wt(e):el(e)}var wr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ce(ko,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Ce(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Oo((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(on,10,St.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=St.fromBigInt(t);return this._push(on,r.length(),r)}uint64Number(t){return this._push(Hs,gr(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=St.fromBigInt(t).zzEncode();return this._push(on,r.length(),r)}sint64Number(t){let r=St.fromNumber(t).zzEncode();return this._push(on,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(No,1,t?1:0)}fixed32(t){return this._push(xr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=St.fromBigInt(t);return this._push(xr,4,r.lo)._push(xr,4,r.hi)}fixed64Number(t){let r=St.fromNumber(t);return this._push(xr,4,r.lo)._push(xr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Zs,4,t)}double(t){return this._push(Ys,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(No,1,0):this.uint32(r)._push(ol,r,t)}string(t){let r=Ws(t);return r!==0?this.uint32(r)._push(Do,r,t):this._push(No,1,0)}fork(){return this.states=new Ko(this),this.head=this.tail=new Ce(ko,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Ce(ko,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=rl(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function No(e,t,r){t[r]=e&255}function nl(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Oo=class extends Ce{next;constructor(t,r){super(nl,t,r),this.next=void 0}};function on(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function xr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function ol(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(wr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(il,t,e),this},wr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(sl,t,e),this});function il(e,t,r){t.set(e,r)}function sl(e,t,r){e.length<40?Do(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Z(e),r)}function Mo(){return new wr}function ze(e,t){let r=Mo();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*Ze(e,t,r){let n=br(e);yield*t.stream(n,void 0,"$",r)}var sn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function an(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function Er(e){function t(i){if(e[i.toString()]==null)throw new Error("Invalid enum value");return e[i]}let r=function(s,a){let c=t(s);a.int32(c)},n=function(s){let a=s.int32();return t(a)},o=function*(s){let a=s.int32();yield t(a)};return an("enum",sn.VARINT,r,n,o)}function je(e,t,r){return an("message",sn.LENGTH_DELIMITED,e,t,r)}var nt;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(nt||(nt={}));var Vo;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Vo||(Vo={}));(function(e){e.codec=()=>Er(Vo)})(nt||(nt={}));var Xt;(function(e){let t;e.codec=()=>(t==null&&(t=je((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),nt.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let u=i.uint32();switch(u>>>3){case 1:{c.Type=nt.codec().decode(i);break}case 2:{c.Data=i.bytes();break}default:{i.skipType(u&7);break}}}return c},function*(i,s,a,c={}){let f=s==null?i.len:i.pos+s;for(;i.pos<f;){let u=i.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:nt.codec().decode(i)};break}case 2:{yield{field:`${a}.Data`,value:i.bytes()};break}default:{i.skipType(u&7);break}}}})),t);function r(i){return ze(i,e.codec())}e.encode=r;function n(i,s){return He(i,e.codec(),s)}e.decode=n;function o(i,s){return Ze(i,e.codec(),s)}e.stream=o})(Xt||(Xt={}));var Po;(function(e){let t;e.codec=()=>(t==null&&(t=je((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),nt.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let u=i.uint32();switch(u>>>3){case 1:{c.Type=nt.codec().decode(i);break}case 2:{c.Data=i.bytes();break}default:{i.skipType(u&7);break}}}return c},function*(i,s,a,c={}){let f=s==null?i.len:i.pos+s;for(;i.pos<f;){let u=i.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:nt.codec().decode(i)};break}case 2:{yield{field:`${a}.Data`,value:i.bytes()};break}default:{i.skipType(u&7);break}}}})),t);function r(i){return ze(i,e.codec())}e.encode=r;function n(i,s){return He(i,e.codec(),s)}e.decode=n;function o(i,s){return Ze(i,e.codec(),s)}e.stream=o})(Po||(Po={}));var Ar={};mt(Ar,{MAX_RSA_KEY_SIZE:()=>Fo,generateRSAKeyPair:()=>oa,jwkToJWKKeyPair:()=>ia,jwkToPkcs1:()=>fl,jwkToPkix:()=>zo,jwkToRSAPrivateKey:()=>Go,pkcs1MessageToJwk:()=>qo,pkcs1MessageToRSAPrivateKey:()=>Zo,pkcs1ToJwk:()=>ul,pkcs1ToRSAPrivateKey:()=>na,pkixMessageToJwk:()=>Ho,pkixMessageToRSAPublicKey:()=>Yo,pkixToJwk:()=>ll,pkixToRSAPublicKey:()=>jo});var Ye=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Ar.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return ut.createV1(114,this._multihash)}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,r,n){return ra(this.jwk,r,t,n)}},Sr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Ar.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}sign(t,r){return ea(this.jwk,t,r)}};var Fo=8192,$o=18,al=1062,cl=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function ul(e){let t=qt(e);return qo(t)}function qo(e){return{n:tt(e[1],"base64url"),e:tt(e[2],"base64url"),d:tt(e[3],"base64url"),p:tt(e[4],"base64url"),q:tt(e[5],"base64url"),dp:tt(e[6],"base64url"),dq:tt(e[7],"base64url"),qi:tt(e[8],"base64url"),kty:"RSA"}}function fl(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new ot("JWK was missing components");return oe([gt(Uint8Array.from([0])),gt(Z(e.n,"base64url")),gt(Z(e.e,"base64url")),gt(Z(e.d,"base64url")),gt(Z(e.p,"base64url")),gt(Z(e.q,"base64url")),gt(Z(e.dp,"base64url")),gt(Z(e.dq,"base64url")),gt(Z(e.qi,"base64url"))]).subarray()}function ll(e){let t=qt(e,{offset:0});return Ho(t)}function Ho(e){let t=qt(e[1],{offset:0});return{kty:"RSA",n:tt(t[0],"base64url"),e:tt(t[1],"base64url")}}function zo(e){if(e.n==null||e.e==null)throw new ot("JWK was missing components");return oe([cl,Hr(oe([gt(Z(e.n,"base64url")),gt(Z(e.e,"base64url"))]))]).subarray()}function na(e){let t=qt(e);return Zo(t)}function Zo(e){let t=qo(e);return Go(t)}function jo(e,t){if(e.byteLength>=al)throw new _e("Key size is too large");let r=qt(e,{offset:0});return Yo(r,e,t)}function Yo(e,t,r){let n=Ho(e);if(r==null){let o=Me(Xt.encode({Type:nt.RSA,Data:t}));r=Kt($o,o)}return new Ye(n,r)}function Go(e){if(aa(e)>Fo)throw new ot("Key size is too large");let t=ia(e),r=Me(Xt.encode({Type:nt.RSA,Data:zo(t.publicKey)})),n=Kt($o,r);return new Sr(t.privateKey,new Ye(t.publicKey,n))}async function oa(e){if(e>Fo)throw new ot("Key size is too large");let t=await sa(e),r=Me(Xt.encode({Type:nt.RSA,Data:zo(t.publicKey)})),n=Kt($o,r);return new Sr(t.privateKey,new Ye(t.publicKey,n))}function ia(e){if(e==null)throw new ot("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function sa(e,t){let r=await It.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await dl(r,t);return{privateKey:n[0],publicKey:n[1]}}async function ea(e,t,r){let n=await It.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await It.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function ra(e,t,r,n){let o=await It.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await It.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function dl(e,t){if(e.privateKey==null||e.publicKey==null)throw new ot("Private and public key are required");let r=await Promise.all([It.get().subtle.exportKey("jwk",e.privateKey),It.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function aa(e){if(e.kty!=="RSA")throw new ot("invalid key type");if(e.n==null)throw new ot("invalid key modulus");return Z(e.n,"base64url").length*8}var cn=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(zr(t),q(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),zt(o)}update(t){return Ke(this),this.iHash.update(t),this}digestInto(t){Ke(this),q(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Xo=(e,t,r)=>new cn(e,t).update(r).digest();Xo.create=(e,t)=>new cn(e,t);var ca=(e,t)=>(e+(e>=0?t:-t)/ua)/t;function hl(e,t,r){let[[n,o],[i,s]]=t,a=ca(s*e,r),c=ca(-o*e,r),f=e-a*n-c*i,u=-a*o-c*s,l=f<Wt,w=u<Wt;l&&(f=-f),w&&(u=-u);let B=hr(Math.ceil(yo(r)/2))+Ge;if(f<Wt||f>=B||u<Wt||u>=B)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:f,k2neg:w,k2:u}}function Jo(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Wo(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return Gt(r.lowS,"lowS"),Gt(r.prehash,"prehash"),r.format!==void 0&&Jo(r.format),r}var Qo=class extends Error{constructor(t=""){super(t)}},he={Err:Qo,_tlv:{encode:(e,t)=>{let{Err:r}=he;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=lr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?lr(o.length/2|128):"";return lr(e)+i+o+t},decode(e,t){let{Err:r}=he,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=he;if(e<Wt)throw new t("integer: negative integers are not allowed");let r=lr(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=he;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ve(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=he,o=q(e,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=he,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},Wt=BigInt(0),Ge=BigInt(1),ua=BigInt(2),un=BigInt(3),pl=BigInt(4);function fa(e,t={}){let r=Wr("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:a}=i;ue(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=da(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(A,y,g){let{x:h,y:E}=y.toAffine(),L=n.toBytes(h);if(Gt(g,"isCompressed"),g){u();let R=!n.isOdd(E);return bt(la(R),L)}else return bt(Uint8Array.of(4),L,n.toBytes(E))}function w(A){q(A,void 0,"Point");let{publicKey:y,publicKeyUncompressed:g}=f,h=A.length,E=A[0],L=A.subarray(1);if(h===y&&(E===2||E===3)){let R=n.fromBytes(L);if(!n.isValid(R))throw new Error("bad point: is not on curve, wrong x");let N=C(R),K;try{K=n.sqrt(N)}catch(X){let Y=X instanceof Error?": "+X.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}u();let V=n.isOdd(K);return(E&1)===1!==V&&(K=n.neg(K)),{x:R,y:K}}else if(h===g&&E===4){let R=n.BYTES,N=n.fromBytes(L.subarray(0,R)),K=n.fromBytes(L.subarray(R,R*2));if(!v(N,K))throw new Error("bad point: is not on curve");return{x:N,y:K}}else throw new Error(`bad point: got length ${h}, expected compressed=${y} or uncompressed=${g}`)}let B=t.toBytes||l,b=t.fromBytes||w;function C(A){let y=n.sqr(A),g=n.mul(y,A);return n.add(n.add(g,n.mul(A,i.a)),i.b)}function v(A,y){let g=n.sqr(y),h=C(A);return n.eql(g,h)}if(!v(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let x=n.mul(n.pow(i.a,un),pl),T=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(x,T)))throw new Error("bad curve params: a or b");function S(A,y,g=!1){if(!n.isValid(y)||g&&n.is0(y))throw new Error(`bad point coordinate ${A}`);return y}function k(A){if(!(A instanceof m))throw new Error("Weierstrass Point expected")}function O(A){if(!c||!c.basises)throw new Error("no endo");return hl(A,c.basises,o.ORDER)}let F=Pe((A,y)=>{let{X:g,Y:h,Z:E}=A;if(n.eql(E,n.ONE))return{x:g,y:h};let L=A.is0();y==null&&(y=L?n.ONE:n.inv(E));let R=n.mul(g,y),N=n.mul(h,y),K=n.mul(E,y);if(L)return{x:n.ZERO,y:n.ZERO};if(!n.eql(K,n.ONE))throw new Error("invZ was invalid");return{x:R,y:N}}),P=Pe(A=>{if(A.is0()){if(t.allowInfinityPoint&&!n.is0(A.Y))return;throw new Error("bad point: ZERO")}let{x:y,y:g}=A.toAffine();if(!n.isValid(y)||!n.isValid(g))throw new Error("bad point: x or y not field elements");if(!v(y,g))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function p(A,y,g,h,E){return g=new m(n.mul(g.X,A),g.Y,g.Z),y=mr(h,y),g=mr(E,g),y.add(g)}class m{static BASE=new m(i.Gx,i.Gy,n.ONE);static ZERO=new m(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(y,g,h){this.X=S("x",y),this.Y=S("y",g,!0),this.Z=S("z",h),Object.freeze(this)}static CURVE(){return i}static fromAffine(y){let{x:g,y:h}=y||{};if(!y||!n.isValid(g)||!n.isValid(h))throw new Error("invalid affine point");if(y instanceof m)throw new Error("projective point not allowed");return n.is0(g)&&n.is0(h)?m.ZERO:new m(g,h,n.ONE)}static fromBytes(y){let g=m.fromAffine(b(q(y,void 0,"point")));return g.assertValidity(),g}static fromHex(y){return m.fromBytes(jt(y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,g=!0){return U.createCache(this,y),g||this.multiply(un),this}assertValidity(){P(this)}hasEvenY(){let{y}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(y)}equals(y){k(y);let{X:g,Y:h,Z:E}=this,{X:L,Y:R,Z:N}=y,K=n.eql(n.mul(g,N),n.mul(L,E)),V=n.eql(n.mul(h,N),n.mul(R,E));return K&&V}negate(){return new m(this.X,n.neg(this.Y),this.Z)}double(){let{a:y,b:g}=i,h=n.mul(g,un),{X:E,Y:L,Z:R}=this,N=n.ZERO,K=n.ZERO,V=n.ZERO,$=n.mul(E,E),X=n.mul(L,L),Y=n.mul(R,R),H=n.mul(E,L);return H=n.add(H,H),V=n.mul(E,R),V=n.add(V,V),N=n.mul(y,V),K=n.mul(h,Y),K=n.add(N,K),N=n.sub(X,K),K=n.add(X,K),K=n.mul(N,K),N=n.mul(H,N),V=n.mul(h,V),Y=n.mul(y,Y),H=n.sub($,Y),H=n.mul(y,H),H=n.add(H,V),V=n.add($,$),$=n.add(V,$),$=n.add($,Y),$=n.mul($,H),K=n.add(K,$),Y=n.mul(L,R),Y=n.add(Y,Y),$=n.mul(Y,H),N=n.sub(N,$),V=n.mul(Y,X),V=n.add(V,V),V=n.add(V,V),new m(N,K,V)}add(y){k(y);let{X:g,Y:h,Z:E}=this,{X:L,Y:R,Z:N}=y,K=n.ZERO,V=n.ZERO,$=n.ZERO,X=i.a,Y=n.mul(i.b,un),H=n.mul(g,L),W=n.mul(h,R),ct=n.mul(E,N),Nt=n.add(g,h),J=n.add(L,R);Nt=n.mul(Nt,J),J=n.add(H,W),Nt=n.sub(Nt,J),J=n.add(g,E);let lt=n.add(L,N);return J=n.mul(J,lt),lt=n.add(H,ct),J=n.sub(J,lt),lt=n.add(h,E),K=n.add(R,N),lt=n.mul(lt,K),K=n.add(W,ct),lt=n.sub(lt,K),$=n.mul(X,J),K=n.mul(Y,ct),$=n.add(K,$),K=n.sub(W,$),$=n.add(W,$),V=n.mul(K,$),W=n.add(H,H),W=n.add(W,H),ct=n.mul(X,ct),J=n.mul(Y,J),W=n.add(W,ct),ct=n.sub(H,ct),ct=n.mul(X,ct),J=n.add(J,ct),H=n.mul(W,J),V=n.add(V,H),H=n.mul(lt,J),K=n.mul(Nt,K),K=n.sub(K,H),H=n.mul(Nt,W),$=n.mul(lt,$),$=n.add($,H),new m(K,V,$)}subtract(y){return this.add(y.negate())}is0(){return this.equals(m.ZERO)}multiply(y){let{endo:g}=t;if(!o.isValidNot0(y))throw new Error("invalid scalar: out of range");let h,E,L=R=>U.cached(this,R,N=>ve(m,N));if(g){let{k1neg:R,k1:N,k2neg:K,k2:V}=O(y),{p:$,f:X}=L(N),{p:Y,f:H}=L(V);E=X.add(H),h=p(g.beta,$,Y,R,K)}else{let{p:R,f:N}=L(y);h=R,E=N}return ve(m,[h,E])[0]}multiplyUnsafe(y){let{endo:g}=t,h=this;if(!o.isValid(y))throw new Error("invalid scalar: out of range");if(y===Wt||h.is0())return m.ZERO;if(y===Ge)return h;if(U.hasCache(this))return this.multiply(y);if(g){let{k1neg:E,k1:L,k2neg:R,k2:N}=O(y),{p1:K,p2:V}=Us(m,h,L,N);return p(g.beta,K,V,E,R)}else return U.unsafe(h,y)}toAffine(y){return F(this,y)}isTorsionFree(){let{isTorsionFree:y}=t;return s===Ge?!0:y?y(m,this):U.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:y}=t;return s===Ge?this:y?y(m,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(y=!0){return Gt(y,"isCompressed"),this.assertValidity(),B(m,this,y)}toHex(y=!0){return Zt(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let _=o.BITS,U=new qe(m,t.endo?Math.ceil(_/2):_);return m.BASE.precompute(8),m}function la(e){return Uint8Array.of(e?2:3)}function da(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ml(e,t={}){let{Fn:r}=e,n=t.randomBytes||Oe,o=Object.assign(da(e.Fp,r),{seed:wo(r.ORDER)});function i(B){try{let b=r.fromBytes(B);return r.isValidNot0(b)}catch{return!1}}function s(B,b){let{publicKey:C,publicKeyUncompressed:v}=o;try{let x=B.length;return b===!0&&x!==C||b===!1&&x!==v?!1:!!e.fromBytes(B)}catch{return!1}}function a(B=n(o.seed)){return Eo(q(B,o.seed,"seed"),r.ORDER)}function c(B,b=!0){return e.BASE.multiply(r.fromBytes(B)).toBytes(b)}function f(B){let{secretKey:b,publicKey:C,publicKeyUncompressed:v}=o;if(!be(B)||"_lengths"in r&&r._lengths||b===C)return;let x=q(B,void 0,"key").length;return x===C||x===v}function u(B,b,C=!0){if(f(B)===!0)throw new Error("first arg must be private key");if(f(b)===!1)throw new Error("second arg must be public key");let v=r.fromBytes(B);return e.fromBytes(b).multiply(v).toBytes(C)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},w=Jr(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:w,Point:e,utils:l,lengths:o})}function ha(e,t,r={}){zr(t),ue(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Oe,o=r.hmac||((g,h)=>Xo(t,g,h)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:f,getPublicKey:u,getSharedSecret:l,utils:w,lengths:B}=ml(e,r),b={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},C=a*ua<i.ORDER;function v(g){let h=a>>Ge;return g>h}function x(g,h){if(!s.isValidNot0(h))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return h}function T(){if(C)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function S(g,h){Jo(h);let E=B.signature,L=h==="compact"?E:h==="recovered"?E+1:void 0;return q(g,L)}class k{r;s;recovery;constructor(h,E,L){if(this.r=x("r",h),this.s=x("s",E),L!=null){if(T(),![0,1,2,3].includes(L))throw new Error("invalid recovery id");this.recovery=L}Object.freeze(this)}static fromBytes(h,E=b.format){S(h,E);let L;if(E==="der"){let{r:V,s:$}=he.toSig(q(h));return new k(V,$)}E==="recovered"&&(L=h[0],E="compact",h=h.subarray(1));let R=B.signature/2,N=h.subarray(0,R),K=h.subarray(R,R*2);return new k(s.fromBytes(N),s.fromBytes(K),L)}static fromHex(h,E){return this.fromBytes(jt(h),E)}assertRecovery(){let{recovery:h}=this;if(h==null)throw new Error("invalid recovery id: must be present");return h}addRecoveryBit(h){return new k(this.r,this.s,h)}recoverPublicKey(h){let{r:E,s:L}=this,R=this.assertRecovery(),N=R===2||R===3?E+a:E;if(!i.isValid(N))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=i.toBytes(N),V=e.fromBytes(bt(la((R&1)===0),K)),$=s.inv(N),X=F(q(h,void 0,"msgHash")),Y=s.create(-X*$),H=s.create(L*$),W=e.BASE.multiplyUnsafe(Y).add(V.multiplyUnsafe(H));if(W.is0())throw new Error("invalid recovery: point at infinify");return W.assertValidity(),W}hasHighS(){return v(this.s)}toBytes(h=b.format){if(Jo(h),h==="der")return jt(he.hexFromSig(this));let{r:E,s:L}=this,R=s.toBytes(E),N=s.toBytes(L);return h==="recovered"?(T(),bt(Uint8Array.of(this.assertRecovery()),R,N)):bt(R,N)}toHex(h){return Zt(this.toBytes(h))}}let O=r.bits2int||function(h){if(h.length>8192)throw new Error("input is too large");let E=Ve(h),L=h.length*8-c;return L>0?E>>BigInt(L):E},F=r.bits2int_modN||function(h){return s.create(O(h))},P=hr(c);function p(g){return dr("num < 2^"+c,g,Wt,P),s.toBytes(g)}function m(g,h){return q(g,void 0,"message"),h?q(t(g),void 0,"prehashed message"):g}function _(g,h,E){let{lowS:L,prehash:R,extraEntropy:N}=Wo(E,b);g=m(g,R);let K=F(g),V=s.fromBytes(h);if(!s.isValidNot0(V))throw new Error("invalid private key");let $=[p(V),p(K)];if(N!=null&&N!==!1){let W=N===!0?n(B.secretKey):N;$.push(q(W,void 0,"extraEntropy"))}let X=bt(...$),Y=K;function H(W){let ct=O(W);if(!s.isValidNot0(ct))return;let Nt=s.inv(ct),J=e.BASE.multiply(ct).toAffine(),lt=s.create(J.x);if(lt===Wt)return;let Kr=s.create(Nt*s.create(Y+lt*V));if(Kr===Wt)return;let xi=(J.x===lt?0:2)|Number(J.y&Ge),wi=Kr;return L&&v(Kr)&&(wi=s.neg(Kr),xi^=1),new k(lt,wi,C?void 0:xi)}return{seed:X,k2sig:H}}function U(g,h,E={}){let{seed:L,k2sig:R}=_(g,h,E);return hs(t.outputLen,s.BYTES,o)(L,R).toBytes(E.format)}function A(g,h,E,L={}){let{lowS:R,prehash:N,format:K}=Wo(L,b);if(E=q(E,void 0,"publicKey"),h=m(h,N),!be(g)){let V=g instanceof k?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+V)}S(g,K);try{let V=k.fromBytes(g,K),$=e.fromBytes(E);if(R&&V.hasHighS())return!1;let{r:X,s:Y}=V,H=F(h),W=s.inv(Y),ct=s.create(H*W),Nt=s.create(X*W),J=e.BASE.multiplyUnsafe(ct).add($.multiplyUnsafe(Nt));return J.is0()?!1:s.create(J.x)===X}catch{return!1}}function y(g,h,E={}){let{prehash:L}=Wo(E,b);return h=m(h,L),k.fromBytes(g,"recovered").recoverPublicKey(h).toBytes()}return Object.freeze({keygen:f,getPublicKey:u,getSharedSecret:l,utils:w,lengths:B,Point:e,sign:U,verify:A,recoverPublicKey:y,Signature:k,hash:t})}var ei={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},yl={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var pa=BigInt(2);function gl(e){let t=ei.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=e*e*e%t,u=f*f*e%t,l=G(u,r,t)*u%t,w=G(l,r,t)*u%t,B=G(w,pa,t)*f%t,b=G(B,o,t)*B%t,C=G(b,i,t)*b%t,v=G(C,a,t)*C%t,x=G(v,c,t)*v%t,T=G(x,a,t)*C%t,S=G(T,r,t)*u%t,k=G(S,s,t)*b%t,O=G(k,n,t)*f%t,F=G(O,pa,t);if(!ti.eql(ti.sqr(F),e))throw new Error("Cannot find square root");return F}var ti=Fe(ei.p,{sqrt:gl}),bl=fa(ei,{Fp:ti,endo:yl}),Xe=ha(bl,Me);function ma(e,t,r,n){let o=Gn.digest(r instanceof Uint8Array?r:r.subarray());if(en(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Xe.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new yr(String(i))});try{return n?.signal?.throwIfAborted(),Xe.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new yr(String(i))}}var fn=class{type="secp256k1";raw;_key;constructor(t){this._key=ga(t),this.raw=ya(this._key)}toMultihash(){return ge.digest(ie(this))}toCID(){return ut.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,r,n){return ma(this._key,r,t,n)}};function ba(e){return new fn(e)}function ya(e){return Xe.Point.fromBytes(e).toBytes()}function ga(e){try{return Xe.Point.fromBytes(e),e}catch(t){throw new _e(String(t))}}function xa(e,t){let{Type:r,Data:n}=Xt.decode(e),o=n??new Uint8Array;switch(r){case nt.RSA:return jo(o,t);case nt.Ed25519:return Vs(o);case nt.secp256k1:return ba(o);case nt.ECDSA:return ji(o);default:throw new Vr}}function ie(e){return Xt.encode({Type:nt[e.type],Data:e.raw})}function xl(e,t){if(typeof e=="string")return wl(e);if(typeof e=="number")return Al(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var ln=xl;function wl(e){if(typeof e!="string"||e.length===0||e.length>100)throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(e)}`);let t=/^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(e);if(!t?.groups)return NaN;let{value:r,unit:n="ms"}=t.groups,o=parseFloat(r),i=n.toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return o*315576e5;case"months":case"month":case"mo":return o*26298e5;case"weeks":case"week":case"w":return o*6048e5;case"days":case"day":case"d":return o*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return o*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return o*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return o*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:throw Error(`Unknown unit "${i}" provided to ms.parse(). value=${JSON.stringify(e)}`)}}function El(e){let t=Math.abs(e);return t>=315576e5?`${Math.round(e/315576e5)}y`:t>=26298e5?`${Math.round(e/26298e5)}mo`:t>=6048e5?`${Math.round(e/6048e5)}w`:t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function Sl(e){let t=Math.abs(e);return t>=315576e5?Te(e,t,315576e5,"year"):t>=26298e5?Te(e,t,26298e5,"month"):t>=6048e5?Te(e,t,6048e5,"week"):t>=864e5?Te(e,t,864e5,"day"):t>=36e5?Te(e,t,36e5,"hour"):t>=6e4?Te(e,t,6e4,"minute"):t>=1e3?Te(e,t,1e3,"second"):`${e} ms`}function Al(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?Sl(e):El(e)}function Te(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function ri(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=ln,r.destroy=f,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let l=0;for(let w=0;w<u.length;w++)l=(l<<5)-l+u.charCodeAt(w),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(u,l){let w,B=null,b,C;function v(...x){if(!v.enabled)return;let T=v,S=Number(new Date),k=S-(w||S);T.diff=k,T.prev=w,T.curr=S,w=S,x[0]=r.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let O=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(P,p)=>{if(P==="%%")return"%";O++;let m=r.formatters[p];if(typeof m=="function"){let _=x[O];P=m.call(T,_),x.splice(O,1),O--}return P}),r.formatArgs.call(T,x),l?.onLog!=null&&l.onLog(...x),(T.log||r.log).apply(T,x)}return v.namespace=u,v.useColors=r.useColors(),v.color=r.selectColor(u),v.extend=n,v.destroy=r.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>B!==null?B:(b!==r.namespaces&&(b=r.namespaces,C=r.enabled(u)),C),set:x=>{B=x}}),typeof r.init=="function"&&r.init(v),v}function n(u,l){let w=r(this.namespace+(typeof l>"u"?":":l)+u);return w.log=this.log,w}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,w=(typeof u=="string"?u:"").split(/[\s,]+/),B=w.length;for(l=0;l<B;l++)w[l]&&(u=w[l].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,w;for(l=0,w=r.skips.length;l<w;l++)if(r.skips[l].test(u))return!1;for(l=0,w=r.names.length;l<w;l++)if(r.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var dn=Ul(),vl=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Bl(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function Cl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+ln(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var Tl=console.debug??console.log??(()=>{});function Il(e){try{e?dn?.setItem("debug",e):dn?.removeItem("debug")}catch{}}function _l(){let e;try{e=dn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function Ul(){try{return localStorage}catch{}}function Dl(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var wa=ri({formatArgs:Cl,save:Il,load:_l,useColors:Bl,setupFormatters:Dl,colors:vl,storage:dn,log:Tl});var xt=wa;xt.formatters.b=e=>e==null?"undefined":rt.baseEncode(e);xt.formatters.t=e=>e==null?"undefined":ee.baseEncode(e);xt.formatters.m=e=>e==null?"undefined":qn.baseEncode(e);xt.formatters.p=e=>e==null?"undefined":e.toString();xt.formatters.c=e=>e==null?"undefined":e.toString();xt.formatters.k=e=>e==null?"undefined":e.toString();xt.formatters.a=e=>e==null?"undefined":e.toString();function Ea(e,t=""){let r=Sa(e.message),n=Sa(e.stack);return r!=null&&n!=null?n.includes(r)?`${n.split(`
|
|
`).join(`
|
|
${t}`)}`:`${r}
|
|
${t}${n.split(`
|
|
`).join(`
|
|
${t}`)}`:n!=null?`${n.split(`
|
|
`).join(`
|
|
${t}`)}`:r!=null?`${r}`:`${e.toString()}`}function Ll(e){return e instanceof AggregateError||e?.name==="AggregateError"&&Array.isArray(e.errors)}function Aa(e,t=""){if(Ll(e)){let r=Ea(e,t);return e.errors.length>0?(t=`${t} `,r+=`
|
|
${t}${e.errors.map(n=>`${Aa(n,`${t}`)}`).join(`
|
|
${t}`)}`):r+=`
|
|
${t}[Error list was empty]`,r.trim()}return Ea(e,t)}xt.formatters.e=e=>e==null?"undefined":Aa(e);function Rl(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function vr(e,t){let r=Rl(`${e}:trace`);return xt.enabled(`${e}:trace`)&&xt.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=xt(`${e}:trace`,t)),Object.assign(xt(e,t),{error:xt(`${e}:error`,t),trace:r,newScope:n=>vr(`${e}:${n}`,t)})}function Sa(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var yi=Xc(va(),1);var hn=class extends Error{static name="SignatureCreationError";constructor(t="Record signature creation failed"){super(t),this.name="SignatureCreationError"}},Jt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}};var Br=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}};var Cr=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},pn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}};var At;(function(e){let t;(function(a){a.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(a){a[a.EOL=0]="EOL"})(r||(r={})),(function(a){a.codec=()=>Er(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=je((a,c,f={})=>{f.lengthDelimited!==!1&&c.fork(),a.value!=null&&(c.uint32(10),c.bytes(a.value)),a.signatureV1!=null&&(c.uint32(18),c.bytes(a.signatureV1)),a.validityType!=null&&(c.uint32(24),e.ValidityType.codec().encode(a.validityType,c)),a.validity!=null&&(c.uint32(34),c.bytes(a.validity)),a.sequence!=null&&(c.uint32(40),c.uint64(a.sequence)),a.ttl!=null&&(c.uint32(48),c.uint64(a.ttl)),a.pubKey!=null&&(c.uint32(58),c.bytes(a.pubKey)),a.signatureV2!=null&&(c.uint32(66),c.bytes(a.signatureV2)),a.data!=null&&(c.uint32(74),c.bytes(a.data)),f.lengthDelimited!==!1&&c.ldelim()},(a,c,f={})=>{let u={},l=c==null?a.len:a.pos+c;for(;a.pos<l;){let w=a.uint32();switch(w>>>3){case 1:{u.value=a.bytes();break}case 2:{u.signatureV1=a.bytes();break}case 3:{u.validityType=e.ValidityType.codec().decode(a);break}case 4:{u.validity=a.bytes();break}case 5:{u.sequence=a.uint64();break}case 6:{u.ttl=a.uint64();break}case 7:{u.pubKey=a.bytes();break}case 8:{u.signatureV2=a.bytes();break}case 9:{u.data=a.bytes();break}default:{a.skipType(w&7);break}}}return u},function*(a,c,f,u={}){let l=c==null?a.len:a.pos+c;for(;a.pos<l;){let w=a.uint32();switch(w>>>3){case 1:{yield{field:`${f}.value`,value:a.bytes()};break}case 2:{yield{field:`${f}.signatureV1`,value:a.bytes()};break}case 3:{yield{field:`${f}.validityType`,value:e.ValidityType.codec().decode(a)};break}case 4:{yield{field:`${f}.validity`,value:a.bytes()};break}case 5:{yield{field:`${f}.sequence`,value:a.uint64()};break}case 6:{yield{field:`${f}.ttl`,value:a.uint64()};break}case 7:{yield{field:`${f}.pubKey`,value:a.bytes()};break}case 8:{yield{field:`${f}.signatureV2`,value:a.bytes()};break}case 9:{yield{field:`${f}.data`,value:a.bytes()};break}default:{a.skipType(w&7);break}}}})),n);function o(a){return ze(a,e.codec())}e.encode=o;function i(a,c){return He(a,e.codec(),c)}e.decode=i;function s(a,c){return Ze(a,e.codec(),c)}e.stream=s})(At||(At={}));var kl=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function oi(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=Nl(e);return r||"Object"}function Nl(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(kl.includes(t))return t}var d=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}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};d.uint=new d(0,"uint",!0);d.negint=new d(1,"negint",!0);d.bytes=new d(2,"bytes",!0);d.string=new d(3,"string",!0);d.array=new d(4,"array",!1);d.map=new d(5,"map",!1);d.tag=new d(6,"tag",!1);d.float=new d(7,"float",!0);d.false=new d(7,"false",!0);d.true=new d(7,"true",!0);d.null=new d(7,"null",!0);d.undefined=new d(7,"undefined",!0);d.break=new d(7,"break",!0);var D=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 Tr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Kl=new TextEncoder;function mn(e){return Tr&&globalThis.Buffer.isBuffer(e)}function Ir(e){return e instanceof Uint8Array?mn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Ol=24,Ml=200,yn=Tr?e=>e.length>=Ol?globalThis.Buffer.from(e):Ba(e):e=>e.length>=Ml?Kl.encode(e):Ba(e),Vt=e=>Uint8Array.from(e),Ca=Tr?(e,t,r)=>mn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Ta=Tr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ir(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},Ia=Tr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function gn(e,t){if(mn(e)&&mn(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 Ba(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var Vl=256,_r=class{constructor(t=Vl){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=Ia(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=Ca(n,0,this.cursor)}else r=Ta(this.chunks,this.cursor);return t&&this.reset(),r}},bn=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",xn="CBOR encode error:",Ur=[];Ur[23]=1;Ur[24]=2;Ur[25]=3;Ur[26]=5;Ur[27]=9;function Qt(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var at=[24,256,65536,4294967296,BigInt("18446744073709551616")];function vt(e,t,r){Qt(e,t,1);let n=e[t];if(r.strict===!0&&n<at[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Bt(e,t,r){Qt(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<at[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ct(e,t,r){Qt(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<at[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Tt(e,t,r){Qt(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<at[3])throw new Error(`${M} 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(`${M} integers outside of the safe integer range are not supported`)}function _a(e,t,r,n){return new D(d.uint,vt(e,t+1,n),2)}function Ua(e,t,r,n){return new D(d.uint,Bt(e,t+1,n),3)}function Da(e,t,r,n){return new D(d.uint,Ct(e,t+1,n),5)}function La(e,t,r,n){return new D(d.uint,Tt(e,t+1,n),9)}function _t(e,t){return j(e,0,t.value)}function j(e,t,r){if(r<at[0]){let n=Number(r);e.push([t|n])}else if(r<at[1]){let n=Number(r);e.push([t|24,n])}else if(r<at[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<at[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<at[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=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]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${M} encountered BigInt larger than allowable range`)}}_t.encodedSize=function(t){return j.encodedSize(t.value)};j.encodedSize=function(t){return t<at[0]?1:t<at[1]?2:t<at[2]?3:t<at[3]?5:9};_t.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Ra(e,t,r,n){return new D(d.negint,-1-vt(e,t+1,n),2)}function ka(e,t,r,n){return new D(d.negint,-1-Bt(e,t+1,n),3)}function Na(e,t,r,n){return new D(d.negint,-1-Ct(e,t+1,n),5)}var ii=BigInt(-1),Ka=BigInt(1);function Oa(e,t,r,n){let o=Tt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new D(d.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new D(d.negint,ii-BigInt(o),9)}function wn(e,t){let r=t.value,n=typeof r=="bigint"?r*ii-Ka:r*-1-1;j(e,t.type.majorEncoded,n)}wn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*ii-Ka:r*-1-1;return n<at[0]?1:n<at[1]?2:n<at[2]?3:n<at[3]?5:9};wn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Dr(e,t,r,n){Qt(e,t,r+n);let o=e.slice(t+r,t+r+n);return new D(d.bytes,o,r+n)}function Ma(e,t,r,n){return Dr(e,t,1,r)}function Va(e,t,r,n){return Dr(e,t,2,vt(e,t+1,n))}function Pa(e,t,r,n){return Dr(e,t,3,Bt(e,t+1,n))}function Fa(e,t,r,n){return Dr(e,t,5,Ct(e,t+1,n))}function $a(e,t,r,n){let o=Tt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return Dr(e,t,9,o)}function En(e){return e.encodedBytes===void 0&&(e.encodedBytes=d.equals(e.type,d.string)?yn(e.value):e.value),e.encodedBytes}function We(e,t){let r=En(t);j(e,t.type.majorEncoded,r.length),e.push(r)}We.encodedSize=function(t){let r=En(t);return j.encodedSize(r.length)+r.length};We.compareTokens=function(t,r){return Fl(En(t),En(r))};function Fl(e,t){return e.length<t.length?-1:e.length>t.length?1:gn(e,t)}var qa=new TextDecoder,ql=32;function Hl(e,t,r){if(r-t<ql){let o="";for(let i=t;i<r;i++){let s=e[i];if(s&128)return qa.decode(e.subarray(t,r));o+=String.fromCharCode(s)}return o}return qa.decode(e.subarray(t,r))}function Lr(e,t,r,n,o){let i=r+n;Qt(e,t,i);let s=new D(d.string,Hl(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+r,t+i)),s}function Ha(e,t,r,n){return Lr(e,t,1,r,n)}function za(e,t,r,n){return Lr(e,t,2,vt(e,t+1,n),n)}function Za(e,t,r,n){return Lr(e,t,3,Bt(e,t+1,n),n)}function ja(e,t,r,n){return Lr(e,t,5,Ct(e,t+1,n),n)}function Ya(e,t,r,n){let o=Tt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return Lr(e,t,9,o,n)}var Ga=We;function Je(e,t,r,n){return new D(d.array,n,r)}function Xa(e,t,r,n){return Je(e,t,1,r)}function Wa(e,t,r,n){return Je(e,t,2,vt(e,t+1,n))}function Ja(e,t,r,n){return Je(e,t,3,Bt(e,t+1,n))}function Qa(e,t,r,n){return Je(e,t,5,Ct(e,t+1,n))}function tc(e,t,r,n){let o=Tt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return Je(e,t,9,o)}function ec(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Je(e,t,1,1/0)}function Sn(e,t){j(e,d.array.majorEncoded,t.value)}Sn.compareTokens=_t.compareTokens;Sn.encodedSize=function(t){return j.encodedSize(t.value)};function Qe(e,t,r,n){return new D(d.map,n,r)}function rc(e,t,r,n){return Qe(e,t,1,r)}function nc(e,t,r,n){return Qe(e,t,2,vt(e,t+1,n))}function oc(e,t,r,n){return Qe(e,t,3,Bt(e,t+1,n))}function ic(e,t,r,n){return Qe(e,t,5,Ct(e,t+1,n))}function sc(e,t,r,n){let o=Tt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return Qe(e,t,9,o)}function ac(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Qe(e,t,1,1/0)}function An(e,t){j(e,d.map.majorEncoded,t.value)}An.compareTokens=_t.compareTokens;An.encodedSize=function(t){return j.encodedSize(t.value)};function cc(e,t,r,n){return new D(d.tag,r,1)}function uc(e,t,r,n){return new D(d.tag,vt(e,t+1,n),2)}function fc(e,t,r,n){return new D(d.tag,Bt(e,t+1,n),3)}function lc(e,t,r,n){return new D(d.tag,Ct(e,t+1,n),5)}function dc(e,t,r,n){return new D(d.tag,Tt(e,t+1,n),9)}function vn(e,t){j(e,d.tag.majorEncoded,t.value)}vn.compareTokens=_t.compareTokens;vn.encodedSize=function(t){return j.encodedSize(t.value)};var si=20,ai=21,ci=22,ui=23;function hc(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new D(d.null,null,1):new D(d.undefined,void 0,1)}function pc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new D(d.break,void 0,1)}function fi(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${M} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new D(d.float,e,t)}function mc(e,t,r,n){return fi(li(e,t+1),3,n)}function yc(e,t,r,n){return fi(di(e,t+1),5,n)}function gc(e,t,r,n){return fi(Ec(e,t+1),9,n)}function Rr(e,t,r){let n=t.value;if(n===!1)e.push([d.float.majorEncoded|si]);else if(n===!0)e.push([d.float.majorEncoded|ai]);else if(n===null)e.push([d.float.majorEncoded|ci]);else if(n===void 0)e.push([d.float.majorEncoded|ui]);else{let o,i=!1;(!r||r.float64!==!0)&&(xc(n),o=li(Rt,1),n===o||Number.isNaN(n)?(Rt[0]=249,e.push(Rt.slice(0,3)),i=!0):(wc(n),o=di(Rt,1),n===o&&(Rt[0]=250,e.push(Rt.slice(0,5)),i=!0))),i||(Gl(n),o=Ec(Rt,1),Rt[0]=251,e.push(Rt.slice(0,9)))}}Rr.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){xc(n);let o=li(Rt,1);if(n===o||Number.isNaN(n))return 3;if(wc(n),o=di(Rt,1),n===o)return 5}return 9};var bc=new ArrayBuffer(9),Ut=new DataView(bc,1),Rt=new Uint8Array(bc,0);function xc(e){if(e===1/0)Ut.setUint16(0,31744,!1);else if(e===-1/0)Ut.setUint16(0,64512,!1);else if(Number.isNaN(e))Ut.setUint16(0,32256,!1);else{Ut.setFloat32(0,e);let t=Ut.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Ut.setUint16(0,31744,!1);else if(r===0)Ut.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Ut.setUint16(0,0):o<-14?Ut.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ut.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function li(e,t){if(e.length-t<2)throw new Error(`${M} 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 wc(e){Ut.setFloat32(0,e,!1)}function di(e,t){if(e.length-t<4)throw new Error(`${M} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Gl(e){Ut.setFloat64(0,e,!1)}function Ec(e,t){if(e.length-t<8)throw new Error(`${M} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Rr.compareTokens=_t.compareTokens;function z(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Bn(e){return()=>{throw new Error(`${M} ${e}`)}}var I=[];for(let e=0;e<=23;e++)I[e]=z;I[24]=_a;I[25]=Ua;I[26]=Da;I[27]=La;I[28]=z;I[29]=z;I[30]=z;I[31]=z;for(let e=32;e<=55;e++)I[e]=z;I[56]=Ra;I[57]=ka;I[58]=Na;I[59]=Oa;I[60]=z;I[61]=z;I[62]=z;I[63]=z;for(let e=64;e<=87;e++)I[e]=Ma;I[88]=Va;I[89]=Pa;I[90]=Fa;I[91]=$a;I[92]=z;I[93]=z;I[94]=z;I[95]=Bn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)I[e]=Ha;I[120]=za;I[121]=Za;I[122]=ja;I[123]=Ya;I[124]=z;I[125]=z;I[126]=z;I[127]=Bn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)I[e]=Xa;I[152]=Wa;I[153]=Ja;I[154]=Qa;I[155]=tc;I[156]=z;I[157]=z;I[158]=z;I[159]=ec;for(let e=160;e<=183;e++)I[e]=rc;I[184]=nc;I[185]=oc;I[186]=ic;I[187]=sc;I[188]=z;I[189]=z;I[190]=z;I[191]=ac;for(let e=192;e<=215;e++)I[e]=cc;I[216]=uc;I[217]=fc;I[218]=lc;I[219]=dc;I[220]=z;I[221]=z;I[222]=z;I[223]=z;for(let e=224;e<=243;e++)I[e]=Bn("simple values are not supported");I[244]=z;I[245]=z;I[246]=z;I[247]=hc;I[248]=Bn("simple values are not supported");I[249]=mc;I[250]=yc;I[251]=gc;I[252]=z;I[253]=z;I[254]=z;I[255]=pc;var kt=[];for(let e=0;e<24;e++)kt[e]=new D(d.uint,e,1);for(let e=-1;e>=-24;e--)kt[31-e]=new D(d.negint,e,1);kt[64]=new D(d.bytes,new Uint8Array(0),1);kt[96]=new D(d.string,"",1);kt[128]=new D(d.array,0,1);kt[160]=new D(d.map,0,1);kt[244]=new D(d.false,!1,1);kt[245]=new D(d.true,!0,1);kt[246]=new D(d.null,null,1);function hi(e){switch(e.type){case d.false:return Vt([244]);case d.true:return Vt([245]);case d.null:return Vt([246]);case d.bytes:return e.value.length?void 0:Vt([64]);case d.string:return e.value===""?Vt([96]):void 0;case d.array:return e.value===0?Vt([128]):void 0;case d.map:return e.value===0?Vt([160]):void 0;case d.uint:return e.value<24?Vt([Number(e.value)]):void 0;case d.negint:if(e.value>=-24)return Vt([31-Number(e.value)])}}var Wl={float64:!1,mapSorter:td,quickEncodeToken:hi},Cc=Object.freeze({float64:!0,mapSorter:ed,quickEncodeToken:hi});function Jl(){let e=[];return e[d.uint.major]=_t,e[d.negint.major]=wn,e[d.bytes.major]=We,e[d.string.major]=Ga,e[d.array.major]=Sn,e[d.map.major]=An,e[d.tag.major]=vn,e[d.float.major]=Rr,e}var er=Jl(),Cn=new _r,Nr=class e{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(`${xn} object contains circular references`);return new e(r,t)}},pe={null:new D(d.null,null),undefined:new D(d.undefined,void 0),true:new D(d.true,!0),false:new D(d.false,!1),emptyArray:new D(d.array,0),emptyMap:new D(d.map,0)},Pt={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new D(d.float,e):e>=0?new D(d.uint,e):new D(d.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new D(d.uint,e):new D(d.negint,e)},Uint8Array(e,t,r,n){return new D(d.bytes,e)},string(e,t,r,n){return new D(d.string,e)},boolean(e,t,r,n){return e?pe.true:pe.false},null(e,t,r,n){return pe.null},undefined(e,t,r,n){return pe.undefined},ArrayBuffer(e,t,r,n){return new D(d.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new D(d.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[pe.emptyArray,new D(d.break)]:pe.emptyArray;n=Nr.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=tr(s,r,n);return r.addBreakTokens?[new D(d.array,e.length),o,new D(d.break)]:[new D(d.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length,a;if(s){a=new Array(s),n=Nr.createCheck(n,e);let c=!o&&r.ignoreUndefinedProperties,f=0;for(let u of i){let l=o?e.get(u):e[u];c&&l===void 0||(a[f++]=[tr(u,r,n),tr(l,r,n)])}f<s&&(a.length=f)}return a?.length?(Ql(a,r),r.addBreakTokens?[new D(d.map,a.length),a,new D(d.break)]:[new D(d.map,a.length),a]):r.addBreakTokens===!0?[pe.emptyMap,new D(d.break)]:pe.emptyMap},Tagged(e,t,r,n){return[new D(d.tag,e.tag),tr(e.value,r,n)]}};Pt.Map=Pt.Object;Pt.Buffer=Pt.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Pt[`${e}Array`]=Pt.DataView;function tr(e,t={},r){let n=oi(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Pt[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Pt[n];if(!i)throw new Error(`${xn} unsupported type: ${n}`);return i(e,n,t,r)}function Ql(e,t){t.mapSorter&&e.sort(t.mapSorter)}function td(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=er[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function ed(e,t){if(e[0]instanceof D&&t[0]instanceof D){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=Sc(r.value)),n._keyBytes||(n._keyBytes=Sc(n.value)),gn(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Sc(e){return Ic(e,er,Cc)}function kr(e,t,r,n){if(Array.isArray(t))for(let o of t)kr(e,o,r,n);else r[t.type.major](e,t,n)}var Ac=d.uint.majorEncoded,vc=d.negint.majorEncoded,rd=d.bytes.majorEncoded,nd=d.string.majorEncoded,Bc=d.array.majorEncoded,od=d.float.majorEncoded|si,id=d.float.majorEncoded|ai,sd=d.float.majorEncoded|ci,ad=d.float.majorEncoded|ui,cd=BigInt(-1),ud=BigInt(1);function fd(e){return e.addBreakTokens!==!0}function Tc(e,t,r,n){let o=oi(t),i=r.typeEncoders&&r.typeEncoders[o];if(i){let s=i(t,o,r,n);if(s!=null){kr(e,s,er,r);return}}switch(o){case"null":e.push([sd]);return;case"undefined":e.push([ad]);return;case"boolean":e.push([t?id:od]);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?Rr(e,new D(d.float,t),r):t>=0?j(e,Ac,t):j(e,vc,t*-1-1);return;case"bigint":t>=BigInt(0)?j(e,Ac,t):j(e,vc,t*cd-ud);return;case"string":{let s=yn(t);j(e,nd,s.length),e.push(s);return}case"Uint8Array":j(e,rd,t.length),e.push(t);return;case"Array":if(!t.length){e.push([Bc]);return}n=Nr.createCheck(n,t),j(e,Bc,t.length);for(let s of t)Tc(e,s,r,n);return;case"Object":case"Map":{let s=Pt.Object(t,o,r,n);kr(e,s,er,r)}return;default:{let s=Pt[o];if(!s)throw new Error(`${xn} unsupported type: ${o}`);let a=s(t,o,r,n);kr(e,a,er,r)}}}function Ic(e,t,r,n){let o=n instanceof Uint8Array,i=o?new bn(n):Cn,s=tr(e,r);if(!Array.isArray(s)&&r.quickEncodeToken){let a=r.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let f=c.encodedSize(s,r);if(o||(i=new _r(f)),c(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():Ir(i.chunks[0])}}return i.reset(),kr(i,s,t,r),i.toBytes(!0)}function pi(e,t){return t=Object.assign({},Wl,t),fd(t)?(Cn.reset(),Tc(Cn,e,t,void 0),Cn.toBytes(!0)):Ic(e,er,t)}var ld={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Tn=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=kt[t];if(r===void 0){let n=I[t];if(!n)throw new Error(`${M} 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}},me=Symbol.for("DONE"),rr=Symbol.for("BREAK");function dd(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=ye(t,r);if(i===rr){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===me)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function hd(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<e.value;a++){let c=ye(t,r);if(c===rr){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===me)throw new Error(`${M} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!n&&typeof c!="string")throw new Error(`${M} non-string keys not supported (got ${typeof c})`);if(o&&(n&&s.has(c)||!n&&Object.hasOwn(i,c)))throw new Error(`${M} found repeat map key "${c}"`);let f=ye(t,r);if(f===me)throw new Error(`${M} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?s.set(c,f):i[c]=f}return n?s:i}function*pd(e,t,r){for(let n=0;n<e.value;n++){let o=ye(t,r);if(o===rr){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(o===me)throw new Error(`${M} found map but not enough entries (got ${n} [no key], expected ${e.value})`);let i=ye(t,r);if(i===me)throw new Error(`${M} found map but not enough entries (got ${n} [no value], expected ${e.value})`);yield[o,i]}}function md(e,t){let r=!1,n=function(){if(r)throw new Error(`${M} tag decode() may only be called once`);r=!0;let o=ye(e,t);if(o===me)throw new Error(`${M} tag content missing`);if(o===rr)throw new Error(`${M} got unexpected break in tag content`);return o};return n.entries=function(){if(r)throw new Error(`${M} tag decode() may only be called once`);r=!0;let o=e.next();if(!d.equals(o.type,d.map))throw new Error(`${M} entries() requires map content, got ${o.type.name}`);let i=[];for(let s of pd(o,e,t))i.push(s);return i},Object.defineProperty(n,"_called",{get(){return r},enumerable:!1}),n}function ye(e,t){if(e.done())return me;let r=e.next();if(d.equals(r.type,d.break))return rr;if(r.type.terminal)return r.value;if(d.equals(r.type,d.array))return dd(r,e,t);if(d.equals(r.type,d.map))return hd(r,e,t);if(d.equals(r.type,d.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=md(e,t),o=t.tags[r.value](n);if(!n._called)throw new Error(`${M} tag decoder must call decode() or entries()`);return o}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function _c(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},ld,t);let r=Ir(e),n=t.tokenizer||new Tn(r,t),o=ye(n,t);if(o===me)throw new Error(`${M} did not find any content to decode`);if(o===rr)throw new Error(`${M} got unexpected break`);return[o,e.subarray(n.pos())]}function mi(e,t){let[r,n]=_c(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var In=class e{constructor(t,r){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=r}static decoder(t){return r=>new e(t,r())}static preserve(...t){let r={};for(let n of t)r[n]=e.decoder(n);return r}};Object.defineProperty(In.prototype,Symbol.toStringTag,{value:"Tagged"});var gd=vr("ipns:utils"),Dc=Z("/ipns/"),bd=114,xd=0,wd=18;function Lc(e){let t;if(e.pubKey!=null)try{t=xa(e.pubKey)}catch(r){throw gd.error(r),r}if(t!=null)return t}function Rc(e,t,r){let n=Z(t);return ne([e,r,n])}function kc(e){let t=Z("ipns-signature:");return ne([t,e])}function Nc(e){return"signatureV1"in e?At.encode({value:Z(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:Z(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):At.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function Kc(e){let t=At.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Jt("Missing data or signatureV2");let r=Pc(t.data),n=Ed(r.Value),o=tt(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Sd(t),{value:n,validityType:At.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:At.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function Oc(e){return ne([Dc,e.bytes])}function Mc(e){let t=Fr(e.slice(Dc.length));if(!Uc(t,xd)&&!Uc(t,wd))throw new Mr("Multihash in IPNS key was not identity or sha2-256");return t}function Vc(e,t,r,n,o){let i;if(t===At.ValidityType.EOL)i=0;else throw new Br("The validity type is unsupported");return pi({Value:e,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Pc(e){let t=mi(e);if(t.ValidityType===0)t.ValidityType=At.ValidityType.EOL;else throw new Br("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function Ed(e){let t=tt(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${ut.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${ut.parse(t).toV1().toString()}`}catch{}throw new Cr("Value must be a valid content path starting with /")}function Fc(e){if(e!=null){let t=Bd(e);if(t!=null)return t.code===bd?`/ipns/${t.toString(re)}`:`/ipfs/${t.toV1().toString()}`;if(Ad(e))return`/ipns/${re.encode(e.bytes)}`;let r=e.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new Cr("Value must be a valid content path starting with /")}function Sd(e){if(e.data==null)throw new pn("Record data is missing");let t=Pc(e.data);if(!yt(t.Value,e.value??new Uint8Array(0)))throw new Jt('Field "value" did not match between protobuf and CBOR');if(!yt(t.Validity,e.validity??new Uint8Array(0)))throw new Jt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Jt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Jt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Jt('Field "ttl" did not match between protobuf and CBOR')}function Ad(e){return e.bytes instanceof Uint8Array}function vd(e){return typeof e?.toCID=="function"}function Bd(e){if(vd(e))return e.toCID();try{return ut.parse(e)}catch{}return ut.asCID(e)}function Uc(e,t){return e.code===t}var Cd=vr("ipns"),gi=300*1e9,$c="/ipns/",Td=$c.length,bi={v1Compatible:!0,ttlNs:gi};async function Id(e,t,r,n,o=bi){let i=new yi.default(Date.now()+Number(n)),s=At.ValidityType.EOL,a=BigInt(o.ttlNs??gi);return qc(e,t,r,s,i.toString(),a,o)}async function _d(e,t,r,n,o=bi){let i=yi.default.fromString(n),s=At.ValidityType.EOL,a=BigInt(o.ttlNs??gi);return qc(e,t,r,s,i.toString(),a,o)}var qc=async(e,t,r,n,o,i,s=bi)=>{r=BigInt(r);let a=Z(o),c=Fc(t),f=Z(c),u=Vc(f,n,a,r,i),l=kc(u),w=await e.sign(l),B;if(e.type==="RSA"&&(B=ie(e.publicKey)),s.v1Compatible===!0){let b=await Ud(e,f,n,a),C={value:c,signatureV1:b,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:w,data:u};return B!=null&&(C.pubKey=B),C}else{let b={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:w,data:u};return B!=null&&(b.pubKey=B),b}},Ud=async(e,t,r,n)=>{try{let o=Rc(t,r,n);return await e.sign(o)}catch(o){throw Cd.error("record signature creation failed",o),new hn("Record signature creation failed")}};return Wc(Dd);})();
|
|
/*! Bundled license information:
|
|
|
|
@noble/hashes/utils.js:
|
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
|
|
@noble/curves/utils.js:
|
|
@noble/curves/abstract/modular.js:
|
|
@noble/curves/abstract/curve.js:
|
|
@noble/curves/abstract/edwards.js:
|
|
@noble/curves/ed25519.js:
|
|
@noble/curves/abstract/weierstrass.js:
|
|
@noble/curves/secp256k1.js:
|
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
*/
|
|
return Ipns}));
|
|
//# sourceMappingURL=index.min.js.map
|