edge-currency-accountbased 4.12.2 → 4.13.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.13.0 (2024-07-16)
6
+
7
+ - changed: FIO SDK upgraded to v1.9.2
8
+ - changed: `getFioNames` call changed to separate `getFioAddresses` and `getFioDomains` calls
9
+
5
10
  ## 4.12.2 (2024-07-15)
6
11
 
7
12
  - fixed: FIO payment wallet connection error, using a temporary workaround while FIO resolves the issue with their network
@@ -1,4 +1,4 @@
1
- var Ot=Object.defineProperty;var Lt=(ne,s,k)=>s in ne?Ot(ne,s,{enumerable:!0,configurable:!0,writable:!0,value:k}):ne[s]=k;var x=(ne,s,k)=>(Lt(ne,typeof s!="symbol"?s+"":s,k),k);(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[1700],{73513:function(ne,s,k){"use strict";var B=k(48287).Buffer,f=k(9598),v=k(39615),A=k(22623);function b(h){var D=Object.create(null);return h&&Object.keys(h).forEach(function(Y){if(Y!=="default"){var ue=Object.getOwnPropertyDescriptor(h,Y);Object.defineProperty(D,Y,ue.get?ue:{enumerable:!0,get:function(){return h[Y]}})}}),D.default=h,Object.freeze(D)}var a=b(f);a.utils.hmacSha256Sync=(h,...D)=>v.hmac(A.sha256,h,a.utils.concatBytes(...D)),a.utils.sha256Sync=(...h)=>A.sha256(a.utils.concatBytes(...h));const d=a.utils._normalizePrivateKey,w=32,i=32,E=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),y=32;function R(h,D){for(let Y=0;Y<32;++Y)if(h[Y]!==D[Y])return h[Y]<D[Y]?-1:1;return 0}function F(h){return!(!(h instanceof Uint8Array)||h.length!==i||R(h,E)>=0)}function V(h){return h instanceof Uint8Array&&h.length===64&&R(h.subarray(0,32),E)<0&&R(h.subarray(32,64),E)<0}function U(h){return h instanceof Uint8Array&&h.length===w}function G(h){return h===void 0||h instanceof Uint8Array&&h.length===y}function I(h){if(typeof h!="string")throw new TypeError("hexToNumber: expected string, got "+typeof h);return BigInt(`0x${h}`)}function C(h){return I(a.utils.bytesToHex(h))}function K(h){let D;if(typeof h=="bigint")D=h;else if(typeof h=="number"&&Number.isSafeInteger(h)&&h>=0)D=BigInt(h);else if(typeof h=="string"){if(h.length!==64)throw new Error("Expected 32 bytes of private scalar");D=I(h)}else if(h instanceof Uint8Array){if(h.length!==32)throw new Error("Expected 32 bytes of private scalar");D=C(h)}else throw new TypeError("Expected valid private scalar");if(D<0)throw new Error("Expected private scalar >= 0");return D}const O=(h,D)=>{const Y=d(h),ue=K(D),ye=a.utils._bigintTo32Bytes(a.utils.mod(Y+ue,a.CURVE.n));return a.utils.isValidPrivateKey(ye)?ye:null},X=(h,D)=>{const Y=d(h),ue=K(D),ye=a.utils._bigintTo32Bytes(a.utils.mod(Y-ue,a.CURVE.n));return a.utils.isValidPrivateKey(ye)?ye:null},Z=h=>{const D=d(h),Y=a.utils._bigintTo32Bytes(a.CURVE.n-D);return a.utils.isValidPrivateKey(Y)?Y:null},ee=(h,D,Y)=>{const ue=a.Point.fromHex(h),ye=K(D),pe=a.Point.BASE.multiplyAndAddUnsafe(ue,ye,1n);if(!pe)throw new Error("Tweaked point at infinity");return pe.toRawBytes(Y)},ge=(h,D,Y)=>{const ue=a.Point.fromHex(h),ye=typeof D=="string"?D:a.utils.bytesToHex(D),pe=BigInt(`0x${ye}`);return ue.multiply(pe).toRawBytes(Y)};function Ee(h,D){return h===void 0?D!==void 0?l(D):!0:!!h}function fe(h){try{return h()}catch{return null}}function S(h,D){if(h.length===32!==D)return!1;try{return!!a.Point.fromHex(h)}catch{return!1}}function g(h){return S(h,!1)}function l(h){return S(h,!1)&&h.length===33}function P(h){return a.utils.isValidPrivateKey(h)}function N(h){return S(h,!0)}function M(h,D){if(!N(h))throw new Error("Expected Point");if(!F(D))throw new Error("Expected Tweak");return fe(()=>{const Y=ee(h,D,!0);return{parity:Y[0]%2===1?1:0,xOnlyPubkey:Y.slice(1)}})}function $(h){if(!g(h))throw new Error("Expected Point");return h.slice(1,33)}function oe(h,D){if(!P(h))throw new Error("Expected Private");return fe(()=>a.getPublicKey(h,Ee(D)))}function se(h){if(!P(h))throw new Error("Expected Private");return $(oe(h))}function ae(h,D){if(!g(h))throw new Error("Expected Point");return a.Point.fromHex(h).toRawBytes(Ee(D,h))}function Q(h,D,Y){if(!g(h))throw new Error("Expected Point");if(!F(D))throw new Error("Expected Tweak");return fe(()=>ge(h,D,Ee(Y,h)))}function he(h,D,Y){if(!g(h)||!g(D))throw new Error("Expected Point");return fe(()=>{const ue=a.Point.fromHex(h),ye=a.Point.fromHex(D);return ue.equals(ye.negate())?null:ue.add(ye).toRawBytes(Ee(Y,h))})}function z(h,D,Y){if(!g(h))throw new Error("Expected Point");if(!F(D))throw new Error("Expected Tweak");return fe(()=>ee(h,D,Ee(Y,h)))}function be(h,D){if(P(h)===!1)throw new Error("Expected Private");if(F(D)===!1)throw new Error("Expected Tweak");return fe(()=>O(h,D))}function Ie(h,D){if(P(h)===!1)throw new Error("Expected Private");if(F(D)===!1)throw new Error("Expected Tweak");return fe(()=>X(h,D))}function me(h){if(P(h)===!1)throw new Error("Expected Private");return Z(h)}function Pe(h,D,Y){if(!P(D))throw new Error("Expected Private");if(!U(h))throw new Error("Expected Scalar");if(!G(Y))throw new Error("Expected Extra Data (32 bytes)");return a.signSync(h,D,{der:!1,extraEntropy:Y})}function Me(h,D,Y=B.alloc(32,0)){if(!P(D))throw new Error("Expected Private");if(!U(h))throw new Error("Expected Scalar");if(!G(Y))throw new Error("Expected Extra Data (32 bytes)");return a.schnorr.signSync(h,D,Y)}function He(h,D,Y,ue){if(!g(D))throw new Error("Expected Point");if(!V(Y))throw new Error("Expected Signature");if(!U(h))throw new Error("Expected Scalar");return a.verify(Y,h,D,{strict:ue})}function Ne(h,D,Y){if(!N(D))throw new Error("Expected Point");if(!V(Y))throw new Error("Expected Signature");if(!U(h))throw new Error("Expected Scalar");return a.schnorr.verifySync(Y,h,D)}s.isPoint=g,s.isPointCompressed=l,s.isPrivate=P,s.isXOnlyPoint=N,s.pointAdd=he,s.pointAddScalar=z,s.pointCompress=ae,s.pointFromScalar=oe,s.pointMultiply=Q,s.privateAdd=be,s.privateNegate=me,s.privateSub=Ie,s.sign=Pe,s.signSchnorr=Me,s.verify=He,s.verifySchnorr=Ne,s.xOnlyPointAddTweak=M,s.xOnlyPointFromPoint=$,s.xOnlyPointFromScalar=se},9598:function(ne,s,k){"use strict";/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(s,"__esModule",{value:!0}),s.utils=s.schnorr=s.verify=s.signSync=s.sign=s.getSharedSecret=s.recoverPublicKey=s.getPublicKey=s.Signature=s.Point=s.CURVE=void 0;const B=k(14923),f=BigInt(0),v=BigInt(1),A=BigInt(2),b=BigInt(3),a=BigInt(8),d=Object.freeze({a:f,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:v,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});s.CURVE=d;const w=(n,e)=>(n+e/A)/e,i={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(n){const{n:e}=d,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),u=-v*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),m=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),T=r,H=BigInt("0x100000000000000000000000000000000"),j=w(T*n,e),q=w(-u*n,e);let W=z(n-j*r-q*m,e),J=z(-j*u-q*T,e);const te=W>H,re=J>H;if(te&&(W=e-W),re&&(J=e-J),W>H||J>H)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:te,k1:W,k2neg:re,k2:J}}},E=32,y=32,R=32,F=E+1,V=2*E+1;function U(n){const{a:e,b:r}=d,u=z(n*n),m=z(u*n);return z(m+e*n+r)}const G=d.a===f;class I extends Error{constructor(e){super(e)}}function C(n){if(!(n instanceof K))throw new TypeError("JacobianPoint expected")}class K{constructor(e,r,u){this.x=e,this.y=r,this.z=u}static fromAffine(e){if(!(e instanceof Z))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Z.ZERO)?K.ZERO:new K(e.x,e.y,v)}static toAffineBatch(e){const r=Pe(e.map(u=>u.z));return e.map((u,m)=>u.toAffine(r[m]))}static normalizeZ(e){return K.toAffineBatch(e).map(K.fromAffine)}equals(e){C(e);const{x:r,y:u,z:m}=this,{x:T,y:H,z:j}=e,q=z(m*m),W=z(j*j),J=z(r*W),te=z(T*q),re=z(z(u*j)*W),de=z(z(H*m)*q);return J===te&&re===de}negate(){return new K(this.x,z(-this.y),this.z)}double(){const{x:e,y:r,z:u}=this,m=z(e*e),T=z(r*r),H=z(T*T),j=e+T,q=z(A*(z(j*j)-m-H)),W=z(b*m),J=z(W*W),te=z(J-A*q),re=z(W*(q-te)-a*H),de=z(A*r*u);return new K(te,re,de)}add(e){C(e);const{x:r,y:u,z:m}=this,{x:T,y:H,z:j}=e;if(T===f||H===f)return this;if(r===f||u===f)return e;const q=z(m*m),W=z(j*j),J=z(r*W),te=z(T*q),re=z(z(u*j)*W),de=z(z(H*m)*q),le=z(te-J),xe=z(de-re);if(le===f)return xe===f?this.double():K.ZERO;const Se=z(le*le),Le=z(le*Se),De=z(J*Se),$e=z(xe*xe-Le-A*De),Ve=z(xe*(De-$e)-re*Le),Fe=z(m*j*le);return new K($e,Ve,Fe)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const r=K.ZERO;if(typeof e=="bigint"&&e===f)return r;let u=he(e);if(u===v)return this;if(!G){let te=r,re=this;for(;u>f;)u&v&&(te=te.add(re)),re=re.double(),u>>=v;return te}let{k1neg:m,k1:T,k2neg:H,k2:j}=i.splitScalar(u),q=r,W=r,J=this;for(;T>f||j>f;)T&v&&(q=q.add(J)),j&v&&(W=W.add(J)),J=J.double(),T>>=v,j>>=v;return m&&(q=q.negate()),H&&(W=W.negate()),W=new K(z(W.x*i.beta),W.y,W.z),q.add(W)}precomputeWindow(e){const r=G?128/e+1:256/e+1,u=[];let m=this,T=m;for(let H=0;H<r;H++){T=m,u.push(T);for(let j=1;j<2**(e-1);j++)T=T.add(m),u.push(T);m=T.double()}return u}wNAF(e,r){!r&&this.equals(K.BASE)&&(r=Z.BASE);const u=r&&r._WINDOW_SIZE||1;if(256%u)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let m=r&&X.get(r);m||(m=this.precomputeWindow(u),r&&u!==1&&(m=K.normalizeZ(m),X.set(r,m)));let T=K.ZERO,H=K.BASE;const j=1+(G?128/u:256/u),q=2**(u-1),W=BigInt(2**u-1),J=2**u,te=BigInt(u);for(let re=0;re<j;re++){const de=re*q;let le=Number(e&W);e>>=te,le>q&&(le-=J,e+=v);const xe=de,Se=de+Math.abs(le)-1,Le=re%2!==0,De=le<0;le===0?H=H.add(O(Le,m[xe])):T=T.add(O(De,m[Se]))}return{p:T,f:H}}multiply(e,r){let u=he(e),m,T;if(G){const{k1neg:H,k1:j,k2neg:q,k2:W}=i.splitScalar(u);let{p:J,f:te}=this.wNAF(j,r),{p:re,f:de}=this.wNAF(W,r);J=O(H,J),re=O(q,re),re=new K(z(re.x*i.beta),re.y,re.z),m=J.add(re),T=te.add(de)}else{const{p:H,f:j}=this.wNAF(u,r);m=H,T=j}return K.normalizeZ([m,T])[0]}toAffine(e){const{x:r,y:u,z:m}=this,T=this.equals(K.ZERO);e==null&&(e=T?a:me(m));const H=e,j=z(H*H),q=z(j*H),W=z(r*j),J=z(u*q),te=z(m*H);if(T)return Z.ZERO;if(te!==v)throw new Error("invZ was invalid");return new Z(W,J)}}K.BASE=new K(d.Gx,d.Gy,v),K.ZERO=new K(f,v,f);function O(n,e){const r=e.negate();return n?r:e}const X=new WeakMap;class Z{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,X.delete(this)}hasEvenY(){return this.y%A===f}static fromCompressedHex(e){const r=e.length===32,u=ae(r?e:e.subarray(1));if(!ue(u))throw new Error("Point is not on curve");const m=U(u);let T=Ie(m);const H=(T&v)===v;r?H&&(T=z(-T)):(e[0]&1)===1!==H&&(T=z(-T));const j=new Z(u,T);return j.assertValidity(),j}static fromUncompressedHex(e){const r=ae(e.subarray(1,E+1)),u=ae(e.subarray(E+1,E*2+1)),m=new Z(r,u);return m.assertValidity(),m}static fromHex(e){const r=Q(e),u=r.length,m=r[0];if(u===E)return this.fromCompressedHex(r);if(u===F&&(m===2||m===3))return this.fromCompressedHex(r);if(u===V&&m===4)return this.fromUncompressedHex(r);throw new Error(`Point.fromHex: received invalid point. Expected 32-${F} compressed bytes or ${V} uncompressed bytes, not ${u}`)}static fromPrivateKey(e){return Z.BASE.multiply(pe(e))}static fromSignature(e,r,u){const{r:m,s:T}=Ke(r);if(![0,1,2,3].includes(u))throw new Error("Cannot recover: invalid recovery bit");const H=He(Q(e)),{n:j}=d,q=u===2||u===3?m+j:m,W=me(q,j),J=z(-H*W,j),te=z(T*W,j),re=u&1?"03":"02",de=Z.fromHex(re+N(q)),le=Z.BASE.multiplyAndAddUnsafe(de,J,te);if(!le)throw new Error("Cannot recover signature: point at infinify");return le.assertValidity(),le}toRawBytes(e=!1){return se(this.toHex(e))}toHex(e=!1){const r=N(this.x);return e?`${this.hasEvenY()?"02":"03"}${r}`:`04${r}${N(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:r,y:u}=this;if(!ue(r)||!ue(u))throw new Error(e);const m=z(u*u),T=U(r);if(z(m-T)!==f)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Z(this.x,z(-this.y))}double(){return K.fromAffine(this).double().toAffine()}add(e){return K.fromAffine(this).add(K.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return K.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,r,u){const m=K.fromAffine(this),T=r===f||r===v||this!==Z.BASE?m.multiplyUnsafe(r):m.multiply(r),H=K.fromAffine(e).multiplyUnsafe(u),j=T.add(H);return j.equals(K.ZERO)?void 0:j.toAffine()}}s.Point=Z,Z.BASE=new Z(d.Gx,d.Gy),Z.ZERO=new Z(f,f);function ee(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function ge(n){if(n.length<2||n[0]!==2)throw new Error(`Invalid signature integer tag: ${l(n)}`);const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:ae(r),left:n.subarray(e+2)}}function Ee(n){if(n.length<2||n[0]!=48)throw new Error(`Invalid signature tag: ${l(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=ge(n.subarray(2)),{data:u,left:m}=ge(r);if(m.length)throw new Error(`Invalid signature: left bytes after parsing: ${l(m)}`);return{r:e,s:u}}class fe{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromCompact(e){const r=e instanceof Uint8Array,u="Signature.fromCompact";if(typeof e!="string"&&!r)throw new TypeError(`${u}: Expected string or Uint8Array`);const m=r?l(e):e;if(m.length!==128)throw new Error(`${u}: Expected 64-byte hex`);return new fe(oe(m.slice(0,64)),oe(m.slice(64,128)))}static fromDER(e){const r=e instanceof Uint8Array;if(typeof e!="string"&&!r)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:u,s:m}=Ee(r?e:se(e));return new fe(u,m)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:r}=this;if(!Y(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Y(r))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=d.n>>v;return this.s>e}normalizeS(){return this.hasHighS()?new fe(this.r,z(-this.s,d.n)):this}toDERRawBytes(){return se(this.toDERHex())}toDERHex(){const e=ee($(this.s)),r=ee($(this.r)),u=e.length/2,m=r.length/2,T=$(u),H=$(m);return`30${$(m+u+4)}02${H}${r}02${T}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return se(this.toCompactHex())}toCompactHex(){return N(this.r)+N(this.s)}}s.Signature=fe;function S(...n){if(!n.every(u=>u instanceof Uint8Array))throw new Error("Uint8Array list expected");if(n.length===1)return n[0];const e=n.reduce((u,m)=>u+m.length,0),r=new Uint8Array(e);for(let u=0,m=0;u<n.length;u++){const T=n[u];r.set(T,m),m+=T.length}return r}const g=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function l(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<n.length;r++)e+=g[n[r]];return e}const P=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function N(n){if(typeof n!="bigint")throw new Error("Expected bigint");if(!(f<=n&&n<P))throw new Error("Expected number 0 <= n < 2^256");return n.toString(16).padStart(64,"0")}function M(n){const e=se(N(n));if(e.length!==32)throw new Error("Error: expected 32 bytes");return e}function $(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function oe(n){if(typeof n!="string")throw new TypeError("hexToNumber: expected string, got "+typeof n);return BigInt(`0x${n}`)}function se(n){if(typeof n!="string")throw new TypeError("hexToBytes: expected string, got "+typeof n);if(n.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+n.length);const e=new Uint8Array(n.length/2);for(let r=0;r<e.length;r++){const u=r*2,m=n.slice(u,u+2),T=Number.parseInt(m,16);if(Number.isNaN(T)||T<0)throw new Error("Invalid byte sequence");e[r]=T}return e}function ae(n){return oe(l(n))}function Q(n){return n instanceof Uint8Array?Uint8Array.from(n):se(n)}function he(n){if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)return BigInt(n);if(typeof n=="bigint"&&Y(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function z(n,e=d.P){const r=n%e;return r>=f?r:e+r}function be(n,e){const{P:r}=d;let u=n;for(;e-- >f;)u*=u,u%=r;return u}function Ie(n){const{P:e}=d,r=BigInt(6),u=BigInt(11),m=BigInt(22),T=BigInt(23),H=BigInt(44),j=BigInt(88),q=n*n*n%e,W=q*q*n%e,J=be(W,b)*W%e,te=be(J,b)*W%e,re=be(te,A)*q%e,de=be(re,u)*re%e,le=be(de,m)*de%e,xe=be(le,H)*le%e,Se=be(xe,j)*xe%e,Le=be(Se,H)*le%e,De=be(Le,b)*W%e,$e=be(De,T)*de%e,Ve=be($e,r)*q%e,Fe=be(Ve,A);if(Fe*Fe%e!==n)throw new Error("Cannot find square root");return Fe}function me(n,e=d.P){if(n===f||e<=f)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let r=z(n,e),u=e,m=f,T=v,H=v,j=f;for(;r!==f;){const W=u/r,J=u%r,te=m-H*W,re=T-j*W;u=r,r=J,m=H,T=j,H=te,j=re}if(u!==v)throw new Error("invert: does not exist");return z(m,e)}function Pe(n,e=d.P){const r=new Array(n.length),u=n.reduce((T,H,j)=>H===f?T:(r[j]=T,z(T*H,e)),v),m=me(u,e);return n.reduceRight((T,H,j)=>H===f?T:(r[j]=z(T*r[j],e),z(T*H,e)),m),r}function Me(n){const e=n.length*8-y*8,r=ae(n);return e>0?r>>BigInt(e):r}function He(n,e=!1){const r=Me(n);if(e)return r;const{n:u}=d;return r>=u?r-u:r}let Ne,h;class D{constructor(e,r){if(this.hashLen=e,this.qByteLen=r,typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof r!="number"||r<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(e).fill(1),this.k=new Uint8Array(e).fill(0),this.counter=0}hmac(...e){return s.utils.hmacSha256(this.k,...e)}hmacSync(...e){return h(this.k,...e)}checkSync(){if(typeof h!="function")throw new I("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),e.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),e.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=await this.hmac(this.v);const u=this.v.slice();r.push(u),e+=this.v.length}return S(...r)}generateSync(){this.checkSync(),this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const u=this.v.slice();r.push(u),e+=this.v.length}return S(...r)}}function Y(n){return f<n&&n<d.n}function ue(n){return f<n&&n<d.P}function ye(n,e,r,u=!0){const{n:m}=d,T=He(n,!0);if(!Y(T))return;const H=me(T,m),j=Z.BASE.multiply(T),q=z(j.x,m);if(q===f)return;const W=z(H*z(e+r*q,m),m);if(W===f)return;let J=new fe(q,W),te=(j.x===J.r?0:2)|Number(j.y&v);return u&&J.hasHighS()&&(J=J.normalizeS(),te^=1),{sig:J,recovery:te}}function pe(n){let e;if(typeof n=="bigint")e=n;else if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)e=BigInt(n);else if(typeof n=="string"){if(n.length!==2*y)throw new Error("Expected 32 bytes of private key");e=oe(n)}else if(n instanceof Uint8Array){if(n.length!==y)throw new Error("Expected 32 bytes of private key");e=ae(n)}else throw new TypeError("Expected valid private key");if(!Y(e))throw new Error("Expected private key: 0 < key < n");return e}function Be(n){return n instanceof Z?(n.assertValidity(),n):Z.fromHex(n)}function Ke(n){if(n instanceof fe)return n.assertValidity(),n;try{return fe.fromDER(n)}catch{return fe.fromCompact(n)}}function Ce(n,e=!1){return Z.fromPrivateKey(n).toRawBytes(e)}s.getPublicKey=Ce;function ct(n,e,r,u=!1){return Z.fromSignature(n,e,r).toRawBytes(u)}s.recoverPublicKey=ct;function Qe(n){const e=n instanceof Uint8Array,r=typeof n=="string",u=(e||r)&&n.length;return e?u===F||u===V:r?u===F*2||u===V*2:n instanceof Z}function ft(n,e,r=!1){if(Qe(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!Qe(e))throw new TypeError("getSharedSecret: second arg must be public key");const u=Be(e);return u.assertValidity(),u.multiply(pe(n)).toRawBytes(r)}s.getSharedSecret=ft;function Je(n){const e=n.length>E?n.slice(0,E):n;return ae(e)}function ut(n){const e=Je(n),r=z(e,d.n);return _e(r<f?e:r)}function _e(n){return M(n)}function et(n,e,r){if(n==null)throw new Error(`sign: expected valid message hash, not "${n}"`);const u=Q(n),m=pe(e),T=[_e(m),ut(u)];if(r!=null){r===!0&&(r=s.utils.randomBytes(E));const q=Q(r);if(q.length!==E)throw new Error(`sign: Expected ${E} bytes of extra data`);T.push(q)}const H=S(...T),j=Je(u);return{seed:H,m:j,d:m}}function tt(n,e){const{sig:r,recovery:u}=n,{der:m,recovered:T}=Object.assign({canonical:!0,der:!0},e),H=m?r.toDERRawBytes():r.toCompactRawBytes();return T?[H,u]:H}async function lt(n,e,r={}){const{seed:u,m,d:T}=et(n,e,r.extraEntropy),H=new D(R,y);await H.reseed(u);let j;for(;!(j=ye(await H.generate(),m,T,r.canonical));)await H.reseed();return tt(j,r)}s.sign=lt;function Ge(n,e,r={}){const{seed:u,m,d:T}=et(n,e,r.extraEntropy),H=new D(R,y);H.reseedSync(u);let j;for(;!(j=ye(H.generateSync(),m,T,r.canonical));)H.reseedSync();return tt(j,r)}s.signSync=Ge;const bt={strict:!0};function yt(n,e,r,u=bt){let m;try{m=Ke(n),e=Q(e)}catch{return!1}const{r:T,s:H}=m;if(u.strict&&m.hasHighS())return!1;const j=He(e);let q;try{q=Be(r)}catch{return!1}const{n:W}=d,J=me(H,W),te=z(j*J,W),re=z(T*J,W),de=Z.BASE.multiplyAndAddUnsafe(q,te,re);return de?z(de.x,W)===T:!1}s.verify=yt;function We(n){return z(ae(n),d.n)}class ze{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromHex(e){const r=Q(e);if(r.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${r.length}`);const u=ae(r.subarray(0,32)),m=ae(r.subarray(32,64));return new ze(u,m)}assertValidity(){const{r:e,s:r}=this;if(!ue(e)||!Y(r))throw new Error("Invalid signature")}toHex(){return N(this.r)+N(this.s)}toRawBytes(){return se(this.toHex())}}function ht(n){return Z.fromPrivateKey(n).toRawX()}class rt{constructor(e,r,u=s.utils.randomBytes()){if(e==null)throw new TypeError(`sign: Expected valid message, not "${e}"`);this.m=Q(e);const{x:m,scalar:T}=this.getScalar(pe(r));if(this.px=m,this.d=T,this.rand=Q(u),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(e){const r=Z.fromPrivateKey(e),u=r.hasEvenY()?e:d.n-e;return{point:r,scalar:u,x:r.toRawX()}}initNonce(e,r){return M(e^ae(r))}finalizeNonce(e){const r=z(ae(e),d.n);if(r===f)throw new Error("sign: Creation of signature failed. k is zero");const{point:u,x:m,scalar:T}=this.getScalar(r);return{R:u,rx:m,k:T}}finalizeSig(e,r,u,m){return new ze(e.x,z(r+u*m,d.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:e,d:r,px:u,rand:m}=this,T=s.utils.taggedHash,H=this.initNonce(r,await T(Te.aux,m)),{R:j,rx:q,k:W}=this.finalizeNonce(await T(Te.nonce,H,u,e)),J=We(await T(Te.challenge,q,u,e)),te=this.finalizeSig(j,W,J,r);return await ot(te,e,u)||this.error(),te}calcSync(){const{m:e,d:r,px:u,rand:m}=this,T=s.utils.taggedHashSync,H=this.initNonce(r,T(Te.aux,m)),{R:j,rx:q,k:W}=this.finalizeNonce(T(Te.nonce,H,u,e)),J=We(T(Te.challenge,q,u,e)),te=this.finalizeSig(j,W,J,r);return it(te,e,u)||this.error(),te}}async function dt(n,e,r){return new rt(n,e,r).calc()}function je(n,e,r){return new rt(n,e,r).calcSync()}function Oe(n,e,r){const u=n instanceof ze,m=u?n:ze.fromHex(n);return u&&m.assertValidity(),{...m,m:Q(e),P:Be(r)}}function nt(n,e,r,u){const m=Z.BASE.multiplyAndAddUnsafe(e,pe(r),z(-u,d.n));return!(!m||!m.hasEvenY()||m.x!==n)}async function ot(n,e,r){try{const{r:u,s:m,m:T,P:H}=Oe(n,e,r),j=We(await s.utils.taggedHash(Te.challenge,M(u),H.toRawX(),T));return nt(u,H,m,j)}catch{return!1}}function it(n,e,r){try{const{r:u,s:m,m:T,P:H}=Oe(n,e,r),j=We(s.utils.taggedHashSync(Te.challenge,M(u),H.toRawX(),T));return nt(u,H,m,j)}catch(u){if(u instanceof I)throw u;return!1}}s.schnorr={Signature:ze,getPublicKey:ht,sign:dt,verify:ot,signSync:je,verifySync:it},Z.BASE._setWindowSize(8);const ve={node:B,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Te={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Ze={};s.utils={bytesToHex:l,hexToBytes:se,concatBytes:S,mod:z,invert:me,isValidPrivateKey(n){try{return pe(n),!0}catch{return!1}},_bigintTo32Bytes:M,_normalizePrivateKey:pe,hashToPrivateKey:n=>{n=Q(n);const e=y+8;if(n.length<e||n.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const r=z(ae(n),d.n-v)+v;return M(r)},randomBytes:(n=32)=>{if(ve.web)return ve.web.getRandomValues(new Uint8Array(n));if(ve.node){const{randomBytes:e}=ve.node;return Uint8Array.from(e(n))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>s.utils.hashToPrivateKey(s.utils.randomBytes(y+8)),precompute(n=8,e=Z.BASE){const r=e===Z.BASE?e:new Z(e.x,e.y);return r._setWindowSize(n),r.multiply(b),r},sha256:async(...n)=>{if(ve.web){const e=await ve.web.subtle.digest("SHA-256",S(...n));return new Uint8Array(e)}else if(ve.node){const{createHash:e}=ve.node,r=e("sha256");return n.forEach(u=>r.update(u)),Uint8Array.from(r.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(n,...e)=>{if(ve.web){const r=await ve.web.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),u=S(...e),m=await ve.web.subtle.sign("HMAC",r,u);return new Uint8Array(m)}else if(ve.node){const{createHmac:r}=ve.node,u=r("sha256",n);return e.forEach(m=>u.update(m)),Uint8Array.from(u.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(n,...e)=>{let r=Ze[n];if(r===void 0){const u=await s.utils.sha256(Uint8Array.from(n,m=>m.charCodeAt(0)));r=S(u,u),Ze[n]=r}return s.utils.sha256(r,...e)},taggedHashSync:(n,...e)=>{if(typeof Ne!="function")throw new I("sha256Sync is undefined, you need to set it");let r=Ze[n];if(r===void 0){const u=Ne(Uint8Array.from(n,m=>m.charCodeAt(0)));r=S(u,u),Ze[n]=r}return Ne(r,...e)},_JacobianPoint:K},Object.defineProperties(s.utils,{sha256Sync:{configurable:!1,get(){return Ne},set(n){Ne||(Ne=n)}},hmacSha256Sync:{configurable:!1,get(){return h},set(n){h||(h=n)}}})},63203:function(ne,s){"use strict";/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(s,"__esModule",{value:!0}),s.bytes=s.stringToBytes=s.str=s.bytesToString=s.hex=s.utf8=s.bech32m=s.bech32=s.base58check=s.createBase58check=s.base58xmr=s.base58xrp=s.base58flickr=s.base58=s.base64urlnopad=s.base64url=s.base64nopad=s.base64=s.base32crockford=s.base32hexnopad=s.base32hex=s.base32nopad=s.base32=s.base16=s.utils=s.assertNumber=void 0;function k(S){if(!Number.isSafeInteger(S))throw new Error(`Wrong integer: ${S}`)}s.assertNumber=k;function B(S){return S instanceof Uint8Array||S!=null&&typeof S=="object"&&S.constructor.name==="Uint8Array"}function f(...S){const g=M=>M,l=(M,$)=>oe=>M($(oe)),P=S.map(M=>M.encode).reduceRight(l,g),N=S.map(M=>M.decode).reduce(l,g);return{encode:P,decode:N}}function v(S){return{encode:g=>{if(!Array.isArray(g)||g.length&&typeof g[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return g.map(l=>{if(k(l),l<0||l>=S.length)throw new Error(`Digit index outside alphabet: ${l} (alphabet: ${S.length})`);return S[l]})},decode:g=>{if(!Array.isArray(g)||g.length&&typeof g[0]!="string")throw new Error("alphabet.decode input should be array of strings");return g.map(l=>{if(typeof l!="string")throw new Error(`alphabet.decode: not string element=${l}`);const P=S.indexOf(l);if(P===-1)throw new Error(`Unknown letter: "${l}". Allowed: ${S}`);return P})}}}function A(S=""){if(typeof S!="string")throw new Error("join separator should be string");return{encode:g=>{if(!Array.isArray(g)||g.length&&typeof g[0]!="string")throw new Error("join.encode input should be array of strings");for(let l of g)if(typeof l!="string")throw new Error(`join.encode: non-string input=${l}`);return g.join(S)},decode:g=>{if(typeof g!="string")throw new Error("join.decode input should be string");return g.split(S)}}}function b(S,g="="){if(k(S),typeof g!="string")throw new Error("padding chr should be string");return{encode(l){if(!Array.isArray(l)||l.length&&typeof l[0]!="string")throw new Error("padding.encode input should be array of strings");for(let P of l)if(typeof P!="string")throw new Error(`padding.encode: non-string input=${P}`);for(;l.length*S%8;)l.push(g);return l},decode(l){if(!Array.isArray(l)||l.length&&typeof l[0]!="string")throw new Error("padding.encode input should be array of strings");for(let N of l)if(typeof N!="string")throw new Error(`padding.decode: non-string input=${N}`);let P=l.length;if(P*S%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;P>0&&l[P-1]===g;P--)if(!((P-1)*S%8))throw new Error("Invalid padding: string has too much padding");return l.slice(0,P)}}}function a(S){if(typeof S!="function")throw new Error("normalize fn should be function");return{encode:g=>g,decode:g=>S(g)}}function d(S,g,l){if(g<2)throw new Error(`convertRadix: wrong from=${g}, base cannot be less than 2`);if(l<2)throw new Error(`convertRadix: wrong to=${l}, base cannot be less than 2`);if(!Array.isArray(S))throw new Error("convertRadix: data should be array");if(!S.length)return[];let P=0;const N=[],M=Array.from(S);for(M.forEach($=>{if(k($),$<0||$>=g)throw new Error(`Wrong integer: ${$}`)});;){let $=0,oe=!0;for(let se=P;se<M.length;se++){const ae=M[se],Q=g*$+ae;if(!Number.isSafeInteger(Q)||g*$/g!==$||Q-ae!==g*$)throw new Error("convertRadix: carry overflow");$=Q%l;const he=Math.floor(Q/l);if(M[se]=he,!Number.isSafeInteger(he)||he*l+$!==Q)throw new Error("convertRadix: carry overflow");if(oe)he?oe=!1:P=se;else continue}if(N.push($),oe)break}for(let $=0;$<S.length-1&&S[$]===0;$++)N.push(0);return N.reverse()}const w=(S,g)=>g?w(g,S%g):S,i=(S,g)=>S+(g-w(S,g));function E(S,g,l,P){if(!Array.isArray(S))throw new Error("convertRadix2: data should be array");if(g<=0||g>32)throw new Error(`convertRadix2: wrong from=${g}`);if(l<=0||l>32)throw new Error(`convertRadix2: wrong to=${l}`);if(i(g,l)>32)throw new Error(`convertRadix2: carry overflow from=${g} to=${l} carryBits=${i(g,l)}`);let N=0,M=0;const $=2**l-1,oe=[];for(const se of S){if(k(se),se>=2**g)throw new Error(`convertRadix2: invalid data word=${se} from=${g}`);if(N=N<<g|se,M+g>32)throw new Error(`convertRadix2: carry overflow pos=${M} from=${g}`);for(M+=g;M>=l;M-=l)oe.push((N>>M-l&$)>>>0);N&=2**M-1}if(N=N<<l-M&$,!P&&M>=g)throw new Error("Excess padding");if(!P&&N)throw new Error(`Non-zero padding: ${N}`);return P&&M>0&&oe.push(N>>>0),oe}function y(S){return k(S),{encode:g=>{if(!B(g))throw new Error("radix.encode input should be Uint8Array");return d(Array.from(g),2**8,S)},decode:g=>{if(!Array.isArray(g)||g.length&&typeof g[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(d(g,S,2**8))}}}function R(S,g=!1){if(k(S),S<=0||S>32)throw new Error("radix2: bits should be in (0..32]");if(i(8,S)>32||i(S,8)>32)throw new Error("radix2: carry overflow");return{encode:l=>{if(!B(l))throw new Error("radix2.encode input should be Uint8Array");return E(Array.from(l),8,S,!g)},decode:l=>{if(!Array.isArray(l)||l.length&&typeof l[0]!="number")throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(E(l,S,8,g))}}}function F(S){if(typeof S!="function")throw new Error("unsafeWrapper fn should be function");return function(...g){try{return S.apply(null,g)}catch{}}}function V(S,g){if(k(S),typeof g!="function")throw new Error("checksum fn should be function");return{encode(l){if(!B(l))throw new Error("checksum.encode: input should be Uint8Array");const P=g(l).slice(0,S),N=new Uint8Array(l.length+S);return N.set(l),N.set(P,l.length),N},decode(l){if(!B(l))throw new Error("checksum.decode: input should be Uint8Array");const P=l.slice(0,-S),N=g(P).slice(0,S),M=l.slice(-S);for(let $=0;$<S;$++)if(N[$]!==M[$])throw new Error("Invalid checksum");return P}}}s.utils={alphabet:v,chain:f,checksum:V,convertRadix:d,convertRadix2:E,radix:y,radix2:R,join:A,padding:b},s.base16=f(R(4),v("0123456789ABCDEF"),A("")),s.base32=f(R(5),v("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),b(5),A("")),s.base32nopad=f(R(5),v("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),A("")),s.base32hex=f(R(5),v("0123456789ABCDEFGHIJKLMNOPQRSTUV"),b(5),A("")),s.base32hexnopad=f(R(5),v("0123456789ABCDEFGHIJKLMNOPQRSTUV"),A("")),s.base32crockford=f(R(5),v("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),A(""),a(S=>S.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),s.base64=f(R(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),b(6),A("")),s.base64nopad=f(R(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),A("")),s.base64url=f(R(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),b(6),A("")),s.base64urlnopad=f(R(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),A(""));const U=S=>f(y(58),v(S),A(""));s.base58=U("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),s.base58flickr=U("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),s.base58xrp=U("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const G=[0,2,3,5,6,7,9,10,11];s.base58xmr={encode(S){let g="";for(let l=0;l<S.length;l+=8){const P=S.subarray(l,l+8);g+=s.base58.encode(P).padStart(G[P.length],"1")}return g},decode(S){let g=[];for(let l=0;l<S.length;l+=11){const P=S.slice(l,l+11),N=G.indexOf(P.length),M=s.base58.decode(P);for(let $=0;$<M.length-N;$++)if(M[$]!==0)throw new Error("base58xmr: wrong padding");g=g.concat(Array.from(M.slice(M.length-N)))}return Uint8Array.from(g)}};const I=S=>f(V(4,g=>S(S(g))),s.base58);s.createBase58check=I,s.base58check=s.createBase58check;const C=f(v("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),A("")),K=[996825010,642813549,513874426,1027748829,705979059];function O(S){const g=S>>25;let l=(S&33554431)<<5;for(let P=0;P<K.length;P++)(g>>P&1)===1&&(l^=K[P]);return l}function X(S,g,l=1){const P=S.length;let N=1;for(let M=0;M<P;M++){const $=S.charCodeAt(M);if($<33||$>126)throw new Error(`Invalid prefix (${S})`);N=O(N)^$>>5}N=O(N);for(let M=0;M<P;M++)N=O(N)^S.charCodeAt(M)&31;for(let M of g)N=O(N)^M;for(let M=0;M<6;M++)N=O(N);return N^=l,C.encode(E([N%2**30],30,5,!1))}function Z(S){const g=S==="bech32"?1:734539939,l=R(5),P=l.decode,N=l.encode,M=F(P);function $(Q,he,z=90){if(typeof Q!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof Q}`);if(!Array.isArray(he)||he.length&&typeof he[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof he}`);if(Q.length===0)throw new TypeError(`Invalid prefix length ${Q.length}`);const be=Q.length+7+he.length;if(z!==!1&&be>z)throw new TypeError(`Length ${be} exceeds limit ${z}`);const Ie=Q.toLowerCase(),me=X(Ie,he,g);return`${Ie}1${C.encode(he)}${me}`}function oe(Q,he=90){if(typeof Q!="string")throw new Error(`bech32.decode input should be string, not ${typeof Q}`);if(Q.length<8||he!==!1&&Q.length>he)throw new TypeError(`Wrong string length: ${Q.length} (${Q}). Expected (8..${he})`);const z=Q.toLowerCase();if(Q!==z&&Q!==Q.toUpperCase())throw new Error("String must be lowercase or uppercase");const be=z.lastIndexOf("1");if(be===0||be===-1)throw new Error('Letter "1" must be present between prefix and data only');const Ie=z.slice(0,be),me=z.slice(be+1);if(me.length<6)throw new Error("Data must be at least 6 characters long");const Pe=C.decode(me).slice(0,-6),Me=X(Ie,Pe,g);if(!me.endsWith(Me))throw new Error(`Invalid checksum in ${Q}: expected "${Me}"`);return{prefix:Ie,words:Pe}}const se=F(oe);function ae(Q){const{prefix:he,words:z}=oe(Q,!1);return{prefix:he,words:z,bytes:P(z)}}return{encode:$,decode:oe,decodeToBytes:ae,decodeUnsafe:se,fromWords:P,fromWordsUnsafe:M,toWords:N}}s.bech32=Z("bech32"),s.bech32m=Z("bech32m"),s.utf8={encode:S=>new TextDecoder().decode(S),decode:S=>new TextEncoder().encode(S)},s.hex=f(R(4),v("0123456789abcdef"),A(""),a(S=>{if(typeof S!="string"||S.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof S} with length ${S.length}`);return S.toLowerCase()}));const ee={utf8:s.utf8,hex:s.hex,base16:s.base16,base32:s.base32,base64:s.base64,base64url:s.base64url,base58:s.base58,base58xmr:s.base58xmr},ge="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr",Ee=(S,g)=>{if(typeof S!="string"||!ee.hasOwnProperty(S))throw new TypeError(ge);if(!B(g))throw new TypeError("bytesToString() expects Uint8Array");return ee[S].encode(g)};s.bytesToString=Ee,s.str=s.bytesToString;const fe=(S,g)=>{if(!ee.hasOwnProperty(S))throw new TypeError(ge);if(typeof g!="string")throw new TypeError("stringToBytes() expects string");return ee[S].decode(g)};s.stringToBytes=fe,s.bytes=s.stringToBytes},11206:function(ne,s,k){"use strict";var B=k(48287).Buffer;Object.defineProperty(s,"__esModule",{value:!0}),s.BIP32Factory=void 0;const f=k(25311),v=k(87569),A=k(63203),b=k(22623),a=k(8676),d=k(57513),w=(0,A.base58check)(b.sha256),i={encode:y=>w.encode(Uint8Array.from(y)),decode:y=>B.from(w.decode(y))};function E(y){(0,v.testEcc)(y);const R=a.BufferN(32),F=a.compile({wif:a.UInt8,bip32:{public:a.UInt32,private:a.UInt32}}),V={messagePrefix:`Bitcoin Signed Message:
2
- `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},U=2147483648,G=Math.pow(2,31)-1;function I(g){return a.String(g)&&g.match(/^(m\/)?(\d+'?\/)*\d+'?$/)!==null}function C(g){return a.UInt32(g)&&g<=G}function K(g){return g.length===32?g:g.slice(1,33)}class O{constructor(l,P){this.__D=l,this.__Q=P,this.lowR=!1}get publicKey(){return this.__Q===void 0&&(this.__Q=B.from(y.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(l,P){if(!this.privateKey)throw new Error("Missing private key");if(P===void 0&&(P=this.lowR),P===!1)return B.from(y.sign(l,this.privateKey));{let N=B.from(y.sign(l,this.privateKey));const M=B.alloc(32,0);let $=0;for(;N[0]>127;)$++,M.writeUIntLE($,0,6),N=B.from(y.sign(l,this.privateKey,M));return N}}signSchnorr(l){if(!this.privateKey)throw new Error("Missing private key");if(!y.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return B.from(y.signSchnorr(l,this.privateKey))}verify(l,P){return y.verify(l,this.publicKey,P)}verifySchnorr(l,P){if(!y.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return y.verifySchnorr(l,this.publicKey.subarray(1,33),P)}}class X extends O{constructor(l,P,N,M,$=0,oe=0,se=0){super(l,P),this.chainCode=N,this.network=M,this.__DEPTH=$,this.__INDEX=oe,this.__PARENT_FINGERPRINT=se,a(F,M)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return f.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return this.__D===void 0}neutered(){return fe(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const l=this.network,P=this.isNeutered()?l.bip32.public:l.bip32.private,N=B.allocUnsafe(78);return N.writeUInt32BE(P,0),N.writeUInt8(this.depth,4),N.writeUInt32BE(this.parentFingerprint,5),N.writeUInt32BE(this.index,9),this.chainCode.copy(N,13),this.isNeutered()?this.publicKey.copy(N,45):(N.writeUInt8(0,45),this.privateKey.copy(N,46)),i.encode(N)}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return d.encode(this.network.wif,this.privateKey,!0)}derive(l){a(a.UInt32,l);const P=l>=U,N=B.allocUnsafe(37);if(P){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");N[0]=0,this.privateKey.copy(N,1),N.writeUInt32BE(l,33)}else this.publicKey.copy(N,0),N.writeUInt32BE(l,33);const M=f.hmacSHA512(this.chainCode,N),$=M.slice(0,32),oe=M.slice(32);if(!y.isPrivate($))return this.derive(l+1);let se;if(this.isNeutered()){const ae=B.from(y.pointAddScalar(this.publicKey,$,!0));if(ae===null)return this.derive(l+1);se=fe(ae,oe,this.network,this.depth+1,l,this.fingerprint.readUInt32BE(0))}else{const ae=B.from(y.privateAdd(this.privateKey,$));if(ae==null)return this.derive(l+1);se=ge(ae,oe,this.network,this.depth+1,l,this.fingerprint.readUInt32BE(0))}return se}deriveHardened(l){return a(C,l),this.derive(l+U)}derivePath(l){a(I,l);let P=l.split("/");if(P[0]==="m"){if(this.parentFingerprint)throw new TypeError("Expected master, got child");P=P.slice(1)}return P.reduce((N,M)=>{let $;return M.slice(-1)==="'"?($=parseInt(M.slice(0,-1),10),N.deriveHardened($)):($=parseInt(M,10),N.derive($))},this)}tweak(l){return this.privateKey?this.tweakFromPrivateKey(l):this.tweakFromPublicKey(l)}tweakFromPublicKey(l){const P=K(this.publicKey);if(!y.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const N=y.xOnlyPointAddTweak(P,l);if(!N||N.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const M=B.from([N.parity===0?2:3]),$=B.concat([M,N.xOnlyPubkey]);return new O(void 0,$)}tweakFromPrivateKey(l){const P=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1,N=(()=>{if(P){if(y.privateNegate)return y.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}else return this.privateKey})(),M=y.privateAdd(N,l);if(!M)throw new Error("Invalid tweaked private key!");return new O(B.from(M),void 0)}}function Z(g,l){const P=i.decode(g);if(P.length!==78)throw new TypeError("Invalid buffer length");l=l||V;const N=P.readUInt32BE(0);if(N!==l.bip32.private&&N!==l.bip32.public)throw new TypeError("Invalid network version");const M=P[4],$=P.readUInt32BE(5);if(M===0&&$!==0)throw new TypeError("Invalid parent fingerprint");const oe=P.readUInt32BE(9);if(M===0&&oe!==0)throw new TypeError("Invalid index");const se=P.slice(13,45);let ae;if(N===l.bip32.private){if(P.readUInt8(45)!==0)throw new TypeError("Invalid private key");const Q=P.slice(46,78);ae=ge(Q,se,l,M,oe,$)}else{const Q=P.slice(45,78);ae=fe(Q,se,l,M,oe,$)}return ae}function ee(g,l,P){return ge(g,l,P)}function ge(g,l,P,N,M,$){if(a({privateKey:R,chainCode:R},{privateKey:g,chainCode:l}),P=P||V,!y.isPrivate(g))throw new TypeError("Private key not in range [1, n)");return new X(g,void 0,l,P,N,M,$)}function Ee(g,l,P){return fe(g,l,P)}function fe(g,l,P,N,M,$){if(a({publicKey:a.BufferN(33),chainCode:R},{publicKey:g,chainCode:l}),P=P||V,!y.isPoint(g))throw new TypeError("Point is not on the curve");return new X(void 0,g,l,P,N,M,$)}function S(g,l){if(a(a.Buffer,g),g.length<16)throw new TypeError("Seed should be at least 128 bits");if(g.length>64)throw new TypeError("Seed should be at most 512 bits");l=l||V;const P=f.hmacSHA512(B.from("Bitcoin seed","utf8"),g),N=P.slice(0,32),M=P.slice(32);return ee(N,M,l)}return{fromSeed:S,fromBase58:Z,fromPublicKey:Ee,fromPrivateKey:ee}}s.BIP32Factory=E},25311:function(ne,s,k){"use strict";var B=k(48287).Buffer;Object.defineProperty(s,"__esModule",{value:!0}),s.hmacSHA512=s.hash160=void 0;const f=k(39615),v=k(93238),A=k(22623),b=k(30102);function a(w){const i=(0,A.sha256)(Uint8Array.from(w));return B.from((0,v.ripemd160)(i))}s.hash160=a;function d(w,i){return B.from((0,f.hmac)(b.sha512,w,i))}s.hmacSHA512=d},83328:function(ne,s,k){"use strict";var B;B={value:!0},s.Pr=B=void 0;var f=k(11206);B={enumerable:!0,get:function(){return f.BIP32Factory}},Object.defineProperty(s,"Pr",{enumerable:!0,get:function(){return f.BIP32Factory}})},87569:function(ne,s,k){"use strict";var B=k(48287).Buffer;Object.defineProperty(s,"__esModule",{value:!0}),s.testEcc=void 0;const f=b=>B.from(b,"hex");function v(b){if(A(b.isPoint(f("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),A(!b.isPoint(f("030000000000000000000000000000000000000000000000000000000000000005"))),A(b.isPrivate(f("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),A(b.isPrivate(f("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),A(!b.isPrivate(f("0000000000000000000000000000000000000000000000000000000000000000"))),A(!b.isPrivate(f("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),A(!b.isPrivate(f("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),A(B.from(b.pointFromScalar(f("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(f("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),b.xOnlyPointAddTweak){A(b.xOnlyPointAddTweak(f("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),f("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let a=b.xOnlyPointAddTweak(f("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),f("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));A(B.from(a.xOnlyPubkey).equals(f("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&a.parity===1),a=b.xOnlyPointAddTweak(f("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),f("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}A(B.from(b.pointAddScalar(f("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),f("0000000000000000000000000000000000000000000000000000000000000003"))).equals(f("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),A(B.from(b.privateAdd(f("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),f("0000000000000000000000000000000000000000000000000000000000000002"))).equals(f("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),b.privateNegate&&(A(B.from(b.privateNegate(f("0000000000000000000000000000000000000000000000000000000000000001"))).equals(f("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),A(B.from(b.privateNegate(f("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(f("0000000000000000000000000000000000000000000000000000000000000003"))),A(B.from(b.privateNegate(f("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(f("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),A(B.from(b.sign(f("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),f("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(f("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),A(b.verify(f("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),f("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),f("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),b.signSchnorr&&A(B.from(b.signSchnorr(f("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),f("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),f("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(f("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),b.verifySchnorr&&A(b.verifySchnorr(f("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),f("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),f("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}s.testEcc=v;function A(b){if(!b)throw new Error("ecc library invalid")}},17009:function(ne,s,k){ne.exports=k(27655)(k(59393))},59393:function(ne,s,k){const B=k(86729).ec,f=new B("secp256k1"),v=f.curve,A=v.n.constructor;function b(i,E){let y=new A(E);if(y.cmp(v.p)>=0)return null;y=y.toRed(v.red);let R=y.redSqr().redIMul(y).redIAdd(v.b).redSqrt();return i===3!==R.isOdd()&&(R=R.redNeg()),f.keyPair({pub:{x:y,y:R}})}function a(i,E,y){let R=new A(E),F=new A(y);if(R.cmp(v.p)>=0||F.cmp(v.p)>=0||(R=R.toRed(v.red),F=F.toRed(v.red),(i===6||i===7)&&F.isOdd()!==(i===7)))return null;const V=R.redSqr().redIMul(R);return F.redSqr().redISub(V.redIAdd(v.b)).isZero()?f.keyPair({pub:{x:R,y:F}}):null}function d(i){const E=i[0];switch(E){case 2:case 3:return i.length!==33?null:b(E,i.subarray(1,33));case 4:case 6:case 7:return i.length!==65?null:a(E,i.subarray(1,33),i.subarray(33,65));default:return null}}function w(i,E){const y=E.encode(null,i.length===33);for(let R=0;R<i.length;++R)i[R]=y[R]}ne.exports={contextRandomize(){return 0},privateKeyVerify(i){const E=new A(i);return E.cmp(v.n)<0&&!E.isZero()?0:1},privateKeyNegate(i){const E=new A(i),y=v.n.sub(E).umod(v.n).toArrayLike(Uint8Array,"be",32);return i.set(y),0},privateKeyTweakAdd(i,E){const y=new A(E);if(y.cmp(v.n)>=0||(y.iadd(new A(i)),y.cmp(v.n)>=0&&y.isub(v.n),y.isZero()))return 1;const R=y.toArrayLike(Uint8Array,"be",32);return i.set(R),0},privateKeyTweakMul(i,E){let y=new A(E);if(y.cmp(v.n)>=0||y.isZero())return 1;y.imul(new A(i)),y.cmp(v.n)>=0&&(y=y.umod(v.n));const R=y.toArrayLike(Uint8Array,"be",32);return i.set(R),0},publicKeyVerify(i){return d(i)===null?1:0},publicKeyCreate(i,E){const y=new A(E);if(y.cmp(v.n)>=0||y.isZero())return 1;const R=f.keyFromPrivate(E).getPublic();return w(i,R),0},publicKeyConvert(i,E){const y=d(E);if(y===null)return 1;const R=y.getPublic();return w(i,R),0},publicKeyNegate(i,E){const y=d(E);if(y===null)return 1;const R=y.getPublic();return R.y=R.y.redNeg(),w(i,R),0},publicKeyCombine(i,E){const y=new Array(E.length);for(let F=0;F<E.length;++F)if(y[F]=d(E[F]),y[F]===null)return 1;let R=y[0].getPublic();for(let F=1;F<y.length;++F)R=R.add(y[F].pub);return R.isInfinity()?2:(w(i,R),0)},publicKeyTweakAdd(i,E,y){const R=d(E);if(R===null)return 1;if(y=new A(y),y.cmp(v.n)>=0)return 2;const F=R.getPublic().add(v.g.mul(y));return F.isInfinity()?2:(w(i,F),0)},publicKeyTweakMul(i,E,y){const R=d(E);if(R===null)return 1;if(y=new A(y),y.cmp(v.n)>=0||y.isZero())return 2;const F=R.getPublic().mul(y);return w(i,F),0},signatureNormalize(i){const E=new A(i.subarray(0,32)),y=new A(i.subarray(32,64));return E.cmp(v.n)>=0||y.cmp(v.n)>=0?1:(y.cmp(f.nh)===1&&i.set(v.n.sub(y).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(i,E){const y=E.subarray(0,32),R=E.subarray(32,64);if(new A(y).cmp(v.n)>=0||new A(R).cmp(v.n)>=0)return 1;const{output:F}=i;let V=F.subarray(4,4+33);V[0]=0,V.set(y,1);let U=33,G=0;for(;U>1&&V[G]===0&&!(V[G+1]&128);--U,++G);if(V=V.subarray(G),V[0]&128||U>1&&V[0]===0&&!(V[1]&128))return 1;let I=F.subarray(6+33,6+33+33);I[0]=0,I.set(R,1);let C=33,K=0;for(;C>1&&I[K]===0&&!(I[K+1]&128);--C,++K);return I=I.subarray(K),I[0]&128||C>1&&I[0]===0&&!(I[1]&128)?1:(i.outputlen=6+U+C,F[0]=48,F[1]=i.outputlen-2,F[2]=2,F[3]=V.length,F.set(V,4),F[4+U]=2,F[5+U]=I.length,F.set(I,6+U),0)},signatureImport(i,E){if(E.length<8||E.length>72||E[0]!==48||E[1]!==E.length-2||E[2]!==2)return 1;const y=E[3];if(y===0||5+y>=E.length||E[4+y]!==2)return 1;const R=E[5+y];if(R===0||6+y+R!==E.length||E[4]&128||y>1&&E[4]===0&&!(E[5]&128)||E[y+6]&128||R>1&&E[y+6]===0&&!(E[y+7]&128))return 1;let F=E.subarray(4,4+y);if(F.length===33&&F[0]===0&&(F=F.subarray(1)),F.length>32)return 1;let V=E.subarray(6+y);if(V.length===33&&V[0]===0&&(V=V.slice(1)),V.length>32)throw new Error("S length is too long");let U=new A(F);U.cmp(v.n)>=0&&(U=new A(0));let G=new A(E.subarray(6+y));return G.cmp(v.n)>=0&&(G=new A(0)),i.set(U.toArrayLike(Uint8Array,"be",32),0),i.set(G.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(i,E,y,R,F){if(F){const G=F;F=I=>{const C=G(E,y,null,R,I);if(!(C instanceof Uint8Array&&C.length===32))throw new Error("This is the way");return new A(C)}}const V=new A(y);if(V.cmp(v.n)>=0||V.isZero())return 1;let U;try{U=f.sign(E,y,{canonical:!0,k:F,pers:R})}catch{return 1}return i.signature.set(U.r.toArrayLike(Uint8Array,"be",32),0),i.signature.set(U.s.toArrayLike(Uint8Array,"be",32),32),i.recid=U.recoveryParam,0},ecdsaVerify(i,E,y){const R={r:i.subarray(0,32),s:i.subarray(32,64)},F=new A(R.r),V=new A(R.s);if(F.cmp(v.n)>=0||V.cmp(v.n)>=0)return 1;if(V.cmp(f.nh)===1||F.isZero()||V.isZero())return 3;const U=d(y);if(U===null)return 2;const G=U.getPublic();return f.verify(E,R,G)?0:3},ecdsaRecover(i,E,y,R){const F={r:E.slice(0,32),s:E.slice(32,64)},V=new A(F.r),U=new A(F.s);if(V.cmp(v.n)>=0||U.cmp(v.n)>=0)return 1;if(V.isZero()||U.isZero())return 2;let G;try{G=f.recoverPubKey(R,F,y)}catch{return 2}return w(i,G),0},ecdh(i,E,y,R,F,V,U){const G=d(E);if(G===null)return 1;const I=new A(y);if(I.cmp(v.n)>=0||I.isZero())return 2;const C=G.getPublic().mul(I);if(F===void 0){const K=C.encode(null,!0),O=f.hash().update(K).digest();for(let X=0;X<32;++X)i[X]=O[X]}else{V||(V=new Uint8Array(32));const K=C.getX().toArray("be",32);for(let ee=0;ee<32;++ee)V[ee]=K[ee];U||(U=new Uint8Array(32));const O=C.getY().toArray("be",32);for(let ee=0;ee<32;++ee)U[ee]=O[ee];const X=F(V,U,R);if(!(X instanceof Uint8Array&&X.length===i.length))return 2;i.set(X)}return 0}}},27655:function(ne){const s={IMPOSSIBLE_CASE:"Impossible case. Please create issue.",TWEAK_ADD:"The tweak was out of range or the resulted private key is invalid",TWEAK_MUL:"The tweak was out of range or equal to zero",CONTEXT_RANDOMIZE_UNKNOW:"Unknow error on context randomization",SECKEY_INVALID:"Private Key is invalid",PUBKEY_PARSE:"Public Key could not be parsed",PUBKEY_SERIALIZE:"Public Key serialization error",PUBKEY_COMBINE:"The sum of the public keys is not valid",SIG_PARSE:"Signature could not be parsed",SIGN:"The nonce generation function failed, or the private key was invalid",RECOVER:"Public key could not be recover",ECDH:"Scalar was invalid (zero or overflow)"};function k(b,a){if(!b)throw new Error(a)}function B(b,a,d){if(k(a instanceof Uint8Array,`Expected ${b} to be an Uint8Array`),d!==void 0)if(Array.isArray(d)){const w=d.join(", "),i=`Expected ${b} to be an Uint8Array with length [${w}]`;k(d.includes(a.length),i)}else{const w=`Expected ${b} to be an Uint8Array with length ${d}`;k(a.length===d,w)}}function f(b){k(A(b)==="Boolean","Expected compressed to be a Boolean")}function v(b=d=>new Uint8Array(d),a){return typeof b=="function"&&(b=b(a)),B("output",b,a),b}function A(b){return Object.prototype.toString.call(b).slice(8,-1)}ne.exports=b=>({contextRandomize(a){switch(k(a===null||a instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),a!==null&&B("seed",a,32),b.contextRandomize(a)){case 1:throw new Error(s.CONTEXT_RANDOMIZE_UNKNOW)}},privateKeyVerify(a){return B("private key",a,32),b.privateKeyVerify(a)===0},privateKeyNegate(a){switch(B("private key",a,32),b.privateKeyNegate(a)){case 0:return a;case 1:throw new Error(s.IMPOSSIBLE_CASE)}},privateKeyTweakAdd(a,d){switch(B("private key",a,32),B("tweak",d,32),b.privateKeyTweakAdd(a,d)){case 0:return a;case 1:throw new Error(s.TWEAK_ADD)}},privateKeyTweakMul(a,d){switch(B("private key",a,32),B("tweak",d,32),b.privateKeyTweakMul(a,d)){case 0:return a;case 1:throw new Error(s.TWEAK_MUL)}},publicKeyVerify(a){return B("public key",a,[33,65]),b.publicKeyVerify(a)===0},publicKeyCreate(a,d=!0,w){switch(B("private key",a,32),f(d),w=v(w,d?33:65),b.publicKeyCreate(w,a)){case 0:return w;case 1:throw new Error(s.SECKEY_INVALID);case 2:throw new Error(s.PUBKEY_SERIALIZE)}},publicKeyConvert(a,d=!0,w){switch(B("public key",a,[33,65]),f(d),w=v(w,d?33:65),b.publicKeyConvert(w,a)){case 0:return w;case 1:throw new Error(s.PUBKEY_PARSE);case 2:throw new Error(s.PUBKEY_SERIALIZE)}},publicKeyNegate(a,d=!0,w){switch(B("public key",a,[33,65]),f(d),w=v(w,d?33:65),b.publicKeyNegate(w,a)){case 0:return w;case 1:throw new Error(s.PUBKEY_PARSE);case 2:throw new Error(s.IMPOSSIBLE_CASE);case 3:throw new Error(s.PUBKEY_SERIALIZE)}},publicKeyCombine(a,d=!0,w){k(Array.isArray(a),"Expected public keys to be an Array"),k(a.length>0,"Expected public keys array will have more than zero items");for(const i of a)B("public key",i,[33,65]);switch(f(d),w=v(w,d?33:65),b.publicKeyCombine(w,a)){case 0:return w;case 1:throw new Error(s.PUBKEY_PARSE);case 2:throw new Error(s.PUBKEY_COMBINE);case 3:throw new Error(s.PUBKEY_SERIALIZE)}},publicKeyTweakAdd(a,d,w=!0,i){switch(B("public key",a,[33,65]),B("tweak",d,32),f(w),i=v(i,w?33:65),b.publicKeyTweakAdd(i,a,d)){case 0:return i;case 1:throw new Error(s.PUBKEY_PARSE);case 2:throw new Error(s.TWEAK_ADD)}},publicKeyTweakMul(a,d,w=!0,i){switch(B("public key",a,[33,65]),B("tweak",d,32),f(w),i=v(i,w?33:65),b.publicKeyTweakMul(i,a,d)){case 0:return i;case 1:throw new Error(s.PUBKEY_PARSE);case 2:throw new Error(s.TWEAK_MUL)}},signatureNormalize(a){switch(B("signature",a,64),b.signatureNormalize(a)){case 0:return a;case 1:throw new Error(s.SIG_PARSE)}},signatureExport(a,d){B("signature",a,64),d=v(d,72);const w={output:d,outputlen:72};switch(b.signatureExport(w,a)){case 0:return d.slice(0,w.outputlen);case 1:throw new Error(s.SIG_PARSE);case 2:throw new Error(s.IMPOSSIBLE_CASE)}},signatureImport(a,d){switch(B("signature",a),d=v(d,64),b.signatureImport(d,a)){case 0:return d;case 1:throw new Error(s.SIG_PARSE);case 2:throw new Error(s.IMPOSSIBLE_CASE)}},ecdsaSign(a,d,w={},i){B("message",a,32),B("private key",d,32),k(A(w)==="Object","Expected options to be an Object"),w.data!==void 0&&B("options.data",w.data),w.noncefn!==void 0&&k(A(w.noncefn)==="Function","Expected options.noncefn to be a Function"),i=v(i,64);const E={signature:i,recid:null};switch(b.ecdsaSign(E,a,d,w.data,w.noncefn)){case 0:return E;case 1:throw new Error(s.SIGN);case 2:throw new Error(s.IMPOSSIBLE_CASE)}},ecdsaVerify(a,d,w){switch(B("signature",a,64),B("message",d,32),B("public key",w,[33,65]),b.ecdsaVerify(a,d,w)){case 0:return!0;case 3:return!1;case 1:throw new Error(s.SIG_PARSE);case 2:throw new Error(s.PUBKEY_PARSE)}},ecdsaRecover(a,d,w,i=!0,E){switch(B("signature",a,64),k(A(d)==="Number"&&d>=0&&d<=3,"Expected recovery id to be a Number within interval [0, 3]"),B("message",w,32),f(i),E=v(E,i?33:65),b.ecdsaRecover(E,a,d,w)){case 0:return E;case 1:throw new Error(s.SIG_PARSE);case 2:throw new Error(s.RECOVER);case 3:throw new Error(s.IMPOSSIBLE_CASE)}},ecdh(a,d,w={},i){switch(B("public key",a,[33,65]),B("private key",d,32),k(A(w)==="Object","Expected options to be an Object"),w.data!==void 0&&B("options.data",w.data),w.hashfn!==void 0?(k(A(w.hashfn)==="Function","Expected options.hashfn to be a Function"),w.xbuf!==void 0&&B("options.xbuf",w.xbuf,32),w.ybuf!==void 0&&B("options.ybuf",w.ybuf,32),B("output",i)):i=v(i,32),b.ecdh(i,a,d,w.data,w.hashfn,w.xbuf,w.ybuf)){case 0:return i;case 1:throw new Error(s.PUBKEY_PARSE);case 2:throw new Error(s.ECDH)}}})},14034:function(ne){var s="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",k="0123456789ABCDEFGHIJKLMNOPQRSTUV",B="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function f(v,A){var b=v.indexOf(A);if(b===-1)throw new Error("Invalid character found: "+A);return b}ne.exports=function(A,b){var a;switch(b){case"RFC3548":case"RFC4648":a=s,A=A.replace(/=+$/,"");break;case"RFC4648-HEX":a=k,A=A.replace(/=+$/,"");break;case"Crockford":a=B,A=A.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1");break;default:throw new Error("Unknown base32 variant: "+b)}for(var d=A.length,w=0,i=0,E=0,y=new Uint8Array(d*5/8|0),R=0;R<d;R++)i=i<<5|f(a,A[R]),w+=5,w>=8&&(y[E++]=i>>>w-8&255,w-=8);return y.buffer}},74156:function(ne,s,k){const B=k(20829);function f(C,K,O){const X=C[K]+C[O];let Z=C[K+1]+C[O+1];X>=4294967296&&Z++,C[K]=X,C[K+1]=Z}function v(C,K,O,X){let Z=C[K]+O;O<0&&(Z+=4294967296);let ee=C[K+1]+X;Z>=4294967296&&ee++,C[K]=Z,C[K+1]=ee}function A(C,K){return C[K]^C[K+1]<<8^C[K+2]<<16^C[K+3]<<24}function b(C,K,O,X,Z,ee){const ge=E[Z],Ee=E[Z+1],fe=E[ee],S=E[ee+1];f(i,C,K),v(i,C,ge,Ee);let g=i[X]^i[C],l=i[X+1]^i[C+1];i[X]=l,i[X+1]=g,f(i,O,X),g=i[K]^i[O],l=i[K+1]^i[O+1],i[K]=g>>>24^l<<8,i[K+1]=l>>>24^g<<8,f(i,C,K),v(i,C,fe,S),g=i[X]^i[C],l=i[X+1]^i[C+1],i[X]=g>>>16^l<<16,i[X+1]=l>>>16^g<<16,f(i,O,X),g=i[K]^i[O],l=i[K+1]^i[O+1],i[K]=l>>>31^g<<1,i[K+1]=g>>>31^l<<1}const a=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),d=[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],w=new Uint8Array(d.map(function(C){return C*2})),i=new Uint32Array(32),E=new Uint32Array(32);function y(C,K){let O=0;for(O=0;O<16;O++)i[O]=C.h[O],i[O+16]=a[O];for(i[24]=i[24]^C.t,i[25]=i[25]^C.t/4294967296,K&&(i[28]=~i[28],i[29]=~i[29]),O=0;O<32;O++)E[O]=A(C.b,4*O);for(O=0;O<12;O++)b(0,8,16,24,w[O*16+0],w[O*16+1]),b(2,10,18,26,w[O*16+2],w[O*16+3]),b(4,12,20,28,w[O*16+4],w[O*16+5]),b(6,14,22,30,w[O*16+6],w[O*16+7]),b(0,10,20,30,w[O*16+8],w[O*16+9]),b(2,12,22,24,w[O*16+10],w[O*16+11]),b(4,14,16,26,w[O*16+12],w[O*16+13]),b(6,8,18,28,w[O*16+14],w[O*16+15]);for(O=0;O<16;O++)C.h[O]=C.h[O]^i[O]^i[O+16]}const R=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function F(C,K,O,X){if(C===0||C>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(K&&K.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(O&&O.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(X&&X.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const Z={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:C};R.fill(0),R[0]=C,K&&(R[1]=K.length),R[2]=1,R[3]=1,O&&R.set(O,32),X&&R.set(X,48);for(let ee=0;ee<16;ee++)Z.h[ee]=a[ee]^A(R,ee*4);return K&&(V(Z,K),Z.c=128),Z}function V(C,K){for(let O=0;O<K.length;O++)C.c===128&&(C.t+=C.c,y(C,!1),C.c=0),C.b[C.c++]=K[O]}function U(C){for(C.t+=C.c;C.c<128;)C.b[C.c++]=0;y(C,!0);const K=new Uint8Array(C.outlen);for(let O=0;O<C.outlen;O++)K[O]=C.h[O>>2]>>8*(O&3);return K}function G(C,K,O,X,Z){O=O||64,C=B.normalizeInput(C),X&&(X=B.normalizeInput(X)),Z&&(Z=B.normalizeInput(Z));const ee=F(O,K,X,Z);return V(ee,C),U(ee)}function I(C,K,O,X,Z){const ee=G(C,K,O,X,Z);return B.toHex(ee)}ne.exports={blake2b:G,blake2bHex:I,blake2bInit:F,blake2bUpdate:V,blake2bFinal:U}},51843:function(ne,s,k){const B=k(20829);function f(U,G){return U[G]^U[G+1]<<8^U[G+2]<<16^U[G+3]<<24}function v(U,G,I,C,K,O){d[U]=d[U]+d[G]+K,d[C]=A(d[C]^d[U],16),d[I]=d[I]+d[C],d[G]=A(d[G]^d[I],12),d[U]=d[U]+d[G]+O,d[C]=A(d[C]^d[U],8),d[I]=d[I]+d[C],d[G]=A(d[G]^d[I],7)}function A(U,G){return U>>>G^U<<32-G}const b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint8Array([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]),d=new Uint32Array(16),w=new Uint32Array(16);function i(U,G){let I=0;for(I=0;I<8;I++)d[I]=U.h[I],d[I+8]=b[I];for(d[12]^=U.t,d[13]^=U.t/4294967296,G&&(d[14]=~d[14]),I=0;I<16;I++)w[I]=f(U.b,4*I);for(I=0;I<10;I++)v(0,4,8,12,w[a[I*16+0]],w[a[I*16+1]]),v(1,5,9,13,w[a[I*16+2]],w[a[I*16+3]]),v(2,6,10,14,w[a[I*16+4]],w[a[I*16+5]]),v(3,7,11,15,w[a[I*16+6]],w[a[I*16+7]]),v(0,5,10,15,w[a[I*16+8]],w[a[I*16+9]]),v(1,6,11,12,w[a[I*16+10]],w[a[I*16+11]]),v(2,7,8,13,w[a[I*16+12]],w[a[I*16+13]]),v(3,4,9,14,w[a[I*16+14]],w[a[I*16+15]]);for(I=0;I<8;I++)U.h[I]^=d[I]^d[I+8]}function E(U,G){if(!(U>0&&U<=32))throw new Error("Incorrect output length, should be in [1, 32]");const I=G?G.length:0;if(G&&!(I>0&&I<=32))throw new Error("Incorrect key length, should be in [1, 32]");const C={h:new Uint32Array(b),b:new Uint8Array(64),c:0,t:0,outlen:U};return C.h[0]^=16842752^I<<8^U,I>0&&(y(C,G),C.c=64),C}function y(U,G){for(let I=0;I<G.length;I++)U.c===64&&(U.t+=U.c,i(U,!1),U.c=0),U.b[U.c++]=G[I]}function R(U){for(U.t+=U.c;U.c<64;)U.b[U.c++]=0;i(U,!0);const G=new Uint8Array(U.outlen);for(let I=0;I<U.outlen;I++)G[I]=U.h[I>>2]>>8*(I&3)&255;return G}function F(U,G,I){I=I||32,U=B.normalizeInput(U);const C=E(I,G);return y(C,U),R(C)}function V(U,G,I){const C=F(U,G,I);return B.toHex(C)}ne.exports={blake2s:F,blake2sHex:V,blake2sInit:E,blake2sUpdate:y,blake2sFinal:R}},92493:function(ne,s,k){const B=k(74156),f=k(51843);ne.exports={blake2b:B.blake2b,blake2bHex:B.blake2bHex,blake2bInit:B.blake2bInit,blake2bUpdate:B.blake2bUpdate,blake2bFinal:B.blake2bFinal,blake2s:f.blake2s,blake2sHex:f.blake2sHex,blake2sInit:f.blake2sInit,blake2sUpdate:f.blake2sUpdate,blake2sFinal:f.blake2sFinal}},20829:function(ne){const s="Input must be an string, Buffer or Uint8Array";function k(b){let a;if(b instanceof Uint8Array)a=b;else if(typeof b=="string")a=new TextEncoder().encode(b);else throw new Error(s);return a}function B(b){return Array.prototype.map.call(b,function(a){return(a<16?"0":"")+a.toString(16)}).join("")}function f(b){return(4294967296+b).toString(16).substring(1)}function v(b,a,d){let w=`
3
- `+b+" = ";for(let i=0;i<a.length;i+=2){if(d===32)w+=f(a[i]).toUpperCase(),w+=" ",w+=f(a[i+1]).toUpperCase();else if(d===64)w+=f(a[i+1]).toUpperCase(),w+=f(a[i]).toUpperCase();else throw new Error("Invalid size "+d);i%6===4?w+=`
4
- `+new Array(b.length+4).join(" "):i<a.length-2&&(w+=" ")}console.log(w)}function A(b,a,d){let w=new Date().getTime();const i=new Uint8Array(a);for(let y=0;y<a;y++)i[y]=y%256;const E=new Date().getTime();console.log("Generated random input in "+(E-w)+"ms"),w=E;for(let y=0;y<d;y++){const R=b(i),F=new Date().getTime(),V=F-w;w=F,console.log("Hashed in "+V+"ms: "+R.substring(0,20)+"..."),console.log(Math.round(a/(1<<20)/(V/1e3)*100)/100+" MB PER SECOND")}}ne.exports={normalizeInput:k,toHex:B,debugPrint:v,testSpeed:A}},42394:function(ne,s,k){const B=k(92861).Buffer;ne.exports=class{constructor(v=B.from([])){this.buffer=v,this._bytesRead=0,this._bytesWrote=0}read(v){this._bytesRead+=v;const A=this.buffer.slice(0,v);return this.buffer=this.buffer.slice(v),A}write(v){v=B.from(v),this._bytesWrote+=v.length,this.buffer=B.concat([this.buffer,v])}get end(){return!this.buffer.length}get bytesRead(){return this._bytesRead}get bytesWrote(){return this._bytesWrote}}},68249:function(ne,s,k){s.unsigned=k(77698),k(7905)},7905:function(ne,s,k){const B=k(39404),f=k(42394);ne.exports={encode:a,decode:d,write:b,read:v,readBn:A};function v(w){return A(w).toString()}function A(w){const i=new B(0);let E=0,y;for(;y=w.read(1)[0],i.ior(new B(y&127).shln(E)),E+=7,y>>7!==0;);return y&64&&i.setn(E),i.fromTwos(E)}function b(w,i){let E=new B(w);const y=E.isNeg();for(y&&(E=E.toTwos(E.bitLength()+8));;){const F=E.maskn(7).toNumber();if(E.ishrn(7),R(E)&&(F&64)!==0||E.isZero()&&(F&64)===0){i.write([F]);break}else i.write([F|128])}function R(F){return y&&F.toString(2).indexOf("0")<0}}function a(w){const i=new f;return b(w,i),i.buffer}function d(w){const i=new f(w);return v(i)}},77698:function(ne,s,k){const B=k(39404),f=k(42394);ne.exports={encode:a,decode:d,read:v,readBn:A,write:b};function v(w){return A(w).toString()}function A(w){const i=new B(0);let E=0,y;for(;y=w.read(1)[0],i.ior(new B(y&127).shln(E)),y>>7!==0;)E+=7;return i}function b(w,i){const E=new B(w);for(;;){const y=E.maskn(7).toNumber();if(E.ishrn(7),E.isZero()){i.write([y]);break}else i.write([y|128])}}function a(w){const i=new f;return b(w,i),i.buffer}function d(w){const i=new f(w);return v(i)}},31700:function(ne,s,k){"use strict";k.d(s,{pV:function(){return D},lg:function(){return a},X$:function(){return d},yo:function(){return Ge},to:function(){return T},D7:function(){return I},ou:function(){return ke},ZX:function(){return de},uW:function(){return m}});var B=k(72505),f=k(39404),v;(function(o){o.ETH="10"})(v||(v={}));const A=255;var b;(function(o){o[o.ID=0]="ID",o[o.SECP256K1=1]="SECP256K1",o[o.ACTOR=2]="ACTOR",o[o.BLS=3]="BLS",o[o.DELEGATED=4]="DELEGATED"})(b||(b={}));var a;(function(o){o.Mainnet="mainnet",o.Calibration="calibration",o.Butterfly="butterfly"})(a||(a={}));var d;(function(o){o.Mainnet="f",o.Testnet="t"})(d||(d={}));const w=20,i=54,E=48,y=20,R=20,F=9,V=new f(2).pow(new f(63)).sub(new f(1));var U;(function(o){o[o.Zero=0]="Zero"})(U||(U={}));var G;(function(o){o[o.Transfer=0]="Transfer",o[o.InvokeEVM=3844450837]="InvokeEVM"})(G||(G={}));var I;(function(o){o[o.SECP256K1=1]="SECP256K1",o[o.BLS=3]="BLS"})(I||(I={}));var C;(function(o){o[o.System=0]="System",o[o.Init=1]="Init",o[o.Reward=2]="Reward",o[o.Cron=3]="Cron",o[o.StoragePower=4]="StoragePower",o[o.StorageMarket=5]="StorageMarket",o[o.VerifiedRegistry=6]="VerifiedRegistry",o[o.DataCap=7]="DataCap",o[o.EAM=10]="EAM"})(C||(C={}));var K;(function(o){o[o.Exec=2]="Exec",o[o.Exec4=3]="Exec4"})(K||(K={}));var O;(function(o){o[o.UpdateChannelState=2]="UpdateChannelState",o[o.Settle=3]="Settle",o[o.Collect=4]="Collect"})(O||(O={}));var X;(function(o){o.Account="bafk2bzacebor5mnjnsav34cmm5pcd3dy4wubbv4wtcrvba7depy3sct7ie4sy",o.Cron="bafk2bzacebetehhedh55alfn4rcx2mhjhvuiustxlhtxc3drkemnpttws5eqw",o.DataCap="bafk2bzaced6uhmrh5jjexhw4lco4ipesi2iutl7uupnyspgmnbydyo3amtu4i",o.EAM="bafk2bzacea6wzcnflfnaxqnwydoghh7ezg5au32ew3bnzljzpiw6fimhlpoiu",o.EthAccount="bafk2bzacedrbpvjvyzif2cjxosm4pliyq2m6wzndvrg7r6hzdhixplzvgubbw",o.EVM="bafk2bzaceabftmhejmvjvpzmbsv4cvaew6v5juj5sqtq7cfijugwsnahnsy5w",o.Init="bafk2bzaceduyjd35y7o2lhvevtysqf45rp5ot7x5f36q6iond6dyiz6773g5q",o.Multisig="bafk2bzacebcb72fmbpocetnzgni2wnbrduamlqx6fl3yelrlzu7id6bu5ib5g",o.PaymentChannel="bafk2bzaceazwhm63kyp47pste5i5acnuhosrgythyagf3kc5clogiqqx6vkzk",o.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",o.Reward="bafk2bzacecp7xo5ev46y64zr5osnn5fxo7itpoqw235tcfv6eo4rymzdemet2",o.StorageMarket="bafk2bzacedjt5mueomasx7dijooxnwxsbtzu2dj2ppp45rtle4kiinkmgzeei",o.StorageMiner="bafk2bzacebkjnjp5okqjhjxzft5qkuv36u4tz7inawseiwi2kw4j43xpxvhpm",o.StoragePower="bafk2bzaced2qsypqwore3jrdtaesh4itst2fyeepdsozvtffc2pianzmphdum",o.System="bafk2bzacedqvik2n3phnj3cni3h2k5mtvz43nyq7mdmv7k7euejysvajywdug",o.VerifiedRegistry="bafk2bzaceceoo5jlom2zweh7kpye2vkj33wgqnkjshlsw2neemqkfg5g2rmvg"})(X||(X={}));var Z;(function(o){o.Account="bafk2bzaceampw4romta75hyz5p4cqriypmpbgnkxncgxgqn6zptv5lsp2w2bo",o.Cron="bafk2bzacedcbtsifegiu432m5tysjzkxkmoczxscb6hqpmrr6img7xzdbbs2g",o.DataCap="bafk2bzacealj5uk7wixhvk7l5tnredtelralwnceafqq34nb2lbylhtuyo64u",o.EAM="bafk2bzacedrpm5gbleh4xkyo2jvs7p5g6f34soa6dpv7ashcdgy676snsum6g",o.EthAccount="bafk2bzaceaqoc5zakbhjxn3jljc4lxnthllzunhdor7sxhwgmskvc6drqc3fa",o.EVM="bafk2bzaceahmzdxhqsm7cu2mexusjp6frm7r4kdesvti3etv5evfqboos2j4g",o.Init="bafk2bzaced2f5rhir3hbpqbz5ght7ohv2kgj42g5ykxrypuo2opxsup3ykwl6",o.Multisig="bafk2bzaceduf3hayh63jnl4z2knxv7cnrdenoubni22fxersc4octlwpxpmy4",o.PaymentChannel="bafk2bzaceartlg4mrbwgzcwric6mtvyawpbgx2xclo2vj27nna57nxynf3pgc",o.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",o.Reward="bafk2bzacebnhtaejfjtzymyfmbdrfmo7vgj3zsof6zlucbmkhrvcuotw5dxpq",o.StorageMarket="bafk2bzaceclejwjtpu2dhw3qbx6ow7b4pmhwa7ocrbbiqwp36sq5yeg6jz2bc",o.StorageMiner="bafk2bzaced4h7noksockro7glnssz2jnmo2rpzd7dvnmfs4p24zx3h6gtx47s",o.StoragePower="bafk2bzacec4ay4crzo73ypmh7o3fjendhbqrxake46bprabw67fvwjz5q6ixq",o.System="bafk2bzacedakk5nofebyup4m7nvx6djksfwhnxzrfuq4oyemhpl4lllaikr64",o.VerifiedRegistry="bafk2bzacedfel6edzqpe5oujno7fog4i526go4dtcs6vwrdtbpy2xq6htvcg6"})(Z||(Z={}));var ee=k(14034),ge=k(68249);const Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",fe="0123456789ABCDEFGHIJKLMNOPQRSTUV",S="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function g(o,t,c){c=c||{};let p,L;switch(t){case"RFC3548":case"RFC4648":p=Ee,L=!0;break;case"RFC4648-HEX":p=fe,L=!0;break;case"Crockford":p=S,L=!1;break}if(!p)throw new Error(`Unknown base32 variant: ${t}`);const _=c.padding!==void 0?c.padding:L,ie=l(o);let ce=0,we=0,Ae="";for(let Ue=0;Ue<ie.byteLength;Ue++)for(we=we<<8|ie.getUint8(Ue),ce+=8;ce>=5;)Ae+=p[we>>>ce-5&31],ce-=5;if(ce>0&&(Ae+=p[we<<5-ce&31]),_)for(;Ae.length%8!==0;)Ae+="=";return Ae}function l(o){if(o instanceof Int8Array||o instanceof Uint8Array||o instanceof Uint8ClampedArray)return new DataView(o.buffer,o.byteOffset,o.byteLength);if(o instanceof ArrayBuffer)return new DataView(o);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}class P extends Error{constructor(t){super(),this.message=`Invalid protocol indicator byte [${t}]`}}class N extends Error{constructor(t){super(),this.message="Unknown protocol indicator byte [${value}]"}}class M extends Error{constructor(t){super(),this.message=`Invalid payload length [${t}]`}}class $ extends Error{constructor(t){super(),this.message=`Invalid namespace [${t}]`}}class oe extends Error{constructor(t){super(),this.message=`Invalid network [${t}]`}}class se extends Error{constructor(){super(),this.message="Invalid subAddress."}}class ae extends Error{constructor(t){super(),this.message=`${t} protocol not supported.`}}class Q extends Error{constructor(t,c){super(),this.message=`Invalid address (checksum not matching the payload). ${t} vs ${c}`}}class he extends Error{constructor(){super(),this.message="Private key need to be an instance of Buffer or a base64 string."}}var z=k(92493),be=k(48287).Buffer;function Ie(o){const t=z.blake2bInit(4);return z.blake2bUpdate(t,o),be.from(z.blake2bFinal(t))}function me(o){let t=0;for(;t<o.length;){const c=o[t];if(t++,c<128)break}return t==o.length?-1:t}const Pe=o=>Object.values(d).includes(o),Me=o=>Object.values(Network).includes(o),He=o=>o===a.Mainnet?d.Mainnet:d.Testnet,Ne=o=>o!==Network.Mainnet;var h=k(48287).Buffer;const st=class{constructor(t,c){x(this,"networkPrefix");x(this,"protocol");x(this,"getPayload",()=>this.payload);x(this,"getNetworkPrefix",()=>this.networkPrefix);x(this,"getProtocol",()=>this.protocol);x(this,"getChecksum",()=>Ie(this.toBytes()));this.networkPrefix=t,this.protocol=c}};let D=st;x(D,"fromString",t=>{const c=parseInt(t[1]);switch(c){case b.ID:return ue.fromString(t);case b.ACTOR:return pe.fromString(t);case b.SECP256K1:return ye.fromString(t);case b.BLS:return Y.fromString(t);case b.DELEGATED:{const p=Be.fromString(t);return st.isFilEthAddress(p)?new Ke(p.getNetworkPrefix(),p.getSubAddress()):p}default:throw new N(c)}}),x(D,"fromBytes",(t,c)=>{const p=c[0];switch(p){case b.ID:return ue.fromBytes(t,c);case b.ACTOR:return pe.fromBytes(t,c);case b.SECP256K1:return ye.fromBytes(t,c);case b.BLS:return Y.fromBytes(t,c);case b.DELEGATED:{const L=Be.fromBytes(t,c);return st.isFilEthAddress(L)?new Ke(L.getNetworkPrefix(),L.getSubAddress()):L}default:throw new N(p)}}),x(D,"fromEthAddress",(t,c)=>{if(typeof c=="string"){const L=c.startsWith("0x")?c.substring(2):c;c=h.from(L,"hex")}const p=h.alloc(12);if(p[0]=A,p.compare(c,0,12)==0){let L=12;for(;c[L]==0;)L+=1;return new ue(t,h.from(c.subarray(L)))}return new Ke(t,c)}),x(D,"isAddressId",t=>t.protocol==b.ID),x(D,"isAddressBls",t=>t.protocol==b.BLS),x(D,"isAddressSecp256k1",t=>t.protocol==b.SECP256K1),x(D,"isAddressDelegated",t=>t.protocol==b.DELEGATED),x(D,"isFilEthAddress",t=>t.protocol==b.DELEGATED&&"namespace"in t&&t.namespace==v.ETH),x(D,"isAddressActor",t=>t.protocol==b.ACTOR);class Y extends D{constructor(c,p){super(c,b.BLS);x(this,"payload");x(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));x(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+g(h.concat([this.payload,c]),"RFC4648",{padding:!1}).toLowerCase()});if(p.byteLength!==E)throw new M(p.byteLength);this.payload=p}static fromString(c){const p=c[0],L=c[1];if(!Pe(p))throw new oe(p);if(parseInt(L)!=b.BLS)throw new P(parseInt(L));const _=h.from(ee(c.substring(2).toUpperCase(),"RFC4648")),ie=h.from(_.subarray(0,-4)),ce=h.from(_.subarray(-4)),we=new Y(p,ie);if(we.getChecksum().toString("hex")!==ce.toString("hex"))throw new Q(we.getChecksum().toString("hex"),ce.toString("hex"));return we}static fromBytes(c,p){if(p[0]!=b.BLS)throw new P(p[0]);const L=h.from(p.subarray(1));return new Y(c,L)}}class ue extends D{constructor(c,p){super(c,b.ID);x(this,"id");x(this,"payload");x(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));x(this,"toString",()=>this.networkPrefix+this.protocol.toString()+ge.unsigned.decode(this.payload));x(this,"getId",()=>this.id);x(this,"toEthAddressHex",(c=!1)=>{const p=h.alloc(w);return p[0]=A,p.set(this.payload,w-this.payload.length),`${c?"0x":""}${p.toString("hex")}`});const L=typeof p=="string"?ge.unsigned.encode(p):p;if(L.length>F)throw new M(L.length);this.payload=L,this.id=this.toString().substring(2)}static fromString(c){const p=c[0],L=c[1];if(!Pe(p))throw new oe(p);if(parseInt(L)!=b.ID)throw new P(parseInt(L));const _=ge.unsigned.encode(c.substring(2));return new ue(p,_)}static fromBytes(c,p){if(p[0]!=b.ID)throw new P(p[0]);const L=h.from(p.subarray(1));return new ue(c,L)}}class ye extends D{constructor(c,p){super(c,b.SECP256K1);x(this,"payload");x(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));x(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+g(h.concat([this.payload,c]),"RFC4648",{padding:!1}).toLowerCase()});if(p.byteLength!==R)throw new M(p.byteLength);this.payload=p}static fromString(c){const p=c[0],L=c[1];if(!Pe(p))throw new oe(p);if(parseInt(L)!=b.SECP256K1)throw new P(parseInt(L));const _=h.from(ee(c.substring(2).toUpperCase(),"RFC4648")),ie=h.from(_.subarray(0,-4)),ce=h.from(_.subarray(-4)),we=new ye(p,ie);if(we.getChecksum().toString("hex")!==ce.toString("hex"))throw new Q(we.getChecksum().toString("hex"),ce.toString("hex"));return we}static fromBytes(c,p){if(p[0]!=b.SECP256K1)throw new P(p[0]);const L=h.from(p.subarray(1));return new ye(c,L)}}class pe extends D{constructor(c,p){super(c,b.ACTOR);x(this,"payload");x(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));x(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+g(h.concat([this.payload,c]),"RFC4648",{padding:!1}).toLowerCase()});if(p.byteLength!==y)throw new M(p.byteLength);this.payload=p}static fromString(c){const p=c[0],L=c[1];if(!Pe(p))throw new oe(p);if(parseInt(L)!=b.ACTOR)throw new P(parseInt(L));const _=h.from(ee(c.substring(2).toUpperCase(),"RFC4648")),ie=h.from(_.subarray(0,-4)),ce=h.from(_.subarray(-4)),we=new pe(p,ie);if(we.getChecksum().toString("hex")!==ce.toString("hex"))throw new Q(we.getChecksum().toString("hex"),ce.toString("hex"));return we}static fromBytes(c,p){if(p[0]!=b.ACTOR)throw new P(p[0]);const L=h.from(p.subarray(1));return new pe(c,L)}}class Be extends D{constructor(c,p,L){super(c,b.DELEGATED);x(this,"payload");x(this,"namespace");x(this,"subAddress");x(this,"getNamespace",()=>this.namespace);x(this,"getSubAddress",()=>this.subAddress);x(this,"toBytes",()=>{const c=h.from(ge.unsigned.encode(this.namespace)),p=h.from(ge.unsigned.encode(this.protocol));return h.concat([p,c,this.subAddress])});x(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+this.namespace+"f"+g(h.concat([this.subAddress,c]),"RFC4648",{padding:!1}).toLowerCase()});if(new f(p).gt(V))throw new $(p);if(L.length===0||L.length>i)throw new se;this.namespace=p,this.subAddress=L,this.payload=h.from(this.toBytes().subarray(1))}static fromString(c){const p=c[0],L=c[1];if(!Pe(p))throw new oe(p);if(parseInt(L)!=b.DELEGATED)throw new P(parseInt(L));const _=c.substring(2,c.indexOf("f",2)),ie=c.substring(c.indexOf("f",2)+1),ce=h.from(ee(ie.toUpperCase(),"RFC4648")),we=h.from(ce.subarray(0,-4)),Ae=h.from(ce.subarray(-4)),Ue=new Be(p,_,we);if(Ue.getChecksum().toString("hex")!==Ae.toString("hex"))throw new Q(Ue.getChecksum().toString("hex"),Ae.toString("hex"));return Ue}static fromBytes(c,p){if(p[0]!=b.DELEGATED)throw new P(p[0]);const L=me(h.from(p.subarray(1))),_=ge.unsigned.decode(h.from(p.subarray(1,1+L))),ie=h.from(p.subarray(L+1));return new Be(c,_,ie)}}class Ke extends Be{constructor(c,p){super(c,v.ETH,p);x(this,"toEthAddressHex",(c=!1)=>`${c?"0x":""}${this.subAddress.toString("hex")}`);if(p.length!==w)throw new Error("invalid ethereum address: length should be 32 bytes")}static fromBytes(c,p){const L=Be.fromBytes(c,p);if(L.getNamespace()!==v.ETH)throw new Error("invalid filecoin address for ethereum space");return new Ke(L.getNetworkPrefix(),L.getSubAddress())}static fromString(c){const p=Be.fromString(c);if(p.getNamespace()!==v.ETH)throw new Error("invalid filecoin address for ethereum space");return new Ke(p.getNetworkPrefix(),p.getSubAddress())}}const Ce="2.0",ct="Filecoin.MpoolGetNonce",Qe="Filecoin.MpoolPush",ft="Filecoin.StateWaitMsg",Je="Filecoin.GasEstimateMessageGas",ut="Filecoin.StateReadState",_e="Filecoin.StateListMiners",et="Filecoin.StateMinerInfo",tt="Filecoin.ClientQueryAsk",lt="Filecoin.WalletBalance";class Ge{constructor(t,c){x(this,"fetcher");x(this,"network");x(this,"getNetwork",()=>this.network);x(this,"validateNetwork",(t,c="address")=>{const p=He(this.network);if(typeof t=="string"&&(t=D.fromString(t)),t.getNetworkPrefix()!==p)throw new Error(`${c} belongs to ${t.getNetworkPrefix()} network while rpc allows ${p}`);return t});this.fetcher=B.create({baseURL:c.url,timeout:c.timeout,headers:{Authorization:`Bearer ${c.token}`}}),this.network=t}async getNonce(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ct,id:1,params:[t.toString()]})).data}catch(c){return this.handleError(c)}}async broadcastTransaction(t,c){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ce,method:Qe,id:1,params:[{Message:t.toJSON(),Signature:c.toJSON()}]})).data}catch(p){return this.handleError(p)}}async getGasEstimation(t){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ce,method:Je,id:1,params:[t.toJSON(),{MaxFee:"0"},null]})).data}catch(c){return this.handleError(c)}}async readState(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ut,id:1,params:[t.toString(),null]})).data}catch(c){return this.handleError(c)}}async waitMsgState(t,c,p){try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ft,id:1,params:[t,c,p,!1]})).data}catch(L){return this.handleError(L)}}async walletBalance(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:lt,id:1,params:[t.toString()]})).data}catch(c){return this.handleError(c)}}async listMiners(){try{return(await this.fetcher.post("",{jsonrpc:Ce,method:_e,id:1,params:[null]})).data}catch(t){return this.handleError(t)}}async getMinerInfo(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:et,id:1,params:[t.toString(),null]})).data}catch(c){return this.handleError(c)}}async askForStorage(t,c){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:tt,id:1,params:[c,t.toString()]})).data}catch(p){return this.handleError(p)}}handleError(t){if(B.isAxiosError(t)){if(t.response){if(t.response.data)return t.response.data;if(t.response.statusText)return{error:{message:`${t.response.status} - ${t.response.statusText}`}}}if(t.request)return{error:{message:"request made but no response received"}};if(t.message)return{error:{message:t.message}}}throw t}}class bt extends Ge{constructor(t){super(a.Mainnet,t)}}class yt extends Ge{constructor(t){super(a.Calibration,t)}}class We extends Ge{constructor(t){super(a.Butterfly,t)}}var ze=k(90749),ht=k(83328),rt=k(73513),dt=k.t(rt,2),je=k(17009),Oe=k(48287).Buffer;const nt=Oe.from([1,113,160,228,2,32]),ot=32,it=o=>{const t=o.split("/");return t[2].includes("'")?t[2].substring(0,t[2].length-1):t[2]};function ve(o){const t=z.blake2bInit(ot);z.blake2bUpdate(t,o);const c=Oe.from(z.blake2bFinal(t));return Oe.concat([nt,c])}function Te(o){const t=z.blake2bInit(32);return z.blake2bUpdate(t,ve(o)),Oe.from(z.blake2bFinal(t))}const Ze=o=>{if(typeof o=="string")if(o.substring(o.length-1)==="=")o=Oe.from(o,"base64");else throw new he;if(o.length!==32)throw new he;return o},n=o=>{const t=z.blake2bInit(20);return z.blake2bUpdate(t,o),Oe.from(z.blake2bFinal(t))},e=o=>I.BLS===o||I.SECP256K1===o;var r=k(48287).Buffer;const u=ht.Pr(dt),Ye=class{static recoverAccount(t,c,p,L){switch(c){case I.SECP256K1:{p=Ze(p);const{publicKey:_,address:ie}=Ye.getPublicSecp256k1FromPrivKey(t,p);return{type:c,privateKey:p,address:ie,publicKey:_,path:L}}default:throw new Error("not supported yet")}}};let m=Ye;x(m,"generateMnemonic",()=>ze.generateMnemonic(256)),x(m,"mnemonicToSeed",(t,c)=>ze.mnemonicToSeedSync(t,c)),x(m,"deriveAccount",(t,c,p,L,_)=>{const ie=Ye.mnemonicToSeed(t,L);return Ye.deriveAccountFromSeed(ie,c,p,_)}),x(m,"deriveAccountFromSeed",(t,c,p,L)=>{switch(typeof t=="string"&&(t=r.from(t,"hex")),c){case I.SECP256K1:{const _=u.fromSeed(t),{privateKey:ie}=_.derivePath(p);if(!ie)throw new Error("privateKey not generated");L||(L=it(p)==="1"?d.Testnet:d.Mainnet);const{publicKey:ce,address:we}=Ye.getPublicSecp256k1FromPrivKey(L,ie);return{type:c,privateKey:ie,publicKey:ce,address:we,path:p}}default:throw new Error("not supported yet")}}),x(m,"signTransaction",async(t,c)=>{const p=await c.serialize(),L=Te(p),{privateKey:_,type:ie}=t;switch(ie){case I.SECP256K1:{const ce=je.ecdsaSign(L,_);return new T(ie,r.concat([r.from(ce.signature),r.from([ce.recid])]))}default:throw new Error("not supported yet")}}),x(m,"verifySignature",async(t,c)=>{const p=await c.serialize(),L=Te(p);switch(t.getType()){case I.SECP256K1:{const _=t.getData(),ie=je.ecdsaRecover(_.subarray(0,-1),_[64],L,!1),ce=n(ie);return c.from.getPayload().toString("hex")!==ce.toString("hex")?!1:je.ecdsaVerify(_.subarray(0,-1),L,ie)}default:throw new Error("not supported yet")}}),x(m,"getPublicSecp256k1FromPrivKey",(t,c)=>{const p=je.publicKeyCreate(c),L=new Uint8Array(65);je.publicKeyConvert(p,!1,L);const _=r.from(L),ie=n(L);return{publicKey:_,address:new ye(t,ie)}});const wt=class{constructor(t,c){x(this,"type");x(this,"data");x(this,"toJSON",()=>({Type:this.type,Data:this.data.toString("base64")}));x(this,"getType",()=>this.type);x(this,"getData",()=>this.data);x(this,"isSecp256k1",()=>this.type===I.SECP256K1);x(this,"isBls",()=>this.type===I.BLS);this.type=t,this.data=c}};let T=wt;x(T,"fromJSON",t=>{if(typeof t!="object"||t===null)throw new Error("input should be an object");if(!("Type"in t)||typeof t.Type!="number")throw new Error("'Type' should be a number");if(!e(t.Type))throw new Error("invalid signature type");if(!("Data"in t)||typeof t.Data!="string")throw new Error("'Data' should be a base64 encoded string");return new wt(t.Type,r.from(t.Data,"base64"))});var H=k(48287).Buffer;const j=(o,t=10)=>{if(o.toString()==="0")return H.from("");const c=new f(o,t),p=c.toArrayLike(H,"be",c.byteLength()),L=H.from(c.isNeg()?"01":"00","hex");return H.concat([L,p])},q=(o,t=10)=>{if(o.length===0)return"0";if(o[0]!=0&&o[0]!=1)throw new Error("invalid bigint");const c=o[0]===1?"-":"",p=new f(o.subarray(1));return c+p.toString(t)},W=o=>new Promise(t=>setTimeout(t,o)),J=async o=>{let t=o();for(;!t;)await W(50),t=o();return t};var te=k(48287).Buffer;let re;k.e(1523).then(k.bind(k,71523)).then(o=>{re=o}).catch(o=>{throw o});const qe=class{constructor(t,c,p,L,_,ie,ce,we,Ae,Ue){x(this,"version");x(this,"to");x(this,"from");x(this,"nonce");x(this,"value");x(this,"gasLimit");x(this,"gasFeeCap");x(this,"gasPremium");x(this,"method");x(this,"params");x(this,"toJSON",()=>({To:this.to.toString(),From:this.from.toString(),Nonce:this.nonce,Value:this.value,Params:this.params,GasFeeCap:this.gasFeeCap,GasPremium:this.gasPremium,GasLimit:this.gasLimit,Method:this.method}));x(this,"serialize",async()=>{const t=await J(()=>re),c=[this.version,this.to.toBytes(),this.from.toBytes(),this.nonce,j(this.value,10),this.gasLimit,j(this.gasFeeCap,10),j(this.gasPremium,10),this.method,te.from(this.params,"base64")];return te.from(t.encode(c))});x(this,"prepareToSend",async t=>{const c=await t.getNonce(this.from);if("error"in c)throw new Error(c.error.message);this.nonce=c.result;const p=await t.getGasEstimation(this);if("error"in p)throw new Error(p.error.message);return this.gasFeeCap=p.result.GasFeeCap,this.gasLimit=p.result.GasLimit,this.gasPremium=p.result.GasPremium,this});if(this.version=t,this.to=c,this.from=p,this.nonce=L,this.value=_,this.gasLimit=ie,this.gasFeeCap=ce,this.gasPremium=we,this.method=Ae,this.params=Ue,_===""||_.includes("-"))throw new Error("value must not be empty or negative")}};let de=qe;x(de,"getNew",(t,c,p,L,_=te.alloc(0))=>new qe(U.Zero,t,c,0,p.toAtto(),0,"0","0",L,_.toString("base64"))),x(de,"fromCBOR",async(t,c)=>{typeof c=="string"&&(c=te.from(c,"hex"));const L=(await J(()=>re)).decode(c);if(!(L instanceof Array))throw new Error("Decoded raw tx should be an array");if(L.length<10)throw new Error("The cbor is missing some fields... please verify you have 9 fields.");const[_,ie,ce,we,Ae,Ue,Ct,Tt,Rt,Ut]=L;if(_!==U.Zero)throw new Error("Unsupported version");if(Ae[0]===1)throw new Error("Value cant be negative");const Nt=new f(te.from(Ae).toString("hex"),16).toString(10),Kt=new f(te.from(Ct).toString("hex"),16).toString(10),zt=new f(te.from(Tt).toString("hex"),16).toString(10);return new qe(_,D.fromBytes(t,ie),D.fromBytes(t,ce),we,Nt,Ue,Kt,zt,Rt,Ut.toString("base64"))}),x(de,"fromJSON",t=>{if(typeof t!="object"||t==null)throw new Error("tx should be an json object");if(!("To"in t)||typeof t.To!="string")throw new Error("'To' is a required field and has to be a 'string'");if(!("From"in t)||typeof t.From!="string")throw new Error("'From' is a required field and has to be a 'string'");if(!("Nonce"in t)||typeof t.Nonce!="number")throw new Error("'Nonce' is a required field and has to be a 'number'");if(!("Value"in t)||typeof t.Value!="string"||t.Value===""||t.Value.includes("-"))throw new Error("'Value' is a required field and has to be a 'string' but not empty or negative");if(!("GasFeeCap"in t)||typeof t.GasFeeCap!="string")throw new Error("'GasFeeCap' is a required field and has to be a 'string'");if(!("GasPremium"in t)||typeof t.GasPremium!="string")throw new Error("'GasPremium' is a required field and has to be a 'string'");if(!("GasLimit"in t)||typeof t.GasLimit!="number")throw new Error("'GasLimit' is a required field and has to be a 'number'");if(!("Method"in t)||typeof t.Method!="number")throw new Error("'Method' is a required field and has to be a 'number'");if(!("Params"in t)||typeof t.Params!="string")throw new Error("'Params' is a required field and has to be a 'string'");return new qe(U.Zero,D.fromString(t.To),D.fromString(t.From),t.Nonce,t.Value,t.GasLimit,t.GasFeeCap,t.GasPremium,t.Method,t.Params)});const le=(o,t)=>{const c=o.isNeg()?"-":"",p=o.abs().toString(),L=p.length-t,_=xe(L>0?`${p.substring(0,L)}.${p.substring(L)}`:`0.${"".padStart(-1*L,"0")}${p}`);return`${c}${_}`},xe=o=>{for(let t=o.length-1;t>=0;t--){if(o[t]==".")return o.substring(0,t);if(o[t]!="0"||t===1)return o.substring(0,t+1)}throw new Error("invalid value")},Se=18,Le=15,De=12,$e=9,Ve=6,Fe=3,St=0,xt=new f(10).pow(new f(Fe)),At=new f(10).pow(new f(Ve)),Pt=new f(10).pow(new f($e)),Bt=new f(10).pow(new f(De)),kt=new f(10).pow(new f(Le)),It=new f(10).pow(new f(Se)),Re=class{constructor(t){x(this,"value");x(this,"add",t=>(this.value=this.value.add(t.value),this));x(this,"sub",t=>(this.value=this.value.sub(t.value),this));x(this,"gt",t=>this.value.gt(t.value));x(this,"gte",t=>this.value.gte(t.value));x(this,"lt",t=>this.value.lt(t.value));x(this,"lte",t=>this.value.lte(t.value));x(this,"isNegative",()=>this.value.isNeg());x(this,"isPositive",()=>!this.value.isNeg());x(this,"isZero",()=>this.value.isZero());x(this,"toWhole",()=>le(this.value,Se));x(this,"toMilli",()=>le(this.value,Se-Fe));x(this,"toMicro",()=>le(this.value,Se-Ve));x(this,"toNano",()=>le(this.value,Se-$e));x(this,"toPico",()=>le(this.value,Se-De));x(this,"toFemto",()=>le(this.value,Se-Le));x(this,"toAtto",()=>le(this.value,0));x(this,"serialize",()=>j(this.value.toString(10),10));this.value=t}};let ke=Re;x(ke,"zero",()=>new Re(new f("0"))),x(ke,"deserialize",t=>new Re(new f(q(t,10),10))),x(ke,"fromAtto",t=>new Re(new f(t))),x(ke,"fromFemto",t=>new Re(new f(t).mul(xt))),x(ke,"fromPico",t=>new Re(new f(t).mul(At))),x(ke,"fromNano",t=>new Re(new f(t).mul(Pt))),x(ke,"fromMicro",t=>new Re(new f(t).mul(Bt))),x(ke,"fromMilli",t=>new Re(new f(t).mul(kt))),x(ke,"fromWhole",t=>new Re(new f(t).mul(It)));class gt{}x(gt,"send",null),x(gt,"getBalance",null);var Dt=k(48287).Buffer;class pt{}x(pt,"newTx",null),x(pt,"newExecTx",null);let mt;k.e(1523).then(k.bind(k,71523)).then(o=>{mt=o}).catch(o=>{throw o});let Et;k.e(2131).then(k.bind(k,92131)).then(o=>{Et=o}).catch(o=>{throw o});class Ft{constructor(t,c){x(this,"targetActorCid");x(this,"targetConstructorParams");x(this,"serialize",async()=>{const t=await waitFor(()=>mt),c=await waitFor(()=>Et);return t.encode([c.CID.parse(this.targetActorCid),this.targetConstructorParams])});this.targetActorCid=t,this.targetConstructorParams=c}}let vt;k.e(1523).then(k.bind(k,71523)).then(o=>{vt=o}).catch(o=>{throw o});class Mt{constructor(t,c){x(this,"from");x(this,"to");x(this,"serialize",async()=>(await waitFor(()=>vt)).encode([this.from.toBytes(),this.to.toBytes()]));this.from=t,this.to=c}}const Ht=o=>{switch(o){case Network.Calibration:return ActorsCalibrationV11;case Network.Mainnet:return ActorsMainnetV10;case Network.Butterfly:throw new Error("not implemented yet")}},at=class{constructor(t,c,p){x(this,"channelAddress");x(this,"from");x(this,"to");x(this,"getAddress",()=>this.channelAddress);x(this,"getTo",()=>this.to);x(this,"getFrom",()=>this.from);x(this,"settle",(t,c)=>{const{address:p}=c,L=Transaction.getNew(this.channelAddress,p,Token.zero(),PayChActorMethods.Settle);return at.sendTx(t,c,L)});x(this,"collect",(t,c)=>{const{address:p}=c,L=Transaction.getNew(this.channelAddress,p,Token.zero(),PayChActorMethods.Collect);return at.sendTx(t,c,L)});this.channelAddress=t,this.from=c,this.to=p}};let Xe=at;x(Xe,"create",null),x(Xe,"loadFromCid",null),x(Xe,"sendTx",null)}}]);
1
+ var Ot=Object.defineProperty;var Lt=(oe,o,R)=>o in oe?Ot(oe,o,{enumerable:!0,configurable:!0,writable:!0,value:R}):oe[o]=R;var P=(oe,o,R)=>(Lt(oe,typeof o!="symbol"?o+"":o,R),R);(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[1700],{73513:function(oe,o,R){"use strict";var C=R(48287).Buffer,c=R(9598),v=R(39615),B=R(22623);function y(h){var D=Object.create(null);return h&&Object.keys(h).forEach(function(X){if(X!=="default"){var le=Object.getOwnPropertyDescriptor(h,X);Object.defineProperty(D,X,le.get?le:{enumerable:!0,get:function(){return h[X]}})}}),D.default=h,Object.freeze(D)}var a=y(c);a.utils.hmacSha256Sync=(h,...D)=>v.hmac(B.sha256,h,a.utils.concatBytes(...D)),a.utils.sha256Sync=(...h)=>B.sha256(a.utils.concatBytes(...h));const d=a.utils._normalizePrivateKey,w=32,i=32,E=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),g=32;function T(h,D){for(let X=0;X<32;++X)if(h[X]!==D[X])return h[X]<D[X]?-1:1;return 0}function F(h){return!(!(h instanceof Uint8Array)||h.length!==i||T(h,E)>=0)}function V(h){return h instanceof Uint8Array&&h.length===64&&T(h.subarray(0,32),E)<0&&T(h.subarray(32,64),E)<0}function K(h){return h instanceof Uint8Array&&h.length===w}function H(h){return h===void 0||h instanceof Uint8Array&&h.length===g}function S(h){if(typeof h!="string")throw new TypeError("hexToNumber: expected string, got "+typeof h);return BigInt(`0x${h}`)}function A(h){return S(a.utils.bytesToHex(h))}function k(h){let D;if(typeof h=="bigint")D=h;else if(typeof h=="number"&&Number.isSafeInteger(h)&&h>=0)D=BigInt(h);else if(typeof h=="string"){if(h.length!==64)throw new Error("Expected 32 bytes of private scalar");D=S(h)}else if(h instanceof Uint8Array){if(h.length!==32)throw new Error("Expected 32 bytes of private scalar");D=A(h)}else throw new TypeError("Expected valid private scalar");if(D<0)throw new Error("Expected private scalar >= 0");return D}const U=(h,D)=>{const X=d(h),le=k(D),ge=a.utils._bigintTo32Bytes(a.utils.mod(X+le,a.CURVE.n));return a.utils.isValidPrivateKey(ge)?ge:null},Y=(h,D)=>{const X=d(h),le=k(D),ge=a.utils._bigintTo32Bytes(a.utils.mod(X-le,a.CURVE.n));return a.utils.isValidPrivateKey(ge)?ge:null},Z=h=>{const D=d(h),X=a.utils._bigintTo32Bytes(a.CURVE.n-D);return a.utils.isValidPrivateKey(X)?X:null},Q=(h,D,X)=>{const le=a.Point.fromHex(h),ge=k(D),me=a.Point.BASE.multiplyAndAddUnsafe(le,ge,1n);if(!me)throw new Error("Tweaked point at infinity");return me.toRawBytes(X)},be=(h,D,X)=>{const le=a.Point.fromHex(h),ge=typeof D=="string"?D:a.utils.bytesToHex(D),me=BigInt(`0x${ge}`);return le.multiply(me).toRawBytes(X)};function pe(h,D){return h===void 0?D!==void 0?f(D):!0:!!h}function ae(h){try{return h()}catch{return null}}function x(h,D){if(h.length===32!==D)return!1;try{return!!a.Point.fromHex(h)}catch{return!1}}function b(h){return x(h,!1)}function f(h){return x(h,!1)&&h.length===33}function I(h){return a.utils.isValidPrivateKey(h)}function z(h){return x(h,!0)}function M(h,D){if(!z(h))throw new Error("Expected Point");if(!F(D))throw new Error("Expected Tweak");return ae(()=>{const X=Q(h,D,!0);return{parity:X[0]%2===1?1:0,xOnlyPubkey:X.slice(1)}})}function G(h){if(!b(h))throw new Error("Expected Point");return h.slice(1,33)}function ne(h,D){if(!I(h))throw new Error("Expected Private");return ae(()=>a.getPublicKey(h,pe(D)))}function ie(h){if(!I(h))throw new Error("Expected Private");return G(ne(h))}function ce(h,D){if(!b(h))throw new Error("Expected Point");return a.Point.fromHex(h).toRawBytes(pe(D,h))}function W(h,D,X){if(!b(h))throw new Error("Expected Point");if(!F(D))throw new Error("Expected Tweak");return ae(()=>be(h,D,pe(X,h)))}function ue(h,D,X){if(!b(h)||!b(D))throw new Error("Expected Point");return ae(()=>{const le=a.Point.fromHex(h),ge=a.Point.fromHex(D);return le.equals(ge.negate())?null:le.add(ge).toRawBytes(pe(X,h))})}function O(h,D,X){if(!b(h))throw new Error("Expected Point");if(!F(D))throw new Error("Expected Tweak");return ae(()=>Q(h,D,pe(X,h)))}function ye(h,D){if(I(h)===!1)throw new Error("Expected Private");if(F(D)===!1)throw new Error("Expected Tweak");return ae(()=>U(h,D))}function ke(h,D){if(I(h)===!1)throw new Error("Expected Private");if(F(D)===!1)throw new Error("Expected Tweak");return ae(()=>Y(h,D))}function Ee(h){if(I(h)===!1)throw new Error("Expected Private");return Z(h)}function Pe(h,D,X){if(!I(D))throw new Error("Expected Private");if(!K(h))throw new Error("Expected Scalar");if(!H(X))throw new Error("Expected Extra Data (32 bytes)");return a.signSync(h,D,{der:!1,extraEntropy:X})}function Me(h,D,X=C.alloc(32,0)){if(!I(D))throw new Error("Expected Private");if(!K(h))throw new Error("Expected Scalar");if(!H(X))throw new Error("Expected Extra Data (32 bytes)");return a.schnorr.signSync(h,D,X)}function He(h,D,X,le){if(!b(D))throw new Error("Expected Point");if(!V(X))throw new Error("Expected Signature");if(!K(h))throw new Error("Expected Scalar");return a.verify(X,h,D,{strict:le})}function Ne(h,D,X){if(!z(D))throw new Error("Expected Point");if(!V(X))throw new Error("Expected Signature");if(!K(h))throw new Error("Expected Scalar");return a.schnorr.verifySync(X,h,D)}o.isPoint=b,o.isPointCompressed=f,o.isPrivate=I,o.isXOnlyPoint=z,o.pointAdd=ue,o.pointAddScalar=O,o.pointCompress=ce,o.pointFromScalar=ne,o.pointMultiply=W,o.privateAdd=ye,o.privateNegate=Ee,o.privateSub=ke,o.sign=Pe,o.signSchnorr=Me,o.verify=He,o.verifySchnorr=Ne,o.xOnlyPointAddTweak=M,o.xOnlyPointFromPoint=G,o.xOnlyPointFromScalar=ie},93238:function(oe,o,R){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.ripemd160=o.RIPEMD160=void 0;const C=R(37202),c=R(99175),v=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),B=new Uint8Array(new Array(16).fill(0).map((H,S)=>S)),y=B.map(H=>(9*H+5)%16);let a=[B],d=[y];for(let H=0;H<4;H++)for(let S of[a,d])S.push(S[H].map(A=>v[A]));const w=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(H=>new Uint8Array(H)),i=a.map((H,S)=>H.map(A=>w[S][A])),E=d.map((H,S)=>H.map(A=>w[S][A])),g=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),T=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function F(H,S,A,k){return H===0?S^A^k:H===1?S&A|~S&k:H===2?(S|~A)^k:H===3?S&k|A&~k:S^(A|~k)}const V=new Uint32Array(16);class K extends C.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:S,h1:A,h2:k,h3:U,h4:Y}=this;return[S,A,k,U,Y]}set(S,A,k,U,Y){this.h0=S|0,this.h1=A|0,this.h2=k|0,this.h3=U|0,this.h4=Y|0}process(S,A){for(let f=0;f<16;f++,A+=4)V[f]=S.getUint32(A,!0);let k=this.h0|0,U=k,Y=this.h1|0,Z=Y,Q=this.h2|0,be=Q,pe=this.h3|0,ae=pe,x=this.h4|0,b=x;for(let f=0;f<5;f++){const I=4-f,z=g[f],M=T[f],G=a[f],ne=d[f],ie=i[f],ce=E[f];for(let W=0;W<16;W++){const ue=(0,c.rotl)(k+F(f,Y,Q,pe)+V[G[W]]+z,ie[W])+x|0;k=x,x=pe,pe=(0,c.rotl)(Q,10)|0,Q=Y,Y=ue}for(let W=0;W<16;W++){const ue=(0,c.rotl)(U+F(I,Z,be,ae)+V[ne[W]]+M,ce[W])+b|0;U=b,b=ae,ae=(0,c.rotl)(be,10)|0,be=Z,Z=ue}}this.set(this.h1+Q+ae|0,this.h2+pe+b|0,this.h3+x+U|0,this.h4+k+Z|0,this.h0+Y+be|0)}roundClean(){V.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}o.RIPEMD160=K,o.ripemd160=(0,c.wrapConstructor)(()=>new K)},9598:function(oe,o,R){"use strict";/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(o,"__esModule",{value:!0}),o.utils=o.schnorr=o.verify=o.signSync=o.sign=o.getSharedSecret=o.recoverPublicKey=o.getPublicKey=o.Signature=o.Point=o.CURVE=void 0;const C=R(14923),c=BigInt(0),v=BigInt(1),B=BigInt(2),y=BigInt(3),a=BigInt(8),d=Object.freeze({a:c,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:v,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});o.CURVE=d;const w=(n,e)=>(n+e/B)/e,i={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(n){const{n:e}=d,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),l=-v*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),m=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),N=r,j=BigInt("0x100000000000000000000000000000000"),$=w(N*n,e),J=w(-l*n,e);let q=O(n-$*r-J*m,e),_=O(-$*l-J*N,e);const te=q>j,re=_>j;if(te&&(q=e-q),re&&(_=e-_),q>j||_>j)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:te,k1:q,k2neg:re,k2:_}}},E=32,g=32,T=32,F=E+1,V=2*E+1;function K(n){const{a:e,b:r}=d,l=O(n*n),m=O(l*n);return O(m+e*n+r)}const H=d.a===c;class S extends Error{constructor(e){super(e)}}function A(n){if(!(n instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(e,r,l){this.x=e,this.y=r,this.z=l}static fromAffine(e){if(!(e instanceof Z))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Z.ZERO)?k.ZERO:new k(e.x,e.y,v)}static toAffineBatch(e){const r=Pe(e.map(l=>l.z));return e.map((l,m)=>l.toAffine(r[m]))}static normalizeZ(e){return k.toAffineBatch(e).map(k.fromAffine)}equals(e){A(e);const{x:r,y:l,z:m}=this,{x:N,y:j,z:$}=e,J=O(m*m),q=O($*$),_=O(r*q),te=O(N*J),re=O(O(l*$)*q),de=O(O(j*m)*J);return _===te&&re===de}negate(){return new k(this.x,O(-this.y),this.z)}double(){const{x:e,y:r,z:l}=this,m=O(e*e),N=O(r*r),j=O(N*N),$=e+N,J=O(B*(O($*$)-m-j)),q=O(y*m),_=O(q*q),te=O(_-B*J),re=O(q*(J-te)-a*j),de=O(B*r*l);return new k(te,re,de)}add(e){A(e);const{x:r,y:l,z:m}=this,{x:N,y:j,z:$}=e;if(N===c||j===c)return this;if(r===c||l===c)return e;const J=O(m*m),q=O($*$),_=O(r*q),te=O(N*J),re=O(O(l*$)*q),de=O(O(j*m)*J),he=O(te-_),xe=O(de-re);if(he===c)return xe===c?this.double():k.ZERO;const Se=O(he*he),Le=O(he*Se),De=O(_*Se),$e=O(xe*xe-Le-B*De),Ve=O(xe*(De-$e)-re*Le),Fe=O(m*$*he);return new k($e,Ve,Fe)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const r=k.ZERO;if(typeof e=="bigint"&&e===c)return r;let l=ue(e);if(l===v)return this;if(!H){let te=r,re=this;for(;l>c;)l&v&&(te=te.add(re)),re=re.double(),l>>=v;return te}let{k1neg:m,k1:N,k2neg:j,k2:$}=i.splitScalar(l),J=r,q=r,_=this;for(;N>c||$>c;)N&v&&(J=J.add(_)),$&v&&(q=q.add(_)),_=_.double(),N>>=v,$>>=v;return m&&(J=J.negate()),j&&(q=q.negate()),q=new k(O(q.x*i.beta),q.y,q.z),J.add(q)}precomputeWindow(e){const r=H?128/e+1:256/e+1,l=[];let m=this,N=m;for(let j=0;j<r;j++){N=m,l.push(N);for(let $=1;$<2**(e-1);$++)N=N.add(m),l.push(N);m=N.double()}return l}wNAF(e,r){!r&&this.equals(k.BASE)&&(r=Z.BASE);const l=r&&r._WINDOW_SIZE||1;if(256%l)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let m=r&&Y.get(r);m||(m=this.precomputeWindow(l),r&&l!==1&&(m=k.normalizeZ(m),Y.set(r,m)));let N=k.ZERO,j=k.BASE;const $=1+(H?128/l:256/l),J=2**(l-1),q=BigInt(2**l-1),_=2**l,te=BigInt(l);for(let re=0;re<$;re++){const de=re*J;let he=Number(e&q);e>>=te,he>J&&(he-=_,e+=v);const xe=de,Se=de+Math.abs(he)-1,Le=re%2!==0,De=he<0;he===0?j=j.add(U(Le,m[xe])):N=N.add(U(De,m[Se]))}return{p:N,f:j}}multiply(e,r){let l=ue(e),m,N;if(H){const{k1neg:j,k1:$,k2neg:J,k2:q}=i.splitScalar(l);let{p:_,f:te}=this.wNAF($,r),{p:re,f:de}=this.wNAF(q,r);_=U(j,_),re=U(J,re),re=new k(O(re.x*i.beta),re.y,re.z),m=_.add(re),N=te.add(de)}else{const{p:j,f:$}=this.wNAF(l,r);m=j,N=$}return k.normalizeZ([m,N])[0]}toAffine(e){const{x:r,y:l,z:m}=this,N=this.equals(k.ZERO);e==null&&(e=N?a:Ee(m));const j=e,$=O(j*j),J=O($*j),q=O(r*$),_=O(l*J),te=O(m*j);if(N)return Z.ZERO;if(te!==v)throw new Error("invZ was invalid");return new Z(q,_)}}k.BASE=new k(d.Gx,d.Gy,v),k.ZERO=new k(c,v,c);function U(n,e){const r=e.negate();return n?r:e}const Y=new WeakMap;class Z{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,Y.delete(this)}hasEvenY(){return this.y%B===c}static fromCompressedHex(e){const r=e.length===32,l=ce(r?e:e.subarray(1));if(!le(l))throw new Error("Point is not on curve");const m=K(l);let N=ke(m);const j=(N&v)===v;r?j&&(N=O(-N)):(e[0]&1)===1!==j&&(N=O(-N));const $=new Z(l,N);return $.assertValidity(),$}static fromUncompressedHex(e){const r=ce(e.subarray(1,E+1)),l=ce(e.subarray(E+1,E*2+1)),m=new Z(r,l);return m.assertValidity(),m}static fromHex(e){const r=W(e),l=r.length,m=r[0];if(l===E)return this.fromCompressedHex(r);if(l===F&&(m===2||m===3))return this.fromCompressedHex(r);if(l===V&&m===4)return this.fromUncompressedHex(r);throw new Error(`Point.fromHex: received invalid point. Expected 32-${F} compressed bytes or ${V} uncompressed bytes, not ${l}`)}static fromPrivateKey(e){return Z.BASE.multiply(me(e))}static fromSignature(e,r,l){const{r:m,s:N}=Ke(r);if(![0,1,2,3].includes(l))throw new Error("Cannot recover: invalid recovery bit");const j=He(W(e)),{n:$}=d,J=l===2||l===3?m+$:m,q=Ee(J,$),_=O(-j*q,$),te=O(N*q,$),re=l&1?"03":"02",de=Z.fromHex(re+z(J)),he=Z.BASE.multiplyAndAddUnsafe(de,_,te);if(!he)throw new Error("Cannot recover signature: point at infinify");return he.assertValidity(),he}toRawBytes(e=!1){return ie(this.toHex(e))}toHex(e=!1){const r=z(this.x);return e?`${this.hasEvenY()?"02":"03"}${r}`:`04${r}${z(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:r,y:l}=this;if(!le(r)||!le(l))throw new Error(e);const m=O(l*l),N=K(r);if(O(m-N)!==c)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Z(this.x,O(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(e){return k.fromAffine(this).add(k.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return k.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,r,l){const m=k.fromAffine(this),N=r===c||r===v||this!==Z.BASE?m.multiplyUnsafe(r):m.multiply(r),j=k.fromAffine(e).multiplyUnsafe(l),$=N.add(j);return $.equals(k.ZERO)?void 0:$.toAffine()}}o.Point=Z,Z.BASE=new Z(d.Gx,d.Gy),Z.ZERO=new Z(c,c);function Q(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function be(n){if(n.length<2||n[0]!==2)throw new Error(`Invalid signature integer tag: ${f(n)}`);const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:ce(r),left:n.subarray(e+2)}}function pe(n){if(n.length<2||n[0]!=48)throw new Error(`Invalid signature tag: ${f(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=be(n.subarray(2)),{data:l,left:m}=be(r);if(m.length)throw new Error(`Invalid signature: left bytes after parsing: ${f(m)}`);return{r:e,s:l}}class ae{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromCompact(e){const r=e instanceof Uint8Array,l="Signature.fromCompact";if(typeof e!="string"&&!r)throw new TypeError(`${l}: Expected string or Uint8Array`);const m=r?f(e):e;if(m.length!==128)throw new Error(`${l}: Expected 64-byte hex`);return new ae(ne(m.slice(0,64)),ne(m.slice(64,128)))}static fromDER(e){const r=e instanceof Uint8Array;if(typeof e!="string"&&!r)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:l,s:m}=pe(r?e:ie(e));return new ae(l,m)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:r}=this;if(!X(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!X(r))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=d.n>>v;return this.s>e}normalizeS(){return this.hasHighS()?new ae(this.r,O(-this.s,d.n)):this}toDERRawBytes(){return ie(this.toDERHex())}toDERHex(){const e=Q(G(this.s)),r=Q(G(this.r)),l=e.length/2,m=r.length/2,N=G(l),j=G(m);return`30${G(m+l+4)}02${j}${r}02${N}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return ie(this.toCompactHex())}toCompactHex(){return z(this.r)+z(this.s)}}o.Signature=ae;function x(...n){if(!n.every(l=>l instanceof Uint8Array))throw new Error("Uint8Array list expected");if(n.length===1)return n[0];const e=n.reduce((l,m)=>l+m.length,0),r=new Uint8Array(e);for(let l=0,m=0;l<n.length;l++){const N=n[l];r.set(N,m),m+=N.length}return r}const b=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function f(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<n.length;r++)e+=b[n[r]];return e}const I=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function z(n){if(typeof n!="bigint")throw new Error("Expected bigint");if(!(c<=n&&n<I))throw new Error("Expected number 0 <= n < 2^256");return n.toString(16).padStart(64,"0")}function M(n){const e=ie(z(n));if(e.length!==32)throw new Error("Error: expected 32 bytes");return e}function G(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function ne(n){if(typeof n!="string")throw new TypeError("hexToNumber: expected string, got "+typeof n);return BigInt(`0x${n}`)}function ie(n){if(typeof n!="string")throw new TypeError("hexToBytes: expected string, got "+typeof n);if(n.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+n.length);const e=new Uint8Array(n.length/2);for(let r=0;r<e.length;r++){const l=r*2,m=n.slice(l,l+2),N=Number.parseInt(m,16);if(Number.isNaN(N)||N<0)throw new Error("Invalid byte sequence");e[r]=N}return e}function ce(n){return ne(f(n))}function W(n){return n instanceof Uint8Array?Uint8Array.from(n):ie(n)}function ue(n){if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)return BigInt(n);if(typeof n=="bigint"&&X(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function O(n,e=d.P){const r=n%e;return r>=c?r:e+r}function ye(n,e){const{P:r}=d;let l=n;for(;e-- >c;)l*=l,l%=r;return l}function ke(n){const{P:e}=d,r=BigInt(6),l=BigInt(11),m=BigInt(22),N=BigInt(23),j=BigInt(44),$=BigInt(88),J=n*n*n%e,q=J*J*n%e,_=ye(q,y)*q%e,te=ye(_,y)*q%e,re=ye(te,B)*J%e,de=ye(re,l)*re%e,he=ye(de,m)*de%e,xe=ye(he,j)*he%e,Se=ye(xe,$)*xe%e,Le=ye(Se,j)*he%e,De=ye(Le,y)*q%e,$e=ye(De,N)*de%e,Ve=ye($e,r)*J%e,Fe=ye(Ve,B);if(Fe*Fe%e!==n)throw new Error("Cannot find square root");return Fe}function Ee(n,e=d.P){if(n===c||e<=c)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let r=O(n,e),l=e,m=c,N=v,j=v,$=c;for(;r!==c;){const q=l/r,_=l%r,te=m-j*q,re=N-$*q;l=r,r=_,m=j,N=$,j=te,$=re}if(l!==v)throw new Error("invert: does not exist");return O(m,e)}function Pe(n,e=d.P){const r=new Array(n.length),l=n.reduce((N,j,$)=>j===c?N:(r[$]=N,O(N*j,e)),v),m=Ee(l,e);return n.reduceRight((N,j,$)=>j===c?N:(r[$]=O(N*r[$],e),O(N*j,e)),m),r}function Me(n){const e=n.length*8-g*8,r=ce(n);return e>0?r>>BigInt(e):r}function He(n,e=!1){const r=Me(n);if(e)return r;const{n:l}=d;return r>=l?r-l:r}let Ne,h;class D{constructor(e,r){if(this.hashLen=e,this.qByteLen=r,typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof r!="number"||r<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(e).fill(1),this.k=new Uint8Array(e).fill(0),this.counter=0}hmac(...e){return o.utils.hmacSha256(this.k,...e)}hmacSync(...e){return h(this.k,...e)}checkSync(){if(typeof h!="function")throw new S("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),e.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),e.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=await this.hmac(this.v);const l=this.v.slice();r.push(l),e+=this.v.length}return x(...r)}generateSync(){this.checkSync(),this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const l=this.v.slice();r.push(l),e+=this.v.length}return x(...r)}}function X(n){return c<n&&n<d.n}function le(n){return c<n&&n<d.P}function ge(n,e,r,l=!0){const{n:m}=d,N=He(n,!0);if(!X(N))return;const j=Ee(N,m),$=Z.BASE.multiply(N),J=O($.x,m);if(J===c)return;const q=O(j*O(e+r*J,m),m);if(q===c)return;let _=new ae(J,q),te=($.x===_.r?0:2)|Number($.y&v);return l&&_.hasHighS()&&(_=_.normalizeS(),te^=1),{sig:_,recovery:te}}function me(n){let e;if(typeof n=="bigint")e=n;else if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)e=BigInt(n);else if(typeof n=="string"){if(n.length!==2*g)throw new Error("Expected 32 bytes of private key");e=ne(n)}else if(n instanceof Uint8Array){if(n.length!==g)throw new Error("Expected 32 bytes of private key");e=ce(n)}else throw new TypeError("Expected valid private key");if(!X(e))throw new Error("Expected private key: 0 < key < n");return e}function Be(n){return n instanceof Z?(n.assertValidity(),n):Z.fromHex(n)}function Ke(n){if(n instanceof ae)return n.assertValidity(),n;try{return ae.fromDER(n)}catch{return ae.fromCompact(n)}}function Ce(n,e=!1){return Z.fromPrivateKey(n).toRawBytes(e)}o.getPublicKey=Ce;function ct(n,e,r,l=!1){return Z.fromSignature(n,e,r).toRawBytes(l)}o.recoverPublicKey=ct;function Qe(n){const e=n instanceof Uint8Array,r=typeof n=="string",l=(e||r)&&n.length;return e?l===F||l===V:r?l===F*2||l===V*2:n instanceof Z}function ft(n,e,r=!1){if(Qe(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!Qe(e))throw new TypeError("getSharedSecret: second arg must be public key");const l=Be(e);return l.assertValidity(),l.multiply(me(n)).toRawBytes(r)}o.getSharedSecret=ft;function Je(n){const e=n.length>E?n.slice(0,E):n;return ce(e)}function ut(n){const e=Je(n),r=O(e,d.n);return _e(r<c?e:r)}function _e(n){return M(n)}function et(n,e,r){if(n==null)throw new Error(`sign: expected valid message hash, not "${n}"`);const l=W(n),m=me(e),N=[_e(m),ut(l)];if(r!=null){r===!0&&(r=o.utils.randomBytes(E));const J=W(r);if(J.length!==E)throw new Error(`sign: Expected ${E} bytes of extra data`);N.push(J)}const j=x(...N),$=Je(l);return{seed:j,m:$,d:m}}function tt(n,e){const{sig:r,recovery:l}=n,{der:m,recovered:N}=Object.assign({canonical:!0,der:!0},e),j=m?r.toDERRawBytes():r.toCompactRawBytes();return N?[j,l]:j}async function lt(n,e,r={}){const{seed:l,m,d:N}=et(n,e,r.extraEntropy),j=new D(T,g);await j.reseed(l);let $;for(;!($=ge(await j.generate(),m,N,r.canonical));)await j.reseed();return tt($,r)}o.sign=lt;function Ge(n,e,r={}){const{seed:l,m,d:N}=et(n,e,r.extraEntropy),j=new D(T,g);j.reseedSync(l);let $;for(;!($=ge(j.generateSync(),m,N,r.canonical));)j.reseedSync();return tt($,r)}o.signSync=Ge;const bt={strict:!0};function yt(n,e,r,l=bt){let m;try{m=Ke(n),e=W(e)}catch{return!1}const{r:N,s:j}=m;if(l.strict&&m.hasHighS())return!1;const $=He(e);let J;try{J=Be(r)}catch{return!1}const{n:q}=d,_=Ee(j,q),te=O($*_,q),re=O(N*_,q),de=Z.BASE.multiplyAndAddUnsafe(J,te,re);return de?O(de.x,q)===N:!1}o.verify=yt;function We(n){return O(ce(n),d.n)}class ze{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromHex(e){const r=W(e);if(r.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${r.length}`);const l=ce(r.subarray(0,32)),m=ce(r.subarray(32,64));return new ze(l,m)}assertValidity(){const{r:e,s:r}=this;if(!le(e)||!X(r))throw new Error("Invalid signature")}toHex(){return z(this.r)+z(this.s)}toRawBytes(){return ie(this.toHex())}}function ht(n){return Z.fromPrivateKey(n).toRawX()}class rt{constructor(e,r,l=o.utils.randomBytes()){if(e==null)throw new TypeError(`sign: Expected valid message, not "${e}"`);this.m=W(e);const{x:m,scalar:N}=this.getScalar(me(r));if(this.px=m,this.d=N,this.rand=W(l),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(e){const r=Z.fromPrivateKey(e),l=r.hasEvenY()?e:d.n-e;return{point:r,scalar:l,x:r.toRawX()}}initNonce(e,r){return M(e^ce(r))}finalizeNonce(e){const r=O(ce(e),d.n);if(r===c)throw new Error("sign: Creation of signature failed. k is zero");const{point:l,x:m,scalar:N}=this.getScalar(r);return{R:l,rx:m,k:N}}finalizeSig(e,r,l,m){return new ze(e.x,O(r+l*m,d.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:e,d:r,px:l,rand:m}=this,N=o.utils.taggedHash,j=this.initNonce(r,await N(Re.aux,m)),{R:$,rx:J,k:q}=this.finalizeNonce(await N(Re.nonce,j,l,e)),_=We(await N(Re.challenge,J,l,e)),te=this.finalizeSig($,q,_,r);return await ot(te,e,l)||this.error(),te}calcSync(){const{m:e,d:r,px:l,rand:m}=this,N=o.utils.taggedHashSync,j=this.initNonce(r,N(Re.aux,m)),{R:$,rx:J,k:q}=this.finalizeNonce(N(Re.nonce,j,l,e)),_=We(N(Re.challenge,J,l,e)),te=this.finalizeSig($,q,_,r);return it(te,e,l)||this.error(),te}}async function dt(n,e,r){return new rt(n,e,r).calc()}function je(n,e,r){return new rt(n,e,r).calcSync()}function Oe(n,e,r){const l=n instanceof ze,m=l?n:ze.fromHex(n);return l&&m.assertValidity(),{...m,m:W(e),P:Be(r)}}function nt(n,e,r,l){const m=Z.BASE.multiplyAndAddUnsafe(e,me(r),O(-l,d.n));return!(!m||!m.hasEvenY()||m.x!==n)}async function ot(n,e,r){try{const{r:l,s:m,m:N,P:j}=Oe(n,e,r),$=We(await o.utils.taggedHash(Re.challenge,M(l),j.toRawX(),N));return nt(l,j,m,$)}catch{return!1}}function it(n,e,r){try{const{r:l,s:m,m:N,P:j}=Oe(n,e,r),$=We(o.utils.taggedHashSync(Re.challenge,M(l),j.toRawX(),N));return nt(l,j,m,$)}catch(l){if(l instanceof S)throw l;return!1}}o.schnorr={Signature:ze,getPublicKey:ht,sign:dt,verify:ot,signSync:je,verifySync:it},Z.BASE._setWindowSize(8);const ve={node:C,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Re={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Ze={};o.utils={bytesToHex:f,hexToBytes:ie,concatBytes:x,mod:O,invert:Ee,isValidPrivateKey(n){try{return me(n),!0}catch{return!1}},_bigintTo32Bytes:M,_normalizePrivateKey:me,hashToPrivateKey:n=>{n=W(n);const e=g+8;if(n.length<e||n.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const r=O(ce(n),d.n-v)+v;return M(r)},randomBytes:(n=32)=>{if(ve.web)return ve.web.getRandomValues(new Uint8Array(n));if(ve.node){const{randomBytes:e}=ve.node;return Uint8Array.from(e(n))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>o.utils.hashToPrivateKey(o.utils.randomBytes(g+8)),precompute(n=8,e=Z.BASE){const r=e===Z.BASE?e:new Z(e.x,e.y);return r._setWindowSize(n),r.multiply(y),r},sha256:async(...n)=>{if(ve.web){const e=await ve.web.subtle.digest("SHA-256",x(...n));return new Uint8Array(e)}else if(ve.node){const{createHash:e}=ve.node,r=e("sha256");return n.forEach(l=>r.update(l)),Uint8Array.from(r.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(n,...e)=>{if(ve.web){const r=await ve.web.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),l=x(...e),m=await ve.web.subtle.sign("HMAC",r,l);return new Uint8Array(m)}else if(ve.node){const{createHmac:r}=ve.node,l=r("sha256",n);return e.forEach(m=>l.update(m)),Uint8Array.from(l.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(n,...e)=>{let r=Ze[n];if(r===void 0){const l=await o.utils.sha256(Uint8Array.from(n,m=>m.charCodeAt(0)));r=x(l,l),Ze[n]=r}return o.utils.sha256(r,...e)},taggedHashSync:(n,...e)=>{if(typeof Ne!="function")throw new S("sha256Sync is undefined, you need to set it");let r=Ze[n];if(r===void 0){const l=Ne(Uint8Array.from(n,m=>m.charCodeAt(0)));r=x(l,l),Ze[n]=r}return Ne(r,...e)},_JacobianPoint:k},Object.defineProperties(o.utils,{sha256Sync:{configurable:!1,get(){return Ne},set(n){Ne||(Ne=n)}},hmacSha256Sync:{configurable:!1,get(){return h},set(n){h||(h=n)}}})},63203:function(oe,o){"use strict";/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(o,"__esModule",{value:!0}),o.bytes=o.stringToBytes=o.str=o.bytesToString=o.hex=o.utf8=o.bech32m=o.bech32=o.base58check=o.createBase58check=o.base58xmr=o.base58xrp=o.base58flickr=o.base58=o.base64urlnopad=o.base64url=o.base64nopad=o.base64=o.base32crockford=o.base32hexnopad=o.base32hex=o.base32nopad=o.base32=o.base16=o.utils=o.assertNumber=void 0;function R(x){if(!Number.isSafeInteger(x))throw new Error(`Wrong integer: ${x}`)}o.assertNumber=R;function C(x){return x instanceof Uint8Array||x!=null&&typeof x=="object"&&x.constructor.name==="Uint8Array"}function c(...x){const b=M=>M,f=(M,G)=>ne=>M(G(ne)),I=x.map(M=>M.encode).reduceRight(f,b),z=x.map(M=>M.decode).reduce(f,b);return{encode:I,decode:z}}function v(x){return{encode:b=>{if(!Array.isArray(b)||b.length&&typeof b[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return b.map(f=>{if(R(f),f<0||f>=x.length)throw new Error(`Digit index outside alphabet: ${f} (alphabet: ${x.length})`);return x[f]})},decode:b=>{if(!Array.isArray(b)||b.length&&typeof b[0]!="string")throw new Error("alphabet.decode input should be array of strings");return b.map(f=>{if(typeof f!="string")throw new Error(`alphabet.decode: not string element=${f}`);const I=x.indexOf(f);if(I===-1)throw new Error(`Unknown letter: "${f}". Allowed: ${x}`);return I})}}}function B(x=""){if(typeof x!="string")throw new Error("join separator should be string");return{encode:b=>{if(!Array.isArray(b)||b.length&&typeof b[0]!="string")throw new Error("join.encode input should be array of strings");for(let f of b)if(typeof f!="string")throw new Error(`join.encode: non-string input=${f}`);return b.join(x)},decode:b=>{if(typeof b!="string")throw new Error("join.decode input should be string");return b.split(x)}}}function y(x,b="="){if(R(x),typeof b!="string")throw new Error("padding chr should be string");return{encode(f){if(!Array.isArray(f)||f.length&&typeof f[0]!="string")throw new Error("padding.encode input should be array of strings");for(let I of f)if(typeof I!="string")throw new Error(`padding.encode: non-string input=${I}`);for(;f.length*x%8;)f.push(b);return f},decode(f){if(!Array.isArray(f)||f.length&&typeof f[0]!="string")throw new Error("padding.encode input should be array of strings");for(let z of f)if(typeof z!="string")throw new Error(`padding.decode: non-string input=${z}`);let I=f.length;if(I*x%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;I>0&&f[I-1]===b;I--)if(!((I-1)*x%8))throw new Error("Invalid padding: string has too much padding");return f.slice(0,I)}}}function a(x){if(typeof x!="function")throw new Error("normalize fn should be function");return{encode:b=>b,decode:b=>x(b)}}function d(x,b,f){if(b<2)throw new Error(`convertRadix: wrong from=${b}, base cannot be less than 2`);if(f<2)throw new Error(`convertRadix: wrong to=${f}, base cannot be less than 2`);if(!Array.isArray(x))throw new Error("convertRadix: data should be array");if(!x.length)return[];let I=0;const z=[],M=Array.from(x);for(M.forEach(G=>{if(R(G),G<0||G>=b)throw new Error(`Wrong integer: ${G}`)});;){let G=0,ne=!0;for(let ie=I;ie<M.length;ie++){const ce=M[ie],W=b*G+ce;if(!Number.isSafeInteger(W)||b*G/b!==G||W-ce!==b*G)throw new Error("convertRadix: carry overflow");G=W%f;const ue=Math.floor(W/f);if(M[ie]=ue,!Number.isSafeInteger(ue)||ue*f+G!==W)throw new Error("convertRadix: carry overflow");if(ne)ue?ne=!1:I=ie;else continue}if(z.push(G),ne)break}for(let G=0;G<x.length-1&&x[G]===0;G++)z.push(0);return z.reverse()}const w=(x,b)=>b?w(b,x%b):x,i=(x,b)=>x+(b-w(x,b));function E(x,b,f,I){if(!Array.isArray(x))throw new Error("convertRadix2: data should be array");if(b<=0||b>32)throw new Error(`convertRadix2: wrong from=${b}`);if(f<=0||f>32)throw new Error(`convertRadix2: wrong to=${f}`);if(i(b,f)>32)throw new Error(`convertRadix2: carry overflow from=${b} to=${f} carryBits=${i(b,f)}`);let z=0,M=0;const G=2**f-1,ne=[];for(const ie of x){if(R(ie),ie>=2**b)throw new Error(`convertRadix2: invalid data word=${ie} from=${b}`);if(z=z<<b|ie,M+b>32)throw new Error(`convertRadix2: carry overflow pos=${M} from=${b}`);for(M+=b;M>=f;M-=f)ne.push((z>>M-f&G)>>>0);z&=2**M-1}if(z=z<<f-M&G,!I&&M>=b)throw new Error("Excess padding");if(!I&&z)throw new Error(`Non-zero padding: ${z}`);return I&&M>0&&ne.push(z>>>0),ne}function g(x){return R(x),{encode:b=>{if(!C(b))throw new Error("radix.encode input should be Uint8Array");return d(Array.from(b),2**8,x)},decode:b=>{if(!Array.isArray(b)||b.length&&typeof b[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(d(b,x,2**8))}}}function T(x,b=!1){if(R(x),x<=0||x>32)throw new Error("radix2: bits should be in (0..32]");if(i(8,x)>32||i(x,8)>32)throw new Error("radix2: carry overflow");return{encode:f=>{if(!C(f))throw new Error("radix2.encode input should be Uint8Array");return E(Array.from(f),8,x,!b)},decode:f=>{if(!Array.isArray(f)||f.length&&typeof f[0]!="number")throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(E(f,x,8,b))}}}function F(x){if(typeof x!="function")throw new Error("unsafeWrapper fn should be function");return function(...b){try{return x.apply(null,b)}catch{}}}function V(x,b){if(R(x),typeof b!="function")throw new Error("checksum fn should be function");return{encode(f){if(!C(f))throw new Error("checksum.encode: input should be Uint8Array");const I=b(f).slice(0,x),z=new Uint8Array(f.length+x);return z.set(f),z.set(I,f.length),z},decode(f){if(!C(f))throw new Error("checksum.decode: input should be Uint8Array");const I=f.slice(0,-x),z=b(I).slice(0,x),M=f.slice(-x);for(let G=0;G<x;G++)if(z[G]!==M[G])throw new Error("Invalid checksum");return I}}}o.utils={alphabet:v,chain:c,checksum:V,convertRadix:d,convertRadix2:E,radix:g,radix2:T,join:B,padding:y},o.base16=c(T(4),v("0123456789ABCDEF"),B("")),o.base32=c(T(5),v("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),y(5),B("")),o.base32nopad=c(T(5),v("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),B("")),o.base32hex=c(T(5),v("0123456789ABCDEFGHIJKLMNOPQRSTUV"),y(5),B("")),o.base32hexnopad=c(T(5),v("0123456789ABCDEFGHIJKLMNOPQRSTUV"),B("")),o.base32crockford=c(T(5),v("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),B(""),a(x=>x.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),o.base64=c(T(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),y(6),B("")),o.base64nopad=c(T(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),B("")),o.base64url=c(T(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),y(6),B("")),o.base64urlnopad=c(T(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),B(""));const K=x=>c(g(58),v(x),B(""));o.base58=K("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),o.base58flickr=K("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),o.base58xrp=K("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const H=[0,2,3,5,6,7,9,10,11];o.base58xmr={encode(x){let b="";for(let f=0;f<x.length;f+=8){const I=x.subarray(f,f+8);b+=o.base58.encode(I).padStart(H[I.length],"1")}return b},decode(x){let b=[];for(let f=0;f<x.length;f+=11){const I=x.slice(f,f+11),z=H.indexOf(I.length),M=o.base58.decode(I);for(let G=0;G<M.length-z;G++)if(M[G]!==0)throw new Error("base58xmr: wrong padding");b=b.concat(Array.from(M.slice(M.length-z)))}return Uint8Array.from(b)}};const S=x=>c(V(4,b=>x(x(b))),o.base58);o.createBase58check=S,o.base58check=o.createBase58check;const A=c(v("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),B("")),k=[996825010,642813549,513874426,1027748829,705979059];function U(x){const b=x>>25;let f=(x&33554431)<<5;for(let I=0;I<k.length;I++)(b>>I&1)===1&&(f^=k[I]);return f}function Y(x,b,f=1){const I=x.length;let z=1;for(let M=0;M<I;M++){const G=x.charCodeAt(M);if(G<33||G>126)throw new Error(`Invalid prefix (${x})`);z=U(z)^G>>5}z=U(z);for(let M=0;M<I;M++)z=U(z)^x.charCodeAt(M)&31;for(let M of b)z=U(z)^M;for(let M=0;M<6;M++)z=U(z);return z^=f,A.encode(E([z%2**30],30,5,!1))}function Z(x){const b=x==="bech32"?1:734539939,f=T(5),I=f.decode,z=f.encode,M=F(I);function G(W,ue,O=90){if(typeof W!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof W}`);if(!Array.isArray(ue)||ue.length&&typeof ue[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof ue}`);if(W.length===0)throw new TypeError(`Invalid prefix length ${W.length}`);const ye=W.length+7+ue.length;if(O!==!1&&ye>O)throw new TypeError(`Length ${ye} exceeds limit ${O}`);const ke=W.toLowerCase(),Ee=Y(ke,ue,b);return`${ke}1${A.encode(ue)}${Ee}`}function ne(W,ue=90){if(typeof W!="string")throw new Error(`bech32.decode input should be string, not ${typeof W}`);if(W.length<8||ue!==!1&&W.length>ue)throw new TypeError(`Wrong string length: ${W.length} (${W}). Expected (8..${ue})`);const O=W.toLowerCase();if(W!==O&&W!==W.toUpperCase())throw new Error("String must be lowercase or uppercase");const ye=O.lastIndexOf("1");if(ye===0||ye===-1)throw new Error('Letter "1" must be present between prefix and data only');const ke=O.slice(0,ye),Ee=O.slice(ye+1);if(Ee.length<6)throw new Error("Data must be at least 6 characters long");const Pe=A.decode(Ee).slice(0,-6),Me=Y(ke,Pe,b);if(!Ee.endsWith(Me))throw new Error(`Invalid checksum in ${W}: expected "${Me}"`);return{prefix:ke,words:Pe}}const ie=F(ne);function ce(W){const{prefix:ue,words:O}=ne(W,!1);return{prefix:ue,words:O,bytes:I(O)}}return{encode:G,decode:ne,decodeToBytes:ce,decodeUnsafe:ie,fromWords:I,fromWordsUnsafe:M,toWords:z}}o.bech32=Z("bech32"),o.bech32m=Z("bech32m"),o.utf8={encode:x=>new TextDecoder().decode(x),decode:x=>new TextEncoder().encode(x)},o.hex=c(T(4),v("0123456789abcdef"),B(""),a(x=>{if(typeof x!="string"||x.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof x} with length ${x.length}`);return x.toLowerCase()}));const Q={utf8:o.utf8,hex:o.hex,base16:o.base16,base32:o.base32,base64:o.base64,base64url:o.base64url,base58:o.base58,base58xmr:o.base58xmr},be="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr",pe=(x,b)=>{if(typeof x!="string"||!Q.hasOwnProperty(x))throw new TypeError(be);if(!C(b))throw new TypeError("bytesToString() expects Uint8Array");return Q[x].encode(b)};o.bytesToString=pe,o.str=o.bytesToString;const ae=(x,b)=>{if(!Q.hasOwnProperty(x))throw new TypeError(be);if(typeof b!="string")throw new TypeError("stringToBytes() expects string");return Q[x].decode(b)};o.stringToBytes=ae,o.bytes=o.stringToBytes},11206:function(oe,o,R){"use strict";var C=R(48287).Buffer;Object.defineProperty(o,"__esModule",{value:!0}),o.BIP32Factory=void 0;const c=R(25311),v=R(87569),B=R(63203),y=R(22623),a=R(8676),d=R(57513),w=(0,B.base58check)(y.sha256),i={encode:g=>w.encode(Uint8Array.from(g)),decode:g=>C.from(w.decode(g))};function E(g){(0,v.testEcc)(g);const T=a.BufferN(32),F=a.compile({wif:a.UInt8,bip32:{public:a.UInt32,private:a.UInt32}}),V={messagePrefix:`Bitcoin Signed Message:
2
+ `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},K=2147483648,H=Math.pow(2,31)-1;function S(b){return a.String(b)&&b.match(/^(m\/)?(\d+'?\/)*\d+'?$/)!==null}function A(b){return a.UInt32(b)&&b<=H}function k(b){return b.length===32?b:b.slice(1,33)}class U{constructor(f,I){this.__D=f,this.__Q=I,this.lowR=!1}get publicKey(){return this.__Q===void 0&&(this.__Q=C.from(g.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(f,I){if(!this.privateKey)throw new Error("Missing private key");if(I===void 0&&(I=this.lowR),I===!1)return C.from(g.sign(f,this.privateKey));{let z=C.from(g.sign(f,this.privateKey));const M=C.alloc(32,0);let G=0;for(;z[0]>127;)G++,M.writeUIntLE(G,0,6),z=C.from(g.sign(f,this.privateKey,M));return z}}signSchnorr(f){if(!this.privateKey)throw new Error("Missing private key");if(!g.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return C.from(g.signSchnorr(f,this.privateKey))}verify(f,I){return g.verify(f,this.publicKey,I)}verifySchnorr(f,I){if(!g.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return g.verifySchnorr(f,this.publicKey.subarray(1,33),I)}}class Y extends U{constructor(f,I,z,M,G=0,ne=0,ie=0){super(f,I),this.chainCode=z,this.network=M,this.__DEPTH=G,this.__INDEX=ne,this.__PARENT_FINGERPRINT=ie,a(F,M)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return c.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return this.__D===void 0}neutered(){return ae(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const f=this.network,I=this.isNeutered()?f.bip32.public:f.bip32.private,z=C.allocUnsafe(78);return z.writeUInt32BE(I,0),z.writeUInt8(this.depth,4),z.writeUInt32BE(this.parentFingerprint,5),z.writeUInt32BE(this.index,9),this.chainCode.copy(z,13),this.isNeutered()?this.publicKey.copy(z,45):(z.writeUInt8(0,45),this.privateKey.copy(z,46)),i.encode(z)}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return d.encode(this.network.wif,this.privateKey,!0)}derive(f){a(a.UInt32,f);const I=f>=K,z=C.allocUnsafe(37);if(I){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");z[0]=0,this.privateKey.copy(z,1),z.writeUInt32BE(f,33)}else this.publicKey.copy(z,0),z.writeUInt32BE(f,33);const M=c.hmacSHA512(this.chainCode,z),G=M.slice(0,32),ne=M.slice(32);if(!g.isPrivate(G))return this.derive(f+1);let ie;if(this.isNeutered()){const ce=C.from(g.pointAddScalar(this.publicKey,G,!0));if(ce===null)return this.derive(f+1);ie=ae(ce,ne,this.network,this.depth+1,f,this.fingerprint.readUInt32BE(0))}else{const ce=C.from(g.privateAdd(this.privateKey,G));if(ce==null)return this.derive(f+1);ie=be(ce,ne,this.network,this.depth+1,f,this.fingerprint.readUInt32BE(0))}return ie}deriveHardened(f){return a(A,f),this.derive(f+K)}derivePath(f){a(S,f);let I=f.split("/");if(I[0]==="m"){if(this.parentFingerprint)throw new TypeError("Expected master, got child");I=I.slice(1)}return I.reduce((z,M)=>{let G;return M.slice(-1)==="'"?(G=parseInt(M.slice(0,-1),10),z.deriveHardened(G)):(G=parseInt(M,10),z.derive(G))},this)}tweak(f){return this.privateKey?this.tweakFromPrivateKey(f):this.tweakFromPublicKey(f)}tweakFromPublicKey(f){const I=k(this.publicKey);if(!g.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const z=g.xOnlyPointAddTweak(I,f);if(!z||z.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const M=C.from([z.parity===0?2:3]),G=C.concat([M,z.xOnlyPubkey]);return new U(void 0,G)}tweakFromPrivateKey(f){const I=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1,z=(()=>{if(I){if(g.privateNegate)return g.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}else return this.privateKey})(),M=g.privateAdd(z,f);if(!M)throw new Error("Invalid tweaked private key!");return new U(C.from(M),void 0)}}function Z(b,f){const I=i.decode(b);if(I.length!==78)throw new TypeError("Invalid buffer length");f=f||V;const z=I.readUInt32BE(0);if(z!==f.bip32.private&&z!==f.bip32.public)throw new TypeError("Invalid network version");const M=I[4],G=I.readUInt32BE(5);if(M===0&&G!==0)throw new TypeError("Invalid parent fingerprint");const ne=I.readUInt32BE(9);if(M===0&&ne!==0)throw new TypeError("Invalid index");const ie=I.slice(13,45);let ce;if(z===f.bip32.private){if(I.readUInt8(45)!==0)throw new TypeError("Invalid private key");const W=I.slice(46,78);ce=be(W,ie,f,M,ne,G)}else{const W=I.slice(45,78);ce=ae(W,ie,f,M,ne,G)}return ce}function Q(b,f,I){return be(b,f,I)}function be(b,f,I,z,M,G){if(a({privateKey:T,chainCode:T},{privateKey:b,chainCode:f}),I=I||V,!g.isPrivate(b))throw new TypeError("Private key not in range [1, n)");return new Y(b,void 0,f,I,z,M,G)}function pe(b,f,I){return ae(b,f,I)}function ae(b,f,I,z,M,G){if(a({publicKey:a.BufferN(33),chainCode:T},{publicKey:b,chainCode:f}),I=I||V,!g.isPoint(b))throw new TypeError("Point is not on the curve");return new Y(void 0,b,f,I,z,M,G)}function x(b,f){if(a(a.Buffer,b),b.length<16)throw new TypeError("Seed should be at least 128 bits");if(b.length>64)throw new TypeError("Seed should be at most 512 bits");f=f||V;const I=c.hmacSHA512(C.from("Bitcoin seed","utf8"),b),z=I.slice(0,32),M=I.slice(32);return Q(z,M,f)}return{fromSeed:x,fromBase58:Z,fromPublicKey:pe,fromPrivateKey:Q}}o.BIP32Factory=E},25311:function(oe,o,R){"use strict";var C=R(48287).Buffer;Object.defineProperty(o,"__esModule",{value:!0}),o.hmacSHA512=o.hash160=void 0;const c=R(39615),v=R(93238),B=R(22623),y=R(30102);function a(w){const i=(0,B.sha256)(Uint8Array.from(w));return C.from((0,v.ripemd160)(i))}o.hash160=a;function d(w,i){return C.from((0,c.hmac)(y.sha512,w,i))}o.hmacSHA512=d},83328:function(oe,o,R){"use strict";var C;C={value:!0},o.Pr=C=void 0;var c=R(11206);C={enumerable:!0,get:function(){return c.BIP32Factory}},Object.defineProperty(o,"Pr",{enumerable:!0,get:function(){return c.BIP32Factory}})},87569:function(oe,o,R){"use strict";var C=R(48287).Buffer;Object.defineProperty(o,"__esModule",{value:!0}),o.testEcc=void 0;const c=y=>C.from(y,"hex");function v(y){if(B(y.isPoint(c("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),B(!y.isPoint(c("030000000000000000000000000000000000000000000000000000000000000005"))),B(y.isPrivate(c("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),B(y.isPrivate(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),B(!y.isPrivate(c("0000000000000000000000000000000000000000000000000000000000000000"))),B(!y.isPrivate(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),B(!y.isPrivate(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),B(C.from(y.pointFromScalar(c("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(c("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),y.xOnlyPointAddTweak){B(y.xOnlyPointAddTweak(c("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let a=y.xOnlyPointAddTweak(c("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),c("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));B(C.from(a.xOnlyPubkey).equals(c("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&a.parity===1),a=y.xOnlyPointAddTweak(c("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),c("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}B(C.from(y.pointAddScalar(c("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),c("0000000000000000000000000000000000000000000000000000000000000003"))).equals(c("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),B(C.from(y.privateAdd(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),c("0000000000000000000000000000000000000000000000000000000000000002"))).equals(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),y.privateNegate&&(B(C.from(y.privateNegate(c("0000000000000000000000000000000000000000000000000000000000000001"))).equals(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),B(C.from(y.privateNegate(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(c("0000000000000000000000000000000000000000000000000000000000000003"))),B(C.from(y.privateNegate(c("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(c("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),B(C.from(y.sign(c("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(c("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),B(y.verify(c("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),c("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),c("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),y.signSchnorr&&B(C.from(y.signSchnorr(c("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),c("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),c("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(c("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),y.verifySchnorr&&B(y.verifySchnorr(c("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),c("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),c("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}o.testEcc=v;function B(y){if(!y)throw new Error("ecc library invalid")}},17009:function(oe,o,R){oe.exports=R(27655)(R(59393))},59393:function(oe,o,R){const C=R(86729).ec,c=new C("secp256k1"),v=c.curve,B=v.n.constructor;function y(i,E){let g=new B(E);if(g.cmp(v.p)>=0)return null;g=g.toRed(v.red);let T=g.redSqr().redIMul(g).redIAdd(v.b).redSqrt();return i===3!==T.isOdd()&&(T=T.redNeg()),c.keyPair({pub:{x:g,y:T}})}function a(i,E,g){let T=new B(E),F=new B(g);if(T.cmp(v.p)>=0||F.cmp(v.p)>=0||(T=T.toRed(v.red),F=F.toRed(v.red),(i===6||i===7)&&F.isOdd()!==(i===7)))return null;const V=T.redSqr().redIMul(T);return F.redSqr().redISub(V.redIAdd(v.b)).isZero()?c.keyPair({pub:{x:T,y:F}}):null}function d(i){const E=i[0];switch(E){case 2:case 3:return i.length!==33?null:y(E,i.subarray(1,33));case 4:case 6:case 7:return i.length!==65?null:a(E,i.subarray(1,33),i.subarray(33,65));default:return null}}function w(i,E){const g=E.encode(null,i.length===33);for(let T=0;T<i.length;++T)i[T]=g[T]}oe.exports={contextRandomize(){return 0},privateKeyVerify(i){const E=new B(i);return E.cmp(v.n)<0&&!E.isZero()?0:1},privateKeyNegate(i){const E=new B(i),g=v.n.sub(E).umod(v.n).toArrayLike(Uint8Array,"be",32);return i.set(g),0},privateKeyTweakAdd(i,E){const g=new B(E);if(g.cmp(v.n)>=0||(g.iadd(new B(i)),g.cmp(v.n)>=0&&g.isub(v.n),g.isZero()))return 1;const T=g.toArrayLike(Uint8Array,"be",32);return i.set(T),0},privateKeyTweakMul(i,E){let g=new B(E);if(g.cmp(v.n)>=0||g.isZero())return 1;g.imul(new B(i)),g.cmp(v.n)>=0&&(g=g.umod(v.n));const T=g.toArrayLike(Uint8Array,"be",32);return i.set(T),0},publicKeyVerify(i){return d(i)===null?1:0},publicKeyCreate(i,E){const g=new B(E);if(g.cmp(v.n)>=0||g.isZero())return 1;const T=c.keyFromPrivate(E).getPublic();return w(i,T),0},publicKeyConvert(i,E){const g=d(E);if(g===null)return 1;const T=g.getPublic();return w(i,T),0},publicKeyNegate(i,E){const g=d(E);if(g===null)return 1;const T=g.getPublic();return T.y=T.y.redNeg(),w(i,T),0},publicKeyCombine(i,E){const g=new Array(E.length);for(let F=0;F<E.length;++F)if(g[F]=d(E[F]),g[F]===null)return 1;let T=g[0].getPublic();for(let F=1;F<g.length;++F)T=T.add(g[F].pub);return T.isInfinity()?2:(w(i,T),0)},publicKeyTweakAdd(i,E,g){const T=d(E);if(T===null)return 1;if(g=new B(g),g.cmp(v.n)>=0)return 2;const F=T.getPublic().add(v.g.mul(g));return F.isInfinity()?2:(w(i,F),0)},publicKeyTweakMul(i,E,g){const T=d(E);if(T===null)return 1;if(g=new B(g),g.cmp(v.n)>=0||g.isZero())return 2;const F=T.getPublic().mul(g);return w(i,F),0},signatureNormalize(i){const E=new B(i.subarray(0,32)),g=new B(i.subarray(32,64));return E.cmp(v.n)>=0||g.cmp(v.n)>=0?1:(g.cmp(c.nh)===1&&i.set(v.n.sub(g).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(i,E){const g=E.subarray(0,32),T=E.subarray(32,64);if(new B(g).cmp(v.n)>=0||new B(T).cmp(v.n)>=0)return 1;const{output:F}=i;let V=F.subarray(4,4+33);V[0]=0,V.set(g,1);let K=33,H=0;for(;K>1&&V[H]===0&&!(V[H+1]&128);--K,++H);if(V=V.subarray(H),V[0]&128||K>1&&V[0]===0&&!(V[1]&128))return 1;let S=F.subarray(6+33,6+33+33);S[0]=0,S.set(T,1);let A=33,k=0;for(;A>1&&S[k]===0&&!(S[k+1]&128);--A,++k);return S=S.subarray(k),S[0]&128||A>1&&S[0]===0&&!(S[1]&128)?1:(i.outputlen=6+K+A,F[0]=48,F[1]=i.outputlen-2,F[2]=2,F[3]=V.length,F.set(V,4),F[4+K]=2,F[5+K]=S.length,F.set(S,6+K),0)},signatureImport(i,E){if(E.length<8||E.length>72||E[0]!==48||E[1]!==E.length-2||E[2]!==2)return 1;const g=E[3];if(g===0||5+g>=E.length||E[4+g]!==2)return 1;const T=E[5+g];if(T===0||6+g+T!==E.length||E[4]&128||g>1&&E[4]===0&&!(E[5]&128)||E[g+6]&128||T>1&&E[g+6]===0&&!(E[g+7]&128))return 1;let F=E.subarray(4,4+g);if(F.length===33&&F[0]===0&&(F=F.subarray(1)),F.length>32)return 1;let V=E.subarray(6+g);if(V.length===33&&V[0]===0&&(V=V.slice(1)),V.length>32)throw new Error("S length is too long");let K=new B(F);K.cmp(v.n)>=0&&(K=new B(0));let H=new B(E.subarray(6+g));return H.cmp(v.n)>=0&&(H=new B(0)),i.set(K.toArrayLike(Uint8Array,"be",32),0),i.set(H.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(i,E,g,T,F){if(F){const H=F;F=S=>{const A=H(E,g,null,T,S);if(!(A instanceof Uint8Array&&A.length===32))throw new Error("This is the way");return new B(A)}}const V=new B(g);if(V.cmp(v.n)>=0||V.isZero())return 1;let K;try{K=c.sign(E,g,{canonical:!0,k:F,pers:T})}catch{return 1}return i.signature.set(K.r.toArrayLike(Uint8Array,"be",32),0),i.signature.set(K.s.toArrayLike(Uint8Array,"be",32),32),i.recid=K.recoveryParam,0},ecdsaVerify(i,E,g){const T={r:i.subarray(0,32),s:i.subarray(32,64)},F=new B(T.r),V=new B(T.s);if(F.cmp(v.n)>=0||V.cmp(v.n)>=0)return 1;if(V.cmp(c.nh)===1||F.isZero()||V.isZero())return 3;const K=d(g);if(K===null)return 2;const H=K.getPublic();return c.verify(E,T,H)?0:3},ecdsaRecover(i,E,g,T){const F={r:E.slice(0,32),s:E.slice(32,64)},V=new B(F.r),K=new B(F.s);if(V.cmp(v.n)>=0||K.cmp(v.n)>=0)return 1;if(V.isZero()||K.isZero())return 2;let H;try{H=c.recoverPubKey(T,F,g)}catch{return 2}return w(i,H),0},ecdh(i,E,g,T,F,V,K){const H=d(E);if(H===null)return 1;const S=new B(g);if(S.cmp(v.n)>=0||S.isZero())return 2;const A=H.getPublic().mul(S);if(F===void 0){const k=A.encode(null,!0),U=c.hash().update(k).digest();for(let Y=0;Y<32;++Y)i[Y]=U[Y]}else{V||(V=new Uint8Array(32));const k=A.getX().toArray("be",32);for(let Q=0;Q<32;++Q)V[Q]=k[Q];K||(K=new Uint8Array(32));const U=A.getY().toArray("be",32);for(let Q=0;Q<32;++Q)K[Q]=U[Q];const Y=F(V,K,T);if(!(Y instanceof Uint8Array&&Y.length===i.length))return 2;i.set(Y)}return 0}}},27655:function(oe){const o={IMPOSSIBLE_CASE:"Impossible case. Please create issue.",TWEAK_ADD:"The tweak was out of range or the resulted private key is invalid",TWEAK_MUL:"The tweak was out of range or equal to zero",CONTEXT_RANDOMIZE_UNKNOW:"Unknow error on context randomization",SECKEY_INVALID:"Private Key is invalid",PUBKEY_PARSE:"Public Key could not be parsed",PUBKEY_SERIALIZE:"Public Key serialization error",PUBKEY_COMBINE:"The sum of the public keys is not valid",SIG_PARSE:"Signature could not be parsed",SIGN:"The nonce generation function failed, or the private key was invalid",RECOVER:"Public key could not be recover",ECDH:"Scalar was invalid (zero or overflow)"};function R(y,a){if(!y)throw new Error(a)}function C(y,a,d){if(R(a instanceof Uint8Array,`Expected ${y} to be an Uint8Array`),d!==void 0)if(Array.isArray(d)){const w=d.join(", "),i=`Expected ${y} to be an Uint8Array with length [${w}]`;R(d.includes(a.length),i)}else{const w=`Expected ${y} to be an Uint8Array with length ${d}`;R(a.length===d,w)}}function c(y){R(B(y)==="Boolean","Expected compressed to be a Boolean")}function v(y=d=>new Uint8Array(d),a){return typeof y=="function"&&(y=y(a)),C("output",y,a),y}function B(y){return Object.prototype.toString.call(y).slice(8,-1)}oe.exports=y=>({contextRandomize(a){switch(R(a===null||a instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),a!==null&&C("seed",a,32),y.contextRandomize(a)){case 1:throw new Error(o.CONTEXT_RANDOMIZE_UNKNOW)}},privateKeyVerify(a){return C("private key",a,32),y.privateKeyVerify(a)===0},privateKeyNegate(a){switch(C("private key",a,32),y.privateKeyNegate(a)){case 0:return a;case 1:throw new Error(o.IMPOSSIBLE_CASE)}},privateKeyTweakAdd(a,d){switch(C("private key",a,32),C("tweak",d,32),y.privateKeyTweakAdd(a,d)){case 0:return a;case 1:throw new Error(o.TWEAK_ADD)}},privateKeyTweakMul(a,d){switch(C("private key",a,32),C("tweak",d,32),y.privateKeyTweakMul(a,d)){case 0:return a;case 1:throw new Error(o.TWEAK_MUL)}},publicKeyVerify(a){return C("public key",a,[33,65]),y.publicKeyVerify(a)===0},publicKeyCreate(a,d=!0,w){switch(C("private key",a,32),c(d),w=v(w,d?33:65),y.publicKeyCreate(w,a)){case 0:return w;case 1:throw new Error(o.SECKEY_INVALID);case 2:throw new Error(o.PUBKEY_SERIALIZE)}},publicKeyConvert(a,d=!0,w){switch(C("public key",a,[33,65]),c(d),w=v(w,d?33:65),y.publicKeyConvert(w,a)){case 0:return w;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.PUBKEY_SERIALIZE)}},publicKeyNegate(a,d=!0,w){switch(C("public key",a,[33,65]),c(d),w=v(w,d?33:65),y.publicKeyNegate(w,a)){case 0:return w;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.IMPOSSIBLE_CASE);case 3:throw new Error(o.PUBKEY_SERIALIZE)}},publicKeyCombine(a,d=!0,w){R(Array.isArray(a),"Expected public keys to be an Array"),R(a.length>0,"Expected public keys array will have more than zero items");for(const i of a)C("public key",i,[33,65]);switch(c(d),w=v(w,d?33:65),y.publicKeyCombine(w,a)){case 0:return w;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.PUBKEY_COMBINE);case 3:throw new Error(o.PUBKEY_SERIALIZE)}},publicKeyTweakAdd(a,d,w=!0,i){switch(C("public key",a,[33,65]),C("tweak",d,32),c(w),i=v(i,w?33:65),y.publicKeyTweakAdd(i,a,d)){case 0:return i;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.TWEAK_ADD)}},publicKeyTweakMul(a,d,w=!0,i){switch(C("public key",a,[33,65]),C("tweak",d,32),c(w),i=v(i,w?33:65),y.publicKeyTweakMul(i,a,d)){case 0:return i;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.TWEAK_MUL)}},signatureNormalize(a){switch(C("signature",a,64),y.signatureNormalize(a)){case 0:return a;case 1:throw new Error(o.SIG_PARSE)}},signatureExport(a,d){C("signature",a,64),d=v(d,72);const w={output:d,outputlen:72};switch(y.signatureExport(w,a)){case 0:return d.slice(0,w.outputlen);case 1:throw new Error(o.SIG_PARSE);case 2:throw new Error(o.IMPOSSIBLE_CASE)}},signatureImport(a,d){switch(C("signature",a),d=v(d,64),y.signatureImport(d,a)){case 0:return d;case 1:throw new Error(o.SIG_PARSE);case 2:throw new Error(o.IMPOSSIBLE_CASE)}},ecdsaSign(a,d,w={},i){C("message",a,32),C("private key",d,32),R(B(w)==="Object","Expected options to be an Object"),w.data!==void 0&&C("options.data",w.data),w.noncefn!==void 0&&R(B(w.noncefn)==="Function","Expected options.noncefn to be a Function"),i=v(i,64);const E={signature:i,recid:null};switch(y.ecdsaSign(E,a,d,w.data,w.noncefn)){case 0:return E;case 1:throw new Error(o.SIGN);case 2:throw new Error(o.IMPOSSIBLE_CASE)}},ecdsaVerify(a,d,w){switch(C("signature",a,64),C("message",d,32),C("public key",w,[33,65]),y.ecdsaVerify(a,d,w)){case 0:return!0;case 3:return!1;case 1:throw new Error(o.SIG_PARSE);case 2:throw new Error(o.PUBKEY_PARSE)}},ecdsaRecover(a,d,w,i=!0,E){switch(C("signature",a,64),R(B(d)==="Number"&&d>=0&&d<=3,"Expected recovery id to be a Number within interval [0, 3]"),C("message",w,32),c(i),E=v(E,i?33:65),y.ecdsaRecover(E,a,d,w)){case 0:return E;case 1:throw new Error(o.SIG_PARSE);case 2:throw new Error(o.RECOVER);case 3:throw new Error(o.IMPOSSIBLE_CASE)}},ecdh(a,d,w={},i){switch(C("public key",a,[33,65]),C("private key",d,32),R(B(w)==="Object","Expected options to be an Object"),w.data!==void 0&&C("options.data",w.data),w.hashfn!==void 0?(R(B(w.hashfn)==="Function","Expected options.hashfn to be a Function"),w.xbuf!==void 0&&C("options.xbuf",w.xbuf,32),w.ybuf!==void 0&&C("options.ybuf",w.ybuf,32),C("output",i)):i=v(i,32),y.ecdh(i,a,d,w.data,w.hashfn,w.xbuf,w.ybuf)){case 0:return i;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.ECDH)}}})},14034:function(oe){var o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",R="0123456789ABCDEFGHIJKLMNOPQRSTUV",C="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function c(v,B){var y=v.indexOf(B);if(y===-1)throw new Error("Invalid character found: "+B);return y}oe.exports=function(B,y){var a;switch(y){case"RFC3548":case"RFC4648":a=o,B=B.replace(/=+$/,"");break;case"RFC4648-HEX":a=R,B=B.replace(/=+$/,"");break;case"Crockford":a=C,B=B.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1");break;default:throw new Error("Unknown base32 variant: "+y)}for(var d=B.length,w=0,i=0,E=0,g=new Uint8Array(d*5/8|0),T=0;T<d;T++)i=i<<5|c(a,B[T]),w+=5,w>=8&&(g[E++]=i>>>w-8&255,w-=8);return g.buffer}},74156:function(oe,o,R){const C=R(20829);function c(A,k,U){const Y=A[k]+A[U];let Z=A[k+1]+A[U+1];Y>=4294967296&&Z++,A[k]=Y,A[k+1]=Z}function v(A,k,U,Y){let Z=A[k]+U;U<0&&(Z+=4294967296);let Q=A[k+1]+Y;Z>=4294967296&&Q++,A[k]=Z,A[k+1]=Q}function B(A,k){return A[k]^A[k+1]<<8^A[k+2]<<16^A[k+3]<<24}function y(A,k,U,Y,Z,Q){const be=E[Z],pe=E[Z+1],ae=E[Q],x=E[Q+1];c(i,A,k),v(i,A,be,pe);let b=i[Y]^i[A],f=i[Y+1]^i[A+1];i[Y]=f,i[Y+1]=b,c(i,U,Y),b=i[k]^i[U],f=i[k+1]^i[U+1],i[k]=b>>>24^f<<8,i[k+1]=f>>>24^b<<8,c(i,A,k),v(i,A,ae,x),b=i[Y]^i[A],f=i[Y+1]^i[A+1],i[Y]=b>>>16^f<<16,i[Y+1]=f>>>16^b<<16,c(i,U,Y),b=i[k]^i[U],f=i[k+1]^i[U+1],i[k]=f>>>31^b<<1,i[k+1]=b>>>31^f<<1}const a=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),d=[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],w=new Uint8Array(d.map(function(A){return A*2})),i=new Uint32Array(32),E=new Uint32Array(32);function g(A,k){let U=0;for(U=0;U<16;U++)i[U]=A.h[U],i[U+16]=a[U];for(i[24]=i[24]^A.t,i[25]=i[25]^A.t/4294967296,k&&(i[28]=~i[28],i[29]=~i[29]),U=0;U<32;U++)E[U]=B(A.b,4*U);for(U=0;U<12;U++)y(0,8,16,24,w[U*16+0],w[U*16+1]),y(2,10,18,26,w[U*16+2],w[U*16+3]),y(4,12,20,28,w[U*16+4],w[U*16+5]),y(6,14,22,30,w[U*16+6],w[U*16+7]),y(0,10,20,30,w[U*16+8],w[U*16+9]),y(2,12,22,24,w[U*16+10],w[U*16+11]),y(4,14,16,26,w[U*16+12],w[U*16+13]),y(6,8,18,28,w[U*16+14],w[U*16+15]);for(U=0;U<16;U++)A.h[U]=A.h[U]^i[U]^i[U+16]}const T=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function F(A,k,U,Y){if(A===0||A>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(k&&k.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(U&&U.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(Y&&Y.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const Z={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:A};T.fill(0),T[0]=A,k&&(T[1]=k.length),T[2]=1,T[3]=1,U&&T.set(U,32),Y&&T.set(Y,48);for(let Q=0;Q<16;Q++)Z.h[Q]=a[Q]^B(T,Q*4);return k&&(V(Z,k),Z.c=128),Z}function V(A,k){for(let U=0;U<k.length;U++)A.c===128&&(A.t+=A.c,g(A,!1),A.c=0),A.b[A.c++]=k[U]}function K(A){for(A.t+=A.c;A.c<128;)A.b[A.c++]=0;g(A,!0);const k=new Uint8Array(A.outlen);for(let U=0;U<A.outlen;U++)k[U]=A.h[U>>2]>>8*(U&3);return k}function H(A,k,U,Y,Z){U=U||64,A=C.normalizeInput(A),Y&&(Y=C.normalizeInput(Y)),Z&&(Z=C.normalizeInput(Z));const Q=F(U,k,Y,Z);return V(Q,A),K(Q)}function S(A,k,U,Y,Z){const Q=H(A,k,U,Y,Z);return C.toHex(Q)}oe.exports={blake2b:H,blake2bHex:S,blake2bInit:F,blake2bUpdate:V,blake2bFinal:K}},51843:function(oe,o,R){const C=R(20829);function c(K,H){return K[H]^K[H+1]<<8^K[H+2]<<16^K[H+3]<<24}function v(K,H,S,A,k,U){d[K]=d[K]+d[H]+k,d[A]=B(d[A]^d[K],16),d[S]=d[S]+d[A],d[H]=B(d[H]^d[S],12),d[K]=d[K]+d[H]+U,d[A]=B(d[A]^d[K],8),d[S]=d[S]+d[A],d[H]=B(d[H]^d[S],7)}function B(K,H){return K>>>H^K<<32-H}const y=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint8Array([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]),d=new Uint32Array(16),w=new Uint32Array(16);function i(K,H){let S=0;for(S=0;S<8;S++)d[S]=K.h[S],d[S+8]=y[S];for(d[12]^=K.t,d[13]^=K.t/4294967296,H&&(d[14]=~d[14]),S=0;S<16;S++)w[S]=c(K.b,4*S);for(S=0;S<10;S++)v(0,4,8,12,w[a[S*16+0]],w[a[S*16+1]]),v(1,5,9,13,w[a[S*16+2]],w[a[S*16+3]]),v(2,6,10,14,w[a[S*16+4]],w[a[S*16+5]]),v(3,7,11,15,w[a[S*16+6]],w[a[S*16+7]]),v(0,5,10,15,w[a[S*16+8]],w[a[S*16+9]]),v(1,6,11,12,w[a[S*16+10]],w[a[S*16+11]]),v(2,7,8,13,w[a[S*16+12]],w[a[S*16+13]]),v(3,4,9,14,w[a[S*16+14]],w[a[S*16+15]]);for(S=0;S<8;S++)K.h[S]^=d[S]^d[S+8]}function E(K,H){if(!(K>0&&K<=32))throw new Error("Incorrect output length, should be in [1, 32]");const S=H?H.length:0;if(H&&!(S>0&&S<=32))throw new Error("Incorrect key length, should be in [1, 32]");const A={h:new Uint32Array(y),b:new Uint8Array(64),c:0,t:0,outlen:K};return A.h[0]^=16842752^S<<8^K,S>0&&(g(A,H),A.c=64),A}function g(K,H){for(let S=0;S<H.length;S++)K.c===64&&(K.t+=K.c,i(K,!1),K.c=0),K.b[K.c++]=H[S]}function T(K){for(K.t+=K.c;K.c<64;)K.b[K.c++]=0;i(K,!0);const H=new Uint8Array(K.outlen);for(let S=0;S<K.outlen;S++)H[S]=K.h[S>>2]>>8*(S&3)&255;return H}function F(K,H,S){S=S||32,K=C.normalizeInput(K);const A=E(S,H);return g(A,K),T(A)}function V(K,H,S){const A=F(K,H,S);return C.toHex(A)}oe.exports={blake2s:F,blake2sHex:V,blake2sInit:E,blake2sUpdate:g,blake2sFinal:T}},92493:function(oe,o,R){const C=R(74156),c=R(51843);oe.exports={blake2b:C.blake2b,blake2bHex:C.blake2bHex,blake2bInit:C.blake2bInit,blake2bUpdate:C.blake2bUpdate,blake2bFinal:C.blake2bFinal,blake2s:c.blake2s,blake2sHex:c.blake2sHex,blake2sInit:c.blake2sInit,blake2sUpdate:c.blake2sUpdate,blake2sFinal:c.blake2sFinal}},20829:function(oe){const o="Input must be an string, Buffer or Uint8Array";function R(y){let a;if(y instanceof Uint8Array)a=y;else if(typeof y=="string")a=new TextEncoder().encode(y);else throw new Error(o);return a}function C(y){return Array.prototype.map.call(y,function(a){return(a<16?"0":"")+a.toString(16)}).join("")}function c(y){return(4294967296+y).toString(16).substring(1)}function v(y,a,d){let w=`
3
+ `+y+" = ";for(let i=0;i<a.length;i+=2){if(d===32)w+=c(a[i]).toUpperCase(),w+=" ",w+=c(a[i+1]).toUpperCase();else if(d===64)w+=c(a[i+1]).toUpperCase(),w+=c(a[i]).toUpperCase();else throw new Error("Invalid size "+d);i%6===4?w+=`
4
+ `+new Array(y.length+4).join(" "):i<a.length-2&&(w+=" ")}console.log(w)}function B(y,a,d){let w=new Date().getTime();const i=new Uint8Array(a);for(let g=0;g<a;g++)i[g]=g%256;const E=new Date().getTime();console.log("Generated random input in "+(E-w)+"ms"),w=E;for(let g=0;g<d;g++){const T=y(i),F=new Date().getTime(),V=F-w;w=F,console.log("Hashed in "+V+"ms: "+T.substring(0,20)+"..."),console.log(Math.round(a/(1<<20)/(V/1e3)*100)/100+" MB PER SECOND")}}oe.exports={normalizeInput:R,toHex:C,debugPrint:v,testSpeed:B}},42394:function(oe,o,R){const C=R(92861).Buffer;oe.exports=class{constructor(v=C.from([])){this.buffer=v,this._bytesRead=0,this._bytesWrote=0}read(v){this._bytesRead+=v;const B=this.buffer.slice(0,v);return this.buffer=this.buffer.slice(v),B}write(v){v=C.from(v),this._bytesWrote+=v.length,this.buffer=C.concat([this.buffer,v])}get end(){return!this.buffer.length}get bytesRead(){return this._bytesRead}get bytesWrote(){return this._bytesWrote}}},68249:function(oe,o,R){o.unsigned=R(77698),R(7905)},7905:function(oe,o,R){const C=R(39404),c=R(42394);oe.exports={encode:a,decode:d,write:y,read:v,readBn:B};function v(w){return B(w).toString()}function B(w){const i=new C(0);let E=0,g;for(;g=w.read(1)[0],i.ior(new C(g&127).shln(E)),E+=7,g>>7!==0;);return g&64&&i.setn(E),i.fromTwos(E)}function y(w,i){let E=new C(w);const g=E.isNeg();for(g&&(E=E.toTwos(E.bitLength()+8));;){const F=E.maskn(7).toNumber();if(E.ishrn(7),T(E)&&(F&64)!==0||E.isZero()&&(F&64)===0){i.write([F]);break}else i.write([F|128])}function T(F){return g&&F.toString(2).indexOf("0")<0}}function a(w){const i=new c;return y(w,i),i.buffer}function d(w){const i=new c(w);return v(i)}},77698:function(oe,o,R){const C=R(39404),c=R(42394);oe.exports={encode:a,decode:d,read:v,readBn:B,write:y};function v(w){return B(w).toString()}function B(w){const i=new C(0);let E=0,g;for(;g=w.read(1)[0],i.ior(new C(g&127).shln(E)),g>>7!==0;)E+=7;return i}function y(w,i){const E=new C(w);for(;;){const g=E.maskn(7).toNumber();if(E.ishrn(7),E.isZero()){i.write([g]);break}else i.write([g|128])}}function a(w){const i=new c;return y(w,i),i.buffer}function d(w){const i=new c(w);return v(i)}},31700:function(oe,o,R){"use strict";R.d(o,{pV:function(){return D},lg:function(){return a},X$:function(){return d},yo:function(){return Ge},to:function(){return N},D7:function(){return S},ou:function(){return Ie},ZX:function(){return de},uW:function(){return m}});var C=R(72505),c=R(39404),v;(function(s){s.ETH="10"})(v||(v={}));const B=255;var y;(function(s){s[s.ID=0]="ID",s[s.SECP256K1=1]="SECP256K1",s[s.ACTOR=2]="ACTOR",s[s.BLS=3]="BLS",s[s.DELEGATED=4]="DELEGATED"})(y||(y={}));var a;(function(s){s.Mainnet="mainnet",s.Calibration="calibration",s.Butterfly="butterfly"})(a||(a={}));var d;(function(s){s.Mainnet="f",s.Testnet="t"})(d||(d={}));const w=20,i=54,E=48,g=20,T=20,F=9,V=new c(2).pow(new c(63)).sub(new c(1));var K;(function(s){s[s.Zero=0]="Zero"})(K||(K={}));var H;(function(s){s[s.Transfer=0]="Transfer",s[s.InvokeEVM=3844450837]="InvokeEVM"})(H||(H={}));var S;(function(s){s[s.SECP256K1=1]="SECP256K1",s[s.BLS=3]="BLS"})(S||(S={}));var A;(function(s){s[s.System=0]="System",s[s.Init=1]="Init",s[s.Reward=2]="Reward",s[s.Cron=3]="Cron",s[s.StoragePower=4]="StoragePower",s[s.StorageMarket=5]="StorageMarket",s[s.VerifiedRegistry=6]="VerifiedRegistry",s[s.DataCap=7]="DataCap",s[s.EAM=10]="EAM"})(A||(A={}));var k;(function(s){s[s.Exec=2]="Exec",s[s.Exec4=3]="Exec4"})(k||(k={}));var U;(function(s){s[s.UpdateChannelState=2]="UpdateChannelState",s[s.Settle=3]="Settle",s[s.Collect=4]="Collect"})(U||(U={}));var Y;(function(s){s.Account="bafk2bzacebor5mnjnsav34cmm5pcd3dy4wubbv4wtcrvba7depy3sct7ie4sy",s.Cron="bafk2bzacebetehhedh55alfn4rcx2mhjhvuiustxlhtxc3drkemnpttws5eqw",s.DataCap="bafk2bzaced6uhmrh5jjexhw4lco4ipesi2iutl7uupnyspgmnbydyo3amtu4i",s.EAM="bafk2bzacea6wzcnflfnaxqnwydoghh7ezg5au32ew3bnzljzpiw6fimhlpoiu",s.EthAccount="bafk2bzacedrbpvjvyzif2cjxosm4pliyq2m6wzndvrg7r6hzdhixplzvgubbw",s.EVM="bafk2bzaceabftmhejmvjvpzmbsv4cvaew6v5juj5sqtq7cfijugwsnahnsy5w",s.Init="bafk2bzaceduyjd35y7o2lhvevtysqf45rp5ot7x5f36q6iond6dyiz6773g5q",s.Multisig="bafk2bzacebcb72fmbpocetnzgni2wnbrduamlqx6fl3yelrlzu7id6bu5ib5g",s.PaymentChannel="bafk2bzaceazwhm63kyp47pste5i5acnuhosrgythyagf3kc5clogiqqx6vkzk",s.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",s.Reward="bafk2bzacecp7xo5ev46y64zr5osnn5fxo7itpoqw235tcfv6eo4rymzdemet2",s.StorageMarket="bafk2bzacedjt5mueomasx7dijooxnwxsbtzu2dj2ppp45rtle4kiinkmgzeei",s.StorageMiner="bafk2bzacebkjnjp5okqjhjxzft5qkuv36u4tz7inawseiwi2kw4j43xpxvhpm",s.StoragePower="bafk2bzaced2qsypqwore3jrdtaesh4itst2fyeepdsozvtffc2pianzmphdum",s.System="bafk2bzacedqvik2n3phnj3cni3h2k5mtvz43nyq7mdmv7k7euejysvajywdug",s.VerifiedRegistry="bafk2bzaceceoo5jlom2zweh7kpye2vkj33wgqnkjshlsw2neemqkfg5g2rmvg"})(Y||(Y={}));var Z;(function(s){s.Account="bafk2bzaceampw4romta75hyz5p4cqriypmpbgnkxncgxgqn6zptv5lsp2w2bo",s.Cron="bafk2bzacedcbtsifegiu432m5tysjzkxkmoczxscb6hqpmrr6img7xzdbbs2g",s.DataCap="bafk2bzacealj5uk7wixhvk7l5tnredtelralwnceafqq34nb2lbylhtuyo64u",s.EAM="bafk2bzacedrpm5gbleh4xkyo2jvs7p5g6f34soa6dpv7ashcdgy676snsum6g",s.EthAccount="bafk2bzaceaqoc5zakbhjxn3jljc4lxnthllzunhdor7sxhwgmskvc6drqc3fa",s.EVM="bafk2bzaceahmzdxhqsm7cu2mexusjp6frm7r4kdesvti3etv5evfqboos2j4g",s.Init="bafk2bzaced2f5rhir3hbpqbz5ght7ohv2kgj42g5ykxrypuo2opxsup3ykwl6",s.Multisig="bafk2bzaceduf3hayh63jnl4z2knxv7cnrdenoubni22fxersc4octlwpxpmy4",s.PaymentChannel="bafk2bzaceartlg4mrbwgzcwric6mtvyawpbgx2xclo2vj27nna57nxynf3pgc",s.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",s.Reward="bafk2bzacebnhtaejfjtzymyfmbdrfmo7vgj3zsof6zlucbmkhrvcuotw5dxpq",s.StorageMarket="bafk2bzaceclejwjtpu2dhw3qbx6ow7b4pmhwa7ocrbbiqwp36sq5yeg6jz2bc",s.StorageMiner="bafk2bzaced4h7noksockro7glnssz2jnmo2rpzd7dvnmfs4p24zx3h6gtx47s",s.StoragePower="bafk2bzacec4ay4crzo73ypmh7o3fjendhbqrxake46bprabw67fvwjz5q6ixq",s.System="bafk2bzacedakk5nofebyup4m7nvx6djksfwhnxzrfuq4oyemhpl4lllaikr64",s.VerifiedRegistry="bafk2bzacedfel6edzqpe5oujno7fog4i526go4dtcs6vwrdtbpy2xq6htvcg6"})(Z||(Z={}));var Q=R(14034),be=R(68249);const pe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",ae="0123456789ABCDEFGHIJKLMNOPQRSTUV",x="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function b(s,t,u){u=u||{};let p,L;switch(t){case"RFC3548":case"RFC4648":p=pe,L=!0;break;case"RFC4648-HEX":p=ae,L=!0;break;case"Crockford":p=x,L=!1;break}if(!p)throw new Error(`Unknown base32 variant: ${t}`);const ee=u.padding!==void 0?u.padding:L,se=f(s);let fe=0,we=0,Ae="";for(let Ue=0;Ue<se.byteLength;Ue++)for(we=we<<8|se.getUint8(Ue),fe+=8;fe>=5;)Ae+=p[we>>>fe-5&31],fe-=5;if(fe>0&&(Ae+=p[we<<5-fe&31]),ee)for(;Ae.length%8!==0;)Ae+="=";return Ae}function f(s){if(s instanceof Int8Array||s instanceof Uint8Array||s instanceof Uint8ClampedArray)return new DataView(s.buffer,s.byteOffset,s.byteLength);if(s instanceof ArrayBuffer)return new DataView(s);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}class I extends Error{constructor(t){super(),this.message=`Invalid protocol indicator byte [${t}]`}}class z extends Error{constructor(t){super(),this.message="Unknown protocol indicator byte [${value}]"}}class M extends Error{constructor(t){super(),this.message=`Invalid payload length [${t}]`}}class G extends Error{constructor(t){super(),this.message=`Invalid namespace [${t}]`}}class ne extends Error{constructor(t){super(),this.message=`Invalid network [${t}]`}}class ie extends Error{constructor(){super(),this.message="Invalid subAddress."}}class ce extends Error{constructor(t){super(),this.message=`${t} protocol not supported.`}}class W extends Error{constructor(t,u){super(),this.message=`Invalid address (checksum not matching the payload). ${t} vs ${u}`}}class ue extends Error{constructor(){super(),this.message="Private key need to be an instance of Buffer or a base64 string."}}var O=R(92493),ye=R(48287).Buffer;function ke(s){const t=O.blake2bInit(4);return O.blake2bUpdate(t,s),ye.from(O.blake2bFinal(t))}function Ee(s){let t=0;for(;t<s.length;){const u=s[t];if(t++,u<128)break}return t==s.length?-1:t}const Pe=s=>Object.values(d).includes(s),Me=s=>Object.values(Network).includes(s),He=s=>s===a.Mainnet?d.Mainnet:d.Testnet,Ne=s=>s!==Network.Mainnet;var h=R(48287).Buffer;const st=class{constructor(t,u){P(this,"networkPrefix");P(this,"protocol");P(this,"getPayload",()=>this.payload);P(this,"getNetworkPrefix",()=>this.networkPrefix);P(this,"getProtocol",()=>this.protocol);P(this,"getChecksum",()=>ke(this.toBytes()));this.networkPrefix=t,this.protocol=u}};let D=st;P(D,"fromString",t=>{const u=parseInt(t[1]);switch(u){case y.ID:return le.fromString(t);case y.ACTOR:return me.fromString(t);case y.SECP256K1:return ge.fromString(t);case y.BLS:return X.fromString(t);case y.DELEGATED:{const p=Be.fromString(t);return st.isFilEthAddress(p)?new Ke(p.getNetworkPrefix(),p.getSubAddress()):p}default:throw new z(u)}}),P(D,"fromBytes",(t,u)=>{const p=u[0];switch(p){case y.ID:return le.fromBytes(t,u);case y.ACTOR:return me.fromBytes(t,u);case y.SECP256K1:return ge.fromBytes(t,u);case y.BLS:return X.fromBytes(t,u);case y.DELEGATED:{const L=Be.fromBytes(t,u);return st.isFilEthAddress(L)?new Ke(L.getNetworkPrefix(),L.getSubAddress()):L}default:throw new z(p)}}),P(D,"fromEthAddress",(t,u)=>{if(typeof u=="string"){const L=u.startsWith("0x")?u.substring(2):u;u=h.from(L,"hex")}const p=h.alloc(12);if(p[0]=B,p.compare(u,0,12)==0){let L=12;for(;u[L]==0;)L+=1;return new le(t,h.from(u.subarray(L)))}return new Ke(t,u)}),P(D,"isAddressId",t=>t.protocol==y.ID),P(D,"isAddressBls",t=>t.protocol==y.BLS),P(D,"isAddressSecp256k1",t=>t.protocol==y.SECP256K1),P(D,"isAddressDelegated",t=>t.protocol==y.DELEGATED),P(D,"isFilEthAddress",t=>t.protocol==y.DELEGATED&&"namespace"in t&&t.namespace==v.ETH),P(D,"isAddressActor",t=>t.protocol==y.ACTOR);class X extends D{constructor(u,p){super(u,y.BLS);P(this,"payload");P(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>{const u=this.getChecksum();return this.networkPrefix+this.protocol.toString()+b(h.concat([this.payload,u]),"RFC4648",{padding:!1}).toLowerCase()});if(p.byteLength!==E)throw new M(p.byteLength);this.payload=p}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.BLS)throw new I(parseInt(L));const ee=h.from(Q(u.substring(2).toUpperCase(),"RFC4648")),se=h.from(ee.subarray(0,-4)),fe=h.from(ee.subarray(-4)),we=new X(p,se);if(we.getChecksum().toString("hex")!==fe.toString("hex"))throw new W(we.getChecksum().toString("hex"),fe.toString("hex"));return we}static fromBytes(u,p){if(p[0]!=y.BLS)throw new I(p[0]);const L=h.from(p.subarray(1));return new X(u,L)}}class le extends D{constructor(u,p){super(u,y.ID);P(this,"id");P(this,"payload");P(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>this.networkPrefix+this.protocol.toString()+be.unsigned.decode(this.payload));P(this,"getId",()=>this.id);P(this,"toEthAddressHex",(u=!1)=>{const p=h.alloc(w);return p[0]=B,p.set(this.payload,w-this.payload.length),`${u?"0x":""}${p.toString("hex")}`});const L=typeof p=="string"?be.unsigned.encode(p):p;if(L.length>F)throw new M(L.length);this.payload=L,this.id=this.toString().substring(2)}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.ID)throw new I(parseInt(L));const ee=be.unsigned.encode(u.substring(2));return new le(p,ee)}static fromBytes(u,p){if(p[0]!=y.ID)throw new I(p[0]);const L=h.from(p.subarray(1));return new le(u,L)}}class ge extends D{constructor(u,p){super(u,y.SECP256K1);P(this,"payload");P(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>{const u=this.getChecksum();return this.networkPrefix+this.protocol.toString()+b(h.concat([this.payload,u]),"RFC4648",{padding:!1}).toLowerCase()});if(p.byteLength!==T)throw new M(p.byteLength);this.payload=p}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.SECP256K1)throw new I(parseInt(L));const ee=h.from(Q(u.substring(2).toUpperCase(),"RFC4648")),se=h.from(ee.subarray(0,-4)),fe=h.from(ee.subarray(-4)),we=new ge(p,se);if(we.getChecksum().toString("hex")!==fe.toString("hex"))throw new W(we.getChecksum().toString("hex"),fe.toString("hex"));return we}static fromBytes(u,p){if(p[0]!=y.SECP256K1)throw new I(p[0]);const L=h.from(p.subarray(1));return new ge(u,L)}}class me extends D{constructor(u,p){super(u,y.ACTOR);P(this,"payload");P(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>{const u=this.getChecksum();return this.networkPrefix+this.protocol.toString()+b(h.concat([this.payload,u]),"RFC4648",{padding:!1}).toLowerCase()});if(p.byteLength!==g)throw new M(p.byteLength);this.payload=p}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.ACTOR)throw new I(parseInt(L));const ee=h.from(Q(u.substring(2).toUpperCase(),"RFC4648")),se=h.from(ee.subarray(0,-4)),fe=h.from(ee.subarray(-4)),we=new me(p,se);if(we.getChecksum().toString("hex")!==fe.toString("hex"))throw new W(we.getChecksum().toString("hex"),fe.toString("hex"));return we}static fromBytes(u,p){if(p[0]!=y.ACTOR)throw new I(p[0]);const L=h.from(p.subarray(1));return new me(u,L)}}class Be extends D{constructor(u,p,L){super(u,y.DELEGATED);P(this,"payload");P(this,"namespace");P(this,"subAddress");P(this,"getNamespace",()=>this.namespace);P(this,"getSubAddress",()=>this.subAddress);P(this,"toBytes",()=>{const u=h.from(be.unsigned.encode(this.namespace)),p=h.from(be.unsigned.encode(this.protocol));return h.concat([p,u,this.subAddress])});P(this,"toString",()=>{const u=this.getChecksum();return this.networkPrefix+this.protocol.toString()+this.namespace+"f"+b(h.concat([this.subAddress,u]),"RFC4648",{padding:!1}).toLowerCase()});if(new c(p).gt(V))throw new G(p);if(L.length===0||L.length>i)throw new ie;this.namespace=p,this.subAddress=L,this.payload=h.from(this.toBytes().subarray(1))}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.DELEGATED)throw new I(parseInt(L));const ee=u.substring(2,u.indexOf("f",2)),se=u.substring(u.indexOf("f",2)+1),fe=h.from(Q(se.toUpperCase(),"RFC4648")),we=h.from(fe.subarray(0,-4)),Ae=h.from(fe.subarray(-4)),Ue=new Be(p,ee,we);if(Ue.getChecksum().toString("hex")!==Ae.toString("hex"))throw new W(Ue.getChecksum().toString("hex"),Ae.toString("hex"));return Ue}static fromBytes(u,p){if(p[0]!=y.DELEGATED)throw new I(p[0]);const L=Ee(h.from(p.subarray(1))),ee=be.unsigned.decode(h.from(p.subarray(1,1+L))),se=h.from(p.subarray(L+1));return new Be(u,ee,se)}}class Ke extends Be{constructor(u,p){super(u,v.ETH,p);P(this,"toEthAddressHex",(u=!1)=>`${u?"0x":""}${this.subAddress.toString("hex")}`);if(p.length!==w)throw new Error("invalid ethereum address: length should be 32 bytes")}static fromBytes(u,p){const L=Be.fromBytes(u,p);if(L.getNamespace()!==v.ETH)throw new Error("invalid filecoin address for ethereum space");return new Ke(L.getNetworkPrefix(),L.getSubAddress())}static fromString(u){const p=Be.fromString(u);if(p.getNamespace()!==v.ETH)throw new Error("invalid filecoin address for ethereum space");return new Ke(p.getNetworkPrefix(),p.getSubAddress())}}const Ce="2.0",ct="Filecoin.MpoolGetNonce",Qe="Filecoin.MpoolPush",ft="Filecoin.StateWaitMsg",Je="Filecoin.GasEstimateMessageGas",ut="Filecoin.StateReadState",_e="Filecoin.StateListMiners",et="Filecoin.StateMinerInfo",tt="Filecoin.ClientQueryAsk",lt="Filecoin.WalletBalance";class Ge{constructor(t,u){P(this,"fetcher");P(this,"network");P(this,"getNetwork",()=>this.network);P(this,"validateNetwork",(t,u="address")=>{const p=He(this.network);if(typeof t=="string"&&(t=D.fromString(t)),t.getNetworkPrefix()!==p)throw new Error(`${u} belongs to ${t.getNetworkPrefix()} network while rpc allows ${p}`);return t});this.fetcher=C.create({baseURL:u.url,timeout:u.timeout,headers:{Authorization:`Bearer ${u.token}`}}),this.network=t}async getNonce(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ct,id:1,params:[t.toString()]})).data}catch(u){return this.handleError(u)}}async broadcastTransaction(t,u){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ce,method:Qe,id:1,params:[{Message:t.toJSON(),Signature:u.toJSON()}]})).data}catch(p){return this.handleError(p)}}async getGasEstimation(t){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ce,method:Je,id:1,params:[t.toJSON(),{MaxFee:"0"},null]})).data}catch(u){return this.handleError(u)}}async readState(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ut,id:1,params:[t.toString(),null]})).data}catch(u){return this.handleError(u)}}async waitMsgState(t,u,p){try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ft,id:1,params:[t,u,p,!1]})).data}catch(L){return this.handleError(L)}}async walletBalance(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:lt,id:1,params:[t.toString()]})).data}catch(u){return this.handleError(u)}}async listMiners(){try{return(await this.fetcher.post("",{jsonrpc:Ce,method:_e,id:1,params:[null]})).data}catch(t){return this.handleError(t)}}async getMinerInfo(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:et,id:1,params:[t.toString(),null]})).data}catch(u){return this.handleError(u)}}async askForStorage(t,u){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:tt,id:1,params:[u,t.toString()]})).data}catch(p){return this.handleError(p)}}handleError(t){if(C.isAxiosError(t)){if(t.response){if(t.response.data)return t.response.data;if(t.response.statusText)return{error:{message:`${t.response.status} - ${t.response.statusText}`}}}if(t.request)return{error:{message:"request made but no response received"}};if(t.message)return{error:{message:t.message}}}throw t}}class bt extends Ge{constructor(t){super(a.Mainnet,t)}}class yt extends Ge{constructor(t){super(a.Calibration,t)}}class We extends Ge{constructor(t){super(a.Butterfly,t)}}var ze=R(90749),ht=R(83328),rt=R(73513),dt=R.t(rt,2),je=R(17009),Oe=R(48287).Buffer;const nt=Oe.from([1,113,160,228,2,32]),ot=32,it=s=>{const t=s.split("/");return t[2].includes("'")?t[2].substring(0,t[2].length-1):t[2]};function ve(s){const t=O.blake2bInit(ot);O.blake2bUpdate(t,s);const u=Oe.from(O.blake2bFinal(t));return Oe.concat([nt,u])}function Re(s){const t=O.blake2bInit(32);return O.blake2bUpdate(t,ve(s)),Oe.from(O.blake2bFinal(t))}const Ze=s=>{if(typeof s=="string")if(s.substring(s.length-1)==="=")s=Oe.from(s,"base64");else throw new ue;if(s.length!==32)throw new ue;return s},n=s=>{const t=O.blake2bInit(20);return O.blake2bUpdate(t,s),Oe.from(O.blake2bFinal(t))},e=s=>S.BLS===s||S.SECP256K1===s;var r=R(48287).Buffer;const l=ht.Pr(dt),Ye=class{static recoverAccount(t,u,p,L){switch(u){case S.SECP256K1:{p=Ze(p);const{publicKey:ee,address:se}=Ye.getPublicSecp256k1FromPrivKey(t,p);return{type:u,privateKey:p,address:se,publicKey:ee,path:L}}default:throw new Error("not supported yet")}}};let m=Ye;P(m,"generateMnemonic",()=>ze.generateMnemonic(256)),P(m,"mnemonicToSeed",(t,u)=>ze.mnemonicToSeedSync(t,u)),P(m,"deriveAccount",(t,u,p,L,ee)=>{const se=Ye.mnemonicToSeed(t,L);return Ye.deriveAccountFromSeed(se,u,p,ee)}),P(m,"deriveAccountFromSeed",(t,u,p,L)=>{switch(typeof t=="string"&&(t=r.from(t,"hex")),u){case S.SECP256K1:{const ee=l.fromSeed(t),{privateKey:se}=ee.derivePath(p);if(!se)throw new Error("privateKey not generated");L||(L=it(p)==="1"?d.Testnet:d.Mainnet);const{publicKey:fe,address:we}=Ye.getPublicSecp256k1FromPrivKey(L,se);return{type:u,privateKey:se,publicKey:fe,address:we,path:p}}default:throw new Error("not supported yet")}}),P(m,"signTransaction",async(t,u)=>{const p=await u.serialize(),L=Re(p),{privateKey:ee,type:se}=t;switch(se){case S.SECP256K1:{const fe=je.ecdsaSign(L,ee);return new N(se,r.concat([r.from(fe.signature),r.from([fe.recid])]))}default:throw new Error("not supported yet")}}),P(m,"verifySignature",async(t,u)=>{const p=await u.serialize(),L=Re(p);switch(t.getType()){case S.SECP256K1:{const ee=t.getData(),se=je.ecdsaRecover(ee.subarray(0,-1),ee[64],L,!1),fe=n(se);return u.from.getPayload().toString("hex")!==fe.toString("hex")?!1:je.ecdsaVerify(ee.subarray(0,-1),L,se)}default:throw new Error("not supported yet")}}),P(m,"getPublicSecp256k1FromPrivKey",(t,u)=>{const p=je.publicKeyCreate(u),L=new Uint8Array(65);je.publicKeyConvert(p,!1,L);const ee=r.from(L),se=n(L);return{publicKey:ee,address:new ge(t,se)}});const wt=class{constructor(t,u){P(this,"type");P(this,"data");P(this,"toJSON",()=>({Type:this.type,Data:this.data.toString("base64")}));P(this,"getType",()=>this.type);P(this,"getData",()=>this.data);P(this,"isSecp256k1",()=>this.type===S.SECP256K1);P(this,"isBls",()=>this.type===S.BLS);this.type=t,this.data=u}};let N=wt;P(N,"fromJSON",t=>{if(typeof t!="object"||t===null)throw new Error("input should be an object");if(!("Type"in t)||typeof t.Type!="number")throw new Error("'Type' should be a number");if(!e(t.Type))throw new Error("invalid signature type");if(!("Data"in t)||typeof t.Data!="string")throw new Error("'Data' should be a base64 encoded string");return new wt(t.Type,r.from(t.Data,"base64"))});var j=R(48287).Buffer;const $=(s,t=10)=>{if(s.toString()==="0")return j.from("");const u=new c(s,t),p=u.toArrayLike(j,"be",u.byteLength()),L=j.from(u.isNeg()?"01":"00","hex");return j.concat([L,p])},J=(s,t=10)=>{if(s.length===0)return"0";if(s[0]!=0&&s[0]!=1)throw new Error("invalid bigint");const u=s[0]===1?"-":"",p=new c(s.subarray(1));return u+p.toString(t)},q=s=>new Promise(t=>setTimeout(t,s)),_=async s=>{let t=s();for(;!t;)await q(50),t=s();return t};var te=R(48287).Buffer;let re;R.e(1523).then(R.bind(R,71523)).then(s=>{re=s}).catch(s=>{throw s});const qe=class{constructor(t,u,p,L,ee,se,fe,we,Ae,Ue){P(this,"version");P(this,"to");P(this,"from");P(this,"nonce");P(this,"value");P(this,"gasLimit");P(this,"gasFeeCap");P(this,"gasPremium");P(this,"method");P(this,"params");P(this,"toJSON",()=>({To:this.to.toString(),From:this.from.toString(),Nonce:this.nonce,Value:this.value,Params:this.params,GasFeeCap:this.gasFeeCap,GasPremium:this.gasPremium,GasLimit:this.gasLimit,Method:this.method}));P(this,"serialize",async()=>{const t=await _(()=>re),u=[this.version,this.to.toBytes(),this.from.toBytes(),this.nonce,$(this.value,10),this.gasLimit,$(this.gasFeeCap,10),$(this.gasPremium,10),this.method,te.from(this.params,"base64")];return te.from(t.encode(u))});P(this,"prepareToSend",async t=>{const u=await t.getNonce(this.from);if("error"in u)throw new Error(u.error.message);this.nonce=u.result;const p=await t.getGasEstimation(this);if("error"in p)throw new Error(p.error.message);return this.gasFeeCap=p.result.GasFeeCap,this.gasLimit=p.result.GasLimit,this.gasPremium=p.result.GasPremium,this});if(this.version=t,this.to=u,this.from=p,this.nonce=L,this.value=ee,this.gasLimit=se,this.gasFeeCap=fe,this.gasPremium=we,this.method=Ae,this.params=Ue,ee===""||ee.includes("-"))throw new Error("value must not be empty or negative")}};let de=qe;P(de,"getNew",(t,u,p,L,ee=te.alloc(0))=>new qe(K.Zero,t,u,0,p.toAtto(),0,"0","0",L,ee.toString("base64"))),P(de,"fromCBOR",async(t,u)=>{typeof u=="string"&&(u=te.from(u,"hex"));const L=(await _(()=>re)).decode(u);if(!(L instanceof Array))throw new Error("Decoded raw tx should be an array");if(L.length<10)throw new Error("The cbor is missing some fields... please verify you have 9 fields.");const[ee,se,fe,we,Ae,Ue,Ct,Rt,Tt,Ut]=L;if(ee!==K.Zero)throw new Error("Unsupported version");if(Ae[0]===1)throw new Error("Value cant be negative");const Nt=new c(te.from(Ae).toString("hex"),16).toString(10),Kt=new c(te.from(Ct).toString("hex"),16).toString(10),zt=new c(te.from(Rt).toString("hex"),16).toString(10);return new qe(ee,D.fromBytes(t,se),D.fromBytes(t,fe),we,Nt,Ue,Kt,zt,Tt,Ut.toString("base64"))}),P(de,"fromJSON",t=>{if(typeof t!="object"||t==null)throw new Error("tx should be an json object");if(!("To"in t)||typeof t.To!="string")throw new Error("'To' is a required field and has to be a 'string'");if(!("From"in t)||typeof t.From!="string")throw new Error("'From' is a required field and has to be a 'string'");if(!("Nonce"in t)||typeof t.Nonce!="number")throw new Error("'Nonce' is a required field and has to be a 'number'");if(!("Value"in t)||typeof t.Value!="string"||t.Value===""||t.Value.includes("-"))throw new Error("'Value' is a required field and has to be a 'string' but not empty or negative");if(!("GasFeeCap"in t)||typeof t.GasFeeCap!="string")throw new Error("'GasFeeCap' is a required field and has to be a 'string'");if(!("GasPremium"in t)||typeof t.GasPremium!="string")throw new Error("'GasPremium' is a required field and has to be a 'string'");if(!("GasLimit"in t)||typeof t.GasLimit!="number")throw new Error("'GasLimit' is a required field and has to be a 'number'");if(!("Method"in t)||typeof t.Method!="number")throw new Error("'Method' is a required field and has to be a 'number'");if(!("Params"in t)||typeof t.Params!="string")throw new Error("'Params' is a required field and has to be a 'string'");return new qe(K.Zero,D.fromString(t.To),D.fromString(t.From),t.Nonce,t.Value,t.GasLimit,t.GasFeeCap,t.GasPremium,t.Method,t.Params)});const he=(s,t)=>{const u=s.isNeg()?"-":"",p=s.abs().toString(),L=p.length-t,ee=xe(L>0?`${p.substring(0,L)}.${p.substring(L)}`:`0.${"".padStart(-1*L,"0")}${p}`);return`${u}${ee}`},xe=s=>{for(let t=s.length-1;t>=0;t--){if(s[t]==".")return s.substring(0,t);if(s[t]!="0"||t===1)return s.substring(0,t+1)}throw new Error("invalid value")},Se=18,Le=15,De=12,$e=9,Ve=6,Fe=3,St=0,xt=new c(10).pow(new c(Fe)),At=new c(10).pow(new c(Ve)),Pt=new c(10).pow(new c($e)),Bt=new c(10).pow(new c(De)),It=new c(10).pow(new c(Le)),kt=new c(10).pow(new c(Se)),Te=class{constructor(t){P(this,"value");P(this,"add",t=>(this.value=this.value.add(t.value),this));P(this,"sub",t=>(this.value=this.value.sub(t.value),this));P(this,"gt",t=>this.value.gt(t.value));P(this,"gte",t=>this.value.gte(t.value));P(this,"lt",t=>this.value.lt(t.value));P(this,"lte",t=>this.value.lte(t.value));P(this,"isNegative",()=>this.value.isNeg());P(this,"isPositive",()=>!this.value.isNeg());P(this,"isZero",()=>this.value.isZero());P(this,"toWhole",()=>he(this.value,Se));P(this,"toMilli",()=>he(this.value,Se-Fe));P(this,"toMicro",()=>he(this.value,Se-Ve));P(this,"toNano",()=>he(this.value,Se-$e));P(this,"toPico",()=>he(this.value,Se-De));P(this,"toFemto",()=>he(this.value,Se-Le));P(this,"toAtto",()=>he(this.value,0));P(this,"serialize",()=>$(this.value.toString(10),10));this.value=t}};let Ie=Te;P(Ie,"zero",()=>new Te(new c("0"))),P(Ie,"deserialize",t=>new Te(new c(J(t,10),10))),P(Ie,"fromAtto",t=>new Te(new c(t))),P(Ie,"fromFemto",t=>new Te(new c(t).mul(xt))),P(Ie,"fromPico",t=>new Te(new c(t).mul(At))),P(Ie,"fromNano",t=>new Te(new c(t).mul(Pt))),P(Ie,"fromMicro",t=>new Te(new c(t).mul(Bt))),P(Ie,"fromMilli",t=>new Te(new c(t).mul(It))),P(Ie,"fromWhole",t=>new Te(new c(t).mul(kt)));class gt{}P(gt,"send",null),P(gt,"getBalance",null);var Dt=R(48287).Buffer;class pt{}P(pt,"newTx",null),P(pt,"newExecTx",null);let mt;R.e(1523).then(R.bind(R,71523)).then(s=>{mt=s}).catch(s=>{throw s});let Et;R.e(2131).then(R.bind(R,92131)).then(s=>{Et=s}).catch(s=>{throw s});class Ft{constructor(t,u){P(this,"targetActorCid");P(this,"targetConstructorParams");P(this,"serialize",async()=>{const t=await waitFor(()=>mt),u=await waitFor(()=>Et);return t.encode([u.CID.parse(this.targetActorCid),this.targetConstructorParams])});this.targetActorCid=t,this.targetConstructorParams=u}}let vt;R.e(1523).then(R.bind(R,71523)).then(s=>{vt=s}).catch(s=>{throw s});class Mt{constructor(t,u){P(this,"from");P(this,"to");P(this,"serialize",async()=>(await waitFor(()=>vt)).encode([this.from.toBytes(),this.to.toBytes()]));this.from=t,this.to=u}}const Ht=s=>{switch(s){case Network.Calibration:return ActorsCalibrationV11;case Network.Mainnet:return ActorsMainnetV10;case Network.Butterfly:throw new Error("not implemented yet")}},at=class{constructor(t,u,p){P(this,"channelAddress");P(this,"from");P(this,"to");P(this,"getAddress",()=>this.channelAddress);P(this,"getTo",()=>this.to);P(this,"getFrom",()=>this.from);P(this,"settle",(t,u)=>{const{address:p}=u,L=Transaction.getNew(this.channelAddress,p,Token.zero(),PayChActorMethods.Settle);return at.sendTx(t,u,L)});P(this,"collect",(t,u)=>{const{address:p}=u,L=Transaction.getNew(this.channelAddress,p,Token.zero(),PayChActorMethods.Collect);return at.sendTx(t,u,L)});this.channelAddress=t,this.from=u,this.to=p}};let Xe=at;P(Xe,"create",null),P(Xe,"loadFromCid",null),P(Xe,"sendTx",null)}}]);