@helia/ipns 8.0.1-73121c2 → 8.0.1-e45e1de
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +3 -6
- package/package.json +2 -2
package/dist/index.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaIpns = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaIpns=(()=>{var
|
|
3
|
-
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(w,v,M){var _=this;if(!(_ instanceof y))return new y(w,v,M);_.time=+w||0,_.nano=+v||0,_.year=+M||0,d(_)}function d(w){var v,M,_,I=w.year,K=w.time,S=w.nano,k=((S<0||a<=S)&&(S-=(M=Math.floor(S/a))*a,K+=M,M=1),I%e);return(K<-i||i<K||k)&&((v=f(K/o))&&(I+=v*e,K-=v*o),(_=A(K)).setUTCFullYear(k+_.getUTCFullYear()),_=(K=+_)+(v=f((I-=k)/e))*o,v&&-i<=_&&_<=i&&(I-=v*e,K=_),M=1),M&&(w.year=I,w.time=K,w.nano=S),w}function A(w){var v=new Date(0);return v.setTime(w),v}function T(I,_){I=+I||0;var M=f((_=(_|0)*s)/n)+f(I/n),_=_%n+I%n,I=f(_/n);return I&&(M+=I,_-=I*n),new y(1e3*_,0,M*e)}function x(w,v,M,_,I,K){return function(k,m){var B=d(this);k=k||new Array(8),F(k,m|=0);var N=Math.floor(B.time/1e3),B=B.year*(r*t/e),p=f(B/s)+f(N/s),B=B%s+N%s,N=Math.floor(B/s);return N&&(p+=N,B-=N*s),S(k,m+I,p),S(k,m+K,B),k};function S(k,m,p){k[m+w]=p>>24&255,k[m+v]=p>>16&255,k[m+M]=p>>8&255,k[m+_]=255&p}}function U(w,v,M,_,I,K){return function(k,m){F(k,m|=0);var p=S(k,m+I);return T(S(k,m+K),p)};function S(k,m){return 16777216*k[m+w]+(k[m+v]<<16|k[m+M]<<8|k[m+_])}}function F(w,v){if(w=w&&w.length,w==null)throw new TypeError("Invalid Buffer");if(w<v+8)throw new RangeError("Out of range")}function D(w){return(9<w?"":"0")+(0|w)}function R(w,v){return(c+(0|w)).substr(-v)}}()});var af=Bi((O1,sf)=>{sf.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,e++,e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var Zp={};Ee(Zp,{ipns:()=>Wp,ipnsSelector:()=>ci,ipnsValidator:()=>li});function ya(t){return t==null?!1:(t.type==="RSA"||t.type==="Ed25519"||t.type==="secp256k1")&&t.raw instanceof Uint8Array&&typeof t.equals=="function"&&typeof t.toMultihash=="function"&&typeof t.toCID=="function"&&typeof t.verify=="function"}var Ai=Symbol.for("@libp2p/peer-id");var xe=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},ur=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Mr=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var lr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var fr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Ii={};Ee(Ii,{base32:()=>Ct,base32hex:()=>Mf,base32hexpad:()=>Hf,base32hexpadupper:()=>Pf,base32hexupper:()=>Of,base32pad:()=>Df,base32padupper:()=>Ff,base32upper:()=>Vf,base32z:()=>Kf});var Qp=new Uint8Array(0);function xa(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function at(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function wa(t){return new TextEncoder().encode(t)}function ba(t){return new TextDecoder().decode(t)}function Nf(t,e){if(t.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<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.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,d=0,A=0,T=E.length;A!==T&&E[A]===0;)A++,y++;for(var x=(T-A)*u+1>>>0,U=new Uint8Array(x);A!==T;){for(var F=E[A],D=0,R=x-1;(F!==0||D<d)&&R!==-1;R--,D++)F+=256*U[R]>>>0,U[R]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");d=D,A++}for(var w=x-d;w!==x&&U[w]===0;)w++;for(var v=c.repeat(y);w<x;++w)v+=t.charAt(U[w]);return v}function h(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 d=0,A=0;E[y]===c;)d++,y++;for(var T=(E.length-y)*f+1>>>0,x=new Uint8Array(T);E[y];){var U=r[E.charCodeAt(y)];if(U===255)return;for(var F=0,D=T-1;(U!==0||F<A)&&D!==-1;D--,F++)U+=a*x[D]>>>0,x[D]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");A=F,y++}if(E[y]!==" "){for(var R=T-A;R!==T&&x[R]===0;)R++;for(var w=new Uint8Array(d+(T-R)),v=d;R!==T;)w[v++]=x[R++];return w}}}function b(E){var y=h(E);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:h,decode:b}}var Uf=Nf,Rf=Uf,Ea=Rf;var Si=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ki=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,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(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ba(this,e)}},Ci=class{decoders;constructor(e){this.decoders=e}or(e){return Ba(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ba(t,e){return new Ci({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Ti=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Si(e,r,n),this.decoder=new ki(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function hr({name:t,prefix:e,encode:r,decode:n}){return new Ti(t,e,r,n)}function kt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ea(r,t);return hr({prefix:e,name:t,encode:n,decode:i=>at(o(i))})}function _f(t,e,r,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let i=t.length;for(;t[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Lf(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function oe({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return hr({prefix:e,name:t,encode(o){return Lf(o,n,r)},decode(o){return _f(o,n,r,t)}})}var Ct=oe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vf=oe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Df=oe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ff=oe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Mf=oe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Of=oe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Hf=oe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pf=oe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Kf=oe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ni={};Ee(Ni,{base58btc:()=>Q,base58flickr:()=>$f});var Q=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$f=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ri={};Ee(Ri,{base64:()=>Ui,base64pad:()=>qf,base64url:()=>zf,base64urlpad:()=>Gf});var Ui=oe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qf=oe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),zf=oe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gf=oe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Wf(t,e){try{if(typeof t=="string"&&t.length>0)return Zf(t);if(typeof t=="number"&&isFinite(t))return e?.long?Yf(t):jf(t);throw new Error("Value is not a string or number.")}catch(r){let n=Jf(r)?`${r.message}. value=${JSON.stringify(t)}`:"An unknown error has occured.";throw new Error(n)}}function Zf(t){if(t=String(t),t.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return NaN;let r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var En=Wf;function jf(t){let e=Math.abs(t);return e>=864e5?`${Math.round(t/864e5)}d`:e>=36e5?`${Math.round(t/36e5)}h`:e>=6e4?`${Math.round(t/6e4)}m`:e>=1e3?`${Math.round(t/1e3)}s`:`${t}ms`}function Yf(t){let e=Math.abs(t);return e>=864e5?vn(t,e,864e5,"day"):e>=36e5?vn(t,e,36e5,"hour"):e>=6e4?vn(t,e,6e4,"minute"):e>=1e3?vn(t,e,1e3,"second"):`${t} ms`}function vn(t,e,r,n){let o=e>=r*1.5;return`${Math.round(t/r)} ${n}${o?"s":""}`}function Jf(t){return typeof t=="object"&&t!==null&&"message"in t}function _i(t){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=En,r.destroy=f,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=e;function r(u){let l,h=null,b,E;function y(...d){if(!y.enabled)return;let A=y,T=Number(new Date),x=T-(l||T);A.diff=x,A.prev=l,A.curr=T,l=T,d[0]=r.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let U=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(D,R)=>{if(D==="%%")return"%";U++;let w=r.formatters[R];if(typeof w=="function"){let v=d[U];D=w.call(A,v),d.splice(U,1),U--}return D}),r.formatArgs.call(A,d),(A.log||r.log).apply(A,d)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(b!==r.namespaces&&(b=r.namespaces,E=r.enabled(u)),E),set:d=>{h=d}}),typeof r.init=="function"&&r.init(y),y}function n(u,l){let h=r(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),b=h.length;for(l=0;l<b;l++)h[l]&&(u=h[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,h;for(l=0,h=r.skips.length;l<h;l++)if(r.skips[l].test(u))return!1;for(l=0,h=r.names.length;l<h;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 Bn=oh(),Xf=["#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 Qf(){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 eh(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+En(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}var th=console.debug??console.log??(()=>{});function rh(t){try{t?Bn?.setItem("debug",t):Bn?.removeItem("debug")}catch{}}function nh(){let t;try{t=Bn?.getItem("debug")}catch{}return!t&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(t=globalThis.process.env.DEBUG),t}function oh(){try{return localStorage}catch{}}function ih(t){t.j=function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Aa=_i({formatArgs:eh,save:rh,load:nh,useColors:Qf,setupFormatters:ih,colors:Xf,storage:Bn,log:th});var Ce=Aa;Ce.formatters.b=t=>t==null?"undefined":Q.baseEncode(t);Ce.formatters.t=t=>t==null?"undefined":Ct.baseEncode(t);Ce.formatters.m=t=>t==null?"undefined":Ui.baseEncode(t);Ce.formatters.p=t=>t==null?"undefined":t.toString();Ce.formatters.c=t=>t==null?"undefined":t.toString();Ce.formatters.k=t=>t==null?"undefined":t.toString();Ce.formatters.a=t=>t==null?"undefined":t.toString();Ce.formatters.e=t=>t==null?"undefined":Sa(t.stack)??Sa(t.message)??t.toString();function sh(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Tt(t){let e=sh(`${t}:trace`);return Ce.enabled(`${t}:trace`)&&Ce.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=Ce(`${t}:trace`)),Object.assign(Ce(t),{error:Ce(`${t}:error`),trace:e})}function Sa(t){if(t!=null&&(t=t.trim(),t.length!==0))return t}var Li={};Ee(Li,{base36:()=>He,base36upper:()=>ah});var He=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ah=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ch=Ta,ka=128,uh=127,lh=~uh,fh=Math.pow(2,31);function Ta(t,e,r){e=e||[],r=r||0;for(var n=r;t>=fh;)e[r++]=t&255|ka,t/=128;for(;t&lh;)e[r++]=t&255|ka,t>>>=7;return e[r]=t|0,Ta.bytes=r-n+1,e}var hh=Vi,dh=128,Ca=127;function Vi(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw Vi.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Ca)<<o:(s&Ca)*Math.pow(2,o),o+=7}while(s>=dh);return Vi.bytes=i-n,r}var ph=Math.pow(2,7),gh=Math.pow(2,14),mh=Math.pow(2,21),yh=Math.pow(2,28),xh=Math.pow(2,35),wh=Math.pow(2,42),bh=Math.pow(2,49),vh=Math.pow(2,56),Eh=Math.pow(2,63),Bh=function(t){return t<ph?1:t<gh?2:t<mh?3:t<yh?4:t<xh?5:t<wh?6:t<bh?7:t<vh?8:t<Eh?9:10},Ah={encode:ch,decode:hh,encodingLength:Bh},Sh=Ah,Or=Sh;function Hr(t,e=0){return[Or.decode(t,e),Or.decode.bytes]}function dr(t,e,r=0){return Or.encode(t,e,r),e}function pr(t){return Or.encodingLength(t)}function Pe(t,e){let r=e.byteLength,n=pr(t),o=n+pr(r),i=new Uint8Array(o+r);return dr(t,i,0),dr(r,i,n),i.set(e,o),new gr(t,r,e,i)}function ct(t){let e=at(t),[r,n]=Hr(e),[o,i]=Hr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new gr(r,o,s,e)}function Ia(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&xa(t.bytes,r.bytes)}}var gr=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Na(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Ch(r,Di(t),e??Q.encoder);default:return Th(r,Di(t),e??Ct.encoder)}}var Ua=new WeakMap;function Di(t){let e=Ua.get(t);if(e==null){let r=new Map;return Ua.set(t,r),r}return e}var re=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==Pr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ih)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.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:e,digest:r}=this.multihash,n=Pe(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&Ia(e.multihash,n.multihash)}toString(e){return Na(this,e)}toJSON(){return{"/":Na(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??Ra(n,o,i.bytes))}else if(r[Nh]===!0){let{version:n,multihash:o,code:i}=r,s=ct(o);return t.create(n,i,s)}else return null}static create(e,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(e){case 0:{if(r!==Pr)throw new Error(`Version 0 CID must use dag-pb (code: ${Pr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Ra(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Pr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=at(e.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 gr(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,h]=Hr(e.subarray(r));return r+=h,l},o=n(),i=Pr;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(e,r){let[n,o]=kh(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Di(i).set(n,e),i}};function kh(t,e){switch(t[0]){case"Q":{let r=e??Q;return[Q.prefix,r.decode(`${Q.prefix}${t}`)]}case Q.prefix:{let r=e??Q;return[Q.prefix,r.decode(t)]}case Ct.prefix:{let r=e??Ct;return[Ct.prefix,r.decode(t)]}case He.prefix:{let r=e??He;return[He.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Ch(t,e,r){let{prefix:n}=r;if(n!==Q.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function Th(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var Pr=112,Ih=18;function Ra(t,e,r){let n=pr(t),o=n+pr(e),i=new Uint8Array(o+r.byteLength);return dr(t,i,0),dr(e,i,n),i.set(r,o),i}var Nh=Symbol.for("@ipld/js-cid/CID");var Fi={};Ee(Fi,{identity:()=>ut});var _a=0,Uh="identity",La=at;function Rh(t){return Pe(_a,La(t))}var ut={code:_a,name:Uh,encode:La,digest:Rh};function he(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Va(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function _h(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function mr(t,...e){if(!_h(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Da(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Va(t.outputLen),Va(t.blockLen)}function yr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Fa(t,e){mr(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var Yt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Sn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ke=(t,e)=>t<<32-e|t>>>e;function Ma(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Kr(t){return typeof t=="string"&&(t=Ma(t)),mr(t),t}function Mi(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];mr(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var xr=class{clone(){return this._cloneInto()}};function kn(t){let e=n=>t().update(Kr(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Cn(t=32){if(Yt&&typeof Yt.getRandomValues=="function")return Yt.getRandomValues(new Uint8Array(t));if(Yt&&typeof Yt.randomBytes=="function")return Yt.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Lh(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Oa=(t,e,r)=>t&e^~t&r,Ha=(t,e,r)=>t&e^t&r^e&r,wr=class extends xr{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Sn(this.buffer)}update(e){yr(this);let{view:r,buffer:n,blockLen:o}=this;e=Kr(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Sn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){yr(this),Fa(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;Lh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Sn(e),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],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%r&&e.buffer.set(n),e}};var Tn=BigInt(4294967295),Oi=BigInt(32);function Pa(t,e=!1){return e?{h:Number(t&Tn),l:Number(t>>Oi&Tn)}:{h:Number(t>>Oi&Tn)|0,l:Number(t&Tn)|0}}function Vh(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:i,l:s}=Pa(t[o],e);[r[o],n[o]]=[i,s]}return[r,n]}var Dh=(t,e)=>BigInt(t>>>0)<<Oi|BigInt(e>>>0),Fh=(t,e,r)=>t>>>r,Mh=(t,e,r)=>t<<32-r|e>>>r,Oh=(t,e,r)=>t>>>r|e<<32-r,Hh=(t,e,r)=>t<<32-r|e>>>r,Ph=(t,e,r)=>t<<64-r|e>>>r-32,Kh=(t,e,r)=>t>>>r-32|e<<64-r,$h=(t,e)=>e,qh=(t,e)=>t,zh=(t,e,r)=>t<<r|e>>>32-r,Gh=(t,e,r)=>e<<r|t>>>32-r,Wh=(t,e,r)=>e<<r-32|t>>>64-r,Zh=(t,e,r)=>t<<r-32|e>>>64-r;function jh(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var Yh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Jh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Xh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Qh=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,ed=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),td=(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0;var rd={fromBig:Pa,split:Vh,toBig:Dh,shrSH:Fh,shrSL:Mh,rotrSH:Oh,rotrSL:Hh,rotrBH:Ph,rotrBL:Kh,rotr32H:$h,rotr32L:qh,rotlSH:zh,rotlSL:Gh,rotlBH:Wh,rotlBL:Zh,add:jh,add3L:Yh,add3H:Jh,add4L:Xh,add4H:Qh,add5H:td,add5L:ed},q=rd;var[nd,od]=q.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(t=>BigInt(t))),Nt=new Uint32Array(80),Ut=new Uint32Array(80),Hi=class extends wr{constructor(){super(128,64,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:e,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:b,Gl:E,Hh:y,Hl:d}=this;return[e,r,n,o,i,s,a,c,f,u,l,h,b,E,y,d]}set(e,r,n,o,i,s,a,c,f,u,l,h,b,E,y,d){this.Ah=e|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=h|0,this.Gh=b|0,this.Gl=E|0,this.Hh=y|0,this.Hl=d|0}process(e,r){for(let x=0;x<16;x++,r+=4)Nt[x]=e.getUint32(r),Ut[x]=e.getUint32(r+=4);for(let x=16;x<80;x++){let U=Nt[x-15]|0,F=Ut[x-15]|0,D=q.rotrSH(U,F,1)^q.rotrSH(U,F,8)^q.shrSH(U,F,7),R=q.rotrSL(U,F,1)^q.rotrSL(U,F,8)^q.shrSL(U,F,7),w=Nt[x-2]|0,v=Ut[x-2]|0,M=q.rotrSH(w,v,19)^q.rotrBH(w,v,61)^q.shrSH(w,v,6),_=q.rotrSL(w,v,19)^q.rotrBL(w,v,61)^q.shrSL(w,v,6),I=q.add4L(R,_,Ut[x-7],Ut[x-16]),K=q.add4H(I,D,M,Nt[x-7],Nt[x-16]);Nt[x]=K|0,Ut[x]=I|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:b,Fl:E,Gh:y,Gl:d,Hh:A,Hl:T}=this;for(let x=0;x<80;x++){let U=q.rotrSH(l,h,14)^q.rotrSH(l,h,18)^q.rotrBH(l,h,41),F=q.rotrSL(l,h,14)^q.rotrSL(l,h,18)^q.rotrBL(l,h,41),D=l&b^~l&y,R=h&E^~h&d,w=q.add5L(T,F,R,od[x],Ut[x]),v=q.add5H(w,A,U,D,nd[x],Nt[x]),M=w|0,_=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),I=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),K=n&i^n&a^i&a,S=o&s^o&c^s&c;A=y|0,T=d|0,y=b|0,d=E|0,b=l|0,E=h|0,{h:l,l:h}=q.add(f|0,u|0,v|0,M|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let k=q.add3L(M,I,S);n=q.add3H(k,v,_,K),o=k|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=q.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=q.add(this.Eh|0,this.El|0,l|0,h|0),{h:b,l:E}=q.add(this.Fh|0,this.Fl|0,b|0,E|0),{h:y,l:d}=q.add(this.Gh|0,this.Gl|0,y|0,d|0),{h:A,l:T}=q.add(this.Hh|0,this.Hl|0,A|0,T|0),this.set(n,o,i,s,a,c,f,u,l,h,b,E,y,d,A,T)}roundClean(){Nt.fill(0),Ut.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 Ka=kn(()=>new Hi);var Un={};Ee(Un,{aInRange:()=>Te,abool:()=>$e,abytes:()=>br,bitGet:()=>ld,bitLen:()=>qi,bitMask:()=>qr,bitSet:()=>fd,bytesToHex:()=>ft,bytesToNumberBE:()=>ht,bytesToNumberLE:()=>_t,concatBytes:()=>dt,createHmacDrbg:()=>zi,ensureBytes:()=>ne,equalBytes:()=>cd,hexToBytes:()=>Xt,hexToNumber:()=>$i,inRange:()=>$r,isBytes:()=>Rt,memoized:()=>er,notImplemented:()=>dd,numberToBytesBE:()=>Lt,numberToBytesLE:()=>Qt,numberToHexUnpadded:()=>Jt,numberToVarBytesBE:()=>ad,utf8ToBytes:()=>ud,validateObject:()=>Xe});var In=BigInt(0),Nn=BigInt(1),id=BigInt(2);function Rt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function br(t){if(!Rt(t))throw new Error("Uint8Array expected")}function $e(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}var sd=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ft(t){br(t);let e="";for(let r=0;r<t.length;r++)e+=sd[t[r]];return e}function Jt(t){let e=t.toString(16);return e.length&1?"0"+e:e}function $i(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?In:BigInt("0x"+t)}var lt={_0:48,_9:57,A:65,F:70,a:97,f:102};function $a(t){if(t>=lt._0&&t<=lt._9)return t-lt._0;if(t>=lt.A&&t<=lt.F)return t-(lt.A-10);if(t>=lt.a&&t<=lt.f)return t-(lt.a-10)}function Xt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=$a(t.charCodeAt(i)),a=$a(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function ht(t){return $i(ft(t))}function _t(t){return br(t),$i(ft(Uint8Array.from(t).reverse()))}function Lt(t,e){return Xt(t.toString(16).padStart(e*2,"0"))}function Qt(t,e){return Lt(t,e).reverse()}function ad(t){return Xt(Jt(t))}function ne(t,e,r){let n;if(typeof e=="string")try{n=Xt(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Rt(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}function dt(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];br(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function cd(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function ud(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}var Pi=t=>typeof t=="bigint"&&In<=t;function $r(t,e,r){return Pi(t)&&Pi(e)&&Pi(r)&&e<=t&&t<r}function Te(t,e,r,n){if(!$r(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function qi(t){let e;for(e=0;t>In;t>>=Nn,e+=1);return e}function ld(t,e){return t>>BigInt(e)&Nn}function fd(t,e,r){return t|(r?Nn:In)<<BigInt(e)}var qr=t=>(id<<BigInt(t-1))-Nn,Ki=t=>new Uint8Array(t),qa=t=>Uint8Array.from(t);function zi(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Ki(t),o=Ki(t),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>r(o,n,...l),c=(l=Ki())=>{o=a(qa([0]),l),n=a(),l.length!==0&&(o=a(qa([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l<e;){n=a();let b=n.slice();h.push(b),l+=n.length}return dt(...h)};return(l,h)=>{s(),c(l);let b;for(;!(b=h(f()));)c();return s(),b}}var hd={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Rt(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Xe(t,e,r={}){let n=(o,i,s)=>{let a=hd[i];if(typeof a!="function")throw new Error("invalid validator function");let c=t[o];if(!(s&&c===void 0)&&!a(c,t))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return t}var dd=()=>{throw new Error("not implemented")};function er(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var ie=BigInt(0),ee=BigInt(1),tr=BigInt(2),pd=BigInt(3),Gi=BigInt(4),za=BigInt(5),Ga=BigInt(8),gd=BigInt(9),md=BigInt(16);function J(t,e){let r=t%e;return r>=ie?r:e+r}function yd(t,e,r){if(e<ie)throw new Error("invalid exponent, negatives unsupported");if(r<=ie)throw new Error("invalid modulus");if(r===ee)return ie;let n=ee;for(;e>ie;)e&ee&&(n=n*t%r),t=t*t%r,e>>=ee;return n}function te(t,e,r){let n=t;for(;e-- >ie;)n*=n,n%=r;return n}function Rn(t,e){if(t===ie)throw new Error("invert: expected non-zero number");if(e<=ie)throw new Error("invert: expected positive modulus, got "+e);let r=J(t,e),n=e,o=ie,i=ee,s=ee,a=ie;for(;r!==ie;){let f=n/r,u=n%r,l=o-s*f,h=i-a*f;n=r,r=u,o=s,i=a,s=l,a=h}if(n!==ee)throw new Error("invert: does not exist");return J(o,e)}function xd(t){let e=(t-ee)/tr,r,n,o;for(r=t-ee,n=0;r%tr===ie;r/=tr,n++);for(o=tr;o<t&&yd(o,e,t)!==t-ee;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(t+ee)/Gi;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(r+ee)/tr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),r),l=a.pow(c,i),h=a.pow(c,r);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let b=1;for(let y=a.sqr(h);b<f&&!a.eql(y,a.ONE);b++)y=a.sqr(y);let E=a.pow(u,ee<<BigInt(f-b-1));u=a.sqr(E),l=a.mul(l,E),h=a.mul(h,u),f=b}return l}}function wd(t){if(t%Gi===pd){let e=(t+ee)/Gi;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%Ga===za){let e=(t-za)/Ga;return function(n,o){let i=n.mul(o,tr),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,tr),s),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 t%md,xd(t)}var Wa=(t,e)=>(J(t,e)&ee)===ee,bd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Wi(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=bd.reduce((n,o)=>(n[o]="function",n),e);return Xe(t,r)}function vd(t,e,r){if(r<ie)throw new Error("invalid exponent, negatives unsupported");if(r===ie)return t.ONE;if(r===ee)return e;let n=t.ONE,o=e;for(;r>ie;)r&ee&&(n=t.mul(n,o)),o=t.sqr(o),r>>=ee;return n}function Ed(t,e){let r=new Array(e.length),n=e.reduce((i,s,a)=>t.is0(s)?i:(r[a]=i,t.mul(i,s)),t.ONE),o=t.inv(n);return e.reduceRight((i,s,a)=>t.is0(s)?i:(r[a]=t.mul(i,r[a]),t.mul(i,s)),o),r}function Zi(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Vt(t,e,r=!1,n={}){if(t<=ie)throw new Error("invalid field: expected ORDER > 0, got "+t);let{nBitLength:o,nByteLength:i}=Zi(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:qr(o),ZERO:ie,ONE:ee,create:c=>J(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ie<=c&&c<t},is0:c=>c===ie,isOdd:c=>(c&ee)===ee,neg:c=>J(-c,t),eql:(c,f)=>c===f,sqr:c=>J(c*c,t),add:(c,f)=>J(c+f,t),sub:(c,f)=>J(c-f,t),mul:(c,f)=>J(c*f,t),pow:(c,f)=>vd(a,c,f),div:(c,f)=>J(c*Rn(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Rn(c,t),sqrt:n.sqrt||(c=>(s||(s=wd(t)),s(a,c))),invertBatch:c=>Ed(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>r?Qt(c,i):Lt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?_t(c):ht(c)}});return Object.freeze(a)}function Za(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function ji(t){let e=Za(t);return e+Math.ceil(e/2)}function ja(t,e,r=!1){let n=t.length,o=Za(e),i=ji(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?ht(t):_t(t),a=J(s,e-ee)+ee;return r?Qt(a,o):Lt(a,o)}var Ya=BigInt(0),_n=BigInt(1);function Yi(t,e){let r=e.negate();return t?r:e}function Ja(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ji(t,e){Ja(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1);return{windows:r,windowSize:n}}function Ad(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function Sd(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}var Xi=new WeakMap,Xa=new WeakMap;function Qi(t){return Xa.get(t)||1}function Ln(t,e){return{constTimeNegate:Yi,hasPrecomputes(r){return Qi(r)!==1},unsafeLadder(r,n,o=t.ZERO){let i=r;for(;n>Ya;)n&_n&&(o=o.add(i)),i=i.double(),n>>=_n;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=Ji(n,e),s=[],a=r,c=a;for(let f=0;f<o;f++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let{windows:i,windowSize:s}=Ji(r,e),a=t.ZERO,c=t.BASE,f=BigInt(2**r-1),u=2**r,l=BigInt(r);for(let h=0;h<i;h++){let b=h*s,E=Number(o&f);o>>=l,E>s&&(E-=u,o+=_n);let y=b,d=b+Math.abs(E)-1,A=h%2!==0,T=E<0;E===0?c=c.add(Yi(A,n[y])):a=a.add(Yi(T,n[d]))}return{p:a,f:c}},wNAFUnsafe(r,n,o,i=t.ZERO){let{windows:s,windowSize:a}=Ji(r,e),c=BigInt(2**r-1),f=2**r,u=BigInt(r);for(let l=0;l<s;l++){let h=l*a;if(o===Ya)break;let b=Number(o&c);if(o>>=u,b>a&&(b-=f,o+=_n),b===0)continue;let E=n[h+Math.abs(b)-1];b<0&&(E=E.negate()),i=i.add(E)}return i},getPrecomputes(r,n,o){let i=Xi.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&Xi.set(n,o(i))),i},wNAFCached(r,n,o){let i=Qi(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=Qi(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Ja(n,e),Xa.set(r,n),Xi.delete(r)}}}function Vn(t,e,r,n){if(Ad(r,t),Sd(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=t.ZERO,i=qi(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,c=new Array(a+1).fill(o),f=Math.floor((e.BITS-1)/s)*s,u=o;for(let l=f;l>=0;l-=s){c.fill(o);for(let b=0;b<n.length;b++){let E=n[b],y=Number(E>>BigInt(l)&BigInt(a));c[y]=c[y].add(r[b])}let h=o;for(let b=c.length-1,E=o;b>0;b--)E=E.add(c[b]),h=h.add(E);if(u=u.add(h),l!==0)for(let b=0;b<s;b++)u=u.double()}return u}function zr(t){return Wi(t.Fp),Xe(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Zi(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var qe=BigInt(0),Ie=BigInt(1),Dn=BigInt(2),kd=BigInt(8),Cd={zip215:!0};function Td(t){let e=zr(t);return Xe(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Qa(t){let e=Td(t),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=Dn<<BigInt(a*8)-Ie,u=r.create,l=Vt(e.n,e.nBitLength),h=e.uvRatio||((m,p)=>{try{return{isValid:!0,value:r.sqrt(m*r.inv(p))}}catch{return{isValid:!1,value:qe}}}),b=e.adjustScalarBytes||(m=>m),E=e.domain||((m,p,B)=>{if($e("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function y(m,p){Te("coordinate "+m,p,qe,f)}function d(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let A=er((m,p)=>{let{ex:B,ey:N,ez:O}=m,H=m.is0();p==null&&(p=H?kd:r.inv(O));let z=u(B*p),W=u(N*p),$=u(O*p);if(H)return{x:qe,y:Ie};if($!==Ie)throw new Error("invZ was invalid");return{x:z,y:W}}),T=er(m=>{let{a:p,d:B}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:N,ey:O,ez:H,et:z}=m,W=u(N*N),$=u(O*O),j=u(H*H),X=u(j*j),ae=u(W*p),ce=u(j*u(ae+$)),fe=u(X+u(B*u(W*$)));if(ce!==fe)throw new Error("bad point: equation left != right (1)");let ye=u(N*O),ke=u(H*z);if(ye!==ke)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,B,N,O){this.ex=p,this.ey=B,this.ez=N,this.et=O,y("x",p),y("y",B),y("z",N),y("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof x)throw new Error("extended point not allowed");let{x:B,y:N}=p||{};return y("x",B),y("y",N),new x(B,N,Ie,u(B*N))}static normalizeZ(p){let B=r.invertBatch(p.map(N=>N.ez));return p.map((N,O)=>N.toAffine(B[O])).map(x.fromAffine)}static msm(p,B){return Vn(x,l,p,B)}_setWindowSize(p){D.setWindowSize(this,p)}assertValidity(){T(this)}equals(p){d(p);let{ex:B,ey:N,ez:O}=this,{ex:H,ey:z,ez:W}=p,$=u(B*W),j=u(H*O),X=u(N*W),ae=u(z*O);return $===j&&X===ae}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:B,ey:N,ez:O}=this,H=u(B*B),z=u(N*N),W=u(Dn*u(O*O)),$=u(p*H),j=B+N,X=u(u(j*j)-H-z),ae=$+z,ce=ae-W,fe=$-z,ye=u(X*ce),ke=u(ae*fe),ve=u(X*fe),Je=u(ce*ae);return new x(ye,ke,Je,ve)}add(p){d(p);let{a:B,d:N}=e,{ex:O,ey:H,ez:z,et:W}=this,{ex:$,ey:j,ez:X,et:ae}=p;if(B===BigInt(-1)){let ua=u((H-O)*(j+$)),la=u((H+O)*(j-$)),Ei=u(la-ua);if(Ei===qe)return this.double();let fa=u(z*Dn*ae),ha=u(W*Dn*X),da=ha+fa,pa=la+ua,ga=ha-fa,bf=u(da*Ei),vf=u(pa*ga),Ef=u(da*ga),Bf=u(Ei*pa);return new x(bf,vf,Bf,Ef)}let ce=u(O*$),fe=u(H*j),ye=u(W*N*ae),ke=u(z*X),ve=u((O+H)*($+j)-ce-fe),Je=ke-ye,st=ke+ye,Dr=u(fe-B*ce),mf=u(ve*Je),yf=u(st*Dr),xf=u(ve*Dr),wf=u(Je*st);return new x(mf,yf,wf,xf)}subtract(p){return this.add(p.negate())}wNAF(p){return D.wNAFCached(this,p,x.normalizeZ)}multiply(p){let B=p;Te("scalar",B,Ie,n);let{p:N,f:O}=this.wNAF(B);return x.normalizeZ([N,O])[0]}multiplyUnsafe(p,B=x.ZERO){let N=p;return Te("scalar",N,qe,n),N===qe?F:this.is0()||N===Ie?this:D.wNAFCachedUnsafe(this,N,x.normalizeZ,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return D.unsafeLadder(this,n).is0()}toAffine(p){return A(this,p)}clearCofactor(){let{h:p}=e;return p===Ie?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:N,a:O}=e,H=r.BYTES;p=ne("pointHex",p,H),$e("zip215",B);let z=p.slice(),W=p[H-1];z[H-1]=W&-129;let $=_t(z),j=B?f:r.ORDER;Te("pointHex.y",$,qe,j);let X=u($*$),ae=u(X-Ie),ce=u(N*X-O),{isValid:fe,value:ye}=h(ae,ce);if(!fe)throw new Error("Point.fromHex: invalid y coordinate");let ke=(ye&Ie)===Ie,ve=(W&128)!==0;if(!B&&ye===qe&&ve)throw new Error("Point.fromHex: x=0 and x_0=1");return ve!==ke&&(ye=u(-ye)),x.fromAffine({x:ye,y:$})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),N=Qt(B,r.BYTES);return N[N.length-1]|=p&Ie?128:0,N}toHex(){return ft(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,Ie,u(e.Gx*e.Gy)),x.ZERO=new x(qe,Ie,Ie,qe);let{BASE:U,ZERO:F}=x,D=Ln(x,a*8);function R(m){return J(m,n)}function w(m){return R(_t(m))}function v(m){let p=r.BYTES;m=ne("private key",m,p);let B=ne("hashed private key",i(m),2*p),N=b(B.slice(0,p)),O=B.slice(p,2*p),H=w(N),z=U.multiply(H),W=z.toRawBytes();return{head:N,prefix:O,scalar:H,point:z,pointBytes:W}}function M(m){return v(m).pointBytes}function _(m=new Uint8Array,...p){let B=dt(...p);return w(i(E(B,ne("context",m),!!o)))}function I(m,p,B={}){m=ne("message",m),o&&(m=o(m));let{prefix:N,scalar:O,pointBytes:H}=v(p),z=_(B.context,N,m),W=U.multiply(z).toRawBytes(),$=_(B.context,W,H,m),j=R(z+$*O);Te("signature.s",j,qe,n);let X=dt(W,Qt(j,r.BYTES));return ne("result",X,r.BYTES*2)}let K=Cd;function S(m,p,B,N=K){let{context:O,zip215:H}=N,z=r.BYTES;m=ne("signature",m,2*z),p=ne("message",p),B=ne("publicKey",B,z),H!==void 0&&$e("zip215",H),o&&(p=o(p));let W=_t(m.slice(z,2*z)),$,j,X;try{$=x.fromHex(B,H),j=x.fromHex(m.slice(0,z),H),X=U.multiplyUnsafe(W)}catch{return!1}if(!H&&$.isSmallOrder())return!1;let ae=_(O,j.toRawBytes(),$.toRawBytes(),p);return j.add($.multiplyUnsafe(ae)).subtract(X).clearCofactor().equals(x.ZERO)}return U._setWindowSize(8),{CURVE:e,getPublicKey:M,sign:I,verify:S,ExtendedPoint:x,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(r.BYTES),precompute(m=8,p=x.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var es=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ec=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),om=BigInt(0),Id=BigInt(1),tc=BigInt(2),im=BigInt(3),Nd=BigInt(5),Ud=BigInt(8);function Rd(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=es,a=t*t%i*t%i,c=te(a,tc,i)*a%i,f=te(c,Id,i)*t%i,u=te(f,Nd,i)*f%i,l=te(u,e,i)*u%i,h=te(l,r,i)*l%i,b=te(h,n,i)*h%i,E=te(b,o,i)*b%i,y=te(E,o,i)*b%i,d=te(y,e,i)*u%i;return{pow_p_5_8:te(d,tc,i)*t%i,b2:a}}function _d(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Ld(t,e){let r=es,n=J(e*e*e,r),o=J(n*n*e,r),i=Rd(t*o).pow_p_5_8,s=J(t*n*i,r),a=J(e*s*s,r),c=s,f=J(s*ec,r),u=a===t,l=a===J(-t,r),h=a===J(-t*ec,r);return u&&(s=c),(l||h)&&(s=f),Wa(s,r)&&(s=J(-s,r)),{isValid:u||l,value:s}}var Vd=Vt(es,void 0,!0),Dd={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Vd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ud,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ka,randomBytes:Cn,adjustScalarBytes:_d,uvRatio:Ld},rc=Qa(Dd);var Fn=32;function nc(t,e,r){return rc.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}var Mn=class{type="Ed25519";raw;constructor(e){this.raw=ts(e,Fn)}toMultihash(){return ut.digest(vr(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return nc(this.raw,r,e)}};function rs(t){return t=ts(t,Fn),new Mn(t)}function ts(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new xe(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}function ns(t=0){return new Uint8Array(t)}function Qe(t=0){return new Uint8Array(t)}var Md=Math.pow(2,7),Od=Math.pow(2,14),Hd=Math.pow(2,21),ic=Math.pow(2,28),sc=Math.pow(2,35),ac=Math.pow(2,42),cc=Math.pow(2,49),Be=128,Dt=127;function Gr(t){if(t<Md)return 1;if(t<Od)return 2;if(t<Hd)return 3;if(t<ic)return 4;if(t<sc)return 5;if(t<ac)return 6;if(t<cc)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function uc(t,e,r=0){switch(Gr(t)){case 8:e[r++]=t&255|Be,t/=128;case 7:e[r++]=t&255|Be,t/=128;case 6:e[r++]=t&255|Be,t/=128;case 5:e[r++]=t&255|Be,t/=128;case 4:e[r++]=t&255|Be,t>>>=7;case 3:e[r++]=t&255|Be,t>>>=7;case 2:e[r++]=t&255|Be,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function lc(t,e){let r=t[e],n=0;if(n+=r&Dt,r<Be||(r=t[e+1],n+=(r&Dt)<<7,r<Be)||(r=t[e+2],n+=(r&Dt)<<14,r<Be)||(r=t[e+3],n+=(r&Dt)<<21,r<Be)||(r=t[e+4],n+=(r&Dt)*ic,r<Be)||(r=t[e+5],n+=(r&Dt)*sc,r<Be)||(r=t[e+6],n+=(r&Dt)*ac,r<Be)||(r=t[e+7],n+=(r&Dt)*cc,r<Be))return n;throw new RangeError("Could not decode varint")}var os=new Float32Array([-0]),Ft=new Uint8Array(os.buffer);function fc(t,e,r){os[0]=t,e[r]=Ft[0],e[r+1]=Ft[1],e[r+2]=Ft[2],e[r+3]=Ft[3]}function hc(t,e){return Ft[0]=t[e],Ft[1]=t[e+1],Ft[2]=t[e+2],Ft[3]=t[e+3],os[0]}var is=new Float64Array([-0]),we=new Uint8Array(is.buffer);function dc(t,e,r){is[0]=t,e[r]=we[0],e[r+1]=we[1],e[r+2]=we[2],e[r+3]=we[3],e[r+4]=we[4],e[r+5]=we[5],e[r+6]=we[6],e[r+7]=we[7]}function pc(t,e){return we[0]=t[e],we[1]=t[e+1],we[2]=t[e+2],we[3]=t[e+3],we[4]=t[e+4],we[5]=t[e+5],we[6]=t[e+6],we[7]=t[e+7],is[0]}var Pd=BigInt(Number.MAX_SAFE_INTEGER),Kd=BigInt(Number.MIN_SAFE_INTEGER),Re=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&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(e=!1){if(e)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(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return rr;if(e<Pd&&e>Kd)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>gc&&(o=0n,++n>gc&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return rr;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):rr}},rr=new Re(0,0);rr.toBigInt=function(){return 0n};rr.zzEncode=rr.zzDecode=function(){return this};rr.length=function(){return 1};var gc=4294967296n;function mc(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function yc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&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 ss(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function ze(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function On(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var as=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ze(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ze(this,4);return On(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ze(this,4);return On(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ze(this,4);let e=hc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ze(this,4);let e=pc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw ze(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return yc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ze(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ze(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Re(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw ze(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw ze(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ze(this,8);let e=On(this.buf,this.pos+=4),r=On(this.buf,this.pos+=4);return new Re(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=lc(this.buf,this.pos);return this.pos+=Gr(e),e}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 cs(t){return new as(t instanceof Uint8Array?t:t.subarray())}function Mt(t,e,r){let n=cs(t);return e.decode(n,void 0,r)}var us={};Ee(us,{base10:()=>$d});var $d=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var ls={};Ee(ls,{base16:()=>qd,base16upper:()=>zd});var qd=oe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zd=oe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fs={};Ee(fs,{base2:()=>Gd});var Gd=oe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hs={};Ee(hs,{base256emoji:()=>Jd});var wc=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}"),Wd=wc.reduce((t,e,r)=>(t[r]=e,t),[]),Zd=wc.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function jd(t){return t.reduce((e,r)=>(e+=Wd[r],e),"")}function Yd(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Zd[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Jd=hr({prefix:"\u{1F680}",name:"base256emoji",encode:jd,decode:Yd});var ds={};Ee(ds,{base8:()=>Xd});var Xd=oe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ps={};Ee(ps,{identity:()=>Qd});var Qd=hr({prefix:"\0",name:"identity",encode:t=>ba(t),decode:t=>wa(t)});var Pm=new TextEncoder,Km=new TextDecoder;var ys={};Ee(ys,{sha256:()=>Wr,sha512:()=>r0});function ms({name:t,code:e,encode:r}){return new gs(t,e,r)}var gs=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Pe(this.code,r):r.then(n=>Pe(this.code,n))}else throw Error("Unknown type, must be binary type")}};function vc(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Wr=ms({name:"sha2-256",code:18,encode:vc("SHA-256")}),r0=ms({name:"sha2-512",code:19,encode:vc("SHA-512")});var xs={...ps,...fs,...ds,...us,...ls,...Ii,...Li,...Ni,...Ri,...hs},ey={...ys,...Fi};function Bc(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Ec=Bc("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ws=Bc("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Qe(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),n0={utf8:Ec,"utf-8":Ec,hex:xs.base16,latin1:ws,ascii:ws,binary:ws,...xs},Hn=n0;function Y(t,e="utf8"){let r=Hn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function bs(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Qe(s);o+s>e&&(n=Qe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var nr=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function vs(){}var Bs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},o0=bs();function i0(t){return globalThis.Buffer!=null?Qe(t):o0(t)}var jr=class{len;head;tail;states;constructor(){this.len=0,this.head=new nr(vs,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new nr(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new As((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Pn,10,Re.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Re.fromBigInt(e);return this._push(Pn,r.length(),r)}uint64Number(e){return this._push(uc,Gr(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Re.fromBigInt(e).zzEncode();return this._push(Pn,r.length(),r)}sint64Number(e){let r=Re.fromNumber(e).zzEncode();return this._push(Pn,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Es,1,e?1:0)}fixed32(e){return this._push(Zr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Re.fromBigInt(e);return this._push(Zr,4,r.lo)._push(Zr,4,r.hi)}fixed64Number(e){let r=Re.fromNumber(e);return this._push(Zr,4,r.lo)._push(Zr,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(fc,4,e)}double(e){return this._push(dc,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Es,1,0):this.uint32(r)._push(a0,r,e)}string(e){let r=mc(e);return r!==0?this.uint32(r)._push(ss,r,e):this._push(Es,1,0)}fork(){return this.states=new Bs(this),this.head=this.tail=new nr(vs,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 nr(vs,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=i0(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Es(t,e,r){e[r]=t&255}function s0(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var As=class extends nr{next;constructor(e,r){super(s0,e,r),this.next=void 0}};function Pn(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Zr(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function a0(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(jr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(c0,e,t),this},jr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(u0,e,t),this});function c0(t,e,r){e.set(t,r)}function u0(t,e,r){t.length<40?ss(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Y(t),r)}function Ss(){return new jr}function Ot(t,e){let r=Ss();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var Er;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(Er||(Er={}));function Kn(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function Yr(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return Kn("enum",Er.VARINT,r,n)}function Ht(t,e){return Kn("message",Er.LENGTH_DELIMITED,t,e)}var se;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1"})(se||(se={}));var ks;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1"})(ks||(ks={}));(function(t){t.codec=()=>Yr(ks)})(se||(se={}));var et;(function(t){let e;t.codec=()=>(e==null&&(e=Ht((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),se.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=se.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Ot(r,t.codec()),t.decode=(r,n)=>Mt(r,t.codec(),n)})(et||(et={}));var Cs;(function(t){let e;t.codec=()=>(e==null&&(e=Ht((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),se.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=se.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Ot(r,t.codec()),t.decode=(r,n)=>Mt(r,t.codec(),n)})(Cs||(Cs={}));var an={};Ee(an,{MAX_RSA_KEY_SIZE:()=>Mo,generateRSAKeyPair:()=>Au,jwkToJWKKeyPair:()=>Su,jwkToPkcs1:()=>T0,jwkToPkix:()=>Os,jwkToRSAPrivateKey:()=>Bu,pkcs1ToJwk:()=>bu,pkcs1ToRSAPrivateKey:()=>Eu,pkixToJwk:()=>vu,pkixToRSAPublicKey:()=>Hs});function l0(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ts(t,...e){if(!l0(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Is(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Sc(t,e){Ts(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var qn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ge=(t,e)=>t<<32-e|t>>>e;function f0(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Ns(t){return typeof t=="string"&&(t=f0(t)),Ts(t),t}var $n=class{clone(){return this._cloneInto()}};function kc(t){let e=n=>t().update(Ns(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function h0(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Cc=(t,e,r)=>t&e^~t&r,Tc=(t,e,r)=>t&e^t&r^e&r,zn=class extends $n{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=qn(this.buffer)}update(e){Is(this);let{view:r,buffer:n,blockLen:o}=this;e=Ns(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=qn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Is(this),Sc(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;h0(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=qn(e),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],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%r&&e.buffer.set(n),e}};var d0=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]),Pt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Kt=new Uint32Array(64),Us=class extends zn{constructor(){super(64,32,8,!1),this.A=Pt[0]|0,this.B=Pt[1]|0,this.C=Pt[2]|0,this.D=Pt[3]|0,this.E=Pt[4]|0,this.F=Pt[5]|0,this.G=Pt[6]|0,this.H=Pt[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|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(e,r){for(let l=0;l<16;l++,r+=4)Kt[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let h=Kt[l-15],b=Kt[l-2],E=Ge(h,7)^Ge(h,18)^h>>>3,y=Ge(b,17)^Ge(b,19)^b>>>10;Kt[l]=y+Kt[l-7]+E+Kt[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 h=Ge(a,6)^Ge(a,11)^Ge(a,25),b=u+h+Cc(a,c,f)+d0[l]+Kt[l]|0,y=(Ge(n,2)^Ge(n,13)^Ge(n,22))+Tc(n,o,i)|0;u=f,f=c,c=a,a=s+b|0,s=i,i=o,o=n,n=b+y|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(){Kt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Gn=kc(()=>new Us);var G=Fr(Ic());function or(t,e){let r=0;if(t.length===1)return t[0];for(let n=t.length-1;n>=0;n--)r+=t[t.length-1-n]*Math.pow(2,e*n);return r}function $t(t,e,r=-1){let n=r,o=t,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(t<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*e);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function jn(...t){let e=0,r=0;for(let i of t)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of t)o.set(i,r),r+=i.length;return o}function _s(){let t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=t[0]===255&&t[1]&128,c=t[0]===0&&(t[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)r[a]=0;r[0]=t[0]&128;let n=or(r,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=t[a];return i[0]&=127,or(i,8)-n}function Nc(t){let e=t<0?t*-1:t,r=128;for(let n=1;n<8;n++){if(e<=r){if(t<0){let s=r-e,a=$t(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=$t(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}r*=Math.pow(2,8)}return new ArrayBuffer(0)}function Uc(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let o=0;o<r.length;o++)if(r[o]!==n[o])return!1;return!0}function Ne(t,e){let r=t.toString(10);if(e<r.length)return"";let n=e-r.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(r)}var Py=Math.log(2);function Yn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Ls(t){let e=0,r=0;for(let o=0;o<t.length;o++){let i=t[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<t.length;o++){let i=t[o];n.set(new Uint8Array(i),r),r+=i.byteLength}return n.buffer}function xt(t,e,r,n){return e instanceof Uint8Array?e.byteLength?r<0?(t.error="Wrong parameter: inputOffset less than zero",!1):n<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-r-n<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Xr=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Ls(this.items)}},Jr=[new Uint8Array([1])],Rc="0123456789";var Cr="",We=new ArrayBuffer(0),Vs=new Uint8Array(0),Qr="EndOfContent",Lc="OCTET STRING",Vc="BIT STRING";function wt(t){var e;return e=class extends t{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?G.BufferSourceConverter.toUint8Array(i.valueHex):Vs}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!xt(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",We)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:G.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var gt=class{constructor({blockLength:e=0,error:r=Cr,warnings:n=[],valueBeforeDecode:o=Vs}={}){this.blockLength=e,this.error=r,this.warnings=n,this.valueBeforeDecodeView=G.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:G.Convert.ToHex(this.valueBeforeDecodeView)}}};gt.NAME="baseBlock";var be=class extends gt{fromBER(e,r,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};be.NAME="valueBlock";var Jn=class extends wt(gt){constructor({idBlock:e={}}={}){var r,n,o,i;super(),e?(this.isHexOnly=(r=e.isHexOnly)!==null&&r!==void 0?r:!1,this.valueHexView=e.valueHex?G.BufferSourceConverter.toUint8Array(e.valueHex):Vs,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let r=0;switch(this.tagClass){case 1:r|=0;break;case 2:r|=64;break;case 3:r|=128;break;case 4:r|=192;break;default:return this.error="Unknown tag class",We}if(this.isConstructed&&(r|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,r|=i,o[0]=r}return o.buffer}if(!this.isHexOnly){let o=$t(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=r|31,!e){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=r|31,!e){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!xt(this,o,r,n))return-1;let i=o.subarray(r,r+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let b=0;b<f.length;b++)h[b]=f[b];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let h=0;h<c;h++)l[h]=f[h];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=or(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return r+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Jn.NAME="identificationBlock";var Xn=class extends gt{constructor({lenBlock:e={}}={}){var r,n,o;super(),this.isIndefiniteForm=(r=e.isIndefiniteForm)!==null&&r!==void 0?r:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!xt(this,o,r,n))return-1;let i=o.subarray(r,r+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,r+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,r+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=r+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=or(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,r+this.blockLength}toBER(e=!1){let r,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=128),r;if(this.longFormUsed){let o=$t(this.length,8);if(o.byteLength>127)return this.error="Too big length",We;if(r=new ArrayBuffer(o.byteLength+1),e)return r;let i=new Uint8Array(o);n=new Uint8Array(r),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return r}return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=this.length),r}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Xn.NAME="lengthBlock";var L={},de=class extends gt{constructor({name:e=Cr,optional:r=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=r,n&&(this.primitiveSchema=n),this.idBlock=new Jn(o),this.lenBlock=new Xn(o),this.valueBlock=i?new i(o):new be(o)}fromBER(e,r,n){let o=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(e,r){let n=r||new Xr;r||Dc(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return r?We:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():G.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let r=this.toBER(),n=e.toBER();return Uc(r,n)}};de.NAME="BaseBlock";function Dc(t){if(t instanceof L.Constructed)for(let e of t.valueBlock.value)Dc(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}var Qn=class extends de{constructor({value:e=Cr,...r}={},n){super(r,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,r,n){let o=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Qn.NAME="BaseStringBlock";var eo=class extends wt(be){constructor({isHexOnly:e=!0,...r}={}){super(r),this.isHexOnly=e}};eo.NAME="PrimitiveValueBlock";var Fc,to=class extends de{constructor(e={}){super(e,eo),this.idBlock.isConstructed=!1}};Fc=to;L.Primitive=Fc;to.NAME="PRIMITIVE";function E0(t,e){if(t instanceof e)return t;let r=new e;return r.idBlock=t.idBlock,r.lenBlock=t.lenBlock,r.warnings=t.warnings,r.valueBeforeDecodeView=t.valueBeforeDecodeView,r}function Do(t,e=0,r=t.length){let n=e,o=new de({},be),i=new gt;if(!xt(i,t,e,r))return o.error=i.error,{offset:-1,result:o};if(!t.subarray(e,e+r).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(t,e,r);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,r-=o.idBlock.blockLength,a=o.lenBlock.fromBER(t,e,r),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,r-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=de;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=L.EndOfContent;break;case 1:c=L.Boolean;break;case 2:c=L.Integer;break;case 3:c=L.BitString;break;case 4:c=L.OctetString;break;case 5:c=L.Null;break;case 6:c=L.ObjectIdentifier;break;case 10:c=L.Enumerated;break;case 12:c=L.Utf8String;break;case 13:c=L.RelativeObjectIdentifier;break;case 14:c=L.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=L.Sequence;break;case 17:c=L.Set;break;case 18:c=L.NumericString;break;case 19:c=L.PrintableString;break;case 20:c=L.TeletexString;break;case 21:c=L.VideotexString;break;case 22:c=L.IA5String;break;case 23:c=L.UTCTime;break;case 24:c=L.GeneralizedTime;break;case 25:c=L.GraphicString;break;case 26:c=L.VisibleString;break;case 27:c=L.GeneralString;break;case 28:c=L.UniversalString;break;case 29:c=L.CharacterString;break;case 30:c=L.BmpString;break;case 31:c=L.DATE;break;case 32:c=L.TimeOfDay;break;case 33:c=L.DateTime;break;case 34:c=L.Duration;break;default:{let f=o.idBlock.isConstructed?new L.Constructed:new L.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?L.Constructed:L.Primitive}return o=E0(o,c),a=o.fromBER(t,e,o.lenBlock.isIndefiniteForm?r:o.lenBlock.length),o.valueBeforeDecodeView=t.subarray(n,n+o.blockLength),{offset:a,result:o}}function Ds(t){if(!t.byteLength){let e=new de({},be);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Do(G.BufferSourceConverter.toUint8Array(t).slice(),0,t.byteLength)}function B0(t,e){return t?1:e}var tt=class extends be{constructor({value:e=[],isIndefiniteForm:r=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=r}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!xt(this,o,r,n))return-1;if(this.valueBeforeDecodeView=o.subarray(r,r+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),r;let i=r;for(;B0(this.isIndefiniteForm,n)>0;){let s=Do(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===Qr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Qr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,r){let n=r||new Xr;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return r?We:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let r of this.value)e.value.push(r.toJSON());return e}};tt.NAME="ConstructedValueBlock";var Mc,qt=class extends de{constructor(e={}){super(e,tt),this.idBlock.isConstructed=!0}fromBER(e,r,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
2
|
+
"use strict";var HeliaIpns=(()=>{var lf=Object.create;var xn=Object.defineProperty;var ff=Object.getOwnPropertyDescriptor;var hf=Object.getOwnPropertyNames;var df=Object.getPrototypeOf,pf=Object.prototype.hasOwnProperty;var yi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ee=(t,e)=>{for(var r in e)xn(t,r,{get:e[r],enumerable:!0})},aa=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of hf(e))!pf.call(t,o)&&o!==r&&xn(t,o,{get:()=>e[o],enumerable:!(n=ff(e,o))||n.enumerable});return t};var Vr=(t,e,r)=>(r=t!=null?lf(df(t)):{},aa(e||!t||!t.__esModule?xn(r,"default",{value:t,enumerable:!0}):r,t)),gf=t=>aa(xn({},"__esModule",{value:!0}),t);var mc=yi(vr=>{"use strict";var Jd="[object ArrayBuffer]",dt=class t{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Jd}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,r){if(e.constructor===r)return e;if(this.isArrayBuffer(e))return new r(e);if(this.isArrayBufferView(e))return new r(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,r){let n=t.toUint8Array(e),o=t.toUint8Array(r);if(n.length!==o.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(...e){let r;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?r=e[0]:e[e.length-1]instanceof Function?r=e.slice(0,e.length-1):r=e;let n=0;for(let s of r)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of r){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},Bs="string",Xd=/^[0-9a-f\s]+$/i,Qd=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,e0=/^[a-zA-Z0-9-_]+$/,Pn=class{static fromString(e){let r=unescape(encodeURIComponent(e)),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n.buffer}static toString(e){let r=dt.toUint8Array(e),n="";for(let i=0;i<r.length;i++)n+=String.fromCharCode(r[i]);return decodeURIComponent(escape(n))}},Fe=class{static toString(e,r=!1){let n=dt.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,r);i+=String.fromCharCode(a)}return i}static fromString(e,r=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let i=0;i<e.length;i++)o.setUint16(i*2,e.charCodeAt(i),r);return n}},Kn=class t{static isHex(e){return typeof e===Bs&&Xd.test(e)}static isBase64(e){return typeof e===Bs&&Qd.test(e)}static isBase64Url(e){return typeof e===Bs&&e0.test(e)}static ToString(e,r="utf8"){let n=dt.toUint8Array(e);switch(r.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Fe.toString(n,!0);case"utf16":case"utf16be":return Fe.toString(n);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromString(e,r="utf8"){if(!e)return new ArrayBuffer(0);switch(r.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Fe.fromString(e,!0);case"utf16":case"utf16be":return Fe.fromString(e);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToBase64(e){let r=dt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(r,"binary");return btoa(n)}else return Buffer.from(r).toString("base64")}static FromBase64(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64(r))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(r)):new Uint8Array(Buffer.from(r,"base64")).buffer}static FromBase64Url(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64Url(r))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(r.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.FromBinary(e);case"utf8":return Pn.fromString(e);case"utf16":case"utf16be":return Fe.fromString(e);case"utf16le":case"usc2":return Fe.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.ToBinary(e);case"utf8":return Pn.toString(e);case"utf16":case"utf16be":return Fe.toString(e);case"utf16le":case"usc2":return Fe.toString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromBinary(e){let r=e.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let r=dt.toUint8Array(e),n="";for(let o=0;o<r.length;o++)n+=String.fromCharCode(r[o]);return n}static ToHex(e){let r=dt.toUint8Array(e),n="",o=r.length;for(let i=0;i<o;i++){let s=r[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isHex(r))throw new TypeError("Argument 'hexString' is not HEX encoded");r.length%2&&(r=`0${r}`);let n=new Uint8Array(r.length/2);for(let o=0;o<r.length;o=o+2){let i=r.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,r=!1){return Fe.toString(e,r)}static FromUtf16String(e,r=!1){return Fe.fromString(e,r)}static Base64Padding(e){let r=4-e.length%4;if(r<4)for(let n=0;n<r;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};Kn.DEFAULT_UTF8_ENCODING="utf8";function t0(t,...e){let r=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)r[i]=o[i]}return r}function r0(...t){let e=t.map(o=>o.byteLength).reduce((o,i)=>o+i),r=new Uint8Array(e),n=0;return t.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)r[n++]=i}),r.buffer}function n0(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let o=0;o<t.byteLength;o++)if(r[o]!==n[o])return!1;return!0}vr.BufferSourceConverter=dt;vr.Convert=Kn;vr.assign=t0;vr.combine=r0;vr.isEqual=n0});var Fo=yi((Xx,Fs)=>{var Jx=function(){typeof Fs<"u"&&(Fs.exports=y);var t=86400,e=3200,r=146097*e/400,n=t*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",l=Math.trunc||function(w){var b=w-w%1;return b==0&&(w<0||w===0&&1/w!=1/0)?-0:b},u=y.prototype,f=(y.fromDate=function(w){return new y(+w)},y.fromInt64BE=U(0,1,2,3,0,4),y.fromInt64LE=U(3,2,1,0,4,0),y.fromString=function(_){var b,M=new y,_=(_+="").replace(/^\s*[+\-]?\d+/,function(K){var K=+K,S=1970+(K-1970)%400;return M.year=K-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(I,K,S){return K<0&&(S*=-1),b=6e4*(60*+K+ +S),""}).replace(/\.\d+$/,function(I){return M.nano=+(I+c).substr(1,9),""}).split(/\D+/);if(1<_.length?_[1]--:_[1]=0,M.time=b=Date.UTC.apply(Date,_)-(b||0),isNaN(b))throw new TypeError("Invalid Date");return d(M)},y.fromTimeT=function(w){return T(w,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(w){return this.nano+=+w||0,this},u.getNano=function(){var w=d(this);return(w.time%1e3*a+ +w.nano+1e9)%1e9},u.getTimeT=function(){var b=d(this),w=Math.floor(b.time/1e3),b=b.year;return b&&(w+=b*r*t/e),w},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return A(d(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(w){var b=this,M=b.toDate(),_={H:function(){return D(M.getUTCHours())},L:function(){return R(M.getUTCMilliseconds(),3)},M:function(){return D(M.getUTCMinutes())},N:function(){return R(b.getNano(),9)},S:function(){return D(M.getUTCSeconds())},Y:function(){var I=b.getYear();return 999999<I?"+"+I:9999<I?"+"+R(I,6):0<=I?R(I,4):-999999<=I?"-"+R(-I,6):I},a:function(){return v[M.getUTCDay()]},b:function(){return h[M.getUTCMonth()]},d:function(){return D(M.getUTCDate())},e:function(){return function(I){return(9<I?"":" ")+(0|I)}(M.getUTCDate())},m:function(){return D(M.getUTCMonth()+1)}};return function I(K){return K.replace(/%./g,function(S){var m=S[1],k=E[m],m=_[m];return k?I(k):m?m():S})}(w||f)},u.writeInt64BE=x(0,1,2,3,0,4),u.writeInt64LE=x(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],E={"%":"%",F:"%Y-%m-%d",n:`
|
|
3
|
+
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(w,b,M){var _=this;if(!(_ instanceof y))return new y(w,b,M);_.time=+w||0,_.nano=+b||0,_.year=+M||0,d(_)}function d(w){var b,M,_,I=w.year,K=w.time,S=w.nano,k=((S<0||a<=S)&&(S-=(M=Math.floor(S/a))*a,K+=M,M=1),I%e);return(K<-i||i<K||k)&&((b=l(K/o))&&(I+=b*e,K-=b*o),(_=A(K)).setUTCFullYear(k+_.getUTCFullYear()),_=(K=+_)+(b=l((I-=k)/e))*o,b&&-i<=_&&_<=i&&(I-=b*e,K=_),M=1),M&&(w.year=I,w.time=K,w.nano=S),w}function A(w){var b=new Date(0);return b.setTime(w),b}function T(I,_){I=+I||0;var M=l((_=(_|0)*s)/n)+l(I/n),_=_%n+I%n,I=l(_/n);return I&&(M+=I,_-=I*n),new y(1e3*_,0,M*e)}function x(w,b,M,_,I,K){return function(k,m){var B=d(this);k=k||new Array(8),F(k,m|=0);var N=Math.floor(B.time/1e3),B=B.year*(r*t/e),p=l(B/s)+l(N/s),B=B%s+N%s,N=Math.floor(B/s);return N&&(p+=N,B-=N*s),S(k,m+I,p),S(k,m+K,B),k};function S(k,m,p){k[m+w]=p>>24&255,k[m+b]=p>>16&255,k[m+M]=p>>8&255,k[m+_]=255&p}}function U(w,b,M,_,I,K){return function(k,m){F(k,m|=0);var p=S(k,m+I);return T(S(k,m+K),p)};function S(k,m){return 16777216*k[m+w]+(k[m+b]<<16|k[m+M]<<8|k[m+_])}}function F(w,b){if(w=w&&w.length,w==null)throw new TypeError("Invalid Buffer");if(w<b+8)throw new RangeError("Out of range")}function D(w){return(9<w?"":"0")+(0|w)}function R(w,b){return(c+(0|w)).substr(-b)}}()});var Gl=yi((f1,zl)=>{zl.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,e++,e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var Np={};Ee(Np,{ipns:()=>Ip,ipnsSelector:()=>ri,ipnsValidator:()=>oi});function ca(t){return t==null?!1:(t.type==="RSA"||t.type==="Ed25519"||t.type==="secp256k1")&&t.raw instanceof Uint8Array&&typeof t.equals=="function"&&typeof t.toMultihash=="function"&&typeof t.toCID=="function"&&typeof t.verify=="function"}var xi=Symbol.for("@libp2p/peer-id");var xe=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},sr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Dr=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var ar=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var cr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Bi={};Ee(Bi,{base32:()=>kt,base32hex:()=>Af,base32hexpad:()=>kf,base32hexpadupper:()=>Cf,base32hexupper:()=>Sf,base32pad:()=>Ef,base32padupper:()=>Bf,base32upper:()=>vf,base32z:()=>Tf});var Vp=new Uint8Array(0);function ua(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function st(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function la(t){return new TextEncoder().encode(t)}function fa(t){return new TextDecoder().decode(t)}function mf(t,e){if(t.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<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(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,d=0,A=0,T=E.length;A!==T&&E[A]===0;)A++,y++;for(var x=(T-A)*u+1>>>0,U=new Uint8Array(x);A!==T;){for(var F=E[A],D=0,R=x-1;(F!==0||D<d)&&R!==-1;R--,D++)F+=256*U[R]>>>0,U[R]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");d=D,A++}for(var w=x-d;w!==x&&U[w]===0;)w++;for(var b=c.repeat(y);w<x;++w)b+=t.charAt(U[w]);return b}function h(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 d=0,A=0;E[y]===c;)d++,y++;for(var T=(E.length-y)*l+1>>>0,x=new Uint8Array(T);E[y];){var U=r[E.charCodeAt(y)];if(U===255)return;for(var F=0,D=T-1;(U!==0||F<A)&&D!==-1;D--,F++)U+=a*x[D]>>>0,x[D]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");A=F,y++}if(E[y]!==" "){for(var R=T-A;R!==T&&x[R]===0;)R++;for(var w=new Uint8Array(d+(T-R)),b=d;R!==T;)w[b++]=x[R++];return w}}}function v(E){var y=h(E);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:v}}var yf=mf,xf=yf,da=xf;var wi=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},bi=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,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(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return pa(this,e)}},vi=class{decoders;constructor(e){this.decoders=e}or(e){return pa(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function pa(t,e){return new vi({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Ei=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new wi(e,r,n),this.decoder=new bi(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ur({name:t,prefix:e,encode:r,decode:n}){return new Ei(t,e,r,n)}function St({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=da(r,t);return ur({prefix:e,name:t,encode:n,decode:i=>st(o(i))})}function wf(t,e,r,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let i=t.length;for(;t[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,l=0;for(let u=0;u<i;++u){let f=o[t[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function bf(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function oe({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return ur({prefix:e,name:t,encode(o){return bf(o,n,r)},decode(o){return wf(o,n,r,t)}})}var kt=oe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),vf=oe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ef=oe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bf=oe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Af=oe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Sf=oe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),kf=oe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Cf=oe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Tf=oe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ai={};Ee(Ai,{base58btc:()=>Q,base58flickr:()=>If});var Q=St({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),If=St({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ki={};Ee(ki,{base64:()=>Si,base64pad:()=>Nf,base64url:()=>Uf,base64urlpad:()=>Rf});var Si=oe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Nf=oe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Uf=oe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Rf=oe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function _f(t,e){try{if(typeof t=="string"&&t.length>0)return Lf(t);if(typeof t=="number"&&isFinite(t))return e?.long?Df(t):Vf(t);throw new Error("Value is not a string or number.")}catch(r){let n=Ff(r)?`${r.message}. value=${JSON.stringify(t)}`:"An unknown error has occured.";throw new Error(n)}}function Lf(t){if(t=String(t),t.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return NaN;let r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var bn=_f;function Vf(t){let e=Math.abs(t);return e>=864e5?`${Math.round(t/864e5)}d`:e>=36e5?`${Math.round(t/36e5)}h`:e>=6e4?`${Math.round(t/6e4)}m`:e>=1e3?`${Math.round(t/1e3)}s`:`${t}ms`}function Df(t){let e=Math.abs(t);return e>=864e5?wn(t,e,864e5,"day"):e>=36e5?wn(t,e,36e5,"hour"):e>=6e4?wn(t,e,6e4,"minute"):e>=1e3?wn(t,e,1e3,"second"):`${t} ms`}function wn(t,e,r,n){let o=e>=r*1.5;return`${Math.round(t/r)} ${n}${o?"s":""}`}function Ff(t){return typeof t=="object"&&t!==null&&"message"in t}function Ci(t){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=bn,r.destroy=l,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let f=0;for(let h=0;h<u.length;h++)f=(f<<5)-f+u.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(u){let f,h=null,v,E;function y(...d){if(!y.enabled)return;let A=y,T=Number(new Date),x=T-(f||T);A.diff=x,A.prev=f,A.curr=T,f=T,d[0]=r.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let U=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(D,R)=>{if(D==="%%")return"%";U++;let w=r.formatters[R];if(typeof w=="function"){let b=d[U];D=w.call(A,b),d.splice(U,1),U--}return D}),r.formatArgs.call(A,d),(A.log||r.log).apply(A,d)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(v!==r.namespaces&&(v=r.namespaces,E=r.enabled(u)),E),set:d=>{h=d}}),typeof r.init=="function"&&r.init(y),y}function n(u,f){let h=r(this.namespace+(typeof f>"u"?":":f)+u);return h.log=this.log,h}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,h=(typeof u=="string"?u:"").split(/[\s,]+/),v=h.length;for(f=0;f<v;f++)h[f]&&(u=h[f].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(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,h;for(f=0,h=r.skips.length;f<h;f++)if(r.skips[f].test(u))return!1;for(f=0,h=r.names.length;f<h;f++)if(r.names[f].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 l(){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 vn=qf(),Mf=["#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 Of(){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 Hf(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+bn(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}var Pf=console.debug??console.log??(()=>{});function Kf(t){try{t?vn?.setItem("debug",t):vn?.removeItem("debug")}catch{}}function $f(){let t;try{t=vn?.getItem("debug")}catch{}return!t&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(t=globalThis.process.env.DEBUG),t}function qf(){try{return localStorage}catch{}}function zf(t){t.j=function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var ga=Ci({formatArgs:Hf,save:Kf,load:$f,useColors:Of,setupFormatters:zf,colors:Mf,storage:vn,log:Pf});var Ce=ga;Ce.formatters.b=t=>t==null?"undefined":Q.baseEncode(t);Ce.formatters.t=t=>t==null?"undefined":kt.baseEncode(t);Ce.formatters.m=t=>t==null?"undefined":Si.baseEncode(t);Ce.formatters.p=t=>t==null?"undefined":t.toString();Ce.formatters.c=t=>t==null?"undefined":t.toString();Ce.formatters.k=t=>t==null?"undefined":t.toString();Ce.formatters.a=t=>t==null?"undefined":t.toString();Ce.formatters.e=t=>t==null?"undefined":ma(t.stack)??ma(t.message)??t.toString();function Gf(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Ct(t){let e=Gf(`${t}:trace`);return Ce.enabled(`${t}:trace`)&&Ce.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=Ce(`${t}:trace`)),Object.assign(Ce(t),{error:Ce(`${t}:error`),trace:e})}function ma(t){if(t!=null&&(t=t.trim(),t.length!==0))return t}var Ti={};Ee(Ti,{base36:()=>He,base36upper:()=>Zf});var He=St({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zf=St({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Wf=wa,ya=128,jf=127,Yf=~jf,Jf=Math.pow(2,31);function wa(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Jf;)e[r++]=t&255|ya,t/=128;for(;t&Yf;)e[r++]=t&255|ya,t>>>=7;return e[r]=t|0,wa.bytes=r-n+1,e}var Xf=Ii,Qf=128,xa=127;function Ii(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw Ii.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&xa)<<o:(s&xa)*Math.pow(2,o),o+=7}while(s>=Qf);return Ii.bytes=i-n,r}var eh=Math.pow(2,7),th=Math.pow(2,14),rh=Math.pow(2,21),nh=Math.pow(2,28),oh=Math.pow(2,35),ih=Math.pow(2,42),sh=Math.pow(2,49),ah=Math.pow(2,56),ch=Math.pow(2,63),uh=function(t){return t<eh?1:t<th?2:t<rh?3:t<nh?4:t<oh?5:t<ih?6:t<sh?7:t<ah?8:t<ch?9:10},lh={encode:Wf,decode:Xf,encodingLength:uh},fh=lh,Fr=fh;function Mr(t,e=0){return[Fr.decode(t,e),Fr.decode.bytes]}function lr(t,e,r=0){return Fr.encode(t,e,r),e}function fr(t){return Fr.encodingLength(t)}function Pe(t,e){let r=e.byteLength,n=fr(t),o=n+fr(r),i=new Uint8Array(o+r);return lr(t,i,0),lr(r,i,n),i.set(e,o),new hr(t,r,e,i)}function at(t){let e=st(t),[r,n]=Mr(e),[o,i]=Mr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new hr(r,o,s,e)}function ba(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ua(t.bytes,r.bytes)}}var hr=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function va(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return dh(r,Ni(t),e??Q.encoder);default:return ph(r,Ni(t),e??kt.encoder)}}var Ea=new WeakMap;function Ni(t){let e=Ea.get(t);if(e==null){let r=new Map;return Ea.set(t,r),r}return e}var re=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==Or)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==gh)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.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:e,digest:r}=this.multihash,n=Pe(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&ba(e.multihash,n.multihash)}toString(e){return va(this,e)}toJSON(){return{"/":va(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??Ba(n,o,i.bytes))}else if(r[mh]===!0){let{version:n,multihash:o,code:i}=r,s=at(o);return t.create(n,i,s)}else return null}static create(e,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(e){case 0:{if(r!==Or)throw new Error(`Version 0 CID must use dag-pb (code: ${Or}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Ba(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Or,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=st(e.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 hr(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[f,h]=Mr(e.subarray(r));return r+=h,f},o=n(),i=Or;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(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(e,r){let[n,o]=hh(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ni(i).set(n,e),i}};function hh(t,e){switch(t[0]){case"Q":{let r=e??Q;return[Q.prefix,r.decode(`${Q.prefix}${t}`)]}case Q.prefix:{let r=e??Q;return[Q.prefix,r.decode(t)]}case kt.prefix:{let r=e??kt;return[kt.prefix,r.decode(t)]}case He.prefix:{let r=e??He;return[He.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function dh(t,e,r){let{prefix:n}=r;if(n!==Q.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function ph(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var Or=112,gh=18;function Ba(t,e,r){let n=fr(t),o=n+fr(e),i=new Uint8Array(o+r.byteLength);return lr(t,i,0),lr(e,i,n),i.set(r,o),i}var mh=Symbol.for("@ipld/js-cid/CID");var Ui={};Ee(Ui,{identity:()=>ct});var Aa=0,yh="identity",Sa=st;function xh(t){return Pe(Aa,Sa(t))}var ct={code:Aa,name:yh,encode:Sa,digest:xh};function he(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function ka(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function wh(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function dr(t,...e){if(!wh(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ca(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ka(t.outputLen),ka(t.blockLen)}function pr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ta(t,e){dr(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var Zt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Bn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ke=(t,e)=>t<<32-e|t>>>e;function Ia(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Hr(t){return typeof t=="string"&&(t=Ia(t)),dr(t),t}function Ri(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];dr(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var gr=class{clone(){return this._cloneInto()}};function An(t){let e=n=>t().update(Hr(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Sn(t=32){if(Zt&&typeof Zt.getRandomValues=="function")return Zt.getRandomValues(new Uint8Array(t));if(Zt&&typeof Zt.randomBytes=="function")return Zt.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function bh(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,l=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+l,a,n)}var Na=(t,e,r)=>t&e^~t&r,Ua=(t,e,r)=>t&e^t&r^e&r,mr=class extends gr{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Bn(this.buffer)}update(e){pr(this);let{view:r,buffer:n,blockLen:o}=this;e=Hr(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Bn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){pr(this),Ta(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;bh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Bn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%r&&e.buffer.set(n),e}};var kn=BigInt(4294967295),_i=BigInt(32);function Ra(t,e=!1){return e?{h:Number(t&kn),l:Number(t>>_i&kn)}:{h:Number(t>>_i&kn)|0,l:Number(t&kn)|0}}function vh(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:i,l:s}=Ra(t[o],e);[r[o],n[o]]=[i,s]}return[r,n]}var Eh=(t,e)=>BigInt(t>>>0)<<_i|BigInt(e>>>0),Bh=(t,e,r)=>t>>>r,Ah=(t,e,r)=>t<<32-r|e>>>r,Sh=(t,e,r)=>t>>>r|e<<32-r,kh=(t,e,r)=>t<<32-r|e>>>r,Ch=(t,e,r)=>t<<64-r|e>>>r-32,Th=(t,e,r)=>t>>>r-32|e<<64-r,Ih=(t,e)=>e,Nh=(t,e)=>t,Uh=(t,e,r)=>t<<r|e>>>32-r,Rh=(t,e,r)=>e<<r|t>>>32-r,_h=(t,e,r)=>e<<r-32|t>>>64-r,Lh=(t,e,r)=>t<<r-32|e>>>64-r;function Vh(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var Dh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Fh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Mh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Oh=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,Hh=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ph=(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0;var Kh={fromBig:Ra,split:vh,toBig:Eh,shrSH:Bh,shrSL:Ah,rotrSH:Sh,rotrSL:kh,rotrBH:Ch,rotrBL:Th,rotr32H:Ih,rotr32L:Nh,rotlSH:Uh,rotlSL:Rh,rotlBH:_h,rotlBL:Lh,add:Vh,add3L:Dh,add3H:Fh,add4L:Mh,add4H:Oh,add5H:Ph,add5L:Hh},q=Kh;var[$h,qh]=q.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(t=>BigInt(t))),It=new Uint32Array(80),Nt=new Uint32Array(80),Li=class extends mr{constructor(){super(128,64,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:e,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:h,Gh:v,Gl:E,Hh:y,Hl:d}=this;return[e,r,n,o,i,s,a,c,l,u,f,h,v,E,y,d]}set(e,r,n,o,i,s,a,c,l,u,f,h,v,E,y,d){this.Ah=e|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=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=v|0,this.Gl=E|0,this.Hh=y|0,this.Hl=d|0}process(e,r){for(let x=0;x<16;x++,r+=4)It[x]=e.getUint32(r),Nt[x]=e.getUint32(r+=4);for(let x=16;x<80;x++){let U=It[x-15]|0,F=Nt[x-15]|0,D=q.rotrSH(U,F,1)^q.rotrSH(U,F,8)^q.shrSH(U,F,7),R=q.rotrSL(U,F,1)^q.rotrSL(U,F,8)^q.shrSL(U,F,7),w=It[x-2]|0,b=Nt[x-2]|0,M=q.rotrSH(w,b,19)^q.rotrBH(w,b,61)^q.shrSH(w,b,6),_=q.rotrSL(w,b,19)^q.rotrBL(w,b,61)^q.shrSL(w,b,6),I=q.add4L(R,_,Nt[x-7],Nt[x-16]),K=q.add4H(I,D,M,It[x-7],It[x-16]);It[x]=K|0,Nt[x]=I|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:h,Fh:v,Fl:E,Gh:y,Gl:d,Hh:A,Hl:T}=this;for(let x=0;x<80;x++){let U=q.rotrSH(f,h,14)^q.rotrSH(f,h,18)^q.rotrBH(f,h,41),F=q.rotrSL(f,h,14)^q.rotrSL(f,h,18)^q.rotrBL(f,h,41),D=f&v^~f&y,R=h&E^~h&d,w=q.add5L(T,F,R,qh[x],Nt[x]),b=q.add5H(w,A,U,D,$h[x],It[x]),M=w|0,_=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),I=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),K=n&i^n&a^i&a,S=o&s^o&c^s&c;A=y|0,T=d|0,y=v|0,d=E|0,v=f|0,E=h|0,{h:f,l:h}=q.add(l|0,u|0,b|0,M|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let k=q.add3L(M,I,S);n=q.add3H(k,b,_,K),o=k|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=q.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=q.add(this.Eh|0,this.El|0,f|0,h|0),{h:v,l:E}=q.add(this.Fh|0,this.Fl|0,v|0,E|0),{h:y,l:d}=q.add(this.Gh|0,this.Gl|0,y|0,d|0),{h:A,l:T}=q.add(this.Hh|0,this.Hl|0,A|0,T|0),this.set(n,o,i,s,a,c,l,u,f,h,v,E,y,d,A,T)}roundClean(){It.fill(0),Nt.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 _a=An(()=>new Li);var In={};Ee(In,{aInRange:()=>Te,abool:()=>$e,abytes:()=>yr,bitGet:()=>Yh,bitLen:()=>Mi,bitMask:()=>Kr,bitSet:()=>Jh,bytesToHex:()=>lt,bytesToNumberBE:()=>ft,bytesToNumberLE:()=>Rt,concatBytes:()=>ht,createHmacDrbg:()=>Oi,ensureBytes:()=>ne,equalBytes:()=>Wh,hexToBytes:()=>jt,hexToNumber:()=>Fi,inRange:()=>Pr,isBytes:()=>Ut,memoized:()=>Jt,notImplemented:()=>Qh,numberToBytesBE:()=>_t,numberToBytesLE:()=>Yt,numberToHexUnpadded:()=>Wt,numberToVarBytesBE:()=>Zh,utf8ToBytes:()=>jh,validateObject:()=>Je});var Cn=BigInt(0),Tn=BigInt(1),zh=BigInt(2);function Ut(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function yr(t){if(!Ut(t))throw new Error("Uint8Array expected")}function $e(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}var Gh=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function lt(t){yr(t);let e="";for(let r=0;r<t.length;r++)e+=Gh[t[r]];return e}function Wt(t){let e=t.toString(16);return e.length&1?"0"+e:e}function Fi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Cn:BigInt("0x"+t)}var ut={_0:48,_9:57,A:65,F:70,a:97,f:102};function La(t){if(t>=ut._0&&t<=ut._9)return t-ut._0;if(t>=ut.A&&t<=ut.F)return t-(ut.A-10);if(t>=ut.a&&t<=ut.f)return t-(ut.a-10)}function jt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=La(t.charCodeAt(i)),a=La(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function ft(t){return Fi(lt(t))}function Rt(t){return yr(t),Fi(lt(Uint8Array.from(t).reverse()))}function _t(t,e){return jt(t.toString(16).padStart(e*2,"0"))}function Yt(t,e){return _t(t,e).reverse()}function Zh(t){return jt(Wt(t))}function ne(t,e,r){let n;if(typeof e=="string")try{n=jt(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Ut(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}function ht(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];yr(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function Wh(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function jh(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}var Vi=t=>typeof t=="bigint"&&Cn<=t;function Pr(t,e,r){return Vi(t)&&Vi(e)&&Vi(r)&&e<=t&&t<r}function Te(t,e,r,n){if(!Pr(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Mi(t){let e;for(e=0;t>Cn;t>>=Tn,e+=1);return e}function Yh(t,e){return t>>BigInt(e)&Tn}function Jh(t,e,r){return t|(r?Tn:Cn)<<BigInt(e)}var Kr=t=>(zh<<BigInt(t-1))-Tn,Di=t=>new Uint8Array(t),Va=t=>Uint8Array.from(t);function Oi(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Di(t),o=Di(t),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...f)=>r(o,n,...f),c=(f=Di())=>{o=a(Va([0]),f),n=a(),f.length!==0&&(o=a(Va([1]),f),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<e;){n=a();let v=n.slice();h.push(v),f+=n.length}return ht(...h)};return(f,h)=>{s(),c(f);let v;for(;!(v=h(l()));)c();return s(),v}}var Xh={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Ut(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Je(t,e,r={}){let n=(o,i,s)=>{let a=Xh[i];if(typeof a!="function")throw new Error("invalid validator function");let c=t[o];if(!(s&&c===void 0)&&!a(c,t))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return t}var Qh=()=>{throw new Error("not implemented")};function Jt(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var ie=BigInt(0),ee=BigInt(1),Xt=BigInt(2),ed=BigInt(3),Hi=BigInt(4),Da=BigInt(5),Fa=BigInt(8),td=BigInt(9),rd=BigInt(16);function J(t,e){let r=t%e;return r>=ie?r:e+r}function nd(t,e,r){if(e<ie)throw new Error("invalid exponent, negatives unsupported");if(r<=ie)throw new Error("invalid modulus");if(r===ee)return ie;let n=ee;for(;e>ie;)e&ee&&(n=n*t%r),t=t*t%r,e>>=ee;return n}function te(t,e,r){let n=t;for(;e-- >ie;)n*=n,n%=r;return n}function Nn(t,e){if(t===ie)throw new Error("invert: expected non-zero number");if(e<=ie)throw new Error("invert: expected positive modulus, got "+e);let r=J(t,e),n=e,o=ie,i=ee,s=ee,a=ie;for(;r!==ie;){let l=n/r,u=n%r,f=o-s*l,h=i-a*l;n=r,r=u,o=s,i=a,s=f,a=h}if(n!==ee)throw new Error("invert: does not exist");return J(o,e)}function od(t){let e=(t-ee)/Xt,r,n,o;for(r=t-ee,n=0;r%Xt===ie;r/=Xt,n++);for(o=Xt;o<t&&nd(o,e,t)!==t-ee;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(t+ee)/Hi;return function(c,l){let u=c.pow(l,s);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}let i=(r+ee)/Xt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,u=a.pow(a.mul(a.ONE,o),r),f=a.pow(c,i),h=a.pow(c,r);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let v=1;for(let y=a.sqr(h);v<l&&!a.eql(y,a.ONE);v++)y=a.sqr(y);let E=a.pow(u,ee<<BigInt(l-v-1));u=a.sqr(E),f=a.mul(f,E),h=a.mul(h,u),l=v}return f}}function id(t){if(t%Hi===ed){let e=(t+ee)/Hi;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%Fa===Da){let e=(t-Da)/Fa;return function(n,o){let i=n.mul(o,Xt),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,Xt),s),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return t%rd,od(t)}var Ma=(t,e)=>(J(t,e)&ee)===ee,sd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pi(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=sd.reduce((n,o)=>(n[o]="function",n),e);return Je(t,r)}function ad(t,e,r){if(r<ie)throw new Error("invalid exponent, negatives unsupported");if(r===ie)return t.ONE;if(r===ee)return e;let n=t.ONE,o=e;for(;r>ie;)r&ee&&(n=t.mul(n,o)),o=t.sqr(o),r>>=ee;return n}function cd(t,e){let r=new Array(e.length),n=e.reduce((i,s,a)=>t.is0(s)?i:(r[a]=i,t.mul(i,s)),t.ONE),o=t.inv(n);return e.reduceRight((i,s,a)=>t.is0(s)?i:(r[a]=t.mul(i,r[a]),t.mul(i,s)),o),r}function Ki(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Lt(t,e,r=!1,n={}){if(t<=ie)throw new Error("invalid field: expected ORDER > 0, got "+t);let{nBitLength:o,nByteLength:i}=Ki(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:t,isLE:r,BITS:o,BYTES:i,MASK:Kr(o),ZERO:ie,ONE:ee,create:c=>J(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ie<=c&&c<t},is0:c=>c===ie,isOdd:c=>(c&ee)===ee,neg:c=>J(-c,t),eql:(c,l)=>c===l,sqr:c=>J(c*c,t),add:(c,l)=>J(c+l,t),sub:(c,l)=>J(c-l,t),mul:(c,l)=>J(c*l,t),pow:(c,l)=>ad(a,c,l),div:(c,l)=>J(c*Nn(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Nn(c,t),sqrt:n.sqrt||(c=>(s||(s=id(t)),s(a,c))),invertBatch:c=>cd(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?Yt(c,i):_t(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?Rt(c):ft(c)}});return Object.freeze(a)}function Oa(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function $i(t){let e=Oa(t);return e+Math.ceil(e/2)}function Ha(t,e,r=!1){let n=t.length,o=Oa(e),i=$i(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Rt(t):ft(t),a=J(s,e-ee)+ee;return r?Yt(a,o):_t(a,o)}var Pa=BigInt(0),Un=BigInt(1);function qi(t,e){let r=e.negate();return t?r:e}function Ka(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function zi(t,e){Ka(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1);return{windows:r,windowSize:n}}function ld(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function fd(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}var Gi=new WeakMap,$a=new WeakMap;function Zi(t){return $a.get(t)||1}function Rn(t,e){return{constTimeNegate:qi,hasPrecomputes(r){return Zi(r)!==1},unsafeLadder(r,n,o=t.ZERO){let i=r;for(;n>Pa;)n&Un&&(o=o.add(i)),i=i.double(),n>>=Un;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=zi(n,e),s=[],a=r,c=a;for(let l=0;l<o;l++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let{windows:i,windowSize:s}=zi(r,e),a=t.ZERO,c=t.BASE,l=BigInt(2**r-1),u=2**r,f=BigInt(r);for(let h=0;h<i;h++){let v=h*s,E=Number(o&l);o>>=f,E>s&&(E-=u,o+=Un);let y=v,d=v+Math.abs(E)-1,A=h%2!==0,T=E<0;E===0?c=c.add(qi(A,n[y])):a=a.add(qi(T,n[d]))}return{p:a,f:c}},wNAFUnsafe(r,n,o,i=t.ZERO){let{windows:s,windowSize:a}=zi(r,e),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let f=0;f<s;f++){let h=f*a;if(o===Pa)break;let v=Number(o&c);if(o>>=u,v>a&&(v-=l,o+=Un),v===0)continue;let E=n[h+Math.abs(v)-1];v<0&&(E=E.negate()),i=i.add(E)}return i},getPrecomputes(r,n,o){let i=Gi.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&Gi.set(n,o(i))),i},wNAFCached(r,n,o){let i=Zi(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=Zi(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Ka(n,e),$a.set(r,n),Gi.delete(r)}}}function _n(t,e,r,n){if(ld(r,t),fd(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=t.ZERO,i=Mi(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,c=new Array(a+1).fill(o),l=Math.floor((e.BITS-1)/s)*s,u=o;for(let f=l;f>=0;f-=s){c.fill(o);for(let v=0;v<n.length;v++){let E=n[v],y=Number(E>>BigInt(f)&BigInt(a));c[y]=c[y].add(r[v])}let h=o;for(let v=c.length-1,E=o;v>0;v--)E=E.add(c[v]),h=h.add(E);if(u=u.add(h),f!==0)for(let v=0;v<s;v++)u=u.double()}return u}function $r(t){return Pi(t.Fp),Je(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ki(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var qe=BigInt(0),Ie=BigInt(1),Ln=BigInt(2),hd=BigInt(8),dd={zip215:!0};function pd(t){let e=$r(t);return Je(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function qa(t){let e=pd(t),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,l=Ln<<BigInt(a*8)-Ie,u=r.create,f=Lt(e.n,e.nBitLength),h=e.uvRatio||((m,p)=>{try{return{isValid:!0,value:r.sqrt(m*r.inv(p))}}catch{return{isValid:!1,value:qe}}}),v=e.adjustScalarBytes||(m=>m),E=e.domain||((m,p,B)=>{if($e("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function y(m,p){Te("coordinate "+m,p,qe,l)}function d(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let A=Jt((m,p)=>{let{ex:B,ey:N,ez:O}=m,H=m.is0();p==null&&(p=H?hd:r.inv(O));let z=u(B*p),Z=u(N*p),$=u(O*p);if(H)return{x:qe,y:Ie};if($!==Ie)throw new Error("invZ was invalid");return{x:z,y:Z}}),T=Jt(m=>{let{a:p,d:B}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:N,ey:O,ez:H,et:z}=m,Z=u(N*N),$=u(O*O),j=u(H*H),X=u(j*j),ae=u(Z*p),ce=u(j*u(ae+$)),fe=u(X+u(B*u(Z*$)));if(ce!==fe)throw new Error("bad point: equation left != right (1)");let ye=u(N*O),ke=u(H*z);if(ye!==ke)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,B,N,O){this.ex=p,this.ey=B,this.ez=N,this.et=O,y("x",p),y("y",B),y("z",N),y("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof x)throw new Error("extended point not allowed");let{x:B,y:N}=p||{};return y("x",B),y("y",N),new x(B,N,Ie,u(B*N))}static normalizeZ(p){let B=r.invertBatch(p.map(N=>N.ez));return p.map((N,O)=>N.toAffine(B[O])).map(x.fromAffine)}static msm(p,B){return _n(x,f,p,B)}_setWindowSize(p){D.setWindowSize(this,p)}assertValidity(){T(this)}equals(p){d(p);let{ex:B,ey:N,ez:O}=this,{ex:H,ey:z,ez:Z}=p,$=u(B*Z),j=u(H*O),X=u(N*Z),ae=u(z*O);return $===j&&X===ae}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:B,ey:N,ez:O}=this,H=u(B*B),z=u(N*N),Z=u(Ln*u(O*O)),$=u(p*H),j=B+N,X=u(u(j*j)-H-z),ae=$+z,ce=ae-Z,fe=$-z,ye=u(X*ce),ke=u(ae*fe),ve=u(X*fe),Ye=u(ce*ae);return new x(ye,ke,Ye,ve)}add(p){d(p);let{a:B,d:N}=e,{ex:O,ey:H,ez:z,et:Z}=this,{ex:$,ey:j,ez:X,et:ae}=p;if(B===BigInt(-1)){let ea=u((H-O)*(j+$)),ta=u((H+O)*(j-$)),mi=u(ta-ea);if(mi===qe)return this.double();let ra=u(z*Ln*ae),na=u(Z*Ln*X),oa=na+ra,ia=ta+ea,sa=na-ra,sf=u(oa*mi),af=u(ia*sa),cf=u(oa*sa),uf=u(mi*ia);return new x(sf,af,uf,cf)}let ce=u(O*$),fe=u(H*j),ye=u(Z*N*ae),ke=u(z*X),ve=u((O+H)*($+j)-ce-fe),Ye=ke-ye,it=ke+ye,Lr=u(fe-B*ce),tf=u(ve*Ye),rf=u(it*Lr),nf=u(ve*Lr),of=u(Ye*it);return new x(tf,rf,of,nf)}subtract(p){return this.add(p.negate())}wNAF(p){return D.wNAFCached(this,p,x.normalizeZ)}multiply(p){let B=p;Te("scalar",B,Ie,n);let{p:N,f:O}=this.wNAF(B);return x.normalizeZ([N,O])[0]}multiplyUnsafe(p,B=x.ZERO){let N=p;return Te("scalar",N,qe,n),N===qe?F:this.is0()||N===Ie?this:D.wNAFCachedUnsafe(this,N,x.normalizeZ,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return D.unsafeLadder(this,n).is0()}toAffine(p){return A(this,p)}clearCofactor(){let{h:p}=e;return p===Ie?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:N,a:O}=e,H=r.BYTES;p=ne("pointHex",p,H),$e("zip215",B);let z=p.slice(),Z=p[H-1];z[H-1]=Z&-129;let $=Rt(z),j=B?l:r.ORDER;Te("pointHex.y",$,qe,j);let X=u($*$),ae=u(X-Ie),ce=u(N*X-O),{isValid:fe,value:ye}=h(ae,ce);if(!fe)throw new Error("Point.fromHex: invalid y coordinate");let ke=(ye&Ie)===Ie,ve=(Z&128)!==0;if(!B&&ye===qe&&ve)throw new Error("Point.fromHex: x=0 and x_0=1");return ve!==ke&&(ye=u(-ye)),x.fromAffine({x:ye,y:$})}static fromPrivateKey(p){return b(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),N=Yt(B,r.BYTES);return N[N.length-1]|=p&Ie?128:0,N}toHex(){return lt(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,Ie,u(e.Gx*e.Gy)),x.ZERO=new x(qe,Ie,Ie,qe);let{BASE:U,ZERO:F}=x,D=Rn(x,a*8);function R(m){return J(m,n)}function w(m){return R(Rt(m))}function b(m){let p=r.BYTES;m=ne("private key",m,p);let B=ne("hashed private key",i(m),2*p),N=v(B.slice(0,p)),O=B.slice(p,2*p),H=w(N),z=U.multiply(H),Z=z.toRawBytes();return{head:N,prefix:O,scalar:H,point:z,pointBytes:Z}}function M(m){return b(m).pointBytes}function _(m=new Uint8Array,...p){let B=ht(...p);return w(i(E(B,ne("context",m),!!o)))}function I(m,p,B={}){m=ne("message",m),o&&(m=o(m));let{prefix:N,scalar:O,pointBytes:H}=b(p),z=_(B.context,N,m),Z=U.multiply(z).toRawBytes(),$=_(B.context,Z,H,m),j=R(z+$*O);Te("signature.s",j,qe,n);let X=ht(Z,Yt(j,r.BYTES));return ne("result",X,r.BYTES*2)}let K=dd;function S(m,p,B,N=K){let{context:O,zip215:H}=N,z=r.BYTES;m=ne("signature",m,2*z),p=ne("message",p),B=ne("publicKey",B,z),H!==void 0&&$e("zip215",H),o&&(p=o(p));let Z=Rt(m.slice(z,2*z)),$,j,X;try{$=x.fromHex(B,H),j=x.fromHex(m.slice(0,z),H),X=U.multiplyUnsafe(Z)}catch{return!1}if(!H&&$.isSmallOrder())return!1;let ae=_(O,j.toRawBytes(),$.toRawBytes(),p);return j.add($.multiplyUnsafe(ae)).subtract(X).clearCofactor().equals(x.ZERO)}return U._setWindowSize(8),{CURVE:e,getPublicKey:M,sign:I,verify:S,ExtendedPoint:x,utils:{getExtendedPublicKey:b,randomPrivateKey:()=>s(r.BYTES),precompute(m=8,p=x.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var Wi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),za=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Hg=BigInt(0),gd=BigInt(1),Ga=BigInt(2),Pg=BigInt(3),md=BigInt(5),yd=BigInt(8);function xd(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Wi,a=t*t%i*t%i,c=te(a,Ga,i)*a%i,l=te(c,gd,i)*t%i,u=te(l,md,i)*l%i,f=te(u,e,i)*u%i,h=te(f,r,i)*f%i,v=te(h,n,i)*h%i,E=te(v,o,i)*v%i,y=te(E,o,i)*v%i,d=te(y,e,i)*u%i;return{pow_p_5_8:te(d,Ga,i)*t%i,b2:a}}function wd(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function bd(t,e){let r=Wi,n=J(e*e*e,r),o=J(n*n*e,r),i=xd(t*o).pow_p_5_8,s=J(t*n*i,r),a=J(e*s*s,r),c=s,l=J(s*za,r),u=a===t,f=a===J(-t,r),h=a===J(-t*za,r);return u&&(s=c),(f||h)&&(s=l),Ma(s,r)&&(s=J(-s,r)),{isValid:u||f,value:s}}var vd=Lt(Wi,void 0,!0),Ed={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:vd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:yd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:_a,randomBytes:Sn,adjustScalarBytes:wd,uvRatio:bd},Za=qa(Ed);var Vn=32;function Wa(t,e,r){return Za.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}var Dn=class{type="Ed25519";raw;constructor(e){this.raw=ji(e,Vn)}toMultihash(){return ct.digest(xr(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return Wa(this.raw,r,e)}};function Yi(t){return t=ji(t,Vn),new Dn(t)}function ji(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new xe(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}function Ji(t=0){return new Uint8Array(t)}function Xe(t=0){return new Uint8Array(t)}var Ad=Math.pow(2,7),Sd=Math.pow(2,14),kd=Math.pow(2,21),Ya=Math.pow(2,28),Ja=Math.pow(2,35),Xa=Math.pow(2,42),Qa=Math.pow(2,49),Be=128,Vt=127;function qr(t){if(t<Ad)return 1;if(t<Sd)return 2;if(t<kd)return 3;if(t<Ya)return 4;if(t<Ja)return 5;if(t<Xa)return 6;if(t<Qa)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ec(t,e,r=0){switch(qr(t)){case 8:e[r++]=t&255|Be,t/=128;case 7:e[r++]=t&255|Be,t/=128;case 6:e[r++]=t&255|Be,t/=128;case 5:e[r++]=t&255|Be,t/=128;case 4:e[r++]=t&255|Be,t>>>=7;case 3:e[r++]=t&255|Be,t>>>=7;case 2:e[r++]=t&255|Be,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function tc(t,e){let r=t[e],n=0;if(n+=r&Vt,r<Be||(r=t[e+1],n+=(r&Vt)<<7,r<Be)||(r=t[e+2],n+=(r&Vt)<<14,r<Be)||(r=t[e+3],n+=(r&Vt)<<21,r<Be)||(r=t[e+4],n+=(r&Vt)*Ya,r<Be)||(r=t[e+5],n+=(r&Vt)*Ja,r<Be)||(r=t[e+6],n+=(r&Vt)*Xa,r<Be)||(r=t[e+7],n+=(r&Vt)*Qa,r<Be))return n;throw new RangeError("Could not decode varint")}var Xi=new Float32Array([-0]),Dt=new Uint8Array(Xi.buffer);function rc(t,e,r){Xi[0]=t,e[r]=Dt[0],e[r+1]=Dt[1],e[r+2]=Dt[2],e[r+3]=Dt[3]}function nc(t,e){return Dt[0]=t[e],Dt[1]=t[e+1],Dt[2]=t[e+2],Dt[3]=t[e+3],Xi[0]}var Qi=new Float64Array([-0]),we=new Uint8Array(Qi.buffer);function oc(t,e,r){Qi[0]=t,e[r]=we[0],e[r+1]=we[1],e[r+2]=we[2],e[r+3]=we[3],e[r+4]=we[4],e[r+5]=we[5],e[r+6]=we[6],e[r+7]=we[7]}function ic(t,e){return we[0]=t[e],we[1]=t[e+1],we[2]=t[e+2],we[3]=t[e+3],we[4]=t[e+4],we[5]=t[e+5],we[6]=t[e+6],we[7]=t[e+7],Qi[0]}var Cd=BigInt(Number.MAX_SAFE_INTEGER),Td=BigInt(Number.MIN_SAFE_INTEGER),Re=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&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(e=!1){if(e)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(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Qt;if(e<Cd&&e>Td)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>sc&&(o=0n,++n>sc&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Qt;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Qt}},Qt=new Re(0,0);Qt.toBigInt=function(){return 0n};Qt.zzEncode=Qt.zzDecode=function(){return this};Qt.length=function(){return 1};var sc=4294967296n;function ac(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function cc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&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 es(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function ze(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Fn(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var ts=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ze(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ze(this,4);return Fn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ze(this,4);return Fn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ze(this,4);let e=nc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ze(this,4);let e=ic(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw ze(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return cc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ze(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ze(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Re(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw ze(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw ze(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ze(this,8);let e=Fn(this.buf,this.pos+=4),r=Fn(this.buf,this.pos+=4);return new Re(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=tc(this.buf,this.pos);return this.pos+=qr(e),e}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 rs(t){return new ts(t instanceof Uint8Array?t:t.subarray())}function Ft(t,e,r){let n=rs(t);return e.decode(n,void 0,r)}var ns={};Ee(ns,{base10:()=>Id});var Id=St({prefix:"9",name:"base10",alphabet:"0123456789"});var os={};Ee(os,{base16:()=>Nd,base16upper:()=>Ud});var Nd=oe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ud=oe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var is={};Ee(is,{base2:()=>Rd});var Rd=oe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ss={};Ee(ss,{base256emoji:()=>Fd});var lc=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}"),_d=lc.reduce((t,e,r)=>(t[r]=e,t),[]),Ld=lc.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Vd(t){return t.reduce((e,r)=>(e+=_d[r],e),"")}function Dd(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Ld[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Fd=ur({prefix:"\u{1F680}",name:"base256emoji",encode:Vd,decode:Dd});var as={};Ee(as,{base8:()=>Md});var Md=oe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var cs={};Ee(cs,{identity:()=>Od});var Od=ur({prefix:"\0",name:"identity",encode:t=>fa(t),decode:t=>la(t)});var Bm=new TextEncoder,Am=new TextDecoder;var fs={};Ee(fs,{sha256:()=>zr,sha512:()=>Kd});function ls({name:t,code:e,encode:r}){return new us(t,e,r)}var us=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Pe(this.code,r):r.then(n=>Pe(this.code,n))}else throw Error("Unknown type, must be binary type")}};function hc(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var zr=ls({name:"sha2-256",code:18,encode:hc("SHA-256")}),Kd=ls({name:"sha2-512",code:19,encode:hc("SHA-512")});var hs={...cs,...is,...as,...ns,...os,...Bi,...Ti,...Ai,...ki,...ss},Dm={...fs,...Ui};function pc(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var dc=pc("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ds=pc("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Xe(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),$d={utf8:dc,"utf-8":dc,hex:hs.base16,latin1:ds,ascii:ds,binary:ds,...hs},Mn=$d;function Y(t,e="utf8"){let r=Mn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function ps(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Xe(s);o+s>e&&(n=Xe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var er=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function gs(){}var ys=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},qd=ps();function zd(t){return globalThis.Buffer!=null?Xe(t):qd(t)}var Zr=class{len;head;tail;states;constructor(){this.len=0,this.head=new er(gs,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new er(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new xs((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(On,10,Re.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Re.fromBigInt(e);return this._push(On,r.length(),r)}uint64Number(e){return this._push(ec,qr(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Re.fromBigInt(e).zzEncode();return this._push(On,r.length(),r)}sint64Number(e){let r=Re.fromNumber(e).zzEncode();return this._push(On,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ms,1,e?1:0)}fixed32(e){return this._push(Gr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Re.fromBigInt(e);return this._push(Gr,4,r.lo)._push(Gr,4,r.hi)}fixed64Number(e){let r=Re.fromNumber(e);return this._push(Gr,4,r.lo)._push(Gr,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(rc,4,e)}double(e){return this._push(oc,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(ms,1,0):this.uint32(r)._push(Zd,r,e)}string(e){let r=ac(e);return r!==0?this.uint32(r)._push(es,r,e):this._push(ms,1,0)}fork(){return this.states=new ys(this),this.head=this.tail=new er(gs,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 er(gs,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=zd(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function ms(t,e,r){e[r]=t&255}function Gd(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var xs=class extends er{next;constructor(e,r){super(Gd,e,r),this.next=void 0}};function On(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Gr(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Zd(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Zr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Wd,e,t),this},Zr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(jd,e,t),this});function Wd(t,e,r){e.set(t,r)}function jd(t,e,r){t.length<40?es(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Y(t),r)}function ws(){return new Zr}function Mt(t,e){let r=ws();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var wr;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(wr||(wr={}));function Hn(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function Wr(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return Hn("enum",wr.VARINT,r,n)}function Ot(t,e){return Hn("message",wr.LENGTH_DELIMITED,t,e)}var se;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1"})(se||(se={}));var bs;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1"})(bs||(bs={}));(function(t){t.codec=()=>Wr(bs)})(se||(se={}));var Qe;(function(t){let e;t.codec=()=>(e==null&&(e=Ot((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),se.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=se.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mt(r,t.codec()),t.decode=(r,n)=>Ft(r,t.codec(),n)})(Qe||(Qe={}));var vs;(function(t){let e;t.codec=()=>(e==null&&(e=Ot((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),se.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=se.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mt(r,t.codec()),t.decode=(r,n)=>Ft(r,t.codec(),n)})(vs||(vs={}));var on={};Ee(on,{MAX_RSA_KEY_SIZE:()=>Ro,generateRSAKeyPair:()=>fu,jwkToJWKKeyPair:()=>hu,jwkToPkcs1:()=>f0,jwkToPkix:()=>Ns,jwkToRSAPrivateKey:()=>lu,pkcs1ToJwk:()=>au,pkcs1ToRSAPrivateKey:()=>uu,pkixToJwk:()=>cu,pkixToRSAPublicKey:()=>Us});var Yd=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]),Ht=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pt=new Uint32Array(64),Es=class extends mr{constructor(){super(64,32,8,!1),this.A=Ht[0]|0,this.B=Ht[1]|0,this.C=Ht[2]|0,this.D=Ht[3]|0,this.E=Ht[4]|0,this.F=Ht[5]|0,this.G=Ht[6]|0,this.H=Ht[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|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(e,r){for(let f=0;f<16;f++,r+=4)Pt[f]=e.getUint32(r,!1);for(let f=16;f<64;f++){let h=Pt[f-15],v=Pt[f-2],E=Ke(h,7)^Ke(h,18)^h>>>3,y=Ke(v,17)^Ke(v,19)^v>>>10;Pt[f]=y+Pt[f-7]+E+Pt[f-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let h=Ke(a,6)^Ke(a,11)^Ke(a,25),v=u+h+Na(a,c,l)+Yd[f]+Pt[f]|0,y=(Ke(n,2)^Ke(n,13)^Ke(n,22))+Ua(n,o,i)|0;u=l,l=c,c=a,a=s+v|0,s=i,i=o,o=n,n=v+y|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,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,l,u)}roundClean(){Pt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var br=An(()=>new Es);var G=Vr(mc());function tr(t,e){let r=0;if(t.length===1)return t[0];for(let n=t.length-1;n>=0;n--)r+=t[t.length-1-n]*Math.pow(2,e*n);return r}function Kt(t,e,r=-1){let n=r,o=t,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(t<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let l=new Uint8Array(c);for(let u=a-1;u>=0;u--){let f=Math.pow(2,u*e);l[i-u-1]=Math.floor(o/f),o-=l[i-u-1]*f}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function $n(...t){let e=0,r=0;for(let i of t)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of t)o.set(i,r),r+=i.length;return o}function As(){let t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=t[0]===255&&t[1]&128,c=t[0]===0&&(t[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)r[a]=0;r[0]=t[0]&128;let n=tr(r,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=t[a];return i[0]&=127,tr(i,8)-n}function yc(t){let e=t<0?t*-1:t,r=128;for(let n=1;n<8;n++){if(e<=r){if(t<0){let s=r-e,a=Kt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Kt(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}r*=Math.pow(2,8)}return new ArrayBuffer(0)}function xc(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let o=0;o<r.length;o++)if(r[o]!==n[o])return!1;return!0}function Ne(t,e){let r=t.toString(10);if(e<r.length)return"";let n=e-r.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(r)}var yy=Math.log(2);function qn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Ss(t){let e=0,r=0;for(let o=0;o<t.length;o++){let i=t[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<t.length;o++){let i=t[o];n.set(new Uint8Array(i),r),r+=i.byteLength}return n.buffer}function yt(t,e,r,n){return e instanceof Uint8Array?e.byteLength?r<0?(t.error="Wrong parameter: inputOffset less than zero",!1):n<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-r-n<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Yr=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Ss(this.items)}},jr=[new Uint8Array([1])],wc="0123456789";var Sr="",Ge=new ArrayBuffer(0),ks=new Uint8Array(0),Jr="EndOfContent",vc="OCTET STRING",Ec="BIT STRING";function xt(t){var e;return e=class extends t{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?G.BufferSourceConverter.toUint8Array(i.valueHex):ks}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!yt(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Ge)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:G.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var pt=class{constructor({blockLength:e=0,error:r=Sr,warnings:n=[],valueBeforeDecode:o=ks}={}){this.blockLength=e,this.error=r,this.warnings=n,this.valueBeforeDecodeView=G.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:G.Convert.ToHex(this.valueBeforeDecodeView)}}};pt.NAME="baseBlock";var be=class extends pt{fromBER(e,r,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};be.NAME="valueBlock";var zn=class extends xt(pt){constructor({idBlock:e={}}={}){var r,n,o,i;super(),e?(this.isHexOnly=(r=e.isHexOnly)!==null&&r!==void 0?r:!1,this.valueHexView=e.valueHex?G.BufferSourceConverter.toUint8Array(e.valueHex):ks,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let r=0;switch(this.tagClass){case 1:r|=0;break;case 2:r|=64;break;case 3:r|=128;break;case 4:r|=192;break;default:return this.error="Unknown tag class",Ge}if(this.isConstructed&&(r|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,r|=i,o[0]=r}return o.buffer}if(!this.isHexOnly){let o=Kt(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=r|31,!e){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=r|31,!e){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(l[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let v=0;v<l.length;v++)h[v]=l[v];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,l[c-1]=i[c]&127;let f=new Uint8Array(c);for(let h=0;h<c;h++)f[h]=l[h];l=this.valueHexView=new Uint8Array(c),l.set(f),this.blockLength<=9?this.tagNumber=tr(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return r+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};zn.NAME="identificationBlock";var Gn=class extends pt{constructor({lenBlock:e={}}={}){var r,n,o;super(),this.isIndefiniteForm=(r=e.isIndefiniteForm)!==null&&r!==void 0?r:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,r+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,r+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=r+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=tr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,r+this.blockLength}toBER(e=!1){let r,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=128),r;if(this.longFormUsed){let o=Kt(this.length,8);if(o.byteLength>127)return this.error="Too big length",Ge;if(r=new ArrayBuffer(o.byteLength+1),e)return r;let i=new Uint8Array(o);n=new Uint8Array(r),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return r}return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=this.length),r}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Gn.NAME="lengthBlock";var L={},de=class extends pt{constructor({name:e=Sr,optional:r=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=r,n&&(this.primitiveSchema=n),this.idBlock=new zn(o),this.lenBlock=new Gn(o),this.valueBlock=i?new i(o):new be(o)}fromBER(e,r,n){let o=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(e,r){let n=r||new Yr;r||Bc(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return r?Ge:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():G.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let r=this.toBER(),n=e.toBER();return xc(r,n)}};de.NAME="BaseBlock";function Bc(t){if(t instanceof L.Constructed)for(let e of t.valueBlock.value)Bc(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}var Zn=class extends de{constructor({value:e=Sr,...r}={},n){super(r,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,r,n){let o=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Zn.NAME="BaseStringBlock";var Wn=class extends xt(be){constructor({isHexOnly:e=!0,...r}={}){super(r),this.isHexOnly=e}};Wn.NAME="PrimitiveValueBlock";var Ac,jn=class extends de{constructor(e={}){super(e,Wn),this.idBlock.isConstructed=!1}};Ac=jn;L.Primitive=Ac;jn.NAME="PRIMITIVE";function i0(t,e){if(t instanceof e)return t;let r=new e;return r.idBlock=t.idBlock,r.lenBlock=t.lenBlock,r.warnings=t.warnings,r.valueBeforeDecodeView=t.valueBeforeDecodeView,r}function No(t,e=0,r=t.length){let n=e,o=new de({},be),i=new pt;if(!yt(i,t,e,r))return o.error=i.error,{offset:-1,result:o};if(!t.subarray(e,e+r).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(t,e,r);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,r-=o.idBlock.blockLength,a=o.lenBlock.fromBER(t,e,r),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,r-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=de;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=L.EndOfContent;break;case 1:c=L.Boolean;break;case 2:c=L.Integer;break;case 3:c=L.BitString;break;case 4:c=L.OctetString;break;case 5:c=L.Null;break;case 6:c=L.ObjectIdentifier;break;case 10:c=L.Enumerated;break;case 12:c=L.Utf8String;break;case 13:c=L.RelativeObjectIdentifier;break;case 14:c=L.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=L.Sequence;break;case 17:c=L.Set;break;case 18:c=L.NumericString;break;case 19:c=L.PrintableString;break;case 20:c=L.TeletexString;break;case 21:c=L.VideotexString;break;case 22:c=L.IA5String;break;case 23:c=L.UTCTime;break;case 24:c=L.GeneralizedTime;break;case 25:c=L.GraphicString;break;case 26:c=L.VisibleString;break;case 27:c=L.GeneralString;break;case 28:c=L.UniversalString;break;case 29:c=L.CharacterString;break;case 30:c=L.BmpString;break;case 31:c=L.DATE;break;case 32:c=L.TimeOfDay;break;case 33:c=L.DateTime;break;case 34:c=L.Duration;break;default:{let l=o.idBlock.isConstructed?new L.Constructed:new L.Primitive;l.idBlock=o.idBlock,l.lenBlock=o.lenBlock,l.warnings=o.warnings,o=l}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?L.Constructed:L.Primitive}return o=i0(o,c),a=o.fromBER(t,e,o.lenBlock.isIndefiniteForm?r:o.lenBlock.length),o.valueBeforeDecodeView=t.subarray(n,n+o.blockLength),{offset:a,result:o}}function Cs(t){if(!t.byteLength){let e=new de({},be);return e.error="Input buffer has zero length",{offset:-1,result:e}}return No(G.BufferSourceConverter.toUint8Array(t).slice(),0,t.byteLength)}function s0(t,e){return t?1:e}var et=class extends be{constructor({value:e=[],isIndefiniteForm:r=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=r}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;if(this.valueBeforeDecodeView=o.subarray(r,r+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),r;let i=r;for(;s0(this.isIndefiniteForm,n)>0;){let s=No(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===Jr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Jr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,r){let n=r||new Yr;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return r?Ge:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let r of this.value)e.value.push(r.toJSON());return e}};et.NAME="ConstructedValueBlock";var Sc,$t=class extends de{constructor(e={}){super(e,et),this.idBlock.isConstructed=!0}fromBER(e,r,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
4
4
|
`).map(o=>` ${o}`).join(`
|
|
5
5
|
`));let r=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${r} :
|
|
6
6
|
${e.join(`
|
|
7
|
-
`)}`:`${r} :`}};Mc=qt;L.Constructed=Mc;qt.NAME="CONSTRUCTED";var ro=class extends be{fromBER(e,r,n){return r}toBER(e){return We}};ro.override="EndOfContentValueBlock";var Oc,no=class extends de{constructor(e={}){super(e,ro),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Oc=no;L.EndOfContent=Oc;no.NAME=Qr;var Hc,Ar=class extends de{constructor(e={}){super(e,be),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,r,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,r+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):r+n}toBER(e,r){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return r&&r.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Hc=Ar;L.Null=Hc;Ar.NAME="NULL";var oo=class extends wt(be){constructor({value:e,...r}={}){super(r),r.valueHex?this.valueHexView=G.BufferSourceConverter.toUint8Array(r.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);return xt(this,o,r,n)?(this.valueHexView=o.subarray(r,r+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,_s.call(this),this.blockLength=n,r+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};oo.NAME="BooleanValueBlock";var Pc,io=class extends de{constructor(e={}){super(e,oo),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Pc=io;L.Boolean=Pc;io.NAME="BOOLEAN";var so=class extends wt(tt){constructor({isConstructed:e=!1,...r}={}){super(r),this.isConstructed=e}fromBER(e,r,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=tt.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===Qr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Lc)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,r,n),this.blockLength=n;return o}toBER(e,r){return this.isConstructed?tt.prototype.toBER.call(this,e,r):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};so.NAME="OctetStringValueBlock";var Kc,ao=class t extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},so),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,r,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),r;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(r,r+n);try{if(i.byteLength){let s=Do(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,r,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?qt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let r of this.valueBlock.value)r instanceof t&&e.push(r.valueBlock.valueHexView);return G.BufferSourceConverter.concat(e)}};Kc=ao;L.OctetString=Kc;ao.NAME=Lc;var co=class extends wt(tt){constructor({unusedBits:e=0,isConstructed:r=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=r,this.blockLength=this.valueHexView.byteLength}fromBER(e,r,n){if(!n)return r;let o=-1;if(this.isConstructed){if(o=tt.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===Qr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Vc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=G.BufferSourceConverter.toUint8Array(e);if(!xt(this,i,r,n))return-1;let s=i.subarray(r,r+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=Do(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,r+n}toBER(e,r){if(this.isConstructed)return tt.prototype.toBER.call(this,e,r);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return We;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};co.NAME="BitStringValueBlock";var $c,Sr=class extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},co),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,r,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,r,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return qt.prototype.onAsciiEncoding.call(this);{let e=[],r=this.valueBlock.valueHexView;for(let o of r)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};$c=Sr;L.BitString=$c;Sr.NAME=Vc;var qc;function A0(t,e){let r=new Uint8Array([0]),n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<s?s:c,l=0;for(let h=u;h>=0;h--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+r[0];break;default:f=i[s-l]+r[0]}switch(r[0]=f/10,!0){case l>=i.length:i=jn(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return r[0]>0&&(i=jn(r,i)),i}function _c(t){if(t>=Jr.length)for(let e=Jr.length;e<=t;e++){let r=new Uint8Array([0]),n=Jr[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+r[0]]);r[0]=i[0]/10,n[o]=i[0]%10}r[0]>0&&(n=jn(r,n)),Jr.push(n)}return Jr[t]}function S0(t,e){let r=0,n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-r,!0){case f<0:r=1,i[s-u]=f+10;break;default:r=0,i[s-u]=f}if(r>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-r,f<0)r=1,i[s-u]=f+10;else{r=0,i[s-u]=f;break}return i.slice()}var en=class extends wt(be){constructor({value:e,...r}={}){super(r),this._valueDec=0,r.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=_s.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Nc(e))}get valueDec(){return this._valueDec}fromDER(e,r,n,o=0){let i=this.fromBER(e,r,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let r=this.valueHexView;switch(!0){case(r[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(r,1),this.valueHexView=n}break;case(r[0]===0&&(r[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,r,n){let o=super.fromBER(e,r,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,r=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:r=S0(_c(n),r),s="-";break;default:r=A0(r,_c(n))}n++,o>>=1}}for(let c=0;c<r.length;c++)r[c]&&(a=!0),a&&(s+=Rc.charAt(r[c]));return a===!1&&(s+=Rc.charAt(0)),s}};qc=en;en.NAME="IntegerValueBlock";Object.defineProperty(qc.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var zc,pe=class t extends de{constructor(e={}){super(e,en),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Yn(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Yn();let r=BigInt(e),n=new Xr,o=r.toString(16).replace(/^-/,""),i=new Uint8Array(G.Convert.FromHex(o));if(r<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${G.Convert.ToHex(a)}`)+r,u=G.BufferSourceConverter.toUint8Array(G.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new t({valueHex:n.final()})}convertToDER(){let e=new t({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new t({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};zc=pe;L.Integer=zc;pe.NAME="INTEGER";var Gc,uo=class extends pe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Gc=uo;L.Enumerated=Gc;uo.NAME="ENUMERATED";var tn=class extends wt(be){constructor({valueDec:e=-1,isFirstSid:r=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=r}fromBER(e,r,n){if(!n)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!xt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=or(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}set valueBigInt(e){Yn();let r=BigInt(e).toString(2);for(;r.length%7;)r="0"+r;let n=new Uint8Array(r.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(r.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=$t(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",We;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=G.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let r=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",r-=40):(e="2.",r-=80),e+=r.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};tn.NAME="sidBlock";var lo=class extends be{constructor({value:e=Cr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new tn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let r=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,We;r.push(o)}return Ls(r)}fromString(e){this.value=[];let r=0,n=0,o="",i=!1;do if(n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new tn;if(o>Number.MAX_SAFE_INTEGER){Yn();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};lo.NAME="ObjectIdentifierValueBlock";var Wc,kr=class extends de{constructor(e={}){super(e,lo),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Wc=kr;L.ObjectIdentifier=Wc;kr.NAME="OBJECT IDENTIFIER";var rn=class extends wt(gt){constructor({valueDec:e=0,...r}={}){super(r),this.valueDec=e}fromBER(e,r,n){if(n===0)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!xt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=or(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=$t(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",We;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=G.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};rn.NAME="relativeSidBlock";var fo=class extends be{constructor({value:e=Cr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new rn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,r){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,We;n.push(i)}return Ls(n)}fromString(e){this.value=[];let r=0,n=0,o="";do{n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1;let i=new rn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};fo.NAME="RelativeObjectIdentifierValueBlock";var Zc,ho=class extends de{constructor(e={}){super(e,fo),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Zc=ho;L.RelativeObjectIdentifier=Zc;ho.NAME="RelativeObjectIdentifier";var jc,mt=class extends qt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};jc=mt;L.Sequence=jc;mt.NAME="SEQUENCE";var Yc,po=class extends qt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Yc=po;L.Set=Yc;po.NAME="SET";var go=class extends wt(be){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Cr}toJSON(){return{...super.toJSON(),value:this.value}}};go.NAME="StringValueBlock";var mo=class extends go{};mo.NAME="SimpleStringValueBlock";var Ae=class extends Qn{constructor({...e}={}){super(e,mo)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Ae.NAME="SIMPLE STRING";var yo=class extends Ae{fromBuffer(e){this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=G.Convert.ToUtf8String(e)}catch(r){this.warnings.push(`Error during "decodeURIComponent": ${r}, using raw string`),this.valueBlock.value=G.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf8String(e)),this.valueBlock.value=e}};yo.NAME="Utf8StringValueBlock";var Jc,yt=class extends yo{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Jc=yt;L.Utf8String=Jc;yt.NAME="UTF8String";var xo=class extends Ae{fromBuffer(e){this.valueBlock.value=G.Convert.ToUtf16String(e),this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf16String(e))}};xo.NAME="BmpStringValueBlock";var Xc,wo=class extends xo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Xc=wo;L.BmpString=Xc;wo.NAME="BMPString";var bo=class extends Ae{fromBuffer(e){let r=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(r);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(r))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r*4);for(let o=0;o<r;o++){let i=$t(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};bo.NAME="UniversalStringValueBlock";var Qc,vo=class extends bo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Qc=vo;L.UniversalString=Qc;vo.NAME="UniversalString";var eu,Eo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};eu=Eo;L.NumericString=eu;Eo.NAME="NumericString";var tu,Bo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};tu=Bo;L.PrintableString=tu;Bo.NAME="PrintableString";var ru,Ao=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};ru=Ao;L.TeletexString=ru;Ao.NAME="TeletexString";var nu,So=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};nu=So;L.VideotexString=nu;So.NAME="VideotexString";var ou,ko=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};ou=ko;L.IA5String=ou;ko.NAME="IA5String";var iu,Co=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};iu=Co;L.GraphicString=iu;Co.NAME="GraphicString";var su,nn=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};su=nn;L.VisibleString=su;nn.NAME="VisibleString";var au,To=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};au=To;L.GeneralString=au;To.NAME="GeneralString";var cu,Io=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};cu=Io;L.CharacterString=cu;Io.NAME="CharacterString";var uu,on=class extends nn{constructor({value:e,valueDate:r,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}r&&(this.fromDate(r),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return r}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let r=new Array(7);return r[0]=Ne(this.year<2e3?this.year-1900:this.year-2e3,2),r[1]=Ne(this.month,2),r[2]=Ne(this.day,2),r[3]=Ne(this.hour,2),r[4]=Ne(this.minute,2),r[5]=Ne(this.second,2),r[6]="Z",r.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};uu=on;L.UTCTime=uu;on.NAME="UTCTime";var lu,No=class extends on{constructor(e={}){var r;super(e),(r=this.millisecond)!==null&&r!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let r=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),r=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,h=n.indexOf("+"),b="";if(h===-1&&(h=n.indexOf("-"),l=-1),h!==-1){if(b=n.substring(h+1),n=n.substring(0,h),b.length!==2&&b.length!==4)throw new Error("Wrong input string for conversion");let E=parseInt(b.substring(0,2),10);if(isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*E,b.length===4){if(E=parseInt(b.substring(2,4),10),isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");c=l*E}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+a;break;case 5:this.minute=parseInt(u[l],10)+c;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(r===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let r=[];return r.push(Ne(this.year,4)),r.push(Ne(this.month,2)),r.push(Ne(this.day,2)),r.push(Ne(this.hour,2)),r.push(Ne(this.minute,2)),r.push(Ne(this.second,2)),this.millisecond!==0&&(r.push("."),r.push(Ne(this.millisecond,3))),r.push("Z"),r.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};lu=No;L.GeneralizedTime=lu;No.NAME="GeneralizedTime";var fu,Uo=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};fu=Uo;L.DATE=fu;Uo.NAME="DATE";var hu,Ro=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};hu=Ro;L.TimeOfDay=hu;Ro.NAME="TimeOfDay";var du,_o=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};du=_o;L.DateTime=du;_o.NAME="DateTime";var pu,Lo=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};pu=Lo;L.Duration=pu;Lo.NAME="Duration";var gu,Vo=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};gu=Vo;L.TIME=gu;Vo.NAME="TIME";function Ue(t,e="utf8"){let r=Hn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var sn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Fo=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var mu={get(t=globalThis){let e=t.crypto;if(e?.subtle==null)throw new Fo("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 e}};var zt=mu;async function yu(t){let e=await zt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await C0(e);return{privateKey:r[0],publicKey:r[1]}}async function xu(t,e){let r=await zt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await zt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function wu(t,e,r){let n=await zt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return zt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,r instanceof Uint8Array?r:r.subarray())}async function C0(t){if(t.privateKey==null||t.publicKey==null)throw new xe("Private and public key are required");return Promise.all([zt.get().subtle.exportKey("jwk",t.privateKey),zt.get().subtle.exportKey("jwk",t.publicKey)])}function Fs(t){if(t.kty!=="RSA")throw new xe("invalid key type");if(t.n==null)throw new xe("invalid key modulus");return Y(t.n,"base64url").length*8}var Tr=class{type="RSA";_key;_raw;_multihash;constructor(e,r){this._key=e,this._multihash=r}get raw(){return this._raw==null&&(this._raw=an.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return re.createV1(114,this._multihash)}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return wu(this._key,r,e)}},cn=class{type="RSA";_key;_raw;publicKey;constructor(e,r){this._key=e,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=an.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}sign(e){return xu(this._key,e)}};var Mo=8192,Ms=18;function bu(t){let{result:e}=Ds(t),r=e.valueBlock.value;return{n:rt(r[1]),e:rt(r[2]),d:rt(r[3]),p:rt(r[4]),q:rt(r[5]),dp:rt(r[6]),dq:rt(r[7]),qi:rt(r[8]),kty:"RSA",alg:"RS256"}}function T0(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new xe("JWK was missing components");let r=new mt({value:[new pe({value:0}),pe.fromBigInt(nt(Y(t.n,"base64url"))),pe.fromBigInt(nt(Y(t.e,"base64url"))),pe.fromBigInt(nt(Y(t.d,"base64url"))),pe.fromBigInt(nt(Y(t.p,"base64url"))),pe.fromBigInt(nt(Y(t.q,"base64url"))),pe.fromBigInt(nt(Y(t.dp,"base64url"))),pe.fromBigInt(nt(Y(t.dq,"base64url"))),pe.fromBigInt(nt(Y(t.qi,"base64url")))]}).toBER();return new Uint8Array(r,0,r.byteLength)}function vu(t){let{result:e}=Ds(t),r=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:rt(r[0]),e:rt(r[1])}}function Os(t){if(t.n==null||t.e==null)throw new xe("JWK was missing components");let r=new mt({value:[new mt({value:[new kr({value:"1.2.840.113549.1.1.1"}),new Ar]}),new Sr({valueHex:new mt({value:[pe.fromBigInt(nt(Y(t.n,"base64url"))),pe.fromBigInt(nt(Y(t.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(r,0,r.byteLength)}function rt(t){let e=t.valueBlock.valueHexView;for(;e[0]===0;)e=e.subarray(1);return Ue(e,"base64url")}function nt(t){let e=[];return t.forEach(function(r){let n=r.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function Eu(t){let e=bu(t);return Bu(e)}function Hs(t){let e=vu(t);if(Fs(e)>Mo)throw new ur("Key size is too large");let r=Gn(et.encode({Type:se.RSA,Data:t})),n=Pe(Ms,r);return new Tr(e,n)}function Bu(t){if(Fs(t)>Mo)throw new xe("Key size is too large");let e=Su(t),r=Gn(et.encode({Type:se.RSA,Data:Os(e.publicKey)})),n=Pe(Ms,r);return new cn(e.privateKey,new Tr(e.publicKey,n))}async function Au(t){if(t>Mo)throw new xe("Key size is too large");let e=await yu(t),r=Gn(et.encode({Type:se.RSA,Data:Os(e.publicKey)})),n=Pe(Ms,r);return new cn(e.privateKey,new Tr(e.publicKey,n))}function Su(t){if(t==null)throw new xe("Missing key parameter");return{privateKey:t,publicKey:{kty:t.kty,n:t.n,e:t.e}}}var I0=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]),Gt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wt=new Uint32Array(64),Ps=class extends wr{constructor(){super(64,32,8,!1),this.A=Gt[0]|0,this.B=Gt[1]|0,this.C=Gt[2]|0,this.D=Gt[3]|0,this.E=Gt[4]|0,this.F=Gt[5]|0,this.G=Gt[6]|0,this.H=Gt[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|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(e,r){for(let l=0;l<16;l++,r+=4)Wt[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let h=Wt[l-15],b=Wt[l-2],E=Ke(h,7)^Ke(h,18)^h>>>3,y=Ke(b,17)^Ke(b,19)^b>>>10;Wt[l]=y+Wt[l-7]+E+Wt[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 h=Ke(a,6)^Ke(a,11)^Ke(a,25),b=u+h+Oa(a,c,f)+I0[l]+Wt[l]|0,y=(Ke(n,2)^Ke(n,13)^Ke(n,22))+Ha(n,o,i)|0;u=f,f=c,c=a,a=s+b|0,s=i,i=o,o=n,n=b+y|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(){Wt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ku=kn(()=>new Ps);var Oo=class extends xr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Da(e);let n=Kr(r);if(this.iHash=e.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 o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return yr(this),this.iHash.update(e),this}digestInto(e){yr(this),mr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ks=(t,e,r)=>new Oo(t,e).update(r).digest();Ks.create=(t,e)=>new Oo(t,e);function Cu(t){t.lowS!==void 0&&$e("lowS",t.lowS),t.prehash!==void 0&&$e("prehash",t.prehash)}function N0(t){let e=zr(t);Xe(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:U0,hexToBytes:R0}=Un,bt={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=bt;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Jt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Jt(o.length/2|128):"";return Jt(t)+i+o+e},decode(t,e){let{Err:r}=bt,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[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=e.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=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=bt;if(t<vt)throw new e("integer: negative integers are not allowed");let r=Jt(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=bt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return U0(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=bt,o=typeof t=="string"?R0(t):t;br(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("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 e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=bt,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},vt=BigInt(0),ue=BigInt(1),Ex=BigInt(2),Tu=BigInt(3),Bx=BigInt(4);function _0(t){let e=N0(t),{Fp:r}=e,n=Vt(e.n,e.nBitLength),o=e.toBytes||((y,d,A)=>{let T=d.toAffine();return dt(Uint8Array.from([4]),r.toBytes(T.x),r.toBytes(T.y))}),i=e.fromBytes||(y=>{let d=y.subarray(1),A=r.fromBytes(d.subarray(0,r.BYTES)),T=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:A,y:T}});function s(y){let{a:d,b:A}=e,T=r.sqr(y),x=r.mul(T,y);return r.add(r.add(x,r.mul(y,d)),A)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return $r(y,ue,e.n)}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:A,wrapPrivateKey:T,n:x}=e;if(d&&typeof y!="bigint"){if(Rt(y)&&(y=ft(y)),typeof y!="string"||!d.includes(y.length))throw new Error("invalid private key");y=y.padStart(A*2,"0")}let U;try{U=typeof y=="bigint"?y:ht(ne("private key",y,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof y)}return T&&(U=J(U,x)),Te("private key",U,ue,x),U}function f(y){if(!(y instanceof h))throw new Error("ProjectivePoint expected")}let u=er((y,d)=>{let{px:A,py:T,pz:x}=y;if(r.eql(x,r.ONE))return{x:A,y:T};let U=y.is0();d==null&&(d=U?r.ONE:r.inv(x));let F=r.mul(A,d),D=r.mul(T,d),R=r.mul(x,d);if(U)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:F,y:D}}),l=er(y=>{if(y.is0()){if(e.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:d,y:A}=y.toAffine();if(!r.isValid(d)||!r.isValid(A))throw new Error("bad point: x or y not FE");let T=r.sqr(A),x=s(d);if(!r.eql(T,x))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,A,T){if(this.px=d,this.py=A,this.pz=T,d==null||!r.isValid(d))throw new Error("x required");if(A==null||!r.isValid(A))throw new Error("y required");if(T==null||!r.isValid(T))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:A,y:T}=d||{};if(!d||!r.isValid(A)||!r.isValid(T))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=U=>r.eql(U,r.ZERO);return x(A)&&x(T)?h.ZERO:new h(A,T,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let A=r.invertBatch(d.map(T=>T.pz));return d.map((T,x)=>T.toAffine(A[x])).map(h.fromAffine)}static fromHex(d){let A=h.fromAffine(i(ne("pointHex",d)));return A.assertValidity(),A}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,A){return Vn(h,n,d,A)}_setWindowSize(d){E.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.eql(r.mul(A,D),r.mul(U,x)),w=r.eql(r.mul(T,D),r.mul(F,x));return R&&w}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:A}=e,T=r.mul(A,Tu),{px:x,py:U,pz:F}=this,D=r.ZERO,R=r.ZERO,w=r.ZERO,v=r.mul(x,x),M=r.mul(U,U),_=r.mul(F,F),I=r.mul(x,U);return I=r.add(I,I),w=r.mul(x,F),w=r.add(w,w),D=r.mul(d,w),R=r.mul(T,_),R=r.add(D,R),D=r.sub(M,R),R=r.add(M,R),R=r.mul(D,R),D=r.mul(I,D),w=r.mul(T,w),_=r.mul(d,_),I=r.sub(v,_),I=r.mul(d,I),I=r.add(I,w),w=r.add(v,v),v=r.add(w,v),v=r.add(v,_),v=r.mul(v,I),R=r.add(R,v),_=r.mul(U,F),_=r.add(_,_),v=r.mul(_,I),D=r.sub(D,v),w=r.mul(_,M),w=r.add(w,w),w=r.add(w,w),new h(D,R,w)}add(d){f(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.ZERO,w=r.ZERO,v=r.ZERO,M=e.a,_=r.mul(e.b,Tu),I=r.mul(A,U),K=r.mul(T,F),S=r.mul(x,D),k=r.add(A,T),m=r.add(U,F);k=r.mul(k,m),m=r.add(I,K),k=r.sub(k,m),m=r.add(A,x);let p=r.add(U,D);return m=r.mul(m,p),p=r.add(I,S),m=r.sub(m,p),p=r.add(T,x),R=r.add(F,D),p=r.mul(p,R),R=r.add(K,S),p=r.sub(p,R),v=r.mul(M,m),R=r.mul(_,S),v=r.add(R,v),R=r.sub(K,v),v=r.add(K,v),w=r.mul(R,v),K=r.add(I,I),K=r.add(K,I),S=r.mul(M,S),m=r.mul(_,m),K=r.add(K,S),S=r.sub(I,S),S=r.mul(M,S),m=r.add(m,S),I=r.mul(K,m),w=r.add(w,I),I=r.mul(p,m),R=r.mul(k,R),R=r.sub(R,I),I=r.mul(k,K),v=r.mul(p,v),v=r.add(v,I),new h(R,w,v)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return E.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:A,n:T}=e;Te("scalar",d,vt,T);let x=h.ZERO;if(d===vt)return x;if(this.is0()||d===ue)return this;if(!A||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:U,k1:F,k2neg:D,k2:R}=A.splitScalar(d),w=x,v=x,M=this;for(;F>vt||R>vt;)F&ue&&(w=w.add(M)),R&ue&&(v=v.add(M)),M=M.double(),F>>=ue,R>>=ue;return U&&(w=w.negate()),D&&(v=v.negate()),v=new h(r.mul(v.px,A.beta),v.py,v.pz),w.add(v)}multiply(d){let{endo:A,n:T}=e;Te("scalar",d,ue,T);let x,U;if(A){let{k1neg:F,k1:D,k2neg:R,k2:w}=A.splitScalar(d),{p:v,f:M}=this.wNAF(D),{p:_,f:I}=this.wNAF(w);v=E.constTimeNegate(F,v),_=E.constTimeNegate(R,_),_=new h(r.mul(_.px,A.beta),_.py,_.pz),x=v.add(_),U=M.add(I)}else{let{p:F,f:D}=this.wNAF(d);x=F,U=D}return h.normalizeZ([x,U])[0]}multiplyAndAddUnsafe(d,A,T){let x=h.BASE,U=(D,R)=>R===vt||R===ue||!D.equals(x)?D.multiplyUnsafe(R):D.multiply(R),F=U(this,A).add(U(d,T));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:A}=e;if(d===ue)return!0;if(A)return A(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:A}=e;return d===ue?this:A?A(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return $e("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return $e("isCompressed",d),ft(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let b=e.nBitLength,E=Ln(h,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function L0(t){let e=zr(t);return Xe(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Iu(t){let e=L0(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return J(S,n)}function a(S){return Rn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=_0({...e,toBytes(S,k,m){let p=k.toAffine(),B=r.toBytes(p.x),N=dt;return $e("isCompressed",m),m?N(Uint8Array.from([k.hasEvenY()?2:3]),B):N(Uint8Array.from([4]),B,r.toBytes(p.y))},fromBytes(S){let k=S.length,m=S[0],p=S.subarray(1);if(k===o&&(m===2||m===3)){let B=ht(p);if(!$r(B,ue,r.ORDER))throw new Error("Point is not on curve");let N=u(B),O;try{O=r.sqrt(N)}catch(W){let $=W instanceof Error?": "+W.message:"";throw new Error("Point is not on curve"+$)}let H=(O&ue)===ue;return(m&1)===1!==H&&(O=r.neg(O)),{x:B,y:O}}else if(k===i&&m===4){let B=r.fromBytes(p.subarray(0,r.BYTES)),N=r.fromBytes(p.subarray(r.BYTES,2*r.BYTES));return{x:B,y:N}}else{let B=o,N=i;throw new Error("invalid Point, expected length of "+B+", or uncompressed "+N+", got "+k)}}}),h=S=>ft(Lt(S,e.nByteLength));function b(S){let k=n>>ue;return S>k}function E(S){return b(S)?s(-S):S}let y=(S,k,m)=>ht(S.slice(k,m));class d{constructor(k,m,p){this.r=k,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(k){let m=e.nByteLength;return k=ne("compactSignature",k,m*2),new d(y(k,0,m),y(k,m,2*m))}static fromDER(k){let{r:m,s:p}=bt.toSig(ne("DER",k));return new d(m,p)}assertValidity(){Te("r",this.r,ue,n),Te("s",this.s,ue,n)}addRecoveryBit(k){return new d(this.r,this.s,k)}recoverPublicKey(k){let{r:m,s:p,recovery:B}=this,N=D(ne("msgHash",k));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let O=B===2||B===3?m+e.n:m;if(O>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=B&1?"03":"02",z=c.fromHex(H+h(O)),W=a(O),$=s(-N*W),j=s(p*W),X=c.BASE.multiplyAndAddUnsafe(z,$,j);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Xt(this.toDERHex())}toDERHex(){return bt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Xt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let A={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=ji(e.n);return ja(e.randomBytes(S),e.n)},precompute(S=8,k=c.BASE){return k._setWindowSize(S),k.multiply(BigInt(3)),k}};function T(S,k=!0){return c.fromPrivateKey(S).toRawBytes(k)}function x(S){let k=Rt(S),m=typeof S=="string",p=(k||m)&&S.length;return k?p===o||p===i:m?p===2*o||p===2*i:S instanceof c}function U(S,k,m=!0){if(x(S))throw new Error("first arg must be private key");if(!x(k))throw new Error("second arg must be public key");return c.fromHex(k).multiply(f(S)).toRawBytes(m)}let F=e.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let k=ht(S),m=S.length*8-e.nBitLength;return m>0?k>>BigInt(m):k},D=e.bits2int_modN||function(S){return s(F(S))},R=qr(e.nBitLength);function w(S){return Te("num < 2^"+e.nBitLength,S,vt,R),Lt(S,e.nByteLength)}function v(S,k,m=M){if(["recovered","canonical"].some(ce=>ce in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:N,prehash:O,extraEntropy:H}=m;N==null&&(N=!0),S=ne("msgHash",S),Cu(m),O&&(S=ne("prehashed msgHash",p(S)));let z=D(S),W=f(k),$=[w(W),w(z)];if(H!=null&&H!==!1){let ce=H===!0?B(r.BYTES):H;$.push(ne("extraEntropy",ce))}let j=dt(...$),X=z;function ae(ce){let fe=F(ce);if(!l(fe))return;let ye=a(fe),ke=c.BASE.multiply(fe).toAffine(),ve=s(ke.x);if(ve===vt)return;let Je=s(ye*s(X+ve*W));if(Je===vt)return;let st=(ke.x===ve?0:2)|Number(ke.y&ue),Dr=Je;return N&&b(Je)&&(Dr=E(Je),st^=1),new d(ve,Dr,st)}return{seed:j,k2sig:ae}}let M={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function I(S,k,m=M){let{seed:p,k2sig:B}=v(S,k,m),N=e;return zi(N.hash.outputLen,N.nByteLength,N.hmac)(p,B)}c.BASE._setWindowSize(8);function K(S,k,m,p=_){let B=S;k=ne("msgHash",k),m=ne("publicKey",m);let{lowS:N,prehash:O,format:H}=p;if(Cu(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(H!==void 0&&H!=="compact"&&H!=="der")throw new Error("format must be compact or der");let z=typeof B=="string"||Rt(B),W=!z&&!H&&typeof B=="object"&&B!==null&&typeof B.r=="bigint"&&typeof B.s=="bigint";if(!z&&!W)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let $,j;try{if(W&&($=new d(B.r,B.s)),z){try{H!=="compact"&&($=d.fromDER(B))}catch(st){if(!(st instanceof bt.Err))throw st}!$&&H!=="der"&&($=d.fromCompact(B))}j=c.fromHex(m)}catch{return!1}if(!$||N&&$.hasHighS())return!1;O&&(k=e.hash(k));let{r:X,s:ae}=$,ce=D(k),fe=a(ae),ye=s(ce*fe),ke=s(X*fe),ve=c.BASE.multiplyAndAddUnsafe(j,ye,ke)?.toAffine();return ve?s(ve.x)===X:!1}return{CURVE:e,getPublicKey:T,getSharedSecret:U,sign:I,verify:K,ProjectivePoint:c,Signature:d,utils:A}}function V0(t){return{hash:t,hmac:(e,...r)=>Ks(t,e,Mi(...r)),randomBytes:Cn}}function Nu(t,e){let r=n=>Iu({...t,...V0(n)});return Object.freeze({...r(e),create:r})}var _u=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Uu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),D0=BigInt(1),$s=BigInt(2),Ru=(t,e)=>(t+e/$s)/e;function F0(t){let e=_u,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=te(u,r,e)*u%e,h=te(l,r,e)*u%e,b=te(h,$s,e)*f%e,E=te(b,o,e)*b%e,y=te(E,i,e)*E%e,d=te(y,a,e)*y%e,A=te(d,c,e)*d%e,T=te(A,a,e)*y%e,x=te(T,r,e)*u%e,U=te(x,s,e)*E%e,F=te(U,n,e)*f%e,D=te(F,$s,e);if(!qs.eql(qs.sqr(D),t))throw new Error("Cannot find square root");return D}var qs=Vt(_u,void 0,void 0,{sqrt:F0}),ir=Nu({a:BigInt(0),b:BigInt(7),Fp:qs,n:Uu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=Uu,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-D0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=Ru(i*t,e),c=Ru(-n*t,e),f=J(t-a*r-c*o,e),u=J(-a*n-c*i,e),l=f>s,h=u>s;if(l&&(f=e-f),h&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},ku),Rx=BigInt(0);var _x=ir.ProjectivePoint;function un(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=Qe(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function Lu(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}function Vu(t,e,r){let n=Wr.digest(r instanceof Uint8Array?r:r.subarray());if(Lu(n))return n.then(({digest:o})=>ir.verify(e,o,t)).catch(o=>{throw new sn(String(o))});try{return ir.verify(e,n.digest,t)}catch(o){throw new sn(String(o))}}var Ho=class{type="secp256k1";raw;_key;constructor(e){this._key=Fu(e),this.raw=Du(this._key)}toMultihash(){return ut.digest(vr(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return Vu(this._key,r,e)}};function zs(t){return new Ho(t)}function Du(t){return ir.ProjectivePoint.fromHex(t).toRawBytes(!0)}function Fu(t){try{return ir.ProjectivePoint.fromHex(t),t}catch(e){throw new ur(String(e))}}function Mu(t){let{Type:e,Data:r}=et.decode(t),n=r??new Uint8Array;switch(e){case se.RSA:return Hs(n);case se.Ed25519:return rs(n);case se.secp256k1:return zs(n);default:throw new fr}}function Po(t){let{Type:e,Data:r}=et.decode(t.digest),n=r??new Uint8Array;switch(e){case se.Ed25519:return rs(n);case se.secp256k1:return zs(n);default:throw new fr}}function vr(t){return et.encode({Type:se[t.type],Data:t.raw})}var Et="/",Ou=new TextEncoder().encode(Et),Ko=Ou[0],ln=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=Y(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Ko)throw new Error("Invalid key")}toString(e="utf8"){return Ue(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(Et))}static random(){return new t(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Ou),this._buf[0]!==Ko){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Ko,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Ko;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(Et).slice(1)}type(){return M0(this.baseNamespace())}name(){return O0(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Et)||(e+=Et),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(Et):new t(e.slice(0,-1).join(Et))}child(e){return this.toString()===Et?e:e.toString()===Et?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...H0(e.map(r=>r.namespaces()))])}};function M0(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function O0(t){let e=t.split(":");return e[e.length-1]}function H0(t){return[].concat(...t)}var Xl=Fr($o(),1);var qo=class extends Error{static name="SignatureCreationError";constructor(e="Record signature creation failed"){super(e),this.name="SignatureCreationError"}},Ze=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},zo=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},sr=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},Go=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},fn=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},Wo=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},hn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var ge;(function(t){let e;(function(o){o.EOL="EOL"})(e=t.ValidityType||(t.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Yr(r)}(e=t.ValidityType||(t.ValidityType={}));let n;t.codec=()=>(n==null&&(n=Ht((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),t.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=t.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),t.encode=o=>Ot(o,t.codec()),t.decode=(o,i)=>Mt(o,t.codec(),i)})(ge||(ge={}));var P0=["string","number","bigint","symbol"],K0=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Hu(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(P0.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if($0(t))return"Buffer";let r=q0(t);return r||"Object"}function $0(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function q0(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(K0.includes(e))return e}var g=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var V=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Ir=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",z0=new TextDecoder,G0=new TextEncoder;function Zo(t){return Ir&&globalThis.Buffer.isBuffer(t)}function Ws(t){return t instanceof Uint8Array?Zo(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var qu=Ir?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Ku(t,e,r):(t,e,r)=>r-e>64?z0.decode(t.subarray(e,r)):Ku(t,e,r),zu=Ir?t=>t.length>64?globalThis.Buffer.from(t):Pu(t):t=>t.length>64?G0.encode(t):Pu(t),ot=t=>Uint8Array.from(t),Nr=Ir?(t,e,r)=>Zo(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Gu=Ir?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ws(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Wu=Ir?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Zu(t,e){if(Zo(t)&&Zo(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function Pu(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}function Ku(t,e,r){let n=[];for(;e<r;){let o=t[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=r){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=t[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=t[e+1],c=t[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=t[e+1],c=t[e+2],f=t[e+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return W0(n)}var $u=4096;function W0(t){let e=t.length;if(e<=$u)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=$u));return r}var Z0=256,dn=class{constructor(e=Z0){this.chunkSize=e,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(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,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)}e.length<64&&e.length<this.chunkSize?(r=Wu(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Nr(n,0,this.cursor)}else r=Gu(this.chunks,this.cursor);return e&&this.reset(),r}};var P="CBOR decode error:",Zs="CBOR encode error:",pn=[];pn[23]=1;pn[24]=2;pn[25]=3;pn[26]=5;pn[27]=9;function Bt(t,e,r){if(t.length-e<r)throw new Error(`${P} not enough data for type`)}var le=[24,256,65536,4294967296,BigInt("18446744073709551616")];function _e(t,e,r){Bt(t,e,1);let n=t[e];if(r.strict===!0&&n<le[0])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Le(t,e,r){Bt(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<le[1])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Ve(t,e,r){Bt(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<le[2])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function De(t,e,r){Bt(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<le[3])throw new Error(`${P} 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(`${P} integers outside of the safe integer range are not supported`)}function ju(t,e,r,n){return new V(g.uint,_e(t,e+1,n),2)}function Yu(t,e,r,n){return new V(g.uint,Le(t,e+1,n),3)}function Ju(t,e,r,n){return new V(g.uint,Ve(t,e+1,n),5)}function Xu(t,e,r,n){return new V(g.uint,De(t,e+1,n),9)}function Me(t,e){return me(t,0,e.value)}function me(t,e,r){if(r<le[0]){let n=Number(r);t.push([e|n])}else if(r<le[1]){let n=Number(r);t.push([e|24,n])}else if(r<le[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<le[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<le[4]){let o=[e|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,t.push(o)}else throw new Error(`${P} encountered BigInt larger than allowable range`)}}Me.encodedSize=function(e){return me.encodedSize(e.value)};me.encodedSize=function(e){return e<le[0]?1:e<le[1]?2:e<le[2]?3:e<le[3]?5:9};Me.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Qu(t,e,r,n){return new V(g.negint,-1-_e(t,e+1,n),2)}function el(t,e,r,n){return new V(g.negint,-1-Le(t,e+1,n),3)}function tl(t,e,r,n){return new V(g.negint,-1-Ve(t,e+1,n),5)}var js=BigInt(-1),rl=BigInt(1);function nl(t,e,r,n){let o=De(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new V(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${P} integers outside of the safe integer range are not supported`);return new V(g.negint,js-BigInt(o),9)}function jo(t,e){let r=e.value,n=typeof r=="bigint"?r*js-rl:r*-1-1;me(t,e.type.majorEncoded,n)}jo.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*js-rl:r*-1-1;return n<le[0]?1:n<le[1]?2:n<le[2]?3:n<le[3]?5:9};jo.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function gn(t,e,r,n){Bt(t,e,r+n);let o=Nr(t,e+r,e+r+n);return new V(g.bytes,o,r+n)}function ol(t,e,r,n){return gn(t,e,1,r)}function il(t,e,r,n){return gn(t,e,2,_e(t,e+1,n))}function sl(t,e,r,n){return gn(t,e,3,Le(t,e+1,n))}function al(t,e,r,n){return gn(t,e,5,Ve(t,e+1,n))}function cl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer bytes lengths not supported`);return gn(t,e,9,o)}function Yo(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===g.string?zu(t.value):t.value),t.encodedBytes}function Ur(t,e){let r=Yo(e);me(t,e.type.majorEncoded,r.length),t.push(r)}Ur.encodedSize=function(e){let r=Yo(e);return me.encodedSize(r.length)+r.length};Ur.compareTokens=function(e,r){return Y0(Yo(e),Yo(r))};function Y0(t,e){return t.length<e.length?-1:t.length>e.length?1:Zu(t,e)}function mn(t,e,r,n,o){let i=r+n;Bt(t,e,i);let s=new V(g.string,qu(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Nr(t,e+r,e+i)),s}function ul(t,e,r,n){return mn(t,e,1,r,n)}function ll(t,e,r,n){return mn(t,e,2,_e(t,e+1,n),n)}function fl(t,e,r,n){return mn(t,e,3,Le(t,e+1,n),n)}function hl(t,e,r,n){return mn(t,e,5,Ve(t,e+1,n),n)}function dl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer string lengths not supported`);return mn(t,e,9,o,n)}var pl=Ur;function Rr(t,e,r,n){return new V(g.array,n,r)}function gl(t,e,r,n){return Rr(t,e,1,r)}function ml(t,e,r,n){return Rr(t,e,2,_e(t,e+1,n))}function yl(t,e,r,n){return Rr(t,e,3,Le(t,e+1,n))}function xl(t,e,r,n){return Rr(t,e,5,Ve(t,e+1,n))}function wl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer array lengths not supported`);return Rr(t,e,9,o)}function bl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return Rr(t,e,1,1/0)}function Jo(t,e){me(t,g.array.majorEncoded,e.value)}Jo.compareTokens=Me.compareTokens;Jo.encodedSize=function(e){return me.encodedSize(e.value)};function _r(t,e,r,n){return new V(g.map,n,r)}function vl(t,e,r,n){return _r(t,e,1,r)}function El(t,e,r,n){return _r(t,e,2,_e(t,e+1,n))}function Bl(t,e,r,n){return _r(t,e,3,Le(t,e+1,n))}function Al(t,e,r,n){return _r(t,e,5,Ve(t,e+1,n))}function Sl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer map lengths not supported`);return _r(t,e,9,o)}function kl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return _r(t,e,1,1/0)}function Xo(t,e){me(t,g.map.majorEncoded,e.value)}Xo.compareTokens=Me.compareTokens;Xo.encodedSize=function(e){return me.encodedSize(e.value)};function Cl(t,e,r,n){return new V(g.tag,r,1)}function Tl(t,e,r,n){return new V(g.tag,_e(t,e+1,n),2)}function Il(t,e,r,n){return new V(g.tag,Le(t,e+1,n),3)}function Nl(t,e,r,n){return new V(g.tag,Ve(t,e+1,n),5)}function Ul(t,e,r,n){return new V(g.tag,De(t,e+1,n),9)}function Qo(t,e){me(t,g.tag.majorEncoded,e.value)}Qo.compareTokens=Me.compareTokens;Qo.encodedSize=function(e){return me.encodedSize(e.value)};var rp=20,np=21,op=22,ip=23;function Rl(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${P} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new V(g.null,null,1):new V(g.undefined,void 0,1)}function _l(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return new V(g.break,void 0,1)}function Ys(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${P} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${P} Infinity values are not supported`)}return new V(g.float,t,e)}function Ll(t,e,r,n){return Ys(Js(t,e+1),3,n)}function Vl(t,e,r,n){return Ys(Xs(t,e+1),5,n)}function Dl(t,e,r,n){return Ys(Hl(t,e+1),9,n)}function ei(t,e,r){let n=e.value;if(n===!1)t.push([g.float.majorEncoded|rp]);else if(n===!0)t.push([g.float.majorEncoded|np]);else if(n===null)t.push([g.float.majorEncoded|op]);else if(n===void 0)t.push([g.float.majorEncoded|ip]);else{let o,i=!1;(!r||r.float64!==!0)&&(Ml(n),o=Js(je,1),n===o||Number.isNaN(n)?(je[0]=249,t.push(je.slice(0,3)),i=!0):(Ol(n),o=Xs(je,1),n===o&&(je[0]=250,t.push(je.slice(0,5)),i=!0))),i||(sp(n),o=Hl(je,1),je[0]=251,t.push(je.slice(0,9)))}}ei.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Ml(n);let o=Js(je,1);if(n===o||Number.isNaN(n))return 3;if(Ol(n),o=Xs(je,1),n===o)return 5}return 9};var Fl=new ArrayBuffer(9),Oe=new DataView(Fl,1),je=new Uint8Array(Fl,0);function Ml(t){if(t===1/0)Oe.setUint16(0,31744,!1);else if(t===-1/0)Oe.setUint16(0,64512,!1);else if(Number.isNaN(t))Oe.setUint16(0,32256,!1);else{Oe.setFloat32(0,t);let e=Oe.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Oe.setUint16(0,31744,!1);else if(r===0)Oe.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Oe.setUint16(0,0):o<-14?Oe.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Oe.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Js(t,e){if(t.length-e<2)throw new Error(`${P} not enough data for float16`);let r=(t[e]<<8)+t[e+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 Ol(t){Oe.setFloat32(0,t,!1)}function Xs(t,e){if(t.length-e<4)throw new Error(`${P} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function sp(t){Oe.setFloat64(0,t,!1)}function Hl(t,e){if(t.length-e<8)throw new Error(`${P} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}ei.compareTokens=Me.compareTokens;function Z(t,e,r){throw new Error(`${P} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function ti(t){return()=>{throw new Error(`${P} ${t}`)}}var C=[];for(let t=0;t<=23;t++)C[t]=Z;C[24]=ju;C[25]=Yu;C[26]=Ju;C[27]=Xu;C[28]=Z;C[29]=Z;C[30]=Z;C[31]=Z;for(let t=32;t<=55;t++)C[t]=Z;C[56]=Qu;C[57]=el;C[58]=tl;C[59]=nl;C[60]=Z;C[61]=Z;C[62]=Z;C[63]=Z;for(let t=64;t<=87;t++)C[t]=ol;C[88]=il;C[89]=sl;C[90]=al;C[91]=cl;C[92]=Z;C[93]=Z;C[94]=Z;C[95]=ti("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)C[t]=ul;C[120]=ll;C[121]=fl;C[122]=hl;C[123]=dl;C[124]=Z;C[125]=Z;C[126]=Z;C[127]=ti("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)C[t]=gl;C[152]=ml;C[153]=yl;C[154]=xl;C[155]=wl;C[156]=Z;C[157]=Z;C[158]=Z;C[159]=bl;for(let t=160;t<=183;t++)C[t]=vl;C[184]=El;C[185]=Bl;C[186]=Al;C[187]=Sl;C[188]=Z;C[189]=Z;C[190]=Z;C[191]=kl;for(let t=192;t<=215;t++)C[t]=Cl;C[216]=Tl;C[217]=Il;C[218]=Nl;C[219]=Ul;C[220]=Z;C[221]=Z;C[222]=Z;C[223]=Z;for(let t=224;t<=243;t++)C[t]=ti("simple values are not supported");C[244]=Z;C[245]=Z;C[246]=Z;C[247]=Rl;C[248]=ti("simple values are not supported");C[249]=Ll;C[250]=Vl;C[251]=Dl;C[252]=Z;C[253]=Z;C[254]=Z;C[255]=_l;var Ye=[];for(let t=0;t<24;t++)Ye[t]=new V(g.uint,t,1);for(let t=-1;t>=-24;t--)Ye[31-t]=new V(g.negint,t,1);Ye[64]=new V(g.bytes,new Uint8Array(0),1);Ye[96]=new V(g.string,"",1);Ye[128]=new V(g.array,0,1);Ye[160]=new V(g.map,0,1);Ye[244]=new V(g.false,!1,1);Ye[245]=new V(g.true,!0,1);Ye[246]=new V(g.null,null,1);function Pl(t){switch(t.type){case g.false:return ot([244]);case g.true:return ot([245]);case g.null:return ot([246]);case g.bytes:return t.value.length?void 0:ot([64]);case g.string:return t.value===""?ot([96]):void 0;case g.array:return t.value===0?ot([128]):void 0;case g.map:return t.value===0?ot([160]):void 0;case g.uint:return t.value<24?ot([Number(t.value)]):void 0;case g.negint:if(t.value>=-24)return ot([31-Number(t.value)])}}var cp={float64:!1,mapSorter:fp,quickEncodeToken:Pl};function up(){let t=[];return t[g.uint.major]=Me,t[g.negint.major]=jo,t[g.bytes.major]=Ur,t[g.string.major]=pl,t[g.array.major]=Jo,t[g.map.major]=Xo,t[g.tag.major]=Qo,t[g.float.major]=ei,t}var Kl=up(),Qs=new dn,ni=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${Zs} object contains circular references`);return new t(r,e)}},Zt={null:new V(g.null,null),undefined:new V(g.undefined,void 0),true:new V(g.true,!0),false:new V(g.false,!1),emptyArray:new V(g.array,0),emptyMap:new V(g.map,0)},jt={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new V(g.float,t):t>=0?new V(g.uint,t):new V(g.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new V(g.uint,t):new V(g.negint,t)},Uint8Array(t,e,r,n){return new V(g.bytes,t)},string(t,e,r,n){return new V(g.string,t)},boolean(t,e,r,n){return t?Zt.true:Zt.false},null(t,e,r,n){return Zt.null},undefined(t,e,r,n){return Zt.undefined},ArrayBuffer(t,e,r,n){return new V(g.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new V(g.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[Zt.emptyArray,new V(g.break)]:Zt.emptyArray;n=ni.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=ri(s,r,n);return r.addBreakTokens?[new V(g.array,t.length),o,new V(g.break)]:[new V(g.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length;if(!s)return r.addBreakTokens===!0?[Zt.emptyMap,new V(g.break)]:Zt.emptyMap;n=ni.createCheck(n,t);let a=[],c=0;for(let f of i)a[c++]=[ri(f,r,n),ri(o?t.get(f):t[f],r,n)];return lp(a,r),r.addBreakTokens?[new V(g.map,s),a,new V(g.break)]:[new V(g.map,s),a]}};jt.Map=jt.Object;jt.Buffer=jt.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))jt[`${t}Array`]=jt.DataView;function ri(t,e={},r){let n=Hu(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||jt[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=jt[n];if(!i)throw new Error(`${Zs} unsupported type: ${n}`);return i(t,n,e,r)}function lp(t,e){e.mapSorter&&t.sort(e.mapSorter)}function fp(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Kl[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function $l(t,e,r,n){if(Array.isArray(e))for(let o of e)$l(t,o,r,n);else r[e.type.major](t,e,n)}function hp(t,e,r){let n=ri(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new dn(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ws(a.chunks[0])}}return Qs.reset(),$l(Qs,n,e,r),Qs.toBytes(!0)}function ea(t,e){return e=Object.assign({},cp,e),hp(t,Kl,e)}var dp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},oi=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=Ye[e];if(r===void 0){let n=C[e];if(!n)throw new Error(`${P} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},yn=Symbol.for("DONE"),ii=Symbol.for("BREAK");function pp(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Lr(e,r);if(i===ii){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed array`)}if(i===yn)throw new Error(`${P} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function gp(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<t.value;s++){let a=Lr(e,r);if(a===ii){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed map`)}if(a===yn)throw new Error(`${P} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${P} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${P} found repeat map key "${a}"`);let c=Lr(e,r);if(c===yn)throw new Error(`${P} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Lr(t,e){if(t.done())return yn;let r=t.next();if(r.type===g.break)return ii;if(r.type.terminal)return r.value;if(r.type===g.array)return pp(r,t,e);if(r.type===g.map)return gp(r,t,e);if(r.type===g.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Lr(t,e);return e.tags[r.value](n)}throw new Error(`${P} tag not supported (${r.value})`)}throw new Error("unsupported")}function ql(t,e){if(!(t instanceof Uint8Array))throw new Error(`${P} data to decode must be a Uint8Array`);e=Object.assign({},dp,e);let r=e.tokenizer||new oi(t,e),n=Lr(r,e);if(n===yn)throw new Error(`${P} did not find any content to decode`);if(n===ii)throw new Error(`${P} got unexpected break`);return[n,t.subarray(r.pos())]}function ta(t,e){let[r,n]=ql(t,e);if(n.length>0)throw new Error(`${P} too many terminals, data makes no sense`);return r}var yp=Tt("ipns:utils"),zl=Y("/ipns/"),xp=114,wp=0,bp=18;function Gl(t){let e;if(t.pubKey!=null)try{e=Mu(t.pubKey)}catch(r){throw yp.error(r),r}if(e!=null)return e}function Wl(t,e,r){let n=Y(e);return un([t,r,n])}function ai(t){let e=Y("ipns-signature:");return un([e,t])}function ra(t){return"signatureV1"in t?ge.encode({value:Y(t.value),signatureV1:t.signatureV1,validityType:t.validityType,validity:Y(t.validity),sequence:t.sequence,ttl:t.ttl,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data}):ge.encode({pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data})}function it(t){let e=ge.decode(t);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new Ze("Missing data or signatureV2");let r=Yl(e.data),n=vp(r.Value),o=Ue(r.Validity);if(e.value!=null&&e.signatureV1!=null)return Ep(e),{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function Vr(t){return un([zl,t.bytes])}function Zl(t){let e=ct(t.slice(zl.length));if(!si(e,wp)&&!si(e,bp))throw new lr("Multihash in IPNS key was not identity or sha2-256");return e}function jl(t,e,r,n,o){let i;if(e===ge.ValidityType.EOL)i=0;else throw new sr("The validity type is unsupported");return ea({Value:t,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Yl(t){let e=ta(t);if(e.ValidityType===0)e.ValidityType=ge.ValidityType.EOL;else throw new sr("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function vp(t){let e=Ue(t).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${re.decode(t).toV1().toString()}`}catch{}try{return`/ipfs/${re.parse(e).toV1().toString()}`}catch{}throw new fn("Value must be a valid content path starting with /")}function Jl(t){if(t!=null){let e=Sp(t);if(e!=null)return e.code===xp?`/ipns/${e.toString(He)}`:`/ipfs/${e.toV1().toString()}`;if(Bp(t))return`/ipns/${He.encode(t.bytes)}`;let r=t.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new fn("Value must be a valid content path starting with /")}function Ep(t){if(t.data==null)throw new Wo("Record data is missing");let e=Yl(t.data);if(!he(e.Value,t.value??new Uint8Array(0)))throw new Ze('Field "value" did not match between protobuf and CBOR');if(!he(e.Validity,t.validity??new Uint8Array(0)))throw new Ze('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==t.validityType)throw new Ze('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==t.sequence)throw new Ze('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==t.ttl)throw new Ze('Field "ttl" did not match between protobuf and CBOR')}function Bp(t){return t.bytes instanceof Uint8Array}function Ap(t){return typeof t?.toCID=="function"}function Sp(t){if(Ap(t))return t.toCID();try{return re.parse(t)}catch{}return re.asCID(t)}function si(t,e){return t.code===e}var kp=Tt("ipns"),Ql=60*60*1e9,Cp="/ipns/",Gb=Cp.length,ef={v1Compatible:!0,ttlNs:Ql};async function tf(t,e,r,n,o=ef){let i=new Xl.default(Date.now()+Number(n)),s=ge.ValidityType.EOL,a=BigInt(o.ttlNs??Ql);return Tp(t,e,r,s,i.toString(),a,o)}var Tp=async(t,e,r,n,o,i,s=ef)=>{r=BigInt(r);let a=Y(o),c=Jl(e),f=Y(c),u=jl(f,n,a,r,i),l=ai(u),h=await t.sign(l),b;if(t.type==="RSA"&&(b=vr(t.publicKey)),s.v1Compatible===!0){let E=await Ip(t,f,n,a),y={value:c,signatureV1:E,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return b!=null&&(y.pubKey=b),y}else{let E={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return b!=null&&(E.pubKey=b),E}},Ip=async(t,e,r,n)=>{try{let o=Wl(e,r,n);return await t.sign(o)}catch(o){throw kp.error("record signature creation failed",o),new qo("Record signature creation failed")}};var na=Fr($o(),1);function ci(t,e){let r=e.map((n,o)=>({record:it(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===ge.ValidityType.EOL&&o.record.validityType===ge.ValidityType.EOL){let a=na.default.fromString(n.record.validity).toDate(),c=na.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var rf=Fr($o(),1);var ui=Tt("ipns:validator"),Np=1024*10,Up=async(t,e)=>{let r=it(e),n;try{let o=ai(r.data);n=await t.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw ui.error("record signature verification failed"),new Ze("Record signature verification failed");if(r.validityType===ge.ValidityType.EOL){if(rf.default.fromString(r.validity).toDate().getTime()<Date.now())throw ui.error("record has expired"),new zo("record has expired")}else if(r.validityType!=null)throw ui.error("the validity type is unsupported"),new sr("The validity type is unsupported");ui("ipns record for %s is valid",r.value)};async function li(t,e){if(e.byteLength>Np)throw new Go("The record is too large");let r=Zl(t),n;si(r,0)&&(n=Po(r));let o=it(e),i=Gl(o)??n;if(i==null)throw new hn("Could not extract public key from IPNS record or routing key");let s=Vr(i.toMultihash());if(!he(t,s))throw new hn("Embedded public key did not match routing key");await Up(i,e)}var Se=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var nf=Symbol.for("nodejs.util.inspect.custom"),Rp=114,xn=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ai]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return re.createV1(Rp,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return he(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return he(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[nf](){return`PeerId(${this.toString()})`}},fi=class extends xn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},hi=class extends xn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},di=class extends xn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},_p=2336,pi=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ut.digest(Y(this.url))}[nf](){return`PeerId(${this.url})`}[Ai]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return re.createV1(_p,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=Ue(e)),e.toString()===this.toString())}};function of(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=ct(Q.decode(`z${t}`));else{if(e==null)throw new xe('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=ct(e.decode(t))}return Lp(r)}function Lp(t){if(Dp(t))return new fi({multihash:t});if(Vp(t))try{let e=Po(t);if(e.type==="Ed25519")return new hi({multihash:t,publicKey:e});if(e.type==="secp256k1")return new di({multihash:t,publicKey:e})}catch{let r=Ue(t.digest);return new pi(new URL(r))}throw new lr("Supplied PeerID Multihash is invalid")}function Vp(t){return t.code===ut.code}function Dp(t){return t.code===Wr.code}var Op=Fr(af(),1);var At;(function(t){t[t.A=1]="A",t[t.CNAME=5]="CNAME",t[t.TXT=16]="TXT",t[t.AAAA=28]="AAAA"})(At||(At={}));var gi=class extends Error{static name="DNSLinkNotFoundError";constructor(e="DNSLink not found"){super(e),this.name="DNSLinkNotFoundError"}},mi=class extends Error{static name="RecordsFailedValidationError";constructor(e="Records failed validation"){super(e),this.name="RecordsFailedValidationError"}},yi=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(e="Unsupported multibase prefix"){super(e),this.name="UnsupportedMultibasePrefixError"}},xi=class extends Error{static name="UnsupportedMultihashCodecError";constructor(e="Unsupported multihash codec"){super(e),this.name="UnsupportedMultihashCodecError"}},wi=class extends Error{static name="InvalidValueError";constructor(e="Invalid value"){super(e),this.name="InvalidValueError"}};var Hp=32;async function cf(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",t);let s=((await r.query(t,{...o,types:[At.TXT]}))?.Answer??[]).sort((f,u)=>f.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,t);for(let f of s)try{let u=f.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",f.name,u),u=u.replace("dnslink=","");let[,l,h,...b]=u.split("/");if(l==="ipfs")try{return{value:`/ipfs/${re.parse(h)}${b.length>0?`/${b.join("/")}`:""}`,answer:f}}catch{}else if(l==="ipns"){try{return{value:`/ipns/${of(h)}${b.length>0?`/${b.join("/")}`:""}`,answer:f}}catch{}return await bi(h,e-1,r,n,o)}else{if(l==="dnslink")return await bi(h,e-1,r,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',l,t);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",t,f.data,u)}n("no DNSLink records found for %s, falling back to CNAME",t);let c=((await r.query(t,{...o,types:[At.CNAME]}))?.Answer??[]).sort((f,u)=>f.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,t);for(let f of c)try{return await bi(f.data,e-1,r,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",t,f.data,u)}throw new gi(`No DNSLink records found for domain: ${t}`)}async function bi(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");t.startsWith("_dnslink.")||(t=`_dnslink.${t}`);try{return await cf(t,e,r,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ENODATA"&&i.name!=="DNSLinkNotFoundError"&&i.name!=="NotFoundError")throw i;return t.startsWith("_dnslink.")?t=t.replace("_dnslink.",""):t=`_dnslink.${t}`,cf(t,e,r,n,o)}}async function uf(t,e,r,n={}){return bi(t,n.maxRecursiveDepth??Hp,e,r,n)}var oa=class{routing;constructor(e){this.routing=e}async put(e,r,n={}){try{await this.routing.put(e,r,n)}catch(o){n.onProgress?.(new Se("ipns:routing:helia:error",o))}}async get(e,r={}){try{return await this.routing.get(e,r)}catch(n){r.onProgress?.(new Se("ipns:routing:helia:error",n))}throw new Error("Not found")}};function lf(t){return new oa(t)}var wn;(function(t){let e;t.codec=()=>(e==null&&(e=Ht((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:ns(0),value:ns(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Ot(r,t.codec()),t.decode=(r,n)=>Mt(r,t.codec(),n)})(wn||(wn={}));function ff(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0"),o=String(t.getUTCHours()).padStart(2,"0"),i=String(t.getUTCMinutes()).padStart(2,"0"),s=String(t.getUTCSeconds()).padStart(2,"0"),a=t.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function hf(t){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),f=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,f))}var cr=class t{key;value;timeReceived;constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=r,this.timeReceived=n}serialize(){return wn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:ff(this.timeReceived)}}static deserialize(e){let r=wn.decode(e);return new t(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(e){let r=hf(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new t(e.key,e.value,r)}};var df;(function(t){t[t.SEND_QUERY=0]="SEND_QUERY",t[t.PEER_RESPONSE=1]="PEER_RESPONSE",t[t.FINAL_PEER=2]="FINAL_PEER",t[t.QUERY_ERROR=3]="QUERY_ERROR",t[t.PROVIDER=4]="PROVIDER",t[t.VALUE=5]="VALUE",t[t.ADD_PEER=6]="ADD_PEER",t[t.DIAL_PEER=7]="DIAL_PEER"})(df||(df={}));function vi(t){return new ln("/dht/record/"+Ue(t,"base32"),!1)}function pf(t){return{async put(e,r,n={}){try{let o=vi(e);try{let s=await t.get(o),a=cr.deserialize(s);if(he(a.value,r))return}catch(s){if(s.name!=="NotFoundError")throw s}let i=new cr(e,r,new Date);n.onProgress?.(new Se("ipns:routing:datastore:put")),await t.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new Se("ipns:routing:datastore:error",o)),o}},async get(e,r={}){try{let n=vi(e);r.onProgress?.(new Se("ipns:routing:datastore:get"));let o=await t.get(n,r),i=cr.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw r.onProgress?.(new Se("ipns:routing:datastore:error",n)),n}},async has(e,r={}){let n=vi(e);return t.has(n,r)},async delete(e,r){let n=vi(e);return t.delete(n,r)}}}function ia(t,e){return t.code===e}var St=Tt("helia:ipns"),qp=60*1e3,ca=60*qp,zp=24*ca,sa=23*ca,Gp=BigInt(ca)*1000000n,gf={[He.prefix]:He,[Q.prefix]:Q},aa=class{routers;localStore;timeout;dns;log;constructor(e,r=[]){this.routers=[lf(e.routing),...r],this.localStore=pf(e.datastore),this.dns=e.dns,this.log=e.logger.forComponent("helia:ipns")}async publish(e,r,n={}){try{let o=1n,i=Vr(e.publicKey.toMultihash());if(await this.localStore.has(i,n)){let{record:c}=await this.localStore.get(i,n);o=it(c).sequence+1n}let s=await tf(e,r,o,n.lifetime??zp,n),a=ra(s);return await this.localStore.put(i,a,n),n.offline!==!0&&await Promise.all(this.routers.map(async c=>{await c.put(i,a,n)})),s}catch(o){throw n.onProgress?.(new Se("ipns:publish:error",o)),o}}async resolve(e,r={}){let n=ya(e)?e.toMultihash():e,o=Vr(n),i=await this.#t(o,r);return{...await this.#e(i.value,r),record:i}}async resolveDNSLink(e,r={}){let n=await uf(e,this.dns,this.log,r);return{...await this.#e(n.value,r),answer:n.answer}}republish(e={}){if(this.timeout!=null)throw new Error("Republish is already running");e.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function r(){let n=Date.now();e.onProgress?.(new Se("ipns:republish:start"));let i=Date.now()-n,s=sa-i;s<0&&(s=e.interval??sa),setTimeout(()=>{r().catch(a=>{St.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{r().catch(n=>{St.error("error republishing",n)})},e.interval??sa)}async#e(e,r={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=Q.decode(`z${i}`);else if(gf[s]!=null)a=gf[s].decode(i);else throw new yi(`Unsupported multibase prefix "${s}"`);let c;try{c=ct(a)}catch{c=re.decode(a).multihash}if(!ia(c,0)&&!ia(c,18))throw new xi(`Unsupported multihash codec "${c.code}"`);let{cid:f}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:f,path:u}}else if(o==="ipfs"){let i=re.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){St.error("error parsing ipfs path",o)}throw St.error("invalid ipfs path %s",e),new wi("Invalid value")}async#t(e,r={}){let n=[];if(await this.localStore.has(e,r))if(St("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(e,r);this.log("record retrieved from cache"),await li(e,a),this.log("record was valid");let f=it(a),u=Number((f.ttl??Gp)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),f;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),f;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(e,r)}else St("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new Mr("Record was not present in the cache or has expired");St("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(e,{...r,validate:!1})}catch(f){St.error("error finding IPNS record",f);return}try{await li(e,c),n.push(c)}catch(f){i++,St.error("error finding IPNS record",f)}})),n.length===0)throw i>0?new mi(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new Mr("Could not find record for routing key");let s=n[ci(e,n)];return await this.localStore.put(e,s,r),it(s)}};function Wp(t,{routers:e=[]}={}){return new aa(t,e)}return If(Zp);})();
|
|
7
|
+
`)}`:`${r} :`}};Sc=$t;L.Constructed=Sc;$t.NAME="CONSTRUCTED";var Yn=class extends be{fromBER(e,r,n){return r}toBER(e){return Ge}};Yn.override="EndOfContentValueBlock";var kc,Jn=class extends de{constructor(e={}){super(e,Yn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};kc=Jn;L.EndOfContent=kc;Jn.NAME=Jr;var Cc,Er=class extends de{constructor(e={}){super(e,be),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,r,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,r+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):r+n}toBER(e,r){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return r&&r.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Cc=Er;L.Null=Cc;Er.NAME="NULL";var Xn=class extends xt(be){constructor({value:e,...r}={}){super(r),r.valueHex?this.valueHexView=G.BufferSourceConverter.toUint8Array(r.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,r,n){let o=G.BufferSourceConverter.toUint8Array(e);return yt(this,o,r,n)?(this.valueHexView=o.subarray(r,r+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,As.call(this),this.blockLength=n,r+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Xn.NAME="BooleanValueBlock";var Tc,Qn=class extends de{constructor(e={}){super(e,Xn),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Tc=Qn;L.Boolean=Tc;Qn.NAME="BOOLEAN";var eo=class extends xt(et){constructor({isConstructed:e=!1,...r}={}){super(r),this.isConstructed=e}fromBER(e,r,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=et.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==vc)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,r,n),this.blockLength=n;return o}toBER(e,r){return this.isConstructed?et.prototype.toBER.call(this,e,r):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};eo.NAME="OctetStringValueBlock";var Ic,to=class t extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},eo),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,r,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),r;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(r,r+n);try{if(i.byteLength){let s=No(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,r,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?$t.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let r of this.valueBlock.value)r instanceof t&&e.push(r.valueBlock.valueHexView);return G.BufferSourceConverter.concat(e)}};Ic=to;L.OctetString=Ic;to.NAME=vc;var ro=class extends xt(et){constructor({unusedBits:e=0,isConstructed:r=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=r,this.blockLength=this.valueHexView.byteLength}fromBER(e,r,n){if(!n)return r;let o=-1;if(this.isConstructed){if(o=et.prototype.fromBER.call(this,e,r,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Ec)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=a.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return o}let i=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,i,r,n))return-1;let s=i.subarray(r,r+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=No(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,r+n}toBER(e,r){if(this.isConstructed)return et.prototype.toBER.call(this,e,r);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ge;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};ro.NAME="BitStringValueBlock";var Nc,Br=class extends de{constructor({idBlock:e={},lenBlock:r={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},ro),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,r,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,r,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return $t.prototype.onAsciiEncoding.call(this);{let e=[],r=this.valueBlock.valueHexView;for(let o of r)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Nc=Br;L.BitString=Nc;Br.NAME=Ec;var Uc;function a0(t,e){let r=new Uint8Array([0]),n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,l=0,u=c<s?s:c,f=0;for(let h=u;h>=0;h--,f++){switch(!0){case f<a.length:l=i[s-f]+a[c-f]+r[0];break;default:l=i[s-f]+r[0]}switch(r[0]=l/10,!0){case f>=i.length:i=$n(new Uint8Array([l%10]),i);break;default:i[s-f]=l%10}}return r[0]>0&&(i=$n(r,i)),i}function bc(t){if(t>=jr.length)for(let e=jr.length;e<=t;e++){let r=new Uint8Array([0]),n=jr[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+r[0]]);r[0]=i[0]/10,n[o]=i[0]%10}r[0]>0&&(n=$n(r,n)),jr.push(n)}return jr[t]}function c0(t,e){let r=0,n=new Uint8Array(t),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,l,u=0;for(let f=c;f>=0;f--,u++)switch(l=i[s-u]-a[c-u]-r,!0){case l<0:r=1,i[s-u]=l+10;break;default:r=0,i[s-u]=l}if(r>0)for(let f=s-c+1;f>=0;f--,u++)if(l=i[s-u]-r,l<0)r=1,i[s-u]=l+10;else{r=0,i[s-u]=l;break}return i.slice()}var Xr=class extends xt(be){constructor({value:e,...r}={}){super(r),this._valueDec=0,r.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=As.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(yc(e))}get valueDec(){return this._valueDec}fromDER(e,r,n,o=0){let i=this.fromBER(e,r,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let r=this.valueHexView;switch(!0){case(r[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(r,1),this.valueHexView=n}break;case(r[0]===0&&(r[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,r,n){let o=super.fromBER(e,r,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,r=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let l=0;l<8;l++){if((o&1)===1)switch(n){case e:r=c0(bc(n),r),s="-";break;default:r=a0(r,bc(n))}n++,o>>=1}}for(let c=0;c<r.length;c++)r[c]&&(a=!0),a&&(s+=wc.charAt(r[c]));return a===!1&&(s+=wc.charAt(0)),s}};Uc=Xr;Xr.NAME="IntegerValueBlock";Object.defineProperty(Uc.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Rc,pe=class t extends de{constructor(e={}){super(e,Xr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return qn(),BigInt(this.valueBlock.toString())}static fromBigInt(e){qn();let r=BigInt(e),n=new Yr,o=r.toString(16).replace(/^-/,""),i=new Uint8Array(G.Convert.FromHex(o));if(r<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let l=BigInt(`0x${G.Convert.ToHex(a)}`)+r,u=G.BufferSourceConverter.toUint8Array(G.Convert.FromHex(l.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new t({valueHex:n.final()})}convertToDER(){let e=new t({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new t({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Rc=pe;L.Integer=Rc;pe.NAME="INTEGER";var _c,no=class extends pe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};_c=no;L.Enumerated=_c;no.NAME="ENUMERATED";var Qr=class extends xt(be){constructor({valueDec:e=-1,isFirstSid:r=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=r}fromBER(e,r,n){if(!n)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=tr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}set valueBigInt(e){qn();let r=BigInt(e).toString(2);for(;r.length%7;)r="0"+r;let n=new Uint8Array(r.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(r.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=Kt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",Ge;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=G.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let r=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",r-=40):(e="2.",r-=80),e+=r.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Qr.NAME="sidBlock";var oo=class extends be{constructor({value:e=Sr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new Qr;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let r=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,Ge;r.push(o)}return Ss(r)}fromString(e){this.value=[];let r=0,n=0,o="",i=!1;do if(n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new Qr;if(o>Number.MAX_SAFE_INTEGER){qn();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};oo.NAME="ObjectIdentifierValueBlock";var Lc,Ar=class extends de{constructor(e={}){super(e,oo),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Lc=Ar;L.ObjectIdentifier=Lc;Ar.NAME="OBJECT IDENTIFIER";var en=class extends xt(pt){constructor({valueDec:e=0,...r}={}){super(r),this.valueDec=e}fromBER(e,r,n){if(n===0)return r;let o=G.BufferSourceConverter.toUint8Array(e);if(!yt(this,o,r,n))return-1;let i=o.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=tr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let r=Kt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",Ge;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=G.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};en.NAME="relativeSidBlock";var io=class extends be{constructor({value:e=Sr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new en;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,r){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,Ge;n.push(i)}return Ss(n)}fromString(e){this.value=[];let r=0,n=0,o="";do{n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1;let i=new en;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};io.NAME="RelativeObjectIdentifierValueBlock";var Vc,so=class extends de{constructor(e={}){super(e,io),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Vc=so;L.RelativeObjectIdentifier=Vc;so.NAME="RelativeObjectIdentifier";var Dc,gt=class extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Dc=gt;L.Sequence=Dc;gt.NAME="SEQUENCE";var Fc,ao=class extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Fc=ao;L.Set=Fc;ao.NAME="SET";var co=class extends xt(be){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Sr}toJSON(){return{...super.toJSON(),value:this.value}}};co.NAME="StringValueBlock";var uo=class extends co{};uo.NAME="SimpleStringValueBlock";var Ae=class extends Zn{constructor({...e}={}){super(e,uo)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Ae.NAME="SIMPLE STRING";var lo=class extends Ae{fromBuffer(e){this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=G.Convert.ToUtf8String(e)}catch(r){this.warnings.push(`Error during "decodeURIComponent": ${r}, using raw string`),this.valueBlock.value=G.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf8String(e)),this.valueBlock.value=e}};lo.NAME="Utf8StringValueBlock";var Mc,mt=class extends lo{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Mc=mt;L.Utf8String=Mc;mt.NAME="UTF8String";var fo=class extends Ae{fromBuffer(e){this.valueBlock.value=G.Convert.ToUtf16String(e),this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf16String(e))}};fo.NAME="BmpStringValueBlock";var Oc,ho=class extends fo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Oc=ho;L.BmpString=Oc;ho.NAME="BMPString";var po=class extends Ae{fromBuffer(e){let r=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(r);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(r))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r*4);for(let o=0;o<r;o++){let i=Kt(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};po.NAME="UniversalStringValueBlock";var Hc,go=class extends po{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Hc=go;L.UniversalString=Hc;go.NAME="UniversalString";var Pc,mo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Pc=mo;L.NumericString=Pc;mo.NAME="NumericString";var Kc,yo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Kc=yo;L.PrintableString=Kc;yo.NAME="PrintableString";var $c,xo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};$c=xo;L.TeletexString=$c;xo.NAME="TeletexString";var qc,wo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};qc=wo;L.VideotexString=qc;wo.NAME="VideotexString";var zc,bo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};zc=bo;L.IA5String=zc;bo.NAME="IA5String";var Gc,vo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Gc=vo;L.GraphicString=Gc;vo.NAME="GraphicString";var Zc,tn=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Zc=tn;L.VisibleString=Zc;tn.NAME="VisibleString";var Wc,Eo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Wc=Eo;L.GeneralString=Wc;Eo.NAME="GeneralString";var jc,Bo=class extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};jc=Bo;L.CharacterString=jc;Bo.NAME="CharacterString";var Yc,rn=class extends tn{constructor({value:e,valueDate:r,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}r&&(this.fromDate(r),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return r}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let r=new Array(7);return r[0]=Ne(this.year<2e3?this.year-1900:this.year-2e3,2),r[1]=Ne(this.month,2),r[2]=Ne(this.day,2),r[3]=Ne(this.hour,2),r[4]=Ne(this.minute,2),r[5]=Ne(this.second,2),r[6]="Z",r.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};Yc=rn;L.UTCTime=Yc;rn.NAME="UTCTime";var Jc,Ao=class extends rn{constructor(e={}){var r;super(e),(r=this.millisecond)!==null&&r!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let r=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),r=!0;else{let f=new Number(e[e.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let f=1,h=n.indexOf("+"),v="";if(h===-1&&(h=n.indexOf("-"),f=-1),h!==-1){if(v=n.substring(h+1),n=n.substring(0,h),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let E=parseInt(v.substring(0,2),10);if(isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");if(a=f*E,v.length===4){if(E=parseInt(v.substring(2,4),10),isNaN(E.valueOf()))throw new Error("Wrong input string for conversion");c=f*E}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let f=new Number(`0${n.substring(l)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");i=f.valueOf(),o=n.substring(0,l)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,l!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*i;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*i;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=1e3*i;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let f=1;f<u.length;f++)switch(f){case 1:this.year=parseInt(u[f],10);break;case 2:this.month=parseInt(u[f],10);break;case 3:this.day=parseInt(u[f],10);break;case 4:this.hour=parseInt(u[f],10)+a;break;case 5:this.minute=parseInt(u[f],10)+c;break;case 6:this.second=parseInt(u[f],10);break;default:throw new Error("Wrong input string for conversion")}if(r===!1){let f=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=f.getUTCFullYear(),this.month=f.getUTCMonth(),this.day=f.getUTCDay(),this.hour=f.getUTCHours(),this.minute=f.getUTCMinutes(),this.second=f.getUTCSeconds(),this.millisecond=f.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let r=[];return r.push(Ne(this.year,4)),r.push(Ne(this.month,2)),r.push(Ne(this.day,2)),r.push(Ne(this.hour,2)),r.push(Ne(this.minute,2)),r.push(Ne(this.second,2)),this.millisecond!==0&&(r.push("."),r.push(Ne(this.millisecond,3))),r.push("Z"),r.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Jc=Ao;L.GeneralizedTime=Jc;Ao.NAME="GeneralizedTime";var Xc,So=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Xc=So;L.DATE=Xc;So.NAME="DATE";var Qc,ko=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Qc=ko;L.TimeOfDay=Qc;ko.NAME="TimeOfDay";var eu,Co=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};eu=Co;L.DateTime=eu;Co.NAME="DateTime";var tu,To=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};tu=To;L.Duration=tu;To.NAME="Duration";var ru,Io=class extends mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};ru=Io;L.TIME=ru;Io.NAME="TIME";function Ue(t,e="utf8"){let r=Mn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var nn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Uo=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var nu={get(t=globalThis){let e=t.crypto;if(e?.subtle==null)throw new Uo("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 e}};var qt=nu;async function ou(t){let e=await qt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await l0(e);return{privateKey:r[0],publicKey:r[1]}}async function iu(t,e){let r=await qt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await qt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function su(t,e,r){let n=await qt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return qt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,r instanceof Uint8Array?r:r.subarray())}async function l0(t){if(t.privateKey==null||t.publicKey==null)throw new xe("Private and public key are required");return Promise.all([qt.get().subtle.exportKey("jwk",t.privateKey),qt.get().subtle.exportKey("jwk",t.publicKey)])}function Ts(t){if(t.kty!=="RSA")throw new xe("invalid key type");if(t.n==null)throw new xe("invalid key modulus");return Y(t.n,"base64url").length*8}var kr=class{type="RSA";_key;_raw;_multihash;constructor(e,r){this._key=e,this._multihash=r}get raw(){return this._raw==null&&(this._raw=on.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return re.createV1(114,this._multihash)}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return su(this._key,r,e)}},sn=class{type="RSA";_key;_raw;publicKey;constructor(e,r){this._key=e,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=on.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}sign(e){return iu(this._key,e)}};var Ro=8192,Is=18;function au(t){let{result:e}=Cs(t),r=e.valueBlock.value;return{n:tt(r[1]),e:tt(r[2]),d:tt(r[3]),p:tt(r[4]),q:tt(r[5]),dp:tt(r[6]),dq:tt(r[7]),qi:tt(r[8]),kty:"RSA",alg:"RS256"}}function f0(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new xe("JWK was missing components");let r=new gt({value:[new pe({value:0}),pe.fromBigInt(rt(Y(t.n,"base64url"))),pe.fromBigInt(rt(Y(t.e,"base64url"))),pe.fromBigInt(rt(Y(t.d,"base64url"))),pe.fromBigInt(rt(Y(t.p,"base64url"))),pe.fromBigInt(rt(Y(t.q,"base64url"))),pe.fromBigInt(rt(Y(t.dp,"base64url"))),pe.fromBigInt(rt(Y(t.dq,"base64url"))),pe.fromBigInt(rt(Y(t.qi,"base64url")))]}).toBER();return new Uint8Array(r,0,r.byteLength)}function cu(t){let{result:e}=Cs(t),r=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:tt(r[0]),e:tt(r[1])}}function Ns(t){if(t.n==null||t.e==null)throw new xe("JWK was missing components");let r=new gt({value:[new gt({value:[new Ar({value:"1.2.840.113549.1.1.1"}),new Er]}),new Br({valueHex:new gt({value:[pe.fromBigInt(rt(Y(t.n,"base64url"))),pe.fromBigInt(rt(Y(t.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(r,0,r.byteLength)}function tt(t){let e=t.valueBlock.valueHexView;for(;e[0]===0;)e=e.subarray(1);return Ue(e,"base64url")}function rt(t){let e=[];return t.forEach(function(r){let n=r.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function uu(t){let e=au(t);return lu(e)}function Us(t){let e=cu(t);if(Ts(e)>Ro)throw new sr("Key size is too large");let r=br(Qe.encode({Type:se.RSA,Data:t})),n=Pe(Is,r);return new kr(e,n)}function lu(t){if(Ts(t)>Ro)throw new xe("Key size is too large");let e=hu(t),r=br(Qe.encode({Type:se.RSA,Data:Ns(e.publicKey)})),n=Pe(Is,r);return new sn(e.privateKey,new kr(e.publicKey,n))}async function fu(t){if(t>Ro)throw new xe("Key size is too large");let e=await ou(t),r=br(Qe.encode({Type:se.RSA,Data:Ns(e.publicKey)})),n=Pe(Is,r);return new sn(e.privateKey,new kr(e.publicKey,n))}function hu(t){if(t==null)throw new xe("Missing key parameter");return{privateKey:t,publicKey:{kty:t.kty,n:t.n,e:t.e}}}var _o=class extends gr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Ca(e);let n=Hr(r);if(this.iHash=e.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 o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return pr(this),this.iHash.update(e),this}digestInto(e){pr(this),dr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Rs=(t,e,r)=>new _o(t,e).update(r).digest();Rs.create=(t,e)=>new _o(t,e);function du(t){t.lowS!==void 0&&$e("lowS",t.lowS),t.prehash!==void 0&&$e("prehash",t.prehash)}function h0(t){let e=$r(t);Je(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:d0,hexToBytes:p0}=In,_s=class extends Error{constructor(e=""){super(e)}},wt={Err:_s,_tlv:{encode:(t,e)=>{let{Err:r}=wt;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Wt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Wt(o.length/2|128):"";return Wt(t)+i+o+e},decode(t,e){let{Err:r}=wt,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[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 l=e.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=wt;if(t<bt)throw new e("integer: negative integers are not allowed");let r=Wt(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=wt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return d0(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt,o=typeof t=="string"?p0(t):t;yr(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(t){let{_tlv:e,_int:r}=wt,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},bt=BigInt(0),ue=BigInt(1),Wy=BigInt(2),pu=BigInt(3),jy=BigInt(4);function g0(t){let e=h0(t),{Fp:r}=e,n=Lt(e.n,e.nBitLength),o=e.toBytes||((y,d,A)=>{let T=d.toAffine();return ht(Uint8Array.from([4]),r.toBytes(T.x),r.toBytes(T.y))}),i=e.fromBytes||(y=>{let d=y.subarray(1),A=r.fromBytes(d.subarray(0,r.BYTES)),T=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:A,y:T}});function s(y){let{a:d,b:A}=e,T=r.sqr(y),x=r.mul(T,y);return r.add(r.add(x,r.mul(y,d)),A)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return Pr(y,ue,e.n)}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:A,wrapPrivateKey:T,n:x}=e;if(d&&typeof y!="bigint"){if(Ut(y)&&(y=lt(y)),typeof y!="string"||!d.includes(y.length))throw new Error("invalid private key");y=y.padStart(A*2,"0")}let U;try{U=typeof y=="bigint"?y:ft(ne("private key",y,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof y)}return T&&(U=J(U,x)),Te("private key",U,ue,x),U}function l(y){if(!(y instanceof h))throw new Error("ProjectivePoint expected")}let u=Jt((y,d)=>{let{px:A,py:T,pz:x}=y;if(r.eql(x,r.ONE))return{x:A,y:T};let U=y.is0();d==null&&(d=U?r.ONE:r.inv(x));let F=r.mul(A,d),D=r.mul(T,d),R=r.mul(x,d);if(U)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:F,y:D}}),f=Jt(y=>{if(y.is0()){if(e.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:d,y:A}=y.toAffine();if(!r.isValid(d)||!r.isValid(A))throw new Error("bad point: x or y not FE");let T=r.sqr(A),x=s(d);if(!r.eql(T,x))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,A,T){if(this.px=d,this.py=A,this.pz=T,d==null||!r.isValid(d))throw new Error("x required");if(A==null||!r.isValid(A))throw new Error("y required");if(T==null||!r.isValid(T))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:A,y:T}=d||{};if(!d||!r.isValid(A)||!r.isValid(T))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=U=>r.eql(U,r.ZERO);return x(A)&&x(T)?h.ZERO:new h(A,T,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let A=r.invertBatch(d.map(T=>T.pz));return d.map((T,x)=>T.toAffine(A[x])).map(h.fromAffine)}static fromHex(d){let A=h.fromAffine(i(ne("pointHex",d)));return A.assertValidity(),A}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,A){return _n(h,n,d,A)}_setWindowSize(d){E.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.eql(r.mul(A,D),r.mul(U,x)),w=r.eql(r.mul(T,D),r.mul(F,x));return R&&w}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:A}=e,T=r.mul(A,pu),{px:x,py:U,pz:F}=this,D=r.ZERO,R=r.ZERO,w=r.ZERO,b=r.mul(x,x),M=r.mul(U,U),_=r.mul(F,F),I=r.mul(x,U);return I=r.add(I,I),w=r.mul(x,F),w=r.add(w,w),D=r.mul(d,w),R=r.mul(T,_),R=r.add(D,R),D=r.sub(M,R),R=r.add(M,R),R=r.mul(D,R),D=r.mul(I,D),w=r.mul(T,w),_=r.mul(d,_),I=r.sub(b,_),I=r.mul(d,I),I=r.add(I,w),w=r.add(b,b),b=r.add(w,b),b=r.add(b,_),b=r.mul(b,I),R=r.add(R,b),_=r.mul(U,F),_=r.add(_,_),b=r.mul(_,I),D=r.sub(D,b),w=r.mul(_,M),w=r.add(w,w),w=r.add(w,w),new h(D,R,w)}add(d){l(d);let{px:A,py:T,pz:x}=this,{px:U,py:F,pz:D}=d,R=r.ZERO,w=r.ZERO,b=r.ZERO,M=e.a,_=r.mul(e.b,pu),I=r.mul(A,U),K=r.mul(T,F),S=r.mul(x,D),k=r.add(A,T),m=r.add(U,F);k=r.mul(k,m),m=r.add(I,K),k=r.sub(k,m),m=r.add(A,x);let p=r.add(U,D);return m=r.mul(m,p),p=r.add(I,S),m=r.sub(m,p),p=r.add(T,x),R=r.add(F,D),p=r.mul(p,R),R=r.add(K,S),p=r.sub(p,R),b=r.mul(M,m),R=r.mul(_,S),b=r.add(R,b),R=r.sub(K,b),b=r.add(K,b),w=r.mul(R,b),K=r.add(I,I),K=r.add(K,I),S=r.mul(M,S),m=r.mul(_,m),K=r.add(K,S),S=r.sub(I,S),S=r.mul(M,S),m=r.add(m,S),I=r.mul(K,m),w=r.add(w,I),I=r.mul(p,m),R=r.mul(k,R),R=r.sub(R,I),I=r.mul(k,K),b=r.mul(p,b),b=r.add(b,I),new h(R,w,b)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return E.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:A,n:T}=e;Te("scalar",d,bt,T);let x=h.ZERO;if(d===bt)return x;if(this.is0()||d===ue)return this;if(!A||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:U,k1:F,k2neg:D,k2:R}=A.splitScalar(d),w=x,b=x,M=this;for(;F>bt||R>bt;)F&ue&&(w=w.add(M)),R&ue&&(b=b.add(M)),M=M.double(),F>>=ue,R>>=ue;return U&&(w=w.negate()),D&&(b=b.negate()),b=new h(r.mul(b.px,A.beta),b.py,b.pz),w.add(b)}multiply(d){let{endo:A,n:T}=e;Te("scalar",d,ue,T);let x,U;if(A){let{k1neg:F,k1:D,k2neg:R,k2:w}=A.splitScalar(d),{p:b,f:M}=this.wNAF(D),{p:_,f:I}=this.wNAF(w);b=E.constTimeNegate(F,b),_=E.constTimeNegate(R,_),_=new h(r.mul(_.px,A.beta),_.py,_.pz),x=b.add(_),U=M.add(I)}else{let{p:F,f:D}=this.wNAF(d);x=F,U=D}return h.normalizeZ([x,U])[0]}multiplyAndAddUnsafe(d,A,T){let x=h.BASE,U=(D,R)=>R===bt||R===ue||!D.equals(x)?D.multiplyUnsafe(R):D.multiply(R),F=U(this,A).add(U(d,T));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:A}=e;if(d===ue)return!0;if(A)return A(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:A}=e;return d===ue?this:A?A(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return $e("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return $e("isCompressed",d),lt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let v=e.nBitLength,E=Rn(h,e.endo?Math.ceil(v/2):v);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function m0(t){let e=$r(t);return Je(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function gu(t){let e=m0(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return J(S,n)}function a(S){return Nn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=g0({...e,toBytes(S,k,m){let p=k.toAffine(),B=r.toBytes(p.x),N=ht;return $e("isCompressed",m),m?N(Uint8Array.from([k.hasEvenY()?2:3]),B):N(Uint8Array.from([4]),B,r.toBytes(p.y))},fromBytes(S){let k=S.length,m=S[0],p=S.subarray(1);if(k===o&&(m===2||m===3)){let B=ft(p);if(!Pr(B,ue,r.ORDER))throw new Error("Point is not on curve");let N=u(B),O;try{O=r.sqrt(N)}catch(Z){let $=Z instanceof Error?": "+Z.message:"";throw new Error("Point is not on curve"+$)}let H=(O&ue)===ue;return(m&1)===1!==H&&(O=r.neg(O)),{x:B,y:O}}else if(k===i&&m===4){let B=r.fromBytes(p.subarray(0,r.BYTES)),N=r.fromBytes(p.subarray(r.BYTES,2*r.BYTES));return{x:B,y:N}}else{let B=o,N=i;throw new Error("invalid Point, expected length of "+B+", or uncompressed "+N+", got "+k)}}}),h=S=>lt(_t(S,e.nByteLength));function v(S){let k=n>>ue;return S>k}function E(S){return v(S)?s(-S):S}let y=(S,k,m)=>ft(S.slice(k,m));class d{constructor(k,m,p){this.r=k,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(k){let m=e.nByteLength;return k=ne("compactSignature",k,m*2),new d(y(k,0,m),y(k,m,2*m))}static fromDER(k){let{r:m,s:p}=wt.toSig(ne("DER",k));return new d(m,p)}assertValidity(){Te("r",this.r,ue,n),Te("s",this.s,ue,n)}addRecoveryBit(k){return new d(this.r,this.s,k)}recoverPublicKey(k){let{r:m,s:p,recovery:B}=this,N=D(ne("msgHash",k));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let O=B===2||B===3?m+e.n:m;if(O>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=B&1?"03":"02",z=c.fromHex(H+h(O)),Z=a(O),$=s(-N*Z),j=s(p*Z),X=c.BASE.multiplyAndAddUnsafe(z,$,j);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return jt(this.toDERHex())}toDERHex(){return wt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return jt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let A={isValidPrivateKey(S){try{return l(S),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let S=$i(e.n);return Ha(e.randomBytes(S),e.n)},precompute(S=8,k=c.BASE){return k._setWindowSize(S),k.multiply(BigInt(3)),k}};function T(S,k=!0){return c.fromPrivateKey(S).toRawBytes(k)}function x(S){let k=Ut(S),m=typeof S=="string",p=(k||m)&&S.length;return k?p===o||p===i:m?p===2*o||p===2*i:S instanceof c}function U(S,k,m=!0){if(x(S))throw new Error("first arg must be private key");if(!x(k))throw new Error("second arg must be public key");return c.fromHex(k).multiply(l(S)).toRawBytes(m)}let F=e.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let k=ft(S),m=S.length*8-e.nBitLength;return m>0?k>>BigInt(m):k},D=e.bits2int_modN||function(S){return s(F(S))},R=Kr(e.nBitLength);function w(S){return Te("num < 2^"+e.nBitLength,S,bt,R),_t(S,e.nByteLength)}function b(S,k,m=M){if(["recovered","canonical"].some(ce=>ce in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:N,prehash:O,extraEntropy:H}=m;N==null&&(N=!0),S=ne("msgHash",S),du(m),O&&(S=ne("prehashed msgHash",p(S)));let z=D(S),Z=l(k),$=[w(Z),w(z)];if(H!=null&&H!==!1){let ce=H===!0?B(r.BYTES):H;$.push(ne("extraEntropy",ce))}let j=ht(...$),X=z;function ae(ce){let fe=F(ce);if(!f(fe))return;let ye=a(fe),ke=c.BASE.multiply(fe).toAffine(),ve=s(ke.x);if(ve===bt)return;let Ye=s(ye*s(X+ve*Z));if(Ye===bt)return;let it=(ke.x===ve?0:2)|Number(ke.y&ue),Lr=Ye;return N&&v(Ye)&&(Lr=E(Ye),it^=1),new d(ve,Lr,it)}return{seed:j,k2sig:ae}}let M={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function I(S,k,m=M){let{seed:p,k2sig:B}=b(S,k,m),N=e;return Oi(N.hash.outputLen,N.nByteLength,N.hmac)(p,B)}c.BASE._setWindowSize(8);function K(S,k,m,p=_){let B=S;k=ne("msgHash",k),m=ne("publicKey",m);let{lowS:N,prehash:O,format:H}=p;if(du(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(H!==void 0&&H!=="compact"&&H!=="der")throw new Error("format must be compact or der");let z=typeof B=="string"||Ut(B),Z=!z&&!H&&typeof B=="object"&&B!==null&&typeof B.r=="bigint"&&typeof B.s=="bigint";if(!z&&!Z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let $,j;try{if(Z&&($=new d(B.r,B.s)),z){try{H!=="compact"&&($=d.fromDER(B))}catch(it){if(!(it instanceof wt.Err))throw it}!$&&H!=="der"&&($=d.fromCompact(B))}j=c.fromHex(m)}catch{return!1}if(!$||N&&$.hasHighS())return!1;O&&(k=e.hash(k));let{r:X,s:ae}=$,ce=D(k),fe=a(ae),ye=s(ce*fe),ke=s(X*fe),ve=c.BASE.multiplyAndAddUnsafe(j,ye,ke)?.toAffine();return ve?s(ve.x)===X:!1}return{CURVE:e,getPublicKey:T,getSharedSecret:U,sign:I,verify:K,ProjectivePoint:c,Signature:d,utils:A}}function y0(t){return{hash:t,hmac:(e,...r)=>Rs(t,e,Ri(...r)),randomBytes:Sn}}function mu(t,e){let r=n=>gu({...t,...y0(n)});return{...r(e),create:r}}var wu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),yu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),x0=BigInt(1),Ls=BigInt(2),xu=(t,e)=>(t+e/Ls)/e;function w0(t){let e=wu,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,f=te(u,r,e)*u%e,h=te(f,r,e)*u%e,v=te(h,Ls,e)*l%e,E=te(v,o,e)*v%e,y=te(E,i,e)*E%e,d=te(y,a,e)*y%e,A=te(d,c,e)*d%e,T=te(A,a,e)*y%e,x=te(T,r,e)*u%e,U=te(x,s,e)*E%e,F=te(U,n,e)*l%e,D=te(F,Ls,e);if(!Vs.eql(Vs.sqr(D),t))throw new Error("Cannot find square root");return D}var Vs=Lt(wu,void 0,void 0,{sqrt:w0}),rr=mu({a:BigInt(0),b:BigInt(7),Fp:Vs,n:yu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=yu,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-x0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=xu(i*t,e),c=xu(-n*t,e),l=J(t-a*r-c*o,e),u=J(-a*n-c*i,e),f=l>s,h=u>s;if(f&&(l=e-l),h&&(u=e-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},br),ox=BigInt(0);var ix=rr.ProjectivePoint;function an(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=Xe(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function bu(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}function vu(t,e,r){let n=zr.digest(r instanceof Uint8Array?r:r.subarray());if(bu(n))return n.then(({digest:o})=>rr.verify(e,o,t)).catch(o=>{throw new nn(String(o))});try{return rr.verify(e,n.digest,t)}catch(o){throw new nn(String(o))}}var Lo=class{type="secp256k1";raw;_key;constructor(e){this._key=Bu(e),this.raw=Eu(this._key)}toMultihash(){return ct.digest(xr(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r){return vu(this._key,r,e)}};function Ds(t){return new Lo(t)}function Eu(t){return rr.ProjectivePoint.fromHex(t).toRawBytes(!0)}function Bu(t){try{return rr.ProjectivePoint.fromHex(t),t}catch(e){throw new sr(String(e))}}function Au(t){let{Type:e,Data:r}=Qe.decode(t),n=r??new Uint8Array;switch(e){case se.RSA:return Us(n);case se.Ed25519:return Yi(n);case se.secp256k1:return Ds(n);default:throw new cr}}function Vo(t){let{Type:e,Data:r}=Qe.decode(t.digest),n=r??new Uint8Array;switch(e){case se.Ed25519:return Yi(n);case se.secp256k1:return Ds(n);default:throw new cr}}function xr(t){return Qe.encode({Type:se[t.type],Data:t.raw})}var vt="/",Su=new TextEncoder().encode(vt),Do=Su[0],cn=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=Y(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Do)throw new Error("Invalid key")}toString(e="utf8"){return Ue(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(vt))}static random(){return new t(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Su),this._buf[0]!==Do){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Do,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Do;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(vt).slice(1)}type(){return b0(this.baseNamespace())}name(){return v0(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(vt)||(e+=vt),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(vt):new t(e.slice(0,-1).join(vt))}child(e){return this.toString()===vt?e:e.toString()===vt?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...E0(e.map(r=>r.namespaces()))])}};function b0(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function v0(t){let e=t.split(":");return e[e.length-1]}function E0(t){return[].concat(...t)}var Ml=Vr(Fo(),1);var Mo=class extends Error{static name="SignatureCreationError";constructor(e="Record signature creation failed"){super(e),this.name="SignatureCreationError"}},Ze=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},Oo=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},nr=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},Ho=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},un=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},Po=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},ln=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var ge;(function(t){let e;(function(o){o.EOL="EOL"})(e=t.ValidityType||(t.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Wr(r)}(e=t.ValidityType||(t.ValidityType={}));let n;t.codec=()=>(n==null&&(n=Ot((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),t.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=t.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),t.encode=o=>Mt(o,t.codec()),t.decode=(o,i)=>Ft(o,t.codec(),i)})(ge||(ge={}));var B0=["string","number","bigint","symbol"],A0=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function ku(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(B0.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(S0(t))return"Buffer";let r=k0(t);return r||"Object"}function S0(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function k0(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(A0.includes(e))return e}var g=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var V=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Cr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",C0=new TextDecoder,T0=new TextEncoder;function Ko(t){return Cr&&globalThis.Buffer.isBuffer(t)}function Ms(t){return t instanceof Uint8Array?Ko(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Nu=Cr?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Tu(t,e,r):(t,e,r)=>r-e>64?C0.decode(t.subarray(e,r)):Tu(t,e,r),Uu=Cr?t=>t.length>64?globalThis.Buffer.from(t):Cu(t):t=>t.length>64?T0.encode(t):Cu(t),nt=t=>Uint8Array.from(t),Tr=Cr?(t,e,r)=>Ko(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Ru=Cr?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ms(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},_u=Cr?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Lu(t,e){if(Ko(t)&&Ko(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function Cu(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}function Tu(t,e,r){let n=[];for(;e<r;){let o=t[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=r){let a,c,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=t[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=t[e+1],c=t[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=t[e+1],c=t[e+2],l=t[e+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return I0(n)}var Iu=4096;function I0(t){let e=t.length;if(e<=Iu)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Iu));return r}var N0=256,fn=class{constructor(e=N0){this.chunkSize=e,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(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,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)}e.length<64&&e.length<this.chunkSize?(r=_u(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Tr(n,0,this.cursor)}else r=Ru(this.chunks,this.cursor);return e&&this.reset(),r}};var P="CBOR decode error:",Os="CBOR encode error:",hn=[];hn[23]=1;hn[24]=2;hn[25]=3;hn[26]=5;hn[27]=9;function Et(t,e,r){if(t.length-e<r)throw new Error(`${P} not enough data for type`)}var le=[24,256,65536,4294967296,BigInt("18446744073709551616")];function _e(t,e,r){Et(t,e,1);let n=t[e];if(r.strict===!0&&n<le[0])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Le(t,e,r){Et(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<le[1])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function Ve(t,e,r){Et(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<le[2])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return n}function De(t,e,r){Et(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<le[3])throw new Error(`${P} 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(`${P} integers outside of the safe integer range are not supported`)}function Vu(t,e,r,n){return new V(g.uint,_e(t,e+1,n),2)}function Du(t,e,r,n){return new V(g.uint,Le(t,e+1,n),3)}function Fu(t,e,r,n){return new V(g.uint,Ve(t,e+1,n),5)}function Mu(t,e,r,n){return new V(g.uint,De(t,e+1,n),9)}function Me(t,e){return me(t,0,e.value)}function me(t,e,r){if(r<le[0]){let n=Number(r);t.push([e|n])}else if(r<le[1]){let n=Number(r);t.push([e|24,n])}else if(r<le[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<le[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<le[4]){let o=[e|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,t.push(o)}else throw new Error(`${P} encountered BigInt larger than allowable range`)}}Me.encodedSize=function(e){return me.encodedSize(e.value)};me.encodedSize=function(e){return e<le[0]?1:e<le[1]?2:e<le[2]?3:e<le[3]?5:9};Me.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Ou(t,e,r,n){return new V(g.negint,-1-_e(t,e+1,n),2)}function Hu(t,e,r,n){return new V(g.negint,-1-Le(t,e+1,n),3)}function Pu(t,e,r,n){return new V(g.negint,-1-Ve(t,e+1,n),5)}var Hs=BigInt(-1),Ku=BigInt(1);function $u(t,e,r,n){let o=De(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new V(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${P} integers outside of the safe integer range are not supported`);return new V(g.negint,Hs-BigInt(o),9)}function $o(t,e){let r=e.value,n=typeof r=="bigint"?r*Hs-Ku:r*-1-1;me(t,e.type.majorEncoded,n)}$o.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*Hs-Ku:r*-1-1;return n<le[0]?1:n<le[1]?2:n<le[2]?3:n<le[3]?5:9};$o.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function dn(t,e,r,n){Et(t,e,r+n);let o=Tr(t,e+r,e+r+n);return new V(g.bytes,o,r+n)}function qu(t,e,r,n){return dn(t,e,1,r)}function zu(t,e,r,n){return dn(t,e,2,_e(t,e+1,n))}function Gu(t,e,r,n){return dn(t,e,3,Le(t,e+1,n))}function Zu(t,e,r,n){return dn(t,e,5,Ve(t,e+1,n))}function Wu(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer bytes lengths not supported`);return dn(t,e,9,o)}function qo(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===g.string?Uu(t.value):t.value),t.encodedBytes}function Ir(t,e){let r=qo(e);me(t,e.type.majorEncoded,r.length),t.push(r)}Ir.encodedSize=function(e){let r=qo(e);return me.encodedSize(r.length)+r.length};Ir.compareTokens=function(e,r){return R0(qo(e),qo(r))};function R0(t,e){return t.length<e.length?-1:t.length>e.length?1:Lu(t,e)}function pn(t,e,r,n,o){let i=r+n;Et(t,e,i);let s=new V(g.string,Nu(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Tr(t,e+r,e+i)),s}function ju(t,e,r,n){return pn(t,e,1,r,n)}function Yu(t,e,r,n){return pn(t,e,2,_e(t,e+1,n),n)}function Ju(t,e,r,n){return pn(t,e,3,Le(t,e+1,n),n)}function Xu(t,e,r,n){return pn(t,e,5,Ve(t,e+1,n),n)}function Qu(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer string lengths not supported`);return pn(t,e,9,o,n)}var el=Ir;function Nr(t,e,r,n){return new V(g.array,n,r)}function tl(t,e,r,n){return Nr(t,e,1,r)}function rl(t,e,r,n){return Nr(t,e,2,_e(t,e+1,n))}function nl(t,e,r,n){return Nr(t,e,3,Le(t,e+1,n))}function ol(t,e,r,n){return Nr(t,e,5,Ve(t,e+1,n))}function il(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer array lengths not supported`);return Nr(t,e,9,o)}function sl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return Nr(t,e,1,1/0)}function zo(t,e){me(t,g.array.majorEncoded,e.value)}zo.compareTokens=Me.compareTokens;zo.encodedSize=function(e){return me.encodedSize(e.value)};function Ur(t,e,r,n){return new V(g.map,n,r)}function al(t,e,r,n){return Ur(t,e,1,r)}function cl(t,e,r,n){return Ur(t,e,2,_e(t,e+1,n))}function ul(t,e,r,n){return Ur(t,e,3,Le(t,e+1,n))}function ll(t,e,r,n){return Ur(t,e,5,Ve(t,e+1,n))}function fl(t,e,r,n){let o=De(t,e+1,n);if(typeof o=="bigint")throw new Error(`${P} 64-bit integer map lengths not supported`);return Ur(t,e,9,o)}function hl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return Ur(t,e,1,1/0)}function Go(t,e){me(t,g.map.majorEncoded,e.value)}Go.compareTokens=Me.compareTokens;Go.encodedSize=function(e){return me.encodedSize(e.value)};function dl(t,e,r,n){return new V(g.tag,r,1)}function pl(t,e,r,n){return new V(g.tag,_e(t,e+1,n),2)}function gl(t,e,r,n){return new V(g.tag,Le(t,e+1,n),3)}function ml(t,e,r,n){return new V(g.tag,Ve(t,e+1,n),5)}function yl(t,e,r,n){return new V(g.tag,De(t,e+1,n),9)}function Zo(t,e){me(t,g.tag.majorEncoded,e.value)}Zo.compareTokens=Me.compareTokens;Zo.encodedSize=function(e){return me.encodedSize(e.value)};var M0=20,O0=21,H0=22,P0=23;function xl(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${P} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new V(g.null,null,1):new V(g.undefined,void 0,1)}function wl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${P} indefinite length items not allowed`);return new V(g.break,void 0,1)}function Ps(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${P} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${P} Infinity values are not supported`)}return new V(g.float,t,e)}function bl(t,e,r,n){return Ps(Ks(t,e+1),3,n)}function vl(t,e,r,n){return Ps($s(t,e+1),5,n)}function El(t,e,r,n){return Ps(kl(t,e+1),9,n)}function Wo(t,e,r){let n=e.value;if(n===!1)t.push([g.float.majorEncoded|M0]);else if(n===!0)t.push([g.float.majorEncoded|O0]);else if(n===null)t.push([g.float.majorEncoded|H0]);else if(n===void 0)t.push([g.float.majorEncoded|P0]);else{let o,i=!1;(!r||r.float64!==!0)&&(Al(n),o=Ks(We,1),n===o||Number.isNaN(n)?(We[0]=249,t.push(We.slice(0,3)),i=!0):(Sl(n),o=$s(We,1),n===o&&(We[0]=250,t.push(We.slice(0,5)),i=!0))),i||(K0(n),o=kl(We,1),We[0]=251,t.push(We.slice(0,9)))}}Wo.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Al(n);let o=Ks(We,1);if(n===o||Number.isNaN(n))return 3;if(Sl(n),o=$s(We,1),n===o)return 5}return 9};var Bl=new ArrayBuffer(9),Oe=new DataView(Bl,1),We=new Uint8Array(Bl,0);function Al(t){if(t===1/0)Oe.setUint16(0,31744,!1);else if(t===-1/0)Oe.setUint16(0,64512,!1);else if(Number.isNaN(t))Oe.setUint16(0,32256,!1);else{Oe.setFloat32(0,t);let e=Oe.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Oe.setUint16(0,31744,!1);else if(r===0)Oe.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Oe.setUint16(0,0):o<-14?Oe.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Oe.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ks(t,e){if(t.length-e<2)throw new Error(`${P} not enough data for float16`);let r=(t[e]<<8)+t[e+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 Sl(t){Oe.setFloat32(0,t,!1)}function $s(t,e){if(t.length-e<4)throw new Error(`${P} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function K0(t){Oe.setFloat64(0,t,!1)}function kl(t,e){if(t.length-e<8)throw new Error(`${P} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Wo.compareTokens=Me.compareTokens;function W(t,e,r){throw new Error(`${P} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function jo(t){return()=>{throw new Error(`${P} ${t}`)}}var C=[];for(let t=0;t<=23;t++)C[t]=W;C[24]=Vu;C[25]=Du;C[26]=Fu;C[27]=Mu;C[28]=W;C[29]=W;C[30]=W;C[31]=W;for(let t=32;t<=55;t++)C[t]=W;C[56]=Ou;C[57]=Hu;C[58]=Pu;C[59]=$u;C[60]=W;C[61]=W;C[62]=W;C[63]=W;for(let t=64;t<=87;t++)C[t]=qu;C[88]=zu;C[89]=Gu;C[90]=Zu;C[91]=Wu;C[92]=W;C[93]=W;C[94]=W;C[95]=jo("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)C[t]=ju;C[120]=Yu;C[121]=Ju;C[122]=Xu;C[123]=Qu;C[124]=W;C[125]=W;C[126]=W;C[127]=jo("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)C[t]=tl;C[152]=rl;C[153]=nl;C[154]=ol;C[155]=il;C[156]=W;C[157]=W;C[158]=W;C[159]=sl;for(let t=160;t<=183;t++)C[t]=al;C[184]=cl;C[185]=ul;C[186]=ll;C[187]=fl;C[188]=W;C[189]=W;C[190]=W;C[191]=hl;for(let t=192;t<=215;t++)C[t]=dl;C[216]=pl;C[217]=gl;C[218]=ml;C[219]=yl;C[220]=W;C[221]=W;C[222]=W;C[223]=W;for(let t=224;t<=243;t++)C[t]=jo("simple values are not supported");C[244]=W;C[245]=W;C[246]=W;C[247]=xl;C[248]=jo("simple values are not supported");C[249]=bl;C[250]=vl;C[251]=El;C[252]=W;C[253]=W;C[254]=W;C[255]=wl;var je=[];for(let t=0;t<24;t++)je[t]=new V(g.uint,t,1);for(let t=-1;t>=-24;t--)je[31-t]=new V(g.negint,t,1);je[64]=new V(g.bytes,new Uint8Array(0),1);je[96]=new V(g.string,"",1);je[128]=new V(g.array,0,1);je[160]=new V(g.map,0,1);je[244]=new V(g.false,!1,1);je[245]=new V(g.true,!0,1);je[246]=new V(g.null,null,1);function Cl(t){switch(t.type){case g.false:return nt([244]);case g.true:return nt([245]);case g.null:return nt([246]);case g.bytes:return t.value.length?void 0:nt([64]);case g.string:return t.value===""?nt([96]):void 0;case g.array:return t.value===0?nt([128]):void 0;case g.map:return t.value===0?nt([160]):void 0;case g.uint:return t.value<24?nt([Number(t.value)]):void 0;case g.negint:if(t.value>=-24)return nt([31-Number(t.value)])}}var q0={float64:!1,mapSorter:Z0,quickEncodeToken:Cl};function z0(){let t=[];return t[g.uint.major]=Me,t[g.negint.major]=$o,t[g.bytes.major]=Ir,t[g.string.major]=el,t[g.array.major]=zo,t[g.map.major]=Go,t[g.tag.major]=Zo,t[g.float.major]=Wo,t}var Tl=z0(),qs=new fn,Jo=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${Os} object contains circular references`);return new t(r,e)}},zt={null:new V(g.null,null),undefined:new V(g.undefined,void 0),true:new V(g.true,!0),false:new V(g.false,!1),emptyArray:new V(g.array,0),emptyMap:new V(g.map,0)},Gt={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new V(g.float,t):t>=0?new V(g.uint,t):new V(g.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new V(g.uint,t):new V(g.negint,t)},Uint8Array(t,e,r,n){return new V(g.bytes,t)},string(t,e,r,n){return new V(g.string,t)},boolean(t,e,r,n){return t?zt.true:zt.false},null(t,e,r,n){return zt.null},undefined(t,e,r,n){return zt.undefined},ArrayBuffer(t,e,r,n){return new V(g.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new V(g.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[zt.emptyArray,new V(g.break)]:zt.emptyArray;n=Jo.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=Yo(s,r,n);return r.addBreakTokens?[new V(g.array,t.length),o,new V(g.break)]:[new V(g.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length;if(!s)return r.addBreakTokens===!0?[zt.emptyMap,new V(g.break)]:zt.emptyMap;n=Jo.createCheck(n,t);let a=[],c=0;for(let l of i)a[c++]=[Yo(l,r,n),Yo(o?t.get(l):t[l],r,n)];return G0(a,r),r.addBreakTokens?[new V(g.map,s),a,new V(g.break)]:[new V(g.map,s),a]}};Gt.Map=Gt.Object;Gt.Buffer=Gt.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Gt[`${t}Array`]=Gt.DataView;function Yo(t,e={},r){let n=ku(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||Gt[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=Gt[n];if(!i)throw new Error(`${Os} unsupported type: ${n}`);return i(t,n,e,r)}function G0(t,e){e.mapSorter&&t.sort(e.mapSorter)}function Z0(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Tl[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Il(t,e,r,n){if(Array.isArray(e))for(let o of e)Il(t,o,r,n);else r[e.type.major](t,e,n)}function W0(t,e,r){let n=Yo(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new fn(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ms(a.chunks[0])}}return qs.reset(),Il(qs,n,e,r),qs.toBytes(!0)}function zs(t,e){return e=Object.assign({},q0,e),W0(t,Tl,e)}var j0={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Xo=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=je[e];if(r===void 0){let n=C[e];if(!n)throw new Error(`${P} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},gn=Symbol.for("DONE"),Qo=Symbol.for("BREAK");function Y0(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Rr(e,r);if(i===Qo){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed array`)}if(i===gn)throw new Error(`${P} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function J0(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<t.value;s++){let a=Rr(e,r);if(a===Qo){if(t.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed map`)}if(a===gn)throw new Error(`${P} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${P} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${P} found repeat map key "${a}"`);let c=Rr(e,r);if(c===gn)throw new Error(`${P} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Rr(t,e){if(t.done())return gn;let r=t.next();if(r.type===g.break)return Qo;if(r.type.terminal)return r.value;if(r.type===g.array)return Y0(r,t,e);if(r.type===g.map)return J0(r,t,e);if(r.type===g.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Rr(t,e);return e.tags[r.value](n)}throw new Error(`${P} tag not supported (${r.value})`)}throw new Error("unsupported")}function Nl(t,e){if(!(t instanceof Uint8Array))throw new Error(`${P} data to decode must be a Uint8Array`);e=Object.assign({},j0,e);let r=e.tokenizer||new Xo(t,e),n=Rr(r,e);if(n===gn)throw new Error(`${P} did not find any content to decode`);if(n===Qo)throw new Error(`${P} got unexpected break`);return[n,t.subarray(r.pos())]}function Gs(t,e){let[r,n]=Nl(t,e);if(n.length>0)throw new Error(`${P} too many terminals, data makes no sense`);return r}var Q0=Ct("ipns:utils"),Ul=Y("/ipns/"),ep=114,tp=0,rp=18;function Rl(t){let e;if(t.pubKey!=null)try{e=Au(t.pubKey)}catch(r){throw Q0.error(r),r}if(e!=null)return e}function _l(t,e,r){let n=Y(e);return an([t,r,n])}function ti(t){let e=Y("ipns-signature:");return an([e,t])}function Zs(t){return"signatureV1"in t?ge.encode({value:Y(t.value),signatureV1:t.signatureV1,validityType:t.validityType,validity:Y(t.validity),sequence:t.sequence,ttl:t.ttl,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data}):ge.encode({pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data})}function ot(t){let e=ge.decode(t);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new Ze("Missing data or signatureV2");let r=Dl(e.data),n=np(r.Value),o=Ue(r.Validity);if(e.value!=null&&e.signatureV1!=null)return op(e),{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:ge.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function _r(t){return an([Ul,t.bytes])}function Ll(t){let e=at(t.slice(Ul.length));if(!ei(e,tp)&&!ei(e,rp))throw new ar("Multihash in IPNS key was not identity or sha2-256");return e}function Vl(t,e,r,n,o){let i;if(e===ge.ValidityType.EOL)i=0;else throw new nr("The validity type is unsupported");return zs({Value:t,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Dl(t){let e=Gs(t);if(e.ValidityType===0)e.ValidityType=ge.ValidityType.EOL;else throw new nr("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function np(t){let e=Ue(t).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${re.decode(t).toV1().toString()}`}catch{}try{return`/ipfs/${re.parse(e).toV1().toString()}`}catch{}throw new un("Value must be a valid content path starting with /")}function Fl(t){if(t!=null){let e=ap(t);if(e!=null)return e.code===ep?`/ipns/${e.toString(He)}`:`/ipfs/${e.toV1().toString()}`;if(ip(t))return`/ipns/${He.encode(t.bytes)}`;let r=t.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new un("Value must be a valid content path starting with /")}function op(t){if(t.data==null)throw new Po("Record data is missing");let e=Dl(t.data);if(!he(e.Value,t.value??new Uint8Array(0)))throw new Ze('Field "value" did not match between protobuf and CBOR');if(!he(e.Validity,t.validity??new Uint8Array(0)))throw new Ze('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==t.validityType)throw new Ze('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==t.sequence)throw new Ze('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==t.ttl)throw new Ze('Field "ttl" did not match between protobuf and CBOR')}function ip(t){return t.bytes instanceof Uint8Array}function sp(t){return typeof t?.toCID=="function"}function ap(t){if(sp(t))return t.toCID();try{return re.parse(t)}catch{}return re.asCID(t)}function ei(t,e){return t.code===e}var cp=Ct("ipns"),Ol=60*60*1e9,up="/ipns/",xb=up.length,Hl={v1Compatible:!0,ttlNs:Ol};async function Pl(t,e,r,n,o=Hl){let i=new Ml.default(Date.now()+Number(n)),s=ge.ValidityType.EOL,a=BigInt(o.ttlNs??Ol);return lp(t,e,r,s,i.toString(),a,o)}var lp=async(t,e,r,n,o,i,s=Hl)=>{r=BigInt(r);let a=Y(o),c=Fl(e),l=Y(c),u=Vl(l,n,a,r,i),f=ti(u),h=await t.sign(f),v;if(t.type==="RSA"&&(v=xr(t.publicKey)),s.v1Compatible===!0){let E=await fp(t,l,n,a),y={value:c,signatureV1:E,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return v!=null&&(y.pubKey=v),y}else{let E={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:h,data:u};return v!=null&&(E.pubKey=v),E}},fp=async(t,e,r,n)=>{try{let o=_l(e,r,n);return await t.sign(o)}catch(o){throw cp.error("record signature creation failed",o),new Mo("Record signature creation failed")}};var Ws=Vr(Fo(),1);function ri(t,e){let r=e.map((n,o)=>({record:ot(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===ge.ValidityType.EOL&&o.record.validityType===ge.ValidityType.EOL){let a=Ws.default.fromString(n.record.validity).toDate(),c=Ws.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var Kl=Vr(Fo(),1);var ni=Ct("ipns:validator"),hp=1024*10,dp=async(t,e)=>{let r=ot(e),n;try{let o=ti(r.data);n=await t.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw ni.error("record signature verification failed"),new Ze("Record signature verification failed");if(r.validityType===ge.ValidityType.EOL){if(Kl.default.fromString(r.validity).toDate().getTime()<Date.now())throw ni.error("record has expired"),new Oo("record has expired")}else if(r.validityType!=null)throw ni.error("the validity type is unsupported"),new nr("The validity type is unsupported");ni("ipns record for %s is valid",r.value)};async function oi(t,e){if(e.byteLength>hp)throw new Ho("The record is too large");let r=Ll(t),n;ei(r,0)&&(n=Vo(r));let o=ot(e),i=Rl(o)??n;if(i==null)throw new ln("Could not extract public key from IPNS record or routing key");let s=_r(i.toMultihash());if(!he(t,s))throw new ln("Embedded public key did not match routing key");await dp(i,e)}var Se=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var $l=Symbol.for("nodejs.util.inspect.custom"),pp=114,mn=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[xi]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return re.createV1(pp,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return he(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return he(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[$l](){return`PeerId(${this.toString()})`}},ii=class extends mn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},si=class extends mn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},ai=class extends mn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},gp=2336,ci=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ct.digest(Y(this.url))}[$l](){return`PeerId(${this.url})`}[xi]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return re.createV1(gp,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=Ue(e)),e.toString()===this.toString())}};function ql(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=at(Q.decode(`z${t}`));else{if(e==null)throw new xe('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=at(e.decode(t))}return mp(r)}function mp(t){if(xp(t))return new ii({multihash:t});if(yp(t))try{let e=Vo(t);if(e.type==="Ed25519")return new si({multihash:t,publicKey:e});if(e.type==="secp256k1")return new ai({multihash:t,publicKey:e})}catch{let r=Ue(t.digest);return new ci(new URL(r))}throw new ar("Supplied PeerID Multihash is invalid")}function yp(t){return t.code===ct.code}function xp(t){return t.code===zr.code}var vp=Vr(Gl(),1);var Bt;(function(t){t[t.A=1]="A",t[t.CNAME=5]="CNAME",t[t.TXT=16]="TXT",t[t.AAAA=28]="AAAA"})(Bt||(Bt={}));var ui=class extends Error{static name="DNSLinkNotFoundError";constructor(e="DNSLink not found"){super(e),this.name="DNSLinkNotFoundError"}},li=class extends Error{static name="RecordsFailedValidationError";constructor(e="Records failed validation"){super(e),this.name="RecordsFailedValidationError"}},fi=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(e="Unsupported multibase prefix"){super(e),this.name="UnsupportedMultibasePrefixError"}},hi=class extends Error{static name="UnsupportedMultihashCodecError";constructor(e="Unsupported multihash codec"){super(e),this.name="UnsupportedMultihashCodecError"}},di=class extends Error{static name="InvalidValueError";constructor(e="Invalid value"){super(e),this.name="InvalidValueError"}};var Ep=32;async function Zl(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",t);let s=((await r.query(t,{...o,types:[Bt.TXT]}))?.Answer??[]).sort((l,u)=>l.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,t);for(let l of s)try{let u=l.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",l.name,u),u=u.replace("dnslink=","");let[,f,h,...v]=u.split("/");if(f==="ipfs")try{return{value:`/ipfs/${re.parse(h)}${v.length>0?`/${v.join("/")}`:""}`,answer:l}}catch{}else if(f==="ipns"){try{return{value:`/ipns/${ql(h)}${v.length>0?`/${v.join("/")}`:""}`,answer:l}}catch{}return await pi(h,e-1,r,n,o)}else{if(f==="dnslink")return await pi(h,e-1,r,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',f,t);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",t,l.data,u)}n("no DNSLink records found for %s, falling back to CNAME",t);let c=((await r.query(t,{...o,types:[Bt.CNAME]}))?.Answer??[]).sort((l,u)=>l.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,t);for(let l of c)try{return await pi(l.data,e-1,r,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",t,l.data,u)}throw new ui(`No DNSLink records found for domain: ${t}`)}async function pi(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");t.startsWith("_dnslink.")||(t=`_dnslink.${t}`);try{return await Zl(t,e,r,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ENODATA"&&i.name!=="DNSLinkNotFoundError"&&i.name!=="NotFoundError")throw i;return t.startsWith("_dnslink.")?t=t.replace("_dnslink.",""):t=`_dnslink.${t}`,Zl(t,e,r,n,o)}}async function Wl(t,e,r,n={}){return pi(t,n.maxRecursiveDepth??Ep,e,r,n)}var js=class{routing;constructor(e){this.routing=e}async put(e,r,n={}){try{await this.routing.put(e,r,n)}catch(o){n.onProgress?.(new Se("ipns:routing:helia:error",o))}}async get(e,r={}){try{return await this.routing.get(e,r)}catch(n){r.onProgress?.(new Se("ipns:routing:helia:error",n))}throw new Error("Not found")}};function jl(t){return new js(t)}var yn;(function(t){let e;t.codec=()=>(e==null&&(e=Ot((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Ji(0),value:Ji(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Mt(r,t.codec()),t.decode=(r,n)=>Ft(r,t.codec(),n)})(yn||(yn={}));function Yl(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0"),o=String(t.getUTCHours()).padStart(2,"0"),i=String(t.getUTCMinutes()).padStart(2,"0"),s=String(t.getUTCSeconds()).padStart(2,"0"),a=t.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function Jl(t){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),l=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,l))}var ir=class t{key;value;timeReceived;constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=r,this.timeReceived=n}serialize(){return yn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:Yl(this.timeReceived)}}static deserialize(e){let r=yn.decode(e);return new t(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(e){let r=Jl(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new t(e.key,e.value,r)}};var Xl;(function(t){t[t.SEND_QUERY=0]="SEND_QUERY",t[t.PEER_RESPONSE=1]="PEER_RESPONSE",t[t.FINAL_PEER=2]="FINAL_PEER",t[t.QUERY_ERROR=3]="QUERY_ERROR",t[t.PROVIDER=4]="PROVIDER",t[t.VALUE=5]="VALUE",t[t.ADD_PEER=6]="ADD_PEER",t[t.DIAL_PEER=7]="DIAL_PEER"})(Xl||(Xl={}));function gi(t){return new cn("/dht/record/"+Ue(t,"base32"),!1)}function Ql(t){return{async put(e,r,n={}){try{let o=gi(e);try{let s=await t.get(o),a=ir.deserialize(s);if(he(a.value,r))return}catch(s){if(s.name!=="NotFoundError")throw s}let i=new ir(e,r,new Date);n.onProgress?.(new Se("ipns:routing:datastore:put")),await t.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new Se("ipns:routing:datastore:error",o)),o}},async get(e,r={}){try{let n=gi(e);r.onProgress?.(new Se("ipns:routing:datastore:get"));let o=await t.get(n,r),i=ir.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw r.onProgress?.(new Se("ipns:routing:datastore:error",n)),n}},async has(e,r={}){let n=gi(e);return t.has(n,r)},async delete(e,r){let n=gi(e);return t.delete(n,r)}}}function Ys(t,e){return t.code===e}var At=Ct("helia:ipns"),kp=60*1e3,Qs=60*kp,Cp=24*Qs,Js=23*Qs,Tp=BigInt(Qs)*1000000n,ef={[He.prefix]:He,[Q.prefix]:Q},Xs=class{routers;localStore;timeout;dns;log;constructor(e,r=[]){this.routers=[jl(e.routing),...r],this.localStore=Ql(e.datastore),this.dns=e.dns,this.log=e.logger.forComponent("helia:ipns")}async publish(e,r,n={}){try{let o=1n,i=_r(e.publicKey.toMultihash());if(await this.localStore.has(i,n)){let{record:c}=await this.localStore.get(i,n);o=ot(c).sequence+1n}let s=await Pl(e,r,o,n.lifetime??Cp,n),a=Zs(s);return await this.localStore.put(i,a,n),n.offline!==!0&&await Promise.all(this.routers.map(async c=>{await c.put(i,a,n)})),s}catch(o){throw n.onProgress?.(new Se("ipns:publish:error",o)),o}}async resolve(e,r={}){let n=ca(e)?e.toMultihash():e,o=_r(n),i=await this.#t(o,r);return{...await this.#e(i.value,r),record:i}}async resolveDNSLink(e,r={}){let n=await Wl(e,this.dns,this.log,r);return{...await this.#e(n.value,r),answer:n.answer}}republish(e={}){if(this.timeout!=null)throw new Error("Republish is already running");e.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function r(){let n=Date.now();e.onProgress?.(new Se("ipns:republish:start"));let i=Date.now()-n,s=Js-i;s<0&&(s=e.interval??Js),setTimeout(()=>{r().catch(a=>{At.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{r().catch(n=>{At.error("error republishing",n)})},e.interval??Js)}async#e(e,r={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=Q.decode(`z${i}`);else if(ef[s]!=null)a=ef[s].decode(i);else throw new fi(`Unsupported multibase prefix "${s}"`);let c;try{c=at(a)}catch{c=re.decode(a).multihash}if(!Ys(c,0)&&!Ys(c,18))throw new hi(`Unsupported multihash codec "${c.code}"`);let{cid:l}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:l,path:u}}else if(o==="ipfs"){let i=re.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){At.error("error parsing ipfs path",o)}throw At.error("invalid ipfs path %s",e),new di("Invalid value")}async#t(e,r={}){let n=[];if(await this.localStore.has(e,r))if(At("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(e,r);this.log("record retrieved from cache"),await oi(e,a),this.log("record was valid");let l=ot(a),u=Number((l.ttl??Tp)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),l;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),l;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(e,r)}else At("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new Dr("Record was not present in the cache or has expired");At("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(e,{...r,validate:!1})}catch(l){At.error("error finding IPNS record",l);return}try{await oi(e,c),n.push(c)}catch(l){i++,At.error("error finding IPNS record",l)}})),n.length===0)throw i>0?new li(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new Dr("Could not find record for routing key");let s=n[ri(e,n)];return await this.localStore.put(e,s,r),ot(s)}};function Ip(t,{routers:e=[]}={}){return new Xs(t,e)}return gf(Np);})();
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
|
10
10
|
pvtsutils/build/index.js:
|
|
@@ -51,9 +51,6 @@ pvtsutils/build/index.js:
|
|
|
51
51
|
@noble/curves/esm/ed25519.js:
|
|
52
52
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
53
53
|
|
|
54
|
-
@noble/hashes/esm/utils.js:
|
|
55
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
56
|
-
|
|
57
54
|
pvutils/build/utils.es.js:
|
|
58
55
|
(*!
|
|
59
56
|
Copyright (c) Peculiar Ventures, LLC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/ipns",
|
|
3
|
-
"version": "8.0.1-
|
|
3
|
+
"version": "8.0.1-e45e1de",
|
|
4
4
|
"description": "An implementation of IPNS for Helia",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/ipns#readme",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"test:electron-main": "aegir test -t electron-main"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@helia/interface": "5.1.0-
|
|
82
|
+
"@helia/interface": "5.1.0-e45e1de",
|
|
83
83
|
"@libp2p/interface": "^2.2.1",
|
|
84
84
|
"@libp2p/kad-dht": "^14.1.3",
|
|
85
85
|
"@libp2p/logger": "^5.1.4",
|