@substrate-system/keys 0.2.32 → 0.2.34

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.
Files changed (53) hide show
  1. package/README.md +152 -35
  2. package/dist/_base.cjs +1 -1
  3. package/dist/_base.cjs.map +2 -2
  4. package/dist/_base.d.ts +2 -2
  5. package/dist/_base.d.ts.map +1 -1
  6. package/dist/_base.js +1 -1
  7. package/dist/_base.js.map +2 -2
  8. package/dist/_base.min.cjs +1 -1
  9. package/dist/_base.min.cjs.map +2 -2
  10. package/dist/_base.min.js +2 -2
  11. package/dist/_base.min.js.map +3 -3
  12. package/dist/aes/index.cjs +15 -9
  13. package/dist/aes/index.cjs.map +2 -2
  14. package/dist/aes/index.d.ts +12 -1
  15. package/dist/aes/index.d.ts.map +1 -1
  16. package/dist/aes/index.js +12 -5
  17. package/dist/aes/index.js.map +2 -2
  18. package/dist/aes/index.min.cjs +1 -1
  19. package/dist/aes/index.min.cjs.map +3 -3
  20. package/dist/aes/index.min.js +2 -2
  21. package/dist/aes/index.min.js.map +3 -3
  22. package/dist/browser/index.js +47 -23
  23. package/dist/browser/index.min.js +2 -2
  24. package/dist/ecc/index.cjs +12 -3
  25. package/dist/ecc/index.cjs.map +2 -2
  26. package/dist/ecc/index.d.ts +11 -2
  27. package/dist/ecc/index.d.ts.map +1 -1
  28. package/dist/ecc/index.js +13 -6
  29. package/dist/ecc/index.js.map +2 -2
  30. package/dist/ecc/index.min.cjs +1 -1
  31. package/dist/ecc/index.min.cjs.map +2 -2
  32. package/dist/ecc/index.min.js +2 -2
  33. package/dist/ecc/index.min.js.map +3 -3
  34. package/dist/index.min.js +2 -2
  35. package/dist/index.min.js.map +3 -3
  36. package/dist/meta.json +18 -18
  37. package/dist/rsa/index.cjs +9 -0
  38. package/dist/rsa/index.cjs.map +2 -2
  39. package/dist/rsa/index.d.ts +10 -4
  40. package/dist/rsa/index.d.ts.map +1 -1
  41. package/dist/rsa/index.js +9 -0
  42. package/dist/rsa/index.js.map +2 -2
  43. package/dist/rsa/index.min.cjs +1 -1
  44. package/dist/rsa/index.min.cjs.map +2 -2
  45. package/dist/rsa/index.min.js +2 -2
  46. package/dist/rsa/index.min.js.map +3 -3
  47. package/dist/types.cjs.map +2 -2
  48. package/dist/types.d.ts.map +1 -1
  49. package/dist/types.js.map +2 -2
  50. package/dist/types.min.cjs.map +2 -2
  51. package/dist/types.min.js.map +2 -2
  52. package/dist/util.min.js.map +2 -2
  53. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- var mf=Object.create;var Ke=Object.defineProperty;var wf=Object.getOwnPropertyDescriptor;var Ef=Object.getOwnPropertyNames;var Kf=Object.getPrototypeOf,vf=Object.prototype.hasOwnProperty;var Uf=(n,e,f)=>e in n?Ke(n,e,{enumerable:!0,configurable:!0,writable:!0,value:f}):n[e]=f;var y=(n,e)=>Ke(n,"name",{value:e,configurable:!0}),_n=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,f)=>(typeof require<"u"?require:e)[f]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Cn=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Dr=(n,e)=>{for(var f in e)Ke(n,f,{get:e[f],enumerable:!0})},Sf=(n,e,f,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let x of Ef(e))!vf.call(n,x)&&x!==f&&Ke(n,x,{get:()=>e[x],enumerable:!(c=wf(e,x))||c.enumerable});return n};var _f=(n,e,f)=>(f=n!=null?mf(Kf(n)):{},Sf(e||!n||!n.__esModule?Ke(f,"default",{value:n,enumerable:!0}):f,n));var O=(n,e,f)=>Uf(n,typeof e!="symbol"?e+"":e,f);var sf=Cn(()=>{"use strict"});var cf=Cn((gs,qe)=>{"use strict";(function(n){"use strict";var e=y(function(t){var o,i=new Float64Array(16);if(t)for(o=0;o<t.length;o++)i[o]=t[o];return i},"gf"),f=y(function(){throw new Error("no PRNG")},"randombytes"),c=new Uint8Array(16),x=new Uint8Array(32);x[0]=9;var l=e(),S=e([1]),Y=e([56129,1]),er=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),gr=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),sr=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Kr=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Yr=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function te(t,o,i,r){t[o]=i>>24&255,t[o+1]=i>>16&255,t[o+2]=i>>8&255,t[o+3]=i&255,t[o+4]=r>>24&255,t[o+5]=r>>16&255,t[o+6]=r>>8&255,t[o+7]=r&255}y(te,"ts64");function $(t,o,i,r,a){var u,p=0;for(u=0;u<a;u++)p|=t[o+u]^i[r+u];return(1&p-1>>>8)-1}y($,"vn");function cr(t,o,i,r){return $(t,o,i,r,16)}y(cr,"crypto_verify_16");function vr(t,o,i,r){return $(t,o,i,r,32)}y(vr,"crypto_verify_32");function wr(t,o,i,r){for(var a=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,u=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,p=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,b=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,E=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,T=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,v=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,q=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,_=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,M=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,L=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,H=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,j=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,N=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,z=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,R=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,C=a,D=u,U=p,B=b,P=E,K=T,h=v,d=q,m=_,g=M,A=L,w=H,I=j,F=N,V=z,G=R,s,k=0;k<20;k+=2)s=C+I|0,P^=s<<7|s>>>25,s=P+C|0,m^=s<<9|s>>>23,s=m+P|0,I^=s<<13|s>>>19,s=I+m|0,C^=s<<18|s>>>14,s=K+D|0,g^=s<<7|s>>>25,s=g+K|0,F^=s<<9|s>>>23,s=F+g|0,D^=s<<13|s>>>19,s=D+F|0,K^=s<<18|s>>>14,s=A+h|0,V^=s<<7|s>>>25,s=V+A|0,U^=s<<9|s>>>23,s=U+V|0,h^=s<<13|s>>>19,s=h+U|0,A^=s<<18|s>>>14,s=G+w|0,B^=s<<7|s>>>25,s=B+G|0,d^=s<<9|s>>>23,s=d+B|0,w^=s<<13|s>>>19,s=w+d|0,G^=s<<18|s>>>14,s=C+B|0,D^=s<<7|s>>>25,s=D+C|0,U^=s<<9|s>>>23,s=U+D|0,B^=s<<13|s>>>19,s=B+U|0,C^=s<<18|s>>>14,s=K+P|0,h^=s<<7|s>>>25,s=h+K|0,d^=s<<9|s>>>23,s=d+h|0,P^=s<<13|s>>>19,s=P+d|0,K^=s<<18|s>>>14,s=A+g|0,w^=s<<7|s>>>25,s=w+A|0,m^=s<<9|s>>>23,s=m+w|0,g^=s<<13|s>>>19,s=g+m|0,A^=s<<18|s>>>14,s=G+V|0,I^=s<<7|s>>>25,s=I+G|0,F^=s<<9|s>>>23,s=F+I|0,V^=s<<13|s>>>19,s=V+F|0,G^=s<<18|s>>>14;C=C+a|0,D=D+u|0,U=U+p|0,B=B+b|0,P=P+E|0,K=K+T|0,h=h+v|0,d=d+q|0,m=m+_|0,g=g+M|0,A=A+L|0,w=w+H|0,I=I+j|0,F=F+N|0,V=V+z|0,G=G+R|0,t[0]=C>>>0&255,t[1]=C>>>8&255,t[2]=C>>>16&255,t[3]=C>>>24&255,t[4]=D>>>0&255,t[5]=D>>>8&255,t[6]=D>>>16&255,t[7]=D>>>24&255,t[8]=U>>>0&255,t[9]=U>>>8&255,t[10]=U>>>16&255,t[11]=U>>>24&255,t[12]=B>>>0&255,t[13]=B>>>8&255,t[14]=B>>>16&255,t[15]=B>>>24&255,t[16]=P>>>0&255,t[17]=P>>>8&255,t[18]=P>>>16&255,t[19]=P>>>24&255,t[20]=K>>>0&255,t[21]=K>>>8&255,t[22]=K>>>16&255,t[23]=K>>>24&255,t[24]=h>>>0&255,t[25]=h>>>8&255,t[26]=h>>>16&255,t[27]=h>>>24&255,t[28]=d>>>0&255,t[29]=d>>>8&255,t[30]=d>>>16&255,t[31]=d>>>24&255,t[32]=m>>>0&255,t[33]=m>>>8&255,t[34]=m>>>16&255,t[35]=m>>>24&255,t[36]=g>>>0&255,t[37]=g>>>8&255,t[38]=g>>>16&255,t[39]=g>>>24&255,t[40]=A>>>0&255,t[41]=A>>>8&255,t[42]=A>>>16&255,t[43]=A>>>24&255,t[44]=w>>>0&255,t[45]=w>>>8&255,t[46]=w>>>16&255,t[47]=w>>>24&255,t[48]=I>>>0&255,t[49]=I>>>8&255,t[50]=I>>>16&255,t[51]=I>>>24&255,t[52]=F>>>0&255,t[53]=F>>>8&255,t[54]=F>>>16&255,t[55]=F>>>24&255,t[56]=V>>>0&255,t[57]=V>>>8&255,t[58]=V>>>16&255,t[59]=V>>>24&255,t[60]=G>>>0&255,t[61]=G>>>8&255,t[62]=G>>>16&255,t[63]=G>>>24&255}y(wr,"core_salsa20");function dr(t,o,i,r){for(var a=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,u=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,p=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,b=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,E=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,T=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,v=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,q=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,_=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,M=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,L=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,H=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,j=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,N=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,z=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,R=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,C=a,D=u,U=p,B=b,P=E,K=T,h=v,d=q,m=_,g=M,A=L,w=H,I=j,F=N,V=z,G=R,s,k=0;k<20;k+=2)s=C+I|0,P^=s<<7|s>>>25,s=P+C|0,m^=s<<9|s>>>23,s=m+P|0,I^=s<<13|s>>>19,s=I+m|0,C^=s<<18|s>>>14,s=K+D|0,g^=s<<7|s>>>25,s=g+K|0,F^=s<<9|s>>>23,s=F+g|0,D^=s<<13|s>>>19,s=D+F|0,K^=s<<18|s>>>14,s=A+h|0,V^=s<<7|s>>>25,s=V+A|0,U^=s<<9|s>>>23,s=U+V|0,h^=s<<13|s>>>19,s=h+U|0,A^=s<<18|s>>>14,s=G+w|0,B^=s<<7|s>>>25,s=B+G|0,d^=s<<9|s>>>23,s=d+B|0,w^=s<<13|s>>>19,s=w+d|0,G^=s<<18|s>>>14,s=C+B|0,D^=s<<7|s>>>25,s=D+C|0,U^=s<<9|s>>>23,s=U+D|0,B^=s<<13|s>>>19,s=B+U|0,C^=s<<18|s>>>14,s=K+P|0,h^=s<<7|s>>>25,s=h+K|0,d^=s<<9|s>>>23,s=d+h|0,P^=s<<13|s>>>19,s=P+d|0,K^=s<<18|s>>>14,s=A+g|0,w^=s<<7|s>>>25,s=w+A|0,m^=s<<9|s>>>23,s=m+w|0,g^=s<<13|s>>>19,s=g+m|0,A^=s<<18|s>>>14,s=G+V|0,I^=s<<7|s>>>25,s=I+G|0,F^=s<<9|s>>>23,s=F+I|0,V^=s<<13|s>>>19,s=V+F|0,G^=s<<18|s>>>14;t[0]=C>>>0&255,t[1]=C>>>8&255,t[2]=C>>>16&255,t[3]=C>>>24&255,t[4]=K>>>0&255,t[5]=K>>>8&255,t[6]=K>>>16&255,t[7]=K>>>24&255,t[8]=A>>>0&255,t[9]=A>>>8&255,t[10]=A>>>16&255,t[11]=A>>>24&255,t[12]=G>>>0&255,t[13]=G>>>8&255,t[14]=G>>>16&255,t[15]=G>>>24&255,t[16]=h>>>0&255,t[17]=h>>>8&255,t[18]=h>>>16&255,t[19]=h>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=m>>>0&255,t[25]=m>>>8&255,t[26]=m>>>16&255,t[27]=m>>>24&255,t[28]=g>>>0&255,t[29]=g>>>8&255,t[30]=g>>>16&255,t[31]=g>>>24&255}y(dr,"core_hsalsa20");function Er(t,o,i,r){wr(t,o,i,r)}y(Er,"crypto_core_salsa20");function lr(t,o,i,r){dr(t,o,i,r)}y(lr,"crypto_core_hsalsa20");var pr=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Ir(t,o,i,r,a,u,p){var b=new Uint8Array(16),E=new Uint8Array(64),T,v;for(v=0;v<16;v++)b[v]=0;for(v=0;v<8;v++)b[v]=u[v];for(;a>=64;){for(Er(E,b,p,pr),v=0;v<64;v++)t[o+v]=i[r+v]^E[v];for(T=1,v=8;v<16;v++)T=T+(b[v]&255)|0,b[v]=T&255,T>>>=8;a-=64,o+=64,r+=64}if(a>0)for(Er(E,b,p,pr),v=0;v<a;v++)t[o+v]=i[r+v]^E[v];return 0}y(Ir,"crypto_stream_salsa20_xor");function Ur(t,o,i,r,a){var u=new Uint8Array(16),p=new Uint8Array(64),b,E;for(E=0;E<16;E++)u[E]=0;for(E=0;E<8;E++)u[E]=r[E];for(;i>=64;){for(Er(p,u,a,pr),E=0;E<64;E++)t[o+E]=p[E];for(b=1,E=8;E<16;E++)b=b+(u[E]&255)|0,u[E]=b&255,b>>>=8;i-=64,o+=64}if(i>0)for(Er(p,u,a,pr),E=0;E<i;E++)t[o+E]=p[E];return 0}y(Ur,"crypto_stream_salsa20");function Pr(t,o,i,r,a){var u=new Uint8Array(32);lr(u,r,a,pr);for(var p=new Uint8Array(8),b=0;b<8;b++)p[b]=r[b+16];return Ur(t,o,i,p,u)}y(Pr,"crypto_stream");function Vr(t,o,i,r,a,u,p){var b=new Uint8Array(32);lr(b,u,p,pr);for(var E=new Uint8Array(8),T=0;T<8;T++)E[T]=u[T+16];return Ir(t,o,i,r,a,E,b)}y(Vr,"crypto_stream_xor");var Me=y(function(t){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var o,i,r,a,u,p,b,E;o=t[0]&255|(t[1]&255)<<8,this.r[0]=o&8191,i=t[2]&255|(t[3]&255)<<8,this.r[1]=(o>>>13|i<<3)&8191,r=t[4]&255|(t[5]&255)<<8,this.r[2]=(i>>>10|r<<6)&7939,a=t[6]&255|(t[7]&255)<<8,this.r[3]=(r>>>7|a<<9)&8191,u=t[8]&255|(t[9]&255)<<8,this.r[4]=(a>>>4|u<<12)&255,this.r[5]=u>>>1&8190,p=t[10]&255|(t[11]&255)<<8,this.r[6]=(u>>>14|p<<2)&8191,b=t[12]&255|(t[13]&255)<<8,this.r[7]=(p>>>11|b<<5)&8065,E=t[14]&255|(t[15]&255)<<8,this.r[8]=(b>>>8|E<<8)&8191,this.r[9]=E>>>5&127,this.pad[0]=t[16]&255|(t[17]&255)<<8,this.pad[1]=t[18]&255|(t[19]&255)<<8,this.pad[2]=t[20]&255|(t[21]&255)<<8,this.pad[3]=t[22]&255|(t[23]&255)<<8,this.pad[4]=t[24]&255|(t[25]&255)<<8,this.pad[5]=t[26]&255|(t[27]&255)<<8,this.pad[6]=t[28]&255|(t[29]&255)<<8,this.pad[7]=t[30]&255|(t[31]&255)<<8},"poly1305");Me.prototype.blocks=function(t,o,i){for(var r=this.fin?0:2048,a,u,p,b,E,T,v,q,_,M,L,H,j,N,z,R,C,D,U,B=this.h[0],P=this.h[1],K=this.h[2],h=this.h[3],d=this.h[4],m=this.h[5],g=this.h[6],A=this.h[7],w=this.h[8],I=this.h[9],F=this.r[0],V=this.r[1],G=this.r[2],s=this.r[3],k=this.r[4],Q=this.r[5],rr=this.r[6],X=this.r[7],Z=this.r[8],J=this.r[9];i>=16;)a=t[o+0]&255|(t[o+1]&255)<<8,B+=a&8191,u=t[o+2]&255|(t[o+3]&255)<<8,P+=(a>>>13|u<<3)&8191,p=t[o+4]&255|(t[o+5]&255)<<8,K+=(u>>>10|p<<6)&8191,b=t[o+6]&255|(t[o+7]&255)<<8,h+=(p>>>7|b<<9)&8191,E=t[o+8]&255|(t[o+9]&255)<<8,d+=(b>>>4|E<<12)&8191,m+=E>>>1&8191,T=t[o+10]&255|(t[o+11]&255)<<8,g+=(E>>>14|T<<2)&8191,v=t[o+12]&255|(t[o+13]&255)<<8,A+=(T>>>11|v<<5)&8191,q=t[o+14]&255|(t[o+15]&255)<<8,w+=(v>>>8|q<<8)&8191,I+=q>>>5|r,_=0,M=_,M+=B*F,M+=P*(5*J),M+=K*(5*Z),M+=h*(5*X),M+=d*(5*rr),_=M>>>13,M&=8191,M+=m*(5*Q),M+=g*(5*k),M+=A*(5*s),M+=w*(5*G),M+=I*(5*V),_+=M>>>13,M&=8191,L=_,L+=B*V,L+=P*F,L+=K*(5*J),L+=h*(5*Z),L+=d*(5*X),_=L>>>13,L&=8191,L+=m*(5*rr),L+=g*(5*Q),L+=A*(5*k),L+=w*(5*s),L+=I*(5*G),_+=L>>>13,L&=8191,H=_,H+=B*G,H+=P*V,H+=K*F,H+=h*(5*J),H+=d*(5*Z),_=H>>>13,H&=8191,H+=m*(5*X),H+=g*(5*rr),H+=A*(5*Q),H+=w*(5*k),H+=I*(5*s),_+=H>>>13,H&=8191,j=_,j+=B*s,j+=P*G,j+=K*V,j+=h*F,j+=d*(5*J),_=j>>>13,j&=8191,j+=m*(5*Z),j+=g*(5*X),j+=A*(5*rr),j+=w*(5*Q),j+=I*(5*k),_+=j>>>13,j&=8191,N=_,N+=B*k,N+=P*s,N+=K*G,N+=h*V,N+=d*F,_=N>>>13,N&=8191,N+=m*(5*J),N+=g*(5*Z),N+=A*(5*X),N+=w*(5*rr),N+=I*(5*Q),_+=N>>>13,N&=8191,z=_,z+=B*Q,z+=P*k,z+=K*s,z+=h*G,z+=d*V,_=z>>>13,z&=8191,z+=m*F,z+=g*(5*J),z+=A*(5*Z),z+=w*(5*X),z+=I*(5*rr),_+=z>>>13,z&=8191,R=_,R+=B*rr,R+=P*Q,R+=K*k,R+=h*s,R+=d*G,_=R>>>13,R&=8191,R+=m*V,R+=g*F,R+=A*(5*J),R+=w*(5*Z),R+=I*(5*X),_+=R>>>13,R&=8191,C=_,C+=B*X,C+=P*rr,C+=K*Q,C+=h*k,C+=d*s,_=C>>>13,C&=8191,C+=m*G,C+=g*V,C+=A*F,C+=w*(5*J),C+=I*(5*Z),_+=C>>>13,C&=8191,D=_,D+=B*Z,D+=P*X,D+=K*rr,D+=h*Q,D+=d*k,_=D>>>13,D&=8191,D+=m*s,D+=g*G,D+=A*V,D+=w*F,D+=I*(5*J),_+=D>>>13,D&=8191,U=_,U+=B*J,U+=P*Z,U+=K*X,U+=h*rr,U+=d*Q,_=U>>>13,U&=8191,U+=m*k,U+=g*s,U+=A*G,U+=w*V,U+=I*F,_+=U>>>13,U&=8191,_=(_<<2)+_|0,_=_+M|0,M=_&8191,_=_>>>13,L+=_,B=M,P=L,K=H,h=j,d=N,m=z,g=R,A=C,w=D,I=U,o+=16,i-=16;this.h[0]=B,this.h[1]=P,this.h[2]=K,this.h[3]=h,this.h[4]=d,this.h[5]=m,this.h[6]=g,this.h[7]=A,this.h[8]=w,this.h[9]=I},Me.prototype.finish=function(t,o){var i=new Uint16Array(10),r,a,u,p;if(this.leftover){for(p=this.leftover,this.buffer[p++]=1;p<16;p++)this.buffer[p]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,p=2;p<10;p++)this.h[p]+=r,r=this.h[p]>>>13,this.h[p]&=8191;for(this.h[0]+=r*5,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,i[0]=this.h[0]+5,r=i[0]>>>13,i[0]&=8191,p=1;p<10;p++)i[p]=this.h[p]+r,r=i[p]>>>13,i[p]&=8191;for(i[9]-=8192,a=(r^1)-1,p=0;p<10;p++)i[p]&=a;for(a=~a,p=0;p<10;p++)this.h[p]=this.h[p]&a|i[p];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,u=this.h[0]+this.pad[0],this.h[0]=u&65535,p=1;p<8;p++)u=(this.h[p]+this.pad[p]|0)+(u>>>16)|0,this.h[p]=u&65535;t[o+0]=this.h[0]>>>0&255,t[o+1]=this.h[0]>>>8&255,t[o+2]=this.h[1]>>>0&255,t[o+3]=this.h[1]>>>8&255,t[o+4]=this.h[2]>>>0&255,t[o+5]=this.h[2]>>>8&255,t[o+6]=this.h[3]>>>0&255,t[o+7]=this.h[3]>>>8&255,t[o+8]=this.h[4]>>>0&255,t[o+9]=this.h[4]>>>8&255,t[o+10]=this.h[5]>>>0&255,t[o+11]=this.h[5]>>>8&255,t[o+12]=this.h[6]>>>0&255,t[o+13]=this.h[6]>>>8&255,t[o+14]=this.h[7]>>>0&255,t[o+15]=this.h[7]>>>8&255},Me.prototype.update=function(t,o,i){var r,a;if(this.leftover){for(a=16-this.leftover,a>i&&(a=i),r=0;r<a;r++)this.buffer[this.leftover+r]=t[o+r];if(i-=a,o+=a,this.leftover+=a,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(i>=16&&(a=i-i%16,this.blocks(t,o,a),o+=a,i-=a),i){for(r=0;r<i;r++)this.buffer[this.leftover+r]=t[o+r];this.leftover+=i}};function nt(t,o,i,r,a,u){var p=new Me(u);return p.update(i,r,a),p.finish(t,o),0}y(nt,"crypto_onetimeauth");function pn(t,o,i,r,a,u){var p=new Uint8Array(16);return nt(p,0,i,r,a,u),cr(t,o,p,0)}y(pn,"crypto_onetimeauth_verify");function ft(t,o,i,r,a){var u;if(i<32)return-1;for(Vr(t,0,o,0,i,r,a),nt(t,16,t,32,i-32,t),u=0;u<16;u++)t[u]=0;return 0}y(ft,"crypto_secretbox");function it(t,o,i,r,a){var u,p=new Uint8Array(32);if(i<32||(Pr(p,0,32,r,a),pn(o,16,o,32,i-32,p)!==0))return-1;for(Vr(t,0,o,0,i,r,a),u=0;u<32;u++)t[u]=0;return 0}y(it,"crypto_secretbox_open");function jr(t,o){var i;for(i=0;i<16;i++)t[i]=o[i]|0}y(jr,"set25519");function ot(t){var o,i,r=1;for(o=0;o<16;o++)i=t[o]+r+65535,r=Math.floor(i/65536),t[o]=i-r*65536;t[0]+=r-1+37*(r-1)}y(ot,"car25519");function ne(t,o,i){for(var r,a=~(i-1),u=0;u<16;u++)r=a&(t[u]^o[u]),t[u]^=r,o[u]^=r}y(ne,"sel25519");function fe(t,o){var i,r,a,u=e(),p=e();for(i=0;i<16;i++)p[i]=o[i];for(ot(p),ot(p),ot(p),r=0;r<2;r++){for(u[0]=p[0]-65517,i=1;i<15;i++)u[i]=p[i]-65535-(u[i-1]>>16&1),u[i-1]&=65535;u[15]=p[15]-32767-(u[14]>>16&1),a=u[15]>>16&1,u[14]&=65535,ne(p,u,1-a)}for(i=0;i<16;i++)t[2*i]=p[i]&255,t[2*i+1]=p[i]>>8}y(fe,"pack25519");function hn(t,o){var i=new Uint8Array(32),r=new Uint8Array(32);return fe(i,t),fe(r,o),vr(i,0,r,0)}y(hn,"neq25519");function dn(t){var o=new Uint8Array(32);return fe(o,t),o[0]&1}y(dn,"par25519");function at(t,o){var i;for(i=0;i<16;i++)t[i]=o[2*i]+(o[2*i+1]<<8);t[15]&=32767}y(at,"unpack25519");function Mr(t,o,i){for(var r=0;r<16;r++)t[r]=o[r]+i[r]}y(Mr,"A");function Lr(t,o,i){for(var r=0;r<16;r++)t[r]=o[r]-i[r]}y(Lr,"Z");function W(t,o,i){var r,a,u=0,p=0,b=0,E=0,T=0,v=0,q=0,_=0,M=0,L=0,H=0,j=0,N=0,z=0,R=0,C=0,D=0,U=0,B=0,P=0,K=0,h=0,d=0,m=0,g=0,A=0,w=0,I=0,F=0,V=0,G=0,s=i[0],k=i[1],Q=i[2],rr=i[3],X=i[4],Z=i[5],J=i[6],yr=i[7],nr=i[8],fr=i[9],ir=i[10],or=i[11],ur=i[12],br=i[13],Ar=i[14],mr=i[15];r=o[0],u+=r*s,p+=r*k,b+=r*Q,E+=r*rr,T+=r*X,v+=r*Z,q+=r*J,_+=r*yr,M+=r*nr,L+=r*fr,H+=r*ir,j+=r*or,N+=r*ur,z+=r*br,R+=r*Ar,C+=r*mr,r=o[1],p+=r*s,b+=r*k,E+=r*Q,T+=r*rr,v+=r*X,q+=r*Z,_+=r*J,M+=r*yr,L+=r*nr,H+=r*fr,j+=r*ir,N+=r*or,z+=r*ur,R+=r*br,C+=r*Ar,D+=r*mr,r=o[2],b+=r*s,E+=r*k,T+=r*Q,v+=r*rr,q+=r*X,_+=r*Z,M+=r*J,L+=r*yr,H+=r*nr,j+=r*fr,N+=r*ir,z+=r*or,R+=r*ur,C+=r*br,D+=r*Ar,U+=r*mr,r=o[3],E+=r*s,T+=r*k,v+=r*Q,q+=r*rr,_+=r*X,M+=r*Z,L+=r*J,H+=r*yr,j+=r*nr,N+=r*fr,z+=r*ir,R+=r*or,C+=r*ur,D+=r*br,U+=r*Ar,B+=r*mr,r=o[4],T+=r*s,v+=r*k,q+=r*Q,_+=r*rr,M+=r*X,L+=r*Z,H+=r*J,j+=r*yr,N+=r*nr,z+=r*fr,R+=r*ir,C+=r*or,D+=r*ur,U+=r*br,B+=r*Ar,P+=r*mr,r=o[5],v+=r*s,q+=r*k,_+=r*Q,M+=r*rr,L+=r*X,H+=r*Z,j+=r*J,N+=r*yr,z+=r*nr,R+=r*fr,C+=r*ir,D+=r*or,U+=r*ur,B+=r*br,P+=r*Ar,K+=r*mr,r=o[6],q+=r*s,_+=r*k,M+=r*Q,L+=r*rr,H+=r*X,j+=r*Z,N+=r*J,z+=r*yr,R+=r*nr,C+=r*fr,D+=r*ir,U+=r*or,B+=r*ur,P+=r*br,K+=r*Ar,h+=r*mr,r=o[7],_+=r*s,M+=r*k,L+=r*Q,H+=r*rr,j+=r*X,N+=r*Z,z+=r*J,R+=r*yr,C+=r*nr,D+=r*fr,U+=r*ir,B+=r*or,P+=r*ur,K+=r*br,h+=r*Ar,d+=r*mr,r=o[8],M+=r*s,L+=r*k,H+=r*Q,j+=r*rr,N+=r*X,z+=r*Z,R+=r*J,C+=r*yr,D+=r*nr,U+=r*fr,B+=r*ir,P+=r*or,K+=r*ur,h+=r*br,d+=r*Ar,m+=r*mr,r=o[9],L+=r*s,H+=r*k,j+=r*Q,N+=r*rr,z+=r*X,R+=r*Z,C+=r*J,D+=r*yr,U+=r*nr,B+=r*fr,P+=r*ir,K+=r*or,h+=r*ur,d+=r*br,m+=r*Ar,g+=r*mr,r=o[10],H+=r*s,j+=r*k,N+=r*Q,z+=r*rr,R+=r*X,C+=r*Z,D+=r*J,U+=r*yr,B+=r*nr,P+=r*fr,K+=r*ir,h+=r*or,d+=r*ur,m+=r*br,g+=r*Ar,A+=r*mr,r=o[11],j+=r*s,N+=r*k,z+=r*Q,R+=r*rr,C+=r*X,D+=r*Z,U+=r*J,B+=r*yr,P+=r*nr,K+=r*fr,h+=r*ir,d+=r*or,m+=r*ur,g+=r*br,A+=r*Ar,w+=r*mr,r=o[12],N+=r*s,z+=r*k,R+=r*Q,C+=r*rr,D+=r*X,U+=r*Z,B+=r*J,P+=r*yr,K+=r*nr,h+=r*fr,d+=r*ir,m+=r*or,g+=r*ur,A+=r*br,w+=r*Ar,I+=r*mr,r=o[13],z+=r*s,R+=r*k,C+=r*Q,D+=r*rr,U+=r*X,B+=r*Z,P+=r*J,K+=r*yr,h+=r*nr,d+=r*fr,m+=r*ir,g+=r*or,A+=r*ur,w+=r*br,I+=r*Ar,F+=r*mr,r=o[14],R+=r*s,C+=r*k,D+=r*Q,U+=r*rr,B+=r*X,P+=r*Z,K+=r*J,h+=r*yr,d+=r*nr,m+=r*fr,g+=r*ir,A+=r*or,w+=r*ur,I+=r*br,F+=r*Ar,V+=r*mr,r=o[15],C+=r*s,D+=r*k,U+=r*Q,B+=r*rr,P+=r*X,K+=r*Z,h+=r*J,d+=r*yr,m+=r*nr,g+=r*fr,A+=r*ir,w+=r*or,I+=r*ur,F+=r*br,V+=r*Ar,G+=r*mr,u+=38*D,p+=38*U,b+=38*B,E+=38*P,T+=38*K,v+=38*h,q+=38*d,_+=38*m,M+=38*g,L+=38*A,H+=38*w,j+=38*I,N+=38*F,z+=38*V,R+=38*G,a=1,r=u+a+65535,a=Math.floor(r/65536),u=r-a*65536,r=p+a+65535,a=Math.floor(r/65536),p=r-a*65536,r=b+a+65535,a=Math.floor(r/65536),b=r-a*65536,r=E+a+65535,a=Math.floor(r/65536),E=r-a*65536,r=T+a+65535,a=Math.floor(r/65536),T=r-a*65536,r=v+a+65535,a=Math.floor(r/65536),v=r-a*65536,r=q+a+65535,a=Math.floor(r/65536),q=r-a*65536,r=_+a+65535,a=Math.floor(r/65536),_=r-a*65536,r=M+a+65535,a=Math.floor(r/65536),M=r-a*65536,r=L+a+65535,a=Math.floor(r/65536),L=r-a*65536,r=H+a+65535,a=Math.floor(r/65536),H=r-a*65536,r=j+a+65535,a=Math.floor(r/65536),j=r-a*65536,r=N+a+65535,a=Math.floor(r/65536),N=r-a*65536,r=z+a+65535,a=Math.floor(r/65536),z=r-a*65536,r=R+a+65535,a=Math.floor(r/65536),R=r-a*65536,r=C+a+65535,a=Math.floor(r/65536),C=r-a*65536,u+=a-1+37*(a-1),a=1,r=u+a+65535,a=Math.floor(r/65536),u=r-a*65536,r=p+a+65535,a=Math.floor(r/65536),p=r-a*65536,r=b+a+65535,a=Math.floor(r/65536),b=r-a*65536,r=E+a+65535,a=Math.floor(r/65536),E=r-a*65536,r=T+a+65535,a=Math.floor(r/65536),T=r-a*65536,r=v+a+65535,a=Math.floor(r/65536),v=r-a*65536,r=q+a+65535,a=Math.floor(r/65536),q=r-a*65536,r=_+a+65535,a=Math.floor(r/65536),_=r-a*65536,r=M+a+65535,a=Math.floor(r/65536),M=r-a*65536,r=L+a+65535,a=Math.floor(r/65536),L=r-a*65536,r=H+a+65535,a=Math.floor(r/65536),H=r-a*65536,r=j+a+65535,a=Math.floor(r/65536),j=r-a*65536,r=N+a+65535,a=Math.floor(r/65536),N=r-a*65536,r=z+a+65535,a=Math.floor(r/65536),z=r-a*65536,r=R+a+65535,a=Math.floor(r/65536),R=r-a*65536,r=C+a+65535,a=Math.floor(r/65536),C=r-a*65536,u+=a-1+37*(a-1),t[0]=u,t[1]=p,t[2]=b,t[3]=E,t[4]=T,t[5]=v,t[6]=q,t[7]=_,t[8]=M,t[9]=L,t[10]=H,t[11]=j,t[12]=N,t[13]=z,t[14]=R,t[15]=C}y(W,"M");function Tr(t,o){W(t,o,o)}y(Tr,"S");function ln(t,o){var i=e(),r;for(r=0;r<16;r++)i[r]=o[r];for(r=253;r>=0;r--)Tr(i,i),r!==2&&r!==4&&W(i,i,o);for(r=0;r<16;r++)t[r]=i[r]}y(ln,"inv25519");function gn(t,o){var i=e(),r;for(r=0;r<16;r++)i[r]=o[r];for(r=250;r>=0;r--)Tr(i,i),r!==1&&W(i,i,o);for(r=0;r<16;r++)t[r]=i[r]}y(gn,"pow2523");function Le(t,o,i){var r=new Uint8Array(32),a=new Float64Array(80),u,p,b=e(),E=e(),T=e(),v=e(),q=e(),_=e();for(p=0;p<31;p++)r[p]=o[p];for(r[31]=o[31]&127|64,r[0]&=248,at(a,i),p=0;p<16;p++)E[p]=a[p],v[p]=b[p]=T[p]=0;for(b[0]=v[0]=1,p=254;p>=0;--p)u=r[p>>>3]>>>(p&7)&1,ne(b,E,u),ne(T,v,u),Mr(q,b,T),Lr(b,b,T),Mr(T,E,v),Lr(E,E,v),Tr(v,q),Tr(_,b),W(b,T,b),W(T,E,q),Mr(q,b,T),Lr(b,b,T),Tr(E,b),Lr(T,v,_),W(b,T,Y),Mr(b,b,v),W(T,T,b),W(b,v,_),W(v,E,a),Tr(E,q),ne(b,E,u),ne(T,v,u);for(p=0;p<16;p++)a[p+16]=b[p],a[p+32]=T[p],a[p+48]=E[p],a[p+64]=v[p];var M=a.subarray(32),L=a.subarray(16);return ln(M,M),W(L,L,M),fe(t,L),0}y(Le,"crypto_scalarmult");function Ne(t,o){return Le(t,o,x)}y(Ne,"crypto_scalarmult_base");function bn(t,o){return f(o,32),Ne(t,o)}y(bn,"crypto_box_keypair");function Re(t,o,i){var r=new Uint8Array(32);return Le(r,i,o),lr(t,c,r,pr)}y(Re,"crypto_box_beforenm");var An=ft,pf=it;function hf(t,o,i,r,a,u){var p=new Uint8Array(32);return Re(p,a,u),An(t,o,i,r,p)}y(hf,"crypto_box");function df(t,o,i,r,a,u){var p=new Uint8Array(32);return Re(p,a,u),pf(t,o,i,r,p)}y(df,"crypto_box_open");var mn=[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 wn(t,o,i,r){for(var a=new Int32Array(16),u=new Int32Array(16),p,b,E,T,v,q,_,M,L,H,j,N,z,R,C,D,U,B,P,K,h,d,m,g,A,w,I=t[0],F=t[1],V=t[2],G=t[3],s=t[4],k=t[5],Q=t[6],rr=t[7],X=o[0],Z=o[1],J=o[2],yr=o[3],nr=o[4],fr=o[5],ir=o[6],or=o[7],ur=0;r>=128;){for(P=0;P<16;P++)K=8*P+ur,a[P]=i[K+0]<<24|i[K+1]<<16|i[K+2]<<8|i[K+3],u[P]=i[K+4]<<24|i[K+5]<<16|i[K+6]<<8|i[K+7];for(P=0;P<80;P++)if(p=I,b=F,E=V,T=G,v=s,q=k,_=Q,M=rr,L=X,H=Z,j=J,N=yr,z=nr,R=fr,C=ir,D=or,h=rr,d=or,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=(s>>>14|nr<<18)^(s>>>18|nr<<14)^(nr>>>9|s<<23),d=(nr>>>14|s<<18)^(nr>>>18|s<<14)^(s>>>9|nr<<23),m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,h=s&k^~s&Q,d=nr&fr^~nr&ir,m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,h=mn[P*2],d=mn[P*2+1],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,h=a[P%16],d=u[P%16],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,U=A&65535|w<<16,B=m&65535|g<<16,h=U,d=B,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=(I>>>28|X<<4)^(X>>>2|I<<30)^(X>>>7|I<<25),d=(X>>>28|I<<4)^(I>>>2|X<<30)^(I>>>7|X<<25),m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,h=I&F^I&V^F&V,d=X&Z^X&J^Z&J,m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,M=A&65535|w<<16,D=m&65535|g<<16,h=T,d=N,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=U,d=B,m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,T=A&65535|w<<16,N=m&65535|g<<16,F=p,V=b,G=E,s=T,k=v,Q=q,rr=_,I=M,Z=L,J=H,yr=j,nr=N,fr=z,ir=R,or=C,X=D,P%16===15)for(K=0;K<16;K++)h=a[K],d=u[K],m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=a[(K+9)%16],d=u[(K+9)%16],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,U=a[(K+1)%16],B=u[(K+1)%16],h=(U>>>1|B<<31)^(U>>>8|B<<24)^U>>>7,d=(B>>>1|U<<31)^(B>>>8|U<<24)^(B>>>7|U<<25),m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,U=a[(K+14)%16],B=u[(K+14)%16],h=(U>>>19|B<<13)^(B>>>29|U<<3)^U>>>6,d=(B>>>19|U<<13)^(U>>>29|B<<3)^(B>>>6|U<<26),m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,a[K]=A&65535|w<<16,u[K]=m&65535|g<<16;h=I,d=X,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[0],d=o[0],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[0]=I=A&65535|w<<16,o[0]=X=m&65535|g<<16,h=F,d=Z,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[1],d=o[1],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[1]=F=A&65535|w<<16,o[1]=Z=m&65535|g<<16,h=V,d=J,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[2],d=o[2],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[2]=V=A&65535|w<<16,o[2]=J=m&65535|g<<16,h=G,d=yr,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[3],d=o[3],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[3]=G=A&65535|w<<16,o[3]=yr=m&65535|g<<16,h=s,d=nr,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[4],d=o[4],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[4]=s=A&65535|w<<16,o[4]=nr=m&65535|g<<16,h=k,d=fr,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[5],d=o[5],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[5]=k=A&65535|w<<16,o[5]=fr=m&65535|g<<16,h=Q,d=ir,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[6],d=o[6],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[6]=Q=A&65535|w<<16,o[6]=ir=m&65535|g<<16,h=rr,d=or,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[7],d=o[7],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[7]=rr=A&65535|w<<16,o[7]=or=m&65535|g<<16,ur+=128,r-=128}return r}y(wn,"crypto_hashblocks_hl");function $r(t,o,i){var r=new Int32Array(8),a=new Int32Array(8),u=new Uint8Array(256),p,b=i;for(r[0]=1779033703,r[1]=3144134277,r[2]=1013904242,r[3]=2773480762,r[4]=1359893119,r[5]=2600822924,r[6]=528734635,r[7]=1541459225,a[0]=4089235720,a[1]=2227873595,a[2]=4271175723,a[3]=1595750129,a[4]=2917565137,a[5]=725511199,a[6]=4215389547,a[7]=327033209,wn(r,a,o,i),i%=128,p=0;p<i;p++)u[p]=o[b-i+p];for(u[i]=128,i=256-128*(i<112?1:0),u[i-9]=0,te(u,i-8,b/536870912|0,b<<3),wn(r,a,u,i),p=0;p<8;p++)te(t,8*p,r[p],a[p]);return 0}y($r,"crypto_hash");function ze(t,o){var i=e(),r=e(),a=e(),u=e(),p=e(),b=e(),E=e(),T=e(),v=e();Lr(i,t[1],t[0]),Lr(v,o[1],o[0]),W(i,i,v),Mr(r,t[0],t[1]),Mr(v,o[0],o[1]),W(r,r,v),W(a,t[3],o[3]),W(a,a,gr),W(u,t[2],o[2]),Mr(u,u,u),Lr(p,r,i),Lr(b,u,a),Mr(E,u,a),Mr(T,r,i),W(t[0],p,b),W(t[1],T,E),W(t[2],E,b),W(t[3],p,T)}y(ze,"add");function En(t,o,i){var r;for(r=0;r<4;r++)ne(t[r],o[r],i)}y(En,"cswap");function st(t,o){var i=e(),r=e(),a=e();ln(a,o[2]),W(i,o[0],a),W(r,o[1],a),fe(t,r),t[31]^=dn(i)<<7}y(st,"pack");function ct(t,o,i){var r,a;for(jr(t[0],l),jr(t[1],S),jr(t[2],S),jr(t[3],l),a=255;a>=0;--a)r=i[a/8|0]>>(a&7)&1,En(t,o,r),ze(o,t),ze(t,t),En(t,o,r)}y(ct,"scalarmult");function Oe(t,o){var i=[e(),e(),e(),e()];jr(i[0],sr),jr(i[1],Kr),jr(i[2],S),W(i[3],sr,Kr),ct(t,i,o)}y(Oe,"scalarbase");function yt(t,o,i){var r=new Uint8Array(64),a=[e(),e(),e(),e()],u;for(i||f(o,32),$r(r,o,32),r[0]&=248,r[31]&=127,r[31]|=64,Oe(a,r),st(t,a),u=0;u<32;u++)o[u+32]=t[u];return 0}y(yt,"crypto_sign_keypair");var Ye=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 xt(t,o){var i,r,a,u;for(r=63;r>=32;--r){for(i=0,a=r-32,u=r-12;a<u;++a)o[a]+=i-16*o[r]*Ye[a-(r-32)],i=Math.floor((o[a]+128)/256),o[a]-=i*256;o[a]+=i,o[r]=0}for(i=0,a=0;a<32;a++)o[a]+=i-(o[31]>>4)*Ye[a],i=o[a]>>8,o[a]&=255;for(a=0;a<32;a++)o[a]-=i*Ye[a];for(r=0;r<32;r++)o[r+1]+=o[r]>>8,t[r]=o[r]&255}y(xt,"modL");function ut(t){var o=new Float64Array(64),i;for(i=0;i<64;i++)o[i]=t[i];for(i=0;i<64;i++)t[i]=0;xt(t,o)}y(ut,"reduce");function Kn(t,o,i,r){var a=new Uint8Array(64),u=new Uint8Array(64),p=new Uint8Array(64),b,E,T=new Float64Array(64),v=[e(),e(),e(),e()];$r(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64;var q=i+64;for(b=0;b<i;b++)t[64+b]=o[b];for(b=0;b<32;b++)t[32+b]=a[32+b];for($r(p,t.subarray(32),i+32),ut(p),Oe(v,p),st(t,v),b=32;b<64;b++)t[b]=r[b];for($r(u,t,i+64),ut(u),b=0;b<64;b++)T[b]=0;for(b=0;b<32;b++)T[b]=p[b];for(b=0;b<32;b++)for(E=0;E<32;E++)T[b+E]+=u[b]*a[E];return xt(t.subarray(32),T),q}y(Kn,"crypto_sign");function lf(t,o){var i=e(),r=e(),a=e(),u=e(),p=e(),b=e(),E=e();return jr(t[2],S),at(t[1],o),Tr(a,t[1]),W(u,a,er),Lr(a,a,t[2]),Mr(u,t[2],u),Tr(p,u),Tr(b,p),W(E,b,p),W(i,E,a),W(i,i,u),gn(i,i),W(i,i,a),W(i,i,u),W(i,i,u),W(t[0],i,u),Tr(r,t[0]),W(r,r,u),hn(r,a)&&W(t[0],t[0],Yr),Tr(r,t[0]),W(r,r,u),hn(r,a)?-1:(dn(t[0])===o[31]>>7&&Lr(t[0],l,t[0]),W(t[3],t[0],t[1]),0)}y(lf,"unpackneg");function pt(t,o,i,r){var a,u=new Uint8Array(32),p=new Uint8Array(64),b=[e(),e(),e(),e()],E=[e(),e(),e(),e()];if(i<64||lf(E,r))return-1;for(a=0;a<i;a++)t[a]=o[a];for(a=0;a<32;a++)t[a+32]=r[a];if($r(p,t,i),ut(p),ct(b,E,p),Oe(E,o.subarray(32)),ze(b,E),st(u,b),i-=64,vr(o,0,u,0)){for(a=0;a<i;a++)t[a]=0;return-1}for(a=0;a<i;a++)t[a]=o[a+64];return i}y(pt,"crypto_sign_open");var ht=32,je=24,Ae=32,ie=16,me=32,He=32,we=32,Ee=32,dt=32,vn=je,gf=Ae,bf=ie,Hr=64,Zr=32,oe=64,lt=32,gt=64;n.lowlevel={crypto_core_hsalsa20:lr,crypto_stream_xor:Vr,crypto_stream:Pr,crypto_stream_salsa20_xor:Ir,crypto_stream_salsa20:Ur,crypto_onetimeauth:nt,crypto_onetimeauth_verify:pn,crypto_verify_16:cr,crypto_verify_32:vr,crypto_secretbox:ft,crypto_secretbox_open:it,crypto_scalarmult:Le,crypto_scalarmult_base:Ne,crypto_box_beforenm:Re,crypto_box_afternm:An,crypto_box:hf,crypto_box_open:df,crypto_box_keypair:bn,crypto_hash:$r,crypto_sign:Kn,crypto_sign_keypair:yt,crypto_sign_open:pt,crypto_secretbox_KEYBYTES:ht,crypto_secretbox_NONCEBYTES:je,crypto_secretbox_ZEROBYTES:Ae,crypto_secretbox_BOXZEROBYTES:ie,crypto_scalarmult_BYTES:me,crypto_scalarmult_SCALARBYTES:He,crypto_box_PUBLICKEYBYTES:we,crypto_box_SECRETKEYBYTES:Ee,crypto_box_BEFORENMBYTES:dt,crypto_box_NONCEBYTES:vn,crypto_box_ZEROBYTES:gf,crypto_box_BOXZEROBYTES:bf,crypto_sign_BYTES:Hr,crypto_sign_PUBLICKEYBYTES:Zr,crypto_sign_SECRETKEYBYTES:oe,crypto_sign_SEEDBYTES:lt,crypto_hash_BYTES:gt,gf:e,D:er,L:Ye,pack25519:fe,unpack25519:at,M:W,A:Mr,S:Tr,Z:Lr,pow2523:gn,add:ze,set25519:jr,modL:xt,scalarmult:ct,scalarbase:Oe};function Un(t,o){if(t.length!==ht)throw new Error("bad key size");if(o.length!==je)throw new Error("bad nonce size")}y(Un,"checkLengths");function Af(t,o){if(t.length!==we)throw new Error("bad public key size");if(o.length!==Ee)throw new Error("bad secret key size")}y(Af,"checkBoxLengths");function _r(){for(var t=0;t<arguments.length;t++)if(!(arguments[t]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}y(_r,"checkArrayTypes");function Sn(t){for(var o=0;o<t.length;o++)t[o]=0}y(Sn,"cleanup"),n.randomBytes=function(t){var o=new Uint8Array(t);return f(o,t),o},n.secretbox=function(t,o,i){_r(t,o,i),Un(i,o);for(var r=new Uint8Array(Ae+t.length),a=new Uint8Array(r.length),u=0;u<t.length;u++)r[u+Ae]=t[u];return ft(a,r,r.length,o,i),a.subarray(ie)},n.secretbox.open=function(t,o,i){_r(t,o,i),Un(i,o);for(var r=new Uint8Array(ie+t.length),a=new Uint8Array(r.length),u=0;u<t.length;u++)r[u+ie]=t[u];return r.length<32||it(a,r,r.length,o,i)!==0?null:a.subarray(Ae)},n.secretbox.keyLength=ht,n.secretbox.nonceLength=je,n.secretbox.overheadLength=ie,n.scalarMult=function(t,o){if(_r(t,o),t.length!==He)throw new Error("bad n size");if(o.length!==me)throw new Error("bad p size");var i=new Uint8Array(me);return Le(i,t,o),i},n.scalarMult.base=function(t){if(_r(t),t.length!==He)throw new Error("bad n size");var o=new Uint8Array(me);return Ne(o,t),o},n.scalarMult.scalarLength=He,n.scalarMult.groupElementLength=me,n.box=function(t,o,i,r){var a=n.box.before(i,r);return n.secretbox(t,o,a)},n.box.before=function(t,o){_r(t,o),Af(t,o);var i=new Uint8Array(dt);return Re(i,t,o),i},n.box.after=n.secretbox,n.box.open=function(t,o,i,r){var a=n.box.before(i,r);return n.secretbox.open(t,o,a)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var t=new Uint8Array(we),o=new Uint8Array(Ee);return bn(t,o),{publicKey:t,secretKey:o}},n.box.keyPair.fromSecretKey=function(t){if(_r(t),t.length!==Ee)throw new Error("bad secret key size");var o=new Uint8Array(we);return Ne(o,t),{publicKey:o,secretKey:new Uint8Array(t)}},n.box.publicKeyLength=we,n.box.secretKeyLength=Ee,n.box.sharedKeyLength=dt,n.box.nonceLength=vn,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(t,o){if(_r(t,o),o.length!==oe)throw new Error("bad secret key size");var i=new Uint8Array(Hr+t.length);return Kn(i,t,t.length,o),i},n.sign.open=function(t,o){if(_r(t,o),o.length!==Zr)throw new Error("bad public key size");var i=new Uint8Array(t.length),r=pt(i,t,t.length,o);if(r<0)return null;for(var a=new Uint8Array(r),u=0;u<a.length;u++)a[u]=i[u];return a},n.sign.detached=function(t,o){for(var i=n.sign(t,o),r=new Uint8Array(Hr),a=0;a<r.length;a++)r[a]=i[a];return r},n.sign.detached.verify=function(t,o,i){if(_r(t,o,i),o.length!==Hr)throw new Error("bad signature size");if(i.length!==Zr)throw new Error("bad public key size");var r=new Uint8Array(Hr+t.length),a=new Uint8Array(Hr+t.length),u;for(u=0;u<Hr;u++)r[u]=o[u];for(u=0;u<t.length;u++)r[u+Hr]=t[u];return pt(a,r,r.length,i)>=0},n.sign.keyPair=function(){var t=new Uint8Array(Zr),o=new Uint8Array(oe);return yt(t,o),{publicKey:t,secretKey:o}},n.sign.keyPair.fromSecretKey=function(t){if(_r(t),t.length!==oe)throw new Error("bad secret key size");for(var o=new Uint8Array(Zr),i=0;i<o.length;i++)o[i]=t[32+i];return{publicKey:o,secretKey:new Uint8Array(t)}},n.sign.keyPair.fromSeed=function(t){if(_r(t),t.length!==lt)throw new Error("bad seed size");for(var o=new Uint8Array(Zr),i=new Uint8Array(oe),r=0;r<32;r++)i[r]=t[r];return yt(o,i,!0),{publicKey:o,secretKey:i}},n.sign.publicKeyLength=Zr,n.sign.secretKeyLength=oe,n.sign.seedLength=lt,n.sign.signatureLength=Hr,n.hash=function(t){_r(t);var o=new Uint8Array(gt);return $r(o,t,t.length),o},n.hash.hashLength=gt,n.verify=function(t,o){return _r(t,o),t.length===0||o.length===0||t.length!==o.length?!1:$(t,0,o,0,t.length)===0},n.setPRNG=function(t){f=t},(function(){var t=typeof self<"u"?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){var o=65536;n.setPRNG(function(i,r){var a,u=new Uint8Array(r);for(a=0;a<r;a+=o)t.getRandomValues(u.subarray(a,a+Math.min(r-a,o)));for(a=0;a<r;a++)i[a]=u[a];Sn(u)})}else typeof _n<"u"&&(t=sf(),t&&t.randomBytes&&n.setPRNG(function(i,r){var a,u=t.randomBytes(r);for(a=0;a<r;a++)i[a]=u[a];Sn(u)}))})()})(typeof qe<"u"&&qe.exports?qe.exports:self.nacl=self.nacl||{})});var Cf=globalThis||window||self,tr=Cf.crypto;function ve(n=0){return new Uint8Array(n)}y(ve,"allocUnsafe");function bt(n,e){e==null&&(e=n.reduce((x,l)=>x+l.length,0));let f=ve(e),c=0;for(let x of n)f.set(x,c),c+=x.length;return f}y(bt,"concat");var _t={};Dr(_t,{base10:()=>Lf});var Eo=new Uint8Array(0);function Bn(n,e){if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let f=0;f<n.byteLength;f++)if(n[f]!==e[f])return!1;return!0}y(Bn,"equals");function Fr(n){if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")}y(Fr,"coerce");function Pn(n){return new TextEncoder().encode(n)}y(Pn,"fromString");function Tn(n){return new TextDecoder().decode(n)}y(Tn,"toString");function Pf(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var f=new Uint8Array(256),c=0;c<f.length;c++)f[c]=255;for(var x=0;x<n.length;x++){var l=n.charAt(x),S=l.charCodeAt(0);if(f[S]!==255)throw new TypeError(l+" is ambiguous");f[S]=x}var Y=n.length,er=n.charAt(0),gr=Math.log(Y)/Math.log(256),sr=Math.log(256)/Math.log(Y);function Kr($){if($ instanceof Uint8Array||(ArrayBuffer.isView($)?$=new Uint8Array($.buffer,$.byteOffset,$.byteLength):Array.isArray($)&&($=Uint8Array.from($))),!($ instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if($.length===0)return"";for(var cr=0,vr=0,wr=0,dr=$.length;wr!==dr&&$[wr]===0;)wr++,cr++;for(var Er=(dr-wr)*sr+1>>>0,lr=new Uint8Array(Er);wr!==dr;){for(var pr=$[wr],Ir=0,Ur=Er-1;(pr!==0||Ir<vr)&&Ur!==-1;Ur--,Ir++)pr+=256*lr[Ur]>>>0,lr[Ur]=pr%Y>>>0,pr=pr/Y>>>0;if(pr!==0)throw new Error("Non-zero carry");vr=Ir,wr++}for(var Pr=Er-vr;Pr!==Er&&lr[Pr]===0;)Pr++;for(var Vr=er.repeat(cr);Pr<Er;++Pr)Vr+=n.charAt(lr[Pr]);return Vr}y(Kr,"encode");function Yr($){if(typeof $!="string")throw new TypeError("Expected String");if($.length===0)return new Uint8Array;var cr=0;if($[cr]!==" "){for(var vr=0,wr=0;$[cr]===er;)vr++,cr++;for(var dr=($.length-cr)*gr+1>>>0,Er=new Uint8Array(dr);$[cr];){var lr=f[$.charCodeAt(cr)];if(lr===255)return;for(var pr=0,Ir=dr-1;(lr!==0||pr<wr)&&Ir!==-1;Ir--,pr++)lr+=Y*Er[Ir]>>>0,Er[Ir]=lr%256>>>0,lr=lr/256>>>0;if(lr!==0)throw new Error("Non-zero carry");wr=pr,cr++}if($[cr]!==" "){for(var Ur=dr-wr;Ur!==dr&&Er[Ur]===0;)Ur++;for(var Pr=new Uint8Array(vr+(dr-Ur)),Vr=vr;Ur!==dr;)Pr[Vr++]=Er[Ur++];return Pr}}}y(Yr,"decodeUnsafe");function te($){var cr=Yr($);if(cr)return cr;throw new Error(`Non-${e} character`)}return y(te,"decode"),{encode:Kr,decodeUnsafe:Yr,decode:te}}y(Pf,"base");var Tf=Pf,Df=Tf,In=Df;var Kt=class Kt{constructor(e,f,c){O(this,"name");O(this,"prefix");O(this,"baseEncode");this.name=e,this.prefix=f,this.baseEncode=c}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};y(Kt,"Encoder");var At=Kt,vt=class vt{constructor(e,f,c){O(this,"name");O(this,"prefix");O(this,"baseDecode");O(this,"prefixCodePoint");this.name=e,this.prefix=f;let x=f.codePointAt(0);if(x===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=x,this.baseDecode=c}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 Mn(this,e)}};y(vt,"Decoder");var mt=vt,Ut=class Ut{constructor(e){O(this,"decoders");this.decoders=e}or(e){return Mn(this,e)}decode(e){let f=e[0],c=this.decoders[f];if(c!=null)return c.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};y(Ut,"ComposedDecoder");var wt=Ut;function Mn(n,e){return new wt({...n.decoders??{[n.prefix]:n},...e.decoders??{[e.prefix]:e}})}y(Mn,"or");var St=class St{constructor(e,f,c,x){O(this,"name");O(this,"prefix");O(this,"baseEncode");O(this,"baseDecode");O(this,"encoder");O(this,"decoder");this.name=e,this.prefix=f,this.baseEncode=c,this.baseDecode=x,this.encoder=new At(e,f,c),this.decoder=new mt(e,f,x)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};y(St,"Codec");var Et=St;function ae({name:n,prefix:e,encode:f,decode:c}){return new Et(n,e,f,c)}y(ae,"from");function Xr({name:n,prefix:e,alphabet:f}){let{encode:c,decode:x}=In(f,n);return ae({prefix:e,name:n,encode:c,decode:y(l=>Fr(x(l)),"decode")})}y(Xr,"baseX");function If(n,e,f,c){let x={};for(let sr=0;sr<e.length;++sr)x[e[sr]]=sr;let l=n.length;for(;n[l-1]==="=";)--l;let S=new Uint8Array(l*f/8|0),Y=0,er=0,gr=0;for(let sr=0;sr<l;++sr){let Kr=x[n[sr]];if(Kr===void 0)throw new SyntaxError(`Non-${c} character`);er=er<<f|Kr,Y+=f,Y>=8&&(Y-=8,S[gr++]=255&er>>Y)}if(Y>=f||(255&er<<8-Y)!==0)throw new SyntaxError("Unexpected end of data");return S}y(If,"decode");function Mf(n,e,f){let c=e[e.length-1]==="=",x=(1<<f)-1,l="",S=0,Y=0;for(let er=0;er<n.length;++er)for(Y=Y<<8|n[er],S+=8;S>f;)S-=f,l+=e[x&Y>>S];if(S!==0&&(l+=e[x&Y<<f-S]),c)for(;(l.length*f&7)!==0;)l+="=";return l}y(Mf,"encode");function ar({name:n,prefix:e,bitsPerChar:f,alphabet:c}){return ae({prefix:e,name:n,encode(x){return Mf(x,c,f)},decode(x){return If(x,c,f,n)}})}y(ar,"rfc4648");var Lf=Xr({prefix:"9",name:"base10",alphabet:"0123456789"});var Ct={};Dr(Ct,{base16:()=>Nf,base16upper:()=>Rf});var Nf=ar({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Rf=ar({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bt={};Dr(Bt,{base2:()=>zf});var zf=ar({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Pt={};Dr(Pt,{base256emoji:()=>Ff});var Ln=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}"),Of=Ln.reduce((n,e,f)=>(n[f]=e,n),[]),Yf=Ln.reduce((n,e,f)=>{let c=e.codePointAt(0);if(c==null)throw new Error(`Invalid character: ${e}`);return n[c]=f,n},[]);function jf(n){return n.reduce((e,f)=>(e+=Of[f],e),"")}y(jf,"encode");function Hf(n){let e=[];for(let f of n){let c=f.codePointAt(0);if(c==null)throw new Error(`Invalid character: ${f}`);let x=Yf[c];if(x==null)throw new Error(`Non-base256emoji character: ${f}`);e.push(x)}return new Uint8Array(e)}y(Hf,"decode");var Ff=ae({prefix:"\u{1F680}",name:"base256emoji",encode:jf,decode:Hf});var Tt={};Dr(Tt,{base32:()=>se,base32hex:()=>kf,base32hexpad:()=>$f,base32hexpadupper:()=>Zf,base32hexupper:()=>Wf,base32pad:()=>Vf,base32padupper:()=>Xf,base32upper:()=>Gf,base32z:()=>Jf});var se=ar({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gf=ar({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Vf=ar({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Xf=ar({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kf=ar({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Wf=ar({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$f=ar({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zf=ar({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Jf=ar({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Dt={};Dr(Dt,{base36:()=>Ue,base36upper:()=>qf});var Ue=Xr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qf=Xr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var It={};Dr(It,{base58btc:()=>Rr,base58flickr:()=>Qf});var Rr=Xr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Qf=Xr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Mt={};Dr(Mt,{base64:()=>ri,base64pad:()=>ei,base64url:()=>ti,base64urlpad:()=>ni});var ri=ar({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ei=ar({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ti=ar({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ni=ar({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Lt={};Dr(Lt,{base8:()=>fi});var fi=ar({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Nt={};Dr(Nt,{identity:()=>ii});var ii=ae({prefix:"\0",name:"identity",encode:y(n=>Tn(n),"encode"),decode:y(n=>Pn(n),"decode")});var Fo=new TextEncoder,Go=new TextDecoder;var Ot={};Dr(Ot,{identity:()=>Ci});var si=zn,Nn=128,ci=127,yi=~ci,xi=Math.pow(2,31);function zn(n,e,f){e=e||[],f=f||0;for(var c=f;n>=xi;)e[f++]=n&255|Nn,n/=128;for(;n&yi;)e[f++]=n&255|Nn,n>>>=7;return e[f]=n|0,zn.bytes=f-c+1,e}y(zn,"encode");var ui=Rt,pi=128,Rn=127;function Rt(n,c){var f=0,c=c||0,x=0,l=c,S,Y=n.length;do{if(l>=Y)throw Rt.bytes=0,new RangeError("Could not decode varint");S=n[l++],f+=x<28?(S&Rn)<<x:(S&Rn)*Math.pow(2,x),x+=7}while(S>=pi);return Rt.bytes=l-c,f}y(Rt,"read");var hi=Math.pow(2,7),di=Math.pow(2,14),li=Math.pow(2,21),gi=Math.pow(2,28),bi=Math.pow(2,35),Ai=Math.pow(2,42),mi=Math.pow(2,49),wi=Math.pow(2,56),Ei=Math.pow(2,63),Ki=y(function(n){return n<hi?1:n<di?2:n<li?3:n<gi?4:n<bi?5:n<Ai?6:n<mi?7:n<wi?8:n<Ei?9:10},"length"),vi={encode:si,decode:ui,encodingLength:Ki},Ui=vi,Se=Ui;function _e(n,e=0){return[Se.decode(n,e),Se.decode.bytes]}y(_e,"decode");function ce(n,e,f=0){return Se.encode(n,e,f),e}y(ce,"encodeTo");function ye(n){return Se.encodingLength(n)}y(ye,"encodingLength");function Jr(n,e){let f=e.byteLength,c=ye(n),x=c+ye(f),l=new Uint8Array(x+f);return ce(n,l,0),ce(f,l,c),l.set(e,x),new xe(n,f,e,l)}y(Jr,"create");function On(n){let e=Fr(n),[f,c]=_e(e),[x,l]=_e(e.subarray(c)),S=e.subarray(c+l);if(S.byteLength!==x)throw new Error("Incorrect length");return new xe(f,x,S,e)}y(On,"decode");function Yn(n,e){if(n===e)return!0;{let f=e;return n.code===f.code&&n.size===f.size&&f.bytes instanceof Uint8Array&&Bn(n.bytes,f.bytes)}}y(Yn,"equals");var zt=class zt{constructor(e,f,c,x){O(this,"code");O(this,"size");O(this,"digest");O(this,"bytes");this.code=e,this.size=f,this.digest=c,this.bytes=x}};y(zt,"Digest");var xe=zt;var jn=0,Si="identity",Hn=Fr;function _i(n){return Jr(jn,Hn(n))}y(_i,"digest");var Ci={code:jn,name:Si,encode:Hn,digest:_i};var Ft={};Dr(Ft,{sha256:()=>Bi,sha512:()=>Pi});function jt({name:n,code:e,encode:f}){return new Yt(n,e,f)}y(jt,"from");var Ht=class Ht{constructor(e,f,c){O(this,"name");O(this,"code");O(this,"encode");this.name=e,this.code=f,this.encode=c}digest(e){if(e instanceof Uint8Array){let f=this.encode(e);return f instanceof Uint8Array?Jr(this.code,f):f.then(c=>Jr(this.code,c))}else throw Error("Unknown type, must be binary type")}};y(Ht,"Hasher");var Yt=Ht;function Gn(n){return async e=>new Uint8Array(await crypto.subtle.digest(n,e))}y(Gn,"sha");var Bi=jt({name:"sha2-256",code:18,encode:Gn("SHA-256")}),Pi=jt({name:"sha2-512",code:19,encode:Gn("SHA-512")});function Vn(n,e){let{bytes:f,version:c}=n;switch(c){case 0:return Di(f,Gt(n),e??Rr.encoder);default:return Ii(f,Gt(n),e??se.encoder)}}y(Vn,"format");var Xn=new WeakMap;function Gt(n){let e=Xn.get(n);if(e==null){let f=new Map;return Xn.set(n,f),f}return e}y(Gt,"baseCache");var Wn,hr=class hr{constructor(e,f,c,x){O(this,"code");O(this,"version");O(this,"multihash");O(this,"bytes");O(this,"/");O(this,Wn,"CID");this.code=f,this.version=e,this.multihash=c,this.bytes=x,this["/"]=x}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:f}=this;if(e!==Be)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(f.code!==Mi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return hr.createV0(f)}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:f}=this.multihash,c=Jr(e,f);return hr.createV1(this.code,c)}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 hr.equals(this,e)}static equals(e,f){let c=f;return c!=null&&e.code===c.code&&e.version===c.version&&Yn(e.multihash,c.multihash)}toString(e){return Vn(this,e)}toJSON(){return{"/":Vn(this)}}link(){return this}[(Wn=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let f=e;if(f instanceof hr)return f;if(f["/"]!=null&&f["/"]===f.bytes||f.asCID===f){let{version:c,code:x,multihash:l,bytes:S}=f;return new hr(c,x,l,S??kn(c,x,l.bytes))}else if(f[Li]===!0){let{version:c,multihash:x,code:l}=f,S=On(x);return hr.create(c,l,S)}else return null}static create(e,f,c){if(typeof f!="number")throw new Error("String codecs are no longer supported");if(!(c.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(f!==Be)throw new Error(`Version 0 CID must use dag-pb (code: ${Be}) block encoding`);return new hr(e,f,c,c.bytes)}case 1:{let x=kn(e,f,c.bytes);return new hr(e,f,c,x)}default:throw new Error("Invalid version")}}static createV0(e){return hr.create(0,Be,e)}static createV1(e,f){return hr.create(1,e,f)}static decode(e){let[f,c]=hr.decodeFirst(e);if(c.length!==0)throw new Error("Incorrect length");return f}static decodeFirst(e){let f=hr.inspectBytes(e),c=f.size-f.multihashSize,x=Fr(e.subarray(c,c+f.multihashSize));if(x.byteLength!==f.multihashSize)throw new Error("Incorrect length");let l=x.subarray(f.multihashSize-f.digestSize),S=new xe(f.multihashCode,f.digestSize,l,x);return[f.version===0?hr.createV0(S):hr.createV1(f.codec,S),e.subarray(f.size)]}static inspectBytes(e){let f=0,c=y(()=>{let[Kr,Yr]=_e(e.subarray(f));return f+=Yr,Kr},"next"),x=c(),l=Be;if(x===18?(x=0,f=0):l=c(),x!==0&&x!==1)throw new RangeError(`Invalid CID version ${x}`);let S=f,Y=c(),er=c(),gr=f+er,sr=gr-S;return{version:x,codec:l,multihashCode:Y,digestSize:er,multihashSize:sr,size:gr}}static parse(e,f){let[c,x]=Ti(e,f),l=hr.decode(x);if(l.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Gt(l).set(c,e),l}};y(hr,"CID");var Ge=hr;function Ti(n,e){switch(n[0]){case"Q":{let f=e??Rr;return[Rr.prefix,f.decode(`${Rr.prefix}${n}`)]}case Rr.prefix:{let f=e??Rr;return[Rr.prefix,f.decode(n)]}case se.prefix:{let f=e??se;return[se.prefix,f.decode(n)]}case Ue.prefix:{let f=e??Ue;return[Ue.prefix,f.decode(n)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[n[0],e.decode(n)]}}}y(Ti,"parseCIDtoBytes");function Di(n,e,f){let{prefix:c}=f;if(c!==Rr.prefix)throw Error(`Cannot string encode V0 in ${f.name} encoding`);let x=e.get(c);if(x==null){let l=f.encode(n).slice(1);return e.set(c,l),l}else return x}y(Di,"toStringV0");function Ii(n,e,f){let{prefix:c}=f,x=e.get(c);if(x==null){let l=f.encode(n);return e.set(c,l),l}else return x}y(Ii,"toStringV1");var Be=112,Mi=18;function kn(n,e,f){let c=ye(n),x=c+ye(e),l=new Uint8Array(x+f.byteLength);return ce(n,l,0),ce(e,l,c),l.set(f,x),l}y(kn,"encodeCID");var Li=Symbol.for("@ipld/js-cid/CID");var Vt={...Nt,...Bt,...Lt,..._t,...Ct,...Tt,...Dt,...It,...Mt,...Pt},wa={...Ft,...Ot};function Zn(n,e,f,c){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:f},decoder:{decode:c}}}y(Zn,"createCodec");var $n=Zn("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),Xt=Zn("ascii","a",n=>{let e="a";for(let f=0;f<n.length;f++)e+=String.fromCharCode(n[f]);return e},n=>{n=n.substring(1);let e=ve(n.length);for(let f=0;f<n.length;f++)e[f]=n.charCodeAt(f);return e}),Ni={utf8:$n,"utf-8":$n,hex:Vt.base16,latin1:Xt,ascii:Xt,binary:Xt,...Vt},Ve=Ni;function Cr(n,e="utf8"){let f=Ve[e];if(f==null)throw new Error(`Unsupported encoding "${e}"`);return f.decoder.decode(`${f.prefix}${n}`)}y(Cr,"fromString");function xr(n,e="utf8"){let f=Ve[e];if(f==null)throw new Error(`Unsupported encoding "${e}"`);return f.encoder.encode(n).substring(1)}y(xr,"toString");var qr="did:key:z",Pe="Ed25519",Jn="X25519",ka="X25519",qn="Ed25519",Qn="X25519";var ue="RSA-OAEP",pe="RSASSA-PKCS1-v1_5",kt="SHA-256",Wt=new Uint8Array([0,245,2]),Wa=2048,$t="SHA-256",he=8,de="AES-GCM",Gr=de,Qr=256,kr=12,Zt=new Uint8Array([234,1]),Jt=new Uint8Array([237,1]),Xe={RSA:"rsa",Edwards:"ed25519",BLS:"bls12-381"};var ke="ecc-exchange",We="ecc-write",zr=16;var rf=new Error("Invalid key use. Please use 'encryption' or 'signing"),Oi=new Error("Max must be less than 256 and greater than 0");function Br(n){return new Uint8Array(n).buffer}y(Br,"toArrayBuffer");async function ef(n){return new Uint8Array(await tr.subtle.digest("sha-256",n.buffer))}y(ef,"sha256");function Or(n){let e=Cr(n,"base64pad");return Br(e)}y(Or,"base64ToArrBuf");var De=y((n,e)=>{if(typeof n=="string")return e(n);if(typeof n=="object"&&n.byteLength!==void 0)return new Uint8Array(n).buffer;throw new Error("Improper value. Must be a string, ArrayBuffer, Uint8Array")},"normalizeToBuf");function $e(n){return De(n,Or)}y($e,"normalizeBase64ToBuf");var Yi=y(n=>De(n,e=>tf(e,8)),"normalizeUtf8ToBuf");function tf(n,e){let f=e===8?new Uint8Array(n.length):new Uint16Array(n.length);for(let c=0,x=n.length;c<x;c++)f[c]=n.charCodeAt(c);return f.buffer}y(tf,"strToArrBuf");var ji=y(n=>De(n,e=>tf(e,16)),"normalizeUtf16ToBuf");function le(n,e){switch(e){case 8:return Yi(n);default:return ji(n)}}y(le,"normalizeUnicodeToBuf");function nf(n){if(!n.startsWith(qr))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let e=""+n.substring(qr.length),f=Cr(e,"base58btc"),{keyBuffer:c,type:x}=Hi(Br(f));return{publicKey:new Uint8Array(c),type:x}}y(nf,"didToPublicKey");function Hi(n){if(Te(n,Br(Wt)))return{keyBuffer:n.slice(Wt.byteLength),type:Xe.RSA};if(Te(n,Br(Jt)))return{keyBuffer:n.slice(Jt.byteLength),type:Xe.Edwards};if(Te(n,Br(Zt)))return{keyBuffer:n.slice(Zt.byteLength),type:Xe.BLS};throw new Error("Unsupported key algorithm. Try using RSA.")}y(Hi,"parseMagicBytes");var Fi={equal:y((n,e)=>{let f=new Uint8Array(n),c=new Uint8Array(e);if(f.length!==c.length)return!1;for(let x=0;x<f.length;x++)if(f[x]!==c[x])return!1;return!0},"equal")};function Te(n,e){return Fi.equal(e,n.slice(0,e.byteLength))}y(Te,"hasPrefix");function Nr(n){return xr(n instanceof ArrayBuffer?new Uint8Array(n):n,"base64pad")}y(Nr,"toBase64");async function Qt(n,e){let f=typeof n=="string"?Or(n):Br(n);return tr.subtle.importKey("raw",f,{name:e?.alg||Gr,length:e?.length||Qr},!0,["encrypt","decrypt"])}y(Qt,"importKey");function ff(n,{max:e}={max:255}){if(e<1||e>255)throw Oi;let f=new Uint8Array(n);if(e===255)return tr.getRandomValues(f),f.buffer;let c=0,x=e+1,l=Math.floor(256/x)*x,S=new Uint8Array(1);for(;c<f.length;)tr.getRandomValues(S),S[0]<l&&(f[c]=S[0]%x,c++);return f.buffer}y(ff,"randomBuf");function Ze(n,e){let f=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(Br(n)),c=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(Br(e)),x=new Uint8Array(f.length+c.length);return x.set(f),x.set(c,f.length),x.buffer}y(Ze,"joinBufs");var is=new Error("Key does not exist. Make sure you properly instantiated the keystore."),os=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),as=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),ss=new Error("ECC is not enabled for this browser. Please use RSA instead."),cs=new Error("Cryptosystem not supported. Please use ECC or RSA"),Gi=new Error("Invalid key use. Please use 'exchange' or 'write'"),ys=new Error("Max must be less than 256 and greater than 0");function of(n){Vi(n,["exchange","write","signing"],Gi)}y(of,"checkValidKeyUse");function Vi(n,e,f){if(!e.some(x=>x===n))throw f}y(Vi,"checkValid");function Je(n){return new Promise((e,f)=>{n.oncomplete=n.onsuccess=()=>e(n.result),n.onabort=n.onerror=()=>f(n.error)})}y(Je,"promisifyRequest");function Xi(n,e){let f,c=y(()=>{if(f)return f;let x=indexedDB.open(n);return x.onupgradeneeded=()=>x.result.createObjectStore(e),f=Je(x),f.then(l=>{l.onclose=()=>f=void 0},()=>{}),f},"getDB");return(x,l)=>c().then(S=>l(S.transaction(e,x).objectStore(e)))}y(Xi,"createStore");var rn;function en(){return rn||(rn=Xi("keyval-store","keyval")),rn}y(en,"defaultGetStore");function tn(n,e=en()){return e("readonly",f=>Je(f.get(n)))}y(tn,"get");function nn(n,e,f=en()){return f("readwrite",c=>(c.put(e,n),Je(c.transaction)))}y(nn,"set");function af(n,e=en()){return e("readwrite",f=>(n.forEach(c=>f.delete(c)),Je(f.transaction)))}y(af,"delMany");var yf=_f(cf(),1);var an={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:y(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:Wi},ed25519:{magicBytes:new Uint8Array([237,1]),verify:ki}}};async function ki({message:n,publicKey:e,signature:f}){let c=n;typeof n=="string"&&(c=Cr(n,"utf8"));let x=f;typeof f=="string"&&(x=Cr(f,"base64pad"));let l=e;if(typeof e=="string"&&(l=xf(e).publicKey),l.length!==32)throw new Error(`Invalid Ed25519 public key size: ${l.length} bytes, expected 32`);if(x.length!==64)throw new Error(`Invalid Ed25519 signature size: ${x.length} bytes, expected 64`);return yf.default.sign.detached.verify(c,x,l)}y(ki,"ed25519Verify");async function Wi({message:n,publicKey:e,signature:f}){let c=e;return typeof e=="string"&&(c=xf(e).publicKey),sn.verify(n,f,await tr.subtle.importKey("spki",Br(c),{name:pe,hash:kt},!1,["verify"]),8)}y(Wi,"rsaVerify");var sn={verify:y(async function(e,f,c,x=he,l=$t){return tr.subtle.verify({name:pe,saltLength:zr},typeof c=="string"?await fn(c,l,"signing"):c,$e(f),le(e,x))},"rsaVerify"),sign:y(async function(e,f,c=he){return tr.subtle.sign({name:pe,saltLength:zr},f,le(e,c))},"sign"),encrypt:y(async function(e,f,c=he,x=$t){let l;return typeof f=="string"?l=await fn(f,x,"exchange"):l=f instanceof Uint8Array?await fn(Br(f),x,"exchange"):f,tr.subtle.encrypt({name:ue},l,le(e,c))},"rsaEncrypt"),decrypt:y(async function(e,f){let c=Qe(f)?f:await qi(f,["decrypt"]),x;typeof e=="string"?x=Cr(e,"base64pad"):x=e;let l=await tr.subtle.decrypt({name:ue},c,x instanceof Uint8Array?Br(x):x);return new Uint8Array(l)},"rsaDecrypt")};async function fn(n,e,f){$i(f);let c=f==="exchange"?ue:pe,x=f==="exchange"?["encrypt"]:["verify"],l=typeof n=="string"?Or(Ji(n)):n;return tr.subtle.importKey("spki",l,{name:c,hash:{name:e}},!0,x)}y(fn,"rsaImportPublicKey");function $i(n){Zi(n,["signing","exchange"],rf)}y($i,"checkValidKeyUse");function Zi(n,e,f){if(!e.some(x=>x===n))throw f}y(Zi,"checkValid");function Ji(n){return n.replace(`-----BEGIN PUBLIC KEY-----
1
+ var Af=Object.create;var Ee=Object.defineProperty;var mf=Object.getOwnPropertyDescriptor;var wf=Object.getOwnPropertyNames;var Ef=Object.getPrototypeOf,Kf=Object.prototype.hasOwnProperty;var vf=(n,e,f)=>e in n?Ee(n,e,{enumerable:!0,configurable:!0,writable:!0,value:f}):n[e]=f;var y=(n,e)=>Ee(n,"name",{value:e,configurable:!0}),Sn=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,f)=>(typeof require<"u"?require:e)[f]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var _n=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Dr=(n,e)=>{for(var f in e)Ee(n,f,{get:e[f],enumerable:!0})},Uf=(n,e,f,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let x of wf(e))!Kf.call(n,x)&&x!==f&&Ee(n,x,{get:()=>e[x],enumerable:!(c=mf(e,x))||c.enumerable});return n};var Sf=(n,e,f)=>(f=n!=null?Af(Ef(n)):{},Uf(e||!n||!n.__esModule?Ee(f,"default",{value:n,enumerable:!0}):f,n));var O=(n,e,f)=>vf(n,typeof e!="symbol"?e+"":e,f);var af=_n(()=>{"use strict"});var sf=_n((ls,Je)=>{"use strict";(function(n){"use strict";var e=y(function(t){var o,i=new Float64Array(16);if(t)for(o=0;o<t.length;o++)i[o]=t[o];return i},"gf"),f=y(function(){throw new Error("no PRNG")},"randombytes"),c=new Uint8Array(16),x=new Uint8Array(32);x[0]=9;var l=e(),S=e([1]),Y=e([56129,1]),er=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),br=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),sr=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),vr=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Yr=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function te(t,o,i,r){t[o]=i>>24&255,t[o+1]=i>>16&255,t[o+2]=i>>8&255,t[o+3]=i&255,t[o+4]=r>>24&255,t[o+5]=r>>16&255,t[o+6]=r>>8&255,t[o+7]=r&255}y(te,"ts64");function $(t,o,i,r,a){var u,p=0;for(u=0;u<a;u++)p|=t[o+u]^i[r+u];return(1&p-1>>>8)-1}y($,"vn");function cr(t,o,i,r){return $(t,o,i,r,16)}y(cr,"crypto_verify_16");function Ur(t,o,i,r){return $(t,o,i,r,32)}y(Ur,"crypto_verify_32");function Er(t,o,i,r){for(var a=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,u=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,p=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,b=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,E=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,T=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,v=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,q=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,_=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,M=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,L=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,H=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,j=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,N=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,z=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,R=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,C=a,D=u,U=p,B=b,P=E,K=T,h=v,d=q,m=_,g=M,A=L,w=H,I=j,F=N,V=z,G=R,s,k=0;k<20;k+=2)s=C+I|0,P^=s<<7|s>>>25,s=P+C|0,m^=s<<9|s>>>23,s=m+P|0,I^=s<<13|s>>>19,s=I+m|0,C^=s<<18|s>>>14,s=K+D|0,g^=s<<7|s>>>25,s=g+K|0,F^=s<<9|s>>>23,s=F+g|0,D^=s<<13|s>>>19,s=D+F|0,K^=s<<18|s>>>14,s=A+h|0,V^=s<<7|s>>>25,s=V+A|0,U^=s<<9|s>>>23,s=U+V|0,h^=s<<13|s>>>19,s=h+U|0,A^=s<<18|s>>>14,s=G+w|0,B^=s<<7|s>>>25,s=B+G|0,d^=s<<9|s>>>23,s=d+B|0,w^=s<<13|s>>>19,s=w+d|0,G^=s<<18|s>>>14,s=C+B|0,D^=s<<7|s>>>25,s=D+C|0,U^=s<<9|s>>>23,s=U+D|0,B^=s<<13|s>>>19,s=B+U|0,C^=s<<18|s>>>14,s=K+P|0,h^=s<<7|s>>>25,s=h+K|0,d^=s<<9|s>>>23,s=d+h|0,P^=s<<13|s>>>19,s=P+d|0,K^=s<<18|s>>>14,s=A+g|0,w^=s<<7|s>>>25,s=w+A|0,m^=s<<9|s>>>23,s=m+w|0,g^=s<<13|s>>>19,s=g+m|0,A^=s<<18|s>>>14,s=G+V|0,I^=s<<7|s>>>25,s=I+G|0,F^=s<<9|s>>>23,s=F+I|0,V^=s<<13|s>>>19,s=V+F|0,G^=s<<18|s>>>14;C=C+a|0,D=D+u|0,U=U+p|0,B=B+b|0,P=P+E|0,K=K+T|0,h=h+v|0,d=d+q|0,m=m+_|0,g=g+M|0,A=A+L|0,w=w+H|0,I=I+j|0,F=F+N|0,V=V+z|0,G=G+R|0,t[0]=C>>>0&255,t[1]=C>>>8&255,t[2]=C>>>16&255,t[3]=C>>>24&255,t[4]=D>>>0&255,t[5]=D>>>8&255,t[6]=D>>>16&255,t[7]=D>>>24&255,t[8]=U>>>0&255,t[9]=U>>>8&255,t[10]=U>>>16&255,t[11]=U>>>24&255,t[12]=B>>>0&255,t[13]=B>>>8&255,t[14]=B>>>16&255,t[15]=B>>>24&255,t[16]=P>>>0&255,t[17]=P>>>8&255,t[18]=P>>>16&255,t[19]=P>>>24&255,t[20]=K>>>0&255,t[21]=K>>>8&255,t[22]=K>>>16&255,t[23]=K>>>24&255,t[24]=h>>>0&255,t[25]=h>>>8&255,t[26]=h>>>16&255,t[27]=h>>>24&255,t[28]=d>>>0&255,t[29]=d>>>8&255,t[30]=d>>>16&255,t[31]=d>>>24&255,t[32]=m>>>0&255,t[33]=m>>>8&255,t[34]=m>>>16&255,t[35]=m>>>24&255,t[36]=g>>>0&255,t[37]=g>>>8&255,t[38]=g>>>16&255,t[39]=g>>>24&255,t[40]=A>>>0&255,t[41]=A>>>8&255,t[42]=A>>>16&255,t[43]=A>>>24&255,t[44]=w>>>0&255,t[45]=w>>>8&255,t[46]=w>>>16&255,t[47]=w>>>24&255,t[48]=I>>>0&255,t[49]=I>>>8&255,t[50]=I>>>16&255,t[51]=I>>>24&255,t[52]=F>>>0&255,t[53]=F>>>8&255,t[54]=F>>>16&255,t[55]=F>>>24&255,t[56]=V>>>0&255,t[57]=V>>>8&255,t[58]=V>>>16&255,t[59]=V>>>24&255,t[60]=G>>>0&255,t[61]=G>>>8&255,t[62]=G>>>16&255,t[63]=G>>>24&255}y(Er,"core_salsa20");function lr(t,o,i,r){for(var a=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,u=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,p=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,b=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,E=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,T=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,v=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,q=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,_=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,M=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,L=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,H=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,j=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,N=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,z=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,R=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,C=a,D=u,U=p,B=b,P=E,K=T,h=v,d=q,m=_,g=M,A=L,w=H,I=j,F=N,V=z,G=R,s,k=0;k<20;k+=2)s=C+I|0,P^=s<<7|s>>>25,s=P+C|0,m^=s<<9|s>>>23,s=m+P|0,I^=s<<13|s>>>19,s=I+m|0,C^=s<<18|s>>>14,s=K+D|0,g^=s<<7|s>>>25,s=g+K|0,F^=s<<9|s>>>23,s=F+g|0,D^=s<<13|s>>>19,s=D+F|0,K^=s<<18|s>>>14,s=A+h|0,V^=s<<7|s>>>25,s=V+A|0,U^=s<<9|s>>>23,s=U+V|0,h^=s<<13|s>>>19,s=h+U|0,A^=s<<18|s>>>14,s=G+w|0,B^=s<<7|s>>>25,s=B+G|0,d^=s<<9|s>>>23,s=d+B|0,w^=s<<13|s>>>19,s=w+d|0,G^=s<<18|s>>>14,s=C+B|0,D^=s<<7|s>>>25,s=D+C|0,U^=s<<9|s>>>23,s=U+D|0,B^=s<<13|s>>>19,s=B+U|0,C^=s<<18|s>>>14,s=K+P|0,h^=s<<7|s>>>25,s=h+K|0,d^=s<<9|s>>>23,s=d+h|0,P^=s<<13|s>>>19,s=P+d|0,K^=s<<18|s>>>14,s=A+g|0,w^=s<<7|s>>>25,s=w+A|0,m^=s<<9|s>>>23,s=m+w|0,g^=s<<13|s>>>19,s=g+m|0,A^=s<<18|s>>>14,s=G+V|0,I^=s<<7|s>>>25,s=I+G|0,F^=s<<9|s>>>23,s=F+I|0,V^=s<<13|s>>>19,s=V+F|0,G^=s<<18|s>>>14;t[0]=C>>>0&255,t[1]=C>>>8&255,t[2]=C>>>16&255,t[3]=C>>>24&255,t[4]=K>>>0&255,t[5]=K>>>8&255,t[6]=K>>>16&255,t[7]=K>>>24&255,t[8]=A>>>0&255,t[9]=A>>>8&255,t[10]=A>>>16&255,t[11]=A>>>24&255,t[12]=G>>>0&255,t[13]=G>>>8&255,t[14]=G>>>16&255,t[15]=G>>>24&255,t[16]=h>>>0&255,t[17]=h>>>8&255,t[18]=h>>>16&255,t[19]=h>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=m>>>0&255,t[25]=m>>>8&255,t[26]=m>>>16&255,t[27]=m>>>24&255,t[28]=g>>>0&255,t[29]=g>>>8&255,t[30]=g>>>16&255,t[31]=g>>>24&255}y(lr,"core_hsalsa20");function Kr(t,o,i,r){Er(t,o,i,r)}y(Kr,"crypto_core_salsa20");function gr(t,o,i,r){lr(t,o,i,r)}y(gr,"crypto_core_hsalsa20");var hr=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Ir(t,o,i,r,a,u,p){var b=new Uint8Array(16),E=new Uint8Array(64),T,v;for(v=0;v<16;v++)b[v]=0;for(v=0;v<8;v++)b[v]=u[v];for(;a>=64;){for(Kr(E,b,p,hr),v=0;v<64;v++)t[o+v]=i[r+v]^E[v];for(T=1,v=8;v<16;v++)T=T+(b[v]&255)|0,b[v]=T&255,T>>>=8;a-=64,o+=64,r+=64}if(a>0)for(Kr(E,b,p,hr),v=0;v<a;v++)t[o+v]=i[r+v]^E[v];return 0}y(Ir,"crypto_stream_salsa20_xor");function Sr(t,o,i,r,a){var u=new Uint8Array(16),p=new Uint8Array(64),b,E;for(E=0;E<16;E++)u[E]=0;for(E=0;E<8;E++)u[E]=r[E];for(;i>=64;){for(Kr(p,u,a,hr),E=0;E<64;E++)t[o+E]=p[E];for(b=1,E=8;E<16;E++)b=b+(u[E]&255)|0,u[E]=b&255,b>>>=8;i-=64,o+=64}if(i>0)for(Kr(p,u,a,hr),E=0;E<i;E++)t[o+E]=p[E];return 0}y(Sr,"crypto_stream_salsa20");function Pr(t,o,i,r,a){var u=new Uint8Array(32);gr(u,r,a,hr);for(var p=new Uint8Array(8),b=0;b<8;b++)p[b]=r[b+16];return Sr(t,o,i,p,u)}y(Pr,"crypto_stream");function Vr(t,o,i,r,a,u,p){var b=new Uint8Array(32);gr(b,u,p,hr);for(var E=new Uint8Array(8),T=0;T<8;T++)E[T]=u[T+16];return Ir(t,o,i,r,a,E,b)}y(Vr,"crypto_stream_xor");var Ie=y(function(t){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var o,i,r,a,u,p,b,E;o=t[0]&255|(t[1]&255)<<8,this.r[0]=o&8191,i=t[2]&255|(t[3]&255)<<8,this.r[1]=(o>>>13|i<<3)&8191,r=t[4]&255|(t[5]&255)<<8,this.r[2]=(i>>>10|r<<6)&7939,a=t[6]&255|(t[7]&255)<<8,this.r[3]=(r>>>7|a<<9)&8191,u=t[8]&255|(t[9]&255)<<8,this.r[4]=(a>>>4|u<<12)&255,this.r[5]=u>>>1&8190,p=t[10]&255|(t[11]&255)<<8,this.r[6]=(u>>>14|p<<2)&8191,b=t[12]&255|(t[13]&255)<<8,this.r[7]=(p>>>11|b<<5)&8065,E=t[14]&255|(t[15]&255)<<8,this.r[8]=(b>>>8|E<<8)&8191,this.r[9]=E>>>5&127,this.pad[0]=t[16]&255|(t[17]&255)<<8,this.pad[1]=t[18]&255|(t[19]&255)<<8,this.pad[2]=t[20]&255|(t[21]&255)<<8,this.pad[3]=t[22]&255|(t[23]&255)<<8,this.pad[4]=t[24]&255|(t[25]&255)<<8,this.pad[5]=t[26]&255|(t[27]&255)<<8,this.pad[6]=t[28]&255|(t[29]&255)<<8,this.pad[7]=t[30]&255|(t[31]&255)<<8},"poly1305");Ie.prototype.blocks=function(t,o,i){for(var r=this.fin?0:2048,a,u,p,b,E,T,v,q,_,M,L,H,j,N,z,R,C,D,U,B=this.h[0],P=this.h[1],K=this.h[2],h=this.h[3],d=this.h[4],m=this.h[5],g=this.h[6],A=this.h[7],w=this.h[8],I=this.h[9],F=this.r[0],V=this.r[1],G=this.r[2],s=this.r[3],k=this.r[4],Q=this.r[5],rr=this.r[6],X=this.r[7],Z=this.r[8],J=this.r[9];i>=16;)a=t[o+0]&255|(t[o+1]&255)<<8,B+=a&8191,u=t[o+2]&255|(t[o+3]&255)<<8,P+=(a>>>13|u<<3)&8191,p=t[o+4]&255|(t[o+5]&255)<<8,K+=(u>>>10|p<<6)&8191,b=t[o+6]&255|(t[o+7]&255)<<8,h+=(p>>>7|b<<9)&8191,E=t[o+8]&255|(t[o+9]&255)<<8,d+=(b>>>4|E<<12)&8191,m+=E>>>1&8191,T=t[o+10]&255|(t[o+11]&255)<<8,g+=(E>>>14|T<<2)&8191,v=t[o+12]&255|(t[o+13]&255)<<8,A+=(T>>>11|v<<5)&8191,q=t[o+14]&255|(t[o+15]&255)<<8,w+=(v>>>8|q<<8)&8191,I+=q>>>5|r,_=0,M=_,M+=B*F,M+=P*(5*J),M+=K*(5*Z),M+=h*(5*X),M+=d*(5*rr),_=M>>>13,M&=8191,M+=m*(5*Q),M+=g*(5*k),M+=A*(5*s),M+=w*(5*G),M+=I*(5*V),_+=M>>>13,M&=8191,L=_,L+=B*V,L+=P*F,L+=K*(5*J),L+=h*(5*Z),L+=d*(5*X),_=L>>>13,L&=8191,L+=m*(5*rr),L+=g*(5*Q),L+=A*(5*k),L+=w*(5*s),L+=I*(5*G),_+=L>>>13,L&=8191,H=_,H+=B*G,H+=P*V,H+=K*F,H+=h*(5*J),H+=d*(5*Z),_=H>>>13,H&=8191,H+=m*(5*X),H+=g*(5*rr),H+=A*(5*Q),H+=w*(5*k),H+=I*(5*s),_+=H>>>13,H&=8191,j=_,j+=B*s,j+=P*G,j+=K*V,j+=h*F,j+=d*(5*J),_=j>>>13,j&=8191,j+=m*(5*Z),j+=g*(5*X),j+=A*(5*rr),j+=w*(5*Q),j+=I*(5*k),_+=j>>>13,j&=8191,N=_,N+=B*k,N+=P*s,N+=K*G,N+=h*V,N+=d*F,_=N>>>13,N&=8191,N+=m*(5*J),N+=g*(5*Z),N+=A*(5*X),N+=w*(5*rr),N+=I*(5*Q),_+=N>>>13,N&=8191,z=_,z+=B*Q,z+=P*k,z+=K*s,z+=h*G,z+=d*V,_=z>>>13,z&=8191,z+=m*F,z+=g*(5*J),z+=A*(5*Z),z+=w*(5*X),z+=I*(5*rr),_+=z>>>13,z&=8191,R=_,R+=B*rr,R+=P*Q,R+=K*k,R+=h*s,R+=d*G,_=R>>>13,R&=8191,R+=m*V,R+=g*F,R+=A*(5*J),R+=w*(5*Z),R+=I*(5*X),_+=R>>>13,R&=8191,C=_,C+=B*X,C+=P*rr,C+=K*Q,C+=h*k,C+=d*s,_=C>>>13,C&=8191,C+=m*G,C+=g*V,C+=A*F,C+=w*(5*J),C+=I*(5*Z),_+=C>>>13,C&=8191,D=_,D+=B*Z,D+=P*X,D+=K*rr,D+=h*Q,D+=d*k,_=D>>>13,D&=8191,D+=m*s,D+=g*G,D+=A*V,D+=w*F,D+=I*(5*J),_+=D>>>13,D&=8191,U=_,U+=B*J,U+=P*Z,U+=K*X,U+=h*rr,U+=d*Q,_=U>>>13,U&=8191,U+=m*k,U+=g*s,U+=A*G,U+=w*V,U+=I*F,_+=U>>>13,U&=8191,_=(_<<2)+_|0,_=_+M|0,M=_&8191,_=_>>>13,L+=_,B=M,P=L,K=H,h=j,d=N,m=z,g=R,A=C,w=D,I=U,o+=16,i-=16;this.h[0]=B,this.h[1]=P,this.h[2]=K,this.h[3]=h,this.h[4]=d,this.h[5]=m,this.h[6]=g,this.h[7]=A,this.h[8]=w,this.h[9]=I},Ie.prototype.finish=function(t,o){var i=new Uint16Array(10),r,a,u,p;if(this.leftover){for(p=this.leftover,this.buffer[p++]=1;p<16;p++)this.buffer[p]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,p=2;p<10;p++)this.h[p]+=r,r=this.h[p]>>>13,this.h[p]&=8191;for(this.h[0]+=r*5,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,i[0]=this.h[0]+5,r=i[0]>>>13,i[0]&=8191,p=1;p<10;p++)i[p]=this.h[p]+r,r=i[p]>>>13,i[p]&=8191;for(i[9]-=8192,a=(r^1)-1,p=0;p<10;p++)i[p]&=a;for(a=~a,p=0;p<10;p++)this.h[p]=this.h[p]&a|i[p];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,u=this.h[0]+this.pad[0],this.h[0]=u&65535,p=1;p<8;p++)u=(this.h[p]+this.pad[p]|0)+(u>>>16)|0,this.h[p]=u&65535;t[o+0]=this.h[0]>>>0&255,t[o+1]=this.h[0]>>>8&255,t[o+2]=this.h[1]>>>0&255,t[o+3]=this.h[1]>>>8&255,t[o+4]=this.h[2]>>>0&255,t[o+5]=this.h[2]>>>8&255,t[o+6]=this.h[3]>>>0&255,t[o+7]=this.h[3]>>>8&255,t[o+8]=this.h[4]>>>0&255,t[o+9]=this.h[4]>>>8&255,t[o+10]=this.h[5]>>>0&255,t[o+11]=this.h[5]>>>8&255,t[o+12]=this.h[6]>>>0&255,t[o+13]=this.h[6]>>>8&255,t[o+14]=this.h[7]>>>0&255,t[o+15]=this.h[7]>>>8&255},Ie.prototype.update=function(t,o,i){var r,a;if(this.leftover){for(a=16-this.leftover,a>i&&(a=i),r=0;r<a;r++)this.buffer[this.leftover+r]=t[o+r];if(i-=a,o+=a,this.leftover+=a,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(i>=16&&(a=i-i%16,this.blocks(t,o,a),o+=a,i-=a),i){for(r=0;r<i;r++)this.buffer[this.leftover+r]=t[o+r];this.leftover+=i}};function tt(t,o,i,r,a,u){var p=new Ie(u);return p.update(i,r,a),p.finish(t,o),0}y(tt,"crypto_onetimeauth");function un(t,o,i,r,a,u){var p=new Uint8Array(16);return tt(p,0,i,r,a,u),cr(t,o,p,0)}y(un,"crypto_onetimeauth_verify");function nt(t,o,i,r,a){var u;if(i<32)return-1;for(Vr(t,0,o,0,i,r,a),tt(t,16,t,32,i-32,t),u=0;u<16;u++)t[u]=0;return 0}y(nt,"crypto_secretbox");function ft(t,o,i,r,a){var u,p=new Uint8Array(32);if(i<32||(Pr(p,0,32,r,a),un(o,16,o,32,i-32,p)!==0))return-1;for(Vr(t,0,o,0,i,r,a),u=0;u<32;u++)t[u]=0;return 0}y(ft,"crypto_secretbox_open");function jr(t,o){var i;for(i=0;i<16;i++)t[i]=o[i]|0}y(jr,"set25519");function it(t){var o,i,r=1;for(o=0;o<16;o++)i=t[o]+r+65535,r=Math.floor(i/65536),t[o]=i-r*65536;t[0]+=r-1+37*(r-1)}y(it,"car25519");function ne(t,o,i){for(var r,a=~(i-1),u=0;u<16;u++)r=a&(t[u]^o[u]),t[u]^=r,o[u]^=r}y(ne,"sel25519");function fe(t,o){var i,r,a,u=e(),p=e();for(i=0;i<16;i++)p[i]=o[i];for(it(p),it(p),it(p),r=0;r<2;r++){for(u[0]=p[0]-65517,i=1;i<15;i++)u[i]=p[i]-65535-(u[i-1]>>16&1),u[i-1]&=65535;u[15]=p[15]-32767-(u[14]>>16&1),a=u[15]>>16&1,u[14]&=65535,ne(p,u,1-a)}for(i=0;i<16;i++)t[2*i]=p[i]&255,t[2*i+1]=p[i]>>8}y(fe,"pack25519");function pn(t,o){var i=new Uint8Array(32),r=new Uint8Array(32);return fe(i,t),fe(r,o),Ur(i,0,r,0)}y(pn,"neq25519");function hn(t){var o=new Uint8Array(32);return fe(o,t),o[0]&1}y(hn,"par25519");function ot(t,o){var i;for(i=0;i<16;i++)t[i]=o[2*i]+(o[2*i+1]<<8);t[15]&=32767}y(ot,"unpack25519");function Mr(t,o,i){for(var r=0;r<16;r++)t[r]=o[r]+i[r]}y(Mr,"A");function Lr(t,o,i){for(var r=0;r<16;r++)t[r]=o[r]-i[r]}y(Lr,"Z");function W(t,o,i){var r,a,u=0,p=0,b=0,E=0,T=0,v=0,q=0,_=0,M=0,L=0,H=0,j=0,N=0,z=0,R=0,C=0,D=0,U=0,B=0,P=0,K=0,h=0,d=0,m=0,g=0,A=0,w=0,I=0,F=0,V=0,G=0,s=i[0],k=i[1],Q=i[2],rr=i[3],X=i[4],Z=i[5],J=i[6],yr=i[7],nr=i[8],fr=i[9],ir=i[10],or=i[11],pr=i[12],Ar=i[13],mr=i[14],wr=i[15];r=o[0],u+=r*s,p+=r*k,b+=r*Q,E+=r*rr,T+=r*X,v+=r*Z,q+=r*J,_+=r*yr,M+=r*nr,L+=r*fr,H+=r*ir,j+=r*or,N+=r*pr,z+=r*Ar,R+=r*mr,C+=r*wr,r=o[1],p+=r*s,b+=r*k,E+=r*Q,T+=r*rr,v+=r*X,q+=r*Z,_+=r*J,M+=r*yr,L+=r*nr,H+=r*fr,j+=r*ir,N+=r*or,z+=r*pr,R+=r*Ar,C+=r*mr,D+=r*wr,r=o[2],b+=r*s,E+=r*k,T+=r*Q,v+=r*rr,q+=r*X,_+=r*Z,M+=r*J,L+=r*yr,H+=r*nr,j+=r*fr,N+=r*ir,z+=r*or,R+=r*pr,C+=r*Ar,D+=r*mr,U+=r*wr,r=o[3],E+=r*s,T+=r*k,v+=r*Q,q+=r*rr,_+=r*X,M+=r*Z,L+=r*J,H+=r*yr,j+=r*nr,N+=r*fr,z+=r*ir,R+=r*or,C+=r*pr,D+=r*Ar,U+=r*mr,B+=r*wr,r=o[4],T+=r*s,v+=r*k,q+=r*Q,_+=r*rr,M+=r*X,L+=r*Z,H+=r*J,j+=r*yr,N+=r*nr,z+=r*fr,R+=r*ir,C+=r*or,D+=r*pr,U+=r*Ar,B+=r*mr,P+=r*wr,r=o[5],v+=r*s,q+=r*k,_+=r*Q,M+=r*rr,L+=r*X,H+=r*Z,j+=r*J,N+=r*yr,z+=r*nr,R+=r*fr,C+=r*ir,D+=r*or,U+=r*pr,B+=r*Ar,P+=r*mr,K+=r*wr,r=o[6],q+=r*s,_+=r*k,M+=r*Q,L+=r*rr,H+=r*X,j+=r*Z,N+=r*J,z+=r*yr,R+=r*nr,C+=r*fr,D+=r*ir,U+=r*or,B+=r*pr,P+=r*Ar,K+=r*mr,h+=r*wr,r=o[7],_+=r*s,M+=r*k,L+=r*Q,H+=r*rr,j+=r*X,N+=r*Z,z+=r*J,R+=r*yr,C+=r*nr,D+=r*fr,U+=r*ir,B+=r*or,P+=r*pr,K+=r*Ar,h+=r*mr,d+=r*wr,r=o[8],M+=r*s,L+=r*k,H+=r*Q,j+=r*rr,N+=r*X,z+=r*Z,R+=r*J,C+=r*yr,D+=r*nr,U+=r*fr,B+=r*ir,P+=r*or,K+=r*pr,h+=r*Ar,d+=r*mr,m+=r*wr,r=o[9],L+=r*s,H+=r*k,j+=r*Q,N+=r*rr,z+=r*X,R+=r*Z,C+=r*J,D+=r*yr,U+=r*nr,B+=r*fr,P+=r*ir,K+=r*or,h+=r*pr,d+=r*Ar,m+=r*mr,g+=r*wr,r=o[10],H+=r*s,j+=r*k,N+=r*Q,z+=r*rr,R+=r*X,C+=r*Z,D+=r*J,U+=r*yr,B+=r*nr,P+=r*fr,K+=r*ir,h+=r*or,d+=r*pr,m+=r*Ar,g+=r*mr,A+=r*wr,r=o[11],j+=r*s,N+=r*k,z+=r*Q,R+=r*rr,C+=r*X,D+=r*Z,U+=r*J,B+=r*yr,P+=r*nr,K+=r*fr,h+=r*ir,d+=r*or,m+=r*pr,g+=r*Ar,A+=r*mr,w+=r*wr,r=o[12],N+=r*s,z+=r*k,R+=r*Q,C+=r*rr,D+=r*X,U+=r*Z,B+=r*J,P+=r*yr,K+=r*nr,h+=r*fr,d+=r*ir,m+=r*or,g+=r*pr,A+=r*Ar,w+=r*mr,I+=r*wr,r=o[13],z+=r*s,R+=r*k,C+=r*Q,D+=r*rr,U+=r*X,B+=r*Z,P+=r*J,K+=r*yr,h+=r*nr,d+=r*fr,m+=r*ir,g+=r*or,A+=r*pr,w+=r*Ar,I+=r*mr,F+=r*wr,r=o[14],R+=r*s,C+=r*k,D+=r*Q,U+=r*rr,B+=r*X,P+=r*Z,K+=r*J,h+=r*yr,d+=r*nr,m+=r*fr,g+=r*ir,A+=r*or,w+=r*pr,I+=r*Ar,F+=r*mr,V+=r*wr,r=o[15],C+=r*s,D+=r*k,U+=r*Q,B+=r*rr,P+=r*X,K+=r*Z,h+=r*J,d+=r*yr,m+=r*nr,g+=r*fr,A+=r*ir,w+=r*or,I+=r*pr,F+=r*Ar,V+=r*mr,G+=r*wr,u+=38*D,p+=38*U,b+=38*B,E+=38*P,T+=38*K,v+=38*h,q+=38*d,_+=38*m,M+=38*g,L+=38*A,H+=38*w,j+=38*I,N+=38*F,z+=38*V,R+=38*G,a=1,r=u+a+65535,a=Math.floor(r/65536),u=r-a*65536,r=p+a+65535,a=Math.floor(r/65536),p=r-a*65536,r=b+a+65535,a=Math.floor(r/65536),b=r-a*65536,r=E+a+65535,a=Math.floor(r/65536),E=r-a*65536,r=T+a+65535,a=Math.floor(r/65536),T=r-a*65536,r=v+a+65535,a=Math.floor(r/65536),v=r-a*65536,r=q+a+65535,a=Math.floor(r/65536),q=r-a*65536,r=_+a+65535,a=Math.floor(r/65536),_=r-a*65536,r=M+a+65535,a=Math.floor(r/65536),M=r-a*65536,r=L+a+65535,a=Math.floor(r/65536),L=r-a*65536,r=H+a+65535,a=Math.floor(r/65536),H=r-a*65536,r=j+a+65535,a=Math.floor(r/65536),j=r-a*65536,r=N+a+65535,a=Math.floor(r/65536),N=r-a*65536,r=z+a+65535,a=Math.floor(r/65536),z=r-a*65536,r=R+a+65535,a=Math.floor(r/65536),R=r-a*65536,r=C+a+65535,a=Math.floor(r/65536),C=r-a*65536,u+=a-1+37*(a-1),a=1,r=u+a+65535,a=Math.floor(r/65536),u=r-a*65536,r=p+a+65535,a=Math.floor(r/65536),p=r-a*65536,r=b+a+65535,a=Math.floor(r/65536),b=r-a*65536,r=E+a+65535,a=Math.floor(r/65536),E=r-a*65536,r=T+a+65535,a=Math.floor(r/65536),T=r-a*65536,r=v+a+65535,a=Math.floor(r/65536),v=r-a*65536,r=q+a+65535,a=Math.floor(r/65536),q=r-a*65536,r=_+a+65535,a=Math.floor(r/65536),_=r-a*65536,r=M+a+65535,a=Math.floor(r/65536),M=r-a*65536,r=L+a+65535,a=Math.floor(r/65536),L=r-a*65536,r=H+a+65535,a=Math.floor(r/65536),H=r-a*65536,r=j+a+65535,a=Math.floor(r/65536),j=r-a*65536,r=N+a+65535,a=Math.floor(r/65536),N=r-a*65536,r=z+a+65535,a=Math.floor(r/65536),z=r-a*65536,r=R+a+65535,a=Math.floor(r/65536),R=r-a*65536,r=C+a+65535,a=Math.floor(r/65536),C=r-a*65536,u+=a-1+37*(a-1),t[0]=u,t[1]=p,t[2]=b,t[3]=E,t[4]=T,t[5]=v,t[6]=q,t[7]=_,t[8]=M,t[9]=L,t[10]=H,t[11]=j,t[12]=N,t[13]=z,t[14]=R,t[15]=C}y(W,"M");function Tr(t,o){W(t,o,o)}y(Tr,"S");function dn(t,o){var i=e(),r;for(r=0;r<16;r++)i[r]=o[r];for(r=253;r>=0;r--)Tr(i,i),r!==2&&r!==4&&W(i,i,o);for(r=0;r<16;r++)t[r]=i[r]}y(dn,"inv25519");function ln(t,o){var i=e(),r;for(r=0;r<16;r++)i[r]=o[r];for(r=250;r>=0;r--)Tr(i,i),r!==1&&W(i,i,o);for(r=0;r<16;r++)t[r]=i[r]}y(ln,"pow2523");function Me(t,o,i){var r=new Uint8Array(32),a=new Float64Array(80),u,p,b=e(),E=e(),T=e(),v=e(),q=e(),_=e();for(p=0;p<31;p++)r[p]=o[p];for(r[31]=o[31]&127|64,r[0]&=248,ot(a,i),p=0;p<16;p++)E[p]=a[p],v[p]=b[p]=T[p]=0;for(b[0]=v[0]=1,p=254;p>=0;--p)u=r[p>>>3]>>>(p&7)&1,ne(b,E,u),ne(T,v,u),Mr(q,b,T),Lr(b,b,T),Mr(T,E,v),Lr(E,E,v),Tr(v,q),Tr(_,b),W(b,T,b),W(T,E,q),Mr(q,b,T),Lr(b,b,T),Tr(E,b),Lr(T,v,_),W(b,T,Y),Mr(b,b,v),W(T,T,b),W(b,v,_),W(v,E,a),Tr(E,q),ne(b,E,u),ne(T,v,u);for(p=0;p<16;p++)a[p+16]=b[p],a[p+32]=T[p],a[p+48]=E[p],a[p+64]=v[p];var M=a.subarray(32),L=a.subarray(16);return dn(M,M),W(L,L,M),fe(t,L),0}y(Me,"crypto_scalarmult");function Le(t,o){return Me(t,o,x)}y(Le,"crypto_scalarmult_base");function gn(t,o){return f(o,32),Le(t,o)}y(gn,"crypto_box_keypair");function Ne(t,o,i){var r=new Uint8Array(32);return Me(r,i,o),gr(t,c,r,hr)}y(Ne,"crypto_box_beforenm");var bn=nt,uf=ft;function pf(t,o,i,r,a,u){var p=new Uint8Array(32);return Ne(p,a,u),bn(t,o,i,r,p)}y(pf,"crypto_box");function hf(t,o,i,r,a,u){var p=new Uint8Array(32);return Ne(p,a,u),uf(t,o,i,r,p)}y(hf,"crypto_box_open");var An=[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 mn(t,o,i,r){for(var a=new Int32Array(16),u=new Int32Array(16),p,b,E,T,v,q,_,M,L,H,j,N,z,R,C,D,U,B,P,K,h,d,m,g,A,w,I=t[0],F=t[1],V=t[2],G=t[3],s=t[4],k=t[5],Q=t[6],rr=t[7],X=o[0],Z=o[1],J=o[2],yr=o[3],nr=o[4],fr=o[5],ir=o[6],or=o[7],pr=0;r>=128;){for(P=0;P<16;P++)K=8*P+pr,a[P]=i[K+0]<<24|i[K+1]<<16|i[K+2]<<8|i[K+3],u[P]=i[K+4]<<24|i[K+5]<<16|i[K+6]<<8|i[K+7];for(P=0;P<80;P++)if(p=I,b=F,E=V,T=G,v=s,q=k,_=Q,M=rr,L=X,H=Z,j=J,N=yr,z=nr,R=fr,C=ir,D=or,h=rr,d=or,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=(s>>>14|nr<<18)^(s>>>18|nr<<14)^(nr>>>9|s<<23),d=(nr>>>14|s<<18)^(nr>>>18|s<<14)^(s>>>9|nr<<23),m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,h=s&k^~s&Q,d=nr&fr^~nr&ir,m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,h=An[P*2],d=An[P*2+1],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,h=a[P%16],d=u[P%16],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,U=A&65535|w<<16,B=m&65535|g<<16,h=U,d=B,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=(I>>>28|X<<4)^(X>>>2|I<<30)^(X>>>7|I<<25),d=(X>>>28|I<<4)^(I>>>2|X<<30)^(I>>>7|X<<25),m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,h=I&F^I&V^F&V,d=X&Z^X&J^Z&J,m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,M=A&65535|w<<16,D=m&65535|g<<16,h=T,d=N,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=U,d=B,m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,T=A&65535|w<<16,N=m&65535|g<<16,F=p,V=b,G=E,s=T,k=v,Q=q,rr=_,I=M,Z=L,J=H,yr=j,nr=N,fr=z,ir=R,or=C,X=D,P%16===15)for(K=0;K<16;K++)h=a[K],d=u[K],m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=a[(K+9)%16],d=u[(K+9)%16],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,U=a[(K+1)%16],B=u[(K+1)%16],h=(U>>>1|B<<31)^(U>>>8|B<<24)^U>>>7,d=(B>>>1|U<<31)^(B>>>8|U<<24)^(B>>>7|U<<25),m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,U=a[(K+14)%16],B=u[(K+14)%16],h=(U>>>19|B<<13)^(B>>>29|U<<3)^U>>>6,d=(B>>>19|U<<13)^(U>>>29|B<<3)^(B>>>6|U<<26),m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,a[K]=A&65535|w<<16,u[K]=m&65535|g<<16;h=I,d=X,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[0],d=o[0],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[0]=I=A&65535|w<<16,o[0]=X=m&65535|g<<16,h=F,d=Z,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[1],d=o[1],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[1]=F=A&65535|w<<16,o[1]=Z=m&65535|g<<16,h=V,d=J,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[2],d=o[2],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[2]=V=A&65535|w<<16,o[2]=J=m&65535|g<<16,h=G,d=yr,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[3],d=o[3],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[3]=G=A&65535|w<<16,o[3]=yr=m&65535|g<<16,h=s,d=nr,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[4],d=o[4],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[4]=s=A&65535|w<<16,o[4]=nr=m&65535|g<<16,h=k,d=fr,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[5],d=o[5],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[5]=k=A&65535|w<<16,o[5]=fr=m&65535|g<<16,h=Q,d=ir,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[6],d=o[6],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[6]=Q=A&65535|w<<16,o[6]=ir=m&65535|g<<16,h=rr,d=or,m=d&65535,g=d>>>16,A=h&65535,w=h>>>16,h=t[7],d=o[7],m+=d&65535,g+=d>>>16,A+=h&65535,w+=h>>>16,g+=m>>>16,A+=g>>>16,w+=A>>>16,t[7]=rr=A&65535|w<<16,o[7]=or=m&65535|g<<16,pr+=128,r-=128}return r}y(mn,"crypto_hashblocks_hl");function $r(t,o,i){var r=new Int32Array(8),a=new Int32Array(8),u=new Uint8Array(256),p,b=i;for(r[0]=1779033703,r[1]=3144134277,r[2]=1013904242,r[3]=2773480762,r[4]=1359893119,r[5]=2600822924,r[6]=528734635,r[7]=1541459225,a[0]=4089235720,a[1]=2227873595,a[2]=4271175723,a[3]=1595750129,a[4]=2917565137,a[5]=725511199,a[6]=4215389547,a[7]=327033209,mn(r,a,o,i),i%=128,p=0;p<i;p++)u[p]=o[b-i+p];for(u[i]=128,i=256-128*(i<112?1:0),u[i-9]=0,te(u,i-8,b/536870912|0,b<<3),mn(r,a,u,i),p=0;p<8;p++)te(t,8*p,r[p],a[p]);return 0}y($r,"crypto_hash");function Re(t,o){var i=e(),r=e(),a=e(),u=e(),p=e(),b=e(),E=e(),T=e(),v=e();Lr(i,t[1],t[0]),Lr(v,o[1],o[0]),W(i,i,v),Mr(r,t[0],t[1]),Mr(v,o[0],o[1]),W(r,r,v),W(a,t[3],o[3]),W(a,a,br),W(u,t[2],o[2]),Mr(u,u,u),Lr(p,r,i),Lr(b,u,a),Mr(E,u,a),Mr(T,r,i),W(t[0],p,b),W(t[1],T,E),W(t[2],E,b),W(t[3],p,T)}y(Re,"add");function wn(t,o,i){var r;for(r=0;r<4;r++)ne(t[r],o[r],i)}y(wn,"cswap");function at(t,o){var i=e(),r=e(),a=e();dn(a,o[2]),W(i,o[0],a),W(r,o[1],a),fe(t,r),t[31]^=hn(i)<<7}y(at,"pack");function st(t,o,i){var r,a;for(jr(t[0],l),jr(t[1],S),jr(t[2],S),jr(t[3],l),a=255;a>=0;--a)r=i[a/8|0]>>(a&7)&1,wn(t,o,r),Re(o,t),Re(t,t),wn(t,o,r)}y(st,"scalarmult");function ze(t,o){var i=[e(),e(),e(),e()];jr(i[0],sr),jr(i[1],vr),jr(i[2],S),W(i[3],sr,vr),st(t,i,o)}y(ze,"scalarbase");function ct(t,o,i){var r=new Uint8Array(64),a=[e(),e(),e(),e()],u;for(i||f(o,32),$r(r,o,32),r[0]&=248,r[31]&=127,r[31]|=64,ze(a,r),at(t,a),u=0;u<32;u++)o[u+32]=t[u];return 0}y(ct,"crypto_sign_keypair");var Oe=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 yt(t,o){var i,r,a,u;for(r=63;r>=32;--r){for(i=0,a=r-32,u=r-12;a<u;++a)o[a]+=i-16*o[r]*Oe[a-(r-32)],i=Math.floor((o[a]+128)/256),o[a]-=i*256;o[a]+=i,o[r]=0}for(i=0,a=0;a<32;a++)o[a]+=i-(o[31]>>4)*Oe[a],i=o[a]>>8,o[a]&=255;for(a=0;a<32;a++)o[a]-=i*Oe[a];for(r=0;r<32;r++)o[r+1]+=o[r]>>8,t[r]=o[r]&255}y(yt,"modL");function xt(t){var o=new Float64Array(64),i;for(i=0;i<64;i++)o[i]=t[i];for(i=0;i<64;i++)t[i]=0;yt(t,o)}y(xt,"reduce");function En(t,o,i,r){var a=new Uint8Array(64),u=new Uint8Array(64),p=new Uint8Array(64),b,E,T=new Float64Array(64),v=[e(),e(),e(),e()];$r(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64;var q=i+64;for(b=0;b<i;b++)t[64+b]=o[b];for(b=0;b<32;b++)t[32+b]=a[32+b];for($r(p,t.subarray(32),i+32),xt(p),ze(v,p),at(t,v),b=32;b<64;b++)t[b]=r[b];for($r(u,t,i+64),xt(u),b=0;b<64;b++)T[b]=0;for(b=0;b<32;b++)T[b]=p[b];for(b=0;b<32;b++)for(E=0;E<32;E++)T[b+E]+=u[b]*a[E];return yt(t.subarray(32),T),q}y(En,"crypto_sign");function df(t,o){var i=e(),r=e(),a=e(),u=e(),p=e(),b=e(),E=e();return jr(t[2],S),ot(t[1],o),Tr(a,t[1]),W(u,a,er),Lr(a,a,t[2]),Mr(u,t[2],u),Tr(p,u),Tr(b,p),W(E,b,p),W(i,E,a),W(i,i,u),ln(i,i),W(i,i,a),W(i,i,u),W(i,i,u),W(t[0],i,u),Tr(r,t[0]),W(r,r,u),pn(r,a)&&W(t[0],t[0],Yr),Tr(r,t[0]),W(r,r,u),pn(r,a)?-1:(hn(t[0])===o[31]>>7&&Lr(t[0],l,t[0]),W(t[3],t[0],t[1]),0)}y(df,"unpackneg");function ut(t,o,i,r){var a,u=new Uint8Array(32),p=new Uint8Array(64),b=[e(),e(),e(),e()],E=[e(),e(),e(),e()];if(i<64||df(E,r))return-1;for(a=0;a<i;a++)t[a]=o[a];for(a=0;a<32;a++)t[a+32]=r[a];if($r(p,t,i),xt(p),st(b,E,p),ze(E,o.subarray(32)),Re(b,E),at(u,b),i-=64,Ur(o,0,u,0)){for(a=0;a<i;a++)t[a]=0;return-1}for(a=0;a<i;a++)t[a]=o[a+64];return i}y(ut,"crypto_sign_open");var pt=32,Ye=24,be=32,ie=16,Ae=32,je=32,me=32,we=32,ht=32,Kn=Ye,lf=be,gf=ie,Hr=64,Zr=32,oe=64,dt=32,lt=64;n.lowlevel={crypto_core_hsalsa20:gr,crypto_stream_xor:Vr,crypto_stream:Pr,crypto_stream_salsa20_xor:Ir,crypto_stream_salsa20:Sr,crypto_onetimeauth:tt,crypto_onetimeauth_verify:un,crypto_verify_16:cr,crypto_verify_32:Ur,crypto_secretbox:nt,crypto_secretbox_open:ft,crypto_scalarmult:Me,crypto_scalarmult_base:Le,crypto_box_beforenm:Ne,crypto_box_afternm:bn,crypto_box:pf,crypto_box_open:hf,crypto_box_keypair:gn,crypto_hash:$r,crypto_sign:En,crypto_sign_keypair:ct,crypto_sign_open:ut,crypto_secretbox_KEYBYTES:pt,crypto_secretbox_NONCEBYTES:Ye,crypto_secretbox_ZEROBYTES:be,crypto_secretbox_BOXZEROBYTES:ie,crypto_scalarmult_BYTES:Ae,crypto_scalarmult_SCALARBYTES:je,crypto_box_PUBLICKEYBYTES:me,crypto_box_SECRETKEYBYTES:we,crypto_box_BEFORENMBYTES:ht,crypto_box_NONCEBYTES:Kn,crypto_box_ZEROBYTES:lf,crypto_box_BOXZEROBYTES:gf,crypto_sign_BYTES:Hr,crypto_sign_PUBLICKEYBYTES:Zr,crypto_sign_SECRETKEYBYTES:oe,crypto_sign_SEEDBYTES:dt,crypto_hash_BYTES:lt,gf:e,D:er,L:Oe,pack25519:fe,unpack25519:ot,M:W,A:Mr,S:Tr,Z:Lr,pow2523:ln,add:Re,set25519:jr,modL:yt,scalarmult:st,scalarbase:ze};function vn(t,o){if(t.length!==pt)throw new Error("bad key size");if(o.length!==Ye)throw new Error("bad nonce size")}y(vn,"checkLengths");function bf(t,o){if(t.length!==me)throw new Error("bad public key size");if(o.length!==we)throw new Error("bad secret key size")}y(bf,"checkBoxLengths");function Cr(){for(var t=0;t<arguments.length;t++)if(!(arguments[t]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}y(Cr,"checkArrayTypes");function Un(t){for(var o=0;o<t.length;o++)t[o]=0}y(Un,"cleanup"),n.randomBytes=function(t){var o=new Uint8Array(t);return f(o,t),o},n.secretbox=function(t,o,i){Cr(t,o,i),vn(i,o);for(var r=new Uint8Array(be+t.length),a=new Uint8Array(r.length),u=0;u<t.length;u++)r[u+be]=t[u];return nt(a,r,r.length,o,i),a.subarray(ie)},n.secretbox.open=function(t,o,i){Cr(t,o,i),vn(i,o);for(var r=new Uint8Array(ie+t.length),a=new Uint8Array(r.length),u=0;u<t.length;u++)r[u+ie]=t[u];return r.length<32||ft(a,r,r.length,o,i)!==0?null:a.subarray(be)},n.secretbox.keyLength=pt,n.secretbox.nonceLength=Ye,n.secretbox.overheadLength=ie,n.scalarMult=function(t,o){if(Cr(t,o),t.length!==je)throw new Error("bad n size");if(o.length!==Ae)throw new Error("bad p size");var i=new Uint8Array(Ae);return Me(i,t,o),i},n.scalarMult.base=function(t){if(Cr(t),t.length!==je)throw new Error("bad n size");var o=new Uint8Array(Ae);return Le(o,t),o},n.scalarMult.scalarLength=je,n.scalarMult.groupElementLength=Ae,n.box=function(t,o,i,r){var a=n.box.before(i,r);return n.secretbox(t,o,a)},n.box.before=function(t,o){Cr(t,o),bf(t,o);var i=new Uint8Array(ht);return Ne(i,t,o),i},n.box.after=n.secretbox,n.box.open=function(t,o,i,r){var a=n.box.before(i,r);return n.secretbox.open(t,o,a)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var t=new Uint8Array(me),o=new Uint8Array(we);return gn(t,o),{publicKey:t,secretKey:o}},n.box.keyPair.fromSecretKey=function(t){if(Cr(t),t.length!==we)throw new Error("bad secret key size");var o=new Uint8Array(me);return Le(o,t),{publicKey:o,secretKey:new Uint8Array(t)}},n.box.publicKeyLength=me,n.box.secretKeyLength=we,n.box.sharedKeyLength=ht,n.box.nonceLength=Kn,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(t,o){if(Cr(t,o),o.length!==oe)throw new Error("bad secret key size");var i=new Uint8Array(Hr+t.length);return En(i,t,t.length,o),i},n.sign.open=function(t,o){if(Cr(t,o),o.length!==Zr)throw new Error("bad public key size");var i=new Uint8Array(t.length),r=ut(i,t,t.length,o);if(r<0)return null;for(var a=new Uint8Array(r),u=0;u<a.length;u++)a[u]=i[u];return a},n.sign.detached=function(t,o){for(var i=n.sign(t,o),r=new Uint8Array(Hr),a=0;a<r.length;a++)r[a]=i[a];return r},n.sign.detached.verify=function(t,o,i){if(Cr(t,o,i),o.length!==Hr)throw new Error("bad signature size");if(i.length!==Zr)throw new Error("bad public key size");var r=new Uint8Array(Hr+t.length),a=new Uint8Array(Hr+t.length),u;for(u=0;u<Hr;u++)r[u]=o[u];for(u=0;u<t.length;u++)r[u+Hr]=t[u];return ut(a,r,r.length,i)>=0},n.sign.keyPair=function(){var t=new Uint8Array(Zr),o=new Uint8Array(oe);return ct(t,o),{publicKey:t,secretKey:o}},n.sign.keyPair.fromSecretKey=function(t){if(Cr(t),t.length!==oe)throw new Error("bad secret key size");for(var o=new Uint8Array(Zr),i=0;i<o.length;i++)o[i]=t[32+i];return{publicKey:o,secretKey:new Uint8Array(t)}},n.sign.keyPair.fromSeed=function(t){if(Cr(t),t.length!==dt)throw new Error("bad seed size");for(var o=new Uint8Array(Zr),i=new Uint8Array(oe),r=0;r<32;r++)i[r]=t[r];return ct(o,i,!0),{publicKey:o,secretKey:i}},n.sign.publicKeyLength=Zr,n.sign.secretKeyLength=oe,n.sign.seedLength=dt,n.sign.signatureLength=Hr,n.hash=function(t){Cr(t);var o=new Uint8Array(lt);return $r(o,t,t.length),o},n.hash.hashLength=lt,n.verify=function(t,o){return Cr(t,o),t.length===0||o.length===0||t.length!==o.length?!1:$(t,0,o,0,t.length)===0},n.setPRNG=function(t){f=t},(function(){var t=typeof self<"u"?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){var o=65536;n.setPRNG(function(i,r){var a,u=new Uint8Array(r);for(a=0;a<r;a+=o)t.getRandomValues(u.subarray(a,a+Math.min(r-a,o)));for(a=0;a<r;a++)i[a]=u[a];Un(u)})}else typeof Sn<"u"&&(t=af(),t&&t.randomBytes&&n.setPRNG(function(i,r){var a,u=t.randomBytes(r);for(a=0;a<r;a++)i[a]=u[a];Un(u)}))})()})(typeof Je<"u"&&Je.exports?Je.exports:self.nacl=self.nacl||{})});var _f=globalThis||window||self,tr=_f.crypto;function Ke(n=0){return new Uint8Array(n)}y(Ke,"allocUnsafe");function gt(n,e){e==null&&(e=n.reduce((x,l)=>x+l.length,0));let f=Ke(e),c=0;for(let x of n)f.set(x,c),c+=x.length;return f}y(gt,"concat");var St={};Dr(St,{base10:()=>Mf});var wo=new Uint8Array(0);function Cn(n,e){if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let f=0;f<n.byteLength;f++)if(n[f]!==e[f])return!1;return!0}y(Cn,"equals");function Fr(n){if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")}y(Fr,"coerce");function Bn(n){return new TextEncoder().encode(n)}y(Bn,"fromString");function Pn(n){return new TextDecoder().decode(n)}y(Pn,"toString");function Bf(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var f=new Uint8Array(256),c=0;c<f.length;c++)f[c]=255;for(var x=0;x<n.length;x++){var l=n.charAt(x),S=l.charCodeAt(0);if(f[S]!==255)throw new TypeError(l+" is ambiguous");f[S]=x}var Y=n.length,er=n.charAt(0),br=Math.log(Y)/Math.log(256),sr=Math.log(256)/Math.log(Y);function vr($){if($ instanceof Uint8Array||(ArrayBuffer.isView($)?$=new Uint8Array($.buffer,$.byteOffset,$.byteLength):Array.isArray($)&&($=Uint8Array.from($))),!($ instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if($.length===0)return"";for(var cr=0,Ur=0,Er=0,lr=$.length;Er!==lr&&$[Er]===0;)Er++,cr++;for(var Kr=(lr-Er)*sr+1>>>0,gr=new Uint8Array(Kr);Er!==lr;){for(var hr=$[Er],Ir=0,Sr=Kr-1;(hr!==0||Ir<Ur)&&Sr!==-1;Sr--,Ir++)hr+=256*gr[Sr]>>>0,gr[Sr]=hr%Y>>>0,hr=hr/Y>>>0;if(hr!==0)throw new Error("Non-zero carry");Ur=Ir,Er++}for(var Pr=Kr-Ur;Pr!==Kr&&gr[Pr]===0;)Pr++;for(var Vr=er.repeat(cr);Pr<Kr;++Pr)Vr+=n.charAt(gr[Pr]);return Vr}y(vr,"encode");function Yr($){if(typeof $!="string")throw new TypeError("Expected String");if($.length===0)return new Uint8Array;var cr=0;if($[cr]!==" "){for(var Ur=0,Er=0;$[cr]===er;)Ur++,cr++;for(var lr=($.length-cr)*br+1>>>0,Kr=new Uint8Array(lr);$[cr];){var gr=f[$.charCodeAt(cr)];if(gr===255)return;for(var hr=0,Ir=lr-1;(gr!==0||hr<Er)&&Ir!==-1;Ir--,hr++)gr+=Y*Kr[Ir]>>>0,Kr[Ir]=gr%256>>>0,gr=gr/256>>>0;if(gr!==0)throw new Error("Non-zero carry");Er=hr,cr++}if($[cr]!==" "){for(var Sr=lr-Er;Sr!==lr&&Kr[Sr]===0;)Sr++;for(var Pr=new Uint8Array(Ur+(lr-Sr)),Vr=Ur;Sr!==lr;)Pr[Vr++]=Kr[Sr++];return Pr}}}y(Yr,"decodeUnsafe");function te($){var cr=Yr($);if(cr)return cr;throw new Error(`Non-${e} character`)}return y(te,"decode"),{encode:vr,decodeUnsafe:Yr,decode:te}}y(Bf,"base");var Pf=Bf,Tf=Pf,Dn=Tf;var Et=class Et{constructor(e,f,c){O(this,"name");O(this,"prefix");O(this,"baseEncode");this.name=e,this.prefix=f,this.baseEncode=c}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};y(Et,"Encoder");var bt=Et,Kt=class Kt{constructor(e,f,c){O(this,"name");O(this,"prefix");O(this,"baseDecode");O(this,"prefixCodePoint");this.name=e,this.prefix=f;let x=f.codePointAt(0);if(x===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=x,this.baseDecode=c}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 In(this,e)}};y(Kt,"Decoder");var At=Kt,vt=class vt{constructor(e){O(this,"decoders");this.decoders=e}or(e){return In(this,e)}decode(e){let f=e[0],c=this.decoders[f];if(c!=null)return c.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};y(vt,"ComposedDecoder");var mt=vt;function In(n,e){return new mt({...n.decoders??{[n.prefix]:n},...e.decoders??{[e.prefix]:e}})}y(In,"or");var Ut=class Ut{constructor(e,f,c,x){O(this,"name");O(this,"prefix");O(this,"baseEncode");O(this,"baseDecode");O(this,"encoder");O(this,"decoder");this.name=e,this.prefix=f,this.baseEncode=c,this.baseDecode=x,this.encoder=new bt(e,f,c),this.decoder=new At(e,f,x)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};y(Ut,"Codec");var wt=Ut;function ae({name:n,prefix:e,encode:f,decode:c}){return new wt(n,e,f,c)}y(ae,"from");function Xr({name:n,prefix:e,alphabet:f}){let{encode:c,decode:x}=Dn(f,n);return ae({prefix:e,name:n,encode:c,decode:y(l=>Fr(x(l)),"decode")})}y(Xr,"baseX");function Df(n,e,f,c){let x={};for(let sr=0;sr<e.length;++sr)x[e[sr]]=sr;let l=n.length;for(;n[l-1]==="=";)--l;let S=new Uint8Array(l*f/8|0),Y=0,er=0,br=0;for(let sr=0;sr<l;++sr){let vr=x[n[sr]];if(vr===void 0)throw new SyntaxError(`Non-${c} character`);er=er<<f|vr,Y+=f,Y>=8&&(Y-=8,S[br++]=255&er>>Y)}if(Y>=f||(255&er<<8-Y)!==0)throw new SyntaxError("Unexpected end of data");return S}y(Df,"decode");function If(n,e,f){let c=e[e.length-1]==="=",x=(1<<f)-1,l="",S=0,Y=0;for(let er=0;er<n.length;++er)for(Y=Y<<8|n[er],S+=8;S>f;)S-=f,l+=e[x&Y>>S];if(S!==0&&(l+=e[x&Y<<f-S]),c)for(;(l.length*f&7)!==0;)l+="=";return l}y(If,"encode");function ar({name:n,prefix:e,bitsPerChar:f,alphabet:c}){return ae({prefix:e,name:n,encode(x){return If(x,c,f)},decode(x){return Df(x,c,f,n)}})}y(ar,"rfc4648");var Mf=Xr({prefix:"9",name:"base10",alphabet:"0123456789"});var _t={};Dr(_t,{base16:()=>Lf,base16upper:()=>Nf});var Lf=ar({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Nf=ar({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ct={};Dr(Ct,{base2:()=>Rf});var Rf=ar({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Bt={};Dr(Bt,{base256emoji:()=>Hf});var Mn=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}"),zf=Mn.reduce((n,e,f)=>(n[f]=e,n),[]),Of=Mn.reduce((n,e,f)=>{let c=e.codePointAt(0);if(c==null)throw new Error(`Invalid character: ${e}`);return n[c]=f,n},[]);function Yf(n){return n.reduce((e,f)=>(e+=zf[f],e),"")}y(Yf,"encode");function jf(n){let e=[];for(let f of n){let c=f.codePointAt(0);if(c==null)throw new Error(`Invalid character: ${f}`);let x=Of[c];if(x==null)throw new Error(`Non-base256emoji character: ${f}`);e.push(x)}return new Uint8Array(e)}y(jf,"decode");var Hf=ae({prefix:"\u{1F680}",name:"base256emoji",encode:Yf,decode:jf});var Pt={};Dr(Pt,{base32:()=>se,base32hex:()=>Xf,base32hexpad:()=>Wf,base32hexpadupper:()=>$f,base32hexupper:()=>kf,base32pad:()=>Gf,base32padupper:()=>Vf,base32upper:()=>Ff,base32z:()=>Zf});var se=ar({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ff=ar({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gf=ar({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Vf=ar({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xf=ar({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kf=ar({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wf=ar({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$f=ar({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zf=ar({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Tt={};Dr(Tt,{base36:()=>ve,base36upper:()=>Jf});var ve=Xr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Jf=Xr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Dt={};Dr(Dt,{base58btc:()=>Rr,base58flickr:()=>qf});var Rr=Xr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qf=Xr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var It={};Dr(It,{base64:()=>Qf,base64pad:()=>ri,base64url:()=>ei,base64urlpad:()=>ti});var Qf=ar({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ri=ar({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ei=ar({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ti=ar({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Mt={};Dr(Mt,{base8:()=>ni});var ni=ar({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Lt={};Dr(Lt,{identity:()=>fi});var fi=ae({prefix:"\0",name:"identity",encode:y(n=>Pn(n),"encode"),decode:y(n=>Bn(n),"decode")});var Ho=new TextEncoder,Fo=new TextDecoder;var zt={};Dr(zt,{identity:()=>_i});var ai=Rn,Ln=128,si=127,ci=~si,yi=Math.pow(2,31);function Rn(n,e,f){e=e||[],f=f||0;for(var c=f;n>=yi;)e[f++]=n&255|Ln,n/=128;for(;n&ci;)e[f++]=n&255|Ln,n>>>=7;return e[f]=n|0,Rn.bytes=f-c+1,e}y(Rn,"encode");var xi=Nt,ui=128,Nn=127;function Nt(n,c){var f=0,c=c||0,x=0,l=c,S,Y=n.length;do{if(l>=Y)throw Nt.bytes=0,new RangeError("Could not decode varint");S=n[l++],f+=x<28?(S&Nn)<<x:(S&Nn)*Math.pow(2,x),x+=7}while(S>=ui);return Nt.bytes=l-c,f}y(Nt,"read");var pi=Math.pow(2,7),hi=Math.pow(2,14),di=Math.pow(2,21),li=Math.pow(2,28),gi=Math.pow(2,35),bi=Math.pow(2,42),Ai=Math.pow(2,49),mi=Math.pow(2,56),wi=Math.pow(2,63),Ei=y(function(n){return n<pi?1:n<hi?2:n<di?3:n<li?4:n<gi?5:n<bi?6:n<Ai?7:n<mi?8:n<wi?9:10},"length"),Ki={encode:ai,decode:xi,encodingLength:Ei},vi=Ki,Ue=vi;function Se(n,e=0){return[Ue.decode(n,e),Ue.decode.bytes]}y(Se,"decode");function ce(n,e,f=0){return Ue.encode(n,e,f),e}y(ce,"encodeTo");function ye(n){return Ue.encodingLength(n)}y(ye,"encodingLength");function Jr(n,e){let f=e.byteLength,c=ye(n),x=c+ye(f),l=new Uint8Array(x+f);return ce(n,l,0),ce(f,l,c),l.set(e,x),new xe(n,f,e,l)}y(Jr,"create");function zn(n){let e=Fr(n),[f,c]=Se(e),[x,l]=Se(e.subarray(c)),S=e.subarray(c+l);if(S.byteLength!==x)throw new Error("Incorrect length");return new xe(f,x,S,e)}y(zn,"decode");function On(n,e){if(n===e)return!0;{let f=e;return n.code===f.code&&n.size===f.size&&f.bytes instanceof Uint8Array&&Cn(n.bytes,f.bytes)}}y(On,"equals");var Rt=class Rt{constructor(e,f,c,x){O(this,"code");O(this,"size");O(this,"digest");O(this,"bytes");this.code=e,this.size=f,this.digest=c,this.bytes=x}};y(Rt,"Digest");var xe=Rt;var Yn=0,Ui="identity",jn=Fr;function Si(n){return Jr(Yn,jn(n))}y(Si,"digest");var _i={code:Yn,name:Ui,encode:jn,digest:Si};var Ht={};Dr(Ht,{sha256:()=>Ci,sha512:()=>Bi});function Yt({name:n,code:e,encode:f}){return new Ot(n,e,f)}y(Yt,"from");var jt=class jt{constructor(e,f,c){O(this,"name");O(this,"code");O(this,"encode");this.name=e,this.code=f,this.encode=c}digest(e){if(e instanceof Uint8Array){let f=this.encode(e);return f instanceof Uint8Array?Jr(this.code,f):f.then(c=>Jr(this.code,c))}else throw Error("Unknown type, must be binary type")}};y(jt,"Hasher");var Ot=jt;function Fn(n){return async e=>new Uint8Array(await crypto.subtle.digest(n,e))}y(Fn,"sha");var Ci=Yt({name:"sha2-256",code:18,encode:Fn("SHA-256")}),Bi=Yt({name:"sha2-512",code:19,encode:Fn("SHA-512")});function Gn(n,e){let{bytes:f,version:c}=n;switch(c){case 0:return Ti(f,Ft(n),e??Rr.encoder);default:return Di(f,Ft(n),e??se.encoder)}}y(Gn,"format");var Vn=new WeakMap;function Ft(n){let e=Vn.get(n);if(e==null){let f=new Map;return Vn.set(n,f),f}return e}y(Ft,"baseCache");var kn,dr=class dr{constructor(e,f,c,x){O(this,"code");O(this,"version");O(this,"multihash");O(this,"bytes");O(this,"/");O(this,kn,"CID");this.code=f,this.version=e,this.multihash=c,this.bytes=x,this["/"]=x}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:f}=this;if(e!==Ce)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(f.code!==Ii)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return dr.createV0(f)}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:f}=this.multihash,c=Jr(e,f);return dr.createV1(this.code,c)}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 dr.equals(this,e)}static equals(e,f){let c=f;return c!=null&&e.code===c.code&&e.version===c.version&&On(e.multihash,c.multihash)}toString(e){return Gn(this,e)}toJSON(){return{"/":Gn(this)}}link(){return this}[(kn=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let f=e;if(f instanceof dr)return f;if(f["/"]!=null&&f["/"]===f.bytes||f.asCID===f){let{version:c,code:x,multihash:l,bytes:S}=f;return new dr(c,x,l,S??Xn(c,x,l.bytes))}else if(f[Mi]===!0){let{version:c,multihash:x,code:l}=f,S=zn(x);return dr.create(c,l,S)}else return null}static create(e,f,c){if(typeof f!="number")throw new Error("String codecs are no longer supported");if(!(c.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(f!==Ce)throw new Error(`Version 0 CID must use dag-pb (code: ${Ce}) block encoding`);return new dr(e,f,c,c.bytes)}case 1:{let x=Xn(e,f,c.bytes);return new dr(e,f,c,x)}default:throw new Error("Invalid version")}}static createV0(e){return dr.create(0,Ce,e)}static createV1(e,f){return dr.create(1,e,f)}static decode(e){let[f,c]=dr.decodeFirst(e);if(c.length!==0)throw new Error("Incorrect length");return f}static decodeFirst(e){let f=dr.inspectBytes(e),c=f.size-f.multihashSize,x=Fr(e.subarray(c,c+f.multihashSize));if(x.byteLength!==f.multihashSize)throw new Error("Incorrect length");let l=x.subarray(f.multihashSize-f.digestSize),S=new xe(f.multihashCode,f.digestSize,l,x);return[f.version===0?dr.createV0(S):dr.createV1(f.codec,S),e.subarray(f.size)]}static inspectBytes(e){let f=0,c=y(()=>{let[vr,Yr]=Se(e.subarray(f));return f+=Yr,vr},"next"),x=c(),l=Ce;if(x===18?(x=0,f=0):l=c(),x!==0&&x!==1)throw new RangeError(`Invalid CID version ${x}`);let S=f,Y=c(),er=c(),br=f+er,sr=br-S;return{version:x,codec:l,multihashCode:Y,digestSize:er,multihashSize:sr,size:br}}static parse(e,f){let[c,x]=Pi(e,f),l=dr.decode(x);if(l.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ft(l).set(c,e),l}};y(dr,"CID");var Fe=dr;function Pi(n,e){switch(n[0]){case"Q":{let f=e??Rr;return[Rr.prefix,f.decode(`${Rr.prefix}${n}`)]}case Rr.prefix:{let f=e??Rr;return[Rr.prefix,f.decode(n)]}case se.prefix:{let f=e??se;return[se.prefix,f.decode(n)]}case ve.prefix:{let f=e??ve;return[ve.prefix,f.decode(n)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[n[0],e.decode(n)]}}}y(Pi,"parseCIDtoBytes");function Ti(n,e,f){let{prefix:c}=f;if(c!==Rr.prefix)throw Error(`Cannot string encode V0 in ${f.name} encoding`);let x=e.get(c);if(x==null){let l=f.encode(n).slice(1);return e.set(c,l),l}else return x}y(Ti,"toStringV0");function Di(n,e,f){let{prefix:c}=f,x=e.get(c);if(x==null){let l=f.encode(n);return e.set(c,l),l}else return x}y(Di,"toStringV1");var Ce=112,Ii=18;function Xn(n,e,f){let c=ye(n),x=c+ye(e),l=new Uint8Array(x+f.byteLength);return ce(n,l,0),ce(e,l,c),l.set(f,x),l}y(Xn,"encodeCID");var Mi=Symbol.for("@ipld/js-cid/CID");var Gt={...Lt,...Ct,...Mt,...St,..._t,...Pt,...Tt,...Dt,...It,...Bt},ma={...Ht,...zt};function $n(n,e,f,c){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:f},decoder:{decode:c}}}y($n,"createCodec");var Wn=$n("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),Vt=$n("ascii","a",n=>{let e="a";for(let f=0;f<n.length;f++)e+=String.fromCharCode(n[f]);return e},n=>{n=n.substring(1);let e=Ke(n.length);for(let f=0;f<n.length;f++)e[f]=n.charCodeAt(f);return e}),Li={utf8:Wn,"utf-8":Wn,hex:Gt.base16,latin1:Vt,ascii:Vt,binary:Vt,...Gt},Ge=Li;function Br(n,e="utf8"){let f=Ge[e];if(f==null)throw new Error(`Unsupported encoding "${e}"`);return f.decoder.decode(`${f.prefix}${n}`)}y(Br,"fromString");function xr(n,e="utf8"){let f=Ge[e];if(f==null)throw new Error(`Unsupported encoding "${e}"`);return f.encoder.encode(n).substring(1)}y(xr,"toString");var qr="did:key:z",Be="Ed25519",Zn="X25519",Xa="X25519",Jn="Ed25519",qn="X25519";var ue="RSA-OAEP",pe="RSASSA-PKCS1-v1_5",Xt="SHA-256",kt=new Uint8Array([0,245,2]),ka=2048,Wt="SHA-256",he=8,de="AES-GCM",Gr=de,Qr=256,kr=12,$t=new Uint8Array([234,1]),Zt=new Uint8Array([237,1]),Ve={RSA:"rsa",Edwards:"ed25519",BLS:"bls12-381"};var Xe="ecc-exchange",ke="ecc-write",zr=16;var Qn=new Error("Invalid key use. Please use 'encryption' or 'signing"),zi=new Error("Max must be less than 256 and greater than 0");function ur(n){return new Uint8Array(n).buffer}y(ur,"toArrayBuffer");async function rf(n){return new Uint8Array(await tr.subtle.digest("sha-256",n.buffer))}y(rf,"sha256");function Or(n){let e=Br(n,"base64pad");return ur(e)}y(Or,"base64ToArrBuf");var Te=y((n,e)=>{if(typeof n=="string")return e(n);if(typeof n=="object"&&n.byteLength!==void 0)return new Uint8Array(n).buffer;throw new Error("Improper value. Must be a string, ArrayBuffer, Uint8Array")},"normalizeToBuf");function We(n){return Te(n,Or)}y(We,"normalizeBase64ToBuf");var Oi=y(n=>Te(n,e=>ef(e,8)),"normalizeUtf8ToBuf");function ef(n,e){let f=e===8?new Uint8Array(n.length):new Uint16Array(n.length);for(let c=0,x=n.length;c<x;c++)f[c]=n.charCodeAt(c);return f.buffer}y(ef,"strToArrBuf");var Yi=y(n=>Te(n,e=>ef(e,16)),"normalizeUtf16ToBuf");function le(n,e){switch(e){case 8:return Oi(n);default:return Yi(n)}}y(le,"normalizeUnicodeToBuf");function tf(n){if(!n.startsWith(qr))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let e=""+n.substring(qr.length),f=Br(e,"base58btc"),{keyBuffer:c,type:x}=ji(ur(f));return{publicKey:new Uint8Array(c),type:x}}y(tf,"didToPublicKey");function ji(n){if(Pe(n,ur(kt)))return{keyBuffer:n.slice(kt.byteLength),type:Ve.RSA};if(Pe(n,ur(Zt)))return{keyBuffer:n.slice(Zt.byteLength),type:Ve.Edwards};if(Pe(n,ur($t)))return{keyBuffer:n.slice($t.byteLength),type:Ve.BLS};throw new Error("Unsupported key algorithm. Try using RSA.")}y(ji,"parseMagicBytes");var Hi={equal:y((n,e)=>{let f=new Uint8Array(n),c=new Uint8Array(e);if(f.length!==c.length)return!1;for(let x=0;x<f.length;x++)if(f[x]!==c[x])return!1;return!0},"equal")};function Pe(n,e){return Hi.equal(e,n.slice(0,e.byteLength))}y(Pe,"hasPrefix");function Nr(n){return xr(n instanceof ArrayBuffer?new Uint8Array(n):n,"base64pad")}y(Nr,"toBase64");async function qt(n,e){let f=typeof n=="string"?Or(n):ur(n);return tr.subtle.importKey("raw",f,{name:e?.alg||Gr,length:e?.length||Qr},!0,["encrypt","decrypt"])}y(qt,"importKey");function nf(n,{max:e}={max:255}){if(e<1||e>255)throw zi;let f=new Uint8Array(n);if(e===255)return tr.getRandomValues(f),f.buffer;let c=0,x=e+1,l=Math.floor(256/x)*x,S=new Uint8Array(1);for(;c<f.length;)tr.getRandomValues(S),S[0]<l&&(f[c]=S[0]%x,c++);return f.buffer}y(nf,"randomBuf");function $e(n,e){let f=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(ur(n)),c=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(ur(e)),x=new Uint8Array(f.length+c.length);return x.set(f),x.set(c,f.length),x.buffer}y($e,"joinBufs");var fs=new Error("Key does not exist. Make sure you properly instantiated the keystore."),is=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),os=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),as=new Error("ECC is not enabled for this browser. Please use RSA instead."),ss=new Error("Cryptosystem not supported. Please use ECC or RSA"),Fi=new Error("Invalid key use. Please use 'exchange' or 'write'"),cs=new Error("Max must be less than 256 and greater than 0");function ff(n){Gi(n,["exchange","write","signing"],Fi)}y(ff,"checkValidKeyUse");function Gi(n,e,f){if(!e.some(x=>x===n))throw f}y(Gi,"checkValid");function Ze(n){return new Promise((e,f)=>{n.oncomplete=n.onsuccess=()=>e(n.result),n.onabort=n.onerror=()=>f(n.error)})}y(Ze,"promisifyRequest");function Vi(n,e){let f,c=y(()=>{if(f)return f;let x=indexedDB.open(n);return x.onupgradeneeded=()=>x.result.createObjectStore(e),f=Ze(x),f.then(l=>{l.onclose=()=>f=void 0},()=>{}),f},"getDB");return(x,l)=>c().then(S=>l(S.transaction(e,x).objectStore(e)))}y(Vi,"createStore");var Qt;function rn(){return Qt||(Qt=Vi("keyval-store","keyval")),Qt}y(rn,"defaultGetStore");function en(n,e=rn()){return e("readonly",f=>Ze(f.get(n)))}y(en,"get");function tn(n,e,f=rn()){return f("readwrite",c=>(c.put(e,n),Ze(c.transaction)))}y(tn,"set");function of(n,e=rn()){return e("readwrite",f=>(n.forEach(c=>f.delete(c)),Ze(f.transaction)))}y(of,"delMany");var cf=Sf(sf(),1);var on={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:y(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:ki},ed25519:{magicBytes:new Uint8Array([237,1]),verify:Xi}}};async function Xi({message:n,publicKey:e,signature:f}){let c=n;typeof n=="string"&&(c=Br(n,"utf8"));let x=f;typeof f=="string"&&(x=Br(f,"base64pad"));let l=e;if(typeof e=="string"&&(l=yf(e).publicKey),l.length!==32)throw new Error(`Invalid Ed25519 public key size: ${l.length} bytes, expected 32`);if(x.length!==64)throw new Error(`Invalid Ed25519 signature size: ${x.length} bytes, expected 64`);return cf.default.sign.detached.verify(c,x,l)}y(Xi,"ed25519Verify");async function ki({message:n,publicKey:e,signature:f}){let c=e;return typeof e=="string"&&(c=yf(e).publicKey),an.verify(n,f,await tr.subtle.importKey("spki",ur(c),{name:pe,hash:Xt},!1,["verify"]),8)}y(ki,"rsaVerify");var an={verify:y(async function(e,f,c,x=he,l=Wt){return tr.subtle.verify({name:pe,saltLength:zr},typeof c=="string"?await nn(c,l,"signing"):c,We(f),le(e,x))},"rsaVerify"),sign:y(async function(e,f,c=he){return tr.subtle.sign({name:pe,saltLength:zr},f,le(e,c))},"sign"),encrypt:y(async function(e,f,c=he,x=Wt){let l;return typeof f=="string"?l=await nn(f,x,"exchange"):l=f instanceof Uint8Array?await nn(ur(f),x,"exchange"):f,tr.subtle.encrypt({name:ue},l,le(e,c))},"rsaEncrypt"),decrypt:y(async function(e,f){let c=qe(f)?f:await Ji(f,["decrypt"]),x;typeof e=="string"?x=Br(e,"base64pad"):x=e;let l=await tr.subtle.decrypt({name:ue},c,x instanceof Uint8Array?ur(x):x);return new Uint8Array(l)},"rsaDecrypt")};async function nn(n,e,f){Wi(f);let c=f==="exchange"?ue:pe,x=f==="exchange"?["encrypt"]:["verify"],l=typeof n=="string"?Or(Zi(n)):n;return tr.subtle.importKey("spki",l,{name:c,hash:{name:e}},!0,x)}y(nn,"rsaImportPublicKey");function Wi(n){$i(n,["signing","exchange"],Qn)}y(Wi,"checkValidKeyUse");function $i(n,e,f){if(!e.some(x=>x===n))throw f}y($i,"checkValid");function Zi(n){return n.replace(`-----BEGIN PUBLIC KEY-----
2
2
  `,"").replace(`
3
- -----END PUBLIC KEY-----`,"")}y(Ji,"stripKeyHeader");function Qe(n){return on(n,"algorithm")&&on(n,"extractable")&&on(n,"type")}y(Qe,"isCryptoKey");function on(n,e){return typeof n=="object"&&n!=null&&e in n}y(on,"hasProp");function qi(n,e){return tr.subtle.importKey("spki",n instanceof Uint8Array?Br(n):n,{name:ue,hash:kt},!1,e)}y(qi,"importRsaKey");async function cn(n,e="rsa"){let f=n instanceof CryptoKey?new Uint8Array(await ge(n)):n;n instanceof CryptoKey&&(e=n.algorithm.name.includes("RSA")?"rsa":"ed25519");let c=an.keyTypes[e]?.magicBytes;if(!c)throw new Error(`Key type '${e}' not supported, available types: ${Object.keys(an.keyTypes).join(", ")}`);let x=bt([c,f]);return qr+xr(x,"base58btc")}y(cn,"publicKeyToDid");async function ge(n){return n instanceof CryptoKey?await tr.subtle.exportKey("spki",n):await tr.subtle.exportKey("spki",n.publicKey)}y(ge,"getPublicKeyAsArrayBuffer");function xf(n){if(!n.startsWith(qr))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let e=n.substring(qr.length),f=Cr(e,"base58btc"),c=Object.entries(an.keyTypes).find(([l,S])=>Te(f.buffer,S.magicBytes.buffer));if(!c)throw new Error("Unsupported key algorithm.");let x=f.slice(c[1].magicBytes.length);return c[0]==="ed25519"&&x.length===44?{publicKey:x.slice(-32),type:c[0]}:{publicKey:x,type:c[0]}}y(xf,"didToPublicKey");function be(n){return new Uint8Array(n).buffer}y(be,"toArrayBuffer");var re={create(n={alg:Gr,length:Qr}){let e=n.length||Qr,f=n.alg||Gr;return tr.subtle.generateKey({name:f,length:e},!0,["encrypt","decrypt"])},export:Object.assign(async n=>{let e=await tr.subtle.exportKey("raw",n);return new Uint8Array(e)},{asString:y(async(n,e)=>{let f=await re.export(n);return e?xr(f,e):Nr(f)},"asString")}),import(n){return yn(typeof n=="string"?Or(n):n)},async exportAsString(n){let e=await re.export(n);return Nr(e)},encrypt:Qi,async decrypt(n,e,f){let c=Qe(e)?e:await yn(e),x=f?await tr.subtle.decrypt({name:de,iv:be(f)},c,typeof n=="string"?be(Cr(n)):n instanceof Uint8Array?be(n):n):await eo(n,c);return new Uint8Array(x)}};function yn(n,e){return tr.subtle.importKey("raw",n instanceof Uint8Array?be(n):n,{name:de,length:e||256},!0,["encrypt","decrypt"])}y(yn,"importAesKey");async function Qi(n,e,f,c){let x=Qe(e)?e:await yn(e),l=c?await tr.subtle.encrypt({name:de,iv:be(c)},x,be(n)):await ro(n,x);return f&&f==="arraybuffer"?l:new Uint8Array(l)}y(Qi,"encrypt");async function ro(n,e,f){let c=le(n,f?.charsize??he),x=typeof e=="string"?await Qt(e,f):e,l=f?.iv||ff(kr),S=await tr.subtle.encrypt({name:de,iv:l},x,c);return Ze(l,S)}y(ro,"encryptBytes");async function eo(n,e,f){let c=$e(n),x=typeof e=="string"?await Qt(e,f):e,l=c.slice(0,kr),S=c.slice(kr);return await tr.subtle.decrypt({name:Gr,iv:l},x,S)}y(eo,"decryptBytes");var Wr=class Wr{constructor(e){O(this,"DID");O(this,"exchangeKey");O(this,"writeKey");O(this,"hasPersisted");O(this,"isSessionOnly");let{keys:f}=e;this.DID=e.did,this.exchangeKey=f.exchange,this.writeKey=f.write,this.hasPersisted=e.hasPersisted,this.isSessionOnly=!!e.isSessionOnly}publicExchangeKeyAsString(e){return this.publicExchangeKey.asString(e)}publicWriteKeyAsString(e){return this.publicWriteKey.asString(e)}get publicWriteKey(){let e=this.writeKey.publicKey;return Object.assign(e,{asString:y(async f=>{let c=await ge(this.writeKey),x=new Uint8Array(c);return f?xr(x,f):Nr(x)},"asString")})}get publicExchangeKey(){let e=this.exchangeKey.publicKey;return Object.assign(e,{asString:y(async f=>{let c=await ge(this.exchangeKey),x=new Uint8Array(c);return f?xr(x,f):Nr(x)},"asString")})}get privateWriteKey(){return this.writeKey.privateKey}get privateExchangeKey(){return this.exchangeKey.privateKey}get deviceName(){return Wr.deviceName(this.DID)}static deviceName(e){return to(e)}async persist(){if(this.isSessionOnly)return;let e=this.constructor.EXCHANGE_KEY_NAME,f=this.constructor.WRITE_KEY_NAME;await Promise.all([nn(e,this.exchangeKey),nn(f,this.writeKey)]),this.hasPersisted=!0}async delete(){await af([this.constructor.EXCHANGE_KEY_NAME,this.constructor.WRITE_KEY_NAME]),this.hasPersisted=!1}async getDeviceName(){return Wr.deviceName(this.DID)}static _createExchangeKeys(e){throw new Error("The child should implement this")}static _createWriteKeys(e){throw new Error("The child should implement this")}static async create(e,f,c){let x=c?.exchangeKeys||await this._createExchangeKeys(f),l=c?.writeKeys||await this._createWriteKeys(f),S=await ge(l),Y=await cn(new Uint8Array(S),this.TYPE==="ecc"?"ed25519":"rsa"),er=new this({keys:{exchange:x,write:l},did:Y,hasPersisted:!1,isSessionOnly:!!e});return this._instance=er,er}static async load(e={session:!1}){if(this._instance)return this._instance;let f=!0,c=await tn(e.encryptionKeyName||this.EXCHANGE_KEY_NAME),x=await tn(e.signingKeyName||this.WRITE_KEY_NAME);c||(f=!1,c=await this._createExchangeKeys(e.extractable)),x||(f=!1,x=await this._createWriteKeys(e.extractable));let l=await ge(x),S=await cn(new Uint8Array(l),this.TYPE==="ecc"?"ed25519":"rsa"),Y=new this({keys:{exchange:c,write:x},did:S,hasPersisted:f,isSessionOnly:!!e.session});return this._instance=Y,Y}};y(Wr,"AbstractKeys"),O(Wr,"EXCHANGE_KEY_NAME"),O(Wr,"WRITE_KEY_NAME"),O(Wr,"_instance");var rt=Wr;async function uf(n,e){let{content:f,publicKey:c}=n,x=e||await re.create(),l=await re.encrypt(typeof f=="string"?Cr(f):f,typeof x=="string"?await re.import(x):x),S=await xn({key:x,publicKey:c});return Ze(S,l)}y(uf,"encryptTo");uf.asString=async function(n,e){let f=await uf(n,e);return xr(new Uint8Array(f),"base64pad")};async function xn({key:n,publicKey:e},f){let c;n instanceof CryptoKey?c=await re.export(n):c=n;let x=await sn.encrypt(c,e);return f&&f==="arraybuffer"?x:new Uint8Array(x)}y(xn,"encryptKeyTo");xn.asString=async function({key:n,publicKey:e},f){let c=await xn({key:n,publicKey:e});return f?xr(c,f):Nr(c)};async function to(n){let e=await ef(new TextEncoder().encode(n.normalize("NFD")));return xr(e,"base32").slice(0,32)}y(to,"getDeviceName");function Ie(n){return new Uint8Array(n).buffer}y(Ie,"toArrayBuffer");var Sr=class Sr extends rt{static async create(e,f,c){return await super.create(e,f,c)}constructor(e){super(e),Sr.EXCHANGE_KEY_NAME=e.exchangeKeyName||ke,Sr.WRITE_KEY_NAME=e.writeKeyName||We}get publicExchangeKey(){let e=this.exchangeKey.publicKey;return Object.assign(e,{asString:y(async f=>{let c=await un(this.exchangeKey),x=new Uint8Array(c);return f?xr(x,f):Nr(c)},"asString")})}get publicWriteKey(){let e=this.writeKey.publicKey;return Object.assign(e,{asString:y(async f=>{let c=await un(this.writeKey),x=new Uint8Array(c);return f?xr(x,f):Nr(c)},"asString")})}static async _createExchangeKeys(e=!1){return await tr.subtle.generateKey({name:Qn},e,["deriveKey","deriveBits"])}static async _createWriteKeys(e=!1){return await tr.subtle.generateKey({name:qn},e,["sign","verify"])}static async load(e={session:!1}){if(this._instance)return this._instance;let f=e.encryptionKeyName||ke,c=e.signingKeyName||We;return super.load({...e,encryptionKeyName:f,signingKeyName:c})}async toJson(e){let f=this.DID,c=await un(this.exchangeKey);return{publicExchangeKey:e?xr(new Uint8Array(c),e):Nr(c),DID:f}}async encrypt(e,f,c,x,l){let S=new TextEncoder,Y=crypto.getRandomValues(new Uint8Array(zr)),er=f||this.exchangeKey.publicKey,gr;typeof er=="string"?gr=await tt(er,"X25519","exchange"):gr=er;let sr=x||await et(this.exchangeKey.privateKey,gr,Y,c||Sr.INFO,l);sr instanceof CryptoKey||(sr=await et(this.exchangeKey.privateKey,gr,Y,c||Sr.INFO));let Kr=crypto.getRandomValues(new Uint8Array(kr)),Yr=typeof e=="string"?S.encode(e):e,te=await crypto.subtle.encrypt({name:Gr,iv:Kr},sr,Ie(Yr)),$=new Uint8Array(Y),cr=new Uint8Array(Kr),vr=new Uint8Array(te),wr=$.length+cr.length+vr.length,dr=new Uint8Array(wr);return dr.set($,0),dr.set(cr,$.length),dr.set(vr,$.length+cr.length),dr}async encryptAsString(e,f,c,x,l){let S=await this.encrypt(e,f,c||Sr.INFO,x,l);return xr(new Uint8Array(S),"base64pad")}async decrypt(e,f,c,x){let l=typeof f=="string"?await tt(f,"X25519","write"):f;l||(l=this.publicExchangeKey);let S=De(e,Or),Y=S.slice(0,zr),er=S.slice(zr,zr+kr),gr=S.slice(zr+kr),{privateKey:sr}=this.exchangeKey,Kr=await et(sr,l,Y,x||Sr.INFO);return await crypto.subtle.decrypt({name:c||Gr,iv:er},Kr,gr)}async decryptAsString(e,f,c,x){let l=await this.decrypt(e,f,c,x);return xr(new Uint8Array(l))}async getAesKey(e,f){e||(e=this.publicExchangeKey);let c;typeof e=="string"?c=await tt(e,"X25519","exchange"):c=e;let x=crypto.getRandomValues(new Uint8Array(zr));return await et(this.exchangeKey.privateKey,c,x,f||Sr.INFO)}async sign(e,f){let c=new TextEncoder,x;typeof e=="string"?x=c.encode(e):e instanceof ArrayBuffer?x=new Uint8Array(e):x=e;let l=await tr.subtle.sign({name:Pe},this.writeKey.privateKey,Ie(x));return new Uint8Array(l)}async signAsString(e,f){let c=await this.sign(e,f);return xr(c,"base64pad")}};y(Sr,"EccKeys"),O(Sr,"TYPE","ecc"),O(Sr,"EXCHANGE_KEY_NAME",ke),O(Sr,"WRITE_KEY_NAME",We),O(Sr,"INFO","keys");var ee=Sr;Object.assign(ee.prototype.sign,{asString:y(async function(n,e){let f=await this.sign(n,e);return xr(f,"base64pad")},"asString")});async function un(n,e="raw"){return await crypto.subtle.exportKey(e,n.publicKey)}y(un,"exportPublicKey");async function tt(n,e,f){of(f);let c=f==="exchange"?Jn:Pe,x=f==="exchange"?[]:["verify"],l=Or(n),S=e==="X25519"?{name:c}:{name:c,namedCurve:e};return tr.subtle.importKey("raw",l,S,!0,x)}y(tt,"importPublicKey");var qs={EccKeys:ee,importPublicKey:tt};Object.assign(ee.prototype.encrypt,{asString:y(async function(n,e,f,c,x){return this.encryptAsString(n,e,f,c,x)},"asString")});Object.assign(ee.prototype.decrypt,{asString:y(async function(n,e,f){return this.decryptAsString(n,e,f)},"asString")});Object.assign(ee.prototype.sign,{asString:y(async function(n,e){return this.signAsString(n,e)},"asString")});async function Qs(n,e,f){try{let c=nf(f);if(c.type!=="ed25519")throw new Error(`Expected Ed25519 key for ECC verification, got ${c.type}`);let x=c.publicKey.slice(-32),l=await tr.subtle.importKey("raw",x,{name:Pe},!0,["verify"]),S=new TextEncoder,Y;typeof n=="string"?Y=S.encode(n):n instanceof ArrayBuffer?Y=new Uint8Array(n):Y=n;let er;return typeof e=="string"?er=new Uint8Array(Or(e)):er=e,await tr.subtle.verify({name:Pe},l,Ie(er),Ie(Y))}catch{return!1}}y(Qs,"verify");async function et(n,e,f,c,x){let l=new TextEncoder,S=await crypto.subtle.deriveBits({name:"X25519",public:e},n,256),Y=await crypto.subtle.importKey("raw",S,"HKDF",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:f instanceof Uint8Array?Ie(f):f,info:l.encode(c)},Y,{name:"AES-GCM",length:x||Qr},!1,["encrypt","decrypt"])}y(et,"deriveKey");export{ee as EccKeys,qs as default,un as exportPublicKey,tt as importPublicKey,Qs as verify};
3
+ -----END PUBLIC KEY-----`,"")}y(Zi,"stripKeyHeader");function qe(n){return fn(n,"algorithm")&&fn(n,"extractable")&&fn(n,"type")}y(qe,"isCryptoKey");function fn(n,e){return typeof n=="object"&&n!=null&&e in n}y(fn,"hasProp");function Ji(n,e){return tr.subtle.importKey("spki",n instanceof Uint8Array?ur(n):n,{name:ue,hash:Xt},!1,e)}y(Ji,"importRsaKey");async function sn(n,e="rsa"){let f=n instanceof CryptoKey?new Uint8Array(await ge(n)):n;n instanceof CryptoKey&&(e=n.algorithm.name.includes("RSA")?"rsa":"ed25519");let c=on.keyTypes[e]?.magicBytes;if(!c)throw new Error(`Key type '${e}' not supported, available types: ${Object.keys(on.keyTypes).join(", ")}`);let x=gt([c,f]);return qr+xr(x,"base58btc")}y(sn,"publicKeyToDid");async function ge(n){return n instanceof CryptoKey?await tr.subtle.exportKey("spki",n):await tr.subtle.exportKey("spki",n.publicKey)}y(ge,"getPublicKeyAsArrayBuffer");function yf(n){if(!n.startsWith(qr))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let e=n.substring(qr.length),f=Br(e,"base58btc"),c=Object.entries(on.keyTypes).find(([l,S])=>Pe(f.buffer,S.magicBytes.buffer));if(!c)throw new Error("Unsupported key algorithm.");let x=f.slice(c[1].magicBytes.length);return c[0]==="ed25519"&&x.length===44?{publicKey:x.slice(-32),type:c[0]}:{publicKey:x,type:c[0]}}y(yf,"didToPublicKey");var re={create(n={alg:Gr,length:Qr}){let e=n.length||Qr,f=n.alg||Gr;return tr.subtle.generateKey({name:f,length:e},!0,["encrypt","decrypt"])},export:Object.assign(async n=>{let e=await tr.subtle.exportKey("raw",n);return new Uint8Array(e)},{asString:y(async(n,e)=>{let f=await re.export(n);return e?xr(f,e):Nr(f)},"asString")}),import(n){return cn(typeof n=="string"?Or(n):n)},async exportAsString(n){let e=await re.export(n);return Nr(e)},encrypt:qi,async decrypt(n,e,f){let c=qe(e)?e:await cn(e),x=f?await tr.subtle.decrypt({name:de,iv:ur(f)},c,typeof n=="string"?ur(Br(n)):n instanceof Uint8Array?ur(n):n):await ro(n,c);return new Uint8Array(x)}};function cn(n,e){return tr.subtle.importKey("raw",n instanceof Uint8Array?ur(n):n,{name:de,length:e||256},!0,["encrypt","decrypt"])}y(cn,"importAesKey");async function qi(n,e,f,c){let x=qe(e)?e:await cn(e),l=c?await tr.subtle.encrypt({name:de,iv:ur(c)},x,ur(n)):await Qi(n,x);return f&&f==="arraybuffer"?l:new Uint8Array(l)}y(qi,"encrypt");async function Qi(n,e,f){let c=le(n,f?.charsize??he),x=typeof e=="string"?await qt(e,f):e,l=f?.iv||nf(kr),S=await tr.subtle.encrypt({name:de,iv:l},x,c);return $e(l,S)}y(Qi,"encryptBytes");async function ro(n,e,f){let c=We(n),x=typeof e=="string"?await qt(e,f):e,l=c.slice(0,kr),S=c.slice(kr);return await tr.subtle.decrypt({name:Gr,iv:l},x,S)}y(ro,"decryptBytes");var Wr=class Wr{constructor(e){O(this,"DID");O(this,"exchangeKey");O(this,"writeKey");O(this,"hasPersisted");O(this,"isSessionOnly");let{keys:f}=e;this.DID=e.did,this.exchangeKey=f.exchange,this.writeKey=f.write,this.hasPersisted=e.hasPersisted,this.isSessionOnly=!!e.isSessionOnly}publicExchangeKeyAsString(e){return this.publicExchangeKey.asString(e)}publicWriteKeyAsString(e){return this.publicWriteKey.asString(e)}get publicWriteKey(){let e=this.writeKey.publicKey;return Object.assign(e,{asString:y(async f=>{let c=await ge(this.writeKey),x=new Uint8Array(c);return f?xr(x,f):Nr(x)},"asString")})}get publicExchangeKey(){let e=this.exchangeKey.publicKey;return Object.assign(e,{asString:y(async f=>{let c=await ge(this.exchangeKey),x=new Uint8Array(c);return f?xr(x,f):Nr(x)},"asString")})}get privateWriteKey(){return this.writeKey.privateKey}get privateExchangeKey(){return this.exchangeKey.privateKey}get deviceName(){return Wr.deviceName(this.DID)}static deviceName(e){return eo(e)}async persist(){if(this.isSessionOnly)return;let e=this.constructor.EXCHANGE_KEY_NAME,f=this.constructor.WRITE_KEY_NAME;await Promise.all([tn(e,this.exchangeKey),tn(f,this.writeKey)]),this.hasPersisted=!0}async delete(){await of([this.constructor.EXCHANGE_KEY_NAME,this.constructor.WRITE_KEY_NAME]),this.hasPersisted=!1}async getDeviceName(){return Wr.deviceName(this.DID)}static _createExchangeKeys(e){throw new Error("The child should implement this")}static _createWriteKeys(e){throw new Error("The child should implement this")}static async create(e,f,c){let x=c?.exchangeKeys||await this._createExchangeKeys(f),l=c?.writeKeys||await this._createWriteKeys(f),S=await ge(l),Y=await sn(new Uint8Array(S),this.TYPE==="ecc"?"ed25519":"rsa"),er=new this({keys:{exchange:x,write:l},did:Y,hasPersisted:!1,isSessionOnly:!!e});return this._instance=er,er}static async load(e={session:!1}){if(this._instance)return this._instance;let f=!0,c=await en(e.encryptionKeyName||this.EXCHANGE_KEY_NAME),x=await en(e.writeKeyName||this.WRITE_KEY_NAME);c||(f=!1,c=await this._createExchangeKeys(e.extractable)),x||(f=!1,x=await this._createWriteKeys(e.extractable));let l=await ge(x),S=await sn(new Uint8Array(l),this.TYPE==="ecc"?"ed25519":"rsa"),Y=new this({keys:{exchange:c,write:x},did:S,hasPersisted:f,isSessionOnly:!!e.session});return this._instance=Y,Y}};y(Wr,"AbstractKeys"),O(Wr,"EXCHANGE_KEY_NAME"),O(Wr,"WRITE_KEY_NAME"),O(Wr,"_instance");var Qe=Wr;async function xf(n,e){let{content:f,publicKey:c}=n,x=e||await re.create(),l=await re.encrypt(typeof f=="string"?Br(f):f,typeof x=="string"?await re.import(x):x),S=await yn({key:x,publicKey:c});return $e(S,l)}y(xf,"encryptTo");xf.asString=async function(n,e){let f=await xf(n,e);return xr(new Uint8Array(f),"base64pad")};async function yn({key:n,publicKey:e},f){let c;n instanceof CryptoKey?c=await re.export(n):c=n;let x=await an.encrypt(c,e);return f&&f==="arraybuffer"?x:new Uint8Array(x)}y(yn,"encryptKeyTo");yn.asString=async function({key:n,publicKey:e},f){let c=await yn({key:n,publicKey:e});return f?xr(c,f):Nr(c)};async function eo(n){let e=await rf(new TextEncoder().encode(n.normalize("NFD")));return xr(e,"base32").slice(0,32)}y(eo,"getDeviceName");function De(n){return new Uint8Array(n).buffer}y(De,"toArrayBuffer");var _r=class _r extends Qe{static async create(e,f,c){return await super.create(e,f,c)}constructor(e){super(e),_r.EXCHANGE_KEY_NAME=e.exchangeKeyName||Xe,_r.WRITE_KEY_NAME=e.writeKeyName||ke}get publicExchangeKey(){let e=this.exchangeKey.publicKey;return Object.assign(e,{asString:y(async f=>{let c=await xn(this.exchangeKey),x=new Uint8Array(c);return f?xr(x,f):Nr(c)},"asString")})}get publicWriteKey(){let e=this.writeKey.publicKey;return Object.assign(e,{asString:y(async f=>{let c=await xn(this.writeKey),x=new Uint8Array(c);return f?xr(x,f):Nr(c)},"asString")})}static async _createExchangeKeys(e=!1){return await tr.subtle.generateKey({name:qn},e,["deriveKey","deriveBits"])}static async _createWriteKeys(e=!1){return await tr.subtle.generateKey({name:Jn},e,["sign","verify"])}static async load(e={session:!1}){if(this._instance)return this._instance;let f=e.encryptionKeyName||Xe,c=e.writeKeyName||ke;return super.load({...e,encryptionKeyName:f,writeKeyName:c})}async toJson(e){let f=this.DID,c=await xn(this.exchangeKey);return{publicExchangeKey:e?xr(new Uint8Array(c),e):Nr(c),DID:f}}async encrypt(e,f,c,x,l){let S=new TextEncoder,Y=crypto.getRandomValues(new Uint8Array(zr)),er=f||this.exchangeKey.publicKey,br;typeof er=="string"?br=await et(er,"X25519","exchange"):br=er;let sr=x||await rt(this.exchangeKey.privateKey,br,Y,c||_r.INFO,l);sr instanceof CryptoKey||(sr=await rt(this.exchangeKey.privateKey,br,Y,c||_r.INFO));let vr=crypto.getRandomValues(new Uint8Array(kr)),Yr=typeof e=="string"?S.encode(e):e,te=await crypto.subtle.encrypt({name:Gr,iv:vr},sr,De(Yr)),$=new Uint8Array(Y),cr=new Uint8Array(vr),Ur=new Uint8Array(te),Er=$.length+cr.length+Ur.length,lr=new Uint8Array(Er);return lr.set($,0),lr.set(cr,$.length),lr.set(Ur,$.length+cr.length),lr}async encryptAsString(e,f,c,x,l){let S=await this.encrypt(e,f,c||_r.INFO,x,l);return xr(new Uint8Array(S),"base64pad")}async decrypt(e,f,c,x){let l=typeof f=="string"?await et(f,"X25519","write"):f;l||(l=this.publicExchangeKey);let S=Te(e,Or),Y=S.slice(0,zr),er=S.slice(zr,zr+kr),br=S.slice(zr+kr),{privateKey:sr}=this.exchangeKey,vr=await rt(sr,l,Y,x||_r.INFO);return await crypto.subtle.decrypt({name:c||Gr,iv:er},vr,br)}async decryptAsString(e,f,c,x){let l=await this.decrypt(e,f,c,x);return xr(new Uint8Array(l))}async getAesKey(e,f){e||(e=this.publicExchangeKey);let c;typeof e=="string"?c=await et(e,"X25519","exchange"):c=e;let x=crypto.getRandomValues(new Uint8Array(zr));return await rt(this.exchangeKey.privateKey,c,x,f||_r.INFO)}async sign(e,f){let c=new TextEncoder,x;typeof e=="string"?x=c.encode(e):e instanceof ArrayBuffer?x=new Uint8Array(e):x=e;let l=await tr.subtle.sign({name:Be},this.writeKey.privateKey,De(x));return new Uint8Array(l)}async signAsString(e,f){let c=await this.sign(e,f);return xr(c,"base64pad")}};y(_r,"EccKeys"),O(_r,"TYPE","ecc"),O(_r,"EXCHANGE_KEY_NAME",Xe),O(_r,"WRITE_KEY_NAME",ke),O(_r,"INFO","keys");var ee=_r;Object.assign(ee.prototype.sign,{asString:y(async function(n,e){let f=await this.sign(n,e);return xr(f,"base64pad")},"asString")});async function xn(n,e="raw"){return await crypto.subtle.exportKey(e,n.publicKey)}y(xn,"exportPublicKey");async function et(n,e,f){ff(f);let c=f==="exchange"?Zn:Be,x=f==="exchange"?[]:["verify"],l=Or(n),S=e==="X25519"?{name:c}:{name:c,namedCurve:e};return tr.subtle.importKey("raw",l,S,!0,x)}y(et,"importPublicKey");var Js={EccKeys:ee,importPublicKey:et};Object.assign(ee.prototype.encrypt,{asString:y(async function(n,e,f,c,x){return this.encryptAsString(n,e,f,c,x)},"asString")});Object.assign(ee.prototype.decrypt,{asString:y(async function(n,e,f){return this.decryptAsString(n,e,f)},"asString")});Object.assign(ee.prototype.sign,{asString:y(async function(n,e){return this.signAsString(n,e)},"asString")});async function qs(n,e,f){try{let c=tf(f);if(c.type!=="ed25519")throw new Error(`Expected Ed25519 key for ECC verification, got ${c.type}`);let x=c.publicKey.slice(-32),l=await tr.subtle.importKey("raw",x,{name:Be},!0,["verify"]),S=new TextEncoder,Y;typeof n=="string"?Y=S.encode(n):n instanceof ArrayBuffer?Y=new Uint8Array(n):Y=n;let er;return typeof e=="string"?er=new Uint8Array(Or(e)):er=e,await tr.subtle.verify({name:Be},l,De(er),De(Y))}catch{return!1}}y(qs,"verify");async function rt(n,e,f,c,x){let l=new TextEncoder,S=await crypto.subtle.deriveBits({name:"X25519",public:e},n,256),Y=await crypto.subtle.importKey("raw",S,"HKDF",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:f instanceof Uint8Array?De(f):f,info:l.encode(c)},Y,{name:"AES-GCM",length:x||Qr},!1,["encrypt","decrypt"])}y(rt,"deriveKey");export{ee as EccKeys,Js as default,xn as exportPublicKey,et as importPublicKey,qs as verify};
4
4
  //# sourceMappingURL=index.min.js.map