class lt{isAvailable=!1;isInstantiated=!1;constructor(){typeof crypto<"u"&&"getRandomValues"in crypto&&(this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(r){if(!this.isAvailable)throw new Error("System random byte generator is not available.");const o=new Uint8Array(r);for(let t=0;t>16&1),o[a-1]&=65535;o[15]=t[15]-32767-(o[14]>>16&1);const i=o[15]>>16&1;o[14]&=65535,X(t,o,1-i)}for(let e=0;e<16;e++)n[2*e]=t[e]&255,n[2*e+1]=t[e]>>8}function Mt(n,r){for(let o=0;o<16;o++)n[o]=r[2*o]+(r[2*o+1]<<8);n[15]&=32767}function et(n,r,o){for(let t=0;t<16;t++)n[t]=r[t]+o[t]}function rt(n,r,o){for(let t=0;t<16;t++)n[t]=r[t]-o[t]}function G(n,r,o){let t,e,i=0,a=0,h=0,s=0,l=0,d=0,c=0,w=0,f=0,u=0,m=0,A=0,_=0,M=0,g=0,C=0,p=0,O=0,Q=0,V=0,N=0,Y=0,j=0,z=0,H=0,$=0,J=0,W=0,tt=0,ot=0,at=0,x=o[0],B=o[1],L=o[2],v=o[3],U=o[4],S=o[5],b=o[6],E=o[7],R=o[8],K=o[9],T=o[10],P=o[11],D=o[12],I=o[13],k=o[14],F=o[15];t=r[0],i+=t*x,a+=t*B,h+=t*L,s+=t*v,l+=t*U,d+=t*S,c+=t*b,w+=t*E,f+=t*R,u+=t*K,m+=t*T,A+=t*P,_+=t*D,M+=t*I,g+=t*k,C+=t*F,t=r[1],a+=t*x,h+=t*B,s+=t*L,l+=t*v,d+=t*U,c+=t*S,w+=t*b,f+=t*E,u+=t*R,m+=t*K,A+=t*T,_+=t*P,M+=t*D,g+=t*I,C+=t*k,p+=t*F,t=r[2],h+=t*x,s+=t*B,l+=t*L,d+=t*v,c+=t*U,w+=t*S,f+=t*b,u+=t*E,m+=t*R,A+=t*K,_+=t*T,M+=t*P,g+=t*D,C+=t*I,p+=t*k,O+=t*F,t=r[3],s+=t*x,l+=t*B,d+=t*L,c+=t*v,w+=t*U,f+=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k,J+=t*F,t=r[12],_+=t*x,M+=t*B,g+=t*L,C+=t*v,p+=t*U,O+=t*S,Q+=t*b,V+=t*E,N+=t*R,Y+=t*K,j+=t*T,z+=t*P,H+=t*D,$+=t*I,J+=t*k,W+=t*F,t=r[13],M+=t*x,g+=t*B,C+=t*L,p+=t*v,O+=t*U,Q+=t*S,V+=t*b,N+=t*E,Y+=t*R,j+=t*K,z+=t*T,H+=t*P,$+=t*D,J+=t*I,W+=t*k,tt+=t*F,t=r[14],g+=t*x,C+=t*B,p+=t*L,O+=t*v,Q+=t*U,V+=t*S,N+=t*b,Y+=t*E,j+=t*R,z+=t*K,H+=t*T,$+=t*P,J+=t*D,W+=t*I,tt+=t*k,ot+=t*F,t=r[15],C+=t*x,p+=t*B,O+=t*L,Q+=t*v,V+=t*U,N+=t*S,Y+=t*b,j+=t*E,z+=t*R,H+=t*K,$+=t*T,J+=t*P,W+=t*D,tt+=t*I,ot+=t*k,at+=t*F,i+=38*p,a+=38*O,h+=38*Q,s+=38*V,l+=38*N,d+=38*Y,c+=38*j,w+=38*z,f+=38*H,u+=38*$,m+=38*J,A+=38*W,_+=38*tt,M+=38*ot,g+=38*at,e=1,t=i+e+65535,e=Math.floor(t/65536),i=t-e*65536,t=a+e+65535,e=Math.floor(t/65536),a=t-e*65536,t=h+e+65535,e=Math.floor(t/65536),h=t-e*65536,t=s+e+65535,e=Math.floor(t/65536),s=t-e*65536,t=l+e+65535,e=Math.floor(t/65536),l=t-e*65536,t=d+e+65535,e=Math.floor(t/65536),d=t-e*65536,t=c+e+65535,e=Math.floor(t/65536),c=t-e*65536,t=w+e+65535,e=Math.floor(t/65536),w=t-e*65536,t=f+e+65535,e=Math.floor(t/65536),f=t-e*65536,t=u+e+65535,e=Math.floor(t/65536),u=t-e*65536,t=m+e+65535,e=Math.floor(t/65536),m=t-e*65536,t=A+e+65535,e=Math.floor(t/65536),A=t-e*65536,t=_+e+65535,e=Math.floor(t/65536),_=t-e*65536,t=M+e+65535,e=Math.floor(t/65536),M=t-e*65536,t=g+e+65535,e=Math.floor(t/65536),g=t-e*65536,t=C+e+65535,e=Math.floor(t/65536),C=t-e*65536,i+=e-1+37*(e-1),e=1,t=i+e+65535,e=Math.floor(t/65536),i=t-e*65536,t=a+e+65535,e=Math.floor(t/65536),a=t-e*65536,t=h+e+65535,e=Math.floor(t/65536),h=t-e*65536,t=s+e+65535,e=Math.floor(t/65536),s=t-e*65536,t=l+e+65535,e=Math.floor(t/65536),l=t-e*65536,t=d+e+65535,e=Math.floor(t/65536),d=t-e*65536,t=c+e+65535,e=Math.floor(t/65536),c=t-e*65536,t=w+e+65535,e=Math.floor(t/65536),w=t-e*65536,t=f+e+65535,e=Math.floor(t/65536),f=t-e*65536,t=u+e+65535,e=Math.floor(t/65536),u=t-e*65536,t=m+e+65535,e=Math.floor(t/65536),m=t-e*65536,t=A+e+65535,e=Math.floor(t/65536),A=t-e*65536,t=_+e+65535,e=Math.floor(t/65536),_=t-e*65536,t=M+e+65535,e=Math.floor(t/65536),M=t-e*65536,t=g+e+65535,e=Math.floor(t/65536),g=t-e*65536,t=C+e+65535,e=Math.floor(t/65536),C=t-e*65536,i+=e-1+37*(e-1),n[0]=i,n[1]=a,n[2]=h,n[3]=s,n[4]=l,n[5]=d,n[6]=c,n[7]=w,n[8]=f,n[9]=u,n[10]=m,n[11]=A,n[12]=_,n[13]=M,n[14]=g,n[15]=C}function Z(n,r){G(n,r,r)}function yt(n,r){const o=q();for(let t=0;t<16;t++)o[t]=r[t];for(let t=253;t>=0;t--)Z(o,o),t!==2&&t!==4&&G(o,o,r);for(let t=0;t<16;t++)n[t]=o[t]}function _t(n,r){const o=new Uint8Array(32),t=new Float64Array(80),e=q(),i=q(),a=q(),h=q(),s=q(),l=q();for(let f=0;f<31;f++)o[f]=n[f];o[31]=n[31]&127|64,o[0]&=248,Mt(t,r);for(let f=0;f<16;f++)i[f]=t[f];e[0]=h[0]=1;for(let f=254;f>=0;--f){const u=o[f>>>3]>>>(f&7)&1;X(e,i,u),X(a,h,u),et(s,e,a),rt(e,e,a),et(a,i,h),rt(i,i,h),Z(h,s),Z(l,e),G(e,a,e),G(a,i,s),et(s,e,a),rt(e,e,a),Z(i,e),rt(a,h,l),G(e,a,gt),et(e,e,h),G(a,a,e),G(e,h,l),G(h,i,t),Z(i,s),X(e,i,u),X(a,h,u)}for(let f=0;f<16;f++)t[f+16]=e[f],t[f+32]=a[f],t[f+48]=i[f],t[f+64]=h[f];const d=t.subarray(32),c=t.subarray(16);yt(d,d),G(c,c,d);const w=new Uint8Array(32);return Ct(w,c),w}function At(n){return _t(n,ft)}function wt(n){if(n.length!==it)throw new Error(`x25519: seed must be ${it} bytes`);const r=new Uint8Array(n);return{publicKey:At(r),secretKey:r}}function xt(n){const r=ut(32,n),o=wt(r);return ct(r),o}const y=256;class ht{_paddingCharacter;constructor(r="="){this._paddingCharacter=r}encodedLength(r){return this._paddingCharacter?(r+2)/3*4|0:(r*8+5)/6|0}encode(r){let o="",t=0;for(;t>>18&63),o+=this._encodeByte(i>>>12&63),o+=this._encodeByte(i>>>6&63),o+=this._encodeByte(i>>>0&63)}const e=r.length-t;if(e>0){let i=r[t]<<16|(e===2?r[t+1]<<8:0);o+=this._encodeByte(i>>>18&63),o+=this._encodeByte(i>>>12&63),e===2?o+=this._encodeByte(i>>>6&63):o+=this._paddingCharacter||"",o+=this._paddingCharacter||""}return o}maxDecodedLength(r){return this._paddingCharacter?r/4*3|0:(r*6+7)/8|0}decodedLength(r){return this.maxDecodedLength(r.length-this._getPaddingLength(r))}decode(r){if(r.length===0)return new Uint8Array(0);const o=this._getPaddingLength(r),t=r.length-o,e=new Uint8Array(this.maxDecodedLength(t));let i=0,a=0,h=0,s=0,l=0,d=0,c=0;for(;a>>4,e[i++]=l<<4|d>>>2,e[i++]=d<<6|c,h|=s&y,h|=l&y,h|=d&y,h|=c&y;if(a>>4,h|=s&y,h|=l&y),a>>2,h|=d&y),a>>8&6,o+=51-r>>>8&-75,o+=61-r>>>8&-15,o+=62-r>>>8&3,String.fromCharCode(o)}_decodeChar(r){let o=y;return o+=(42-r&r-44)>>>8&-y+r-43+62,o+=(46-r&r-48)>>>8&-y+r-47+63,o+=(47-r&r-58)>>>8&-y+r-48+52,o+=(64-r&r-91)>>>8&-y+r-65+0,o+=(96-r&r-123)>>>8&-y+r-97+26,o}_getPaddingLength(r){let o=0;if(this._paddingCharacter){for(let t=r.length-1;t>=0&&r[t]===this._paddingCharacter;t--)o++;if(r.length<4||o>2)throw new Error("Base64Coder: incorrect padding")}return o}}const dt=new ht;function Bt(n){return dt.encode(n)}function Lt(n){return dt.decode(n)}class mt extends ht{_encodeByte(r){let o=r;return o+=65,o+=25-r>>>8&6,o+=51-r>>>8&-75,o+=61-r>>>8&-13,o+=62-r>>>8&49,String.fromCharCode(o)}_decodeChar(r){let o=y;return o+=(44-r&r-46)>>>8&-y+r-45+62,o+=(94-r&r-96)>>>8&-y+r-95+63,o+=(47-r&r-58)>>>8&-y+r-48+52,o+=(64-r&r-91)>>>8&-y+r-65+0,o+=(96-r&r-123)>>>8&-y+r-97+26,o}}const pt=new mt;function vt(n){return pt.encode(n)}export{Bt as a,Lt as d,vt as e,xt as g};