/* esm.sh - @noble/hashes@1.8.0/_md */
import{Hash as p,abytes as l,aexists as a,aoutput as g,clean as y,createView as b,toBytes as w}from"./utils.mjs";function I(o,t,e,n){if(typeof o.setBigUint64=="function")return o.setBigUint64(t,e,n);let i=BigInt(32),f=BigInt(4294967295),s=Number(e>>i&f),r=Number(e&f),c=n?4:0,x=n?0:4;o.setUint32(t+c,s,n),o.setUint32(t+x,r,n)}function _(o,t,e){return o&t^~o&e}function m(o,t,e){return o&t^o&e^t&e}var d=class extends p{constructor(t,e,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=b(this.buffer)}update(t){a(this),t=w(t),l(t);let{view:e,buffer:n,blockLen:i}=this,f=t.length;for(let s=0;s<f;){let r=Math.min(i-this.pos,f-s);if(r===i){let c=b(t);for(;i<=f-s;s+=i)this.process(c,s);continue}n.set(t.subarray(s,s+r),this.pos),this.pos+=r,s+=r,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){a(this),g(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:f}=this,{pos:s}=this;e[s++]=128,y(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(n,0),s=0);for(let h=s;h<i;h++)e[h]=0;I(n,i-8,BigInt(this.length*8),f),this.process(n,0);let r=b(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let x=c/4,u=this.get();if(x>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<x;h++)r.setUint32(4*h,u[h],f)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:f,destroyed:s,pos:r}=this;return t.destroyed=s,t.finished=f,t.length=i,t.pos=r,i%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},A=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),B=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),L=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),V=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);export{_ as Chi,d as HashMD,m as Maj,B as SHA224_IV,A as SHA256_IV,L as SHA384_IV,V as SHA512_IV,I as setBigUint64};
//# sourceMappingURL=_md.mjs.map