@aboutcircles/sdk-utils 0.1.12 → 0.1.13
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/config.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -19,7 +19,7 @@ export const circlesConfig = {
|
|
|
19
19
|
baseGroupFactoryAddress: "0xD0B5Bd9962197BEaC4cbA24244ec3587f19Bd06d",
|
|
20
20
|
liftERC20Address: "0x5F99a795dD2743C36D63511f0D4bc667e6d3cDB5",
|
|
21
21
|
invitationFarmAddress: "0x0000000000000000000000000000000000000000",
|
|
22
|
-
referralsModuleAddress: "
|
|
22
|
+
referralsModuleAddress: "0x12105a9B291aF2ABb0591001155A75949b062CE5",
|
|
23
23
|
invitationModuleAddress: "0x00738aca013B7B2e6cfE1690F0021C3182Fa40B5"
|
|
24
24
|
}
|
|
25
25
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class d${static ONE_64=1n<<64n;static GAMMA_64=18443079296116538654n;static BETA_64=18450409579521241655n;static SECONDS_PER_DAY=86400n;static INFLATION_DAY_ZERO_UNIX=1602720000n;static ATTO_FACTOR=1000000000000000000n;static FACTOR_1E12=1000000000000n;static V1_ACCURACY=100000000n;static V1_INFLATION_PCT_NUM=107n;static V1_INFLATION_PCT_DEN=100n;static PERIOD_SEC=31556952n;static mul64(J,Q){return J*Q>>64n}static mulU(J,Q){return J*Q>>64n}static pow64(J,Q){let $=J,q=Q,Y=this.ONE_64;while(q>0n){if((q&1n)===1n)Y=this.mul64(Y,$);$=this.mul64($,$),q>>=1n}return Y}static ONE_36=1000000000000000000000000000000000000000n;static GAMMA_36=999801332008598957430613406568191166n;static BETA_36=1000198707468214629156271489013303962n;static mul36(J,Q){return J*Q/this.ONE_36}static pow36(J,Q){let $=this.ONE_36,q=J,Y=Q;while(Y>0n){if((Y&1n)===1n)$=this.mul36($,q);q=this.mul36(q,q),Y>>=1n}return $}static attoCirclesToCircles(J){if(J===0n)return 0;let Q=J/this.ATTO_FACTOR,$=J%this.ATTO_FACTOR,q=BigInt(Number.MAX_SAFE_INTEGER);if(Q>q||Q<-q)throw RangeError("Atto value’s integer component exceeds JS double precision.");return Number(Q)+Number($)/Number(this.ATTO_FACTOR)}static circlesToAttoCircles(J){return BigInt(Math.trunc(J*Number(this.ATTO_FACTOR)))}static inflationaryToDemurrage(J,Q){return this.mulU(this.pow64(this.GAMMA_64,Q),J)}static demurrageToInflationary(J,Q){return this.mulU(this.pow64(this.BETA_64,Q),J)}static dayFromTimestamp(J){return(J-this.INFLATION_DAY_ZERO_UNIX)/this.SECONDS_PER_DAY}static attoCirclesToAttoStaticCircles(J,Q=BigInt(Math.floor(Date.now()/1000))){return this.demurrageToInflationary(J,this.dayFromTimestamp(Q))}static attoStaticCirclesToAttoCircles(J,Q=BigInt(Math.floor(Date.now()/1000))){return this.inflationaryToDemurrage(J,this.dayFromTimestamp(Q))}static inflationaryToDemurrageExact(J,Q){let $=this.pow36(this.GAMMA_36,Q);return J*$/this.ONE_36}static demurrageToInflationaryExact(J,Q){let $=this.pow36(this.BETA_36,Q);return J*$/this.ONE_36}static attoCirclesToAttoStaticCirclesExact(J,Q=BigInt(Math.floor(Date.now()/1000))){let $=this.dayFromTimestamp(Q);return this.demurrageToInflationaryExact(J,$)}static attoStaticCirclesToAttoCirclesExact(J,Q=BigInt(Math.floor(Date.now()/1000))){let $=this.dayFromTimestamp(Q);return this.inflationaryToDemurrageExact(J,$)}static truncateToInt64(J){let Q=J/this.FACTOR_1E12,$=9223372036854775807n;return Q>$?$:Q}static blowUpToBigInt(J){return J*this.FACTOR_1E12}static truncateToSixDecimals(J){return this.blowUpToBigInt(this.truncateToInt64(J))}static v1InflateFactor(J){if(J===0n)return this.V1_ACCURACY;return this.V1_ACCURACY*this.V1_INFLATION_PCT_NUM**J/this.V1_INFLATION_PCT_DEN**J}static attoCrcToAttoCircles(J,Q){let $=Q-this.INFLATION_DAY_ZERO_UNIX,q=$/this.PERIOD_SEC,Y=$%this.PERIOD_SEC,G=this.v1InflateFactor(q),Z=this.v1InflateFactor(q+1n);return this.v1ToDemurrage(J,G,Z,Y,this.PERIOD_SEC)}static attoCirclesToAttoCrc(J,Q){let $=Q-this.INFLATION_DAY_ZERO_UNIX,q=$/this.PERIOD_SEC,Y=$%this.PERIOD_SEC,G=this.v1InflateFactor(q),Z=this.v1InflateFactor(q+1n),X=G*(this.PERIOD_SEC-Y)+Z*Y;return J*3n*this.V1_ACCURACY*this.PERIOD_SEC/X}static v1ToDemurrage(J,Q,$,q,Y){let G=Q*(Y-q)+$*q;return J*3n*this.V1_ACCURACY*Y/G}}var c$=[];for(let J=0;J<256;J++)c$[J]=J.toString(16).padStart(2,"0");function bJ(J){let Q="0x";for(let $=0;$<J.length;$++)Q+=c$[J[$]];return Q}function Y8(J){let Q=J.startsWith("0x")?J.slice(2):J,$=new Uint8Array(Q.length/2);for(let q=0;q<Q.length;q+=2)$[q/2]=parseInt(Q.slice(q,q+2),16);return $}var sJ=BigInt(4294967295),p$=BigInt(32);function G8(J,Q=!1){if(Q)return{h:Number(J&sJ),l:Number(J>>p$&sJ)};return{h:Number(J>>p$&sJ)|0,l:Number(J&sJ)|0}}function i$(J,Q=!1){let $=J.length,q=new Uint32Array($),Y=new Uint32Array($);for(let G=0;G<$;G++){let{h:Z,l:X}=G8(J[G],Q);[q[G],Y[G]]=[Z,X]}return[q,Y]}var n$=(J,Q,$)=>J<<$|Q>>>32-$,o$=(J,Q,$)=>Q<<$|J>>>32-$,r$=(J,Q,$)=>Q<<$-32|J>>>64-$,a$=(J,Q,$)=>J<<$-32|Q>>>64-$;var zJ=typeof globalThis==="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Z8(J){return J instanceof Uint8Array||ArrayBuffer.isView(J)&&J.constructor.name==="Uint8Array"}function OJ(J){if(!Number.isSafeInteger(J)||J<0)throw Error("positive integer expected, got "+J)}function t(J,...Q){if(!Z8(J))throw Error("Uint8Array expected");if(Q.length>0&&!Q.includes(J.length))throw Error("Uint8Array expected of length "+Q+", got length="+J.length)}function s$(J){if(typeof J!=="function"||typeof J.create!=="function")throw Error("Hash should be wrapped by utils.createHasher");OJ(J.outputLen),OJ(J.blockLen)}function qJ(J,Q=!0){if(J.destroyed)throw Error("Hash instance has been destroyed");if(Q&&J.finished)throw Error("Hash#digest() has already been called")}function tJ(J,Q){t(J);let $=Q.outputLen;if(J.length<$)throw Error("digestInto() expects output buffer of length at least "+$)}function t$(J){return new Uint32Array(J.buffer,J.byteOffset,Math.floor(J.byteLength/4))}function e(...J){for(let Q=0;Q<J.length;Q++)J[Q].fill(0)}function eJ(J){return new DataView(J.buffer,J.byteOffset,J.byteLength)}function r(J,Q){return J<<32-Q|J>>>Q}var K8=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function X8(J){return J<<24&4278190080|J<<8&16711680|J>>>8&65280|J>>>24&255}function M8(J){for(let Q=0;Q<J.length;Q++)J[Q]=X8(J[Q]);return J}var j$=K8?(J)=>J:M8;function U8(J){if(typeof J!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode(J))}function VJ(J){if(typeof J==="string")J=U8(J);return t(J),J}function e$(...J){let Q=0;for(let q=0;q<J.length;q++){let Y=J[q];t(Y),Q+=Y.length}let $=new Uint8Array(Q);for(let q=0,Y=0;q<J.length;q++){let G=J[q];$.set(G,Y),Y+=G.length}return $}class TJ{}function J$(J){let Q=(q)=>J().update(VJ(q)).digest(),$=J();return Q.outputLen=$.outputLen,Q.blockLen=$.blockLen,Q.create=()=>J(),Q}function J0(J=32){if(zJ&&typeof zJ.getRandomValues==="function")return zJ.getRandomValues(new Uint8Array(J));if(zJ&&typeof zJ.randomBytes==="function")return Uint8Array.from(zJ.randomBytes(J));throw Error("crypto.getRandomValues must be defined")}var j8=BigInt(0),mJ=BigInt(1),N8=BigInt(2),W8=BigInt(7),z8=BigInt(256),O8=BigInt(113),q0=[],Y0=[],G0=[];for(let J=0,Q=mJ,$=1,q=0;J<24;J++){[$,q]=[q,(2*$+3*q)%5],q0.push(2*(5*q+$)),Y0.push((J+1)*(J+2)/2%64);let Y=j8;for(let G=0;G<7;G++)if(Q=(Q<<mJ^(Q>>W8)*O8)%z8,Q&N8)Y^=mJ<<(mJ<<BigInt(G))-mJ;G0.push(Y)}var Z0=i$(G0,!0),V8=Z0[0],T8=Z0[1],$0=(J,Q,$)=>$>32?r$(J,Q,$):n$(J,Q,$),Q0=(J,Q,$)=>$>32?a$(J,Q,$):o$(J,Q,$);function D8(J,Q=24){let $=new Uint32Array(10);for(let q=24-Q;q<24;q++){for(let Z=0;Z<10;Z++)$[Z]=J[Z]^J[Z+10]^J[Z+20]^J[Z+30]^J[Z+40];for(let Z=0;Z<10;Z+=2){let X=(Z+8)%10,K=(Z+2)%10,M=$[K],U=$[K+1],O=$0(M,U,1)^$[X],I=Q0(M,U,1)^$[X+1];for(let w=0;w<50;w+=10)J[Z+w]^=O,J[Z+w+1]^=I}let Y=J[2],G=J[3];for(let Z=0;Z<24;Z++){let X=Y0[Z],K=$0(Y,G,X),M=Q0(Y,G,X),U=q0[Z];Y=J[U],G=J[U+1],J[U]=K,J[U+1]=M}for(let Z=0;Z<50;Z+=10){for(let X=0;X<10;X++)$[X]=J[Z+X];for(let X=0;X<10;X++)J[Z+X]^=~$[(X+2)%10]&$[(X+4)%10]}J[0]^=V8[q],J[1]^=T8[q]}e($)}class N$ extends TJ{constructor(J,Q,$,q=!1,Y=24){super();if(this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=J,this.suffix=Q,this.outputLen=$,this.enableXOF=q,this.rounds=Y,OJ($),!(0<J&&J<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=t$(this.state)}clone(){return this._cloneInto()}keccak(){j$(this.state32),D8(this.state32,this.rounds),j$(this.state32),this.posOut=0,this.pos=0}update(J){qJ(this),J=VJ(J),t(J);let{blockLen:Q,state:$}=this,q=J.length;for(let Y=0;Y<q;){let G=Math.min(Q-this.pos,q-Y);for(let Z=0;Z<G;Z++)$[this.pos++]^=J[Y++];if(this.pos===Q)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:J,suffix:Q,pos:$,blockLen:q}=this;if(J[$]^=Q,(Q&128)!==0&&$===q-1)this.keccak();J[q-1]^=128,this.keccak()}writeInto(J){qJ(this,!1),t(J),this.finish();let Q=this.state,{blockLen:$}=this;for(let q=0,Y=J.length;q<Y;){if(this.posOut>=$)this.keccak();let G=Math.min($-this.posOut,Y-q);J.set(Q.subarray(this.posOut,this.posOut+G),q),this.posOut+=G,q+=G}return J}xofInto(J){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(J)}xof(J){return OJ(J),this.xofInto(new Uint8Array(J))}digestInto(J){if(tJ(J,this),this.finished)throw Error("digest() was already called");return this.writeInto(J),this.destroy(),J}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,e(this.state)}_cloneInto(J){let{blockLen:Q,suffix:$,outputLen:q,rounds:Y,enableXOF:G}=this;return J||(J=new N$(Q,$,q,G,Y)),J.state32.set(this.state32),J.pos=this.pos,J.posOut=this.posOut,J.finished=this.finished,J.rounds=Y,J.suffix=$,J.outputLen=q,J.enableXOF=G,J.destroyed=this.destroyed,J}}var I8=(J,Q,$)=>J$(()=>new N$(Q,J,$));var DJ=(()=>I8(1,136,32))();var g=64,Q$=32,hJ=(J)=>J.startsWith("0x")?J.slice(2):J;var JJ=(J)=>J.toString(16).padStart(g,"0");function q$(J){let Q=J.toLowerCase().replace("0x",""),$=bJ(DJ(new TextEncoder().encode(Q))).slice(2),q="0x";for(let Y=0;Y<Q.length;Y++)q+=parseInt($[Y],16)>=8?Q[Y].toUpperCase():Q[Y];return q}function $$(J,Q){if(J==="tuple"&&Q)return`(${Q.map((Y)=>$$(Y.type,Y.components)).join(",")})`;let $=J.match(/^tuple(\[\d*\])$/);if($&&Q)return`${$$("tuple",Q)}${$[1]}`;return J}function R8(J){let $=(J.inputs||[]).map((q)=>$$(q.type,q.components));return`${J.name}(${$.join(",")})`}function w8(J){let Q=R8(J),$=DJ(new TextEncoder().encode(Q));return bJ($.slice(0,4))}function AJ(J,Q){if(J==="string"||J==="bytes")return!0;if(J.includes("[")){let $=J.slice(0,J.indexOf("["));if(J.endsWith("[]"))return!0;if($==="tuple")return K0(Q);return AJ($)}if(J==="tuple")return K0(Q);return!1}function K0(J){return J?.some((Q)=>AJ(Q.type,Q.components))??!1}function UJ(J,Q,$){if(J==="tuple"&&$)return k8($,Q);if(J.includes("["))return L8(J,Q,$);return P8(J,Q)}function L8(J,Q,$){let q=J.slice(0,J.indexOf("[")),Y=J.endsWith("[]"),G=AJ(q,$),Z;if(G){let X=Q.map((U)=>UJ(q,U,$)),K=Q.length*Q$;Z=X.map((U)=>{let O=K;return K+=U.length/2,JJ(O)}).join("")+X.join("")}else Z=Q.map((X)=>UJ(q,X,$)).join("");return Y?JJ(Q.length)+Z:Z}function k8(J,Q){let $=Array.isArray(Q),q=[],Y=[],G=[];for(let Z=0;Z<J.length;Z++){let X=J[Z],K=$?Q[Z]:Q[X.name||""],M=AJ(X.type,X.components);if(G.push(M),M)q.push(""),Y.push(UJ(X.type,K,X.components));else q.push(UJ(X.type,K,X.components))}if(Y.length>0){let Z=q.reduce((M,U,O)=>M+(G[O]?Q$:U.length/2),0),X="",K=0;for(let M=0;M<J.length;M++)if(G[M])X+=JJ(Z),Z+=Y[K].length/2,K++;else X+=q[M];return X+Y.join("")}return q.join("")}function P8(J,Q){if(J==="address")return hJ(Q).toLowerCase().padStart(g,"0");if(J==="bool")return JJ(Q?1:0);if(J.startsWith("uint")){let $=typeof Q==="bigint"?Q:BigInt(Q);return JJ($)}if(J.startsWith("int")){let $=typeof Q==="bigint"?Q:BigInt(Q);if($<0n){let q=J==="int"?256:parseInt(J.slice(3));$=(1n<<BigInt(q))+$}return JJ($)}if(J.startsWith("bytes")&&J!=="bytes")return hJ(Q).padEnd(g,"0");if(J==="bytes"){let $=hJ(Q),q=JJ($.length/2),Y=$.padEnd(Math.ceil($.length/g)*g,"0");return q+Y}if(J==="string"){let $=Array.from(new TextEncoder().encode(Q)).map((G)=>G.toString(16).padStart(2,"0")).join(""),q=JJ($.length/2),Y=$.padEnd(Math.ceil($.length/g)*g,"0");return q+Y}throw Error(`Unsupported type: ${J}`)}function BJ(J,Q,$=0,q){if(J==="tuple"&&q)return B8(q,Q,$);if(J.includes("["))return C8(J,Q,$,q);return A8(J,Q,$)}function C8(J,Q,$,q){let Y=J.slice(0,J.indexOf("[")),G=Q.slice($,$+g);if(J.endsWith("[]")){let X=parseInt(G,16)*2,K=parseInt(Q.slice(X,X+g),16),M=[],U=X+g;for(let O=0;O<K;O++){let I=BJ(Y,Q,U,q);M.push(I.value),U+=I.consumed}return{value:M,consumed:g}}let Z=J.match(/\[(\d+)\]$/);if(Z){let X=parseInt(Z[1]),K=[],M=0;for(let U=0;U<X;U++){let O=BJ(Y,Q,$+M,q);K.push(O.value),M+=O.consumed}return{value:K,consumed:M}}throw Error(`Invalid array type: ${J}`)}function B8(J,Q,$){let q=[],Y=$;for(let G of J){let Z=BJ(G.type,Q,Y,G.components);q.push(Z.value),Y+=Z.consumed}return{value:q,consumed:Y-$}}function A8(J,Q,$){let q=Q.slice($,$+g);if(J==="address")return{value:q$("0x"+q.slice(24)),consumed:g};if(J==="bool")return{value:parseInt(q,16)!==0,consumed:g};if(J.startsWith("uint"))return{value:BigInt("0x"+q),consumed:g};if(J.startsWith("int")){let Y=BigInt("0x"+q),G=J==="int"?256:parseInt(J.slice(3)),Z=1n<<BigInt(G-1);return{value:Y>=Z?Y-(1n<<BigInt(G)):Y,consumed:g}}if(J.startsWith("bytes")&&J!=="bytes"){let Y=parseInt(J.match(/^bytes(\d+)$/)[1]);return{value:"0x"+q.slice(0,Y*2),consumed:g}}if(J==="bytes"){let Y=parseInt(q,16)*2,G=parseInt(Q.slice(Y,Y+g),16)*2;return{value:"0x"+Q.slice(Y+g,Y+g+G),consumed:g}}if(J==="string"){let Y=parseInt(q,16)*2,G=parseInt(Q.slice(Y,Y+g),16)*2,Z=Q.slice(Y+g,Y+g+G),X=new Uint8Array(Z.match(/.{2}/g)?.map((K)=>parseInt(K,16))||[]);return{value:new TextDecoder().decode(X),consumed:g}}throw Error(`Unsupported type: ${J}`)}function S8(J){let{abi:Q,functionName:$,args:q=[]}=J,Y=Q.find((w)=>w.type==="function"&&w.name===$);if(!Y)throw Error(`Function "${$}" not found in ABI`);let G=w8(Y),Z=Y.inputs||[];if(Z.length===0)return G;if(q.length!==Z.length)throw Error(`Expected ${Z.length} arguments, got ${q.length}`);let X=[],K=[],M=[];for(let w=0;w<Z.length;w++){let T=Z[w],z=T.components,v=AJ(T.type,z);if(M.push(v),v)X.push(""),K.push(UJ(T.type,q[w],z));else X.push(UJ(T.type,q[w],z))}if(K.length===0)return G+X.join("");let U=X.reduce((w,T,z)=>w+(M[z]?Q$:T.length/2),0),O="",I=0;for(let w=0;w<Z.length;w++)if(M[w])O+=JJ(U),U+=K[I].length/2,I++;else O+=X[w];return G+O+K.join("")}function H8(J){let{abi:Q,functionName:$,data:q}=J,Y=Q.find((M)=>M.type==="function"&&M.name===$);if(!Y)throw Error(`Function "${$}" not found in ABI`);let G=Y.outputs||[];if(G.length===0)return;let Z=hJ(q);if(G.length===1)return BJ(G[0].type,Z,0,G[0].components).value;let X=[],K=0;for(let M of G){let U=BJ(M.type,Z,K,M.components);X.push(U.value),K+=U.consumed}return X}function E8(J){let $=(J.inputs||[]).map((G)=>$$(G.type,G.components)),q=`${J.name}(${$.join(",")})`,Y=DJ(new TextEncoder().encode(q));return bJ(Y.slice(0,4))}function W$(J){let{abi:Q,data:$}=J;if(!$||$.length<10)return null;let q=$.slice(0,10).toLowerCase(),Y=hJ($.slice(10)),G=Q.filter((Z)=>Z.type==="error");for(let Z of G)if(E8(Z).toLowerCase()===q){let K=Z.inputs||[];if(K.length===0)return{errorName:Z.name};let M=[],U=0;for(let O of K){let I=BJ(O.type,Y,U,O.components);M.push(I.value),U+=I.consumed}return{errorName:Z.name,args:M}}return null}function x8(J,Q){if(J.length!==Q.length)throw Error(`Type/value length mismatch: ${J.length} types, ${Q.length} values`);let $=[],q=[],Y=[];for(let K=0;K<J.length;K++){let M=J[K],U=AJ(M);if(Y.push(U),U)$.push(""),q.push(UJ(M,Q[K]));else $.push(UJ(M,Q[K]))}if(q.length===0)return"0x"+$.join("");let G=$.reduce((K,M,U)=>K+(Y[U]?Q$:M.length/2),0),Z="",X=0;for(let K=0;K<J.length;K++)if(Y[K])Z+=JJ(G),G+=q[X].length/2,X++;else Z+=$[K];return"0x"+Z+q.join("")}var Gq=new Uint8Array(0);function X0(J,Q){if(J===Q)return!0;if(J.byteLength!==Q.byteLength)return!1;for(let $=0;$<J.byteLength;$++)if(J[$]!==Q[$])return!1;return!0}function SJ(J){if(J instanceof Uint8Array&&J.constructor.name==="Uint8Array")return J;if(J instanceof ArrayBuffer)return new Uint8Array(J);if(ArrayBuffer.isView(J))return new Uint8Array(J.buffer,J.byteOffset,J.byteLength);throw Error("Unknown type, must be binary type")}function _8(J,Q){if(J.length>=255)throw TypeError("Alphabet too long");var $=new Uint8Array(256);for(var q=0;q<$.length;q++)$[q]=255;for(var Y=0;Y<J.length;Y++){var G=J.charAt(Y),Z=G.charCodeAt(0);if($[Z]!==255)throw TypeError(G+" is ambiguous");$[Z]=Y}var X=J.length,K=J.charAt(0),M=Math.log(X)/Math.log(256),U=Math.log(256)/Math.log(X);function O(T){if(T instanceof Uint8Array);else if(ArrayBuffer.isView(T))T=new Uint8Array(T.buffer,T.byteOffset,T.byteLength);else if(Array.isArray(T))T=Uint8Array.from(T);if(!(T instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(T.length===0)return"";var z=0,v=0,x=0,f=T.length;while(x!==f&&T[x]===0)x++,z++;var j=(f-x)*U+1>>>0,W=new Uint8Array(j);while(x!==f){var D=T[x],R=0;for(var L=j-1;(D!==0||R<v)&&L!==-1;L--,R++)D+=256*W[L]>>>0,W[L]=D%X>>>0,D=D/X>>>0;if(D!==0)throw Error("Non-zero carry");v=R,x++}var C=j-v;while(C!==j&&W[C]===0)C++;var H=K.repeat(z);for(;C<j;++C)H+=J.charAt(W[C]);return H}function I(T){if(typeof T!=="string")throw TypeError("Expected String");if(T.length===0)return new Uint8Array;var z=0;if(T[z]===" ")return;var v=0,x=0;while(T[z]===K)v++,z++;var f=(T.length-z)*M+1>>>0,j=new Uint8Array(f);while(T[z]){var W=$[T.charCodeAt(z)];if(W===255)return;var D=0;for(var R=f-1;(W!==0||D<x)&&R!==-1;R--,D++)W+=X*j[R]>>>0,j[R]=W%256>>>0,W=W/256>>>0;if(W!==0)throw Error("Non-zero carry");x=D,z++}if(T[z]===" ")return;var L=f-x;while(L!==f&&j[L]===0)L++;var C=new Uint8Array(v+(f-L)),H=v;while(L!==f)C[H++]=j[L++];return C}function w(T){var z=I(T);if(z)return z;throw Error(`Non-${Q} character`)}return{encode:O,decodeUnsafe:I,decode:w}}var v8=_8,g8=v8,M0=g8;class U0{name;prefix;baseEncode;constructor(J,Q,$){this.name=J,this.prefix=Q,this.baseEncode=$}encode(J){if(J instanceof Uint8Array)return`${this.prefix}${this.baseEncode(J)}`;else throw Error("Unknown type, must be binary type")}}class j0{name;prefix;baseDecode;prefixCodePoint;constructor(J,Q,$){this.name=J,this.prefix=Q;let q=Q.codePointAt(0);if(q===void 0)throw Error("Invalid prefix character");this.prefixCodePoint=q,this.baseDecode=$}decode(J){if(typeof J==="string"){if(J.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(J)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(J.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(J){return W0(this,J)}}class N0{decoders;constructor(J){this.decoders=J}or(J){return W0(this,J)}decode(J){let Q=J[0],$=this.decoders[Q];if($!=null)return $.decode(J);else throw RangeError(`Unable to decode multibase string ${JSON.stringify(J)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function W0(J,Q){return new N0({...J.decoders??{[J.prefix]:J},...Q.decoders??{[Q.prefix]:Q}})}class z0{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(J,Q,$,q){this.name=J,this.prefix=Q,this.baseEncode=$,this.baseDecode=q,this.encoder=new U0(J,Q,$),this.decoder=new j0(J,Q,q)}encode(J){return this.encoder.encode(J)}decode(J){return this.decoder.decode(J)}}function O0({name:J,prefix:Q,encode:$,decode:q}){return new z0(J,Q,$,q)}function HJ({name:J,prefix:Q,alphabet:$}){let{encode:q,decode:Y}=M0($,J);return O0({prefix:Q,name:J,encode:q,decode:(G)=>SJ(Y(G))})}function F8(J,Q,$,q){let Y=J.length;while(J[Y-1]==="=")--Y;let G=new Uint8Array(Y*$/8|0),Z=0,X=0,K=0;for(let M=0;M<Y;++M){let U=Q[J[M]];if(U===void 0)throw SyntaxError(`Non-${q} character`);if(X=X<<$|U,Z+=$,Z>=8)Z-=8,G[K++]=255&X>>Z}if(Z>=$||(255&X<<8-Z)!==0)throw SyntaxError("Unexpected end of data");return G}function f8(J,Q,$){let q=Q[Q.length-1]==="=",Y=(1<<$)-1,G="",Z=0,X=0;for(let K=0;K<J.length;++K){X=X<<8|J[K],Z+=8;while(Z>$)Z-=$,G+=Q[Y&X>>Z]}if(Z!==0)G+=Q[Y&X<<$-Z];if(q)while((G.length*$&7)!==0)G+="=";return G}function y8(J){let Q={};for(let $=0;$<J.length;++$)Q[J[$]]=$;return Q}function $J({name:J,prefix:Q,bitsPerChar:$,alphabet:q}){let Y=y8(q);return O0({prefix:Q,name:J,encode(G){return f8(G,q,$)},decode(G){return F8(G,Y,$,J)}})}var uJ=$J({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Nq=$J({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Wq=$J({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),zq=$J({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Oq=$J({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vq=$J({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Tq=$J({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Dq=$J({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Iq=$J({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Y$=HJ({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Lq=HJ({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var o=HJ({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cq=HJ({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var b8=D0,V0=128,m8=127,h8=~m8,u8=Math.pow(2,31);function D0(J,Q,$){Q=Q||[],$=$||0;var q=$;while(J>=u8)Q[$++]=J&255|V0,J/=128;while(J&h8)Q[$++]=J&255|V0,J>>>=7;return Q[$]=J|0,D0.bytes=$-q+1,Q}var l8=z$,d8=128,T0=127;function z$(J,q){var $=0,q=q||0,Y=0,G=q,Z,X=J.length;do{if(G>=X)throw z$.bytes=0,RangeError("Could not decode varint");Z=J[G++],$+=Y<28?(Z&T0)<<Y:(Z&T0)*Math.pow(2,Y),Y+=7}while(Z>=d8);return z$.bytes=G-q,$}var c8=Math.pow(2,7),p8=Math.pow(2,14),i8=Math.pow(2,21),n8=Math.pow(2,28),o8=Math.pow(2,35),r8=Math.pow(2,42),a8=Math.pow(2,49),s8=Math.pow(2,56),t8=Math.pow(2,63),e8=function(J){return J<c8?1:J<p8?2:J<i8?3:J<n8?4:J<o8?5:J<r8?6:J<a8?7:J<s8?8:J<t8?9:10},JQ={encode:b8,decode:l8,encodingLength:e8},$Q=JQ,lJ=$Q;function dJ(J,Q=0){return[lJ.decode(J,Q),lJ.decode.bytes]}function EJ(J,Q,$=0){return lJ.encode(J,Q,$),Q}function xJ(J){return lJ.encodingLength(J)}function R0(J,Q){let $=Q.byteLength,q=xJ(J),Y=q+xJ($),G=new Uint8Array(Y+$);return EJ(J,G,0),EJ($,G,q),G.set(Q,Y),new cJ(J,$,Q,G)}function w0(J){let Q=SJ(J),[$,q]=dJ(Q),[Y,G]=dJ(Q.subarray(q)),Z=Q.subarray(q+G);if(Z.byteLength!==Y)throw Error("Incorrect length");return new cJ($,Y,Z,Q)}function L0(J,Q){if(J===Q)return!0;else{let $=Q;return J.code===$.code&&J.size===$.size&&$.bytes instanceof Uint8Array&&X0(J.bytes,$.bytes)}}class cJ{code;size;digest;bytes;constructor(J,Q,$,q){this.code=J,this.size=Q,this.digest=$,this.bytes=q}}function k0(J,Q){let{bytes:$,version:q}=J;switch(q){case 0:return YQ($,O$(J),Q??o.encoder);default:return GQ($,O$(J),Q??uJ.encoder)}}var P0=new WeakMap;function O$(J){let Q=P0.get(J);if(Q==null){let $=new Map;return P0.set(J,$),$}return Q}class y{code;version;multihash;bytes;"/";constructor(J,Q,$,q){this.code=Q,this.version=J,this.multihash=$,this.bytes=q,this["/"]=q}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:J,multihash:Q}=this;if(J!==pJ)throw Error("Cannot convert a non dag-pb CID to CIDv0");if(Q.code!==ZQ)throw Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.createV0(Q)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:J,digest:Q}=this.multihash,$=R0(J,Q);return y.createV1(this.code,$)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(J){return y.equals(this,J)}static equals(J,Q){let $=Q;return $!=null&&J.code===$.code&&J.version===$.version&&L0(J.multihash,$.multihash)}toString(J){return k0(this,J)}toJSON(){return{"/":k0(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(J){if(J==null)return null;let Q=J;if(Q instanceof y)return Q;else if(Q["/"]!=null&&Q["/"]===Q.bytes||Q.asCID===Q){let{version:$,code:q,multihash:Y,bytes:G}=Q;return new y($,q,Y,G??C0($,q,Y.bytes))}else if(Q[KQ]===!0){let{version:$,multihash:q,code:Y}=Q,G=w0(q);return y.create($,Y,G)}else return null}static create(J,Q,$){if(typeof Q!=="number")throw Error("String codecs are no longer supported");if(!($.bytes instanceof Uint8Array))throw Error("Invalid digest");switch(J){case 0:if(Q!==pJ)throw Error(`Version 0 CID must use dag-pb (code: ${pJ}) block encoding`);else return new y(J,Q,$,$.bytes);case 1:{let q=C0(J,Q,$.bytes);return new y(J,Q,$,q)}default:throw Error("Invalid version")}}static createV0(J){return y.create(0,pJ,J)}static createV1(J,Q){return y.create(1,J,Q)}static decode(J){let[Q,$]=y.decodeFirst(J);if($.length!==0)throw Error("Incorrect length");return Q}static decodeFirst(J){let Q=y.inspectBytes(J),$=Q.size-Q.multihashSize,q=SJ(J.subarray($,$+Q.multihashSize));if(q.byteLength!==Q.multihashSize)throw Error("Incorrect length");let Y=q.subarray(Q.multihashSize-Q.digestSize),G=new cJ(Q.multihashCode,Q.digestSize,Y,q);return[Q.version===0?y.createV0(G):y.createV1(Q.codec,G),J.subarray(Q.size)]}static inspectBytes(J){let Q=0,$=()=>{let[U,O]=dJ(J.subarray(Q));return Q+=O,U},q=$(),Y=pJ;if(q===18)q=0,Q=0;else Y=$();if(q!==0&&q!==1)throw RangeError(`Invalid CID version ${q}`);let G=Q,Z=$(),X=$(),K=Q+X,M=K-G;return{version:q,codec:Y,multihashCode:Z,digestSize:X,multihashSize:M,size:K}}static parse(J,Q){let[$,q]=qQ(J,Q),Y=y.decode(q);if(Y.version===0&&J[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return O$(Y).set($,J),Y}}function qQ(J,Q){switch(J[0]){case"Q":{let $=Q??o;return[o.prefix,$.decode(`${o.prefix}${J}`)]}case o.prefix:{let $=Q??o;return[o.prefix,$.decode(J)]}case uJ.prefix:{let $=Q??uJ;return[uJ.prefix,$.decode(J)]}case Y$.prefix:{let $=Q??Y$;return[Y$.prefix,$.decode(J)]}default:{if(Q==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[J[0],Q.decode(J)]}}}function YQ(J,Q,$){let{prefix:q}=$;if(q!==o.prefix)throw Error(`Cannot string encode V0 in ${$.name} encoding`);let Y=Q.get(q);if(Y==null){let G=$.encode(J).slice(1);return Q.set(q,G),G}else return Y}function GQ(J,Q,$){let{prefix:q}=$,Y=Q.get(q);if(Y==null){let G=$.encode(J);return Q.set(q,G),G}else return Y}var pJ=112,ZQ=18;function C0(J,Q,$){let q=xJ(J),Y=q+xJ(Q),G=new Uint8Array(Y+$.byteLength);return EJ(J,G,0),EJ(Q,G,q),G.set($,Y),G}var KQ=Symbol.for("@ipld/js-cid/CID");function XQ(J){let Q=y.parse(J,o);if(Q.version!==0)throw Error(`Expected CIDv0, got CIDv${Q.version}`);if(Q.multihash.code!==18)throw Error("Unsupported hash algorithm. Only SHA-256 is supported for CIDv0.");let $=Q.multihash.digest;return`0x${Array.from($).map((Y)=>Y.toString(16).padStart(2,"0")).join("")}`}function MQ(J){let Q=y.parse(J,o);if(Q.version!==0)throw Error(`Expected CIDv0, got CIDv${Q.version}`);if(Q.multihash.code!==18)throw Error("Unsupported hash algorithm. Only SHA-256 is supported for CIDv0.");return Q.multihash.digest}function UQ(J){return`0x${J.toString(16).padStart(64,"0").slice(-40)}`}var jQ="0x0000000000000000000000000000000000000000",NQ=BigInt(96)*BigInt(1000000000000000000),WQ=BigInt("9999999999999999999999999999999999999"),zQ="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",OQ="0x440ea2f93c9703f7d456d48796f7bc25b8721582535a492ce0a09df32146242a",VQ="0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee";var TQ={100:{circlesRpcUrl:"https://rpc.aboutcircles.com/",pathfinderUrl:"https://pathfinder.aboutcircles.com",profileServiceUrl:"https://rpc.aboutcircles.com/profiles/",referralsServiceUrl:"https://staging.circlesubi.network/referrals",v1HubAddress:"0x29b9a7fbb8995b2423a71cc17cf9810798f6c543",v2HubAddress:"0xc12C1E50ABB450d6205Ea2C3Fa861b3B834d13e8",nameRegistryAddress:"0xA27566fD89162cC3D40Cb59c87AAaA49B85F3474",baseGroupMintPolicy:"0xcCa27c26CF7BAC2a9928f42201d48220F0e3a549",standardTreasury:"0x08F90aB73A515308f03A718257ff9887ED330C6e",coreMembersGroupDeployer:"0xFEca40Eb02FB1f4F5F795fC7a03c1A27819B1Ded",baseGroupFactoryAddress:"0xD0B5Bd9962197BEaC4cbA24244ec3587f19Bd06d",liftERC20Address:"0x5F99a795dD2743C36D63511f0D4bc667e6d3cDB5",invitationFarmAddress:"0x0000000000000000000000000000000000000000",referralsModuleAddress:"0xd6dF7cc2C2DB03ec91761f4469D8dBAac7e538C9",invitationModuleAddress:"0x00738aca013B7B2e6cfE1690F0021C3182Fa40B5"}};class QJ extends Error{name;code;source;cause;context;constructor(J,Q,$){super(Q);if(this.name=J,this.code=$?.code,this.source=$?.source??"UNKNOWN",this.cause=$?.cause,this.context=$?.context,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,source:this.source,context:this.context,cause:this.cause instanceof Error?{name:this.cause.name,message:this.cause.message}:this.cause,stack:this.stack}}toString(){let J=`[${this.source}] ${this.name}: ${this.message}`;if(this.code)J+=` (Code: ${this.code})`;if(this.context)J+=`
|
|
1
|
+
class d${static ONE_64=1n<<64n;static GAMMA_64=18443079296116538654n;static BETA_64=18450409579521241655n;static SECONDS_PER_DAY=86400n;static INFLATION_DAY_ZERO_UNIX=1602720000n;static ATTO_FACTOR=1000000000000000000n;static FACTOR_1E12=1000000000000n;static V1_ACCURACY=100000000n;static V1_INFLATION_PCT_NUM=107n;static V1_INFLATION_PCT_DEN=100n;static PERIOD_SEC=31556952n;static mul64(J,Q){return J*Q>>64n}static mulU(J,Q){return J*Q>>64n}static pow64(J,Q){let $=J,q=Q,Y=this.ONE_64;while(q>0n){if((q&1n)===1n)Y=this.mul64(Y,$);$=this.mul64($,$),q>>=1n}return Y}static ONE_36=1000000000000000000000000000000000000000n;static GAMMA_36=999801332008598957430613406568191166n;static BETA_36=1000198707468214629156271489013303962n;static mul36(J,Q){return J*Q/this.ONE_36}static pow36(J,Q){let $=this.ONE_36,q=J,Y=Q;while(Y>0n){if((Y&1n)===1n)$=this.mul36($,q);q=this.mul36(q,q),Y>>=1n}return $}static attoCirclesToCircles(J){if(J===0n)return 0;let Q=J/this.ATTO_FACTOR,$=J%this.ATTO_FACTOR,q=BigInt(Number.MAX_SAFE_INTEGER);if(Q>q||Q<-q)throw RangeError("Atto value’s integer component exceeds JS double precision.");return Number(Q)+Number($)/Number(this.ATTO_FACTOR)}static circlesToAttoCircles(J){return BigInt(Math.trunc(J*Number(this.ATTO_FACTOR)))}static inflationaryToDemurrage(J,Q){return this.mulU(this.pow64(this.GAMMA_64,Q),J)}static demurrageToInflationary(J,Q){return this.mulU(this.pow64(this.BETA_64,Q),J)}static dayFromTimestamp(J){return(J-this.INFLATION_DAY_ZERO_UNIX)/this.SECONDS_PER_DAY}static attoCirclesToAttoStaticCircles(J,Q=BigInt(Math.floor(Date.now()/1000))){return this.demurrageToInflationary(J,this.dayFromTimestamp(Q))}static attoStaticCirclesToAttoCircles(J,Q=BigInt(Math.floor(Date.now()/1000))){return this.inflationaryToDemurrage(J,this.dayFromTimestamp(Q))}static inflationaryToDemurrageExact(J,Q){let $=this.pow36(this.GAMMA_36,Q);return J*$/this.ONE_36}static demurrageToInflationaryExact(J,Q){let $=this.pow36(this.BETA_36,Q);return J*$/this.ONE_36}static attoCirclesToAttoStaticCirclesExact(J,Q=BigInt(Math.floor(Date.now()/1000))){let $=this.dayFromTimestamp(Q);return this.demurrageToInflationaryExact(J,$)}static attoStaticCirclesToAttoCirclesExact(J,Q=BigInt(Math.floor(Date.now()/1000))){let $=this.dayFromTimestamp(Q);return this.inflationaryToDemurrageExact(J,$)}static truncateToInt64(J){let Q=J/this.FACTOR_1E12,$=9223372036854775807n;return Q>$?$:Q}static blowUpToBigInt(J){return J*this.FACTOR_1E12}static truncateToSixDecimals(J){return this.blowUpToBigInt(this.truncateToInt64(J))}static v1InflateFactor(J){if(J===0n)return this.V1_ACCURACY;return this.V1_ACCURACY*this.V1_INFLATION_PCT_NUM**J/this.V1_INFLATION_PCT_DEN**J}static attoCrcToAttoCircles(J,Q){let $=Q-this.INFLATION_DAY_ZERO_UNIX,q=$/this.PERIOD_SEC,Y=$%this.PERIOD_SEC,G=this.v1InflateFactor(q),Z=this.v1InflateFactor(q+1n);return this.v1ToDemurrage(J,G,Z,Y,this.PERIOD_SEC)}static attoCirclesToAttoCrc(J,Q){let $=Q-this.INFLATION_DAY_ZERO_UNIX,q=$/this.PERIOD_SEC,Y=$%this.PERIOD_SEC,G=this.v1InflateFactor(q),Z=this.v1InflateFactor(q+1n),X=G*(this.PERIOD_SEC-Y)+Z*Y;return J*3n*this.V1_ACCURACY*this.PERIOD_SEC/X}static v1ToDemurrage(J,Q,$,q,Y){let G=Q*(Y-q)+$*q;return J*3n*this.V1_ACCURACY*Y/G}}var c$=[];for(let J=0;J<256;J++)c$[J]=J.toString(16).padStart(2,"0");function bJ(J){let Q="0x";for(let $=0;$<J.length;$++)Q+=c$[J[$]];return Q}function Y8(J){let Q=J.startsWith("0x")?J.slice(2):J,$=new Uint8Array(Q.length/2);for(let q=0;q<Q.length;q+=2)$[q/2]=parseInt(Q.slice(q,q+2),16);return $}var sJ=BigInt(4294967295),p$=BigInt(32);function G8(J,Q=!1){if(Q)return{h:Number(J&sJ),l:Number(J>>p$&sJ)};return{h:Number(J>>p$&sJ)|0,l:Number(J&sJ)|0}}function i$(J,Q=!1){let $=J.length,q=new Uint32Array($),Y=new Uint32Array($);for(let G=0;G<$;G++){let{h:Z,l:X}=G8(J[G],Q);[q[G],Y[G]]=[Z,X]}return[q,Y]}var n$=(J,Q,$)=>J<<$|Q>>>32-$,o$=(J,Q,$)=>Q<<$|J>>>32-$,r$=(J,Q,$)=>Q<<$-32|J>>>64-$,a$=(J,Q,$)=>J<<$-32|Q>>>64-$;var zJ=typeof globalThis==="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Z8(J){return J instanceof Uint8Array||ArrayBuffer.isView(J)&&J.constructor.name==="Uint8Array"}function OJ(J){if(!Number.isSafeInteger(J)||J<0)throw Error("positive integer expected, got "+J)}function t(J,...Q){if(!Z8(J))throw Error("Uint8Array expected");if(Q.length>0&&!Q.includes(J.length))throw Error("Uint8Array expected of length "+Q+", got length="+J.length)}function s$(J){if(typeof J!=="function"||typeof J.create!=="function")throw Error("Hash should be wrapped by utils.createHasher");OJ(J.outputLen),OJ(J.blockLen)}function qJ(J,Q=!0){if(J.destroyed)throw Error("Hash instance has been destroyed");if(Q&&J.finished)throw Error("Hash#digest() has already been called")}function tJ(J,Q){t(J);let $=Q.outputLen;if(J.length<$)throw Error("digestInto() expects output buffer of length at least "+$)}function t$(J){return new Uint32Array(J.buffer,J.byteOffset,Math.floor(J.byteLength/4))}function e(...J){for(let Q=0;Q<J.length;Q++)J[Q].fill(0)}function eJ(J){return new DataView(J.buffer,J.byteOffset,J.byteLength)}function r(J,Q){return J<<32-Q|J>>>Q}var K8=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function X8(J){return J<<24&4278190080|J<<8&16711680|J>>>8&65280|J>>>24&255}function M8(J){for(let Q=0;Q<J.length;Q++)J[Q]=X8(J[Q]);return J}var j$=K8?(J)=>J:M8;function U8(J){if(typeof J!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode(J))}function VJ(J){if(typeof J==="string")J=U8(J);return t(J),J}function e$(...J){let Q=0;for(let q=0;q<J.length;q++){let Y=J[q];t(Y),Q+=Y.length}let $=new Uint8Array(Q);for(let q=0,Y=0;q<J.length;q++){let G=J[q];$.set(G,Y),Y+=G.length}return $}class TJ{}function J$(J){let Q=(q)=>J().update(VJ(q)).digest(),$=J();return Q.outputLen=$.outputLen,Q.blockLen=$.blockLen,Q.create=()=>J(),Q}function J0(J=32){if(zJ&&typeof zJ.getRandomValues==="function")return zJ.getRandomValues(new Uint8Array(J));if(zJ&&typeof zJ.randomBytes==="function")return Uint8Array.from(zJ.randomBytes(J));throw Error("crypto.getRandomValues must be defined")}var j8=BigInt(0),mJ=BigInt(1),N8=BigInt(2),W8=BigInt(7),z8=BigInt(256),O8=BigInt(113),q0=[],Y0=[],G0=[];for(let J=0,Q=mJ,$=1,q=0;J<24;J++){[$,q]=[q,(2*$+3*q)%5],q0.push(2*(5*q+$)),Y0.push((J+1)*(J+2)/2%64);let Y=j8;for(let G=0;G<7;G++)if(Q=(Q<<mJ^(Q>>W8)*O8)%z8,Q&N8)Y^=mJ<<(mJ<<BigInt(G))-mJ;G0.push(Y)}var Z0=i$(G0,!0),V8=Z0[0],T8=Z0[1],$0=(J,Q,$)=>$>32?r$(J,Q,$):n$(J,Q,$),Q0=(J,Q,$)=>$>32?a$(J,Q,$):o$(J,Q,$);function D8(J,Q=24){let $=new Uint32Array(10);for(let q=24-Q;q<24;q++){for(let Z=0;Z<10;Z++)$[Z]=J[Z]^J[Z+10]^J[Z+20]^J[Z+30]^J[Z+40];for(let Z=0;Z<10;Z+=2){let X=(Z+8)%10,K=(Z+2)%10,M=$[K],U=$[K+1],O=$0(M,U,1)^$[X],I=Q0(M,U,1)^$[X+1];for(let w=0;w<50;w+=10)J[Z+w]^=O,J[Z+w+1]^=I}let Y=J[2],G=J[3];for(let Z=0;Z<24;Z++){let X=Y0[Z],K=$0(Y,G,X),M=Q0(Y,G,X),U=q0[Z];Y=J[U],G=J[U+1],J[U]=K,J[U+1]=M}for(let Z=0;Z<50;Z+=10){for(let X=0;X<10;X++)$[X]=J[Z+X];for(let X=0;X<10;X++)J[Z+X]^=~$[(X+2)%10]&$[(X+4)%10]}J[0]^=V8[q],J[1]^=T8[q]}e($)}class N$ extends TJ{constructor(J,Q,$,q=!1,Y=24){super();if(this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=J,this.suffix=Q,this.outputLen=$,this.enableXOF=q,this.rounds=Y,OJ($),!(0<J&&J<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=t$(this.state)}clone(){return this._cloneInto()}keccak(){j$(this.state32),D8(this.state32,this.rounds),j$(this.state32),this.posOut=0,this.pos=0}update(J){qJ(this),J=VJ(J),t(J);let{blockLen:Q,state:$}=this,q=J.length;for(let Y=0;Y<q;){let G=Math.min(Q-this.pos,q-Y);for(let Z=0;Z<G;Z++)$[this.pos++]^=J[Y++];if(this.pos===Q)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:J,suffix:Q,pos:$,blockLen:q}=this;if(J[$]^=Q,(Q&128)!==0&&$===q-1)this.keccak();J[q-1]^=128,this.keccak()}writeInto(J){qJ(this,!1),t(J),this.finish();let Q=this.state,{blockLen:$}=this;for(let q=0,Y=J.length;q<Y;){if(this.posOut>=$)this.keccak();let G=Math.min($-this.posOut,Y-q);J.set(Q.subarray(this.posOut,this.posOut+G),q),this.posOut+=G,q+=G}return J}xofInto(J){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(J)}xof(J){return OJ(J),this.xofInto(new Uint8Array(J))}digestInto(J){if(tJ(J,this),this.finished)throw Error("digest() was already called");return this.writeInto(J),this.destroy(),J}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,e(this.state)}_cloneInto(J){let{blockLen:Q,suffix:$,outputLen:q,rounds:Y,enableXOF:G}=this;return J||(J=new N$(Q,$,q,G,Y)),J.state32.set(this.state32),J.pos=this.pos,J.posOut=this.posOut,J.finished=this.finished,J.rounds=Y,J.suffix=$,J.outputLen=q,J.enableXOF=G,J.destroyed=this.destroyed,J}}var I8=(J,Q,$)=>J$(()=>new N$(Q,J,$));var DJ=(()=>I8(1,136,32))();var g=64,Q$=32,hJ=(J)=>J.startsWith("0x")?J.slice(2):J;var JJ=(J)=>J.toString(16).padStart(g,"0");function q$(J){let Q=J.toLowerCase().replace("0x",""),$=bJ(DJ(new TextEncoder().encode(Q))).slice(2),q="0x";for(let Y=0;Y<Q.length;Y++)q+=parseInt($[Y],16)>=8?Q[Y].toUpperCase():Q[Y];return q}function $$(J,Q){if(J==="tuple"&&Q)return`(${Q.map((Y)=>$$(Y.type,Y.components)).join(",")})`;let $=J.match(/^tuple(\[\d*\])$/);if($&&Q)return`${$$("tuple",Q)}${$[1]}`;return J}function R8(J){let $=(J.inputs||[]).map((q)=>$$(q.type,q.components));return`${J.name}(${$.join(",")})`}function w8(J){let Q=R8(J),$=DJ(new TextEncoder().encode(Q));return bJ($.slice(0,4))}function AJ(J,Q){if(J==="string"||J==="bytes")return!0;if(J.includes("[")){let $=J.slice(0,J.indexOf("["));if(J.endsWith("[]"))return!0;if($==="tuple")return K0(Q);return AJ($)}if(J==="tuple")return K0(Q);return!1}function K0(J){return J?.some((Q)=>AJ(Q.type,Q.components))??!1}function UJ(J,Q,$){if(J==="tuple"&&$)return k8($,Q);if(J.includes("["))return L8(J,Q,$);return P8(J,Q)}function L8(J,Q,$){let q=J.slice(0,J.indexOf("[")),Y=J.endsWith("[]"),G=AJ(q,$),Z;if(G){let X=Q.map((U)=>UJ(q,U,$)),K=Q.length*Q$;Z=X.map((U)=>{let O=K;return K+=U.length/2,JJ(O)}).join("")+X.join("")}else Z=Q.map((X)=>UJ(q,X,$)).join("");return Y?JJ(Q.length)+Z:Z}function k8(J,Q){let $=Array.isArray(Q),q=[],Y=[],G=[];for(let Z=0;Z<J.length;Z++){let X=J[Z],K=$?Q[Z]:Q[X.name||""],M=AJ(X.type,X.components);if(G.push(M),M)q.push(""),Y.push(UJ(X.type,K,X.components));else q.push(UJ(X.type,K,X.components))}if(Y.length>0){let Z=q.reduce((M,U,O)=>M+(G[O]?Q$:U.length/2),0),X="",K=0;for(let M=0;M<J.length;M++)if(G[M])X+=JJ(Z),Z+=Y[K].length/2,K++;else X+=q[M];return X+Y.join("")}return q.join("")}function P8(J,Q){if(J==="address")return hJ(Q).toLowerCase().padStart(g,"0");if(J==="bool")return JJ(Q?1:0);if(J.startsWith("uint")){let $=typeof Q==="bigint"?Q:BigInt(Q);return JJ($)}if(J.startsWith("int")){let $=typeof Q==="bigint"?Q:BigInt(Q);if($<0n){let q=J==="int"?256:parseInt(J.slice(3));$=(1n<<BigInt(q))+$}return JJ($)}if(J.startsWith("bytes")&&J!=="bytes")return hJ(Q).padEnd(g,"0");if(J==="bytes"){let $=hJ(Q),q=JJ($.length/2),Y=$.padEnd(Math.ceil($.length/g)*g,"0");return q+Y}if(J==="string"){let $=Array.from(new TextEncoder().encode(Q)).map((G)=>G.toString(16).padStart(2,"0")).join(""),q=JJ($.length/2),Y=$.padEnd(Math.ceil($.length/g)*g,"0");return q+Y}throw Error(`Unsupported type: ${J}`)}function BJ(J,Q,$=0,q){if(J==="tuple"&&q)return B8(q,Q,$);if(J.includes("["))return C8(J,Q,$,q);return A8(J,Q,$)}function C8(J,Q,$,q){let Y=J.slice(0,J.indexOf("[")),G=Q.slice($,$+g);if(J.endsWith("[]")){let X=parseInt(G,16)*2,K=parseInt(Q.slice(X,X+g),16),M=[],U=X+g;for(let O=0;O<K;O++){let I=BJ(Y,Q,U,q);M.push(I.value),U+=I.consumed}return{value:M,consumed:g}}let Z=J.match(/\[(\d+)\]$/);if(Z){let X=parseInt(Z[1]),K=[],M=0;for(let U=0;U<X;U++){let O=BJ(Y,Q,$+M,q);K.push(O.value),M+=O.consumed}return{value:K,consumed:M}}throw Error(`Invalid array type: ${J}`)}function B8(J,Q,$){let q=[],Y=$;for(let G of J){let Z=BJ(G.type,Q,Y,G.components);q.push(Z.value),Y+=Z.consumed}return{value:q,consumed:Y-$}}function A8(J,Q,$){let q=Q.slice($,$+g);if(J==="address")return{value:q$("0x"+q.slice(24)),consumed:g};if(J==="bool")return{value:parseInt(q,16)!==0,consumed:g};if(J.startsWith("uint"))return{value:BigInt("0x"+q),consumed:g};if(J.startsWith("int")){let Y=BigInt("0x"+q),G=J==="int"?256:parseInt(J.slice(3)),Z=1n<<BigInt(G-1);return{value:Y>=Z?Y-(1n<<BigInt(G)):Y,consumed:g}}if(J.startsWith("bytes")&&J!=="bytes"){let Y=parseInt(J.match(/^bytes(\d+)$/)[1]);return{value:"0x"+q.slice(0,Y*2),consumed:g}}if(J==="bytes"){let Y=parseInt(q,16)*2,G=parseInt(Q.slice(Y,Y+g),16)*2;return{value:"0x"+Q.slice(Y+g,Y+g+G),consumed:g}}if(J==="string"){let Y=parseInt(q,16)*2,G=parseInt(Q.slice(Y,Y+g),16)*2,Z=Q.slice(Y+g,Y+g+G),X=new Uint8Array(Z.match(/.{2}/g)?.map((K)=>parseInt(K,16))||[]);return{value:new TextDecoder().decode(X),consumed:g}}throw Error(`Unsupported type: ${J}`)}function S8(J){let{abi:Q,functionName:$,args:q=[]}=J,Y=Q.find((w)=>w.type==="function"&&w.name===$);if(!Y)throw Error(`Function "${$}" not found in ABI`);let G=w8(Y),Z=Y.inputs||[];if(Z.length===0)return G;if(q.length!==Z.length)throw Error(`Expected ${Z.length} arguments, got ${q.length}`);let X=[],K=[],M=[];for(let w=0;w<Z.length;w++){let T=Z[w],z=T.components,v=AJ(T.type,z);if(M.push(v),v)X.push(""),K.push(UJ(T.type,q[w],z));else X.push(UJ(T.type,q[w],z))}if(K.length===0)return G+X.join("");let U=X.reduce((w,T,z)=>w+(M[z]?Q$:T.length/2),0),O="",I=0;for(let w=0;w<Z.length;w++)if(M[w])O+=JJ(U),U+=K[I].length/2,I++;else O+=X[w];return G+O+K.join("")}function H8(J){let{abi:Q,functionName:$,data:q}=J,Y=Q.find((M)=>M.type==="function"&&M.name===$);if(!Y)throw Error(`Function "${$}" not found in ABI`);let G=Y.outputs||[];if(G.length===0)return;let Z=hJ(q);if(G.length===1)return BJ(G[0].type,Z,0,G[0].components).value;let X=[],K=0;for(let M of G){let U=BJ(M.type,Z,K,M.components);X.push(U.value),K+=U.consumed}return X}function E8(J){let $=(J.inputs||[]).map((G)=>$$(G.type,G.components)),q=`${J.name}(${$.join(",")})`,Y=DJ(new TextEncoder().encode(q));return bJ(Y.slice(0,4))}function W$(J){let{abi:Q,data:$}=J;if(!$||$.length<10)return null;let q=$.slice(0,10).toLowerCase(),Y=hJ($.slice(10)),G=Q.filter((Z)=>Z.type==="error");for(let Z of G)if(E8(Z).toLowerCase()===q){let K=Z.inputs||[];if(K.length===0)return{errorName:Z.name};let M=[],U=0;for(let O of K){let I=BJ(O.type,Y,U,O.components);M.push(I.value),U+=I.consumed}return{errorName:Z.name,args:M}}return null}function x8(J,Q){if(J.length!==Q.length)throw Error(`Type/value length mismatch: ${J.length} types, ${Q.length} values`);let $=[],q=[],Y=[];for(let K=0;K<J.length;K++){let M=J[K],U=AJ(M);if(Y.push(U),U)$.push(""),q.push(UJ(M,Q[K]));else $.push(UJ(M,Q[K]))}if(q.length===0)return"0x"+$.join("");let G=$.reduce((K,M,U)=>K+(Y[U]?Q$:M.length/2),0),Z="",X=0;for(let K=0;K<J.length;K++)if(Y[K])Z+=JJ(G),G+=q[X].length/2,X++;else Z+=$[K];return"0x"+Z+q.join("")}var Gq=new Uint8Array(0);function X0(J,Q){if(J===Q)return!0;if(J.byteLength!==Q.byteLength)return!1;for(let $=0;$<J.byteLength;$++)if(J[$]!==Q[$])return!1;return!0}function SJ(J){if(J instanceof Uint8Array&&J.constructor.name==="Uint8Array")return J;if(J instanceof ArrayBuffer)return new Uint8Array(J);if(ArrayBuffer.isView(J))return new Uint8Array(J.buffer,J.byteOffset,J.byteLength);throw Error("Unknown type, must be binary type")}function _8(J,Q){if(J.length>=255)throw TypeError("Alphabet too long");var $=new Uint8Array(256);for(var q=0;q<$.length;q++)$[q]=255;for(var Y=0;Y<J.length;Y++){var G=J.charAt(Y),Z=G.charCodeAt(0);if($[Z]!==255)throw TypeError(G+" is ambiguous");$[Z]=Y}var X=J.length,K=J.charAt(0),M=Math.log(X)/Math.log(256),U=Math.log(256)/Math.log(X);function O(T){if(T instanceof Uint8Array);else if(ArrayBuffer.isView(T))T=new Uint8Array(T.buffer,T.byteOffset,T.byteLength);else if(Array.isArray(T))T=Uint8Array.from(T);if(!(T instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(T.length===0)return"";var z=0,v=0,x=0,f=T.length;while(x!==f&&T[x]===0)x++,z++;var j=(f-x)*U+1>>>0,W=new Uint8Array(j);while(x!==f){var D=T[x],R=0;for(var L=j-1;(D!==0||R<v)&&L!==-1;L--,R++)D+=256*W[L]>>>0,W[L]=D%X>>>0,D=D/X>>>0;if(D!==0)throw Error("Non-zero carry");v=R,x++}var C=j-v;while(C!==j&&W[C]===0)C++;var H=K.repeat(z);for(;C<j;++C)H+=J.charAt(W[C]);return H}function I(T){if(typeof T!=="string")throw TypeError("Expected String");if(T.length===0)return new Uint8Array;var z=0;if(T[z]===" ")return;var v=0,x=0;while(T[z]===K)v++,z++;var f=(T.length-z)*M+1>>>0,j=new Uint8Array(f);while(T[z]){var W=$[T.charCodeAt(z)];if(W===255)return;var D=0;for(var R=f-1;(W!==0||D<x)&&R!==-1;R--,D++)W+=X*j[R]>>>0,j[R]=W%256>>>0,W=W/256>>>0;if(W!==0)throw Error("Non-zero carry");x=D,z++}if(T[z]===" ")return;var L=f-x;while(L!==f&&j[L]===0)L++;var C=new Uint8Array(v+(f-L)),H=v;while(L!==f)C[H++]=j[L++];return C}function w(T){var z=I(T);if(z)return z;throw Error(`Non-${Q} character`)}return{encode:O,decodeUnsafe:I,decode:w}}var v8=_8,g8=v8,M0=g8;class U0{name;prefix;baseEncode;constructor(J,Q,$){this.name=J,this.prefix=Q,this.baseEncode=$}encode(J){if(J instanceof Uint8Array)return`${this.prefix}${this.baseEncode(J)}`;else throw Error("Unknown type, must be binary type")}}class j0{name;prefix;baseDecode;prefixCodePoint;constructor(J,Q,$){this.name=J,this.prefix=Q;let q=Q.codePointAt(0);if(q===void 0)throw Error("Invalid prefix character");this.prefixCodePoint=q,this.baseDecode=$}decode(J){if(typeof J==="string"){if(J.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(J)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(J.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(J){return W0(this,J)}}class N0{decoders;constructor(J){this.decoders=J}or(J){return W0(this,J)}decode(J){let Q=J[0],$=this.decoders[Q];if($!=null)return $.decode(J);else throw RangeError(`Unable to decode multibase string ${JSON.stringify(J)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function W0(J,Q){return new N0({...J.decoders??{[J.prefix]:J},...Q.decoders??{[Q.prefix]:Q}})}class z0{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(J,Q,$,q){this.name=J,this.prefix=Q,this.baseEncode=$,this.baseDecode=q,this.encoder=new U0(J,Q,$),this.decoder=new j0(J,Q,q)}encode(J){return this.encoder.encode(J)}decode(J){return this.decoder.decode(J)}}function O0({name:J,prefix:Q,encode:$,decode:q}){return new z0(J,Q,$,q)}function HJ({name:J,prefix:Q,alphabet:$}){let{encode:q,decode:Y}=M0($,J);return O0({prefix:Q,name:J,encode:q,decode:(G)=>SJ(Y(G))})}function F8(J,Q,$,q){let Y=J.length;while(J[Y-1]==="=")--Y;let G=new Uint8Array(Y*$/8|0),Z=0,X=0,K=0;for(let M=0;M<Y;++M){let U=Q[J[M]];if(U===void 0)throw SyntaxError(`Non-${q} character`);if(X=X<<$|U,Z+=$,Z>=8)Z-=8,G[K++]=255&X>>Z}if(Z>=$||(255&X<<8-Z)!==0)throw SyntaxError("Unexpected end of data");return G}function f8(J,Q,$){let q=Q[Q.length-1]==="=",Y=(1<<$)-1,G="",Z=0,X=0;for(let K=0;K<J.length;++K){X=X<<8|J[K],Z+=8;while(Z>$)Z-=$,G+=Q[Y&X>>Z]}if(Z!==0)G+=Q[Y&X<<$-Z];if(q)while((G.length*$&7)!==0)G+="=";return G}function y8(J){let Q={};for(let $=0;$<J.length;++$)Q[J[$]]=$;return Q}function $J({name:J,prefix:Q,bitsPerChar:$,alphabet:q}){let Y=y8(q);return O0({prefix:Q,name:J,encode(G){return f8(G,q,$)},decode(G){return F8(G,Y,$,J)}})}var uJ=$J({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Nq=$J({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Wq=$J({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),zq=$J({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Oq=$J({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vq=$J({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Tq=$J({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Dq=$J({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Iq=$J({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Y$=HJ({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Lq=HJ({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var o=HJ({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cq=HJ({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var b8=D0,V0=128,m8=127,h8=~m8,u8=Math.pow(2,31);function D0(J,Q,$){Q=Q||[],$=$||0;var q=$;while(J>=u8)Q[$++]=J&255|V0,J/=128;while(J&h8)Q[$++]=J&255|V0,J>>>=7;return Q[$]=J|0,D0.bytes=$-q+1,Q}var l8=z$,d8=128,T0=127;function z$(J,q){var $=0,q=q||0,Y=0,G=q,Z,X=J.length;do{if(G>=X)throw z$.bytes=0,RangeError("Could not decode varint");Z=J[G++],$+=Y<28?(Z&T0)<<Y:(Z&T0)*Math.pow(2,Y),Y+=7}while(Z>=d8);return z$.bytes=G-q,$}var c8=Math.pow(2,7),p8=Math.pow(2,14),i8=Math.pow(2,21),n8=Math.pow(2,28),o8=Math.pow(2,35),r8=Math.pow(2,42),a8=Math.pow(2,49),s8=Math.pow(2,56),t8=Math.pow(2,63),e8=function(J){return J<c8?1:J<p8?2:J<i8?3:J<n8?4:J<o8?5:J<r8?6:J<a8?7:J<s8?8:J<t8?9:10},JQ={encode:b8,decode:l8,encodingLength:e8},$Q=JQ,lJ=$Q;function dJ(J,Q=0){return[lJ.decode(J,Q),lJ.decode.bytes]}function EJ(J,Q,$=0){return lJ.encode(J,Q,$),Q}function xJ(J){return lJ.encodingLength(J)}function R0(J,Q){let $=Q.byteLength,q=xJ(J),Y=q+xJ($),G=new Uint8Array(Y+$);return EJ(J,G,0),EJ($,G,q),G.set(Q,Y),new cJ(J,$,Q,G)}function w0(J){let Q=SJ(J),[$,q]=dJ(Q),[Y,G]=dJ(Q.subarray(q)),Z=Q.subarray(q+G);if(Z.byteLength!==Y)throw Error("Incorrect length");return new cJ($,Y,Z,Q)}function L0(J,Q){if(J===Q)return!0;else{let $=Q;return J.code===$.code&&J.size===$.size&&$.bytes instanceof Uint8Array&&X0(J.bytes,$.bytes)}}class cJ{code;size;digest;bytes;constructor(J,Q,$,q){this.code=J,this.size=Q,this.digest=$,this.bytes=q}}function k0(J,Q){let{bytes:$,version:q}=J;switch(q){case 0:return YQ($,O$(J),Q??o.encoder);default:return GQ($,O$(J),Q??uJ.encoder)}}var P0=new WeakMap;function O$(J){let Q=P0.get(J);if(Q==null){let $=new Map;return P0.set(J,$),$}return Q}class y{code;version;multihash;bytes;"/";constructor(J,Q,$,q){this.code=Q,this.version=J,this.multihash=$,this.bytes=q,this["/"]=q}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:J,multihash:Q}=this;if(J!==pJ)throw Error("Cannot convert a non dag-pb CID to CIDv0");if(Q.code!==ZQ)throw Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.createV0(Q)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:J,digest:Q}=this.multihash,$=R0(J,Q);return y.createV1(this.code,$)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(J){return y.equals(this,J)}static equals(J,Q){let $=Q;return $!=null&&J.code===$.code&&J.version===$.version&&L0(J.multihash,$.multihash)}toString(J){return k0(this,J)}toJSON(){return{"/":k0(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(J){if(J==null)return null;let Q=J;if(Q instanceof y)return Q;else if(Q["/"]!=null&&Q["/"]===Q.bytes||Q.asCID===Q){let{version:$,code:q,multihash:Y,bytes:G}=Q;return new y($,q,Y,G??C0($,q,Y.bytes))}else if(Q[KQ]===!0){let{version:$,multihash:q,code:Y}=Q,G=w0(q);return y.create($,Y,G)}else return null}static create(J,Q,$){if(typeof Q!=="number")throw Error("String codecs are no longer supported");if(!($.bytes instanceof Uint8Array))throw Error("Invalid digest");switch(J){case 0:if(Q!==pJ)throw Error(`Version 0 CID must use dag-pb (code: ${pJ}) block encoding`);else return new y(J,Q,$,$.bytes);case 1:{let q=C0(J,Q,$.bytes);return new y(J,Q,$,q)}default:throw Error("Invalid version")}}static createV0(J){return y.create(0,pJ,J)}static createV1(J,Q){return y.create(1,J,Q)}static decode(J){let[Q,$]=y.decodeFirst(J);if($.length!==0)throw Error("Incorrect length");return Q}static decodeFirst(J){let Q=y.inspectBytes(J),$=Q.size-Q.multihashSize,q=SJ(J.subarray($,$+Q.multihashSize));if(q.byteLength!==Q.multihashSize)throw Error("Incorrect length");let Y=q.subarray(Q.multihashSize-Q.digestSize),G=new cJ(Q.multihashCode,Q.digestSize,Y,q);return[Q.version===0?y.createV0(G):y.createV1(Q.codec,G),J.subarray(Q.size)]}static inspectBytes(J){let Q=0,$=()=>{let[U,O]=dJ(J.subarray(Q));return Q+=O,U},q=$(),Y=pJ;if(q===18)q=0,Q=0;else Y=$();if(q!==0&&q!==1)throw RangeError(`Invalid CID version ${q}`);let G=Q,Z=$(),X=$(),K=Q+X,M=K-G;return{version:q,codec:Y,multihashCode:Z,digestSize:X,multihashSize:M,size:K}}static parse(J,Q){let[$,q]=qQ(J,Q),Y=y.decode(q);if(Y.version===0&&J[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return O$(Y).set($,J),Y}}function qQ(J,Q){switch(J[0]){case"Q":{let $=Q??o;return[o.prefix,$.decode(`${o.prefix}${J}`)]}case o.prefix:{let $=Q??o;return[o.prefix,$.decode(J)]}case uJ.prefix:{let $=Q??uJ;return[uJ.prefix,$.decode(J)]}case Y$.prefix:{let $=Q??Y$;return[Y$.prefix,$.decode(J)]}default:{if(Q==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[J[0],Q.decode(J)]}}}function YQ(J,Q,$){let{prefix:q}=$;if(q!==o.prefix)throw Error(`Cannot string encode V0 in ${$.name} encoding`);let Y=Q.get(q);if(Y==null){let G=$.encode(J).slice(1);return Q.set(q,G),G}else return Y}function GQ(J,Q,$){let{prefix:q}=$,Y=Q.get(q);if(Y==null){let G=$.encode(J);return Q.set(q,G),G}else return Y}var pJ=112,ZQ=18;function C0(J,Q,$){let q=xJ(J),Y=q+xJ(Q),G=new Uint8Array(Y+$.byteLength);return EJ(J,G,0),EJ(Q,G,q),G.set($,Y),G}var KQ=Symbol.for("@ipld/js-cid/CID");function XQ(J){let Q=y.parse(J,o);if(Q.version!==0)throw Error(`Expected CIDv0, got CIDv${Q.version}`);if(Q.multihash.code!==18)throw Error("Unsupported hash algorithm. Only SHA-256 is supported for CIDv0.");let $=Q.multihash.digest;return`0x${Array.from($).map((Y)=>Y.toString(16).padStart(2,"0")).join("")}`}function MQ(J){let Q=y.parse(J,o);if(Q.version!==0)throw Error(`Expected CIDv0, got CIDv${Q.version}`);if(Q.multihash.code!==18)throw Error("Unsupported hash algorithm. Only SHA-256 is supported for CIDv0.");return Q.multihash.digest}function UQ(J){return`0x${J.toString(16).padStart(64,"0").slice(-40)}`}var jQ="0x0000000000000000000000000000000000000000",NQ=BigInt(96)*BigInt(1000000000000000000),WQ=BigInt("9999999999999999999999999999999999999"),zQ="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",OQ="0x440ea2f93c9703f7d456d48796f7bc25b8721582535a492ce0a09df32146242a",VQ="0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee";var TQ={100:{circlesRpcUrl:"https://rpc.aboutcircles.com/",pathfinderUrl:"https://pathfinder.aboutcircles.com",profileServiceUrl:"https://rpc.aboutcircles.com/profiles/",referralsServiceUrl:"https://staging.circlesubi.network/referrals",v1HubAddress:"0x29b9a7fbb8995b2423a71cc17cf9810798f6c543",v2HubAddress:"0xc12C1E50ABB450d6205Ea2C3Fa861b3B834d13e8",nameRegistryAddress:"0xA27566fD89162cC3D40Cb59c87AAaA49B85F3474",baseGroupMintPolicy:"0xcCa27c26CF7BAC2a9928f42201d48220F0e3a549",standardTreasury:"0x08F90aB73A515308f03A718257ff9887ED330C6e",coreMembersGroupDeployer:"0xFEca40Eb02FB1f4F5F795fC7a03c1A27819B1Ded",baseGroupFactoryAddress:"0xD0B5Bd9962197BEaC4cbA24244ec3587f19Bd06d",liftERC20Address:"0x5F99a795dD2743C36D63511f0D4bc667e6d3cDB5",invitationFarmAddress:"0x0000000000000000000000000000000000000000",referralsModuleAddress:"0x12105a9B291aF2ABb0591001155A75949b062CE5",invitationModuleAddress:"0x00738aca013B7B2e6cfE1690F0021C3182Fa40B5"}};class QJ extends Error{name;code;source;cause;context;constructor(J,Q,$){super(Q);if(this.name=J,this.code=$?.code,this.source=$?.source??"UNKNOWN",this.cause=$?.cause,this.context=$?.context,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,source:this.source,context:this.context,cause:this.cause instanceof Error?{name:this.cause.name,message:this.cause.message}:this.cause,stack:this.stack}}toString(){let J=`[${this.source}] ${this.name}: ${this.message}`;if(this.code)J+=` (Code: ${this.code})`;if(this.context)J+=`
|
|
2
2
|
Context: ${JSON.stringify(this.context,null,2)}`;return J}}class _J extends QJ{constructor(J,Q){super("ValidationError",J,{...Q,source:"VALIDATION"})}static invalidAddress(J){return new _J("Invalid Ethereum address",{code:"VALIDATION_INVALID_ADDRESS",context:{address:J}})}static invalidAmount(J,Q){return new _J(Q||"Invalid amount",{code:"VALIDATION_INVALID_AMOUNT",context:{amount:J,reason:Q}})}static missingParameter(J){return new _J(`Missing required parameter: ${J}`,{code:"VALIDATION_MISSING_PARAM",context:{paramName:J}})}static invalidParameter(J,Q,$){return new _J(`Invalid parameter '${J}': ${$||"value is invalid"}`,{code:"VALIDATION_INVALID_PARAM",context:{paramName:J,value:Q,reason:$}})}}class G$ extends QJ{constructor(J,Q){super("EncodingError",J,{...Q,source:"ENCODING"})}static abiEncoding(J,Q){return new G$("Failed to encode ABI data",{code:"ENCODING_ABI_FAILED",cause:Q,context:{functionName:J}})}static cidConversion(J,Q){return new G$("Failed to convert CID",{code:"ENCODING_CID_FAILED",cause:Q,context:{cid:J}})}}function DQ(J,Q="UNKNOWN"){if(J instanceof QJ)return J;if(J instanceof Error)return new QJ(J.name||"UnknownError",J.message,{source:Q,cause:J});return new QJ("UnknownError",String(J),{source:Q,cause:J})}function B0(J){return J instanceof QJ}function IQ(J){if(B0(J))return J.message;if(J instanceof Error)return J.message;return String(J)}var RQ={0:"Avatar already registered",1:"Avatar must be registered before inviting",2:"Invalid invitation",3:"Avatar must be registered",4:"Only self can register",5:"Maximum value reached",6:"Inflationary supply already set",7:"Group has no collateral",161:"Trust to zero address is not allowed",16:"Invalid parameter"};function wQ(J){if(J?.details&&typeof J.details==="string"){let $=J.details.match(/err:\s*(0x[0-9a-fA-F]+)/);if($)return $[1]}if(J?.data&&typeof J.data==="string"&&J.data.startsWith("0x"))return J.data;let Q=J;while(Q){if(Q.data&&typeof Q.data==="string")return Q.data;Q=Q.cause}return null}function LQ(J,Q,$){if(!Q||Q.length===0)return J;if(!$||!$.inputs){let Z=Q.map((X)=>{if(typeof X==="bigint")return X.toString();return String(X)}).join(", ");return`${J}(${Z})`}let q=$.inputs.findIndex((Z)=>Z.name==="code"||Z.name===""&&Z.type==="uint8"),Y=J,G=[];if(q!==-1){let Z=Number(Q[q]),X=RQ[Z];if(X)Y=X}if($.inputs.forEach((Z,X)=>{let K=Q[X],M=Z.name||`arg${X}`;if(!Z.name&&Z.type==="uint8")return;let U;if(typeof K==="bigint")U=K.toString();else if(typeof K==="string"&&K.startsWith("0x"))U=K;else U=String(K);if(M==="code"||Z.type==="uint8")U=`0x${Number(K).toString(16)}`;G.push(`${M}: ${U}`)}),G.length>0)return`${Y} (${G.join(", ")})`;return Y}function A0(J,Q){let $=wQ(J);if(!$)return null;let q=W$({abi:Q,data:$});if(!q)return null;let Y=Q.find((X)=>X.type==="error"&&X.name===q.errorName),G=$.slice(0,10),Z=LQ(q.errorName,q.args,Y);return{errorName:q.errorName,args:q.args,selector:G,rawData:$,formattedMessage:Z}}class Z$ extends QJ{decodedError;constructor(J,Q){super("ContractError",J,{...Q,source:"CORE"});this.decodedError=Q?.decodedError}static fromTransactionError(J,Q,$){let q=A0(J,Q);if(q)return new Z$(`Transaction failed: ${q.formattedMessage}`,{code:q.selector,cause:J,context:{...$,errorName:q.errorName,errorArgs:q.args},decodedError:q});let Y=J?.message||String(J);return new Z$(`Transaction failed: ${Y}`,{cause:J,context:$})}toString(){let J=super.toString();if(this.decodedError){if(J+=`
|
|
3
3
|
Decoded Error: ${this.decodedError.formattedMessage}`,this.decodedError.args&&this.decodedError.args.length>0)J+=`
|
|
4
4
|
Arguments: ${JSON.stringify(this.decodedError.args,(Q,$)=>typeof $==="bigint"?$.toString():$)}`}return J}}function kQ(J,Q,$,q){if(typeof J.setBigUint64==="function")return J.setBigUint64(Q,$,q);let Y=BigInt(32),G=BigInt(4294967295),Z=Number($>>Y&G),X=Number($&G),K=q?4:0,M=q?0:4;J.setUint32(Q+K,Z,q),J.setUint32(Q+M,X,q)}function S0(J,Q,$){return J&Q^~J&$}function H0(J,Q,$){return J&Q^J&$^Q&$}class V$ extends TJ{constructor(J,Q,$,q){super();this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=J,this.outputLen=Q,this.padOffset=$,this.isLE=q,this.buffer=new Uint8Array(J),this.view=eJ(this.buffer)}update(J){qJ(this),J=VJ(J),t(J);let{view:Q,buffer:$,blockLen:q}=this,Y=J.length;for(let G=0;G<Y;){let Z=Math.min(q-this.pos,Y-G);if(Z===q){let X=eJ(J);for(;q<=Y-G;G+=q)this.process(X,G);continue}if($.set(J.subarray(G,G+Z),this.pos),this.pos+=Z,G+=Z,this.pos===q)this.process(Q,0),this.pos=0}return this.length+=J.length,this.roundClean(),this}digestInto(J){qJ(this),tJ(J,this),this.finished=!0;let{buffer:Q,view:$,blockLen:q,isLE:Y}=this,{pos:G}=this;if(Q[G++]=128,e(this.buffer.subarray(G)),this.padOffset>q-G)this.process($,0),G=0;for(let U=G;U<q;U++)Q[U]=0;kQ($,q-8,BigInt(this.length*8),Y),this.process($,0);let Z=eJ(J),X=this.outputLen;if(X%4)throw Error("_sha2: outputLen should be aligned to 32bit");let K=X/4,M=this.get();if(K>M.length)throw Error("_sha2: outputLen bigger than state");for(let U=0;U<K;U++)Z.setUint32(4*U,M[U],Y)}digest(){let{buffer:J,outputLen:Q}=this;this.digestInto(J);let $=J.slice(0,Q);return this.destroy(),$}_cloneInto(J){J||(J=new this.constructor),J.set(...this.get());let{blockLen:Q,buffer:$,length:q,finished:Y,destroyed:G,pos:Z}=this;if(J.destroyed=G,J.finished=Y,J.length=q,J.pos=Z,q%Q)J.buffer.set($);return J}clone(){return this._cloneInto()}}var YJ=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var PQ=Uint32Array.from([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]),jJ=new Uint32Array(64);class E0 extends V${constructor(J=32){super(64,J,8,!1);this.A=YJ[0]|0,this.B=YJ[1]|0,this.C=YJ[2]|0,this.D=YJ[3]|0,this.E=YJ[4]|0,this.F=YJ[5]|0,this.G=YJ[6]|0,this.H=YJ[7]|0}get(){let{A:J,B:Q,C:$,D:q,E:Y,F:G,G:Z,H:X}=this;return[J,Q,$,q,Y,G,Z,X]}set(J,Q,$,q,Y,G,Z,X){this.A=J|0,this.B=Q|0,this.C=$|0,this.D=q|0,this.E=Y|0,this.F=G|0,this.G=Z|0,this.H=X|0}process(J,Q){for(let U=0;U<16;U++,Q+=4)jJ[U]=J.getUint32(Q,!1);for(let U=16;U<64;U++){let O=jJ[U-15],I=jJ[U-2],w=r(O,7)^r(O,18)^O>>>3,T=r(I,17)^r(I,19)^I>>>10;jJ[U]=T+jJ[U-7]+w+jJ[U-16]|0}let{A:$,B:q,C:Y,D:G,E:Z,F:X,G:K,H:M}=this;for(let U=0;U<64;U++){let O=r(Z,6)^r(Z,11)^r(Z,25),I=M+O+S0(Z,X,K)+PQ[U]+jJ[U]|0,T=(r($,2)^r($,13)^r($,22))+H0($,q,Y)|0;M=K,K=X,X=Z,Z=G+I|0,G=Y,Y=q,q=$,$=I+T|0}$=$+this.A|0,q=q+this.B|0,Y=Y+this.C|0,G=G+this.D|0,Z=Z+this.E|0,X=X+this.F|0,K=K+this.G|0,M=M+this.H|0,this.set($,q,Y,G,Z,X,K,M)}roundClean(){e(jJ)}destroy(){this.set(0,0,0,0,0,0,0,0),e(this.buffer)}}var x0=J$(()=>new E0);class T$ extends TJ{constructor(J,Q){super();this.finished=!1,this.destroyed=!1,s$(J);let $=VJ(Q);if(this.iHash=J.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let q=this.blockLen,Y=new Uint8Array(q);Y.set($.length>q?J.create().update($).digest():$);for(let G=0;G<Y.length;G++)Y[G]^=54;this.iHash.update(Y),this.oHash=J.create();for(let G=0;G<Y.length;G++)Y[G]^=106;this.oHash.update(Y),e(Y)}update(J){return qJ(this),this.iHash.update(J),this}digestInto(J){qJ(this),t(J,this.outputLen),this.finished=!0,this.iHash.digestInto(J),this.oHash.update(J),this.oHash.digestInto(J),this.destroy()}digest(){let J=new Uint8Array(this.oHash.outputLen);return this.digestInto(J),J}_cloneInto(J){J||(J=Object.create(Object.getPrototypeOf(this),{}));let{oHash:Q,iHash:$,finished:q,destroyed:Y,blockLen:G,outputLen:Z}=this;return J=J,J.finished=q,J.destroyed=Y,J.blockLen=G,J.outputLen=Z,J.oHash=Q._cloneInto(J.oHash),J.iHash=$._cloneInto(J.iHash),J}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var D$=(J,Q,$)=>new T$(J,Q).update($).digest();D$.create=(J,Q)=>new T$(J,Q);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var L$=BigInt(0),w$=BigInt(1);function vJ(J){return J instanceof Uint8Array||ArrayBuffer.isView(J)&&J.constructor.name==="Uint8Array"}function k$(J){if(!vJ(J))throw Error("Uint8Array expected")}function gJ(J,Q){if(typeof Q!=="boolean")throw Error(J+" boolean expected, got "+Q)}function iJ(J){let Q=J.toString(16);return Q.length&1?"0"+Q:Q}function g0(J){if(typeof J!=="string")throw Error("hex string expected, got "+typeof J);return J===""?L$:BigInt("0x"+J)}var F0=typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function",CQ=Array.from({length:256},(J,Q)=>Q.toString(16).padStart(2,"0"));function FJ(J){if(k$(J),F0)return J.toHex();let Q="";for(let $=0;$<J.length;$++)Q+=CQ[J[$]];return Q}var GJ={_0:48,_9:57,A:65,F:70,a:97,f:102};function _0(J){if(J>=GJ._0&&J<=GJ._9)return J-GJ._0;if(J>=GJ.A&&J<=GJ.F)return J-(GJ.A-10);if(J>=GJ.a&&J<=GJ.f)return J-(GJ.a-10);return}function nJ(J){if(typeof J!=="string")throw Error("hex string expected, got "+typeof J);if(F0)return Uint8Array.fromHex(J);let Q=J.length,$=Q/2;if(Q%2)throw Error("hex string expected, got unpadded hex of length "+Q);let q=new Uint8Array($);for(let Y=0,G=0;Y<$;Y++,G+=2){let Z=_0(J.charCodeAt(G)),X=_0(J.charCodeAt(G+1));if(Z===void 0||X===void 0){let K=J[G]+J[G+1];throw Error('hex string expected, got non-hex character "'+K+'" at index '+G)}q[Y]=Z*16+X}return q}function ZJ(J){return g0(FJ(J))}function P$(J){return k$(J),g0(FJ(Uint8Array.from(J).reverse()))}function IJ(J,Q){return nJ(J.toString(16).padStart(Q*2,"0"))}function C$(J,Q){return IJ(J,Q).reverse()}function p(J,Q,$){let q;if(typeof Q==="string")try{q=nJ(Q)}catch(G){throw Error(J+" must be hex string or Uint8Array, cause: "+G)}else if(vJ(Q))q=Uint8Array.from(Q);else throw Error(J+" must be hex string or Uint8Array");let Y=q.length;if(typeof $==="number"&&Y!==$)throw Error(J+" of length "+$+" expected, got "+Y);return q}function oJ(...J){let Q=0;for(let q=0;q<J.length;q++){let Y=J[q];k$(Y),Q+=Y.length}let $=new Uint8Array(Q);for(let q=0,Y=0;q<J.length;q++){let G=J[q];$.set(G,Y),Y+=G.length}return $}var I$=(J)=>typeof J==="bigint"&&L$<=J;function K$(J,Q,$){return I$(J)&&I$(Q)&&I$($)&&Q<=J&&J<$}function RJ(J,Q,$,q){if(!K$(Q,$,q))throw Error("expected valid "+J+": "+$+" <= n < "+q+", got "+Q)}function f0(J){let Q;for(Q=0;J>L$;J>>=w$,Q+=1);return Q}var wJ=(J)=>(w$<<BigInt(J))-w$,R$=(J)=>new Uint8Array(J),v0=(J)=>Uint8Array.from(J);function y0(J,Q,$){if(typeof J!=="number"||J<2)throw Error("hashLen must be a number");if(typeof Q!=="number"||Q<2)throw Error("qByteLen must be a number");if(typeof $!=="function")throw Error("hmacFn must be a function");let q=R$(J),Y=R$(J),G=0,Z=()=>{q.fill(1),Y.fill(0),G=0},X=(...O)=>$(Y,q,...O),K=(O=R$(0))=>{if(Y=X(v0([0]),O),q=X(),O.length===0)return;Y=X(v0([1]),O),q=X()},M=()=>{if(G++>=1000)throw Error("drbg: tried 1000 values");let O=0,I=[];while(O<Q){q=X();let w=q.slice();I.push(w),O+=q.length}return oJ(...I)};return(O,I)=>{Z(),K(O);let w=void 0;while(!(w=I(M())))K();return Z(),w}}var BQ={bigint:(J)=>typeof J==="bigint",function:(J)=>typeof J==="function",boolean:(J)=>typeof J==="boolean",string:(J)=>typeof J==="string",stringOrUint8Array:(J)=>typeof J==="string"||vJ(J),isSafeInteger:(J)=>Number.isSafeInteger(J),array:(J)=>Array.isArray(J),field:(J,Q)=>Q.Fp.isValid(J),hash:(J)=>typeof J==="function"&&Number.isSafeInteger(J.outputLen)};function LJ(J,Q,$={}){let q=(Y,G,Z)=>{let X=BQ[G];if(typeof X!=="function")throw Error("invalid validator function");let K=J[Y];if(Z&&K===void 0)return;if(!X(K,J))throw Error("param "+String(Y)+" is invalid. Expected "+G+", got "+K)};for(let[Y,G]of Object.entries(Q))q(Y,G,!1);for(let[Y,G]of Object.entries($))q(Y,G,!0);return J}function B$(J){let Q=new WeakMap;return($,...q)=>{let Y=Q.get($);if(Y!==void 0)return Y;let G=J($,...q);return Q.set($,G),G}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var d=BigInt(0),u=BigInt(1),kJ=BigInt(2),AQ=BigInt(3),m0=BigInt(4),h0=BigInt(5),u0=BigInt(8);function h(J,Q){let $=J%Q;return $>=d?$:Q+$}function i(J,Q,$){let q=J;while(Q-- >d)q*=q,q%=$;return q}function X$(J,Q){if(J===d)throw Error("invert: expected non-zero number");if(Q<=d)throw Error("invert: expected positive modulus, got "+Q);let $=h(J,Q),q=Q,Y=d,G=u,Z=u,X=d;while($!==d){let M=q/$,U=q%$,O=Y-Z*M,I=G-X*M;q=$,$=U,Y=Z,G=X,Z=O,X=I}if(q!==u)throw Error("invert: does not exist");return h(Y,Q)}function l0(J,Q){let $=(J.ORDER+u)/m0,q=J.pow(Q,$);if(!J.eql(J.sqr(q),Q))throw Error("Cannot find square root");return q}function SQ(J,Q){let $=(J.ORDER-h0)/u0,q=J.mul(Q,kJ),Y=J.pow(q,$),G=J.mul(Q,Y),Z=J.mul(J.mul(G,kJ),Y),X=J.mul(G,J.sub(Z,J.ONE));if(!J.eql(J.sqr(X),Q))throw Error("Cannot find square root");return X}function HQ(J){if(J<BigInt(3))throw Error("sqrt is not defined for small field");let Q=J-u,$=0;while(Q%kJ===d)Q/=kJ,$++;let q=kJ,Y=rJ(J);while(b0(Y,q)===1)if(q++>1000)throw Error("Cannot find square root: probably non-prime P");if($===1)return l0;let G=Y.pow(q,Q),Z=(Q+u)/kJ;return function(K,M){if(K.is0(M))return M;if(b0(K,M)!==1)throw Error("Cannot find square root");let U=$,O=K.mul(K.ONE,G),I=K.pow(M,Q),w=K.pow(M,Z);while(!K.eql(I,K.ONE)){if(K.is0(I))return K.ZERO;let T=1,z=K.sqr(I);while(!K.eql(z,K.ONE))if(T++,z=K.sqr(z),T===U)throw Error("Cannot find square root");let v=u<<BigInt(U-T-1),x=K.pow(O,v);U=T,O=K.sqr(x),I=K.mul(I,O),w=K.mul(w,x)}return w}}function EQ(J){if(J%m0===AQ)return l0;if(J%u0===h0)return SQ;return HQ(J)}var xQ=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function A$(J){let Q={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},$=xQ.reduce((q,Y)=>{return q[Y]="function",q},Q);return LJ(J,$)}function _Q(J,Q,$){if($<d)throw Error("invalid exponent, negatives unsupported");if($===d)return J.ONE;if($===u)return Q;let q=J.ONE,Y=Q;while($>d){if($&u)q=J.mul(q,Y);Y=J.sqr(Y),$>>=u}return q}function S$(J,Q,$=!1){let q=Array(Q.length).fill($?J.ZERO:void 0),Y=Q.reduce((Z,X,K)=>{if(J.is0(X))return Z;return q[K]=Z,J.mul(Z,X)},J.ONE),G=J.inv(Y);return Q.reduceRight((Z,X,K)=>{if(J.is0(X))return Z;return q[K]=J.mul(Z,q[K]),J.mul(Z,X)},G),q}function b0(J,Q){let $=(J.ORDER-u)/kJ,q=J.pow(Q,$),Y=J.eql(q,J.ONE),G=J.eql(q,J.ZERO),Z=J.eql(q,J.neg(J.ONE));if(!Y&&!G&&!Z)throw Error("invalid Legendre symbol result");return Y?1:G?0:-1}function H$(J,Q){if(Q!==void 0)OJ(Q);let $=Q!==void 0?Q:J.toString(2).length,q=Math.ceil($/8);return{nBitLength:$,nByteLength:q}}function rJ(J,Q,$=!1,q={}){if(J<=d)throw Error("invalid field: expected ORDER > 0, got "+J);let{nBitLength:Y,nByteLength:G}=H$(J,Q);if(G>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let Z,X=Object.freeze({ORDER:J,isLE:$,BITS:Y,BYTES:G,MASK:wJ(Y),ZERO:d,ONE:u,create:(K)=>h(K,J),isValid:(K)=>{if(typeof K!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof K);return d<=K&&K<J},is0:(K)=>K===d,isOdd:(K)=>(K&u)===u,neg:(K)=>h(-K,J),eql:(K,M)=>K===M,sqr:(K)=>h(K*K,J),add:(K,M)=>h(K+M,J),sub:(K,M)=>h(K-M,J),mul:(K,M)=>h(K*M,J),pow:(K,M)=>_Q(X,K,M),div:(K,M)=>h(K*X$(M,J),J),sqrN:(K)=>K*K,addN:(K,M)=>K+M,subN:(K,M)=>K-M,mulN:(K,M)=>K*M,inv:(K)=>X$(K,J),sqrt:q.sqrt||((K)=>{if(!Z)Z=EQ(J);return Z(X,K)}),toBytes:(K)=>$?C$(K,G):IJ(K,G),fromBytes:(K)=>{if(K.length!==G)throw Error("Field.fromBytes: expected "+G+" bytes, got "+K.length);return $?P$(K):ZJ(K)},invertBatch:(K)=>S$(X,K),cmov:(K,M,U)=>U?M:K});return Object.freeze(X)}function d0(J){if(typeof J!=="bigint")throw Error("field order must be bigint");let Q=J.toString(2).length;return Math.ceil(Q/8)}function E$(J){let Q=d0(J);return Q+Math.ceil(Q/2)}function c0(J,Q,$=!1){let q=J.length,Y=d0(Q),G=E$(Q);if(q<16||q<G||q>1024)throw Error("expected "+G+"-1024 bytes of input, got "+q);let Z=$?P$(J):ZJ(J),X=h(Z,Q-u)+u;return $?C$(X,Y):IJ(X,Y)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var p0=BigInt(0),F$=BigInt(1);function x$(J,Q){let $=Q.negate();return J?$:Q}function n0(J,Q){if(!Number.isSafeInteger(J)||J<=0||J>Q)throw Error("invalid window size, expected [1.."+Q+"], got W="+J)}function _$(J,Q){n0(J,Q);let $=Math.ceil(Q/J)+1,q=2**(J-1),Y=2**J,G=wJ(J),Z=BigInt(J);return{windows:$,windowSize:q,mask:G,maxNumber:Y,shiftBy:Z}}function i0(J,Q,$){let{windowSize:q,mask:Y,maxNumber:G,shiftBy:Z}=$,X=Number(J&Y),K=J>>Z;if(X>q)X-=G,K+=F$;let M=Q*q,U=M+Math.abs(X)-1,O=X===0,I=X<0,w=Q%2!==0;return{nextN:K,offset:U,isZero:O,isNeg:I,isNegF:w,offsetF:M}}function vQ(J,Q){if(!Array.isArray(J))throw Error("array expected");J.forEach(($,q)=>{if(!($ instanceof Q))throw Error("invalid point at index "+q)})}function gQ(J,Q){if(!Array.isArray(J))throw Error("array of scalars expected");J.forEach(($,q)=>{if(!Q.isValid($))throw Error("invalid scalar at index "+q)})}var v$=new WeakMap,o0=new WeakMap;function g$(J){return o0.get(J)||1}function r0(J,Q){return{constTimeNegate:x$,hasPrecomputes($){return g$($)!==1},unsafeLadder($,q,Y=J.ZERO){let G=$;while(q>p0){if(q&F$)Y=Y.add(G);G=G.double(),q>>=F$}return Y},precomputeWindow($,q){let{windows:Y,windowSize:G}=_$(q,Q),Z=[],X=$,K=X;for(let M=0;M<Y;M++){K=X,Z.push(K);for(let U=1;U<G;U++)K=K.add(X),Z.push(K);X=K.double()}return Z},wNAF($,q,Y){let{ZERO:G,BASE:Z}=J,X=_$($,Q);for(let K=0;K<X.windows;K++){let{nextN:M,offset:U,isZero:O,isNeg:I,isNegF:w,offsetF:T}=i0(Y,K,X);if(Y=M,O)Z=Z.add(x$(w,q[T]));else G=G.add(x$(I,q[U]))}return{p:G,f:Z}},wNAFUnsafe($,q,Y,G=J.ZERO){let Z=_$($,Q);for(let X=0;X<Z.windows;X++){if(Y===p0)break;let{nextN:K,offset:M,isZero:U,isNeg:O}=i0(Y,X,Z);if(Y=K,U)continue;else{let I=q[M];G=G.add(O?I.negate():I)}}return G},getPrecomputes($,q,Y){let G=v$.get(q);if(!G){if(G=this.precomputeWindow(q,$),$!==1)v$.set(q,Y(G))}return G},wNAFCached($,q,Y){let G=g$($);return this.wNAF(G,this.getPrecomputes(G,$,Y),q)},wNAFCachedUnsafe($,q,Y,G){let Z=g$($);if(Z===1)return this.unsafeLadder($,q,G);return this.wNAFUnsafe(Z,this.getPrecomputes(Z,$,Y),q,G)},setWindowSize($,q){n0(q,Q),o0.set($,q),v$.delete($)}}}function a0(J,Q,$,q){vQ($,J),gQ(q,Q);let Y=$.length,G=q.length;if(Y!==G)throw Error("arrays of points and scalars must have equal length");let Z=J.ZERO,X=f0(BigInt(Y)),K=1;if(X>12)K=X-3;else if(X>4)K=X-2;else if(X>0)K=2;let M=wJ(K),U=Array(Number(M)+1).fill(Z),O=Math.floor((Q.BITS-1)/K)*K,I=Z;for(let w=O;w>=0;w-=K){U.fill(Z);for(let z=0;z<G;z++){let v=q[z],x=Number(v>>BigInt(w)&M);U[x]=U[x].add($[z])}let T=Z;for(let z=U.length-1,v=Z;z>0;z--)v=v.add(U[z]),T=T.add(v);if(I=I.add(T),w!==0)for(let z=0;z<K;z++)I=I.double()}return I}function f$(J){return A$(J.Fp),LJ(J,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...H$(J.n,J.nBitLength),...J,...{p:J.Fp.ORDER}})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function s0(J){if(J.lowS!==void 0)gJ("lowS",J.lowS);if(J.prehash!==void 0)gJ("prehash",J.prehash)}function FQ(J){let Q=f$(J);LJ(Q,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:$,Fp:q,a:Y}=Q;if($){if(!q.eql(Y,q.ZERO))throw Error("invalid endo: CURVE.a must be 0");if(typeof $!=="object"||typeof $.beta!=="bigint"||typeof $.splitScalar!=="function")throw Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...Q})}class t0 extends Error{constructor(J=""){super(J)}}var KJ={Err:t0,_tlv:{encode:(J,Q)=>{let{Err:$}=KJ;if(J<0||J>256)throw new $("tlv.encode: wrong tag");if(Q.length&1)throw new $("tlv.encode: unpadded data");let q=Q.length/2,Y=iJ(q);if(Y.length/2&128)throw new $("tlv.encode: long form length too big");let G=q>127?iJ(Y.length/2|128):"";return iJ(J)+G+Y+Q},decode(J,Q){let{Err:$}=KJ,q=0;if(J<0||J>256)throw new $("tlv.encode: wrong tag");if(Q.length<2||Q[q++]!==J)throw new $("tlv.decode: wrong tlv");let Y=Q[q++],G=!!(Y&128),Z=0;if(!G)Z=Y;else{let K=Y&127;if(!K)throw new $("tlv.decode(long): indefinite length not supported");if(K>4)throw new $("tlv.decode(long): byte length is too big");let M=Q.subarray(q,q+K);if(M.length!==K)throw new $("tlv.decode: length bytes not complete");if(M[0]===0)throw new $("tlv.decode(long): zero leftmost byte");for(let U of M)Z=Z<<8|U;if(q+=K,Z<128)throw new $("tlv.decode(long): not minimal encoding")}let X=Q.subarray(q,q+Z);if(X.length!==Z)throw new $("tlv.decode: wrong value length");return{v:X,l:Q.subarray(q+Z)}}},_int:{encode(J){let{Err:Q}=KJ;if(J<XJ)throw new Q("integer: negative integers are not allowed");let $=iJ(J);if(Number.parseInt($[0],16)&8)$="00"+$;if($.length&1)throw new Q("unexpected DER parsing assertion: unpadded hex");return $},decode(J){let{Err:Q}=KJ;if(J[0]&128)throw new Q("invalid signature integer: negative");if(J[0]===0&&!(J[1]&128))throw new Q("invalid signature integer: unnecessary leading zero");return ZJ(J)}},toSig(J){let{Err:Q,_int:$,_tlv:q}=KJ,Y=p("signature",J),{v:G,l:Z}=q.decode(48,Y);if(Z.length)throw new Q("invalid signature: left bytes after parsing");let{v:X,l:K}=q.decode(2,G),{v:M,l:U}=q.decode(2,K);if(U.length)throw new Q("invalid signature: left bytes after parsing");return{r:$.decode(X),s:$.decode(M)}},hexFromSig(J){let{_tlv:Q,_int:$}=KJ,q=Q.encode(2,$.encode(J.r)),Y=Q.encode(2,$.encode(J.s)),G=q+Y;return Q.encode(48,G)}};function y$(J,Q){return FJ(IJ(J,Q))}var XJ=BigInt(0),b=BigInt(1),NY=BigInt(2),b$=BigInt(3),fQ=BigInt(4);function yQ(J){let Q=FQ(J),{Fp:$}=Q,q=rJ(Q.n,Q.nBitLength),Y=Q.toBytes||((j,W,D)=>{let R=W.toAffine();return oJ(Uint8Array.from([4]),$.toBytes(R.x),$.toBytes(R.y))}),G=Q.fromBytes||((j)=>{let W=j.subarray(1),D=$.fromBytes(W.subarray(0,$.BYTES)),R=$.fromBytes(W.subarray($.BYTES,2*$.BYTES));return{x:D,y:R}});function Z(j){let{a:W,b:D}=Q,R=$.sqr(j),L=$.mul(R,j);return $.add($.add(L,$.mul(j,W)),D)}function X(j,W){let D=$.sqr(W),R=Z(j);return $.eql(D,R)}if(!X(Q.Gx,Q.Gy))throw Error("bad curve params: generator point");let K=$.mul($.pow(Q.a,b$),fQ),M=$.mul($.sqr(Q.b),BigInt(27));if($.is0($.add(K,M)))throw Error("bad curve params: a or b");function U(j){return K$(j,b,Q.n)}function O(j){let{allowedPrivateKeyLengths:W,nByteLength:D,wrapPrivateKey:R,n:L}=Q;if(W&&typeof j!=="bigint"){if(vJ(j))j=FJ(j);if(typeof j!=="string"||!W.includes(j.length))throw Error("invalid private key");j=j.padStart(D*2,"0")}let C;try{C=typeof j==="bigint"?j:ZJ(p("private key",j,D))}catch(H){throw Error("invalid private key, expected hex or "+D+" bytes, got "+typeof j)}if(R)C=h(C,L);return RJ("private key",C,b,L),C}function I(j){if(!(j instanceof z))throw Error("ProjectivePoint expected")}let w=B$((j,W)=>{let{px:D,py:R,pz:L}=j;if($.eql(L,$.ONE))return{x:D,y:R};let C=j.is0();if(W==null)W=C?$.ONE:$.inv(L);let H=$.mul(D,W),B=$.mul(R,W),S=$.mul(L,W);if(C)return{x:$.ZERO,y:$.ZERO};if(!$.eql(S,$.ONE))throw Error("invZ was invalid");return{x:H,y:B}}),T=B$((j)=>{if(j.is0()){if(Q.allowInfinityPoint&&!$.is0(j.py))return;throw Error("bad point: ZERO")}let{x:W,y:D}=j.toAffine();if(!$.isValid(W)||!$.isValid(D))throw Error("bad point: x or y not FE");if(!X(W,D))throw Error("bad point: equation left != right");if(!j.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});class z{constructor(j,W,D){if(j==null||!$.isValid(j))throw Error("x required");if(W==null||!$.isValid(W)||$.is0(W))throw Error("y required");if(D==null||!$.isValid(D))throw Error("z required");this.px=j,this.py=W,this.pz=D,Object.freeze(this)}static fromAffine(j){let{x:W,y:D}=j||{};if(!j||!$.isValid(W)||!$.isValid(D))throw Error("invalid affine point");if(j instanceof z)throw Error("projective point not allowed");let R=(L)=>$.eql(L,$.ZERO);if(R(W)&&R(D))return z.ZERO;return new z(W,D,$.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(j){let W=S$($,j.map((D)=>D.pz));return j.map((D,R)=>D.toAffine(W[R])).map(z.fromAffine)}static fromHex(j){let W=z.fromAffine(G(p("pointHex",j)));return W.assertValidity(),W}static fromPrivateKey(j){return z.BASE.multiply(O(j))}static msm(j,W){return a0(z,q,j,W)}_setWindowSize(j){f.setWindowSize(this,j)}assertValidity(){T(this)}hasEvenY(){let{y:j}=this.toAffine();if($.isOdd)return!$.isOdd(j);throw Error("Field doesn't support isOdd")}equals(j){I(j);let{px:W,py:D,pz:R}=this,{px:L,py:C,pz:H}=j,B=$.eql($.mul(W,H),$.mul(L,R)),S=$.eql($.mul(D,H),$.mul(C,R));return B&&S}negate(){return new z(this.px,$.neg(this.py),this.pz)}double(){let{a:j,b:W}=Q,D=$.mul(W,b$),{px:R,py:L,pz:C}=this,H=$.ZERO,B=$.ZERO,S=$.ZERO,A=$.mul(R,R),m=$.mul(L,L),F=$.mul(C,C),N=$.mul(R,L);return N=$.add(N,N),S=$.mul(R,C),S=$.add(S,S),H=$.mul(j,S),B=$.mul(D,F),B=$.add(H,B),H=$.sub(m,B),B=$.add(m,B),B=$.mul(H,B),H=$.mul(N,H),S=$.mul(D,S),F=$.mul(j,F),N=$.sub(A,F),N=$.mul(j,N),N=$.add(N,S),S=$.add(A,A),A=$.add(S,A),A=$.add(A,F),A=$.mul(A,N),B=$.add(B,A),F=$.mul(L,C),F=$.add(F,F),A=$.mul(F,N),H=$.sub(H,A),S=$.mul(F,m),S=$.add(S,S),S=$.add(S,S),new z(H,B,S)}add(j){I(j);let{px:W,py:D,pz:R}=this,{px:L,py:C,pz:H}=j,B=$.ZERO,S=$.ZERO,A=$.ZERO,m=Q.a,F=$.mul(Q.b,b$),N=$.mul(W,L),V=$.mul(D,C),k=$.mul(R,H),_=$.add(W,D),P=$.add(L,C);_=$.mul(_,P),P=$.add(N,V),_=$.sub(_,P),P=$.add(W,R);let E=$.add(L,H);return P=$.mul(P,E),E=$.add(N,k),P=$.sub(P,E),E=$.add(D,R),B=$.add(C,H),E=$.mul(E,B),B=$.add(V,k),E=$.sub(E,B),A=$.mul(m,P),B=$.mul(F,k),A=$.add(B,A),B=$.sub(V,A),A=$.add(V,A),S=$.mul(B,A),V=$.add(N,N),V=$.add(V,N),k=$.mul(m,k),P=$.mul(F,P),V=$.add(V,k),k=$.sub(N,k),k=$.mul(m,k),P=$.add(P,k),N=$.mul(V,P),S=$.add(S,N),N=$.mul(E,P),B=$.mul(_,B),B=$.sub(B,N),N=$.mul(_,V),A=$.mul(E,A),A=$.add(A,N),new z(B,S,A)}subtract(j){return this.add(j.negate())}is0(){return this.equals(z.ZERO)}wNAF(j){return f.wNAFCached(this,j,z.normalizeZ)}multiplyUnsafe(j){let{endo:W,n:D}=Q;RJ("scalar",j,XJ,D);let R=z.ZERO;if(j===XJ)return R;if(this.is0()||j===b)return this;if(!W||f.hasPrecomputes(this))return f.wNAFCachedUnsafe(this,j,z.normalizeZ);let{k1neg:L,k1:C,k2neg:H,k2:B}=W.splitScalar(j),S=R,A=R,m=this;while(C>XJ||B>XJ){if(C&b)S=S.add(m);if(B&b)A=A.add(m);m=m.double(),C>>=b,B>>=b}if(L)S=S.negate();if(H)A=A.negate();return A=new z($.mul(A.px,W.beta),A.py,A.pz),S.add(A)}multiply(j){let{endo:W,n:D}=Q;RJ("scalar",j,b,D);let R,L;if(W){let{k1neg:C,k1:H,k2neg:B,k2:S}=W.splitScalar(j),{p:A,f:m}=this.wNAF(H),{p:F,f:N}=this.wNAF(S);A=f.constTimeNegate(C,A),F=f.constTimeNegate(B,F),F=new z($.mul(F.px,W.beta),F.py,F.pz),R=A.add(F),L=m.add(N)}else{let{p:C,f:H}=this.wNAF(j);R=C,L=H}return z.normalizeZ([R,L])[0]}multiplyAndAddUnsafe(j,W,D){let R=z.BASE,L=(H,B)=>B===XJ||B===b||!H.equals(R)?H.multiplyUnsafe(B):H.multiply(B),C=L(this,W).add(L(j,D));return C.is0()?void 0:C}toAffine(j){return w(this,j)}isTorsionFree(){let{h:j,isTorsionFree:W}=Q;if(j===b)return!0;if(W)return W(z,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:j,clearCofactor:W}=Q;if(j===b)return this;if(W)return W(z,this);return this.multiplyUnsafe(Q.h)}toRawBytes(j=!0){return gJ("isCompressed",j),this.assertValidity(),Y(z,this,j)}toHex(j=!0){return gJ("isCompressed",j),FJ(this.toRawBytes(j))}}z.BASE=new z(Q.Gx,Q.Gy,$.ONE),z.ZERO=new z($.ZERO,$.ONE,$.ZERO);let{endo:v,nBitLength:x}=Q,f=r0(z,v?Math.ceil(x/2):x);return{CURVE:Q,ProjectivePoint:z,normPrivateKeyToScalar:O,weierstrassEquation:Z,isWithinCurveOrder:U}}function bQ(J){let Q=f$(J);return LJ(Q,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...Q})}function e0(J){let Q=bQ(J),{Fp:$,n:q,nByteLength:Y,nBitLength:G}=Q,Z=$.BYTES+1,X=2*$.BYTES+1;function K(N){return h(N,q)}function M(N){return X$(N,q)}let{ProjectivePoint:U,normPrivateKeyToScalar:O,weierstrassEquation:I,isWithinCurveOrder:w}=yQ({...Q,toBytes(N,V,k){let _=V.toAffine(),P=$.toBytes(_.x),E=oJ;if(gJ("isCompressed",k),k)return E(Uint8Array.from([V.hasEvenY()?2:3]),P);else return E(Uint8Array.from([4]),P,$.toBytes(_.y))},fromBytes(N){let V=N.length,k=N[0],_=N.subarray(1);if(V===Z&&(k===2||k===3)){let P=ZJ(_);if(!K$(P,b,$.ORDER))throw Error("Point is not on curve");let E=I(P),n;try{n=$.sqrt(E)}catch(s){let c=s instanceof Error?": "+s.message:"";throw Error("Point is not on curve"+c)}let l=(n&b)===b;if((k&1)===1!==l)n=$.neg(n);return{x:P,y:n}}else if(V===X&&k===4){let P=$.fromBytes(_.subarray(0,$.BYTES)),E=$.fromBytes(_.subarray($.BYTES,2*$.BYTES));return{x:P,y:E}}else{let P=Z,E=X;throw Error("invalid Point, expected length of "+P+", or uncompressed "+E+", got "+V)}}});function T(N){let V=q>>b;return N>V}function z(N){return T(N)?K(-N):N}let v=(N,V,k)=>ZJ(N.slice(V,k));class x{constructor(N,V,k){if(RJ("r",N,b,q),RJ("s",V,b,q),this.r=N,this.s=V,k!=null)this.recovery=k;Object.freeze(this)}static fromCompact(N){let V=Y;return N=p("compactSignature",N,V*2),new x(v(N,0,V),v(N,V,2*V))}static fromDER(N){let{r:V,s:k}=KJ.toSig(p("DER",N));return new x(V,k)}assertValidity(){}addRecoveryBit(N){return new x(this.r,this.s,N)}recoverPublicKey(N){let{r:V,s:k,recovery:_}=this,P=L(p("msgHash",N));if(_==null||![0,1,2,3].includes(_))throw Error("recovery id invalid");let E=_===2||_===3?V+Q.n:V;if(E>=$.ORDER)throw Error("recovery id 2 or 3 invalid");let n=(_&1)===0?"02":"03",l=U.fromHex(n+y$(E,$.BYTES)),a=M(E),s=K(-P*a),c=K(k*a),MJ=U.BASE.multiplyAndAddUnsafe(l,s,c);if(!MJ)throw Error("point at infinify");return MJ.assertValidity(),MJ}hasHighS(){return T(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,K(-this.s),this.recovery):this}toDERRawBytes(){return nJ(this.toDERHex())}toDERHex(){return KJ.hexFromSig(this)}toCompactRawBytes(){return nJ(this.toCompactHex())}toCompactHex(){let N=Y;return y$(this.r,N)+y$(this.s,N)}}let f={isValidPrivateKey(N){try{return O(N),!0}catch(V){return!1}},normPrivateKeyToScalar:O,randomPrivateKey:()=>{let N=E$(Q.n);return c0(Q.randomBytes(N),Q.n)},precompute(N=8,V=U.BASE){return V._setWindowSize(N),V.multiply(BigInt(3)),V}};function j(N,V=!0){return U.fromPrivateKey(N).toRawBytes(V)}function W(N){if(typeof N==="bigint")return!1;if(N instanceof U)return!0;let k=p("key",N).length,_=$.BYTES,P=_+1,E=2*_+1;if(Q.allowedPrivateKeyLengths||Y===P)return;else return k===P||k===E}function D(N,V,k=!0){if(W(N)===!0)throw Error("first arg must be private key");if(W(V)===!1)throw Error("second arg must be public key");return U.fromHex(V).multiply(O(N)).toRawBytes(k)}let R=Q.bits2int||function(N){if(N.length>8192)throw Error("input is too large");let V=ZJ(N),k=N.length*8-G;return k>0?V>>BigInt(k):V},L=Q.bits2int_modN||function(N){return K(R(N))},C=wJ(G);function H(N){return RJ("num < 2^"+G,N,XJ,C),IJ(N,Y)}function B(N,V,k=S){if(["recovered","canonical"].some((NJ)=>(NJ in k)))throw Error("sign() legacy options not supported");let{hash:_,randomBytes:P}=Q,{lowS:E,prehash:n,extraEntropy:l}=k;if(E==null)E=!0;if(N=p("msgHash",N),s0(k),n)N=p("prehashed msgHash",_(N));let a=L(N),s=O(V),c=[H(s),H(a)];if(l!=null&&l!==!1){let NJ=l===!0?P($.BYTES):l;c.push(p("extraEntropy",NJ))}let MJ=oJ(...c),aJ=a;function M$(NJ){let PJ=R(NJ);if(!w(PJ))return;let U$=M(PJ),fJ=U.BASE.multiply(PJ).toAffine(),WJ=K(fJ.x);if(WJ===XJ)return;let yJ=K(U$*K(aJ+WJ*s));if(yJ===XJ)return;let CJ=(fJ.x===WJ?0:2)|Number(fJ.y&b),l$=yJ;if(E&&T(yJ))l$=z(yJ),CJ^=1;return new x(WJ,l$,CJ)}return{seed:MJ,k2sig:M$}}let S={lowS:Q.lowS,prehash:!1},A={lowS:Q.lowS,prehash:!1};function m(N,V,k=S){let{seed:_,k2sig:P}=B(N,V,k),E=Q;return y0(E.hash.outputLen,E.nByteLength,E.hmac)(_,P)}U.BASE._setWindowSize(8);function F(N,V,k,_=A){let P=N;V=p("msgHash",V),k=p("publicKey",k);let{lowS:E,prehash:n,format:l}=_;if(s0(_),"strict"in _)throw Error("options.strict was renamed to lowS");if(l!==void 0&&l!=="compact"&&l!=="der")throw Error("format must be compact or der");let a=typeof P==="string"||vJ(P),s=!a&&!l&&typeof P==="object"&&P!==null&&typeof P.r==="bigint"&&typeof P.s==="bigint";if(!a&&!s)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");let c=void 0,MJ;try{if(s)c=new x(P.r,P.s);if(a){try{if(l!=="compact")c=x.fromDER(P)}catch(CJ){if(!(CJ instanceof KJ.Err))throw CJ}if(!c&&l!=="der")c=x.fromCompact(P)}MJ=U.fromHex(k)}catch(CJ){return!1}if(!c)return!1;if(E&&c.hasHighS())return!1;if(n)V=Q.hash(V);let{r:aJ,s:M$}=c,NJ=L(V),PJ=M(M$),U$=K(NJ*PJ),fJ=K(aJ*PJ),WJ=U.BASE.multiplyAndAddUnsafe(MJ,U$,fJ)?.toAffine();if(!WJ)return!1;return K(WJ.x)===aJ}return{CURVE:Q,getPublicKey:j,getSharedSecret:D,sign:m,verify:F,ProjectivePoint:U,Signature:x,utils:f}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function mQ(J){return{hash:J,hmac:(Q,...$)=>D$(J,Q,e$(...$)),randomBytes:J0}}function J8(J,Q){let $=(q)=>e0({...J,...mQ(q)});return{...$(Q),create:$}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var q8=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$8=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),hQ=BigInt(0),uQ=BigInt(1),m$=BigInt(2),Q8=(J,Q)=>(J+Q/m$)/Q;function lQ(J){let Q=q8,$=BigInt(3),q=BigInt(6),Y=BigInt(11),G=BigInt(22),Z=BigInt(23),X=BigInt(44),K=BigInt(88),M=J*J*J%Q,U=M*M*J%Q,O=i(U,$,Q)*U%Q,I=i(O,$,Q)*U%Q,w=i(I,m$,Q)*M%Q,T=i(w,Y,Q)*w%Q,z=i(T,G,Q)*T%Q,v=i(z,X,Q)*z%Q,x=i(v,K,Q)*v%Q,f=i(x,X,Q)*z%Q,j=i(f,$,Q)*U%Q,W=i(j,Z,Q)*T%Q,D=i(W,q,Q)*M%Q,R=i(D,m$,Q);if(!h$.eql(h$.sqr(R),J))throw Error("Cannot find square root");return R}var h$=rJ(q8,void 0,void 0,{sqrt:lQ}),u$=J8({a:hQ,b:BigInt(7),Fp:h$,n:$8,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:(J)=>{let Q=$8,$=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),q=-uQ*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),Y=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),G=$,Z=BigInt("0x100000000000000000000000000000000"),X=Q8(G*J,Q),K=Q8(-q*J,Q),M=h(J-X*$-K*Y,Q),U=h(-X*q-K*G,Q),O=M>Z,I=U>Z;if(O)M=Q-M;if(I)U=Q-U;if(M>Z||U>Z)throw Error("splitScalar: Endomorphism failed, k="+J);return{k1neg:O,k1:M,k2neg:I,k2:U}}}},x0);function dQ(){let J=u$.utils.randomPrivateKey();return"0x"+Buffer.from(J).toString("hex")}function cQ(J){let Q=J.startsWith("0x")?J.slice(2):J,$=Buffer.from(Q,"hex"),q=u$.getPublicKey($,!1),G=DJ(q.slice(1)).slice(-20),Z="0x"+Buffer.from(G).toString("hex");return q$(Z)}function pQ(J){let Q;if(typeof J==="string"){let q=J.startsWith("0x")?J.slice(2):J;Q=Buffer.from(q,"hex")}else Q=J;let $=DJ(Q);return"0x"+Buffer.from($).toString("hex")}export{DQ as wrapError,UQ as uint256ToAddress,cQ as privateKeyToAddress,A0 as parseContractError,pQ as keccak256,B0 as isCirclesError,Y8 as hexToBytes,IQ as getErrorMessage,dQ as generatePrivateKey,S8 as encodeFunctionData,x8 as encodeAbiParameters,H8 as decodeFunctionResult,W$ as decodeErrorResult,TQ as circlesConfig,MQ as cidV0ToUint8Array,XQ as cidV0ToHex,q$ as checksumAddress,bJ as bytesToHex,jQ as ZERO_ADDRESS,_J as ValidationError,zQ as SAFE_PROXY_FACTORY,WQ as MAX_FLOW,NQ as INVITATION_FEE,G$ as EncodingError,Z$ as ContractError,QJ as CirclesError,d$ as CirclesConverter,OQ as ACCOUNT_INITIALIZER_HASH,VQ as ACCOUNT_CREATION_CODE_HASH};
|