@spfunctions/cli 2.0.6 → 2.0.10
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/README.md +268 -144
- package/dist/122.index.js +1 -0
- package/dist/160.index.js +1 -1
- package/dist/340.index.js +1 -0
- package/dist/563.index.js +1 -1
- package/dist/634.index.js +13 -0
- package/dist/77.index.js +1 -0
- package/dist/index.js +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";exports.id=634,exports.ids=[634],exports.modules={37634:(t,e,n)=>{n.d(e,{Wallet:()=>qs});var r={};function i(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function s(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function o(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");i(t.outputLen),i(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function l(t,e){s(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}n.r(r),n.d(r,{OG:()=>H,My:()=>F,Ph:()=>D,lX:()=>z,Id:()=>_,fg:()=>q,qj:()=>M,aT:()=>$,lq:()=>V,z:()=>K,Q5:()=>Y});var c=n(77598),u=n.t(c,2);const h=u&&"object"==typeof u&&"webcrypto"in u?c.webcrypto:void 0,f=t=>t instanceof Uint8Array,d=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),p=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),g=(t,e)=>t<<32-e|t>>>e;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const y=async()=>{};async function m(t,e,n){let r=Date.now();for(let i=0;i<t;i++){n(i);const t=Date.now()-r;t>=0&&t<e||(await y(),r+=t)}}function w(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!f(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class b{clone(){return this._cloneInto()}}const v={}.toString;function E(t,e){if(void 0!==e&&"[object Object]"!==v.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)}function I(t){const e=e=>t().update(w(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function A(t=32){if(h&&"function"==typeof h.getRandomValues)return h.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class P extends b{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=p(this.buffer)}update(t){a(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=w(t)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o===r){const e=p(t);for(;r<=i-s;s+=r)this.process(e,s);continue}n.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){a(this),l(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let t=s;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;t.setUint32(e+l,o,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=p(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)o.setUint32(4*t,h[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return t.length=r,t.pos=o,t.finished=i,t.destroyed=s,r%e&&t.buffer.set(n),t}}const N=(t,e,n)=>t&e^~t&n,x=(t,e,n)=>t&e^t&n^e&n,O=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),S=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),R=new Uint32Array(64);class T extends P{constructor(){super(64,32,8,!1),this.A=0|S[0],this.B=0|S[1],this.C=0|S[2],this.D=0|S[3],this.E=0|S[4],this.F=0|S[5],this.G=0|S[6],this.H=0|S[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[t,e,n,r,i,s,o,a]}set(t,e,n,r,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)R[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=R[t-15],n=R[t-2],r=g(e,7)^g(e,18)^e>>>3,i=g(n,17)^g(n,19)^n>>>10;R[t]=i+R[t-7]+r+R[t-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let t=0;t<64;t++){const e=c+(g(o,6)^g(o,11)^g(o,25))+N(o,a,l)+O[t]+R[t]|0,u=(g(n,2)^g(n,13)^g(n,22))+x(n,r,i)|0;c=l,l=a,a=o,o=s+e|0,s=i,i=r,r=n,n=e+u|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){R.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const k=I(()=>new T),L=(BigInt(0),BigInt(1)),B=BigInt(2),C=t=>t instanceof Uint8Array,U=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function F(t){if(!C(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=U[t[n]];return e}function G(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function $(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let e=0;e<n.length;e++){const r=2*e,i=t.slice(r,r+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[e]=s}return n}function D(t){return G(F(t))}function z(t){if(!C(t))throw new Error("Uint8Array expected");return G(F(Uint8Array.from(t).reverse()))}function V(t,e){return $(t.toString(16).padStart(2*e,"0"))}function K(t,e){return V(t,e).reverse()}function M(t,e,n){let r;if("string"==typeof e)try{r=$(e)}catch(n){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${n}`)}else{if(!C(e))throw new Error(`${t} must be hex string or Uint8Array`);r=Uint8Array.from(e)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${t} expected ${n} bytes, got ${i}`);return r}function _(...t){const e=new Uint8Array(t.reduce((t,e)=>t+e.length,0));let n=0;return t.forEach(t=>{if(!C(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}const H=t=>(B<<BigInt(t-1))-L,j=t=>new Uint8Array(t),W=t=>Uint8Array.from(t);function q(t,e,n){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=j(t),i=j(t),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...t)=>n(i,r,...t),l=(t=j())=>{i=a(W([0]),t),r=a(),0!==t.length&&(i=a(W([1]),t),r=a())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t<e;){r=a();const e=r.slice();n.push(e),t+=r.length}return _(...n)};return(t,e)=>{let n;for(o(),l(t);!(n=e(c()));)l();return o(),n}}const Z={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function Y(t,e,n={}){const r=(e,n,r)=>{const i=Z[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const s=t[e];if(!(r&&void 0===s||i(s,t)))throw new Error(`Invalid param ${String(e)}=${s} (${typeof s}), expected ${n}`)};for(const[t,n]of Object.entries(e))r(t,n,!1);for(const[t,e]of Object.entries(n))r(t,e,!0);return t}
|
|
2
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
+
const J=BigInt(0),X=BigInt(1),Q=BigInt(2),tt=BigInt(3),et=BigInt(4),nt=BigInt(5),rt=BigInt(8);BigInt(9),BigInt(16);function it(t,e){const n=t%e;return n>=J?n:e+n}function st(t,e,n){if(n<=J||e<J)throw new Error("Expected power/modulo > 0");if(n===X)return J;let r=X;for(;e>J;)e&X&&(r=r*t%n),t=t*t%n,e>>=X;return r}function ot(t,e,n){let r=t;for(;e-- >J;)r*=r,r%=n;return r}function at(t,e){if(t===J||e<=J)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=it(t,e),r=e,i=J,s=X,o=X,a=J;for(;n!==J;){const t=r/n,e=r%n,l=i-o*t,c=s-a*t;r=n,n=e,i=o,s=a,o=l,a=c}if(r!==X)throw new Error("invert: does not exist");return it(i,e)}function lt(t){if(t%et===tt){const e=(t+X)/et;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}if(t%rt===nt){const e=(t-nt)/rt;return function(t,n){const r=t.mul(n,Q),i=t.pow(r,e),s=t.mul(n,i),o=t.mul(t.mul(s,Q),i),a=t.mul(s,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-X)/Q;let n,r,i;for(n=t-X,r=0;n%Q===J;n/=Q,r++);for(i=Q;i<t&&st(i,e,t)!==t-X;i++);if(1===r){const e=(t+X)/et;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}const s=(n+X)/Q;return function(t,o){if(t.pow(o,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=r,l=t.pow(t.mul(t.ONE,i),n),c=t.pow(o,s),u=t.pow(o,n);for(;!t.eql(u,t.ONE);){if(t.eql(u,t.ZERO))return t.ZERO;let e=1;for(let n=t.sqr(u);e<a&&!t.eql(n,t.ONE);e++)n=t.sqr(n);const n=t.pow(l,X<<BigInt(a-e-1));l=t.sqr(n),c=t.mul(c,n),u=t.mul(u,l),a=e}return c}}(t)}const ct=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ut(t,e){const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function ht(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function ft(t){const e=ht(t);return e+Math.ceil(e/2)}class dt extends b{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,o(t);const n=w(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return a(this),this.iHash.update(t),this}digestInto(t){a(this),s(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return t.finished=r,t.destroyed=i,t.blockLen=s,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const pt=(t,e,n)=>new dt(t,e).update(n).digest();pt.create=(t,e)=>new dt(t,e);
|
|
4
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
|
+
const gt=BigInt(0),yt=BigInt(1);function mt(t){return Y(t.Fp,ct.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Y(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ut(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const{Ph:wt,aT:bt}=r,vt={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=vt;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(128&r[0])throw new e("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:wt(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=vt,n="string"==typeof t?bt(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=vt._parseInt(n.subarray(2)),{d:o,l:a}=vt._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,n=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},r=e(n(t.s)),i=e(n(t.r)),s=r.length/2,o=i.length/2,a=n(s),l=n(o);return`30${n(o+s+4)}02${l}${i}02${a}${r}`}},Et=BigInt(0),It=BigInt(1),At=(BigInt(2),BigInt(3));BigInt(4);function Pt(t){const e=
|
|
6
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
7
|
+
function(t){const e=mt(t);Y(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:n}=e,r=e.toBytes||((t,e,r)=>{const i=e.toAffine();return _(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function s(t){const{a:r,b:i}=e,s=n.sqr(t),o=n.mul(s,t);return n.add(n.add(o,n.mul(t,r)),i)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(t){return"bigint"==typeof t&&Et<t&&t<e.n}function a(t){if(!o(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(t){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:s}=e;if(n&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=F(t)),"string"!=typeof t||!n.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*r,"0")}let o;try{o="bigint"==typeof t?t:D(M("private key",t,r))}catch(e){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof t}`)}return i&&(o=it(o,s)),a(o),o}const c=new Map;function u(t){if(!(t instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(t,e,r){if(this.px=t,this.py=e,this.pz=r,null==t||!n.isValid(t))throw new Error("x required");if(null==e||!n.isValid(e))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof h)throw new Error("projective point not allowed");const i=t=>n.eql(t,n.ZERO);return i(e)&&i(r)?h.ZERO:new h(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=n.invertBatch(t.map(t=>t.pz));return t.map((t,n)=>t.toAffine(e[n])).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(i(M("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(l(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:r}=this.toAffine();if(!n.isValid(t)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=n.sqr(r),o=s(t);if(!n.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:r,pz:i}=this,{px:s,py:o,pz:a}=t,l=n.eql(n.mul(e,a),n.mul(s,i)),c=n.eql(n.mul(r,a),n.mul(o,i));return l&&c}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,i=n.mul(r,At),{px:s,py:o,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,f=n.mul(s,s),d=n.mul(o,o),p=n.mul(a,a),g=n.mul(s,o);return g=n.add(g,g),u=n.mul(s,a),u=n.add(u,u),l=n.mul(t,u),c=n.mul(i,p),c=n.add(l,c),l=n.sub(d,c),c=n.add(d,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(i,u),p=n.mul(t,p),g=n.sub(f,p),g=n.mul(t,g),g=n.add(g,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,p),f=n.mul(f,g),c=n.add(c,f),p=n.mul(o,a),p=n.add(p,p),f=n.mul(p,g),l=n.sub(l,f),u=n.mul(p,d),u=n.add(u,u),u=n.add(u,u),new h(l,c,u)}add(t){u(t);const{px:r,py:i,pz:s}=this,{px:o,py:a,pz:l}=t;let c=n.ZERO,f=n.ZERO,d=n.ZERO;const p=e.a,g=n.mul(e.b,At);let y=n.mul(r,o),m=n.mul(i,a),w=n.mul(s,l),b=n.add(r,i),v=n.add(o,a);b=n.mul(b,v),v=n.add(y,m),b=n.sub(b,v),v=n.add(r,s);let E=n.add(o,l);return v=n.mul(v,E),E=n.add(y,w),v=n.sub(v,E),E=n.add(i,s),c=n.add(a,l),E=n.mul(E,c),c=n.add(m,w),E=n.sub(E,c),d=n.mul(p,v),c=n.mul(g,w),d=n.add(c,d),c=n.sub(m,d),d=n.add(m,d),f=n.mul(c,d),m=n.add(y,y),m=n.add(m,y),w=n.mul(p,w),v=n.mul(g,v),m=n.add(m,w),w=n.sub(y,w),w=n.mul(p,w),v=n.add(v,w),y=n.mul(m,v),f=n.add(f,y),y=n.mul(E,v),c=n.mul(b,c),c=n.sub(c,y),y=n.mul(b,m),d=n.mul(E,d),d=n.add(d,y),new h(c,f,d)}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return d.wNAFCached(this,c,t,t=>{const e=n.invertBatch(t.map(t=>t.pz));return t.map((t,n)=>t.toAffine(e[n])).map(h.fromAffine)})}multiplyUnsafe(t){const r=h.ZERO;if(t===Et)return r;if(a(t),t===It)return this;const{endo:i}=e;if(!i)return d.unsafeLadder(this,t);let{k1neg:s,k1:o,k2neg:l,k2:c}=i.splitScalar(t),u=r,f=r,p=this;for(;o>Et||c>Et;)o&It&&(u=u.add(p)),c&It&&(f=f.add(p)),p=p.double(),o>>=It,c>>=It;return s&&(u=u.negate()),l&&(f=f.negate()),f=new h(n.mul(f.px,i.beta),f.py,f.pz),u.add(f)}multiply(t){a(t);let r,i,s=t;const{endo:o}=e;if(o){const{k1neg:t,k1:e,k2neg:a,k2:l}=o.splitScalar(s);let{p:c,f:u}=this.wNAF(e),{p:f,f:p}=this.wNAF(l);c=d.constTimeNegate(t,c),f=d.constTimeNegate(a,f),f=new h(n.mul(f.px,o.beta),f.py,f.pz),r=c.add(f),i=u.add(p)}else{const{p:t,f:e}=this.wNAF(s);r=t,i=e}return h.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(t,e,n){const r=h.BASE,i=(t,e)=>e!==Et&&e!==It&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),s=i(this,e).add(i(t,n));return s.is0()?void 0:s}toAffine(t){const{px:e,py:r,pz:i}=this,s=this.is0();null==t&&(t=s?n.ONE:n.inv(i));const o=n.mul(e,t),a=n.mul(r,t),l=n.mul(i,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===It)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===It?this:n?n(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(h,this,t)}toHex(t=!0){return F(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const f=e.nBitLength,d=function(t,e){const n=(t,e)=>{const n=e.negate();return t?n:e},r=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:n,unsafeLadder(e,n){let r=t.ZERO,i=e;for(;n>gt;)n&yt&&(r=r.add(i)),i=i.double(),n>>=yt;return r},precomputeWindow(t,e){const{windows:n,windowSize:i}=r(e),s=[];let o=t,a=o;for(let t=0;t<n;t++){a=o,s.push(a);for(let t=1;t<i;t++)a=a.add(o),s.push(a);o=a.double()}return s},wNAF(e,i,s){const{windows:o,windowSize:a}=r(e);let l=t.ZERO,c=t.BASE;const u=BigInt(2**e-1),h=2**e,f=BigInt(e);for(let t=0;t<o;t++){const e=t*a;let r=Number(s&u);s>>=f,r>a&&(r-=h,s+=yt);const o=e,d=e+Math.abs(r)-1,p=t%2!=0,g=r<0;0===r?c=c.add(n(p,i[o])):l=l.add(n(g,i[d]))}return{p:l,f:c}},wNAFCached(t,e,n,r){const i=t._WINDOW_SIZE||1;let s=e.get(t);return s||(s=this.precomputeWindow(t,i),1!==i&&e.set(t,r(s))),this.wNAF(i,s,n)}}}(h,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:o}}function Nt(t){const e=function(t){const e=mt(t);return Y(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:n,n:r}=e,i=n.BYTES+1,s=2*n.BYTES+1;function o(t){return it(t,r)}function a(t){return at(t,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:h}=Pt({...e,toBytes(t,e,r){const i=e.toAffine(),s=n.toBytes(i.x),o=_;return r?o(Uint8Array.from([e.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(i.y))},fromBytes(t){const e=t.length,r=t[0],o=t.subarray(1);if(e!==i||2!==r&&3!==r){if(e===s&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const t=D(o);if(!(Et<(a=t)&&a<n.ORDER))throw new Error("Point is not on curve");const e=u(t);let i=n.sqrt(e);return!(1&~r)!==((i&It)===It)&&(i=n.neg(i)),{x:t,y:i}}var a}}),f=t=>F(V(t,e.nByteLength));function d(t){return t>r>>It}const p=(t,e,n)=>D(t.slice(e,n));class g{constructor(t,e,n){this.r=t,this.s=e,this.recovery=n,this.assertValidity()}static fromCompact(t){const n=e.nByteLength;return t=M("compactSignature",t,2*n),new g(p(t,0,n),p(t,n,2*n))}static fromDER(t){const{r:e,s:n}=vt.toSig(M("DER",t));return new g(e,n)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:r,s:i,recovery:s}=this,c=b(M("msgHash",t));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?r+e.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&s?"03":"02",d=l.fromHex(h+f(u)),p=a(u),g=o(-c*p),y=o(i*p),m=l.BASE.multiplyAndAddUnsafe(d,g,y);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return $(this.toDERHex())}toDERHex(){return vt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return $(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const y={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=ft(e.n);return function(t,e,n=!1){const r=t.length,i=ht(e),s=ft(e);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=it(n?D(t):z(t),e-X)+X;return n?K(o,i):V(o,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=l.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function m(t){const e=t instanceof Uint8Array,n="string"==typeof t,r=(e||n)&&t.length;return e?r===i||r===s:n?r===2*i||r===2*s:t instanceof l}const w=e.bits2int||function(t){const n=D(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},b=e.bits2int_modN||function(t){return o(w(t))},v=H(e.nBitLength);function E(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(Et<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return V(t,e.nByteLength)}function I(t,r,i=A){if(["recovered","canonical"].some(t=>t in i))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=e;let{lowS:f,prehash:p,extraEntropy:y}=i;null==f&&(f=!0),t=M("msgHash",t),p&&(t=M("prehashed msgHash",s(t)));const m=b(t),v=c(r),I=[E(v),E(m)];if(null!=y){const t=!0===y?u(n.BYTES):y;I.push(M("extraEntropy",t))}const P=_(...I),N=m;return{seed:P,k2sig:function(t){const e=w(t);if(!h(e))return;const n=a(e),r=l.BASE.multiply(e).toAffine(),i=o(r.x);if(i===Et)return;const s=o(n*o(N+i*v));if(s===Et)return;let c=(r.x===i?0:2)|Number(r.y&It),u=s;return f&&d(s)&&(u=function(t){return d(t)?o(-t):t}(s),c^=1),new g(i,u,c)}}}const A={lowS:e.lowS,prehash:!1},P={lowS:e.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return l.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,n=!0){if(m(t))throw new Error("first arg must be private key");if(!m(e))throw new Error("second arg must be public key");return l.fromHex(e).multiply(c(t)).toRawBytes(n)},sign:function(t,n,r=A){const{seed:i,k2sig:s}=I(t,n,r),o=e;return q(o.hash.outputLen,o.nByteLength,o.hmac)(i,s)},verify:function(t,n,r,i=P){const s=t;if(n=M("msgHash",n),r=M("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=i;let h,f;try{if("string"==typeof s||s instanceof Uint8Array)try{h=g.fromDER(s)}catch(t){if(!(t instanceof vt.Err))throw t;h=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:t,s:e}=s;h=new g(t,e)}}f=l.fromHex(r)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&h.hasHighS())return!1;u&&(n=e.hash(n));const{r:d,s:p}=h,y=b(n),m=a(p),w=o(y*m),v=o(d*m),E=l.BASE.multiplyAndAddUnsafe(f,w,v)?.toAffine();return!!E&&o(E.x)===d},ProjectivePoint:l,Signature:g,utils:y}}
|
|
8
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
9
|
+
function xt(t){return{hash:t,hmac:(e,...n)=>pt(t,e,function(...t){const e=new Uint8Array(t.reduce((t,e)=>t+e.length,0));let n=0;return t.forEach(t=>{if(!f(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}(...n)),randomBytes:A}}
|
|
10
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
11
|
+
const Ot=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),St=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Rt=BigInt(1),Tt=BigInt(2),kt=(t,e)=>(t+e/Tt)/e;function Lt(t){const e=Ot,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,h=ot(u,n,e)*u%e,f=ot(h,n,e)*u%e,d=ot(f,Tt,e)*c%e,p=ot(d,i,e)*d%e,g=ot(p,s,e)*p%e,y=ot(g,a,e)*g%e,m=ot(y,l,e)*y%e,w=ot(m,a,e)*g%e,b=ot(w,n,e)*u%e,v=ot(b,o,e)*p%e,E=ot(v,r,e)*c%e,I=ot(E,Tt,e);if(!Bt.eql(Bt.sqr(I),t))throw new Error("Cannot find square root");return I}const Bt=function(t,e,n=!1,r={}){if(t<=J)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=ut(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=lt(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:H(i),ZERO:J,ONE:X,create:e=>it(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return J<=e&&e<t},is0:t=>t===J,isOdd:t=>(t&X)===X,neg:e=>it(-e,t),eql:(t,e)=>t===e,sqr:e=>it(e*e,t),add:(e,n)=>it(e+n,t),sub:(e,n)=>it(e-n,t),mul:(e,n)=>it(e*n,t),pow:(t,e)=>function(t,e,n){if(n<J)throw new Error("Expected power > 0");if(n===J)return t.ONE;if(n===X)return e;let r=t.ONE,i=e;for(;n>J;)n&X&&(r=t.mul(r,i)),i=t.sqr(i),n>>=X;return r}(a,t,e),div:(e,n)=>it(e*at(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>at(e,t),sqrt:r.sqrt||(t=>o(a,t)),invertBatch:t=>function(t,e){const n=new Array(e.length),r=e.reduce((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r)),t.ONE),i=t.inv(r);return e.reduceRight((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r)),i),n}(a,t),cmov:(t,e,n)=>n?e:t,toBytes:t=>n?K(t,s):V(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return n?z(t):D(t)}});return Object.freeze(a)}(Ot,void 0,void 0,{sqrt:Lt}),Ct=function(t,e){const n=e=>Nt({...t,...xt(e)});return Object.freeze({...n(e),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Bt,n:St,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=St,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Rt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=kt(s*t,e),l=kt(-r*t,e);let c=it(t-a*n-l*i,e),u=it(-a*r-l*s,e);const h=c>o,f=u>o;if(h&&(c=e-c),f&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:f,k2:u}}}},k);BigInt(0);Ct.ProjectivePoint;const Ut="6.16.0";function Ft(t,e,n){const r=e.split("|").map(t=>t.trim());for(let n=0;n<r.length;n++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof t===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${n}`,i.value=t,i}async function Gt(t){const e=Object.keys(t);return(await Promise.all(e.map(e=>Promise.resolve(t[e])))).reduce((t,n,r)=>(t[e[r]]=n,t),{})}function $t(t,e,n){for(let r in e){let i=e[r];const s=n?n[r]:null;s&&Ft(i,s,r),Object.defineProperty(t,r,{enumerable:!0,value:i,writable:!1})}}function Dt(t,e){if(null==t)return"null";if(null==e&&(e=new Set),"object"==typeof t){if(e.has(t))return"[Circular]";e.add(t)}if(Array.isArray(t))return"[ "+t.map(t=>Dt(t,e)).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let n="0x";for(let r=0;r<t.length;r++)n+=e[t[r]>>4],n+=e[15&t[r]];return n}if("object"==typeof t&&"function"==typeof t.toJSON)return Dt(t.toJSON(),e);switch(typeof t){case"boolean":case"number":case"symbol":return t.toString();case"bigint":return BigInt(t).toString();case"string":return JSON.stringify(t);case"object":{const n=Object.keys(t);return n.sort(),"{ "+n.map(n=>`${Dt(n,e)}: ${Dt(t[n],e)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function zt(t,e,n){let r,i=t;{const r=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${Dt(n)}`);for(const t in n){if("shortMessage"===t)continue;const e=n[t];r.push(t+"="+Dt(e))}}r.push(`code=${e}`),r.push(`version=${Ut}`),r.length&&(t+=" ("+r.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":r=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(t);break;default:r=new Error(t)}return $t(r,{code:e}),n&&Object.assign(r,n),null==r.shortMessage&&$t(r,{shortMessage:i}),r}function Vt(t,e,n,r){if(!t)throw zt(e,n,r)}function Kt(t,e,n,r){Vt(t,e,"INVALID_ARGUMENT",{argument:n,value:r})}const Mt=["NFD","NFC","NFKD","NFKC"].reduce((t,e)=>{try{if("test"!=="test".normalize(e))throw new Error("bad");if("NFD"===e){const t=String.fromCharCode(233).normalize("NFD");if(t!==String.fromCharCode(101,769))throw new Error("broken")}t.push(e)}catch(t){}return t},[]);function _t(t){Vt(Mt.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}function Ht(t,e,n){if(null==n&&(n=""),t!==e){let t=n,e="new";n&&(t+=".",e+=" "+n),Vt(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function jt(t,e,n){if(t instanceof Uint8Array)return n?new Uint8Array(t):t;if("string"==typeof t&&t.length%2==0&&t.match(/^0x[0-9a-f]*$/i)){const e=new Uint8Array((t.length-2)/2);let n=2;for(let r=0;r<e.length;r++)e[r]=parseInt(t.substring(n,n+2),16),n+=2;return e}Kt(!1,"invalid BytesLike value",e||"value",t)}function Wt(t,e){return jt(t,e,!1)}function qt(t,e){return jt(t,e,!0)}function Zt(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(("number"!=typeof e||t.length===2+2*e)&&(!0!==e||t.length%2==0))}function Yt(t){return Zt(t,!0)||t instanceof Uint8Array}const Jt="0123456789abcdef";function Xt(t){const e=Wt(t);let n="0x";for(let t=0;t<e.length;t++){const r=e[t];n+=Jt[(240&r)>>4]+Jt[15&r]}return n}function Qt(t){return"0x"+t.map(t=>Xt(t).substring(2)).join("")}function te(t){return Zt(t,!0)?(t.length-2)/2:Wt(t).length}function ee(t,e,n){const r=Wt(t);return null!=n&&n>r.length&&Vt(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n}),Xt(r.slice(null==e?0:e,null==n?r.length:n))}function ne(t,e,n){const r=Wt(t);Vt(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),n?i.set(r,e-r.length):i.set(r,0),Xt(i)}function re(t,e){return ne(t,e,!0)}const ie=BigInt(0),se=BigInt(1),oe=9007199254740991;function ae(t,e){switch(typeof t){case"bigint":return t;case"number":return Kt(Number.isInteger(t),"underflow",e||"value",t),Kt(t>=-oe&&t<=oe,"overflow",e||"value",t),BigInt(t);case"string":try{if(""===t)throw new Error("empty string");return"-"===t[0]&&"-"!==t[1]?-BigInt(t.substring(1)):BigInt(t)}catch(n){Kt(!1,`invalid BigNumberish string: ${n.message}`,e||"value",t)}}Kt(!1,"invalid BigNumberish value",e||"value",t)}function le(t,e){const n=ae(t,e);return Vt(n>=ie,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),n}const ce="0123456789abcdef";function ue(t){if(t instanceof Uint8Array){let e="0x0";for(const n of t)e+=ce[n>>4],e+=ce[15&n];return BigInt(e)}return ae(t)}function he(t,e){switch(typeof t){case"bigint":return Kt(t>=-oe&&t<=oe,"overflow",e||"value",t),Number(t);case"number":return Kt(Number.isInteger(t),"underflow",e||"value",t),Kt(t>=-oe&&t<=oe,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return he(BigInt(t),e)}catch(n){Kt(!1,`invalid numeric string: ${n.message}`,e||"value",t)}}Kt(!1,"invalid numeric value",e||"value",t)}function fe(t,e){const n=le(t,"value");let r=n.toString(16);if(null==e)r.length%2&&(r="0"+r);else{const i=he(e,"width");if(0===i&&n===ie)return"0x";for(Vt(2*i>=r.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});r.length<2*i;)r="0"+r}return"0x"+r}function de(t,e){const n=le(t,"value");if(n===ie){const t=null!=e?he(e,"width"):0;return new Uint8Array(t)}let r=n.toString(16);if(r.length%2&&(r="0"+r),null!=e){const n=he(e,"width");for(;r.length<2*n;)r="00"+r;Vt(2*n===r.length,`value exceeds width (${n} bytes)`,"NUMERIC_FAULT",{operation:"toBeArray",fault:"overflow",value:t})}const i=new Uint8Array(r.length/2);for(let t=0;t<i.length;t++){const e=2*t;i[t]=parseInt(r.substring(e,e+2),16)}return i}const pe="0x0000000000000000000000000000000000000000000000000000000000000000",ge=BigInt(0),ye=BigInt(1),me=BigInt(2),we=BigInt(27),be=BigInt(28),ve=BigInt(35),Ee=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ie=Ee/me,Ae=Symbol.for("nodejs.util.inspect.custom"),Pe={};function Ne(t){return re(de(t),32)}class xe{#t;#e;#n;#r;get r(){return this.#t}set r(t){Kt(32===te(t),"invalid r","value",t),this.#t=Xt(t)}get s(){return Kt(parseInt(this.#e.substring(0,3))<8,"non-canonical s; use ._s","s",this.#e),this.#e}set s(t){Kt(32===te(t),"invalid s","value",t),this.#e=Xt(t)}get _s(){return this.#e}isValid(){return BigInt(this.#e)<=Ie}get v(){return this.#n}set v(t){const e=he(t,"value");Kt(27===e||28===e,"invalid v","v",t),this.#n=e}get networkV(){return this.#r}get legacyChainId(){const t=this.networkV;return null==t?null:xe.getChainId(t)}get yParity(){return 27===this.v?0:1}get yParityAndS(){const t=Wt(this.s);return this.yParity&&(t[0]|=128),Xt(t)}get compactSerialized(){return Qt([this.r,this.yParityAndS])}get serialized(){return Qt([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor(t,e,n,r){Ht(t,Pe,"Signature"),this.#t=e,this.#e=n,this.#n=r,this.#r=null}getCanonical(){if(this.isValid())return this;const t=Ee-BigInt(this._s),e=55-this.v,n=new xe(Pe,this.r,Ne(t),e);return this.networkV&&(n.#r=this.networkV),n}clone(){const t=new xe(Pe,this.r,this._s,this.v);return this.networkV&&(t.#r=this.networkV),t}toJSON(){const t=this.networkV;return{_type:"signature",networkV:null!=t?t.toString():null,r:this.r,s:this._s,v:this.v}}[Ae](){return this.toString()}toString(){return this.isValid()?`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v} }`:`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v}, valid: false }`}static getChainId(t){const e=ae(t,"v");return e==we||e==be?ge:(Kt(e>=ve,"invalid EIP-155 v","v",t),(e-ve)/me)}static getChainIdV(t,e){return ae(t)*me+BigInt(35+e-27)}static getNormalizedV(t){const e=ae(t);return e===ge||e===we?27:e===ye||e===be?28:(Kt(e>=ve,"invalid v","v",t),e&ye?27:28)}static from(t){function e(e,n){Kt(e,n,"signature",t)}if(null==t)return new xe(Pe,pe,pe,27);if("string"==typeof t){const n=Wt(t,"signature");if(64===n.length){const t=Xt(n.slice(0,32)),e=n.slice(32,64),r=128&e[0]?28:27;return e[0]&=127,new xe(Pe,t,Xt(e),r)}if(65===n.length){const t=Xt(n.slice(0,32)),e=Xt(n.slice(32,64)),r=xe.getNormalizedV(n[64]);return new xe(Pe,t,e,r)}e(!1,"invalid raw signature length")}if(t instanceof xe)return t.clone();const n=t.r;e(null!=n,"missing r");const r=Ne(n),i=function(t,n){if(null!=t)return Ne(t);if(null!=n){e(Zt(n,32),"invalid yParityAndS");const t=Wt(n);return t[0]&=127,Xt(t)}e(!1,"missing s")}(t.s,t.yParityAndS),{networkV:s,v:o}=function(t,n,r){if(null!=t){const e=ae(t);return{networkV:e>=ve?e:void 0,v:xe.getNormalizedV(e)}}if(null!=n)return e(Zt(n,32),"invalid yParityAndS"),{v:128&Wt(n)[0]?28:27};if(null!=r){switch(he(r,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}e(!1,"invalid yParity")}e(!1,"missing v")}(t.v,t.yParityAndS,t.yParity),a=new xe(Pe,r,i,o);return s&&(a.#r=s),e(null==t.yParity||he(t.yParity,"sig.yParity")===a.yParity,"yParity mismatch"),e(null==t.yParityAndS||t.yParityAndS===a.yParityAndS,"yParityAndS mismatch"),a}}class Oe{#i;constructor(t){Kt(32===te(t),"invalid private key","privateKey","[REDACTED]"),this.#i=Xt(t)}get privateKey(){return this.#i}get publicKey(){return Oe.computePublicKey(this.#i)}get compressedPublicKey(){return Oe.computePublicKey(this.#i,!0)}sign(t){Kt(32===te(t),"invalid digest length","digest",t);const e=Ct.sign(qt(t),qt(this.#i),{lowS:!0});return xe.from({r:fe(e.r,32),s:fe(e.s,32),v:e.recovery?28:27})}computeSharedSecret(t){const e=Oe.computePublicKey(t);return Xt(Ct.getSharedSecret(qt(this.#i),Wt(e),!1))}static computePublicKey(t,e){let n=Wt(t,"key");if(32===n.length){return Xt(Ct.getPublicKey(n,!!e))}if(64===n.length){const t=new Uint8Array(65);t[0]=4,t.set(n,1),n=t}return Xt(Ct.ProjectivePoint.fromHex(n).toRawBytes(e))}static recoverPublicKey(t,e){Kt(32===te(t),"invalid digest length","digest",t);const n=xe.from(e);let r=Ct.Signature.fromCompact(qt(Qt([n.r,n.s])));r=r.addRecoveryBit(n.yParity);const i=r.recoverPublicKey(qt(t));return Kt(null!=i,"invalid signature for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(t,e,n){const r=Ct.ProjectivePoint.fromHex(Oe.computePublicKey(t).substring(2)),i=Ct.ProjectivePoint.fromHex(Oe.computePublicKey(e).substring(2));return"0x"+r.add(i).toHex(!!n)}}const Se=BigInt(2**32-1),Re=BigInt(32);function Te(t,e=!1){return e?{h:Number(t&Se),l:Number(t>>Re&Se)}:{h:0|Number(t>>Re&Se),l:0|Number(t&Se)}}function ke(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=Te(t[i],e);[n[i],r[i]]=[s,o]}return[n,r]}const Le=(t,e,n)=>t<<n|e>>>32-n,Be=(t,e,n)=>e<<n|t>>>32-n,Ce=(t,e,n)=>e<<n-32|t>>>64-n,Ue=(t,e,n)=>t<<n-32|e>>>64-n;const[Fe,Ge,$e]=[[],[],[]],De=BigInt(0),ze=BigInt(1),Ve=BigInt(2),Ke=BigInt(7),Me=BigInt(256),_e=BigInt(113);for(let t=0,e=ze,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Fe.push(2*(5*r+n)),Ge.push((t+1)*(t+2)/2%64);let i=De;for(let t=0;t<7;t++)e=(e<<ze^(e>>Ke)*_e)%Me,e&Ve&&(i^=ze<<(ze<<BigInt(t))-ze);$e.push(i)}const[He,je]=ke($e,!0),We=(t,e,n)=>n>32?Ce(t,e,n):Le(t,e,n),qe=(t,e,n)=>n>32?Ue(t,e,n):Be(t,e,n);class Ze extends b{constructor(t,e,n,r=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,i(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=d(this.state)}keccak(){!function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const r=(e+8)%10,i=(e+2)%10,s=n[i],o=n[i+1],a=We(s,o,1)^n[r],l=qe(s,o,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=a,t[e+n+1]^=l}let e=t[2],i=t[3];for(let n=0;n<24;n++){const r=Ge[n],s=We(e,i,r),o=qe(e,i,r),a=Fe[n];e=t[a],i=t[a+1],t[a]=s,t[a+1]=o}for(let e=0;e<50;e+=10){for(let r=0;r<10;r++)n[r]=t[e+r];for(let r=0;r<10;r++)t[e+r]^=~n[(r+2)%10]&n[(r+4)%10]}t[0]^=He[r],t[1]^=je[r]}n.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){a(this);const{blockLen:e,state:n}=this,r=(t=w(t)).length;for(let i=0;i<r;){const s=Math.min(e-this.pos,r-i);for(let e=0;e<s;e++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:r}=this;t[n]^=e,128&e&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){a(this,!1),s(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,i=t.length;r<i;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,i-r);t.set(e.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return i(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(l(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:i,enableXOF:s}=this;return t||(t=new Ze(e,n,r,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=r,t.enableXOF=s,t.destroyed=this.destroyed,t}}const Ye=(t,e,n)=>I(()=>new Ze(e,t,n)),Je=Ye(1,136,32);let Xe=!1;const Qe=function(t){return Je(t)};let tn=Qe;function en(t){const e=Wt(t,"data");return Xt(tn(e))}en._=Qe,en.lock=function(){Xe=!0},en.register=function(t){if(Xe)throw new TypeError("keccak256 is locked");tn=t},Object.freeze(en);const nn=BigInt(0),rn=BigInt(36);function sn(t){const e=(t=t.toLowerCase()).substring(2).split(""),n=new Uint8Array(40);for(let t=0;t<40;t++)n[t]=e[t].charCodeAt(0);const r=Wt(en(n));for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&r[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const on={};for(let t=0;t<10;t++)on[String(t)]=String(t);for(let t=0;t<26;t++)on[String.fromCharCode(65+t)]=String(10+t);function an(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map(t=>on[t]).join("");for(;e.length>=15;){let t=e.substring(0,15);e=parseInt(t,10)%97+e.substring(t.length)}let n=String(98-parseInt(e,10)%97);for(;n.length<2;)n="0"+n;return n}const ln=function(){const t={};for(let e=0;e<36;e++){t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e)}return t}();function cn(t){if(Kt("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=sn(t);return Kt(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){Kt(t.substring(2,4)===an(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=nn;for(let n=0;n<t.length;n++)e=e*rn+ln[t[n]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return sn("0x"+e)}Kt(!1,"invalid address","address",t)}async function un(t,e){const n=await e;return null!=n&&"0x0000000000000000000000000000000000000000"!==n||(Vt("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),Kt(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),cn(n)}function hn(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?cn(t):(Vt(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),un(t,e.resolveName(t))):(n=t)&&"function"==typeof n.getAddress?un(t,t.getAddress()):t&&"function"==typeof t.then?un(t,t):void Kt(!1,"unsupported addressable value","target",t);var n}function fn(t,e,n,r,i){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let r=e+1;r<n.length&&n[r]>>6==2;r++)t++;return t}return"OVERRUN"===t?n.length-e-1:0}Object.freeze({error:function(t,e,n,r,i){Kt(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",n)},ignore:fn,replace:function(t,e,n,r,i){return"OVERLONG"===t?(Kt("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),r.push(i),0):(r.push(65533),fn(t,e,n))}});function dn(t,e){Kt("string"==typeof t,"invalid string value","str",t),null!=e&&(_t(e),t=t.normalize(e));let n=[];for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);if(r<128)n.push(r);else if(r<2048)n.push(r>>6|192),n.push(63&r|128);else if(55296==(64512&r)){e++;const i=t.charCodeAt(e);Kt(e<t.length&&56320==(64512&i),"invalid surrogate pair","str",t);const s=65536+((1023&r)<<10)+(1023&i);n.push(s>>18|240),n.push(s>>12&63|128),n.push(s>>6&63|128),n.push(63&s|128)}else n.push(r>>12|224),n.push(r>>6&63|128),n.push(63&r|128)}return new Uint8Array(n)}function pn(t){return"string"==typeof t&&(t=dn(t)),en(Qt([dn("Ethereum Signed Message:\n"),dn(String(t.length)),t]))}function gn(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function yn(t){if(Array.isArray(t)){let e=[];if(t.forEach(function(t){e=e.concat(yn(t))}),e.length<=55)return e.unshift(192+e.length),e;const n=gn(e.length);return n.unshift(247+n.length),n.concat(e)}const e=Array.prototype.slice.call(Wt(t,"object"));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const n=gn(e.length);return n.unshift(183+n.length),n.concat(e)}const mn="0123456789abcdef";function wn(t){let e="0x";for(const n of yn(t))e+=mn[n>>4],e+=mn[15&n];return e}function bn(t){return Kt("string"==typeof t.address,"invalid address for hashAuthorization","auth.address",t),en(Qt(["0x05",wn([null!=t.chainId?de(t.chainId):"0x",cn(t.address),null!=t.nonce?de(t.nonce):"0x"])]))}function vn(t){return en(dn(t))}const En=new Uint8Array(32);En.fill(0);const In=BigInt(-1),An=BigInt(0),Pn=BigInt(1),Nn=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const xn=fe(Pn,32),On=fe(An,32),Sn={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Rn=["name","version","chainId","verifyingContract","salt"];function Tn(t){return function(e){return Kt("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const kn={name:Tn("name"),version:Tn("version"),chainId:function(t){const e=ae(t,"domain.chainId");return Kt(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):function(t){let e=Xt(Yt(t)?t:de(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}(e)},verifyingContract:function(t){try{return cn(t).toLowerCase()}catch(t){}Kt(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=Wt(t,"domain.salt");return Kt(32===e.length,'invalid domain value "salt"',"domain.salt",t),Xt(e)}};function Ln(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const n=""===e[1],r=parseInt(e[2]);Kt(r%8==0&&0!==r&&r<=256&&e[2]===String(r),"invalid numeric width","type",t);const i=function(t,e){const n=le(t,"value"),r=BigInt(he(e,"bits"));return n&(se<<r)-se}(Nn,n?r-1:r),s=n?(i+Pn)*In:An;return function(e){const r=ae(e,"value");return Kt(r>=s&&r<=i,`value out-of-bounds for ${t}`,"value",r),fe(n?function(t,e){let n=ae(t,"value");const r=BigInt(he(e,"width")),i=se<<r-se;if(n<ie)return n=-n,Vt(n<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),(~n&(se<<r)-se)+se;return Vt(n<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),n}(r,256):r,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const n=parseInt(e[1]);return Kt(0!==n&&n<=32&&e[1]===String(n),"invalid bytes width","type",t),function(e){return Kt(Wt(e).length===n,`invalid length for ${t}`,"value",e),function(t){const e=Wt(t),n=e.length%32;return n?Qt([e,En.slice(n)]):Xt(e)}(e)}}}switch(t){case"address":return function(t){return re(cn(t),32)};case"bool":return function(t){return t?xn:On};case"bytes":return function(t){return en(t)};case"string":return function(t){return vn(t)}}return null}function Bn(t,e){return`${t}(${e.map(({name:t,type:e})=>e+" "+t).join(",")})`}function Cn(t){const e=t.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:t}}class Un{primaryType;#s;get types(){return JSON.parse(this.#s)}#o;#a;constructor(t){this.#o=new Map,this.#a=new Map;const e=new Map,n=new Map,r=new Map,i={};Object.keys(t).forEach(s=>{i[s]=t[s].map(({name:e,type:n})=>{let{base:r,index:i}=Cn(n);return"int"!==r||t.int||(r="int256"),"uint"!==r||t.uint||(r="uint256"),{name:e,type:r+(i||"")}}),e.set(s,new Set),n.set(s,[]),r.set(s,new Set)}),this.#s=JSON.stringify(i);for(const r in i){const s=new Set;for(const o of i[r]){Kt(!s.has(o.name),`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(r)}`,"types",t),s.add(o.name);const i=Cn(o.type).base;Kt(i!==r,`circular type reference to ${JSON.stringify(i)}`,"types",t);Ln(i)||(Kt(n.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),n.get(i).push(r),e.get(r).add(i))}}const s=Array.from(n.keys()).filter(t=>0===n.get(t).length);Kt(0!==s.length,"missing primary type","types",t),Kt(1===s.length,`ambiguous primary types or unused types: ${s.map(t=>JSON.stringify(t)).join(", ")}`,"types",t),$t(this,{primaryType:s[0]}),function i(s,o){Kt(!o.has(s),`circular type reference to ${JSON.stringify(s)}`,"types",t),o.add(s);for(const t of e.get(s))if(n.has(t)){i(t,o);for(const e of o)r.get(e).add(t)}o.delete(s)}(this.primaryType,new Set);for(const[t,e]of r){const n=Array.from(e);n.sort(),this.#o.set(t,Bn(t,i[t])+n.map(t=>Bn(t,i[t])).join(""))}}getEncoder(t){let e=this.#a.get(t);return e||(e=this.#l(t),this.#a.set(t,e)),e}#l(t){{const e=Ln(t);if(e)return e}const e=Cn(t).array;if(e){const t=e.prefix,n=this.getEncoder(t);return r=>{Kt(-1===e.count||e.count===r.length,`array length mismatch; expected length ${e.count}`,"value",r);let i=r.map(n);return this.#o.has(t)&&(i=i.map(en)),en(Qt(i))}}const n=this.types[t];if(n){const e=vn(this.#o.get(t));return t=>{const r=n.map(({name:e,type:n})=>{const r=this.getEncoder(n)(t[e]);return this.#o.has(n)?en(r):r});return r.unshift(e),Qt(r)}}Kt(!1,`unknown type: ${t}`,"type",t)}encodeType(t){const e=this.#o.get(t);return Kt(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return en(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,n){if(Ln(t))return n(t,e);const r=Cn(t).array;if(r)return Kt(-1===r.count||r.count===e.length,`array length mismatch; expected length ${r.count}`,"value",e),e.map(t=>this._visit(r.prefix,t,n));const i=this.types[t];if(i)return i.reduce((t,{name:r,type:i})=>(t[r]=this._visit(i,e[r],n),t),{});Kt(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new Un(t)}static getPrimaryType(t){return Un.from(t).primaryType}static hashStruct(t,e,n){return Un.from(e).hashStruct(t,n)}static hashDomain(t){const e=[];for(const n in t){if(null==t[n])continue;const r=Sn[n];Kt(r,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",t),e.push({name:n,type:r})}return e.sort((t,e)=>Rn.indexOf(t.name)-Rn.indexOf(e.name)),Un.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,n){return Qt(["0x1901",Un.hashDomain(t),Un.from(e).hash(n)])}static hash(t,e,n){return en(Un.encode(t,e,n))}static async resolveNames(t,e,n,r){t=Object.assign({},t);for(const e in t)null==t[e]&&delete t[e];const i={};t.verifyingContract&&!Zt(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const s=Un.from(e);s.visit(n,(t,e)=>("address"!==t||Zt(e,20)||(i[e]="0x"),e));for(const t in i)i[t]=await r(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),{domain:t,value:n=s.visit(n,(t,e)=>"address"===t&&i[e]?i[e]:e)}}static getPayload(t,e,n){Un.hashDomain(t);const r={},i=[];Rn.forEach(e=>{const n=t[e];null!=n&&(r[e]=kn[e](n),i.push({name:e,type:Sn[e]}))});const s=Un.from(e);e=s.types;const o=Object.assign({},e);return Kt(null==o.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",e),o.EIP712Domain=i,s.encode(n),{types:o,domain:r,primaryType:s.primaryType,message:s.visit(n,(t,e)=>{if(t.match(/^bytes(\d*)/))return Xt(Wt(e));if(t.match(/^u?int/))return ae(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return Kt("string"==typeof e,"invalid string","value",e),e}Kt(!1,"unsupported type","type",t)})}}}const Fn="0x0000000000000000000000000000000000000000";var Gn=n(76982);const $n=function(t){return(0,Gn.createHash)("sha256").update(t).digest()},Dn=function(t){return(0,Gn.createHash)("sha512").update(t).digest()};let zn=$n,Vn=Dn,Kn=!1,Mn=!1;function _n(t){const e=Wt(t,"data");return Xt(zn(e))}function Hn(t){const e=Wt(t,"data");return Xt(Vn(e))}function jn(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function Wn(t,e,n){let r=0;for(let i=0;i<n;i++)r=256*r+t[e+i];return r}function qn(t,e,n,r){const i=[];for(;n<e+1+r;){const s=Zn(t,n);i.push(s.result),Vt((n+=s.consumed)<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:t,length:r,offset:e})}return{consumed:1+r,result:i}}function Zn(t,e){Vt(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const n=e=>{Vt(e<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:e})};if(t[e]>=248){const r=t[e]-247;n(e+1+r);const i=Wn(t,e+1,r);return n(e+1+r+i),qn(t,e,e+1+r,r+i)}if(t[e]>=192){const r=t[e]-192;return n(e+1+r),qn(t,e,e+1,r)}if(t[e]>=184){const r=t[e]-183;n(e+1+r);const i=Wn(t,e+1,r);n(e+1+r+i);return{consumed:1+r+i,result:Xt(t.slice(e+1+r,e+1+r+i))}}if(t[e]>=128){const r=t[e]-128;n(e+1+r);return{consumed:1+r,result:Xt(t.slice(e+1,e+1+r))}}return{consumed:1,result:jn(t[e])}}function Yn(t){const e=Wt(t,"data"),n=Zn(e,0);return Kt(n.consumed===e.length,"unexpected junk after rlp payload","data",t),n.result}function Jn(t,e){return{address:cn(t),storageKeys:e.map((t,e)=>(Kt(Zt(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase()))}}function Xn(t){if(Array.isArray(t))return t.map((e,n)=>Array.isArray(e)?(Kt(2===e.length,"invalid slot set",`value[${n}]`,e),Jn(e[0],e[1])):(Kt(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),Jn(e.address,e.storageKeys)));Kt(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map(e=>{const n=t[e].reduce((t,e)=>(t[e]=!0,t),{});return Jn(e,Object.keys(n).sort())});return e.sort((t,e)=>t.address.localeCompare(e.address)),e}function Qn(t){let e;return e="string"==typeof t?Oe.computePublicKey(t,!1):t.publicKey,cn(en("0x"+e.substring(4)).substring(26))}_n._=$n,_n.lock=function(){Kn=!0},_n.register=function(t){if(Kn)throw new Error("sha256 is locked");zn=t},Object.freeze(_n),Hn._=Dn,Hn.lock=function(){Mn=!0},Hn.register=function(t){if(Mn)throw new Error("sha512 is locked");Vn=t},Object.freeze(_n);const tr=BigInt(0),er=BigInt(2),nr=BigInt(27),rr=BigInt(28),ir=BigInt(35),sr=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),or=Symbol.for("nodejs.util.inspect.custom"),ar=131072,lr=128;function cr(t,e){let n=t.toString(16);for(;n.length<2;)n="0"+n;return n+=_n(e).substring(4),"0x"+n}function ur(t){return"0x"===t?null:cn(t)}function hr(t,e){try{return Xn(t)}catch(n){Kt(!1,n.message,e,t)}}function fr(t,e){try{if(!Array.isArray(t))throw new Error("authorizationList: invalid array");const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!Array.isArray(r))throw new Error(`authorization[${n}]: invalid array`);if(6!==r.length)throw new Error(`authorization[${n}]: wrong length`);if(!r[1])throw new Error(`authorization[${n}]: null address`);e.push({address:ur(r[1]),nonce:pr(r[2],"nonce"),chainId:pr(r[0],"chainId"),signature:xe.from({yParity:dr(r[3],"yParity"),r:re(r[4],32),s:re(r[5],32)})})}return e}catch(n){Kt(!1,n.message,e,t)}}function dr(t,e){return"0x"===t?0:he(t,e)}function pr(t,e){if("0x"===t)return tr;const n=ae(t,e);return Kt(n<=sr,"value exceeds uint size",e,n),n}function gr(t,e){const n=ae(t,"value"),r=de(n);return Kt(r.length<=32,"value too large",`tx.${e}`,n),r}function yr(t){return Xn(t).map(t=>[t.address,t.storageKeys])}function mr(t,e){Kt(Array.isArray(t),`invalid ${e}`,"value",t);for(let e=0;e<t.length;e++)Kt(Zt(t[e],32),"invalid ${ param } hash",`value[${e}]`,t[e]);return t}function wr(t,e){let n;try{if(n=dr(e[0],"yParity"),0!==n&&1!==n)throw new Error("bad yParity")}catch(t){Kt(!1,"invalid yParity","yParity",e[0])}const r=re(e[1],32),i=re(e[2],32),s=xe.from({r:r,s:i,yParity:n});t.signature=s}class br{#c;#u;#h;#f;#d;#p;#g;#y;#m;#w;#b;#v;#E;#I;#A;#P;#N;#x;get type(){return this.#c}set type(t){switch(t){case null:this.#c=null;break;case 0:case"legacy":this.#c=0;break;case 1:case"berlin":case"eip-2930":this.#c=1;break;case 2:case"london":case"eip-1559":this.#c=2;break;case 3:case"cancun":case"eip-4844":this.#c=3;break;case 4:case"pectra":case"eip-7702":this.#c=4;break;default:Kt(!1,"unsupported transaction type","type",t)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844";case 4:return"eip-7702"}return null}get to(){const t=this.#u;return null==t&&3===this.type?Fn:t}set to(t){this.#u=null==t?null:cn(t)}get nonce(){return this.#f}set nonce(t){this.#f=he(t,"value")}get gasLimit(){return this.#d}set gasLimit(t){this.#d=ae(t)}get gasPrice(){const t=this.#p;return null!=t||0!==this.type&&1!==this.type?t:tr}set gasPrice(t){this.#p=null==t?null:ae(t,"gasPrice")}get maxPriorityFeePerGas(){const t=this.#g;return null==t?2===this.type||3===this.type?tr:null:t}set maxPriorityFeePerGas(t){this.#g=null==t?null:ae(t,"maxPriorityFeePerGas")}get maxFeePerGas(){const t=this.#y;return null==t?2===this.type||3===this.type?tr:null:t}set maxFeePerGas(t){this.#y=null==t?null:ae(t,"maxFeePerGas")}get data(){return this.#h}set data(t){this.#h=Xt(t)}get value(){return this.#m}set value(t){this.#m=ae(t,"value")}get chainId(){return this.#w}set chainId(t){this.#w=ae(t)}get signature(){return this.#b||null}set signature(t){this.#b=null==t?null:xe.from(t)}isValid(){const t=this.signature;if(t&&!t.isValid())return!1;const e=this.authorizationList;if(e)for(const t of e)if(!t.signature.isValid())return!1;return!0}get accessList(){const t=this.#v||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){this.#v=null==t?null:Xn(t)}get authorizationList(){const t=this.#N||null;return null==t&&4===this.type?[]:t}set authorizationList(t){this.#N=null==t?null:t.map(t=>{return{address:cn((e=t).address),nonce:ae(null!=e.nonce?e.nonce:0),chainId:ae(null!=e.chainId?e.chainId:0),signature:xe.from(e.signature)};var e})}get maxFeePerBlobGas(){const t=this.#E;return null==t&&3===this.type?tr:t}set maxFeePerBlobGas(t){this.#E=null==t?null:ae(t,"maxFeePerBlobGas")}get blobVersionedHashes(){let t=this.#I;return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){Kt(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)Kt(Zt(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}this.#I=t}get blobs(){return null==this.#P?null:this.#P.map(t=>Object.assign({},t))}set blobs(t){if(null==t)return void(this.#P=null);const e=[],n=[];for(let r=0;r<t.length;r++){const i=t[r];if(Yt(i)){Vt(this.#A,"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=Wt(i);if(Kt(t.length<=ar,"blob is too large",`blobs[${r}]`,i),t.length!==ar){const e=new Uint8Array(ar);e.set(t),t=e}const s=this.#A.blobToKzgCommitment(t),o=Xt(this.#A.computeBlobKzgProof(t,s));e.push({data:Xt(t),commitment:Xt(s),proof:o}),n.push(cr(1,s))}else{const t=Xt(i.data),r=Xt(i.commitment),s=Xt(i.proof);e.push({data:t,commitment:r,proof:s}),n.push(cr(1,r))}}this.#P=e,this.#I=n}get kzg(){return this.#A}set kzg(t){this.#A=null==t?null:function(t){return{blobToKzgCommitment:e=>{if("computeBlobProof"in t){if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return Wt(t.blobToKzgCommitment(Xt(e)))}else if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return Wt(t.blobToKzgCommitment(e));if("blobToKZGCommitment"in t&&"function"==typeof t.blobToKZGCommitment)return Wt(t.blobToKZGCommitment(Xt(e)));Kt(!1,"unsupported KZG library","kzg",t)},computeBlobKzgProof:(e,n)=>"computeBlobProof"in t&&"function"==typeof t.computeBlobProof?Wt(t.computeBlobProof(Xt(e),Xt(n))):"computeBlobKzgProof"in t&&"function"==typeof t.computeBlobKzgProof?t.computeBlobKzgProof(e,n):"computeBlobKZGProof"in t&&"function"==typeof t.computeBlobKZGProof?Wt(t.computeBlobKZGProof(Xt(e),Xt(n))):void Kt(!1,"unsupported KZG library","kzg",t)}}(t)}get blobWrapperVersion(){return this.#x}set blobWrapperVersion(t){this.#x=t}constructor(){this.#c=null,this.#u=null,this.#f=0,this.#d=tr,this.#p=null,this.#g=null,this.#y=null,this.#h="0x",this.#m=tr,this.#w=tr,this.#b=null,this.#v=null,this.#E=null,this.#I=null,this.#A=null,this.#P=null,this.#N=null,this.#x=null}get hash(){return null==this.signature?null:en(this.#O(!0,!1))}get unsignedHash(){return en(this.unsignedSerialized)}get from(){return null==this.signature?null:(t=this.unsignedHash,e=this.signature.getCanonical(),Qn(Oe.recoverPublicKey(t,e)));var t,e}get fromPublicKey(){return null==this.signature?null:Oe.recoverPublicKey(this.unsignedHash,this.signature.getCanonical())}isSigned(){return null!=this.signature}#O(t,e){Vt(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const n=[gr(t.nonce,"nonce"),gr(t.gasPrice||0,"gasPrice"),gr(t.gasLimit,"gasLimit"),t.to||"0x",gr(t.value,"value"),t.data];let r=tr;if(t.chainId!=tr)r=ae(t.chainId,"tx.chainId"),Kt(!e||null==e.networkV||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(r=e)}if(!e)return r!==tr&&(n.push(de(r)),n.push("0x"),n.push("0x")),wn(n);let i=BigInt(27+e.yParity);return r!==tr?i=xe.getChainIdV(r,e.v):BigInt(e.v)!==i&&Kt(!1,"tx.chainId/sig.v mismatch","sig",e),n.push(de(i)),n.push(de(e.r)),n.push(de(e._s)),wn(n)}(this,n);case 1:return function(t,e){const n=[gr(t.chainId,"chainId"),gr(t.nonce,"nonce"),gr(t.gasPrice||0,"gasPrice"),gr(t.gasLimit,"gasLimit"),t.to||"0x",gr(t.value,"value"),t.data,yr(t.accessList||[])];return e&&(n.push(gr(e.yParity,"recoveryParam")),n.push(de(e.r)),n.push(de(e.s))),Qt(["0x01",wn(n)])}(this,n);case 2:return function(t,e){const n=[gr(t.chainId,"chainId"),gr(t.nonce,"nonce"),gr(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gr(t.maxFeePerGas||0,"maxFeePerGas"),gr(t.gasLimit,"gasLimit"),t.to||"0x",gr(t.value,"value"),t.data,yr(t.accessList||[])];return e&&(n.push(gr(e.yParity,"yParity")),n.push(de(e.r)),n.push(de(e.s))),Qt(["0x02",wn(n)])}(this,n);case 3:return function(t,e,n){const r=[gr(t.chainId,"chainId"),gr(t.nonce,"nonce"),gr(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gr(t.maxFeePerGas||0,"maxFeePerGas"),gr(t.gasLimit,"gasLimit"),t.to||Fn,gr(t.value,"value"),t.data,yr(t.accessList||[]),gr(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),mr(t.blobVersionedHashes||[],"blobVersionedHashes")];if(e&&(r.push(gr(e.yParity,"yParity")),r.push(de(e.r)),r.push(de(e.s)),n)){if(null!=t.blobWrapperVersion){const e=de(t.blobWrapperVersion),i=[];for(const{proof:t}of n){const e=Wt(t),n=e.length/lr;for(let t=0;t<e.length;t+=n)i.push(e.subarray(t,t+n))}return Qt(["0x03",wn([r,e,n.map(t=>t.data),n.map(t=>t.commitment),i])])}return Qt(["0x03",wn([r,n.map(t=>t.data),n.map(t=>t.commitment),n.map(t=>t.proof)])])}return Qt(["0x03",wn(r)])}(this,n,e?this.blobs:null);case 4:return function(t,e){const n=[gr(t.chainId,"chainId"),gr(t.nonce,"nonce"),gr(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gr(t.maxFeePerGas||0,"maxFeePerGas"),gr(t.gasLimit,"gasLimit"),t.to||"0x",gr(t.value,"value"),t.data,yr(t.accessList||[]),(r=t.authorizationList||[],r.map(t=>[gr(t.chainId,"chainId"),t.address,gr(t.nonce,"nonce"),gr(t.signature.yParity,"yParity"),de(t.signature.r),de(t.signature._s)]))];var r;return e&&(n.push(gr(e.yParity,"yParity")),n.push(de(e.r)),n.push(de(e.s))),Qt(["0x04",wn(n)])}(this,n)}Vt(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})}get serialized(){return this.#O(!0,!0)}get unsignedSerialized(){return this.#O(!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=null!=this.gasPrice,e=null!=this.maxFeePerGas||null!=this.maxPriorityFeePerGas,n=null!=this.accessList,r=null!=this.#E||this.#I;null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&Vt(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),Vt(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),Vt(0!==this.type||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return null!=this.type?i.push(this.type):this.authorizationList&&this.authorizationList.length?i.push(4):e?i.push(2):t?(i.push(1),n||i.push(0)):n?(i.push(1),i.push(2)):(r&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}clone(){return br.from(this)}toJSON(){const t=t=>null==t?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}[or](){return this.toString()}toString(){const t=[],e=e=>{let n=this[e];"string"==typeof n&&(n=JSON.stringify(n)),t.push(`${e}: ${n}`)};this.type&&e("type"),e("to"),e("data"),e("nonce"),e("gasLimit"),e("value"),null!=this.chainId&&e("chainId"),this.signature&&(e("from"),t.push(`signature: ${this.signature.toString()}`));const n=this.authorizationList;if(n){const e=[];for(const t of n){const n=[];n.push(`address: ${JSON.stringify(t.address)}`),null!=t.nonce&&n.push(`nonce: ${t.nonce}`),null!=t.chainId&&n.push(`chainId: ${t.chainId}`),t.signature&&n.push(`signature: ${t.signature.toString()}`),e.push(`Authorization { ${n.join(", ")} }`)}t.push(`authorizations: [ ${e.join(", ")} ]`)}return`Transaction { ${t.join(", ")} }`}static from(t){if(null==t)return new br;if("string"==typeof t){const e=Wt(t);if(e[0]>=127)return br.from(function(t){const e=Yn(t);Kt(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const n={type:0,nonce:dr(e[0],"nonce"),gasPrice:pr(e[1],"gasPrice"),gasLimit:pr(e[2],"gasLimit"),to:ur(e[3]),value:pr(e[4],"value"),data:Xt(e[5]),chainId:tr};if(6===e.length)return n;const r=pr(e[6],"v"),i=pr(e[7],"r"),s=pr(e[8],"s");if(i===tr&&s===tr)n.chainId=r;else{let t=(r-ir)/er;t<tr&&(t=tr),n.chainId=t,Kt(t!==tr||r===nr||r===rr,"non-canonical legacy v","v",e[6]),n.signature=xe.from({r:re(e[7],32),s:re(e[8],32),v:r})}return n}(e));switch(e[0]){case 1:return br.from(function(t){const e=Yn(Wt(t).slice(1));Kt(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",Xt(t));const n={type:1,chainId:pr(e[0],"chainId"),nonce:dr(e[1],"nonce"),gasPrice:pr(e[2],"gasPrice"),gasLimit:pr(e[3],"gasLimit"),to:ur(e[4]),value:pr(e[5],"value"),data:Xt(e[6]),accessList:hr(e[7],"accessList")};return 8===e.length||wr(n,e.slice(8)),n}(e));case 2:return br.from(function(t){const e=Yn(Wt(t).slice(1));Kt(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",Xt(t));const n={type:2,chainId:pr(e[0],"chainId"),nonce:dr(e[1],"nonce"),maxPriorityFeePerGas:pr(e[2],"maxPriorityFeePerGas"),maxFeePerGas:pr(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:pr(e[4],"gasLimit"),to:ur(e[5]),value:pr(e[6],"value"),data:Xt(e[7]),accessList:hr(e[8],"accessList")};return 9===e.length||wr(n,e.slice(9)),n}(e));case 3:return br.from(function(t){let e=Yn(Wt(t).slice(1)),n="3",r=null,i=null;if(4===e.length&&Array.isArray(e[0])){n="3 (network format)";const t=e[1],r=e[2],s=e[3];Kt(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),Kt(Array.isArray(r),"invalid network format: commitments not an array","fields[2]",r),Kt(Array.isArray(s),"invalid network format: proofs not an array","fields[3]",s),Kt(t.length===r.length,"invalid network format: blobs/commitments length mismatch","fields",e),Kt(t.length===s.length,"invalid network format: blobs/proofs length mismatch","fields",e),i=[];for(let n=0;n<e[1].length;n++)i.push({data:t[n],commitment:r[n],proof:s[n]});e=e[0]}else if(5===e.length&&Array.isArray(e[0])){n="3 (EIP-7594 network format)",r=he(e[1]);const t=e[2],s=e[3],o=e[4];Kt(1===r,`unsupported EIP-7594 network format version: ${r}`,"fields[1]",r),Kt(Array.isArray(t),"invalid EIP-7594 network format: blobs not an array","fields[2]",t),Kt(Array.isArray(s),"invalid EIP-7594 network format: commitments not an array","fields[3]",s),Kt(Array.isArray(o),"invalid EIP-7594 network format: proofs not an array","fields[4]",o),Kt(t.length===s.length,"invalid network format: blobs/commitments length mismatch","fields",e),Kt(t.length*lr===o.length,"invalid network format: blobs/proofs length mismatch","fields",e),i=[];for(let e=0;e<t.length;e++){const n=[];for(let t=0;t<lr;t++)n.push(o[e*lr+t]);i.push({data:t[e],commitment:s[e],proof:Qt(n)})}e=e[0]}Kt(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${n}`,"data",Xt(t));const s={type:3,chainId:pr(e[0],"chainId"),nonce:dr(e[1],"nonce"),maxPriorityFeePerGas:pr(e[2],"maxPriorityFeePerGas"),maxFeePerGas:pr(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:pr(e[4],"gasLimit"),to:ur(e[5]),value:pr(e[6],"value"),data:Xt(e[7]),accessList:hr(e[8],"accessList"),maxFeePerBlobGas:pr(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10],blobWrapperVersion:r};i&&(s.blobs=i),Kt(null!=s.to,`invalid address for transaction type: ${n}`,"data",t),Kt(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let e=0;e<s.blobVersionedHashes.length;e++)Kt(Zt(s.blobVersionedHashes[e],32),`invalid blobVersionedHash at index ${e}: must be length 32`,"data",t);return 11===e.length||wr(s,e.slice(11)),s}(e));case 4:return br.from(function(t){const e=Yn(Wt(t).slice(1));Kt(Array.isArray(e)&&(10===e.length||13===e.length),"invalid field count for transaction type: 4","data",Xt(t));const n={type:4,chainId:pr(e[0],"chainId"),nonce:dr(e[1],"nonce"),maxPriorityFeePerGas:pr(e[2],"maxPriorityFeePerGas"),maxFeePerGas:pr(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:pr(e[4],"gasLimit"),to:ur(e[5]),value:pr(e[6],"value"),data:Xt(e[7]),accessList:hr(e[8],"accessList"),authorizationList:fr(e[9],"authorizationList")};return 10===e.length||wr(n,e.slice(10)),n}(e))}Vt(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const e=new br;return null!=t.type&&(e.type=t.type),null!=t.to&&(e.to=t.to),null!=t.nonce&&(e.nonce=t.nonce),null!=t.gasLimit&&(e.gasLimit=t.gasLimit),null!=t.gasPrice&&(e.gasPrice=t.gasPrice),null!=t.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas),null!=t.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null!=t.maxFeePerBlobGas&&(e.maxFeePerBlobGas=t.maxFeePerBlobGas),null!=t.data&&(e.data=t.data),null!=t.value&&(e.value=t.value),null!=t.chainId&&(e.chainId=t.chainId),null!=t.signature&&(e.signature=xe.from(t.signature)),null!=t.accessList&&(e.accessList=t.accessList),null!=t.authorizationList&&(e.authorizationList=t.authorizationList),null!=t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes),null!=t.kzg&&(e.kzg=t.kzg),null!=t.blobWrapperVersion&&(e.blobWrapperVersion=t.blobWrapperVersion),null!=t.blobs&&(e.blobs=t.blobs),null!=t.hash&&(Kt(e.isSigned(),"unsigned transaction cannot define '.hash'","tx",t),Kt(e.hash===t.hash,"hash mismatch","tx",t)),null!=t.from&&(Kt(e.isSigned(),"unsigned transaction cannot define '.from'","tx",t),Kt(e.from.toLowerCase()===(t.from||"").toLowerCase(),"from mismatch","tx",t)),e}}BigInt(0);function vr(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=Xt(t.data));const n="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const r of n)r in t&&null!=t[r]&&(e[r]=ae(t[r],`request.${r}`));const r="type,nonce".split(/,/);for(const n of r)n in t&&null!=t[n]&&(e[n]=he(t[n],`request.${n}`));return t.accessList&&(e.accessList=Xn(t.accessList)),t.authorizationList&&(e.authorizationList=t.authorizationList.slice()),"blockTag"in t&&(e.blockTag=t.blockTag),"enableCcipRead"in t&&(e.enableCcipRead=!!t.enableCcipRead),"customData"in t&&(e.customData=t.customData),"blobVersionedHashes"in t&&t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.slice()),"kzg"in t&&(e.kzg=t.kzg),"blobWrapperVersion"in t&&(e.blobWrapperVersion=t.blobWrapperVersion),"blobs"in t&&t.blobs&&(e.blobs=t.blobs.map(t=>Yt(t)?Xt(t):Object.assign({},t))),e}Symbol.iterator;Symbol.iterator;function Er(t,e){if(t.provider)return t.provider;Vt(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function Ir(t,e){let n=vr(e);if(null!=n.to&&(n.to=hn(n.to,t)),null!=n.from){const e=n.from;n.from=Promise.all([t.getAddress(),hn(e,t)]).then(([t,e])=>(Kt(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t))}else n.from=t.getAddress();return await Gt(n)}class Ar{provider;constructor(t){$t(this,{provider:t||null})}async getNonce(t){return Er(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await Ir(this,t)}async populateTransaction(t){const e=Er(this,"populateTransaction"),n=await Ir(this,t);null==n.nonce&&(n.nonce=await this.getNonce("pending")),null==n.gasLimit&&(n.gasLimit=await this.estimateGas(n));const r=await this.provider.getNetwork();if(null!=n.chainId){Kt(ae(n.chainId)===r.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else n.chainId=r.chainId;const i=null!=n.maxFeePerGas||null!=n.maxPriorityFeePerGas;if(null==n.gasPrice||2!==n.type&&!i?0!==n.type&&1!==n.type||!i||Kt(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):Kt(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==n.type&&null!=n.type||null==n.maxFeePerGas||null==n.maxPriorityFeePerGas)if(0===n.type||1===n.type){const t=await e.getFeeData();Vt(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==n.gasPrice&&(n.gasPrice=t.gasPrice)}else{const t=await e.getFeeData();if(null==n.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(n.authorizationList&&n.authorizationList.length?n.type=4:n.type=2,null!=n.gasPrice){const t=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=t,n.maxPriorityFeePerGas=t}else null==n.maxFeePerGas&&(n.maxFeePerGas=t.maxFeePerGas),null==n.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(Vt(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==n.gasPrice&&(n.gasPrice=t.gasPrice),n.type=0):Vt(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==n.type&&3!==n.type&&4!==n.type||(null==n.maxFeePerGas&&(n.maxFeePerGas=t.maxFeePerGas),null==n.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else n.type=2;return await Gt(n)}async populateAuthorization(t){const e=Object.assign({},t);return null==e.chainId&&(e.chainId=(await Er(this,"getNetwork").getNetwork()).chainId),null==e.nonce&&(e.nonce=await this.getNonce()),e}async estimateGas(t){return Er(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return Er(this,"call").call(await this.populateCall(t))}async resolveName(t){const e=Er(this,"resolveName");return await e.resolveName(t)}async sendTransaction(t){const e=Er(this,"sendTransaction"),n=await this.populateTransaction(t);delete n.from;const r=br.from(n);return await e.broadcastTransaction(await this.signTransaction(r))}authorize(t){Vt(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}class Pr extends Ar{address;constructor(t,e){super(e),$t(this,{address:t})}async getAddress(){return this.address}connect(t){return new Pr(this.address,t)}#S(t,e){Vt(!1,`VoidSigner cannot sign ${t}`,"UNSUPPORTED_OPERATION",{operation:e})}async signTransaction(t){this.#S("transactions","signTransaction")}async signMessage(t){this.#S("messages","signMessage")}async signTypedData(t,e,n){this.#S("typed-data","signTypedData")}}class Nr extends Ar{address;#R;constructor(t,e){super(e),Kt(t&&"function"==typeof t.sign,"invalid private key","privateKey","[ REDACTED ]"),this.#R=t;$t(this,{address:Qn(this.signingKey.publicKey)})}get signingKey(){return this.#R}get privateKey(){return this.signingKey.privateKey}async getAddress(){return this.address}connect(t){return new Nr(this.#R,t)}async signTransaction(t){t=vr(t);const{to:e,from:n}=await Gt({to:t.to?hn(t.to,this):void 0,from:t.from?hn(t.from,this):void 0});null!=e&&(t.to=e),null!=n&&(t.from=n),null!=t.from&&(Kt(cn(t.from)===this.address,"transaction from address mismatch","tx.from",t.from),delete t.from);const r=br.from(t);return r.signature=this.signingKey.sign(r.unsignedHash),r.serialized}async signMessage(t){return this.signMessageSync(t)}signMessageSync(t){return this.signingKey.sign(pn(t)).serialized}authorizeSync(t){Kt("string"==typeof t.address,"invalid address for authorizeSync","auth.address",t);const e=this.signingKey.sign(bn(t));return Object.assign({},{address:cn(t.address),nonce:ae(t.nonce||0),chainId:ae(t.chainId||0)},{signature:e})}async authorize(t){return t=Object.assign({},t,{address:await hn(t.address,this)}),this.authorizeSync(await this.populateAuthorization(t))}async signTypedData(t,e,n){const r=await Un.resolveNames(t,e,n,async t=>{Vt(null!=this.provider,"cannot resolve ENS names without a provider","UNSUPPORTED_OPERATION",{operation:"resolveName",info:{name:t}});const e=await this.provider.resolveName(t);return Vt(null!=e,"unconfigured ENS name","UNCONFIGURED_NAME",{value:t}),e});return this.signingKey.sign(Un.hash(r.domain,e,r.value)).serialized}}let xr=!1;const Or=function(t,e,n){return(0,Gn.createHmac)(t,e).update(n).digest()};let Sr=Or;function Rr(t,e,n){const r=Wt(e,"key"),i=Wt(n,"data");return Xt(Sr(t,r,i))}Rr._=Or,Rr.lock=function(){xr=!0},Rr.register=function(t){if(xr)throw new Error("computeHmac is locked");Sr=t},Object.freeze(Rr);const Tr=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),kr=Uint8Array.from({length:16},(t,e)=>e);let Lr=[kr],Br=[kr.map(t=>(9*t+5)%16)];for(let t=0;t<4;t++)for(let e of[Lr,Br])e.push(e[t].map(t=>Tr[t]));const Cr=[[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(t=>new Uint8Array(t)),Ur=Lr.map((t,e)=>t.map(t=>Cr[e][t])),Fr=Br.map((t,e)=>t.map(t=>Cr[e][t])),Gr=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),$r=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),Dr=(t,e)=>t<<e|t>>>32-e;function zr(t,e,n,r){return 0===t?e^n^r:1===t?e&n|~e&r:2===t?(e|~n)^r:3===t?e&r|n&~r:e^(n|~r)}const Vr=new Uint32Array(16);class Kr extends P{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:n,h3:r,h4:i}=this;return[t,e,n,r,i]}set(t,e,n,r,i){this.h0=0|t,this.h1=0|e,this.h2=0|n,this.h3=0|r,this.h4=0|i}process(t,e){for(let n=0;n<16;n++,e+=4)Vr[n]=t.getUint32(e,!0);let n=0|this.h0,r=n,i=0|this.h1,s=i,o=0|this.h2,a=o,l=0|this.h3,c=l,u=0|this.h4,h=u;for(let t=0;t<5;t++){const e=4-t,f=Gr[t],d=$r[t],p=Lr[t],g=Br[t],y=Ur[t],m=Fr[t];for(let e=0;e<16;e++){const r=Dr(n+zr(t,i,o,l)+Vr[p[e]]+f,y[e])+u|0;n=u,u=l,l=0|Dr(o,10),o=i,i=r}for(let t=0;t<16;t++){const n=Dr(r+zr(e,s,a,c)+Vr[g[t]]+d,m[t])+h|0;r=h,h=c,c=0|Dr(a,10),a=s,s=n}}this.set(this.h1+o+c|0,this.h2+l+h|0,this.h3+u+r|0,this.h4+n+s|0,this.h0+i+a|0)}roundClean(){Vr.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const Mr=I(()=>new Kr);let _r=!1;const Hr=function(t){return Mr(t)};let jr=Hr;function Wr(t){const e=Wt(t,"data");return Xt(jr(e))}Wr._=Hr,Wr.lock=function(){_r=!0},Wr.register=function(t){if(_r)throw new TypeError("ripemd160 is locked");jr=t},Object.freeze(Wr);let qr=!1;const Zr=function(t){return new Uint8Array((0,Gn.randomBytes)(t))};let Yr=Zr;function Jr(t){return Yr(t)}Jr._=Zr,Jr.lock=function(){qr=!0},Jr.register=function(t){if(qr)throw new Error("randomBytes is locked");Yr=t},Object.freeze(Jr);const Xr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";let Qr=null;function ti(t){if(null==Qr){Qr={};for(let t=0;t<58;t++)Qr[Xr[t]]=BigInt(t)}const e=Qr[t];return Kt(null!=e,"invalid base58 value","letter",t),e}const ei=BigInt(0),ni=BigInt(58);const ri=" !#$%&'()*+,-./<=>?@[]^_`{|}~",ii=/^[a-z]*$/i;function si(t,e){let n=97;return t.reduce((t,r)=>(r===e?n++:r.match(ii)?t.push(String.fromCharCode(n)+r):(n=97,t.push(r)),t),[])}function oi(t){return Kt("0"===t[0],"unsupported auwl data","data",t),function(t,e){for(let n=28;n>=0;n--)t=t.split(ri[n]).join(e.substring(2*n,2*n+2));const n=[],r=t.replace(/(:|([0-9])|([A-Z][a-z]*))/g,(t,e,r,i)=>{if(r)for(let t=parseInt(r);t>=0;t--)n.push(";");else n.push(e.toLowerCase());return""});if(r)throw new Error(`leftovers: ${JSON.stringify(r)}`);return si(si(n,";"),":")}(t.substring(59),t.substring(1,59))}class ai{locale;constructor(t){$t(this,{locale:t})}split(t){return t.toLowerCase().split(/\s+/g)}join(t){return t.join(" ")}}class li extends ai{#h;#T;constructor(t,e,n){super(t),this.#h=e,this.#T=n,this.#k=null}get _data(){return this.#h}_decodeWords(){return oi(this.#h)}#k;#L(){if(null==this.#k){const t=this._decodeWords();if(vn(t.join("\n")+"\n")!==this.#T)throw new Error(`BIP39 Wordlist for ${this.locale} FAILED`);this.#k=t}return this.#k}getWord(t){const e=this.#L();return Kt(t>=0&&t<e.length,`invalid word index: ${t}`,"index",t),e[t]}getWordIndex(t){return this.#L().indexOf(t)}}let ci=null;class ui extends li{constructor(){super("en","0erleonalorenseinceregesticitStanvetearctssi#ch2Athck&tneLl0And#Il.yLeOutO=S|S%b/ra@SurdU'0Ce[Cid|CountCu'Hie=IdOu,-Qui*Ro[TT]T%T*[Tu$0AptDD-tD*[Ju,M.UltV<)Vi)0Rob-0FairF%dRaid0A(EEntRee0Ead0MRRp%tS!_rmBumCoholErtI&LLeyLowMo,O}PhaReadySoT Ways0A>urAz(gOngOuntU'd0Aly,Ch%Ci|G G!GryIm$K!Noun)Nu$O` Sw T&naTiqueXietyY1ArtOlogyPe?P!Pro=Ril1ChCt-EaEnaGueMMedM%MyOundR<+Re,Ri=RowTTefa@Ti,Tw%k0KPe@SaultSetSi,SumeThma0H!>OmTa{T&dT.udeTra@0Ct]D.Gu,NtTh%ToTumn0Era+OcadoOid0AkeA*AyEsomeFulKw?d0Is:ByChel%C#D+GL<)Lc#y~MbooN<aNn RRelyRga(R*lSeS-SketTt!3A^AnAutyCau'ComeEfF%eG(Ha=H(dLie=LowLtN^Nef./TrayTt Twe&Y#d3Cyc!DKeNdOlogyRdR`Tt _{AdeAmeAnketA,EakE[IndOodO[omOu'UeUrUsh_rdAtDyIlMbNeNusOkO,Rd R(gRrowSsTtomUn)XY_{etA(AndA[A=EadEezeI{Id+IefIghtIngIskOccoliOk&OnzeOomO` OwnUsh2Bb!DdyD+tFf$oIldLbLkL!tNd!Nk Rd&Rg R,SS(e[SyTt Y Zz:Bba+B(B!CtusGeKe~LmM aMpNN$N)lNdyNn#NoeNvasNy#Pab!P.$Pta(RRb#RdRgoRpetRryRtSeShS(o/!Su$TT$ogT^Teg%yTt!UghtU'Ut]Ve3Il(gL yM|NsusNturyRe$Rta(_irAlkAmp]An+AosApt Ar+A'AtEapE{Ee'EfErryE,I{&IefIldIm}yOi)Oo'R#-U{!UnkUrn0G?Nnam#Rc!Tiz&TyVil_imApArifyAwAyE<ErkEv I{I|IffImbIn-IpO{OgO'O`OudOwnUbUmpU, Ut^_^A,C#utDeFfeeIlInL!@L%LumnMb(eMeMf%tM-Mm#Mp<yNc tNdu@NfirmNg*[N}@Nsid NtrolNv()OkOlPp PyR$ReRnR*@/Tt#U^UntryUp!Ur'Us(V Yo>_{Ad!AftAmA}AshAt AwlAzyEamEd.EekEwI{etImeIspIt-OpO[Ou^OwdUci$UelUi'Umb!Un^UshYY,$2BeLtu*PPbo?dRiousRr|Rta(R=Sh]/omTe3C!:DMa+MpN)Ng R(gShUght WnY3AlBa>BrisCadeCemb CideCl(eC%a>C*a'ErF&'F(eFyG*eLayLiv M<dMi'Ni$Nti,NyP?tP&dPos.P`PutyRi=ScribeS tSignSkSpair/royTailTe@VelopVi)Vo>3AgramAlAm#dAryCeE'lEtFf G.$Gn.yLemmaNn NosaurRe@RtSag*eScov Sea'ShSmi[S%d Splay/<)V tVideV%)Zzy5Ct%Cum|G~Lph(Ma(Na>NkeyN%OrSeUb!Ve_ftAg#AmaA,-AwEamE[IftIllInkIpI=OpUmY2CkMbNeR(g/T^Ty1Arf1Nam-:G G!RlyRnR`Sily/Sy1HoOlogyOnomy0GeItUca>1F%t0G1GhtTh 2BowD E@r-Eg<tEm|Eph<tEvat%I>Se0B?kBodyBra)Er+Ot]PloyPow Pty0Ab!A@DD![D%'EmyErgyF%)Ga+G(eH<)JoyLi,OughR-hRollSu*T Ti*TryVelope1Isode0U$Uip0AA'OdeOs]R%Upt0CapeSayS&)Ta>0Ern$H-s1Id&)IlOkeOl=1A@Amp!Ce[Ch<+C.eCludeCu'Ecu>Erci'Hau,Hib.I!I,ItOt-P<dPe@Pi*Pla(Po'P*[T&dTra0EEbrow:Br-CeCultyDeIntI`~L'MeMilyMousNNcyNtasyRmSh]TT$Th TigueUltV%.e3Atu*Bru?yD $EEdElMa!N)/iv$T^V W3B Ct]EldGu*LeLmLt N$NdNeNg NishReRmR,Sc$ShTT}[X_gAmeAshAtAv%EeIghtIpOatO{O%Ow UidUshY_mCusGIlLd~owOdOtR)Re,R+tRkRtu}RumRw?dSsil/ UndX_gi!AmeEqu|EshI&dIn+OgOntO,OwnOz&U.2ElNNnyRna)RyTu*:D+tInLaxy~ yMePRa+Rba+Rd&Rl-Rm|SSpTeTh U+Ze3N $NiusN*Nt!Nu(e/u*2O,0AntFtGg!Ng RaffeRlVe_dAn)A*A[IdeImp'ObeOomOryO=OwUe_tDde[LdOdO'RillaSpelSsipV nWn_bA)A(AntApeA[Av.yEatE&IdIefItOc yOupOwUnt_rdE[IdeIltIt?N3M:B.IrLfMm M, NdPpyRb%RdRshR=,TVeWkZ?d3AdAl`ArtAvyD+hogIght~oLmetLpNRo3Dd&Gh~NtPRe/%y5BbyCkeyLdLeLiday~owMeNeyOdPeRnRr%R'Sp.$/TelUrV 5BGeM<Mb!M%Nd*dNgryNtRd!RryRtSb<d3Brid:1EOn0EaEntifyLe2N%e4LLeg$L}[0A+Ita>M&'Mu}Pa@Po'Pro=Pul'0ChCludeComeC*a'DexD-a>Do%Du,ryF<tFl-tF%mHa!H .Iti$Je@JuryMa>N Noc|PutQuiryS<eSe@SideSpi*/$lTa@T e,ToVe,V.eVol=3On0L<dOla>Sue0Em1Ory:CketGu?RZz3AlousAns~yWel9BInKeUr}yY5D+I)MpNg!Ni%Nk/:Ng?oo3EnEpT^upY3CkDD}yNdNgdomSsTT^&TeTt&Wi4EeIfeO{Ow:BBelB%Dd DyKeMpNgua+PtopR+T T(UghUndryVaWWnWsu.Y Zy3Ad AfArnA=Ctu*FtGG$G&dIsu*M#NdNg`NsOp?dSs#Tt Vel3ArB tyBr?yC&'FeFtGhtKeMbM.NkOnQuid/Tt!VeZ?d5AdAnB, C$CkG-NelyNgOpTt yUdUn+VeY$5CkyGga+Mb N?N^Xury3R-s:Ch(eDG-G}tIdIlInJ%KeMm$NNa+Nda>NgoNs]Nu$P!Rb!R^Rg(R(eRketRria+SkSs/ T^T i$ThTrixTt XimumZe3AdowAnAsu*AtCh<-D$DiaLodyLtMb M%yNt]NuRcyR+R.RryShSsa+T$Thod3Dd!DnightLk~]M-NdNimumN%Nu>Rac!Rr%S ySs/akeXXedXtu*5Bi!DelDifyMM|N.%NkeyN, N`OnR$ReRn(gSqu.oTh T]T%Unta(U'VeVie5ChFf(LeLtiplySc!SeumShroomS-/Tu$3Self/ yTh:I=MePk(Rrow/yT]Tu*3ArCkEdGati=G!@I` PhewR=/TTw%kUtr$V WsXt3CeGht5B!I'M(eeOd!Rm$R`SeTab!TeTh(gTi)VelW5C!?Mb R'T:K0EyJe@Li+Scu*S =Ta(Vious0CurE<Tob 0Or1FF Fi)T&2L1Ay0DI=Ymp-0It0CeEI#L(eLy1EnEraIn]Po'T]1An+B.Ch?dD D(?yG<I|Ig($Ph<0Tr-h0H 0Tdo%T TputTside0AlEnEr0NN 0Yg&0/ 0O}:CtDd!GeIrLa)LmNdaNelN-N` P RadeR|RkRrotRtySsT^ThTi|TrolTt nU'VeYm|3A)AnutArAs<tL-<NN$tyNcilOp!Pp Rfe@Rm.Rs#T2O}OtoRa'Ys-$0AnoCn-Ctu*E)GGe#~LotNkO} Pe/olT^Zza_)A}tA,-A>AyEa'Ed+U{UgUn+2EmEtIntL?LeLi)NdNyOlPul?Rt]S.]Ssib!/TatoTt yV tyWd W _@i)Ai'Ed-tEf Epa*Es|EttyEv|I)IdeIm?yIntI%.yIs#Iva>IzeOb!mO)[Odu)Of.OgramOje@Omo>OofOp tyOsp O>@OudOvide2Bl-Dd(g~LpL'Mpk(N^PilPpyR^a'R.yRpo'R'ShTZz!3Ramid:99Al.yAntumArt E,]I{ItIzO>:Bb.Cco#CeCkD?DioIlInI'~yMpN^NdomN+PidReTeTh V&WZ%3AdyAlAs#BelBuildC$lCei=CipeC%dCyc!Du)F!@F%mFu'G]G*tGul?Je@LaxLea'LiefLyMa(Memb M(dMo=Nd NewNtOp&PairPeatPla)P%tQui*ScueSemb!Si,Sour)Sp#'SultTi*T*atTurnUn]Ve$ViewW?d2Y`m0BBb#CeChDeD+F!GhtGidNgOtPp!SkTu$V$V 5AdA,BotBu,CketM<)OfOkieOmSeTa>UghUndU>Y$5Bb DeGLeNNwayR$:DDd!D}[FeIlLadLm#L#LtLu>MeMp!NdTisfyToshiU)Usa+VeY1A!AnA*Att E}HemeHoolI&)I[%sOrp]OutRapRe&RiptRub1AAr^As#AtC#dC*tCt]Cur.yEdEkGm|Le@~M(?Ni%N'Nt&)RiesRvi)Ss]Tt!TupV&_dowAftAllowA*EdEllEriffIeldIftI}IpIv O{OeOotOpOrtOuld O=RimpRugUff!Y0Bl(gCkDeE+GhtGnL|Lk~yLv Mil?Mp!N)NgR&/ Tua>XZe1A>Et^IIllInIrtUll0AbAmEepEnd I)IdeIghtImOg<OtOwUsh0AllArtI!OkeOo`0A{AkeApIffOw0ApCc Ci$CkDaFtL?Ldi LidLut]L=Me#eNgOnRryRtUlUndUpUr)U`0A)A*Ati$AwnEakEci$EedEllEndH eI)Id IkeInIr.L.OilOns%O#OrtOtRayReadR(gY0Ua*UeezeUir*l_b!AdiumAffA+AirsAmpAndArtA>AyEakEelEmEpE*oI{IllIngO{Oma^O}OolOryO=Ra>gyReetRikeR#gRugg!Ud|UffUmb!Y!0Bje@Bm.BwayC)[ChDd&Ff G?G+,ItMm NNnyN'tP PplyP*meReRfa)R+Rpri'RroundR=ySpe@/a(1AllowAmpApArmE?EetIftImIngIt^Ord1MbolMptomRup/em:B!Ck!GIlL|LkNkPeR+tSk/eTtooXi3A^Am~NN<tNnisNtRm/Xt_nkAtEmeEnE%yE*EyIngIsOughtReeRi=RowUmbUnd 0CketDeG LtMb MeNyPRedSsueT!5A,BaccoDayDdl EGe` I!tK&MatoM%rowNeNgueNightOlO`PP-Pp!R^RnadoRtoi'SsT$Uri,W?dW WnY_{AdeAff-Ag-A(Ansf ApAshA=lAyEatEeEndI$IbeI{Igg ImIpOphyOub!U{UeUlyUmpetU,U`Y2BeIt]Mb!NaN}lRkeyRnRt!1El=EntyI)InI,O1PeP-$:5Ly5B*lla0Ab!Awa*C!Cov D DoFairFoldHappyIf%mIqueItIv 'KnownLo{TilUsu$Veil1Da>GradeHoldOnP Set1B<Ge0A+EEdEfulE![U$0Il.y:C<tCuumGueLidL!yL=NNishP%Rious/Ult3H-!L=tNd%Ntu*NueRbRifyRs]RyS'lT <3Ab!Br<tCiousCt%yDeoEw~a+Nta+Ol(Rtu$RusSaS.Su$T$Vid5C$I)IdLc<oLumeTeYa+:GeG#ItLk~LnutNtRfa*RmRri%ShSp/eT VeY3Al`Ap#ArA'lA` BDd(gEk&dIrdLcome/T_!AtEatEelEnE*IpIsp 0DeD`FeLd~NNdowNeNgNkNn Nt ReSdomSeShT}[5LfM<Nd OdOlRdRkRldRryR`_pE{E,!I,I>Ong::Rd3Ar~ow9UUngU`:3BraRo9NeO","0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60")}static wordlist(){return null==ci&&(ci=new ui),ci}}let hi=!1;const fi=function(t,e,n,r,i){return(0,Gn.pbkdf2Sync)(t,e,n,r,i)};let di=fi;function pi(t,e,n,r,i){const s=Wt(t,"password"),o=Wt(e,"salt");return Xt(di(s,o,n,r,i))}function gi(t){return(1<<t)-1<<8-t&255}function yi(t){return(1<<t)-1&255}function mi(t,e){_t("NFKD"),null==e&&(e=ui.wordlist());const n=e.split(t);Kt(n.length%3==0&&n.length>=12&&n.length<=24,"invalid mnemonic length","mnemonic","[ REDACTED ]");const r=new Uint8Array(Math.ceil(11*n.length/8));let i=0;for(let t=0;t<n.length;t++){let s=e.getWordIndex(n[t].normalize("NFKD"));Kt(s>=0,`invalid mnemonic word at index ${t}`,"mnemonic","[ REDACTED ]");for(let t=0;t<11;t++)s&1<<10-t&&(r[i>>3]|=1<<7-i%8),i++}const s=32*n.length/3,o=gi(n.length/3);return Kt((Wt(_n(r.slice(0,s/8)))[0]&o)===(r[r.length-1]&o),"invalid mnemonic checksum","mnemonic","[ REDACTED ]"),Xt(r.slice(0,s/8))}function wi(t,e){Kt(t.length%4==0&&t.length>=16&&t.length<=32,"invalid entropy size","entropy","[ REDACTED ]"),null==e&&(e=ui.wordlist());const n=[0];let r=11;for(let e=0;e<t.length;e++)r>8?(n[n.length-1]<<=8,n[n.length-1]|=t[e],r-=8):(n[n.length-1]<<=r,n[n.length-1]|=t[e]>>8-r,n.push(t[e]&yi(8-r)),r+=3);const i=t.length/4,s=parseInt(_n(t).substring(2,4),16)&gi(i);return n[n.length-1]<<=i,n[n.length-1]|=s>>8-i,e.join(n.map(t=>e.getWord(t)))}pi._=fi,pi.lock=function(){hi=!0},pi.register=function(t){if(hi)throw new Error("pbkdf2 is locked");di=t},Object.freeze(pi);const bi={};class vi{phrase;password;wordlist;entropy;constructor(t,e,n,r,i){null==r&&(r=""),null==i&&(i=ui.wordlist()),Ht(t,bi,"Mnemonic"),$t(this,{phrase:n,password:r,wordlist:i,entropy:e})}computeSeed(){const t=dn("mnemonic"+this.password,"NFKD");return pi(dn(this.phrase,"NFKD"),t,2048,64,"sha512")}static fromPhrase(t,e,n){const r=mi(t,n);return t=wi(Wt(r),n),new vi(bi,r,t,e,n)}static fromEntropy(t,e,n){const r=Wt(t,"entropy"),i=wi(r,n);return new vi(bi,Xt(r),i,e,n)}static entropyToPhrase(t,e){return wi(Wt(t,"entropy"),e)}static phraseToEntropy(t,e){return mi(t,e)}static isValidMnemonic(t,e){try{return mi(t,e),!0}catch(t){}return!1}}
|
|
12
|
+
/*! MIT License. Copyright 2015-2022 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */
|
|
13
|
+
var Ei,Ii,Ai,Pi=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)},Ni=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n};const xi={16:10,24:12,32:14},Oi=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],Si=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],Ri=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],Ti=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],ki=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],Li=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],Bi=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Ci=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],Ui=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],Fi=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],Gi=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],$i=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],Di=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],zi=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Vi=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Ki(t){const e=[];for(let n=0;n<t.length;n+=4)e.push(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3]);return e}class Mi{get key(){return Pi(this,Ei,"f").slice()}constructor(t){if(Ei.set(this,void 0),Ii.set(this,void 0),Ai.set(this,void 0),!(this instanceof Mi))throw Error("AES must be instanitated with `new`");Ni(this,Ei,new Uint8Array(t),"f");const e=xi[this.key.length];if(null==e)throw new TypeError("invalid key size (must be 16, 24 or 32 bytes)");Ni(this,Ai,[],"f"),Ni(this,Ii,[],"f");for(let t=0;t<=e;t++)Pi(this,Ai,"f").push([0,0,0,0]),Pi(this,Ii,"f").push([0,0,0,0]);const n=4*(e+1),r=this.key.length/4,i=Ki(this.key);let s;for(let t=0;t<r;t++)s=t>>2,Pi(this,Ai,"f")[s][t%4]=i[t],Pi(this,Ii,"f")[e-s][t%4]=i[t];let o,a=0,l=r;for(;l<n;){if(o=i[r-1],i[0]^=Si[o>>16&255]<<24^Si[o>>8&255]<<16^Si[255&o]<<8^Si[o>>24&255]^Oi[a]<<24,a+=1,8!=r)for(let t=1;t<r;t++)i[t]^=i[t-1];else{for(let t=1;t<r/2;t++)i[t]^=i[t-1];o=i[r/2-1],i[r/2]^=Si[255&o]^Si[o>>8&255]<<8^Si[o>>16&255]<<16^Si[o>>24&255]<<24;for(let t=r/2+1;t<r;t++)i[t]^=i[t-1]}let t,s,c=0;for(;c<r&&l<n;)t=l>>2,s=l%4,Pi(this,Ai,"f")[t][s]=i[c],Pi(this,Ii,"f")[e-t][s]=i[c++],l++}for(let t=1;t<e;t++)for(let e=0;e<4;e++)o=Pi(this,Ii,"f")[t][e],Pi(this,Ii,"f")[t][e]=$i[o>>24&255]^Di[o>>16&255]^zi[o>>8&255]^Vi[255&o]}encrypt(t){if(16!=t.length)throw new TypeError("invalid plaintext size (must be 16 bytes)");const e=Pi(this,Ai,"f").length-1,n=[0,0,0,0];let r=Ki(t);for(let t=0;t<4;t++)r[t]^=Pi(this,Ai,"f")[0][t];for(let t=1;t<e;t++){for(let e=0;e<4;e++)n[e]=Ti[r[e]>>24&255]^ki[r[(e+1)%4]>>16&255]^Li[r[(e+2)%4]>>8&255]^Bi[255&r[(e+3)%4]]^Pi(this,Ai,"f")[t][e];r=n.slice()}const i=new Uint8Array(16);let s=0;for(let t=0;t<4;t++)s=Pi(this,Ai,"f")[e][t],i[4*t]=255&(Si[r[t]>>24&255]^s>>24),i[4*t+1]=255&(Si[r[(t+1)%4]>>16&255]^s>>16),i[4*t+2]=255&(Si[r[(t+2)%4]>>8&255]^s>>8),i[4*t+3]=255&(Si[255&r[(t+3)%4]]^s);return i}decrypt(t){if(16!=t.length)throw new TypeError("invalid ciphertext size (must be 16 bytes)");const e=Pi(this,Ii,"f").length-1,n=[0,0,0,0];let r=Ki(t);for(let t=0;t<4;t++)r[t]^=Pi(this,Ii,"f")[0][t];for(let t=1;t<e;t++){for(let e=0;e<4;e++)n[e]=Ci[r[e]>>24&255]^Ui[r[(e+3)%4]>>16&255]^Fi[r[(e+2)%4]>>8&255]^Gi[255&r[(e+1)%4]]^Pi(this,Ii,"f")[t][e];r=n.slice()}const i=new Uint8Array(16);let s=0;for(let t=0;t<4;t++)s=Pi(this,Ii,"f")[e][t],i[4*t]=255&(Ri[r[t]>>24&255]^s>>24),i[4*t+1]=255&(Ri[r[(t+3)%4]>>16&255]^s>>16),i[4*t+2]=255&(Ri[r[(t+2)%4]>>8&255]^s>>8),i[4*t+3]=255&(Ri[255&r[(t+1)%4]]^s);return i}}Ei=new WeakMap,Ii=new WeakMap,Ai=new WeakMap;class _i{constructor(t,e,n){if(n&&!(this instanceof n))throw new Error(`${t} must be instantiated with "new"`);Object.defineProperties(this,{aes:{enumerable:!0,value:new Mi(e)},name:{enumerable:!0,value:t}})}}var Hi,ji,Wi=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n},qi=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};class Zi extends _i{constructor(t,e){if(super("ECC",t,Zi),Hi.set(this,void 0),ji.set(this,void 0),e){if(e.length%16)throw new TypeError("invalid iv size (must be 16 bytes)");Wi(this,Hi,new Uint8Array(e),"f")}else Wi(this,Hi,new Uint8Array(16),"f");Wi(this,ji,this.iv,"f")}get iv(){return new Uint8Array(qi(this,Hi,"f"))}encrypt(t){if(t.length%16)throw new TypeError("invalid plaintext size (must be multiple of 16 bytes)");const e=new Uint8Array(t.length);for(let n=0;n<t.length;n+=16){for(let e=0;e<16;e++)qi(this,ji,"f")[e]^=t[n+e];Wi(this,ji,this.aes.encrypt(qi(this,ji,"f")),"f"),e.set(qi(this,ji,"f"),n)}return e}decrypt(t){if(t.length%16)throw new TypeError("invalid ciphertext size (must be multiple of 16 bytes)");const e=new Uint8Array(t.length);for(let n=0;n<t.length;n+=16){const r=this.aes.decrypt(t.subarray(n,n+16));for(let i=0;i<16;i++)e[n+i]=r[i]^qi(this,ji,"f")[i],qi(this,ji,"f")[i]=t[n+i]}return e}}Hi=new WeakMap,ji=new WeakMap;var Yi,Ji=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};new WeakMap,Yi=new WeakMap,new WeakSet;var Xi,Qi,ts,es=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n},ns=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};class rs extends _i{constructor(t,e){super("CTR",t,rs),Xi.set(this,void 0),Qi.set(this,void 0),ts.set(this,void 0),es(this,ts,new Uint8Array(16),"f"),ns(this,ts,"f").fill(0),es(this,Xi,ns(this,ts,"f"),"f"),es(this,Qi,16,"f"),null==e&&(e=1),"number"==typeof e?this.setCounterValue(e):this.setCounterBytes(e)}get counter(){return new Uint8Array(ns(this,ts,"f"))}setCounterValue(t){if(!Number.isInteger(t)||t<0||t>Number.MAX_SAFE_INTEGER)throw new TypeError("invalid counter initial integer value");for(let e=15;e>=0;--e)ns(this,ts,"f")[e]=t%256,t=Math.floor(t/256)}setCounterBytes(t){if(16!==t.length)throw new TypeError("invalid counter initial Uint8Array value length");ns(this,ts,"f").set(t)}increment(){for(let t=15;t>=0;t--){if(255!==ns(this,ts,"f")[t]){ns(this,ts,"f")[t]++;break}ns(this,ts,"f")[t]=0}}encrypt(t){var e,n;const r=new Uint8Array(t);for(let t=0;t<r.length;t++)16===ns(this,Qi,"f")&&(es(this,Xi,this.aes.encrypt(ns(this,ts,"f")),"f"),es(this,Qi,0,"f"),this.increment()),r[t]^=ns(this,Xi,"f")[es(this,Qi,(n=ns(this,Qi,"f"),e=n++,n),"f"),e];return r}decrypt(t){return this.encrypt(t)}}Xi=new WeakMap,Qi=new WeakMap,ts=new WeakMap;function is(t,e,n,r){o(t);const s=E({dkLen:32,asyncTick:10},r),{c:a,dkLen:l,asyncTick:c}=s;if(i(a),i(l),i(c),a<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const u=w(e),h=w(n),f=new Uint8Array(l),d=pt.create(t,u),p=d._cloneInto().update(h);return{c:a,dkLen:l,asyncTick:c,DK:f,PRF:d,PRFSalt:p}}function ss(t,e,n,r,i){return t.destroy(),e.destroy(),r&&r.destroy(),i.fill(0),n}function os(t,e,n,r){const{c:i,dkLen:s,DK:o,PRF:a,PRFSalt:l}=is(t,e,n,r);let c;const u=new Uint8Array(4),h=p(u),f=new Uint8Array(a.outputLen);for(let t=1,e=0;e<s;t++,e+=a.outputLen){const n=o.subarray(e,e+a.outputLen);h.setInt32(0,t,!1),(c=l._cloneInto(c)).update(u).digestInto(f),n.set(f.subarray(0,n.length));for(let t=1;t<i;t++){a._cloneInto(c).update(f).digestInto(f);for(let t=0;t<n.length;t++)n[t]^=f[t]}}return ss(a,l,o,c,f)}new WeakMap,new WeakMap,new WeakMap;const as=(t,e)=>t<<e|t>>>32-e;function ls(t,e,n,r,i,s){let o=t[e++]^n[r++],a=t[e++]^n[r++],l=t[e++]^n[r++],c=t[e++]^n[r++],u=t[e++]^n[r++],h=t[e++]^n[r++],f=t[e++]^n[r++],d=t[e++]^n[r++],p=t[e++]^n[r++],g=t[e++]^n[r++],y=t[e++]^n[r++],m=t[e++]^n[r++],w=t[e++]^n[r++],b=t[e++]^n[r++],v=t[e++]^n[r++],E=t[e++]^n[r++],I=o,A=a,P=l,N=c,x=u,O=h,S=f,R=d,T=p,k=g,L=y,B=m,C=w,U=b,F=v,G=E;for(let t=0;t<8;t+=2)x^=as(I+C|0,7),T^=as(x+I|0,9),C^=as(T+x|0,13),I^=as(C+T|0,18),k^=as(O+A|0,7),U^=as(k+O|0,9),A^=as(U+k|0,13),O^=as(A+U|0,18),F^=as(L+S|0,7),P^=as(F+L|0,9),S^=as(P+F|0,13),L^=as(S+P|0,18),N^=as(G+B|0,7),R^=as(N+G|0,9),B^=as(R+N|0,13),G^=as(B+R|0,18),A^=as(I+N|0,7),P^=as(A+I|0,9),N^=as(P+A|0,13),I^=as(N+P|0,18),S^=as(O+x|0,7),R^=as(S+O|0,9),x^=as(R+S|0,13),O^=as(x+R|0,18),B^=as(L+k|0,7),T^=as(B+L|0,9),k^=as(T+B|0,13),L^=as(k+T|0,18),C^=as(G+F|0,7),U^=as(C+G|0,9),F^=as(U+C|0,13),G^=as(F+U|0,18);i[s++]=o+I|0,i[s++]=a+A|0,i[s++]=l+P|0,i[s++]=c+N|0,i[s++]=u+x|0,i[s++]=h+O|0,i[s++]=f+S|0,i[s++]=d+R|0,i[s++]=p+T|0,i[s++]=g+k|0,i[s++]=y+L|0,i[s++]=m+B|0,i[s++]=w+C|0,i[s++]=b+U|0,i[s++]=v+F|0,i[s++]=E+G|0}function cs(t,e,n,r,i){let s=r+0,o=r+16*i;for(let r=0;r<16;r++)n[o+r]=t[e+16*(2*i-1)+r];for(let r=0;r<i;r++,s+=16,e+=16)ls(n,o,t,e,n,s),r>0&&(o+=16),ls(n,s,t,e+=16,n,o)}function us(t,e,n){const r=E({dkLen:32,asyncTick:10,maxmem:1073742848},n),{N:s,r:o,p:a,dkLen:l,asyncTick:c,maxmem:u,onProgress:h}=r;if(i(s),i(o),i(a),i(l),i(c),i(u),void 0!==h&&"function"!=typeof h)throw new Error("progressCb should be function");const f=128*o,p=f/4;if(s<=1||s&s-1||s>=2**(f/8)||s>2**32)throw new Error("Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32");if(a<0||a>137438953440/f)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(l<0||l>137438953440)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");const g=f*(s+a);if(g>u)throw new Error(`Scrypt: parameters too large, ${g} (128 * r * (N + p)) > ${u} (maxmem)`);const y=os(k,t,e,{c:1,dkLen:f*a}),m=d(y),w=d(new Uint8Array(f*s)),b=d(new Uint8Array(f));let v=()=>{};if(h){const t=2*s*a,e=Math.max(Math.floor(t/1e4),1);let n=0;v=()=>{n++,!h||n%e&&n!==t||h(n/t)}}return{N:s,r:o,p:a,dkLen:l,blockSize32:p,V:w,B32:m,B:y,tmp:b,blockMixCb:v,asyncTick:c}}function hs(t,e,n,r,i){const s=os(k,t,n,{c:1,dkLen:e});return n.fill(0),r.fill(0),i.fill(0),s}let fs=!1,ds=!1;const ps=async function(t,e,n,r,i,s,o){return await async function(t,e,n){const{N:r,r:i,p:s,dkLen:o,blockSize32:a,V:l,B32:c,B:u,tmp:h,blockMixCb:f,asyncTick:d}=us(t,e,n);for(let t=0;t<s;t++){const e=a*t;for(let t=0;t<a;t++)l[t]=c[e+t];let n=0;await m(r-1,d,()=>{cs(l,n,l,n+=a,i),f()}),cs(l,(r-1)*a,c,e,i),f(),await m(r,d,()=>{const t=c[e+a-16]%r;for(let n=0;n<a;n++)h[n]=c[e+n]^l[t*a+n];cs(h,0,c,e,i),f()})}return hs(t,o,u,l,h)}(t,e,{N:n,r:r,p:i,dkLen:s,onProgress:o})},gs=function(t,e,n,r,i,s){return function(t,e,n){const{N:r,r:i,p:s,dkLen:o,blockSize32:a,V:l,B32:c,B:u,tmp:h,blockMixCb:f}=us(t,e,n);for(let t=0;t<s;t++){const e=a*t;for(let t=0;t<a;t++)l[t]=c[e+t];for(let t=0,e=0;t<r-1;t++)cs(l,e,l,e+=a,i),f();cs(l,(r-1)*a,c,e,i),f();for(let t=0;t<r;t++){const t=c[e+a-16]%r;for(let n=0;n<a;n++)h[n]=c[e+n]^l[t*a+n];cs(h,0,c,e,i),f()}}return hs(t,o,u,l,h)}(t,e,{N:n,r:r,p:i,dkLen:s})};let ys=ps,ms=gs;async function ws(t,e,n,r,i,s,o){const a=Wt(t,"passwd"),l=Wt(e,"salt");return Xt(await ys(a,l,n,r,i,s,o))}function bs(t,e,n,r,i,s){const o=Wt(t,"passwd"),a=Wt(e,"salt");return Xt(ms(o,a,n,r,i,s))}function vs(t){const e=Wt(t,"randomBytes");e[6]=15&e[6]|64,e[8]=63&e[8]|128;const n=Xt(e);return[n.substring(2,10),n.substring(10,14),n.substring(14,18),n.substring(18,22),n.substring(22,34)].join("-")}function Es(t){return"string"!=typeof t||t.startsWith("0x")||(t="0x"+t),qt(t)}function Is(t,e){for(t=String(t);t.length<e;)t="0"+t;return t}function As(t){return"string"==typeof t?dn(t,"NFKC"):qt(t)}function Ps(t,e){const n=e.match(/^([a-z0-9$_.-]*)(:([a-z]+))?(!)?$/i);Kt(null!=n,"invalid path","path",e);const r=n[1],i=n[3],s="!"===n[4];let o=t;for(const t of r.toLowerCase().split(".")){if(Array.isArray(o)){if(!t.match(/^[0-9]+$/))break;o=o[parseInt(t)]}else if("object"==typeof o){let e=null;for(const n in o)if(n.toLowerCase()===t){e=o[n];break}o=e}else o=null;if(null==o)break}if(Kt(!s||null!=o,"missing required value","path",r),i&&null!=o){if("int"===i){if("string"==typeof o&&o.match(/^-?[0-9]+$/))return parseInt(o);if(Number.isSafeInteger(o))return o}if("number"===i&&"string"==typeof o&&o.match(/^-?[0-9.]*$/))return parseFloat(o);if("data"===i&&"string"==typeof o)return Es(o);if("array"===i&&Array.isArray(o))return o;if(i===typeof o)return o;Kt(!1,`wrong type found for ${i} `,"path",r)}return o}ws._=ps,ws.lock=function(){ds=!0},ws.register=function(t){if(ds)throw new Error("scrypt is locked");ys=t},Object.freeze(ws),bs._=gs,bs.lock=function(){fs=!0},bs.register=function(t){if(fs)throw new Error("scryptSync is locked");ms=t},Object.freeze(bs);const Ns="m/44'/60'/0'/0/0";function xs(t){try{const e=JSON.parse(t);if(3===(null!=e.version?parseInt(e.version):0))return!0}catch(t){}return!1}function Os(t,e){const n=Wt(e),r=Ps(t,"crypto.ciphertext:data!");Kt(Xt(en(Qt([n.slice(16,32),r]))).substring(2)===Ps(t,"crypto.mac:string!").toLowerCase(),"incorrect password","password","[ REDACTED ]");const i=function(t,e,n){if("aes-128-ctr"===Ps(t,"crypto.cipher:string")){const r=Ps(t,"crypto.cipherparams.iv:data!");return Xt(new rs(e,r).decrypt(n))}Vt(!1,"unsupported cipher","UNSUPPORTED_OPERATION",{operation:"decrypt"})}(t,n.slice(0,16),r),s=Qn(i);if(t.address){let e=t.address.toLowerCase();e.startsWith("0x")||(e="0x"+e),Kt(cn(e)===s,"keystore address/privateKey mismatch","address",t.address)}const o={address:s,privateKey:i};if("0.1"===Ps(t,"x-ethers.version:string")){const e=n.slice(32,64),r=Ps(t,"x-ethers.mnemonicCiphertext:data!"),i=Ps(t,"x-ethers.mnemonicCounter:data!"),s=new rs(e,i);o.mnemonic={path:Ps(t,"x-ethers.path:string")||Ns,locale:Ps(t,"x-ethers.locale:string")||"en",entropy:Xt(Wt(s.decrypt(r)))}}return o}function Ss(t){const e=Ps(t,"crypto.kdf:string");if(e&&"string"==typeof e){if("scrypt"===e.toLowerCase()){const n=Ps(t,"crypto.kdfparams.salt:data!"),r=Ps(t,"crypto.kdfparams.n:int!"),i=Ps(t,"crypto.kdfparams.r:int!"),s=Ps(t,"crypto.kdfparams.p:int!");Kt(r>0&&!(r&r-1),"invalid kdf.N","kdf.N",r),Kt(i>0&&s>0,"invalid kdf","kdf",e);const o=Ps(t,"crypto.kdfparams.dklen:int!");return Kt(32===o,"invalid kdf.dklen","kdf.dflen",o),{name:"scrypt",salt:n,N:r,r:i,p:s,dkLen:64}}if("pbkdf2"===e.toLowerCase()){const e=Ps(t,"crypto.kdfparams.salt:data!"),n=Ps(t,"crypto.kdfparams.prf:string!"),r=n.split("-").pop();Kt("sha256"===r||"sha512"===r,"invalid kdf.pdf","kdf.pdf",n);const i=Ps(t,"crypto.kdfparams.c:int!"),s=Ps(t,"crypto.kdfparams.dklen:int!");return Kt(32===s,"invalid kdf.dklen","kdf.dklen",s),{name:"pbkdf2",salt:e,count:i,dkLen:s,algorithm:r}}}Kt(!1,"unsupported key-derivation function","kdf",e)}function Rs(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}function Ts(t){const e=null!=t.salt?Wt(t.salt,"options.salt"):Jr(32);let n=1<<17,r=8,i=1;return t.scrypt&&(t.scrypt.N&&(n=t.scrypt.N),t.scrypt.r&&(r=t.scrypt.r),t.scrypt.p&&(i=t.scrypt.p)),Kt("number"==typeof n&&n>0&&Number.isSafeInteger(n)&&(BigInt(n)&BigInt(n-1))===BigInt(0),"invalid scrypt N parameter","options.N",n),Kt("number"==typeof r&&r>0&&Number.isSafeInteger(r),"invalid scrypt r parameter","options.r",r),Kt("number"==typeof i&&i>0&&Number.isSafeInteger(i),"invalid scrypt p parameter","options.p",i),{name:"scrypt",dkLen:32,salt:e,N:n,r:r,p:i}}function ks(t,e,n,r){const i=Wt(n.privateKey,"privateKey"),s=null!=r.iv?Wt(r.iv,"options.iv"):Jr(16);Kt(16===s.length,"invalid options.iv length","options.iv",r.iv);const o=null!=r.uuid?Wt(r.uuid,"options.uuid"):Jr(16);Kt(16===o.length,"invalid options.uuid length","options.uuid",r.iv);const a=t.slice(0,16),l=t.slice(16,32),c=Wt(new rs(a,s).encrypt(i)),u=en(Qt([l,c])),h={address:n.address.substring(2).toLowerCase(),id:vs(o),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:Xt(s).substring(2)},ciphertext:Xt(c).substring(2),kdf:"scrypt",kdfparams:{salt:Xt(e.salt).substring(2),n:e.N,dklen:32,p:e.p,r:e.r},mac:u.substring(2)}};if(n.mnemonic){const e=null!=r.client?r.client:`ethers/${Ut}`,i=n.mnemonic.path||Ns,s=n.mnemonic.locale||"en",o=t.slice(32,64),a=Wt(n.mnemonic.entropy,"account.mnemonic.entropy"),l=Jr(16),c=Wt(new rs(o,l).encrypt(a)),u=new Date,f="UTC--"+(u.getUTCFullYear()+"-"+Is(u.getUTCMonth()+1,2)+"-"+Is(u.getUTCDate(),2)+"T"+Is(u.getUTCHours(),2)+"-"+Is(u.getUTCMinutes(),2)+"-"+Is(u.getUTCSeconds(),2)+".0Z")+"--"+h.address;h["x-ethers"]={client:e,gethFilename:f,path:i,locale:s,mnemonicCounter:Xt(l).substring(2),mnemonicCiphertext:Xt(c).substring(2),version:"0.1"}}return JSON.stringify(h)}function Ls(t,e,n){null==n&&(n={});const r=As(e),i=Ts(n);return ks(Wt(bs(r,i.salt,i.N,i.r,i.p,64)),i,t,n)}async function Bs(t,e,n){null==n&&(n={});const r=As(e),i=Ts(n);return ks(Wt(await ws(r,i.salt,i.N,i.r,i.p,64,n.progressCallback)),i,t,n)}const Cs="m/44'/60'/0'/0/0",Us=new Uint8Array([66,105,116,99,111,105,110,32,115,101,101,100]),Fs=2147483648,Gs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");function $s(t,e){let n="";for(;t;)n="0123456789abcdef"[t%16]+n,t=Math.trunc(t/16);for(;n.length<2*e;)n="0"+n;return"0x"+n}function Ds(t){const e=Wt(t);return function(t){const e=Wt(t);let n=ue(e),r="";for(;n;)r=Xr[Number(n%ni)]+r,n/=ni;for(let t=0;t<e.length&&!e[t];t++)r=Xr[0]+r;return r}(Qt([e,ee(_n(_n(e)),0,4)]))}const zs={};function Vs(t,e,n,r){const i=new Uint8Array(37);t&Fs?(Vt(null!=r,"cannot derive child of neutered node","UNSUPPORTED_OPERATION",{operation:"deriveChild"}),i.set(Wt(r),1)):i.set(Wt(n));for(let e=24;e>=0;e-=8)i[33+(e>>3)]=t>>24-e&255;const s=Wt(Rr("sha512",e,i));return{IL:s.slice(0,32),IR:s.slice(32)}}function Ks(t,e){const n=e.split("/");Kt(n.length>0,"invalid path","path",e),"m"===n[0]&&(Kt(0===t.depth,`cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${t.depth}`,"path",e),n.shift());let r=t;for(let t=0;t<n.length;t++){const e=n[t];if(e.match(/^[0-9]+'$/)){const n=parseInt(e.substring(0,e.length-1));Kt(n<Fs,"invalid path index",`path[${t}]`,e),r=r.deriveChild(Fs+n)}else if(e.match(/^[0-9]+$/)){const n=parseInt(e);Kt(n<Fs,"invalid path index",`path[${t}]`,e),r=r.deriveChild(n)}else Kt(!1,"invalid path component",`path[${t}]`,e)}return r}class Ms extends Nr{publicKey;fingerprint;parentFingerprint;mnemonic;chainCode;path;index;depth;constructor(t,e,n,r,i,s,o,a,l){super(e,l),Ht(t,zs,"HDNodeWallet"),$t(this,{publicKey:e.compressedPublicKey});$t(this,{parentFingerprint:n,fingerprint:ee(Wr(_n(this.publicKey)),0,4),chainCode:r,path:i,index:s,depth:o}),$t(this,{mnemonic:a})}connect(t){return new Ms(zs,this.signingKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.mnemonic,t)}#B(){const t={address:this.address,privateKey:this.privateKey},e=this.mnemonic;return this.path&&e&&"en"===e.wordlist.locale&&""===e.password&&(t.mnemonic={path:this.path,locale:"en",entropy:e.entropy}),t}async encrypt(t,e){return await Bs(this.#B(),t,{progressCallback:e})}encryptSync(t){return Ls(this.#B(),t)}get extendedKey(){return Vt(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),Ds(Qt(["0x0488ADE4",$s(this.depth,1),this.parentFingerprint,$s(this.index,4),this.chainCode,Qt(["0x00",this.privateKey])]))}hasPath(){return null!=this.path}neuter(){return new _s(zs,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.provider)}deriveChild(t){const e=he(t,"index");Kt(e<=4294967295,"invalid index","index",e);let n=this.path;n&&(n+="/"+(2147483647&e),e&Fs&&(n+="'"));const{IR:r,IL:i}=Vs(e,this.chainCode,this.publicKey,this.privateKey),s=new Oe(fe((ue(i)+BigInt(this.privateKey))%Gs,32));return new Ms(zs,s,this.fingerprint,Xt(r),n,e,this.depth+1,this.mnemonic,this.provider)}derivePath(t){return Ks(this,t)}static#C(t,e){Kt(Yt(t),"invalid seed","seed","[REDACTED]");const n=Wt(t,"seed");Kt(n.length>=16&&n.length<=64,"invalid seed","seed","[REDACTED]");const r=Wt(Rr("sha512",Us,n)),i=new Oe(Xt(r.slice(0,32)));return new Ms(zs,i,"0x00000000",Xt(r.slice(32)),"m",0,0,e,null)}static fromExtendedKey(t){const e=de(function(t){let e=ei;for(let n=0;n<t.length;n++)e*=ni,e+=ti(t[n]);return e}(t));Kt(82===e.length||Ds(e.slice(0,78))===t,"invalid extended key","extendedKey","[ REDACTED ]");const n=e[4],r=Xt(e.slice(5,9)),i=parseInt(Xt(e.slice(9,13)).substring(2),16),s=Xt(e.slice(13,45)),o=e.slice(45,78);switch(Xt(e.slice(0,4))){case"0x0488b21e":case"0x043587cf":{const t=Xt(o);return new _s(zs,Qn(t),t,r,s,null,i,n,null)}case"0x0488ade4":case"0x04358394 ":if(0!==o[0])break;return new Ms(zs,new Oe(o.slice(1)),r,s,null,i,n,null,null)}Kt(!1,"invalid extended key prefix","extendedKey","[ REDACTED ]")}static createRandom(t,e,n){null==t&&(t=""),null==e&&(e=Cs),null==n&&(n=ui.wordlist());const r=vi.fromEntropy(Jr(16),t,n);return Ms.#C(r.computeSeed(),r).derivePath(e)}static fromMnemonic(t,e){return e||(e=Cs),Ms.#C(t.computeSeed(),t).derivePath(e)}static fromPhrase(t,e,n,r){null==e&&(e=""),null==n&&(n=Cs),null==r&&(r=ui.wordlist());const i=vi.fromPhrase(t,e,r);return Ms.#C(i.computeSeed(),i).derivePath(n)}static fromSeed(t){return Ms.#C(t,null)}}class _s extends Pr{publicKey;fingerprint;parentFingerprint;chainCode;path;index;depth;constructor(t,e,n,r,i,s,o,a,l){super(e,l),Ht(t,zs,"HDNodeVoidWallet"),$t(this,{publicKey:n});$t(this,{publicKey:n,fingerprint:ee(Wr(_n(n)),0,4),parentFingerprint:r,chainCode:i,path:s,index:o,depth:a})}connect(t){return new _s(zs,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,t)}get extendedKey(){return Vt(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),Ds(Qt(["0x0488B21E",$s(this.depth,1),this.parentFingerprint,$s(this.index,4),this.chainCode,this.publicKey]))}hasPath(){return null!=this.path}deriveChild(t){const e=he(t,"index");Kt(e<=4294967295,"invalid index","index",e);let n=this.path;n&&(n+="/"+(2147483647&e),e&Fs&&(n+="'"));const{IR:r,IL:i}=Vs(e,this.chainCode,this.publicKey,null),s=Oe.addPoints(i,this.publicKey,!0),o=Qn(s);return new _s(zs,o,s,this.fingerprint,Xt(r),n,e,this.depth+1,this.provider)}derivePath(t){return Ks(this,t)}}function Hs(t){try{if(JSON.parse(t).encseed)return!0}catch(t){}return!1}function js(t,e){const n=JSON.parse(t),r=As(e),i=cn(Ps(n,"ethaddr:string!")),s=Es(Ps(n,"encseed:string!"));Kt(s&&s.length%16==0,"invalid encseed","json",t);const o=Wt(pi(r,r,2e3,32,"sha256")).slice(0,16),a=s.slice(0,16),l=s.slice(16),c=function(t){if(t.length<16)throw new TypeError("PKCS#7 invalid length");const e=t[t.length-1];if(e>16)throw new TypeError("PKCS#7 padding byte out of range");const n=t.length-e;for(let r=0;r<e;r++)if(t[n+r]!==e)throw new TypeError("PKCS#7 invalid padding byte");return new Uint8Array(t.subarray(0,n))}(Wt(new Zi(o,a).decrypt(l)));let u="";for(let t=0;t<c.length;t++)u+=String.fromCharCode(c[t]);return{address:i,privateKey:vn(u)}}function Ws(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}class qs extends Nr{constructor(t,e){"string"!=typeof t||t.startsWith("0x")||(t="0x"+t),super("string"==typeof t?new Oe(t):t,e)}connect(t){return new qs(this.signingKey,t)}async encrypt(t,e){const n={address:this.address,privateKey:this.privateKey};return await Bs(n,t,{progressCallback:e})}encryptSync(t){return Ls({address:this.address,privateKey:this.privateKey},t)}static#U(t){if(Kt(t,"invalid JSON wallet","json","[ REDACTED ]"),"mnemonic"in t&&t.mnemonic&&"en"===t.mnemonic.locale){const e=vi.fromEntropy(t.mnemonic.entropy),n=Ms.fromMnemonic(e,t.mnemonic.path);if(n.address===t.address&&n.privateKey===t.privateKey)return n;console.log("WARNING: JSON mismatch address/privateKey != mnemonic; fallback onto private key")}const e=new qs(t.privateKey);return Kt(e.address===t.address,"address/privateKey mismatch","json","[ REDACTED ]"),e}static async fromEncryptedJson(t,e,n){let r=null;return xs(t)?r=await async function(t,e,n){const r=JSON.parse(t),i=As(e),s=Ss(r);if("pbkdf2"===s.name){n&&(n(0),await Rs(0));const{salt:t,count:e,dkLen:o,algorithm:a}=s,l=pi(i,t,e,o,a);return n&&(n(1),await Rs(0)),Os(r,l)}Vt("scrypt"===s.name,"cannot be reached","UNKNOWN_ERROR",{params:s});const{salt:o,N:a,r:l,p:c,dkLen:u}=s;return Os(r,await ws(i,o,a,l,c,u,n))}(t,e,n):Hs(t)&&(n&&(n(0),await Ws(0)),r=js(t,e),n&&(n(1),await Ws(0))),qs.#U(r)}static fromEncryptedJsonSync(t,e){let n=null;return xs(t)?n=function(t,e){const n=JSON.parse(t),r=As(e),i=Ss(n);if("pbkdf2"===i.name){const{salt:t,count:e,dkLen:s,algorithm:o}=i;return Os(n,pi(r,t,e,s,o))}Vt("scrypt"===i.name,"cannot be reached","UNKNOWN_ERROR",{params:i});const{salt:s,N:o,r:a,p:l,dkLen:c}=i;return Os(n,bs(r,s,o,a,l,c))}(t,e):Hs(t)?n=js(t,e):Kt(!1,"invalid JSON wallet","json","[ REDACTED ]"),qs.#U(n)}static createRandom(t){const e=Ms.createRandom();return t?e.connect(t):e}static fromPhrase(t,e){const n=Ms.fromPhrase(t);return e?n.connect(e):n}}}};
|
package/dist/77.index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.id=77,exports.ids=[77],exports.modules={37077:(e,t,o)=>{t.backtestCommand=async function(e,t){const a=t.venue||"kalshi",i=parseInt(t.days||"30"),l=parseInt(t.quantity||"50");let c,p=t.entryBelow?parseInt(t.entryBelow):void 0,d=t.entryAbove?parseInt(t.entryAbove):void 0,$=t.stop?parseInt(t.stop):void 0,y=t.tp?parseInt(t.tp):void 0;if(t.strategy&&t.thesis)try{const{SFClient:s}=await Promise.resolve().then(o.bind(o,19218)),n=new s,r=((await n.getStrategies(t.thesis,void 0)).strategies||[]).find(o=>o.id.startsWith(t.strategy)||o.marketId===e);r&&(p=p??r.entryBelow,d=d??r.entryAbove,$=$??r.stopLoss,y=y??r.takeProfit)}catch{}p||d||(console.error(` ${s.c.red}Error:${s.c.reset} Need --entry-below or --entry-above. Example: sf backtest KXFED --entry-below 35 --stop 20 --tp 60`),process.exit(1));t.json||(console.log(),console.log(` ${s.c.bold}Backtest${s.c.reset} ${e} (${i}d, ${a})`),console.log(` ${s.c.dim}Entry: ${p?`≤${p}¢`:""}${d?`≥${d}¢`:""} | Stop: ${$??"-"}¢ | TP: ${y??"-"}¢ | Qty: ${l}${s.c.reset}`),console.log());try{c=await n(e,a,i)}catch(e){console.error(` ${s.c.red}Error:${s.c.reset} Failed to fetch price history: ${e.message}`),process.exit(1)}0===c.length&&(console.error(` ${s.c.dim}No price data found for ${e}.${s.c.reset}`),process.exit(1));const g=r(c,{ticker:e,venue:a,entryBelow:p,entryAbove:d,stopLoss:$,takeProfit:y,quantity:l,days:i});if(t.json)return void console.log(JSON.stringify(g,null,2));const f=g.totalPnlCents>=0?s.c.green:s.c.red,u=g.totalPnlCents>=0?"+":"";if(console.log(` ${s.c.bold}Results${s.c.reset}`),console.log(` Data points ${g.dataPoints}`),console.log(` Trades ${g.totalTrades} (${g.wins}W / ${g.losses}L)`),console.log(` Win rate ${g.winRate}%`),console.log(` Total P&L ${f}${u}$${(g.totalPnlCents/100).toFixed(2)}${s.c.reset}`),console.log(` Max drawdown ${s.c.red}-$${(g.maxDrawdownCents/100).toFixed(2)}${s.c.reset}`),console.log(` Avg hold time ${g.avgHoldingPeriodHours}h`),console.log(),g.trades.length>0){console.log(` ${s.c.bold}Trade Log${s.c.reset}`);for(const e of g.trades){const t="entry"===e.type?`${s.c.cyan}→${s.c.reset}`:"take_profit"===e.type?`${s.c.green}✓${s.c.reset}`:`${s.c.red}✗${s.c.reset}`,o=0!==e.pnlCents?` ${e.pnlCents>0?s.c.green:s.c.red}${e.pnlCents>0?"+":""}$${(e.pnlCents/100).toFixed(2)}${s.c.reset}`:"",n="open"===e.timestamp?"still open":e.timestamp.slice(0,16).replace("T"," ");console.log(` ${t} ${e.type.padEnd(12)} ${e.price}¢ ${n}${o}`)}console.log()}},t.runBacktest=r,t.fetchPriceHistory=n;const s=o(99236);async function n(e,t,s){if("polymarket"===t){const{polymarketGetPriceHistory:t}=await Promise.resolve().then(o.bind(o,34331)),n=Math.floor((Date.now()-864e5*s)/1e3);return(await t({tokenId:e,startTs:n,fidelity:60})).map(e=>({t:e.t,p:Math.round(100*e.p)}))}const{getBatchCandlesticks:n}=await Promise.resolve().then(o.t.bind(o,96139,23)),r=Math.floor(Date.now()/1e3),a=r-86400*s,i=await n({tickers:[e],startTs:a,endTs:r,periodInterval:3600});if(i&&i.length>0)return i.map(e=>({t:new Date(e.end_period_ts||e.period_start||e.ts).getTime()/1e3,p:Math.round((e.yes_price||e.price||e.close||0)*(e.yes_price>1?1:100))})).filter(e=>e.p>0);const l=process.env.SF_API_URL||"https://simplefunctions.dev",c=new Date(Date.now()-864e5*s).toISOString(),p=await fetch(`${l}/api/changes?since=${encodeURIComponent(c)}&q=${encodeURIComponent(e)}&limit=500`);if(!p.ok)return[];return((await p.json()).changes||[]).filter(e=>null!=e.afterPrice).map(e=>({t:new Date(e.detectedAt).getTime()/1e3,p:e.afterPrice})).reverse()}function r(e,t){const o=[];let s=!1,n=0,r=0,a=0,i=0,l=0,c=0,p=0,d=0;for(const $ of e)if(s){let e=null;if(null!=t.stopLoss&&$.p<=t.stopLoss&&(e="stop_loss"),null!=t.takeProfit&&$.p>=t.takeProfit&&(e="take_profit"),e){const y=($.p-n)*t.quantity;a+=y,y>0?c++:p++,d+=($.t-r)/3600,o.push({type:e,price:$.p,timestamp:new Date(1e3*$.t).toISOString(),pnlCents:y}),s=!1,a>l&&(l=a);const g=l-a;g>i&&(i=g)}}else{let e=!1;null!=t.entryBelow&&$.p<=t.entryBelow&&(e=!0),null!=t.entryAbove&&$.p>=t.entryAbove&&(e=!0),e&&(s=!0,n=$.p,r=$.t,o.push({type:"entry",price:$.p,timestamp:new Date(1e3*$.t).toISOString(),pnlCents:0}))}if(s&&e.length>0){const s=e[e.length-1].p,r=(s-n)*t.quantity;a+=r,o.push({type:"take_profit",price:s,timestamp:"open",pnlCents:r})}const $=o.filter(e=>"entry"!==e.type).length;return{ticker:t.ticker,days:t.days,dataPoints:e.length,trades:o,totalTrades:$,wins:c,losses:p,totalPnlCents:Math.round(a),maxDrawdownCents:Math.round(i),winRate:$>0?Math.round(c/$*100):0,avgHoldingPeriodHours:$>0?Math.round(d/$):0,params:{entryBelow:t.entryBelow,entryAbove:t.entryAbove,stopLoss:t.stopLoss,takeProfit:t.takeProfit,quantity:t.quantity}}}}};
|