@libp2p/peer-record
Version:
Used to transfer signed peer data across the network
2 lines • 114 kB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerRecord = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var Libp2PPeerRecord=(()=>{var Nr=Object.defineProperty;var _i=Object.getOwnPropertyDescriptor;var Ki=Object.getOwnPropertyNames;var Ri=Object.prototype.hasOwnProperty;var gt=(r,t)=>{for(var e in t)Nr(r,e,{get:t[e],enumerable:!0})},Ni=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ki(t))!Ri.call(r,o)&&o!==e&&Nr(r,o,{get:()=>t[o],enumerable:!(n=_i(t,o))||n.enumerable});return r};var ki=r=>Ni(Nr({},"__esModule",{value:!0}),r);var Yu={};gt(Yu,{PeerRecord:()=>Rr,RecordEnvelope:()=>vr});var kr=Symbol.for("@libp2p/peer-id");var ot=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ye=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var er=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var ge=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Vr={};gt(Vr,{base58btc:()=>$,base58flickr:()=>Fi});var tf=new Uint8Array(0);function Uo(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Kt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Do(r){return new TextEncoder().encode(r)}function _o(r){return new TextDecoder().decode(r)}function Oi(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var y=0,h=0,b=0,v=E.length;b!==v&&E[b]===0;)b++,y++;for(var m=(v-b)*u+1>>>0,B=new Uint8Array(m);b!==v;){for(var D=E[b],U=0,T=m-1;(D!==0||U<h)&&T!==-1;T--,U++)D+=256*B[T]>>>0,B[T]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");h=U,b++}for(var P=m-h;P!==m&&B[P]===0;)P++;for(var L=c.repeat(y);P<m;++P)L+=r.charAt(B[P]);return L}function p(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var y=0;if(E[y]!==" "){for(var h=0,b=0;E[y]===c;)h++,y++;for(var v=(E.length-y)*f+1>>>0,m=new Uint8Array(v);E[y];){var B=e[E.charCodeAt(y)];if(B===255)return;for(var D=0,U=v-1;(B!==0||D<b)&&U!==-1;U--,D++)B+=a*m[U]>>>0,m[U]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");b=D,y++}if(E[y]!==" "){for(var T=v-b;T!==v&&m[T]===0;)T++;for(var P=new Uint8Array(h+(v-T)),L=h;T!==v;)P[L++]=m[T++];return P}}}function w(E){var y=p(E);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:p,decode:w}}var Mi=Oi,qi=Mi,Ro=qi;var Or=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Mr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.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 No(this,t)}},qr=class{decoders;constructor(t){this.decoders=t}or(t){return No(this,t)}decode(t){let e=t[0],n=this.decoders[e];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 No(r,t){return new qr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Hr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Or(t,e,n),this.decoder=new Mr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function be({name:r,prefix:t,encode:e,decode:n}){return new Hr(r,t,e,n)}function Gt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ro(e,r);return be({prefix:t,name:r,encode:n,decode:s=>Kt(o(s))})}function Hi(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,c=0,f=0;for(let u=0;u<s;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|l,a+=e,a>=8&&(a-=8,i[f++]=255&c>>a)}if(a>=e||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return i}function Vi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function J({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return be({prefix:t,name:r,encode(o){return Vi(o,n,e)},decode(o){return Hi(o,n,e,r)}})}var $=Gt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fi=Gt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Fr={};gt(Fr,{base32:()=>Rt,base32hex:()=>Zi,base32hexpad:()=>Wi,base32hexpadupper:()=>Yi,base32hexupper:()=>$i,base32pad:()=>Gi,base32padupper:()=>ji,base32upper:()=>zi,base32z:()=>Xi});var Rt=J({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zi=J({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gi=J({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ji=J({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Zi=J({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$i=J({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wi=J({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Yi=J({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Xi=J({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var zr={};gt(zr,{base36:()=>Ke,base36upper:()=>Ji});var Ke=Gt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ji=Gt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qi=Mo,ko=128,ta=127,ea=~ta,ra=Math.pow(2,31);function Mo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ra;)t[e++]=r&255|ko,r/=128;for(;r&ea;)t[e++]=r&255|ko,r>>>=7;return t[e]=r|0,Mo.bytes=e-n+1,t}var na=Gr,oa=128,Oo=127;function Gr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Gr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Oo)<<o:(i&Oo)*Math.pow(2,o),o+=7}while(i>=oa);return Gr.bytes=s-n,e}var sa=Math.pow(2,7),ia=Math.pow(2,14),aa=Math.pow(2,21),ca=Math.pow(2,28),ua=Math.pow(2,35),fa=Math.pow(2,42),la=Math.pow(2,49),ha=Math.pow(2,56),da=Math.pow(2,63),pa=function(r){return r<sa?1:r<ia?2:r<aa?3:r<ca?4:r<ua?5:r<fa?6:r<la?7:r<ha?8:r<da?9:10},ma={encode:Qi,decode:na,encodingLength:pa},ya=ma,Re=ya;function Ne(r,t=0){return[Re.decode(r,t),Re.decode.bytes]}function xe(r,t,e=0){return Re.encode(r,t,e),t}function we(r){return Re.encodingLength(r)}function It(r,t){let e=t.byteLength,n=we(r),o=n+we(e),s=new Uint8Array(o+e);return xe(r,s,0),xe(e,s,n),s.set(t,o),new Ee(r,e,t,s)}function oe(r){let t=Kt(r),[e,n]=Ne(t),[o,s]=Ne(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Ee(e,o,i,t)}function qo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Uo(r.bytes,e.bytes)}}var Ee=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Ho(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ba(e,jr(r),t??$.encoder);default:return xa(e,jr(r),t??Rt.encoder)}}var Vo=new WeakMap;function jr(r){let t=Vo.get(r);if(t==null){let e=new Map;return Vo.set(r,e),e}return t}var rt=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==wa)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=It(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&qo(t.multihash,n.multihash)}toString(t){return Ho(this,t)}toJSON(){return{"/":Ho(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 e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Fo(n,o,s.bytes))}else if(e[Ea]===!0){let{version:n,multihash:o,code:s}=e,i=oe(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="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(e!==ke)throw new Error(`Version 0 CID must use dag-pb (code: ${ke}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Fo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ke,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Kt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new Ee(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,p]=Ne(t.subarray(e));return e+=p,l},o=n(),s=ke;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),f=e+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,e){let[n,o]=ga(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return jr(s).set(n,t),s}};function ga(r,t){switch(r[0]){case"Q":{let e=t??$;return[$.prefix,e.decode(`${$.prefix}${r}`)]}case $.prefix:{let e=t??$;return[$.prefix,e.decode(r)]}case Rt.prefix:{let e=t??Rt;return[Rt.prefix,e.decode(r)]}case Ke.prefix:{let e=t??Ke;return[Ke.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function ba(r,t,e){let{prefix:n}=e;if(n!==$.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function xa(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var ke=112,wa=18;function Fo(r,t,e){let n=we(r),o=n+we(t),s=new Uint8Array(o+e.byteLength);return xe(r,s,0),xe(t,s,n),s.set(e,o),s}var Ea=Symbol.for("@ipld/js-cid/CID");var Zr={};gt(Zr,{identity:()=>Tt});var zo=0,Sa="identity",Go=Kt;function Aa(r){return It(zo,Go(r))}var Tt={code:zo,name:Sa,encode:Go,digest:Aa};function at(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function ft(r=0){return new Uint8Array(r)}function bt(r=0){return new Uint8Array(r)}function St(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=bt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Zo=Symbol.for("@achingbrain/uint8arraylist");function jo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function nr(r){return!!r?.[Zo]}var pt=class r{bufs;length;[Zo]=!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 e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(nr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(nr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=jo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=jo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(nr(t))for(let n=0;n<t.length;n++)this.set(e+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,e){let{bufs:n,length:o}=this._subList(t,e);return St(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:St(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let f=t>=a&&t<c,u=e>a&&e<=c;if(f&&u){if(t===a&&e===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(e-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(u){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!nr(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(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=e;l<=c;l+=u){u=0;for(let p=f;p>=0;p--){let w=this.get(l+p);if(n[p]!==w){u=Math.max(1,p-a[w]);break}}if(u===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=ft(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=ft(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=ft(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=ft(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=ft(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=ft(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=ft(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=ft(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!at(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var $r={};gt($r,{base10:()=>va});var va=Gt({prefix:"9",name:"base10",alphabet:"0123456789"});var Wr={};gt(Wr,{base16:()=>Ba,base16upper:()=>Ia});var Ba=J({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ia=J({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Yr={};gt(Yr,{base2:()=>Ta});var Ta=J({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Xr={};gt(Xr,{base256emoji:()=>Da});var $o=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}"),Pa=$o.reduce((r,t,e)=>(r[e]=t,r),[]),La=$o.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Ca(r){return r.reduce((t,e)=>(t+=Pa[e],t),"")}function Ua(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=La[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Da=be({prefix:"\u{1F680}",name:"base256emoji",encode:Ca,decode:Ua});var Jr={};gt(Jr,{base64:()=>_a,base64pad:()=>Ka,base64url:()=>Ra,base64urlpad:()=>Na});var _a=J({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ka=J({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ra=J({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Na=J({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Qr={};gt(Qr,{base8:()=>ka});var ka=J({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var tn={};gt(tn,{identity:()=>Oa});var Oa=be({prefix:"\0",name:"identity",encode:r=>_o(r),decode:r=>Do(r)});var Of=new TextEncoder,Mf=new TextDecoder;var nn={};gt(nn,{sha256:()=>Oe,sha512:()=>Ha});function rn({name:r,code:t,encode:e}){return new en(r,t,e)}var en=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?It(this.code,e):e.then(n=>It(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Yo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Oe=rn({name:"sha2-256",code:18,encode:Yo("SHA-256")}),Ha=rn({name:"sha2-512",code:19,encode:Yo("SHA-512")});var Me={...tn,...Yr,...Qr,...$r,...Wr,...Fr,...zr,...Vr,...Jr,...Xr},Xf={...nn,...Zr};function Jo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Xo=Jo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),on=Jo("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=bt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Va={utf8:Xo,"utf-8":Xo,hex:Me.base16,latin1:on,ascii:on,binary:on,...Me},or=Va;function G(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function k(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Fa=parseInt("11111",2),sn=parseInt("10000000",2),za=parseInt("01111111",2),Qo={0:qe,1:qe,2:Ga,3:$a,4:Wa,5:Za,6:ja,16:qe,22:qe,48:qe};function Nt(r,t={offset:0}){let e=r[t.offset]&Fa;if(t.offset++,Qo[e]!=null)return Qo[e](r,t);throw new Error("No decoder for tag "+e)}function He(r,t){let e=0;if((r[t.offset]&sn)===sn){let n=r[t.offset]&za,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function qe(r,t){He(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Nt(r,t);if(n===null)break;e.push(n)}return e}function Ga(r,t){let e=He(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function ja(r,t){let e=He(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let f=r[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 Za(r,t){return t.offset++,null}function $a(r,t){let e=He(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Wa(r,t){let e=He(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Ya(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new pt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function an(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Ya(r.byteLength);return new pt(Uint8Array.from([t.byteLength|sn]),t)}function xt(r){let t=new pt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new pt(Uint8Array.from([2]),an(t),t)}function sr(r){let t=Uint8Array.from([0]),e=new pt(t,r);return new pt(Uint8Array.from([3]),an(e),e)}function Zt(r,t=48){let e=new pt;for(let n of r)e.append(n);return new pt(Uint8Array.from([t]),an(e),e)}async function ts(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var Xa=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ja=Uint8Array.from([6,5,43,129,4,0,34]),Qa=Uint8Array.from([6,5,43,129,4,0,35]),tc={ext:!0,kty:"EC",crv:"P-256"},ec={ext:!0,kty:"EC",crv:"P-384"},rc={ext:!0,kty:"EC",crv:"P-521"},cn=32,un=48,fn=66;function ln(r){let t=Nt(r);return es(t)}function es(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===cn*2+1)return n=k(t.subarray(e,e+cn),"base64url"),o=k(t.subarray(e+cn),"base64url"),new Se({...tc,key_ops:["verify"],x:n,y:o});if(t.byteLength===un*2+1)return n=k(t.subarray(e,e+un),"base64url"),o=k(t.subarray(e+un),"base64url"),new Se({...ec,key_ops:["verify"],x:n,y:o});if(t.byteLength===fn*2+1)return n=k(t.subarray(e,e+fn),"base64url"),o=k(t.subarray(e+fn),"base64url"),new Se({...rc,key_ops:["verify"],x:n,y:o});throw new ot(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function rs(r){return Zt([xt(Uint8Array.from([1])),Zt([nc(r.crv)],160),Zt([sr(new pt(Uint8Array.from([4]),G(r.x??"","base64url"),G(r.y??"","base64url")))],161)]).subarray()}function nc(r){if(r==="P-256")return Xa;if(r==="P-384")return Ja;if(r==="P-521")return Qa;throw new ot(`Invalid curve ${r}`)}var Se=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=rs(this.jwk)),this._raw}toMultihash(){return Tt.digest($t(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return $.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}async verify(t,e){return ts(this.jwk,e,t)}};function ns(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function oc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ae(r,...t){if(!oc(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function os(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ns(r.outputLen),ns(r.blockLen)}function ve(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function ss(r,t){Ae(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var se=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ir(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Pt(r,t){return r<<32-t|r>>>t}var Dl=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function";function is(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Ve(r){return typeof r=="string"&&(r=is(r)),Ae(r),r}function hn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ae(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Be=class{clone(){return this._cloneInto()}};function ar(r){let t=n=>r().update(Ve(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function cr(r=32){if(se&&typeof se.getRandomValues=="function")return se.getRandomValues(new Uint8Array(r));if(se&&typeof se.randomBytes=="function")return Uint8Array.from(se.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function sc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),a=Number(e&s),c=n?4:0,f=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+f,a,n)}function as(r,t,e){return r&t^~r&e}function cs(r,t,e){return r&t^r&e^t&e}var Ie=class extends Be{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ir(this.buffer)}update(t){ve(this);let{view:e,buffer:n,blockLen:o}=this;t=Ve(t);let s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=ir(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ve(this),ss(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;sc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=ir(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should 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],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.length=o,t.pos=a,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var ic=new Uint32Array([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]),Wt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yt=new Uint32Array(64),dn=class extends Ie{constructor(t=32){super(64,t,8,!1),this.A=Wt[0]|0,this.B=Wt[1]|0,this.C=Wt[2]|0,this.D=Wt[3]|0,this.E=Wt[4]|0,this.F=Wt[5]|0,this.G=Wt[6]|0,this.H=Wt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)Yt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let p=Yt[l-15],w=Yt[l-2],E=Pt(p,7)^Pt(p,18)^p>>>3,y=Pt(w,17)^Pt(w,19)^w>>>10;Yt[l]=y+Yt[l-7]+E+Yt[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=Pt(a,6)^Pt(a,11)^Pt(a,25),w=u+p+as(a,c,f)+ic[l]+Yt[l]|0,y=(Pt(n,2)^Pt(n,13)^Pt(n,22))+cs(n,o,s)|0;u=f,f=c,c=a,a=i+w|0,i=s,s=o,o=n,n=w+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+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,s,i,a,c,f,u)}roundClean(){Yt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ie=ar(()=>new dn);var ur=BigInt(4294967295),pn=BigInt(32);function us(r,t=!1){return t?{h:Number(r&ur),l:Number(r>>pn&ur)}:{h:Number(r>>pn&ur)|0,l:Number(r&ur)|0}}function ac(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=us(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var cc=(r,t)=>BigInt(r>>>0)<<pn|BigInt(t>>>0),uc=(r,t,e)=>r>>>e,fc=(r,t,e)=>r<<32-e|t>>>e,lc=(r,t,e)=>r>>>e|t<<32-e,hc=(r,t,e)=>r<<32-e|t>>>e,dc=(r,t,e)=>r<<64-e|t>>>e-32,pc=(r,t,e)=>r>>>e-32|t<<64-e,mc=(r,t)=>t,yc=(r,t)=>r,gc=(r,t,e)=>r<<e|t>>>32-e,bc=(r,t,e)=>t<<e|r>>>32-e,xc=(r,t,e)=>t<<e-32|r>>>64-e,wc=(r,t,e)=>r<<e-32|t>>>64-e;function Ec(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Sc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Ac=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,vc=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Bc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Ic=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Tc=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Pc={fromBig:us,split:ac,toBig:cc,shrSH:uc,shrSL:fc,rotrSH:lc,rotrSL:hc,rotrBH:dc,rotrBL:pc,rotr32H:mc,rotr32L:yc,rotlSH:gc,rotlSL:bc,rotlBH:xc,rotlBL:wc,add:Ec,add3L:Sc,add3H:Ac,add4L:vc,add4H:Bc,add5H:Tc,add5L:Ic},K=Pc;var[Lc,Cc]=K.split(["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(r=>BigInt(r))),Xt=new Uint32Array(80),Jt=new Uint32Array(80),mn=class extends Ie{constructor(t=64){super(128,t,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:p,Gh:w,Gl:E,Hh:y,Hl:h}=this;return[t,e,n,o,s,i,a,c,f,u,l,p,w,E,y,h]}set(t,e,n,o,s,i,a,c,f,u,l,p,w,E,y,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=w|0,this.Gl=E|0,this.Hh=y|0,this.Hl=h|0}process(t,e){for(let m=0;m<16;m++,e+=4)Xt[m]=t.getUint32(e),Jt[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let B=Xt[m-15]|0,D=Jt[m-15]|0,U=K.rotrSH(B,D,1)^K.rotrSH(B,D,8)^K.shrSH(B,D,7),T=K.rotrSL(B,D,1)^K.rotrSL(B,D,8)^K.shrSL(B,D,7),P=Xt[m-2]|0,L=Jt[m-2]|0,Z=K.rotrSH(P,L,19)^K.rotrBH(P,L,61)^K.shrSH(P,L,6),H=K.rotrSL(P,L,19)^K.rotrBL(P,L,61)^K.shrSL(P,L,6),N=K.add4L(T,H,Jt[m-7],Jt[m-16]),nt=K.add4H(N,U,Z,Xt[m-7],Xt[m-16]);Xt[m]=nt|0,Jt[m]=N|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:p,Fh:w,Fl:E,Gh:y,Gl:h,Hh:b,Hl:v}=this;for(let m=0;m<80;m++){let B=K.rotrSH(l,p,14)^K.rotrSH(l,p,18)^K.rotrBH(l,p,41),D=K.rotrSL(l,p,14)^K.rotrSL(l,p,18)^K.rotrBL(l,p,41),U=l&w^~l&y,T=p&E^~p&h,P=K.add5L(v,D,T,Cc[m],Jt[m]),L=K.add5H(P,b,B,U,Lc[m],Xt[m]),Z=P|0,H=K.rotrSH(n,o,28)^K.rotrBH(n,o,34)^K.rotrBH(n,o,39),N=K.rotrSL(n,o,28)^K.rotrBL(n,o,34)^K.rotrBL(n,o,39),nt=n&s^n&a^s&a,S=o&i^o&c^i&c;b=y|0,v=h|0,y=w|0,h=E|0,w=l|0,E=p|0,{h:l,l:p}=K.add(f|0,u|0,L|0,Z|0),f=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let I=K.add3L(Z,N,S);n=K.add3H(I,L,H,nt),o=I|0}({h:n,l:o}=K.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=K.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=K.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=K.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=K.add(this.Eh|0,this.El|0,l|0,p|0),{h:w,l:E}=K.add(this.Fh|0,this.Fl|0,w|0,E|0),{h:y,l:h}=K.add(this.Gh|0,this.Gl|0,y|0,h|0),{h:b,l:v}=K.add(this.Hh|0,this.Hl|0,b|0,v|0),this.set(n,o,s,i,a,c,f,u,l,p,w,E,y,h,b,v)}roundClean(){Xt.fill(0),Jt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var yn=ar(()=>new mn);var wn=BigInt(0),xn=BigInt(1);function ae(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function En(r){if(!ae(r))throw new Error("Uint8Array expected")}function Ct(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Fe(r){let t=r.toString(16);return t.length&1?"0"+t:t}function hs(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?wn:BigInt("0x"+r)}var ds=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Uc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Qt(r){if(En(r),ds)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Uc[r[e]];return t}var kt={_0:48,_9:57,A:65,F:70,a:97,f:102};function fs(r){if(r>=kt._0&&r<=kt._9)return r-kt._0;if(r>=kt.A&&r<=kt.F)return r-(kt.A-10);if(r>=kt.a&&r<=kt.f)return r-(kt.a-10)}function ze(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(ds)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=fs(r.charCodeAt(s)),a=fs(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Ot(r){return hs(Qt(r))}function ce(r){return En(r),hs(Qt(Uint8Array.from(r).reverse()))}function ue(r,t){return ze(r.toString(16).padStart(t*2,"0"))}function Te(r,t){return ue(r,t).reverse()}function X(r,t,e){let n;if(typeof t=="string")try{n=ze(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ae(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function te(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];En(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var gn=r=>typeof r=="bigint"&&wn<=r;function fr(r,t,e){return gn(r)&&gn(t)&&gn(e)&&t<=r&&r<e}function At(r,t,e,n){if(!fr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function ps(r){let t;for(t=0;r>wn;r>>=xn,t+=1);return t}var fe=r=>(xn<<BigInt(r))-xn,bn=r=>new Uint8Array(r),ls=r=>Uint8Array.from(r);function ms(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=bn(r),o=bn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>e(o,n,...l),c=(l=bn(0))=>{o=a(ls([0]),l),n=a(),l.length!==0&&(o=a(ls([1]),l),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<t;){n=a();let w=n.slice();p.push(w),l+=n.length}return te(...p)};return(l,p)=>{i(),c(l);let w;for(;!(w=p(f()));)c();return i(),w}}var Dc={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ae(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Mt(r,t,e={}){let n=(o,s,i)=>{let a=Dc[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function Pe(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var st=BigInt(0),W=BigInt(1),le=BigInt(2),_c=BigInt(3),Sn=BigInt(4),ys=BigInt(5),gs=BigInt(8),Kc=BigInt(9),Rc=BigInt(16);function z(r,t){let e=r%t;return e>=st?e:t+e}function Nc(r,t,e){if(t<st)throw new Error("invalid exponent, negatives unsupported");if(e<=st)throw new Error("invalid modulus");if(e===W)return st;let n=W;for(;t>st;)t&W&&(n=n*r%e),r=r*r%e,t>>=W;return n}function Y(r,t,e){let n=r;for(;t-- >st;)n*=n,n%=e;return n}function lr(r,t){if(r===st)throw new Error("invert: expected non-zero number");if(t<=st)throw new Error("invert: expected positive modulus, got "+t);let e=z(r,t),n=t,o=st,s=W,i=W,a=st;for(;e!==st;){let f=n/e,u=n%e,l=o-i*f,p=s-a*f;n=e,e=u,o=i,s=a,i=l,a=p}if(n!==W)throw new Error("invert: does not exist");return z(o,t)}function kc(r){let t=(r-W)/le,e,n,o;for(e=r-W,n=0;e%le===st;e/=le,n++);for(o=le;o<r&&Nc(o,t,r)!==r-W;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+W)/Sn;return function(c,f){let u=c.pow(f,i);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(e+W)/le;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),e),l=a.pow(c,s),p=a.pow(c,e);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let w=1;for(let y=a.sqr(p);w<f&&!a.eql(y,a.ONE);w++)y=a.sqr(y);let E=a.pow(u,W<<BigInt(f-w-1));u=a.sqr(E),l=a.mul(l,E),p=a.mul(p,u),f=w}return l}}function Oc(r){if(r%Sn===_c){let t=(r+W)/Sn;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%gs===ys){let t=(r-ys)/gs;return function(n,o){let s=n.mul(o,le),i=n.pow(s,t),a=n.mul(o,i),c=n.mul(n.mul(a,le),i),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%Rc,kc(r)}var bs=(r,t)=>(z(r,t)&W)===W,Mc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function An(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Mc.reduce((n,o)=>(n[o]="function",n),t);return Mt(r,e)}function qc(r,t,e){if(e<st)throw new Error("invalid exponent, negatives unsupported");if(e===st)return r.ONE;if(e===W)return t;let n=r.ONE,o=t;for(;e>st;)e&W&&(n=r.mul(n,o)),o=r.sqr(o),e>>=W;return n}function Hc(r,t){let e=new Array(t.length),n=t.reduce((s,i,a)=>r.is0(i)?s:(e[a]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,a)=>r.is0(i)?s:(e[a]=r.mul(s,e[a]),r.mul(s,i)),o),e}function vn(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function ee(r,t,e=!1,n={}){if(r<=st)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=vn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:fe(o),ZERO:st,ONE:W,create:c=>z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return st<=c&&c<r},is0:c=>c===st,isOdd:c=>(c&W)===W,neg:c=>z(-c,r),eql:(c,f)=>c===f,sqr:c=>z(c*c,r),add:(c,f)=>z(c+f,r),sub:(c,f)=>z(c-f,r),mul:(c,f)=>z(c*f,r),pow:(c,f)=>qc(a,c,f),div:(c,f)=>z(c*lr(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>lr(c,r),sqrt:n.sqrt||(c=>(i||(i=Oc(r)),i(a,c))),invertBatch:c=>Hc(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>e?Te(c,s):ue(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?ce(c):Ot(c)}});return Object.freeze(a)}function xs(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Bn(r){let t=xs(r);return t+Math.ceil(t/2)}function ws(r,t,e=!1){let n=r.length,o=xs(t),s=Bn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?ce(r):Ot(r),a=z(i,t-W)+W;return e?Te(a,o):ue(a,o)}var Es=BigInt(0),Cn=BigInt(1);function In(r,t){let e=t.negate();return r?e:t}function As(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Tn(r,t){As(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=fe(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Ss(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=Cn);let f=t*n,u=f+Math.abs(a)-1,l=a===0,p=a<0,w=t%2!==0;return{nextN:c,offset:u,isZero:l,isNeg:p,isNegF:w,offsetF:f}}function Vc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Fc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Pn=new WeakMap,vs=new WeakMap;function Ln(r){return vs.get(r)||1}function hr(r,t){return{constTimeNegate:In,hasPrecomputes(e){return Ln(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Es;)n&Cn&&(o=o.add(s)),s=s.double(),n>>=Cn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Tn(n,t),i=[],a=e,c=a;for(let f=0;f<o;f++){c=a,i.push(c);for(let u=1;u<s;u++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=Tn(e,t);for(let c=0;c<a.windows;c++){let{nextN:f,offset:u,isZero:l,isNeg:p,isNegF:w,offsetF:E}=Ss(o,c,a);o=f,l?i=i.add(In(w,n[E])):s=s.add(In(p,n[u]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Tn(e,t);for(let a=0;a<i.windows&&o!==Es;a++){let{nextN:c,offset:f,isZero:u,isNeg:l}=Ss(o,a,i);if(o=c,!u){let p=n[f];s=s.add(l?p.negate():p)}}return s},getPrecomputes(e,n,o){let s=Pn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Pn.set(n,o(s))),s},wNAFCached(e,n,o){let s=Ln(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Ln(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){As(n,t),vs.set(e,n),Pn.delete(e)}}}function dr(r,t,e,n){if(Vc(e,r),Fc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=ps(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,a=fe(i),c=new Array(Number(a)+1).fill(o),f=Math.floor((t.BITS-1)/i)*i,u=o;for(let l=f;l>=0;l-=i){c.fill(o);for(let w=0;w<n.length;w++){let E=n[w],y=Number(E>>BigInt(l)&a);c[y]=c[y].add(e[w])}let p=o;for(let w=c.length-1,E=o;w>0;w--)E=E.add(c[w]),p=p.add(E);if(u=u.add(p),l!==0)for(let w=0;w<i;w++)u=u.double()}return u}function Ge(r){return An(r.Fp),Mt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...vn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ut=BigInt(0),mt=BigInt(1),Bs=BigInt(2),zc=BigInt(8),Gc={zip215:!0};function jc(r){let t=Ge(r);return Mt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"func