@origintrail-official/dkg-node-ui 10.0.2 → 10.0.3

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.
Files changed (50) hide show
  1. package/dist/chain-cursor-stores.d.ts +45 -0
  2. package/dist/chain-cursor-stores.d.ts.map +1 -0
  3. package/dist/chain-cursor-stores.js +107 -0
  4. package/dist/chain-cursor-stores.js.map +1 -0
  5. package/dist/chat-memory.d.ts +0 -17
  6. package/dist/chat-memory.d.ts.map +1 -1
  7. package/dist/chat-memory.js +6 -33
  8. package/dist/chat-memory.js.map +1 -1
  9. package/dist/db.d.ts +15 -0
  10. package/dist/db.d.ts.map +1 -1
  11. package/dist/db.js +40 -1
  12. package/dist/db.js.map +1 -1
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +2 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/notifications-scope.d.ts +19 -0
  18. package/dist/notifications-scope.d.ts.map +1 -1
  19. package/dist/notifications-scope.js +34 -2
  20. package/dist/notifications-scope.js.map +1 -1
  21. package/dist-ui/assets/{3d-force-graph-CcVMtgO4.js → 3d-force-graph-DRDhpplH.js} +1 -1
  22. package/dist-ui/assets/AgentHub-DdUAxJoy.js +1 -0
  23. package/dist-ui/assets/AgentProfilePage-yI8fA4vv.js +1 -0
  24. package/dist-ui/assets/ApproveWalletsModal-9w2edv7e.js +57 -0
  25. package/dist-ui/assets/ConvictionDetailView-CcQMya-y.js +2 -0
  26. package/dist-ui/assets/Network-DpAKVzwi.js +1 -0
  27. package/dist-ui/assets/OnChainProvenanceCard-DMOm3jLz.js +1 -0
  28. package/dist-ui/assets/{Operations-CCMDENBd.js → Operations-DKJFp6hM.js} +1 -1
  29. package/dist-ui/assets/PublishingConviction-1CPHxNwp.js +2 -0
  30. package/dist-ui/assets/Settings-DaYMlGHD.js +1 -0
  31. package/dist-ui/assets/ccip-hCQYqfNz.js +1 -0
  32. package/dist-ui/assets/{index-BrxEjqsW.js → index-Bh_8bMB0.js} +3 -3
  33. package/dist-ui/assets/{index-W4n8cdTA.js → index-CVwCoJrM.js} +10 -10
  34. package/dist-ui/assets/index-D5UiTYlY.css +1 -0
  35. package/dist-ui/assets/index-DGpnb_b1.js +1661 -0
  36. package/dist-ui/assets/{jsonld-32FQRO67-CbN9NJJW.js → jsonld-32FQRO67-C3B_LjZ-.js} +2 -2
  37. package/dist-ui/assets/{jsonld-DkQdPwg5.js → jsonld-CoPRWQuM.js} +1 -1
  38. package/dist-ui/assets/{renderer-3d-2EVDZII7-CTUExXUn.js → renderer-3d-2EVDZII7-Bx6o7Gge.js} +2 -2
  39. package/dist-ui/index.html +2 -2
  40. package/package.json +5 -3
  41. package/dist-ui/assets/Admin-DNNaF7rz.js +0 -45
  42. package/dist-ui/assets/AgentHub-eWb_Tns6.js +0 -1
  43. package/dist-ui/assets/AgentProfilePage-D2T_V6PG.js +0 -1
  44. package/dist-ui/assets/Network-C6MDsv2e.js +0 -1
  45. package/dist-ui/assets/OnChainProvenanceCard-BbrU7jzL.js +0 -1
  46. package/dist-ui/assets/Settings-WaFKYtwQ.js +0 -1
  47. package/dist-ui/assets/ccip-CDdHldzo.js +0 -1
  48. package/dist-ui/assets/formatTrac-BTy0WudH.js +0 -1
  49. package/dist-ui/assets/index-2Gzrk1k3.js +0 -1661
  50. package/dist-ui/assets/index-CmliV5st.css +0 -1
