@dodoex/wallet-web3 0.4.1-rise.1 → 0.4.1-rise.2
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/{alchemy-provider-5870b6fa-bb85ec6a.js → alchemy-provider-5870b6fa-e05de000.js} +1 -1
- package/dist/{alchemy-websocket-provider-213da986-d5400b6b.js → alchemy-websocket-provider-213da986-e04e20e5.js} +1 -1
- package/dist/{blocto-eff0b92d.js → blocto-97587019.js} +1 -1
- package/dist/{ccip-8aed4fac.js → ccip-0db5fcae.js} +1 -1
- package/dist/{ccip-f0761404.js → ccip-c37d418e.js} +1 -1
- package/dist/cjs/{alchemy-provider-5870b6fa-382979ef.cjs → alchemy-provider-5870b6fa-e24212d7.cjs} +1 -1
- package/dist/cjs/{alchemy-websocket-provider-213da986-4ce7835d.cjs → alchemy-websocket-provider-213da986-84543bd0.cjs} +1 -1
- package/dist/cjs/{blocto-14fc9f60.cjs → blocto-7c451e4d.cjs} +1 -1
- package/dist/cjs/{ccip-a1973409.cjs → ccip-3251edc4.cjs} +1 -1
- package/dist/cjs/{ccip-2b0ca597.cjs → ccip-e99c5ad4.cjs} +1 -1
- package/dist/cjs/{draggabilly-5c6a8eb9.cjs → draggabilly-f5a8f0d3.cjs} +1 -1
- package/dist/cjs/id-1447427c.cjs +1 -0
- package/dist/cjs/{index-34ad5f20.cjs → index-02f31a88.cjs} +1 -1
- package/dist/cjs/{index-5ce728f7.cjs → index-2e9d24e4.cjs} +4 -4
- package/dist/cjs/{index-21073eb0.cjs → index-37e9b5f9.cjs} +1 -1
- package/dist/cjs/{index-0eb47a78.cjs → index-79b6b22d.cjs} +1 -1
- package/dist/cjs/{index-418ee7e2.cjs → index-a167f18c.cjs} +1 -1
- package/dist/cjs/{index-67de37f3.cjs → index-a64ff146.cjs} +1 -1
- package/dist/cjs/{index-5d7df663.cjs → index-c46d1215.cjs} +1 -1
- package/dist/cjs/{index-ddd9f3b1.cjs → index-cae93f1f.cjs} +1 -1
- package/dist/cjs/{index-d2b3e830.cjs → index-d0e2d4e2.cjs} +3 -3
- package/dist/cjs/{index-6507817d.cjs → index-ed87a9e3.cjs} +2 -2
- package/dist/cjs/{index-ceef92b9.cjs → index-f810457d.cjs} +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/{index.es-26c6ee46.cjs → index.es-a1c165d6.cjs} +1 -1
- package/dist/cjs/{interface-301bc9d4.cjs → interface-a406ad88.cjs} +1 -1
- package/dist/cjs/lib-typedarrays-57096314.cjs +1 -0
- package/dist/cjs/{portis-6ae03796.cjs → portis-25ec3385.cjs} +1 -1
- package/dist/cjs/{provider-aec1ee59.cjs → provider-e1c77615.cjs} +1 -1
- package/dist/cjs/{rainbow-920371d7.cjs → rainbow-c04bf66f.cjs} +1 -1
- package/dist/cjs/{secp256k1-88c91671.cjs → secp256k1-91126b50.cjs} +1 -1
- package/dist/cjs/sha224-a1c60756.cjs +1 -0
- package/dist/cjs/{sha256-559d937c.cjs → sha256-19da1b79.cjs} +1 -1
- package/dist/cjs/{typed-data-2ac6e5bb.cjs → typed-data-86473c70.cjs} +1 -1
- package/dist/cjs/uAuth-31d0a167.cjs +1 -0
- package/dist/cjs/{walletConnect-1514d700.cjs → walletConnect-f85e4bb9.cjs} +1 -1
- package/dist/cjs/{walletLink-5879a68b.cjs → walletLink-7c24a1d7.cjs} +1 -1
- package/dist/{draggabilly-f3461ab1.js → draggabilly-81fdc066.js} +1 -1
- package/dist/id-a2df48d3.js +1 -0
- package/dist/{index-ad6d7603.js → index-07138828.js} +1 -1
- package/dist/{index-14f309d2.js → index-11df9422.js} +1 -1
- package/dist/{index-4b6c652e.js → index-3fc26524.js} +1 -1
- package/dist/{index-01b9db23.js → index-760f75a7.js} +1 -1
- package/dist/{index-31a37014.js → index-7b780725.js} +3 -3
- package/dist/{index-b6f1e8cc.js → index-83d37806.js} +2 -2
- package/dist/{index-c8e0cbe6.js → index-bc033af5.js} +1 -1
- package/dist/{index-c836d1b2.js → index-e2de6ccc.js} +4 -4
- package/dist/{index-e01611dd.js → index-f3e2bf95.js} +1 -1
- package/dist/{index-fff9fb0c.js → index-fa588d6b.js} +2 -2
- package/dist/{index-609bf40c.js → index-ff800c71.js} +1 -1
- package/dist/{index.es-9ce4fdd7.js → index.es-8feb0512.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{interface-226cc3e0.js → interface-1eb95ed0.js} +1 -1
- package/dist/lib-typedarrays-f580c438.js +1 -0
- package/dist/{portis-9112d997.js → portis-cb3a4ac8.js} +1 -1
- package/dist/{provider-1e6242a3.js → provider-1414b238.js} +1 -1
- package/dist/{rainbow-280f7951.js → rainbow-d286c290.js} +1 -1
- package/dist/{secp256k1-d403d4c1.js → secp256k1-501de86d.js} +1 -1
- package/dist/sha224-98feba8e.js +1 -0
- package/dist/{sha256-ecf76121.js → sha256-ab11a2f8.js} +1 -1
- package/dist/{typed-data-cfc1152c.js → typed-data-4720c77b.js} +1 -1
- package/dist/uAuth-a0882ace.js +1 -0
- package/dist/{walletConnect-6bf9ed97.js → walletConnect-5b288c1f.js} +1 -1
- package/dist/{walletLink-0444bb94.js → walletLink-541d2c47.js} +1 -1
- package/package.json +1 -1
- package/dist/cjs/id-030fb120.cjs +0 -1
- package/dist/cjs/lib-typedarrays-e51b5d1f.cjs +0 -1
- package/dist/cjs/sha224-44664857.cjs +0 -1
- package/dist/cjs/uAuth-63dec270.cjs +0 -1
- package/dist/id-155c1875.js +0 -1
- package/dist/lib-typedarrays-c1439d8d.js +0 -1
- package/dist/sha224-34dbb09c.js +0 -1
- package/dist/uAuth-2883581a.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a1 as e,_ as t,A as n}from"./index-c836d1b2.js";import"@ethersproject/address";class r extends Error{constructor(e,t={}){const n=t.cause instanceof r?t.cause.details:t.cause?.message?t.cause.message:t.details,s=t.cause instanceof r&&t.cause.docsPath||t.docsPath;super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...n?[`Details: ${n}`]:[],"Version: abitype@1.0.8"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),t.cause&&(this.cause=t.cause),this.details=n,this.docsPath=s,this.metaMessages=t.metaMessages,this.shortMessage=e}}function s(e,t){const n=e.exec(t);return n?.groups}const i=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,a=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,o=/^\(.+?\).*?$/,c=/^tuple(?<array>(\[(\d*)\])*)$/;function u(e){let t=e.type;if(c.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=u(e.components[r]),r<n-1&&(t+=", ")}const r=s(c,e.type);return t+=`)${r?.array??""}`,u({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function d(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=u(e[r]),r!==n-1&&(t+=", ")}return t}const l=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const f=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const p=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const h=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function m(e){return h.test(e)}function y(e){return s(h,e)}const b=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const g=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const w=/^receive\(\) external payable$/;const v=new Set(["indexed"]),x=new Set(["calldata","memory","storage"]);class I extends r{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class P extends r{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class z extends r{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class E extends r{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class A extends r{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class k extends r{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class M extends r{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class $ extends r{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class O extends r{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class j extends r{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class S extends r{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class N extends r{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const T=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function _(e,t={}){if(function(e){return p.test(e)}(e))return function(e,t={}){const n=function(e){return s(p,e)}(e);if(!n)throw new $({signature:e,type:"function"});const r=U(n.parameters),i=[],a=r.length;for(let e=0;e<a;e++)i.push(D(r[e],{modifiers:x,structs:t,type:"function"}));const o=[];if(n.returns){const e=U(n.returns),r=e.length;for(let n=0;n<r;n++)o.push(D(e[n],{modifiers:x,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:i,outputs:o}}(e,t);if(function(e){return f.test(e)}(e))return function(e,t={}){const n=function(e){return s(f,e)}(e);if(!n)throw new $({signature:e,type:"event"});const r=U(n.parameters),i=[],a=r.length;for(let e=0;e<a;e++)i.push(D(r[e],{modifiers:v,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:i}}(e,t);if(function(e){return l.test(e)}(e))return function(e,t={}){const n=function(e){return s(l,e)}(e);if(!n)throw new $({signature:e,type:"error"});const r=U(n.parameters),i=[],a=r.length;for(let e=0;e<a;e++)i.push(D(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:i}}(e,t);if(function(e){return b.test(e)}(e))return function(e,t={}){const n=function(e){return s(b,e)}(e);if(!n)throw new $({signature:e,type:"constructor"});const r=U(n.parameters),i=[],a=r.length;for(let e=0;e<a;e++)i.push(D(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:i}}(e,t);if(function(e){return g.test(e)}(e))return function(e){const t=function(e){return s(g,e)}(e);if(!t)throw new $({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return w.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new O({signature:e})}const R=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,C=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,B=/^u?int$/;function D(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:e}(e,t?.type,t?.structs);if(T.has(n))return T.get(n);const r=o.test(e),c=s(r?C:R,e);if(!c)throw new z({param:e});if(c.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||i.test(e)||a.test(e)||L.test(e)}(c.name))throw new E({param:e,name:c.name});const u=c.name?{name:c.name}:{},d="indexed"===c.modifier?{indexed:!0}:{},l=t?.structs??{};let f,p={};if(r){f="tuple";const e=U(c.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(D(e[r],{structs:l}));p={components:t}}else if(c.type in l)f="tuple",p={components:l[c.type]};else if(B.test(c.type))f=`${c.type}256`;else if(f=c.type,"struct"!==t?.type&&!q(f))throw new P({type:f});if(c.modifier){if(!t?.modifiers?.has?.(c.modifier))throw new A({param:e,type:t?.type,modifier:c.modifier});if(x.has(c.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(f,!!c.array))throw new k({param:e,type:t?.type,modifier:c.modifier})}const h={type:`${f}${c.array??""}`,...u,...d,...p};return T.set(n,h),h}function U(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const s=e[i],a=e.slice(i+1);switch(s){case",":return 0===r?U(a,[...t,n.trim()]):U(a,t,`${n}${s}`,r);case"(":return U(a,t,`${n}${s}`,r+1);case")":return U(a,t,`${n}${s}`,r-1);default:return U(a,t,`${n}${s}`,r)}}if(""===n)return t;if(0!==r)throw new N({current:n,depth:r});return t.push(n.trim()),t}function q(e){return"address"===e||"bool"===e||"function"===e||"string"===e||i.test(e)||a.test(e)}const L=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;const F=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function K(e,t,n=new Set){const r=[],i=e.length;for(let a=0;a<i;a++){const i=e[a];if(o.test(i.type))r.push(i);else{const e=s(F,i.type);if(!e?.type)throw new M({abiParameter:i});const{array:a,type:o}=e;if(o in t){if(n.has(o))throw new S({type:o});r.push({...i,type:`tuple${a??""}`,components:K(t[o]??[],t,new Set([...n,o]))})}else{if(!q(o))throw new I({type:o});r.push(i)}}}return r}function V(e){const t=function(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!m(n))continue;const s=y(n);if(!s)throw new $({signature:n,type:"struct"});const i=s.properties.split(";"),a=[],o=i.length;for(let e=0;e<o;e++){const t=i[e].trim();if(!t)continue;const n=D(t,{type:"struct"});a.push(n)}if(!a.length)throw new j({signature:n});t[s.name]=a}const r={},s=Object.entries(t),i=s.length;for(let e=0;e<i;e++){const[n,i]=s[e];r[n]=K(i,t)}return r}(e),n=[],r=e.length;for(let s=0;s<r;s++){const r=e[s];m(r)||n.push(_(r,t))}return n}function G(e,t,n){const r=e[t.name];if("function"==typeof r)return r;const s=e[n];return"function"==typeof s?s:n=>t(e,n)}function Z(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new ve(e.type);return`${e.name}(${H(e.inputs,{includeName:t})})`}function H(e,{includeName:t=!1}={}){return e?e.map((e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${H(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t}))).join(t?", ":","):""}function W(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function Y(e){return W(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Q="2.37.0";let J=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,X=`viem@${Q}`;class ee extends Error{constructor(e,t={}){const n=t.cause instanceof ee?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof ee&&t.cause.docsPath||t.docsPath,s=J?.({...t,docsPath:r});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...X?[`Version: ${X}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=Q}walk(e){return te(this,e)}}function te(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?te(e.cause,t):t?null:e}class ne extends ee{constructor({docsPath:e}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join("\n"),{docsPath:e,name:"AbiConstructorNotFoundError"})}}class re extends ee{constructor({docsPath:e}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join("\n"),{docsPath:e,name:"AbiConstructorParamsNotFoundError"})}}class se extends ee{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${H(t,{includeName:!0})})`,`Data: ${e} (${n} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=t,this.size=n}}class ie extends ee{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class ae extends ee{constructor({expectedLength:e,givenLength:t,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${e}`,`Given length: ${t}`].join("\n"),{name:"AbiEncodingArrayLengthMismatchError"})}}class oe extends ee{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Y(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class ce extends ee{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${t}`].join("\n"),{name:"AbiEncodingLengthMismatchError"})}}class ue extends ee{constructor(e,{docsPath:t}){super([`Arguments (\`args\`) were provided to "${e}", but "${e}" on the ABI does not contain any parameters (\`inputs\`).`,"Cannot encode error result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the inputs exist on it."].join("\n"),{docsPath:t,name:"AbiErrorInputsNotFoundError"})}}class de extends ee{constructor(e,{docsPath:t}={}){super([`Error ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join("\n"),{docsPath:t,name:"AbiErrorNotFoundError"})}}class le extends ee{constructor(e,{docsPath:t}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join("\n"),{docsPath:t,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class fe extends ee{constructor(e,{docsPath:t}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:t,name:"AbiFunctionNotFoundError"})}}class pe extends ee{constructor(e,{docsPath:t}){super([`Function "${e}" does not contain any \`outputs\` on ABI.`,"Cannot decode function result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:t,name:"AbiFunctionOutputsNotFoundError"})}}class he extends ee{constructor(e,{docsPath:t}){super([`Encoded function signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${e}.`].join("\n"),{docsPath:t,name:"AbiFunctionSignatureNotFoundError"})}}class me extends ee{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${Z(e.abiItem)}\`, and`,`\`${t.type}\` in \`${Z(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class ye extends ee{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}}class be extends ee{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiEncodingType"})}}class ge extends ee{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiDecodingType"})}}class we extends ee{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}}class ve extends ee{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class xe extends ee{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class Ie extends ee{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}class Pe extends ee{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function ze(e,{dir:t,size:n=32}={}){return"string"==typeof e?Ee(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new Ie({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i="right"===t;r[i?s:n-s-1]=e[i?s:e.length-s-1]}return r}(e,{dir:t,size:n})}function Ee(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new Ie({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}class Ae extends ee{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number "${s}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class ke extends ee{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class Me extends ee{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class $e extends ee{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Oe(e,{dir:t="left"}={}){let n="string"==typeof e?e.replace("0x",""):e,r=0;for(let e=0;e<n.length-1&&"0"===n["left"===t?e:n.length-e-1].toString();e++)r++;return n="left"===t?n.slice(r):n.slice(0,n.length-r),"string"==typeof e?(1===n.length&&"right"===t&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}function je(e,{size:t}){if(Y(e)>t)throw new $e({givenSize:Y(e),maxSize:t})}function Se(e,t={}){const{signed:n}=t;t.size&&je(e,{size:t.size});const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2;return r<=(1n<<8n*BigInt(s)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*s,"f")}`)-1n}function Ne(e,t={}){return Number(Se(e,t))}const Te=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function _e(e,t={}){return"number"==typeof e||"bigint"==typeof e?Be(e,t):"string"==typeof e?Ue(e,t):"boolean"==typeof e?Re(e,t):Ce(e,t)}function Re(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(je(n,{size:t.size}),ze(n,{size:t.size})):n}function Ce(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Te[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(je(r,{size:t.size}),ze(r,{dir:"right",size:t.size})):r}function Be(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new Ae({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?(1n<<BigInt(8*r))+BigInt(s):s).toString(16)}`;return r?ze(o,{size:r}):o}const De=new TextEncoder;function Ue(e,t={}){return Ce(De.encode(e),t)}const qe=new TextEncoder;function Le(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=Be(e,t);return Ve(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return je(n,{size:t.size}),ze(n,{size:t.size});return n}(e,t):W(e)?Ve(e,t):Ge(e,t)}const Fe={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ke(e){return e>=Fe.zero&&e<=Fe.nine?e-Fe.zero:e>=Fe.A&&e<=Fe.F?e-(Fe.A-10):e>=Fe.a&&e<=Fe.f?e-(Fe.a-10):void 0}function Ve(e,t={}){let n=e;t.size&&(je(n,{size:t.size}),n=ze(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let e=0,t=0;e<s;e++){const n=Ke(r.charCodeAt(t++)),s=Ke(r.charCodeAt(t++));if(void 0===n||void 0===s)throw new ee(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);i[e]=16*n+s}return i}function Ge(e,t={}){const n=qe.encode(e);return"number"==typeof t.size?(je(n,{size:t.size}),ze(n,{dir:"right",size:t.size})):n}const Ze=BigInt(2**32-1),He=BigInt(32);function We(e,t=!1){return t?{h:Number(e&Ze),l:Number(e>>He&Ze)}:{h:0|Number(e>>He&Ze),l:0|Number(e&Ze)}}function Ye(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:a}=We(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]}const Qe=(e,t,n)=>e>>>n,Je=(e,t,n)=>e<<32-n|t>>>n,Xe=(e,t,n)=>e>>>n|t<<32-n,et=(e,t,n)=>e<<32-n|t>>>n,tt=(e,t,n)=>e<<64-n|t>>>n-32,nt=(e,t,n)=>e>>>n-32|t<<64-n;function rt(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:0|s}}const st=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),it=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,at=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),ot=(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,ct=(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0),ut=(e,t,n,r,s,i)=>t+n+r+s+i+(e/2**32|0)|0,dt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function lt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ft(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function pt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ht(e,t){ft(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function mt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function yt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function bt(e,t){return e<<32-t|e>>>t}const gt=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let n=0;n<e.length;n++)e[n]=(t=e[n])<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;var t;return e};function wt(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),ft(e),e}class vt{}function xt(e){const t=t=>e().update(wt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function It(e=32){if(dt&&"function"==typeof dt.getRandomValues)return dt.getRandomValues(new Uint8Array(e));if(dt&&"function"==typeof dt.randomBytes)return Uint8Array.from(dt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const Pt=BigInt(0),zt=BigInt(1),Et=BigInt(2),At=BigInt(7),kt=BigInt(256),Mt=BigInt(113),$t=[],Ot=[],jt=[];for(let e=0,t=zt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],$t.push(2*(5*r+n)),Ot.push((e+1)*(e+2)/2%64);let s=Pt;for(let e=0;e<7;e++)t=(t<<zt^(t>>At)*Mt)%kt,t&Et&&(s^=zt<<(zt<<BigInt(e))-zt);jt.push(s)}const St=Ye(jt,!0),Nt=St[0],Tt=St[1],_t=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),Rt=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class Ct extends vt{constructor(e,t,n,r=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=s,lt(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var i;this.state=new Uint8Array(200),this.state32=(i=this.state,new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)))}clone(){return this._cloneInto()}keccak(){gt(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,s=(t+2)%10,i=n[s],a=n[s+1],o=_t(i,a,1)^n[r],c=Rt(i,a,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=c}let t=e[2],s=e[3];for(let n=0;n<24;n++){const r=Ot[n],i=_t(t,s,r),a=Rt(t,s,r),o=$t[n];t=e[o],s=e[o+1],e[o]=i,e[o+1]=a}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=Nt[r],e[1]^=Tt[r]}mt(n)}(this.state32,this.rounds),gt(this.state32),this.posOut=0,this.pos=0}update(e){pt(this),ft(e=wt(e));const{blockLen:t,state:n}=this,r=e.length;for(let s=0;s<r;){const i=Math.min(t-this.pos,r-s);for(let t=0;t<i;t++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,0!=(128&t)&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){pt(this,!1),ft(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,s=e.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return lt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ht(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,mt(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return e||(e=new Ct(t,n,r,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}const Bt=(()=>{return e=1,t=136,n=32,xt((()=>new Ct(t,e,n)));var e,t,n})();function Dt(e,t){const n=t||"hex",r=Bt(W(e,{strict:!1})?Le(e):e);return"bytes"===n?r:_e(r)}const Ut=e=>Dt(Le(e));const qt=e=>{var t;return function(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),"("===o&&r++,")"===o&&r--,t)if(0!==r)" "!==o?(s+=o,n+=o):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===o&&["event","function",""].includes(s))s="";else if(s+=o,")"===o){i=!0;break}}if(!i)throw new ee("Unable to normalize signature.");return s}("string"==typeof e?e:"function"===(t=e).type?`function ${t.name}(${d(t.inputs)})${t.stateMutability&&"nonpayable"!==t.stateMutability?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${d(t.outputs)})`:""}`:"event"===t.type?`event ${t.name}(${d(t.inputs)})`:"error"===t.type?`error ${t.name}(${d(t.inputs)})`:"constructor"===t.type?`constructor(${d(t.inputs)})${"payable"===t.stateMutability?" payable":""}`:"fallback"===t.type?"fallback() external"+("payable"===t.stateMutability?" payable":""):"receive() external payable")};function Lt(e){return t=qt(e),Ut(t);var t}const Ft=Lt;class Kt extends ee{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Vt extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const Gt=new Vt(8192);function Zt(e,t){if(Gt.has(`${e}.${t}`))return Gt.get(`${e}.${t}`);const n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Dt(Ge(n),"bytes"),s=(t?n.substring(`${t}0x`.length):n).split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&s[e]&&(s[e]=s[e].toUpperCase()),(15&r[e>>1])>=8&&s[e+1]&&(s[e+1]=s[e+1].toUpperCase());const i=`0x${s.join("")}`;return Gt.set(`${e}.${t}`,i),i}function Ht(e,t){if(!Qt(e,{strict:!1}))throw new Kt({address:e});return Zt(e,t)}const Wt=/^0x[a-fA-F0-9]{40}$/,Yt=new Vt(8192);function Qt(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Yt.has(r))return Yt.get(r);const s=!(!Wt.test(e)||e.toLowerCase()!==e&&n&&Zt(e)!==e);return Yt.set(r,s),s}function Jt(e){return"string"==typeof e[0]?Xt(e):function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(e)}function Xt(e){return`0x${e.reduce(((e,t)=>e+t.replace("0x","")),"")}`}function en(e,t,n,{strict:r}={}){return W(e,{strict:!1})?sn(e,t,n,{strict:r}):rn(e,t,n,{strict:r})}function tn(e,t){if("number"==typeof t&&t>0&&t>Y(e)-1)throw new xe({offset:t,position:"start",size:Y(e)})}function nn(e,t,n){if("number"==typeof t&&"number"==typeof n&&Y(e)!==n-t)throw new xe({offset:n,position:"end",size:Y(e)})}function rn(e,t,n,{strict:r}={}){tn(e,t);const s=e.slice(t,n);return r&&nn(s,t,n),s}function sn(e,t,n,{strict:r}={}){tn(e,t);const s=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return r&&nn(s,t,n),s}const an=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,on=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function cn(e,t){if(e.length!==t.length)throw new ce({expectedLength:e.length,givenLength:t.length});const n=function({params:e,values:t}){const n=[];for(let r=0;r<e.length;r++)n.push(un({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=dn(n);return 0===r.length?"0x":r}function un({param:e,value:t}){const n=ln(e.type);if(n){const[r,s]=n;return function(e,{length:t,param:n}){const r=null===t;if(!Array.isArray(e))throw new we(e);if(!r&&e.length!==t)throw new ae({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let s=!1;const i=[];for(let t=0;t<e.length;t++){const r=un({param:n,value:e[t]});r.dynamic&&(s=!0),i.push(r)}if(r||s){const e=dn(i);if(r){const t=Be(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?Jt([t,e]):t}}if(s)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Jt(i.map((({encoded:e})=>e)))}}(t,{length:r,param:{...e,type:s}})}if("tuple"===e.type)return function(e,{param:t}){let n=!1;const r=[];for(let s=0;s<t.components.length;s++){const i=t.components[s],a=un({param:i,value:e[Array.isArray(e)?s:i.name]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?dn(r):Jt(r.map((({encoded:e})=>e)))}}(t,{param:e});if("address"===e.type)return function(e){if(!Qt(e))throw new Kt({address:e});return{dynamic:!1,encoded:Ee(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new ee(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Ee(Re(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=on.exec(e.type)??[];return function(e,{signed:t,size:n=256}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new Ae({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Be(e,{size:32,signed:t})}}(t,{signed:n,size:Number(r)})}if(e.type.startsWith("bytes"))return function(e,{param:t}){const[,n]=t.type.split("bytes"),r=Y(e);if(!n){let t=e;return r%32!=0&&(t=Ee(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:Jt([Ee(Be(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new oe({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:Ee(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=Ue(e),n=Math.ceil(Y(t)/32),r=[];for(let e=0;e<n;e++)r.push(Ee(en(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:Jt([Ee(Be(Y(t),{size:32})),...r])}}(t);throw new be(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function dn(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:s}=e[n];t+=r?32:Y(s)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(Be(t+s,{size:32})),r.push(o),s+=Y(o)):n.push(o)}return Jt([...n,...r])}function ln(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const fn=e=>en(Lt(e),0,4);function pn(e){const{abi:t,args:n=[],name:r}=e,s=W(r,{strict:!1}),i=t.filter((e=>s?"function"===e.type?fn(e)===r:"event"===e.type&&Ft(e)===r:"name"in e&&e.name===r));if(0===i.length)return;if(1===i.length)return i[0];let a;for(const e of i){if(!("inputs"in e))continue;if(!n||0===n.length){if(!e.inputs||0===e.inputs.length)return e;continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==n.length)continue;const t=n.every(((t,n)=>{const r="inputs"in e&&e.inputs[n];return!!r&&hn(t,r)}));if(t){if(a&&"inputs"in a&&a.inputs){const t=mn(e.inputs,a.inputs,n);if(t)throw new me({abiItem:e,type:t[0]},{abiItem:a,type:t[1]})}a=e}}return a||i[0]}function hn(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Qt(e,{strict:!1});case"bool":return"boolean"===n;case"function":case"string":return"string"===n;default:return"tuple"===r&&"components"in t?Object.values(t.components).every(((t,n)=>hn(Object.values(e)[n],t))):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?"number"===n||"bigint"===n:/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?"string"===n||e instanceof Uint8Array:!!/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)&&(Array.isArray(e)&&e.every((e=>hn(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")}))))}}function mn(e,t,n){for(const r in e){const s=e[r],i=t[r];if("tuple"===s.type&&"tuple"===i.type&&"components"in s&&"components"in i)return mn(s.components,i.components,n[r]);const a=[s.type,i.type];if(!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&Qt(n[r],{strict:!1}))return a}}function yn(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const bn="/docs/contract/encodeFunctionData";function gn(e){const{args:t}=e,{abi:n,functionName:r}=1===e.abi.length&&e.functionName?.startsWith("0x")?e:function(e){const{abi:t,args:n,functionName:r}=e;let s=t[0];if(r){const e=pn({abi:t,args:n,name:r});if(!e)throw new fe(r,{docsPath:bn});s=e}if("function"!==s.type)throw new fe(void 0,{docsPath:bn});return{abi:[s],functionName:fn(Z(s))}}(e),s=n[0];return Xt([r,("inputs"in s&&s.inputs?cn(s.inputs,t??[]):void 0)??"0x"])}const wn={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},vn={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},xn={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};class In extends ee{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class Pn extends ee{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class zn extends ee{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const En={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new zn({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Pn({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new In({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new In({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function An(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(En);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function kn(e,t={}){void 0!==t.size&&je(e,{size:t.size});return Se(Ce(e,t),t)}function Mn(e,t={}){let n=e;if(void 0!==t.size&&(je(n,{size:t.size}),n=Oe(n)),n.length>1||n[0]>1)throw new ke(n);return Boolean(n[0])}function $n(e,t={}){void 0!==t.size&&je(e,{size:t.size});return Ne(Ce(e,t),t)}function On(e,t){const n="string"==typeof t?Ve(t):t,r=An(n);if(0===Y(n)&&e.length>0)throw new ie;if(Y(t)&&Y(t)<32)throw new se({data:"string"==typeof t?t:Ce(t),params:e,size:Y(t)});let s=0;const i=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(s);const[a,o]=jn(r,n,{staticPosition:0});s+=o,i.push(a)}return i}function jn(e,t,{staticPosition:n}){const r=ln(t.type);if(r){const[s,i]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+$n(e.readBytes(Nn)),s=n+Sn;e.setPosition(n);const i=$n(e.readBytes(Sn)),a=Tn(t);let o=0;const c=[];for(let n=0;n<i;++n){e.setPosition(s+(a?32*n:o));const[r,i]=jn(e,t,{staticPosition:s});o+=i,c.push(r)}return e.setPosition(r+32),[c,32]}if(Tn(t)){const s=r+$n(e.readBytes(Nn)),i=[];for(let r=0;r<n;++r){e.setPosition(s+32*r);const[n]=jn(e,t,{staticPosition:s});i.push(n)}return e.setPosition(r+32),[i,32]}let s=0;const i=[];for(let a=0;a<n;++a){const[n,a]=jn(e,t,{staticPosition:r+s});s+=a,i.push(n)}return[i,s]}(e,{...t,type:i},{length:s,staticPosition:n})}if("tuple"===t.type)return function(e,t,{staticPosition:n}){const r=0===t.components.length||t.components.some((({name:e})=>!e)),s=r?[]:{};let i=0;if(Tn(t)){const a=n+$n(e.readBytes(Nn));for(let n=0;n<t.components.length;++n){const o=t.components[n];e.setPosition(a+i);const[c,u]=jn(e,o,{staticPosition:a});i+=u,s[r?n:o?.name]=c}return e.setPosition(n+32),[s,32]}for(let a=0;a<t.components.length;++a){const o=t.components[a],[c,u]=jn(e,o,{staticPosition:n});s[r?a:o?.name]=c,i+=u}return[s,i]}(e,t,{staticPosition:n});if("address"===t.type)return function(e){const t=e.readBytes(32);return[Zt(Ce(rn(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[Mn(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const t=$n(e.readBytes(32));e.setPosition(n+t);const r=$n(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const s=e.readBytes(r);return e.setPosition(n+32),[Ce(s),32]}const i=Ce(e.readBytes(Number.parseInt(s,10),32));return[i,32]}(e,t,{staticPosition:n});if(t.type.startsWith("uint")||t.type.startsWith("int"))return function(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),s=e.readBytes(32);return[r>48?kn(s,{signed:n}):$n(s,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=$n(e.readBytes(32)),r=t+n;e.setPosition(r);const s=$n(e.readBytes(32));if(0===s)return e.setPosition(t+32),["",32];const i=e.readBytes(s,32),a=function(e,t={}){let n=e;return void 0!==t.size&&(je(n,{size:t.size}),n=Oe(n,{dir:"right"})),(new TextDecoder).decode(n)}(Oe(i));return e.setPosition(t+32),[a,32]}(e,{staticPosition:n});throw new ge(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Sn=32,Nn=32;function Tn(e){const{type:t}=e;if("string"===t)return!0;if("bytes"===t)return!0;if(t.endsWith("[]"))return!0;if("tuple"===t)return e.components?.some(Tn);const n=ln(e.type);return!(!n||!Tn({...e,type:n[1]}))}function _n(e){const{abi:t,data:n}=e,r=en(n,0,4);if("0x"===r)throw new ie;const s=[...t||[],vn,xn].find((e=>"error"===e.type&&r===fn(Z(e))));if(!s)throw new le(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:s,args:"inputs"in s&&s.inputs&&s.inputs.length>0?On(s.inputs,en(n,4)):void 0,errorName:s.name}}const Rn=(e,t,n)=>JSON.stringify(e,((e,n)=>{const r="bigint"==typeof n?n.toString():n;return"function"==typeof t?t(e,r):r}),n);function Cn({abiItem:e,args:t,includeFunctionName:n=!0,includeName:r=!1}){if("name"in e&&"inputs"in e&&e.inputs)return`${n?e.name:""}(${e.inputs.map(((e,n)=>`${r&&e.name?`${e.name}: `:""}${"object"==typeof t[n]?Rn(t[n]):t[n]}`)).join(", ")})`}const Bn={gwei:9,wei:18},Dn={ether:-9,wei:9};function Un(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[s,i]=[n.slice(0,n.length-t),n.slice(n.length-t)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function qn(e,t="wei"){return Un(e,Bn[t])}function Ln(e,t="wei"){return Un(e,Dn[t])}class Fn extends ee{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Kn extends ee{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Vn(e){return e.reduce(((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`),"")}function Gn(e){const t=Object.entries(e).map((([e,t])=>void 0===t||!1===t?null:[e,t])).filter(Boolean),n=t.reduce(((e,[t])=>Math.max(e,t.length)),0);return t.map((([e,t])=>` ${`${e}:`.padEnd(n+1)} ${t}`)).join("\n")}class Zn extends ee{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join("\n"),{name:"FeeConflictError"})}}class Hn extends ee{constructor({v:e}){super(`Invalid \`v\` value "${e}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class Wn extends ee{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Gn(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class Yn extends ee{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${Math.floor((e.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}const Qn=e=>e;class Jn extends ee{constructor(e,{account:t,docsPath:n,chain:r,data:s,gas:i,gasPrice:a,maxFeePerGas:o,maxPriorityFeePerGas:c,nonce:u,to:d,value:l,stateOverride:f}){const p=t?yn(t):void 0;let h=Gn({from:p?.address,to:d,value:void 0!==l&&`${qn(l)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:s,gas:i,gasPrice:void 0!==a&&`${Ln(a)} gwei`,maxFeePerGas:void 0!==o&&`${Ln(o)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Ln(c)} gwei`,nonce:u});f&&(h+=`\n${function(e){return e.reduce(((e,{address:t,...n})=>{let r=`${e} ${t}:\n`;return n.nonce&&(r+=` nonce: ${n.nonce}\n`),n.balance&&(r+=` balance: ${n.balance}\n`),n.code&&(r+=` code: ${n.code}\n`),n.state&&(r+=" state:\n",r+=Vn(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Vn(n.stateDiff)),r})," State Override:\n").slice(0,-1)}(f)}`),super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Raw Call Arguments:",h].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class Xn extends ee{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:s,functionName:i,sender:a}){const o=pn({abi:t,args:n,name:i}),c=o?Cn({abiItem:o,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=Gn({address:r&&r,function:o?Z(o,{includeName:!0}):void 0,args:c&&"()"!==c&&`${[...Array(i?.length??0).keys()].map((()=>" ")).join("")}${c}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${i}".`,{cause:e,docsPath:s,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],u&&"Contract Call:",u].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=t,this.args=n,this.cause=e,this.contractAddress=r,this.functionName=i,this.sender=a}}class er extends ee{constructor({abi:e,data:t,functionName:n,message:r}){let s,i,a,o,c;if(t&&"0x"!==t)try{i=_n({abi:e,data:t});const{abiItem:n,errorName:r,args:s}=i;if("Error"===r)o=s[0];else if("Panic"===r){const[e]=s;o=wn[e]}else{const e=n?Z(n,{includeName:!0}):void 0,t=n&&s?Cn({abiItem:n,args:s,includeFunctionName:!1,includeName:!1}):void 0;a=[e?`Error: ${e}`:"",t&&"()"!==t?` ${[...Array(r?.length??0).keys()].map((()=>" ")).join("")}${t}`:""]}}catch(e){s=e}else r&&(o=r);s instanceof le&&(c=s.signature,a=[`Unable to decode signature "${c}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${c}.`]),super(o&&"execution reverted"!==o||c?[`The contract function "${n}" reverted with the following ${c?"signature":"reason"}:`,o||c].join("\n"):`The contract function "${n}" reverted.`,{cause:s,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=i,this.raw=t,this.reason=o,this.signature=c}}class tr extends ee{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class nr extends ee{constructor({factory:e}){super("Deployment for counterfactual contract call failed"+(e?` for factory "${e}".`:""),{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class rr extends ee{constructor({data:e,message:t}){super(t||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e}}class sr extends ee{constructor({body:e,cause:t,details:n,headers:r,status:s,url:i}){super("HTTP request failed.",{cause:t,details:n,metaMessages:[s&&`Status: ${s}`,`URL: ${i}`,e&&`Request body: ${Rn(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=r,this.status=s,this.url=i}}class ir extends ee{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${Rn(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t.code,this.data=t.data}}class ar extends ee{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${Rn(e)}`],name:"TimeoutError"})}}class or extends ee{constructor(e,{code:t,docsPath:n,metaMessages:r,name:s,shortMessage:i}){super(i,{cause:e,docsPath:n,metaMessages:r||e?.metaMessages,name:s||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=s||e.name,this.code=e instanceof ir?e.code:t??-1}}class cr extends or{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class ur extends or{constructor(e){super(e,{code:ur.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(ur,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class dr extends or{constructor(e){super(e,{code:dr.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(dr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class lr extends or{constructor(e,{method:t}={}){super(e,{code:lr.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(lr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class fr extends or{constructor(e){super(e,{code:fr.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(fr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class pr extends or{constructor(e){super(e,{code:pr.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class hr extends or{constructor(e){super(e,{code:hr.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(hr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class mr extends or{constructor(e){super(e,{code:mr.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(mr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class yr extends or{constructor(e){super(e,{code:yr.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(yr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class br extends or{constructor(e){super(e,{code:br.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(br,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class gr extends or{constructor(e,{method:t}={}){super(e,{code:gr.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(gr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class wr extends or{constructor(e){super(e,{code:wr.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(wr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class vr extends or{constructor(e){super(e,{code:vr.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(vr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class xr extends cr{constructor(e){super(e,{code:xr.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Ir extends cr{constructor(e){super(e,{code:Ir.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Pr extends cr{constructor(e,{method:t}={}){super(e,{code:Pr.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(Pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class zr extends cr{constructor(e){super(e,{code:zr.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(zr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Er extends cr{constructor(e){super(e,{code:Er.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(Er,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Ar extends cr{constructor(e){super(e,{code:Ar.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Ar,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class kr extends cr{constructor(e){super(e,{code:kr.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(kr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Mr extends cr{constructor(e){super(e,{code:Mr.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Mr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class $r extends cr{constructor(e){super(e,{code:$r.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty($r,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class Or extends cr{constructor(e){super(e,{code:Or.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(Or,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class jr extends cr{constructor(e){super(e,{code:jr.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(jr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Sr extends cr{constructor(e){super(e,{code:Sr.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Sr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Nr extends cr{constructor(e){super(e,{code:Nr.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Nr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Tr extends or{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const _r=3;function Rr(e,{abi:t,address:n,args:r,docsPath:s,functionName:i,sender:a}){const o=e instanceof rr?e:e instanceof ee?e.walk((e=>"data"in e))||e.walk():{},{code:c,data:u,details:d,message:l,shortMessage:f}=o,p=e instanceof ie?new tr({functionName:i}):[_r,pr.code].includes(c)&&(u||d||l||f)?new er({abi:t,data:"object"==typeof u?u.data:u,functionName:i,message:o instanceof ir?d:f??l}):e;return new Xn(p,{abi:t,args:r,contractAddress:n,docsPath:s,functionName:i,sender:a})}function Cr(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw new Error("Invalid yParityOrV value")}async function Br({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=W(e)?e:_e(e),{secp256k1:r}=await Promise.resolve().then((function(){return jd}));return`0x${(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:s,yParity:i}=t,a=Cr(Number(i??s));return new r.Signature(Se(e),Se(n)).addRecoveryBit(a)}const e=W(t)?t:_e(t);if(65!==Y(e))throw new Error("invalid signature length");const n=Cr(Ne(`0x${e.slice(130)}`));return r.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(n)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}({hash:e,signature:t}),Zt(`0x${Dt(`0x${n.substring(4)}`).substring(26)}`);var n}function Dr(e,t="hex"){const n=Ur(e),r=An(new Uint8Array(n.length));return n.encode(r),"hex"===t?Ce(r.bytes):r.bytes}function Ur(e){return Array.isArray(e)?function(e){const t=e.reduce(((e,t)=>e+t.length),0),n=qr(t);return{length:t<=55?1+t:1+n+t,encode(r){t<=55?r.pushByte(192+t):(r.pushByte(247+n),1===n?r.pushUint8(t):2===n?r.pushUint16(t):3===n?r.pushUint24(t):r.pushUint32(t));for(const{encode:t}of e)t(r)}}}(e.map((e=>Ur(e)))):function(e){const t="string"==typeof e?Ve(e):e,n=qr(t.length),r=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length;return{length:r,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+n),1===n?e.pushUint8(t.length):2===n?e.pushUint16(t.length):3===n?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function qr(e){if(e<256)return 1;if(e<65536)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new ee("Length is too large.")}function Lr(e){const{chainId:t,nonce:n,to:r}=e,s=e.contractAddress??e.address,i=Dt(Xt(["0x05",Dr([t?Be(t):"0x",s,n?Be(n):"0x"])]));return"bytes"===r?Ve(i):i}class Fr extends ee{constructor({cause:e,message:t}={}){const n=t?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Fr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Fr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Kr extends ee{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Ln(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Kr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class Vr extends ee{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Ln(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(Vr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class Gr extends ee{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(Gr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Zr extends ee{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join("\n"),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(Zr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Hr extends ee{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Wr extends ee{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join("\n"),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(Wr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Yr extends ee{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(Yr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Qr extends ee{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(Qr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Jr extends ee{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Xr extends ee{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${Ln(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Ln(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Xr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class es extends ee{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function ts(e,{format:t}){if(!t)return{};const n={};return function t(r){const s=Object.keys(r);for(const i of s)i in e&&(n[i]=e[i]),r[i]&&"object"==typeof r[i]&&!Array.isArray(r[i])&&t(r[i])}(t(e||{})),n}function ns(e,t){return({exclude:n,format:r})=>({exclude:n,format:e=>{const s=t(e);if(n)for(const e of n)delete s[e];return{...s,...r(e)}},type:e})}const rs={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function ss(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map((e=>({address:e.address,r:e.r?Be(BigInt(e.r)):e.r,s:e.s?Be(BigInt(e.s)):e.s,chainId:Be(e.chainId),nonce:Be(e.nonce),...void 0!==e.yParity?{yParity:Be(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:Be(e.v)}:{}})))),void 0!==e.accessList&&(t.accessList=e.accessList),void 0!==e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes),void 0!==e.blobs&&("string"!=typeof e.blobs[0]?t.blobs=e.blobs.map((e=>Ce(e))):t.blobs=e.blobs),void 0!==e.data&&(t.data=e.data),void 0!==e.from&&(t.from=e.from),void 0!==e.gas&&(t.gas=Be(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=Be(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=Be(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Be(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Be(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Be(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=rs[e.type]),void 0!==e.value&&(t.value=Be(e.value)),t}function is(e){if(e&&0!==e.length)return e.reduce(((e,{slot:t,value:n})=>{if(66!==t.length)throw new Pe({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new Pe({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e}),{})}function as(e){const{balance:t,nonce:n,state:r,stateDiff:s,code:i}=e,a={};if(void 0!==i&&(a.code=i),void 0!==t&&(a.balance=Be(t)),void 0!==n&&(a.nonce=Be(n)),void 0!==r&&(a.state=is(r)),void 0!==s){if(a.state)throw new Kn;a.stateDiff=is(s)}return a}const os=2n**256n-1n;const cs={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function us(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Ne(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?Ne(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?cs[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(t.authorizationList=e.authorizationList.map((e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)})))),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if("bigint"==typeof t.v){if(0n===t.v||27n===t.v)return 0;if(1n===t.v||28n===t.v)return 1;if(t.v>=35n)return t.v%2n===0n?1:0}})(),"legacy"===t.type&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),"eip2930"===t.type&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),"eip1559"===t.type&&delete t.maxFeePerBlobGas,t}const ds=ns("transaction",us);function ls(e){const t=(e.transactions??[]).map((e=>"string"==typeof e?e:us(e)));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:t,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const fs=ns("block",ls);function ps(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map((e=>Ve(e))):e.blobs,s=[];for(const e of r)s.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?s:s.map((e=>Ce(e)))}function hs(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map((e=>Ve(e))):e.blobs,s="string"==typeof e.commitments[0]?e.commitments.map((e=>Ve(e))):e.commitments,i=[];for(let e=0;e<r.length;e++){const n=r[e],a=s[e];i.push(Uint8Array.from(t.computeBlobKzgProof(n,a)))}return"bytes"===n?i:i.map((e=>Ce(e)))}function ms(e,t,n){return e&t^e&n^t&n}class ys extends vt{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=yt(this.buffer)}update(e){pt(this),ft(e=wt(e));const{view:t,buffer:n,blockLen:r}=this,s=e.length;for(let i=0;i<s;){const a=Math.min(r-this.pos,s-i);if(a!==r)n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=yt(e);for(;r<=s-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){pt(this),ht(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:s}=this;let{pos:i}=this;t[i++]=128,mt(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),a=Number(n>>s&i),o=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,o,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const a=yt(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=o/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)a.setUint32(4*e,u[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:s,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=s,e.length=r,e.pos=a,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const bs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),gs=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),ws=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),vs=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]),xs=new Uint32Array(64);class Is extends ys{constructor(e=32){super(64,e,8,!1),this.A=0|bs[0],this.B=0|bs[1],this.C=0|bs[2],this.D=0|bs[3],this.E=0|bs[4],this.F=0|bs[5],this.G=0|bs[6],this.H=0|bs[7]}get(){const{A:e,B:t,C:n,D:r,E:s,F:i,G:a,H:o}=this;return[e,t,n,r,s,i,a,o]}set(e,t,n,r,s,i,a,o){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|i,this.G=0|a,this.H=0|o}process(e,t){for(let n=0;n<16;n++,t+=4)xs[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=xs[e-15],n=xs[e-2],r=bt(t,7)^bt(t,18)^t>>>3,s=bt(n,17)^bt(n,19)^n>>>10;xs[e]=s+xs[e-7]+r+xs[e-16]|0}let{A:n,B:r,C:s,D:i,E:a,F:o,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(bt(a,6)^bt(a,11)^bt(a,25))+((d=a)&o^~d&c)+vs[e]+xs[e]|0,l=(bt(n,2)^bt(n,13)^bt(n,22))+ms(n,r,s)|0;u=c,c=o,o=a,a=i+t|0,i=s,s=r,r=n,n=t+l|0}var d;n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,o=o+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,s,i,a,o,c,u)}roundClean(){mt(xs)}destroy(){this.set(0,0,0,0,0,0,0,0),mt(this.buffer)}}const Ps=(()=>Ye(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),zs=(()=>Ps[0])(),Es=(()=>Ps[1])(),As=new Uint32Array(80),ks=new Uint32Array(80);class Ms extends ys{constructor(e=64){super(128,e,16,!1),this.Ah=0|ws[0],this.Al=0|ws[1],this.Bh=0|ws[2],this.Bl=0|ws[3],this.Ch=0|ws[4],this.Cl=0|ws[5],this.Dh=0|ws[6],this.Dl=0|ws[7],this.Eh=0|ws[8],this.El=0|ws[9],this.Fh=0|ws[10],this.Fl=0|ws[11],this.Gh=0|ws[12],this.Gl=0|ws[13],this.Hh=0|ws[14],this.Hl=0|ws[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:s,Cl:i,Dh:a,Dl:o,Eh:c,El:u,Fh:d,Fl:l,Gh:f,Gl:p,Hh:h,Hl:m}=this;return[e,t,n,r,s,i,a,o,c,u,d,l,f,p,h,m]}set(e,t,n,r,s,i,a,o,c,u,d,l,f,p,h,m){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|s,this.Cl=0|i,this.Dh=0|a,this.Dl=0|o,this.Eh=0|c,this.El=0|u,this.Fh=0|d,this.Fl=0|l,this.Gh=0|f,this.Gl=0|p,this.Hh=0|h,this.Hl=0|m}process(e,t){for(let n=0;n<16;n++,t+=4)As[n]=e.getUint32(t),ks[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|As[e-15],n=0|ks[e-15],r=Xe(t,n,1)^Xe(t,n,8)^Qe(t,0,7),s=et(t,n,1)^et(t,n,8)^Je(t,n,7),i=0|As[e-2],a=0|ks[e-2],o=Xe(i,a,19)^tt(i,a,61)^Qe(i,0,6),c=et(i,a,19)^nt(i,a,61)^Je(i,a,6),u=at(s,c,ks[e-7],ks[e-16]),d=ot(u,r,o,As[e-7],As[e-16]);As[e]=0|d,ks[e]=0|u}let{Ah:n,Al:r,Bh:s,Bl:i,Ch:a,Cl:o,Dh:c,Dl:u,Eh:d,El:l,Fh:f,Fl:p,Gh:h,Gl:m,Hh:y,Hl:b}=this;for(let e=0;e<80;e++){const t=Xe(d,l,14)^Xe(d,l,18)^tt(d,l,41),g=et(d,l,14)^et(d,l,18)^nt(d,l,41),w=d&f^~d&h,v=ct(b,g,l&p^~l&m,Es[e],ks[e]),x=ut(v,y,t,w,zs[e],As[e]),I=0|v,P=Xe(n,r,28)^tt(n,r,34)^tt(n,r,39),z=et(n,r,28)^nt(n,r,34)^nt(n,r,39),E=n&s^n&a^s&a,A=r&i^r&o^i&o;y=0|h,b=0|m,h=0|f,m=0|p,f=0|d,p=0|l,({h:d,l:l}=rt(0|c,0|u,0|x,0|I)),c=0|a,u=0|o,a=0|s,o=0|i,s=0|n,i=0|r;const k=st(I,z,A);n=it(k,x,P,E),r=0|k}({h:n,l:r}=rt(0|this.Ah,0|this.Al,0|n,0|r)),({h:s,l:i}=rt(0|this.Bh,0|this.Bl,0|s,0|i)),({h:a,l:o}=rt(0|this.Ch,0|this.Cl,0|a,0|o)),({h:c,l:u}=rt(0|this.Dh,0|this.Dl,0|c,0|u)),({h:d,l:l}=rt(0|this.Eh,0|this.El,0|d,0|l)),({h:f,l:p}=rt(0|this.Fh,0|this.Fl,0|f,0|p)),({h:h,l:m}=rt(0|this.Gh,0|this.Gl,0|h,0|m)),({h:y,l:b}=rt(0|this.Hh,0|this.Hl,0|y,0|b)),this.set(n,r,s,i,a,o,c,u,d,l,f,p,h,m,y,b)}roundClean(){mt(As,ks)}destroy(){mt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class $s extends Ms{constructor(){super(48),this.Ah=0|gs[0],this.Al=0|gs[1],this.Bh=0|gs[2],this.Bl=0|gs[3],this.Ch=0|gs[4],this.Cl=0|gs[5],this.Dh=0|gs[6],this.Dl=0|gs[7],this.Eh=0|gs[8],this.El=0|gs[9],this.Fh=0|gs[10],this.Fl=0|gs[11],this.Gh=0|gs[12],this.Gl=0|gs[13],this.Hh=0|gs[14],this.Hl=0|gs[15]}}const Os=xt((()=>new Is)),js=xt((()=>new Ms)),Ss=xt((()=>new $s)),Ns=Os;function Ts(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),s=function(e,t){const n=t||"hex",r=Ns(W(e,{strict:!1})?Le(e):e);return"bytes"===n?r:_e(r)}(t,"bytes");return s.set([n],0),"bytes"===r?s:Ce(s)}const _s=32,Rs=4096,Cs=_s*Rs,Bs=6*Cs-1-1*Rs*6,Ds=1;class Us extends ee{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class qs extends ee{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class Ls extends ee{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`],name:"InvalidVersionedHashSizeError"})}}class Fs extends ee{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${Ds}`,`Received: ${t}`],name:"InvalidVersionedHashVersionError"})}}function Ks(e){const{data:t,kzg:n,to:r}=e,s=e.blobs??function(e){const t=e.to??("string"==typeof e.data?"hex":"bytes"),n="string"==typeof e.data?Ve(e.data):e.data,r=Y(n);if(!r)throw new qs;if(r>Bs)throw new Us({maxSize:Bs,size:r});const s=[];let i=!0,a=0;for(;i;){const e=An(new Uint8Array(Cs));let t=0;for(;t<Rs;){const r=n.slice(a,a+(_s-1));if(e.pushByte(0),e.pushBytes(r),r.length<31){e.pushByte(128),i=!1;break}t++,a+=31}s.push(e)}return"bytes"===t?s.map((e=>e.bytes)):s.map((e=>Ce(e.bytes)))}({data:t,to:r}),i=e.commitments??ps({blobs:s,kzg:n,to:r}),a=e.proofs??hs({blobs:s,commitments:i,kzg:n,to:r}),o=[];for(let e=0;e<s.length;e++)o.push({blob:s[e],commitment:i[e],proof:a[e]});return o}function Vs(e,t){if(!Qt(e,{strict:!1}))throw new Kt({address:e});if(!Qt(t,{strict:!1}))throw new Kt({address:t});return e.toLowerCase()===t.toLowerCase()}const Gs="/docs/contract/decodeFunctionResult";function Zs(e){const{abi:t,args:n,functionName:r,data:s}=e;let i=t[0];if(r){const e=pn({abi:t,args:n,name:r});if(!e)throw new fe(r,{docsPath:Gs});i=e}if("function"!==i.type)throw new fe(void 0,{docsPath:Gs});if(!i.outputs)throw new pe(i.name,{docsPath:Gs});const a=On(i.outputs,s);return a&&a.length>1?a:a&&1===a.length?a[0]:void 0}
|
|
2
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Hs=BigInt(0),Ws=BigInt(1);function Ys(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Qs(e){if(!Ys(e))throw new Error("Uint8Array expected")}function Js(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function Xs(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function ei(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Hs:BigInt("0x"+e)}const ti="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,ni=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function ri(e){if(Qs(e),ti)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=ni[e[n]];return t}const si={_0:48,_9:57,A:65,F:70,a:97,f:102};function ii(e){return e>=si._0&&e<=si._9?e-si._0:e>=si.A&&e<=si.F?e-(si.A-10):e>=si.a&&e<=si.f?e-(si.a-10):void 0}function ai(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(ti)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,s=0;t<n;t++,s+=2){const n=ii(e.charCodeAt(s)),i=ii(e.charCodeAt(s+1));if(void 0===n||void 0===i){const t=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+s)}r[t]=16*n+i}return r}function oi(e){return ei(ri(e))}function ci(e){return Qs(e),ei(ri(Uint8Array.from(e).reverse()))}function ui(e,t){return ai(e.toString(16).padStart(2*t,"0"))}function di(e,t){return ui(e,t).reverse()}function li(e,t,n){let r;if("string"==typeof t)try{r=ai(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Ys(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const s=r.length;if("number"==typeof n&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}function fi(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];Qs(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const s=e[t];n.set(s,r),r+=s.length}return n}function pi(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}const hi=e=>"bigint"==typeof e&&Hs<=e;function mi(e,t,n){return hi(e)&&hi(t)&&hi(n)&&t<=e&&e<n}function yi(e,t,n,r){if(!mi(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const bi=e=>(Ws<<BigInt(e))-Ws,gi=e=>new Uint8Array(e),wi=e=>Uint8Array.from(e);const vi={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||Ys(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function xi(e,t,n={}){const r=(t,n,r)=>{const s=vi[n];if("function"!=typeof s)throw new Error("invalid validator function");const i=e[t];if(!(r&&void 0===i||s(i,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+i)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}function Ii(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(void 0!==s)return s;const i=e(n,...r);return t.set(n,i),i}}class Pi extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof Pi){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&"string"==typeof t.cause.details?t.cause.details:t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof Pi&&t.cause.docsPath||t.docsPath,s=`https://oxlib.sh${r??""}`;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${s}`:void 0]:[]].filter((e=>"string"==typeof e)).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:"ox@0.1.1"}),this.cause=t.cause,this.details=n,this.docs=s,this.docsPath=r,this.shortMessage=e}walk(e){return zi(this,e)}}function zi(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?zi(e.cause,t):t?null:e}function Ei(e,t){if(Ri(e)>t)throw new Ki({givenSize:Ri(e),maxSize:t})}const Ai={zero:48,nine:57,A:65,F:70,a:97,f:102};function ki(e){return e>=Ai.zero&&e<=Ai.nine?e-Ai.zero:e>=Ai.A&&e<=Ai.F?e-(Ai.A-10):e>=Ai.a&&e<=Ai.f?e-(Ai.a-10):void 0}function Mi(e,t={}){const{dir:n="left"}=t;let r=e,s=0;for(let e=0;e<r.length-1&&"0"===r["left"===n?e:r.length-e-1].toString();e++)s++;return r="left"===n?r.slice(s):r.slice(0,r.length-s),r}function $i(e,t){if(ra(e)>t)throw new oa({givenSize:ra(e),maxSize:t})}function Oi(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const s=e.replace("0x","");if(s.length>2*r)throw new ua({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s["right"===n?"padEnd":"padStart"](2*r,"0")}`}const ji=new TextDecoder,Si=new TextEncoder;function Ni(e){return e instanceof Uint8Array?e:"string"==typeof e?Ti(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function Ti(e,t={}){const{size:n}=t;let r=e;n&&($i(e,n),r=ta(e,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){const n=ki(s.charCodeAt(t++)),r=ki(s.charCodeAt(t++));if(void 0===n||void 0===r)throw new Pi(`Invalid byte sequence ("${s[t-2]}${s[t-1]}" in "${s}").`);a[e]=16*n+r}return a}function _i(e,t={}){const{size:n}=t,r=Si.encode(e);return"number"==typeof n?(Ei(r,n),function(e,t){return function(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;if(e.length>r)throw new Gi({size:e.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let t=0;t<r;t++){const i="right"===n;s[i?t:r-t-1]=e[i?t:e.length-t-1]}return s}(e,{dir:"right",size:t})}(r,n)):r}function Ri(e){return e.length}function Ci(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>Ri(e)-1)throw new Vi({offset:t,position:"start",size:Ri(e)})}(e,t);const i=e.slice(t,n);return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&Ri(e)!==n-t)throw new Vi({offset:n,position:"end",size:Ri(e)})}(i,t,n),i}function Bi(e,t={}){const{size:n}=t;void 0!==n&&Ei(e,n);return sa(Qi(e,t),t)}function Di(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(Ei(r,n),r=Li(r)),r.length>1||r[0]>1)throw new Fi(r);return Boolean(r[0])}function Ui(e,t={}){const{size:n}=t;void 0!==n&&Ei(e,n);return ia(Qi(e,t),t)}function qi(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(Ei(r,n),r=Mi(r,{dir:"right"})),ji.decode(r)}function Li(e){return Mi(e,{dir:"left"})}class Fi extends Pi{constructor(e){super(`Bytes value \`${e}\` is not a valid boolean.`,{metaMessages:["The bytes array must contain a single byte of either a `0` or `1` value."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesBooleanError"})}}class Ki extends Pi{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Vi extends Pi{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}}class Gi extends Pi{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}const Zi=new TextEncoder,Hi=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Wi(...e){return`0x${e.reduce(((e,t)=>e+t.replace("0x","")),"")}`}function Yi(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?($i(n,t.size),ea(n,t.size)):n}function Qi(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Hi[e[t]];const r=`0x${n}`;return"number"==typeof t.size?($i(r,t.size),ta(r,t.size)):r}function Ji(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new aa({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?(1n<<BigInt(8*r))+BigInt(s):s).toString(16)}`;return r?ea(o,r):o}function Xi(e,t={}){return Qi(Zi.encode(e),t)}function ea(e,t){return Oi(e,{dir:"left",size:t})}function ta(e,t){return Oi(e,{dir:"right",size:t})}function na(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>ra(e)-1)throw new ca({offset:t,position:"start",size:ra(e)})}(e,t);const i=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&ra(e)!==n-t)throw new ca({offset:n,position:"end",size:ra(e)})}(i,t,n),i}function ra(e){return Math.ceil((e.length-2)/2)}function sa(e,t={}){const{signed:n}=t;t.size&&$i(e,t.size);const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<8n*BigInt(s))-1n;return r<=i>>1n?r:r-i-1n}function ia(e,t={}){const{signed:n,size:r}=t;return Number(n||r?sa(e,t):e)}class aa extends Pi{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number \`${s}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class oa extends Pi{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class ca extends Pi{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class ua extends Pi{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function da(e){return{address:e.address,amount:Ji(e.amount),index:Ji(e.index),validatorIndex:Ji(e.validatorIndex)}}const la=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],fa=[{name:"query",type:"function",stateMutability:"view",inputs:[{type:"tuple[]",name:"queries",components:[{type:"address",name:"sender"},{type:"string[]",name:"urls"},{type:"bytes",name:"data"}]}],outputs:[{type:"bool[]",name:"failures"},{type:"bytes[]",name:"responses"}]},{name:"HttpError",type:"error",inputs:[{type:"uint16",name:"status"},{type:"string",name:"message"}]}],pa=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],ha=[{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],outputs:[{type:"bool"}],stateMutability:"nonpayable",type:"function",name:"isValidSig"}],ma="0x82ad56cb",ya="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",ba="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",ga="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",wa="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class va extends ee{constructor({blockNumber:e,chain:t,contract:n}){super(`Chain "${t.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...e&&n.blockCreated&&n.blockCreated>e?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${e}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class xa extends ee{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class Ia extends ee{constructor({chainId:e}){super("number"==typeof e?`Chain ID "${e}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const Pa="/docs/contract/encodeDeployData";function za(e){const{abi:t,args:n,bytecode:r}=e;if(!n||0===n.length)return r;const s=t.find((e=>"type"in e&&"constructor"===e.type));if(!s)throw new ne({docsPath:Pa});if(!("inputs"in s))throw new re({docsPath:Pa});if(!s.inputs||0===s.inputs.length)throw new re({docsPath:Pa});return Xt([r,cn(s.inputs,n)])}function Ea(e,{docsPath:t,...n}){const r=(()=>{const t=function(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof ee?e.walk((e=>e?.code===Fr.code)):e;return r instanceof ee?new Fr({cause:e,message:r.details}):Fr.nodeMessage.test(n)?new Fr({cause:e,message:e.details}):Kr.nodeMessage.test(n)?new Kr({cause:e,maxFeePerGas:t?.maxFeePerGas}):Vr.nodeMessage.test(n)?new Vr({cause:e,maxFeePerGas:t?.maxFeePerGas}):Gr.nodeMessage.test(n)?new Gr({cause:e,nonce:t?.nonce}):Zr.nodeMessage.test(n)?new Zr({cause:e,nonce:t?.nonce}):Hr.nodeMessage.test(n)?new Hr({cause:e,nonce:t?.nonce}):Wr.nodeMessage.test(n)?new Wr({cause:e}):Yr.nodeMessage.test(n)?new Yr({cause:e,gas:t?.gas}):Qr.nodeMessage.test(n)?new Qr({cause:e,gas:t?.gas}):Jr.nodeMessage.test(n)?new Jr({cause:e}):Xr.nodeMessage.test(n)?new Xr({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new es({cause:e})}(e,n);return t instanceof es?e:t})();return new Jn(r,{docsPath:t,...n})}function Aa(){let e=()=>{},t=()=>{};return{promise:new Promise(((n,r)=>{e=n,t=r})),resolve:e,reject:t}}const ka=new Map;function Ma({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:s}){const i=async()=>{const t=o();a();const n=t.map((({args:e})=>e));0!==n.length&&e(n).then((e=>{s&&Array.isArray(e)&&e.sort(s);for(let n=0;n<t.length;n++){const{resolve:r}=t[n];r?.([e[n],e])}})).catch((e=>{for(let n=0;n<t.length;n++){const{reject:r}=t[n];r?.(e)}}))},a=()=>ka.delete(t),o=()=>ka.get(t)||[],c=e=>ka.set(t,[...o(),e]);return{flush:a,async schedule(e){const{promise:t,resolve:s,reject:a}=Aa(),u=n?.([...o().map((({args:e})=>e)),e]);u&&i();return o().length>0?(c({args:e,resolve:s,reject:a}),t):(c({args:e,resolve:s,reject:a}),setTimeout(i,r),t)}}}async function $a(e,t){const{account:n=e.account,authorizationList:r,batch:s=Boolean(e.batch?.multicall),blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",accessList:o,blobs:c,blockOverrides:u,code:d,data:l,factory:f,factoryData:p,gas:h,gasPrice:m,maxFeePerBlobGas:y,maxFeePerGas:b,maxPriorityFeePerGas:g,nonce:w,to:v,value:x,stateOverride:I,...P}=t,z=n?yn(n):void 0;if(d&&(f||p))throw new ee("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(d&&v)throw new ee("Cannot provide both `code` & `to` as parameters.");const E=d&&l,A=f&&p&&v&&l,k=E||A,M=E?Oa({code:d,data:l}):A?function(e){const{data:t,factory:n,factoryData:r,to:s}=e;return za({abi:V(["constructor(address, bytes, address, bytes)"]),bytecode:ba,args:[s,t,n,r]})}({data:l,factory:f,factoryData:p,to:v}):l;try{!function(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:s,to:i}=e,a=t?yn(t):void 0;if(a&&!Qt(a.address))throw new Kt({address:a.address});if(i&&!Qt(i))throw new Kt({address:i});if(void 0!==n&&(void 0!==r||void 0!==s))throw new Zn;if(r&&r>os)throw new Kr({maxFeePerGas:r});if(s&&r&&s>r)throw new Xr({maxFeePerGas:r,maxPriorityFeePerGas:s})}(t);const n=("bigint"==typeof i?Be(i):void 0)||a,d=u?function(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:Ji(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:Ji(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:Ji(e.gasLimit)},..."bigint"==typeof e.number&&{number:Ji(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:Ji(e.prevRandao)},..."bigint"==typeof e.time&&{time:Ji(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(da)}}}(u):void 0,l=function(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!Qt(n,{strict:!1}))throw new Kt({address:n});if(t[n])throw new Fn({address:n});t[n]=as(r)}return t}(I),f=e.chain?.formatters?.transactionRequest?.format,p=(f||ss)({...ts(P,{format:f}),from:z?.address,accessList:o,authorizationList:r,blobs:c,data:M,gas:h,gasPrice:m,maxFeePerBlobGas:y,maxFeePerGas:b,maxPriorityFeePerGas:g,nonce:w,to:k?void 0:v,value:x});if(s&&function({request:e}){const{data:t,to:n,...r}=e;return!!t&&(!t.startsWith(ma)&&(!!n&&!(Object.values(r).filter((e=>void 0!==e)).length>0)))}({request:p})&&!l&&!d)try{return await async function(e,t){const{batchSize:n=1024,deployless:r=!1,wait:s=0}="object"==typeof e.batch?.multicall?e.batch.multicall:{},{blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",data:o,to:c}=t,u=(()=>{if(r)return null;if(t.multicallAddress)return t.multicallAddress;if(e.chain)return function({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new va({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new va({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}({blockNumber:i,chain:e.chain,contract:"multicall3"});throw new xa})(),d="bigint"==typeof i?Be(i):void 0,l=d||a,{schedule:f}=Ma({id:`${e.uid}.${l}`,wait:s,shouldSplitBatch(e){const t=e.reduce(((e,{data:t})=>e+(t.length-2)),0);return t>2*n},fn:async t=>{const n=t.map((e=>({allowFailure:!0,callData:e.data,target:e.to}))),r=gn({abi:la,args:[n],functionName:"aggregate3"}),s=await e.request({method:"eth_call",params:[{...null===u?{data:Oa({code:wa,data:r})}:{to:u,data:r}},l]});return Zs({abi:la,args:[n],functionName:"aggregate3",data:s||"0x"})}}),[{returnData:p,success:h}]=await f({data:o,to:c});if(!h)throw new rr({data:p});return"0x"===p?{data:void 0}:{data:p}}(e,{...p,blockNumber:i,blockTag:a})}catch(e){if(!(e instanceof xa||e instanceof va))throw e}const E=(()=>{const e=[p,n];return l&&d?[...e,l,d]:l?[...e,l]:d?[...e,{},d]:e})(),A=await e.request({method:"eth_call",params:E});return"0x"===A?{data:void 0}:{data:A}}catch(n){const r=function(e){if(!(e instanceof ee))return;const t=e.walk();return"object"==typeof t?.data?t.data?.data:t.data}(n),{offchainLookup:s,offchainLookupSignature:i}=await import("./ccip-8aed4fac.js");if(!1!==e.ccipRead&&r?.slice(0,10)===i&&v)return{data:await s(e,{data:r,to:v})};if(k&&"0x101bb98d"===r?.slice(0,10))throw new nr({factory:f});throw Ea(n,{...t,account:z,chain:e.chain})}}function Oa(e){const{code:t,data:n}=e;return za({abi:V(["constructor(bytes, bytes)"]),bytecode:ya,args:[t,n]})}async function ja(e,t){const{abi:n,address:r,args:s,functionName:i,...a}=t,o=gn({abi:n,args:s,functionName:i});try{const{data:t}=await G(e,$a,"call")({...a,data:o,to:r});return Zs({abi:n,args:s,functionName:i,data:t||"0x"})}catch(e){throw Rr(e,{abi:n,address:r,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}const Sa=new Map,Na=new Map;let Ta=0;function _a(e,t,n){const r=++Ta,s=()=>Sa.get(e)||[],i=()=>{const t=s();if(!t.some((e=>e.id===r)))return;const n=Na.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch((()=>{}))}(()=>{const t=s();Sa.set(e,t.filter((e=>e.id!==r)))})()},a=s();if(Sa.set(e,[...a,{id:r,fns:t}]),a&&a.length>0)return i;const o={};for(const e in t)o[e]=(...t)=>{const n=s();if(0!==n.length)for(const r of n)r.fns[e]?.(...t)};const c=n(o);return"function"==typeof c&&Na.set(e,c),i}async function Ra(e){return new Promise((t=>setTimeout(t,e)))}const Ca=new Map,Ba=new Map;async function Da(e,{cacheKey:t,cacheTime:n=Number.POSITIVE_INFINITY}){const r=function(e){const t=(e,t)=>({clear:()=>t.delete(e),get:()=>t.get(e),set:n=>t.set(e,n)}),n=t(e,Ca),r=t(e,Ba);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}(t),s=r.response.get();if(s&&n>0){if(Date.now()-s.created.getTime()<n)return s.data}let i=r.promise.get();i||(i=e(),r.promise.set(i));try{const e=await i;return r.response.set({created:new Date,data:e}),e}finally{r.promise.clear()}}class Ua extends ee{constructor(e){super(`Call bundle failed with status: ${e.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=e}}function qa(e,{delay:t=100,retryCount:n=2,shouldRetry:r=(()=>!0)}={}){return new Promise(((s,i)=>{const a=async({count:o=0}={})=>{try{const t=await e();s(t)}catch(e){if(o<n&&await r({count:o,error:e}))return(async({error:e})=>{const n="function"==typeof t?t({count:o,error:e}):t;n&&await Ra(n),a({count:o+1})})({error:e});i(e)}};a()}))}const La={"0x0":"reverted","0x1":"success"};function Fa(e){const t={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map((e=>function(e,{args:t,eventName:n}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...n?{args:t,eventName:n}:{}}}(e))):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Ne(e.transactionIndex):null,status:e.status?La[e.status]:null,type:e.type?cs[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}const Ka=ns("transactionReceipt",Fa),Va="0x5792579257925792579257925792579257925792579257925792579257925792",Ga=Be(0,{size:32});async function Za(e,t){const{id:n,pollingInterval:r=e.pollingInterval,status:s=(({statusCode:e})=>200===e||e>=300),retryCount:i=4,retryDelay:a=(({count:e})=>200*~~(1<<e)),timeout:o=6e4,throwOnFailure:c=!1}=t,u=Rn(["waitForCallsStatus",e.uid,n]),{promise:d,resolve:l,reject:f}=Aa();let p;const h=_a(u,{resolve:l,reject:f},(t=>{const o=function(e,{emitOnBegin:t,initialWaitTime:n,interval:r}){let s=!0;const i=()=>s=!1;return(async()=>{let a;t&&(a=await e({unpoll:i}));const o=await(n?.(a))??r;await Ra(o);const c=async()=>{s&&(await e({unpoll:i}),await Ra(r),c())};c()})(),i}((async()=>{const r=e=>{clearTimeout(p),o(),e(),h()};try{const o=await qa((async()=>{const t=await async function(e,t){const{atomic:n=!1,chainId:r,receipts:s,version:i="2.0.0",...a}=await async function(t){if(t.endsWith(Va.slice(2))){const n=Oe(sn(t,-64,-32)),r=sn(t,0,-64).slice(2).match(/.{1,64}/g),s=await Promise.all(r.map((t=>Ga.slice(2)!==t?e.request({method:"eth_getTransactionReceipt",params:[`0x${t}`]},{dedupe:!0}):void 0))),i=s.some((e=>null===e))?100:s.every((e=>"0x1"===e?.status))?200:s.every((e=>"0x0"===e?.status))?500:600;return{atomic:!1,chainId:Ne(n),receipts:s.filter(Boolean),status:i,version:"2.0.0"}}return e.request({method:"wallet_getCallsStatus",params:[t]})}(t.id),[o,c]=(()=>{const e=a.status;return e>=100&&e<200?["pending",e]:e>=200&&e<300?["success",e]:e>=300&&e<700?["failure",e]:"CONFIRMED"===e?["success",200]:"PENDING"===e?["pending",100]:[void 0,e]})();return{...a,atomic:n,chainId:r?Ne(r):void 0,receipts:s?.map((e=>({...e,blockNumber:Se(e.blockNumber),gasUsed:Se(e.gasUsed),status:La[e.status]})))??[],statusCode:c,status:o,version:i}}(e,{id:n});if(c&&"failure"===t.status)throw new Ua(t);return t}),{retryCount:i,delay:a});if(!s(o))return;r((()=>t.resolve(o)))}catch(e){r((()=>t.reject(e)))}}),{interval:r,emitOnBegin:!0});return o}));return p=o?setTimeout((()=>{h(),clearTimeout(p),f(new Ha({id:n}))}),o):void 0,await d}class Ha extends ee{constructor({id:e}){super(`Timed out while waiting for call bundle with id "${e}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}const Wa=256;let Ya,Qa=Wa;function Ja(e=11){if(!Ya||Qa+e>2*Wa){Ya="",Qa=0;for(let e=0;e<Wa;e++)Ya+=(256+256*Math.random()|0).toString(16).substring(1)}return Ya.substring(Qa,Qa+++e)}function Xa(e){const{batch:t,chain:n,ccipRead:r,key:s="base",name:i="Base Client",type:a="base"}=e,o=e.experimental_blockTag??("number"==typeof n?.experimental_preconfirmationTime?"pending":void 0),c=n?.blockTime??12e3,u=Math.min(Math.max(Math.floor(c/2),500),4e3),d=e.pollingInterval??u,l=e.cacheTime??d,f=e.account?yn(e.account):void 0,{config:p,request:h,value:m}=e.transport({chain:n,pollingInterval:d}),y={account:f,batch:t,cacheTime:l,ccipRead:r,chain:n,key:s,name:i,pollingInterval:d,request:h,transport:{...p,...m},type:a,uid:Ja(),...o?{experimental_blockTag:o}:{}};return Object.assign(y,{extend:function e(t){return n=>{const r=n(t);for(const e in y)delete r[e];const s={...t,...r};return Object.assign(s,{extend:e(s)})}}(y)})}class eo extends ee{constructor({address:e}){super(`No EIP-712 domain found on contract "${e}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${e}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}const to=[{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];function no(e){const{chainId:t,maxPriorityFeePerGas:n,maxFeePerGas:r,to:s}=e;if(t<=0)throw new Ia({chainId:t});if(s&&!Qt(s))throw new Kt({address:s});if(r&&r>os)throw new Kr({maxFeePerGas:r});if(n&&r&&n>r)throw new Xr({maxFeePerGas:r,maxPriorityFeePerGas:n})}function ro(e){if(!e||0===e.length)return[];const t=[];for(let n=0;n<e.length;n++){const{address:r,storageKeys:s}=e[n];for(let e=0;e<s.length;e++)if(s[e].length-2!=64)throw new Yn({storageKey:s[e]});if(!Qt(r,{strict:!1}))throw new Kt({address:r});t.push([r,s])}return t}function so(e,t){const n=function(e){if(e.type)return e.type;if(void 0!==e.authorizationList)return"eip7702";if(void 0!==e.blobs||void 0!==e.blobVersionedHashes||void 0!==e.maxFeePerBlobGas||void 0!==e.sidecars)return"eip4844";if(void 0!==e.maxFeePerGas||void 0!==e.maxPriorityFeePerGas)return"eip1559";if(void 0!==e.gasPrice)return void 0!==e.accessList?"eip2930":"legacy";throw new Wn({transaction:e})}(e);return"eip1559"===n?function(e,t){const{chainId:n,gas:r,nonce:s,to:i,value:a,maxFeePerGas:o,maxPriorityFeePerGas:c,accessList:u,data:d}=e;no(e);const l=ro(u),f=[Be(n),s?Be(s):"0x",c?Be(c):"0x",o?Be(o):"0x",r?Be(r):"0x",i??"0x",a?Be(a):"0x",d??"0x",l,...io(e,t)];return Xt(["0x02",Dr(f)])}(e,t):"eip2930"===n?function(e,t){const{chainId:n,gas:r,data:s,nonce:i,to:a,value:o,accessList:c,gasPrice:u}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:s,to:i}=e;if(t<=0)throw new Ia({chainId:t});if(i&&!Qt(i))throw new Kt({address:i});if(n||s)throw new ee("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>os)throw new Kr({maxFeePerGas:r})}(e);const d=ro(c),l=[Be(n),i?Be(i):"0x",u?Be(u):"0x",r?Be(r):"0x",a??"0x",o?Be(o):"0x",s??"0x",d,...io(e,t)];return Xt(["0x01",Dr(l)])}(e,t):"eip4844"===n?function(e,t){const{chainId:n,gas:r,nonce:s,to:i,value:a,maxFeePerBlobGas:o,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=e;!function(e){const{blobVersionedHashes:t}=e;if(t){if(0===t.length)throw new qs;for(const e of t){const t=Y(e),n=Ne(en(e,0,1));if(32!==t)throw new Ls({hash:e,size:t});if(n!==Ds)throw new Fs({hash:e,version:n})}}no(e)}(e);let f=e.blobVersionedHashes,p=e.sidecars;if(e.blobs&&(void 0===f||void 0===p)){const t="string"==typeof e.blobs[0]?e.blobs:e.blobs.map((e=>Ce(e))),n=e.kzg,r=ps({blobs:t,kzg:n});if(void 0===f&&(f=function(e){const{commitments:t,version:n}=e,r=e.to??("string"==typeof t[0]?"hex":"bytes"),s=[];for(const e of t)s.push(Ts({commitment:e,to:r,version:n}));return s}({commitments:r})),void 0===p){p=Ks({blobs:t,commitments:r,proofs:hs({blobs:t,commitments:r,kzg:n})})}}const h=ro(d),m=[Be(n),s?Be(s):"0x",u?Be(u):"0x",c?Be(c):"0x",r?Be(r):"0x",i??"0x",a?Be(a):"0x",l??"0x",h,o?Be(o):"0x",f??[],...io(e,t)],y=[],b=[],g=[];if(p)for(let e=0;e<p.length;e++){const{blob:t,commitment:n,proof:r}=p[e];y.push(t),b.push(n),g.push(r)}return Xt(["0x03",Dr(p?[m,y,b,g]:m)])}(e,t):"eip7702"===n?function(e,t){const{authorizationList:n,chainId:r,gas:s,nonce:i,to:a,value:o,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=e;!function(e){const{authorizationList:t}=e;if(t)for(const e of t){const{chainId:t}=e,n=e.address;if(!Qt(n))throw new Kt({address:n});if(t<0)throw new Ia({chainId:t})}no(e)}(e);const f=ro(d),p=function(e){if(!e||0===e.length)return[];const t=[];for(const n of e){const{chainId:e,nonce:r,...s}=n,i=n.address;t.push([e?_e(e):"0x",i,r?_e(r):"0x",...io({},s)])}return t}(n);return Xt(["0x04",Dr([Be(r),i?Be(i):"0x",u?Be(u):"0x",c?Be(c):"0x",s?Be(s):"0x",a??"0x",o?Be(o):"0x",l??"0x",f,p,...io(e,t)])])}(e,t):function(e,t){const{chainId:n=0,gas:r,data:s,nonce:i,to:a,value:o,gasPrice:c}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:s,to:i}=e;if(i&&!Qt(i))throw new Kt({address:i});if(void 0!==t&&t<=0)throw new Ia({chainId:t});if(n||s)throw new ee("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>os)throw new Kr({maxFeePerGas:r})}(e);let u=[i?Be(i):"0x",c?Be(c):"0x",r?Be(r):"0x",a??"0x",o?Be(o):"0x",s??"0x"];if(t){const e=(()=>{if(t.v>=35n){return(t.v-35n)/2n>0?t.v:27n+(35n===t.v?0n:1n)}if(n>0)return BigInt(2*n)+BigInt(35n+t.v-27n);const e=27n+(27n===t.v?0n:1n);if(t.v!==e)throw new Hn({v:t.v});return e})(),r=Oe(t.r),s=Oe(t.s);u=[...u,Be(e),"0x00"===r?"0x":r,"0x00"===s?"0x":s]}else n>0&&(u=[...u,Be(n),"0x","0x"]);return Dr(u)}(e,t)}function io(e,t){const n=t??e,{v:r,yParity:s}=n;if(void 0===n.r)return[];if(void 0===n.s)return[];if(void 0===r&&void 0===s)return[];const i=Oe(n.r),a=Oe(n.s);return["number"==typeof s?s?Be(1):"0x":0n===r?"0x":1n===r?Be(1):27n===r?"0x":Be(1),"0x00"===i?"0x":i,"0x00"===a?"0x":a]}async function ao({address:e,authorization:t,signature:n}){return Vs(Ht(e),await async function(e){const{authorization:t,signature:n}=e;return Br({hash:Lr(t),signature:n??t})}({authorization:t,signature:n}))}const oo=new Vt(8192);function co(e,t={}){return async(n,r={})=>{const{dedupe:s=!1,methods:i,retryDelay:a=150,retryCount:o=3,uid:c}={...t,...r},{method:u}=n;if(i?.exclude?.includes(u))throw new gr(new Error("method not supported"),{method:u});if(i?.include&&!i.include.includes(u))throw new gr(new Error("method not supported"),{method:u});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(oo.get(n))return oo.get(n);const r=e().finally((()=>oo.delete(n)));return oo.set(n,r),r}((()=>qa((async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case ur.code:throw new ur(t);case dr.code:throw new dr(t);case lr.code:throw new lr(t,{method:n.method});case fr.code:throw new fr(t);case pr.code:throw new pr(t);case hr.code:throw new hr(t);case mr.code:throw new mr(t);case yr.code:throw new yr(t);case br.code:throw new br(t);case gr.code:throw new gr(t,{method:n.method});case wr.code:throw new wr(t);case vr.code:throw new vr(t);case xr.code:throw new xr(t);case Ir.code:throw new Ir(t);case Pr.code:throw new Pr(t);case zr.code:throw new zr(t);case Er.code:throw new Er(t);case Ar.code:throw new Ar(t);case kr.code:throw new kr(t);case Mr.code:throw new Mr(t);case $r.code:throw new $r(t);case Or.code:throw new Or(t);case jr.code:throw new jr(t);case Sr.code:throw new Sr(t);case Nr.code:throw new Nr(t);case 5e3:throw new xr(t);default:if(e instanceof ee)throw e;throw new Tr(t)}}}),{delay:({count:e,error:t})=>{if(t&&t instanceof sr){const e=t?.headers?.get("Retry-After");if(e?.match(/\d/))return 1e3*Number.parseInt(e,10)}return~~(1<<e)*a},retryCount:o,shouldRetry:({error:e})=>function(e){if("code"in e&&"number"==typeof e.code)return-1===e.code||(e.code===wr.code||e.code===pr.code);if(e instanceof sr&&e.status)return 403===e.status||(408===e.status||(413===e.status||(429===e.status||(500===e.status||(502===e.status||(503===e.status||504===e.status))))));return!0}(e)})),{enabled:s,id:s?Ue(`${c}.${Rn(n)}`):void 0})}}function uo(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}function lo(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const fo=lo();function po(e,t={}){return{async request(n){const{body:r,fetchFn:s=t.fetchFn??fetch,onRequest:i=t.onRequest,onResponse:a=t.onResponse,timeout:o=t.timeout??1e4}=n,c={...t.fetchOptions??{},...n.fetchOptions??{}},{headers:u,method:d,signal:l}=c;try{const t=await function(e,{errorInstance:t=new Error("timed out"),timeout:n,signal:r}){return new Promise(((s,i)=>{(async()=>{let a;try{const o=new AbortController;n>0&&(a=setTimeout((()=>{r?o.abort():i(t)}),n)),s(await e({signal:o?.signal||null}))}catch(e){"AbortError"===e?.name&&i(t),i(e)}finally{clearTimeout(a)}})()}))}((async({signal:t})=>{const n={...c,body:Array.isArray(r)?Rn(r.map((e=>({jsonrpc:"2.0",id:e.id??fo.take(),...e})))):Rn({jsonrpc:"2.0",id:r.id??fo.take(),...r}),headers:{"Content-Type":"application/json",...u},method:d||"POST",signal:l||(o>0?t:null)},a=new Request(e,n),f=await(i?.(a,n))??{...n,url:e};return await s(f.url??e,f)}),{errorInstance:new ar({body:r,url:e}),timeout:o,signal:!0});let n;if(a&&await a(t),t.headers.get("Content-Type")?.startsWith("application/json"))n=await t.json();else{n=await t.text();try{n=JSON.parse(n||"{}")}catch(e){if(t.ok)throw e;n={error:n}}}if(!t.ok)throw new sr({body:r,details:Rn(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof sr)throw t;if(t instanceof ar)throw t;throw new sr({body:r,cause:t,url:e})}}}}const ho="Ethereum Signed Message:\n";function mo(e,t){return Dt(function(e){const t="string"==typeof e?Ue(e):"string"==typeof e.raw?e.raw:Ce(e.raw);return Jt([Ue(`${ho}${Y(t)}`),t])}(e),t)}class yo extends ee{constructor({domain:e}){super(`Invalid domain "${Rn(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class bo extends ee{constructor({primaryType:e,types:t}){super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(t))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class go extends ee{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function wo({domain:e}){return["string"==typeof e?.name&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},("number"==typeof e?.chainId||"bigint"==typeof e?.chainId)&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function vo(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new go({type:e})}function xo(e){const{domain:t={},message:n,primaryType:r}=e,s={EIP712Domain:wo({domain:t}),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:s}=e,i=(e,t)=>{for(const n of e){const{name:e,type:r}=n,a=t[e],o=r.match(on);if(o&&("number"==typeof a||"bigint"==typeof a)){const[e,t,n]=o;Be(a,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof a&&!Qt(a))throw new Kt({address:a});const c=r.match(an);if(c){const[e,t]=c;if(t&&Y(a)!==Number.parseInt(t,10))throw new ye({expectedSize:Number.parseInt(t,10),givenSize:Y(a)})}const u=s[r];u&&(vo(r),i(u,a))}};if(s.EIP712Domain&&t){if("object"!=typeof t)throw new yo({domain:t});i(s.EIP712Domain,t)}if("EIP712Domain"!==r){if(!s[r])throw new bo({primaryType:r,types:s});i(s[r],n)}}({domain:t,message:n,primaryType:r,types:s});const i=["0x1901"];return t&&i.push(function({domain:e,types:t}){return Io({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:s})),"EIP712Domain"!==r&&i.push(Io({data:n,primaryType:r,types:s})),Dt(Jt(i))}function Io({data:e,primaryType:t,types:n}){return Dt(Po({data:e,primaryType:t,types:n}))}function Po({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],s=[zo({primaryType:t,types:n})];for(const i of n[t]){const[t,a]=Ao({types:n,name:i.name,type:i.type,value:e[i.name]});r.push(t),s.push(a)}return cn(r,s)}function zo({primaryType:e,types:t}){const n=_e(function({primaryType:e,types:t}){let n="";const r=Eo({primaryType:e,types:t});r.delete(e);const s=[e,...Array.from(r).sort()];for(const e of s)n+=`${e}(${t[e].map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`;return n}({primaryType:e,types:t}));return Dt(n)}function Eo({primaryType:e,types:t},n=new Set){const r=e.match(/^\w*/u),s=r?.[0];if(n.has(s)||void 0===t[s])return n;n.add(s);for(const e of t[s])Eo({primaryType:e.type,types:t},n);return n}function Ao({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},Dt(Po({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},Dt(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},Dt(_e(r))];if(n.lastIndexOf("]")===n.length-1){const s=n.slice(0,n.lastIndexOf("[")),i=r.map((n=>Ao({name:t,type:s,types:e,value:n})));return[{type:"bytes32"},Dt(cn(i.map((([e])=>e)),i.map((([,e])=>e))))]}return[{type:n},r]}class ko extends Error{constructor(e,t={}){const n=t.cause instanceof ko?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof ko&&t.cause.docsPath||t.docsPath;super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...r?[`Docs: https://abitype.dev${r}`]:[],...n?[`Details: ${n}`]:[],"Version: abitype@1.2.3"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),t.cause&&(this.cause=t.cause),this.details=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.shortMessage=e}}function Mo(e,t){const n=e.exec(t);return n?.groups}const $o=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Oo=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,jo=/^\(.+?\).*?$/,So=/^tuple(?<array>(\[(\d*)\])*)$/;function No(e){let t=e.type;if(So.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=No(e.components[r]),r<n-1&&(t+=", ")}const r=Mo(So,e.type);return t+=`)${r?.array||""}`,No({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function To(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=No(e[r]),r!==n-1&&(t+=", ")}return t}const _o=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Ro=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Co=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const Bo=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function Do(e){return Bo.test(e)}function Uo(e){return Mo(Bo,e)}const qo=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const Lo=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const Fo=/^receive\(\) external payable$/;const Ko=new Set(["memory","indexed","storage","calldata"]),Vo=new Set(["indexed"]),Go=new Set(["calldata","memory","storage"]);class Zo extends ko{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class Ho extends ko{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class Wo extends ko{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class Yo extends ko{constructor({params:e}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class Qo extends ko{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class Jo extends ko{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class Xo extends ko{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class ec extends ko{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class tc extends ko{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class nc extends ko{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class rc extends ko{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class sc extends ko{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class ic extends ko{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class ac extends ko{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const oc=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function cc(e,t={}){if(function(e){return Co.test(e)}(e))return function(e,t={}){const n=function(e){return Mo(Co,e)}(e);if(!n)throw new nc({signature:e,type:"function"});const r=pc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(fc(r[e],{modifiers:Go,structs:t,type:"function"}));const a=[];if(n.returns){const e=pc(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(fc(e[n],{modifiers:Go,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:a}}(e,t);if(function(e){return Ro.test(e)}(e))return function(e,t={}){const n=function(e){return Mo(Ro,e)}(e);if(!n)throw new nc({signature:e,type:"event"});const r=pc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(fc(r[e],{modifiers:Vo,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}(e,t);if(function(e){return _o.test(e)}(e))return function(e,t={}){const n=function(e){return Mo(_o,e)}(e);if(!n)throw new nc({signature:e,type:"error"});const r=pc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(fc(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}(e,t);if(function(e){return qo.test(e)}(e))return function(e,t={}){const n=function(e){return Mo(qo,e)}(e);if(!n)throw new nc({signature:e,type:"constructor"});const r=pc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(fc(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}(e,t);if(function(e){return Lo.test(e)}(e))return function(e){const t=function(e){return Mo(Lo,e)}(e);if(!t)throw new nc({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return Fo.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new rc({signature:e})}const uc=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,dc=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,lc=/^u?int$/;function fc(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:`${e}${r}`}(e,t?.type,t?.structs);if(oc.has(n))return oc.get(n);const r=jo.test(e),s=Mo(r?dc:uc,e);if(!s)throw new Qo({param:e});if(s.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||$o.test(e)||Oo.test(e)||mc.test(e)}(s.name))throw new Jo({param:e,name:s.name});const i=s.name?{name:s.name}:{},a="indexed"===s.modifier?{indexed:!0}:{},o=t?.structs??{};let c,u={};if(r){c="tuple";const e=pc(s.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(fc(e[r],{structs:o}));u={components:t}}else if(s.type in o)c="tuple",u={components:o[s.type]};else if(lc.test(s.type))c=`${s.type}256`;else if("address payable"===s.type)c="address";else if(c=s.type,"struct"!==t?.type&&!hc(c))throw new Wo({type:c});if(s.modifier){if(!t?.modifiers?.has?.(s.modifier))throw new Xo({param:e,type:t?.type,modifier:s.modifier});if(Go.has(s.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!s.array))throw new ec({param:e,type:t?.type,modifier:s.modifier})}const d={type:`${c}${s.array??""}`,...i,...a,...u};return oc.set(n,d),d}function pc(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const s=e[i],a=e.slice(i+1);switch(s){case",":return 0===r?pc(a,[...t,n.trim()]):pc(a,t,`${n}${s}`,r);case"(":return pc(a,t,`${n}${s}`,r+1);case")":return pc(a,t,`${n}${s}`,r-1);default:return pc(a,t,`${n}${s}`,r)}}if(""===n)return t;if(0!==r)throw new ac({current:n,depth:r});return t.push(n.trim()),t}function hc(e){return"address"===e||"bool"===e||"function"===e||"string"===e||$o.test(e)||Oo.test(e)}const mc=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function yc(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!Do(n))continue;const s=Uo(n);if(!s)throw new nc({signature:n,type:"struct"});const i=s.properties.split(";"),a=[],o=i.length;for(let e=0;e<o;e++){const t=i[e].trim();if(!t)continue;const n=fc(t,{type:"struct"});a.push(n)}if(!a.length)throw new sc({signature:n});t[s.name]=a}const r={},s=Object.entries(t),i=s.length;for(let e=0;e<i;e++){const[n,i]=s[e];r[n]=gc(i,t)}return r}const bc=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function gc(e=[],t={},n=new Set){const r=[],s=e.length;for(let i=0;i<s;i++){const s=e[i];if(jo.test(s.type))r.push(s);else{const e=Mo(bc,s.type);if(!e?.type)throw new tc({abiParameter:s});const{array:i,type:a}=e;if(a in t){if(n.has(a))throw new ic({type:a});r.push({...s,type:`tuple${i??""}`,components:gc(t[a],t,new Set([...n,a]))})}else{if(!hc(a))throw new Ho({type:a});r.push(s)}}}return r}function wc(e){let t;if("string"==typeof e)t=cc(e);else{const n=yc(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(!Do(r)){t=cc(r,n);break}}}if(!t)throw new Zo({signature:e});return t}function vc(e){const t=[];if("string"==typeof e){const n=pc(e),r=n.length;for(let e=0;e<r;e++)t.push(fc(n[e],{modifiers:Ko}))}else{const n=yc(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(Do(r))continue;const i=pc(r),a=i.length;for(let e=0;e<a;e++)t.push(fc(i[e],{modifiers:Ko,structs:n}))}}if(0===t.length)throw new Yo({params:e});return t}class xc extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const Ic={checksum:new xc(8192)}.checksum;function Pc(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Bt(Ni(e));return"Bytes"===n?r:Qi(r)}const zc=/^0x[a-fA-F0-9]{40}$/;function Ec(e,t={}){const{strict:n=!0}=t;if(!zc.test(e))throw new kc({address:e,cause:new Mc});if(n){if(e.toLowerCase()===e)return;if(Ac(e)!==e)throw new kc({address:e,cause:new $c})}}function Ac(e){if(Ic.has(e))return Ic.get(e);Ec(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=Pc(_i(t),{as:"Bytes"}),r=t.split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&r[e]&&(r[e]=r[e].toUpperCase()),(15&n[e>>1])>=8&&r[e+1]&&(r[e+1]=r[e+1].toUpperCase());const s=`0x${r.join("")}`;return Ic.set(e,s),s}class kc extends Pi{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Mc extends Pi{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class $c extends Pi{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Oc=/^(.*)\[([0-9]*)\]$/,jc=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Sc=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,Nc=2n**256n-1n;function Tc(e,t,n){const{checksumAddress:r,staticPosition:s}=n,i=Dc(t.type);if(i){const[n,a]=i;return function(e,t,n){const{checksumAddress:r,length:s,staticPosition:i}=n;if(!s){const n=i+Ui(e.readBytes(Rc)),s=n+_c;e.setPosition(n);const a=Ui(e.readBytes(_c)),o=Uc(t);let c=0;const u=[];for(let n=0;n<a;++n){e.setPosition(s+(o?32*n:c));const[i,a]=Tc(e,t,{checksumAddress:r,staticPosition:s});c+=a,u.push(i)}return e.setPosition(i+32),[u,32]}if(Uc(t)){const n=i+Ui(e.readBytes(Rc)),a=[];for(let i=0;i<s;++i){e.setPosition(n+32*i);const[s]=Tc(e,t,{checksumAddress:r,staticPosition:n});a.push(s)}return e.setPosition(i+32),[a,32]}let a=0;const o=[];for(let n=0;n<s;++n){const[n,s]=Tc(e,t,{checksumAddress:r,staticPosition:i+a});a+=s,o.push(n)}return[o,a]}(e,{...t,type:a},{checksumAddress:r,length:n,staticPosition:s})}if("tuple"===t.type)return function(e,t,n){const{checksumAddress:r,staticPosition:s}=n,i=0===t.components.length||t.components.some((({name:e})=>!e)),a=i?[]:{};let o=0;if(Uc(t)){const n=s+Ui(e.readBytes(Rc));for(let s=0;s<t.components.length;++s){const c=t.components[s];e.setPosition(n+o);const[u,d]=Tc(e,c,{checksumAddress:r,staticPosition:n});o+=d,a[i?s:c?.name]=u}return e.setPosition(s+32),[a,32]}for(let n=0;n<t.components.length;++n){const c=t.components[n],[u,d]=Tc(e,c,{checksumAddress:r,staticPosition:s});a[i?n:c?.name]=u,o+=d}return[a,o]}(e,t,{checksumAddress:r,staticPosition:s});if("address"===t.type)return function(e,t={}){const{checksum:n=!1}=t,r=e.readBytes(32),s=e=>n?Ac(e):e;return[s(Qi(Ci(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[Di(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const t=Ui(e.readBytes(32));e.setPosition(n+t);const r=Ui(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const s=e.readBytes(r);return e.setPosition(n+32),[Qi(s),32]}const i=Qi(e.readBytes(Number.parseInt(s,10),32));return[i,32]}(e,t,{staticPosition:s});if(t.type.startsWith("uint")||t.type.startsWith("int"))return function(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),s=e.readBytes(32);return[r>48?Bi(s,{signed:n}):Ui(s,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=Ui(e.readBytes(32)),r=t+n;e.setPosition(r);const s=Ui(e.readBytes(32));if(0===s)return e.setPosition(t+32),["",32];const i=e.readBytes(s,32),a=qi(Li(i));return e.setPosition(t+32),[a,32]}(e,{staticPosition:s});throw new tu(t.type)}const _c=32,Rc=32;function Cc({checksumAddress:e=!1,parameter:t,value:n}){const r=t,s=Dc(r.type);if(s){const[t,i]=s;return function(e,t){const{checksumAddress:n,length:r,parameter:s}=t,i=null===r;if(!Array.isArray(e))throw new eu(e);if(!i&&e.length!==r)throw new Qc({expectedLength:r,givenLength:e.length,type:`${s.type}[${r}]`});let a=!1;const o=[];for(let t=0;t<e.length;t++){const r=Cc({checksumAddress:n,parameter:s,value:e[t]});r.dynamic&&(a=!0),o.push(r)}if(i||a){const e=Bc(o);if(i){const t=Ji(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?Wi(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Wi(...o.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:i}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let s=!1;const i=[];for(let t=0;t<r.components.length;t++){const a=r.components[t],o=Cc({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});i.push(o),o.dynamic&&(s=!0)}return{dynamic:s,encoded:s?Bc(i):Wi(...i.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return Ec(e,{strict:n}),{dynamic:!1,encoded:ea(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new Pi(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:ea(Yi(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Sc.exec(r.type)??[];return function(e,{signed:t,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new aa({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Ji(e,{size:32,signed:t})}}(n,{signed:e,size:Number(t)})}if(r.type.startsWith("bytes"))return function(e,{type:t}){const[,n]=t.split("bytes"),r=ra(e);if(!n){let t=e;return r%32!=0&&(t=ta(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:Wi(ea(Ji(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new Jc({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:ta(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=Xi(e),n=Math.ceil(ra(t)/32),r=[];for(let e=0;e<n;e++)r.push(ta(na(t,32*e,32*(e+1))));return{dynamic:!0,encoded:Wi(ta(Ji(ra(t),{size:32})),...r)}}(n);throw new tu(r.type)}function Bc(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:s}=e[n];t+=r?32:ra(s)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(Ji(t+s,{size:32})),r.push(o),s+=ra(o)):n.push(o)}return Wi(...n,...r)}function Dc(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Uc(e){const{type:t}=e;if("string"===t)return!0;if("bytes"===t)return!0;if(t.endsWith("[]"))return!0;if("tuple"===t)return e.components?.some(Uc);const n=Dc(e.type);return!(!n||!Uc({...e,type:n[1]}))}const qc={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Kc({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Fc({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Lc({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new Lc({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};class Lc extends Pi{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class Fc extends Pi{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class Kc extends Pi{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function Vc(e,t,n={}){const{as:r="Array",checksumAddress:s=!1}=n,i="string"==typeof t?Ti(t):t,a=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(qc);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(i);if(0===Ri(i)&&e.length>0)throw new Yc;if(Ri(i)&&Ri(i)<32)throw new Wc({data:"string"==typeof t?t:Qi(t),parameters:e,size:Ri(i)});let o=0;const c="Array"===r?[]:{};for(let t=0;t<e.length;++t){const n=e[t];a.setPosition(o);const[i,u]=Tc(a,n,{checksumAddress:s,staticPosition:0});o+=u,"Array"===r?c.push(i):c[n.name??t]=i}return c}function Gc(e,t,n){const{checksumAddress:r=!1}=n??{};if(e.length!==t.length)throw new Xc({expectedLength:e.length,givenLength:t.length});const s=function({checksumAddress:e,parameters:t,values:n}){const r=[];for(let s=0;s<t.length;s++)r.push(Cc({checksumAddress:e,parameter:t[s],value:n[s]}));return r}({checksumAddress:r,parameters:e,values:t}),i=Bc(s);return 0===i.length?"0x":i}function Zc(e,t){if(e.length!==t.length)throw new Xc({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r];n.push(Zc.encode(s,i))}return Wi(...n)}function Hc(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?vc(e):e}(Zc||(Zc={})).encode=function e(t,n,r=!1){if("address"===t){const e=n;return Ec(e),ea(e.toLowerCase(),r?32:0)}if("string"===t)return Xi(n);if("bytes"===t)return n;if("bool"===t)return ea(Yi(n),r?32:1);const s=t.match(Sc);if(s){const[e,t,i="256"]=s,a=Number.parseInt(i,10)/8;return Ji(n,{size:r?32:a,signed:"int"===t})}const i=t.match(jc);if(i){const[e,t]=i;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new Jc({expectedSize:Number.parseInt(t,10),value:n});return ta(n,r?32:0)}const a=t.match(Oc);if(a&&Array.isArray(n)){const[t,r]=a,s=[];for(let t=0;t<n.length;t++)s.push(e(r,n[t],!0));return 0===s.length?"0x":Wi(...s)}throw new tu(t)};class Wc extends Pi{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${To(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Yc extends Pi{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Qc extends Pi{constructor({expectedLength:e,givenLength:t,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class Jc extends Pi{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${ra(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Xc extends Pi{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class eu extends Pi{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class tu extends Pi{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class nu extends vt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");lt(e.outputLen),lt(e.blockLen)}(e);const n=wt(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),mt(s)}update(e){return pt(this),this.iHash.update(e),this}digestInto(e){pt(this),ft(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:s,blockLen:i,outputLen:a}=this;return e.finished=r,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ru=(e,t,n)=>new nu(e,t).update(n).digest();ru.create=(e,t)=>new nu(e,t);const su=BigInt(0),iu=BigInt(1),au=BigInt(2),ou=BigInt(3),cu=BigInt(4),uu=BigInt(5),du=BigInt(8);function lu(e,t){const n=e%t;return n>=su?n:t+n}function fu(e,t,n){let r=e;for(;t-- >su;)r*=r,r%=n;return r}function pu(e,t){if(e===su)throw new Error("invert: expected non-zero number");if(t<=su)throw new Error("invert: expected positive modulus, got "+t);let n=lu(e,t),r=t,s=su,i=iu;for(;n!==su;){const e=r%n,t=s-i*(r/n);r=n,n=e,s=i,i=t}if(r!==iu)throw new Error("invert: does not exist");return lu(s,t)}function hu(e,t){const n=(e.ORDER+iu)/cu,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function mu(e,t){const n=(e.ORDER-uu)/du,r=e.mul(t,au),s=e.pow(r,n),i=e.mul(t,s),a=e.mul(e.mul(i,au),s),o=e.mul(i,e.sub(a,e.ONE));if(!e.eql(e.sqr(o),t))throw new Error("Cannot find square root");return o}function yu(e){return e%cu===ou?hu:e%du===uu?mu:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-iu,n=0;for(;t%au===su;)t/=au,n++;let r=au;const s=Iu(e);for(;1===vu(s,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return hu;let i=s.pow(r,t);const a=(t+iu)/au;return function(e,r){if(e.is0(r))return r;if(1!==vu(e,r))throw new Error("Cannot find square root");let s=n,o=e.mul(e.ONE,i),c=e.pow(r,t),u=e.pow(r,a);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===s)throw new Error("Cannot find square root");const r=iu<<BigInt(s-t-1),i=e.pow(o,r);s=t,o=e.sqr(i),c=e.mul(c,o),u=e.mul(u,i)}return u}}(e)}const bu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gu(e){return xi(e,bu.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}function wu(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce(((t,n,s)=>e.is0(n)?t:(r[s]=t,e.mul(t,n))),e.ONE),i=e.inv(s);return t.reduceRight(((t,n,s)=>e.is0(n)?t:(r[s]=e.mul(t,r[s]),e.mul(t,n))),i),r}function vu(e,t){const n=(e.ORDER-iu)/au,r=e.pow(t,n),s=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),a=e.eql(r,e.neg(e.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function xu(e,t){void 0!==t&<(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Iu(e,t,n=!1,r={}){if(e<=su)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:s,nByteLength:i}=xu(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const o=Object.freeze({ORDER:e,isLE:n,BITS:s,BYTES:i,MASK:bi(s),ZERO:su,ONE:iu,create:t=>lu(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return su<=t&&t<e},is0:e=>e===su,isOdd:e=>(e&iu)===iu,neg:t=>lu(-t,e),eql:(e,t)=>e===t,sqr:t=>lu(t*t,e),add:(t,n)=>lu(t+n,e),sub:(t,n)=>lu(t-n,e),mul:(t,n)=>lu(t*n,e),pow:(e,t)=>function(e,t,n){if(n<su)throw new Error("invalid exponent, negatives unsupported");if(n===su)return e.ONE;if(n===iu)return t;let r=e.ONE,s=t;for(;n>su;)n&iu&&(r=e.mul(r,s)),s=e.sqr(s),n>>=iu;return r}(o,e,t),div:(t,n)=>lu(t*pu(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>pu(t,e),sqrt:r.sqrt||(t=>(a||(a=yu(e)),a(o,t))),toBytes:e=>n?di(e,i):ui(e,i),fromBytes:e=>{if(e.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);return n?ci(e):oi(e)},invertBatch:e=>wu(o,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(o)}function Pu(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function zu(e){const t=Pu(e);return t+Math.ceil(t/2)}const Eu=BigInt(0),Au=BigInt(1);function ku(e,t){const n=t.negate();return e?n:t}function Mu(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function $u(e,t){Mu(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:bi(e),maxNumber:n,shiftBy:BigInt(e)}}function Ou(e,t,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:a}=n;let o=Number(e&s),c=e>>a;o>r&&(o-=i,c+=Au);const u=t*r;return{nextN:c,offset:u+Math.abs(o)-1,isZero:0===o,isNeg:o<0,isNegF:t%2!=0,offsetF:u}}const ju=new WeakMap,Su=new WeakMap;function Nu(e){return Su.get(e)||1}function Tu(e,t,n,r){!function(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}(n,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}(r,t);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,o=function(e){let t;for(t=0;e>Hs;e>>=Ws,t+=1);return t}(BigInt(s));let c=1;o>12?c=o-3:o>4?c=o-2:o>0&&(c=2);const u=bi(c),d=new Array(Number(u)+1).fill(a);let l=a;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){d.fill(a);for(let t=0;t<i;t++){const s=r[t],i=Number(s>>BigInt(e)&u);d[i]=d[i].add(n[t])}let t=a;for(let e=d.length-1,n=a;e>0;e--)n=n.add(d[e]),t=t.add(n);if(l=l.add(t),0!==e)for(let e=0;e<c;e++)l=l.double()}return l}function _u(e){return gu(e.Fp),xi(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...xu(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function Ru(e){void 0!==e.lowS&&Js("lowS",e.lowS),void 0!==e.prehash&&Js("prehash",e.prehash)}class Cu extends Error{constructor(e=""){super(e)}}const Bu={Err:Cu,_tlv:{encode:(e,t)=>{const{Err:n}=Bu;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=Xs(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?Xs(s.length/2|128):"";return Xs(e)+i+s+t},decode(e,t){const{Err:n}=Bu;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[r++];let i=0;if(!!(128&s)){const e=127&s;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+e);if(a.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===a[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of a)i=i<<8|e;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=s;const a=t.subarray(r,r+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=Bu;if(e<Uu)throw new t("integer: negative integers are not allowed");let n=Xs(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=Bu;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return oi(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Bu,s=li("signature",e),{v:i,l:a}=r.decode(48,s);if(a.length)throw new t("invalid signature: left bytes after parsing");const{v:o,l:c}=r.decode(2,i),{v:u,l:d}=r.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(o),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=Bu,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function Du(e,t){return ri(ui(e,t))}const Uu=BigInt(0),qu=BigInt(1),Lu=BigInt(2),Fu=BigInt(3),Ku=BigInt(4);function Vu(e){const t=function(e){const t=_u(e);xi(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}(e),{Fp:n}=t,r=Iu(t.n,t.nBitLength),s=t.toBytes||((e,t,r)=>{const s=t.toAffine();return fi(Uint8Array.from([4]),n.toBytes(s.x),n.toBytes(s.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){const{a:r,b:s}=t,i=n.sqr(e),a=n.mul(i,e);return n.add(n.add(a,n.mul(e,r)),s)}function o(e,t){const r=n.sqr(t),s=a(e);return n.eql(r,s)}if(!o(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const c=n.mul(n.pow(t.a,Fu),Ku),u=n.mul(n.sqr(t.b),BigInt(27));if(n.is0(n.add(c,u)))throw new Error("bad curve params: a or b");function d(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:s,n:i}=t;if(n&&"bigint"!=typeof e){if(Ys(e)&&(e=ri(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*r,"0")}let a;try{a="bigint"==typeof e?e:oi(li("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return s&&(a=lu(a,i)),yi("private key",a,qu,i),a}function l(e){if(!(e instanceof h))throw new Error("ProjectivePoint expected")}const f=Ii(((e,t)=>{const{px:r,py:s,pz:i}=e;if(n.eql(i,n.ONE))return{x:r,y:s};const a=e.is0();null==t&&(t=a?n.ONE:n.inv(i));const o=n.mul(r,t),c=n.mul(s,t),u=n.mul(i,t);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:o,y:c}})),p=Ii((e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:r,y:s}=e.toAffine();if(!n.isValid(r)||!n.isValid(s))throw new Error("bad point: x or y not FE");if(!o(r,s))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class h{constructor(e,t,r){if(null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t)||n.is0(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required");this.px=e,this.py=t,this.pz=r,Object.freeze(this)}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof h)throw new Error("projective point not allowed");const s=e=>n.eql(e,n.ZERO);return s(t)&&s(r)?h.ZERO:new h(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=wu(n,e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(i(li("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(d(e))}static msm(e,t){return Tu(h,r,e,t)}_setWindowSize(e){b.setWindowSize(this,e)}assertValidity(){p(this)}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:r,pz:s}=this,{px:i,py:a,pz:o}=e,c=n.eql(n.mul(t,o),n.mul(i,s)),u=n.eql(n.mul(r,o),n.mul(a,s));return c&&u}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,s=n.mul(r,Fu),{px:i,py:a,pz:o}=this;let c=n.ZERO,u=n.ZERO,d=n.ZERO,l=n.mul(i,i),f=n.mul(a,a),p=n.mul(o,o),m=n.mul(i,a);return m=n.add(m,m),d=n.mul(i,o),d=n.add(d,d),c=n.mul(e,d),u=n.mul(s,p),u=n.add(c,u),c=n.sub(f,u),u=n.add(f,u),u=n.mul(c,u),c=n.mul(m,c),d=n.mul(s,d),p=n.mul(e,p),m=n.sub(l,p),m=n.mul(e,m),m=n.add(m,d),d=n.add(l,l),l=n.add(d,l),l=n.add(l,p),l=n.mul(l,m),u=n.add(u,l),p=n.mul(a,o),p=n.add(p,p),l=n.mul(p,m),c=n.sub(c,l),d=n.mul(p,f),d=n.add(d,d),d=n.add(d,d),new h(c,u,d)}add(e){l(e);const{px:r,py:s,pz:i}=this,{px:a,py:o,pz:c}=e;let u=n.ZERO,d=n.ZERO,f=n.ZERO;const p=t.a,m=n.mul(t.b,Fu);let y=n.mul(r,a),b=n.mul(s,o),g=n.mul(i,c),w=n.add(r,s),v=n.add(a,o);w=n.mul(w,v),v=n.add(y,b),w=n.sub(w,v),v=n.add(r,i);let x=n.add(a,c);return v=n.mul(v,x),x=n.add(y,g),v=n.sub(v,x),x=n.add(s,i),u=n.add(o,c),x=n.mul(x,u),u=n.add(b,g),x=n.sub(x,u),f=n.mul(p,v),u=n.mul(m,g),f=n.add(u,f),u=n.sub(b,f),f=n.add(b,f),d=n.mul(u,f),b=n.add(y,y),b=n.add(b,y),g=n.mul(p,g),v=n.mul(m,v),b=n.add(b,g),g=n.sub(y,g),g=n.mul(p,g),v=n.add(v,g),y=n.mul(b,v),d=n.add(d,y),y=n.mul(x,v),u=n.mul(w,u),u=n.sub(u,y),y=n.mul(w,b),f=n.mul(x,f),f=n.add(f,y),new h(u,d,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return b.wNAFCached(this,e,h.normalizeZ)}multiplyUnsafe(e){const{endo:r,n:s}=t;yi("scalar",e,Uu,s);const i=h.ZERO;if(e===Uu)return i;if(this.is0()||e===qu)return this;if(!r||b.hasPrecomputes(this))return b.wNAFCachedUnsafe(this,e,h.normalizeZ);let{k1neg:a,k1:o,k2neg:c,k2:u}=r.splitScalar(e),d=i,l=i,f=this;for(;o>Uu||u>Uu;)o&qu&&(d=d.add(f)),u&qu&&(l=l.add(f)),f=f.double(),o>>=qu,u>>=qu;return a&&(d=d.negate()),c&&(l=l.negate()),l=new h(n.mul(l.px,r.beta),l.py,l.pz),d.add(l)}multiply(e){const{endo:r,n:s}=t;let i,a;if(yi("scalar",e,qu,s),r){const{k1neg:t,k1:s,k2neg:o,k2:c}=r.splitScalar(e);let{p:u,f:d}=this.wNAF(s),{p:l,f:f}=this.wNAF(c);u=b.constTimeNegate(t,u),l=b.constTimeNegate(o,l),l=new h(n.mul(l.px,r.beta),l.py,l.pz),i=u.add(l),a=d.add(f)}else{const{p:t,f:n}=this.wNAF(e);i=t,a=n}return h.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=h.BASE,s=(e,t)=>t!==Uu&&t!==qu&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=s(this,t).add(s(e,n));return i.is0()?void 0:i}toAffine(e){return f(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===qu)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===qu?this:n?n(h,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return Js("isCompressed",e),this.assertValidity(),s(h,this,e)}toHex(e=!0){return Js("isCompressed",e),ri(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const{endo:m,nBitLength:y}=t,b=(g=h,w=m?Math.ceil(y/2):y,{constTimeNegate:ku,hasPrecomputes:e=>1!==Nu(e),unsafeLadder(e,t,n=g.ZERO){let r=e;for(;t>Eu;)t&Au&&(n=n.add(r)),r=r.double(),t>>=Au;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=$u(t,w),s=[];let i=e,a=i;for(let e=0;e<n;e++){a=i,s.push(a);for(let e=1;e<r;e++)a=a.add(i),s.push(a);i=a.double()}return s},wNAF(e,t,n){let r=g.ZERO,s=g.BASE;const i=$u(e,w);for(let e=0;e<i.windows;e++){const{nextN:a,offset:o,isZero:c,isNeg:u,isNegF:d,offsetF:l}=Ou(n,e,i);n=a,c?s=s.add(ku(d,t[l])):r=r.add(ku(u,t[o]))}return{p:r,f:s}},wNAFUnsafe(e,t,n,r=g.ZERO){const s=$u(e,w);for(let e=0;e<s.windows&&n!==Eu;e++){const{nextN:i,offset:a,isZero:o,isNeg:c}=Ou(n,e,s);if(n=i,!o){const e=t[a];r=r.add(c?e.negate():e)}}return r},getPrecomputes(e,t,n){let r=ju.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&ju.set(t,n(r))),r},wNAFCached(e,t,n){const r=Nu(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const s=Nu(e);return 1===s?this.unsafeLadder(e,t,r):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),t,r)},setWindowSize(e,t){Mu(t,w),Su.set(e,t),ju.delete(e)}});var g,w;return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:d,weierstrassEquation:a,isWithinCurveOrder:function(e){return mi(e,qu,t.n)}}}function Gu(e){const t=function(e){const t=_u(e);return xi(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r,nByteLength:s,nBitLength:i}=t,a=n.BYTES+1,o=2*n.BYTES+1;function c(e){return lu(e,r)}function u(e){return pu(e,r)}const{ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:f,isWithinCurveOrder:p}=Vu({...t,toBytes(e,t,r){const s=t.toAffine(),i=n.toBytes(s.x),a=fi;return Js("isCompressed",r),r?a(Uint8Array.from([t.hasEvenY()?2:3]),i):a(Uint8Array.from([4]),i,n.toBytes(s.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==a||2!==r&&3!==r){if(t===o&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error("invalid Point, expected length of "+a+", or uncompressed "+o+", got "+t)}{const e=oi(s);if(!mi(e,qu,n.ORDER))throw new Error("Point is not on curve");const t=f(e);let i;try{i=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return 1==(1&r)!==((i&qu)===qu)&&(i=n.neg(i)),{x:e,y:i}}}});function h(e){return e>r>>qu}const m=(e,t,n)=>oi(e.slice(t,n));class y{constructor(e,t,n){yi("r",e,qu,r),yi("s",t,qu,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=s;return e=li("compactSignature",e,2*t),new y(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=Bu.toSig(li("DER",e));return new y(t,n)}assertValidity(){}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:s,recovery:i}=this,a=v(li("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const o=2===i||3===i?r+t.n:r;if(o>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=0==(1&i)?"02":"03",f=d.fromHex(l+Du(o,n.BYTES)),p=u(o),h=c(-a*p),m=c(s*p),y=d.BASE.multiplyAndAddUnsafe(f,h,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return ai(this.toDERHex())}toDERHex(){return Bu.hexFromSig(this)}toCompactRawBytes(){return ai(this.toCompactHex())}toCompactHex(){const e=s;return Du(this.r,e)+Du(this.s,e)}}const b={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=zu(t.n);return function(e,t,n=!1){const r=e.length,s=Pu(t),i=zu(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const a=lu(n?ci(e):oi(e),t-iu)+iu;return n?di(a,s):ui(a,s)}(t.randomBytes(e),t.n)},precompute:(e=8,t=d.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function g(e){if("bigint"==typeof e)return!1;if(e instanceof d)return!0;const r=li("key",e).length,i=n.BYTES,a=i+1,o=2*i+1;return t.allowedPrivateKeyLengths||s===a?void 0:r===a||r===o}const w=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=oi(e),n=8*e.length-i;return n>0?t>>BigInt(n):t},v=t.bits2int_modN||function(e){return c(w(e))},x=bi(i);function I(e){return yi("num < 2^"+i,e,Uu,x),ui(e,s)}function P(e,r,s=z){if(["recovered","canonical"].some((e=>e in s)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:a}=t;let{lowS:o,prehash:f,extraEntropy:m}=s;null==o&&(o=!0),e=li("msgHash",e),Ru(s),f&&(e=li("prehashed msgHash",i(e)));const b=v(e),g=l(r),x=[I(g),I(b)];if(null!=m&&!1!==m){const e=!0===m?a(n.BYTES):m;x.push(li("extraEntropy",e))}const P=fi(...x),E=b;return{seed:P,k2sig:function(e){const t=w(e);if(!p(t))return;const n=u(t),r=d.BASE.multiply(t).toAffine(),s=c(r.x);if(s===Uu)return;const i=c(n*c(E+s*g));if(i===Uu)return;let a=(r.x===s?0:2)|Number(r.y&qu),l=i;return o&&h(i)&&(l=function(e){return h(e)?c(-e):e}(i),a^=1),new y(s,l,a)}}}const z={lowS:t.lowS,prehash:!1},E={lowS:t.lowS,prehash:!1};return d.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return d.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(!0===g(e))throw new Error("first arg must be private key");if(!1===g(t))throw new Error("second arg must be public key");return d.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,n,r=z){const{seed:s,k2sig:i}=P(e,n,r),a=t,o=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=gi(e),s=gi(e),i=0;const a=()=>{r.fill(1),s.fill(0),i=0},o=(...e)=>n(s,r,...e),c=(e=gi(0))=>{s=o(wi([0]),e),r=o(),0!==e.length&&(s=o(wi([1]),e),r=o())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=o();const t=r.slice();n.push(t),e+=r.length}return fi(...n)};return(e,t)=>{let n;for(a(),c(e);!(n=t(u()));)c();return a(),n}}(a.hash.outputLen,a.nByteLength,a.hmac);return o(s,i)},verify:function(e,n,r,s=E){const i=e;n=li("msgHash",n),r=li("publicKey",r);const{lowS:a,prehash:o,format:l}=s;if(Ru(s),"strict"in s)throw new Error("options.strict was renamed to lowS");if(void 0!==l&&"compact"!==l&&"der"!==l)throw new Error("format must be compact or der");const f="string"==typeof i||Ys(i),p=!f&&!l&&"object"==typeof i&&null!==i&&"bigint"==typeof i.r&&"bigint"==typeof i.s;if(!f&&!p)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let h,m;try{if(p&&(h=new y(i.r,i.s)),f){try{"compact"!==l&&(h=y.fromDER(i))}catch(e){if(!(e instanceof Bu.Err))throw e}h||"der"===l||(h=y.fromCompact(i))}m=d.fromHex(r)}catch(e){return!1}if(!h)return!1;if(a&&h.hasHighS())return!1;o&&(n=t.hash(n));const{r:b,s:g}=h,w=v(n),x=u(g),I=c(w*x),P=c(b*x),z=d.BASE.multiplyAndAddUnsafe(m,I,P)?.toAffine();return!!z&&c(z.x)===b},ProjectivePoint:d,Signature:y,utils:b}}function Zu(e,t){if(gu(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=function(e,t){const n=e.ORDER;let r=Uu;for(let e=n-qu;e%Lu===Uu;e/=Lu)r+=qu;const s=r,i=Lu<<s-qu-qu,a=i*Lu,o=(n-qu)/a,c=(o-qu)/Lu,u=a-qu,d=i,l=e.pow(t,o),f=e.pow(t,(o+qu)/Lu);let p=(t,n)=>{let r=l,i=e.pow(n,u),a=e.sqr(i);a=e.mul(a,n);let o=e.mul(t,a);o=e.pow(o,c),o=e.mul(o,i),i=e.mul(o,n),a=e.mul(o,t);let p=e.mul(a,i);o=e.pow(p,d);let h=e.eql(o,e.ONE);i=e.mul(a,f),o=e.mul(p,r),a=e.cmov(i,a,h),p=e.cmov(o,p,h);for(let t=s;t>qu;t--){let n=t-Lu;n=Lu<<n-qu;let s=e.pow(p,n);const o=e.eql(s,e.ONE);i=e.mul(a,r),r=e.mul(r,r),s=e.mul(p,r),a=e.cmov(i,a,o),p=e.cmov(s,p,o)}return{isValid:h,value:a}};if(e.ORDER%Ku===Fu){const n=(e.ORDER-Fu)/Ku,r=e.sqrt(e.neg(t));p=(t,s)=>{let i=e.sqr(s);const a=e.mul(t,s);i=e.mul(i,a);let o=e.pow(i,n);o=e.mul(o,a);const c=e.mul(o,r),u=e.mul(e.sqr(o),s),d=e.eql(u,t);return{isValid:d,value:e.cmov(c,o,d)}}}return p}(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let s,i,a,o,c,u,d,l;s=e.sqr(r),s=e.mul(s,t.Z),i=e.sqr(s),i=e.add(i,s),a=e.add(i,e.ONE),a=e.mul(a,t.B),o=e.cmov(t.Z,e.neg(i),!e.eql(i,e.ZERO)),o=e.mul(o,t.A),i=e.sqr(a),u=e.sqr(o),c=e.mul(u,t.A),i=e.add(i,c),i=e.mul(i,a),u=e.mul(u,o),c=e.mul(u,t.B),i=e.add(i,c),d=e.mul(s,a);const{isValid:f,value:p}=n(i,u);l=e.mul(s,r),l=e.mul(l,p),d=e.cmov(d,a,f),l=e.cmov(l,p,f);const h=e.isOdd(r)===e.isOdd(l);l=e.cmov(e.neg(l),l,h);const m=wu(e,[o],!0)[0];return d=e.mul(d,m),{x:d,y:l}}}function Hu(e){return{hash:e,hmac:(t,...n)=>ru(e,t,function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];ft(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const s=e[t];n.set(s,r),r+=s.length}return n}(...n)),randomBytes:It}}function Wu(e,t){const n=t=>Gu({...e,...Hu(t)});return{...n(t),create:n}}const Yu=oi;function Qu(e,t){if(Xu(e),Xu(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function Ju(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function Xu(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function ed(e,t,n){xi(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:s,m:i,hash:a,expand:o,DST:c}=n;Qs(e),Xu(t);const u="string"==typeof c?pi(c):c,d=r.toString(2).length,l=Math.ceil((d+s)/8),f=t*i*l;let p;if("xmd"===o)p=function(e,t,n,r){Qs(e),Qs(t),Xu(n),t.length>255&&(t=r(fi(pi("H2C-OVERSIZE-DST-"),t)));const{outputLen:s,blockLen:i}=r,a=Math.ceil(n/s);if(n>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");const o=fi(t,Qu(t.length,1)),c=Qu(0,i),u=Qu(n,2),d=new Array(a),l=r(fi(c,e,u,Qu(0,1),o));d[0]=r(fi(l,Qu(1,1),o));for(let e=1;e<=a;e++){const t=[Ju(l,d[e-1]),Qu(e+1,1),o];d[e]=r(fi(...t))}return fi(...d).slice(0,n)}(e,u,f,a);else if("xof"===o)p=function(e,t,n,r,s){if(Qs(e),Qs(t),Xu(n),t.length>255){const e=Math.ceil(2*r/8);t=s.create({dkLen:e}).update(pi("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:n}).update(e).update(Qu(n,2)).update(t).update(Qu(t.length,1)).digest()}(e,u,f,s,a);else{if("_internal_pass"!==o)throw new Error('expand must be "xmd" or "xof"');p=e}const h=new Array(t);for(let e=0;e<t;e++){const t=new Array(i);for(let n=0;n<i;n++){const s=l*(n+e*i),a=p.subarray(s,s+l);t[n]=lu(Yu(a),r)}h[e]=t}return h}const td=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),nd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),rd=BigInt(0),sd=BigInt(1),id=BigInt(2),ad=(e,t)=>(e+t/id)/t;function od(e){const t=td,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),a=BigInt(23),o=BigInt(44),c=BigInt(88),u=e*e*e%t,d=u*u*e%t,l=fu(d,n,t)*d%t,f=fu(l,n,t)*d%t,p=fu(f,id,t)*u%t,h=fu(p,s,t)*p%t,m=fu(h,i,t)*h%t,y=fu(m,o,t)*m%t,b=fu(y,c,t)*y%t,g=fu(b,o,t)*m%t,w=fu(g,n,t)*d%t,v=fu(w,a,t)*h%t,x=fu(v,r,t)*u%t,I=fu(x,id,t);if(!cd.eql(cd.sqr(I),e))throw new Error("Cannot find square root");return I}const cd=Iu(td,void 0,void 0,{sqrt:od}),ud=Wu({a:rd,b:BigInt(7),Fp:cd,n:nd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=nd,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-sd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,a=BigInt("0x100000000000000000000000000000000"),o=ad(i*e,t),c=ad(-r*e,t);let u=lu(e-o*n-c*s,t),d=lu(-o*r-c*i,t);const l=u>a,f=d>a;if(l&&(u=t-u),f&&(d=t-d),u>a||d>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:u,k2neg:f,k2:d}}}},Os),dd={};function ld(e,...t){let n=dd[e];if(void 0===n){const t=Os(Uint8Array.from(e,(e=>e.charCodeAt(0))));n=fi(t,t),dd[e]=n}return Os(fi(n,...t))}const fd=e=>e.toRawBytes(!0).slice(1),pd=e=>ui(e,32),hd=e=>lu(e,td),md=e=>lu(e,nd),yd=(()=>ud.ProjectivePoint)(),bd=(e,t,n)=>yd.BASE.multiplyAndAddUnsafe(e,t,n);function gd(e){let t=ud.utils.normPrivateKeyToScalar(e),n=yd.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:md(-t),bytes:fd(n)}}function wd(e){yi("x",e,sd,td);const t=hd(e*e);let n=od(hd(t*e+BigInt(7)));n%id!==rd&&(n=hd(-n));const r=new yd(e,n,sd);return r.assertValidity(),r}const vd=oi;function xd(...e){return md(vd(ld("BIP0340/challenge",...e)))}function Id(e){return gd(e).bytes}function Pd(e,t,n=It(32)){const r=li("message",e),{bytes:s,scalar:i}=gd(t),a=li("auxRand",n,32),o=pd(i^vd(ld("BIP0340/aux",a))),c=ld("BIP0340/nonce",o,s,r),u=md(vd(c));if(u===rd)throw new Error("sign failed: k is zero");const{bytes:d,scalar:l}=gd(u),f=xd(d,s,r),p=new Uint8Array(64);if(p.set(d,0),p.set(pd(md(l+f*i)),32),!zd(p,r,s))throw new Error("sign: Invalid signature produced");return p}function zd(e,t,n){const r=li("signature",e,64),s=li("message",t),i=li("publicKey",n,32);try{const e=wd(vd(i)),t=vd(r.subarray(0,32));if(!mi(t,sd,td))return!1;const n=vd(r.subarray(32,64));if(!mi(n,sd,nd))return!1;const a=xd(pd(t),fd(e),s),o=bd(e,n,md(-a));return!(!o||!o.hasEvenY()||o.toAffine().x!==t)}catch(e){return!1}}const Ed=(()=>({getPublicKey:Id,sign:Pd,verify:zd,utils:{randomPrivateKey:ud.utils.randomPrivateKey,lift_x:wd,pointToBytes:fd,numberToBytesBE:ui,bytesToNumberBE:oi,taggedHash:ld,mod:lu}}))(),Ad=(()=>function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[s,i,a,o]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r))))),[c,u]=wu(e,[i,o],!0);return t=e.mul(s,c),r=e.mul(r,e.mul(a,u)),{x:t,y:r}}}(cd,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))))(),kd=(()=>Zu(cd,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:cd.create(BigInt("-11"))}))(),Md=(()=>function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");function r(n){return e.fromAffine(t(n))}function s(t){const n=t.clearCofactor();return n.equals(e.ZERO)?e.ZERO:(n.assertValidity(),n)}return{defaults:n,hashToCurve(e,t){const i=ed(e,2,{...n,DST:n.DST,...t}),a=r(i[0]),o=r(i[1]);return s(a.add(o))},encodeToCurve:(e,t)=>s(r(ed(e,1,{...n,DST:n.encodeDST,...t})[0])),mapToCurve(e){if(!Array.isArray(e))throw new Error("expected array of bigints");for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return s(r(e))}}}(ud.ProjectivePoint,(e=>{const{x:t,y:n}=kd(cd.create(e[0]));return Ad(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:cd.ORDER,m:1,k:128,expand:"xmd",hash:Os}))(),$d=(()=>Md.hashToCurve)(),Od=(()=>Md.encodeToCurve)();var jd=Object.freeze({__proto__:null,secp256k1:ud,schnorr:Ed,secp256k1_hasher:Md,hashToCurve:$d,encodeToCurve:Od});function Sd(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new Cd({signature:e});if(void 0===e.s)throw new Cd({signature:e});if(n&&void 0===e.yParity)throw new Cd({signature:e});if(e.r<0n||e.r>Nc)throw new Bd({value:e.r});if(e.s<0n||e.s>Nc)throw new Dd({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new Ud({value:e.yParity})}function Nd(e){if(130!==e.length&&132!==e.length)throw new Rd({signature:e});const t=BigInt(na(e,0,32)),n=BigInt(na(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return _d(t)}catch{throw new Ud({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function Td(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?Nd(e):e instanceof Uint8Array?function(e){return Nd(Qi(e))}(e):"string"==typeof e.r?function(e){const t=(()=>{const t=e.v?Number(e.v):void 0;let n=e.yParity?Number(e.yParity):void 0;if("number"==typeof t&&"number"!=typeof n&&(n=_d(t)),"number"!=typeof n)throw new Ud({value:e.yParity});return n})();return{r:BigInt(e.r),s:BigInt(e.s),yParity:t}}(e):e.v?function(e){return{r:e.r,s:e.s,yParity:_d(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return Sd(t),t}(e)}function _d(e){if(0===e||27===e)return 0;if(1===e||28===e)return 1;if(e>=35)return e%2==0?1:0;throw new qd({value:e})}class Rd extends Pi{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${ra((t=e,t instanceof Uint8Array?Qi(t):Array.isArray(t)?Qi(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class Cd extends Pi{constructor({signature:e}){var t,n,r;super(`Signature \`${t=e,JSON.stringify(t,((e,t)=>"function"==typeof n?n(e,t):"bigint"==typeof t?t.toString()+"#__bigint":t),r)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class Bd extends Pi{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class Dd extends Pi{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class Ud extends Pi{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class qd extends Pi{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function Ld(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,s=Td(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...s}}(e):{...e,...t.signature}}const Fd="0x8010801080108010801080108010801080108010801080108010801080108010",Kd=Hc("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function Vd(e){if("string"==typeof e){if(na(e,-32)!==Fd)throw new Gd(e)}else Sd(e.authorization)}class Gd extends Pi{constructor(e){super(`Value \`${e}\` is an invalid ERC-8010 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc8010.InvalidWrappedSignatureError"})}}function Zd(e){const t="string"==typeof e?e:function(e){return"function"===e.type?`function ${e.name}(${To(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${To(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${To(e.inputs)})`:"error"===e.type?`error ${e.name}(${To(e.inputs)})`:"constructor"===e.type?`constructor(${To(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}(e);return function(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),"("===o&&r++,")"===o&&r--,t)if(0!==r)" "!==o?(s+=o,n+=o):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===o&&["event","function","error",""].includes(s))s="";else if(s+=o,")"===o){i=!0;break}}if(!i)throw new Pi("Unable to normalize signature.");return s}(t)}function Hd(e){return"string"!=typeof e&&"hash"in e&&e.hash?e.hash:Pc(Xi(Zd(e)))}const Wd="0x0000000000000000000000000000000000000000",Yd="0x6492649264926492649264926492649264926492649264926492649264926492";function Qd(e){try{return function(e){if(na(e,-32)!==Yd)throw new Jd(e)}(e),!0}catch{return!1}}class Jd extends Pi{constructor(e){super(`Value \`${e}\` is an invalid ERC-6492 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc6492.InvalidWrappedSignatureError"})}}async function Xd(e,t){const{address:n,hash:r,erc6492VerifierAddress:s=t.universalSignatureVerifierAddress??e.chain?.contracts?.erc6492Verifier?.address,multicallAddress:i=t.multicallAddress??e.chain?.contracts?.multicall3?.address}=t,a=(()=>{const e=t.signature;return W(e)?e:"object"==typeof e&&"r"in e&&"s"in e?function({r:e,s:t,to:n="hex",v:r,yParity:s}){const i=(()=>{if(0===s||1===s)return s;if(r&&(27n===r||28n===r||r>=35n))return r%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),a=`0x${new ud.Signature(Se(e),Se(t)).toCompactHex()}${0===i?"1b":"1c"}`;return"hex"===n?a:Ve(a)}(e):Ce(e)})();try{return function(e){try{return Vd(e),!0}catch{return!1}}(a)?await async function(e,t){const{address:n,blockNumber:r,blockTag:s,hash:i,multicallAddress:a}=t,{authorization:o,data:c,signature:u,to:d}=function(e){Vd(e);const t=ia(na(e,-64,-32)),n=na(e,-t-64,-64),r=na(e,0,-t-64),[s,i,a]=Vc(Kd,n);return{authorization:Ld({address:s.delegation,chainId:Number(s.chainId),nonce:s.nonce,yParity:s.yParity,r:s.r,s:s.s}),signature:r,...a&&"0x"!==a?{data:a,to:i}:{}}}(t.signature),l=await async function(e,{address:t,blockNumber:n,blockTag:r="latest"}){const s=void 0!==n?Be(n):void 0,i=await e.request({method:"eth_getCode",params:[t,s||r]},{dedupe:Boolean(s)});if("0x"!==i)return i}(e,{address:n,blockNumber:r,blockTag:s});if(l===Xt(["0xef0100",o.address]))return await async function(e,t){const{address:n,blockNumber:r,blockTag:s,hash:i,signature:a}=t,o=await G(e,ja,"readContract")({address:n,abi:pa,args:[i,a],blockNumber:r,blockTag:s,functionName:"isValidSignature"}).catch((e=>{if(e instanceof Xn)throw new el;throw e}));if(o.startsWith("0x1626ba7e"))return!0;throw new el}(e,{address:n,blockNumber:r,blockTag:s,hash:i,signature:u});const f={address:o.address,chainId:Number(o.chainId),nonce:Number(o.nonce),r:Be(o.r,{size:32}),s:Be(o.s,{size:32}),yParity:o.yParity},p=await ao({address:n,authorization:f});if(!p)throw new el;const h=await G(e,ja,"readContract")({...a?{address:a}:{code:wa},authorizationList:[f],abi:la,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:d??n,callData:c}]:[],{allowFailure:!0,target:n,callData:gn({abi:pa,functionName:"isValidSignature",args:[i,u]})}]]}),m=h[h.length-1]?.returnData;if(m?.startsWith("0x1626ba7e"))return!0;throw new el}(e,{...t,multicallAddress:i,signature:a}):await async function(e,t){const{address:n,factory:r,factoryData:s,hash:i,signature:a,verifierAddress:o,...c}=t,u=await(async()=>r||s?Qd(a)?a:function(e){const{data:t,signature:n,to:r}=e;return Wi(Gc(Hc("address, bytes, bytes"),[r,t,n]),Yd)}({data:s,signature:a,to:r}):a)(),d=o?{to:o,data:gn({abi:ha,functionName:"isValidSig",args:[n,i,u]}),...c}:{data:za({abi:ha,args:[n,i,u],bytecode:ga}),...c},{data:l}=await G(e,$a,"call")(d).catch((e=>{if(e instanceof Jn)throw new el;throw e}));if(function(e,t={}){let n=e;if(t.size&&(je(n,{size:t.size}),n=Oe(n)),"0x00"===Oe(n))return!1;if("0x01"===Oe(n))return!0;throw new Me(n)}(l??"0x0"))return!0;throw new el}(e,{...t,verifierAddress:s,signature:a})}catch(e){try{if(Vs(Ht(n),await Br({hash:r,signature:a})))return!0}catch{}if(e instanceof el)return!1;throw e}}class el extends Error{}function tl({key:e,methods:t,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:a,type:o},c){return{config:{key:e,methods:t,name:n,request:r,retryCount:s,retryDelay:i,timeout:a,type:o},request:co(r,{methods:t,retryCount:s,retryDelay:i,uid:Ja()}),value:c}}function nl(e,t={}){const{key:n="fallback",name:r="Fallback",rank:s=!1,shouldThrow:i=rl,retryCount:a,retryDelay:o}=t;return({chain:t,pollingInterval:c=4e3,timeout:u,...d})=>{let l=e,f=()=>{};const p=tl({key:n,name:r,async request({method:e,params:n}){let r;const s=async(a=0)=>{const o=l[a]({...d,chain:t,retryCount:0,timeout:u});try{const t=await o.request({method:e,params:n});return f({method:e,params:n,response:t,transport:o,status:"success"}),t}catch(c){if(f({error:c,method:e,params:n,transport:o,status:"error"}),i(c))throw c;if(a===l.length-1)throw c;if(r??=l.slice(a+1).some((n=>{const{include:r,exclude:s}=n({chain:t}).config.methods||{};return r?r.includes(e):!s||!s.includes(e)})),!r)throw c;return s(a+1)}};return s()},retryCount:a,retryDelay:o,type:"fallback"},{onResponse:e=>f=e,transports:l.map((e=>e({chain:t,retryCount:0})))});if(s){const e="object"==typeof s?s:{};!function({chain:e,interval:t=4e3,onTransports:n,ping:r,sampleCount:s=10,timeout:i=1e3,transports:a,weights:o={}}){const{stability:c=.7,latency:u=.3}=o,d=[],l=async()=>{const o=await Promise.all(a.map((async t=>{const n=t({chain:e,retryCount:0,timeout:i}),s=Date.now();let a,o;try{await(r?r({transport:n}):n.request({method:"net_listening"})),o=1}catch{o=0}finally{a=Date.now()}return{latency:a-s,success:o}})));d.push(o),d.length>s&&d.shift();const f=Math.max(...d.map((e=>Math.max(...e.map((({latency:e})=>e)))))),p=a.map(((e,t)=>{const n=d.map((e=>e[t].latency)),r=1-n.reduce(((e,t)=>e+t),0)/n.length/f,s=d.map((e=>e[t].success)),i=s.reduce(((e,t)=>e+t),0)/s.length;return 0===i?[0,t]:[u*r+c*i,t]})).sort(((e,t)=>t[0]-e[0]));n(p.map((([,e])=>a[e]))),await Ra(t),l()};l()}({chain:t,interval:e.interval??c,onTransports:e=>l=e,ping:e.ping,sampleCount:e.sampleCount,timeout:e.timeout,transports:l,weights:e.weights})}return p}}function rl(e){return!(!("code"in e)||"number"!=typeof e.code||e.code!==br.code&&e.code!==xr.code&&!Fr.nodeMessage.test(e.message)&&5e3!==e.code)}class sl extends ee{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function il(e,t={}){const{batch:n,fetchOptions:r,key:s="http",methods:i,name:a="HTTP JSON-RPC",onFetchRequest:o,onFetchResponse:c,retryDelay:u,raw:d}=t;return({chain:l,retryCount:f,timeout:p})=>{const{batchSize:h=1e3,wait:m=0}="object"==typeof n?n:{},y=t.retryCount??f,b=p??t.timeout??1e4,g=e||l?.rpcUrls.default.http[0];if(!g)throw new sl;const w=po(g,{fetchOptions:r,onRequest:o,onResponse:c,timeout:b});return tl({key:s,methods:i,name:a,async request({method:e,params:t}){const r={method:e,params:t},{schedule:s}=Ma({id:g,wait:m,shouldSplitBatch:e=>e.length>h,fn:e=>w.request({body:e}),sort:(e,t)=>e.id-t.id}),[{error:i,result:a}]=await(async e=>n?s(e):[await w.request({body:e})])(r);if(d)return{error:i,result:a};if(i)throw new ir({body:r,error:i,url:g});return a},retryCount:y,retryDelay:u,timeout:b,type:"http"},{fetchOptions:r,url:g})}}const al={transaction:function(e,t){return function(e){return"deposit"===e.type||void 0!==e.sourceHash}(e)?function(e){!function(e){const{from:t,to:n}=e;if(t&&!Qt(t))throw new Kt({address:t});if(n&&!Qt(n))throw new Kt({address:n})}(e);const{sourceHash:t,data:n,from:r,gas:s,isSystemTx:i,mint:a,to:o,value:c}=e,u=[t,r,o??"0x",a?_e(a):"0x",c?_e(c):"0x",s?_e(s):"0x",i?"0x1":"0x",n??"0x"];return Xt(["0x7e",Dr(u)])}(e):so(e,t)}};const ol={blockTime:2e3,contracts:{gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},formatters:{block:fs({format(e){const t=e.transactions?.map((e=>{if("string"==typeof e)return e;const t=us(e);return"0x7e"===t.typeHex&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Se(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}));return{transactions:t,stateRoot:e.stateRoot}}}),transaction:ds({format(e){const t={};return"0x7e"===e.type&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Se(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Ka({format:e=>({l1GasPrice:e.l1GasPrice?Se(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Se(e.l1GasUsed):null,l1Fee:e.l1Fee?Se(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null})})},serializers:al},cl=11155111,ul=uo({...ol,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...ol.contracts,disputeGameFactory:{[cl]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[cl]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[cl]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[cl]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:cl}),dl=uo({id:11155931,name:"RISE Testnet",nativeCurrency:{name:"RISE Testnet Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://testnet.riselabs.xyz"],webSocket:["wss://testnet.riselabs.xyz/ws"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.testnet.riselabs.xyz/",apiUrl:"https://explorer.testnet.riselabs.xyz/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"}},testnet:!0});var ll=Object.freeze({__proto__:null,baseSepolia:ul,riseTestnet:dl});const fl=[dl,...Object.values(ll).filter((e=>e.id!==dl.id))],pl="#__bigint";function hl(e,t,n){return JSON.stringify(e,((e,n)=>"function"==typeof t?t(e,n):"bigint"==typeof n?n.toString()+pl:n),n)}class ml extends Error{static setStaticOptions(e){ml.prototype.docsOrigin=e.docsOrigin,ml.prototype.showVersion=e.showVersion,ml.prototype.version=e.version}constructor(e,t={}){const n=(()=>{if(t.cause instanceof ml){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&"string"==typeof t.cause.details?t.cause.details:t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof ml&&t.cause.docsPath||t.docsPath,s=t.docsOrigin??ml.prototype.docsOrigin,i=`${s}${r??""}`,a=Boolean(t.version??ml.prototype.showVersion),o=t.version??ml.prototype.version;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r||a?["",n?`Details: ${n}`:void 0,r?`See: ${i}`:void 0,a?`Version: ${o}`:void 0]:[]].filter((e=>"string"==typeof e)).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsOrigin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showVersion",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.cause=t.cause,this.details=n,this.docs=i,this.docsOrigin=s,this.docsPath=r,this.shortMessage=e,this.showVersion=a,this.version=o}walk(e){return yl(this,e)}}function yl(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?yl(e.cause,t):t?null:e}function bl(e){const t=e;if(t instanceof Error&&!("code"in t))return new $l({cause:t,data:t,message:t.message,stack:t.stack});const{code:n}=t;return n===$l.code?new $l(t):n===wl.code?new wl(t):n===Ml.code?new Ml(t):n===Al.code?new Al(t):n===zl.code?new zl(t):n===kl.code?new kl(t):n===Pl.code?new Pl(t):n===Ol.code?new Ol(t):n===vl.code?new vl(t):n===xl.code?new xl(t):n===Il.code?new Il(t):n===El.code?new El(t):new $l({cause:t instanceof Error?t:void 0,data:t,message:t.message,stack:t instanceof Error?t.stack:void 0})}Object.defineProperty(ml,"defaultStaticOptions",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:"https://oxlib.sh",showVersion:!1,version:"ox@0.1.1"}}),ml.setStaticOptions(ml.defaultStaticOptions);class gl extends Error{constructor(e){const{cause:t,code:n,message:r,data:s,stack:i}=e;super(r,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.BaseError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t,this.code=n,this.data=s,this.stack=i??""}}class wl extends gl{constructor(e={}){super({code:wl.code,data:e.data,message:e.message??"Missing or invalid parameters."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidInputError"})}}Object.defineProperty(wl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class vl extends gl{constructor(e={}){super({code:vl.code,data:e.data,message:e.message??"Requested resource not found."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceNotFoundError"})}}Object.defineProperty(vl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class xl extends gl{constructor(e={}){super({code:xl.code,data:e.data,message:e.message??"Requested resource not available."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceUnavailableError"})}}Object.defineProperty(xl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class Il extends gl{constructor(e={}){super({code:Il.code,data:e.data,message:e.message??"Transaction creation failed."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.TransactionRejectedError"})}}Object.defineProperty(Il,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Pl extends gl{constructor(e={}){super({code:Pl.code,data:e.data,message:e.message??"Method is not implemented."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotSupportedError"})}}Object.defineProperty(Pl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class zl extends gl{constructor(e={}){super({code:zl.code,data:e.data,message:e.message??"Rate limit exceeded."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.LimitExceededError"})}}Object.defineProperty(zl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class El extends gl{constructor(e={}){super({code:El.code,data:e.data,message:e.message??"JSON-RPC version not supported."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.VersionNotSupportedError"})}}Object.defineProperty(El,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Al extends gl{constructor(e={}){super({code:Al.code,data:e.data,message:e.message??"Input is not a valid JSON-RPC request."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidRequestError"})}}Object.defineProperty(Al,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class kl extends gl{constructor(e={}){super({code:kl.code,data:e.data,message:e.message??"Method does not exist."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotFoundError"})}}Object.defineProperty(kl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Ml extends gl{constructor(e={}){super({code:Ml.code,data:e.data,message:e.message??"Invalid method parameters."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidParamsError"})}}Object.defineProperty(Ml,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class $l extends gl{constructor(e={}){super({cause:e.cause,code:$l.code,data:e.data,message:e.message??"Internal JSON-RPC error.",stack:e.stack}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InternalError"})}}Object.defineProperty($l,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ol extends gl{constructor(e={}){super({code:Ol.code,data:e.data,message:e.message??"Failed to parse JSON-RPC response."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ParseError"})}}Object.defineProperty(Ol,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class jl extends Error{constructor(e,t){super(t),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderRpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e,this.details=t}}class Sl extends jl{constructor({message:e="The user rejected the request."}={}){super(4001,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UserRejectedRequestError"})}}Object.defineProperty(Sl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Nl extends jl{constructor({message:e="The requested method and/or account has not been authorized by the user."}={}){super(4100,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnauthorizedError"})}}Object.defineProperty(Nl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Tl extends jl{constructor({message:e="The provider does not support the requested method."}={}){super(4200,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedMethodError"})}}Object.defineProperty(Tl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class _l extends jl{constructor({message:e="The provider is disconnected from all chains."}={}){super(4900,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DisconnectedError"})}}Object.defineProperty(_l,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Rl extends jl{constructor({message:e="The provider is not connected to the requested chain."}={}){super(4901,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.ChainDisconnectedError"})}}Object.defineProperty(Rl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Cl extends jl{constructor({message:e="An error occurred when attempting to switch chain."}={}){super(4902,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.SwitchChainError"})}}Object.defineProperty(Cl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class Bl extends jl{constructor({message:e="This Wallet does not support a capability that was not marked as optional."}={}){super(5700,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedNonOptionalCapabilityError"})}}Object.defineProperty(Bl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Dl extends jl{constructor({message:e="This Wallet does not support the requested chain ID."}={}){super(5710,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedChainIdError"})}}Object.defineProperty(Dl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class Ul extends jl{constructor({message:e="There is already a bundle submitted with this ID."}={}){super(5720,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DuplicateIdError"})}}Object.defineProperty(Ul,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class ql extends jl{constructor({message:e="This bundle id is unknown / has not been submitted."}={}){super(5730,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnknownBundleIdError"})}}Object.defineProperty(ql,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Ll extends jl{constructor({message:e="The call bundle is too large for the Wallet to process."}={}){super(5740,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.BundleTooLargeError"})}}Object.defineProperty(Ll,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Fl extends jl{constructor({message:e="The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."}={}){super(5750,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.AtomicReadyWalletRejectedUpgradeError"})}}Object.defineProperty(Fl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Kl extends jl{constructor({message:e="The wallet does not support atomic execution but the request requires it."}={}){super(5760,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.AtomicityNotSupportedError"})}}function Vl(e,t={}){if(!e)throw new Zl;return{...e,async request(t){try{const n=await e.request(t);return n&&"object"==typeof n&&"jsonrpc"in n?function(e,t={}){const{raw:n=!1}=t,r=e;if(n)return e;if(r.error)throw bl(r.error);return r.result}(n):n}catch(e){throw Gl(e)}}}}function Gl(e){const t=bl(e);if(t instanceof $l){if(!t.data)return t;const{code:e}=t.data;if(e===_l.code)return new _l(t);if(e===Rl.code)return new Rl(t);if(e===Sl.code)return new Sl(t);if(e===Nl.code)return new Nl(t);if(e===Tl.code)return new Tl(t);if(e===Cl.code)return new Cl(t);if(e===Fl.code)return new Fl(t);if(e===Kl.code)return new Kl(t);if(e===Ll.code)return new Ll(t);if(e===ql.code)return new ql(t);if(e===Ul.code)return new Ul(t);if(e===Dl.code)return new Dl(t);if(e===Bl.code)return new Bl(t)}return t}Object.defineProperty(Kl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Zl extends ml{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}}const Hl=()=>"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in IntersectionObserverEntry.prototype&&"isVisible"in IntersectionObserverEntry.prototype;const Wl=function(e={}){const{prefix:t="[Porto]"}=e,n=new Set;return{error:Yl(console.error,{prefix:t}),errorOnce:Yl(console.error,{memo:n,prefix:t}),log:Yl(console.log,{prefix:t}),logOnce:Yl(console.log,{memo:n,prefix:t}),warn:Yl(console.warn,{prefix:t}),warnOnce:Yl(console.warn,{memo:n,prefix:t})}}();function Yl(e,t={}){const{memo:n,prefix:r}=t;return(...t)=>{const s=t.join(" ");n?.has(s)||(n?.add(s),e(`${r} ${s}`))}}function Ql(e){if(Array.isArray(e))return e.map(Ql);if("function"==typeof e)return;if("object"!=typeof e||null===e)return e;if(Object.getPrototypeOf(e)!==Object.prototype)try{return structuredClone(e)}catch{return}const t={};for(const[n,r]of Object.entries(e))t[n]=Ql(r);return t}function Jl(e,t){const n=[],r=new Set;for(const s of e){const e=t(s);r.has(e)||(r.add(e),n.push(s))}return n}function Xl(){return"undefined"!=typeof globalThis&&"crypto"in globalThis?globalThis.crypto.randomUUID():crypto.randomUUID()}function ef(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(ef.cache.get(n))return ef.cache.get(n);const r=e().finally((()=>ef.cache.delete(n)));return ef.cache.set(n,r),r}function tf(e,t={}){const{targetOrigin:n}=t,r=new Map;return{destroy(){for(const t of r.values())e.removeEventListener("message",t)},on(t,s,i){function a(e){e.data.topic===t&&(i&&e.data.id!==i||n&&e.origin!==n||s(e.data.payload,e))}return e.addEventListener("message",a),r.set(t,a),()=>e.removeEventListener("message",a)},async send(t,r,s){const i=Xl();return e.postMessage(Ql({id:i,payload:r,topic:t}),s??n??"*"),{id:i,payload:r,topic:t}},async sendAsync(e,t,n){const{id:r}=await this.send(e,t,n);return new Promise((t=>this.on(e,t,r)))}}}function nf(e){const{from:t,to:n,waitForReady:r=!1}=e;let s=!1;const i=function(){let e=()=>{},t=()=>{};return{promise:new Promise(((n,r)=>{e=n,t=r})),reject:t,resolve:e}}();t.on("ready",i.resolve);const a={destroy(){t.destroy(),n.destroy(),s&&i.reject()},on:(e,n,r)=>t.on(e,n,r),send:async(e,t)=>(s=!0,r&&await i.promise.finally((()=>s=!1)),n.send(e,t)),sendAsync:async(e,t)=>(s=!0,r&&await i.promise.finally((()=>s=!1)),n.sendAsync(e,t))};return{...a,ready(e){a.send("ready",e)},waitForReady:()=>i.promise}}!function(e){e.cache=new Map}(ef||(ef={}));const rf={local:"http://localhost:5175/dialog/",prod:"https://wallet.risechain.com/dialog",stg:"https://stg.wallet.risechain.com/dialog"};function sf(e={}){const{skipProtocolCheck:t,skipUnsupported:n}=e,r=e=>!n&&function(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")}()&&e?.some((e=>["wallet_connect","eth_requestAccounts"].includes(e.method)));return"undefined"==typeof window?af():{name:"iframe",setup(e){const{host:n,internal:s,theme:i,themeController:a}=e,{store:o}=s,c=function(e={}){if("undefined"==typeof window)return af();const{type:t="auto",size:n=of}=e;return{name:"popup",setup(e){const{host:r,internal:s,themeController:i}=e,{store:a}=s,o=new URL(r);let c=null;const u="page"===t||"auto"===t&&(window.navigator?.userAgentData?.mobile||navigator.maxTouchPoints>1||/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(navigator.userAgent.slice(0,4)))?"page":"popup";function d(){c&&df(a)}const l=(()=>{const e=setInterval((()=>{c?.closed&&df(a)}),100);return()=>clearInterval(e)})();let f;return i?._setup(null,!0),{close(){c&&(c.close(),c=null)},destroy(){this.close(),window.removeEventListener("focus",d),f?.destroy(),l()},open(){if("popup"===u){const e=(window.innerWidth-n.width)/2+window.screenX,t=window.screenY+100;c=window.open(ff(r),"_blank",`width=${n.width},height=${n.height},left=${e},top=${t}`)}else c=window.open(ff(r),"_blank");if(!c)throw new Error("Failed to open popup");f=nf({from:tf(window,{targetOrigin:o.origin}),to:tf(c,{targetOrigin:o.origin}),waitForReady:!0}),i?._setup(f,!1),f.send("__internal",{mode:"page"===u?"page":"popup",referrer:uf(),theme:i?.getTheme()??e.theme,type:"init"}),f.on("rpc-response",(e=>lf(a,e))),window.removeEventListener("focus",d),window.addEventListener("focus",d)},secure:async()=>({frame:!0,host:!0,protocol:!0}),async syncRequests(e){e.some((e=>cf(e.request)))&&(c&&!c.closed||this.open(),c?.focus()),f?.send("rpc-requests",e)}}},supportsHeadless:!1}}().setup(e);let u=!1;const d=new URL(n),l=document.createElement("dialog");l.dataset.porto="",l.setAttribute("role","dialog"),l.setAttribute("aria-closed","true"),l.setAttribute("aria-label","Porto Wallet"),l.setAttribute("hidden","until-found"),Object.assign(l.style,{background:"transparent",border:"0",outline:"0",padding:"0",position:"fixed"}),document.body.appendChild(l);const f=document.createElement("iframe");f.setAttribute("data-testid","porto");const p=["payment",`publickey-credentials-get ${d.origin}`,`publickey-credentials-create ${d.origin}`];(function(){const e=navigator.userAgent.toLowerCase();return(e.includes("firefox")||e.includes("fxios"))&&!e.includes("seamonkey")})()||p.push("clipboard-write"),f.setAttribute("allow",p.join("; ")),f.setAttribute("tabindex","0"),f.setAttribute("sandbox","allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox"),f.setAttribute("src",ff(n)),f.setAttribute("title","Porto"),Object.assign(f.style,{backgroundColor:"transparent",border:"0",colorScheme:"light dark",height:"100%",left:"0",position:"fixed",top:"0",width:"100%"});const h=document.createElement("style");h.innerHTML="\n dialog[data-porto]::backdrop {\n background: transparent!important;\n }\n ",l.appendChild(h),l.appendChild(f);const m=nf({from:tf(window,{targetOrigin:d.origin}),to:tf(f.contentWindow,{targetOrigin:d.origin}),waitForReady:!0});a?._setup(m,!0);const y=window.matchMedia("(max-width: 460px)"),b=()=>{m.send("__internal",{type:"resize",width:y.matches?460:461})};y.addEventListener("change",b),m.on("ready",(t=>{let n=e.internal.store.getState().chainIds.filter((e=>t.chainIds.includes(e)));0===n.length&&(n=t.chainIds),o.setState((e=>({...e,chainIds:n}))),m.send("__internal",{chainIds:n,mode:"iframe",referrer:uf(),theme:i,type:"init"}),b()})),m.on("rpc-response",(e=>{if(r([e._request])){const e=f.src;f.src=e}lf(o,e)})),m.on("__internal",(e=>{"switch"===e.type&&"popup"===e.mode&&(c.open(),c.syncRequests(o.getState().requestQueue))}));let g=null,w=null;const v=()=>df(o),x=e=>{"Escape"===e.key&&df(o)},I=new MutationObserver((e=>{for(const t of e){if("attributes"!==t.type)continue;const e=t.attributeName;e&&("inert"===e&&l.removeAttribute(e))}}));I.observe(l,{attributeOldValue:!0,attributes:!0});let P=!1;const z=()=>{P&&(P=!1,l.removeEventListener("click",v),document.removeEventListener("keydown",x),l.style.pointerEvents="none",w?.focus(),w=null,Object.assign(document.body.style,g??""),document.body.style.overflow=g?.overflow??"")};let E=!1;const A=()=>{if(E){E=!1,l.setAttribute("hidden","true"),l.setAttribute("aria-closed","true"),l.close();for(const e of l.parentNode?Array.from(l.parentNode.children):[])e!==l&&e.hasAttribute("inert")&&e.removeAttribute("inert")}};return{close(){c.close(),u=!1,m.send("__internal",{mode:"iframe",referrer:uf(),type:"init"}),A(),z()},destroy(){c.close(),u=!1,z(),A(),c.destroy(),m.destroy(),l.remove(),I.disconnect(),y.removeEventListener("change",b)},open(){u||(u=!0,E||(E=!0,document.activeElement instanceof HTMLElement&&(w=document.activeElement),l.removeAttribute("hidden"),l.removeAttribute("aria-closed"),l.showModal()),P||(P=!0,l.addEventListener("click",v),document.addEventListener("keydown",x),f.focus(),l.style.pointerEvents="auto",g=Object.assign({},document.body.style),document.body.style.overflow="hidden"),m.send("__internal",{mode:"iframe",referrer:uf(),type:"init"}))},async secure(){const{trustedHosts:e}=await m.waitForReady(),n=(()=>{if(t)return!0;const e=window.location.protocol.startsWith("https");return e||Wl.warnOnce("Detected insecure protocol (HTTP).",`\n\nThe Porto iframe is not supported on HTTP origins (${window.location.origin})`,"due to lack of WebAuthn support.","See https://porto.sh/sdk#secure-origins-https for more information."),e})(),r=Hl(),s=Boolean(e?.includes(window.location.hostname)),i=Boolean(r||s);return i||Wl.warnOnce([`Warning: Browser does not support IntersectionObserver v2 or host "${d.hostname}" is not trusted by Porto.`,"This may result in the dialog falling back to a popup.","",`Add "${d.hostname}" to the trusted hosts list to enable iframe dialog: https://github.com/ithacaxyz/porto/edit/main/src/trusted-hosts.ts`].join("\n")),{frame:i,host:s,protocol:n}},async syncRequests(e){const{methodPolicies:t}=await m.waitForReady(),n=await this.secure(),s=e?.every((e=>!0===t?.find((t=>t.method===e.request.method))?.modes?.headless)),i=r(e.map((e=>e.request)));if(s||!i&&n.protocol&&n.frame){const n=e.some((e=>cf(e.request,{methodPolicies:t,targetOrigin:d.origin})));!u&&n&&this.open(),m.send("rpc-requests",e)}else c.syncRequests(e)}}},supportsHeadless:!0}}function af(){return{name:"noop",setup:()=>({close(){},destroy(){},open(){},secure:async()=>({frame:!0,host:!0,protocol:!0}),async syncRequests(){}}),supportsHeadless:!0}}const of={height:282,width:360};function cf(e,t={}){const{methodPolicies:n,targetOrigin:r}=t,s=n?.find((t=>t.method===e.method));return!s||(!s.modes?.headless||!("object"!=typeof s.modes.headless||!s.modes.headless.sameOrigin||r===window.location.origin))}function uf(){return{icon:(()=>{const e=document.querySelector('link[rel="icon"][media="(prefers-color-scheme: dark)"]')?.href,t=document.querySelector('link[rel="icon"][media="(prefers-color-scheme: light)"]')?.href??document.querySelector('link[rel="icon"]')?.href;if(e&&t&&e!==t)return{dark:e,light:t};return window.matchMedia("(prefers-color-scheme: dark)").matches?e:t})(),title:document.title}}function df(e){e.setState((e=>({...e,requestQueue:e.requestQueue.map((e=>({account:e.account,error:new Sl,request:e.request,status:"error"})))})))}function lf(e,t){e.setState((e=>({...e,requestQueue:e.requestQueue.map((e=>e.request.id!==t.id?e:t.error?{account:e.account,error:t.error,request:e.request,status:"error"}:{account:e.account,request:e.request,result:t.result,status:"success"}))})))}function ff(e){const t=new URL(e),n=new URLSearchParams(window.location.search),r="porto.";for(const[e,s]of n.entries())e.startsWith(r)&&t.searchParams.set(e.slice(6),s);return t.toString()}function pf(e,t){if(Vf(e)>t)throw new Qf({givenSize:Vf(e),maxSize:t})}const hf={zero:48,nine:57,A:65,F:70,a:97,f:102};function mf(e){return e>=hf.zero&&e<=hf.nine?e-hf.zero:e>=hf.A&&e<=hf.F?e-(hf.A-10):e>=hf.a&&e<=hf.f?e-(hf.a-10):void 0}function yf(e,t){if($f(e)>t)throw new Cf({givenSize:$f(e),maxSize:t})}function bf(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const s=e.replace("0x","");if(s.length>2*r)throw new Df({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s["right"===n?"padEnd":"padStart"](2*r,"0")}`}const gf=new TextEncoder,wf=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function vf(...e){return`0x${e.reduce(((e,t)=>e+t.replace("0x","")),"")}`}function xf(e){return e instanceof Uint8Array?Pf(e):Array.isArray(e)?Pf(new Uint8Array(e)):e}function If(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(yf(n,t.size),Af(n,t.size)):n}function Pf(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=wf[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(yf(r,t.size),kf(r,t.size)):r}function zf(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new Tf({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?BigInt.asUintN(8*r,BigInt(s)):s).toString(16)}`;return r?Af(o,r):o}function Ef(e,t={}){return Pf(gf.encode(e),t)}function Af(e,t){return bf(e,{dir:"left",size:t})}function kf(e,t){return bf(e,{dir:"right",size:t})}function Mf(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>$f(e)-1)throw new Bf({offset:t,position:"start",size:$f(e)})}(e,t);const i=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&$f(e)!==n-t)throw new Bf({offset:n,position:"end",size:$f(e)})}(i,t,n),i}function $f(e){return Math.ceil((e.length-2)/2)}function Of(e){return function(e,t={}){const{dir:n="left"}=t;let r=e.replace("0x",""),s=0;for(let e=0;e<r.length-1&&"0"===r["left"===n?e:r.length-e-1].toString();e++)s++;return r="left"===n?r.slice(s):r.slice(0,r.length-s),"0"===r?"0x":"right"===n&&r.length%2==1?`0x${r}0`:`0x${r}`}(e,{dir:"left"})}function jf(e,t={}){const{signed:n}=t;t.size&&yf(e,t.size);const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<8n*BigInt(s))-1n;return r<=i>>1n?r:r-i-1n}function Sf(e,t={}){const{signed:n,size:r}=t;return Number(n||r?jf(e,t):e)}function Nf(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new _f(e);if("string"!=typeof e)throw new _f(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new Rf(e);if(!e.startsWith("0x"))throw new Rf(e)}(e,{strict:n}),!0}catch{return!1}}class Tf extends ml{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number \`${s}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class _f extends ml{constructor(e){super(`Value \`${"object"==typeof e?hl(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class Rf extends ml{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}class Cf extends ml{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class Bf extends ml{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class Df extends ml{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}const Uf=new TextEncoder;function qf(e){return e instanceof Uint8Array?e:"string"==typeof e?Ff(e):Lf(e)}function Lf(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Ff(e,t={}){const{size:n}=t;let r=e;n&&(yf(e,n),r=kf(e,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){const n=mf(s.charCodeAt(t++)),r=mf(s.charCodeAt(t++));if(void 0===n||void 0===r)throw new ml(`Invalid byte sequence ("${s[t-2]}${s[t-1]}" in "${s}").`);a[e]=n<<4|r}return a}function Kf(e,t={}){const{size:n}=t,r=Uf.encode(e);return"number"==typeof n?(pf(r,n),function(e,t){return function(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;if(e.length>r)throw new Xf({size:e.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let t=0;t<r;t++){const i="right"===n;s[i?t:r-t-1]=e[i?t:e.length-t-1]}return s}(e,{dir:"right",size:t})}(r,n)):r}function Vf(e){return e.length}function Gf(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>Vf(e)-1)throw new Jf({offset:t,position:"start",size:Vf(e)})}(e,t);const i=e.slice(t,n);return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&Vf(e)!==n-t)throw new Jf({offset:n,position:"end",size:Vf(e)})}(i,t,n),i}function Zf(e,t={}){const{size:n}=t;void 0!==n&&pf(e,n);return jf(Pf(e,t),t)}function Hf(e,t={}){return Pf(e,t)}function Wf(e){try{return function(e){if(!(e instanceof Uint8Array)){if(!e)throw new Yf(e);if("object"!=typeof e)throw new Yf(e);if(!("BYTES_PER_ELEMENT"in e))throw new Yf(e);if(1!==e.BYTES_PER_ELEMENT||"Uint8Array"!==e.constructor.name)throw new Yf(e)}}(e),!0}catch{return!1}}class Yf extends ml{constructor(e){super(`Value \`${"object"==typeof e?hl(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class Qf extends ml{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Jf extends ml{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}}class Xf extends ml{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}class ep extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const tp={checksum:new ep(8192)}.checksum;function np(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Bt(qf(e));return"Bytes"===n?r:Pf(r)}function rp(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Ns(qf(e));return"Bytes"===n?r:Pf(r)}function sp(e,t={}){const{compressed:n}=t,{prefix:r,x:s,y:i}=e;if(!1===n||"bigint"==typeof s&&"bigint"==typeof i){if(4!==r)throw new up({prefix:r,cause:new lp})}else{if(!0!==n&&("bigint"!=typeof s||void 0!==i))throw new cp({publicKey:e});if(3!==r&&2!==r)throw new up({prefix:r,cause:new dp})}}function ip(e){const t=(()=>{if(Nf(e))return ap(e);if(Wf(e))return function(e){return ap(Pf(e))}(e);const{prefix:t,x:n,y:r}=e;return"bigint"==typeof n&&"bigint"==typeof r?{prefix:t??4,x:n,y:r}:{prefix:t,x:n}})();return sp(t),t}function ap(e){if(132!==e.length&&130!==e.length&&68!==e.length)throw new fp({publicKey:e});if(130===e.length){return{prefix:4,x:BigInt(Mf(e,0,32)),y:BigInt(Mf(e,32,64))}}if(132===e.length){return{prefix:Number(Mf(e,0,1)),x:BigInt(Mf(e,1,33)),y:BigInt(Mf(e,33,65))}}return{prefix:Number(Mf(e,0,1)),x:BigInt(Mf(e,1,33))}}function op(e,t={}){sp(e);const{prefix:n,x:r,y:s}=e,{includePrefix:i=!0}=t;return vf(i?zf(n,{size:1}):"0x",zf(r,{size:32}),"bigint"==typeof s?zf(s,{size:32}):"0x")}class cp extends ml{constructor({publicKey:e}){super(`Value \`${hl(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class up extends ml{constructor({prefix:e,cause:t}){super(`Prefix "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class dp extends ml{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class lp extends ml{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}class fp extends ml{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${$f(xf(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}}const pp=/^0x[a-fA-F0-9]{40}$/;function hp(e,t={}){const{strict:n=!0}=t;if(!pp.test(e))throw new vp({address:e,cause:new xp});if(n){if(e.toLowerCase()===e)return;if(mp(e)!==e)throw new vp({address:e,cause:new Ip})}}function mp(e){if(tp.has(e))return tp.get(e);hp(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=np(Kf(t),{as:"Bytes"}),r=t.split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&r[e]&&(r[e]=r[e].toUpperCase()),(15&n[e>>1])>=8&&r[e+1]&&(r[e+1]=r[e+1].toUpperCase());const s=`0x${r.join("")}`;return tp.set(e,s),s}function yp(e,t={}){const{checksum:n=!1}=t;return hp(e),n?mp(e):e}function bp(e,t={}){return yp(`0x${np(`0x${op(e).slice(4)}`).substring(26)}`,t)}function gp(e,t){return hp(e,{strict:!1}),hp(t,{strict:!1}),e.toLowerCase()===t.toLowerCase()}function wp(e,t={}){const{strict:n=!0}=t??{};try{return hp(e,{strict:n}),!0}catch{return!1}}class vp extends ml{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class xp extends ml{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class Ip extends ml{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}function Pp(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:a,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const s=a.prototype,i=Object.keys(s);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=s[t].bind(n))}}const s=n?.Parent??Object;class i extends s{}function a(e){var t;const s=n?.Parent?new i:this;r(s,e),(t=s._zod).deferred??(t.deferred=[]);for(const e of s._zod.deferred)e();return s}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}Object.freeze({status:"aborted"});class zp extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ep={};function Ap(e){return e&&Object.assign(Ep,e),Ep}function kp(e,t){return"bigint"==typeof t?t.toString():t}function Mp(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function $p(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Op=Symbol("evaluating");function jp(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Op)return void 0===r&&(r=Op,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Sp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Np(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}const Tp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _p(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Rp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Cp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bp(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function Dp(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function Up(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function qp(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function Lp(e){return"string"==typeof e?e:e?.message}function Fp(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const s=Lp(e.inst?._zod.def?.error?.(e))??Lp(t?.error?.(e))??Lp(n.customError?.(e))??Lp(n.localeError?.(e))??"Invalid input";r.message=s}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}const Kp=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,kp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Vp=Pp("$ZodError",Kp),Gp=Pp("$ZodError",Kp,{Parent:Error}),Zp=e=>(t,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new zp;if(a.issues.length){const t=new(s?.Err??e)(a.issues.map((e=>Fp(e,i,Ap()))));throw Tp(t,s?.callee),t}return a.value},Hp=Zp(Gp),Wp=e=>async(t,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(s?.Err??e)(a.issues.map((e=>Fp(e,i,Ap()))));throw Tp(t,s?.callee),t}return a.value},Yp=Wp(Gp),Qp=e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new zp;return i.issues.length?{success:!1,error:new(e??Vp)(i.issues.map((e=>Fp(e,s,Ap()))))}:{success:!0,data:i.value}},Jp=Qp(Gp),Xp=e=>async(t,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map((e=>Fp(e,s,Ap()))))}:{success:!0,data:i.value}},eh=Xp(Gp),th=e=>(t,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Zp(e)(t,n,s)},nh=th(Gp),rh=e=>(t,n,r)=>Zp(e)(t,n,r),sh=rh(Gp),ih=/^-?\d+n?$/,ah=/^-?\d+(?:\.\d+)?/,oh=/^(?:true|false)$/i,ch=/^null$/i,uh=/^undefined$/i,dh=Pp("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),lh={number:"number",bigint:"bigint",object:"date"},fh=Pp("$ZodCheckGreaterThan",((e,t)=>{dh.init(e,t);const n=lh[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)})),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),ph=Pp("$ZodCheckMinLength",((e,t)=>{var n;dh.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!(n=t,null==n||void 0===t.length);var n}),e._zod.onattach.push((e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const s=function(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}(r);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),hh=Pp("$ZodCheckStringFormat",((e,t)=>{var n,r;dh.init(e,t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))})),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})})),mh=Pp("$ZodCheckRegex",((e,t)=>{hh.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}})),yh={major:4,minor:2,patch:1},bh=Pp("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yh;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const t of r)for(const n of t._zod.onattach)n(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,n)=>{let r,s=Up(e);for(const i of t){if(i._zod.def.when){if(!i._zod.def.when(e))continue}else if(s)continue;const t=e.issues.length,a=i._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new zp;if(r||a instanceof Promise)r=(r??Promise.resolve()).then((async()=>{await a;e.issues.length!==t&&(s||(s=Up(e,t)))}));else{if(e.issues.length===t)continue;s||(s=Up(e,t))}}return r?r.then((()=>e)):e},n=(n,s,i)=>{if(Up(n))return n.aborted=!0,n;const a=t(s,r,i);if(a instanceof Promise){if(!1===i.async)throw new zp;return a.then((t=>e._zod.parse(t,i)))}return e._zod.parse(a,i)};e._zod.run=(s,i)=>{if(i.skipChecks)return e._zod.parse(s,i);if("backward"===i.direction){const t=e._zod.parse({value:s.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then((e=>n(e,s,i))):n(t,s,i)}const a=e._zod.parse(s,i);if(a instanceof Promise){if(!1===i.async)throw new zp;return a.then((e=>t(e,r,i)))}return t(a,r,i)}}e["~standard"]={validate:t=>{try{const n=Jp(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return eh(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1}})),gh=Pp("$ZodString",((e,t)=>{var n;bh.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),wh=Pp("$ZodNumber",((e,t)=>{bh.init(e,t),e._zod.pattern=e._zod.bag.pattern??ah,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const s=n.value;if("number"==typeof s&&!Number.isNaN(s)&&Number.isFinite(s))return n;const i="number"==typeof s?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...i?{received:i}:{}}),n}})),vh=Pp("$ZodBoolean",((e,t)=>{bh.init(e,t),e._zod.pattern=oh,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const s=n.value;return"boolean"==typeof s||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}})),xh=Pp("$ZodBigInt",((e,t)=>{bh.init(e,t),e._zod.pattern=ih,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(e){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}})),Ih=Pp("$ZodUndefined",((e,t)=>{bh.init(e,t),e._zod.pattern=uh,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(t,n)=>{const r=t.value;return void 0===r||t.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),t}})),Ph=Pp("$ZodNull",((e,t)=>{bh.init(e,t),e._zod.pattern=ch,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{const r=t.value;return null===r||t.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),t}})),zh=Pp("$ZodAny",((e,t)=>{bh.init(e,t),e._zod.parse=e=>e})),Eh=Pp("$ZodUnknown",((e,t)=>{bh.init(e,t),e._zod.parse=e=>e})),Ah=Pp("$ZodDate",((e,t)=>{bh.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(e){}const s=n.value,i=s instanceof Date;return i&&!Number.isNaN(s.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:s,...i?{received:"Invalid Date"}:{},inst:e}),n}}));function kh(e,t,n){e.issues.length&&t.issues.push(...qp(n,e.issues)),t.value[n]=e.value}const Mh=Pp("$ZodArray",((e,t)=>{bh.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const i=[];for(let e=0;e<s.length;e++){const a=s[e],o=t.element._zod.run({value:a,issues:[]},r);o instanceof Promise?i.push(o.then((t=>kh(t,n,e)))):kh(o,n,e)}return i.length?Promise.all(i).then((()=>n)):n}}));function $h(e,t,n,r){e.issues.length&&t.issues.push(...qp(n,e.issues)),void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Oh(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter((e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout)));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}const jh=Pp("$ZodObject",((e,t)=>{bh.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=Mp((()=>Oh(t)));jp(e._zod,"propValues",(()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n}));const s=_p,i=t.catchall;let a;e._zod.parse=(t,n)=>{a??(a=r.value);const o=t.value;if(!s(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};const c=[],u=a.shape;for(const e of a.keys){const r=u[e]._zod.run({value:o[e],issues:[]},n);r instanceof Promise?c.push(r.then((n=>$h(n,t,e,o)))):$h(r,t,e,o)}return i?function(e,t,n,r,s,i){const a=[],o=s.keySet,c=s.catchall._zod,u=c.def.type;for(const s in t){if(o.has(s))continue;if("never"===u){a.push(s);continue}const i=c.run({value:t[s],issues:[]},r);i instanceof Promise?e.push(i.then((e=>$h(e,n,s,t)))):$h(i,n,s,t)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then((()=>n)):n}(c,o,t,n,r.value,e):c.length?Promise.all(c).then((()=>t)):t}}));function Sh(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const s=e.filter((e=>!Up(e)));return 1===s.length?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>Fp(e,r,Ap())))))}),t)}const Nh=Pp("$ZodUnion",((e,t)=>{bh.init(e,t),jp(e._zod,"optin",(()=>t.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),jp(e._zod,"optout",(()=>t.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),jp(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),jp(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>$p(e.source))).join("|")})$`)}}));const n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(s,i)=>{if(n)return r(s,i);let a=!1;const o=[];for(const e of t.options){const t=e._zod.run({value:s.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(0===t.issues.length)return t;o.push(t)}}return a?Promise.all(o).then((t=>Sh(t,s,e,i))):Sh(o,s,e,i)}})),Th=Pp("$ZodDiscriminatedUnion",((e,t)=>{t.inclusive=!1,Nh.init(e,t);const n=e._zod.parse;jp(e._zod,"propValues",(()=>{const e={};for(const n of t.options){const r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(const r of n)e[t].add(r)}}return e}));const r=Mp((()=>{const e=t.options,n=new Map;for(const r of e){const e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n}));e._zod.parse=(s,i)=>{const a=s.value;if(!_p(a))return s.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),s;const o=r.value.get(a?.[t.discriminator]);return o?o._zod.run(s,i):t.unionFallback?n(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),s)}})),_h=Pp("$ZodTuple",((e,t)=>{bh.init(e,t);const n=t.items;e._zod.parse=(r,s)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const a=[],o=[...n].reverse().findIndex((e=>"optional"!==e._zod.optin)),c=-1===o?0:n.length-o;if(!t.rest){const t=i.length>n.length,s=i.length<c-1;if(t||s)return r.issues.push({...t?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:i,inst:e,origin:"array"}),r}let u=-1;for(const e of n){if(u++,u>=i.length&&u>=c)continue;const t=e._zod.run({value:i[u],issues:[]},s);t instanceof Promise?a.push(t.then((e=>Rh(e,r,u)))):Rh(t,r,u)}if(t.rest){const e=i.slice(n.length);for(const n of e){u++;const e=t.rest._zod.run({value:n,issues:[]},s);e instanceof Promise?a.push(e.then((e=>Rh(e,r,u)))):Rh(e,r,u)}}return a.length?Promise.all(a).then((()=>r)):r}}));function Rh(e,t,n){e.issues.length&&t.issues.push(...qp(n,e.issues)),t.value[n]=e.value}const Ch=Pp("$ZodRecord",((e,t)=>{bh.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!function(e){if(!1===_p(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==_p(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const o=new Set;for(const e of a)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){o.add("number"==typeof e?e.toString():e);const a=t.valueType._zod.run({value:s[e],issues:[]},r);a instanceof Promise?i.push(a.then((t=>{t.issues.length&&n.issues.push(...qp(e,t.issues)),n.value[e]=t.value}))):(a.issues.length&&n.issues.push(...qp(e,a.issues)),n.value[e]=a.value)}let c;for(const e in s)o.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(s)){if("__proto__"===a)continue;const o=t.keyType._zod.run({value:a,issues:[]},r);if(o instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(o.issues.length){"loose"===t.mode?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:o.issues.map((e=>Fp(e,r,Ap()))),input:a,path:[a],inst:e});continue}const c=t.valueType._zod.run({value:s[a],issues:[]},r);c instanceof Promise?i.push(c.then((e=>{e.issues.length&&n.issues.push(...qp(a,e.issues)),n.value[o.value]=e.value}))):(c.issues.length&&n.issues.push(...qp(a,c.issues)),n.value[o.value]=c.value)}}return i.length?Promise.all(i).then((()=>n)):n}})),Bh=Pp("$ZodLiteral",((e,t)=>{if(bh.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?Cp(e):e?Cp(e.toString()):String(e))).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}));function Dh(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Uh=Pp("$ZodOptional",((e,t)=>{bh.init(e,t),e._zod.optin="optional",e._zod.optout="optional",jp(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),jp(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${$p(e.source)})?$`):void 0})),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((t=>Dh(t,e.value))):Dh(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}})),qh=Pp("$ZodNullable",((e,t)=>{bh.init(e,t),jp(e._zod,"optin",(()=>t.innerType._zod.optin)),jp(e._zod,"optout",(()=>t.innerType._zod.optout)),jp(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${$p(e.source)}|null)$`):void 0})),jp(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),Lh=Pp("$ZodPipe",((e,t)=>{bh.init(e,t),jp(e._zod,"values",(()=>t.in._zod.values)),jp(e._zod,"optin",(()=>t.in._zod.optin)),jp(e._zod,"optout",(()=>t.out._zod.optout)),jp(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>Fh(e,t.in,n))):Fh(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>Fh(e,t.out,n))):Fh(r,t.out,n)}}));function Fh(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Kh=Pp("$ZodCodec",((e,t)=>{bh.init(e,t),jp(e._zod,"values",(()=>t.in._zod.values)),jp(e._zod,"optin",(()=>t.in._zod.optin)),jp(e._zod,"optout",(()=>t.out._zod.optout)),jp(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,n)=>{if("forward"===(n.direction||"forward")){const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>Vh(e,t,n))):Vh(r,t,n)}{const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>Vh(e,t,n))):Vh(r,t,n)}}}));function Vh(e,t,n){if(e.issues.length)return e.aborted=!0,e;if("forward"===(n.direction||"forward")){const r=t.transform(e.value,e);return r instanceof Promise?r.then((r=>Gh(e,r,t.out,n))):Gh(e,r,t.out,n)}{const r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then((r=>Gh(e,r,t.in,n))):Gh(e,r,t.in,n)}}function Gh(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Zh=Pp("$ZodReadonly",((e,t)=>{bh.init(e,t),jp(e._zod,"propValues",(()=>t.innerType._zod.propValues)),jp(e._zod,"values",(()=>t.innerType._zod.values)),jp(e._zod,"optin",(()=>t.innerType?._zod?.optin)),jp(e._zod,"optout",(()=>t.innerType?._zod?.optout)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Hh):Hh(r)}}));function Hh(e){return e.value=Object.freeze(e.value),e}const Wh=Pp("$ZodTemplateLiteral",((e,t)=>{bh.init(e,t);const n=[];for(const e of t.parts)if("object"==typeof e&&null!==e){if(!e._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);const t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw new Error(`Invalid template literal part: ${e._zod.traits}`);const r=t.startsWith("^")?1:0,s=t.endsWith("$")?t.length-1:t.length;n.push(t.slice(r,s))}else{if(null!==e&&!Rp.has(typeof e))throw new Error(`Invalid template literal part: ${e}`);n.push(Cp(`${e}`))}e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(n,r)=>"string"!=typeof n.value?(n.issues.push({input:n.value,inst:e,expected:"template_literal",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}));var Yh;class Qh{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Jh(e,t){return new ph({check:"min_length",...Dp(t),minimum:e})}function Xh(e,t){return new mh({check:"string_format",format:"regex",...Dp(t),pattern:e})}(Yh=globalThis).__zod_globalRegistry??(Yh.__zod_globalRegistry=new Qh);const em=Pp("ZodMiniType",((e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");bh.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>Hp(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Jp(e,t,n),e.parseAsync=async(t,n)=>Yp(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>eh(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),e.clone=(t,n)=>Bp(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e)})),tm=Pp("ZodMiniString",((e,t)=>{gh.init(e,t),em.init(e,t)}));function nm(e){return function(e,t){return new e({type:"string",...Dp(t)})}(tm,e)}const rm=Pp("ZodMiniNumber",((e,t)=>{wh.init(e,t),em.init(e,t)}));function sm(e){return function(e,t){return new e({type:"number",checks:[],...Dp(t)})}(rm,e)}const im=Pp("ZodMiniBoolean",((e,t)=>{vh.init(e,t),em.init(e,t)}));function am(e){return function(e,t){return new e({type:"boolean",...Dp(t)})}(im,e)}const om=Pp("ZodMiniBigInt",((e,t)=>{xh.init(e,t),em.init(e,t)}));function cm(e){return function(e,t){return new e({type:"bigint",...Dp(t)})}(om,e)}const um=Pp("ZodMiniUndefined",((e,t)=>{Ih.init(e,t),em.init(e,t)}));function dm(e){return function(e,t){return new e({type:"undefined",...Dp(t)})}(um,e)}const lm=Pp("ZodMiniNull",((e,t)=>{Ph.init(e,t),em.init(e,t)}));function fm(e){return function(e,t){return new e({type:"null",...Dp(t)})}(lm,e)}const pm=Pp("ZodMiniAny",((e,t)=>{zh.init(e,t),em.init(e,t)}));function hm(){return new pm({type:"any"})}const mm=Pp("ZodMiniUnknown",((e,t)=>{Eh.init(e,t),em.init(e,t)}));function ym(){return new mm({type:"unknown"})}const bm=Pp("ZodMiniDate",((e,t)=>{Ah.init(e,t),em.init(e,t)}));function gm(e){return function(e,t){return new e({type:"date",...Dp(t)})}(bm,e)}const wm=Pp("ZodMiniArray",((e,t)=>{Mh.init(e,t),em.init(e,t)}));function vm(e,t){return new wm({type:"array",element:e,...Dp(t)})}const xm=Pp("ZodMiniObject",((e,t)=>{jh.init(e,t),em.init(e,t),jp(e,"shape",(()=>t.shape))}));function Im(e,t){const n={type:"object",shape:e??{},...Dp(t)};return new xm(n)}function Pm(e,t){return function(e,t){const n=e._zod.def;return Bp(e,Np(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Sp(this,"shape",e),e},checks:[]}))}(e,t)}function zm(e,t){return function(e,t){const n=e._zod.def,r=Np(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Sp(this,"shape",r),r},checks:[]});return Bp(e,r)}(e,t)}function Em(e,t){return function(e,t,n){const r=Np(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(s[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)s[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Sp(this,"shape",s),s},checks:[]});return Bp(t,r)}(_m,e,t)}const Am=Pp("ZodMiniUnion",((e,t)=>{Nh.init(e,t),em.init(e,t)}));function km(e,t){return new Am({type:"union",options:e,...Dp(t)})}const Mm=Pp("ZodMiniDiscriminatedUnion",((e,t)=>{Th.init(e,t),em.init(e,t)}));const $m=Pp("ZodMiniTuple",((e,t)=>{_h.init(e,t),em.init(e,t)}));function Om(e,t,n){const r=t instanceof bh;return new $m({type:"tuple",items:e,rest:r?t:null,...Dp(r?n:t)})}const jm=Pp("ZodMiniRecord",((e,t)=>{Ch.init(e,t),em.init(e,t)}));function Sm(e,t,n){return new jm({type:"record",keyType:e,valueType:t,...Dp(n)})}const Nm=Pp("ZodMiniLiteral",((e,t)=>{Bh.init(e,t),em.init(e,t)}));function Tm(e,t){return new Nm({type:"literal",values:Array.isArray(e)?e:[e],...Dp(t)})}const _m=Pp("ZodMiniOptional",((e,t)=>{Uh.init(e,t),em.init(e,t)}));function Rm(e){return new _m({type:"optional",innerType:e})}const Cm=Pp("ZodMiniNullable",((e,t)=>{qh.init(e,t),em.init(e,t)}));function Bm(e){return new Cm({type:"nullable",innerType:e})}function Dm(e){return Rm(Bm(e))}const Um=Pp("ZodMiniPipe",((e,t)=>{Lh.init(e,t),em.init(e,t)})),qm=Pp("ZodMiniCodec",((e,t)=>{Um.init(e,t),Kh.init(e,t)}));function Lm(e,t,n){return new qm({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}const Fm=Pp("ZodMiniReadonly",((e,t)=>{Zh.init(e,t),em.init(e,t)}));function Km(e){return new Fm({type:"readonly",innerType:e})}const Vm=Pp("ZodMiniTemplateLiteral",((e,t)=>{Wh.init(e,t),em.init(e,t)}));function Gm(e,t){return new Vm({type:"template_literal",parts:e,...Dp(t)})}let Zm=!1;function Hm(e){return bp(function(e){const{payload:t,signature:n}=e,{r:r,s:s,yParity:i}=n,a=new ud.Signature(BigInt(r),BigInt(s)).addRecoveryBit(i);return ip(a.recoverPublicKey(xf(t).substring(2)))}(e))}function Wm(e){const{extraEntropy:t=Zm,hash:n,payload:r,privateKey:s}=e,{r:i,s:a,recovery:o}=ud.sign(qf(r),qf(s),{extraEntropy:"boolean"==typeof t?t:xf(t).slice(2),lowS:!0,...n?{prehash:!0}:{}});return{r:i,s:a,yParity:o}}const Ym=/^(.*)\[([0-9]*)\]$/,Qm=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Jm=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,Xm=2n**256n-1n;function ey(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new oy({signature:e});if(void 0===e.s)throw new oy({signature:e});if(n&&void 0===e.yParity)throw new oy({signature:e});if(e.r<0n||e.r>Xm)throw new cy({value:e.r});if(e.s<0n||e.s>Xm)throw new uy({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new dy({value:e.yParity})}function ty(e){if(130!==e.length&&132!==e.length)throw new ay({signature:e});const t=BigInt(Mf(e,0,32)),n=BigInt(Mf(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return iy(t)}catch{throw new dy({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function ny(e){const t="string"==typeof e?ty(e):e instanceof Uint8Array?function(e){return ty(Pf(e))}(e):"string"==typeof e.r?function(e){const t=(()=>{const t=e.v?Number(e.v):void 0;let n=e.yParity?Number(e.yParity):void 0;if("number"==typeof t&&"number"!=typeof n&&(n=iy(t)),"number"!=typeof n)throw new dy({value:e.yParity});return n})();return{r:BigInt(e.r),s:BigInt(e.s),yParity:t}}(e):e.v?function(e){return{r:e.r,s:e.s,yParity:iy(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return ey(t),t}function ry(e){ey(e);const t=e.r,n=e.s;return vf(zf(t,{size:32}),zf(n,{size:32}),"number"==typeof e.yParity?zf(function(e){if(0===e)return 27;if(1===e)return 28;throw new dy({value:e})}(e.yParity),{size:1}):"0x")}function sy(e){const{r:t,s:n,yParity:r}=e;return[r?"0x01":"0x",0n===t?"0x":Of(zf(t)),0n===n?"0x":Of(zf(n))]}function iy(e){if(0===e||27===e)return 0;if(1===e||28===e)return 1;if(e>=35)return e%2==0?1:0;throw new ly({value:e})}class ay extends ml{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${$f(xf(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class oy extends ml{constructor({signature:e}){super(`Signature \`${hl(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class cy extends ml{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class uy extends ml{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class dy extends ml{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class ly extends ml{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}class fy extends Error{constructor(e,t={}){const n=t.cause instanceof fy?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof fy&&t.cause.docsPath||t.docsPath;super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...r?[`Docs: https://abitype.dev${r}`]:[],...n?[`Details: ${n}`]:[],"Version: abitype@1.2.3"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),t.cause&&(this.cause=t.cause),this.details=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.shortMessage=e}}function py(e,t){const n=e.exec(t);return n?.groups}const hy=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,my=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,yy=/^\(.+?\).*?$/,by=/^tuple(?<array>(\[(\d*)\])*)$/;function gy(e){let t=e.type;if(by.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=gy(e.components[r]),r<n-1&&(t+=", ")}const r=py(by,e.type);return t+=`)${r?.array||""}`,gy({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function wy(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=gy(e[r]),r!==n-1&&(t+=", ")}return t}function vy(e){return"function"===e.type?`function ${e.name}(${wy(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${wy(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${wy(e.inputs)})`:"error"===e.type?`error ${e.name}(${wy(e.inputs)})`:"constructor"===e.type?`constructor(${wy(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const xy=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Iy=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Py=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const zy=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function Ey(e){return zy.test(e)}function Ay(e){return py(zy,e)}const ky=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const My=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const $y=/^receive\(\) external payable$/;const Oy=new Set(["memory","indexed","storage","calldata"]),jy=new Set(["indexed"]),Sy=new Set(["calldata","memory","storage"]);class Ny extends fy{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class Ty extends fy{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class _y extends fy{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class Ry extends fy{constructor({params:e}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class Cy extends fy{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class By extends fy{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class Dy extends fy{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class Uy extends fy{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class qy extends fy{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class Ly extends fy{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Fy extends fy{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Ky extends fy{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class Vy extends fy{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class Gy extends fy{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const Zy=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function Hy(e,t={}){if(function(e){return Py.test(e)}(e))return function(e,t={}){const n=function(e){return py(Py,e)}(e);if(!n)throw new Ly({signature:e,type:"function"});const r=Xy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Jy(r[e],{modifiers:Sy,structs:t,type:"function"}));const a=[];if(n.returns){const e=Xy(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(Jy(e[n],{modifiers:Sy,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:a}}(e,t);if(function(e){return Iy.test(e)}(e))return function(e,t={}){const n=function(e){return py(Iy,e)}(e);if(!n)throw new Ly({signature:e,type:"event"});const r=Xy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Jy(r[e],{modifiers:jy,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}(e,t);if(function(e){return xy.test(e)}(e))return function(e,t={}){const n=function(e){return py(xy,e)}(e);if(!n)throw new Ly({signature:e,type:"error"});const r=Xy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Jy(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}(e,t);if(function(e){return ky.test(e)}(e))return function(e,t={}){const n=function(e){return py(ky,e)}(e);if(!n)throw new Ly({signature:e,type:"constructor"});const r=Xy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Jy(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}(e,t);if(function(e){return My.test(e)}(e))return function(e){const t=function(e){return py(My,e)}(e);if(!t)throw new Ly({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return $y.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new Fy({signature:e})}const Wy=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Yy=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Qy=/^u?int$/;function Jy(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:`${e}${r}`}(e,t?.type,t?.structs);if(Zy.has(n))return Zy.get(n);const r=yy.test(e),s=py(r?Yy:Wy,e);if(!s)throw new Cy({param:e});if(s.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||hy.test(e)||my.test(e)||tb.test(e)}(s.name))throw new By({param:e,name:s.name});const i=s.name?{name:s.name}:{},a="indexed"===s.modifier?{indexed:!0}:{},o=t?.structs??{};let c,u={};if(r){c="tuple";const e=Xy(s.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Jy(e[r],{structs:o}));u={components:t}}else if(s.type in o)c="tuple",u={components:o[s.type]};else if(Qy.test(s.type))c=`${s.type}256`;else if("address payable"===s.type)c="address";else if(c=s.type,"struct"!==t?.type&&!eb(c))throw new _y({type:c});if(s.modifier){if(!t?.modifiers?.has?.(s.modifier))throw new Dy({param:e,type:t?.type,modifier:s.modifier});if(Sy.has(s.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!s.array))throw new Uy({param:e,type:t?.type,modifier:s.modifier})}const d={type:`${c}${s.array??""}`,...i,...a,...u};return Zy.set(n,d),d}function Xy(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const s=e[i],a=e.slice(i+1);switch(s){case",":return 0===r?Xy(a,[...t,n.trim()]):Xy(a,t,`${n}${s}`,r);case"(":return Xy(a,t,`${n}${s}`,r+1);case")":return Xy(a,t,`${n}${s}`,r-1);default:return Xy(a,t,`${n}${s}`,r)}}if(""===n)return t;if(0!==r)throw new Gy({current:n,depth:r});return t.push(n.trim()),t}function eb(e){return"address"===e||"bool"===e||"function"===e||"string"===e||hy.test(e)||my.test(e)}const tb=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function nb(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!Ey(n))continue;const s=Ay(n);if(!s)throw new Ly({signature:n,type:"struct"});const i=s.properties.split(";"),a=[],o=i.length;for(let e=0;e<o;e++){const t=i[e].trim();if(!t)continue;const n=Jy(t,{type:"struct"});a.push(n)}if(!a.length)throw new Ky({signature:n});t[s.name]=a}const r={},s=Object.entries(t),i=s.length;for(let e=0;e<i;e++){const[n,i]=s[e];r[n]=sb(i,t)}return r}const rb=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function sb(e=[],t={},n=new Set){const r=[],s=e.length;for(let i=0;i<s;i++){const s=e[i];if(yy.test(s.type))r.push(s);else{const e=py(rb,s.type);if(!e?.type)throw new qy({abiParameter:s});const{array:i,type:a}=e;if(a in t){if(n.has(a))throw new Vy({type:a});r.push({...s,type:`tuple${i??""}`,components:sb(t[a],t,new Set([...n,a]))})}else{if(!eb(a))throw new Ty({type:a});r.push(s)}}}return r}function ib(e){let t;if("string"==typeof e)t=Hy(e);else{const n=nb(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(!Ey(r)){t=Hy(r,n);break}}}if(!t)throw new Ny({signature:e});return t}function ab(e){const t=[];if("string"==typeof e){const n=Xy(e),r=n.length;for(let e=0;e<r;e++)t.push(Jy(n[e],{modifiers:Oy}))}else{const n=nb(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(Ey(r))continue;const i=Xy(r),a=i.length;for(let e=0;e<a;e++)t.push(Jy(i[e],{modifiers:Oy,structs:n}))}}if(0===t.length)throw new Ry({params:e});return t}function ob({checksumAddress:e=!1,parameter:t,value:n}){const r=t,s=function(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}(r.type);if(s){const[t,i]=s;return function(e,t){const{checksumAddress:n,length:r,parameter:s}=t,i=null===r;if(!Array.isArray(e))throw new wb(e);if(!i&&e.length!==r)throw new yb({expectedLength:r,givenLength:e.length,type:`${s.type}[${r}]`});let a=!1;const o=[];for(let t=0;t<e.length;t++){const r=ob({checksumAddress:n,parameter:s,value:e[t]});r.dynamic&&(a=!0),o.push(r)}if(i||a){const e=cb(o);if(i){const t=zf(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?vf(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:vf(...o.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:i}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let s=!1;const i=[];for(let t=0;t<r.components.length;t++){const a=r.components[t],o=ob({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});i.push(o),o.dynamic&&(s=!0)}return{dynamic:s,encoded:s?cb(i):vf(...i.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return hp(e,{strict:n}),{dynamic:!1,encoded:Af(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new ml(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Af(If(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Jm.exec(r.type)??[];return function(e,{signed:t,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new Tf({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:zf(e,{size:32,signed:t})}}(n,{signed:e,size:Number(t)})}if(r.type.startsWith("bytes"))return function(e,{type:t}){const[,n]=t.split("bytes"),r=$f(e);if(!n){let t=e;return r%32!=0&&(t=kf(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:vf(Af(zf(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new bb({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:kf(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=Ef(e),n=Math.ceil($f(t)/32),r=[];for(let e=0;e<n;e++)r.push(kf(Mf(t,32*e,32*(e+1))));return{dynamic:!0,encoded:vf(kf(zf($f(t),{size:32})),...r)}}(n);throw new vb(r.type)}function cb(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:s}=e[n];t+=r?32:$f(s)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(zf(t+s,{size:32})),r.push(o),s+=$f(o)):n.push(o)}return vf(...n,...r)}const ub={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new fb({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new lb({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new db({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new db({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};class db extends ml{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class lb extends ml{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class fb extends ml{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function pb(e,t,n){const{checksumAddress:r=!1}=n??{};if(e.length!==t.length)throw new gb({expectedLength:e.length,givenLength:t.length});const s=function({checksumAddress:e,parameters:t,values:n}){const r=[];for(let s=0;s<t.length;s++)r.push(ob({checksumAddress:e,parameter:t[s],value:n[s]}));return r}({checksumAddress:r,parameters:e,values:t}),i=cb(s);return 0===i.length?"0x":i}function hb(e,t){if(e.length!==t.length)throw new gb({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r];n.push(hb.encode(s,i))}return vf(...n)}function mb(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?ab(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return hp(e),Af(e.toLowerCase(),r?32:0)}if("string"===t)return Ef(n);if("bytes"===t)return n;if("bool"===t)return Af(If(n),r?32:1);const s=t.match(Jm);if(s){const[e,t,i="256"]=s,a=Number.parseInt(i,10)/8;return zf(n,{size:r?32:a,signed:"int"===t})}const i=t.match(Qm);if(i){const[e,t]=i;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new bb({expectedSize:Number.parseInt(t,10),value:n});return kf(n,r?32:0)}const a=t.match(Ym);if(a&&Array.isArray(n)){const[t,r]=a,s=[];for(let t=0;t<n.length;t++)s.push(e(r,n[t],!0));return 0===s.length?"0x":vf(...s)}throw new vb(t)}}(hb||(hb={}));class yb extends ml{constructor({expectedLength:e,givenLength:t,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class bb extends ml{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${$f(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class gb extends ml{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class wb extends ml{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class vb extends ml{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}function xb(e){const{domain:t={},message:n,primaryType:r}=e,s={EIP712Domain:Pb(t),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:s}=e,i=(e,t)=>{for(const n of e){const{name:e,type:r}=n,a=t[e],o=r.match(Jm);if(o&&("number"==typeof a||"bigint"==typeof a)){const[,e,t]=o;zf(a,{signed:"int"===e,size:Number.parseInt(t??"",10)/8})}if("address"===r&&"string"==typeof a&&!wp(a))throw new vp({address:a,cause:new xp});const c=r.match(Qm);if(c){const[,e]=c;if(e&&$f(a)!==Number.parseInt(e,10))throw new Ab({expectedSize:Number.parseInt(e,10),givenSize:$f(a)})}const u=s[r];u&&(Tb(r),i(u,a))}};if(s.EIP712Domain&&t){if("object"!=typeof t)throw new kb({domain:t});i(s.EIP712Domain,t)}if("EIP712Domain"!==r){if(!s[r])throw new Mb({primaryType:r,types:s});i(s[r],n)}}({domain:t,message:n,primaryType:r,types:s});const i=["0x19","0x01"];return t&&i.push(function(e){const{domain:t,types:n}=e;return Eb({data:t,primaryType:"EIP712Domain",types:{...n,EIP712Domain:n?.EIP712Domain||Pb(t)}})}({domain:t,types:s})),"EIP712Domain"!==r&&i.push(Eb({data:n,primaryType:r,types:s})),vf(...i)}function Ib(e){const{primaryType:t,types:n}=e;let r="";const s=Nb({primaryType:t,types:n});s.delete(t);const i=[t,...Array.from(s).sort()];for(const e of i)r+=`${e}(${(n[e]??[]).map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`;return r}function Pb(e){return["string"==typeof e?.name&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},("number"==typeof e?.chainId||"bigint"==typeof e?.chainId)&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function zb(e){return np(xb(e))}function Eb(e){const{data:t,primaryType:n,types:r}=e;return np(Ob({data:t,primaryType:n,types:r}))}class Ab extends ml{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.BytesSizeMismatchError"})}}class kb extends ml{constructor({domain:e}){super(`Invalid domain "${hl(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.InvalidDomainError"})}}class Mb extends ml{constructor({primaryType:e,types:t}){super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(t))}\`.`,{metaMessages:["Check that the primary type is a key in `types`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.InvalidPrimaryTypeError"})}}class $b extends ml{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.InvalidStructTypeError"})}}function Ob(e){const{data:t,primaryType:n,types:r}=e,s=[{type:"bytes32"}],i=[jb({primaryType:n,types:r})];for(const e of r[n]??[]){const[n,a]=Sb({types:r,name:e.name,type:e.type,value:t[e.name]});s.push(n),i.push(a)}return pb(s,i)}function jb(e){const{primaryType:t,types:n}=e;return np(Ef(Ib({primaryType:t,types:n})))}function Sb(e){let{types:t,name:n,type:r,value:s}=e;if(void 0!==t[r])return[{type:"bytes32"},np(Ob({data:s,primaryType:r,types:t}))];if("bytes"===r){return s=`0x${(s.length%2?"0":"")+s.slice(2)}`,[{type:"bytes32"},np(s,{as:"Hex"})]}if("string"===r)return[{type:"bytes32"},np(Kf(s),{as:"Hex"})];if(r.lastIndexOf("]")===r.length-1){const e=r.slice(0,r.lastIndexOf("[")),i=s.map((r=>Sb({name:n,type:e,types:t,value:r})));return[{type:"bytes32"},np(pb(i.map((([e])=>e)),i.map((([,e])=>e))))]}return[{type:r},s]}function Nb(e,t=new Set){const{primaryType:n,types:r}=e,s=n.match(/^\w*/u),i=s?.[0];if(t.has(i)||void 0===r[i])return t;t.add(i);for(const e of r[i])Nb({primaryType:e.type,types:r},t);return t}function Tb(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new $b({type:e})}function _b(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),"("===o&&r++,")"===o&&r--,t)if(0!==r)" "!==o?(s+=o,n+=o):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===o&&["event","function","error",""].includes(s))s="";else if(s+=o,")"===o){i=!0;break}}if(!i)throw new ml("Unable to normalize signature.");return s}function Rb(e,t){const n=typeof e,r=t.type;switch(r){case"address":return wp(e,{strict:!1});case"bool":return"boolean"===n;case"function":case"string":return"string"===n;default:return"tuple"===r&&"components"in t?Object.values(t.components).every(((t,n)=>Rb(Object.values(e)[n],t))):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?"number"===n||"bigint"===n:/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?"string"===n||e instanceof Uint8Array:!!/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)&&(Array.isArray(e)&&e.every((e=>Rb(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")}))))}}function Cb(e,t,n){for(const r in e){const s=e[r],i=t[r];if("tuple"===s.type&&"tuple"===i.type&&"components"in s&&"components"in i)return Cb(s.components,i.components,n[r]);const a=[s.type,i.type];if(!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&wp(n[r],{strict:!1}))return a}}function Bb(e,t,n){const{args:r=[],prepare:s=!0}=n??{},i=Nf(t,{strict:!1}),a=e.filter((e=>i?"function"===e.type||"error"===e.type?Db(e)===Mf(t,0,4):"event"===e.type&&Ub(e)===t:"name"in e&&e.name===t));if(0===a.length)throw new Lb({name:t});if(1===a.length)return{...a[0],...s?{hash:Ub(a[0])}:{}};let o;for(const e of a){if(!("inputs"in e))continue;if(!r||0===r.length){if(!e.inputs||0===e.inputs.length)return{...e,...s?{hash:Ub(e)}:{}};continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==r.length)continue;const t=r.every(((t,n)=>{const r="inputs"in e&&e.inputs[n];return!!r&&Rb(t,r)}));if(t){if(o&&"inputs"in o&&o.inputs){const t=Cb(e.inputs,o.inputs,r);if(t)throw new qb({abiItem:e,type:t[0]},{abiItem:o,type:t[1]})}o=e}}const c=(()=>{if(o)return o;const[e,...t]=a;return{...e,overloads:t}})();if(!c)throw new Lb({name:t});return{...c,...s?{hash:Ub(c)}:{}}}function Db(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Bb(t,n)}return e[0]})();return Mf(Ub(t),0,4)}function Ub(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Bb(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:np(Ef(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Bb(t,n)}return e[0]})();return _b("string"==typeof t?t:vy(t))}(t)))}class qb extends ml{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${_b(vy(e.abiItem))}\`, and`,`\`${t.type}\` in \`${_b(vy(t.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}class Lb extends ml{constructor({name:e,data:t,type:n="item"}){super(`ABI ${n}${e?` with name "${e}"`:t?` with data "${t}"`:""} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}function Fb(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Kb(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,s=r?Kb([t,...r],t.name,{args:n}):t,i=Vb(s),a=n.length>0?pb(s.inputs,n):void 0;return a?vf(i,a):i}function Kb(e,t,n){const r=Bb(e,t,n);if("function"!==r.type)throw new Lb({name:t,type:"function"});return r}function Vb(e){return Db(e)}const Gb=Iu(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Zb=Wu({a:Gb.create(BigInt("-3")),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:Gb,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Os),Hb=Iu(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"));Wu({a:Hb.create(BigInt("-3")),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Fp:Hb,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},Ss);const Wb=Iu(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));Wu({a:Wb.create(BigInt("-3")),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Fp:Wb,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1),lowS:!1,allowedPrivateKeyLengths:[130,131,132]},js);const Yb=Zb,Qb=Zb;function Jb(e){const{privateKey:t}=e;return ip(Qb.ProjectivePoint.fromPrivateKey("string"==typeof t?t.slice(2):Pf(t).slice(2)))}function Xb(e={}){const{as:t="Hex"}=e,n=Qb.utils.randomPrivateKey();return"Hex"===t?Pf(n):n}function eg(e){const{extraEntropy:t=Zm,hash:n,payload:r,privateKey:s}=e,{r:i,s:a,recovery:o}=Qb.sign(r instanceof Uint8Array?r:Ff(r),s instanceof Uint8Array?s:Ff(s),{extraEntropy:"boolean"==typeof t?t:xf(t).slice(2),lowS:!0,...n?{prehash:!0}:{}});return{r:i,s:a,yParity:o}}function tg(e,t=0){if(!/^(-?)([0-9]*)\.?([0-9]*)$/.test(e))throw new ng({value:e});let[n="",r="0"]=e.split(".");const s=n.startsWith("-");if(s&&(n=n.slice(1)),r=r.replace(/(0+)$/,""),0===t)1===Math.round(Number(`.${r}`))&&(n=`${BigInt(n)+1n}`),r="";else if(r.length>t){const[e,s,i]=[r.slice(0,t-1),r.slice(t-1,t),r.slice(t)],a=Math.round(Number(`${s}.${i}`));r=a>9?`${BigInt(e)+BigInt(1)}0`.padStart(e.length+1,"0"):`${e}${a}`,r.length>t&&(r=r.slice(1),n=`${BigInt(n)+1n}`),r=r.slice(0,t)}else r=r.padEnd(t,"0");return BigInt(`${s?"-":""}${n}${r}`)}class ng extends ml{constructor({value:e}){super(`Value \`${e}\` is not a valid decimal number.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Value.InvalidDecimalNumberError"})}}const rg=new TextEncoder,sg=new TextDecoder,ig=Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map(((e,t)=>[t,e.charCodeAt(0)]))),ag={...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map(((e,t)=>[e.charCodeAt(0),t]))),["=".charCodeAt(0)]:0,["-".charCodeAt(0)]:62,["_".charCodeAt(0)]:63};function og(e,t={}){return function(e,t={}){const{pad:n=!0,url:r=!1}=t,s=new Uint8Array(4*Math.ceil(e.length/3));for(let t=0,n=0;n<e.length;t+=4,n+=3){const r=(e[n]<<16)+(e[n+1]<<8)+(0|e[n+2]);s[t]=ig[r>>18],s[t+1]=ig[r>>12&63],s[t+2]=ig[r>>6&63],s[t+3]=ig[63&r]}const i=e.length%3,a=4*Math.floor(e.length/3)+(i&&i+1);let o=sg.decode(new Uint8Array(s.buffer,0,a));return n&&1===i&&(o+="=="),n&&2===i&&(o+="="),r&&(o=o.replaceAll("+","-").replaceAll("/","_")),o}(Ff(e),t)}function cg(e){const t=e.replace(/=+$/,""),n=t.length,r=new Uint8Array(n+3);rg.encodeInto(t+"===",r);for(let e=0,n=0;e<t.length;e+=4,n+=3){const t=(ag[r[e]]<<18)+(ag[r[e+1]]<<12)+(ag[r[e+2]]<<6)+ag[r[e+3]];r[n]=t>>16,r[n+1]=t>>8&255,r[n+2]=255&t}const s=3*(n>>2)+(n%4&&n%4-1);return new Uint8Array(r.buffer,0,s)}const ug=Uint8Array.from([105,171,180,181,160,222,75,198,42,42,32,31,141,37,186,233]);async function dg(e){const{createFn:t=window.navigator.credentials.create.bind(window.navigator.credentials),...n}=e,r=function(e){const{attestation:t="none",authenticatorSelection:n={residentKey:"preferred",requireResidentKey:!1,userVerification:"required"},challenge:r=ug,excludeCredentialIds:s,extensions:i,name:a,rp:o={id:window.location.hostname,name:window.document.title},user:c}=e,u=c?.name??a;return{publicKey:{attestation:t,authenticatorSelection:n,challenge:"string"==typeof r?Ff(r):r,...s?{excludeCredentials:s?.map((e=>({id:cg(e),type:"public-key"})))}:{},pubKeyCredParams:[{type:"public-key",alg:-7}],...i&&{extensions:i},rp:o,user:{id:c?.id??np(Kf(u),{as:"Bytes"}),name:u,displayName:c?.displayName??u}}}}(n);try{const e=await t(r);if(!e)throw new pg;const n=e.response,s=await async function(e){try{const t=e.getPublicKey();if(!t)throw new pg;const n=new Uint8Array(t),r=await crypto.subtle.importKey("spki",new Uint8Array(n),{name:"ECDSA",namedCurve:"P-256",hash:"SHA-256"},!0,["verify"]);return ip(new Uint8Array(await crypto.subtle.exportKey("raw",r)))}catch(t){if("Permission denied to access object"!==t.message)throw t;const n=new Uint8Array(e.attestationObject),r=32,s=88,i=e=>{const t=new Uint8Array([e,s,r]);for(let e=0;e<n.length-t.length;e++)if(t.every(((t,r)=>n[e+r]===t)))return e+t.length;throw new pg},a=i(33),o=i(34);return ip(new Uint8Array([4,...n.slice(a,a+r),...n.slice(o,o+r)]))}}(n);return{id:e.id,publicKey:s,raw:e}}catch(e){throw new pg({cause:e})}}function lg(e){const{challenge:t,crossOrigin:n,extraClientData:r,flag:s,origin:i,rpId:a,signCount:o,userVerification:c="required"}=e,u=function(e={}){const{flag:t=5,rpId:n=window.location.hostname,signCount:r=0}=e;return vf(rp(Ef(n)),zf(t,{size:1}),zf(r,{size:4}))}({flag:s,rpId:a,signCount:o}),d=function(e){const{challenge:t,crossOrigin:n=!1,extraClientData:r,origin:s=window.location.origin}=e;return JSON.stringify({type:"webauthn.get",challenge:og(t,{url:!0,pad:!1}),origin:s,crossOrigin:n,...r})}({challenge:t,crossOrigin:n,extraClientData:r,origin:i}),l=rp(Ef(d)),f=d.indexOf('"challenge"'),p=d.indexOf('"type"');return{metadata:{authenticatorData:u,clientDataJSON:d,challengeIndex:f,typeIndex:p,userVerificationRequired:"required"===c},payload:vf(u,l)}}async function fg(e){const{getFn:t=window.navigator.credentials.get.bind(window.navigator.credentials),...n}=e,r=function(e){const{credentialId:t,challenge:n,extensions:r,rpId:s=window.location.hostname,userVerification:i="required"}=e;return{publicKey:{...t?{allowCredentials:Array.isArray(t)?t.map((e=>({id:cg(e),type:"public-key"}))):[{id:cg(t),type:"public-key"}]}:{},challenge:Ff(n),...r&&{extensions:r},rpId:s,userVerification:i}}}(n);try{const e=await t(r);if(!e)throw new hg;const n=e.response,s=String.fromCharCode(...new Uint8Array(n.clientDataJSON)),i=s.indexOf('"challenge"'),a=s.indexOf('"type"'),o=function(e){const t=0===e[4]?5:4,n=t+32,r=0===e[n+2]?n+3:n+2,s=BigInt(Pf(e.slice(t,n))),i=BigInt(Pf(e.slice(r)));return{r:s,s:i>Yb.CURVE.n/2n?Yb.CURVE.n-i:i}}(new Uint8Array(n.signature));return{metadata:{authenticatorData:Pf(new Uint8Array(n.authenticatorData)),clientDataJSON:s,challengeIndex:i,typeIndex:a,userVerificationRequired:"required"===r.publicKey.userVerification},signature:o,raw:e}}catch(e){throw new hg({cause:e})}}class pg extends ml{constructor({cause:e}={}){super("Failed to create credential.",{cause:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WebAuthnP256.CredentialCreationFailedError"})}}class hg extends ml{constructor({cause:e}={}){super("Failed to request credential.",{cause:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WebAuthnP256.CredentialRequestFailedError"})}}const mg="0x3232323232323232323232323232323232323232",yg="0x32323232",bg={p256:"p256",secp256k1:"secp256k1",webauthnp256:"webauthn-p256"},gg={admin:"admin",normal:"session"},wg={0:"minute",1:"hour",2:"day",3:"week",4:"month",5:"year"},vg={address:"secp256k1",p256:"p256",secp256k1:"secp256k1","webauthn-p256":"webauthnp256"},xg={admin:"admin",session:"normal"},Ig={address:2,p256:0,secp256k1:2,"webauthn-p256":1},Pg={day:2,hour:1,minute:0,month:4,week:3,year:5};function zg(e={}){return function(e){const{chainId:t,expiry:n,feeToken:r,permissions:s,privateKey:i,role:a}=e,o=op(Jb({privateKey:i}),{includePrefix:!1});return Mg({chainId:t,expiry:n,feeToken:r,permissions:s,privateKey:()=>i,publicKey:o,role:a,type:"p256"})}({...e,privateKey:Xb()})}async function Eg(e){const{createFn:t,label:n,rpId:r,userId:s}=e,i=await dg({authenticatorSelection:{requireResidentKey:!0,residentKey:"required",userVerification:"required"},createFn:t,extensions:{credProps:!0},rp:r?{id:r,name:r}:void 0,user:{displayName:n,id:new Uint8Array(s??Kf(n)),name:n}});return $g({...e,credential:{id:i.id,publicKey:i.publicKey},id:s?Hf(s):op(i.publicKey,{includePrefix:!1})})}function Ag(e={}){return function(e){const{privateKey:t}=e,n=op(Jb({privateKey:t}),{includePrefix:!1});return Mg({chainId:e.chainId,expiry:e.expiry??0,feeToken:e.feeToken,permissions:e.permissions,privateKey:{privateKey:()=>t},publicKey:n,role:e.role,type:"webauthn-p256"})}({...e,privateKey:Xb()})}async function kg(e={}){return function(e){const{chainId:t,expiry:n,feeToken:r,keyPair:s,permissions:i,role:a}=e,{privateKey:o}=s,c=op(s.publicKey,{includePrefix:!1});return Mg({chainId:t,expiry:n,feeToken:r,permissions:i,prehash:!0,privateKey:o,publicKey:c,role:a,type:"p256"})}({...e,keyPair:await async function(e={}){const{extractable:t=!1}=e,n=await globalThis.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},t,["sign","verify"]),r=await globalThis.crypto.subtle.exportKey("raw",n.publicKey),s=ip(new Uint8Array(r));return{privateKey:n.privateKey,publicKey:s}}()})}function Mg(e,t={}){const{chainId:n=e.chainId}=t,{expiry:r=0,id:s,prehash:i=!1,role:a="admin",type:o}=e,c=(()=>{const t=e.publicKey;if("0x"===t)return t;if("secp256k1"===o||"address"===o){return 20===$f(t)||0n===jf(Mf(t,0,12))?Mf(t,-20):bp(ap(t))}return t})();return{...e,chainId:n,expiry:r,hash:Og({publicKey:c,type:o}),id:(s??c).toLowerCase(),prehash:i,publicKey:c.toLowerCase(),role:a,type:o}}function $g(e){const{credential:t,id:n,rpId:r}=e,s=op(t.publicKey,{includePrefix:!1});return Mg({chainId:e.chainId,expiry:e.expiry??0,feeToken:e.feeToken,id:n,permissions:e.permissions,privateKey:{credential:t,rpId:r},publicKey:s,role:e.role,type:"webauthn-p256"})}function Og(e){const{type:t}=e,n=jg(e.publicKey);return np(pb([{type:"uint8"},{type:"bytes32"}],[Ig[t],np(n)]))}function jg(e){return $f(e)<32?Af(e,32):e}async function Sg(e,t){const{address:n,storage:r,webAuthn:s,wrap:i=!0}=t,{privateKey:a,publicKey:o,type:c}=e;if(!a)throw new Error("Key does not have a private key to sign with.\n\nKey:\n"+hl(e,null,2));const u=n?zb({domain:{verifyingContract:n},message:{digest:t.payload},primaryType:"ERC1271Sign",types:{ERC1271Sign:[{name:"digest",type:"bytes32"}]}}):t.payload,[d,l]=await(async()=>{if("p256"===c){const{privateKey:t}=e;if("function"==typeof t)return[ry(eg({payload:u,privateKey:t()})),!1];if(t instanceof CryptoKey){const e=ry(await async function(e){const{payload:t,privateKey:n}=e,r=await globalThis.crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},n,qf(t)),s=Lf(new Uint8Array(r)),i=Zf(Gf(s,0,32));let a=Zf(Gf(s,32,64));return a>Yb.CURVE.n/2n&&(a=Yb.CURVE.n-a),{r:i,s:a}}({payload:u,privateKey:t}));return[e,!0]}}if("secp256k1"===c)return[ry(Wm({payload:u,privateKey:a()})),!1];if("webauthn-p256"===c){if(a.privateKey){const{payload:e,metadata:t}=lg({challenge:u,origin:"https://ithaca.xyz",rpId:"ithaca.xyz"}),{r:n,s:r}=eg({hash:!0,payload:e,privateKey:a.privateKey()});return[_g({metadata:t,signature:{r:n,s:r}}),!1]}const{credential:t,rpId:n}=a,i=`porto.webauthnVerified.${e.hash}`,o=Date.now(),c=6e5;let d=!0;if(r){const e=await r.getItem(i);d=!e||o-e>c}const{signature:{r:l,s:f},raw:p,metadata:h}=await fg({challenge:u,credentialId:t.id,getFn:s?.getFn,rpId:n,userVerification:d?"required":"preferred"}),m=p.response;if(!m?.userHandle)throw new Error("No user handle in response",{cause:{response:m}});const y=Hf(new Uint8Array(m.userHandle));if(e.id&&wp(e.id)&&!gp(e.id,y))throw new Error(`supplied webauthn key "${e.id}" does not match signature webauthn key "${y}"`,{cause:{id:y,key:e}});d&&r&&await r.setItem(i,o);return[_g({metadata:h,signature:{r:l,s:f}}),!1]}throw new Error(`Key type "${c}" is not supported.\n\nKey:\n`+hl(e,null,2))})();return i?Rg(d,{keyType:c,prehash:l,publicKey:o}):d}function Ng(e,t={}){const{expiry:n=0,prehash:r=!1,publicKey:s,role:i="admin",type:a}=e,{feeTokens:o,orchestrator:c}=t,u=Object.entries(Tg(e,{feeTokens:o})).map((([e,t])=>{if("calls"===e){return t.map((({signature:e,to:t})=>({selector:e?Nf(e)?e:Vb(e):yg,to:t??mg,type:"call"})))}if("feeToken"!==e){if("spend"===e){return t.map((({limit:e,period:t,token:n})=>({limit:e,period:t,token:n,type:"spend"})))}throw new Error(`Invalid permission type "${e}".`)}})).flat().filter(Boolean);return"session"===e.role&&c&&u.push({selector:yg,to:c,type:"call"}),{expiry:n,permissions:u??[],prehash:r,publicKey:jg(s),role:xg[i],type:vg[a]}}function Tg(e,t){const{permissions:n}=e,r=n?.calls?[...n.calls]:[],s=n?.spend?[...n.spend]:[],i=t.feeTokens?.filter((e=>e.feeToken));if(i&&i.length>0){const t=function(e,t){const{feeTokens:n}=t;if(!e.feeToken)return;const r=n.find((t=>e.feeToken.symbol===t.symbol||(e.feeToken.symbol?"native"===e.feeToken.symbol&&t.address===Wd:t.address===Wd)));if(!r)return;const s=tg(e.feeToken.limit,r.decimals);return{...r,value:s}}(e,{feeTokens:i});if(t){let e=-1,n=Pg.year;for(let r=0;r<s.length;r++){const i=s[r];if(i.token&&gp(t.address,i.token)){e=r;break}if(!i.token&&t.address===Wd){e=r;break}const a=Pg[i.period];a<n&&(n=a)}-1!==e?(s[e]={...s[e],limit:s[e].limit+t.value},s.unshift(s.splice(e,1)[0])):"number"==typeof n&&s.unshift({limit:t.value,period:wg[n],token:t.address})}}return{...n,calls:r,spend:s}}function _g(e){const{metadata:t,signature:n}=e;return pb(mb(["struct WebAuthnAuth { bytes authenticatorData; string clientDataJSON; uint256 challengeIndex; uint256 typeIndex; bytes32 r; bytes32 s; }","WebAuthnAuth auth"]),[{authenticatorData:t.authenticatorData,challengeIndex:BigInt(t.challengeIndex),clientDataJSON:t.clientDataJSON,r:zf(n.r,{size:32}),s:zf(n.s,{size:32}),typeIndex:BigInt(t.typeIndex)}])}function Rg(e,t){const{keyType:n,prehash:r=!1,publicKey:s}=t;return hb(["bytes","bytes32","bool"],[e,Og({publicKey:s,type:n}),r])}function Cg(e){const t="string"==typeof e?{address:e}:e,n=t.sign?"privateKey":"porto",{address:r,sign:s,signMessage:i,signTransaction:a,signTypedData:o,type:c}=function(e){if("string"==typeof e){if(!Qt(e,{strict:!1}))throw new Kt({address:e});return{address:e,type:"json-rpc"}}if(!Qt(e.address,{strict:!1}))throw new Kt({address:e.address});return{address:e.address,nonceManager:e.nonceManager,sign:e.sign,signAuthorization:e.signAuthorization,signMessage:e.signMessage,signTransaction:e.signTransaction,signTypedData:e.signTypedData,source:"custom",type:"local"}}({address:t.address,sign({hash:e}){if("privateKey"===n)return t.sign({hash:e});throw new Error("`sign` not supported on porto accounts.")},signMessage({message:e}){return this.sign({hash:mo(e)})},signTransaction(){throw new Error("`signTransaction` not supported on porto accounts.")},signTypedData(e){return this.sign({hash:xo(e)})}});return{address:r,keys:t.keys??void 0,sign:s,signMessage:i,signTransaction:a,signTypedData:o,source:n,type:c}}function Bg(e,t={}){const{keys:n}=t,r=bp(function(e){const{privateKey:t}=e;return ip(ud.ProjectivePoint.fromPrivateKey(xf(t).slice(2)))}({privateKey:e}));return Cg({address:r,keys:n,sign:async({hash:t})=>ry(Wm({payload:t,privateKey:e})),source:"privateKey"})}function Dg(e,t={}){const{key:n,role:r}=t;if(null!==n)return"object"==typeof n?n:e.keys&&e.keys.length>0?"number"==typeof n?e.keys[n]:e.keys.find((e=>e.privateKey&&(!r||e.role===r))):void 0}async function Ug(e,t){const{storage:n,replaySafe:r=!0,wrap:s=!0,webAuthn:i}=t,a=Dg(e,t),o=r?zb({domain:{verifyingContract:e.address},message:{digest:t.payload},primaryType:"ERC1271Sign",types:{ERC1271Sign:[{name:"digest",type:"bytes32"}]}}):t.payload,c=a?({hash:e})=>Sg(a,{address:null,payload:e,storage:n,webAuthn:i,wrap:s}):"privateKey"===e.source?e.sign:void 0;if(!c)throw new Error("cannot find key to sign with.");return await c({hash:o})}function qg(e,t={}){return function(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?ib(e):e;return{...r,...n?{hash:Ub(r)}:{}}}(e,t)}const Lg=qg({inputs:[{name:"message",type:"string"}],name:"Error",type:"error"}),Fg="0x08c379a0",Kg=qg({inputs:[{name:"reason",type:"uint8"}],name:"Panic",type:"error"}),Vg="0x4e487b71";class Gg extends ee{constructor(){super("Function is not recognized.",{metaMessages:["This could be due to any of the following:"," - The contract does not have the function,"," - The address is not a contract."],name:"FunctionSelectorNotRecognizedError"})}}function Zg(e,t={}){return function(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?wc(e):e;return{...r,...n?{hash:Hd(r)}:{}}}(e,t)}function Hg(e){return function(e){return na(Hd(e),0,4)}(e)}const Wg=()=>Gm(["0x",nm()],{message:"Needs string in format ^0x[A-Fa-f0-9]{40}$."}),Yg=()=>Gm(["0x",nm()],{message:"Needs string in format ^0x[A-Fa-f0-9]+$."}),Qg=()=>Lm(Yg(),sm(),{decode:e=>Sf(e),encode:e=>zf(e)}),Jg=()=>Lm(Yg(),cm({message:"Required bigint"}),{decode:e=>jf(e),encode:e=>zf(e)});function Xg(e){return km(e)}class ew extends ml{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Schema.ValidationError"})}}function tw(e){const t=e;let n=`Validation failed with ${t.issues.length} error${1===t.issues.length?"":"s"}:`;n+="\n";for(const e of t.issues)e&&(n+="\n",n+=nw(e));return new ew(n)}function nw(e,t=0){const n=function(e){return 0===e.length?"":"at `"+e.map(((e,t)=>"number"==typeof e?`[${e}]`:"symbol"==typeof e?`[${e.toString()}]`:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)&&t>0?`.${e}`:0===t&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)?e:`["${e}"]`)).join("")+"`"}(e.path),r="- "+(n?`${n}: `:""),s=" ".repeat(t+1);let i=r;switch(e.code){case"invalid_type":{const t=e.expected,n=e.input?function(e){const t=e.input;if(void 0===t)return"undefined";if(null===t)return"null";const n=typeof t;if("object"===n)return Array.isArray(t)?"array":t instanceof Date?"date":t instanceof Map?"map":t instanceof Set?"set":"object";return n}(e):"undefined";i+=`Expected ${t}. ${"Invalid input"!==e.message?e.message:""}`,"undefined"!==n&&(i+=`but received ${n}`);break}case"too_big":{const t=e.maximum,n=e.inclusive??!0,r=e.exact??!1;i+=r?`${e.origin} must be exactly ${t}`:`${e.origin} must be ${n?"at most":"less than"} ${t}`;break}case"too_small":{const t=e.minimum,n=e.inclusive??!0,r=e.exact??!1;i+=r?`${e.origin} must be exactly ${t}`:`${e.origin} must be ${n?"at least":"greater than"} ${t}`;break}case"invalid_format":switch(e.format){case"regex":case"template_literal":i+=`Must match pattern: ${e.pattern}`;break;case"starts_with":i+=`Must start with "${e.prefix}"`;break;case"ends_with":i+=`Must end with "${e.suffix}"`;break;case"includes":i+=`Must include "${e.includes}"`;break;default:i+=`Invalid ${e.format} format`}break;case"not_multiple_of":i+=`Number must be a multiple of ${e.divisor}`;break;case"unrecognized_keys":{const t=e.keys.map((e=>`"${e}"`)).join(", ");i+=`Unrecognized key${e.keys.length>1?"s":""}: ${t}`;break}case"invalid_union":{const n=e.errors&&e.errors.length>0;i+="Invalid union value.",n&&e.errors.forEach((e=>{e.length>0&&e.forEach((e=>{i+="\n",i+=s,i+=nw(e,t+1)}))}));break}case"invalid_key":i+=`Invalid ${e.origin} key`,e.issues&&e.issues.length>0&&e.issues.forEach((e=>{i+="\n",i+=s,i+=nw(e,t+1)}));break;case"invalid_element":i+=`Invalid ${e.origin} element at key "${e.key}"`,e.issues&&e.issues.length>0&&e.issues.forEach((e=>{i+="\n",i+=s,i+=nw(e,t+1)}));break;case"invalid_value":{const t=e.values.map((e=>JSON.stringify(e))).join(", ");e.values.length>1?i+=`Expected one of: ${t}`:i+=`Expected ${t}`;break}case"custom":i+=e.message||"Custom validation failed";break;default:i+=e.message||"Validation failed"}return i}const rw=Im({selector:Yg(),to:Wg(),type:Tm("call")}),sw=Im({limit:Jg(),period:km([Tm("minute"),Tm("hour"),Tm("day"),Tm("week"),Tm("month"),Tm("year")]),token:Rm(km([Wg(),fm()])),type:Tm("spend")}),iw=km([rw,sw]),aw=Im({expiry:Qg(),prehash:Rm(am()),publicKey:Yg(),role:km([Tm("admin"),Tm("normal")]),type:km([Tm("p256"),Tm("secp256k1"),Tm("webauthnp256")])}),ow=Im({...aw.shape,permissions:Km(vm(iw))});var cw,uw,dw,lw,fw,pw;!function(e){e.AssetDiffAsset=km([Im({address:Rm(km([Wg(),fm()])),decimals:Rm(km([sm(),fm()])),direction:km([Tm("incoming"),Tm("outgoing")]),fiat:Rm(Im({currency:nm(),value:Lm(nm(),sm(),{decode:e=>Number(e),encode:e=>String(e)})})),name:Rm(km([nm(),fm()])),symbol:nm(),type:Tm("erc20"),value:Jg()}),Im({address:Rm(km([Wg(),fm()])),direction:km([Tm("incoming"),Tm("outgoing")]),fiat:Rm(Im({currency:nm(),value:Lm(nm(),sm(),{decode:e=>Number(e),encode:e=>String(e)})})),name:Rm(km([nm(),fm()])),symbol:nm(),type:Tm("erc721"),uri:nm(),value:Jg()}),Im({address:fm(),decimals:Rm(km([sm(),fm()])),direction:km([Tm("incoming"),Tm("outgoing")]),fiat:Rm(Im({currency:nm(),value:Lm(nm(),sm(),{decode:e=>Number(e),encode:e=>String(e)})})),symbol:nm(),type:fm(),value:Jg()})]),e.Response=Sm(Yg(),Km(vm(Km(Om([Wg(),Km(vm(e.AssetDiffAsset))])))))}(cw||(cw={})),function(e){e.Request=Km(vm(ow)),e.Response=Km(vm(Im({...ow.shape,hash:Yg()})))}(uw||(uw={})),function(e){e.Response=Sm(Yg(),Im({currency:nm(),value:nm()}))}(dw||(dw={})),function(e){e.Request=Im({feePayer:Rm(Wg()),feeToken:Rm(Wg()),nonce:Rm(Jg())})}(lw||(lw={})),(fw||(fw={})).Request=Km(vm(Im({address:Wg(),value:Jg()}))),function(e){e.Request=Km(vm(Im({hash:Yg()}))),e.Response=Km(vm(Im({hash:Yg()})))}(pw||(pw={}));const hw=Im({eoa:Wg(),executionData:Yg(),nonce:Yg(),signature:Yg()}),mw=Im({...hw.shape,chainId:Qg()}),yw=km([Im({combinedGas:Jg(),encodedFundTransfers:Km(vm(Yg())),encodedPreCalls:Km(vm(Yg())),eoa:Wg(),executionData:Yg(),expiry:Jg(),funder:Wg(),funderSignature:Yg(),isMultichain:am(),nonce:Jg(),payer:Wg(),paymentAmount:Jg(),paymentMaxAmount:Jg(),paymentRecipient:Wg(),paymentSignature:Yg(),paymentToken:Wg(),settler:Wg(),settlerContext:Yg(),signature:Yg(),supportedAccountImplementation:Wg()}),Im({combinedGas:Jg(),encodedFundTransfers:Km(vm(Yg())),encodedPreCalls:Km(vm(Yg())),eoa:Wg(),executionData:Yg(),expiry:Jg(),funder:Wg(),funderSignature:Yg(),isMultichain:am(),nonce:Jg(),payer:Wg(),paymentRecipient:Wg(),paymentSignature:Yg(),paymentToken:Wg(),prePaymentAmount:Jg(),prePaymentMaxAmount:Jg(),settler:Wg(),settlerContext:Yg(),signature:Yg(),supportedAccountImplementation:Wg(),totalPaymentAmount:Jg(),totalPaymentMaxAmount:Jg()})]);Im({eoa:Wg(),executionData:Yg(),nonce:Jg()});const bw=Im({address:km([Wg(),fm()]),decimals:Rm(sm()),deficit:Jg(),fiat:Rm(Im({currency:nm(),value:nm()})),name:Rm(nm()),required:Jg(),symbol:Rm(nm())}),gw=Im({additionalAuthorization:Dm(Im({address:Wg(),chainId:Qg(),nonce:Qg(),r:Yg(),s:Yg(),yParity:Qg()})),assetDeficits:Rm(vm(bw)),authorizationAddress:Rm(km([Wg(),fm()])),chainId:Qg(),ethPrice:Jg(),extraPayment:Jg(),feeTokenDeficit:Jg(),intent:yw,nativeFeeEstimate:Im({maxFeePerGas:Jg(),maxPriorityFeePerGas:Jg()}),orchestrator:Wg(),paymentTokenDecimals:sm(),txGas:Jg()}),ww=Im({multiChainRoot:Rm(km([Yg(),fm()])),quotes:Km(vm(gw)).check(Jh(1)),ttl:sm()}),vw=Im({...ww.shape,hash:Yg(),r:Yg(),s:Yg(),v:Rm(Yg()),yParity:Rm(Yg())}),xw=Im({address:Wg(),decimals:sm(),feeToken:Rm(am()),interop:Rm(am()),nativeRate:Rm(Jg()),symbol:nm(),uid:nm()}),Iw=nm().check(Xh(/^[A-Z0-9]+$/)),Pw=Im({address:Wg(),chainId:Qg(),nonce:Qg()}),zw=Im({...Pw.shape,r:Yg(),s:Yg(),yParity:Qg()}),Ew=Im({data:Rm(Yg()),to:Wg(),value:Rm(Jg())});var Aw,kw,Mw,$w,Ow,jw,Sw,Nw,Tw,_w,Rw,Cw,Bw,Dw,Uw,qw,Lw,Fw,Kw,Vw,Gw;async function Zw(e,t={}){const n=t.chainId?[t.chainId]:"all"!==t.chainIds?t.chainIds?t.chainIds:[e.chain.id]:void 0;try{const r="wallet_getCapabilities",s=await Da((()=>e.request({method:r,params:n?[n]:void 0},{retryCount:0})),{cacheKey:`${e.uid}.${r}.${n?.join(",")}`}),i=t.raw?s:sh(Cw.Response,s);return t.chainIds?i:Object.values(i)[0]}catch(e){throw Jw(e),e}}async function Hw(e,t){const{address:n,capabilities:r,chain:s=e.chain,key:i}=t,a=t.calls.map((e=>({data:e.abi?Fb(Kb(e.abi,e.functionName),e.args):e.data??"0x",to:e.to,value:e.value??0n})));try{const t="wallet_prepareCalls",o=await e.request({method:t,params:[nh(qw.Parameters,{calls:a,capabilities:{...r,meta:{...r?.meta}},chainId:s?.id,from:n,key:i?{prehash:i.prehash,publicKey:i.publicKey,type:i.type}:void 0})]},{retryCount:0});return Object.assign(sh(qw.Response,o),{_raw:o})}catch(e){throw Jw(e),Yw(e,{calls:t.calls}),e}}async function Ww(e,t){const{signature:n}=t,{signature:r,capabilities:{feeSignature:s,...i},...a}=t.response,o=Qw({capabilities:i,...a}),c=Hm({payload:np(Ef(JSON.stringify(o))),signature:ty(n)}),{quoteSigner:u}=await async function(e){const t="health",n=await Da((()=>e.request({method:t})),{cacheKey:`${e.uid}.${t}`});return sh(Nw.Response,n)}(e);return c===u}function Yw(e,{calls:t}={}){if(!(e instanceof ee))return;const n=function(e,t){const n=e.walk((e=>"data"in e));if(!n?.data)return e;if(n.data===Hg(Zg("error FnSelectorNotRecognized()")))return new Gg;let r=null;for(const e of t.calls){const t=e;if(t.abi)try{if(!Boolean(_n({abi:t.abi,data:n.data})))continue;r=t}catch{}}return r?Rr(n,{abi:r.abi,address:r.to,args:r.args,functionName:r.functionName}):e}(e,{calls:t??[]}),r=(e=>{try{if("ContractFunctionExecutionError"===e.name){const t="ContractFunctionRevertedError"===e.cause.name?e.cause.data:void 0;if(t)return function(e,t,n){if("Error"===t)return Lg;if("Panic"===t)return Kg;if(Nf(t,{strict:!1})){const e=Mf(t,0,4);if(e===Fg)return Lg;if(e===Vg)return Kg}const r=Bb(e,t,n);if("error"!==r.type)throw new Lb({name:t,type:"error"});return r}([t.abiItem],t.errorName)}const t=e.walk((e=>!(e instanceof Error)&&3===e.code));if(!t)return;const{data:n,message:r}=t;return"0xd0d5039b"===n?qg("error Unauthorized()"):{inputs:[],name:(r??n).split("(")[0],type:"error"}}catch{return}})(n);if(n!==e||r)throw new Xw(Object.assign(n,{abiError:r}))}function Qw(e){if("object"==typeof e&&null!==e){if(Array.isArray(e))return e.map(Qw);const t={};for(const n of Object.keys(e).sort())t[n]=Qw(e[n]);return t}return e}function Jw(e){if("$ZodError"===e.name)throw tw(e)}!function(e){e.Parameters=Im({address:Wg(),secret:nm()}),e.Request=Im({method:Tm("account_getOnrampContactInfo"),params:Km(Om([e.Parameters]))}),e.Response=Im({email:Rm(nm()),phone:Rm(nm()),phoneVerifiedAt:Rm(sm())})}(Aw||(Aw={})),function(e){e.Parameters=Im({address:Wg()}),e.Request=Im({method:Tm("account_onrampStatus"),params:Km(Om([e.Parameters]))}),e.Response=Im({email:Rm(sm()),phone:Rm(sm())})}(kw||(kw={})),function(e){e.Parameters=Im({phone:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_resendVerifyPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Mw||(Mw={})),function(e){e.Parameters=Im({email:nm().check(Xh(/^.*@.*$/)),walletAddress:Wg()}),e.Request=Im({method:Tm("account_setEmail"),params:Km(Om([e.Parameters]))}),e.Response=fm()}($w||($w={})),function(e){e.Parameters=Im({phone:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_setPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Ow||(Ow={})),function(e){e.Parameters=Im({chainId:Qg(),email:nm(),signature:Yg(),token:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_verifyEmail"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(jw||(jw={})),function(e){e.Parameters=Im({code:nm(),phone:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_verifyPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Sw||(Sw={})),function(e){e.Request=Im({method:Tm("health"),params:dm()}),e.Response=Im({quoteSigner:Wg(),status:nm(),version:nm()})}(Nw||(Nw={})),function(e){e.Parameters=Im({address:Wg(),chainId:Qg(),tokenAddress:Wg(),value:Jg()}),e.Request=Im({method:Tm("wallet_addFaucetFunds"),params:Km(Om([e.Parameters]))}),e.Response=Im({message:Rm(nm()),transactionHash:Yg()})}(Tw||(Tw={})),function(e){e.Parameters=Im({chainId:Qg(),id:Yg()}),e.Request=Im({method:Tm("wallet_getAccounts"),params:Km(Om([e.Parameters]))}),e.Response=Km(vm(Im({address:Wg(),keys:uw.Response})))}(_w||(_w={})),function(e){e.Parameters=Im({address:Wg()}),e.Request=Im({method:Tm("wallet_getAuthorization"),params:Km(Om([e.Parameters]))}),e.Response=Im({authorization:zw,data:Yg(),to:Wg()})}(Rw||(Rw={})),function(e){e.Request=Im({method:Tm("wallet_getCapabilities"),params:Rm(Om([Km(vm(sm()))]))});const t=Im({address:Wg(),version:Rm(km([nm(),fm()]))});e.Response=Sm(Yg(),Im({contracts:Im({accountImplementation:t,accountProxy:t,legacyAccountImplementations:Km(vm(t)),legacyOrchestrators:Km(vm(km([Im({orchestrator:t,simulator:t}),t]))),orchestrator:t,simulator:t}),fees:Im({quoteConfig:Im({constantRate:Rm(km([sm(),fm()])),gas:Rm(Im({intentBuffer:Rm(sm()),txBuffer:Rm(sm())})),rateTtl:sm(),ttl:sm()}),recipient:Wg(),tokens:Km(vm(xw))})}))}(Cw||(Cw={})),function(e){const t=km([Tm("native"),Tm("erc20"),Tm("erc721"),nm()]);e.Parameters=Im({account:Wg(),assetFilter:Rm(Sm(Yg(),Km(vm(Im({address:km([Wg(),Tm("native")]),type:t}))))),assetTypeFilter:Rm(Km(vm(t))),chainFilter:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_getAssets"),params:Km(Om([e.Parameters]))}),e.Price=Im({currency:nm(),value:Lm(nm(),sm(),{decode:e=>Number(e),encode:e=>String(e)})}),e.Response=Sm(nm(),Km(vm(Xg([Im({address:Wg(),balance:Jg(),metadata:Bm(Im({decimals:sm(),fiat:Dm(e.Price),name:nm(),symbol:nm()})),type:Tm("erc20")}),Im({address:Bm(Tm("native")),balance:Jg(),metadata:Bm(Im({decimals:sm(),fiat:Dm(e.Price),name:Rm(nm()),symbol:Rm(nm())})),type:Tm("native")})]))))}(Bw||(Bw={})),function(e){e.Request=Im({method:Tm("wallet_getCallsStatus"),params:Km(Om([Yg()]))}),e.Response=Im({id:nm(),receipts:Rm(Km(vm(Im({blockHash:Yg(),blockNumber:Qg(),chainId:Qg(),gasUsed:Qg(),logs:Km(vm(Im({address:Wg(),data:Yg(),topics:Km(vm(Yg()))}))),status:Yg(),transactionHash:Yg()})))),status:sm()})}(Dw||(Dw={})),function(e){e.Parameters=Im({address:Wg(),chainIds:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_getKeys"),params:Km(Om([e.Parameters]))}),e.Response=Sm(Yg(),uw.Response)}(Uw||(Uw={})),function(e){e.Capabilities=Im({authorizeKeys:Rm(uw.Request),meta:lw.Request,preCall:Rm(am()),preCalls:Rm(Km(vm(hw))),requiredFunds:Rm(fw.Request),revokeKeys:Rm(pw.Request)}),e.ResponseCapabilities=Im({assetDiffs:Rm(cw.Response),authorizeKeys:Dm(uw.Response),feePayerDigest:Rm(Yg()),feeSignature:Rm(Yg()),feeTotals:Rm(dw.Response),revokeKeys:Dm(pw.Response)}),e.Parameters=Im({calls:Km(vm(Ew)),capabilities:e.Capabilities,chainId:Qg(),from:Rm(Wg()),key:Rm(Im({prehash:am(),publicKey:Yg(),type:aw.shape.type}))}),e.Request=Im({method:Tm("wallet_prepareCalls"),params:Km(Om([e.Parameters]))}),e.Response=Im({capabilities:e.ResponseCapabilities,context:Im({preCall:Rm(Em(mw)),quote:Rm(Em(vw))}),digest:Yg(),key:Dm(Im({prehash:am(),publicKey:Yg(),type:aw.shape.type})),signature:Yg(),typedData:Im({domain:km([Im({chainId:km([Qg(),sm()]),name:nm(),verifyingContract:Wg(),version:nm()}),Im({})]),message:Sm(nm(),ym()),primaryType:nm(),types:Sm(nm(),ym())})})}(qw||(qw={})),function(e){e.Capabilities=Im({authorizeKeys:uw.Request}),e.Parameters=Im({address:Wg(),capabilities:e.Capabilities,chainId:Rm(sm()),delegation:Wg()}),e.Request=Im({method:Tm("wallet_prepareUpgradeAccount"),params:Km(Om([e.Parameters]))}),e.Response=Im({capabilities:e.Capabilities,chainId:Qg(),context:Im({address:Wg(),authorization:Pw,chainId:Qg(),preCall:hw}),digests:Im({auth:Yg(),exec:Yg()}),typedData:Im({domain:km([Im({chainId:km([Qg(),sm()]),name:nm(),verifyingContract:Wg(),version:nm()}),Im({})]),message:Sm(nm(),ym()),primaryType:nm(),types:Sm(nm(),ym())})})}(Lw||(Lw={})),function(e){e.Request=Im({method:Tm("wallet_feeTokens"),params:Rm(dm())}),e.Response=Sm(Yg(),Km(vm(Im({address:Wg(),decimals:sm(),nativeRate:Rm(Jg()),symbol:nm()}))))}(Fw||(Fw={})),function(e){e.Parameters=Im({capabilities:Rm(Im({feeSignature:Rm(Yg())})),context:Im({preCall:Rm(Em(mw)),quote:Rm(Em(vw))}),key:Rm(Im({prehash:am(),publicKey:Yg(),type:aw.shape.type})),signature:Yg()}),e.Request=Im({method:Tm("wallet_sendPreparedCalls"),params:Km(Om([e.Parameters]))}),e.Response=Im({id:Yg()})}(Kw||(Kw={})),function(e){e.Parameters=Im({context:Im({address:Wg(),authorization:Pw,chainId:Qg(),preCall:hw}),signatures:Im({auth:Yg(),exec:Yg()})}),e.Request=Im({method:Tm("wallet_upgradeAccount"),params:Km(Om([e.Parameters]))}),e.Response=dm()}(Vw||(Vw={})),function(e){e.Parameters=Im({address:Yg(),chainId:Qg(),digest:Yg(),signature:Yg()}),e.Request=Im({method:Tm("wallet_verifySignature"),params:Km(Om([e.Parameters]))}),e.Response=Im({proof:Dm(Im({account:Wg(),initPreCall:Dm(hw),keyHash:Yg()})),valid:am()})}(Gw||(Gw={}));class Xw extends ml{constructor(e){super("An error occurred while executing calls.",{cause:e,metaMessages:[e.abiError&&"Reason: "+e.abiError.name].filter(Boolean)}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Rpc.ExecutionError"}),Object.defineProperty(this,"abiError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiError=e.abiError}}function ev(e){return t=>{const n=e.public(t),r=e.relay(t);return tl({key:ev.type,name:"Relay Proxy",request:async({method:e,params:t},s)=>function(e){return!!e.startsWith("wallet_")||(!!e.startsWith("account_")||"health"===e)}(e)?r.request({method:e,params:t},s):n.request({method:e,params:t},s),type:ev.type})}}!function(e){e.type="relayProxy"}(ev||(ev={}));const tv=new Map;const nv=Im({chainId:Rm(Qg()),expiry:Qg(),hash:Yg(),id:Yg(),prehash:Rm(am()),publicKey:Yg(),role:km([Tm("admin"),Tm("session")]),type:km([Tm("address"),Tm("p256"),Tm("secp256k1"),Tm("webauthn-p256")])}),rv=Km(vm(Xg([Im({signature:nm(),to:Wg()}),Im({signature:nm()}),Im({to:Wg()})])).check(Jh(1))),sv=Im({limit:km([Gm([sm(),".",sm()]),Gm([sm()])]).check(Xh(/^\d+(\.\d+)?$/)),symbol:Rm(km([Tm("native"),Iw]))}),iv=Im({addresses:Km(vm(Wg()))}),av=Km(vm(Im({limit:Jg(),period:km([Tm("minute"),Tm("hour"),Tm("day"),Tm("week"),Tm("month"),Tm("year")]),token:Rm(Wg())}))),ov=Im({calls:Rm(rv),signatureVerification:Rm(iv),spend:Rm(av)}),cv=Im({...nv.shape,feeToken:Rm(Bm(sv)),permissions:Rm(ov)}),uv=Im({address:Wg(),chainId:Rm(Qg()),expiry:sm(),id:Yg(),key:Pm(nv,{publicKey:!0,type:!0}),permissions:Im({calls:rv,signatureVerification:Rm(iv),spend:Rm(av)})}),dv=Im({address:Rm(Wg()),chainId:Rm(Qg()),expiry:sm().check((lv=1,new fh({check:"greater_than",...Dp(fv),value:lv,inclusive:!0}))),feeToken:Bm(sv),key:Rm(Pm(nv,{publicKey:!0,type:!0})),permissions:Im({calls:rv,signatureVerification:Rm(iv),spend:Rm(av)})});var lv,fv;const pv=uv;function hv(e,t){const{chainId:n,expiry:r,permissions:s,id:i,publicKey:a,type:o}=e,{address:c}=t;return{address:c,chainId:n,expiry:r,id:i,key:{publicKey:a,type:o},permissions:s??{}}}function mv(e){const{chainId:t,expiry:n,key:r}=e;return Mg({chainId:t,expiry:n,permissions:e.permissions??{},publicKey:r.publicKey,role:"session",type:r.type})}var yv,bv,gv,wv,vv,xv,Iv,Pv,zv,Ev;!function(e){e.GetCapabilitiesResponse=Im({status:km([Tm("supported"),Tm("unsupported")])})}(yv||(yv={})),function(e){e.Request=km([am(),Im({chainId:Rm(Qg()),label:Rm(nm())})])}(bv||(bv={})),function(e){e.Request=Xg([Im({chainId:Rm(sm()),domain:Rm(nm()),expirationTime:Rm(gm()),issuedAt:Rm(gm()),nonce:nm(),notBefore:Rm(gm()),requestId:Rm(nm()),resources:Rm(Km(vm(nm()))),scheme:Rm(nm()),statement:Rm(nm()),uri:Rm(nm()),version:Rm(Tm("1"))}),Im({authUrl:km([nm(),Im({logout:nm(),nonce:nm(),verify:nm()})]),chainId:Rm(Qg()),domain:Rm(nm()),expirationTime:Rm(gm()),issuedAt:Rm(gm()),notBefore:Rm(gm()),requestId:Rm(nm()),resources:Rm(Km(vm(nm()))),scheme:Rm(nm()),statement:Rm(nm()),uri:Rm(nm()),version:Rm(Tm("1"))})]),e.Response=Im({message:nm(),signature:Yg(),token:Rm(nm())})}(gv||(gv={})),function(e){e.GetCapabilitiesResponse=Im({supported:am(),tokens:Km(vm(xw))}),e.Request=km([Iw,Wg()])}(wv||(wv={})),function(e){e.Request=dv}(vv||(vv={})),function(e){e.GetCapabilitiesResponse=Im({supported:am()})}(xv||(xv={})),function(e){e.GetCapabilitiesResponse=Im({supported:am()}),e.Request=Im({id:Rm(km([Yg(),fm()]))}),e.Response=Km(vm(uv))}(Iv||(Iv={})),function(e){e.Request=Km(vm(Im({context:ym(),signature:Yg()}))),e.Response=e.Request}(Pv||(Pv={})),function(e){e.Request=nm()}(zv||(zv={})),function(e){e.GetCapabilitiesResponse=Im({supported:am(),tokens:Km(vm(xw))}),e.Request=Km(vm(Xg([Im({address:Wg(),value:Jg()}),Im({symbol:Iw,value:km([Gm([sm(),".",sm()]),Gm([sm()])]).check(Xh(/^\d+(\.\d+)?$/))})])))}(Ev||(Ev={}));const Av=Im({...Pm(nv,{id:!0,publicKey:!0,type:!0}).shape,credentialId:Rm(nm()),privateKey:Rm(hm())});var kv,Mv,$v,Ov,jv,Sv,Nv,Tv,_v,Rv,Cv,Bv,Dv,Uv,qv,Lv,Fv,Kv,Vv,Gv,Zv,Hv,Wv,Yv,Qv,Jv,Xv,ex,tx,nx,rx,sx,ix,ax,ox;!function(e){e.Parameters=Im({address:Wg(),secret:nm()}),e.Request=Im({method:Tm("account_getOnrampContactInfo"),params:Km(Om([e.Parameters]))}),e.Response=Im({email:Rm(nm()),phone:Rm(nm()),phoneVerifiedAt:Rm(sm())})}(kv||(kv={})),function(e){e.Parameters=Im({address:Wg()}),e.Request=Im({method:Tm("account_onrampStatus"),params:Km(Om([e.Parameters]))}),e.Response=Im({email:Rm(sm()),phone:Rm(sm())})}(Mv||(Mv={})),function(e){e.Parameters=Im({email:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_resendVerifyPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}($v||($v={})),function(e){e.Parameters=Im({email:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_setEmail"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Ov||(Ov={})),function(e){e.Parameters=Im({email:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_setPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(jv||(jv={})),function(e){e.Parameters=Im({chainId:Qg(),email:nm(),token:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_verifyEmail"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Sv||(Sv={})),function(e){e.Parameters=Im({code:nm(),phone:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_verifyPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Nv||(Nv={})),function(e){e.Parameters=Im({address:Rm(Wg()),chainId:Rm(Qg()),token:Rm(Wg()),value:Rm(nm())}),e.Request=Im({method:Tm("wallet_addFunds"),params:Km(Om([e.Parameters]))}),e.Response=Im({id:Yg()})}(Tv||(Tv={})),function(e){e.Request=Im({method:Tm("eth_accounts"),params:Rm(ym())}),e.Response=Km(vm(Wg()))}(_v||(_v={})),function(e){e.Request=Im({method:Tm("eth_chainId"),params:Rm(ym())}),e.Response=Yg()}(Rv||(Rv={})),function(e){e.Request=Im({method:Tm("eth_requestAccounts"),params:Rm(ym())}),e.Response=Km(vm(Wg()))}(Cv||(Cv={})),function(e){e.Request=Im({method:Tm("eth_sendTransaction"),params:Km(Om([Im({capabilities:Rm(Im({feeToken:Rm(wv.Request),merchantUrl:Rm(zv.Request),preCalls:Rm(Pv.Request)})),chainId:Rm(Qg()),data:Rm(Yg()),from:Rm(Wg()),to:Wg(),value:Rm(Jg())})]))}),e.Response=Yg()}(Bv||(Bv={})),function(e){e.Request=Im({method:Tm("eth_signTypedData_v4"),params:Km(Om([Wg(),nm()]))}),e.Response=Yg()}(Dv||(Dv={})),function(e){e.Parameters=Im({address:Rm(Wg()),chainId:Rm(Qg())}),e.Request=Im({method:Tm("wallet_getAdmins"),params:Rm(Km(Om([e.Parameters])))}),e.Key=Av,e.Response=Im({address:Wg(),chainId:Qg(),keys:Km(vm(e.Key))})}(Uv||(Uv={})),function(e){e.Capabilities=Im({feeToken:Rm(wv.Request)}),e.Parameters=Im({address:Rm(Wg()),capabilities:Rm(e.Capabilities),chainId:Rm(Qg()),key:Pm(nv,{publicKey:!0,type:!0})}),e.Request=Im({method:Tm("wallet_grantAdmin"),params:Km(Om([e.Parameters]))}),e.Response=Im({address:Wg(),chainId:Qg(),key:Uv.Key})}(qv||(qv={})),function(e){e.Parameters=dv,e.Request=Im({method:Tm("wallet_grantPermissions"),params:Km(Om([e.Parameters]))}),e.ResponseCapabilities=Im({preCalls:Rm(Pv.Response)}),e.Response=Im({...uv.shape,capabilities:Rm(hm())})}(Lv||(Lv={})),function(e){e.Parameters=Im({address:Rm(Wg())}),e.Request=Im({method:Tm("wallet_getAccountVersion"),params:Rm(Km(Om([e.Parameters])))}),e.Response=Im({current:nm(),latest:nm()})}(Fv||(Fv={})),function(e){e.Parameters=Im({address:Rm(Wg()),chainIds:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_getPermissions"),params:Rm(Km(Om([e.Parameters])))}),e.Response=Iv.Response}(Kv||(Kv={})),function(e){e.Capabilities=Im({feeToken:Rm(wv.Request)}),e.Parameters=Im({address:Rm(Wg()),capabilities:Rm(e.Capabilities),chainId:Rm(Qg()),id:Yg()}),e.Request=Im({method:Tm("wallet_revokeAdmin"),params:Km(Om([e.Parameters]))}),e.Response=void 0}(Vv||(Vv={})),function(e){e.Capabilities=Im({feeToken:Rm(wv.Request)}),e.Parameters=Im({address:Rm(Wg()),capabilities:Rm(e.Capabilities),id:Yg()}),e.Request=Im({method:Tm("wallet_revokePermissions"),params:Km(Om([e.Parameters]))}),e.Response=void 0}(Gv||(Gv={})),function(e){e.Request=Im({method:Tm("wallet_switchEthereumChain"),params:Km(Om([Im({chainId:Yg()})]))})}(Zv||(Zv={})),function(e){e.Parameters=Im({context:ym(),signatures:Im({auth:Yg(),exec:Yg()})}),e.Request=Im({method:Tm("wallet_upgradeAccount"),params:Km(Om([e.Parameters]))}),e.ResponseCapabilities=Im({admins:Rm(Km(vm(Uv.Key))),permissions:Rm(Iv.Response)}),e.Response=Im({address:Wg(),capabilities:Rm(e.ResponseCapabilities)})}(Hv||(Hv={})),function(e){e.Request=Im({method:Tm("personal_sign"),params:Km(Om([Yg(),Wg()]))}),e.Response=Yg()}(Wv||(Wv={})),function(e){e.Request=Im({method:Tm("porto_ping"),params:Rm(dm())}),e.Response=Tm("pong")}(Yv||(Yv={})),function(e){e.Capabilities=Im({createAccount:Rm(bv.Request),email:Rm(am()),grantAdmins:Rm(Km(vm(Pm(nv,{publicKey:!0,type:!0})))),grantPermissions:Rm(vv.Request),preCalls:Rm(Pv.Request),selectAccount:Rm(km([am(),Im({address:Wg(),key:Rm(Im({credentialId:Rm(nm()),publicKey:Yg()}))})])),signInWithEthereum:Rm(gv.Request)}),e.Parameters=Im({capabilities:Rm(e.Capabilities),chainIds:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_connect"),params:Rm(Km(Om([e.Parameters])))}),e.ResponseCapabilities=Im({admins:Rm(Km(vm(Im({...Pm(nv,{id:!0,publicKey:!0,type:!0}).shape,credentialId:Rm(nm())})))),permissions:Rm(Iv.Response),preCalls:Rm(Pv.Response),signInWithEthereum:Rm(gv.Response)}),e.Response=Im({accounts:Km(vm(Im({address:Wg(),capabilities:Rm(e.ResponseCapabilities)}))),chainIds:Km(vm(Qg()))})}(Qv||(Qv={})),function(e){e.Request=Im({method:Tm("wallet_disconnect"),params:Rm(ym())}),e.Response=void 0}(Jv||(Jv={})),function(e){e.Parameters=Bw.Parameters,e.Request=Bw.Request,e.Response=Bw.Response}(Xv||(Xv={})),function(e){e.Request=Im({method:Tm("wallet_getCallsStatus"),params:Om([Yg()])}),e.Response=Im({atomic:am(),chainId:Qg(),id:nm(),receipts:Rm(Km(vm(Im({blockHash:Yg(),blockNumber:Yg(),gasUsed:Yg(),logs:Km(vm(Im({address:Wg(),data:Yg(),topics:Km(vm(Yg()))}))),status:Yg(),transactionHash:Yg()})))),status:sm(),version:nm()})}(ex||(ex={})),function(e){e.Request=Im({method:Tm("wallet_getCapabilities"),params:Rm(km([Km(Om([km([Yg(),dm()])])),Km(Om([km([Yg(),dm()]),Km(vm(Qg()))]))]))}),e.Response=Sm(Yg(),Im({atomic:yv.GetCapabilitiesResponse,feeToken:wv.GetCapabilitiesResponse,merchant:xv.GetCapabilitiesResponse,permissions:Iv.GetCapabilitiesResponse,requiredFunds:Ev.GetCapabilitiesResponse}))}(tx||(tx={})),function(e){e.Parameters=Im({address:Wg(),chainIds:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_getKeys"),params:Km(Om([e.Parameters]))}),e.Response=Km(vm(cv))}(nx||(nx={})),function(e){e.Capabilities=Im({feeToken:Rm(wv.Request),merchantUrl:Rm(zv.Request),permissions:Rm(Iv.Request),preCalls:Rm(Pv.Request),requiredFunds:Rm(Ev.Request)}),e.Parameters=Im({calls:Km(vm(Im({data:Rm(Yg()),to:Wg(),value:Rm(Jg())}))),capabilities:Rm(e.Capabilities),chainId:Rm(Qg()),from:Rm(Wg()),key:Rm(Pm(nv,{prehash:!0,publicKey:!0,type:!0})),version:Rm(nm())}),e.Request=Im({method:Tm("wallet_prepareCalls"),params:Km(Om([e.Parameters]))}),e.Response=Im({capabilities:Rm(Im({...qw.ResponseCapabilities.shape,quote:Rm(vw)})),chainId:Yg(),context:Im({account:Im({address:Wg()}),calls:e.Parameters.shape.calls,nonce:Jg(),quote:Rm(Em(vw))}),digest:Yg(),key:Pm(nv,{prehash:!0,publicKey:!0,type:!0}),typedData:Im({domain:km([Im({chainId:Qg(),name:nm(),verifyingContract:Wg(),version:nm()}),Im({})]),message:Sm(nm(),ym()),primaryType:nm(),types:Sm(nm(),ym())})})}(rx||(rx={})),function(e){e.Capabilities=Im({...Qv.Capabilities.shape,label:Rm(nm())}),e.Parameters=Im({address:Wg(),capabilities:Rm(e.Capabilities),chainId:Rm(Qg())}),e.Request=Im({method:Tm("wallet_prepareUpgradeAccount"),params:Km(Om([e.Parameters]))}),e.Response=Im({context:ym(),digests:Im({auth:Yg(),exec:Yg()})})}(sx||(sx={})),function(e){e.Capabilities=rx.Capabilities,e.Request=Im({method:Tm("wallet_sendCalls"),params:Km(Om([zm(rx.Parameters,{key:!0})]))}),e.Response=Im({id:Yg()})}(ix||(ix={})),function(e){e.Parameters=Im({capabilities:rx.Response.shape.capabilities,chainId:Yg(),context:rx.Response.shape.context,key:rx.Response.shape.key,signature:Yg()}),e.Request=Im({method:Tm("wallet_sendPreparedCalls"),params:Km(Om([e.Parameters]))}),e.Response=Km(vm(Im({capabilities:Rm(Sm(nm(),ym())),id:Yg()})))}(ax||(ax={})),function(e){e.Parameters=Im({address:Wg(),chainId:Rm(Qg()),digest:Yg(),signature:Yg()}),e.Request=Im({method:Tm("wallet_verifySignature"),params:Km(Om([e.Parameters]))}),e.Response=Im({address:Wg(),chainId:Qg(),proof:Rm(ym()),valid:am()})}(ox||(ox={}));const cx=function(e,t,n){return new Mm({type:"union",options:t,discriminator:e,...Dp(n)})}("method",[Sv.Request,Tv.Request,_v.Request,Rv.Request,Cv.Request,Bv.Request,Dv.Request,Fv.Request,Uv.Request,Kv.Request,qv.Request,Lv.Request,sx.Request,Vv.Request,Gv.Request,Hv.Request,Wv.Request,Yv.Request,Qv.Request,Jv.Request,Xv.Request,ex.Request,tx.Request,nx.Request,rx.Request,ix.Request,ax.Request,Zv.Request,ox.Request]);function ux(e,t){const n=Jp(e,t);if(n.error){const e=n.error.issues.at(0);if("invalid_union"===e?.code&&"No matching discriminator"===e.note)throw new Pl;throw new Ml(tw(n.error))}return{...t,_decoded:n.data}}async function dx(e){e.persist.hasHydrated()||await new Promise((t=>{e.persist.onFinishHydration((()=>t(!0))),setTimeout((()=>t(!0)),100)}))}function lx(e){if(e)return e.startsWith("/")?`${window.location.origin}${e}`:e}function fx(t){const{config:n,getMode:r,id:s,store:i}=t,{announceProvider:a}=n;function o(e={}){const t=c(),a=e.request??ux(cx,{method:"wallet_getCapabilities",params:e.chainIds?[void 0,e.chainIds]:void 0});return Da((()=>r().actions.getCapabilities({chainIds:e.chainIds,internal:{client:t,config:n,request:a,store:i}})),{cacheKey:`getCapabilities.${s}.${e.chainIds?.join(",")}`})}function c(e){const n="string"==typeof e?Sf(e):e;return function(e,t={}){const{config:n,id:r,store:s}=e._internal,{chains:i,relay:a}=n,o=s.getState(),c=t.chainId??o.chainIds[0],u=i.find((e=>e.id===c));if(!u)throw new Error(["Could not find a compatible Porto chain on the given chain configuration.","",`Provided chains: [${i.map((e=>`${e.name} (id: ${e.id})`)).join(", ")}]`,`Needed chain (id): ${c}`,"Please add this chain (id) to your chain configuration."].join("\n"));const d=ev({public:n.transports[u.id]??nl(u.rpcUrls.default.http.map((e=>il(e)))),relay:a}),l=[r,hl(u)].filter(Boolean).join(":");if(tv.has(l))return tv.get(l);const f=Xa({...t,chain:u,pollingInterval:1e3,transport:d});return tv.set(l,f),f}({_internal:t},{chainId:n})}const u=new Map,d=[],l=function(){const t=new e;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}(),f=Vl({...l,async request(e){await dx(i);return ef((async()=>{let t;try{t=ux(cx,e)}catch(t){if(!(t instanceof Pl))throw t;if(e.method.startsWith("wallet_"))throw new Tl;return c().request(e)}const s=i.getState();switch(t.method){case"account_verifyEmail":{if(0===s.accounts.length)throw new _l;const[e]=t._decoded.params,{chainId:a,email:o,token:u,walletAddress:d}=e,l=c(a);if(a&&a!==l.chain.id)throw new Rl;const f=d?s.accounts.find((e=>gp(e.address,d))):s.accounts[0];if(!f)throw new Nl;return await r().actions.verifyEmail({account:f,chainId:a,email:o,internal:{client:l,config:n,request:t,store:i},token:u,walletAddress:d})}case"wallet_addFunds":{if(0===s.accounts.length)throw new _l;const{address:e,value:a,token:o}=t.params[0]??{},u=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!u)throw new Nl;const d=c(),f=await r().actions.addFunds({address:u.address,internal:{client:d,config:n,request:t,store:i},token:o,value:a});return l.emit("message",{data:null,type:"assetsChanged"}),f}case"eth_accounts":if(0===s.accounts.length)throw new _l;return s.accounts.map(yx);case"eth_chainId":return zf(s.chainIds[0]);case"eth_requestAccounts":{if(s.accounts.length>0&&u.get("eth_requestAccounts"))return s.accounts.map(yx);const e=c(),{accounts:a}=await r().actions.loadAccounts({internal:{client:e,config:n,request:t,store:i}});return i.setState((e=>({...e,accounts:a}))),l.emit("connect",{chainId:zf(e.chain.id)}),u.set("eth_requestAccounts",!0),setTimeout((()=>u.delete("eth_requestAccounts")),1e3),a.map(yx)}case"eth_sendTransaction":{if(0===s.accounts.length)throw new _l;const[{capabilities:e,chainId:a,data:o="0x",from:u,to:d,value:l}]=t._decoded.params,f=c(a);if(a&&a!==f.chain.id)throw new Rl;const p=u?s.accounts.find((e=>gp(e.address,u))):s.accounts[0];if(!p)throw new Nl;const{id:h}=await r().actions.sendCalls({account:p,asTxHash:!0,calls:[{data:o,to:d,value:l}],internal:{client:f,config:n,request:t,store:i},merchantUrl:lx(n.merchantUrl??e?.merchantUrl)});return h}case"eth_signTypedData_v4":{if(0===s.accounts.length)throw new _l;const[e,a]=t._decoded.params,o=s.accounts.find((t=>gp(t.address,e)));if(!o)throw new Nl;const u=c();return await r().actions.signTypedData({account:o,data:a,internal:{client:u,config:n,request:t,store:i}})}case"wallet_grantAdmin":{if(0===s.accounts.length)throw new _l;const[{address:e,capabilities:a,chainId:o,key:u}]=t._decoded.params??[{}],d=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!d)throw new Nl;const f=c(o),p=hx([...d.keys??[]])?.some((e=>e.publicKey?.toLowerCase()===u.publicKey.toLowerCase()));if(p)throw new Ml({message:"Key already granted as admin."});const{key:h}=await r().actions.grantAdmin({account:d,feeToken:a?.feeToken,internal:{client:f,config:n,request:t,store:i},key:u});i.setState((e=>{const t=e.accounts.findIndex((e=>!d||gp(e.address,d.address)));return-1===t?e:{...e,accounts:e.accounts.map(((e,n)=>n===t?{...e,keys:[...e.keys??[],h]}:e))}}));const m=hx([...d.keys??[],h]);return l.emit("message",{data:null,type:"adminsChanged"}),nh(qv.Response,{address:d.address,chainId:f.chain.id,key:m.at(-1)})}case"wallet_grantPermissions":{if(0===s.accounts.length)throw new _l;const[{address:e,chainId:a,...o}]=t._decoded.params??[{}],u=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!u)throw new Nl;const d=c(a),{key:f}=await r().actions.grantPermissions({account:u,internal:{client:d,config:n,request:t,store:i},permissions:o});return i.setState((e=>{const t=e.accounts.findIndex((e=>!u||gp(e.address,u.address)));return-1===t?e:{...e,accounts:e.accounts.map(((e,n)=>n===t?{...e,keys:[...e.keys??[],f]}:e))}})),l.emit("message",{data:null,type:"permissionsChanged"}),nh(Lv.Response,{...hv(f,{address:u.address})})}case"wallet_getAdmins":{if(0===s.accounts.length)throw new _l;const[{address:e,chainId:a}]=t._decoded.params??[{}],o=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!o)throw new Nl;const u=c(a),d=hx(await r().actions.getKeys({account:o,internal:{client:u,config:n,request:t,store:i}}));return nh(Uv.Response,{address:o.address,chainId:u.chain.id,keys:d})}case"wallet_prepareUpgradeAccount":{const[{address:e,capabilities:s,chainId:a}]=t._decoded.params??[{}],{email:o,label:u,grantPermissions:l}=s??{},f=c(a),{context:p,digests:h}=await r().actions.prepareUpgradeAccount({address:e,email:o,internal:{client:f,config:n,request:t,store:i},label:u,permissions:l});return d.push(p.account),{context:p,digests:h}}case"wallet_getAccountVersion":{if(0===s.accounts.length)throw new _l;const[{address:e}]=t._decoded.params??[{}],a=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!a)throw new Nl;const o=c(),{current:u,latest:d}=await r().actions.getAccountVersion({address:a.address,internal:{client:o,config:n,request:t,store:i}});return{current:u,latest:d}}case"wallet_getKeys":{if(0===s.accounts.length)throw new _l;const[{address:e,chainIds:a}]=t._decoded.params??[{}],o=s.accounts.find((t=>gp(t.address,e)));if(!o)throw new Nl;const u=c(),d=await r().actions.getKeys({account:o,chainIds:a,internal:{client:u,config:n,request:t,store:i}});return nh(nx.Response,d)}case"wallet_getPermissions":{if(0===s.accounts.length)throw new _l;const[{address:e,chainIds:a}]=t._decoded.params??[{}],o=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!o)throw new Nl;const u=c();return mx(await r().actions.getKeys({account:o,chainIds:a,internal:{client:u,config:n,request:t,store:i}}),{address:o.address})}case"wallet_revokeAdmin":{if(0===s.accounts.length)throw new _l;const[{address:e,capabilities:a,id:o}]=t._decoded.params,u=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!u)throw new Nl;const d=c();await r().actions.revokeAdmin({account:u,feeToken:a?.feeToken,id:o,internal:{client:d,config:n,request:t,store:i}});const f=u.keys?.filter((e=>e.id.toLowerCase()!==o.toLowerCase()));return i.setState((e=>({...e,accounts:e.accounts.map((e=>gp(e.address,u.address)?{...e,keys:f}:e))}))),void l.emit("message",{data:null,type:"adminsChanged"})}case"wallet_revokePermissions":{if(0===s.accounts.length)throw new _l;const[{address:e,capabilities:a,id:o}]=t._decoded.params,u=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!u)throw new Nl;const d=c();await r().actions.revokePermissions({account:u,feeToken:a?.feeToken,id:o,internal:{client:d,config:n,request:t,store:i}});const f=u.keys?.filter((e=>e.id.toLowerCase()!==o.toLowerCase()));return i.setState((e=>({...e,accounts:e.accounts.map((e=>gp(e.address,u.address)?{...e,keys:f}:e))}))),void l.emit("message",{data:null,type:"permissionsChanged"})}case"wallet_upgradeAccount":{const[{context:e,signatures:s}]=t._decoded.params??[{}],a=c(),o=d.find((t=>gp(t.address,e.account.address)));if(!o)throw new Nl;const{account:u}=await r().actions.upgradeAccount({account:o,context:e,internal:{client:a,config:n,request:t,store:i},signatures:s}),f=hx(u.keys??[]),p=mx(u.keys??[],{address:u.address});return i.setState((e=>({...e,accounts:[u]}))),l.emit("connect",{chainId:zf(a.chain.id)}),{address:u.address,capabilities:{admins:f,...p.length>0?{permissions:p}:{}}}}case"porto_ping":return"pong";case"personal_sign":{if(0===s.accounts.length)throw new _l;const[e,a]=t._decoded.params,o=s.accounts.find((e=>gp(e.address,a)));if(!o)throw new Nl;const u=c();return await r().actions.signPersonalMessage({account:o,data:e,internal:{client:u,config:n,request:t,store:i}})}case"wallet_connect":{const[{capabilities:e,chainIds:a}]=t._decoded.params??[{}],o=c(a?.[0]),u=o.chain.id,{createAccount:d,email:f,grantAdmins:p,grantPermissions:h,selectAccount:m,signInWithEthereum:y}=e??{},b={client:o,config:n,request:t,store:i},{accounts:g}=await(async()=>{if(f||d){const{label:e}="object"==typeof d?d:{},{account:t}=await r().actions.createAccount({admins:p,email:f,internal:b,label:e,permissions:h,signInWithEthereum:y});return{accounts:[t]}}const e=s.accounts[0],{address:t,key:n}=(()=>{if(m)return"object"==typeof m?m:{address:void 0,key:void 0};for(const t of e?.keys??[])if("webauthn-p256"===t.type&&"admin"===t.role)return{address:e?.address,key:{credentialId:t.credentialId??t.privateKey?.credential?.id,publicKey:t.publicKey}};return{address:void 0,key:void 0}})(),i={internal:b,permissions:h,signInWithEthereum:y};try{return await r().actions.loadAccounts({address:t,key:n,...i})}catch(e){if(e instanceof Sl)throw e;if(t&&n)return await r().actions.loadAccounts(i);throw e}})();i.setState((e=>({...e,accounts:g})));const w=[u,...i.getState().chainIds.filter((e=>e!==u))];return l.emit("connect",{chainId:zf(w[0])}),{accounts:g.map((e=>({address:yx(e),capabilities:{admins:e.keys?hx(e.keys):[],permissions:e.keys?mx(e.keys,{address:e.address}):[],...e.signInWithEthereum&&{signInWithEthereum:e.signInWithEthereum}}}))),chainIds:w.map((e=>zf(e)))}}case"wallet_disconnect":{const e=c();return await(r().actions.disconnect?.({internal:{client:e,config:n,request:t,store:i}})),i.setState((e=>({...e,accounts:[]}))),void l.emit("disconnect",new _l)}case"wallet_getAssets":{const[e]=t._decoded.params??[],{account:s,chainFilter:a,assetFilter:o,assetTypeFilter:u}=e,d=c(),l=await r().actions.getAssets({account:s,assetFilter:o,assetTypeFilter:u,chainFilter:a,internal:{client:d,config:n,request:t,store:i}}),f=Object.entries(l).reduce(((e,[t,n])=>(e[zf(Number(t))]=n,e)),{});return nh(Xv.Response,f)}case"wallet_getCallsStatus":{const[e]=t._decoded.params??[],s=c();return await r().actions.getCallsStatus({id:e,internal:{client:s,config:n,request:t,store:i}})}case"wallet_getCapabilities":{const[e,n]=t.params??[];return await o({chainIds:n,request:t})}case"wallet_prepareCalls":{const[e]=t._decoded.params,{calls:a,capabilities:o,chainId:u,key:d,from:l}=e,f=c(u),p=l??s.accounts[0];if(!p)throw new Nl;if(u&&u!==f.chain.id)throw new Rl;const{digest:h,...m}=await r().actions.prepareCalls({account:Cg(p),calls:a,feeToken:o?.feeToken,internal:{client:f,config:n,request:t,store:i},key:d,merchantUrl:lx(n.merchantUrl??o?.merchantUrl),requiredFunds:o?.requiredFunds});return nh(rx.Response,{capabilities:m.capabilities,chainId:zf(m.chainId??f.chain.id),context:{...m.context,account:{address:m.account.address},calls:m.context.calls??[],nonce:m.context.nonce??0n},digest:h,key:m.key,typedData:m.typedData})}case"wallet_sendPreparedCalls":{const[e]=t._decoded.params,{chainId:s,context:a,key:o,signature:u}=e,{account:d}=e.context,l=c(s);if(s&&Sf(s)!==l.chain.id)throw new Rl;return[{id:await r().actions.sendPreparedCalls({account:Cg(d),context:a,internal:{client:l,config:n,request:t,store:i},key:o,signature:u})}]}case"wallet_sendCalls":{if(0===s.accounts.length)throw new _l;const[e]=t._decoded.params,{calls:a,capabilities:o,chainId:u,from:d}=e,l=c(u);if(u&&u!==l.chain.id)throw new Rl;const f=d?s.accounts.find((e=>gp(e.address,d))):s.accounts[0];if(!f)throw new Nl;const{id:p}=await r().actions.sendCalls({account:f,calls:a,feeToken:o?.feeToken,internal:{client:l,config:n,request:t,store:i},merchantUrl:lx(n.merchantUrl??o?.merchantUrl),permissionsId:o?.permissions?.id,requiredFunds:o?.requiredFunds});return{id:p}}case"wallet_switchEthereumChain":{const[e]=t._decoded.params,{chainId:s}=e,a=Sf(s);if(!n.chains.find((e=>e.id===a)))throw new Dl;const o=c(s);return await(r().actions.switchChain?.({chainId:o.chain.id,internal:{client:o,config:n,request:t,store:i}})),void i.setState((e=>({...e,chainIds:[a,...e.chainIds.filter((e=>e!==a))]})))}case"wallet_verifySignature":{const[e]=t._decoded.params,{address:n,chainId:r,digest:s,signature:i}=e,a=c(r),o=await async function(e,t){const{address:n,chain:r=e.chain,digest:s,signature:i}=t;try{async function a(){return{proof:null,valid:await Xd(e,{address:n,hash:s,signature:i})}}const o="wallet_verifySignature",c=await(async()=>{const t=await e.request({method:o,params:[nh(Gw.Parameters,{address:n,chainId:r?.id,digest:s,signature:i})]},{retryCount:0}).catch(a);return t.valid?t:a()})();return sh(Gw.Response,c)}catch(u){throw Jw(u),u}}(a,{address:n,digest:s,signature:i});return{...o,address:n,chainId:zf(a.chain.id)}}}}),{enabled:["eth_accounts","eth_chainId","eth_requestAccounts","wallet_getAssets","wallet_getCapabilities","wallet_getKeys","wallet_getPermissions","wallet_getAccountVersion","wallet_connect"].includes(e.method),id:hl(e)})}});const p=function(){let e=()=>{},t=()=>{};dx(i).then((()=>{o().catch((()=>{})),e(),e=i.subscribe((e=>e.accounts),(e=>{l.emit("accountsChanged",e.map(yx))}),{equalityFn:(e,t)=>e.every(((e,n)=>e.address===t[n]?.address))}),t(),t=i.subscribe((e=>e.chainIds[0]),((e,t)=>{e!==t&&l.emit("chainChanged",zf(e))}))}));const n=px(f,a);return()=>{e(),t(),n()}}();return Object.assign(f,{_internal:{destroy:p}})}function px(e,t){if(!t)return()=>{};if("undefined"==typeof window||!window.dispatchEvent)return()=>{};const{icon:n="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDIyIiBoZWlnaHQ9IjQyMiIgdmlld0JveD0iMCAwIDQyMiA0MjIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSI0MjIiIGhlaWdodD0iNDIyIiBmaWxsPSJibGFjayIvPgo8ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfMV8xNSkiPgo8cGF0aCBkPSJNODEgMjg2LjM2NkM4MSAyODAuODkzIDg1LjQ1MDUgMjc2LjQ1NSA5MC45NDA0IDI3Ni40NTVIMzI5LjUxMUMzMzUuMDAxIDI3Ni40NTUgMzM5LjQ1MiAyODAuODkzIDMzOS40NTIgMjg2LjM2NlYzMDYuMTg4QzMzOS40NTIgMzExLjY2MiAzMzUuMDAxIDMxNi4wOTkgMzI5LjUxMSAzMTYuMDk5SDkwLjk0MDRDODUuNDUwNSAzMTYuMDk5IDgxIDMxMS42NjIgODEgMzA2LjE4OFYyODYuMzY2WiIgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC41Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuOTQwNCAyMzQuODI4Qzg1LjQ1MDUgMjM0LjgyOCA4MSAyMzkuMjY2IDgxIDI0NC43MzlWMjcxLjUzMUM4My44NDMyIDI2OS42MzMgODcuMjYyMiAyNjguNTI2IDkwLjk0MDQgMjY4LjUyNkgzMjkuNTExQzMzMy4xODggMjY4LjUyNiAzMzYuNjA4IDI2OS42MzMgMzM5LjQ1MiAyNzEuNTMxVjI0NC43MzlDMzM5LjQ1MiAyMzkuMjY2IDMzNS4wMDEgMjM0LjgyOCAzMjkuNTExIDIzNC44MjhIOTAuOTQwNFpNMzM5LjQ1MiAyODYuMzY2QzMzOS40NTIgMjgwLjg5MyAzMzUuMDAxIDI3Ni40NTUgMzI5LjUxMSAyNzYuNDU1SDkwLjk0MDRDODUuNDUwNSAyNzYuNDU1IDgxIDI4MC44OTMgODEgMjg2LjM2NlYzMDYuMTlDODEgMzExLjY2NCA4NS40NTA1IDMxNi4xMDEgOTAuOTQwNCAzMTYuMTAxSDMyOS41MTFDMzM1LjAwMSAzMTYuMTAxIDMzOS40NTIgMzExLjY2NCAzMzkuNDUyIDMwNi4xOVYyODYuMzY2WiIgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC41Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuOTQwNCAxOTMuMjAxQzg1LjQ1MDUgMTkzLjIwMSA4MSAxOTcuNjM4IDgxIDIwMy4xMTJWMjI5LjkwM0M4My44NDMyIDIyOC4wMDYgODcuMjYyMiAyMjYuODk5IDkwLjk0MDQgMjI2Ljg5OUgzMjkuNTExQzMzMy4xODggMjI2Ljg5OSAzMzYuNjA4IDIyOC4wMDYgMzM5LjQ1MiAyMjkuOTAzVjIwMy4xMTJDMzM5LjQ1MiAxOTcuNjM4IDMzNS4wMDEgMTkzLjIwMSAzMjkuNTExIDE5My4yMDFIOTAuOTQwNFpNMzM5LjQ1MiAyNDQuNzM5QzMzOS40NTIgMjM5LjI2NSAzMzUuMDAxIDIzNC44MjggMzI5LjUxMSAyMzQuODI4SDkwLjk0MDRDODUuNDUwNSAyMzQuODI4IDgxIDIzOS4yNjUgODEgMjQ0LjczOVYyNzEuNTNDODEuMjE3NSAyNzEuMzg1IDgxLjQzODMgMjcxLjI0NSA4MS42NjI0IDI3MS4xMDlDODMuODMyNSAyNjkuNzk0IDg2LjMwNTQgMjY4LjkyNyA4OC45NTIzIDI2OC42MzVDODkuNjA1MSAyNjguNTYzIDkwLjI2ODQgMjY4LjUyNiA5MC45NDA0IDI2OC41MjZIMzI5LjUxMUMzMzAuMTgzIDI2OC41MjYgMzMwLjg0NiAyNjguNTYzIDMzMS40OTggMjY4LjYzNUMzMzQuNDE5IDI2OC45NTcgMzM3LjEyOCAyNjkuOTggMzM5LjQ1MiAyNzEuNTNWMjQ0LjczOVpNMzM5LjQ1MiAyODYuMzY2QzMzOS40NTIgMjgxLjAyMSAzMzUuMjA2IDI3Ni42NjMgMzI5Ljg5MyAyNzYuNDYyQzMyOS43NjcgMjc2LjQ1NyAzMjkuNjQgMjc2LjQ1NSAzMjkuNTExIDI3Ni40NTVIOTAuOTQwNEM4NS40NTA1IDI3Ni40NTUgODEgMjgwLjg5MyA4MSAyODYuMzY2VjMwNi4xODhDODEgMzExLjY2MiA4NS40NTA1IDMxNi4xMDEgOTAuOTQwNCAzMTYuMTAxSDMyOS41MTFDMzM1LjAwMSAzMTYuMTAxIDMzOS40NTIgMzExLjY2MiAzMzkuNDUyIDMwNi4xODhWMjg2LjM2NloiIGZpbGw9IndoaXRlIiBmaWxsLW9wYWNpdHk9IjAuNSIvPgo8cGF0aCBvcGFjaXR5PSIwLjMiIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTguMDE0NiAxMDRDODguNjE3NyAxMDQgODEgMTExLjU5NSA4MSAxMjAuOTY1VjE4OC4yNzZDODMuODQzMiAxODYuMzc5IDg3LjI2MjIgMTg1LjI3MiA5MC45NDA0IDE4NS4yNzJIMzI5LjUxMUMzMzMuMTg4IDE4NS4yNzIgMzM2LjYwOCAxODYuMzc5IDMzOS40NTIgMTg4LjI3NlYxMjAuOTY1QzMzOS40NTIgMTExLjU5NSAzMzEuODMzIDEwNCAzMjIuNDM3IDEwNEg5OC4wMTQ2Wk0zMzkuNDUyIDIwMy4xMTJDMzM5LjQ1MiAxOTcuNjM4IDMzNS4wMDEgMTkzLjIwMSAzMjkuNTExIDE5My4yMDFIOTAuOTQwNEM4NS40NTA1IDE5My4yMDEgODEgMTk3LjYzOCA4MSAyMDMuMTEyVjIyOS45MDNDODEuMjE3NSAyMjkuNzU4IDgxLjQzODMgMjI5LjYxOCA4MS42NjI0IDIyOS40ODJDODMuODMyNSAyMjguMTY3IDg2LjMwNTQgMjI3LjMgODguOTUyMyAyMjcuMDA4Qzg5LjYwNTEgMjI2LjkzNiA5MC4yNjg0IDIyNi44OTkgOTAuOTQwNCAyMjYuODk5SDMyOS41MTFDMzMwLjE4MyAyMjYuODk5IDMzMC44NDYgMjI2LjkzNiAzMzEuNDk4IDIyNy4wMDhDMzM0LjQxOSAyMjcuMzMgMzM3LjEyOCAyMjguMzUyIDMzOS40NTIgMjI5LjkwM1YyMDMuMTEyWk0zMzkuNDUyIDI0NC43MzlDMzM5LjQ1MiAyMzkuMzkzIDMzNS4yMDYgMjM1LjAzNiAzMjkuODkzIDIzNC44MzVDMzI5Ljc2NyAyMzQuODMgMzI5LjY0IDIzNC44MjggMzI5LjUxMSAyMzQuODI4SDkwLjk0MDRDODUuNDUwNSAyMzQuODI4IDgxIDIzOS4yNjUgODEgMjQ0LjczOVYyNzEuNTNMODEuMDcwNyAyNzEuNDgzQzgxLjI2NTMgMjcxLjM1NSA4MS40NjI1IDI3MS4yMyA4MS42NjI0IDI3MS4xMDlDODEuOTA4MyAyNzAuOTYgODIuMTU4MSAyNzAuODE3IDgyLjQxMTcgMjcwLjY3OUM4NC4zOTUzIDI2OS42MDUgODYuNjA1NCAyNjguODk0IDg4Ljk1MjMgMjY4LjYzNUM4OS4wMDUyIDI2OC42MjkgODkuMDU4IDI2OC42MjQgODkuMTExIDI2OC42MThDODkuNzEyNSAyNjguNTU3IDkwLjMyMjggMjY4LjUyNiA5MC45NDA0IDI2OC41MjZIMzI5LjUxMUMzMjkuNzM4IDI2OC41MjYgMzI5Ljk2NSAyNjguNTMgMzMwLjE5MiAyNjguNTM5QzMzMC42MzEgMjY4LjU1NSAzMzEuMDY3IDI2OC41ODcgMzMxLjQ5OCAyNjguNjM1QzMzNC40MTkgMjY4Ljk1NyAzMzcuMTI4IDI2OS45OCAzMzkuNDUyIDI3MS41M1YyNDQuNzM5Wk0zMzkuNDUyIDI4Ni4zNjZDMzM5LjQ1MiAyODEuMDIxIDMzNS4yMDYgMjc2LjY2MyAzMjkuODkzIDI3Ni40NjJMMzI5Ljg2NSAyNzYuNDYxQzMyOS43NDggMjc2LjQ1NyAzMjkuNjI5IDI3Ni40NTUgMzI5LjUxMSAyNzYuNDU1SDkwLjk0MDRDODUuNDUwNSAyNzYuNDU1IDgxIDI4MC44OTMgODEgMjg2LjM2NlYzMDYuMTg4QzgxIDMxMS42NjIgODUuNDUwNSAzMTYuMTAxIDkwLjk0MDQgMzE2LjEwMUgzMjkuNTExQzMzNS4wMDEgMzE2LjEwMSAzMzkuNDUyIDMxMS42NjIgMzM5LjQ1MiAzMDYuMTg4VjI4Ni4zNjZaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNMjY5Ljg2OCAxMzEuNzUyQzI2OS44NjggMTI2LjI3OCAyNzQuMzE4IDEyMS44NCAyNzkuODA4IDEyMS44NEgzMTEuNjE4QzMxNy4xMDggMTIxLjg0IDMyMS41NTggMTI2LjI3OCAzMjEuNTU4IDEzMS43NTJWMTYxLjQ4NUMzMjEuNTU4IDE2Ni45NTkgMzE3LjEwOCAxNzEuMzk2IDMxMS42MTggMTcxLjM5NkgyNzkuODA4QzI3NC4zMTggMTcxLjM5NiAyNjkuODY4IDE2Ni45NTkgMjY5Ljg2OCAxNjEuNDg1VjEzMS43NTJaIiBmaWxsPSJ3aGl0ZSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzFfMTUiPgo8cmVjdCB3aWR0aD0iMjU5IiBoZWlnaHQ9IjIxMyIgZmlsbD0id2hpdGUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDgxIDEwNCkiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",name:r="Rise Wallet",rdns:s="com.risechain.wallet"}="object"==typeof t?t:{};return function(e){const t=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(e)});window.dispatchEvent(t);const n=()=>window.dispatchEvent(t);return window.addEventListener("eip6963:requestProvider",n),()=>window.removeEventListener("eip6963:requestProvider",n)}({info:{icon:n,name:r,rdns:s,uuid:Xl()},provider:e})}function hx(e){return e.map((e=>{if("admin"===e.role)try{return nh(Uv.Key,{id:e.id??e.publicKey,publicKey:e.publicKey,type:e.type,..."webauthn-p256"===e.type?{credentialId:e.privateKey?.credential?.id,privateKey:{credential:{id:e.privateKey?.credential?.id},rpId:e.privateKey?.rpId}}:{}})}catch{return}})).filter(Boolean)}function mx(e,{address:t}){return e.map((e=>{if(e.chainId&&"session"===e.role&&!(e.expiry>0&&e.expiry<BigInt(Math.floor(Date.now()/1e3))))try{return nh(pv,hv(e,{address:t}))}catch{return}})).filter(Boolean)}function yx(e){return Ht(e.address)}function bx(e){return{...e,setup:e.setup??(()=>()=>{})}}async function gx(e){const{account:t,calls:n,permissionsId:r}=e;if(void 0!==r){if(null===r)return;const e=t.keys?.find((e=>e.publicKey===r&&e.privateKey));if(!e)throw new Error(`permission (id: ${r}) does not exist.`);return e}const s=t.keys?.find((e=>{if(!e.privateKey)return!1;if("session"!==e.role)return!1;if(e.expiry<BigInt(Math.floor(Date.now()/1e3)))return!1;const t=n.every((t=>e.permissions?.calls?.some((e=>{if(e.to&&e.to!==t.to)return!1;if(e.signature){if(!t.data)return!1;const n=Mf(t.data,0,4);if(Nf(e.signature))return e.signature===n;if(Db(e.signature)!==n)return!1}return!0}))));return!!t})),i=t.keys?.find((e=>"admin"===e.role&&e.privateKey));return s??i}const wx=dv;function vx(e){const{expiry:t,feeToken:n,permissions:r,publicKey:s,type:i}=e;return{expiry:t,feeToken:n??null,key:{publicKey:s,type:i},permissions:r??{}}}async function xx(e,t={}){if(!e)return;const n={chainId:t.chainId??e.chainId,expiry:e.expiry??0,feeToken:e.feeToken,permissions:Tg(e,{feeTokens:t.feeTokens}),role:"session"};if(e?.key)return Mg({...n,publicKey:e.key.publicKey,type:e.key.type??"secp256k1"});if("function"==typeof globalThis.crypto?.subtle?.generateKey)try{return await kg(n)}catch(e){if(!function(e){if(!(e instanceof Error))return!1;const t=e.message?.toLowerCase()??"";return"TypeError"===e.name||"ReferenceError"===e.name||t.includes("subtle")||t.includes("generatekey")}(e))throw e}return zg(n)}const Ix=/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/,Px=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/,zx=/^localhost(:[0-9]{1,5})?$/,Ex=/^[a-zA-Z0-9]{8,}$/,Ax=/^([a-zA-Z][a-zA-Z0-9+-.]*)$/,kx=/^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/,Mx=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function $x(e){if(/[^a-z0-9:/?#[\]@!$&'()*+,;=.\-_~%]/i.test(e))return!1;if(/%[^0-9a-f]/i.test(e))return!1;if(/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))return!1;const t=function(e){return e.match(/(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}(e),n=t[1],r=t[2],s=t[3],i=t[4],a=t[5];if(!(n?.length&&s&&s.length>=0))return!1;if(r?.length){if(0!==s.length&&!/^\//.test(s))return!1}else if(/^\/\//.test(s))return!1;if(!/^[a-z][a-z0-9+\-.]*$/.test(n.toLowerCase()))return!1;let o="";return o+=`${n}:`,r?.length&&(o+=`//${r}`),o+=s,i?.length&&(o+=`?${i}`),a?.length&&(o+=`#${a}`),o}class Ox extends ml{constructor(e){const{field:t,metaMessages:n}=e;super(`Invalid Sign-In with Ethereum message field "${t}".`,{metaMessages:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Siwe.InvalidMessageFieldError"})}}async function jx(e){const{address:t,authUrl:n,message:r,signature:s}=e,{chainId:i}=function(e){const{scheme:t,statement:n,...r}=e.match(kx)?.groups??{},{chainId:s,expirationTime:i,issuedAt:a,notBefore:o,requestId:c,...u}=e.match(Mx)?.groups??{},d=e.split("Resources:")[1]?.split("\n- ").slice(1);return{...r,...u,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...a?{issuedAt:new Date(a)}:{},...o?{notBefore:new Date(o)}:{},...c?{requestId:c}:{},...d?{resources:d}:{},...t?{scheme:t}:{},...n?{statement:n}:{}}}(r);return await fetch(n.verify,{body:JSON.stringify({address:t,chainId:i,message:r,signature:s,walletAddress:t}),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST"}).then((e=>e.json()))}async function Sx(e,t,n){const{chainId:r=e.chain?.id,domain:s,uri:i,resources:a,version:o="1"}=t,{address:c}=n,u=t.authUrl?Nx(t.authUrl):void 0;if(!r)throw new Error("`chainId` is required.");if(!s)throw new Error("`domain` is required.");if(!t.nonce&&!u?.nonce)throw new Error("`nonce` or `authUrl.nonce` is required.");if(!i)throw new Error("`uri` is required.");const d=await(async()=>{if(t.nonce)return t.nonce;if(!u?.nonce)throw new Error("`nonce` or `authUrl.nonce` is required.");const e=await fetch(u.nonce,{body:JSON.stringify({address:c,chainId:r,walletAddress:c}),headers:{"Content-Type":"application/json"},method:"POST"}),n=await e.json().catch((()=>{}));if(!n?.nonce)throw new Error("`nonce` or `authUrl.nonce` is required.");return n.nonce})(),l=function(e){const{chainId:t,domain:n,expirationTime:r,issuedAt:s=new Date,nonce:i,notBefore:a,requestId:o,resources:c,scheme:u,uri:d,version:l}=e;{if(t!==Math.floor(t))throw new Ox({field:"chainId",metaMessages:["- Chain ID must be a EIP-155 chain ID.","- See https://eips.ethereum.org/EIPS/eip-155","",`Provided value: ${t}`]});if(!(Ix.test(n)||Px.test(n)||zx.test(n)))throw new Ox({field:"domain",metaMessages:["- Domain must be an RFC 3986 authority.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${n}`]});if(!Ex.test(i))throw new Ox({field:"nonce",metaMessages:["- Nonce must be at least 8 characters.","- Nonce must be alphanumeric.","",`Provided value: ${i}`]});if(!$x(d))throw new Ox({field:"uri",metaMessages:["- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${d}`]});if("1"!==l)throw new Ox({field:"version",metaMessages:["- Version must be '1'.","",`Provided value: ${l}`]});if(u&&!Ax.test(u))throw new Ox({field:"scheme",metaMessages:["- Scheme must be an RFC 3986 URI scheme.","- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1","",`Provided value: ${u}`]});const r=e.statement;if(r?.includes("\n"))throw new Ox({field:"statement",metaMessages:["- Statement must not include '\\n'.","",`Provided value: ${r}`]})}const f=yp(e.address,{checksum:!0}),p=`${u?`${u}://${n}`:n} wants you to sign in with your Ethereum account:\n${f}\n\n${e.statement?`${e.statement}\n`:""}`;let h=`URI: ${d}\nVersion: ${l}\nChain ID: ${t}\nNonce: ${i}\nIssued At: ${s.toISOString()}`;if(r&&(h+=`\nExpiration Time: ${r.toISOString()}`),a&&(h+=`\nNot Before: ${a.toISOString()}`),o&&(h+=`\nRequest ID: ${o}`),c){let e="\nResources:";for(const t of c){if(!$x(t))throw new Ox({field:"resources",metaMessages:["- Every resource must be a RFC 3986 URI.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${t}`]});e+=`\n- ${t}`}h+=e}return`${p}\n${h}`}({...t,address:n.address,chainId:r,domain:s,nonce:d,resources:a,uri:i,version:o});return l}function Nx(e,t=""){if(!e)return;const n=(()=>{if("string"==typeof e){const t=e.replace(/\/$/,"");return{logout:t+"/logout",nonce:t+"/nonce",verify:t+"/verify"}}return e})();return{logout:Tx(n.logout,t),nonce:Tx(n.nonce,t),verify:Tx(n.verify,t)}}function Tx(e,t){return t&&e.startsWith("/")?t+e:e}function _x(e){return np(function(e){const t=xf(e);return vf("0x19",Ef("Ethereum Signed Message:\n"+$f(t)),t)}(e))}function Rx(e,t){const{as:n}=t,r=Cx(e),s=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(ub);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(new Uint8Array(r.length));return r.encode(s),"Hex"===n?Pf(s.bytes):s.bytes}function Cx(e){return Array.isArray(e)?function(e){const t=e.reduce(((e,t)=>e+t.length),0),n=Bx(t);return{length:t<=55?1+t:1+n+t,encode(r){t<=55?r.pushByte(192+t):(r.pushByte(247+n),1===n?r.pushUint8(t):2===n?r.pushUint16(t):3===n?r.pushUint24(t):r.pushUint32(t));for(const{encode:t}of e)t(r)}}}(e.map((e=>Cx(e)))):function(e){const t="string"==typeof e?Ff(e):e,n=Bx(t.length),r=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length;return{length:r,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+n),1===n?e.pushUint8(t.length):2===n?e.pushUint16(t.length):3===n?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function Bx(e){if(e<=255)return 1;if(e<=65535)return 2;if(e<=16777215)return 3;if(e<=4294967295)return 4;throw new ml("Length is too large.")}function Dx(e){return function(e,t={}){const{presign:n}=t;return np(vf("0x05",function(e,t={}){const{as:n="Hex"}=t;return Rx(e,{as:n})}(function(e){const{address:t,chainId:n,nonce:r}=e,s=function(e){if(void 0!==e.r&&void 0!==e.s)return ny(e)}(e);return[n?zf(n):"0x",t,r?zf(r):"0x",...s?sy(s):[]]}(n?{address:e.address,chainId:e.chainId,nonce:e.nonce}:e))))}(e,{presign:!0})}async function Ux(e,t){const{account:n=e.account}=t,r=n?Cg(n):void 0;if(!r)throw new Error("account is required.");const{domain:{name:s,version:i}}=await async function(e,t){const{address:n,factory:r,factoryData:s}=t;try{const[t,i,a,o,c,u,d]=await G(e,ja,"readContract")({abi:to,address:n,functionName:"eip712Domain",factory:r,factoryData:s});return{domain:{name:i,version:a,chainId:Number(o),verifyingContract:c,salt:u},extensions:d,fields:t}}catch(e){const t=e;if("ContractFunctionExecutionError"===t.name&&"ContractFunctionZeroDataError"===t.cause.name)throw new eo({address:n});throw t}}(e,{address:r.address});if(!e.chain)throw new Error("client.chain is required");return{chainId:e.chain.id,name:s,verifyingContract:r.address,version:i}}async function qx(e,t){const{account:n=e.account,chainIds:r}=t,s=n?Cg(n):void 0;if(!s)throw new Error("account is required.");const i=await async function(e,t){const{address:n,chainIds:r}=t;try{const t="wallet_getKeys",s=await e.request({method:t,params:[nh(Uw.Parameters,{address:n,chainIds:r})]});return sh(Uw.Response,s)}catch(e){throw Jw(e),e}}(e,{address:s.address,chainIds:r});return Object.entries(i).flatMap((([e,t])=>t.map((t=>function(e,t){const{chainId:n}=t,{publicKey:r}=e,s=20===$f(r)||0n===jf(Mf(r,0,12)),i={};for(const t of e.permissions)"call"===t.type&&(i.calls??=[],i.calls.push({signature:t.selector,to:t.to===mg?void 0:t.to})),"spend"===t.type&&(i.spend??=[],i.spend.push({limit:t.limit,period:t.period,token:t.token}));return Mg({chainId:n,expiry:e.expiry,permissions:i,publicKey:e.publicKey,role:gg[e.role],type:s?"address":bg[e.type]})}(t,{chainId:Number(e)})))))}async function Lx(e,t){const{account:n=e.account,calls:r,chain:s=e.chain,feePayer:i,merchantUrl:a,nonce:o,preCalls:c,requiredFunds:u,revokeKeys:d}=t,l=n?Cg(n):void 0,f=t.key??(l?Dg(l,{role:"admin"}):void 0),p=t.authorizeKeys?.some((e=>"session"===e.role)),{contracts:h,fees:{tokens:m}}=await Zw(e,{chainId:s?.id}),y=p?h.orchestrator.address:void 0,b=(t.authorizeKeys??[]).map((e=>Ng(e,{feeTokens:m,orchestrator:y}))),g=t.feeToken?t.feeToken:f?.permissions?.spend?.[0]?.token,w="boolean"==typeof c&&c,v="object"==typeof c?c.map((({context:e,signature:t})=>({...e.preCall,signature:t}))):void 0,x={address:l?.address,calls:r??[],capabilities:{authorizeKeys:b,meta:{feePayer:i,feeToken:g,nonce:o},preCall:w,preCalls:v,requiredFunds:u,revokeKeys:d?.map((e=>({hash:e.hash})))},chain:s,key:f?Ng(f,{feeTokens:m}):void 0},I=await(async()=>{if(a){const t=Xa({chain:e.chain,transport:il(a)});return await Hw(t,x).catch((t=>(console.error(t),Hw(e,x))))}return await Hw(e,x)})(),{capabilities:P,context:z,digest:E,signature:A,typedData:k}=I;if(a){if(!await Ww(e,{response:I._raw,signature:A}))throw new Error(`cannot verify integrity of \`wallet_prepareCalls\` response from ${a}`)}return{capabilities:{...P,quote:z.quote},context:z,digest:E,key:f,typedData:k}}async function Fx(e,t){const{address:n,authorizeKeys:r,chain:s=e.chain}=t;if(!s)throw new Error("chain is required.");const{contracts:i,fees:{tokens:a}}=await Zw(e,{chainId:s.id}),o=t.delegation??i.accountProxy.address,c=r.some((e=>"session"===e.role))?i.orchestrator.address:void 0,u=r.map((e=>{const t="session"===e.role?e.permissions:{};return Ng({...e,permissions:t},{feeTokens:a,orchestrator:c})})),{capabilities:d,chainId:l,context:f,digests:p,typedData:h}=await async function(e,t){const{address:n,chain:r=e.chain,delegation:s,...i}=t;try{const t="wallet_prepareUpgradeAccount",a=await e.request({method:t,params:[nh(Lw.Parameters,Ql({address:n,capabilities:i,chainId:r?.id,delegation:s}))]},{retryCount:0});return sh(Lw.Response,a)}catch(e){throw Jw(e),Yw(e),e}}(e,{address:n,authorizeKeys:u,chain:s,delegation:o});return{capabilities:d,chainId:l,context:{...f,account:Cg({address:n,keys:r})},digests:p,typedData:h}}async function Kx(e,t){const{account:n=e.account,chain:r=e.chain,webAuthn:s}=t;if(!r)throw new Error("`chain` is required.");const i=n?Cg(n):void 0;if(!i)throw new Error("`account` is required.");const a=t.key??Dg(i,t);if(!a&&!i.sign)throw new Error("`key` or `account` with `sign` is required");const o=await Promise.all((t.preCalls??[]).map((async n=>{if(n.signature)return n;const{authorizeKeys:a,key:o,calls:c,revokeKeys:u}=n,{context:d,digest:l}=await Lx(e,{account:i,authorizeKeys:a,calls:c,chain:r,feeToken:t.feeToken,key:o,preCalls:!0,revokeKeys:u});return{context:d,signature:await Sg(o,{address:null,payload:l,webAuthn:s})}}))),{capabilities:c,context:u,digest:d}=await Lx(e,{...t,account:i,chain:r,key:a,preCalls:o}),l=await(async()=>a?await Sg(a,{address:null,payload:d,webAuthn:s,wrap:!1}):await i.sign({hash:d}))();return await Vx(e,{capabilities:c.feeSignature?{feeSignature:c.feeSignature}:void 0,context:u,key:a,signature:l})}async function Vx(e,t){const{capabilities:n,context:r,key:s,signature:i}=t;return await async function(e,t){const{capabilities:n,context:r,key:s,signature:i}=t;try{const t="wallet_sendPreparedCalls",a=await e.request({method:t,params:[nh(Kw.Parameters,{capabilities:n,context:{preCall:r.preCall,quote:r.quote},key:s?{prehash:s.prehash,publicKey:s.publicKey,type:s.type}:void 0,signature:i})]},{retryCount:0});return sh(Kw.Response,a)}catch(e){throw Jw(e),Yw(e),e}}(e,{capabilities:n,context:r,key:s?Ng(s):void 0,signature:i})}async function Gx(e,t){const{email:n,walletAddress:r}=t;return await async function(e,t){const{email:n,walletAddress:r}=t;try{const t="account_setEmail",s=await e.request({method:t,params:[nh($w.Parameters,{email:n,walletAddress:r})]},{retryCount:0});return sh($w.Response,s)}catch(e){throw Jw(e),Yw(e),e}}(e,{email:n,walletAddress:r})}async function Zx(e,t){if(t.account){const{account:n}=t,r=[...n.keys??[],...t.authorizeKeys??[]].filter(((e,t,n)=>n.findIndex((t=>t.id===e.id))===t)),{digests:s,...i}=await Fx(e,{...t,address:n.address,authorizeKeys:r}),a={auth:await n.sign({hash:s.auth}),exec:await n.sign({hash:s.exec})};return await Zx(e,{...i,signatures:a})}const{context:n,signatures:r}=t,s=Cg(n.account);return await async function(e,t){const{context:n,signatures:r}=t;try{const t="wallet_upgradeAccount";await e.request({method:t,params:[nh(Vw.Parameters,{context:n,signatures:r})]},{retryCount:0})}catch(e){throw Jw(e),Yw(e),e}}(e,{context:n,signatures:r}),s}async function Hx(e,t){const{chainId:n,email:r,signature:s,token:i,walletAddress:a}=t;return await async function(e,t){const{chainId:n,email:r,signature:s,token:i,walletAddress:a}=t;try{const t="account_verifyEmail",o=await e.request({method:t,params:[nh(jw.Parameters,{chainId:n,email:r,signature:s,token:i,walletAddress:a})]},{retryCount:0});return sh(jw.Response,o)}catch(e){throw Jw(e),Yw(e),e}}(e,{chainId:n,email:r,signature:s,token:i,walletAddress:a})}const Wx="0x8010801080108010801080108010801080108010801080108010801080108010",Yx=mb("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function Qx(e){const{data:t,signature:n}=e;!function(e){if("string"==typeof e){if(Mf(e,-32)!==Wx)throw new Jx(e)}else ey(e.authorization)}(e);const r=Hm({payload:Dx(e.authorization),signature:ny(e.authorization)}),s=pb(Yx,[{...e.authorization,delegation:e.authorization.address,chainId:BigInt(e.authorization.chainId)},e.to??r,t??"0x"]);return vf(n,s,zf($f(s),{size:32}),Wx)}class Jx extends ml{constructor(e){super(`Value \`${e}\` is an invalid ERC-8010 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc8010.InvalidWrappedSignatureError"})}}async function Xx(e,t){const{address:n}=t,{authorization:r,data:s,to:i}=await async function(e,t){try{const n="wallet_getAuthorization",r=await Da((()=>e.request({method:n,params:[nh(Rw.Parameters,t)]})),{cacheKey:`${e.uid}.${n}.${t.address}`});return sh(Rw.Response,r)}catch(e){throw Jw(e),e}}(e,{address:n});return Qx({authorization:{...r,nonce:BigInt(r.nonce),r:BigInt(r.r),s:BigInt(r.s)},data:s,signature:t.signature,to:i})}function eI(e,t){const{tokens:n}=t,r=n.filter((e=>e.interop));return e.map((e=>{if(e.address)return e;const t=r.find((t=>t.symbol===e.symbol));if(!t)throw new Error(`interop token not found: ${e.symbol}`);return{address:t.address,value:tg(e.value,t.decimals)}}))}async function tI(e,t){const{chain:n=e.chain}=t??{};return await Zw(e,{chainId:n?.id}).then((e=>e.fees.tokens))}async function nI(e,t){const{addressOrSymbol:n}=t;return(await tI(e,t)).find(nI.predicate(n))}async function rI(e,t){const{chain:n=e.chain,store:r}=t??{},s=r?.getState()??{},i=t?.addressOrSymbol??s.feeToken,a=await tI(e,{chain:n}).then((e=>e.filter((e=>e.feeToken)))),o=a?.find((e=>!!i&&("native"===i&&e.address===Wd||(!(!wp(i)||!gp(e.address,i))||i===e.symbol))));return o}function sI(e={}){const t=e,{mock:n,multichain:r=!0,webAuthn:s}=t;let i,a;const o=(()=>{if("self"!==t.keystoreHost&&("undefined"==typeof window||"localhost"!==window.location?.hostname))return t.keystoreHost})();return bx({actions:{async addFunds(){throw new Tl},async createAccount(e){const{admins:t,email:r,label:a,permissions:c,internal:u,signInWithEthereum:d}=e,{client:l}=u,f=Bg(function(e={}){const{as:t="Hex"}=e,n=ud.utils.randomPrivateKey();return"Hex"===t?Pf(n):n}()),p=await tI(l),h=n?Ag():await Eg({createFn:s?.createFn,label:a||`${f.address.slice(0,8)}…${f.address.slice(-6)}`,rpId:o,userId:qf(f.address)}),m=await xx(c,{chainId:l.chain.id,feeTokens:p}),y=t?.map((e=>Mg(e))),b=await Zx(l,{account:f,authorizeKeys:[h,...y??[],...m?[m]:[]]});i=f.address,r&&a&&await Gx(l,{email:a,walletAddress:b.address});const g=await(async()=>{if(!d)return;const e=await Sx(l,d,{address:b.address}),t=await Ug(f,{payload:_x(Ef(e))});return{message:e,signature:await Xx(l,{address:b.address,signature:t})}})();return{account:{...b,signInWithEthereum:g}}},async getAccountVersion(e){const{address:t,internal:n}=e,{client:r}=n,{contracts:s}=await Zw(r),{accountImplementation:i}=s,a=await Ux(r,{account:Cg(i)}).then((e=>e.version)),o=await Ux(r,{account:t}).then((e=>e.version)).catch((()=>a));if(!o||!a)throw new Error("version not found.");return{current:o,latest:a}},async getAssets(e){const{account:t,chainFilter:n,assetFilter:r,assetTypeFilter:s,internal:i}=e,{client:a}=i,o=await async function(e,t){const{account:n,assetFilter:r,assetTypeFilter:s,chainFilter:i}=t;try{const t="wallet_getAssets",a=await e.request({method:t,params:[nh(Bw.Parameters,{account:n,assetFilter:r,assetTypeFilter:s,chainFilter:i})]}),o=sh(Bw.Response,a),c=Object.entries(o).reduce(((e,[t,n])=>(e[Sf(t)]=n,e)),{}),u={};for(const e of Object.values(c))for(const t of e){const e=JSON.stringify(t.metadata);u[e]={...t,balance:t.balance+(u[e]?.balance??0n)}}return{...c,0:Object.values(u)}}catch(e){throw Jw(e),e}}(a,{account:t,assetFilter:r,assetTypeFilter:s,chainFilter:n});return o},async getCallsStatus(e){const{id:t,internal:n}=e,{client:r}=n,s=await async function(e,t){const{id:n}=t;try{const t="wallet_getCallsStatus",r=await e.request({method:t,params:[n]});return sh(Dw.Response,r)}catch(e){throw Jw(e),e}}(r,{id:t});return{atomic:!0,chainId:zf(r.chain.id),id:t,receipts:s.receipts?.map((e=>({blockHash:e.blockHash,blockNumber:zf(e.blockNumber),gasUsed:zf(e.gasUsed),logs:e.logs,status:e.status,transactionHash:e.transactionHash}))),status:s.status,version:"1.0"}},async getCapabilities(e){const{chainIds:t,internal:n}=e,{client:s}=n,i={atomic:{status:"supported"},atomicBatch:{supported:!0},feeToken:{supported:!0,tokens:[]},merchant:{supported:!0},permissions:{supported:!0},requiredFunds:{supported:Boolean(r),tokens:[]}},a=await Zw(s,{chainIds:t?t.map((e=>Sf(e))):"all",raw:!0});return Object.entries(a).reduce(((e,[t,n])=>({...e,[t]:{...i,...n,feeToken:{supported:!0,tokens:n.fees.tokens},requiredFunds:{supported:Boolean(r),tokens:r?n.fees.tokens.filter((e=>e.interop)):[]}}})),{})},async getKeys(e){const{account:t,chainIds:n,internal:r}=e,{client:s}=r;return Jl([...await qx(s,{account:t,chainIds:n}),...t.keys??[]],(e=>e.publicKey))},async grantAdmin(e){const{account:t,internal:n}=e,{client:r}=n,i=Mg(e.key,{chainId:r.chain.id}),a=await rI(r,{addressOrSymbol:e.feeToken,store:n.store}),{id:o}=await Kx(r,{account:t,authorizeKeys:[i],feeToken:a?.address,webAuthn:s});return await Za(r,{id:o,pollingInterval:500}),{key:i}},async grantPermissions(e){const{account:t,internal:n,permissions:r}=e,{client:s}=n,i=await tI(s),a=await xx(r,{chainId:s.chain.id,feeTokens:i});if(!a)throw new Error("key to authorize not found.");const o=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!o)throw new Error("admin key not found.");const{context:c,digest:u}=await Lx(s,{account:t,authorizeKeys:[a],key:o,preCalls:!0}),d=await Sg(o,{address:null,payload:u});return await Vx(s,{context:c,key:o,signature:d}),{key:a}},async loadAccounts(e){const{internal:t,permissions:r,signInWithEthereum:a}=e,{client:c}=t,u=await tI(c),d=await xx(r,{chainId:c.chain.id,feeTokens:u}),{digest:l,digestType:f,message:p}=await(async()=>{if(a&&e.address){const t=await Sx(c,a,{address:e.address});return{context:void 0,digest:_x(Ef(t)),digestType:"siwe",message:t}}return{context:void 0,digest:"0x",message:void 0}})(),{address:h,credentialId:m,webAuthnSignature:y}=await(async()=>{if(n){if(!i)throw new Error("address_internal not found.");return{address:i,credentialId:void 0}}if(e.address&&e.key)return{address:e.address,credentialId:e.key.credentialId};const t=await fg({challenge:l,getFn:s?.getFn,rpId:o}),r=t.raw.response;return{address:Hf(new Uint8Array(r.userHandle)),credentialId:t.raw.id,webAuthnSignature:t}})(),b=await qx(c,{account:h,chainIds:[c.chain.id]}),g=Cg({address:h,keys:[...b,...d?[d]:[]].map(((e,t)=>0===t&&"webauthn-p256"===e.type?$g({...e,credential:{id:m,publicKey:ap(e.publicKey)},id:h,rpId:o}):e))}),w=Dg(g,{role:"admin"}),v=await(async()=>{if("0x"!==l)return y?Rg(_g(y),{keyType:"webauthn-p256",publicKey:w.publicKey}):await Sg(w,{address:g.address,payload:l})})();if(d){const{context:e,digest:t}=await Lx(c,{account:g,authorizeKeys:[d],preCalls:!0}),n=await Sg(w,{address:null,payload:t});await Vx(c,{context:e,key:w,signature:n})}const x=await(async()=>{if(a){if("siwe"===f&&p&&v){const e=await Xx(c,{address:g.address,signature:v});return{message:p,signature:e}}{const e=await Sx(c,a,{address:g.address}),t=await Ug(g,{payload:_x(Ef(e)),role:"admin"});return{message:e,signature:await Xx(c,{address:g.address,signature:t})}}}})();return{accounts:[{...g,signInWithEthereum:x}]}},async prepareCalls(e){const{account:t,calls:n,internal:s,merchantUrl:i}=e,{client:a}=s,o=e.key??await gx({account:t,calls:n});if(!o)throw new Error("cannot find authorized key to sign with.");const[c,u]=await Promise.all([tI(a),rI(a,{addressOrSymbol:e.feeToken,store:s.store})]),d=eI(e.requiredFunds??[],{tokens:c}),{capabilities:l,context:f,digest:p,typedData:h}=await Lx(a,{account:t,calls:n,feeToken:u?.address,key:o,merchantUrl:i,requiredFunds:r?d:void 0}),m=f.quote?.quotes??[],y=m[m.length-1];return{account:t,capabilities:{...l,quote:f.quote},chainId:a.chain.id,context:{...f,account:t,calls:n,nonce:y?.intent.nonce},digest:p,key:o,typedData:h}},async prepareUpgradeAccount(e){const{address:t,email:r,label:i,internal:c,permissions:u}=e,{client:d}=c,[l,f]=await Promise.all([tI(d),rI(d,{store:c.store})]),p=n?Ag():await Eg({createFn:s?.createFn,label:i||`${t.slice(0,8)}…${t.slice(-6)}`,rpId:o,userId:qf(t)}),h=await xx(u,{chainId:d.chain.id,feeTokens:l}),{context:m,digests:y}=await Fx(d,{address:t,authorizeKeys:[p,...h?[h]:[]],feeToken:f?.address});return r&&(a=i),{context:m,digests:y}},async revokeAdmin(e){const{account:t,id:n,internal:r}=e,{client:i}=r,a=t.keys?.find((e=>e.id===n));if(a){if("webauthn-p256"===a.type&&1===t.keys?.filter((e=>"webauthn-p256"===e.type)).length)throw new Error("revoke the only WebAuthn key left.");try{const n=await rI(i,{addressOrSymbol:e.feeToken,store:r.store}),{id:o}=await Kx(i,{account:t,feeToken:n?.address,revokeKeys:[a],webAuthn:s});await Za(i,{id:o})}catch(e){const t=e;if("Rpc.ExecutionError"===t.name&&"KeyDoesNotExist"===t.abiError?.name)return;throw e}}},async revokePermissions(e){const{account:t,id:n,internal:r}=e,{client:i}=r,a=t.keys?.find((e=>e.id===n));if(a){if("admin"===a.role)throw new Error("cannot revoke admins.");try{const n=await rI(i,{addressOrSymbol:e.feeToken,store:r.store}),{id:o}=await Kx(i,{account:t,feeToken:n?.address,revokeKeys:[a],webAuthn:s});await Za(i,{id:o})}catch(e){const t=e;if("Rpc.ExecutionError"===t.name&&"KeyDoesNotExist"===t.abiError?.name)return;throw e}}},async sendCalls(e){const{account:t,asTxHash:n,calls:i,internal:a,merchantUrl:o}=e,{client:c}=a,u=await gx({account:t,calls:i,permissionsId:e.permissionsId}),[d,l]=await Promise.all([tI(c),rI(c,{addressOrSymbol:e.feeToken,store:a.store})]),f=eI(e.requiredFunds??[],{tokens:d}),p=await Kx(c,{account:t,calls:i,feeToken:l?.address,key:u,merchantUrl:o,requiredFunds:r?f:void 0,webAuthn:s});if(n){const{id:e,receipts:t,status:n}=await Za(c,{id:p.id,pollingInterval:500});if(!t?.[0]){if("success"===n)throw new ql({message:"Call bundle with id: "+e+" not found."});throw new Il({message:"Transaction failed under call bundle id: "+e+"."})}return{id:t[0].transactionHash}}return p},async sendPreparedCalls(e){const{context:t,key:n,internal:r,signature:s}=e,{client:i}=r,{id:a}=await Vx(i,{context:t,key:n,signature:s});return a},async signPersonalMessage(e){const{account:t,data:n,internal:r}=e,{client:i}=r,a=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!a)throw new Error("cannot find admin key to sign with.");const o=await Ug(t,{key:a,payload:_x(n),webAuthn:s});return Xx(i,{address:t.address,signature:o})},async signTypedData(e){const{account:t,internal:n}=e,{client:r}=n,i=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!i)throw new Error("cannot find admin key to sign with.");const a=function(e,t){return JSON.parse(e,((e,n)=>{const r=n;return"string"==typeof r&&r.endsWith(pl)?BigInt(r.slice(0,-pl.length)):"function"==typeof t?t(e,r):r}))}(e.data),o="Orchestrator"===a.domain?.name,c=await Ug(t,{key:i,payload:zb(a),replaySafe:!o,webAuthn:s});return o?c:Xx(r,{address:t.address,signature:c})},async upgradeAccount(e){const{account:t,context:n,internal:r,signatures:s}=e,{client:i}=r;return await Zx(i,{context:n,signatures:s}),a&&await Gx(i,{email:a,walletAddress:t.address}),{account:t}},async verifyEmail(e){const{account:t,chainId:n,email:r,token:i,internal:a,walletAddress:o}=e,{client:c}=a,u=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!u)throw new Error("cannot find admin key to sign with.");const d=await Ug(t,{key:u,payload:np(Ef(`${r}${i}`)),webAuthn:s});return await Hx(c,{chainId:n,email:r,signature:d,token:i,walletAddress:o})}},config:e,name:"rpc"})}async function iI(e,t){const{config:{feeToken:n}}=e,{feeToken:r}=t??{};return r??n}function aI(e,{storage:t}){if(!e)return;const n=Nx(e,"undefined"!=typeof window?window.location.origin:void 0);return n&&t.setItem("porto.authUrl",n),n}!function(e){e.predicate=function(e){return t=>!!e&&(wp(e)?gp(t.address,e):"native"===e?t.address===Wd:e===t.symbol)}}(nI||(nI={}));const oI=new Map,cI=e=>{const t=oI.get(e);return t?Object.fromEntries(Object.entries(t.stores).map((([e,t])=>[e,t.getState()]))):{}},uI=e=>{var t,n;if(!e)return;const r=e.split("\n"),s=r.findIndex((e=>e.includes("api.setState")));if(s<0)return;const i=(null==(t=r[s+1])?void 0:t.trim())||"";return null==(n=/.+ (.+) .+/.exec(i))?void 0:n[1]},dI=(e,t={})=>(n,r,s)=>{const{enabled:i,anonymousActionType:a,store:o,...c}=t;let u;try{u=(null!=i?i:"production"!==(import.meta.env?import.meta.env.MODE:void 0))&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}if(!u)return e(n,r,s);const{connection:d,...l}=((e,t,n)=>{if(void 0===e)return{type:"untracked",connection:t.connect(n)};const r=oI.get(n.name);if(r)return{type:"tracked",store:e,...r};const s={connection:t.connect(n),stores:{}};return oI.set(n.name,s),{type:"tracked",store:e,...s}})(o,u,c);let f=!0;s.setState=(e,t,i)=>{const u=n(e,t);if(!f)return u;const l=void 0===i?{type:a||uI((new Error).stack)||"anonymous"}:"string"==typeof i?{type:i}:i;return void 0===o?(null==d||d.send(l,r()),u):(null==d||d.send({...l,type:`${o}/${l.type}`},{...cI(c.name),[o]:s.getState()}),u)},s.devtools={cleanup:()=>{d&&"function"==typeof d.unsubscribe&&d.unsubscribe(),((e,t)=>{if(void 0===t)return;const n=oI.get(e);n&&(delete n.stores[t],0===Object.keys(n.stores).length&&oI.delete(e))})(c.name,o)}};const p=(...e)=>{const t=f;f=!1,n(...e),f=t},h=e(s.setState,r,s);if("untracked"===l.type?null==d||d.init(h):(l.stores[l.store]=s,null==d||d.init(Object.fromEntries(Object.entries(l.stores).map((([e,t])=>[e,e===l.store?h:t.getState()]))))),s.dispatchFromDevtools&&"function"==typeof s.dispatch){let e=!1;const t=s.dispatch;s.dispatch=(...n)=>{"production"===(import.meta.env?import.meta.env.MODE:void 0)||"__setState"!==n[0].type||e||(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),e=!0),t(...n)}}return d.subscribe((e=>{var t;switch(e.type){case"ACTION":return"string"!=typeof e.payload?void console.error("[zustand devtools middleware] Unsupported action format"):lI(e.payload,(e=>{if("__setState"!==e.type)s.dispatchFromDevtools&&"function"==typeof s.dispatch&&s.dispatch(e);else{if(void 0===o)return void p(e.state);1!==Object.keys(e.state).length&&console.error('\n [zustand devtools middleware] Unsupported __setState action format.\n When using \'store\' option in devtools(), the \'state\' should have only one key, which is a value of \'store\' that was passed in devtools(),\n and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }\n ');const t=e.state[o];if(null==t)return;JSON.stringify(s.getState())!==JSON.stringify(t)&&p(t)}}));case"DISPATCH":switch(e.payload.type){case"RESET":return p(h),void 0===o?null==d?void 0:d.init(s.getState()):null==d?void 0:d.init(cI(c.name));case"COMMIT":return void 0===o?void(null==d||d.init(s.getState())):null==d?void 0:d.init(cI(c.name));case"ROLLBACK":return lI(e.state,(e=>{if(void 0===o)return p(e),void(null==d||d.init(s.getState()));p(e[o]),null==d||d.init(cI(c.name))}));case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return lI(e.state,(e=>{void 0!==o?JSON.stringify(s.getState())!==JSON.stringify(e[o])&&p(e[o]):p(e)}));case"IMPORT_STATE":{const{nextLiftedState:n}=e.payload,r=null==(t=n.computedStates.slice(-1)[0])?void 0:t.state;if(!r)return;return p(void 0===o?r:r[o]),void(null==d||d.send(null,n))}case"PAUSE_RECORDING":return f=!f}return}})),h},lI=(e,t)=>{let n;try{n=JSON.parse(e)}catch(e){console.error("[zustand devtools middleware] Could not parse the received json",e)}void 0!==n&&t(n)},fI=e=>(t,n,r)=>{const s=r.subscribe;r.subscribe=(e,t,n)=>{let i=e;if(t){const s=(null==n?void 0:n.equalityFn)||Object.is;let a=e(r.getState());i=n=>{const r=e(n);if(!s(a,r)){const e=a;t(a=r,e)}},(null==n?void 0:n.fireImmediately)&&t(a,a)}return s(i)};return e(t,n,r)};function pI(e,t){let n;try{n=e()}catch(e){return}const r={getItem:e=>{var r;const s=e=>null===e?null:JSON.parse(e,null==t?void 0:t.reviver),i=null!=(r=n.getItem(e))?r:null;return i instanceof Promise?i.then(s):s(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,null==t?void 0:t.replacer)),removeItem:e=>n.removeItem(e)};return r}const hI=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>hI(e)(n),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>hI(t)(e)}}},mI=(e,t)=>(n,r,s)=>{let i={storage:pI((()=>localStorage)),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},a=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e(((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...e)}),r,s);const d=()=>{const e=i.partialize({...r()});return u.setItem(i.name,{state:e,version:i.version})},l=s.setState;s.setState=(e,t)=>(l(e,t),d());const f=e(((...e)=>(n(...e),d())),r,s);let p;s.getInitialState=()=>f;const h=()=>{var e,t;if(!u)return;a=!1,o.forEach((e=>{var t;return e(null!=(t=r())?t:f)}));const s=(null==(t=i.onRehydrateStorage)?void 0:t.call(i,null!=(e=r())?e:f))||void 0;return hI(u.getItem.bind(u))(i.name).then((e=>{if(e){if("number"!=typeof e.version||e.version===i.version)return[!1,e.state];if(i.migrate){const t=i.migrate(e.state,e.version);return t instanceof Promise?t.then((e=>[!0,e])):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]})).then((e=>{var t;const[s,a]=e;if(p=i.merge(a,null!=(t=r())?t:f),n(p,!0),s)return d()})).then((()=>{null==s||s(p,void 0),p=r(),a=!0,c.forEach((e=>e(p)))})).catch((e=>{null==s||s(void 0,e)}))};return s.persist={setOptions:e=>{i={...i,...e},e.storage&&(u=e.storage)},clearStorage:()=>{null==u||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>h(),hasHydrated:()=>a,onHydrate:e=>(o.add(e),()=>{o.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},i.skipHydration||h(),p||f},yI=e=>{let t;const n=new Set,r=(e,r)=>{const s="function"==typeof e?e(t):e;if(!Object.is(s,t)){const e=t;t=(null!=r?r:"object"!=typeof s||null===s)?s:Object.assign({},t,s),n.forEach((n=>n(t,e)))}},s=()=>t,i={setState:r,getState:s,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e))},a=t=e(r,s,i);return i},bI=e=>e?yI(e):yI;function gI(e){return new Promise(((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}))}function wI(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=gI(n);return(e,n)=>r.then((r=>n(r.transaction(t,e).objectStore(t))))}let vI;function xI(){return vI||(vI=wI("keyval-store","keyval")),vI}const II="undefined"!=typeof window&&"undefined"!=typeof document,PI={announceProvider:!0,chains:fl,mode:II?function(e={}){const{fallback:t=sI(),host:n=rf.prod,renderer:r=sf(),theme:s,themeController:i}=e,a=new Set,o=function(e={}){let t=e.id??0;return{prepare:e=>function(e){return{...e,jsonrpc:"2.0"}}({id:t++,...e}),get id(){return t}}}();function c(e){return Vl({async request(t){const n=o.prepare(t);return e.setState((e=>{const t=e.accounts[0],r=t?.keys?.find((e=>"admin"===e.role&&"webauthn-p256"===e.type));return{...e,requestQueue:[...e.requestQueue,{account:t?{address:t.address,key:r?{credentialId:r?.credentialId,publicKey:r.publicKey}:void 0}:void 0,request:n,status:"pending"}]}})),new Promise(((t,r)=>{const s=i=>{const o=i.find((e=>e.request.id===n.id));if(!o&&0===i.length)return a.delete(s),void r(new Sl);o&&("success"!==o.status&&"error"!==o.status||(a.delete(s),"success"===o.status?t(o.result):r(Gl(o.error)),e.setState((e=>({...e,requestQueue:e.requestQueue.filter((e=>e.request.id!==n.id))})))))};a.add(s)}))}},{schema:null})}return bx({actions:{async addFunds(e){const{internal:t}=e,{request:n,store:r}=t;if("wallet_addFunds"!==n.method)throw new Error("Cannot add funds for method: "+n.method);const s=c(r);return await s.request(n)},async createAccount(e){const{internal:t}=e,{client:n,config:r,request:s,store:i}=t,{storage:a}=r,o=c(i),u=await(async()=>{if("wallet_connect"===s.method){const[{capabilities:e,chainIds:t}]=s._decoded.params??[{}],i=aI(e?.signInWithEthereum?.authUrl??r.authUrl,{storage:a}),c=s.params?.[0]?.capabilities?.signInWithEthereum,u=await xx(e?.grantPermissions,{chainId:n.chain.id}),d=u?nh(wx,vx(u)):void 0,{accounts:l}=await o.request({...s,params:[{capabilities:{...s.params?.[0]?.capabilities,grantPermissions:d,signInWithEthereum:i||c?{...c,authUrl:i}:void 0},chainIds:t?.map((e=>zf(e)))}]}),[f]=l;if(!f)throw new Error("no account found.");const p=f.capabilities?.admins?.map((e=>Mg(e,{chainId:n.chain.id}))).filter(Boolean),h=f.capabilities?.permissions?.map((e=>{try{const t=mv(sh(pv,e));return t.id===u?.id?{...t,...u,permissions:t.permissions}:t}catch{return}})).filter(Boolean),m=await(async()=>{if(!f.capabilities?.signInWithEthereum)return;const{message:e,signature:t}=f.capabilities.signInWithEthereum;if(!i)return{message:e,signature:t};const{token:n}=await jx({address:f.address,authUrl:i,message:e,signature:t});return{message:e,signature:t,token:n}})();return{...Cg({address:f.address,keys:[...p??[],...h??[]]}),signInWithEthereum:m}}throw new Error(`Account creation not supported on method: ${s.method}`)})();return{account:u}},async disconnect(e){const{internal:t}=e,{config:n}=t,{storage:r}=n,s=await r.getItem("porto.authUrl")||void 0,i=aI(n.authUrl??s,{storage:r});i&&await fetch(i.logout,{credentials:"include",method:"POST"}).catch((()=>{}))},async getAccountVersion(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getAccountVersion"!==i.method)throw new Error("Cannot get version for method: "+i.method);if(!r.supportsHeadless)return t.actions.getAccountVersion(e);const a=c(s);return await a.request(i)},async getAssets(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getAssets"!==i.method)throw new Error("Cannot get assets for method: "+i.method);if(!r.supportsHeadless)return t.actions.getAssets(e);const a=c(s),o=await a.request(i);return sh(Xv.Response,o)},async getCallsStatus(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getCallsStatus"!==i.method)throw new Error("Cannot get status for method: "+i.method);if(!r.supportsHeadless)return t.actions.getCallsStatus(e);const a=c(s);return await a.request(i)},async getCapabilities(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getCapabilities"!==i.method)throw new Error("Cannot get capabilities for method: "+i.method);if(!r.supportsHeadless)return t.actions.getCapabilities(e);const a=c(s);return await a.request(i)},async getKeys(e){const{account:n,chainIds:s,internal:i}=e,{store:a}=i;return Jl([...await(async()=>{if(!r.supportsHeadless)return t.actions.getKeys(e);const i=c(a),o=await i.request({method:"wallet_getKeys",params:[nh(nx.Parameters,{address:n.address,chainIds:s})]});return sh(nx.Response,o)})(),...n.keys??[]],(e=>e.publicKey))},async grantAdmin(e){const{internal:t}=e,{request:n,store:r}=t;if("wallet_grantAdmin"!==n.method)throw new Error("Cannot authorize admin for method: "+n.method);const[s]=n._decoded.params,i=Mg(s.key);if(!i)throw new Error("no key found.");const a=await iI(t,e),o=c(r);return await o.request({method:"wallet_grantAdmin",params:[{...n.params?.[0],capabilities:{...n.params?.[0]?.capabilities,feeToken:a}}]}),{key:i}},async grantPermissions(e){const{internal:t}=e,{client:n,request:r,store:s}=t;if("wallet_grantPermissions"!==r.method)throw new Error("Cannot grant permissions for method: "+r.method);const[{address:i,...a}]=r._decoded.params,o=await xx(a,{chainId:n.chain.id});if(!o)throw new Error("no key found.");const u=nh(wx,vx(o)),d=c(s);return await d.request({method:"wallet_grantPermissions",params:[u]}),{key:o}},async loadAccounts(e){const{internal:t}=e,{client:n,config:r,store:s}=t,{storage:i}=r,a=c(s),o=t.request;if("wallet_connect"!==o.method&&"eth_requestAccounts"!==o.method)throw new Error("Cannot load accounts for method: "+o.method);const u=await(async()=>{const[e]=o._decoded.params??[],{capabilities:t}=e??{},s=aI(t?.signInWithEthereum?.authUrl??r.authUrl,{storage:i}),c=o.params?.[0]?.capabilities?.signInWithEthereum,u=await xx(t?.grantPermissions,{chainId:n.chain.id}),d=u?nh(wx,vx(u)):void 0,{accounts:l}=await a.request({method:"wallet_connect",params:[{...o.params?.[0],capabilities:{...o.params?.[0]?.capabilities,grantPermissions:d,signInWithEthereum:s||c?{...c,authUrl:s}:void 0}}]});return Promise.all(l.map((async e=>{const t=e.capabilities?.admins?.map((e=>Mg(e))).filter(Boolean),n=e.capabilities?.permissions?.map((e=>{try{const t=mv(sh(pv,e));return t.id===u?.id?{...t,...u,permissions:t.permissions}:t}catch{return}})).filter(Boolean),r=await(async()=>{if(!e.capabilities?.signInWithEthereum)return;const{message:t,signature:n}=e.capabilities.signInWithEthereum;if(!s)return{message:t,signature:n};const{token:r}=await jx({address:e.address,authUrl:s,message:t,signature:n});return{message:t,signature:n,token:r}})();return{...Cg({address:e.address,keys:[...t??[],...n??[]]}),signInWithEthereum:r}})))})();return{accounts:u}},async prepareCalls(e){const{account:n,internal:s}=e,{store:i,request:a}=s;if("wallet_prepareCalls"!==a.method)throw new Error("Cannot prepare calls for method: "+a.method);if(!r.supportsHeadless)return t.actions.prepareCalls(e);const o=await iI(s,e),u=c(i),d=sh(rx.Response,await u.request({...a,params:[{...a.params?.[0],capabilities:{...a.params?.[0]?.capabilities,feeToken:o}}]}));return{account:n,chainId:Number(d.chainId),context:d.context,digest:d.digest,key:d.key,typedData:d.typedData}},async prepareUpgradeAccount(e){const{internal:n}=e,{client:s,store:i,request:a}=n;if("wallet_prepareUpgradeAccount"!==a.method)throw new Error("Cannot prepare upgrade for method: "+a.method);if(!r.supportsHeadless)return t.actions.prepareUpgradeAccount(e);const[{capabilities:o}]=a._decoded.params??[{}],u=await xx(o?.grantPermissions,{chainId:s.chain.id}),d=u?nh(wx,vx(u)):void 0,l=c(i),{context:f,digests:p}=await l.request({...a,params:[{...a.params?.[0],capabilities:{...a.params?.[0]?.capabilities,grantPermissions:d}}]}),h=f.account.keys?.map((e=>e.id===u?.id?{...e,...u}:e));return{context:{...f,account:{...f.account,keys:h}},digests:p}},async revokeAdmin(e){const{account:t,id:n,internal:r}=e,{store:s,request:i}=r;if("wallet_revokeAdmin"!==i.method)throw new Error("Cannot revoke admin for method: "+i.method);const a=t.keys?.find((e=>e.id===n));if(!a)return;if("webauthn-p256"===a.type&&1===t.keys?.filter((e=>"webauthn-p256"===e.type)).length)throw new Error("revoke the only WebAuthn key left.");const o=await iI(r,e),u=c(s);return await u.request({...i,params:[{...i.params?.[0],capabilities:{...i.params?.[0]?.capabilities,feeToken:o}}]})},async revokePermissions(e){const{account:t,id:n,internal:r}=e,{store:s,request:i}=r;if("wallet_revokePermissions"!==i.method)throw new Error("Cannot revoke permissions for method: "+i.method);const a=t.keys?.find((e=>e.id===n));if(!a)return;if("admin"===a.role)throw new Error("cannot revoke permissions.");const o=c(s);return await o.request(i)},async sendCalls(e){const{account:n,asTxHash:s,calls:i,internal:a,merchantUrl:o,requiredFunds:u}=e,{client:d,store:l,request:f}=a,p=c(l),h=await iI(a,e),m=await gx({account:n,calls:i,permissionsId:e.permissionsId});if(m&&"session"===m.role){if(!r.supportsHeadless)return t.actions.sendCalls(e);try{const e=await p.request(nh(rx.Request,{method:"wallet_prepareCalls",params:[{calls:i,capabilities:{..."wallet_sendCalls"===f._decoded.method?f._decoded.params?.[0]?.capabilities:void 0,feeToken:h,merchantUrl:o,requiredFunds:u},chainId:d.chain.id,from:n.address,key:m}]})),t=e.capabilities?.quote?.quotes??[],r=t.some(((e,n)=>!(n===t.length-1&&t.length>1)&&jf(e.feeTokenDeficit)>0n));if(r)throw new Error("insufficient funds");const a=await Sg(m,{address:null,payload:e.digest,wrap:!1}),c=(await p.request({method:"wallet_sendPreparedCalls",params:[{...e,signature:a}]}))[0];if(!c)throw new Error("id not found");if(s){const{id:e,receipts:t,status:n}=await Za(d,{id:c.id,pollingInterval:500});if(!t?.[0]){if("success"===n)throw new ql({message:"Call bundle with id: "+e+" not found."});throw new Il({message:"Transaction failed under call bundle id: "+e+"."})}return{id:t[0].transactionHash}}return c}catch{}}if("eth_sendTransaction"===f.method){return{id:await p.request({...f,params:[{...f.params?.[0],capabilities:{feeToken:h,merchantUrl:o}}]})}}if("wallet_sendCalls"===f.method){return await p.request({method:"wallet_sendCalls",params:[{...f.params?.[0],capabilities:{...f.params?.[0]?.capabilities,feeToken:h,merchantUrl:o}}]})}throw new Error("Cannot execute for method: "+f.method)},async sendPreparedCalls(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_sendPreparedCalls"!==i.method)throw new Error("Cannot send prepared calls for method: "+i.method);if(!r.supportsHeadless)return t.actions.sendPreparedCalls(e);const a=c(s),o=await a.request(i),u=o[0]?.id;if(!u)throw new Error("id not found");return u},async signPersonalMessage(e){const{internal:t}=e,{store:n,request:r}=t;if("personal_sign"!==r.method)throw new Error("Cannot sign personal message for method: "+r.method);const s=c(n);return await s.request(r)},async signTypedData(e){const{internal:t}=e,{store:n,request:r}=t;if("eth_signTypedData_v4"!==r.method)throw new Error("Cannot sign typed data for method: "+r.method);const s=c(n);return await s.request(r)},async switchChain(e){const{internal:t}=e,{store:n,request:s}=t;if("wallet_switchEthereumChain"!==s.method)throw new Error("Cannot switch chain for method: "+s.method);if(!r.supportsHeadless)return;const i=c(n);return await i.request(s)},async upgradeAccount(e){const{account:t,internal:n}=e,{store:r,request:s}=n;if("wallet_upgradeAccount"!==s.method)throw new Error("Cannot upgrade account for method: "+s.method);const i=c(r);return await i.request(s),{account:t}},async verifyEmail(e){const{internal:t}=e,{request:n,store:r}=t;if("account_verifyEmail"!==n.method)throw new Error("Cannot verify email for method: "+n.method);const s=c(r);return await s.request(n)}},config:e,name:"dialog",setup(e){const{internal:t}=e,{store:o}=t,c=r.setup({host:n,internal:t,theme:s,themeController:i}),u=o.subscribe((e=>e.requestQueue),(e=>{for(const t of a)t(e);const t=e.map((e=>"pending"===e.status?e:void 0)).filter(Boolean);c.syncRequests(t).catch((()=>{})),0===t.length&&c.close()}));return()=>{u(),c.destroy()}}})}({host:rf.prod}):sI(),relay:il("https://relay.wallet.risechain.com"),storage:II&&"undefined"!=typeof indexedDB?function(){const e="undefined"!=typeof indexedDB?wI("porto","store"):void 0;return{async getItem(t){const n=await function(e,t=xI()){return t("readonly",(t=>gI(t.get(e))))}(t,e);return null===n?null:n},async removeItem(t){await function(e,t=xI()){return t("readwrite",(t=>(t.delete(e),gI(t.transaction))))}(t,e)},async setItem(t,n){await function(e,t,n=xI()){return n("readwrite",(n=>(n.put(t,e),gI(n.transaction))))}(t,Ql(n),e)},sizeLimit:52428800}}():function(){const e=new Map;return{getItem:t=>e.get(t)??null,removeItem(t){e.delete(t)},setItem(t,n){e.set(t,n)},sizeLimit:Number.POSITIVE_INFINITY}}(),storageKey:"risewallet.store"};function zI(e){return t(this,void 0,void 0,(function*(){const e=function(e={}){const t=e.chains??PI.chains,n=Object.fromEntries(t.map((t=>[t.id,e.transports?.[t.id]??il()]))),r={announceProvider:e.announceProvider??PI.announceProvider,authUrl:e.authUrl,chains:t,feeToken:e.feeToken,merchantUrl:e.merchantUrl,mode:e.mode??PI.mode,relay:e.relay??PI.relay,storage:e.storage??PI.storage,storageKey:e.storageKey??PI.storageKey,transports:n},s=bI(dI(fI(mI((e=>({accounts:[],chainIds:r.chains.map((e=>e.id)),feeToken:r.feeToken,requestQueue:[]})),{merge(e,t){const n=e,s=r.chains.find((e=>e.id===n.chainIds[0]))?.id??r.chains[0].id,i=[s,...r.chains.map((e=>e.id)).filter((e=>e!==s))];return{...t,...n,chainIds:i}},name:r.storageKey,partialize:e=>({accounts:e.accounts.map((e=>Ql(e))),chainIds:e.chainIds}),storage:r.storage,version:5}))));let i=r.mode;const a={config:r,getMode:()=>i,id:Xl(),setMode:e=>(c?.(),i=e,c=e.setup({internal:a}),c),store:s},o=fx(a);let c=null!==i?i.setup({internal:a}):()=>{};return{_internal:a,config:r,destroy(){c(),o._internal.destroy()},provider:o}}();return e.provider}))}var EI=Object.freeze({__proto__:null,default:function(e,r){var s,i,a,o,c;return t(this,void 0,void 0,(function*(){const e=yield zI();if(!e)throw new Error("Failed to create Rise wallet provider");return null===(s=e.on)||void 0===s||s.call(e,"connect",r.connect),null===(i=e.on)||void 0===i||i.call(e,"disconnect",r.disconnect),null===(a=e.on)||void 0===a||a.call(e,"accountsChanged",r.accountsChanged),null===(o=e.on)||void 0===o||o.call(e,"chainChanged",r.chainChanged),null===(c=e.on)||void 0===c||c.call(e,"message",r.message),yield e.request({method:"eth_requestAccounts"}),n(e)}))}});export{he as A,ee as B,sr as H,we as I,de as a,ue as b,Xt as c,On as d,cn as e,Z as f,pn as g,fe as h,pe as i,fa as j,vn as k,Qn as l,Rn as m,_n as n,Vs as o,$a as p,Jt as q,W as r,en as s,fn as t,EI as u};
|
|
1
|
+
import{a1 as e,_ as t,A as n}from"./index-e2de6ccc.js";import"@ethersproject/address";class r extends Error{constructor(e,t={}){const n=t.cause instanceof r?t.cause.details:t.cause?.message?t.cause.message:t.details,s=t.cause instanceof r&&t.cause.docsPath||t.docsPath;super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...n?[`Details: ${n}`]:[],"Version: abitype@1.0.8"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),t.cause&&(this.cause=t.cause),this.details=n,this.docsPath=s,this.metaMessages=t.metaMessages,this.shortMessage=e}}function s(e,t){const n=e.exec(t);return n?.groups}const i=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,a=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,o=/^\(.+?\).*?$/,c=/^tuple(?<array>(\[(\d*)\])*)$/;function u(e){let t=e.type;if(c.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=u(e.components[r]),r<n-1&&(t+=", ")}const r=s(c,e.type);return t+=`)${r?.array??""}`,u({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function d(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=u(e[r]),r!==n-1&&(t+=", ")}return t}const l=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const f=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const p=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const h=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function m(e){return h.test(e)}function y(e){return s(h,e)}const b=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const g=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const w=/^receive\(\) external payable$/;const v=new Set(["indexed"]),x=new Set(["calldata","memory","storage"]);class I extends r{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class P extends r{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class z extends r{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class E extends r{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class A extends r{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class k extends r{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class M extends r{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class $ extends r{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class O extends r{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class j extends r{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class S extends r{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class N extends r{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const T=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function _(e,t={}){if(function(e){return p.test(e)}(e))return function(e,t={}){const n=function(e){return s(p,e)}(e);if(!n)throw new $({signature:e,type:"function"});const r=U(n.parameters),i=[],a=r.length;for(let e=0;e<a;e++)i.push(D(r[e],{modifiers:x,structs:t,type:"function"}));const o=[];if(n.returns){const e=U(n.returns),r=e.length;for(let n=0;n<r;n++)o.push(D(e[n],{modifiers:x,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:i,outputs:o}}(e,t);if(function(e){return f.test(e)}(e))return function(e,t={}){const n=function(e){return s(f,e)}(e);if(!n)throw new $({signature:e,type:"event"});const r=U(n.parameters),i=[],a=r.length;for(let e=0;e<a;e++)i.push(D(r[e],{modifiers:v,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:i}}(e,t);if(function(e){return l.test(e)}(e))return function(e,t={}){const n=function(e){return s(l,e)}(e);if(!n)throw new $({signature:e,type:"error"});const r=U(n.parameters),i=[],a=r.length;for(let e=0;e<a;e++)i.push(D(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:i}}(e,t);if(function(e){return b.test(e)}(e))return function(e,t={}){const n=function(e){return s(b,e)}(e);if(!n)throw new $({signature:e,type:"constructor"});const r=U(n.parameters),i=[],a=r.length;for(let e=0;e<a;e++)i.push(D(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:i}}(e,t);if(function(e){return g.test(e)}(e))return function(e){const t=function(e){return s(g,e)}(e);if(!t)throw new $({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return w.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new O({signature:e})}const R=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,C=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,B=/^u?int$/;function D(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:e}(e,t?.type,t?.structs);if(T.has(n))return T.get(n);const r=o.test(e),c=s(r?C:R,e);if(!c)throw new z({param:e});if(c.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||i.test(e)||a.test(e)||L.test(e)}(c.name))throw new E({param:e,name:c.name});const u=c.name?{name:c.name}:{},d="indexed"===c.modifier?{indexed:!0}:{},l=t?.structs??{};let f,p={};if(r){f="tuple";const e=U(c.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(D(e[r],{structs:l}));p={components:t}}else if(c.type in l)f="tuple",p={components:l[c.type]};else if(B.test(c.type))f=`${c.type}256`;else if(f=c.type,"struct"!==t?.type&&!q(f))throw new P({type:f});if(c.modifier){if(!t?.modifiers?.has?.(c.modifier))throw new A({param:e,type:t?.type,modifier:c.modifier});if(x.has(c.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(f,!!c.array))throw new k({param:e,type:t?.type,modifier:c.modifier})}const h={type:`${f}${c.array??""}`,...u,...d,...p};return T.set(n,h),h}function U(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const s=e[i],a=e.slice(i+1);switch(s){case",":return 0===r?U(a,[...t,n.trim()]):U(a,t,`${n}${s}`,r);case"(":return U(a,t,`${n}${s}`,r+1);case")":return U(a,t,`${n}${s}`,r-1);default:return U(a,t,`${n}${s}`,r)}}if(""===n)return t;if(0!==r)throw new N({current:n,depth:r});return t.push(n.trim()),t}function q(e){return"address"===e||"bool"===e||"function"===e||"string"===e||i.test(e)||a.test(e)}const L=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;const F=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function K(e,t,n=new Set){const r=[],i=e.length;for(let a=0;a<i;a++){const i=e[a];if(o.test(i.type))r.push(i);else{const e=s(F,i.type);if(!e?.type)throw new M({abiParameter:i});const{array:a,type:o}=e;if(o in t){if(n.has(o))throw new S({type:o});r.push({...i,type:`tuple${a??""}`,components:K(t[o]??[],t,new Set([...n,o]))})}else{if(!q(o))throw new I({type:o});r.push(i)}}}return r}function V(e){const t=function(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!m(n))continue;const s=y(n);if(!s)throw new $({signature:n,type:"struct"});const i=s.properties.split(";"),a=[],o=i.length;for(let e=0;e<o;e++){const t=i[e].trim();if(!t)continue;const n=D(t,{type:"struct"});a.push(n)}if(!a.length)throw new j({signature:n});t[s.name]=a}const r={},s=Object.entries(t),i=s.length;for(let e=0;e<i;e++){const[n,i]=s[e];r[n]=K(i,t)}return r}(e),n=[],r=e.length;for(let s=0;s<r;s++){const r=e[s];m(r)||n.push(_(r,t))}return n}function G(e,t,n){const r=e[t.name];if("function"==typeof r)return r;const s=e[n];return"function"==typeof s?s:n=>t(e,n)}function Z(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new ve(e.type);return`${e.name}(${H(e.inputs,{includeName:t})})`}function H(e,{includeName:t=!1}={}){return e?e.map((e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${H(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t}))).join(t?", ":","):""}function W(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function Y(e){return W(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Q="2.37.0";let J=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,X=`viem@${Q}`;class ee extends Error{constructor(e,t={}){const n=t.cause instanceof ee?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof ee&&t.cause.docsPath||t.docsPath,s=J?.({...t,docsPath:r});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...X?[`Version: ${X}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=Q}walk(e){return te(this,e)}}function te(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?te(e.cause,t):t?null:e}class ne extends ee{constructor({docsPath:e}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join("\n"),{docsPath:e,name:"AbiConstructorNotFoundError"})}}class re extends ee{constructor({docsPath:e}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join("\n"),{docsPath:e,name:"AbiConstructorParamsNotFoundError"})}}class se extends ee{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${H(t,{includeName:!0})})`,`Data: ${e} (${n} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=t,this.size=n}}class ie extends ee{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class ae extends ee{constructor({expectedLength:e,givenLength:t,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${e}`,`Given length: ${t}`].join("\n"),{name:"AbiEncodingArrayLengthMismatchError"})}}class oe extends ee{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Y(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class ce extends ee{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${t}`].join("\n"),{name:"AbiEncodingLengthMismatchError"})}}class ue extends ee{constructor(e,{docsPath:t}){super([`Arguments (\`args\`) were provided to "${e}", but "${e}" on the ABI does not contain any parameters (\`inputs\`).`,"Cannot encode error result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the inputs exist on it."].join("\n"),{docsPath:t,name:"AbiErrorInputsNotFoundError"})}}class de extends ee{constructor(e,{docsPath:t}={}){super([`Error ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join("\n"),{docsPath:t,name:"AbiErrorNotFoundError"})}}class le extends ee{constructor(e,{docsPath:t}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join("\n"),{docsPath:t,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class fe extends ee{constructor(e,{docsPath:t}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:t,name:"AbiFunctionNotFoundError"})}}class pe extends ee{constructor(e,{docsPath:t}){super([`Function "${e}" does not contain any \`outputs\` on ABI.`,"Cannot decode function result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:t,name:"AbiFunctionOutputsNotFoundError"})}}class he extends ee{constructor(e,{docsPath:t}){super([`Encoded function signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${e}.`].join("\n"),{docsPath:t,name:"AbiFunctionSignatureNotFoundError"})}}class me extends ee{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${Z(e.abiItem)}\`, and`,`\`${t.type}\` in \`${Z(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class ye extends ee{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}}class be extends ee{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiEncodingType"})}}class ge extends ee{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiDecodingType"})}}class we extends ee{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}}class ve extends ee{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class xe extends ee{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class Ie extends ee{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}class Pe extends ee{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function ze(e,{dir:t,size:n=32}={}){return"string"==typeof e?Ee(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new Ie({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i="right"===t;r[i?s:n-s-1]=e[i?s:e.length-s-1]}return r}(e,{dir:t,size:n})}function Ee(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new Ie({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}class Ae extends ee{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number "${s}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class ke extends ee{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class Me extends ee{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class $e extends ee{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Oe(e,{dir:t="left"}={}){let n="string"==typeof e?e.replace("0x",""):e,r=0;for(let e=0;e<n.length-1&&"0"===n["left"===t?e:n.length-e-1].toString();e++)r++;return n="left"===t?n.slice(r):n.slice(0,n.length-r),"string"==typeof e?(1===n.length&&"right"===t&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}function je(e,{size:t}){if(Y(e)>t)throw new $e({givenSize:Y(e),maxSize:t})}function Se(e,t={}){const{signed:n}=t;t.size&&je(e,{size:t.size});const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2;return r<=(1n<<8n*BigInt(s)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*s,"f")}`)-1n}function Ne(e,t={}){return Number(Se(e,t))}const Te=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function _e(e,t={}){return"number"==typeof e||"bigint"==typeof e?Be(e,t):"string"==typeof e?Ue(e,t):"boolean"==typeof e?Re(e,t):Ce(e,t)}function Re(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(je(n,{size:t.size}),ze(n,{size:t.size})):n}function Ce(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Te[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(je(r,{size:t.size}),ze(r,{dir:"right",size:t.size})):r}function Be(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new Ae({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?(1n<<BigInt(8*r))+BigInt(s):s).toString(16)}`;return r?ze(o,{size:r}):o}const De=new TextEncoder;function Ue(e,t={}){return Ce(De.encode(e),t)}const qe=new TextEncoder;function Le(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=Be(e,t);return Ve(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return je(n,{size:t.size}),ze(n,{size:t.size});return n}(e,t):W(e)?Ve(e,t):Ge(e,t)}const Fe={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ke(e){return e>=Fe.zero&&e<=Fe.nine?e-Fe.zero:e>=Fe.A&&e<=Fe.F?e-(Fe.A-10):e>=Fe.a&&e<=Fe.f?e-(Fe.a-10):void 0}function Ve(e,t={}){let n=e;t.size&&(je(n,{size:t.size}),n=ze(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let e=0,t=0;e<s;e++){const n=Ke(r.charCodeAt(t++)),s=Ke(r.charCodeAt(t++));if(void 0===n||void 0===s)throw new ee(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);i[e]=16*n+s}return i}function Ge(e,t={}){const n=qe.encode(e);return"number"==typeof t.size?(je(n,{size:t.size}),ze(n,{dir:"right",size:t.size})):n}const Ze=BigInt(2**32-1),He=BigInt(32);function We(e,t=!1){return t?{h:Number(e&Ze),l:Number(e>>He&Ze)}:{h:0|Number(e>>He&Ze),l:0|Number(e&Ze)}}function Ye(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:a}=We(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]}const Qe=(e,t,n)=>e>>>n,Je=(e,t,n)=>e<<32-n|t>>>n,Xe=(e,t,n)=>e>>>n|t<<32-n,et=(e,t,n)=>e<<32-n|t>>>n,tt=(e,t,n)=>e<<64-n|t>>>n-32,nt=(e,t,n)=>e>>>n-32|t<<64-n;function rt(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:0|s}}const st=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),it=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,at=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),ot=(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,ct=(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0),ut=(e,t,n,r,s,i)=>t+n+r+s+i+(e/2**32|0)|0,dt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function lt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ft(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function pt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ht(e,t){ft(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function mt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function yt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function bt(e,t){return e<<32-t|e>>>t}const gt=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let n=0;n<e.length;n++)e[n]=(t=e[n])<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;var t;return e};function wt(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),ft(e),e}class vt{}function xt(e){const t=t=>e().update(wt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function It(e=32){if(dt&&"function"==typeof dt.getRandomValues)return dt.getRandomValues(new Uint8Array(e));if(dt&&"function"==typeof dt.randomBytes)return Uint8Array.from(dt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const Pt=BigInt(0),zt=BigInt(1),Et=BigInt(2),At=BigInt(7),kt=BigInt(256),Mt=BigInt(113),$t=[],Ot=[],jt=[];for(let e=0,t=zt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],$t.push(2*(5*r+n)),Ot.push((e+1)*(e+2)/2%64);let s=Pt;for(let e=0;e<7;e++)t=(t<<zt^(t>>At)*Mt)%kt,t&Et&&(s^=zt<<(zt<<BigInt(e))-zt);jt.push(s)}const St=Ye(jt,!0),Nt=St[0],Tt=St[1],_t=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),Rt=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class Ct extends vt{constructor(e,t,n,r=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=s,lt(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var i;this.state=new Uint8Array(200),this.state32=(i=this.state,new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)))}clone(){return this._cloneInto()}keccak(){gt(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,s=(t+2)%10,i=n[s],a=n[s+1],o=_t(i,a,1)^n[r],c=Rt(i,a,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=c}let t=e[2],s=e[3];for(let n=0;n<24;n++){const r=Ot[n],i=_t(t,s,r),a=Rt(t,s,r),o=$t[n];t=e[o],s=e[o+1],e[o]=i,e[o+1]=a}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=Nt[r],e[1]^=Tt[r]}mt(n)}(this.state32,this.rounds),gt(this.state32),this.posOut=0,this.pos=0}update(e){pt(this),ft(e=wt(e));const{blockLen:t,state:n}=this,r=e.length;for(let s=0;s<r;){const i=Math.min(t-this.pos,r-s);for(let t=0;t<i;t++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,0!=(128&t)&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){pt(this,!1),ft(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,s=e.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return lt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ht(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,mt(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return e||(e=new Ct(t,n,r,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}const Bt=(()=>{return e=1,t=136,n=32,xt((()=>new Ct(t,e,n)));var e,t,n})();function Dt(e,t){const n=t||"hex",r=Bt(W(e,{strict:!1})?Le(e):e);return"bytes"===n?r:_e(r)}const Ut=e=>Dt(Le(e));const qt=e=>{var t;return function(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),"("===o&&r++,")"===o&&r--,t)if(0!==r)" "!==o?(s+=o,n+=o):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===o&&["event","function",""].includes(s))s="";else if(s+=o,")"===o){i=!0;break}}if(!i)throw new ee("Unable to normalize signature.");return s}("string"==typeof e?e:"function"===(t=e).type?`function ${t.name}(${d(t.inputs)})${t.stateMutability&&"nonpayable"!==t.stateMutability?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${d(t.outputs)})`:""}`:"event"===t.type?`event ${t.name}(${d(t.inputs)})`:"error"===t.type?`error ${t.name}(${d(t.inputs)})`:"constructor"===t.type?`constructor(${d(t.inputs)})${"payable"===t.stateMutability?" payable":""}`:"fallback"===t.type?"fallback() external"+("payable"===t.stateMutability?" payable":""):"receive() external payable")};function Lt(e){return t=qt(e),Ut(t);var t}const Ft=Lt;class Kt extends ee{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Vt extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const Gt=new Vt(8192);function Zt(e,t){if(Gt.has(`${e}.${t}`))return Gt.get(`${e}.${t}`);const n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Dt(Ge(n),"bytes"),s=(t?n.substring(`${t}0x`.length):n).split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&s[e]&&(s[e]=s[e].toUpperCase()),(15&r[e>>1])>=8&&s[e+1]&&(s[e+1]=s[e+1].toUpperCase());const i=`0x${s.join("")}`;return Gt.set(`${e}.${t}`,i),i}function Ht(e,t){if(!Qt(e,{strict:!1}))throw new Kt({address:e});return Zt(e,t)}const Wt=/^0x[a-fA-F0-9]{40}$/,Yt=new Vt(8192);function Qt(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Yt.has(r))return Yt.get(r);const s=!(!Wt.test(e)||e.toLowerCase()!==e&&n&&Zt(e)!==e);return Yt.set(r,s),s}function Jt(e){return"string"==typeof e[0]?Xt(e):function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(e)}function Xt(e){return`0x${e.reduce(((e,t)=>e+t.replace("0x","")),"")}`}function en(e,t,n,{strict:r}={}){return W(e,{strict:!1})?sn(e,t,n,{strict:r}):rn(e,t,n,{strict:r})}function tn(e,t){if("number"==typeof t&&t>0&&t>Y(e)-1)throw new xe({offset:t,position:"start",size:Y(e)})}function nn(e,t,n){if("number"==typeof t&&"number"==typeof n&&Y(e)!==n-t)throw new xe({offset:n,position:"end",size:Y(e)})}function rn(e,t,n,{strict:r}={}){tn(e,t);const s=e.slice(t,n);return r&&nn(s,t,n),s}function sn(e,t,n,{strict:r}={}){tn(e,t);const s=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return r&&nn(s,t,n),s}const an=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,on=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function cn(e,t){if(e.length!==t.length)throw new ce({expectedLength:e.length,givenLength:t.length});const n=function({params:e,values:t}){const n=[];for(let r=0;r<e.length;r++)n.push(un({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=dn(n);return 0===r.length?"0x":r}function un({param:e,value:t}){const n=ln(e.type);if(n){const[r,s]=n;return function(e,{length:t,param:n}){const r=null===t;if(!Array.isArray(e))throw new we(e);if(!r&&e.length!==t)throw new ae({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let s=!1;const i=[];for(let t=0;t<e.length;t++){const r=un({param:n,value:e[t]});r.dynamic&&(s=!0),i.push(r)}if(r||s){const e=dn(i);if(r){const t=Be(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?Jt([t,e]):t}}if(s)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Jt(i.map((({encoded:e})=>e)))}}(t,{length:r,param:{...e,type:s}})}if("tuple"===e.type)return function(e,{param:t}){let n=!1;const r=[];for(let s=0;s<t.components.length;s++){const i=t.components[s],a=un({param:i,value:e[Array.isArray(e)?s:i.name]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?dn(r):Jt(r.map((({encoded:e})=>e)))}}(t,{param:e});if("address"===e.type)return function(e){if(!Qt(e))throw new Kt({address:e});return{dynamic:!1,encoded:Ee(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new ee(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Ee(Re(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=on.exec(e.type)??[];return function(e,{signed:t,size:n=256}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new Ae({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Be(e,{size:32,signed:t})}}(t,{signed:n,size:Number(r)})}if(e.type.startsWith("bytes"))return function(e,{param:t}){const[,n]=t.type.split("bytes"),r=Y(e);if(!n){let t=e;return r%32!=0&&(t=Ee(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:Jt([Ee(Be(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new oe({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:Ee(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=Ue(e),n=Math.ceil(Y(t)/32),r=[];for(let e=0;e<n;e++)r.push(Ee(en(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:Jt([Ee(Be(Y(t),{size:32})),...r])}}(t);throw new be(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function dn(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:s}=e[n];t+=r?32:Y(s)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(Be(t+s,{size:32})),r.push(o),s+=Y(o)):n.push(o)}return Jt([...n,...r])}function ln(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const fn=e=>en(Lt(e),0,4);function pn(e){const{abi:t,args:n=[],name:r}=e,s=W(r,{strict:!1}),i=t.filter((e=>s?"function"===e.type?fn(e)===r:"event"===e.type&&Ft(e)===r:"name"in e&&e.name===r));if(0===i.length)return;if(1===i.length)return i[0];let a;for(const e of i){if(!("inputs"in e))continue;if(!n||0===n.length){if(!e.inputs||0===e.inputs.length)return e;continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==n.length)continue;const t=n.every(((t,n)=>{const r="inputs"in e&&e.inputs[n];return!!r&&hn(t,r)}));if(t){if(a&&"inputs"in a&&a.inputs){const t=mn(e.inputs,a.inputs,n);if(t)throw new me({abiItem:e,type:t[0]},{abiItem:a,type:t[1]})}a=e}}return a||i[0]}function hn(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Qt(e,{strict:!1});case"bool":return"boolean"===n;case"function":case"string":return"string"===n;default:return"tuple"===r&&"components"in t?Object.values(t.components).every(((t,n)=>hn(Object.values(e)[n],t))):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?"number"===n||"bigint"===n:/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?"string"===n||e instanceof Uint8Array:!!/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)&&(Array.isArray(e)&&e.every((e=>hn(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")}))))}}function mn(e,t,n){for(const r in e){const s=e[r],i=t[r];if("tuple"===s.type&&"tuple"===i.type&&"components"in s&&"components"in i)return mn(s.components,i.components,n[r]);const a=[s.type,i.type];if(!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&Qt(n[r],{strict:!1}))return a}}function yn(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const bn="/docs/contract/encodeFunctionData";function gn(e){const{args:t}=e,{abi:n,functionName:r}=1===e.abi.length&&e.functionName?.startsWith("0x")?e:function(e){const{abi:t,args:n,functionName:r}=e;let s=t[0];if(r){const e=pn({abi:t,args:n,name:r});if(!e)throw new fe(r,{docsPath:bn});s=e}if("function"!==s.type)throw new fe(void 0,{docsPath:bn});return{abi:[s],functionName:fn(Z(s))}}(e),s=n[0];return Xt([r,("inputs"in s&&s.inputs?cn(s.inputs,t??[]):void 0)??"0x"])}const wn={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},vn={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},xn={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};class In extends ee{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class Pn extends ee{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class zn extends ee{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const En={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new zn({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Pn({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new In({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new In({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function An(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(En);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function kn(e,t={}){void 0!==t.size&&je(e,{size:t.size});return Se(Ce(e,t),t)}function Mn(e,t={}){let n=e;if(void 0!==t.size&&(je(n,{size:t.size}),n=Oe(n)),n.length>1||n[0]>1)throw new ke(n);return Boolean(n[0])}function $n(e,t={}){void 0!==t.size&&je(e,{size:t.size});return Ne(Ce(e,t),t)}function On(e,t){const n="string"==typeof t?Ve(t):t,r=An(n);if(0===Y(n)&&e.length>0)throw new ie;if(Y(t)&&Y(t)<32)throw new se({data:"string"==typeof t?t:Ce(t),params:e,size:Y(t)});let s=0;const i=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(s);const[a,o]=jn(r,n,{staticPosition:0});s+=o,i.push(a)}return i}function jn(e,t,{staticPosition:n}){const r=ln(t.type);if(r){const[s,i]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+$n(e.readBytes(Nn)),s=n+Sn;e.setPosition(n);const i=$n(e.readBytes(Sn)),a=Tn(t);let o=0;const c=[];for(let n=0;n<i;++n){e.setPosition(s+(a?32*n:o));const[r,i]=jn(e,t,{staticPosition:s});o+=i,c.push(r)}return e.setPosition(r+32),[c,32]}if(Tn(t)){const s=r+$n(e.readBytes(Nn)),i=[];for(let r=0;r<n;++r){e.setPosition(s+32*r);const[n]=jn(e,t,{staticPosition:s});i.push(n)}return e.setPosition(r+32),[i,32]}let s=0;const i=[];for(let a=0;a<n;++a){const[n,a]=jn(e,t,{staticPosition:r+s});s+=a,i.push(n)}return[i,s]}(e,{...t,type:i},{length:s,staticPosition:n})}if("tuple"===t.type)return function(e,t,{staticPosition:n}){const r=0===t.components.length||t.components.some((({name:e})=>!e)),s=r?[]:{};let i=0;if(Tn(t)){const a=n+$n(e.readBytes(Nn));for(let n=0;n<t.components.length;++n){const o=t.components[n];e.setPosition(a+i);const[c,u]=jn(e,o,{staticPosition:a});i+=u,s[r?n:o?.name]=c}return e.setPosition(n+32),[s,32]}for(let a=0;a<t.components.length;++a){const o=t.components[a],[c,u]=jn(e,o,{staticPosition:n});s[r?a:o?.name]=c,i+=u}return[s,i]}(e,t,{staticPosition:n});if("address"===t.type)return function(e){const t=e.readBytes(32);return[Zt(Ce(rn(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[Mn(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const t=$n(e.readBytes(32));e.setPosition(n+t);const r=$n(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const s=e.readBytes(r);return e.setPosition(n+32),[Ce(s),32]}const i=Ce(e.readBytes(Number.parseInt(s,10),32));return[i,32]}(e,t,{staticPosition:n});if(t.type.startsWith("uint")||t.type.startsWith("int"))return function(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),s=e.readBytes(32);return[r>48?kn(s,{signed:n}):$n(s,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=$n(e.readBytes(32)),r=t+n;e.setPosition(r);const s=$n(e.readBytes(32));if(0===s)return e.setPosition(t+32),["",32];const i=e.readBytes(s,32),a=function(e,t={}){let n=e;return void 0!==t.size&&(je(n,{size:t.size}),n=Oe(n,{dir:"right"})),(new TextDecoder).decode(n)}(Oe(i));return e.setPosition(t+32),[a,32]}(e,{staticPosition:n});throw new ge(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Sn=32,Nn=32;function Tn(e){const{type:t}=e;if("string"===t)return!0;if("bytes"===t)return!0;if(t.endsWith("[]"))return!0;if("tuple"===t)return e.components?.some(Tn);const n=ln(e.type);return!(!n||!Tn({...e,type:n[1]}))}function _n(e){const{abi:t,data:n}=e,r=en(n,0,4);if("0x"===r)throw new ie;const s=[...t||[],vn,xn].find((e=>"error"===e.type&&r===fn(Z(e))));if(!s)throw new le(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:s,args:"inputs"in s&&s.inputs&&s.inputs.length>0?On(s.inputs,en(n,4)):void 0,errorName:s.name}}const Rn=(e,t,n)=>JSON.stringify(e,((e,n)=>{const r="bigint"==typeof n?n.toString():n;return"function"==typeof t?t(e,r):r}),n);function Cn({abiItem:e,args:t,includeFunctionName:n=!0,includeName:r=!1}){if("name"in e&&"inputs"in e&&e.inputs)return`${n?e.name:""}(${e.inputs.map(((e,n)=>`${r&&e.name?`${e.name}: `:""}${"object"==typeof t[n]?Rn(t[n]):t[n]}`)).join(", ")})`}const Bn={gwei:9,wei:18},Dn={ether:-9,wei:9};function Un(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[s,i]=[n.slice(0,n.length-t),n.slice(n.length-t)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function qn(e,t="wei"){return Un(e,Bn[t])}function Ln(e,t="wei"){return Un(e,Dn[t])}class Fn extends ee{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Kn extends ee{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Vn(e){return e.reduce(((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`),"")}function Gn(e){const t=Object.entries(e).map((([e,t])=>void 0===t||!1===t?null:[e,t])).filter(Boolean),n=t.reduce(((e,[t])=>Math.max(e,t.length)),0);return t.map((([e,t])=>` ${`${e}:`.padEnd(n+1)} ${t}`)).join("\n")}class Zn extends ee{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join("\n"),{name:"FeeConflictError"})}}class Hn extends ee{constructor({v:e}){super(`Invalid \`v\` value "${e}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class Wn extends ee{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Gn(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class Yn extends ee{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${Math.floor((e.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}const Qn=e=>e;class Jn extends ee{constructor(e,{account:t,docsPath:n,chain:r,data:s,gas:i,gasPrice:a,maxFeePerGas:o,maxPriorityFeePerGas:c,nonce:u,to:d,value:l,stateOverride:f}){const p=t?yn(t):void 0;let h=Gn({from:p?.address,to:d,value:void 0!==l&&`${qn(l)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:s,gas:i,gasPrice:void 0!==a&&`${Ln(a)} gwei`,maxFeePerGas:void 0!==o&&`${Ln(o)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Ln(c)} gwei`,nonce:u});f&&(h+=`\n${function(e){return e.reduce(((e,{address:t,...n})=>{let r=`${e} ${t}:\n`;return n.nonce&&(r+=` nonce: ${n.nonce}\n`),n.balance&&(r+=` balance: ${n.balance}\n`),n.code&&(r+=` code: ${n.code}\n`),n.state&&(r+=" state:\n",r+=Vn(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Vn(n.stateDiff)),r})," State Override:\n").slice(0,-1)}(f)}`),super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Raw Call Arguments:",h].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class Xn extends ee{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:s,functionName:i,sender:a}){const o=pn({abi:t,args:n,name:i}),c=o?Cn({abiItem:o,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=Gn({address:r&&r,function:o?Z(o,{includeName:!0}):void 0,args:c&&"()"!==c&&`${[...Array(i?.length??0).keys()].map((()=>" ")).join("")}${c}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${i}".`,{cause:e,docsPath:s,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],u&&"Contract Call:",u].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=t,this.args=n,this.cause=e,this.contractAddress=r,this.functionName=i,this.sender=a}}class er extends ee{constructor({abi:e,data:t,functionName:n,message:r}){let s,i,a,o,c;if(t&&"0x"!==t)try{i=_n({abi:e,data:t});const{abiItem:n,errorName:r,args:s}=i;if("Error"===r)o=s[0];else if("Panic"===r){const[e]=s;o=wn[e]}else{const e=n?Z(n,{includeName:!0}):void 0,t=n&&s?Cn({abiItem:n,args:s,includeFunctionName:!1,includeName:!1}):void 0;a=[e?`Error: ${e}`:"",t&&"()"!==t?` ${[...Array(r?.length??0).keys()].map((()=>" ")).join("")}${t}`:""]}}catch(e){s=e}else r&&(o=r);s instanceof le&&(c=s.signature,a=[`Unable to decode signature "${c}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${c}.`]),super(o&&"execution reverted"!==o||c?[`The contract function "${n}" reverted with the following ${c?"signature":"reason"}:`,o||c].join("\n"):`The contract function "${n}" reverted.`,{cause:s,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=i,this.raw=t,this.reason=o,this.signature=c}}class tr extends ee{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class nr extends ee{constructor({factory:e}){super("Deployment for counterfactual contract call failed"+(e?` for factory "${e}".`:""),{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class rr extends ee{constructor({data:e,message:t}){super(t||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e}}class sr extends ee{constructor({body:e,cause:t,details:n,headers:r,status:s,url:i}){super("HTTP request failed.",{cause:t,details:n,metaMessages:[s&&`Status: ${s}`,`URL: ${i}`,e&&`Request body: ${Rn(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=r,this.status=s,this.url=i}}class ir extends ee{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${Rn(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t.code,this.data=t.data}}class ar extends ee{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${Rn(e)}`],name:"TimeoutError"})}}class or extends ee{constructor(e,{code:t,docsPath:n,metaMessages:r,name:s,shortMessage:i}){super(i,{cause:e,docsPath:n,metaMessages:r||e?.metaMessages,name:s||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=s||e.name,this.code=e instanceof ir?e.code:t??-1}}class cr extends or{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class ur extends or{constructor(e){super(e,{code:ur.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(ur,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class dr extends or{constructor(e){super(e,{code:dr.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(dr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class lr extends or{constructor(e,{method:t}={}){super(e,{code:lr.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(lr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class fr extends or{constructor(e){super(e,{code:fr.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(fr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class pr extends or{constructor(e){super(e,{code:pr.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class hr extends or{constructor(e){super(e,{code:hr.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(hr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class mr extends or{constructor(e){super(e,{code:mr.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(mr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class yr extends or{constructor(e){super(e,{code:yr.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(yr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class br extends or{constructor(e){super(e,{code:br.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(br,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class gr extends or{constructor(e,{method:t}={}){super(e,{code:gr.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(gr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class wr extends or{constructor(e){super(e,{code:wr.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(wr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class vr extends or{constructor(e){super(e,{code:vr.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(vr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class xr extends cr{constructor(e){super(e,{code:xr.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Ir extends cr{constructor(e){super(e,{code:Ir.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Pr extends cr{constructor(e,{method:t}={}){super(e,{code:Pr.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(Pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class zr extends cr{constructor(e){super(e,{code:zr.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(zr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Er extends cr{constructor(e){super(e,{code:Er.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(Er,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Ar extends cr{constructor(e){super(e,{code:Ar.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Ar,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class kr extends cr{constructor(e){super(e,{code:kr.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(kr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Mr extends cr{constructor(e){super(e,{code:Mr.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Mr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class $r extends cr{constructor(e){super(e,{code:$r.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty($r,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class Or extends cr{constructor(e){super(e,{code:Or.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(Or,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class jr extends cr{constructor(e){super(e,{code:jr.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(jr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Sr extends cr{constructor(e){super(e,{code:Sr.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Sr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Nr extends cr{constructor(e){super(e,{code:Nr.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Nr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Tr extends or{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const _r=3;function Rr(e,{abi:t,address:n,args:r,docsPath:s,functionName:i,sender:a}){const o=e instanceof rr?e:e instanceof ee?e.walk((e=>"data"in e))||e.walk():{},{code:c,data:u,details:d,message:l,shortMessage:f}=o,p=e instanceof ie?new tr({functionName:i}):[_r,pr.code].includes(c)&&(u||d||l||f)?new er({abi:t,data:"object"==typeof u?u.data:u,functionName:i,message:o instanceof ir?d:f??l}):e;return new Xn(p,{abi:t,args:r,contractAddress:n,docsPath:s,functionName:i,sender:a})}function Cr(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw new Error("Invalid yParityOrV value")}async function Br({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=W(e)?e:_e(e),{secp256k1:r}=await Promise.resolve().then((function(){return jd}));return`0x${(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:s,yParity:i}=t,a=Cr(Number(i??s));return new r.Signature(Se(e),Se(n)).addRecoveryBit(a)}const e=W(t)?t:_e(t);if(65!==Y(e))throw new Error("invalid signature length");const n=Cr(Ne(`0x${e.slice(130)}`));return r.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(n)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}({hash:e,signature:t}),Zt(`0x${Dt(`0x${n.substring(4)}`).substring(26)}`);var n}function Dr(e,t="hex"){const n=Ur(e),r=An(new Uint8Array(n.length));return n.encode(r),"hex"===t?Ce(r.bytes):r.bytes}function Ur(e){return Array.isArray(e)?function(e){const t=e.reduce(((e,t)=>e+t.length),0),n=qr(t);return{length:t<=55?1+t:1+n+t,encode(r){t<=55?r.pushByte(192+t):(r.pushByte(247+n),1===n?r.pushUint8(t):2===n?r.pushUint16(t):3===n?r.pushUint24(t):r.pushUint32(t));for(const{encode:t}of e)t(r)}}}(e.map((e=>Ur(e)))):function(e){const t="string"==typeof e?Ve(e):e,n=qr(t.length),r=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length;return{length:r,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+n),1===n?e.pushUint8(t.length):2===n?e.pushUint16(t.length):3===n?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function qr(e){if(e<256)return 1;if(e<65536)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new ee("Length is too large.")}function Lr(e){const{chainId:t,nonce:n,to:r}=e,s=e.contractAddress??e.address,i=Dt(Xt(["0x05",Dr([t?Be(t):"0x",s,n?Be(n):"0x"])]));return"bytes"===r?Ve(i):i}class Fr extends ee{constructor({cause:e,message:t}={}){const n=t?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Fr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Fr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Kr extends ee{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Ln(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Kr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class Vr extends ee{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Ln(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(Vr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class Gr extends ee{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(Gr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Zr extends ee{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join("\n"),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(Zr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Hr extends ee{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Wr extends ee{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join("\n"),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(Wr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Yr extends ee{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(Yr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Qr extends ee{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(Qr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Jr extends ee{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Xr extends ee{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${Ln(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Ln(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Xr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class es extends ee{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function ts(e,{format:t}){if(!t)return{};const n={};return function t(r){const s=Object.keys(r);for(const i of s)i in e&&(n[i]=e[i]),r[i]&&"object"==typeof r[i]&&!Array.isArray(r[i])&&t(r[i])}(t(e||{})),n}function ns(e,t){return({exclude:n,format:r})=>({exclude:n,format:e=>{const s=t(e);if(n)for(const e of n)delete s[e];return{...s,...r(e)}},type:e})}const rs={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function ss(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map((e=>({address:e.address,r:e.r?Be(BigInt(e.r)):e.r,s:e.s?Be(BigInt(e.s)):e.s,chainId:Be(e.chainId),nonce:Be(e.nonce),...void 0!==e.yParity?{yParity:Be(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:Be(e.v)}:{}})))),void 0!==e.accessList&&(t.accessList=e.accessList),void 0!==e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes),void 0!==e.blobs&&("string"!=typeof e.blobs[0]?t.blobs=e.blobs.map((e=>Ce(e))):t.blobs=e.blobs),void 0!==e.data&&(t.data=e.data),void 0!==e.from&&(t.from=e.from),void 0!==e.gas&&(t.gas=Be(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=Be(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=Be(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Be(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Be(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Be(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=rs[e.type]),void 0!==e.value&&(t.value=Be(e.value)),t}function is(e){if(e&&0!==e.length)return e.reduce(((e,{slot:t,value:n})=>{if(66!==t.length)throw new Pe({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new Pe({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e}),{})}function as(e){const{balance:t,nonce:n,state:r,stateDiff:s,code:i}=e,a={};if(void 0!==i&&(a.code=i),void 0!==t&&(a.balance=Be(t)),void 0!==n&&(a.nonce=Be(n)),void 0!==r&&(a.state=is(r)),void 0!==s){if(a.state)throw new Kn;a.stateDiff=is(s)}return a}const os=2n**256n-1n;const cs={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function us(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Ne(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?Ne(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?cs[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(t.authorizationList=e.authorizationList.map((e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)})))),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if("bigint"==typeof t.v){if(0n===t.v||27n===t.v)return 0;if(1n===t.v||28n===t.v)return 1;if(t.v>=35n)return t.v%2n===0n?1:0}})(),"legacy"===t.type&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),"eip2930"===t.type&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),"eip1559"===t.type&&delete t.maxFeePerBlobGas,t}const ds=ns("transaction",us);function ls(e){const t=(e.transactions??[]).map((e=>"string"==typeof e?e:us(e)));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:t,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const fs=ns("block",ls);function ps(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map((e=>Ve(e))):e.blobs,s=[];for(const e of r)s.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?s:s.map((e=>Ce(e)))}function hs(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map((e=>Ve(e))):e.blobs,s="string"==typeof e.commitments[0]?e.commitments.map((e=>Ve(e))):e.commitments,i=[];for(let e=0;e<r.length;e++){const n=r[e],a=s[e];i.push(Uint8Array.from(t.computeBlobKzgProof(n,a)))}return"bytes"===n?i:i.map((e=>Ce(e)))}function ms(e,t,n){return e&t^e&n^t&n}class ys extends vt{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=yt(this.buffer)}update(e){pt(this),ft(e=wt(e));const{view:t,buffer:n,blockLen:r}=this,s=e.length;for(let i=0;i<s;){const a=Math.min(r-this.pos,s-i);if(a!==r)n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=yt(e);for(;r<=s-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){pt(this),ht(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:s}=this;let{pos:i}=this;t[i++]=128,mt(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),a=Number(n>>s&i),o=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,o,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const a=yt(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=o/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)a.setUint32(4*e,u[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:s,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=s,e.length=r,e.pos=a,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const bs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),gs=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),ws=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),vs=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]),xs=new Uint32Array(64);class Is extends ys{constructor(e=32){super(64,e,8,!1),this.A=0|bs[0],this.B=0|bs[1],this.C=0|bs[2],this.D=0|bs[3],this.E=0|bs[4],this.F=0|bs[5],this.G=0|bs[6],this.H=0|bs[7]}get(){const{A:e,B:t,C:n,D:r,E:s,F:i,G:a,H:o}=this;return[e,t,n,r,s,i,a,o]}set(e,t,n,r,s,i,a,o){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|i,this.G=0|a,this.H=0|o}process(e,t){for(let n=0;n<16;n++,t+=4)xs[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=xs[e-15],n=xs[e-2],r=bt(t,7)^bt(t,18)^t>>>3,s=bt(n,17)^bt(n,19)^n>>>10;xs[e]=s+xs[e-7]+r+xs[e-16]|0}let{A:n,B:r,C:s,D:i,E:a,F:o,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(bt(a,6)^bt(a,11)^bt(a,25))+((d=a)&o^~d&c)+vs[e]+xs[e]|0,l=(bt(n,2)^bt(n,13)^bt(n,22))+ms(n,r,s)|0;u=c,c=o,o=a,a=i+t|0,i=s,s=r,r=n,n=t+l|0}var d;n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,o=o+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,s,i,a,o,c,u)}roundClean(){mt(xs)}destroy(){this.set(0,0,0,0,0,0,0,0),mt(this.buffer)}}const Ps=(()=>Ye(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),zs=(()=>Ps[0])(),Es=(()=>Ps[1])(),As=new Uint32Array(80),ks=new Uint32Array(80);class Ms extends ys{constructor(e=64){super(128,e,16,!1),this.Ah=0|ws[0],this.Al=0|ws[1],this.Bh=0|ws[2],this.Bl=0|ws[3],this.Ch=0|ws[4],this.Cl=0|ws[5],this.Dh=0|ws[6],this.Dl=0|ws[7],this.Eh=0|ws[8],this.El=0|ws[9],this.Fh=0|ws[10],this.Fl=0|ws[11],this.Gh=0|ws[12],this.Gl=0|ws[13],this.Hh=0|ws[14],this.Hl=0|ws[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:s,Cl:i,Dh:a,Dl:o,Eh:c,El:u,Fh:d,Fl:l,Gh:f,Gl:p,Hh:h,Hl:m}=this;return[e,t,n,r,s,i,a,o,c,u,d,l,f,p,h,m]}set(e,t,n,r,s,i,a,o,c,u,d,l,f,p,h,m){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|s,this.Cl=0|i,this.Dh=0|a,this.Dl=0|o,this.Eh=0|c,this.El=0|u,this.Fh=0|d,this.Fl=0|l,this.Gh=0|f,this.Gl=0|p,this.Hh=0|h,this.Hl=0|m}process(e,t){for(let n=0;n<16;n++,t+=4)As[n]=e.getUint32(t),ks[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|As[e-15],n=0|ks[e-15],r=Xe(t,n,1)^Xe(t,n,8)^Qe(t,0,7),s=et(t,n,1)^et(t,n,8)^Je(t,n,7),i=0|As[e-2],a=0|ks[e-2],o=Xe(i,a,19)^tt(i,a,61)^Qe(i,0,6),c=et(i,a,19)^nt(i,a,61)^Je(i,a,6),u=at(s,c,ks[e-7],ks[e-16]),d=ot(u,r,o,As[e-7],As[e-16]);As[e]=0|d,ks[e]=0|u}let{Ah:n,Al:r,Bh:s,Bl:i,Ch:a,Cl:o,Dh:c,Dl:u,Eh:d,El:l,Fh:f,Fl:p,Gh:h,Gl:m,Hh:y,Hl:b}=this;for(let e=0;e<80;e++){const t=Xe(d,l,14)^Xe(d,l,18)^tt(d,l,41),g=et(d,l,14)^et(d,l,18)^nt(d,l,41),w=d&f^~d&h,v=ct(b,g,l&p^~l&m,Es[e],ks[e]),x=ut(v,y,t,w,zs[e],As[e]),I=0|v,P=Xe(n,r,28)^tt(n,r,34)^tt(n,r,39),z=et(n,r,28)^nt(n,r,34)^nt(n,r,39),E=n&s^n&a^s&a,A=r&i^r&o^i&o;y=0|h,b=0|m,h=0|f,m=0|p,f=0|d,p=0|l,({h:d,l:l}=rt(0|c,0|u,0|x,0|I)),c=0|a,u=0|o,a=0|s,o=0|i,s=0|n,i=0|r;const k=st(I,z,A);n=it(k,x,P,E),r=0|k}({h:n,l:r}=rt(0|this.Ah,0|this.Al,0|n,0|r)),({h:s,l:i}=rt(0|this.Bh,0|this.Bl,0|s,0|i)),({h:a,l:o}=rt(0|this.Ch,0|this.Cl,0|a,0|o)),({h:c,l:u}=rt(0|this.Dh,0|this.Dl,0|c,0|u)),({h:d,l:l}=rt(0|this.Eh,0|this.El,0|d,0|l)),({h:f,l:p}=rt(0|this.Fh,0|this.Fl,0|f,0|p)),({h:h,l:m}=rt(0|this.Gh,0|this.Gl,0|h,0|m)),({h:y,l:b}=rt(0|this.Hh,0|this.Hl,0|y,0|b)),this.set(n,r,s,i,a,o,c,u,d,l,f,p,h,m,y,b)}roundClean(){mt(As,ks)}destroy(){mt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class $s extends Ms{constructor(){super(48),this.Ah=0|gs[0],this.Al=0|gs[1],this.Bh=0|gs[2],this.Bl=0|gs[3],this.Ch=0|gs[4],this.Cl=0|gs[5],this.Dh=0|gs[6],this.Dl=0|gs[7],this.Eh=0|gs[8],this.El=0|gs[9],this.Fh=0|gs[10],this.Fl=0|gs[11],this.Gh=0|gs[12],this.Gl=0|gs[13],this.Hh=0|gs[14],this.Hl=0|gs[15]}}const Os=xt((()=>new Is)),js=xt((()=>new Ms)),Ss=xt((()=>new $s)),Ns=Os;function Ts(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),s=function(e,t){const n=t||"hex",r=Ns(W(e,{strict:!1})?Le(e):e);return"bytes"===n?r:_e(r)}(t,"bytes");return s.set([n],0),"bytes"===r?s:Ce(s)}const _s=32,Rs=4096,Cs=_s*Rs,Bs=6*Cs-1-1*Rs*6,Ds=1;class Us extends ee{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class qs extends ee{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class Ls extends ee{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`],name:"InvalidVersionedHashSizeError"})}}class Fs extends ee{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${Ds}`,`Received: ${t}`],name:"InvalidVersionedHashVersionError"})}}function Ks(e){const{data:t,kzg:n,to:r}=e,s=e.blobs??function(e){const t=e.to??("string"==typeof e.data?"hex":"bytes"),n="string"==typeof e.data?Ve(e.data):e.data,r=Y(n);if(!r)throw new qs;if(r>Bs)throw new Us({maxSize:Bs,size:r});const s=[];let i=!0,a=0;for(;i;){const e=An(new Uint8Array(Cs));let t=0;for(;t<Rs;){const r=n.slice(a,a+(_s-1));if(e.pushByte(0),e.pushBytes(r),r.length<31){e.pushByte(128),i=!1;break}t++,a+=31}s.push(e)}return"bytes"===t?s.map((e=>e.bytes)):s.map((e=>Ce(e.bytes)))}({data:t,to:r}),i=e.commitments??ps({blobs:s,kzg:n,to:r}),a=e.proofs??hs({blobs:s,commitments:i,kzg:n,to:r}),o=[];for(let e=0;e<s.length;e++)o.push({blob:s[e],commitment:i[e],proof:a[e]});return o}function Vs(e,t){if(!Qt(e,{strict:!1}))throw new Kt({address:e});if(!Qt(t,{strict:!1}))throw new Kt({address:t});return e.toLowerCase()===t.toLowerCase()}const Gs="/docs/contract/decodeFunctionResult";function Zs(e){const{abi:t,args:n,functionName:r,data:s}=e;let i=t[0];if(r){const e=pn({abi:t,args:n,name:r});if(!e)throw new fe(r,{docsPath:Gs});i=e}if("function"!==i.type)throw new fe(void 0,{docsPath:Gs});if(!i.outputs)throw new pe(i.name,{docsPath:Gs});const a=On(i.outputs,s);return a&&a.length>1?a:a&&1===a.length?a[0]:void 0}
|
|
2
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Hs=BigInt(0),Ws=BigInt(1);function Ys(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Qs(e){if(!Ys(e))throw new Error("Uint8Array expected")}function Js(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function Xs(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function ei(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Hs:BigInt("0x"+e)}const ti="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,ni=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function ri(e){if(Qs(e),ti)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=ni[e[n]];return t}const si={_0:48,_9:57,A:65,F:70,a:97,f:102};function ii(e){return e>=si._0&&e<=si._9?e-si._0:e>=si.A&&e<=si.F?e-(si.A-10):e>=si.a&&e<=si.f?e-(si.a-10):void 0}function ai(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(ti)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,s=0;t<n;t++,s+=2){const n=ii(e.charCodeAt(s)),i=ii(e.charCodeAt(s+1));if(void 0===n||void 0===i){const t=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+s)}r[t]=16*n+i}return r}function oi(e){return ei(ri(e))}function ci(e){return Qs(e),ei(ri(Uint8Array.from(e).reverse()))}function ui(e,t){return ai(e.toString(16).padStart(2*t,"0"))}function di(e,t){return ui(e,t).reverse()}function li(e,t,n){let r;if("string"==typeof t)try{r=ai(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Ys(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const s=r.length;if("number"==typeof n&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}function fi(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];Qs(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const s=e[t];n.set(s,r),r+=s.length}return n}function pi(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}const hi=e=>"bigint"==typeof e&&Hs<=e;function mi(e,t,n){return hi(e)&&hi(t)&&hi(n)&&t<=e&&e<n}function yi(e,t,n,r){if(!mi(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const bi=e=>(Ws<<BigInt(e))-Ws,gi=e=>new Uint8Array(e),wi=e=>Uint8Array.from(e);const vi={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||Ys(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function xi(e,t,n={}){const r=(t,n,r)=>{const s=vi[n];if("function"!=typeof s)throw new Error("invalid validator function");const i=e[t];if(!(r&&void 0===i||s(i,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+i)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}function Ii(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(void 0!==s)return s;const i=e(n,...r);return t.set(n,i),i}}class Pi extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof Pi){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&"string"==typeof t.cause.details?t.cause.details:t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof Pi&&t.cause.docsPath||t.docsPath,s=`https://oxlib.sh${r??""}`;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${s}`:void 0]:[]].filter((e=>"string"==typeof e)).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:"ox@0.1.1"}),this.cause=t.cause,this.details=n,this.docs=s,this.docsPath=r,this.shortMessage=e}walk(e){return zi(this,e)}}function zi(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?zi(e.cause,t):t?null:e}function Ei(e,t){if(Ri(e)>t)throw new Ki({givenSize:Ri(e),maxSize:t})}const Ai={zero:48,nine:57,A:65,F:70,a:97,f:102};function ki(e){return e>=Ai.zero&&e<=Ai.nine?e-Ai.zero:e>=Ai.A&&e<=Ai.F?e-(Ai.A-10):e>=Ai.a&&e<=Ai.f?e-(Ai.a-10):void 0}function Mi(e,t={}){const{dir:n="left"}=t;let r=e,s=0;for(let e=0;e<r.length-1&&"0"===r["left"===n?e:r.length-e-1].toString();e++)s++;return r="left"===n?r.slice(s):r.slice(0,r.length-s),r}function $i(e,t){if(ra(e)>t)throw new oa({givenSize:ra(e),maxSize:t})}function Oi(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const s=e.replace("0x","");if(s.length>2*r)throw new ua({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s["right"===n?"padEnd":"padStart"](2*r,"0")}`}const ji=new TextDecoder,Si=new TextEncoder;function Ni(e){return e instanceof Uint8Array?e:"string"==typeof e?Ti(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function Ti(e,t={}){const{size:n}=t;let r=e;n&&($i(e,n),r=ta(e,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){const n=ki(s.charCodeAt(t++)),r=ki(s.charCodeAt(t++));if(void 0===n||void 0===r)throw new Pi(`Invalid byte sequence ("${s[t-2]}${s[t-1]}" in "${s}").`);a[e]=16*n+r}return a}function _i(e,t={}){const{size:n}=t,r=Si.encode(e);return"number"==typeof n?(Ei(r,n),function(e,t){return function(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;if(e.length>r)throw new Gi({size:e.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let t=0;t<r;t++){const i="right"===n;s[i?t:r-t-1]=e[i?t:e.length-t-1]}return s}(e,{dir:"right",size:t})}(r,n)):r}function Ri(e){return e.length}function Ci(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>Ri(e)-1)throw new Vi({offset:t,position:"start",size:Ri(e)})}(e,t);const i=e.slice(t,n);return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&Ri(e)!==n-t)throw new Vi({offset:n,position:"end",size:Ri(e)})}(i,t,n),i}function Bi(e,t={}){const{size:n}=t;void 0!==n&&Ei(e,n);return sa(Qi(e,t),t)}function Di(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(Ei(r,n),r=Li(r)),r.length>1||r[0]>1)throw new Fi(r);return Boolean(r[0])}function Ui(e,t={}){const{size:n}=t;void 0!==n&&Ei(e,n);return ia(Qi(e,t),t)}function qi(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(Ei(r,n),r=Mi(r,{dir:"right"})),ji.decode(r)}function Li(e){return Mi(e,{dir:"left"})}class Fi extends Pi{constructor(e){super(`Bytes value \`${e}\` is not a valid boolean.`,{metaMessages:["The bytes array must contain a single byte of either a `0` or `1` value."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesBooleanError"})}}class Ki extends Pi{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Vi extends Pi{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}}class Gi extends Pi{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}const Zi=new TextEncoder,Hi=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Wi(...e){return`0x${e.reduce(((e,t)=>e+t.replace("0x","")),"")}`}function Yi(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?($i(n,t.size),ea(n,t.size)):n}function Qi(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Hi[e[t]];const r=`0x${n}`;return"number"==typeof t.size?($i(r,t.size),ta(r,t.size)):r}function Ji(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new aa({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?(1n<<BigInt(8*r))+BigInt(s):s).toString(16)}`;return r?ea(o,r):o}function Xi(e,t={}){return Qi(Zi.encode(e),t)}function ea(e,t){return Oi(e,{dir:"left",size:t})}function ta(e,t){return Oi(e,{dir:"right",size:t})}function na(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>ra(e)-1)throw new ca({offset:t,position:"start",size:ra(e)})}(e,t);const i=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&ra(e)!==n-t)throw new ca({offset:n,position:"end",size:ra(e)})}(i,t,n),i}function ra(e){return Math.ceil((e.length-2)/2)}function sa(e,t={}){const{signed:n}=t;t.size&&$i(e,t.size);const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<8n*BigInt(s))-1n;return r<=i>>1n?r:r-i-1n}function ia(e,t={}){const{signed:n,size:r}=t;return Number(n||r?sa(e,t):e)}class aa extends Pi{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number \`${s}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class oa extends Pi{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class ca extends Pi{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class ua extends Pi{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function da(e){return{address:e.address,amount:Ji(e.amount),index:Ji(e.index),validatorIndex:Ji(e.validatorIndex)}}const la=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],fa=[{name:"query",type:"function",stateMutability:"view",inputs:[{type:"tuple[]",name:"queries",components:[{type:"address",name:"sender"},{type:"string[]",name:"urls"},{type:"bytes",name:"data"}]}],outputs:[{type:"bool[]",name:"failures"},{type:"bytes[]",name:"responses"}]},{name:"HttpError",type:"error",inputs:[{type:"uint16",name:"status"},{type:"string",name:"message"}]}],pa=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],ha=[{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],outputs:[{type:"bool"}],stateMutability:"nonpayable",type:"function",name:"isValidSig"}],ma="0x82ad56cb",ya="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",ba="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",ga="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",wa="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class va extends ee{constructor({blockNumber:e,chain:t,contract:n}){super(`Chain "${t.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...e&&n.blockCreated&&n.blockCreated>e?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${e}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class xa extends ee{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class Ia extends ee{constructor({chainId:e}){super("number"==typeof e?`Chain ID "${e}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const Pa="/docs/contract/encodeDeployData";function za(e){const{abi:t,args:n,bytecode:r}=e;if(!n||0===n.length)return r;const s=t.find((e=>"type"in e&&"constructor"===e.type));if(!s)throw new ne({docsPath:Pa});if(!("inputs"in s))throw new re({docsPath:Pa});if(!s.inputs||0===s.inputs.length)throw new re({docsPath:Pa});return Xt([r,cn(s.inputs,n)])}function Ea(e,{docsPath:t,...n}){const r=(()=>{const t=function(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof ee?e.walk((e=>e?.code===Fr.code)):e;return r instanceof ee?new Fr({cause:e,message:r.details}):Fr.nodeMessage.test(n)?new Fr({cause:e,message:e.details}):Kr.nodeMessage.test(n)?new Kr({cause:e,maxFeePerGas:t?.maxFeePerGas}):Vr.nodeMessage.test(n)?new Vr({cause:e,maxFeePerGas:t?.maxFeePerGas}):Gr.nodeMessage.test(n)?new Gr({cause:e,nonce:t?.nonce}):Zr.nodeMessage.test(n)?new Zr({cause:e,nonce:t?.nonce}):Hr.nodeMessage.test(n)?new Hr({cause:e,nonce:t?.nonce}):Wr.nodeMessage.test(n)?new Wr({cause:e}):Yr.nodeMessage.test(n)?new Yr({cause:e,gas:t?.gas}):Qr.nodeMessage.test(n)?new Qr({cause:e,gas:t?.gas}):Jr.nodeMessage.test(n)?new Jr({cause:e}):Xr.nodeMessage.test(n)?new Xr({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new es({cause:e})}(e,n);return t instanceof es?e:t})();return new Jn(r,{docsPath:t,...n})}function Aa(){let e=()=>{},t=()=>{};return{promise:new Promise(((n,r)=>{e=n,t=r})),resolve:e,reject:t}}const ka=new Map;function Ma({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:s}){const i=async()=>{const t=o();a();const n=t.map((({args:e})=>e));0!==n.length&&e(n).then((e=>{s&&Array.isArray(e)&&e.sort(s);for(let n=0;n<t.length;n++){const{resolve:r}=t[n];r?.([e[n],e])}})).catch((e=>{for(let n=0;n<t.length;n++){const{reject:r}=t[n];r?.(e)}}))},a=()=>ka.delete(t),o=()=>ka.get(t)||[],c=e=>ka.set(t,[...o(),e]);return{flush:a,async schedule(e){const{promise:t,resolve:s,reject:a}=Aa(),u=n?.([...o().map((({args:e})=>e)),e]);u&&i();return o().length>0?(c({args:e,resolve:s,reject:a}),t):(c({args:e,resolve:s,reject:a}),setTimeout(i,r),t)}}}async function $a(e,t){const{account:n=e.account,authorizationList:r,batch:s=Boolean(e.batch?.multicall),blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",accessList:o,blobs:c,blockOverrides:u,code:d,data:l,factory:f,factoryData:p,gas:h,gasPrice:m,maxFeePerBlobGas:y,maxFeePerGas:b,maxPriorityFeePerGas:g,nonce:w,to:v,value:x,stateOverride:I,...P}=t,z=n?yn(n):void 0;if(d&&(f||p))throw new ee("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(d&&v)throw new ee("Cannot provide both `code` & `to` as parameters.");const E=d&&l,A=f&&p&&v&&l,k=E||A,M=E?Oa({code:d,data:l}):A?function(e){const{data:t,factory:n,factoryData:r,to:s}=e;return za({abi:V(["constructor(address, bytes, address, bytes)"]),bytecode:ba,args:[s,t,n,r]})}({data:l,factory:f,factoryData:p,to:v}):l;try{!function(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:s,to:i}=e,a=t?yn(t):void 0;if(a&&!Qt(a.address))throw new Kt({address:a.address});if(i&&!Qt(i))throw new Kt({address:i});if(void 0!==n&&(void 0!==r||void 0!==s))throw new Zn;if(r&&r>os)throw new Kr({maxFeePerGas:r});if(s&&r&&s>r)throw new Xr({maxFeePerGas:r,maxPriorityFeePerGas:s})}(t);const n=("bigint"==typeof i?Be(i):void 0)||a,d=u?function(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:Ji(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:Ji(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:Ji(e.gasLimit)},..."bigint"==typeof e.number&&{number:Ji(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:Ji(e.prevRandao)},..."bigint"==typeof e.time&&{time:Ji(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(da)}}}(u):void 0,l=function(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!Qt(n,{strict:!1}))throw new Kt({address:n});if(t[n])throw new Fn({address:n});t[n]=as(r)}return t}(I),f=e.chain?.formatters?.transactionRequest?.format,p=(f||ss)({...ts(P,{format:f}),from:z?.address,accessList:o,authorizationList:r,blobs:c,data:M,gas:h,gasPrice:m,maxFeePerBlobGas:y,maxFeePerGas:b,maxPriorityFeePerGas:g,nonce:w,to:k?void 0:v,value:x});if(s&&function({request:e}){const{data:t,to:n,...r}=e;return!!t&&(!t.startsWith(ma)&&(!!n&&!(Object.values(r).filter((e=>void 0!==e)).length>0)))}({request:p})&&!l&&!d)try{return await async function(e,t){const{batchSize:n=1024,deployless:r=!1,wait:s=0}="object"==typeof e.batch?.multicall?e.batch.multicall:{},{blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",data:o,to:c}=t,u=(()=>{if(r)return null;if(t.multicallAddress)return t.multicallAddress;if(e.chain)return function({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new va({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new va({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}({blockNumber:i,chain:e.chain,contract:"multicall3"});throw new xa})(),d="bigint"==typeof i?Be(i):void 0,l=d||a,{schedule:f}=Ma({id:`${e.uid}.${l}`,wait:s,shouldSplitBatch(e){const t=e.reduce(((e,{data:t})=>e+(t.length-2)),0);return t>2*n},fn:async t=>{const n=t.map((e=>({allowFailure:!0,callData:e.data,target:e.to}))),r=gn({abi:la,args:[n],functionName:"aggregate3"}),s=await e.request({method:"eth_call",params:[{...null===u?{data:Oa({code:wa,data:r})}:{to:u,data:r}},l]});return Zs({abi:la,args:[n],functionName:"aggregate3",data:s||"0x"})}}),[{returnData:p,success:h}]=await f({data:o,to:c});if(!h)throw new rr({data:p});return"0x"===p?{data:void 0}:{data:p}}(e,{...p,blockNumber:i,blockTag:a})}catch(e){if(!(e instanceof xa||e instanceof va))throw e}const E=(()=>{const e=[p,n];return l&&d?[...e,l,d]:l?[...e,l]:d?[...e,{},d]:e})(),A=await e.request({method:"eth_call",params:E});return"0x"===A?{data:void 0}:{data:A}}catch(n){const r=function(e){if(!(e instanceof ee))return;const t=e.walk();return"object"==typeof t?.data?t.data?.data:t.data}(n),{offchainLookup:s,offchainLookupSignature:i}=await import("./ccip-0db5fcae.js");if(!1!==e.ccipRead&&r?.slice(0,10)===i&&v)return{data:await s(e,{data:r,to:v})};if(k&&"0x101bb98d"===r?.slice(0,10))throw new nr({factory:f});throw Ea(n,{...t,account:z,chain:e.chain})}}function Oa(e){const{code:t,data:n}=e;return za({abi:V(["constructor(bytes, bytes)"]),bytecode:ya,args:[t,n]})}async function ja(e,t){const{abi:n,address:r,args:s,functionName:i,...a}=t,o=gn({abi:n,args:s,functionName:i});try{const{data:t}=await G(e,$a,"call")({...a,data:o,to:r});return Zs({abi:n,args:s,functionName:i,data:t||"0x"})}catch(e){throw Rr(e,{abi:n,address:r,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}const Sa=new Map,Na=new Map;let Ta=0;function _a(e,t,n){const r=++Ta,s=()=>Sa.get(e)||[],i=()=>{const t=s();if(!t.some((e=>e.id===r)))return;const n=Na.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch((()=>{}))}(()=>{const t=s();Sa.set(e,t.filter((e=>e.id!==r)))})()},a=s();if(Sa.set(e,[...a,{id:r,fns:t}]),a&&a.length>0)return i;const o={};for(const e in t)o[e]=(...t)=>{const n=s();if(0!==n.length)for(const r of n)r.fns[e]?.(...t)};const c=n(o);return"function"==typeof c&&Na.set(e,c),i}async function Ra(e){return new Promise((t=>setTimeout(t,e)))}const Ca=new Map,Ba=new Map;async function Da(e,{cacheKey:t,cacheTime:n=Number.POSITIVE_INFINITY}){const r=function(e){const t=(e,t)=>({clear:()=>t.delete(e),get:()=>t.get(e),set:n=>t.set(e,n)}),n=t(e,Ca),r=t(e,Ba);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}(t),s=r.response.get();if(s&&n>0){if(Date.now()-s.created.getTime()<n)return s.data}let i=r.promise.get();i||(i=e(),r.promise.set(i));try{const e=await i;return r.response.set({created:new Date,data:e}),e}finally{r.promise.clear()}}class Ua extends ee{constructor(e){super(`Call bundle failed with status: ${e.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=e}}function qa(e,{delay:t=100,retryCount:n=2,shouldRetry:r=(()=>!0)}={}){return new Promise(((s,i)=>{const a=async({count:o=0}={})=>{try{const t=await e();s(t)}catch(e){if(o<n&&await r({count:o,error:e}))return(async({error:e})=>{const n="function"==typeof t?t({count:o,error:e}):t;n&&await Ra(n),a({count:o+1})})({error:e});i(e)}};a()}))}const La={"0x0":"reverted","0x1":"success"};function Fa(e){const t={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map((e=>function(e,{args:t,eventName:n}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...n?{args:t,eventName:n}:{}}}(e))):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Ne(e.transactionIndex):null,status:e.status?La[e.status]:null,type:e.type?cs[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}const Ka=ns("transactionReceipt",Fa),Va="0x5792579257925792579257925792579257925792579257925792579257925792",Ga=Be(0,{size:32});async function Za(e,t){const{id:n,pollingInterval:r=e.pollingInterval,status:s=(({statusCode:e})=>200===e||e>=300),retryCount:i=4,retryDelay:a=(({count:e})=>200*~~(1<<e)),timeout:o=6e4,throwOnFailure:c=!1}=t,u=Rn(["waitForCallsStatus",e.uid,n]),{promise:d,resolve:l,reject:f}=Aa();let p;const h=_a(u,{resolve:l,reject:f},(t=>{const o=function(e,{emitOnBegin:t,initialWaitTime:n,interval:r}){let s=!0;const i=()=>s=!1;return(async()=>{let a;t&&(a=await e({unpoll:i}));const o=await(n?.(a))??r;await Ra(o);const c=async()=>{s&&(await e({unpoll:i}),await Ra(r),c())};c()})(),i}((async()=>{const r=e=>{clearTimeout(p),o(),e(),h()};try{const o=await qa((async()=>{const t=await async function(e,t){const{atomic:n=!1,chainId:r,receipts:s,version:i="2.0.0",...a}=await async function(t){if(t.endsWith(Va.slice(2))){const n=Oe(sn(t,-64,-32)),r=sn(t,0,-64).slice(2).match(/.{1,64}/g),s=await Promise.all(r.map((t=>Ga.slice(2)!==t?e.request({method:"eth_getTransactionReceipt",params:[`0x${t}`]},{dedupe:!0}):void 0))),i=s.some((e=>null===e))?100:s.every((e=>"0x1"===e?.status))?200:s.every((e=>"0x0"===e?.status))?500:600;return{atomic:!1,chainId:Ne(n),receipts:s.filter(Boolean),status:i,version:"2.0.0"}}return e.request({method:"wallet_getCallsStatus",params:[t]})}(t.id),[o,c]=(()=>{const e=a.status;return e>=100&&e<200?["pending",e]:e>=200&&e<300?["success",e]:e>=300&&e<700?["failure",e]:"CONFIRMED"===e?["success",200]:"PENDING"===e?["pending",100]:[void 0,e]})();return{...a,atomic:n,chainId:r?Ne(r):void 0,receipts:s?.map((e=>({...e,blockNumber:Se(e.blockNumber),gasUsed:Se(e.gasUsed),status:La[e.status]})))??[],statusCode:c,status:o,version:i}}(e,{id:n});if(c&&"failure"===t.status)throw new Ua(t);return t}),{retryCount:i,delay:a});if(!s(o))return;r((()=>t.resolve(o)))}catch(e){r((()=>t.reject(e)))}}),{interval:r,emitOnBegin:!0});return o}));return p=o?setTimeout((()=>{h(),clearTimeout(p),f(new Ha({id:n}))}),o):void 0,await d}class Ha extends ee{constructor({id:e}){super(`Timed out while waiting for call bundle with id "${e}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}const Wa=256;let Ya,Qa=Wa;function Ja(e=11){if(!Ya||Qa+e>2*Wa){Ya="",Qa=0;for(let e=0;e<Wa;e++)Ya+=(256+256*Math.random()|0).toString(16).substring(1)}return Ya.substring(Qa,Qa+++e)}function Xa(e){const{batch:t,chain:n,ccipRead:r,key:s="base",name:i="Base Client",type:a="base"}=e,o=e.experimental_blockTag??("number"==typeof n?.experimental_preconfirmationTime?"pending":void 0),c=n?.blockTime??12e3,u=Math.min(Math.max(Math.floor(c/2),500),4e3),d=e.pollingInterval??u,l=e.cacheTime??d,f=e.account?yn(e.account):void 0,{config:p,request:h,value:m}=e.transport({chain:n,pollingInterval:d}),y={account:f,batch:t,cacheTime:l,ccipRead:r,chain:n,key:s,name:i,pollingInterval:d,request:h,transport:{...p,...m},type:a,uid:Ja(),...o?{experimental_blockTag:o}:{}};return Object.assign(y,{extend:function e(t){return n=>{const r=n(t);for(const e in y)delete r[e];const s={...t,...r};return Object.assign(s,{extend:e(s)})}}(y)})}class eo extends ee{constructor({address:e}){super(`No EIP-712 domain found on contract "${e}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${e}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}const to=[{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];function no(e){const{chainId:t,maxPriorityFeePerGas:n,maxFeePerGas:r,to:s}=e;if(t<=0)throw new Ia({chainId:t});if(s&&!Qt(s))throw new Kt({address:s});if(r&&r>os)throw new Kr({maxFeePerGas:r});if(n&&r&&n>r)throw new Xr({maxFeePerGas:r,maxPriorityFeePerGas:n})}function ro(e){if(!e||0===e.length)return[];const t=[];for(let n=0;n<e.length;n++){const{address:r,storageKeys:s}=e[n];for(let e=0;e<s.length;e++)if(s[e].length-2!=64)throw new Yn({storageKey:s[e]});if(!Qt(r,{strict:!1}))throw new Kt({address:r});t.push([r,s])}return t}function so(e,t){const n=function(e){if(e.type)return e.type;if(void 0!==e.authorizationList)return"eip7702";if(void 0!==e.blobs||void 0!==e.blobVersionedHashes||void 0!==e.maxFeePerBlobGas||void 0!==e.sidecars)return"eip4844";if(void 0!==e.maxFeePerGas||void 0!==e.maxPriorityFeePerGas)return"eip1559";if(void 0!==e.gasPrice)return void 0!==e.accessList?"eip2930":"legacy";throw new Wn({transaction:e})}(e);return"eip1559"===n?function(e,t){const{chainId:n,gas:r,nonce:s,to:i,value:a,maxFeePerGas:o,maxPriorityFeePerGas:c,accessList:u,data:d}=e;no(e);const l=ro(u),f=[Be(n),s?Be(s):"0x",c?Be(c):"0x",o?Be(o):"0x",r?Be(r):"0x",i??"0x",a?Be(a):"0x",d??"0x",l,...io(e,t)];return Xt(["0x02",Dr(f)])}(e,t):"eip2930"===n?function(e,t){const{chainId:n,gas:r,data:s,nonce:i,to:a,value:o,accessList:c,gasPrice:u}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:s,to:i}=e;if(t<=0)throw new Ia({chainId:t});if(i&&!Qt(i))throw new Kt({address:i});if(n||s)throw new ee("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>os)throw new Kr({maxFeePerGas:r})}(e);const d=ro(c),l=[Be(n),i?Be(i):"0x",u?Be(u):"0x",r?Be(r):"0x",a??"0x",o?Be(o):"0x",s??"0x",d,...io(e,t)];return Xt(["0x01",Dr(l)])}(e,t):"eip4844"===n?function(e,t){const{chainId:n,gas:r,nonce:s,to:i,value:a,maxFeePerBlobGas:o,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=e;!function(e){const{blobVersionedHashes:t}=e;if(t){if(0===t.length)throw new qs;for(const e of t){const t=Y(e),n=Ne(en(e,0,1));if(32!==t)throw new Ls({hash:e,size:t});if(n!==Ds)throw new Fs({hash:e,version:n})}}no(e)}(e);let f=e.blobVersionedHashes,p=e.sidecars;if(e.blobs&&(void 0===f||void 0===p)){const t="string"==typeof e.blobs[0]?e.blobs:e.blobs.map((e=>Ce(e))),n=e.kzg,r=ps({blobs:t,kzg:n});if(void 0===f&&(f=function(e){const{commitments:t,version:n}=e,r=e.to??("string"==typeof t[0]?"hex":"bytes"),s=[];for(const e of t)s.push(Ts({commitment:e,to:r,version:n}));return s}({commitments:r})),void 0===p){p=Ks({blobs:t,commitments:r,proofs:hs({blobs:t,commitments:r,kzg:n})})}}const h=ro(d),m=[Be(n),s?Be(s):"0x",u?Be(u):"0x",c?Be(c):"0x",r?Be(r):"0x",i??"0x",a?Be(a):"0x",l??"0x",h,o?Be(o):"0x",f??[],...io(e,t)],y=[],b=[],g=[];if(p)for(let e=0;e<p.length;e++){const{blob:t,commitment:n,proof:r}=p[e];y.push(t),b.push(n),g.push(r)}return Xt(["0x03",Dr(p?[m,y,b,g]:m)])}(e,t):"eip7702"===n?function(e,t){const{authorizationList:n,chainId:r,gas:s,nonce:i,to:a,value:o,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=e;!function(e){const{authorizationList:t}=e;if(t)for(const e of t){const{chainId:t}=e,n=e.address;if(!Qt(n))throw new Kt({address:n});if(t<0)throw new Ia({chainId:t})}no(e)}(e);const f=ro(d),p=function(e){if(!e||0===e.length)return[];const t=[];for(const n of e){const{chainId:e,nonce:r,...s}=n,i=n.address;t.push([e?_e(e):"0x",i,r?_e(r):"0x",...io({},s)])}return t}(n);return Xt(["0x04",Dr([Be(r),i?Be(i):"0x",u?Be(u):"0x",c?Be(c):"0x",s?Be(s):"0x",a??"0x",o?Be(o):"0x",l??"0x",f,p,...io(e,t)])])}(e,t):function(e,t){const{chainId:n=0,gas:r,data:s,nonce:i,to:a,value:o,gasPrice:c}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:s,to:i}=e;if(i&&!Qt(i))throw new Kt({address:i});if(void 0!==t&&t<=0)throw new Ia({chainId:t});if(n||s)throw new ee("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>os)throw new Kr({maxFeePerGas:r})}(e);let u=[i?Be(i):"0x",c?Be(c):"0x",r?Be(r):"0x",a??"0x",o?Be(o):"0x",s??"0x"];if(t){const e=(()=>{if(t.v>=35n){return(t.v-35n)/2n>0?t.v:27n+(35n===t.v?0n:1n)}if(n>0)return BigInt(2*n)+BigInt(35n+t.v-27n);const e=27n+(27n===t.v?0n:1n);if(t.v!==e)throw new Hn({v:t.v});return e})(),r=Oe(t.r),s=Oe(t.s);u=[...u,Be(e),"0x00"===r?"0x":r,"0x00"===s?"0x":s]}else n>0&&(u=[...u,Be(n),"0x","0x"]);return Dr(u)}(e,t)}function io(e,t){const n=t??e,{v:r,yParity:s}=n;if(void 0===n.r)return[];if(void 0===n.s)return[];if(void 0===r&&void 0===s)return[];const i=Oe(n.r),a=Oe(n.s);return["number"==typeof s?s?Be(1):"0x":0n===r?"0x":1n===r?Be(1):27n===r?"0x":Be(1),"0x00"===i?"0x":i,"0x00"===a?"0x":a]}async function ao({address:e,authorization:t,signature:n}){return Vs(Ht(e),await async function(e){const{authorization:t,signature:n}=e;return Br({hash:Lr(t),signature:n??t})}({authorization:t,signature:n}))}const oo=new Vt(8192);function co(e,t={}){return async(n,r={})=>{const{dedupe:s=!1,methods:i,retryDelay:a=150,retryCount:o=3,uid:c}={...t,...r},{method:u}=n;if(i?.exclude?.includes(u))throw new gr(new Error("method not supported"),{method:u});if(i?.include&&!i.include.includes(u))throw new gr(new Error("method not supported"),{method:u});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(oo.get(n))return oo.get(n);const r=e().finally((()=>oo.delete(n)));return oo.set(n,r),r}((()=>qa((async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case ur.code:throw new ur(t);case dr.code:throw new dr(t);case lr.code:throw new lr(t,{method:n.method});case fr.code:throw new fr(t);case pr.code:throw new pr(t);case hr.code:throw new hr(t);case mr.code:throw new mr(t);case yr.code:throw new yr(t);case br.code:throw new br(t);case gr.code:throw new gr(t,{method:n.method});case wr.code:throw new wr(t);case vr.code:throw new vr(t);case xr.code:throw new xr(t);case Ir.code:throw new Ir(t);case Pr.code:throw new Pr(t);case zr.code:throw new zr(t);case Er.code:throw new Er(t);case Ar.code:throw new Ar(t);case kr.code:throw new kr(t);case Mr.code:throw new Mr(t);case $r.code:throw new $r(t);case Or.code:throw new Or(t);case jr.code:throw new jr(t);case Sr.code:throw new Sr(t);case Nr.code:throw new Nr(t);case 5e3:throw new xr(t);default:if(e instanceof ee)throw e;throw new Tr(t)}}}),{delay:({count:e,error:t})=>{if(t&&t instanceof sr){const e=t?.headers?.get("Retry-After");if(e?.match(/\d/))return 1e3*Number.parseInt(e,10)}return~~(1<<e)*a},retryCount:o,shouldRetry:({error:e})=>function(e){if("code"in e&&"number"==typeof e.code)return-1===e.code||(e.code===wr.code||e.code===pr.code);if(e instanceof sr&&e.status)return 403===e.status||(408===e.status||(413===e.status||(429===e.status||(500===e.status||(502===e.status||(503===e.status||504===e.status))))));return!0}(e)})),{enabled:s,id:s?Ue(`${c}.${Rn(n)}`):void 0})}}function uo(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}function lo(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const fo=lo();function po(e,t={}){return{async request(n){const{body:r,fetchFn:s=t.fetchFn??fetch,onRequest:i=t.onRequest,onResponse:a=t.onResponse,timeout:o=t.timeout??1e4}=n,c={...t.fetchOptions??{},...n.fetchOptions??{}},{headers:u,method:d,signal:l}=c;try{const t=await function(e,{errorInstance:t=new Error("timed out"),timeout:n,signal:r}){return new Promise(((s,i)=>{(async()=>{let a;try{const o=new AbortController;n>0&&(a=setTimeout((()=>{r?o.abort():i(t)}),n)),s(await e({signal:o?.signal||null}))}catch(e){"AbortError"===e?.name&&i(t),i(e)}finally{clearTimeout(a)}})()}))}((async({signal:t})=>{const n={...c,body:Array.isArray(r)?Rn(r.map((e=>({jsonrpc:"2.0",id:e.id??fo.take(),...e})))):Rn({jsonrpc:"2.0",id:r.id??fo.take(),...r}),headers:{"Content-Type":"application/json",...u},method:d||"POST",signal:l||(o>0?t:null)},a=new Request(e,n),f=await(i?.(a,n))??{...n,url:e};return await s(f.url??e,f)}),{errorInstance:new ar({body:r,url:e}),timeout:o,signal:!0});let n;if(a&&await a(t),t.headers.get("Content-Type")?.startsWith("application/json"))n=await t.json();else{n=await t.text();try{n=JSON.parse(n||"{}")}catch(e){if(t.ok)throw e;n={error:n}}}if(!t.ok)throw new sr({body:r,details:Rn(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof sr)throw t;if(t instanceof ar)throw t;throw new sr({body:r,cause:t,url:e})}}}}const ho="Ethereum Signed Message:\n";function mo(e,t){return Dt(function(e){const t="string"==typeof e?Ue(e):"string"==typeof e.raw?e.raw:Ce(e.raw);return Jt([Ue(`${ho}${Y(t)}`),t])}(e),t)}class yo extends ee{constructor({domain:e}){super(`Invalid domain "${Rn(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class bo extends ee{constructor({primaryType:e,types:t}){super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(t))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class go extends ee{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function wo({domain:e}){return["string"==typeof e?.name&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},("number"==typeof e?.chainId||"bigint"==typeof e?.chainId)&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function vo(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new go({type:e})}function xo(e){const{domain:t={},message:n,primaryType:r}=e,s={EIP712Domain:wo({domain:t}),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:s}=e,i=(e,t)=>{for(const n of e){const{name:e,type:r}=n,a=t[e],o=r.match(on);if(o&&("number"==typeof a||"bigint"==typeof a)){const[e,t,n]=o;Be(a,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof a&&!Qt(a))throw new Kt({address:a});const c=r.match(an);if(c){const[e,t]=c;if(t&&Y(a)!==Number.parseInt(t,10))throw new ye({expectedSize:Number.parseInt(t,10),givenSize:Y(a)})}const u=s[r];u&&(vo(r),i(u,a))}};if(s.EIP712Domain&&t){if("object"!=typeof t)throw new yo({domain:t});i(s.EIP712Domain,t)}if("EIP712Domain"!==r){if(!s[r])throw new bo({primaryType:r,types:s});i(s[r],n)}}({domain:t,message:n,primaryType:r,types:s});const i=["0x1901"];return t&&i.push(function({domain:e,types:t}){return Io({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:s})),"EIP712Domain"!==r&&i.push(Io({data:n,primaryType:r,types:s})),Dt(Jt(i))}function Io({data:e,primaryType:t,types:n}){return Dt(Po({data:e,primaryType:t,types:n}))}function Po({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],s=[zo({primaryType:t,types:n})];for(const i of n[t]){const[t,a]=Ao({types:n,name:i.name,type:i.type,value:e[i.name]});r.push(t),s.push(a)}return cn(r,s)}function zo({primaryType:e,types:t}){const n=_e(function({primaryType:e,types:t}){let n="";const r=Eo({primaryType:e,types:t});r.delete(e);const s=[e,...Array.from(r).sort()];for(const e of s)n+=`${e}(${t[e].map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`;return n}({primaryType:e,types:t}));return Dt(n)}function Eo({primaryType:e,types:t},n=new Set){const r=e.match(/^\w*/u),s=r?.[0];if(n.has(s)||void 0===t[s])return n;n.add(s);for(const e of t[s])Eo({primaryType:e.type,types:t},n);return n}function Ao({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},Dt(Po({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},Dt(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},Dt(_e(r))];if(n.lastIndexOf("]")===n.length-1){const s=n.slice(0,n.lastIndexOf("[")),i=r.map((n=>Ao({name:t,type:s,types:e,value:n})));return[{type:"bytes32"},Dt(cn(i.map((([e])=>e)),i.map((([,e])=>e))))]}return[{type:n},r]}class ko extends Error{constructor(e,t={}){const n=t.cause instanceof ko?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof ko&&t.cause.docsPath||t.docsPath;super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...r?[`Docs: https://abitype.dev${r}`]:[],...n?[`Details: ${n}`]:[],"Version: abitype@1.2.3"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),t.cause&&(this.cause=t.cause),this.details=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.shortMessage=e}}function Mo(e,t){const n=e.exec(t);return n?.groups}const $o=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Oo=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,jo=/^\(.+?\).*?$/,So=/^tuple(?<array>(\[(\d*)\])*)$/;function No(e){let t=e.type;if(So.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=No(e.components[r]),r<n-1&&(t+=", ")}const r=Mo(So,e.type);return t+=`)${r?.array||""}`,No({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function To(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=No(e[r]),r!==n-1&&(t+=", ")}return t}const _o=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Ro=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Co=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const Bo=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function Do(e){return Bo.test(e)}function Uo(e){return Mo(Bo,e)}const qo=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const Lo=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const Fo=/^receive\(\) external payable$/;const Ko=new Set(["memory","indexed","storage","calldata"]),Vo=new Set(["indexed"]),Go=new Set(["calldata","memory","storage"]);class Zo extends ko{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class Ho extends ko{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class Wo extends ko{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class Yo extends ko{constructor({params:e}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class Qo extends ko{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class Jo extends ko{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class Xo extends ko{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class ec extends ko{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class tc extends ko{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class nc extends ko{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class rc extends ko{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class sc extends ko{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class ic extends ko{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class ac extends ko{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const oc=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function cc(e,t={}){if(function(e){return Co.test(e)}(e))return function(e,t={}){const n=function(e){return Mo(Co,e)}(e);if(!n)throw new nc({signature:e,type:"function"});const r=pc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(fc(r[e],{modifiers:Go,structs:t,type:"function"}));const a=[];if(n.returns){const e=pc(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(fc(e[n],{modifiers:Go,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:a}}(e,t);if(function(e){return Ro.test(e)}(e))return function(e,t={}){const n=function(e){return Mo(Ro,e)}(e);if(!n)throw new nc({signature:e,type:"event"});const r=pc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(fc(r[e],{modifiers:Vo,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}(e,t);if(function(e){return _o.test(e)}(e))return function(e,t={}){const n=function(e){return Mo(_o,e)}(e);if(!n)throw new nc({signature:e,type:"error"});const r=pc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(fc(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}(e,t);if(function(e){return qo.test(e)}(e))return function(e,t={}){const n=function(e){return Mo(qo,e)}(e);if(!n)throw new nc({signature:e,type:"constructor"});const r=pc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(fc(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}(e,t);if(function(e){return Lo.test(e)}(e))return function(e){const t=function(e){return Mo(Lo,e)}(e);if(!t)throw new nc({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return Fo.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new rc({signature:e})}const uc=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,dc=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,lc=/^u?int$/;function fc(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:`${e}${r}`}(e,t?.type,t?.structs);if(oc.has(n))return oc.get(n);const r=jo.test(e),s=Mo(r?dc:uc,e);if(!s)throw new Qo({param:e});if(s.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||$o.test(e)||Oo.test(e)||mc.test(e)}(s.name))throw new Jo({param:e,name:s.name});const i=s.name?{name:s.name}:{},a="indexed"===s.modifier?{indexed:!0}:{},o=t?.structs??{};let c,u={};if(r){c="tuple";const e=pc(s.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(fc(e[r],{structs:o}));u={components:t}}else if(s.type in o)c="tuple",u={components:o[s.type]};else if(lc.test(s.type))c=`${s.type}256`;else if("address payable"===s.type)c="address";else if(c=s.type,"struct"!==t?.type&&!hc(c))throw new Wo({type:c});if(s.modifier){if(!t?.modifiers?.has?.(s.modifier))throw new Xo({param:e,type:t?.type,modifier:s.modifier});if(Go.has(s.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!s.array))throw new ec({param:e,type:t?.type,modifier:s.modifier})}const d={type:`${c}${s.array??""}`,...i,...a,...u};return oc.set(n,d),d}function pc(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const s=e[i],a=e.slice(i+1);switch(s){case",":return 0===r?pc(a,[...t,n.trim()]):pc(a,t,`${n}${s}`,r);case"(":return pc(a,t,`${n}${s}`,r+1);case")":return pc(a,t,`${n}${s}`,r-1);default:return pc(a,t,`${n}${s}`,r)}}if(""===n)return t;if(0!==r)throw new ac({current:n,depth:r});return t.push(n.trim()),t}function hc(e){return"address"===e||"bool"===e||"function"===e||"string"===e||$o.test(e)||Oo.test(e)}const mc=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function yc(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!Do(n))continue;const s=Uo(n);if(!s)throw new nc({signature:n,type:"struct"});const i=s.properties.split(";"),a=[],o=i.length;for(let e=0;e<o;e++){const t=i[e].trim();if(!t)continue;const n=fc(t,{type:"struct"});a.push(n)}if(!a.length)throw new sc({signature:n});t[s.name]=a}const r={},s=Object.entries(t),i=s.length;for(let e=0;e<i;e++){const[n,i]=s[e];r[n]=gc(i,t)}return r}const bc=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function gc(e=[],t={},n=new Set){const r=[],s=e.length;for(let i=0;i<s;i++){const s=e[i];if(jo.test(s.type))r.push(s);else{const e=Mo(bc,s.type);if(!e?.type)throw new tc({abiParameter:s});const{array:i,type:a}=e;if(a in t){if(n.has(a))throw new ic({type:a});r.push({...s,type:`tuple${i??""}`,components:gc(t[a],t,new Set([...n,a]))})}else{if(!hc(a))throw new Ho({type:a});r.push(s)}}}return r}function wc(e){let t;if("string"==typeof e)t=cc(e);else{const n=yc(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(!Do(r)){t=cc(r,n);break}}}if(!t)throw new Zo({signature:e});return t}function vc(e){const t=[];if("string"==typeof e){const n=pc(e),r=n.length;for(let e=0;e<r;e++)t.push(fc(n[e],{modifiers:Ko}))}else{const n=yc(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(Do(r))continue;const i=pc(r),a=i.length;for(let e=0;e<a;e++)t.push(fc(i[e],{modifiers:Ko,structs:n}))}}if(0===t.length)throw new Yo({params:e});return t}class xc extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const Ic={checksum:new xc(8192)}.checksum;function Pc(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Bt(Ni(e));return"Bytes"===n?r:Qi(r)}const zc=/^0x[a-fA-F0-9]{40}$/;function Ec(e,t={}){const{strict:n=!0}=t;if(!zc.test(e))throw new kc({address:e,cause:new Mc});if(n){if(e.toLowerCase()===e)return;if(Ac(e)!==e)throw new kc({address:e,cause:new $c})}}function Ac(e){if(Ic.has(e))return Ic.get(e);Ec(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=Pc(_i(t),{as:"Bytes"}),r=t.split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&r[e]&&(r[e]=r[e].toUpperCase()),(15&n[e>>1])>=8&&r[e+1]&&(r[e+1]=r[e+1].toUpperCase());const s=`0x${r.join("")}`;return Ic.set(e,s),s}class kc extends Pi{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Mc extends Pi{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class $c extends Pi{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Oc=/^(.*)\[([0-9]*)\]$/,jc=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Sc=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,Nc=2n**256n-1n;function Tc(e,t,n){const{checksumAddress:r,staticPosition:s}=n,i=Dc(t.type);if(i){const[n,a]=i;return function(e,t,n){const{checksumAddress:r,length:s,staticPosition:i}=n;if(!s){const n=i+Ui(e.readBytes(Rc)),s=n+_c;e.setPosition(n);const a=Ui(e.readBytes(_c)),o=Uc(t);let c=0;const u=[];for(let n=0;n<a;++n){e.setPosition(s+(o?32*n:c));const[i,a]=Tc(e,t,{checksumAddress:r,staticPosition:s});c+=a,u.push(i)}return e.setPosition(i+32),[u,32]}if(Uc(t)){const n=i+Ui(e.readBytes(Rc)),a=[];for(let i=0;i<s;++i){e.setPosition(n+32*i);const[s]=Tc(e,t,{checksumAddress:r,staticPosition:n});a.push(s)}return e.setPosition(i+32),[a,32]}let a=0;const o=[];for(let n=0;n<s;++n){const[n,s]=Tc(e,t,{checksumAddress:r,staticPosition:i+a});a+=s,o.push(n)}return[o,a]}(e,{...t,type:a},{checksumAddress:r,length:n,staticPosition:s})}if("tuple"===t.type)return function(e,t,n){const{checksumAddress:r,staticPosition:s}=n,i=0===t.components.length||t.components.some((({name:e})=>!e)),a=i?[]:{};let o=0;if(Uc(t)){const n=s+Ui(e.readBytes(Rc));for(let s=0;s<t.components.length;++s){const c=t.components[s];e.setPosition(n+o);const[u,d]=Tc(e,c,{checksumAddress:r,staticPosition:n});o+=d,a[i?s:c?.name]=u}return e.setPosition(s+32),[a,32]}for(let n=0;n<t.components.length;++n){const c=t.components[n],[u,d]=Tc(e,c,{checksumAddress:r,staticPosition:s});a[i?n:c?.name]=u,o+=d}return[a,o]}(e,t,{checksumAddress:r,staticPosition:s});if("address"===t.type)return function(e,t={}){const{checksum:n=!1}=t,r=e.readBytes(32),s=e=>n?Ac(e):e;return[s(Qi(Ci(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[Di(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const t=Ui(e.readBytes(32));e.setPosition(n+t);const r=Ui(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const s=e.readBytes(r);return e.setPosition(n+32),[Qi(s),32]}const i=Qi(e.readBytes(Number.parseInt(s,10),32));return[i,32]}(e,t,{staticPosition:s});if(t.type.startsWith("uint")||t.type.startsWith("int"))return function(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),s=e.readBytes(32);return[r>48?Bi(s,{signed:n}):Ui(s,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=Ui(e.readBytes(32)),r=t+n;e.setPosition(r);const s=Ui(e.readBytes(32));if(0===s)return e.setPosition(t+32),["",32];const i=e.readBytes(s,32),a=qi(Li(i));return e.setPosition(t+32),[a,32]}(e,{staticPosition:s});throw new tu(t.type)}const _c=32,Rc=32;function Cc({checksumAddress:e=!1,parameter:t,value:n}){const r=t,s=Dc(r.type);if(s){const[t,i]=s;return function(e,t){const{checksumAddress:n,length:r,parameter:s}=t,i=null===r;if(!Array.isArray(e))throw new eu(e);if(!i&&e.length!==r)throw new Qc({expectedLength:r,givenLength:e.length,type:`${s.type}[${r}]`});let a=!1;const o=[];for(let t=0;t<e.length;t++){const r=Cc({checksumAddress:n,parameter:s,value:e[t]});r.dynamic&&(a=!0),o.push(r)}if(i||a){const e=Bc(o);if(i){const t=Ji(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?Wi(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Wi(...o.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:i}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let s=!1;const i=[];for(let t=0;t<r.components.length;t++){const a=r.components[t],o=Cc({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});i.push(o),o.dynamic&&(s=!0)}return{dynamic:s,encoded:s?Bc(i):Wi(...i.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return Ec(e,{strict:n}),{dynamic:!1,encoded:ea(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new Pi(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:ea(Yi(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Sc.exec(r.type)??[];return function(e,{signed:t,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new aa({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Ji(e,{size:32,signed:t})}}(n,{signed:e,size:Number(t)})}if(r.type.startsWith("bytes"))return function(e,{type:t}){const[,n]=t.split("bytes"),r=ra(e);if(!n){let t=e;return r%32!=0&&(t=ta(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:Wi(ea(Ji(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new Jc({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:ta(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=Xi(e),n=Math.ceil(ra(t)/32),r=[];for(let e=0;e<n;e++)r.push(ta(na(t,32*e,32*(e+1))));return{dynamic:!0,encoded:Wi(ta(Ji(ra(t),{size:32})),...r)}}(n);throw new tu(r.type)}function Bc(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:s}=e[n];t+=r?32:ra(s)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(Ji(t+s,{size:32})),r.push(o),s+=ra(o)):n.push(o)}return Wi(...n,...r)}function Dc(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Uc(e){const{type:t}=e;if("string"===t)return!0;if("bytes"===t)return!0;if(t.endsWith("[]"))return!0;if("tuple"===t)return e.components?.some(Uc);const n=Dc(e.type);return!(!n||!Uc({...e,type:n[1]}))}const qc={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Kc({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Fc({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Lc({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new Lc({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};class Lc extends Pi{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class Fc extends Pi{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class Kc extends Pi{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function Vc(e,t,n={}){const{as:r="Array",checksumAddress:s=!1}=n,i="string"==typeof t?Ti(t):t,a=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(qc);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(i);if(0===Ri(i)&&e.length>0)throw new Yc;if(Ri(i)&&Ri(i)<32)throw new Wc({data:"string"==typeof t?t:Qi(t),parameters:e,size:Ri(i)});let o=0;const c="Array"===r?[]:{};for(let t=0;t<e.length;++t){const n=e[t];a.setPosition(o);const[i,u]=Tc(a,n,{checksumAddress:s,staticPosition:0});o+=u,"Array"===r?c.push(i):c[n.name??t]=i}return c}function Gc(e,t,n){const{checksumAddress:r=!1}=n??{};if(e.length!==t.length)throw new Xc({expectedLength:e.length,givenLength:t.length});const s=function({checksumAddress:e,parameters:t,values:n}){const r=[];for(let s=0;s<t.length;s++)r.push(Cc({checksumAddress:e,parameter:t[s],value:n[s]}));return r}({checksumAddress:r,parameters:e,values:t}),i=Bc(s);return 0===i.length?"0x":i}function Zc(e,t){if(e.length!==t.length)throw new Xc({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r];n.push(Zc.encode(s,i))}return Wi(...n)}function Hc(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?vc(e):e}(Zc||(Zc={})).encode=function e(t,n,r=!1){if("address"===t){const e=n;return Ec(e),ea(e.toLowerCase(),r?32:0)}if("string"===t)return Xi(n);if("bytes"===t)return n;if("bool"===t)return ea(Yi(n),r?32:1);const s=t.match(Sc);if(s){const[e,t,i="256"]=s,a=Number.parseInt(i,10)/8;return Ji(n,{size:r?32:a,signed:"int"===t})}const i=t.match(jc);if(i){const[e,t]=i;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new Jc({expectedSize:Number.parseInt(t,10),value:n});return ta(n,r?32:0)}const a=t.match(Oc);if(a&&Array.isArray(n)){const[t,r]=a,s=[];for(let t=0;t<n.length;t++)s.push(e(r,n[t],!0));return 0===s.length?"0x":Wi(...s)}throw new tu(t)};class Wc extends Pi{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${To(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Yc extends Pi{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Qc extends Pi{constructor({expectedLength:e,givenLength:t,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class Jc extends Pi{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${ra(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Xc extends Pi{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class eu extends Pi{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class tu extends Pi{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class nu extends vt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");lt(e.outputLen),lt(e.blockLen)}(e);const n=wt(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),mt(s)}update(e){return pt(this),this.iHash.update(e),this}digestInto(e){pt(this),ft(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:s,blockLen:i,outputLen:a}=this;return e.finished=r,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ru=(e,t,n)=>new nu(e,t).update(n).digest();ru.create=(e,t)=>new nu(e,t);const su=BigInt(0),iu=BigInt(1),au=BigInt(2),ou=BigInt(3),cu=BigInt(4),uu=BigInt(5),du=BigInt(8);function lu(e,t){const n=e%t;return n>=su?n:t+n}function fu(e,t,n){let r=e;for(;t-- >su;)r*=r,r%=n;return r}function pu(e,t){if(e===su)throw new Error("invert: expected non-zero number");if(t<=su)throw new Error("invert: expected positive modulus, got "+t);let n=lu(e,t),r=t,s=su,i=iu;for(;n!==su;){const e=r%n,t=s-i*(r/n);r=n,n=e,s=i,i=t}if(r!==iu)throw new Error("invert: does not exist");return lu(s,t)}function hu(e,t){const n=(e.ORDER+iu)/cu,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function mu(e,t){const n=(e.ORDER-uu)/du,r=e.mul(t,au),s=e.pow(r,n),i=e.mul(t,s),a=e.mul(e.mul(i,au),s),o=e.mul(i,e.sub(a,e.ONE));if(!e.eql(e.sqr(o),t))throw new Error("Cannot find square root");return o}function yu(e){return e%cu===ou?hu:e%du===uu?mu:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-iu,n=0;for(;t%au===su;)t/=au,n++;let r=au;const s=Iu(e);for(;1===vu(s,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return hu;let i=s.pow(r,t);const a=(t+iu)/au;return function(e,r){if(e.is0(r))return r;if(1!==vu(e,r))throw new Error("Cannot find square root");let s=n,o=e.mul(e.ONE,i),c=e.pow(r,t),u=e.pow(r,a);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===s)throw new Error("Cannot find square root");const r=iu<<BigInt(s-t-1),i=e.pow(o,r);s=t,o=e.sqr(i),c=e.mul(c,o),u=e.mul(u,i)}return u}}(e)}const bu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gu(e){return xi(e,bu.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}function wu(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce(((t,n,s)=>e.is0(n)?t:(r[s]=t,e.mul(t,n))),e.ONE),i=e.inv(s);return t.reduceRight(((t,n,s)=>e.is0(n)?t:(r[s]=e.mul(t,r[s]),e.mul(t,n))),i),r}function vu(e,t){const n=(e.ORDER-iu)/au,r=e.pow(t,n),s=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),a=e.eql(r,e.neg(e.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function xu(e,t){void 0!==t&<(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Iu(e,t,n=!1,r={}){if(e<=su)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:s,nByteLength:i}=xu(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const o=Object.freeze({ORDER:e,isLE:n,BITS:s,BYTES:i,MASK:bi(s),ZERO:su,ONE:iu,create:t=>lu(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return su<=t&&t<e},is0:e=>e===su,isOdd:e=>(e&iu)===iu,neg:t=>lu(-t,e),eql:(e,t)=>e===t,sqr:t=>lu(t*t,e),add:(t,n)=>lu(t+n,e),sub:(t,n)=>lu(t-n,e),mul:(t,n)=>lu(t*n,e),pow:(e,t)=>function(e,t,n){if(n<su)throw new Error("invalid exponent, negatives unsupported");if(n===su)return e.ONE;if(n===iu)return t;let r=e.ONE,s=t;for(;n>su;)n&iu&&(r=e.mul(r,s)),s=e.sqr(s),n>>=iu;return r}(o,e,t),div:(t,n)=>lu(t*pu(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>pu(t,e),sqrt:r.sqrt||(t=>(a||(a=yu(e)),a(o,t))),toBytes:e=>n?di(e,i):ui(e,i),fromBytes:e=>{if(e.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);return n?ci(e):oi(e)},invertBatch:e=>wu(o,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(o)}function Pu(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function zu(e){const t=Pu(e);return t+Math.ceil(t/2)}const Eu=BigInt(0),Au=BigInt(1);function ku(e,t){const n=t.negate();return e?n:t}function Mu(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function $u(e,t){Mu(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:bi(e),maxNumber:n,shiftBy:BigInt(e)}}function Ou(e,t,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:a}=n;let o=Number(e&s),c=e>>a;o>r&&(o-=i,c+=Au);const u=t*r;return{nextN:c,offset:u+Math.abs(o)-1,isZero:0===o,isNeg:o<0,isNegF:t%2!=0,offsetF:u}}const ju=new WeakMap,Su=new WeakMap;function Nu(e){return Su.get(e)||1}function Tu(e,t,n,r){!function(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}(n,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}(r,t);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,o=function(e){let t;for(t=0;e>Hs;e>>=Ws,t+=1);return t}(BigInt(s));let c=1;o>12?c=o-3:o>4?c=o-2:o>0&&(c=2);const u=bi(c),d=new Array(Number(u)+1).fill(a);let l=a;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){d.fill(a);for(let t=0;t<i;t++){const s=r[t],i=Number(s>>BigInt(e)&u);d[i]=d[i].add(n[t])}let t=a;for(let e=d.length-1,n=a;e>0;e--)n=n.add(d[e]),t=t.add(n);if(l=l.add(t),0!==e)for(let e=0;e<c;e++)l=l.double()}return l}function _u(e){return gu(e.Fp),xi(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...xu(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function Ru(e){void 0!==e.lowS&&Js("lowS",e.lowS),void 0!==e.prehash&&Js("prehash",e.prehash)}class Cu extends Error{constructor(e=""){super(e)}}const Bu={Err:Cu,_tlv:{encode:(e,t)=>{const{Err:n}=Bu;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=Xs(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?Xs(s.length/2|128):"";return Xs(e)+i+s+t},decode(e,t){const{Err:n}=Bu;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[r++];let i=0;if(!!(128&s)){const e=127&s;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+e);if(a.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===a[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of a)i=i<<8|e;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=s;const a=t.subarray(r,r+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=Bu;if(e<Uu)throw new t("integer: negative integers are not allowed");let n=Xs(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=Bu;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return oi(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Bu,s=li("signature",e),{v:i,l:a}=r.decode(48,s);if(a.length)throw new t("invalid signature: left bytes after parsing");const{v:o,l:c}=r.decode(2,i),{v:u,l:d}=r.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(o),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=Bu,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function Du(e,t){return ri(ui(e,t))}const Uu=BigInt(0),qu=BigInt(1),Lu=BigInt(2),Fu=BigInt(3),Ku=BigInt(4);function Vu(e){const t=function(e){const t=_u(e);xi(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}(e),{Fp:n}=t,r=Iu(t.n,t.nBitLength),s=t.toBytes||((e,t,r)=>{const s=t.toAffine();return fi(Uint8Array.from([4]),n.toBytes(s.x),n.toBytes(s.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){const{a:r,b:s}=t,i=n.sqr(e),a=n.mul(i,e);return n.add(n.add(a,n.mul(e,r)),s)}function o(e,t){const r=n.sqr(t),s=a(e);return n.eql(r,s)}if(!o(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const c=n.mul(n.pow(t.a,Fu),Ku),u=n.mul(n.sqr(t.b),BigInt(27));if(n.is0(n.add(c,u)))throw new Error("bad curve params: a or b");function d(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:s,n:i}=t;if(n&&"bigint"!=typeof e){if(Ys(e)&&(e=ri(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*r,"0")}let a;try{a="bigint"==typeof e?e:oi(li("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return s&&(a=lu(a,i)),yi("private key",a,qu,i),a}function l(e){if(!(e instanceof h))throw new Error("ProjectivePoint expected")}const f=Ii(((e,t)=>{const{px:r,py:s,pz:i}=e;if(n.eql(i,n.ONE))return{x:r,y:s};const a=e.is0();null==t&&(t=a?n.ONE:n.inv(i));const o=n.mul(r,t),c=n.mul(s,t),u=n.mul(i,t);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:o,y:c}})),p=Ii((e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:r,y:s}=e.toAffine();if(!n.isValid(r)||!n.isValid(s))throw new Error("bad point: x or y not FE");if(!o(r,s))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class h{constructor(e,t,r){if(null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t)||n.is0(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required");this.px=e,this.py=t,this.pz=r,Object.freeze(this)}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof h)throw new Error("projective point not allowed");const s=e=>n.eql(e,n.ZERO);return s(t)&&s(r)?h.ZERO:new h(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=wu(n,e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(i(li("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(d(e))}static msm(e,t){return Tu(h,r,e,t)}_setWindowSize(e){b.setWindowSize(this,e)}assertValidity(){p(this)}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:r,pz:s}=this,{px:i,py:a,pz:o}=e,c=n.eql(n.mul(t,o),n.mul(i,s)),u=n.eql(n.mul(r,o),n.mul(a,s));return c&&u}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,s=n.mul(r,Fu),{px:i,py:a,pz:o}=this;let c=n.ZERO,u=n.ZERO,d=n.ZERO,l=n.mul(i,i),f=n.mul(a,a),p=n.mul(o,o),m=n.mul(i,a);return m=n.add(m,m),d=n.mul(i,o),d=n.add(d,d),c=n.mul(e,d),u=n.mul(s,p),u=n.add(c,u),c=n.sub(f,u),u=n.add(f,u),u=n.mul(c,u),c=n.mul(m,c),d=n.mul(s,d),p=n.mul(e,p),m=n.sub(l,p),m=n.mul(e,m),m=n.add(m,d),d=n.add(l,l),l=n.add(d,l),l=n.add(l,p),l=n.mul(l,m),u=n.add(u,l),p=n.mul(a,o),p=n.add(p,p),l=n.mul(p,m),c=n.sub(c,l),d=n.mul(p,f),d=n.add(d,d),d=n.add(d,d),new h(c,u,d)}add(e){l(e);const{px:r,py:s,pz:i}=this,{px:a,py:o,pz:c}=e;let u=n.ZERO,d=n.ZERO,f=n.ZERO;const p=t.a,m=n.mul(t.b,Fu);let y=n.mul(r,a),b=n.mul(s,o),g=n.mul(i,c),w=n.add(r,s),v=n.add(a,o);w=n.mul(w,v),v=n.add(y,b),w=n.sub(w,v),v=n.add(r,i);let x=n.add(a,c);return v=n.mul(v,x),x=n.add(y,g),v=n.sub(v,x),x=n.add(s,i),u=n.add(o,c),x=n.mul(x,u),u=n.add(b,g),x=n.sub(x,u),f=n.mul(p,v),u=n.mul(m,g),f=n.add(u,f),u=n.sub(b,f),f=n.add(b,f),d=n.mul(u,f),b=n.add(y,y),b=n.add(b,y),g=n.mul(p,g),v=n.mul(m,v),b=n.add(b,g),g=n.sub(y,g),g=n.mul(p,g),v=n.add(v,g),y=n.mul(b,v),d=n.add(d,y),y=n.mul(x,v),u=n.mul(w,u),u=n.sub(u,y),y=n.mul(w,b),f=n.mul(x,f),f=n.add(f,y),new h(u,d,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return b.wNAFCached(this,e,h.normalizeZ)}multiplyUnsafe(e){const{endo:r,n:s}=t;yi("scalar",e,Uu,s);const i=h.ZERO;if(e===Uu)return i;if(this.is0()||e===qu)return this;if(!r||b.hasPrecomputes(this))return b.wNAFCachedUnsafe(this,e,h.normalizeZ);let{k1neg:a,k1:o,k2neg:c,k2:u}=r.splitScalar(e),d=i,l=i,f=this;for(;o>Uu||u>Uu;)o&qu&&(d=d.add(f)),u&qu&&(l=l.add(f)),f=f.double(),o>>=qu,u>>=qu;return a&&(d=d.negate()),c&&(l=l.negate()),l=new h(n.mul(l.px,r.beta),l.py,l.pz),d.add(l)}multiply(e){const{endo:r,n:s}=t;let i,a;if(yi("scalar",e,qu,s),r){const{k1neg:t,k1:s,k2neg:o,k2:c}=r.splitScalar(e);let{p:u,f:d}=this.wNAF(s),{p:l,f:f}=this.wNAF(c);u=b.constTimeNegate(t,u),l=b.constTimeNegate(o,l),l=new h(n.mul(l.px,r.beta),l.py,l.pz),i=u.add(l),a=d.add(f)}else{const{p:t,f:n}=this.wNAF(e);i=t,a=n}return h.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=h.BASE,s=(e,t)=>t!==Uu&&t!==qu&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=s(this,t).add(s(e,n));return i.is0()?void 0:i}toAffine(e){return f(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===qu)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===qu?this:n?n(h,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return Js("isCompressed",e),this.assertValidity(),s(h,this,e)}toHex(e=!0){return Js("isCompressed",e),ri(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const{endo:m,nBitLength:y}=t,b=(g=h,w=m?Math.ceil(y/2):y,{constTimeNegate:ku,hasPrecomputes:e=>1!==Nu(e),unsafeLadder(e,t,n=g.ZERO){let r=e;for(;t>Eu;)t&Au&&(n=n.add(r)),r=r.double(),t>>=Au;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=$u(t,w),s=[];let i=e,a=i;for(let e=0;e<n;e++){a=i,s.push(a);for(let e=1;e<r;e++)a=a.add(i),s.push(a);i=a.double()}return s},wNAF(e,t,n){let r=g.ZERO,s=g.BASE;const i=$u(e,w);for(let e=0;e<i.windows;e++){const{nextN:a,offset:o,isZero:c,isNeg:u,isNegF:d,offsetF:l}=Ou(n,e,i);n=a,c?s=s.add(ku(d,t[l])):r=r.add(ku(u,t[o]))}return{p:r,f:s}},wNAFUnsafe(e,t,n,r=g.ZERO){const s=$u(e,w);for(let e=0;e<s.windows&&n!==Eu;e++){const{nextN:i,offset:a,isZero:o,isNeg:c}=Ou(n,e,s);if(n=i,!o){const e=t[a];r=r.add(c?e.negate():e)}}return r},getPrecomputes(e,t,n){let r=ju.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&ju.set(t,n(r))),r},wNAFCached(e,t,n){const r=Nu(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const s=Nu(e);return 1===s?this.unsafeLadder(e,t,r):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),t,r)},setWindowSize(e,t){Mu(t,w),Su.set(e,t),ju.delete(e)}});var g,w;return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:d,weierstrassEquation:a,isWithinCurveOrder:function(e){return mi(e,qu,t.n)}}}function Gu(e){const t=function(e){const t=_u(e);return xi(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r,nByteLength:s,nBitLength:i}=t,a=n.BYTES+1,o=2*n.BYTES+1;function c(e){return lu(e,r)}function u(e){return pu(e,r)}const{ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:f,isWithinCurveOrder:p}=Vu({...t,toBytes(e,t,r){const s=t.toAffine(),i=n.toBytes(s.x),a=fi;return Js("isCompressed",r),r?a(Uint8Array.from([t.hasEvenY()?2:3]),i):a(Uint8Array.from([4]),i,n.toBytes(s.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==a||2!==r&&3!==r){if(t===o&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error("invalid Point, expected length of "+a+", or uncompressed "+o+", got "+t)}{const e=oi(s);if(!mi(e,qu,n.ORDER))throw new Error("Point is not on curve");const t=f(e);let i;try{i=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return 1==(1&r)!==((i&qu)===qu)&&(i=n.neg(i)),{x:e,y:i}}}});function h(e){return e>r>>qu}const m=(e,t,n)=>oi(e.slice(t,n));class y{constructor(e,t,n){yi("r",e,qu,r),yi("s",t,qu,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=s;return e=li("compactSignature",e,2*t),new y(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=Bu.toSig(li("DER",e));return new y(t,n)}assertValidity(){}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:s,recovery:i}=this,a=v(li("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const o=2===i||3===i?r+t.n:r;if(o>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=0==(1&i)?"02":"03",f=d.fromHex(l+Du(o,n.BYTES)),p=u(o),h=c(-a*p),m=c(s*p),y=d.BASE.multiplyAndAddUnsafe(f,h,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return ai(this.toDERHex())}toDERHex(){return Bu.hexFromSig(this)}toCompactRawBytes(){return ai(this.toCompactHex())}toCompactHex(){const e=s;return Du(this.r,e)+Du(this.s,e)}}const b={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=zu(t.n);return function(e,t,n=!1){const r=e.length,s=Pu(t),i=zu(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const a=lu(n?ci(e):oi(e),t-iu)+iu;return n?di(a,s):ui(a,s)}(t.randomBytes(e),t.n)},precompute:(e=8,t=d.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function g(e){if("bigint"==typeof e)return!1;if(e instanceof d)return!0;const r=li("key",e).length,i=n.BYTES,a=i+1,o=2*i+1;return t.allowedPrivateKeyLengths||s===a?void 0:r===a||r===o}const w=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=oi(e),n=8*e.length-i;return n>0?t>>BigInt(n):t},v=t.bits2int_modN||function(e){return c(w(e))},x=bi(i);function I(e){return yi("num < 2^"+i,e,Uu,x),ui(e,s)}function P(e,r,s=z){if(["recovered","canonical"].some((e=>e in s)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:a}=t;let{lowS:o,prehash:f,extraEntropy:m}=s;null==o&&(o=!0),e=li("msgHash",e),Ru(s),f&&(e=li("prehashed msgHash",i(e)));const b=v(e),g=l(r),x=[I(g),I(b)];if(null!=m&&!1!==m){const e=!0===m?a(n.BYTES):m;x.push(li("extraEntropy",e))}const P=fi(...x),E=b;return{seed:P,k2sig:function(e){const t=w(e);if(!p(t))return;const n=u(t),r=d.BASE.multiply(t).toAffine(),s=c(r.x);if(s===Uu)return;const i=c(n*c(E+s*g));if(i===Uu)return;let a=(r.x===s?0:2)|Number(r.y&qu),l=i;return o&&h(i)&&(l=function(e){return h(e)?c(-e):e}(i),a^=1),new y(s,l,a)}}}const z={lowS:t.lowS,prehash:!1},E={lowS:t.lowS,prehash:!1};return d.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return d.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(!0===g(e))throw new Error("first arg must be private key");if(!1===g(t))throw new Error("second arg must be public key");return d.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,n,r=z){const{seed:s,k2sig:i}=P(e,n,r),a=t,o=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=gi(e),s=gi(e),i=0;const a=()=>{r.fill(1),s.fill(0),i=0},o=(...e)=>n(s,r,...e),c=(e=gi(0))=>{s=o(wi([0]),e),r=o(),0!==e.length&&(s=o(wi([1]),e),r=o())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=o();const t=r.slice();n.push(t),e+=r.length}return fi(...n)};return(e,t)=>{let n;for(a(),c(e);!(n=t(u()));)c();return a(),n}}(a.hash.outputLen,a.nByteLength,a.hmac);return o(s,i)},verify:function(e,n,r,s=E){const i=e;n=li("msgHash",n),r=li("publicKey",r);const{lowS:a,prehash:o,format:l}=s;if(Ru(s),"strict"in s)throw new Error("options.strict was renamed to lowS");if(void 0!==l&&"compact"!==l&&"der"!==l)throw new Error("format must be compact or der");const f="string"==typeof i||Ys(i),p=!f&&!l&&"object"==typeof i&&null!==i&&"bigint"==typeof i.r&&"bigint"==typeof i.s;if(!f&&!p)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let h,m;try{if(p&&(h=new y(i.r,i.s)),f){try{"compact"!==l&&(h=y.fromDER(i))}catch(e){if(!(e instanceof Bu.Err))throw e}h||"der"===l||(h=y.fromCompact(i))}m=d.fromHex(r)}catch(e){return!1}if(!h)return!1;if(a&&h.hasHighS())return!1;o&&(n=t.hash(n));const{r:b,s:g}=h,w=v(n),x=u(g),I=c(w*x),P=c(b*x),z=d.BASE.multiplyAndAddUnsafe(m,I,P)?.toAffine();return!!z&&c(z.x)===b},ProjectivePoint:d,Signature:y,utils:b}}function Zu(e,t){if(gu(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=function(e,t){const n=e.ORDER;let r=Uu;for(let e=n-qu;e%Lu===Uu;e/=Lu)r+=qu;const s=r,i=Lu<<s-qu-qu,a=i*Lu,o=(n-qu)/a,c=(o-qu)/Lu,u=a-qu,d=i,l=e.pow(t,o),f=e.pow(t,(o+qu)/Lu);let p=(t,n)=>{let r=l,i=e.pow(n,u),a=e.sqr(i);a=e.mul(a,n);let o=e.mul(t,a);o=e.pow(o,c),o=e.mul(o,i),i=e.mul(o,n),a=e.mul(o,t);let p=e.mul(a,i);o=e.pow(p,d);let h=e.eql(o,e.ONE);i=e.mul(a,f),o=e.mul(p,r),a=e.cmov(i,a,h),p=e.cmov(o,p,h);for(let t=s;t>qu;t--){let n=t-Lu;n=Lu<<n-qu;let s=e.pow(p,n);const o=e.eql(s,e.ONE);i=e.mul(a,r),r=e.mul(r,r),s=e.mul(p,r),a=e.cmov(i,a,o),p=e.cmov(s,p,o)}return{isValid:h,value:a}};if(e.ORDER%Ku===Fu){const n=(e.ORDER-Fu)/Ku,r=e.sqrt(e.neg(t));p=(t,s)=>{let i=e.sqr(s);const a=e.mul(t,s);i=e.mul(i,a);let o=e.pow(i,n);o=e.mul(o,a);const c=e.mul(o,r),u=e.mul(e.sqr(o),s),d=e.eql(u,t);return{isValid:d,value:e.cmov(c,o,d)}}}return p}(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let s,i,a,o,c,u,d,l;s=e.sqr(r),s=e.mul(s,t.Z),i=e.sqr(s),i=e.add(i,s),a=e.add(i,e.ONE),a=e.mul(a,t.B),o=e.cmov(t.Z,e.neg(i),!e.eql(i,e.ZERO)),o=e.mul(o,t.A),i=e.sqr(a),u=e.sqr(o),c=e.mul(u,t.A),i=e.add(i,c),i=e.mul(i,a),u=e.mul(u,o),c=e.mul(u,t.B),i=e.add(i,c),d=e.mul(s,a);const{isValid:f,value:p}=n(i,u);l=e.mul(s,r),l=e.mul(l,p),d=e.cmov(d,a,f),l=e.cmov(l,p,f);const h=e.isOdd(r)===e.isOdd(l);l=e.cmov(e.neg(l),l,h);const m=wu(e,[o],!0)[0];return d=e.mul(d,m),{x:d,y:l}}}function Hu(e){return{hash:e,hmac:(t,...n)=>ru(e,t,function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];ft(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const s=e[t];n.set(s,r),r+=s.length}return n}(...n)),randomBytes:It}}function Wu(e,t){const n=t=>Gu({...e,...Hu(t)});return{...n(t),create:n}}const Yu=oi;function Qu(e,t){if(Xu(e),Xu(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function Ju(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function Xu(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function ed(e,t,n){xi(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:s,m:i,hash:a,expand:o,DST:c}=n;Qs(e),Xu(t);const u="string"==typeof c?pi(c):c,d=r.toString(2).length,l=Math.ceil((d+s)/8),f=t*i*l;let p;if("xmd"===o)p=function(e,t,n,r){Qs(e),Qs(t),Xu(n),t.length>255&&(t=r(fi(pi("H2C-OVERSIZE-DST-"),t)));const{outputLen:s,blockLen:i}=r,a=Math.ceil(n/s);if(n>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");const o=fi(t,Qu(t.length,1)),c=Qu(0,i),u=Qu(n,2),d=new Array(a),l=r(fi(c,e,u,Qu(0,1),o));d[0]=r(fi(l,Qu(1,1),o));for(let e=1;e<=a;e++){const t=[Ju(l,d[e-1]),Qu(e+1,1),o];d[e]=r(fi(...t))}return fi(...d).slice(0,n)}(e,u,f,a);else if("xof"===o)p=function(e,t,n,r,s){if(Qs(e),Qs(t),Xu(n),t.length>255){const e=Math.ceil(2*r/8);t=s.create({dkLen:e}).update(pi("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:n}).update(e).update(Qu(n,2)).update(t).update(Qu(t.length,1)).digest()}(e,u,f,s,a);else{if("_internal_pass"!==o)throw new Error('expand must be "xmd" or "xof"');p=e}const h=new Array(t);for(let e=0;e<t;e++){const t=new Array(i);for(let n=0;n<i;n++){const s=l*(n+e*i),a=p.subarray(s,s+l);t[n]=lu(Yu(a),r)}h[e]=t}return h}const td=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),nd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),rd=BigInt(0),sd=BigInt(1),id=BigInt(2),ad=(e,t)=>(e+t/id)/t;function od(e){const t=td,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),a=BigInt(23),o=BigInt(44),c=BigInt(88),u=e*e*e%t,d=u*u*e%t,l=fu(d,n,t)*d%t,f=fu(l,n,t)*d%t,p=fu(f,id,t)*u%t,h=fu(p,s,t)*p%t,m=fu(h,i,t)*h%t,y=fu(m,o,t)*m%t,b=fu(y,c,t)*y%t,g=fu(b,o,t)*m%t,w=fu(g,n,t)*d%t,v=fu(w,a,t)*h%t,x=fu(v,r,t)*u%t,I=fu(x,id,t);if(!cd.eql(cd.sqr(I),e))throw new Error("Cannot find square root");return I}const cd=Iu(td,void 0,void 0,{sqrt:od}),ud=Wu({a:rd,b:BigInt(7),Fp:cd,n:nd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=nd,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-sd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,a=BigInt("0x100000000000000000000000000000000"),o=ad(i*e,t),c=ad(-r*e,t);let u=lu(e-o*n-c*s,t),d=lu(-o*r-c*i,t);const l=u>a,f=d>a;if(l&&(u=t-u),f&&(d=t-d),u>a||d>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:u,k2neg:f,k2:d}}}},Os),dd={};function ld(e,...t){let n=dd[e];if(void 0===n){const t=Os(Uint8Array.from(e,(e=>e.charCodeAt(0))));n=fi(t,t),dd[e]=n}return Os(fi(n,...t))}const fd=e=>e.toRawBytes(!0).slice(1),pd=e=>ui(e,32),hd=e=>lu(e,td),md=e=>lu(e,nd),yd=(()=>ud.ProjectivePoint)(),bd=(e,t,n)=>yd.BASE.multiplyAndAddUnsafe(e,t,n);function gd(e){let t=ud.utils.normPrivateKeyToScalar(e),n=yd.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:md(-t),bytes:fd(n)}}function wd(e){yi("x",e,sd,td);const t=hd(e*e);let n=od(hd(t*e+BigInt(7)));n%id!==rd&&(n=hd(-n));const r=new yd(e,n,sd);return r.assertValidity(),r}const vd=oi;function xd(...e){return md(vd(ld("BIP0340/challenge",...e)))}function Id(e){return gd(e).bytes}function Pd(e,t,n=It(32)){const r=li("message",e),{bytes:s,scalar:i}=gd(t),a=li("auxRand",n,32),o=pd(i^vd(ld("BIP0340/aux",a))),c=ld("BIP0340/nonce",o,s,r),u=md(vd(c));if(u===rd)throw new Error("sign failed: k is zero");const{bytes:d,scalar:l}=gd(u),f=xd(d,s,r),p=new Uint8Array(64);if(p.set(d,0),p.set(pd(md(l+f*i)),32),!zd(p,r,s))throw new Error("sign: Invalid signature produced");return p}function zd(e,t,n){const r=li("signature",e,64),s=li("message",t),i=li("publicKey",n,32);try{const e=wd(vd(i)),t=vd(r.subarray(0,32));if(!mi(t,sd,td))return!1;const n=vd(r.subarray(32,64));if(!mi(n,sd,nd))return!1;const a=xd(pd(t),fd(e),s),o=bd(e,n,md(-a));return!(!o||!o.hasEvenY()||o.toAffine().x!==t)}catch(e){return!1}}const Ed=(()=>({getPublicKey:Id,sign:Pd,verify:zd,utils:{randomPrivateKey:ud.utils.randomPrivateKey,lift_x:wd,pointToBytes:fd,numberToBytesBE:ui,bytesToNumberBE:oi,taggedHash:ld,mod:lu}}))(),Ad=(()=>function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[s,i,a,o]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r))))),[c,u]=wu(e,[i,o],!0);return t=e.mul(s,c),r=e.mul(r,e.mul(a,u)),{x:t,y:r}}}(cd,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))))(),kd=(()=>Zu(cd,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:cd.create(BigInt("-11"))}))(),Md=(()=>function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");function r(n){return e.fromAffine(t(n))}function s(t){const n=t.clearCofactor();return n.equals(e.ZERO)?e.ZERO:(n.assertValidity(),n)}return{defaults:n,hashToCurve(e,t){const i=ed(e,2,{...n,DST:n.DST,...t}),a=r(i[0]),o=r(i[1]);return s(a.add(o))},encodeToCurve:(e,t)=>s(r(ed(e,1,{...n,DST:n.encodeDST,...t})[0])),mapToCurve(e){if(!Array.isArray(e))throw new Error("expected array of bigints");for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return s(r(e))}}}(ud.ProjectivePoint,(e=>{const{x:t,y:n}=kd(cd.create(e[0]));return Ad(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:cd.ORDER,m:1,k:128,expand:"xmd",hash:Os}))(),$d=(()=>Md.hashToCurve)(),Od=(()=>Md.encodeToCurve)();var jd=Object.freeze({__proto__:null,secp256k1:ud,schnorr:Ed,secp256k1_hasher:Md,hashToCurve:$d,encodeToCurve:Od});function Sd(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new Cd({signature:e});if(void 0===e.s)throw new Cd({signature:e});if(n&&void 0===e.yParity)throw new Cd({signature:e});if(e.r<0n||e.r>Nc)throw new Bd({value:e.r});if(e.s<0n||e.s>Nc)throw new Dd({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new Ud({value:e.yParity})}function Nd(e){if(130!==e.length&&132!==e.length)throw new Rd({signature:e});const t=BigInt(na(e,0,32)),n=BigInt(na(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return _d(t)}catch{throw new Ud({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function Td(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?Nd(e):e instanceof Uint8Array?function(e){return Nd(Qi(e))}(e):"string"==typeof e.r?function(e){const t=(()=>{const t=e.v?Number(e.v):void 0;let n=e.yParity?Number(e.yParity):void 0;if("number"==typeof t&&"number"!=typeof n&&(n=_d(t)),"number"!=typeof n)throw new Ud({value:e.yParity});return n})();return{r:BigInt(e.r),s:BigInt(e.s),yParity:t}}(e):e.v?function(e){return{r:e.r,s:e.s,yParity:_d(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return Sd(t),t}(e)}function _d(e){if(0===e||27===e)return 0;if(1===e||28===e)return 1;if(e>=35)return e%2==0?1:0;throw new qd({value:e})}class Rd extends Pi{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${ra((t=e,t instanceof Uint8Array?Qi(t):Array.isArray(t)?Qi(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class Cd extends Pi{constructor({signature:e}){var t,n,r;super(`Signature \`${t=e,JSON.stringify(t,((e,t)=>"function"==typeof n?n(e,t):"bigint"==typeof t?t.toString()+"#__bigint":t),r)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class Bd extends Pi{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class Dd extends Pi{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class Ud extends Pi{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class qd extends Pi{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function Ld(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,s=Td(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...s}}(e):{...e,...t.signature}}const Fd="0x8010801080108010801080108010801080108010801080108010801080108010",Kd=Hc("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function Vd(e){if("string"==typeof e){if(na(e,-32)!==Fd)throw new Gd(e)}else Sd(e.authorization)}class Gd extends Pi{constructor(e){super(`Value \`${e}\` is an invalid ERC-8010 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc8010.InvalidWrappedSignatureError"})}}function Zd(e){const t="string"==typeof e?e:function(e){return"function"===e.type?`function ${e.name}(${To(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${To(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${To(e.inputs)})`:"error"===e.type?`error ${e.name}(${To(e.inputs)})`:"constructor"===e.type?`constructor(${To(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}(e);return function(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),"("===o&&r++,")"===o&&r--,t)if(0!==r)" "!==o?(s+=o,n+=o):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===o&&["event","function","error",""].includes(s))s="";else if(s+=o,")"===o){i=!0;break}}if(!i)throw new Pi("Unable to normalize signature.");return s}(t)}function Hd(e){return"string"!=typeof e&&"hash"in e&&e.hash?e.hash:Pc(Xi(Zd(e)))}const Wd="0x0000000000000000000000000000000000000000",Yd="0x6492649264926492649264926492649264926492649264926492649264926492";function Qd(e){try{return function(e){if(na(e,-32)!==Yd)throw new Jd(e)}(e),!0}catch{return!1}}class Jd extends Pi{constructor(e){super(`Value \`${e}\` is an invalid ERC-6492 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc6492.InvalidWrappedSignatureError"})}}async function Xd(e,t){const{address:n,hash:r,erc6492VerifierAddress:s=t.universalSignatureVerifierAddress??e.chain?.contracts?.erc6492Verifier?.address,multicallAddress:i=t.multicallAddress??e.chain?.contracts?.multicall3?.address}=t,a=(()=>{const e=t.signature;return W(e)?e:"object"==typeof e&&"r"in e&&"s"in e?function({r:e,s:t,to:n="hex",v:r,yParity:s}){const i=(()=>{if(0===s||1===s)return s;if(r&&(27n===r||28n===r||r>=35n))return r%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),a=`0x${new ud.Signature(Se(e),Se(t)).toCompactHex()}${0===i?"1b":"1c"}`;return"hex"===n?a:Ve(a)}(e):Ce(e)})();try{return function(e){try{return Vd(e),!0}catch{return!1}}(a)?await async function(e,t){const{address:n,blockNumber:r,blockTag:s,hash:i,multicallAddress:a}=t,{authorization:o,data:c,signature:u,to:d}=function(e){Vd(e);const t=ia(na(e,-64,-32)),n=na(e,-t-64,-64),r=na(e,0,-t-64),[s,i,a]=Vc(Kd,n);return{authorization:Ld({address:s.delegation,chainId:Number(s.chainId),nonce:s.nonce,yParity:s.yParity,r:s.r,s:s.s}),signature:r,...a&&"0x"!==a?{data:a,to:i}:{}}}(t.signature),l=await async function(e,{address:t,blockNumber:n,blockTag:r="latest"}){const s=void 0!==n?Be(n):void 0,i=await e.request({method:"eth_getCode",params:[t,s||r]},{dedupe:Boolean(s)});if("0x"!==i)return i}(e,{address:n,blockNumber:r,blockTag:s});if(l===Xt(["0xef0100",o.address]))return await async function(e,t){const{address:n,blockNumber:r,blockTag:s,hash:i,signature:a}=t,o=await G(e,ja,"readContract")({address:n,abi:pa,args:[i,a],blockNumber:r,blockTag:s,functionName:"isValidSignature"}).catch((e=>{if(e instanceof Xn)throw new el;throw e}));if(o.startsWith("0x1626ba7e"))return!0;throw new el}(e,{address:n,blockNumber:r,blockTag:s,hash:i,signature:u});const f={address:o.address,chainId:Number(o.chainId),nonce:Number(o.nonce),r:Be(o.r,{size:32}),s:Be(o.s,{size:32}),yParity:o.yParity},p=await ao({address:n,authorization:f});if(!p)throw new el;const h=await G(e,ja,"readContract")({...a?{address:a}:{code:wa},authorizationList:[f],abi:la,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:d??n,callData:c}]:[],{allowFailure:!0,target:n,callData:gn({abi:pa,functionName:"isValidSignature",args:[i,u]})}]]}),m=h[h.length-1]?.returnData;if(m?.startsWith("0x1626ba7e"))return!0;throw new el}(e,{...t,multicallAddress:i,signature:a}):await async function(e,t){const{address:n,factory:r,factoryData:s,hash:i,signature:a,verifierAddress:o,...c}=t,u=await(async()=>r||s?Qd(a)?a:function(e){const{data:t,signature:n,to:r}=e;return Wi(Gc(Hc("address, bytes, bytes"),[r,t,n]),Yd)}({data:s,signature:a,to:r}):a)(),d=o?{to:o,data:gn({abi:ha,functionName:"isValidSig",args:[n,i,u]}),...c}:{data:za({abi:ha,args:[n,i,u],bytecode:ga}),...c},{data:l}=await G(e,$a,"call")(d).catch((e=>{if(e instanceof Jn)throw new el;throw e}));if(function(e,t={}){let n=e;if(t.size&&(je(n,{size:t.size}),n=Oe(n)),"0x00"===Oe(n))return!1;if("0x01"===Oe(n))return!0;throw new Me(n)}(l??"0x0"))return!0;throw new el}(e,{...t,verifierAddress:s,signature:a})}catch(e){try{if(Vs(Ht(n),await Br({hash:r,signature:a})))return!0}catch{}if(e instanceof el)return!1;throw e}}class el extends Error{}function tl({key:e,methods:t,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:a,type:o},c){return{config:{key:e,methods:t,name:n,request:r,retryCount:s,retryDelay:i,timeout:a,type:o},request:co(r,{methods:t,retryCount:s,retryDelay:i,uid:Ja()}),value:c}}function nl(e,t={}){const{key:n="fallback",name:r="Fallback",rank:s=!1,shouldThrow:i=rl,retryCount:a,retryDelay:o}=t;return({chain:t,pollingInterval:c=4e3,timeout:u,...d})=>{let l=e,f=()=>{};const p=tl({key:n,name:r,async request({method:e,params:n}){let r;const s=async(a=0)=>{const o=l[a]({...d,chain:t,retryCount:0,timeout:u});try{const t=await o.request({method:e,params:n});return f({method:e,params:n,response:t,transport:o,status:"success"}),t}catch(c){if(f({error:c,method:e,params:n,transport:o,status:"error"}),i(c))throw c;if(a===l.length-1)throw c;if(r??=l.slice(a+1).some((n=>{const{include:r,exclude:s}=n({chain:t}).config.methods||{};return r?r.includes(e):!s||!s.includes(e)})),!r)throw c;return s(a+1)}};return s()},retryCount:a,retryDelay:o,type:"fallback"},{onResponse:e=>f=e,transports:l.map((e=>e({chain:t,retryCount:0})))});if(s){const e="object"==typeof s?s:{};!function({chain:e,interval:t=4e3,onTransports:n,ping:r,sampleCount:s=10,timeout:i=1e3,transports:a,weights:o={}}){const{stability:c=.7,latency:u=.3}=o,d=[],l=async()=>{const o=await Promise.all(a.map((async t=>{const n=t({chain:e,retryCount:0,timeout:i}),s=Date.now();let a,o;try{await(r?r({transport:n}):n.request({method:"net_listening"})),o=1}catch{o=0}finally{a=Date.now()}return{latency:a-s,success:o}})));d.push(o),d.length>s&&d.shift();const f=Math.max(...d.map((e=>Math.max(...e.map((({latency:e})=>e)))))),p=a.map(((e,t)=>{const n=d.map((e=>e[t].latency)),r=1-n.reduce(((e,t)=>e+t),0)/n.length/f,s=d.map((e=>e[t].success)),i=s.reduce(((e,t)=>e+t),0)/s.length;return 0===i?[0,t]:[u*r+c*i,t]})).sort(((e,t)=>t[0]-e[0]));n(p.map((([,e])=>a[e]))),await Ra(t),l()};l()}({chain:t,interval:e.interval??c,onTransports:e=>l=e,ping:e.ping,sampleCount:e.sampleCount,timeout:e.timeout,transports:l,weights:e.weights})}return p}}function rl(e){return!(!("code"in e)||"number"!=typeof e.code||e.code!==br.code&&e.code!==xr.code&&!Fr.nodeMessage.test(e.message)&&5e3!==e.code)}class sl extends ee{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function il(e,t={}){const{batch:n,fetchOptions:r,key:s="http",methods:i,name:a="HTTP JSON-RPC",onFetchRequest:o,onFetchResponse:c,retryDelay:u,raw:d}=t;return({chain:l,retryCount:f,timeout:p})=>{const{batchSize:h=1e3,wait:m=0}="object"==typeof n?n:{},y=t.retryCount??f,b=p??t.timeout??1e4,g=e||l?.rpcUrls.default.http[0];if(!g)throw new sl;const w=po(g,{fetchOptions:r,onRequest:o,onResponse:c,timeout:b});return tl({key:s,methods:i,name:a,async request({method:e,params:t}){const r={method:e,params:t},{schedule:s}=Ma({id:g,wait:m,shouldSplitBatch:e=>e.length>h,fn:e=>w.request({body:e}),sort:(e,t)=>e.id-t.id}),[{error:i,result:a}]=await(async e=>n?s(e):[await w.request({body:e})])(r);if(d)return{error:i,result:a};if(i)throw new ir({body:r,error:i,url:g});return a},retryCount:y,retryDelay:u,timeout:b,type:"http"},{fetchOptions:r,url:g})}}const al={transaction:function(e,t){return function(e){return"deposit"===e.type||void 0!==e.sourceHash}(e)?function(e){!function(e){const{from:t,to:n}=e;if(t&&!Qt(t))throw new Kt({address:t});if(n&&!Qt(n))throw new Kt({address:n})}(e);const{sourceHash:t,data:n,from:r,gas:s,isSystemTx:i,mint:a,to:o,value:c}=e,u=[t,r,o??"0x",a?_e(a):"0x",c?_e(c):"0x",s?_e(s):"0x",i?"0x1":"0x",n??"0x"];return Xt(["0x7e",Dr(u)])}(e):so(e,t)}};const ol={blockTime:2e3,contracts:{gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},formatters:{block:fs({format(e){const t=e.transactions?.map((e=>{if("string"==typeof e)return e;const t=us(e);return"0x7e"===t.typeHex&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Se(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}));return{transactions:t,stateRoot:e.stateRoot}}}),transaction:ds({format(e){const t={};return"0x7e"===e.type&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Se(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Ka({format:e=>({l1GasPrice:e.l1GasPrice?Se(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Se(e.l1GasUsed):null,l1Fee:e.l1Fee?Se(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null})})},serializers:al},cl=11155111,ul=uo({...ol,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...ol.contracts,disputeGameFactory:{[cl]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[cl]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[cl]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[cl]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:cl}),dl=uo({id:11155931,name:"RISE Testnet",nativeCurrency:{name:"RISE Testnet Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://testnet.riselabs.xyz"],webSocket:["wss://testnet.riselabs.xyz/ws"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.testnet.riselabs.xyz/",apiUrl:"https://explorer.testnet.riselabs.xyz/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"}},testnet:!0});var ll=Object.freeze({__proto__:null,baseSepolia:ul,riseTestnet:dl});const fl=[dl,...Object.values(ll).filter((e=>e.id!==dl.id))],pl="#__bigint";function hl(e,t,n){return JSON.stringify(e,((e,n)=>"function"==typeof t?t(e,n):"bigint"==typeof n?n.toString()+pl:n),n)}class ml extends Error{static setStaticOptions(e){ml.prototype.docsOrigin=e.docsOrigin,ml.prototype.showVersion=e.showVersion,ml.prototype.version=e.version}constructor(e,t={}){const n=(()=>{if(t.cause instanceof ml){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&"string"==typeof t.cause.details?t.cause.details:t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof ml&&t.cause.docsPath||t.docsPath,s=t.docsOrigin??ml.prototype.docsOrigin,i=`${s}${r??""}`,a=Boolean(t.version??ml.prototype.showVersion),o=t.version??ml.prototype.version;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r||a?["",n?`Details: ${n}`:void 0,r?`See: ${i}`:void 0,a?`Version: ${o}`:void 0]:[]].filter((e=>"string"==typeof e)).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsOrigin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showVersion",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.cause=t.cause,this.details=n,this.docs=i,this.docsOrigin=s,this.docsPath=r,this.shortMessage=e,this.showVersion=a,this.version=o}walk(e){return yl(this,e)}}function yl(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?yl(e.cause,t):t?null:e}function bl(e){const t=e;if(t instanceof Error&&!("code"in t))return new $l({cause:t,data:t,message:t.message,stack:t.stack});const{code:n}=t;return n===$l.code?new $l(t):n===wl.code?new wl(t):n===Ml.code?new Ml(t):n===Al.code?new Al(t):n===zl.code?new zl(t):n===kl.code?new kl(t):n===Pl.code?new Pl(t):n===Ol.code?new Ol(t):n===vl.code?new vl(t):n===xl.code?new xl(t):n===Il.code?new Il(t):n===El.code?new El(t):new $l({cause:t instanceof Error?t:void 0,data:t,message:t.message,stack:t instanceof Error?t.stack:void 0})}Object.defineProperty(ml,"defaultStaticOptions",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:"https://oxlib.sh",showVersion:!1,version:"ox@0.1.1"}}),ml.setStaticOptions(ml.defaultStaticOptions);class gl extends Error{constructor(e){const{cause:t,code:n,message:r,data:s,stack:i}=e;super(r,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.BaseError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t,this.code=n,this.data=s,this.stack=i??""}}class wl extends gl{constructor(e={}){super({code:wl.code,data:e.data,message:e.message??"Missing or invalid parameters."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidInputError"})}}Object.defineProperty(wl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class vl extends gl{constructor(e={}){super({code:vl.code,data:e.data,message:e.message??"Requested resource not found."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceNotFoundError"})}}Object.defineProperty(vl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class xl extends gl{constructor(e={}){super({code:xl.code,data:e.data,message:e.message??"Requested resource not available."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceUnavailableError"})}}Object.defineProperty(xl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class Il extends gl{constructor(e={}){super({code:Il.code,data:e.data,message:e.message??"Transaction creation failed."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.TransactionRejectedError"})}}Object.defineProperty(Il,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Pl extends gl{constructor(e={}){super({code:Pl.code,data:e.data,message:e.message??"Method is not implemented."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotSupportedError"})}}Object.defineProperty(Pl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class zl extends gl{constructor(e={}){super({code:zl.code,data:e.data,message:e.message??"Rate limit exceeded."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.LimitExceededError"})}}Object.defineProperty(zl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class El extends gl{constructor(e={}){super({code:El.code,data:e.data,message:e.message??"JSON-RPC version not supported."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.VersionNotSupportedError"})}}Object.defineProperty(El,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Al extends gl{constructor(e={}){super({code:Al.code,data:e.data,message:e.message??"Input is not a valid JSON-RPC request."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidRequestError"})}}Object.defineProperty(Al,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class kl extends gl{constructor(e={}){super({code:kl.code,data:e.data,message:e.message??"Method does not exist."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotFoundError"})}}Object.defineProperty(kl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Ml extends gl{constructor(e={}){super({code:Ml.code,data:e.data,message:e.message??"Invalid method parameters."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidParamsError"})}}Object.defineProperty(Ml,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class $l extends gl{constructor(e={}){super({cause:e.cause,code:$l.code,data:e.data,message:e.message??"Internal JSON-RPC error.",stack:e.stack}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InternalError"})}}Object.defineProperty($l,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ol extends gl{constructor(e={}){super({code:Ol.code,data:e.data,message:e.message??"Failed to parse JSON-RPC response."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ParseError"})}}Object.defineProperty(Ol,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class jl extends Error{constructor(e,t){super(t),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderRpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e,this.details=t}}class Sl extends jl{constructor({message:e="The user rejected the request."}={}){super(4001,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UserRejectedRequestError"})}}Object.defineProperty(Sl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Nl extends jl{constructor({message:e="The requested method and/or account has not been authorized by the user."}={}){super(4100,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnauthorizedError"})}}Object.defineProperty(Nl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Tl extends jl{constructor({message:e="The provider does not support the requested method."}={}){super(4200,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedMethodError"})}}Object.defineProperty(Tl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class _l extends jl{constructor({message:e="The provider is disconnected from all chains."}={}){super(4900,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DisconnectedError"})}}Object.defineProperty(_l,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Rl extends jl{constructor({message:e="The provider is not connected to the requested chain."}={}){super(4901,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.ChainDisconnectedError"})}}Object.defineProperty(Rl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Cl extends jl{constructor({message:e="An error occurred when attempting to switch chain."}={}){super(4902,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.SwitchChainError"})}}Object.defineProperty(Cl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class Bl extends jl{constructor({message:e="This Wallet does not support a capability that was not marked as optional."}={}){super(5700,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedNonOptionalCapabilityError"})}}Object.defineProperty(Bl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Dl extends jl{constructor({message:e="This Wallet does not support the requested chain ID."}={}){super(5710,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedChainIdError"})}}Object.defineProperty(Dl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class Ul extends jl{constructor({message:e="There is already a bundle submitted with this ID."}={}){super(5720,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DuplicateIdError"})}}Object.defineProperty(Ul,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class ql extends jl{constructor({message:e="This bundle id is unknown / has not been submitted."}={}){super(5730,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnknownBundleIdError"})}}Object.defineProperty(ql,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Ll extends jl{constructor({message:e="The call bundle is too large for the Wallet to process."}={}){super(5740,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.BundleTooLargeError"})}}Object.defineProperty(Ll,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Fl extends jl{constructor({message:e="The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."}={}){super(5750,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.AtomicReadyWalletRejectedUpgradeError"})}}Object.defineProperty(Fl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Kl extends jl{constructor({message:e="The wallet does not support atomic execution but the request requires it."}={}){super(5760,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.AtomicityNotSupportedError"})}}function Vl(e,t={}){if(!e)throw new Zl;return{...e,async request(t){try{const n=await e.request(t);return n&&"object"==typeof n&&"jsonrpc"in n?function(e,t={}){const{raw:n=!1}=t,r=e;if(n)return e;if(r.error)throw bl(r.error);return r.result}(n):n}catch(e){throw Gl(e)}}}}function Gl(e){const t=bl(e);if(t instanceof $l){if(!t.data)return t;const{code:e}=t.data;if(e===_l.code)return new _l(t);if(e===Rl.code)return new Rl(t);if(e===Sl.code)return new Sl(t);if(e===Nl.code)return new Nl(t);if(e===Tl.code)return new Tl(t);if(e===Cl.code)return new Cl(t);if(e===Fl.code)return new Fl(t);if(e===Kl.code)return new Kl(t);if(e===Ll.code)return new Ll(t);if(e===ql.code)return new ql(t);if(e===Ul.code)return new Ul(t);if(e===Dl.code)return new Dl(t);if(e===Bl.code)return new Bl(t)}return t}Object.defineProperty(Kl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Zl extends ml{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}}const Hl=()=>"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in IntersectionObserverEntry.prototype&&"isVisible"in IntersectionObserverEntry.prototype;const Wl=function(e={}){const{prefix:t="[Porto]"}=e,n=new Set;return{error:Yl(console.error,{prefix:t}),errorOnce:Yl(console.error,{memo:n,prefix:t}),log:Yl(console.log,{prefix:t}),logOnce:Yl(console.log,{memo:n,prefix:t}),warn:Yl(console.warn,{prefix:t}),warnOnce:Yl(console.warn,{memo:n,prefix:t})}}();function Yl(e,t={}){const{memo:n,prefix:r}=t;return(...t)=>{const s=t.join(" ");n?.has(s)||(n?.add(s),e(`${r} ${s}`))}}function Ql(e){if(Array.isArray(e))return e.map(Ql);if("function"==typeof e)return;if("object"!=typeof e||null===e)return e;if(Object.getPrototypeOf(e)!==Object.prototype)try{return structuredClone(e)}catch{return}const t={};for(const[n,r]of Object.entries(e))t[n]=Ql(r);return t}function Jl(e,t){const n=[],r=new Set;for(const s of e){const e=t(s);r.has(e)||(r.add(e),n.push(s))}return n}function Xl(){return"undefined"!=typeof globalThis&&"crypto"in globalThis?globalThis.crypto.randomUUID():crypto.randomUUID()}function ef(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(ef.cache.get(n))return ef.cache.get(n);const r=e().finally((()=>ef.cache.delete(n)));return ef.cache.set(n,r),r}function tf(e,t={}){const{targetOrigin:n}=t,r=new Map;return{destroy(){for(const t of r.values())e.removeEventListener("message",t)},on(t,s,i){function a(e){e.data.topic===t&&(i&&e.data.id!==i||n&&e.origin!==n||s(e.data.payload,e))}return e.addEventListener("message",a),r.set(t,a),()=>e.removeEventListener("message",a)},async send(t,r,s){const i=Xl();return e.postMessage(Ql({id:i,payload:r,topic:t}),s??n??"*"),{id:i,payload:r,topic:t}},async sendAsync(e,t,n){const{id:r}=await this.send(e,t,n);return new Promise((t=>this.on(e,t,r)))}}}function nf(e){const{from:t,to:n,waitForReady:r=!1}=e;let s=!1;const i=function(){let e=()=>{},t=()=>{};return{promise:new Promise(((n,r)=>{e=n,t=r})),reject:t,resolve:e}}();t.on("ready",i.resolve);const a={destroy(){t.destroy(),n.destroy(),s&&i.reject()},on:(e,n,r)=>t.on(e,n,r),send:async(e,t)=>(s=!0,r&&await i.promise.finally((()=>s=!1)),n.send(e,t)),sendAsync:async(e,t)=>(s=!0,r&&await i.promise.finally((()=>s=!1)),n.sendAsync(e,t))};return{...a,ready(e){a.send("ready",e)},waitForReady:()=>i.promise}}!function(e){e.cache=new Map}(ef||(ef={}));const rf={local:"http://localhost:5175/dialog/",prod:"https://wallet.risechain.com/dialog",stg:"https://stg.wallet.risechain.com/dialog"};function sf(e={}){const{skipProtocolCheck:t,skipUnsupported:n}=e,r=e=>!n&&function(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")}()&&e?.some((e=>["wallet_connect","eth_requestAccounts"].includes(e.method)));return"undefined"==typeof window?af():{name:"iframe",setup(e){const{host:n,internal:s,theme:i,themeController:a}=e,{store:o}=s,c=function(e={}){if("undefined"==typeof window)return af();const{type:t="auto",size:n=of}=e;return{name:"popup",setup(e){const{host:r,internal:s,themeController:i}=e,{store:a}=s,o=new URL(r);let c=null;const u="page"===t||"auto"===t&&(window.navigator?.userAgentData?.mobile||navigator.maxTouchPoints>1||/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(navigator.userAgent.slice(0,4)))?"page":"popup";function d(){c&&df(a)}const l=(()=>{const e=setInterval((()=>{c?.closed&&df(a)}),100);return()=>clearInterval(e)})();let f;return i?._setup(null,!0),{close(){c&&(c.close(),c=null)},destroy(){this.close(),window.removeEventListener("focus",d),f?.destroy(),l()},open(){if("popup"===u){const e=(window.innerWidth-n.width)/2+window.screenX,t=window.screenY+100;c=window.open(ff(r),"_blank",`width=${n.width},height=${n.height},left=${e},top=${t}`)}else c=window.open(ff(r),"_blank");if(!c)throw new Error("Failed to open popup");f=nf({from:tf(window,{targetOrigin:o.origin}),to:tf(c,{targetOrigin:o.origin}),waitForReady:!0}),i?._setup(f,!1),f.send("__internal",{mode:"page"===u?"page":"popup",referrer:uf(),theme:i?.getTheme()??e.theme,type:"init"}),f.on("rpc-response",(e=>lf(a,e))),window.removeEventListener("focus",d),window.addEventListener("focus",d)},secure:async()=>({frame:!0,host:!0,protocol:!0}),async syncRequests(e){e.some((e=>cf(e.request)))&&(c&&!c.closed||this.open(),c?.focus()),f?.send("rpc-requests",e)}}},supportsHeadless:!1}}().setup(e);let u=!1;const d=new URL(n),l=document.createElement("dialog");l.dataset.porto="",l.setAttribute("role","dialog"),l.setAttribute("aria-closed","true"),l.setAttribute("aria-label","Porto Wallet"),l.setAttribute("hidden","until-found"),Object.assign(l.style,{background:"transparent",border:"0",outline:"0",padding:"0",position:"fixed"}),document.body.appendChild(l);const f=document.createElement("iframe");f.setAttribute("data-testid","porto");const p=["payment",`publickey-credentials-get ${d.origin}`,`publickey-credentials-create ${d.origin}`];(function(){const e=navigator.userAgent.toLowerCase();return(e.includes("firefox")||e.includes("fxios"))&&!e.includes("seamonkey")})()||p.push("clipboard-write"),f.setAttribute("allow",p.join("; ")),f.setAttribute("tabindex","0"),f.setAttribute("sandbox","allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox"),f.setAttribute("src",ff(n)),f.setAttribute("title","Porto"),Object.assign(f.style,{backgroundColor:"transparent",border:"0",colorScheme:"light dark",height:"100%",left:"0",position:"fixed",top:"0",width:"100%"});const h=document.createElement("style");h.innerHTML="\n dialog[data-porto]::backdrop {\n background: transparent!important;\n }\n ",l.appendChild(h),l.appendChild(f);const m=nf({from:tf(window,{targetOrigin:d.origin}),to:tf(f.contentWindow,{targetOrigin:d.origin}),waitForReady:!0});a?._setup(m,!0);const y=window.matchMedia("(max-width: 460px)"),b=()=>{m.send("__internal",{type:"resize",width:y.matches?460:461})};y.addEventListener("change",b),m.on("ready",(t=>{let n=e.internal.store.getState().chainIds.filter((e=>t.chainIds.includes(e)));0===n.length&&(n=t.chainIds),o.setState((e=>({...e,chainIds:n}))),m.send("__internal",{chainIds:n,mode:"iframe",referrer:uf(),theme:i,type:"init"}),b()})),m.on("rpc-response",(e=>{if(r([e._request])){const e=f.src;f.src=e}lf(o,e)})),m.on("__internal",(e=>{"switch"===e.type&&"popup"===e.mode&&(c.open(),c.syncRequests(o.getState().requestQueue))}));let g=null,w=null;const v=()=>df(o),x=e=>{"Escape"===e.key&&df(o)},I=new MutationObserver((e=>{for(const t of e){if("attributes"!==t.type)continue;const e=t.attributeName;e&&("inert"===e&&l.removeAttribute(e))}}));I.observe(l,{attributeOldValue:!0,attributes:!0});let P=!1;const z=()=>{P&&(P=!1,l.removeEventListener("click",v),document.removeEventListener("keydown",x),l.style.pointerEvents="none",w?.focus(),w=null,Object.assign(document.body.style,g??""),document.body.style.overflow=g?.overflow??"")};let E=!1;const A=()=>{if(E){E=!1,l.setAttribute("hidden","true"),l.setAttribute("aria-closed","true"),l.close();for(const e of l.parentNode?Array.from(l.parentNode.children):[])e!==l&&e.hasAttribute("inert")&&e.removeAttribute("inert")}};return{close(){c.close(),u=!1,m.send("__internal",{mode:"iframe",referrer:uf(),type:"init"}),A(),z()},destroy(){c.close(),u=!1,z(),A(),c.destroy(),m.destroy(),l.remove(),I.disconnect(),y.removeEventListener("change",b)},open(){u||(u=!0,E||(E=!0,document.activeElement instanceof HTMLElement&&(w=document.activeElement),l.removeAttribute("hidden"),l.removeAttribute("aria-closed"),l.showModal()),P||(P=!0,l.addEventListener("click",v),document.addEventListener("keydown",x),f.focus(),l.style.pointerEvents="auto",g=Object.assign({},document.body.style),document.body.style.overflow="hidden"),m.send("__internal",{mode:"iframe",referrer:uf(),type:"init"}))},async secure(){const{trustedHosts:e}=await m.waitForReady(),n=(()=>{if(t)return!0;const e=window.location.protocol.startsWith("https");return e||Wl.warnOnce("Detected insecure protocol (HTTP).",`\n\nThe Porto iframe is not supported on HTTP origins (${window.location.origin})`,"due to lack of WebAuthn support.","See https://porto.sh/sdk#secure-origins-https for more information."),e})(),r=Hl(),s=Boolean(e?.includes(window.location.hostname)),i=Boolean(r||s);return i||Wl.warnOnce([`Warning: Browser does not support IntersectionObserver v2 or host "${d.hostname}" is not trusted by Porto.`,"This may result in the dialog falling back to a popup.","",`Add "${d.hostname}" to the trusted hosts list to enable iframe dialog: https://github.com/ithacaxyz/porto/edit/main/src/trusted-hosts.ts`].join("\n")),{frame:i,host:s,protocol:n}},async syncRequests(e){const{methodPolicies:t}=await m.waitForReady(),n=await this.secure(),s=e?.every((e=>!0===t?.find((t=>t.method===e.request.method))?.modes?.headless)),i=r(e.map((e=>e.request)));if(s||!i&&n.protocol&&n.frame){const n=e.some((e=>cf(e.request,{methodPolicies:t,targetOrigin:d.origin})));!u&&n&&this.open(),m.send("rpc-requests",e)}else c.syncRequests(e)}}},supportsHeadless:!0}}function af(){return{name:"noop",setup:()=>({close(){},destroy(){},open(){},secure:async()=>({frame:!0,host:!0,protocol:!0}),async syncRequests(){}}),supportsHeadless:!0}}const of={height:282,width:360};function cf(e,t={}){const{methodPolicies:n,targetOrigin:r}=t,s=n?.find((t=>t.method===e.method));return!s||(!s.modes?.headless||!("object"!=typeof s.modes.headless||!s.modes.headless.sameOrigin||r===window.location.origin))}function uf(){return{icon:(()=>{const e=document.querySelector('link[rel="icon"][media="(prefers-color-scheme: dark)"]')?.href,t=document.querySelector('link[rel="icon"][media="(prefers-color-scheme: light)"]')?.href??document.querySelector('link[rel="icon"]')?.href;if(e&&t&&e!==t)return{dark:e,light:t};return window.matchMedia("(prefers-color-scheme: dark)").matches?e:t})(),title:document.title}}function df(e){e.setState((e=>({...e,requestQueue:e.requestQueue.map((e=>({account:e.account,error:new Sl,request:e.request,status:"error"})))})))}function lf(e,t){e.setState((e=>({...e,requestQueue:e.requestQueue.map((e=>e.request.id!==t.id?e:t.error?{account:e.account,error:t.error,request:e.request,status:"error"}:{account:e.account,request:e.request,result:t.result,status:"success"}))})))}function ff(e){const t=new URL(e),n=new URLSearchParams(window.location.search),r="porto.";for(const[e,s]of n.entries())e.startsWith(r)&&t.searchParams.set(e.slice(6),s);return t.toString()}function pf(e,t){if(Vf(e)>t)throw new Qf({givenSize:Vf(e),maxSize:t})}const hf={zero:48,nine:57,A:65,F:70,a:97,f:102};function mf(e){return e>=hf.zero&&e<=hf.nine?e-hf.zero:e>=hf.A&&e<=hf.F?e-(hf.A-10):e>=hf.a&&e<=hf.f?e-(hf.a-10):void 0}function yf(e,t){if($f(e)>t)throw new Cf({givenSize:$f(e),maxSize:t})}function bf(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const s=e.replace("0x","");if(s.length>2*r)throw new Df({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s["right"===n?"padEnd":"padStart"](2*r,"0")}`}const gf=new TextEncoder,wf=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function vf(...e){return`0x${e.reduce(((e,t)=>e+t.replace("0x","")),"")}`}function xf(e){return e instanceof Uint8Array?Pf(e):Array.isArray(e)?Pf(new Uint8Array(e)):e}function If(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(yf(n,t.size),Af(n,t.size)):n}function Pf(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=wf[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(yf(r,t.size),kf(r,t.size)):r}function zf(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new Tf({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?BigInt.asUintN(8*r,BigInt(s)):s).toString(16)}`;return r?Af(o,r):o}function Ef(e,t={}){return Pf(gf.encode(e),t)}function Af(e,t){return bf(e,{dir:"left",size:t})}function kf(e,t){return bf(e,{dir:"right",size:t})}function Mf(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>$f(e)-1)throw new Bf({offset:t,position:"start",size:$f(e)})}(e,t);const i=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&$f(e)!==n-t)throw new Bf({offset:n,position:"end",size:$f(e)})}(i,t,n),i}function $f(e){return Math.ceil((e.length-2)/2)}function Of(e){return function(e,t={}){const{dir:n="left"}=t;let r=e.replace("0x",""),s=0;for(let e=0;e<r.length-1&&"0"===r["left"===n?e:r.length-e-1].toString();e++)s++;return r="left"===n?r.slice(s):r.slice(0,r.length-s),"0"===r?"0x":"right"===n&&r.length%2==1?`0x${r}0`:`0x${r}`}(e,{dir:"left"})}function jf(e,t={}){const{signed:n}=t;t.size&&yf(e,t.size);const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<8n*BigInt(s))-1n;return r<=i>>1n?r:r-i-1n}function Sf(e,t={}){const{signed:n,size:r}=t;return Number(n||r?jf(e,t):e)}function Nf(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new _f(e);if("string"!=typeof e)throw new _f(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new Rf(e);if(!e.startsWith("0x"))throw new Rf(e)}(e,{strict:n}),!0}catch{return!1}}class Tf extends ml{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number \`${s}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class _f extends ml{constructor(e){super(`Value \`${"object"==typeof e?hl(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class Rf extends ml{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}class Cf extends ml{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class Bf extends ml{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class Df extends ml{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}const Uf=new TextEncoder;function qf(e){return e instanceof Uint8Array?e:"string"==typeof e?Ff(e):Lf(e)}function Lf(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Ff(e,t={}){const{size:n}=t;let r=e;n&&(yf(e,n),r=kf(e,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){const n=mf(s.charCodeAt(t++)),r=mf(s.charCodeAt(t++));if(void 0===n||void 0===r)throw new ml(`Invalid byte sequence ("${s[t-2]}${s[t-1]}" in "${s}").`);a[e]=n<<4|r}return a}function Kf(e,t={}){const{size:n}=t,r=Uf.encode(e);return"number"==typeof n?(pf(r,n),function(e,t){return function(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;if(e.length>r)throw new Xf({size:e.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let t=0;t<r;t++){const i="right"===n;s[i?t:r-t-1]=e[i?t:e.length-t-1]}return s}(e,{dir:"right",size:t})}(r,n)):r}function Vf(e){return e.length}function Gf(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>Vf(e)-1)throw new Jf({offset:t,position:"start",size:Vf(e)})}(e,t);const i=e.slice(t,n);return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&Vf(e)!==n-t)throw new Jf({offset:n,position:"end",size:Vf(e)})}(i,t,n),i}function Zf(e,t={}){const{size:n}=t;void 0!==n&&pf(e,n);return jf(Pf(e,t),t)}function Hf(e,t={}){return Pf(e,t)}function Wf(e){try{return function(e){if(!(e instanceof Uint8Array)){if(!e)throw new Yf(e);if("object"!=typeof e)throw new Yf(e);if(!("BYTES_PER_ELEMENT"in e))throw new Yf(e);if(1!==e.BYTES_PER_ELEMENT||"Uint8Array"!==e.constructor.name)throw new Yf(e)}}(e),!0}catch{return!1}}class Yf extends ml{constructor(e){super(`Value \`${"object"==typeof e?hl(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class Qf extends ml{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Jf extends ml{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}}class Xf extends ml{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}class ep extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const tp={checksum:new ep(8192)}.checksum;function np(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Bt(qf(e));return"Bytes"===n?r:Pf(r)}function rp(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Ns(qf(e));return"Bytes"===n?r:Pf(r)}function sp(e,t={}){const{compressed:n}=t,{prefix:r,x:s,y:i}=e;if(!1===n||"bigint"==typeof s&&"bigint"==typeof i){if(4!==r)throw new up({prefix:r,cause:new lp})}else{if(!0!==n&&("bigint"!=typeof s||void 0!==i))throw new cp({publicKey:e});if(3!==r&&2!==r)throw new up({prefix:r,cause:new dp})}}function ip(e){const t=(()=>{if(Nf(e))return ap(e);if(Wf(e))return function(e){return ap(Pf(e))}(e);const{prefix:t,x:n,y:r}=e;return"bigint"==typeof n&&"bigint"==typeof r?{prefix:t??4,x:n,y:r}:{prefix:t,x:n}})();return sp(t),t}function ap(e){if(132!==e.length&&130!==e.length&&68!==e.length)throw new fp({publicKey:e});if(130===e.length){return{prefix:4,x:BigInt(Mf(e,0,32)),y:BigInt(Mf(e,32,64))}}if(132===e.length){return{prefix:Number(Mf(e,0,1)),x:BigInt(Mf(e,1,33)),y:BigInt(Mf(e,33,65))}}return{prefix:Number(Mf(e,0,1)),x:BigInt(Mf(e,1,33))}}function op(e,t={}){sp(e);const{prefix:n,x:r,y:s}=e,{includePrefix:i=!0}=t;return vf(i?zf(n,{size:1}):"0x",zf(r,{size:32}),"bigint"==typeof s?zf(s,{size:32}):"0x")}class cp extends ml{constructor({publicKey:e}){super(`Value \`${hl(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class up extends ml{constructor({prefix:e,cause:t}){super(`Prefix "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class dp extends ml{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class lp extends ml{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}class fp extends ml{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${$f(xf(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}}const pp=/^0x[a-fA-F0-9]{40}$/;function hp(e,t={}){const{strict:n=!0}=t;if(!pp.test(e))throw new vp({address:e,cause:new xp});if(n){if(e.toLowerCase()===e)return;if(mp(e)!==e)throw new vp({address:e,cause:new Ip})}}function mp(e){if(tp.has(e))return tp.get(e);hp(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=np(Kf(t),{as:"Bytes"}),r=t.split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&r[e]&&(r[e]=r[e].toUpperCase()),(15&n[e>>1])>=8&&r[e+1]&&(r[e+1]=r[e+1].toUpperCase());const s=`0x${r.join("")}`;return tp.set(e,s),s}function yp(e,t={}){const{checksum:n=!1}=t;return hp(e),n?mp(e):e}function bp(e,t={}){return yp(`0x${np(`0x${op(e).slice(4)}`).substring(26)}`,t)}function gp(e,t){return hp(e,{strict:!1}),hp(t,{strict:!1}),e.toLowerCase()===t.toLowerCase()}function wp(e,t={}){const{strict:n=!0}=t??{};try{return hp(e,{strict:n}),!0}catch{return!1}}class vp extends ml{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class xp extends ml{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class Ip extends ml{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}function Pp(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:a,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const s=a.prototype,i=Object.keys(s);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=s[t].bind(n))}}const s=n?.Parent??Object;class i extends s{}function a(e){var t;const s=n?.Parent?new i:this;r(s,e),(t=s._zod).deferred??(t.deferred=[]);for(const e of s._zod.deferred)e();return s}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}Object.freeze({status:"aborted"});class zp extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ep={};function Ap(e){return e&&Object.assign(Ep,e),Ep}function kp(e,t){return"bigint"==typeof t?t.toString():t}function Mp(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function $p(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Op=Symbol("evaluating");function jp(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Op)return void 0===r&&(r=Op,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Sp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Np(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}const Tp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _p(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Rp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Cp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bp(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function Dp(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function Up(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function qp(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function Lp(e){return"string"==typeof e?e:e?.message}function Fp(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const s=Lp(e.inst?._zod.def?.error?.(e))??Lp(t?.error?.(e))??Lp(n.customError?.(e))??Lp(n.localeError?.(e))??"Invalid input";r.message=s}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}const Kp=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,kp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Vp=Pp("$ZodError",Kp),Gp=Pp("$ZodError",Kp,{Parent:Error}),Zp=e=>(t,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new zp;if(a.issues.length){const t=new(s?.Err??e)(a.issues.map((e=>Fp(e,i,Ap()))));throw Tp(t,s?.callee),t}return a.value},Hp=Zp(Gp),Wp=e=>async(t,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(s?.Err??e)(a.issues.map((e=>Fp(e,i,Ap()))));throw Tp(t,s?.callee),t}return a.value},Yp=Wp(Gp),Qp=e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new zp;return i.issues.length?{success:!1,error:new(e??Vp)(i.issues.map((e=>Fp(e,s,Ap()))))}:{success:!0,data:i.value}},Jp=Qp(Gp),Xp=e=>async(t,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map((e=>Fp(e,s,Ap()))))}:{success:!0,data:i.value}},eh=Xp(Gp),th=e=>(t,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Zp(e)(t,n,s)},nh=th(Gp),rh=e=>(t,n,r)=>Zp(e)(t,n,r),sh=rh(Gp),ih=/^-?\d+n?$/,ah=/^-?\d+(?:\.\d+)?/,oh=/^(?:true|false)$/i,ch=/^null$/i,uh=/^undefined$/i,dh=Pp("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),lh={number:"number",bigint:"bigint",object:"date"},fh=Pp("$ZodCheckGreaterThan",((e,t)=>{dh.init(e,t);const n=lh[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)})),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),ph=Pp("$ZodCheckMinLength",((e,t)=>{var n;dh.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!(n=t,null==n||void 0===t.length);var n}),e._zod.onattach.push((e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const s=function(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}(r);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),hh=Pp("$ZodCheckStringFormat",((e,t)=>{var n,r;dh.init(e,t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))})),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})})),mh=Pp("$ZodCheckRegex",((e,t)=>{hh.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}})),yh={major:4,minor:2,patch:1},bh=Pp("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yh;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const t of r)for(const n of t._zod.onattach)n(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,n)=>{let r,s=Up(e);for(const i of t){if(i._zod.def.when){if(!i._zod.def.when(e))continue}else if(s)continue;const t=e.issues.length,a=i._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new zp;if(r||a instanceof Promise)r=(r??Promise.resolve()).then((async()=>{await a;e.issues.length!==t&&(s||(s=Up(e,t)))}));else{if(e.issues.length===t)continue;s||(s=Up(e,t))}}return r?r.then((()=>e)):e},n=(n,s,i)=>{if(Up(n))return n.aborted=!0,n;const a=t(s,r,i);if(a instanceof Promise){if(!1===i.async)throw new zp;return a.then((t=>e._zod.parse(t,i)))}return e._zod.parse(a,i)};e._zod.run=(s,i)=>{if(i.skipChecks)return e._zod.parse(s,i);if("backward"===i.direction){const t=e._zod.parse({value:s.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then((e=>n(e,s,i))):n(t,s,i)}const a=e._zod.parse(s,i);if(a instanceof Promise){if(!1===i.async)throw new zp;return a.then((e=>t(e,r,i)))}return t(a,r,i)}}e["~standard"]={validate:t=>{try{const n=Jp(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return eh(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1}})),gh=Pp("$ZodString",((e,t)=>{var n;bh.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),wh=Pp("$ZodNumber",((e,t)=>{bh.init(e,t),e._zod.pattern=e._zod.bag.pattern??ah,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const s=n.value;if("number"==typeof s&&!Number.isNaN(s)&&Number.isFinite(s))return n;const i="number"==typeof s?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...i?{received:i}:{}}),n}})),vh=Pp("$ZodBoolean",((e,t)=>{bh.init(e,t),e._zod.pattern=oh,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const s=n.value;return"boolean"==typeof s||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}})),xh=Pp("$ZodBigInt",((e,t)=>{bh.init(e,t),e._zod.pattern=ih,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(e){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}})),Ih=Pp("$ZodUndefined",((e,t)=>{bh.init(e,t),e._zod.pattern=uh,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(t,n)=>{const r=t.value;return void 0===r||t.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),t}})),Ph=Pp("$ZodNull",((e,t)=>{bh.init(e,t),e._zod.pattern=ch,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{const r=t.value;return null===r||t.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),t}})),zh=Pp("$ZodAny",((e,t)=>{bh.init(e,t),e._zod.parse=e=>e})),Eh=Pp("$ZodUnknown",((e,t)=>{bh.init(e,t),e._zod.parse=e=>e})),Ah=Pp("$ZodDate",((e,t)=>{bh.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(e){}const s=n.value,i=s instanceof Date;return i&&!Number.isNaN(s.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:s,...i?{received:"Invalid Date"}:{},inst:e}),n}}));function kh(e,t,n){e.issues.length&&t.issues.push(...qp(n,e.issues)),t.value[n]=e.value}const Mh=Pp("$ZodArray",((e,t)=>{bh.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const i=[];for(let e=0;e<s.length;e++){const a=s[e],o=t.element._zod.run({value:a,issues:[]},r);o instanceof Promise?i.push(o.then((t=>kh(t,n,e)))):kh(o,n,e)}return i.length?Promise.all(i).then((()=>n)):n}}));function $h(e,t,n,r){e.issues.length&&t.issues.push(...qp(n,e.issues)),void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Oh(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter((e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout)));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}const jh=Pp("$ZodObject",((e,t)=>{bh.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=Mp((()=>Oh(t)));jp(e._zod,"propValues",(()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n}));const s=_p,i=t.catchall;let a;e._zod.parse=(t,n)=>{a??(a=r.value);const o=t.value;if(!s(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};const c=[],u=a.shape;for(const e of a.keys){const r=u[e]._zod.run({value:o[e],issues:[]},n);r instanceof Promise?c.push(r.then((n=>$h(n,t,e,o)))):$h(r,t,e,o)}return i?function(e,t,n,r,s,i){const a=[],o=s.keySet,c=s.catchall._zod,u=c.def.type;for(const s in t){if(o.has(s))continue;if("never"===u){a.push(s);continue}const i=c.run({value:t[s],issues:[]},r);i instanceof Promise?e.push(i.then((e=>$h(e,n,s,t)))):$h(i,n,s,t)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then((()=>n)):n}(c,o,t,n,r.value,e):c.length?Promise.all(c).then((()=>t)):t}}));function Sh(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const s=e.filter((e=>!Up(e)));return 1===s.length?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>Fp(e,r,Ap())))))}),t)}const Nh=Pp("$ZodUnion",((e,t)=>{bh.init(e,t),jp(e._zod,"optin",(()=>t.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),jp(e._zod,"optout",(()=>t.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),jp(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),jp(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>$p(e.source))).join("|")})$`)}}));const n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(s,i)=>{if(n)return r(s,i);let a=!1;const o=[];for(const e of t.options){const t=e._zod.run({value:s.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(0===t.issues.length)return t;o.push(t)}}return a?Promise.all(o).then((t=>Sh(t,s,e,i))):Sh(o,s,e,i)}})),Th=Pp("$ZodDiscriminatedUnion",((e,t)=>{t.inclusive=!1,Nh.init(e,t);const n=e._zod.parse;jp(e._zod,"propValues",(()=>{const e={};for(const n of t.options){const r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(const r of n)e[t].add(r)}}return e}));const r=Mp((()=>{const e=t.options,n=new Map;for(const r of e){const e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n}));e._zod.parse=(s,i)=>{const a=s.value;if(!_p(a))return s.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),s;const o=r.value.get(a?.[t.discriminator]);return o?o._zod.run(s,i):t.unionFallback?n(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),s)}})),_h=Pp("$ZodTuple",((e,t)=>{bh.init(e,t);const n=t.items;e._zod.parse=(r,s)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const a=[],o=[...n].reverse().findIndex((e=>"optional"!==e._zod.optin)),c=-1===o?0:n.length-o;if(!t.rest){const t=i.length>n.length,s=i.length<c-1;if(t||s)return r.issues.push({...t?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:i,inst:e,origin:"array"}),r}let u=-1;for(const e of n){if(u++,u>=i.length&&u>=c)continue;const t=e._zod.run({value:i[u],issues:[]},s);t instanceof Promise?a.push(t.then((e=>Rh(e,r,u)))):Rh(t,r,u)}if(t.rest){const e=i.slice(n.length);for(const n of e){u++;const e=t.rest._zod.run({value:n,issues:[]},s);e instanceof Promise?a.push(e.then((e=>Rh(e,r,u)))):Rh(e,r,u)}}return a.length?Promise.all(a).then((()=>r)):r}}));function Rh(e,t,n){e.issues.length&&t.issues.push(...qp(n,e.issues)),t.value[n]=e.value}const Ch=Pp("$ZodRecord",((e,t)=>{bh.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!function(e){if(!1===_p(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==_p(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const o=new Set;for(const e of a)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){o.add("number"==typeof e?e.toString():e);const a=t.valueType._zod.run({value:s[e],issues:[]},r);a instanceof Promise?i.push(a.then((t=>{t.issues.length&&n.issues.push(...qp(e,t.issues)),n.value[e]=t.value}))):(a.issues.length&&n.issues.push(...qp(e,a.issues)),n.value[e]=a.value)}let c;for(const e in s)o.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(s)){if("__proto__"===a)continue;const o=t.keyType._zod.run({value:a,issues:[]},r);if(o instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(o.issues.length){"loose"===t.mode?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:o.issues.map((e=>Fp(e,r,Ap()))),input:a,path:[a],inst:e});continue}const c=t.valueType._zod.run({value:s[a],issues:[]},r);c instanceof Promise?i.push(c.then((e=>{e.issues.length&&n.issues.push(...qp(a,e.issues)),n.value[o.value]=e.value}))):(c.issues.length&&n.issues.push(...qp(a,c.issues)),n.value[o.value]=c.value)}}return i.length?Promise.all(i).then((()=>n)):n}})),Bh=Pp("$ZodLiteral",((e,t)=>{if(bh.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?Cp(e):e?Cp(e.toString()):String(e))).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}));function Dh(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Uh=Pp("$ZodOptional",((e,t)=>{bh.init(e,t),e._zod.optin="optional",e._zod.optout="optional",jp(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),jp(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${$p(e.source)})?$`):void 0})),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((t=>Dh(t,e.value))):Dh(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}})),qh=Pp("$ZodNullable",((e,t)=>{bh.init(e,t),jp(e._zod,"optin",(()=>t.innerType._zod.optin)),jp(e._zod,"optout",(()=>t.innerType._zod.optout)),jp(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${$p(e.source)}|null)$`):void 0})),jp(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),Lh=Pp("$ZodPipe",((e,t)=>{bh.init(e,t),jp(e._zod,"values",(()=>t.in._zod.values)),jp(e._zod,"optin",(()=>t.in._zod.optin)),jp(e._zod,"optout",(()=>t.out._zod.optout)),jp(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>Fh(e,t.in,n))):Fh(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>Fh(e,t.out,n))):Fh(r,t.out,n)}}));function Fh(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Kh=Pp("$ZodCodec",((e,t)=>{bh.init(e,t),jp(e._zod,"values",(()=>t.in._zod.values)),jp(e._zod,"optin",(()=>t.in._zod.optin)),jp(e._zod,"optout",(()=>t.out._zod.optout)),jp(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,n)=>{if("forward"===(n.direction||"forward")){const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>Vh(e,t,n))):Vh(r,t,n)}{const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>Vh(e,t,n))):Vh(r,t,n)}}}));function Vh(e,t,n){if(e.issues.length)return e.aborted=!0,e;if("forward"===(n.direction||"forward")){const r=t.transform(e.value,e);return r instanceof Promise?r.then((r=>Gh(e,r,t.out,n))):Gh(e,r,t.out,n)}{const r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then((r=>Gh(e,r,t.in,n))):Gh(e,r,t.in,n)}}function Gh(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Zh=Pp("$ZodReadonly",((e,t)=>{bh.init(e,t),jp(e._zod,"propValues",(()=>t.innerType._zod.propValues)),jp(e._zod,"values",(()=>t.innerType._zod.values)),jp(e._zod,"optin",(()=>t.innerType?._zod?.optin)),jp(e._zod,"optout",(()=>t.innerType?._zod?.optout)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Hh):Hh(r)}}));function Hh(e){return e.value=Object.freeze(e.value),e}const Wh=Pp("$ZodTemplateLiteral",((e,t)=>{bh.init(e,t);const n=[];for(const e of t.parts)if("object"==typeof e&&null!==e){if(!e._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);const t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw new Error(`Invalid template literal part: ${e._zod.traits}`);const r=t.startsWith("^")?1:0,s=t.endsWith("$")?t.length-1:t.length;n.push(t.slice(r,s))}else{if(null!==e&&!Rp.has(typeof e))throw new Error(`Invalid template literal part: ${e}`);n.push(Cp(`${e}`))}e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(n,r)=>"string"!=typeof n.value?(n.issues.push({input:n.value,inst:e,expected:"template_literal",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}));var Yh;class Qh{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Jh(e,t){return new ph({check:"min_length",...Dp(t),minimum:e})}function Xh(e,t){return new mh({check:"string_format",format:"regex",...Dp(t),pattern:e})}(Yh=globalThis).__zod_globalRegistry??(Yh.__zod_globalRegistry=new Qh);const em=Pp("ZodMiniType",((e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");bh.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>Hp(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Jp(e,t,n),e.parseAsync=async(t,n)=>Yp(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>eh(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),e.clone=(t,n)=>Bp(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e)})),tm=Pp("ZodMiniString",((e,t)=>{gh.init(e,t),em.init(e,t)}));function nm(e){return function(e,t){return new e({type:"string",...Dp(t)})}(tm,e)}const rm=Pp("ZodMiniNumber",((e,t)=>{wh.init(e,t),em.init(e,t)}));function sm(e){return function(e,t){return new e({type:"number",checks:[],...Dp(t)})}(rm,e)}const im=Pp("ZodMiniBoolean",((e,t)=>{vh.init(e,t),em.init(e,t)}));function am(e){return function(e,t){return new e({type:"boolean",...Dp(t)})}(im,e)}const om=Pp("ZodMiniBigInt",((e,t)=>{xh.init(e,t),em.init(e,t)}));function cm(e){return function(e,t){return new e({type:"bigint",...Dp(t)})}(om,e)}const um=Pp("ZodMiniUndefined",((e,t)=>{Ih.init(e,t),em.init(e,t)}));function dm(e){return function(e,t){return new e({type:"undefined",...Dp(t)})}(um,e)}const lm=Pp("ZodMiniNull",((e,t)=>{Ph.init(e,t),em.init(e,t)}));function fm(e){return function(e,t){return new e({type:"null",...Dp(t)})}(lm,e)}const pm=Pp("ZodMiniAny",((e,t)=>{zh.init(e,t),em.init(e,t)}));function hm(){return new pm({type:"any"})}const mm=Pp("ZodMiniUnknown",((e,t)=>{Eh.init(e,t),em.init(e,t)}));function ym(){return new mm({type:"unknown"})}const bm=Pp("ZodMiniDate",((e,t)=>{Ah.init(e,t),em.init(e,t)}));function gm(e){return function(e,t){return new e({type:"date",...Dp(t)})}(bm,e)}const wm=Pp("ZodMiniArray",((e,t)=>{Mh.init(e,t),em.init(e,t)}));function vm(e,t){return new wm({type:"array",element:e,...Dp(t)})}const xm=Pp("ZodMiniObject",((e,t)=>{jh.init(e,t),em.init(e,t),jp(e,"shape",(()=>t.shape))}));function Im(e,t){const n={type:"object",shape:e??{},...Dp(t)};return new xm(n)}function Pm(e,t){return function(e,t){const n=e._zod.def;return Bp(e,Np(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Sp(this,"shape",e),e},checks:[]}))}(e,t)}function zm(e,t){return function(e,t){const n=e._zod.def,r=Np(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Sp(this,"shape",r),r},checks:[]});return Bp(e,r)}(e,t)}function Em(e,t){return function(e,t,n){const r=Np(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(s[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)s[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Sp(this,"shape",s),s},checks:[]});return Bp(t,r)}(_m,e,t)}const Am=Pp("ZodMiniUnion",((e,t)=>{Nh.init(e,t),em.init(e,t)}));function km(e,t){return new Am({type:"union",options:e,...Dp(t)})}const Mm=Pp("ZodMiniDiscriminatedUnion",((e,t)=>{Th.init(e,t),em.init(e,t)}));const $m=Pp("ZodMiniTuple",((e,t)=>{_h.init(e,t),em.init(e,t)}));function Om(e,t,n){const r=t instanceof bh;return new $m({type:"tuple",items:e,rest:r?t:null,...Dp(r?n:t)})}const jm=Pp("ZodMiniRecord",((e,t)=>{Ch.init(e,t),em.init(e,t)}));function Sm(e,t,n){return new jm({type:"record",keyType:e,valueType:t,...Dp(n)})}const Nm=Pp("ZodMiniLiteral",((e,t)=>{Bh.init(e,t),em.init(e,t)}));function Tm(e,t){return new Nm({type:"literal",values:Array.isArray(e)?e:[e],...Dp(t)})}const _m=Pp("ZodMiniOptional",((e,t)=>{Uh.init(e,t),em.init(e,t)}));function Rm(e){return new _m({type:"optional",innerType:e})}const Cm=Pp("ZodMiniNullable",((e,t)=>{qh.init(e,t),em.init(e,t)}));function Bm(e){return new Cm({type:"nullable",innerType:e})}function Dm(e){return Rm(Bm(e))}const Um=Pp("ZodMiniPipe",((e,t)=>{Lh.init(e,t),em.init(e,t)})),qm=Pp("ZodMiniCodec",((e,t)=>{Um.init(e,t),Kh.init(e,t)}));function Lm(e,t,n){return new qm({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}const Fm=Pp("ZodMiniReadonly",((e,t)=>{Zh.init(e,t),em.init(e,t)}));function Km(e){return new Fm({type:"readonly",innerType:e})}const Vm=Pp("ZodMiniTemplateLiteral",((e,t)=>{Wh.init(e,t),em.init(e,t)}));function Gm(e,t){return new Vm({type:"template_literal",parts:e,...Dp(t)})}let Zm=!1;function Hm(e){return bp(function(e){const{payload:t,signature:n}=e,{r:r,s:s,yParity:i}=n,a=new ud.Signature(BigInt(r),BigInt(s)).addRecoveryBit(i);return ip(a.recoverPublicKey(xf(t).substring(2)))}(e))}function Wm(e){const{extraEntropy:t=Zm,hash:n,payload:r,privateKey:s}=e,{r:i,s:a,recovery:o}=ud.sign(qf(r),qf(s),{extraEntropy:"boolean"==typeof t?t:xf(t).slice(2),lowS:!0,...n?{prehash:!0}:{}});return{r:i,s:a,yParity:o}}const Ym=/^(.*)\[([0-9]*)\]$/,Qm=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Jm=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,Xm=2n**256n-1n;function ey(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new oy({signature:e});if(void 0===e.s)throw new oy({signature:e});if(n&&void 0===e.yParity)throw new oy({signature:e});if(e.r<0n||e.r>Xm)throw new cy({value:e.r});if(e.s<0n||e.s>Xm)throw new uy({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new dy({value:e.yParity})}function ty(e){if(130!==e.length&&132!==e.length)throw new ay({signature:e});const t=BigInt(Mf(e,0,32)),n=BigInt(Mf(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return iy(t)}catch{throw new dy({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function ny(e){const t="string"==typeof e?ty(e):e instanceof Uint8Array?function(e){return ty(Pf(e))}(e):"string"==typeof e.r?function(e){const t=(()=>{const t=e.v?Number(e.v):void 0;let n=e.yParity?Number(e.yParity):void 0;if("number"==typeof t&&"number"!=typeof n&&(n=iy(t)),"number"!=typeof n)throw new dy({value:e.yParity});return n})();return{r:BigInt(e.r),s:BigInt(e.s),yParity:t}}(e):e.v?function(e){return{r:e.r,s:e.s,yParity:iy(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return ey(t),t}function ry(e){ey(e);const t=e.r,n=e.s;return vf(zf(t,{size:32}),zf(n,{size:32}),"number"==typeof e.yParity?zf(function(e){if(0===e)return 27;if(1===e)return 28;throw new dy({value:e})}(e.yParity),{size:1}):"0x")}function sy(e){const{r:t,s:n,yParity:r}=e;return[r?"0x01":"0x",0n===t?"0x":Of(zf(t)),0n===n?"0x":Of(zf(n))]}function iy(e){if(0===e||27===e)return 0;if(1===e||28===e)return 1;if(e>=35)return e%2==0?1:0;throw new ly({value:e})}class ay extends ml{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${$f(xf(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class oy extends ml{constructor({signature:e}){super(`Signature \`${hl(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class cy extends ml{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class uy extends ml{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class dy extends ml{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class ly extends ml{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}class fy extends Error{constructor(e,t={}){const n=t.cause instanceof fy?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof fy&&t.cause.docsPath||t.docsPath;super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...r?[`Docs: https://abitype.dev${r}`]:[],...n?[`Details: ${n}`]:[],"Version: abitype@1.2.3"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),t.cause&&(this.cause=t.cause),this.details=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.shortMessage=e}}function py(e,t){const n=e.exec(t);return n?.groups}const hy=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,my=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,yy=/^\(.+?\).*?$/,by=/^tuple(?<array>(\[(\d*)\])*)$/;function gy(e){let t=e.type;if(by.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=gy(e.components[r]),r<n-1&&(t+=", ")}const r=py(by,e.type);return t+=`)${r?.array||""}`,gy({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function wy(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=gy(e[r]),r!==n-1&&(t+=", ")}return t}function vy(e){return"function"===e.type?`function ${e.name}(${wy(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${wy(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${wy(e.inputs)})`:"error"===e.type?`error ${e.name}(${wy(e.inputs)})`:"constructor"===e.type?`constructor(${wy(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const xy=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Iy=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Py=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const zy=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function Ey(e){return zy.test(e)}function Ay(e){return py(zy,e)}const ky=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const My=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const $y=/^receive\(\) external payable$/;const Oy=new Set(["memory","indexed","storage","calldata"]),jy=new Set(["indexed"]),Sy=new Set(["calldata","memory","storage"]);class Ny extends fy{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class Ty extends fy{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class _y extends fy{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class Ry extends fy{constructor({params:e}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class Cy extends fy{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class By extends fy{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class Dy extends fy{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class Uy extends fy{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class qy extends fy{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class Ly extends fy{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Fy extends fy{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Ky extends fy{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class Vy extends fy{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class Gy extends fy{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const Zy=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function Hy(e,t={}){if(function(e){return Py.test(e)}(e))return function(e,t={}){const n=function(e){return py(Py,e)}(e);if(!n)throw new Ly({signature:e,type:"function"});const r=Xy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Jy(r[e],{modifiers:Sy,structs:t,type:"function"}));const a=[];if(n.returns){const e=Xy(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(Jy(e[n],{modifiers:Sy,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:a}}(e,t);if(function(e){return Iy.test(e)}(e))return function(e,t={}){const n=function(e){return py(Iy,e)}(e);if(!n)throw new Ly({signature:e,type:"event"});const r=Xy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Jy(r[e],{modifiers:jy,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}(e,t);if(function(e){return xy.test(e)}(e))return function(e,t={}){const n=function(e){return py(xy,e)}(e);if(!n)throw new Ly({signature:e,type:"error"});const r=Xy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Jy(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}(e,t);if(function(e){return ky.test(e)}(e))return function(e,t={}){const n=function(e){return py(ky,e)}(e);if(!n)throw new Ly({signature:e,type:"constructor"});const r=Xy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Jy(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}(e,t);if(function(e){return My.test(e)}(e))return function(e){const t=function(e){return py(My,e)}(e);if(!t)throw new Ly({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return $y.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new Fy({signature:e})}const Wy=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Yy=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Qy=/^u?int$/;function Jy(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:`${e}${r}`}(e,t?.type,t?.structs);if(Zy.has(n))return Zy.get(n);const r=yy.test(e),s=py(r?Yy:Wy,e);if(!s)throw new Cy({param:e});if(s.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||hy.test(e)||my.test(e)||tb.test(e)}(s.name))throw new By({param:e,name:s.name});const i=s.name?{name:s.name}:{},a="indexed"===s.modifier?{indexed:!0}:{},o=t?.structs??{};let c,u={};if(r){c="tuple";const e=Xy(s.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Jy(e[r],{structs:o}));u={components:t}}else if(s.type in o)c="tuple",u={components:o[s.type]};else if(Qy.test(s.type))c=`${s.type}256`;else if("address payable"===s.type)c="address";else if(c=s.type,"struct"!==t?.type&&!eb(c))throw new _y({type:c});if(s.modifier){if(!t?.modifiers?.has?.(s.modifier))throw new Dy({param:e,type:t?.type,modifier:s.modifier});if(Sy.has(s.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!s.array))throw new Uy({param:e,type:t?.type,modifier:s.modifier})}const d={type:`${c}${s.array??""}`,...i,...a,...u};return Zy.set(n,d),d}function Xy(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const s=e[i],a=e.slice(i+1);switch(s){case",":return 0===r?Xy(a,[...t,n.trim()]):Xy(a,t,`${n}${s}`,r);case"(":return Xy(a,t,`${n}${s}`,r+1);case")":return Xy(a,t,`${n}${s}`,r-1);default:return Xy(a,t,`${n}${s}`,r)}}if(""===n)return t;if(0!==r)throw new Gy({current:n,depth:r});return t.push(n.trim()),t}function eb(e){return"address"===e||"bool"===e||"function"===e||"string"===e||hy.test(e)||my.test(e)}const tb=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function nb(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!Ey(n))continue;const s=Ay(n);if(!s)throw new Ly({signature:n,type:"struct"});const i=s.properties.split(";"),a=[],o=i.length;for(let e=0;e<o;e++){const t=i[e].trim();if(!t)continue;const n=Jy(t,{type:"struct"});a.push(n)}if(!a.length)throw new Ky({signature:n});t[s.name]=a}const r={},s=Object.entries(t),i=s.length;for(let e=0;e<i;e++){const[n,i]=s[e];r[n]=sb(i,t)}return r}const rb=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function sb(e=[],t={},n=new Set){const r=[],s=e.length;for(let i=0;i<s;i++){const s=e[i];if(yy.test(s.type))r.push(s);else{const e=py(rb,s.type);if(!e?.type)throw new qy({abiParameter:s});const{array:i,type:a}=e;if(a in t){if(n.has(a))throw new Vy({type:a});r.push({...s,type:`tuple${i??""}`,components:sb(t[a],t,new Set([...n,a]))})}else{if(!eb(a))throw new Ty({type:a});r.push(s)}}}return r}function ib(e){let t;if("string"==typeof e)t=Hy(e);else{const n=nb(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(!Ey(r)){t=Hy(r,n);break}}}if(!t)throw new Ny({signature:e});return t}function ab(e){const t=[];if("string"==typeof e){const n=Xy(e),r=n.length;for(let e=0;e<r;e++)t.push(Jy(n[e],{modifiers:Oy}))}else{const n=nb(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(Ey(r))continue;const i=Xy(r),a=i.length;for(let e=0;e<a;e++)t.push(Jy(i[e],{modifiers:Oy,structs:n}))}}if(0===t.length)throw new Ry({params:e});return t}function ob({checksumAddress:e=!1,parameter:t,value:n}){const r=t,s=function(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}(r.type);if(s){const[t,i]=s;return function(e,t){const{checksumAddress:n,length:r,parameter:s}=t,i=null===r;if(!Array.isArray(e))throw new wb(e);if(!i&&e.length!==r)throw new yb({expectedLength:r,givenLength:e.length,type:`${s.type}[${r}]`});let a=!1;const o=[];for(let t=0;t<e.length;t++){const r=ob({checksumAddress:n,parameter:s,value:e[t]});r.dynamic&&(a=!0),o.push(r)}if(i||a){const e=cb(o);if(i){const t=zf(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?vf(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:vf(...o.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:i}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let s=!1;const i=[];for(let t=0;t<r.components.length;t++){const a=r.components[t],o=ob({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});i.push(o),o.dynamic&&(s=!0)}return{dynamic:s,encoded:s?cb(i):vf(...i.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return hp(e,{strict:n}),{dynamic:!1,encoded:Af(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new ml(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Af(If(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Jm.exec(r.type)??[];return function(e,{signed:t,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new Tf({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:zf(e,{size:32,signed:t})}}(n,{signed:e,size:Number(t)})}if(r.type.startsWith("bytes"))return function(e,{type:t}){const[,n]=t.split("bytes"),r=$f(e);if(!n){let t=e;return r%32!=0&&(t=kf(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:vf(Af(zf(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new bb({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:kf(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=Ef(e),n=Math.ceil($f(t)/32),r=[];for(let e=0;e<n;e++)r.push(kf(Mf(t,32*e,32*(e+1))));return{dynamic:!0,encoded:vf(kf(zf($f(t),{size:32})),...r)}}(n);throw new vb(r.type)}function cb(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:s}=e[n];t+=r?32:$f(s)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(zf(t+s,{size:32})),r.push(o),s+=$f(o)):n.push(o)}return vf(...n,...r)}const ub={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new fb({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new lb({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new db({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new db({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};class db extends ml{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class lb extends ml{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class fb extends ml{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function pb(e,t,n){const{checksumAddress:r=!1}=n??{};if(e.length!==t.length)throw new gb({expectedLength:e.length,givenLength:t.length});const s=function({checksumAddress:e,parameters:t,values:n}){const r=[];for(let s=0;s<t.length;s++)r.push(ob({checksumAddress:e,parameter:t[s],value:n[s]}));return r}({checksumAddress:r,parameters:e,values:t}),i=cb(s);return 0===i.length?"0x":i}function hb(e,t){if(e.length!==t.length)throw new gb({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r];n.push(hb.encode(s,i))}return vf(...n)}function mb(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?ab(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return hp(e),Af(e.toLowerCase(),r?32:0)}if("string"===t)return Ef(n);if("bytes"===t)return n;if("bool"===t)return Af(If(n),r?32:1);const s=t.match(Jm);if(s){const[e,t,i="256"]=s,a=Number.parseInt(i,10)/8;return zf(n,{size:r?32:a,signed:"int"===t})}const i=t.match(Qm);if(i){const[e,t]=i;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new bb({expectedSize:Number.parseInt(t,10),value:n});return kf(n,r?32:0)}const a=t.match(Ym);if(a&&Array.isArray(n)){const[t,r]=a,s=[];for(let t=0;t<n.length;t++)s.push(e(r,n[t],!0));return 0===s.length?"0x":vf(...s)}throw new vb(t)}}(hb||(hb={}));class yb extends ml{constructor({expectedLength:e,givenLength:t,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class bb extends ml{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${$f(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class gb extends ml{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class wb extends ml{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class vb extends ml{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}function xb(e){const{domain:t={},message:n,primaryType:r}=e,s={EIP712Domain:Pb(t),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:s}=e,i=(e,t)=>{for(const n of e){const{name:e,type:r}=n,a=t[e],o=r.match(Jm);if(o&&("number"==typeof a||"bigint"==typeof a)){const[,e,t]=o;zf(a,{signed:"int"===e,size:Number.parseInt(t??"",10)/8})}if("address"===r&&"string"==typeof a&&!wp(a))throw new vp({address:a,cause:new xp});const c=r.match(Qm);if(c){const[,e]=c;if(e&&$f(a)!==Number.parseInt(e,10))throw new Ab({expectedSize:Number.parseInt(e,10),givenSize:$f(a)})}const u=s[r];u&&(Tb(r),i(u,a))}};if(s.EIP712Domain&&t){if("object"!=typeof t)throw new kb({domain:t});i(s.EIP712Domain,t)}if("EIP712Domain"!==r){if(!s[r])throw new Mb({primaryType:r,types:s});i(s[r],n)}}({domain:t,message:n,primaryType:r,types:s});const i=["0x19","0x01"];return t&&i.push(function(e){const{domain:t,types:n}=e;return Eb({data:t,primaryType:"EIP712Domain",types:{...n,EIP712Domain:n?.EIP712Domain||Pb(t)}})}({domain:t,types:s})),"EIP712Domain"!==r&&i.push(Eb({data:n,primaryType:r,types:s})),vf(...i)}function Ib(e){const{primaryType:t,types:n}=e;let r="";const s=Nb({primaryType:t,types:n});s.delete(t);const i=[t,...Array.from(s).sort()];for(const e of i)r+=`${e}(${(n[e]??[]).map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`;return r}function Pb(e){return["string"==typeof e?.name&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},("number"==typeof e?.chainId||"bigint"==typeof e?.chainId)&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function zb(e){return np(xb(e))}function Eb(e){const{data:t,primaryType:n,types:r}=e;return np(Ob({data:t,primaryType:n,types:r}))}class Ab extends ml{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.BytesSizeMismatchError"})}}class kb extends ml{constructor({domain:e}){super(`Invalid domain "${hl(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.InvalidDomainError"})}}class Mb extends ml{constructor({primaryType:e,types:t}){super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(t))}\`.`,{metaMessages:["Check that the primary type is a key in `types`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.InvalidPrimaryTypeError"})}}class $b extends ml{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.InvalidStructTypeError"})}}function Ob(e){const{data:t,primaryType:n,types:r}=e,s=[{type:"bytes32"}],i=[jb({primaryType:n,types:r})];for(const e of r[n]??[]){const[n,a]=Sb({types:r,name:e.name,type:e.type,value:t[e.name]});s.push(n),i.push(a)}return pb(s,i)}function jb(e){const{primaryType:t,types:n}=e;return np(Ef(Ib({primaryType:t,types:n})))}function Sb(e){let{types:t,name:n,type:r,value:s}=e;if(void 0!==t[r])return[{type:"bytes32"},np(Ob({data:s,primaryType:r,types:t}))];if("bytes"===r){return s=`0x${(s.length%2?"0":"")+s.slice(2)}`,[{type:"bytes32"},np(s,{as:"Hex"})]}if("string"===r)return[{type:"bytes32"},np(Kf(s),{as:"Hex"})];if(r.lastIndexOf("]")===r.length-1){const e=r.slice(0,r.lastIndexOf("[")),i=s.map((r=>Sb({name:n,type:e,types:t,value:r})));return[{type:"bytes32"},np(pb(i.map((([e])=>e)),i.map((([,e])=>e))))]}return[{type:r},s]}function Nb(e,t=new Set){const{primaryType:n,types:r}=e,s=n.match(/^\w*/u),i=s?.[0];if(t.has(i)||void 0===r[i])return t;t.add(i);for(const e of r[i])Nb({primaryType:e.type,types:r},t);return t}function Tb(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new $b({type:e})}function _b(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),"("===o&&r++,")"===o&&r--,t)if(0!==r)" "!==o?(s+=o,n+=o):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===o&&["event","function","error",""].includes(s))s="";else if(s+=o,")"===o){i=!0;break}}if(!i)throw new ml("Unable to normalize signature.");return s}function Rb(e,t){const n=typeof e,r=t.type;switch(r){case"address":return wp(e,{strict:!1});case"bool":return"boolean"===n;case"function":case"string":return"string"===n;default:return"tuple"===r&&"components"in t?Object.values(t.components).every(((t,n)=>Rb(Object.values(e)[n],t))):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?"number"===n||"bigint"===n:/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?"string"===n||e instanceof Uint8Array:!!/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)&&(Array.isArray(e)&&e.every((e=>Rb(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")}))))}}function Cb(e,t,n){for(const r in e){const s=e[r],i=t[r];if("tuple"===s.type&&"tuple"===i.type&&"components"in s&&"components"in i)return Cb(s.components,i.components,n[r]);const a=[s.type,i.type];if(!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&wp(n[r],{strict:!1}))return a}}function Bb(e,t,n){const{args:r=[],prepare:s=!0}=n??{},i=Nf(t,{strict:!1}),a=e.filter((e=>i?"function"===e.type||"error"===e.type?Db(e)===Mf(t,0,4):"event"===e.type&&Ub(e)===t:"name"in e&&e.name===t));if(0===a.length)throw new Lb({name:t});if(1===a.length)return{...a[0],...s?{hash:Ub(a[0])}:{}};let o;for(const e of a){if(!("inputs"in e))continue;if(!r||0===r.length){if(!e.inputs||0===e.inputs.length)return{...e,...s?{hash:Ub(e)}:{}};continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==r.length)continue;const t=r.every(((t,n)=>{const r="inputs"in e&&e.inputs[n];return!!r&&Rb(t,r)}));if(t){if(o&&"inputs"in o&&o.inputs){const t=Cb(e.inputs,o.inputs,r);if(t)throw new qb({abiItem:e,type:t[0]},{abiItem:o,type:t[1]})}o=e}}const c=(()=>{if(o)return o;const[e,...t]=a;return{...e,overloads:t}})();if(!c)throw new Lb({name:t});return{...c,...s?{hash:Ub(c)}:{}}}function Db(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Bb(t,n)}return e[0]})();return Mf(Ub(t),0,4)}function Ub(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Bb(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:np(Ef(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Bb(t,n)}return e[0]})();return _b("string"==typeof t?t:vy(t))}(t)))}class qb extends ml{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${_b(vy(e.abiItem))}\`, and`,`\`${t.type}\` in \`${_b(vy(t.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}class Lb extends ml{constructor({name:e,data:t,type:n="item"}){super(`ABI ${n}${e?` with name "${e}"`:t?` with data "${t}"`:""} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}function Fb(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Kb(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,s=r?Kb([t,...r],t.name,{args:n}):t,i=Vb(s),a=n.length>0?pb(s.inputs,n):void 0;return a?vf(i,a):i}function Kb(e,t,n){const r=Bb(e,t,n);if("function"!==r.type)throw new Lb({name:t,type:"function"});return r}function Vb(e){return Db(e)}const Gb=Iu(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Zb=Wu({a:Gb.create(BigInt("-3")),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:Gb,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Os),Hb=Iu(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"));Wu({a:Hb.create(BigInt("-3")),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Fp:Hb,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},Ss);const Wb=Iu(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));Wu({a:Wb.create(BigInt("-3")),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Fp:Wb,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1),lowS:!1,allowedPrivateKeyLengths:[130,131,132]},js);const Yb=Zb,Qb=Zb;function Jb(e){const{privateKey:t}=e;return ip(Qb.ProjectivePoint.fromPrivateKey("string"==typeof t?t.slice(2):Pf(t).slice(2)))}function Xb(e={}){const{as:t="Hex"}=e,n=Qb.utils.randomPrivateKey();return"Hex"===t?Pf(n):n}function eg(e){const{extraEntropy:t=Zm,hash:n,payload:r,privateKey:s}=e,{r:i,s:a,recovery:o}=Qb.sign(r instanceof Uint8Array?r:Ff(r),s instanceof Uint8Array?s:Ff(s),{extraEntropy:"boolean"==typeof t?t:xf(t).slice(2),lowS:!0,...n?{prehash:!0}:{}});return{r:i,s:a,yParity:o}}function tg(e,t=0){if(!/^(-?)([0-9]*)\.?([0-9]*)$/.test(e))throw new ng({value:e});let[n="",r="0"]=e.split(".");const s=n.startsWith("-");if(s&&(n=n.slice(1)),r=r.replace(/(0+)$/,""),0===t)1===Math.round(Number(`.${r}`))&&(n=`${BigInt(n)+1n}`),r="";else if(r.length>t){const[e,s,i]=[r.slice(0,t-1),r.slice(t-1,t),r.slice(t)],a=Math.round(Number(`${s}.${i}`));r=a>9?`${BigInt(e)+BigInt(1)}0`.padStart(e.length+1,"0"):`${e}${a}`,r.length>t&&(r=r.slice(1),n=`${BigInt(n)+1n}`),r=r.slice(0,t)}else r=r.padEnd(t,"0");return BigInt(`${s?"-":""}${n}${r}`)}class ng extends ml{constructor({value:e}){super(`Value \`${e}\` is not a valid decimal number.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Value.InvalidDecimalNumberError"})}}const rg=new TextEncoder,sg=new TextDecoder,ig=Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map(((e,t)=>[t,e.charCodeAt(0)]))),ag={...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map(((e,t)=>[e.charCodeAt(0),t]))),["=".charCodeAt(0)]:0,["-".charCodeAt(0)]:62,["_".charCodeAt(0)]:63};function og(e,t={}){return function(e,t={}){const{pad:n=!0,url:r=!1}=t,s=new Uint8Array(4*Math.ceil(e.length/3));for(let t=0,n=0;n<e.length;t+=4,n+=3){const r=(e[n]<<16)+(e[n+1]<<8)+(0|e[n+2]);s[t]=ig[r>>18],s[t+1]=ig[r>>12&63],s[t+2]=ig[r>>6&63],s[t+3]=ig[63&r]}const i=e.length%3,a=4*Math.floor(e.length/3)+(i&&i+1);let o=sg.decode(new Uint8Array(s.buffer,0,a));return n&&1===i&&(o+="=="),n&&2===i&&(o+="="),r&&(o=o.replaceAll("+","-").replaceAll("/","_")),o}(Ff(e),t)}function cg(e){const t=e.replace(/=+$/,""),n=t.length,r=new Uint8Array(n+3);rg.encodeInto(t+"===",r);for(let e=0,n=0;e<t.length;e+=4,n+=3){const t=(ag[r[e]]<<18)+(ag[r[e+1]]<<12)+(ag[r[e+2]]<<6)+ag[r[e+3]];r[n]=t>>16,r[n+1]=t>>8&255,r[n+2]=255&t}const s=3*(n>>2)+(n%4&&n%4-1);return new Uint8Array(r.buffer,0,s)}const ug=Uint8Array.from([105,171,180,181,160,222,75,198,42,42,32,31,141,37,186,233]);async function dg(e){const{createFn:t=window.navigator.credentials.create.bind(window.navigator.credentials),...n}=e,r=function(e){const{attestation:t="none",authenticatorSelection:n={residentKey:"preferred",requireResidentKey:!1,userVerification:"required"},challenge:r=ug,excludeCredentialIds:s,extensions:i,name:a,rp:o={id:window.location.hostname,name:window.document.title},user:c}=e,u=c?.name??a;return{publicKey:{attestation:t,authenticatorSelection:n,challenge:"string"==typeof r?Ff(r):r,...s?{excludeCredentials:s?.map((e=>({id:cg(e),type:"public-key"})))}:{},pubKeyCredParams:[{type:"public-key",alg:-7}],...i&&{extensions:i},rp:o,user:{id:c?.id??np(Kf(u),{as:"Bytes"}),name:u,displayName:c?.displayName??u}}}}(n);try{const e=await t(r);if(!e)throw new pg;const n=e.response,s=await async function(e){try{const t=e.getPublicKey();if(!t)throw new pg;const n=new Uint8Array(t),r=await crypto.subtle.importKey("spki",new Uint8Array(n),{name:"ECDSA",namedCurve:"P-256",hash:"SHA-256"},!0,["verify"]);return ip(new Uint8Array(await crypto.subtle.exportKey("raw",r)))}catch(t){if("Permission denied to access object"!==t.message)throw t;const n=new Uint8Array(e.attestationObject),r=32,s=88,i=e=>{const t=new Uint8Array([e,s,r]);for(let e=0;e<n.length-t.length;e++)if(t.every(((t,r)=>n[e+r]===t)))return e+t.length;throw new pg},a=i(33),o=i(34);return ip(new Uint8Array([4,...n.slice(a,a+r),...n.slice(o,o+r)]))}}(n);return{id:e.id,publicKey:s,raw:e}}catch(e){throw new pg({cause:e})}}function lg(e){const{challenge:t,crossOrigin:n,extraClientData:r,flag:s,origin:i,rpId:a,signCount:o,userVerification:c="required"}=e,u=function(e={}){const{flag:t=5,rpId:n=window.location.hostname,signCount:r=0}=e;return vf(rp(Ef(n)),zf(t,{size:1}),zf(r,{size:4}))}({flag:s,rpId:a,signCount:o}),d=function(e){const{challenge:t,crossOrigin:n=!1,extraClientData:r,origin:s=window.location.origin}=e;return JSON.stringify({type:"webauthn.get",challenge:og(t,{url:!0,pad:!1}),origin:s,crossOrigin:n,...r})}({challenge:t,crossOrigin:n,extraClientData:r,origin:i}),l=rp(Ef(d)),f=d.indexOf('"challenge"'),p=d.indexOf('"type"');return{metadata:{authenticatorData:u,clientDataJSON:d,challengeIndex:f,typeIndex:p,userVerificationRequired:"required"===c},payload:vf(u,l)}}async function fg(e){const{getFn:t=window.navigator.credentials.get.bind(window.navigator.credentials),...n}=e,r=function(e){const{credentialId:t,challenge:n,extensions:r,rpId:s=window.location.hostname,userVerification:i="required"}=e;return{publicKey:{...t?{allowCredentials:Array.isArray(t)?t.map((e=>({id:cg(e),type:"public-key"}))):[{id:cg(t),type:"public-key"}]}:{},challenge:Ff(n),...r&&{extensions:r},rpId:s,userVerification:i}}}(n);try{const e=await t(r);if(!e)throw new hg;const n=e.response,s=String.fromCharCode(...new Uint8Array(n.clientDataJSON)),i=s.indexOf('"challenge"'),a=s.indexOf('"type"'),o=function(e){const t=0===e[4]?5:4,n=t+32,r=0===e[n+2]?n+3:n+2,s=BigInt(Pf(e.slice(t,n))),i=BigInt(Pf(e.slice(r)));return{r:s,s:i>Yb.CURVE.n/2n?Yb.CURVE.n-i:i}}(new Uint8Array(n.signature));return{metadata:{authenticatorData:Pf(new Uint8Array(n.authenticatorData)),clientDataJSON:s,challengeIndex:i,typeIndex:a,userVerificationRequired:"required"===r.publicKey.userVerification},signature:o,raw:e}}catch(e){throw new hg({cause:e})}}class pg extends ml{constructor({cause:e}={}){super("Failed to create credential.",{cause:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WebAuthnP256.CredentialCreationFailedError"})}}class hg extends ml{constructor({cause:e}={}){super("Failed to request credential.",{cause:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WebAuthnP256.CredentialRequestFailedError"})}}const mg="0x3232323232323232323232323232323232323232",yg="0x32323232",bg={p256:"p256",secp256k1:"secp256k1",webauthnp256:"webauthn-p256"},gg={admin:"admin",normal:"session"},wg={0:"minute",1:"hour",2:"day",3:"week",4:"month",5:"year"},vg={address:"secp256k1",p256:"p256",secp256k1:"secp256k1","webauthn-p256":"webauthnp256"},xg={admin:"admin",session:"normal"},Ig={address:2,p256:0,secp256k1:2,"webauthn-p256":1},Pg={day:2,hour:1,minute:0,month:4,week:3,year:5};function zg(e={}){return function(e){const{chainId:t,expiry:n,feeToken:r,permissions:s,privateKey:i,role:a}=e,o=op(Jb({privateKey:i}),{includePrefix:!1});return Mg({chainId:t,expiry:n,feeToken:r,permissions:s,privateKey:()=>i,publicKey:o,role:a,type:"p256"})}({...e,privateKey:Xb()})}async function Eg(e){const{createFn:t,label:n,rpId:r,userId:s}=e,i=await dg({authenticatorSelection:{requireResidentKey:!0,residentKey:"required",userVerification:"required"},createFn:t,extensions:{credProps:!0},rp:r?{id:r,name:r}:void 0,user:{displayName:n,id:new Uint8Array(s??Kf(n)),name:n}});return $g({...e,credential:{id:i.id,publicKey:i.publicKey},id:s?Hf(s):op(i.publicKey,{includePrefix:!1})})}function Ag(e={}){return function(e){const{privateKey:t}=e,n=op(Jb({privateKey:t}),{includePrefix:!1});return Mg({chainId:e.chainId,expiry:e.expiry??0,feeToken:e.feeToken,permissions:e.permissions,privateKey:{privateKey:()=>t},publicKey:n,role:e.role,type:"webauthn-p256"})}({...e,privateKey:Xb()})}async function kg(e={}){return function(e){const{chainId:t,expiry:n,feeToken:r,keyPair:s,permissions:i,role:a}=e,{privateKey:o}=s,c=op(s.publicKey,{includePrefix:!1});return Mg({chainId:t,expiry:n,feeToken:r,permissions:i,prehash:!0,privateKey:o,publicKey:c,role:a,type:"p256"})}({...e,keyPair:await async function(e={}){const{extractable:t=!1}=e,n=await globalThis.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},t,["sign","verify"]),r=await globalThis.crypto.subtle.exportKey("raw",n.publicKey),s=ip(new Uint8Array(r));return{privateKey:n.privateKey,publicKey:s}}()})}function Mg(e,t={}){const{chainId:n=e.chainId}=t,{expiry:r=0,id:s,prehash:i=!1,role:a="admin",type:o}=e,c=(()=>{const t=e.publicKey;if("0x"===t)return t;if("secp256k1"===o||"address"===o){return 20===$f(t)||0n===jf(Mf(t,0,12))?Mf(t,-20):bp(ap(t))}return t})();return{...e,chainId:n,expiry:r,hash:Og({publicKey:c,type:o}),id:(s??c).toLowerCase(),prehash:i,publicKey:c.toLowerCase(),role:a,type:o}}function $g(e){const{credential:t,id:n,rpId:r}=e,s=op(t.publicKey,{includePrefix:!1});return Mg({chainId:e.chainId,expiry:e.expiry??0,feeToken:e.feeToken,id:n,permissions:e.permissions,privateKey:{credential:t,rpId:r},publicKey:s,role:e.role,type:"webauthn-p256"})}function Og(e){const{type:t}=e,n=jg(e.publicKey);return np(pb([{type:"uint8"},{type:"bytes32"}],[Ig[t],np(n)]))}function jg(e){return $f(e)<32?Af(e,32):e}async function Sg(e,t){const{address:n,storage:r,webAuthn:s,wrap:i=!0}=t,{privateKey:a,publicKey:o,type:c}=e;if(!a)throw new Error("Key does not have a private key to sign with.\n\nKey:\n"+hl(e,null,2));const u=n?zb({domain:{verifyingContract:n},message:{digest:t.payload},primaryType:"ERC1271Sign",types:{ERC1271Sign:[{name:"digest",type:"bytes32"}]}}):t.payload,[d,l]=await(async()=>{if("p256"===c){const{privateKey:t}=e;if("function"==typeof t)return[ry(eg({payload:u,privateKey:t()})),!1];if(t instanceof CryptoKey){const e=ry(await async function(e){const{payload:t,privateKey:n}=e,r=await globalThis.crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},n,qf(t)),s=Lf(new Uint8Array(r)),i=Zf(Gf(s,0,32));let a=Zf(Gf(s,32,64));return a>Yb.CURVE.n/2n&&(a=Yb.CURVE.n-a),{r:i,s:a}}({payload:u,privateKey:t}));return[e,!0]}}if("secp256k1"===c)return[ry(Wm({payload:u,privateKey:a()})),!1];if("webauthn-p256"===c){if(a.privateKey){const{payload:e,metadata:t}=lg({challenge:u,origin:"https://ithaca.xyz",rpId:"ithaca.xyz"}),{r:n,s:r}=eg({hash:!0,payload:e,privateKey:a.privateKey()});return[_g({metadata:t,signature:{r:n,s:r}}),!1]}const{credential:t,rpId:n}=a,i=`porto.webauthnVerified.${e.hash}`,o=Date.now(),c=6e5;let d=!0;if(r){const e=await r.getItem(i);d=!e||o-e>c}const{signature:{r:l,s:f},raw:p,metadata:h}=await fg({challenge:u,credentialId:t.id,getFn:s?.getFn,rpId:n,userVerification:d?"required":"preferred"}),m=p.response;if(!m?.userHandle)throw new Error("No user handle in response",{cause:{response:m}});const y=Hf(new Uint8Array(m.userHandle));if(e.id&&wp(e.id)&&!gp(e.id,y))throw new Error(`supplied webauthn key "${e.id}" does not match signature webauthn key "${y}"`,{cause:{id:y,key:e}});d&&r&&await r.setItem(i,o);return[_g({metadata:h,signature:{r:l,s:f}}),!1]}throw new Error(`Key type "${c}" is not supported.\n\nKey:\n`+hl(e,null,2))})();return i?Rg(d,{keyType:c,prehash:l,publicKey:o}):d}function Ng(e,t={}){const{expiry:n=0,prehash:r=!1,publicKey:s,role:i="admin",type:a}=e,{feeTokens:o,orchestrator:c}=t,u=Object.entries(Tg(e,{feeTokens:o})).map((([e,t])=>{if("calls"===e){return t.map((({signature:e,to:t})=>({selector:e?Nf(e)?e:Vb(e):yg,to:t??mg,type:"call"})))}if("feeToken"!==e){if("spend"===e){return t.map((({limit:e,period:t,token:n})=>({limit:e,period:t,token:n,type:"spend"})))}throw new Error(`Invalid permission type "${e}".`)}})).flat().filter(Boolean);return"session"===e.role&&c&&u.push({selector:yg,to:c,type:"call"}),{expiry:n,permissions:u??[],prehash:r,publicKey:jg(s),role:xg[i],type:vg[a]}}function Tg(e,t){const{permissions:n}=e,r=n?.calls?[...n.calls]:[],s=n?.spend?[...n.spend]:[],i=t.feeTokens?.filter((e=>e.feeToken));if(i&&i.length>0){const t=function(e,t){const{feeTokens:n}=t;if(!e.feeToken)return;const r=n.find((t=>e.feeToken.symbol===t.symbol||(e.feeToken.symbol?"native"===e.feeToken.symbol&&t.address===Wd:t.address===Wd)));if(!r)return;const s=tg(e.feeToken.limit,r.decimals);return{...r,value:s}}(e,{feeTokens:i});if(t){let e=-1,n=Pg.year;for(let r=0;r<s.length;r++){const i=s[r];if(i.token&&gp(t.address,i.token)){e=r;break}if(!i.token&&t.address===Wd){e=r;break}const a=Pg[i.period];a<n&&(n=a)}-1!==e?(s[e]={...s[e],limit:s[e].limit+t.value},s.unshift(s.splice(e,1)[0])):"number"==typeof n&&s.unshift({limit:t.value,period:wg[n],token:t.address})}}return{...n,calls:r,spend:s}}function _g(e){const{metadata:t,signature:n}=e;return pb(mb(["struct WebAuthnAuth { bytes authenticatorData; string clientDataJSON; uint256 challengeIndex; uint256 typeIndex; bytes32 r; bytes32 s; }","WebAuthnAuth auth"]),[{authenticatorData:t.authenticatorData,challengeIndex:BigInt(t.challengeIndex),clientDataJSON:t.clientDataJSON,r:zf(n.r,{size:32}),s:zf(n.s,{size:32}),typeIndex:BigInt(t.typeIndex)}])}function Rg(e,t){const{keyType:n,prehash:r=!1,publicKey:s}=t;return hb(["bytes","bytes32","bool"],[e,Og({publicKey:s,type:n}),r])}function Cg(e){const t="string"==typeof e?{address:e}:e,n=t.sign?"privateKey":"porto",{address:r,sign:s,signMessage:i,signTransaction:a,signTypedData:o,type:c}=function(e){if("string"==typeof e){if(!Qt(e,{strict:!1}))throw new Kt({address:e});return{address:e,type:"json-rpc"}}if(!Qt(e.address,{strict:!1}))throw new Kt({address:e.address});return{address:e.address,nonceManager:e.nonceManager,sign:e.sign,signAuthorization:e.signAuthorization,signMessage:e.signMessage,signTransaction:e.signTransaction,signTypedData:e.signTypedData,source:"custom",type:"local"}}({address:t.address,sign({hash:e}){if("privateKey"===n)return t.sign({hash:e});throw new Error("`sign` not supported on porto accounts.")},signMessage({message:e}){return this.sign({hash:mo(e)})},signTransaction(){throw new Error("`signTransaction` not supported on porto accounts.")},signTypedData(e){return this.sign({hash:xo(e)})}});return{address:r,keys:t.keys??void 0,sign:s,signMessage:i,signTransaction:a,signTypedData:o,source:n,type:c}}function Bg(e,t={}){const{keys:n}=t,r=bp(function(e){const{privateKey:t}=e;return ip(ud.ProjectivePoint.fromPrivateKey(xf(t).slice(2)))}({privateKey:e}));return Cg({address:r,keys:n,sign:async({hash:t})=>ry(Wm({payload:t,privateKey:e})),source:"privateKey"})}function Dg(e,t={}){const{key:n,role:r}=t;if(null!==n)return"object"==typeof n?n:e.keys&&e.keys.length>0?"number"==typeof n?e.keys[n]:e.keys.find((e=>e.privateKey&&(!r||e.role===r))):void 0}async function Ug(e,t){const{storage:n,replaySafe:r=!0,wrap:s=!0,webAuthn:i}=t,a=Dg(e,t),o=r?zb({domain:{verifyingContract:e.address},message:{digest:t.payload},primaryType:"ERC1271Sign",types:{ERC1271Sign:[{name:"digest",type:"bytes32"}]}}):t.payload,c=a?({hash:e})=>Sg(a,{address:null,payload:e,storage:n,webAuthn:i,wrap:s}):"privateKey"===e.source?e.sign:void 0;if(!c)throw new Error("cannot find key to sign with.");return await c({hash:o})}function qg(e,t={}){return function(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?ib(e):e;return{...r,...n?{hash:Ub(r)}:{}}}(e,t)}const Lg=qg({inputs:[{name:"message",type:"string"}],name:"Error",type:"error"}),Fg="0x08c379a0",Kg=qg({inputs:[{name:"reason",type:"uint8"}],name:"Panic",type:"error"}),Vg="0x4e487b71";class Gg extends ee{constructor(){super("Function is not recognized.",{metaMessages:["This could be due to any of the following:"," - The contract does not have the function,"," - The address is not a contract."],name:"FunctionSelectorNotRecognizedError"})}}function Zg(e,t={}){return function(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?wc(e):e;return{...r,...n?{hash:Hd(r)}:{}}}(e,t)}function Hg(e){return function(e){return na(Hd(e),0,4)}(e)}const Wg=()=>Gm(["0x",nm()],{message:"Needs string in format ^0x[A-Fa-f0-9]{40}$."}),Yg=()=>Gm(["0x",nm()],{message:"Needs string in format ^0x[A-Fa-f0-9]+$."}),Qg=()=>Lm(Yg(),sm(),{decode:e=>Sf(e),encode:e=>zf(e)}),Jg=()=>Lm(Yg(),cm({message:"Required bigint"}),{decode:e=>jf(e),encode:e=>zf(e)});function Xg(e){return km(e)}class ew extends ml{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Schema.ValidationError"})}}function tw(e){const t=e;let n=`Validation failed with ${t.issues.length} error${1===t.issues.length?"":"s"}:`;n+="\n";for(const e of t.issues)e&&(n+="\n",n+=nw(e));return new ew(n)}function nw(e,t=0){const n=function(e){return 0===e.length?"":"at `"+e.map(((e,t)=>"number"==typeof e?`[${e}]`:"symbol"==typeof e?`[${e.toString()}]`:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)&&t>0?`.${e}`:0===t&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)?e:`["${e}"]`)).join("")+"`"}(e.path),r="- "+(n?`${n}: `:""),s=" ".repeat(t+1);let i=r;switch(e.code){case"invalid_type":{const t=e.expected,n=e.input?function(e){const t=e.input;if(void 0===t)return"undefined";if(null===t)return"null";const n=typeof t;if("object"===n)return Array.isArray(t)?"array":t instanceof Date?"date":t instanceof Map?"map":t instanceof Set?"set":"object";return n}(e):"undefined";i+=`Expected ${t}. ${"Invalid input"!==e.message?e.message:""}`,"undefined"!==n&&(i+=`but received ${n}`);break}case"too_big":{const t=e.maximum,n=e.inclusive??!0,r=e.exact??!1;i+=r?`${e.origin} must be exactly ${t}`:`${e.origin} must be ${n?"at most":"less than"} ${t}`;break}case"too_small":{const t=e.minimum,n=e.inclusive??!0,r=e.exact??!1;i+=r?`${e.origin} must be exactly ${t}`:`${e.origin} must be ${n?"at least":"greater than"} ${t}`;break}case"invalid_format":switch(e.format){case"regex":case"template_literal":i+=`Must match pattern: ${e.pattern}`;break;case"starts_with":i+=`Must start with "${e.prefix}"`;break;case"ends_with":i+=`Must end with "${e.suffix}"`;break;case"includes":i+=`Must include "${e.includes}"`;break;default:i+=`Invalid ${e.format} format`}break;case"not_multiple_of":i+=`Number must be a multiple of ${e.divisor}`;break;case"unrecognized_keys":{const t=e.keys.map((e=>`"${e}"`)).join(", ");i+=`Unrecognized key${e.keys.length>1?"s":""}: ${t}`;break}case"invalid_union":{const n=e.errors&&e.errors.length>0;i+="Invalid union value.",n&&e.errors.forEach((e=>{e.length>0&&e.forEach((e=>{i+="\n",i+=s,i+=nw(e,t+1)}))}));break}case"invalid_key":i+=`Invalid ${e.origin} key`,e.issues&&e.issues.length>0&&e.issues.forEach((e=>{i+="\n",i+=s,i+=nw(e,t+1)}));break;case"invalid_element":i+=`Invalid ${e.origin} element at key "${e.key}"`,e.issues&&e.issues.length>0&&e.issues.forEach((e=>{i+="\n",i+=s,i+=nw(e,t+1)}));break;case"invalid_value":{const t=e.values.map((e=>JSON.stringify(e))).join(", ");e.values.length>1?i+=`Expected one of: ${t}`:i+=`Expected ${t}`;break}case"custom":i+=e.message||"Custom validation failed";break;default:i+=e.message||"Validation failed"}return i}const rw=Im({selector:Yg(),to:Wg(),type:Tm("call")}),sw=Im({limit:Jg(),period:km([Tm("minute"),Tm("hour"),Tm("day"),Tm("week"),Tm("month"),Tm("year")]),token:Rm(km([Wg(),fm()])),type:Tm("spend")}),iw=km([rw,sw]),aw=Im({expiry:Qg(),prehash:Rm(am()),publicKey:Yg(),role:km([Tm("admin"),Tm("normal")]),type:km([Tm("p256"),Tm("secp256k1"),Tm("webauthnp256")])}),ow=Im({...aw.shape,permissions:Km(vm(iw))});var cw,uw,dw,lw,fw,pw;!function(e){e.AssetDiffAsset=km([Im({address:Rm(km([Wg(),fm()])),decimals:Rm(km([sm(),fm()])),direction:km([Tm("incoming"),Tm("outgoing")]),fiat:Rm(Im({currency:nm(),value:Lm(nm(),sm(),{decode:e=>Number(e),encode:e=>String(e)})})),name:Rm(km([nm(),fm()])),symbol:nm(),type:Tm("erc20"),value:Jg()}),Im({address:Rm(km([Wg(),fm()])),direction:km([Tm("incoming"),Tm("outgoing")]),fiat:Rm(Im({currency:nm(),value:Lm(nm(),sm(),{decode:e=>Number(e),encode:e=>String(e)})})),name:Rm(km([nm(),fm()])),symbol:nm(),type:Tm("erc721"),uri:nm(),value:Jg()}),Im({address:fm(),decimals:Rm(km([sm(),fm()])),direction:km([Tm("incoming"),Tm("outgoing")]),fiat:Rm(Im({currency:nm(),value:Lm(nm(),sm(),{decode:e=>Number(e),encode:e=>String(e)})})),symbol:nm(),type:fm(),value:Jg()})]),e.Response=Sm(Yg(),Km(vm(Km(Om([Wg(),Km(vm(e.AssetDiffAsset))])))))}(cw||(cw={})),function(e){e.Request=Km(vm(ow)),e.Response=Km(vm(Im({...ow.shape,hash:Yg()})))}(uw||(uw={})),function(e){e.Response=Sm(Yg(),Im({currency:nm(),value:nm()}))}(dw||(dw={})),function(e){e.Request=Im({feePayer:Rm(Wg()),feeToken:Rm(Wg()),nonce:Rm(Jg())})}(lw||(lw={})),(fw||(fw={})).Request=Km(vm(Im({address:Wg(),value:Jg()}))),function(e){e.Request=Km(vm(Im({hash:Yg()}))),e.Response=Km(vm(Im({hash:Yg()})))}(pw||(pw={}));const hw=Im({eoa:Wg(),executionData:Yg(),nonce:Yg(),signature:Yg()}),mw=Im({...hw.shape,chainId:Qg()}),yw=km([Im({combinedGas:Jg(),encodedFundTransfers:Km(vm(Yg())),encodedPreCalls:Km(vm(Yg())),eoa:Wg(),executionData:Yg(),expiry:Jg(),funder:Wg(),funderSignature:Yg(),isMultichain:am(),nonce:Jg(),payer:Wg(),paymentAmount:Jg(),paymentMaxAmount:Jg(),paymentRecipient:Wg(),paymentSignature:Yg(),paymentToken:Wg(),settler:Wg(),settlerContext:Yg(),signature:Yg(),supportedAccountImplementation:Wg()}),Im({combinedGas:Jg(),encodedFundTransfers:Km(vm(Yg())),encodedPreCalls:Km(vm(Yg())),eoa:Wg(),executionData:Yg(),expiry:Jg(),funder:Wg(),funderSignature:Yg(),isMultichain:am(),nonce:Jg(),payer:Wg(),paymentRecipient:Wg(),paymentSignature:Yg(),paymentToken:Wg(),prePaymentAmount:Jg(),prePaymentMaxAmount:Jg(),settler:Wg(),settlerContext:Yg(),signature:Yg(),supportedAccountImplementation:Wg(),totalPaymentAmount:Jg(),totalPaymentMaxAmount:Jg()})]);Im({eoa:Wg(),executionData:Yg(),nonce:Jg()});const bw=Im({address:km([Wg(),fm()]),decimals:Rm(sm()),deficit:Jg(),fiat:Rm(Im({currency:nm(),value:nm()})),name:Rm(nm()),required:Jg(),symbol:Rm(nm())}),gw=Im({additionalAuthorization:Dm(Im({address:Wg(),chainId:Qg(),nonce:Qg(),r:Yg(),s:Yg(),yParity:Qg()})),assetDeficits:Rm(vm(bw)),authorizationAddress:Rm(km([Wg(),fm()])),chainId:Qg(),ethPrice:Jg(),extraPayment:Jg(),feeTokenDeficit:Jg(),intent:yw,nativeFeeEstimate:Im({maxFeePerGas:Jg(),maxPriorityFeePerGas:Jg()}),orchestrator:Wg(),paymentTokenDecimals:sm(),txGas:Jg()}),ww=Im({multiChainRoot:Rm(km([Yg(),fm()])),quotes:Km(vm(gw)).check(Jh(1)),ttl:sm()}),vw=Im({...ww.shape,hash:Yg(),r:Yg(),s:Yg(),v:Rm(Yg()),yParity:Rm(Yg())}),xw=Im({address:Wg(),decimals:sm(),feeToken:Rm(am()),interop:Rm(am()),nativeRate:Rm(Jg()),symbol:nm(),uid:nm()}),Iw=nm().check(Xh(/^[A-Z0-9]+$/)),Pw=Im({address:Wg(),chainId:Qg(),nonce:Qg()}),zw=Im({...Pw.shape,r:Yg(),s:Yg(),yParity:Qg()}),Ew=Im({data:Rm(Yg()),to:Wg(),value:Rm(Jg())});var Aw,kw,Mw,$w,Ow,jw,Sw,Nw,Tw,_w,Rw,Cw,Bw,Dw,Uw,qw,Lw,Fw,Kw,Vw,Gw;async function Zw(e,t={}){const n=t.chainId?[t.chainId]:"all"!==t.chainIds?t.chainIds?t.chainIds:[e.chain.id]:void 0;try{const r="wallet_getCapabilities",s=await Da((()=>e.request({method:r,params:n?[n]:void 0},{retryCount:0})),{cacheKey:`${e.uid}.${r}.${n?.join(",")}`}),i=t.raw?s:sh(Cw.Response,s);return t.chainIds?i:Object.values(i)[0]}catch(e){throw Jw(e),e}}async function Hw(e,t){const{address:n,capabilities:r,chain:s=e.chain,key:i}=t,a=t.calls.map((e=>({data:e.abi?Fb(Kb(e.abi,e.functionName),e.args):e.data??"0x",to:e.to,value:e.value??0n})));try{const t="wallet_prepareCalls",o=await e.request({method:t,params:[nh(qw.Parameters,{calls:a,capabilities:{...r,meta:{...r?.meta}},chainId:s?.id,from:n,key:i?{prehash:i.prehash,publicKey:i.publicKey,type:i.type}:void 0})]},{retryCount:0});return Object.assign(sh(qw.Response,o),{_raw:o})}catch(e){throw Jw(e),Yw(e,{calls:t.calls}),e}}async function Ww(e,t){const{signature:n}=t,{signature:r,capabilities:{feeSignature:s,...i},...a}=t.response,o=Qw({capabilities:i,...a}),c=Hm({payload:np(Ef(JSON.stringify(o))),signature:ty(n)}),{quoteSigner:u}=await async function(e){const t="health",n=await Da((()=>e.request({method:t})),{cacheKey:`${e.uid}.${t}`});return sh(Nw.Response,n)}(e);return c===u}function Yw(e,{calls:t}={}){if(!(e instanceof ee))return;const n=function(e,t){const n=e.walk((e=>"data"in e));if(!n?.data)return e;if(n.data===Hg(Zg("error FnSelectorNotRecognized()")))return new Gg;let r=null;for(const e of t.calls){const t=e;if(t.abi)try{if(!Boolean(_n({abi:t.abi,data:n.data})))continue;r=t}catch{}}return r?Rr(n,{abi:r.abi,address:r.to,args:r.args,functionName:r.functionName}):e}(e,{calls:t??[]}),r=(e=>{try{if("ContractFunctionExecutionError"===e.name){const t="ContractFunctionRevertedError"===e.cause.name?e.cause.data:void 0;if(t)return function(e,t,n){if("Error"===t)return Lg;if("Panic"===t)return Kg;if(Nf(t,{strict:!1})){const e=Mf(t,0,4);if(e===Fg)return Lg;if(e===Vg)return Kg}const r=Bb(e,t,n);if("error"!==r.type)throw new Lb({name:t,type:"error"});return r}([t.abiItem],t.errorName)}const t=e.walk((e=>!(e instanceof Error)&&3===e.code));if(!t)return;const{data:n,message:r}=t;return"0xd0d5039b"===n?qg("error Unauthorized()"):{inputs:[],name:(r??n).split("(")[0],type:"error"}}catch{return}})(n);if(n!==e||r)throw new Xw(Object.assign(n,{abiError:r}))}function Qw(e){if("object"==typeof e&&null!==e){if(Array.isArray(e))return e.map(Qw);const t={};for(const n of Object.keys(e).sort())t[n]=Qw(e[n]);return t}return e}function Jw(e){if("$ZodError"===e.name)throw tw(e)}!function(e){e.Parameters=Im({address:Wg(),secret:nm()}),e.Request=Im({method:Tm("account_getOnrampContactInfo"),params:Km(Om([e.Parameters]))}),e.Response=Im({email:Rm(nm()),phone:Rm(nm()),phoneVerifiedAt:Rm(sm())})}(Aw||(Aw={})),function(e){e.Parameters=Im({address:Wg()}),e.Request=Im({method:Tm("account_onrampStatus"),params:Km(Om([e.Parameters]))}),e.Response=Im({email:Rm(sm()),phone:Rm(sm())})}(kw||(kw={})),function(e){e.Parameters=Im({phone:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_resendVerifyPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Mw||(Mw={})),function(e){e.Parameters=Im({email:nm().check(Xh(/^.*@.*$/)),walletAddress:Wg()}),e.Request=Im({method:Tm("account_setEmail"),params:Km(Om([e.Parameters]))}),e.Response=fm()}($w||($w={})),function(e){e.Parameters=Im({phone:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_setPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Ow||(Ow={})),function(e){e.Parameters=Im({chainId:Qg(),email:nm(),signature:Yg(),token:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_verifyEmail"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(jw||(jw={})),function(e){e.Parameters=Im({code:nm(),phone:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_verifyPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Sw||(Sw={})),function(e){e.Request=Im({method:Tm("health"),params:dm()}),e.Response=Im({quoteSigner:Wg(),status:nm(),version:nm()})}(Nw||(Nw={})),function(e){e.Parameters=Im({address:Wg(),chainId:Qg(),tokenAddress:Wg(),value:Jg()}),e.Request=Im({method:Tm("wallet_addFaucetFunds"),params:Km(Om([e.Parameters]))}),e.Response=Im({message:Rm(nm()),transactionHash:Yg()})}(Tw||(Tw={})),function(e){e.Parameters=Im({chainId:Qg(),id:Yg()}),e.Request=Im({method:Tm("wallet_getAccounts"),params:Km(Om([e.Parameters]))}),e.Response=Km(vm(Im({address:Wg(),keys:uw.Response})))}(_w||(_w={})),function(e){e.Parameters=Im({address:Wg()}),e.Request=Im({method:Tm("wallet_getAuthorization"),params:Km(Om([e.Parameters]))}),e.Response=Im({authorization:zw,data:Yg(),to:Wg()})}(Rw||(Rw={})),function(e){e.Request=Im({method:Tm("wallet_getCapabilities"),params:Rm(Om([Km(vm(sm()))]))});const t=Im({address:Wg(),version:Rm(km([nm(),fm()]))});e.Response=Sm(Yg(),Im({contracts:Im({accountImplementation:t,accountProxy:t,legacyAccountImplementations:Km(vm(t)),legacyOrchestrators:Km(vm(km([Im({orchestrator:t,simulator:t}),t]))),orchestrator:t,simulator:t}),fees:Im({quoteConfig:Im({constantRate:Rm(km([sm(),fm()])),gas:Rm(Im({intentBuffer:Rm(sm()),txBuffer:Rm(sm())})),rateTtl:sm(),ttl:sm()}),recipient:Wg(),tokens:Km(vm(xw))})}))}(Cw||(Cw={})),function(e){const t=km([Tm("native"),Tm("erc20"),Tm("erc721"),nm()]);e.Parameters=Im({account:Wg(),assetFilter:Rm(Sm(Yg(),Km(vm(Im({address:km([Wg(),Tm("native")]),type:t}))))),assetTypeFilter:Rm(Km(vm(t))),chainFilter:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_getAssets"),params:Km(Om([e.Parameters]))}),e.Price=Im({currency:nm(),value:Lm(nm(),sm(),{decode:e=>Number(e),encode:e=>String(e)})}),e.Response=Sm(nm(),Km(vm(Xg([Im({address:Wg(),balance:Jg(),metadata:Bm(Im({decimals:sm(),fiat:Dm(e.Price),name:nm(),symbol:nm()})),type:Tm("erc20")}),Im({address:Bm(Tm("native")),balance:Jg(),metadata:Bm(Im({decimals:sm(),fiat:Dm(e.Price),name:Rm(nm()),symbol:Rm(nm())})),type:Tm("native")})]))))}(Bw||(Bw={})),function(e){e.Request=Im({method:Tm("wallet_getCallsStatus"),params:Km(Om([Yg()]))}),e.Response=Im({id:nm(),receipts:Rm(Km(vm(Im({blockHash:Yg(),blockNumber:Qg(),chainId:Qg(),gasUsed:Qg(),logs:Km(vm(Im({address:Wg(),data:Yg(),topics:Km(vm(Yg()))}))),status:Yg(),transactionHash:Yg()})))),status:sm()})}(Dw||(Dw={})),function(e){e.Parameters=Im({address:Wg(),chainIds:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_getKeys"),params:Km(Om([e.Parameters]))}),e.Response=Sm(Yg(),uw.Response)}(Uw||(Uw={})),function(e){e.Capabilities=Im({authorizeKeys:Rm(uw.Request),meta:lw.Request,preCall:Rm(am()),preCalls:Rm(Km(vm(hw))),requiredFunds:Rm(fw.Request),revokeKeys:Rm(pw.Request)}),e.ResponseCapabilities=Im({assetDiffs:Rm(cw.Response),authorizeKeys:Dm(uw.Response),feePayerDigest:Rm(Yg()),feeSignature:Rm(Yg()),feeTotals:Rm(dw.Response),revokeKeys:Dm(pw.Response)}),e.Parameters=Im({calls:Km(vm(Ew)),capabilities:e.Capabilities,chainId:Qg(),from:Rm(Wg()),key:Rm(Im({prehash:am(),publicKey:Yg(),type:aw.shape.type}))}),e.Request=Im({method:Tm("wallet_prepareCalls"),params:Km(Om([e.Parameters]))}),e.Response=Im({capabilities:e.ResponseCapabilities,context:Im({preCall:Rm(Em(mw)),quote:Rm(Em(vw))}),digest:Yg(),key:Dm(Im({prehash:am(),publicKey:Yg(),type:aw.shape.type})),signature:Yg(),typedData:Im({domain:km([Im({chainId:km([Qg(),sm()]),name:nm(),verifyingContract:Wg(),version:nm()}),Im({})]),message:Sm(nm(),ym()),primaryType:nm(),types:Sm(nm(),ym())})})}(qw||(qw={})),function(e){e.Capabilities=Im({authorizeKeys:uw.Request}),e.Parameters=Im({address:Wg(),capabilities:e.Capabilities,chainId:Rm(sm()),delegation:Wg()}),e.Request=Im({method:Tm("wallet_prepareUpgradeAccount"),params:Km(Om([e.Parameters]))}),e.Response=Im({capabilities:e.Capabilities,chainId:Qg(),context:Im({address:Wg(),authorization:Pw,chainId:Qg(),preCall:hw}),digests:Im({auth:Yg(),exec:Yg()}),typedData:Im({domain:km([Im({chainId:km([Qg(),sm()]),name:nm(),verifyingContract:Wg(),version:nm()}),Im({})]),message:Sm(nm(),ym()),primaryType:nm(),types:Sm(nm(),ym())})})}(Lw||(Lw={})),function(e){e.Request=Im({method:Tm("wallet_feeTokens"),params:Rm(dm())}),e.Response=Sm(Yg(),Km(vm(Im({address:Wg(),decimals:sm(),nativeRate:Rm(Jg()),symbol:nm()}))))}(Fw||(Fw={})),function(e){e.Parameters=Im({capabilities:Rm(Im({feeSignature:Rm(Yg())})),context:Im({preCall:Rm(Em(mw)),quote:Rm(Em(vw))}),key:Rm(Im({prehash:am(),publicKey:Yg(),type:aw.shape.type})),signature:Yg()}),e.Request=Im({method:Tm("wallet_sendPreparedCalls"),params:Km(Om([e.Parameters]))}),e.Response=Im({id:Yg()})}(Kw||(Kw={})),function(e){e.Parameters=Im({context:Im({address:Wg(),authorization:Pw,chainId:Qg(),preCall:hw}),signatures:Im({auth:Yg(),exec:Yg()})}),e.Request=Im({method:Tm("wallet_upgradeAccount"),params:Km(Om([e.Parameters]))}),e.Response=dm()}(Vw||(Vw={})),function(e){e.Parameters=Im({address:Yg(),chainId:Qg(),digest:Yg(),signature:Yg()}),e.Request=Im({method:Tm("wallet_verifySignature"),params:Km(Om([e.Parameters]))}),e.Response=Im({proof:Dm(Im({account:Wg(),initPreCall:Dm(hw),keyHash:Yg()})),valid:am()})}(Gw||(Gw={}));class Xw extends ml{constructor(e){super("An error occurred while executing calls.",{cause:e,metaMessages:[e.abiError&&"Reason: "+e.abiError.name].filter(Boolean)}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Rpc.ExecutionError"}),Object.defineProperty(this,"abiError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiError=e.abiError}}function ev(e){return t=>{const n=e.public(t),r=e.relay(t);return tl({key:ev.type,name:"Relay Proxy",request:async({method:e,params:t},s)=>function(e){return!!e.startsWith("wallet_")||(!!e.startsWith("account_")||"health"===e)}(e)?r.request({method:e,params:t},s):n.request({method:e,params:t},s),type:ev.type})}}!function(e){e.type="relayProxy"}(ev||(ev={}));const tv=new Map;const nv=Im({chainId:Rm(Qg()),expiry:Qg(),hash:Yg(),id:Yg(),prehash:Rm(am()),publicKey:Yg(),role:km([Tm("admin"),Tm("session")]),type:km([Tm("address"),Tm("p256"),Tm("secp256k1"),Tm("webauthn-p256")])}),rv=Km(vm(Xg([Im({signature:nm(),to:Wg()}),Im({signature:nm()}),Im({to:Wg()})])).check(Jh(1))),sv=Im({limit:km([Gm([sm(),".",sm()]),Gm([sm()])]).check(Xh(/^\d+(\.\d+)?$/)),symbol:Rm(km([Tm("native"),Iw]))}),iv=Im({addresses:Km(vm(Wg()))}),av=Km(vm(Im({limit:Jg(),period:km([Tm("minute"),Tm("hour"),Tm("day"),Tm("week"),Tm("month"),Tm("year")]),token:Rm(Wg())}))),ov=Im({calls:Rm(rv),signatureVerification:Rm(iv),spend:Rm(av)}),cv=Im({...nv.shape,feeToken:Rm(Bm(sv)),permissions:Rm(ov)}),uv=Im({address:Wg(),chainId:Rm(Qg()),expiry:sm(),id:Yg(),key:Pm(nv,{publicKey:!0,type:!0}),permissions:Im({calls:rv,signatureVerification:Rm(iv),spend:Rm(av)})}),dv=Im({address:Rm(Wg()),chainId:Rm(Qg()),expiry:sm().check((lv=1,new fh({check:"greater_than",...Dp(fv),value:lv,inclusive:!0}))),feeToken:Bm(sv),key:Rm(Pm(nv,{publicKey:!0,type:!0})),permissions:Im({calls:rv,signatureVerification:Rm(iv),spend:Rm(av)})});var lv,fv;const pv=uv;function hv(e,t){const{chainId:n,expiry:r,permissions:s,id:i,publicKey:a,type:o}=e,{address:c}=t;return{address:c,chainId:n,expiry:r,id:i,key:{publicKey:a,type:o},permissions:s??{}}}function mv(e){const{chainId:t,expiry:n,key:r}=e;return Mg({chainId:t,expiry:n,permissions:e.permissions??{},publicKey:r.publicKey,role:"session",type:r.type})}var yv,bv,gv,wv,vv,xv,Iv,Pv,zv,Ev;!function(e){e.GetCapabilitiesResponse=Im({status:km([Tm("supported"),Tm("unsupported")])})}(yv||(yv={})),function(e){e.Request=km([am(),Im({chainId:Rm(Qg()),label:Rm(nm())})])}(bv||(bv={})),function(e){e.Request=Xg([Im({chainId:Rm(sm()),domain:Rm(nm()),expirationTime:Rm(gm()),issuedAt:Rm(gm()),nonce:nm(),notBefore:Rm(gm()),requestId:Rm(nm()),resources:Rm(Km(vm(nm()))),scheme:Rm(nm()),statement:Rm(nm()),uri:Rm(nm()),version:Rm(Tm("1"))}),Im({authUrl:km([nm(),Im({logout:nm(),nonce:nm(),verify:nm()})]),chainId:Rm(Qg()),domain:Rm(nm()),expirationTime:Rm(gm()),issuedAt:Rm(gm()),notBefore:Rm(gm()),requestId:Rm(nm()),resources:Rm(Km(vm(nm()))),scheme:Rm(nm()),statement:Rm(nm()),uri:Rm(nm()),version:Rm(Tm("1"))})]),e.Response=Im({message:nm(),signature:Yg(),token:Rm(nm())})}(gv||(gv={})),function(e){e.GetCapabilitiesResponse=Im({supported:am(),tokens:Km(vm(xw))}),e.Request=km([Iw,Wg()])}(wv||(wv={})),function(e){e.Request=dv}(vv||(vv={})),function(e){e.GetCapabilitiesResponse=Im({supported:am()})}(xv||(xv={})),function(e){e.GetCapabilitiesResponse=Im({supported:am()}),e.Request=Im({id:Rm(km([Yg(),fm()]))}),e.Response=Km(vm(uv))}(Iv||(Iv={})),function(e){e.Request=Km(vm(Im({context:ym(),signature:Yg()}))),e.Response=e.Request}(Pv||(Pv={})),function(e){e.Request=nm()}(zv||(zv={})),function(e){e.GetCapabilitiesResponse=Im({supported:am(),tokens:Km(vm(xw))}),e.Request=Km(vm(Xg([Im({address:Wg(),value:Jg()}),Im({symbol:Iw,value:km([Gm([sm(),".",sm()]),Gm([sm()])]).check(Xh(/^\d+(\.\d+)?$/))})])))}(Ev||(Ev={}));const Av=Im({...Pm(nv,{id:!0,publicKey:!0,type:!0}).shape,credentialId:Rm(nm()),privateKey:Rm(hm())});var kv,Mv,$v,Ov,jv,Sv,Nv,Tv,_v,Rv,Cv,Bv,Dv,Uv,qv,Lv,Fv,Kv,Vv,Gv,Zv,Hv,Wv,Yv,Qv,Jv,Xv,ex,tx,nx,rx,sx,ix,ax,ox;!function(e){e.Parameters=Im({address:Wg(),secret:nm()}),e.Request=Im({method:Tm("account_getOnrampContactInfo"),params:Km(Om([e.Parameters]))}),e.Response=Im({email:Rm(nm()),phone:Rm(nm()),phoneVerifiedAt:Rm(sm())})}(kv||(kv={})),function(e){e.Parameters=Im({address:Wg()}),e.Request=Im({method:Tm("account_onrampStatus"),params:Km(Om([e.Parameters]))}),e.Response=Im({email:Rm(sm()),phone:Rm(sm())})}(Mv||(Mv={})),function(e){e.Parameters=Im({email:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_resendVerifyPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}($v||($v={})),function(e){e.Parameters=Im({email:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_setEmail"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Ov||(Ov={})),function(e){e.Parameters=Im({email:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_setPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(jv||(jv={})),function(e){e.Parameters=Im({chainId:Qg(),email:nm(),token:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_verifyEmail"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Sv||(Sv={})),function(e){e.Parameters=Im({code:nm(),phone:nm(),walletAddress:Wg()}),e.Request=Im({method:Tm("account_verifyPhone"),params:Km(Om([e.Parameters]))}),e.Response=fm()}(Nv||(Nv={})),function(e){e.Parameters=Im({address:Rm(Wg()),chainId:Rm(Qg()),token:Rm(Wg()),value:Rm(nm())}),e.Request=Im({method:Tm("wallet_addFunds"),params:Km(Om([e.Parameters]))}),e.Response=Im({id:Yg()})}(Tv||(Tv={})),function(e){e.Request=Im({method:Tm("eth_accounts"),params:Rm(ym())}),e.Response=Km(vm(Wg()))}(_v||(_v={})),function(e){e.Request=Im({method:Tm("eth_chainId"),params:Rm(ym())}),e.Response=Yg()}(Rv||(Rv={})),function(e){e.Request=Im({method:Tm("eth_requestAccounts"),params:Rm(ym())}),e.Response=Km(vm(Wg()))}(Cv||(Cv={})),function(e){e.Request=Im({method:Tm("eth_sendTransaction"),params:Km(Om([Im({capabilities:Rm(Im({feeToken:Rm(wv.Request),merchantUrl:Rm(zv.Request),preCalls:Rm(Pv.Request)})),chainId:Rm(Qg()),data:Rm(Yg()),from:Rm(Wg()),to:Wg(),value:Rm(Jg())})]))}),e.Response=Yg()}(Bv||(Bv={})),function(e){e.Request=Im({method:Tm("eth_signTypedData_v4"),params:Km(Om([Wg(),nm()]))}),e.Response=Yg()}(Dv||(Dv={})),function(e){e.Parameters=Im({address:Rm(Wg()),chainId:Rm(Qg())}),e.Request=Im({method:Tm("wallet_getAdmins"),params:Rm(Km(Om([e.Parameters])))}),e.Key=Av,e.Response=Im({address:Wg(),chainId:Qg(),keys:Km(vm(e.Key))})}(Uv||(Uv={})),function(e){e.Capabilities=Im({feeToken:Rm(wv.Request)}),e.Parameters=Im({address:Rm(Wg()),capabilities:Rm(e.Capabilities),chainId:Rm(Qg()),key:Pm(nv,{publicKey:!0,type:!0})}),e.Request=Im({method:Tm("wallet_grantAdmin"),params:Km(Om([e.Parameters]))}),e.Response=Im({address:Wg(),chainId:Qg(),key:Uv.Key})}(qv||(qv={})),function(e){e.Parameters=dv,e.Request=Im({method:Tm("wallet_grantPermissions"),params:Km(Om([e.Parameters]))}),e.ResponseCapabilities=Im({preCalls:Rm(Pv.Response)}),e.Response=Im({...uv.shape,capabilities:Rm(hm())})}(Lv||(Lv={})),function(e){e.Parameters=Im({address:Rm(Wg())}),e.Request=Im({method:Tm("wallet_getAccountVersion"),params:Rm(Km(Om([e.Parameters])))}),e.Response=Im({current:nm(),latest:nm()})}(Fv||(Fv={})),function(e){e.Parameters=Im({address:Rm(Wg()),chainIds:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_getPermissions"),params:Rm(Km(Om([e.Parameters])))}),e.Response=Iv.Response}(Kv||(Kv={})),function(e){e.Capabilities=Im({feeToken:Rm(wv.Request)}),e.Parameters=Im({address:Rm(Wg()),capabilities:Rm(e.Capabilities),chainId:Rm(Qg()),id:Yg()}),e.Request=Im({method:Tm("wallet_revokeAdmin"),params:Km(Om([e.Parameters]))}),e.Response=void 0}(Vv||(Vv={})),function(e){e.Capabilities=Im({feeToken:Rm(wv.Request)}),e.Parameters=Im({address:Rm(Wg()),capabilities:Rm(e.Capabilities),id:Yg()}),e.Request=Im({method:Tm("wallet_revokePermissions"),params:Km(Om([e.Parameters]))}),e.Response=void 0}(Gv||(Gv={})),function(e){e.Request=Im({method:Tm("wallet_switchEthereumChain"),params:Km(Om([Im({chainId:Yg()})]))})}(Zv||(Zv={})),function(e){e.Parameters=Im({context:ym(),signatures:Im({auth:Yg(),exec:Yg()})}),e.Request=Im({method:Tm("wallet_upgradeAccount"),params:Km(Om([e.Parameters]))}),e.ResponseCapabilities=Im({admins:Rm(Km(vm(Uv.Key))),permissions:Rm(Iv.Response)}),e.Response=Im({address:Wg(),capabilities:Rm(e.ResponseCapabilities)})}(Hv||(Hv={})),function(e){e.Request=Im({method:Tm("personal_sign"),params:Km(Om([Yg(),Wg()]))}),e.Response=Yg()}(Wv||(Wv={})),function(e){e.Request=Im({method:Tm("porto_ping"),params:Rm(dm())}),e.Response=Tm("pong")}(Yv||(Yv={})),function(e){e.Capabilities=Im({createAccount:Rm(bv.Request),email:Rm(am()),grantAdmins:Rm(Km(vm(Pm(nv,{publicKey:!0,type:!0})))),grantPermissions:Rm(vv.Request),preCalls:Rm(Pv.Request),selectAccount:Rm(km([am(),Im({address:Wg(),key:Rm(Im({credentialId:Rm(nm()),publicKey:Yg()}))})])),signInWithEthereum:Rm(gv.Request)}),e.Parameters=Im({capabilities:Rm(e.Capabilities),chainIds:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_connect"),params:Rm(Km(Om([e.Parameters])))}),e.ResponseCapabilities=Im({admins:Rm(Km(vm(Im({...Pm(nv,{id:!0,publicKey:!0,type:!0}).shape,credentialId:Rm(nm())})))),permissions:Rm(Iv.Response),preCalls:Rm(Pv.Response),signInWithEthereum:Rm(gv.Response)}),e.Response=Im({accounts:Km(vm(Im({address:Wg(),capabilities:Rm(e.ResponseCapabilities)}))),chainIds:Km(vm(Qg()))})}(Qv||(Qv={})),function(e){e.Request=Im({method:Tm("wallet_disconnect"),params:Rm(ym())}),e.Response=void 0}(Jv||(Jv={})),function(e){e.Parameters=Bw.Parameters,e.Request=Bw.Request,e.Response=Bw.Response}(Xv||(Xv={})),function(e){e.Request=Im({method:Tm("wallet_getCallsStatus"),params:Om([Yg()])}),e.Response=Im({atomic:am(),chainId:Qg(),id:nm(),receipts:Rm(Km(vm(Im({blockHash:Yg(),blockNumber:Yg(),gasUsed:Yg(),logs:Km(vm(Im({address:Wg(),data:Yg(),topics:Km(vm(Yg()))}))),status:Yg(),transactionHash:Yg()})))),status:sm(),version:nm()})}(ex||(ex={})),function(e){e.Request=Im({method:Tm("wallet_getCapabilities"),params:Rm(km([Km(Om([km([Yg(),dm()])])),Km(Om([km([Yg(),dm()]),Km(vm(Qg()))]))]))}),e.Response=Sm(Yg(),Im({atomic:yv.GetCapabilitiesResponse,feeToken:wv.GetCapabilitiesResponse,merchant:xv.GetCapabilitiesResponse,permissions:Iv.GetCapabilitiesResponse,requiredFunds:Ev.GetCapabilitiesResponse}))}(tx||(tx={})),function(e){e.Parameters=Im({address:Wg(),chainIds:Rm(Km(vm(Qg())))}),e.Request=Im({method:Tm("wallet_getKeys"),params:Km(Om([e.Parameters]))}),e.Response=Km(vm(cv))}(nx||(nx={})),function(e){e.Capabilities=Im({feeToken:Rm(wv.Request),merchantUrl:Rm(zv.Request),permissions:Rm(Iv.Request),preCalls:Rm(Pv.Request),requiredFunds:Rm(Ev.Request)}),e.Parameters=Im({calls:Km(vm(Im({data:Rm(Yg()),to:Wg(),value:Rm(Jg())}))),capabilities:Rm(e.Capabilities),chainId:Rm(Qg()),from:Rm(Wg()),key:Rm(Pm(nv,{prehash:!0,publicKey:!0,type:!0})),version:Rm(nm())}),e.Request=Im({method:Tm("wallet_prepareCalls"),params:Km(Om([e.Parameters]))}),e.Response=Im({capabilities:Rm(Im({...qw.ResponseCapabilities.shape,quote:Rm(vw)})),chainId:Yg(),context:Im({account:Im({address:Wg()}),calls:e.Parameters.shape.calls,nonce:Jg(),quote:Rm(Em(vw))}),digest:Yg(),key:Pm(nv,{prehash:!0,publicKey:!0,type:!0}),typedData:Im({domain:km([Im({chainId:Qg(),name:nm(),verifyingContract:Wg(),version:nm()}),Im({})]),message:Sm(nm(),ym()),primaryType:nm(),types:Sm(nm(),ym())})})}(rx||(rx={})),function(e){e.Capabilities=Im({...Qv.Capabilities.shape,label:Rm(nm())}),e.Parameters=Im({address:Wg(),capabilities:Rm(e.Capabilities),chainId:Rm(Qg())}),e.Request=Im({method:Tm("wallet_prepareUpgradeAccount"),params:Km(Om([e.Parameters]))}),e.Response=Im({context:ym(),digests:Im({auth:Yg(),exec:Yg()})})}(sx||(sx={})),function(e){e.Capabilities=rx.Capabilities,e.Request=Im({method:Tm("wallet_sendCalls"),params:Km(Om([zm(rx.Parameters,{key:!0})]))}),e.Response=Im({id:Yg()})}(ix||(ix={})),function(e){e.Parameters=Im({capabilities:rx.Response.shape.capabilities,chainId:Yg(),context:rx.Response.shape.context,key:rx.Response.shape.key,signature:Yg()}),e.Request=Im({method:Tm("wallet_sendPreparedCalls"),params:Km(Om([e.Parameters]))}),e.Response=Km(vm(Im({capabilities:Rm(Sm(nm(),ym())),id:Yg()})))}(ax||(ax={})),function(e){e.Parameters=Im({address:Wg(),chainId:Rm(Qg()),digest:Yg(),signature:Yg()}),e.Request=Im({method:Tm("wallet_verifySignature"),params:Km(Om([e.Parameters]))}),e.Response=Im({address:Wg(),chainId:Qg(),proof:Rm(ym()),valid:am()})}(ox||(ox={}));const cx=function(e,t,n){return new Mm({type:"union",options:t,discriminator:e,...Dp(n)})}("method",[Sv.Request,Tv.Request,_v.Request,Rv.Request,Cv.Request,Bv.Request,Dv.Request,Fv.Request,Uv.Request,Kv.Request,qv.Request,Lv.Request,sx.Request,Vv.Request,Gv.Request,Hv.Request,Wv.Request,Yv.Request,Qv.Request,Jv.Request,Xv.Request,ex.Request,tx.Request,nx.Request,rx.Request,ix.Request,ax.Request,Zv.Request,ox.Request]);function ux(e,t){const n=Jp(e,t);if(n.error){const e=n.error.issues.at(0);if("invalid_union"===e?.code&&"No matching discriminator"===e.note)throw new Pl;throw new Ml(tw(n.error))}return{...t,_decoded:n.data}}async function dx(e){e.persist.hasHydrated()||await new Promise((t=>{e.persist.onFinishHydration((()=>t(!0))),setTimeout((()=>t(!0)),100)}))}function lx(e){if(e)return e.startsWith("/")?`${window.location.origin}${e}`:e}function fx(t){const{config:n,getMode:r,id:s,store:i}=t,{announceProvider:a}=n;function o(e={}){const t=c(),a=e.request??ux(cx,{method:"wallet_getCapabilities",params:e.chainIds?[void 0,e.chainIds]:void 0});return Da((()=>r().actions.getCapabilities({chainIds:e.chainIds,internal:{client:t,config:n,request:a,store:i}})),{cacheKey:`getCapabilities.${s}.${e.chainIds?.join(",")}`})}function c(e){const n="string"==typeof e?Sf(e):e;return function(e,t={}){const{config:n,id:r,store:s}=e._internal,{chains:i,relay:a}=n,o=s.getState(),c=t.chainId??o.chainIds[0],u=i.find((e=>e.id===c));if(!u)throw new Error(["Could not find a compatible Porto chain on the given chain configuration.","",`Provided chains: [${i.map((e=>`${e.name} (id: ${e.id})`)).join(", ")}]`,`Needed chain (id): ${c}`,"Please add this chain (id) to your chain configuration."].join("\n"));const d=ev({public:n.transports[u.id]??nl(u.rpcUrls.default.http.map((e=>il(e)))),relay:a}),l=[r,hl(u)].filter(Boolean).join(":");if(tv.has(l))return tv.get(l);const f=Xa({...t,chain:u,pollingInterval:1e3,transport:d});return tv.set(l,f),f}({_internal:t},{chainId:n})}const u=new Map,d=[],l=function(){const t=new e;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}(),f=Vl({...l,async request(e){await dx(i);return ef((async()=>{let t;try{t=ux(cx,e)}catch(t){if(!(t instanceof Pl))throw t;if(e.method.startsWith("wallet_"))throw new Tl;return c().request(e)}const s=i.getState();switch(t.method){case"account_verifyEmail":{if(0===s.accounts.length)throw new _l;const[e]=t._decoded.params,{chainId:a,email:o,token:u,walletAddress:d}=e,l=c(a);if(a&&a!==l.chain.id)throw new Rl;const f=d?s.accounts.find((e=>gp(e.address,d))):s.accounts[0];if(!f)throw new Nl;return await r().actions.verifyEmail({account:f,chainId:a,email:o,internal:{client:l,config:n,request:t,store:i},token:u,walletAddress:d})}case"wallet_addFunds":{if(0===s.accounts.length)throw new _l;const{address:e,value:a,token:o}=t.params[0]??{},u=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!u)throw new Nl;const d=c(),f=await r().actions.addFunds({address:u.address,internal:{client:d,config:n,request:t,store:i},token:o,value:a});return l.emit("message",{data:null,type:"assetsChanged"}),f}case"eth_accounts":if(0===s.accounts.length)throw new _l;return s.accounts.map(yx);case"eth_chainId":return zf(s.chainIds[0]);case"eth_requestAccounts":{if(s.accounts.length>0&&u.get("eth_requestAccounts"))return s.accounts.map(yx);const e=c(),{accounts:a}=await r().actions.loadAccounts({internal:{client:e,config:n,request:t,store:i}});return i.setState((e=>({...e,accounts:a}))),l.emit("connect",{chainId:zf(e.chain.id)}),u.set("eth_requestAccounts",!0),setTimeout((()=>u.delete("eth_requestAccounts")),1e3),a.map(yx)}case"eth_sendTransaction":{if(0===s.accounts.length)throw new _l;const[{capabilities:e,chainId:a,data:o="0x",from:u,to:d,value:l}]=t._decoded.params,f=c(a);if(a&&a!==f.chain.id)throw new Rl;const p=u?s.accounts.find((e=>gp(e.address,u))):s.accounts[0];if(!p)throw new Nl;const{id:h}=await r().actions.sendCalls({account:p,asTxHash:!0,calls:[{data:o,to:d,value:l}],internal:{client:f,config:n,request:t,store:i},merchantUrl:lx(n.merchantUrl??e?.merchantUrl)});return h}case"eth_signTypedData_v4":{if(0===s.accounts.length)throw new _l;const[e,a]=t._decoded.params,o=s.accounts.find((t=>gp(t.address,e)));if(!o)throw new Nl;const u=c();return await r().actions.signTypedData({account:o,data:a,internal:{client:u,config:n,request:t,store:i}})}case"wallet_grantAdmin":{if(0===s.accounts.length)throw new _l;const[{address:e,capabilities:a,chainId:o,key:u}]=t._decoded.params??[{}],d=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!d)throw new Nl;const f=c(o),p=hx([...d.keys??[]])?.some((e=>e.publicKey?.toLowerCase()===u.publicKey.toLowerCase()));if(p)throw new Ml({message:"Key already granted as admin."});const{key:h}=await r().actions.grantAdmin({account:d,feeToken:a?.feeToken,internal:{client:f,config:n,request:t,store:i},key:u});i.setState((e=>{const t=e.accounts.findIndex((e=>!d||gp(e.address,d.address)));return-1===t?e:{...e,accounts:e.accounts.map(((e,n)=>n===t?{...e,keys:[...e.keys??[],h]}:e))}}));const m=hx([...d.keys??[],h]);return l.emit("message",{data:null,type:"adminsChanged"}),nh(qv.Response,{address:d.address,chainId:f.chain.id,key:m.at(-1)})}case"wallet_grantPermissions":{if(0===s.accounts.length)throw new _l;const[{address:e,chainId:a,...o}]=t._decoded.params??[{}],u=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!u)throw new Nl;const d=c(a),{key:f}=await r().actions.grantPermissions({account:u,internal:{client:d,config:n,request:t,store:i},permissions:o});return i.setState((e=>{const t=e.accounts.findIndex((e=>!u||gp(e.address,u.address)));return-1===t?e:{...e,accounts:e.accounts.map(((e,n)=>n===t?{...e,keys:[...e.keys??[],f]}:e))}})),l.emit("message",{data:null,type:"permissionsChanged"}),nh(Lv.Response,{...hv(f,{address:u.address})})}case"wallet_getAdmins":{if(0===s.accounts.length)throw new _l;const[{address:e,chainId:a}]=t._decoded.params??[{}],o=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!o)throw new Nl;const u=c(a),d=hx(await r().actions.getKeys({account:o,internal:{client:u,config:n,request:t,store:i}}));return nh(Uv.Response,{address:o.address,chainId:u.chain.id,keys:d})}case"wallet_prepareUpgradeAccount":{const[{address:e,capabilities:s,chainId:a}]=t._decoded.params??[{}],{email:o,label:u,grantPermissions:l}=s??{},f=c(a),{context:p,digests:h}=await r().actions.prepareUpgradeAccount({address:e,email:o,internal:{client:f,config:n,request:t,store:i},label:u,permissions:l});return d.push(p.account),{context:p,digests:h}}case"wallet_getAccountVersion":{if(0===s.accounts.length)throw new _l;const[{address:e}]=t._decoded.params??[{}],a=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!a)throw new Nl;const o=c(),{current:u,latest:d}=await r().actions.getAccountVersion({address:a.address,internal:{client:o,config:n,request:t,store:i}});return{current:u,latest:d}}case"wallet_getKeys":{if(0===s.accounts.length)throw new _l;const[{address:e,chainIds:a}]=t._decoded.params??[{}],o=s.accounts.find((t=>gp(t.address,e)));if(!o)throw new Nl;const u=c(),d=await r().actions.getKeys({account:o,chainIds:a,internal:{client:u,config:n,request:t,store:i}});return nh(nx.Response,d)}case"wallet_getPermissions":{if(0===s.accounts.length)throw new _l;const[{address:e,chainIds:a}]=t._decoded.params??[{}],o=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!o)throw new Nl;const u=c();return mx(await r().actions.getKeys({account:o,chainIds:a,internal:{client:u,config:n,request:t,store:i}}),{address:o.address})}case"wallet_revokeAdmin":{if(0===s.accounts.length)throw new _l;const[{address:e,capabilities:a,id:o}]=t._decoded.params,u=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!u)throw new Nl;const d=c();await r().actions.revokeAdmin({account:u,feeToken:a?.feeToken,id:o,internal:{client:d,config:n,request:t,store:i}});const f=u.keys?.filter((e=>e.id.toLowerCase()!==o.toLowerCase()));return i.setState((e=>({...e,accounts:e.accounts.map((e=>gp(e.address,u.address)?{...e,keys:f}:e))}))),void l.emit("message",{data:null,type:"adminsChanged"})}case"wallet_revokePermissions":{if(0===s.accounts.length)throw new _l;const[{address:e,capabilities:a,id:o}]=t._decoded.params,u=e?s.accounts.find((t=>gp(t.address,e))):s.accounts[0];if(!u)throw new Nl;const d=c();await r().actions.revokePermissions({account:u,feeToken:a?.feeToken,id:o,internal:{client:d,config:n,request:t,store:i}});const f=u.keys?.filter((e=>e.id.toLowerCase()!==o.toLowerCase()));return i.setState((e=>({...e,accounts:e.accounts.map((e=>gp(e.address,u.address)?{...e,keys:f}:e))}))),void l.emit("message",{data:null,type:"permissionsChanged"})}case"wallet_upgradeAccount":{const[{context:e,signatures:s}]=t._decoded.params??[{}],a=c(),o=d.find((t=>gp(t.address,e.account.address)));if(!o)throw new Nl;const{account:u}=await r().actions.upgradeAccount({account:o,context:e,internal:{client:a,config:n,request:t,store:i},signatures:s}),f=hx(u.keys??[]),p=mx(u.keys??[],{address:u.address});return i.setState((e=>({...e,accounts:[u]}))),l.emit("connect",{chainId:zf(a.chain.id)}),{address:u.address,capabilities:{admins:f,...p.length>0?{permissions:p}:{}}}}case"porto_ping":return"pong";case"personal_sign":{if(0===s.accounts.length)throw new _l;const[e,a]=t._decoded.params,o=s.accounts.find((e=>gp(e.address,a)));if(!o)throw new Nl;const u=c();return await r().actions.signPersonalMessage({account:o,data:e,internal:{client:u,config:n,request:t,store:i}})}case"wallet_connect":{const[{capabilities:e,chainIds:a}]=t._decoded.params??[{}],o=c(a?.[0]),u=o.chain.id,{createAccount:d,email:f,grantAdmins:p,grantPermissions:h,selectAccount:m,signInWithEthereum:y}=e??{},b={client:o,config:n,request:t,store:i},{accounts:g}=await(async()=>{if(f||d){const{label:e}="object"==typeof d?d:{},{account:t}=await r().actions.createAccount({admins:p,email:f,internal:b,label:e,permissions:h,signInWithEthereum:y});return{accounts:[t]}}const e=s.accounts[0],{address:t,key:n}=(()=>{if(m)return"object"==typeof m?m:{address:void 0,key:void 0};for(const t of e?.keys??[])if("webauthn-p256"===t.type&&"admin"===t.role)return{address:e?.address,key:{credentialId:t.credentialId??t.privateKey?.credential?.id,publicKey:t.publicKey}};return{address:void 0,key:void 0}})(),i={internal:b,permissions:h,signInWithEthereum:y};try{return await r().actions.loadAccounts({address:t,key:n,...i})}catch(e){if(e instanceof Sl)throw e;if(t&&n)return await r().actions.loadAccounts(i);throw e}})();i.setState((e=>({...e,accounts:g})));const w=[u,...i.getState().chainIds.filter((e=>e!==u))];return l.emit("connect",{chainId:zf(w[0])}),{accounts:g.map((e=>({address:yx(e),capabilities:{admins:e.keys?hx(e.keys):[],permissions:e.keys?mx(e.keys,{address:e.address}):[],...e.signInWithEthereum&&{signInWithEthereum:e.signInWithEthereum}}}))),chainIds:w.map((e=>zf(e)))}}case"wallet_disconnect":{const e=c();return await(r().actions.disconnect?.({internal:{client:e,config:n,request:t,store:i}})),i.setState((e=>({...e,accounts:[]}))),void l.emit("disconnect",new _l)}case"wallet_getAssets":{const[e]=t._decoded.params??[],{account:s,chainFilter:a,assetFilter:o,assetTypeFilter:u}=e,d=c(),l=await r().actions.getAssets({account:s,assetFilter:o,assetTypeFilter:u,chainFilter:a,internal:{client:d,config:n,request:t,store:i}}),f=Object.entries(l).reduce(((e,[t,n])=>(e[zf(Number(t))]=n,e)),{});return nh(Xv.Response,f)}case"wallet_getCallsStatus":{const[e]=t._decoded.params??[],s=c();return await r().actions.getCallsStatus({id:e,internal:{client:s,config:n,request:t,store:i}})}case"wallet_getCapabilities":{const[e,n]=t.params??[];return await o({chainIds:n,request:t})}case"wallet_prepareCalls":{const[e]=t._decoded.params,{calls:a,capabilities:o,chainId:u,key:d,from:l}=e,f=c(u),p=l??s.accounts[0];if(!p)throw new Nl;if(u&&u!==f.chain.id)throw new Rl;const{digest:h,...m}=await r().actions.prepareCalls({account:Cg(p),calls:a,feeToken:o?.feeToken,internal:{client:f,config:n,request:t,store:i},key:d,merchantUrl:lx(n.merchantUrl??o?.merchantUrl),requiredFunds:o?.requiredFunds});return nh(rx.Response,{capabilities:m.capabilities,chainId:zf(m.chainId??f.chain.id),context:{...m.context,account:{address:m.account.address},calls:m.context.calls??[],nonce:m.context.nonce??0n},digest:h,key:m.key,typedData:m.typedData})}case"wallet_sendPreparedCalls":{const[e]=t._decoded.params,{chainId:s,context:a,key:o,signature:u}=e,{account:d}=e.context,l=c(s);if(s&&Sf(s)!==l.chain.id)throw new Rl;return[{id:await r().actions.sendPreparedCalls({account:Cg(d),context:a,internal:{client:l,config:n,request:t,store:i},key:o,signature:u})}]}case"wallet_sendCalls":{if(0===s.accounts.length)throw new _l;const[e]=t._decoded.params,{calls:a,capabilities:o,chainId:u,from:d}=e,l=c(u);if(u&&u!==l.chain.id)throw new Rl;const f=d?s.accounts.find((e=>gp(e.address,d))):s.accounts[0];if(!f)throw new Nl;const{id:p}=await r().actions.sendCalls({account:f,calls:a,feeToken:o?.feeToken,internal:{client:l,config:n,request:t,store:i},merchantUrl:lx(n.merchantUrl??o?.merchantUrl),permissionsId:o?.permissions?.id,requiredFunds:o?.requiredFunds});return{id:p}}case"wallet_switchEthereumChain":{const[e]=t._decoded.params,{chainId:s}=e,a=Sf(s);if(!n.chains.find((e=>e.id===a)))throw new Dl;const o=c(s);return await(r().actions.switchChain?.({chainId:o.chain.id,internal:{client:o,config:n,request:t,store:i}})),void i.setState((e=>({...e,chainIds:[a,...e.chainIds.filter((e=>e!==a))]})))}case"wallet_verifySignature":{const[e]=t._decoded.params,{address:n,chainId:r,digest:s,signature:i}=e,a=c(r),o=await async function(e,t){const{address:n,chain:r=e.chain,digest:s,signature:i}=t;try{async function a(){return{proof:null,valid:await Xd(e,{address:n,hash:s,signature:i})}}const o="wallet_verifySignature",c=await(async()=>{const t=await e.request({method:o,params:[nh(Gw.Parameters,{address:n,chainId:r?.id,digest:s,signature:i})]},{retryCount:0}).catch(a);return t.valid?t:a()})();return sh(Gw.Response,c)}catch(u){throw Jw(u),u}}(a,{address:n,digest:s,signature:i});return{...o,address:n,chainId:zf(a.chain.id)}}}}),{enabled:["eth_accounts","eth_chainId","eth_requestAccounts","wallet_getAssets","wallet_getCapabilities","wallet_getKeys","wallet_getPermissions","wallet_getAccountVersion","wallet_connect"].includes(e.method),id:hl(e)})}});const p=function(){let e=()=>{},t=()=>{};dx(i).then((()=>{o().catch((()=>{})),e(),e=i.subscribe((e=>e.accounts),(e=>{l.emit("accountsChanged",e.map(yx))}),{equalityFn:(e,t)=>e.every(((e,n)=>e.address===t[n]?.address))}),t(),t=i.subscribe((e=>e.chainIds[0]),((e,t)=>{e!==t&&l.emit("chainChanged",zf(e))}))}));const n=px(f,a);return()=>{e(),t(),n()}}();return Object.assign(f,{_internal:{destroy:p}})}function px(e,t){if(!t)return()=>{};if("undefined"==typeof window||!window.dispatchEvent)return()=>{};const{icon:n="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDIyIiBoZWlnaHQ9IjQyMiIgdmlld0JveD0iMCAwIDQyMiA0MjIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSI0MjIiIGhlaWdodD0iNDIyIiBmaWxsPSJibGFjayIvPgo8ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfMV8xNSkiPgo8cGF0aCBkPSJNODEgMjg2LjM2NkM4MSAyODAuODkzIDg1LjQ1MDUgMjc2LjQ1NSA5MC45NDA0IDI3Ni40NTVIMzI5LjUxMUMzMzUuMDAxIDI3Ni40NTUgMzM5LjQ1MiAyODAuODkzIDMzOS40NTIgMjg2LjM2NlYzMDYuMTg4QzMzOS40NTIgMzExLjY2MiAzMzUuMDAxIDMxNi4wOTkgMzI5LjUxMSAzMTYuMDk5SDkwLjk0MDRDODUuNDUwNSAzMTYuMDk5IDgxIDMxMS42NjIgODEgMzA2LjE4OFYyODYuMzY2WiIgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC41Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuOTQwNCAyMzQuODI4Qzg1LjQ1MDUgMjM0LjgyOCA4MSAyMzkuMjY2IDgxIDI0NC43MzlWMjcxLjUzMUM4My44NDMyIDI2OS42MzMgODcuMjYyMiAyNjguNTI2IDkwLjk0MDQgMjY4LjUyNkgzMjkuNTExQzMzMy4xODggMjY4LjUyNiAzMzYuNjA4IDI2OS42MzMgMzM5LjQ1MiAyNzEuNTMxVjI0NC43MzlDMzM5LjQ1MiAyMzkuMjY2IDMzNS4wMDEgMjM0LjgyOCAzMjkuNTExIDIzNC44MjhIOTAuOTQwNFpNMzM5LjQ1MiAyODYuMzY2QzMzOS40NTIgMjgwLjg5MyAzMzUuMDAxIDI3Ni40NTUgMzI5LjUxMSAyNzYuNDU1SDkwLjk0MDRDODUuNDUwNSAyNzYuNDU1IDgxIDI4MC44OTMgODEgMjg2LjM2NlYzMDYuMTlDODEgMzExLjY2NCA4NS40NTA1IDMxNi4xMDEgOTAuOTQwNCAzMTYuMTAxSDMyOS41MTFDMzM1LjAwMSAzMTYuMTAxIDMzOS40NTIgMzExLjY2NCAzMzkuNDUyIDMwNi4xOVYyODYuMzY2WiIgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC41Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuOTQwNCAxOTMuMjAxQzg1LjQ1MDUgMTkzLjIwMSA4MSAxOTcuNjM4IDgxIDIwMy4xMTJWMjI5LjkwM0M4My44NDMyIDIyOC4wMDYgODcuMjYyMiAyMjYuODk5IDkwLjk0MDQgMjI2Ljg5OUgzMjkuNTExQzMzMy4xODggMjI2Ljg5OSAzMzYuNjA4IDIyOC4wMDYgMzM5LjQ1MiAyMjkuOTAzVjIwMy4xMTJDMzM5LjQ1MiAxOTcuNjM4IDMzNS4wMDEgMTkzLjIwMSAzMjkuNTExIDE5My4yMDFIOTAuOTQwNFpNMzM5LjQ1MiAyNDQuNzM5QzMzOS40NTIgMjM5LjI2NSAzMzUuMDAxIDIzNC44MjggMzI5LjUxMSAyMzQuODI4SDkwLjk0MDRDODUuNDUwNSAyMzQuODI4IDgxIDIzOS4yNjUgODEgMjQ0LjczOVYyNzEuNTNDODEuMjE3NSAyNzEuMzg1IDgxLjQzODMgMjcxLjI0NSA4MS42NjI0IDI3MS4xMDlDODMuODMyNSAyNjkuNzk0IDg2LjMwNTQgMjY4LjkyNyA4OC45NTIzIDI2OC42MzVDODkuNjA1MSAyNjguNTYzIDkwLjI2ODQgMjY4LjUyNiA5MC45NDA0IDI2OC41MjZIMzI5LjUxMUMzMzAuMTgzIDI2OC41MjYgMzMwLjg0NiAyNjguNTYzIDMzMS40OTggMjY4LjYzNUMzMzQuNDE5IDI2OC45NTcgMzM3LjEyOCAyNjkuOTggMzM5LjQ1MiAyNzEuNTNWMjQ0LjczOVpNMzM5LjQ1MiAyODYuMzY2QzMzOS40NTIgMjgxLjAyMSAzMzUuMjA2IDI3Ni42NjMgMzI5Ljg5MyAyNzYuNDYyQzMyOS43NjcgMjc2LjQ1NyAzMjkuNjQgMjc2LjQ1NSAzMjkuNTExIDI3Ni40NTVIOTAuOTQwNEM4NS40NTA1IDI3Ni40NTUgODEgMjgwLjg5MyA4MSAyODYuMzY2VjMwNi4xODhDODEgMzExLjY2MiA4NS40NTA1IDMxNi4xMDEgOTAuOTQwNCAzMTYuMTAxSDMyOS41MTFDMzM1LjAwMSAzMTYuMTAxIDMzOS40NTIgMzExLjY2MiAzMzkuNDUyIDMwNi4xODhWMjg2LjM2NloiIGZpbGw9IndoaXRlIiBmaWxsLW9wYWNpdHk9IjAuNSIvPgo8cGF0aCBvcGFjaXR5PSIwLjMiIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTguMDE0NiAxMDRDODguNjE3NyAxMDQgODEgMTExLjU5NSA4MSAxMjAuOTY1VjE4OC4yNzZDODMuODQzMiAxODYuMzc5IDg3LjI2MjIgMTg1LjI3MiA5MC45NDA0IDE4NS4yNzJIMzI5LjUxMUMzMzMuMTg4IDE4NS4yNzIgMzM2LjYwOCAxODYuMzc5IDMzOS40NTIgMTg4LjI3NlYxMjAuOTY1QzMzOS40NTIgMTExLjU5NSAzMzEuODMzIDEwNCAzMjIuNDM3IDEwNEg5OC4wMTQ2Wk0zMzkuNDUyIDIwMy4xMTJDMzM5LjQ1MiAxOTcuNjM4IDMzNS4wMDEgMTkzLjIwMSAzMjkuNTExIDE5My4yMDFIOTAuOTQwNEM4NS40NTA1IDE5My4yMDEgODEgMTk3LjYzOCA4MSAyMDMuMTEyVjIyOS45MDNDODEuMjE3NSAyMjkuNzU4IDgxLjQzODMgMjI5LjYxOCA4MS42NjI0IDIyOS40ODJDODMuODMyNSAyMjguMTY3IDg2LjMwNTQgMjI3LjMgODguOTUyMyAyMjcuMDA4Qzg5LjYwNTEgMjI2LjkzNiA5MC4yNjg0IDIyNi44OTkgOTAuOTQwNCAyMjYuODk5SDMyOS41MTFDMzMwLjE4MyAyMjYuODk5IDMzMC44NDYgMjI2LjkzNiAzMzEuNDk4IDIyNy4wMDhDMzM0LjQxOSAyMjcuMzMgMzM3LjEyOCAyMjguMzUyIDMzOS40NTIgMjI5LjkwM1YyMDMuMTEyWk0zMzkuNDUyIDI0NC43MzlDMzM5LjQ1MiAyMzkuMzkzIDMzNS4yMDYgMjM1LjAzNiAzMjkuODkzIDIzNC44MzVDMzI5Ljc2NyAyMzQuODMgMzI5LjY0IDIzNC44MjggMzI5LjUxMSAyMzQuODI4SDkwLjk0MDRDODUuNDUwNSAyMzQuODI4IDgxIDIzOS4yNjUgODEgMjQ0LjczOVYyNzEuNTNMODEuMDcwNyAyNzEuNDgzQzgxLjI2NTMgMjcxLjM1NSA4MS40NjI1IDI3MS4yMyA4MS42NjI0IDI3MS4xMDlDODEuOTA4MyAyNzAuOTYgODIuMTU4MSAyNzAuODE3IDgyLjQxMTcgMjcwLjY3OUM4NC4zOTUzIDI2OS42MDUgODYuNjA1NCAyNjguODk0IDg4Ljk1MjMgMjY4LjYzNUM4OS4wMDUyIDI2OC42MjkgODkuMDU4IDI2OC42MjQgODkuMTExIDI2OC42MThDODkuNzEyNSAyNjguNTU3IDkwLjMyMjggMjY4LjUyNiA5MC45NDA0IDI2OC41MjZIMzI5LjUxMUMzMjkuNzM4IDI2OC41MjYgMzI5Ljk2NSAyNjguNTMgMzMwLjE5MiAyNjguNTM5QzMzMC42MzEgMjY4LjU1NSAzMzEuMDY3IDI2OC41ODcgMzMxLjQ5OCAyNjguNjM1QzMzNC40MTkgMjY4Ljk1NyAzMzcuMTI4IDI2OS45OCAzMzkuNDUyIDI3MS41M1YyNDQuNzM5Wk0zMzkuNDUyIDI4Ni4zNjZDMzM5LjQ1MiAyODEuMDIxIDMzNS4yMDYgMjc2LjY2MyAzMjkuODkzIDI3Ni40NjJMMzI5Ljg2NSAyNzYuNDYxQzMyOS43NDggMjc2LjQ1NyAzMjkuNjI5IDI3Ni40NTUgMzI5LjUxMSAyNzYuNDU1SDkwLjk0MDRDODUuNDUwNSAyNzYuNDU1IDgxIDI4MC44OTMgODEgMjg2LjM2NlYzMDYuMTg4QzgxIDMxMS42NjIgODUuNDUwNSAzMTYuMTAxIDkwLjk0MDQgMzE2LjEwMUgzMjkuNTExQzMzNS4wMDEgMzE2LjEwMSAzMzkuNDUyIDMxMS42NjIgMzM5LjQ1MiAzMDYuMTg4VjI4Ni4zNjZaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNMjY5Ljg2OCAxMzEuNzUyQzI2OS44NjggMTI2LjI3OCAyNzQuMzE4IDEyMS44NCAyNzkuODA4IDEyMS44NEgzMTEuNjE4QzMxNy4xMDggMTIxLjg0IDMyMS41NTggMTI2LjI3OCAzMjEuNTU4IDEzMS43NTJWMTYxLjQ4NUMzMjEuNTU4IDE2Ni45NTkgMzE3LjEwOCAxNzEuMzk2IDMxMS42MTggMTcxLjM5NkgyNzkuODA4QzI3NC4zMTggMTcxLjM5NiAyNjkuODY4IDE2Ni45NTkgMjY5Ljg2OCAxNjEuNDg1VjEzMS43NTJaIiBmaWxsPSJ3aGl0ZSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzFfMTUiPgo8cmVjdCB3aWR0aD0iMjU5IiBoZWlnaHQ9IjIxMyIgZmlsbD0id2hpdGUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDgxIDEwNCkiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",name:r="Rise Wallet",rdns:s="com.risechain.wallet"}="object"==typeof t?t:{};return function(e){const t=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(e)});window.dispatchEvent(t);const n=()=>window.dispatchEvent(t);return window.addEventListener("eip6963:requestProvider",n),()=>window.removeEventListener("eip6963:requestProvider",n)}({info:{icon:n,name:r,rdns:s,uuid:Xl()},provider:e})}function hx(e){return e.map((e=>{if("admin"===e.role)try{return nh(Uv.Key,{id:e.id??e.publicKey,publicKey:e.publicKey,type:e.type,..."webauthn-p256"===e.type?{credentialId:e.privateKey?.credential?.id,privateKey:{credential:{id:e.privateKey?.credential?.id},rpId:e.privateKey?.rpId}}:{}})}catch{return}})).filter(Boolean)}function mx(e,{address:t}){return e.map((e=>{if(e.chainId&&"session"===e.role&&!(e.expiry>0&&e.expiry<BigInt(Math.floor(Date.now()/1e3))))try{return nh(pv,hv(e,{address:t}))}catch{return}})).filter(Boolean)}function yx(e){return Ht(e.address)}function bx(e){return{...e,setup:e.setup??(()=>()=>{})}}async function gx(e){const{account:t,calls:n,permissionsId:r}=e;if(void 0!==r){if(null===r)return;const e=t.keys?.find((e=>e.publicKey===r&&e.privateKey));if(!e)throw new Error(`permission (id: ${r}) does not exist.`);return e}const s=t.keys?.find((e=>{if(!e.privateKey)return!1;if("session"!==e.role)return!1;if(e.expiry<BigInt(Math.floor(Date.now()/1e3)))return!1;const t=n.every((t=>e.permissions?.calls?.some((e=>{if(e.to&&e.to!==t.to)return!1;if(e.signature){if(!t.data)return!1;const n=Mf(t.data,0,4);if(Nf(e.signature))return e.signature===n;if(Db(e.signature)!==n)return!1}return!0}))));return!!t})),i=t.keys?.find((e=>"admin"===e.role&&e.privateKey));return s??i}const wx=dv;function vx(e){const{expiry:t,feeToken:n,permissions:r,publicKey:s,type:i}=e;return{expiry:t,feeToken:n??null,key:{publicKey:s,type:i},permissions:r??{}}}async function xx(e,t={}){if(!e)return;const n={chainId:t.chainId??e.chainId,expiry:e.expiry??0,feeToken:e.feeToken,permissions:Tg(e,{feeTokens:t.feeTokens}),role:"session"};if(e?.key)return Mg({...n,publicKey:e.key.publicKey,type:e.key.type??"secp256k1"});if("function"==typeof globalThis.crypto?.subtle?.generateKey)try{return await kg(n)}catch(e){if(!function(e){if(!(e instanceof Error))return!1;const t=e.message?.toLowerCase()??"";return"TypeError"===e.name||"ReferenceError"===e.name||t.includes("subtle")||t.includes("generatekey")}(e))throw e}return zg(n)}const Ix=/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/,Px=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/,zx=/^localhost(:[0-9]{1,5})?$/,Ex=/^[a-zA-Z0-9]{8,}$/,Ax=/^([a-zA-Z][a-zA-Z0-9+-.]*)$/,kx=/^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/,Mx=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function $x(e){if(/[^a-z0-9:/?#[\]@!$&'()*+,;=.\-_~%]/i.test(e))return!1;if(/%[^0-9a-f]/i.test(e))return!1;if(/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))return!1;const t=function(e){return e.match(/(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}(e),n=t[1],r=t[2],s=t[3],i=t[4],a=t[5];if(!(n?.length&&s&&s.length>=0))return!1;if(r?.length){if(0!==s.length&&!/^\//.test(s))return!1}else if(/^\/\//.test(s))return!1;if(!/^[a-z][a-z0-9+\-.]*$/.test(n.toLowerCase()))return!1;let o="";return o+=`${n}:`,r?.length&&(o+=`//${r}`),o+=s,i?.length&&(o+=`?${i}`),a?.length&&(o+=`#${a}`),o}class Ox extends ml{constructor(e){const{field:t,metaMessages:n}=e;super(`Invalid Sign-In with Ethereum message field "${t}".`,{metaMessages:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Siwe.InvalidMessageFieldError"})}}async function jx(e){const{address:t,authUrl:n,message:r,signature:s}=e,{chainId:i}=function(e){const{scheme:t,statement:n,...r}=e.match(kx)?.groups??{},{chainId:s,expirationTime:i,issuedAt:a,notBefore:o,requestId:c,...u}=e.match(Mx)?.groups??{},d=e.split("Resources:")[1]?.split("\n- ").slice(1);return{...r,...u,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...a?{issuedAt:new Date(a)}:{},...o?{notBefore:new Date(o)}:{},...c?{requestId:c}:{},...d?{resources:d}:{},...t?{scheme:t}:{},...n?{statement:n}:{}}}(r);return await fetch(n.verify,{body:JSON.stringify({address:t,chainId:i,message:r,signature:s,walletAddress:t}),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST"}).then((e=>e.json()))}async function Sx(e,t,n){const{chainId:r=e.chain?.id,domain:s,uri:i,resources:a,version:o="1"}=t,{address:c}=n,u=t.authUrl?Nx(t.authUrl):void 0;if(!r)throw new Error("`chainId` is required.");if(!s)throw new Error("`domain` is required.");if(!t.nonce&&!u?.nonce)throw new Error("`nonce` or `authUrl.nonce` is required.");if(!i)throw new Error("`uri` is required.");const d=await(async()=>{if(t.nonce)return t.nonce;if(!u?.nonce)throw new Error("`nonce` or `authUrl.nonce` is required.");const e=await fetch(u.nonce,{body:JSON.stringify({address:c,chainId:r,walletAddress:c}),headers:{"Content-Type":"application/json"},method:"POST"}),n=await e.json().catch((()=>{}));if(!n?.nonce)throw new Error("`nonce` or `authUrl.nonce` is required.");return n.nonce})(),l=function(e){const{chainId:t,domain:n,expirationTime:r,issuedAt:s=new Date,nonce:i,notBefore:a,requestId:o,resources:c,scheme:u,uri:d,version:l}=e;{if(t!==Math.floor(t))throw new Ox({field:"chainId",metaMessages:["- Chain ID must be a EIP-155 chain ID.","- See https://eips.ethereum.org/EIPS/eip-155","",`Provided value: ${t}`]});if(!(Ix.test(n)||Px.test(n)||zx.test(n)))throw new Ox({field:"domain",metaMessages:["- Domain must be an RFC 3986 authority.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${n}`]});if(!Ex.test(i))throw new Ox({field:"nonce",metaMessages:["- Nonce must be at least 8 characters.","- Nonce must be alphanumeric.","",`Provided value: ${i}`]});if(!$x(d))throw new Ox({field:"uri",metaMessages:["- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${d}`]});if("1"!==l)throw new Ox({field:"version",metaMessages:["- Version must be '1'.","",`Provided value: ${l}`]});if(u&&!Ax.test(u))throw new Ox({field:"scheme",metaMessages:["- Scheme must be an RFC 3986 URI scheme.","- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1","",`Provided value: ${u}`]});const r=e.statement;if(r?.includes("\n"))throw new Ox({field:"statement",metaMessages:["- Statement must not include '\\n'.","",`Provided value: ${r}`]})}const f=yp(e.address,{checksum:!0}),p=`${u?`${u}://${n}`:n} wants you to sign in with your Ethereum account:\n${f}\n\n${e.statement?`${e.statement}\n`:""}`;let h=`URI: ${d}\nVersion: ${l}\nChain ID: ${t}\nNonce: ${i}\nIssued At: ${s.toISOString()}`;if(r&&(h+=`\nExpiration Time: ${r.toISOString()}`),a&&(h+=`\nNot Before: ${a.toISOString()}`),o&&(h+=`\nRequest ID: ${o}`),c){let e="\nResources:";for(const t of c){if(!$x(t))throw new Ox({field:"resources",metaMessages:["- Every resource must be a RFC 3986 URI.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${t}`]});e+=`\n- ${t}`}h+=e}return`${p}\n${h}`}({...t,address:n.address,chainId:r,domain:s,nonce:d,resources:a,uri:i,version:o});return l}function Nx(e,t=""){if(!e)return;const n=(()=>{if("string"==typeof e){const t=e.replace(/\/$/,"");return{logout:t+"/logout",nonce:t+"/nonce",verify:t+"/verify"}}return e})();return{logout:Tx(n.logout,t),nonce:Tx(n.nonce,t),verify:Tx(n.verify,t)}}function Tx(e,t){return t&&e.startsWith("/")?t+e:e}function _x(e){return np(function(e){const t=xf(e);return vf("0x19",Ef("Ethereum Signed Message:\n"+$f(t)),t)}(e))}function Rx(e,t){const{as:n}=t,r=Cx(e),s=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(ub);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(new Uint8Array(r.length));return r.encode(s),"Hex"===n?Pf(s.bytes):s.bytes}function Cx(e){return Array.isArray(e)?function(e){const t=e.reduce(((e,t)=>e+t.length),0),n=Bx(t);return{length:t<=55?1+t:1+n+t,encode(r){t<=55?r.pushByte(192+t):(r.pushByte(247+n),1===n?r.pushUint8(t):2===n?r.pushUint16(t):3===n?r.pushUint24(t):r.pushUint32(t));for(const{encode:t}of e)t(r)}}}(e.map((e=>Cx(e)))):function(e){const t="string"==typeof e?Ff(e):e,n=Bx(t.length),r=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length;return{length:r,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+n),1===n?e.pushUint8(t.length):2===n?e.pushUint16(t.length):3===n?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function Bx(e){if(e<=255)return 1;if(e<=65535)return 2;if(e<=16777215)return 3;if(e<=4294967295)return 4;throw new ml("Length is too large.")}function Dx(e){return function(e,t={}){const{presign:n}=t;return np(vf("0x05",function(e,t={}){const{as:n="Hex"}=t;return Rx(e,{as:n})}(function(e){const{address:t,chainId:n,nonce:r}=e,s=function(e){if(void 0!==e.r&&void 0!==e.s)return ny(e)}(e);return[n?zf(n):"0x",t,r?zf(r):"0x",...s?sy(s):[]]}(n?{address:e.address,chainId:e.chainId,nonce:e.nonce}:e))))}(e,{presign:!0})}async function Ux(e,t){const{account:n=e.account}=t,r=n?Cg(n):void 0;if(!r)throw new Error("account is required.");const{domain:{name:s,version:i}}=await async function(e,t){const{address:n,factory:r,factoryData:s}=t;try{const[t,i,a,o,c,u,d]=await G(e,ja,"readContract")({abi:to,address:n,functionName:"eip712Domain",factory:r,factoryData:s});return{domain:{name:i,version:a,chainId:Number(o),verifyingContract:c,salt:u},extensions:d,fields:t}}catch(e){const t=e;if("ContractFunctionExecutionError"===t.name&&"ContractFunctionZeroDataError"===t.cause.name)throw new eo({address:n});throw t}}(e,{address:r.address});if(!e.chain)throw new Error("client.chain is required");return{chainId:e.chain.id,name:s,verifyingContract:r.address,version:i}}async function qx(e,t){const{account:n=e.account,chainIds:r}=t,s=n?Cg(n):void 0;if(!s)throw new Error("account is required.");const i=await async function(e,t){const{address:n,chainIds:r}=t;try{const t="wallet_getKeys",s=await e.request({method:t,params:[nh(Uw.Parameters,{address:n,chainIds:r})]});return sh(Uw.Response,s)}catch(e){throw Jw(e),e}}(e,{address:s.address,chainIds:r});return Object.entries(i).flatMap((([e,t])=>t.map((t=>function(e,t){const{chainId:n}=t,{publicKey:r}=e,s=20===$f(r)||0n===jf(Mf(r,0,12)),i={};for(const t of e.permissions)"call"===t.type&&(i.calls??=[],i.calls.push({signature:t.selector,to:t.to===mg?void 0:t.to})),"spend"===t.type&&(i.spend??=[],i.spend.push({limit:t.limit,period:t.period,token:t.token}));return Mg({chainId:n,expiry:e.expiry,permissions:i,publicKey:e.publicKey,role:gg[e.role],type:s?"address":bg[e.type]})}(t,{chainId:Number(e)})))))}async function Lx(e,t){const{account:n=e.account,calls:r,chain:s=e.chain,feePayer:i,merchantUrl:a,nonce:o,preCalls:c,requiredFunds:u,revokeKeys:d}=t,l=n?Cg(n):void 0,f=t.key??(l?Dg(l,{role:"admin"}):void 0),p=t.authorizeKeys?.some((e=>"session"===e.role)),{contracts:h,fees:{tokens:m}}=await Zw(e,{chainId:s?.id}),y=p?h.orchestrator.address:void 0,b=(t.authorizeKeys??[]).map((e=>Ng(e,{feeTokens:m,orchestrator:y}))),g=t.feeToken?t.feeToken:f?.permissions?.spend?.[0]?.token,w="boolean"==typeof c&&c,v="object"==typeof c?c.map((({context:e,signature:t})=>({...e.preCall,signature:t}))):void 0,x={address:l?.address,calls:r??[],capabilities:{authorizeKeys:b,meta:{feePayer:i,feeToken:g,nonce:o},preCall:w,preCalls:v,requiredFunds:u,revokeKeys:d?.map((e=>({hash:e.hash})))},chain:s,key:f?Ng(f,{feeTokens:m}):void 0},I=await(async()=>{if(a){const t=Xa({chain:e.chain,transport:il(a)});return await Hw(t,x).catch((t=>(console.error(t),Hw(e,x))))}return await Hw(e,x)})(),{capabilities:P,context:z,digest:E,signature:A,typedData:k}=I;if(a){if(!await Ww(e,{response:I._raw,signature:A}))throw new Error(`cannot verify integrity of \`wallet_prepareCalls\` response from ${a}`)}return{capabilities:{...P,quote:z.quote},context:z,digest:E,key:f,typedData:k}}async function Fx(e,t){const{address:n,authorizeKeys:r,chain:s=e.chain}=t;if(!s)throw new Error("chain is required.");const{contracts:i,fees:{tokens:a}}=await Zw(e,{chainId:s.id}),o=t.delegation??i.accountProxy.address,c=r.some((e=>"session"===e.role))?i.orchestrator.address:void 0,u=r.map((e=>{const t="session"===e.role?e.permissions:{};return Ng({...e,permissions:t},{feeTokens:a,orchestrator:c})})),{capabilities:d,chainId:l,context:f,digests:p,typedData:h}=await async function(e,t){const{address:n,chain:r=e.chain,delegation:s,...i}=t;try{const t="wallet_prepareUpgradeAccount",a=await e.request({method:t,params:[nh(Lw.Parameters,Ql({address:n,capabilities:i,chainId:r?.id,delegation:s}))]},{retryCount:0});return sh(Lw.Response,a)}catch(e){throw Jw(e),Yw(e),e}}(e,{address:n,authorizeKeys:u,chain:s,delegation:o});return{capabilities:d,chainId:l,context:{...f,account:Cg({address:n,keys:r})},digests:p,typedData:h}}async function Kx(e,t){const{account:n=e.account,chain:r=e.chain,webAuthn:s}=t;if(!r)throw new Error("`chain` is required.");const i=n?Cg(n):void 0;if(!i)throw new Error("`account` is required.");const a=t.key??Dg(i,t);if(!a&&!i.sign)throw new Error("`key` or `account` with `sign` is required");const o=await Promise.all((t.preCalls??[]).map((async n=>{if(n.signature)return n;const{authorizeKeys:a,key:o,calls:c,revokeKeys:u}=n,{context:d,digest:l}=await Lx(e,{account:i,authorizeKeys:a,calls:c,chain:r,feeToken:t.feeToken,key:o,preCalls:!0,revokeKeys:u});return{context:d,signature:await Sg(o,{address:null,payload:l,webAuthn:s})}}))),{capabilities:c,context:u,digest:d}=await Lx(e,{...t,account:i,chain:r,key:a,preCalls:o}),l=await(async()=>a?await Sg(a,{address:null,payload:d,webAuthn:s,wrap:!1}):await i.sign({hash:d}))();return await Vx(e,{capabilities:c.feeSignature?{feeSignature:c.feeSignature}:void 0,context:u,key:a,signature:l})}async function Vx(e,t){const{capabilities:n,context:r,key:s,signature:i}=t;return await async function(e,t){const{capabilities:n,context:r,key:s,signature:i}=t;try{const t="wallet_sendPreparedCalls",a=await e.request({method:t,params:[nh(Kw.Parameters,{capabilities:n,context:{preCall:r.preCall,quote:r.quote},key:s?{prehash:s.prehash,publicKey:s.publicKey,type:s.type}:void 0,signature:i})]},{retryCount:0});return sh(Kw.Response,a)}catch(e){throw Jw(e),Yw(e),e}}(e,{capabilities:n,context:r,key:s?Ng(s):void 0,signature:i})}async function Gx(e,t){const{email:n,walletAddress:r}=t;return await async function(e,t){const{email:n,walletAddress:r}=t;try{const t="account_setEmail",s=await e.request({method:t,params:[nh($w.Parameters,{email:n,walletAddress:r})]},{retryCount:0});return sh($w.Response,s)}catch(e){throw Jw(e),Yw(e),e}}(e,{email:n,walletAddress:r})}async function Zx(e,t){if(t.account){const{account:n}=t,r=[...n.keys??[],...t.authorizeKeys??[]].filter(((e,t,n)=>n.findIndex((t=>t.id===e.id))===t)),{digests:s,...i}=await Fx(e,{...t,address:n.address,authorizeKeys:r}),a={auth:await n.sign({hash:s.auth}),exec:await n.sign({hash:s.exec})};return await Zx(e,{...i,signatures:a})}const{context:n,signatures:r}=t,s=Cg(n.account);return await async function(e,t){const{context:n,signatures:r}=t;try{const t="wallet_upgradeAccount";await e.request({method:t,params:[nh(Vw.Parameters,{context:n,signatures:r})]},{retryCount:0})}catch(e){throw Jw(e),Yw(e),e}}(e,{context:n,signatures:r}),s}async function Hx(e,t){const{chainId:n,email:r,signature:s,token:i,walletAddress:a}=t;return await async function(e,t){const{chainId:n,email:r,signature:s,token:i,walletAddress:a}=t;try{const t="account_verifyEmail",o=await e.request({method:t,params:[nh(jw.Parameters,{chainId:n,email:r,signature:s,token:i,walletAddress:a})]},{retryCount:0});return sh(jw.Response,o)}catch(e){throw Jw(e),Yw(e),e}}(e,{chainId:n,email:r,signature:s,token:i,walletAddress:a})}const Wx="0x8010801080108010801080108010801080108010801080108010801080108010",Yx=mb("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function Qx(e){const{data:t,signature:n}=e;!function(e){if("string"==typeof e){if(Mf(e,-32)!==Wx)throw new Jx(e)}else ey(e.authorization)}(e);const r=Hm({payload:Dx(e.authorization),signature:ny(e.authorization)}),s=pb(Yx,[{...e.authorization,delegation:e.authorization.address,chainId:BigInt(e.authorization.chainId)},e.to??r,t??"0x"]);return vf(n,s,zf($f(s),{size:32}),Wx)}class Jx extends ml{constructor(e){super(`Value \`${e}\` is an invalid ERC-8010 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc8010.InvalidWrappedSignatureError"})}}async function Xx(e,t){const{address:n}=t,{authorization:r,data:s,to:i}=await async function(e,t){try{const n="wallet_getAuthorization",r=await Da((()=>e.request({method:n,params:[nh(Rw.Parameters,t)]})),{cacheKey:`${e.uid}.${n}.${t.address}`});return sh(Rw.Response,r)}catch(e){throw Jw(e),e}}(e,{address:n});return Qx({authorization:{...r,nonce:BigInt(r.nonce),r:BigInt(r.r),s:BigInt(r.s)},data:s,signature:t.signature,to:i})}function eI(e,t){const{tokens:n}=t,r=n.filter((e=>e.interop));return e.map((e=>{if(e.address)return e;const t=r.find((t=>t.symbol===e.symbol));if(!t)throw new Error(`interop token not found: ${e.symbol}`);return{address:t.address,value:tg(e.value,t.decimals)}}))}async function tI(e,t){const{chain:n=e.chain}=t??{};return await Zw(e,{chainId:n?.id}).then((e=>e.fees.tokens))}async function nI(e,t){const{addressOrSymbol:n}=t;return(await tI(e,t)).find(nI.predicate(n))}async function rI(e,t){const{chain:n=e.chain,store:r}=t??{},s=r?.getState()??{},i=t?.addressOrSymbol??s.feeToken,a=await tI(e,{chain:n}).then((e=>e.filter((e=>e.feeToken)))),o=a?.find((e=>!!i&&("native"===i&&e.address===Wd||(!(!wp(i)||!gp(e.address,i))||i===e.symbol))));return o}function sI(e={}){const t=e,{mock:n,multichain:r=!0,webAuthn:s}=t;let i,a;const o=(()=>{if("self"!==t.keystoreHost&&("undefined"==typeof window||"localhost"!==window.location?.hostname))return t.keystoreHost})();return bx({actions:{async addFunds(){throw new Tl},async createAccount(e){const{admins:t,email:r,label:a,permissions:c,internal:u,signInWithEthereum:d}=e,{client:l}=u,f=Bg(function(e={}){const{as:t="Hex"}=e,n=ud.utils.randomPrivateKey();return"Hex"===t?Pf(n):n}()),p=await tI(l),h=n?Ag():await Eg({createFn:s?.createFn,label:a||`${f.address.slice(0,8)}…${f.address.slice(-6)}`,rpId:o,userId:qf(f.address)}),m=await xx(c,{chainId:l.chain.id,feeTokens:p}),y=t?.map((e=>Mg(e))),b=await Zx(l,{account:f,authorizeKeys:[h,...y??[],...m?[m]:[]]});i=f.address,r&&a&&await Gx(l,{email:a,walletAddress:b.address});const g=await(async()=>{if(!d)return;const e=await Sx(l,d,{address:b.address}),t=await Ug(f,{payload:_x(Ef(e))});return{message:e,signature:await Xx(l,{address:b.address,signature:t})}})();return{account:{...b,signInWithEthereum:g}}},async getAccountVersion(e){const{address:t,internal:n}=e,{client:r}=n,{contracts:s}=await Zw(r),{accountImplementation:i}=s,a=await Ux(r,{account:Cg(i)}).then((e=>e.version)),o=await Ux(r,{account:t}).then((e=>e.version)).catch((()=>a));if(!o||!a)throw new Error("version not found.");return{current:o,latest:a}},async getAssets(e){const{account:t,chainFilter:n,assetFilter:r,assetTypeFilter:s,internal:i}=e,{client:a}=i,o=await async function(e,t){const{account:n,assetFilter:r,assetTypeFilter:s,chainFilter:i}=t;try{const t="wallet_getAssets",a=await e.request({method:t,params:[nh(Bw.Parameters,{account:n,assetFilter:r,assetTypeFilter:s,chainFilter:i})]}),o=sh(Bw.Response,a),c=Object.entries(o).reduce(((e,[t,n])=>(e[Sf(t)]=n,e)),{}),u={};for(const e of Object.values(c))for(const t of e){const e=JSON.stringify(t.metadata);u[e]={...t,balance:t.balance+(u[e]?.balance??0n)}}return{...c,0:Object.values(u)}}catch(e){throw Jw(e),e}}(a,{account:t,assetFilter:r,assetTypeFilter:s,chainFilter:n});return o},async getCallsStatus(e){const{id:t,internal:n}=e,{client:r}=n,s=await async function(e,t){const{id:n}=t;try{const t="wallet_getCallsStatus",r=await e.request({method:t,params:[n]});return sh(Dw.Response,r)}catch(e){throw Jw(e),e}}(r,{id:t});return{atomic:!0,chainId:zf(r.chain.id),id:t,receipts:s.receipts?.map((e=>({blockHash:e.blockHash,blockNumber:zf(e.blockNumber),gasUsed:zf(e.gasUsed),logs:e.logs,status:e.status,transactionHash:e.transactionHash}))),status:s.status,version:"1.0"}},async getCapabilities(e){const{chainIds:t,internal:n}=e,{client:s}=n,i={atomic:{status:"supported"},atomicBatch:{supported:!0},feeToken:{supported:!0,tokens:[]},merchant:{supported:!0},permissions:{supported:!0},requiredFunds:{supported:Boolean(r),tokens:[]}},a=await Zw(s,{chainIds:t?t.map((e=>Sf(e))):"all",raw:!0});return Object.entries(a).reduce(((e,[t,n])=>({...e,[t]:{...i,...n,feeToken:{supported:!0,tokens:n.fees.tokens},requiredFunds:{supported:Boolean(r),tokens:r?n.fees.tokens.filter((e=>e.interop)):[]}}})),{})},async getKeys(e){const{account:t,chainIds:n,internal:r}=e,{client:s}=r;return Jl([...await qx(s,{account:t,chainIds:n}),...t.keys??[]],(e=>e.publicKey))},async grantAdmin(e){const{account:t,internal:n}=e,{client:r}=n,i=Mg(e.key,{chainId:r.chain.id}),a=await rI(r,{addressOrSymbol:e.feeToken,store:n.store}),{id:o}=await Kx(r,{account:t,authorizeKeys:[i],feeToken:a?.address,webAuthn:s});return await Za(r,{id:o,pollingInterval:500}),{key:i}},async grantPermissions(e){const{account:t,internal:n,permissions:r}=e,{client:s}=n,i=await tI(s),a=await xx(r,{chainId:s.chain.id,feeTokens:i});if(!a)throw new Error("key to authorize not found.");const o=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!o)throw new Error("admin key not found.");const{context:c,digest:u}=await Lx(s,{account:t,authorizeKeys:[a],key:o,preCalls:!0}),d=await Sg(o,{address:null,payload:u});return await Vx(s,{context:c,key:o,signature:d}),{key:a}},async loadAccounts(e){const{internal:t,permissions:r,signInWithEthereum:a}=e,{client:c}=t,u=await tI(c),d=await xx(r,{chainId:c.chain.id,feeTokens:u}),{digest:l,digestType:f,message:p}=await(async()=>{if(a&&e.address){const t=await Sx(c,a,{address:e.address});return{context:void 0,digest:_x(Ef(t)),digestType:"siwe",message:t}}return{context:void 0,digest:"0x",message:void 0}})(),{address:h,credentialId:m,webAuthnSignature:y}=await(async()=>{if(n){if(!i)throw new Error("address_internal not found.");return{address:i,credentialId:void 0}}if(e.address&&e.key)return{address:e.address,credentialId:e.key.credentialId};const t=await fg({challenge:l,getFn:s?.getFn,rpId:o}),r=t.raw.response;return{address:Hf(new Uint8Array(r.userHandle)),credentialId:t.raw.id,webAuthnSignature:t}})(),b=await qx(c,{account:h,chainIds:[c.chain.id]}),g=Cg({address:h,keys:[...b,...d?[d]:[]].map(((e,t)=>0===t&&"webauthn-p256"===e.type?$g({...e,credential:{id:m,publicKey:ap(e.publicKey)},id:h,rpId:o}):e))}),w=Dg(g,{role:"admin"}),v=await(async()=>{if("0x"!==l)return y?Rg(_g(y),{keyType:"webauthn-p256",publicKey:w.publicKey}):await Sg(w,{address:g.address,payload:l})})();if(d){const{context:e,digest:t}=await Lx(c,{account:g,authorizeKeys:[d],preCalls:!0}),n=await Sg(w,{address:null,payload:t});await Vx(c,{context:e,key:w,signature:n})}const x=await(async()=>{if(a){if("siwe"===f&&p&&v){const e=await Xx(c,{address:g.address,signature:v});return{message:p,signature:e}}{const e=await Sx(c,a,{address:g.address}),t=await Ug(g,{payload:_x(Ef(e)),role:"admin"});return{message:e,signature:await Xx(c,{address:g.address,signature:t})}}}})();return{accounts:[{...g,signInWithEthereum:x}]}},async prepareCalls(e){const{account:t,calls:n,internal:s,merchantUrl:i}=e,{client:a}=s,o=e.key??await gx({account:t,calls:n});if(!o)throw new Error("cannot find authorized key to sign with.");const[c,u]=await Promise.all([tI(a),rI(a,{addressOrSymbol:e.feeToken,store:s.store})]),d=eI(e.requiredFunds??[],{tokens:c}),{capabilities:l,context:f,digest:p,typedData:h}=await Lx(a,{account:t,calls:n,feeToken:u?.address,key:o,merchantUrl:i,requiredFunds:r?d:void 0}),m=f.quote?.quotes??[],y=m[m.length-1];return{account:t,capabilities:{...l,quote:f.quote},chainId:a.chain.id,context:{...f,account:t,calls:n,nonce:y?.intent.nonce},digest:p,key:o,typedData:h}},async prepareUpgradeAccount(e){const{address:t,email:r,label:i,internal:c,permissions:u}=e,{client:d}=c,[l,f]=await Promise.all([tI(d),rI(d,{store:c.store})]),p=n?Ag():await Eg({createFn:s?.createFn,label:i||`${t.slice(0,8)}…${t.slice(-6)}`,rpId:o,userId:qf(t)}),h=await xx(u,{chainId:d.chain.id,feeTokens:l}),{context:m,digests:y}=await Fx(d,{address:t,authorizeKeys:[p,...h?[h]:[]],feeToken:f?.address});return r&&(a=i),{context:m,digests:y}},async revokeAdmin(e){const{account:t,id:n,internal:r}=e,{client:i}=r,a=t.keys?.find((e=>e.id===n));if(a){if("webauthn-p256"===a.type&&1===t.keys?.filter((e=>"webauthn-p256"===e.type)).length)throw new Error("revoke the only WebAuthn key left.");try{const n=await rI(i,{addressOrSymbol:e.feeToken,store:r.store}),{id:o}=await Kx(i,{account:t,feeToken:n?.address,revokeKeys:[a],webAuthn:s});await Za(i,{id:o})}catch(e){const t=e;if("Rpc.ExecutionError"===t.name&&"KeyDoesNotExist"===t.abiError?.name)return;throw e}}},async revokePermissions(e){const{account:t,id:n,internal:r}=e,{client:i}=r,a=t.keys?.find((e=>e.id===n));if(a){if("admin"===a.role)throw new Error("cannot revoke admins.");try{const n=await rI(i,{addressOrSymbol:e.feeToken,store:r.store}),{id:o}=await Kx(i,{account:t,feeToken:n?.address,revokeKeys:[a],webAuthn:s});await Za(i,{id:o})}catch(e){const t=e;if("Rpc.ExecutionError"===t.name&&"KeyDoesNotExist"===t.abiError?.name)return;throw e}}},async sendCalls(e){const{account:t,asTxHash:n,calls:i,internal:a,merchantUrl:o}=e,{client:c}=a,u=await gx({account:t,calls:i,permissionsId:e.permissionsId}),[d,l]=await Promise.all([tI(c),rI(c,{addressOrSymbol:e.feeToken,store:a.store})]),f=eI(e.requiredFunds??[],{tokens:d}),p=await Kx(c,{account:t,calls:i,feeToken:l?.address,key:u,merchantUrl:o,requiredFunds:r?f:void 0,webAuthn:s});if(n){const{id:e,receipts:t,status:n}=await Za(c,{id:p.id,pollingInterval:500});if(!t?.[0]){if("success"===n)throw new ql({message:"Call bundle with id: "+e+" not found."});throw new Il({message:"Transaction failed under call bundle id: "+e+"."})}return{id:t[0].transactionHash}}return p},async sendPreparedCalls(e){const{context:t,key:n,internal:r,signature:s}=e,{client:i}=r,{id:a}=await Vx(i,{context:t,key:n,signature:s});return a},async signPersonalMessage(e){const{account:t,data:n,internal:r}=e,{client:i}=r,a=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!a)throw new Error("cannot find admin key to sign with.");const o=await Ug(t,{key:a,payload:_x(n),webAuthn:s});return Xx(i,{address:t.address,signature:o})},async signTypedData(e){const{account:t,internal:n}=e,{client:r}=n,i=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!i)throw new Error("cannot find admin key to sign with.");const a=function(e,t){return JSON.parse(e,((e,n)=>{const r=n;return"string"==typeof r&&r.endsWith(pl)?BigInt(r.slice(0,-pl.length)):"function"==typeof t?t(e,r):r}))}(e.data),o="Orchestrator"===a.domain?.name,c=await Ug(t,{key:i,payload:zb(a),replaySafe:!o,webAuthn:s});return o?c:Xx(r,{address:t.address,signature:c})},async upgradeAccount(e){const{account:t,context:n,internal:r,signatures:s}=e,{client:i}=r;return await Zx(i,{context:n,signatures:s}),a&&await Gx(i,{email:a,walletAddress:t.address}),{account:t}},async verifyEmail(e){const{account:t,chainId:n,email:r,token:i,internal:a,walletAddress:o}=e,{client:c}=a,u=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!u)throw new Error("cannot find admin key to sign with.");const d=await Ug(t,{key:u,payload:np(Ef(`${r}${i}`)),webAuthn:s});return await Hx(c,{chainId:n,email:r,signature:d,token:i,walletAddress:o})}},config:e,name:"rpc"})}async function iI(e,t){const{config:{feeToken:n}}=e,{feeToken:r}=t??{};return r??n}function aI(e,{storage:t}){if(!e)return;const n=Nx(e,"undefined"!=typeof window?window.location.origin:void 0);return n&&t.setItem("porto.authUrl",n),n}!function(e){e.predicate=function(e){return t=>!!e&&(wp(e)?gp(t.address,e):"native"===e?t.address===Wd:e===t.symbol)}}(nI||(nI={}));const oI=new Map,cI=e=>{const t=oI.get(e);return t?Object.fromEntries(Object.entries(t.stores).map((([e,t])=>[e,t.getState()]))):{}},uI=e=>{var t,n;if(!e)return;const r=e.split("\n"),s=r.findIndex((e=>e.includes("api.setState")));if(s<0)return;const i=(null==(t=r[s+1])?void 0:t.trim())||"";return null==(n=/.+ (.+) .+/.exec(i))?void 0:n[1]},dI=(e,t={})=>(n,r,s)=>{const{enabled:i,anonymousActionType:a,store:o,...c}=t;let u;try{u=(null!=i?i:"production"!==(import.meta.env?import.meta.env.MODE:void 0))&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}if(!u)return e(n,r,s);const{connection:d,...l}=((e,t,n)=>{if(void 0===e)return{type:"untracked",connection:t.connect(n)};const r=oI.get(n.name);if(r)return{type:"tracked",store:e,...r};const s={connection:t.connect(n),stores:{}};return oI.set(n.name,s),{type:"tracked",store:e,...s}})(o,u,c);let f=!0;s.setState=(e,t,i)=>{const u=n(e,t);if(!f)return u;const l=void 0===i?{type:a||uI((new Error).stack)||"anonymous"}:"string"==typeof i?{type:i}:i;return void 0===o?(null==d||d.send(l,r()),u):(null==d||d.send({...l,type:`${o}/${l.type}`},{...cI(c.name),[o]:s.getState()}),u)},s.devtools={cleanup:()=>{d&&"function"==typeof d.unsubscribe&&d.unsubscribe(),((e,t)=>{if(void 0===t)return;const n=oI.get(e);n&&(delete n.stores[t],0===Object.keys(n.stores).length&&oI.delete(e))})(c.name,o)}};const p=(...e)=>{const t=f;f=!1,n(...e),f=t},h=e(s.setState,r,s);if("untracked"===l.type?null==d||d.init(h):(l.stores[l.store]=s,null==d||d.init(Object.fromEntries(Object.entries(l.stores).map((([e,t])=>[e,e===l.store?h:t.getState()]))))),s.dispatchFromDevtools&&"function"==typeof s.dispatch){let e=!1;const t=s.dispatch;s.dispatch=(...n)=>{"production"===(import.meta.env?import.meta.env.MODE:void 0)||"__setState"!==n[0].type||e||(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),e=!0),t(...n)}}return d.subscribe((e=>{var t;switch(e.type){case"ACTION":return"string"!=typeof e.payload?void console.error("[zustand devtools middleware] Unsupported action format"):lI(e.payload,(e=>{if("__setState"!==e.type)s.dispatchFromDevtools&&"function"==typeof s.dispatch&&s.dispatch(e);else{if(void 0===o)return void p(e.state);1!==Object.keys(e.state).length&&console.error('\n [zustand devtools middleware] Unsupported __setState action format.\n When using \'store\' option in devtools(), the \'state\' should have only one key, which is a value of \'store\' that was passed in devtools(),\n and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }\n ');const t=e.state[o];if(null==t)return;JSON.stringify(s.getState())!==JSON.stringify(t)&&p(t)}}));case"DISPATCH":switch(e.payload.type){case"RESET":return p(h),void 0===o?null==d?void 0:d.init(s.getState()):null==d?void 0:d.init(cI(c.name));case"COMMIT":return void 0===o?void(null==d||d.init(s.getState())):null==d?void 0:d.init(cI(c.name));case"ROLLBACK":return lI(e.state,(e=>{if(void 0===o)return p(e),void(null==d||d.init(s.getState()));p(e[o]),null==d||d.init(cI(c.name))}));case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return lI(e.state,(e=>{void 0!==o?JSON.stringify(s.getState())!==JSON.stringify(e[o])&&p(e[o]):p(e)}));case"IMPORT_STATE":{const{nextLiftedState:n}=e.payload,r=null==(t=n.computedStates.slice(-1)[0])?void 0:t.state;if(!r)return;return p(void 0===o?r:r[o]),void(null==d||d.send(null,n))}case"PAUSE_RECORDING":return f=!f}return}})),h},lI=(e,t)=>{let n;try{n=JSON.parse(e)}catch(e){console.error("[zustand devtools middleware] Could not parse the received json",e)}void 0!==n&&t(n)},fI=e=>(t,n,r)=>{const s=r.subscribe;r.subscribe=(e,t,n)=>{let i=e;if(t){const s=(null==n?void 0:n.equalityFn)||Object.is;let a=e(r.getState());i=n=>{const r=e(n);if(!s(a,r)){const e=a;t(a=r,e)}},(null==n?void 0:n.fireImmediately)&&t(a,a)}return s(i)};return e(t,n,r)};function pI(e,t){let n;try{n=e()}catch(e){return}const r={getItem:e=>{var r;const s=e=>null===e?null:JSON.parse(e,null==t?void 0:t.reviver),i=null!=(r=n.getItem(e))?r:null;return i instanceof Promise?i.then(s):s(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,null==t?void 0:t.replacer)),removeItem:e=>n.removeItem(e)};return r}const hI=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>hI(e)(n),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>hI(t)(e)}}},mI=(e,t)=>(n,r,s)=>{let i={storage:pI((()=>localStorage)),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},a=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e(((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...e)}),r,s);const d=()=>{const e=i.partialize({...r()});return u.setItem(i.name,{state:e,version:i.version})},l=s.setState;s.setState=(e,t)=>(l(e,t),d());const f=e(((...e)=>(n(...e),d())),r,s);let p;s.getInitialState=()=>f;const h=()=>{var e,t;if(!u)return;a=!1,o.forEach((e=>{var t;return e(null!=(t=r())?t:f)}));const s=(null==(t=i.onRehydrateStorage)?void 0:t.call(i,null!=(e=r())?e:f))||void 0;return hI(u.getItem.bind(u))(i.name).then((e=>{if(e){if("number"!=typeof e.version||e.version===i.version)return[!1,e.state];if(i.migrate){const t=i.migrate(e.state,e.version);return t instanceof Promise?t.then((e=>[!0,e])):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]})).then((e=>{var t;const[s,a]=e;if(p=i.merge(a,null!=(t=r())?t:f),n(p,!0),s)return d()})).then((()=>{null==s||s(p,void 0),p=r(),a=!0,c.forEach((e=>e(p)))})).catch((e=>{null==s||s(void 0,e)}))};return s.persist={setOptions:e=>{i={...i,...e},e.storage&&(u=e.storage)},clearStorage:()=>{null==u||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>h(),hasHydrated:()=>a,onHydrate:e=>(o.add(e),()=>{o.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},i.skipHydration||h(),p||f},yI=e=>{let t;const n=new Set,r=(e,r)=>{const s="function"==typeof e?e(t):e;if(!Object.is(s,t)){const e=t;t=(null!=r?r:"object"!=typeof s||null===s)?s:Object.assign({},t,s),n.forEach((n=>n(t,e)))}},s=()=>t,i={setState:r,getState:s,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e))},a=t=e(r,s,i);return i},bI=e=>e?yI(e):yI;function gI(e){return new Promise(((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}))}function wI(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=gI(n);return(e,n)=>r.then((r=>n(r.transaction(t,e).objectStore(t))))}let vI;function xI(){return vI||(vI=wI("keyval-store","keyval")),vI}const II="undefined"!=typeof window&&"undefined"!=typeof document,PI={announceProvider:!0,chains:fl,mode:II?function(e={}){const{fallback:t=sI(),host:n=rf.prod,renderer:r=sf(),theme:s,themeController:i}=e,a=new Set,o=function(e={}){let t=e.id??0;return{prepare:e=>function(e){return{...e,jsonrpc:"2.0"}}({id:t++,...e}),get id(){return t}}}();function c(e){return Vl({async request(t){const n=o.prepare(t);return e.setState((e=>{const t=e.accounts[0],r=t?.keys?.find((e=>"admin"===e.role&&"webauthn-p256"===e.type));return{...e,requestQueue:[...e.requestQueue,{account:t?{address:t.address,key:r?{credentialId:r?.credentialId,publicKey:r.publicKey}:void 0}:void 0,request:n,status:"pending"}]}})),new Promise(((t,r)=>{const s=i=>{const o=i.find((e=>e.request.id===n.id));if(!o&&0===i.length)return a.delete(s),void r(new Sl);o&&("success"!==o.status&&"error"!==o.status||(a.delete(s),"success"===o.status?t(o.result):r(Gl(o.error)),e.setState((e=>({...e,requestQueue:e.requestQueue.filter((e=>e.request.id!==n.id))})))))};a.add(s)}))}},{schema:null})}return bx({actions:{async addFunds(e){const{internal:t}=e,{request:n,store:r}=t;if("wallet_addFunds"!==n.method)throw new Error("Cannot add funds for method: "+n.method);const s=c(r);return await s.request(n)},async createAccount(e){const{internal:t}=e,{client:n,config:r,request:s,store:i}=t,{storage:a}=r,o=c(i),u=await(async()=>{if("wallet_connect"===s.method){const[{capabilities:e,chainIds:t}]=s._decoded.params??[{}],i=aI(e?.signInWithEthereum?.authUrl??r.authUrl,{storage:a}),c=s.params?.[0]?.capabilities?.signInWithEthereum,u=await xx(e?.grantPermissions,{chainId:n.chain.id}),d=u?nh(wx,vx(u)):void 0,{accounts:l}=await o.request({...s,params:[{capabilities:{...s.params?.[0]?.capabilities,grantPermissions:d,signInWithEthereum:i||c?{...c,authUrl:i}:void 0},chainIds:t?.map((e=>zf(e)))}]}),[f]=l;if(!f)throw new Error("no account found.");const p=f.capabilities?.admins?.map((e=>Mg(e,{chainId:n.chain.id}))).filter(Boolean),h=f.capabilities?.permissions?.map((e=>{try{const t=mv(sh(pv,e));return t.id===u?.id?{...t,...u,permissions:t.permissions}:t}catch{return}})).filter(Boolean),m=await(async()=>{if(!f.capabilities?.signInWithEthereum)return;const{message:e,signature:t}=f.capabilities.signInWithEthereum;if(!i)return{message:e,signature:t};const{token:n}=await jx({address:f.address,authUrl:i,message:e,signature:t});return{message:e,signature:t,token:n}})();return{...Cg({address:f.address,keys:[...p??[],...h??[]]}),signInWithEthereum:m}}throw new Error(`Account creation not supported on method: ${s.method}`)})();return{account:u}},async disconnect(e){const{internal:t}=e,{config:n}=t,{storage:r}=n,s=await r.getItem("porto.authUrl")||void 0,i=aI(n.authUrl??s,{storage:r});i&&await fetch(i.logout,{credentials:"include",method:"POST"}).catch((()=>{}))},async getAccountVersion(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getAccountVersion"!==i.method)throw new Error("Cannot get version for method: "+i.method);if(!r.supportsHeadless)return t.actions.getAccountVersion(e);const a=c(s);return await a.request(i)},async getAssets(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getAssets"!==i.method)throw new Error("Cannot get assets for method: "+i.method);if(!r.supportsHeadless)return t.actions.getAssets(e);const a=c(s),o=await a.request(i);return sh(Xv.Response,o)},async getCallsStatus(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getCallsStatus"!==i.method)throw new Error("Cannot get status for method: "+i.method);if(!r.supportsHeadless)return t.actions.getCallsStatus(e);const a=c(s);return await a.request(i)},async getCapabilities(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getCapabilities"!==i.method)throw new Error("Cannot get capabilities for method: "+i.method);if(!r.supportsHeadless)return t.actions.getCapabilities(e);const a=c(s);return await a.request(i)},async getKeys(e){const{account:n,chainIds:s,internal:i}=e,{store:a}=i;return Jl([...await(async()=>{if(!r.supportsHeadless)return t.actions.getKeys(e);const i=c(a),o=await i.request({method:"wallet_getKeys",params:[nh(nx.Parameters,{address:n.address,chainIds:s})]});return sh(nx.Response,o)})(),...n.keys??[]],(e=>e.publicKey))},async grantAdmin(e){const{internal:t}=e,{request:n,store:r}=t;if("wallet_grantAdmin"!==n.method)throw new Error("Cannot authorize admin for method: "+n.method);const[s]=n._decoded.params,i=Mg(s.key);if(!i)throw new Error("no key found.");const a=await iI(t,e),o=c(r);return await o.request({method:"wallet_grantAdmin",params:[{...n.params?.[0],capabilities:{...n.params?.[0]?.capabilities,feeToken:a}}]}),{key:i}},async grantPermissions(e){const{internal:t}=e,{client:n,request:r,store:s}=t;if("wallet_grantPermissions"!==r.method)throw new Error("Cannot grant permissions for method: "+r.method);const[{address:i,...a}]=r._decoded.params,o=await xx(a,{chainId:n.chain.id});if(!o)throw new Error("no key found.");const u=nh(wx,vx(o)),d=c(s);return await d.request({method:"wallet_grantPermissions",params:[u]}),{key:o}},async loadAccounts(e){const{internal:t}=e,{client:n,config:r,store:s}=t,{storage:i}=r,a=c(s),o=t.request;if("wallet_connect"!==o.method&&"eth_requestAccounts"!==o.method)throw new Error("Cannot load accounts for method: "+o.method);const u=await(async()=>{const[e]=o._decoded.params??[],{capabilities:t}=e??{},s=aI(t?.signInWithEthereum?.authUrl??r.authUrl,{storage:i}),c=o.params?.[0]?.capabilities?.signInWithEthereum,u=await xx(t?.grantPermissions,{chainId:n.chain.id}),d=u?nh(wx,vx(u)):void 0,{accounts:l}=await a.request({method:"wallet_connect",params:[{...o.params?.[0],capabilities:{...o.params?.[0]?.capabilities,grantPermissions:d,signInWithEthereum:s||c?{...c,authUrl:s}:void 0}}]});return Promise.all(l.map((async e=>{const t=e.capabilities?.admins?.map((e=>Mg(e))).filter(Boolean),n=e.capabilities?.permissions?.map((e=>{try{const t=mv(sh(pv,e));return t.id===u?.id?{...t,...u,permissions:t.permissions}:t}catch{return}})).filter(Boolean),r=await(async()=>{if(!e.capabilities?.signInWithEthereum)return;const{message:t,signature:n}=e.capabilities.signInWithEthereum;if(!s)return{message:t,signature:n};const{token:r}=await jx({address:e.address,authUrl:s,message:t,signature:n});return{message:t,signature:n,token:r}})();return{...Cg({address:e.address,keys:[...t??[],...n??[]]}),signInWithEthereum:r}})))})();return{accounts:u}},async prepareCalls(e){const{account:n,internal:s}=e,{store:i,request:a}=s;if("wallet_prepareCalls"!==a.method)throw new Error("Cannot prepare calls for method: "+a.method);if(!r.supportsHeadless)return t.actions.prepareCalls(e);const o=await iI(s,e),u=c(i),d=sh(rx.Response,await u.request({...a,params:[{...a.params?.[0],capabilities:{...a.params?.[0]?.capabilities,feeToken:o}}]}));return{account:n,chainId:Number(d.chainId),context:d.context,digest:d.digest,key:d.key,typedData:d.typedData}},async prepareUpgradeAccount(e){const{internal:n}=e,{client:s,store:i,request:a}=n;if("wallet_prepareUpgradeAccount"!==a.method)throw new Error("Cannot prepare upgrade for method: "+a.method);if(!r.supportsHeadless)return t.actions.prepareUpgradeAccount(e);const[{capabilities:o}]=a._decoded.params??[{}],u=await xx(o?.grantPermissions,{chainId:s.chain.id}),d=u?nh(wx,vx(u)):void 0,l=c(i),{context:f,digests:p}=await l.request({...a,params:[{...a.params?.[0],capabilities:{...a.params?.[0]?.capabilities,grantPermissions:d}}]}),h=f.account.keys?.map((e=>e.id===u?.id?{...e,...u}:e));return{context:{...f,account:{...f.account,keys:h}},digests:p}},async revokeAdmin(e){const{account:t,id:n,internal:r}=e,{store:s,request:i}=r;if("wallet_revokeAdmin"!==i.method)throw new Error("Cannot revoke admin for method: "+i.method);const a=t.keys?.find((e=>e.id===n));if(!a)return;if("webauthn-p256"===a.type&&1===t.keys?.filter((e=>"webauthn-p256"===e.type)).length)throw new Error("revoke the only WebAuthn key left.");const o=await iI(r,e),u=c(s);return await u.request({...i,params:[{...i.params?.[0],capabilities:{...i.params?.[0]?.capabilities,feeToken:o}}]})},async revokePermissions(e){const{account:t,id:n,internal:r}=e,{store:s,request:i}=r;if("wallet_revokePermissions"!==i.method)throw new Error("Cannot revoke permissions for method: "+i.method);const a=t.keys?.find((e=>e.id===n));if(!a)return;if("admin"===a.role)throw new Error("cannot revoke permissions.");const o=c(s);return await o.request(i)},async sendCalls(e){const{account:n,asTxHash:s,calls:i,internal:a,merchantUrl:o,requiredFunds:u}=e,{client:d,store:l,request:f}=a,p=c(l),h=await iI(a,e),m=await gx({account:n,calls:i,permissionsId:e.permissionsId});if(m&&"session"===m.role){if(!r.supportsHeadless)return t.actions.sendCalls(e);try{const e=await p.request(nh(rx.Request,{method:"wallet_prepareCalls",params:[{calls:i,capabilities:{..."wallet_sendCalls"===f._decoded.method?f._decoded.params?.[0]?.capabilities:void 0,feeToken:h,merchantUrl:o,requiredFunds:u},chainId:d.chain.id,from:n.address,key:m}]})),t=e.capabilities?.quote?.quotes??[],r=t.some(((e,n)=>!(n===t.length-1&&t.length>1)&&jf(e.feeTokenDeficit)>0n));if(r)throw new Error("insufficient funds");const a=await Sg(m,{address:null,payload:e.digest,wrap:!1}),c=(await p.request({method:"wallet_sendPreparedCalls",params:[{...e,signature:a}]}))[0];if(!c)throw new Error("id not found");if(s){const{id:e,receipts:t,status:n}=await Za(d,{id:c.id,pollingInterval:500});if(!t?.[0]){if("success"===n)throw new ql({message:"Call bundle with id: "+e+" not found."});throw new Il({message:"Transaction failed under call bundle id: "+e+"."})}return{id:t[0].transactionHash}}return c}catch{}}if("eth_sendTransaction"===f.method){return{id:await p.request({...f,params:[{...f.params?.[0],capabilities:{feeToken:h,merchantUrl:o}}]})}}if("wallet_sendCalls"===f.method){return await p.request({method:"wallet_sendCalls",params:[{...f.params?.[0],capabilities:{...f.params?.[0]?.capabilities,feeToken:h,merchantUrl:o}}]})}throw new Error("Cannot execute for method: "+f.method)},async sendPreparedCalls(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_sendPreparedCalls"!==i.method)throw new Error("Cannot send prepared calls for method: "+i.method);if(!r.supportsHeadless)return t.actions.sendPreparedCalls(e);const a=c(s),o=await a.request(i),u=o[0]?.id;if(!u)throw new Error("id not found");return u},async signPersonalMessage(e){const{internal:t}=e,{store:n,request:r}=t;if("personal_sign"!==r.method)throw new Error("Cannot sign personal message for method: "+r.method);const s=c(n);return await s.request(r)},async signTypedData(e){const{internal:t}=e,{store:n,request:r}=t;if("eth_signTypedData_v4"!==r.method)throw new Error("Cannot sign typed data for method: "+r.method);const s=c(n);return await s.request(r)},async switchChain(e){const{internal:t}=e,{store:n,request:s}=t;if("wallet_switchEthereumChain"!==s.method)throw new Error("Cannot switch chain for method: "+s.method);if(!r.supportsHeadless)return;const i=c(n);return await i.request(s)},async upgradeAccount(e){const{account:t,internal:n}=e,{store:r,request:s}=n;if("wallet_upgradeAccount"!==s.method)throw new Error("Cannot upgrade account for method: "+s.method);const i=c(r);return await i.request(s),{account:t}},async verifyEmail(e){const{internal:t}=e,{request:n,store:r}=t;if("account_verifyEmail"!==n.method)throw new Error("Cannot verify email for method: "+n.method);const s=c(r);return await s.request(n)}},config:e,name:"dialog",setup(e){const{internal:t}=e,{store:o}=t,c=r.setup({host:n,internal:t,theme:s,themeController:i}),u=o.subscribe((e=>e.requestQueue),(e=>{for(const t of a)t(e);const t=e.map((e=>"pending"===e.status?e:void 0)).filter(Boolean);c.syncRequests(t).catch((()=>{})),0===t.length&&c.close()}));return()=>{u(),c.destroy()}}})}({host:rf.prod}):sI(),relay:il("https://relay.wallet.risechain.com"),storage:II&&"undefined"!=typeof indexedDB?function(){const e="undefined"!=typeof indexedDB?wI("porto","store"):void 0;return{async getItem(t){const n=await function(e,t=xI()){return t("readonly",(t=>gI(t.get(e))))}(t,e);return null===n?null:n},async removeItem(t){await function(e,t=xI()){return t("readwrite",(t=>(t.delete(e),gI(t.transaction))))}(t,e)},async setItem(t,n){await function(e,t,n=xI()){return n("readwrite",(n=>(n.put(t,e),gI(n.transaction))))}(t,Ql(n),e)},sizeLimit:52428800}}():function(){const e=new Map;return{getItem:t=>e.get(t)??null,removeItem(t){e.delete(t)},setItem(t,n){e.set(t,n)},sizeLimit:Number.POSITIVE_INFINITY}}(),storageKey:"risewallet.store"};function zI(e){return t(this,void 0,void 0,(function*(){const e=function(e={}){const t=e.chains??PI.chains,n=Object.fromEntries(t.map((t=>[t.id,e.transports?.[t.id]??il()]))),r={announceProvider:e.announceProvider??PI.announceProvider,authUrl:e.authUrl,chains:t,feeToken:e.feeToken,merchantUrl:e.merchantUrl,mode:e.mode??PI.mode,relay:e.relay??PI.relay,storage:e.storage??PI.storage,storageKey:e.storageKey??PI.storageKey,transports:n},s=bI(dI(fI(mI((e=>({accounts:[],chainIds:r.chains.map((e=>e.id)),feeToken:r.feeToken,requestQueue:[]})),{merge(e,t){const n=e,s=r.chains.find((e=>e.id===n.chainIds[0]))?.id??r.chains[0].id,i=[s,...r.chains.map((e=>e.id)).filter((e=>e!==s))];return{...t,...n,chainIds:i}},name:r.storageKey,partialize:e=>({accounts:e.accounts.map((e=>Ql(e))),chainIds:e.chainIds}),storage:r.storage,version:5}))));let i=r.mode;const a={config:r,getMode:()=>i,id:Xl(),setMode:e=>(c?.(),i=e,c=e.setup({internal:a}),c),store:s},o=fx(a);let c=null!==i?i.setup({internal:a}):()=>{};return{_internal:a,config:r,destroy(){c(),o._internal.destroy()},provider:o}}({announceProvider:!1});return e.provider}))}var EI=Object.freeze({__proto__:null,default:function(e,r){var s,i,a,o,c;return t(this,void 0,void 0,(function*(){const e=yield zI();if(!e)throw new Error("Failed to create Rise wallet provider");null===(s=e.on)||void 0===s||s.call(e,"connect",r.connect),null===(i=e.on)||void 0===i||i.call(e,"disconnect",r.disconnect),null===(a=e.on)||void 0===a||a.call(e,"accountsChanged",r.accountsChanged),null===(o=e.on)||void 0===o||o.call(e,"chainChanged",r.chainChanged),null===(c=e.on)||void 0===c||c.call(e,"message",r.message);return(yield e.request({method:"eth_accounts"})).length||(yield e.request({method:"eth_requestAccounts"})),n(e)}))}});export{he as A,ee as B,sr as H,we as I,de as a,ue as b,Xt as c,On as d,cn as e,Z as f,pn as g,fe as h,pe as i,fa as j,vn as k,Qn as l,Rn as m,_n as n,Vs as o,$a as p,Jt as q,W as r,en as s,fn as t,EI as u};
|