import{m as D,__tla as __tla_0}from"./debounce-D1Adyjvd.js";import{w as F}from"./english-DcJvXDRI.js";import{aD as T,aE as x,aF as H,aG as _,aH as O,aI as E,aJ as C,aK as M,aL as z,aM as K,aj as N,__tla as __tla_1}from"./_virtual_wxt-plugins-D2Qy6pl9.js";import{h as v,b as g,__tla as __tla_2}from"./headers-DBBLE3ii.js";let cn,dn,on,yn;let __tla=Promise.all([(()=>{try{return __tla_0}catch{}})(),(()=>{try{return __tla_1}catch{}})(),(()=>{try{return __tla_2}catch{}})()]).then(async()=>{const U=T;function W(n,e,t,s){_(n);const r=O({dkLen:32,asyncTick:10},s),{c:a,dkLen:c,asyncTick:l}=r;if(E(a),E(c),E(l),a<1)throw new Error("iterations (c) should be >= 1");const i=C(e),o=C(t),d=new Uint8Array(c),u=v.create(n,i),p=u._cloneInto().update(o);return{c:a,dkLen:c,asyncTick:l,DK:d,PRF:u,PRFSalt:p}}function j(n,e,t,s,r){return n.destroy(),e.destroy(),s&&s.destroy(),M(r),t}async function G(n,e,t,s){const{c:r,dkLen:a,asyncTick:c,DK:l,PRF:i,PRFSalt:o}=W(n,e,t,s);let d;const u=new Uint8Array(4),p=x(u),y=new Uint8Array(i.outputLen);for(let R=1,w=0;w<a;R++,w+=i.outputLen){const A=l.subarray(w,w+i.outputLen);p.setInt32(0,R,!1),(d=o._cloneInto(d)).update(u).digestInto(y),A.set(y.subarray(0,A.length)),await H(r-1,c,()=>{i._cloneInto(d).update(y).digestInto(y);for(let L=0;L<A.length;L++)A[L]^=y[L]})}return j(i,o,l,d,y)}const h=0x80000000,J=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn;async function V(n){const e=await G(U,new Uint8Array(0),n,{c:4096,dkLen:96,asyncTick:10}),t=e.slice(0,32),s=e.slice(32,64),r=e.slice(64,96);return e.fill(0),t[0]&=248,t[31]&=31,t[31]|=64,{kL:t,kR:s,cc:r}}function f(n){n.kL.fill(0),n.kR.fill(0),n.cc.fill(0)}function $(n){const e=new Uint8Array(4);return e[0]=n&255,e[1]=n>>8&255,e[2]=n>>16&255,e[3]=n>>24&255,e}function P(n,e){const t=new Uint8Array(32);let s=0;for(let r=0;r<32;r++){const a=(n[r]||0)+(e[r]||0)+s;t[r]=a&255,s=a>>8}return t}function q(n,e){const t=new Uint8Array(32);let s=0;for(let r=0;r<28;r++){const a=n[r]<<3|s;t[r]=a&255,s=a>>8}return s&&(t[28]=s),P(t,e)}function Q(n){let e=0n;for(let t=n.length-1;t>=0;t--)e=e<<8n|BigInt(n[t]);return e}function k(n){const e=Q(n)%J;return z.Point.BASE.multiply(e).toBytes()}function X(n,e){const t=e>=h,s=$(e),r=k(n.kL),a=t?new Uint8Array(69):new Uint8Array(37);a[0]=t?0:2,t?(a.set(n.kL,1),a.set(n.kR,33),a.set(s,65)):(a.set(r,1),a.set(s,33));const c=v(U,n.cc,a),l=q(c.slice(0,28),n.kL),i=P(c.slice(32,64),n.kR),o=t?new Uint8Array(69):new Uint8Array(37);o[0]=t?1:3,t?(o.set(n.kL,1),o.set(n.kR,33),o.set(s,65)):(o.set(r,1),o.set(s,33));const d=v(U,n.cc,o).slice(32,64);return r.fill(0),c.fill(0),a.fill(0),o.fill(0),{kL:l,kR:i,cc:d}}function m(n,e){let t=n;for(const s of e){const r=t;t=X(t,s),r!==n&&f(r)}return t}async function I(n,e,t){const s=new Uint8Array(n),r=await V(s),a=m(r,[1852+h,1815+h,e+h]);try{return await t(a)}finally{s.fill(0),f(r),f(a)}}function Y(n,e){const t=m(n,[0,0]),s=m(n,[1,0]),r=m(n,[2,0]);try{const a=g(k(t.kL),{dkLen:28}),c=g(k(s.kL),{dkLen:28}),l=k(r.kL),i=g(l,{dkLen:28}),o=e==="mainnet"?1:0,d=p=>{const y=new Uint8Array(57);return y[0]=o,y.set(p,1),y.set(i,29),K.encode(o===1?"addr":"addr_test",K.toWords(y),1023)},u=new Uint8Array(29);return u[0]=224|o,u.set(i,1),{baseAddress:d(a),changeAddress:d(c),rewardAddress:K.encode(o===1?"stake":"stake_test",K.toWords(u),1023)}}finally{f(t),f(s),f(r)}}function S(n,e=0,t="mainnet"){return I(n,e,s=>Y(s,t))}async function Z(n,e=0,t="mainnet"){return(await S(n,e,t)).baseAddress}function B(n,e=0){return I(n,e,t=>{const s=m(t,[0,0]),r=m(t,[2,0]);try{const a=new Uint8Array(64);a.set(s.kL,0),a.set(s.kR,32);const c=new Uint8Array(64);return c.set(r.kL,0),c.set(r.kR,32),{paymentExtendedPrivateKey:a,paymentPublicKey:k(s.kL),stakeExtendedPrivateKey:c,stakePublicKey:k(r.kL)}}finally{f(s),f(r)}})}async function nn(n,e=0){const{paymentExtendedPrivateKey:t,paymentPublicKey:s}=await B(n,e);return{extendedPrivateKey:t,publicKey:s}}function tn(n){const e=D(n,F);return typeof e=="string"?N(e):Uint8Array.from(e)}async function b(n,e){const t=tn(n);try{return await e(t)}finally{t.fill(0)}}on=function(n,e=0,t="mainnet"){return b(n,s=>S(s,e,t))};cn=function(n,e=0,t="mainnet"){return b(n,s=>Z(s,e,t))};dn=function(n,e=0){return b(n,t=>B(t,e))};yn=function(n,e=0){return b(n,t=>nn(t,e))}});export{cn as a,dn as b,on as c,yn as d,__tla};