/* esm.sh - @noble/hashes@1.8.0/argon2 */ var Q=BigInt(4294967295),pt=BigInt(32);function xt(t,e=!1){return e?{h:Number(t&Q),l:Number(t>>pt&Q)}:{h:Number(t>>pt&Q)|0,l:Number(t&Q)|0}}var X=(t,e,n)=>t>>>n|e<<32-n,P=(t,e,n)=>t<<32-n|e>>>n,$=(t,e,n)=>t<<64-n|e>>>n-32,K=(t,e,n)=>t>>>n-32|e<<64-n,tt=(t,e)=>e,et=(t,e)=>t;function st(t,e,n,s){let h=(e>>>0)+(s>>>0);return{h:t+n+(h/2**32|0)|0,l:h|0}}var Z=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),q=(t,e,n,s)=>e+n+s+(t/2**32|0)|0;function St(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function O(t,...e){if(!St(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ht(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function bt(t,e){O(t);let n=e.outputLen;if(t.length>>8&65280|t>>>24&255}var D=wt?t=>t:t=>yt(t);function Ot(t){for(let e=0;et:Ot;var gt=async()=>{};function Bt(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function R(t){return typeof t=="string"&&(t=Bt(t)),O(t),t}function ot(t){return typeof t=="string"&&(t=Bt(t)),O(t),t}var nt=class{};function At(t){let e=(s,h)=>t(h).update(R(s)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=s=>t(s),e}var mt=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);var B=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),l=new Uint32Array(32);function _(t,e,n,s,h,r){let i=h[r],o=h[r+1],c=l[2*t],f=l[2*t+1],a=l[2*e],u=l[2*e+1],x=l[2*n],b=l[2*n+1],p=l[2*s],d=l[2*s+1],g=Z(c,a,i);f=q(g,f,u,o),c=g|0,{Dh:d,Dl:p}={Dh:d^f,Dl:p^c},{Dh:d,Dl:p}={Dh:tt(d,p),Dl:et(d,p)},{h:b,l:x}=st(b,x,d,p),{Bh:u,Bl:a}={Bh:u^b,Bl:a^x},{Bh:u,Bl:a}={Bh:X(u,a,24),Bl:P(u,a,24)},l[2*t]=c,l[2*t+1]=f,l[2*e]=a,l[2*e+1]=u,l[2*n]=x,l[2*n+1]=b,l[2*s]=p,l[2*s+1]=d}function T(t,e,n,s,h,r){let i=h[r],o=h[r+1],c=l[2*t],f=l[2*t+1],a=l[2*e],u=l[2*e+1],x=l[2*n],b=l[2*n+1],p=l[2*s],d=l[2*s+1],g=Z(c,a,i);f=q(g,f,u,o),c=g|0,{Dh:d,Dl:p}={Dh:d^f,Dl:p^c},{Dh:d,Dl:p}={Dh:X(d,p,16),Dl:P(d,p,16)},{h:b,l:x}=st(b,x,d,p),{Bh:u,Bl:a}={Bh:u^b,Bl:a^x},{Bh:u,Bl:a}={Bh:$(u,a,63),Bl:K(u,a,63)},l[2*t]=c,l[2*t+1]=f,l[2*e]=a,l[2*e+1]=u,l[2*n]=x,l[2*n+1]=b,l[2*s]=p,l[2*s+1]=d}function _t(t,e={},n,s,h){if(rt(n),t<0||t>n)throw new Error("outputLen bigger than keyLen");let{key:r,salt:i,personalization:o}=e;if(r!==void 0&&(r.length<1||r.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==s)throw new Error("salt must be undefined or "+s);if(o!==void 0&&o.length!==h)throw new Error("personalization must be undefined or "+h)}var lt=class extends nt{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,rt(e),rt(n),this.blockLen=e,this.outputLen=n,this.buffer=new Uint8Array(e),this.buffer32=G(this.buffer)}update(e){ht(this),e=R(e),O(e);let{blockLen:n,buffer:s,buffer32:h}=this,r=e.length,i=e.byteOffset,o=e.buffer;for(let c=0;ch[i]=D(r))}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let s=e.slice(0,n);return this.destroy(),s}_cloneInto(e){let{buffer:n,length:s,finished:h,destroyed:r,outputLen:i,pos:o}=this;return e||(e=new this.constructor({dkLen:i})),e.set(...this.get()),e.buffer.set(n),e.destroyed=r,e.finished=h,e.length=s,e.pos=o,e.outputLen=i,e}clone(){return this._cloneInto()}},ct=class extends lt{constructor(e={}){let n=e.dkLen===void 0?64:e.dkLen;super(128,n),this.v0l=B[0]|0,this.v0h=B[1]|0,this.v1l=B[2]|0,this.v1h=B[3]|0,this.v2l=B[4]|0,this.v2h=B[5]|0,this.v3l=B[6]|0,this.v3h=B[7]|0,this.v4l=B[8]|0,this.v4h=B[9]|0,this.v5l=B[10]|0,this.v5h=B[11]|0,this.v6l=B[12]|0,this.v6h=B[13]|0,this.v7l=B[14]|0,this.v7h=B[15]|0,_t(n,e,64,16,16);let{key:s,personalization:h,salt:r}=e,i=0;if(s!==void 0&&(s=R(s),i=s.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,r!==void 0){r=R(r);let o=G(r);this.v4l^=D(o[0]),this.v4h^=D(o[1]),this.v5l^=D(o[2]),this.v5h^=D(o[3])}if(h!==void 0){h=R(h);let o=G(h);this.v6l^=D(o[0]),this.v6h^=D(o[1]),this.v7l^=D(o[2]),this.v7h^=D(o[3])}if(s!==void 0){let o=new Uint8Array(this.blockLen);o.set(s),this.update(o)}}get(){let{v0l:e,v0h:n,v1l:s,v1h:h,v2l:r,v2h:i,v3l:o,v3h:c,v4l:f,v4h:a,v5l:u,v5h:x,v6l:b,v6h:p,v7l:d,v7h:g}=this;return[e,n,s,h,r,i,o,c,f,a,u,x,b,p,d,g]}set(e,n,s,h,r,i,o,c,f,a,u,x,b,p,d,g){this.v0l=e|0,this.v0h=n|0,this.v1l=s|0,this.v1h=h|0,this.v2l=r|0,this.v2h=i|0,this.v3l=o|0,this.v3h=c|0,this.v4l=f|0,this.v4h=a|0,this.v5l=u|0,this.v5h=x|0,this.v6l=b|0,this.v6h=p|0,this.v7l=d|0,this.v7h=g|0}compress(e,n,s){this.get().forEach((c,f)=>l[f]=c),l.set(B,16);let{h,l:r}=xt(BigInt(this.length));l[24]=B[8]^r,l[25]=B[9]^h,s&&(l[28]=~l[28],l[29]=~l[29]);let i=0,o=mt;for(let c=0;c<12;c++)_(0,4,8,12,e,n+2*o[i++]),T(0,4,8,12,e,n+2*o[i++]),_(1,5,9,13,e,n+2*o[i++]),T(1,5,9,13,e,n+2*o[i++]),_(2,6,10,14,e,n+2*o[i++]),T(2,6,10,14,e,n+2*o[i++]),_(3,7,11,15,e,n+2*o[i++]),T(3,7,11,15,e,n+2*o[i++]),_(0,5,10,15,e,n+2*o[i++]),T(0,5,10,15,e,n+2*o[i++]),_(1,6,11,12,e,n+2*o[i++]),T(1,6,11,12,e,n+2*o[i++]),_(2,7,8,13,e,n+2*o[i++]),T(2,7,8,13,e,n+2*o[i++]),_(3,4,9,14,e,n+2*o[i++]),T(3,4,9,14,e,n+2*o[i++]);this.v0l^=l[0]^l[16],this.v0h^=l[1]^l[17],this.v1l^=l[2]^l[18],this.v1h^=l[3]^l[19],this.v2l^=l[4]^l[20],this.v2h^=l[5]^l[21],this.v3l^=l[6]^l[22],this.v3h^=l[7]^l[23],this.v4l^=l[8]^l[24],this.v4h^=l[9]^l[25],this.v5l^=l[10]^l[26],this.v5h^=l[11]^l[27],this.v6l^=l[12]^l[28],this.v6h^=l[13]^l[29],this.v7l^=l[14]^l[30],this.v7h^=l[15]^l[31],H(l)}destroy(){this.destroyed=!0,H(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},W=At(t=>new ct(t));var E={Argond2d:0,Argon2i:1,Argon2id:2},Y=4,kt=t=>t===void 0?Uint8Array.of():ot(t);function ft(t,e){let n=t&65535,s=t>>>16,h=e&65535,r=e>>>16,i=Math.imul(n,h),o=Math.imul(s,h),c=Math.imul(n,r),f=Math.imul(s,r),a=(i>>>16)+(o&65535)+c,u=f+(o>>>16)+(a>>>16)|0,x=a<<16|i&65535;return{h:u,l:x}}function Tt(t,e){let{h:n,l:s}=ft(t,e);return{h:(n<<1|s>>>31)&4294967295,l:s<<1&4294967295}}function it(t,e,n,s){let{h,l:r}=Tt(e,s),i=Z(e,s,r);return{h:q(i,t,n,h),l:i|0}}var y=new Uint32Array(256);function M(t,e,n,s){let h=y[2*t],r=y[2*t+1],i=y[2*e],o=y[2*e+1],c=y[2*n],f=y[2*n+1],a=y[2*s],u=y[2*s+1];({h:r,l:h}=it(r,h,o,i)),{Dh:u,Dl:a}={Dh:u^r,Dl:a^h},{Dh:u,Dl:a}={Dh:tt(u,a),Dl:et(u,a)},{h:f,l:c}=it(f,c,u,a),{Bh:o,Bl:i}={Bh:o^f,Bl:i^c},{Bh:o,Bl:i}={Bh:X(o,i,24),Bl:P(o,i,24)},{h:r,l:h}=it(r,h,o,i),{Dh:u,Dl:a}={Dh:u^r,Dl:a^h},{Dh:u,Dl:a}={Dh:X(u,a,16),Dl:P(u,a,16)},{h:f,l:c}=it(f,c,u,a),{Bh:o,Bl:i}={Bh:o^f,Bl:i^c},{Bh:o,Bl:i}={Bh:$(o,i,63),Bl:K(o,i,63)},y[2*t]=h,y[2*t+1]=r,y[2*e]=i,y[2*e+1]=o,y[2*n]=c,y[2*n+1]=f,y[2*s]=a,y[2*s+1]=u}function Lt(t,e,n,s,h,r,i,o,c,f,a,u,x,b,p,d){M(t,h,c,x),M(e,r,f,b),M(n,i,a,p),M(s,o,u,d),M(t,r,a,d),M(e,i,u,x),M(n,o,c,b),M(s,h,f,p)}function j(t,e,n,s,h){for(let r=0;r<256;r++)y[r]=t[e+r]^t[n+r];for(let r=0;r<128;r+=16)Lt(r,r+1,r+2,r+3,r+4,r+5,r+6,r+7,r+8,r+9,r+10,r+11,r+12,r+13,r+14,r+15);for(let r=0;r<16;r+=2)Lt(r,r+1,r+16,r+17,r+32,r+33,r+48,r+49,r+64,r+65,r+80,r+81,r+96,r+97,r+112,r+113);if(h)for(let r=0;r<256;r++)t[s+r]^=y[r]^t[e+r]^t[n+r];else for(let r=0;r<256;r++)t[s+r]=y[r]^t[e+r]^t[n+r];H(y)}function ut(t,e){let n=z(t),s=new Uint32Array(1),h=z(s);if(s[0]=e,e<=64)return W.create({dkLen:e}).update(h).update(n).digest();let r=new Uint8Array(e),i=W.create({}).update(h).update(n).digest(),o=0;for(r.set(i.subarray(0,32)),o+=32;e-o>64;o+=32){let c=W.create({}).update(i);c.digestInto(i),c.destroy(),r.set(i.subarray(0,32),o)}return r.set(W(i,{dkLen:e-o}),o),H(i,s),G(r)}function Mt(t,e,n,s,h,r,i=!1){let o;t===0?e===0?o=h-1:i?o=e*s+h-1:o=e*s+(h==0?-1:0):i?o=n-s+h-1:o=n-s+(h==0?-1:0);let c=t!==0&&e!==Y-1?(e+1)*s:0,f=o-1-ft(o,ft(r,r).h).h;return(c+f)%n}var Ut=Math.pow(2,32);function C(t){return Number.isSafeInteger(t)&&t>=0&&t=Math.pow(2,24))throw new Error("p should be 1 <= p < 2^24");if(!C(h))throw new Error("m should be 0 <= m < 2^32");if(!C(r)||r<1)throw new Error("t (iterations) should be 1 <= t < 2^32");if(o!==void 0&&typeof o!="function")throw new Error("progressCb should be function");if(!C(h)||h<8*s)throw new Error("memory should be at least 8*p bytes");if(i!==16&&i!==19)throw new Error("unknown version="+i);return e}function Ht(t,e,n,s){if(t=ot(t),e=ot(e),O(t),O(e),!C(t.length))throw new Error("password should be less than 4 GB");if(!C(e.length)||e.length<8)throw new Error("salt should be at least 8 bytes and less than 4 GB");if(!Object.values(E).includes(n))throw new Error("invalid type");let{p:h,dkLen:r,m:i,t:o,version:c,key:f,personalization:a,maxmem:u,onProgress:x,asyncTick:b}=Ct(s);f=kt(f),a=kt(a);let p=W.create({}),d=new Uint32Array(1),g=z(d);for(let A of[h,r,i,o,c,n])d[0]=A,p.update(g);for(let A of[t,e,f,a])d[0]=A.length,p.update(g).update(A);let w=new Uint32Array(18),L=z(w);p.digestInto(L);let m=h,I=4*h*Math.floor(i/(Y*h)),k=Math.floor(I/h),S=Math.floor(k/Y),U=I*256;if(!C(u)||U>u)throw new Error("mem should be less than 2**32, got: maxmem="+u+", memused="+U);let N=new Uint32Array(U);for(let A=0;A{};if(x){let A=o*Y*h*S,v=Math.max(Math.floor(A/1e4),1),J=0;F=()=>{J++,x&&(!(J%v)||J===A)&&x(J/A)}}return H(d,w),{type:n,mP:I,p:h,t:o,version:c,B:N,laneLen:k,lanes:m,segmentLen:S,dkLen:r,perBlock:F,asyncTick:b}}function Et(t,e,n,s){let h=new Uint32Array(256);for(let i=0;iat(E.Argond2d,t,e,n),Zt=(t,e,n)=>at(E.Argon2i,t,e,n),qt=(t,e,n)=>at(E.Argon2id,t,e,n);async function dt(t,e,n,s){let{mP:h,p:r,t:i,version:o,B:c,laneLen:f,lanes:a,segmentLen:u,dkLen:x,perBlock:b,asyncTick:p}=Ht(e,n,t,s),d=new Uint32Array(3*256);d[262]=h,d[264]=i,d[266]=t;let g=Date.now();for(let w=0;w=0&&Adt(E.Argond2d,t,e,n),Jt=(t,e,n)=>dt(E.Argon2i,t,e,n),Qt=(t,e,n)=>dt(E.Argon2id,t,e,n);export{Yt as argon2d,vt as argon2dAsync,Zt as argon2i,Jt as argon2iAsync,qt as argon2id,Qt as argon2idAsync}; /*! Bundled license information: @noble/hashes/esm/utils.js: (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *) */