@@ -1,45 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ccip-CDdHldzo.js","assets/index-2Gzrk1k3.js","assets/index-CmliV5st.css","assets/formatTrac-BTy0WudH.js"])))=>i.map(i=>d[i]);
2
- import{_ as Zi,Z as G,X as b,ag as dn,u as Ou,y as Mu,w as Lu,n as Uu,k as _u,ai as Du,e as Gu,a0 as qu,a4 as Hu,x as Vu,i as Wu,Y as Zu,a2 as Ku,a1 as Yu,f as Ju,$ as Xu,j as Qu,a3 as e0}from"./index-2Gzrk1k3.js";import{f as Ko,b as Yo}from"./formatTrac-BTy0WudH.js";const t0="1.2.3";let fe=class bs extends Error{constructor(t,n={}){var i;const r=n.cause instanceof bs?n.cause.details:(i=n.cause)!=null&&i.message?n.cause.message:n.details,s=n.cause instanceof bs&&n.cause.docsPath||n.docsPath,o=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...r?[`Details: ${r}`]:[],`Version: abitype@${t0}`].join(`
3
- `);super(o),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"}),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=t}};function Ke(e,t){const n=e.exec(t);return n==null?void 0:n.groups}const Ki=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Yi=/^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)?$/,Ji=/^\(.+?\).*?$/,Jo=/^tuple(?<array>(\[(\d*)\])*)$/;function ms(e){let t=e.type;if(Jo.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let s=0;s<n;s++){const o=e.components[s];t+=ms(o),s<n-1&&(t+=", ")}const r=Ke(Jo,e.type);return t+=`)${(r==null?void 0:r.array)||""}`,ms({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Tt(e){let t="";const n=e.length;for(let r=0;r<n;r++){const s=e[r];t+=ms(s),r!==n-1&&(t+=", ")}return t}function ar(e){var t;return e.type==="function"?`function ${e.name}(${Tt(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${(t=e.outputs)!=null&&t.length?` returns (${Tt(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${Tt(e.inputs)})`:e.type==="error"?`error ${e.name}(${Tt(e.inputs)})`:e.type==="constructor"?`constructor(${Tt(e.inputs)})${e.stateMutability==="payable"?" payable":""}`:e.type==="fallback"?`fallback() external${e.stateMutability==="payable"?" payable":""}`:"receive() external payable"}const Xi=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function n0(e){return Xi.test(e)}function r0(e){return Ke(Xi,e)}const Qi=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function s0(e){return Qi.test(e)}function o0(e){return Ke(Qi,e)}const ea=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function i0(e){return ea.test(e)}function a0(e){return Ke(ea,e)}const ta=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function yr(e){return ta.test(e)}function c0(e){return Ke(ta,e)}const na=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function u0(e){return na.test(e)}function d0(e){return Ke(na,e)}const ra=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function l0(e){return ra.test(e)}function f0(e){return Ke(ra,e)}const h0=/^receive\(\) external payable$/;function p0(e){return h0.test(e)}const Xo=new Set(["memory","indexed","storage","calldata"]),b0=new Set(["indexed"]),ys=new Set(["calldata","memory","storage"]);class m0 extends fe{constructor({signature:t}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(t,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class y0 extends fe{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" 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 g0 extends fe{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class w0 extends fe{constructor({params:t}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(t,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class x0 extends fe{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class v0 extends fe{constructor({param:t,name:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${n}" 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 E0 extends fe{constructor({param:t,type:n,modifier:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class P0 extends fe{constructor({param:t,type:n,modifier:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${r}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class A0 extends fe{constructor({abiParameter:t}){super("Invalid ABI parameter.",{details:JSON.stringify(t,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class Vt extends fe{constructor({signature:t,type:n}){super(`Invalid ${n} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class I0 extends fe{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class C0 extends fe{constructor({signature:t}){super("Invalid struct signature.",{details:t,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class $0 extends fe{constructor({type:t}){super("Circular reference detected.",{metaMessages:[`Struct "${t}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class S0 extends fe{constructor({current:t,depth:n}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${n>0?"opening":"closing"} parentheses.`],details:`Depth "${n}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function B0(e,t,n){let r="";if(n)for(const s of Object.entries(n)){if(!s)continue;let o="";for(const i of s[1])o+=`[${i.type}${i.name?`:${i.name}`:""}]`;r+=`(${s[0]}{${o}})`}return t?`${t}:${e}${r}`:`${e}${r}`}const Vr=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 gs(e,t={}){if(i0(e))return T0(e,t);if(s0(e))return N0(e,t);if(n0(e))return k0(e,t);if(u0(e))return j0(e,t);if(l0(e))return z0(e);if(p0(e))return{type:"receive",stateMutability:"payable"};throw new I0({signature:e})}function T0(e,t={}){const n=a0(e);if(!n)throw new Vt({signature:e,type:"function"});const r=ge(n.parameters),s=[],o=r.length;for(let a=0;a<o;a++)s.push(We(r[a],{modifiers:ys,structs:t,type:"function"}));const i=[];if(n.returns){const a=ge(n.returns),c=a.length;for(let u=0;u<c;u++)i.push(We(a[u],{modifiers:ys,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:i}}function N0(e,t={}){const n=o0(e);if(!n)throw new Vt({signature:e,type:"event"});const r=ge(n.parameters),s=[],o=r.length;for(let i=0;i<o;i++)s.push(We(r[i],{modifiers:b0,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}function k0(e,t={}){const n=r0(e);if(!n)throw new Vt({signature:e,type:"error"});const r=ge(n.parameters),s=[],o=r.length;for(let i=0;i<o;i++)s.push(We(r[i],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}function j0(e,t={}){const n=d0(e);if(!n)throw new Vt({signature:e,type:"constructor"});const r=ge(n.parameters),s=[],o=r.length;for(let i=0;i<o;i++)s.push(We(r[i],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}function z0(e){const t=f0(e);if(!t)throw new Vt({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}const R0=/^(?<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$_]*))?$/,F0=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,O0=/^u?int$/;function We(e,t){var l,f;const n=B0(e,t==null?void 0:t.type,t==null?void 0:t.structs);if(Vr.has(n))return Vr.get(n);const r=Ji.test(e),s=Ke(r?F0:R0,e);if(!s)throw new x0({param:e});if(s.name&&L0(s.name))throw new v0({param:e,name:s.name});const o=s.name?{name:s.name}:{},i=s.modifier==="indexed"?{indexed:!0}:{},a=(t==null?void 0:t.structs)??{};let c,u={};if(r){c="tuple";const p=ge(s.type),h=[],m=p.length;for(let x=0;x<m;x++)h.push(We(p[x],{structs:a}));u={components:h}}else if(s.type in a)c="tuple",u={components:a[s.type]};else if(O0.test(s.type))c=`${s.type}256`;else if(s.type==="address payable")c="address";else if(c=s.type,(t==null?void 0:t.type)!=="struct"&&!sa(c))throw new g0({type:c});if(s.modifier){if(!((f=(l=t==null?void 0:t.modifiers)==null?void 0:l.has)!=null&&f.call(l,s.modifier)))throw new E0({param:e,type:t==null?void 0:t.type,modifier:s.modifier});if(ys.has(s.modifier)&&!U0(c,!!s.array))throw new P0({param:e,type:t==null?void 0:t.type,modifier:s.modifier})}const d={type:`${c}${s.array??""}`,...o,...i,...u};return Vr.set(n,d),d}function ge(e,t=[],n="",r=0){const s=e.trim().length;for(let o=0;o<s;o++){const i=e[o],a=e.slice(o+1);switch(i){case",":return r===0?ge(a,[...t,n.trim()]):ge(a,t,`${n}${i}`,r);case"(":return ge(a,t,`${n}${i}`,r+1);case")":return ge(a,t,`${n}${i}`,r-1);default:return ge(a,t,`${n}${i}`,r)}}if(n==="")return t;if(r!==0)throw new S0({current:n,depth:r});return t.push(n.trim()),t}function sa(e){return e==="address"||e==="bool"||e==="function"||e==="string"||Ki.test(e)||Yi.test(e)}const M0=/^(?: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 L0(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||Ki.test(e)||Yi.test(e)||M0.test(e)}function U0(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}function Qs(e){const t={},n=e.length;for(let i=0;i<n;i++){const a=e[i];if(!yr(a))continue;const c=c0(a);if(!c)throw new Vt({signature:a,type:"struct"});const u=c.properties.split(";"),d=[],l=u.length;for(let f=0;f<l;f++){const h=u[f].trim();if(!h)continue;const m=We(h,{type:"struct"});d.push(m)}if(!d.length)throw new C0({signature:a});t[c.name]=d}const r={},s=Object.entries(t),o=s.length;for(let i=0;i<o;i++){const[a,c]=s[i];r[a]=oa(c,t)}return r}const _0=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function oa(e=[],t={},n=new Set){const r=[],s=e.length;for(let o=0;o<s;o++){const i=e[o];if(Ji.test(i.type))r.push(i);else{const c=Ke(_0,i.type);if(!(c!=null&&c.type))throw new A0({abiParameter:i});const{array:u,type:d}=c;if(d in t){if(n.has(d))throw new $0({type:d});r.push({...i,type:`tuple${u??""}`,components:oa(t[d],t,new Set([...n,d]))})}else if(sa(d))r.push(i);else throw new y0({type:d})}}return r}function ia(e){const t=Qs(e),n=[],r=e.length;for(let s=0;s<r;s++){const o=e[s];yr(o)||n.push(gs(o,t))}return n}function Qo(e){let t;if(typeof e=="string")t=gs(e);else{const n=Qs(e),r=e.length;for(let s=0;s<r;s++){const o=e[s];if(!yr(o)){t=gs(o,n);break}}}if(!t)throw new m0({signature:e});return t}function ei(e){const t=[];if(typeof e=="string"){const n=ge(e),r=n.length;for(let s=0;s<r;s++)t.push(We(n[s],{modifiers:Xo}))}else{const n=Qs(e),r=e.length;for(let s=0;s<r;s++){const o=e[s];if(yr(o))continue;const i=ge(o),a=i.length;for(let c=0;c<a;c++)t.push(We(i[c],{modifiers:Xo,structs:n}))}}if(t.length===0)throw new w0({params:e});return t}function M(e,t,n){const r=e[t.name];if(typeof r=="function")return r;const s=e[n];return typeof s=="function"?s:o=>t(e,o)}function $e(e,{includeName:t=!1}={}){if(e.type!=="function"&&e.type!=="event"&&e.type!=="error")throw new td(e.type);return`${e.name}(${gr(e.inputs,{includeName:t})})`}function gr(e,{includeName:t=!1}={}){return e?e.map(n=>D0(n,{includeName:t})).join(t?", ":","):""}function D0(e,{includeName:t}){return e.type.startsWith("tuple")?`(${gr(e.components,{includeName:t})})${e.type.slice(5)}`:e.type+(t&&e.name?` ${e.name}`:"")}function Fe(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function Z(e){return Fe(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const aa="2.53.1";let sn={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${aa}`},$=class ws extends Error{constructor(t,n={}){var a;const r=(()=>{var c;return n.cause instanceof ws?n.cause.details:(c=n.cause)!=null&&c.message?n.cause.message:n.details})(),s=n.cause instanceof ws&&n.cause.docsPath||n.docsPath,o=(a=sn.getDocsUrl)==null?void 0:a.call(sn,{...n,docsPath:s}),i=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: ${o}`]:[],...r?[`Details: ${r}`]:[],...sn.version?[`Version: ${sn.version}`]:[]].join(`
4
- `);super(i,n.cause?{cause:n.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=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=aa}walk(t){return ca(this,t)}};function ca(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?ca(e.cause,t):t?null:e}class G0 extends ${constructor({docsPath:t}){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(`
5
- `),{docsPath:t,name:"AbiConstructorNotFoundError"})}}class ti extends ${constructor({docsPath:t}){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(`
6
- `),{docsPath:t,name:"AbiConstructorParamsNotFoundError"})}}class ua extends ${constructor({data:t,params:n,size:r}){super([`Data size of ${r} bytes is too small for given parameters.`].join(`
7
- `),{metaMessages:[`Params: (${gr(n,{includeName:!0})})`,`Data: ${t} (${r} 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=t,this.params=n,this.size=r}}class Mn extends ${constructor({cause:t}={}){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError",cause:t})}}class q0 extends ${constructor({expectedLength:t,givenLength:n,type:r}){super([`ABI encoding array length mismatch for type ${r}.`,`Expected length: ${t}`,`Given length: ${n}`].join(`
8
- `),{name:"AbiEncodingArrayLengthMismatchError"})}}class H0 extends ${constructor({expectedSize:t,value:n}){super(`Size of bytes "${n}" (bytes${Z(n)}) does not match expected size (bytes${t}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class V0 extends ${constructor({expectedLength:t,givenLength:n}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${t}`,`Given length (values): ${n}`].join(`
9
- `),{name:"AbiEncodingLengthMismatchError"})}}class W0 extends ${constructor(t,{docsPath:n}){super([`Arguments (\`args\`) were provided to "${t}", but "${t}" 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(`
10
- `),{docsPath:n,name:"AbiErrorInputsNotFoundError"})}}class ni extends ${constructor(t,{docsPath:n}={}){super([`Error ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join(`
11
- `),{docsPath:n,name:"AbiErrorNotFoundError"})}}class da extends ${constructor(t,{docsPath:n,cause:r}){super([`Encoded error signature "${t}" 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://4byte.sourcify.dev/?q=${t}.`].join(`
12
- `),{docsPath:n,name:"AbiErrorSignatureNotFoundError",cause:r}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=t}}class Z0 extends ${constructor({docsPath:t}){super("Cannot extract event signature from empty topics.",{docsPath:t,name:"AbiEventSignatureEmptyTopicsError"})}}class K0 extends ${constructor(t,{docsPath:n}){super([`Encoded event signature "${t}" not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it.",`You can look up the signature here: https://4byte.sourcify.dev/?q=${t}.`].join(`
13
- `),{docsPath:n,name:"AbiEventSignatureNotFoundError"})}}class ri extends ${constructor(t,{docsPath:n}={}){super([`Event ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it."].join(`
14
- `),{docsPath:n,name:"AbiEventNotFoundError"})}}class Mt extends ${constructor(t,{docsPath:n}={}){super([`Function ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(`
15
- `),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class la extends ${constructor(t,{docsPath:n}){super([`Function "${t}" 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(`
16
- `),{docsPath:n,name:"AbiFunctionOutputsNotFoundError"})}}class Y0 extends ${constructor(t,{docsPath:n}){super([`Encoded function signature "${t}" 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://4byte.sourcify.dev/?q=${t}.`].join(`
17
- `),{docsPath:n,name:"AbiFunctionSignatureNotFoundError"})}}class J0 extends ${constructor(t,n){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${t.type}\` in \`${$e(t.abiItem)}\`, and`,`\`${n.type}\` in \`${$e(n.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let X0=class extends ${constructor({expectedSize:t,givenSize:n}){super(`Expected bytes${t}, got bytes${n}.`,{name:"BytesSizeMismatchError"})}};class cr extends ${constructor({abiItem:t,data:n,params:r,size:s}){super([`Data size of ${s} bytes is too small for non-indexed event parameters.`].join(`
18
- `),{metaMessages:[`Params: (${gr(r,{includeName:!0})})`,`Data: ${n} (${s} bytes)`],name:"DecodeLogDataMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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.abiItem=t,this.data=n,this.params=r,this.size=s}}class eo extends ${constructor({abiItem:t,param:n}){super([`Expected a topic for indexed event parameter${n.name?` "${n.name}"`:""} on event "${$e(t,{includeName:!0})}".`].join(`
19
- `),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=t}}class Q0 extends ${constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
20
- `),{docsPath:n,name:"InvalidAbiEncodingType"})}}class ed extends ${constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(`
21
- `),{docsPath:n,name:"InvalidAbiDecodingType"})}}let fa=class extends ${constructor(t){super([`Value "${t}" is not a valid array.`].join(`
22
- `),{name:"InvalidArrayError"})}};class td extends ${constructor(t){super([`"${t}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(`
23
- `),{name:"InvalidDefinitionTypeError"})}}class nd extends ${constructor(t){super(`Filter type "${t}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let ha=class extends ${constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}},pa=class extends ${constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}};class si extends ${constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} is expected to be ${n} ${r} long, but is ${t} ${r} long.`,{name:"InvalidBytesLengthError"})}}function Wt(e,{dir:t,size:n=32}={}){return typeof e=="string"?et(e,{dir:t,size:n}):rd(e,{dir:t,size:n})}function et(e,{dir:t,size:n=32}={}){if(n===null)return e;const r=e.replace("0x","");if(r.length>n*2)throw new pa({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function rd(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new pa({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const o=t==="right";r[o?s:n-s-1]=e[o?s:e.length-s-1]}return r}let to=class extends ${constructor({max:t,min:n,signed:r,size:s,value:o}){super(`Number "${o}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}},sd=class extends ${constructor(t){super(`Bytes value "${t}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}};class od extends ${constructor(t){super(`Hex value "${t}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let id=class extends ${constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}};function we(e,{dir:t="left"}={}){let n=typeof e=="string"?e.replace("0x",""):e,r=0;for(let s=0;s<n.length-1&&n[t==="left"?s:n.length-s-1].toString()==="0";s++)r++;return n=t==="left"?n.slice(r):n.slice(0,n.length-r),typeof e=="string"?(n.length===1&&t==="right"&&(n=`${n}0`),`0x${n.length%2===1?`0${n}`:n}`):n}function Ne(e,{size:t}){if(Z(e)>t)throw new id({givenSize:Z(e),maxSize:t})}function Q(e,t={}){const{signed:n}=t;t.size&&Ne(e,{size:t.size});const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,o=(1n<<BigInt(s)*8n-1n)-1n;return r<=o?r:r-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function ad(e,t={}){let n=e;if(t.size&&(Ne(n,{size:t.size}),n=we(n)),we(n)==="0x00")return!1;if(we(n)==="0x01")return!0;throw new od(n)}function Pe(e,t={}){const n=Q(e,t),r=Number(n);if(!Number.isSafeInteger(r))throw new to({max:`${Number.MAX_SAFE_INTEGER}`,min:`${Number.MIN_SAFE_INTEGER}`,signed:t.signed,size:t.size,value:`${n}n`});return r}const cd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function de(e,t={}){return typeof e=="number"||typeof e=="bigint"?j(e,t):typeof e=="string"?ln(e,t):typeof e=="boolean"?ba(e,t):Y(e,t)}function ba(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(Ne(n,{size:t.size}),Wt(n,{size:t.size})):n}function Y(e,t={}){let n="";for(let s=0;s<e.length;s++)n+=cd[e[s]];const r=`0x${n}`;return typeof t.size=="number"?(Ne(r,{size:t.size}),Wt(r,{dir:"right",size:t.size})):r}function j(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let o;r?n?o=(1n<<BigInt(r)*8n-1n)-1n:o=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(o=BigInt(Number.MAX_SAFE_INTEGER));const i=typeof o=="bigint"&&n?-o-1n:0;if(o&&s>o||s<i){const c=typeof e=="bigint"?"n":"";throw new to({max:o?`${o}${c}`:void 0,min:`${i}${c}`,signed:n,size:r,value:`${e}${c}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?Wt(a,{size:r}):a}const ud=new TextEncoder;function ln(e,t={}){const n=ud.encode(e);return Y(n,t)}const dd=new TextEncoder;function Zt(e,t={}){return typeof e=="number"||typeof e=="bigint"?fd(e,t):typeof e=="boolean"?ld(e,t):Fe(e)?Oe(e,t):lt(e,t)}function ld(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(Ne(n,{size:t.size}),Wt(n,{size:t.size})):n}const Ue={zero:48,nine:57,A:65,F:70,a:97,f:102};function oi(e){if(e>=Ue.zero&&e<=Ue.nine)return e-Ue.zero;if(e>=Ue.A&&e<=Ue.F)return e-(Ue.A-10);if(e>=Ue.a&&e<=Ue.f)return e-(Ue.a-10)}function Oe(e,t={}){let n=e;t.size&&(Ne(n,{size:t.size}),n=Wt(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,o=new Uint8Array(s);for(let i=0,a=0;i<s;i++){const c=oi(r.charCodeAt(a++)),u=oi(r.charCodeAt(a++));if(c===void 0||u===void 0)throw new $(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);o[i]=c*16+u}return o}function fd(e,t){const n=j(e,t);return Oe(n)}function lt(e,t={}){const n=dd.encode(e);return typeof t.size=="number"?(Ne(n,{size:t.size}),Wt(n,{dir:"right",size:t.size})):n}const er=BigInt(2**32-1),ii=BigInt(32);function hd(e,t=!1){return t?{h:Number(e&er),l:Number(e>>ii&er)}:{h:Number(e>>ii&er)|0,l:Number(e&er)|0}}function pd(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:a}=hd(e[o],t);[r[o],s[o]]=[i,a]}return[r,s]}const bd=(e,t,n)=>e<<n|t>>>32-n,md=(e,t,n)=>t<<n|e>>>32-n,yd=(e,t,n)=>t<<n-32|e>>>64-n,gd=(e,t,n)=>e<<n-32|t>>>64-n,St=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function wd(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function fn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function pt(e,...t){if(!wd(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function xd(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");fn(e.outputLen),fn(e.blockLen)}function Lt(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 ma(e,t){pt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function vd(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ut(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Wr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ze(e,t){return e<<32-t|e>>>t}const Ed=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Pd(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ad(e){for(let t=0;t<e.length;t++)e[t]=Pd(e[t]);return e}const ai=Ed?e=>e:Ad;function Id(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function wr(e){return typeof e=="string"&&(e=Id(e)),pt(e),e}function Cd(...e){let t=0;for(let r=0;r<e.length;r++){const s=e[r];pt(s),t+=s.length}const n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.length}return n}class no{}function ya(e){const t=r=>e().update(wr(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function $d(e=32){if(St&&typeof St.getRandomValues=="function")return St.getRandomValues(new Uint8Array(e));if(St&&typeof St.randomBytes=="function")return Uint8Array.from(St.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const Sd=BigInt(0),on=BigInt(1),Bd=BigInt(2),Td=BigInt(7),Nd=BigInt(256),kd=BigInt(113),ga=[],wa=[],xa=[];for(let e=0,t=on,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ga.push(2*(5*r+n)),wa.push((e+1)*(e+2)/2%64);let s=Sd;for(let o=0;o<7;o++)t=(t<<on^(t>>Td)*kd)%Nd,t&Bd&&(s^=on<<(on<<BigInt(o))-on);xa.push(s)}const va=pd(xa,!0),jd=va[0],zd=va[1],ci=(e,t,n)=>n>32?yd(e,t,n):bd(e,t,n),ui=(e,t,n)=>n>32?gd(e,t,n):md(e,t,n);function Rd(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,c=(i+2)%10,u=n[c],d=n[c+1],l=ci(u,d,1)^n[a],f=ui(u,d,1)^n[a+1];for(let p=0;p<50;p+=10)e[i+p]^=l,e[i+p+1]^=f}let s=e[2],o=e[3];for(let i=0;i<24;i++){const a=wa[i],c=ci(s,o,a),u=ui(s,o,a),d=ga[i];s=e[d],o=e[d+1],e[d]=c,e[d+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)n[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=jd[r],e[1]^=zd[r]}Ut(n)}class ro extends no{constructor(t,n,r,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,fn(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=vd(this.state)}clone(){return this._cloneInto()}keccak(){ai(this.state32),Rd(this.state32,this.rounds),ai(this.state32),this.posOut=0,this.pos=0}update(t){Lt(this),t=wr(t),pt(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let a=0;a<i;a++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Lt(this,!1),pt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return fn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(ma(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Ut(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new ro(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Fd=(e,t,n)=>ya(()=>new ro(t,e,n)),Ea=Fd(1,136,256/8);function te(e,t){const n=t||"hex",r=Ea(Fe(e,{strict:!1})?Zt(e):e);return n==="bytes"?r:de(r)}const Od=e=>te(Zt(e));function Md(e){return Od(e)}function Ld(e){let t=!0,n="",r=0,s="",o=!1;for(let i=0;i<e.length;i++){const a=e[i];if(["(",")",","].includes(a)&&(t=!0),a==="("&&r++,a===")"&&r--,!!t){if(r===0){if(a===" "&&["event","function",""].includes(s))s="";else if(s+=a,a===")"){o=!0;break}continue}if(a===" "){e[i-1]!==","&&n!==","&&n!==",("&&(n="",t=!1);continue}s+=a,n+=a}}if(!o)throw new $("Unable to normalize signature.");return s}const Ud=e=>{const t=typeof e=="string"?e:ar(e);return Ld(t)};function Pa(e){return Md(Ud(e))}const xr=Pa;let oe=class extends ${constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}},Kt=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&(super.delete(t),super.set(t,n)),n}set(t,n){if(super.has(t)&&super.delete(t),super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=super.keys().next().value;r!==void 0&&super.delete(r)}return this}};const Zr=new Kt(8192);function Ln(e,t){if(Zr.has(`${e}.${t}`))return Zr.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=te(lt(n),"bytes"),s=n.split("");for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&s[i]&&(s[i]=s[i].toUpperCase()),(r[i>>1]&15)>=8&&s[i+1]&&(s[i+1]=s[i+1].toUpperCase());const o=`0x${s.join("")}`;return Zr.set(`${e}.${t}`,o),o}function _t(e,t){if(!J(e,{strict:!1}))throw new oe({address:e});return Ln(e,t)}const _d=/^0x[a-fA-F0-9]{40}$/,Kr=new Kt(8192);function J(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Kr.has(r))return Kr.get(r);const s=_d.test(e)?e.toLowerCase()===e?!0:n?Ln(e)===e:!0:!1;return Kr.set(r,s),s}function ne(e){return typeof e[0]=="string"?ke(e):Dd(e)}function Dd(e){let t=0;for(const s of e)t+=s.length;const n=new Uint8Array(t);let r=0;for(const s of e)n.set(s,r),r+=s.length;return n}function ke(e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function tt(e,t,n,{strict:r}={}){return Fe(e,{strict:!1})?xs(e,t,n,{strict:r}):Ca(e,t,n,{strict:r})}function Aa(e,t){if(typeof t=="number"&&t>0&&t>Z(e)-1)throw new ha({offset:t,position:"start",size:Z(e)})}function Ia(e,t,n){if(typeof t=="number"&&typeof n=="number"&&Z(e)!==n-t)throw new ha({offset:n,position:"end",size:Z(e)})}function Ca(e,t,n,{strict:r}={}){Aa(e,t);const s=e.slice(t,n);return r&&Ia(s,t,n),s}function xs(e,t,n,{strict:r}={}){Aa(e,t);const s=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return r&&Ia(s,t,n),s}const Gd=/^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)?$/;function At(e,t){if(e.length!==t.length)throw new V0({expectedLength:e.length,givenLength:t.length});const n=qd({params:e,values:t}),r=oo(n);return r.length===0?"0x":r}function qd({params:e,values:t}){const n=[];for(let r=0;r<e.length;r++)n.push(so({param:e[r],value:t[r]}));return n}function so({param:e,value:t}){const n=io(e.type);if(n){const[r,s]=n;return Vd(t,{length:r,param:{...e,type:s}})}if(e.type==="tuple")return Jd(t,{param:e});if(e.type==="address")return Hd(t);if(e.type==="bool")return Zd(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const r=e.type.startsWith("int"),[,,s="256"]=$a.exec(e.type)??[];return Kd(t,{signed:r,size:Number(s)})}if(e.type.startsWith("bytes"))return Wd(t,{param:e});if(e.type==="string")return Yd(t);throw new Q0(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function oo(e){let t=0;for(let o=0;o<e.length;o++){const{dynamic:i,encoded:a}=e[o];i?t+=32:t+=Z(a)}const n=[],r=[];let s=0;for(let o=0;o<e.length;o++){const{dynamic:i,encoded:a}=e[o];i?(n.push(j(t+s,{size:32})),r.push(a),s+=Z(a)):n.push(a)}return ne([...n,...r])}function Hd(e){if(!J(e))throw new oe({address:e});return{dynamic:!1,encoded:et(e.toLowerCase())}}function Vd(e,{length:t,param:n}){const r=t===null;if(!Array.isArray(e))throw new fa(e);if(!r&&e.length!==t)throw new q0({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let s=!1;const o=[];for(let i=0;i<e.length;i++){const a=so({param:n,value:e[i]});a.dynamic&&(s=!0),o.push(a)}if(r||s){const i=oo(o);if(r){const a=j(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?ne([a,i]):a}}if(s)return{dynamic:!0,encoded:i}}return{dynamic:!1,encoded:ne(o.map(({encoded:i})=>i))}}function Wd(e,{param:t}){const[,n]=t.type.split("bytes"),r=Z(e);if(!n){let s=e;return r%32!==0&&(s=et(s,{dir:"right",size:Math.ceil((e.length-2)/2/32)*32})),{dynamic:!0,encoded:ne([et(j(r,{size:32})),s])}}if(r!==Number.parseInt(n,10))throw new H0({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:et(e,{dir:"right"})}}function Zd(e){if(typeof e!="boolean")throw new $(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:et(ba(e))}}function Kd(e,{signed:t,size:n=256}){if(typeof n=="number"){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new to({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:j(e,{size:32,signed:t})}}function Yd(e){const t=ln(e),n=Math.ceil(Z(t)/32),r=[];for(let s=0;s<n;s++)r.push(et(tt(t,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:ne([et(j(Z(t),{size:32})),...r])}}function Jd(e,{param:t}){let n=!1;const r=[];for(let s=0;s<t.components.length;s++){const o=t.components[s],i=Array.isArray(e)?s:o.name,a=so({param:o,value:e[i]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?oo(r):ne(r.map(({encoded:s})=>s))}}function io(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const Un=e=>tt(Pa(e),0,4);function It(e){const{abi:t,args:n=[],name:r}=e,s=Fe(r,{strict:!1}),o=t.filter(a=>s?a.type==="function"?Un(a)===r:a.type==="event"?xr(a)===r:!1:"name"in a&&a.name===r);if(o.length===0)return;if(o.length===1)return o[0];let i;for(const a of o){if(!("inputs"in a))continue;if(!n||n.length===0){if(!a.inputs||a.inputs.length===0)return a;continue}if(!a.inputs||a.inputs.length===0||a.inputs.length!==n.length)continue;if(n.every((u,d)=>{const l="inputs"in a&&a.inputs[d];return l?vs(u,l):!1})){if(i&&"inputs"in i&&i.inputs){const u=Sa(a.inputs,i.inputs,n);if(u)throw new J0({abiItem:a,type:u[0]},{abiItem:i,type:u[1]})}i=a}}return i||o[0]}function vs(e,t){const n=typeof e,r=t.type;switch(r){case"address":return J(e,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in t?Object.values(t.components).every((s,o)=>n==="object"&&vs(Object.values(e)[o],s)):/^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)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||e instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(e)&&e.every(s=>vs(s,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Sa(e,t,n){for(const r in e){const s=e[r],o=t[r];if(s.type==="tuple"&&o.type==="tuple"&&"components"in s&&"components"in o)return Sa(s.components,o.components,n[r]);const i=[s.type,o.type];if(i.includes("address")&&i.includes("bytes20")?!0:i.includes("address")&&i.includes("string")?J(n[r],{strict:!1}):i.includes("address")&&i.includes("bytes")?J(n[r],{strict:!1}):!1)return i}}const di="/docs/contract/encodeEventTopics";function _n(e){var c;const{abi:t,eventName:n,args:r}=e;let s=t[0];if(n){const u=It({abi:t,name:n});if(!u)throw new ri(n,{docsPath:di});s=u}if(s.type!=="event")throw new ri(void 0,{docsPath:di});let o=[];if(r&&"inputs"in s){const u=(c=s.inputs)==null?void 0:c.filter(l=>"indexed"in l&&l.indexed),d=Array.isArray(r)?r:Object.values(r).length>0?(u==null?void 0:u.map(l=>r[l.name]))??[]:[];d.length>0&&(o=(u==null?void 0:u.map((l,f)=>Array.isArray(d[f])?d[f].map((p,h)=>li({param:l,value:d[f][h]})):typeof d[f]<"u"&&d[f]!==null?li({param:l,value:d[f]}):null))??[])}if(s.anonymous)return o;const i=$e(s);return[xr(i),...o]}function li({param:e,value:t}){if(e.type==="string"||e.type==="bytes")return te(Zt(t));if(e.type==="tuple"||e.type.match(/^(.*)\[(\d+)?\]$/))throw new nd(e.type);return At([e],[t])}function vr(e,{method:t}){var r,s;const n={};return e.transport.type==="fallback"&&((s=(r=e.transport).onResponse)==null||s.call(r,({method:o,response:i,status:a,transport:c})=>{a==="success"&&t===o&&(n[i]=c.request)})),(o=>n[o]||e.request)}async function Ba(e,t){const{address:n,abi:r,args:s,eventName:o,fromBlock:i,strict:a,toBlock:c}=t,u=vr(e,{method:"eth_newFilter"}),d=o?_n({abi:r,args:s,eventName:o}):void 0,l=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:typeof i=="bigint"?j(i):i,toBlock:typeof c=="bigint"?j(c):c,topics:d}]});return{abi:r,args:s,eventName:o,id:l,request:u(l),strict:!!a,type:"event"}}function K(e){return typeof e=="string"?{address:e,type:"json-rpc"}:e}const fi="/docs/contract/encodeFunctionData";function Xd(e){const{abi:t,args:n,functionName:r}=e;let s=t[0];if(r){const o=It({abi:t,args:n,name:r});if(!o)throw new Mt(r,{docsPath:fi});s=o}if(s.type!=="function")throw new Mt(void 0,{docsPath:fi});return{abi:[s],functionName:Un($e(s))}}function he(e){const{args:t}=e,{abi:n,functionName:r}=(()=>{var a;return e.abi.length===1&&((a=e.functionName)!=null&&a.startsWith("0x"))?e:Xd(e)})(),s=n[0],o=r,i="inputs"in s&&s.inputs?At(s.inputs,t??[]):void 0;return ke([o,i??"0x"])}const Qd={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."},Ta={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},el={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};let hi=class extends ${constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},Na=class extends ${constructor({length:t,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},tl=class extends ${constructor({count:t,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}};const nl={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 tl({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Na({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new hi({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 hi({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,e&255),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 ao(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(nl);return n.bytes=e,n.dataView=new DataView(e.buffer??e,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function rl(e,t={}){typeof t.size<"u"&&Ne(e,{size:t.size});const n=Y(e,t);return Q(n,t)}function sl(e,t={}){let n=e;if(typeof t.size<"u"&&(Ne(n,{size:t.size}),n=we(n)),n.length>1||n[0]>1)throw new sd(n);return!!n[0]}function He(e,t={}){typeof t.size<"u"&&Ne(e,{size:t.size});const n=Y(e,t);return Pe(n,t)}function ol(e,t={}){let n=e;return typeof t.size<"u"&&(Ne(n,{size:t.size}),n=we(n,{dir:"right"})),new TextDecoder().decode(n)}function Dn(e,t){const n=typeof t=="string"?Oe(t):t,r=ao(n);if(Z(n)===0&&e.length>0)throw new Mn;if(Z(t)&&Z(t)<32)throw new ua({data:typeof t=="string"?t:Y(t),params:e,size:Z(t)});let s=0;const o=[];for(let i=0;i<e.length;++i){const a=e[i];r.setPosition(s);const[c,u]=zt(r,a,{staticPosition:0});s+=u,o.push(c)}return o}function zt(e,t,{staticPosition:n}){const r=io(t.type);if(r){const[s,o]=r;return al(e,{...t,type:o},{length:s,staticPosition:n})}if(t.type==="tuple")return ll(e,t,{staticPosition:n});if(t.type==="address")return il(e);if(t.type==="bool")return cl(e);if(t.type.startsWith("bytes"))return ul(e,t,{staticPosition:n});if(t.type.startsWith("uint")||t.type.startsWith("int"))return dl(e,t);if(t.type==="string")return fl(e,{staticPosition:n});throw new ed(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const pi=32,Es=32;function il(e){const t=e.readBytes(32);return[Ln(Y(Ca(t,-20))),32]}function al(e,t,{length:n,staticPosition:r}){if(!n){const i=He(e.readBytes(Es)),a=r+i,c=a+pi;e.setPosition(a);const u=He(e.readBytes(pi)),d=hn(t);let l=0;const f=[];for(let p=0;p<u;++p){e.setPosition(c+(d?p*32:l));const[h,m]=zt(e,t,{staticPosition:c});l+=m,f.push(h)}return e.setPosition(r+32),[f,32]}if(hn(t)){const i=He(e.readBytes(Es)),a=r+i,c=[];for(let u=0;u<n;++u){e.setPosition(a+u*32);const[d]=zt(e,t,{staticPosition:a});c.push(d)}return e.setPosition(r+32),[c,32]}let s=0;const o=[];for(let i=0;i<n;++i){const[a,c]=zt(e,t,{staticPosition:r+s});s+=c,o.push(a)}return[o,s]}function cl(e){return[sl(e.readBytes(32),{size:32}),32]}function ul(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const i=He(e.readBytes(32));e.setPosition(n+i);const a=He(e.readBytes(32));if(a===0)return e.setPosition(n+32),["0x",32];const c=e.readBytes(a);return e.setPosition(n+32),[Y(c),32]}return[Y(e.readBytes(Number.parseInt(s,10),32)),32]}function dl(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?rl(s,{signed:n}):He(s,{signed:n}),32]}function ll(e,t,{staticPosition:n}){const r=t.components.length===0||t.components.some(({name:i})=>!i),s=r?[]:{};let o=0;if(hn(t)){const i=He(e.readBytes(Es)),a=n+i;for(let c=0;c<t.components.length;++c){const u=t.components[c];e.setPosition(a+o);const[d,l]=zt(e,u,{staticPosition:a});o+=l,s[r?c:u==null?void 0:u.name]=d}return e.setPosition(n+32),[s,32]}for(let i=0;i<t.components.length;++i){const a=t.components[i],[c,u]=zt(e,a,{staticPosition:n});s[r?i:a==null?void 0:a.name]=c,o+=u}return[s,o]}function fl(e,{staticPosition:t}){const n=He(e.readBytes(32)),r=t+n;e.setPosition(r);const s=He(e.readBytes(32));if(s===0)return e.setPosition(t+32),["",32];const o=e.readBytes(s,32),i=ol(we(o));return e.setPosition(t+32),[i,32]}function hn(e){var r;const{type:t}=e;if(t==="string"||t==="bytes"||t.endsWith("[]"))return!0;if(t==="tuple")return(r=e.components)==null?void 0:r.some(hn);const n=io(e.type);return!!(n&&hn({...e,type:n[1]}))}function hl(e){const{abi:t,data:n,cause:r}=e,s=tt(n,0,4);if(s==="0x")throw new Mn({cause:r});const i=[...t||[],Ta,el].find(a=>a.type==="error"&&s===Un($e(a)));if(!i)throw new da(s,{docsPath:"/docs/contract/decodeErrorResult",cause:r});return{abiItem:i,args:"inputs"in i&&i.inputs&&i.inputs.length>0?Dn(i.inputs,tt(n,4)):void 0,errorName:i.name}}const ie=(e,t,n)=>JSON.stringify(e,(r,s)=>typeof s=="bigint"?s.toString():s,n);function ka({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((s,o)=>`${r&&s.name?`${s.name}: `:""}${typeof t[o]=="object"?ie(t[o]):t[o]}`).join(", ")})`}const ja={gwei:9,wei:18},pl={ether:-9,wei:9};function za(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[s,o]=[n.slice(0,n.length-t),n.slice(n.length-t)];return o=o.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${o?`.${o}`:""}`}function co(e,t="wei"){return za(e,ja[t])}function le(e,t="wei"){return za(e,pl[t])}class bl extends ${constructor({address:t}){super(`State for account "${t}" is set multiple times.`,{name:"AccountStateConflictError"})}}class ml extends ${constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function bi(e){return e.reduce((t,{slot:n,value:r})=>`${t} ${n}: ${r}
24
- `,"")}function yl(e){return e.reduce((t,{address:n,...r})=>{let s=`${t} ${n}:
25
- `;return r.nonce&&(s+=` nonce: ${r.nonce}
26
- `),r.balance&&(s+=` balance: ${r.balance}
27
- `),r.code&&(s+=` code: ${r.code}
28
- `),r.state&&(s+=` state:
29
- `,s+=bi(r.state)),r.stateDiff&&(s+=` stateDiff:
30
- `,s+=bi(r.stateDiff)),s},` State Override:
31
- `).slice(0,-1)}function Gn(e){const t=Object.entries(e).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=t.reduce((r,[s])=>Math.max(r,s.length),0);return t.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(`
32
- `)}class gl extends ${constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class wl extends ${constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Gn(t),"}","","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 xl extends ${constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}class vl extends ${constructor(t,{account:n,docsPath:r,chain:s,data:o,gas:i,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:d,to:l,value:f}){var h;const p=Gn({chain:s&&`${s==null?void 0:s.name} (id: ${s==null?void 0:s.id})`,from:n==null?void 0:n.address,to:l,value:typeof f<"u"&&`${co(f)} ${((h=s==null?void 0:s.nativeCurrency)==null?void 0:h.symbol)||"ETH"}`,data:o,gas:i,gasPrice:typeof a<"u"&&`${le(a)} gwei`,maxFeePerGas:typeof c<"u"&&`${le(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${le(u)} gwei`,nonce:d});super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Request Arguments:",p].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class Ra extends ${constructor({blockHash:t,blockNumber:n,blockTag:r,hash:s,index:o}){let i="Transaction";r&&o!==void 0&&(i=`Transaction at block time "${r}" at index "${o}"`),t&&o!==void 0&&(i=`Transaction at block hash "${t}" at index "${o}"`),n&&o!==void 0&&(i=`Transaction at block number "${n}" at index "${o}"`),s&&(i=`Transaction with hash "${s}"`),super(`${i} could not be found.`,{name:"TransactionNotFoundError"})}}class Fa extends ${constructor({hash:t}){super(`Transaction receipt with hash "${t}" could not be found. The Transaction may not be processed on a block yet.`,{name:"TransactionReceiptNotFoundError"})}}class Ps extends ${constructor({receipt:t}){super(`Transaction with hash "${t.transactionHash}" reverted.`,{metaMessages:['The receipt marked the transaction as "reverted". This could mean that the function on the contract you are trying to call threw an error.'," ","You can attempt to extract the revert reason by:","- calling the `simulateContract` or `simulateCalls` Action with the `abi` and `functionName` of the contract","- using the `call` Action with raw `data`"],name:"TransactionReceiptRevertedError"}),Object.defineProperty(this,"receipt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.receipt=t}}class El extends ${constructor({hash:t}){super(`Timed out while waiting for transaction with hash "${t}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}const Pl=e=>e;function bt(e){if(e!=null&&e.reason)return e.reason;if(typeof DOMException=="function")return new DOMException("This operation was aborted","AbortError");const t=new Error("This operation was aborted");return t.name="AbortError",t}function Er(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}const Oa=e=>{try{const t=new URL(e);return!t.username&&!t.password?e:(t.username="",t.password="",t.toString())}catch{return e}};class Ma extends ${constructor(t,{account:n,docsPath:r,chain:s,data:o,gas:i,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:d,to:l,value:f,stateOverride:p}){var x;const h=n?K(n):void 0;let m=Gn({from:h==null?void 0:h.address,to:l,value:typeof f<"u"&&`${co(f)} ${((x=s==null?void 0:s.nativeCurrency)==null?void 0:x.symbol)||"ETH"}`,data:o,gas:i,gasPrice:typeof a<"u"&&`${le(a)} gwei`,maxFeePerGas:typeof c<"u"&&`${le(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${le(u)} gwei`,nonce:d});p&&(m+=`
33
- ${yl(p)}`),super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Raw Call Arguments:",m].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class La extends ${constructor(t,{abi:n,args:r,contractAddress:s,docsPath:o,functionName:i,sender:a}){const c=It({abi:n,args:r,name:i}),u=c?ka({abiItem:c,args:r,includeFunctionName:!1,includeName:!1}):void 0,d=c?$e(c,{includeName:!0}):void 0,l=Gn({address:s&&Pl(s),function:d,args:u&&u!=="()"&&`${[...Array((i==null?void 0:i.length)??0).keys()].map(()=>" ").join("")}${u}`,sender:a});super(t.shortMessage||`An unknown error occurred while executing the contract function "${i}".`,{cause:t,docsPath:o,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],l&&"Contract Call:",l].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=n,this.args=r,this.cause=t,this.contractAddress=s,this.functionName=i,this.sender=a}}class As extends ${constructor({abi:t,data:n,functionName:r,message:s,cause:o}){let i,a,c,u;if(n&&n!=="0x")try{a=hl({abi:t,data:n,cause:o});const{abiItem:l,errorName:f,args:p}=a;if(f==="Error")u=p[0];else if(f==="Panic"){const[h]=p;u=Qd[h]}else{const h=l?$e(l,{includeName:!0}):void 0,m=l&&p?ka({abiItem:l,args:p,includeFunctionName:!1,includeName:!1}):void 0;c=[h?`Error: ${h}`:"",m&&m!=="()"?` ${[...Array((f==null?void 0:f.length)??0).keys()].map(()=>" ").join("")}${m}`:""]}}catch(l){i=l}else s&&(u=s);let d;i instanceof da&&(d=i.signature,c=[`Unable to decode signature "${d}" 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://4byte.sourcify.dev/?q=${d}.`]),super(u&&u!=="execution reverted"||d?[`The contract function "${r}" reverted with the following ${d?"signature":"reason"}:`,u||d].join(`
34
- `):`The contract function "${r}" reverted.`,{cause:i??o,metaMessages:c,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=a,this.raw=n,this.reason=u,this.signature=d}}class Al extends ${constructor({functionName:t,cause:n}){super(`The contract function "${t}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${t}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError",cause:n})}}class Il extends ${constructor({factory:t}){super(`Deployment for counterfactual contract call failed${t?` for factory "${t}".`:""}`,{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 Pr extends ${constructor({data:t,message:n}){super(n||"",{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=t}}class Ua extends ${constructor({body:t,cause:n,details:r,headers:s,status:o,url:i}){super("HTTP request failed.",{cause:n,details:r,metaMessages:[o&&`Status: ${o}`,`URL: ${Oa(i)}`,t&&`Request body: ${ie(t)}`].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=t,this.headers=s,this.status=o,this.url=i}}class _a extends ${constructor({body:t,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${Oa(r)}`,`Request body: ${ie(t)}`],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}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n.code,this.data=n.data,this.url=r}}const Cl=-1;class pe extends ${constructor(t,{code:n,docsPath:r,metaMessages:s,name:o,shortMessage:i}){super(i,{cause:t,docsPath:r,metaMessages:s||(t==null?void 0:t.metaMessages),name:o||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=o||t.name,this.code=t instanceof _a?t.code:n??Cl}}class be extends pe{constructor(t,n){super(t,n),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n.data}}class pn extends pe{constructor(t){super(t,{code:pn.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(pn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class bn extends pe{constructor(t){super(t,{code:bn.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(bn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class mn extends pe{constructor(t,{method:n}={}){super(t,{code:mn.code,name:"MethodNotFoundRpcError",shortMessage:`The method${n?` "${n}"`:""} does not exist / is not available.`})}}Object.defineProperty(mn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class yn extends pe{constructor(t){super(t,{code:yn.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
35
- `)})}}Object.defineProperty(yn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class mt extends pe{constructor(t){super(t,{code:mt.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(mt,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class nt extends pe{constructor(t){super(t,{code:nt.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
36
- `)})}}Object.defineProperty(nt,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class gn extends pe{constructor(t){super(t,{code:gn.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(gn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class wn extends pe{constructor(t){super(t,{code:wn.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(wn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class xn extends pe{constructor(t){super(t,{code:xn.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(xn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class ut extends pe{constructor(t,{method:n}={}){super(t,{code:ut.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${n?` "${n}"`:""} is not supported.`})}}Object.defineProperty(ut,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class Dt extends pe{constructor(t){super(t,{code:Dt.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(Dt,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class vn extends pe{constructor(t){super(t,{code:vn.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(vn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Rt extends be{constructor(t){super(t,{code:Rt.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(Rt,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class En extends be{constructor(t){super(t,{code:En.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(En,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Pn extends be{constructor(t,{method:n}={}){super(t,{code:Pn.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${n?` " ${n}"`:""}.`})}}Object.defineProperty(Pn,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class An extends be{constructor(t){super(t,{code:An.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(An,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class In extends be{constructor(t){super(t,{code:In.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(In,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Cn extends be{constructor(t){super(t,{code:Cn.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Cn,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class Gt extends be{constructor(t){super(t,{code:Gt.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(Gt,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class $n extends be{constructor(t){super(t,{code:$n.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty($n,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class Sn extends be{constructor(t){super(t,{code:Sn.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(Sn,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class Bn extends be{constructor(t){super(t,{code:Bn.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(Bn,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Tn extends be{constructor(t){super(t,{code:Tn.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Tn,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Nn extends be{constructor(t){super(t,{code:Nn.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Nn,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class qt extends be{constructor(t){super(t,{code:qt.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(qt,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class kn extends be{constructor(t){super(t,{code:kn.code,name:"WalletConnectSessionSettlementError",shortMessage:"WalletConnect session settlement failed."})}}Object.defineProperty(kn,"code",{enumerable:!0,configurable:!0,writable:!0,value:7e3});class $l extends pe{constructor(t){super(t,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Sl=3;function yt(e,{abi:t,address:n,args:r,docsPath:s,functionName:o,sender:i}){const a=e instanceof Pr?e:e instanceof $?e.walk(h=>"data"in h)||e.walk():{},{code:c,data:u,details:d,message:l,shortMessage:f}=a,p=e instanceof Mn?new Al({functionName:o,cause:e}):[Sl,mt.code].includes(c)&&(u||d||l||f)||c===nt.code&&d==="execution reverted"&&u?new As({abi:t,data:typeof u=="object"?u.data:u,functionName:o,message:a instanceof _a?d:f??l,cause:e}):e;return new La(p,{abi:t,args:r,contractAddress:n,docsPath:s,functionName:o,sender:i})}function Bl(e){const t=te(`0x${e.substring(4)}`).substring(26);return Ln(`0x${t}`)}async function Tl({hash:e,signature:t}){const n=Fe(e)?e:de(e),{secp256k1:r}=await Zi(async()=>{const{secp256k1:i}=await Promise.resolve().then(()=>w1);return{secp256k1:i}},void 0);return`0x${(()=>{if(typeof t=="object"&&"r"in t&&"s"in t){const{r:u,s:d,v:l,yParity:f}=t,p=Number(f??l),h=mi(p);return new r.Signature(Q(u),Q(d)).addRecoveryBit(h)}const i=Fe(t)?t:de(t);if(Z(i)!==65)throw new Error("invalid signature length");const a=Pe(`0x${i.slice(130)}`),c=mi(a);return r.Signature.fromCompact(i.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function mi(e){if(e===0||e===1)return e;if(e===27)return 0;if(e===28)return 1;throw new Error("Invalid yParityOrV value")}async function Is({hash:e,signature:t}){return Bl(await Tl({hash:e,signature:t}))}function rt(e,t="hex"){const n=Da(e),r=ao(new Uint8Array(n.length));return n.encode(r),t==="hex"?Y(r.bytes):r.bytes}function Da(e){return Array.isArray(e)?Nl(e.map(t=>Da(t))):kl(e)}function Nl(e){const t=e.reduce((s,o)=>s+o.length,0),n=Ga(t);return{length:t<=55?1+t:1+n+t,encode(s){t<=55?s.pushByte(192+t):(s.pushByte(247+n),n===1?s.pushUint8(t):n===2?s.pushUint16(t):n===3?s.pushUint24(t):s.pushUint32(t));for(const{encode:o}of e)o(s)}}}function kl(e){const t=typeof e=="string"?Oe(e):e,n=Ga(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length,encode(s){t.length===1&&t[0]<128?s.pushBytes(t):t.length<=55?(s.pushByte(128+t.length),s.pushBytes(t)):(s.pushByte(183+n),n===1?s.pushUint8(t.length):n===2?s.pushUint16(t.length):n===3?s.pushUint24(t.length):s.pushUint32(t.length),s.pushBytes(t))}}}function Ga(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new $("Length is too large.")}function jl(e){const{chainId:t,nonce:n,to:r}=e,s=e.contractAddress??e.address,o=te(ke(["0x05",rt([t?j(t):"0x",s,n?j(n):"0x"])]));return r==="bytes"?Oe(o):o}async function Ar(e){const{authorization:t,signature:n}=e;return Is({hash:jl(t),signature:n??t})}class zl extends ${constructor(t,{account:n,docsPath:r,chain:s,data:o,gas:i,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:d,to:l,value:f}){var h;const p=Gn({from:n==null?void 0:n.address,to:l,value:typeof f<"u"&&`${co(f)} ${((h=s==null?void 0:s.nativeCurrency)==null?void 0:h.symbol)||"ETH"}`,data:o,gas:i,gasPrice:typeof a<"u"&&`${le(a)} gwei`,maxFeePerGas:typeof c<"u"&&`${le(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${le(u)} gwei`,nonce:d});super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Estimate Gas Arguments:",p].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class Nt extends ${constructor({cause:t,message:n}={}){var s;const r=(s=n==null?void 0:n.replace("execution reverted: ",""))==null?void 0:s.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}}Object.defineProperty(Nt,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(Nt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class gt extends ${constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${le(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(gt,"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 Cs extends ${constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${le(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}}Object.defineProperty(Cs,"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 $s extends ${constructor({cause:t,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}}Object.defineProperty($s,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Ss extends ${constructor({cause:t,nonce:n}={}){super([`Nonce provided for the transaction ${n?`(${n}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
37
- `),{cause:t,name:"NonceTooLowError"})}}Object.defineProperty(Ss,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Bs extends ${constructor({cause:t,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}}Object.defineProperty(Bs,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Ts extends ${constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
38
- `),{cause:t,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(Ts,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Ns extends ${constructor({cause:t,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(Ns,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class ks extends ${constructor({cause:t,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(ks,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class js extends ${constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(js,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class jn extends ${constructor({cause:t,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${le(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${le(r)} gwei`:""}).`].join(`
39
- `),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(jn,"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 qn extends ${constructor({cause:t}){super(`An error occurred while executing: ${t==null?void 0:t.shortMessage}`,{cause:t,name:"UnknownNodeError"})}}function Ir(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof $?e.walk(s=>(s==null?void 0:s.code)===Nt.code):e;return r instanceof $?new Nt({cause:e,message:r.details}):Nt.nodeMessage.test(n)?new Nt({cause:e,message:e.details}):gt.nodeMessage.test(n)?new gt({cause:e,maxFeePerGas:t==null?void 0:t.maxFeePerGas}):Cs.nodeMessage.test(n)?new Cs({cause:e,maxFeePerGas:t==null?void 0:t.maxFeePerGas}):$s.nodeMessage.test(n)?new $s({cause:e,nonce:t==null?void 0:t.nonce}):Ss.nodeMessage.test(n)?new Ss({cause:e,nonce:t==null?void 0:t.nonce}):Bs.nodeMessage.test(n)?new Bs({cause:e,nonce:t==null?void 0:t.nonce}):Ts.nodeMessage.test(n)?new Ts({cause:e}):Ns.nodeMessage.test(n)?new Ns({cause:e,gas:t==null?void 0:t.gas}):ks.nodeMessage.test(n)?new ks({cause:e,gas:t==null?void 0:t.gas}):js.nodeMessage.test(n)?new js({cause:e}):jn.nodeMessage.test(n)?new jn({cause:e,maxFeePerGas:t==null?void 0:t.maxFeePerGas,maxPriorityFeePerGas:t==null?void 0:t.maxPriorityFeePerGas}):new qn({cause:e})}function Rl(e,{docsPath:t,...n}){const r=(()=>{const s=Ir(e,n);return s instanceof qn?e:s})();return new zl(r,{docsPath:t,...n})}function Yt(e,{format:t}){if(!t)return{};const n={};function r(o){const i=Object.keys(o);for(const a of i)a in e&&(n[a]=e[a]),o[a]&&typeof o[a]=="object"&&!Array.isArray(o[a])&&r(o[a])}const s=t(e||{});return r(s),n}function uo(e,t){return({exclude:n,format:r})=>({exclude:n,format:(s,o)=>{const i=t(s,o);if(n)for(const a of n)delete i[a];return{...i,...r(s,o)}},type:e})}const Fl={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function st(e,t){const n={};return typeof e.authorizationList<"u"&&(n.authorizationList=Ol(e.authorizationList)),typeof e.accessList<"u"&&(n.accessList=e.accessList),typeof e.blobVersionedHashes<"u"&&(n.blobVersionedHashes=e.blobVersionedHashes),typeof e.blobs<"u"&&(typeof e.blobs[0]!="string"?n.blobs=e.blobs.map(r=>Y(r)):n.blobs=e.blobs),typeof e.data<"u"&&(n.data=e.data),e.account&&(n.from=e.account.address),typeof e.from<"u"&&(n.from=e.from),typeof e.gas<"u"&&(n.gas=j(e.gas)),typeof e.gasPrice<"u"&&(n.gasPrice=j(e.gasPrice)),typeof e.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=j(e.maxFeePerBlobGas)),typeof e.maxFeePerGas<"u"&&(n.maxFeePerGas=j(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=j(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(n.nonce=j(e.nonce)),typeof e.to<"u"&&(n.to=e.to),typeof e.type<"u"&&(n.type=Fl[e.type]),typeof e.value<"u"&&(n.value=j(e.value)),n}function Ol(e){return e.map(t=>({address:t.address,r:t.r?j(BigInt(t.r)):t.r,s:t.s?j(BigInt(t.s)):t.s,chainId:j(t.chainId),nonce:j(t.nonce),...typeof t.yParity<"u"?{yParity:j(t.yParity)}:{},...typeof t.v<"u"&&typeof t.yParity>"u"?{v:j(t.v)}:{}}))}function yi(e){if(!(!e||e.length===0))return e.reduce((t,{slot:n,value:r})=>{if(n.length!==66)throw new si({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new si({size:r.length,targetSize:66,type:"hex"});return t[n]=r,t},{})}function Ml(e){const{balance:t,nonce:n,state:r,stateDiff:s,code:o}=e,i={};if(o!==void 0&&(i.code=o),t!==void 0&&(i.balance=j(t)),n!==void 0&&(i.nonce=j(n)),r!==void 0&&(i.state=yi(r)),s!==void 0){if(i.state)throw new ml;i.stateDiff=yi(s)}return i}function lo(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!J(n,{strict:!1}))throw new oe({address:n});if(t[n])throw new bl({address:n});t[n]=Ml(r)}return t}const Cr=2n**256n-1n;function Ye(e){const{account:t,maxFeePerGas:n,maxPriorityFeePerGas:r,to:s}=e,o=t?K(t):void 0;if(o&&!J(o.address))throw new oe({address:o.address});if(s&&!J(s))throw new oe({address:s});if(n&&n>Cr)throw new gt({maxFeePerGas:n});if(r&&n&&r>n)throw new jn({maxFeePerGas:n,maxPriorityFeePerGas:r})}class qa extends ${constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class fo extends ${constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class Ll extends ${constructor({maxPriorityFeePerGas:t}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${le(t)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class ho extends ${constructor({blockHash:t,blockNumber:n}){let r="Block";t&&(r=`Block at hash "${t}"`),n&&(r=`Block at number "${n}"`),super(`${r} could not be found.`,{name:"BlockNotFoundError"})}}const Ha={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Hn(e,t){const n={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,...e.blockTimestamp!=null&&{blockTimestamp:BigInt(e.blockTimestamp)},chainId:e.chainId?Pe(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?Pe(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Ha[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&&(n.authorizationList=_l(e.authorizationList)),n.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof n.v=="bigint"){if(n.v===0n||n.v===27n)return 0;if(n.v===1n||n.v===28n)return 1;if(n.v>=35n)return n.v%2n===0n?1:0}})(),n.type==="legacy"&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),n.type==="eip2930"&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),n.type==="eip1559"&&delete n.maxFeePerBlobGas,n}const Ul=uo("transaction",Hn);function _l(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function po(e,t){const n=(e.transactions??[]).map(r=>typeof r=="string"?r:Hn(r));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:n,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const Dl=uo("block",po);async function Ce(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",includeTransactions:s}={}){var u,d,l;const o=s??!1,i=n!==void 0?j(n):void 0;let a=null;if(t?a=await e.request({method:"eth_getBlockByHash",params:[t,o]},{dedupe:!0}):a=await e.request({method:"eth_getBlockByNumber",params:[i||r,o]},{dedupe:!!i}),!a)throw new ho({blockHash:t,blockNumber:n});return(((l=(d=(u=e.chain)==null?void 0:u.formatters)==null?void 0:d.block)==null?void 0:l.format)||po)(a,"getBlock")}async function bo(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function Gl(e,t){return Va(e,t)}async function Va(e,t){var o,i;const{block:n,chain:r=e.chain,request:s}=t||{};try{const a=((o=r==null?void 0:r.fees)==null?void 0:o.maxPriorityFeePerGas)??((i=r==null?void 0:r.fees)==null?void 0:i.defaultPriorityFee);if(typeof a=="function"){const u=n||await M(e,Ce,"getBlock")({}),d=await a({block:u,client:e,request:s});if(d===null)throw new Error;return d}if(typeof a<"u")return a;const c=await e.request({method:"eth_maxPriorityFeePerGas"});return Q(c)}catch{const[a,c]=await Promise.all([n?Promise.resolve(n):M(e,Ce,"getBlock")({}),M(e,bo,"getGasPrice")({})]);if(typeof a.baseFeePerGas!="bigint")throw new fo;const u=c-a.baseFeePerGas;return u<0n?0n:u}}async function ql(e,t){return zs(e,t)}async function zs(e,t){var f,p;const{block:n,chain:r=e.chain,request:s,type:o="eip1559"}=t||{},i=await(async()=>{var h,m;return typeof((h=r==null?void 0:r.fees)==null?void 0:h.baseFeeMultiplier)=="function"?r.fees.baseFeeMultiplier({block:n,client:e,request:s}):((m=r==null?void 0:r.fees)==null?void 0:m.baseFeeMultiplier)??1.2})();if(i<1)throw new qa;const c=10**(((f=i.toString().split(".")[1])==null?void 0:f.length)??0),u=h=>h*BigInt(Math.ceil(i*c))/BigInt(c),d=n||await M(e,Ce,"getBlock")({});if(typeof((p=r==null?void 0:r.fees)==null?void 0:p.estimateFeesPerGas)=="function"){const h=await r.fees.estimateFeesPerGas({block:n,client:e,multiply:u,request:s,type:o});if(h!==null)return h}if(o==="eip1559"){if(typeof d.baseFeePerGas!="bigint")throw new fo;const h=typeof(s==null?void 0:s.maxPriorityFeePerGas)=="bigint"?s.maxPriorityFeePerGas:await Va(e,{block:d,chain:r,request:s}),m=u(d.baseFeePerGas);return{maxFeePerGas:(s==null?void 0:s.maxFeePerGas)??m+h,maxPriorityFeePerGas:h}}return{gasPrice:(s==null?void 0:s.gasPrice)??u(await M(e,bo,"getGasPrice")({}))}}function Ct(e){const{blockHash:t,blockNumber:n,blockTag:r,requireCanonical:s}=e;if(s!==void 0&&!t)throw new $("`requireCanonical` can only be provided when `blockHash` is set.");return t?s?{blockHash:t,requireCanonical:s}:{blockHash:t}:typeof n=="bigint"?j(n):r??"latest"}async function mo(e,{address:t,blockHash:n,blockNumber:r,blockTag:s="latest",requireCanonical:o}){const i=Ct({blockHash:n,blockNumber:r,blockTag:s,requireCanonical:o}),a=await e.request({method:"eth_getTransactionCount",params:[t,i]},{dedupe:typeof r=="bigint"||n!==void 0});return Pe(a)}function yo(e){const{kzg:t}=e,n=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),r=typeof e.blobs[0]=="string"?e.blobs.map(o=>Oe(o)):e.blobs,s=[];for(const o of r)s.push(Uint8Array.from(t.blobToKzgCommitment(o)));return n==="bytes"?s:s.map(o=>Y(o))}function go(e){const{kzg:t}=e,n=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),r=typeof e.blobs[0]=="string"?e.blobs.map(i=>Oe(i)):e.blobs,s=typeof e.commitments[0]=="string"?e.commitments.map(i=>Oe(i)):e.commitments,o=[];for(let i=0;i<r.length;i++){const a=r[i],c=s[i];o.push(Uint8Array.from(t.computeBlobKzgProof(a,c)))}return n==="bytes"?o:o.map(i=>Y(i))}function Hl(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}function Vl(e,t,n){return e&t^~e&n}function Wl(e,t,n){return e&t^e&n^t&n}class Zl extends no{constructor(t,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(t),this.view=Wr(this.buffer)}update(t){Lt(this),t=wr(t),pt(t);const{view:n,buffer:r,blockLen:s}=this,o=t.length;for(let i=0;i<o;){const a=Math.min(s-this.pos,o-i);if(a===s){const c=Wr(t);for(;s<=o-i;i+=s)this.process(c,i);continue}r.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Lt(this),ma(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:o}=this;let{pos:i}=this;n[i++]=128,Ut(this.buffer.subarray(i)),this.padOffset>s-i&&(this.process(r,0),i=0);for(let l=i;l<s;l++)n[l]=0;Hl(r,s-8,BigInt(this.length*8),o),this.process(r,0);const a=Wr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,d=this.get();if(u>d.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,d[l],o)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:o,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=o,t.length=s,t.pos=a,s%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const Je=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Kl=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]),Xe=new Uint32Array(64);class Yl extends Zl{constructor(t=32){super(64,t,8,!1),this.A=Je[0]|0,this.B=Je[1]|0,this.C=Je[2]|0,this.D=Je[3]|0,this.E=Je[4]|0,this.F=Je[5]|0,this.G=Je[6]|0,this.H=Je[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)Xe[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const f=Xe[l-15],p=Xe[l-2],h=ze(f,7)^ze(f,18)^f>>>3,m=ze(p,17)^ze(p,19)^p>>>10;Xe[l]=m+Xe[l-7]+h+Xe[l-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:d}=this;for(let l=0;l<64;l++){const f=ze(a,6)^ze(a,11)^ze(a,25),p=d+f+Vl(a,c,u)+Kl[l]+Xe[l]|0,m=(ze(r,2)^ze(r,13)^ze(r,22))+Wl(r,s,o)|0;d=u,u=c,c=a,a=i+p|0,i=o,o=s,s=r,r=p+m|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,d=d+this.H|0,this.set(r,s,o,i,a,c,u,d)}roundClean(){Ut(Xe)}destroy(){this.set(0,0,0,0,0,0,0,0),Ut(this.buffer)}}const Wa=ya(()=>new Yl),Jl=Wa;function Xl(e,t){return Jl(Fe(e,{strict:!1})?Zt(e):e)}function Ql(e){const{commitment:t,version:n=1}=e,r=e.to??(typeof t=="string"?"hex":"bytes"),s=Xl(t);return s.set([n],0),r==="bytes"?s:Y(s)}function Za(e){const{commitments:t,version:n}=e,r=e.to??(typeof t[0]=="string"?"hex":"bytes"),s=[];for(const o of t)s.push(Ql({commitment:o,to:r,version:n}));return s}const gi=6,Ka=32,wo=4096,Ya=Ka*wo,wi=Ya*gi-1-1*wo*gi,Ja=1;class ef extends ${constructor({maxSize:t,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class Xa extends ${constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class tf extends ${constructor({hash:t,size:n}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${n}`],name:"InvalidVersionedHashSizeError"})}}class nf extends ${constructor({hash:t,version:n}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${Ja}`,`Received: ${n}`],name:"InvalidVersionedHashVersionError"})}}function rf(e){const t=e.to??(typeof e.data=="string"?"hex":"bytes"),n=typeof e.data=="string"?Oe(e.data):e.data,r=Z(n);if(!r)throw new Xa;if(r>wi)throw new ef({maxSize:wi,size:r});const s=[];let o=!0,i=0;for(;o;){const a=ao(new Uint8Array(Ya));let c=0;for(;c<wo;){const u=n.slice(i,i+(Ka-1));if(a.pushByte(0),a.pushBytes(u),u.length<31){a.pushByte(128),o=!1;break}c++,i+=31}s.push(a)}return t==="bytes"?s.map(a=>a.bytes):s.map(a=>Y(a.bytes))}function Qa(e){const{data:t,kzg:n,to:r}=e,s=e.blobs??rf({data:t,to:r}),o=e.commitments??yo({blobs:s,kzg:n,to:r}),i=e.proofs??go({blobs:s,commitments:o,kzg:n,to:r}),a=[];for(let c=0;c<s.length;c++)a.push({blob:s[c],commitment:o[c],proof:i[c]});return a}function ec(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new wl({transaction:e})}function $r(e,{docsPath:t,...n}){const r=(()=>{const s=Ir(e,n);return s instanceof qn?e:s})();return new vl(r,{docsPath:t,...n})}async function Me(e){const t=await e.request({method:"eth_chainId"},{dedupe:!0});return Pe(t)}async function xo(e,t){var I,T,F,S,R;const{account:n=e.account,accessList:r,authorizationList:s,chain:o=e.chain,blobVersionedHashes:i,blobs:a,data:c,gas:u,gasPrice:d,maxFeePerBlobGas:l,maxFeePerGas:f,maxPriorityFeePerGas:p,nonce:h,nonceManager:m,to:x,type:g,value:A,...y}=t,w=await(async()=>{if(!n||!m||typeof h<"u")return h;const k=K(n),U=o?o.id:await M(e,Me,"getChainId")({});return await m.consume({address:k.address,chainId:U,client:e})})();Ye(t);const v=(T=(I=o==null?void 0:o.formatters)==null?void 0:I.transactionRequest)==null?void 0:T.format,P=(v||st)({...Yt(y,{format:v}),account:n?K(n):void 0,accessList:r,authorizationList:s,blobs:a,blobVersionedHashes:i,data:c,gas:u,gasPrice:d,maxFeePerBlobGas:l,maxFeePerGas:f,maxPriorityFeePerGas:p,nonce:w,to:x,type:g,value:A},"fillTransaction");try{const k=await e.request({method:"eth_fillTransaction",params:[P]}),C=(((S=(F=o==null?void 0:o.formatters)==null?void 0:F.transaction)==null?void 0:S.format)||Hn)(k.tx);delete C.blockHash,delete C.blockNumber,delete C.r,delete C.s,delete C.transactionIndex,delete C.v,delete C.yParity,C.data=C.input,C.gas&&(C.gas=t.gas??C.gas),C.gasPrice&&(C.gasPrice=t.gasPrice??C.gasPrice),C.maxFeePerBlobGas&&(C.maxFeePerBlobGas=t.maxFeePerBlobGas??C.maxFeePerBlobGas),C.maxFeePerGas&&(C.maxFeePerGas=t.maxFeePerGas??C.maxFeePerGas),C.maxPriorityFeePerGas&&(C.maxPriorityFeePerGas=t.maxPriorityFeePerGas??C.maxPriorityFeePerGas),typeof C.nonce<"u"&&(C.nonce=t.nonce??C.nonce);const B=await(async()=>{var L,D;if(typeof((L=o==null?void 0:o.fees)==null?void 0:L.baseFeeMultiplier)=="function"){const q=await M(e,Ce,"getBlock")({});return o.fees.baseFeeMultiplier({block:q,client:e,request:t})}return((D=o==null?void 0:o.fees)==null?void 0:D.baseFeeMultiplier)??1.2})();if(B<1)throw new qa;const N=10**(((R=B.toString().split(".")[1])==null?void 0:R.length)??0),O=L=>L*BigInt(Math.ceil(B*N))/BigInt(N);return C.feePayerSignature||(C.maxFeePerGas&&!t.maxFeePerGas&&(C.maxFeePerGas=O(C.maxFeePerGas)),C.gasPrice&&!t.gasPrice&&(C.gasPrice=O(C.gasPrice))),{raw:k.raw,transaction:{from:P.from,...C},...k.capabilities?{capabilities:k.capabilities}:{}}}catch(k){throw $r(k,{...t,chain:e.chain})}}const vo=["blobVersionedHashes","chainId","fees","gas","nonce","type"],xi=new Map,Yr=new Kt(128);async function Vn(e,t){var w,v,E;let n=t;n.account??(n.account=e.account),n.parameters??(n.parameters=vo);const{account:r,chain:s=e.chain,nonceManager:o,parameters:i}=n,a=(()=>{if(typeof(s==null?void 0:s.prepareTransactionRequest)=="function")return{fn:s.prepareTransactionRequest,runAt:["beforeFillTransaction"]};if(Array.isArray(s==null?void 0:s.prepareTransactionRequest))return{fn:s.prepareTransactionRequest[0],runAt:s.prepareTransactionRequest[1].runAt}})();let c;async function u(){return c||(typeof n.chainId<"u"?n.chainId:s?s.id:(c=await M(e,Me,"getChainId")({}),c))}const d=r&&K(r);let l=n.nonce;if(i.includes("nonce")&&typeof l>"u"&&d&&o){const P=await u();l=await o.consume({address:d.address,chainId:P,client:e})}a!=null&&a.fn&&((w=a.runAt)!=null&&w.includes("beforeFillTransaction"))&&(n=await a.fn({...n,chain:s},{client:e,phase:"beforeFillTransaction"}),l??(l=n.nonce));const p=((i.includes("blobVersionedHashes")||i.includes("sidecars"))&&n.kzg&&n.blobs||Yr.get(e.uid)===!1||!["fees","gas"].some(I=>i.includes(I))?!1:!!(i.includes("chainId")&&typeof n.chainId!="number"||i.includes("nonce")&&typeof l!="number"||i.includes("fees")&&typeof n.gasPrice!="bigint"&&(typeof n.maxFeePerGas!="bigint"||typeof n.maxPriorityFeePerGas!="bigint")||i.includes("gas")&&typeof n.gas!="bigint"))?await M(e,xo,"fillTransaction")({...n,nonce:l}).then(P=>{const{chainId:I,from:T,gas:F,gasPrice:S,nonce:R,maxFeePerBlobGas:k,maxFeePerGas:U,maxPriorityFeePerGas:C,type:B,...z}=P.transaction;return Yr.set(e.uid,!0),{...n,...T?{from:T}:{},...B&&!n.type?{type:B}:{},...typeof I<"u"?{chainId:I}:{},...typeof F<"u"?{gas:F}:{},...typeof S<"u"?{gasPrice:S}:{},...typeof R<"u"?{nonce:R}:{},...typeof k<"u"&&n.type!=="legacy"&&n.type!=="eip2930"?{maxFeePerBlobGas:k}:{},...typeof U<"u"&&n.type!=="legacy"&&n.type!=="eip2930"?{maxFeePerGas:U}:{},...typeof C<"u"&&n.type!=="legacy"&&n.type!=="eip2930"?{maxPriorityFeePerGas:C}:{},..."nonceKey"in z&&typeof z.nonceKey<"u"?{nonceKey:z.nonceKey}:{},..."keyAuthorization"in z&&typeof z.keyAuthorization<"u"&&z.keyAuthorization!==null&&!("keyAuthorization"in n)?{keyAuthorization:z.keyAuthorization}:{},..."feePayerSignature"in z&&typeof z.feePayerSignature<"u"&&z.feePayerSignature!==null?{feePayerSignature:z.feePayerSignature}:{},..."feeToken"in z&&typeof z.feeToken<"u"&&z.feeToken!==null&&!("feeToken"in n)?{feeToken:z.feeToken}:{},...P.capabilities?{_capabilities:P.capabilities}:{}}}).catch(P=>{var S,R;const I=P;if(I.name!=="TransactionExecutionError")return n;if((S=I.walk)==null?void 0:S.call(I,k=>k.name==="ExecutionRevertedError"))throw P;return((R=I.walk)==null?void 0:R.call(I,k=>{var C;const U=k;return U.name==="MethodNotFoundRpcError"||U.name==="MethodNotSupportedRpcError"||((C=U.message)==null?void 0:C.includes("eth_fillTransaction is not available"))}))&&Yr.set(e.uid,!1),n}):n;l??(l=p.nonce),n={...p,...d?{from:d==null?void 0:d.address}:{},...typeof l<"u"?{nonce:l}:{}};const{blobs:h,gas:m,kzg:x,type:g}=n;a!=null&&a.fn&&((v=a.runAt)!=null&&v.includes("beforeFillParameters"))&&(n=await a.fn({...n,chain:s},{client:e,phase:"beforeFillParameters"}));let A;async function y(){return A||(A=await M(e,Ce,"getBlock")({blockTag:"latest"}),A)}if(i.includes("nonce")&&typeof l>"u"&&d&&!o&&(n.nonce=await M(e,mo,"getTransactionCount")({address:d.address,blockTag:"pending"})),(i.includes("blobVersionedHashes")||i.includes("sidecars"))&&h&&x){const P=yo({blobs:h,kzg:x});if(i.includes("blobVersionedHashes")){const I=Za({commitments:P,to:"hex"});n.blobVersionedHashes=I}if(i.includes("sidecars")){const I=go({blobs:h,commitments:P,kzg:x}),T=Qa({blobs:h,commitments:P,proofs:I,to:"hex"});n.sidecars=T}}if(i.includes("chainId")&&(n.chainId=await u()),(i.includes("fees")||i.includes("type"))&&typeof g>"u")try{n.type=ec(n)}catch{let P=xi.get(e.uid);if(typeof P>"u"){const I=await y();P=typeof(I==null?void 0:I.baseFeePerGas)=="bigint",xi.set(e.uid,P)}n.type=P?"eip1559":"legacy"}if(i.includes("fees"))if(n.type!=="legacy"&&n.type!=="eip2930"){if(typeof n.maxFeePerGas>"u"||typeof n.maxPriorityFeePerGas>"u"){const P=await y(),{maxFeePerGas:I,maxPriorityFeePerGas:T}=await zs(e,{block:P,chain:s,request:n});if(typeof n.maxPriorityFeePerGas>"u"&&n.maxFeePerGas&&n.maxFeePerGas<T)throw new Ll({maxPriorityFeePerGas:T});n.maxPriorityFeePerGas=T,n.maxFeePerGas=I}}else{if(typeof n.maxFeePerGas<"u"||typeof n.maxPriorityFeePerGas<"u")throw new fo;if(typeof n.gasPrice>"u"){const P=await y(),{gasPrice:I}=await zs(e,{block:P,chain:s,request:n,type:"legacy"});n.gasPrice=I}}return i.includes("gas")&&typeof m>"u"&&(n.gas=await M(e,Eo,"estimateGas")({...n,account:d,prepare:(d==null?void 0:d.type)==="local"?[]:["blobVersionedHashes"]})),a!=null&&a.fn&&((E=a.runAt)!=null&&E.includes("afterFillParameters"))&&(n=await a.fn({...n,chain:s},{client:e,phase:"afterFillParameters"})),Ye(n),delete n.parameters,n}async function Eo(e,t){var i,a,c;const{account:n=e.account,prepare:r=!0}=t,s=n?K(n):void 0,o=(()=>{if(Array.isArray(r))return r;if((s==null?void 0:s.type)!=="local")return["blobVersionedHashes"]})();try{const u=await(async()=>{if(t.to)return t.to;if(t.authorizationList&&t.authorizationList.length>0)return await Ar({authorization:t.authorizationList[0]}).catch(()=>{throw new $("`to` is required. Could not infer from `authorizationList`")})})(),{accessList:d,authorizationList:l,blobs:f,blobVersionedHashes:p,blockNumber:h,blockTag:m,data:x,gas:g,gasPrice:A,maxFeePerBlobGas:y,maxFeePerGas:w,maxPriorityFeePerGas:v,nonce:E,value:P,stateOverride:I,...T}=r?await Vn(e,{...t,parameters:o,to:u}):t;if(g&&t.gas!==g)return g;const S=(typeof h=="bigint"?j(h):void 0)||m,R=lo(I);Ye(t);const k=(c=(a=(i=e.chain)==null?void 0:i.formatters)==null?void 0:a.transactionRequest)==null?void 0:c.format,C=(k||st)({...Yt(T,{format:k}),account:s,accessList:d,authorizationList:l,blobs:f,blobVersionedHashes:p,data:x,gasPrice:A,maxFeePerBlobGas:y,maxFeePerGas:w,maxPriorityFeePerGas:v,nonce:E,to:u,value:P},"estimateGas");return BigInt(await e.request({method:"eth_estimateGas",params:R?[C,S??e.experimental_blockTag??"latest",R]:S?[C,S]:[C]}))}catch(u){throw Rl(u,{...t,account:s,chain:e.chain})}}async function sf(e,t){var u;const{abi:n,address:r,args:s,functionName:o,dataSuffix:i=typeof e.dataSuffix=="string"?e.dataSuffix:(u=e.dataSuffix)==null?void 0:u.value,...a}=t,c=he({abi:n,args:s,functionName:o});try{return await M(e,Eo,"estimateGas")({data:`${c}${i?i.replace("0x",""):""}`,to:r,...a})}catch(d){const l=a.account?K(a.account):void 0;throw yt(d,{abi:n,address:r,args:s,docsPath:"/docs/contract/estimateContractGas",functionName:o,sender:l==null?void 0:l.address})}}function wt(e,t){if(!J(e,{strict:!1}))throw new oe({address:e});if(!J(t,{strict:!1}))throw new oe({address:t});return e.toLowerCase()===t.toLowerCase()}function Le(e,{args:t,eventName:n}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,blockTimestamp:e.blockTimestamp?BigInt(e.blockTimestamp):e.blockTimestamp===null?null:void 0,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}:{}}}const vi="/docs/contract/decodeEventLog";function ur(e){const{abi:t,data:n,strict:r,topics:s}=e,o=r??!0,[i,...a]=s;if(!i)throw new Z0({docsPath:vi});const c=t.find(g=>g.type==="event"&&i===xr($e(g)));if(!(c&&"name"in c)||c.type!=="event")throw new K0(i,{docsPath:vi});const{name:u,inputs:d}=c,l=d==null?void 0:d.some(g=>!("name"in g&&g.name)),f=l?[]:{},p=d.map((g,A)=>[g,A]).filter(([g])=>"indexed"in g&&g.indexed),h=[];for(let g=0;g<p.length;g++){const[A,y]=p[g],w=a[g];if(!w){if(o)throw new eo({abiItem:c,param:A});h.push([A,y]);continue}f[l?y:A.name||y]=of({param:A,value:w})}const m=d.filter(g=>!("indexed"in g&&g.indexed)),x=o?m:[...h.map(([g])=>g),...m];if(x.length>0){if(n&&n!=="0x")try{const g=Dn(x,n);if(g){let A=0;if(!o)for(const[y,w]of h)f[l?w:y.name||w]=g[A++];if(l)for(let y=0;y<d.length;y++)f[y]===void 0&&A<g.length&&(f[y]=g[A++]);else for(let y=0;y<m.length;y++)f[m[y].name]=g[A++]}}catch(g){if(o)throw g instanceof ua||g instanceof Na?new cr({abiItem:c,data:n,params:x,size:Z(n)}):g}else if(o)throw new cr({abiItem:c,data:"0x",params:x,size:0})}return{eventName:u,args:Object.values(f).length>0?f:void 0}}function of({param:e,value:t}){return e.type==="string"||e.type==="bytes"||e.type==="tuple"||e.type.match(/^(.*)\[(\d+)?\]$/)?t:(Dn([e],t)||[])[0]}function Sr(e){const{abi:t,args:n,logs:r,strict:s=!0}=e,o=(()=>{if(e.eventName)return Array.isArray(e.eventName)?e.eventName:[e.eventName]})(),i=t.filter(a=>a.type==="event").map(a=>({abi:a,selector:xr(a)}));return r.map(a=>{var f;const c=typeof a.blockNumber=="string"?Le(a):a,u=i.filter(p=>c.topics[0]===p.selector);if(u.length===0)return null;let d,l;for(const p of u)try{d=ur({...c,abi:[p.abi],strict:!0}),l=p;break}catch{}if(!d&&!s){l=u[0];try{d=ur({data:c.data,topics:c.topics,abi:[l.abi],strict:!1})}catch{const p=(f=l.abi.inputs)==null?void 0:f.some(h=>!("name"in h&&h.name));return{...c,args:p?[]:{},eventName:l.abi.name}}}return!d||!l||o&&!o.includes(d.eventName)||!af({args:d.args,inputs:l.abi.inputs,matchArgs:n})?null:{...d,...c}}).filter(Boolean)}function af(e){const{args:t,inputs:n,matchArgs:r}=e;if(!r)return!0;if(!t)return!1;function s(o,i,a){try{return o.type==="address"?wt(i,a):o.type==="string"||o.type==="bytes"?te(Zt(i))===a:i===a}catch{return!1}}return Array.isArray(t)&&Array.isArray(r)?r.every((o,i)=>{if(o==null)return!0;const a=n[i];return a?(Array.isArray(o)?o:[o]).some(u=>s(a,u,t[i])):!1}):typeof t=="object"&&!Array.isArray(t)&&typeof r=="object"&&!Array.isArray(r)?Object.entries(r).every(([o,i])=>{if(i==null)return!0;const a=n.find(u=>u.name===o);return a?(Array.isArray(i)?i:[i]).some(u=>s(a,u,t[o])):!1}):!1}async function Po(e,{address:t,blockHash:n,fromBlock:r,toBlock:s,event:o,events:i,args:a,strict:c}={}){const u=c??!1,d=i??(o?[o]:void 0);let l=[];d&&(l=[d.flatMap(m=>_n({abi:[m],eventName:m.name,args:i?void 0:a}))],o&&(l=l[0]));let f;n?f=await e.request({method:"eth_getLogs",params:[{address:t,topics:l,blockHash:n}]}):f=await e.request({method:"eth_getLogs",params:[{address:t,topics:l,fromBlock:typeof r=="bigint"?j(r):r,toBlock:typeof s=="bigint"?j(s):s}]});const p=f.map(h=>Le(h));return d?Sr({abi:d,args:a,logs:p,strict:u}):p}async function tc(e,t){const{abi:n,address:r,args:s,blockHash:o,eventName:i,fromBlock:a,toBlock:c,strict:u}=t,d=i?It({abi:n,name:i}):void 0,l=d?void 0:n.filter(f=>f.type==="event");return M(e,Po,"getLogs")({address:r,args:s,blockHash:o,event:d,events:l,fromBlock:a,toBlock:c,strict:u})}const Jr="/docs/contract/decodeFunctionResult";function ot(e){const{abi:t,args:n,functionName:r,data:s}=e;let o=t[0];if(r){const a=It({abi:t,args:n,name:r});if(!a)throw new Mt(r,{docsPath:Jr});o=a}if(o.type!=="function")throw new Mt(void 0,{docsPath:Jr});if(!o.outputs)throw new la(o.name,{docsPath:Jr});const i=Dn(o.outputs,s);if(i&&i.length>1)return i;if(i&&i.length===1)return i[0]}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ao=BigInt(0),Rs=BigInt(1);function Wn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Io(e){if(!Wn(e))throw new Error("Uint8Array expected")}function zn(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function tr(e){const t=e.toString(16);return t.length&1?"0"+t:t}function nc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Ao:BigInt("0x"+e)}const rc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",cf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Rn(e){if(Io(e),rc)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=cf[e[n]];return t}const _e={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ei(e){if(e>=_e._0&&e<=_e._9)return e-_e._0;if(e>=_e.A&&e<=_e.F)return e-(_e.A-10);if(e>=_e.a&&e<=_e.f)return e-(_e.a-10)}function dr(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(rc)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 s=0,o=0;s<n;s++,o+=2){const i=Ei(e.charCodeAt(o)),a=Ei(e.charCodeAt(o+1));if(i===void 0||a===void 0){const c=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}r[s]=i*16+a}return r}function ft(e){return nc(Rn(e))}function sc(e){return Io(e),nc(Rn(Uint8Array.from(e).reverse()))}function Zn(e,t){return dr(e.toString(16).padStart(t*2,"0"))}function oc(e,t){return Zn(e,t).reverse()}function Ee(e,t,n){let r;if(typeof t=="string")try{r=dr(t)}catch(o){throw new Error(e+" must be hex string or Uint8Array, cause: "+o)}else if(Wn(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}function lr(...e){let t=0;for(let r=0;r<e.length;r++){const s=e[r];Io(s),t+=s.length}const n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.length}return n}const Xr=e=>typeof e=="bigint"&&Ao<=e;function Co(e,t,n){return Xr(e)&&Xr(t)&&Xr(n)&&t<=e&&e<n}function Ft(e,t,n,r){if(!Co(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function uf(e){let t;for(t=0;e>Ao;e>>=Rs,t+=1);return t}const Br=e=>(Rs<<BigInt(e))-Rs,Qr=e=>new Uint8Array(e),Pi=e=>Uint8Array.from(e);function df(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Qr(e),s=Qr(e),o=0;const i=()=>{r.fill(1),s.fill(0),o=0},a=(...l)=>n(s,r,...l),c=(l=Qr(0))=>{s=a(Pi([0]),l),r=a(),l.length!==0&&(s=a(Pi([1]),l),r=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0;const f=[];for(;l<t;){r=a();const p=r.slice();f.push(p),l+=r.length}return lr(...f)};return(l,f)=>{i(),c(l);let p;for(;!(p=f(u()));)c();return i(),p}}const lf={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||Wn(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Tr(e,t,n={}){const r=(s,o,i)=>{const a=lf[o];if(typeof a!="function")throw new Error("invalid validator function");const c=e[s];if(!(i&&c===void 0)&&!a(c,e))throw new Error("param "+String(s)+" is invalid. Expected "+o+", got "+c)};for(const[s,o]of Object.entries(t))r(s,o,!1);for(const[s,o]of Object.entries(n))r(s,o,!0);return e}function Ai(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(s!==void 0)return s;const o=e(n,...r);return t.set(n,o),o}}const ff="0.1.1";function hf(){return ff}class _ extends Error{static setStaticOptions(t){_.prototype.docsOrigin=t.docsOrigin,_.prototype.showVersion=t.showVersion,_.prototype.version=t.version}constructor(t,n={}){const r=(()=>{var d;if(n.cause instanceof _){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:(d=n.cause)!=null&&d.message?n.cause.message:n.details})(),s=n.cause instanceof _&&n.cause.docsPath||n.docsPath,o=n.docsOrigin??_.prototype.docsOrigin,i=`${o}${s??""}`,a=!!(n.version??_.prototype.showVersion),c=n.version??_.prototype.version,u=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||s||a?["",r?`Details: ${r}`:void 0,s?`See: ${i}`:void 0,a?`Version: ${c}`:void 0]:[]].filter(d=>typeof d=="string").join(`
40
- `);super(u,n.cause?{cause:n.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=n.cause,this.details=r,this.docs=i,this.docsOrigin=o,this.docsPath=s,this.shortMessage=t,this.showVersion=a,this.version=c}walk(t){return ic(this,t)}}Object.defineProperty(_,"defaultStaticOptions",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:"https://oxlib.sh",showVersion:!1,version:`ox@${hf()}`}});_.setStaticOptions(_.defaultStaticOptions);function ic(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?ic(e.cause,t):t?null:e}function Kn(e,t){if(kt(e)>t)throw new Tf({givenSize:kt(e),maxSize:t})}const De={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ii(e){if(e>=De.zero&&e<=De.nine)return e-De.zero;if(e>=De.A&&e<=De.F)return e-(De.A-10);if(e>=De.a&&e<=De.f)return e-(De.a-10)}function pf(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new Nf({size:e.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let o=0;o<r;o++){const i=n==="right";s[i?o:r-o-1]=e[i?o:e.length-o-1]}return s}function ac(e,t={}){const{dir:n="left"}=t;let r=e,s=0;for(let o=0;o<r.length-1&&r[n==="left"?o:r.length-o-1].toString()==="0";o++)s++;return r=n==="left"?r.slice(s):r.slice(0,r.length-s),r}function Nr(e,t){if(xe(e)>t)throw new Of({givenSize:xe(e),maxSize:t})}function bf(e,t){if(typeof t=="number"&&t>0&&t>xe(e)-1)throw new mc({offset:t,position:"start",size:xe(e)})}function mf(e,t,n){if(typeof t=="number"&&typeof n=="number"&&xe(e)!==n-t)throw new mc({offset:n,position:"end",size:xe(e)})}function cc(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const s=e.replace("0x","");if(s.length>r*2)throw new Mf({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s[n==="right"?"padEnd":"padStart"](r*2,"0")}`}const yf="#__bigint";function uc(e,t,n){return JSON.stringify(e,(r,s)=>typeof s=="bigint"?s.toString()+yf:s,n)}const gf=new TextDecoder,wf=new TextEncoder;function xf(e){return e instanceof Uint8Array?e:typeof e=="string"?dc(e):vf(e)}function vf(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function dc(e,t={}){const{size:n}=t;let r=e;n&&(Nr(e,n),r=vt(e,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const o=s.length/2,i=new Uint8Array(o);for(let a=0,c=0;a<o;a++){const u=Ii(s.charCodeAt(c++)),d=Ii(s.charCodeAt(c++));if(u===void 0||d===void 0)throw new _(`Invalid byte sequence ("${s[c-2]}${s[c-1]}" in "${s}").`);i[a]=u<<4|d}return i}function Ef(e,t={}){const{size:n}=t,r=wf.encode(e);return typeof n=="number"?(Kn(r,n),Pf(r,n)):r}function Pf(e,t){return pf(e,{dir:"right",size:t})}function kt(e){return e.length}function Af(e,t,n,r={}){const{strict:s}=r;return e.slice(t,n)}function If(e,t={}){const{size:n}=t;typeof n<"u"&&Kn(e,n);const r=Be(e,t);return hc(r,t)}function Cf(e,t={}){const{size:n}=t;let r=e;if(typeof n<"u"&&(Kn(r,n),r=lc(r)),r.length>1||r[0]>1)throw new Bf(r);return!!r[0]}function Ve(e,t={}){const{size:n}=t;typeof n<"u"&&Kn(e,n);const r=Be(e,t);return pc(r,t)}function $f(e,t={}){const{size:n}=t;let r=e;return typeof n<"u"&&(Kn(r,n),r=Sf(r)),gf.decode(r)}function lc(e){return ac(e,{dir:"left"})}function Sf(e){return ac(e,{dir:"right"})}class Bf extends _{constructor(t){super(`Bytes value \`${t}\` 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"})}}let Tf=class extends _{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}},Nf=class extends _{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}};const kf=new TextEncoder,jf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function zf(e,t={}){const{strict:n=!1}=t;if(!e)throw new Ci(e);if(typeof e!="string")throw new Ci(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new $i(e);if(!e.startsWith("0x"))throw new $i(e)}function Se(...e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function Rf(e){return e instanceof Uint8Array?Be(e):Array.isArray(e)?Be(new Uint8Array(e)):e}function fc(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(Nr(n,t.size),xt(n,t.size)):n}function Be(e,t={}){let n="";for(let s=0;s<e.length;s++)n+=jf[e[s]];const r=`0x${n}`;return typeof t.size=="number"?(Nr(r,t.size),vt(r,t.size)):r}function re(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let o;r?n?o=(1n<<BigInt(r)*8n-1n)-1n:o=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(o=BigInt(Number.MAX_SAFE_INTEGER));const i=typeof o=="bigint"&&n?-o-1n:0;if(o&&s>o||s<i){const u=typeof e=="bigint"?"n":"";throw new bc({max:o?`${o}${u}`:void 0,min:`${i}${u}`,signed:n,size:r,value:`${e}${u}`})}const c=`0x${(n&&s<0?BigInt.asUintN(r*8,BigInt(s)):s).toString(16)}`;return r?xt(c,r):c}function $o(e,t={}){return Be(kf.encode(e),t)}function xt(e,t){return cc(e,{dir:"left",size:t})}function vt(e,t){return cc(e,{dir:"right",size:t})}function Re(e,t,n,r={}){const{strict:s}=r;bf(e,t);const o=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return s&&mf(o,t,n),o}function xe(e){return Math.ceil((e.length-2)/2)}function hc(e,t={}){const{signed:n}=t;t.size&&Nr(e,t.size);const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,o=(1n<<BigInt(s)*8n)-1n,i=o>>1n;return r<=i?r:r-o-1n}function pc(e,t={}){const{signed:n,size:r}=t;return Number(!n&&!r?e:hc(e,t))}function Ff(e,t={}){const{strict:n=!1}=t;try{return zf(e,{strict:n}),!0}catch{return!1}}class bc extends _{constructor({max:t,min:n,signed:r,size:s,value:o}){super(`Number \`${o}\` is not in safe${s?` ${s*8}-bit`:""}${r?" signed":" unsigned"} integer range ${t?`(\`${n}\` to \`${t}\`)`:`(above \`${n}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class Ci extends _{constructor(t){super(`Value \`${typeof t=="object"?uc(t):t}\` of type \`${typeof t}\` 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 $i extends _{constructor(t){super(`Value \`${t}\` 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 Of extends _{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class mc extends _{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class Mf extends _{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function Lf(e){return{address:e.address,amount:re(e.amount),index:re(e.index),validatorIndex:re(e.validatorIndex)}}function yc(e){return{...typeof e.baseFeePerGas=="bigint"&&{baseFeePerGas:re(e.baseFeePerGas)},...typeof e.blobBaseFee=="bigint"&&{blobBaseFee:re(e.blobBaseFee)},...typeof e.feeRecipient=="string"&&{feeRecipient:e.feeRecipient},...typeof e.gasLimit=="bigint"&&{gasLimit:re(e.gasLimit)},...typeof e.number=="bigint"&&{number:re(e.number)},...typeof e.prevRandao=="bigint"&&{prevRandao:re(e.prevRandao)},...typeof e.time=="bigint"&&{time:re(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(Lf)}}}const Ht=[{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"},{inputs:[{name:"addr",type:"address"}],name:"getEthBalance",outputs:[{name:"balance",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"}],Fs=[{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"}]}],gc=[{inputs:[{name:"dns",type:"bytes"}],name:"DNSDecodingFailed",type:"error"},{inputs:[{name:"ens",type:"string"}],name:"DNSEncodingFailed",type:"error"},{inputs:[],name:"EmptyAddress",type:"error"},{inputs:[{name:"status",type:"uint16"},{name:"message",type:"string"}],name:"HttpError",type:"error"},{inputs:[],name:"InvalidBatchGatewayResponse",type:"error"},{inputs:[{name:"errorData",type:"bytes"}],name:"ResolverError",type:"error"},{inputs:[{name:"name",type:"bytes"},{name:"resolver",type:"address"}],name:"ResolverNotContract",type:"error"},{inputs:[{name:"name",type:"bytes"}],name:"ResolverNotFound",type:"error"},{inputs:[{name:"primary",type:"string"},{name:"primaryAddress",type:"bytes"}],name:"ReverseAddressMismatch",type:"error"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"UnsupportedResolverProfile",type:"error"}],wc=[...gc,{name:"resolveWithGateways",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"},{name:"gateways",type:"string[]"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]}],Uf=[...gc,{name:"reverseWithGateways",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"},{type:"uint256",name:"coinType"},{type:"string[]",name:"gateways"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolver"},{type:"address",name:"reverseResolver"}]}],Si=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],xc=[{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"}],outputs:[{name:"",type:"address"}]},{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"coinType",type:"uint256"}],outputs:[{name:"",type:"bytes"}]}],vc=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],Bi=[{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"}],Ti=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],_f="0x82ad56cb",Ec="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",Df="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",Gf="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",So="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class Os extends ${constructor({blockNumber:t,chain:n,contract:r}){super(`Chain "${n.name}" does not support contract "${r.name}".`,{metaMessages:["This could be due to any of the following:",...t&&r.blockCreated&&r.blockCreated>t?[`- The contract "${r.name}" was not deployed until block ${r.blockCreated} (current block ${t}).`]:[`- The chain does not have the contract "${r.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class qf extends ${constructor({chain:t,currentChainId:n}){super(`The current chain of the wallet (id: ${n}) does not match the target chain for the transaction (id: ${t.id} – ${t.name}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${t.id} – ${t.name}`],name:"ChainMismatchError"})}}class Hf extends ${constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
41
- `),{name:"ChainNotFoundError"})}}class Pc extends ${constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class kr extends ${constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const es="/docs/contract/encodeDeployData";function jr(e){const{abi:t,args:n,bytecode:r}=e;if(!n||n.length===0)return r;const s=t.find(i=>"type"in i&&i.type==="constructor");if(!s)throw new G0({docsPath:es});if(!("inputs"in s))throw new ti({docsPath:es});if(!s.inputs||s.inputs.length===0)throw new ti({docsPath:es});const o=At(s.inputs,n);return ke([r,o])}function Jt({blockNumber:e,chain:t,contract:n}){var s;const r=(s=t==null?void 0:t.contracts)==null?void 0:s[n];if(!r)throw new Os({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new Os({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function Ac(e,{docsPath:t,...n}){const r=(()=>{const s=Ir(e,n);return s instanceof qn?e:s})();return new Ma(r,{docsPath:t,...n})}function Bo(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}const ts=new Map;function Vf({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:s}){const o=async()=>{const d=c();i();const l=d.map(({args:f})=>f);l.length!==0&&e(l).then(f=>{s&&Array.isArray(f)&&f.sort(s);for(let p=0;p<d.length;p++){const{resolve:h}=d[p];h==null||h([f[p],f])}}).catch(f=>{for(let p=0;p<d.length;p++){const{reject:h}=d[p];h==null||h(f)}})},i=()=>ts.delete(t),a=()=>c().map(({args:d})=>d),c=()=>ts.get(t)||[],u=d=>ts.set(t,[...c(),d]);return{flush:i,async schedule(d){const{promise:l,resolve:f,reject:p}=Bo();return(n==null?void 0:n([...a(),d]))&&o(),c().length>0?(u({args:d,resolve:f,reject:p}),l):(u({args:d,resolve:f,reject:p}),setTimeout(o,r),l)}}}async function Yn(e,t){var B,z,N,O,L,D;const{account:n=e.account,authorizationList:r,batch:s=!!((B=e.batch)!=null&&B.multicall),blockHash:o,blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",requireCanonical:c,accessList:u,blobs:d,blockOverrides:l,code:f,data:p,factory:h,factoryData:m,gas:x,gasPrice:g,maxFeePerBlobGas:A,maxFeePerGas:y,maxPriorityFeePerGas:w,nonce:v,requestOptions:E,to:P,value:I,stateOverride:T,...F}=t,S=n?K(n):void 0;if(f&&(h||m))throw new $("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(f&&P)throw new $("Cannot provide both `code` & `to` as parameters.");const R=f&&p,k=h&&m&&P&&p,U=R||k,C=R?Cc({code:f,data:p}):k?Xf({data:p,factory:h,factoryData:m,to:P}):p;try{Ye(t);const q=Ct({blockHash:o,blockNumber:i,blockTag:a,requireCanonical:c}),V=l?yc(l):void 0,H=lo(T),W=(O=(N=(z=e.chain)==null?void 0:z.formatters)==null?void 0:N.transactionRequest)==null?void 0:O.format,ae=(W||st)({...Yt(F,{format:W}),accessList:u,account:S,authorizationList:r,blobs:d,data:C,gas:x,gasPrice:g,maxFeePerBlobGas:A,maxFeePerGas:y,maxPriorityFeePerGas:w,nonce:v,to:U?void 0:P,value:I},"call");if(s&&Wf({request:ae})&&!V&&o===void 0)try{const{deployless:ee=!1}=typeof((L=e.batch)==null?void 0:L.multicall)=="object"?e.batch.multicall:{},at=Ic(e,{blockNumber:i,deployless:ee});if(!at||!Jf(H,at))return await Yf(e,{...ae,blockHash:o,blockNumber:i,blockTag:a,multicallAddress:at,requestOptions:E,requireCanonical:c,rpcStateOverride:H})}catch(ee){if(!(ee instanceof Pc)&&!(ee instanceof Os))throw ee}const en=(()=>{const ee=[ae,q];return H&&V?[...ee,H,V]:H?[...ee,H]:V?[...ee,{},V]:ee})(),je=await e.request({method:"eth_call",params:en},E);return je==="0x"?{data:void 0}:{data:je}}catch(q){if((D=E==null?void 0:E.signal)!=null&&D.aborted)throw bt(E.signal);if(Er(q))throw q;const V=Qf(q),{offchainLookup:H,offchainLookupSignature:W}=await Zi(async()=>{const{offchainLookup:me,offchainLookupSignature:ae}=await import("./ccip-CDdHldzo.js");return{offchainLookup:me,offchainLookupSignature:ae}},__vite__mapDeps([0,1,2,3]));if(e.ccipRead!==!1&&(V==null?void 0:V.slice(0,10))===W&&P)return{data:await H(e,{data:V,requestOptions:E,to:P})};throw U&&(V==null?void 0:V.slice(0,10))==="0x101bb98d"?new Il({factory:h}):Ac(q,{...t,account:S,chain:e.chain})}}function Wf({request:e}){const{data:t,to:n,...r}=e;return!(!t||t.startsWith(_f)||!n||Object.values(r).filter(s=>typeof s<"u").length>0)}let Zf=0;const Ni=new WeakMap;function Kf(e){if(!e)return"default";const t=Ni.get(e);if(t!==void 0)return t;const n=Zf++;return Ni.set(e,n),n}async function Yf(e,t){var v;const{batchSize:n=1024,deployless:r=!1,wait:s=0}=typeof((v=e.batch)==null?void 0:v.multicall)=="object"?e.batch.multicall:{},{blockHash:o,blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",requireCanonical:c,data:u,multicallAddress:d,requestOptions:l,rpcStateOverride:f,to:p}=t,h=d!==void 0?d:Ic(e,{blockNumber:i,deployless:r}),m=Ct({blockHash:o,blockNumber:i,blockTag:a,requireCanonical:c}),x=typeof m=="string"?m:JSON.stringify(m),g=f?`.${JSON.stringify(f)}`:"",{schedule:A}=Vf({id:`${e.uid}.${x}.${Kf(l)}${g}`,wait:s,shouldSplitBatch(E){return E.reduce((I,{data:T})=>I+(T.length-2),0)>n*2},fn:async E=>{const P=E.map(S=>({allowFailure:!0,callData:S.data,target:S.to})),I=he({abi:Ht,args:[P],functionName:"aggregate3"}),T={...h===null?{data:Cc({code:So,data:I})}:{to:h,data:I}},F=await e.request({method:"eth_call",params:f?[T,m,f]:[T,m]},l);return ot({abi:Ht,args:[P],functionName:"aggregate3",data:F||"0x"})}}),[{returnData:y,success:w}]=await A({data:u,to:p});if(!w)throw new Pr({data:y});return y==="0x"?{data:void 0}:{data:y}}function Ic(e,t){const{blockNumber:n,deployless:r}=t;if(r)return null;if(e.chain)return Jt({blockNumber:n,chain:e.chain,contract:"multicall3"});throw new Pc}function Jf(e,t){return e?Object.keys(e).some(n=>wt(n,t)):!1}function Cc(e){const{code:t,data:n}=e;return jr({abi:ia(["constructor(bytes, bytes)"]),bytecode:Ec,args:[t,n]})}function Xf(e){const{data:t,factory:n,factoryData:r,to:s}=e;return jr({abi:ia(["constructor(address, bytes, address, bytes)"]),bytecode:Df,args:[s,t,n,r]})}function Qf(e){var n;if(!(e instanceof $))return;const t=e.walk();return typeof(t==null?void 0:t.data)=="object"?(n=t.data)==null?void 0:n.data:t.data}async function Te(e,t){const{abi:n,address:r,args:s,functionName:o,...i}=t,a=he({abi:n,args:s,functionName:o});try{const{data:c}=await M(e,Yn,"call")({...i,data:a,to:r});return ot({abi:n,args:s,functionName:o,data:c||"0x"})}catch(c){throw yt(c,{abi:n,address:r,args:s,docsPath:"/docs/contract/readContract",functionName:o})}}async function eh(e,t){var d;const{abi:n,address:r,args:s,functionName:o,dataSuffix:i=typeof e.dataSuffix=="string"?e.dataSuffix:(d=e.dataSuffix)==null?void 0:d.value,...a}=t,c=a.account?K(a.account):e.account,u=he({abi:n,args:s,functionName:o});try{const{data:l}=await M(e,Yn,"call")({batch:!1,data:`${u}${i?i.replace("0x",""):""}`,to:r,...a,account:c}),f=ot({abi:n,args:s,functionName:o,data:l||"0x"}),p=n.filter(h=>"name"in h&&h.name===t.functionName);return{result:f,request:{abi:p,address:r,args:s,dataSuffix:i,functionName:o,...a,account:c}}}catch(l){throw yt(l,{abi:n,address:r,args:s,docsPath:"/docs/contract/simulateContract",functionName:o,sender:c==null?void 0:c.address})}}const nr=new Map,ns=new Map;let th=0;function Ze(e,t,n){const r=++th,s=()=>nr.get(e)||[],o=()=>{const l=s().filter(f=>f.id!==r);if(l.length===0){nr.delete(e),ns.delete(e);return}nr.set(e,l)},i=()=>{const d=s();if(!d.some(f=>f.id===r))return;const l=ns.get(e);if(d.length===1&&l){const f=l();f instanceof Promise&&f.catch(()=>{})}o()},a=s();if(nr.set(e,[...a,{id:r,fns:t}]),a&&a.length>0)return i;const c={};for(const d in t)c[d]=((...l)=>{var p,h;const f=s();if(f.length!==0)for(const m of f)(h=(p=m.fns)[d])==null||h.call(p,...l)});const u=n(c);return typeof u=="function"&&ns.set(e,u),i}async function Ms(e,{signal:t}={}){return new Promise((n,r)=>{if(t!=null&&t.aborted){r(bt(t));return}const s=()=>t==null?void 0:t.removeEventListener("abort",i),o=setTimeout(()=>{s(),n()},e),i=()=>{clearTimeout(o),s(),r(bt(t))};t==null||t.addEventListener("abort",i,{once:!0})})}function Xt(e,{emitOnBegin:t,initialWaitTime:n,interval:r}){let s=!0;const o=()=>s=!1;return(async()=>{let a;t&&(a=await e({unpoll:o}));const c=await(n==null?void 0:n(a))??r;await Ms(c);const u=async()=>{s&&(await e({unpoll:o}),await Ms(r),u())};u()})(),o}const nh=new Map,rh=new Map;function sh(e){const t=(s,o)=>({clear:()=>o.delete(s),get:()=>o.get(s),set:i=>o.set(s,i)}),n=t(e,nh),r=t(e,rh);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}async function oh(e,{cacheKey:t,cacheTime:n=Number.POSITIVE_INFINITY}){const r=sh(t),s=r.response.get();if(s&&n>0&&Date.now()-s.created.getTime()<n)return s.data;let o=r.promise.get();o||(o=e(),r.promise.set(o));try{const i=await o;return r.response.set({created:new Date,data:i}),i}finally{r.promise.clear()}}const ih=e=>`blockNumber.${e}`;async function Jn(e,{cacheTime:t=e.cacheTime}={}){const n=await oh(()=>e.request({method:"eth_blockNumber"}),{cacheKey:ih(e.uid),cacheTime:t});return BigInt(n)}async function zr(e,{filter:t}){const n="strict"in t&&t.strict,r=await t.request({method:"eth_getFilterChanges",params:[t.id]});if(typeof r[0]=="string")return r;const s=r.map(o=>Le(o));return!("abi"in t)||!t.abi?s:Sr({abi:t.abi,logs:s,strict:n})}async function Rr(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function ah(e,t){const{abi:n,address:r,args:s,batch:o=!0,eventName:i,fromBlock:a,onError:c,onLogs:u,poll:d,pollingInterval:l=e.pollingInterval,strict:f}=t;return(typeof d<"u"?d:typeof a=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")))?(()=>{const x=f??!1,g=ie(["watchContractEvent",r,s,o,e.uid,i,l,x,a]);return Ze(g,{onLogs:u,onError:c},A=>{let y;a!==void 0&&(y=a-1n);let w,v=!1;const E=Xt(async()=>{var P;if(!v){try{w=await M(e,Ba,"createContractEventFilter")({abi:n,address:r,args:s,eventName:i,strict:x,fromBlock:a})}catch{}v=!0;return}try{let I;if(w)I=await M(e,zr,"getFilterChanges")({filter:w});else{const T=await M(e,Jn,"getBlockNumber")({});y&&y<T?I=await M(e,tc,"getContractEvents")({abi:n,address:r,args:s,eventName:i,fromBlock:y+1n,toBlock:T,strict:x}):I=[],y=T}if(I.length===0)return;if(o)A.onLogs(I);else for(const T of I)A.onLogs([T])}catch(I){w&&I instanceof nt&&(v=!1),(P=A.onError)==null||P.call(A,I)}},{emitOnBegin:!0,interval:l});return async()=>{w&&await M(e,Rr,"uninstallFilter")({filter:w}),E()}})})():(()=>{const x=f??!1,g=ie(["watchContractEvent",r,s,o,e.uid,i,l,x]);let A=!0,y=()=>A=!1;return Ze(g,{onLogs:u,onError:c},w=>((async()=>{try{const v=(()=>{if(e.transport.type==="fallback"){const I=e.transport.transports.find(T=>T.config.type==="webSocket"||T.config.type==="ipc");return I?I.value:e.transport}return e.transport})(),E=i?_n({abi:n,eventName:i,args:s}):[],{unsubscribe:P}=await v.subscribe({params:["logs",{address:r,topics:E}],onData(I){var F;if(!A)return;const T=I.result;try{const{eventName:S,args:R}=ur({abi:n,data:T.data,topics:T.topics,strict:f}),k=Le(T,{args:R,eventName:S});w.onLogs([k])}catch(S){let R,k;if(S instanceof cr||S instanceof eo){if(f)return;R=S.abiItem.name,k=(F=S.abiItem.inputs)==null?void 0:F.some(C=>!("name"in C&&C.name))}const U=Le(T,{args:k?[]:{},eventName:R});w.onLogs([U])}},onError(I){var T;(T=w.onError)==null||T.call(w,I)}});y=P,A||y()}catch(v){c==null||c(v)}})(),()=>y()))})()}class it extends ${constructor({docsPath:t}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(`
42
- `),{docsPath:t,docsSlug:"account",name:"AccountNotFoundError"})}}class ht extends ${constructor({docsPath:t,metaMessages:n,type:r}){super(`Account type "${r}" is not supported.`,{docsPath:t,metaMessages:n,name:"AccountTypeNotSupportedError"})}}function To({chain:e,currentChainId:t}){if(!e)throw new Hf;if(t!==e.id)throw new qf({chain:e,currentChainId:t})}async function No(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}const rs=new Kt(128);async function Fr(e,t){var v,E,P,I,T,F;const{account:n=e.account,assertChainId:r=!0,chain:s=e.chain,accessList:o,authorizationList:i,blobs:a,data:c,dataSuffix:u=typeof e.dataSuffix=="string"?e.dataSuffix:(v=e.dataSuffix)==null?void 0:v.value,gas:d,gasPrice:l,maxFeePerBlobGas:f,maxFeePerGas:p,maxPriorityFeePerGas:h,nonce:m,type:x,value:g,...A}=t;if(typeof n>"u")throw new it({docsPath:"/docs/actions/wallet/sendTransaction"});const y=n?K(n):null;let w;try{Ye(t);const S=await(async()=>{if(t.to)return t.to;if(t.to!==null&&i&&i.length>0)return await Ar({authorization:i[0]}).catch(()=>{throw new $("`to` is required. Could not infer from `authorizationList`.")})})();if((y==null?void 0:y.type)==="json-rpc"||y===null){let R;s!==null&&(R=await M(e,Me,"getChainId")({}),r&&To({currentChainId:R,chain:s}));const k=(I=(P=(E=e.chain)==null?void 0:E.formatters)==null?void 0:P.transactionRequest)==null?void 0:I.format,C=(k||st)({...Yt(A,{format:k}),accessList:o,account:y,authorizationList:i,blobs:a,chainId:R,data:u?ne([c??"0x",u]):c,gas:d,gasPrice:l,maxFeePerBlobGas:f,maxFeePerGas:p,maxPriorityFeePerGas:h,nonce:m,to:S,type:x,value:g},"sendTransaction"),B=rs.get(e.uid),z=B?"wallet_sendTransaction":"eth_sendTransaction";try{return await e.request({method:z,params:[C]},{retryCount:0})}catch(N){if(B===!1)throw N;const O=N;if(O.name==="InvalidInputRpcError"||O.name==="InvalidParamsRpcError"||O.name==="MethodNotFoundRpcError"||O.name==="MethodNotSupportedRpcError")return await e.request({method:"wallet_sendTransaction",params:[C]},{retryCount:0}).then(L=>(rs.set(e.uid,!0),L)).catch(L=>{const D=L;throw D.name==="MethodNotFoundRpcError"||D.name==="MethodNotSupportedRpcError"?(rs.set(e.uid,!1),O):D});throw O}}if((y==null?void 0:y.type)==="local"){if(y.nonceManager&&typeof m>"u"){const C=A.chainId,B=await(async()=>typeof C=="number"?C:s?s.id:M(e,Me,"getChainId")({}))();w={address:y.address,chainId:B}}const R=await M(e,Vn,"prepareTransactionRequest")({account:y,accessList:o,authorizationList:i,blobs:a,chain:s,data:u?ne([c??"0x",u]):c,gas:d,gasPrice:l,maxFeePerBlobGas:f,maxFeePerGas:p,maxPriorityFeePerGas:h,nonce:m,nonceManager:y.nonceManager,parameters:[...vo,"sidecars"],type:x,value:g,...A,to:S}),k=(T=s==null?void 0:s.serializers)==null?void 0:T.transaction,U=await y.signTransaction(R,{serializer:k});return await M(e,No,"sendRawTransaction")({serializedTransaction:U})}throw(y==null?void 0:y.type)==="smart"?new ht({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new ht({docsPath:"/docs/actions/wallet/sendTransaction",type:y==null?void 0:y.type})}catch(S){throw S instanceof ht?S:(w&&((F=y==null?void 0:y.nonceManager)==null||F.reset(w)),$r(S,{...t,account:y,chain:t.chain||void 0}))}}async function Fn(e,t){return Fn.internal(e,Fr,"sendTransaction",t)}(function(e){async function t(n,r,s,o){const{abi:i,account:a=n.account,address:c,args:u,functionName:d,...l}=o;if(typeof a>"u")throw new it({docsPath:"/docs/contract/writeContract"});const f=a?K(a):null,p=he({abi:i,args:u,functionName:d});try{return await M(n,r,s)({data:p,to:c,account:f,...l})}catch(h){throw yt(h,{abi:i,address:c,args:u,docsPath:"/docs/contract/writeContract",functionName:d,sender:f==null?void 0:f.address})}}e.internal=t})(Fn||(Fn={}));class ch extends ${constructor(t){super(`Call bundle failed with status: ${t.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=t}}function fr(e,{delay:t=100,retryCount:n=2,shouldRetry:r=()=>!0,signal:s}={}){return new Promise((o,i)=>{const a=async({count:c=0}={})=>{if(s!=null&&s.aborted){i(bt(s));return}const u=async({error:d})=>{const l=typeof t=="function"?t({count:c,error:d}):t;if(l)try{await Ms(l,{signal:s})}catch(f){i(f);return}a({count:c+1})};try{const d=await e();o(d)}catch(d){if(s!=null&&s.aborted){i(bt(s));return}if(Er(d)){i(d);return}if(c<n&&await r({count:c,error:d}))return u({error:d});i(d)}};a()})}const $c={"0x0":"reverted","0x1":"success"};function Or(e,t){const n={...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(r=>Le(r)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Pe(e.transactionIndex):null,status:e.status?$c[e.status]:null,type:e.type?Ha[e.type]||e.type:null};return e.blobGasPrice&&(n.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(n.blobGasUsed=BigInt(e.blobGasUsed)),n}const uh=uo("transactionReceipt",Or),Sc="0x5792579257925792579257925792579257925792579257925792579257925792",Bc=j(0,{size:32});async function Tc(e,t){var f;const{account:n=e.account,chain:r=e.chain,experimental_fallback:s,experimental_fallbackDelay:o=32,forceAtomic:i=!1,id:a,version:c="2.0.0"}=t,u=n?K(n):null;let d=t.capabilities;e.dataSuffix&&!((f=t.capabilities)!=null&&f.dataSuffix)&&(typeof e.dataSuffix=="string"?d={...t.capabilities,dataSuffix:{value:e.dataSuffix,optional:!0}}:d={...t.capabilities,dataSuffix:{value:e.dataSuffix.value,...e.dataSuffix.required?{}:{optional:!0}}});const l=t.calls.map(p=>{const h=p,m=h.abi?he({abi:h.abi,functionName:h.functionName,args:h.args}):h.data;return{data:h.dataSuffix&&m?ne([m,h.dataSuffix]):m,to:h.to,value:h.value?j(h.value):void 0}});try{const p=await e.request({method:"wallet_sendCalls",params:[{atomicRequired:i,calls:l,capabilities:d,chainId:j(r.id),from:u==null?void 0:u.address,id:a,version:c}]},{retryCount:0});return typeof p=="string"?{id:p}:p}catch(p){const h=p;if(s&&(h.name==="MethodNotFoundRpcError"||h.name==="MethodNotSupportedRpcError"||h.name==="UnknownRpcError"||h.details.toLowerCase().includes("does not exist / is not available")||h.details.toLowerCase().includes("missing or invalid. request()")||h.details.toLowerCase().includes("did not match any variant of untagged enum")||h.details.toLowerCase().includes("account upgraded to unsupported contract")||h.details.toLowerCase().includes("eip-7702 not supported")||h.details.toLowerCase().includes("unsupported wc_ method")||h.details.toLowerCase().includes("feature toggled misconfigured")||h.details.toLowerCase().includes("jsonrpcengine: response has no error or result for request"))){if(d&&Object.values(d).some(A=>!A.optional)){const A="non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";throw new Gt(new $(A,{details:A}))}if(i&&l.length>1){const g="`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";throw new qt(new $(g,{details:g}))}const m=[];for(const g of l){try{const A=await Fr(e,{account:u,chain:r,data:g.data,to:g.to,value:g.value?Q(g.value):void 0});m.push({status:"fulfilled",value:A})}catch(A){m.push({reason:A,status:"rejected"})}o>0&&await new Promise(A=>setTimeout(A,o))}if(m.every(g=>g.status==="rejected"))throw m[0].reason;const x=m.map(g=>g.status==="fulfilled"?g.value:Bc);return{id:ne([...x,j(r.id,{size:32}),Sc])}}throw $r(p,{...t,account:u,chain:t.chain})}}async function Nc(e,t){async function n(d){if(d.endsWith(Sc.slice(2))){const f=we(xs(d,-64,-32)),p=xs(d,0,-64).slice(2).match(/.{1,64}/g),h=await Promise.all(p.map(x=>Bc.slice(2)!==x?e.request({method:"eth_getTransactionReceipt",params:[`0x${x}`]},{dedupe:!0}):void 0)),m=h.some(x=>x===null)?100:h.every(x=>(x==null?void 0:x.status)==="0x1")?200:h.every(x=>(x==null?void 0:x.status)==="0x0")?500:600;return{atomic:!1,chainId:Pe(f),receipts:h.filter(Boolean),status:m,version:"2.0.0"}}return e.request({method:"wallet_getCallsStatus",params:[d]})}const{atomic:r=!1,chainId:s,receipts:o,version:i="2.0.0",...a}=await n(t.id),[c,u]=(()=>{const d=a.status;return d>=100&&d<200?["pending",d]:d>=200&&d<300?["success",d]:d>=300&&d<700?["failure",d]:d==="CONFIRMED"?["success",200]:d==="PENDING"?["pending",100]:[void 0,d]})();return{...a,atomic:r,chainId:s?Pe(s):void 0,receipts:(o==null?void 0:o.map(d=>({...d,blockNumber:Q(d.blockNumber),gasUsed:Q(d.gasUsed),status:$c[d.status]})))??[],statusCode:u,status:c,version:i}}async function kc(e,t){const{id:n,pollingInterval:r=e.pollingInterval,status:s=({statusCode:m})=>m===200||m>=300,retryCount:o=4,retryDelay:i=({count:m})=>~~(1<<m)*200,timeout:a=6e4,throwOnFailure:c=!1}=t,u=ie(["waitForCallsStatus",e.uid,n]),{promise:d,resolve:l,reject:f}=Bo();let p;const h=Ze(u,{resolve:l,reject:f},m=>{const x=Xt(async()=>{const g=A=>{clearTimeout(p),x(),A(),h()};try{const A=await fr(async()=>{const y=await M(e,Nc,"getCallsStatus")({id:n});if(c&&y.status==="failure")throw new ch(y);return y},{retryCount:o,delay:i});if(!s(A))return;g(()=>m.resolve(A))}catch(A){g(()=>m.reject(A))}},{interval:r,emitOnBegin:!0});return x});return p=a?setTimeout(()=>{h(),clearTimeout(p),f(new dh({id:n}))},a):void 0,await d}class dh extends ${constructor({id:t}){super(`Timed out while waiting for call bundle with id "${t}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}const Ls=256;let rr=Ls,sr;function jc(e=11){if(!sr||rr+e>Ls*2){sr="",rr=0;for(let t=0;t<Ls;t++)sr+=(256+Math.random()*256|0).toString(16).substring(1)}return sr.substring(rr,rr+++e)}function zc(e){const{batch:t,chain:n,ccipRead:r,dataSuffix:s,key:o="base",name:i="Base Client",type:a="base"}=e,c=e.experimental_blockTag??(typeof(n==null?void 0:n.experimental_preconfirmationTime)=="number"?"pending":void 0),u=(n==null?void 0:n.blockTime)??12e3,d=Math.min(Math.max(Math.floor(u/2),500),4e3),l=e.pollingInterval??d,f=e.cacheTime??l,p=e.account?K(e.account):void 0,{config:h,request:m,value:x}=e.transport({account:p,chain:n,pollingInterval:l}),g={...h,...x},A={account:p,batch:t,cacheTime:f,ccipRead:r,chain:n,dataSuffix:s,key:o,name:i,pollingInterval:l,request:m,transport:g,type:a,uid:jc(),...c?{experimental_blockTag:c}:{}};function y(w){return v=>{const E=v(w);for(const I in A)delete E[I];const P={...w,...E};return Object.assign(P,{extend:y(P)})}}return Object.assign(A,{extend:y(A)})}function ko(e){var n,r,s,o,i,a;if(!(e instanceof $))return!1;const t=e.walk(c=>c instanceof As);return t instanceof As?((n=t.data)==null?void 0:n.errorName)==="HttpError"||((r=t.data)==null?void 0:r.errorName)==="ResolverError"||((s=t.data)==null?void 0:s.errorName)==="ResolverNotContract"||((o=t.data)==null?void 0:o.errorName)==="ResolverNotFound"||((i=t.data)==null?void 0:i.errorName)==="ReverseAddressMismatch"||((a=t.data)==null?void 0:a.errorName)==="UnsupportedResolverProfile":!1}function lh(e){const{abi:t,data:n}=e,r=tt(n,0,4),s=t.find(o=>o.type==="function"&&r===Un($e(o)));if(!s)throw new Y0(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:s.name,args:"inputs"in s&&s.inputs&&s.inputs.length>0?Dn(s.inputs,tt(n,4)):void 0}}const ss="/docs/contract/encodeErrorResult";function ki(e){const{abi:t,errorName:n,args:r}=e;let s=t[0];if(n){const c=It({abi:t,args:r,name:n});if(!c)throw new ni(n,{docsPath:ss});s=c}if(s.type!=="error")throw new ni(void 0,{docsPath:ss});const o=$e(s),i=Un(o);let a="0x";if(r&&r.length>0){if(!s.inputs)throw new W0(s.name,{docsPath:ss});a=At(s.inputs,r)}return ke([i,a])}const os="/docs/contract/encodeFunctionResult";function fh(e){const{abi:t,functionName:n,result:r}=e;let s=t[0];if(n){const i=It({abi:t,name:n});if(!i)throw new Mt(n,{docsPath:os});s=i}if(s.type!=="function")throw new Mt(void 0,{docsPath:os});if(!s.outputs)throw new la(s.name,{docsPath:os});const o=(()=>{if(s.outputs.length===0)return[];if(s.outputs.length===1)return[r];if(Array.isArray(r))return r;throw new fa(r)})();return At(s.outputs,o)}const Mr="x-batch-gateway:true";async function hh(e){const{data:t,ccipRequest:n}=e,{args:[r]}=lh({abi:Fs,data:t}),s=[],o=[];return await Promise.all(r.map(async(i,a)=>{try{o[a]=i.urls.includes(Mr)?await hh({data:i.data,ccipRequest:n}):await n(i),s[a]=!1}catch(c){s[a]=!0,o[a]=ph(c)}})),fh({abi:Fs,functionName:"query",result:[s,o]})}function ph(e){return e.name==="HttpRequestError"&&e.status?ki({abi:Fs,errorName:"HttpError",args:[e.status,e.shortMessage]}):ki({abi:[Ta],errorName:"Error",args:["shortMessage"in e?e.shortMessage:e.message]})}function Rc(e){if(e.length!==66||e.indexOf("[")!==0||e.indexOf("]")!==65)return null;const t=`0x${e.slice(1,65)}`;return Fe(t)?t:null}function Us(e){let t=new Uint8Array(32).fill(0);if(!e)return Y(t);const n=e.split(".");for(let r=n.length-1;r>=0;r-=1){const s=Rc(n[r]),o=s?Zt(s):te(lt(n[r]),"bytes");t=te(ne([t,o]),"bytes")}return Y(t)}function bh(e){return`[${e.slice(2)}]`}function mh(e){const t=new Uint8Array(32).fill(0);return e?Rc(e)||te(lt(e)):Y(t)}function jo(e){const t=e.replace(/^\.|\.$/gm,"");if(t.length===0)return new Uint8Array(1);const n=new Uint8Array(lt(t).byteLength+2);let r=0;const s=t.split(".");for(let o=0;o<s.length;o++){let i=lt(s[o]);i.byteLength>255&&(i=lt(bh(mh(s[o])))),n[r]=i.length,n.set(i,r+1),r+=i.length+1}return n.byteLength!==r+1?n.slice(0,r+1):n}async function yh(e,t){const{blockNumber:n,blockTag:r,coinType:s,name:o,gatewayUrls:i,strict:a}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Jt({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),d=c==null?void 0:c.ensTlds;if(d&&!d.some(f=>o.endsWith(f)))return null;const l=s!=null?[Us(o),BigInt(s)]:[Us(o)];try{const f=he({abi:xc,functionName:"addr",args:l}),p={address:u,abi:wc,functionName:"resolveWithGateways",args:[de(jo(o)),f,i??[Mr]],blockNumber:n,blockTag:r},m=await M(e,Te,"readContract")(p);if(m[0]==="0x")return null;const x=gh({coinType:s,data:m[0],args:l});return x==="0x"||we(x)==="0x00"?null:x}catch(f){if(a)throw f;if(ko(f))return null;throw f}}function gh({coinType:e,data:t,args:n}){try{return ot({abi:xc,args:n,functionName:"addr",data:t})}catch(r){if(e==null)throw r;const s=we(t);if(Z(s)===20)return _t(s);throw r}}class wh extends ${constructor({data:t}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(t)}`],name:"EnsAvatarInvalidMetadataError"})}}class an extends ${constructor({reason:t}){super(`ENS NFT avatar URI is invalid. ${t}`,{name:"EnsAvatarInvalidNftUriError"})}}class zo extends ${constructor({uri:t}){super(`Unable to resolve ENS avatar URI "${t}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class xh extends ${constructor({namespace:t}){super(`ENS NFT avatar namespace "${t}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const vh=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,Eh=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/,Ph=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,Ah=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function Ih(e){try{const t=await fetch(e,{method:"HEAD"});if(t.status===200){const n=t.headers.get("content-type");return n==null?void 0:n.startsWith("image/")}return!1}catch(t){return typeof t=="object"&&typeof t.response<"u"||!Object.hasOwn(globalThis,"Image")?!1:new Promise(n=>{const r=new Image;r.onload=()=>{n(!0)},r.onerror=()=>{n(!1)},r.src=e})}}function ji(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function Fc({uri:e,gatewayUrls:t}){const n=Ph.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=ji(t==null?void 0:t.ipfs,"https://ipfs.io"),s=ji(t==null?void 0:t.arweave,"https://arweave.net"),o=e.match(vh),{protocol:i,subpath:a,target:c,subtarget:u=""}=(o==null?void 0:o.groups)||{},d=i==="ipns:/"||a==="ipns/",l=i==="ipfs:/"||a==="ipfs/"||Eh.test(e);if(e.startsWith("http")&&!d&&!l){let p=e;return t!=null&&t.arweave&&(p=e.replace(/https:\/\/arweave.net/g,t==null?void 0:t.arweave)),{uri:p,isOnChain:!1,isEncoded:!1}}if((d||l)&&c)return{uri:`${r}/${d?"ipns":"ipfs"}/${c}${u}`,isOnChain:!1,isEncoded:!1};if(i==="ar:/"&&c)return{uri:`${s}/${c}${u||""}`,isOnChain:!1,isEncoded:!1};let f=e.replace(Ah,"");if(f.startsWith("<svg")&&(f=`data:image/svg+xml;base64,${btoa(f)}`),f.startsWith("data:")||f.startsWith("{"))return{uri:f,isOnChain:!0,isEncoded:!1};throw new zo({uri:e})}function Oc(e){if(typeof e!="object"||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new wh({data:e});return e.image||e.image_url||e.image_data}async function Ch({gatewayUrls:e,uri:t}){try{const n=await fetch(t).then(s=>s.json());return await Ro({gatewayUrls:e,uri:Oc(n)})}catch{throw new zo({uri:t})}}async function Ro({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=Fc({uri:t,gatewayUrls:e});if(r||await Ih(n))return n;throw new zo({uri:t})}function $h(e){let t=e;t.startsWith("did:nft:")&&(t=t.replace("did:nft:","").replace(/_/g,"/"));const[n,r,s]=t.split("/"),[o,i]=n.split(":"),[a,c]=r.split(":");if(!o||o.toLowerCase()!=="eip155")throw new an({reason:"Only EIP-155 supported"});if(!i)throw new an({reason:"Chain ID not found"});if(!c)throw new an({reason:"Contract address not found"});if(!s)throw new an({reason:"Token ID not found"});if(!a)throw new an({reason:"ERC namespace not found"});return{chainID:Number.parseInt(i,10),namespace:a.toLowerCase(),contractAddress:c,tokenID:s}}async function Sh(e,{nft:t}){if(t.namespace==="erc721")return Te(e,{address:t.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(t.tokenID)]});if(t.namespace==="erc1155")return Te(e,{address:t.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(t.tokenID)]});throw new xh({namespace:t.namespace})}async function Bh(e,{gatewayUrls:t,record:n}){return/eip155:/i.test(n)?Th(e,{gatewayUrls:t,record:n}):Ro({uri:n,gatewayUrls:t})}async function Th(e,{gatewayUrls:t,record:n}){const r=$h(n),s=await Sh(e,{nft:r}),{uri:o,isOnChain:i,isEncoded:a}=Fc({uri:s,gatewayUrls:t});if(i&&(o.includes("data:application/json;base64,")||o.startsWith("{"))){const u=a?atob(o.replace("data:application/json;base64,","")):o,d=JSON.parse(u);return Ro({uri:Oc(d),gatewayUrls:t})}let c=r.tokenID;return r.namespace==="erc1155"&&(c=c.replace("0x","").padStart(64,"0")),Ch({gatewayUrls:t,uri:o.replace(/(?:0x)?{id}/,c)})}async function Mc(e,t){const{blockNumber:n,blockTag:r,key:s,name:o,gatewayUrls:i,strict:a}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Jt({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),d=c==null?void 0:c.ensTlds;if(d&&!d.some(l=>o.endsWith(l)))return null;try{const l={address:u,abi:wc,args:[de(jo(o)),he({abi:Si,functionName:"text",args:[Us(o),s]}),i??[Mr]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},p=await M(e,Te,"readContract")(l);if(p[0]==="0x")return null;const h=ot({abi:Si,functionName:"text",data:p[0]});return h===""?null:h}catch(l){if(a)throw l;if(ko(l))return null;throw l}}async function Nh(e,{blockNumber:t,blockTag:n,assetGatewayUrls:r,name:s,gatewayUrls:o,strict:i,universalResolverAddress:a}){const c=await M(e,Mc,"getEnsText")({blockNumber:t,blockTag:n,key:"avatar",name:s,universalResolverAddress:a,gatewayUrls:o,strict:i});if(!c)return null;try{return await Bh(e,{record:c,gatewayUrls:r})}catch{return null}}async function kh(e,t){const{address:n,blockNumber:r,blockTag:s,coinType:o=60n,gatewayUrls:i,strict:a}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Jt({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})();try{const d={address:u,abi:Uf,args:[n,o,i??[Mr]],functionName:"reverseWithGateways",blockNumber:r,blockTag:s},l=M(e,Te,"readContract"),[f]=await l(d);return f||null}catch(d){if(a)throw d;if(ko(d))return null;throw d}}async function jh(e,t){const{blockNumber:n,blockTag:r,name:s}=t,{chain:o}=e,i=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!o)throw new Error("client chain not configured. universalResolverAddress is required.");return Jt({blockNumber:n,chain:o,contract:"ensUniversalResolver"})})(),a=o==null?void 0:o.ensTlds;if(a&&!a.some(u=>s.endsWith(u)))throw new Error(`${s} is not a valid ENS TLD (${a==null?void 0:a.join(", ")}) for chain "${o.name}" (id: ${o.id}).`);const[c]=await M(e,Te,"readContract")({address:i,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[de(jo(s))],blockNumber:n,blockTag:r});return c}async function Lc(e,t){var x,g,A;const{account:n=e.account,blockNumber:r,blockTag:s="latest",blobs:o,data:i,gas:a,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:d,maxPriorityFeePerGas:l,to:f,value:p,...h}=t,m=n?K(n):void 0;try{Ye(t);const w=(typeof r=="bigint"?j(r):void 0)||s,v=(A=(g=(x=e.chain)==null?void 0:x.formatters)==null?void 0:g.transactionRequest)==null?void 0:A.format,P=(v||st)({...Yt(h,{format:v}),account:m,blobs:o,data:i,gas:a,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:d,maxPriorityFeePerGas:l,to:f,value:p},"createAccessList"),I=await e.request({method:"eth_createAccessList",params:[P,w]});if(I.error)throw new $(I.error,{details:I.error});return{accessList:I.accessList,gasUsed:BigInt(I.gasUsed)}}catch(y){throw Ac(y,{...t,account:m,chain:e.chain})}}async function zh(e){const t=vr(e,{method:"eth_newBlockFilter"}),n=await e.request({method:"eth_newBlockFilter"});return{id:n,request:t(n),type:"block"}}async function Uc(e,{address:t,args:n,event:r,events:s,fromBlock:o,strict:i,toBlock:a}={}){const c=s??(r?[r]:void 0),u=vr(e,{method:"eth_newFilter"});let d=[];c&&(d=[c.flatMap(p=>_n({abi:[p],eventName:p.name,args:n}))],r&&(d=d[0]));const l=await e.request({method:"eth_newFilter",params:[{address:t,fromBlock:typeof o=="bigint"?j(o):o,toBlock:typeof a=="bigint"?j(a):a,...d.length?{topics:d}:{}}]});return{abi:c,args:n,eventName:r?r.name:void 0,fromBlock:o,id:l,request:u(l),strict:!!i,toBlock:a,type:"event"}}async function _c(e){const t=vr(e,{method:"eth_newPendingTransactionFilter"}),n=await e.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:t(n),type:"transaction"}}async function Rh(e,{address:t,blockHash:n,blockNumber:r,blockTag:s=e.experimental_blockTag??"latest",requireCanonical:o}){var c,u,d;const i=Ct({blockHash:n,blockNumber:r,blockTag:s,requireCanonical:o});if((c=e.batch)!=null&&c.multicall&&((d=(u=e.chain)==null?void 0:u.contracts)!=null&&d.multicall3)){const l=e.chain.contracts.multicall3.address,f=he({abi:Ht,functionName:"getEthBalance",args:[t]}),{data:p}=await M(e,Yn,"call")({to:l,data:f,blockHash:n,blockNumber:r,blockTag:s,requireCanonical:o});return ot({abi:Ht,functionName:"getEthBalance",args:[t],data:p||"0x"})}const a=await e.request({method:"eth_getBalance",params:[t,i]});return BigInt(a)}async function Fh(e){const t=await e.request({method:"eth_blobBaseFee"});return BigInt(t)}async function Oh(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest"}={}){var a,c,u;const s=n!==void 0?j(n):void 0,o=await e.request({method:"eth_getBlockReceipts",params:[t||s||r]},{dedupe:!!(t||s)});if(!o)throw new ho({blockHash:t,blockNumber:n});const i=((u=(c=(a=e.chain)==null?void 0:a.formatters)==null?void 0:c.transactionReceipt)==null?void 0:u.format)||Or;return o.map(d=>i(d,"getBlockReceipts"))}async function Mh(e,{blockHash:t,blockNumber:n,blockTag:r="latest"}={}){const s=n!==void 0?j(n):void 0;let o;return t?o=await e.request({method:"eth_getBlockTransactionCountByHash",params:[t]},{dedupe:!0}):o=await e.request({method:"eth_getBlockTransactionCountByNumber",params:[s||r]},{dedupe:!!s}),Pe(o)}async function hr(e,{address:t,blockHash:n,blockNumber:r,blockTag:s="latest",requireCanonical:o}){const i=Ct({blockHash:n,blockNumber:r,blockTag:s,requireCanonical:o}),a=await e.request({method:"eth_getCode",params:[t,i]},{dedupe:typeof r=="bigint"||n!==void 0});if(a!=="0x")return a}async function Lh(e,{address:t,blockNumber:n,blockTag:r="latest"}){const s=await hr(e,{address:t,...n!==void 0?{blockNumber:n}:{blockTag:r}});if(s&&Z(s)===23&&s.startsWith("0xef0100"))return _t(tt(s,3,23))}class Uh extends ${constructor({address:t}){super(`No EIP-712 domain found on contract "${t}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${t}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}async function _h(e,t){const{address:n,factory:r,factoryData:s}=t;try{const[o,i,a,c,u,d,l]=await M(e,Te,"readContract")({abi:Dh,address:n,functionName:"eip712Domain",factory:r,factoryData:s});return{domain:{name:i,version:a,chainId:Number(c),verifyingContract:u,salt:d},extensions:l,fields:o}}catch(o){const i=o;throw i.name==="ContractFunctionExecutionError"&&i.cause.name==="ContractFunctionZeroDataError"?new Uh({address:n}):i}}const Dh=[{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 Gh(e){var t;return{baseFeePerGas:e.baseFeePerGas.map(n=>BigInt(n)),gasUsedRatio:e.gasUsedRatio,oldestBlock:BigInt(e.oldestBlock),reward:(t=e.reward)==null?void 0:t.map(n=>n.map(r=>BigInt(r)))}}async function qh(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:s}){const o=typeof n=="bigint"?j(n):void 0,i=await e.request({method:"eth_feeHistory",params:[j(t),o||r,s]},{dedupe:!!o});return Gh(i)}async function Hh(e,{filter:t}){const n=t.strict??!1,s=(await t.request({method:"eth_getFilterLogs",params:[t.id]})).map(o=>Le(o));return t.abi?Sr({abi:t.abi,logs:s,strict:n}):s}function Vh(e){const{authorizationList:t}=e;if(t)for(const n of t){const{chainId:r}=n,s=n.address;if(!J(s))throw new oe({address:s});if(r<0)throw new kr({chainId:r})}Fo(e)}function Wh(e){const{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new Xa;for(const n of t){const r=Z(n),s=Pe(tt(n,0,1));if(r!==32)throw new tf({hash:n,size:r});if(s!==Ja)throw new nf({hash:n,version:s})}}Fo(e)}function Fo(e){const{chainId:t,maxPriorityFeePerGas:n,maxFeePerGas:r,to:s}=e;if(t<=0)throw new kr({chainId:t});if(s&&!J(s))throw new oe({address:s});if(r&&r>Cr)throw new gt({maxFeePerGas:r});if(n&&r&&n>r)throw new jn({maxFeePerGas:r,maxPriorityFeePerGas:n})}function Zh(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:s,to:o}=e;if(t<=0)throw new kr({chainId:t});if(o&&!J(o))throw new oe({address:o});if(n||s)throw new $("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>Cr)throw new gt({maxFeePerGas:r})}function Kh(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:s,to:o}=e;if(o&&!J(o))throw new oe({address:o});if(typeof t<"u"&&t<=0)throw new kr({chainId:t});if(n||s)throw new $("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>Cr)throw new gt({maxFeePerGas:r})}function Lr(e){if(!e||e.length===0)return[];const t=[];for(let n=0;n<e.length;n++){const{address:r,storageKeys:s}=e[n];for(let o=0;o<s.length;o++)if(s[o].length-2!==64)throw new xl({storageKey:s[o]});if(!J(r,{strict:!1}))throw new oe({address:r});t.push([r,s])}return t}function Yh(e,t){const n=ec(e);return n==="eip1559"?Qh(e,t):n==="eip2930"?ep(e,t):n==="eip4844"?Xh(e,t):n==="eip7702"?Jh(e,t):tp(e,t)}function Jh(e,t){const{authorizationList:n,chainId:r,gas:s,nonce:o,to:i,value:a,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=e;Vh(e);const f=Lr(d),p=np(n);return ke(["0x04",rt([j(r),o?j(o):"0x",u?j(u):"0x",c?j(c):"0x",s?j(s):"0x",i??"0x",a?j(a):"0x",l??"0x",f,p,...Xn(e,t)])])}function Xh(e,t){const{chainId:n,gas:r,nonce:s,to:o,value:i,maxFeePerBlobGas:a,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=e;Wh(e);let f=e.blobVersionedHashes,p=e.sidecars;if(e.blobs&&(typeof f>"u"||typeof p>"u")){const y=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(E=>Y(E)),w=e.kzg,v=yo({blobs:y,kzg:w});if(typeof f>"u"&&(f=Za({commitments:v})),typeof p>"u"){const E=go({blobs:y,commitments:v,kzg:w});p=Qa({blobs:y,commitments:v,proofs:E})}}const h=Lr(d),m=[j(n),s?j(s):"0x",u?j(u):"0x",c?j(c):"0x",r?j(r):"0x",o??"0x",i?j(i):"0x",l??"0x",h,a?j(a):"0x",f??[],...Xn(e,t)],x=[],g=[],A=[];if(p)for(let y=0;y<p.length;y++){const{blob:w,commitment:v,proof:E}=p[y];x.push(w),g.push(v),A.push(E)}return ke(["0x03",rt(p?[m,x,g,A]:m)])}function Qh(e,t){const{chainId:n,gas:r,nonce:s,to:o,value:i,maxFeePerGas:a,maxPriorityFeePerGas:c,accessList:u,data:d}=e;Fo(e);const l=Lr(u),f=[j(n),s?j(s):"0x",c?j(c):"0x",a?j(a):"0x",r?j(r):"0x",o??"0x",i?j(i):"0x",d??"0x",l,...Xn(e,t)];return ke(["0x02",rt(f)])}function ep(e,t){const{chainId:n,gas:r,data:s,nonce:o,to:i,value:a,accessList:c,gasPrice:u}=e;Zh(e);const d=Lr(c),l=[j(n),o?j(o):"0x",u?j(u):"0x",r?j(r):"0x",i??"0x",a?j(a):"0x",s??"0x",d,...Xn(e,t)];return ke(["0x01",rt(l)])}function tp(e,t){const{chainId:n=0,gas:r,data:s,nonce:o,to:i,value:a,gasPrice:c}=e;Kh(e);let u=[o?j(o):"0x",c?j(c):"0x",r?j(r):"0x",i??"0x",a?j(a):"0x",s??"0x"];if(t){const d=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(n>0)return BigInt(n*2)+BigInt(35n+t.v-27n);const p=27n+(t.v===27n?0n:1n);if(t.v!==p)throw new gl({v:t.v});return p})(),l=we(t.r),f=we(t.s);u=[...u,j(d),l==="0x00"?"0x":l,f==="0x00"?"0x":f]}else n>0&&(u=[...u,j(n),"0x","0x"]);return rt(u)}function Xn(e,t){const n=t??e,{v:r,yParity:s}=n;if(typeof n.r>"u")return[];if(typeof n.s>"u")return[];if(typeof r>"u"&&typeof s>"u")return[];const o=we(n.r),i=we(n.s);return[typeof s=="number"?s?j(1):"0x":r===0n?"0x":r===1n?j(1):r===27n?"0x":j(1),o==="0x00"?"0x":o,i==="0x00"?"0x":i]}function np(e){if(!e||e.length===0)return[];const t=[];for(const n of e){const{chainId:r,nonce:s,...o}=n,i=n.address;t.push([r?de(r):"0x",i,s?de(s):"0x",...Xn({},o)])}return t}async function rp({address:e,authorization:t,signature:n}){return wt(_t(e),await Ar({authorization:t,signature:n}))}const or=new Kt(8192);function sp(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(or.get(n))return or.get(n);const r=e().finally(()=>or.delete(n));return or.set(n,r),r}function op(e,t={}){return async(n,r={})=>{var f;const{dedupe:s=!1,methods:o,retryDelay:i=150,retryCount:a=3,signal:c,uid:u}={...t,...r},{method:d}=n;if((f=o==null?void 0:o.exclude)!=null&&f.includes(d))throw new ut(new Error("method not supported"),{method:d});if(o!=null&&o.include&&!o.include.includes(d))throw new ut(new Error("method not supported"),{method:d});if(c!=null&&c.aborted)throw bt(c);const l=s?ap(`${u}.${ie(n)}`):void 0;return sp(()=>fr(async()=>{try{return await e(n,c?{signal:c}:void 0)}catch(p){if(c!=null&&c.aborted)throw bt(c);if(Er(p))throw p;const h=p;switch(h.code){case pn.code:throw new pn(h);case bn.code:throw new bn(h);case mn.code:throw new mn(h,{method:n.method});case yn.code:throw new yn(h);case mt.code:throw new mt(h);case nt.code:throw new nt(h);case gn.code:throw new gn(h);case wn.code:throw new wn(h);case xn.code:throw new xn(h);case ut.code:throw new ut(h,{method:n.method});case Dt.code:throw new Dt(h);case vn.code:throw new vn(h);case Rt.code:throw new Rt(h);case En.code:throw new En(h);case Pn.code:throw new Pn(h);case An.code:throw new An(h);case In.code:throw new In(h);case Cn.code:throw new Cn(h);case Gt.code:throw new Gt(h);case $n.code:throw new $n(h);case Sn.code:throw new Sn(h);case Bn.code:throw new Bn(h);case Tn.code:throw new Tn(h);case Nn.code:throw new Nn(h);case qt.code:throw new qt(h);case 5e3:throw new Rt(h);case kn.code:throw new kn(h);default:throw p instanceof $?p:new $l(h)}}},{delay:({count:p,error:h})=>{var m;if(h&&h instanceof Ua){const x=(m=h==null?void 0:h.headers)==null?void 0:m.get("Retry-After");if(x!=null&&x.match(/\d/))return Number.parseInt(x,10)*1e3}return~~(1<<p)*i},retryCount:a,signal:c,shouldRetry:({error:p})=>ip(p)}),{enabled:s,id:l})}}function ip(e){return Er(e)?!1:"code"in e&&typeof e.code=="number"?e.code===-1||e.code===Dt.code||e.code===mt.code||e.code===429:e instanceof Ua&&e.status?e.status===403||e.status===408||e.status===413||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504:!0}function ap(e,t=0){let n=3735928559^t,r=1103547991^t;for(let s=0;s<e.length;s++){const o=e.charCodeAt(s);n=Math.imul(n^o,2654435761),r=Math.imul(r^o,1597334677)}return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>16,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>16,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36)}function Qt(e){const t={formatters:void 0,fees:void 0,serializers:void 0,...e};function n(r){return s=>{const o=typeof s=="function"?s(r):s,i={...r,...o};return Object.assign(i,{extend:n(i)})}}return Object.assign(t,{extend:n(t)})}const cp=`Ethereum Signed Message:
43
- `;function up(e){const t=typeof e=="string"?ln(e):typeof e.raw=="string"?e.raw:Y(e.raw),n=ln(`${cp}${Z(t)}`);return ne([n,t])}function Dc(e,t){return te(up(e),t)}class dp extends ${constructor({domain:t}){super(`Invalid domain "${ie(t)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class lp extends ${constructor({primaryType:t,types:n}){super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(n))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class fp extends ${constructor({type:t}){super(`Struct type "${t}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function hp(e){const{domain:t,message:n,primaryType:r,types:s}=e,o=(c,u)=>{const d={...u};for(const l of c){const{name:f,type:p}=l;p==="address"&&(d[f]=d[f].toLowerCase())}return d},i=s.EIP712Domain?t?o(s.EIP712Domain,t):{}:{},a=(()=>{if(r!=="EIP712Domain")return o(s[r],n)})();return ie({domain:i,message:a,primaryType:r,types:s})}function Gc(e){const{domain:t,message:n,primaryType:r,types:s}=e,o=(i,a)=>{for(const c of i){const{name:u,type:d}=c,l=a[u],f=d.match($a);if(f&&(typeof l=="number"||typeof l=="bigint")){const[m,x,g]=f;j(l,{signed:x==="int",size:Number.parseInt(g,10)/8})}if(d==="address"&&typeof l=="string"&&!J(l))throw new oe({address:l});const p=d.match(Gd);if(p){const[m,x]=p;if(x&&Z(l)!==Number.parseInt(x,10))throw new X0({expectedSize:Number.parseInt(x,10),givenSize:Z(l)})}const h=s[d];h&&(pp(d),o(h,l))}};if(s.EIP712Domain&&t){if(typeof t!="object")throw new dp({domain:t});o(s.EIP712Domain,t)}if(r!=="EIP712Domain")if(s[r])o(s[r],n);else throw new lp({primaryType:r,types:s})}function qc({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},(typeof(e==null?void 0:e.chainId)=="number"||typeof(e==null?void 0:e.chainId)=="bigint")&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function pp(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new fp({type:e})}function bp(e){const{domain:t={},message:n,primaryType:r}=e,s={EIP712Domain:qc({domain:t}),...e.types};Gc({domain:t,message:n,primaryType:r,types:s});const o=["0x1901"];return t&&o.push(mp({domain:t,types:s})),r!=="EIP712Domain"&&o.push(Hc({data:n,primaryType:r,types:s})),te(ne(o))}function mp({domain:e,types:t}){return Hc({data:e,primaryType:"EIP712Domain",types:t})}function Hc({data:e,primaryType:t,types:n}){const r=Vc({data:e,primaryType:t,types:n});return te(r)}function Vc({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],s=[yp({primaryType:t,types:n})];for(const o of n[t]){const[i,a]=Zc({types:n,name:o.name,type:o.type,value:e[o.name]});r.push(i),s.push(a)}return At(r,s)}function yp({primaryType:e,types:t}){const n=de(gp({primaryType:e,types:t}));return te(n)}function gp({primaryType:e,types:t}){let n="";const r=Wc({primaryType:e,types:t});r.delete(e);const s=[e,...Array.from(r).sort()];for(const o of s)n+=`${o}(${t[o].map(({name:i,type:a})=>`${a} ${i}`).join(",")})`;return n}function Wc({primaryType:e,types:t},n=new Set){const r=e.match(/^\w*/u),s=r==null?void 0:r[0];if(n.has(s)||t[s]===void 0)return n;n.add(s);for(const o of t[s])Wc({primaryType:o.type,types:t},n);return n}function Zc({types:e,name:t,type:n,value:r}){if(e[n]!==void 0)return[{type:"bytes32"},te(Vc({data:r,primaryType:n,types:e}))];if(n==="bytes")return[{type:"bytes32"},te(r)];if(n==="string")return[{type:"bytes32"},te(de(r))];if(n.lastIndexOf("]")===n.length-1){const s=n.slice(0,n.lastIndexOf("[")),o=r.map(i=>Zc({name:t,type:s,types:e,value:i}));return[{type:"bytes32"},te(At(o.map(([i])=>i),o.map(([,i])=>i)))]}return[{type:n},r]}class wp extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const xp={checksum:new wp(8192)},is=xp.checksum;class Kc extends no{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,xd(t);const r=wr(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),Ut(o)}update(t){return Lt(this),this.iHash.update(t),this}digestInto(t){Lt(this),pt(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=a,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Yc=(e,t,n)=>new Kc(e,t).update(n).digest();Yc.create=(e,t)=>new Kc(e,t);function Jc(e,t={}){const{as:n=typeof e=="string"?"Hex":"Bytes"}=t,r=Ea(xf(e));return n==="Bytes"?r:Be(r)}const vp=/^0x[a-fA-F0-9]{40}$/;function Ur(e,t={}){const{strict:n=!0}=t;if(!vp.test(e))throw new zi({address:e,cause:new Ep});if(n){if(e.toLowerCase()===e)return;if(Xc(e)!==e)throw new zi({address:e,cause:new Pp})}}function Xc(e){if(is.has(e))return is.get(e);Ur(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=Jc(Ef(t),{as:"Bytes"}),r=t.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(n[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const s=`0x${r.join("")}`;return is.set(e,s),s}function _s(e,t={}){const{strict:n=!0}=t??{};try{return Ur(e,{strict:n}),!0}catch{return!1}}class zi extends _{constructor({address:t,cause:n}){super(`Address "${t}" is invalid.`,{cause:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Ep extends _{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 Pp extends _{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Ap=/^(.*)\[([0-9]*)\]$/,Ip=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Qc=/^(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)?$/,Ri=2n**256n-1n;function Ot(e,t,n){const{checksumAddress:r,staticPosition:s}=n,o=Lo(t.type);if(o){const[i,a]=o;return $p(e,{...t,type:a},{checksumAddress:r,length:i,staticPosition:s})}if(t.type==="tuple")return Np(e,t,{checksumAddress:r,staticPosition:s});if(t.type==="address")return Cp(e,{checksum:r});if(t.type==="bool")return Sp(e);if(t.type.startsWith("bytes"))return Bp(e,t,{staticPosition:s});if(t.type.startsWith("uint")||t.type.startsWith("int"))return Tp(e,t);if(t.type==="string")return kp(e,{staticPosition:s});throw new _o(t.type)}const Fi=32,Ds=32;function Cp(e,t={}){const{checksum:n=!1}=t,r=e.readBytes(32);return[(o=>n?Xc(o):o)(Be(Af(r,-20))),32]}function $p(e,t,n){const{checksumAddress:r,length:s,staticPosition:o}=n;if(!s){const c=Ve(e.readBytes(Ds)),u=o+c,d=u+Fi;e.setPosition(u);const l=Ve(e.readBytes(Fi)),f=On(t);let p=0;const h=[];for(let m=0;m<l;++m){e.setPosition(d+(f?m*32:p));const[x,g]=Ot(e,t,{checksumAddress:r,staticPosition:d});p+=g,h.push(x)}return e.setPosition(o+32),[h,32]}if(On(t)){const c=Ve(e.readBytes(Ds)),u=o+c,d=[];for(let l=0;l<s;++l){e.setPosition(u+l*32);const[f]=Ot(e,t,{checksumAddress:r,staticPosition:u});d.push(f)}return e.setPosition(o+32),[d,32]}let i=0;const a=[];for(let c=0;c<s;++c){const[u,d]=Ot(e,t,{checksumAddress:r,staticPosition:o+i});i+=d,a.push(u)}return[a,i]}function Sp(e){return[Cf(e.readBytes(32),{size:32}),32]}function Bp(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const i=Ve(e.readBytes(32));e.setPosition(n+i);const a=Ve(e.readBytes(32));if(a===0)return e.setPosition(n+32),["0x",32];const c=e.readBytes(a);return e.setPosition(n+32),[Be(c),32]}return[Be(e.readBytes(Number.parseInt(s,10),32)),32]}function Tp(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?If(s,{signed:n}):Ve(s,{signed:n}),32]}function Np(e,t,n){const{checksumAddress:r,staticPosition:s}=n,o=t.components.length===0||t.components.some(({name:c})=>!c),i=o?[]:{};let a=0;if(On(t)){const c=Ve(e.readBytes(Ds)),u=s+c;for(let d=0;d<t.components.length;++d){const l=t.components[d];e.setPosition(u+a);const[f,p]=Ot(e,l,{checksumAddress:r,staticPosition:u});a+=p,i[o?d:l==null?void 0:l.name]=f}return e.setPosition(s+32),[i,32]}for(let c=0;c<t.components.length;++c){const u=t.components[c],[d,l]=Ot(e,u,{checksumAddress:r,staticPosition:s});i[o?c:u==null?void 0:u.name]=d,a+=l}return[i,a]}function kp(e,{staticPosition:t}){const n=Ve(e.readBytes(32)),r=t+n;e.setPosition(r);const s=Ve(e.readBytes(32));if(s===0)return e.setPosition(t+32),["",32];const o=e.readBytes(s,32),i=$f(lc(o));return e.setPosition(t+32),[i,32]}function jp({checksumAddress:e,parameters:t,values:n}){const r=[];for(let s=0;s<t.length;s++)r.push(Oo({checksumAddress:e,parameter:t[s],value:n[s]}));return r}function Oo({checksumAddress:e=!1,parameter:t,value:n}){const r=t,s=Lo(r.type);if(s){const[o,i]=s;return Rp(n,{checksumAddress:e,length:o,parameter:{...r,type:i}})}if(r.type==="tuple")return Up(n,{checksumAddress:e,parameter:r});if(r.type==="address")return zp(n,{checksum:e});if(r.type==="bool")return Op(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const o=r.type.startsWith("int"),[,,i="256"]=Qc.exec(r.type)??[];return Mp(n,{signed:o,size:Number(i)})}if(r.type.startsWith("bytes"))return Fp(n,{type:r.type});if(r.type==="string")return Lp(n);throw new _o(r.type)}function Mo(e){let t=0;for(let o=0;o<e.length;o++){const{dynamic:i,encoded:a}=e[o];i?t+=32:t+=xe(a)}const n=[],r=[];let s=0;for(let o=0;o<e.length;o++){const{dynamic:i,encoded:a}=e[o];i?(n.push(re(t+s,{size:32})),r.push(a),s+=xe(a)):n.push(a)}return Se(...n,...r)}function zp(e,t){const{checksum:n=!1}=t;return Ur(e,{strict:n}),{dynamic:!1,encoded:xt(e.toLowerCase())}}function Rp(e,t){const{checksumAddress:n,length:r,parameter:s}=t,o=r===null;if(!Array.isArray(e))throw new Kp(e);if(!o&&e.length!==r)throw new Zp({expectedLength:r,givenLength:e.length,type:`${s.type}[${r}]`});let i=!1;const a=[];for(let c=0;c<e.length;c++){const u=Oo({checksumAddress:n,parameter:s,value:e[c]});u.dynamic&&(i=!0),a.push(u)}if(o||i){const c=Mo(a);if(o){const u=re(a.length,{size:32});return{dynamic:!0,encoded:a.length>0?Se(u,c):u}}if(i)return{dynamic:!0,encoded:c}}return{dynamic:!1,encoded:Se(...a.map(({encoded:c})=>c))}}function Fp(e,{type:t}){const[,n]=t.split("bytes"),r=xe(e);if(!n){let s=e;return r%32!==0&&(s=vt(s,Math.ceil((e.length-2)/2/32)*32)),{dynamic:!0,encoded:Se(xt(re(r,{size:32})),s)}}if(r!==Number.parseInt(n,10))throw new tu({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:vt(e)}}function Op(e){if(typeof e!="boolean")throw new _(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:xt(fc(e))}}function Mp(e,{signed:t,size:n}){if(typeof n=="number"){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new bc({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:re(e,{size:32,signed:t})}}function Lp(e){const t=$o(e),n=Math.ceil(xe(t)/32),r=[];for(let s=0;s<n;s++)r.push(vt(Re(t,s*32,(s+1)*32)));return{dynamic:!0,encoded:Se(vt(re(xe(t),{size:32})),...r)}}function Up(e,t){const{checksumAddress:n,parameter:r}=t;let s=!1;const o=[];for(let i=0;i<r.components.length;i++){const a=r.components[i],c=Array.isArray(e)?i:a.name,u=Oo({checksumAddress:n,parameter:a,value:e[c]});o.push(u),u.dynamic&&(s=!0)}return{dynamic:s,encoded:s?Mo(o):Se(...o.map(({encoded:i})=>i))}}function Lo(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function On(e){var r;const{type:t}=e;if(t==="string"||t==="bytes"||t.endsWith("[]"))return!0;if(t==="tuple")return(r=e.components)==null?void 0:r.some(On);const n=Lo(e.type);return!!(n&&On({...e,type:n[1]}))}const _p={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 qp({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Gp({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Oi({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 Oi({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,e&255),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 Dp(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(_p);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}class Oi extends _{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class Gp extends _{constructor({length:t,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class qp extends _{constructor({count:t,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function Hp(e,t,n={}){const{as:r="Array",checksumAddress:s=!1}=n,o=typeof t=="string"?dc(t):t,i=Dp(o);if(kt(o)===0&&e.length>0)throw new Wp;if(kt(o)&&kt(o)<32)throw new Vp({data:typeof t=="string"?t:Be(t),parameters:e,size:kt(o)});let a=0;const c=r==="Array"?[]:{};for(let u=0;u<e.length;++u){const d=e[u];i.setPosition(a);const[l,f]=Ot(i,d,{checksumAddress:s,staticPosition:0});a+=f,r==="Array"?c.push(l):c[d.name??u]=l}return c}function Uo(e,t,n){const{checksumAddress:r=!1}={};if(e.length!==t.length)throw new nu({expectedLength:e.length,givenLength:t.length});const s=jp({checksumAddress:r,parameters:e,values:t}),o=Mo(s);return o.length===0?"0x":o}function Gs(e,t){if(e.length!==t.length)throw new nu({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const s=e[r],o=t[r];n.push(Gs.encode(s,o))}return Se(...n)}(function(e){function t(n,r,s=!1){if(n==="address"){const c=r;return Ur(c),xt(c.toLowerCase(),s?32:0)}if(n==="string")return $o(r);if(n==="bytes")return r;if(n==="bool")return xt(fc(r),s?32:1);const o=n.match(Qc);if(o){const[c,u,d="256"]=o,l=Number.parseInt(d,10)/8;return re(r,{size:s?32:l,signed:u==="int"})}const i=n.match(Ip);if(i){const[c,u]=i;if(Number.parseInt(u,10)!==(r.length-2)/2)throw new tu({expectedSize:Number.parseInt(u,10),value:r});return vt(r,s?32:0)}const a=n.match(Ap);if(a&&Array.isArray(r)){const[c,u]=a,d=[];for(let l=0;l<r.length;l++)d.push(t(u,r[l],!0));return d.length===0?"0x":Se(...d)}throw new _o(n)}e.encode=t})(Gs||(Gs={}));function eu(e){return Array.isArray(e)&&typeof e[0]=="string"||typeof e=="string"?ei(e):e}class Vp extends _{constructor({data:t,parameters:n,size:r}){super(`Data size of ${r} bytes is too small for given parameters.`,{metaMessages:[`Params: (${Tt(n)})`,`Data: ${t} (${r} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Wp extends _{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Zp extends _{constructor({expectedLength:t,givenLength:n,type:r}){super(`Array length mismatch for type \`${r}\`. Expected: \`${t}\`. Given: \`${n}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class tu extends _{constructor({expectedSize:t,value:n}){super(`Size of bytes "${n}" (bytes${xe(n)}) does not match expected size (bytes${t}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class nu extends _{constructor({expectedLength:t,givenLength:n}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${t}`,`Given length (values): ${n}`].join(`
44
- `)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class Kp extends _{constructor(t){super(`Value \`${t}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class _o extends _{constructor(t){super(`Type \`${t}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ue=BigInt(0),se=BigInt(1),dt=BigInt(2),Yp=BigInt(3),ru=BigInt(4),su=BigInt(5),ou=BigInt(8);function ce(e,t){const n=e%t;return n>=ue?n:t+n}function ve(e,t,n){let r=e;for(;t-- >ue;)r*=r,r%=n;return r}function qs(e,t){if(e===ue)throw new Error("invert: expected non-zero number");if(t<=ue)throw new Error("invert: expected positive modulus, got "+t);let n=ce(e,t),r=t,s=ue,o=se;for(;n!==ue;){const a=r/n,c=r%n,u=s-o*a;r=n,n=c,s=o,o=u}if(r!==se)throw new Error("invert: does not exist");return ce(s,t)}function iu(e,t){const n=(e.ORDER+se)/ru,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function Jp(e,t){const n=(e.ORDER-su)/ou,r=e.mul(t,dt),s=e.pow(r,n),o=e.mul(t,s),i=e.mul(e.mul(o,dt),s),a=e.mul(o,e.sub(i,e.ONE));if(!e.eql(e.sqr(a),t))throw new Error("Cannot find square root");return a}function Xp(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-se,n=0;for(;t%dt===ue;)t/=dt,n++;let r=dt;const s=Do(e);for(;Mi(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return iu;let o=s.pow(r,t);const i=(t+se)/dt;return function(c,u){if(c.is0(u))return u;if(Mi(c,u)!==1)throw new Error("Cannot find square root");let d=n,l=c.mul(c.ONE,o),f=c.pow(u,t),p=c.pow(u,i);for(;!c.eql(f,c.ONE);){if(c.is0(f))return c.ZERO;let h=1,m=c.sqr(f);for(;!c.eql(m,c.ONE);)if(h++,m=c.sqr(m),h===d)throw new Error("Cannot find square root");const x=se<<BigInt(d-h-1),g=c.pow(l,x);d=h,l=c.sqr(g),f=c.mul(f,l),p=c.mul(p,g)}return p}}function Qp(e){return e%ru===Yp?iu:e%ou===su?Jp:Xp(e)}const e1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function t1(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=e1.reduce((r,s)=>(r[s]="function",r),t);return Tr(e,n)}function n1(e,t,n){if(n<ue)throw new Error("invalid exponent, negatives unsupported");if(n===ue)return e.ONE;if(n===se)return t;let r=e.ONE,s=t;for(;n>ue;)n&se&&(r=e.mul(r,s)),s=e.sqr(s),n>>=se;return r}function au(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce((i,a,c)=>e.is0(a)?i:(r[c]=i,e.mul(i,a)),e.ONE),o=e.inv(s);return t.reduceRight((i,a,c)=>e.is0(a)?i:(r[c]=e.mul(i,r[c]),e.mul(i,a)),o),r}function Mi(e,t){const n=(e.ORDER-se)/dt,r=e.pow(t,n),s=e.eql(r,e.ONE),o=e.eql(r,e.ZERO),i=e.eql(r,e.neg(e.ONE));if(!s&&!o&&!i)throw new Error("invalid Legendre symbol result");return s?1:o?0:-1}function cu(e,t){t!==void 0&&fn(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Do(e,t,n=!1,r={}){if(e<=ue)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:s,nByteLength:o}=cu(e,t);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i;const a=Object.freeze({ORDER:e,isLE:n,BITS:s,BYTES:o,MASK:Br(s),ZERO:ue,ONE:se,create:c=>ce(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ue<=c&&c<e},is0:c=>c===ue,isOdd:c=>(c&se)===se,neg:c=>ce(-c,e),eql:(c,u)=>c===u,sqr:c=>ce(c*c,e),add:(c,u)=>ce(c+u,e),sub:(c,u)=>ce(c-u,e),mul:(c,u)=>ce(c*u,e),pow:(c,u)=>n1(a,c,u),div:(c,u)=>ce(c*qs(u,e),e),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>qs(c,e),sqrt:r.sqrt||(c=>(i||(i=Qp(e)),i(a,c))),toBytes:c=>n?oc(c,o):Zn(c,o),fromBytes:c=>{if(c.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+c.length);return n?sc(c):ft(c)},invertBatch:c=>au(a,c),cmov:(c,u,d)=>d?u:c});return Object.freeze(a)}function uu(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function du(e){const t=uu(e);return t+Math.ceil(t/2)}function r1(e,t,n=!1){const r=e.length,s=uu(t),o=du(t);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const i=n?sc(e):ft(e),a=ce(i,t-se)+se;return n?oc(a,s):Zn(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Li=BigInt(0),Hs=BigInt(1);function as(e,t){const n=t.negate();return e?n:t}function lu(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function cs(e,t){lu(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),s=2**e,o=Br(e),i=BigInt(e);return{windows:n,windowSize:r,mask:o,maxNumber:s,shiftBy:i}}function Ui(e,t,n){const{windowSize:r,mask:s,maxNumber:o,shiftBy:i}=n;let a=Number(e&s),c=e>>i;a>r&&(a-=o,c+=Hs);const u=t*r,d=u+Math.abs(a)-1,l=a===0,f=a<0,p=t%2!==0;return{nextN:c,offset:d,isZero:l,isNeg:f,isNegF:p,offsetF:u}}function s1(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function o1(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const us=new WeakMap,fu=new WeakMap;function ds(e){return fu.get(e)||1}function i1(e,t){return{constTimeNegate:as,hasPrecomputes(n){return ds(n)!==1},unsafeLadder(n,r,s=e.ZERO){let o=n;for(;r>Li;)r&Hs&&(s=s.add(o)),o=o.double(),r>>=Hs;return s},precomputeWindow(n,r){const{windows:s,windowSize:o}=cs(r,t),i=[];let a=n,c=a;for(let u=0;u<s;u++){c=a,i.push(c);for(let d=1;d<o;d++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(n,r,s){let o=e.ZERO,i=e.BASE;const a=cs(n,t);for(let c=0;c<a.windows;c++){const{nextN:u,offset:d,isZero:l,isNeg:f,isNegF:p,offsetF:h}=Ui(s,c,a);s=u,l?i=i.add(as(p,r[h])):o=o.add(as(f,r[d]))}return{p:o,f:i}},wNAFUnsafe(n,r,s,o=e.ZERO){const i=cs(n,t);for(let a=0;a<i.windows&&s!==Li;a++){const{nextN:c,offset:u,isZero:d,isNeg:l}=Ui(s,a,i);if(s=c,!d){const f=r[u];o=o.add(l?f.negate():f)}}return o},getPrecomputes(n,r,s){let o=us.get(r);return o||(o=this.precomputeWindow(r,n),n!==1&&us.set(r,s(o))),o},wNAFCached(n,r,s){const o=ds(n);return this.wNAF(o,this.getPrecomputes(o,n,s),r)},wNAFCachedUnsafe(n,r,s,o){const i=ds(n);return i===1?this.unsafeLadder(n,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,n,s),r,o)},setWindowSize(n,r){lu(r,t),fu.set(n,r),us.delete(n)}}}function a1(e,t,n,r){s1(n,e),o1(r,t);const s=n.length,o=r.length;if(s!==o)throw new Error("arrays of points and scalars must have equal length");const i=e.ZERO,a=uf(BigInt(s));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Br(c),d=new Array(Number(u)+1).fill(i),l=Math.floor((t.BITS-1)/c)*c;let f=i;for(let p=l;p>=0;p-=c){d.fill(i);for(let m=0;m<o;m++){const x=r[m],g=Number(x>>BigInt(p)&u);d[g]=d[g].add(n[m])}let h=i;for(let m=d.length-1,x=i;m>0;m--)x=x.add(d[m]),h=h.add(x);if(f=f.add(h),p!==0)for(let m=0;m<c;m++)f=f.double()}return f}function hu(e){return t1(e.Fp),Tr(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...cu(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function _i(e){e.lowS!==void 0&&zn("lowS",e.lowS),e.prehash!==void 0&&zn("prehash",e.prehash)}function c1(e){const t=hu(e);Tr(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(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}class u1 extends Error{constructor(t=""){super(t)}}const Ge={Err:u1,_tlv:{encode:(e,t)=>{const{Err:n}=Ge;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=tr(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?tr(s.length/2|128):"";return tr(e)+o+s+t},decode(e,t){const{Err:n}=Ge;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++],o=!!(s&128);let i=0;if(!o)i=s;else{const c=s&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const u=t.subarray(r,r+c);if(u.length!==c)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const d of u)i=i<<8|d;if(r+=c,i<128)throw new n("tlv.decode(long): not minimal encoding")}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}=Ge;if(e<qe)throw new t("integer: negative integers are not allowed");let n=tr(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=Ge;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ft(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Ge,s=Ee("signature",e),{v:o,l:i}=r.decode(48,s);if(i.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,o),{v:u,l:d}=r.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=Ge,r=t.encode(2,n.encode(e.r)),s=t.encode(2,n.encode(e.s)),o=r+s;return t.encode(48,o)}};function ls(e,t){return Rn(Zn(e,t))}const qe=BigInt(0),X=BigInt(1);BigInt(2);const fs=BigInt(3),d1=BigInt(4);function l1(e){const t=c1(e),{Fp:n}=t,r=Do(t.n,t.nBitLength),s=t.toBytes||((y,w,v)=>{const E=w.toAffine();return lr(Uint8Array.from([4]),n.toBytes(E.x),n.toBytes(E.y))}),o=t.fromBytes||(y=>{const w=y.subarray(1),v=n.fromBytes(w.subarray(0,n.BYTES)),E=n.fromBytes(w.subarray(n.BYTES,2*n.BYTES));return{x:v,y:E}});function i(y){const{a:w,b:v}=t,E=n.sqr(y),P=n.mul(E,y);return n.add(n.add(P,n.mul(y,w)),v)}function a(y,w){const v=n.sqr(w),E=i(y);return n.eql(v,E)}if(!a(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const c=n.mul(n.pow(t.a,fs),d1),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(y){return Co(y,X,t.n)}function l(y){const{allowedPrivateKeyLengths:w,nByteLength:v,wrapPrivateKey:E,n:P}=t;if(w&&typeof y!="bigint"){if(Wn(y)&&(y=Rn(y)),typeof y!="string"||!w.includes(y.length))throw new Error("invalid private key");y=y.padStart(v*2,"0")}let I;try{I=typeof y=="bigint"?y:ft(Ee("private key",y,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof y)}return E&&(I=ce(I,P)),Ft("private key",I,X,P),I}function f(y){if(!(y instanceof m))throw new Error("ProjectivePoint expected")}const p=Ai((y,w)=>{const{px:v,py:E,pz:P}=y;if(n.eql(P,n.ONE))return{x:v,y:E};const I=y.is0();w==null&&(w=I?n.ONE:n.inv(P));const T=n.mul(v,w),F=n.mul(E,w),S=n.mul(P,w);if(I)return{x:n.ZERO,y:n.ZERO};if(!n.eql(S,n.ONE))throw new Error("invZ was invalid");return{x:T,y:F}}),h=Ai(y=>{if(y.is0()){if(t.allowInfinityPoint&&!n.is0(y.py))return;throw new Error("bad point: ZERO")}const{x:w,y:v}=y.toAffine();if(!n.isValid(w)||!n.isValid(v))throw new Error("bad point: x or y not FE");if(!a(w,v))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(w,v,E){if(w==null||!n.isValid(w))throw new Error("x required");if(v==null||!n.isValid(v)||n.is0(v))throw new Error("y required");if(E==null||!n.isValid(E))throw new Error("z required");this.px=w,this.py=v,this.pz=E,Object.freeze(this)}static fromAffine(w){const{x:v,y:E}=w||{};if(!w||!n.isValid(v)||!n.isValid(E))throw new Error("invalid affine point");if(w instanceof m)throw new Error("projective point not allowed");const P=I=>n.eql(I,n.ZERO);return P(v)&&P(E)?m.ZERO:new m(v,E,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w){const v=au(n,w.map(E=>E.pz));return w.map((E,P)=>E.toAffine(v[P])).map(m.fromAffine)}static fromHex(w){const v=m.fromAffine(o(Ee("pointHex",w)));return v.assertValidity(),v}static fromPrivateKey(w){return m.BASE.multiply(l(w))}static msm(w,v){return a1(m,r,w,v)}_setWindowSize(w){A.setWindowSize(this,w)}assertValidity(){h(this)}hasEvenY(){const{y:w}=this.toAffine();if(n.isOdd)return!n.isOdd(w);throw new Error("Field doesn't support isOdd")}equals(w){f(w);const{px:v,py:E,pz:P}=this,{px:I,py:T,pz:F}=w,S=n.eql(n.mul(v,F),n.mul(I,P)),R=n.eql(n.mul(E,F),n.mul(T,P));return S&&R}negate(){return new m(this.px,n.neg(this.py),this.pz)}double(){const{a:w,b:v}=t,E=n.mul(v,fs),{px:P,py:I,pz:T}=this;let F=n.ZERO,S=n.ZERO,R=n.ZERO,k=n.mul(P,P),U=n.mul(I,I),C=n.mul(T,T),B=n.mul(P,I);return B=n.add(B,B),R=n.mul(P,T),R=n.add(R,R),F=n.mul(w,R),S=n.mul(E,C),S=n.add(F,S),F=n.sub(U,S),S=n.add(U,S),S=n.mul(F,S),F=n.mul(B,F),R=n.mul(E,R),C=n.mul(w,C),B=n.sub(k,C),B=n.mul(w,B),B=n.add(B,R),R=n.add(k,k),k=n.add(R,k),k=n.add(k,C),k=n.mul(k,B),S=n.add(S,k),C=n.mul(I,T),C=n.add(C,C),k=n.mul(C,B),F=n.sub(F,k),R=n.mul(C,U),R=n.add(R,R),R=n.add(R,R),new m(F,S,R)}add(w){f(w);const{px:v,py:E,pz:P}=this,{px:I,py:T,pz:F}=w;let S=n.ZERO,R=n.ZERO,k=n.ZERO;const U=t.a,C=n.mul(t.b,fs);let B=n.mul(v,I),z=n.mul(E,T),N=n.mul(P,F),O=n.add(v,E),L=n.add(I,T);O=n.mul(O,L),L=n.add(B,z),O=n.sub(O,L),L=n.add(v,P);let D=n.add(I,F);return L=n.mul(L,D),D=n.add(B,N),L=n.sub(L,D),D=n.add(E,P),S=n.add(T,F),D=n.mul(D,S),S=n.add(z,N),D=n.sub(D,S),k=n.mul(U,L),S=n.mul(C,N),k=n.add(S,k),S=n.sub(z,k),k=n.add(z,k),R=n.mul(S,k),z=n.add(B,B),z=n.add(z,B),N=n.mul(U,N),L=n.mul(C,L),z=n.add(z,N),N=n.sub(B,N),N=n.mul(U,N),L=n.add(L,N),B=n.mul(z,L),R=n.add(R,B),B=n.mul(D,L),S=n.mul(O,S),S=n.sub(S,B),B=n.mul(O,z),k=n.mul(D,k),k=n.add(k,B),new m(S,R,k)}subtract(w){return this.add(w.negate())}is0(){return this.equals(m.ZERO)}wNAF(w){return A.wNAFCached(this,w,m.normalizeZ)}multiplyUnsafe(w){const{endo:v,n:E}=t;Ft("scalar",w,qe,E);const P=m.ZERO;if(w===qe)return P;if(this.is0()||w===X)return this;if(!v||A.hasPrecomputes(this))return A.wNAFCachedUnsafe(this,w,m.normalizeZ);let{k1neg:I,k1:T,k2neg:F,k2:S}=v.splitScalar(w),R=P,k=P,U=this;for(;T>qe||S>qe;)T&X&&(R=R.add(U)),S&X&&(k=k.add(U)),U=U.double(),T>>=X,S>>=X;return I&&(R=R.negate()),F&&(k=k.negate()),k=new m(n.mul(k.px,v.beta),k.py,k.pz),R.add(k)}multiply(w){const{endo:v,n:E}=t;Ft("scalar",w,X,E);let P,I;if(v){const{k1neg:T,k1:F,k2neg:S,k2:R}=v.splitScalar(w);let{p:k,f:U}=this.wNAF(F),{p:C,f:B}=this.wNAF(R);k=A.constTimeNegate(T,k),C=A.constTimeNegate(S,C),C=new m(n.mul(C.px,v.beta),C.py,C.pz),P=k.add(C),I=U.add(B)}else{const{p:T,f:F}=this.wNAF(w);P=T,I=F}return m.normalizeZ([P,I])[0]}multiplyAndAddUnsafe(w,v,E){const P=m.BASE,I=(F,S)=>S===qe||S===X||!F.equals(P)?F.multiplyUnsafe(S):F.multiply(S),T=I(this,v).add(I(w,E));return T.is0()?void 0:T}toAffine(w){return p(this,w)}isTorsionFree(){const{h:w,isTorsionFree:v}=t;if(w===X)return!0;if(v)return v(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:w,clearCofactor:v}=t;return w===X?this:v?v(m,this):this.multiplyUnsafe(t.h)}toRawBytes(w=!0){return zn("isCompressed",w),this.assertValidity(),s(m,this,w)}toHex(w=!0){return zn("isCompressed",w),Rn(this.toRawBytes(w))}}m.BASE=new m(t.Gx,t.Gy,n.ONE),m.ZERO=new m(n.ZERO,n.ONE,n.ZERO);const{endo:x,nBitLength:g}=t,A=i1(m,x?Math.ceil(g/2):g);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:d}}function f1(e){const t=hu(e);return Tr(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function h1(e){const t=f1(e),{Fp:n,n:r,nByteLength:s,nBitLength:o}=t,i=n.BYTES+1,a=2*n.BYTES+1;function c(C){return ce(C,r)}function u(C){return qs(C,r)}const{ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:f,isWithinCurveOrder:p}=l1({...t,toBytes(C,B,z){const N=B.toAffine(),O=n.toBytes(N.x),L=lr;return zn("isCompressed",z),z?L(Uint8Array.from([B.hasEvenY()?2:3]),O):L(Uint8Array.from([4]),O,n.toBytes(N.y))},fromBytes(C){const B=C.length,z=C[0],N=C.subarray(1);if(B===i&&(z===2||z===3)){const O=ft(N);if(!Co(O,X,n.ORDER))throw new Error("Point is not on curve");const L=f(O);let D;try{D=n.sqrt(L)}catch(H){const W=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+W)}const q=(D&X)===X;return(z&1)===1!==q&&(D=n.neg(D)),{x:O,y:D}}else if(B===a&&z===4){const O=n.fromBytes(N.subarray(0,n.BYTES)),L=n.fromBytes(N.subarray(n.BYTES,2*n.BYTES));return{x:O,y:L}}else{const O=i,L=a;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+L+", got "+B)}}});function h(C){const B=r>>X;return C>B}function m(C){return h(C)?c(-C):C}const x=(C,B,z)=>ft(C.slice(B,z));class g{constructor(B,z,N){Ft("r",B,X,r),Ft("s",z,X,r),this.r=B,this.s=z,N!=null&&(this.recovery=N),Object.freeze(this)}static fromCompact(B){const z=s;return B=Ee("compactSignature",B,z*2),new g(x(B,0,z),x(B,z,2*z))}static fromDER(B){const{r:z,s:N}=Ge.toSig(Ee("DER",B));return new g(z,N)}assertValidity(){}addRecoveryBit(B){return new g(this.r,this.s,B)}recoverPublicKey(B){const{r:z,s:N,recovery:O}=this,L=P(Ee("msgHash",B));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const D=O===2||O===3?z+t.n:z;if(D>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const q=(O&1)===0?"02":"03",V=d.fromHex(q+ls(D,n.BYTES)),H=u(D),W=c(-L*H),me=c(N*H),ae=d.BASE.multiplyAndAddUnsafe(V,W,me);if(!ae)throw new Error("point at infinify");return ae.assertValidity(),ae}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return dr(this.toDERHex())}toDERHex(){return Ge.hexFromSig(this)}toCompactRawBytes(){return dr(this.toCompactHex())}toCompactHex(){const B=s;return ls(this.r,B)+ls(this.s,B)}}const A={isValidPrivateKey(C){try{return l(C),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const C=du(t.n);return r1(t.randomBytes(C),t.n)},precompute(C=8,B=d.BASE){return B._setWindowSize(C),B.multiply(BigInt(3)),B}};function y(C,B=!0){return d.fromPrivateKey(C).toRawBytes(B)}function w(C){if(typeof C=="bigint")return!1;if(C instanceof d)return!0;const z=Ee("key",C).length,N=n.BYTES,O=N+1,L=2*N+1;if(!(t.allowedPrivateKeyLengths||s===O))return z===O||z===L}function v(C,B,z=!0){if(w(C)===!0)throw new Error("first arg must be private key");if(w(B)===!1)throw new Error("second arg must be public key");return d.fromHex(B).multiply(l(C)).toRawBytes(z)}const E=t.bits2int||function(C){if(C.length>8192)throw new Error("input is too large");const B=ft(C),z=C.length*8-o;return z>0?B>>BigInt(z):B},P=t.bits2int_modN||function(C){return c(E(C))},I=Br(o);function T(C){return Ft("num < 2^"+o,C,qe,I),Zn(C,s)}function F(C,B,z=S){if(["recovered","canonical"].some(je=>je in z))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:O}=t;let{lowS:L,prehash:D,extraEntropy:q}=z;L==null&&(L=!0),C=Ee("msgHash",C),_i(z),D&&(C=Ee("prehashed msgHash",N(C)));const V=P(C),H=l(B),W=[T(H),T(V)];if(q!=null&&q!==!1){const je=q===!0?O(n.BYTES):q;W.push(Ee("extraEntropy",je))}const me=lr(...W),ae=V;function en(je){const ee=E(je);if(!p(ee))return;const at=u(ee),tn=d.BASE.multiply(ee).toAffine(),ct=c(tn.x);if(ct===qe)return;const nn=c(at*c(ae+ct*H));if(nn===qe)return;let rn=(tn.x===ct?0:2)|Number(tn.y&X),$t=nn;return L&&h(nn)&&($t=m(nn),rn^=1),new g(ct,$t,rn)}return{seed:me,k2sig:en}}const S={lowS:t.lowS,prehash:!1},R={lowS:t.lowS,prehash:!1};function k(C,B,z=S){const{seed:N,k2sig:O}=F(C,B,z),L=t;return df(L.hash.outputLen,L.nByteLength,L.hmac)(N,O)}d.BASE._setWindowSize(8);function U(C,B,z,N=R){var rn;const O=C;B=Ee("msgHash",B),z=Ee("publicKey",z);const{lowS:L,prehash:D,format:q}=N;if(_i(N),"strict"in N)throw new Error("options.strict was renamed to lowS");if(q!==void 0&&q!=="compact"&&q!=="der")throw new Error("format must be compact or der");const V=typeof O=="string"||Wn(O),H=!V&&!q&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!V&&!H)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let W,me;try{if(H&&(W=new g(O.r,O.s)),V){try{q!=="compact"&&(W=g.fromDER(O))}catch($t){if(!($t instanceof Ge.Err))throw $t}!W&&q!=="der"&&(W=g.fromCompact(O))}me=d.fromHex(z)}catch{return!1}if(!W||L&&W.hasHighS())return!1;D&&(B=t.hash(B));const{r:ae,s:en}=W,je=P(B),ee=u(en),at=c(je*ee),tn=c(ae*ee),ct=(rn=d.BASE.multiplyAndAddUnsafe(me,at,tn))==null?void 0:rn.toAffine();return ct?c(ct.x)===ae:!1}return{CURVE:t,getPublicKey:y,getSharedSecret:v,sign:k,verify:U,ProjectivePoint:d,Signature:g,utils:A}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function p1(e){return{hash:e,hmac:(t,...n)=>Yc(e,t,Cd(...n)),randomBytes:$d}}function b1(e,t){const n=r=>h1({...e,...p1(r)});return{...n(t),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const pu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Di=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),m1=BigInt(0),y1=BigInt(1),Vs=BigInt(2),Gi=(e,t)=>(e+t/Vs)/t;function g1(e){const t=pu,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,d=u*u*e%t,l=ve(d,n,t)*d%t,f=ve(l,n,t)*d%t,p=ve(f,Vs,t)*u%t,h=ve(p,s,t)*p%t,m=ve(h,o,t)*h%t,x=ve(m,a,t)*m%t,g=ve(x,c,t)*x%t,A=ve(g,a,t)*m%t,y=ve(A,n,t)*d%t,w=ve(y,i,t)*h%t,v=ve(w,r,t)*u%t,E=ve(v,Vs,t);if(!Ws.eql(Ws.sqr(E),e))throw new Error("Cannot find square root");return E}const Ws=Do(pu,void 0,void 0,{sqrt:g1}),bu=b1({a:m1,b:BigInt(7),Fp:Ws,n:Di,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Di,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-y1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,i=BigInt("0x100000000000000000000000000000000"),a=Gi(o*e,t),c=Gi(-r*e,t);let u=ce(e-a*n-c*s,t),d=ce(-a*r-c*o,t);const l=u>i,f=d>i;if(l&&(u=t-u),f&&(d=t-d),u>i||d>i)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:u,k2neg:f,k2:d}}}},Wa),w1=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:bu},Symbol.toStringTag,{value:"Module"}));function mu(e,t={}){const{recovered:n}=t;if(typeof e.r>"u")throw new hs({signature:e});if(typeof e.s>"u")throw new hs({signature:e});if(n&&typeof e.yParity>"u")throw new hs({signature:e});if(e.r<0n||e.r>Ri)throw new C1({value:e.r});if(e.s<0n||e.s>Ri)throw new $1({value:e.s});if(typeof e.yParity=="number"&&e.yParity!==0&&e.yParity!==1)throw new qo({value:e.yParity})}function x1(e){return yu(Be(e))}function yu(e){if(e.length!==130&&e.length!==132)throw new I1({signature:e});const t=BigInt(Re(e,0,32)),n=BigInt(Re(e,32,64)),r=(()=>{const s=+`0x${e.slice(130)}`;if(!Number.isNaN(s))try{return Go(s)}catch{throw new qo({value:s})}})();return typeof r>"u"?{r:t,s:n}:{r:t,s:n,yParity:r}}function v1(e){if(!(typeof e.r>"u")&&!(typeof e.s>"u"))return E1(e)}function E1(e){const t=typeof e=="string"?yu(e):e instanceof Uint8Array?x1(e):typeof e.r=="string"?A1(e):e.v?P1(e):{r:e.r,s:e.s,...typeof e.yParity<"u"?{yParity:e.yParity}:{}};return mu(t),t}function P1(e){return{r:e.r,s:e.s,yParity:Go(e.v)}}function A1(e){const t=(()=>{const n=e.v?Number(e.v):void 0;let r=e.yParity?Number(e.yParity):void 0;if(typeof n=="number"&&typeof r!="number"&&(r=Go(n)),typeof r!="number")throw new qo({value:e.yParity});return r})();return{r:BigInt(e.r),s:BigInt(e.s),yParity:t}}function Go(e){if(e===0||e===27)return 0;if(e===1||e===28)return 1;if(e>=35)return e%2===0?1:0;throw new S1({value:e})}class I1 extends _{constructor({signature:t}){super(`Value \`${t}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${xe(Rf(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class hs extends _{constructor({signature:t}){super(`Signature \`${uc(t)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class C1 extends _{constructor({value:t}){super(`Value \`${t}\` 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 $1 extends _{constructor({value:t}){super(`Value \`${t}\` 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 qo extends _{constructor({value:t}){super(`Value \`${t}\` 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 S1 extends _{constructor({value:t}){super(`Value \`${t}\` 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 B1(e,t={}){return typeof e.chainId=="string"?T1(e):{...e,...t.signature}}function T1(e){const{address:t,chainId:n,nonce:r}=e,s=v1(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...s}}const N1="0x8010801080108010801080108010801080108010801080108010801080108010",k1=eu("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function gu(e){if(typeof e=="string"){if(Re(e,-32)!==N1)throw new R1(e)}else mu(e.authorization)}function j1(e){gu(e);const t=pc(Re(e,-64,-32)),n=Re(e,-t-64,-64),r=Re(e,0,-t-64),[s,o,i]=Hp(k1,n);return{authorization:B1({address:s.delegation,chainId:Number(s.chainId),nonce:s.nonce,yParity:s.yParity,r:s.r,s:s.s}),signature:r,...i&&i!=="0x"?{data:i,to:o}:{}}}function z1(e){try{return gu(e),!0}catch{return!1}}let R1=class extends _{constructor(t){super(`Value \`${t}\` is an invalid ERC-8010 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc8010.InvalidWrappedSignatureError"})}};class F1 extends ${constructor({value:t}){super(`Number \`${t}\` is not a valid decimal number.`,{name:"InvalidDecimalNumberError"})}}function O1(e,t){if(!/^(-?)([0-9]*)\.?([0-9]*)$/.test(e))throw new F1({value:e});let[n,r="0"]=e.split(".");const s=n.startsWith("-");if(s&&(n=n.slice(1)),r=r.replace(/(0+)$/,""),t===0)Math.round(+`.${r}`)===1&&(n=`${BigInt(n)+1n}`),r="";else if(r.length>t){const[o,i,a]=[r.slice(0,t-1),r.slice(t-1,t),r.slice(t)],c=Math.round(+`${i}.${a}`);c>9?r=`${BigInt(o)+BigInt(1)}0`.padStart(o.length+1,"0"):r=`${o}${c}`,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}`)}function wu(e,t="wei"){return O1(e,ja[t])}function M1(e){return e.map(t=>({...t,value:BigInt(t.value)}))}function L1(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?Pe(e.nonce):void 0,storageProof:e.storageProof?M1(e.storageProof):void 0}}async function U1(e,{address:t,blockHash:n,blockNumber:r,blockTag:s="latest",requireCanonical:o,storageKeys:i}){const a=Ct({blockHash:n,blockNumber:r,blockTag:s,requireCanonical:o}),c=await e.request({method:"eth_getProof",params:[t,i,a]});return L1(c)}async function _1(e,{address:t,blockHash:n,blockNumber:r,blockTag:s="latest",requireCanonical:o,slot:i}){const a=Ct({blockHash:n,blockNumber:r,blockTag:s,requireCanonical:o});return await e.request({method:"eth_getStorageAt",params:[t,i,a]})}async function Ho(e,{blockHash:t,blockNumber:n,blockTag:r,hash:s,index:o,sender:i,nonce:a}){var f,p,h;const c=r||"latest",u=n!==void 0?j(n):void 0;let d=null;if(s?d=await e.request({method:"eth_getTransactionByHash",params:[s]},{dedupe:!0}):t?d=await e.request({method:"eth_getTransactionByBlockHashAndIndex",params:[t,j(o)]},{dedupe:!0}):typeof o=="number"?d=await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[u||c,j(o)]},{dedupe:!!u}):i&&typeof a=="number"&&(d=await e.request({method:"eth_getTransactionBySenderAndNonce",params:[i,j(a)]},{dedupe:!0})),!d)throw new Ra({blockHash:t,blockNumber:n,blockTag:c,hash:s,index:o});return(((h=(p=(f=e.chain)==null?void 0:f.formatters)==null?void 0:p.transaction)==null?void 0:h.format)||Hn)(d,"getTransaction")}async function D1(e,{hash:t,transactionReceipt:n}){const[r,s]=await Promise.all([M(e,Jn,"getBlockNumber")({}),t?M(e,Ho,"getTransaction")({hash:t}):void 0]),o=(n==null?void 0:n.blockNumber)||(s==null?void 0:s.blockNumber);return o?r-o+1n:0n}async function ir(e,{hash:t}){var s,o,i;const n=await e.request({method:"eth_getTransactionReceipt",params:[t]},{dedupe:!0});if(!n)throw new Fa({hash:t});return(((i=(o=(s=e.chain)==null?void 0:s.formatters)==null?void 0:o.transactionReceipt)==null?void 0:i.format)||Or)(n,"getTransactionReceipt")}async function G1(e,t){var w;const{account:n,authorizationList:r,allowFailure:s=!0,blockHash:o,blockNumber:i,blockOverrides:a,blockTag:c,requireCanonical:u,stateOverride:d}=t,l=t.contracts,{batchSize:f=t.batchSize??1024,deployless:p=t.deployless??!1}=typeof((w=e.batch)==null?void 0:w.multicall)=="object"?e.batch.multicall:{},h=(()=>{if(t.multicallAddress)return t.multicallAddress;if(p)return null;if(e.chain)return Jt({blockNumber:i,chain:e.chain,contract:"multicall3"});throw new Error("client chain not configured. multicallAddress is required.")})(),m=[[]];let x=0,g=0;for(let v=0;v<l.length;v++){const{abi:E,address:P,args:I,functionName:T}=l[v];try{const F=he({abi:E,args:I,functionName:T});g+=(F.length-2)/2,f>0&&g>f&&m[x].length>0&&(x++,g=(F.length-2)/2,m[x]=[]),m[x]=[...m[x],{allowFailure:!0,callData:F,target:P}]}catch(F){const S=yt(F,{abi:E,address:P,args:I,docsPath:"/docs/contract/multicall",functionName:T,sender:n});if(!s)throw S;m[x]=[...m[x],{allowFailure:!0,callData:"0x",target:P}]}}const A=await Promise.allSettled(m.map(v=>M(e,Te,"readContract")({...h===null?{code:So}:{address:h},abi:Ht,account:n,args:[v],authorizationList:r,blockHash:o,blockNumber:i,blockOverrides:a,blockTag:c,functionName:"aggregate3",requireCanonical:u,stateOverride:d}))),y=[];for(let v=0;v<A.length;v++){const E=A[v];if(E.status==="rejected"){if(!s)throw E.reason;for(let I=0;I<m[v].length;I++)y.push({status:"failure",error:E.reason,result:void 0});continue}const P=E.value;for(let I=0;I<P.length;I++){const{returnData:T,success:F}=P[I],{callData:S}=m[v][I],{abi:R,address:k,functionName:U,args:C}=l[y.length];try{if(S==="0x")throw new Mn;if(!F)throw new Pr({data:T});const B=ot({abi:R,args:C,data:T,functionName:U});y.push(s?{result:B,status:"success"}:B)}catch(B){const z=yt(B,{abi:R,address:k,args:C,docsPath:"/docs/contract/multicall",functionName:U});if(!s)throw z;y.push({error:z,result:void 0,status:"failure"})}}}if(y.length!==l.length)throw new $("multicall results mismatch");return y}async function Zs(e,t){const{blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",blocks:s,returnFullTransactions:o,traceTransfers:i,validation:a}=t;try{const c=[];for(const f of s){const p=f.blockOverrides?yc(f.blockOverrides):void 0,h=f.calls.map(x=>{const g=x,A=g.account?K(g.account):void 0,y=g.abi?he(g):g.data,w={...g,account:A,data:g.dataSuffix?ne([y||"0x",g.dataSuffix]):y,from:g.from??(A==null?void 0:A.address)};return Ye(w),st(w)}),m=f.stateOverrides?lo(f.stateOverrides):void 0;c.push({blockOverrides:p,calls:h,stateOverrides:m})}const d=(typeof n=="bigint"?j(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:c,returnFullTransactions:o,traceTransfers:i,validation:a},d]})).map((f,p)=>({...po(f),calls:f.calls.map((h,m)=>{var F,S;const{abi:x,args:g,functionName:A,to:y}=s[p].calls[m],w=((F=h.error)==null?void 0:F.data)??h.returnData,v=BigInt(h.gasUsed),E=(S=h.logs)==null?void 0:S.map(R=>Le(R)),P=h.status==="0x1"?"success":"failure",I=x&&P==="success"&&w!=="0x"?ot({abi:x,data:w,functionName:A}):null,T=(()=>{if(P==="success")return;let R;if(w==="0x"?R=new Mn:w&&(R=new Pr({data:w})),!!R)return yt(R,{abi:x??[],address:y??"0x",args:g,functionName:A??"<unknown>"})})();return{data:w,gasUsed:v,logs:E,status:P,...P==="success"?{result:I}:{error:T}}})}))}catch(c){const u=c,d=Ir(u,{});throw d instanceof qn?u:d}}function Ks(e){let t=!0,n="",r=0,s="",o=!1;for(let i=0;i<e.length;i++){const a=e[i];if(["(",")",","].includes(a)&&(t=!0),a==="("&&r++,a===")"&&r--,!!t){if(r===0){if(a===" "&&["event","function","error",""].includes(s))s="";else if(s+=a,a===")"){o=!0;break}continue}if(a===" "){e[i-1]!==","&&n!==","&&n!==",("&&(n="",t=!1);continue}s+=a,n+=a}}if(!o)throw new _("Unable to normalize signature.");return s}function Ys(e,t){const n=typeof e,r=t.type;switch(r){case"address":return _s(e,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in t?Object.values(t.components).every((s,o)=>Ys(Object.values(e)[o],s)):/^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)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||e instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(e)&&e.every(s=>Ys(s,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function xu(e,t,n){for(const r in e){const s=e[r],o=t[r];if(s.type==="tuple"&&o.type==="tuple"&&"components"in s&&"components"in o)return xu(s.components,o.components,n[r]);const i=[s.type,o.type];if(i.includes("address")&&i.includes("bytes20")?!0:i.includes("address")&&i.includes("string")?_s(n[r],{strict:!1}):i.includes("address")&&i.includes("bytes")?_s(n[r],{strict:!1}):!1)return i}}function vu(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||typeof e=="string"?Qo(e):e;return{...r,...n?{hash:jt(r)}:{}}}function _r(e,t,n){const{args:r=[],prepare:s=!0}=n??{},o=Ff(t,{strict:!1}),i=e.filter(u=>o?u.type==="function"||u.type==="error"?Eu(u)===Re(t,0,4):u.type==="event"?jt(u)===t:!1:"name"in u&&u.name===t);if(i.length===0)throw new pr({name:t});if(i.length===1)return{...i[0],...s?{hash:jt(i[0])}:{}};let a;for(const u of i){if(!("inputs"in u))continue;if(!r||r.length===0){if(!u.inputs||u.inputs.length===0)return{...u,...s?{hash:jt(u)}:{}};continue}if(!u.inputs||u.inputs.length===0||u.inputs.length!==r.length)continue;if(r.every((l,f)=>{const p="inputs"in u&&u.inputs[f];return p?Ys(l,p):!1})){if(a&&"inputs"in a&&a.inputs){const l=xu(u.inputs,a.inputs,r);if(l)throw new H1({abiItem:u,type:l[0]},{abiItem:a,type:l[1]})}a=u}}const c=(()=>{if(a)return a;const[u,...d]=i;return{...u,overloads:d}})();if(!c)throw new pr({name:t});return{...c,...s?{hash:jt(c)}:{}}}function Eu(...e){const t=(()=>{if(Array.isArray(e[0])){const[n,r]=e;return _r(n,r)}return e[0]})();return Re(jt(t),0,4)}function q1(...e){const t=(()=>{if(Array.isArray(e[0])){const[r,s]=e;return _r(r,s)}return e[0]})(),n=typeof t=="string"?t:ar(t);return Ks(n)}function jt(...e){const t=(()=>{if(Array.isArray(e[0])){const[n,r]=e;return _r(n,r)}return e[0]})();return typeof t!="string"&&"hash"in t&&t.hash?t.hash:Jc($o(q1(t)))}class H1 extends _{constructor(t,n){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${t.type}\` in \`${Ks(ar(t.abiItem))}\`, and`,`\`${n.type}\` in \`${Ks(ar(n.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 pr extends _{constructor({name:t,data:n,type:r="item"}){const s=t?` with name "${t}"`:n?` with data "${n}"`:"";super(`ABI ${r}${s} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}function V1(...e){var o;const[t,n]=(()=>{if(Array.isArray(e[0])){const[i,a]=e;return[Z1(i),a]}return e})(),{bytecode:r,args:s}=n;return Se(r,(o=t.inputs)!=null&&o.length&&(s!=null&&s.length)?Uo(t.inputs,s):"0x")}function W1(e){return vu(e)}function Z1(e){const t=e.find(n=>n.type==="constructor");if(!t)throw new pr({name:"constructor"});return t}function K1(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[u,d,l]=e;return[qi(u,d,{args:l}),l]}const[a,c]=e;return[a,c]})(),{overloads:r}=t,s=r?qi([t,...r],t.name,{args:n}):t,o=Y1(s),i=n.length>0?Uo(s.inputs,n):void 0;return i?Se(o,i):o}function Bt(e,t={}){return vu(e,t)}function qi(e,t,n){const r=_r(e,t,n);if(r.type!=="function")throw new pr({name:t,type:"function"});return r}function Y1(e){return Eu(e)}const J1="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",Ae="0x0000000000000000000000000000000000000000",X1="0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033";async function Q1(e,t){const{blockNumber:n,blockTag:r,calls:s,stateOverrides:o,traceAssetChanges:i,traceTransfers:a,validation:c}=t,u=t.account?K(t.account):void 0;if(i&&!u)throw new $("`account` is required when `traceAssetChanges` is true");const d=u?V1(W1("constructor(bytes, bytes)"),{bytecode:Ec,args:[X1,K1(Bt("function getBalance(address)"),[u.address])]}):void 0,l=i?await Promise.all(t.calls.map(async N=>{if(!N.data&&!N.abi)return;const{accessList:O}=await Lc(e,{account:u.address,...N,data:N.abi?he(N):N.data});return O.map(({address:L,storageKeys:D})=>D.length>0?L:null)})).then(N=>N.flat().filter(Boolean)):[],f=await Zs(e,{blockNumber:n,blockTag:r,blocks:[...i?[{calls:[{data:d}],stateOverrides:o},{calls:l.map((N,O)=>({abi:[Bt("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:N,from:Ae,nonce:O})),stateOverrides:[{address:Ae,nonce:0}]}]:[],{calls:[...s,{to:Ae}].map(N=>({...N,from:u==null?void 0:u.address})),stateOverrides:o},...i?[{calls:[{data:d}]},{calls:l.map((N,O)=>({abi:[Bt("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:N,from:Ae,nonce:O})),stateOverrides:[{address:Ae,nonce:0}]},{calls:l.map((N,O)=>({to:N,abi:[Bt("function decimals() returns (uint256)")],functionName:"decimals",from:Ae,nonce:O})),stateOverrides:[{address:Ae,nonce:0}]},{calls:l.map((N,O)=>({to:N,abi:[Bt("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:Ae,nonce:O})),stateOverrides:[{address:Ae,nonce:0}]},{calls:l.map((N,O)=>({to:N,abi:[Bt("function symbol() returns (string)")],functionName:"symbol",from:Ae,nonce:O})),stateOverrides:[{address:Ae,nonce:0}]}]:[]],traceTransfers:a,validation:c}),p=i?f[2]:f[0],[h,m,,x,g,A,y,w]=i?f:[],{calls:v,...E}=p,P=v.slice(0,-1)??[],I=(h==null?void 0:h.calls)??[],T=(m==null?void 0:m.calls)??[],F=[...I,...T].map(N=>N.status==="success"?Q(N.data):null),S=(x==null?void 0:x.calls)??[],R=(g==null?void 0:g.calls)??[],k=[...S,...R].map(N=>N.status==="success"?Q(N.data):null),U=((A==null?void 0:A.calls)??[]).map(N=>N.status==="success"?N.result:null),C=((w==null?void 0:w.calls)??[]).map(N=>N.status==="success"?N.result:null),B=((y==null?void 0:y.calls)??[]).map(N=>N.status==="success"?N.result:null),z=[];for(const[N,O]of k.entries()){const L=F[N];if(typeof O!="bigint"||typeof L!="bigint")continue;const D=U[N-1],q=C[N-1],V=B[N-1],H=N===0?{address:J1,decimals:18,symbol:"ETH"}:{address:l[N-1],decimals:V||D?Number(D??1):void 0,symbol:q??void 0};z.some(W=>W.token.address===H.address)||z.push({token:H,value:{pre:L,post:O,diff:O-L}})}return{assetChanges:z,block:E,results:P}}const Pu="0x6492649264926492649264926492649264926492649264926492649264926492";function eb(e){if(Re(e,-32)!==Pu)throw new rb(e)}function tb(e){const{data:t,signature:n,to:r}=e;return Se(Uo(eu("address, bytes, bytes"),[r,t,n]),Pu)}function nb(e){try{return eb(e),!0}catch{return!1}}class rb extends _{constructor(t){super(`Value \`${t}\` is an invalid ERC-6492 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc6492.InvalidWrappedSignatureError"})}}function sb({r:e,s:t,to:n="hex",v:r,yParity:s}){const o=(()=>{if(s===0||s===1)return s;if(r&&(r===27n||r===28n||r>=35n))return r%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),i=`0x${new bu.Signature(Q(e),Q(t)).toCompactHex()}${o===0?"1b":"1c"}`;return n==="hex"?i:Oe(i)}async function Dr(e,t){var u,d,l,f;const{address:n,chain:r=e.chain,hash:s,erc6492VerifierAddress:o=t.universalSignatureVerifierAddress??((d=(u=r==null?void 0:r.contracts)==null?void 0:u.erc6492Verifier)==null?void 0:d.address),multicallAddress:i=t.multicallAddress??((f=(l=r==null?void 0:r.contracts)==null?void 0:l.multicall3)==null?void 0:f.address),mode:a="auto"}=t;if(r!=null&&r.verifyHash)return await r.verifyHash(e,t);const c=(()=>{const p=t.signature;return Fe(p)?p:typeof p=="object"&&"r"in p&&"s"in p?sb(p):Y(p)})();try{if(a==="eoa")try{if(wt(_t(n),await Is({hash:s,signature:c})))return!0}catch{}return z1(c)?await ob(e,{...t,multicallAddress:i,signature:c}):await ib(e,{...t,verifierAddress:o,signature:c})}catch(p){if(a!=="eoa")try{if(wt(_t(n),await Is({hash:s,signature:c})))return!0}catch{}if(p instanceof Et)return!1;throw p}}async function ob(e,t){var x;const{address:n,blockNumber:r,blockTag:s,hash:o,multicallAddress:i}=t,{authorization:a,data:c,signature:u,to:d}=j1(t.signature);if(await hr(e,{address:n,blockNumber:r,blockTag:s})===ke(["0xef0100",a.address]))return await ab(e,{address:n,blockNumber:r,blockTag:s,hash:o,signature:u});const f={address:a.address,chainId:Number(a.chainId),nonce:Number(a.nonce),r:j(a.r,{size:32}),s:j(a.s,{size:32}),yParity:a.yParity};if(!await rp({address:n,authorization:f}))throw new Et;const h=await M(e,Te,"readContract")({...i?{address:i}:{code:So},authorizationList:[f],abi:Ht,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:d??n,callData:c}]:[],{allowFailure:!0,target:n,callData:he({abi:vc,functionName:"isValidSignature",args:[o,u]})}]]}),m=(x=h[h.length-1])==null?void 0:x.returnData;if(m!=null&&m.startsWith("0x1626ba7e"))return!0;throw new Et}async function ib(e,t){const{address:n,factory:r,factoryData:s,hash:o,signature:i,verifierAddress:a,...c}=t,u=await(async()=>!r&&!s||nb(i)?i:tb({data:s,signature:i,to:r}))(),d=a?{to:a,data:he({abi:Bi,functionName:"isValidSig",args:[n,o,u]}),...c}:{data:jr({abi:Bi,args:[n,o,u],bytecode:Gf}),...c},{data:l}=await M(e,Yn,"call")(d).catch(f=>{throw f instanceof Ma?new Et:f});if(ad(l??"0x0"))return!0;throw new Et}async function ab(e,t){const{address:n,blockNumber:r,blockTag:s,hash:o,signature:i}=t;if((await M(e,Te,"readContract")({address:n,abi:vc,args:[o,i],blockNumber:r,blockTag:s,functionName:"isValidSignature"}).catch(c=>{throw c instanceof La?new Et:c})).startsWith("0x1626ba7e"))return!0;throw new Et}class Et extends Error{}async function cb(e,{address:t,message:n,factory:r,factoryData:s,signature:o,...i}){const a=Dc(n);return M(e,Dr,"verifyHash")({address:t,factory:r,factoryData:s,hash:a,signature:o,...i})}async function ub(e,t){const{address:n,factory:r,factoryData:s,signature:o,message:i,primaryType:a,types:c,domain:u,...d}=t,l=bp({message:i,primaryType:a,types:c,domain:u});return M(e,Dr,"verifyHash")({address:n,factory:r,factoryData:s,hash:l,signature:o,...d})}function Au(e,{emitOnBegin:t=!1,emitMissed:n=!1,onBlockNumber:r,onError:s,poll:o,pollingInterval:i=e.pollingInterval}){const a=typeof o<"u"?o:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc"));let c;return a?(()=>{const l=ie(["watchBlockNumber",e.uid,t,n,i]);return Ze(l,{onBlockNumber:r,onError:s},f=>Xt(async()=>{var p;try{const h=await M(e,Jn,"getBlockNumber")({cacheTime:0});if(c!==void 0){if(h===c)return;if(h-c>1&&n)for(let m=c+1n;m<h;m++)f.onBlockNumber(m,c),c=m}(c===void 0||h>c)&&(f.onBlockNumber(h,c),c=h)}catch(h){(p=f.onError)==null||p.call(f,h)}},{emitOnBegin:t,interval:i}))})():(()=>{const l=ie(["watchBlockNumber",e.uid,t,n]);return Ze(l,{onBlockNumber:r,onError:s},f=>{let p=!0,h=()=>p=!1;return(async()=>{try{const m=(()=>{if(e.transport.type==="fallback"){const g=e.transport.transports.find(A=>A.config.type==="webSocket"||A.config.type==="ipc");return g?g.value:e.transport}return e.transport})(),{unsubscribe:x}=await m.subscribe({params:["newHeads"],onData(g){var y;if(!p)return;const A=Q((y=g.result)==null?void 0:y.number);f.onBlockNumber(A,c),c=A},onError(g){var A;(A=f.onError)==null||A.call(f,g)}});h=x,p||h()}catch(m){s==null||s(m)}})(),()=>h()})})()}async function Iu(e,t){const{checkReplacement:n=!0,confirmations:r=1,hash:s,onReplaced:o,retryCount:i=6,retryDelay:a=({count:v})=>~~(1<<v)*200,timeout:c=18e4}=t,u=ie(["waitForTransactionReceipt",e.uid,s]),d=(()=>{var v;return t.pollingInterval?t.pollingInterval:(v=e.chain)!=null&&v.experimental_preconfirmationTime?e.chain.experimental_preconfirmationTime:e.pollingInterval})();let l,f,p,h=!1,m,x;const{promise:g,resolve:A,reject:y}=Bo(),w=c?setTimeout(()=>{x==null||x(),m==null||m(),y(new El({hash:s}))},c):void 0;return m=Ze(u,{onReplaced:o,resolve:A,reject:y},async v=>{if(p=await M(e,ir,"getTransactionReceipt")({hash:s}).catch(()=>{}),p&&r<=1){clearTimeout(w),v.resolve(p),m==null||m();return}x=M(e,Au,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:d,async onBlockNumber(E){const P=T=>{clearTimeout(w),x==null||x(),T(),m==null||m()};let I=E;if(!h)try{if(p){if(r>1&&(!p.blockNumber||I-p.blockNumber+1n<r))return;P(()=>v.resolve(p));return}if(n&&!l&&(h=!0,await fr(async()=>{l=await M(e,Ho,"getTransaction")({hash:s}),l.blockNumber&&(I=l.blockNumber)},{delay:a,retryCount:i}),h=!1),p=await M(e,ir,"getTransactionReceipt")({hash:s}),r>1&&(!p.blockNumber||I-p.blockNumber+1n<r))return;P(()=>v.resolve(p))}catch(T){if(T instanceof Ra||T instanceof Fa){if(!l){h=!1;return}try{f=l,h=!0;const F=await fr(()=>M(e,Ce,"getBlock")({blockNumber:I,includeTransactions:!0}),{delay:a,retryCount:i,shouldRetry:({error:k})=>k instanceof ho});h=!1;const S=F.transactions.find(({from:k,nonce:U})=>k===f.from&&U===f.nonce);if(!S||(p=await M(e,ir,"getTransactionReceipt")({hash:S.hash}),r>1&&(!p.blockNumber||I-p.blockNumber+1n<r)))return;let R="replaced";S.to===f.to&&S.value===f.value&&S.input===f.input?R="repriced":S.from===S.to&&S.value===0n&&(R="cancelled"),P(()=>{var k;(k=v.onReplaced)==null||k.call(v,{reason:R,replacedTransaction:f,transaction:S,transactionReceipt:p}),v.resolve(p)})}catch(F){P(()=>v.reject(F))}}else P(()=>v.reject(T))}}})}),g}function db(e,{blockTag:t=e.experimental_blockTag??"latest",emitMissed:n=!1,emitOnBegin:r=!1,onBlock:s,onError:o,includeTransactions:i,poll:a,pollingInterval:c=e.pollingInterval}){const u=typeof a<"u"?a:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")),d=i??!1;let l;return u?(()=>{const h=ie(["watchBlocks",e.uid,t,n,r,d,c]);return Ze(h,{onBlock:s,onError:o},m=>Xt(async()=>{var x;try{const g=await M(e,Ce,"getBlock")({blockTag:t,includeTransactions:d});if(g.number!==null&&(l==null?void 0:l.number)!=null){if(g.number===l.number)return;if(g.number-l.number>1&&n)for(let A=(l==null?void 0:l.number)+1n;A<g.number;A++){const y=await M(e,Ce,"getBlock")({blockNumber:A,includeTransactions:d});m.onBlock(y,l),l=y}}((l==null?void 0:l.number)==null||t==="pending"&&(g==null?void 0:g.number)==null||g.number!==null&&g.number>l.number)&&(m.onBlock(g,l),l=g)}catch(g){(x=m.onError)==null||x.call(m,g)}},{emitOnBegin:r,interval:c}))})():(()=>{let h=!0,m=!0,x=()=>h=!1;return(async()=>{try{r&&M(e,Ce,"getBlock")({blockTag:t,includeTransactions:d}).then(y=>{h&&m&&(s(y,void 0),m=!1)}).catch(o);const g=(()=>{if(e.transport.type==="fallback"){const y=e.transport.transports.find(w=>w.config.type==="webSocket"||w.config.type==="ipc");return y?y.value:e.transport}return e.transport})(),{unsubscribe:A}=await g.subscribe({params:["newHeads"],async onData(y){var v;if(!h)return;const w=await M(e,Ce,"getBlock")({blockNumber:(v=y.result)==null?void 0:v.number,includeTransactions:d}).catch(()=>{});h&&(s(w,l),m=!1,l=w)},onError(y){o==null||o(y)}});x=A,h||x()}catch(g){o==null||o(g)}})(),()=>x()})()}function lb(e,{address:t,args:n,batch:r=!0,event:s,events:o,fromBlock:i,onError:a,onLogs:c,poll:u,pollingInterval:d=e.pollingInterval,strict:l}){const f=typeof u<"u"?u:typeof i=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")),p=l??!1;return f?(()=>{const x=ie(["watchEvent",t,n,r,e.uid,s,d,i]);return Ze(x,{onLogs:c,onError:a},g=>{let A;i!==void 0&&(A=i-1n);let y,w=!1;const v=Xt(async()=>{var E;if(!w){try{y=await M(e,Uc,"createEventFilter")({address:t,args:n,event:s,events:o,strict:p,fromBlock:i})}catch{}w=!0;return}try{let P;if(y)P=await M(e,zr,"getFilterChanges")({filter:y});else{const I=await M(e,Jn,"getBlockNumber")({});A&&A!==I?P=await M(e,Po,"getLogs")({address:t,args:n,event:s,events:o,fromBlock:A+1n,toBlock:I}):P=[],A=I}if(P.length===0)return;if(r)g.onLogs(P);else for(const I of P)g.onLogs([I])}catch(P){y&&P instanceof nt&&(w=!1),(E=g.onError)==null||E.call(g,P)}},{emitOnBegin:!0,interval:d});return async()=>{y&&await M(e,Rr,"uninstallFilter")({filter:y}),v()}})})():(()=>{let x=!0,g=()=>x=!1;return(async()=>{try{const A=(()=>{if(e.transport.type==="fallback"){const E=e.transport.transports.find(P=>P.config.type==="webSocket"||P.config.type==="ipc");return E?E.value:e.transport}return e.transport})(),y=o??(s?[s]:void 0);let w=[];y&&(w=[y.flatMap(P=>_n({abi:[P],eventName:P.name,args:n}))],s&&(w=w[0]));const{unsubscribe:v}=await A.subscribe({params:["logs",{address:t,topics:w}],onData(E){var I;if(!x)return;const P=E.result;try{const{eventName:T,args:F}=ur({abi:y??[],data:P.data,topics:P.topics,strict:p}),S=Le(P,{args:F,eventName:T});c([S])}catch(T){let F,S;if(T instanceof cr||T instanceof eo){if(l)return;F=T.abiItem.name,S=(I=T.abiItem.inputs)==null?void 0:I.some(k=>!("name"in k&&k.name))}const R=Le(P,{args:S?[]:{},eventName:F});c([R])}},onError(E){a==null||a(E)}});g=v,x||g()}catch(A){a==null||a(A)}})(),()=>g()})()}function fb(e,{batch:t=!0,onError:n,onTransactions:r,poll:s,pollingInterval:o=e.pollingInterval}){return(typeof s<"u"?s:e.transport.type!=="webSocket"&&e.transport.type!=="ipc")?(()=>{const u=ie(["watchPendingTransactions",e.uid,t,o]);return Ze(u,{onTransactions:r,onError:n},d=>{let l;const f=Xt(async()=>{var p;try{if(!l)try{l=await M(e,_c,"createPendingTransactionFilter")({});return}catch(m){throw f(),m}const h=await M(e,zr,"getFilterChanges")({filter:l});if(h.length===0)return;if(t)d.onTransactions(h);else for(const m of h)d.onTransactions([m])}catch(h){(p=d.onError)==null||p.call(d,h)}},{emitOnBegin:!0,interval:o});return async()=>{l&&await M(e,Rr,"uninstallFilter")({filter:l}),f()}})})():(()=>{let u=!0,d=()=>u=!1;return(async()=>{try{const{unsubscribe:l}=await e.transport.subscribe({params:["newPendingTransactions"],onData(f){if(!u)return;const p=f.result;r([p])},onError(f){n==null||n(f)}});d=l,u||d()}catch(l){n==null||n(l)}})(),()=>d()})()}function hb(e){var l,f,p;const{scheme:t,statement:n,...r}=((l=e.match(pb))==null?void 0:l.groups)??{},{chainId:s,expirationTime:o,issuedAt:i,notBefore:a,requestId:c,...u}=((f=e.match(bb))==null?void 0:f.groups)??{},d=(p=e.split("Resources:")[1])==null?void 0:p.split(`
45
- - `).slice(1);return{...r,...u,...s?{chainId:Number(s)}:{},...o?{expirationTime:new Date(o)}:{},...i?{issuedAt:new Date(i)}:{},...a?{notBefore:new Date(a)}:{},...c?{requestId:c}:{},...d?{resources:d}:{},...t?{scheme:t}:{},...n?{statement:n}:{}}}const pb=/^(?:(?<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)?/,bb=/(?: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 mb(e){const{address:t,domain:n,message:r,nonce:s,scheme:o,time:i=new Date}=e;if(n&&r.domain!==n||s&&r.nonce!==s||o&&r.scheme!==o||r.expirationTime&&i>=r.expirationTime||r.notBefore&&i<r.notBefore)return!1;try{if(!r.address||!J(r.address,{strict:!1})||t&&!wt(r.address,t))return!1}catch{return!1}return!0}async function yb(e,t){const{address:n,domain:r,message:s,nonce:o,scheme:i,signature:a,time:c=new Date,...u}=t,d=hb(s);if(!d.address||!mb({address:n,domain:r,message:d,nonce:o,scheme:i,time:c}))return!1;const f=Dc(s);return Dr(e,{address:d.address,hash:f,signature:a,...u})}async function Vo(e,{serializedTransaction:t,throwOnReceiptRevert:n,timeout:r}){var a,c,u;const s=await e.request({method:"eth_sendRawTransactionSync",params:r?[t,r]:[t]},{retryCount:0}),i=(((u=(c=(a=e.chain)==null?void 0:a.formatters)==null?void 0:c.transactionReceipt)==null?void 0:u.format)||Or)(s);if(i.status==="reverted"&&n)throw new Ps({receipt:i});return i}function gb(e){return{call:t=>Yn(e,t),createAccessList:t=>Lc(e,t),createBlockFilter:()=>zh(e),createContractEventFilter:t=>Ba(e,t),createEventFilter:t=>Uc(e,t),createPendingTransactionFilter:()=>_c(e),estimateContractGas:t=>sf(e,t),estimateGas:t=>Eo(e,t),getBalance:t=>Rh(e,t),getBlobBaseFee:()=>Fh(e),getBlock:t=>Ce(e,t),getBlockNumber:t=>Jn(e,t),getBlockReceipts:t=>Oh(e,t),getBlockTransactionCount:t=>Mh(e,t),getBytecode:t=>hr(e,t),getChainId:()=>Me(e),getCode:t=>hr(e,t),getContractEvents:t=>tc(e,t),getDelegation:t=>Lh(e,t),getEip712Domain:t=>_h(e,t),getEnsAddress:t=>yh(e,t),getEnsAvatar:t=>Nh(e,t),getEnsName:t=>kh(e,t),getEnsResolver:t=>jh(e,t),getEnsText:t=>Mc(e,t),getFeeHistory:t=>qh(e,t),estimateFeesPerGas:t=>ql(e,t),getFilterChanges:t=>zr(e,t),getFilterLogs:t=>Hh(e,t),getGasPrice:()=>bo(e),getLogs:t=>Po(e,t),getProof:t=>U1(e,t),estimateMaxPriorityFeePerGas:t=>Gl(e,t),fillTransaction:t=>xo(e,t),getStorageAt:t=>_1(e,t),getTransaction:t=>Ho(e,t),getTransactionConfirmations:t=>D1(e,t),getTransactionCount:t=>mo(e,t),getTransactionReceipt:t=>ir(e,t),multicall:t=>G1(e,t),prepareTransactionRequest:t=>Vn(e,t),readContract:t=>Te(e,t),sendRawTransaction:t=>No(e,t),sendRawTransactionSync:t=>Vo(e,t),simulate:t=>Zs(e,t),simulateBlocks:t=>Zs(e,t),simulateCalls:t=>Q1(e,t),simulateContract:t=>eh(e,t),verifyHash:t=>Dr(e,t),verifyMessage:t=>cb(e,t),verifySiweMessage:t=>yb(e,t),verifyTypedData:t=>ub(e,t),uninstallFilter:t=>Rr(e,t),waitForTransactionReceipt:t=>Iu(e,t),watchBlocks:t=>db(e,t),watchBlockNumber:t=>Au(e,t),watchContractEvent:t=>ah(e,t),watchEvent:t=>lb(e,t),watchPendingTransactions:t=>fb(e,t)}}function wb(e){const{key:t="public",name:n="Public Client"}=e;return zc({...e,key:t,name:n,type:"publicClient"}).extend(gb)}async function xb(e,{chain:t}){const{id:n,name:r,nativeCurrency:s,rpcUrls:o,blockExplorers:i}=t;await e.request({method:"wallet_addEthereumChain",params:[{chainId:j(n),chainName:r,nativeCurrency:s,rpcUrls:o.default.http,blockExplorerUrls:i?Object.values(i).map(({url:a})=>a):void 0}]},{dedupe:!0,retryCount:0})}function vb(e,t){const{abi:n,args:r,bytecode:s,...o}=t,i=jr({abi:n,args:r,bytecode:s});return Fr(e,{...o,...o.authorizationList?{to:null}:{},data:i})}async function Eb(e){var n;return((n=e.account)==null?void 0:n.type)==="local"?[e.account.address]:(await e.request({method:"eth_accounts"},{dedupe:!0})).map(r=>Ln(r))}async function Pb(e,t={}){const{account:n=e.account,chainId:r}=t,s=n?K(n):void 0,o=r?[s==null?void 0:s.address,[j(r)]]:[s==null?void 0:s.address],i=await e.request({method:"wallet_getCapabilities",params:o}),a={};for(const[c,u]of Object.entries(i)){a[Number(c)]={};for(let[d,l]of Object.entries(u))d==="addSubAccount"&&(d="unstable_addSubAccount"),a[Number(c)][d]=l}return typeof r=="number"?a[r]:a}async function Ab(e){return await e.request({method:"wallet_getPermissions"},{dedupe:!0})}async function Cu(e,t){var c;const{account:n=e.account,chainId:r,nonce:s}=t;if(!n)throw new it({docsPath:"/docs/eip7702/prepareAuthorization"});const o=K(n),i=(()=>{if(t.executor)return t.executor==="self"?t.executor:K(t.executor)})(),a={address:t.contractAddress??t.address,chainId:r,nonce:s};return typeof a.chainId>"u"&&(a.chainId=((c=e.chain)==null?void 0:c.id)??await M(e,Me,"getChainId")({})),typeof a.nonce>"u"&&(a.nonce=await M(e,mo,"getTransactionCount")({address:o.address,blockTag:"pending"}),(i==="self"||i!=null&&i.address&&wt(i.address,o.address))&&(a.nonce+=1)),a}async function Ib(e){return(await e.request({method:"eth_requestAccounts"},{dedupe:!0,retryCount:0})).map(n=>_t(n))}async function Cb(e,t){return e.request({method:"wallet_requestPermissions",params:[t]},{retryCount:0})}async function $b(e,t){const{chain:n=e.chain}=t,r=t.timeout??Math.max(((n==null?void 0:n.blockTime)??0)*3,5e3),s=await M(e,Tc,"sendCalls")(t);return await M(e,kc,"waitForCallsStatus")({...t,id:s.id,timeout:r})}const ps=new Kt(128);async function $u(e,t){var I,T,F,S,R,k;const{account:n=e.account,assertChainId:r=!0,chain:s=e.chain,accessList:o,authorizationList:i,blobs:a,data:c,dataSuffix:u=typeof e.dataSuffix=="string"?e.dataSuffix:(I=e.dataSuffix)==null?void 0:I.value,gas:d,gasPrice:l,maxFeePerBlobGas:f,maxFeePerGas:p,maxPriorityFeePerGas:h,nonce:m,pollingInterval:x,throwOnReceiptRevert:g,type:A,value:y,...w}=t,v=t.timeout??Math.max(((s==null?void 0:s.blockTime)??0)*3,5e3);if(typeof n>"u")throw new it({docsPath:"/docs/actions/wallet/sendTransactionSync"});const E=n?K(n):null;let P;try{Ye(t);const U=await(async()=>{if(t.to)return t.to;if(t.to!==null&&i&&i.length>0)return await Ar({authorization:i[0]}).catch(()=>{throw new $("`to` is required. Could not infer from `authorizationList`.")})})();if((E==null?void 0:E.type)==="json-rpc"||E===null){let C;s!==null&&(C=await M(e,Me,"getChainId")({}),r&&To({currentChainId:C,chain:s}));const B=(S=(F=(T=e.chain)==null?void 0:T.formatters)==null?void 0:F.transactionRequest)==null?void 0:S.format,N=(B||st)({...Yt(w,{format:B}),accessList:o,account:E,authorizationList:i,blobs:a,chainId:C,data:u?ne([c??"0x",u]):c,gas:d,gasPrice:l,maxFeePerBlobGas:f,maxFeePerGas:p,maxPriorityFeePerGas:h,nonce:m,to:U,type:A,value:y},"sendTransaction"),O=ps.get(e.uid),L=O?"wallet_sendTransaction":"eth_sendTransaction",D=await(async()=>{try{return await e.request({method:L,params:[N]},{retryCount:0})}catch(V){if(O===!1)throw V;const H=V;if(H.name==="InvalidInputRpcError"||H.name==="InvalidParamsRpcError"||H.name==="MethodNotFoundRpcError"||H.name==="MethodNotSupportedRpcError")return await e.request({method:"wallet_sendTransaction",params:[N]},{retryCount:0}).then(W=>(ps.set(e.uid,!0),W)).catch(W=>{const me=W;throw me.name==="MethodNotFoundRpcError"||me.name==="MethodNotSupportedRpcError"?(ps.set(e.uid,!1),H):me});throw H}})(),q=await M(e,Iu,"waitForTransactionReceipt")({checkReplacement:!1,hash:D,pollingInterval:x,timeout:v});if(g&&q.status==="reverted")throw new Ps({receipt:q});return q}if((E==null?void 0:E.type)==="local"){if(E.nonceManager&&typeof m>"u"){const N=w.chainId,O=await(async()=>typeof N=="number"?N:s?s.id:M(e,Me,"getChainId")({}))();P={address:E.address,chainId:O}}const C=await M(e,Vn,"prepareTransactionRequest")({account:E,accessList:o,authorizationList:i,blobs:a,chain:s,data:u?ne([c??"0x",u]):c,gas:d,gasPrice:l,maxFeePerBlobGas:f,maxFeePerGas:p,maxPriorityFeePerGas:h,nonce:m,nonceManager:E.nonceManager,parameters:[...vo,"sidecars"],type:A,value:y,...w,to:U}),B=(R=s==null?void 0:s.serializers)==null?void 0:R.transaction,z=await E.signTransaction(C,{serializer:B});return await M(e,Vo,"sendRawTransactionSync")({serializedTransaction:z,throwOnReceiptRevert:g,timeout:t.timeout})}throw(E==null?void 0:E.type)==="smart"?new ht({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new ht({docsPath:"/docs/actions/wallet/sendTransactionSync",type:E==null?void 0:E.type})}catch(U){throw U instanceof ht?U:(P&&!(U instanceof Ps)&&((k=E==null?void 0:E.nonceManager)==null||k.reset(P)),$r(U,{...t,account:E,chain:t.chain||void 0}))}}async function Sb(e,t){const{id:n}=t;await e.request({method:"wallet_showCallsStatus",params:[n]})}async function Bb(e,t){const{account:n=e.account}=t;if(!n)throw new it({docsPath:"/docs/eip7702/signAuthorization"});const r=K(n);if(!r.signAuthorization)throw new ht({docsPath:"/docs/eip7702/signAuthorization",metaMessages:["The `signAuthorization` Action does not support JSON-RPC Accounts."],type:r.type});const s=await Cu(e,t);return r.signAuthorization(s)}async function Tb(e,{account:t=e.account,message:n}){if(!t)throw new it({docsPath:"/docs/actions/wallet/signMessage"});const r=K(t);if(r.signMessage)return r.signMessage({message:n});const s=typeof n=="string"?ln(n):n.raw instanceof Uint8Array?de(n.raw):n.raw;return e.request({method:"personal_sign",params:[s,r.address]},{retryCount:0})}async function Nb(e,t){var u,d,l,f;const{account:n=e.account,chain:r=e.chain,...s}=t;if(!n)throw new it({docsPath:"/docs/actions/wallet/signTransaction"});const o=K(n);Ye({account:o,...t});const i=await M(e,Me,"getChainId")({});r!==null&&To({currentChainId:i,chain:r});const a=(r==null?void 0:r.formatters)||((u=e.chain)==null?void 0:u.formatters),c=((d=a==null?void 0:a.transactionRequest)==null?void 0:d.format)||st;return o.signTransaction?o.signTransaction({...s,account:o,chainId:i},{serializer:(f=(l=e.chain)==null?void 0:l.serializers)==null?void 0:f.transaction}):await e.request({method:"eth_signTransaction",params:[{...c({...s,account:o},"signTransaction"),chainId:j(i),from:o.address}]},{retryCount:0})}async function kb(e,t){const{account:n=e.account,domain:r,message:s,primaryType:o}=t;if(!n)throw new it({docsPath:"/docs/actions/wallet/signTypedData"});const i=K(n),a={EIP712Domain:qc({domain:r}),...t.types};if(Gc({domain:r,message:s,primaryType:o,types:a}),i.signTypedData)return i.signTypedData({domain:r,message:s,primaryType:o,types:a});const c=hp({domain:r,message:s,primaryType:o,types:a});return e.request({method:"eth_signTypedData_v4",params:[i.address,c]},{retryCount:0})}async function jb(e,{id:t}){await e.request({method:"wallet_switchEthereumChain",params:[{chainId:j(t)}]},{retryCount:0})}async function zb(e,t){return await e.request({method:"wallet_watchAsset",params:t},{retryCount:0})}async function Rb(e,t){return Fn.internal(e,$u,"sendTransactionSync",t)}function Fb(e){return{addChain:t=>xb(e,t),deployContract:t=>vb(e,t),fillTransaction:t=>xo(e,t),getAddresses:()=>Eb(e),getCallsStatus:t=>Nc(e,t),getCapabilities:t=>Pb(e,t),getChainId:()=>Me(e),getPermissions:()=>Ab(e),prepareAuthorization:t=>Cu(e,t),prepareTransactionRequest:t=>Vn(e,t),requestAddresses:()=>Ib(e),requestPermissions:t=>Cb(e,t),sendCalls:t=>Tc(e,t),sendCallsSync:t=>$b(e,t),sendRawTransaction:t=>No(e,t),sendRawTransactionSync:t=>Vo(e,t),sendTransaction:t=>Fr(e,t),sendTransactionSync:t=>$u(e,t),showCallsStatus:t=>Sb(e,t),signAuthorization:t=>Bb(e,t),signMessage:t=>Tb(e,t),signTransaction:t=>Nb(e,t),signTypedData:t=>kb(e,t),switchChain:t=>jb(e,t),waitForCallsStatus:t=>kc(e,t),watchAsset:t=>zb(e,t),writeContract:t=>Fn(e,t),writeContractSync:t=>Rb(e,t)}}function Ob(e){const{key:t="wallet",name:n="Wallet Client",transport:r}=e;return zc({...e,key:t,name:n,transport:r,type:"walletClient"}).extend(Fb)}function Mb({key:e,methods:t,name:n,request:r,retryCount:s=3,retryDelay:o=150,timeout:i,type:a},c){const u=jc();return{config:{key:e,methods:t,name:n,request:r,retryCount:s,retryDelay:o,timeout:i,type:a},request:op(r,{methods:t,retryCount:s,retryDelay:o,uid:u}),value:c}}function Su(e,t={}){const{key:n="custom",methods:r,name:s="Custom Provider",retryDelay:o}=t;return({retryCount:i})=>Mb({key:n,methods:r,name:s,request:e.request.bind(e),retryCount:t.retryCount??i,retryDelay:o,type:"custom"})}const br=new Map,Js=new Set;let Hi=!1;function Lb(){const e=[...br.values()];for(const t of Js)t(e)}function Ub(e){const t=e.detail;br.has(t.info.uuid)||(br.set(t.info.uuid,t),Lb())}function _b(){Hi||typeof window>"u"||(Hi=!0,window.addEventListener("eip6963:announceProvider",Ub),window.dispatchEvent(new Event("eip6963:requestProvider")))}function Db(e){return Js.add(e),e([...br.values()]),()=>{Js.delete(e)}}const Wo="dkg-node-ui:wallet-provider-uuid";function Gb(e){var t;try{(t=globalThis.localStorage)==null||t.setItem(Wo,e)}catch{}}function qb(){var e;try{return((e=globalThis.localStorage)==null?void 0:e.getItem(Wo))??null}catch{return null}}function Vi(){var e;try{(e=globalThis.localStorage)==null||e.removeItem(Wo)}catch{}}const Hb={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},Vb={block:Dl({format(e){var n;return{transactions:(n=e.transactions)==null?void 0:n.map(r=>{if(typeof r=="string")return r;const s=Hn(r);return s.typeHex==="0x7e"&&(s.isSystemTx=r.isSystemTx,s.mint=r.mint?Q(r.mint):void 0,s.sourceHash=r.sourceHash,s.type="deposit"),s}),stateRoot:e.stateRoot}}}),transaction:Ul({format(e){const t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Q(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:uh({format(e){return{l1GasPrice:e.l1GasPrice?Q(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Q(e.l1GasUsed):null,l1Fee:e.l1Fee?Q(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};function Wb(e,t){return Yb(e)?Kb(e):Yh(e,t)}const Zb={transaction:Wb};function Kb(e){Jb(e);const{sourceHash:t,data:n,from:r,gas:s,isSystemTx:o,mint:i,to:a,value:c}=e,u=[t,r,a??"0x",i?de(i):"0x",c?de(c):"0x",s?de(s):"0x",o?"0x1":"0x",n??"0x"];return ke(["0x7e",rt(u)])}function Yb(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function Jb(e){const{from:t,to:n}=e;if(t&&!J(t))throw new oe({address:t});if(n&&!J(n))throw new oe({address:n})}const mr={blockTime:2e3,contracts:Hb,formatters:Vb,serializers:Zb},cn=1,Bu=Qt({...mr,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...mr.contracts,disputeGameFactory:{[cn]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[cn]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[cn]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[cn]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:cn});({...Bu});const un=11155111,Tu=Qt({...mr,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:{...mr.contracts,disputeGameFactory:{[un]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[un]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[un]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[un]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:un});({...Tu});const Xb=Qt({id:100,name:"Gnosis",nativeCurrency:{decimals:18,name:"xDAI",symbol:"XDAI"},blockTime:5e3,rpcUrls:{default:{http:["https://rpc.gnosischain.com"],webSocket:["wss://rpc.gnosischain.com/wss"]}},blockExplorers:{default:{name:"Gnosisscan",url:"https://gnosisscan.io",apiUrl:"https://api.gnosisscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:21022491}}}),Qb=Qt({id:31337,name:"Hardhat",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"]}}}),em={id:2043,name:"NeuroWeb",nativeCurrency:{name:"NEURO",symbol:"NEURO",decimals:18},rpcUrls:{default:{http:["https://astrosat.origintrail.network"]}},blockExplorers:{default:{name:"NeuroWeb",url:"https://neuroweb.subscan.io"}}},tm=[Bu,Xb,Tu,Qb,em];function Zo(e){return tm.find(t=>t.id===e)}function Xs(e){var t;return e==null?"—":((t=Zo(e))==null?void 0:t.name)??`Chain ${e}`}const Nu=G.createContext(null);function Gr(){const e=G.useContext(Nu);if(!e)throw new Error("useWallet must be used within <WalletProvider>");return e}function nm({children:e}){const[t,n]=G.useState(null),[r,s]=G.useState(null),[o,i]=G.useState(null),[a,c]=G.useState([]),u=G.useRef(null),d=G.useCallback(x=>{u.current=x,n((x==null?void 0:x.address)??null),s((x==null?void 0:x.chainId)??null)},[]),l=G.useCallback(()=>{u.current=null,d(null),i(null),Vi()},[d]),f=G.useCallback(x=>{x.on&&(x.on("accountsChanged",(...g)=>{const A=g[0],y=(A==null?void 0:A[0])??null;if(y===null){l();return}const w=u.current;w&&d({...w,address:y})}),x.on("chainChanged",(...g)=>{const A=parseInt(g[0],16),y=u.current;y&&d({...y,chainId:A})}),x.on("disconnect",()=>l()))},[l,d]),p=G.useCallback(async x=>{const g=x.provider,A=await g.request({method:"eth_requestAccounts"}),y=await g.request({method:"eth_chainId"});f(g),i(x.info),d({provider:g,address:A[0]??"",chainId:parseInt(y,16)}),Gb(x.info.uuid)},[f,d]),h=G.useCallback(async x=>{const g=u.current;if(!g)throw new Error("Wallet not connected.");const A=`0x${x.toString(16)}`;try{await g.provider.request({method:"wallet_switchEthereumChain",params:[{chainId:A}]})}catch(y){const w=y==null?void 0:y.code,v=Zo(x);if(w===4902&&v&&v.rpcUrls.default.http[0]&&!v.rpcUrls.default.http[0].includes("127.0.0.1"))await g.provider.request({method:"wallet_addEthereumChain",params:[{chainId:A,chainName:v.name,nativeCurrency:v.nativeCurrency,rpcUrls:[...v.rpcUrls.default.http],blockExplorerUrls:v.blockExplorers?[v.blockExplorers.default.url]:[]}]});else throw w===4902?new Error(`Add this network to your wallet manually (chainId ${x}), then retry.`):y}},[]);G.useEffect(()=>{_b();const x=qb();let g=!1;const A=Db(y=>{if(c(y),!x||g)return;const w=y.find(v=>v.info.uuid===x);w&&(g=!0,(async()=>{try{const v=await w.provider.request({method:"eth_accounts"});if(v.length===0){Vi();return}const E=await w.provider.request({method:"eth_chainId"});f(w.provider),i(w.info),d({provider:w.provider,address:v[0],chainId:parseInt(E,16)})}catch(v){console.warn("[wallet] silent reconnect failed",v)}})())});return()=>A()},[f,d]);const m={address:t,chainId:r,providerInfo:o,availableProviders:a,connected:t!==null,connect:p,disconnect:l,switchChain:h,getConnection:()=>u.current};return b.jsx(Nu.Provider,{value:m,children:e})}function rm(e,t){return wb({chain:e,transport:Su(t)})}function sm(e,t){return Ob({chain:e,transport:Su(t)})}const ku=[{type:"function",name:"createAccount",stateMutability:"nonpayable",inputs:[{name:"committedTRAC",type:"uint96"},{name:"primaryNode",type:"uint72"}],outputs:[{name:"accountId",type:"uint256"}]},{type:"function",name:"topUp",stateMutability:"nonpayable",inputs:[{name:"accountId",type:"uint256"},{name:"amount",type:"uint96"}],outputs:[]},{type:"function",name:"registerAgent",stateMutability:"nonpayable",inputs:[{name:"accountId",type:"uint256"},{name:"agent",type:"address"}],outputs:[]},{type:"function",name:"deregisterAgent",stateMutability:"nonpayable",inputs:[{name:"accountId",type:"uint256"},{name:"agent",type:"address"}],outputs:[]},{type:"function",name:"setPrimaryNode",stateMutability:"nonpayable",inputs:[{name:"accountId",type:"uint256"},{name:"newNode",type:"uint72"}],outputs:[]},{type:"event",name:"AccountCreated",inputs:[{name:"accountId",type:"uint256",indexed:!0},{name:"owner",type:"address",indexed:!0},{name:"committedTRAC",type:"uint96",indexed:!1},{name:"discountBps",type:"uint16",indexed:!1},{name:"createdAtEpoch",type:"uint40",indexed:!1},{name:"expiresAtEpoch",type:"uint40",indexed:!1}]}],om=[{type:"function",name:"clearAgents",stateMutability:"nonpayable",inputs:[{name:"accountId",type:"uint256"}],outputs:[]}];function im(e){return typeof e=="string"?e:e.address}async function Qn(e,t,n,r){r==null||r("signing");const s=await e.walletClient.writeContract({account:e.account,chain:e.chain,address:e.nftAddress,abi:ku,functionName:t,args:n});r==null||r("mining");const o=await e.publicClient.waitForTransactionReceipt({hash:s});if(o.status==="reverted")throw new Error(`Transaction reverted on-chain (${s.slice(0,10)}…). Nothing changed.`);return{hash:s,receipt:o}}async function ju(e,t,n){n==null||n("checking-allowance");const r=im(e.account);if(await e.publicClient.readContract({address:e.tokenAddress,abi:Ti,functionName:"allowance",args:[r,e.nftAddress]})>=t)return;n==null||n("signing-approve");const o=await e.walletClient.writeContract({account:e.account,chain:e.chain,address:e.tokenAddress,abi:Ti,functionName:"approve",args:[e.nftAddress,t]});if(n==null||n("mining-approve"),(await e.publicClient.waitForTransactionReceipt({hash:o})).status==="reverted")throw new Error(`Approve reverted (${o.slice(0,10)}…). No TRAC approved; nothing changed.`)}async function am(e,t,n,r){const{hash:s,receipt:o}=await Qn(e,"registerAgent",[t,n],r);return{hash:s,blockNumber:o.blockNumber}}async function cm(e,t,n,r){const{hash:s,receipt:o}=await Qn(e,"deregisterAgent",[t,n],r);return{hash:s,blockNumber:o.blockNumber}}async function um(e,t,n){n==null||n("signing");const r=await e.walletClient.writeContract({account:e.account,chain:e.chain,address:e.publishingConvictionAddress,abi:om,functionName:"clearAgents",args:[t]});n==null||n("mining");const s=await e.publicClient.waitForTransactionReceipt({hash:r});if(s.status==="reverted")throw new Error(`Transaction reverted on-chain (${r.slice(0,10)}…). Nothing changed.`);return{hash:r,blockNumber:s.blockNumber}}async function dm(e,t,n,r){const{hash:s,receipt:o}=await Qn(e,"setPrimaryNode",[t,n],r);return{hash:s,blockNumber:o.blockNumber}}async function lm(e,t,n,r){await ju(e,n,r);const{hash:s,receipt:o}=await Qn(e,"topUp",[t,n],r);return{hash:s,blockNumber:o.blockNumber}}async function fm(e,t,n,r){await ju(e,t,r);const{hash:s,receipt:o}=await Qn(e,"createAccount",[t,n],r),i=Sr({abi:ku,eventName:"AccountCreated",logs:o.logs}),a=i.length>0?i[0].args.accountId:void 0;if(a===void 0)throw new Error("PCA created but no AccountCreated event found in the receipt.");return{hash:s,blockNumber:o.blockNumber,accountId:a}}function Pt(e,t=6,n=4){return e?e.length<=t+n+1?e:`${e.slice(0,t)}…${e.slice(-n)}`:"—"}const zu=(e,t="Action failed")=>(e==null?void 0:e.message)??t;function qr(){const[e,t]=G.useState(!1),[n,r]=G.useState(null),[s,o]=G.useState(null),[i,a]=G.useState(null),c=G.useCallback(async(u,d="Done")=>{r(null),t(!0),a(null);try{return await u(),o(d),setTimeout(()=>o(null),2500),!0}catch(l){return r(zu(l)),!1}finally{t(!1),a(null)}},[]);return{saving:e,error:n,saved:s,phase:i,setPhase:a,run:c,setError:r}}function Hr({saved:e,error:t,phase:n}){return b.jsxs("span",{"aria-live":"polite",style:{marginLeft:10},children:[n&&b.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:n}),e&&b.jsx("span",{style:{fontSize:11,color:"var(--green)",fontWeight:600},children:e}),t&&b.jsx("span",{style:{fontSize:11,color:"var(--red)"},children:t})]})}function hm(e,t){const n=Zo(e.chainId);return n?{walletClient:sm(n,t.provider),publicClient:rm(n,t.provider),account:t.address,chain:n,nftAddress:e.nftAddress,tokenAddress:e.tokenAddress,publishingConvictionAddress:e.publishingConvictionAddress}:null}function Ru(e){switch(e){case"checking-allowance":return"Checking allowance…";case"signing-approve":return"Approve TRAC in wallet…";case"mining-approve":return"Approving TRAC…";case"signing":return"Confirm in wallet…";case"mining":return"Submitting…"}}function Fu(e){const t=Gr();return G.useCallback(async()=>{if(!e)throw new Error("Contract addresses unavailable — reload.");let n=t.getConnection();if(!n)throw new Error("Connect your wallet first.");if(n.chainId!==e.chainId&&(await t.switchChain(e.chainId),n=t.getConnection(),!n||n.chainId!==e.chainId))throw new Error(`Switch your wallet to ${Xs(e.chainId)} and retry.`);const r=hm(e,n);if(!r)throw new Error(`Unsupported chain ${e.chainId}.`);return r},[e,t])}function pm({contracts:e}){const t=Gr(),[n,r]=G.useState(!1),s=e!=null&&t.chainId!=null&&t.chainId!==e.chainId;if(!t.connected){if(t.availableProviders.length===0)return b.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"No browser wallet detected"});if(t.availableProviders.length===1){const o=t.availableProviders[0];return b.jsxs("button",{className:"dkg-btn-secondary",style:{fontSize:11},onClick:()=>void t.connect(o),children:["Connect ",o.info.name]})}return b.jsxs("div",{style:{position:"relative"},children:[b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11},onClick:()=>r(o=>!o),children:"Connect Wallet ▾"}),n&&b.jsx("div",{style:{position:"absolute",right:0,top:"110%",zIndex:20,background:"var(--bg-elevated)",border:"1px solid var(--border-default)",borderRadius:6,padding:4,minWidth:160},children:t.availableProviders.map(o=>b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11,display:"block",width:"100%",textAlign:"left"},onClick:()=>{r(!1),t.connect(o)},children:o.info.name},o.info.uuid))})]})}return b.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[s&&b.jsxs("button",{className:"dkg-btn-secondary",style:{fontSize:11,color:"var(--amber)"},onClick:()=>e&&void t.switchChain(e.chainId),children:["Switch to ",Xs(e==null?void 0:e.chainId)]}),b.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},title:t.address??"",children:[Xs(t.chainId)," · ",b.jsx("span",{className:"mono",children:Pt(t.address,6,4)})]}),b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11},onClick:()=>t.disconnect(),children:"Disconnect"})]})}function Ie({open:e,onClose:t,title:n,subtitle:r,children:s,footer:o}){const i=Du(e,t);return e?b.jsx("div",{className:"v10-modal-overlay",onClick:i.onBackdropClick,role:"presentation",children:b.jsxs("div",{className:"v10-modal-box",ref:i.dialogRef,role:"dialog","aria-modal":"true","aria-label":n,children:[b.jsx("button",{type:"button",className:"v10-modal-close",onClick:t,"aria-label":"Close",title:"Close (Esc)",children:"×"}),b.jsxs("div",{className:"v10-modal-header",children:[b.jsx("div",{className:"v10-modal-title",children:n}),r&&b.jsx("div",{className:"v10-modal-subtitle",children:r})]}),b.jsx("div",{className:"v10-modal-body",children:s}),b.jsx("div",{className:"v10-modal-footer",children:o})]})}):null}function ye({children:e,tone:t="neutral"}){const n={neutral:{fg:"var(--text-muted)",bg:"var(--bg-elevated)"},green:{fg:"var(--green)",bg:"var(--green-dim)"},amber:{fg:"var(--amber)",bg:"var(--amber-dim)"},blue:{fg:"var(--accent-blue)",bg:"var(--bg-elevated)"}},r=n[t]??n.neutral;return b.jsx("span",{style:{fontSize:10,fontWeight:600,color:r.fg,background:r.bg,borderRadius:4,padding:"1px 6px",marginLeft:6,whiteSpace:"nowrap"},children:e})}const Qe={fontFamily:"var(--font-mono)"};function bm(){const{data:e,loading:t,error:n,refresh:r}=dn(Ou,[],3e4),s=qr(),[o,i]=G.useState(!1),[a,c]=G.useState(""),[u,d]=G.useState(null),l=(e==null?void 0:e.canManage)??!1,f=async()=>{await s.run(async()=>{await Gu(a.trim()),r()},"Wallet authorized")&&(i(!1),c(""))},p=async h=>{await s.run(async()=>{await qu(h),r()},"Wallet removed")&&d(null)};return b.jsxs("section",{className:"card",children:[b.jsxs("div",{className:"card-header",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b.jsx("h2",{className:"card-title",children:"Operational Wallets"}),b.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[b.jsx(Hr,{saved:s.saved,error:s.error}),b.jsx("button",{className:"dkg-btn",disabled:!l||s.saving,title:l?"Authorize a new operational wallet":"Requires an admin key and an on-chain profile",onClick:()=>{s.setError(null),i(!0)},style:{marginLeft:10},children:"Authorize Wallet"})]})]}),b.jsxs("div",{className:"card-body",children:[b.jsxs("p",{style:{fontSize:11,color:"var(--text-muted)",marginTop:0},children:["Wallets the node holds locally and their on-chain authorization status. Add/remove require the node's admin key (in ",b.jsx("span",{className:"mono",children:"~/.dkg/wallets.json"}),") and an on-chain profile."]}),t&&!e&&b.jsx("div",{style:{color:"var(--text-muted)",fontSize:13},children:"Loading…"}),n&&b.jsx("div",{style:{color:"var(--red)",fontSize:12},children:n}),e&&b.jsxs(b.Fragment,{children:[b.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:10},children:["Identity: ",b.jsx("span",{className:"mono",children:e.hasProfile?`#${e.identityId}`:"no on-chain profile"}),!e.adminKeyConfigured&&b.jsx(ye,{tone:"amber",children:"no admin key — read-only"}),e.adminKeyConfigured&&!e.hasProfile&&b.jsx(ye,{tone:"amber",children:"no profile"})]}),e.wallets.length===0&&b.jsx("div",{style:{color:"var(--text-muted)",fontSize:13},children:"No operational wallets configured."}),e.wallets.map(h=>b.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 0",borderBottom:"1px solid var(--border-subtle)"},children:[b.jsxs("div",{children:[b.jsx("span",{className:"mono",style:{fontSize:12},title:h.address,children:Pt(h.address,10,8)}),h.isPrimary&&b.jsx(ye,{tone:"blue",children:"primary"}),h.isAdmin&&b.jsx(ye,{tone:"blue",children:"admin"}),h.registered===!0&&b.jsx(ye,{tone:"green",children:"on-chain ✓"}),h.registered===!1&&b.jsx(ye,{tone:"amber",children:"not registered"}),h.registered===null&&b.jsx(ye,{children:"status unknown"})]}),b.jsx("button",{className:"dkg-btn-secondary",disabled:!l||h.isPrimary||s.saving,title:h.isPrimary?"The primary wallet anchors identity resolution and cannot be removed":"Remove this operational wallet",onClick:()=>{s.setError(null),d(h.address)},style:{fontSize:11},children:"Remove"})]},h.address))]})]}),b.jsxs(Ie,{open:o,onClose:()=>i(!1),title:"Authorize Operational Wallet",subtitle:"Registers the address as an operational key on this node's on-chain identity (admin-signed).",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:()=>i(!1),children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:!a.trim()||s.saving,onClick:f,children:s.saving?"Authorizing…":"Authorize"})]}),children:[s.error&&b.jsx("div",{className:"v10-modal-error",children:s.error}),b.jsxs("div",{className:"v10-form-group",children:[b.jsx("label",{className:"v10-form-label",htmlFor:"opw-addr",children:"Wallet Address"}),b.jsx("input",{id:"opw-addr",className:"v10-form-input",style:Qe,type:"text",value:a,onChange:h=>c(h.target.value),placeholder:"0x…",autoFocus:!0,autoComplete:"off"})]})]}),b.jsxs(Ie,{open:u!==null,onClose:()=>d(null),title:"Remove Operational Wallet?",subtitle:"De-authorizes the key on-chain (admin-signed). This cannot be undone here — re-authorize to restore.",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:()=>d(null),children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:s.saving,onClick:()=>u&&p(u),children:s.saving?"Removing…":"Remove Wallet"})]}),children:[s.error&&b.jsx("div",{className:"v10-modal-error",children:s.error}),b.jsx("div",{className:"mono",style:{fontSize:12},children:u})]})]})}function mm({identity:e}){const t=(e==null?void 0:e.agentAddress)??null,{data:n,loading:r,error:s,refresh:o}=dn(()=>t?_u(t):Promise.resolve(null),[t]),i=qr(),[a,c]=G.useState(!1),[u,d]=G.useState(!1),[l,f]=G.useState(null),[p,h]=G.useState(null),m=async()=>{await i.run(async()=>{if(!t)throw new Error("No agent address");const w=await Ku(t,u);h(w.profilePublished?null:w.profilePublishError??"Profile re-publish failed — peers may still use the old key."),o()},"Key rotated")&&(c(!1),d(!1))},x=async y=>{await i.run(async()=>{if(!t)throw new Error("No agent address");const v=await Yu(t,y);h(v.profilePublished?null:v.profilePublishError??"Profile re-publish failed — peers may still encrypt to the revoked key."),o()},"Key revoked")&&f(null)},g=()=>i.run(async()=>{await Zu(),h(null)},"Profile re-published"),A=((n==null?void 0:n.keys)??[]).filter(y=>y.status==="active").length;return b.jsxs("section",{className:"card",children:[b.jsxs("div",{className:"card-header",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b.jsx("h2",{className:"card-title",children:"Agent Encryption Keys"}),b.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[b.jsx(Hr,{saved:i.saved,error:i.error}),b.jsx("button",{className:"dkg-btn",disabled:!t||i.saving,onClick:()=>{i.setError(null),c(!0)},style:{marginLeft:10},children:"Rotate Key"})]})]}),b.jsxs("div",{className:"card-body",children:[b.jsx("p",{style:{fontSize:11,color:"var(--text-muted)",marginTop:0},children:"Workspace encryption keys for this node's default agent (used for shared/private memory). Rotating mints a fresh key and re-publishes the profile so peers learn it."}),e&&b.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:10},children:["Agent: ",b.jsx("span",{className:"mono",title:e.agentAddress,children:Pt(e.agentAddress,10,8)})]}),p&&b.jsxs("div",{className:"v10-modal-warning",style:{marginBottom:10,display:"flex",justifyContent:"space-between",alignItems:"center",gap:10},children:[b.jsx("span",{children:p}),b.jsx("button",{className:"dkg-btn-secondary",disabled:i.saving,onClick:g,style:{fontSize:11},children:"Re-publish profile"})]}),r&&!n&&b.jsx("div",{style:{color:"var(--text-muted)",fontSize:13},children:"Loading…"}),s&&b.jsx("div",{style:{color:"var(--red)",fontSize:12},children:s}),n&&n.keys.length===0&&b.jsx("div",{style:{color:"var(--text-muted)",fontSize:13},children:"No encryption keys found."}),n==null?void 0:n.keys.map(y=>b.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 0",borderBottom:"1px solid var(--border-subtle)"},children:[b.jsxs("div",{children:[b.jsx("span",{className:"mono",style:{fontSize:11},title:y.encryptionKeyId,children:Pt(y.encryptionKeyId,28,8)}),y.status==="active"?b.jsx(ye,{tone:"green",children:"active"}):b.jsx(ye,{tone:"amber",children:"revoked"}),b.jsx("span",{style:{fontSize:10,color:"var(--text-dim)",marginLeft:8},children:y.encryptionKeyAlgorithm})]}),y.status==="active"&&b.jsx("button",{className:"dkg-btn-secondary",disabled:i.saving||A<=1,title:A<=1?"Cannot revoke the last active key — rotate first":"Revoke this key",onClick:()=>{i.setError(null),f(y)},style:{fontSize:11},children:"Revoke"})]},y.encryptionKeyId))]}),b.jsxs(Ie,{open:a,onClose:()=>c(!1),title:"Rotate Encryption Key",subtitle:"Mints a new workspace key and re-publishes the agent profile.",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:()=>c(!1),children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:i.saving,onClick:m,children:i.saving?"Rotating…":"Rotate Key"})]}),children:[i.error&&b.jsx("div",{className:"v10-modal-error",children:i.error}),b.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[b.jsx("input",{type:"checkbox",checked:u,onChange:y=>d(y.target.checked)}),"Also retire the previous key now (only after propagation has settled, or for compromise)"]})]}),b.jsxs(Ie,{open:l!==null,onClose:()=>f(null),title:"Revoke Encryption Key?",subtitle:"Peers keep encrypting to this key until the profile re-publishes. This cannot be undone.",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:()=>f(null),children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:i.saving,onClick:()=>l&&x(l.encryptionKeyId),children:i.saving?"Revoking…":"Revoke Key"})]}),children:[i.error&&b.jsx("div",{className:"v10-modal-error",children:i.error}),b.jsx("div",{className:"mono",style:{fontSize:11},children:l==null?void 0:l.encryptionKeyId})]})]})}function Wi({pca:e,contracts:t,onChanged:n}){const r=qr(),s=Gr(),[o,i]=G.useState(null),[a,c]=G.useState(""),[u,d]=G.useState(""),[l,f]=G.useState(""),p=()=>{i(null),c(""),d(""),f("")},h=e.expiresAtTimestamp>0&&e.expiresAtTimestamp*1e3<Date.now(),m=e.owned!==!1,x=s.connected&&s.address!=null&&s.address.toLowerCase()===e.owner.toLowerCase(),g=m||x,A=!m&&x,y=g?A?"Signed by your connected wallet":void 0:`Owned by ${Pt(e.owner,8,6)} — connect that wallet to manage it`,w=Fu(t),v=(E,P,I)=>r.run(async()=>{if(A){const T=await w();await P(T,F=>r.setPhase(Ru(F)))}else await E();n()},I);return b.jsxs("div",{style:{border:"1px solid var(--border-default)",borderRadius:6,padding:12,marginBottom:10},children:[b.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[b.jsxs("div",{children:[b.jsxs("span",{style:{fontWeight:600},children:["PCA #",e.accountId]}),e.fundsThisNode&&b.jsx(ye,{tone:"green",children:"funds this node"}),A&&b.jsx(ye,{tone:"blue",children:"wallet-managed"}),!g&&b.jsx(ye,{tone:"amber",children:"owned elsewhere"}),h&&b.jsx(ye,{tone:"amber",children:"expired"})]}),b.jsx(Hr,{saved:r.saved,error:r.error,phase:r.phase})]}),b.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"4px 16px",fontSize:12,marginTop:8},children:[b.jsx("span",{style:{color:"var(--text-muted)"},children:"Committed"}),b.jsxs("span",{className:"mono",title:Yo(e.committedTRACTrac),children:[Ko(e.committedTRACTrac)," TRAC"]}),b.jsx("span",{style:{color:"var(--text-muted)"},children:"Top-up buffer"}),b.jsxs("span",{className:"mono",title:Yo(e.topUpBufferTrac),children:[Ko(e.topUpBufferTrac)," TRAC"]}),b.jsx("span",{style:{color:"var(--text-muted)"},children:"Discount"}),b.jsxs("span",{children:[(e.discountBps/100).toFixed(e.discountBps%100?2:0),"%"]}),b.jsx("span",{style:{color:"var(--text-muted)"},children:"Agents"}),b.jsx("span",{children:e.agentCount}),b.jsx("span",{style:{color:"var(--text-muted)"},children:"Expires (epoch)"}),b.jsx("span",{children:e.expiresAtEpoch}),b.jsx("span",{style:{color:"var(--text-muted)"},children:"Primary node"}),b.jsx("span",{className:"mono",children:e.primaryNode&&e.primaryNode!=="0"?`#${e.primaryNode}`:"none"}),b.jsx("span",{style:{color:"var(--text-muted)"},children:"Owner"}),b.jsx("span",{className:"mono",title:e.owner,children:Pt(e.owner,10,8)})]}),b.jsxs("div",{style:{display:"flex",gap:8,marginTop:10,flexWrap:"wrap"},children:[b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11},disabled:!g||r.saving,title:y,onClick:()=>{r.setError(null),i("funds")},children:"Top up"}),b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11},disabled:!g||r.saving,title:y,onClick:()=>{r.setError(null),i("addAgent")},children:"Add agent"}),b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11},disabled:!g||r.saving,title:y,onClick:()=>{r.setError(null),i("removeAgent")},children:"Remove agent"}),b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11},disabled:!g||r.saving||e.agentCount===0||!A||!(t!=null&&t.clearAgentsSupported),title:e.agentCount===0?"No agents to clear":t!=null&&t.clearAgentsSupported?A?y:"Bulk clear is available for a wallet-owned PCA; for a node-owned PCA remove agents individually (full node support ships with the PublishingConviction upgrade)":"Available once the PublishingConviction 10.0.6 upgrade is deployed on this chain",onClick:()=>{r.setError(null),i("clearAgents")},children:"Clear agents"}),b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11},disabled:!g||r.saving,title:y,onClick:()=>{r.setError(null),i("primaryNode")},children:"Set primary node"}),b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11},onClick:()=>{r.setError(null),i("settle")},children:"Settle"})]}),b.jsxs(Ie,{open:o==="funds",onClose:p,title:`Top up PCA #${e.accountId}`,subtitle:"Adds TRAC to the account's top-up buffer (owner-gated).",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:p,children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:!a.trim()||r.saving,onClick:async()=>{await v(()=>Ju(e.accountId,a.trim()),(E,P)=>lm(E,BigInt(e.accountId),wu(a.trim()),P),"Topped up")&&p()},children:r.saving?r.phase??"Topping up…":"Top up"})]}),children:[r.error&&b.jsx("div",{className:"v10-modal-error",children:r.error}),b.jsxs("div",{className:"v10-form-group",children:[b.jsx("label",{className:"v10-form-label",htmlFor:`funds-${e.accountId}`,children:"TRAC amount"}),b.jsx("input",{id:`funds-${e.accountId}`,className:"v10-form-input",style:Qe,inputMode:"decimal",value:a,onChange:E=>c(E.target.value),placeholder:"50000",autoFocus:!0,autoComplete:"off"})]})]}),b.jsxs(Ie,{open:o==="addAgent",onClose:p,title:`Add agent to PCA #${e.accountId}`,subtitle:"Authorize a wallet to publish against this PCA's funds (owner-gated).",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:p,children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:!u.trim()||r.saving,onClick:async()=>{await v(()=>Xu(e.accountId,u.trim()),(E,P)=>am(E,BigInt(e.accountId),u.trim(),P),"Agent added")&&p()},children:r.saving?r.phase??"Adding…":"Add agent"})]}),children:[r.error&&b.jsx("div",{className:"v10-modal-error",children:r.error}),b.jsxs("div",{className:"v10-form-group",children:[b.jsx("label",{className:"v10-form-label",htmlFor:`addagent-${e.accountId}`,children:"Agent wallet address"}),b.jsx("input",{id:`addagent-${e.accountId}`,className:"v10-form-input",style:Qe,value:u,onChange:E=>d(E.target.value),placeholder:"0x…",autoFocus:!0,autoComplete:"off"})]})]}),b.jsxs(Ie,{open:o==="removeAgent",onClose:p,title:`Remove agent from PCA #${e.accountId}`,subtitle:"De-authorize a publishing agent wallet (owner-gated).",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:p,children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:!u.trim()||r.saving,onClick:async()=>{await v(()=>Qu(e.accountId,u.trim()),(E,P)=>cm(E,BigInt(e.accountId),u.trim(),P),"Agent removed")&&p()},children:r.saving?r.phase??"Removing…":"Remove agent"})]}),children:[r.error&&b.jsx("div",{className:"v10-modal-error",children:r.error}),b.jsxs("div",{className:"v10-form-group",children:[b.jsx("label",{className:"v10-form-label",htmlFor:`rmagent-${e.accountId}`,children:"Agent wallet address"}),b.jsx("input",{id:`rmagent-${e.accountId}`,className:"v10-form-input",style:Qe,value:u,onChange:E=>d(E.target.value),placeholder:"0x…",autoFocus:!0,autoComplete:"off"})]})]}),b.jsxs(Ie,{open:o==="clearAgents",onClose:p,title:`Clear all agents — PCA #${e.accountId}`,subtitle:"Removes EVERY registered publishing agent in one transaction (owner-gated). Agents are PRESERVED across NFT transfer, so use this to drop an allow-list inherited from a previous owner.",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:p,children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:r.saving,onClick:async()=>{await v(()=>{throw new Error("Bulk-clear for a node-owned PCA ships with the PublishingConviction upgrade — remove agents individually meanwhile.")},(E,P)=>um(E,BigInt(e.accountId),P),"Agents cleared")&&p()},children:r.saving?r.phase??"Clearing…":`Clear ${e.agentCount} agent${e.agentCount===1?"":"s"}`})]}),children:[r.error&&b.jsx("div",{className:"v10-modal-error",children:r.error}),b.jsxs("p",{style:{fontSize:13,color:"var(--text-muted)",margin:0},children:["This removes all ",e.agentCount," registered agent",e.agentCount===1?"":"s"," from PCA #",e.accountId,". You can re-add agents afterwards."]})]}),b.jsxs(Ie,{open:o==="primaryNode",onClose:p,title:`Re-designate primary node — PCA #${e.accountId}`,subtitle:"OT-RFC-51: moves future-epoch publishing allocation to a new node. Rate-limited to once per epoch.",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:p,children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:!l.trim()||r.saving,onClick:async()=>{await v(()=>e0(e.accountId,l.trim()),(E,P)=>dm(E,BigInt(e.accountId),BigInt(l.trim()),P),"Primary node set")&&p()},children:r.saving?r.phase??"Setting…":"Set primary node"})]}),children:[r.error&&b.jsx("div",{className:"v10-modal-error",children:r.error}),b.jsxs("div",{className:"v10-form-group",children:[b.jsx("label",{className:"v10-form-label",htmlFor:`node-${e.accountId}`,children:"Node identityId"}),b.jsx("input",{id:`node-${e.accountId}`,className:"v10-form-input",style:Qe,inputMode:"numeric",value:l,onChange:E=>f(E.target.value),placeholder:"42",autoFocus:!0,autoComplete:"off"})]})]}),b.jsxs(Ie,{open:o==="settle",onClose:p,title:`Settle PCA #${e.accountId}?`,subtitle:"Runs the lazy-settlement sweep (permissionless). Safe to run anytime.",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:p,children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:r.saving,onClick:async()=>{await r.run(async()=>{await Hu(e.accountId),n()},"Settled")&&p()},children:r.saving?"Settling…":"Settle"})]}),children:[r.error&&b.jsx("div",{className:"v10-modal-error",children:r.error}),b.jsx("div",{style:{fontSize:13},children:"Sweep elapsed billing windows for this account."})]})]})}function ym({identity:e}){const{data:t,loading:n,error:r,refresh:s}=dn(Mu,[],3e4),{data:o}=dn(Lu,[],0),i=Gr(),a=Fu(o??null),c=qr(),[u,d]=G.useState(!1),[l,f]=G.useState(""),[p,h]=G.useState(""),[m,x]=G.useState(""),[g,A]=G.useState(null),[y,w]=G.useState(null),v=e!=null&&e.nodeIdentityId&&e.nodeIdentityId!=="0"?e.nodeIdentityId:"",E=async()=>{await c.run(async()=>{const T=(p||v).trim();if(i.connected){const F=await a();await fm(F,wu(l.trim()),BigInt(T),S=>c.setPhase(Ru(S)))}else await Wu(l.trim(),T);s()},"PCA created")&&(d(!1),f(""),h(""))},P=async()=>{w(null),A(null);try{const I=await Vu(m.trim());A(I)}catch(I){w(zu(I,"Not found"))}};return b.jsxs("section",{className:"card",children:[b.jsxs("div",{className:"card-header",style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:10,flexWrap:"wrap"},children:[b.jsx("h2",{className:"card-title",children:"Publishing Conviction Accounts"}),b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx(pm,{contracts:o??null}),b.jsx(Hr,{saved:c.saved,error:c.error,phase:c.phase}),b.jsx("button",{className:"dkg-btn",disabled:c.saving,onClick:()=>{c.setError(null),h(v),d(!0)},children:"Create PCA"})]})]}),b.jsxs("div",{className:"card-body",children:[b.jsxs("p",{style:{fontSize:11,color:"var(--text-muted)",marginTop:0},children:["PCAs owned by this node's wallet, with their OT-RFC-51 node association. A PCA's committed TRAC funds a designated node's publishing allocation and discounts its agents' publishes."," ",b.jsx("strong",{children:"Connect a wallet"})," to manage a PCA owned by an external wallet (it signs the owner-gated txs directly)."]}),n&&!t&&b.jsx("div",{style:{color:"var(--text-muted)",fontSize:13},children:"Loading…"}),r&&b.jsx("div",{style:{color:"var(--red)",fontSize:12},children:r}),t&&t.accounts.length===0&&b.jsx("div",{style:{color:"var(--text-muted)",fontSize:13},children:"This node owns no PCAs. Create one, or look one up by id below."}),t==null?void 0:t.accounts.map(I=>b.jsx(Wi,{pca:I,contracts:o??null,onChanged:s},I.accountId)),b.jsxs("div",{style:{marginTop:14,paddingTop:12,borderTop:"1px solid var(--border-subtle)"},children:[b.jsx("div",{className:"settings-field-label",children:"Look up a PCA by account id"}),b.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginTop:6},children:[b.jsx("input",{className:"input",style:{...Qe,maxWidth:180},inputMode:"numeric",value:m,onChange:I=>x(I.target.value),placeholder:"accountId"}),b.jsx("button",{className:"dkg-btn-secondary",style:{fontSize:11},disabled:!m.trim(),onClick:P,children:"Look up"})]}),y&&b.jsx("div",{style:{color:"var(--red)",fontSize:12,marginTop:6},children:y}),g&&b.jsx("div",{style:{marginTop:10},children:b.jsx(Wi,{pca:g,contracts:o??null,onChanged:P})})]})]}),b.jsxs(Ie,{open:u,onClose:()=>d(!1),title:"Create Publishing Conviction Account",subtitle:"Locks committed TRAC to fund a node's publishing allocation. The primary node is required.",footer:b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"v10-modal-btn",onClick:()=>d(!1),children:"Cancel"}),b.jsx("button",{className:"v10-modal-btn primary",disabled:!l.trim()||!(p||v).trim()||c.saving,onClick:E,children:c.saving?c.phase??"Creating…":"Create PCA"})]}),children:[c.error&&b.jsx("div",{className:"v10-modal-error",children:c.error}),b.jsx("div",{className:"v10-modal-tip",style:{marginBottom:10},children:i.connected?b.jsxs(b.Fragment,{children:["Signed by your connected wallet — the new PCA will be owned by ",b.jsx("span",{className:"mono",children:Pt(i.address,6,4)}),". Requires TRAC in that wallet."]}):b.jsx(b.Fragment,{children:"Signed by this node's wallet — the new PCA will be node-owned and managed server-side."})}),b.jsxs("div",{className:"v10-form-group",children:[b.jsx("label",{className:"v10-form-label",htmlFor:"create-tokens",children:"Committed TRAC"}),b.jsx("input",{id:"create-tokens",className:"v10-form-input",style:Qe,inputMode:"decimal",value:l,onChange:I=>f(I.target.value),placeholder:"100000",autoFocus:!0,autoComplete:"off"})]}),b.jsxs("div",{className:"v10-form-group",children:[b.jsx("label",{className:"v10-form-label",htmlFor:"create-node",children:"Primary node identityId"}),b.jsx("input",{id:"create-node",className:"v10-form-input",style:Qe,inputMode:"numeric",value:p,onChange:I=>h(I.target.value),placeholder:v||"node identityId",autoComplete:"off"}),v&&b.jsxs("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:4},children:["Defaults to this node (#",v,")."]})]})]})]})}function gm(){const{data:e}=dn(Uu,[],0);return b.jsx(nm,{children:b.jsxs("div",{className:"page-section",children:[b.jsxs("div",{style:{marginBottom:20},children:[b.jsx("h1",{className:"page-title",style:{marginBottom:0},children:"Admin"}),b.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",marginTop:4},children:"Manage node keys, operational wallets, and Publishing Conviction Accounts. Node-owned actions are signed by the node's wallets; connect a browser wallet to manage PCAs you own externally."})]}),b.jsxs("div",{className:"settings-stack",children:[b.jsx(bm,{}),b.jsx(ym,{identity:e??null}),b.jsx(mm,{identity:e??null})]})]})})}const Fm=Object.freeze(Object.defineProperty({__proto__:null,AdminPage:gm},Symbol.toStringTag,{value:"Module"}));export{Fm as A,$ as B,Ua as H,ne as a,Oa as b,Yn as c,hl as d,At as e,wt as f,bt as g,Fe as h,Er as i,Mr as j,hh as l,ie as s};