genosdb 0.10.7 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sm.min.js CHANGED
@@ -1,2 +1,2 @@
1
- var _Y=Object.defineProperty;var bY=($,Q)=>{for(var J in Q)_Y($,J,{get:Q[J],enumerable:!0,configurable:!0,set:(Y)=>Q[J]=()=>Y})};var P$="6.15.0";var xY=function($,Q,J){const Y=Q.split("|").map((Z)=>Z.trim());for(let Z=0;Z<Y.length;Z++)switch(Q){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof $===Q)return}const X=new Error(`invalid value for type ${Q}`);throw X.code="INVALID_ARGUMENT",X.argument=`value.${J}`,X.value=$,X};async function h0($){const Q=Object.keys($);return(await Promise.all(Q.map((Y)=>Promise.resolve($[Y])))).reduce((Y,X,Z)=>{return Y[Q[Z]]=X,Y},{})}function a($,Q,J){for(let Y in Q){let X=Q[Y];const Z=J?J[Y]:null;if(Z)xY(X,Z,Y);Object.defineProperty($,Y,{enumerable:!0,value:X,writable:!1})}}var y8=function($,Q){if($==null)return"null";if(Q==null)Q=new Set;if(typeof $==="object"){if(Q.has($))return"[Circular]";Q.add($)}if(Array.isArray($))return"[ "+$.map((J)=>y8(J,Q)).join(", ")+" ]";if($ instanceof Uint8Array){let Y="0x";for(let X=0;X<$.length;X++)Y+="0123456789abcdef"[$[X]>>4],Y+="0123456789abcdef"[$[X]&15];return Y}if(typeof $==="object"&&typeof $.toJSON==="function")return y8($.toJSON(),Q);switch(typeof $){case"boolean":case"number":case"symbol":return $.toString();case"bigint":return BigInt($).toString();case"string":return JSON.stringify($);case"object":{const J=Object.keys($);return J.sort(),"{ "+J.map((Y)=>`${y8(Y,Q)}: ${y8($[Y],Q)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"};function S$($,Q){return $&&$.code===Q}function X$($,Q,J){let Y=$;{const Z=[];if(J){if(("message"in J)||("code"in J)||("name"in J))throw new Error(`value will overwrite populated values: ${y8(J)}`);for(let M in J){if(M==="shortMessage")continue;const q=J[M];Z.push(M+"="+y8(q))}}if(Z.push(`code=${Q}`),Z.push(`version=${P$}`),Z.length)$+=" ("+Z.join(", ")+")"}let X;switch(Q){case"INVALID_ARGUMENT":X=new TypeError($);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":X=new RangeError($);break;default:X=new Error($)}if(a(X,{code:Q}),J)Object.assign(X,J);if(X.shortMessage==null)a(X,{shortMessage:Y});return X}function F($,Q,J,Y){if(!$)throw X$(Q,J,Y)}function O($,Q,J,Y){F($,Q,"INVALID_ARGUMENT",{argument:J,value:Y})}function c8($){F(vY.indexOf($)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:$}})}function n0($,Q,J){if(J==null)J="";if($!==Q){let Y=J,X="new";if(J)Y+=".",X+=" "+J;F(!1,`private constructor; use ${Y}from* methods`,"UNSUPPORTED_OPERATION",{operation:X})}}var vY=["NFD","NFC","NFKD","NFKC"].reduce(($,Q)=>{try{if("test".normalize(Q)!=="test")throw new Error("bad");if(Q==="NFD"){const J=String.fromCharCode(233).normalize("NFD"),Y=String.fromCharCode(101,769);if(J!==Y)throw new Error("broken")}$.push(Q)}catch(J){}return $},[]);var EQ=function($,Q,J){if($ instanceof Uint8Array){if(J)return new Uint8Array($);return $}if(typeof $==="string"&&$.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const Y=new Uint8Array(($.length-2)/2);let X=2;for(let Z=0;Z<Y.length;Z++)Y[Z]=parseInt($.substring(X,X+2),16),X+=2;return Y}O(!1,"invalid BytesLike value",Q||"value",$)};function C($,Q){return EQ($,Q,!1)}function b0($,Q){return EQ($,Q,!0)}function I0($,Q){if(typeof $!=="string"||!$.match(/^0x[0-9A-Fa-f]*$/))return!1;if(typeof Q==="number"&&$.length!==2+2*Q)return!1;if(Q===!0&&$.length%2!==0)return!1;return!0}function y0($){return I0($,!0)||$ instanceof Uint8Array}function H($){const Q=C($);let J="0x";for(let Y=0;Y<Q.length;Y++){const X=Q[Y];J+=CQ[(X&240)>>4]+CQ[X&15]}return J}function o($){return"0x"+$.map((Q)=>H(Q).substring(2)).join("")}function o0($){if(I0($,!0))return($.length-2)/2;return C($).length}function u8($,Q,J){const Y=C($);if(J!=null&&J>Y.length)F(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:Y,length:Y.length,offset:J});return H(Y.slice(Q==null?0:Q,J==null?Y.length:J))}var mY=function($,Q,J){const Y=C($);F(Q>=Y.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(Y),length:Q,offset:Q+1});const X=new Uint8Array(Q);if(X.fill(0),J)X.set(Y,Q-Y.length);else X.set(Y,0);return H(X)};function C0($,Q){return mY($,Q,!0)}var CQ="0123456789abcdef";function w$($,Q){let J=g($,"value");const Y=BigInt(q0(Q,"width")),X=C8<<Y-C8;if(J<N9){J=-J,F(J<=X,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:$});const Z=(C8<<Y)-C8;return(~J&Z)+C8}else F(J<X,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:$});return J}function A$($,Q){const J=Z$($,"value"),Y=BigInt(q0(Q,"bits"));return J&(C8<<Y)-C8}function g($,Q){switch(typeof $){case"bigint":return $;case"number":return O(Number.isInteger($),"underflow",Q||"value",$),O($>=-p8&&$<=p8,"overflow",Q||"value",$),BigInt($);case"string":try{if($==="")throw new Error("empty string");if($[0]==="-"&&$[1]!=="-")return-BigInt($.substring(1));return BigInt($)}catch(J){O(!1,`invalid BigNumberish string: ${J.message}`,Q||"value",$)}}O(!1,"invalid BigNumberish value",Q||"value",$)}function Z$($,Q){const J=g($,Q);return F(J>=N9,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:$}),J}function d8($){if($ instanceof Uint8Array){let Q="0x0";for(let J of $)Q+=PQ[J>>4],Q+=PQ[J&15];return BigInt(Q)}return g($)}function q0($,Q){switch(typeof $){case"bigint":return O($>=-p8&&$<=p8,"overflow",Q||"value",$),Number($);case"number":return O(Number.isInteger($),"underflow",Q||"value",$),O($>=-p8&&$<=p8,"overflow",Q||"value",$),$;case"string":try{if($==="")throw new Error("empty string");return q0(BigInt($),Q)}catch(J){O(!1,`invalid numeric string: ${J.message}`,Q||"value",$)}}O(!1,"invalid numeric value",Q||"value",$)}function x0($,Q){let Y=Z$($,"value").toString(16);if(Q==null){if(Y.length%2)Y="0"+Y}else{const X=q0(Q,"width");F(X*2>=Y.length,`value exceeds width (${X} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:$});while(Y.length<X*2)Y="0"+Y}return"0x"+Y}function s($){const Q=Z$($,"value");if(Q===N9)return new Uint8Array([]);let J=Q.toString(16);if(J.length%2)J="0"+J;const Y=new Uint8Array(J.length/2);for(let X=0;X<Y.length;X++){const Z=X*2;Y[X]=parseInt(J.substring(Z,Z+2),16)}return Y}function B$($){let Q=H(y0($)?$:s($)).substring(2);while(Q.startsWith("0"))Q=Q.substring(1);if(Q==="")Q="0";return"0x"+Q}var N9=BigInt(0),C8=BigInt(1),p8=9007199254740991,PQ="0123456789abcdef";var gY=function($){if(F$==null){F$={};for(let J=0;J<f$.length;J++)F$[f$[J]]=BigInt(J)}const Q=F$[$];return O(Q!=null,"invalid base58 value","letter",$),Q};function k$($){const Q=C($);let J=d8(Q),Y="";while(J)Y=f$[Number(J%C9)]+Y,J/=C9;for(let X=0;X<Q.length;X++){if(Q[X])break;Y=f$[0]+Y}return Y}function _$($){let Q=hY;for(let J=0;J<$.length;J++)Q*=C9,Q+=gY($[J]);return Q}var f$="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",F$=null,hY=BigInt(0),C9=BigInt(58);var yY=function($,Q,J,Y,X){O(!1,`invalid codepoint at offset ${Q}; ${$}`,"bytes",J)},SQ=function($,Q,J,Y,X){if($==="BAD_PREFIX"||$==="UNEXPECTED_CONTINUE"){let Z=0;for(let M=Q+1;M<J.length;M++){if(J[M]>>6!==2)break;Z++}return Z}if($==="OVERRUN")return J.length-Q-1;return 0},cY=function($,Q,J,Y,X){if($==="OVERLONG")return O(typeof X==="number","invalid bad code point for replacement","badCodepoint",X),Y.push(X),0;return Y.push(65533),SQ($,Q,J,Y,X)};function W0($,Q){if(O(typeof $==="string","invalid string value","str",$),Q!=null)c8(Q),$=$.normalize(Q);let J=[];for(let Y=0;Y<$.length;Y++){const X=$.charCodeAt(Y);if(X<128)J.push(X);else if(X<2048)J.push(X>>6|192),J.push(X&63|128);else if((X&64512)==55296){Y++;const Z=$.charCodeAt(Y);O(Y<$.length&&(Z&64512)===56320,"invalid surrogate pair","str",$);const M=65536+((X&1023)<<10)+(Z&1023);J.push(M>>18|240),J.push(M>>12&63|128),J.push(M>>6&63|128),J.push(M&63|128)}else J.push(X>>12|224),J.push(X>>6&63|128),J.push(X&63|128)}return new Uint8Array(J)}var wQ=Object.freeze({error:yY,ignore:SQ,replace:cY});var uY=function($){let Q=$.toString(16);while(Q.length<2)Q="0"+Q;return"0x"+Q},AQ=function($,Q,J){let Y=0;for(let X=0;X<J;X++)Y=Y*256+$[Q+X];return Y},BQ=function($,Q,J,Y){const X=[];while(J<Q+1+Y){const Z=FQ($,J);X.push(Z.result),J+=Z.consumed,F(J<=Q+1+Y,"child data too short","BUFFER_OVERRUN",{buffer:$,length:Y,offset:Q})}return{consumed:1+Y,result:X}},FQ=function($,Q){F($.length!==0,"data too short","BUFFER_OVERRUN",{buffer:$,length:0,offset:1});const J=(Y)=>{F(Y<=$.length,"data short segment too short","BUFFER_OVERRUN",{buffer:$,length:$.length,offset:Y})};if($[Q]>=248){const Y=$[Q]-247;J(Q+1+Y);const X=AQ($,Q+1,Y);return J(Q+1+Y+X),BQ($,Q,Q+1+Y,Y+X)}else if($[Q]>=192){const Y=$[Q]-192;return J(Q+1+Y),BQ($,Q,Q+1,Y)}else if($[Q]>=184){const Y=$[Q]-183;J(Q+1+Y);const X=AQ($,Q+1,Y);J(Q+1+Y+X);const Z=H($.slice(Q+1+Y,Q+1+Y+X));return{consumed:1+Y+X,result:Z}}else if($[Q]>=128){const Y=$[Q]-128;J(Q+1+Y);const X=H($.slice(Q+1,Q+1+Y));return{consumed:1+Y,result:X}}return{consumed:1,result:uY($[Q])}};function G8($){const Q=C($,"data"),J=FQ(Q,0);return O(J.consumed===Q.length,"unexpected junk after rlp payload","data",$),J.result}var fQ=function($){const Q=[];while($)Q.unshift($&255),$>>=8;return Q},_Q=function($){if(Array.isArray($)){let Y=[];if($.forEach(function(Z){Y=Y.concat(_Q(Z))}),Y.length<=55)return Y.unshift(192+Y.length),Y;const X=fQ(Y.length);return X.unshift(247+X.length),X.concat(Y)}const Q=Array.prototype.slice.call(C($,"object"));if(Q.length===1&&Q[0]<=127)return Q;else if(Q.length<=55)return Q.unshift(128+Q.length),Q;const J=fQ(Q.length);return J.unshift(183+J.length),J.concat(Q)};function w0($){let Q="0x";for(let J of _Q($))Q+=kQ[J>>4],Q+=kQ[J&15];return Q}var kQ="0123456789abcdef";function b$($){const Q=C($,"randomBytes");Q[6]=Q[6]&15|64,Q[8]=Q[8]&63|128;const J=H(Q);return[J.substring(2,10),J.substring(10,14),J.substring(14,18),J.substring(18,22),J.substring(22,34)].join("-")}var D0=function($){if(!Number.isSafeInteger($)||$<0)throw new Error(`Wrong positive integer: ${$}`)};var M$=function($,...Q){if(!($ instanceof Uint8Array))throw new Error("Expected Uint8Array");if(Q.length>0&&!Q.includes($.length))throw new Error(`Expected Uint8Array of length ${Q}, not of length=${$.length}`)},x$=function($){if(typeof $!=="function"||typeof $.create!=="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");D0($.outputLen),D0($.blockLen)},i0=function($,Q=!0){if($.destroyed)throw new Error("Hash instance has been destroyed");if(Q&&$.finished)throw new Error("Hash#digest() has already been called")},v$=function($,Q){M$($);const J=Q.outputLen;if($.length<J)throw new Error(`digestInto() expects output buffer of length at least ${J}`)};var m$=typeof globalThis==="object"&&("crypto"in globalThis)?globalThis.crypto:void 0;async function g$($,Q,J){let Y=Date.now();for(let X=0;X<$;X++){J(X);const Z=Date.now()-Y;if(Z>=0&&Z<Q)continue;await tY(),Y+=Z}}function eY($){if(typeof $!=="string")throw new Error(`utf8ToBytes expected string, got ${typeof $}`);return new Uint8Array((new TextEncoder()).encode($))}function c0($){if(typeof $==="string")$=eY($);if(!bQ($))throw new Error(`expected Uint8Array, got ${typeof $}`);return $}function xQ(...$){const Q=new Uint8Array($.reduce((Y,X)=>Y+X.length,0));let J=0;return $.forEach((Y)=>{if(!bQ(Y))throw new Error("Uint8Array expected");Q.set(Y,J),J+=Y.length}),Q}function h$($,Q){if(Q!==void 0&&$X.call(Q)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign($,Q)}function W8($){const Q=(Y)=>$().update(c0(Y)).digest(),J=$();return Q.outputLen=J.outputLen,Q.blockLen=J.blockLen,Q.create=()=>$(),Q}function vQ($=32){if(m$&&typeof m$.getRandomValues==="function")return m$.getRandomValues(new Uint8Array($));throw new Error("crypto.getRandomValues must be defined")}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */var bQ=($)=>$ instanceof Uint8Array;var l8=($)=>new Uint32Array($.buffer,$.byteOffset,Math.floor($.byteLength/4)),n8=($)=>new DataView($.buffer,$.byteOffset,$.byteLength),v0=($,Q)=>$<<32-Q|$>>>Q,sY=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!sY)throw new Error("Non little-endian hardware is not supported");var tY=async()=>{};class E8{clone(){return this._cloneInto()}}var $X={}.toString;class E9 extends E8{constructor($,Q){super();this.finished=!1,this.destroyed=!1,x$($);const J=c0(Q);if(this.iHash=$.create(),typeof this.iHash.update!=="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const Y=this.blockLen,X=new Uint8Array(Y);X.set(J.length>Y?$.create().update(J).digest():J);for(let Z=0;Z<X.length;Z++)X[Z]^=54;this.iHash.update(X),this.oHash=$.create();for(let Z=0;Z<X.length;Z++)X[Z]^=54^92;this.oHash.update(X),X.fill(0)}update($){return i0(this),this.iHash.update($),this}digestInto($){i0(this),M$($,this.outputLen),this.finished=!0,this.iHash.digestInto($),this.oHash.update($),this.oHash.digestInto($),this.destroy()}digest(){const $=new Uint8Array(this.oHash.outputLen);return this.digestInto($),$}_cloneInto($){$||($=Object.create(Object.getPrototypeOf(this),{}));const{oHash:Q,iHash:J,finished:Y,destroyed:X,blockLen:Z,outputLen:M}=this;return $=$,$.finished=Y,$.destroyed=X,$.blockLen=Z,$.outputLen=M,$.oHash=Q._cloneInto($.oHash),$.iHash=J._cloneInto($.iHash),$}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var P8=($,Q,J)=>new E9($,Q).update(J).digest();P8.create=($,Q)=>new E9($,Q);var QX=function($,Q,J,Y){x$($);const X=h$({dkLen:32,asyncTick:10},Y),{c:Z,dkLen:M,asyncTick:q}=X;if(D0(Z),D0(M),D0(q),Z<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const U=c0(Q),G=c0(J),W=new Uint8Array(M),V=P8.create($,U),I=V._cloneInto().update(G);return{c:Z,dkLen:M,asyncTick:q,DK:W,PRF:V,PRFSalt:I}},JX=function($,Q,J,Y,X){if($.destroy(),Q.destroy(),Y)Y.destroy();return X.fill(0),J};function q$($,Q,J,Y){const{c:X,dkLen:Z,DK:M,PRF:q,PRFSalt:U}=QX($,Q,J,Y);let G;const W=new Uint8Array(4),V=n8(W),I=new Uint8Array(q.outputLen);for(let E=1,z=0;z<Z;E++,z+=q.outputLen){const D=M.subarray(z,z+q.outputLen);V.setInt32(0,E,!1),(G=U._cloneInto(G)).update(W).digestInto(I),D.set(I.subarray(0,D.length));for(let R=1;R<X;R++){q._cloneInto(G).update(I).digestInto(I);for(let L=0;L<D.length;L++)D[L]^=I[L]}}return JX(q,U,M,G,I)}var YX=function($,Q,J,Y){if(typeof $.setBigUint64==="function")return $.setBigUint64(Q,J,Y);const X=BigInt(32),Z=BigInt(4294967295),M=Number(J>>X&Z),q=Number(J&Z),U=Y?4:0,G=Y?0:4;$.setUint32(Q+U,M,Y),$.setUint32(Q+G,q,Y)};class S8 extends E8{constructor($,Q,J,Y){super();this.blockLen=$,this.outputLen=Q,this.padOffset=J,this.isLE=Y,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array($),this.view=n8(this.buffer)}update($){i0(this);const{view:Q,buffer:J,blockLen:Y}=this;$=c0($);const X=$.length;for(let Z=0;Z<X;){const M=Math.min(Y-this.pos,X-Z);if(M===Y){const q=n8($);for(;Y<=X-Z;Z+=Y)this.process(q,Z);continue}if(J.set($.subarray(Z,Z+M),this.pos),this.pos+=M,Z+=M,this.pos===Y)this.process(Q,0),this.pos=0}return this.length+=$.length,this.roundClean(),this}digestInto($){i0(this),v$($,this),this.finished=!0;const{buffer:Q,view:J,blockLen:Y,isLE:X}=this;let{pos:Z}=this;if(Q[Z++]=128,this.buffer.subarray(Z).fill(0),this.padOffset>Y-Z)this.process(J,0),Z=0;for(let W=Z;W<Y;W++)Q[W]=0;YX(J,Y-8,BigInt(this.length*8),X),this.process(J,0);const M=n8($),q=this.outputLen;if(q%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const U=q/4,G=this.get();if(U>G.length)throw new Error("_sha2: outputLen bigger than state");for(let W=0;W<U;W++)M.setUint32(4*W,G[W],X)}digest(){const{buffer:$,outputLen:Q}=this;this.digestInto($);const J=$.slice(0,Q);return this.destroy(),J}_cloneInto($){$||($=new this.constructor),$.set(...this.get());const{blockLen:Q,buffer:J,length:Y,finished:X,destroyed:Z,pos:M}=this;if($.length=Y,$.pos=M,$.finished=X,$.destroyed=Z,Y%Q)$.buffer.set(J);return $}}var XX=($,Q,J)=>$&Q^~$&J,ZX=($,Q,J)=>$&Q^$&J^Q&J,MX=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]),O8=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),V8=new Uint32Array(64);class mQ extends S8{constructor(){super(64,32,8,!1);this.A=O8[0]|0,this.B=O8[1]|0,this.C=O8[2]|0,this.D=O8[3]|0,this.E=O8[4]|0,this.F=O8[5]|0,this.G=O8[6]|0,this.H=O8[7]|0}get(){const{A:$,B:Q,C:J,D:Y,E:X,F:Z,G:M,H:q}=this;return[$,Q,J,Y,X,Z,M,q]}set($,Q,J,Y,X,Z,M,q){this.A=$|0,this.B=Q|0,this.C=J|0,this.D=Y|0,this.E=X|0,this.F=Z|0,this.G=M|0,this.H=q|0}process($,Q){for(let W=0;W<16;W++,Q+=4)V8[W]=$.getUint32(Q,!1);for(let W=16;W<64;W++){const V=V8[W-15],I=V8[W-2],E=v0(V,7)^v0(V,18)^V>>>3,z=v0(I,17)^v0(I,19)^I>>>10;V8[W]=z+V8[W-7]+E+V8[W-16]|0}let{A:J,B:Y,C:X,D:Z,E:M,F:q,G:U,H:G}=this;for(let W=0;W<64;W++){const V=v0(M,6)^v0(M,11)^v0(M,25),I=G+V+XX(M,q,U)+MX[W]+V8[W]|0,z=(v0(J,2)^v0(J,13)^v0(J,22))+ZX(J,Y,X)|0;G=U,U=q,q=M,M=Z+I|0,Z=X,X=Y,Y=J,J=I+z|0}J=J+this.A|0,Y=Y+this.B|0,X=X+this.C|0,Z=Z+this.D|0,M=M+this.E|0,q=q+this.F|0,U=U+this.G|0,G=G+this.H|0,this.set(J,Y,X,Z,M,q,U,G)}roundClean(){V8.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}var r0=W8(()=>new mQ);var gQ=function($,Q=!1){if(Q)return{h:Number($&y$),l:Number($>>P9&y$)};return{h:Number($>>P9&y$)|0,l:Number($&y$)|0}},S9=function($,Q=!1){let J=new Uint32Array($.length),Y=new Uint32Array($.length);for(let X=0;X<$.length;X++){const{h:Z,l:M}=gQ($[X],Q);[J[X],Y[X]]=[Z,M]}return[J,Y]},KX=function($,Q,J,Y){const X=(Q>>>0)+(Y>>>0);return{h:$+J+(X/4294967296|0)|0,l:X|0}},y$=BigInt(4294967295),P9=BigInt(32),qX=($,Q)=>BigInt($>>>0)<<P9|BigInt(Q>>>0),UX=($,Q,J)=>$>>>J,GX=($,Q,J)=>$<<32-J|Q>>>J,WX=($,Q,J)=>$>>>J|Q<<32-J,OX=($,Q,J)=>$<<32-J|Q>>>J,VX=($,Q,J)=>$<<64-J|Q>>>J-32,zX=($,Q,J)=>$>>>J-32|Q<<64-J,IX=($,Q)=>Q,DX=($,Q)=>$,w9=($,Q,J)=>$<<J|Q>>>32-J,A9=($,Q,J)=>Q<<J|$>>>32-J,B9=($,Q,J)=>Q<<J-32|$>>>64-J,F9=($,Q,J)=>$<<J-32|Q>>>64-J,RX=($,Q,J)=>($>>>0)+(Q>>>0)+(J>>>0),TX=($,Q,J,Y)=>Q+J+Y+($/4294967296|0)|0,LX=($,Q,J,Y)=>($>>>0)+(Q>>>0)+(J>>>0)+(Y>>>0),jX=($,Q,J,Y,X)=>Q+J+Y+X+($/4294967296|0)|0,HX=($,Q,J,Y,X)=>($>>>0)+(Q>>>0)+(J>>>0)+(Y>>>0)+(X>>>0),NX=($,Q,J,Y,X,Z)=>Q+J+Y+X+Z+($/4294967296|0)|0;var CX={fromBig:gQ,split:S9,toBig:qX,shrSH:UX,shrSL:GX,rotrSH:WX,rotrSL:OX,rotrBH:VX,rotrBL:zX,rotr32H:IX,rotr32L:DX,rotlSH:w9,rotlSL:A9,rotlBH:B9,rotlBL:F9,add:KX,add3L:RX,add3H:TX,add4L:LX,add4H:jX,add5H:NX,add5L:HX},x=CX;var[EX,PX]=(()=>x.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(($)=>BigInt($))))(),z8=new Uint32Array(80),I8=new Uint32Array(80);class hQ extends S8{constructor(){super(128,64,16,!1);this.Ah=1779033703|0,this.Al=4089235720|0,this.Bh=3144134277|0,this.Bl=2227873595|0,this.Ch=1013904242|0,this.Cl=4271175723|0,this.Dh=2773480762|0,this.Dl=1595750129|0,this.Eh=1359893119|0,this.El=2917565137|0,this.Fh=2600822924|0,this.Fl=725511199|0,this.Gh=528734635|0,this.Gl=4215389547|0,this.Hh=1541459225|0,this.Hl=327033209|0}get(){const{Ah:$,Al:Q,Bh:J,Bl:Y,Ch:X,Cl:Z,Dh:M,Dl:q,Eh:U,El:G,Fh:W,Fl:V,Gh:I,Gl:E,Hh:z,Hl:D}=this;return[$,Q,J,Y,X,Z,M,q,U,G,W,V,I,E,z,D]}set($,Q,J,Y,X,Z,M,q,U,G,W,V,I,E,z,D){this.Ah=$|0,this.Al=Q|0,this.Bh=J|0,this.Bl=Y|0,this.Ch=X|0,this.Cl=Z|0,this.Dh=M|0,this.Dl=q|0,this.Eh=U|0,this.El=G|0,this.Fh=W|0,this.Fl=V|0,this.Gh=I|0,this.Gl=E|0,this.Hh=z|0,this.Hl=D|0}process($,Q){for(let S=0;S<16;S++,Q+=4)z8[S]=$.getUint32(Q),I8[S]=$.getUint32(Q+=4);for(let S=16;S<80;S++){const k=z8[S-15]|0,T=I8[S-15]|0,K=x.rotrSH(k,T,1)^x.rotrSH(k,T,8)^x.shrSH(k,T,7),N=x.rotrSL(k,T,1)^x.rotrSL(k,T,8)^x.shrSL(k,T,7),P=z8[S-2]|0,B=I8[S-2]|0,w=x.rotrSH(P,B,19)^x.rotrBH(P,B,61)^x.shrSH(P,B,6),f=x.rotrSL(P,B,19)^x.rotrBL(P,B,61)^x.shrSL(P,B,6),b=x.add4L(N,f,I8[S-7],I8[S-16]),y=x.add4H(b,K,w,z8[S-7],z8[S-16]);z8[S]=y|0,I8[S]=b|0}let{Ah:J,Al:Y,Bh:X,Bl:Z,Ch:M,Cl:q,Dh:U,Dl:G,Eh:W,El:V,Fh:I,Fl:E,Gh:z,Gl:D,Hh:R,Hl:L}=this;for(let S=0;S<80;S++){const k=x.rotrSH(W,V,14)^x.rotrSH(W,V,18)^x.rotrBH(W,V,41),T=x.rotrSL(W,V,14)^x.rotrSL(W,V,18)^x.rotrBL(W,V,41),K=W&I^~W&z,N=V&E^~V&D,P=x.add5L(L,T,N,PX[S],I8[S]),B=x.add5H(P,R,k,K,EX[S],z8[S]),w=P|0,f=x.rotrSH(J,Y,28)^x.rotrBH(J,Y,34)^x.rotrBH(J,Y,39),b=x.rotrSL(J,Y,28)^x.rotrBL(J,Y,34)^x.rotrBL(J,Y,39),y=J&X^J&M^X&M,e=Y&Z^Y&q^Z&q;R=z|0,L=D|0,z=I|0,D=E|0,I=W|0,E=V|0,{h:W,l:V}=x.add(U|0,G|0,B|0,w|0),U=M|0,G=q|0,M=X|0,q=Z|0,X=J|0,Z=Y|0;const u=x.add3L(w,b,e);J=x.add3H(u,B,f,y),Y=u|0}({h:J,l:Y}=x.add(this.Ah|0,this.Al|0,J|0,Y|0)),{h:X,l:Z}=x.add(this.Bh|0,this.Bl|0,X|0,Z|0),{h:M,l:q}=x.add(this.Ch|0,this.Cl|0,M|0,q|0),{h:U,l:G}=x.add(this.Dh|0,this.Dl|0,U|0,G|0),{h:W,l:V}=x.add(this.Eh|0,this.El|0,W|0,V|0),{h:I,l:E}=x.add(this.Fh|0,this.Fl|0,I|0,E|0),{h:z,l:D}=x.add(this.Gh|0,this.Gl|0,z|0,D|0),{h:R,l:L}=x.add(this.Hh|0,this.Hl|0,R|0,L|0),this.set(J,Y,X,Z,M,q,U,G,W,V,I,E,z,D,R,L)}roundClean(){z8.fill(0),I8.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}var c$=W8(()=>new hQ);var SX=function(){if(typeof self!=="undefined")return self;if(typeof window!=="undefined")return window;if(typeof window!=="undefined")return window;throw new Error("unable to locate global object")};function f9($){switch($){case"sha256":return r0.create();case"sha512":return c$.create()}O(!1,"invalid hashing algorithm name","algorithm",$)}function uQ($,Q){const J={sha256:r0,sha512:c$}[$];return O(J!=null,"invalid hmac algorithm","algorithm",$),P8.create(J,Q)}function pQ($,Q,J,Y,X){const Z={sha256:r0,sha512:c$}[X];return O(Z!=null,"invalid pbkdf2 algorithm","algorithm",X),q$(Z,$,Q,{c:J,dkLen:Y})}function dQ($){F(cQ!=null,"platform does not support secure random numbers","UNSUPPORTED_OPERATION",{operation:"randomBytes"}),O(Number.isInteger($)&&$>0&&$<=1024,"invalid length","length",$);const Q=new Uint8Array($);return cQ.getRandomValues(Q),Q}var yQ=SX(),cQ=yQ.crypto||yQ.msCrypto;function a0($,Q,J){const Y=C(Q,"key"),X=C(J,"data");return H(oQ($,Y,X))}var lQ=!1,nQ=function($,Q,J){return uQ($,Q).update(J).digest()},oQ=nQ;a0._=nQ;a0.lock=function(){lQ=!0};a0.register=function($){if(lQ)throw new Error("computeHmac is locked");oQ=$};Object.freeze(a0);function bX($,Q=24){const J=new Uint32Array(10);for(let Y=24-Q;Y<24;Y++){for(let M=0;M<10;M++)J[M]=$[M]^$[M+10]^$[M+20]^$[M+30]^$[M+40];for(let M=0;M<10;M+=2){const q=(M+8)%10,U=(M+2)%10,G=J[U],W=J[U+1],V=iQ(G,W,1)^J[q],I=rQ(G,W,1)^J[q+1];for(let E=0;E<50;E+=10)$[M+E]^=V,$[M+E+1]^=I}let X=$[2],Z=$[3];for(let M=0;M<24;M++){const q=sQ[M],U=iQ(X,Z,q),G=rQ(X,Z,q),W=aQ[M];X=$[W],Z=$[W+1],$[W]=U,$[W+1]=G}for(let M=0;M<50;M+=10){for(let q=0;q<10;q++)J[q]=$[M+q];for(let q=0;q<10;q++)$[M+q]^=~J[(q+2)%10]&J[(q+4)%10]}$[0]^=kX[Y],$[1]^=_X[Y]}J.fill(0)}var[aQ,sQ,tQ]=[[],[],[]],wX=BigInt(0),U$=BigInt(1),AX=BigInt(2),BX=BigInt(7),FX=BigInt(256),fX=BigInt(113);for(let $=0,Q=U$,J=1,Y=0;$<24;$++){[J,Y]=[Y,(2*J+3*Y)%5],aQ.push(2*(5*Y+J)),sQ.push(($+1)*($+2)/2%64);let X=wX;for(let Z=0;Z<7;Z++)if(Q=(Q<<U$^(Q>>BX)*fX)%FX,Q&AX)X^=U$<<(U$<<BigInt(Z))-U$;tQ.push(X)}var[kX,_X]=S9(tQ,!0),iQ=($,Q,J)=>J>32?B9($,Q,J):w9($,Q,J),rQ=($,Q,J)=>J>32?F9($,Q,J):A9($,Q,J);class k9 extends E8{constructor($,Q,J,Y=!1,X=24){super();if(this.blockLen=$,this.suffix=Q,this.outputLen=J,this.enableXOF=Y,this.rounds=X,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,D0(J),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=l8(this.state)}keccak(){bX(this.state32,this.rounds),this.posOut=0,this.pos=0}update($){i0(this);const{blockLen:Q,state:J}=this;$=c0($);const Y=$.length;for(let X=0;X<Y;){const Z=Math.min(Q-this.pos,Y-X);for(let M=0;M<Z;M++)J[this.pos++]^=$[X++];if(this.pos===Q)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:$,suffix:Q,pos:J,blockLen:Y}=this;if($[J]^=Q,(Q&128)!==0&&J===Y-1)this.keccak();$[Y-1]^=128,this.keccak()}writeInto($){i0(this,!1),M$($),this.finish();const Q=this.state,{blockLen:J}=this;for(let Y=0,X=$.length;Y<X;){if(this.posOut>=J)this.keccak();const Z=Math.min(J-this.posOut,X-Y);$.set(Q.subarray(this.posOut,this.posOut+Z),Y),this.posOut+=Z,Y+=Z}return $}xofInto($){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto($)}xof($){return D0($),this.xofInto(new Uint8Array($))}digestInto($){if(v$($,this),this.finished)throw new Error("digest() was already called");return this.writeInto($),this.destroy(),$}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto($){const{blockLen:Q,suffix:J,outputLen:Y,rounds:X,enableXOF:Z}=this;return $||($=new k9(Q,J,Y,Z,X)),$.state32.set(this.state32),$.pos=this.pos,$.posOut=this.posOut,$.finished=this.finished,$.rounds=X,$.suffix=J,$.outputLen=Y,$.enableXOF=Z,$.destroyed=this.destroyed,$}}var xX=($,Q,J)=>W8(()=>new k9(Q,$,J));var eQ=xX(1,136,32);function n($){const Q=C($,"data");return H(JJ(Q))}var $J=!1,QJ=function($){return eQ($)},JJ=QJ;n._=QJ;n.lock=function(){$J=!0};n.register=function($){if($J)throw new TypeError("keccak256 is locked");JJ=$};Object.freeze(n);var YJ=function($,Q,J,Y){if($===0)return Q^J^Y;else if($===1)return Q&J|~Q&Y;else if($===2)return(Q|~J)^Y;else if($===3)return Q&Y|J&~Y;else return Q^(J|~Y)},vX=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),XJ=Uint8Array.from({length:16},($,Q)=>Q),mX=XJ.map(($)=>(9*$+5)%16),_9=[XJ],b9=[mX];for(let $=0;$<4;$++)for(let Q of[_9,b9])Q.push(Q[$].map((J)=>vX[J]));var ZJ=[[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(($)=>new Uint8Array($)),gX=_9.map(($,Q)=>$.map((J)=>ZJ[Q][J])),hX=b9.map(($,Q)=>$.map((J)=>ZJ[Q][J])),yX=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),cX=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),u$=($,Q)=>$<<Q|$>>>32-Q,p$=new Uint32Array(16);class MJ extends S8{constructor(){super(64,20,8,!0);this.h0=1732584193|0,this.h1=4023233417|0,this.h2=2562383102|0,this.h3=271733878|0,this.h4=3285377520|0}get(){const{h0:$,h1:Q,h2:J,h3:Y,h4:X}=this;return[$,Q,J,Y,X]}set($,Q,J,Y,X){this.h0=$|0,this.h1=Q|0,this.h2=J|0,this.h3=Y|0,this.h4=X|0}process($,Q){for(let I=0;I<16;I++,Q+=4)p$[I]=$.getUint32(Q,!0);let J=this.h0|0,Y=J,X=this.h1|0,Z=X,M=this.h2|0,q=M,U=this.h3|0,G=U,W=this.h4|0,V=W;for(let I=0;I<5;I++){const E=4-I,z=yX[I],D=cX[I],R=_9[I],L=b9[I],S=gX[I],k=hX[I];for(let T=0;T<16;T++){const K=u$(J+YJ(I,X,M,U)+p$[R[T]]+z,S[T])+W|0;J=W,W=U,U=u$(M,10)|0,M=X,X=K}for(let T=0;T<16;T++){const K=u$(Y+YJ(E,Z,q,G)+p$[L[T]]+D,k[T])+V|0;Y=V,V=G,G=u$(q,10)|0,q=Z,Z=K}}this.set(this.h1+M+G|0,this.h2+U+V|0,this.h3+W+Y|0,this.h4+J+Z|0,this.h0+X+q|0)}roundClean(){p$.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}var qJ=W8(()=>new MJ);function s0($){const Q=C($,"data");return H(WJ(Q))}var UJ=!1,GJ=function($){return qJ($)},WJ=GJ;s0._=GJ;s0.lock=function(){UJ=!0};s0.register=function($){if(UJ)throw new TypeError("ripemd160 is locked");WJ=$};Object.freeze(s0);function E0($,Q,J,Y,X){const Z=C($,"password"),M=C(Q,"salt");return H(zJ(Z,M,J,Y,X))}var OJ=!1,VJ=function($,Q,J,Y,X){return pQ($,Q,J,Y,X)},zJ=VJ;E0._=VJ;E0.lock=function(){OJ=!0};E0.register=function($){if(OJ)throw new Error("pbkdf2 is locked");zJ=$};Object.freeze(E0);function Z0($){return KJ($)}var IJ=!1,DJ=function($){return new Uint8Array(dQ($))},KJ=DJ;Z0._=DJ;Z0.lock=function(){IJ=!0};Z0.register=function($){if(IJ)throw new Error("randomBytes is locked");KJ=$};Object.freeze(Z0);var RJ=function($,Q,J,Y,X,Z){let M=$[Q++]^J[Y++],q=$[Q++]^J[Y++],U=$[Q++]^J[Y++],G=$[Q++]^J[Y++],W=$[Q++]^J[Y++],V=$[Q++]^J[Y++],I=$[Q++]^J[Y++],E=$[Q++]^J[Y++],z=$[Q++]^J[Y++],D=$[Q++]^J[Y++],R=$[Q++]^J[Y++],L=$[Q++]^J[Y++],S=$[Q++]^J[Y++],k=$[Q++]^J[Y++],T=$[Q++]^J[Y++],K=$[Q++]^J[Y++],N=M,P=q,B=U,w=G,f=W,b=V,y=I,e=E,u=z,j=D,A=R,_=L,v=S,c=k,l=T,p=K;for(let z0=0;z0<8;z0+=2)f^=d(N+v|0,7),u^=d(f+N|0,9),v^=d(u+f|0,13),N^=d(v+u|0,18),j^=d(b+P|0,7),c^=d(j+b|0,9),P^=d(c+j|0,13),b^=d(P+c|0,18),l^=d(A+y|0,7),B^=d(l+A|0,9),y^=d(B+l|0,13),A^=d(y+B|0,18),w^=d(p+_|0,7),e^=d(w+p|0,9),_^=d(e+w|0,13),p^=d(_+e|0,18),P^=d(N+w|0,7),B^=d(P+N|0,9),w^=d(B+P|0,13),N^=d(w+B|0,18),y^=d(b+f|0,7),e^=d(y+b|0,9),f^=d(e+y|0,13),b^=d(f+e|0,18),_^=d(A+j|0,7),u^=d(_+A|0,9),j^=d(u+_|0,13),A^=d(j+u|0,18),v^=d(p+l|0,7),c^=d(v+p|0,9),l^=d(c+v|0,13),p^=d(l+c|0,18);X[Z++]=M+N|0,X[Z++]=q+P|0,X[Z++]=U+B|0,X[Z++]=G+w|0,X[Z++]=W+f|0,X[Z++]=V+b|0,X[Z++]=I+y|0,X[Z++]=E+e|0,X[Z++]=z+u|0,X[Z++]=D+j|0,X[Z++]=R+A|0,X[Z++]=L+_|0,X[Z++]=S+v|0,X[Z++]=k+c|0,X[Z++]=T+l|0,X[Z++]=K+p|0},o8=function($,Q,J,Y,X){let Z=Y+0,M=Y+16*X;for(let q=0;q<16;q++)J[M+q]=$[Q+(2*X-1)*16+q];for(let q=0;q<X;q++,Z+=16,Q+=16){if(RJ(J,M,$,Q,J,Z),q>0)M+=16;RJ(J,Z,$,Q+=16,J,M)}},TJ=function($,Q,J){const Y=h$({dkLen:32,asyncTick:10,maxmem:1073742848},J),{N:X,r:Z,p:M,dkLen:q,asyncTick:U,maxmem:G,onProgress:W}=Y;if(D0(X),D0(Z),D0(M),D0(q),D0(U),D0(G),W!==void 0&&typeof W!=="function")throw new Error("progressCb should be function");const V=128*Z,I=V/4;if(X<=1||(X&X-1)!==0||X>=2**(V/8)||X>4294967296)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(M<0||M>137438953440/V)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(q<0||q>137438953440)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");const E=V*(X+M);if(E>G)throw new Error(`Scrypt: parameters too large, ${E} (128 * r * (N + p)) > ${G} (maxmem)`);const z=q$(r0,$,Q,{c:1,dkLen:V*M}),D=l8(z),R=l8(new Uint8Array(V*X)),L=l8(new Uint8Array(V));let S=()=>{};if(W){const k=2*X*M,T=Math.max(Math.floor(k/1e4),1);let K=0;S=()=>{if(K++,W&&(!(K%T)||K===k))W(K/k)}}return{N:X,r:Z,p:M,dkLen:q,blockSize32:I,V:R,B32:D,B:z,tmp:L,blockMixCb:S,asyncTick:U}},LJ=function($,Q,J,Y,X){const Z=q$(r0,$,J,{c:1,dkLen:Q});return J.fill(0),Y.fill(0),X.fill(0),Z};function jJ($,Q,J){const{N:Y,r:X,p:Z,dkLen:M,blockSize32:q,V:U,B32:G,B:W,tmp:V,blockMixCb:I}=TJ($,Q,J);for(let E=0;E<Z;E++){const z=q*E;for(let D=0;D<q;D++)U[D]=G[z+D];for(let D=0,R=0;D<Y-1;D++)o8(U,R,U,R+=q,X),I();o8(U,(Y-1)*q,G,z,X),I();for(let D=0;D<Y;D++){const R=G[z+q-16]%Y;for(let L=0;L<q;L++)V[L]=G[z+L]^U[R*q+L];o8(V,0,G,z,X),I()}}return LJ($,M,W,U,V)}async function HJ($,Q,J){const{N:Y,r:X,p:Z,dkLen:M,blockSize32:q,V:U,B32:G,B:W,tmp:V,blockMixCb:I,asyncTick:E}=TJ($,Q,J);for(let z=0;z<Z;z++){const D=q*z;for(let L=0;L<q;L++)U[L]=G[D+L];let R=0;await g$(Y-1,E,()=>{o8(U,R,U,R+=q,X),I()}),o8(U,(Y-1)*q,G,D,X),I(),await g$(Y,E,()=>{const L=G[D+q-16]%Y;for(let S=0;S<q;S++)V[S]=G[D+S]^U[L*q+S];o8(V,0,G,D,X),I()})}return LJ($,M,W,U,V)}var d=($,Q)=>$<<Q|$>>>32-Q;async function t0($,Q,J,Y,X,Z,M){const q=C($,"passwd"),U=C(Q,"salt");return H(await SJ(q,U,J,Y,X,Z,M))}function e0($,Q,J,Y,X,Z){const M=C($,"passwd"),q=C(Q,"salt");return H(wJ(M,q,J,Y,X,Z))}var NJ=!1,CJ=!1,EJ=async function($,Q,J,Y,X,Z,M){return await HJ($,Q,{N:J,r:Y,p:X,dkLen:Z,onProgress:M})},PJ=function($,Q,J,Y,X,Z){return jJ($,Q,{N:J,r:Y,p:X,dkLen:Z})},SJ=EJ,wJ=PJ;t0._=EJ;t0.lock=function(){CJ=!0};t0.register=function($){if(CJ)throw new Error("scrypt is locked");SJ=$};Object.freeze(t0);e0._=PJ;e0.lock=function(){NJ=!0};e0.register=function($){if(NJ)throw new Error("scryptSync is locked");wJ=$};Object.freeze(e0);function O0($){const Q=C($,"data");return H(FJ(Q))}function G$($){const Q=C($,"data");return H(fJ(Q))}var AJ=function($){return f9("sha256").update($).digest()},BJ=function($){return f9("sha512").update($).digest()},FJ=AJ,fJ=BJ,kJ=!1,_J=!1;O0._=AJ;O0.lock=function(){kJ=!0};O0.register=function($){if(kJ)throw new Error("sha256 is locked");FJ=$};Object.freeze(O0);G$._=BJ;G$.lock=function(){_J=!0};G$.register=function($){if(_J)throw new Error("sha512 is locked");fJ=$};Object.freeze(O0);var g9={};bY(g9,{validateObject:()=>{{return K8}},utf8ToBytes:()=>{{return nX}},numberToVarBytesBE:()=>{{return dX}},numberToHexUnpadded:()=>{{return vJ}},numberToBytesLE:()=>{{return o$}},numberToBytesBE:()=>{{return D8}},hexToNumber:()=>{{return v9}},hexToBytes:()=>{{return A8}},equalBytes:()=>{{return lX}},ensureBytes:()=>{{return P0}},createHmacDrbg:()=>{{return m9}},concatBytes:()=>{{return i8}},bytesToNumberLE:()=>{{return n$}},bytesToNumberBE:()=>{{return $8}},bytesToHex:()=>{{return w8}},bitSet:()=>{{return rX}},bitMask:()=>{{return W$}},bitLen:()=>{{return oX}},bitGet:()=>{{return iX}}});function w8($){if(!l$($))throw new Error("Uint8Array expected");let Q="";for(let J=0;J<$.length;J++)Q+=pX[$[J]];return Q}function vJ($){const Q=$.toString(16);return Q.length&1?`0${Q}`:Q}function v9($){if(typeof $!=="string")throw new Error("hex string expected, got "+typeof $);return BigInt($===""?"0":`0x${$}`)}function A8($){if(typeof $!=="string")throw new Error("hex string expected, got "+typeof $);const Q=$.length;if(Q%2)throw new Error("padded hex string expected, got unpadded hex of length "+Q);const J=new Uint8Array(Q/2);for(let Y=0;Y<J.length;Y++){const X=Y*2,Z=$.slice(X,X+2),M=Number.parseInt(Z,16);if(Number.isNaN(M)||M<0)throw new Error("Invalid byte sequence");J[Y]=M}return J}function $8($){return v9(w8($))}function n$($){if(!l$($))throw new Error("Uint8Array expected");return v9(w8(Uint8Array.from($).reverse()))}function D8($,Q){return A8($.toString(16).padStart(Q*2,"0"))}function o$($,Q){return D8($,Q).reverse()}function dX($){return A8(vJ($))}function P0($,Q,J){let Y;if(typeof Q==="string")try{Y=A8(Q)}catch(Z){throw new Error(`${$} must be valid hex string, got "${Q}". Cause: ${Z}`)}else if(l$(Q))Y=Uint8Array.from(Q);else throw new Error(`${$} must be hex string or Uint8Array`);const X=Y.length;if(typeof J==="number"&&X!==J)throw new Error(`${$} expected ${J} bytes, got ${X}`);return Y}function i8(...$){const Q=new Uint8Array($.reduce((Y,X)=>Y+X.length,0));let J=0;return $.forEach((Y)=>{if(!l$(Y))throw new Error("Uint8Array expected");Q.set(Y,J),J+=Y.length}),Q}function lX($,Q){if($.length!==Q.length)return!1;for(let J=0;J<$.length;J++)if($[J]!==Q[J])return!1;return!0}function nX($){if(typeof $!=="string")throw new Error(`utf8ToBytes expected string, got ${typeof $}`);return new Uint8Array((new TextEncoder()).encode($))}function oX($){let Q;for(Q=0;$>xJ;$>>=d$,Q+=1);return Q}function iX($,Q){return $>>BigInt(Q)&d$}function m9($,Q,J){if(typeof $!=="number"||$<2)throw new Error("hashLen must be a number");if(typeof Q!=="number"||Q<2)throw new Error("qByteLen must be a number");if(typeof J!=="function")throw new Error("hmacFn must be a function");let Y=x9($),X=x9($),Z=0;const M=()=>{Y.fill(1),X.fill(0),Z=0},q=(...V)=>J(X,Y,...V),U=(V=x9())=>{if(X=q(bJ([0]),V),Y=q(),V.length===0)return;X=q(bJ([1]),V),Y=q()},G=()=>{if(Z++>=1000)throw new Error("drbg: tried 1000 values");let V=0;const I=[];while(V<Q){Y=q();const E=Y.slice();I.push(E),V+=Y.length}return i8(...I)};return(V,I)=>{M(),U(V);let E=void 0;while(!(E=I(G())))U();return M(),E}}function K8($,Q,J={}){const Y=(X,Z,M)=>{const q=aX[Z];if(typeof q!=="function")throw new Error(`Invalid validator "${Z}", expected function`);const U=$[X];if(M&&U===void 0)return;if(!q(U,$))throw new Error(`Invalid param ${String(X)}=${U} (${typeof U}), expected ${Z}`)};for(let[X,Z]of Object.entries(Q))Y(X,Z,!1);for(let[X,Z]of Object.entries(J))Y(X,Z,!0);return $}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var xJ=BigInt(0),d$=BigInt(1),uX=BigInt(2),l$=($)=>$ instanceof Uint8Array,pX=Array.from({length:256},($,Q)=>Q.toString(16).padStart(2,"0")),rX=($,Q,J)=>{return $|(J?d$:xJ)<<BigInt(Q)},W$=($)=>(uX<<BigInt($-1))-d$,x9=($)=>new Uint8Array($),bJ=($)=>Uint8Array.from($),aX={bigint:($)=>typeof $==="bigint",function:($)=>typeof $==="function",boolean:($)=>typeof $==="boolean",string:($)=>typeof $==="string",stringOrUint8Array:($)=>typeof $==="string"||$ instanceof Uint8Array,isSafeInteger:($)=>Number.isSafeInteger($),array:($)=>Array.isArray($),field:($,Q)=>Q.Fp.isValid($),hash:($)=>typeof $==="function"&&Number.isSafeInteger($.outputLen)};function K0($,Q){const J=$%Q;return J>=M0?J:Q+J}function $Z($,Q,J){if(J<=M0||Q<M0)throw new Error("Expected power/modulo > 0");if(J===Y0)return M0;let Y=Y0;while(Q>M0){if(Q&Y0)Y=Y*$%J;$=$*$%J,Q>>=Y0}return Y}function S0($,Q,J){let Y=$;while(Q-- >M0)Y*=Y,Y%=J;return Y}function i$($,Q){if($===M0||Q<=M0)throw new Error(`invert: expected positive integers, got n=${$} mod=${Q}`);let J=K0($,Q),Y=Q,X=M0,Z=Y0,M=Y0,q=M0;while(J!==M0){const G=Y/J,W=Y%J,V=X-M*G,I=Z-q*G;Y=J,J=W,X=M,Z=q,M=V,q=I}if(Y!==Y0)throw new Error("invert: does not exist");return K0(X,Q)}function QZ($){const Q=($-Y0)/B8;let J,Y,X;for(J=$-Y0,Y=0;J%B8===M0;J/=B8,Y++);for(X=B8;X<$&&$Z(X,Q,$)!==$-Y0;X++);if(Y===1){const M=($+Y0)/h9;return function q(U,G){const W=U.pow(G,M);if(!U.eql(U.sqr(W),G))throw new Error("Cannot find square root");return W}}const Z=(J+Y0)/B8;return function M(q,U){if(q.pow(U,Q)===q.neg(q.ONE))throw new Error("Cannot find square root");let G=Y,W=q.pow(q.mul(q.ONE,X),J),V=q.pow(U,Z),I=q.pow(U,J);while(!q.eql(I,q.ONE)){if(q.eql(I,q.ZERO))return q.ZERO;let E=1;for(let D=q.sqr(I);E<G;E++){if(q.eql(D,q.ONE))break;D=q.sqr(D)}const z=q.pow(W,Y0<<BigInt(G-E-1));W=q.sqr(z),V=q.mul(V,z),I=q.mul(I,W),G=E}return V}}function JZ($){if($%h9===sX){const Q=($+Y0)/h9;return function J(Y,X){const Z=Y.pow(X,Q);if(!Y.eql(Y.sqr(Z),X))throw new Error("Cannot find square root");return Z}}if($%gJ===mJ){const Q=($-mJ)/gJ;return function J(Y,X){const Z=Y.mul(X,B8),M=Y.pow(Z,Q),q=Y.mul(X,M),U=Y.mul(Y.mul(q,B8),M),G=Y.mul(q,Y.sub(U,Y.ONE));if(!Y.eql(Y.sqr(G),X))throw new Error("Cannot find square root");return G}}if($%eX===tX);return QZ($)}function y9($){const Q={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},J=YZ.reduce((Y,X)=>{return Y[X]="function",Y},Q);return K8($,J)}function XZ($,Q,J){if(J<M0)throw new Error("Expected power > 0");if(J===M0)return $.ONE;if(J===Y0)return Q;let Y=$.ONE,X=Q;while(J>M0){if(J&Y0)Y=$.mul(Y,X);X=$.sqr(X),J>>=Y0}return Y}function ZZ($,Q){const J=new Array(Q.length),Y=Q.reduce((Z,M,q)=>{if($.is0(M))return Z;return J[q]=Z,$.mul(Z,M)},$.ONE),X=$.inv(Y);return Q.reduceRight((Z,M,q)=>{if($.is0(M))return Z;return J[q]=$.mul(Z,J[q]),$.mul(Z,M)},X),J}function c9($,Q){const J=Q!==void 0?Q:$.toString(2).length,Y=Math.ceil(J/8);return{nBitLength:J,nByteLength:Y}}function hJ($,Q,J=!1,Y={}){if($<=M0)throw new Error(`Expected Field ORDER > 0, got ${$}`);const{nBitLength:X,nByteLength:Z}=c9($,Q);if(Z>2048)throw new Error("Field lengths over 2048 bytes are not supported");const M=JZ($),q=Object.freeze({ORDER:$,BITS:X,BYTES:Z,MASK:W$(X),ZERO:M0,ONE:Y0,create:(U)=>K0(U,$),isValid:(U)=>{if(typeof U!=="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof U}`);return M0<=U&&U<$},is0:(U)=>U===M0,isOdd:(U)=>(U&Y0)===Y0,neg:(U)=>K0(-U,$),eql:(U,G)=>U===G,sqr:(U)=>K0(U*U,$),add:(U,G)=>K0(U+G,$),sub:(U,G)=>K0(U-G,$),mul:(U,G)=>K0(U*G,$),pow:(U,G)=>XZ(q,U,G),div:(U,G)=>K0(U*i$(G,$),$),sqrN:(U)=>U*U,addN:(U,G)=>U+G,subN:(U,G)=>U-G,mulN:(U,G)=>U*G,inv:(U)=>i$(U,$),sqrt:Y.sqrt||((U)=>M(q,U)),invertBatch:(U)=>ZZ(q,U),cmov:(U,G,W)=>W?G:U,toBytes:(U)=>J?o$(U,Z):D8(U,Z),fromBytes:(U)=>{if(U.length!==Z)throw new Error(`Fp.fromBytes: expected ${Z}, got ${U.length}`);return J?n$(U):$8(U)}});return Object.freeze(q)}function yJ($){if(typeof $!=="bigint")throw new Error("field order must be bigint");const Q=$.toString(2).length;return Math.ceil(Q/8)}function u9($){const Q=yJ($);return Q+Math.ceil(Q/2)}function cJ($,Q,J=!1){const Y=$.length,X=yJ(Q),Z=u9(Q);if(Y<16||Y<Z||Y>1024)throw new Error(`expected ${Z}-1024 bytes of input, got ${Y}`);const M=J?$8($):n$($),q=K0(M,Q-Y0)+Y0;return J?o$(q,X):D8(q,X)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var M0=BigInt(0),Y0=BigInt(1),B8=BigInt(2),sX=BigInt(3),h9=BigInt(4),mJ=BigInt(5),gJ=BigInt(8),tX=BigInt(9),eX=BigInt(16);var YZ=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function uJ($,Q){const J=(X,Z)=>{const M=Z.negate();return X?M:Z},Y=(X)=>{const Z=Math.ceil(Q/X)+1,M=2**(X-1);return{windows:Z,windowSize:M}};return{constTimeNegate:J,unsafeLadder(X,Z){let M=$.ZERO,q=X;while(Z>qZ){if(Z&p9)M=M.add(q);q=q.double(),Z>>=p9}return M},precomputeWindow(X,Z){const{windows:M,windowSize:q}=Y(Z),U=[];let G=X,W=G;for(let V=0;V<M;V++){W=G,U.push(W);for(let I=1;I<q;I++)W=W.add(G),U.push(W);G=W.double()}return U},wNAF(X,Z,M){const{windows:q,windowSize:U}=Y(X);let{ZERO:G,BASE:W}=$;const V=BigInt(2**X-1),I=2**X,E=BigInt(X);for(let z=0;z<q;z++){const D=z*U;let R=Number(M&V);if(M>>=E,R>U)R-=I,M+=p9;const L=D,S=D+Math.abs(R)-1,k=z%2!==0,T=R<0;if(R===0)W=W.add(J(k,Z[L]));else G=G.add(J(T,Z[S]))}return{p:G,f:W}},wNAFCached(X,Z,M,q){const U=X._WINDOW_SIZE||1;let G=Z.get(X);if(!G){if(G=this.precomputeWindow(X,U),U!==1)Z.set(X,q(G))}return this.wNAF(U,G,M)}}}function d9($){return y9($.Fp),K8($,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...c9($.n,$.nBitLength),...$,...{p:$.Fp.ORDER}})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var qZ=BigInt(0),p9=BigInt(1);var UZ=function($){const Q=d9($);K8(Q,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:J,Fp:Y,a:X}=Q;if(J){if(!Y.eql(X,Y.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof J!=="object"||typeof J.beta!=="bigint"||typeof J.splitScalar!=="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...Q})};function OZ($){const Q=UZ($),{Fp:J}=Q,Y=Q.toBytes||((z,D,R)=>{const L=D.toAffine();return i8(Uint8Array.from([4]),J.toBytes(L.x),J.toBytes(L.y))}),X=Q.fromBytes||((z)=>{const D=z.subarray(1),R=J.fromBytes(D.subarray(0,J.BYTES)),L=J.fromBytes(D.subarray(J.BYTES,2*J.BYTES));return{x:R,y:L}});function Z(z){const{a:D,b:R}=Q,L=J.sqr(z),S=J.mul(L,z);return J.add(J.add(S,J.mul(z,D)),R)}if(!J.eql(J.sqr(Q.Gy),Z(Q.Gx)))throw new Error("bad generator point: equation left != right");function M(z){return typeof z==="bigint"&&Q8<z&&z<Q.n}function q(z){if(!M(z))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function U(z){const{allowedPrivateKeyLengths:D,nByteLength:R,wrapPrivateKey:L,n:S}=Q;if(D&&typeof z!=="bigint"){if(z instanceof Uint8Array)z=w8(z);if(typeof z!=="string"||!D.includes(z.length))throw new Error("Invalid key");z=z.padStart(R*2,"0")}let k;try{k=typeof z==="bigint"?z:$8(P0("private key",z,R))}catch(T){throw new Error(`private key must be ${R} bytes, hex or bigint, not ${typeof z}`)}if(L)k=K0(k,S);return q(k),k}const G=new Map;function W(z){if(!(z instanceof V))throw new Error("ProjectivePoint expected")}class V{constructor(z,D,R){if(this.px=z,this.py=D,this.pz=R,z==null||!J.isValid(z))throw new Error("x required");if(D==null||!J.isValid(D))throw new Error("y required");if(R==null||!J.isValid(R))throw new Error("z required")}static fromAffine(z){const{x:D,y:R}=z||{};if(!z||!J.isValid(D)||!J.isValid(R))throw new Error("invalid affine point");if(z instanceof V)throw new Error("projective point not allowed");const L=(S)=>J.eql(S,J.ZERO);if(L(D)&&L(R))return V.ZERO;return new V(D,R,J.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(z){const D=J.invertBatch(z.map((R)=>R.pz));return z.map((R,L)=>R.toAffine(D[L])).map(V.fromAffine)}static fromHex(z){const D=V.fromAffine(X(P0("pointHex",z)));return D.assertValidity(),D}static fromPrivateKey(z){return V.BASE.multiply(U(z))}_setWindowSize(z){this._WINDOW_SIZE=z,G.delete(this)}assertValidity(){if(this.is0()){if(Q.allowInfinityPoint&&!J.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:z,y:D}=this.toAffine();if(!J.isValid(z)||!J.isValid(D))throw new Error("bad point: x or y not FE");const R=J.sqr(D),L=Z(z);if(!J.eql(R,L))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:z}=this.toAffine();if(J.isOdd)return!J.isOdd(z);throw new Error("Field doesn't support isOdd")}equals(z){W(z);const{px:D,py:R,pz:L}=this,{px:S,py:k,pz:T}=z,K=J.eql(J.mul(D,T),J.mul(S,L)),N=J.eql(J.mul(R,T),J.mul(k,L));return K&&N}negate(){return new V(this.px,J.neg(this.py),this.pz)}double(){const{a:z,b:D}=Q,R=J.mul(D,pJ),{px:L,py:S,pz:k}=this;let{ZERO:T,ZERO:K,ZERO:N}=J,P=J.mul(L,L),B=J.mul(S,S),w=J.mul(k,k),f=J.mul(L,S);return f=J.add(f,f),N=J.mul(L,k),N=J.add(N,N),T=J.mul(z,N),K=J.mul(R,w),K=J.add(T,K),T=J.sub(B,K),K=J.add(B,K),K=J.mul(T,K),T=J.mul(f,T),N=J.mul(R,N),w=J.mul(z,w),f=J.sub(P,w),f=J.mul(z,f),f=J.add(f,N),N=J.add(P,P),P=J.add(N,P),P=J.add(P,w),P=J.mul(P,f),K=J.add(K,P),w=J.mul(S,k),w=J.add(w,w),P=J.mul(w,f),T=J.sub(T,P),N=J.mul(w,B),N=J.add(N,N),N=J.add(N,N),new V(T,K,N)}add(z){W(z);const{px:D,py:R,pz:L}=this,{px:S,py:k,pz:T}=z;let{ZERO:K,ZERO:N,ZERO:P}=J;const B=Q.a,w=J.mul(Q.b,pJ);let f=J.mul(D,S),b=J.mul(R,k),y=J.mul(L,T),e=J.add(D,R),u=J.add(S,k);e=J.mul(e,u),u=J.add(f,b),e=J.sub(e,u),u=J.add(D,L);let j=J.add(S,T);return u=J.mul(u,j),j=J.add(f,y),u=J.sub(u,j),j=J.add(R,L),K=J.add(k,T),j=J.mul(j,K),K=J.add(b,y),j=J.sub(j,K),P=J.mul(B,u),K=J.mul(w,y),P=J.add(K,P),K=J.sub(b,P),P=J.add(b,P),N=J.mul(K,P),b=J.add(f,f),b=J.add(b,f),y=J.mul(B,y),u=J.mul(w,u),b=J.add(b,y),y=J.sub(f,y),y=J.mul(B,y),u=J.add(u,y),f=J.mul(b,u),N=J.add(N,f),f=J.mul(j,u),K=J.mul(e,K),K=J.sub(K,f),f=J.mul(e,b),P=J.mul(j,P),P=J.add(P,f),new V(K,N,P)}subtract(z){return this.add(z.negate())}is0(){return this.equals(V.ZERO)}wNAF(z){return E.wNAFCached(this,G,z,(D)=>{const R=J.invertBatch(D.map((L)=>L.pz));return D.map((L,S)=>L.toAffine(R[S])).map(V.fromAffine)})}multiplyUnsafe(z){const D=V.ZERO;if(z===Q8)return D;if(q(z),z===A0)return this;const{endo:R}=Q;if(!R)return E.unsafeLadder(this,z);let{k1neg:L,k1:S,k2neg:k,k2:T}=R.splitScalar(z),K=D,N=D,P=this;while(S>Q8||T>Q8){if(S&A0)K=K.add(P);if(T&A0)N=N.add(P);P=P.double(),S>>=A0,T>>=A0}if(L)K=K.negate();if(k)N=N.negate();return N=new V(J.mul(N.px,R.beta),N.py,N.pz),K.add(N)}multiply(z){q(z);let D=z,R,L;const{endo:S}=Q;if(S){const{k1neg:k,k1:T,k2neg:K,k2:N}=S.splitScalar(D);let{p:P,f:B}=this.wNAF(T),{p:w,f}=this.wNAF(N);P=E.constTimeNegate(k,P),w=E.constTimeNegate(K,w),w=new V(J.mul(w.px,S.beta),w.py,w.pz),R=P.add(w),L=B.add(f)}else{const{p:k,f:T}=this.wNAF(D);R=k,L=T}return V.normalizeZ([R,L])[0]}multiplyAndAddUnsafe(z,D,R){const L=V.BASE,S=(T,K)=>K===Q8||K===A0||!T.equals(L)?T.multiplyUnsafe(K):T.multiply(K),k=S(this,D).add(S(z,R));return k.is0()?void 0:k}toAffine(z){const{px:D,py:R,pz:L}=this,S=this.is0();if(z==null)z=S?J.ONE:J.inv(L);const k=J.mul(D,z),T=J.mul(R,z),K=J.mul(L,z);if(S)return{x:J.ZERO,y:J.ZERO};if(!J.eql(K,J.ONE))throw new Error("invZ was invalid");return{x:k,y:T}}isTorsionFree(){const{h:z,isTorsionFree:D}=Q;if(z===A0)return!0;if(D)return D(V,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:z,clearCofactor:D}=Q;if(z===A0)return this;if(D)return D(V,this);return this.multiplyUnsafe(Q.h)}toRawBytes(z=!0){return this.assertValidity(),Y(V,this,z)}toHex(z=!0){return w8(this.toRawBytes(z))}}V.BASE=new V(Q.Gx,Q.Gy,J.ONE),V.ZERO=new V(J.ZERO,J.ONE,J.ZERO);const I=Q.nBitLength,E=uJ(V,Q.endo?Math.ceil(I/2):I);return{CURVE:Q,ProjectivePoint:V,normPrivateKeyToScalar:U,weierstrassEquation:Z,isWithinCurveOrder:M}}var VZ=function($){const Q=d9($);return K8(Q,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...Q})};function dJ($){const Q=VZ($),{Fp:J,n:Y}=Q,X=J.BYTES+1,Z=2*J.BYTES+1;function M(j){return Q8<j&&j<J.ORDER}function q(j){return K0(j,Y)}function U(j){return i$(j,Y)}const{ProjectivePoint:G,normPrivateKeyToScalar:W,weierstrassEquation:V,isWithinCurveOrder:I}=OZ({...Q,toBytes(j,A,_){const v=A.toAffine(),c=J.toBytes(v.x),l=i8;if(_)return l(Uint8Array.from([A.hasEvenY()?2:3]),c);else return l(Uint8Array.from([4]),c,J.toBytes(v.y))},fromBytes(j){const A=j.length,_=j[0],v=j.subarray(1);if(A===X&&(_===2||_===3)){const c=$8(v);if(!M(c))throw new Error("Point is not on curve");const l=V(c);let p=J.sqrt(l);const z0=(p&A0)===A0;if((_&1)===1!==z0)p=J.neg(p);return{x:c,y:p}}else if(A===Z&&_===4){const c=J.fromBytes(v.subarray(0,J.BYTES)),l=J.fromBytes(v.subarray(J.BYTES,2*J.BYTES));return{x:c,y:l}}else throw new Error(`Point of length ${A} was invalid. Expected ${X} compressed bytes or ${Z} uncompressed bytes`)}}),E=(j)=>w8(D8(j,Q.nByteLength));function z(j){const A=Y>>A0;return j>A}function D(j){return z(j)?q(-j):j}const R=(j,A,_)=>$8(j.slice(A,_));class L{constructor(j,A,_){this.r=j,this.s=A,this.recovery=_,this.assertValidity()}static fromCompact(j){const A=Q.nByteLength;return j=P0("compactSignature",j,A*2),new L(R(j,0,A),R(j,A,2*A))}static fromDER(j){const{r:A,s:_}=F8.toSig(P0("DER",j));return new L(A,_)}assertValidity(){if(!I(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!I(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(j){return new L(this.r,this.s,j)}recoverPublicKey(j){const{r:A,s:_,recovery:v}=this,c=P(P0("msgHash",j));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");const l=v===2||v===3?A+Q.n:A;if(l>=J.ORDER)throw new Error("recovery id 2 or 3 invalid");const p=(v&1)===0?"02":"03",z0=G.fromHex(p+E(l)),l0=U(l),j8=q(-c*l0),m8=q(_*l0),H8=G.BASE.multiplyAndAddUnsafe(z0,j8,m8);if(!H8)throw new Error("point at infinify");return H8.assertValidity(),H8}hasHighS(){return z(this.s)}normalizeS(){return this.hasHighS()?new L(this.r,q(-this.s),this.recovery):this}toDERRawBytes(){return A8(this.toDERHex())}toDERHex(){return F8.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return A8(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}const S={isValidPrivateKey(j){try{return W(j),!0}catch(A){return!1}},normPrivateKeyToScalar:W,randomPrivateKey:()=>{const j=u9(Q.n);return cJ(Q.randomBytes(j),Q.n)},precompute(j=8,A=G.BASE){return A._setWindowSize(j),A.multiply(BigInt(3)),A}};function k(j,A=!0){return G.fromPrivateKey(j).toRawBytes(A)}function T(j){const A=j instanceof Uint8Array,_=typeof j==="string",v=(A||_)&&j.length;if(A)return v===X||v===Z;if(_)return v===2*X||v===2*Z;if(j instanceof G)return!0;return!1}function K(j,A,_=!0){if(T(j))throw new Error("first arg must be private key");if(!T(A))throw new Error("second arg must be public key");return G.fromHex(A).multiply(W(j)).toRawBytes(_)}const N=Q.bits2int||function(j){const A=$8(j),_=j.length*8-Q.nBitLength;return _>0?A>>BigInt(_):A},P=Q.bits2int_modN||function(j){return q(N(j))},B=W$(Q.nBitLength);function w(j){if(typeof j!=="bigint")throw new Error("bigint expected");if(!(Q8<=j&&j<B))throw new Error(`bigint expected < 2^${Q.nBitLength}`);return D8(j,Q.nByteLength)}function f(j,A,_=b){if(["recovered","canonical"].some((N8)=>(N8 in _)))throw new Error("sign() legacy options not supported");const{hash:v,randomBytes:c}=Q;let{lowS:l,prehash:p,extraEntropy:z0}=_;if(l==null)l=!0;if(j=P0("msgHash",j),p)j=P0("prehashed msgHash",v(j));const l0=P(j),j8=W(A),m8=[w(j8),w(l0)];if(z0!=null){const N8=z0===!0?c(J.BYTES):z0;m8.push(P0("extraEntropy",N8))}const H8=i8(...m8),C$=l0;function H9(N8){const g8=N(N8);if(!I(g8))return;const jQ=U(g8),g0=G.BASE.multiply(g8).toAffine(),h8=q(g0.x);if(h8===Q8)return;const E$=q(jQ*q(C$+h8*j8));if(E$===Q8)return;let HQ=(g0.x===h8?0:2)|Number(g0.y&A0),NQ=E$;if(l&&z(E$))NQ=D(E$),HQ^=1;return new L(h8,NQ,HQ)}return{seed:H8,k2sig:H9}}const b={lowS:Q.lowS,prehash:!1},y={lowS:Q.lowS,prehash:!1};function e(j,A,_=b){const{seed:v,k2sig:c}=f(j,A,_),l=Q;return m9(l.hash.outputLen,l.nByteLength,l.hmac)(v,c)}G.BASE._setWindowSize(8);function u(j,A,_,v=y){const c=j;if(A=P0("msgHash",A),_=P0("publicKey",_),("strict"in v))throw new Error("options.strict was renamed to lowS");const{lowS:l,prehash:p}=v;let z0=void 0,l0;try{if(typeof c==="string"||c instanceof Uint8Array)try{z0=L.fromDER(c)}catch(g0){if(!(g0 instanceof F8.Err))throw g0;z0=L.fromCompact(c)}else if(typeof c==="object"&&typeof c.r==="bigint"&&typeof c.s==="bigint"){const{r:g0,s:h8}=c;z0=new L(g0,h8)}else throw new Error("PARSE");l0=G.fromHex(_)}catch(g0){if(g0.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(l&&z0.hasHighS())return!1;if(p)A=Q.hash(A);const{r:j8,s:m8}=z0,H8=P(A),C$=U(m8),H9=q(H8*C$),N8=q(j8*C$),g8=G.BASE.multiplyAndAddUnsafe(l0,H9,N8)?.toAffine();if(!g8)return!1;return q(g8.x)===j8}return{CURVE:Q,getPublicKey:k,getSharedSecret:K,sign:e,verify:u,ProjectivePoint:G,Signature:L,utils:S}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var{bytesToNumberBE:GZ,hexToBytes:WZ}=g9,F8={Err:class $ extends Error{constructor(Q=""){super(Q)}},_parseInt($){const{Err:Q}=F8;if($.length<2||$[0]!==2)throw new Q("Invalid signature integer tag");const J=$[1],Y=$.subarray(2,J+2);if(!J||Y.length!==J)throw new Q("Invalid signature integer: wrong length");if(Y[0]&128)throw new Q("Invalid signature integer: negative");if(Y[0]===0&&!(Y[1]&128))throw new Q("Invalid signature integer: unnecessary leading zero");return{d:GZ(Y),l:$.subarray(J+2)}},toSig($){const{Err:Q}=F8,J=typeof $==="string"?WZ($):$;if(!(J instanceof Uint8Array))throw new Error("ui8a expected");let Y=J.length;if(Y<2||J[0]!=48)throw new Q("Invalid signature tag");if(J[1]!==Y-2)throw new Q("Invalid signature: incorrect length");const{d:X,l:Z}=F8._parseInt(J.subarray(2)),{d:M,l:q}=F8._parseInt(Z);if(q.length)throw new Q("Invalid signature: left bytes after parsing");return{r:X,s:M}},hexFromSig($){const Q=(G)=>Number.parseInt(G[0],16)&8?"00"+G:G,J=(G)=>{const W=G.toString(16);return W.length&1?`0${W}`:W},Y=Q(J($.s)),X=Q(J($.r)),Z=Y.length/2,M=X.length/2,q=J(Z),U=J(M);return`30${J(M+Z+4)}02${U}${X}02${q}${Y}`}},Q8=BigInt(0),A0=BigInt(1),Eq=BigInt(2),pJ=BigInt(3),Pq=BigInt(4);function zZ($){return{hash:$,hmac:(Q,...J)=>P8($,Q,xQ(...J)),randomBytes:vQ}}function lJ($,Q){const J=(Y)=>dJ({...$,...zZ(Y)});return Object.freeze({...J(Q),create:J})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var DZ=function($){const Q=iJ,J=BigInt(3),Y=BigInt(6),X=BigInt(11),Z=BigInt(22),M=BigInt(23),q=BigInt(44),U=BigInt(88),G=$*$*$%Q,W=G*G*$%Q,V=S0(W,J,Q)*W%Q,I=S0(V,J,Q)*W%Q,E=S0(I,l9,Q)*G%Q,z=S0(E,X,Q)*E%Q,D=S0(z,Z,Q)*z%Q,R=S0(D,q,Q)*D%Q,L=S0(R,U,Q)*R%Q,S=S0(L,q,Q)*D%Q,k=S0(S,J,Q)*W%Q,T=S0(k,M,Q)*z%Q,K=S0(T,Y,Q)*G%Q,N=S0(K,l9,Q);if(!n9.eql(n9.sqr(N),$))throw new Error("Cannot find square root");return N};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var iJ=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),nJ=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),IZ=BigInt(1),l9=BigInt(2),oJ=($,Q)=>($+Q/l9)/Q,n9=hJ(iJ,void 0,void 0,{sqrt:DZ}),J8=lJ({a:BigInt(0),b:BigInt(7),Fp:n9,n:nJ,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:($)=>{const Q=nJ,J=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),Y=-IZ*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),X=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),Z=J,M=BigInt("0x100000000000000000000000000000000"),q=oJ(Z*$,Q),U=oJ(-Y*$,Q);let G=K0($-q*J-U*X,Q),W=K0(-q*Y-U*Z,Q);const V=G>M,I=W>M;if(V)G=Q-G;if(I)W=Q-W;if(G>M||W>M)throw new Error("splitScalar: Endomorphism failed, k="+$);return{k1neg:V,k1:G,k2neg:I,k2:W}}}},r0),bq=BigInt(0);var xq=J8.ProjectivePoint;var o9="0x0000000000000000000000000000000000000000";var r$="0x0000000000000000000000000000000000000000000000000000000000000000";var i9=`\x19Ethereum Signed Message:
2
- `;var $Y=function($){return C0(s($),32)},rJ=BigInt(0),aJ=BigInt(1),sJ=BigInt(2),tJ=BigInt(27),eJ=BigInt(28),a$=BigInt(35),r8={};class $0{#$;#Q;#J;#Y;get r(){return this.#$}set r($){O(o0($)===32,"invalid r","value",$),this.#$=H($)}get s(){return O(parseInt(this.#Q.substring(0,3))<8,"non-canonical s; use ._s","s",this.#Q),this.#Q}set s($){O(o0($)===32,"invalid s","value",$),this.#Q=H($)}get _s(){return this.#Q}isValid(){return parseInt(this.#Q.substring(0,3))<8}get v(){return this.#J}set v($){const Q=q0($,"value");O(Q===27||Q===28,"invalid v","v",$),this.#J=Q}get networkV(){return this.#Y}get legacyChainId(){const $=this.networkV;if($==null)return null;return $0.getChainId($)}get yParity(){return this.v===27?0:1}get yParityAndS(){const $=C(this.s);if(this.yParity)$[0]|=128;return H($)}get compactSerialized(){return o([this.r,this.yParityAndS])}get serialized(){return o([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor($,Q,J,Y){n0($,r8,"Signature"),this.#$=Q,this.#Q=J,this.#J=Y,this.#Y=null}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this._s}"${this.isValid()?"":', valid: "false"'}, yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const $=new $0(r8,this.r,this._s,this.v);if(this.networkV)$.#Y=this.networkV;return $}toJSON(){const $=this.networkV;return{_type:"signature",networkV:$!=null?$.toString():null,r:this.r,s:this._s,v:this.v}}static getChainId($){const Q=g($,"v");if(Q==tJ||Q==eJ)return rJ;return O(Q>=a$,"invalid EIP-155 v","v",$),(Q-a$)/sJ}static getChainIdV($,Q){return g($)*sJ+BigInt(35+Q-27)}static getNormalizedV($){const Q=g($);if(Q===rJ||Q===tJ)return 27;if(Q===aJ||Q===eJ)return 28;return O(Q>=a$,"invalid v","v",$),Q&aJ?27:28}static from($){function Q(U,G){O(U,G,"signature",$)}if($==null)return new $0(r8,r$,r$,27);if(typeof $==="string"){const U=C($,"signature");if(U.length===64){const G=H(U.slice(0,32)),W=U.slice(32,64),V=W[0]&128?28:27;return W[0]&=127,new $0(r8,G,H(W),V)}if(U.length===65){const G=H(U.slice(0,32)),W=H(U.slice(32,64)),V=$0.getNormalizedV(U[64]);return new $0(r8,G,W,V)}Q(!1,"invalid raw signature length")}if($ instanceof $0)return $.clone();const J=$.r;Q(J!=null,"missing r");const Y=$Y(J),X=function(U,G){if(U!=null)return $Y(U);if(G!=null){Q(I0(G,32),"invalid yParityAndS");const W=C(G);return W[0]&=127,H(W)}Q(!1,"missing s")}($.s,$.yParityAndS),{networkV:Z,v:M}=function(U,G,W){if(U!=null){const V=g(U);return{networkV:V>=a$?V:void 0,v:$0.getNormalizedV(V)}}if(G!=null)return Q(I0(G,32),"invalid yParityAndS"),{v:C(G)[0]&128?28:27};if(W!=null){switch(q0(W,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}Q(!1,"invalid yParity")}Q(!1,"missing v")}($.v,$.yParityAndS,$.yParity),q=new $0(r8,Y,X,M);if(Z)q.#Y=Z;return Q($.yParity==null||q0($.yParity,"sig.yParity")===q.yParity,"yParity mismatch"),Q($.yParityAndS==null||$.yParityAndS===q.yParityAndS,"yParityAndS mismatch"),q}}class X0{#$;constructor($){O(o0($)===32,"invalid private key","privateKey","[REDACTED]"),this.#$=H($)}get privateKey(){return this.#$}get publicKey(){return X0.computePublicKey(this.#$)}get compressedPublicKey(){return X0.computePublicKey(this.#$,!0)}sign($){O(o0($)===32,"invalid digest length","digest",$);const Q=J8.sign(b0($),b0(this.#$),{lowS:!0});return $0.from({r:x0(Q.r,32),s:x0(Q.s,32),v:Q.recovery?28:27})}computeSharedSecret($){const Q=X0.computePublicKey($);return H(J8.getSharedSecret(b0(this.#$),C(Q),!1))}static computePublicKey($,Q){let J=C($,"key");if(J.length===32){const X=J8.getPublicKey(J,!!Q);return H(X)}if(J.length===64){const X=new Uint8Array(65);X[0]=4,X.set(J,1),J=X}const Y=J8.ProjectivePoint.fromHex(J);return H(Y.toRawBytes(Q))}static recoverPublicKey($,Q){O(o0($)===32,"invalid digest length","digest",$);const J=$0.from(Q);let Y=J8.Signature.fromCompact(b0(o([J.r,J.s])));Y=Y.addRecoveryBit(J.yParity);const X=Y.recoverPublicKey(b0($));return O(X!=null,"invalid signature for digest","signature",Q),"0x"+X.toHex(!1)}static addPoints($,Q,J){const Y=J8.ProjectivePoint.fromHex(X0.computePublicKey($).substring(2)),X=J8.ProjectivePoint.fromHex(X0.computePublicKey(Q).substring(2));return"0x"+Y.add(X).toHex(!!J)}}var QY=function($){$=$.toLowerCase();const Q=$.substring(2).split(""),J=new Uint8Array(40);for(let X=0;X<40;X++)J[X]=Q[X].charCodeAt(0);const Y=C(n(J));for(let X=0;X<40;X+=2){if(Y[X>>1]>>4>=8)Q[X]=Q[X].toUpperCase();if((Y[X>>1]&15)>=8)Q[X+1]=Q[X+1].toUpperCase()}return"0x"+Q.join("")},TZ=function($){$=$.toUpperCase(),$=$.substring(4)+$.substring(0,2)+"00";let Q=$.split("").map((Y)=>{return r9[Y]}).join("");while(Q.length>=JY){let Y=Q.substring(0,JY);Q=parseInt(Y,10)%97+Q.substring(Y.length)}let J=String(98-parseInt(Q,10)%97);while(J.length<2)J="0"+J;return J},jZ=function($){$=$.toLowerCase();let Q=KZ;for(let J=0;J<$.length;J++)Q=Q*RZ+LZ[$[J]];return Q};function m($){if(O(typeof $==="string","invalid address","address",$),$.match(/^(0x)?[0-9a-fA-F]{40}$/)){if(!$.startsWith("0x"))$="0x"+$;const Q=QY($);return O(!$.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||Q===$,"bad address checksum","address",$),Q}if($.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){O($.substring(2,4)===TZ($),"bad icap checksum","address",$);let Q=jZ($.substring(4)).toString(16);while(Q.length<40)Q="0"+Q;return QY("0x"+Q)}O(!1,"invalid address","address",$)}var KZ=BigInt(0),RZ=BigInt(36),r9={};for(let $=0;$<10;$++)r9[String($)]=String($);for(let $=0;$<26;$++)r9[String.fromCharCode(65+$)]=String(10+$);var JY=15,LZ=function(){const $={};for(let Q=0;Q<36;Q++){const J="0123456789abcdefghijklmnopqrstuvwxyz"[Q];$[J]=BigInt(Q)}return $}();function s9($){return $&&typeof $.getAddress==="function"}async function a9($,Q){const J=await Q;if(J==null||J==="0x0000000000000000000000000000000000000000")F(typeof $!=="string","unconfigured name","UNCONFIGURED_NAME",{value:$}),O(!1,"invalid AddressLike value; did not resolve to a value address","target",$);return m(J)}function Y8($,Q){if(typeof $==="string"){if($.match(/^0x[0-9a-f]{40}$/i))return m($);return F(Q!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),a9($,Q.resolveName($))}else if(s9($))return a9($,$.getAddress());else if($&&typeof $.then==="function")return a9($,$);O(!1,"unsupported addressable value","target",$)}var t9=function($,Q){return{address:m($),storageKeys:Q.map((J,Y)=>{return O(I0(J,32),"invalid slot",`storageKeys[${Y}]`,J),J.toLowerCase()})}};function f8($){if(Array.isArray($))return $.map((J,Y)=>{if(Array.isArray(J))return O(J.length===2,"invalid slot set",`value[${Y}]`,J),t9(J[0],J[1]);return O(J!=null&&typeof J==="object","invalid address-slot set","value",$),t9(J.address,J.storageKeys)});O($!=null&&typeof $==="object","invalid access list","value",$);const Q=Object.keys($).map((J)=>{const Y=$[J].reduce((X,Z)=>{return X[Z]=!0,X},{});return t9(J,Object.keys(Y).sort())});return Q.sort((J,Y)=>J.address.localeCompare(Y.address)),Q}function YY($){return{address:m($.address),nonce:g($.nonce!=null?$.nonce:0),chainId:g($.chainId!=null?$.chainId:0),signature:$0.from($.signature)}}function X8($){let Q;if(typeof $==="string")Q=X0.computePublicKey($,!1);else Q=$.publicKey;return m(n("0x"+Q.substring(4)).substring(26))}function O$($,Q){return X8(X0.recoverPublicKey($,Q))}var AZ=function($){return{blobToKzgCommitment:(Y)=>{if("computeBlobProof"in $){if(("blobToKzgCommitment"in $)&&typeof $.blobToKzgCommitment==="function")return C($.blobToKzgCommitment(H(Y)))}else if(("blobToKzgCommitment"in $)&&typeof $.blobToKzgCommitment==="function")return C($.blobToKzgCommitment(Y));if(("blobToKZGCommitment"in $)&&typeof $.blobToKZGCommitment==="function")return C($.blobToKZGCommitment(H(Y)));O(!1,"unsupported KZG library","kzg",$)},computeBlobKzgProof:(Y,X)=>{if(("computeBlobProof"in $)&&typeof $.computeBlobProof==="function")return C($.computeBlobProof(H(Y),H(X)));if(("computeBlobKzgProof"in $)&&typeof $.computeBlobKzgProof==="function")return $.computeBlobKzgProof(Y,X);if(("computeBlobKZGProof"in $)&&typeof $.computeBlobKZGProof==="function")return C($.computeBlobKZGProof(H(Y),H(X)));O(!1,"unsupported KZG library","kzg",$)}}},XY=function($,Q){let J=$.toString(16);while(J.length<2)J="0"+J;return J+=O0(Q).substring(4),"0x"+J},a8=function($){if($==="0x")return null;return m($)},s$=function($,Q){try{return f8($)}catch(J){O(!1,J.message,Q,$)}},BZ=function($,Q){try{if(!Array.isArray($))throw new Error("authorizationList: invalid array");const J=[];for(let Y=0;Y<$.length;Y++){const X=$[Y];if(!Array.isArray(X))throw new Error(`authorization[${Y}]: invalid array`);if(X.length!==6)throw new Error(`authorization[${Y}]: wrong length`);if(!X[1])throw new Error(`authorization[${Y}]: null address`);J.push({address:a8(X[1]),nonce:r(X[2],"nonce"),chainId:r(X[0],"chainId"),signature:$0.from({yParity:k8(X[3],"yParity"),r:C0(X[4],32),s:C0(X[5],32)})})}return J}catch(J){O(!1,J.message,Q,$)}},k8=function($,Q){if($==="0x")return 0;return q0($,Q)},r=function($,Q){if($==="0x")return U0;const J=g($,Q);return O(J<=wZ,"value exceeds uint size",Q,J),J},h=function($,Q){const J=g($,"value"),Y=s(J);return O(Y.length<=32,"value too large",`tx.${Q}`,J),Y},t$=function($){return f8($).map((Q)=>[Q.address,Q.storageKeys])},FZ=function($){return $.map((Q)=>{return[h(Q.chainId,"chainId"),Q.address,h(Q.nonce,"nonce"),h(Q.signature.yParity,"yParity"),s(Q.signature.r),s(Q.signature.s)]})},fZ=function($,Q){O(Array.isArray($),`invalid ${Q}`,"value",$);for(let J=0;J<$.length;J++)O(I0($[J],32),"invalid ${ param } hash",`value[${J}]`,$[J]);return $},kZ=function($){const Q=G8($);O(Array.isArray(Q)&&(Q.length===9||Q.length===6),"invalid field count for legacy transaction","data",$);const J={type:0,nonce:k8(Q[0],"nonce"),gasPrice:r(Q[1],"gasPrice"),gasLimit:r(Q[2],"gasLimit"),to:a8(Q[3]),value:r(Q[4],"value"),data:H(Q[5]),chainId:U0};if(Q.length===6)return J;const Y=r(Q[6],"v"),X=r(Q[7],"r"),Z=r(Q[8],"s");if(X===U0&&Z===U0)J.chainId=Y;else{let M=(Y-SZ)/CZ;if(M<U0)M=U0;J.chainId=M,O(M!==U0||(Y===EZ||Y===PZ),"non-canonical legacy v","v",Q[6]),J.signature=$0.from({r:C0(Q[7],32),s:C0(Q[8],32),v:Y})}return J},_Z=function($,Q){const J=[h($.nonce,"nonce"),h($.gasPrice||0,"gasPrice"),h($.gasLimit,"gasLimit"),$.to||"0x",h($.value,"value"),$.data];let Y=U0;if($.chainId!=U0)Y=g($.chainId,"tx.chainId"),O(!Q||Q.networkV==null||Q.legacyChainId===Y,"tx.chainId/sig.v mismatch","sig",Q);else if($.signature){const Z=$.signature.legacyChainId;if(Z!=null)Y=Z}if(!Q){if(Y!==U0)J.push(s(Y)),J.push("0x"),J.push("0x");return w0(J)}let X=BigInt(27+Q.yParity);if(Y!==U0)X=$0.getChainIdV(Y,Q.v);else if(BigInt(Q.v)!==X)O(!1,"tx.chainId/sig.v mismatch","sig",Q);return J.push(s(X)),J.push(s(Q.r)),J.push(s(Q.s)),w0(J)},e$=function($,Q){let J;try{if(J=k8(Q[0],"yParity"),J!==0&&J!==1)throw new Error("bad yParity")}catch(M){O(!1,"invalid yParity","yParity",Q[0])}const Y=C0(Q[1],32),X=C0(Q[2],32),Z=$0.from({r:Y,s:X,yParity:J});$.signature=Z},bZ=function($){const Q=G8(C($).slice(1));O(Array.isArray(Q)&&(Q.length===9||Q.length===12),"invalid field count for transaction type: 2","data",H($));const J={type:2,chainId:r(Q[0],"chainId"),nonce:k8(Q[1],"nonce"),maxPriorityFeePerGas:r(Q[2],"maxPriorityFeePerGas"),maxFeePerGas:r(Q[3],"maxFeePerGas"),gasPrice:null,gasLimit:r(Q[4],"gasLimit"),to:a8(Q[5]),value:r(Q[6],"value"),data:H(Q[7]),accessList:s$(Q[8],"accessList")};if(Q.length===9)return J;return e$(J,Q.slice(9)),J},xZ=function($,Q){const J=[h($.chainId,"chainId"),h($.nonce,"nonce"),h($.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),h($.maxFeePerGas||0,"maxFeePerGas"),h($.gasLimit,"gasLimit"),$.to||"0x",h($.value,"value"),$.data,t$($.accessList||[])];if(Q)J.push(h(Q.yParity,"yParity")),J.push(s(Q.r)),J.push(s(Q.s));return o(["0x02",w0(J)])},vZ=function($){const Q=G8(C($).slice(1));O(Array.isArray(Q)&&(Q.length===8||Q.length===11),"invalid field count for transaction type: 1","data",H($));const J={type:1,chainId:r(Q[0],"chainId"),nonce:k8(Q[1],"nonce"),gasPrice:r(Q[2],"gasPrice"),gasLimit:r(Q[3],"gasLimit"),to:a8(Q[4]),value:r(Q[5],"value"),data:H(Q[6]),accessList:s$(Q[7],"accessList")};if(Q.length===8)return J;return e$(J,Q.slice(8)),J},mZ=function($,Q){const J=[h($.chainId,"chainId"),h($.nonce,"nonce"),h($.gasPrice||0,"gasPrice"),h($.gasLimit,"gasLimit"),$.to||"0x",h($.value,"value"),$.data,t$($.accessList||[])];if(Q)J.push(h(Q.yParity,"recoveryParam")),J.push(s(Q.r)),J.push(s(Q.s));return o(["0x01",w0(J)])},gZ=function($){let Q=G8(C($).slice(1)),J="3",Y=null;if(Q.length===4&&Array.isArray(Q[0])){J="3 (network format)";const Z=Q[1],M=Q[2],q=Q[3];O(Array.isArray(Z),"invalid network format: blobs not an array","fields[1]",Z),O(Array.isArray(M),"invalid network format: commitments not an array","fields[2]",M),O(Array.isArray(q),"invalid network format: proofs not an array","fields[3]",q),O(Z.length===M.length,"invalid network format: blobs/commitments length mismatch","fields",Q),O(Z.length===q.length,"invalid network format: blobs/proofs length mismatch","fields",Q),Y=[];for(let U=0;U<Q[1].length;U++)Y.push({data:Z[U],commitment:M[U],proof:q[U]});Q=Q[0]}O(Array.isArray(Q)&&(Q.length===11||Q.length===14),`invalid field count for transaction type: ${J}`,"data",H($));const X={type:3,chainId:r(Q[0],"chainId"),nonce:k8(Q[1],"nonce"),maxPriorityFeePerGas:r(Q[2],"maxPriorityFeePerGas"),maxFeePerGas:r(Q[3],"maxFeePerGas"),gasPrice:null,gasLimit:r(Q[4],"gasLimit"),to:a8(Q[5]),value:r(Q[6],"value"),data:H(Q[7]),accessList:s$(Q[8],"accessList"),maxFeePerBlobGas:r(Q[9],"maxFeePerBlobGas"),blobVersionedHashes:Q[10]};if(Y)X.blobs=Y;O(X.to!=null,`invalid address for transaction type: ${J}`,"data",$),O(Array.isArray(X.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",$);for(let Z=0;Z<X.blobVersionedHashes.length;Z++)O(I0(X.blobVersionedHashes[Z],32),`invalid blobVersionedHash at index ${Z}: must be length 32`,"data",$);if(Q.length===11)return X;return e$(X,Q.slice(11)),X},hZ=function($,Q,J){const Y=[h($.chainId,"chainId"),h($.nonce,"nonce"),h($.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),h($.maxFeePerGas||0,"maxFeePerGas"),h($.gasLimit,"gasLimit"),$.to||o9,h($.value,"value"),$.data,t$($.accessList||[]),h($.maxFeePerBlobGas||0,"maxFeePerBlobGas"),fZ($.blobVersionedHashes||[],"blobVersionedHashes")];if(Q){if(Y.push(h(Q.yParity,"yParity")),Y.push(s(Q.r)),Y.push(s(Q.s)),J)return o(["0x03",w0([Y,J.map((X)=>X.data),J.map((X)=>X.commitment),J.map((X)=>X.proof)])])}return o(["0x03",w0(Y)])},yZ=function($){const Q=G8(C($).slice(1));O(Array.isArray(Q)&&(Q.length===10||Q.length===13),"invalid field count for transaction type: 4","data",H($));const J={type:4,chainId:r(Q[0],"chainId"),nonce:k8(Q[1],"nonce"),maxPriorityFeePerGas:r(Q[2],"maxPriorityFeePerGas"),maxFeePerGas:r(Q[3],"maxFeePerGas"),gasPrice:null,gasLimit:r(Q[4],"gasLimit"),to:a8(Q[5]),value:r(Q[6],"value"),data:H(Q[7]),accessList:s$(Q[8],"accessList"),authorizationList:BZ(Q[9],"authorizationList")};if(Q.length===10)return J;return e$(J,Q.slice(10)),J},cZ=function($,Q){const J=[h($.chainId,"chainId"),h($.nonce,"nonce"),h($.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),h($.maxFeePerGas||0,"maxFeePerGas"),h($.gasLimit,"gasLimit"),$.to||"0x",h($.value,"value"),$.data,t$($.accessList||[]),FZ($.authorizationList||[])];if(Q)J.push(h(Q.yParity,"yParity")),J.push(s(Q.r)),J.push(s(Q.s));return o(["0x04",w0(J)])},U0=BigInt(0),CZ=BigInt(2),EZ=BigInt(27),PZ=BigInt(28),SZ=BigInt(35),wZ=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e9=131072;class L0{#$;#Q;#J;#Y;#U;#G;#W;#O;#V;#z;#I;#D;#q;#Z;#X;#M;#K;get type(){return this.#$}set type($){switch($){case null:this.#$=null;break;case 0:case"legacy":this.#$=0;break;case 1:case"berlin":case"eip-2930":this.#$=1;break;case 2:case"london":case"eip-1559":this.#$=2;break;case 3:case"cancun":case"eip-4844":this.#$=3;break;case 4:case"pectra":case"eip-7702":this.#$=4;break;default:O(!1,"unsupported transaction type","type",$)}}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 $=this.#Q;if($==null&&this.type===3)return o9;return $}set to($){this.#Q=$==null?null:m($)}get nonce(){return this.#Y}set nonce($){this.#Y=q0($,"value")}get gasLimit(){return this.#U}set gasLimit($){this.#U=g($)}get gasPrice(){const $=this.#G;if($==null&&(this.type===0||this.type===1))return U0;return $}set gasPrice($){this.#G=$==null?null:g($,"gasPrice")}get maxPriorityFeePerGas(){const $=this.#W;if($==null){if(this.type===2||this.type===3)return U0;return null}return $}set maxPriorityFeePerGas($){this.#W=$==null?null:g($,"maxPriorityFeePerGas")}get maxFeePerGas(){const $=this.#O;if($==null){if(this.type===2||this.type===3)return U0;return null}return $}set maxFeePerGas($){this.#O=$==null?null:g($,"maxFeePerGas")}get data(){return this.#J}set data($){this.#J=H($)}get value(){return this.#V}set value($){this.#V=g($,"value")}get chainId(){return this.#z}set chainId($){this.#z=g($)}get signature(){return this.#I||null}set signature($){this.#I=$==null?null:$0.from($)}get accessList(){const $=this.#D||null;if($==null){if(this.type===1||this.type===2||this.type===3)return[];return null}return $}set accessList($){this.#D=$==null?null:f8($)}get authorizationList(){const $=this.#K||null;if($==null){if(this.type===4)return[]}return $}set authorizationList($){this.#K=$==null?null:$.map((Q)=>YY(Q))}get maxFeePerBlobGas(){const $=this.#q;if($==null&&this.type===3)return U0;return $}set maxFeePerBlobGas($){this.#q=$==null?null:g($,"maxFeePerBlobGas")}get blobVersionedHashes(){let $=this.#Z;if($==null&&this.type===3)return[];return $}set blobVersionedHashes($){if($!=null){O(Array.isArray($),"blobVersionedHashes must be an Array","value",$),$=$.slice();for(let Q=0;Q<$.length;Q++)O(I0($[Q],32),"invalid blobVersionedHash",`value[${Q}]`,$[Q])}this.#Z=$}get blobs(){if(this.#M==null)return null;return this.#M.map(($)=>Object.assign({},$))}set blobs($){if($==null){this.#M=null;return}const Q=[],J=[];for(let Y=0;Y<$.length;Y++){const X=$[Y];if(y0(X)){F(this.#X,"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let Z=C(X);if(O(Z.length<=e9,"blob is too large",`blobs[${Y}]`,X),Z.length!==e9){const U=new Uint8Array(e9);U.set(Z),Z=U}const M=this.#X.blobToKzgCommitment(Z),q=H(this.#X.computeBlobKzgProof(Z,M));Q.push({data:H(Z),commitment:H(M),proof:q}),J.push(XY(1,M))}else{const Z=H(X.commitment);Q.push({data:H(X.data),commitment:Z,proof:H(X.proof)}),J.push(XY(1,Z))}}this.#M=Q,this.#Z=J}get kzg(){return this.#X}set kzg($){if($==null)this.#X=null;else this.#X=AZ($)}constructor(){this.#$=null,this.#Q=null,this.#Y=0,this.#U=U0,this.#G=null,this.#W=null,this.#O=null,this.#J="0x",this.#V=U0,this.#z=U0,this.#I=null,this.#D=null,this.#q=null,this.#Z=null,this.#X=null,this.#M=null,this.#K=null}get hash(){if(this.signature==null)return null;return n(this.#R(!0,!1))}get unsignedHash(){return n(this.unsignedSerialized)}get from(){if(this.signature==null)return null;return O$(this.unsignedHash,this.signature)}get fromPublicKey(){if(this.signature==null)return null;return X0.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}#R($,Q){F(!$||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const J=$?this.signature:null;switch(this.inferType()){case 0:return _Z(this,J);case 1:return mZ(this,J);case 2:return xZ(this,J);case 3:return hZ(this,J,Q?this.blobs:null);case 4:return cZ(this,J)}F(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})}get serialized(){return this.#R(!0,!0)}get unsignedSerialized(){return this.#R(!1,!1)}inferType(){const $=this.inferTypes();if($.indexOf(2)>=0)return 2;return $.pop()}inferTypes(){const $=this.gasPrice!=null,Q=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,J=this.accessList!=null,Y=this.#q!=null||this.#Z;if(this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null)F(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this});F(!Q||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),F(this.type!==0||!J,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const X=[];if(this.type!=null)X.push(this.type);else if(this.authorizationList&&this.authorizationList.length)X.push(4);else if(Q)X.push(2);else if($){if(X.push(1),!J)X.push(0)}else if(J)X.push(1),X.push(2);else if(Y&&this.to)X.push(3);else X.push(0),X.push(1),X.push(2),X.push(3);return X.sort(),X}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return L0.from(this)}toJSON(){const $=(Q)=>{if(Q==null)return null;return Q.toString()};return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:$(this.gasLimit),gasPrice:$(this.gasPrice),maxPriorityFeePerGas:$(this.maxPriorityFeePerGas),maxFeePerGas:$(this.maxFeePerGas),value:$(this.value),chainId:$(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from($){if($==null)return new L0;if(typeof $==="string"){const J=C($);if(J[0]>=127)return L0.from(kZ(J));switch(J[0]){case 1:return L0.from(vZ(J));case 2:return L0.from(bZ(J));case 3:return L0.from(gZ(J));case 4:return L0.from(yZ(J))}F(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const Q=new L0;if($.type!=null)Q.type=$.type;if($.to!=null)Q.to=$.to;if($.nonce!=null)Q.nonce=$.nonce;if($.gasLimit!=null)Q.gasLimit=$.gasLimit;if($.gasPrice!=null)Q.gasPrice=$.gasPrice;if($.maxPriorityFeePerGas!=null)Q.maxPriorityFeePerGas=$.maxPriorityFeePerGas;if($.maxFeePerGas!=null)Q.maxFeePerGas=$.maxFeePerGas;if($.maxFeePerBlobGas!=null)Q.maxFeePerBlobGas=$.maxFeePerBlobGas;if($.data!=null)Q.data=$.data;if($.value!=null)Q.value=$.value;if($.chainId!=null)Q.chainId=$.chainId;if($.signature!=null)Q.signature=$0.from($.signature);if($.accessList!=null)Q.accessList=$.accessList;if($.authorizationList!=null)Q.authorizationList=$.authorizationList;if($.blobVersionedHashes!=null)Q.blobVersionedHashes=$.blobVersionedHashes;if($.kzg!=null)Q.kzg=$.kzg;if($.blobs!=null)Q.blobs=$.blobs;if($.hash!=null)O(Q.isSigned(),"unsigned transaction cannot define '.hash'","tx",$),O(Q.hash===$.hash,"hash mismatch","tx",$);if($.from!=null)O(Q.isSigned(),"unsigned transaction cannot define '.from'","tx",$),O(Q.from.toLowerCase()===($.from||"").toLowerCase(),"from mismatch","tx",$);return Q}}function $9($){return O(typeof $.address==="string","invalid address for hashAuthorization","auth.address",$),n(o(["0x05",w0([$.chainId!=null?s($.chainId):"0x",m($.address),$.nonce!=null?s($.nonce):"0x"])]))}function Z8($){return n(W0($))}function V$($){if(typeof $==="string")$=W0($);return n(o([W0(i9),W0(String($.length)),$]))}function Q9($,Q){const J=V$($);return O$(J,Q)}var dZ=function($){const Q=C($),J=Q.length%32;if(J)return o([Q,UY.slice(J)]);return H(Q)},MY=function($){return function(Q){return O(typeof Q==="string",`invalid domain value for ${JSON.stringify($)}`,`domain.${$}`,Q),Q}},QQ=function($){{const Q=$.match(/^(u?)int(\d+)$/);if(Q){const J=Q[1]==="",Y=parseInt(Q[2]);O(Y%8===0&&Y!==0&&Y<=256&&Q[2]===String(Y),"invalid numeric width","type",$);const X=A$(pZ,J?Y-1:Y),Z=J?(X+WY)*uZ:GY;return function(M){const q=g(M,"value");return O(q>=Z&&q<=X,`value out-of-bounds for ${$}`,"value",q),x0(J?w$(q,256):q,32)}}}{const Q=$.match(/^bytes(\d+)$/);if(Q){const J=parseInt(Q[1]);return O(J!==0&&J<=32&&Q[1]===String(J),"invalid bytes width","type",$),function(Y){const X=C(Y);return O(X.length===J,`invalid length for ${$}`,"value",Y),dZ(Y)}}}switch($){case"address":return function(Q){return C0(m(Q),32)};case"bool":return function(Q){return!Q?nZ:lZ};case"bytes":return function(Q){return n(Q)};case"string":return function(Q){return Z8(Q)}}return null},qY=function($,Q){return`${$}(${Q.map(({name:J,type:Y})=>Y+" "+J).join(",")})`},J9=function($){const Q=$.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);if(Q)return{base:Q[1],index:Q[2]+Q[4],array:{base:Q[1],prefix:Q[1]+Q[2],count:Q[5]?parseInt(Q[5]):-1}};return{base:$}};var UY=new Uint8Array(32);UY.fill(0);var uZ=BigInt(-1),GY=BigInt(0),WY=BigInt(1),pZ=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),lZ=x0(WY,32),nZ=x0(GY,32),ZY={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},$Q=["name","version","chainId","verifyingContract","salt"],oZ={name:MY("name"),version:MY("version"),chainId:function($){const Q=g($,"domain.chainId");if(O(Q>=0,"invalid chain ID","domain.chainId",$),Number.isSafeInteger(Q))return Number(Q);return B$(Q)},verifyingContract:function($){try{return m($).toLowerCase()}catch(Q){}O(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",$)},salt:function($){const Q=C($,"domain.salt");return O(Q.length===32,'invalid domain value "salt"',"domain.salt",$),H(Q)}};class R0{primaryType;#$;get types(){return JSON.parse(this.#$)}#Q;#J;constructor($){this.#Q=new Map,this.#J=new Map;const Q=new Map,J=new Map,Y=new Map,X={};Object.keys($).forEach((q)=>{X[q]=$[q].map(({name:U,type:G})=>{let{base:W,index:V}=J9(G);if(W==="int"&&!$.int)W="int256";if(W==="uint"&&!$.uint)W="uint256";return{name:U,type:W+(V||"")}}),Q.set(q,new Set),J.set(q,[]),Y.set(q,new Set)}),this.#$=JSON.stringify(X);for(let q in X){const U=new Set;for(let G of X[q]){O(!U.has(G.name),`duplicate variable name ${JSON.stringify(G.name)} in ${JSON.stringify(q)}`,"types",$),U.add(G.name);const W=J9(G.type).base;if(O(W!==q,`circular type reference to ${JSON.stringify(W)}`,"types",$),QQ(W))continue;O(J.has(W),`unknown type ${JSON.stringify(W)}`,"types",$),J.get(W).push(q),Q.get(q).add(W)}}const Z=Array.from(J.keys()).filter((q)=>J.get(q).length===0);O(Z.length!==0,"missing primary type","types",$),O(Z.length===1,`ambiguous primary types or unused types: ${Z.map((q)=>JSON.stringify(q)).join(", ")}`,"types",$),a(this,{primaryType:Z[0]});function M(q,U){O(!U.has(q),`circular type reference to ${JSON.stringify(q)}`,"types",$),U.add(q);for(let G of Q.get(q)){if(!J.has(G))continue;M(G,U);for(let W of U)Y.get(W).add(G)}U.delete(q)}M(this.primaryType,new Set);for(let[q,U]of Y){const G=Array.from(U);G.sort(),this.#Q.set(q,qY(q,X[q])+G.map((W)=>qY(W,X[W])).join(""))}}getEncoder($){let Q=this.#J.get($);if(!Q)Q=this.#Y($),this.#J.set($,Q);return Q}#Y($){{const Y=QQ($);if(Y)return Y}const Q=J9($).array;if(Q){const Y=Q.prefix,X=this.getEncoder(Y);return(Z)=>{O(Q.count===-1||Q.count===Z.length,`array length mismatch; expected length ${Q.count}`,"value",Z);let M=Z.map(X);if(this.#Q.has(Y))M=M.map(n);return n(o(M))}}const J=this.types[$];if(J){const Y=Z8(this.#Q.get($));return(X)=>{const Z=J.map(({name:M,type:q})=>{const U=this.getEncoder(q)(X[M]);if(this.#Q.has(q))return n(U);return U});return Z.unshift(Y),o(Z)}}O(!1,`unknown type: ${$}`,"type",$)}encodeType($){const Q=this.#Q.get($);return O(Q,`unknown type: ${JSON.stringify($)}`,"name",$),Q}encodeData($,Q){return this.getEncoder($)(Q)}hashStruct($,Q){return n(this.encodeData($,Q))}encode($){return this.encodeData(this.primaryType,$)}hash($){return this.hashStruct(this.primaryType,$)}_visit($,Q,J){if(QQ($))return J($,Q);const Y=J9($).array;if(Y)return O(Y.count===-1||Y.count===Q.length,`array length mismatch; expected length ${Y.count}`,"value",Q),Q.map((Z)=>this._visit(Y.prefix,Z,J));const X=this.types[$];if(X)return X.reduce((Z,{name:M,type:q})=>{return Z[M]=this._visit(q,Q[M],J),Z},{});O(!1,`unknown type: ${$}`,"type",$)}visit($,Q){return this._visit(this.primaryType,$,Q)}static from($){return new R0($)}static getPrimaryType($){return R0.from($).primaryType}static hashStruct($,Q,J){return R0.from(Q).hashStruct($,J)}static hashDomain($){const Q=[];for(let J in $){if($[J]==null)continue;const Y=ZY[J];O(Y,`invalid typed-data domain key: ${JSON.stringify(J)}`,"domain",$),Q.push({name:J,type:Y})}return Q.sort((J,Y)=>{return $Q.indexOf(J.name)-$Q.indexOf(Y.name)}),R0.hashStruct("EIP712Domain",{EIP712Domain:Q},$)}static encode($,Q,J){return o(["0x1901",R0.hashDomain($),R0.from(Q).hash(J)])}static hash($,Q,J){return n(R0.encode($,Q,J))}static async resolveNames($,Q,J,Y){$=Object.assign({},$);for(let M in $)if($[M]==null)delete $[M];const X={};if($.verifyingContract&&!I0($.verifyingContract,20))X[$.verifyingContract]="0x";const Z=R0.from(Q);Z.visit(J,(M,q)=>{if(M==="address"&&!I0(q,20))X[q]="0x";return q});for(let M in X)X[M]=await Y(M);if($.verifyingContract&&X[$.verifyingContract])$.verifyingContract=X[$.verifyingContract];return J=Z.visit(J,(M,q)=>{if(M==="address"&&X[q])return X[q];return q}),{domain:$,value:J}}static getPayload($,Q,J){R0.hashDomain($);const Y={},X=[];$Q.forEach((q)=>{const U=$[q];if(U==null)return;Y[q]=oZ[q](U),X.push({name:q,type:ZY[q]})});const Z=R0.from(Q);Q=Z.types;const M=Object.assign({},Q);return O(M.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",Q),M.EIP712Domain=X,Z.encode(J),{types:M,domain:Y,primaryType:Z.primaryType,message:Z.visit(J,(q,U)=>{if(q.match(/^bytes(\d*)/))return H(C(U));if(q.match(/^u?int/))return g(U).toString();switch(q){case"address":return U.toLowerCase();case"bool":return!!U;case"string":return O(typeof U==="string","invalid string","value",U),U}O(!1,"unsupported type","type",q)})}}}var JQ=function($){if($==null)return null;return $},G0=function($){if($==null)return null;return $.toString()};function z$($){const Q={};if($.to)Q.to=$.to;if($.from)Q.from=$.from;if($.data)Q.data=H($.data);const J="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(let X of J){if(!(X in $)||$[X]==null)continue;Q[X]=g($[X],`request.${X}`)}const Y="type,nonce".split(/,/);for(let X of Y){if(!(X in $)||$[X]==null)continue;Q[X]=q0($[X],`request.${X}`)}if($.accessList)Q.accessList=f8($.accessList);if($.authorizationList)Q.authorizationList=$.authorizationList.slice();if("blockTag"in $)Q.blockTag=$.blockTag;if("enableCcipRead"in $)Q.enableCcipRead=!!$.enableCcipRead;if("customData"in $)Q.customData=$.customData;if(("blobVersionedHashes"in $)&&$.blobVersionedHashes)Q.blobVersionedHashes=$.blobVersionedHashes.slice();if("kzg"in $)Q.kzg=$.kzg;if(("blobs"in $)&&$.blobs)Q.blobs=$.blobs.map((X)=>{if(y0(X))return H(X);return Object.assign({},X)});return Q}var aZ=function($){return{orphan:"drop-block",hash:$.hash,number:$.number}},IY=function($,Q){return{orphan:"reorder-transaction",tx:$,other:Q}},DY=function($){return{orphan:"drop-transaction",tx:$}},sZ=function($){return{orphan:"drop-log",log:{transactionHash:$.transactionHash,blockHash:$.blockHash,blockNumber:$.blockNumber,address:$.address,data:$.data,topics:Object.freeze($.topics.slice()),index:$.index}}},OY=BigInt(0);class VY{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#$;constructor($,Q){this.#$=$.transactions.map((J)=>{if(typeof J!=="string")return new Y9(J,Q);return J}),a(this,{provider:Q,hash:JQ($.hash),number:$.number,timestamp:$.timestamp,parentHash:$.parentHash,parentBeaconBlockRoot:$.parentBeaconBlockRoot,nonce:$.nonce,difficulty:$.difficulty,gasLimit:$.gasLimit,gasUsed:$.gasUsed,blobGasUsed:$.blobGasUsed,excessBlobGas:$.excessBlobGas,miner:$.miner,prevRandao:JQ($.prevRandao),extraData:$.extraData,baseFeePerGas:JQ($.baseFeePerGas),stateRoot:$.stateRoot,receiptsRoot:$.receiptsRoot})}get transactions(){return this.#$.map(($)=>{if(typeof $==="string")return $;return $.hash})}get prefetchedTransactions(){const $=this.#$.slice();if($.length===0)return[];return F(typeof $[0]==="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),$}toJSON(){const{baseFeePerGas:$,difficulty:Q,extraData:J,gasLimit:Y,gasUsed:X,hash:Z,miner:M,prevRandao:q,nonce:U,number:G,parentHash:W,parentBeaconBlockRoot:V,stateRoot:I,receiptsRoot:E,timestamp:z,transactions:D}=this;return{_type:"Block",baseFeePerGas:G0($),difficulty:G0(Q),extraData:J,gasLimit:G0(Y),gasUsed:G0(X),blobGasUsed:G0(this.blobGasUsed),excessBlobGas:G0(this.excessBlobGas),hash:Z,miner:M,prevRandao:q,nonce:U,number:G,parentHash:W,timestamp:z,parentBeaconBlockRoot:V,stateRoot:I,receiptsRoot:E,transactions:D}}[Symbol.iterator](){let $=0;const Q=this.transactions;return{next:()=>{if($<this.length)return{value:Q[$++],done:!1};return{value:void 0,done:!0}}}}get length(){return this.#$.length}get date(){if(this.timestamp==null)return null;return new Date(this.timestamp*1000)}async getTransaction($){let Q=void 0;if(typeof $==="number")Q=this.#$[$];else{const J=$.toLowerCase();for(let Y of this.#$)if(typeof Y==="string"){if(Y!==J)continue;Q=Y;break}else{if(Y.hash!==J)continue;Q=Y;break}}if(Q==null)throw new Error("no such tx");if(typeof Q==="string")return await this.provider.getTransaction(Q);else return Q}getPrefetchedTransaction($){const Q=this.prefetchedTransactions;if(typeof $==="number")return Q[$];$=$.toLowerCase();for(let J of Q)if(J.hash===$)return J;O(!1,"no matching transaction","indexOrHash",$)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return aZ(this)}}class YQ{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor($,Q){this.provider=Q;const J=Object.freeze($.topics.slice());a(this,{transactionHash:$.transactionHash,blockHash:$.blockHash,blockNumber:$.blockNumber,removed:$.removed,address:$.address,data:$.data,topics:J,index:$.index,transactionIndex:$.transactionIndex})}toJSON(){const{address:$,blockHash:Q,blockNumber:J,data:Y,index:X,removed:Z,topics:M,transactionHash:q,transactionIndex:U}=this;return{_type:"log",address:$,blockHash:Q,blockNumber:J,data:Y,index:X,removed:Z,topics:M,transactionHash:q,transactionIndex:U}}async getBlock(){const $=await this.provider.getBlock(this.blockHash);return F(!!$,"failed to find transaction","UNKNOWN_ERROR",{}),$}async getTransaction(){const $=await this.provider.getTransaction(this.transactionHash);return F(!!$,"failed to find transaction","UNKNOWN_ERROR",{}),$}async getTransactionReceipt(){const $=await this.provider.getTransactionReceipt(this.transactionHash);return F(!!$,"failed to find transaction receipt","UNKNOWN_ERROR",{}),$}removedEvent(){return sZ(this)}}class zY{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#$;constructor($,Q){this.#$=Object.freeze($.logs.map((Y)=>{return new YQ(Y,Q)}));let J=OY;if($.effectiveGasPrice!=null)J=$.effectiveGasPrice;else if($.gasPrice!=null)J=$.gasPrice;a(this,{provider:Q,to:$.to,from:$.from,contractAddress:$.contractAddress,hash:$.hash,index:$.index,blockHash:$.blockHash,blockNumber:$.blockNumber,logsBloom:$.logsBloom,gasUsed:$.gasUsed,cumulativeGasUsed:$.cumulativeGasUsed,blobGasUsed:$.blobGasUsed,gasPrice:J,blobGasPrice:$.blobGasPrice,type:$.type,status:$.status,root:$.root})}get logs(){return this.#$}toJSON(){const{to:$,from:Q,contractAddress:J,hash:Y,index:X,blockHash:Z,blockNumber:M,logsBloom:q,logs:U,status:G,root:W}=this;return{_type:"TransactionReceipt",blockHash:Z,blockNumber:M,contractAddress:J,cumulativeGasUsed:G0(this.cumulativeGasUsed),from:Q,gasPrice:G0(this.gasPrice),blobGasUsed:G0(this.blobGasUsed),blobGasPrice:G0(this.blobGasPrice),gasUsed:G0(this.gasUsed),hash:Y,index:X,logs:U,logsBloom:q,root:W,status:G,to:$}}get length(){return this.logs.length}[Symbol.iterator](){let $=0;return{next:()=>{if($<this.length)return{value:this.logs[$++],done:!1};return{value:void 0,done:!0}}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const $=await this.provider.getBlock(this.blockHash);if($==null)throw new Error("TODO");return $}async getTransaction(){const $=await this.provider.getTransaction(this.hash);if($==null)throw new Error("TODO");return $}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return DY(this)}reorderedEvent($){return F(!$||$.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),IY(this,$)}}class Y9{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;authorizationList;#$;constructor($,Q){this.provider=Q,this.blockNumber=$.blockNumber!=null?$.blockNumber:null,this.blockHash=$.blockHash!=null?$.blockHash:null,this.hash=$.hash,this.index=$.index,this.type=$.type,this.from=$.from,this.to=$.to||null,this.gasLimit=$.gasLimit,this.nonce=$.nonce,this.data=$.data,this.value=$.value,this.gasPrice=$.gasPrice,this.maxPriorityFeePerGas=$.maxPriorityFeePerGas!=null?$.maxPriorityFeePerGas:null,this.maxFeePerGas=$.maxFeePerGas!=null?$.maxFeePerGas:null,this.maxFeePerBlobGas=$.maxFeePerBlobGas!=null?$.maxFeePerBlobGas:null,this.chainId=$.chainId,this.signature=$.signature,this.accessList=$.accessList!=null?$.accessList:null,this.blobVersionedHashes=$.blobVersionedHashes!=null?$.blobVersionedHashes:null,this.authorizationList=$.authorizationList!=null?$.authorizationList:null,this.#$=-1}toJSON(){const{blockNumber:$,blockHash:Q,index:J,hash:Y,type:X,to:Z,from:M,nonce:q,data:U,signature:G,accessList:W,blobVersionedHashes:V}=this;return{_type:"TransactionResponse",accessList:W,blockNumber:$,blockHash:Q,blobVersionedHashes:V,chainId:G0(this.chainId),data:U,from:M,gasLimit:G0(this.gasLimit),gasPrice:G0(this.gasPrice),hash:Y,maxFeePerGas:G0(this.maxFeePerGas),maxPriorityFeePerGas:G0(this.maxPriorityFeePerGas),maxFeePerBlobGas:G0(this.maxFeePerBlobGas),nonce:q,signature:G,to:Z,index:J,type:X,value:G0(this.value)}}async getBlock(){let $=this.blockNumber;if($==null){const J=await this.getTransaction();if(J)$=J.blockNumber}if($==null)return null;const Q=this.provider.getBlock($);if(Q==null)throw new Error("TODO");return Q}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:Q,blockNumber:J}=await h0({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});if(Q==null||Q.blockNumber==null)return 0;return J-Q.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait($,Q){const J=$==null?1:$,Y=Q==null?0:Q;let X=this.#$,Z=-1,M=X===-1?!0:!1;const q=async()=>{if(M)return null;const{blockNumber:V,nonce:I}=await h0({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(I<this.nonce){X=V;return}if(M)return null;const E=await this.getTransaction();if(E&&E.blockNumber!=null)return;if(Z===-1){if(Z=X-3,Z<this.#$)Z=this.#$}while(Z<=V){if(M)return null;const z=await this.provider.getBlock(Z,!0);if(z==null)return;for(let D of z)if(D===this.hash)return;for(let D=0;D<z.length;D++){const R=await z.getTransaction(D);if(R.from===this.from&&R.nonce===this.nonce){if(M)return null;const L=await this.provider.getTransactionReceipt(R.hash);if(L==null)return;if(V-L.blockNumber+1<J)return;let S="replaced";if(R.data===this.data&&R.to===this.to&&R.value===this.value)S="repriced";else if(R.data==="0x"&&R.from===R.to&&R.value===OY)S="cancelled";F(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:S==="replaced"||S==="cancelled",reason:S,replacement:R.replaceableTransaction(X),hash:R.hash,receipt:L})}}Z++}return},U=(V)=>{if(V==null||V.status!==0)return V;F(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:V.to,from:V.from,data:""},receipt:V})},G=await this.provider.getTransactionReceipt(this.hash);if(J===0)return U(G);if(G){if(J===1||await G.confirmations()>=J)return U(G)}else if(await q(),J===0)return null;return await new Promise((V,I)=>{const E=[],z=()=>{E.forEach((R)=>R())};if(E.push(()=>{M=!0}),Y>0){const R=setTimeout(()=>{z(),I(X$("wait for transaction timeout","TIMEOUT"))},Y);E.push(()=>{clearTimeout(R)})}const D=async(R)=>{if(await R.confirmations()>=J){z();try{V(U(R))}catch(L){I(L)}}};if(E.push(()=>{this.provider.off(this.hash,D)}),this.provider.on(this.hash,D),X>=0){const R=async()=>{try{await q()}catch(L){if(S$(L,"TRANSACTION_REPLACED")){z(),I(L);return}}if(!M)this.provider.once("block",R)};E.push(()=>{this.provider.off("block",R)}),this.provider.once("block",R)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return F(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),DY(this)}reorderedEvent($){return F(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),F(!$||$.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),IY(this,$)}replaceableTransaction($){O(Number.isInteger($)&&$>=0,"invalid startBlock","startBlock",$);const Q=new Y9(this,this.provider);return Q.#$=$,Q}}var _8=function($,Q){if($.provider)return $.provider;F(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:Q})};async function KY($,Q){let J=z$(Q);if(J.to!=null)J.to=Y8(J.to,$);if(J.from!=null){const Y=J.from;J.from=Promise.all([$.getAddress(),Y8(Y,$)]).then(([X,Z])=>{return O(X.toLowerCase()===Z.toLowerCase(),"transaction from mismatch","tx.from",Z),X})}else J.from=$.getAddress();return await h0(J)}class I${provider;constructor($){a(this,{provider:$||null})}async getNonce($){return _8(this,"getTransactionCount").getTransactionCount(await this.getAddress(),$)}async populateCall($){return await KY(this,$)}async populateTransaction($){const Q=_8(this,"populateTransaction"),J=await KY(this,$);if(J.nonce==null)J.nonce=await this.getNonce("pending");if(J.gasLimit==null)J.gasLimit=await this.estimateGas(J);const Y=await this.provider.getNetwork();if(J.chainId!=null){const Z=g(J.chainId);O(Z===Y.chainId,"transaction chainId mismatch","tx.chainId",$.chainId)}else J.chainId=Y.chainId;const X=J.maxFeePerGas!=null||J.maxPriorityFeePerGas!=null;if(J.gasPrice!=null&&(J.type===2||X))O(!1,"eip-1559 transaction do not support gasPrice","tx",$);else if((J.type===0||J.type===1)&&X)O(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",$);if((J.type===2||J.type==null)&&(J.maxFeePerGas!=null&&J.maxPriorityFeePerGas!=null))J.type=2;else if(J.type===0||J.type===1){const Z=await Q.getFeeData();if(F(Z.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),J.gasPrice==null)J.gasPrice=Z.gasPrice}else{const Z=await Q.getFeeData();if(J.type==null)if(Z.maxFeePerGas!=null&&Z.maxPriorityFeePerGas!=null){if(J.authorizationList&&J.authorizationList.length)J.type=4;else J.type=2;if(J.gasPrice!=null){const M=J.gasPrice;delete J.gasPrice,J.maxFeePerGas=M,J.maxPriorityFeePerGas=M}else{if(J.maxFeePerGas==null)J.maxFeePerGas=Z.maxFeePerGas;if(J.maxPriorityFeePerGas==null)J.maxPriorityFeePerGas=Z.maxPriorityFeePerGas}}else if(Z.gasPrice!=null){if(F(!X,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),J.gasPrice==null)J.gasPrice=Z.gasPrice;J.type=0}else F(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else if(J.type===2||J.type===3||J.type===4){if(J.maxFeePerGas==null)J.maxFeePerGas=Z.maxFeePerGas;if(J.maxPriorityFeePerGas==null)J.maxPriorityFeePerGas=Z.maxPriorityFeePerGas}}return await h0(J)}async populateAuthorization($){const Q=Object.assign({},$);if(Q.chainId==null)Q.chainId=(await _8(this,"getNetwork").getNetwork()).chainId;if(Q.nonce==null)Q.nonce=await this.getNonce();return Q}async estimateGas($){return _8(this,"estimateGas").estimateGas(await this.populateCall($))}async call($){return _8(this,"call").call(await this.populateCall($))}async resolveName($){return await _8(this,"resolveName").resolveName($)}async sendTransaction($){const Q=_8(this,"sendTransaction"),J=await this.populateTransaction($);delete J.from;const Y=L0.from(J);return await Q.broadcastTransaction(await this.signTransaction(Y))}authorize($){F(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}class D$ extends I${address;constructor($,Q){super(Q);a(this,{address:$})}async getAddress(){return this.address}connect($){return new D$(this.address,$)}#$($,Q){F(!1,`VoidSigner cannot sign ${$}`,"UNSUPPORTED_OPERATION",{operation:Q})}async signTransaction($){this.#$("transactions","signTransaction")}async signMessage($){this.#$("messages","signMessage")}async signTypedData($,Q,J){this.#$("typed-data","signTypedData")}}class b8 extends I${address;#$;constructor($,Q){super(Q);O($&&typeof $.sign==="function","invalid private key","privateKey","[ REDACTED ]"),this.#$=$;const J=X8(this.signingKey.publicKey);a(this,{address:J})}get signingKey(){return this.#$}get privateKey(){return this.signingKey.privateKey}async getAddress(){return this.address}connect($){return new b8(this.#$,$)}async signTransaction($){$=z$($);const{to:Q,from:J}=await h0({to:$.to?Y8($.to,this):void 0,from:$.from?Y8($.from,this):void 0});if(Q!=null)$.to=Q;if(J!=null)$.from=J;if($.from!=null)O(m($.from)===this.address,"transaction from address mismatch","tx.from",$.from),delete $.from;const Y=L0.from($);return Y.signature=this.signingKey.sign(Y.unsignedHash),Y.serialized}async signMessage($){return this.signMessageSync($)}signMessageSync($){return this.signingKey.sign(V$($)).serialized}authorizeSync($){O(typeof $.address==="string","invalid address for authorizeSync","auth.address",$);const Q=this.signingKey.sign($9($));return Object.assign({},{address:m($.address),nonce:g($.nonce||0),chainId:g($.chainId||0)},{signature:Q})}async authorize($){return $=Object.assign({},$,{address:await Y8($.address,this)}),this.authorizeSync(await this.populateAuthorization($))}async signTypedData($,Q,J){const Y=await R0.resolveNames($,Q,J,async(X)=>{F(this.provider!=null,"cannot resolve ENS names without a provider","UNSUPPORTED_OPERATION",{operation:"resolveName",info:{name:X}});const Z=await this.provider.resolveName(X);return F(Z!=null,"unconfigured ENS name","UNCONFIGURED_NAME",{value:X}),Z});return this.signingKey.sign(R0.hash(Y.domain,Q,Y.value)).serialized}}var RY=function($,Q){let J=97;return $.reduce((Y,X)=>{if(X===Q)J++;else if(X.match(tZ))Y.push(String.fromCharCode(J)+X);else J=97,Y.push(X);return Y},[])};function eZ($,Q){for(let X=X9.length-1;X>=0;X--)$=$.split(X9[X]).join(Q.substring(2*X,2*X+2));const J=[],Y=$.replace(/(:|([0-9])|([A-Z][a-z]*))/g,(X,Z,M,q)=>{if(M)for(let U=parseInt(M);U>=0;U--)J.push(";");else J.push(Z.toLowerCase());return""});if(Y)throw new Error(`leftovers: ${JSON.stringify(Y)}`);return RY(RY(J,";"),":")}function TY($){return O($[0]==="0","unsupported auwl data","data",$),eZ($.substring(1+2*X9.length),$.substring(1,1+2*X9.length))}var X9=" !#$%&'()*+,-./<=>?@[]^_`{|}~",tZ=/^[a-z]*$/i;class XQ{locale;constructor($){a(this,{locale:$})}split($){return $.toLowerCase().split(/\s+/g)}join($){return $.join(" ")}}class ZQ extends XQ{#$;#Q;constructor($,Q,J){super($);this.#$=Q,this.#Q=J,this.#J=null}get _data(){return this.#$}_decodeWords(){return TY(this.#$)}#J;#Y(){if(this.#J==null){const $=this._decodeWords();if(Z8($.join("\n")+"\n")!==this.#Q)throw new Error(`BIP39 Wordlist for ${this.locale} FAILED`);this.#J=$}return this.#J}getWord($){const Q=this.#Y();return O($>=0&&$<Q.length,`invalid word index: ${$}`,"index",$),Q[$]}getWordIndex($){return this.#Y().indexOf($)}}var $5="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",Q5="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60",MQ=null;class M8 extends ZQ{constructor(){super("en",$5,Q5)}static wordlist(){if(MQ==null)MQ=new M8;return MQ}}var LY=function($){return(1<<$)-1<<8-$&255},J5=function($){return(1<<$)-1&255},qQ=function($,Q){if(c8("NFKD"),Q==null)Q=M8.wordlist();const J=Q.split($);O(J.length%3===0&&J.length>=12&&J.length<=24,"invalid mnemonic length","mnemonic","[ REDACTED ]");const Y=new Uint8Array(Math.ceil(11*J.length/8));let X=0;for(let G=0;G<J.length;G++){let W=Q.getWordIndex(J[G].normalize("NFKD"));O(W>=0,`invalid mnemonic word at index ${G}`,"mnemonic","[ REDACTED ]");for(let V=0;V<11;V++){if(W&1<<10-V)Y[X>>3]|=1<<7-X%8;X++}}const Z=32*J.length/3,M=J.length/3,q=LY(M),U=C(O0(Y.slice(0,Z/8)))[0]&q;return O(U===(Y[Y.length-1]&q),"invalid mnemonic checksum","mnemonic","[ REDACTED ]"),H(Y.slice(0,Z/8))},UQ=function($,Q){if(O($.length%4===0&&$.length>=16&&$.length<=32,"invalid entropy size","entropy","[ REDACTED ]"),Q==null)Q=M8.wordlist();const J=[0];let Y=11;for(let M=0;M<$.length;M++)if(Y>8)J[J.length-1]<<=8,J[J.length-1]|=$[M],Y-=8;else J[J.length-1]<<=Y,J[J.length-1]|=$[M]>>8-Y,J.push($[M]&J5(8-Y)),Y+=3;const X=$.length/4,Z=parseInt(O0($).substring(2,4),16)&LY(X);return J[J.length-1]<<=X,J[J.length-1]|=Z>>8-X,Q.join(J.map((M)=>Q.getWord(M)))},GQ={};class q8{phrase;password;wordlist;entropy;constructor($,Q,J,Y,X){if(Y==null)Y="";if(X==null)X=M8.wordlist();n0($,GQ,"Mnemonic"),a(this,{phrase:J,password:Y,wordlist:X,entropy:Q})}computeSeed(){const $=W0("mnemonic"+this.password,"NFKD");return E0(W0(this.phrase,"NFKD"),$,2048,64,"sha512")}static fromPhrase($,Q,J){const Y=qQ($,J);return $=UQ(C(Y),J),new q8(GQ,Y,$,Q,J)}static fromEntropy($,Q,J){const Y=C($,"entropy"),X=UQ(Y,J);return new q8(GQ,H(Y),X,Q,J)}static entropyToPhrase($,Q){const J=C($,"entropy");return UQ(J,Q)}static phraseToEntropy($,Q){return qQ($,Q)}static isValidMnemonic($,Q){try{return qQ($,Q),!0}catch(J){}return!1}}var OQ=function($){const Q=[];for(let J=0;J<$.length;J+=4)Q.push($[J]<<24|$[J+1]<<16|$[J+2]<<8|$[J+3]);return Q};/*! MIT License. Copyright 2015-2022 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */var V0=function($,Q,J,Y){if(J==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?$!==Q||!Y:!Q.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return J==="m"?Y:J==="a"?Y.call($):Y?Y.value:Q.get($)},WQ=function($,Q,J,Y,X){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?$!==Q||!X:!Q.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?X.call($,J):X?X.value=J:Q.set($,J),J},M9,F0,u0,Y5={16:10,24:12,32:14},X5=[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],B0=[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],Z9=[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],Z5=[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],M5=[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],q5=[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],U5=[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],G5=[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],W5=[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],O5=[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,1047239000,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],V5=[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,679998000,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],z5=[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],I5=[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],D5=[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,1047239000,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],K5=[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,679998000,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];class q9{get key(){return V0(this,M9,"f").slice()}constructor($){if(M9.set(this,void 0),F0.set(this,void 0),u0.set(this,void 0),!(this instanceof q9))throw Error("AES must be instanitated with `new`");WQ(this,M9,new Uint8Array($),"f");const Q=Y5[this.key.length];if(Q==null)throw new TypeError("invalid key size (must be 16, 24 or 32 bytes)");WQ(this,u0,[],"f"),WQ(this,F0,[],"f");for(let G=0;G<=Q;G++)V0(this,u0,"f").push([0,0,0,0]),V0(this,F0,"f").push([0,0,0,0]);const J=(Q+1)*4,Y=this.key.length/4,X=OQ(this.key);let Z;for(let G=0;G<Y;G++)Z=G>>2,V0(this,u0,"f")[Z][G%4]=X[G],V0(this,F0,"f")[Q-Z][G%4]=X[G];let M=0,q=Y,U;while(q<J){if(U=X[Y-1],X[0]^=B0[U>>16&255]<<24^B0[U>>8&255]<<16^B0[U&255]<<8^B0[U>>24&255]^X5[M]<<24,M+=1,Y!=8)for(let I=1;I<Y;I++)X[I]^=X[I-1];else{for(let I=1;I<Y/2;I++)X[I]^=X[I-1];U=X[Y/2-1],X[Y/2]^=B0[U&255]^B0[U>>8&255]<<8^B0[U>>16&255]<<16^B0[U>>24&255]<<24;for(let I=Y/2+1;I<Y;I++)X[I]^=X[I-1]}let G=0,W,V;while(G<Y&&q<J)W=q>>2,V=q%4,V0(this,u0,"f")[W][V]=X[G],V0(this,F0,"f")[Q-W][V]=X[G++],q++}for(let G=1;G<Q;G++)for(let W=0;W<4;W++)U=V0(this,F0,"f")[G][W],V0(this,F0,"f")[G][W]=z5[U>>24&255]^I5[U>>16&255]^D5[U>>8&255]^K5[U&255]}encrypt($){if($.length!=16)throw new TypeError("invalid plaintext size (must be 16 bytes)");const Q=V0(this,u0,"f").length-1,J=[0,0,0,0];let Y=OQ($);for(let M=0;M<4;M++)Y[M]^=V0(this,u0,"f")[0][M];for(let M=1;M<Q;M++){for(let q=0;q<4;q++)J[q]=Z5[Y[q]>>24&255]^M5[Y[(q+1)%4]>>16&255]^q5[Y[(q+2)%4]>>8&255]^U5[Y[(q+3)%4]&255]^V0(this,u0,"f")[M][q];Y=J.slice()}const X=new Uint8Array(16);let Z=0;for(let M=0;M<4;M++)Z=V0(this,u0,"f")[Q][M],X[4*M]=(B0[Y[M]>>24&255]^Z>>24)&255,X[4*M+1]=(B0[Y[(M+1)%4]>>16&255]^Z>>16)&255,X[4*M+2]=(B0[Y[(M+2)%4]>>8&255]^Z>>8)&255,X[4*M+3]=(B0[Y[(M+3)%4]&255]^Z)&255;return X}decrypt($){if($.length!=16)throw new TypeError("invalid ciphertext size (must be 16 bytes)");const Q=V0(this,F0,"f").length-1,J=[0,0,0,0];let Y=OQ($);for(let M=0;M<4;M++)Y[M]^=V0(this,F0,"f")[0][M];for(let M=1;M<Q;M++){for(let q=0;q<4;q++)J[q]=G5[Y[q]>>24&255]^W5[Y[(q+3)%4]>>16&255]^O5[Y[(q+2)%4]>>8&255]^V5[Y[(q+1)%4]&255]^V0(this,F0,"f")[M][q];Y=J.slice()}const X=new Uint8Array(16);let Z=0;for(let M=0;M<4;M++)Z=V0(this,F0,"f")[Q][M],X[4*M]=(Z9[Y[M]>>24&255]^Z>>24)&255,X[4*M+1]=(Z9[Y[(M+3)%4]>>16&255]^Z>>16)&255,X[4*M+2]=(Z9[Y[(M+2)%4]>>8&255]^Z>>8)&255,X[4*M+3]=(Z9[Y[(M+1)%4]&255]^Z)&255;return X}}M9=new WeakMap,F0=new WeakMap,u0=new WeakMap;class K${constructor($,Q,J){if(J&&!(this instanceof J))throw new Error(`${$} must be instantiated with "new"`);Object.defineProperties(this,{aes:{enumerable:!0,value:new q9(Q)},name:{enumerable:!0,value:$}})}}var U9=function($,Q,J,Y,X){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?$!==Q||!X:!Q.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?X.call($,J):X?X.value=J:Q.set($,J),J},s8=function($,Q,J,Y){if(J==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?$!==Q||!Y:!Q.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return J==="m"?Y:J==="a"?Y.call($):Y?Y.value:Q.get($)},R$,U8;class T$ extends K${constructor($,Q){super("ECC",$,T$);if(R$.set(this,void 0),U8.set(this,void 0),Q){if(Q.length%16)throw new TypeError("invalid iv size (must be 16 bytes)");U9(this,R$,new Uint8Array(Q),"f")}else U9(this,R$,new Uint8Array(16),"f");U9(this,U8,this.iv,"f")}get iv(){return new Uint8Array(s8(this,R$,"f"))}encrypt($){if($.length%16)throw new TypeError("invalid plaintext size (must be multiple of 16 bytes)");const Q=new Uint8Array($.length);for(let J=0;J<$.length;J+=16){for(let Y=0;Y<16;Y++)s8(this,U8,"f")[Y]^=$[J+Y];U9(this,U8,this.aes.encrypt(s8(this,U8,"f")),"f"),Q.set(s8(this,U8,"f"),J)}return Q}decrypt($){if($.length%16)throw new TypeError("invalid ciphertext size (must be multiple of 16 bytes)");const Q=new Uint8Array($.length);for(let J=0;J<$.length;J+=16){const Y=this.aes.decrypt($.subarray(J,J+16));for(let X=0;X<16;X++)Q[J+X]=Y[X]^s8(this,U8,"f")[X],s8(this,U8,"f")[X]=$[J+X]}return Q}}R$=new WeakMap,U8=new WeakMap;var t8=function($,Q,J,Y,X){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?$!==Q||!X:!Q.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?X.call($,J):X?X.value=J:Q.set($,J),J},f0=function($,Q,J,Y){if(J==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?$!==Q||!Y:!Q.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return J==="m"?Y:J==="a"?Y.call($):Y?Y.value:Q.get($)},L$,x8,k0;class R8 extends K${constructor($,Q){super("CTR",$,R8);if(L$.set(this,void 0),x8.set(this,void 0),k0.set(this,void 0),t8(this,k0,new Uint8Array(16),"f"),f0(this,k0,"f").fill(0),t8(this,L$,f0(this,k0,"f"),"f"),t8(this,x8,16,"f"),Q==null)Q=1;if(typeof Q==="number")this.setCounterValue(Q);else this.setCounterBytes(Q)}get counter(){return new Uint8Array(f0(this,k0,"f"))}setCounterValue($){if(!Number.isInteger($)||$<0||$>Number.MAX_SAFE_INTEGER)throw new TypeError("invalid counter initial integer value");for(let Q=15;Q>=0;--Q)f0(this,k0,"f")[Q]=$%256,$=Math.floor($/256)}setCounterBytes($){if($.length!==16)throw new TypeError("invalid counter initial Uint8Array value length");f0(this,k0,"f").set($)}increment(){for(let $=15;$>=0;$--)if(f0(this,k0,"f")[$]===255)f0(this,k0,"f")[$]=0;else{f0(this,k0,"f")[$]++;break}}encrypt($){var Q,J;const Y=new Uint8Array($);for(let X=0;X<Y.length;X++){if(f0(this,x8,"f")===16)t8(this,L$,this.aes.encrypt(f0(this,k0,"f")),"f"),t8(this,x8,0,"f"),this.increment();Y[X]^=f0(this,L$,"f")[t8(this,x8,(J=f0(this,x8,"f"),Q=J++,J),"f"),Q]}return Y}decrypt($){return this.encrypt($)}}L$=new WeakMap,x8=new WeakMap,k0=new WeakMap;function VQ($){if($.length<16)throw new TypeError("PKCS#7 invalid length");const Q=$[$.length-1];if(Q>16)throw new TypeError("PKCS#7 padding byte out of range");const J=$.length-Q;for(let Y=0;Y<Q;Y++)if($[J+Y]!==Q)throw new TypeError("PKCS#7 invalid padding byte");return new Uint8Array($.subarray(0,J))}function zQ($){if(typeof $==="string"&&!$.startsWith("0x"))$="0x"+$;return b0($)}function e8($,Q){$=String($);while($.length<Q)$="0"+$;return $}function v8($){if(typeof $==="string")return W0($,"NFKC");return b0($)}function J0($,Q){const J=Q.match(/^([a-z0-9$_.-]*)(:([a-z]+))?(!)?$/i);O(J!=null,"invalid path","path",Q);const Y=J[1],X=J[3],Z=J[4]==="!";let M=$;for(let q of Y.toLowerCase().split(".")){if(Array.isArray(M)){if(!q.match(/^[0-9]+$/))break;M=M[parseInt(q)]}else if(typeof M==="object"){let U=null;for(let G in M)if(G.toLowerCase()===q){U=M[G];break}M=U}else M=null;if(M==null)break}if(O(!Z||M!=null,"missing required value","path",Y),X&&M!=null){if(X==="int"){if(typeof M==="string"&&M.match(/^-?[0-9]+$/))return parseInt(M);else if(Number.isSafeInteger(M))return M}if(X==="number"){if(typeof M==="string"&&M.match(/^-?[0-9.]*$/))return parseFloat(M)}if(X==="data"){if(typeof M==="string")return zQ(M)}if(X==="array"&&Array.isArray(M))return M;if(X===typeof M)return M;O(!1,`wrong type found for ${X} `,"path",Y)}return M}function W9($){try{const Q=JSON.parse($);if((Q.version!=null?parseInt(Q.version):0)===3)return!0}catch(Q){}return!1}var R5=function($,Q,J){if(J0($,"crypto.cipher:string")==="aes-128-ctr"){const X=J0($,"crypto.cipherparams.iv:data!"),Z=new R8(Q,X);return H(Z.decrypt(J))}F(!1,"unsupported cipher","UNSUPPORTED_OPERATION",{operation:"decrypt"})},G9=function($,Q){const J=C(Q),Y=J0($,"crypto.ciphertext:data!"),X=H(n(o([J.slice(16,32),Y]))).substring(2);O(X===J0($,"crypto.mac:string!").toLowerCase(),"incorrect password","password","[ REDACTED ]");const Z=R5($,J.slice(0,16),Y),M=X8(Z);if($.address){let G=$.address.toLowerCase();if(!G.startsWith("0x"))G="0x"+G;O(m(G)===M,"keystore address/privateKey mismatch","address",$.address)}const q={address:M,privateKey:Z};if(J0($,"x-ethers.version:string")==="0.1"){const G=J.slice(32,64),W=J0($,"x-ethers.mnemonicCiphertext:data!"),V=J0($,"x-ethers.mnemonicCounter:data!"),I=new R8(G,V);q.mnemonic={path:J0($,"x-ethers.path:string")||HY,locale:J0($,"x-ethers.locale:string")||"en",entropy:H(C(I.decrypt(W)))}}return q},NY=function($){const Q=J0($,"crypto.kdf:string");if(Q&&typeof Q==="string"){if(Q.toLowerCase()==="scrypt"){const J=J0($,"crypto.kdfparams.salt:data!"),Y=J0($,"crypto.kdfparams.n:int!"),X=J0($,"crypto.kdfparams.r:int!"),Z=J0($,"crypto.kdfparams.p:int!");O(Y>0&&(Y&Y-1)===0,"invalid kdf.N","kdf.N",Y),O(X>0&&Z>0,"invalid kdf","kdf",Q);const M=J0($,"crypto.kdfparams.dklen:int!");return O(M===32,"invalid kdf.dklen","kdf.dflen",M),{name:"scrypt",salt:J,N:Y,r:X,p:Z,dkLen:64}}else if(Q.toLowerCase()==="pbkdf2"){const J=J0($,"crypto.kdfparams.salt:data!"),Y=J0($,"crypto.kdfparams.prf:string!"),X=Y.split("-").pop();O(X==="sha256"||X==="sha512","invalid kdf.pdf","kdf.pdf",Y);const Z=J0($,"crypto.kdfparams.c:int!"),M=J0($,"crypto.kdfparams.dklen:int!");return O(M===32,"invalid kdf.dklen","kdf.dklen",M),{name:"pbkdf2",salt:J,count:Z,dkLen:M,algorithm:X}}}O(!1,"unsupported key-derivation function","kdf",Q)};function IQ($,Q){const J=JSON.parse($),Y=v8(Q),X=NY(J);if(X.name==="pbkdf2"){const{salt:V,count:I,dkLen:E,algorithm:z}=X,D=E0(Y,V,I,E,z);return G9(J,D)}F(X.name==="scrypt","cannot be reached","UNKNOWN_ERROR",{params:X});const{salt:Z,N:M,r:q,p:U,dkLen:G}=X,W=e0(Y,Z,M,q,U,G);return G9(J,W)}var jY=function($){return new Promise((Q)=>{setTimeout(()=>{Q()},$)})};async function DQ($,Q,J){const Y=JSON.parse($),X=v8(Q),Z=NY(Y);if(Z.name==="pbkdf2"){if(J)J(0),await jY(0);const{salt:I,count:E,dkLen:z,algorithm:D}=Z,R=E0(X,I,E,z,D);if(J)J(1),await jY(0);return G9(Y,R)}F(Z.name==="scrypt","cannot be reached","UNKNOWN_ERROR",{params:Z});const{salt:M,N:q,r:U,p:G,dkLen:W}=Z,V=await t0(X,M,q,U,G,W,J);return G9(Y,V)}var CY=function($){const Q=$.salt!=null?C($.salt,"options.salt"):Z0(32);let J=1<<17,Y=8,X=1;if($.scrypt){if($.scrypt.N)J=$.scrypt.N;if($.scrypt.r)Y=$.scrypt.r;if($.scrypt.p)X=$.scrypt.p}return O(typeof J==="number"&&J>0&&Number.isSafeInteger(J)&&(BigInt(J)&BigInt(J-1))===BigInt(0),"invalid scrypt N parameter","options.N",J),O(typeof Y==="number"&&Y>0&&Number.isSafeInteger(Y),"invalid scrypt r parameter","options.r",Y),O(typeof X==="number"&&X>0&&Number.isSafeInteger(X),"invalid scrypt p parameter","options.p",X),{name:"scrypt",dkLen:32,salt:Q,N:J,r:Y,p:X}},EY=function($,Q,J,Y){const X=C(J.privateKey,"privateKey"),Z=Y.iv!=null?C(Y.iv,"options.iv"):Z0(16);O(Z.length===16,"invalid options.iv length","options.iv",Y.iv);const M=Y.uuid!=null?C(Y.uuid,"options.uuid"):Z0(16);O(M.length===16,"invalid options.uuid length","options.uuid",Y.iv);const q=$.slice(0,16),U=$.slice(16,32),G=new R8(q,Z),W=C(G.encrypt(X)),V=n(o([U,W])),I={address:J.address.substring(2).toLowerCase(),id:b$(M),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:H(Z).substring(2)},ciphertext:H(W).substring(2),kdf:"scrypt",kdfparams:{salt:H(Q.salt).substring(2),n:Q.N,dklen:32,p:Q.p,r:Q.r},mac:V.substring(2)}};if(J.mnemonic){const E=Y.client!=null?Y.client:`ethers/${P$}`,z=J.mnemonic.path||HY,D=J.mnemonic.locale||"en",R=$.slice(32,64),L=C(J.mnemonic.entropy,"account.mnemonic.entropy"),S=Z0(16),k=new R8(R,S),T=C(k.encrypt(L)),K=new Date,P="UTC--"+(K.getUTCFullYear()+"-"+e8(K.getUTCMonth()+1,2)+"-"+e8(K.getUTCDate(),2)+"T"+e8(K.getUTCHours(),2)+"-"+e8(K.getUTCMinutes(),2)+"-"+e8(K.getUTCSeconds(),2)+".0Z--")+I.address;I["x-ethers"]={client:E,gethFilename:P,path:z,locale:D,mnemonicCounter:H(S).substring(2),mnemonicCiphertext:H(T).substring(2),version:"0.1"}}return JSON.stringify(I)};function j$($,Q,J){if(J==null)J={};const Y=v8(Q),X=CY(J),Z=e0(Y,X.salt,X.N,X.r,X.p,64);return EY(C(Z),X,$,J)}async function H$($,Q,J){if(J==null)J={};const Y=v8(Q),X=CY(J),Z=await t0(Y,X.salt,X.N,X.r,X.p,64,J.progressCallback);return EY(C(Z),X,$,J)}var HY="m/44'/60'/0'/0/0";var V9=function($,Q){let J="";while($)J=j5[$%16]+J,$=Math.trunc($/16);while(J.length<Q*2)J="0"+J;return"0x"+J},KQ=function($){const Q=C($),J=u8(O0(O0(Q)),0,4),Y=o([Q,J]);return k$(Y)},PY=function($,Q,J,Y){const X=new Uint8Array(37);if($&T8)F(Y!=null,"cannot derive child of neutered node","UNSUPPORTED_OPERATION",{operation:"deriveChild"}),X.set(C(Y),1);else X.set(C(J));for(let M=24;M>=0;M-=8)X[33+(M>>3)]=$>>24-M&255;const Z=C(a0("sha512",Q,X));return{IL:Z.slice(0,32),IR:Z.slice(32)}},SY=function($,Q){const J=Q.split("/");if(O(J.length>0,"invalid path","path",Q),J[0]==="m")O($.depth===0,`cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${$.depth}`,"path",Q),J.shift();let Y=$;for(let X=0;X<J.length;X++){const Z=J[X];if(Z.match(/^[0-9]+'$/)){const M=parseInt(Z.substring(0,Z.length-1));O(M<T8,"invalid path index",`path[${X}]`,Z),Y=Y.deriveChild(T8+M)}else if(Z.match(/^[0-9]+$/)){const M=parseInt(Z);O(M<T8,"invalid path index",`path[${X}]`,Z),Y=Y.deriveChild(M)}else O(!1,"invalid path component",`path[${X}]`,Z)}return Y};var O9="m/44'/60'/0'/0/0",T5=new Uint8Array([66,105,116,99,111,105,110,32,115,101,101,100]),T8=2147483648,L5=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),j5="0123456789abcdef",p0={};class j0 extends b8{publicKey;fingerprint;parentFingerprint;mnemonic;chainCode;path;index;depth;constructor($,Q,J,Y,X,Z,M,q,U){super(Q,U);n0($,p0,"HDNodeWallet"),a(this,{publicKey:Q.compressedPublicKey});const G=u8(s0(O0(this.publicKey)),0,4);a(this,{parentFingerprint:J,fingerprint:G,chainCode:Y,path:X,index:Z,depth:M}),a(this,{mnemonic:q})}connect($){return new j0(p0,this.signingKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.mnemonic,$)}#$(){const $={address:this.address,privateKey:this.privateKey},Q=this.mnemonic;if(this.path&&Q&&Q.wordlist.locale==="en"&&Q.password==="")$.mnemonic={path:this.path,locale:"en",entropy:Q.entropy};return $}async encrypt($,Q){return await H$(this.#$(),$,{progressCallback:Q})}encryptSync($){return j$(this.#$(),$)}get extendedKey(){return F(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),KQ(o(["0x0488ADE4",V9(this.depth,1),this.parentFingerprint,V9(this.index,4),this.chainCode,o(["0x00",this.privateKey])]))}hasPath(){return this.path!=null}neuter(){return new $$(p0,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.provider)}deriveChild($){const Q=q0($,"index");O(Q<=4294967295,"invalid index","index",Q);let J=this.path;if(J){if(J+="/"+(Q&~T8),Q&T8)J+="'"}const{IR:Y,IL:X}=PY(Q,this.chainCode,this.publicKey,this.privateKey),Z=new X0(x0((d8(X)+BigInt(this.privateKey))%L5,32));return new j0(p0,Z,this.fingerprint,H(Y),J,Q,this.depth+1,this.mnemonic,this.provider)}derivePath($){return SY(this,$)}static#Q($,Q){O(y0($),"invalid seed","seed","[REDACTED]");const J=C($,"seed");O(J.length>=16&&J.length<=64,"invalid seed","seed","[REDACTED]");const Y=C(a0("sha512",T5,J)),X=new X0(H(Y.slice(0,32)));return new j0(p0,X,"0x00000000",H(Y.slice(32)),"m",0,0,Q,null)}static fromExtendedKey($){const Q=s(_$($));O(Q.length===82||KQ(Q.slice(0,78))===$,"invalid extended key","extendedKey","[ REDACTED ]");const J=Q[4],Y=H(Q.slice(5,9)),X=parseInt(H(Q.slice(9,13)).substring(2),16),Z=H(Q.slice(13,45)),M=Q.slice(45,78);switch(H(Q.slice(0,4))){case"0x0488b21e":case"0x043587cf":{const q=H(M);return new $$(p0,X8(q),q,Y,Z,null,X,J,null)}case"0x0488ade4":case"0x04358394 ":if(M[0]!==0)break;return new j0(p0,new X0(M.slice(1)),Y,Z,null,X,J,null,null)}O(!1,"invalid extended key prefix","extendedKey","[ REDACTED ]")}static createRandom($,Q,J){if($==null)$="";if(Q==null)Q=O9;if(J==null)J=M8.wordlist();const Y=q8.fromEntropy(Z0(16),$,J);return j0.#Q(Y.computeSeed(),Y).derivePath(Q)}static fromMnemonic($,Q){if(!Q)Q=O9;return j0.#Q($.computeSeed(),$).derivePath(Q)}static fromPhrase($,Q,J,Y){if(Q==null)Q="";if(J==null)J=O9;if(Y==null)Y=M8.wordlist();const X=q8.fromPhrase($,Q,Y);return j0.#Q(X.computeSeed(),X).derivePath(J)}static fromSeed($){return j0.#Q($,null)}}class $$ extends D${publicKey;fingerprint;parentFingerprint;chainCode;path;index;depth;constructor($,Q,J,Y,X,Z,M,q,U){super(Q,U);n0($,p0,"HDNodeVoidWallet"),a(this,{publicKey:J});const G=u8(s0(O0(J)),0,4);a(this,{publicKey:J,fingerprint:G,parentFingerprint:Y,chainCode:X,path:Z,index:M,depth:q})}connect($){return new $$(p0,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,$)}get extendedKey(){return F(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),KQ(o(["0x0488B21E",V9(this.depth,1),this.parentFingerprint,V9(this.index,4),this.chainCode,this.publicKey]))}hasPath(){return this.path!=null}deriveChild($){const Q=q0($,"index");O(Q<=4294967295,"invalid index","index",Q);let J=this.path;if(J){if(J+="/"+(Q&~T8),Q&T8)J+="'"}const{IR:Y,IL:X}=PY(Q,this.chainCode,this.publicKey,null),Z=X0.addPoints(X,this.publicKey,!0),M=X8(Z);return new $$(p0,M,Z,this.fingerprint,H(Y),J,Q,this.depth+1,this.provider)}derivePath($){return SY(this,$)}}function z9($){try{if(JSON.parse($).encseed)return!0}catch(Q){}return!1}function I9($,Q){const J=JSON.parse($),Y=v8(Q),X=m(J0(J,"ethaddr:string!")),Z=zQ(J0(J,"encseed:string!"));O(Z&&Z.length%16===0,"invalid encseed","json",$);const M=C(E0(Y,Y,2000,32,"sha256")).slice(0,16),q=Z.slice(0,16),U=Z.slice(16),G=new T$(M,q),W=VQ(C(G.decrypt(U)));let V="";for(let I=0;I<W.length;I++)V+=String.fromCharCode(W[I]);return{address:X,privateKey:Z8(V)}}var wY=function($){return new Promise((Q)=>{setTimeout(()=>{Q()},$)})};class _0 extends b8{constructor($,Q){if(typeof $==="string"&&!$.startsWith("0x"))$="0x"+$;let J=typeof $==="string"?new X0($):$;super(J,Q)}connect($){return new _0(this.signingKey,$)}async encrypt($,Q){const J={address:this.address,privateKey:this.privateKey};return await H$(J,$,{progressCallback:Q})}encryptSync($){const Q={address:this.address,privateKey:this.privateKey};return j$(Q,$)}static#$($){if(O($,"invalid JSON wallet","json","[ REDACTED ]"),("mnemonic"in $)&&$.mnemonic&&$.mnemonic.locale==="en"){const J=q8.fromEntropy($.mnemonic.entropy),Y=j0.fromMnemonic(J,$.mnemonic.path);if(Y.address===$.address&&Y.privateKey===$.privateKey)return Y;console.log("WARNING: JSON mismatch address/privateKey != mnemonic; fallback onto private key")}const Q=new _0($.privateKey);return O(Q.address===$.address,"address/privateKey mismatch","json","[ REDACTED ]"),Q}static async fromEncryptedJson($,Q,J){let Y=null;if(W9($))Y=await DQ($,Q,J);else if(z9($)){if(J)J(0),await wY(0);if(Y=I9($,Q),J)J(1),await wY(0)}return _0.#$(Y)}static fromEncryptedJsonSync($,Q){let J=null;if(W9($))J=IQ($,Q);else if(z9($))J=I9($,Q);else O(!1,"invalid JSON wallet","json","[ REDACTED ]");return _0.#$(J)}static createRandom($){const Q=j0.createRandom();if($)return Q.connect($);return Q}static fromPhrase($,Q){const J=j0.fromPhrase($);if(Q)return J.connect(Q);return J}}function AY($,Q,J,Y=[]){let X=$;const Z=Q,M=J,q=(Y||[]).map((T)=>{try{return m(T)}catch(K){return console.warn(`\u26A0\uFE0F SM: Invalid superadmin address skipped: ${Q$(T)}`),null}}).filter(Boolean);let U=null,G=X&&typeof X.getAddress==="function"?W():Promise.resolve();async function W(){if(X)U=m(await X.getAddress())}async function V(T){X=T,U=null,G=T&&typeof T.getAddress==="function"?W():Promise.resolve(),await G}async function I(){return G}function E(T){return JSON.stringify(T,Object.keys(T).sort())}async function z(T){if(await I(),!X||!U)return console.warn("\u26A0\uFE0F SM: Cannot sign outgoing operations; no active signer session."),[];const K=U,N=[];for(let P of T){const B={...P,originUser:K},w=E(B);try{const f=await X.signMessage(W0(w));N.push({...P,originUser:K,originEthAddress:K,signature:f})}catch(f){console.error(`\u274C SM: Failed to sign operation for ${Q$(K)}:`,f.message)}}return N}async function D(T){const K=[];for(let P of T){let B,w;const f=["signature","originEthAddress","originUser"].filter((p)=>!P[p]);if(f.length){console.warn(`\u26A0\uFE0F SM: Incomplete op, missing: [${f.join(", ")}]. Discarding.`,P);continue}try{if(B=m(P.originEthAddress),m(P.originUser)!==B){console.warn("\u26A0\uFE0F SM: Address discrepancy. Discarding.",P);continue}}catch(p){console.warn("\u26A0\uFE0F SM: Invalid address format. Discarding.",p.message,P);continue}const{signature:b,originEthAddress:y,...e}=P;w=e;const u=E(w);try{const p=Q9(W0(u),b);if(m(p)!==B){console.warn("\u26A0\uFE0F SM: Invalid signature. Discarding.",w);continue}}catch(p){console.error("\u274C SM: Signature verification error. Discarding.",p.message,w);continue}let j,A;if(q.includes(B))j="superadmin",console.log(`\uD83D\uDEE1\uFE0F SM: Sender ${Q$(B)} recognized as a config Super Admin.`);else{A=await Z.get(`user:${B}`);const p=A.result?.value;j=p?.role&&!(p?.expiresAt&&new Date(p.expiresAt)<new Date)?p.role:"guest"}const _=w.type,v=M.mapChangeTypeToAction(_,w),{role:c,ethAddress:l}=w.value??{};if(c==="superadmin"&&!q.includes(m(l??""))){console.warn(`\u26A0\uFE0F SM: [POLICY VIOLATION] ${Q$(B)} tried to assign 'superadmin' to ${Q$(l)}. Discarded.`);continue}if(M.can(j,v))K.push(w);else console.warn(`\u26A0\uFE0F SM: Sender ${Q$(B)} (role: ${j}) DENIED operation with action '${v}'.`,w)}return{validatedOperations:K}}async function R(T){if(await I(),!X)throw new Error("\uD83D\uDEE1\uFE0F SM Encrypt: User session (signer) required for encryption.");try{const K=await S("ssm-encrypt-for-current-user-v1"),N=Z.encode(T),P=Z.pako.deflate(N),B=Z0(12),w=await crypto.subtle.encrypt({name:"AES-GCM",iv:B},K,P);return JSON.stringify({iv:H(B),encrypted:H(new Uint8Array(w)),type:"aes-gcm-self-ssm-v2"})}catch(K){throw console.error("\uD83D\uDEE1\uFE0F SM: Error in encryptDataForCurrentUser:",K),new Error("\uD83D\uDEE1\uFE0F SM: Failed to encrypt personal data.")}}async function L(T){if(await I(),!X)throw new Error("\uD83D\uDEE1\uFE0F SM Decrypt: User session (signer) required for decryption.");let K;try{K=JSON.parse(T)}catch{throw new Error("\uD83D\uDEE1\uFE0F SM Decrypt: encryptedString is not valid JSON.")}if(K.type!=="aes-gcm-self-ssm-v2")throw new Error("\uD83D\uDEE1\uFE0F SM Decrypt: Unsupported encryption type or incorrect version.");if(!K.iv||!K.encrypted)throw new Error("\uD83D\uDEE1\uFE0F SM Decrypt: Invalid encrypted data format.");try{const N=C(K.iv),P=C(K.encrypted),B=await S("ssm-encrypt-for-current-user-v1"),w=await crypto.subtle.decrypt({name:"AES-GCM",iv:N},B,P),f=Z.pako.inflate(new Uint8Array(w));return Z.decode(f)}catch(N){throw console.error("\uD83D\uDEE1\uFE0F SM: Error in decryptDataForCurrentUser:",N),new Error("\uD83D\uDEE1\uFE0F SM: Failed to decrypt personal data.")}}async function S(T="ssm-default-aes-salt"){const K=C(X.privateKey),N=W0(T),P=await crypto.subtle.importKey("raw",K,{name:"PBKDF2"},!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:N,iterations:1e5,hash:"SHA-256"},P,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}return{get localUserEthAddress(){return U},updateSigner:V,signOutgoingOperations:z,verifyIncomingOperations:D,encryptDataForCurrentUser:R,decryptDataForCurrentUser:L}}var Q$=($)=>`${$.slice(0,6)}...${$.slice(-4)}`;var J$=function($){if(!($ instanceof ArrayBuffer))if($.buffer&&$.buffer instanceof ArrayBuffer)$=$.buffer.slice($.byteOffset,$.byteOffset+$.byteLength);else throw console.error("\u274C SM: arrayBufferToBase64Url input is not ArrayBuffer nor TypedArray with .buffer",$),new Error("arrayBufferToBase64Url: ArrayBuffer or TypedArray required.");return btoa(String.fromCharCode(...new Uint8Array($))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},Y$=function($){let Q=$.replace(/-/g,"+").replace(/_/g,"/");const J=atob(Q),Y=new ArrayBuffer(J.length),X=new Uint8Array(Y);for(let Z=0;Z<J.length;Z++)X[Z]=J.charCodeAt(Z);return Y};function BY(){let $=null,Q=null,J=null,Y=null,X=null;async function Z(){const T=_0.createRandom();return J=T.mnemonic.phrase,console.log("\uD83D\uDEE1\uFE0F SM: New Ethereum identity generated (mnemonic and private key in memory)."),{address:await T.getAddress(),mnemonic:J,privateKey:T.privateKey}}async function M(T,K){const N=Z0(12),P=C(T),B=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:N},K,P);return JSON.stringify({iv:J$(N.buffer.slice(N.byteOffset,N.byteOffset+N.byteLength)),ciphertext:J$(B)})}async function q(T,K){const{iv:N,ciphertext:P}=JSON.parse(T),B=Y$(N),w=Y$(P),f=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(B)},K,w);return H(new Uint8Array(f))}async function U(T,K){const N=await window.crypto.subtle.importKey("raw",K,{name:"PBKDF2"},!1,["deriveKey"]);return window.crypto.subtle.deriveKey({name:"PBKDF2",salt:T,iterations:200000,hash:"SHA-256"},N,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}async function G(T,K){const N=localStorage.getItem(D9);if(!N)return console.warn("\u26A0\uFE0F SM (_loadAndDecrypt): No encrypted Ethereum material found."),D(),null;try{const P=await U(T,K),B=await q(N,P),w=new _0(B);return $=w,Q=await w.getAddress(),J=null,Y=T,X=K,console.log(`\u2705 SM (_loadAndDecrypt): Session established for ${N5(Q)}`),Q}catch(P){return console.error("\u274C SM (_loadAndDecrypt): Error (decryption/wallet loading):",P),D(),null}}async function W(T){if(!window.navigator.credentials||!window.navigator.credentials.create)return console.error("\u274C SM: WebAuthn is not supported by this browser."),alert("WebAuthn is not supported by this browser."),!1;const K=Z0(32),N=K.buffer.slice(K.byteOffset,K.byteOffset+K.byteLength);try{const P=X0.computePublicKey(T,!1),B=C(P),w=C(n(B)),b=w.buffer.slice(w.byteOffset,w.byteOffset+Math.min(w.length,64)),e=new _0(T).address.slice(0,10),u={challenge:N,rp:{name:"GDB WebAuthn App",id:window.location.hostname},user:{id:b,name:`user-${e}`,displayName:"GDB User"},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{authenticatorAttachment:"platform",userVerification:"preferred",residentKey:"preferred",requireResidentKey:!1},timeout:60000,attestation:"none"},j=await window.navigator.credentials.create({publicKey:u});if(!j||!j.rawId||!j.id)throw new Error("\u274C WebAuthn registration failed or was canceled (no credential).");const A=j.rawId,_=await U(A,N),v=await M(T,_);return localStorage.setItem(D9,v),localStorage.setItem(N$,JSON.stringify({credentialIdBase64Url:J$(A),originalChallengeBase64Url:J$(N)})),console.log("\uD83D\uDEE1\uFE0F SM: WebAuthn registered and Ethereum key encrypted and saved."),await G(A,N)}catch(P){return console.error("\u274C SM: Error during WebAuthn registration:",P),D(),localStorage.removeItem(D9),localStorage.removeItem(N$),alert(`\u274C WebAuthn registration error: ${P.message||"Unknown. Check console."}`),!1}}async function V(){if(!window.navigator.credentials||!window.navigator.credentials.get)return console.error("\u274C SM: WebAuthn is not supported."),alert("WebAuthn is not supported by this browser."),null;const T=localStorage.getItem(N$);if(!T)return console.warn("\u26A0\uFE0F SM: No WebAuthn registration details saved."),null;let K;try{K=JSON.parse(T)}catch(f){return console.error("\u274C SM: Error parsing WebAuthn registration details from localStorage:",f),null}if(!K.credentialIdBase64Url||!K.originalChallengeBase64Url)return console.error("\u274C SM: WebAuthn registration details in localStorage are incomplete."),null;const N=Y$(K.credentialIdBase64Url),P=Y$(K.originalChallengeBase64Url),B=Z0(32),w=B.buffer.slice(B.byteOffset,B.byteOffset+B.byteLength);try{const f={challenge:w,allowCredentials:[{type:"public-key",id:N}],userVerification:"preferred",timeout:60000},b=await window.navigator.credentials.get({publicKey:f});if(!b||!b.rawId||!b.response||!b.response.authenticatorData||!b.response.signature||!b.response.clientDataJSON)throw new Error("\u274C WebAuthn authentication failed or was canceled (incomplete assertion).");if(J$(b.rawId)!==K.credentialIdBase64Url)throw new Error("\u274C WebAuthn credential ID in assertion does not match stored ID.");const y=JSON.parse((new TextDecoder()).decode(b.response.clientDataJSON));if(y.challenge!==J$(w))throw new Error("\u274C WebAuthn assertion challenge mismatch.");if(y.origin!==`https://${window.location.hostname}`&&y.origin!==`http://${window.location.hostname}`){let e=window.location.protocol+"//";if(y.origin.startsWith(e+window.location.hostname));else if(window.location.hostname==="localhost"&&y.origin.startsWith(e+"localhost"));else console.warn("\u26A0\uFE0F SM: WebAuthn assertion origin mismatch. Expected based on hostname:",window.location.hostname,"Got:",y.origin)}return console.log("\uD83D\uDEE1\uFE0F SM: Interactive WebAuthn assertion received and validated."),await G(b.rawId,P)}catch(f){return console.error("\u274C SM: Error during interactive WebAuthn login:",f),D(),null}}async function I(){console.log("\uD83D\uDEE1\uFE0F SM: Attempting silent WebAuthn login...");const T=localStorage.getItem(N$);if(!T)return console.warn("\u26A0\uFE0F SM Silent Login: No WebAuthn registration details."),null;let K;try{K=JSON.parse(T)}catch(N){return console.error("\u274C SM Silent Login: Error parsing registration details:",N),null}if(!K.credentialIdBase64Url||!K.originalChallengeBase64Url)return console.error("\u274C SM Silent Login: Incomplete WebAuthn registration details."),null;try{const N=Y$(K.credentialIdBase64Url),P=Y$(K.originalChallengeBase64Url),B=await G(N,P);if(B)return console.log(`\u2705 SM Silent Login: Success for ${B}.`),B;else return console.warn("\u26A0\uFE0F SM Silent Login: _loadAndDecryptWalletFromWebAuthnMaterial failed."),null}catch(N){return console.error("\u274C SM Silent Login: Error during silent login attempt:",N),D(),null}}async function E(T){try{const K=_0.fromPhrase(T);return $=K,Q=await K.getAddress(),J=T,Y=null,X=null,{address:Q,privateKey:K.privateKey,mnemonic:J}}catch(K){return console.error("\u274C SM: Error loading wallet from mnemonic:",K),D(),null}}function z(){return localStorage.getItem(N$)!==null&&localStorage.getItem(D9)!==null}function D(){$=null,Q=null,J=null,Y=null,X=null}function R(){return $}function L(){return Q}function S(){if(J&&(!Y||!X))return J;return null}function k(){return!!($&&Y&&X)}return{createNewEthereumIdentity:Z,registerAndProtectWithWebAuthn:W,loginWithWebAuthn:V,trySilentWebAuthnLogin:I,loadWalletFromMnemonic:E,hasWebAuthnRegistration:z,logout:D,getSigner:R,getAddress:L,getMnemonicForDisplay:S,isSessionWebAuthnProtected:k}}var D9="gdb_ethereum_material_encrypted_webauthn_v2",N$="gdb_webauthn_registration_details_v2",N5=($)=>`${$.slice(0,6)}...${$.slice(-4)}`;var C5=function($){if(typeof $!=="object"||$===null||Array.isArray($))throw new Error("\uD83D\uDEE1\uFE0F SM: Custom roles must be a valid object.");RQ=$,console.log("\uD83D\uDEE1\uFE0F SM: Custom roles set.")},TQ=function($,Q,J=new Set){const Y=RQ;if(!$||!Y[$])return!1;if(J.has($))return console.warn(`\u26A0\uFE0F SM: Inheritance loop detected involving role '${$}'.`),!1;if(J.add($),Y[$].can&&Y[$].can.includes(Q))return J.delete($),!0;if(Y[$].inherits&&Array.isArray(Y[$].inherits)){if(Y[$].inherits.some((X)=>TQ(X,Q,new Set(J))))return J.delete($),!0}return J.delete($),!1},E5=function($,Q={}){if($==="upsert")return"write";if($==="remove")return"delete";if($==="link")return"link";if($==="sync"||$==="syncReceive"||$==="deltaSync")return"sync";return console.warn(`\u26A0\uFE0F SM mapChangeTypeToAction: Unknown change type '${$}'.`),"unknown"};function D4($){if(typeof $==="function")R9=$,N0();else if($===null)R9=null;else console.warn("\u26A0\uFE0F SM: Attempted to set invalid state change callback.")}function K4($){if(typeof $==="function")T9=$,N0();else if($===null)T9=null;else console.warn("\u26A0\uFE0F SM: Attempted to set invalid governance state change callback.")}var N0=function(){if(R9)R9({isActive:T0,activeAddress:Q0?.localUserEthAddress||t.getAddress(),abbrAddr:L8(Q0?.localUserEthAddress||t.getAddress()||"N/A"),isWebAuthnProtected:m0,hasVolatileIdentity:!!H0,hasWebAuthnHardwareRegistration:t.hasWebAuthnRegistration()});if(T9)T9({isActive:T0,activeAddress:Q0?.localUserEthAddress||t.getAddress()})};async function R4(){if(T0)await j9();t.logout(),H0=null,m0=!1,localStorage.removeItem(d0);try{const $=await t.createNewEthereumIdentity();if($)H0=$;return N0(),$}catch($){throw H0=null,N0(),$}}async function T4($){const Q=$||H0?.privateKey;if(!Q)return alert("\uD83D\uDEE1\uFE0F SM Error: No volatile ETH identity to protect."),null;if(T0&&m0&&Q0?.signer)return Q0.localUserEthAddress;if(T0)await j9();t.logout();const J=await t.registerAndProtectWithWebAuthn(Q);if(J&&t.getSigner()){if(H0=null,m0=!0,localStorage.setItem(d0,"true"),i)await L9(t.getSigner(),{method:"WebAuthn"});else console.warn("\u26A0\uFE0F SM: Identity protected, but GDB not configured. Global SM signing not active.");return J}else return m0=!1,localStorage.removeItem(d0),N0(),null}async function L4(){if(T0)await j9();t.logout(),H0=null;const $=await t.loginWithWebAuthn();if($&&t.getSigner()){if(m0=!0,localStorage.setItem(d0,"true"),i)await L9(t.getSigner(),{method:"silent WebAuthn"});else console.warn("\u26A0\uFE0F SM: WebAuthn login OK, but GDB not configured for full security activation.");return $}else return m0=!1,localStorage.removeItem(d0),N0(),null}async function j4($){if(T0)await j9();t.logout(),H0=null;const Q=await t.loadWalletFromMnemonic($);if(Q&&Q.address&&t.getSigner()){if(H0=Q,m0=!1,localStorage.removeItem(d0),i)await L9(t.getSigner(),{method:"mnemonic"});else console.warn("\u26A0\uFE0F SM: Mnemonic loaded, but GDB not configured for full security activation.");return H0}else return N0(),null}async function P5($,Q={}){if(!$){console.error("\u274C SM: GDB instance is required.");return}if(i=$,K9=((Q.superAdmins??[])||[]).map((Y)=>{try{return m(Y)}catch(X){return console.warn(`\u26A0\uFE0F SM: Invalid superadmin address skipped: ${L8(Y)}`),null}}).filter(Boolean),Q0=AY(null,i,{can:TQ,mapChangeTypeToAction:E5},K9),!FY)i.use(async function Y(X){const{validatedOperations:Z}=await Q0.verifyIncomingOperations(X);return Z||[]}),FY=!0;else console.info("\uD83D\uDEE1\uFE0F SM: Security middleware already registered. Skipping duplicate registration.");if(console.info("\uD83D\uDEE1\uFE0F SM: Security context established and middleware registered."),localStorage.getItem(d0)==="true"&&t.hasWebAuthnRegistration()){console.info("\uD83D\uDEE1\uFE0F SM: Previous WebAuthn session detected. Attempting silent login...");try{const Y=await t.trySilentWebAuthnLogin();if(Y&&t.getSigner())m0=!0,await L9(t.getSigner()),console.info(`\uD83D\uDEE1\uFE0F SM: Silent WebAuthn login successful for ${L8(Y)}.`);else console.warn("\u26A0\uFE0F SM: Silent WebAuthn login failed or no signer obtained. Manual login required."),localStorage.removeItem(d0),N0()}catch(Y){console.error("\u274C SM: Error during silent WebAuthn login attempt:",Y),localStorage.removeItem(d0),N0()}}else N0();if(Q.customRoles)C5(Q.customRoles);if(Q.acls){console.info("\uD83D\uDEE1\uFE0F SM: ACLS options activated.");try{(await import(new URL("./sm-acls.min.js",import.meta.url).href)).start(i,Q)}catch(Y){console.error("\u274C SM: Failed to load or start the ACLS module.",Y)}}if(Q.governanceRules)try{(await import(new URL("./sm-gov.min.js",import.meta.url).href)).start(i,Q)}catch(Y){console.error("\u274C SM: Failed to load or start the governance module.",Y)}}async function j9(){if(i&&i.syncChannel&&i.syncChannel._originalSendBySM)i.syncChannel.send=i.syncChannel._originalSendBySM,delete i.syncChannel._originalSendBySM;if(t.logout(),Q0)try{await Q0.updateSigner(null)}catch($){console.error("\u274C SM: Error during signer deactivation in clearSecurity:",$)}H0=null,m0=!1,localStorage.removeItem(d0),T0=!1,N0(),console.info("\uD83D\uDEE1\uFE0F SM: Session closed. Now in anonymous verification mode.")}async function H4($,Q){const J=Q??(typeof crypto!=="undefined"&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`),Y=`SM_ID_PREFIX_${J}`;if(!i)throw new Error("\u274C SM.put: Not initialized");if(!LQ())throw new Error("\u274C SM.put: Session not active");const{result:X}=await S5(J);if(X&&X.decrypted===!1)throw new Error(`\u274C SM.put: Cannot overwrite encrypted data on node ID '${Q}' owned by another user. DENIED.`);const Z=Q0;let M,q;try{const G=await Z.encryptDataForCurrentUser($),W=JSON.parse(G);M=W.encrypted,q={owner:Z.localUserEthAddress,encType:W.type,iv:W.iv}}catch(G){throw console.error(`\u274C SM.put: Encryption failed for ID ${Q||"(new)"}: ${G.message}`),G}const U={_gdbWrapperType:fY,_payload:M,_meta:q};return console.info(`\uD83D\uDEE1\uFE0F SM (put): Storing wrapped secure payload for ID: ${Q||"(new)"}`),await i.put(U,Y),J}async function S5($,Q=null){if(!$)throw new Error("\u274C SM.get: id is required");let J=`SM_ID_PREFIX_${$}`;if(!i)throw new Error("\u274C SM.get: Not initialized");const Y=Q0,X=async(U)=>{if(!U)return null;let G=U.value,W=!1;if(G&&G._gdbWrapperType===fY){const V=G,I=V._payload,E=V._meta;if(G=typeof I==="string"?I:V,E&&E.owner&&Y&&Y.localUserEthAddress&&E.owner===Y.localUserEthAddress)try{const z=JSON.stringify({iv:E.iv,encrypted:I,type:E.encType});G=await Y.decryptDataForCurrentUser(z),W=!0}catch(z){console.error(`\u274C SM.get: Decryption failed for node ${U.id}. User: ${Y.localUserEthAddress}, Owner: ${E.owner}. Error: ${z.message}`)}else if(E&&E.owner)console.warn(`\u26A0\uFE0F SM.get: Decryption not attempted for node ${U.id}. Owner: ${E.owner}. Session active: ${!!(Y&&Y.signer)}`);else console.warn(`\u26A0\uFE0F SM.get: Secure payload wrapper for node ${U.id} lacks sufficient metadata for decryption.`)}return{id:$,value:G,edges:U.edges||[],timestamp:U.timestamp,decrypted:W}};if(!Q){const U=await i.get(J,null);return{result:await X(U?U.result:null)}}let Z=null;const M=await i.get(J,null);if(Z=await X(M?M.result:null),typeof Q==="function")Q(Z);const{unsubscribe:q}=await i.get(J,async(U)=>{const G=await X(U),W=G&&Z&&i.hybridClock?.compare(G.timestamp,Z.timestamp)>0,V=JSON.stringify(G?G.value:null)!==JSON.stringify(Z?Z.value:null);if(!G&&Z){if(Z=null,typeof Q==="function")Q(null)}else if(G&&(!Z||W||V)){if(Z=G,typeof Q==="function")Q(G)}});return{result:Z,unsubscribe:()=>{if(q)q()}}}var kY=function(){if(!T0||!Q0?.localUserEthAddress)throw new Error("\u274C SM Operation: Security not active or no local user ETH identified in SecurityManager.");return Q0.localUserEthAddress};async function N4($,Q,J=null){if(!$||!Q)throw new Error("\u274C SM assignRole: targetUserEthAddress, and role are required.");let Y;try{Y=m($)}catch(G){throw new Error(`\u274C SM assignRole: targetUserEthAddress '${L8($)}' is invalid.`)}if(!RQ[Q])throw new Error(`\u274C SM assignRole: Role '${Q}' is not a defined role.`);const X=kY(),Z=`user:${Y}`,q=(await i.get(Z)).result?.value||{},U={...q,ethAddress:Y,role:Q,assignedByEthAddress:X,expiresAt:J?new Date(J).toISOString():null,priority:!0};await i.put(U,Z),console.info(`\uD83D\uDEE1\uFE0F SM: PROMOTING \x1B[32m ${L8(Y)} \x1B[0m from \x1B[32m '${q.role}' \x1B[0m to \x1B[32m ${Q} \x1B[0m by \x1B[32m ${L8(X)} \x1B[0m written.`)}async function w5(){if(!T0||!Q0?.localUserEthAddress)return!1;return K9.includes(Q0.localUserEthAddress)}async function A5($,Q="unknown"){let J;try{J=m($)}catch(Z){throw new Error(`\u274C SM: Invalid ETH address '${L8($)}' when verifying role for op '${Q}'.`)}const Y=await i.get(`user:${J}`);if(!Y.result?.value?.role)throw console.warn(`\u26A0\uFE0F SM verifyUserRoleLocal: Node/role not found for ETH ${J}. Op: ${Q}. Data:`,Y.result?.value),new Error(`\u274C SM: Role not found for ETH ${J} (operation: ${Q}).`);const X=Y.result.value;if(X.expiresAt&&new Date(X.expiresAt)<new Date)throw new Error(`\u274C SM: Role for ETH ${J} has expired.`);return X.role}async function B5($,Q){const J=await A5($,Q);if(!TQ(J,Q))throw new Error(`\u274C SM: ETH User ${$} (role ${J}) does not have permission for '${Q}'.`)}async function C4($){if(!$)throw new Error("\u274C SM executeWithPermission: operationName is required.");const Q=kY();if(!($==="assignRole"&&await w5()))await B5(Q,$);return Q}function E4(){return T0?Q0?.localUserEthAddress:null}function LQ(){return T0}function P4(){return T0&&m0}function S4(){return t.hasWebAuthnRegistration()}function w4(){if(H0&&H0.mnemonic&&!t.isSessionWebAuthnProtected())return H0.mnemonic;return t.getMnemonicForDisplay()}async function A4($){if(!LQ()||!Q0)throw new Error("\u274C SM Encryption: Local signing security not active or SecurityManager not available.");return await Q0.encryptDataForCurrentUser($)}async function B4($){if(!LQ()||!Q0)throw new Error("\u274C SM Decryption: Local signing security not active or SecurityManager not available.");return await Q0.decryptDataForCurrentUser($)}async function F4($,Q,J={}){i=$;const Y={...Q};return $.sm=Y,Object.hasOwn(J,"superAdmins")&&await P5($,J),Object.freeze(Y),{sm:Y}}var L8=($)=>`${$.slice(0,6)}...${$.slice(-4)}`,RQ={superadmin:{can:["assignRole","deleteAny"],inherits:["admin"]},admin:{can:["delete"],inherits:["manager"]},manager:{can:["publish"],inherits:["user"]},user:{can:["write","link","sync"],inherits:["guest"]},guest:{can:["read","sync"]}},d0="gdb_sm_last_session_was_webauthn",i=null,Q0=null,t=BY(),K9=[],T0=!1,FY=!1,H0=null,m0=!1,R9=null,T9=null,L9=async($,Q={})=>{if(!i||!Q0||!$)return console.error("\u274C SM: GDB, SSM, or signer missing."),T0=!1,N0(),!1;try{await Q0.updateSigner($)}catch(q){return console.error("\u274C SM: updateSigner failed:",q),T0=!1,N0(),!1}const{localUserEthAddress:J}=Q0,{syncChannel:Y}=i??{};if(Y?.send&&!Y._originalSendBySM)Y._originalSendBySM=Y.send.bind(Y),Y.send=async(q)=>Y._originalSendBySM(await Q0.signOutgoingOperations(q));const X=`user:${J}`;let Z={role:"unknown",status:"Existing user."};try{const{result:q}=await i.get(X);if(!q)Z.role=K9.includes(J)?"superadmin":"guest",Z.status="New user.",await i.put({ethAddress:J,role:Z.role},X);else Z.role=q.value.role||"unknown";Y?.send?.([{type:"sync",timestamp:null}])}catch(q){console.error(`\u274C SM: User node check failed for ${J}: ${q}`)}T0=!0,N0();const M=Q.method?` via ${Q.method}`:"";return console.info(`\uD83D\uDEE1\uFE0F\uD83D\uDD12 SM: ACTIVE for \x1B[32m${L8(J)} (${Z.role})\x1B[0m${M}. ${Z.status}`),!0},fY="_gdbSecurePayloadV1";export{R4 as startNewUserRegistration,D4 as setSecurityStateChangeCallback,K4 as setGovernanceStateChangeCallback,H4 as put,T4 as protectCurrentIdentityWithWebAuthn,j4 as loginOrRecoverUserWithMnemonic,L4 as loginCurrentUserWithWebAuthn,LQ as isSecurityActive,P4 as isCurrentSessionProtectedByWebAuthn,F4 as init,S4 as hasExistingWebAuthnRegistration,w4 as getMnemonicForDisplayAfterRegistrationOrRecovery,E4 as getActiveEthAddress,S5 as get,C4 as executeWithPermission,A4 as encryptDataForCurrentUser,B4 as decryptDataForCurrentUser,j9 as clearSecurity,N4 as assignRole,L8 as abbrAddr};
1
+ var _Y=Object.defineProperty;var bY=($,Q)=>{for(var J in Q)_Y($,J,{get:Q[J],enumerable:!0,configurable:!0,set:(Y)=>Q[J]=()=>Y})};var P$="6.15.0";var xY=function($,Q,J){const Y=Q.split("|").map((Z)=>Z.trim());for(let Z=0;Z<Y.length;Z++)switch(Q){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof $===Q)return}const X=new Error(`invalid value for type ${Q}`);throw X.code="INVALID_ARGUMENT",X.argument=`value.${J}`,X.value=$,X};async function h0($){const Q=Object.keys($);return(await Promise.all(Q.map((Y)=>Promise.resolve($[Y])))).reduce((Y,X,Z)=>{return Y[Q[Z]]=X,Y},{})}function a($,Q,J){for(let Y in Q){let X=Q[Y];const Z=J?J[Y]:null;if(Z)xY(X,Z,Y);Object.defineProperty($,Y,{enumerable:!0,value:X,writable:!1})}}var y8=function($,Q){if($==null)return"null";if(Q==null)Q=new Set;if(typeof $==="object"){if(Q.has($))return"[Circular]";Q.add($)}if(Array.isArray($))return"[ "+$.map((J)=>y8(J,Q)).join(", ")+" ]";if($ instanceof Uint8Array){let Y="0x";for(let X=0;X<$.length;X++)Y+="0123456789abcdef"[$[X]>>4],Y+="0123456789abcdef"[$[X]&15];return Y}if(typeof $==="object"&&typeof $.toJSON==="function")return y8($.toJSON(),Q);switch(typeof $){case"boolean":case"number":case"symbol":return $.toString();case"bigint":return BigInt($).toString();case"string":return JSON.stringify($);case"object":{const J=Object.keys($);return J.sort(),"{ "+J.map((Y)=>`${y8(Y,Q)}: ${y8($[Y],Q)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"};function S$($,Q){return $&&$.code===Q}function Y$($,Q,J){let Y=$;{const Z=[];if(J){if(("message"in J)||("code"in J)||("name"in J))throw new Error(`value will overwrite populated values: ${y8(J)}`);for(let M in J){if(M==="shortMessage")continue;const q=J[M];Z.push(M+"="+y8(q))}}if(Z.push(`code=${Q}`),Z.push(`version=${P$}`),Z.length)$+=" ("+Z.join(", ")+")"}let X;switch(Q){case"INVALID_ARGUMENT":X=new TypeError($);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":X=new RangeError($);break;default:X=new Error($)}if(a(X,{code:Q}),J)Object.assign(X,J);if(X.shortMessage==null)a(X,{shortMessage:Y});return X}function f($,Q,J,Y){if(!$)throw Y$(Q,J,Y)}function V($,Q,J,Y){f($,Q,"INVALID_ARGUMENT",{argument:J,value:Y})}function c8($){f(vY.indexOf($)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:$}})}function n0($,Q,J){if(J==null)J="";if($!==Q){let Y=J,X="new";if(J)Y+=".",X+=" "+J;f(!1,`private constructor; use ${Y}from* methods`,"UNSUPPORTED_OPERATION",{operation:X})}}var vY=["NFD","NFC","NFKD","NFKC"].reduce(($,Q)=>{try{if("test".normalize(Q)!=="test")throw new Error("bad");if(Q==="NFD"){const J=String.fromCharCode(233).normalize("NFD"),Y=String.fromCharCode(101,769);if(J!==Y)throw new Error("broken")}$.push(Q)}catch(J){}return $},[]);var EQ=function($,Q,J){if($ instanceof Uint8Array){if(J)return new Uint8Array($);return $}if(typeof $==="string"&&$.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const Y=new Uint8Array(($.length-2)/2);let X=2;for(let Z=0;Z<Y.length;Z++)Y[Z]=parseInt($.substring(X,X+2),16),X+=2;return Y}V(!1,"invalid BytesLike value",Q||"value",$)};function C($,Q){return EQ($,Q,!1)}function b0($,Q){return EQ($,Q,!0)}function D0($,Q){if(typeof $!=="string"||!$.match(/^0x[0-9A-Fa-f]*$/))return!1;if(typeof Q==="number"&&$.length!==2+2*Q)return!1;if(Q===!0&&$.length%2!==0)return!1;return!0}function y0($){return D0($,!0)||$ instanceof Uint8Array}function N($){const Q=C($);let J="0x";for(let Y=0;Y<Q.length;Y++){const X=Q[Y];J+=CQ[(X&240)>>4]+CQ[X&15]}return J}function l($){return"0x"+$.map((Q)=>N(Q).substring(2)).join("")}function o0($){if(D0($,!0))return($.length-2)/2;return C($).length}function u8($,Q,J){const Y=C($);if(J!=null&&J>Y.length)f(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:Y,length:Y.length,offset:J});return N(Y.slice(Q==null?0:Q,J==null?Y.length:J))}var mY=function($,Q,J){const Y=C($);f(Q>=Y.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(Y),length:Q,offset:Q+1});const X=new Uint8Array(Q);if(X.fill(0),J)X.set(Y,Q-Y.length);else X.set(Y,0);return N(X)};function C0($,Q){return mY($,Q,!0)}var CQ="0123456789abcdef";function w$($,Q){let J=h($,"value");const Y=BigInt(q0(Q,"width")),X=C8<<Y-C8;if(J<N9){J=-J,f(J<=X,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:$});const Z=(C8<<Y)-C8;return(~J&Z)+C8}else f(J<X,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:$});return J}function A$($,Q){const J=X$($,"value"),Y=BigInt(q0(Q,"bits"));return J&(C8<<Y)-C8}function h($,Q){switch(typeof $){case"bigint":return $;case"number":return V(Number.isInteger($),"underflow",Q||"value",$),V($>=-p8&&$<=p8,"overflow",Q||"value",$),BigInt($);case"string":try{if($==="")throw new Error("empty string");if($[0]==="-"&&$[1]!=="-")return-BigInt($.substring(1));return BigInt($)}catch(J){V(!1,`invalid BigNumberish string: ${J.message}`,Q||"value",$)}}V(!1,"invalid BigNumberish value",Q||"value",$)}function X$($,Q){const J=h($,Q);return f(J>=N9,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:$}),J}function d8($){if($ instanceof Uint8Array){let Q="0x0";for(let J of $)Q+=PQ[J>>4],Q+=PQ[J&15];return BigInt(Q)}return h($)}function q0($,Q){switch(typeof $){case"bigint":return V($>=-p8&&$<=p8,"overflow",Q||"value",$),Number($);case"number":return V(Number.isInteger($),"underflow",Q||"value",$),V($>=-p8&&$<=p8,"overflow",Q||"value",$),$;case"string":try{if($==="")throw new Error("empty string");return q0(BigInt($),Q)}catch(J){V(!1,`invalid numeric string: ${J.message}`,Q||"value",$)}}V(!1,"invalid numeric value",Q||"value",$)}function x0($,Q){let Y=X$($,"value").toString(16);if(Q==null){if(Y.length%2)Y="0"+Y}else{const X=q0(Q,"width");f(X*2>=Y.length,`value exceeds width (${X} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:$});while(Y.length<X*2)Y="0"+Y}return"0x"+Y}function s($){const Q=X$($,"value");if(Q===N9)return new Uint8Array([]);let J=Q.toString(16);if(J.length%2)J="0"+J;const Y=new Uint8Array(J.length/2);for(let X=0;X<Y.length;X++){const Z=X*2;Y[X]=parseInt(J.substring(Z,Z+2),16)}return Y}function B$($){let Q=N(y0($)?$:s($)).substring(2);while(Q.startsWith("0"))Q=Q.substring(1);if(Q==="")Q="0";return"0x"+Q}var N9=BigInt(0),C8=BigInt(1),p8=9007199254740991,PQ="0123456789abcdef";var gY=function($){if(F$==null){F$={};for(let J=0;J<f$.length;J++)F$[f$[J]]=BigInt(J)}const Q=F$[$];return V(Q!=null,"invalid base58 value","letter",$),Q};function k$($){const Q=C($);let J=d8(Q),Y="";while(J)Y=f$[Number(J%C9)]+Y,J/=C9;for(let X=0;X<Q.length;X++){if(Q[X])break;Y=f$[0]+Y}return Y}function _$($){let Q=hY;for(let J=0;J<$.length;J++)Q*=C9,Q+=gY($[J]);return Q}var f$="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",F$=null,hY=BigInt(0),C9=BigInt(58);var yY=function($,Q,J,Y,X){V(!1,`invalid codepoint at offset ${Q}; ${$}`,"bytes",J)},SQ=function($,Q,J,Y,X){if($==="BAD_PREFIX"||$==="UNEXPECTED_CONTINUE"){let Z=0;for(let M=Q+1;M<J.length;M++){if(J[M]>>6!==2)break;Z++}return Z}if($==="OVERRUN")return J.length-Q-1;return 0},cY=function($,Q,J,Y,X){if($==="OVERLONG")return V(typeof X==="number","invalid bad code point for replacement","badCodepoint",X),Y.push(X),0;return Y.push(65533),SQ($,Q,J,Y,X)};function W0($,Q){if(V(typeof $==="string","invalid string value","str",$),Q!=null)c8(Q),$=$.normalize(Q);let J=[];for(let Y=0;Y<$.length;Y++){const X=$.charCodeAt(Y);if(X<128)J.push(X);else if(X<2048)J.push(X>>6|192),J.push(X&63|128);else if((X&64512)==55296){Y++;const Z=$.charCodeAt(Y);V(Y<$.length&&(Z&64512)===56320,"invalid surrogate pair","str",$);const M=65536+((X&1023)<<10)+(Z&1023);J.push(M>>18|240),J.push(M>>12&63|128),J.push(M>>6&63|128),J.push(M&63|128)}else J.push(X>>12|224),J.push(X>>6&63|128),J.push(X&63|128)}return new Uint8Array(J)}var wQ=Object.freeze({error:yY,ignore:SQ,replace:cY});var uY=function($){let Q=$.toString(16);while(Q.length<2)Q="0"+Q;return"0x"+Q},AQ=function($,Q,J){let Y=0;for(let X=0;X<J;X++)Y=Y*256+$[Q+X];return Y},BQ=function($,Q,J,Y){const X=[];while(J<Q+1+Y){const Z=FQ($,J);X.push(Z.result),J+=Z.consumed,f(J<=Q+1+Y,"child data too short","BUFFER_OVERRUN",{buffer:$,length:Y,offset:Q})}return{consumed:1+Y,result:X}},FQ=function($,Q){f($.length!==0,"data too short","BUFFER_OVERRUN",{buffer:$,length:0,offset:1});const J=(Y)=>{f(Y<=$.length,"data short segment too short","BUFFER_OVERRUN",{buffer:$,length:$.length,offset:Y})};if($[Q]>=248){const Y=$[Q]-247;J(Q+1+Y);const X=AQ($,Q+1,Y);return J(Q+1+Y+X),BQ($,Q,Q+1+Y,Y+X)}else if($[Q]>=192){const Y=$[Q]-192;return J(Q+1+Y),BQ($,Q,Q+1,Y)}else if($[Q]>=184){const Y=$[Q]-183;J(Q+1+Y);const X=AQ($,Q+1,Y);J(Q+1+Y+X);const Z=N($.slice(Q+1+Y,Q+1+Y+X));return{consumed:1+Y+X,result:Z}}else if($[Q]>=128){const Y=$[Q]-128;J(Q+1+Y);const X=N($.slice(Q+1,Q+1+Y));return{consumed:1+Y,result:X}}return{consumed:1,result:uY($[Q])}};function G8($){const Q=C($,"data"),J=FQ(Q,0);return V(J.consumed===Q.length,"unexpected junk after rlp payload","data",$),J.result}var fQ=function($){const Q=[];while($)Q.unshift($&255),$>>=8;return Q},_Q=function($){if(Array.isArray($)){let Y=[];if($.forEach(function(Z){Y=Y.concat(_Q(Z))}),Y.length<=55)return Y.unshift(192+Y.length),Y;const X=fQ(Y.length);return X.unshift(247+X.length),X.concat(Y)}const Q=Array.prototype.slice.call(C($,"object"));if(Q.length===1&&Q[0]<=127)return Q;else if(Q.length<=55)return Q.unshift(128+Q.length),Q;const J=fQ(Q.length);return J.unshift(183+J.length),J.concat(Q)};function w0($){let Q="0x";for(let J of _Q($))Q+=kQ[J>>4],Q+=kQ[J&15];return Q}var kQ="0123456789abcdef";function b$($){const Q=C($,"randomBytes");Q[6]=Q[6]&15|64,Q[8]=Q[8]&63|128;const J=N(Q);return[J.substring(2,10),J.substring(10,14),J.substring(14,18),J.substring(18,22),J.substring(22,34)].join("-")}var I0=function($){if(!Number.isSafeInteger($)||$<0)throw new Error(`Wrong positive integer: ${$}`)};var Z$=function($,...Q){if(!($ instanceof Uint8Array))throw new Error("Expected Uint8Array");if(Q.length>0&&!Q.includes($.length))throw new Error(`Expected Uint8Array of length ${Q}, not of length=${$.length}`)},x$=function($){if(typeof $!=="function"||typeof $.create!=="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");I0($.outputLen),I0($.blockLen)},i0=function($,Q=!0){if($.destroyed)throw new Error("Hash instance has been destroyed");if(Q&&$.finished)throw new Error("Hash#digest() has already been called")},v$=function($,Q){Z$($);const J=Q.outputLen;if($.length<J)throw new Error(`digestInto() expects output buffer of length at least ${J}`)};var m$=typeof globalThis==="object"&&("crypto"in globalThis)?globalThis.crypto:void 0;async function g$($,Q,J){let Y=Date.now();for(let X=0;X<$;X++){J(X);const Z=Date.now()-Y;if(Z>=0&&Z<Q)continue;await tY(),Y+=Z}}function eY($){if(typeof $!=="string")throw new Error(`utf8ToBytes expected string, got ${typeof $}`);return new Uint8Array((new TextEncoder()).encode($))}function c0($){if(typeof $==="string")$=eY($);if(!bQ($))throw new Error(`expected Uint8Array, got ${typeof $}`);return $}function xQ(...$){const Q=new Uint8Array($.reduce((Y,X)=>Y+X.length,0));let J=0;return $.forEach((Y)=>{if(!bQ(Y))throw new Error("Uint8Array expected");Q.set(Y,J),J+=Y.length}),Q}function h$($,Q){if(Q!==void 0&&$X.call(Q)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign($,Q)}function W8($){const Q=(Y)=>$().update(c0(Y)).digest(),J=$();return Q.outputLen=J.outputLen,Q.blockLen=J.blockLen,Q.create=()=>$(),Q}function vQ($=32){if(m$&&typeof m$.getRandomValues==="function")return m$.getRandomValues(new Uint8Array($));throw new Error("crypto.getRandomValues must be defined")}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */var bQ=($)=>$ instanceof Uint8Array;var l8=($)=>new Uint32Array($.buffer,$.byteOffset,Math.floor($.byteLength/4)),n8=($)=>new DataView($.buffer,$.byteOffset,$.byteLength),v0=($,Q)=>$<<32-Q|$>>>Q,sY=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!sY)throw new Error("Non little-endian hardware is not supported");var tY=async()=>{};class E8{clone(){return this._cloneInto()}}var $X={}.toString;class E9 extends E8{constructor($,Q){super();this.finished=!1,this.destroyed=!1,x$($);const J=c0(Q);if(this.iHash=$.create(),typeof this.iHash.update!=="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const Y=this.blockLen,X=new Uint8Array(Y);X.set(J.length>Y?$.create().update(J).digest():J);for(let Z=0;Z<X.length;Z++)X[Z]^=54;this.iHash.update(X),this.oHash=$.create();for(let Z=0;Z<X.length;Z++)X[Z]^=54^92;this.oHash.update(X),X.fill(0)}update($){return i0(this),this.iHash.update($),this}digestInto($){i0(this),Z$($,this.outputLen),this.finished=!0,this.iHash.digestInto($),this.oHash.update($),this.oHash.digestInto($),this.destroy()}digest(){const $=new Uint8Array(this.oHash.outputLen);return this.digestInto($),$}_cloneInto($){$||($=Object.create(Object.getPrototypeOf(this),{}));const{oHash:Q,iHash:J,finished:Y,destroyed:X,blockLen:Z,outputLen:M}=this;return $=$,$.finished=Y,$.destroyed=X,$.blockLen=Z,$.outputLen=M,$.oHash=Q._cloneInto($.oHash),$.iHash=J._cloneInto($.iHash),$}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var P8=($,Q,J)=>new E9($,Q).update(J).digest();P8.create=($,Q)=>new E9($,Q);var QX=function($,Q,J,Y){x$($);const X=h$({dkLen:32,asyncTick:10},Y),{c:Z,dkLen:M,asyncTick:q}=X;if(I0(Z),I0(M),I0(q),Z<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const U=c0(Q),G=c0(J),W=new Uint8Array(M),O=P8.create($,U),D=O._cloneInto().update(G);return{c:Z,dkLen:M,asyncTick:q,DK:W,PRF:O,PRFSalt:D}},JX=function($,Q,J,Y,X){if($.destroy(),Q.destroy(),Y)Y.destroy();return X.fill(0),J};function M$($,Q,J,Y){const{c:X,dkLen:Z,DK:M,PRF:q,PRFSalt:U}=QX($,Q,J,Y);let G;const W=new Uint8Array(4),O=n8(W),D=new Uint8Array(q.outputLen);for(let E=1,z=0;z<Z;E++,z+=q.outputLen){const I=M.subarray(z,z+q.outputLen);O.setInt32(0,E,!1),(G=U._cloneInto(G)).update(W).digestInto(D),I.set(D.subarray(0,I.length));for(let T=1;T<X;T++){q._cloneInto(G).update(D).digestInto(D);for(let L=0;L<I.length;L++)I[L]^=D[L]}}return JX(q,U,M,G,D)}var YX=function($,Q,J,Y){if(typeof $.setBigUint64==="function")return $.setBigUint64(Q,J,Y);const X=BigInt(32),Z=BigInt(4294967295),M=Number(J>>X&Z),q=Number(J&Z),U=Y?4:0,G=Y?0:4;$.setUint32(Q+U,M,Y),$.setUint32(Q+G,q,Y)};class S8 extends E8{constructor($,Q,J,Y){super();this.blockLen=$,this.outputLen=Q,this.padOffset=J,this.isLE=Y,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array($),this.view=n8(this.buffer)}update($){i0(this);const{view:Q,buffer:J,blockLen:Y}=this;$=c0($);const X=$.length;for(let Z=0;Z<X;){const M=Math.min(Y-this.pos,X-Z);if(M===Y){const q=n8($);for(;Y<=X-Z;Z+=Y)this.process(q,Z);continue}if(J.set($.subarray(Z,Z+M),this.pos),this.pos+=M,Z+=M,this.pos===Y)this.process(Q,0),this.pos=0}return this.length+=$.length,this.roundClean(),this}digestInto($){i0(this),v$($,this),this.finished=!0;const{buffer:Q,view:J,blockLen:Y,isLE:X}=this;let{pos:Z}=this;if(Q[Z++]=128,this.buffer.subarray(Z).fill(0),this.padOffset>Y-Z)this.process(J,0),Z=0;for(let W=Z;W<Y;W++)Q[W]=0;YX(J,Y-8,BigInt(this.length*8),X),this.process(J,0);const M=n8($),q=this.outputLen;if(q%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const U=q/4,G=this.get();if(U>G.length)throw new Error("_sha2: outputLen bigger than state");for(let W=0;W<U;W++)M.setUint32(4*W,G[W],X)}digest(){const{buffer:$,outputLen:Q}=this;this.digestInto($);const J=$.slice(0,Q);return this.destroy(),J}_cloneInto($){$||($=new this.constructor),$.set(...this.get());const{blockLen:Q,buffer:J,length:Y,finished:X,destroyed:Z,pos:M}=this;if($.length=Y,$.pos=M,$.finished=X,$.destroyed=Z,Y%Q)$.buffer.set(J);return $}}var XX=($,Q,J)=>$&Q^~$&J,ZX=($,Q,J)=>$&Q^$&J^Q&J,MX=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]),V8=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),z8=new Uint32Array(64);class mQ extends S8{constructor(){super(64,32,8,!1);this.A=V8[0]|0,this.B=V8[1]|0,this.C=V8[2]|0,this.D=V8[3]|0,this.E=V8[4]|0,this.F=V8[5]|0,this.G=V8[6]|0,this.H=V8[7]|0}get(){const{A:$,B:Q,C:J,D:Y,E:X,F:Z,G:M,H:q}=this;return[$,Q,J,Y,X,Z,M,q]}set($,Q,J,Y,X,Z,M,q){this.A=$|0,this.B=Q|0,this.C=J|0,this.D=Y|0,this.E=X|0,this.F=Z|0,this.G=M|0,this.H=q|0}process($,Q){for(let W=0;W<16;W++,Q+=4)z8[W]=$.getUint32(Q,!1);for(let W=16;W<64;W++){const O=z8[W-15],D=z8[W-2],E=v0(O,7)^v0(O,18)^O>>>3,z=v0(D,17)^v0(D,19)^D>>>10;z8[W]=z+z8[W-7]+E+z8[W-16]|0}let{A:J,B:Y,C:X,D:Z,E:M,F:q,G:U,H:G}=this;for(let W=0;W<64;W++){const O=v0(M,6)^v0(M,11)^v0(M,25),D=G+O+XX(M,q,U)+MX[W]+z8[W]|0,z=(v0(J,2)^v0(J,13)^v0(J,22))+ZX(J,Y,X)|0;G=U,U=q,q=M,M=Z+D|0,Z=X,X=Y,Y=J,J=D+z|0}J=J+this.A|0,Y=Y+this.B|0,X=X+this.C|0,Z=Z+this.D|0,M=M+this.E|0,q=q+this.F|0,U=U+this.G|0,G=G+this.H|0,this.set(J,Y,X,Z,M,q,U,G)}roundClean(){z8.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}var r0=W8(()=>new mQ);var gQ=function($,Q=!1){if(Q)return{h:Number($&y$),l:Number($>>P9&y$)};return{h:Number($>>P9&y$)|0,l:Number($&y$)|0}},S9=function($,Q=!1){let J=new Uint32Array($.length),Y=new Uint32Array($.length);for(let X=0;X<$.length;X++){const{h:Z,l:M}=gQ($[X],Q);[J[X],Y[X]]=[Z,M]}return[J,Y]},KX=function($,Q,J,Y){const X=(Q>>>0)+(Y>>>0);return{h:$+J+(X/4294967296|0)|0,l:X|0}},y$=BigInt(4294967295),P9=BigInt(32),qX=($,Q)=>BigInt($>>>0)<<P9|BigInt(Q>>>0),UX=($,Q,J)=>$>>>J,GX=($,Q,J)=>$<<32-J|Q>>>J,WX=($,Q,J)=>$>>>J|Q<<32-J,VX=($,Q,J)=>$<<32-J|Q>>>J,zX=($,Q,J)=>$<<64-J|Q>>>J-32,OX=($,Q,J)=>$>>>J-32|Q<<64-J,DX=($,Q)=>Q,IX=($,Q)=>$,w9=($,Q,J)=>$<<J|Q>>>32-J,A9=($,Q,J)=>Q<<J|$>>>32-J,B9=($,Q,J)=>Q<<J-32|$>>>64-J,F9=($,Q,J)=>$<<J-32|Q>>>64-J,RX=($,Q,J)=>($>>>0)+(Q>>>0)+(J>>>0),TX=($,Q,J,Y)=>Q+J+Y+($/4294967296|0)|0,LX=($,Q,J,Y)=>($>>>0)+(Q>>>0)+(J>>>0)+(Y>>>0),jX=($,Q,J,Y,X)=>Q+J+Y+X+($/4294967296|0)|0,HX=($,Q,J,Y,X)=>($>>>0)+(Q>>>0)+(J>>>0)+(Y>>>0)+(X>>>0),NX=($,Q,J,Y,X,Z)=>Q+J+Y+X+Z+($/4294967296|0)|0;var CX={fromBig:gQ,split:S9,toBig:qX,shrSH:UX,shrSL:GX,rotrSH:WX,rotrSL:VX,rotrBH:zX,rotrBL:OX,rotr32H:DX,rotr32L:IX,rotlSH:w9,rotlSL:A9,rotlBH:B9,rotlBL:F9,add:KX,add3L:RX,add3H:TX,add4L:LX,add4H:jX,add5H:NX,add5L:HX},x=CX;var[EX,PX]=(()=>x.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(($)=>BigInt($))))(),O8=new Uint32Array(80),D8=new Uint32Array(80);class hQ extends S8{constructor(){super(128,64,16,!1);this.Ah=1779033703|0,this.Al=4089235720|0,this.Bh=3144134277|0,this.Bl=2227873595|0,this.Ch=1013904242|0,this.Cl=4271175723|0,this.Dh=2773480762|0,this.Dl=1595750129|0,this.Eh=1359893119|0,this.El=2917565137|0,this.Fh=2600822924|0,this.Fl=725511199|0,this.Gh=528734635|0,this.Gl=4215389547|0,this.Hh=1541459225|0,this.Hl=327033209|0}get(){const{Ah:$,Al:Q,Bh:J,Bl:Y,Ch:X,Cl:Z,Dh:M,Dl:q,Eh:U,El:G,Fh:W,Fl:O,Gh:D,Gl:E,Hh:z,Hl:I}=this;return[$,Q,J,Y,X,Z,M,q,U,G,W,O,D,E,z,I]}set($,Q,J,Y,X,Z,M,q,U,G,W,O,D,E,z,I){this.Ah=$|0,this.Al=Q|0,this.Bh=J|0,this.Bl=Y|0,this.Ch=X|0,this.Cl=Z|0,this.Dh=M|0,this.Dl=q|0,this.Eh=U|0,this.El=G|0,this.Fh=W|0,this.Fl=O|0,this.Gh=D|0,this.Gl=E|0,this.Hh=z|0,this.Hl=I|0}process($,Q){for(let S=0;S<16;S++,Q+=4)O8[S]=$.getUint32(Q),D8[S]=$.getUint32(Q+=4);for(let S=16;S<80;S++){const k=O8[S-15]|0,P=D8[S-15]|0,K=x.rotrSH(k,P,1)^x.rotrSH(k,P,8)^x.shrSH(k,P,7),R=x.rotrSL(k,P,1)^x.rotrSL(k,P,8)^x.shrSL(k,P,7),j=O8[S-2]|0,w=D8[S-2]|0,B=x.rotrSH(j,w,19)^x.rotrBH(j,w,61)^x.shrSH(j,w,6),F=x.rotrSL(j,w,19)^x.rotrBL(j,w,61)^x.shrSL(j,w,6),_=x.add4L(R,F,D8[S-7],D8[S-16]),v=x.add4H(_,K,B,O8[S-7],O8[S-16]);O8[S]=v|0,D8[S]=_|0}let{Ah:J,Al:Y,Bh:X,Bl:Z,Ch:M,Cl:q,Dh:U,Dl:G,Eh:W,El:O,Fh:D,Fl:E,Gh:z,Gl:I,Hh:T,Hl:L}=this;for(let S=0;S<80;S++){const k=x.rotrSH(W,O,14)^x.rotrSH(W,O,18)^x.rotrBH(W,O,41),P=x.rotrSL(W,O,14)^x.rotrSL(W,O,18)^x.rotrBL(W,O,41),K=W&D^~W&z,R=O&E^~O&I,j=x.add5L(L,P,R,PX[S],D8[S]),w=x.add5H(j,T,k,K,EX[S],O8[S]),B=j|0,F=x.rotrSH(J,Y,28)^x.rotrBH(J,Y,34)^x.rotrBH(J,Y,39),_=x.rotrSL(J,Y,28)^x.rotrBL(J,Y,34)^x.rotrBL(J,Y,39),v=J&X^J&M^X&M,o=Y&Z^Y&q^Z&q;T=z|0,L=I|0,z=D|0,I=E|0,D=W|0,E=O|0,{h:W,l:O}=x.add(U|0,G|0,w|0,B|0),U=M|0,G=q|0,M=X|0,q=Z|0,X=J|0,Z=Y|0;const u=x.add3L(B,_,o);J=x.add3H(u,w,F,v),Y=u|0}({h:J,l:Y}=x.add(this.Ah|0,this.Al|0,J|0,Y|0)),{h:X,l:Z}=x.add(this.Bh|0,this.Bl|0,X|0,Z|0),{h:M,l:q}=x.add(this.Ch|0,this.Cl|0,M|0,q|0),{h:U,l:G}=x.add(this.Dh|0,this.Dl|0,U|0,G|0),{h:W,l:O}=x.add(this.Eh|0,this.El|0,W|0,O|0),{h:D,l:E}=x.add(this.Fh|0,this.Fl|0,D|0,E|0),{h:z,l:I}=x.add(this.Gh|0,this.Gl|0,z|0,I|0),{h:T,l:L}=x.add(this.Hh|0,this.Hl|0,T|0,L|0),this.set(J,Y,X,Z,M,q,U,G,W,O,D,E,z,I,T,L)}roundClean(){O8.fill(0),D8.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}var c$=W8(()=>new hQ);var SX=function(){if(typeof self!=="undefined")return self;if(typeof window!=="undefined")return window;if(typeof window!=="undefined")return window;throw new Error("unable to locate global object")};function f9($){switch($){case"sha256":return r0.create();case"sha512":return c$.create()}V(!1,"invalid hashing algorithm name","algorithm",$)}function uQ($,Q){const J={sha256:r0,sha512:c$}[$];return V(J!=null,"invalid hmac algorithm","algorithm",$),P8.create(J,Q)}function pQ($,Q,J,Y,X){const Z={sha256:r0,sha512:c$}[X];return V(Z!=null,"invalid pbkdf2 algorithm","algorithm",X),M$(Z,$,Q,{c:J,dkLen:Y})}function dQ($){f(cQ!=null,"platform does not support secure random numbers","UNSUPPORTED_OPERATION",{operation:"randomBytes"}),V(Number.isInteger($)&&$>0&&$<=1024,"invalid length","length",$);const Q=new Uint8Array($);return cQ.getRandomValues(Q),Q}var yQ=SX(),cQ=yQ.crypto||yQ.msCrypto;function a0($,Q,J){const Y=C(Q,"key"),X=C(J,"data");return N(oQ($,Y,X))}var lQ=!1,nQ=function($,Q,J){return uQ($,Q).update(J).digest()},oQ=nQ;a0._=nQ;a0.lock=function(){lQ=!0};a0.register=function($){if(lQ)throw new Error("computeHmac is locked");oQ=$};Object.freeze(a0);function bX($,Q=24){const J=new Uint32Array(10);for(let Y=24-Q;Y<24;Y++){for(let M=0;M<10;M++)J[M]=$[M]^$[M+10]^$[M+20]^$[M+30]^$[M+40];for(let M=0;M<10;M+=2){const q=(M+8)%10,U=(M+2)%10,G=J[U],W=J[U+1],O=iQ(G,W,1)^J[q],D=rQ(G,W,1)^J[q+1];for(let E=0;E<50;E+=10)$[M+E]^=O,$[M+E+1]^=D}let X=$[2],Z=$[3];for(let M=0;M<24;M++){const q=sQ[M],U=iQ(X,Z,q),G=rQ(X,Z,q),W=aQ[M];X=$[W],Z=$[W+1],$[W]=U,$[W+1]=G}for(let M=0;M<50;M+=10){for(let q=0;q<10;q++)J[q]=$[M+q];for(let q=0;q<10;q++)$[M+q]^=~J[(q+2)%10]&J[(q+4)%10]}$[0]^=kX[Y],$[1]^=_X[Y]}J.fill(0)}var[aQ,sQ,tQ]=[[],[],[]],wX=BigInt(0),q$=BigInt(1),AX=BigInt(2),BX=BigInt(7),FX=BigInt(256),fX=BigInt(113);for(let $=0,Q=q$,J=1,Y=0;$<24;$++){[J,Y]=[Y,(2*J+3*Y)%5],aQ.push(2*(5*Y+J)),sQ.push(($+1)*($+2)/2%64);let X=wX;for(let Z=0;Z<7;Z++)if(Q=(Q<<q$^(Q>>BX)*fX)%FX,Q&AX)X^=q$<<(q$<<BigInt(Z))-q$;tQ.push(X)}var[kX,_X]=S9(tQ,!0),iQ=($,Q,J)=>J>32?B9($,Q,J):w9($,Q,J),rQ=($,Q,J)=>J>32?F9($,Q,J):A9($,Q,J);class k9 extends E8{constructor($,Q,J,Y=!1,X=24){super();if(this.blockLen=$,this.suffix=Q,this.outputLen=J,this.enableXOF=Y,this.rounds=X,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,I0(J),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=l8(this.state)}keccak(){bX(this.state32,this.rounds),this.posOut=0,this.pos=0}update($){i0(this);const{blockLen:Q,state:J}=this;$=c0($);const Y=$.length;for(let X=0;X<Y;){const Z=Math.min(Q-this.pos,Y-X);for(let M=0;M<Z;M++)J[this.pos++]^=$[X++];if(this.pos===Q)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:$,suffix:Q,pos:J,blockLen:Y}=this;if($[J]^=Q,(Q&128)!==0&&J===Y-1)this.keccak();$[Y-1]^=128,this.keccak()}writeInto($){i0(this,!1),Z$($),this.finish();const Q=this.state,{blockLen:J}=this;for(let Y=0,X=$.length;Y<X;){if(this.posOut>=J)this.keccak();const Z=Math.min(J-this.posOut,X-Y);$.set(Q.subarray(this.posOut,this.posOut+Z),Y),this.posOut+=Z,Y+=Z}return $}xofInto($){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto($)}xof($){return I0($),this.xofInto(new Uint8Array($))}digestInto($){if(v$($,this),this.finished)throw new Error("digest() was already called");return this.writeInto($),this.destroy(),$}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto($){const{blockLen:Q,suffix:J,outputLen:Y,rounds:X,enableXOF:Z}=this;return $||($=new k9(Q,J,Y,Z,X)),$.state32.set(this.state32),$.pos=this.pos,$.posOut=this.posOut,$.finished=this.finished,$.rounds=X,$.suffix=J,$.outputLen=Y,$.enableXOF=Z,$.destroyed=this.destroyed,$}}var xX=($,Q,J)=>W8(()=>new k9(Q,$,J));var eQ=xX(1,136,32);function d($){const Q=C($,"data");return N(JJ(Q))}var $J=!1,QJ=function($){return eQ($)},JJ=QJ;d._=QJ;d.lock=function(){$J=!0};d.register=function($){if($J)throw new TypeError("keccak256 is locked");JJ=$};Object.freeze(d);var YJ=function($,Q,J,Y){if($===0)return Q^J^Y;else if($===1)return Q&J|~Q&Y;else if($===2)return(Q|~J)^Y;else if($===3)return Q&Y|J&~Y;else return Q^(J|~Y)},vX=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),XJ=Uint8Array.from({length:16},($,Q)=>Q),mX=XJ.map(($)=>(9*$+5)%16),_9=[XJ],b9=[mX];for(let $=0;$<4;$++)for(let Q of[_9,b9])Q.push(Q[$].map((J)=>vX[J]));var ZJ=[[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(($)=>new Uint8Array($)),gX=_9.map(($,Q)=>$.map((J)=>ZJ[Q][J])),hX=b9.map(($,Q)=>$.map((J)=>ZJ[Q][J])),yX=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),cX=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),u$=($,Q)=>$<<Q|$>>>32-Q,p$=new Uint32Array(16);class MJ extends S8{constructor(){super(64,20,8,!0);this.h0=1732584193|0,this.h1=4023233417|0,this.h2=2562383102|0,this.h3=271733878|0,this.h4=3285377520|0}get(){const{h0:$,h1:Q,h2:J,h3:Y,h4:X}=this;return[$,Q,J,Y,X]}set($,Q,J,Y,X){this.h0=$|0,this.h1=Q|0,this.h2=J|0,this.h3=Y|0,this.h4=X|0}process($,Q){for(let D=0;D<16;D++,Q+=4)p$[D]=$.getUint32(Q,!0);let J=this.h0|0,Y=J,X=this.h1|0,Z=X,M=this.h2|0,q=M,U=this.h3|0,G=U,W=this.h4|0,O=W;for(let D=0;D<5;D++){const E=4-D,z=yX[D],I=cX[D],T=_9[D],L=b9[D],S=gX[D],k=hX[D];for(let P=0;P<16;P++){const K=u$(J+YJ(D,X,M,U)+p$[T[P]]+z,S[P])+W|0;J=W,W=U,U=u$(M,10)|0,M=X,X=K}for(let P=0;P<16;P++){const K=u$(Y+YJ(E,Z,q,G)+p$[L[P]]+I,k[P])+O|0;Y=O,O=G,G=u$(q,10)|0,q=Z,Z=K}}this.set(this.h1+M+G|0,this.h2+U+O|0,this.h3+W+Y|0,this.h4+J+Z|0,this.h0+X+q|0)}roundClean(){p$.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}var qJ=W8(()=>new MJ);function s0($){const Q=C($,"data");return N(WJ(Q))}var UJ=!1,GJ=function($){return qJ($)},WJ=GJ;s0._=GJ;s0.lock=function(){UJ=!0};s0.register=function($){if(UJ)throw new TypeError("ripemd160 is locked");WJ=$};Object.freeze(s0);function E0($,Q,J,Y,X){const Z=C($,"password"),M=C(Q,"salt");return N(OJ(Z,M,J,Y,X))}var VJ=!1,zJ=function($,Q,J,Y,X){return pQ($,Q,J,Y,X)},OJ=zJ;E0._=zJ;E0.lock=function(){VJ=!0};E0.register=function($){if(VJ)throw new Error("pbkdf2 is locked");OJ=$};Object.freeze(E0);function Z0($){return KJ($)}var DJ=!1,IJ=function($){return new Uint8Array(dQ($))},KJ=IJ;Z0._=IJ;Z0.lock=function(){DJ=!0};Z0.register=function($){if(DJ)throw new Error("randomBytes is locked");KJ=$};Object.freeze(Z0);var RJ=function($,Q,J,Y,X,Z){let M=$[Q++]^J[Y++],q=$[Q++]^J[Y++],U=$[Q++]^J[Y++],G=$[Q++]^J[Y++],W=$[Q++]^J[Y++],O=$[Q++]^J[Y++],D=$[Q++]^J[Y++],E=$[Q++]^J[Y++],z=$[Q++]^J[Y++],I=$[Q++]^J[Y++],T=$[Q++]^J[Y++],L=$[Q++]^J[Y++],S=$[Q++]^J[Y++],k=$[Q++]^J[Y++],P=$[Q++]^J[Y++],K=$[Q++]^J[Y++],R=M,j=q,w=U,B=G,F=W,_=O,v=D,o=E,u=z,H=I,A=T,b=L,g=S,c=k,i=P,X0=K;for(let O0=0;O0<8;O0+=2)F^=p(R+g|0,7),u^=p(F+R|0,9),g^=p(u+F|0,13),R^=p(g+u|0,18),H^=p(_+j|0,7),c^=p(H+_|0,9),j^=p(c+H|0,13),_^=p(j+c|0,18),i^=p(A+v|0,7),w^=p(i+A|0,9),v^=p(w+i|0,13),A^=p(v+w|0,18),B^=p(X0+b|0,7),o^=p(B+X0|0,9),b^=p(o+B|0,13),X0^=p(b+o|0,18),j^=p(R+B|0,7),w^=p(j+R|0,9),B^=p(w+j|0,13),R^=p(B+w|0,18),v^=p(_+F|0,7),o^=p(v+_|0,9),F^=p(o+v|0,13),_^=p(F+o|0,18),b^=p(A+H|0,7),u^=p(b+A|0,9),H^=p(u+b|0,13),A^=p(H+u|0,18),g^=p(X0+i|0,7),c^=p(g+X0|0,9),i^=p(c+g|0,13),X0^=p(i+c|0,18);X[Z++]=M+R|0,X[Z++]=q+j|0,X[Z++]=U+w|0,X[Z++]=G+B|0,X[Z++]=W+F|0,X[Z++]=O+_|0,X[Z++]=D+v|0,X[Z++]=E+o|0,X[Z++]=z+u|0,X[Z++]=I+H|0,X[Z++]=T+A|0,X[Z++]=L+b|0,X[Z++]=S+g|0,X[Z++]=k+c|0,X[Z++]=P+i|0,X[Z++]=K+X0|0},o8=function($,Q,J,Y,X){let Z=Y+0,M=Y+16*X;for(let q=0;q<16;q++)J[M+q]=$[Q+(2*X-1)*16+q];for(let q=0;q<X;q++,Z+=16,Q+=16){if(RJ(J,M,$,Q,J,Z),q>0)M+=16;RJ(J,Z,$,Q+=16,J,M)}},TJ=function($,Q,J){const Y=h$({dkLen:32,asyncTick:10,maxmem:1073742848},J),{N:X,r:Z,p:M,dkLen:q,asyncTick:U,maxmem:G,onProgress:W}=Y;if(I0(X),I0(Z),I0(M),I0(q),I0(U),I0(G),W!==void 0&&typeof W!=="function")throw new Error("progressCb should be function");const O=128*Z,D=O/4;if(X<=1||(X&X-1)!==0||X>=2**(O/8)||X>4294967296)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(M<0||M>137438953440/O)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(q<0||q>137438953440)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");const E=O*(X+M);if(E>G)throw new Error(`Scrypt: parameters too large, ${E} (128 * r * (N + p)) > ${G} (maxmem)`);const z=M$(r0,$,Q,{c:1,dkLen:O*M}),I=l8(z),T=l8(new Uint8Array(O*X)),L=l8(new Uint8Array(O));let S=()=>{};if(W){const k=2*X*M,P=Math.max(Math.floor(k/1e4),1);let K=0;S=()=>{if(K++,W&&(!(K%P)||K===k))W(K/k)}}return{N:X,r:Z,p:M,dkLen:q,blockSize32:D,V:T,B32:I,B:z,tmp:L,blockMixCb:S,asyncTick:U}},LJ=function($,Q,J,Y,X){const Z=M$(r0,$,J,{c:1,dkLen:Q});return J.fill(0),Y.fill(0),X.fill(0),Z};function jJ($,Q,J){const{N:Y,r:X,p:Z,dkLen:M,blockSize32:q,V:U,B32:G,B:W,tmp:O,blockMixCb:D}=TJ($,Q,J);for(let E=0;E<Z;E++){const z=q*E;for(let I=0;I<q;I++)U[I]=G[z+I];for(let I=0,T=0;I<Y-1;I++)o8(U,T,U,T+=q,X),D();o8(U,(Y-1)*q,G,z,X),D();for(let I=0;I<Y;I++){const T=G[z+q-16]%Y;for(let L=0;L<q;L++)O[L]=G[z+L]^U[T*q+L];o8(O,0,G,z,X),D()}}return LJ($,M,W,U,O)}async function HJ($,Q,J){const{N:Y,r:X,p:Z,dkLen:M,blockSize32:q,V:U,B32:G,B:W,tmp:O,blockMixCb:D,asyncTick:E}=TJ($,Q,J);for(let z=0;z<Z;z++){const I=q*z;for(let L=0;L<q;L++)U[L]=G[I+L];let T=0;await g$(Y-1,E,()=>{o8(U,T,U,T+=q,X),D()}),o8(U,(Y-1)*q,G,I,X),D(),await g$(Y,E,()=>{const L=G[I+q-16]%Y;for(let S=0;S<q;S++)O[S]=G[I+S]^U[L*q+S];o8(O,0,G,I,X),D()})}return LJ($,M,W,U,O)}var p=($,Q)=>$<<Q|$>>>32-Q;async function t0($,Q,J,Y,X,Z,M){const q=C($,"passwd"),U=C(Q,"salt");return N(await SJ(q,U,J,Y,X,Z,M))}function e0($,Q,J,Y,X,Z){const M=C($,"passwd"),q=C(Q,"salt");return N(wJ(M,q,J,Y,X,Z))}var NJ=!1,CJ=!1,EJ=async function($,Q,J,Y,X,Z,M){return await HJ($,Q,{N:J,r:Y,p:X,dkLen:Z,onProgress:M})},PJ=function($,Q,J,Y,X,Z){return jJ($,Q,{N:J,r:Y,p:X,dkLen:Z})},SJ=EJ,wJ=PJ;t0._=EJ;t0.lock=function(){CJ=!0};t0.register=function($){if(CJ)throw new Error("scrypt is locked");SJ=$};Object.freeze(t0);e0._=PJ;e0.lock=function(){NJ=!0};e0.register=function($){if(NJ)throw new Error("scryptSync is locked");wJ=$};Object.freeze(e0);function V0($){const Q=C($,"data");return N(FJ(Q))}function U$($){const Q=C($,"data");return N(fJ(Q))}var AJ=function($){return f9("sha256").update($).digest()},BJ=function($){return f9("sha512").update($).digest()},FJ=AJ,fJ=BJ,kJ=!1,_J=!1;V0._=AJ;V0.lock=function(){kJ=!0};V0.register=function($){if(kJ)throw new Error("sha256 is locked");FJ=$};Object.freeze(V0);U$._=BJ;U$.lock=function(){_J=!0};U$.register=function($){if(_J)throw new Error("sha512 is locked");fJ=$};Object.freeze(V0);var g9={};bY(g9,{validateObject:()=>{{return K8}},utf8ToBytes:()=>{{return nX}},numberToVarBytesBE:()=>{{return dX}},numberToHexUnpadded:()=>{{return vJ}},numberToBytesLE:()=>{{return o$}},numberToBytesBE:()=>{{return I8}},hexToNumber:()=>{{return v9}},hexToBytes:()=>{{return A8}},equalBytes:()=>{{return lX}},ensureBytes:()=>{{return P0}},createHmacDrbg:()=>{{return m9}},concatBytes:()=>{{return i8}},bytesToNumberLE:()=>{{return n$}},bytesToNumberBE:()=>{{return $8}},bytesToHex:()=>{{return w8}},bitSet:()=>{{return rX}},bitMask:()=>{{return G$}},bitLen:()=>{{return oX}},bitGet:()=>{{return iX}}});function w8($){if(!l$($))throw new Error("Uint8Array expected");let Q="";for(let J=0;J<$.length;J++)Q+=pX[$[J]];return Q}function vJ($){const Q=$.toString(16);return Q.length&1?`0${Q}`:Q}function v9($){if(typeof $!=="string")throw new Error("hex string expected, got "+typeof $);return BigInt($===""?"0":`0x${$}`)}function A8($){if(typeof $!=="string")throw new Error("hex string expected, got "+typeof $);const Q=$.length;if(Q%2)throw new Error("padded hex string expected, got unpadded hex of length "+Q);const J=new Uint8Array(Q/2);for(let Y=0;Y<J.length;Y++){const X=Y*2,Z=$.slice(X,X+2),M=Number.parseInt(Z,16);if(Number.isNaN(M)||M<0)throw new Error("Invalid byte sequence");J[Y]=M}return J}function $8($){return v9(w8($))}function n$($){if(!l$($))throw new Error("Uint8Array expected");return v9(w8(Uint8Array.from($).reverse()))}function I8($,Q){return A8($.toString(16).padStart(Q*2,"0"))}function o$($,Q){return I8($,Q).reverse()}function dX($){return A8(vJ($))}function P0($,Q,J){let Y;if(typeof Q==="string")try{Y=A8(Q)}catch(Z){throw new Error(`${$} must be valid hex string, got "${Q}". Cause: ${Z}`)}else if(l$(Q))Y=Uint8Array.from(Q);else throw new Error(`${$} must be hex string or Uint8Array`);const X=Y.length;if(typeof J==="number"&&X!==J)throw new Error(`${$} expected ${J} bytes, got ${X}`);return Y}function i8(...$){const Q=new Uint8Array($.reduce((Y,X)=>Y+X.length,0));let J=0;return $.forEach((Y)=>{if(!l$(Y))throw new Error("Uint8Array expected");Q.set(Y,J),J+=Y.length}),Q}function lX($,Q){if($.length!==Q.length)return!1;for(let J=0;J<$.length;J++)if($[J]!==Q[J])return!1;return!0}function nX($){if(typeof $!=="string")throw new Error(`utf8ToBytes expected string, got ${typeof $}`);return new Uint8Array((new TextEncoder()).encode($))}function oX($){let Q;for(Q=0;$>xJ;$>>=d$,Q+=1);return Q}function iX($,Q){return $>>BigInt(Q)&d$}function m9($,Q,J){if(typeof $!=="number"||$<2)throw new Error("hashLen must be a number");if(typeof Q!=="number"||Q<2)throw new Error("qByteLen must be a number");if(typeof J!=="function")throw new Error("hmacFn must be a function");let Y=x9($),X=x9($),Z=0;const M=()=>{Y.fill(1),X.fill(0),Z=0},q=(...O)=>J(X,Y,...O),U=(O=x9())=>{if(X=q(bJ([0]),O),Y=q(),O.length===0)return;X=q(bJ([1]),O),Y=q()},G=()=>{if(Z++>=1000)throw new Error("drbg: tried 1000 values");let O=0;const D=[];while(O<Q){Y=q();const E=Y.slice();D.push(E),O+=Y.length}return i8(...D)};return(O,D)=>{M(),U(O);let E=void 0;while(!(E=D(G())))U();return M(),E}}function K8($,Q,J={}){const Y=(X,Z,M)=>{const q=aX[Z];if(typeof q!=="function")throw new Error(`Invalid validator "${Z}", expected function`);const U=$[X];if(M&&U===void 0)return;if(!q(U,$))throw new Error(`Invalid param ${String(X)}=${U} (${typeof U}), expected ${Z}`)};for(let[X,Z]of Object.entries(Q))Y(X,Z,!1);for(let[X,Z]of Object.entries(J))Y(X,Z,!0);return $}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var xJ=BigInt(0),d$=BigInt(1),uX=BigInt(2),l$=($)=>$ instanceof Uint8Array,pX=Array.from({length:256},($,Q)=>Q.toString(16).padStart(2,"0")),rX=($,Q,J)=>{return $|(J?d$:xJ)<<BigInt(Q)},G$=($)=>(uX<<BigInt($-1))-d$,x9=($)=>new Uint8Array($),bJ=($)=>Uint8Array.from($),aX={bigint:($)=>typeof $==="bigint",function:($)=>typeof $==="function",boolean:($)=>typeof $==="boolean",string:($)=>typeof $==="string",stringOrUint8Array:($)=>typeof $==="string"||$ instanceof Uint8Array,isSafeInteger:($)=>Number.isSafeInteger($),array:($)=>Array.isArray($),field:($,Q)=>Q.Fp.isValid($),hash:($)=>typeof $==="function"&&Number.isSafeInteger($.outputLen)};function K0($,Q){const J=$%Q;return J>=M0?J:Q+J}function $Z($,Q,J){if(J<=M0||Q<M0)throw new Error("Expected power/modulo > 0");if(J===J0)return M0;let Y=J0;while(Q>M0){if(Q&J0)Y=Y*$%J;$=$*$%J,Q>>=J0}return Y}function S0($,Q,J){let Y=$;while(Q-- >M0)Y*=Y,Y%=J;return Y}function i$($,Q){if($===M0||Q<=M0)throw new Error(`invert: expected positive integers, got n=${$} mod=${Q}`);let J=K0($,Q),Y=Q,X=M0,Z=J0,M=J0,q=M0;while(J!==M0){const G=Y/J,W=Y%J,O=X-M*G,D=Z-q*G;Y=J,J=W,X=M,Z=q,M=O,q=D}if(Y!==J0)throw new Error("invert: does not exist");return K0(X,Q)}function QZ($){const Q=($-J0)/B8;let J,Y,X;for(J=$-J0,Y=0;J%B8===M0;J/=B8,Y++);for(X=B8;X<$&&$Z(X,Q,$)!==$-J0;X++);if(Y===1){const M=($+J0)/h9;return function q(U,G){const W=U.pow(G,M);if(!U.eql(U.sqr(W),G))throw new Error("Cannot find square root");return W}}const Z=(J+J0)/B8;return function M(q,U){if(q.pow(U,Q)===q.neg(q.ONE))throw new Error("Cannot find square root");let G=Y,W=q.pow(q.mul(q.ONE,X),J),O=q.pow(U,Z),D=q.pow(U,J);while(!q.eql(D,q.ONE)){if(q.eql(D,q.ZERO))return q.ZERO;let E=1;for(let I=q.sqr(D);E<G;E++){if(q.eql(I,q.ONE))break;I=q.sqr(I)}const z=q.pow(W,J0<<BigInt(G-E-1));W=q.sqr(z),O=q.mul(O,z),D=q.mul(D,W),G=E}return O}}function JZ($){if($%h9===sX){const Q=($+J0)/h9;return function J(Y,X){const Z=Y.pow(X,Q);if(!Y.eql(Y.sqr(Z),X))throw new Error("Cannot find square root");return Z}}if($%gJ===mJ){const Q=($-mJ)/gJ;return function J(Y,X){const Z=Y.mul(X,B8),M=Y.pow(Z,Q),q=Y.mul(X,M),U=Y.mul(Y.mul(q,B8),M),G=Y.mul(q,Y.sub(U,Y.ONE));if(!Y.eql(Y.sqr(G),X))throw new Error("Cannot find square root");return G}}if($%eX===tX);return QZ($)}function y9($){const Q={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},J=YZ.reduce((Y,X)=>{return Y[X]="function",Y},Q);return K8($,J)}function XZ($,Q,J){if(J<M0)throw new Error("Expected power > 0");if(J===M0)return $.ONE;if(J===J0)return Q;let Y=$.ONE,X=Q;while(J>M0){if(J&J0)Y=$.mul(Y,X);X=$.sqr(X),J>>=J0}return Y}function ZZ($,Q){const J=new Array(Q.length),Y=Q.reduce((Z,M,q)=>{if($.is0(M))return Z;return J[q]=Z,$.mul(Z,M)},$.ONE),X=$.inv(Y);return Q.reduceRight((Z,M,q)=>{if($.is0(M))return Z;return J[q]=$.mul(Z,J[q]),$.mul(Z,M)},X),J}function c9($,Q){const J=Q!==void 0?Q:$.toString(2).length,Y=Math.ceil(J/8);return{nBitLength:J,nByteLength:Y}}function hJ($,Q,J=!1,Y={}){if($<=M0)throw new Error(`Expected Field ORDER > 0, got ${$}`);const{nBitLength:X,nByteLength:Z}=c9($,Q);if(Z>2048)throw new Error("Field lengths over 2048 bytes are not supported");const M=JZ($),q=Object.freeze({ORDER:$,BITS:X,BYTES:Z,MASK:G$(X),ZERO:M0,ONE:J0,create:(U)=>K0(U,$),isValid:(U)=>{if(typeof U!=="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof U}`);return M0<=U&&U<$},is0:(U)=>U===M0,isOdd:(U)=>(U&J0)===J0,neg:(U)=>K0(-U,$),eql:(U,G)=>U===G,sqr:(U)=>K0(U*U,$),add:(U,G)=>K0(U+G,$),sub:(U,G)=>K0(U-G,$),mul:(U,G)=>K0(U*G,$),pow:(U,G)=>XZ(q,U,G),div:(U,G)=>K0(U*i$(G,$),$),sqrN:(U)=>U*U,addN:(U,G)=>U+G,subN:(U,G)=>U-G,mulN:(U,G)=>U*G,inv:(U)=>i$(U,$),sqrt:Y.sqrt||((U)=>M(q,U)),invertBatch:(U)=>ZZ(q,U),cmov:(U,G,W)=>W?G:U,toBytes:(U)=>J?o$(U,Z):I8(U,Z),fromBytes:(U)=>{if(U.length!==Z)throw new Error(`Fp.fromBytes: expected ${Z}, got ${U.length}`);return J?n$(U):$8(U)}});return Object.freeze(q)}function yJ($){if(typeof $!=="bigint")throw new Error("field order must be bigint");const Q=$.toString(2).length;return Math.ceil(Q/8)}function u9($){const Q=yJ($);return Q+Math.ceil(Q/2)}function cJ($,Q,J=!1){const Y=$.length,X=yJ(Q),Z=u9(Q);if(Y<16||Y<Z||Y>1024)throw new Error(`expected ${Z}-1024 bytes of input, got ${Y}`);const M=J?$8($):n$($),q=K0(M,Q-J0)+J0;return J?o$(q,X):I8(q,X)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var M0=BigInt(0),J0=BigInt(1),B8=BigInt(2),sX=BigInt(3),h9=BigInt(4),mJ=BigInt(5),gJ=BigInt(8),tX=BigInt(9),eX=BigInt(16);var YZ=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function uJ($,Q){const J=(X,Z)=>{const M=Z.negate();return X?M:Z},Y=(X)=>{const Z=Math.ceil(Q/X)+1,M=2**(X-1);return{windows:Z,windowSize:M}};return{constTimeNegate:J,unsafeLadder(X,Z){let M=$.ZERO,q=X;while(Z>qZ){if(Z&p9)M=M.add(q);q=q.double(),Z>>=p9}return M},precomputeWindow(X,Z){const{windows:M,windowSize:q}=Y(Z),U=[];let G=X,W=G;for(let O=0;O<M;O++){W=G,U.push(W);for(let D=1;D<q;D++)W=W.add(G),U.push(W);G=W.double()}return U},wNAF(X,Z,M){const{windows:q,windowSize:U}=Y(X);let{ZERO:G,BASE:W}=$;const O=BigInt(2**X-1),D=2**X,E=BigInt(X);for(let z=0;z<q;z++){const I=z*U;let T=Number(M&O);if(M>>=E,T>U)T-=D,M+=p9;const L=I,S=I+Math.abs(T)-1,k=z%2!==0,P=T<0;if(T===0)W=W.add(J(k,Z[L]));else G=G.add(J(P,Z[S]))}return{p:G,f:W}},wNAFCached(X,Z,M,q){const U=X._WINDOW_SIZE||1;let G=Z.get(X);if(!G){if(G=this.precomputeWindow(X,U),U!==1)Z.set(X,q(G))}return this.wNAF(U,G,M)}}}function d9($){return y9($.Fp),K8($,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...c9($.n,$.nBitLength),...$,...{p:$.Fp.ORDER}})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var qZ=BigInt(0),p9=BigInt(1);var UZ=function($){const Q=d9($);K8(Q,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:J,Fp:Y,a:X}=Q;if(J){if(!Y.eql(X,Y.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof J!=="object"||typeof J.beta!=="bigint"||typeof J.splitScalar!=="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...Q})};function VZ($){const Q=UZ($),{Fp:J}=Q,Y=Q.toBytes||((z,I,T)=>{const L=I.toAffine();return i8(Uint8Array.from([4]),J.toBytes(L.x),J.toBytes(L.y))}),X=Q.fromBytes||((z)=>{const I=z.subarray(1),T=J.fromBytes(I.subarray(0,J.BYTES)),L=J.fromBytes(I.subarray(J.BYTES,2*J.BYTES));return{x:T,y:L}});function Z(z){const{a:I,b:T}=Q,L=J.sqr(z),S=J.mul(L,z);return J.add(J.add(S,J.mul(z,I)),T)}if(!J.eql(J.sqr(Q.Gy),Z(Q.Gx)))throw new Error("bad generator point: equation left != right");function M(z){return typeof z==="bigint"&&Q8<z&&z<Q.n}function q(z){if(!M(z))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function U(z){const{allowedPrivateKeyLengths:I,nByteLength:T,wrapPrivateKey:L,n:S}=Q;if(I&&typeof z!=="bigint"){if(z instanceof Uint8Array)z=w8(z);if(typeof z!=="string"||!I.includes(z.length))throw new Error("Invalid key");z=z.padStart(T*2,"0")}let k;try{k=typeof z==="bigint"?z:$8(P0("private key",z,T))}catch(P){throw new Error(`private key must be ${T} bytes, hex or bigint, not ${typeof z}`)}if(L)k=K0(k,S);return q(k),k}const G=new Map;function W(z){if(!(z instanceof O))throw new Error("ProjectivePoint expected")}class O{constructor(z,I,T){if(this.px=z,this.py=I,this.pz=T,z==null||!J.isValid(z))throw new Error("x required");if(I==null||!J.isValid(I))throw new Error("y required");if(T==null||!J.isValid(T))throw new Error("z required")}static fromAffine(z){const{x:I,y:T}=z||{};if(!z||!J.isValid(I)||!J.isValid(T))throw new Error("invalid affine point");if(z instanceof O)throw new Error("projective point not allowed");const L=(S)=>J.eql(S,J.ZERO);if(L(I)&&L(T))return O.ZERO;return new O(I,T,J.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(z){const I=J.invertBatch(z.map((T)=>T.pz));return z.map((T,L)=>T.toAffine(I[L])).map(O.fromAffine)}static fromHex(z){const I=O.fromAffine(X(P0("pointHex",z)));return I.assertValidity(),I}static fromPrivateKey(z){return O.BASE.multiply(U(z))}_setWindowSize(z){this._WINDOW_SIZE=z,G.delete(this)}assertValidity(){if(this.is0()){if(Q.allowInfinityPoint&&!J.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:z,y:I}=this.toAffine();if(!J.isValid(z)||!J.isValid(I))throw new Error("bad point: x or y not FE");const T=J.sqr(I),L=Z(z);if(!J.eql(T,L))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:z}=this.toAffine();if(J.isOdd)return!J.isOdd(z);throw new Error("Field doesn't support isOdd")}equals(z){W(z);const{px:I,py:T,pz:L}=this,{px:S,py:k,pz:P}=z,K=J.eql(J.mul(I,P),J.mul(S,L)),R=J.eql(J.mul(T,P),J.mul(k,L));return K&&R}negate(){return new O(this.px,J.neg(this.py),this.pz)}double(){const{a:z,b:I}=Q,T=J.mul(I,pJ),{px:L,py:S,pz:k}=this;let{ZERO:P,ZERO:K,ZERO:R}=J,j=J.mul(L,L),w=J.mul(S,S),B=J.mul(k,k),F=J.mul(L,S);return F=J.add(F,F),R=J.mul(L,k),R=J.add(R,R),P=J.mul(z,R),K=J.mul(T,B),K=J.add(P,K),P=J.sub(w,K),K=J.add(w,K),K=J.mul(P,K),P=J.mul(F,P),R=J.mul(T,R),B=J.mul(z,B),F=J.sub(j,B),F=J.mul(z,F),F=J.add(F,R),R=J.add(j,j),j=J.add(R,j),j=J.add(j,B),j=J.mul(j,F),K=J.add(K,j),B=J.mul(S,k),B=J.add(B,B),j=J.mul(B,F),P=J.sub(P,j),R=J.mul(B,w),R=J.add(R,R),R=J.add(R,R),new O(P,K,R)}add(z){W(z);const{px:I,py:T,pz:L}=this,{px:S,py:k,pz:P}=z;let{ZERO:K,ZERO:R,ZERO:j}=J;const w=Q.a,B=J.mul(Q.b,pJ);let F=J.mul(I,S),_=J.mul(T,k),v=J.mul(L,P),o=J.add(I,T),u=J.add(S,k);o=J.mul(o,u),u=J.add(F,_),o=J.sub(o,u),u=J.add(I,L);let H=J.add(S,P);return u=J.mul(u,H),H=J.add(F,v),u=J.sub(u,H),H=J.add(T,L),K=J.add(k,P),H=J.mul(H,K),K=J.add(_,v),H=J.sub(H,K),j=J.mul(w,u),K=J.mul(B,v),j=J.add(K,j),K=J.sub(_,j),j=J.add(_,j),R=J.mul(K,j),_=J.add(F,F),_=J.add(_,F),v=J.mul(w,v),u=J.mul(B,u),_=J.add(_,v),v=J.sub(F,v),v=J.mul(w,v),u=J.add(u,v),F=J.mul(_,u),R=J.add(R,F),F=J.mul(H,u),K=J.mul(o,K),K=J.sub(K,F),F=J.mul(o,_),j=J.mul(H,j),j=J.add(j,F),new O(K,R,j)}subtract(z){return this.add(z.negate())}is0(){return this.equals(O.ZERO)}wNAF(z){return E.wNAFCached(this,G,z,(I)=>{const T=J.invertBatch(I.map((L)=>L.pz));return I.map((L,S)=>L.toAffine(T[S])).map(O.fromAffine)})}multiplyUnsafe(z){const I=O.ZERO;if(z===Q8)return I;if(q(z),z===A0)return this;const{endo:T}=Q;if(!T)return E.unsafeLadder(this,z);let{k1neg:L,k1:S,k2neg:k,k2:P}=T.splitScalar(z),K=I,R=I,j=this;while(S>Q8||P>Q8){if(S&A0)K=K.add(j);if(P&A0)R=R.add(j);j=j.double(),S>>=A0,P>>=A0}if(L)K=K.negate();if(k)R=R.negate();return R=new O(J.mul(R.px,T.beta),R.py,R.pz),K.add(R)}multiply(z){q(z);let I=z,T,L;const{endo:S}=Q;if(S){const{k1neg:k,k1:P,k2neg:K,k2:R}=S.splitScalar(I);let{p:j,f:w}=this.wNAF(P),{p:B,f:F}=this.wNAF(R);j=E.constTimeNegate(k,j),B=E.constTimeNegate(K,B),B=new O(J.mul(B.px,S.beta),B.py,B.pz),T=j.add(B),L=w.add(F)}else{const{p:k,f:P}=this.wNAF(I);T=k,L=P}return O.normalizeZ([T,L])[0]}multiplyAndAddUnsafe(z,I,T){const L=O.BASE,S=(P,K)=>K===Q8||K===A0||!P.equals(L)?P.multiplyUnsafe(K):P.multiply(K),k=S(this,I).add(S(z,T));return k.is0()?void 0:k}toAffine(z){const{px:I,py:T,pz:L}=this,S=this.is0();if(z==null)z=S?J.ONE:J.inv(L);const k=J.mul(I,z),P=J.mul(T,z),K=J.mul(L,z);if(S)return{x:J.ZERO,y:J.ZERO};if(!J.eql(K,J.ONE))throw new Error("invZ was invalid");return{x:k,y:P}}isTorsionFree(){const{h:z,isTorsionFree:I}=Q;if(z===A0)return!0;if(I)return I(O,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:z,clearCofactor:I}=Q;if(z===A0)return this;if(I)return I(O,this);return this.multiplyUnsafe(Q.h)}toRawBytes(z=!0){return this.assertValidity(),Y(O,this,z)}toHex(z=!0){return w8(this.toRawBytes(z))}}O.BASE=new O(Q.Gx,Q.Gy,J.ONE),O.ZERO=new O(J.ZERO,J.ONE,J.ZERO);const D=Q.nBitLength,E=uJ(O,Q.endo?Math.ceil(D/2):D);return{CURVE:Q,ProjectivePoint:O,normPrivateKeyToScalar:U,weierstrassEquation:Z,isWithinCurveOrder:M}}var zZ=function($){const Q=d9($);return K8(Q,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...Q})};function dJ($){const Q=zZ($),{Fp:J,n:Y}=Q,X=J.BYTES+1,Z=2*J.BYTES+1;function M(H){return Q8<H&&H<J.ORDER}function q(H){return K0(H,Y)}function U(H){return i$(H,Y)}const{ProjectivePoint:G,normPrivateKeyToScalar:W,weierstrassEquation:O,isWithinCurveOrder:D}=VZ({...Q,toBytes(H,A,b){const g=A.toAffine(),c=J.toBytes(g.x),i=i8;if(b)return i(Uint8Array.from([A.hasEvenY()?2:3]),c);else return i(Uint8Array.from([4]),c,J.toBytes(g.y))},fromBytes(H){const A=H.length,b=H[0],g=H.subarray(1);if(A===X&&(b===2||b===3)){const c=$8(g);if(!M(c))throw new Error("Point is not on curve");const i=O(c);let X0=J.sqrt(i);const O0=(X0&A0)===A0;if((b&1)===1!==O0)X0=J.neg(X0);return{x:c,y:X0}}else if(A===Z&&b===4){const c=J.fromBytes(g.subarray(0,J.BYTES)),i=J.fromBytes(g.subarray(J.BYTES,2*J.BYTES));return{x:c,y:i}}else throw new Error(`Point of length ${A} was invalid. Expected ${X} compressed bytes or ${Z} uncompressed bytes`)}}),E=(H)=>w8(I8(H,Q.nByteLength));function z(H){const A=Y>>A0;return H>A}function I(H){return z(H)?q(-H):H}const T=(H,A,b)=>$8(H.slice(A,b));class L{constructor(H,A,b){this.r=H,this.s=A,this.recovery=b,this.assertValidity()}static fromCompact(H){const A=Q.nByteLength;return H=P0("compactSignature",H,A*2),new L(T(H,0,A),T(H,A,2*A))}static fromDER(H){const{r:A,s:b}=F8.toSig(P0("DER",H));return new L(A,b)}assertValidity(){if(!D(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!D(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(H){return new L(this.r,this.s,H)}recoverPublicKey(H){const{r:A,s:b,recovery:g}=this,c=j(P0("msgHash",H));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");const i=g===2||g===3?A+Q.n:A;if(i>=J.ORDER)throw new Error("recovery id 2 or 3 invalid");const X0=(g&1)===0?"02":"03",O0=G.fromHex(X0+E(i)),l0=U(i),j8=q(-c*l0),m8=q(b*l0),H8=G.BASE.multiplyAndAddUnsafe(O0,j8,m8);if(!H8)throw new Error("point at infinify");return H8.assertValidity(),H8}hasHighS(){return z(this.s)}normalizeS(){return this.hasHighS()?new L(this.r,q(-this.s),this.recovery):this}toDERRawBytes(){return A8(this.toDERHex())}toDERHex(){return F8.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return A8(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}const S={isValidPrivateKey(H){try{return W(H),!0}catch(A){return!1}},normPrivateKeyToScalar:W,randomPrivateKey:()=>{const H=u9(Q.n);return cJ(Q.randomBytes(H),Q.n)},precompute(H=8,A=G.BASE){return A._setWindowSize(H),A.multiply(BigInt(3)),A}};function k(H,A=!0){return G.fromPrivateKey(H).toRawBytes(A)}function P(H){const A=H instanceof Uint8Array,b=typeof H==="string",g=(A||b)&&H.length;if(A)return g===X||g===Z;if(b)return g===2*X||g===2*Z;if(H instanceof G)return!0;return!1}function K(H,A,b=!0){if(P(H))throw new Error("first arg must be private key");if(!P(A))throw new Error("second arg must be public key");return G.fromHex(A).multiply(W(H)).toRawBytes(b)}const R=Q.bits2int||function(H){const A=$8(H),b=H.length*8-Q.nBitLength;return b>0?A>>BigInt(b):A},j=Q.bits2int_modN||function(H){return q(R(H))},w=G$(Q.nBitLength);function B(H){if(typeof H!=="bigint")throw new Error("bigint expected");if(!(Q8<=H&&H<w))throw new Error(`bigint expected < 2^${Q.nBitLength}`);return I8(H,Q.nByteLength)}function F(H,A,b=_){if(["recovered","canonical"].some((N8)=>(N8 in b)))throw new Error("sign() legacy options not supported");const{hash:g,randomBytes:c}=Q;let{lowS:i,prehash:X0,extraEntropy:O0}=b;if(i==null)i=!0;if(H=P0("msgHash",H),X0)H=P0("prehashed msgHash",g(H));const l0=j(H),j8=W(A),m8=[B(j8),B(l0)];if(O0!=null){const N8=O0===!0?c(J.BYTES):O0;m8.push(P0("extraEntropy",N8))}const H8=i8(...m8),C$=l0;function H9(N8){const g8=R(N8);if(!D(g8))return;const jQ=U(g8),g0=G.BASE.multiply(g8).toAffine(),h8=q(g0.x);if(h8===Q8)return;const E$=q(jQ*q(C$+h8*j8));if(E$===Q8)return;let HQ=(g0.x===h8?0:2)|Number(g0.y&A0),NQ=E$;if(i&&z(E$))NQ=I(E$),HQ^=1;return new L(h8,NQ,HQ)}return{seed:H8,k2sig:H9}}const _={lowS:Q.lowS,prehash:!1},v={lowS:Q.lowS,prehash:!1};function o(H,A,b=_){const{seed:g,k2sig:c}=F(H,A,b),i=Q;return m9(i.hash.outputLen,i.nByteLength,i.hmac)(g,c)}G.BASE._setWindowSize(8);function u(H,A,b,g=v){const c=H;if(A=P0("msgHash",A),b=P0("publicKey",b),("strict"in g))throw new Error("options.strict was renamed to lowS");const{lowS:i,prehash:X0}=g;let O0=void 0,l0;try{if(typeof c==="string"||c instanceof Uint8Array)try{O0=L.fromDER(c)}catch(g0){if(!(g0 instanceof F8.Err))throw g0;O0=L.fromCompact(c)}else if(typeof c==="object"&&typeof c.r==="bigint"&&typeof c.s==="bigint"){const{r:g0,s:h8}=c;O0=new L(g0,h8)}else throw new Error("PARSE");l0=G.fromHex(b)}catch(g0){if(g0.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(i&&O0.hasHighS())return!1;if(X0)A=Q.hash(A);const{r:j8,s:m8}=O0,H8=j(A),C$=U(m8),H9=q(H8*C$),N8=q(j8*C$),g8=G.BASE.multiplyAndAddUnsafe(l0,H9,N8)?.toAffine();if(!g8)return!1;return q(g8.x)===j8}return{CURVE:Q,getPublicKey:k,getSharedSecret:K,sign:o,verify:u,ProjectivePoint:G,Signature:L,utils:S}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var{bytesToNumberBE:GZ,hexToBytes:WZ}=g9,F8={Err:class $ extends Error{constructor(Q=""){super(Q)}},_parseInt($){const{Err:Q}=F8;if($.length<2||$[0]!==2)throw new Q("Invalid signature integer tag");const J=$[1],Y=$.subarray(2,J+2);if(!J||Y.length!==J)throw new Q("Invalid signature integer: wrong length");if(Y[0]&128)throw new Q("Invalid signature integer: negative");if(Y[0]===0&&!(Y[1]&128))throw new Q("Invalid signature integer: unnecessary leading zero");return{d:GZ(Y),l:$.subarray(J+2)}},toSig($){const{Err:Q}=F8,J=typeof $==="string"?WZ($):$;if(!(J instanceof Uint8Array))throw new Error("ui8a expected");let Y=J.length;if(Y<2||J[0]!=48)throw new Q("Invalid signature tag");if(J[1]!==Y-2)throw new Q("Invalid signature: incorrect length");const{d:X,l:Z}=F8._parseInt(J.subarray(2)),{d:M,l:q}=F8._parseInt(Z);if(q.length)throw new Q("Invalid signature: left bytes after parsing");return{r:X,s:M}},hexFromSig($){const Q=(G)=>Number.parseInt(G[0],16)&8?"00"+G:G,J=(G)=>{const W=G.toString(16);return W.length&1?`0${W}`:W},Y=Q(J($.s)),X=Q(J($.r)),Z=Y.length/2,M=X.length/2,q=J(Z),U=J(M);return`30${J(M+Z+4)}02${U}${X}02${q}${Y}`}},Q8=BigInt(0),A0=BigInt(1),Eq=BigInt(2),pJ=BigInt(3),Pq=BigInt(4);function OZ($){return{hash:$,hmac:(Q,...J)=>P8($,Q,xQ(...J)),randomBytes:vQ}}function lJ($,Q){const J=(Y)=>dJ({...$,...OZ(Y)});return Object.freeze({...J(Q),create:J})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var IZ=function($){const Q=iJ,J=BigInt(3),Y=BigInt(6),X=BigInt(11),Z=BigInt(22),M=BigInt(23),q=BigInt(44),U=BigInt(88),G=$*$*$%Q,W=G*G*$%Q,O=S0(W,J,Q)*W%Q,D=S0(O,J,Q)*W%Q,E=S0(D,l9,Q)*G%Q,z=S0(E,X,Q)*E%Q,I=S0(z,Z,Q)*z%Q,T=S0(I,q,Q)*I%Q,L=S0(T,U,Q)*T%Q,S=S0(L,q,Q)*I%Q,k=S0(S,J,Q)*W%Q,P=S0(k,M,Q)*z%Q,K=S0(P,Y,Q)*G%Q,R=S0(K,l9,Q);if(!n9.eql(n9.sqr(R),$))throw new Error("Cannot find square root");return R};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var iJ=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),nJ=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),DZ=BigInt(1),l9=BigInt(2),oJ=($,Q)=>($+Q/l9)/Q,n9=hJ(iJ,void 0,void 0,{sqrt:IZ}),J8=lJ({a:BigInt(0),b:BigInt(7),Fp:n9,n:nJ,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:($)=>{const Q=nJ,J=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),Y=-DZ*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),X=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),Z=J,M=BigInt("0x100000000000000000000000000000000"),q=oJ(Z*$,Q),U=oJ(-Y*$,Q);let G=K0($-q*J-U*X,Q),W=K0(-q*Y-U*Z,Q);const O=G>M,D=W>M;if(O)G=Q-G;if(D)W=Q-W;if(G>M||W>M)throw new Error("splitScalar: Endomorphism failed, k="+$);return{k1neg:O,k1:G,k2neg:D,k2:W}}}},r0),bq=BigInt(0);var xq=J8.ProjectivePoint;var o9="0x0000000000000000000000000000000000000000";var r$="0x0000000000000000000000000000000000000000000000000000000000000000";var i9=`\x19Ethereum Signed Message:
2
+ `;var $Y=function($){return C0(s($),32)},rJ=BigInt(0),aJ=BigInt(1),sJ=BigInt(2),tJ=BigInt(27),eJ=BigInt(28),a$=BigInt(35),r8={};class e{#$;#Q;#J;#Y;get r(){return this.#$}set r($){V(o0($)===32,"invalid r","value",$),this.#$=N($)}get s(){return V(parseInt(this.#Q.substring(0,3))<8,"non-canonical s; use ._s","s",this.#Q),this.#Q}set s($){V(o0($)===32,"invalid s","value",$),this.#Q=N($)}get _s(){return this.#Q}isValid(){return parseInt(this.#Q.substring(0,3))<8}get v(){return this.#J}set v($){const Q=q0($,"value");V(Q===27||Q===28,"invalid v","v",$),this.#J=Q}get networkV(){return this.#Y}get legacyChainId(){const $=this.networkV;if($==null)return null;return e.getChainId($)}get yParity(){return this.v===27?0:1}get yParityAndS(){const $=C(this.s);if(this.yParity)$[0]|=128;return N($)}get compactSerialized(){return l([this.r,this.yParityAndS])}get serialized(){return l([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor($,Q,J,Y){n0($,r8,"Signature"),this.#$=Q,this.#Q=J,this.#J=Y,this.#Y=null}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this._s}"${this.isValid()?"":', valid: "false"'}, yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const $=new e(r8,this.r,this._s,this.v);if(this.networkV)$.#Y=this.networkV;return $}toJSON(){const $=this.networkV;return{_type:"signature",networkV:$!=null?$.toString():null,r:this.r,s:this._s,v:this.v}}static getChainId($){const Q=h($,"v");if(Q==tJ||Q==eJ)return rJ;return V(Q>=a$,"invalid EIP-155 v","v",$),(Q-a$)/sJ}static getChainIdV($,Q){return h($)*sJ+BigInt(35+Q-27)}static getNormalizedV($){const Q=h($);if(Q===rJ||Q===tJ)return 27;if(Q===aJ||Q===eJ)return 28;return V(Q>=a$,"invalid v","v",$),Q&aJ?27:28}static from($){function Q(U,G){V(U,G,"signature",$)}if($==null)return new e(r8,r$,r$,27);if(typeof $==="string"){const U=C($,"signature");if(U.length===64){const G=N(U.slice(0,32)),W=U.slice(32,64),O=W[0]&128?28:27;return W[0]&=127,new e(r8,G,N(W),O)}if(U.length===65){const G=N(U.slice(0,32)),W=N(U.slice(32,64)),O=e.getNormalizedV(U[64]);return new e(r8,G,W,O)}Q(!1,"invalid raw signature length")}if($ instanceof e)return $.clone();const J=$.r;Q(J!=null,"missing r");const Y=$Y(J),X=function(U,G){if(U!=null)return $Y(U);if(G!=null){Q(D0(G,32),"invalid yParityAndS");const W=C(G);return W[0]&=127,N(W)}Q(!1,"missing s")}($.s,$.yParityAndS),{networkV:Z,v:M}=function(U,G,W){if(U!=null){const O=h(U);return{networkV:O>=a$?O:void 0,v:e.getNormalizedV(O)}}if(G!=null)return Q(D0(G,32),"invalid yParityAndS"),{v:C(G)[0]&128?28:27};if(W!=null){switch(q0(W,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}Q(!1,"invalid yParity")}Q(!1,"missing v")}($.v,$.yParityAndS,$.yParity),q=new e(r8,Y,X,M);if(Z)q.#Y=Z;return Q($.yParity==null||q0($.yParity,"sig.yParity")===q.yParity,"yParity mismatch"),Q($.yParityAndS==null||$.yParityAndS===q.yParityAndS,"yParityAndS mismatch"),q}}class Y0{#$;constructor($){V(o0($)===32,"invalid private key","privateKey","[REDACTED]"),this.#$=N($)}get privateKey(){return this.#$}get publicKey(){return Y0.computePublicKey(this.#$)}get compressedPublicKey(){return Y0.computePublicKey(this.#$,!0)}sign($){V(o0($)===32,"invalid digest length","digest",$);const Q=J8.sign(b0($),b0(this.#$),{lowS:!0});return e.from({r:x0(Q.r,32),s:x0(Q.s,32),v:Q.recovery?28:27})}computeSharedSecret($){const Q=Y0.computePublicKey($);return N(J8.getSharedSecret(b0(this.#$),C(Q),!1))}static computePublicKey($,Q){let J=C($,"key");if(J.length===32){const X=J8.getPublicKey(J,!!Q);return N(X)}if(J.length===64){const X=new Uint8Array(65);X[0]=4,X.set(J,1),J=X}const Y=J8.ProjectivePoint.fromHex(J);return N(Y.toRawBytes(Q))}static recoverPublicKey($,Q){V(o0($)===32,"invalid digest length","digest",$);const J=e.from(Q);let Y=J8.Signature.fromCompact(b0(l([J.r,J.s])));Y=Y.addRecoveryBit(J.yParity);const X=Y.recoverPublicKey(b0($));return V(X!=null,"invalid signature for digest","signature",Q),"0x"+X.toHex(!1)}static addPoints($,Q,J){const Y=J8.ProjectivePoint.fromHex(Y0.computePublicKey($).substring(2)),X=J8.ProjectivePoint.fromHex(Y0.computePublicKey(Q).substring(2));return"0x"+Y.add(X).toHex(!!J)}}var QY=function($){$=$.toLowerCase();const Q=$.substring(2).split(""),J=new Uint8Array(40);for(let X=0;X<40;X++)J[X]=Q[X].charCodeAt(0);const Y=C(d(J));for(let X=0;X<40;X+=2){if(Y[X>>1]>>4>=8)Q[X]=Q[X].toUpperCase();if((Y[X>>1]&15)>=8)Q[X+1]=Q[X+1].toUpperCase()}return"0x"+Q.join("")},TZ=function($){$=$.toUpperCase(),$=$.substring(4)+$.substring(0,2)+"00";let Q=$.split("").map((Y)=>{return r9[Y]}).join("");while(Q.length>=JY){let Y=Q.substring(0,JY);Q=parseInt(Y,10)%97+Q.substring(Y.length)}let J=String(98-parseInt(Q,10)%97);while(J.length<2)J="0"+J;return J},jZ=function($){$=$.toLowerCase();let Q=KZ;for(let J=0;J<$.length;J++)Q=Q*RZ+LZ[$[J]];return Q};function m($){if(V(typeof $==="string","invalid address","address",$),$.match(/^(0x)?[0-9a-fA-F]{40}$/)){if(!$.startsWith("0x"))$="0x"+$;const Q=QY($);return V(!$.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||Q===$,"bad address checksum","address",$),Q}if($.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){V($.substring(2,4)===TZ($),"bad icap checksum","address",$);let Q=jZ($.substring(4)).toString(16);while(Q.length<40)Q="0"+Q;return QY("0x"+Q)}V(!1,"invalid address","address",$)}var KZ=BigInt(0),RZ=BigInt(36),r9={};for(let $=0;$<10;$++)r9[String($)]=String($);for(let $=0;$<26;$++)r9[String.fromCharCode(65+$)]=String(10+$);var JY=15,LZ=function(){const $={};for(let Q=0;Q<36;Q++){const J="0123456789abcdefghijklmnopqrstuvwxyz"[Q];$[J]=BigInt(Q)}return $}();function s9($){return $&&typeof $.getAddress==="function"}async function a9($,Q){const J=await Q;if(J==null||J==="0x0000000000000000000000000000000000000000")f(typeof $!=="string","unconfigured name","UNCONFIGURED_NAME",{value:$}),V(!1,"invalid AddressLike value; did not resolve to a value address","target",$);return m(J)}function Y8($,Q){if(typeof $==="string"){if($.match(/^0x[0-9a-f]{40}$/i))return m($);return f(Q!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),a9($,Q.resolveName($))}else if(s9($))return a9($,$.getAddress());else if($&&typeof $.then==="function")return a9($,$);V(!1,"unsupported addressable value","target",$)}var t9=function($,Q){return{address:m($),storageKeys:Q.map((J,Y)=>{return V(D0(J,32),"invalid slot",`storageKeys[${Y}]`,J),J.toLowerCase()})}};function f8($){if(Array.isArray($))return $.map((J,Y)=>{if(Array.isArray(J))return V(J.length===2,"invalid slot set",`value[${Y}]`,J),t9(J[0],J[1]);return V(J!=null&&typeof J==="object","invalid address-slot set","value",$),t9(J.address,J.storageKeys)});V($!=null&&typeof $==="object","invalid access list","value",$);const Q=Object.keys($).map((J)=>{const Y=$[J].reduce((X,Z)=>{return X[Z]=!0,X},{});return t9(J,Object.keys(Y).sort())});return Q.sort((J,Y)=>J.address.localeCompare(Y.address)),Q}function YY($){return{address:m($.address),nonce:h($.nonce!=null?$.nonce:0),chainId:h($.chainId!=null?$.chainId:0),signature:e.from($.signature)}}function X8($){let Q;if(typeof $==="string")Q=Y0.computePublicKey($,!1);else Q=$.publicKey;return m(d("0x"+Q.substring(4)).substring(26))}function W$($,Q){return X8(Y0.recoverPublicKey($,Q))}var AZ=function($){return{blobToKzgCommitment:(Y)=>{if("computeBlobProof"in $){if(("blobToKzgCommitment"in $)&&typeof $.blobToKzgCommitment==="function")return C($.blobToKzgCommitment(N(Y)))}else if(("blobToKzgCommitment"in $)&&typeof $.blobToKzgCommitment==="function")return C($.blobToKzgCommitment(Y));if(("blobToKZGCommitment"in $)&&typeof $.blobToKZGCommitment==="function")return C($.blobToKZGCommitment(N(Y)));V(!1,"unsupported KZG library","kzg",$)},computeBlobKzgProof:(Y,X)=>{if(("computeBlobProof"in $)&&typeof $.computeBlobProof==="function")return C($.computeBlobProof(N(Y),N(X)));if(("computeBlobKzgProof"in $)&&typeof $.computeBlobKzgProof==="function")return $.computeBlobKzgProof(Y,X);if(("computeBlobKZGProof"in $)&&typeof $.computeBlobKZGProof==="function")return C($.computeBlobKZGProof(N(Y),N(X)));V(!1,"unsupported KZG library","kzg",$)}}},XY=function($,Q){let J=$.toString(16);while(J.length<2)J="0"+J;return J+=V0(Q).substring(4),"0x"+J},a8=function($){if($==="0x")return null;return m($)},s$=function($,Q){try{return f8($)}catch(J){V(!1,J.message,Q,$)}},BZ=function($,Q){try{if(!Array.isArray($))throw new Error("authorizationList: invalid array");const J=[];for(let Y=0;Y<$.length;Y++){const X=$[Y];if(!Array.isArray(X))throw new Error(`authorization[${Y}]: invalid array`);if(X.length!==6)throw new Error(`authorization[${Y}]: wrong length`);if(!X[1])throw new Error(`authorization[${Y}]: null address`);J.push({address:a8(X[1]),nonce:r(X[2],"nonce"),chainId:r(X[0],"chainId"),signature:e.from({yParity:k8(X[3],"yParity"),r:C0(X[4],32),s:C0(X[5],32)})})}return J}catch(J){V(!1,J.message,Q,$)}},k8=function($,Q){if($==="0x")return 0;return q0($,Q)},r=function($,Q){if($==="0x")return U0;const J=h($,Q);return V(J<=wZ,"value exceeds uint size",Q,J),J},y=function($,Q){const J=h($,"value"),Y=s(J);return V(Y.length<=32,"value too large",`tx.${Q}`,J),Y},t$=function($){return f8($).map((Q)=>[Q.address,Q.storageKeys])},FZ=function($){return $.map((Q)=>{return[y(Q.chainId,"chainId"),Q.address,y(Q.nonce,"nonce"),y(Q.signature.yParity,"yParity"),s(Q.signature.r),s(Q.signature.s)]})},fZ=function($,Q){V(Array.isArray($),`invalid ${Q}`,"value",$);for(let J=0;J<$.length;J++)V(D0($[J],32),"invalid ${ param } hash",`value[${J}]`,$[J]);return $},kZ=function($){const Q=G8($);V(Array.isArray(Q)&&(Q.length===9||Q.length===6),"invalid field count for legacy transaction","data",$);const J={type:0,nonce:k8(Q[0],"nonce"),gasPrice:r(Q[1],"gasPrice"),gasLimit:r(Q[2],"gasLimit"),to:a8(Q[3]),value:r(Q[4],"value"),data:N(Q[5]),chainId:U0};if(Q.length===6)return J;const Y=r(Q[6],"v"),X=r(Q[7],"r"),Z=r(Q[8],"s");if(X===U0&&Z===U0)J.chainId=Y;else{let M=(Y-SZ)/CZ;if(M<U0)M=U0;J.chainId=M,V(M!==U0||(Y===EZ||Y===PZ),"non-canonical legacy v","v",Q[6]),J.signature=e.from({r:C0(Q[7],32),s:C0(Q[8],32),v:Y})}return J},_Z=function($,Q){const J=[y($.nonce,"nonce"),y($.gasPrice||0,"gasPrice"),y($.gasLimit,"gasLimit"),$.to||"0x",y($.value,"value"),$.data];let Y=U0;if($.chainId!=U0)Y=h($.chainId,"tx.chainId"),V(!Q||Q.networkV==null||Q.legacyChainId===Y,"tx.chainId/sig.v mismatch","sig",Q);else if($.signature){const Z=$.signature.legacyChainId;if(Z!=null)Y=Z}if(!Q){if(Y!==U0)J.push(s(Y)),J.push("0x"),J.push("0x");return w0(J)}let X=BigInt(27+Q.yParity);if(Y!==U0)X=e.getChainIdV(Y,Q.v);else if(BigInt(Q.v)!==X)V(!1,"tx.chainId/sig.v mismatch","sig",Q);return J.push(s(X)),J.push(s(Q.r)),J.push(s(Q.s)),w0(J)},e$=function($,Q){let J;try{if(J=k8(Q[0],"yParity"),J!==0&&J!==1)throw new Error("bad yParity")}catch(M){V(!1,"invalid yParity","yParity",Q[0])}const Y=C0(Q[1],32),X=C0(Q[2],32),Z=e.from({r:Y,s:X,yParity:J});$.signature=Z},bZ=function($){const Q=G8(C($).slice(1));V(Array.isArray(Q)&&(Q.length===9||Q.length===12),"invalid field count for transaction type: 2","data",N($));const J={type:2,chainId:r(Q[0],"chainId"),nonce:k8(Q[1],"nonce"),maxPriorityFeePerGas:r(Q[2],"maxPriorityFeePerGas"),maxFeePerGas:r(Q[3],"maxFeePerGas"),gasPrice:null,gasLimit:r(Q[4],"gasLimit"),to:a8(Q[5]),value:r(Q[6],"value"),data:N(Q[7]),accessList:s$(Q[8],"accessList")};if(Q.length===9)return J;return e$(J,Q.slice(9)),J},xZ=function($,Q){const J=[y($.chainId,"chainId"),y($.nonce,"nonce"),y($.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),y($.maxFeePerGas||0,"maxFeePerGas"),y($.gasLimit,"gasLimit"),$.to||"0x",y($.value,"value"),$.data,t$($.accessList||[])];if(Q)J.push(y(Q.yParity,"yParity")),J.push(s(Q.r)),J.push(s(Q.s));return l(["0x02",w0(J)])},vZ=function($){const Q=G8(C($).slice(1));V(Array.isArray(Q)&&(Q.length===8||Q.length===11),"invalid field count for transaction type: 1","data",N($));const J={type:1,chainId:r(Q[0],"chainId"),nonce:k8(Q[1],"nonce"),gasPrice:r(Q[2],"gasPrice"),gasLimit:r(Q[3],"gasLimit"),to:a8(Q[4]),value:r(Q[5],"value"),data:N(Q[6]),accessList:s$(Q[7],"accessList")};if(Q.length===8)return J;return e$(J,Q.slice(8)),J},mZ=function($,Q){const J=[y($.chainId,"chainId"),y($.nonce,"nonce"),y($.gasPrice||0,"gasPrice"),y($.gasLimit,"gasLimit"),$.to||"0x",y($.value,"value"),$.data,t$($.accessList||[])];if(Q)J.push(y(Q.yParity,"recoveryParam")),J.push(s(Q.r)),J.push(s(Q.s));return l(["0x01",w0(J)])},gZ=function($){let Q=G8(C($).slice(1)),J="3",Y=null;if(Q.length===4&&Array.isArray(Q[0])){J="3 (network format)";const Z=Q[1],M=Q[2],q=Q[3];V(Array.isArray(Z),"invalid network format: blobs not an array","fields[1]",Z),V(Array.isArray(M),"invalid network format: commitments not an array","fields[2]",M),V(Array.isArray(q),"invalid network format: proofs not an array","fields[3]",q),V(Z.length===M.length,"invalid network format: blobs/commitments length mismatch","fields",Q),V(Z.length===q.length,"invalid network format: blobs/proofs length mismatch","fields",Q),Y=[];for(let U=0;U<Q[1].length;U++)Y.push({data:Z[U],commitment:M[U],proof:q[U]});Q=Q[0]}V(Array.isArray(Q)&&(Q.length===11||Q.length===14),`invalid field count for transaction type: ${J}`,"data",N($));const X={type:3,chainId:r(Q[0],"chainId"),nonce:k8(Q[1],"nonce"),maxPriorityFeePerGas:r(Q[2],"maxPriorityFeePerGas"),maxFeePerGas:r(Q[3],"maxFeePerGas"),gasPrice:null,gasLimit:r(Q[4],"gasLimit"),to:a8(Q[5]),value:r(Q[6],"value"),data:N(Q[7]),accessList:s$(Q[8],"accessList"),maxFeePerBlobGas:r(Q[9],"maxFeePerBlobGas"),blobVersionedHashes:Q[10]};if(Y)X.blobs=Y;V(X.to!=null,`invalid address for transaction type: ${J}`,"data",$),V(Array.isArray(X.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",$);for(let Z=0;Z<X.blobVersionedHashes.length;Z++)V(D0(X.blobVersionedHashes[Z],32),`invalid blobVersionedHash at index ${Z}: must be length 32`,"data",$);if(Q.length===11)return X;return e$(X,Q.slice(11)),X},hZ=function($,Q,J){const Y=[y($.chainId,"chainId"),y($.nonce,"nonce"),y($.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),y($.maxFeePerGas||0,"maxFeePerGas"),y($.gasLimit,"gasLimit"),$.to||o9,y($.value,"value"),$.data,t$($.accessList||[]),y($.maxFeePerBlobGas||0,"maxFeePerBlobGas"),fZ($.blobVersionedHashes||[],"blobVersionedHashes")];if(Q){if(Y.push(y(Q.yParity,"yParity")),Y.push(s(Q.r)),Y.push(s(Q.s)),J)return l(["0x03",w0([Y,J.map((X)=>X.data),J.map((X)=>X.commitment),J.map((X)=>X.proof)])])}return l(["0x03",w0(Y)])},yZ=function($){const Q=G8(C($).slice(1));V(Array.isArray(Q)&&(Q.length===10||Q.length===13),"invalid field count for transaction type: 4","data",N($));const J={type:4,chainId:r(Q[0],"chainId"),nonce:k8(Q[1],"nonce"),maxPriorityFeePerGas:r(Q[2],"maxPriorityFeePerGas"),maxFeePerGas:r(Q[3],"maxFeePerGas"),gasPrice:null,gasLimit:r(Q[4],"gasLimit"),to:a8(Q[5]),value:r(Q[6],"value"),data:N(Q[7]),accessList:s$(Q[8],"accessList"),authorizationList:BZ(Q[9],"authorizationList")};if(Q.length===10)return J;return e$(J,Q.slice(10)),J},cZ=function($,Q){const J=[y($.chainId,"chainId"),y($.nonce,"nonce"),y($.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),y($.maxFeePerGas||0,"maxFeePerGas"),y($.gasLimit,"gasLimit"),$.to||"0x",y($.value,"value"),$.data,t$($.accessList||[]),FZ($.authorizationList||[])];if(Q)J.push(y(Q.yParity,"yParity")),J.push(s(Q.r)),J.push(s(Q.s));return l(["0x04",w0(J)])},U0=BigInt(0),CZ=BigInt(2),EZ=BigInt(27),PZ=BigInt(28),SZ=BigInt(35),wZ=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e9=131072;class L0{#$;#Q;#J;#Y;#U;#G;#W;#V;#z;#O;#D;#I;#q;#Z;#X;#M;#K;get type(){return this.#$}set type($){switch($){case null:this.#$=null;break;case 0:case"legacy":this.#$=0;break;case 1:case"berlin":case"eip-2930":this.#$=1;break;case 2:case"london":case"eip-1559":this.#$=2;break;case 3:case"cancun":case"eip-4844":this.#$=3;break;case 4:case"pectra":case"eip-7702":this.#$=4;break;default:V(!1,"unsupported transaction type","type",$)}}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 $=this.#Q;if($==null&&this.type===3)return o9;return $}set to($){this.#Q=$==null?null:m($)}get nonce(){return this.#Y}set nonce($){this.#Y=q0($,"value")}get gasLimit(){return this.#U}set gasLimit($){this.#U=h($)}get gasPrice(){const $=this.#G;if($==null&&(this.type===0||this.type===1))return U0;return $}set gasPrice($){this.#G=$==null?null:h($,"gasPrice")}get maxPriorityFeePerGas(){const $=this.#W;if($==null){if(this.type===2||this.type===3)return U0;return null}return $}set maxPriorityFeePerGas($){this.#W=$==null?null:h($,"maxPriorityFeePerGas")}get maxFeePerGas(){const $=this.#V;if($==null){if(this.type===2||this.type===3)return U0;return null}return $}set maxFeePerGas($){this.#V=$==null?null:h($,"maxFeePerGas")}get data(){return this.#J}set data($){this.#J=N($)}get value(){return this.#z}set value($){this.#z=h($,"value")}get chainId(){return this.#O}set chainId($){this.#O=h($)}get signature(){return this.#D||null}set signature($){this.#D=$==null?null:e.from($)}get accessList(){const $=this.#I||null;if($==null){if(this.type===1||this.type===2||this.type===3)return[];return null}return $}set accessList($){this.#I=$==null?null:f8($)}get authorizationList(){const $=this.#K||null;if($==null){if(this.type===4)return[]}return $}set authorizationList($){this.#K=$==null?null:$.map((Q)=>YY(Q))}get maxFeePerBlobGas(){const $=this.#q;if($==null&&this.type===3)return U0;return $}set maxFeePerBlobGas($){this.#q=$==null?null:h($,"maxFeePerBlobGas")}get blobVersionedHashes(){let $=this.#Z;if($==null&&this.type===3)return[];return $}set blobVersionedHashes($){if($!=null){V(Array.isArray($),"blobVersionedHashes must be an Array","value",$),$=$.slice();for(let Q=0;Q<$.length;Q++)V(D0($[Q],32),"invalid blobVersionedHash",`value[${Q}]`,$[Q])}this.#Z=$}get blobs(){if(this.#M==null)return null;return this.#M.map(($)=>Object.assign({},$))}set blobs($){if($==null){this.#M=null;return}const Q=[],J=[];for(let Y=0;Y<$.length;Y++){const X=$[Y];if(y0(X)){f(this.#X,"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let Z=C(X);if(V(Z.length<=e9,"blob is too large",`blobs[${Y}]`,X),Z.length!==e9){const U=new Uint8Array(e9);U.set(Z),Z=U}const M=this.#X.blobToKzgCommitment(Z),q=N(this.#X.computeBlobKzgProof(Z,M));Q.push({data:N(Z),commitment:N(M),proof:q}),J.push(XY(1,M))}else{const Z=N(X.commitment);Q.push({data:N(X.data),commitment:Z,proof:N(X.proof)}),J.push(XY(1,Z))}}this.#M=Q,this.#Z=J}get kzg(){return this.#X}set kzg($){if($==null)this.#X=null;else this.#X=AZ($)}constructor(){this.#$=null,this.#Q=null,this.#Y=0,this.#U=U0,this.#G=null,this.#W=null,this.#V=null,this.#J="0x",this.#z=U0,this.#O=U0,this.#D=null,this.#I=null,this.#q=null,this.#Z=null,this.#X=null,this.#M=null,this.#K=null}get hash(){if(this.signature==null)return null;return d(this.#R(!0,!1))}get unsignedHash(){return d(this.unsignedSerialized)}get from(){if(this.signature==null)return null;return W$(this.unsignedHash,this.signature)}get fromPublicKey(){if(this.signature==null)return null;return Y0.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}#R($,Q){f(!$||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const J=$?this.signature:null;switch(this.inferType()){case 0:return _Z(this,J);case 1:return mZ(this,J);case 2:return xZ(this,J);case 3:return hZ(this,J,Q?this.blobs:null);case 4:return cZ(this,J)}f(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})}get serialized(){return this.#R(!0,!0)}get unsignedSerialized(){return this.#R(!1,!1)}inferType(){const $=this.inferTypes();if($.indexOf(2)>=0)return 2;return $.pop()}inferTypes(){const $=this.gasPrice!=null,Q=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,J=this.accessList!=null,Y=this.#q!=null||this.#Z;if(this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null)f(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this});f(!Q||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),f(this.type!==0||!J,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const X=[];if(this.type!=null)X.push(this.type);else if(this.authorizationList&&this.authorizationList.length)X.push(4);else if(Q)X.push(2);else if($){if(X.push(1),!J)X.push(0)}else if(J)X.push(1),X.push(2);else if(Y&&this.to)X.push(3);else X.push(0),X.push(1),X.push(2),X.push(3);return X.sort(),X}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return L0.from(this)}toJSON(){const $=(Q)=>{if(Q==null)return null;return Q.toString()};return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:$(this.gasLimit),gasPrice:$(this.gasPrice),maxPriorityFeePerGas:$(this.maxPriorityFeePerGas),maxFeePerGas:$(this.maxFeePerGas),value:$(this.value),chainId:$(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from($){if($==null)return new L0;if(typeof $==="string"){const J=C($);if(J[0]>=127)return L0.from(kZ(J));switch(J[0]){case 1:return L0.from(vZ(J));case 2:return L0.from(bZ(J));case 3:return L0.from(gZ(J));case 4:return L0.from(yZ(J))}f(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const Q=new L0;if($.type!=null)Q.type=$.type;if($.to!=null)Q.to=$.to;if($.nonce!=null)Q.nonce=$.nonce;if($.gasLimit!=null)Q.gasLimit=$.gasLimit;if($.gasPrice!=null)Q.gasPrice=$.gasPrice;if($.maxPriorityFeePerGas!=null)Q.maxPriorityFeePerGas=$.maxPriorityFeePerGas;if($.maxFeePerGas!=null)Q.maxFeePerGas=$.maxFeePerGas;if($.maxFeePerBlobGas!=null)Q.maxFeePerBlobGas=$.maxFeePerBlobGas;if($.data!=null)Q.data=$.data;if($.value!=null)Q.value=$.value;if($.chainId!=null)Q.chainId=$.chainId;if($.signature!=null)Q.signature=e.from($.signature);if($.accessList!=null)Q.accessList=$.accessList;if($.authorizationList!=null)Q.authorizationList=$.authorizationList;if($.blobVersionedHashes!=null)Q.blobVersionedHashes=$.blobVersionedHashes;if($.kzg!=null)Q.kzg=$.kzg;if($.blobs!=null)Q.blobs=$.blobs;if($.hash!=null)V(Q.isSigned(),"unsigned transaction cannot define '.hash'","tx",$),V(Q.hash===$.hash,"hash mismatch","tx",$);if($.from!=null)V(Q.isSigned(),"unsigned transaction cannot define '.from'","tx",$),V(Q.from.toLowerCase()===($.from||"").toLowerCase(),"from mismatch","tx",$);return Q}}function $9($){return V(typeof $.address==="string","invalid address for hashAuthorization","auth.address",$),d(l(["0x05",w0([$.chainId!=null?s($.chainId):"0x",m($.address),$.nonce!=null?s($.nonce):"0x"])]))}function Z8($){return d(W0($))}function V$($){if(typeof $==="string")$=W0($);return d(l([W0(i9),W0(String($.length)),$]))}function Q9($,Q){const J=V$($);return W$(J,Q)}var dZ=function($){const Q=C($),J=Q.length%32;if(J)return l([Q,UY.slice(J)]);return N(Q)},MY=function($){return function(Q){return V(typeof Q==="string",`invalid domain value for ${JSON.stringify($)}`,`domain.${$}`,Q),Q}},QQ=function($){{const Q=$.match(/^(u?)int(\d+)$/);if(Q){const J=Q[1]==="",Y=parseInt(Q[2]);V(Y%8===0&&Y!==0&&Y<=256&&Q[2]===String(Y),"invalid numeric width","type",$);const X=A$(pZ,J?Y-1:Y),Z=J?(X+WY)*uZ:GY;return function(M){const q=h(M,"value");return V(q>=Z&&q<=X,`value out-of-bounds for ${$}`,"value",q),x0(J?w$(q,256):q,32)}}}{const Q=$.match(/^bytes(\d+)$/);if(Q){const J=parseInt(Q[1]);return V(J!==0&&J<=32&&Q[1]===String(J),"invalid bytes width","type",$),function(Y){const X=C(Y);return V(X.length===J,`invalid length for ${$}`,"value",Y),dZ(Y)}}}switch($){case"address":return function(Q){return C0(m(Q),32)};case"bool":return function(Q){return!Q?nZ:lZ};case"bytes":return function(Q){return d(Q)};case"string":return function(Q){return Z8(Q)}}return null},qY=function($,Q){return`${$}(${Q.map(({name:J,type:Y})=>Y+" "+J).join(",")})`},J9=function($){const Q=$.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);if(Q)return{base:Q[1],index:Q[2]+Q[4],array:{base:Q[1],prefix:Q[1]+Q[2],count:Q[5]?parseInt(Q[5]):-1}};return{base:$}};var UY=new Uint8Array(32);UY.fill(0);var uZ=BigInt(-1),GY=BigInt(0),WY=BigInt(1),pZ=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),lZ=x0(WY,32),nZ=x0(GY,32),ZY={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},$Q=["name","version","chainId","verifyingContract","salt"],oZ={name:MY("name"),version:MY("version"),chainId:function($){const Q=h($,"domain.chainId");if(V(Q>=0,"invalid chain ID","domain.chainId",$),Number.isSafeInteger(Q))return Number(Q);return B$(Q)},verifyingContract:function($){try{return m($).toLowerCase()}catch(Q){}V(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",$)},salt:function($){const Q=C($,"domain.salt");return V(Q.length===32,'invalid domain value "salt"',"domain.salt",$),N(Q)}};class R0{primaryType;#$;get types(){return JSON.parse(this.#$)}#Q;#J;constructor($){this.#Q=new Map,this.#J=new Map;const Q=new Map,J=new Map,Y=new Map,X={};Object.keys($).forEach((q)=>{X[q]=$[q].map(({name:U,type:G})=>{let{base:W,index:O}=J9(G);if(W==="int"&&!$.int)W="int256";if(W==="uint"&&!$.uint)W="uint256";return{name:U,type:W+(O||"")}}),Q.set(q,new Set),J.set(q,[]),Y.set(q,new Set)}),this.#$=JSON.stringify(X);for(let q in X){const U=new Set;for(let G of X[q]){V(!U.has(G.name),`duplicate variable name ${JSON.stringify(G.name)} in ${JSON.stringify(q)}`,"types",$),U.add(G.name);const W=J9(G.type).base;if(V(W!==q,`circular type reference to ${JSON.stringify(W)}`,"types",$),QQ(W))continue;V(J.has(W),`unknown type ${JSON.stringify(W)}`,"types",$),J.get(W).push(q),Q.get(q).add(W)}}const Z=Array.from(J.keys()).filter((q)=>J.get(q).length===0);V(Z.length!==0,"missing primary type","types",$),V(Z.length===1,`ambiguous primary types or unused types: ${Z.map((q)=>JSON.stringify(q)).join(", ")}`,"types",$),a(this,{primaryType:Z[0]});function M(q,U){V(!U.has(q),`circular type reference to ${JSON.stringify(q)}`,"types",$),U.add(q);for(let G of Q.get(q)){if(!J.has(G))continue;M(G,U);for(let W of U)Y.get(W).add(G)}U.delete(q)}M(this.primaryType,new Set);for(let[q,U]of Y){const G=Array.from(U);G.sort(),this.#Q.set(q,qY(q,X[q])+G.map((W)=>qY(W,X[W])).join(""))}}getEncoder($){let Q=this.#J.get($);if(!Q)Q=this.#Y($),this.#J.set($,Q);return Q}#Y($){{const Y=QQ($);if(Y)return Y}const Q=J9($).array;if(Q){const Y=Q.prefix,X=this.getEncoder(Y);return(Z)=>{V(Q.count===-1||Q.count===Z.length,`array length mismatch; expected length ${Q.count}`,"value",Z);let M=Z.map(X);if(this.#Q.has(Y))M=M.map(d);return d(l(M))}}const J=this.types[$];if(J){const Y=Z8(this.#Q.get($));return(X)=>{const Z=J.map(({name:M,type:q})=>{const U=this.getEncoder(q)(X[M]);if(this.#Q.has(q))return d(U);return U});return Z.unshift(Y),l(Z)}}V(!1,`unknown type: ${$}`,"type",$)}encodeType($){const Q=this.#Q.get($);return V(Q,`unknown type: ${JSON.stringify($)}`,"name",$),Q}encodeData($,Q){return this.getEncoder($)(Q)}hashStruct($,Q){return d(this.encodeData($,Q))}encode($){return this.encodeData(this.primaryType,$)}hash($){return this.hashStruct(this.primaryType,$)}_visit($,Q,J){if(QQ($))return J($,Q);const Y=J9($).array;if(Y)return V(Y.count===-1||Y.count===Q.length,`array length mismatch; expected length ${Y.count}`,"value",Q),Q.map((Z)=>this._visit(Y.prefix,Z,J));const X=this.types[$];if(X)return X.reduce((Z,{name:M,type:q})=>{return Z[M]=this._visit(q,Q[M],J),Z},{});V(!1,`unknown type: ${$}`,"type",$)}visit($,Q){return this._visit(this.primaryType,$,Q)}static from($){return new R0($)}static getPrimaryType($){return R0.from($).primaryType}static hashStruct($,Q,J){return R0.from(Q).hashStruct($,J)}static hashDomain($){const Q=[];for(let J in $){if($[J]==null)continue;const Y=ZY[J];V(Y,`invalid typed-data domain key: ${JSON.stringify(J)}`,"domain",$),Q.push({name:J,type:Y})}return Q.sort((J,Y)=>{return $Q.indexOf(J.name)-$Q.indexOf(Y.name)}),R0.hashStruct("EIP712Domain",{EIP712Domain:Q},$)}static encode($,Q,J){return l(["0x1901",R0.hashDomain($),R0.from(Q).hash(J)])}static hash($,Q,J){return d(R0.encode($,Q,J))}static async resolveNames($,Q,J,Y){$=Object.assign({},$);for(let M in $)if($[M]==null)delete $[M];const X={};if($.verifyingContract&&!D0($.verifyingContract,20))X[$.verifyingContract]="0x";const Z=R0.from(Q);Z.visit(J,(M,q)=>{if(M==="address"&&!D0(q,20))X[q]="0x";return q});for(let M in X)X[M]=await Y(M);if($.verifyingContract&&X[$.verifyingContract])$.verifyingContract=X[$.verifyingContract];return J=Z.visit(J,(M,q)=>{if(M==="address"&&X[q])return X[q];return q}),{domain:$,value:J}}static getPayload($,Q,J){R0.hashDomain($);const Y={},X=[];$Q.forEach((q)=>{const U=$[q];if(U==null)return;Y[q]=oZ[q](U),X.push({name:q,type:ZY[q]})});const Z=R0.from(Q);Q=Z.types;const M=Object.assign({},Q);return V(M.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",Q),M.EIP712Domain=X,Z.encode(J),{types:M,domain:Y,primaryType:Z.primaryType,message:Z.visit(J,(q,U)=>{if(q.match(/^bytes(\d*)/))return N(C(U));if(q.match(/^u?int/))return h(U).toString();switch(q){case"address":return U.toLowerCase();case"bool":return!!U;case"string":return V(typeof U==="string","invalid string","value",U),U}V(!1,"unsupported type","type",q)})}}}var JQ=function($){if($==null)return null;return $},G0=function($){if($==null)return null;return $.toString()};function z$($){const Q={};if($.to)Q.to=$.to;if($.from)Q.from=$.from;if($.data)Q.data=N($.data);const J="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(let X of J){if(!(X in $)||$[X]==null)continue;Q[X]=h($[X],`request.${X}`)}const Y="type,nonce".split(/,/);for(let X of Y){if(!(X in $)||$[X]==null)continue;Q[X]=q0($[X],`request.${X}`)}if($.accessList)Q.accessList=f8($.accessList);if($.authorizationList)Q.authorizationList=$.authorizationList.slice();if("blockTag"in $)Q.blockTag=$.blockTag;if("enableCcipRead"in $)Q.enableCcipRead=!!$.enableCcipRead;if("customData"in $)Q.customData=$.customData;if(("blobVersionedHashes"in $)&&$.blobVersionedHashes)Q.blobVersionedHashes=$.blobVersionedHashes.slice();if("kzg"in $)Q.kzg=$.kzg;if(("blobs"in $)&&$.blobs)Q.blobs=$.blobs.map((X)=>{if(y0(X))return N(X);return Object.assign({},X)});return Q}var aZ=function($){return{orphan:"drop-block",hash:$.hash,number:$.number}},DY=function($,Q){return{orphan:"reorder-transaction",tx:$,other:Q}},IY=function($){return{orphan:"drop-transaction",tx:$}},sZ=function($){return{orphan:"drop-log",log:{transactionHash:$.transactionHash,blockHash:$.blockHash,blockNumber:$.blockNumber,address:$.address,data:$.data,topics:Object.freeze($.topics.slice()),index:$.index}}},VY=BigInt(0);class zY{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#$;constructor($,Q){this.#$=$.transactions.map((J)=>{if(typeof J!=="string")return new Y9(J,Q);return J}),a(this,{provider:Q,hash:JQ($.hash),number:$.number,timestamp:$.timestamp,parentHash:$.parentHash,parentBeaconBlockRoot:$.parentBeaconBlockRoot,nonce:$.nonce,difficulty:$.difficulty,gasLimit:$.gasLimit,gasUsed:$.gasUsed,blobGasUsed:$.blobGasUsed,excessBlobGas:$.excessBlobGas,miner:$.miner,prevRandao:JQ($.prevRandao),extraData:$.extraData,baseFeePerGas:JQ($.baseFeePerGas),stateRoot:$.stateRoot,receiptsRoot:$.receiptsRoot})}get transactions(){return this.#$.map(($)=>{if(typeof $==="string")return $;return $.hash})}get prefetchedTransactions(){const $=this.#$.slice();if($.length===0)return[];return f(typeof $[0]==="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),$}toJSON(){const{baseFeePerGas:$,difficulty:Q,extraData:J,gasLimit:Y,gasUsed:X,hash:Z,miner:M,prevRandao:q,nonce:U,number:G,parentHash:W,parentBeaconBlockRoot:O,stateRoot:D,receiptsRoot:E,timestamp:z,transactions:I}=this;return{_type:"Block",baseFeePerGas:G0($),difficulty:G0(Q),extraData:J,gasLimit:G0(Y),gasUsed:G0(X),blobGasUsed:G0(this.blobGasUsed),excessBlobGas:G0(this.excessBlobGas),hash:Z,miner:M,prevRandao:q,nonce:U,number:G,parentHash:W,timestamp:z,parentBeaconBlockRoot:O,stateRoot:D,receiptsRoot:E,transactions:I}}[Symbol.iterator](){let $=0;const Q=this.transactions;return{next:()=>{if($<this.length)return{value:Q[$++],done:!1};return{value:void 0,done:!0}}}}get length(){return this.#$.length}get date(){if(this.timestamp==null)return null;return new Date(this.timestamp*1000)}async getTransaction($){let Q=void 0;if(typeof $==="number")Q=this.#$[$];else{const J=$.toLowerCase();for(let Y of this.#$)if(typeof Y==="string"){if(Y!==J)continue;Q=Y;break}else{if(Y.hash!==J)continue;Q=Y;break}}if(Q==null)throw new Error("no such tx");if(typeof Q==="string")return await this.provider.getTransaction(Q);else return Q}getPrefetchedTransaction($){const Q=this.prefetchedTransactions;if(typeof $==="number")return Q[$];$=$.toLowerCase();for(let J of Q)if(J.hash===$)return J;V(!1,"no matching transaction","indexOrHash",$)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return aZ(this)}}class YQ{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor($,Q){this.provider=Q;const J=Object.freeze($.topics.slice());a(this,{transactionHash:$.transactionHash,blockHash:$.blockHash,blockNumber:$.blockNumber,removed:$.removed,address:$.address,data:$.data,topics:J,index:$.index,transactionIndex:$.transactionIndex})}toJSON(){const{address:$,blockHash:Q,blockNumber:J,data:Y,index:X,removed:Z,topics:M,transactionHash:q,transactionIndex:U}=this;return{_type:"log",address:$,blockHash:Q,blockNumber:J,data:Y,index:X,removed:Z,topics:M,transactionHash:q,transactionIndex:U}}async getBlock(){const $=await this.provider.getBlock(this.blockHash);return f(!!$,"failed to find transaction","UNKNOWN_ERROR",{}),$}async getTransaction(){const $=await this.provider.getTransaction(this.transactionHash);return f(!!$,"failed to find transaction","UNKNOWN_ERROR",{}),$}async getTransactionReceipt(){const $=await this.provider.getTransactionReceipt(this.transactionHash);return f(!!$,"failed to find transaction receipt","UNKNOWN_ERROR",{}),$}removedEvent(){return sZ(this)}}class OY{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#$;constructor($,Q){this.#$=Object.freeze($.logs.map((Y)=>{return new YQ(Y,Q)}));let J=VY;if($.effectiveGasPrice!=null)J=$.effectiveGasPrice;else if($.gasPrice!=null)J=$.gasPrice;a(this,{provider:Q,to:$.to,from:$.from,contractAddress:$.contractAddress,hash:$.hash,index:$.index,blockHash:$.blockHash,blockNumber:$.blockNumber,logsBloom:$.logsBloom,gasUsed:$.gasUsed,cumulativeGasUsed:$.cumulativeGasUsed,blobGasUsed:$.blobGasUsed,gasPrice:J,blobGasPrice:$.blobGasPrice,type:$.type,status:$.status,root:$.root})}get logs(){return this.#$}toJSON(){const{to:$,from:Q,contractAddress:J,hash:Y,index:X,blockHash:Z,blockNumber:M,logsBloom:q,logs:U,status:G,root:W}=this;return{_type:"TransactionReceipt",blockHash:Z,blockNumber:M,contractAddress:J,cumulativeGasUsed:G0(this.cumulativeGasUsed),from:Q,gasPrice:G0(this.gasPrice),blobGasUsed:G0(this.blobGasUsed),blobGasPrice:G0(this.blobGasPrice),gasUsed:G0(this.gasUsed),hash:Y,index:X,logs:U,logsBloom:q,root:W,status:G,to:$}}get length(){return this.logs.length}[Symbol.iterator](){let $=0;return{next:()=>{if($<this.length)return{value:this.logs[$++],done:!1};return{value:void 0,done:!0}}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const $=await this.provider.getBlock(this.blockHash);if($==null)throw new Error("TODO");return $}async getTransaction(){const $=await this.provider.getTransaction(this.hash);if($==null)throw new Error("TODO");return $}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return IY(this)}reorderedEvent($){return f(!$||$.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),DY(this,$)}}class Y9{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;authorizationList;#$;constructor($,Q){this.provider=Q,this.blockNumber=$.blockNumber!=null?$.blockNumber:null,this.blockHash=$.blockHash!=null?$.blockHash:null,this.hash=$.hash,this.index=$.index,this.type=$.type,this.from=$.from,this.to=$.to||null,this.gasLimit=$.gasLimit,this.nonce=$.nonce,this.data=$.data,this.value=$.value,this.gasPrice=$.gasPrice,this.maxPriorityFeePerGas=$.maxPriorityFeePerGas!=null?$.maxPriorityFeePerGas:null,this.maxFeePerGas=$.maxFeePerGas!=null?$.maxFeePerGas:null,this.maxFeePerBlobGas=$.maxFeePerBlobGas!=null?$.maxFeePerBlobGas:null,this.chainId=$.chainId,this.signature=$.signature,this.accessList=$.accessList!=null?$.accessList:null,this.blobVersionedHashes=$.blobVersionedHashes!=null?$.blobVersionedHashes:null,this.authorizationList=$.authorizationList!=null?$.authorizationList:null,this.#$=-1}toJSON(){const{blockNumber:$,blockHash:Q,index:J,hash:Y,type:X,to:Z,from:M,nonce:q,data:U,signature:G,accessList:W,blobVersionedHashes:O}=this;return{_type:"TransactionResponse",accessList:W,blockNumber:$,blockHash:Q,blobVersionedHashes:O,chainId:G0(this.chainId),data:U,from:M,gasLimit:G0(this.gasLimit),gasPrice:G0(this.gasPrice),hash:Y,maxFeePerGas:G0(this.maxFeePerGas),maxPriorityFeePerGas:G0(this.maxPriorityFeePerGas),maxFeePerBlobGas:G0(this.maxFeePerBlobGas),nonce:q,signature:G,to:Z,index:J,type:X,value:G0(this.value)}}async getBlock(){let $=this.blockNumber;if($==null){const J=await this.getTransaction();if(J)$=J.blockNumber}if($==null)return null;const Q=this.provider.getBlock($);if(Q==null)throw new Error("TODO");return Q}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:Q,blockNumber:J}=await h0({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});if(Q==null||Q.blockNumber==null)return 0;return J-Q.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait($,Q){const J=$==null?1:$,Y=Q==null?0:Q;let X=this.#$,Z=-1,M=X===-1?!0:!1;const q=async()=>{if(M)return null;const{blockNumber:O,nonce:D}=await h0({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(D<this.nonce){X=O;return}if(M)return null;const E=await this.getTransaction();if(E&&E.blockNumber!=null)return;if(Z===-1){if(Z=X-3,Z<this.#$)Z=this.#$}while(Z<=O){if(M)return null;const z=await this.provider.getBlock(Z,!0);if(z==null)return;for(let I of z)if(I===this.hash)return;for(let I=0;I<z.length;I++){const T=await z.getTransaction(I);if(T.from===this.from&&T.nonce===this.nonce){if(M)return null;const L=await this.provider.getTransactionReceipt(T.hash);if(L==null)return;if(O-L.blockNumber+1<J)return;let S="replaced";if(T.data===this.data&&T.to===this.to&&T.value===this.value)S="repriced";else if(T.data==="0x"&&T.from===T.to&&T.value===VY)S="cancelled";f(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:S==="replaced"||S==="cancelled",reason:S,replacement:T.replaceableTransaction(X),hash:T.hash,receipt:L})}}Z++}return},U=(O)=>{if(O==null||O.status!==0)return O;f(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:O.to,from:O.from,data:""},receipt:O})},G=await this.provider.getTransactionReceipt(this.hash);if(J===0)return U(G);if(G){if(J===1||await G.confirmations()>=J)return U(G)}else if(await q(),J===0)return null;return await new Promise((O,D)=>{const E=[],z=()=>{E.forEach((T)=>T())};if(E.push(()=>{M=!0}),Y>0){const T=setTimeout(()=>{z(),D(Y$("wait for transaction timeout","TIMEOUT"))},Y);E.push(()=>{clearTimeout(T)})}const I=async(T)=>{if(await T.confirmations()>=J){z();try{O(U(T))}catch(L){D(L)}}};if(E.push(()=>{this.provider.off(this.hash,I)}),this.provider.on(this.hash,I),X>=0){const T=async()=>{try{await q()}catch(L){if(S$(L,"TRANSACTION_REPLACED")){z(),D(L);return}}if(!M)this.provider.once("block",T)};E.push(()=>{this.provider.off("block",T)}),this.provider.once("block",T)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return f(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),IY(this)}reorderedEvent($){return f(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),f(!$||$.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),DY(this,$)}replaceableTransaction($){V(Number.isInteger($)&&$>=0,"invalid startBlock","startBlock",$);const Q=new Y9(this,this.provider);return Q.#$=$,Q}}var _8=function($,Q){if($.provider)return $.provider;f(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:Q})};async function KY($,Q){let J=z$(Q);if(J.to!=null)J.to=Y8(J.to,$);if(J.from!=null){const Y=J.from;J.from=Promise.all([$.getAddress(),Y8(Y,$)]).then(([X,Z])=>{return V(X.toLowerCase()===Z.toLowerCase(),"transaction from mismatch","tx.from",Z),X})}else J.from=$.getAddress();return await h0(J)}class O${provider;constructor($){a(this,{provider:$||null})}async getNonce($){return _8(this,"getTransactionCount").getTransactionCount(await this.getAddress(),$)}async populateCall($){return await KY(this,$)}async populateTransaction($){const Q=_8(this,"populateTransaction"),J=await KY(this,$);if(J.nonce==null)J.nonce=await this.getNonce("pending");if(J.gasLimit==null)J.gasLimit=await this.estimateGas(J);const Y=await this.provider.getNetwork();if(J.chainId!=null){const Z=h(J.chainId);V(Z===Y.chainId,"transaction chainId mismatch","tx.chainId",$.chainId)}else J.chainId=Y.chainId;const X=J.maxFeePerGas!=null||J.maxPriorityFeePerGas!=null;if(J.gasPrice!=null&&(J.type===2||X))V(!1,"eip-1559 transaction do not support gasPrice","tx",$);else if((J.type===0||J.type===1)&&X)V(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",$);if((J.type===2||J.type==null)&&(J.maxFeePerGas!=null&&J.maxPriorityFeePerGas!=null))J.type=2;else if(J.type===0||J.type===1){const Z=await Q.getFeeData();if(f(Z.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),J.gasPrice==null)J.gasPrice=Z.gasPrice}else{const Z=await Q.getFeeData();if(J.type==null)if(Z.maxFeePerGas!=null&&Z.maxPriorityFeePerGas!=null){if(J.authorizationList&&J.authorizationList.length)J.type=4;else J.type=2;if(J.gasPrice!=null){const M=J.gasPrice;delete J.gasPrice,J.maxFeePerGas=M,J.maxPriorityFeePerGas=M}else{if(J.maxFeePerGas==null)J.maxFeePerGas=Z.maxFeePerGas;if(J.maxPriorityFeePerGas==null)J.maxPriorityFeePerGas=Z.maxPriorityFeePerGas}}else if(Z.gasPrice!=null){if(f(!X,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),J.gasPrice==null)J.gasPrice=Z.gasPrice;J.type=0}else f(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else if(J.type===2||J.type===3||J.type===4){if(J.maxFeePerGas==null)J.maxFeePerGas=Z.maxFeePerGas;if(J.maxPriorityFeePerGas==null)J.maxPriorityFeePerGas=Z.maxPriorityFeePerGas}}return await h0(J)}async populateAuthorization($){const Q=Object.assign({},$);if(Q.chainId==null)Q.chainId=(await _8(this,"getNetwork").getNetwork()).chainId;if(Q.nonce==null)Q.nonce=await this.getNonce();return Q}async estimateGas($){return _8(this,"estimateGas").estimateGas(await this.populateCall($))}async call($){return _8(this,"call").call(await this.populateCall($))}async resolveName($){return await _8(this,"resolveName").resolveName($)}async sendTransaction($){const Q=_8(this,"sendTransaction"),J=await this.populateTransaction($);delete J.from;const Y=L0.from(J);return await Q.broadcastTransaction(await this.signTransaction(Y))}authorize($){f(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}class D$ extends O${address;constructor($,Q){super(Q);a(this,{address:$})}async getAddress(){return this.address}connect($){return new D$(this.address,$)}#$($,Q){f(!1,`VoidSigner cannot sign ${$}`,"UNSUPPORTED_OPERATION",{operation:Q})}async signTransaction($){this.#$("transactions","signTransaction")}async signMessage($){this.#$("messages","signMessage")}async signTypedData($,Q,J){this.#$("typed-data","signTypedData")}}class b8 extends O${address;#$;constructor($,Q){super(Q);V($&&typeof $.sign==="function","invalid private key","privateKey","[ REDACTED ]"),this.#$=$;const J=X8(this.signingKey.publicKey);a(this,{address:J})}get signingKey(){return this.#$}get privateKey(){return this.signingKey.privateKey}async getAddress(){return this.address}connect($){return new b8(this.#$,$)}async signTransaction($){$=z$($);const{to:Q,from:J}=await h0({to:$.to?Y8($.to,this):void 0,from:$.from?Y8($.from,this):void 0});if(Q!=null)$.to=Q;if(J!=null)$.from=J;if($.from!=null)V(m($.from)===this.address,"transaction from address mismatch","tx.from",$.from),delete $.from;const Y=L0.from($);return Y.signature=this.signingKey.sign(Y.unsignedHash),Y.serialized}async signMessage($){return this.signMessageSync($)}signMessageSync($){return this.signingKey.sign(V$($)).serialized}authorizeSync($){V(typeof $.address==="string","invalid address for authorizeSync","auth.address",$);const Q=this.signingKey.sign($9($));return Object.assign({},{address:m($.address),nonce:h($.nonce||0),chainId:h($.chainId||0)},{signature:Q})}async authorize($){return $=Object.assign({},$,{address:await Y8($.address,this)}),this.authorizeSync(await this.populateAuthorization($))}async signTypedData($,Q,J){const Y=await R0.resolveNames($,Q,J,async(X)=>{f(this.provider!=null,"cannot resolve ENS names without a provider","UNSUPPORTED_OPERATION",{operation:"resolveName",info:{name:X}});const Z=await this.provider.resolveName(X);return f(Z!=null,"unconfigured ENS name","UNCONFIGURED_NAME",{value:X}),Z});return this.signingKey.sign(R0.hash(Y.domain,Q,Y.value)).serialized}}var RY=function($,Q){let J=97;return $.reduce((Y,X)=>{if(X===Q)J++;else if(X.match(tZ))Y.push(String.fromCharCode(J)+X);else J=97,Y.push(X);return Y},[])};function eZ($,Q){for(let X=X9.length-1;X>=0;X--)$=$.split(X9[X]).join(Q.substring(2*X,2*X+2));const J=[],Y=$.replace(/(:|([0-9])|([A-Z][a-z]*))/g,(X,Z,M,q)=>{if(M)for(let U=parseInt(M);U>=0;U--)J.push(";");else J.push(Z.toLowerCase());return""});if(Y)throw new Error(`leftovers: ${JSON.stringify(Y)}`);return RY(RY(J,";"),":")}function TY($){return V($[0]==="0","unsupported auwl data","data",$),eZ($.substring(1+2*X9.length),$.substring(1,1+2*X9.length))}var X9=" !#$%&'()*+,-./<=>?@[]^_`{|}~",tZ=/^[a-z]*$/i;class XQ{locale;constructor($){a(this,{locale:$})}split($){return $.toLowerCase().split(/\s+/g)}join($){return $.join(" ")}}class ZQ extends XQ{#$;#Q;constructor($,Q,J){super($);this.#$=Q,this.#Q=J,this.#J=null}get _data(){return this.#$}_decodeWords(){return TY(this.#$)}#J;#Y(){if(this.#J==null){const $=this._decodeWords();if(Z8($.join("\n")+"\n")!==this.#Q)throw new Error(`BIP39 Wordlist for ${this.locale} FAILED`);this.#J=$}return this.#J}getWord($){const Q=this.#Y();return V($>=0&&$<Q.length,`invalid word index: ${$}`,"index",$),Q[$]}getWordIndex($){return this.#Y().indexOf($)}}var $5="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",Q5="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60",MQ=null;class M8 extends ZQ{constructor(){super("en",$5,Q5)}static wordlist(){if(MQ==null)MQ=new M8;return MQ}}var LY=function($){return(1<<$)-1<<8-$&255},J5=function($){return(1<<$)-1&255},qQ=function($,Q){if(c8("NFKD"),Q==null)Q=M8.wordlist();const J=Q.split($);V(J.length%3===0&&J.length>=12&&J.length<=24,"invalid mnemonic length","mnemonic","[ REDACTED ]");const Y=new Uint8Array(Math.ceil(11*J.length/8));let X=0;for(let G=0;G<J.length;G++){let W=Q.getWordIndex(J[G].normalize("NFKD"));V(W>=0,`invalid mnemonic word at index ${G}`,"mnemonic","[ REDACTED ]");for(let O=0;O<11;O++){if(W&1<<10-O)Y[X>>3]|=1<<7-X%8;X++}}const Z=32*J.length/3,M=J.length/3,q=LY(M),U=C(V0(Y.slice(0,Z/8)))[0]&q;return V(U===(Y[Y.length-1]&q),"invalid mnemonic checksum","mnemonic","[ REDACTED ]"),N(Y.slice(0,Z/8))},UQ=function($,Q){if(V($.length%4===0&&$.length>=16&&$.length<=32,"invalid entropy size","entropy","[ REDACTED ]"),Q==null)Q=M8.wordlist();const J=[0];let Y=11;for(let M=0;M<$.length;M++)if(Y>8)J[J.length-1]<<=8,J[J.length-1]|=$[M],Y-=8;else J[J.length-1]<<=Y,J[J.length-1]|=$[M]>>8-Y,J.push($[M]&J5(8-Y)),Y+=3;const X=$.length/4,Z=parseInt(V0($).substring(2,4),16)&LY(X);return J[J.length-1]<<=X,J[J.length-1]|=Z>>8-X,Q.join(J.map((M)=>Q.getWord(M)))},GQ={};class q8{phrase;password;wordlist;entropy;constructor($,Q,J,Y,X){if(Y==null)Y="";if(X==null)X=M8.wordlist();n0($,GQ,"Mnemonic"),a(this,{phrase:J,password:Y,wordlist:X,entropy:Q})}computeSeed(){const $=W0("mnemonic"+this.password,"NFKD");return E0(W0(this.phrase,"NFKD"),$,2048,64,"sha512")}static fromPhrase($,Q,J){const Y=qQ($,J);return $=UQ(C(Y),J),new q8(GQ,Y,$,Q,J)}static fromEntropy($,Q,J){const Y=C($,"entropy"),X=UQ(Y,J);return new q8(GQ,N(Y),X,Q,J)}static entropyToPhrase($,Q){const J=C($,"entropy");return UQ(J,Q)}static phraseToEntropy($,Q){return qQ($,Q)}static isValidMnemonic($,Q){try{return qQ($,Q),!0}catch(J){}return!1}}var VQ=function($){const Q=[];for(let J=0;J<$.length;J+=4)Q.push($[J]<<24|$[J+1]<<16|$[J+2]<<8|$[J+3]);return Q};/*! MIT License. Copyright 2015-2022 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */var z0=function($,Q,J,Y){if(J==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?$!==Q||!Y:!Q.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return J==="m"?Y:J==="a"?Y.call($):Y?Y.value:Q.get($)},WQ=function($,Q,J,Y,X){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?$!==Q||!X:!Q.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?X.call($,J):X?X.value=J:Q.set($,J),J},M9,F0,u0,Y5={16:10,24:12,32:14},X5=[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],B0=[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],Z9=[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],Z5=[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],M5=[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],q5=[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],U5=[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],G5=[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],W5=[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],V5=[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,1047239000,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],z5=[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,679998000,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],O5=[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],D5=[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],I5=[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,1047239000,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],K5=[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,679998000,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];class q9{get key(){return z0(this,M9,"f").slice()}constructor($){if(M9.set(this,void 0),F0.set(this,void 0),u0.set(this,void 0),!(this instanceof q9))throw Error("AES must be instanitated with `new`");WQ(this,M9,new Uint8Array($),"f");const Q=Y5[this.key.length];if(Q==null)throw new TypeError("invalid key size (must be 16, 24 or 32 bytes)");WQ(this,u0,[],"f"),WQ(this,F0,[],"f");for(let G=0;G<=Q;G++)z0(this,u0,"f").push([0,0,0,0]),z0(this,F0,"f").push([0,0,0,0]);const J=(Q+1)*4,Y=this.key.length/4,X=VQ(this.key);let Z;for(let G=0;G<Y;G++)Z=G>>2,z0(this,u0,"f")[Z][G%4]=X[G],z0(this,F0,"f")[Q-Z][G%4]=X[G];let M=0,q=Y,U;while(q<J){if(U=X[Y-1],X[0]^=B0[U>>16&255]<<24^B0[U>>8&255]<<16^B0[U&255]<<8^B0[U>>24&255]^X5[M]<<24,M+=1,Y!=8)for(let D=1;D<Y;D++)X[D]^=X[D-1];else{for(let D=1;D<Y/2;D++)X[D]^=X[D-1];U=X[Y/2-1],X[Y/2]^=B0[U&255]^B0[U>>8&255]<<8^B0[U>>16&255]<<16^B0[U>>24&255]<<24;for(let D=Y/2+1;D<Y;D++)X[D]^=X[D-1]}let G=0,W,O;while(G<Y&&q<J)W=q>>2,O=q%4,z0(this,u0,"f")[W][O]=X[G],z0(this,F0,"f")[Q-W][O]=X[G++],q++}for(let G=1;G<Q;G++)for(let W=0;W<4;W++)U=z0(this,F0,"f")[G][W],z0(this,F0,"f")[G][W]=O5[U>>24&255]^D5[U>>16&255]^I5[U>>8&255]^K5[U&255]}encrypt($){if($.length!=16)throw new TypeError("invalid plaintext size (must be 16 bytes)");const Q=z0(this,u0,"f").length-1,J=[0,0,0,0];let Y=VQ($);for(let M=0;M<4;M++)Y[M]^=z0(this,u0,"f")[0][M];for(let M=1;M<Q;M++){for(let q=0;q<4;q++)J[q]=Z5[Y[q]>>24&255]^M5[Y[(q+1)%4]>>16&255]^q5[Y[(q+2)%4]>>8&255]^U5[Y[(q+3)%4]&255]^z0(this,u0,"f")[M][q];Y=J.slice()}const X=new Uint8Array(16);let Z=0;for(let M=0;M<4;M++)Z=z0(this,u0,"f")[Q][M],X[4*M]=(B0[Y[M]>>24&255]^Z>>24)&255,X[4*M+1]=(B0[Y[(M+1)%4]>>16&255]^Z>>16)&255,X[4*M+2]=(B0[Y[(M+2)%4]>>8&255]^Z>>8)&255,X[4*M+3]=(B0[Y[(M+3)%4]&255]^Z)&255;return X}decrypt($){if($.length!=16)throw new TypeError("invalid ciphertext size (must be 16 bytes)");const Q=z0(this,F0,"f").length-1,J=[0,0,0,0];let Y=VQ($);for(let M=0;M<4;M++)Y[M]^=z0(this,F0,"f")[0][M];for(let M=1;M<Q;M++){for(let q=0;q<4;q++)J[q]=G5[Y[q]>>24&255]^W5[Y[(q+3)%4]>>16&255]^V5[Y[(q+2)%4]>>8&255]^z5[Y[(q+1)%4]&255]^z0(this,F0,"f")[M][q];Y=J.slice()}const X=new Uint8Array(16);let Z=0;for(let M=0;M<4;M++)Z=z0(this,F0,"f")[Q][M],X[4*M]=(Z9[Y[M]>>24&255]^Z>>24)&255,X[4*M+1]=(Z9[Y[(M+3)%4]>>16&255]^Z>>16)&255,X[4*M+2]=(Z9[Y[(M+2)%4]>>8&255]^Z>>8)&255,X[4*M+3]=(Z9[Y[(M+1)%4]&255]^Z)&255;return X}}M9=new WeakMap,F0=new WeakMap,u0=new WeakMap;class I${constructor($,Q,J){if(J&&!(this instanceof J))throw new Error(`${$} must be instantiated with "new"`);Object.defineProperties(this,{aes:{enumerable:!0,value:new q9(Q)},name:{enumerable:!0,value:$}})}}var U9=function($,Q,J,Y,X){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?$!==Q||!X:!Q.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?X.call($,J):X?X.value=J:Q.set($,J),J},s8=function($,Q,J,Y){if(J==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?$!==Q||!Y:!Q.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return J==="m"?Y:J==="a"?Y.call($):Y?Y.value:Q.get($)},K$,U8;class R$ extends I${constructor($,Q){super("ECC",$,R$);if(K$.set(this,void 0),U8.set(this,void 0),Q){if(Q.length%16)throw new TypeError("invalid iv size (must be 16 bytes)");U9(this,K$,new Uint8Array(Q),"f")}else U9(this,K$,new Uint8Array(16),"f");U9(this,U8,this.iv,"f")}get iv(){return new Uint8Array(s8(this,K$,"f"))}encrypt($){if($.length%16)throw new TypeError("invalid plaintext size (must be multiple of 16 bytes)");const Q=new Uint8Array($.length);for(let J=0;J<$.length;J+=16){for(let Y=0;Y<16;Y++)s8(this,U8,"f")[Y]^=$[J+Y];U9(this,U8,this.aes.encrypt(s8(this,U8,"f")),"f"),Q.set(s8(this,U8,"f"),J)}return Q}decrypt($){if($.length%16)throw new TypeError("invalid ciphertext size (must be multiple of 16 bytes)");const Q=new Uint8Array($.length);for(let J=0;J<$.length;J+=16){const Y=this.aes.decrypt($.subarray(J,J+16));for(let X=0;X<16;X++)Q[J+X]=Y[X]^s8(this,U8,"f")[X],s8(this,U8,"f")[X]=$[J+X]}return Q}}K$=new WeakMap,U8=new WeakMap;var t8=function($,Q,J,Y,X){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?$!==Q||!X:!Q.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?X.call($,J):X?X.value=J:Q.set($,J),J},f0=function($,Q,J,Y){if(J==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?$!==Q||!Y:!Q.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return J==="m"?Y:J==="a"?Y.call($):Y?Y.value:Q.get($)},T$,x8,k0;class R8 extends I${constructor($,Q){super("CTR",$,R8);if(T$.set(this,void 0),x8.set(this,void 0),k0.set(this,void 0),t8(this,k0,new Uint8Array(16),"f"),f0(this,k0,"f").fill(0),t8(this,T$,f0(this,k0,"f"),"f"),t8(this,x8,16,"f"),Q==null)Q=1;if(typeof Q==="number")this.setCounterValue(Q);else this.setCounterBytes(Q)}get counter(){return new Uint8Array(f0(this,k0,"f"))}setCounterValue($){if(!Number.isInteger($)||$<0||$>Number.MAX_SAFE_INTEGER)throw new TypeError("invalid counter initial integer value");for(let Q=15;Q>=0;--Q)f0(this,k0,"f")[Q]=$%256,$=Math.floor($/256)}setCounterBytes($){if($.length!==16)throw new TypeError("invalid counter initial Uint8Array value length");f0(this,k0,"f").set($)}increment(){for(let $=15;$>=0;$--)if(f0(this,k0,"f")[$]===255)f0(this,k0,"f")[$]=0;else{f0(this,k0,"f")[$]++;break}}encrypt($){var Q,J;const Y=new Uint8Array($);for(let X=0;X<Y.length;X++){if(f0(this,x8,"f")===16)t8(this,T$,this.aes.encrypt(f0(this,k0,"f")),"f"),t8(this,x8,0,"f"),this.increment();Y[X]^=f0(this,T$,"f")[t8(this,x8,(J=f0(this,x8,"f"),Q=J++,J),"f"),Q]}return Y}decrypt($){return this.encrypt($)}}T$=new WeakMap,x8=new WeakMap,k0=new WeakMap;function zQ($){if($.length<16)throw new TypeError("PKCS#7 invalid length");const Q=$[$.length-1];if(Q>16)throw new TypeError("PKCS#7 padding byte out of range");const J=$.length-Q;for(let Y=0;Y<Q;Y++)if($[J+Y]!==Q)throw new TypeError("PKCS#7 invalid padding byte");return new Uint8Array($.subarray(0,J))}function OQ($){if(typeof $==="string"&&!$.startsWith("0x"))$="0x"+$;return b0($)}function e8($,Q){$=String($);while($.length<Q)$="0"+$;return $}function v8($){if(typeof $==="string")return W0($,"NFKC");return b0($)}function Q0($,Q){const J=Q.match(/^([a-z0-9$_.-]*)(:([a-z]+))?(!)?$/i);V(J!=null,"invalid path","path",Q);const Y=J[1],X=J[3],Z=J[4]==="!";let M=$;for(let q of Y.toLowerCase().split(".")){if(Array.isArray(M)){if(!q.match(/^[0-9]+$/))break;M=M[parseInt(q)]}else if(typeof M==="object"){let U=null;for(let G in M)if(G.toLowerCase()===q){U=M[G];break}M=U}else M=null;if(M==null)break}if(V(!Z||M!=null,"missing required value","path",Y),X&&M!=null){if(X==="int"){if(typeof M==="string"&&M.match(/^-?[0-9]+$/))return parseInt(M);else if(Number.isSafeInteger(M))return M}if(X==="number"){if(typeof M==="string"&&M.match(/^-?[0-9.]*$/))return parseFloat(M)}if(X==="data"){if(typeof M==="string")return OQ(M)}if(X==="array"&&Array.isArray(M))return M;if(X===typeof M)return M;V(!1,`wrong type found for ${X} `,"path",Y)}return M}function W9($){try{const Q=JSON.parse($);if((Q.version!=null?parseInt(Q.version):0)===3)return!0}catch(Q){}return!1}var R5=function($,Q,J){if(Q0($,"crypto.cipher:string")==="aes-128-ctr"){const X=Q0($,"crypto.cipherparams.iv:data!"),Z=new R8(Q,X);return N(Z.decrypt(J))}f(!1,"unsupported cipher","UNSUPPORTED_OPERATION",{operation:"decrypt"})},G9=function($,Q){const J=C(Q),Y=Q0($,"crypto.ciphertext:data!"),X=N(d(l([J.slice(16,32),Y]))).substring(2);V(X===Q0($,"crypto.mac:string!").toLowerCase(),"incorrect password","password","[ REDACTED ]");const Z=R5($,J.slice(0,16),Y),M=X8(Z);if($.address){let G=$.address.toLowerCase();if(!G.startsWith("0x"))G="0x"+G;V(m(G)===M,"keystore address/privateKey mismatch","address",$.address)}const q={address:M,privateKey:Z};if(Q0($,"x-ethers.version:string")==="0.1"){const G=J.slice(32,64),W=Q0($,"x-ethers.mnemonicCiphertext:data!"),O=Q0($,"x-ethers.mnemonicCounter:data!"),D=new R8(G,O);q.mnemonic={path:Q0($,"x-ethers.path:string")||HY,locale:Q0($,"x-ethers.locale:string")||"en",entropy:N(C(D.decrypt(W)))}}return q},NY=function($){const Q=Q0($,"crypto.kdf:string");if(Q&&typeof Q==="string"){if(Q.toLowerCase()==="scrypt"){const J=Q0($,"crypto.kdfparams.salt:data!"),Y=Q0($,"crypto.kdfparams.n:int!"),X=Q0($,"crypto.kdfparams.r:int!"),Z=Q0($,"crypto.kdfparams.p:int!");V(Y>0&&(Y&Y-1)===0,"invalid kdf.N","kdf.N",Y),V(X>0&&Z>0,"invalid kdf","kdf",Q);const M=Q0($,"crypto.kdfparams.dklen:int!");return V(M===32,"invalid kdf.dklen","kdf.dflen",M),{name:"scrypt",salt:J,N:Y,r:X,p:Z,dkLen:64}}else if(Q.toLowerCase()==="pbkdf2"){const J=Q0($,"crypto.kdfparams.salt:data!"),Y=Q0($,"crypto.kdfparams.prf:string!"),X=Y.split("-").pop();V(X==="sha256"||X==="sha512","invalid kdf.pdf","kdf.pdf",Y);const Z=Q0($,"crypto.kdfparams.c:int!"),M=Q0($,"crypto.kdfparams.dklen:int!");return V(M===32,"invalid kdf.dklen","kdf.dklen",M),{name:"pbkdf2",salt:J,count:Z,dkLen:M,algorithm:X}}}V(!1,"unsupported key-derivation function","kdf",Q)};function DQ($,Q){const J=JSON.parse($),Y=v8(Q),X=NY(J);if(X.name==="pbkdf2"){const{salt:O,count:D,dkLen:E,algorithm:z}=X,I=E0(Y,O,D,E,z);return G9(J,I)}f(X.name==="scrypt","cannot be reached","UNKNOWN_ERROR",{params:X});const{salt:Z,N:M,r:q,p:U,dkLen:G}=X,W=e0(Y,Z,M,q,U,G);return G9(J,W)}var jY=function($){return new Promise((Q)=>{setTimeout(()=>{Q()},$)})};async function IQ($,Q,J){const Y=JSON.parse($),X=v8(Q),Z=NY(Y);if(Z.name==="pbkdf2"){if(J)J(0),await jY(0);const{salt:D,count:E,dkLen:z,algorithm:I}=Z,T=E0(X,D,E,z,I);if(J)J(1),await jY(0);return G9(Y,T)}f(Z.name==="scrypt","cannot be reached","UNKNOWN_ERROR",{params:Z});const{salt:M,N:q,r:U,p:G,dkLen:W}=Z,O=await t0(X,M,q,U,G,W,J);return G9(Y,O)}var CY=function($){const Q=$.salt!=null?C($.salt,"options.salt"):Z0(32);let J=1<<17,Y=8,X=1;if($.scrypt){if($.scrypt.N)J=$.scrypt.N;if($.scrypt.r)Y=$.scrypt.r;if($.scrypt.p)X=$.scrypt.p}return V(typeof J==="number"&&J>0&&Number.isSafeInteger(J)&&(BigInt(J)&BigInt(J-1))===BigInt(0),"invalid scrypt N parameter","options.N",J),V(typeof Y==="number"&&Y>0&&Number.isSafeInteger(Y),"invalid scrypt r parameter","options.r",Y),V(typeof X==="number"&&X>0&&Number.isSafeInteger(X),"invalid scrypt p parameter","options.p",X),{name:"scrypt",dkLen:32,salt:Q,N:J,r:Y,p:X}},EY=function($,Q,J,Y){const X=C(J.privateKey,"privateKey"),Z=Y.iv!=null?C(Y.iv,"options.iv"):Z0(16);V(Z.length===16,"invalid options.iv length","options.iv",Y.iv);const M=Y.uuid!=null?C(Y.uuid,"options.uuid"):Z0(16);V(M.length===16,"invalid options.uuid length","options.uuid",Y.iv);const q=$.slice(0,16),U=$.slice(16,32),G=new R8(q,Z),W=C(G.encrypt(X)),O=d(l([U,W])),D={address:J.address.substring(2).toLowerCase(),id:b$(M),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:N(Z).substring(2)},ciphertext:N(W).substring(2),kdf:"scrypt",kdfparams:{salt:N(Q.salt).substring(2),n:Q.N,dklen:32,p:Q.p,r:Q.r},mac:O.substring(2)}};if(J.mnemonic){const E=Y.client!=null?Y.client:`ethers/${P$}`,z=J.mnemonic.path||HY,I=J.mnemonic.locale||"en",T=$.slice(32,64),L=C(J.mnemonic.entropy,"account.mnemonic.entropy"),S=Z0(16),k=new R8(T,S),P=C(k.encrypt(L)),K=new Date,j="UTC--"+(K.getUTCFullYear()+"-"+e8(K.getUTCMonth()+1,2)+"-"+e8(K.getUTCDate(),2)+"T"+e8(K.getUTCHours(),2)+"-"+e8(K.getUTCMinutes(),2)+"-"+e8(K.getUTCSeconds(),2)+".0Z--")+D.address;D["x-ethers"]={client:E,gethFilename:j,path:z,locale:I,mnemonicCounter:N(S).substring(2),mnemonicCiphertext:N(P).substring(2),version:"0.1"}}return JSON.stringify(D)};function L$($,Q,J){if(J==null)J={};const Y=v8(Q),X=CY(J),Z=e0(Y,X.salt,X.N,X.r,X.p,64);return EY(C(Z),X,$,J)}async function j$($,Q,J){if(J==null)J={};const Y=v8(Q),X=CY(J),Z=await t0(Y,X.salt,X.N,X.r,X.p,64,J.progressCallback);return EY(C(Z),X,$,J)}var HY="m/44'/60'/0'/0/0";var z9=function($,Q){let J="";while($)J=j5[$%16]+J,$=Math.trunc($/16);while(J.length<Q*2)J="0"+J;return"0x"+J},KQ=function($){const Q=C($),J=u8(V0(V0(Q)),0,4),Y=l([Q,J]);return k$(Y)},PY=function($,Q,J,Y){const X=new Uint8Array(37);if($&T8)f(Y!=null,"cannot derive child of neutered node","UNSUPPORTED_OPERATION",{operation:"deriveChild"}),X.set(C(Y),1);else X.set(C(J));for(let M=24;M>=0;M-=8)X[33+(M>>3)]=$>>24-M&255;const Z=C(a0("sha512",Q,X));return{IL:Z.slice(0,32),IR:Z.slice(32)}},SY=function($,Q){const J=Q.split("/");if(V(J.length>0,"invalid path","path",Q),J[0]==="m")V($.depth===0,`cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${$.depth}`,"path",Q),J.shift();let Y=$;for(let X=0;X<J.length;X++){const Z=J[X];if(Z.match(/^[0-9]+'$/)){const M=parseInt(Z.substring(0,Z.length-1));V(M<T8,"invalid path index",`path[${X}]`,Z),Y=Y.deriveChild(T8+M)}else if(Z.match(/^[0-9]+$/)){const M=parseInt(Z);V(M<T8,"invalid path index",`path[${X}]`,Z),Y=Y.deriveChild(M)}else V(!1,"invalid path component",`path[${X}]`,Z)}return Y};var V9="m/44'/60'/0'/0/0",T5=new Uint8Array([66,105,116,99,111,105,110,32,115,101,101,100]),T8=2147483648,L5=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),j5="0123456789abcdef",p0={};class j0 extends b8{publicKey;fingerprint;parentFingerprint;mnemonic;chainCode;path;index;depth;constructor($,Q,J,Y,X,Z,M,q,U){super(Q,U);n0($,p0,"HDNodeWallet"),a(this,{publicKey:Q.compressedPublicKey});const G=u8(s0(V0(this.publicKey)),0,4);a(this,{parentFingerprint:J,fingerprint:G,chainCode:Y,path:X,index:Z,depth:M}),a(this,{mnemonic:q})}connect($){return new j0(p0,this.signingKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.mnemonic,$)}#$(){const $={address:this.address,privateKey:this.privateKey},Q=this.mnemonic;if(this.path&&Q&&Q.wordlist.locale==="en"&&Q.password==="")$.mnemonic={path:this.path,locale:"en",entropy:Q.entropy};return $}async encrypt($,Q){return await j$(this.#$(),$,{progressCallback:Q})}encryptSync($){return L$(this.#$(),$)}get extendedKey(){return f(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),KQ(l(["0x0488ADE4",z9(this.depth,1),this.parentFingerprint,z9(this.index,4),this.chainCode,l(["0x00",this.privateKey])]))}hasPath(){return this.path!=null}neuter(){return new $$(p0,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,this.provider)}deriveChild($){const Q=q0($,"index");V(Q<=4294967295,"invalid index","index",Q);let J=this.path;if(J){if(J+="/"+(Q&~T8),Q&T8)J+="'"}const{IR:Y,IL:X}=PY(Q,this.chainCode,this.publicKey,this.privateKey),Z=new Y0(x0((d8(X)+BigInt(this.privateKey))%L5,32));return new j0(p0,Z,this.fingerprint,N(Y),J,Q,this.depth+1,this.mnemonic,this.provider)}derivePath($){return SY(this,$)}static#Q($,Q){V(y0($),"invalid seed","seed","[REDACTED]");const J=C($,"seed");V(J.length>=16&&J.length<=64,"invalid seed","seed","[REDACTED]");const Y=C(a0("sha512",T5,J)),X=new Y0(N(Y.slice(0,32)));return new j0(p0,X,"0x00000000",N(Y.slice(32)),"m",0,0,Q,null)}static fromExtendedKey($){const Q=s(_$($));V(Q.length===82||KQ(Q.slice(0,78))===$,"invalid extended key","extendedKey","[ REDACTED ]");const J=Q[4],Y=N(Q.slice(5,9)),X=parseInt(N(Q.slice(9,13)).substring(2),16),Z=N(Q.slice(13,45)),M=Q.slice(45,78);switch(N(Q.slice(0,4))){case"0x0488b21e":case"0x043587cf":{const q=N(M);return new $$(p0,X8(q),q,Y,Z,null,X,J,null)}case"0x0488ade4":case"0x04358394 ":if(M[0]!==0)break;return new j0(p0,new Y0(M.slice(1)),Y,Z,null,X,J,null,null)}V(!1,"invalid extended key prefix","extendedKey","[ REDACTED ]")}static createRandom($,Q,J){if($==null)$="";if(Q==null)Q=V9;if(J==null)J=M8.wordlist();const Y=q8.fromEntropy(Z0(16),$,J);return j0.#Q(Y.computeSeed(),Y).derivePath(Q)}static fromMnemonic($,Q){if(!Q)Q=V9;return j0.#Q($.computeSeed(),$).derivePath(Q)}static fromPhrase($,Q,J,Y){if(Q==null)Q="";if(J==null)J=V9;if(Y==null)Y=M8.wordlist();const X=q8.fromPhrase($,Q,Y);return j0.#Q(X.computeSeed(),X).derivePath(J)}static fromSeed($){return j0.#Q($,null)}}class $$ extends D${publicKey;fingerprint;parentFingerprint;chainCode;path;index;depth;constructor($,Q,J,Y,X,Z,M,q,U){super(Q,U);n0($,p0,"HDNodeVoidWallet"),a(this,{publicKey:J});const G=u8(s0(V0(J)),0,4);a(this,{publicKey:J,fingerprint:G,parentFingerprint:Y,chainCode:X,path:Z,index:M,depth:q})}connect($){return new $$(p0,this.address,this.publicKey,this.parentFingerprint,this.chainCode,this.path,this.index,this.depth,$)}get extendedKey(){return f(this.depth<256,"Depth too deep","UNSUPPORTED_OPERATION",{operation:"extendedKey"}),KQ(l(["0x0488B21E",z9(this.depth,1),this.parentFingerprint,z9(this.index,4),this.chainCode,this.publicKey]))}hasPath(){return this.path!=null}deriveChild($){const Q=q0($,"index");V(Q<=4294967295,"invalid index","index",Q);let J=this.path;if(J){if(J+="/"+(Q&~T8),Q&T8)J+="'"}const{IR:Y,IL:X}=PY(Q,this.chainCode,this.publicKey,null),Z=Y0.addPoints(X,this.publicKey,!0),M=X8(Z);return new $$(p0,M,Z,this.fingerprint,N(Y),J,Q,this.depth+1,this.provider)}derivePath($){return SY(this,$)}}function O9($){try{if(JSON.parse($).encseed)return!0}catch(Q){}return!1}function D9($,Q){const J=JSON.parse($),Y=v8(Q),X=m(Q0(J,"ethaddr:string!")),Z=OQ(Q0(J,"encseed:string!"));V(Z&&Z.length%16===0,"invalid encseed","json",$);const M=C(E0(Y,Y,2000,32,"sha256")).slice(0,16),q=Z.slice(0,16),U=Z.slice(16),G=new R$(M,q),W=zQ(C(G.decrypt(U)));let O="";for(let D=0;D<W.length;D++)O+=String.fromCharCode(W[D]);return{address:X,privateKey:Z8(O)}}var wY=function($){return new Promise((Q)=>{setTimeout(()=>{Q()},$)})};class _0 extends b8{constructor($,Q){if(typeof $==="string"&&!$.startsWith("0x"))$="0x"+$;let J=typeof $==="string"?new Y0($):$;super(J,Q)}connect($){return new _0(this.signingKey,$)}async encrypt($,Q){const J={address:this.address,privateKey:this.privateKey};return await j$(J,$,{progressCallback:Q})}encryptSync($){const Q={address:this.address,privateKey:this.privateKey};return L$(Q,$)}static#$($){if(V($,"invalid JSON wallet","json","[ REDACTED ]"),("mnemonic"in $)&&$.mnemonic&&$.mnemonic.locale==="en"){const J=q8.fromEntropy($.mnemonic.entropy),Y=j0.fromMnemonic(J,$.mnemonic.path);if(Y.address===$.address&&Y.privateKey===$.privateKey)return Y;console.log("WARNING: JSON mismatch address/privateKey != mnemonic; fallback onto private key")}const Q=new _0($.privateKey);return V(Q.address===$.address,"address/privateKey mismatch","json","[ REDACTED ]"),Q}static async fromEncryptedJson($,Q,J){let Y=null;if(W9($))Y=await IQ($,Q,J);else if(O9($)){if(J)J(0),await wY(0);if(Y=D9($,Q),J)J(1),await wY(0)}return _0.#$(Y)}static fromEncryptedJsonSync($,Q){let J=null;if(W9($))J=DQ($,Q);else if(O9($))J=D9($,Q);else V(!1,"invalid JSON wallet","json","[ REDACTED ]");return _0.#$(J)}static createRandom($){const Q=j0.createRandom();if($)return Q.connect($);return Q}static fromPhrase($,Q){const J=j0.fromPhrase($);if(Q)return J.connect(Q);return J}}function AY($,Q,J,Y=[]){let X=$;const Z=Q,M=J,q=(Y||[]).map((K)=>{try{return m(K)}catch(R){return console.warn(`\u26A0\uFE0F SM: Invalid superadmin address skipped: ${H$(K)}`),null}}).filter(Boolean);let U=null,G=X&&typeof X.getAddress==="function"?W():Promise.resolve();async function W(){if(X)U=m(await X.getAddress())}async function O(K){X=K,U=null,G=K&&typeof K.getAddress==="function"?W():Promise.resolve(),await G}async function D(){return G}function E(K){const R=(j)=>j&&typeof j==="object"&&!Array.isArray(j)?Object.keys(j).sort().reduce((w,B)=>(w[B]=R(j[B]),w),{}):Array.isArray(j)?j.map(R):j;return JSON.stringify(R(K))}function z(K){if(!K?.signature||!K?.originEthAddress||!K?.originUser)return{ok:!1,reason:"missing-fields"};let R;try{if(R=m(K.originEthAddress),m(K.originUser)!==R)return{ok:!1,reason:"address-mismatch"}}catch{return{ok:!1,reason:"invalid-address"}}const{signature:j,originEthAddress:w,...B}=K,F=E(B);try{const _=Q9(W0(F),j);if(m(_)!==R)return{ok:!1,reason:"invalid-signature"};const{originUser:v,...o}=B;return{ok:!0,normalizedOriginEthAddress:R,payload:o}}catch(_){return{ok:!1,reason:"verify-error",error:_}}}async function I(K){if(await D(),!X||!U)return console.warn("\u26A0\uFE0F SM: Cannot sign outgoing operations; no active signer session."),[];const R=U,j=[];for(let w of K){if(w?.signature&&w?.originEthAddress&&w?.originUser){j.push(w);continue}const B={...w,originUser:R},F=E(B);try{const _=await X.signMessage(W0(F));j.push({...w,originUser:R,originEthAddress:R,signature:_})}catch(_){console.error(`\u274C SM: Failed to sign operation for ${H$(R)}:`,_.message)}}return j}async function T(K){const R=[];for(let w of K){let B,F;if(w.type==="sync"){R.push(w);continue}if(w.type==="fullStateSync"){if(w.signature&&w.originEthAddress&&w.originUser){const A=z(w);if(!A.ok){console.warn("\u26A0\uFE0F SM: fullStateSync inv\xE1lido:",A.reason);continue}R.push(A.payload)}else R.push(w);continue}if(w.type==="deltaSync"){if(w.signature&&w.originEthAddress&&w.originUser){const A=z(w);if(!A.ok){console.warn("\u26A0\uFE0F SM: deltaSync inv\xE1lido:",A.reason);continue}R.push(A.payload)}else R.push(w);continue}{const A=z(w);if(!A.ok){console.warn("\u26A0\uFE0F SM: Operaci\xF3n firmada inv\xE1lida:",A.reason);continue}B=A.normalizedOriginEthAddress,F=A.payload}let _;if(q.includes(B))_="superadmin";else _=(await Z.get(`user:${B}`)).result?.value?.role||"guest";const v=F.type,o=M.mapChangeTypeToAction(v,F);if(v==="upsert"&&F.id===`user:${B}`){if(!(await Z.get(F.id)).result){const b=U&&U===B,c={...F,value:{ethAddress:B,role:"guest"},timestamp:F.timestamp||Z.hybridClock.now()};R.push(c);continue}else if(_!=="superadmin"&&F.value?.role&&F.value.role!==_)F.value.role=_}const{role:u,ethAddress:H}=F.value??{};if(u==="superadmin"&&!q.includes(m(H??""))){console.warn(`\u26A0\uFE0F SM: [POLICY] ${H$(B)} tried to assign superadmin to ${H$(H)}. Blocked.`);continue}if(M.can(_,o))R.push(F);else console.warn(`\u26A0\uFE0F SM: ${H$(B)} (role: ${_}) DENIED ${o}`,F)}return{validatedOperations:R}}async function L(K){if(await D(),!X)throw new Error("\uD83D\uDEE1\uFE0F SM Encrypt: User session (signer) required for encryption.");try{const R=await k("ssm-encrypt-for-current-user-v1"),j=Z.encode(K),w=Z.pako.deflate(j),B=Z0(12),F=await crypto.subtle.encrypt({name:"AES-GCM",iv:B},R,w);return JSON.stringify({iv:N(B),encrypted:N(new Uint8Array(F)),type:"aes-gcm-self-ssm-v2"})}catch(R){throw console.error("\uD83D\uDEE1\uFE0F SM: Error in encryptDataForCurrentUser:",R),new Error("\uD83D\uDEE1\uFE0F SM: Failed to encrypt personal data.")}}async function S(K){if(await D(),!X)throw new Error("\uD83D\uDEE1\uFE0F SM Decrypt: User session (signer) required for decryption.");let R;try{R=JSON.parse(K)}catch{throw new Error("\uD83D\uDEE1\uFE0F SM Decrypt: encryptedString is not valid JSON.")}if(R.type!=="aes-gcm-self-ssm-v2")throw new Error("\uD83D\uDEE1\uFE0F SM Decrypt: Unsupported encryption type or incorrect version.");if(!R.iv||!R.encrypted)throw new Error("\uD83D\uDEE1\uFE0F SM Decrypt: Invalid encrypted data format.");try{const j=C(R.iv),w=C(R.encrypted),B=await k("ssm-encrypt-for-current-user-v1"),F=await crypto.subtle.decrypt({name:"AES-GCM",iv:j},B,w),_=Z.pako.inflate(new Uint8Array(F));return Z.decode(_)}catch(j){throw console.error("\uD83D\uDEE1\uFE0F SM: Error in decryptDataForCurrentUser:",j),new Error("\uD83D\uDEE1\uFE0F SM: Failed to decrypt personal data.")}}async function k(K="ssm-default-aes-salt"){const R=C(X.privateKey),j=W0(K),w=await crypto.subtle.importKey("raw",R,{name:"PBKDF2"},!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:j,iterations:1e5,hash:"SHA-256"},w,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}return{get localUserEthAddress(){return U},updateSigner:O,signOutgoingOperations:I,verifyIncomingOperations:T,encryptDataForCurrentUser:L,decryptDataForCurrentUser:S}}var H$=($)=>`${$.slice(0,6)}...${$.slice(-4)}`;var Q$=function($){if(!($ instanceof ArrayBuffer))if($.buffer&&$.buffer instanceof ArrayBuffer)$=$.buffer.slice($.byteOffset,$.byteOffset+$.byteLength);else throw console.error("\u274C SM: arrayBufferToBase64Url input is not ArrayBuffer nor TypedArray with .buffer",$),new Error("arrayBufferToBase64Url: ArrayBuffer or TypedArray required.");return btoa(String.fromCharCode(...new Uint8Array($))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},J$=function($){let Q=$.replace(/-/g,"+").replace(/_/g,"/");const J=atob(Q),Y=new ArrayBuffer(J.length),X=new Uint8Array(Y);for(let Z=0;Z<J.length;Z++)X[Z]=J.charCodeAt(Z);return Y};function BY(){let $=null,Q=null,J=null,Y=null,X=null;async function Z(){const P=_0.createRandom();return J=P.mnemonic.phrase,console.log("\uD83D\uDEE1\uFE0F SM: New Ethereum identity generated (mnemonic and private key in memory)."),{address:await P.getAddress(),mnemonic:J,privateKey:P.privateKey}}async function M(P,K){const R=Z0(12),j=C(P),w=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:R},K,j);return JSON.stringify({iv:Q$(R.buffer.slice(R.byteOffset,R.byteOffset+R.byteLength)),ciphertext:Q$(w)})}async function q(P,K){const{iv:R,ciphertext:j}=JSON.parse(P),w=J$(R),B=J$(j),F=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(w)},K,B);return N(new Uint8Array(F))}async function U(P,K){const R=await window.crypto.subtle.importKey("raw",K,{name:"PBKDF2"},!1,["deriveKey"]);return window.crypto.subtle.deriveKey({name:"PBKDF2",salt:P,iterations:200000,hash:"SHA-256"},R,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}async function G(P,K){const R=localStorage.getItem(I9);if(!R)return console.warn("\u26A0\uFE0F SM (_loadAndDecrypt): No encrypted Ethereum material found."),I(),null;try{const j=await U(P,K),w=await q(R,j),B=new _0(w);return $=B,Q=await B.getAddress(),J=null,Y=P,X=K,console.log(`\u2705 SM (_loadAndDecrypt): Session established for ${N5(Q)}`),Q}catch(j){return console.error("\u274C SM (_loadAndDecrypt): Error (decryption/wallet loading):",j),I(),null}}async function W(P){if(!window.navigator.credentials||!window.navigator.credentials.create)return console.error("\u274C SM: WebAuthn is not supported by this browser."),alert("WebAuthn is not supported by this browser."),!1;const K=Z0(32),R=K.buffer.slice(K.byteOffset,K.byteOffset+K.byteLength);try{const j=Y0.computePublicKey(P,!1),w=C(j),B=C(d(w)),_=B.buffer.slice(B.byteOffset,B.byteOffset+Math.min(B.length,64)),o=new _0(P).address.slice(0,10),u={challenge:R,rp:{name:"GDB WebAuthn App",id:window.location.hostname},user:{id:_,name:`user-${o}`,displayName:"GDB User"},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{authenticatorAttachment:"platform",userVerification:"preferred",residentKey:"preferred",requireResidentKey:!1},timeout:60000,attestation:"none"},H=await window.navigator.credentials.create({publicKey:u});if(!H||!H.rawId||!H.id)throw new Error("\u274C WebAuthn registration failed or was canceled (no credential).");const A=H.rawId,b=await U(A,R),g=await M(P,b);return localStorage.setItem(I9,g),localStorage.setItem(N$,JSON.stringify({credentialIdBase64Url:Q$(A),originalChallengeBase64Url:Q$(R)})),console.log("\uD83D\uDEE1\uFE0F SM: WebAuthn registered and Ethereum key encrypted and saved."),await G(A,R)}catch(j){return console.error("\u274C SM: Error during WebAuthn registration:",j),I(),localStorage.removeItem(I9),localStorage.removeItem(N$),alert(`\u274C WebAuthn registration error: ${j.message||"Unknown. Check console."}`),!1}}async function O(){if(!window.navigator.credentials||!window.navigator.credentials.get)return console.error("\u274C SM: WebAuthn is not supported."),alert("WebAuthn is not supported by this browser."),null;const P=localStorage.getItem(N$);if(!P)return console.warn("\u26A0\uFE0F SM: No WebAuthn registration details saved."),null;let K;try{K=JSON.parse(P)}catch(F){return console.error("\u274C SM: Error parsing WebAuthn registration details from localStorage:",F),null}if(!K.credentialIdBase64Url||!K.originalChallengeBase64Url)return console.error("\u274C SM: WebAuthn registration details in localStorage are incomplete."),null;const R=J$(K.credentialIdBase64Url),j=J$(K.originalChallengeBase64Url),w=Z0(32),B=w.buffer.slice(w.byteOffset,w.byteOffset+w.byteLength);try{const F={challenge:B,allowCredentials:[{type:"public-key",id:R}],userVerification:"preferred",timeout:60000},_=await window.navigator.credentials.get({publicKey:F});if(!_||!_.rawId||!_.response||!_.response.authenticatorData||!_.response.signature||!_.response.clientDataJSON)throw new Error("\u274C WebAuthn authentication failed or was canceled (incomplete assertion).");if(Q$(_.rawId)!==K.credentialIdBase64Url)throw new Error("\u274C WebAuthn credential ID in assertion does not match stored ID.");const v=JSON.parse((new TextDecoder()).decode(_.response.clientDataJSON));if(v.challenge!==Q$(B))throw new Error("\u274C WebAuthn assertion challenge mismatch.");if(v.origin!==`https://${window.location.hostname}`&&v.origin!==`http://${window.location.hostname}`){let o=window.location.protocol+"//";if(v.origin.startsWith(o+window.location.hostname));else if(window.location.hostname==="localhost"&&v.origin.startsWith(o+"localhost"));else console.warn("\u26A0\uFE0F SM: WebAuthn assertion origin mismatch. Expected based on hostname:",window.location.hostname,"Got:",v.origin)}return console.log("\uD83D\uDEE1\uFE0F SM: Interactive WebAuthn assertion received and validated."),await G(_.rawId,j)}catch(F){return console.error("\u274C SM: Error during interactive WebAuthn login:",F),I(),null}}async function D(){console.log("\uD83D\uDEE1\uFE0F SM: Attempting silent WebAuthn login...");const P=localStorage.getItem(N$);if(!P)return console.warn("\u26A0\uFE0F SM Silent Login: No WebAuthn registration details."),null;let K;try{K=JSON.parse(P)}catch(R){return console.error("\u274C SM Silent Login: Error parsing registration details:",R),null}if(!K.credentialIdBase64Url||!K.originalChallengeBase64Url)return console.error("\u274C SM Silent Login: Incomplete WebAuthn registration details."),null;try{const R=J$(K.credentialIdBase64Url),j=J$(K.originalChallengeBase64Url),w=await G(R,j);if(w)return console.log(`\u2705 SM Silent Login: Success for ${w}.`),w;else return console.warn("\u26A0\uFE0F SM Silent Login: _loadAndDecryptWalletFromWebAuthnMaterial failed."),null}catch(R){return console.error("\u274C SM Silent Login: Error during silent login attempt:",R),I(),null}}async function E(P){try{const K=_0.fromPhrase(P);return $=K,Q=await K.getAddress(),J=P,Y=null,X=null,{address:Q,privateKey:K.privateKey,mnemonic:J}}catch(K){return console.error("\u274C SM: Error loading wallet from mnemonic:",K),I(),null}}function z(){return localStorage.getItem(N$)!==null&&localStorage.getItem(I9)!==null}function I(){$=null,Q=null,J=null,Y=null,X=null}function T(){return $}function L(){return Q}function S(){if(J&&(!Y||!X))return J;return null}function k(){return!!($&&Y&&X)}return{createNewEthereumIdentity:Z,registerAndProtectWithWebAuthn:W,loginWithWebAuthn:O,trySilentWebAuthnLogin:D,loadWalletFromMnemonic:E,hasWebAuthnRegistration:z,logout:I,getSigner:T,getAddress:L,getMnemonicForDisplay:S,isSessionWebAuthnProtected:k}}var I9="gdb_ethereum_material_encrypted_webauthn_v2",N$="gdb_webauthn_registration_details_v2",N5=($)=>`${$.slice(0,6)}...${$.slice(-4)}`;var C5=function($){if(typeof $!=="object"||$===null||Array.isArray($))throw new Error("\uD83D\uDEE1\uFE0F SM: Custom roles must be a valid object.");RQ=$,console.log("\uD83D\uDEE1\uFE0F SM: Custom roles set.")},TQ=function($,Q,J=new Set){const Y=RQ;if(!$||!Y[$])return!1;if(J.has($))return console.warn(`\u26A0\uFE0F SM: Inheritance loop detected involving role '${$}'.`),!1;if(J.add($),Y[$].can&&Y[$].can.includes(Q))return J.delete($),!0;if(Y[$].inherits&&Array.isArray(Y[$].inherits)){if(Y[$].inherits.some((X)=>TQ(X,Q,new Set(J))))return J.delete($),!0}return J.delete($),!1},E5=function($,Q={}){if($==="upsert")return"write";if($==="remove")return"delete";if($==="link")return"link";if($==="sync"||$==="syncReceive"||$==="deltaSync")return"sync";return console.warn(`\u26A0\uFE0F SM mapChangeTypeToAction: Unknown change type '${$}'.`),"unknown"};function I4($){if(typeof $==="function")R9=$,N0();else if($===null)R9=null;else console.warn("\u26A0\uFE0F SM: Attempted to set invalid state change callback.")}function K4($){if(typeof $==="function")T9=$,N0();else if($===null)T9=null;else console.warn("\u26A0\uFE0F SM: Attempted to set invalid governance state change callback.")}var N0=function(){if(R9)R9({isActive:T0,activeAddress:$0?.localUserEthAddress||t.getAddress(),abbrAddr:L8($0?.localUserEthAddress||t.getAddress()||"N/A"),isWebAuthnProtected:m0,hasVolatileIdentity:!!H0,hasWebAuthnHardwareRegistration:t.hasWebAuthnRegistration()});if(T9)T9({isActive:T0,activeAddress:$0?.localUserEthAddress||t.getAddress()})};async function R4(){if(T0)await j9();t.logout(),H0=null,m0=!1,localStorage.removeItem(d0);try{const $=await t.createNewEthereumIdentity();if($)H0=$;return N0(),$}catch($){throw H0=null,N0(),$}}async function T4($){const Q=$||H0?.privateKey;if(!Q)return alert("\uD83D\uDEE1\uFE0F SM Error: No volatile ETH identity to protect."),null;if(T0&&m0&&$0?.signer)return $0.localUserEthAddress;if(T0)await j9();t.logout();const J=await t.registerAndProtectWithWebAuthn(Q);if(J&&t.getSigner()){if(H0=null,m0=!0,localStorage.setItem(d0,"true"),n)await L9(t.getSigner(),{method:"WebAuthn"});else console.warn("\u26A0\uFE0F SM: Identity protected, but GDB not configured. Global SM signing not active.");return J}else return m0=!1,localStorage.removeItem(d0),N0(),null}async function L4(){if(T0)await j9();t.logout(),H0=null;const $=await t.loginWithWebAuthn();if($&&t.getSigner()){if(m0=!0,localStorage.setItem(d0,"true"),n)await L9(t.getSigner(),{method:"silent WebAuthn"});else console.warn("\u26A0\uFE0F SM: WebAuthn login OK, but GDB not configured for full security activation.");return $}else return m0=!1,localStorage.removeItem(d0),N0(),null}async function j4($){if(T0)await j9();t.logout(),H0=null;const Q=await t.loadWalletFromMnemonic($);if(Q&&Q.address&&t.getSigner()){if(H0=Q,m0=!1,localStorage.removeItem(d0),n)await L9(t.getSigner(),{method:"mnemonic"});else console.warn("\u26A0\uFE0F SM: Mnemonic loaded, but GDB not configured for full security activation.");return H0}else return N0(),null}async function P5($,Q={}){if(!$){console.error("\u274C SM: GDB instance is required.");return}if(n=$,K9=((Q.superAdmins??[])||[]).map((Y)=>{try{return m(Y)}catch(X){return console.warn(`\u26A0\uFE0F SM: Invalid superadmin address skipped: ${L8(Y)}`),null}}).filter(Boolean),$0=AY(null,n,{can:TQ,mapChangeTypeToAction:E5},K9),!FY)n.use(async function Y(X){const{validatedOperations:Z}=await $0.verifyIncomingOperations(X);return Z||[]}),FY=!0;else console.info("\uD83D\uDEE1\uFE0F SM: Security middleware already registered. Skipping duplicate registration.");if(console.info("\uD83D\uDEE1\uFE0F SM: Security context established and middleware registered."),localStorage.getItem(d0)==="true"&&t.hasWebAuthnRegistration()){console.info("\uD83D\uDEE1\uFE0F SM: Previous WebAuthn session detected. Attempting silent login...");try{const Y=await t.trySilentWebAuthnLogin();if(Y&&t.getSigner())m0=!0,await L9(t.getSigner()),console.info(`\uD83D\uDEE1\uFE0F SM: Silent WebAuthn login successful for ${L8(Y)}.`);else console.warn("\u26A0\uFE0F SM: Silent WebAuthn login failed or no signer obtained. Manual login required."),localStorage.removeItem(d0),N0()}catch(Y){console.error("\u274C SM: Error during silent WebAuthn login attempt:",Y),localStorage.removeItem(d0),N0()}}else N0();if(Q.customRoles)C5(Q.customRoles);if(Q.acls){console.info("\uD83D\uDEE1\uFE0F SM: ACLS options activated.");try{(await import(new URL("./sm-acls.min.js",import.meta.url).href)).start(n,Q)}catch(Y){console.error("\u274C SM: Failed to load or start the ACLS module.",Y)}}if(Q.governanceRules)try{(await import(new URL("./sm-gov.min.js",import.meta.url).href)).start(n,Q)}catch(Y){console.error("\u274C SM: Failed to load or start the governance module.",Y)}}async function j9(){if(n&&n.syncChannel&&n.syncChannel._originalSendBySM)n.syncChannel.send=n.syncChannel._originalSendBySM,delete n.syncChannel._originalSendBySM;if(t.logout(),$0)try{await $0.updateSigner(null)}catch($){console.error("\u274C SM: Error during signer deactivation in clearSecurity:",$)}H0=null,m0=!1,localStorage.removeItem(d0),T0=!1,N0(),console.info("\uD83D\uDEE1\uFE0F SM: Session closed. Now in anonymous verification mode.")}async function H4($,Q){const J=Q??(typeof crypto!=="undefined"&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`),Y=`SM_ID_PREFIX_${J}`;if(!n)throw new Error("\u274C SM.put: Not initialized");if(!LQ())throw new Error("\u274C SM.put: Session not active");const{result:X}=await S5(J);if(X&&X.decrypted===!1)throw new Error(`\u274C SM.put: Cannot overwrite encrypted data on node ID '${Q}' owned by another user. DENIED.`);const Z=$0;let M,q;try{const G=await Z.encryptDataForCurrentUser($),W=JSON.parse(G);M=W.encrypted,q={owner:Z.localUserEthAddress,encType:W.type,iv:W.iv}}catch(G){throw console.error(`\u274C SM.put: Encryption failed for ID ${Q||"(new)"}: ${G.message}`),G}const U={_gdbWrapperType:fY,_payload:M,_meta:q};return console.info(`\uD83D\uDEE1\uFE0F SM (put): Storing wrapped secure payload for ID: ${Q||"(new)"}`),await n.put(U,Y),J}async function S5($,Q=null){if(!$)throw new Error("\u274C SM.get: id is required");let J=`SM_ID_PREFIX_${$}`;if(!n)throw new Error("\u274C SM.get: Not initialized");const Y=$0,X=async(U)=>{if(!U)return null;let G=U.value,W=!1;if(G&&G._gdbWrapperType===fY){const O=G,D=O._payload,E=O._meta;if(G=typeof D==="string"?D:O,E&&E.owner&&Y&&Y.localUserEthAddress&&E.owner===Y.localUserEthAddress)try{const z=JSON.stringify({iv:E.iv,encrypted:D,type:E.encType});G=await Y.decryptDataForCurrentUser(z),W=!0}catch(z){console.error(`\u274C SM.get: Decryption failed for node ${U.id}. User: ${Y.localUserEthAddress}, Owner: ${E.owner}. Error: ${z.message}`)}else if(E&&E.owner)console.warn(`\u26A0\uFE0F SM.get: Decryption not attempted for node ${U.id}. Owner: ${E.owner}. Session active: ${!!(Y&&Y.signer)}`);else console.warn(`\u26A0\uFE0F SM.get: Secure payload wrapper for node ${U.id} lacks sufficient metadata for decryption.`)}return{id:$,value:G,edges:U.edges||[],timestamp:U.timestamp,decrypted:W}};if(!Q){const U=await n.get(J,null);return{result:await X(U?U.result:null)}}let Z=null;const M=await n.get(J,null);if(Z=await X(M?M.result:null),typeof Q==="function")Q(Z);const{unsubscribe:q}=await n.get(J,async(U)=>{const G=await X(U),W=G&&Z&&n.hybridClock?.compare(G.timestamp,Z.timestamp)>0,O=JSON.stringify(G?G.value:null)!==JSON.stringify(Z?Z.value:null);if(!G&&Z){if(Z=null,typeof Q==="function")Q(null)}else if(G&&(!Z||W||O)){if(Z=G,typeof Q==="function")Q(G)}});return{result:Z,unsubscribe:()=>{if(q)q()}}}var kY=function(){if(!T0||!$0?.localUserEthAddress)throw new Error("\u274C SM Operation: Security not active or no local user ETH identified in SecurityManager.");return $0.localUserEthAddress};async function N4($,Q,J=null){if(!$||!Q)throw new Error("\u274C SM assignRole: targetUserEthAddress, and role are required.");let Y;try{Y=m($)}catch(G){throw new Error(`\u274C SM assignRole: targetUserEthAddress '${L8($)}' is invalid.`)}if(!RQ[Q])throw new Error(`\u274C SM assignRole: Role '${Q}' is not a defined role.`);const X=kY(),Z=`user:${Y}`,q=(await n.get(Z)).result?.value||{},U={...q,ethAddress:Y,role:Q,assignedByEthAddress:X,expiresAt:J?new Date(J).toISOString():null,priority:!0};await n.put(U,Z),console.info(`\uD83D\uDEE1\uFE0F SM: PROMOTING \x1B[32m ${L8(Y)} \x1B[0m from \x1B[32m '${q.role}' \x1B[0m to \x1B[32m ${Q} \x1B[0m by \x1B[32m ${L8(X)} \x1B[0m written.`)}async function w5(){if(!T0||!$0?.localUserEthAddress)return!1;return K9.includes($0.localUserEthAddress)}async function A5($,Q="unknown"){let J;try{J=m($)}catch(Z){throw new Error(`\u274C SM: Invalid ETH address '${L8($)}' when verifying role for op '${Q}'.`)}const Y=await n.get(`user:${J}`);if(!Y.result?.value?.role)throw console.warn(`\u26A0\uFE0F SM verifyUserRoleLocal: Node/role not found for ETH ${J}. Op: ${Q}. Data:`,Y.result?.value),new Error(`\u274C SM: Role not found for ETH ${J} (operation: ${Q}).`);const X=Y.result.value;if(X.expiresAt&&new Date(X.expiresAt)<new Date)throw new Error(`\u274C SM: Role for ETH ${J} has expired.`);return X.role}async function B5($,Q){const J=await A5($,Q);if(!TQ(J,Q))throw new Error(`\u274C SM: ETH User ${$} (role ${J}) does not have permission for '${Q}'.`)}async function C4($){if(!$)throw new Error("\u274C SM executeWithPermission: operationName is required.");const Q=kY();if(!($==="assignRole"&&await w5()))await B5(Q,$);return Q}function E4(){return T0?$0?.localUserEthAddress:null}function LQ(){return T0}function P4(){return T0&&m0}function S4(){return t.hasWebAuthnRegistration()}function w4(){if(H0&&H0.mnemonic&&!t.isSessionWebAuthnProtected())return H0.mnemonic;return t.getMnemonicForDisplay()}async function A4($){if(!LQ()||!$0)throw new Error("\u274C SM Encryption: Local signing security not active or SecurityManager not available.");return await $0.encryptDataForCurrentUser($)}async function B4($){if(!LQ()||!$0)throw new Error("\u274C SM Decryption: Local signing security not active or SecurityManager not available.");return await $0.decryptDataForCurrentUser($)}async function F4($,Q,J={}){n=$;const Y={...Q};return $.sm=Y,Object.hasOwn(J,"superAdmins")&&await P5($,J),Object.freeze(Y),{sm:Y}}var L8=($)=>`${$.slice(0,6)}...${$.slice(-4)}`,RQ={superadmin:{can:["assignRole","deleteAny"],inherits:["admin"]},admin:{can:["delete"],inherits:["manager"]},manager:{can:["publish"],inherits:["user"]},user:{can:["write","link","sync"],inherits:["guest"]},guest:{can:["read","sync"]}},d0="gdb_sm_last_session_was_webauthn",n=null,$0=null,t=BY(),K9=[],T0=!1,FY=!1,H0=null,m0=!1,R9=null,T9=null,L9=async($,Q={})=>{if(!n||!$0||!$)return console.error("\u274C SM: GDB, SSM, or signer missing."),T0=!1,N0(),!1;try{await $0.updateSigner($)}catch(q){return console.error("\u274C SM: updateSigner failed:",q),T0=!1,N0(),!1}const{localUserEthAddress:J}=$0,{syncChannel:Y}=n??{};if(Y?.send&&!Y._originalSendBySM)Y._originalSendBySM=Y.send.bind(Y),Y.send=async(q)=>Y._originalSendBySM(await $0.signOutgoingOperations(q));const X=`user:${J}`;let Z={role:"unknown",status:"Existing user."};try{const{result:q}=await n.get(X);if(!q)Z.role=K9.includes(J)?"superadmin":"guest",Z.status="New user.",await n.put({ethAddress:J,role:Z.role},X);else Z.role=q.value.role||"unknown";Y?.send?.([{type:"sync",timestamp:null}])}catch(q){console.error(`\u274C SM: User node check failed for ${J}: ${q}`)}T0=!0,N0();const M=Q.method?` via ${Q.method}`:"";return console.info(`\uD83D\uDEE1\uFE0F\uD83D\uDD12 SM: ACTIVE for \x1B[32m${L8(J)} (${Z.role})\x1B[0m${M}. ${Z.status}`),!0},fY="_gdbSecurePayloadV1";export{R4 as startNewUserRegistration,I4 as setSecurityStateChangeCallback,K4 as setGovernanceStateChangeCallback,H4 as put,T4 as protectCurrentIdentityWithWebAuthn,j4 as loginOrRecoverUserWithMnemonic,L4 as loginCurrentUserWithWebAuthn,LQ as isSecurityActive,P4 as isCurrentSessionProtectedByWebAuthn,F4 as init,S4 as hasExistingWebAuthnRegistration,w4 as getMnemonicForDisplayAfterRegistrationOrRecovery,E4 as getActiveEthAddress,S5 as get,C4 as executeWithPermission,A4 as encryptDataForCurrentUser,B4 as decryptDataForCurrentUser,j9 as clearSecurity,N4 as assignRole,L8 as abbrAddr};