@junobuild/core 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/index.cjs.js +23 -23
- package/dist/cjs/index.cjs.js.map +4 -4
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +4 -4
- package/package.json +2 -1
- package/dist/types/events/log.events.d.ts +0 -6
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as Br,b as Nn,c as Kr,d as Pn,e as Re,f as Un,g as Be,h as Ke,i as Rn,j as rr,k as Ht,l as nr,m as Bn,p as Cr,q as Mr}from"./chunk-VT367M3F.js";var jr={};Pn(jr,{default:()=>Kn});var Kn,Yr=Nn(()=>{Kn={}});var Vr=Kr((li,Ce)=>{var zt=(Yr(),Un(jr));if(zt&&zt.default){Ce.exports=zt.default;for(let e in zt)Ce.exports[e]=zt[e]}else zt&&(Ce.exports=zt)});var ir=Kr((xi,Me)=>{(function(e){"use strict";var n=function(r){var o,i=new Float64Array(16);if(r)for(o=0;o<r.length;o++)i[o]=r[o];return i},a=function(){throw new Error("no PRNG")},u=new Uint8Array(16),h=new Uint8Array(32);h[0]=9;var m=n(),v=n([1]),B=n([56129,1]),C=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),P=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),tt=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),rt=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),ht=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Nt(r,o,i,t){r[o]=i>>24&255,r[o+1]=i>>16&255,r[o+2]=i>>8&255,r[o+3]=i&255,r[o+4]=t>>24&255,r[o+5]=t>>16&255,r[o+6]=t>>8&255,r[o+7]=t&255}function bt(r,o,i,t,f){var c,l=0;for(c=0;c<f;c++)l|=r[o+c]^i[t+c];return(1&l-1>>>8)-1}function Pt(r,o,i,t){return bt(r,o,i,t,16)}function vt(r,o,i,t){return bt(r,o,i,t,32)}function Gt(r,o,i,t){for(var f=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,c=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,l=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,y=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,_=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,R=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,A=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,T=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,j=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,Y=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,z=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,H=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,V=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,k=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,F=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,O=f,K=c,S=l,N=y,U=_,E=R,x=A,d=Q,b=T,p=j,g=Y,w=z,M=H,$=V,J=k,W=F,s,q=0;q<20;q+=2)s=O+M|0,U^=s<<7|s>>>32-7,s=U+O|0,b^=s<<9|s>>>32-9,s=b+U|0,M^=s<<13|s>>>32-13,s=M+b|0,O^=s<<18|s>>>32-18,s=E+K|0,p^=s<<7|s>>>32-7,s=p+E|0,$^=s<<9|s>>>32-9,s=$+p|0,K^=s<<13|s>>>32-13,s=K+$|0,E^=s<<18|s>>>32-18,s=g+x|0,J^=s<<7|s>>>32-7,s=J+g|0,S^=s<<9|s>>>32-9,s=S+J|0,x^=s<<13|s>>>32-13,s=x+S|0,g^=s<<18|s>>>32-18,s=W+w|0,N^=s<<7|s>>>32-7,s=N+W|0,d^=s<<9|s>>>32-9,s=d+N|0,w^=s<<13|s>>>32-13,s=w+d|0,W^=s<<18|s>>>32-18,s=O+N|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,N^=s<<13|s>>>32-13,s=N+S|0,O^=s<<18|s>>>32-18,s=E+U|0,x^=s<<7|s>>>32-7,s=x+E|0,d^=s<<9|s>>>32-9,s=d+x|0,U^=s<<13|s>>>32-13,s=U+d|0,E^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,b^=s<<9|s>>>32-9,s=b+w|0,p^=s<<13|s>>>32-13,s=p+b|0,g^=s<<18|s>>>32-18,s=W+J|0,M^=s<<7|s>>>32-7,s=M+W|0,$^=s<<9|s>>>32-9,s=$+M|0,J^=s<<13|s>>>32-13,s=J+$|0,W^=s<<18|s>>>32-18;O=O+f|0,K=K+c|0,S=S+l|0,N=N+y|0,U=U+_|0,E=E+R|0,x=x+A|0,d=d+Q|0,b=b+T|0,p=p+j|0,g=g+Y|0,w=w+z|0,M=M+H|0,$=$+V|0,J=J+k|0,W=W+F|0,r[0]=O>>>0&255,r[1]=O>>>8&255,r[2]=O>>>16&255,r[3]=O>>>24&255,r[4]=K>>>0&255,r[5]=K>>>8&255,r[6]=K>>>16&255,r[7]=K>>>24&255,r[8]=S>>>0&255,r[9]=S>>>8&255,r[10]=S>>>16&255,r[11]=S>>>24&255,r[12]=N>>>0&255,r[13]=N>>>8&255,r[14]=N>>>16&255,r[15]=N>>>24&255,r[16]=U>>>0&255,r[17]=U>>>8&255,r[18]=U>>>16&255,r[19]=U>>>24&255,r[20]=E>>>0&255,r[21]=E>>>8&255,r[22]=E>>>16&255,r[23]=E>>>24&255,r[24]=x>>>0&255,r[25]=x>>>8&255,r[26]=x>>>16&255,r[27]=x>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255,r[32]=b>>>0&255,r[33]=b>>>8&255,r[34]=b>>>16&255,r[35]=b>>>24&255,r[36]=p>>>0&255,r[37]=p>>>8&255,r[38]=p>>>16&255,r[39]=p>>>24&255,r[40]=g>>>0&255,r[41]=g>>>8&255,r[42]=g>>>16&255,r[43]=g>>>24&255,r[44]=w>>>0&255,r[45]=w>>>8&255,r[46]=w>>>16&255,r[47]=w>>>24&255,r[48]=M>>>0&255,r[49]=M>>>8&255,r[50]=M>>>16&255,r[51]=M>>>24&255,r[52]=$>>>0&255,r[53]=$>>>8&255,r[54]=$>>>16&255,r[55]=$>>>24&255,r[56]=J>>>0&255,r[57]=J>>>8&255,r[58]=J>>>16&255,r[59]=J>>>24&255,r[60]=W>>>0&255,r[61]=W>>>8&255,r[62]=W>>>16&255,r[63]=W>>>24&255}function qt(r,o,i,t){for(var f=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,c=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,l=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,y=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,_=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,R=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,A=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,T=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,j=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,Y=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,z=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,H=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,V=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,k=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,F=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,O=f,K=c,S=l,N=y,U=_,E=R,x=A,d=Q,b=T,p=j,g=Y,w=z,M=H,$=V,J=k,W=F,s,q=0;q<20;q+=2)s=O+M|0,U^=s<<7|s>>>32-7,s=U+O|0,b^=s<<9|s>>>32-9,s=b+U|0,M^=s<<13|s>>>32-13,s=M+b|0,O^=s<<18|s>>>32-18,s=E+K|0,p^=s<<7|s>>>32-7,s=p+E|0,$^=s<<9|s>>>32-9,s=$+p|0,K^=s<<13|s>>>32-13,s=K+$|0,E^=s<<18|s>>>32-18,s=g+x|0,J^=s<<7|s>>>32-7,s=J+g|0,S^=s<<9|s>>>32-9,s=S+J|0,x^=s<<13|s>>>32-13,s=x+S|0,g^=s<<18|s>>>32-18,s=W+w|0,N^=s<<7|s>>>32-7,s=N+W|0,d^=s<<9|s>>>32-9,s=d+N|0,w^=s<<13|s>>>32-13,s=w+d|0,W^=s<<18|s>>>32-18,s=O+N|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,N^=s<<13|s>>>32-13,s=N+S|0,O^=s<<18|s>>>32-18,s=E+U|0,x^=s<<7|s>>>32-7,s=x+E|0,d^=s<<9|s>>>32-9,s=d+x|0,U^=s<<13|s>>>32-13,s=U+d|0,E^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,b^=s<<9|s>>>32-9,s=b+w|0,p^=s<<13|s>>>32-13,s=p+b|0,g^=s<<18|s>>>32-18,s=W+J|0,M^=s<<7|s>>>32-7,s=M+W|0,$^=s<<9|s>>>32-9,s=$+M|0,J^=s<<13|s>>>32-13,s=J+$|0,W^=s<<18|s>>>32-18;r[0]=O>>>0&255,r[1]=O>>>8&255,r[2]=O>>>16&255,r[3]=O>>>24&255,r[4]=E>>>0&255,r[5]=E>>>8&255,r[6]=E>>>16&255,r[7]=E>>>24&255,r[8]=g>>>0&255,r[9]=g>>>8&255,r[10]=g>>>16&255,r[11]=g>>>24&255,r[12]=W>>>0&255,r[13]=W>>>8&255,r[14]=W>>>16&255,r[15]=W>>>24&255,r[16]=x>>>0&255,r[17]=x>>>8&255,r[18]=x>>>16&255,r[19]=x>>>24&255,r[20]=d>>>0&255,r[21]=d>>>8&255,r[22]=d>>>16&255,r[23]=d>>>24&255,r[24]=b>>>0&255,r[25]=b>>>8&255,r[26]=b>>>16&255,r[27]=b>>>24&255,r[28]=p>>>0&255,r[29]=p>>>8&255,r[30]=p>>>16&255,r[31]=p>>>24&255}function xt(r,o,i,t){Gt(r,o,i,t)}function Ut(r,o,i,t){qt(r,o,i,t)}var Et=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Vt(r,o,i,t,f,c,l){var y=new Uint8Array(16),_=new Uint8Array(64),R,A;for(A=0;A<16;A++)y[A]=0;for(A=0;A<8;A++)y[A]=c[A];for(;f>=64;){for(xt(_,y,l,Et),A=0;A<64;A++)r[o+A]=i[t+A]^_[A];for(R=1,A=8;A<16;A++)R=R+(y[A]&255)|0,y[A]=R&255,R>>>=8;f-=64,o+=64,t+=64}if(f>0)for(xt(_,y,l,Et),A=0;A<f;A++)r[o+A]=i[t+A]^_[A];return 0}function we(r,o,i,t,f){var c=new Uint8Array(16),l=new Uint8Array(64),y,_;for(_=0;_<16;_++)c[_]=0;for(_=0;_<8;_++)c[_]=t[_];for(;i>=64;){for(xt(l,c,f,Et),_=0;_<64;_++)r[o+_]=l[_];for(y=1,_=8;_<16;_++)y=y+(c[_]&255)|0,c[_]=y&255,y>>>=8;i-=64,o+=64}if(i>0)for(xt(l,c,f,Et),_=0;_<i;_++)r[o+_]=l[_];return 0}function _e(r,o,i,t,f){var c=new Uint8Array(32);Ut(c,t,f,Et);for(var l=new Uint8Array(8),y=0;y<8;y++)l[y]=t[y+16];return we(r,o,i,l,c)}function oe(r,o,i,t,f,c,l){var y=new Uint8Array(32);Ut(y,c,l,Et);for(var _=new Uint8Array(8),R=0;R<8;R++)_[R]=c[R+16];return Vt(r,o,i,t,f,_,y)}var Zt=function(r){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,t,f,c,l,y,_;o=r[0]&255|(r[1]&255)<<8,this.r[0]=o&8191,i=r[2]&255|(r[3]&255)<<8,this.r[1]=(o>>>13|i<<3)&8191,t=r[4]&255|(r[5]&255)<<8,this.r[2]=(i>>>10|t<<6)&7939,f=r[6]&255|(r[7]&255)<<8,this.r[3]=(t>>>7|f<<9)&8191,c=r[8]&255|(r[9]&255)<<8,this.r[4]=(f>>>4|c<<12)&255,this.r[5]=c>>>1&8190,l=r[10]&255|(r[11]&255)<<8,this.r[6]=(c>>>14|l<<2)&8191,y=r[12]&255|(r[13]&255)<<8,this.r[7]=(l>>>11|y<<5)&8065,_=r[14]&255|(r[15]&255)<<8,this.r[8]=(y>>>8|_<<8)&8191,this.r[9]=_>>>5&127,this.pad[0]=r[16]&255|(r[17]&255)<<8,this.pad[1]=r[18]&255|(r[19]&255)<<8,this.pad[2]=r[20]&255|(r[21]&255)<<8,this.pad[3]=r[22]&255|(r[23]&255)<<8,this.pad[4]=r[24]&255|(r[25]&255)<<8,this.pad[5]=r[26]&255|(r[27]&255)<<8,this.pad[6]=r[28]&255|(r[29]&255)<<8,this.pad[7]=r[30]&255|(r[31]&255)<<8};Zt.prototype.blocks=function(r,o,i){for(var t=this.fin?0:2048,f,c,l,y,_,R,A,Q,T,j,Y,z,H,V,k,F,O,K,S,N=this.h[0],U=this.h[1],E=this.h[2],x=this.h[3],d=this.h[4],b=this.h[5],p=this.h[6],g=this.h[7],w=this.h[8],M=this.h[9],$=this.r[0],J=this.r[1],W=this.r[2],s=this.r[3],q=this.r[4],I=this.r[5],L=this.r[6],G=this.r[7],X=this.r[8],D=this.r[9];i>=16;)f=r[o+0]&255|(r[o+1]&255)<<8,N+=f&8191,c=r[o+2]&255|(r[o+3]&255)<<8,U+=(f>>>13|c<<3)&8191,l=r[o+4]&255|(r[o+5]&255)<<8,E+=(c>>>10|l<<6)&8191,y=r[o+6]&255|(r[o+7]&255)<<8,x+=(l>>>7|y<<9)&8191,_=r[o+8]&255|(r[o+9]&255)<<8,d+=(y>>>4|_<<12)&8191,b+=_>>>1&8191,R=r[o+10]&255|(r[o+11]&255)<<8,p+=(_>>>14|R<<2)&8191,A=r[o+12]&255|(r[o+13]&255)<<8,g+=(R>>>11|A<<5)&8191,Q=r[o+14]&255|(r[o+15]&255)<<8,w+=(A>>>8|Q<<8)&8191,M+=Q>>>5|t,T=0,j=T,j+=N*$,j+=U*(5*D),j+=E*(5*X),j+=x*(5*G),j+=d*(5*L),T=j>>>13,j&=8191,j+=b*(5*I),j+=p*(5*q),j+=g*(5*s),j+=w*(5*W),j+=M*(5*J),T+=j>>>13,j&=8191,Y=T,Y+=N*J,Y+=U*$,Y+=E*(5*D),Y+=x*(5*X),Y+=d*(5*G),T=Y>>>13,Y&=8191,Y+=b*(5*L),Y+=p*(5*I),Y+=g*(5*q),Y+=w*(5*s),Y+=M*(5*W),T+=Y>>>13,Y&=8191,z=T,z+=N*W,z+=U*J,z+=E*$,z+=x*(5*D),z+=d*(5*X),T=z>>>13,z&=8191,z+=b*(5*G),z+=p*(5*L),z+=g*(5*I),z+=w*(5*q),z+=M*(5*s),T+=z>>>13,z&=8191,H=T,H+=N*s,H+=U*W,H+=E*J,H+=x*$,H+=d*(5*D),T=H>>>13,H&=8191,H+=b*(5*X),H+=p*(5*G),H+=g*(5*L),H+=w*(5*I),H+=M*(5*q),T+=H>>>13,H&=8191,V=T,V+=N*q,V+=U*s,V+=E*W,V+=x*J,V+=d*$,T=V>>>13,V&=8191,V+=b*(5*D),V+=p*(5*X),V+=g*(5*G),V+=w*(5*L),V+=M*(5*I),T+=V>>>13,V&=8191,k=T,k+=N*I,k+=U*q,k+=E*s,k+=x*W,k+=d*J,T=k>>>13,k&=8191,k+=b*$,k+=p*(5*D),k+=g*(5*X),k+=w*(5*G),k+=M*(5*L),T+=k>>>13,k&=8191,F=T,F+=N*L,F+=U*I,F+=E*q,F+=x*s,F+=d*W,T=F>>>13,F&=8191,F+=b*J,F+=p*$,F+=g*(5*D),F+=w*(5*X),F+=M*(5*G),T+=F>>>13,F&=8191,O=T,O+=N*G,O+=U*L,O+=E*I,O+=x*q,O+=d*s,T=O>>>13,O&=8191,O+=b*W,O+=p*J,O+=g*$,O+=w*(5*D),O+=M*(5*X),T+=O>>>13,O&=8191,K=T,K+=N*X,K+=U*G,K+=E*L,K+=x*I,K+=d*q,T=K>>>13,K&=8191,K+=b*s,K+=p*W,K+=g*J,K+=w*$,K+=M*(5*D),T+=K>>>13,K&=8191,S=T,S+=N*D,S+=U*X,S+=E*G,S+=x*L,S+=d*I,T=S>>>13,S&=8191,S+=b*q,S+=p*s,S+=g*W,S+=w*J,S+=M*$,T+=S>>>13,S&=8191,T=(T<<2)+T|0,T=T+j|0,j=T&8191,T=T>>>13,Y+=T,N=j,U=Y,E=z,x=H,d=V,b=k,p=F,g=O,w=K,M=S,o+=16,i-=16;this.h[0]=N,this.h[1]=U,this.h[2]=E,this.h[3]=x,this.h[4]=d,this.h[5]=b,this.h[6]=p,this.h[7]=g,this.h[8]=w,this.h[9]=M},Zt.prototype.finish=function(r,o){var i=new Uint16Array(10),t,f,c,l;if(this.leftover){for(l=this.leftover,this.buffer[l++]=1;l<16;l++)this.buffer[l]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(t=this.h[1]>>>13,this.h[1]&=8191,l=2;l<10;l++)this.h[l]+=t,t=this.h[l]>>>13,this.h[l]&=8191;for(this.h[0]+=t*5,t=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=t,t=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=t,i[0]=this.h[0]+5,t=i[0]>>>13,i[0]&=8191,l=1;l<10;l++)i[l]=this.h[l]+t,t=i[l]>>>13,i[l]&=8191;for(i[9]-=1<<13,f=(t^1)-1,l=0;l<10;l++)i[l]&=f;for(f=~f,l=0;l<10;l++)this.h[l]=this.h[l]&f|i[l];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,c=this.h[0]+this.pad[0],this.h[0]=c&65535,l=1;l<8;l++)c=(this.h[l]+this.pad[l]|0)+(c>>>16)|0,this.h[l]=c&65535;r[o+0]=this.h[0]>>>0&255,r[o+1]=this.h[0]>>>8&255,r[o+2]=this.h[1]>>>0&255,r[o+3]=this.h[1]>>>8&255,r[o+4]=this.h[2]>>>0&255,r[o+5]=this.h[2]>>>8&255,r[o+6]=this.h[3]>>>0&255,r[o+7]=this.h[3]>>>8&255,r[o+8]=this.h[4]>>>0&255,r[o+9]=this.h[4]>>>8&255,r[o+10]=this.h[5]>>>0&255,r[o+11]=this.h[5]>>>8&255,r[o+12]=this.h[6]>>>0&255,r[o+13]=this.h[6]>>>8&255,r[o+14]=this.h[7]>>>0&255,r[o+15]=this.h[7]>>>8&255},Zt.prototype.update=function(r,o,i){var t,f;if(this.leftover){for(f=16-this.leftover,f>i&&(f=i),t=0;t<f;t++)this.buffer[this.leftover+t]=r[o+t];if(i-=f,o+=f,this.leftover+=f,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(i>=16&&(f=i-i%16,this.blocks(r,o,f),o+=f,i-=f),i){for(t=0;t<i;t++)this.buffer[this.leftover+t]=r[o+t];this.leftover+=i}};function fe(r,o,i,t,f,c){var l=new Zt(c);return l.update(i,t,f),l.finish(r,o),0}function ve(r,o,i,t,f,c){var l=new Uint8Array(16);return fe(l,0,i,t,f,c),Pt(r,o,l,0)}function ae(r,o,i,t,f){var c;if(i<32)return-1;for(oe(r,0,o,0,i,t,f),fe(r,16,r,32,i-32,r),c=0;c<16;c++)r[c]=0;return 0}function se(r,o,i,t,f){var c,l=new Uint8Array(32);if(i<32||(_e(l,0,32,t,f),ve(o,16,o,32,i-32,l)!==0))return-1;for(oe(r,0,o,0,i,t,f),c=0;c<32;c++)r[c]=0;return 0}function Rt(r,o){var i;for(i=0;i<16;i++)r[i]=o[i]|0}function We(r){var o,i,t=1;for(o=0;o<16;o++)i=r[o]+t+65535,t=Math.floor(i/65536),r[o]=i-t*65536;r[0]+=t-1+37*(t-1)}function Xt(r,o,i){for(var t,f=~(i-1),c=0;c<16;c++)t=f&(r[c]^o[c]),r[c]^=t,o[c]^=t}function Dt(r,o){var i,t,f,c=n(),l=n();for(i=0;i<16;i++)l[i]=o[i];for(We(l),We(l),We(l),t=0;t<2;t++){for(c[0]=l[0]-65517,i=1;i<15;i++)c[i]=l[i]-65535-(c[i-1]>>16&1),c[i-1]&=65535;c[15]=l[15]-32767-(c[14]>>16&1),f=c[15]>>16&1,c[14]&=65535,Xt(l,c,1-f)}for(i=0;i<16;i++)r[2*i]=l[i]&255,r[2*i+1]=l[i]>>8}function mr(r,o){var i=new Uint8Array(32),t=new Uint8Array(32);return Dt(i,r),Dt(t,o),vt(i,0,t,0)}function wr(r){var o=new Uint8Array(32);return Dt(o,r),o[0]&1}function Je(r,o){var i;for(i=0;i<16;i++)r[i]=o[2*i]+(o[2*i+1]<<8);r[15]&=32767}function mt(r,o,i){for(var t=0;t<16;t++)r[t]=o[t]+i[t]}function wt(r,o,i){for(var t=0;t<16;t++)r[t]=o[t]-i[t]}function Z(r,o,i){var t,f,c=0,l=0,y=0,_=0,R=0,A=0,Q=0,T=0,j=0,Y=0,z=0,H=0,V=0,k=0,F=0,O=0,K=0,S=0,N=0,U=0,E=0,x=0,d=0,b=0,p=0,g=0,w=0,M=0,$=0,J=0,W=0,s=i[0],q=i[1],I=i[2],L=i[3],G=i[4],X=i[5],D=i[6],ft=i[7],et=i[8],nt=i[9],it=i[10],ot=i[11],at=i[12],st=i[13],ct=i[14],lt=i[15];t=o[0],c+=t*s,l+=t*q,y+=t*I,_+=t*L,R+=t*G,A+=t*X,Q+=t*D,T+=t*ft,j+=t*et,Y+=t*nt,z+=t*it,H+=t*ot,V+=t*at,k+=t*st,F+=t*ct,O+=t*lt,t=o[1],l+=t*s,y+=t*q,_+=t*I,R+=t*L,A+=t*G,Q+=t*X,T+=t*D,j+=t*ft,Y+=t*et,z+=t*nt,H+=t*it,V+=t*ot,k+=t*at,F+=t*st,O+=t*ct,K+=t*lt,t=o[2],y+=t*s,_+=t*q,R+=t*I,A+=t*L,Q+=t*G,T+=t*X,j+=t*D,Y+=t*ft,z+=t*et,H+=t*nt,V+=t*it,k+=t*ot,F+=t*at,O+=t*st,K+=t*ct,S+=t*lt,t=o[3],_+=t*s,R+=t*q,A+=t*I,Q+=t*L,T+=t*G,j+=t*X,Y+=t*D,z+=t*ft,H+=t*et,V+=t*nt,k+=t*it,F+=t*ot,O+=t*at,K+=t*st,S+=t*ct,N+=t*lt,t=o[4],R+=t*s,A+=t*q,Q+=t*I,T+=t*L,j+=t*G,Y+=t*X,z+=t*D,H+=t*ft,V+=t*et,k+=t*nt,F+=t*it,O+=t*ot,K+=t*at,S+=t*st,N+=t*ct,U+=t*lt,t=o[5],A+=t*s,Q+=t*q,T+=t*I,j+=t*L,Y+=t*G,z+=t*X,H+=t*D,V+=t*ft,k+=t*et,F+=t*nt,O+=t*it,K+=t*ot,S+=t*at,N+=t*st,U+=t*ct,E+=t*lt,t=o[6],Q+=t*s,T+=t*q,j+=t*I,Y+=t*L,z+=t*G,H+=t*X,V+=t*D,k+=t*ft,F+=t*et,O+=t*nt,K+=t*it,S+=t*ot,N+=t*at,U+=t*st,E+=t*ct,x+=t*lt,t=o[7],T+=t*s,j+=t*q,Y+=t*I,z+=t*L,H+=t*G,V+=t*X,k+=t*D,F+=t*ft,O+=t*et,K+=t*nt,S+=t*it,N+=t*ot,U+=t*at,E+=t*st,x+=t*ct,d+=t*lt,t=o[8],j+=t*s,Y+=t*q,z+=t*I,H+=t*L,V+=t*G,k+=t*X,F+=t*D,O+=t*ft,K+=t*et,S+=t*nt,N+=t*it,U+=t*ot,E+=t*at,x+=t*st,d+=t*ct,b+=t*lt,t=o[9],Y+=t*s,z+=t*q,H+=t*I,V+=t*L,k+=t*G,F+=t*X,O+=t*D,K+=t*ft,S+=t*et,N+=t*nt,U+=t*it,E+=t*ot,x+=t*at,d+=t*st,b+=t*ct,p+=t*lt,t=o[10],z+=t*s,H+=t*q,V+=t*I,k+=t*L,F+=t*G,O+=t*X,K+=t*D,S+=t*ft,N+=t*et,U+=t*nt,E+=t*it,x+=t*ot,d+=t*at,b+=t*st,p+=t*ct,g+=t*lt,t=o[11],H+=t*s,V+=t*q,k+=t*I,F+=t*L,O+=t*G,K+=t*X,S+=t*D,N+=t*ft,U+=t*et,E+=t*nt,x+=t*it,d+=t*ot,b+=t*at,p+=t*st,g+=t*ct,w+=t*lt,t=o[12],V+=t*s,k+=t*q,F+=t*I,O+=t*L,K+=t*G,S+=t*X,N+=t*D,U+=t*ft,E+=t*et,x+=t*nt,d+=t*it,b+=t*ot,p+=t*at,g+=t*st,w+=t*ct,M+=t*lt,t=o[13],k+=t*s,F+=t*q,O+=t*I,K+=t*L,S+=t*G,N+=t*X,U+=t*D,E+=t*ft,x+=t*et,d+=t*nt,b+=t*it,p+=t*ot,g+=t*at,w+=t*st,M+=t*ct,$+=t*lt,t=o[14],F+=t*s,O+=t*q,K+=t*I,S+=t*L,N+=t*G,U+=t*X,E+=t*D,x+=t*ft,d+=t*et,b+=t*nt,p+=t*it,g+=t*ot,w+=t*at,M+=t*st,$+=t*ct,J+=t*lt,t=o[15],O+=t*s,K+=t*q,S+=t*I,N+=t*L,U+=t*G,E+=t*X,x+=t*D,d+=t*ft,b+=t*et,p+=t*nt,g+=t*it,w+=t*ot,M+=t*at,$+=t*st,J+=t*ct,W+=t*lt,c+=38*K,l+=38*S,y+=38*N,_+=38*U,R+=38*E,A+=38*x,Q+=38*d,T+=38*b,j+=38*p,Y+=38*g,z+=38*w,H+=38*M,V+=38*$,k+=38*J,F+=38*W,f=1,t=c+f+65535,f=Math.floor(t/65536),c=t-f*65536,t=l+f+65535,f=Math.floor(t/65536),l=t-f*65536,t=y+f+65535,f=Math.floor(t/65536),y=t-f*65536,t=_+f+65535,f=Math.floor(t/65536),_=t-f*65536,t=R+f+65535,f=Math.floor(t/65536),R=t-f*65536,t=A+f+65535,f=Math.floor(t/65536),A=t-f*65536,t=Q+f+65535,f=Math.floor(t/65536),Q=t-f*65536,t=T+f+65535,f=Math.floor(t/65536),T=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=t-f*65536,t=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=z+f+65535,f=Math.floor(t/65536),z=t-f*65536,t=H+f+65535,f=Math.floor(t/65536),H=t-f*65536,t=V+f+65535,f=Math.floor(t/65536),V=t-f*65536,t=k+f+65535,f=Math.floor(t/65536),k=t-f*65536,t=F+f+65535,f=Math.floor(t/65536),F=t-f*65536,t=O+f+65535,f=Math.floor(t/65536),O=t-f*65536,c+=f-1+37*(f-1),f=1,t=c+f+65535,f=Math.floor(t/65536),c=t-f*65536,t=l+f+65535,f=Math.floor(t/65536),l=t-f*65536,t=y+f+65535,f=Math.floor(t/65536),y=t-f*65536,t=_+f+65535,f=Math.floor(t/65536),_=t-f*65536,t=R+f+65535,f=Math.floor(t/65536),R=t-f*65536,t=A+f+65535,f=Math.floor(t/65536),A=t-f*65536,t=Q+f+65535,f=Math.floor(t/65536),Q=t-f*65536,t=T+f+65535,f=Math.floor(t/65536),T=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=t-f*65536,t=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=z+f+65535,f=Math.floor(t/65536),z=t-f*65536,t=H+f+65535,f=Math.floor(t/65536),H=t-f*65536,t=V+f+65535,f=Math.floor(t/65536),V=t-f*65536,t=k+f+65535,f=Math.floor(t/65536),k=t-f*65536,t=F+f+65535,f=Math.floor(t/65536),F=t-f*65536,t=O+f+65535,f=Math.floor(t/65536),O=t-f*65536,c+=f-1+37*(f-1),r[0]=c,r[1]=l,r[2]=y,r[3]=_,r[4]=R,r[5]=A,r[6]=Q,r[7]=T,r[8]=j,r[9]=Y,r[10]=z,r[11]=H,r[12]=V,r[13]=k,r[14]=F,r[15]=O}function yt(r,o){Z(r,o,o)}function _r(r,o){var i=n(),t;for(t=0;t<16;t++)i[t]=o[t];for(t=253;t>=0;t--)yt(i,i),t!==2&&t!==4&&Z(i,i,o);for(t=0;t<16;t++)r[t]=i[t]}function vr(r,o){var i=n(),t;for(t=0;t<16;t++)i[t]=o[t];for(t=250;t>=0;t--)yt(i,i),t!==1&&Z(i,i,o);for(t=0;t<16;t++)r[t]=i[t]}function Ee(r,o,i){var t=new Uint8Array(32),f=new Float64Array(80),c,l,y=n(),_=n(),R=n(),A=n(),Q=n(),T=n();for(l=0;l<31;l++)t[l]=o[l];for(t[31]=o[31]&127|64,t[0]&=248,Je(f,i),l=0;l<16;l++)_[l]=f[l],A[l]=y[l]=R[l]=0;for(y[0]=A[0]=1,l=254;l>=0;--l)c=t[l>>>3]>>>(l&7)&1,Xt(y,_,c),Xt(R,A,c),mt(Q,y,R),wt(y,y,R),mt(R,_,A),wt(_,_,A),yt(A,Q),yt(T,y),Z(y,R,y),Z(R,_,Q),mt(Q,y,R),wt(y,y,R),yt(_,y),wt(R,A,T),Z(y,R,B),mt(y,y,A),Z(R,R,y),Z(y,A,T),Z(A,_,f),yt(_,Q),Xt(y,_,c),Xt(R,A,c);for(l=0;l<16;l++)f[l+16]=y[l],f[l+32]=R[l],f[l+48]=_[l],f[l+64]=A[l];var j=f.subarray(32),Y=f.subarray(16);return _r(j,j),Z(Y,Y,j),Dt(r,Y),0}function Ae(r,o){return Ee(r,o,h)}function Er(r,o){return a(o,32),Ae(r,o)}function Se(r,o,i){var t=new Uint8Array(32);return Ee(t,i,o),Ut(r,u,t,Et)}var Ar=ae,_n=se;function vn(r,o,i,t,f,c){var l=new Uint8Array(32);return Se(l,f,c),Ar(r,o,i,t,l)}function En(r,o,i,t,f,c){var l=new Uint8Array(32);return Se(l,f,c),_n(r,o,i,t,l)}var Sr=[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 Tr(r,o,i,t){for(var f=new Int32Array(16),c=new Int32Array(16),l,y,_,R,A,Q,T,j,Y,z,H,V,k,F,O,K,S,N,U,E,x,d,b,p,g,w,M=r[0],$=r[1],J=r[2],W=r[3],s=r[4],q=r[5],I=r[6],L=r[7],G=o[0],X=o[1],D=o[2],ft=o[3],et=o[4],nt=o[5],it=o[6],ot=o[7],at=0;t>=128;){for(U=0;U<16;U++)E=8*U+at,f[U]=i[E+0]<<24|i[E+1]<<16|i[E+2]<<8|i[E+3],c[U]=i[E+4]<<24|i[E+5]<<16|i[E+6]<<8|i[E+7];for(U=0;U<80;U++)if(l=M,y=$,_=J,R=W,A=s,Q=q,T=I,j=L,Y=G,z=X,H=D,V=ft,k=et,F=nt,O=it,K=ot,x=L,d=ot,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=(s>>>14|et<<32-14)^(s>>>18|et<<32-18)^(et>>>41-32|s<<32-(41-32)),d=(et>>>14|s<<32-14)^(et>>>18|s<<32-18)^(s>>>41-32|et<<32-(41-32)),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=s&q^~s&I,d=et&nt^~et&it,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=Sr[U*2],d=Sr[U*2+1],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=f[U%16],d=c[U%16],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,S=g&65535|w<<16,N=b&65535|p<<16,x=S,d=N,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=(M>>>28|G<<32-28)^(G>>>34-32|M<<32-(34-32))^(G>>>39-32|M<<32-(39-32)),d=(G>>>28|M<<32-28)^(M>>>34-32|G<<32-(34-32))^(M>>>39-32|G<<32-(39-32)),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=M&$^M&J^$&J,d=G&X^G&D^X&D,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,j=g&65535|w<<16,K=b&65535|p<<16,x=R,d=V,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=S,d=N,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,R=g&65535|w<<16,V=b&65535|p<<16,$=l,J=y,W=_,s=R,q=A,I=Q,L=T,M=j,X=Y,D=z,ft=H,et=V,nt=k,it=F,ot=O,G=K,U%16===15)for(E=0;E<16;E++)x=f[E],d=c[E],b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=f[(E+9)%16],d=c[(E+9)%16],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,S=f[(E+1)%16],N=c[(E+1)%16],x=(S>>>1|N<<32-1)^(S>>>8|N<<32-8)^S>>>7,d=(N>>>1|S<<32-1)^(N>>>8|S<<32-8)^(N>>>7|S<<32-7),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,S=f[(E+14)%16],N=c[(E+14)%16],x=(S>>>19|N<<32-19)^(N>>>61-32|S<<32-(61-32))^S>>>6,d=(N>>>19|S<<32-19)^(S>>>61-32|N<<32-(61-32))^(N>>>6|S<<32-6),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,f[E]=g&65535|w<<16,c[E]=b&65535|p<<16;x=M,d=G,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[0],d=o[0],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[0]=M=g&65535|w<<16,o[0]=G=b&65535|p<<16,x=$,d=X,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[1],d=o[1],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[1]=$=g&65535|w<<16,o[1]=X=b&65535|p<<16,x=J,d=D,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[2],d=o[2],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[2]=J=g&65535|w<<16,o[2]=D=b&65535|p<<16,x=W,d=ft,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[3],d=o[3],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[3]=W=g&65535|w<<16,o[3]=ft=b&65535|p<<16,x=s,d=et,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[4],d=o[4],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[4]=s=g&65535|w<<16,o[4]=et=b&65535|p<<16,x=q,d=nt,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[5],d=o[5],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[5]=q=g&65535|w<<16,o[5]=nt=b&65535|p<<16,x=I,d=it,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[6],d=o[6],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[6]=I=g&65535|w<<16,o[6]=it=b&65535|p<<16,x=L,d=ot,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[7],d=o[7],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[7]=L=g&65535|w<<16,o[7]=ot=b&65535|p<<16,at+=128,t-=128}return t}function Ft(r,o,i){var t=new Int32Array(8),f=new Int32Array(8),c=new Uint8Array(256),l,y=i;for(t[0]=1779033703,t[1]=3144134277,t[2]=1013904242,t[3]=2773480762,t[4]=1359893119,t[5]=2600822924,t[6]=528734635,t[7]=1541459225,f[0]=4089235720,f[1]=2227873595,f[2]=4271175723,f[3]=1595750129,f[4]=2917565137,f[5]=725511199,f[6]=4215389547,f[7]=327033209,Tr(t,f,o,i),i%=128,l=0;l<i;l++)c[l]=o[y-i+l];for(c[i]=128,i=256-128*(i<112?1:0),c[i-9]=0,Nt(c,i-8,y/536870912|0,y<<3),Tr(t,f,c,i),l=0;l<8;l++)Nt(r,8*l,t[l],f[l]);return 0}function Te(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n(),R=n(),A=n();wt(i,r[1],r[0]),wt(A,o[1],o[0]),Z(i,i,A),mt(t,r[0],r[1]),mt(A,o[0],o[1]),Z(t,t,A),Z(f,r[3],o[3]),Z(f,f,P),Z(c,r[2],o[2]),mt(c,c,c),wt(l,t,i),wt(y,c,f),mt(_,c,f),mt(R,t,i),Z(r[0],l,y),Z(r[1],R,_),Z(r[2],_,y),Z(r[3],l,R)}function Or(r,o,i){var t;for(t=0;t<4;t++)Xt(r[t],o[t],i)}function Ge(r,o){var i=n(),t=n(),f=n();_r(f,o[2]),Z(i,o[0],f),Z(t,o[1],f),Dt(r,t),r[31]^=wr(i)<<7}function qe(r,o,i){var t,f;for(Rt(r[0],m),Rt(r[1],v),Rt(r[2],v),Rt(r[3],m),f=255;f>=0;--f)t=i[f/8|0]>>(f&7)&1,Or(r,o,t),Te(o,r),Te(r,r),Or(r,o,t)}function Oe(r,o){var i=[n(),n(),n(),n()];Rt(i[0],tt),Rt(i[1],rt),Rt(i[2],v),Z(i[3],tt,rt),qe(r,i,o)}function Ze(r,o,i){var t=new Uint8Array(64),f=[n(),n(),n(),n()],c;for(i||a(o,32),Ft(t,o,32),t[0]&=248,t[31]&=127,t[31]|=64,Oe(f,t),Ge(r,f),c=0;c<32;c++)o[c+32]=r[c];return 0}var Ne=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 Xe(r,o){var i,t,f,c;for(t=63;t>=32;--t){for(i=0,f=t-32,c=t-12;f<c;++f)o[f]+=i-16*o[t]*Ne[f-(t-32)],i=Math.floor((o[f]+128)/256),o[f]-=i*256;o[f]+=i,o[t]=0}for(i=0,f=0;f<32;f++)o[f]+=i-(o[31]>>4)*Ne[f],i=o[f]>>8,o[f]&=255;for(f=0;f<32;f++)o[f]-=i*Ne[f];for(t=0;t<32;t++)o[t+1]+=o[t]>>8,r[t]=o[t]&255}function De(r){var o=new Float64Array(64),i;for(i=0;i<64;i++)o[i]=r[i];for(i=0;i<64;i++)r[i]=0;Xe(r,o)}function Nr(r,o,i,t){var f=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),y,_,R=new Float64Array(64),A=[n(),n(),n(),n()];Ft(f,t,32),f[0]&=248,f[31]&=127,f[31]|=64;var Q=i+64;for(y=0;y<i;y++)r[64+y]=o[y];for(y=0;y<32;y++)r[32+y]=f[32+y];for(Ft(l,r.subarray(32),i+32),De(l),Oe(A,l),Ge(r,A),y=32;y<64;y++)r[y]=t[y];for(Ft(c,r,i+64),De(c),y=0;y<64;y++)R[y]=0;for(y=0;y<32;y++)R[y]=l[y];for(y=0;y<32;y++)for(_=0;_<32;_++)R[y+_]+=c[y]*f[_];return Xe(r.subarray(32),R),Q}function An(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n();return Rt(r[2],v),Je(r[1],o),yt(f,r[1]),Z(c,f,C),wt(f,f,r[2]),mt(c,r[2],c),yt(l,c),yt(y,l),Z(_,y,l),Z(i,_,f),Z(i,i,c),vr(i,i),Z(i,i,f),Z(i,i,c),Z(i,i,c),Z(r[0],i,c),yt(t,r[0]),Z(t,t,c),mr(t,f)&&Z(r[0],r[0],ht),yt(t,r[0]),Z(t,t,c),mr(t,f)?-1:(wr(r[0])===o[31]>>7&&wt(r[0],m,r[0]),Z(r[3],r[0],r[1]),0)}function Qe(r,o,i,t){var f,c=new Uint8Array(32),l=new Uint8Array(64),y=[n(),n(),n(),n()],_=[n(),n(),n(),n()];if(i<64||An(_,t))return-1;for(f=0;f<i;f++)r[f]=o[f];for(f=0;f<32;f++)r[f+32]=t[f];if(Ft(l,r,i),De(l),qe(y,_,l),Oe(_,o.subarray(32)),Te(y,_),Ge(c,y),i-=64,vt(o,0,c,0)){for(f=0;f<i;f++)r[f]=0;return-1}for(f=0;f<i;f++)r[f]=o[f+64];return i}var Ie=32,Pe=24,ce=32,Qt=16,le=32,Ue=32,xe=32,de=32,Le=32,Pr=Pe,Sn=ce,Tn=Qt,Bt=64,kt=32,It=64,tr=32,er=64;e.lowlevel={crypto_core_hsalsa20:Ut,crypto_stream_xor:oe,crypto_stream:_e,crypto_stream_salsa20_xor:Vt,crypto_stream_salsa20:we,crypto_onetimeauth:fe,crypto_onetimeauth_verify:ve,crypto_verify_16:Pt,crypto_verify_32:vt,crypto_secretbox:ae,crypto_secretbox_open:se,crypto_scalarmult:Ee,crypto_scalarmult_base:Ae,crypto_box_beforenm:Se,crypto_box_afternm:Ar,crypto_box:vn,crypto_box_open:En,crypto_box_keypair:Er,crypto_hash:Ft,crypto_sign:Nr,crypto_sign_keypair:Ze,crypto_sign_open:Qe,crypto_secretbox_KEYBYTES:Ie,crypto_secretbox_NONCEBYTES:Pe,crypto_secretbox_ZEROBYTES:ce,crypto_secretbox_BOXZEROBYTES:Qt,crypto_scalarmult_BYTES:le,crypto_scalarmult_SCALARBYTES:Ue,crypto_box_PUBLICKEYBYTES:xe,crypto_box_SECRETKEYBYTES:de,crypto_box_BEFORENMBYTES:Le,crypto_box_NONCEBYTES:Pr,crypto_box_ZEROBYTES:Sn,crypto_box_BOXZEROBYTES:Tn,crypto_sign_BYTES:Bt,crypto_sign_PUBLICKEYBYTES:kt,crypto_sign_SECRETKEYBYTES:It,crypto_sign_SEEDBYTES:tr,crypto_hash_BYTES:er,gf:n,D:C,L:Ne,pack25519:Dt,unpack25519:Je,M:Z,A:mt,S:yt,Z:wt,pow2523:vr,add:Te,set25519:Rt,modL:Xe,scalarmult:qe,scalarbase:Oe};function Ur(r,o){if(r.length!==Ie)throw new Error("bad key size");if(o.length!==Pe)throw new Error("bad nonce size")}function On(r,o){if(r.length!==xe)throw new Error("bad public key size");if(o.length!==de)throw new Error("bad secret key size")}function pt(){for(var r=0;r<arguments.length;r++)if(!(arguments[r]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Rr(r){for(var o=0;o<r.length;o++)r[o]=0}e.randomBytes=function(r){var o=new Uint8Array(r);return a(o,r),o},e.secretbox=function(r,o,i){pt(r,o,i),Ur(i,o);for(var t=new Uint8Array(ce+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+ce]=r[c];return ae(f,t,t.length,o,i),f.subarray(Qt)},e.secretbox.open=function(r,o,i){pt(r,o,i),Ur(i,o);for(var t=new Uint8Array(Qt+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+Qt]=r[c];return t.length<32||se(f,t,t.length,o,i)!==0?null:f.subarray(ce)},e.secretbox.keyLength=Ie,e.secretbox.nonceLength=Pe,e.secretbox.overheadLength=Qt,e.scalarMult=function(r,o){if(pt(r,o),r.length!==Ue)throw new Error("bad n size");if(o.length!==le)throw new Error("bad p size");var i=new Uint8Array(le);return Ee(i,r,o),i},e.scalarMult.base=function(r){if(pt(r),r.length!==Ue)throw new Error("bad n size");var o=new Uint8Array(le);return Ae(o,r),o},e.scalarMult.scalarLength=Ue,e.scalarMult.groupElementLength=le,e.box=function(r,o,i,t){var f=e.box.before(i,t);return e.secretbox(r,o,f)},e.box.before=function(r,o){pt(r,o),On(r,o);var i=new Uint8Array(Le);return Se(i,r,o),i},e.box.after=e.secretbox,e.box.open=function(r,o,i,t){var f=e.box.before(i,t);return e.secretbox.open(r,o,f)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var r=new Uint8Array(xe),o=new Uint8Array(de);return Er(r,o),{publicKey:r,secretKey:o}},e.box.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==de)throw new Error("bad secret key size");var o=new Uint8Array(xe);return Ae(o,r),{publicKey:o,secretKey:new Uint8Array(r)}},e.box.publicKeyLength=xe,e.box.secretKeyLength=de,e.box.sharedKeyLength=Le,e.box.nonceLength=Pr,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(r,o){if(pt(r,o),o.length!==It)throw new Error("bad secret key size");var i=new Uint8Array(Bt+r.length);return Nr(i,r,r.length,o),i},e.sign.open=function(r,o){if(pt(r,o),o.length!==kt)throw new Error("bad public key size");var i=new Uint8Array(r.length),t=Qe(i,r,r.length,o);if(t<0)return null;for(var f=new Uint8Array(t),c=0;c<f.length;c++)f[c]=i[c];return f},e.sign.detached=function(r,o){for(var i=e.sign(r,o),t=new Uint8Array(Bt),f=0;f<t.length;f++)t[f]=i[f];return t},e.sign.detached.verify=function(r,o,i){if(pt(r,o,i),o.length!==Bt)throw new Error("bad signature size");if(i.length!==kt)throw new Error("bad public key size");var t=new Uint8Array(Bt+r.length),f=new Uint8Array(Bt+r.length),c;for(c=0;c<Bt;c++)t[c]=o[c];for(c=0;c<r.length;c++)t[c+Bt]=r[c];return Qe(f,t,t.length,i)>=0},e.sign.keyPair=function(){var r=new Uint8Array(kt),o=new Uint8Array(It);return Ze(r,o),{publicKey:r,secretKey:o}},e.sign.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==It)throw new Error("bad secret key size");for(var o=new Uint8Array(kt),i=0;i<o.length;i++)o[i]=r[32+i];return{publicKey:o,secretKey:new Uint8Array(r)}},e.sign.keyPair.fromSeed=function(r){if(pt(r),r.length!==tr)throw new Error("bad seed size");for(var o=new Uint8Array(kt),i=new Uint8Array(It),t=0;t<32;t++)i[t]=r[t];return Ze(o,i,!0),{publicKey:o,secretKey:i}},e.sign.publicKeyLength=kt,e.sign.secretKeyLength=It,e.sign.seedLength=tr,e.sign.signatureLength=Bt,e.hash=function(r){pt(r);var o=new Uint8Array(er);return Ft(o,r,r.length),o},e.hash.hashLength=er,e.verify=function(r,o){return pt(r,o),r.length===0||o.length===0||r.length!==o.length?!1:bt(r,0,o,0,r.length)===0},e.setPRNG=function(r){a=r},function(){var r=typeof self<"u"?self.crypto||self.msCrypto:null;if(r&&r.getRandomValues){var o=65536;e.setPRNG(function(i,t){var f,c=new Uint8Array(t);for(f=0;f<t;f+=o)r.getRandomValues(c.subarray(f,f+Math.min(t-f,o)));for(f=0;f<t;f++)i[f]=c[f];Rr(c)})}else typeof Br<"u"&&(r=Vr(),r&&r.randomBytes&&e.setPRNG(function(i,t){var f,c=r.randomBytes(t);for(f=0;f<t;f++)i[f]=c[f];Rr(c)}))}()})(typeof Me<"u"&&Me.exports?Me.exports:self.nacl=self.nacl||{})});var ue=Re(ir());function Lt(e){var n;return new Uint8Array(((n=e.match(/.{1,2}/g))!==null&&n!==void 0?n:[]).map(a=>parseInt(a,16))).buffer}function Kt(e){return new Uint8Array(e).reduce((n,a)=>n+a.toString(16).padStart(2,"0"),"")}var Cn=(e,n)=>{if(e.byteLength!==n.byteLength)return!1;let a=new Uint8Array(e),u=new Uint8Array(n);for(let h=0;h<a.length;h++)if(a[h]!==u[h])return!1;return!0},Fr=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},kr=(e,n,a)=>{if(a<=127)return e[n]=a,1;if(a<=255)return e[n]=129,e[n+1]=a,2;if(a<=65535)return e[n]=130,e[n+1]=a>>8,e[n+2]=a,3;if(a<=16777215)return e[n]=131,e[n+1]=a>>16,e[n+2]=a>>8,e[n+3]=a,4;throw new Error("Length too long (> 4 bytes)")},or=(e,n)=>{if(e[n]<128)return 1;if(e[n]===128)throw new Error("Invalid length 0");if(e[n]===129)return 2;if(e[n]===130)return 3;if(e[n]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Mn=(e,n)=>{let a=or(e,n);if(a===1)return e[n];if(a===2)return e[n+1];if(a===3)return(e[n+1]<<8)+e[n+2];if(a===4)return(e[n+1]<<16)+(e[n+2]<<8)+e[n+3];throw new Error("Length too long (> 4 bytes)")},Hr=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),je=Uint8Array.from([48,5,6,3,43,101,112]),hi=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function Ye(e,n){let a=2+Fr(e.byteLength+1),u=n.byteLength+a+e.byteLength,h=0,m=new Uint8Array(1+Fr(u)+u);return m[h++]=48,h+=kr(m,h,u),m.set(n,h),h+=n.byteLength,m[h++]=3,h+=kr(m,h,e.byteLength+1),m[h++]=0,m.set(new Uint8Array(e),h),m}var fr=(e,n)=>{let a=0,u=(B,C)=>{if(h[a++]!==B)throw new Error("Expected: "+C)},h=new Uint8Array(e);if(u(48,"sequence"),a+=or(h,a),!Cn(h.slice(a,a+n.byteLength),n))throw new Error("Not the expected OID.");a+=n.byteLength,u(3,"bit string");let m=Mn(h,a)-1;a+=or(h,a),u(0,"0 padding");let v=h.slice(a);if(m!==v.length)throw new Error(`DER payload mismatch: Expected length ${m} actual length ${v.length}`);return v};var gt=class{constructor(n){this.rawKey=n,this.derKey=gt.derEncode(n)}static from(n){return this.fromDer(n.toDer())}static fromRaw(n){return new gt(n)}static fromDer(n){return new gt(this.derDecode(n))}static derEncode(n){return Ye(n,je).buffer}static derDecode(n){let a=fr(n,je);if(a.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return a}toDer(){return this.derKey}toRaw(){return this.rawKey}};gt.RAW_KEY_LENGTH=32;var Ct=class extends Ht{constructor(n,a){super(),this._privateKey=a,this._publicKey=gt.from(n)}static generate(n){if(n&&n.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");let{publicKey:a,secretKey:u}=n===void 0?ue.sign.keyPair():ue.sign.keyPair.fromSeed(n);return new this(gt.fromRaw(a),u)}static fromParsedJson(n){let[a,u]=n;return new Ct(gt.fromDer(Lt(a)),Lt(u))}static fromJSON(n){let a=JSON.parse(n);if(Array.isArray(a)){if(typeof a[0]=="string"&&typeof a[1]=="string")return this.fromParsedJson([a[0],a[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(n)}`)}static fromKeyPair(n,a){return new Ct(gt.fromRaw(n),a)}static fromSecretKey(n){let a=ue.sign.keyPair.fromSecretKey(new Uint8Array(n));return Ct.fromKeyPair(a.publicKey,a.secretKey)}toJSON(){return[Kt(this._publicKey.toDer()),Kt(this._privateKey)]}getKeyPair(){return{secretKey:this._privateKey,publicKey:this._publicKey}}getPublicKey(){return this._publicKey}async sign(n){let a=new Uint8Array(n);return ue.sign.detached(a,new Uint8Array(this._privateKey)).buffer}};var he=class extends Error{constructor(n){super(n),this.message=n,Object.setPrototypeOf(this,he.prototype)}};function zr(e){if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new he("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var $t=class extends Ht{constructor(n,a,u){super(),this._keyPair=n,this._derKey=a,this._subtleCrypto=u}static async generate(n){let{extractable:a=!1,keyUsages:u=["sign","verify"],subtleCrypto:h}=n??{},m=zr(h),v=await m.generateKey({name:"ECDSA",namedCurve:"P-256"},a,u),B=await m.exportKey("spki",v.publicKey);return new this(v,B,m)}static async fromKeyPair(n,a){let u=zr(a),h=await u.exportKey("spki",n.publicKey);return new $t(n,h,u)}getKeyPair(){return this._keyPair}getPublicKey(){let n=this._derKey,a=Object.create(this._keyPair.publicKey);return a.toDer=function(){return n},a}async sign(n){let a={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(a,this._keyPair.privateKey,n)}};var te=Re(Bn());var jn=function(e,n){var a={};for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&n.indexOf(u)<0&&(a[u]=e[u]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var h=0,u=Object.getOwnPropertySymbols(e);h<u.length;h++)n.indexOf(u[h])<0&&Object.prototype.propertyIsEnumerable.call(e,u[h])&&(a[u[h]]=e[u[h]]);return a},Yn=new TextEncoder().encode("ic-request-auth-delegation"),Vn=new TextEncoder().encode(`
|
|
2
|
-
ic-request`);function ar(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return Lt(e)}var ee=class{constructor(n,a,u){this.pubkey=n,this.expiration=a,this.targets=u}toCBOR(){return te.value.map(Object.assign({pubkey:te.value.bytes(this.pubkey),expiration:te.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:te.value.array(this.targets.map(n=>te.value.bytes(n.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Kt(this.pubkey)},this.targets&&{targets:this.targets.map(n=>n.toHex())})}};async function Fn(e,n,a,u){let h=new ee(n.toDer(),BigInt(+a)*BigInt(1e6),u),m=new Uint8Array([...Yn,...new Uint8Array(rr(h))]),v=await e.sign(m);return{delegation:h,signature:v}}var Wt=class{constructor(n,a){this.delegations=n,this.publicKey=a}static async create(n,a,u=new Date(Date.now()+15*60*1e3),h={}){var m,v;let B=await Fn(n,a,u,h.targets);return new Wt([...((m=h.previous)===null||m===void 0?void 0:m.delegations)||[],B],((v=h.previous)===null||v===void 0?void 0:v.publicKey)||n.getPublicKey().toDer())}static fromJSON(n){let{publicKey:a,delegations:u}=typeof n=="string"?JSON.parse(n):n;if(!Array.isArray(u))throw new Error("Invalid delegations.");let h=u.map(m=>{let{delegation:v,signature:B}=m,{pubkey:C,expiration:P,targets:tt}=v;if(tt!==void 0&&!Array.isArray(tt))throw new Error("Invalid targets.");return{delegation:new ee(ar(C),BigInt(`0x${P}`),tt&&tt.map(rt=>{if(typeof rt!="string")throw new Error("Invalid target.");return Ke.fromHex(rt)})),signature:ar(B)}});return new this(h,ar(a))}static fromDelegations(n,a){return new this(n,a)}toJSON(){return{delegations:this.delegations.map(n=>{let{delegation:a,signature:u}=n,{targets:h}=a;return{delegation:Object.assign({expiration:a.expiration.toString(16),pubkey:Kt(a.pubkey)},h&&{targets:h.map(m=>m.toHex())}),signature:Kt(u)}}),publicKey:Kt(this.publicKey)}}},pe=class extends Ht{constructor(n,a){super(),this._inner=n,this._delegation=a}static fromDelegation(n,a){return new this(n,a)}getDelegation(){return this._delegation}getPublicKey(){return{toDer:()=>this._delegation.publicKey}}sign(n){return this._inner.sign(n)}async transformRequest(n){let{body:a}=n,u=jn(n,["body"]),h=await rr(a);return Object.assign(Object.assign({},u),{body:{content:a,sender_sig:await this.sign(new Uint8Array([...Vn,...new Uint8Array(h)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};function $r(e,n){for(let{delegation:h}of e.delegations)if(+new Date(Number(h.expiration/BigInt(1e6)))<=+Date.now())return!1;let a=[],u=n?.scope;u&&(Array.isArray(u)?a.push(...u.map(h=>typeof h=="string"?Ke.fromText(h):h)):a.push(typeof u=="string"?Ke.fromText(u):u));for(let h of a){let m=h.toText();for(let{delegation:v}of e.delegations){if(v.targets===void 0)continue;let B=!0;for(let C of v.targets)if(C.toText()===m){B=!1;break}if(B)return!1}}return!0}var kn=Re(Rn()),Hn=Re(ir());var Wr;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Wr||(Wr={}));var Jr=["mousedown","mousemove","keydown","touchstart","wheel"],ye=class{constructor(n={}){var a;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:u,idleTimeout:h=10*60*1e3}=n||{};this.callbacks=u?[u]:[],this.idleTimeout=h;let m=this._resetTimer.bind(this);window.addEventListener("load",m,!0),Jr.forEach(function(B){document.addEventListener(B,m,!0)});let v=(B,C)=>{let P;return(...tt)=>{let rt=this,ht=function(){P=void 0,B.apply(rt,tt)};clearTimeout(P),P=window.setTimeout(ht,C)}};if(n?.captureScroll){let B=v(m,(a=n?.scrollDebounce)!==null&&a!==void 0?a:100);window.addEventListener("scroll",B,!0)}m()}static create(n={}){return new this(n)}registerCallback(n){this.callbacks.push(n)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let n=this._resetTimer.bind(this);Jr.forEach(function(a){document.removeEventListener(a,n,!0)}),this.callbacks.forEach(a=>a())}_resetTimer(){let n=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(n,this.idleTimeout)}};var zn=(e,n)=>n.some(a=>e instanceof a),Gr,qr;function $n(){return Gr||(Gr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Wn(){return qr||(qr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Zr=new WeakMap,cr=new WeakMap,Xr=new WeakMap,sr=new WeakMap,xr=new WeakMap;function Jn(e){let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("success",m),e.removeEventListener("error",v)},m=()=>{a(At(e.result)),h()},v=()=>{u(e.error),h()};e.addEventListener("success",m),e.addEventListener("error",v)});return n.then(a=>{a instanceof IDBCursor&&Zr.set(a,e)}).catch(()=>{}),xr.set(n,e),n}function Gn(e){if(cr.has(e))return;let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("complete",m),e.removeEventListener("error",v),e.removeEventListener("abort",v)},m=()=>{a(),h()},v=()=>{u(e.error||new DOMException("AbortError","AbortError")),h()};e.addEventListener("complete",m),e.addEventListener("error",v),e.addEventListener("abort",v)});cr.set(e,n)}var lr={get(e,n,a){if(e instanceof IDBTransaction){if(n==="done")return cr.get(e);if(n==="objectStoreNames")return e.objectStoreNames||Xr.get(e);if(n==="store")return a.objectStoreNames[1]?void 0:a.objectStore(a.objectStoreNames[0])}return At(e[n])},set(e,n,a){return e[n]=a,!0},has(e,n){return e instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in e}};function Dr(e){lr=e(lr)}function qn(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...a){let u=e.call(Ve(this),n,...a);return Xr.set(u,n.sort?n.sort():[n]),At(u)}:Wn().includes(e)?function(...n){return e.apply(Ve(this),n),At(Zr.get(this))}:function(...n){return At(e.apply(Ve(this),n))}}function Zn(e){return typeof e=="function"?qn(e):(e instanceof IDBTransaction&&Gn(e),zn(e,$n())?new Proxy(e,lr):e)}function At(e){if(e instanceof IDBRequest)return Jn(e);if(sr.has(e))return sr.get(e);let n=Zn(e);return n!==e&&(sr.set(e,n),xr.set(n,e)),n}var Ve=e=>xr.get(e);function Ir(e,n,{blocked:a,upgrade:u,blocking:h,terminated:m}={}){let v=indexedDB.open(e,n),B=At(v);return u&&v.addEventListener("upgradeneeded",C=>{u(At(v.result),C.oldVersion,C.newVersion,At(v.transaction),C)}),a&&v.addEventListener("blocked",C=>a(C.oldVersion,C.newVersion,C)),B.then(C=>{m&&C.addEventListener("close",()=>m()),h&&C.addEventListener("versionchange",P=>h(P.oldVersion,P.newVersion,P))}).catch(()=>{}),B}var Xn=["get","getKey","getAll","getAllKeys","count"],Dn=["put","add","delete","clear"],dr=new Map;function Qr(e,n){if(!(e instanceof IDBDatabase&&!(n in e)&&typeof n=="string"))return;if(dr.get(n))return dr.get(n);let a=n.replace(/FromIndex$/,""),u=n!==a,h=Dn.includes(a);if(!(a in(u?IDBIndex:IDBObjectStore).prototype)||!(h||Xn.includes(a)))return;let m=async function(v,...B){let C=this.transaction(v,h?"readwrite":"readonly"),P=C.store;return u&&(P=P.index(B.shift())),(await Promise.all([P[a](...B),h&&C.done]))[0]};return dr.set(n,m),m}Dr(e=>({...e,get:(n,a,u)=>Qr(n,a)||e.get(n,a,u),has:(n,a)=>!!Qr(n,a)||e.has(n,a)}));var Lr="auth-client-db",tn="ic-keyval",Qn=async(e=Lr,n=tn,a)=>(Fe&&(localStorage!=null&&localStorage.getItem(_t))&&(localStorage.removeItem(_t),localStorage.removeItem(St)),await Ir(e,a,{upgrade:u=>{u.objectStoreNames,u.objectStoreNames.contains(n)&&u.clear(n),u.createObjectStore(n)}}));async function In(e,n,a){return await e.get(n,a)}async function Ln(e,n,a,u){return await e.put(n,u,a)}async function ti(e,n,a){return await e.delete(n,a)}var Jt=class{constructor(n,a){this._db=n,this._storeName=a}static async create(n){let{dbName:a=Lr,storeName:u=tn,version:h=1}=n??{},m=await Qn(a,u,h);return new Jt(m,u)}async set(n,a){return await Ln(this._db,this._storeName,n,a)}async get(n){var a;return(a=await In(this._db,this._storeName,n))!==null&&a!==void 0?a:null}async remove(n){return await ti(this._db,this._storeName,n)}};var St="identity",_t="delegation",en="iv",ei=1,Fe=typeof window<"u",ge=class{constructor(n="ic-",a){this.prefix=n,this._localStorage=a}get(n){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+n))}set(n,a){return this._getLocalStorage().setItem(this.prefix+n,a),Promise.resolve()}remove(n){return this._getLocalStorage().removeItem(this.prefix+n),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let n=typeof window>"u"&&typeof window>"u"?typeof self>"u"?void 0:self.localStorage:window.localStorage;if(!n)throw new Error("Could not find local storage.");return n}},be=class{get _db(){return new Promise(n=>{if(this.initializedDb){n(this.initializedDb);return}Jt.create({version:ei}).then(a=>{this.initializedDb=a,n(a)})})}async get(n){return await(await this._db).get(n)}async set(n,a){await(await this._db).set(n,a)}async remove(n){await(await this._db).remove(n)}};var ri="https://identity.ic0.app",ni="#authorize",ii=500,oi="UserInterrupt",ke=class{constructor(n,a,u,h,m,v,B,C){var P;this._identity=n,this._key=a,this._chain=u,this._storage=h,this.idleManager=m,this._createOptions=v,this._idpWindow=B,this._eventHandler=C;let tt=this.logout.bind(this),rt=v?.idleOptions;!rt?.onIdle&&!rt?.disableDefaultIdleCallback&&((P=this.idleManager)===null||P===void 0||P.registerCallback(()=>{tt(),location.reload()}))}static async create(n={}){var a,u;let h=(a=n.storage)!==null&&a!==void 0?a:new be,m=null;if(n.identity)m=n.identity;else{let P=await h.get(St);if(!P&&Fe)try{let tt=new ge,rt=await tt.get(_t),ht=await tt.get(St);rt&&ht&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await h.set(_t,rt),await h.set(St,ht),P=rt,await tt.remove(_t),await tt.remove(St))}catch(tt){console.error("error while attempting to recover localstorage: "+tt)}if(P)try{typeof P=="object"?m=await $t.fromKeyPair(P):typeof P=="string"&&(m=Ct.fromJSON(P))}catch{}}let v=new nr,B=null;if(m)try{let P=await h.get(_t);if(typeof P=="object"&&P!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");n.identity?v=n.identity:P&&(B=Wt.fromJSON(P),$r(B)?v=pe.fromDelegation(m,B):(await ur(h),m=null))}catch(P){console.error(P),await ur(h),m=null}let C;return!((u=n.idleOptions)===null||u===void 0)&&u.disableIdle?C=void 0:(B||n.identity)&&(C=ye.create(n.idleOptions)),m||(m=await $t.generate(),await h.set(St,m.getKeyPair())),new this(v,m,B,h,C,n)}_handleSuccess(n,a){var u,h,m;let v=n.delegations.map(P=>({delegation:new ee(P.delegation.pubkey,P.delegation.expiration,P.delegation.targets),signature:P.signature.buffer})),B=Wt.fromDelegations(v,n.userPublicKey.buffer),C=this._key;if(C){if(this._chain=B,this._identity=pe.fromDelegation(C,this._chain),(u=this._idpWindow)===null||u===void 0||u.close(),!this.idleManager){let P=(h=this._createOptions)===null||h===void 0?void 0:h.idleOptions;this.idleManager=ye.create(P),!P?.onIdle&&!P?.disableDefaultIdleCallback&&((m=this.idleManager)===null||m===void 0||m.registerCallback(()=>{this.logout(),location.reload()}))}a?.(),this._removeEventListener(),delete this._idpWindow}}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(n){var a,u,h,m;let v=BigInt(8)*BigInt(36e11),B=new URL(((a=n?.identityProvider)===null||a===void 0?void 0:a.toString())||ri);B.hash=ni,(u=this._idpWindow)===null||u===void 0||u.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(B,Object.assign({maxTimeToLive:(h=n?.maxTimeToLive)!==null&&h!==void 0?h:v},n)),window.addEventListener("message",this._eventHandler),this._idpWindow=(m=window.open(B.toString(),"idpWindow",n?.windowOpenerFeatures))!==null&&m!==void 0?m:void 0;let C=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(oi,n?.onError):setTimeout(C,ii))};C()}_getEventHandler(n,a){return async u=>{var h,m,v;if(u.origin!==n.origin){console.warn(`WARNING: expected origin '${n.origin}', got '${u.origin}' (ignoring)`);return}let B=u.data;switch(B.kind){case"authorize-ready":{let C={kind:"authorize-client",sessionPublicKey:new Uint8Array((h=this._key)===null||h===void 0?void 0:h.getPublicKey().toDer()),maxTimeToLive:a?.maxTimeToLive,derivationOrigin:(m=a?.derivationOrigin)===null||m===void 0?void 0:m.toString()};(v=this._idpWindow)===null||v===void 0||v.postMessage(C,n.origin);break}case"authorize-client-success":try{this._handleSuccess(B,a?.onSuccess),this._chain&&await this._storage.set(_t,JSON.stringify(this._chain.toJSON()))}catch(C){this._handleFailure(C.message,a?.onError)}break;case"authorize-client-failure":this._handleFailure(B.text,a?.onError);break;default:break}}}_handleFailure(n,a){var u;(u=this._idpWindow)===null||u===void 0||u.close(),a?.(n),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(n={}){if(await ur(this._storage),this._identity=new nr,this._chain=null,n.returnTo)try{window.history.pushState({},"",n.returnTo)}catch{window.location.href=n.returnTo}}};async function ur(e){await e.remove(St),await e.remove(_t),await e.remove(en)}var rn=BigInt(144e11);var re=class{callbacks=[];populate(n){this.callbacks.forEach(({callback:a})=>a(n))}subscribe(n){let a=Symbol();return this.callbacks.push({id:a,callback:n}),()=>this.callbacks=this.callbacks.filter(({id:u})=>u!==a)}};var ne=class extends re{authUser=null;constructor(){super()}static getInstance(){return ne.instance||(ne.instance=new ne),ne.instance}set(n){this.authUser=n,this.populate(n)}get(){return this.authUser}subscribe(n){let a=super.subscribe(n);return n(this.authUser),a}isLoggedIn(){return!this.authUser?.data?.principal.isAnonymous()}reset(){this.authUser=null,this.populate(this.authUser)}},Yt=ne;Be(Yt,"instance");var ie=class extends re{env;constructor(){super()}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}set(n){this.env=n,this.populate(n)}get(){return this.env}localIdentity(){return this.get()?.localIdentityCanisterId!==void 0}subscribe(n){let a=super.subscribe(n);return n(this.env),a}},dt=ie;Be(dt,"instance");var me=()=>typeof window<"u",hr=()=>{let e=dt.getInstance().get()?.satelliteId??"unknown";return dt.getInstance().localIdentity()?`http://${e}.localhost:8000`:`https://${e}.ic0.app`};var Mt=e=>{if(!me()&&e.level==="info"){console.log(e.msg);return}if(!me()&&e.level==="error"){console.error(e.msg);return}let n=new CustomEvent("ddgLog",{detail:e,bubbles:!0});document.dispatchEvent(n)};var ut=e=>e?[e]:[],He=e=>e?.[0],nn=async e=>{let n=new Blob([JSON.stringify(e)],{type:"application/json; charset=utf-8"});return new Uint8Array(await n.arrayBuffer())},pr=async e=>{let n=new Blob([e],{type:"application/json; charset=utf-8"});return JSON.parse(await n.text())};var yr=e=>e==null;var ze=({matcher:e,paginate:n,order:a})=>({matcher:ut(e),paginate:ut(yr(n)?void 0:{start_after:ut(n.startAfter),limit:ut(yr(n.limit)?void 0:BigInt(n.limit))}),order:ut(a)});var on=({IDL:e})=>{let n=e.Record({controllers:e.Vec(e.Principal)}),a=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),u=e.Record({updated_at:e.Opt(e.Nat64)}),h=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),m=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),v=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),B=e.Variant({Callback:e.Record({token:v,callback:e.Func([],[],[])})}),C=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(B),status_code:e.Nat16}),P=e.Record({token:e.Opt(v),body:e.Vec(e.Nat8)}),tt=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),rt=e.Record({batch_id:e.Nat}),ht=e.Record({desc:e.Bool}),Nt=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),bt=e.Record({order:e.Opt(ht),matcher:e.Opt(e.Text),paginate:e.Opt(Nt)}),Pt=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),vt=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),Gt=e.Record({key:Pt,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,vt)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),qt=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,Gt))}),xt=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Text}),Ut=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,h))}),Et=e.Variant({Db:e.Null,Storage:e.Null}),Vt=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),we=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:Vt,created_at:e.Nat64,write:Vt}),_e=e.Variant({Never:e.Null,Always:e.Null}),oe=e.Record({trailing_slash:_e}),Zt=e.Record({storage:oe}),fe=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),ve=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:Vt,write:Vt}),ae=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),se=e.Record({chunk_id:e.Nat});return e.Service({add_controllers:e.Func([n],[e.Vec(e.Principal)],[]),commit_asset_upload:e.Func([a],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,u],[],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(h)],["query"]),http_request:e.Func([m],[C],["query"]),http_request_streaming_callback:e.Func([v],[P],["query"]),init_asset_upload:e.Func([tt],[rt],[]),list_assets:e.Func([e.Opt(e.Text),bt],[qt],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,xt))],["query"]),list_docs:e.Func([e.Text,bt],[Ut],["query"]),list_rules:e.Func([Et],[e.Vec(e.Tuple(e.Text,we))],["query"]),remove_controllers:e.Func([n],[e.Vec(e.Principal)],[]),set_config:e.Func([Zt],[],[]),set_custom_domain:e.Func([e.Text,e.Text],[],[]),set_doc:e.Func([e.Text,e.Text,fe],[h],[]),set_rule:e.Func([Et,e.Text,ve],[],[]),upload_asset_chunk:e.Func([ae],[se],[]),version:e.Func([],[e.Text],["query"])})};var fn=async({satelliteId:e,idlFactory:n,identity:a,fetch:u,env:h="prod"})=>{let m=h==="dev"||dt.getInstance().localIdentity(),v=m?"http://127.0.0.1:8000/":"https://ic0.app",B=new Cr({identity:a,...v&&{host:v},...u&&{fetch:u}});return m&&await B.fetchRootKey(),Mr.createActor(n,{agent:B,canisterId:e})};var Tt=async({satelliteId:e,...n})=>{let{satelliteId:a}=e!==void 0?{satelliteId:e}:dt.getInstance().get()??{satelliteId:void 0};if(!a)throw new Error("No satellite principal defined.");return fn({satelliteId:a,idlFactory:on,...n})};var an=async({collection:e,key:n,satellite:a})=>{let u=await Tt(a),h=He(await u.get_doc(e,n));if(!h)return;let m=await pr(h.data);return{key:n,data:m,created_at:h.created_at,updated_at:h.updated_at}},sn=async({collection:e,doc:n,satellite:a})=>{let u=await Tt(a),{key:h,data:m,updated_at:v}=n,B=await u.set_doc(e,h,{data:await nn(m),updated_at:ut(v)});return{key:h,data:m,created_at:B.created_at,updated_at:B.updated_at}},cn=async({collection:e,doc:n,satellite:a})=>{let u=await Tt(a),{key:h,updated_at:m}=n;return u.del_doc(e,h,{updated_at:ut(m)})},ln=async({collection:e,filter:n,satellite:a})=>{let u=await Tt(a),{items:h,matches_length:m,length:v}=await u.list_docs(e,ze(n)),B=[];for(let[C,P]of h)B.push({key:C,data:await pr(P.data),created_at:P.created_at,updated_at:P.updated_at});return{items:B,length:v,matches_length:m}};var Ot=e=>{if(e!==void 0)return e;let n=$e();if(!n)throw new Error("No internet identity.");return n};var xn=async({satellite:e,...n})=>{let a=Ot(e?.identity);return an({...n,satellite:{...e,identity:a}})},dn=async({satellite:e,...n})=>{let a=Ot(e?.identity);return sn({...n,satellite:{...e,identity:a}})},Mo=async({satellite:e,...n})=>{let a=Ot(e?.identity);return cn({...n,satellite:{...e,identity:a}})},jo=async({satellite:e,...n})=>{let a=Ot(e?.identity);return ln({...n,satellite:{...e,identity:a}})};var un=async()=>{Mt({msg:"[get][start] user",level:"info"});let e=performance.now(),n=$e();if(!n)throw new Error("No internet identity.");let a=n.getPrincipal().toText(),u=await xn({collection:"#user",key:a}),h=performance.now();return Mt({msg:"[get][done] user",duration:h-e,level:"info"}),u||await fi({userId:a,principal:n.getPrincipal()})},fi=async({userId:e,principal:n})=>{let a=new Date;return dn({collection:"#user",doc:{key:e,data:{principal:n,created_at:a,updated_at:a}}})};var jt,hn=()=>ke.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}}),gr=async()=>{if(jt=jt??await hn(),!(await jt?.isAuthenticated()||!1))return;let n=await un();Yt.getInstance().set(n)},ai=async e=>new Promise(async(n,a)=>{jt=jt??await hn(),await jt.login({onSuccess:async()=>{await gr(),n()},onError:u=>a(u),maxTimeToLive:e?.maxTimeToLive??rn,...dt.getInstance().localIdentity()&&{identityProvider:`http://${dt.getInstance().get()?.localIdentityCanisterId}.localhost:8000?#authorize`},...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...e?.windowOpenerFeatures!==void 0&&{windowOpenerFeatures:e.windowOpenerFeatures}})}),si=async()=>{await jt?.logout(),jt=void 0,Yt.getInstance().reset()},$e=()=>jt?.getIdentity();var pn=async({data:e,filename:n,collection:a,headers:u,token:h,fullPath:m,encoding:v,satellite:B})=>{let C=`${n}${v?` (${v})`:""}`;Mt({msg:`[upload][start] ${C}`,level:"info"});let P=performance.now(),tt=await Tt(B),{batch_id:rt}=await tt.init_asset_upload({collection:a,full_path:m,name:n,token:ut(h),encoding_type:ut(v)}),ht=performance.now();Mt({msg:`[upload][create batch] ${C}`,duration:ht-P,level:"info"});let Nt=7e5,bt=[],Pt=me()?new Blob([await e.arrayBuffer()]):e;for(let xt=0;xt<Pt.size;xt+=Nt){let Ut=Pt.slice(xt,xt+Nt);bt.push(await ci({batchId:rt,chunk:Ut,actor:tt}))}let vt=performance.now();Mt({msg:`[upload][chunks] ${C}`,duration:vt-ht,level:"info"});let Gt=u.find(([xt,Ut])=>xt.toLowerCase()==="content-type")===void 0&&e.type!==void 0&&e.type!==""?[["Content-Type",e.type]]:void 0;await tt.commit_asset_upload({batch_id:rt,chunk_ids:bt.map(({chunk_id:xt})=>xt),headers:[...u,...Gt||[]]});let qt=performance.now();Mt({msg:`[upload][commit batch] ${C}`,duration:qt-vt,level:"info"}),Mt({msg:`[upload][done] ${C}`,duration:qt-P,level:"info"})},ci=async({batchId:e,chunk:n,actor:a})=>a.upload_asset_chunk({batch_id:e,content:new Uint8Array(await n.arrayBuffer())}),yn=async({collection:e,satellite:n,filter:a})=>{let u=await Tt(n),{items:h,matches_length:m,length:v}=await u.list_assets(ut(e),ze(a));return{items:h.map(([B,C])=>C),length:v,matches_length:m}},gn=async({collection:e,storageFile:n,satellite:a})=>{let u=await Tt(a),{fullPath:h}=n;return u.del_asset(e,h)},bn=async({collection:e,satellite:n})=>(await Tt(n)).del_assets(ut(e));var mn=e=>btoa([...e].map(n=>String.fromCharCode(n)).join(""));var br=e=>encodeURI(e.toLowerCase().replace(/\s/g,"-"));var cf=async e=>wn(e),lf=async e=>wn({filename:e.data.name,...e}),wn=async({filename:e,data:n,collection:a,headers:u=[],fullPath:h,token:m,satellite:v,encoding:B})=>{let C=Ot(v?.identity),P=br(e),tt=h||`/${P}`;return await pn({data:n,filename:br(P),collection:a,token:m,headers:u,fullPath:tt,encoding:B,satellite:{...v,identity:C}}),{downloadUrl:`${hr()}${tt}${m!==void 0?`?token=${m}`:""}`,fullPath:tt,name:P}},xf=async({collection:e,satellite:n,filter:a})=>{let{items:u,...h}=await yn({collection:e,satellite:{...n,identity:Ot(n?.identity)},filter:a??{}}),m=hr();return{assets:u.map(({key:{full_path:v,token:B,name:C},headers:P,encodings:tt})=>{let rt=He(B);return{fullPath:v,name:C,downloadUrl:`${m}${v}${rt!==void 0?`?token=${rt}`:""}`,token:rt,headers:P,encodings:tt.reduce((ht,[Nt,{modified:bt,sha256:Pt,total_length:vt}])=>({...ht,[Nt]:{modified:bt,sha256:mn(Pt),total_length:vt}}),{})}}),...h}},df=async({storageFile:e,collection:n,satellite:a})=>gn({collection:n,storageFile:e,satellite:{...a,identity:Ot(a?.identity)}}),uf=async({collection:e,satellite:n})=>bn({collection:e,satellite:{...n,identity:Ot(n?.identity)}});var bf=async e=>{dt.getInstance().set(e),await gr()},mf=e=>Yt.getInstance().subscribe(e);export{mf as authSubscribe,Mo as delDoc,df as deleteAsset,uf as deleteAssets,xn as getDoc,bf as initDapp,xf as listAssets,jo as listDocs,dn as setDoc,ai as signIn,si as signOut,cf as uploadBlob,lf as uploadFile};
|
|
1
|
+
import{a as Ur,b as On,c as Rr,d as Nn,e as Oe,f as Pn,g as Ne,h as Pe,i as Un,j as tr,k as Vt,l as er,m as Rn,p as Br,q as Kr}from"./chunk-VT367M3F.js";var Cr={};Nn(Cr,{default:()=>Bn});var Bn,Mr=On(()=>{Bn={}});var jr=Rr((ci,Ue)=>{var Ft=(Mr(),Pn(Cr));if(Ft&&Ft.default){Ue.exports=Ft.default;for(let e in Ft)Ue.exports[e]=Ft[e]}else Ft&&(Ue.exports=Ft)});var rr=Rr((li,Re)=>{(function(e){"use strict";var n=function(r){var o,i=new Float64Array(16);if(r)for(o=0;o<r.length;o++)i[o]=r[o];return i},a=function(){throw new Error("no PRNG")},u=new Uint8Array(16),h=new Uint8Array(32);h[0]=9;var m=n(),v=n([1]),B=n([56129,1]),M=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),P=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),tt=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),rt=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),ht=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Nt(r,o,i,t){r[o]=i>>24&255,r[o+1]=i>>16&255,r[o+2]=i>>8&255,r[o+3]=i&255,r[o+4]=t>>24&255,r[o+5]=t>>16&255,r[o+6]=t>>8&255,r[o+7]=t&255}function bt(r,o,i,t,f){var c,l=0;for(c=0;c<f;c++)l|=r[o+c]^i[t+c];return(1&l-1>>>8)-1}function xt(r,o,i,t){return bt(r,o,i,t,16)}function vt(r,o,i,t){return bt(r,o,i,t,32)}function ke(r,o,i,t){for(var f=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,c=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,l=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,y=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,_=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,R=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,A=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,T=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,j=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,Y=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,z=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,H=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,V=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,k=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,F=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,O=f,K=c,S=l,N=y,U=_,E=R,x=A,d=Q,b=T,p=j,g=Y,w=z,C=H,W=V,G=k,J=F,s,q=0;q<20;q+=2)s=O+C|0,U^=s<<7|s>>>32-7,s=U+O|0,b^=s<<9|s>>>32-9,s=b+U|0,C^=s<<13|s>>>32-13,s=C+b|0,O^=s<<18|s>>>32-18,s=E+K|0,p^=s<<7|s>>>32-7,s=p+E|0,W^=s<<9|s>>>32-9,s=W+p|0,K^=s<<13|s>>>32-13,s=K+W|0,E^=s<<18|s>>>32-18,s=g+x|0,G^=s<<7|s>>>32-7,s=G+g|0,S^=s<<9|s>>>32-9,s=S+G|0,x^=s<<13|s>>>32-13,s=x+S|0,g^=s<<18|s>>>32-18,s=J+w|0,N^=s<<7|s>>>32-7,s=N+J|0,d^=s<<9|s>>>32-9,s=d+N|0,w^=s<<13|s>>>32-13,s=w+d|0,J^=s<<18|s>>>32-18,s=O+N|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,N^=s<<13|s>>>32-13,s=N+S|0,O^=s<<18|s>>>32-18,s=E+U|0,x^=s<<7|s>>>32-7,s=x+E|0,d^=s<<9|s>>>32-9,s=d+x|0,U^=s<<13|s>>>32-13,s=U+d|0,E^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,b^=s<<9|s>>>32-9,s=b+w|0,p^=s<<13|s>>>32-13,s=p+b|0,g^=s<<18|s>>>32-18,s=J+G|0,C^=s<<7|s>>>32-7,s=C+J|0,W^=s<<9|s>>>32-9,s=W+C|0,G^=s<<13|s>>>32-13,s=G+W|0,J^=s<<18|s>>>32-18;O=O+f|0,K=K+c|0,S=S+l|0,N=N+y|0,U=U+_|0,E=E+R|0,x=x+A|0,d=d+Q|0,b=b+T|0,p=p+j|0,g=g+Y|0,w=w+z|0,C=C+H|0,W=W+V|0,G=G+k|0,J=J+F|0,r[0]=O>>>0&255,r[1]=O>>>8&255,r[2]=O>>>16&255,r[3]=O>>>24&255,r[4]=K>>>0&255,r[5]=K>>>8&255,r[6]=K>>>16&255,r[7]=K>>>24&255,r[8]=S>>>0&255,r[9]=S>>>8&255,r[10]=S>>>16&255,r[11]=S>>>24&255,r[12]=N>>>0&255,r[13]=N>>>8&255,r[14]=N>>>16&255,r[15]=N>>>24&255,r[16]=U>>>0&255,r[17]=U>>>8&255,r[18]=U>>>16&255,r[19]=U>>>24&255,r[20]=E>>>0&255,r[21]=E>>>8&255,r[22]=E>>>16&255,r[23]=E>>>24&255,r[24]=x>>>0&255,r[25]=x>>>8&255,r[26]=x>>>16&255,r[27]=x>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255,r[32]=b>>>0&255,r[33]=b>>>8&255,r[34]=b>>>16&255,r[35]=b>>>24&255,r[36]=p>>>0&255,r[37]=p>>>8&255,r[38]=p>>>16&255,r[39]=p>>>24&255,r[40]=g>>>0&255,r[41]=g>>>8&255,r[42]=g>>>16&255,r[43]=g>>>24&255,r[44]=w>>>0&255,r[45]=w>>>8&255,r[46]=w>>>16&255,r[47]=w>>>24&255,r[48]=C>>>0&255,r[49]=C>>>8&255,r[50]=C>>>16&255,r[51]=C>>>24&255,r[52]=W>>>0&255,r[53]=W>>>8&255,r[54]=W>>>16&255,r[55]=W>>>24&255,r[56]=G>>>0&255,r[57]=G>>>8&255,r[58]=G>>>16&255,r[59]=G>>>24&255,r[60]=J>>>0&255,r[61]=J>>>8&255,r[62]=J>>>16&255,r[63]=J>>>24&255}function He(r,o,i,t){for(var f=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,c=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,l=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,y=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,_=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,R=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,A=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,T=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,j=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,Y=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,z=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,H=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,V=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,k=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,F=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,O=f,K=c,S=l,N=y,U=_,E=R,x=A,d=Q,b=T,p=j,g=Y,w=z,C=H,W=V,G=k,J=F,s,q=0;q<20;q+=2)s=O+C|0,U^=s<<7|s>>>32-7,s=U+O|0,b^=s<<9|s>>>32-9,s=b+U|0,C^=s<<13|s>>>32-13,s=C+b|0,O^=s<<18|s>>>32-18,s=E+K|0,p^=s<<7|s>>>32-7,s=p+E|0,W^=s<<9|s>>>32-9,s=W+p|0,K^=s<<13|s>>>32-13,s=K+W|0,E^=s<<18|s>>>32-18,s=g+x|0,G^=s<<7|s>>>32-7,s=G+g|0,S^=s<<9|s>>>32-9,s=S+G|0,x^=s<<13|s>>>32-13,s=x+S|0,g^=s<<18|s>>>32-18,s=J+w|0,N^=s<<7|s>>>32-7,s=N+J|0,d^=s<<9|s>>>32-9,s=d+N|0,w^=s<<13|s>>>32-13,s=w+d|0,J^=s<<18|s>>>32-18,s=O+N|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,N^=s<<13|s>>>32-13,s=N+S|0,O^=s<<18|s>>>32-18,s=E+U|0,x^=s<<7|s>>>32-7,s=x+E|0,d^=s<<9|s>>>32-9,s=d+x|0,U^=s<<13|s>>>32-13,s=U+d|0,E^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,b^=s<<9|s>>>32-9,s=b+w|0,p^=s<<13|s>>>32-13,s=p+b|0,g^=s<<18|s>>>32-18,s=J+G|0,C^=s<<7|s>>>32-7,s=C+J|0,W^=s<<9|s>>>32-9,s=W+C|0,G^=s<<13|s>>>32-13,s=G+W|0,J^=s<<18|s>>>32-18;r[0]=O>>>0&255,r[1]=O>>>8&255,r[2]=O>>>16&255,r[3]=O>>>24&255,r[4]=E>>>0&255,r[5]=E>>>8&255,r[6]=E>>>16&255,r[7]=E>>>24&255,r[8]=g>>>0&255,r[9]=g>>>8&255,r[10]=g>>>16&255,r[11]=g>>>24&255,r[12]=J>>>0&255,r[13]=J>>>8&255,r[14]=J>>>16&255,r[15]=J>>>24&255,r[16]=x>>>0&255,r[17]=x>>>8&255,r[18]=x>>>16&255,r[19]=x>>>24&255,r[20]=d>>>0&255,r[21]=d>>>8&255,r[22]=d>>>16&255,r[23]=d>>>24&255,r[24]=b>>>0&255,r[25]=b>>>8&255,r[26]=b>>>16&255,r[27]=b>>>24&255,r[28]=p>>>0&255,r[29]=p>>>8&255,r[30]=p>>>16&255,r[31]=p>>>24&255}function Wt(r,o,i,t){ke(r,o,i,t)}function Jt(r,o,i,t){He(r,o,i,t)}var Et=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Mt(r,o,i,t,f,c,l){var y=new Uint8Array(16),_=new Uint8Array(64),R,A;for(A=0;A<16;A++)y[A]=0;for(A=0;A<8;A++)y[A]=c[A];for(;f>=64;){for(Wt(_,y,l,Et),A=0;A<64;A++)r[o+A]=i[t+A]^_[A];for(R=1,A=8;A<16;A++)R=R+(y[A]&255)|0,y[A]=R&255,R>>>=8;f-=64,o+=64,t+=64}if(f>0)for(Wt(_,y,l,Et),A=0;A<f;A++)r[o+A]=i[t+A]^_[A];return 0}function ye(r,o,i,t,f){var c=new Uint8Array(16),l=new Uint8Array(64),y,_;for(_=0;_<16;_++)c[_]=0;for(_=0;_<8;_++)c[_]=t[_];for(;i>=64;){for(Wt(l,c,f,Et),_=0;_<64;_++)r[o+_]=l[_];for(y=1,_=8;_<16;_++)y=y+(c[_]&255)|0,c[_]=y&255,y>>>=8;i-=64,o+=64}if(i>0)for(Wt(l,c,f,Et),_=0;_<i;_++)r[o+_]=l[_];return 0}function ge(r,o,i,t,f){var c=new Uint8Array(32);Jt(c,t,f,Et);for(var l=new Uint8Array(8),y=0;y<8;y++)l[y]=t[y+16];return ye(r,o,i,l,c)}function re(r,o,i,t,f,c,l){var y=new Uint8Array(32);Jt(y,c,l,Et);for(var _=new Uint8Array(8),R=0;R<8;R++)_[R]=c[R+16];return Mt(r,o,i,t,f,_,y)}var Gt=function(r){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,t,f,c,l,y,_;o=r[0]&255|(r[1]&255)<<8,this.r[0]=o&8191,i=r[2]&255|(r[3]&255)<<8,this.r[1]=(o>>>13|i<<3)&8191,t=r[4]&255|(r[5]&255)<<8,this.r[2]=(i>>>10|t<<6)&7939,f=r[6]&255|(r[7]&255)<<8,this.r[3]=(t>>>7|f<<9)&8191,c=r[8]&255|(r[9]&255)<<8,this.r[4]=(f>>>4|c<<12)&255,this.r[5]=c>>>1&8190,l=r[10]&255|(r[11]&255)<<8,this.r[6]=(c>>>14|l<<2)&8191,y=r[12]&255|(r[13]&255)<<8,this.r[7]=(l>>>11|y<<5)&8065,_=r[14]&255|(r[15]&255)<<8,this.r[8]=(y>>>8|_<<8)&8191,this.r[9]=_>>>5&127,this.pad[0]=r[16]&255|(r[17]&255)<<8,this.pad[1]=r[18]&255|(r[19]&255)<<8,this.pad[2]=r[20]&255|(r[21]&255)<<8,this.pad[3]=r[22]&255|(r[23]&255)<<8,this.pad[4]=r[24]&255|(r[25]&255)<<8,this.pad[5]=r[26]&255|(r[27]&255)<<8,this.pad[6]=r[28]&255|(r[29]&255)<<8,this.pad[7]=r[30]&255|(r[31]&255)<<8};Gt.prototype.blocks=function(r,o,i){for(var t=this.fin?0:2048,f,c,l,y,_,R,A,Q,T,j,Y,z,H,V,k,F,O,K,S,N=this.h[0],U=this.h[1],E=this.h[2],x=this.h[3],d=this.h[4],b=this.h[5],p=this.h[6],g=this.h[7],w=this.h[8],C=this.h[9],W=this.r[0],G=this.r[1],J=this.r[2],s=this.r[3],q=this.r[4],I=this.r[5],L=this.r[6],$=this.r[7],X=this.r[8],D=this.r[9];i>=16;)f=r[o+0]&255|(r[o+1]&255)<<8,N+=f&8191,c=r[o+2]&255|(r[o+3]&255)<<8,U+=(f>>>13|c<<3)&8191,l=r[o+4]&255|(r[o+5]&255)<<8,E+=(c>>>10|l<<6)&8191,y=r[o+6]&255|(r[o+7]&255)<<8,x+=(l>>>7|y<<9)&8191,_=r[o+8]&255|(r[o+9]&255)<<8,d+=(y>>>4|_<<12)&8191,b+=_>>>1&8191,R=r[o+10]&255|(r[o+11]&255)<<8,p+=(_>>>14|R<<2)&8191,A=r[o+12]&255|(r[o+13]&255)<<8,g+=(R>>>11|A<<5)&8191,Q=r[o+14]&255|(r[o+15]&255)<<8,w+=(A>>>8|Q<<8)&8191,C+=Q>>>5|t,T=0,j=T,j+=N*W,j+=U*(5*D),j+=E*(5*X),j+=x*(5*$),j+=d*(5*L),T=j>>>13,j&=8191,j+=b*(5*I),j+=p*(5*q),j+=g*(5*s),j+=w*(5*J),j+=C*(5*G),T+=j>>>13,j&=8191,Y=T,Y+=N*G,Y+=U*W,Y+=E*(5*D),Y+=x*(5*X),Y+=d*(5*$),T=Y>>>13,Y&=8191,Y+=b*(5*L),Y+=p*(5*I),Y+=g*(5*q),Y+=w*(5*s),Y+=C*(5*J),T+=Y>>>13,Y&=8191,z=T,z+=N*J,z+=U*G,z+=E*W,z+=x*(5*D),z+=d*(5*X),T=z>>>13,z&=8191,z+=b*(5*$),z+=p*(5*L),z+=g*(5*I),z+=w*(5*q),z+=C*(5*s),T+=z>>>13,z&=8191,H=T,H+=N*s,H+=U*J,H+=E*G,H+=x*W,H+=d*(5*D),T=H>>>13,H&=8191,H+=b*(5*X),H+=p*(5*$),H+=g*(5*L),H+=w*(5*I),H+=C*(5*q),T+=H>>>13,H&=8191,V=T,V+=N*q,V+=U*s,V+=E*J,V+=x*G,V+=d*W,T=V>>>13,V&=8191,V+=b*(5*D),V+=p*(5*X),V+=g*(5*$),V+=w*(5*L),V+=C*(5*I),T+=V>>>13,V&=8191,k=T,k+=N*I,k+=U*q,k+=E*s,k+=x*J,k+=d*G,T=k>>>13,k&=8191,k+=b*W,k+=p*(5*D),k+=g*(5*X),k+=w*(5*$),k+=C*(5*L),T+=k>>>13,k&=8191,F=T,F+=N*L,F+=U*I,F+=E*q,F+=x*s,F+=d*J,T=F>>>13,F&=8191,F+=b*G,F+=p*W,F+=g*(5*D),F+=w*(5*X),F+=C*(5*$),T+=F>>>13,F&=8191,O=T,O+=N*$,O+=U*L,O+=E*I,O+=x*q,O+=d*s,T=O>>>13,O&=8191,O+=b*J,O+=p*G,O+=g*W,O+=w*(5*D),O+=C*(5*X),T+=O>>>13,O&=8191,K=T,K+=N*X,K+=U*$,K+=E*L,K+=x*I,K+=d*q,T=K>>>13,K&=8191,K+=b*s,K+=p*J,K+=g*G,K+=w*W,K+=C*(5*D),T+=K>>>13,K&=8191,S=T,S+=N*D,S+=U*X,S+=E*$,S+=x*L,S+=d*I,T=S>>>13,S&=8191,S+=b*q,S+=p*s,S+=g*J,S+=w*G,S+=C*W,T+=S>>>13,S&=8191,T=(T<<2)+T|0,T=T+j|0,j=T&8191,T=T>>>13,Y+=T,N=j,U=Y,E=z,x=H,d=V,b=k,p=F,g=O,w=K,C=S,o+=16,i-=16;this.h[0]=N,this.h[1]=U,this.h[2]=E,this.h[3]=x,this.h[4]=d,this.h[5]=b,this.h[6]=p,this.h[7]=g,this.h[8]=w,this.h[9]=C},Gt.prototype.finish=function(r,o){var i=new Uint16Array(10),t,f,c,l;if(this.leftover){for(l=this.leftover,this.buffer[l++]=1;l<16;l++)this.buffer[l]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(t=this.h[1]>>>13,this.h[1]&=8191,l=2;l<10;l++)this.h[l]+=t,t=this.h[l]>>>13,this.h[l]&=8191;for(this.h[0]+=t*5,t=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=t,t=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=t,i[0]=this.h[0]+5,t=i[0]>>>13,i[0]&=8191,l=1;l<10;l++)i[l]=this.h[l]+t,t=i[l]>>>13,i[l]&=8191;for(i[9]-=1<<13,f=(t^1)-1,l=0;l<10;l++)i[l]&=f;for(f=~f,l=0;l<10;l++)this.h[l]=this.h[l]&f|i[l];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,c=this.h[0]+this.pad[0],this.h[0]=c&65535,l=1;l<8;l++)c=(this.h[l]+this.pad[l]|0)+(c>>>16)|0,this.h[l]=c&65535;r[o+0]=this.h[0]>>>0&255,r[o+1]=this.h[0]>>>8&255,r[o+2]=this.h[1]>>>0&255,r[o+3]=this.h[1]>>>8&255,r[o+4]=this.h[2]>>>0&255,r[o+5]=this.h[2]>>>8&255,r[o+6]=this.h[3]>>>0&255,r[o+7]=this.h[3]>>>8&255,r[o+8]=this.h[4]>>>0&255,r[o+9]=this.h[4]>>>8&255,r[o+10]=this.h[5]>>>0&255,r[o+11]=this.h[5]>>>8&255,r[o+12]=this.h[6]>>>0&255,r[o+13]=this.h[6]>>>8&255,r[o+14]=this.h[7]>>>0&255,r[o+15]=this.h[7]>>>8&255},Gt.prototype.update=function(r,o,i){var t,f;if(this.leftover){for(f=16-this.leftover,f>i&&(f=i),t=0;t<f;t++)this.buffer[this.leftover+t]=r[o+t];if(i-=f,o+=f,this.leftover+=f,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(i>=16&&(f=i-i%16,this.blocks(r,o,f),o+=f,i-=f),i){for(t=0;t<i;t++)this.buffer[this.leftover+t]=r[o+t];this.leftover+=i}};function ne(r,o,i,t,f,c){var l=new Gt(c);return l.update(i,t,f),l.finish(r,o),0}function be(r,o,i,t,f,c){var l=new Uint8Array(16);return ne(l,0,i,t,f,c),xt(r,o,l,0)}function ie(r,o,i,t,f){var c;if(i<32)return-1;for(re(r,0,o,0,i,t,f),ne(r,16,r,32,i-32,r),c=0;c<16;c++)r[c]=0;return 0}function oe(r,o,i,t,f){var c,l=new Uint8Array(32);if(i<32||(ge(l,0,32,t,f),be(o,16,o,32,i-32,l)!==0))return-1;for(re(r,0,o,0,i,t,f),c=0;c<32;c++)r[c]=0;return 0}function Pt(r,o){var i;for(i=0;i<16;i++)r[i]=o[i]|0}function ze(r){var o,i,t=1;for(o=0;o<16;o++)i=r[o]+t+65535,t=Math.floor(i/65536),r[o]=i-t*65536;r[0]+=t-1+37*(t-1)}function $t(r,o,i){for(var t,f=~(i-1),c=0;c<16;c++)t=f&(r[c]^o[c]),r[c]^=t,o[c]^=t}function qt(r,o){var i,t,f,c=n(),l=n();for(i=0;i<16;i++)l[i]=o[i];for(ze(l),ze(l),ze(l),t=0;t<2;t++){for(c[0]=l[0]-65517,i=1;i<15;i++)c[i]=l[i]-65535-(c[i-1]>>16&1),c[i-1]&=65535;c[15]=l[15]-32767-(c[14]>>16&1),f=c[15]>>16&1,c[14]&=65535,$t(l,c,1-f)}for(i=0;i<16;i++)r[2*i]=l[i]&255,r[2*i+1]=l[i]>>8}function gr(r,o){var i=new Uint8Array(32),t=new Uint8Array(32);return qt(i,r),qt(t,o),vt(i,0,t,0)}function br(r){var o=new Uint8Array(32);return qt(o,r),o[0]&1}function We(r,o){var i;for(i=0;i<16;i++)r[i]=o[2*i]+(o[2*i+1]<<8);r[15]&=32767}function mt(r,o,i){for(var t=0;t<16;t++)r[t]=o[t]+i[t]}function wt(r,o,i){for(var t=0;t<16;t++)r[t]=o[t]-i[t]}function Z(r,o,i){var t,f,c=0,l=0,y=0,_=0,R=0,A=0,Q=0,T=0,j=0,Y=0,z=0,H=0,V=0,k=0,F=0,O=0,K=0,S=0,N=0,U=0,E=0,x=0,d=0,b=0,p=0,g=0,w=0,C=0,W=0,G=0,J=0,s=i[0],q=i[1],I=i[2],L=i[3],$=i[4],X=i[5],D=i[6],ft=i[7],et=i[8],nt=i[9],it=i[10],ot=i[11],at=i[12],st=i[13],ct=i[14],lt=i[15];t=o[0],c+=t*s,l+=t*q,y+=t*I,_+=t*L,R+=t*$,A+=t*X,Q+=t*D,T+=t*ft,j+=t*et,Y+=t*nt,z+=t*it,H+=t*ot,V+=t*at,k+=t*st,F+=t*ct,O+=t*lt,t=o[1],l+=t*s,y+=t*q,_+=t*I,R+=t*L,A+=t*$,Q+=t*X,T+=t*D,j+=t*ft,Y+=t*et,z+=t*nt,H+=t*it,V+=t*ot,k+=t*at,F+=t*st,O+=t*ct,K+=t*lt,t=o[2],y+=t*s,_+=t*q,R+=t*I,A+=t*L,Q+=t*$,T+=t*X,j+=t*D,Y+=t*ft,z+=t*et,H+=t*nt,V+=t*it,k+=t*ot,F+=t*at,O+=t*st,K+=t*ct,S+=t*lt,t=o[3],_+=t*s,R+=t*q,A+=t*I,Q+=t*L,T+=t*$,j+=t*X,Y+=t*D,z+=t*ft,H+=t*et,V+=t*nt,k+=t*it,F+=t*ot,O+=t*at,K+=t*st,S+=t*ct,N+=t*lt,t=o[4],R+=t*s,A+=t*q,Q+=t*I,T+=t*L,j+=t*$,Y+=t*X,z+=t*D,H+=t*ft,V+=t*et,k+=t*nt,F+=t*it,O+=t*ot,K+=t*at,S+=t*st,N+=t*ct,U+=t*lt,t=o[5],A+=t*s,Q+=t*q,T+=t*I,j+=t*L,Y+=t*$,z+=t*X,H+=t*D,V+=t*ft,k+=t*et,F+=t*nt,O+=t*it,K+=t*ot,S+=t*at,N+=t*st,U+=t*ct,E+=t*lt,t=o[6],Q+=t*s,T+=t*q,j+=t*I,Y+=t*L,z+=t*$,H+=t*X,V+=t*D,k+=t*ft,F+=t*et,O+=t*nt,K+=t*it,S+=t*ot,N+=t*at,U+=t*st,E+=t*ct,x+=t*lt,t=o[7],T+=t*s,j+=t*q,Y+=t*I,z+=t*L,H+=t*$,V+=t*X,k+=t*D,F+=t*ft,O+=t*et,K+=t*nt,S+=t*it,N+=t*ot,U+=t*at,E+=t*st,x+=t*ct,d+=t*lt,t=o[8],j+=t*s,Y+=t*q,z+=t*I,H+=t*L,V+=t*$,k+=t*X,F+=t*D,O+=t*ft,K+=t*et,S+=t*nt,N+=t*it,U+=t*ot,E+=t*at,x+=t*st,d+=t*ct,b+=t*lt,t=o[9],Y+=t*s,z+=t*q,H+=t*I,V+=t*L,k+=t*$,F+=t*X,O+=t*D,K+=t*ft,S+=t*et,N+=t*nt,U+=t*it,E+=t*ot,x+=t*at,d+=t*st,b+=t*ct,p+=t*lt,t=o[10],z+=t*s,H+=t*q,V+=t*I,k+=t*L,F+=t*$,O+=t*X,K+=t*D,S+=t*ft,N+=t*et,U+=t*nt,E+=t*it,x+=t*ot,d+=t*at,b+=t*st,p+=t*ct,g+=t*lt,t=o[11],H+=t*s,V+=t*q,k+=t*I,F+=t*L,O+=t*$,K+=t*X,S+=t*D,N+=t*ft,U+=t*et,E+=t*nt,x+=t*it,d+=t*ot,b+=t*at,p+=t*st,g+=t*ct,w+=t*lt,t=o[12],V+=t*s,k+=t*q,F+=t*I,O+=t*L,K+=t*$,S+=t*X,N+=t*D,U+=t*ft,E+=t*et,x+=t*nt,d+=t*it,b+=t*ot,p+=t*at,g+=t*st,w+=t*ct,C+=t*lt,t=o[13],k+=t*s,F+=t*q,O+=t*I,K+=t*L,S+=t*$,N+=t*X,U+=t*D,E+=t*ft,x+=t*et,d+=t*nt,b+=t*it,p+=t*ot,g+=t*at,w+=t*st,C+=t*ct,W+=t*lt,t=o[14],F+=t*s,O+=t*q,K+=t*I,S+=t*L,N+=t*$,U+=t*X,E+=t*D,x+=t*ft,d+=t*et,b+=t*nt,p+=t*it,g+=t*ot,w+=t*at,C+=t*st,W+=t*ct,G+=t*lt,t=o[15],O+=t*s,K+=t*q,S+=t*I,N+=t*L,U+=t*$,E+=t*X,x+=t*D,d+=t*ft,b+=t*et,p+=t*nt,g+=t*it,w+=t*ot,C+=t*at,W+=t*st,G+=t*ct,J+=t*lt,c+=38*K,l+=38*S,y+=38*N,_+=38*U,R+=38*E,A+=38*x,Q+=38*d,T+=38*b,j+=38*p,Y+=38*g,z+=38*w,H+=38*C,V+=38*W,k+=38*G,F+=38*J,f=1,t=c+f+65535,f=Math.floor(t/65536),c=t-f*65536,t=l+f+65535,f=Math.floor(t/65536),l=t-f*65536,t=y+f+65535,f=Math.floor(t/65536),y=t-f*65536,t=_+f+65535,f=Math.floor(t/65536),_=t-f*65536,t=R+f+65535,f=Math.floor(t/65536),R=t-f*65536,t=A+f+65535,f=Math.floor(t/65536),A=t-f*65536,t=Q+f+65535,f=Math.floor(t/65536),Q=t-f*65536,t=T+f+65535,f=Math.floor(t/65536),T=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=t-f*65536,t=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=z+f+65535,f=Math.floor(t/65536),z=t-f*65536,t=H+f+65535,f=Math.floor(t/65536),H=t-f*65536,t=V+f+65535,f=Math.floor(t/65536),V=t-f*65536,t=k+f+65535,f=Math.floor(t/65536),k=t-f*65536,t=F+f+65535,f=Math.floor(t/65536),F=t-f*65536,t=O+f+65535,f=Math.floor(t/65536),O=t-f*65536,c+=f-1+37*(f-1),f=1,t=c+f+65535,f=Math.floor(t/65536),c=t-f*65536,t=l+f+65535,f=Math.floor(t/65536),l=t-f*65536,t=y+f+65535,f=Math.floor(t/65536),y=t-f*65536,t=_+f+65535,f=Math.floor(t/65536),_=t-f*65536,t=R+f+65535,f=Math.floor(t/65536),R=t-f*65536,t=A+f+65535,f=Math.floor(t/65536),A=t-f*65536,t=Q+f+65535,f=Math.floor(t/65536),Q=t-f*65536,t=T+f+65535,f=Math.floor(t/65536),T=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=t-f*65536,t=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=z+f+65535,f=Math.floor(t/65536),z=t-f*65536,t=H+f+65535,f=Math.floor(t/65536),H=t-f*65536,t=V+f+65535,f=Math.floor(t/65536),V=t-f*65536,t=k+f+65535,f=Math.floor(t/65536),k=t-f*65536,t=F+f+65535,f=Math.floor(t/65536),F=t-f*65536,t=O+f+65535,f=Math.floor(t/65536),O=t-f*65536,c+=f-1+37*(f-1),r[0]=c,r[1]=l,r[2]=y,r[3]=_,r[4]=R,r[5]=A,r[6]=Q,r[7]=T,r[8]=j,r[9]=Y,r[10]=z,r[11]=H,r[12]=V,r[13]=k,r[14]=F,r[15]=O}function yt(r,o){Z(r,o,o)}function mr(r,o){var i=n(),t;for(t=0;t<16;t++)i[t]=o[t];for(t=253;t>=0;t--)yt(i,i),t!==2&&t!==4&&Z(i,i,o);for(t=0;t<16;t++)r[t]=i[t]}function wr(r,o){var i=n(),t;for(t=0;t<16;t++)i[t]=o[t];for(t=250;t>=0;t--)yt(i,i),t!==1&&Z(i,i,o);for(t=0;t<16;t++)r[t]=i[t]}function me(r,o,i){var t=new Uint8Array(32),f=new Float64Array(80),c,l,y=n(),_=n(),R=n(),A=n(),Q=n(),T=n();for(l=0;l<31;l++)t[l]=o[l];for(t[31]=o[31]&127|64,t[0]&=248,We(f,i),l=0;l<16;l++)_[l]=f[l],A[l]=y[l]=R[l]=0;for(y[0]=A[0]=1,l=254;l>=0;--l)c=t[l>>>3]>>>(l&7)&1,$t(y,_,c),$t(R,A,c),mt(Q,y,R),wt(y,y,R),mt(R,_,A),wt(_,_,A),yt(A,Q),yt(T,y),Z(y,R,y),Z(R,_,Q),mt(Q,y,R),wt(y,y,R),yt(_,y),wt(R,A,T),Z(y,R,B),mt(y,y,A),Z(R,R,y),Z(y,A,T),Z(A,_,f),yt(_,Q),$t(y,_,c),$t(R,A,c);for(l=0;l<16;l++)f[l+16]=y[l],f[l+32]=R[l],f[l+48]=_[l],f[l+64]=A[l];var j=f.subarray(32),Y=f.subarray(16);return mr(j,j),Z(Y,Y,j),qt(r,Y),0}function we(r,o){return me(r,o,h)}function _r(r,o){return a(o,32),we(r,o)}function _e(r,o,i){var t=new Uint8Array(32);return me(t,i,o),Jt(r,u,t,Et)}var vr=ie,wn=oe;function _n(r,o,i,t,f,c){var l=new Uint8Array(32);return _e(l,f,c),vr(r,o,i,t,l)}function vn(r,o,i,t,f,c){var l=new Uint8Array(32);return _e(l,f,c),wn(r,o,i,t,l)}var Er=[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 Ar(r,o,i,t){for(var f=new Int32Array(16),c=new Int32Array(16),l,y,_,R,A,Q,T,j,Y,z,H,V,k,F,O,K,S,N,U,E,x,d,b,p,g,w,C=r[0],W=r[1],G=r[2],J=r[3],s=r[4],q=r[5],I=r[6],L=r[7],$=o[0],X=o[1],D=o[2],ft=o[3],et=o[4],nt=o[5],it=o[6],ot=o[7],at=0;t>=128;){for(U=0;U<16;U++)E=8*U+at,f[U]=i[E+0]<<24|i[E+1]<<16|i[E+2]<<8|i[E+3],c[U]=i[E+4]<<24|i[E+5]<<16|i[E+6]<<8|i[E+7];for(U=0;U<80;U++)if(l=C,y=W,_=G,R=J,A=s,Q=q,T=I,j=L,Y=$,z=X,H=D,V=ft,k=et,F=nt,O=it,K=ot,x=L,d=ot,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=(s>>>14|et<<32-14)^(s>>>18|et<<32-18)^(et>>>41-32|s<<32-(41-32)),d=(et>>>14|s<<32-14)^(et>>>18|s<<32-18)^(s>>>41-32|et<<32-(41-32)),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=s&q^~s&I,d=et&nt^~et&it,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=Er[U*2],d=Er[U*2+1],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=f[U%16],d=c[U%16],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,S=g&65535|w<<16,N=b&65535|p<<16,x=S,d=N,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=(C>>>28|$<<32-28)^($>>>34-32|C<<32-(34-32))^($>>>39-32|C<<32-(39-32)),d=($>>>28|C<<32-28)^(C>>>34-32|$<<32-(34-32))^(C>>>39-32|$<<32-(39-32)),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=C&W^C&G^W&G,d=$&X^$&D^X&D,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,j=g&65535|w<<16,K=b&65535|p<<16,x=R,d=V,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=S,d=N,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,R=g&65535|w<<16,V=b&65535|p<<16,W=l,G=y,J=_,s=R,q=A,I=Q,L=T,C=j,X=Y,D=z,ft=H,et=V,nt=k,it=F,ot=O,$=K,U%16===15)for(E=0;E<16;E++)x=f[E],d=c[E],b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=f[(E+9)%16],d=c[(E+9)%16],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,S=f[(E+1)%16],N=c[(E+1)%16],x=(S>>>1|N<<32-1)^(S>>>8|N<<32-8)^S>>>7,d=(N>>>1|S<<32-1)^(N>>>8|S<<32-8)^(N>>>7|S<<32-7),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,S=f[(E+14)%16],N=c[(E+14)%16],x=(S>>>19|N<<32-19)^(N>>>61-32|S<<32-(61-32))^S>>>6,d=(N>>>19|S<<32-19)^(S>>>61-32|N<<32-(61-32))^(N>>>6|S<<32-6),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,f[E]=g&65535|w<<16,c[E]=b&65535|p<<16;x=C,d=$,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[0],d=o[0],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[0]=C=g&65535|w<<16,o[0]=$=b&65535|p<<16,x=W,d=X,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[1],d=o[1],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[1]=W=g&65535|w<<16,o[1]=X=b&65535|p<<16,x=G,d=D,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[2],d=o[2],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[2]=G=g&65535|w<<16,o[2]=D=b&65535|p<<16,x=J,d=ft,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[3],d=o[3],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[3]=J=g&65535|w<<16,o[3]=ft=b&65535|p<<16,x=s,d=et,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[4],d=o[4],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[4]=s=g&65535|w<<16,o[4]=et=b&65535|p<<16,x=q,d=nt,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[5],d=o[5],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[5]=q=g&65535|w<<16,o[5]=nt=b&65535|p<<16,x=I,d=it,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[6],d=o[6],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[6]=I=g&65535|w<<16,o[6]=it=b&65535|p<<16,x=L,d=ot,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[7],d=o[7],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[7]=L=g&65535|w<<16,o[7]=ot=b&65535|p<<16,at+=128,t-=128}return t}function jt(r,o,i){var t=new Int32Array(8),f=new Int32Array(8),c=new Uint8Array(256),l,y=i;for(t[0]=1779033703,t[1]=3144134277,t[2]=1013904242,t[3]=2773480762,t[4]=1359893119,t[5]=2600822924,t[6]=528734635,t[7]=1541459225,f[0]=4089235720,f[1]=2227873595,f[2]=4271175723,f[3]=1595750129,f[4]=2917565137,f[5]=725511199,f[6]=4215389547,f[7]=327033209,Ar(t,f,o,i),i%=128,l=0;l<i;l++)c[l]=o[y-i+l];for(c[i]=128,i=256-128*(i<112?1:0),c[i-9]=0,Nt(c,i-8,y/536870912|0,y<<3),Ar(t,f,c,i),l=0;l<8;l++)Nt(r,8*l,t[l],f[l]);return 0}function ve(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n(),R=n(),A=n();wt(i,r[1],r[0]),wt(A,o[1],o[0]),Z(i,i,A),mt(t,r[0],r[1]),mt(A,o[0],o[1]),Z(t,t,A),Z(f,r[3],o[3]),Z(f,f,P),Z(c,r[2],o[2]),mt(c,c,c),wt(l,t,i),wt(y,c,f),mt(_,c,f),mt(R,t,i),Z(r[0],l,y),Z(r[1],R,_),Z(r[2],_,y),Z(r[3],l,R)}function Sr(r,o,i){var t;for(t=0;t<4;t++)$t(r[t],o[t],i)}function Je(r,o){var i=n(),t=n(),f=n();mr(f,o[2]),Z(i,o[0],f),Z(t,o[1],f),qt(r,t),r[31]^=br(i)<<7}function Ge(r,o,i){var t,f;for(Pt(r[0],m),Pt(r[1],v),Pt(r[2],v),Pt(r[3],m),f=255;f>=0;--f)t=i[f/8|0]>>(f&7)&1,Sr(r,o,t),ve(o,r),ve(r,r),Sr(r,o,t)}function Ee(r,o){var i=[n(),n(),n(),n()];Pt(i[0],tt),Pt(i[1],rt),Pt(i[2],v),Z(i[3],tt,rt),Ge(r,i,o)}function $e(r,o,i){var t=new Uint8Array(64),f=[n(),n(),n(),n()],c;for(i||a(o,32),jt(t,o,32),t[0]&=248,t[31]&=127,t[31]|=64,Ee(f,t),Je(r,f),c=0;c<32;c++)o[c+32]=r[c];return 0}var Ae=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 qe(r,o){var i,t,f,c;for(t=63;t>=32;--t){for(i=0,f=t-32,c=t-12;f<c;++f)o[f]+=i-16*o[t]*Ae[f-(t-32)],i=Math.floor((o[f]+128)/256),o[f]-=i*256;o[f]+=i,o[t]=0}for(i=0,f=0;f<32;f++)o[f]+=i-(o[31]>>4)*Ae[f],i=o[f]>>8,o[f]&=255;for(f=0;f<32;f++)o[f]-=i*Ae[f];for(t=0;t<32;t++)o[t+1]+=o[t]>>8,r[t]=o[t]&255}function Ze(r){var o=new Float64Array(64),i;for(i=0;i<64;i++)o[i]=r[i];for(i=0;i<64;i++)r[i]=0;qe(r,o)}function Tr(r,o,i,t){var f=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),y,_,R=new Float64Array(64),A=[n(),n(),n(),n()];jt(f,t,32),f[0]&=248,f[31]&=127,f[31]|=64;var Q=i+64;for(y=0;y<i;y++)r[64+y]=o[y];for(y=0;y<32;y++)r[32+y]=f[32+y];for(jt(l,r.subarray(32),i+32),Ze(l),Ee(A,l),Je(r,A),y=32;y<64;y++)r[y]=t[y];for(jt(c,r,i+64),Ze(c),y=0;y<64;y++)R[y]=0;for(y=0;y<32;y++)R[y]=l[y];for(y=0;y<32;y++)for(_=0;_<32;_++)R[y+_]+=c[y]*f[_];return qe(r.subarray(32),R),Q}function En(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n();return Pt(r[2],v),We(r[1],o),yt(f,r[1]),Z(c,f,M),wt(f,f,r[2]),mt(c,r[2],c),yt(l,c),yt(y,l),Z(_,y,l),Z(i,_,f),Z(i,i,c),wr(i,i),Z(i,i,f),Z(i,i,c),Z(i,i,c),Z(r[0],i,c),yt(t,r[0]),Z(t,t,c),gr(t,f)&&Z(r[0],r[0],ht),yt(t,r[0]),Z(t,t,c),gr(t,f)?-1:(br(r[0])===o[31]>>7&&wt(r[0],m,r[0]),Z(r[3],r[0],r[1]),0)}function Xe(r,o,i,t){var f,c=new Uint8Array(32),l=new Uint8Array(64),y=[n(),n(),n(),n()],_=[n(),n(),n(),n()];if(i<64||En(_,t))return-1;for(f=0;f<i;f++)r[f]=o[f];for(f=0;f<32;f++)r[f+32]=t[f];if(jt(l,r,i),Ze(l),Ge(y,_,l),Ee(_,o.subarray(32)),ve(y,_),Je(c,y),i-=64,vt(o,0,c,0)){for(f=0;f<i;f++)r[f]=0;return-1}for(f=0;f<i;f++)r[f]=o[f+64];return i}var De=32,Se=24,fe=32,Zt=16,ae=32,Te=32,se=32,ce=32,Qe=32,Or=Se,An=fe,Sn=Zt,Ut=64,Yt=32,Xt=64,Ie=32,Le=64;e.lowlevel={crypto_core_hsalsa20:Jt,crypto_stream_xor:re,crypto_stream:ge,crypto_stream_salsa20_xor:Mt,crypto_stream_salsa20:ye,crypto_onetimeauth:ne,crypto_onetimeauth_verify:be,crypto_verify_16:xt,crypto_verify_32:vt,crypto_secretbox:ie,crypto_secretbox_open:oe,crypto_scalarmult:me,crypto_scalarmult_base:we,crypto_box_beforenm:_e,crypto_box_afternm:vr,crypto_box:_n,crypto_box_open:vn,crypto_box_keypair:_r,crypto_hash:jt,crypto_sign:Tr,crypto_sign_keypair:$e,crypto_sign_open:Xe,crypto_secretbox_KEYBYTES:De,crypto_secretbox_NONCEBYTES:Se,crypto_secretbox_ZEROBYTES:fe,crypto_secretbox_BOXZEROBYTES:Zt,crypto_scalarmult_BYTES:ae,crypto_scalarmult_SCALARBYTES:Te,crypto_box_PUBLICKEYBYTES:se,crypto_box_SECRETKEYBYTES:ce,crypto_box_BEFORENMBYTES:Qe,crypto_box_NONCEBYTES:Or,crypto_box_ZEROBYTES:An,crypto_box_BOXZEROBYTES:Sn,crypto_sign_BYTES:Ut,crypto_sign_PUBLICKEYBYTES:Yt,crypto_sign_SECRETKEYBYTES:Xt,crypto_sign_SEEDBYTES:Ie,crypto_hash_BYTES:Le,gf:n,D:M,L:Ae,pack25519:qt,unpack25519:We,M:Z,A:mt,S:yt,Z:wt,pow2523:wr,add:ve,set25519:Pt,modL:qe,scalarmult:Ge,scalarbase:Ee};function Nr(r,o){if(r.length!==De)throw new Error("bad key size");if(o.length!==Se)throw new Error("bad nonce size")}function Tn(r,o){if(r.length!==se)throw new Error("bad public key size");if(o.length!==ce)throw new Error("bad secret key size")}function pt(){for(var r=0;r<arguments.length;r++)if(!(arguments[r]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Pr(r){for(var o=0;o<r.length;o++)r[o]=0}e.randomBytes=function(r){var o=new Uint8Array(r);return a(o,r),o},e.secretbox=function(r,o,i){pt(r,o,i),Nr(i,o);for(var t=new Uint8Array(fe+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+fe]=r[c];return ie(f,t,t.length,o,i),f.subarray(Zt)},e.secretbox.open=function(r,o,i){pt(r,o,i),Nr(i,o);for(var t=new Uint8Array(Zt+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+Zt]=r[c];return t.length<32||oe(f,t,t.length,o,i)!==0?null:f.subarray(fe)},e.secretbox.keyLength=De,e.secretbox.nonceLength=Se,e.secretbox.overheadLength=Zt,e.scalarMult=function(r,o){if(pt(r,o),r.length!==Te)throw new Error("bad n size");if(o.length!==ae)throw new Error("bad p size");var i=new Uint8Array(ae);return me(i,r,o),i},e.scalarMult.base=function(r){if(pt(r),r.length!==Te)throw new Error("bad n size");var o=new Uint8Array(ae);return we(o,r),o},e.scalarMult.scalarLength=Te,e.scalarMult.groupElementLength=ae,e.box=function(r,o,i,t){var f=e.box.before(i,t);return e.secretbox(r,o,f)},e.box.before=function(r,o){pt(r,o),Tn(r,o);var i=new Uint8Array(Qe);return _e(i,r,o),i},e.box.after=e.secretbox,e.box.open=function(r,o,i,t){var f=e.box.before(i,t);return e.secretbox.open(r,o,f)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var r=new Uint8Array(se),o=new Uint8Array(ce);return _r(r,o),{publicKey:r,secretKey:o}},e.box.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==ce)throw new Error("bad secret key size");var o=new Uint8Array(se);return we(o,r),{publicKey:o,secretKey:new Uint8Array(r)}},e.box.publicKeyLength=se,e.box.secretKeyLength=ce,e.box.sharedKeyLength=Qe,e.box.nonceLength=Or,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(r,o){if(pt(r,o),o.length!==Xt)throw new Error("bad secret key size");var i=new Uint8Array(Ut+r.length);return Tr(i,r,r.length,o),i},e.sign.open=function(r,o){if(pt(r,o),o.length!==Yt)throw new Error("bad public key size");var i=new Uint8Array(r.length),t=Xe(i,r,r.length,o);if(t<0)return null;for(var f=new Uint8Array(t),c=0;c<f.length;c++)f[c]=i[c];return f},e.sign.detached=function(r,o){for(var i=e.sign(r,o),t=new Uint8Array(Ut),f=0;f<t.length;f++)t[f]=i[f];return t},e.sign.detached.verify=function(r,o,i){if(pt(r,o,i),o.length!==Ut)throw new Error("bad signature size");if(i.length!==Yt)throw new Error("bad public key size");var t=new Uint8Array(Ut+r.length),f=new Uint8Array(Ut+r.length),c;for(c=0;c<Ut;c++)t[c]=o[c];for(c=0;c<r.length;c++)t[c+Ut]=r[c];return Xe(f,t,t.length,i)>=0},e.sign.keyPair=function(){var r=new Uint8Array(Yt),o=new Uint8Array(Xt);return $e(r,o),{publicKey:r,secretKey:o}},e.sign.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==Xt)throw new Error("bad secret key size");for(var o=new Uint8Array(Yt),i=0;i<o.length;i++)o[i]=r[32+i];return{publicKey:o,secretKey:new Uint8Array(r)}},e.sign.keyPair.fromSeed=function(r){if(pt(r),r.length!==Ie)throw new Error("bad seed size");for(var o=new Uint8Array(Yt),i=new Uint8Array(Xt),t=0;t<32;t++)i[t]=r[t];return $e(o,i,!0),{publicKey:o,secretKey:i}},e.sign.publicKeyLength=Yt,e.sign.secretKeyLength=Xt,e.sign.seedLength=Ie,e.sign.signatureLength=Ut,e.hash=function(r){pt(r);var o=new Uint8Array(Le);return jt(o,r,r.length),o},e.hash.hashLength=Le,e.verify=function(r,o){return pt(r,o),r.length===0||o.length===0||r.length!==o.length?!1:bt(r,0,o,0,r.length)===0},e.setPRNG=function(r){a=r},function(){var r=typeof self<"u"?self.crypto||self.msCrypto:null;if(r&&r.getRandomValues){var o=65536;e.setPRNG(function(i,t){var f,c=new Uint8Array(t);for(f=0;f<t;f+=o)r.getRandomValues(c.subarray(f,f+Math.min(t-f,o)));for(f=0;f<t;f++)i[f]=c[f];Pr(c)})}else typeof Ur<"u"&&(r=jr(),r&&r.randomBytes&&e.setPRNG(function(i,t){var f,c=r.randomBytes(t);for(f=0;f<t;f++)i[f]=c[f];Pr(c)}))}()})(typeof Re<"u"&&Re.exports?Re.exports:self.nacl=self.nacl||{})});var le=Oe(rr());function Dt(e){var n;return new Uint8Array(((n=e.match(/.{1,2}/g))!==null&&n!==void 0?n:[]).map(a=>parseInt(a,16))).buffer}function Rt(e){return new Uint8Array(e).reduce((n,a)=>n+a.toString(16).padStart(2,"0"),"")}var Kn=(e,n)=>{if(e.byteLength!==n.byteLength)return!1;let a=new Uint8Array(e),u=new Uint8Array(n);for(let h=0;h<a.length;h++)if(a[h]!==u[h])return!1;return!0},Yr=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Vr=(e,n,a)=>{if(a<=127)return e[n]=a,1;if(a<=255)return e[n]=129,e[n+1]=a,2;if(a<=65535)return e[n]=130,e[n+1]=a>>8,e[n+2]=a,3;if(a<=16777215)return e[n]=131,e[n+1]=a>>16,e[n+2]=a>>8,e[n+3]=a,4;throw new Error("Length too long (> 4 bytes)")},nr=(e,n)=>{if(e[n]<128)return 1;if(e[n]===128)throw new Error("Invalid length 0");if(e[n]===129)return 2;if(e[n]===130)return 3;if(e[n]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Cn=(e,n)=>{let a=nr(e,n);if(a===1)return e[n];if(a===2)return e[n+1];if(a===3)return(e[n+1]<<8)+e[n+2];if(a===4)return(e[n+1]<<16)+(e[n+2]<<8)+e[n+3];throw new Error("Length too long (> 4 bytes)")},Fr=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Be=Uint8Array.from([48,5,6,3,43,101,112]),ui=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function Ke(e,n){let a=2+Yr(e.byteLength+1),u=n.byteLength+a+e.byteLength,h=0,m=new Uint8Array(1+Yr(u)+u);return m[h++]=48,h+=Vr(m,h,u),m.set(n,h),h+=n.byteLength,m[h++]=3,h+=Vr(m,h,e.byteLength+1),m[h++]=0,m.set(new Uint8Array(e),h),m}var ir=(e,n)=>{let a=0,u=(B,M)=>{if(h[a++]!==B)throw new Error("Expected: "+M)},h=new Uint8Array(e);if(u(48,"sequence"),a+=nr(h,a),!Kn(h.slice(a,a+n.byteLength),n))throw new Error("Not the expected OID.");a+=n.byteLength,u(3,"bit string");let m=Cn(h,a)-1;a+=nr(h,a),u(0,"0 padding");let v=h.slice(a);if(m!==v.length)throw new Error(`DER payload mismatch: Expected length ${m} actual length ${v.length}`);return v};var gt=class{constructor(n){this.rawKey=n,this.derKey=gt.derEncode(n)}static from(n){return this.fromDer(n.toDer())}static fromRaw(n){return new gt(n)}static fromDer(n){return new gt(this.derDecode(n))}static derEncode(n){return Ke(n,Be).buffer}static derDecode(n){let a=ir(n,Be);if(a.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return a}toDer(){return this.derKey}toRaw(){return this.rawKey}};gt.RAW_KEY_LENGTH=32;var Bt=class extends Vt{constructor(n,a){super(),this._privateKey=a,this._publicKey=gt.from(n)}static generate(n){if(n&&n.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");let{publicKey:a,secretKey:u}=n===void 0?le.sign.keyPair():le.sign.keyPair.fromSeed(n);return new this(gt.fromRaw(a),u)}static fromParsedJson(n){let[a,u]=n;return new Bt(gt.fromDer(Dt(a)),Dt(u))}static fromJSON(n){let a=JSON.parse(n);if(Array.isArray(a)){if(typeof a[0]=="string"&&typeof a[1]=="string")return this.fromParsedJson([a[0],a[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(n)}`)}static fromKeyPair(n,a){return new Bt(gt.fromRaw(n),a)}static fromSecretKey(n){let a=le.sign.keyPair.fromSecretKey(new Uint8Array(n));return Bt.fromKeyPair(a.publicKey,a.secretKey)}toJSON(){return[Rt(this._publicKey.toDer()),Rt(this._privateKey)]}getKeyPair(){return{secretKey:this._privateKey,publicKey:this._publicKey}}getPublicKey(){return this._publicKey}async sign(n){let a=new Uint8Array(n);return le.sign.detached(a,new Uint8Array(this._privateKey)).buffer}};var xe=class extends Error{constructor(n){super(n),this.message=n,Object.setPrototypeOf(this,xe.prototype)}};function kr(e){if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new xe("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var kt=class extends Vt{constructor(n,a,u){super(),this._keyPair=n,this._derKey=a,this._subtleCrypto=u}static async generate(n){let{extractable:a=!1,keyUsages:u=["sign","verify"],subtleCrypto:h}=n??{},m=kr(h),v=await m.generateKey({name:"ECDSA",namedCurve:"P-256"},a,u),B=await m.exportKey("spki",v.publicKey);return new this(v,B,m)}static async fromKeyPair(n,a){let u=kr(a),h=await u.exportKey("spki",n.publicKey);return new kt(n,h,u)}getKeyPair(){return this._keyPair}getPublicKey(){let n=this._derKey,a=Object.create(this._keyPair.publicKey);return a.toDer=function(){return n},a}async sign(n){let a={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(a,this._keyPair.privateKey,n)}};var Qt=Oe(Rn());var Mn=function(e,n){var a={};for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&n.indexOf(u)<0&&(a[u]=e[u]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var h=0,u=Object.getOwnPropertySymbols(e);h<u.length;h++)n.indexOf(u[h])<0&&Object.prototype.propertyIsEnumerable.call(e,u[h])&&(a[u[h]]=e[u[h]]);return a},jn=new TextEncoder().encode("ic-request-auth-delegation"),Yn=new TextEncoder().encode(`
|
|
2
|
+
ic-request`);function or(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return Dt(e)}var It=class{constructor(n,a,u){this.pubkey=n,this.expiration=a,this.targets=u}toCBOR(){return Qt.value.map(Object.assign({pubkey:Qt.value.bytes(this.pubkey),expiration:Qt.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Qt.value.array(this.targets.map(n=>Qt.value.bytes(n.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Rt(this.pubkey)},this.targets&&{targets:this.targets.map(n=>n.toHex())})}};async function Vn(e,n,a,u){let h=new It(n.toDer(),BigInt(+a)*BigInt(1e6),u),m=new Uint8Array([...jn,...new Uint8Array(tr(h))]),v=await e.sign(m);return{delegation:h,signature:v}}var Ht=class{constructor(n,a){this.delegations=n,this.publicKey=a}static async create(n,a,u=new Date(Date.now()+15*60*1e3),h={}){var m,v;let B=await Vn(n,a,u,h.targets);return new Ht([...((m=h.previous)===null||m===void 0?void 0:m.delegations)||[],B],((v=h.previous)===null||v===void 0?void 0:v.publicKey)||n.getPublicKey().toDer())}static fromJSON(n){let{publicKey:a,delegations:u}=typeof n=="string"?JSON.parse(n):n;if(!Array.isArray(u))throw new Error("Invalid delegations.");let h=u.map(m=>{let{delegation:v,signature:B}=m,{pubkey:M,expiration:P,targets:tt}=v;if(tt!==void 0&&!Array.isArray(tt))throw new Error("Invalid targets.");return{delegation:new It(or(M),BigInt(`0x${P}`),tt&&tt.map(rt=>{if(typeof rt!="string")throw new Error("Invalid target.");return Pe.fromHex(rt)})),signature:or(B)}});return new this(h,or(a))}static fromDelegations(n,a){return new this(n,a)}toJSON(){return{delegations:this.delegations.map(n=>{let{delegation:a,signature:u}=n,{targets:h}=a;return{delegation:Object.assign({expiration:a.expiration.toString(16),pubkey:Rt(a.pubkey)},h&&{targets:h.map(m=>m.toHex())}),signature:Rt(u)}}),publicKey:Rt(this.publicKey)}}},de=class extends Vt{constructor(n,a){super(),this._inner=n,this._delegation=a}static fromDelegation(n,a){return new this(n,a)}getDelegation(){return this._delegation}getPublicKey(){return{toDer:()=>this._delegation.publicKey}}sign(n){return this._inner.sign(n)}async transformRequest(n){let{body:a}=n,u=Mn(n,["body"]),h=await tr(a);return Object.assign(Object.assign({},u),{body:{content:a,sender_sig:await this.sign(new Uint8Array([...Yn,...new Uint8Array(h)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};function Hr(e,n){for(let{delegation:h}of e.delegations)if(+new Date(Number(h.expiration/BigInt(1e6)))<=+Date.now())return!1;let a=[],u=n?.scope;u&&(Array.isArray(u)?a.push(...u.map(h=>typeof h=="string"?Pe.fromText(h):h)):a.push(typeof u=="string"?Pe.fromText(u):u));for(let h of a){let m=h.toText();for(let{delegation:v}of e.delegations){if(v.targets===void 0)continue;let B=!0;for(let M of v.targets)if(M.toText()===m){B=!1;break}if(B)return!1}}return!0}var Fn=Oe(Un()),kn=Oe(rr());var zr;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(zr||(zr={}));var Wr=["mousedown","mousemove","keydown","touchstart","wheel"],ue=class{constructor(n={}){var a;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:u,idleTimeout:h=10*60*1e3}=n||{};this.callbacks=u?[u]:[],this.idleTimeout=h;let m=this._resetTimer.bind(this);window.addEventListener("load",m,!0),Wr.forEach(function(B){document.addEventListener(B,m,!0)});let v=(B,M)=>{let P;return(...tt)=>{let rt=this,ht=function(){P=void 0,B.apply(rt,tt)};clearTimeout(P),P=window.setTimeout(ht,M)}};if(n?.captureScroll){let B=v(m,(a=n?.scrollDebounce)!==null&&a!==void 0?a:100);window.addEventListener("scroll",B,!0)}m()}static create(n={}){return new this(n)}registerCallback(n){this.callbacks.push(n)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let n=this._resetTimer.bind(this);Wr.forEach(function(a){document.removeEventListener(a,n,!0)}),this.callbacks.forEach(a=>a())}_resetTimer(){let n=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(n,this.idleTimeout)}};var Hn=(e,n)=>n.some(a=>e instanceof a),Jr,Gr;function zn(){return Jr||(Jr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Wn(){return Gr||(Gr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var $r=new WeakMap,ar=new WeakMap,qr=new WeakMap,fr=new WeakMap,cr=new WeakMap;function Jn(e){let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("success",m),e.removeEventListener("error",v)},m=()=>{a(At(e.result)),h()},v=()=>{u(e.error),h()};e.addEventListener("success",m),e.addEventListener("error",v)});return n.then(a=>{a instanceof IDBCursor&&$r.set(a,e)}).catch(()=>{}),cr.set(n,e),n}function Gn(e){if(ar.has(e))return;let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("complete",m),e.removeEventListener("error",v),e.removeEventListener("abort",v)},m=()=>{a(),h()},v=()=>{u(e.error||new DOMException("AbortError","AbortError")),h()};e.addEventListener("complete",m),e.addEventListener("error",v),e.addEventListener("abort",v)});ar.set(e,n)}var sr={get(e,n,a){if(e instanceof IDBTransaction){if(n==="done")return ar.get(e);if(n==="objectStoreNames")return e.objectStoreNames||qr.get(e);if(n==="store")return a.objectStoreNames[1]?void 0:a.objectStore(a.objectStoreNames[0])}return At(e[n])},set(e,n,a){return e[n]=a,!0},has(e,n){return e instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in e}};function Zr(e){sr=e(sr)}function $n(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...a){let u=e.call(Ce(this),n,...a);return qr.set(u,n.sort?n.sort():[n]),At(u)}:Wn().includes(e)?function(...n){return e.apply(Ce(this),n),At($r.get(this))}:function(...n){return At(e.apply(Ce(this),n))}}function qn(e){return typeof e=="function"?$n(e):(e instanceof IDBTransaction&&Gn(e),Hn(e,zn())?new Proxy(e,sr):e)}function At(e){if(e instanceof IDBRequest)return Jn(e);if(fr.has(e))return fr.get(e);let n=qn(e);return n!==e&&(fr.set(e,n),cr.set(n,e)),n}var Ce=e=>cr.get(e);function Dr(e,n,{blocked:a,upgrade:u,blocking:h,terminated:m}={}){let v=indexedDB.open(e,n),B=At(v);return u&&v.addEventListener("upgradeneeded",M=>{u(At(v.result),M.oldVersion,M.newVersion,At(v.transaction),M)}),a&&v.addEventListener("blocked",M=>a(M.oldVersion,M.newVersion,M)),B.then(M=>{m&&M.addEventListener("close",()=>m()),h&&M.addEventListener("versionchange",P=>h(P.oldVersion,P.newVersion,P))}).catch(()=>{}),B}var Zn=["get","getKey","getAll","getAllKeys","count"],Xn=["put","add","delete","clear"],lr=new Map;function Xr(e,n){if(!(e instanceof IDBDatabase&&!(n in e)&&typeof n=="string"))return;if(lr.get(n))return lr.get(n);let a=n.replace(/FromIndex$/,""),u=n!==a,h=Xn.includes(a);if(!(a in(u?IDBIndex:IDBObjectStore).prototype)||!(h||Zn.includes(a)))return;let m=async function(v,...B){let M=this.transaction(v,h?"readwrite":"readonly"),P=M.store;return u&&(P=P.index(B.shift())),(await Promise.all([P[a](...B),h&&M.done]))[0]};return lr.set(n,m),m}Zr(e=>({...e,get:(n,a,u)=>Xr(n,a)||e.get(n,a,u),has:(n,a)=>!!Xr(n,a)||e.has(n,a)}));var Qr="auth-client-db",Ir="ic-keyval",Dn=async(e=Qr,n=Ir,a)=>(Me&&(localStorage!=null&&localStorage.getItem(_t))&&(localStorage.removeItem(_t),localStorage.removeItem(St)),await Dr(e,a,{upgrade:u=>{u.objectStoreNames,u.objectStoreNames.contains(n)&&u.clear(n),u.createObjectStore(n)}}));async function Qn(e,n,a){return await e.get(n,a)}async function In(e,n,a,u){return await e.put(n,u,a)}async function Ln(e,n,a){return await e.delete(n,a)}var zt=class{constructor(n,a){this._db=n,this._storeName=a}static async create(n){let{dbName:a=Qr,storeName:u=Ir,version:h=1}=n??{},m=await Dn(a,u,h);return new zt(m,u)}async set(n,a){return await In(this._db,this._storeName,n,a)}async get(n){var a;return(a=await Qn(this._db,this._storeName,n))!==null&&a!==void 0?a:null}async remove(n){return await Ln(this._db,this._storeName,n)}};var St="identity",_t="delegation",Lr="iv",ti=1,Me=typeof window<"u",he=class{constructor(n="ic-",a){this.prefix=n,this._localStorage=a}get(n){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+n))}set(n,a){return this._getLocalStorage().setItem(this.prefix+n,a),Promise.resolve()}remove(n){return this._getLocalStorage().removeItem(this.prefix+n),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let n=typeof window>"u"&&typeof window>"u"?typeof self>"u"?void 0:self.localStorage:window.localStorage;if(!n)throw new Error("Could not find local storage.");return n}},pe=class{get _db(){return new Promise(n=>{if(this.initializedDb){n(this.initializedDb);return}zt.create({version:ti}).then(a=>{this.initializedDb=a,n(a)})})}async get(n){return await(await this._db).get(n)}async set(n,a){await(await this._db).set(n,a)}async remove(n){await(await this._db).remove(n)}};var ei="https://identity.ic0.app",ri="#authorize",ni=500,ii="UserInterrupt",je=class{constructor(n,a,u,h,m,v,B,M){var P;this._identity=n,this._key=a,this._chain=u,this._storage=h,this.idleManager=m,this._createOptions=v,this._idpWindow=B,this._eventHandler=M;let tt=this.logout.bind(this),rt=v?.idleOptions;!rt?.onIdle&&!rt?.disableDefaultIdleCallback&&((P=this.idleManager)===null||P===void 0||P.registerCallback(()=>{tt(),location.reload()}))}static async create(n={}){var a,u;let h=(a=n.storage)!==null&&a!==void 0?a:new pe,m=null;if(n.identity)m=n.identity;else{let P=await h.get(St);if(!P&&Me)try{let tt=new he,rt=await tt.get(_t),ht=await tt.get(St);rt&&ht&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await h.set(_t,rt),await h.set(St,ht),P=rt,await tt.remove(_t),await tt.remove(St))}catch(tt){console.error("error while attempting to recover localstorage: "+tt)}if(P)try{typeof P=="object"?m=await kt.fromKeyPair(P):typeof P=="string"&&(m=Bt.fromJSON(P))}catch{}}let v=new er,B=null;if(m)try{let P=await h.get(_t);if(typeof P=="object"&&P!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");n.identity?v=n.identity:P&&(B=Ht.fromJSON(P),Hr(B)?v=de.fromDelegation(m,B):(await xr(h),m=null))}catch(P){console.error(P),await xr(h),m=null}let M;return!((u=n.idleOptions)===null||u===void 0)&&u.disableIdle?M=void 0:(B||n.identity)&&(M=ue.create(n.idleOptions)),m||(m=await kt.generate(),await h.set(St,m.getKeyPair())),new this(v,m,B,h,M,n)}_handleSuccess(n,a){var u,h,m;let v=n.delegations.map(P=>({delegation:new It(P.delegation.pubkey,P.delegation.expiration,P.delegation.targets),signature:P.signature.buffer})),B=Ht.fromDelegations(v,n.userPublicKey.buffer),M=this._key;if(M){if(this._chain=B,this._identity=de.fromDelegation(M,this._chain),(u=this._idpWindow)===null||u===void 0||u.close(),!this.idleManager){let P=(h=this._createOptions)===null||h===void 0?void 0:h.idleOptions;this.idleManager=ue.create(P),!P?.onIdle&&!P?.disableDefaultIdleCallback&&((m=this.idleManager)===null||m===void 0||m.registerCallback(()=>{this.logout(),location.reload()}))}a?.(),this._removeEventListener(),delete this._idpWindow}}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(n){var a,u,h,m;let v=BigInt(8)*BigInt(36e11),B=new URL(((a=n?.identityProvider)===null||a===void 0?void 0:a.toString())||ei);B.hash=ri,(u=this._idpWindow)===null||u===void 0||u.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(B,Object.assign({maxTimeToLive:(h=n?.maxTimeToLive)!==null&&h!==void 0?h:v},n)),window.addEventListener("message",this._eventHandler),this._idpWindow=(m=window.open(B.toString(),"idpWindow",n?.windowOpenerFeatures))!==null&&m!==void 0?m:void 0;let M=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(ii,n?.onError):setTimeout(M,ni))};M()}_getEventHandler(n,a){return async u=>{var h,m,v;if(u.origin!==n.origin){console.warn(`WARNING: expected origin '${n.origin}', got '${u.origin}' (ignoring)`);return}let B=u.data;switch(B.kind){case"authorize-ready":{let M={kind:"authorize-client",sessionPublicKey:new Uint8Array((h=this._key)===null||h===void 0?void 0:h.getPublicKey().toDer()),maxTimeToLive:a?.maxTimeToLive,derivationOrigin:(m=a?.derivationOrigin)===null||m===void 0?void 0:m.toString()};(v=this._idpWindow)===null||v===void 0||v.postMessage(M,n.origin);break}case"authorize-client-success":try{this._handleSuccess(B,a?.onSuccess),this._chain&&await this._storage.set(_t,JSON.stringify(this._chain.toJSON()))}catch(M){this._handleFailure(M.message,a?.onError)}break;case"authorize-client-failure":this._handleFailure(B.text,a?.onError);break;default:break}}}_handleFailure(n,a){var u;(u=this._idpWindow)===null||u===void 0||u.close(),a?.(n),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(n={}){if(await xr(this._storage),this._identity=new er,this._chain=null,n.returnTo)try{window.history.pushState({},"",n.returnTo)}catch{window.location.href=n.returnTo}}};async function xr(e){await e.remove(St),await e.remove(_t),await e.remove(Lr)}var tn=BigInt(144e11);var Lt=class{callbacks=[];populate(n){this.callbacks.forEach(({callback:a})=>a(n))}subscribe(n){let a=Symbol();return this.callbacks.push({id:a,callback:n}),()=>this.callbacks=this.callbacks.filter(({id:u})=>u!==a)}};var te=class extends Lt{authUser=null;constructor(){super()}static getInstance(){return te.instance||(te.instance=new te),te.instance}set(n){this.authUser=n,this.populate(n)}get(){return this.authUser}subscribe(n){let a=super.subscribe(n);return n(this.authUser),a}isLoggedIn(){return!this.authUser?.data?.principal.isAnonymous()}reset(){this.authUser=null,this.populate(this.authUser)}},Ct=te;Ne(Ct,"instance");var ee=class extends Lt{env;constructor(){super()}static getInstance(){return ee.instance||(ee.instance=new ee),ee.instance}set(n){this.env=n,this.populate(n)}get(){return this.env}localIdentity(){return this.get()?.localIdentityCanisterId!==void 0}subscribe(n){let a=super.subscribe(n);return n(this.env),a}},dt=ee;Ne(dt,"instance");var ut=e=>e?[e]:[],Ye=e=>e?.[0],en=async e=>{let n=new Blob([JSON.stringify(e)],{type:"application/json; charset=utf-8"});return new Uint8Array(await n.arrayBuffer())},dr=async e=>{let n=new Blob([e],{type:"application/json; charset=utf-8"});return JSON.parse(await n.text())};var ur=e=>e==null;var Ve=({matcher:e,paginate:n,order:a})=>({matcher:ut(e),paginate:ut(ur(n)?void 0:{start_after:ut(n.startAfter),limit:ut(ur(n.limit)?void 0:BigInt(n.limit))}),order:ut(a)});var rn=({IDL:e})=>{let n=e.Record({controllers:e.Vec(e.Principal)}),a=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),u=e.Record({updated_at:e.Opt(e.Nat64)}),h=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),m=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),v=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),B=e.Variant({Callback:e.Record({token:v,callback:e.Func([],[],[])})}),M=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(B),status_code:e.Nat16}),P=e.Record({token:e.Opt(v),body:e.Vec(e.Nat8)}),tt=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),rt=e.Record({batch_id:e.Nat}),ht=e.Record({desc:e.Bool}),Nt=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),bt=e.Record({order:e.Opt(ht),matcher:e.Opt(e.Text),paginate:e.Opt(Nt)}),xt=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),vt=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),ke=e.Record({key:xt,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,vt)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),He=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,ke))}),Wt=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Text}),Jt=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,h))}),Et=e.Variant({Db:e.Null,Storage:e.Null}),Mt=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ye=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:Mt,created_at:e.Nat64,write:Mt}),ge=e.Variant({Never:e.Null,Always:e.Null}),re=e.Record({trailing_slash:ge}),Gt=e.Record({storage:re}),ne=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),be=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:Mt,write:Mt}),ie=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),oe=e.Record({chunk_id:e.Nat});return e.Service({add_controllers:e.Func([n],[e.Vec(e.Principal)],[]),commit_asset_upload:e.Func([a],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,u],[],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(h)],["query"]),http_request:e.Func([m],[M],["query"]),http_request_streaming_callback:e.Func([v],[P],["query"]),init_asset_upload:e.Func([tt],[rt],[]),list_assets:e.Func([e.Opt(e.Text),bt],[He],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Wt))],["query"]),list_docs:e.Func([e.Text,bt],[Jt],["query"]),list_rules:e.Func([Et],[e.Vec(e.Tuple(e.Text,ye))],["query"]),remove_controllers:e.Func([n],[e.Vec(e.Principal)],[]),set_config:e.Func([Gt],[],[]),set_custom_domain:e.Func([e.Text,e.Text],[],[]),set_doc:e.Func([e.Text,e.Text,ne],[h],[]),set_rule:e.Func([Et,e.Text,be],[],[]),upload_asset_chunk:e.Func([ie],[oe],[]),version:e.Func([],[e.Text],["query"])})};var nn=async({satelliteId:e,idlFactory:n,identity:a,fetch:u,env:h="prod"})=>{let m=h==="dev"||dt.getInstance().localIdentity(),v=m?"http://127.0.0.1:8000/":"https://ic0.app",B=new Br({identity:a,...v&&{host:v},...u&&{fetch:u}});return m&&await B.fetchRootKey(),Kr.createActor(n,{agent:B,canisterId:e})};var Tt=async({satelliteId:e,...n})=>{let{satelliteId:a}=e!==void 0?{satelliteId:e}:dt.getInstance().get()??{satelliteId:void 0};if(!a)throw new Error("No satellite principal defined.");return nn({satelliteId:a,idlFactory:rn,...n})};var on=async({collection:e,key:n,satellite:a})=>{let u=await Tt(a),h=Ye(await u.get_doc(e,n));if(!h)return;let m=await dr(h.data);return{key:n,data:m,created_at:h.created_at,updated_at:h.updated_at}},fn=async({collection:e,doc:n,satellite:a})=>{let u=await Tt(a),{key:h,data:m,updated_at:v}=n,B=await u.set_doc(e,h,{data:await en(m),updated_at:ut(v)});return{key:h,data:m,created_at:B.created_at,updated_at:B.updated_at}},an=async({collection:e,doc:n,satellite:a})=>{let u=await Tt(a),{key:h,updated_at:m}=n;return u.del_doc(e,h,{updated_at:ut(m)})},sn=async({collection:e,filter:n,satellite:a})=>{let u=await Tt(a),{items:h,matches_length:m,length:v}=await u.list_docs(e,Ve(n)),B=[];for(let[M,P]of h)B.push({key:M,data:await dr(P.data),created_at:P.created_at,updated_at:P.updated_at});return{items:B,length:v,matches_length:m}};var Ot=e=>{if(e!==void 0)return e;let n=Fe();if(!n)throw new Error("No internet identity.");return n};var cn=async({satellite:e,...n})=>{let a=Ot(e?.identity);return on({...n,satellite:{...e,identity:a}})},ln=async({satellite:e,...n})=>{let a=Ot(e?.identity);return fn({...n,satellite:{...e,identity:a}})},Uo=async({satellite:e,...n})=>{let a=Ot(e?.identity);return an({...n,satellite:{...e,identity:a}})},Ro=async({satellite:e,...n})=>{let a=Ot(e?.identity);return sn({...n,satellite:{...e,identity:a}})};var xn=async()=>{let e=Fe();if(!e)throw new Error("No internet identity.");let n=e.getPrincipal().toText(),a=await cn({collection:"#user",key:n});return a||await oi({userId:n,principal:e.getPrincipal()})},oi=async({userId:e,principal:n})=>{let a=new Date;return ln({collection:"#user",doc:{key:e,data:{principal:n,created_at:a,updated_at:a}}})};var Kt,dn=()=>je.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}}),hr=async()=>{if(Kt=Kt??await dn(),!(await Kt?.isAuthenticated()||!1))return;let n=await xn();Ct.getInstance().set(n)},fi=async e=>new Promise(async(n,a)=>{Kt=Kt??await dn(),await Kt.login({onSuccess:async()=>{await hr(),n()},onError:u=>a(u),maxTimeToLive:e?.maxTimeToLive??tn,...dt.getInstance().localIdentity()&&{identityProvider:`http://${dt.getInstance().get()?.localIdentityCanisterId}.localhost:8000?#authorize`},...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...e?.windowOpenerFeatures!==void 0&&{windowOpenerFeatures:e.windowOpenerFeatures}})}),ai=async()=>{await Kt?.logout(),Kt=void 0,Ct.getInstance().reset()},Fe=()=>Kt?.getIdentity();var un=()=>typeof window<"u",pr=()=>{let e=dt.getInstance().get()?.satelliteId??"unknown";return dt.getInstance().localIdentity()?`http://${e}.localhost:8000`:`https://${e}.ic0.app`};var hn=async({data:e,filename:n,collection:a,headers:u,token:h,fullPath:m,encoding:v,satellite:B})=>{let M=`${n}${v?` (${v})`:""}`,P=await Tt(B),{batch_id:tt}=await P.init_asset_upload({collection:a,full_path:m,name:n,token:ut(h),encoding_type:ut(v)}),rt=7e5,ht=[],Nt=un()?new Blob([await e.arrayBuffer()]):e;for(let xt=0;xt<Nt.size;xt+=rt){let vt=Nt.slice(xt,xt+rt);ht.push(await si({batchId:tt,chunk:vt,actor:P}))}let bt=u.find(([xt,vt])=>xt.toLowerCase()==="content-type")===void 0&&e.type!==void 0&&e.type!==""?[["Content-Type",e.type]]:void 0;await P.commit_asset_upload({batch_id:tt,chunk_ids:ht.map(({chunk_id:xt})=>xt),headers:[...u,...bt||[]]})},si=async({batchId:e,chunk:n,actor:a})=>a.upload_asset_chunk({batch_id:e,content:new Uint8Array(await n.arrayBuffer())}),pn=async({collection:e,satellite:n,filter:a})=>{let u=await Tt(n),{items:h,matches_length:m,length:v}=await u.list_assets(ut(e),Ve(a));return{items:h.map(([B,M])=>M),length:v,matches_length:m}},yn=async({collection:e,storageFile:n,satellite:a})=>{let u=await Tt(a),{fullPath:h}=n;return u.del_asset(e,h)},gn=async({collection:e,satellite:n})=>(await Tt(n)).del_assets(ut(e));var bn=e=>btoa([...e].map(n=>String.fromCharCode(n)).join(""));var yr=e=>encodeURI(e.toLowerCase().replace(/\s/g,"-"));var nf=async e=>mn(e),of=async e=>mn({filename:e.data.name,...e}),mn=async({filename:e,data:n,collection:a,headers:u=[],fullPath:h,token:m,satellite:v,encoding:B})=>{let M=Ot(v?.identity),P=yr(e),tt=h||`/${P}`;return await hn({data:n,filename:yr(P),collection:a,token:m,headers:u,fullPath:tt,encoding:B,satellite:{...v,identity:M}}),{downloadUrl:`${pr()}${tt}${m!==void 0?`?token=${m}`:""}`,fullPath:tt,name:P}},ff=async({collection:e,satellite:n,filter:a})=>{let{items:u,...h}=await pn({collection:e,satellite:{...n,identity:Ot(n?.identity)},filter:a??{}}),m=pr();return{assets:u.map(({key:{full_path:v,token:B,name:M},headers:P,encodings:tt})=>{let rt=Ye(B);return{fullPath:v,name:M,downloadUrl:`${m}${v}${rt!==void 0?`?token=${rt}`:""}`,token:rt,headers:P,encodings:tt.reduce((ht,[Nt,{modified:bt,sha256:xt,total_length:vt}])=>({...ht,[Nt]:{modified:bt,sha256:bn(xt),total_length:vt}}),{})}}),...h}},af=async({storageFile:e,collection:n,satellite:a})=>yn({collection:n,storageFile:e,satellite:{...a,identity:Ot(a?.identity)}}),sf=async({collection:e,satellite:n})=>gn({collection:e,satellite:{...n,identity:Ot(n?.identity)}});var uf=async e=>{dt.getInstance().set(e),await hr()},hf=e=>Ct.getInstance().subscribe(e);export{hf as authSubscribe,Uo as delDoc,af as deleteAsset,sf as deleteAssets,cn as getDoc,uf as initDapp,ff as listAssets,Ro as listDocs,ln as setDoc,fi as signIn,ai as signOut,nf as uploadBlob,of as uploadFile};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|