@wovin/connect-nftstorage 0.0.14 → 0.0.15

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.
@@ -1,4 +1,4 @@
1
- import{a as Dn,b as Ut,c as It,d as ir,e as or}from"./chunk-WJCHHT2E.min.js";var zn=Ut($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.BrowserRandomSource=void 0;var qn=65536,_r=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let n=new Uint8Array(e);for(let r=0;r<n.length;r+=qn)this._crypto.getRandomValues(n.subarray(r,r+Math.min(n.length-r,qn)));return n}};$e.BrowserRandomSource=_r});var De=Ut(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});function Ws(t){for(var e=0;e<t.length;e++)t[e]=0;return t}Ir.wipe=Ws});var Hn=Ut(()=>{"use strict"});var Vn=Ut(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.NodeRandomSource=void 0;var Qs=De(),Ur=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Dn<"u"){let e=Hn();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let n=this._crypto.randomBytes(e);if(n.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let r=new Uint8Array(e);for(let i=0;i<r.length;i++)r[i]=n[i];return(0,Qs.wipe)(n),r}};qe.NodeRandomSource=Ur});var Gn=Ut(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.SystemRandomSource=void 0;var Ys=zn(),js=Vn(),Pr=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Ys.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new js.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};ze.SystemRandomSource=Pr});var Jn=Ut(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});function ta(t,e){var n=t>>>16&65535,r=t&65535,i=e>>>16&65535,s=e&65535;return r*s+(n*s+r*i<<16>>>0)|0}_t.mul=Math.imul||ta;function ea(t,e){return t+e|0}_t.add=ea;function ra(t,e){return t-e|0}_t.sub=ra;function na(t,e){return t<<e|t>>>32-e}_t.rotl=na;function ia(t,e){return t<<32-e|t>>>e}_t.rotr=ia;function oa(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t}_t.isInteger=Number.isInteger||oa;_t.MAX_SAFE_INTEGER=9007199254740991;_t.isSafeInteger=function(t){return _t.isInteger(t)&&t>=-_t.MAX_SAFE_INTEGER&&t<=_t.MAX_SAFE_INTEGER}});var Tr=Ut(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});var Xn=Jn();function sa(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}H.readInt16BE=sa;function aa(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}H.readUint16BE=aa;function ua(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}H.readInt16LE=ua;function ca(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}H.readUint16LE=ca;function Zn(t,e,n){return e===void 0&&(e=new Uint8Array(2)),n===void 0&&(n=0),e[n+0]=t>>>8,e[n+1]=t>>>0,e}H.writeUint16BE=Zn;H.writeInt16BE=Zn;function Wn(t,e,n){return e===void 0&&(e=new Uint8Array(2)),n===void 0&&(n=0),e[n+0]=t>>>0,e[n+1]=t>>>8,e}H.writeUint16LE=Wn;H.writeInt16LE=Wn;function Br(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}H.readInt32BE=Br;function Lr(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}H.readUint32BE=Lr;function Nr(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}H.readInt32LE=Nr;function Fr(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}H.readUint32LE=Fr;function He(t,e,n){return e===void 0&&(e=new Uint8Array(4)),n===void 0&&(n=0),e[n+0]=t>>>24,e[n+1]=t>>>16,e[n+2]=t>>>8,e[n+3]=t>>>0,e}H.writeUint32BE=He;H.writeInt32BE=He;function Ve(t,e,n){return e===void 0&&(e=new Uint8Array(4)),n===void 0&&(n=0),e[n+0]=t>>>0,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24,e}H.writeUint32LE=Ve;H.writeInt32LE=Ve;function fa(t,e){e===void 0&&(e=0);var n=Br(t,e),r=Br(t,e+4);return n*4294967296+r-(r>>31)*4294967296}H.readInt64BE=fa;function la(t,e){e===void 0&&(e=0);var n=Lr(t,e),r=Lr(t,e+4);return n*4294967296+r}H.readUint64BE=la;function pa(t,e){e===void 0&&(e=0);var n=Nr(t,e),r=Nr(t,e+4);return r*4294967296+n-(n>>31)*4294967296}H.readInt64LE=pa;function da(t,e){e===void 0&&(e=0);var n=Fr(t,e),r=Fr(t,e+4);return r*4294967296+n}H.readUint64LE=da;function Qn(t,e,n){return e===void 0&&(e=new Uint8Array(8)),n===void 0&&(n=0),He(t/4294967296>>>0,e,n),He(t>>>0,e,n+4),e}H.writeUint64BE=Qn;H.writeInt64BE=Qn;function Yn(t,e,n){return e===void 0&&(e=new Uint8Array(8)),n===void 0&&(n=0),Ve(t>>>0,e,n),Ve(t/4294967296>>>0,e,n+4),e}H.writeUint64LE=Yn;H.writeInt64LE=Yn;function ha(t,e,n){if(n===void 0&&(n=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-n)throw new Error("readUintBE: array is too short for the given bitLength");for(var r=0,i=1,s=t/8+n-1;s>=n;s--)r+=e[s]*i,i*=256;return r}H.readUintBE=ha;function ya(t,e,n){if(n===void 0&&(n=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-n)throw new Error("readUintLE: array is too short for the given bitLength");for(var r=0,i=1,s=n;s<n+t/8;s++)r+=e[s]*i,i*=256;return r}H.readUintLE=ya;function ma(t,e,n,r){if(n===void 0&&(n=new Uint8Array(t/8)),r===void 0&&(r=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!Xn.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=t/8+r-1;s>=r;s--)n[s]=e/i&255,i*=256;return n}H.writeUintBE=ma;function va(t,e,n,r){if(n===void 0&&(n=new Uint8Array(t/8)),r===void 0&&(r=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Xn.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=r;s<r+t/8;s++)n[s]=e/i&255,i*=256;return n}H.writeUintLE=va;function wa(t,e){e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat32(e)}H.readFloat32BE=wa;function ba(t,e){e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat32(e,!0)}H.readFloat32LE=ba;function xa(t,e){e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat64(e)}H.readFloat64BE=xa;function Da(t,e){e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat64(e,!0)}H.readFloat64LE=Da;function ga(t,e,n){e===void 0&&(e=new Uint8Array(4)),n===void 0&&(n=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setFloat32(n,t),e}H.writeFloat32BE=ga;function Ea(t,e,n){e===void 0&&(e=new Uint8Array(4)),n===void 0&&(n=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setFloat32(n,t,!0),e}H.writeFloat32LE=Ea;function Sa(t,e,n){e===void 0&&(e=new Uint8Array(8)),n===void 0&&(n=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setFloat64(n,t),e}H.writeFloat64BE=Sa;function Aa(t,e,n){e===void 0&&(e=new Uint8Array(8)),n===void 0&&(n=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setFloat64(n,t,!0),e}H.writeFloat64LE=Aa});var ri=Ut(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.randomStringForEntropy=xt.randomString=xt.randomUint32=xt.randomBytes=xt.defaultRandomSource=void 0;var Ca=Gn(),_a=Tr(),jn=De();xt.defaultRandomSource=new Ca.SystemRandomSource;function Mr(t,e=xt.defaultRandomSource){return e.randomBytes(t)}xt.randomBytes=Mr;function Ia(t=xt.defaultRandomSource){let e=Mr(4,t),n=(0,_a.readUint32LE)(e);return(0,jn.wipe)(e),n}xt.randomUint32=Ia;var ti="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function ei(t,e=ti,n=xt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let r="",i=e.length,s=256-256%i;for(;t>0;){let f=Mr(Math.ceil(t*256/s),n);for(let c=0;c<f.length&&t>0;c++){let l=f[c];l<s&&(r+=e.charAt(l%i),t--)}(0,jn.wipe)(f)}return r}xt.randomString=ei;function Ua(t,e=ti,n=xt.defaultRandomSource){let r=Math.ceil(t/(Math.log(e.length)/Math.LN2));return ei(r,e,n)}xt.randomStringForEntropy=Ua});var oi=Ut(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});var ce=Tr(),ue=De();Tt.DIGEST_LENGTH=64;Tt.BLOCK_SIZE=128;var ii=function(){function t(){this.digestLength=Tt.DIGEST_LENGTH,this.blockSize=Tt.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return t.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},t.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},t.prototype.clean=function(){ue.wipe(this._buffer),ue.wipe(this._tempHi),ue.wipe(this._tempLo),this.reset()},t.prototype.update=function(e,n){if(n===void 0&&(n=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var r=0;if(this._bytesHashed+=n,this._bufferLength>0){for(;this._bufferLength<Tt.BLOCK_SIZE&&n>0;)this._buffer[this._bufferLength++]=e[r++],n--;this._bufferLength===this.blockSize&&(Rr(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(n>=this.blockSize&&(r=Rr(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,r,n),n%=this.blockSize);n>0;)this._buffer[this._bufferLength++]=e[r++],n--;return this},t.prototype.finish=function(e){if(!this._finished){var n=this._bytesHashed,r=this._bufferLength,i=n/536870912|0,s=n<<3,f=n%128<112?128:256;this._buffer[r]=128;for(var c=r+1;c<f-8;c++)this._buffer[c]=0;ce.writeUint32BE(i,this._buffer,f-8),ce.writeUint32BE(s,this._buffer,f-4),Rr(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,f),this._finished=!0}for(var c=0;c<this.digestLength/8;c++)ce.writeUint32BE(this._stateHi[c],e,c*8),ce.writeUint32BE(this._stateLo[c],e,c*8+4);return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},t.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},t.prototype.cleanSavedState=function(e){ue.wipe(e.stateHi),ue.wipe(e.stateLo),e.buffer&&ue.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},t}();Tt.SHA512=ii;var ni=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function Rr(t,e,n,r,i,s,f){for(var c=n[0],l=n[1],p=n[2],u=n[3],y=n[4],x=n[5],L=n[6],E=n[7],A=r[0],M=r[1],N=r[2],F=r[3],I=r[4],P=r[5],O=r[6],$=r[7],v,b,q,G,U,C,_,B;f>=128;){for(var ot=0;ot<16;ot++){var et=8*ot+s;t[ot]=ce.readUint32BE(i,et),e[ot]=ce.readUint32BE(i,et+4)}for(var ot=0;ot<80;ot++){var gt=c,At=l,Ht=p,rt=u,W=y,nt=x,Y=L,st=E,at=A,ut=M,ht=N,tt=F,pt=I,dt=P,ct=O,ft=$;if(v=E,b=$,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=(y>>>14|I<<18)^(y>>>18|I<<14)^(I>>>9|y<<23),b=(I>>>14|y<<18)^(I>>>18|y<<14)^(y>>>9|I<<23),U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,v=y&x^~y&L,b=I&P^~I&O,U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,v=ni[ot*2],b=ni[ot*2+1],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,v=t[ot%16],b=e[ot%16],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,q=_&65535|B<<16,G=U&65535|C<<16,v=q,b=G,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=(c>>>28|A<<4)^(A>>>2|c<<30)^(A>>>7|c<<25),b=(A>>>28|c<<4)^(c>>>2|A<<30)^(c>>>7|A<<25),U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,v=c&l^c&p^l&p,b=A&M^A&N^M&N,U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,st=_&65535|B<<16,ft=U&65535|C<<16,v=rt,b=tt,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=q,b=G,U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,rt=_&65535|B<<16,tt=U&65535|C<<16,l=gt,p=At,u=Ht,y=rt,x=W,L=nt,E=Y,c=st,M=at,N=ut,F=ht,I=tt,P=pt,O=dt,$=ct,A=ft,ot%16===15)for(var et=0;et<16;et++)v=t[et],b=e[et],U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=t[(et+9)%16],b=e[(et+9)%16],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,q=t[(et+1)%16],G=e[(et+1)%16],v=(q>>>1|G<<31)^(q>>>8|G<<24)^q>>>7,b=(G>>>1|q<<31)^(G>>>8|q<<24)^(G>>>7|q<<25),U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,q=t[(et+14)%16],G=e[(et+14)%16],v=(q>>>19|G<<13)^(G>>>29|q<<3)^q>>>6,b=(G>>>19|q<<13)^(q>>>29|G<<3)^(G>>>6|q<<26),U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,t[et]=_&65535|B<<16,e[et]=U&65535|C<<16}v=c,b=A,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[0],b=r[0],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[0]=c=_&65535|B<<16,r[0]=A=U&65535|C<<16,v=l,b=M,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[1],b=r[1],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[1]=l=_&65535|B<<16,r[1]=M=U&65535|C<<16,v=p,b=N,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[2],b=r[2],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[2]=p=_&65535|B<<16,r[2]=N=U&65535|C<<16,v=u,b=F,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[3],b=r[3],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[3]=u=_&65535|B<<16,r[3]=F=U&65535|C<<16,v=y,b=I,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[4],b=r[4],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[4]=y=_&65535|B<<16,r[4]=I=U&65535|C<<16,v=x,b=P,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[5],b=r[5],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[5]=x=_&65535|B<<16,r[5]=P=U&65535|C<<16,v=L,b=O,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[6],b=r[6],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[6]=L=_&65535|B<<16,r[6]=O=U&65535|C<<16,v=E,b=$,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[7],b=r[7],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[7]=E=_&65535|B<<16,r[7]=$=U&65535|C<<16,s+=128,f-=128}return s}function Pa(t){var e=new ii;e.update(t);var n=e.digest();return e.clean(),n}Tt.hash=Pa});var Vr=Ut(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.convertSecretKeyToX25519=X.convertPublicKeyToX25519=X.verify=X.sign=X.extractPublicKeyFromSecretKey=X.generateKeyPair=X.generateKeyPairFromSeed=X.SEED_LENGTH=X.SECRET_KEY_LENGTH=X.PUBLIC_KEY_LENGTH=X.SIGNATURE_LENGTH=void 0;var Ba=ri(),ge=oi(),fi=De();X.SIGNATURE_LENGTH=64;X.PUBLIC_KEY_LENGTH=32;X.SECRET_KEY_LENGTH=64;X.SEED_LENGTH=32;function T(t){let e=new Float64Array(16);if(t)for(let n=0;n<t.length;n++)e[n]=t[n];return e}var La=new Uint8Array(32);La[0]=9;var Kr=T(),fe=T([1]),Na=T([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),Fa=T([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),si=T([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),ai=T([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Ta=T([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function qt(t,e){for(let n=0;n<16;n++)t[n]=e[n]|0}function Or(t){let e=1;for(let n=0;n<16;n++){let r=t[n]+e+65535;e=Math.floor(r/65536),t[n]=r-e*65536}t[0]+=e-1+37*(e-1)}function li(t,e,n){let r=~(n-1);for(let i=0;i<16;i++){let s=r&(t[i]^e[i]);t[i]^=s,e[i]^=s}}function Ee(t,e){let n=T(),r=T();for(let i=0;i<16;i++)r[i]=e[i];Or(r),Or(r),Or(r);for(let i=0;i<2;i++){n[0]=r[0]-65517;for(let f=1;f<15;f++)n[f]=r[f]-65535-(n[f-1]>>16&1),n[f-1]&=65535;n[15]=r[15]-32767-(n[14]>>16&1);let s=n[15]>>16&1;n[14]&=65535,li(r,n,1-s)}for(let i=0;i<16;i++)t[2*i]=r[i]&255,t[2*i+1]=r[i]>>8}function pi(t,e){let n=0;for(let r=0;r<32;r++)n|=t[r]^e[r];return(1&n-1>>>8)-1}function ui(t,e){let n=new Uint8Array(32),r=new Uint8Array(32);return Ee(n,t),Ee(r,e),pi(n,r)}function di(t){let e=new Uint8Array(32);return Ee(e,t),e[0]&1}function Ma(t,e){for(let n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function Xt(t,e,n){for(let r=0;r<16;r++)t[r]=e[r]+n[r]}function Wt(t,e,n){for(let r=0;r<16;r++)t[r]=e[r]-n[r]}function Q(t,e,n){let r,i,s=0,f=0,c=0,l=0,p=0,u=0,y=0,x=0,L=0,E=0,A=0,M=0,N=0,F=0,I=0,P=0,O=0,$=0,v=0,b=0,q=0,G=0,U=0,C=0,_=0,B=0,ot=0,et=0,gt=0,At=0,Ht=0,rt=n[0],W=n[1],nt=n[2],Y=n[3],st=n[4],at=n[5],ut=n[6],ht=n[7],tt=n[8],pt=n[9],dt=n[10],ct=n[11],ft=n[12],mt=n[13],vt=n[14],wt=n[15];r=e[0],s+=r*rt,f+=r*W,c+=r*nt,l+=r*Y,p+=r*st,u+=r*at,y+=r*ut,x+=r*ht,L+=r*tt,E+=r*pt,A+=r*dt,M+=r*ct,N+=r*ft,F+=r*mt,I+=r*vt,P+=r*wt,r=e[1],f+=r*rt,c+=r*W,l+=r*nt,p+=r*Y,u+=r*st,y+=r*at,x+=r*ut,L+=r*ht,E+=r*tt,A+=r*pt,M+=r*dt,N+=r*ct,F+=r*ft,I+=r*mt,P+=r*vt,O+=r*wt,r=e[2],c+=r*rt,l+=r*W,p+=r*nt,u+=r*Y,y+=r*st,x+=r*at,L+=r*ut,E+=r*ht,A+=r*tt,M+=r*pt,N+=r*dt,F+=r*ct,I+=r*ft,P+=r*mt,O+=r*vt,$+=r*wt,r=e[3],l+=r*rt,p+=r*W,u+=r*nt,y+=r*Y,x+=r*st,L+=r*at,E+=r*ut,A+=r*ht,M+=r*tt,N+=r*pt,F+=r*dt,I+=r*ct,P+=r*ft,O+=r*mt,$+=r*vt,v+=r*wt,r=e[4],p+=r*rt,u+=r*W,y+=r*nt,x+=r*Y,L+=r*st,E+=r*at,A+=r*ut,M+=r*ht,N+=r*tt,F+=r*pt,I+=r*dt,P+=r*ct,O+=r*ft,$+=r*mt,v+=r*vt,b+=r*wt,r=e[5],u+=r*rt,y+=r*W,x+=r*nt,L+=r*Y,E+=r*st,A+=r*at,M+=r*ut,N+=r*ht,F+=r*tt,I+=r*pt,P+=r*dt,O+=r*ct,$+=r*ft,v+=r*mt,b+=r*vt,q+=r*wt,r=e[6],y+=r*rt,x+=r*W,L+=r*nt,E+=r*Y,A+=r*st,M+=r*at,N+=r*ut,F+=r*ht,I+=r*tt,P+=r*pt,O+=r*dt,$+=r*ct,v+=r*ft,b+=r*mt,q+=r*vt,G+=r*wt,r=e[7],x+=r*rt,L+=r*W,E+=r*nt,A+=r*Y,M+=r*st,N+=r*at,F+=r*ut,I+=r*ht,P+=r*tt,O+=r*pt,$+=r*dt,v+=r*ct,b+=r*ft,q+=r*mt,G+=r*vt,U+=r*wt,r=e[8],L+=r*rt,E+=r*W,A+=r*nt,M+=r*Y,N+=r*st,F+=r*at,I+=r*ut,P+=r*ht,O+=r*tt,$+=r*pt,v+=r*dt,b+=r*ct,q+=r*ft,G+=r*mt,U+=r*vt,C+=r*wt,r=e[9],E+=r*rt,A+=r*W,M+=r*nt,N+=r*Y,F+=r*st,I+=r*at,P+=r*ut,O+=r*ht,$+=r*tt,v+=r*pt,b+=r*dt,q+=r*ct,G+=r*ft,U+=r*mt,C+=r*vt,_+=r*wt,r=e[10],A+=r*rt,M+=r*W,N+=r*nt,F+=r*Y,I+=r*st,P+=r*at,O+=r*ut,$+=r*ht,v+=r*tt,b+=r*pt,q+=r*dt,G+=r*ct,U+=r*ft,C+=r*mt,_+=r*vt,B+=r*wt,r=e[11],M+=r*rt,N+=r*W,F+=r*nt,I+=r*Y,P+=r*st,O+=r*at,$+=r*ut,v+=r*ht,b+=r*tt,q+=r*pt,G+=r*dt,U+=r*ct,C+=r*ft,_+=r*mt,B+=r*vt,ot+=r*wt,r=e[12],N+=r*rt,F+=r*W,I+=r*nt,P+=r*Y,O+=r*st,$+=r*at,v+=r*ut,b+=r*ht,q+=r*tt,G+=r*pt,U+=r*dt,C+=r*ct,_+=r*ft,B+=r*mt,ot+=r*vt,et+=r*wt,r=e[13],F+=r*rt,I+=r*W,P+=r*nt,O+=r*Y,$+=r*st,v+=r*at,b+=r*ut,q+=r*ht,G+=r*tt,U+=r*pt,C+=r*dt,_+=r*ct,B+=r*ft,ot+=r*mt,et+=r*vt,gt+=r*wt,r=e[14],I+=r*rt,P+=r*W,O+=r*nt,$+=r*Y,v+=r*st,b+=r*at,q+=r*ut,G+=r*ht,U+=r*tt,C+=r*pt,_+=r*dt,B+=r*ct,ot+=r*ft,et+=r*mt,gt+=r*vt,At+=r*wt,r=e[15],P+=r*rt,O+=r*W,$+=r*nt,v+=r*Y,b+=r*st,q+=r*at,G+=r*ut,U+=r*ht,C+=r*tt,_+=r*pt,B+=r*dt,ot+=r*ct,et+=r*ft,gt+=r*mt,At+=r*vt,Ht+=r*wt,s+=38*O,f+=38*$,c+=38*v,l+=38*b,p+=38*q,u+=38*G,y+=38*U,x+=38*C,L+=38*_,E+=38*B,A+=38*ot,M+=38*et,N+=38*gt,F+=38*At,I+=38*Ht,i=1,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=x+i+65535,i=Math.floor(r/65536),x=r-i*65536,r=L+i+65535,i=Math.floor(r/65536),L=r-i*65536,r=E+i+65535,i=Math.floor(r/65536),E=r-i*65536,r=A+i+65535,i=Math.floor(r/65536),A=r-i*65536,r=M+i+65535,i=Math.floor(r/65536),M=r-i*65536,r=N+i+65535,i=Math.floor(r/65536),N=r-i*65536,r=F+i+65535,i=Math.floor(r/65536),F=r-i*65536,r=I+i+65535,i=Math.floor(r/65536),I=r-i*65536,r=P+i+65535,i=Math.floor(r/65536),P=r-i*65536,s+=i-1+37*(i-1),i=1,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=x+i+65535,i=Math.floor(r/65536),x=r-i*65536,r=L+i+65535,i=Math.floor(r/65536),L=r-i*65536,r=E+i+65535,i=Math.floor(r/65536),E=r-i*65536,r=A+i+65535,i=Math.floor(r/65536),A=r-i*65536,r=M+i+65535,i=Math.floor(r/65536),M=r-i*65536,r=N+i+65535,i=Math.floor(r/65536),N=r-i*65536,r=F+i+65535,i=Math.floor(r/65536),F=r-i*65536,r=I+i+65535,i=Math.floor(r/65536),I=r-i*65536,r=P+i+65535,i=Math.floor(r/65536),P=r-i*65536,s+=i-1+37*(i-1),t[0]=s,t[1]=f,t[2]=c,t[3]=l,t[4]=p,t[5]=u,t[6]=y,t[7]=x,t[8]=L,t[9]=E,t[10]=A,t[11]=M,t[12]=N,t[13]=F,t[14]=I,t[15]=P}function Zt(t,e){Q(t,e,e)}function hi(t,e){let n=T(),r;for(r=0;r<16;r++)n[r]=e[r];for(r=253;r>=0;r--)Zt(n,n),r!==2&&r!==4&&Q(n,n,e);for(r=0;r<16;r++)t[r]=n[r]}function Ra(t,e){let n=T(),r;for(r=0;r<16;r++)n[r]=e[r];for(r=250;r>=0;r--)Zt(n,n),r!==1&&Q(n,n,e);for(r=0;r<16;r++)t[r]=n[r]}function $r(t,e){let n=T(),r=T(),i=T(),s=T(),f=T(),c=T(),l=T(),p=T(),u=T();Wt(n,t[1],t[0]),Wt(u,e[1],e[0]),Q(n,n,u),Xt(r,t[0],t[1]),Xt(u,e[0],e[1]),Q(r,r,u),Q(i,t[3],e[3]),Q(i,i,Fa),Q(s,t[2],e[2]),Xt(s,s,s),Wt(f,r,n),Wt(c,s,i),Xt(l,s,i),Xt(p,r,n),Q(t[0],f,c),Q(t[1],p,l),Q(t[2],l,c),Q(t[3],f,p)}function ci(t,e,n){for(let r=0;r<4;r++)li(t[r],e[r],n)}function zr(t,e){let n=T(),r=T(),i=T();hi(i,e[2]),Q(n,e[0],i),Q(r,e[1],i),Ee(t,r),t[31]^=di(n)<<7}function yi(t,e,n){qt(t[0],Kr),qt(t[1],fe),qt(t[2],fe),qt(t[3],Kr);for(let r=255;r>=0;--r){let i=n[r/8|0]>>(r&7)&1;ci(t,e,i),$r(e,t),$r(t,t),ci(t,e,i)}}function Hr(t,e){let n=[T(),T(),T(),T()];qt(n[0],si),qt(n[1],ai),qt(n[2],fe),Q(n[3],si,ai),yi(t,n,e)}function mi(t){if(t.length!==X.SEED_LENGTH)throw new Error(`ed25519: seed must be ${X.SEED_LENGTH} bytes`);let e=(0,ge.hash)(t);e[0]&=248,e[31]&=127,e[31]|=64;let n=new Uint8Array(32),r=[T(),T(),T(),T()];Hr(r,e),zr(n,r);let i=new Uint8Array(64);return i.set(t),i.set(n,32),{publicKey:n,secretKey:i}}X.generateKeyPairFromSeed=mi;function Oa(t){let e=(0,Ba.randomBytes)(32,t),n=mi(e);return(0,fi.wipe)(e),n}X.generateKeyPair=Oa;function ka(t){if(t.length!==X.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${X.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(t.subarray(32))}X.extractPublicKeyFromSecretKey=ka;var kr=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function vi(t,e){let n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i<s;++i)e[i]+=n-16*e[r]*kr[i-(r-32)],n=Math.floor((e[i]+128)/256),e[i]-=n*256;e[i]+=n,e[r]=0}for(n=0,i=0;i<32;i++)e[i]+=n-(e[31]>>4)*kr[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*kr[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=e[r]&255}function qr(t){let e=new Float64Array(64);for(let n=0;n<64;n++)e[n]=t[n];for(let n=0;n<64;n++)t[n]=0;vi(t,e)}function Ka(t,e){let n=new Float64Array(64),r=[T(),T(),T(),T()],i=(0,ge.hash)(t.subarray(0,32));i[0]&=248,i[31]&=127,i[31]|=64;let s=new Uint8Array(64);s.set(i.subarray(32),32);let f=new ge.SHA512;f.update(s.subarray(32)),f.update(e);let c=f.digest();f.clean(),qr(c),Hr(r,c),zr(s,r),f.reset(),f.update(s.subarray(0,32)),f.update(t.subarray(32)),f.update(e);let l=f.digest();qr(l);for(let p=0;p<32;p++)n[p]=c[p];for(let p=0;p<32;p++)for(let u=0;u<32;u++)n[p+u]+=l[p]*i[u];return vi(s.subarray(32),n),s}X.sign=Ka;function wi(t,e){let n=T(),r=T(),i=T(),s=T(),f=T(),c=T(),l=T();return qt(t[2],fe),Ma(t[1],e),Zt(i,t[1]),Q(s,i,Na),Wt(i,i,t[2]),Xt(s,t[2],s),Zt(f,s),Zt(c,f),Q(l,c,f),Q(n,l,i),Q(n,n,s),Ra(n,n),Q(n,n,i),Q(n,n,s),Q(n,n,s),Q(t[0],n,s),Zt(r,t[0]),Q(r,r,s),ui(r,i)&&Q(t[0],t[0],Ta),Zt(r,t[0]),Q(r,r,s),ui(r,i)?-1:(di(t[0])===e[31]>>7&&Wt(t[0],Kr,t[0]),Q(t[3],t[0],t[1]),0)}function $a(t,e,n){let r=new Uint8Array(32),i=[T(),T(),T(),T()],s=[T(),T(),T(),T()];if(n.length!==X.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${X.SIGNATURE_LENGTH} bytes`);if(wi(s,t))return!1;let f=new ge.SHA512;f.update(n.subarray(0,32)),f.update(t),f.update(e);let c=f.digest();return qr(c),yi(i,s,c),Hr(s,n.subarray(32)),$r(i,s),zr(r,i),!pi(n,r)}X.verify=$a;function qa(t){let e=[T(),T(),T(),T()];if(wi(e,t))throw new Error("Ed25519: invalid public key");let n=T(),r=T(),i=e[1];Xt(n,fe,i),Wt(r,fe,i),hi(r,r),Q(n,n,r);let s=new Uint8Array(32);return Ee(s,n),s}X.convertPublicKeyToX25519=qa;function za(t){let e=(0,ge.hash)(t.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let n=new Uint8Array(e.subarray(0,32));return(0,fi.wipe)(e),n}X.convertSecretKeyToX25519=za});var Ii=Ut((jf,We)=>{"use strict";var yt=function(t){"use strict";var e=1e7,n=7,r=9007199254740992,i=x(r),s="0123456789abcdefghijklmnopqrstuvwxyz",f=typeof BigInt=="function";function c(o,a,d,h){return typeof o>"u"?c[0]:typeof a<"u"?+a==10&&!d?k(o):wt(o,a,d,h):k(o)}function l(o,a){this.value=o,this.sign=a,this.isSmall=!1}l.prototype=Object.create(c.prototype);function p(o){this.value=o,this.sign=o<0,this.isSmall=!0}p.prototype=Object.create(c.prototype);function u(o){this.value=o}u.prototype=Object.create(c.prototype);function y(o){return-r<o&&o<r}function x(o){return o<1e7?[o]:o<1e14?[o%1e7,Math.floor(o/1e7)]:[o%1e7,Math.floor(o/1e7)%1e7,Math.floor(o/1e14)]}function L(o){E(o);var a=o.length;if(a<4&&At(o,i)<0)switch(a){case 0:return 0;case 1:return o[0];case 2:return o[0]+o[1]*e;default:return o[0]+(o[1]+o[2]*e)*e}return o}function E(o){for(var a=o.length;o[--a]===0;);o.length=a+1}function A(o){for(var a=new Array(o),d=-1;++d<o;)a[d]=0;return a}function M(o){return o>0?Math.floor(o):Math.ceil(o)}function N(o,a){var d=o.length,h=a.length,w=new Array(d),m=0,g=e,D,S;for(S=0;S<h;S++)D=o[S]+a[S]+m,m=D>=g?1:0,w[S]=D-m*g;for(;S<d;)D=o[S]+m,m=D===g?1:0,w[S++]=D-m*g;return m>0&&w.push(m),w}function F(o,a){return o.length>=a.length?N(o,a):N(a,o)}function I(o,a){var d=o.length,h=new Array(d),w=e,m,g;for(g=0;g<d;g++)m=o[g]-w+a,a=Math.floor(m/w),h[g]=m-a*w,a+=1;for(;a>0;)h[g++]=a%w,a=Math.floor(a/w);return h}l.prototype.add=function(o){var a=k(o);if(this.sign!==a.sign)return this.subtract(a.negate());var d=this.value,h=a.value;return a.isSmall?new l(I(d,Math.abs(h)),this.sign):new l(F(d,h),this.sign)},l.prototype.plus=l.prototype.add,p.prototype.add=function(o){var a=k(o),d=this.value;if(d<0!==a.sign)return this.subtract(a.negate());var h=a.value;if(a.isSmall){if(y(d+h))return new p(d+h);h=x(Math.abs(h))}return new l(I(h,Math.abs(d)),d<0)},p.prototype.plus=p.prototype.add,u.prototype.add=function(o){return new u(this.value+k(o).value)},u.prototype.plus=u.prototype.add;function P(o,a){var d=o.length,h=a.length,w=new Array(d),m=0,g=e,D,S;for(D=0;D<h;D++)S=o[D]-m-a[D],S<0?(S+=g,m=1):m=0,w[D]=S;for(D=h;D<d;D++){if(S=o[D]-m,S<0)S+=g;else{w[D++]=S;break}w[D]=S}for(;D<d;D++)w[D]=o[D];return E(w),w}function O(o,a,d){var h;return At(o,a)>=0?h=P(o,a):(h=P(a,o),d=!d),h=L(h),typeof h=="number"?(d&&(h=-h),new p(h)):new l(h,d)}function $(o,a,d){var h=o.length,w=new Array(h),m=-a,g=e,D,S;for(D=0;D<h;D++)S=o[D]+m,m=Math.floor(S/g),S%=g,w[D]=S<0?S+g:S;return w=L(w),typeof w=="number"?(d&&(w=-w),new p(w)):new l(w,d)}l.prototype.subtract=function(o){var a=k(o);if(this.sign!==a.sign)return this.add(a.negate());var d=this.value,h=a.value;return a.isSmall?$(d,Math.abs(h),this.sign):O(d,h,this.sign)},l.prototype.minus=l.prototype.subtract,p.prototype.subtract=function(o){var a=k(o),d=this.value;if(d<0!==a.sign)return this.add(a.negate());var h=a.value;return a.isSmall?new p(d-h):$(h,Math.abs(d),d>=0)},p.prototype.minus=p.prototype.subtract,u.prototype.subtract=function(o){return new u(this.value-k(o).value)},u.prototype.minus=u.prototype.subtract,l.prototype.negate=function(){return new l(this.value,!this.sign)},p.prototype.negate=function(){var o=this.sign,a=new p(-this.value);return a.sign=!o,a},u.prototype.negate=function(){return new u(-this.value)},l.prototype.abs=function(){return new l(this.value,!1)},p.prototype.abs=function(){return new p(Math.abs(this.value))},u.prototype.abs=function(){return new u(this.value>=0?this.value:-this.value)};function v(o,a){var d=o.length,h=a.length,w=d+h,m=A(w),g=e,D,S,K,V,z;for(K=0;K<d;++K){V=o[K];for(var J=0;J<h;++J)z=a[J],D=V*z+m[K+J],S=Math.floor(D/g),m[K+J]=D-S*g,m[K+J+1]+=S}return E(m),m}function b(o,a){var d=o.length,h=new Array(d),w=e,m=0,g,D;for(D=0;D<d;D++)g=o[D]*a+m,m=Math.floor(g/w),h[D]=g-m*w;for(;m>0;)h[D++]=m%w,m=Math.floor(m/w);return h}function q(o,a){for(var d=[];a-- >0;)d.push(0);return d.concat(o)}function G(o,a){var d=Math.max(o.length,a.length);if(d<=30)return v(o,a);d=Math.ceil(d/2);var h=o.slice(d),w=o.slice(0,d),m=a.slice(d),g=a.slice(0,d),D=G(w,g),S=G(h,m),K=G(F(w,h),F(g,m)),V=F(F(D,q(P(P(K,D),S),d)),q(S,2*d));return E(V),V}function U(o,a){return-.012*o-.012*a+15e-6*o*a>0}l.prototype.multiply=function(o){var a=k(o),d=this.value,h=a.value,w=this.sign!==a.sign,m;if(a.isSmall){if(h===0)return c[0];if(h===1)return this;if(h===-1)return this.negate();if(m=Math.abs(h),m<e)return new l(b(d,m),w);h=x(m)}return U(d.length,h.length)?new l(G(d,h),w):new l(v(d,h),w)},l.prototype.times=l.prototype.multiply;function C(o,a,d){return o<e?new l(b(a,o),d):new l(v(a,x(o)),d)}p.prototype._multiplyBySmall=function(o){return y(o.value*this.value)?new p(o.value*this.value):C(Math.abs(o.value),x(Math.abs(this.value)),this.sign!==o.sign)},l.prototype._multiplyBySmall=function(o){return o.value===0?c[0]:o.value===1?this:o.value===-1?this.negate():C(Math.abs(o.value),this.value,this.sign!==o.sign)},p.prototype.multiply=function(o){return k(o)._multiplyBySmall(this)},p.prototype.times=p.prototype.multiply,u.prototype.multiply=function(o){return new u(this.value*k(o).value)},u.prototype.times=u.prototype.multiply;function _(o){var a=o.length,d=A(a+a),h=e,w,m,g,D,S;for(g=0;g<a;g++){D=o[g],m=0-D*D;for(var K=g;K<a;K++)S=o[K],w=2*(D*S)+d[g+K]+m,m=Math.floor(w/h),d[g+K]=w-m*h;d[g+a]=m}return E(d),d}l.prototype.square=function(){return new l(_(this.value),!1)},p.prototype.square=function(){var o=this.value*this.value;return y(o)?new p(o):new l(_(x(Math.abs(this.value))),!1)},u.prototype.square=function(o){return new u(this.value*this.value)};function B(o,a){var d=o.length,h=a.length,w=e,m=A(a.length),g=a[h-1],D=Math.ceil(w/(2*g)),S=b(o,D),K=b(a,D),V,z,J,Ct,Et,rr,nr;for(S.length<=d&&S.push(0),K.push(0),g=K[h-1],z=d-h;z>=0;z--){for(V=w-1,S[z+h]!==g&&(V=Math.floor((S[z+h]*w+S[z+h-1])/g)),J=0,Ct=0,rr=K.length,Et=0;Et<rr;Et++)J+=V*K[Et],nr=Math.floor(J/w),Ct+=S[z+Et]-(J-nr*w),J=nr,Ct<0?(S[z+Et]=Ct+w,Ct=-1):(S[z+Et]=Ct,Ct=0);for(;Ct!==0;){for(V-=1,J=0,Et=0;Et<rr;Et++)J+=S[z+Et]-w+K[Et],J<0?(S[z+Et]=J+w,J=0):(S[z+Et]=J,J=1);Ct+=J}m[z]=V}return S=et(S,D)[0],[L(m),L(S)]}function ot(o,a){for(var d=o.length,h=a.length,w=[],m=[],g=e,D,S,K,V,z;d;){if(m.unshift(o[--d]),E(m),At(m,a)<0){w.push(0);continue}S=m.length,K=m[S-1]*g+m[S-2],V=a[h-1]*g+a[h-2],S>h&&(K=(K+1)*g),D=Math.ceil(K/V);do{if(z=b(a,D),At(z,m)<=0)break;D--}while(D);w.push(D),m=P(m,z)}return w.reverse(),[L(w),L(m)]}function et(o,a){var d=o.length,h=A(d),w=e,m,g,D,S;for(D=0,m=d-1;m>=0;--m)S=D*w+o[m],g=M(S/a),D=S-g*a,h[m]=g|0;return[h,D|0]}function gt(o,a){var d,h=k(a);if(f)return[new u(o.value/h.value),new u(o.value%h.value)];var w=o.value,m=h.value,g;if(m===0)throw new Error("Cannot divide by zero");if(o.isSmall)return h.isSmall?[new p(M(w/m)),new p(w%m)]:[c[0],o];if(h.isSmall){if(m===1)return[o,c[0]];if(m==-1)return[o.negate(),c[0]];var D=Math.abs(m);if(D<e){d=et(w,D),g=L(d[0]);var S=d[1];return o.sign&&(S=-S),typeof g=="number"?(o.sign!==h.sign&&(g=-g),[new p(g),new p(S)]):[new l(g,o.sign!==h.sign),new p(S)]}m=x(D)}var K=At(w,m);if(K===-1)return[c[0],o];if(K===0)return[c[o.sign===h.sign?1:-1],c[0]];w.length+m.length<=200?d=B(w,m):d=ot(w,m),g=d[0];var V=o.sign!==h.sign,z=d[1],J=o.sign;return typeof g=="number"?(V&&(g=-g),g=new p(g)):g=new l(g,V),typeof z=="number"?(J&&(z=-z),z=new p(z)):z=new l(z,J),[g,z]}l.prototype.divmod=function(o){var a=gt(this,o);return{quotient:a[0],remainder:a[1]}},u.prototype.divmod=p.prototype.divmod=l.prototype.divmod,l.prototype.divide=function(o){return gt(this,o)[0]},u.prototype.over=u.prototype.divide=function(o){return new u(this.value/k(o).value)},p.prototype.over=p.prototype.divide=l.prototype.over=l.prototype.divide,l.prototype.mod=function(o){return gt(this,o)[1]},u.prototype.mod=u.prototype.remainder=function(o){return new u(this.value%k(o).value)},p.prototype.remainder=p.prototype.mod=l.prototype.remainder=l.prototype.mod,l.prototype.pow=function(o){var a=k(o),d=this.value,h=a.value,w,m,g;if(h===0)return c[1];if(d===0)return c[0];if(d===1)return c[1];if(d===-1)return a.isEven()?c[1]:c[-1];if(a.sign)return c[0];if(!a.isSmall)throw new Error("The exponent "+a.toString()+" is too large.");if(this.isSmall&&y(w=Math.pow(d,h)))return new p(M(w));for(m=this,g=c[1];h&!0&&(g=g.times(m),--h),h!==0;)h/=2,m=m.square();return g},p.prototype.pow=l.prototype.pow,u.prototype.pow=function(o){var a=k(o),d=this.value,h=a.value,w=BigInt(0),m=BigInt(1),g=BigInt(2);if(h===w)return c[1];if(d===w)return c[0];if(d===m)return c[1];if(d===BigInt(-1))return a.isEven()?c[1]:c[-1];if(a.isNegative())return new u(w);for(var D=this,S=c[1];(h&m)===m&&(S=S.times(D),--h),h!==w;)h/=g,D=D.square();return S},l.prototype.modPow=function(o,a){if(o=k(o),a=k(a),a.isZero())throw new Error("Cannot take modPow with modulus 0");var d=c[1],h=this.mod(a);for(o.isNegative()&&(o=o.multiply(c[-1]),h=h.modInv(a));o.isPositive();){if(h.isZero())return c[0];o.isOdd()&&(d=d.multiply(h).mod(a)),o=o.divide(2),h=h.square().mod(a)}return d},u.prototype.modPow=p.prototype.modPow=l.prototype.modPow;function At(o,a){if(o.length!==a.length)return o.length>a.length?1:-1;for(var d=o.length-1;d>=0;d--)if(o[d]!==a[d])return o[d]>a[d]?1:-1;return 0}l.prototype.compareAbs=function(o){var a=k(o),d=this.value,h=a.value;return a.isSmall?1:At(d,h)},p.prototype.compareAbs=function(o){var a=k(o),d=Math.abs(this.value),h=a.value;return a.isSmall?(h=Math.abs(h),d===h?0:d>h?1:-1):-1},u.prototype.compareAbs=function(o){var a=this.value,d=k(o).value;return a=a>=0?a:-a,d=d>=0?d:-d,a===d?0:a>d?1:-1},l.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var a=k(o),d=this.value,h=a.value;return this.sign!==a.sign?a.sign?1:-1:a.isSmall?this.sign?-1:1:At(d,h)*(this.sign?-1:1)},l.prototype.compareTo=l.prototype.compare,p.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var a=k(o),d=this.value,h=a.value;return a.isSmall?d==h?0:d>h?1:-1:d<0!==a.sign?d<0?-1:1:d<0?1:-1},p.prototype.compareTo=p.prototype.compare,u.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var a=this.value,d=k(o).value;return a===d?0:a>d?1:-1},u.prototype.compareTo=u.prototype.compare,l.prototype.equals=function(o){return this.compare(o)===0},u.prototype.eq=u.prototype.equals=p.prototype.eq=p.prototype.equals=l.prototype.eq=l.prototype.equals,l.prototype.notEquals=function(o){return this.compare(o)!==0},u.prototype.neq=u.prototype.notEquals=p.prototype.neq=p.prototype.notEquals=l.prototype.neq=l.prototype.notEquals,l.prototype.greater=function(o){return this.compare(o)>0},u.prototype.gt=u.prototype.greater=p.prototype.gt=p.prototype.greater=l.prototype.gt=l.prototype.greater,l.prototype.lesser=function(o){return this.compare(o)<0},u.prototype.lt=u.prototype.lesser=p.prototype.lt=p.prototype.lesser=l.prototype.lt=l.prototype.lesser,l.prototype.greaterOrEquals=function(o){return this.compare(o)>=0},u.prototype.geq=u.prototype.greaterOrEquals=p.prototype.geq=p.prototype.greaterOrEquals=l.prototype.geq=l.prototype.greaterOrEquals,l.prototype.lesserOrEquals=function(o){return this.compare(o)<=0},u.prototype.leq=u.prototype.lesserOrEquals=p.prototype.leq=p.prototype.lesserOrEquals=l.prototype.leq=l.prototype.lesserOrEquals,l.prototype.isEven=function(){return(this.value[0]&1)===0},p.prototype.isEven=function(){return(this.value&1)===0},u.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},l.prototype.isOdd=function(){return(this.value[0]&1)===1},p.prototype.isOdd=function(){return(this.value&1)===1},u.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},l.prototype.isPositive=function(){return!this.sign},p.prototype.isPositive=function(){return this.value>0},u.prototype.isPositive=p.prototype.isPositive,l.prototype.isNegative=function(){return this.sign},p.prototype.isNegative=function(){return this.value<0},u.prototype.isNegative=p.prototype.isNegative,l.prototype.isUnit=function(){return!1},p.prototype.isUnit=function(){return Math.abs(this.value)===1},u.prototype.isUnit=function(){return this.abs().value===BigInt(1)},l.prototype.isZero=function(){return!1},p.prototype.isZero=function(){return this.value===0},u.prototype.isZero=function(){return this.value===BigInt(0)},l.prototype.isDivisibleBy=function(o){var a=k(o);return a.isZero()?!1:a.isUnit()?!0:a.compareAbs(2)===0?this.isEven():this.mod(a).isZero()},u.prototype.isDivisibleBy=p.prototype.isDivisibleBy=l.prototype.isDivisibleBy;function Ht(o){var a=o.abs();if(a.isUnit())return!1;if(a.equals(2)||a.equals(3)||a.equals(5))return!0;if(a.isEven()||a.isDivisibleBy(3)||a.isDivisibleBy(5))return!1;if(a.lesser(49))return!0}function rt(o,a){for(var d=o.prev(),h=d,w=0,m,g,D,S;h.isEven();)h=h.divide(2),w++;t:for(D=0;D<a.length;D++)if(!o.lesser(a[D])&&(S=yt(a[D]).modPow(h,o),!(S.isUnit()||S.equals(d)))){for(m=w-1;m!=0;m--){if(S=S.square().mod(o),S.isUnit())return!1;if(S.equals(d))continue t}return!1}return!0}l.prototype.isPrime=function(o){var a=Ht(this);if(a!==t)return a;var d=this.abs(),h=d.bitLength();if(h<=64)return rt(d,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var w=Math.log(2)*h.toJSNumber(),m=Math.ceil(o===!0?2*Math.pow(w,2):w),g=[],D=0;D<m;D++)g.push(yt(D+2));return rt(d,g)},u.prototype.isPrime=p.prototype.isPrime=l.prototype.isPrime,l.prototype.isProbablePrime=function(o,a){var d=Ht(this);if(d!==t)return d;for(var h=this.abs(),w=o===t?5:o,m=[],g=0;g<w;g++)m.push(yt.randBetween(2,h.minus(2),a));return rt(h,m)},u.prototype.isProbablePrime=p.prototype.isProbablePrime=l.prototype.isProbablePrime,l.prototype.modInv=function(o){for(var a=yt.zero,d=yt.one,h=k(o),w=this.abs(),m,g,D;!w.isZero();)m=h.divide(w),g=a,D=h,a=d,h=w,d=g.subtract(m.multiply(d)),w=D.subtract(m.multiply(w));if(!h.isUnit())throw new Error(this.toString()+" and "+o.toString()+" are not co-prime");return a.compare(0)===-1&&(a=a.add(o)),this.isNegative()?a.negate():a},u.prototype.modInv=p.prototype.modInv=l.prototype.modInv,l.prototype.next=function(){var o=this.value;return this.sign?$(o,1,this.sign):new l(I(o,1),this.sign)},p.prototype.next=function(){var o=this.value;return o+1<r?new p(o+1):new l(i,!1)},u.prototype.next=function(){return new u(this.value+BigInt(1))},l.prototype.prev=function(){var o=this.value;return this.sign?new l(I(o,1),!0):$(o,1,this.sign)},p.prototype.prev=function(){var o=this.value;return o-1>-r?new p(o-1):new l(i,!0)},u.prototype.prev=function(){return new u(this.value-BigInt(1))};for(var W=[1];2*W[W.length-1]<=e;)W.push(2*W[W.length-1]);var nt=W.length,Y=W[nt-1];function st(o){return Math.abs(o)<=e}l.prototype.shiftLeft=function(o){var a=k(o).toJSNumber();if(!st(a))throw new Error(String(a)+" is too large for shifting.");if(a<0)return this.shiftRight(-a);var d=this;if(d.isZero())return d;for(;a>=nt;)d=d.multiply(Y),a-=nt-1;return d.multiply(W[a])},u.prototype.shiftLeft=p.prototype.shiftLeft=l.prototype.shiftLeft,l.prototype.shiftRight=function(o){var a,d=k(o).toJSNumber();if(!st(d))throw new Error(String(d)+" is too large for shifting.");if(d<0)return this.shiftLeft(-d);for(var h=this;d>=nt;){if(h.isZero()||h.isNegative()&&h.isUnit())return h;a=gt(h,Y),h=a[1].isNegative()?a[0].prev():a[0],d-=nt-1}return a=gt(h,W[d]),a[1].isNegative()?a[0].prev():a[0]},u.prototype.shiftRight=p.prototype.shiftRight=l.prototype.shiftRight;function at(o,a,d){a=k(a);for(var h=o.isNegative(),w=a.isNegative(),m=h?o.not():o,g=w?a.not():a,D=0,S=0,K=null,V=null,z=[];!m.isZero()||!g.isZero();)K=gt(m,Y),D=K[1].toJSNumber(),h&&(D=Y-1-D),V=gt(g,Y),S=V[1].toJSNumber(),w&&(S=Y-1-S),m=K[0],g=V[0],z.push(d(D,S));for(var J=d(h?1:0,w?1:0)!==0?yt(-1):yt(0),Ct=z.length-1;Ct>=0;Ct-=1)J=J.multiply(Y).add(yt(z[Ct]));return J}l.prototype.not=function(){return this.negate().prev()},u.prototype.not=p.prototype.not=l.prototype.not,l.prototype.and=function(o){return at(this,o,function(a,d){return a&d})},u.prototype.and=p.prototype.and=l.prototype.and,l.prototype.or=function(o){return at(this,o,function(a,d){return a|d})},u.prototype.or=p.prototype.or=l.prototype.or,l.prototype.xor=function(o){return at(this,o,function(a,d){return a^d})},u.prototype.xor=p.prototype.xor=l.prototype.xor;var ut=1<<30,ht=(e&-e)*(e&-e)|ut;function tt(o){var a=o.value,d=typeof a=="number"?a|ut:typeof a=="bigint"?a|BigInt(ut):a[0]+a[1]*e|ht;return d&-d}function pt(o,a){if(a.compareTo(o)<=0){var d=pt(o,a.square(a)),h=d.p,w=d.e,m=h.multiply(a);return m.compareTo(o)<=0?{p:m,e:w*2+1}:{p:h,e:w*2}}return{p:yt(1),e:0}}l.prototype.bitLength=function(){var o=this;return o.compareTo(yt(0))<0&&(o=o.negate().subtract(yt(1))),o.compareTo(yt(0))===0?yt(0):yt(pt(o,yt(2)).e).add(yt(1))},u.prototype.bitLength=p.prototype.bitLength=l.prototype.bitLength;function dt(o,a){return o=k(o),a=k(a),o.greater(a)?o:a}function ct(o,a){return o=k(o),a=k(a),o.lesser(a)?o:a}function ft(o,a){if(o=k(o).abs(),a=k(a).abs(),o.equals(a))return o;if(o.isZero())return a;if(a.isZero())return o;for(var d=c[1],h,w;o.isEven()&&a.isEven();)h=ct(tt(o),tt(a)),o=o.divide(h),a=a.divide(h),d=d.multiply(h);for(;o.isEven();)o=o.divide(tt(o));do{for(;a.isEven();)a=a.divide(tt(a));o.greater(a)&&(w=a,a=o,o=w),a=a.subtract(o)}while(!a.isZero());return d.isUnit()?o:o.multiply(d)}function mt(o,a){return o=k(o).abs(),a=k(a).abs(),o.divide(ft(o,a)).multiply(a)}function vt(o,a,d){o=k(o),a=k(a);var h=d||Math.random,w=ct(o,a),m=dt(o,a),g=m.subtract(w).add(1);if(g.isSmall)return w.add(Math.floor(h()*g));for(var D=me(g,e).value,S=[],K=!0,V=0;V<D.length;V++){var z=K?D[V]+(V+1<D.length?D[V+1]/e:0):e,J=M(h()*z);S.push(J),J<D[V]&&(K=!1)}return w.add(c.fromArray(S,e,!1))}var wt=function(o,a,d,h){d=d||s,o=String(o),h||(o=o.toLowerCase(),d=d.toLowerCase());var w=o.length,m,g=Math.abs(a),D={};for(m=0;m<d.length;m++)D[d[m]]=m;for(m=0;m<w;m++){var S=o[m];if(S!=="-"&&S in D&&D[S]>=g){if(S==="1"&&g===1)continue;throw new Error(S+" is not a valid digit in base "+a+".")}}a=k(a);var K=[],V=o[0]==="-";for(m=V?1:0;m<o.length;m++){var S=o[m];if(S in D)K.push(k(D[S]));else if(S==="<"){var z=m;do m++;while(o[m]!==">"&&m<o.length);K.push(k(o.slice(z+1,m)))}else throw new Error(S+" is not a valid character")}return wn(K,a,V)};function wn(o,a,d){var h=c[0],w=c[1],m;for(m=o.length-1;m>=0;m--)h=h.add(o[m].times(w)),w=w.times(a);return d?h.negate():h}function Oo(o,a){return a=a||s,o<a.length?a[o]:"<"+o+">"}function me(o,a){if(a=yt(a),a.isZero()){if(o.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(a.equals(-1)){if(o.isZero())return{value:[0],isNegative:!1};if(o.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-o.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var d=Array.apply(null,Array(o.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return d.unshift([1]),{value:[].concat.apply([],d),isNegative:!1}}var h=!1;if(o.isNegative()&&a.isPositive()&&(h=!0,o=o.abs()),a.isUnit())return o.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(o.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:h};for(var w=[],m=o,g;m.isNegative()||m.compareAbs(a)>=0;){g=m.divmod(a),m=g.quotient;var D=g.remainder;D.isNegative()&&(D=a.minus(D).abs(),m=m.next()),w.push(D.toJSNumber())}return w.push(m.toJSNumber()),{value:w.reverse(),isNegative:h}}function bn(o,a,d){var h=me(o,a);return(h.isNegative?"-":"")+h.value.map(function(w){return Oo(w,d)}).join("")}l.prototype.toArray=function(o){return me(this,o)},p.prototype.toArray=function(o){return me(this,o)},u.prototype.toArray=function(o){return me(this,o)},l.prototype.toString=function(o,a){if(o===t&&(o=10),o!==10)return bn(this,o,a);for(var d=this.value,h=d.length,w=String(d[--h]),m="0000000",g;--h>=0;)g=String(d[h]),w+=m.slice(g.length)+g;var D=this.sign?"-":"";return D+w},p.prototype.toString=function(o,a){return o===t&&(o=10),o!=10?bn(this,o,a):String(this.value)},u.prototype.toString=p.prototype.toString,u.prototype.toJSON=l.prototype.toJSON=p.prototype.toJSON=function(){return this.toString()},l.prototype.valueOf=function(){return parseInt(this.toString(),10)},l.prototype.toJSNumber=l.prototype.valueOf,p.prototype.valueOf=function(){return this.value},p.prototype.toJSNumber=p.prototype.valueOf,u.prototype.valueOf=u.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function xn(o){if(y(+o)){var a=+o;if(a===M(a))return f?new u(BigInt(a)):new p(a);throw new Error("Invalid integer: "+o)}var d=o[0]==="-";d&&(o=o.slice(1));var h=o.split(/e/i);if(h.length>2)throw new Error("Invalid integer: "+h.join("e"));if(h.length===2){var w=h[1];if(w[0]==="+"&&(w=w.slice(1)),w=+w,w!==M(w)||!y(w))throw new Error("Invalid integer: "+w+" is not a valid exponent.");var m=h[0],g=m.indexOf(".");if(g>=0&&(w-=m.length-g-1,m=m.slice(0,g)+m.slice(g+1)),w<0)throw new Error("Cannot include negative exponent part for integers");m+=new Array(w+1).join("0"),o=m}var D=/^([0-9][0-9]*)$/.test(o);if(!D)throw new Error("Invalid integer: "+o);if(f)return new u(BigInt(d?"-"+o:o));for(var S=[],K=o.length,V=n,z=K-V;K>0;)S.push(+o.slice(z,K)),z-=V,z<0&&(z=0),K-=V;return E(S),new l(S,d)}function ko(o){if(f)return new u(BigInt(o));if(y(o)){if(o!==M(o))throw new Error(o+" is not an integer.");return new p(o)}return xn(o.toString())}function k(o){return typeof o=="number"?ko(o):typeof o=="string"?xn(o):typeof o=="bigint"?new u(o):o}for(var Vt=0;Vt<1e3;Vt++)c[Vt]=k(Vt),Vt>0&&(c[-Vt]=k(-Vt));return c.one=c[1],c.zero=c[0],c.minusOne=c[-1],c.max=dt,c.min=ct,c.gcd=ft,c.lcm=mt,c.isInstance=function(o){return o instanceof l||o instanceof p||o instanceof u},c.randBetween=vt,c.fromArray=function(o,a,d){return wn(o.map(k),k(a||10),d)},c}();typeof We<"u"&&We.hasOwnProperty("exports")&&(We.exports=yt);typeof define=="function"&&define.amd&&define(function(){return yt})});function Gt(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));let n=new Uint8Array(e),r=0;for(let i of t)n.set(i,r),r+=i.length;return n}function re(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==e[n])return!1;return!0}var fr={};It(fr,{identity:()=>Vo});function Ko(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),f=s.charCodeAt(0);if(n[f]!==255)throw new TypeError(s+" is ambiguous");n[f]=i}var c=t.length,l=t.charAt(0),p=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function y(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 A=0,M=0,N=0,F=E.length;N!==F&&E[N]===0;)N++,A++;for(var I=(F-N)*u+1>>>0,P=new Uint8Array(I);N!==F;){for(var O=E[N],$=0,v=I-1;(O!==0||$<M)&&v!==-1;v--,$++)O+=256*P[v]>>>0,P[v]=O%c>>>0,O=O/c>>>0;if(O!==0)throw new Error("Non-zero carry");M=$,N++}for(var b=I-M;b!==I&&P[b]===0;)b++;for(var q=l.repeat(A);b<I;++b)q+=t.charAt(P[b]);return q}function x(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var A=0;if(E[A]!==" "){for(var M=0,N=0;E[A]===l;)M++,A++;for(var F=(E.length-A)*p+1>>>0,I=new Uint8Array(F);E[A];){var P=n[E.charCodeAt(A)];if(P===255)return;for(var O=0,$=F-1;(P!==0||O<N)&&$!==-1;$--,O++)P+=c*I[$]>>>0,I[$]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");N=O,A++}if(E[A]!==" "){for(var v=F-N;v!==F&&I[v]===0;)v++;for(var b=new Uint8Array(M+(F-v)),q=M;v!==F;)b[q++]=I[v++];return b}}}function L(E){var A=x(E);if(A)return A;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:x,decode:L}}var $o=Ko,qo=$o,gn=qo;var Ac=new Uint8Array(0);var En=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==e[n])return!1;return!0},Ft=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")};var Sn=t=>new TextEncoder().encode(t),An=t=>new TextDecoder().decode(t);var sr=class{constructor(e,n,r){this.name=e,this.prefix=n,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ar=class{constructor(e,n,r){if(this.name=e,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r}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 _n(this,e)}},ur=class{constructor(e){this.decoders=e}or(e){return _n(this,e)}decode(e){let n=e[0],r=this.decoders[n];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},_n=(t,e)=>new ur({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),cr=class{constructor(e,n,r,i){this.name=e,this.prefix=n,this.baseEncode=r,this.baseDecode=i,this.encoder=new sr(e,n,r),this.decoder=new ar(e,n,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ne=({name:t,prefix:e,encode:n,decode:r})=>new cr(t,e,n,r),Kt=({prefix:t,name:e,alphabet:n})=>{let{encode:r,decode:i}=gn(n,e);return ne({prefix:t,name:e,encode:r,decode:s=>Ft(i(s))})},zo=(t,e,n,r)=>{let i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;let f=new Uint8Array(s*n/8|0),c=0,l=0,p=0;for(let u=0;u<s;++u){let y=i[t[u]];if(y===void 0)throw new SyntaxError(`Non-${r} character`);l=l<<n|y,c+=n,c>=8&&(c-=8,f[p++]=255&l>>c)}if(c>=n||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return f},Ho=(t,e,n)=>{let r=e[e.length-1]==="=",i=(1<<n)-1,s="",f=0,c=0;for(let l=0;l<t.length;++l)for(c=c<<8|t[l],f+=8;f>n;)f-=n,s+=e[i&c>>f];if(f&&(s+=e[i&c<<n-f]),r)for(;s.length*n&7;)s+="=";return s},lt=({name:t,prefix:e,bitsPerChar:n,alphabet:r})=>ne({prefix:e,name:t,encode(i){return Ho(i,r,n)},decode(i){return zo(i,r,n,t)}});var Vo=ne({prefix:"\0",name:"identity",encode:t=>An(t),decode:t=>Sn(t)});var lr={};It(lr,{base2:()=>Go});var Go=lt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pr={};It(pr,{base8:()=>Jo});var Jo=lt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var dr={};It(dr,{base10:()=>Xo});var Xo=Kt({prefix:"9",name:"base10",alphabet:"0123456789"});var hr={};It(hr,{base16:()=>Zo,base16upper:()=>Wo});var Zo=lt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Wo=lt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var yr={};It(yr,{base32:()=>ie,base32hex:()=>ts,base32hexpad:()=>rs,base32hexpadupper:()=>ns,base32hexupper:()=>es,base32pad:()=>Yo,base32padupper:()=>jo,base32upper:()=>Qo,base32z:()=>is});var ie=lt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qo=lt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Yo=lt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),jo=lt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ts=lt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),es=lt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rs=lt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ns=lt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),is=lt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mr={};It(mr,{base36:()=>os,base36upper:()=>ss});var os=Kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ss=Kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var vr={};It(vr,{base58btc:()=>Bt,base58flickr:()=>as});var Bt=Kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),as=Kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var wr={};It(wr,{base64:()=>us,base64pad:()=>cs,base64url:()=>fs,base64urlpad:()=>ls});var us=lt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),cs=lt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fs=lt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ls=lt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var br={};It(br,{base256emoji:()=>ms});var In=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}"),ps=In.reduce((t,e,n)=>(t[n]=e,t),[]),ds=In.reduce((t,e,n)=>(t[e.codePointAt(0)]=n,t),[]);function hs(t){return t.reduce((e,n)=>(e+=ps[n],e),"")}function ys(t){let e=[];for(let n of t){let r=ds[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);e.push(r)}return new Uint8Array(e)}var ms=ne({prefix:"\u{1F680}",name:"base256emoji",encode:hs,decode:ys});var Er={};It(Er,{sha256:()=>Ts,sha512:()=>Ms});var vs=Bn,Un=128,ws=127,bs=~ws,xs=Math.pow(2,31);function Bn(t,e,n){e=e||[],n=n||0;for(var r=n;t>=xs;)e[n++]=t&255|Un,t/=128;for(;t&bs;)e[n++]=t&255|Un,t>>>=7;return e[n]=t|0,Bn.bytes=n-r+1,e}var Ds=xr,gs=128,Pn=127;function xr(t,r){var n=0,r=r||0,i=0,s=r,f,c=t.length;do{if(s>=c)throw xr.bytes=0,new RangeError("Could not decode varint");f=t[s++],n+=i<28?(f&Pn)<<i:(f&Pn)*Math.pow(2,i),i+=7}while(f>=gs);return xr.bytes=s-r,n}var Es=Math.pow(2,7),Ss=Math.pow(2,14),As=Math.pow(2,21),Cs=Math.pow(2,28),_s=Math.pow(2,35),Is=Math.pow(2,42),Us=Math.pow(2,49),Ps=Math.pow(2,56),Bs=Math.pow(2,63),Ls=function(t){return t<Es?1:t<Ss?2:t<As?3:t<Cs?4:t<_s?5:t<Is?6:t<Us?7:t<Ps?8:t<Bs?9:10},Ns={encode:vs,decode:Ds,encodingLength:Ls},Fs=Ns,ve=Fs;var we=(t,e=0)=>[ve.decode(t,e),ve.decode.bytes],oe=(t,e,n=0)=>(ve.encode(t,e,n),e),se=t=>ve.encodingLength(t);var Jt=(t,e)=>{let n=e.byteLength,r=se(t),i=r+se(n),s=new Uint8Array(i+n);return oe(t,s,0),oe(n,s,r),s.set(e,i),new ae(t,n,e,s)},Ln=t=>{let e=Ft(t),[n,r]=we(e),[i,s]=we(e.subarray(r)),f=e.subarray(r+s);if(f.byteLength!==i)throw new Error("Incorrect length");return new ae(n,i,f,e)},Nn=(t,e)=>t===e?!0:t.code===e.code&&t.size===e.size&&En(t.bytes,e.bytes),ae=class{constructor(e,n,r,i){this.code=e,this.size=n,this.digest=r,this.bytes=i}};var gr=({name:t,code:e,encode:n})=>new Dr(t,e,n),Dr=class{constructor(e,n,r){this.name=e,this.code=n,this.encode=r}digest(e){if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Jt(this.code,n):n.then(r=>Jt(this.code,r))}else throw Error("Unknown type, must be binary type")}};var Tn=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Ts=gr({name:"sha2-256",code:18,encode:Tn("SHA-256")}),Ms=gr({name:"sha2-512",code:19,encode:Tn("SHA-512")});var Sr={};It(Sr,{identity:()=>ks});var Mn=0,Rs="identity",Rn=Ft,Os=t=>Jt(Mn,Rn(t)),ks={code:Mn,name:Rs,encode:Rn,digest:Os};var Gc=new TextEncoder,Jc=new TextDecoder;var ke=class t{constructor(e,n,r,i){this.code=n,this.version=e,this.multihash=r,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Oe,byteLength:Oe,code:Re,version:Re,multihash:Re,bytes:Re,_baseCache:Oe,asCID:Oe})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:n}=this;if(e!==xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==Vs)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(n)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:n}=this.multihash,r=Jt(e,n);return t.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&Nn(this.multihash,e.multihash)}toString(e){let{bytes:n,version:r,_baseCache:i}=this;switch(r){case 0:return zs(n,i,e||Bt.encoder);default:return Hs(n,i,e||ie.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Js(/^0\.0/,Xs),!!(e&&(e[kn]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof t)return e;if(e!=null&&e.asCID===e){let{version:n,code:r,multihash:i,bytes:s}=e;return new t(n,r,i,s||On(n,r,i.bytes))}else if(e!=null&&e[kn]===!0){let{version:n,multihash:r,code:i}=e,s=Ln(r);return t.create(n,i,s)}else return null}static create(e,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(n!==xe)throw new Error(`Version 0 CID must use dag-pb (code: ${xe}) block encoding`);return new t(e,n,r,r.bytes)}case 1:{let i=On(e,n,r.bytes);return new t(e,n,r,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,xe,e)}static createV1(e,n){return t.create(1,e,n)}static decode(e){let[n,r]=t.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return n}static decodeFirst(e){let n=t.inspectBytes(e),r=n.size-n.multihashSize,i=Ft(e.subarray(r,r+n.multihashSize));if(i.byteLength!==n.multihashSize)throw new Error("Incorrect length");let s=i.subarray(n.multihashSize-n.digestSize),f=new ae(n.multihashCode,n.digestSize,s,i);return[n.version===0?t.createV0(f):t.createV1(n.codec,f),e.subarray(n.size)]}static inspectBytes(e){let n=0,r=()=>{let[y,x]=we(e.subarray(n));return n+=x,y},i=r(),s=xe;if(i===18?(i=0,n=0):i===1&&(s=r()),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let f=n,c=r(),l=r(),p=n+l,u=p-f;return{version:i,codec:s,multihashCode:c,digestSize:l,multihashSize:u,size:p}}static parse(e,n){let[r,i]=qs(e,n),s=t.decode(i);return s._baseCache.set(r,e),s}},qs=(t,e)=>{switch(t[0]){case"Q":{let n=e||Bt;return[Bt.prefix,n.decode(`${Bt.prefix}${t}`)]}case Bt.prefix:{let n=e||Bt;return[Bt.prefix,n.decode(t)]}case ie.prefix:{let n=e||ie;return[ie.prefix,n.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},zs=(t,e,n)=>{let{prefix:r}=n;if(r!==Bt.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let i=e.get(r);if(i==null){let s=n.encode(t).slice(1);return e.set(r,s),s}else return i},Hs=(t,e,n)=>{let{prefix:r}=n,i=e.get(r);if(i==null){let s=n.encode(t);return e.set(r,s),s}else return i},xe=112,Vs=18,On=(t,e,n)=>{let r=se(t),i=r+se(e),s=new Uint8Array(i+n.byteLength);return oe(t,s,0),oe(e,s,r),s.set(n,i),s},kn=Symbol.for("@ipld/js-cid/CID"),Re={writable:!1,configurable:!1,enumerable:!0},Oe={writable:!1,enumerable:!1,configurable:!1},Gs="0.0.0-dev",Js=(t,e)=>{if(t.test(Gs))console.warn(e);else throw new Error(e)},Xs=`CID.isCID(v) is deprecated and will be removed in the next major release.
1
+ import{a as Dn,b as Ut,c as It,d as ir,e as or}from"./chunk-BKKH6BET.min.js";var zn=Ut($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.BrowserRandomSource=void 0;var qn=65536,_r=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let n=new Uint8Array(e);for(let r=0;r<n.length;r+=qn)this._crypto.getRandomValues(n.subarray(r,r+Math.min(n.length-r,qn)));return n}};$e.BrowserRandomSource=_r});var De=Ut(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});function Ws(t){for(var e=0;e<t.length;e++)t[e]=0;return t}Ir.wipe=Ws});var Hn=Ut(()=>{"use strict"});var Vn=Ut(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.NodeRandomSource=void 0;var Qs=De(),Ur=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Dn<"u"){let e=Hn();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let n=this._crypto.randomBytes(e);if(n.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let r=new Uint8Array(e);for(let i=0;i<r.length;i++)r[i]=n[i];return(0,Qs.wipe)(n),r}};qe.NodeRandomSource=Ur});var Gn=Ut(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.SystemRandomSource=void 0;var Ys=zn(),js=Vn(),Pr=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Ys.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new js.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};ze.SystemRandomSource=Pr});var Jn=Ut(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});function ta(t,e){var n=t>>>16&65535,r=t&65535,i=e>>>16&65535,s=e&65535;return r*s+(n*s+r*i<<16>>>0)|0}_t.mul=Math.imul||ta;function ea(t,e){return t+e|0}_t.add=ea;function ra(t,e){return t-e|0}_t.sub=ra;function na(t,e){return t<<e|t>>>32-e}_t.rotl=na;function ia(t,e){return t<<32-e|t>>>e}_t.rotr=ia;function oa(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t}_t.isInteger=Number.isInteger||oa;_t.MAX_SAFE_INTEGER=9007199254740991;_t.isSafeInteger=function(t){return _t.isInteger(t)&&t>=-_t.MAX_SAFE_INTEGER&&t<=_t.MAX_SAFE_INTEGER}});var Tr=Ut(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});var Xn=Jn();function sa(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}H.readInt16BE=sa;function aa(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}H.readUint16BE=aa;function ua(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}H.readInt16LE=ua;function ca(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}H.readUint16LE=ca;function Zn(t,e,n){return e===void 0&&(e=new Uint8Array(2)),n===void 0&&(n=0),e[n+0]=t>>>8,e[n+1]=t>>>0,e}H.writeUint16BE=Zn;H.writeInt16BE=Zn;function Wn(t,e,n){return e===void 0&&(e=new Uint8Array(2)),n===void 0&&(n=0),e[n+0]=t>>>0,e[n+1]=t>>>8,e}H.writeUint16LE=Wn;H.writeInt16LE=Wn;function Br(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}H.readInt32BE=Br;function Lr(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}H.readUint32BE=Lr;function Nr(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}H.readInt32LE=Nr;function Fr(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}H.readUint32LE=Fr;function He(t,e,n){return e===void 0&&(e=new Uint8Array(4)),n===void 0&&(n=0),e[n+0]=t>>>24,e[n+1]=t>>>16,e[n+2]=t>>>8,e[n+3]=t>>>0,e}H.writeUint32BE=He;H.writeInt32BE=He;function Ve(t,e,n){return e===void 0&&(e=new Uint8Array(4)),n===void 0&&(n=0),e[n+0]=t>>>0,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24,e}H.writeUint32LE=Ve;H.writeInt32LE=Ve;function fa(t,e){e===void 0&&(e=0);var n=Br(t,e),r=Br(t,e+4);return n*4294967296+r-(r>>31)*4294967296}H.readInt64BE=fa;function la(t,e){e===void 0&&(e=0);var n=Lr(t,e),r=Lr(t,e+4);return n*4294967296+r}H.readUint64BE=la;function pa(t,e){e===void 0&&(e=0);var n=Nr(t,e),r=Nr(t,e+4);return r*4294967296+n-(n>>31)*4294967296}H.readInt64LE=pa;function da(t,e){e===void 0&&(e=0);var n=Fr(t,e),r=Fr(t,e+4);return r*4294967296+n}H.readUint64LE=da;function Qn(t,e,n){return e===void 0&&(e=new Uint8Array(8)),n===void 0&&(n=0),He(t/4294967296>>>0,e,n),He(t>>>0,e,n+4),e}H.writeUint64BE=Qn;H.writeInt64BE=Qn;function Yn(t,e,n){return e===void 0&&(e=new Uint8Array(8)),n===void 0&&(n=0),Ve(t>>>0,e,n),Ve(t/4294967296>>>0,e,n+4),e}H.writeUint64LE=Yn;H.writeInt64LE=Yn;function ha(t,e,n){if(n===void 0&&(n=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-n)throw new Error("readUintBE: array is too short for the given bitLength");for(var r=0,i=1,s=t/8+n-1;s>=n;s--)r+=e[s]*i,i*=256;return r}H.readUintBE=ha;function ya(t,e,n){if(n===void 0&&(n=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-n)throw new Error("readUintLE: array is too short for the given bitLength");for(var r=0,i=1,s=n;s<n+t/8;s++)r+=e[s]*i,i*=256;return r}H.readUintLE=ya;function ma(t,e,n,r){if(n===void 0&&(n=new Uint8Array(t/8)),r===void 0&&(r=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!Xn.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=t/8+r-1;s>=r;s--)n[s]=e/i&255,i*=256;return n}H.writeUintBE=ma;function va(t,e,n,r){if(n===void 0&&(n=new Uint8Array(t/8)),r===void 0&&(r=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Xn.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=r;s<r+t/8;s++)n[s]=e/i&255,i*=256;return n}H.writeUintLE=va;function wa(t,e){e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat32(e)}H.readFloat32BE=wa;function ba(t,e){e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat32(e,!0)}H.readFloat32LE=ba;function xa(t,e){e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat64(e)}H.readFloat64BE=xa;function Da(t,e){e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.getFloat64(e,!0)}H.readFloat64LE=Da;function ga(t,e,n){e===void 0&&(e=new Uint8Array(4)),n===void 0&&(n=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setFloat32(n,t),e}H.writeFloat32BE=ga;function Ea(t,e,n){e===void 0&&(e=new Uint8Array(4)),n===void 0&&(n=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setFloat32(n,t,!0),e}H.writeFloat32LE=Ea;function Sa(t,e,n){e===void 0&&(e=new Uint8Array(8)),n===void 0&&(n=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setFloat64(n,t),e}H.writeFloat64BE=Sa;function Aa(t,e,n){e===void 0&&(e=new Uint8Array(8)),n===void 0&&(n=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setFloat64(n,t,!0),e}H.writeFloat64LE=Aa});var ri=Ut(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.randomStringForEntropy=xt.randomString=xt.randomUint32=xt.randomBytes=xt.defaultRandomSource=void 0;var Ca=Gn(),_a=Tr(),jn=De();xt.defaultRandomSource=new Ca.SystemRandomSource;function Mr(t,e=xt.defaultRandomSource){return e.randomBytes(t)}xt.randomBytes=Mr;function Ia(t=xt.defaultRandomSource){let e=Mr(4,t),n=(0,_a.readUint32LE)(e);return(0,jn.wipe)(e),n}xt.randomUint32=Ia;var ti="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function ei(t,e=ti,n=xt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let r="",i=e.length,s=256-256%i;for(;t>0;){let f=Mr(Math.ceil(t*256/s),n);for(let c=0;c<f.length&&t>0;c++){let l=f[c];l<s&&(r+=e.charAt(l%i),t--)}(0,jn.wipe)(f)}return r}xt.randomString=ei;function Ua(t,e=ti,n=xt.defaultRandomSource){let r=Math.ceil(t/(Math.log(e.length)/Math.LN2));return ei(r,e,n)}xt.randomStringForEntropy=Ua});var oi=Ut(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});var ce=Tr(),ue=De();Tt.DIGEST_LENGTH=64;Tt.BLOCK_SIZE=128;var ii=function(){function t(){this.digestLength=Tt.DIGEST_LENGTH,this.blockSize=Tt.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return t.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},t.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},t.prototype.clean=function(){ue.wipe(this._buffer),ue.wipe(this._tempHi),ue.wipe(this._tempLo),this.reset()},t.prototype.update=function(e,n){if(n===void 0&&(n=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var r=0;if(this._bytesHashed+=n,this._bufferLength>0){for(;this._bufferLength<Tt.BLOCK_SIZE&&n>0;)this._buffer[this._bufferLength++]=e[r++],n--;this._bufferLength===this.blockSize&&(Rr(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(n>=this.blockSize&&(r=Rr(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,r,n),n%=this.blockSize);n>0;)this._buffer[this._bufferLength++]=e[r++],n--;return this},t.prototype.finish=function(e){if(!this._finished){var n=this._bytesHashed,r=this._bufferLength,i=n/536870912|0,s=n<<3,f=n%128<112?128:256;this._buffer[r]=128;for(var c=r+1;c<f-8;c++)this._buffer[c]=0;ce.writeUint32BE(i,this._buffer,f-8),ce.writeUint32BE(s,this._buffer,f-4),Rr(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,f),this._finished=!0}for(var c=0;c<this.digestLength/8;c++)ce.writeUint32BE(this._stateHi[c],e,c*8),ce.writeUint32BE(this._stateLo[c],e,c*8+4);return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},t.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},t.prototype.cleanSavedState=function(e){ue.wipe(e.stateHi),ue.wipe(e.stateLo),e.buffer&&ue.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},t}();Tt.SHA512=ii;var ni=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function Rr(t,e,n,r,i,s,f){for(var c=n[0],l=n[1],p=n[2],u=n[3],y=n[4],x=n[5],L=n[6],E=n[7],A=r[0],M=r[1],N=r[2],F=r[3],I=r[4],P=r[5],O=r[6],$=r[7],v,b,q,G,U,C,_,B;f>=128;){for(var ot=0;ot<16;ot++){var et=8*ot+s;t[ot]=ce.readUint32BE(i,et),e[ot]=ce.readUint32BE(i,et+4)}for(var ot=0;ot<80;ot++){var gt=c,At=l,Ht=p,rt=u,W=y,nt=x,Y=L,st=E,at=A,ut=M,ht=N,tt=F,pt=I,dt=P,ct=O,ft=$;if(v=E,b=$,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=(y>>>14|I<<18)^(y>>>18|I<<14)^(I>>>9|y<<23),b=(I>>>14|y<<18)^(I>>>18|y<<14)^(y>>>9|I<<23),U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,v=y&x^~y&L,b=I&P^~I&O,U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,v=ni[ot*2],b=ni[ot*2+1],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,v=t[ot%16],b=e[ot%16],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,q=_&65535|B<<16,G=U&65535|C<<16,v=q,b=G,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=(c>>>28|A<<4)^(A>>>2|c<<30)^(A>>>7|c<<25),b=(A>>>28|c<<4)^(c>>>2|A<<30)^(c>>>7|A<<25),U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,v=c&l^c&p^l&p,b=A&M^A&N^M&N,U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,st=_&65535|B<<16,ft=U&65535|C<<16,v=rt,b=tt,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=q,b=G,U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,rt=_&65535|B<<16,tt=U&65535|C<<16,l=gt,p=At,u=Ht,y=rt,x=W,L=nt,E=Y,c=st,M=at,N=ut,F=ht,I=tt,P=pt,O=dt,$=ct,A=ft,ot%16===15)for(var et=0;et<16;et++)v=t[et],b=e[et],U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=t[(et+9)%16],b=e[(et+9)%16],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,q=t[(et+1)%16],G=e[(et+1)%16],v=(q>>>1|G<<31)^(q>>>8|G<<24)^q>>>7,b=(G>>>1|q<<31)^(G>>>8|q<<24)^(G>>>7|q<<25),U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,q=t[(et+14)%16],G=e[(et+14)%16],v=(q>>>19|G<<13)^(G>>>29|q<<3)^q>>>6,b=(G>>>19|q<<13)^(q>>>29|G<<3)^(G>>>6|q<<26),U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,t[et]=_&65535|B<<16,e[et]=U&65535|C<<16}v=c,b=A,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[0],b=r[0],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[0]=c=_&65535|B<<16,r[0]=A=U&65535|C<<16,v=l,b=M,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[1],b=r[1],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[1]=l=_&65535|B<<16,r[1]=M=U&65535|C<<16,v=p,b=N,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[2],b=r[2],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[2]=p=_&65535|B<<16,r[2]=N=U&65535|C<<16,v=u,b=F,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[3],b=r[3],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[3]=u=_&65535|B<<16,r[3]=F=U&65535|C<<16,v=y,b=I,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[4],b=r[4],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[4]=y=_&65535|B<<16,r[4]=I=U&65535|C<<16,v=x,b=P,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[5],b=r[5],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[5]=x=_&65535|B<<16,r[5]=P=U&65535|C<<16,v=L,b=O,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[6],b=r[6],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[6]=L=_&65535|B<<16,r[6]=O=U&65535|C<<16,v=E,b=$,U=b&65535,C=b>>>16,_=v&65535,B=v>>>16,v=n[7],b=r[7],U+=b&65535,C+=b>>>16,_+=v&65535,B+=v>>>16,C+=U>>>16,_+=C>>>16,B+=_>>>16,n[7]=E=_&65535|B<<16,r[7]=$=U&65535|C<<16,s+=128,f-=128}return s}function Pa(t){var e=new ii;e.update(t);var n=e.digest();return e.clean(),n}Tt.hash=Pa});var Vr=Ut(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.convertSecretKeyToX25519=X.convertPublicKeyToX25519=X.verify=X.sign=X.extractPublicKeyFromSecretKey=X.generateKeyPair=X.generateKeyPairFromSeed=X.SEED_LENGTH=X.SECRET_KEY_LENGTH=X.PUBLIC_KEY_LENGTH=X.SIGNATURE_LENGTH=void 0;var Ba=ri(),ge=oi(),fi=De();X.SIGNATURE_LENGTH=64;X.PUBLIC_KEY_LENGTH=32;X.SECRET_KEY_LENGTH=64;X.SEED_LENGTH=32;function T(t){let e=new Float64Array(16);if(t)for(let n=0;n<t.length;n++)e[n]=t[n];return e}var La=new Uint8Array(32);La[0]=9;var Kr=T(),fe=T([1]),Na=T([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),Fa=T([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),si=T([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),ai=T([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Ta=T([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function qt(t,e){for(let n=0;n<16;n++)t[n]=e[n]|0}function Or(t){let e=1;for(let n=0;n<16;n++){let r=t[n]+e+65535;e=Math.floor(r/65536),t[n]=r-e*65536}t[0]+=e-1+37*(e-1)}function li(t,e,n){let r=~(n-1);for(let i=0;i<16;i++){let s=r&(t[i]^e[i]);t[i]^=s,e[i]^=s}}function Ee(t,e){let n=T(),r=T();for(let i=0;i<16;i++)r[i]=e[i];Or(r),Or(r),Or(r);for(let i=0;i<2;i++){n[0]=r[0]-65517;for(let f=1;f<15;f++)n[f]=r[f]-65535-(n[f-1]>>16&1),n[f-1]&=65535;n[15]=r[15]-32767-(n[14]>>16&1);let s=n[15]>>16&1;n[14]&=65535,li(r,n,1-s)}for(let i=0;i<16;i++)t[2*i]=r[i]&255,t[2*i+1]=r[i]>>8}function pi(t,e){let n=0;for(let r=0;r<32;r++)n|=t[r]^e[r];return(1&n-1>>>8)-1}function ui(t,e){let n=new Uint8Array(32),r=new Uint8Array(32);return Ee(n,t),Ee(r,e),pi(n,r)}function di(t){let e=new Uint8Array(32);return Ee(e,t),e[0]&1}function Ma(t,e){for(let n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function Xt(t,e,n){for(let r=0;r<16;r++)t[r]=e[r]+n[r]}function Wt(t,e,n){for(let r=0;r<16;r++)t[r]=e[r]-n[r]}function Q(t,e,n){let r,i,s=0,f=0,c=0,l=0,p=0,u=0,y=0,x=0,L=0,E=0,A=0,M=0,N=0,F=0,I=0,P=0,O=0,$=0,v=0,b=0,q=0,G=0,U=0,C=0,_=0,B=0,ot=0,et=0,gt=0,At=0,Ht=0,rt=n[0],W=n[1],nt=n[2],Y=n[3],st=n[4],at=n[5],ut=n[6],ht=n[7],tt=n[8],pt=n[9],dt=n[10],ct=n[11],ft=n[12],mt=n[13],vt=n[14],wt=n[15];r=e[0],s+=r*rt,f+=r*W,c+=r*nt,l+=r*Y,p+=r*st,u+=r*at,y+=r*ut,x+=r*ht,L+=r*tt,E+=r*pt,A+=r*dt,M+=r*ct,N+=r*ft,F+=r*mt,I+=r*vt,P+=r*wt,r=e[1],f+=r*rt,c+=r*W,l+=r*nt,p+=r*Y,u+=r*st,y+=r*at,x+=r*ut,L+=r*ht,E+=r*tt,A+=r*pt,M+=r*dt,N+=r*ct,F+=r*ft,I+=r*mt,P+=r*vt,O+=r*wt,r=e[2],c+=r*rt,l+=r*W,p+=r*nt,u+=r*Y,y+=r*st,x+=r*at,L+=r*ut,E+=r*ht,A+=r*tt,M+=r*pt,N+=r*dt,F+=r*ct,I+=r*ft,P+=r*mt,O+=r*vt,$+=r*wt,r=e[3],l+=r*rt,p+=r*W,u+=r*nt,y+=r*Y,x+=r*st,L+=r*at,E+=r*ut,A+=r*ht,M+=r*tt,N+=r*pt,F+=r*dt,I+=r*ct,P+=r*ft,O+=r*mt,$+=r*vt,v+=r*wt,r=e[4],p+=r*rt,u+=r*W,y+=r*nt,x+=r*Y,L+=r*st,E+=r*at,A+=r*ut,M+=r*ht,N+=r*tt,F+=r*pt,I+=r*dt,P+=r*ct,O+=r*ft,$+=r*mt,v+=r*vt,b+=r*wt,r=e[5],u+=r*rt,y+=r*W,x+=r*nt,L+=r*Y,E+=r*st,A+=r*at,M+=r*ut,N+=r*ht,F+=r*tt,I+=r*pt,P+=r*dt,O+=r*ct,$+=r*ft,v+=r*mt,b+=r*vt,q+=r*wt,r=e[6],y+=r*rt,x+=r*W,L+=r*nt,E+=r*Y,A+=r*st,M+=r*at,N+=r*ut,F+=r*ht,I+=r*tt,P+=r*pt,O+=r*dt,$+=r*ct,v+=r*ft,b+=r*mt,q+=r*vt,G+=r*wt,r=e[7],x+=r*rt,L+=r*W,E+=r*nt,A+=r*Y,M+=r*st,N+=r*at,F+=r*ut,I+=r*ht,P+=r*tt,O+=r*pt,$+=r*dt,v+=r*ct,b+=r*ft,q+=r*mt,G+=r*vt,U+=r*wt,r=e[8],L+=r*rt,E+=r*W,A+=r*nt,M+=r*Y,N+=r*st,F+=r*at,I+=r*ut,P+=r*ht,O+=r*tt,$+=r*pt,v+=r*dt,b+=r*ct,q+=r*ft,G+=r*mt,U+=r*vt,C+=r*wt,r=e[9],E+=r*rt,A+=r*W,M+=r*nt,N+=r*Y,F+=r*st,I+=r*at,P+=r*ut,O+=r*ht,$+=r*tt,v+=r*pt,b+=r*dt,q+=r*ct,G+=r*ft,U+=r*mt,C+=r*vt,_+=r*wt,r=e[10],A+=r*rt,M+=r*W,N+=r*nt,F+=r*Y,I+=r*st,P+=r*at,O+=r*ut,$+=r*ht,v+=r*tt,b+=r*pt,q+=r*dt,G+=r*ct,U+=r*ft,C+=r*mt,_+=r*vt,B+=r*wt,r=e[11],M+=r*rt,N+=r*W,F+=r*nt,I+=r*Y,P+=r*st,O+=r*at,$+=r*ut,v+=r*ht,b+=r*tt,q+=r*pt,G+=r*dt,U+=r*ct,C+=r*ft,_+=r*mt,B+=r*vt,ot+=r*wt,r=e[12],N+=r*rt,F+=r*W,I+=r*nt,P+=r*Y,O+=r*st,$+=r*at,v+=r*ut,b+=r*ht,q+=r*tt,G+=r*pt,U+=r*dt,C+=r*ct,_+=r*ft,B+=r*mt,ot+=r*vt,et+=r*wt,r=e[13],F+=r*rt,I+=r*W,P+=r*nt,O+=r*Y,$+=r*st,v+=r*at,b+=r*ut,q+=r*ht,G+=r*tt,U+=r*pt,C+=r*dt,_+=r*ct,B+=r*ft,ot+=r*mt,et+=r*vt,gt+=r*wt,r=e[14],I+=r*rt,P+=r*W,O+=r*nt,$+=r*Y,v+=r*st,b+=r*at,q+=r*ut,G+=r*ht,U+=r*tt,C+=r*pt,_+=r*dt,B+=r*ct,ot+=r*ft,et+=r*mt,gt+=r*vt,At+=r*wt,r=e[15],P+=r*rt,O+=r*W,$+=r*nt,v+=r*Y,b+=r*st,q+=r*at,G+=r*ut,U+=r*ht,C+=r*tt,_+=r*pt,B+=r*dt,ot+=r*ct,et+=r*ft,gt+=r*mt,At+=r*vt,Ht+=r*wt,s+=38*O,f+=38*$,c+=38*v,l+=38*b,p+=38*q,u+=38*G,y+=38*U,x+=38*C,L+=38*_,E+=38*B,A+=38*ot,M+=38*et,N+=38*gt,F+=38*At,I+=38*Ht,i=1,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=x+i+65535,i=Math.floor(r/65536),x=r-i*65536,r=L+i+65535,i=Math.floor(r/65536),L=r-i*65536,r=E+i+65535,i=Math.floor(r/65536),E=r-i*65536,r=A+i+65535,i=Math.floor(r/65536),A=r-i*65536,r=M+i+65535,i=Math.floor(r/65536),M=r-i*65536,r=N+i+65535,i=Math.floor(r/65536),N=r-i*65536,r=F+i+65535,i=Math.floor(r/65536),F=r-i*65536,r=I+i+65535,i=Math.floor(r/65536),I=r-i*65536,r=P+i+65535,i=Math.floor(r/65536),P=r-i*65536,s+=i-1+37*(i-1),i=1,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=x+i+65535,i=Math.floor(r/65536),x=r-i*65536,r=L+i+65535,i=Math.floor(r/65536),L=r-i*65536,r=E+i+65535,i=Math.floor(r/65536),E=r-i*65536,r=A+i+65535,i=Math.floor(r/65536),A=r-i*65536,r=M+i+65535,i=Math.floor(r/65536),M=r-i*65536,r=N+i+65535,i=Math.floor(r/65536),N=r-i*65536,r=F+i+65535,i=Math.floor(r/65536),F=r-i*65536,r=I+i+65535,i=Math.floor(r/65536),I=r-i*65536,r=P+i+65535,i=Math.floor(r/65536),P=r-i*65536,s+=i-1+37*(i-1),t[0]=s,t[1]=f,t[2]=c,t[3]=l,t[4]=p,t[5]=u,t[6]=y,t[7]=x,t[8]=L,t[9]=E,t[10]=A,t[11]=M,t[12]=N,t[13]=F,t[14]=I,t[15]=P}function Zt(t,e){Q(t,e,e)}function hi(t,e){let n=T(),r;for(r=0;r<16;r++)n[r]=e[r];for(r=253;r>=0;r--)Zt(n,n),r!==2&&r!==4&&Q(n,n,e);for(r=0;r<16;r++)t[r]=n[r]}function Ra(t,e){let n=T(),r;for(r=0;r<16;r++)n[r]=e[r];for(r=250;r>=0;r--)Zt(n,n),r!==1&&Q(n,n,e);for(r=0;r<16;r++)t[r]=n[r]}function $r(t,e){let n=T(),r=T(),i=T(),s=T(),f=T(),c=T(),l=T(),p=T(),u=T();Wt(n,t[1],t[0]),Wt(u,e[1],e[0]),Q(n,n,u),Xt(r,t[0],t[1]),Xt(u,e[0],e[1]),Q(r,r,u),Q(i,t[3],e[3]),Q(i,i,Fa),Q(s,t[2],e[2]),Xt(s,s,s),Wt(f,r,n),Wt(c,s,i),Xt(l,s,i),Xt(p,r,n),Q(t[0],f,c),Q(t[1],p,l),Q(t[2],l,c),Q(t[3],f,p)}function ci(t,e,n){for(let r=0;r<4;r++)li(t[r],e[r],n)}function zr(t,e){let n=T(),r=T(),i=T();hi(i,e[2]),Q(n,e[0],i),Q(r,e[1],i),Ee(t,r),t[31]^=di(n)<<7}function yi(t,e,n){qt(t[0],Kr),qt(t[1],fe),qt(t[2],fe),qt(t[3],Kr);for(let r=255;r>=0;--r){let i=n[r/8|0]>>(r&7)&1;ci(t,e,i),$r(e,t),$r(t,t),ci(t,e,i)}}function Hr(t,e){let n=[T(),T(),T(),T()];qt(n[0],si),qt(n[1],ai),qt(n[2],fe),Q(n[3],si,ai),yi(t,n,e)}function mi(t){if(t.length!==X.SEED_LENGTH)throw new Error(`ed25519: seed must be ${X.SEED_LENGTH} bytes`);let e=(0,ge.hash)(t);e[0]&=248,e[31]&=127,e[31]|=64;let n=new Uint8Array(32),r=[T(),T(),T(),T()];Hr(r,e),zr(n,r);let i=new Uint8Array(64);return i.set(t),i.set(n,32),{publicKey:n,secretKey:i}}X.generateKeyPairFromSeed=mi;function Oa(t){let e=(0,Ba.randomBytes)(32,t),n=mi(e);return(0,fi.wipe)(e),n}X.generateKeyPair=Oa;function ka(t){if(t.length!==X.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${X.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(t.subarray(32))}X.extractPublicKeyFromSecretKey=ka;var kr=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function vi(t,e){let n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i<s;++i)e[i]+=n-16*e[r]*kr[i-(r-32)],n=Math.floor((e[i]+128)/256),e[i]-=n*256;e[i]+=n,e[r]=0}for(n=0,i=0;i<32;i++)e[i]+=n-(e[31]>>4)*kr[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*kr[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=e[r]&255}function qr(t){let e=new Float64Array(64);for(let n=0;n<64;n++)e[n]=t[n];for(let n=0;n<64;n++)t[n]=0;vi(t,e)}function Ka(t,e){let n=new Float64Array(64),r=[T(),T(),T(),T()],i=(0,ge.hash)(t.subarray(0,32));i[0]&=248,i[31]&=127,i[31]|=64;let s=new Uint8Array(64);s.set(i.subarray(32),32);let f=new ge.SHA512;f.update(s.subarray(32)),f.update(e);let c=f.digest();f.clean(),qr(c),Hr(r,c),zr(s,r),f.reset(),f.update(s.subarray(0,32)),f.update(t.subarray(32)),f.update(e);let l=f.digest();qr(l);for(let p=0;p<32;p++)n[p]=c[p];for(let p=0;p<32;p++)for(let u=0;u<32;u++)n[p+u]+=l[p]*i[u];return vi(s.subarray(32),n),s}X.sign=Ka;function wi(t,e){let n=T(),r=T(),i=T(),s=T(),f=T(),c=T(),l=T();return qt(t[2],fe),Ma(t[1],e),Zt(i,t[1]),Q(s,i,Na),Wt(i,i,t[2]),Xt(s,t[2],s),Zt(f,s),Zt(c,f),Q(l,c,f),Q(n,l,i),Q(n,n,s),Ra(n,n),Q(n,n,i),Q(n,n,s),Q(n,n,s),Q(t[0],n,s),Zt(r,t[0]),Q(r,r,s),ui(r,i)&&Q(t[0],t[0],Ta),Zt(r,t[0]),Q(r,r,s),ui(r,i)?-1:(di(t[0])===e[31]>>7&&Wt(t[0],Kr,t[0]),Q(t[3],t[0],t[1]),0)}function $a(t,e,n){let r=new Uint8Array(32),i=[T(),T(),T(),T()],s=[T(),T(),T(),T()];if(n.length!==X.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${X.SIGNATURE_LENGTH} bytes`);if(wi(s,t))return!1;let f=new ge.SHA512;f.update(n.subarray(0,32)),f.update(t),f.update(e);let c=f.digest();return qr(c),yi(i,s,c),Hr(s,n.subarray(32)),$r(i,s),zr(r,i),!pi(n,r)}X.verify=$a;function qa(t){let e=[T(),T(),T(),T()];if(wi(e,t))throw new Error("Ed25519: invalid public key");let n=T(),r=T(),i=e[1];Xt(n,fe,i),Wt(r,fe,i),hi(r,r),Q(n,n,r);let s=new Uint8Array(32);return Ee(s,n),s}X.convertPublicKeyToX25519=qa;function za(t){let e=(0,ge.hash)(t.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let n=new Uint8Array(e.subarray(0,32));return(0,fi.wipe)(e),n}X.convertSecretKeyToX25519=za});var Ii=Ut((jf,We)=>{"use strict";var yt=function(t){"use strict";var e=1e7,n=7,r=9007199254740992,i=x(r),s="0123456789abcdefghijklmnopqrstuvwxyz",f=typeof BigInt=="function";function c(o,a,d,h){return typeof o>"u"?c[0]:typeof a<"u"?+a==10&&!d?k(o):wt(o,a,d,h):k(o)}function l(o,a){this.value=o,this.sign=a,this.isSmall=!1}l.prototype=Object.create(c.prototype);function p(o){this.value=o,this.sign=o<0,this.isSmall=!0}p.prototype=Object.create(c.prototype);function u(o){this.value=o}u.prototype=Object.create(c.prototype);function y(o){return-r<o&&o<r}function x(o){return o<1e7?[o]:o<1e14?[o%1e7,Math.floor(o/1e7)]:[o%1e7,Math.floor(o/1e7)%1e7,Math.floor(o/1e14)]}function L(o){E(o);var a=o.length;if(a<4&&At(o,i)<0)switch(a){case 0:return 0;case 1:return o[0];case 2:return o[0]+o[1]*e;default:return o[0]+(o[1]+o[2]*e)*e}return o}function E(o){for(var a=o.length;o[--a]===0;);o.length=a+1}function A(o){for(var a=new Array(o),d=-1;++d<o;)a[d]=0;return a}function M(o){return o>0?Math.floor(o):Math.ceil(o)}function N(o,a){var d=o.length,h=a.length,w=new Array(d),m=0,g=e,D,S;for(S=0;S<h;S++)D=o[S]+a[S]+m,m=D>=g?1:0,w[S]=D-m*g;for(;S<d;)D=o[S]+m,m=D===g?1:0,w[S++]=D-m*g;return m>0&&w.push(m),w}function F(o,a){return o.length>=a.length?N(o,a):N(a,o)}function I(o,a){var d=o.length,h=new Array(d),w=e,m,g;for(g=0;g<d;g++)m=o[g]-w+a,a=Math.floor(m/w),h[g]=m-a*w,a+=1;for(;a>0;)h[g++]=a%w,a=Math.floor(a/w);return h}l.prototype.add=function(o){var a=k(o);if(this.sign!==a.sign)return this.subtract(a.negate());var d=this.value,h=a.value;return a.isSmall?new l(I(d,Math.abs(h)),this.sign):new l(F(d,h),this.sign)},l.prototype.plus=l.prototype.add,p.prototype.add=function(o){var a=k(o),d=this.value;if(d<0!==a.sign)return this.subtract(a.negate());var h=a.value;if(a.isSmall){if(y(d+h))return new p(d+h);h=x(Math.abs(h))}return new l(I(h,Math.abs(d)),d<0)},p.prototype.plus=p.prototype.add,u.prototype.add=function(o){return new u(this.value+k(o).value)},u.prototype.plus=u.prototype.add;function P(o,a){var d=o.length,h=a.length,w=new Array(d),m=0,g=e,D,S;for(D=0;D<h;D++)S=o[D]-m-a[D],S<0?(S+=g,m=1):m=0,w[D]=S;for(D=h;D<d;D++){if(S=o[D]-m,S<0)S+=g;else{w[D++]=S;break}w[D]=S}for(;D<d;D++)w[D]=o[D];return E(w),w}function O(o,a,d){var h;return At(o,a)>=0?h=P(o,a):(h=P(a,o),d=!d),h=L(h),typeof h=="number"?(d&&(h=-h),new p(h)):new l(h,d)}function $(o,a,d){var h=o.length,w=new Array(h),m=-a,g=e,D,S;for(D=0;D<h;D++)S=o[D]+m,m=Math.floor(S/g),S%=g,w[D]=S<0?S+g:S;return w=L(w),typeof w=="number"?(d&&(w=-w),new p(w)):new l(w,d)}l.prototype.subtract=function(o){var a=k(o);if(this.sign!==a.sign)return this.add(a.negate());var d=this.value,h=a.value;return a.isSmall?$(d,Math.abs(h),this.sign):O(d,h,this.sign)},l.prototype.minus=l.prototype.subtract,p.prototype.subtract=function(o){var a=k(o),d=this.value;if(d<0!==a.sign)return this.add(a.negate());var h=a.value;return a.isSmall?new p(d-h):$(h,Math.abs(d),d>=0)},p.prototype.minus=p.prototype.subtract,u.prototype.subtract=function(o){return new u(this.value-k(o).value)},u.prototype.minus=u.prototype.subtract,l.prototype.negate=function(){return new l(this.value,!this.sign)},p.prototype.negate=function(){var o=this.sign,a=new p(-this.value);return a.sign=!o,a},u.prototype.negate=function(){return new u(-this.value)},l.prototype.abs=function(){return new l(this.value,!1)},p.prototype.abs=function(){return new p(Math.abs(this.value))},u.prototype.abs=function(){return new u(this.value>=0?this.value:-this.value)};function v(o,a){var d=o.length,h=a.length,w=d+h,m=A(w),g=e,D,S,K,V,z;for(K=0;K<d;++K){V=o[K];for(var J=0;J<h;++J)z=a[J],D=V*z+m[K+J],S=Math.floor(D/g),m[K+J]=D-S*g,m[K+J+1]+=S}return E(m),m}function b(o,a){var d=o.length,h=new Array(d),w=e,m=0,g,D;for(D=0;D<d;D++)g=o[D]*a+m,m=Math.floor(g/w),h[D]=g-m*w;for(;m>0;)h[D++]=m%w,m=Math.floor(m/w);return h}function q(o,a){for(var d=[];a-- >0;)d.push(0);return d.concat(o)}function G(o,a){var d=Math.max(o.length,a.length);if(d<=30)return v(o,a);d=Math.ceil(d/2);var h=o.slice(d),w=o.slice(0,d),m=a.slice(d),g=a.slice(0,d),D=G(w,g),S=G(h,m),K=G(F(w,h),F(g,m)),V=F(F(D,q(P(P(K,D),S),d)),q(S,2*d));return E(V),V}function U(o,a){return-.012*o-.012*a+15e-6*o*a>0}l.prototype.multiply=function(o){var a=k(o),d=this.value,h=a.value,w=this.sign!==a.sign,m;if(a.isSmall){if(h===0)return c[0];if(h===1)return this;if(h===-1)return this.negate();if(m=Math.abs(h),m<e)return new l(b(d,m),w);h=x(m)}return U(d.length,h.length)?new l(G(d,h),w):new l(v(d,h),w)},l.prototype.times=l.prototype.multiply;function C(o,a,d){return o<e?new l(b(a,o),d):new l(v(a,x(o)),d)}p.prototype._multiplyBySmall=function(o){return y(o.value*this.value)?new p(o.value*this.value):C(Math.abs(o.value),x(Math.abs(this.value)),this.sign!==o.sign)},l.prototype._multiplyBySmall=function(o){return o.value===0?c[0]:o.value===1?this:o.value===-1?this.negate():C(Math.abs(o.value),this.value,this.sign!==o.sign)},p.prototype.multiply=function(o){return k(o)._multiplyBySmall(this)},p.prototype.times=p.prototype.multiply,u.prototype.multiply=function(o){return new u(this.value*k(o).value)},u.prototype.times=u.prototype.multiply;function _(o){var a=o.length,d=A(a+a),h=e,w,m,g,D,S;for(g=0;g<a;g++){D=o[g],m=0-D*D;for(var K=g;K<a;K++)S=o[K],w=2*(D*S)+d[g+K]+m,m=Math.floor(w/h),d[g+K]=w-m*h;d[g+a]=m}return E(d),d}l.prototype.square=function(){return new l(_(this.value),!1)},p.prototype.square=function(){var o=this.value*this.value;return y(o)?new p(o):new l(_(x(Math.abs(this.value))),!1)},u.prototype.square=function(o){return new u(this.value*this.value)};function B(o,a){var d=o.length,h=a.length,w=e,m=A(a.length),g=a[h-1],D=Math.ceil(w/(2*g)),S=b(o,D),K=b(a,D),V,z,J,Ct,Et,rr,nr;for(S.length<=d&&S.push(0),K.push(0),g=K[h-1],z=d-h;z>=0;z--){for(V=w-1,S[z+h]!==g&&(V=Math.floor((S[z+h]*w+S[z+h-1])/g)),J=0,Ct=0,rr=K.length,Et=0;Et<rr;Et++)J+=V*K[Et],nr=Math.floor(J/w),Ct+=S[z+Et]-(J-nr*w),J=nr,Ct<0?(S[z+Et]=Ct+w,Ct=-1):(S[z+Et]=Ct,Ct=0);for(;Ct!==0;){for(V-=1,J=0,Et=0;Et<rr;Et++)J+=S[z+Et]-w+K[Et],J<0?(S[z+Et]=J+w,J=0):(S[z+Et]=J,J=1);Ct+=J}m[z]=V}return S=et(S,D)[0],[L(m),L(S)]}function ot(o,a){for(var d=o.length,h=a.length,w=[],m=[],g=e,D,S,K,V,z;d;){if(m.unshift(o[--d]),E(m),At(m,a)<0){w.push(0);continue}S=m.length,K=m[S-1]*g+m[S-2],V=a[h-1]*g+a[h-2],S>h&&(K=(K+1)*g),D=Math.ceil(K/V);do{if(z=b(a,D),At(z,m)<=0)break;D--}while(D);w.push(D),m=P(m,z)}return w.reverse(),[L(w),L(m)]}function et(o,a){var d=o.length,h=A(d),w=e,m,g,D,S;for(D=0,m=d-1;m>=0;--m)S=D*w+o[m],g=M(S/a),D=S-g*a,h[m]=g|0;return[h,D|0]}function gt(o,a){var d,h=k(a);if(f)return[new u(o.value/h.value),new u(o.value%h.value)];var w=o.value,m=h.value,g;if(m===0)throw new Error("Cannot divide by zero");if(o.isSmall)return h.isSmall?[new p(M(w/m)),new p(w%m)]:[c[0],o];if(h.isSmall){if(m===1)return[o,c[0]];if(m==-1)return[o.negate(),c[0]];var D=Math.abs(m);if(D<e){d=et(w,D),g=L(d[0]);var S=d[1];return o.sign&&(S=-S),typeof g=="number"?(o.sign!==h.sign&&(g=-g),[new p(g),new p(S)]):[new l(g,o.sign!==h.sign),new p(S)]}m=x(D)}var K=At(w,m);if(K===-1)return[c[0],o];if(K===0)return[c[o.sign===h.sign?1:-1],c[0]];w.length+m.length<=200?d=B(w,m):d=ot(w,m),g=d[0];var V=o.sign!==h.sign,z=d[1],J=o.sign;return typeof g=="number"?(V&&(g=-g),g=new p(g)):g=new l(g,V),typeof z=="number"?(J&&(z=-z),z=new p(z)):z=new l(z,J),[g,z]}l.prototype.divmod=function(o){var a=gt(this,o);return{quotient:a[0],remainder:a[1]}},u.prototype.divmod=p.prototype.divmod=l.prototype.divmod,l.prototype.divide=function(o){return gt(this,o)[0]},u.prototype.over=u.prototype.divide=function(o){return new u(this.value/k(o).value)},p.prototype.over=p.prototype.divide=l.prototype.over=l.prototype.divide,l.prototype.mod=function(o){return gt(this,o)[1]},u.prototype.mod=u.prototype.remainder=function(o){return new u(this.value%k(o).value)},p.prototype.remainder=p.prototype.mod=l.prototype.remainder=l.prototype.mod,l.prototype.pow=function(o){var a=k(o),d=this.value,h=a.value,w,m,g;if(h===0)return c[1];if(d===0)return c[0];if(d===1)return c[1];if(d===-1)return a.isEven()?c[1]:c[-1];if(a.sign)return c[0];if(!a.isSmall)throw new Error("The exponent "+a.toString()+" is too large.");if(this.isSmall&&y(w=Math.pow(d,h)))return new p(M(w));for(m=this,g=c[1];h&!0&&(g=g.times(m),--h),h!==0;)h/=2,m=m.square();return g},p.prototype.pow=l.prototype.pow,u.prototype.pow=function(o){var a=k(o),d=this.value,h=a.value,w=BigInt(0),m=BigInt(1),g=BigInt(2);if(h===w)return c[1];if(d===w)return c[0];if(d===m)return c[1];if(d===BigInt(-1))return a.isEven()?c[1]:c[-1];if(a.isNegative())return new u(w);for(var D=this,S=c[1];(h&m)===m&&(S=S.times(D),--h),h!==w;)h/=g,D=D.square();return S},l.prototype.modPow=function(o,a){if(o=k(o),a=k(a),a.isZero())throw new Error("Cannot take modPow with modulus 0");var d=c[1],h=this.mod(a);for(o.isNegative()&&(o=o.multiply(c[-1]),h=h.modInv(a));o.isPositive();){if(h.isZero())return c[0];o.isOdd()&&(d=d.multiply(h).mod(a)),o=o.divide(2),h=h.square().mod(a)}return d},u.prototype.modPow=p.prototype.modPow=l.prototype.modPow;function At(o,a){if(o.length!==a.length)return o.length>a.length?1:-1;for(var d=o.length-1;d>=0;d--)if(o[d]!==a[d])return o[d]>a[d]?1:-1;return 0}l.prototype.compareAbs=function(o){var a=k(o),d=this.value,h=a.value;return a.isSmall?1:At(d,h)},p.prototype.compareAbs=function(o){var a=k(o),d=Math.abs(this.value),h=a.value;return a.isSmall?(h=Math.abs(h),d===h?0:d>h?1:-1):-1},u.prototype.compareAbs=function(o){var a=this.value,d=k(o).value;return a=a>=0?a:-a,d=d>=0?d:-d,a===d?0:a>d?1:-1},l.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var a=k(o),d=this.value,h=a.value;return this.sign!==a.sign?a.sign?1:-1:a.isSmall?this.sign?-1:1:At(d,h)*(this.sign?-1:1)},l.prototype.compareTo=l.prototype.compare,p.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var a=k(o),d=this.value,h=a.value;return a.isSmall?d==h?0:d>h?1:-1:d<0!==a.sign?d<0?-1:1:d<0?1:-1},p.prototype.compareTo=p.prototype.compare,u.prototype.compare=function(o){if(o===1/0)return-1;if(o===-1/0)return 1;var a=this.value,d=k(o).value;return a===d?0:a>d?1:-1},u.prototype.compareTo=u.prototype.compare,l.prototype.equals=function(o){return this.compare(o)===0},u.prototype.eq=u.prototype.equals=p.prototype.eq=p.prototype.equals=l.prototype.eq=l.prototype.equals,l.prototype.notEquals=function(o){return this.compare(o)!==0},u.prototype.neq=u.prototype.notEquals=p.prototype.neq=p.prototype.notEquals=l.prototype.neq=l.prototype.notEquals,l.prototype.greater=function(o){return this.compare(o)>0},u.prototype.gt=u.prototype.greater=p.prototype.gt=p.prototype.greater=l.prototype.gt=l.prototype.greater,l.prototype.lesser=function(o){return this.compare(o)<0},u.prototype.lt=u.prototype.lesser=p.prototype.lt=p.prototype.lesser=l.prototype.lt=l.prototype.lesser,l.prototype.greaterOrEquals=function(o){return this.compare(o)>=0},u.prototype.geq=u.prototype.greaterOrEquals=p.prototype.geq=p.prototype.greaterOrEquals=l.prototype.geq=l.prototype.greaterOrEquals,l.prototype.lesserOrEquals=function(o){return this.compare(o)<=0},u.prototype.leq=u.prototype.lesserOrEquals=p.prototype.leq=p.prototype.lesserOrEquals=l.prototype.leq=l.prototype.lesserOrEquals,l.prototype.isEven=function(){return(this.value[0]&1)===0},p.prototype.isEven=function(){return(this.value&1)===0},u.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},l.prototype.isOdd=function(){return(this.value[0]&1)===1},p.prototype.isOdd=function(){return(this.value&1)===1},u.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},l.prototype.isPositive=function(){return!this.sign},p.prototype.isPositive=function(){return this.value>0},u.prototype.isPositive=p.prototype.isPositive,l.prototype.isNegative=function(){return this.sign},p.prototype.isNegative=function(){return this.value<0},u.prototype.isNegative=p.prototype.isNegative,l.prototype.isUnit=function(){return!1},p.prototype.isUnit=function(){return Math.abs(this.value)===1},u.prototype.isUnit=function(){return this.abs().value===BigInt(1)},l.prototype.isZero=function(){return!1},p.prototype.isZero=function(){return this.value===0},u.prototype.isZero=function(){return this.value===BigInt(0)},l.prototype.isDivisibleBy=function(o){var a=k(o);return a.isZero()?!1:a.isUnit()?!0:a.compareAbs(2)===0?this.isEven():this.mod(a).isZero()},u.prototype.isDivisibleBy=p.prototype.isDivisibleBy=l.prototype.isDivisibleBy;function Ht(o){var a=o.abs();if(a.isUnit())return!1;if(a.equals(2)||a.equals(3)||a.equals(5))return!0;if(a.isEven()||a.isDivisibleBy(3)||a.isDivisibleBy(5))return!1;if(a.lesser(49))return!0}function rt(o,a){for(var d=o.prev(),h=d,w=0,m,g,D,S;h.isEven();)h=h.divide(2),w++;t:for(D=0;D<a.length;D++)if(!o.lesser(a[D])&&(S=yt(a[D]).modPow(h,o),!(S.isUnit()||S.equals(d)))){for(m=w-1;m!=0;m--){if(S=S.square().mod(o),S.isUnit())return!1;if(S.equals(d))continue t}return!1}return!0}l.prototype.isPrime=function(o){var a=Ht(this);if(a!==t)return a;var d=this.abs(),h=d.bitLength();if(h<=64)return rt(d,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var w=Math.log(2)*h.toJSNumber(),m=Math.ceil(o===!0?2*Math.pow(w,2):w),g=[],D=0;D<m;D++)g.push(yt(D+2));return rt(d,g)},u.prototype.isPrime=p.prototype.isPrime=l.prototype.isPrime,l.prototype.isProbablePrime=function(o,a){var d=Ht(this);if(d!==t)return d;for(var h=this.abs(),w=o===t?5:o,m=[],g=0;g<w;g++)m.push(yt.randBetween(2,h.minus(2),a));return rt(h,m)},u.prototype.isProbablePrime=p.prototype.isProbablePrime=l.prototype.isProbablePrime,l.prototype.modInv=function(o){for(var a=yt.zero,d=yt.one,h=k(o),w=this.abs(),m,g,D;!w.isZero();)m=h.divide(w),g=a,D=h,a=d,h=w,d=g.subtract(m.multiply(d)),w=D.subtract(m.multiply(w));if(!h.isUnit())throw new Error(this.toString()+" and "+o.toString()+" are not co-prime");return a.compare(0)===-1&&(a=a.add(o)),this.isNegative()?a.negate():a},u.prototype.modInv=p.prototype.modInv=l.prototype.modInv,l.prototype.next=function(){var o=this.value;return this.sign?$(o,1,this.sign):new l(I(o,1),this.sign)},p.prototype.next=function(){var o=this.value;return o+1<r?new p(o+1):new l(i,!1)},u.prototype.next=function(){return new u(this.value+BigInt(1))},l.prototype.prev=function(){var o=this.value;return this.sign?new l(I(o,1),!0):$(o,1,this.sign)},p.prototype.prev=function(){var o=this.value;return o-1>-r?new p(o-1):new l(i,!0)},u.prototype.prev=function(){return new u(this.value-BigInt(1))};for(var W=[1];2*W[W.length-1]<=e;)W.push(2*W[W.length-1]);var nt=W.length,Y=W[nt-1];function st(o){return Math.abs(o)<=e}l.prototype.shiftLeft=function(o){var a=k(o).toJSNumber();if(!st(a))throw new Error(String(a)+" is too large for shifting.");if(a<0)return this.shiftRight(-a);var d=this;if(d.isZero())return d;for(;a>=nt;)d=d.multiply(Y),a-=nt-1;return d.multiply(W[a])},u.prototype.shiftLeft=p.prototype.shiftLeft=l.prototype.shiftLeft,l.prototype.shiftRight=function(o){var a,d=k(o).toJSNumber();if(!st(d))throw new Error(String(d)+" is too large for shifting.");if(d<0)return this.shiftLeft(-d);for(var h=this;d>=nt;){if(h.isZero()||h.isNegative()&&h.isUnit())return h;a=gt(h,Y),h=a[1].isNegative()?a[0].prev():a[0],d-=nt-1}return a=gt(h,W[d]),a[1].isNegative()?a[0].prev():a[0]},u.prototype.shiftRight=p.prototype.shiftRight=l.prototype.shiftRight;function at(o,a,d){a=k(a);for(var h=o.isNegative(),w=a.isNegative(),m=h?o.not():o,g=w?a.not():a,D=0,S=0,K=null,V=null,z=[];!m.isZero()||!g.isZero();)K=gt(m,Y),D=K[1].toJSNumber(),h&&(D=Y-1-D),V=gt(g,Y),S=V[1].toJSNumber(),w&&(S=Y-1-S),m=K[0],g=V[0],z.push(d(D,S));for(var J=d(h?1:0,w?1:0)!==0?yt(-1):yt(0),Ct=z.length-1;Ct>=0;Ct-=1)J=J.multiply(Y).add(yt(z[Ct]));return J}l.prototype.not=function(){return this.negate().prev()},u.prototype.not=p.prototype.not=l.prototype.not,l.prototype.and=function(o){return at(this,o,function(a,d){return a&d})},u.prototype.and=p.prototype.and=l.prototype.and,l.prototype.or=function(o){return at(this,o,function(a,d){return a|d})},u.prototype.or=p.prototype.or=l.prototype.or,l.prototype.xor=function(o){return at(this,o,function(a,d){return a^d})},u.prototype.xor=p.prototype.xor=l.prototype.xor;var ut=1<<30,ht=(e&-e)*(e&-e)|ut;function tt(o){var a=o.value,d=typeof a=="number"?a|ut:typeof a=="bigint"?a|BigInt(ut):a[0]+a[1]*e|ht;return d&-d}function pt(o,a){if(a.compareTo(o)<=0){var d=pt(o,a.square(a)),h=d.p,w=d.e,m=h.multiply(a);return m.compareTo(o)<=0?{p:m,e:w*2+1}:{p:h,e:w*2}}return{p:yt(1),e:0}}l.prototype.bitLength=function(){var o=this;return o.compareTo(yt(0))<0&&(o=o.negate().subtract(yt(1))),o.compareTo(yt(0))===0?yt(0):yt(pt(o,yt(2)).e).add(yt(1))},u.prototype.bitLength=p.prototype.bitLength=l.prototype.bitLength;function dt(o,a){return o=k(o),a=k(a),o.greater(a)?o:a}function ct(o,a){return o=k(o),a=k(a),o.lesser(a)?o:a}function ft(o,a){if(o=k(o).abs(),a=k(a).abs(),o.equals(a))return o;if(o.isZero())return a;if(a.isZero())return o;for(var d=c[1],h,w;o.isEven()&&a.isEven();)h=ct(tt(o),tt(a)),o=o.divide(h),a=a.divide(h),d=d.multiply(h);for(;o.isEven();)o=o.divide(tt(o));do{for(;a.isEven();)a=a.divide(tt(a));o.greater(a)&&(w=a,a=o,o=w),a=a.subtract(o)}while(!a.isZero());return d.isUnit()?o:o.multiply(d)}function mt(o,a){return o=k(o).abs(),a=k(a).abs(),o.divide(ft(o,a)).multiply(a)}function vt(o,a,d){o=k(o),a=k(a);var h=d||Math.random,w=ct(o,a),m=dt(o,a),g=m.subtract(w).add(1);if(g.isSmall)return w.add(Math.floor(h()*g));for(var D=me(g,e).value,S=[],K=!0,V=0;V<D.length;V++){var z=K?D[V]+(V+1<D.length?D[V+1]/e:0):e,J=M(h()*z);S.push(J),J<D[V]&&(K=!1)}return w.add(c.fromArray(S,e,!1))}var wt=function(o,a,d,h){d=d||s,o=String(o),h||(o=o.toLowerCase(),d=d.toLowerCase());var w=o.length,m,g=Math.abs(a),D={};for(m=0;m<d.length;m++)D[d[m]]=m;for(m=0;m<w;m++){var S=o[m];if(S!=="-"&&S in D&&D[S]>=g){if(S==="1"&&g===1)continue;throw new Error(S+" is not a valid digit in base "+a+".")}}a=k(a);var K=[],V=o[0]==="-";for(m=V?1:0;m<o.length;m++){var S=o[m];if(S in D)K.push(k(D[S]));else if(S==="<"){var z=m;do m++;while(o[m]!==">"&&m<o.length);K.push(k(o.slice(z+1,m)))}else throw new Error(S+" is not a valid character")}return wn(K,a,V)};function wn(o,a,d){var h=c[0],w=c[1],m;for(m=o.length-1;m>=0;m--)h=h.add(o[m].times(w)),w=w.times(a);return d?h.negate():h}function Oo(o,a){return a=a||s,o<a.length?a[o]:"<"+o+">"}function me(o,a){if(a=yt(a),a.isZero()){if(o.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(a.equals(-1)){if(o.isZero())return{value:[0],isNegative:!1};if(o.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-o.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var d=Array.apply(null,Array(o.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return d.unshift([1]),{value:[].concat.apply([],d),isNegative:!1}}var h=!1;if(o.isNegative()&&a.isPositive()&&(h=!0,o=o.abs()),a.isUnit())return o.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(o.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:h};for(var w=[],m=o,g;m.isNegative()||m.compareAbs(a)>=0;){g=m.divmod(a),m=g.quotient;var D=g.remainder;D.isNegative()&&(D=a.minus(D).abs(),m=m.next()),w.push(D.toJSNumber())}return w.push(m.toJSNumber()),{value:w.reverse(),isNegative:h}}function bn(o,a,d){var h=me(o,a);return(h.isNegative?"-":"")+h.value.map(function(w){return Oo(w,d)}).join("")}l.prototype.toArray=function(o){return me(this,o)},p.prototype.toArray=function(o){return me(this,o)},u.prototype.toArray=function(o){return me(this,o)},l.prototype.toString=function(o,a){if(o===t&&(o=10),o!==10)return bn(this,o,a);for(var d=this.value,h=d.length,w=String(d[--h]),m="0000000",g;--h>=0;)g=String(d[h]),w+=m.slice(g.length)+g;var D=this.sign?"-":"";return D+w},p.prototype.toString=function(o,a){return o===t&&(o=10),o!=10?bn(this,o,a):String(this.value)},u.prototype.toString=p.prototype.toString,u.prototype.toJSON=l.prototype.toJSON=p.prototype.toJSON=function(){return this.toString()},l.prototype.valueOf=function(){return parseInt(this.toString(),10)},l.prototype.toJSNumber=l.prototype.valueOf,p.prototype.valueOf=function(){return this.value},p.prototype.toJSNumber=p.prototype.valueOf,u.prototype.valueOf=u.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function xn(o){if(y(+o)){var a=+o;if(a===M(a))return f?new u(BigInt(a)):new p(a);throw new Error("Invalid integer: "+o)}var d=o[0]==="-";d&&(o=o.slice(1));var h=o.split(/e/i);if(h.length>2)throw new Error("Invalid integer: "+h.join("e"));if(h.length===2){var w=h[1];if(w[0]==="+"&&(w=w.slice(1)),w=+w,w!==M(w)||!y(w))throw new Error("Invalid integer: "+w+" is not a valid exponent.");var m=h[0],g=m.indexOf(".");if(g>=0&&(w-=m.length-g-1,m=m.slice(0,g)+m.slice(g+1)),w<0)throw new Error("Cannot include negative exponent part for integers");m+=new Array(w+1).join("0"),o=m}var D=/^([0-9][0-9]*)$/.test(o);if(!D)throw new Error("Invalid integer: "+o);if(f)return new u(BigInt(d?"-"+o:o));for(var S=[],K=o.length,V=n,z=K-V;K>0;)S.push(+o.slice(z,K)),z-=V,z<0&&(z=0),K-=V;return E(S),new l(S,d)}function ko(o){if(f)return new u(BigInt(o));if(y(o)){if(o!==M(o))throw new Error(o+" is not an integer.");return new p(o)}return xn(o.toString())}function k(o){return typeof o=="number"?ko(o):typeof o=="string"?xn(o):typeof o=="bigint"?new u(o):o}for(var Vt=0;Vt<1e3;Vt++)c[Vt]=k(Vt),Vt>0&&(c[-Vt]=k(-Vt));return c.one=c[1],c.zero=c[0],c.minusOne=c[-1],c.max=dt,c.min=ct,c.gcd=ft,c.lcm=mt,c.isInstance=function(o){return o instanceof l||o instanceof p||o instanceof u},c.randBetween=vt,c.fromArray=function(o,a,d){return wn(o.map(k),k(a||10),d)},c}();typeof We<"u"&&We.hasOwnProperty("exports")&&(We.exports=yt);typeof define=="function"&&define.amd&&define(function(){return yt})});function Gt(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));let n=new Uint8Array(e),r=0;for(let i of t)n.set(i,r),r+=i.length;return n}function re(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==e[n])return!1;return!0}var fr={};It(fr,{identity:()=>Vo});function Ko(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),f=s.charCodeAt(0);if(n[f]!==255)throw new TypeError(s+" is ambiguous");n[f]=i}var c=t.length,l=t.charAt(0),p=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function y(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 A=0,M=0,N=0,F=E.length;N!==F&&E[N]===0;)N++,A++;for(var I=(F-N)*u+1>>>0,P=new Uint8Array(I);N!==F;){for(var O=E[N],$=0,v=I-1;(O!==0||$<M)&&v!==-1;v--,$++)O+=256*P[v]>>>0,P[v]=O%c>>>0,O=O/c>>>0;if(O!==0)throw new Error("Non-zero carry");M=$,N++}for(var b=I-M;b!==I&&P[b]===0;)b++;for(var q=l.repeat(A);b<I;++b)q+=t.charAt(P[b]);return q}function x(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var A=0;if(E[A]!==" "){for(var M=0,N=0;E[A]===l;)M++,A++;for(var F=(E.length-A)*p+1>>>0,I=new Uint8Array(F);E[A];){var P=n[E.charCodeAt(A)];if(P===255)return;for(var O=0,$=F-1;(P!==0||O<N)&&$!==-1;$--,O++)P+=c*I[$]>>>0,I[$]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");N=O,A++}if(E[A]!==" "){for(var v=F-N;v!==F&&I[v]===0;)v++;for(var b=new Uint8Array(M+(F-v)),q=M;v!==F;)b[q++]=I[v++];return b}}}function L(E){var A=x(E);if(A)return A;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:x,decode:L}}var $o=Ko,qo=$o,gn=qo;var Ac=new Uint8Array(0);var En=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==e[n])return!1;return!0},Ft=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")};var Sn=t=>new TextEncoder().encode(t),An=t=>new TextDecoder().decode(t);var sr=class{constructor(e,n,r){this.name=e,this.prefix=n,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ar=class{constructor(e,n,r){if(this.name=e,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r}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 _n(this,e)}},ur=class{constructor(e){this.decoders=e}or(e){return _n(this,e)}decode(e){let n=e[0],r=this.decoders[n];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},_n=(t,e)=>new ur({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),cr=class{constructor(e,n,r,i){this.name=e,this.prefix=n,this.baseEncode=r,this.baseDecode=i,this.encoder=new sr(e,n,r),this.decoder=new ar(e,n,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ne=({name:t,prefix:e,encode:n,decode:r})=>new cr(t,e,n,r),Kt=({prefix:t,name:e,alphabet:n})=>{let{encode:r,decode:i}=gn(n,e);return ne({prefix:t,name:e,encode:r,decode:s=>Ft(i(s))})},zo=(t,e,n,r)=>{let i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;let f=new Uint8Array(s*n/8|0),c=0,l=0,p=0;for(let u=0;u<s;++u){let y=i[t[u]];if(y===void 0)throw new SyntaxError(`Non-${r} character`);l=l<<n|y,c+=n,c>=8&&(c-=8,f[p++]=255&l>>c)}if(c>=n||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return f},Ho=(t,e,n)=>{let r=e[e.length-1]==="=",i=(1<<n)-1,s="",f=0,c=0;for(let l=0;l<t.length;++l)for(c=c<<8|t[l],f+=8;f>n;)f-=n,s+=e[i&c>>f];if(f&&(s+=e[i&c<<n-f]),r)for(;s.length*n&7;)s+="=";return s},lt=({name:t,prefix:e,bitsPerChar:n,alphabet:r})=>ne({prefix:e,name:t,encode(i){return Ho(i,r,n)},decode(i){return zo(i,r,n,t)}});var Vo=ne({prefix:"\0",name:"identity",encode:t=>An(t),decode:t=>Sn(t)});var lr={};It(lr,{base2:()=>Go});var Go=lt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pr={};It(pr,{base8:()=>Jo});var Jo=lt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var dr={};It(dr,{base10:()=>Xo});var Xo=Kt({prefix:"9",name:"base10",alphabet:"0123456789"});var hr={};It(hr,{base16:()=>Zo,base16upper:()=>Wo});var Zo=lt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Wo=lt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var yr={};It(yr,{base32:()=>ie,base32hex:()=>ts,base32hexpad:()=>rs,base32hexpadupper:()=>ns,base32hexupper:()=>es,base32pad:()=>Yo,base32padupper:()=>jo,base32upper:()=>Qo,base32z:()=>is});var ie=lt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qo=lt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Yo=lt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),jo=lt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ts=lt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),es=lt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rs=lt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ns=lt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),is=lt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mr={};It(mr,{base36:()=>os,base36upper:()=>ss});var os=Kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ss=Kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var vr={};It(vr,{base58btc:()=>Bt,base58flickr:()=>as});var Bt=Kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),as=Kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var wr={};It(wr,{base64:()=>us,base64pad:()=>cs,base64url:()=>fs,base64urlpad:()=>ls});var us=lt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),cs=lt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fs=lt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ls=lt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var br={};It(br,{base256emoji:()=>ms});var In=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}"),ps=In.reduce((t,e,n)=>(t[n]=e,t),[]),ds=In.reduce((t,e,n)=>(t[e.codePointAt(0)]=n,t),[]);function hs(t){return t.reduce((e,n)=>(e+=ps[n],e),"")}function ys(t){let e=[];for(let n of t){let r=ds[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);e.push(r)}return new Uint8Array(e)}var ms=ne({prefix:"\u{1F680}",name:"base256emoji",encode:hs,decode:ys});var Er={};It(Er,{sha256:()=>Ts,sha512:()=>Ms});var vs=Bn,Un=128,ws=127,bs=~ws,xs=Math.pow(2,31);function Bn(t,e,n){e=e||[],n=n||0;for(var r=n;t>=xs;)e[n++]=t&255|Un,t/=128;for(;t&bs;)e[n++]=t&255|Un,t>>>=7;return e[n]=t|0,Bn.bytes=n-r+1,e}var Ds=xr,gs=128,Pn=127;function xr(t,r){var n=0,r=r||0,i=0,s=r,f,c=t.length;do{if(s>=c)throw xr.bytes=0,new RangeError("Could not decode varint");f=t[s++],n+=i<28?(f&Pn)<<i:(f&Pn)*Math.pow(2,i),i+=7}while(f>=gs);return xr.bytes=s-r,n}var Es=Math.pow(2,7),Ss=Math.pow(2,14),As=Math.pow(2,21),Cs=Math.pow(2,28),_s=Math.pow(2,35),Is=Math.pow(2,42),Us=Math.pow(2,49),Ps=Math.pow(2,56),Bs=Math.pow(2,63),Ls=function(t){return t<Es?1:t<Ss?2:t<As?3:t<Cs?4:t<_s?5:t<Is?6:t<Us?7:t<Ps?8:t<Bs?9:10},Ns={encode:vs,decode:Ds,encodingLength:Ls},Fs=Ns,ve=Fs;var we=(t,e=0)=>[ve.decode(t,e),ve.decode.bytes],oe=(t,e,n=0)=>(ve.encode(t,e,n),e),se=t=>ve.encodingLength(t);var Jt=(t,e)=>{let n=e.byteLength,r=se(t),i=r+se(n),s=new Uint8Array(i+n);return oe(t,s,0),oe(n,s,r),s.set(e,i),new ae(t,n,e,s)},Ln=t=>{let e=Ft(t),[n,r]=we(e),[i,s]=we(e.subarray(r)),f=e.subarray(r+s);if(f.byteLength!==i)throw new Error("Incorrect length");return new ae(n,i,f,e)},Nn=(t,e)=>t===e?!0:t.code===e.code&&t.size===e.size&&En(t.bytes,e.bytes),ae=class{constructor(e,n,r,i){this.code=e,this.size=n,this.digest=r,this.bytes=i}};var gr=({name:t,code:e,encode:n})=>new Dr(t,e,n),Dr=class{constructor(e,n,r){this.name=e,this.code=n,this.encode=r}digest(e){if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Jt(this.code,n):n.then(r=>Jt(this.code,r))}else throw Error("Unknown type, must be binary type")}};var Tn=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Ts=gr({name:"sha2-256",code:18,encode:Tn("SHA-256")}),Ms=gr({name:"sha2-512",code:19,encode:Tn("SHA-512")});var Sr={};It(Sr,{identity:()=>ks});var Mn=0,Rs="identity",Rn=Ft,Os=t=>Jt(Mn,Rn(t)),ks={code:Mn,name:Rs,encode:Rn,digest:Os};var Gc=new TextEncoder,Jc=new TextDecoder;var ke=class t{constructor(e,n,r,i){this.code=n,this.version=e,this.multihash=r,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Oe,byteLength:Oe,code:Re,version:Re,multihash:Re,bytes:Re,_baseCache:Oe,asCID:Oe})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:n}=this;if(e!==xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==Vs)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(n)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:n}=this.multihash,r=Jt(e,n);return t.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&Nn(this.multihash,e.multihash)}toString(e){let{bytes:n,version:r,_baseCache:i}=this;switch(r){case 0:return zs(n,i,e||Bt.encoder);default:return Hs(n,i,e||ie.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Js(/^0\.0/,Xs),!!(e&&(e[kn]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof t)return e;if(e!=null&&e.asCID===e){let{version:n,code:r,multihash:i,bytes:s}=e;return new t(n,r,i,s||On(n,r,i.bytes))}else if(e!=null&&e[kn]===!0){let{version:n,multihash:r,code:i}=e,s=Ln(r);return t.create(n,i,s)}else return null}static create(e,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(n!==xe)throw new Error(`Version 0 CID must use dag-pb (code: ${xe}) block encoding`);return new t(e,n,r,r.bytes)}case 1:{let i=On(e,n,r.bytes);return new t(e,n,r,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,xe,e)}static createV1(e,n){return t.create(1,e,n)}static decode(e){let[n,r]=t.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return n}static decodeFirst(e){let n=t.inspectBytes(e),r=n.size-n.multihashSize,i=Ft(e.subarray(r,r+n.multihashSize));if(i.byteLength!==n.multihashSize)throw new Error("Incorrect length");let s=i.subarray(n.multihashSize-n.digestSize),f=new ae(n.multihashCode,n.digestSize,s,i);return[n.version===0?t.createV0(f):t.createV1(n.codec,f),e.subarray(n.size)]}static inspectBytes(e){let n=0,r=()=>{let[y,x]=we(e.subarray(n));return n+=x,y},i=r(),s=xe;if(i===18?(i=0,n=0):i===1&&(s=r()),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let f=n,c=r(),l=r(),p=n+l,u=p-f;return{version:i,codec:s,multihashCode:c,digestSize:l,multihashSize:u,size:p}}static parse(e,n){let[r,i]=qs(e,n),s=t.decode(i);return s._baseCache.set(r,e),s}},qs=(t,e)=>{switch(t[0]){case"Q":{let n=e||Bt;return[Bt.prefix,n.decode(`${Bt.prefix}${t}`)]}case Bt.prefix:{let n=e||Bt;return[Bt.prefix,n.decode(t)]}case ie.prefix:{let n=e||ie;return[ie.prefix,n.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},zs=(t,e,n)=>{let{prefix:r}=n;if(r!==Bt.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let i=e.get(r);if(i==null){let s=n.encode(t).slice(1);return e.set(r,s),s}else return i},Hs=(t,e,n)=>{let{prefix:r}=n,i=e.get(r);if(i==null){let s=n.encode(t);return e.set(r,s),s}else return i},xe=112,Vs=18,On=(t,e,n)=>{let r=se(t),i=r+se(e),s=new Uint8Array(i+n.byteLength);return oe(t,s,0),oe(e,s,r),s.set(n,i),s},kn=Symbol.for("@ipld/js-cid/CID"),Re={writable:!1,configurable:!1,enumerable:!0},Oe={writable:!1,enumerable:!1,configurable:!1},Gs="0.0.0-dev",Js=(t,e)=>{if(t.test(Gs))console.warn(e);else throw new Error(e)},Xs=`CID.isCID(v) is deprecated and will be removed in the next major release.
2
2
  Following code pattern:
3
3
 
4
4
  if (CID.isCID(value)) {
@@ -13,4 +13,4 @@ if (cid) {
13
13
  doSomethingWithCID(cid)
14
14
  }
15
15
  `;var Ar={...fr,...lr,...pr,...dr,...hr,...yr,...mr,...vr,...wr,...br},ef={...Er,...Sr};function $n(t,e,n,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:n},decoder:{decode:r}}}var Kn=$n("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Cr=$n("ascii","a",t=>{let e="a";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return e},t=>{t=t.substring(1);let e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}),Zs={utf8:Kn,"utf-8":Kn,hex:Ar.base16,latin1:Cr,ascii:Cr,binary:Cr,...Ar},Ke=Zs;function bt(t,e="utf8"){let n=Ke[e];if(!n)throw new Error(`Unsupported encoding "${e}"`);return n.decoder.decode(`${n.prefix}${t}`)}function St(t,e="utf8"){let n=Ke[e];if(!n)throw new Error(`Unsupported encoding "${e}"`);return n.encoder.encode(t).substring(1)}var Jr=ir(Vr(),1);var Ge=new Uint8Array([237,1]),Bf=new Uint8Array([234,1]),Je=new Uint8Array([128,36]),Lf=new Uint8Array([129,36]),Nf=new Uint8Array([130,36]),Xe=new Uint8Array([133,36]),Ze=new Uint8Array([0,245,2]),Gr="did:key:z";function Qt(t,e){if(!t.startsWith(Gr))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let n=t.slice(Gr.length),r=bt(n,"base58btc");if(!Ha(r,e))throw new Error(`Expected prefix: ${e}`);return r.slice(e.length)}var Ha=(t,e)=>re(e,t.subarray(0,e.byteLength));var xi=t=>Qt(t,Ge);var Va=globalThis||window||self,zt=Va.crypto;var Si=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},Ai="RSASSA-PKCS1-v1_5";var Ga="SHA-256",Ja=128;var Xa=t=>Si(void 0,void 0,void 0,function*(){return yield zt.subtle.importKey("spki",t,{name:Ai,hash:{name:Ga}},!0,["verify"])});var Xr=(t,e,n)=>Si(void 0,void 0,void 0,function*(){return yield zt.subtle.verify({name:Ai,saltLength:Ja},yield Xa(t),n,e)}),Ci=t=>{let e=Qt(t,Xe);return Qa(e)},_i=t=>Qt(t,Ze);var gi=new Uint8Array([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]),Za=new Uint8Array([48]),Wa=new Uint8Array([3]),Qa=t=>{let e=Gt([Wa,Ei(t.length+1),new Uint8Array([0]),t]);return Gt([Za,Ei(gi.length+e.length),gi,e])};function Ei(t){if(t<0||!isFinite(t))throw new TypeError(`Expected non-negative number. Got ${t}`);if(t<=127)return new Uint8Array([t]);let e=[];for(;t!==0;)e.push(t&255),t=t>>>8;return e.reverse(),new Uint8Array([128|e.length&255,...e])}var Se=ir(Ii(),1);var Ui=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},Pi="ECDSA",ja="P-256",tu="SHA-256";var eu=t=>Ui(void 0,void 0,void 0,function*(){return yield zt.subtle.importKey("raw",t,{name:Pi,namedCurve:ja},!0,["verify"])});var Bi=(t,e,n)=>Ui(void 0,void 0,void 0,function*(){return yield zt.subtle.verify({name:Pi,hash:{name:tu}},yield eu(t),n,e)}),Li=t=>{let e=Qt(t,Je);return ru(e)};var ru=t=>{if(t.length!==33)throw new Error("Expected 33 byte compress pubkey");if(t[0]!==2&&t[0]!==3)throw new Error("Expected first byte to be 0x02 or 0x03");let e=(0,Se.default)(2),n=e.pow(256).subtract(e.pow(224)).add(e.pow(192)).add(e.pow(96)).subtract(1),r=(0,Se.default)("41058363725152142129326129780047268409114441015993725554835256314039467401291"),i=n.add(1).divide(4),s=(0,Se.default)(t[0]-2),f=t.slice(1),c=(0,Se.default)(St(f,"base10")),l=c.pow(3).subtract(c.multiply(3)).add(r).modPow(i,n),p;l.mod(2).equals(s)?p=l:p=n.subtract(l);let u=bt(p.toString(10),"base10"),y=32-u.length,x=new Uint8Array(32);return x.set(u,y),Gt([[4],f,x])};var Ni=ir(Vr(),1);var nu=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},Fi={prefix:Ge,jwtAlg:"EdDSA",verifySignature:(t,e,n)=>nu(void 0,void 0,void 0,function*(){let r=xi(t);return Ni.verify(r,e,n)})};var Ti=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},Mi={prefix:Xe,jwtAlg:"RS256",verifySignature:(t,e,n)=>Ti(void 0,void 0,void 0,function*(){let r=Ci(t);return Xr(r,e,n)})},Ri={prefix:Ze,jwtAlg:"RS256",verifySignature:(t,e,n)=>Ti(void 0,void 0,void 0,function*(){let r=_i(t);return Xr(r,e,n)})};var iu=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},Oi={prefix:Je,jwtAlg:"ES256",verifySignature:(t,e,n)=>iu(void 0,void 0,void 0,function*(){let r=Li(t);return Bi(r,e,n)})};var ou=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},su=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(f){return new Promise(function(c,l){f=t[s](f),i(c,l,f.done,f.value)})}}function i(s,f,c,l){Promise.resolve(l).then(function(p){s({value:p,done:c})},f)}},ki="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Ki=(t=6)=>{let e="";for(let n=0;n<t;n++)e+=ki[Math.floor(Math.random()*ki.length)];return e};function R(t,e){return typeof t=="object"&&t!=null&&e in t}function it(t){return typeof t=="object"&&t!=null}function au(t){return typeof t=="object"&&t!=null&&Symbol.iterator in t}function uu(t){return typeof t=="object"&&t!=null&&Symbol.asyncIterator in t}function $i(t){if(au(t)){for(let e of t)return e;return}else{if(uu(t))return ou(this,void 0,void 0,function*(){var e,n;try{for(var r=su(t),i;i=yield r.next(),!i.done;)return i.value}catch(s){e={error:s}}finally{try{i&&!i.done&&(n=r.return)&&(yield n.call(r))}finally{if(e)throw e.error}}});throw new TypeError(`Expected either Iterable or AsyncIterable, but got ${t}`)}}function Hi(t){return it(t)&&R(t,"major")&&typeof t.major=="number"&&R(t,"minor")&&typeof t.minor=="number"&&R(t,"patch")&&typeof t.patch=="number"}var cu=/^0|[1-9]\d*/,fu=t=>e=>{let n=e.match(t);return n?n[0].length===e.length:!1};function Qe(t){var e,n,r;let i=t.match(/^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/);if(i===null)return null;let s=`${(e=i.groups)===null||e===void 0?void 0:e.major}.${(n=i.groups)===null||n===void 0?void 0:n.minor}.${(r=i.groups)===null||r===void 0?void 0:r.patch}`.split(".");if(s.length!==3||!s.every(fu(cu)))return null;let[f,c,l]=s.map(p=>parseInt(p,10));return!Number.isSafeInteger(f)||!Number.isSafeInteger(c)||!Number.isSafeInteger(l)||f<0||c<0||l<0?null:{major:f,minor:c,patch:l}}function Vi(t){return`${t.major}.${t.minor}.${t.patch}`}var qi=1,zi=0,Yr=-1;function Qr(t,e){return t==null?e==null?zi:Yr:e==null||t>e?qi:t<e?Yr:zi}function lu(t,e){let n=typeof t=="string"?Qe(t):t,r=typeof e=="string"?Qe(e):e;return Qr(n?.major,r?.major)||Qr(n?.minor,r?.minor)||Qr(n?.patch,r?.patch)}function Ae(t,e){return lu(t,e)===Yr}function Gi(t,e){return!Ae(t,e)}var j="*";var Ji="/";function tn(t){return t===j||it(t)&&R(t,"namespace")&&typeof t.namespace=="string"&&R(t,"segments")&&Array.isArray(t.segments)&&t.segments.every(e=>typeof e=="string")}function pu(t){return t.join(Ji)}function Xi(t){switch(t){case j:return t;default:return pu([t.namespace,...t.segments])}}function Zi(t){switch(t){case j:return j;default:{let[e,...n]=t.split(Ji);return{namespace:e,segments:n}}}}var en=":";function rn(t){return it(t)&&R(t,"scheme")&&typeof t.scheme=="string"&&R(t,"hierPart")&&(t.hierPart===j||typeof t.hierPart=="string")}function Qi(t){return{scheme:"my",hierPart:t}}function Yi(t){return`${t.scheme}${en}${t.hierPart}`}function ji(t){let[e,...n]=t.split(en);return{scheme:e,hierPart:n.join(en)}}function Lt(t){return it(t)&&R(t,"with")&&rn(t.with)&&R(t,"can")&&tn(t.can)}function Ye(t){return it(t)&&R(t,"with")&&typeof t.with=="string"&&R(t,"can")&&typeof t.can=="string"}function to(t){return{with:Qi(t),can:j}}function eo(t){return{with:Yi(t.with),can:Xi(t.can)}}function ro(t){return{with:ji(t.with),can:Zi(t.can)}}function je(t){return it(t)&&R(t,"jwtAlg")&&typeof t.jwtAlg=="string"&&R(t,"sign")&&typeof t.sign=="function"}function io(t){return it(t)&&R(t,"alg")&&typeof t.alg=="string"&&R(t,"typ")&&typeof t.typ=="string"&&R(t,"ucv")&&Hi(t.ucv)}function oo(t){return it(t)&&R(t,"iss")&&typeof t.iss=="string"&&R(t,"aud")&&typeof t.aud=="string"&&R(t,"exp")&&typeof t.exp=="number"&&(!R(t,"nbf")||typeof t.nbf=="number")&&(!R(t,"nnc")||typeof t.nnc=="string")&&R(t,"att")&&Array.isArray(t.att)&&t.att.every(e=>Lt(e)||Ye(e))&&(!R(t,"fct")||Array.isArray(t.fct)&&t.fct.every(it))&&R(t,"prf")&&Array.isArray(t.prf)&&t.prf.every(e=>typeof e=="string")}var hu={major:0,minor:3,patch:0};function yu(t){return it(t)&&R(t,"alg")&&typeof t.alg=="string"&&R(t,"typ")&&typeof t.typ=="string"&&R(t,"uav")&&typeof t.uav=="string"}function mu(t){return it(t)&&R(t,"iss")&&typeof t.iss=="string"&&R(t,"aud")&&typeof t.aud=="string"&&(!R(t,"nbf")||typeof t.nbf=="number")&&R(t,"exp")&&typeof t.exp=="number"&&R(t,"rsc")&&(typeof t.rsc=="string"||it(t))&&R(t,"ptc")&&typeof t.ptc=="string"&&(!R(t,"prf")||typeof t.prf=="string")}function so(t,e){let n=(i,s)=>new Error(`Can't parse UCAN ${i}: ${s}`);if(!it(t))throw n("header","Invalid format: Expected a record");let r="0.9.1";if(!R(t,"ucv")||typeof t.ucv!="string"){if(!R(t,"uav")||typeof t.uav!="string")throw n("header","Invalid format: Missing version indicator");if(t.uav!=="1.0.0")throw n("header",`Unsupported version 'uav: ${t.uav}'`);r="0.3.0"}else if(Ae(t.ucv,"0.8.0"))throw n("header",`Unsupported version 'ucv: ${t.ucv}'`);if(Gi(r,"0.8.0")){if(typeof t.ucv!="string")throw n("header","Invalid format: Missing 'ucv' key or 'ucv' is not a string");if(t.ucv=Qe(t.ucv),t.ucv==null)throw n("header","Invalid format: 'ucv' string cannot be parsed into a semantic version");if(!io(t))throw n("header","Invalid format");if(!oo(e))throw n("payload","Invalid format");return{header:t,payload:e}}if(!yu(t))throw n("header","Invalid version 0.3.0 format");if(!mu(e))throw n("payload","Invalid version 0.3.0 format");return{header:{alg:t.alg,typ:t.typ,ucv:hu},payload:{iss:e.iss,aud:e.aud,nbf:e.nbf,exp:e.exp,att:(()=>{if(e.rsc===j||typeof e.rsc=="string")return[to(j)];let i=e.rsc;return Object.keys(i).map(s=>({with:{scheme:s,hierPart:i[s]},can:e.ptc===j?j:{namespace:s,segments:[e.ptc]}}))})(),prf:e.prf!=null?[e.prf]:[]}}}var ao=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},jt=function(t){return this instanceof jt?(this.v=t,this):new jt(t)},vu=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,s=[];return i={},f("next"),f("throw"),f("return"),i[Symbol.asyncIterator]=function(){return this},i;function f(x){r[x]&&(i[x]=function(L){return new Promise(function(E,A){s.push([x,L,E,A])>1||c(x,L)})})}function c(x,L){try{l(r[x](L))}catch(E){y(s[0][3],E)}}function l(x){x.value instanceof jt?Promise.resolve(x.value.v).then(p,u):y(s[0][2],x)}function p(x){c("next",x)}function u(x){c("throw",x)}function y(x,L){x(L),s.shift(),s.length&&c(s[0][0],s[0][1])}},wu="JWT",bu={major:0,minor:8,patch:1},uo=t=>e=>{let n=e.issuer,r=nn(Object.assign(Object.assign({},e),{issuer:n.did()}));return Ce(t)(r,n)};function nn(t){let{issuer:e,audience:n,capabilities:r=[],lifetimeInSeconds:i=30,expiration:s,notBefore:f,facts:c,proofs:l=[],addNonce:p=!1}=t;if(!e.startsWith("did:"))throw new Error("The issuer must be a DID");if(!n.startsWith("did:"))throw new Error("The audience must be a DID");let u=Math.floor(Date.now()/1e3),y=s||u+i;return{aud:n,att:r,exp:y,fct:c,iss:e,nbf:f,nnc:p?Ki():void 0,prf:l}}var on=t=>(e,n,r)=>ao(void 0,void 0,void 0,function*(){let i={alg:n,typ:wu,ucv:bu};if(!t.verifyIssuerAlg(e.iss,n))throw new Error("The issuer's key type must match the given key type.");let s=xu(i),f=Du(e),c=`${s}.${f}`,l=bt(c,"utf8"),p=yield r(l);return Object.freeze({header:i,payload:e,signedData:c,signature:St(p,"base64url")})}),Ce=t=>(e,n)=>on(t)(e,n.jwtAlg,r=>n.sign(r));function Dt(t){return`${t.signedData}.${t.signature}`}function xu(t){let e=Object.assign(Object.assign({},t),{ucv:Vi(t.ucv)});return St(bt(JSON.stringify(e),"utf8"),"base64url")}function Du(t){let e=Object.assign(Object.assign({},t),{att:t.att.map(eo)});return St(bt(JSON.stringify(e),"utf8"),"base64url")}function gu(t){let[e,n,r]=t.split(".");if(e==null||n==null||r==null)throw new Error(`Can't parse UCAN: ${t}: Expected JWT format: 3 dot-separated base64url-encoded values.`);let i,s;try{i=St(bt(e,"base64url"),"utf8")}catch{throw new Error(`Can't parse UCAN header: ${e}: Can't parse as base64url.`)}try{s=JSON.parse(i)}catch{throw new Error(`Can't parse UCAN header: ${e}: Can't parse encoded JSON inside.`)}let f,c;try{f=St(bt(n,"base64url"),"utf8")}catch{throw new Error(`Can't parse UCAN payload: ${n}: Can't parse as base64url.`)}try{c=JSON.parse(f)}catch{throw new Error(`Can't parse UCAN payload: ${n}: Can't parse encoded JSON inside.`)}let{header:l,payload:p}=so(s,c),u=p.att.reduce((y,x)=>Ye(x)?[...y,ro(x)]:Lt(x)?[...y,x]:y,[]);return{header:l,payload:Object.assign(Object.assign({},p),{att:u})}}var te=t=>(e,n)=>ao(void 0,void 0,void 0,function*(){let{checkIssuer:r=!0,checkSignature:i=!0,checkIsExpired:s=!0,checkIsTooEarly:f=!0}=n??{},{header:c,payload:l}=gu(e),[p,u,y]=e.split(".");if(r&&!t.verifyIssuerAlg(l.iss,c.alg))throw new Error(`Invalid UCAN: ${e}: Issuer key type does not match UCAN's \`alg\` property.`);if(i){let E=bt(y,"base64url"),A=bt(`${p}.${u}`,"utf8");if(!(yield t.verifySignature(l.iss,A,E)))throw new Error(`Invalid UCAN: ${e}: Signature invalid.`)}let x=`${p}.${u}`,L={header:c,payload:l,signedData:x,signature:y};if(s&&Eu(L))throw new Error(`Invalid UCAN: ${e}: Expired.`);if(f&&Su(L))throw new Error(`Invalid UCAN: ${e}: Not active yet (too early).`);return L}),tr=t=>function(e,n){return vu(this,arguments,function*(){let{checkAddressing:r=!0,checkTimeBoundsSubset:i=!0,checkVersionMonotonic:s=!0}=n||{};for(let f of e.payload.prf)try{let c=yield jt(te(t)(f,n));if(r&&e.payload.iss!==c.payload.aud)throw new Error(`Invalid Proof: Issuer ${e.payload.iss} doesn't match parent's audience ${c.payload.aud}`);if(i&&c.payload.nbf!=null&&e.payload.exp>c.payload.nbf)throw new Error(`Invalid Proof: 'Not before' (${c.payload.nbf}) is after parent's expiration (${e.payload.exp})`);if(i&&e.payload.nbf!=null&&e.payload.nbf>c.payload.exp)throw new Error(`Invalid Proof: Expiration (${c.payload.exp}) is before parent's 'not before' (${e.payload.nbf})`);if(s&&Ae(e.header.ucv,c.header.ucv))throw new Error(`Invalid Proof: Version (${c.header.ucv}) is higher than parent's version (${e.header.ucv})`);yield yield jt(c)}catch(c){c instanceof Error?yield yield jt(c):yield yield jt(new Error(`Error when trying to parse UCAN proof: ${c}`))}})};function Eu(t){return t.payload.exp<=Math.floor(Date.now()/1e3)}var Su=t=>t.payload.nbf==null?!1:t.payload.nbf>Math.floor(Date.now()/1e3);var Au=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},Z=function(t){return this instanceof Z?(this.v=t,this):new Z(t)},Mt=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(f){return new Promise(function(c,l){f=t[s](f),i(c,l,f.done,f.value)})}}function i(s,f,c,l){Promise.resolve(l).then(function(p){s({value:p,done:c})},f)}},Ie=function(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(f){return(n=!n)?{value:Z(t[i](f)),done:i==="return"}:s?s(f):f}:s}},Ue=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,s=[];return i={},f("next"),f("throw"),f("return"),i[Symbol.asyncIterator]=function(){return this},i;function f(x){r[x]&&(i[x]=function(L){return new Promise(function(E,A){s.push([x,L,E,A])>1||c(x,L)})})}function c(x,L){try{l(r[x](L))}catch(E){y(s[0][3],E)}}function l(x){x.value instanceof Z?Promise.resolve(x.value.v).then(p,u):y(s[0][2],x)}function p(x){c("next",x)}function u(x){c("throw",x)}function y(x,L){x(L),s.shift(),s.length&&c(s[0][0],s[0][1])}},Rt=t=>function(e,n,r=()=>Au(this,void 0,void 0,function*(){return!1})){return Ue(this,arguments,function*(){if(yield Z(r(n)))return yield yield Z(new Error(`UCAN Revoked: ${Dt(n)}`)),yield Z(void 0);yield Z(yield*Ie(Mt(_u(n)))),yield Z(yield*Ie(Mt(Iu(t,e,n,r))))})};function Pe(t){return"capability"in t?t.chainStep==null?t.ucan.payload.iss:Pe(t.chainStep):t.ownershipDID}var co={canDelegateResource(t,e){return t.scheme!==e.scheme?!1:t.hierPart===e.hierPart},canDelegateAbility(t,e){return t===j?!0:e===j||t.namespace!==e.namespace||t.segments.length!==e.segments.length?!1:t.segments.reduce((n,r,i)=>n&&e.segments[i]===r,!0)}};function ee(t,e,n){if("capability"in n)return Lu(t,n.capability,e);let r=n.scope;return r===j?!0:r.scheme==e.with.scheme&&t.canDelegateAbility(r.ability,e.can)}function Cu(t,e,n,r){if(e!==r.ownershipDID)return!1;let i=r.scope;return i===j?!0:n===j?!1:i.scheme===n.scheme&&t.canDelegateAbility(i.ability,n.ability)}function*_u(t){for(let e of t.payload.att)switch(e.with.scheme.toLowerCase()){case"my":{let n=e.with.hierPart===j?j:{scheme:e.with.hierPart,ability:e.can};yield{ownershipDID:t.payload.iss,scope:n,ucan:t};break}case"as":case"prf":break;default:yield{capability:e,ucan:t}}}function Iu(t,e,n,r){return Ue(this,arguments,function*(){var s,f;let c=0;try{for(var l=Mt(tr(t)(n)),p;p=yield Z(l.next()),!p.done;){let y=p.value;if(y instanceof Error){yield yield Z(y);continue}for(let x of n.payload.att)try{switch(x.with.scheme.toLowerCase()){case"my":continue;case"as":{yield Z(yield*Ie(Mt(Uu(t,e,x,n,y,r))));break}case"prf":{yield Z(yield*Ie(Mt(Pu(t,e,x,n,y,c,r))));break}default:yield Z(yield*Ie(Mt(Bu(t,e,x,n,y,r))))}}catch(L){yield yield Z(u(L))}c++}}catch(y){s={error:y}}finally{try{p&&!p.done&&(f=l.return)&&(yield Z(f.call(l)))}finally{if(s)throw s.error}}function u(y){return y instanceof Error?y:new Error(`Error during capability delegation checking: ${y}`)}})}function Uu(t,e,n,r,i,s){return Ue(this,arguments,function*(){var c,l;let p=n.with.hierPart.split(":"),u=p[p.length-1],y=p.slice(0,-1).join(":"),x=u===j?j:{scheme:u,ability:n.can};try{for(var L=Mt(Rt(t)(e,i,s)),E;E=yield Z(L.next()),!E.done;){let A=E.value;if(A instanceof Error){yield yield Z(A);continue}"ownershipDID"in A&&Cu(e,y,x,A)&&(yield yield Z({ownershipDID:y,scope:x,ucan:r,chainStep:A}))}}catch(A){c={error:A}}finally{try{E&&!E.done&&(l=L.return)&&(yield Z(l.call(L)))}finally{if(c)throw c.error}}})}function Pu(t,e,n,r,i,s,f){return Ue(this,arguments,function*(){var l,p;if(n.with.hierPart!==j&&parseInt(n.with.hierPart,10)!==s)return yield Z(void 0);try{for(var u=Mt(Rt(t)(e,i,f)),y;y=yield Z(u.next()),!y.done;){let x=y.value;if(x instanceof Error){yield yield Z(x);continue}"capability"in x&&(yield yield Z({capability:x.capability,ucan:r,chainStep:x}))}}catch(x){l={error:x}}finally{try{y&&!y.done&&(p=u.return)&&(yield Z(p.call(u)))}finally{if(l)throw l.error}}})}function Bu(t,e,n,r,i,s){return Ue(this,arguments,function*(){var c,l;try{for(var p=Mt(Rt(t)(e,i,s)),u;u=yield Z(p.next()),!u.done;){let y=u.value;if(y instanceof Error){yield yield Z(y);continue}ee(e,n,y)&&(yield yield Z({capability:n,ucan:r,chainStep:y}))}}catch(y){c={error:y}}finally{try{u&&!u.done&&(l=p.return)&&(yield Z(l.call(p)))}finally{if(c)throw c.error}}})}function Lu(t,e,n){return t.canDelegateResource(e.with,n.with)&&t.canDelegateAbility(e.can,n.can)}var fo=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},Fu=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(f){return new Promise(function(c,l){f=t[s](f),i(c,l,f.done,f.value)})}}function i(s,f,c,l){Promise.resolve(l).then(function(p){s({value:p,done:c})},f)}},Tu=t=>({ok:!0,value:t}),sn=t=>({ok:!1,error:t}),lo=t=>(e,n)=>fo(void 0,void 0,void 0,function*(){var r,i,s,f,c;let{audience:l,requiredCapabilities:p}=n,u=(s=n.semantics)!==null&&s!==void 0?s:co,y=(f=n.isRevoked)!==null&&f!==void 0?f:()=>fo(void 0,void 0,void 0,function*(){return!1}),x=(c=n.checkFacts)!==null&&c!==void 0?c:()=>!0;if(typeof e!="string")throw new TypeError(`Expected an encoded UCAN string as first argument, but got ${e}`);if(typeof l!="string"||!l.startsWith("did:"))throw new TypeError(`Expected a DID string as second argument, but got ${l}`);if(typeof y!="function")throw new TypeError(`Expected a function returning a promise as third argument, but got ${y}`);if(!Array.isArray(p))throw new TypeError(`Expected an array as fourth argument, but got ${p}`);if(p.length<1)throw new TypeError("Expected a non-empty list of required capabilities as 4th argument.");if(p.some(A=>!Lt(A.capability)||typeof A.rootIssuer!="string"||!A.rootIssuer.startsWith("did:")))throw new TypeError(`Expected an array of records of capabilities and rootIssuers as DID strings as 4th argument, but got ${p}`);if(typeof u.canDelegateResource!="function"||typeof u.canDelegateAbility!="function")throw new TypeError(`Expected a record with two functions 'canDelegateResource' and 'canDelegateAbility' as 5th argument, but got ${u}`);if(typeof x!="function")throw new TypeError(`Expected a function as 6th argument, but got ${x}`);try{let A=yield te(t)(e);if(A.payload.aud!==l)return sn([new Error(`Invalid UCAN: Expected audience to be ${l}, but it's ${A.payload.aud}`)]);let M=[],N=new Set(p),F=[];try{t:for(var L=Fu(Rt(t)(u,A,y)),E;E=yield L.next(),!E.done;){let I=E.value;if(I instanceof Error){M.push(I);continue}for(let P of N)ee(u,P.capability,I)&&Pe(I)===P.rootIssuer&&(N.delete(P),F.push(Object.assign(Object.assign({},P),{proof:I})));if(N.size===0)break t}}catch(I){r={error:I}}finally{try{E&&!E.done&&(i=L.return)&&(yield i.call(L))}finally{if(r)throw r.error}}return N.size>0?sn(M):Tu(F)}catch(A){return sn([A instanceof Error?A:new Error(`Unknown error during UCAN verification: ${A}`)])}});var Ru=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})};function po(t){return it(t)&&R(t,"issuer")&&je(t.issuer)&&R(t,"audience")&&typeof t.audience=="string"&&R(t,"expiration")&&typeof t.expiration=="number"}function Ou(t){return it(t)&&R(t,"issuer")&&je(t.issuer)&&R(t,"expiration")&&typeof t.expiration=="number"}var ku=t=>class Pt{constructor(n,r){this.state=n,this.defaultable=r}static create(){return new Pt({},{capabilities:[],facts:[],proofs:[],addNonce:!1})}issuedBy(n){if(!je(n))throw new TypeError(`Expected a Keypair, but got ${n}`);return new Pt(Object.assign(Object.assign({},this.state),{issuer:n}),this.defaultable)}toAudience(n){if(typeof n!="string")throw new TypeError(`Expected audience DID as string, but got ${n}`);return new Pt(Object.assign(Object.assign({},this.state),{audience:n}),this.defaultable)}withLifetimeInSeconds(n){if(typeof n!="number")throw new TypeError(`Expected seconds as number, but got ${n}`);if(!isFinite(n)||n<=0)throw new TypeError(`Expected seconds to be a positive number, but got ${n}`);return this.withExpiration(Math.floor(Date.now()/1e3)+n)}withExpiration(n){if(typeof n!="number"||!isFinite(n))throw new TypeError(`Expected expiration as number, but got ${n}`);if(this.defaultable.notBefore!=null&&n<this.defaultable.notBefore)throw new Error(`Can't set expiration to ${n} which is before 'notBefore': ${this.defaultable.notBefore}`);return new Pt(Object.assign(Object.assign({},this.state),{expiration:n}),this.defaultable)}withNotBefore(n){if(typeof n!="number"||!isFinite(n))throw new TypeError(`Expected notBeforeTimestamp as number, but got ${n}`);if(R(this.state,"expiration")&&typeof this.state.expiration=="number"&&this.state.expiration<n)throw new Error(`Can't set 'notBefore' to ${n} which is after expiration: ${this.state.expiration}`);return new Pt(this.state,Object.assign(Object.assign({},this.defaultable),{notBefore:n}))}withFact(n,...r){if(!it(n)||r.some(i=>!it(i)))throw new TypeError(`Expected fact(s) to be a record, but got ${n}`);return new Pt(this.state,Object.assign(Object.assign({},this.defaultable),{facts:[...this.defaultable.facts,n,...r]}))}withNonce(){return new Pt(this.state,Object.assign(Object.assign({},this.defaultable),{addNonce:!0}))}claimCapability(n,...r){if(!Lt(n))throw new TypeError(`Expected capability, but got ${JSON.stringify(n,null," ")}`);return new Pt(this.state,Object.assign(Object.assign({},this.defaultable),{capabilities:[...this.defaultable.capabilities,n,...r]}))}delegateCapability(n,r,i){if(!Lt(n))throw new TypeError(`Expected 'requiredCapability' as a second argument, but got ${n}`);if(!Ou(this.state))throw new Error("Can't delegate capabilities without having these paramenters set in the builder: issuer and expiration.");function s(f){return R(f,"capability")||R(f,"ownershipDID")}if(s(r)){if(i==null)throw new TypeError("Expected 'semantics' as third argument if a 'proof' DelegationChain was passed as second.");let f=r,c=f.ucan;if(!ee(i,n,f))throw new Error("Can't add capability to UCAN: Given proof doesn't give required rights to delegate.");return new Pt(this.state,Object.assign(Object.assign({},this.defaultable),{capabilities:[...this.defaultable.capabilities,n],proofs:this.defaultable.proofs.find(l=>Dt(l)===Dt(c))==null?[...this.defaultable.proofs,c]:this.defaultable.proofs}))}else{let f=r,c=this.state.issuer.did(),l=$i(f.findWithCapability(c,n,c));if(l!=null){let p=l.ucan,u=Dt(p);return new Pt(this.state,Object.assign(Object.assign({},this.defaultable),{capabilities:[...this.defaultable.capabilities,n],proofs:this.defaultable.proofs.find(y=>Dt(y)===u)==null?[...this.defaultable.proofs,p]:this.defaultable.proofs}))}else throw new Error("Couldn't add capability to UCAN. Couldn't find anything providing this capability in given store.")}}buildPayload(){if(!po(this.state))throw new Error("Builder is missing one of the required properties before it can be built: issuer, audience and expiration.");return nn({issuer:this.state.issuer.did(),audience:this.state.audience,expiration:this.state.expiration,notBefore:this.defaultable.notBefore,addNonce:this.defaultable.addNonce,capabilities:this.defaultable.capabilities,facts:this.defaultable.facts,proofs:this.defaultable.proofs.map(n=>Dt(n))})}build(){return Ru(this,void 0,void 0,function*(){if(!po(this.state))throw new Error("Builder is missing one of the required properties before it can be built: issuer, audience and expiration.");let n=this.buildPayload();return yield Ce(t)(n,this.state.issuer)})}},ho=ku;var yo=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},mo=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(f){return new Promise(function(c,l){f=t[s](f),i(c,l,f.done,f.value)})}}function i(s,f,c,l){Promise.resolve(l).then(function(p){s({value:p,done:c})},f)}},Ku=t=>class an{constructor(n,r){this.index=r,this.knownSemantics=n}static empty(n){return new an(n,{})}static fromTokens(n,r){var i,s,f,c;return yo(this,void 0,void 0,function*(){let l=an.empty(n);try{for(i=mo(r);s=yield i.next(),!s.done;){let p=s.value,u=yield te(t)(p);yield l.add(u)}}catch(p){f={error:p}}finally{try{s&&!s.done&&(c=i.return)&&(yield c.call(i))}finally{if(f)throw f.error}}return l})}add(n){var r,i,s;return yo(this,void 0,void 0,function*(){let f=n.payload.aud,c=(s=this.index[f])!==null&&s!==void 0?s:[],l=Dt(n);if(c.find(x=>Dt(x.processedUcan)===l)!=null)return;let p=[];try{for(var u=mo(Rt(t)(this.knownSemantics,n)),y;y=yield u.next(),!y.done;){let x=y.value;if(x instanceof Error){console.warn("Delegation chain error while storing UCAN:",x);continue}p.push(x)}}catch(x){r={error:x}}finally{try{y&&!y.done&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}c.find(x=>Dt(x.processedUcan)===l)==null&&(c.push({processedUcan:n,capabilities:p}),this.index[f]=c)})}getByAudience(n){var r;return((r=this.index[n])!==null&&r!==void 0?r:[]).map(i=>i.processedUcan)}findByAudience(n,r){var i,s,f;return(f=(s=(i=this.index[n])===null||i===void 0?void 0:i.find(c=>r(c.processedUcan)))===null||s===void 0?void 0:s.processedUcan)!==null&&f!==void 0?f:null}*findWithCapability(n,r,i){let s=this.index[n];if(s!=null)for(let f of s)for(let c of f.capabilities)ee(this.knownSemantics,r,c)&&Pe(c)===i&&(yield c)}},vo=Ku;var $u=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(f){f(s)})}return new(n||(n=Promise))(function(s,f){function c(u){try{p(r.next(u))}catch(y){f(y)}}function l(u){try{p(r.throw(u))}catch(y){f(y)}}function p(u){u.done?s(u.value):i(u.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},er=class{constructor(e,n){this.keys=e,this.methods=n}verifyIssuerAlg(e,n){let r=Do(e);if(r==="key"){let i=xo(e);for(let s of this.keys)if(wo(i,s.prefix))return n===s.jwtAlg}else{let i=this.methods[r];if(i)return i.checkJwtAlg(e,n)}throw new Error(`DID method not supported by plugins: ${e}`)}verifySignature(e,n,r){return $u(this,void 0,void 0,function*(){let i=Do(e);if(i==="key"){let s=xo(e);for(let f of this.keys)if(wo(s,f.prefix))return f.verifySignature(e,n,r)}else{let s=this.methods[i];if(s)return s.verifySignature(e,n,r)}throw new Error(`DID method not supported by plugins: ${e}`)})}};var wo=(t,e)=>re(e,t.subarray(0,e.byteLength)),bo="did:key:z",xo=t=>{if(!t.startsWith(bo))throw new Error(`Not a valid base58 formatted did:key: ${t}`);return bt(t.slice(bo.length),"base58btc")},Do=t=>{let e=t.split(":");if(e[0]!=="did")throw new Error(`Not a DID: ${t}`);if(e[1].length<1)throw new Error(`No DID method included: ${t}`);return e[1]};var go=t=>{let e=uo(t),n=on(t),r=Ce(t),i=te(t),s=tr(t),f=lo(t),c=Rt(t),l=ho(t),p=vo(t);return{build:e,sign:n,signWithKeypair:r,validate:i,validateProofs:s,verify:f,delegationChains:c,Builder:l,Store:p}};var Eo=new er([Fi,Oi,Mi,Ri],{});var Ot=go(Eo),So=Ot.build,mp=Ot.sign,vp=Ot.signWithKeypair,Ao=Ot.validate,wp=Ot.validateProofs,bp=Ot.verify,xp=Ot.Builder,Dp=Ot.Store,gp=Ot.delegationChains;var Ap=new Uint8Array(0);function Co(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==e[n])return!1;return!0}function le(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 Gu(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),f=s.charCodeAt(0);if(n[f]!==255)throw new TypeError(s+" is ambiguous");n[f]=i}var c=t.length,l=t.charAt(0),p=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function y(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 A=0,M=0,N=0,F=E.length;N!==F&&E[N]===0;)N++,A++;for(var I=(F-N)*u+1>>>0,P=new Uint8Array(I);N!==F;){for(var O=E[N],$=0,v=I-1;(O!==0||$<M)&&v!==-1;v--,$++)O+=256*P[v]>>>0,P[v]=O%c>>>0,O=O/c>>>0;if(O!==0)throw new Error("Non-zero carry");M=$,N++}for(var b=I-M;b!==I&&P[b]===0;)b++;for(var q=l.repeat(A);b<I;++b)q+=t.charAt(P[b]);return q}function x(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var A=0;if(E[A]!==" "){for(var M=0,N=0;E[A]===l;)M++,A++;for(var F=(E.length-A)*p+1>>>0,I=new Uint8Array(F);E[A];){var P=n[E.charCodeAt(A)];if(P===255)return;for(var O=0,$=F-1;(P!==0||O<N)&&$!==-1;$--,O++)P+=c*I[$]>>>0,I[$]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");N=O,A++}if(E[A]!==" "){for(var v=F-N;v!==F&&I[v]===0;)v++;for(var b=new Uint8Array(M+(F-v)),q=M;v!==F;)b[q++]=I[v++];return b}}}function L(E){var A=x(E);if(A)return A;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:x,decode:L}}var Ju=Gu,Xu=Ju,_o=Xu;var un=class{name;prefix;baseEncode;constructor(e,n,r){this.name=e,this.prefix=n,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},cn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,n,r){if(this.name=e,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r}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 Io(this,e)}},fn=class{decoders;constructor(e){this.decoders=e}or(e){return Io(this,e)}decode(e){let n=e[0],r=this.decoders[n];if(r!=null)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Io(t,e){return new fn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var ln=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,n,r,i){this.name=e,this.prefix=n,this.baseEncode=r,this.baseDecode=i,this.encoder=new un(e,n,r),this.decoder=new cn(e,n,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Uo({name:t,prefix:e,encode:n,decode:r}){return new ln(t,e,n,r)}function pn({name:t,prefix:e,alphabet:n}){let{encode:r,decode:i}=_o(n,t);return Uo({prefix:e,name:t,encode:r,decode:s=>le(i(s))})}function Zu(t,e,n,r){let i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;let f=new Uint8Array(s*n/8|0),c=0,l=0,p=0;for(let u=0;u<s;++u){let y=i[t[u]];if(y===void 0)throw new SyntaxError(`Non-${r} character`);l=l<<n|y,c+=n,c>=8&&(c-=8,f[p++]=255&l>>c)}if(c>=n||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return f}function Wu(t,e,n){let r=e[e.length-1]==="=",i=(1<<n)-1,s="",f=0,c=0;for(let l=0;l<t.length;++l)for(c=c<<8|t[l],f+=8;f>n;)f-=n,s+=e[i&c>>f];if(f!==0&&(s+=e[i&c<<n-f]),r)for(;s.length*n&7;)s+="=";return s}function Nt({name:t,prefix:e,bitsPerChar:n,alphabet:r}){return Uo({prefix:e,name:t,encode(i){return Wu(i,r,n)},decode(i){return Zu(i,r,n,t)}})}var Be=Nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Bp=Nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Lp=Nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Np=Nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Fp=Nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Tp=Nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Mp=Nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Rp=Nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Op=Nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var kt=pn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$p=pn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qu=Lo,Po=128,Yu=127,ju=~Yu,tc=Math.pow(2,31);function Lo(t,e,n){e=e||[],n=n||0;for(var r=n;t>=tc;)e[n++]=t&255|Po,t/=128;for(;t&ju;)e[n++]=t&255|Po,t>>>=7;return e[n]=t|0,Lo.bytes=n-r+1,e}var ec=dn,rc=128,Bo=127;function dn(t,r){var n=0,r=r||0,i=0,s=r,f,c=t.length;do{if(s>=c)throw dn.bytes=0,new RangeError("Could not decode varint");f=t[s++],n+=i<28?(f&Bo)<<i:(f&Bo)*Math.pow(2,i),i+=7}while(f>=rc);return dn.bytes=s-r,n}var nc=Math.pow(2,7),ic=Math.pow(2,14),oc=Math.pow(2,21),sc=Math.pow(2,28),ac=Math.pow(2,35),uc=Math.pow(2,42),cc=Math.pow(2,49),fc=Math.pow(2,56),lc=Math.pow(2,63),pc=function(t){return t<nc?1:t<ic?2:t<oc?3:t<sc?4:t<ac?5:t<uc?6:t<cc?7:t<fc?8:t<lc?9:10},dc={encode:Qu,decode:ec,encodingLength:pc},hc=dc,Le=hc;function Ne(t,e=0){return[Le.decode(t,e),Le.decode.bytes]}function pe(t,e,n=0){return Le.encode(t,e,n),e}function de(t){return Le.encodingLength(t)}function yn(t,e){let n=e.byteLength,r=de(t),i=r+de(n),s=new Uint8Array(i+n);return pe(t,s,0),pe(n,s,r),s.set(e,i),new he(t,n,e,s)}function No(t){let e=le(t),[n,r]=Ne(e),[i,s]=Ne(e.subarray(r)),f=e.subarray(r+s);if(f.byteLength!==i)throw new Error("Incorrect length");return new he(n,i,f,e)}function Fo(t,e){if(t===e)return!0;{let n=e;return t.code===n.code&&t.size===n.size&&n.bytes instanceof Uint8Array&&Co(t.bytes,n.bytes)}}var he=class{code;size;digest;bytes;constructor(e,n,r,i){this.code=e,this.size=n,this.digest=r,this.bytes=i}};function To(t,e){let{bytes:n,version:r}=t;switch(r){case 0:return mc(n,vn(t),e??kt.encoder);default:return vc(n,vn(t),e??Be.encoder)}}var Mo=new WeakMap;function vn(t){let e=Mo.get(t);if(e==null){let n=new Map;return Mo.set(t,n),n}return e}var Te=class t{code;version;multihash;bytes;"/";constructor(e,n,r,i){this.code=n,this.version=e,this.multihash=r,this.bytes=i,this["/"]=i}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:n}=this;if(e!==Fe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==wc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(n)}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:n}=this.multihash,r=yn(e,n);return t.createV1(this.code,r)}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,n){let r=n;return r!=null&&e.code===r.code&&e.version===r.version&&Fo(e.multihash,r.multihash)}toString(e){return To(this,e)}toJSON(){return{"/":To(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 n=e;if(n instanceof t)return n;if(n["/"]!=null&&n["/"]===n.bytes||n.asCID===n){let{version:r,code:i,multihash:s,bytes:f}=n;return new t(r,i,s,f??Ro(r,i,s.bytes))}else if(n[bc]===!0){let{version:r,multihash:i,code:s}=n,f=No(i);return t.create(r,s,f)}else return null}static create(e,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(n!==Fe)throw new Error(`Version 0 CID must use dag-pb (code: ${Fe}) block encoding`);return new t(e,n,r,r.bytes)}case 1:{let i=Ro(e,n,r.bytes);return new t(e,n,r,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Fe,e)}static createV1(e,n){return t.create(1,e,n)}static decode(e){let[n,r]=t.decodeFirst(e);if(r.length!==0)throw new Error("Incorrect length");return n}static decodeFirst(e){let n=t.inspectBytes(e),r=n.size-n.multihashSize,i=le(e.subarray(r,r+n.multihashSize));if(i.byteLength!==n.multihashSize)throw new Error("Incorrect length");let s=i.subarray(n.multihashSize-n.digestSize),f=new he(n.multihashCode,n.digestSize,s,i);return[n.version===0?t.createV0(f):t.createV1(n.codec,f),e.subarray(n.size)]}static inspectBytes(e){let n=0,r=()=>{let[y,x]=Ne(e.subarray(n));return n+=x,y},i=r(),s=Fe;if(i===18?(i=0,n=0):s=r(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let f=n,c=r(),l=r(),p=n+l,u=p-f;return{version:i,codec:s,multihashCode:c,digestSize:l,multihashSize:u,size:p}}static parse(e,n){let[r,i]=yc(e,n),s=t.decode(i);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return vn(s).set(r,e),s}};function yc(t,e){switch(t[0]){case"Q":{let n=e??kt;return[kt.prefix,n.decode(`${kt.prefix}${t}`)]}case kt.prefix:{let n=e??kt;return[kt.prefix,n.decode(t)]}case Be.prefix:{let n=e??Be;return[Be.prefix,n.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function mc(t,e,n){let{prefix:r}=n;if(r!==kt.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let i=e.get(r);if(i==null){let s=n.encode(t).slice(1);return e.set(r,s),s}else return i}function vc(t,e,n){let{prefix:r}=n,i=e.get(r);if(i==null){let s=n.encode(t);return e.set(r,s),s}else return i}var Fe=112,wc=18;function Ro(t,e,n){let r=de(t),i=r+de(e),s=new Uint8Array(i+n.byteLength);return pe(t,s,0),pe(e,s,r),s.set(n,i),s}var bc=Symbol.for("@ipld/js-cid/CID");var{WARN:ad,LOG:ud,DEBUG:ye,VERBOSE:cd,ERROR:fd}=or.setup(or.INFO);async function ld(t,e){let n=typeof e!="string",r=await(await fetch("https://api.nft.storage/upload",{method:"POST",headers:{Authorization:`Bearer ${n?Dt(e):e}`,"Content-Type":"application/car","x-agent-did":n?e.payload.iss:void 0},body:t})).json();if(ye("[storeCar] result",{result:r,isUcan:n}),!r.ok)throw new Error("Failed to upload"+JSON.stringify(r.error));return Te.parse(r.value.cid)}async function pd(t,e,n){ye("[createRequestToken] ",{keypair:t,ucanToken:n});let r=n.payload;return So({issuer:t,audience:e,capabilities:r.att,proofs:[Dt(n)]})}async function dd(t,e){ye("Registering",{did:e});let n=await(await fetch("https://api.nft.storage/user/did",{method:"POST",headers:{Authorization:`Bearer ${t}`},body:JSON.stringify({did:e})})).json();if(ye("Register DID result",n),!n.ok)throw new Error("Failed to register DID "+JSON.stringify(n.error))}async function hd(t){ye("Get root UCAN",{apiKey:t});let e=await(await fetch("https://api.nft.storage/ucan/token",{method:"POST",headers:{Authorization:`Bearer ${t}`}})).json();if(ye("Get root UCAN result",e),!e.ok)throw new Error("Failed get root UCAN "+JSON.stringify(e.error));return Ao(e.value)}export{ld as a,pd as b,dd as c,hd as d};
16
- //# sourceMappingURL=chunk-RCYKXPTN.min.js.map
16
+ //# sourceMappingURL=chunk-PRWLUGGV.min.js.map