@beampay/checkout 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,7 +35,7 @@ ${pk(p)}`),super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessa
35
35
  `),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(mm,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class wm extends ee{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(wm,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class ym extends ee{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(ym,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class bm extends ee{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(bm,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Ip extends ee{constructor({cause:e,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${Mn(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${Mn(r)} gwei`:""}).`].join(`
36
36
  `),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Ip,"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 Sp extends ee{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function vm(t,e){const n=(t.details||"").toLowerCase(),r=t instanceof ee?t.walk(i=>i?.code===da.code):t;return r instanceof ee?new da({cause:t,message:r.details}):da.nodeMessage.test(n)?new da({cause:t,message:t.details}):$p.nodeMessage.test(n)?new $p({cause:t,maxFeePerGas:e?.maxFeePerGas}):hm.nodeMessage.test(n)?new hm({cause:t,maxFeePerGas:e?.maxFeePerGas}):fm.nodeMessage.test(n)?new fm({cause:t,nonce:e?.nonce}):pm.nodeMessage.test(n)?new pm({cause:t,nonce:e?.nonce}):gm.nodeMessage.test(n)?new gm({cause:t,nonce:e?.nonce}):mm.nodeMessage.test(n)?new mm({cause:t}):wm.nodeMessage.test(n)?new wm({cause:t,gas:e?.gas}):ym.nodeMessage.test(n)?new ym({cause:t,gas:e?.gas}):bm.nodeMessage.test(n)?new bm({cause:t}):Ip.nodeMessage.test(n)?new Ip({cause:t,maxFeePerGas:e?.maxFeePerGas,maxPriorityFeePerGas:e?.maxPriorityFeePerGas}):new Sp({cause:t})}function Vk(t,{docsPath:e,...n}){const r=(()=>{const i=vm(t,n);return i instanceof Sp?t:i})();return new bk(r,{docsPath:e,...n})}function Ap(t,{format:e}){if(!e)return{};const n={};function r(s){const o=Object.keys(s);for(const a of o)a in t&&(n[a]=t[a]),s[a]&&typeof s[a]=="object"&&!Array.isArray(s[a])&&r(s[a])}const i=e(t||{});return r(i),n}const Kk={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Pp(t,e){const n={};return typeof t.authorizationList<"u"&&(n.authorizationList=Gk(t.authorizationList)),typeof t.accessList<"u"&&(n.accessList=t.accessList),typeof t.blobVersionedHashes<"u"&&(n.blobVersionedHashes=t.blobVersionedHashes),typeof t.blobs<"u"&&(typeof t.blobs[0]!="string"?n.blobs=t.blobs.map(r=>Un(r)):n.blobs=t.blobs),typeof t.data<"u"&&(n.data=t.data),t.account&&(n.from=t.account.address),typeof t.from<"u"&&(n.from=t.from),typeof t.gas<"u"&&(n.gas=Pe(t.gas)),typeof t.gasPrice<"u"&&(n.gasPrice=Pe(t.gasPrice)),typeof t.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=Pe(t.maxFeePerBlobGas)),typeof t.maxFeePerGas<"u"&&(n.maxFeePerGas=Pe(t.maxFeePerGas)),typeof t.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=Pe(t.maxPriorityFeePerGas)),typeof t.nonce<"u"&&(n.nonce=Pe(t.nonce)),typeof t.to<"u"&&(n.to=t.to),typeof t.type<"u"&&(n.type=Kk[t.type]),typeof t.value<"u"&&(n.value=Pe(t.value)),n}function Gk(t){return t.map(e=>({address:e.address,r:e.r?Pe(BigInt(e.r)):e.r,s:e.s?Pe(BigInt(e.s)):e.s,chainId:Pe(e.chainId),nonce:Pe(e.nonce),...typeof e.yParity<"u"?{yParity:Pe(e.yParity)}:{},...typeof e.v<"u"&&typeof e.yParity>"u"?{v:Pe(e.v)}:{}}))}function m6(){let t=()=>{},e=()=>{};return{promise:new Promise((r,i)=>{t=r,e=i}),resolve:t,reject:e}}const Em=new Map;function w6({fn:t,id:e,shouldSplitBatch:n,wait:r=0,sort:i}){const s=async()=>{const u=c();o();const d=u.map(({args:h})=>h);d.length!==0&&t(d).then(h=>{i&&Array.isArray(h)&&h.sort(i);for(let p=0;p<u.length;p++){const{resolve:w}=u[p];w?.([h[p],h])}}).catch(h=>{for(let p=0;p<u.length;p++){const{reject:w}=u[p];w?.(h)}})},o=()=>Em.delete(e),a=()=>c().map(({args:u})=>u),c=()=>Em.get(e)||[],l=u=>Em.set(e,[...c(),u]);return{flush:o,async schedule(u){const{promise:d,resolve:h,reject:p}=m6();return n?.([...a(),u])&&s(),c().length>0?(l({args:u,resolve:h,reject:p}),d):(l({args:u,resolve:h,reject:p}),setTimeout(s,r),d)}}}function y6(t){if(!(!t||t.length===0))return t.reduce((e,{slot:n,value:r})=>{if(n.length!==66)throw new l3({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new l3({size:r.length,targetSize:66,type:"hex"});return e[n]=r,e},{})}function Zk(t){const{balance:e,nonce:n,state:r,stateDiff:i,code:s}=t,o={};if(s!==void 0&&(o.code=s),e!==void 0&&(o.balance=Pe(e)),n!==void 0&&(o.nonce=Pe(n)),r!==void 0&&(o.state=y6(r)),i!==void 0){if(o.state)throw new fk;o.stateDiff=y6(i)}return o}function b6(t){if(!t)return;const e={};for(const{address:n,...r}of t){if(!Bi(n,{strict:!1}))throw new ra({address:n});if(e[n])throw new hk({address:n});e[n]=Zk(r)}return e}const Yk=2n**256n-1n;function Fd(t){const{account:e,maxFeePerGas:n,maxPriorityFeePerGas:r,to:i}=t,s=e?ai(e):void 0;if(s&&!Bi(s.address))throw new ra({address:s.address});if(i&&!Bi(i))throw new ra({address:i});if(n&&n>Yk)throw new $p({maxFeePerGas:n});if(r&&n&&r>n)throw new Ip({maxFeePerGas:n,maxPriorityFeePerGas:r})}async function Cm(t,e){const{account:n=t.account,authorizationList:r,batch:i=!!t.batch?.multicall,blockHash:s,blockNumber:o,blockTag:a=t.experimental_blockTag??"latest",requireCanonical:c,accessList:l,blobs:u,blockOverrides:d,code:h,data:p,factory:w,factoryData:g,gas:m,gasPrice:E,maxFeePerBlobGas:v,maxFeePerGas:S,maxPriorityFeePerGas:$,nonce:A,requestOptions:f,to:y,value:x,stateOverride:C,...P}=e,O=n?ai(n):void 0;if(h&&(w||g))throw new ee("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(h&&y)throw new ee("Cannot provide both `code` & `to` as parameters.");const N=h&&p,D=w&&g&&y&&p,b=N||D,_=N?C6({code:h,data:p}):D?nR({data:p,factory:w,factoryData:g,to:y}):p;try{Fd(e);const I=dm({blockHash:s,blockNumber:o,blockTag:a,requireCanonical:c}),T=d?Fk(d):void 0,R=b6(C),k=t.chain?.formatters?.transactionRequest?.format,U=(k||Pp)({...Ap(P,{format:k}),accessList:l,account:O,authorizationList:r,blobs:u,data:_,gas:m,gasPrice:E,maxFeePerBlobGas:v,maxFeePerGas:S,maxPriorityFeePerGas:$,nonce:A,to:b?void 0:y,value:x},"call");if(i&&Jk({request:U})&&!T&&s===void 0)try{const{deployless:F=!1}=typeof t.batch?.multicall=="object"?t.batch.multicall:{},V=E6(t,{blockNumber:o,deployless:F});if(!V||!tR(R,V))return await eR(t,{...U,blockHash:s,blockNumber:o,blockTag:a,multicallAddress:V,requestOptions:f,requireCanonical:c,rpcStateOverride:R})}catch(F){if(!(F instanceof K3)&&!(F instanceof Q1))throw F}const j=(()=>{const F=[U,I];return R&&T?[...F,R,T]:R?[...F,R]:T?[...F,{},T]:F})(),q=await t.request({method:"eth_call",params:j},f);return q==="0x"?{data:void 0}:{data:q}}catch(I){if(f?.signal?.aborted)throw ci(f.signal);if(lo(I))throw I;const T=rR(I),{offchainLookup:R,offchainLookupSignature:k}=await Promise.resolve().then(()=>eB);if(t.ccipRead!==!1&&T?.slice(0,10)===k&&y)return{data:await R(t,{data:T,requestOptions:f,to:y})};throw b&&T?.slice(0,10)==="0x101bb98d"?new xk({factory:w}):Vk(I,{...e,account:O,chain:t.chain})}}function Jk({request:t}){const{data:e,to:n,...r}=t;return!(!e||e.startsWith(zk)||!n||Object.values(r).filter(i=>typeof i<"u").length>0)}let Xk=0;const v6=new WeakMap;function Qk(t){if(!t)return"default";const e=v6.get(t);if(e!==void 0)return e;const n=Xk++;return v6.set(t,n),n}async function eR(t,e){const{batchSize:n=1024,deployless:r=!1,wait:i=0}=typeof t.batch?.multicall=="object"?t.batch.multicall:{},{blockHash:s,blockNumber:o,blockTag:a=t.experimental_blockTag??"latest",requireCanonical:c,data:l,multicallAddress:u,requestOptions:d,rpcStateOverride:h,to:p}=e,w=u!==void 0?u:E6(t,{blockNumber:o,deployless:r}),g=dm({blockHash:s,blockNumber:o,blockTag:a,requireCanonical:c}),m=typeof g=="string"?g:JSON.stringify(g),E=h?`.${JSON.stringify(h)}`:"",{schedule:v}=w6({id:`${t.uid}.${m}.${Qk(d)}${E}`,wait:i,shouldSplitBatch(A){return A.reduce((y,{data:x})=>y+(x.length-2),0)>n*2},fn:async A=>{const f=A.map(P=>({allowFailure:!0,callData:P.data,target:P.to})),y=X1({abi:Q5,args:[f],functionName:"aggregate3"}),x={...w===null?{data:C6({code:Wk,data:y})}:{to:w,data:y}},C=await t.request({method:"eth_call",params:h?[x,g,h]:[x,g]},d);return W3({abi:Q5,args:[f],functionName:"aggregate3",data:C||"0x"})}}),[{returnData:S,success:$}]=await v({data:l,to:p});if(!$)throw new e6({data:S});return S==="0x"?{data:void 0}:{data:S}}function E6(t,e){const{blockNumber:n,deployless:r}=e;if(r)return null;if(t.chain)return ak({blockNumber:n,chain:t.chain,contract:"multicall3"});throw new K3}function tR(t,e){return t?Object.keys(t).some(n=>g6(n,e)):!1}function C6(t){const{code:e,data:n}=t;return p6({abi:z3(["constructor(bytes, bytes)"]),bytecode:qk,args:[e,n]})}function nR(t){const{data:e,factory:n,factoryData:r,to:i}=t;return p6({abi:z3(["constructor(address, bytes, address, bytes)"]),bytecode:Hk,args:[i,e,n,r]})}function rR(t){if(!(t instanceof ee))return;const e=t.walk();return typeof e?.data=="object"?e.data?.data:e.data}async function iR(t,e){const{abi:n,address:r,args:i,functionName:s,...o}=e,a=X1({abi:n,args:i,functionName:s});try{const{data:c}=await dt(t,Cm,"call")({...o,data:a,to:r});return W3({abi:n,args:i,functionName:s,data:c||"0x"})}catch(c){throw s6(c,{abi:n,address:r,args:i,docsPath:"/docs/contract/readContract",functionName:s})}}function sR(t){const e=wp(`0x${t.substring(4)}`).substring(26);return yp(`0x${e}`)}async function oR({hash:t,signature:e}){const n=ls(t)?t:ad(t),{secp256k1:r}=await Promise.resolve().then(()=>AB);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:u,v:d,yParity:h}=e,p=Number(h??d),w=x6(p);return new r.Signature(Lc(l),Lc(u)).addRecoveryBit(w)}const o=ls(e)?e:ad(e);if(Mt(o)!==65)throw new Error("invalid signature length");const a=ia(`0x${o.slice(130)}`),c=x6(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function x6(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function aR({hash:t,signature:e}){return sR(await oR({hash:t,signature:e}))}function cR(t,e="hex"){const n=_6(t),r=F1(new Uint8Array(n.length));return n.encode(r),e==="hex"?Un(r.bytes):r.bytes}function _6(t){return Array.isArray(t)?lR(t.map(e=>_6(e))):uR(t)}function lR(t){const e=t.reduce((i,s)=>i+s.length,0),n=$6(e);return{length:e<=55?1+e:1+n+e,encode(i){e<=55?i.pushByte(192+e):(i.pushByte(247+n),n===1?i.pushUint8(e):n===2?i.pushUint16(e):n===3?i.pushUint24(e):i.pushUint32(e));for(const{encode:s}of t)s(i)}}}function uR(t){const e=typeof t=="string"?ki(t):t,n=$6(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+n+e.length,encode(i){e.length===1&&e[0]<128?i.pushBytes(e):e.length<=55?(i.pushByte(128+e.length),i.pushBytes(e)):(i.pushByte(183+n),n===1?i.pushUint8(e.length):n===2?i.pushUint16(e.length):n===3?i.pushUint24(e.length):i.pushUint32(e.length),i.pushBytes(e))}}}function $6(t){if(t<256)return 1;if(t<65536)return 2;if(t<16777216)return 3;if(t<4294967296)return 4;throw new ee("Length is too large.")}function dR(t){const{chainId:e,nonce:n,to:r}=t,i=t.contractAddress??t.address,s=wp(dd(["0x05",cR([e?Pe(e):"0x",i,n?Pe(n):"0x"])]));return r==="bytes"?ki(s):s}async function I6(t){const{authorization:e,signature:n}=t;return aR({hash:dR(e),signature:n??e})}class hR extends ee{constructor(e,{account:n,docsPath:r,chain:i,data:s,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:d,value:h}){const p=wd({from:n?.address,to:d,value:typeof h<"u"&&`${em(h)} ${i?.nativeCurrency?.symbol||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${Mn(a)} gwei`,maxFeePerGas:typeof c<"u"&&`${Mn(c)} gwei`,maxPriorityFeePerGas:typeof l<"u"&&`${Mn(l)} gwei`,nonce:u});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",p].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}function fR(t,{docsPath:e,...n}){const r=(()=>{const i=vm(t,n);return i instanceof Sp?t:i})();return new hR(r,{docsPath:e,...n})}class S6 extends ee{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class xm extends ee{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class pR extends ee{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Mn(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class A6 extends ee{constructor({blockHash:e,blockNumber:n}){let r="Block";e&&(r=`Block at hash "${e}"`),n&&(r=`Block at number "${n}"`),super(`${r} could not be found.`,{name:"BlockNotFoundError"})}}const P6={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function _m(t,e){const n={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,...t.blockTimestamp!=null&&{blockTimestamp:BigInt(t.blockTimestamp)},chainId:t.chainId?ia(t.chainId):void 0,gas:t.gas?BigInt(t.gas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,maxFeePerBlobGas:t.maxFeePerBlobGas?BigInt(t.maxFeePerBlobGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,nonce:t.nonce?ia(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?P6[t.type]:void 0,typeHex:t.type?t.type:void 0,value:t.value?BigInt(t.value):void 0,v:t.v?BigInt(t.v):void 0};return t.authorizationList&&(n.authorizationList=gR(t.authorizationList)),n.yParity=(()=>{if(t.yParity)return Number(t.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}function gR(t){return t.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))}function mR(t,e){const n=(t.transactions??[]).map(r=>typeof r=="string"?r:_m(r));return{...t,baseFeePerGas:t.baseFeePerGas?BigInt(t.baseFeePerGas):null,blobGasUsed:t.blobGasUsed?BigInt(t.blobGasUsed):void 0,difficulty:t.difficulty?BigInt(t.difficulty):void 0,excessBlobGas:t.excessBlobGas?BigInt(t.excessBlobGas):void 0,gasLimit:t.gasLimit?BigInt(t.gasLimit):void 0,gasUsed:t.gasUsed?BigInt(t.gasUsed):void 0,hash:t.hash?t.hash:null,logsBloom:t.logsBloom?t.logsBloom:null,nonce:t.nonce?t.nonce:null,number:t.number?BigInt(t.number):null,size:t.size?BigInt(t.size):void 0,timestamp:t.timestamp?BigInt(t.timestamp):void 0,transactions:n,totalDifficulty:t.totalDifficulty?BigInt(t.totalDifficulty):null}}async function Zc(t,{blockHash:e,blockNumber:n,blockTag:r=t.experimental_blockTag??"latest",includeTransactions:i}={}){const s=i??!1,o=n!==void 0?Pe(n):void 0;let a=null;if(e?a=await t.request({method:"eth_getBlockByHash",params:[e,s]},{dedupe:!0}):a=await t.request({method:"eth_getBlockByNumber",params:[o||r,s]},{dedupe:!!o}),!a)throw new A6({blockHash:e,blockNumber:n});return(t.chain?.formatters?.block?.format||mR)(a,"getBlock")}async function O6(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function wR(t,e){const{block:n,chain:r=t.chain,request:i}=e||{};try{const s=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if(typeof s=="function"){const a=n||await dt(t,Zc,"getBlock")({}),c=await s({block:a,client:t,request:i});if(c===null)throw new Error;return c}if(typeof s<"u")return s;const o=await t.request({method:"eth_maxPriorityFeePerGas"});return Lc(o)}catch{const[s,o]=await Promise.all([n?Promise.resolve(n):dt(t,Zc,"getBlock")({}),dt(t,O6,"getGasPrice")({})]);if(typeof s.baseFeePerGas!="bigint")throw new xm;const a=o-s.baseFeePerGas;return a<0n?0n:a}}async function N6(t,e){const{block:n,chain:r=t.chain,request:i,type:s="eip1559"}=e||{},o=await(async()=>typeof r?.fees?.baseFeeMultiplier=="function"?r.fees.baseFeeMultiplier({block:n,client:t,request:i}):r?.fees?.baseFeeMultiplier??1.2)();if(o<1)throw new S6;const c=10**(o.toString().split(".")[1]?.length??0),l=h=>h*BigInt(Math.ceil(o*c))/BigInt(c),u=n||await dt(t,Zc,"getBlock")({});if(typeof r?.fees?.estimateFeesPerGas=="function"){const h=await r.fees.estimateFeesPerGas({block:n,client:t,multiply:l,request:i,type:s});if(h!==null)return h}if(s==="eip1559"){if(typeof u.baseFeePerGas!="bigint")throw new xm;const h=typeof i?.maxPriorityFeePerGas=="bigint"?i.maxPriorityFeePerGas:await wR(t,{block:u,chain:r,request:i}),p=l(u.baseFeePerGas);return{maxFeePerGas:i?.maxFeePerGas??p+h,maxPriorityFeePerGas:h}}return{gasPrice:i?.gasPrice??l(await dt(t,O6,"getGasPrice")({}))}}async function yR(t,{address:e,blockHash:n,blockNumber:r,blockTag:i="latest",requireCanonical:s}){const o=dm({blockHash:n,blockNumber:r,blockTag:i,requireCanonical:s}),a=await t.request({method:"eth_getTransactionCount",params:[e,o]},{dedupe:typeof r=="bigint"||n!==void 0});return ia(a)}function T6(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(s=>ki(s)):t.blobs,i=[];for(const s of r)i.push(Uint8Array.from(e.blobToKzgCommitment(s)));return n==="bytes"?i:i.map(s=>Un(s))}function k6(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(o=>ki(o)):t.blobs,i=typeof t.commitments[0]=="string"?t.commitments.map(o=>ki(o)):t.commitments,s=[];for(let o=0;o<r.length;o++){const a=r[o],c=i[o];s.push(Uint8Array.from(e.computeBlobKzgProof(a,c)))}return n==="bytes"?s:s.map(o=>Un(o))}function bR(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+l,a,r)}function vR(t,e,n){return t&e^~t&n}function ER(t,e,n){return t&e^t&n^e&n}let CR=class extends U1{constructor(e,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=L1(this.buffer)}update(e){Mc(this),e=mp(e),sa(e);const{view:n,buffer:r,blockLen:i}=this,s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=L1(e);for(;i<=s-o;o+=i)this.process(c,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Mc(this),g3(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;n[o++]=128,jc(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(r,0),o=0);for(let d=o;d<i;d++)n[d]=0;bR(r,i-8,BigInt(this.length*8),s),this.process(r,0);const a=L1(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,u[d],s)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:s,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=s,e.length=i,e.pos=a,i%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}};const fo=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xR=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]),po=new Uint32Array(64);let _R=class extends CR{constructor(e=32){super(64,e,8,!1),this.A=fo[0]|0,this.B=fo[1]|0,this.C=fo[2]|0,this.D=fo[3]|0,this.E=fo[4]|0,this.F=fo[5]|0,this.G=fo[6]|0,this.H=fo[7]|0}get(){const{A:e,B:n,C:r,D:i,E:s,F:o,G:a,H:c}=this;return[e,n,r,i,s,o,a,c]}set(e,n,r,i,s,o,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,n){for(let d=0;d<16;d++,n+=4)po[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){const h=po[d-15],p=po[d-2],w=Ri(h,7)^Ri(h,18)^h>>>3,g=Ri(p,17)^Ri(p,19)^p>>>10;po[d]=g+po[d-7]+w+po[d-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const h=Ri(a,6)^Ri(a,11)^Ri(a,25),p=u+h+vR(a,c,l)+xR[d]+po[d]|0,g=(Ri(r,2)^Ri(r,13)^Ri(r,22))+ER(r,i,s)|0;u=l,l=c,c=a,a=o+p|0,o=s,s=i,i=r,r=p+g|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,i,s,o,a,c,l,u)}roundClean(){jc(po)}destroy(){this.set(0,0,0,0,0,0,0,0),jc(this.buffer)}};const R6=w3(()=>new _R),$R=R6;function IR(t,e){return $R(ls(t,{strict:!1})?D1(t):t)}function SR(t){const{commitment:e,version:n=1}=t,r=t.to??(typeof e=="string"?"hex":"bytes"),i=IR(e);return i.set([n],0),r==="bytes"?i:Un(i)}function AR(t){const{commitments:e,version:n}=t,r=t.to,i=[];for(const s of e)i.push(SR({commitment:s,to:r,version:n}));return i}const B6=6,D6=32,$m=4096,L6=D6*$m,U6=L6*B6-1-1*$m*B6;class PR extends ee{constructor({maxSize:e,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class OR extends ee{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function NR(t){const e=typeof t.data=="string"?ki(t.data):t.data,n=Mt(e);if(!n)throw new OR;if(n>U6)throw new PR({maxSize:U6,size:n});const r=[];let i=!0,s=0;for(;i;){const o=F1(new Uint8Array(L6));let a=0;for(;a<$m;){const c=e.slice(s,s+(D6-1));if(o.pushByte(0),o.pushBytes(c),c.length<31){o.pushByte(128),i=!1;break}a++,s+=31}r.push(o)}return r.map(o=>Un(o.bytes))}function TR(t){const{data:e,kzg:n,to:r}=t,i=t.blobs??NR({data:e}),s=t.commitments??T6({blobs:i,kzg:n,to:r}),o=t.proofs??k6({blobs:i,commitments:s,kzg:n,to:r}),a=[];for(let c=0;c<i.length;c++)a.push({blob:i[c],commitment:s[c],proof:o[c]});return a}function kR(t){if(t.type)return t.type;if(typeof t.authorizationList<"u")return"eip7702";if(typeof t.blobs<"u"||typeof t.blobVersionedHashes<"u"||typeof t.maxFeePerBlobGas<"u"||typeof t.sidecars<"u")return"eip4844";if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")return"eip1559";if(typeof t.gasPrice<"u")return typeof t.accessList<"u"?"eip2930":"legacy";throw new gk({transaction:t})}function M6(t,{docsPath:e,...n}){const r=(()=>{const i=vm(t,n);return i instanceof Sp?t:i})();return new mk(r,{docsPath:e,...n})}async function Op(t){const e=await t.request({method:"eth_chainId"},{dedupe:!0});return ia(e)}async function RR(t,e){const{account:n=t.account,accessList:r,authorizationList:i,chain:s=t.chain,blobVersionedHashes:o,blobs:a,data:c,gas:l,gasPrice:u,maxFeePerBlobGas:d,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:w,nonceManager:g,to:m,type:E,value:v,...S}=e,$=await(async()=>{if(!n||!g||typeof w<"u")return w;const x=ai(n),C=s?s.id:await dt(t,Op,"getChainId")({});return await g.consume({address:x.address,chainId:C,client:t})})();Fd(e);const A=s?.formatters?.transactionRequest?.format,y=(A||Pp)({...Ap(S,{format:A}),account:n?ai(n):void 0,accessList:r,authorizationList:i,blobs:a,blobVersionedHashes:o,data:c,gas:l,gasPrice:u,maxFeePerBlobGas:d,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:$,to:m,type:E,value:v},"fillTransaction");try{const x=await t.request({method:"eth_fillTransaction",params:[y]}),P=(s?.formatters?.transaction?.format||_m)(x.tx);delete P.blockHash,delete P.blockNumber,delete P.r,delete P.s,delete P.transactionIndex,delete P.v,delete P.yParity,P.data=P.input,P.gas&&(P.gas=e.gas??P.gas),P.gasPrice&&(P.gasPrice=e.gasPrice??P.gasPrice),P.maxFeePerBlobGas&&(P.maxFeePerBlobGas=e.maxFeePerBlobGas??P.maxFeePerBlobGas),P.maxFeePerGas&&(P.maxFeePerGas=e.maxFeePerGas??P.maxFeePerGas),P.maxPriorityFeePerGas&&(P.maxPriorityFeePerGas=e.maxPriorityFeePerGas??P.maxPriorityFeePerGas),typeof P.nonce<"u"&&(P.nonce=e.nonce??P.nonce);const O=await(async()=>{if(typeof s?.fees?.baseFeeMultiplier=="function"){const _=await dt(t,Zc,"getBlock")({});return s.fees.baseFeeMultiplier({block:_,client:t,request:e})}return s?.fees?.baseFeeMultiplier??1.2})();if(O<1)throw new S6;const D=10**(O.toString().split(".")[1]?.length??0),b=_=>_*BigInt(Math.ceil(O*D))/BigInt(D);return P.feePayerSignature||(P.maxFeePerGas&&!e.maxFeePerGas&&(P.maxFeePerGas=b(P.maxFeePerGas)),P.gasPrice&&!e.gasPrice&&(P.gasPrice=b(P.gasPrice))),{raw:x.raw,transaction:{from:y.from,...P},...x.capabilities?{capabilities:x.capabilities}:{}}}catch(x){throw M6(x,{...e,chain:t.chain})}}const j6=["blobVersionedHashes","chainId","fees","gas","nonce","type"],F6=new Map,Im=new ud(128);async function z6(t,e){let n=e;n.account??=t.account,n.parameters??=j6;const{account:r,chain:i=t.chain,nonceManager:s,parameters:o}=n,a=(()=>{if(typeof i?.prepareTransactionRequest=="function")return{fn:i.prepareTransactionRequest,runAt:["beforeFillTransaction"]};if(Array.isArray(i?.prepareTransactionRequest))return{fn:i.prepareTransactionRequest[0],runAt:i.prepareTransactionRequest[1].runAt}})();let c;async function l(){return c||(typeof n.chainId<"u"?n.chainId:i?i.id:(c=await dt(t,Op,"getChainId")({}),c))}const u=r&&ai(r);let d=n.nonce;if(o.includes("nonce")&&typeof d>"u"&&u&&s){const $=await l();d=await s.consume({address:u.address,chainId:$,client:t})}a?.fn&&a.runAt?.includes("beforeFillTransaction")&&(n=await a.fn({...n,chain:i},{client:t,phase:"beforeFillTransaction"}),d??=n.nonce);const p=((o.includes("blobVersionedHashes")||o.includes("sidecars"))&&n.kzg&&n.blobs||Im.get(t.uid)===!1||!["fees","gas"].some(A=>o.includes(A))?!1:!!(o.includes("chainId")&&typeof n.chainId!="number"||o.includes("nonce")&&typeof d!="number"||o.includes("fees")&&typeof n.gasPrice!="bigint"&&(typeof n.maxFeePerGas!="bigint"||typeof n.maxPriorityFeePerGas!="bigint")||o.includes("gas")&&typeof n.gas!="bigint"))?await dt(t,RR,"fillTransaction")({...n,nonce:d}).then($=>{const{chainId:A,from:f,gas:y,gasPrice:x,nonce:C,maxFeePerBlobGas:P,maxFeePerGas:O,maxPriorityFeePerGas:N,type:D,...b}=$.transaction;return Im.set(t.uid,!0),{...n,...f?{from:f}:{},...D&&!n.type?{type:D}:{},...typeof A<"u"?{chainId:A}:{},...typeof y<"u"?{gas:y}:{},...typeof x<"u"?{gasPrice:x}:{},...typeof C<"u"?{nonce:C}:{},...typeof P<"u"&&n.type!=="legacy"&&n.type!=="eip2930"?{maxFeePerBlobGas:P}:{},...typeof O<"u"&&n.type!=="legacy"&&n.type!=="eip2930"?{maxFeePerGas:O}:{},...typeof N<"u"&&n.type!=="legacy"&&n.type!=="eip2930"?{maxPriorityFeePerGas:N}:{},..."nonceKey"in b&&typeof b.nonceKey<"u"?{nonceKey:b.nonceKey}:{},..."keyAuthorization"in b&&typeof b.keyAuthorization<"u"&&b.keyAuthorization!==null&&!("keyAuthorization"in n)?{keyAuthorization:b.keyAuthorization}:{},..."feePayerSignature"in b&&typeof b.feePayerSignature<"u"&&b.feePayerSignature!==null?{feePayerSignature:b.feePayerSignature}:{},..."feeToken"in b&&typeof b.feeToken<"u"&&b.feeToken!==null&&!("feeToken"in n)?{feeToken:b.feeToken}:{},...$.capabilities?{_capabilities:$.capabilities}:{}}}).catch($=>{const A=$;if(A.name!=="TransactionExecutionError")return n;if(A.walk?.(x=>x.name==="ExecutionRevertedError"))throw $;return A.walk?.(x=>{const C=x;return C.name==="MethodNotFoundRpcError"||C.name==="MethodNotSupportedRpcError"||C.message?.includes("eth_fillTransaction is not available")})&&Im.set(t.uid,!1),n}):n;d??=p.nonce,n={...p,...u?{from:u?.address}:{},...typeof d<"u"?{nonce:d}:{}};const{blobs:w,gas:g,kzg:m,type:E}=n;a?.fn&&a.runAt?.includes("beforeFillParameters")&&(n=await a.fn({...n,chain:i},{client:t,phase:"beforeFillParameters"}));let v;async function S(){return v||(v=await dt(t,Zc,"getBlock")({blockTag:"latest"}),v)}if(o.includes("nonce")&&typeof d>"u"&&u&&!s&&(n.nonce=await dt(t,yR,"getTransactionCount")({address:u.address,blockTag:"pending"})),(o.includes("blobVersionedHashes")||o.includes("sidecars"))&&w&&m){const $=T6({blobs:w,kzg:m});if(o.includes("blobVersionedHashes")){const A=AR({commitments:$,to:"hex"});n.blobVersionedHashes=A}if(o.includes("sidecars")){const A=k6({blobs:w,commitments:$,kzg:m}),f=TR({blobs:w,commitments:$,proofs:A,to:"hex"});n.sidecars=f}}if(o.includes("chainId")&&(n.chainId=await l()),(o.includes("fees")||o.includes("type"))&&typeof E>"u")try{n.type=kR(n)}catch{let $=F6.get(t.uid);typeof $>"u"&&($=typeof(await S())?.baseFeePerGas=="bigint",F6.set(t.uid,$)),n.type=$?"eip1559":"legacy"}if(o.includes("fees"))if(n.type!=="legacy"&&n.type!=="eip2930"){if(typeof n.maxFeePerGas>"u"||typeof n.maxPriorityFeePerGas>"u"){const $=await S(),{maxFeePerGas:A,maxPriorityFeePerGas:f}=await N6(t,{block:$,chain:i,request:n});if(typeof n.maxPriorityFeePerGas>"u"&&n.maxFeePerGas&&n.maxFeePerGas<f)throw new pR({maxPriorityFeePerGas:f});n.maxPriorityFeePerGas=f,n.maxFeePerGas=A}}else{if(typeof n.maxFeePerGas<"u"||typeof n.maxPriorityFeePerGas<"u")throw new xm;if(typeof n.gasPrice>"u"){const $=await S(),{gasPrice:A}=await N6(t,{block:$,chain:i,request:n,type:"legacy"});n.gasPrice=A}}return o.includes("gas")&&typeof g>"u"&&(n.gas=await dt(t,BR,"estimateGas")({...n,account:u,prepare:u?.type==="local"?[]:["blobVersionedHashes"]})),a?.fn&&a.runAt?.includes("afterFillParameters")&&(n=await a.fn({...n,chain:i},{client:t,phase:"afterFillParameters"})),Fd(n),delete n.parameters,n}async function BR(t,e){const{account:n=t.account,prepare:r=!0}=e,i=n?ai(n):void 0,s=(()=>{if(Array.isArray(r))return r;if(i?.type!=="local")return["blobVersionedHashes"]})();try{const o=await(async()=>{if(e.to)return e.to;if(e.authorizationList&&e.authorizationList.length>0)return await I6({authorization:e.authorizationList[0]}).catch(()=>{throw new ee("`to` is required. Could not infer from `authorizationList`")})})(),{accessList:a,authorizationList:c,blobs:l,blobVersionedHashes:u,blockNumber:d,blockTag:h,data:p,gas:w,gasPrice:g,maxFeePerBlobGas:m,maxFeePerGas:E,maxPriorityFeePerGas:v,nonce:S,value:$,stateOverride:A,...f}=r?await z6(t,{...e,parameters:s,to:o}):e;if(w&&e.gas!==w)return w;const x=(typeof d=="bigint"?Pe(d):void 0)||h,C=b6(A);Fd(e);const P=t.chain?.formatters?.transactionRequest?.format,N=(P||Pp)({...Ap(f,{format:P}),account:i,accessList:a,authorizationList:c,blobs:l,blobVersionedHashes:u,data:p,gasPrice:g,maxFeePerBlobGas:m,maxFeePerGas:E,maxPriorityFeePerGas:v,nonce:S,to:o,value:$},"estimateGas");return BigInt(await t.request({method:"eth_estimateGas",params:C?[N,x??t.experimental_blockTag??"latest",C]:x?[N,x]:[N]}))}catch(o){throw fR(o,{...e,account:i,chain:t.chain})}}const DR=new Map,LR=new Map;function UR(t){const e=(i,s)=>({clear:()=>s.delete(i),get:()=>s.get(i),set:o=>s.set(i,o)}),n=e(t,DR),r=e(t,LR);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}async function MR(t,{cacheKey:e,cacheTime:n=Number.POSITIVE_INFINITY}){const r=UR(e),i=r.response.get();if(i&&n>0&&Date.now()-i.created.getTime()<n)return i.data;let s=r.promise.get();s||(s=t(),r.promise.set(s));try{const o=await s;return r.response.set({created:new Date,data:o}),o}finally{r.promise.clear()}}const jR=t=>`blockNumber.${t}`;async function FR(t,{cacheTime:e=t.cacheTime}={}){const n=await MR(()=>t.request({method:"eth_blockNumber"}),{cacheKey:jR(t.uid),cacheTime:e});return BigInt(n)}function zR(t,{args:e,eventName:n}={}){return{...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,blockTimestamp:t.blockTimestamp?BigInt(t.blockTimestamp):t.blockTimestamp===null?null:void 0,logIndex:t.logIndex?Number(t.logIndex):null,transactionHash:t.transactionHash?t.transactionHash:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,...n?{args:e,eventName:n}:{}}}const qR={"0x0":"reverted","0x1":"success"};function HR(t,e){const n={...t,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,contractAddress:t.contractAddress?t.contractAddress:null,cumulativeGasUsed:t.cumulativeGasUsed?BigInt(t.cumulativeGasUsed):null,effectiveGasPrice:t.effectiveGasPrice?BigInt(t.effectiveGasPrice):null,gasUsed:t.gasUsed?BigInt(t.gasUsed):null,logs:t.logs?t.logs.map(r=>zR(r)):null,to:t.to?t.to:null,transactionIndex:t.transactionIndex?ia(t.transactionIndex):null,status:t.status?qR[t.status]:null,type:t.type?P6[t.type]||t.type:null};return t.blobGasPrice&&(n.blobGasPrice=BigInt(t.blobGasPrice)),t.blobGasUsed&&(n.blobGasUsed=BigInt(t.blobGasUsed)),n}const Np=new ud(8192);function WR(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(Np.get(n))return Np.get(n);const r=t().finally(()=>Np.delete(n));return Np.set(n,r),r}async function Tp(t,{signal:e}={}){return new Promise((n,r)=>{if(e?.aborted){r(ci(e));return}const i=()=>e?.removeEventListener("abort",o),s=setTimeout(()=>{i(),n()},t),o=()=>{clearTimeout(s),i(),r(ci(e))};e?.addEventListener("abort",o,{once:!0})})}function kp(t,{delay:e=100,retryCount:n=2,shouldRetry:r=()=>!0,signal:i}={}){return new Promise((s,o)=>{const a=async({count:c=0}={})=>{if(i?.aborted){o(ci(i));return}const l=async({error:u})=>{const d=typeof e=="function"?e({count:c,error:u}):e;if(d)try{await Tp(d,{signal:i})}catch(h){o(h);return}a({count:c+1})};try{const u=await t();s(u)}catch(u){if(i?.aborted){o(ci(i));return}if(lo(u)){o(u);return}if(c<n&&await r({count:c,error:u}))return l({error:u});o(u)}};a()})}function VR(t,e={}){return async(n,r={})=>{const{dedupe:i=!1,methods:s,retryDelay:o=150,retryCount:a=3,signal:c,uid:l}={...e,...r},{method:u}=n;if(s?.exclude?.includes(u))throw new la(new Error("method not supported"),{method:u});if(s?.include&&!s.include.includes(u))throw new la(new Error("method not supported"),{method:u});if(c?.aborted)throw ci(c);const d=i?GR(`${l}.${pr(n)}`):void 0;return WR(()=>kp(async()=>{try{return await t(n,c?{signal:c}:void 0)}catch(h){if(c?.aborted)throw ci(c);if(lo(h))throw h;const p=h;switch(p.code){case bd.code:throw new bd(p);case vd.code:throw new vd(p);case Ed.code:throw new Ed(p,{method:n.method});case Cd.code:throw new Cd(p);case ca.code:throw new ca(p);case Hc.code:throw new Hc(p);case xd.code:throw new xd(p);case uo.code:throw new uo(p);case Wc.code:throw new Wc(p);case la.code:throw new la(p,{method:n.method});case Vc.code:throw new Vc(p);case _d.code:throw new _d(p);case Pt.code:throw new Pt(p);case $d.code:throw new $d(p);case Id.code:throw new Id(p);case Sd.code:throw new Sd(p);case Ad.code:throw new Ad(p);case ho.code:throw new ho(p);case Pd.code:throw new Pd(p);case Od.code:throw new Od(p);case Nd.code:throw new Nd(p);case Td.code:throw new Td(p);case kd.code:throw new kd(p);case Rd.code:throw new Rd(p);case Bd.code:throw new Bd(p);case 5e3:throw new Pt(p);case Kc.code:throw new Kc(p);default:throw h instanceof ee?h:new Ak(p)}}},{delay:({count:h,error:p})=>{if(p&&p instanceof aa){const w=p?.headers?.get("Retry-After");if(w?.match(/\d/))return Number.parseInt(w,10)*1e3}return~~(1<<h)*o},retryCount:a,signal:c,shouldRetry:({error:h})=>KR(h)}),{enabled:i,id:d})}}function KR(t){return lo(t)?!1:"code"in t&&typeof t.code=="number"?t.code===-1||t.code===Vc.code||t.code===ca.code||t.code===429:t instanceof aa&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function GR(t,e=0){let n=3735928559^e,r=1103547991^e;for(let i=0;i<t.length;i++){const s=t.charCodeAt(i);n=Math.imul(n^s,2654435761),r=Math.imul(r^s,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)}class ZR extends ee{constructor({callbackSelector:e,cause:n,data:r,extraData:i,sender:s,urls:o}){super(n.shortMessage||"An error occurred while fetching for an offchain result.",{cause:n,metaMessages:[...n.metaMessages||[],n.metaMessages?.length?"":[],"Offchain Gateway Call:",o&&[" Gateway URL(s):",...o.map(a=>` ${yd(a)}`)],` Sender: ${s}`,` Data: ${r}`,` Callback selector: ${e}`,` Extra data: ${i}`].flat(),name:"OffchainLookupError"})}}class YR extends ee{constructor({result:e,url:n}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${yd(n)}`,`Response: ${pr(e)}`],name:"OffchainLookupResponseMalformedError"})}}class JR extends ee{constructor({sender:e,to:n}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${n}`,`OffchainLookup sender address: ${e}`],name:"OffchainLookupSenderMismatchError"})}}const XR="0x556f1830",q6={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function QR(t,{blockNumber:e,blockTag:n,data:r,requestOptions:i,to:s}){const{args:o}=Z3({data:r,abi:[q6]}),[a,c,l,u,d]=o,{ccipRead:h}=t,p=h&&typeof h?.request=="function"?h.request:H6;try{if(!g6(s,a))throw new JR({sender:a,to:s});const w=c.includes(n6)?await r6({data:l,ccipRequest:m=>p({...m,requestOptions:i})}):await p({data:l,requestOptions:i,sender:a,urls:c}),{data:g}=await Cm(t,{blockNumber:e,blockTag:n,data:hs([u,hd([{type:"bytes"},{type:"bytes"}],[w,d])]),requestOptions:i,to:s});return g}catch(w){throw i?.signal?.aborted?ci(i.signal):lo(w)?w:new ZR({callbackSelector:u,cause:w,data:r,extraData:d,sender:a,urls:c})}}async function H6({data:t,requestOptions:e,sender:n,urls:r}){let i=new Error("An unknown error occurred.");for(let s=0;s<r.length;s++){if(e?.signal?.aborted)throw ci(e.signal);const o=r[s],a=o.includes("{data}")?"GET":"POST",c=a==="POST"?{data:t,sender:n}:void 0,l=a==="POST"?{"Content-Type":"application/json"}:{};try{const u=await fetch(o.replace("{sender}",n.toLowerCase()).replace("{data}",t),{body:JSON.stringify(c),headers:l,method:a,...e?.signal?{signal:e.signal}:{}});let d;if(u.headers.get("Content-Type")?.startsWith("application/json")?d=(await u.json()).data:d=await u.text(),!u.ok){i=new aa({body:c,details:d?.error?pr(d.error):u.statusText,headers:u.headers,status:u.status,url:o});continue}if(!ls(d)){i=new YR({result:d,url:o});continue}return d}catch(u){if(e?.signal?.aborted)throw ci(e.signal);if(lo(u))throw u;i=new aa({body:c,details:u.message,url:o})}}throw i}const eB=Object.freeze(Object.defineProperty({__proto__:null,ccipRequest:H6,offchainLookup:QR,offchainLookupAbiItem:q6,offchainLookupSignature:XR},Symbol.toStringTag,{value:"Module"}));function tB({chain:t,currentChainId:e}){if(!t)throw new ok;if(e!==t.id)throw new sk({chain:t,currentChainId:e})}function Sm(t){const e={formatters:void 0,fees:void 0,serializers:void 0,...t};function n(r){return i=>{const s=typeof i=="function"?i(r):i,o={...r,...s};return Object.assign(o,{extend:n(o)})}}return Object.assign(e,{extend:n(e)})}function W6(t,{errorInstance:e=new Error("timed out"),timeout:n,signal:r}){return new Promise((i,s)=>{(async()=>{let o;const a=new AbortController;try{n>0&&(o=setTimeout(()=>{r?a.abort():s(e)},n)),i(await t({signal:a?.signal||null}))}catch(c){if(a?.signal.aborted&&lo(c)){s(e);return}s(c)}finally{clearTimeout(o)}})()})}function nB(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const V6=nB();function rB(t,e={}){const{url:n,headers:r}=iB(t);return{async request(i){const{body:s,fetchFn:o=e.fetchFn??fetch,onRequest:a=e.onRequest,onResponse:c=e.onResponse,timeout:l=e.timeout??1e4}=i,u={...e.fetchOptions??{},...i.fetchOptions??{}},{headers:d,method:h,signal:p}=u;try{const w=await W6(async({signal:m})=>{const E={...u,body:Array.isArray(s)?pr(s.map(A=>({jsonrpc:"2.0",id:A.id??V6.take(),...A}))):pr({jsonrpc:"2.0",id:s.id??V6.take(),...s}),headers:{...r,"Content-Type":"application/json",...d},method:h||"POST",signal:p||(l>0?m:null)},v=new Request(n,E),S=await a?.(v,E)??{...E,url:n};return await o(S.url??n,S)},{errorInstance:new i6({body:s,url:n}),timeout:l,signal:!0});c&&await c(w);let g;if(w.headers.get("Content-Type")?.startsWith("application/json"))g=await w.json();else{g=await w.text();try{g=JSON.parse(g||"{}")}catch(m){if(w.ok)throw m;g={error:g}}}if(!w.ok){if(typeof g.error?.code=="number"&&typeof g.error?.message=="string")return g;throw new aa({body:s,details:pr(g.error)||w.statusText,headers:w.headers,status:w.status,url:n})}return g}catch(w){throw p?.aborted?ci(p):lo(w)||w instanceof aa||w instanceof i6?w:new aa({body:s,cause:w,url:n})}}}}function iB(t){try{const e=new URL(t),n=(()=>{if(e.username){const r=`${decodeURIComponent(e.username)}:${decodeURIComponent(e.password)}`;return e.username="",e.password="",{url:e.toString(),headers:{Authorization:`Basic ${btoa(r)}`}}}})();return{url:e.toString(),...n}}catch{return{url:t}}}let K6=class extends U1{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,EN(e);const r=mp(n);if(this.iHash=e.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 i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?e.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),jc(s)}update(e){return Mc(this),this.iHash.update(e),this}digestInto(e){Mc(this),sa(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const G6=(t,e,n)=>new K6(t,e).update(n).digest();G6.create=(t,e)=>new K6(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zn=BigInt(0),On=BigInt(1),ha=BigInt(2),sB=BigInt(3),Z6=BigInt(4),Y6=BigInt(5),J6=BigInt(8);function qn(t,e){const n=t%e;return n>=zn?n:e+n}function jr(t,e,n){let r=t;for(;e-- >zn;)r*=r,r%=n;return r}function Am(t,e){if(t===zn)throw new Error("invert: expected non-zero number");if(e<=zn)throw new Error("invert: expected positive modulus, got "+e);let n=qn(t,e),r=e,i=zn,s=On;for(;n!==zn;){const a=r/n,c=r%n,l=i-s*a;r=n,n=c,i=s,s=l}if(r!==On)throw new Error("invert: does not exist");return qn(i,e)}function X6(t,e){const n=(t.ORDER+On)/Z6,r=t.pow(e,n);if(!t.eql(t.sqr(r),e))throw new Error("Cannot find square root");return r}function oB(t,e){const n=(t.ORDER-Y6)/J6,r=t.mul(e,ha),i=t.pow(r,n),s=t.mul(e,i),o=t.mul(t.mul(s,ha),i),a=t.mul(s,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),e))throw new Error("Cannot find square root");return a}function aB(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-On,n=0;for(;e%ha===zn;)e/=ha,n++;let r=ha;const i=Pm(t);for(;e8(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return X6;let s=i.pow(r,e);const o=(e+On)/ha;return function(c,l){if(c.is0(l))return l;if(e8(c,l)!==1)throw new Error("Cannot find square root");let u=n,d=c.mul(c.ONE,s),h=c.pow(l,e),p=c.pow(l,o);for(;!c.eql(h,c.ONE);){if(c.is0(h))return c.ZERO;let w=1,g=c.sqr(h);for(;!c.eql(g,c.ONE);)if(w++,g=c.sqr(g),w===u)throw new Error("Cannot find square root");const m=On<<BigInt(u-w-1),E=c.pow(d,m);u=w,d=c.sqr(E),h=c.mul(h,d),p=c.mul(p,E)}return p}}function cB(t){return t%Z6===sB?X6:t%J6===Y6?oB:aB(t)}const lB=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function uB(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=lB.reduce((r,i)=>(r[i]="function",r),e);return _p(t,n)}function dB(t,e,n){if(n<zn)throw new Error("invalid exponent, negatives unsupported");if(n===zn)return t.ONE;if(n===On)return e;let r=t.ONE,i=e;for(;n>zn;)n&On&&(r=t.mul(r,i)),i=t.sqr(i),n>>=On;return r}function Q6(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),i=e.reduce((o,a,c)=>t.is0(a)?o:(r[c]=o,t.mul(o,a)),t.ONE),s=t.inv(i);return e.reduceRight((o,a,c)=>t.is0(a)?o:(r[c]=t.mul(o,r[c]),t.mul(o,a)),s),r}function e8(t,e){const n=(t.ORDER-On)/ha,r=t.pow(e,n),i=t.eql(r,t.ONE),s=t.eql(r,t.ZERO),o=t.eql(r,t.neg(t.ONE));if(!i&&!s&&!o)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function t8(t,e){e!==void 0&&cd(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Pm(t,e,n=!1,r={}){if(t<=zn)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:s}=t8(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:n,BITS:i,BYTES:s,MASK:xp(i),ZERO:zn,ONE:On,create:c=>qn(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return zn<=c&&c<t},is0:c=>c===zn,isOdd:c=>(c&On)===On,neg:c=>qn(-c,t),eql:(c,l)=>c===l,sqr:c=>qn(c*c,t),add:(c,l)=>qn(c+l,t),sub:(c,l)=>qn(c-l,t),mul:(c,l)=>qn(c*l,t),pow:(c,l)=>dB(a,c,l),div:(c,l)=>qn(c*Am(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Am(c,t),sqrt:r.sqrt||(c=>(o||(o=cB(t)),o(a,c))),toBytes:c=>n?u6(c,s):Md(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return n?l6(c):ua(c)},invertBatch:c=>Q6(a,c),cmov:(c,l,u)=>u?l:c});return Object.freeze(a)}function n8(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function r8(t){const e=n8(t);return e+Math.ceil(e/2)}function hB(t,e,n=!1){const r=t.length,i=n8(e),s=r8(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const o=n?l6(t):ua(t),a=qn(o,e-On)+On;return n?u6(a,i):Md(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const i8=BigInt(0),Om=BigInt(1);function Nm(t,e){const n=e.negate();return t?n:e}function s8(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Tm(t,e){s8(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),i=2**t,s=xp(t),o=BigInt(t);return{windows:n,windowSize:r,mask:s,maxNumber:i,shiftBy:o}}function o8(t,e,n){const{windowSize:r,mask:i,maxNumber:s,shiftBy:o}=n;let a=Number(t&i),c=t>>o;a>r&&(a-=s,c+=Om);const l=e*r,u=l+Math.abs(a)-1,d=a===0,h=a<0,p=e%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:h,isNegF:p,offsetF:l}}function fB(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function pB(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const km=new WeakMap,a8=new WeakMap;function Rm(t){return a8.get(t)||1}function gB(t,e){return{constTimeNegate:Nm,hasPrecomputes(n){return Rm(n)!==1},unsafeLadder(n,r,i=t.ZERO){let s=n;for(;r>i8;)r&Om&&(i=i.add(s)),s=s.double(),r>>=Om;return i},precomputeWindow(n,r){const{windows:i,windowSize:s}=Tm(r,e),o=[];let a=n,c=a;for(let l=0;l<i;l++){c=a,o.push(c);for(let u=1;u<s;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(n,r,i){let s=t.ZERO,o=t.BASE;const a=Tm(n,e);for(let c=0;c<a.windows;c++){const{nextN:l,offset:u,isZero:d,isNeg:h,isNegF:p,offsetF:w}=o8(i,c,a);i=l,d?o=o.add(Nm(p,r[w])):s=s.add(Nm(h,r[u]))}return{p:s,f:o}},wNAFUnsafe(n,r,i,s=t.ZERO){const o=Tm(n,e);for(let a=0;a<o.windows&&i!==i8;a++){const{nextN:c,offset:l,isZero:u,isNeg:d}=o8(i,a,o);if(i=c,!u){const h=r[l];s=s.add(d?h.negate():h)}}return s},getPrecomputes(n,r,i){let s=km.get(r);return s||(s=this.precomputeWindow(r,n),n!==1&&km.set(r,i(s))),s},wNAFCached(n,r,i){const s=Rm(n);return this.wNAF(s,this.getPrecomputes(s,n,i),r)},wNAFCachedUnsafe(n,r,i,s){const o=Rm(n);return o===1?this.unsafeLadder(n,r,s):this.wNAFUnsafe(o,this.getPrecomputes(o,n,i),r,s)},setWindowSize(n,r){s8(r,e),a8.set(n,r),km.delete(n)}}}function mB(t,e,n,r){fB(n,t),pB(r,e);const i=n.length,s=r.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=Nk(BigInt(i));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=xp(c),u=new Array(Number(l)+1).fill(o),d=Math.floor((e.BITS-1)/c)*c;let h=o;for(let p=d;p>=0;p-=c){u.fill(o);for(let g=0;g<s;g++){const m=r[g],E=Number(m>>BigInt(p)&l);u[E]=u[E].add(n[g])}let w=o;for(let g=u.length-1,m=o;g>0;g--)m=m.add(u[g]),w=w.add(m);if(h=h.add(w),p!==0)for(let g=0;g<c;g++)h=h.double()}return h}function c8(t){return uB(t.Fp),_p(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...t8(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function l8(t){t.lowS!==void 0&&Ld("lowS",t.lowS),t.prehash!==void 0&&Ld("prehash",t.prehash)}function wB(t){const e=c8(t);_p(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,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({...e})}const ms={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{const{Err:n}=ms;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,i=vp(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?vp(i.length/2|128):"";return vp(t)+s+i+e},decode(t,e){const{Err:n}=ms;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const i=e[r++],s=!!(i&128);let o=0;if(!s)o=i;else{const c=i&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 l=e.subarray(r,r+c);if(l.length!==c)throw new n("tlv.decode: length bytes not complete");if(l[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const u of l)o=o<<8|u;if(r+=c,o<128)throw new n("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=ms;if(t<ws)throw new e("integer: negative integers are not allowed");let n=vp(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=ms;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return ua(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=ms,i=Mr("signature",t),{v:s,l:o}=r.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,s),{v:l,l:u}=r.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(l)}},hexFromSig(t){const{_tlv:e,_int:n}=ms,r=e.encode(2,n.encode(t.r)),i=e.encode(2,n.encode(t.s)),s=r+i;return e.encode(48,s)}};function Bm(t,e){return Ud(Md(t,e))}const ws=BigInt(0),jt=BigInt(1);BigInt(2);const Dm=BigInt(3),yB=BigInt(4);function bB(t){const e=wB(t),{Fp:n}=e,r=Pm(e.n,e.nBitLength),i=e.toBytes||((S,$,A)=>{const f=$.toAffine();return Cp(Uint8Array.from([4]),n.toBytes(f.x),n.toBytes(f.y))}),s=e.fromBytes||(S=>{const $=S.subarray(1),A=n.fromBytes($.subarray(0,n.BYTES)),f=n.fromBytes($.subarray(n.BYTES,2*n.BYTES));return{x:A,y:f}});function o(S){const{a:$,b:A}=e,f=n.sqr(S),y=n.mul(f,S);return n.add(n.add(y,n.mul(S,$)),A)}function a(S,$){const A=n.sqr($),f=o(S);return n.eql(A,f)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const c=n.mul(n.pow(e.a,Dm),yB),l=n.mul(n.sqr(e.b),BigInt(27));if(n.is0(n.add(c,l)))throw new Error("bad curve params: a or b");function u(S){return cm(S,jt,e.n)}function d(S){const{allowedPrivateKeyLengths:$,nByteLength:A,wrapPrivateKey:f,n:y}=e;if($&&typeof S!="bigint"){if(Dd(S)&&(S=Ud(S)),typeof S!="string"||!$.includes(S.length))throw new Error("invalid private key");S=S.padStart(A*2,"0")}let x;try{x=typeof S=="bigint"?S:ua(Mr("private key",S,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof S)}return f&&(x=qn(x,y)),Gc("private key",x,jt,y),x}function h(S){if(!(S instanceof g))throw new Error("ProjectivePoint expected")}const p=h6((S,$)=>{const{px:A,py:f,pz:y}=S;if(n.eql(y,n.ONE))return{x:A,y:f};const x=S.is0();$==null&&($=x?n.ONE:n.inv(y));const C=n.mul(A,$),P=n.mul(f,$),O=n.mul(y,$);if(x)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:C,y:P}}),w=h6(S=>{if(S.is0()){if(e.allowInfinityPoint&&!n.is0(S.py))return;throw new Error("bad point: ZERO")}const{x:$,y:A}=S.toAffine();if(!n.isValid($)||!n.isValid(A))throw new Error("bad point: x or y not FE");if(!a($,A))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor($,A,f){if($==null||!n.isValid($))throw new Error("x required");if(A==null||!n.isValid(A)||n.is0(A))throw new Error("y required");if(f==null||!n.isValid(f))throw new Error("z required");this.px=$,this.py=A,this.pz=f,Object.freeze(this)}static fromAffine($){const{x:A,y:f}=$||{};if(!$||!n.isValid(A)||!n.isValid(f))throw new Error("invalid affine point");if($ instanceof g)throw new Error("projective point not allowed");const y=x=>n.eql(x,n.ZERO);return y(A)&&y(f)?g.ZERO:new g(A,f,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ($){const A=Q6(n,$.map(f=>f.pz));return $.map((f,y)=>f.toAffine(A[y])).map(g.fromAffine)}static fromHex($){const A=g.fromAffine(s(Mr("pointHex",$)));return A.assertValidity(),A}static fromPrivateKey($){return g.BASE.multiply(d($))}static msm($,A){return mB(g,r,$,A)}_setWindowSize($){v.setWindowSize(this,$)}assertValidity(){w(this)}hasEvenY(){const{y:$}=this.toAffine();if(n.isOdd)return!n.isOdd($);throw new Error("Field doesn't support isOdd")}equals($){h($);const{px:A,py:f,pz:y}=this,{px:x,py:C,pz:P}=$,O=n.eql(n.mul(A,P),n.mul(x,y)),N=n.eql(n.mul(f,P),n.mul(C,y));return O&&N}negate(){return new g(this.px,n.neg(this.py),this.pz)}double(){const{a:$,b:A}=e,f=n.mul(A,Dm),{px:y,py:x,pz:C}=this;let P=n.ZERO,O=n.ZERO,N=n.ZERO,D=n.mul(y,y),b=n.mul(x,x),_=n.mul(C,C),I=n.mul(y,x);return I=n.add(I,I),N=n.mul(y,C),N=n.add(N,N),P=n.mul($,N),O=n.mul(f,_),O=n.add(P,O),P=n.sub(b,O),O=n.add(b,O),O=n.mul(P,O),P=n.mul(I,P),N=n.mul(f,N),_=n.mul($,_),I=n.sub(D,_),I=n.mul($,I),I=n.add(I,N),N=n.add(D,D),D=n.add(N,D),D=n.add(D,_),D=n.mul(D,I),O=n.add(O,D),_=n.mul(x,C),_=n.add(_,_),D=n.mul(_,I),P=n.sub(P,D),N=n.mul(_,b),N=n.add(N,N),N=n.add(N,N),new g(P,O,N)}add($){h($);const{px:A,py:f,pz:y}=this,{px:x,py:C,pz:P}=$;let O=n.ZERO,N=n.ZERO,D=n.ZERO;const b=e.a,_=n.mul(e.b,Dm);let I=n.mul(A,x),T=n.mul(f,C),R=n.mul(y,P),k=n.add(A,f),B=n.add(x,C);k=n.mul(k,B),B=n.add(I,T),k=n.sub(k,B),B=n.add(A,y);let U=n.add(x,P);return B=n.mul(B,U),U=n.add(I,R),B=n.sub(B,U),U=n.add(f,y),O=n.add(C,P),U=n.mul(U,O),O=n.add(T,R),U=n.sub(U,O),D=n.mul(b,B),O=n.mul(_,R),D=n.add(O,D),O=n.sub(T,D),D=n.add(T,D),N=n.mul(O,D),T=n.add(I,I),T=n.add(T,I),R=n.mul(b,R),B=n.mul(_,B),T=n.add(T,R),R=n.sub(I,R),R=n.mul(b,R),B=n.add(B,R),I=n.mul(T,B),N=n.add(N,I),I=n.mul(U,B),O=n.mul(k,O),O=n.sub(O,I),I=n.mul(k,T),D=n.mul(U,D),D=n.add(D,I),new g(O,N,D)}subtract($){return this.add($.negate())}is0(){return this.equals(g.ZERO)}wNAF($){return v.wNAFCached(this,$,g.normalizeZ)}multiplyUnsafe($){const{endo:A,n:f}=e;Gc("scalar",$,ws,f);const y=g.ZERO;if($===ws)return y;if(this.is0()||$===jt)return this;if(!A||v.hasPrecomputes(this))return v.wNAFCachedUnsafe(this,$,g.normalizeZ);let{k1neg:x,k1:C,k2neg:P,k2:O}=A.splitScalar($),N=y,D=y,b=this;for(;C>ws||O>ws;)C&jt&&(N=N.add(b)),O&jt&&(D=D.add(b)),b=b.double(),C>>=jt,O>>=jt;return x&&(N=N.negate()),P&&(D=D.negate()),D=new g(n.mul(D.px,A.beta),D.py,D.pz),N.add(D)}multiply($){const{endo:A,n:f}=e;Gc("scalar",$,jt,f);let y,x;if(A){const{k1neg:C,k1:P,k2neg:O,k2:N}=A.splitScalar($);let{p:D,f:b}=this.wNAF(P),{p:_,f:I}=this.wNAF(N);D=v.constTimeNegate(C,D),_=v.constTimeNegate(O,_),_=new g(n.mul(_.px,A.beta),_.py,_.pz),y=D.add(_),x=b.add(I)}else{const{p:C,f:P}=this.wNAF($);y=C,x=P}return g.normalizeZ([y,x])[0]}multiplyAndAddUnsafe($,A,f){const y=g.BASE,x=(P,O)=>O===ws||O===jt||!P.equals(y)?P.multiplyUnsafe(O):P.multiply(O),C=x(this,A).add(x($,f));return C.is0()?void 0:C}toAffine($){return p(this,$)}isTorsionFree(){const{h:$,isTorsionFree:A}=e;if($===jt)return!0;if(A)return A(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:$,clearCofactor:A}=e;return $===jt?this:A?A(g,this):this.multiplyUnsafe(e.h)}toRawBytes($=!0){return Ld("isCompressed",$),this.assertValidity(),i(g,this,$)}toHex($=!0){return Ld("isCompressed",$),Ud(this.toRawBytes($))}}g.BASE=new g(e.Gx,e.Gy,n.ONE),g.ZERO=new g(n.ZERO,n.ONE,n.ZERO);const{endo:m,nBitLength:E}=e,v=gB(g,m?Math.ceil(E/2):E);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:d,weierstrassEquation:o,isWithinCurveOrder:u}}function vB(t){const e=c8(t);return _p(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function EB(t){const e=vB(t),{Fp:n,n:r,nByteLength:i,nBitLength:s}=e,o=n.BYTES+1,a=2*n.BYTES+1;function c(_){return qn(_,r)}function l(_){return Am(_,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:d,weierstrassEquation:h,isWithinCurveOrder:p}=bB({...e,toBytes(_,I,T){const R=I.toAffine(),k=n.toBytes(R.x),B=Cp;return Ld("isCompressed",T),T?B(Uint8Array.from([I.hasEvenY()?2:3]),k):B(Uint8Array.from([4]),k,n.toBytes(R.y))},fromBytes(_){const I=_.length,T=_[0],R=_.subarray(1);if(I===o&&(T===2||T===3)){const k=ua(R);if(!cm(k,jt,n.ORDER))throw new Error("Point is not on curve");const B=h(k);let U;try{U=n.sqrt(B)}catch(F){const V=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+V)}const j=(U&jt)===jt;return(T&1)===1!==j&&(U=n.neg(U)),{x:k,y:U}}else if(I===a&&T===4){const k=n.fromBytes(R.subarray(0,n.BYTES)),B=n.fromBytes(R.subarray(n.BYTES,2*n.BYTES));return{x:k,y:B}}else{const k=o,B=a;throw new Error("invalid Point, expected length of "+k+", or uncompressed "+B+", got "+I)}}});function w(_){const I=r>>jt;return _>I}function g(_){return w(_)?c(-_):_}const m=(_,I,T)=>ua(_.slice(I,T));class E{constructor(I,T,R){Gc("r",I,jt,r),Gc("s",T,jt,r),this.r=I,this.s=T,R!=null&&(this.recovery=R),Object.freeze(this)}static fromCompact(I){const T=i;return I=Mr("compactSignature",I,T*2),new E(m(I,0,T),m(I,T,2*T))}static fromDER(I){const{r:T,s:R}=ms.toSig(Mr("DER",I));return new E(T,R)}assertValidity(){}addRecoveryBit(I){return new E(this.r,this.s,I)}recoverPublicKey(I){const{r:T,s:R,recovery:k}=this,B=y(Mr("msgHash",I));if(k==null||![0,1,2,3].includes(k))throw new Error("recovery id invalid");const U=k===2||k===3?T+e.n:T;if(U>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const j=(k&1)===0?"02":"03",q=u.fromHex(j+Bm(U,n.BYTES)),F=l(U),V=c(-B*F),W=c(R*F),se=u.BASE.multiplyAndAddUnsafe(q,V,W);if(!se)throw new Error("point at infinify");return se.assertValidity(),se}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Ep(this.toDERHex())}toDERHex(){return ms.hexFromSig(this)}toCompactRawBytes(){return Ep(this.toCompactHex())}toCompactHex(){const I=i;return Bm(this.r,I)+Bm(this.s,I)}}const v={isValidPrivateKey(_){try{return d(_),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const _=r8(e.n);return hB(e.randomBytes(_),e.n)},precompute(_=8,I=u.BASE){return I._setWindowSize(_),I.multiply(BigInt(3)),I}};function S(_,I=!0){return u.fromPrivateKey(_).toRawBytes(I)}function $(_){if(typeof _=="bigint")return!1;if(_ instanceof u)return!0;const T=Mr("key",_).length,R=n.BYTES,k=R+1,B=2*R+1;if(!(e.allowedPrivateKeyLengths||i===k))return T===k||T===B}function A(_,I,T=!0){if($(_)===!0)throw new Error("first arg must be private key");if($(I)===!1)throw new Error("second arg must be public key");return u.fromHex(I).multiply(d(_)).toRawBytes(T)}const f=e.bits2int||function(_){if(_.length>8192)throw new Error("input is too large");const I=ua(_),T=_.length*8-s;return T>0?I>>BigInt(T):I},y=e.bits2int_modN||function(_){return c(f(_))},x=xp(s);function C(_){return Gc("num < 2^"+s,_,ws,x),Md(_,i)}function P(_,I,T=O){if(["recovered","canonical"].some(J=>J in T))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:k}=e;let{lowS:B,prehash:U,extraEntropy:j}=T;B==null&&(B=!0),_=Mr("msgHash",_),l8(T),U&&(_=Mr("prehashed msgHash",R(_)));const q=y(_),F=d(I),V=[C(F),C(q)];if(j!=null&&j!==!1){const J=j===!0?k(n.BYTES):j;V.push(Mr("extraEntropy",J))}const W=Cp(...V),se=q;function X(J){const Ce=f(J);if(!p(Ce))return;const Ee=l(Ce),pe=u.BASE.multiply(Ce).toAffine(),ve=c(pe.x);if(ve===ws)return;const Se=c(Ee*c(se+ve*F));if(Se===ws)return;let ot=(pe.x===ve?0:2)|Number(pe.y&jt),O1=Se;return B&&w(Se)&&(O1=g(Se),ot^=1),new E(ve,O1,ot)}return{seed:W,k2sig:X}}const O={lowS:e.lowS,prehash:!1},N={lowS:e.lowS,prehash:!1};function D(_,I,T=O){const{seed:R,k2sig:k}=P(_,I,T),B=e;return Tk(B.hash.outputLen,B.nByteLength,B.hmac)(R,k)}u.BASE._setWindowSize(8);function b(_,I,T,R=N){const k=_;I=Mr("msgHash",I),T=Mr("publicKey",T);const{lowS:B,prehash:U,format:j}=R;if(l8(R),"strict"in R)throw new Error("options.strict was renamed to lowS");if(j!==void 0&&j!=="compact"&&j!=="der")throw new Error("format must be compact or der");const q=typeof k=="string"||Dd(k),F=!q&&!j&&typeof k=="object"&&k!==null&&typeof k.r=="bigint"&&typeof k.s=="bigint";if(!q&&!F)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,W;try{if(F&&(V=new E(k.r,k.s)),q){try{j!=="compact"&&(V=E.fromDER(k))}catch(ot){if(!(ot instanceof ms.Err))throw ot}!V&&j!=="der"&&(V=E.fromCompact(k))}W=u.fromHex(T)}catch{return!1}if(!V||B&&V.hasHighS())return!1;U&&(I=e.hash(I));const{r:se,s:X}=V,J=y(I),Ce=l(X),Ee=c(J*Ce),pe=c(se*Ce),ve=u.BASE.multiplyAndAddUnsafe(W,Ee,pe)?.toAffine();return ve?c(ve.x)===se:!1}return{CURVE:e,getPublicKey:S,getSharedSecret:A,sign:D,verify:b,ProjectivePoint:u,Signature:E,utils:v}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function CB(t){return{hash:t,hmac:(e,...n)=>G6(t,e,SN(...n)),randomBytes:AN}}function xB(t,e){const n=r=>EB({...t,...CB(r)});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const u8=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),d8=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_B=BigInt(0),$B=BigInt(1),Lm=BigInt(2),h8=(t,e)=>(t+e/Lm)/e;function IB(t){const e=u8,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,d=jr(u,n,e)*u%e,h=jr(d,n,e)*u%e,p=jr(h,Lm,e)*l%e,w=jr(p,i,e)*p%e,g=jr(w,s,e)*w%e,m=jr(g,a,e)*g%e,E=jr(m,c,e)*m%e,v=jr(E,a,e)*g%e,S=jr(v,n,e)*u%e,$=jr(S,o,e)*w%e,A=jr($,r,e)*l%e,f=jr(A,Lm,e);if(!Um.eql(Um.sqr(f),t))throw new Error("Cannot find square root");return f}const Um=Pm(u8,void 0,void 0,{sqrt:IB}),SB=xB({a:_B,b:BigInt(7),Fp:Um,n:d8,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=d8,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-$B*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=h8(s*t,e),c=h8(-r*t,e);let l=qn(t-a*n-c*i,e),u=qn(-a*r-c*s,e);const d=l>o,h=u>o;if(d&&(l=e-l),h&&(u=e-u),l>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:d,k1:l,k2neg:h,k2:u}}}},R6),AB=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:SB},Symbol.toStringTag,{value:"Module"}));async function f8(t,{blockHash:e,blockNumber:n,blockTag:r,hash:i,index:s,sender:o,nonce:a}){const c=r||"latest",l=n!==void 0?Pe(n):void 0;let u=null;if(i?u=await t.request({method:"eth_getTransactionByHash",params:[i]},{dedupe:!0}):e?u=await t.request({method:"eth_getTransactionByBlockHashAndIndex",params:[e,Pe(s)]},{dedupe:!0}):typeof s=="number"?u=await t.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[l||c,Pe(s)]},{dedupe:!!l}):o&&typeof a=="number"&&(u=await t.request({method:"eth_getTransactionBySenderAndNonce",params:[o,Pe(a)]},{dedupe:!0})),!u)throw new X3({blockHash:e,blockNumber:n,blockTag:c,hash:i,index:s});return(t.chain?.formatters?.transaction?.format||_m)(u,"getTransaction")}async function Mm(t,{hash:e}){const n=await t.request({method:"eth_getTransactionReceipt",params:[e]},{dedupe:!0});if(!n)throw new Q3({hash:e});return(t.chain?.formatters?.transactionReceipt?.format||HR)(n,"getTransactionReceipt")}const Rp=new Map,jm=new Map;let PB=0;function Fm(t,e,n){const r=++PB,i=()=>Rp.get(t)||[],s=()=>{const d=i().filter(h=>h.id!==r);if(d.length===0){Rp.delete(t),jm.delete(t);return}Rp.set(t,d)},o=()=>{const u=i();if(!u.some(h=>h.id===r))return;const d=jm.get(t);if(u.length===1&&d){const h=d();h instanceof Promise&&h.catch(()=>{})}s()},a=i();if(Rp.set(t,[...a,{id:r,fns:e}]),a&&a.length>0)return o;const c={};for(const u in e)c[u]=((...d)=>{const h=i();if(h.length!==0)for(const p of h)p.fns[u]?.(...d)});const l=n(c);return typeof l=="function"&&jm.set(t,l),o}function OB(t,{emitOnBegin:e,initialWaitTime:n,interval:r}){let i=!0;const s=()=>i=!1;return(async()=>{let a;e&&(a=await t({unpoll:s}));const c=await n?.(a)??r;await Tp(c);const l=async()=>{i&&(await t({unpoll:s}),await Tp(r),l())};l()})(),s}function NB(t,{emitOnBegin:e=!1,emitMissed:n=!1,onBlockNumber:r,onError:i,poll:s,pollingInterval:o=t.pollingInterval}){const a=typeof s<"u"?s:!(t.transport.type==="webSocket"||t.transport.type==="ipc"||t.transport.type==="fallback"&&(t.transport.transports[0].config.type==="webSocket"||t.transport.transports[0].config.type==="ipc"));let c;return a?(()=>{const d=pr(["watchBlockNumber",t.uid,e,n,o]);return Fm(d,{onBlockNumber:r,onError:i},h=>OB(async()=>{try{const p=await dt(t,FR,"getBlockNumber")({cacheTime:0});if(c!==void 0){if(p===c)return;if(p-c>1&&n)for(let w=c+1n;w<p;w++)h.onBlockNumber(w,c),c=w}(c===void 0||p>c)&&(h.onBlockNumber(p,c),c=p)}catch(p){h.onError?.(p)}},{emitOnBegin:e,interval:o}))})():(()=>{const d=pr(["watchBlockNumber",t.uid,e,n]);return Fm(d,{onBlockNumber:r,onError:i},h=>{let p=!0,w=()=>p=!1;return(async()=>{try{const g=(()=>{if(t.transport.type==="fallback"){const E=t.transport.transports.find(v=>v.config.type==="webSocket"||v.config.type==="ipc");return E?E.value:t.transport}return t.transport})(),{unsubscribe:m}=await g.subscribe({params:["newHeads"],onData(E){if(!p)return;const v=Lc(E.result?.number);h.onBlockNumber(v,c),c=v},onError(E){h.onError?.(E)}});w=m,p||w()}catch(g){i?.(g)}})(),()=>w()})})()}async function TB(t,e){const{checkReplacement:n=!0,confirmations:r=1,hash:i,onReplaced:s,retryCount:o=6,retryDelay:a=({count:A})=>~~(1<<A)*200,timeout:c=18e4}=e,l=pr(["waitForTransactionReceipt",t.uid,i]),u=e.pollingInterval?e.pollingInterval:t.chain?.experimental_preconfirmationTime?t.chain.experimental_preconfirmationTime:t.pollingInterval;let d,h,p,w=!1,g,m;const{promise:E,resolve:v,reject:S}=m6(),$=c?setTimeout(()=>{m?.(),g?.(),S(new wk({hash:i}))},c):void 0;return g=Fm(l,{onReplaced:s,resolve:v,reject:S},async A=>{if(p=await dt(t,Mm,"getTransactionReceipt")({hash:i}).catch(()=>{}),p&&r<=1){clearTimeout($),A.resolve(p),g?.();return}m=dt(t,NB,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:u,async onBlockNumber(f){const y=C=>{clearTimeout($),m?.(),C(),g?.()};let x=f;if(!w)try{if(p){if(r>1&&(!p.blockNumber||x-p.blockNumber+1n<r))return;y(()=>A.resolve(p));return}if(n&&!d&&(w=!0,await kp(async()=>{d=await dt(t,f8,"getTransaction")({hash:i}),d.blockNumber&&(x=d.blockNumber)},{delay:a,retryCount:o}),w=!1),p=await dt(t,Mm,"getTransactionReceipt")({hash:i}),r>1&&(!p.blockNumber||x-p.blockNumber+1n<r))return;y(()=>A.resolve(p))}catch(C){if(C instanceof X3||C instanceof Q3){if(!d){w=!1;return}try{h=d,w=!0;const P=await kp(()=>dt(t,Zc,"getBlock")({blockNumber:x,includeTransactions:!0}),{delay:a,retryCount:o,shouldRetry:({error:D})=>D instanceof A6});w=!1;const O=P.transactions.find(({from:D,nonce:b})=>D===h.from&&b===h.nonce);if(!O||(p=await dt(t,Mm,"getTransactionReceipt")({hash:O.hash}),r>1&&(!p.blockNumber||x-p.blockNumber+1n<r)))return;let N="replaced";O.to===h.to&&O.value===h.value&&O.input===h.input?N="repriced":O.from===O.to&&O.value===0n&&(N="cancelled"),y(()=>{A.onReplaced?.({reason:N,replacedTransaction:h,transaction:O,transactionReceipt:p}),A.resolve(p)})}catch(P){y(()=>A.reject(P))}}else y(()=>A.reject(C))}}})}),E}class p8 extends ee{constructor({docsPath:e}={}){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(`
37
37
  `),{docsPath:e,docsSlug:"account",name:"AccountNotFoundError"})}}class zm extends ee{constructor({docsPath:e,metaMessages:n,type:r}){super(`Account type "${r}" is not supported.`,{docsPath:e,metaMessages:n,name:"AccountTypeNotSupportedError"})}}async function kB(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]},{retryCount:0})}const qm=new ud(128);async function RB(t,e){const{account:n=t.account,assertChainId:r=!0,chain:i=t.chain,accessList:s,authorizationList:o,blobs:a,data:c,dataSuffix:l=typeof t.dataSuffix=="string"?t.dataSuffix:t.dataSuffix?.value,gas:u,gasPrice:d,maxFeePerBlobGas:h,maxFeePerGas:p,maxPriorityFeePerGas:w,nonce:g,type:m,value:E,...v}=e;if(typeof n>"u")throw new p8({docsPath:"/docs/actions/wallet/sendTransaction"});const S=n?ai(n):null;let $;try{Fd(e);const A=await(async()=>{if(e.to)return e.to;if(e.to!==null&&o&&o.length>0)return await I6({authorization:o[0]}).catch(()=>{throw new ee("`to` is required. Could not infer from `authorizationList`.")})})();if(S?.type==="json-rpc"||S===null){let f;i!==null&&(f=await dt(t,Op,"getChainId")({}),r&&tB({currentChainId:f,chain:i}));const y=t.chain?.formatters?.transactionRequest?.format,C=(y||Pp)({...Ap(v,{format:y}),accessList:s,account:S,authorizationList:o,blobs:a,chainId:f,data:l?hs([c??"0x",l]):c,gas:u,gasPrice:d,maxFeePerBlobGas:h,maxFeePerGas:p,maxPriorityFeePerGas:w,nonce:g,to:A,type:m,value:E},"sendTransaction"),P=qm.get(t.uid),O=P?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:O,params:[C]},{retryCount:0})}catch(N){if(P===!1)throw N;const D=N;if(D.name==="InvalidInputRpcError"||D.name==="InvalidParamsRpcError"||D.name==="MethodNotFoundRpcError"||D.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[C]},{retryCount:0}).then(b=>(qm.set(t.uid,!0),b)).catch(b=>{const _=b;throw _.name==="MethodNotFoundRpcError"||_.name==="MethodNotSupportedRpcError"?(qm.set(t.uid,!1),D):_});throw D}}if(S?.type==="local"){if(S.nonceManager&&typeof g>"u"){const C=v.chainId,P=await(async()=>typeof C=="number"?C:i?i.id:dt(t,Op,"getChainId")({}))();$={address:S.address,chainId:P}}const f=await dt(t,z6,"prepareTransactionRequest")({account:S,accessList:s,authorizationList:o,blobs:a,chain:i,data:l?hs([c??"0x",l]):c,gas:u,gasPrice:d,maxFeePerBlobGas:h,maxFeePerGas:p,maxPriorityFeePerGas:w,nonce:g,nonceManager:S.nonceManager,parameters:[...j6,"sidecars"],type:m,value:E,...v,to:A}),y=i?.serializers?.transaction,x=await S.signTransaction(f,{serializer:y});return await dt(t,kB,"sendRawTransaction")({serializedTransaction:x})}throw S?.type==="smart"?new zm({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new zm({docsPath:"/docs/actions/wallet/sendTransaction",type:S?.type})}catch(A){throw A instanceof zm?A:($&&S?.nonceManager?.reset($),M6(A,{...e,account:S,chain:e.chain||void 0}))}}async function Bp(t,e){return Bp.internal(t,RB,"sendTransaction",e)}(function(t){async function e(n,r,i,s){const{abi:o,account:a=n.account,address:c,args:l,functionName:u,...d}=s;if(typeof a>"u")throw new p8({docsPath:"/docs/contract/writeContract"});const h=a?ai(a):null,p=X1({abi:o,args:l,functionName:u});try{return await dt(n,r,i)({data:p,to:c,account:h,...d})}catch(w){throw s6(w,{abi:o,address:c,args:l,docsPath:"/docs/contract/writeContract",functionName:u,sender:h?.address})}}t.internal=e})(Bp||(Bp={}));function zd(t,e,n){const r=t[e.name];if(typeof r=="function")return r;const i=t[n];return typeof i=="function"?i:s=>e(t,s)}const Dp="2.22.1",BB=()=>`@wagmi/core@${Dp}`;var g8=function(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)},Lp,m8;let go=class J5 extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return BB()}constructor(e,n={}){super(),Lp.add(this),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:"WagmiCoreError"});const r=n.cause instanceof J5?n.cause.details:n.cause?.message?n.cause.message:n.details,i=n.cause instanceof J5&&n.cause.docsPath||n.docsPath;this.message=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${this.docsBaseUrl}${i}.html${n.docsSlug?`#${n.docsSlug}`:""}`]:[],...r?[`Details: ${r}`]:[],`Version: ${this.version}`].join(`
38
- `),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=i,this.metaMessages=n.metaMessages,this.shortMessage=e}walk(e){return g8(this,Lp,"m",m8).call(this,this,e)}};Lp=new WeakSet,m8=function t(e,n){return n?.(e)?e:e.cause?g8(this,Lp,"m",t).call(this,e.cause,n):e};class qd extends go{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class DB extends go{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class LB extends go{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class UB extends go{constructor({address:e,connector:n}){super(`Account "${e}" not found for connector "${n.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class MB extends go{constructor({connectionChainId:e,connectorChainId:n}){super(`The current chain of the connector (id: ${n}) does not match the connection's chain (id: ${e}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class jB extends go{constructor({connector:e}){super(`Connector "${e.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function FB(t,e){let n;if(typeof e.connector=="function"?n=t._internal.connectors.setup(e.connector):n=e.connector,n.uid===t.state.current)throw new DB;try{t.setState(o=>({...o,status:"connecting"})),n.emitter.emit("message",{type:"connecting"});const{connector:r,...i}=e,s=await n.connect(i);return n.emitter.off("connect",t._internal.events.connect),n.emitter.on("change",t._internal.events.change),n.emitter.on("disconnect",t._internal.events.disconnect),await t.storage?.setItem("recentConnectorId",n.id),t.setState(o=>({...o,connections:new Map(o.connections).set(n.uid,{accounts:i.withCapabilities?s.accounts.map(a=>typeof a=="object"?a.address:a):s.accounts,chainId:s.chainId,connector:n}),current:n.uid,status:"connected"})),{accounts:i.withCapabilities?s.accounts.map(o=>typeof o=="object"?o:{address:o,capabilities:{}}):s.accounts,chainId:s.chainId}}catch(r){throw t.setState(i=>({...i,status:i.current?"connected":"disconnected"})),r}}const Hm=256;let Up=Hm,Mp;function w8(t=11){if(!Mp||Up+t>Hm*2){Mp="",Up=0;for(let e=0;e<Hm;e++)Mp+=(256+Math.random()*256|0).toString(16).substring(1)}return Mp.substring(Up,Up+++t)}function y8(t){const{batch:e,chain:n,ccipRead:r,dataSuffix:i,key:s="base",name:o="Base Client",type:a="base"}=t,c=t.experimental_blockTag??(typeof n?.experimental_preconfirmationTime=="number"?"pending":void 0),l=n?.blockTime??12e3,u=Math.min(Math.max(Math.floor(l/2),500),4e3),d=t.pollingInterval??u,h=t.cacheTime??d,p=t.account?ai(t.account):void 0,{config:w,request:g,value:m}=t.transport({account:p,chain:n,pollingInterval:d}),E={...w,...m},v={account:p,batch:e,cacheTime:h,ccipRead:r,chain:n,dataSuffix:i,key:s,name:o,pollingInterval:d,request:g,transport:E,type:a,uid:w8(),...c?{experimental_blockTag:c}:{}};function S($){return A=>{const f=A($);for(const x in v)delete f[x];const y={...$,...f};return Object.assign(y,{extend:S(y)})}}return Object.assign(v,{extend:S(v)})}function Wm({key:t,methods:e,name:n,request:r,retryCount:i=3,retryDelay:s=150,timeout:o,type:a},c){const l=w8();return{config:{key:t,methods:e,name:n,request:r,retryCount:i,retryDelay:s,timeout:o,type:a},request:VR(r,{methods:e,retryCount:i,retryDelay:s,uid:l}),value:c}}function zB(t,e={}){const{key:n="custom",methods:r,name:i="Custom Provider",retryDelay:s}=e;return({retryCount:o})=>Wm({key:n,methods:r,name:i,request:t.request.bind(t),retryCount:e.retryCount??o,retryDelay:s,type:"custom"})}function Vm(t,e={}){const{key:n="fallback",name:r="Fallback",rank:i=!1,shouldThrow:s=qB,retryCount:o,retryDelay:a}=e;return(({chain:c,pollingInterval:l=4e3,timeout:u,...d})=>{let h=t,p=()=>{};const w=Wm({key:n,name:r,async request({method:g,params:m}){let E;const v=async(S=0)=>{const $=h[S]({...d,chain:c,retryCount:0,timeout:u});try{const A=await $.request({method:g,params:m});return p({method:g,params:m,response:A,transport:$,status:"success"}),A}catch(A){if(p({error:A,method:g,params:m,transport:$,status:"error"}),s(A)||S===h.length-1||(E??=h.slice(S+1).some(f=>{const{include:y,exclude:x}=f({chain:c}).config.methods||{};return y?y.includes(g):x?!x.includes(g):!0}),!E))throw A;return v(S+1)}};return v()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:g=>p=g,transports:h.map(g=>g({chain:c,retryCount:0}))});if(i){const g=typeof i=="object"?i:{};HB({chain:c,interval:g.interval??l,onTransports:m=>h=m,ping:g.ping,sampleCount:g.sampleCount,timeout:g.timeout,transports:h,weights:g.weights})}return w})}function qB(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===Wc.code||t.code===Pt.code||t.code===Kc.code||da.nodeMessage.test(t.message)||t.code===5e3))}function HB({chain:t,interval:e=4e3,onTransports:n,ping:r,sampleCount:i=10,timeout:s=1e3,transports:o,weights:a={}}){const{stability:c=.7,latency:l=.3}=a,u=[],d=async()=>{const h=await Promise.all(o.map(async g=>{const m=g({chain:t,retryCount:0,timeout:s}),E=Date.now();let v,S;try{await(r?r({transport:m}):m.request({method:"net_listening"})),S=1}catch{S=0}finally{v=Date.now()}return{latency:v-E,success:S}}));u.push(h),u.length>i&&u.shift();const p=Math.max(...u.map(g=>Math.max(...g.map(({latency:m})=>m)))),w=o.map((g,m)=>{const E=u.map(f=>f[m].latency),S=1-E.reduce((f,y)=>f+y,0)/E.length/p,$=u.map(f=>f[m].success),A=$.reduce((f,y)=>f+y,0)/$.length;return A===0?[0,m]:[l*S+c*A,m]}).sort((g,m)=>m[0]-g[0]);n(w.map(([,g])=>o[g])),await Tp(e),d()};d()}class WB extends ee{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}let VB=0;const b8=new WeakMap;function KB(t){if(!t)return"default";const e=b8.get(t);if(e!==void 0)return e;const n=VB++;return b8.set(t,n),n}function fa(t,e={}){const{batch:n,fetchFn:r,fetchOptions:i,key:s="http",methods:o,name:a="HTTP JSON-RPC",onFetchRequest:c,onFetchResponse:l,retryDelay:u,raw:d}=e;return({chain:h,retryCount:p,timeout:w})=>{const{batchSize:g=1e3,wait:m=0}=typeof n=="object"?n:{},E=e.retryCount??p,v=w??e.timeout??1e4,S=t||h?.rpcUrls.default.http[0];if(!S)throw new WB;const $=rB(S,{fetchFn:r,fetchOptions:i,onRequest:c,onResponse:l,timeout:v});return Wm({key:s,methods:o,name:a,async request({method:A,params:f},y){const x={method:A,params:f},C=y?.signal?{signal:y.signal}:void 0,{schedule:P}=w6({id:`${S}.${KB(y?.signal)}`,wait:m,shouldSplitBatch(b){return b.length>g},fn:b=>$.request({body:b,fetchOptions:C}),sort:(b,_)=>b.id-_.id}),O=async b=>n?P(b):[await $.request({body:b,fetchOptions:C})],[{error:N,result:D}]=await O(x);if(d)return{error:N,result:D};if(N)throw new rm({body:x,error:N,url:S});return D},retryCount:E,retryDelay:u,timeout:v,type:"http"},{fetchOptions:i,url:S})}}async function GB(t,e={}){const{assertChainId:n=!0}=e;let r;if(e.connector){const{connector:u}=e;if(t.state.status==="reconnecting"&&!u.getAccounts&&!u.getChainId)throw new jB({connector:u});const[d,h]=await Promise.all([u.getAccounts().catch(p=>{if(e.account===null)return[];throw p}),u.getChainId()]);r={accounts:d,chainId:h,connector:u}}else r=t.state.connections.get(t.state.current);if(!r)throw new LB;const i=e.chainId??r.chainId,s=await r.connector.getChainId();if(n&&s!==i)throw new MB({connectionChainId:i,connectorChainId:s});const o=r.connector;if(o.getClient)return o.getClient({chainId:i});const a=ai(e.account??r.accounts[0]);if(a&&(a.address=co(a.address)),e.account&&!r.accounts.some(u=>u.toLowerCase()===a.address.toLowerCase()))throw new UB({address:a.address,connector:o});const c=t.chains.find(u=>u.id===i),l=await r.connector.getProvider({chainId:i});return y8({account:a,chain:c,name:"Connector Client",transport:u=>zB(l)({...u,retryCount:0})})}function ZB(t){const e=t.state.current,n=t.state.connections.get(e),r=n?.accounts,i=r?.[0],s=t.chains.find(a=>a.id===n?.chainId),o=t.state.status;switch(o){case"connected":return{address:i,addresses:r,chain:s,chainId:n?.chainId,connector:n?.connector,isConnected:!0,isConnecting:!1,isDisconnected:!1,isReconnecting:!1,status:o};case"reconnecting":return{address:i,addresses:r,chain:s,chainId:n?.chainId,connector:n?.connector,isConnected:!!i,isConnecting:!1,isDisconnected:!1,isReconnecting:!0,status:o};case"connecting":return{address:i,addresses:r,chain:s,chainId:n?.chainId,connector:n?.connector,isConnected:!1,isConnecting:!0,isDisconnected:!1,isReconnecting:!1,status:o};case"disconnected":return{address:void 0,addresses:void 0,chain:void 0,chainId:void 0,connector:void 0,isConnected:!1,isConnecting:!1,isDisconnected:!0,isReconnecting:!1,status:o}}}function v8(t,e){const{chainId:n,...r}=e,i=t.getClient({chainId:n});return zd(i,iR,"readContract")(r)}class mo extends go{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}class YB extends go{constructor({connector:e}){super(`"${e.name}" does not support programmatic chain switching.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SwitchChainNotSupportedError"})}}async function JB(t,e){const{addEthereumChainParameter:n,chainId:r}=e,i=t.state.connections.get(e.connector?.uid??t.state.current);if(i){const o=i.connector;if(!o.switchChain)throw new YB({connector:o});return await o.switchChain({addEthereumChainParameter:n,chainId:r})}const s=t.chains.find(o=>o.id===r);if(!s)throw new qd;return t.setState(o=>({...o,chainId:r})),s}async function E8(t,e){const{chainId:n,timeout:r=0,...i}=e,s=t.getClient({chainId:n}),a=await zd(s,TB,"waitForTransactionReceipt")({...i,timeout:r});if(a.status==="reverted"){const c=zd(s,f8,"getTransaction"),{from:l,...u}=await c({hash:a.transactionHash}),h=await zd(s,Cm,"call")({...u,account:l,data:u.input,gasPrice:u.type!=="eip1559"?u.gasPrice:void 0,maxFeePerGas:u.type==="eip1559"?u.maxFeePerGas:void 0,maxPriorityFeePerGas:u.type==="eip1559"?u.maxPriorityFeePerGas:void 0}),p=h?.data?cN(`0x${h.data.substring(138)}`):"unknown reason";throw new Error(p)}return{...a,chainId:s.chain.id}}async function C8(t,e){const{account:n,chainId:r,connector:i,...s}=e;let o;return typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await GB(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:i}),await zd(o,Bp,"writeContract")({...s,...n?{account:n}:{},chain:r?{id:r}:null})}function Hye(t){return t}jp.type="injected";function jp(t={}){const{shimDisconnect:e=!0,unstable_shimAsyncInject:n}=t;function r(){const c=t.target;if(typeof c=="function"){const l=c();if(l)return l}return typeof c=="object"?c:typeof c=="string"?{...XB[c]??{id:c,name:`${c[0].toUpperCase()}${c.slice(1)}`,provider:`is${c[0].toUpperCase()}${c.slice(1)}`}}:{id:"injected",name:"Injected",provider(l){return l?.ethereum}}}let i,s,o,a;return c=>({get icon(){return r().icon},get id(){return r().id},get name(){return r().name},get supportsSimulation(){return!0},type:jp.type,async setup(){const l=await this.getProvider();l?.on&&t.target&&(o||(o=this.onConnect.bind(this),l.on("connect",o)),i||(i=this.onAccountsChanged.bind(this),l.on("accountsChanged",i)))},async connect({chainId:l,isReconnecting:u,withCapabilities:d}={}){const h=await this.getProvider();if(!h)throw new mo;let p=[];if(u)p=await this.getAccounts().catch(()=>[]);else if(e)try{p=(await h.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0]?.caveats?.[0]?.value?.map(g=>co(g)),p.length>0&&(p=await this.getAccounts())}catch(w){const g=w;if(g.code===Pt.code)throw new Pt(g);if(g.code===uo.code)throw g}try{!p?.length&&!u&&(p=(await h.request({method:"eth_requestAccounts"})).map(m=>co(m))),o&&(h.removeListener("connect",o),o=void 0),i||(i=this.onAccountsChanged.bind(this),h.on("accountsChanged",i)),s||(s=this.onChainChanged.bind(this),h.on("chainChanged",s)),a||(a=this.onDisconnect.bind(this),h.on("disconnect",a));let w=await this.getChainId();return l&&w!==l&&(w=(await this.switchChain({chainId:l}).catch(m=>{if(m.code===Pt.code)throw m;return{id:w}}))?.id??w),e&&await c.storage?.removeItem(`${this.id}.disconnected`),t.target||await c.storage?.setItem("injected.connected",!0),{accounts:d?p.map(g=>({address:g,capabilities:{}})):p,chainId:w}}catch(w){const g=w;throw g.code===Pt.code?new Pt(g):g.code===uo.code?new uo(g):g}},async disconnect(){const l=await this.getProvider();if(!l)throw new mo;s&&(l.removeListener("chainChanged",s),s=void 0),a&&(l.removeListener("disconnect",a),a=void 0),o||(o=this.onConnect.bind(this),l.on("connect",o));try{await W6(()=>l.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}e&&await c.storage?.setItem(`${this.id}.disconnected`,!0),t.target||await c.storage?.removeItem("injected.connected")},async getAccounts(){const l=await this.getProvider();if(!l)throw new mo;return(await l.request({method:"eth_accounts"})).map(d=>co(d))},async getChainId(){const l=await this.getProvider();if(!l)throw new mo;const u=await l.request({method:"eth_chainId"});return Number(u)},async getProvider(){if(typeof window>"u")return;let l;const u=r();return typeof u.provider=="function"?l=u.provider(window):typeof u.provider=="string"?l=Fp(window,u.provider):l=u.provider,l&&!l.removeListener&&("off"in l&&typeof l.off=="function"?l.removeListener=l.off:l.removeListener=()=>{}),l},async isAuthorized(){try{if(e&&await c.storage?.getItem(`${this.id}.disconnected`)||!t.target&&!await c.storage?.getItem("injected.connected"))return!1;if(!await this.getProvider()){if(n!==void 0&&n!==!1){const h=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",h),!!await this.getProvider()),p=typeof n=="number"?n:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(g=>window.addEventListener("ethereum#initialized",()=>g(h()),{once:!0}))]:[],new Promise(g=>setTimeout(()=>g(h()),p))]))return!0}throw new mo}return!!(await kp(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:l,chainId:u}){const d=await this.getProvider();if(!d)throw new mo;const h=c.chains.find(w=>w.id===u);if(!h)throw new ho(new qd);const p=new Promise(w=>{const g=(m=>{"chainId"in m&&m.chainId===u&&(c.emitter.off("change",g),w())});c.emitter.on("change",g)});try{return await Promise.all([d.request({method:"wallet_switchEthereumChain",params:[{chainId:Pe(u)}]}).then(async()=>{await this.getChainId()===u&&c.emitter.emit("change",{chainId:u})}),p]),h}catch(w){const g=w;if(g.code===4902||g?.data?.originalError?.code===4902)try{const{default:m,...E}=h.blockExplorers??{};let v;l?.blockExplorerUrls?v=l.blockExplorerUrls:m&&(v=[m.url,...Object.values(E).map(A=>A.url)]);let S;l?.rpcUrls?.length?S=l.rpcUrls:S=[h.rpcUrls.default?.http[0]??""];const $={blockExplorerUrls:v,chainId:Pe(u),chainName:l?.chainName??h.name,iconUrls:l?.iconUrls,nativeCurrency:l?.nativeCurrency??h.nativeCurrency,rpcUrls:S};return await Promise.all([d.request({method:"wallet_addEthereumChain",params:[$]}).then(async()=>{if(await this.getChainId()===u)c.emitter.emit("change",{chainId:u});else throw new Pt(new Error("User rejected switch after adding network."))}),p]),h}catch(m){throw new Pt(m)}throw g.code===Pt.code?new Pt(g):new ho(g)}},async onAccountsChanged(l){if(l.length===0)this.onDisconnect();else if(c.emitter.listenerCount("connect")){const u=(await this.getChainId()).toString();this.onConnect({chainId:u}),e&&await c.storage?.removeItem(`${this.id}.disconnected`)}else c.emitter.emit("change",{accounts:l.map(u=>co(u))})},onChainChanged(l){const u=Number(l);c.emitter.emit("change",{chainId:u})},async onConnect(l){const u=await this.getAccounts();if(u.length===0)return;const d=Number(l.chainId);c.emitter.emit("connect",{accounts:u,chainId:d});const h=await this.getProvider();h&&(o&&(h.removeListener("connect",o),o=void 0),i||(i=this.onAccountsChanged.bind(this),h.on("accountsChanged",i)),s||(s=this.onChainChanged.bind(this),h.on("chainChanged",s)),a||(a=this.onDisconnect.bind(this),h.on("disconnect",a)))},async onDisconnect(l){const u=await this.getProvider();l&&l.code===1013&&u&&(await this.getAccounts()).length||(c.emitter.emit("disconnect"),u&&(s&&(u.removeListener("chainChanged",s),s=void 0),a&&(u.removeListener("disconnect",a),a=void 0),o||(o=this.onConnect.bind(this),u.on("connect",o))))}})}const XB={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(t){return t?.coinbaseWalletExtension?t.coinbaseWalletExtension:Fp(t,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(t){return Fp(t,e=>{if(!e.isMetaMask||e.isBraveWallet&&!e._events&&!e._state)return!1;const n=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPhantom","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const r of n)if(e[r])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(t){return t?.phantom?.ethereum?t.phantom?.ethereum:Fp(t,"isPhantom")}}};function Fp(t,e){function n(i){return typeof e=="function"?e(i):typeof e=="string"?i[e]:!0}const r=t.ethereum;if(r?.providers)return r.providers.find(i=>n(i));if(r&&n(r))return r}function QB(t){if(typeof window>"u")return;const e=n=>t(n.detail);return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new CustomEvent("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)}function eD(){const t=new Set;let e=[];const n=()=>QB(i=>{e.some(({info:s})=>s.uuid===i.info.uuid)||(e=[...e,i],t.forEach(s=>s(e,{added:[i]})))});let r=n();return{_listeners(){return t},clear(){t.forEach(i=>i([],{removed:[...e]})),e=[]},destroy(){this.clear(),t.clear(),r?.()},findProvider({rdns:i}){return e.find(s=>s.info.rdns===i)},getProviders(){return e},reset(){this.clear(),r?.(),r=n()},subscribe(i,{emitImmediately:s}={}){return t.add(i),s&&i(e,{added:e}),()=>t.delete(i)}}}const tD=t=>(e,n,r)=>{const i=r.subscribe;return r.subscribe=(o,a,c)=>{let l=o;if(a){const u=c?.equalityFn||Object.is;let d=o(r.getState());l=h=>{const p=o(h);if(!u(d,p)){const w=d;a(d=p,w)}},c?.fireImmediately&&a(d,d)}return i(l)},t(e,n,r)};function nD(t,e){let n;try{n=t()}catch{return}return{getItem:i=>{var s;const o=c=>c===null?null:JSON.parse(c,void 0),a=(s=n.getItem(i))!=null?s:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const Km=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then(r){return Km(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Km(r)(n)}}}},rD=(t,e)=>(n,r,i)=>{let s={storage:nD(()=>localStorage),partialize:g=>g,version:0,merge:(g,m)=>({...m,...g}),...e},o=!1;const a=new Set,c=new Set;let l=s.storage;if(!l)return t((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...g)},r,i);const u=()=>{const g=s.partialize({...r()});return l.setItem(s.name,{state:g,version:s.version})},d=i.setState;i.setState=(g,m)=>{d(g,m),u()};const h=t((...g)=>{n(...g),u()},r,i);i.getInitialState=()=>h;let p;const w=()=>{var g,m;if(!l)return;o=!1,a.forEach(v=>{var S;return v((S=r())!=null?S:h)});const E=((m=s.onRehydrateStorage)==null?void 0:m.call(s,(g=r())!=null?g:h))||void 0;return Km(l.getItem.bind(l))(s.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==s.version){if(s.migrate)return[!0,s.migrate(v.state,v.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,v.state];return[!1,void 0]}).then(v=>{var S;const[$,A]=v;if(p=s.merge(A,(S=r())!=null?S:h),n(p,!0),$)return u()}).then(()=>{E?.(p,void 0),p=r(),o=!0,c.forEach(v=>v(p))}).catch(v=>{E?.(void 0,v)})};return i.persist={setOptions:g=>{s={...s,...g},g.storage&&(l=g.storage)},clearStorage:()=>{l?.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>w(),hasHydrated:()=>o,onHydrate:g=>(a.add(g),()=>{a.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},s.skipHydration||w(),p||h},x8=t=>{let e;const n=new Set,r=(l,u)=>{const d=typeof l=="function"?l(e):l;if(!Object.is(d,e)){const h=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(p=>p(e,h))}},i=()=>e,a={setState:r,getState:i,getInitialState:()=>c,subscribe:l=>(n.add(l),()=>n.delete(l))},c=e=t(r,i,a);return a},Gm=t=>t?x8(t):x8;var Di=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function iD(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var Zm={exports:{}},_8;function sD(){return _8||(_8=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,l,u){this.fn=c,this.context=l,this.once=u||!1}function s(c,l,u,d,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new i(u,d||c,h),w=n?n+l:l;return c._events[w]?c._events[w].fn?c._events[w]=[c._events[w],p]:c._events[w].push(p):(c._events[w]=p,c._eventsCount++),c}function o(c,l){--c._eventsCount===0?c._events=new r:delete c._events[l]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],u,d;if(this._eventsCount===0)return l;for(d in u=this._events)e.call(u,d)&&l.push(n?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},a.prototype.listeners=function(l){var u=n?n+l:l,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,p=d.length,w=new Array(p);h<p;h++)w[h]=d[h].fn;return w},a.prototype.listenerCount=function(l){var u=n?n+l:l,d=this._events[u];return d?d.fn?1:d.length:0},a.prototype.emit=function(l,u,d,h,p,w){var g=n?n+l:l;if(!this._events[g])return!1;var m=this._events[g],E=arguments.length,v,S;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),E){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,u),!0;case 3:return m.fn.call(m.context,u,d),!0;case 4:return m.fn.call(m.context,u,d,h),!0;case 5:return m.fn.call(m.context,u,d,h,p),!0;case 6:return m.fn.call(m.context,u,d,h,p,w),!0}for(S=1,v=new Array(E-1);S<E;S++)v[S-1]=arguments[S];m.fn.apply(m.context,v)}else{var $=m.length,A;for(S=0;S<$;S++)switch(m[S].once&&this.removeListener(l,m[S].fn,void 0,!0),E){case 1:m[S].fn.call(m[S].context);break;case 2:m[S].fn.call(m[S].context,u);break;case 3:m[S].fn.call(m[S].context,u,d);break;case 4:m[S].fn.call(m[S].context,u,d,h);break;default:if(!v)for(A=1,v=new Array(E-1);A<E;A++)v[A-1]=arguments[A];m[S].fn.apply(m[S].context,v)}}return!0},a.prototype.on=function(l,u,d){return s(this,l,u,d,!1)},a.prototype.once=function(l,u,d){return s(this,l,u,d,!0)},a.prototype.removeListener=function(l,u,d,h){var p=n?n+l:l;if(!this._events[p])return this;if(!u)return o(this,p),this;var w=this._events[p];if(w.fn)w.fn===u&&(!h||w.once)&&(!d||w.context===d)&&o(this,p);else{for(var g=0,m=[],E=w.length;g<E;g++)(w[g].fn!==u||h&&!w[g].once||d&&w[g].context!==d)&&m.push(w[g]);m.length?this._events[p]=m.length===1?m[0]:m:o(this,p)}return this},a.prototype.removeAllListeners=function(l){var u;return l?(u=n?n+l:l,this._events[u]&&o(this,u)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a})(Zm)),Zm.exports}var oD=sD();const aD=wo(oD);class cD{constructor(e){Object.defineProperty(this,"uid",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_emitter",{enumerable:!0,configurable:!0,writable:!0,value:new aD})}on(e,n){this._emitter.on(e,n)}once(e,n){this._emitter.once(e,n)}off(e,n){this._emitter.off(e,n)}emit(e,...n){const r=n[0];this._emitter.emit(e,{uid:this.uid,...r})}listenerCount(e){return this._emitter.listenerCount(e)}}function lD(t){return new cD(t)}function uD(t,e){return JSON.parse(t,(n,r)=>{let i=r;return i?.__type==="bigint"&&(i=BigInt(i.value)),i?.__type==="Map"&&(i=new Map(i.value)),e?.(n,i)??i})}function $8(t,e){return t.slice(0,e).join(".")||"."}function I8(t,e){const{length:n}=t;for(let r=0;r<n;++r)if(t[r]===e)return r+1;return 0}function dD(t,e){const n=typeof t=="function",r=typeof e=="function",i=[],s=[];return function(a,c){if(typeof c=="object")if(i.length){const l=I8(i,this);l===0?i[i.length]=this:(i.splice(l),s.splice(l)),s[s.length]=a;const u=I8(i,c);if(u!==0)return r?e.call(this,a,c,$8(s,u)):`[ref=${$8(s,u)}]`}else i[0]=c,s[0]=a;return n?t.call(this,a,c):c}}function hD(t,e,n,r){return JSON.stringify(t,dD((i,s)=>{let o=s;return typeof o=="bigint"&&(o={__type:"bigint",value:s.toString()}),o instanceof Map&&(o={__type:"Map",value:Array.from(s.entries())}),e?.(i,o)??o},r),n??void 0)}function fD(t){const{deserialize:e=uD,key:n="wagmi",serialize:r=hD,storage:i=S8}=t;function s(o){return o instanceof Promise?o.then(a=>a).catch(()=>null):o}return{...i,key:n,async getItem(o,a){const c=i.getItem(`${n}.${o}`),l=await s(c);return l?e(l)??null:a??null},async setItem(o,a){const c=`${n}.${o}`;a===null?await s(i.removeItem(c)):await s(i.setItem(c,r(a)))},async removeItem(o){await s(i.removeItem(`${n}.${o}`))}}}const S8={getItem:()=>null,setItem:()=>{},removeItem:()=>{}};function pD(){const t=typeof window<"u"&&window.localStorage?window.localStorage:S8;return{getItem(e){return t.getItem(e)},removeItem(e){t.removeItem(e)},setItem(e,n){try{t.setItem(e,n)}catch{}}}}const Ym=256;let zp=Ym,qp;function gD(t=11){if(!qp||zp+t>Ym*2){qp="",zp=0;for(let e=0;e<Ym;e++)qp+=(256+Math.random()*256|0).toString(16).substring(1)}return qp.substring(zp,zp+++t)}function mD(t){const{multiInjectedProviderDiscovery:e=!0,storage:n=fD({storage:pD()}),syncConnectedChain:r=!0,ssr:i=!1,...s}=t,o=typeof window<"u"&&e?eD():void 0,a=Gm(()=>s.chains),c=Gm(()=>{const A=[],f=new Set;for(const y of s.connectors??[]){const x=l(y);if(A.push(x),!i&&x.rdns){const C=typeof x.rdns=="string"?[x.rdns]:x.rdns;for(const P of C)f.add(P)}}if(!i&&o){const y=o.getProviders();for(const x of y)f.has(x.info.rdns)||A.push(l(u(x)))}return A});function l(A){const f=lD(gD()),y={...A({emitter:f,chains:a.getState(),storage:n,transports:s.transports}),emitter:f,uid:f.uid};return f.on("connect",S),y.setup?.(),y}function u(A){const{info:f}=A,y=A.provider;return jp({target:{...f,id:f.rdns,provider:y}})}const d=new Map;function h(A={}){const f=A.chainId??m.getState().chainId,y=a.getState().find(C=>C.id===f);if(A.chainId&&!y)throw new qd;{const C=d.get(m.getState().chainId);if(C&&!y)return C;if(!y)throw new qd}{const C=d.get(f);if(C)return C}let x;if(s.client)x=s.client({chain:y});else{const C=y.id,P=a.getState().map(D=>D.id),O={},N=Object.entries(s);for(const[D,b]of N)if(!(D==="chains"||D==="client"||D==="connectors"||D==="transports"))if(typeof b=="object")if(C in b)O[D]=b[C];else{if(P.some(I=>I in b))continue;O[D]=b}else O[D]=b;x=y8({...O,chain:y,batch:O.batch??{multicall:!0},transport:D=>s.transports[C]({...D,connectors:c})})}return d.set(f,x),x}function p(){return{chainId:a.getState()[0].id,connections:new Map,current:null,status:"disconnected"}}let w;const g="0.0.0-canary-";Dp.startsWith(g)?w=Number.parseInt(Dp.replace(g,""),10):w=Number.parseInt(Dp.split(".")[0]??"0",10);const m=Gm(tD(n?rD(p,{migrate(A,f){if(f===w)return A;const y=p(),x=E(A,y.chainId);return{...y,chainId:x}},name:"store",partialize(A){return{connections:{__type:"Map",value:Array.from(A.connections.entries()).map(([f,y])=>{const{id:x,name:C,type:P,uid:O}=y.connector;return[f,{...y,connector:{id:x,name:C,type:P,uid:O}}]})},chainId:A.chainId,current:A.current}},merge(A,f){typeof A=="object"&&A&&"status"in A&&delete A.status;const y=E(A,f.chainId);return{...f,...A,chainId:y}},skipHydration:i,storage:n,version:w}):p));m.setState(p());function E(A,f){return A&&typeof A=="object"&&"chainId"in A&&typeof A.chainId=="number"&&a.getState().some(y=>y.id===A.chainId)?A.chainId:f}r&&m.subscribe(({connections:A,current:f})=>f?A.get(f)?.chainId:void 0,A=>{if(a.getState().some(y=>y.id===A))return m.setState(y=>({...y,chainId:A??y.chainId}))}),o?.subscribe(A=>{const f=new Set,y=new Set;for(const C of c.getState())if(f.add(C.id),C.rdns){const P=typeof C.rdns=="string"?[C.rdns]:C.rdns;for(const O of P)y.add(O)}const x=[];for(const C of A){if(y.has(C.info.rdns))continue;const P=l(u(C));f.has(P.id)||x.push(P)}n&&!m.persist.hasHydrated()||c.setState(C=>[...C,...x],!0)});function v(A){m.setState(f=>{const y=f.connections.get(A.uid);return y?{...f,connections:new Map(f.connections).set(A.uid,{accounts:A.accounts??y.accounts,chainId:A.chainId??y.chainId,connector:y.connector})}:f})}function S(A){m.getState().status==="connecting"||m.getState().status==="reconnecting"||m.setState(f=>{const y=c.getState().find(x=>x.uid===A.uid);return y?(y.emitter.listenerCount("connect")&&y.emitter.off("connect",v),y.emitter.listenerCount("change")||y.emitter.on("change",v),y.emitter.listenerCount("disconnect")||y.emitter.on("disconnect",$),{...f,connections:new Map(f.connections).set(A.uid,{accounts:A.accounts,chainId:A.chainId,connector:y}),current:A.uid,status:"connected"}):f})}function $(A){m.setState(f=>{const y=f.connections.get(A.uid);if(y){const C=y.connector;C.emitter.listenerCount("change")&&y.connector.emitter.off("change",v),C.emitter.listenerCount("disconnect")&&y.connector.emitter.off("disconnect",$),C.emitter.listenerCount("connect")||y.connector.emitter.on("connect",S)}if(f.connections.delete(A.uid),f.connections.size===0)return{...f,connections:new Map,current:null,status:"disconnected"};const x=f.connections.values().next().value;return{...f,connections:new Map(f.connections),current:x.connector.uid}})}return{get chains(){return a.getState()},get connectors(){return c.getState()},storage:n,getClient:h,get state(){return m.getState()},setState(A){let f;typeof A=="function"?f=A(m.getState()):f=A;const y=p();typeof f!="object"&&(f=y),Object.keys(y).some(C=>!(C in f))&&(f=y),m.setState(f,!0)},subscribe(A,f,y){return m.subscribe(A,f,y?{...y,fireImmediately:y.emitImmediately}:void 0)},_internal:{mipd:o,async revalidate(){const A=m.getState(),f=A.connections;let y=A.current;for(const[,x]of f){const C=x.connector;C.isAuthorized&&await C.isAuthorized()||(f.delete(C.uid),y===C.uid&&(y=null))}m.setState(x=>({...x,connections:f,current:y}))},store:m,ssr:!!i,syncConnectedChain:r,transports:s.transports,chains:{setState(A){const f=typeof A=="function"?A(a.getState()):A;if(f.length!==0)return a.setState(f,!0)},subscribe(A){return a.subscribe(A)}},connectors:{providerDetailToConnector:u,setup:l,setState(A){return c.setState(typeof A=="function"?A(c.getState()):A,!0)},subscribe(A){return c.subscribe(A)}},events:{change:v,connect:S,disconnect:$}}}}function Jm(t,e){return Vm(t,e)}function wD(t){const{chain:e}=t,n=e.rpcUrls.default.http[0];if(!t.transports)return[n];const r=t.transports?.[e.id]?.({chain:e});return(r?.value?.transports||[r]).map(({value:s})=>s?.url||n)}const Hp=Sm({id:56,name:"BNB Smart Chain",blockTime:750,nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://56.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com",apiUrl:"https://api.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15921452}}}),Wp=Sm({id:97,name:"BNB Smart Chain Testnet",nativeCurrency:{decimals:18,name:"BNB",symbol:"tBNB"},rpcUrls:{default:{http:["https://data-seed-prebsc-1-s1.bnbchain.org:8545"]}},blockExplorers:{default:{name:"BscScan",url:"https://testnet.bscscan.com",apiUrl:"https://api-testnet.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:17422483}},testnet:!0}),Vp=Sm({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}});Hp.id+"",Vp.id+"",Wp.id+"";const yD={bsc:t=>`https://bscscan.com/tx/${t}`,ethereum:t=>`https://etherscan.io/tx/${t}`,"bsc-testnet":t=>`https://testnet.bscscan.com/tx/${t}`};function A8(t){return t==="bsc"||t==="ethereum"||t==="bsc-testnet"}function bD(t,e){return yD[t](e)}const vD="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";function P8(t){return t.toLowerCase()===vD.toLowerCase()}var ED=[{type:"constructor",inputs:[{name:"_governance",type:"address",internalType:"address"},{name:"_initialTokens",type:"address[]",internalType:"address[]"},{name:"_initialRecipients",type:"address[]",internalType:"address[]"},{name:"_initialFeeRate",type:"uint256",internalType:"uint256"}],stateMutability:"nonpayable"},{type:"function",name:"BASIS_POINTS_DENOMINATOR",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"DOMAIN_SEPARATOR",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"FEE_RATE_HARD_LIMIT",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"MAX_FEE_RECIPIENTS",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"NATIVE_TOKEN",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"ORDER_TYPEHASH",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"TIMELOCK_DELAY",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"acceptGovernance",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"addFeeRecipient",inputs:[{name:"recipient",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"addToken",inputs:[{name:"token",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"allowedTokens",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"calculateFee",inputs:[{name:"amount",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"cancelPendingChange",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"currentFeeRate",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"eip712Domain",inputs:[],outputs:[{name:"fields",type:"bytes1",internalType:"bytes1"},{name:"name",type:"string",internalType:"string"},{name:"version",type:"string",internalType:"string"},{name:"chainId",type:"uint256",internalType:"uint256"},{name:"verifyingContract",type:"address",internalType:"address"},{name:"salt",type:"bytes32",internalType:"bytes32"},{name:"extensions",type:"uint256[]",internalType:"uint256[]"}],stateMutability:"view"},{type:"function",name:"executeFeeChange",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"feeRecipients",inputs:[{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"feeRecipientsLength",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getFeeRecipients",inputs:[],outputs:[{name:"",type:"address[]",internalType:"address[]"}],stateMutability:"view"},{type:"function",name:"getOrder",inputs:[{name:"merchant",type:"address",internalType:"address"},{name:"orderId",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"tuple",internalType:"struct BeamPayRouter.OrderRecord",components:[{name:"payer",type:"address",internalType:"address"},{name:"createdAt",type:"uint64",internalType:"uint64"},{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"refunded",type:"uint256",internalType:"uint256"},{name:"receiver",type:"address",internalType:"address"},{name:"signer",type:"address",internalType:"address"},{name:"expiresAt",type:"uint64",internalType:"uint64"}]}],stateMutability:"view"},{type:"function",name:"governance",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"isFeeRecipient",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"merchantReceiver",inputs:[{name:"merchant",type:"address",internalType:"address"}],outputs:[{name:"receiver",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"merchantSigner",inputs:[{name:"merchant",type:"address",internalType:"address"}],outputs:[{name:"signer",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"orders",inputs:[{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"payer",type:"address",internalType:"address"},{name:"createdAt",type:"uint64",internalType:"uint64"},{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"refunded",type:"uint256",internalType:"uint256"},{name:"receiver",type:"address",internalType:"address"},{name:"signer",type:"address",internalType:"address"},{name:"expiresAt",type:"uint64",internalType:"uint64"}],stateMutability:"view"},{type:"function",name:"pay",inputs:[{name:"merchant",type:"address",internalType:"address"},{name:"receiver",type:"address",internalType:"address"},{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"orderId",type:"bytes32",internalType:"bytes32"},{name:"signer",type:"address",internalType:"address"},{name:"createdAt",type:"uint64",internalType:"uint64"},{name:"expiresAt",type:"uint64",internalType:"uint64"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"function",name:"pending",inputs:[],outputs:[{name:"newRate",type:"uint256",internalType:"uint256"},{name:"effectiveTime",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingGovernance",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"proposeFeeChange",inputs:[{name:"newRate",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"refund",inputs:[{name:"orderId",type:"bytes32",internalType:"bytes32"},{name:"amount",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"payable"},{type:"function",name:"removeFeeRecipient",inputs:[{name:"index",type:"uint256",internalType:"uint256"},{name:"expectedAddress",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"renounceGovernance",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setReceiver",inputs:[{name:"newReceiver",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setSigner",inputs:[{name:"newSigner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferGovernance",inputs:[{name:"newGov",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"EIP712DomainChanged",inputs:[],anonymous:!1},{type:"event",name:"FeeChangeCancelled",inputs:[],anonymous:!1},{type:"event",name:"FeeChangeExecuted",inputs:[{name:"newRate",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"FeeChangeProposed",inputs:[{name:"newRate",type:"uint256",indexed:!1,internalType:"uint256"},{name:"effectiveTime",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"FeeRecipientAdded",inputs:[{name:"recipient",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"FeeRecipientRemoved",inputs:[{name:"index",type:"uint256",indexed:!1,internalType:"uint256"},{name:"recipient",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"FeeRedirectedToMerchant",inputs:[{name:"orderId",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"fee",type:"uint256",indexed:!1,internalType:"uint256"},{name:"feeRecipient",type:"address",indexed:!0,internalType:"address"},{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"receiver",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"FeeTransferFailed",inputs:[{name:"orderId",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"fee",type:"uint256",indexed:!1,internalType:"uint256"},{name:"feeRecipient",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"GovernanceTransferStarted",inputs:[{name:"oldGov",type:"address",indexed:!0,internalType:"address"},{name:"pendingGov",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"GovernanceTransferred",inputs:[{name:"oldGov",type:"address",indexed:!0,internalType:"address"},{name:"newGov",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Initialized",inputs:[{name:"governance",type:"address",indexed:!1,internalType:"address"},{name:"feeRate",type:"uint256",indexed:!1,internalType:"uint256"},{name:"timelockDelay",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"Paid",inputs:[{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"orderId",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"payer",type:"address",indexed:!0,internalType:"address"},{name:"receiver",type:"address",indexed:!1,internalType:"address"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"fee",type:"uint256",indexed:!1,internalType:"uint256"},{name:"feeRecipient",type:"address",indexed:!1,internalType:"address"},{name:"feeCollected",type:"bool",indexed:!1,internalType:"bool"},{name:"timestamp",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"ReceiverUpdated",inputs:[{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"oldReceiver",type:"address",indexed:!0,internalType:"address"},{name:"newReceiver",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Refunded",inputs:[{name:"orderId",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"payer",type:"address",indexed:!0,internalType:"address"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"timestamp",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"SignerUpdated",inputs:[{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"oldSigner",type:"address",indexed:!0,internalType:"address"},{name:"newSigner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"TokenAdded",inputs:[{name:"token",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AddressMismatch",inputs:[]},{type:"error",name:"AlreadyAllowed",inputs:[]},{type:"error",name:"AlreadyFeeRecipient",inputs:[]},{type:"error",name:"AmountTooSmall",inputs:[]},{type:"error",name:"DuplicateOrder",inputs:[]},{type:"error",name:"ECDSAInvalidSignature",inputs:[]},{type:"error",name:"ECDSAInvalidSignatureLength",inputs:[{name:"length",type:"uint256",internalType:"uint256"}]},{type:"error",name:"ECDSAInvalidSignatureS",inputs:[{name:"s",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"IncorrectNativeValue",inputs:[]},{type:"error",name:"InvalidExpiry",inputs:[]},{type:"error",name:"InvalidShortString",inputs:[]},{type:"error",name:"InvalidSignature",inputs:[]},{type:"error",name:"MustKeepAtLeastOne",inputs:[]},{type:"error",name:"NativeTransferFailed",inputs:[]},{type:"error",name:"NoPending",inputs:[]},{type:"error",name:"NotAFeeRecipient",inputs:[]},{type:"error",name:"NotGovernance",inputs:[]},{type:"error",name:"NotPendingGovernance",inputs:[]},{type:"error",name:"OrderExpired",inputs:[]},{type:"error",name:"OrderNotPaid",inputs:[]},{type:"error",name:"RateExceedsHardLimit",inputs:[]},{type:"error",name:"Reentrant",inputs:[]},{type:"error",name:"RefundExceedsOrder",inputs:[]},{type:"error",name:"SafeERC20Failed",inputs:[]},{type:"error",name:"StringTooLong",inputs:[{name:"str",type:"string",internalType:"string"}]},{type:"error",name:"TimelockNotExpired",inputs:[]},{type:"error",name:"TokenNotAllowed",inputs:[]},{type:"error",name:"TooManyRecipients",inputs:[]},{type:"error",name:"UnauthorizedSigner",inputs:[]},{type:"error",name:"UnexpectedNativeValue",inputs:[]},{type:"error",name:"ZeroAddress",inputs:[]},{type:"error",name:"ZeroAmount",inputs:[]},{type:"error",name:"ZeroOrderId",inputs:[]}],O8=ED,CD={bsc:"0xBEA93fceFb115b22a3D6c714Ee815B359e2AAbaa",ethereum:"0xBEA93fceFb115b22a3D6c714Ee815B359e2AAbaa","bsc-testnet":"0xBEA93fceFb115b22a3D6c714Ee815B359e2AAbaa"};const N8="0x0000000000000000000000000000000000000000";function Kp(t){const e=CD[t];if(!e||e===N8)throw new Error(`BeamPayRouter address for ${t} is not configured`);return e}const T8=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]}];function xD(t,e){const n=BigInt(e.amount),r=P8(e.token);return{address:Kp(t),abi:O8,functionName:"pay",args:[e.merchant,e.receiver,e.token,n,e.orderId,e.signer,BigInt(e.createdAt),BigInt(e.expiresAt),e.signature],value:r?n:0n}}function _D(t,e,n){return{address:e,abi:T8,functionName:"approve",args:[Kp(t),n]}}async function $D(t,e,n,r){return await v8(t,{address:n,abi:T8,functionName:"allowance",args:[r,Kp(e)]})}async function k8(t,e,n,r){return(await v8(t,{address:Kp(e),abi:O8,functionName:"getOrder",args:[n,r]})).payer}function R8(t){return t.toLowerCase()!==N8}Xm.type="walletConnect";function Xm(t){const e=t.isNewChainsStale??!0;let n,r;const i="eip155";let s,o,a,c,l,u;return d=>({id:"walletConnect",name:"WalletConnect",type:Xm.type,async setup(){const h=await this.getProvider().catch(()=>null);h&&(a||(a=this.onConnect.bind(this),h.on("connect",a)),l||(l=this.onSessionDelete.bind(this),h.on("session_delete",l)))},async connect({chainId:h,withCapabilities:p,...w}={}){try{const g=await this.getProvider();if(!g)throw new mo;c||(c=this.onDisplayUri,g.on("display_uri",c));let m=h;if(!m){const $=await d.storage?.getItem("state")??{};d.chains.some(f=>f.id===$.chainId)?m=$.chainId:m=d.chains[0]?.id}if(!m)throw new Error("No chains found on connector.");const E=await this.isChainsStale();if(g.session&&E&&await g.disconnect(),!g.session||E){const $=d.chains.filter(A=>A.id!==m).map(A=>A.id);await g.connect({optionalChains:[m,...$],..."pairingTopic"in w?{pairingTopic:w.pairingTopic}:{}}),this.setRequestedChainsIds(d.chains.map(A=>A.id))}const v=(await g.enable()).map($=>co($));let S=await this.getChainId();return h&&S!==h&&(S=(await this.switchChain({chainId:h}).catch(A=>{if(A.code===Pt.code&&A.cause?.message!=="Missing or invalid. request() method: wallet_addEthereumChain")throw A;return{id:S}}))?.id??S),c&&(g.removeListener("display_uri",c),c=void 0),a&&(g.removeListener("connect",a),a=void 0),s||(s=this.onAccountsChanged.bind(this),g.on("accountsChanged",s)),o||(o=this.onChainChanged.bind(this),g.on("chainChanged",o)),u||(u=this.onDisconnect.bind(this),g.on("disconnect",u)),l||(l=this.onSessionDelete.bind(this),g.on("session_delete",l)),{accounts:p?v.map($=>({address:$,capabilities:{}})):v,chainId:S}}catch(g){throw/(user rejected|connection request reset)/i.test(g?.message)?new Pt(g):g}},async disconnect(){const h=await this.getProvider();try{await h?.disconnect()}catch(p){if(!/No matching key/i.test(p.message))throw p}finally{o&&(h?.removeListener("chainChanged",o),o=void 0),u&&(h?.removeListener("disconnect",u),u=void 0),a||(a=this.onConnect.bind(this),h?.on("connect",a)),s&&(h?.removeListener("accountsChanged",s),s=void 0),l&&(h?.removeListener("session_delete",l),l=void 0),this.setRequestedChainsIds([])}},async getAccounts(){return(await this.getProvider()).accounts.map(p=>co(p))},async getProvider({chainId:h}={}){async function p(){const w=d.chains.map(m=>m.id);if(!w.length)return;const{EthereumProvider:g}=await Promise.resolve().then(()=>Wee);return await g.init({...t,disableProviderPing:!0,optionalChains:w,projectId:t.projectId,rpcMap:Object.fromEntries(d.chains.map(m=>{const[E]=wD({chain:m,transports:d.transports});return[m.id,E]})),showQrModal:t.showQrModal??!0})}return n||(r||(r=p()),n=await r,n?.events.setMaxListeners(Number.POSITIVE_INFINITY)),h&&await this.switchChain?.({chainId:h}),n},async getChainId(){return(await this.getProvider()).chainId},async isAuthorized(){try{const[h,p]=await Promise.all([this.getAccounts(),this.getProvider()]);return h.length?await this.isChainsStale()&&p.session?(await p.disconnect().catch(()=>{}),!1):!0:!1}catch{return!1}},async switchChain({addEthereumChainParameter:h,chainId:p}){const w=await this.getProvider();if(!w)throw new mo;const g=d.chains.find(m=>m.id===p);if(!g)throw new ho(new qd);try{await Promise.all([new Promise(E=>{const v=({chainId:S})=>{S===p&&(d.emitter.off("change",v),E())};d.emitter.on("change",v)}),w.request({method:"wallet_switchEthereumChain",params:[{chainId:Pe(p)}]})]);const m=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...m,p]),g}catch(m){const E=m;if(/(user rejected)/i.test(E.message))throw new Pt(E);try{let v;h?.blockExplorerUrls?v=h.blockExplorerUrls:v=g.blockExplorers?.default.url?[g.blockExplorers?.default.url]:[];let S;h?.rpcUrls?.length?S=h.rpcUrls:S=[...g.rpcUrls.default.http];const $={blockExplorerUrls:v,chainId:Pe(p),chainName:h?.chainName??g.name,iconUrls:h?.iconUrls,nativeCurrency:h?.nativeCurrency??g.nativeCurrency,rpcUrls:S};await w.request({method:"wallet_addEthereumChain",params:[$]});const A=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...A,p]),g}catch(v){throw new Pt(v)}}},onAccountsChanged(h){h.length===0?this.onDisconnect():d.emitter.emit("change",{accounts:h.map(p=>co(p))})},onChainChanged(h){const p=Number(h);d.emitter.emit("change",{chainId:p})},async onConnect(h){const p=Number(h.chainId),w=await this.getAccounts();d.emitter.emit("connect",{accounts:w,chainId:p})},async onDisconnect(h){this.setRequestedChainsIds([]),d.emitter.emit("disconnect");const p=await this.getProvider();s&&(p.removeListener("accountsChanged",s),s=void 0),o&&(p.removeListener("chainChanged",o),o=void 0),u&&(p.removeListener("disconnect",u),u=void 0),l&&(p.removeListener("session_delete",l),l=void 0),a||(a=this.onConnect.bind(this),p.on("connect",a))},onDisplayUri(h){d.emitter.emit("message",{type:"display_uri",data:h})},onSessionDelete(){this.onDisconnect()},getNamespaceChainsIds(){return n?n.session?.namespaces[i]?.accounts?.map(p=>Number.parseInt(p.split(":")[1]||"",10))??[]:[]},async getRequestedChainsIds(){return await d.storage?.getItem(this.requestedChainsStorageKey)??[]},async isChainsStale(){if(!e)return!1;const h=d.chains.map(g=>g.id),p=this.getNamespaceChainsIds();if(p.length&&!p.some(g=>h.includes(g)))return!1;const w=await this.getRequestedChainsIds();return!h.every(g=>w.includes(g))},async setRequestedChainsIds(h){await d.storage?.setItem(this.requestedChainsStorageKey,h)},get requestedChainsStorageKey(){return`${this.id}.requestedChains`}})}function ID(t){const e=[jp(),...t?[Xm({projectId:t})]:[]];return mD({chains:[Hp,Wp,Vp],transports:{[Hp.id]:Jm([fa()]),[Wp.id]:Jm([fa()]),[Vp.id]:Jm([fa()])},connectors:e})}let Qm,B8;function SD(t){const e=t??"";return(!Qm||B8!==e)&&(Qm=ID(t),B8=e),Qm}const AD=2e3,PD=6e4;function OD(t){return new Promise(e=>setTimeout(e,t))}const ND={bsc:Hp,ethereum:Vp,"bsc-testnet":Wp};async function TD(t,e,n){if(!A8(e.chain))throw new Error(`Unsupported chain: ${e.chain}`);const r=e.chain,i=ND[r],s=BigInt(e.amount),o=ZB(t);if(!o.address)throw new Error("Wallet not connected");const a=o.address;if(o.chainId!==i.id&&(n("switching"),await JB(t,{chainId:i.id})),!P8(e.token)&&await $D(t,r,e.token,a)<s){n("approving");const h=await C8(t,_D(r,e.token,s));await E8(t,{hash:h})}n("confirming");const c=await C8(t,xD(r,e));n("pending"),await E8(t,{hash:c});const l=Date.now()+PD;let u=await k8(t,r,e.merchant,e.orderId);for(;!R8(u)&&Date.now()<l;)await OD(AD),u=await k8(t,r,e.merchant,e.orderId);if(!R8(u))throw new Error("Payment submitted but order not confirmed on-chain (timeout)");return{orderKey:e.orderId,chain:r,merchant:e.merchant,token:e.token,amount:e.amount,payer:u,state:"paid",txHash:c,updatedAt:Date.now()}}class D8{constructor(e){this.root=null,this.opts=e,this.config=SD(e.wcProjectId)}mount(e){if(this.root=typeof e=="string"?document.querySelector(e):e,!this.root)throw new Error(`BeamPay: element not found: ${e}`);Promise.resolve().then(()=>Tte),Promise.resolve().then(()=>Mte);const n=document.createElement("beam-pay-button");return n.opts=this.opts,n.addEventListener("beam-pay-click",()=>this.openModal()),this.root.replaceWith(n),this.root=n,this}openModal(){const e=document.createElement("beam-pay-modal");e.opts=this.opts,e.config=this.config,e.addEventListener("beam-pay-success",n=>{this.opts.onSuccess?.(n.detail),e.remove()}),e.addEventListener("beam-pay-error",n=>{this.opts.onError?.(n.detail),e.remove()}),e.addEventListener("beam-pay-close",()=>e.remove()),document.body.appendChild(e)}}const L8={init(t){return new D8(t)}};typeof window<"u"&&(window.BeamPay=L8);var Gp={exports:{}},U8;function kD(){if(U8)return Gp.exports;U8=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(A,f,y){return Function.prototype.apply.call(A,f,y)},n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=function(A){return Object.getOwnPropertyNames(A).concat(Object.getOwnPropertySymbols(A))}:n=function(A){return Object.getOwnPropertyNames(A)};function r($){console&&console.warn&&console.warn($)}var i=Number.isNaN||function(A){return A!==A};function s(){s.init.call(this)}Gp.exports=s,Gp.exports.once=E,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a($){if(typeof $!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof $)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function($){if(typeof $!="number"||$<0||i($))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+$+".");o=$}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(A){if(typeof A!="number"||A<0||i(A))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+A+".");return this._maxListeners=A,this};function c($){return $._maxListeners===void 0?s.defaultMaxListeners:$._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(A){for(var f=[],y=1;y<arguments.length;y++)f.push(arguments[y]);var x=A==="error",C=this._events;if(C!==void 0)x=x&&C.error===void 0;else if(!x)return!1;if(x){var P;if(f.length>0&&(P=f[0]),P instanceof Error)throw P;var O=new Error("Unhandled error."+(P?" ("+P.message+")":""));throw O.context=P,O}var N=C[A];if(N===void 0)return!1;if(typeof N=="function")e(N,this,f);else for(var D=N.length,b=w(N,D),y=0;y<D;++y)e(b[y],this,f);return!0};function l($,A,f,y){var x,C,P;if(a(f),C=$._events,C===void 0?(C=$._events=Object.create(null),$._eventsCount=0):(C.newListener!==void 0&&($.emit("newListener",A,f.listener?f.listener:f),C=$._events),P=C[A]),P===void 0)P=C[A]=f,++$._eventsCount;else if(typeof P=="function"?P=C[A]=y?[f,P]:[P,f]:y?P.unshift(f):P.push(f),x=c($),x>0&&P.length>x&&!P.warned){P.warned=!0;var O=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+String(A)+" listeners added. Use emitter.setMaxListeners() to increase limit");O.name="MaxListenersExceededWarning",O.emitter=$,O.type=A,O.count=P.length,r(O)}return $}s.prototype.addListener=function(A,f){return l(this,A,f,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(A,f){return l(this,A,f,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d($,A,f){var y={fired:!1,wrapFn:void 0,target:$,type:A,listener:f},x=u.bind(y);return x.listener=f,y.wrapFn=x,x}s.prototype.once=function(A,f){return a(f),this.on(A,d(this,A,f)),this},s.prototype.prependOnceListener=function(A,f){return a(f),this.prependListener(A,d(this,A,f)),this},s.prototype.removeListener=function(A,f){var y,x,C,P,O;if(a(f),x=this._events,x===void 0)return this;if(y=x[A],y===void 0)return this;if(y===f||y.listener===f)--this._eventsCount===0?this._events=Object.create(null):(delete x[A],x.removeListener&&this.emit("removeListener",A,y.listener||f));else if(typeof y!="function"){for(C=-1,P=y.length-1;P>=0;P--)if(y[P]===f||y[P].listener===f){O=y[P].listener,C=P;break}if(C<0)return this;C===0?y.shift():g(y,C),y.length===1&&(x[A]=y[0]),x.removeListener!==void 0&&this.emit("removeListener",A,O||f)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(A){var f,y,x;if(y=this._events,y===void 0)return this;if(y.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):y[A]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete y[A]),this;if(arguments.length===0){var C=Object.keys(y),P;for(x=0;x<C.length;++x)P=C[x],P!=="removeListener"&&this.removeAllListeners(P);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(f=y[A],typeof f=="function")this.removeListener(A,f);else if(f!==void 0)for(x=f.length-1;x>=0;x--)this.removeListener(A,f[x]);return this};function h($,A,f){var y=$._events;if(y===void 0)return[];var x=y[A];return x===void 0?[]:typeof x=="function"?f?[x.listener||x]:[x]:f?m(x):w(x,x.length)}s.prototype.listeners=function(A){return h(this,A,!0)},s.prototype.rawListeners=function(A){return h(this,A,!1)},s.listenerCount=function($,A){return typeof $.listenerCount=="function"?$.listenerCount(A):p.call($,A)},s.prototype.listenerCount=p;function p($){var A=this._events;if(A!==void 0){var f=A[$];if(typeof f=="function")return 1;if(f!==void 0)return f.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function w($,A){for(var f=new Array(A),y=0;y<A;++y)f[y]=$[y];return f}function g($,A){for(;A+1<$.length;A++)$[A]=$[A+1];$.pop()}function m($){for(var A=new Array($.length),f=0;f<A.length;++f)A[f]=$[f].listener||$[f];return A}function E($,A){return new Promise(function(f,y){function x(P){$.removeListener(A,C),y(P)}function C(){typeof $.removeListener=="function"&&$.removeListener("error",x),f([].slice.call(arguments))}S($,A,C,{once:!0}),A!=="error"&&v($,x,{once:!0})})}function v($,A,f){typeof $.on=="function"&&S($,"error",A,f)}function S($,A,f,y){if(typeof $.on=="function")y.once?$.once(A,f):$.on(A,f);else if(typeof $.addEventListener=="function")$.addEventListener(A,function x(C){y.once&&$.removeEventListener(A,x),f(C)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof $)}return Gp.exports}var Ot=kD();const Yc=wo(Ot);var M8=function(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))},RD=(function(){function t(e,n,r){this.name=e,this.version=n,this.os=r,this.type="browser"}return t})(),BD=(function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t})(),DD=(function(){function t(e,n,r,i){this.name=e,this.version=n,this.os=r,this.bot=i,this.type="bot-device"}return t})(),LD=(function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t})(),UD=(function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t})(),MD=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,jD=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,j8=3,FD=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",MD]],F8=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function z8(t){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new UD:typeof navigator<"u"?qD(navigator.userAgent):WD()}function zD(t){return t!==""&&FD.reduce(function(e,n){var r=n[0],i=n[1];if(e)return e;var s=i.exec(t);return!!s&&[r,s]},!1)}function qD(t){var e=zD(t);if(!e)return null;var n=e[0],r=e[1];if(n==="searchbot")return new LD;var i=r[1]&&r[1].split(".").join("_").split("_").slice(0,3);i?i.length<j8&&(i=M8(M8([],i,!0),VD(j8-i.length),!0)):i=[];var s=i.join("."),o=HD(t),a=jD.exec(t);return a&&a[1]?new DD(n,s,o,a[1]):new RD(n,s,o)}function HD(t){for(var e=0,n=F8.length;e<n;e++){var r=F8[e],i=r[0],s=r[1],o=s.exec(t);if(o)return i}return null}function WD(){var t=typeof process<"u"&&process.version;return t?new BD(process.version.slice(1)):null}function VD(t){for(var e=[],n=0;n<t;n++)e.push("0");return e}var ew={};/*! *****************************************************************************
38
+ `),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=i,this.metaMessages=n.metaMessages,this.shortMessage=e}walk(e){return g8(this,Lp,"m",m8).call(this,this,e)}};Lp=new WeakSet,m8=function t(e,n){return n?.(e)?e:e.cause?g8(this,Lp,"m",t).call(this,e.cause,n):e};class qd extends go{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class DB extends go{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class LB extends go{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class UB extends go{constructor({address:e,connector:n}){super(`Account "${e}" not found for connector "${n.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class MB extends go{constructor({connectionChainId:e,connectorChainId:n}){super(`The current chain of the connector (id: ${n}) does not match the connection's chain (id: ${e}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class jB extends go{constructor({connector:e}){super(`Connector "${e.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function FB(t,e){let n;if(typeof e.connector=="function"?n=t._internal.connectors.setup(e.connector):n=e.connector,n.uid===t.state.current)throw new DB;try{t.setState(o=>({...o,status:"connecting"})),n.emitter.emit("message",{type:"connecting"});const{connector:r,...i}=e,s=await n.connect(i);return n.emitter.off("connect",t._internal.events.connect),n.emitter.on("change",t._internal.events.change),n.emitter.on("disconnect",t._internal.events.disconnect),await t.storage?.setItem("recentConnectorId",n.id),t.setState(o=>({...o,connections:new Map(o.connections).set(n.uid,{accounts:i.withCapabilities?s.accounts.map(a=>typeof a=="object"?a.address:a):s.accounts,chainId:s.chainId,connector:n}),current:n.uid,status:"connected"})),{accounts:i.withCapabilities?s.accounts.map(o=>typeof o=="object"?o:{address:o,capabilities:{}}):s.accounts,chainId:s.chainId}}catch(r){throw t.setState(i=>({...i,status:i.current?"connected":"disconnected"})),r}}const Hm=256;let Up=Hm,Mp;function w8(t=11){if(!Mp||Up+t>Hm*2){Mp="",Up=0;for(let e=0;e<Hm;e++)Mp+=(256+Math.random()*256|0).toString(16).substring(1)}return Mp.substring(Up,Up+++t)}function y8(t){const{batch:e,chain:n,ccipRead:r,dataSuffix:i,key:s="base",name:o="Base Client",type:a="base"}=t,c=t.experimental_blockTag??(typeof n?.experimental_preconfirmationTime=="number"?"pending":void 0),l=n?.blockTime??12e3,u=Math.min(Math.max(Math.floor(l/2),500),4e3),d=t.pollingInterval??u,h=t.cacheTime??d,p=t.account?ai(t.account):void 0,{config:w,request:g,value:m}=t.transport({account:p,chain:n,pollingInterval:d}),E={...w,...m},v={account:p,batch:e,cacheTime:h,ccipRead:r,chain:n,dataSuffix:i,key:s,name:o,pollingInterval:d,request:g,transport:E,type:a,uid:w8(),...c?{experimental_blockTag:c}:{}};function S($){return A=>{const f=A($);for(const x in v)delete f[x];const y={...$,...f};return Object.assign(y,{extend:S(y)})}}return Object.assign(v,{extend:S(v)})}function Wm({key:t,methods:e,name:n,request:r,retryCount:i=3,retryDelay:s=150,timeout:o,type:a},c){const l=w8();return{config:{key:t,methods:e,name:n,request:r,retryCount:i,retryDelay:s,timeout:o,type:a},request:VR(r,{methods:e,retryCount:i,retryDelay:s,uid:l}),value:c}}function zB(t,e={}){const{key:n="custom",methods:r,name:i="Custom Provider",retryDelay:s}=e;return({retryCount:o})=>Wm({key:n,methods:r,name:i,request:t.request.bind(t),retryCount:e.retryCount??o,retryDelay:s,type:"custom"})}function Vm(t,e={}){const{key:n="fallback",name:r="Fallback",rank:i=!1,shouldThrow:s=qB,retryCount:o,retryDelay:a}=e;return(({chain:c,pollingInterval:l=4e3,timeout:u,...d})=>{let h=t,p=()=>{};const w=Wm({key:n,name:r,async request({method:g,params:m}){let E;const v=async(S=0)=>{const $=h[S]({...d,chain:c,retryCount:0,timeout:u});try{const A=await $.request({method:g,params:m});return p({method:g,params:m,response:A,transport:$,status:"success"}),A}catch(A){if(p({error:A,method:g,params:m,transport:$,status:"error"}),s(A)||S===h.length-1||(E??=h.slice(S+1).some(f=>{const{include:y,exclude:x}=f({chain:c}).config.methods||{};return y?y.includes(g):x?!x.includes(g):!0}),!E))throw A;return v(S+1)}};return v()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:g=>p=g,transports:h.map(g=>g({chain:c,retryCount:0}))});if(i){const g=typeof i=="object"?i:{};HB({chain:c,interval:g.interval??l,onTransports:m=>h=m,ping:g.ping,sampleCount:g.sampleCount,timeout:g.timeout,transports:h,weights:g.weights})}return w})}function qB(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===Wc.code||t.code===Pt.code||t.code===Kc.code||da.nodeMessage.test(t.message)||t.code===5e3))}function HB({chain:t,interval:e=4e3,onTransports:n,ping:r,sampleCount:i=10,timeout:s=1e3,transports:o,weights:a={}}){const{stability:c=.7,latency:l=.3}=a,u=[],d=async()=>{const h=await Promise.all(o.map(async g=>{const m=g({chain:t,retryCount:0,timeout:s}),E=Date.now();let v,S;try{await(r?r({transport:m}):m.request({method:"net_listening"})),S=1}catch{S=0}finally{v=Date.now()}return{latency:v-E,success:S}}));u.push(h),u.length>i&&u.shift();const p=Math.max(...u.map(g=>Math.max(...g.map(({latency:m})=>m)))),w=o.map((g,m)=>{const E=u.map(f=>f[m].latency),S=1-E.reduce((f,y)=>f+y,0)/E.length/p,$=u.map(f=>f[m].success),A=$.reduce((f,y)=>f+y,0)/$.length;return A===0?[0,m]:[l*S+c*A,m]}).sort((g,m)=>m[0]-g[0]);n(w.map(([,g])=>o[g])),await Tp(e),d()};d()}class WB extends ee{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}let VB=0;const b8=new WeakMap;function KB(t){if(!t)return"default";const e=b8.get(t);if(e!==void 0)return e;const n=VB++;return b8.set(t,n),n}function fa(t,e={}){const{batch:n,fetchFn:r,fetchOptions:i,key:s="http",methods:o,name:a="HTTP JSON-RPC",onFetchRequest:c,onFetchResponse:l,retryDelay:u,raw:d}=e;return({chain:h,retryCount:p,timeout:w})=>{const{batchSize:g=1e3,wait:m=0}=typeof n=="object"?n:{},E=e.retryCount??p,v=w??e.timeout??1e4,S=t||h?.rpcUrls.default.http[0];if(!S)throw new WB;const $=rB(S,{fetchFn:r,fetchOptions:i,onRequest:c,onResponse:l,timeout:v});return Wm({key:s,methods:o,name:a,async request({method:A,params:f},y){const x={method:A,params:f},C=y?.signal?{signal:y.signal}:void 0,{schedule:P}=w6({id:`${S}.${KB(y?.signal)}`,wait:m,shouldSplitBatch(b){return b.length>g},fn:b=>$.request({body:b,fetchOptions:C}),sort:(b,_)=>b.id-_.id}),O=async b=>n?P(b):[await $.request({body:b,fetchOptions:C})],[{error:N,result:D}]=await O(x);if(d)return{error:N,result:D};if(N)throw new rm({body:x,error:N,url:S});return D},retryCount:E,retryDelay:u,timeout:v,type:"http"},{fetchOptions:i,url:S})}}async function GB(t,e={}){const{assertChainId:n=!0}=e;let r;if(e.connector){const{connector:u}=e;if(t.state.status==="reconnecting"&&!u.getAccounts&&!u.getChainId)throw new jB({connector:u});const[d,h]=await Promise.all([u.getAccounts().catch(p=>{if(e.account===null)return[];throw p}),u.getChainId()]);r={accounts:d,chainId:h,connector:u}}else r=t.state.connections.get(t.state.current);if(!r)throw new LB;const i=e.chainId??r.chainId,s=await r.connector.getChainId();if(n&&s!==i)throw new MB({connectionChainId:i,connectorChainId:s});const o=r.connector;if(o.getClient)return o.getClient({chainId:i});const a=ai(e.account??r.accounts[0]);if(a&&(a.address=co(a.address)),e.account&&!r.accounts.some(u=>u.toLowerCase()===a.address.toLowerCase()))throw new UB({address:a.address,connector:o});const c=t.chains.find(u=>u.id===i),l=await r.connector.getProvider({chainId:i});return y8({account:a,chain:c,name:"Connector Client",transport:u=>zB(l)({...u,retryCount:0})})}function ZB(t){const e=t.state.current,n=t.state.connections.get(e),r=n?.accounts,i=r?.[0],s=t.chains.find(a=>a.id===n?.chainId),o=t.state.status;switch(o){case"connected":return{address:i,addresses:r,chain:s,chainId:n?.chainId,connector:n?.connector,isConnected:!0,isConnecting:!1,isDisconnected:!1,isReconnecting:!1,status:o};case"reconnecting":return{address:i,addresses:r,chain:s,chainId:n?.chainId,connector:n?.connector,isConnected:!!i,isConnecting:!1,isDisconnected:!1,isReconnecting:!0,status:o};case"connecting":return{address:i,addresses:r,chain:s,chainId:n?.chainId,connector:n?.connector,isConnected:!1,isConnecting:!0,isDisconnected:!1,isReconnecting:!1,status:o};case"disconnected":return{address:void 0,addresses:void 0,chain:void 0,chainId:void 0,connector:void 0,isConnected:!1,isConnecting:!1,isDisconnected:!0,isReconnecting:!1,status:o}}}function v8(t,e){const{chainId:n,...r}=e,i=t.getClient({chainId:n});return zd(i,iR,"readContract")(r)}class mo extends go{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}class YB extends go{constructor({connector:e}){super(`"${e.name}" does not support programmatic chain switching.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SwitchChainNotSupportedError"})}}async function JB(t,e){const{addEthereumChainParameter:n,chainId:r}=e,i=t.state.connections.get(e.connector?.uid??t.state.current);if(i){const o=i.connector;if(!o.switchChain)throw new YB({connector:o});return await o.switchChain({addEthereumChainParameter:n,chainId:r})}const s=t.chains.find(o=>o.id===r);if(!s)throw new qd;return t.setState(o=>({...o,chainId:r})),s}async function E8(t,e){const{chainId:n,timeout:r=0,...i}=e,s=t.getClient({chainId:n}),a=await zd(s,TB,"waitForTransactionReceipt")({...i,timeout:r});if(a.status==="reverted"){const c=zd(s,f8,"getTransaction"),{from:l,...u}=await c({hash:a.transactionHash}),h=await zd(s,Cm,"call")({...u,account:l,data:u.input,gasPrice:u.type!=="eip1559"?u.gasPrice:void 0,maxFeePerGas:u.type==="eip1559"?u.maxFeePerGas:void 0,maxPriorityFeePerGas:u.type==="eip1559"?u.maxPriorityFeePerGas:void 0}),p=h?.data?cN(`0x${h.data.substring(138)}`):"unknown reason";throw new Error(p)}return{...a,chainId:s.chain.id}}async function C8(t,e){const{account:n,chainId:r,connector:i,...s}=e;let o;return typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await GB(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:i}),await zd(o,Bp,"writeContract")({...s,...n?{account:n}:{},chain:r?{id:r}:null})}function Hye(t){return t}jp.type="injected";function jp(t={}){const{shimDisconnect:e=!0,unstable_shimAsyncInject:n}=t;function r(){const c=t.target;if(typeof c=="function"){const l=c();if(l)return l}return typeof c=="object"?c:typeof c=="string"?{...XB[c]??{id:c,name:`${c[0].toUpperCase()}${c.slice(1)}`,provider:`is${c[0].toUpperCase()}${c.slice(1)}`}}:{id:"injected",name:"Injected",provider(l){return l?.ethereum}}}let i,s,o,a;return c=>({get icon(){return r().icon},get id(){return r().id},get name(){return r().name},get supportsSimulation(){return!0},type:jp.type,async setup(){const l=await this.getProvider();l?.on&&t.target&&(o||(o=this.onConnect.bind(this),l.on("connect",o)),i||(i=this.onAccountsChanged.bind(this),l.on("accountsChanged",i)))},async connect({chainId:l,isReconnecting:u,withCapabilities:d}={}){const h=await this.getProvider();if(!h)throw new mo;let p=[];if(u)p=await this.getAccounts().catch(()=>[]);else if(e)try{p=(await h.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0]?.caveats?.[0]?.value?.map(g=>co(g)),p.length>0&&(p=await this.getAccounts())}catch(w){const g=w;if(g.code===Pt.code)throw new Pt(g);if(g.code===uo.code)throw g}try{!p?.length&&!u&&(p=(await h.request({method:"eth_requestAccounts"})).map(m=>co(m))),o&&(h.removeListener("connect",o),o=void 0),i||(i=this.onAccountsChanged.bind(this),h.on("accountsChanged",i)),s||(s=this.onChainChanged.bind(this),h.on("chainChanged",s)),a||(a=this.onDisconnect.bind(this),h.on("disconnect",a));let w=await this.getChainId();return l&&w!==l&&(w=(await this.switchChain({chainId:l}).catch(m=>{if(m.code===Pt.code)throw m;return{id:w}}))?.id??w),e&&await c.storage?.removeItem(`${this.id}.disconnected`),t.target||await c.storage?.setItem("injected.connected",!0),{accounts:d?p.map(g=>({address:g,capabilities:{}})):p,chainId:w}}catch(w){const g=w;throw g.code===Pt.code?new Pt(g):g.code===uo.code?new uo(g):g}},async disconnect(){const l=await this.getProvider();if(!l)throw new mo;s&&(l.removeListener("chainChanged",s),s=void 0),a&&(l.removeListener("disconnect",a),a=void 0),o||(o=this.onConnect.bind(this),l.on("connect",o));try{await W6(()=>l.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}e&&await c.storage?.setItem(`${this.id}.disconnected`,!0),t.target||await c.storage?.removeItem("injected.connected")},async getAccounts(){const l=await this.getProvider();if(!l)throw new mo;return(await l.request({method:"eth_accounts"})).map(d=>co(d))},async getChainId(){const l=await this.getProvider();if(!l)throw new mo;const u=await l.request({method:"eth_chainId"});return Number(u)},async getProvider(){if(typeof window>"u")return;let l;const u=r();return typeof u.provider=="function"?l=u.provider(window):typeof u.provider=="string"?l=Fp(window,u.provider):l=u.provider,l&&!l.removeListener&&("off"in l&&typeof l.off=="function"?l.removeListener=l.off:l.removeListener=()=>{}),l},async isAuthorized(){try{if(e&&await c.storage?.getItem(`${this.id}.disconnected`)||!t.target&&!await c.storage?.getItem("injected.connected"))return!1;if(!await this.getProvider()){if(n!==void 0&&n!==!1){const h=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",h),!!await this.getProvider()),p=typeof n=="number"?n:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(g=>window.addEventListener("ethereum#initialized",()=>g(h()),{once:!0}))]:[],new Promise(g=>setTimeout(()=>g(h()),p))]))return!0}throw new mo}return!!(await kp(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:l,chainId:u}){const d=await this.getProvider();if(!d)throw new mo;const h=c.chains.find(w=>w.id===u);if(!h)throw new ho(new qd);const p=new Promise(w=>{const g=(m=>{"chainId"in m&&m.chainId===u&&(c.emitter.off("change",g),w())});c.emitter.on("change",g)});try{return await Promise.all([d.request({method:"wallet_switchEthereumChain",params:[{chainId:Pe(u)}]}).then(async()=>{await this.getChainId()===u&&c.emitter.emit("change",{chainId:u})}),p]),h}catch(w){const g=w;if(g.code===4902||g?.data?.originalError?.code===4902)try{const{default:m,...E}=h.blockExplorers??{};let v;l?.blockExplorerUrls?v=l.blockExplorerUrls:m&&(v=[m.url,...Object.values(E).map(A=>A.url)]);let S;l?.rpcUrls?.length?S=l.rpcUrls:S=[h.rpcUrls.default?.http[0]??""];const $={blockExplorerUrls:v,chainId:Pe(u),chainName:l?.chainName??h.name,iconUrls:l?.iconUrls,nativeCurrency:l?.nativeCurrency??h.nativeCurrency,rpcUrls:S};return await Promise.all([d.request({method:"wallet_addEthereumChain",params:[$]}).then(async()=>{if(await this.getChainId()===u)c.emitter.emit("change",{chainId:u});else throw new Pt(new Error("User rejected switch after adding network."))}),p]),h}catch(m){throw new Pt(m)}throw g.code===Pt.code?new Pt(g):new ho(g)}},async onAccountsChanged(l){if(l.length===0)this.onDisconnect();else if(c.emitter.listenerCount("connect")){const u=(await this.getChainId()).toString();this.onConnect({chainId:u}),e&&await c.storage?.removeItem(`${this.id}.disconnected`)}else c.emitter.emit("change",{accounts:l.map(u=>co(u))})},onChainChanged(l){const u=Number(l);c.emitter.emit("change",{chainId:u})},async onConnect(l){const u=await this.getAccounts();if(u.length===0)return;const d=Number(l.chainId);c.emitter.emit("connect",{accounts:u,chainId:d});const h=await this.getProvider();h&&(o&&(h.removeListener("connect",o),o=void 0),i||(i=this.onAccountsChanged.bind(this),h.on("accountsChanged",i)),s||(s=this.onChainChanged.bind(this),h.on("chainChanged",s)),a||(a=this.onDisconnect.bind(this),h.on("disconnect",a)))},async onDisconnect(l){const u=await this.getProvider();l&&l.code===1013&&u&&(await this.getAccounts()).length||(c.emitter.emit("disconnect"),u&&(s&&(u.removeListener("chainChanged",s),s=void 0),a&&(u.removeListener("disconnect",a),a=void 0),o||(o=this.onConnect.bind(this),u.on("connect",o))))}})}const XB={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(t){return t?.coinbaseWalletExtension?t.coinbaseWalletExtension:Fp(t,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(t){return Fp(t,e=>{if(!e.isMetaMask||e.isBraveWallet&&!e._events&&!e._state)return!1;const n=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPhantom","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const r of n)if(e[r])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(t){return t?.phantom?.ethereum?t.phantom?.ethereum:Fp(t,"isPhantom")}}};function Fp(t,e){function n(i){return typeof e=="function"?e(i):typeof e=="string"?i[e]:!0}const r=t.ethereum;if(r?.providers)return r.providers.find(i=>n(i));if(r&&n(r))return r}function QB(t){if(typeof window>"u")return;const e=n=>t(n.detail);return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new CustomEvent("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)}function eD(){const t=new Set;let e=[];const n=()=>QB(i=>{e.some(({info:s})=>s.uuid===i.info.uuid)||(e=[...e,i],t.forEach(s=>s(e,{added:[i]})))});let r=n();return{_listeners(){return t},clear(){t.forEach(i=>i([],{removed:[...e]})),e=[]},destroy(){this.clear(),t.clear(),r?.()},findProvider({rdns:i}){return e.find(s=>s.info.rdns===i)},getProviders(){return e},reset(){this.clear(),r?.(),r=n()},subscribe(i,{emitImmediately:s}={}){return t.add(i),s&&i(e,{added:e}),()=>t.delete(i)}}}const tD=t=>(e,n,r)=>{const i=r.subscribe;return r.subscribe=(o,a,c)=>{let l=o;if(a){const u=c?.equalityFn||Object.is;let d=o(r.getState());l=h=>{const p=o(h);if(!u(d,p)){const w=d;a(d=p,w)}},c?.fireImmediately&&a(d,d)}return i(l)},t(e,n,r)};function nD(t,e){let n;try{n=t()}catch{return}return{getItem:i=>{var s;const o=c=>c===null?null:JSON.parse(c,void 0),a=(s=n.getItem(i))!=null?s:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const Km=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then(r){return Km(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Km(r)(n)}}}},rD=(t,e)=>(n,r,i)=>{let s={storage:nD(()=>localStorage),partialize:g=>g,version:0,merge:(g,m)=>({...m,...g}),...e},o=!1;const a=new Set,c=new Set;let l=s.storage;if(!l)return t((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...g)},r,i);const u=()=>{const g=s.partialize({...r()});return l.setItem(s.name,{state:g,version:s.version})},d=i.setState;i.setState=(g,m)=>{d(g,m),u()};const h=t((...g)=>{n(...g),u()},r,i);i.getInitialState=()=>h;let p;const w=()=>{var g,m;if(!l)return;o=!1,a.forEach(v=>{var S;return v((S=r())!=null?S:h)});const E=((m=s.onRehydrateStorage)==null?void 0:m.call(s,(g=r())!=null?g:h))||void 0;return Km(l.getItem.bind(l))(s.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==s.version){if(s.migrate)return[!0,s.migrate(v.state,v.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,v.state];return[!1,void 0]}).then(v=>{var S;const[$,A]=v;if(p=s.merge(A,(S=r())!=null?S:h),n(p,!0),$)return u()}).then(()=>{E?.(p,void 0),p=r(),o=!0,c.forEach(v=>v(p))}).catch(v=>{E?.(void 0,v)})};return i.persist={setOptions:g=>{s={...s,...g},g.storage&&(l=g.storage)},clearStorage:()=>{l?.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>w(),hasHydrated:()=>o,onHydrate:g=>(a.add(g),()=>{a.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},s.skipHydration||w(),p||h},x8=t=>{let e;const n=new Set,r=(l,u)=>{const d=typeof l=="function"?l(e):l;if(!Object.is(d,e)){const h=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(p=>p(e,h))}},i=()=>e,a={setState:r,getState:i,getInitialState:()=>c,subscribe:l=>(n.add(l),()=>n.delete(l))},c=e=t(r,i,a);return a},Gm=t=>t?x8(t):x8;var Di=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function iD(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var Zm={exports:{}},_8;function sD(){return _8||(_8=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,l,u){this.fn=c,this.context=l,this.once=u||!1}function s(c,l,u,d,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new i(u,d||c,h),w=n?n+l:l;return c._events[w]?c._events[w].fn?c._events[w]=[c._events[w],p]:c._events[w].push(p):(c._events[w]=p,c._eventsCount++),c}function o(c,l){--c._eventsCount===0?c._events=new r:delete c._events[l]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],u,d;if(this._eventsCount===0)return l;for(d in u=this._events)e.call(u,d)&&l.push(n?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},a.prototype.listeners=function(l){var u=n?n+l:l,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,p=d.length,w=new Array(p);h<p;h++)w[h]=d[h].fn;return w},a.prototype.listenerCount=function(l){var u=n?n+l:l,d=this._events[u];return d?d.fn?1:d.length:0},a.prototype.emit=function(l,u,d,h,p,w){var g=n?n+l:l;if(!this._events[g])return!1;var m=this._events[g],E=arguments.length,v,S;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),E){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,u),!0;case 3:return m.fn.call(m.context,u,d),!0;case 4:return m.fn.call(m.context,u,d,h),!0;case 5:return m.fn.call(m.context,u,d,h,p),!0;case 6:return m.fn.call(m.context,u,d,h,p,w),!0}for(S=1,v=new Array(E-1);S<E;S++)v[S-1]=arguments[S];m.fn.apply(m.context,v)}else{var $=m.length,A;for(S=0;S<$;S++)switch(m[S].once&&this.removeListener(l,m[S].fn,void 0,!0),E){case 1:m[S].fn.call(m[S].context);break;case 2:m[S].fn.call(m[S].context,u);break;case 3:m[S].fn.call(m[S].context,u,d);break;case 4:m[S].fn.call(m[S].context,u,d,h);break;default:if(!v)for(A=1,v=new Array(E-1);A<E;A++)v[A-1]=arguments[A];m[S].fn.apply(m[S].context,v)}}return!0},a.prototype.on=function(l,u,d){return s(this,l,u,d,!1)},a.prototype.once=function(l,u,d){return s(this,l,u,d,!0)},a.prototype.removeListener=function(l,u,d,h){var p=n?n+l:l;if(!this._events[p])return this;if(!u)return o(this,p),this;var w=this._events[p];if(w.fn)w.fn===u&&(!h||w.once)&&(!d||w.context===d)&&o(this,p);else{for(var g=0,m=[],E=w.length;g<E;g++)(w[g].fn!==u||h&&!w[g].once||d&&w[g].context!==d)&&m.push(w[g]);m.length?this._events[p]=m.length===1?m[0]:m:o(this,p)}return this},a.prototype.removeAllListeners=function(l){var u;return l?(u=n?n+l:l,this._events[u]&&o(this,u)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a})(Zm)),Zm.exports}var oD=sD();const aD=wo(oD);class cD{constructor(e){Object.defineProperty(this,"uid",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_emitter",{enumerable:!0,configurable:!0,writable:!0,value:new aD})}on(e,n){this._emitter.on(e,n)}once(e,n){this._emitter.once(e,n)}off(e,n){this._emitter.off(e,n)}emit(e,...n){const r=n[0];this._emitter.emit(e,{uid:this.uid,...r})}listenerCount(e){return this._emitter.listenerCount(e)}}function lD(t){return new cD(t)}function uD(t,e){return JSON.parse(t,(n,r)=>{let i=r;return i?.__type==="bigint"&&(i=BigInt(i.value)),i?.__type==="Map"&&(i=new Map(i.value)),e?.(n,i)??i})}function $8(t,e){return t.slice(0,e).join(".")||"."}function I8(t,e){const{length:n}=t;for(let r=0;r<n;++r)if(t[r]===e)return r+1;return 0}function dD(t,e){const n=typeof t=="function",r=typeof e=="function",i=[],s=[];return function(a,c){if(typeof c=="object")if(i.length){const l=I8(i,this);l===0?i[i.length]=this:(i.splice(l),s.splice(l)),s[s.length]=a;const u=I8(i,c);if(u!==0)return r?e.call(this,a,c,$8(s,u)):`[ref=${$8(s,u)}]`}else i[0]=c,s[0]=a;return n?t.call(this,a,c):c}}function hD(t,e,n,r){return JSON.stringify(t,dD((i,s)=>{let o=s;return typeof o=="bigint"&&(o={__type:"bigint",value:s.toString()}),o instanceof Map&&(o={__type:"Map",value:Array.from(s.entries())}),e?.(i,o)??o},r),n??void 0)}function fD(t){const{deserialize:e=uD,key:n="wagmi",serialize:r=hD,storage:i=S8}=t;function s(o){return o instanceof Promise?o.then(a=>a).catch(()=>null):o}return{...i,key:n,async getItem(o,a){const c=i.getItem(`${n}.${o}`),l=await s(c);return l?e(l)??null:a??null},async setItem(o,a){const c=`${n}.${o}`;a===null?await s(i.removeItem(c)):await s(i.setItem(c,r(a)))},async removeItem(o){await s(i.removeItem(`${n}.${o}`))}}}const S8={getItem:()=>null,setItem:()=>{},removeItem:()=>{}};function pD(){const t=typeof window<"u"&&window.localStorage?window.localStorage:S8;return{getItem(e){return t.getItem(e)},removeItem(e){t.removeItem(e)},setItem(e,n){try{t.setItem(e,n)}catch{}}}}const Ym=256;let zp=Ym,qp;function gD(t=11){if(!qp||zp+t>Ym*2){qp="",zp=0;for(let e=0;e<Ym;e++)qp+=(256+Math.random()*256|0).toString(16).substring(1)}return qp.substring(zp,zp+++t)}function mD(t){const{multiInjectedProviderDiscovery:e=!0,storage:n=fD({storage:pD()}),syncConnectedChain:r=!0,ssr:i=!1,...s}=t,o=typeof window<"u"&&e?eD():void 0,a=Gm(()=>s.chains),c=Gm(()=>{const A=[],f=new Set;for(const y of s.connectors??[]){const x=l(y);if(A.push(x),!i&&x.rdns){const C=typeof x.rdns=="string"?[x.rdns]:x.rdns;for(const P of C)f.add(P)}}if(!i&&o){const y=o.getProviders();for(const x of y)f.has(x.info.rdns)||A.push(l(u(x)))}return A});function l(A){const f=lD(gD()),y={...A({emitter:f,chains:a.getState(),storage:n,transports:s.transports}),emitter:f,uid:f.uid};return f.on("connect",S),y.setup?.(),y}function u(A){const{info:f}=A,y=A.provider;return jp({target:{...f,id:f.rdns,provider:y}})}const d=new Map;function h(A={}){const f=A.chainId??m.getState().chainId,y=a.getState().find(C=>C.id===f);if(A.chainId&&!y)throw new qd;{const C=d.get(m.getState().chainId);if(C&&!y)return C;if(!y)throw new qd}{const C=d.get(f);if(C)return C}let x;if(s.client)x=s.client({chain:y});else{const C=y.id,P=a.getState().map(D=>D.id),O={},N=Object.entries(s);for(const[D,b]of N)if(!(D==="chains"||D==="client"||D==="connectors"||D==="transports"))if(typeof b=="object")if(C in b)O[D]=b[C];else{if(P.some(I=>I in b))continue;O[D]=b}else O[D]=b;x=y8({...O,chain:y,batch:O.batch??{multicall:!0},transport:D=>s.transports[C]({...D,connectors:c})})}return d.set(f,x),x}function p(){return{chainId:a.getState()[0].id,connections:new Map,current:null,status:"disconnected"}}let w;const g="0.0.0-canary-";Dp.startsWith(g)?w=Number.parseInt(Dp.replace(g,""),10):w=Number.parseInt(Dp.split(".")[0]??"0",10);const m=Gm(tD(n?rD(p,{migrate(A,f){if(f===w)return A;const y=p(),x=E(A,y.chainId);return{...y,chainId:x}},name:"store",partialize(A){return{connections:{__type:"Map",value:Array.from(A.connections.entries()).map(([f,y])=>{const{id:x,name:C,type:P,uid:O}=y.connector;return[f,{...y,connector:{id:x,name:C,type:P,uid:O}}]})},chainId:A.chainId,current:A.current}},merge(A,f){typeof A=="object"&&A&&"status"in A&&delete A.status;const y=E(A,f.chainId);return{...f,...A,chainId:y}},skipHydration:i,storage:n,version:w}):p));m.setState(p());function E(A,f){return A&&typeof A=="object"&&"chainId"in A&&typeof A.chainId=="number"&&a.getState().some(y=>y.id===A.chainId)?A.chainId:f}r&&m.subscribe(({connections:A,current:f})=>f?A.get(f)?.chainId:void 0,A=>{if(a.getState().some(y=>y.id===A))return m.setState(y=>({...y,chainId:A??y.chainId}))}),o?.subscribe(A=>{const f=new Set,y=new Set;for(const C of c.getState())if(f.add(C.id),C.rdns){const P=typeof C.rdns=="string"?[C.rdns]:C.rdns;for(const O of P)y.add(O)}const x=[];for(const C of A){if(y.has(C.info.rdns))continue;const P=l(u(C));f.has(P.id)||x.push(P)}n&&!m.persist.hasHydrated()||c.setState(C=>[...C,...x],!0)});function v(A){m.setState(f=>{const y=f.connections.get(A.uid);return y?{...f,connections:new Map(f.connections).set(A.uid,{accounts:A.accounts??y.accounts,chainId:A.chainId??y.chainId,connector:y.connector})}:f})}function S(A){m.getState().status==="connecting"||m.getState().status==="reconnecting"||m.setState(f=>{const y=c.getState().find(x=>x.uid===A.uid);return y?(y.emitter.listenerCount("connect")&&y.emitter.off("connect",v),y.emitter.listenerCount("change")||y.emitter.on("change",v),y.emitter.listenerCount("disconnect")||y.emitter.on("disconnect",$),{...f,connections:new Map(f.connections).set(A.uid,{accounts:A.accounts,chainId:A.chainId,connector:y}),current:A.uid,status:"connected"}):f})}function $(A){m.setState(f=>{const y=f.connections.get(A.uid);if(y){const C=y.connector;C.emitter.listenerCount("change")&&y.connector.emitter.off("change",v),C.emitter.listenerCount("disconnect")&&y.connector.emitter.off("disconnect",$),C.emitter.listenerCount("connect")||y.connector.emitter.on("connect",S)}if(f.connections.delete(A.uid),f.connections.size===0)return{...f,connections:new Map,current:null,status:"disconnected"};const x=f.connections.values().next().value;return{...f,connections:new Map(f.connections),current:x.connector.uid}})}return{get chains(){return a.getState()},get connectors(){return c.getState()},storage:n,getClient:h,get state(){return m.getState()},setState(A){let f;typeof A=="function"?f=A(m.getState()):f=A;const y=p();typeof f!="object"&&(f=y),Object.keys(y).some(C=>!(C in f))&&(f=y),m.setState(f,!0)},subscribe(A,f,y){return m.subscribe(A,f,y?{...y,fireImmediately:y.emitImmediately}:void 0)},_internal:{mipd:o,async revalidate(){const A=m.getState(),f=A.connections;let y=A.current;for(const[,x]of f){const C=x.connector;C.isAuthorized&&await C.isAuthorized()||(f.delete(C.uid),y===C.uid&&(y=null))}m.setState(x=>({...x,connections:f,current:y}))},store:m,ssr:!!i,syncConnectedChain:r,transports:s.transports,chains:{setState(A){const f=typeof A=="function"?A(a.getState()):A;if(f.length!==0)return a.setState(f,!0)},subscribe(A){return a.subscribe(A)}},connectors:{providerDetailToConnector:u,setup:l,setState(A){return c.setState(typeof A=="function"?A(c.getState()):A,!0)},subscribe(A){return c.subscribe(A)}},events:{change:v,connect:S,disconnect:$}}}}function Jm(t,e){return Vm(t,e)}function wD(t){const{chain:e}=t,n=e.rpcUrls.default.http[0];if(!t.transports)return[n];const r=t.transports?.[e.id]?.({chain:e});return(r?.value?.transports||[r]).map(({value:s})=>s?.url||n)}const Hp=Sm({id:56,name:"BNB Smart Chain",blockTime:750,nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://56.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com",apiUrl:"https://api.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15921452}}}),Wp=Sm({id:97,name:"BNB Smart Chain Testnet",nativeCurrency:{decimals:18,name:"BNB",symbol:"tBNB"},rpcUrls:{default:{http:["https://data-seed-prebsc-1-s1.bnbchain.org:8545"]}},blockExplorers:{default:{name:"BscScan",url:"https://testnet.bscscan.com",apiUrl:"https://api-testnet.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:17422483}},testnet:!0}),Vp=Sm({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}});Hp.id+"",Vp.id+"",Wp.id+"";const yD={bsc:t=>`https://bscscan.com/tx/${t}`,ethereum:t=>`https://etherscan.io/tx/${t}`,"bsc-testnet":t=>`https://testnet.bscscan.com/tx/${t}`};function A8(t){return t==="bsc"||t==="ethereum"||t==="bsc-testnet"}function bD(t,e){return yD[t](e)}const vD="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";function P8(t){return t.toLowerCase()===vD.toLowerCase()}var ED=[{type:"constructor",inputs:[{name:"_governance",type:"address",internalType:"address"},{name:"_initialTokens",type:"address[]",internalType:"address[]"},{name:"_initialRecipients",type:"address[]",internalType:"address[]"},{name:"_initialFeeRate",type:"uint256",internalType:"uint256"}],stateMutability:"nonpayable"},{type:"function",name:"BASIS_POINTS_DENOMINATOR",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"DOMAIN_SEPARATOR",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"FEE_RATE_HARD_LIMIT",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"MAX_FEE_RECIPIENTS",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"NATIVE_TOKEN",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"ORDER_TYPEHASH",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"TIMELOCK_DELAY",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"acceptGovernance",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"addFeeRecipient",inputs:[{name:"recipient",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"addToken",inputs:[{name:"token",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"allowedTokens",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"calculateFee",inputs:[{name:"amount",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"cancelPendingChange",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"currentFeeRate",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"eip712Domain",inputs:[],outputs:[{name:"fields",type:"bytes1",internalType:"bytes1"},{name:"name",type:"string",internalType:"string"},{name:"version",type:"string",internalType:"string"},{name:"chainId",type:"uint256",internalType:"uint256"},{name:"verifyingContract",type:"address",internalType:"address"},{name:"salt",type:"bytes32",internalType:"bytes32"},{name:"extensions",type:"uint256[]",internalType:"uint256[]"}],stateMutability:"view"},{type:"function",name:"executeFeeChange",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"feeRecipients",inputs:[{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"feeRecipientsLength",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getFeeRecipients",inputs:[],outputs:[{name:"",type:"address[]",internalType:"address[]"}],stateMutability:"view"},{type:"function",name:"getOrder",inputs:[{name:"merchant",type:"address",internalType:"address"},{name:"orderId",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"tuple",internalType:"struct BeamPayRouter.OrderRecord",components:[{name:"payer",type:"address",internalType:"address"},{name:"createdAt",type:"uint64",internalType:"uint64"},{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"refunded",type:"uint256",internalType:"uint256"},{name:"receiver",type:"address",internalType:"address"},{name:"signer",type:"address",internalType:"address"},{name:"expiresAt",type:"uint64",internalType:"uint64"}]}],stateMutability:"view"},{type:"function",name:"governance",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"isFeeRecipient",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"merchantReceiver",inputs:[{name:"merchant",type:"address",internalType:"address"}],outputs:[{name:"receiver",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"merchantSigner",inputs:[{name:"merchant",type:"address",internalType:"address"}],outputs:[{name:"signer",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"orders",inputs:[{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"payer",type:"address",internalType:"address"},{name:"createdAt",type:"uint64",internalType:"uint64"},{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"refunded",type:"uint256",internalType:"uint256"},{name:"receiver",type:"address",internalType:"address"},{name:"signer",type:"address",internalType:"address"},{name:"expiresAt",type:"uint64",internalType:"uint64"}],stateMutability:"view"},{type:"function",name:"pay",inputs:[{name:"merchant",type:"address",internalType:"address"},{name:"receiver",type:"address",internalType:"address"},{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"orderId",type:"bytes32",internalType:"bytes32"},{name:"signer",type:"address",internalType:"address"},{name:"createdAt",type:"uint64",internalType:"uint64"},{name:"expiresAt",type:"uint64",internalType:"uint64"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"function",name:"pending",inputs:[],outputs:[{name:"newRate",type:"uint256",internalType:"uint256"},{name:"effectiveTime",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingGovernance",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"proposeFeeChange",inputs:[{name:"newRate",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"refund",inputs:[{name:"orderId",type:"bytes32",internalType:"bytes32"},{name:"amount",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"payable"},{type:"function",name:"removeFeeRecipient",inputs:[{name:"index",type:"uint256",internalType:"uint256"},{name:"expectedAddress",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"renounceGovernance",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setReceiver",inputs:[{name:"newReceiver",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setSigner",inputs:[{name:"newSigner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferGovernance",inputs:[{name:"newGov",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"EIP712DomainChanged",inputs:[],anonymous:!1},{type:"event",name:"FeeChangeCancelled",inputs:[],anonymous:!1},{type:"event",name:"FeeChangeExecuted",inputs:[{name:"newRate",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"FeeChangeProposed",inputs:[{name:"newRate",type:"uint256",indexed:!1,internalType:"uint256"},{name:"effectiveTime",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"FeeRecipientAdded",inputs:[{name:"recipient",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"FeeRecipientRemoved",inputs:[{name:"index",type:"uint256",indexed:!1,internalType:"uint256"},{name:"recipient",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"FeeRedirectedToMerchant",inputs:[{name:"orderId",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"fee",type:"uint256",indexed:!1,internalType:"uint256"},{name:"feeRecipient",type:"address",indexed:!0,internalType:"address"},{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"receiver",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"FeeTransferFailed",inputs:[{name:"orderId",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"fee",type:"uint256",indexed:!1,internalType:"uint256"},{name:"feeRecipient",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"GovernanceTransferStarted",inputs:[{name:"oldGov",type:"address",indexed:!0,internalType:"address"},{name:"pendingGov",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"GovernanceTransferred",inputs:[{name:"oldGov",type:"address",indexed:!0,internalType:"address"},{name:"newGov",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Initialized",inputs:[{name:"governance",type:"address",indexed:!1,internalType:"address"},{name:"feeRate",type:"uint256",indexed:!1,internalType:"uint256"},{name:"timelockDelay",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"Paid",inputs:[{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"orderId",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"payer",type:"address",indexed:!0,internalType:"address"},{name:"receiver",type:"address",indexed:!1,internalType:"address"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"fee",type:"uint256",indexed:!1,internalType:"uint256"},{name:"feeRecipient",type:"address",indexed:!1,internalType:"address"},{name:"feeCollected",type:"bool",indexed:!1,internalType:"bool"},{name:"timestamp",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"ReceiverUpdated",inputs:[{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"oldReceiver",type:"address",indexed:!0,internalType:"address"},{name:"newReceiver",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Refunded",inputs:[{name:"orderId",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"payer",type:"address",indexed:!0,internalType:"address"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"timestamp",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"SignerUpdated",inputs:[{name:"merchant",type:"address",indexed:!0,internalType:"address"},{name:"oldSigner",type:"address",indexed:!0,internalType:"address"},{name:"newSigner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"TokenAdded",inputs:[{name:"token",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AddressMismatch",inputs:[]},{type:"error",name:"AlreadyAllowed",inputs:[]},{type:"error",name:"AlreadyFeeRecipient",inputs:[]},{type:"error",name:"AmountTooSmall",inputs:[]},{type:"error",name:"DuplicateOrder",inputs:[]},{type:"error",name:"ECDSAInvalidSignature",inputs:[]},{type:"error",name:"ECDSAInvalidSignatureLength",inputs:[{name:"length",type:"uint256",internalType:"uint256"}]},{type:"error",name:"ECDSAInvalidSignatureS",inputs:[{name:"s",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"IncorrectNativeValue",inputs:[]},{type:"error",name:"InvalidExpiry",inputs:[]},{type:"error",name:"InvalidShortString",inputs:[]},{type:"error",name:"InvalidSignature",inputs:[]},{type:"error",name:"MustKeepAtLeastOne",inputs:[]},{type:"error",name:"NativeTransferFailed",inputs:[]},{type:"error",name:"NoPending",inputs:[]},{type:"error",name:"NotAFeeRecipient",inputs:[]},{type:"error",name:"NotGovernance",inputs:[]},{type:"error",name:"NotPendingGovernance",inputs:[]},{type:"error",name:"OrderExpired",inputs:[]},{type:"error",name:"OrderNotPaid",inputs:[]},{type:"error",name:"RateExceedsHardLimit",inputs:[]},{type:"error",name:"Reentrant",inputs:[]},{type:"error",name:"RefundExceedsOrder",inputs:[]},{type:"error",name:"SafeERC20Failed",inputs:[]},{type:"error",name:"StringTooLong",inputs:[{name:"str",type:"string",internalType:"string"}]},{type:"error",name:"TimelockNotExpired",inputs:[]},{type:"error",name:"TokenNotAllowed",inputs:[]},{type:"error",name:"TooManyRecipients",inputs:[]},{type:"error",name:"UnauthorizedSigner",inputs:[]},{type:"error",name:"UnexpectedNativeValue",inputs:[]},{type:"error",name:"ZeroAddress",inputs:[]},{type:"error",name:"ZeroAmount",inputs:[]},{type:"error",name:"ZeroOrderId",inputs:[]}],O8=ED,CD={bsc:"0xBEA93fceFb115b22a3D6c714Ee815B359e2AAbaa",ethereum:"0xBEA93fceFb115b22a3D6c714Ee815B359e2AAbaa","bsc-testnet":"0xBEA93fceFb115b22a3D6c714Ee815B359e2AAbaa"};const N8="0x0000000000000000000000000000000000000000";function Kp(t){const e=CD[t];if(!e||e===N8)throw new Error(`BeamPayRouter address for ${t} is not configured`);return e}const T8=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]}];function xD(t,e){const n=BigInt(e.amount),r=P8(e.token);return{address:Kp(t),abi:O8,functionName:"pay",args:[e.merchant,e.receiver,e.token,n,e.orderId,e.signer,BigInt(e.createdAt),BigInt(e.expiresAt),e.signature],value:r?n:0n}}function _D(t,e,n){return{address:e,abi:T8,functionName:"approve",args:[Kp(t),n]}}async function $D(t,e,n,r){return await v8(t,{address:n,abi:T8,functionName:"allowance",args:[r,Kp(e)]})}async function k8(t,e,n,r){return(await v8(t,{address:Kp(e),abi:O8,functionName:"getOrder",args:[n,r]})).payer}function R8(t){return t.toLowerCase()!==N8}Xm.type="walletConnect";function Xm(t){const e=t.isNewChainsStale??!0;let n,r;const i="eip155";let s,o,a,c,l,u;return d=>({id:"walletConnect",name:"WalletConnect",type:Xm.type,async setup(){const h=await this.getProvider().catch(()=>null);h&&(a||(a=this.onConnect.bind(this),h.on("connect",a)),l||(l=this.onSessionDelete.bind(this),h.on("session_delete",l)))},async connect({chainId:h,withCapabilities:p,...w}={}){try{const g=await this.getProvider();if(!g)throw new mo;c||(c=this.onDisplayUri,g.on("display_uri",c));let m=h;if(!m){const $=await d.storage?.getItem("state")??{};d.chains.some(f=>f.id===$.chainId)?m=$.chainId:m=d.chains[0]?.id}if(!m)throw new Error("No chains found on connector.");const E=await this.isChainsStale();if(g.session&&E&&await g.disconnect(),!g.session||E){const $=d.chains.filter(A=>A.id!==m).map(A=>A.id);await g.connect({optionalChains:[m,...$],..."pairingTopic"in w?{pairingTopic:w.pairingTopic}:{}}),this.setRequestedChainsIds(d.chains.map(A=>A.id))}const v=(await g.enable()).map($=>co($));let S=await this.getChainId();return h&&S!==h&&(S=(await this.switchChain({chainId:h}).catch(A=>{if(A.code===Pt.code&&A.cause?.message!=="Missing or invalid. request() method: wallet_addEthereumChain")throw A;return{id:S}}))?.id??S),c&&(g.removeListener("display_uri",c),c=void 0),a&&(g.removeListener("connect",a),a=void 0),s||(s=this.onAccountsChanged.bind(this),g.on("accountsChanged",s)),o||(o=this.onChainChanged.bind(this),g.on("chainChanged",o)),u||(u=this.onDisconnect.bind(this),g.on("disconnect",u)),l||(l=this.onSessionDelete.bind(this),g.on("session_delete",l)),{accounts:p?v.map($=>({address:$,capabilities:{}})):v,chainId:S}}catch(g){throw/(user rejected|connection request reset)/i.test(g?.message)?new Pt(g):g}},async disconnect(){const h=await this.getProvider();try{await h?.disconnect()}catch(p){if(!/No matching key/i.test(p.message))throw p}finally{o&&(h?.removeListener("chainChanged",o),o=void 0),u&&(h?.removeListener("disconnect",u),u=void 0),a||(a=this.onConnect.bind(this),h?.on("connect",a)),s&&(h?.removeListener("accountsChanged",s),s=void 0),l&&(h?.removeListener("session_delete",l),l=void 0),this.setRequestedChainsIds([])}},async getAccounts(){return(await this.getProvider()).accounts.map(p=>co(p))},async getProvider({chainId:h}={}){async function p(){const w=d.chains.map(m=>m.id);if(!w.length)return;const{EthereumProvider:g}=await Promise.resolve().then(()=>Wee);return await g.init({...t,disableProviderPing:!0,optionalChains:w,projectId:t.projectId,rpcMap:Object.fromEntries(d.chains.map(m=>{const[E]=wD({chain:m,transports:d.transports});return[m.id,E]})),showQrModal:t.showQrModal??!0})}return n||(r||(r=p()),n=await r,n?.events.setMaxListeners(Number.POSITIVE_INFINITY)),h&&await this.switchChain?.({chainId:h}),n},async getChainId(){return(await this.getProvider()).chainId},async isAuthorized(){try{const[h,p]=await Promise.all([this.getAccounts(),this.getProvider()]);return h.length?await this.isChainsStale()&&p.session?(await p.disconnect().catch(()=>{}),!1):!0:!1}catch{return!1}},async switchChain({addEthereumChainParameter:h,chainId:p}){const w=await this.getProvider();if(!w)throw new mo;const g=d.chains.find(m=>m.id===p);if(!g)throw new ho(new qd);try{await Promise.all([new Promise(E=>{const v=({chainId:S})=>{S===p&&(d.emitter.off("change",v),E())};d.emitter.on("change",v)}),w.request({method:"wallet_switchEthereumChain",params:[{chainId:Pe(p)}]})]);const m=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...m,p]),g}catch(m){const E=m;if(/(user rejected)/i.test(E.message))throw new Pt(E);try{let v;h?.blockExplorerUrls?v=h.blockExplorerUrls:v=g.blockExplorers?.default.url?[g.blockExplorers?.default.url]:[];let S;h?.rpcUrls?.length?S=h.rpcUrls:S=[...g.rpcUrls.default.http];const $={blockExplorerUrls:v,chainId:Pe(p),chainName:h?.chainName??g.name,iconUrls:h?.iconUrls,nativeCurrency:h?.nativeCurrency??g.nativeCurrency,rpcUrls:S};await w.request({method:"wallet_addEthereumChain",params:[$]});const A=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...A,p]),g}catch(v){throw new Pt(v)}}},onAccountsChanged(h){h.length===0?this.onDisconnect():d.emitter.emit("change",{accounts:h.map(p=>co(p))})},onChainChanged(h){const p=Number(h);d.emitter.emit("change",{chainId:p})},async onConnect(h){const p=Number(h.chainId),w=await this.getAccounts();d.emitter.emit("connect",{accounts:w,chainId:p})},async onDisconnect(h){this.setRequestedChainsIds([]),d.emitter.emit("disconnect");const p=await this.getProvider();s&&(p.removeListener("accountsChanged",s),s=void 0),o&&(p.removeListener("chainChanged",o),o=void 0),u&&(p.removeListener("disconnect",u),u=void 0),l&&(p.removeListener("session_delete",l),l=void 0),a||(a=this.onConnect.bind(this),p.on("connect",a))},onDisplayUri(h){d.emitter.emit("message",{type:"display_uri",data:h})},onSessionDelete(){this.onDisconnect()},getNamespaceChainsIds(){return n?n.session?.namespaces[i]?.accounts?.map(p=>Number.parseInt(p.split(":")[1]||"",10))??[]:[]},async getRequestedChainsIds(){return await d.storage?.getItem(this.requestedChainsStorageKey)??[]},async isChainsStale(){if(!e)return!1;const h=d.chains.map(g=>g.id),p=this.getNamespaceChainsIds();if(p.length&&!p.some(g=>h.includes(g)))return!1;const w=await this.getRequestedChainsIds();return!h.every(g=>w.includes(g))},async setRequestedChainsIds(h){await d.storage?.setItem(this.requestedChainsStorageKey,h)},get requestedChainsStorageKey(){return`${this.id}.requestedChains`}})}function ID(t){const e=[jp(),...t?[Xm({projectId:t})]:[]];return mD({chains:[Hp,Wp,Vp],transports:{[Hp.id]:Jm([fa()]),[Wp.id]:Jm([fa()]),[Vp.id]:Jm([fa()])},connectors:e})}let Qm,B8;function SD(t){const e=t??"";return(!Qm||B8!==e)&&(Qm=ID(t),B8=e),Qm}const AD=2e3,PD=6e4;function OD(t){return new Promise(e=>setTimeout(e,t))}const ND={bsc:Hp,ethereum:Vp,"bsc-testnet":Wp};async function TD(t,e,n){if(!A8(e.chain))throw new Error(`Unsupported chain: ${e.chain}`);const r=e.chain,i=ND[r],s=BigInt(e.amount),o=ZB(t);if(!o.address)throw new Error("Wallet not connected");const a=o.address;if(o.chainId!==i.id&&(n("switching"),await JB(t,{chainId:i.id})),!P8(e.token)&&await $D(t,r,e.token,a)<s){n("approving");const h=await C8(t,_D(r,e.token,s));await E8(t,{hash:h})}n("confirming");const c=await C8(t,xD(r,e));n("pending"),await E8(t,{hash:c});const l=Date.now()+PD;let u=await k8(t,r,e.merchant,e.orderId);for(;!R8(u)&&Date.now()<l;)await OD(AD),u=await k8(t,r,e.merchant,e.orderId);if(!R8(u))throw new Error("Payment submitted but order not confirmed on-chain (timeout)");return{orderId:e.orderId,chain:r,merchant:e.merchant,token:e.token,amount:e.amount,payer:u,state:"paid",txHash:c,updatedAt:Date.now()}}class D8{constructor(e){this.root=null,this.opts=e,this.config=SD(e.wcProjectId)}mount(e){if(this.root=typeof e=="string"?document.querySelector(e):e,!this.root)throw new Error(`BeamPay: element not found: ${e}`);Promise.resolve().then(()=>Tte),Promise.resolve().then(()=>Mte);const n=document.createElement("beam-pay-button");return n.opts=this.opts,n.addEventListener("beam-pay-click",()=>this.openModal()),this.root.replaceWith(n),this.root=n,this}openModal(){const e=document.createElement("beam-pay-modal");e.opts=this.opts,e.config=this.config,e.addEventListener("beam-pay-success",n=>{this.opts.onSuccess?.(n.detail),e.remove()}),e.addEventListener("beam-pay-error",n=>{this.opts.onError?.(n.detail),e.remove()}),e.addEventListener("beam-pay-close",()=>e.remove()),document.body.appendChild(e)}}const L8={init(t){return new D8(t)}};typeof window<"u"&&(window.BeamPay=L8);var Gp={exports:{}},U8;function kD(){if(U8)return Gp.exports;U8=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(A,f,y){return Function.prototype.apply.call(A,f,y)},n;t&&typeof t.ownKeys=="function"?n=t.ownKeys:Object.getOwnPropertySymbols?n=function(A){return Object.getOwnPropertyNames(A).concat(Object.getOwnPropertySymbols(A))}:n=function(A){return Object.getOwnPropertyNames(A)};function r($){console&&console.warn&&console.warn($)}var i=Number.isNaN||function(A){return A!==A};function s(){s.init.call(this)}Gp.exports=s,Gp.exports.once=E,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a($){if(typeof $!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof $)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function($){if(typeof $!="number"||$<0||i($))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+$+".");o=$}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(A){if(typeof A!="number"||A<0||i(A))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+A+".");return this._maxListeners=A,this};function c($){return $._maxListeners===void 0?s.defaultMaxListeners:$._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(A){for(var f=[],y=1;y<arguments.length;y++)f.push(arguments[y]);var x=A==="error",C=this._events;if(C!==void 0)x=x&&C.error===void 0;else if(!x)return!1;if(x){var P;if(f.length>0&&(P=f[0]),P instanceof Error)throw P;var O=new Error("Unhandled error."+(P?" ("+P.message+")":""));throw O.context=P,O}var N=C[A];if(N===void 0)return!1;if(typeof N=="function")e(N,this,f);else for(var D=N.length,b=w(N,D),y=0;y<D;++y)e(b[y],this,f);return!0};function l($,A,f,y){var x,C,P;if(a(f),C=$._events,C===void 0?(C=$._events=Object.create(null),$._eventsCount=0):(C.newListener!==void 0&&($.emit("newListener",A,f.listener?f.listener:f),C=$._events),P=C[A]),P===void 0)P=C[A]=f,++$._eventsCount;else if(typeof P=="function"?P=C[A]=y?[f,P]:[P,f]:y?P.unshift(f):P.push(f),x=c($),x>0&&P.length>x&&!P.warned){P.warned=!0;var O=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+String(A)+" listeners added. Use emitter.setMaxListeners() to increase limit");O.name="MaxListenersExceededWarning",O.emitter=$,O.type=A,O.count=P.length,r(O)}return $}s.prototype.addListener=function(A,f){return l(this,A,f,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(A,f){return l(this,A,f,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d($,A,f){var y={fired:!1,wrapFn:void 0,target:$,type:A,listener:f},x=u.bind(y);return x.listener=f,y.wrapFn=x,x}s.prototype.once=function(A,f){return a(f),this.on(A,d(this,A,f)),this},s.prototype.prependOnceListener=function(A,f){return a(f),this.prependListener(A,d(this,A,f)),this},s.prototype.removeListener=function(A,f){var y,x,C,P,O;if(a(f),x=this._events,x===void 0)return this;if(y=x[A],y===void 0)return this;if(y===f||y.listener===f)--this._eventsCount===0?this._events=Object.create(null):(delete x[A],x.removeListener&&this.emit("removeListener",A,y.listener||f));else if(typeof y!="function"){for(C=-1,P=y.length-1;P>=0;P--)if(y[P]===f||y[P].listener===f){O=y[P].listener,C=P;break}if(C<0)return this;C===0?y.shift():g(y,C),y.length===1&&(x[A]=y[0]),x.removeListener!==void 0&&this.emit("removeListener",A,O||f)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(A){var f,y,x;if(y=this._events,y===void 0)return this;if(y.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):y[A]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete y[A]),this;if(arguments.length===0){var C=Object.keys(y),P;for(x=0;x<C.length;++x)P=C[x],P!=="removeListener"&&this.removeAllListeners(P);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(f=y[A],typeof f=="function")this.removeListener(A,f);else if(f!==void 0)for(x=f.length-1;x>=0;x--)this.removeListener(A,f[x]);return this};function h($,A,f){var y=$._events;if(y===void 0)return[];var x=y[A];return x===void 0?[]:typeof x=="function"?f?[x.listener||x]:[x]:f?m(x):w(x,x.length)}s.prototype.listeners=function(A){return h(this,A,!0)},s.prototype.rawListeners=function(A){return h(this,A,!1)},s.listenerCount=function($,A){return typeof $.listenerCount=="function"?$.listenerCount(A):p.call($,A)},s.prototype.listenerCount=p;function p($){var A=this._events;if(A!==void 0){var f=A[$];if(typeof f=="function")return 1;if(f!==void 0)return f.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function w($,A){for(var f=new Array(A),y=0;y<A;++y)f[y]=$[y];return f}function g($,A){for(;A+1<$.length;A++)$[A]=$[A+1];$.pop()}function m($){for(var A=new Array($.length),f=0;f<A.length;++f)A[f]=$[f].listener||$[f];return A}function E($,A){return new Promise(function(f,y){function x(P){$.removeListener(A,C),y(P)}function C(){typeof $.removeListener=="function"&&$.removeListener("error",x),f([].slice.call(arguments))}S($,A,C,{once:!0}),A!=="error"&&v($,x,{once:!0})})}function v($,A,f){typeof $.on=="function"&&S($,"error",A,f)}function S($,A,f,y){if(typeof $.on=="function")y.once?$.once(A,f):$.on(A,f);else if(typeof $.addEventListener=="function")$.addEventListener(A,function x(C){y.once&&$.removeEventListener(A,x),f(C)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof $)}return Gp.exports}var Ot=kD();const Yc=wo(Ot);var M8=function(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))},RD=(function(){function t(e,n,r){this.name=e,this.version=n,this.os=r,this.type="browser"}return t})(),BD=(function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t})(),DD=(function(){function t(e,n,r,i){this.name=e,this.version=n,this.os=r,this.bot=i,this.type="bot-device"}return t})(),LD=(function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t})(),UD=(function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t})(),MD=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,jD=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,j8=3,FD=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",MD]],F8=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function z8(t){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new UD:typeof navigator<"u"?qD(navigator.userAgent):WD()}function zD(t){return t!==""&&FD.reduce(function(e,n){var r=n[0],i=n[1];if(e)return e;var s=i.exec(t);return!!s&&[r,s]},!1)}function qD(t){var e=zD(t);if(!e)return null;var n=e[0],r=e[1];if(n==="searchbot")return new LD;var i=r[1]&&r[1].split(".").join("_").split("_").slice(0,3);i?i.length<j8&&(i=M8(M8([],i,!0),VD(j8-i.length),!0)):i=[];var s=i.join("."),o=HD(t),a=jD.exec(t);return a&&a[1]?new DD(n,s,o,a[1]):new RD(n,s,o)}function HD(t){for(var e=0,n=F8.length;e<n;e++){var r=F8[e],i=r[0],s=r[1],o=s.exec(t);if(o)return i}return null}function WD(){var t=typeof process<"u"&&process.version;return t?new BD(process.version.slice(1)):null}function VD(t){for(var e=[],n=0;n<t;n++)e.push("0");return e}var ew={};/*! *****************************************************************************
39
39
  Copyright (c) Microsoft Corporation.
40
40
 
41
41
  Permission to use, copy, modify, and/or distribute this software for any