@wormhole-foundation/wormhole-connect 4.0.0-beta.0-development → 4.0.0-beta.1-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/dist/assets/{aptos-CIKjhZ5R.js → aptos-CaGPw7HM.js} +2 -2
  2. package/dist/assets/create-54a95t1x.js +1 -0
  3. package/dist/assets/{evm-Ky_mCHhS.js → evm-Bv0RsFka.js} +2 -2
  4. package/dist/assets/{index-DW7sWcdW.js → index-B5JfIVKE.js} +1 -1
  5. package/dist/assets/{index-DHLr3HmO.js → index-BCD-VOiF.js} +1 -1
  6. package/dist/assets/index-BwhO0jGm.js +1 -0
  7. package/dist/assets/{index-DpM61P6H.js → index-CMULoTsT.js} +1 -1
  8. package/dist/assets/{index-DZpeOp3V.js → index-CO4HXUmy.js} +1 -1
  9. package/dist/assets/{index-Bg3NWSHL.js → index-COw2RtBx.js} +1 -1
  10. package/dist/assets/{index-DRk-Cj0P.js → index-ClrVAZUa.js} +1 -1
  11. package/dist/assets/{index-D7RgFG0F.js → index-CzQeh-hT.js} +1 -1
  12. package/dist/assets/{index-Csghphw2.js → index-DC4mZtDw.js} +1 -1
  13. package/dist/assets/{index-Cqs_fFht.js → index-DI-xN_q3.js} +1 -1
  14. package/dist/assets/{index-DVbfoP0w.js → index-DRsHBjoG.js} +1 -1
  15. package/dist/assets/{index-CdAFGcxx.js → index-DXcQbQ8r.js} +1 -1
  16. package/dist/assets/{index-DJ52h-dV.js → index-DxHhcWFS.js} +1 -1
  17. package/dist/assets/{index-g9iLhWvp.js → index-GKTf0CV7.js} +1 -1
  18. package/dist/assets/{index-DuR9wYhp.js → index-aoYIFErC.js} +1 -1
  19. package/dist/assets/{index-DfNgilHG.js → index-jixjwN_L.js} +1 -1
  20. package/dist/assets/{solana-jYIeIu4B.js → solana-DpD0VkQS.js} +2 -2
  21. package/dist/assets/{sui-B96bqBVv.js → sui-7K04yY2U.js} +2 -2
  22. package/dist/main.js +75 -75
  23. package/dist/src/components/TokenBalance.d.ts.map +1 -1
  24. package/dist/src/config/mainnet/tokens.d.ts.map +1 -1
  25. package/dist/src/config/testnet/tokens.d.ts.map +1 -1
  26. package/dist/src/contexts/wallet/WalletProvider.d.ts.map +1 -1
  27. package/dist/src/hooks/useFetchSupportedRoutes.d.ts.map +1 -1
  28. package/dist/src/hooks/useTokenListWithSearch.d.ts +1 -4
  29. package/dist/src/hooks/useTokenListWithSearch.d.ts.map +1 -1
  30. package/dist/src/routes/operator.d.ts.map +1 -1
  31. package/dist/src/routes/sdkv2/route.d.ts +2 -2
  32. package/dist/src/routes/sdkv2/route.d.ts.map +1 -1
  33. package/dist/src/telemetry/types.d.ts +1 -0
  34. package/dist/src/telemetry/types.d.ts.map +1 -1
  35. package/dist/src/utils/sdkv2.d.ts.map +1 -1
  36. package/dist/src/utils/wrappedNativeTokens.d.ts +12 -0
  37. package/dist/src/utils/wrappedNativeTokens.d.ts.map +1 -0
  38. package/dist/src/views/Terms.d.ts.map +1 -1
  39. package/dist/src/views/v2/Bridge/AssetPicker/TokenList.d.ts.map +1 -1
  40. package/dist/src/views/v3/Bridge/AssetPicker/SearchableList/index.d.ts.map +1 -1
  41. package/dist/src/views/v3/Bridge/AssetPicker/TokenList.d.ts.map +1 -1
  42. package/dist/src/views/v3/Bridge/AssetPicker/TokenSectionHeader.d.ts +2 -4
  43. package/dist/src/views/v3/Bridge/AssetPicker/TokenSectionHeader.d.ts.map +1 -1
  44. package/lib/{account-D0Q4K1CI.js → account-24z6tDMM.js} +1 -1
  45. package/lib/{account-BdDruAAr.mjs → account-BcnWVXmg.mjs} +1 -1
  46. package/lib/{address-fSXS9iww.mjs → address-BX2fIOro.mjs} +1 -1
  47. package/lib/{address-BO6rj6uK.js → address-Bc-5yO4D.js} +1 -1
  48. package/lib/{aptos-B1VSCmD9.mjs → aptos-5b4F4UXd.mjs} +4 -4
  49. package/lib/{aptos-DG7QN21P.js → aptos-B_Yz-0gh.js} +1 -1
  50. package/lib/{aptos-BnKScTtI.mjs → aptos-DO_Sexq-.mjs} +7 -7
  51. package/lib/{aptos-B3C7cnvM.js → aptos-DffuIzI0.js} +2 -2
  52. package/lib/{basic-BRYkcAmD.mjs → basic-BclwqsOq.mjs} +4 -4
  53. package/lib/{basic-CN2jAqvS.js → basic-BdiYk8Hf.js} +1 -1
  54. package/lib/{basic-DufHOLGA.js → basic-CuO6iz8a.js} +1 -1
  55. package/lib/{basic-Cw13RoYq.mjs → basic-HasHL_DG.mjs} +4 -4
  56. package/lib/{blake2b-CT6EW399.mjs → blake2b-CVpPk5O9.mjs} +1 -1
  57. package/lib/{blake2b-B_Q_lTGN.js → blake2b-DXExLbRg.js} +1 -1
  58. package/lib/{browser-ponyfill-CnfcLhK-.mjs → browser-ponyfill-DeOApqpH.mjs} +1 -1
  59. package/lib/{browser-ponyfill-DbGoEOBo.js → browser-ponyfill-VhIu9z_I.js} +1 -1
  60. package/lib/{chain-BCKkYvDb.js → chain-BxNUWKZE.js} +1 -1
  61. package/lib/{chain-_dXKRkCE.mjs → chain-CvZsIsLh.mjs} +1 -1
  62. package/lib/{chunk-KJH4KKG6-RA0hChr8.mjs → chunk-KJH4KKG6-BgebMATq.mjs} +2 -2
  63. package/lib/{chunk-KJH4KKG6-BXBLZwfY.js → chunk-KJH4KKG6-DNlN4p21.js} +1 -1
  64. package/lib/{constants-QsbOfMbk.mjs → constants-DnbaS3cF.mjs} +3 -3
  65. package/lib/constants-abC7FLXq.js +1 -0
  66. package/lib/{contract-MkLF5rqi.js → contract-CTycrpaK.js} +1 -1
  67. package/lib/{contract-C_4H8x77.mjs → contract-KYuIk_vR.mjs} +1 -1
  68. package/lib/{core-Cpb3gtg_.js → core-COM78LTW.js} +3 -3
  69. package/lib/{core-ntLR7o2S.mjs → core-DT_3gIqi.mjs} +6 -6
  70. package/lib/{create-naslyPfU.mjs → create-BvzkkBPW.mjs} +1 -1
  71. package/lib/{create-CfgTxAS-.js → create-CGZYy2vu.js} +1 -1
  72. package/lib/{evm-C6xp3v8Z.mjs → evm-CUR4-a7F.mjs} +9 -9
  73. package/lib/{evm-B3G2Vkzg.js → evm-CoLwXequ.js} +2 -2
  74. package/lib/{evm-B20n3mf_.mjs → evm-DoVrPE_X.mjs} +7 -7
  75. package/lib/{evm-aSG_vFbw.js → evm-Dv-WYu07.js} +2 -2
  76. package/lib/executor.js +1 -1
  77. package/lib/executor.mjs +815 -572
  78. package/lib/hosted.js +1 -1
  79. package/lib/hosted.mjs +1 -1
  80. package/lib/{index-DSmKiYkD.mjs → index-B1KwS33G.mjs} +5 -5
  81. package/lib/{index-vhQ5Q8ov.mjs → index-B2sVzSwb.mjs} +52 -97
  82. package/lib/{index-Bz7ogqhR.mjs → index-B3idKQJG.mjs} +1 -1
  83. package/lib/index-B7Afz_5P.js +1 -0
  84. package/lib/{index-Dq7WWqFe.js → index-B7HBnPLP.js} +1 -1
  85. package/lib/{index-DQX74QAE.js → index-BFBwRlid.js} +1 -1
  86. package/lib/{index-C6XNAQ4w.js → index-BZZZ8OeS.js} +1 -1
  87. package/lib/{index-C3LC73WN.js → index-BaYN-RHF.js} +1 -1
  88. package/lib/{index-BTUx12aa.js → index-Bhwzpq1T.js} +1 -1
  89. package/lib/{index-MsaML_Ju.mjs → index-Bicx897u.mjs} +2 -2
  90. package/lib/{index-Dajw3Alx.mjs → index-BlWksu-f.mjs} +1 -1
  91. package/lib/{index-DS8bl8fA.mjs → index-Bn0hkKKz.mjs} +4 -4
  92. package/lib/{index-BojkMsXD.js → index-BoKTcLq-.js} +1 -1
  93. package/lib/{index-BRYq_Nt2.mjs → index-Bp4ojxz6.mjs} +4 -4
  94. package/lib/{index-Cnznwcdb.js → index-BqabgGIh.js} +1 -1
  95. package/lib/{index-DxYgNWMY.mjs → index-BtEjOWoP.mjs} +3 -3
  96. package/lib/{index-BJcbyvof.js → index-C8HxYDNY.js} +1 -1
  97. package/lib/{index-Bhd_YhUf.js → index-C9Bk-rKp.js} +1 -1
  98. package/lib/{index-YAL4zolc.js → index-C9uGqcwH.js} +1 -1
  99. package/lib/{index-BQvEIlB2.mjs → index-CBGUPQXa.mjs} +3 -3
  100. package/lib/{index-IHxtA-NL.js → index-CGpn3INM.js} +1 -1
  101. package/lib/{index-BRyW-hBN.mjs → index-CTpINVAG.mjs} +2 -2
  102. package/lib/{index-bNUantLb.js → index-CjjP3Qp5.js} +1 -1
  103. package/lib/{index-CU73EUQW.js → index-CkGYgQTz.js} +1 -1
  104. package/lib/{index-DqzqJgVc.mjs → index-CkvxfaqA.mjs} +3 -3
  105. package/lib/{index-DfDB5FLw.js → index-ClMpLrxa.js} +1 -1
  106. package/lib/{index-B7VNYedX.mjs → index-CtU_hkYp.mjs} +4 -4
  107. package/lib/{index-DMOY218i.js → index-CzRVzbTC.js} +1 -1
  108. package/lib/{index-B4S4sz6p.mjs → index-Czxl_5Tr.mjs} +5 -5
  109. package/lib/{index-D0XQIiQn.js → index-D6qJDbzm.js} +1 -1
  110. package/lib/{index-D-H8WyKb.mjs → index-DGzoIr_I.mjs} +1 -1
  111. package/lib/{index-BD0gcmCp.mjs → index-DPpi4Don.mjs} +5 -5
  112. package/lib/{index-7_BfcP8x.mjs → index-DZaOh3F9.mjs} +2105 -2021
  113. package/lib/{index-QlIJYJce.js → index-DaY7_eQ6.js} +66 -66
  114. package/lib/{index-C3L-xKvN.mjs → index-DlmQ0_RF.mjs} +4839 -4850
  115. package/lib/{index-D5ENAOm3.js → index-DmsirrTI.js} +1 -1
  116. package/lib/{index-DnO0ZdKy.mjs → index-DpN0dULN.mjs} +1 -1
  117. package/lib/{index-BNuKzxGJ.js → index-DydXCN0v.js} +1 -1
  118. package/lib/{index-CSMunRpZ.mjs → index-NKV6j8zE.mjs} +3 -3
  119. package/lib/{index-BIYx5IBr.mjs → index-OlMuNft9.mjs} +3 -3
  120. package/lib/{index-tztRp3yJ.js → index-P9DbJOzh.js} +1 -1
  121. package/lib/{index-D1y-l93C.js → index-UbeUI3Ir.js} +1 -1
  122. package/lib/{index-BZYEbYGY.mjs → index-ZGgSxaDf.mjs} +3 -3
  123. package/lib/{index-DFpSbD7R.mjs → index-_e8uUnEK.mjs} +5 -5
  124. package/lib/{index-Cb9lswnP.js → index-cCBQV2Yv.js} +8 -8
  125. package/lib/{index-B9ybSY9R.mjs → index-cggXdVJu.mjs} +5 -5
  126. package/lib/{index.es-C476iHvN.mjs → index.es-5ecqX8B9.mjs} +4 -4
  127. package/lib/{index.es-CU6nhwJO.js → index.es-LBG64XJ6.js} +1 -1
  128. package/lib/{index.es-CkGpObng.js → index.es-owVcNlof.js} +3 -3
  129. package/lib/{index.es-CtiAoQ78.mjs → index.es-zNH_KzcH.mjs} +3 -3
  130. package/lib/index.js +1 -1
  131. package/lib/index.mjs +5 -5
  132. package/lib/mayan.js +1 -1
  133. package/lib/mayan.mjs +11 -11
  134. package/lib/{mint-zy6P38iu.js → mint-B4t2SvV6.js} +1 -1
  135. package/lib/{mint-DyoU9X22.mjs → mint-BGuU5y5m.mjs} +1 -1
  136. package/lib/ntt.js +1 -1
  137. package/lib/ntt.mjs +14 -12
  138. package/lib/{platform-x3ZBJ0YM.js → platform-Bkbg7A9d.js} +1 -1
  139. package/lib/{platform-BqpAMtgx.mjs → platform-C5gJAqtZ.mjs} +3 -3
  140. package/lib/{platform-BhspUaMJ.js → platform-C6QB7aIN.js} +1 -1
  141. package/lib/{platform-DQfpyXSV.mjs → platform-DBNvSsue.mjs} +4 -4
  142. package/lib/{platform-BHAZvZ_O.mjs → platform-DtB8gGMl.mjs} +4 -4
  143. package/lib/{platform-4nANkJAM.js → platform-qdbxkhTI.js} +1 -1
  144. package/lib/{provider-jsonrpc-DIXcAw4Q.mjs → provider-jsonrpc-BIIDy-Aw.mjs} +2 -2
  145. package/lib/{provider-jsonrpc-BCKoIijx.js → provider-jsonrpc-DHzam3ud.js} +1 -1
  146. package/lib/{secp256k1-CaaRyr2C.mjs → secp256k1-BF6Vm50D.mjs} +1 -1
  147. package/lib/{secp256k1-C60XBS-e.js → secp256k1-Bb6lbAjK.js} +1 -1
  148. package/lib/{secp256k1-UnRv5Suy.mjs → secp256k1-BfK5OWRP.mjs} +1 -1
  149. package/lib/{secp256k1-BWFGSbjt.mjs → secp256k1-CqT-a-I8.mjs} +1 -1
  150. package/lib/{secp256k1-CFt7TfEF.js → secp256k1-DRTQ6WrU.js} +1 -1
  151. package/lib/{secp256k1-BIiWvuxu.js → secp256k1-D_GNj8sK.js} +1 -1
  152. package/lib/{signer-DhO2iGae.mjs → signer-BH3gAHuj.mjs} +2 -2
  153. package/lib/{signer-BFY1Ytf6.js → signer-MBixef_P.js} +1 -1
  154. package/lib/{solana-CQk4ocg8.mjs → solana-C1puc64V.mjs} +11 -11
  155. package/lib/solana-C8xK8qJY.mjs +18 -0
  156. package/lib/solana-CRSliekb.js +1 -0
  157. package/lib/{solana-Cp49k9--.js → solana-CtBdJ6Wt.js} +4 -4
  158. package/lib/{solanaEmbed.esm-Cwa6cl_R.js → solanaEmbed.esm-BpIKVhXq.js} +1 -1
  159. package/lib/{solanaEmbed.esm-DBOqO9Ii.mjs → solanaEmbed.esm-NdE_DQuw.mjs} +3 -3
  160. package/lib/src/components/TokenBalance.d.ts.map +1 -1
  161. package/lib/src/config/mainnet/tokens.d.ts.map +1 -1
  162. package/lib/src/config/testnet/tokens.d.ts.map +1 -1
  163. package/lib/src/contexts/wallet/WalletProvider.d.ts.map +1 -1
  164. package/lib/src/hooks/useFetchSupportedRoutes.d.ts.map +1 -1
  165. package/lib/src/hooks/useTokenListWithSearch.d.ts +1 -4
  166. package/lib/src/hooks/useTokenListWithSearch.d.ts.map +1 -1
  167. package/lib/src/routes/operator.d.ts.map +1 -1
  168. package/lib/src/routes/sdkv2/route.d.ts +2 -2
  169. package/lib/src/routes/sdkv2/route.d.ts.map +1 -1
  170. package/lib/src/telemetry/types.d.ts +1 -0
  171. package/lib/src/telemetry/types.d.ts.map +1 -1
  172. package/lib/src/utils/sdkv2.d.ts.map +1 -1
  173. package/lib/src/utils/wrappedNativeTokens.d.ts +12 -0
  174. package/lib/src/utils/wrappedNativeTokens.d.ts.map +1 -0
  175. package/lib/src/views/Terms.d.ts.map +1 -1
  176. package/lib/src/views/v2/Bridge/AssetPicker/TokenList.d.ts.map +1 -1
  177. package/lib/src/views/v3/Bridge/AssetPicker/SearchableList/index.d.ts.map +1 -1
  178. package/lib/src/views/v3/Bridge/AssetPicker/TokenList.d.ts.map +1 -1
  179. package/lib/src/views/v3/Bridge/AssetPicker/TokenSectionHeader.d.ts +2 -4
  180. package/lib/src/views/v3/Bridge/AssetPicker/TokenSectionHeader.d.ts.map +1 -1
  181. package/lib/{sui-C2a1eehP.mjs → sui-BW7tMLZs.mjs} +4 -4
  182. package/lib/{sui-9gsoM56W.js → sui-DdujB9Bc.js} +1 -1
  183. package/lib/{sui-Cr98JBgS.js → sui-QcDjGW68.js} +1 -1
  184. package/lib/{sui-B4RvzEXx.mjs → sui-euceXgYf.mjs} +7 -7
  185. package/lib/{tokens-BbFKf6Hv.mjs → tokens-DI-tPIbd.mjs} +3 -3
  186. package/lib/{tokens-LVHsSbYG.js → tokens-DJos2DwM.js} +1 -1
  187. package/lib/{transfer-DZ-wNocj.js → transfer-BinEH6ml.js} +1 -1
  188. package/lib/{transfer-BV1ou1GP.mjs → transfer-DTvv5m_5.mjs} +2 -2
  189. package/lib/{units-BqUlbZ46.mjs → units-CVEv4txp.mjs} +2 -2
  190. package/lib/{units-D-oRQjOa.js → units-DtldPRXy.js} +1 -1
  191. package/lib/{unsignedTransaction-BmxD6VsY.mjs → unsignedTransaction-CVE7GUdC.mjs} +3 -3
  192. package/lib/{unsignedTransaction-CiPKh85X.js → unsignedTransaction-DL3WyIkF.js} +1 -1
  193. package/lib/{w3m-modal-3qLkbPfi.mjs → w3m-modal-B2VF8j7W.mjs} +2 -2
  194. package/lib/{w3m-modal-D4-nrnEK.mjs → w3m-modal-C32eQxEe.mjs} +2 -2
  195. package/lib/{w3m-modal-CoTG8Zu4.js → w3m-modal-DSY2qJYP.js} +1 -1
  196. package/lib/{w3m-modal-xqVExHU-.js → w3m-modal-DgqSQLqZ.js} +1 -1
  197. package/lib/{web3-C1wK6wIV.js → web3-BKaP497Y.js} +1 -1
  198. package/lib/{web3-BkEb7AgB.mjs → web3-BifDBsFp.mjs} +8 -4
  199. package/package.json +49 -44
  200. package/dist/assets/create-q7V6muDT.js +0 -1
  201. package/dist/assets/index-B59bCuJJ.js +0 -1
  202. package/lib/constants-BR_zyzqY.js +0 -1
  203. package/lib/index-CXsUtRJQ.js +0 -1
  204. package/lib/solana-Dv_mUYcl.mjs +0 -18
  205. package/lib/solana-g3YsP966.js +0 -1
@@ -1,4 +1,4 @@
1
- const a = "https://wormholescan.io/#/", o = "4.0.0-beta.0-development", e = "6117514f4ab7bb8b1a257d2658b16c218aea6eb8", n = [
1
+ const a = "https://wormholescan.io/#/", e = "4.0.0-beta.1-development", o = "674e14e5c4ad5063e9a56fee10ff23601b7a1858", n = [
2
2
  "Ethereum",
3
3
  "Solana",
4
4
  "Arbitrum",
@@ -21,8 +21,8 @@ const a = "https://wormholescan.io/#/", o = "4.0.0-beta.0-development", e = "611
21
21
  "HyperEVM"
22
22
  ];
23
23
  export {
24
- e as C,
24
+ o as C,
25
25
  a as W,
26
- o as a,
26
+ e as a,
27
27
  n as b
28
28
  };
@@ -0,0 +1 @@
1
+ "use strict";const e="https://wormholescan.io/#/",o="4.0.0-beta.1-development",a="674e14e5c4ad5063e9a56fee10ff23601b7a1858",n=["Ethereum","Solana","Arbitrum","Base","Sui","Bsc","Optimism","Unichain","Fantom","Polygon","Avalanche","Celo","Moonbeam","Klaytn","Scroll","Mantle","Berachain","Mezo","Fogo","HyperEVM"];exports.CHAIN_ORDER=n;exports.CONNECT_GIT_HASH=a;exports.CONNECT_VERSION=o;exports.WORMSCAN=e;
@@ -1 +1 @@
1
- "use strict";const o=require("./web3-C1wK6wIV.js"),gt=BigInt(0),B=BigInt(1),tt=9007199254740991;function ee(s,t){const e=mt(s,"value"),n=BigInt(L(t,"width"));if(o.assert(e>>n===gt,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:s}),e>>n-B){const r=(B<<n)-B;return-((~e&r)+B)}return e}function ne(s,t){let e=H(s,"value");const n=BigInt(L(t,"width")),r=B<<n-B;if(e<gt){e=-e,o.assert(e<=r,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:s});const i=(B<<n)-B;return(~e&i)+B}else o.assert(e<r,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:s});return e}function at(s,t){const e=mt(s,"value"),n=BigInt(L(t,"bits"));return e&(B<<n)-B}function H(s,t){switch(typeof s){case"bigint":return s;case"number":return o.assertArgument(Number.isInteger(s),"underflow",t||"value",s),o.assertArgument(s>=-tt&&s<=tt,"overflow",t||"value",s),BigInt(s);case"string":try{if(s==="")throw new Error("empty string");return s[0]==="-"&&s[1]!=="-"?-BigInt(s.substring(1)):BigInt(s)}catch(e){o.assertArgument(!1,`invalid BigNumberish string: ${e.message}`,t||"value",s)}}o.assertArgument(!1,"invalid BigNumberish value",t||"value",s)}function mt(s,t){const e=H(s,t);return o.assert(e>=gt,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:s}),e}const Lt="0123456789abcdef";function Tt(s){if(s instanceof Uint8Array){let t="0x0";for(const e of s)t+=Lt[e>>4],t+=Lt[e&15];return BigInt(t)}return H(s)}function L(s,t){switch(typeof s){case"bigint":return o.assertArgument(s>=-tt&&s<=tt,"overflow",t||"value",s),Number(s);case"number":return o.assertArgument(Number.isInteger(s),"underflow",t||"value",s),o.assertArgument(s>=-tt&&s<=tt,"overflow",t||"value",s),s;case"string":try{if(s==="")throw new Error("empty string");return L(BigInt(s),t)}catch(e){o.assertArgument(!1,`invalid numeric string: ${e.message}`,t||"value",s)}}o.assertArgument(!1,"invalid numeric value",t||"value",s)}function Se(s){return L(Tt(s))}function Rt(s,t){let n=mt(s,"value").toString(16);if(t==null)n.length%2&&(n="0"+n);else{const r=L(t,"width");for(o.assert(r*2>=n.length,`value exceeds width (${r} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:s});n.length<r*2;)n="0"+n}return"0x"+n}function kt(s){const t=mt(s,"value");if(t===gt)return new Uint8Array([]);let e=t.toString(16);e.length%2&&(e="0"+e);const n=new Uint8Array(e.length/2);for(let r=0;r<n.length;r++){const i=r*2;n[r]=parseInt(e.substring(i,i+2),16)}return n}function Ce(s){let t=o.hexlify(o.isBytesLike(s)?s:kt(s)).substring(2);for(;t.startsWith("0");)t=t.substring(1);return t===""&&(t="0"),"0x"+t}class re{filter;emitter;#t;constructor(t,e,n){this.#t=e,o.defineProperties(this,{emitter:t,filter:n})}async removeListener(){this.#t!=null&&await this.emitter.off(this.filter,this.#t)}}function Fe(s,t,e,n,r){o.assertArgument(!1,`invalid codepoint at offset ${t}; ${s}`,"bytes",e)}function se(s,t,e,n,r){if(s==="BAD_PREFIX"||s==="UNEXPECTED_CONTINUE"){let i=0;for(let a=t+1;a<e.length&&e[a]>>6===2;a++)i++;return i}return s==="OVERRUN"?e.length-t-1:0}function Le(s,t,e,n,r){return s==="OVERLONG"?(o.assertArgument(typeof r=="number","invalid bad code point for replacement","badCodepoint",r),n.push(r),0):(n.push(65533),se(s,t,e))}const De=Object.freeze({error:Fe,ignore:se,replace:Le});function $e(s,t){t==null&&(t=De.error);const e=o.getBytes(s,"bytes"),n=[];let r=0;for(;r<e.length;){const i=e[r++];if(i>>7===0){n.push(i);continue}let a=null,c=null;if((i&224)===192)a=1,c=127;else if((i&240)===224)a=2,c=2047;else if((i&248)===240)a=3,c=65535;else{(i&192)===128?r+=t("UNEXPECTED_CONTINUE",r-1,e,n):r+=t("BAD_PREFIX",r-1,e,n);continue}if(r-1+a>=e.length){r+=t("OVERRUN",r-1,e,n);continue}let u=i&(1<<8-a-1)-1;for(let l=0;l<a;l++){let f=e[r];if((f&192)!=128){r+=t("MISSING_CONTINUE",r,e,n),u=null;break}u=u<<6|f&63,r++}if(u!==null){if(u>1114111){r+=t("OUT_OF_RANGE",r-1-a,e,n,u);continue}if(u>=55296&&u<=57343){r+=t("UTF16_SURROGATE",r-1-a,e,n,u);continue}if(u<=c){r+=t("OVERLONG",r-1-a,e,n,u);continue}n.push(u)}}return n}function Ut(s,t){o.assertArgument(typeof s=="string","invalid string value","str",s),t!=null&&(o.assertNormalize(t),s=s.normalize(t));let e=[];for(let n=0;n<s.length;n++){const r=s.charCodeAt(n);if(r<128)e.push(r);else if(r<2048)e.push(r>>6|192),e.push(r&63|128);else if((r&64512)==55296){n++;const i=s.charCodeAt(n);o.assertArgument(n<s.length&&(i&64512)===56320,"invalid surrogate pair","str",s);const a=65536+((r&1023)<<10)+(i&1023);e.push(a>>18|240),e.push(a>>12&63|128),e.push(a>>6&63|128),e.push(a&63|128)}else e.push(r>>12|224),e.push(r>>6&63|128),e.push(r&63|128)}return new Uint8Array(e)}function Ge(s){return s.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function ie(s,t){return Ge($e(s,t))}const v=32,Pt=new Uint8Array(v),_e=["then"],ft={},ae=new WeakMap;function Y(s){return ae.get(s)}function Dt(s,t){ae.set(s,t)}function it(s,t){const e=new Error(`deferred error during ABI decoding triggered accessing ${s}`);throw e.error=t,e}function At(s,t,e){return s.indexOf(null)>=0?t.map((n,r)=>n instanceof G?At(Y(n),n,e):n):s.reduce((n,r,i)=>{let a=t.getValue(r);return r in n||(e&&a instanceof G&&(a=At(Y(a),a,e)),n[r]=a),n},{})}class G extends Array{#t;constructor(...t){const e=t[0];let n=t[1],r=(t[2]||[]).slice(),i=!0;e!==ft&&(n=t,r=[],i=!1),super(n.length),n.forEach((u,l)=>{this[l]=u});const a=r.reduce((u,l)=>(typeof l=="string"&&u.set(l,(u.get(l)||0)+1),u),new Map);if(Dt(this,Object.freeze(n.map((u,l)=>{const f=r[l];return f!=null&&a.get(f)===1?f:null}))),this.#t=[],this.#t==null&&this.#t,!i)return;Object.freeze(this);const c=new Proxy(this,{get:(u,l,f)=>{if(typeof l=="string"){if(l.match(/^[0-9]+$/)){const d=L(l,"%index");if(d<0||d>=this.length)throw new RangeError("out of result range");const g=u[d];return g instanceof Error&&it(`index ${d}`,g),g}if(_e.indexOf(l)>=0)return Reflect.get(u,l,f);const h=u[l];if(h instanceof Function)return function(...d){return h.apply(this===f?u:this,d)};if(!(l in u))return u.getValue.apply(this===f?u:this,[l])}return Reflect.get(u,l,f)}});return Dt(c,Y(this)),c}toArray(t){const e=[];return this.forEach((n,r)=>{n instanceof Error&&it(`index ${r}`,n),t&&n instanceof G&&(n=n.toArray(t)),e.push(n)}),e}toObject(t){const e=Y(this);return e.reduce((n,r,i)=>(o.assert(r!=null,`value at index ${i} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),At(e,this,t)),{})}slice(t,e){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),e==null&&(e=this.length),e<0&&(e+=this.length,e<0&&(e=0)),e>this.length&&(e=this.length);const n=Y(this),r=[],i=[];for(let a=t;a<e;a++)r.push(this[a]),i.push(n[a]);return new G(ft,r,i)}filter(t,e){const n=Y(this),r=[],i=[];for(let a=0;a<this.length;a++){const c=this[a];c instanceof Error&&it(`index ${a}`,c),t.call(e,c,a,this)&&(r.push(c),i.push(n[a]))}return new G(ft,r,i)}map(t,e){const n=[];for(let r=0;r<this.length;r++){const i=this[r];i instanceof Error&&it(`index ${r}`,i),n.push(t.call(e,i,r,this))}return n}getValue(t){const e=Y(this).indexOf(t);if(e===-1)return;const n=this[e];return n instanceof Error&&it(`property ${JSON.stringify(t)}`,n.error),n}static fromItems(t,e){return new G(ft,t,e)}}function $t(s){let t=kt(s);return o.assert(t.length<=v,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:v,offset:t.length}),t.length!==v&&(t=o.getBytesCopy(o.concat([Pt.slice(t.length%v),t]))),t}class z{name;type;localName;dynamic;constructor(t,e,n,r){o.defineProperties(this,{name:t,type:e,localName:n,dynamic:r},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){o.assertArgument(!1,t,this.localName,e)}}class Nt{#t;#e;constructor(){this.#t=[],this.#e=0}get data(){return o.concat(this.#t)}get length(){return this.#e}#n(t){return this.#t.push(t),this.#e+=t.length,t.length}appendWriter(t){return this.#n(o.getBytesCopy(t.data))}writeBytes(t){let e=o.getBytesCopy(t);const n=e.length%v;return n&&(e=o.getBytesCopy(o.concat([e,Pt.slice(n)]))),this.#n(e)}writeValue(t){return this.#n($t(t))}writeUpdatableValue(){const t=this.#t.length;return this.#t.push(Pt),this.#e+=v,e=>{this.#t[t]=$t(e)}}}class It{allowLoose;#t;#e;#n;#r;#s;constructor(t,e,n){o.defineProperties(this,{allowLoose:!!e}),this.#t=o.getBytesCopy(t),this.#n=0,this.#r=null,this.#s=n??1024,this.#e=0}get data(){return o.hexlify(this.#t)}get dataLength(){return this.#t.length}get consumed(){return this.#e}get bytes(){return new Uint8Array(this.#t)}#i(t){if(this.#r)return this.#r.#i(t);this.#n+=t,o.assert(this.#s<1||this.#n<=this.#s*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#s} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:o.getBytesCopy(this.#t),offset:this.#e,length:t,info:{bytesRead:this.#n,dataLength:this.dataLength}})}#a(t,e,n){let r=Math.ceil(e/v)*v;return this.#e+r>this.#t.length&&(this.allowLoose&&n&&this.#e+e<=this.#t.length?r=e:o.assert(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:o.getBytesCopy(this.#t),length:this.#t.length,offset:this.#e+r})),this.#t.slice(this.#e,this.#e+r)}subReader(t){const e=new It(this.#t.slice(this.#e+t),this.allowLoose,this.#s);return e.#r=this,e}readBytes(t,e){let n=this.#a(0,t,!!e);return this.#i(t),this.#e+=n.length,n.slice(0,t)}readValue(){return Tt(this.readBytes(v))}readIndex(){return Se(this.readBytes(v))}}const D={};function p(s,t){let e=!1;return t<0&&(e=!0,t*=-1),new A(D,`${e?"":"u"}int${t}`,s,{signed:e,width:t})}function m(s,t){return new A(D,`bytes${t||""}`,s,{size:t})}const Gt=Symbol.for("_ethers_typed");class A{type;value;#t;_typedSymbol;constructor(t,e,n,r){r==null&&(r=null),o.assertPrivate(D,t,"Typed"),o.defineProperties(this,{_typedSymbol:Gt,type:e,value:n}),this.#t=r,this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(t=>t.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return this.#t}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return this.#t===!0?-1:this.#t===!1?this.value.length:null}static from(t,e){return new A(D,t,e)}static uint8(t){return p(t,8)}static uint16(t){return p(t,16)}static uint24(t){return p(t,24)}static uint32(t){return p(t,32)}static uint40(t){return p(t,40)}static uint48(t){return p(t,48)}static uint56(t){return p(t,56)}static uint64(t){return p(t,64)}static uint72(t){return p(t,72)}static uint80(t){return p(t,80)}static uint88(t){return p(t,88)}static uint96(t){return p(t,96)}static uint104(t){return p(t,104)}static uint112(t){return p(t,112)}static uint120(t){return p(t,120)}static uint128(t){return p(t,128)}static uint136(t){return p(t,136)}static uint144(t){return p(t,144)}static uint152(t){return p(t,152)}static uint160(t){return p(t,160)}static uint168(t){return p(t,168)}static uint176(t){return p(t,176)}static uint184(t){return p(t,184)}static uint192(t){return p(t,192)}static uint200(t){return p(t,200)}static uint208(t){return p(t,208)}static uint216(t){return p(t,216)}static uint224(t){return p(t,224)}static uint232(t){return p(t,232)}static uint240(t){return p(t,240)}static uint248(t){return p(t,248)}static uint256(t){return p(t,256)}static uint(t){return p(t,256)}static int8(t){return p(t,-8)}static int16(t){return p(t,-16)}static int24(t){return p(t,-24)}static int32(t){return p(t,-32)}static int40(t){return p(t,-40)}static int48(t){return p(t,-48)}static int56(t){return p(t,-56)}static int64(t){return p(t,-64)}static int72(t){return p(t,-72)}static int80(t){return p(t,-80)}static int88(t){return p(t,-88)}static int96(t){return p(t,-96)}static int104(t){return p(t,-104)}static int112(t){return p(t,-112)}static int120(t){return p(t,-120)}static int128(t){return p(t,-128)}static int136(t){return p(t,-136)}static int144(t){return p(t,-144)}static int152(t){return p(t,-152)}static int160(t){return p(t,-160)}static int168(t){return p(t,-168)}static int176(t){return p(t,-176)}static int184(t){return p(t,-184)}static int192(t){return p(t,-192)}static int200(t){return p(t,-200)}static int208(t){return p(t,-208)}static int216(t){return p(t,-216)}static int224(t){return p(t,-224)}static int232(t){return p(t,-232)}static int240(t){return p(t,-240)}static int248(t){return p(t,-248)}static int256(t){return p(t,-256)}static int(t){return p(t,-256)}static bytes1(t){return m(t,1)}static bytes2(t){return m(t,2)}static bytes3(t){return m(t,3)}static bytes4(t){return m(t,4)}static bytes5(t){return m(t,5)}static bytes6(t){return m(t,6)}static bytes7(t){return m(t,7)}static bytes8(t){return m(t,8)}static bytes9(t){return m(t,9)}static bytes10(t){return m(t,10)}static bytes11(t){return m(t,11)}static bytes12(t){return m(t,12)}static bytes13(t){return m(t,13)}static bytes14(t){return m(t,14)}static bytes15(t){return m(t,15)}static bytes16(t){return m(t,16)}static bytes17(t){return m(t,17)}static bytes18(t){return m(t,18)}static bytes19(t){return m(t,19)}static bytes20(t){return m(t,20)}static bytes21(t){return m(t,21)}static bytes22(t){return m(t,22)}static bytes23(t){return m(t,23)}static bytes24(t){return m(t,24)}static bytes25(t){return m(t,25)}static bytes26(t){return m(t,26)}static bytes27(t){return m(t,27)}static bytes28(t){return m(t,28)}static bytes29(t){return m(t,29)}static bytes30(t){return m(t,30)}static bytes31(t){return m(t,31)}static bytes32(t){return m(t,32)}static address(t){return new A(D,"address",t)}static bool(t){return new A(D,"bool",!!t)}static bytes(t){return new A(D,"bytes",t)}static string(t){return new A(D,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new A(D,"overrides",Object.assign({},t))}static isTyped(t){return t&&typeof t=="object"&&"_typedSymbol"in t&&t._typedSymbol===Gt}static dereference(t,e){if(A.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}}class Ve extends z{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let n=A.dereference(e,"string");try{n=o.getAddress(n)}catch(r){return this._throwError(r.message,e)}return t.writeValue(n)}decode(t){return o.getAddress(Rt(t.readValue(),20))}}class Me extends z{coder;constructor(t){super(t.name,t.type,"_",t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function oe(s,t,e){let n=[];if(Array.isArray(e))n=e;else if(e&&typeof e=="object"){let u={};n=t.map(l=>{const f=l.localName;return o.assert(f,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:e}),o.assert(!u[f],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:e}),u[f]=!0,e[f]})}else o.assertArgument(!1,"invalid tuple value","tuple",e);o.assertArgument(t.length===n.length,"types/value length mismatch","tuple",e);let r=new Nt,i=new Nt,a=[];t.forEach((u,l)=>{let f=n[l];if(u.dynamic){let h=i.length;u.encode(i,f);let d=r.writeUpdatableValue();a.push(g=>{d(g+h)})}else u.encode(r,f)}),a.forEach(u=>{u(r.length)});let c=s.appendWriter(r);return c+=s.appendWriter(i),c}function ce(s,t){let e=[],n=[],r=s.subReader(0);return t.forEach(i=>{let a=null;if(i.dynamic){let c=s.readIndex(),u=r.subReader(c);try{a=i.decode(u)}catch(l){if(o.isError(l,"BUFFER_OVERRUN"))throw l;a=l,a.baseType=i.name,a.name=i.localName,a.type=i.type}}else try{a=i.decode(s)}catch(c){if(o.isError(c,"BUFFER_OVERRUN"))throw c;a=c,a.baseType=i.name,a.name=i.localName,a.type=i.type}if(a==null)throw new Error("investigate");e.push(a),n.push(i.localName||null)}),G.fromItems(e,n)}class He extends z{coder;length;constructor(t,e,n){const r=t.type+"["+(e>=0?e:"")+"]",i=e===-1||t.dynamic;super("array",r,n,i),o.defineProperties(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let n=0;n<this.length;n++)e.push(t);return e}encode(t,e){const n=A.dereference(e,"array");Array.isArray(n)||this._throwError("expected array value",n);let r=this.length;r===-1&&(r=n.length,t.writeValue(n.length)),o.assertArgumentCount(n.length,r,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let a=0;a<n.length;a++)i.push(this.coder);return oe(t,i,n)}decode(t){let e=this.length;e===-1&&(e=t.readIndex(),o.assert(e*v<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*v,length:t.dataLength}));let n=[];for(let r=0;r<e;r++)n.push(new Me(this.coder));return ce(t,n)}}class ze extends z{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const n=A.dereference(e,"bool");return t.writeValue(n?1:0)}decode(t){return!!t.readValue()}}class ue extends z{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=o.getBytesCopy(e);let n=t.writeValue(e.length);return n+=t.writeBytes(e),n}decode(t){return t.readBytes(t.readIndex(),!0)}}class Je extends ue{constructor(t){super("bytes",t)}decode(t){return o.hexlify(super.decode(t))}}class Ke extends z{size;constructor(t,e){let n="bytes"+String(t);super(n,n,e,!1),o.defineProperties(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,e){let n=o.getBytesCopy(A.dereference(e,this.type));return n.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(n)}decode(t){return o.hexlify(t.readBytes(this.size))}}const We=new Uint8Array([]);class Ye extends z{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return e!=null&&this._throwError("not null",e),t.writeBytes(We)}decode(t){return t.readBytes(0),null}}const Xe=BigInt(0),Ze=BigInt(1),Qe=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class qe extends z{size;signed;constructor(t,e,n){const r=(e?"int":"uint")+t*8;super(r,r,n,!1),o.defineProperties(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let n=H(A.dereference(e,this.type)),r=at(Qe,v*8);if(this.signed){let i=at(r,this.size*8-1);(n>i||n<-(i+Ze))&&this._throwError("value out-of-bounds",e),n=ne(n,8*v)}else(n<Xe||n>at(r,this.size*8))&&this._throwError("value out-of-bounds",e);return t.writeValue(n)}decode(t){let e=at(t.readValue(),this.size*8);return this.signed&&(e=ee(e,this.size*8)),e}}class je extends ue{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Ut(A.dereference(e,"string")))}decode(t){return ie(super.decode(t))}}class ht extends z{coders;constructor(t,e){let n=!1;const r=[];t.forEach(a=>{a.dynamic&&(n=!0),r.push(a.type)});const i="tuple("+r.join(",")+")";super("tuple",i,e,n),o.defineProperties(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(n=>{t.push(n.defaultValue())});const e=this.coders.reduce((n,r)=>{const i=r.localName;return i&&(n[i]||(n[i]=0),n[i]++),n},{});return this.coders.forEach((n,r)=>{let i=n.localName;!i||e[i]!==1||(i==="length"&&(i="_length"),t[i]==null&&(t[i]=t[r]))}),Object.freeze(t)}encode(t,e){const n=A.dereference(e,"tuple");return oe(t,this.coders,n)}decode(t){return ce(t,this.coders)}}function rt(s){return o.keccak256(Ut(s))}function Et(s,t){return{address:o.getAddress(s),storageKeys:t.map((e,n)=>(o.assertArgument(o.isHexString(e,32),"invalid slot",`storageKeys[${n}]`,e),e.toLowerCase()))}}function le(s){if(Array.isArray(s))return s.map((e,n)=>Array.isArray(e)?(o.assertArgument(e.length===2,"invalid slot set",`value[${n}]`,e),Et(e[0],e[1])):(o.assertArgument(e!=null&&typeof e=="object","invalid address-slot set","value",s),Et(e.address,e.storageKeys)));o.assertArgument(s!=null&&typeof s=="object","invalid access list","value",s);const t=Object.keys(s).map(e=>{const n=s[e].reduce((r,i)=>(r[i]=!0,r),{});return Et(e,Object.keys(n).sort())});return t.sort((e,n)=>e.address.localeCompare(n.address)),t}function O(s){const t=new Set;return s.forEach(e=>t.add(e)),Object.freeze(t)}const tn="external public payable override",en=O(tn.split(" ")),fe="constant external internal payable private public pure view override",nn=O(fe.split(" ")),he="constructor error event fallback function receive struct",de=O(he.split(" ")),pe="calldata memory storage payable indexed",rn=O(pe.split(" ")),sn="tuple returns",an=[he,pe,sn,fe].join(" "),on=O(an.split(" ")),cn={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},un=new RegExp("^(\\s*)"),ln=new RegExp("^([0-9]+)"),fn=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),ge=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),me=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class I{#t;#e;get offset(){return this.#t}get length(){return this.#e.length-this.#t}constructor(t){this.#t=0,this.#e=t.slice()}clone(){return new I(this.#e)}reset(){this.#t=0}#n(t=0,e=0){return new I(this.#e.slice(t,e).map(n=>Object.freeze(Object.assign({},n,{match:n.match-t,linkBack:n.linkBack-t,linkNext:n.linkNext-t}))))}popKeyword(t){const e=this.peek();if(e.type!=="KEYWORD"||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=this.#n(this.#t+1,t.match+1);return this.#t=t.match+1,e}popParams(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=[];for(;this.#t<t.match-1;){const n=this.peek().linkNext;e.push(this.#n(this.#t+1,n)),this.#t=n}return this.#t=t.match+1,e}peek(){if(this.#t>=this.#e.length)throw new Error("out-of-bounds");return this.#e[this.#t]}peekKeyword(t){const e=this.peekType("KEYWORD");return e!=null&&t.has(e)?e:null}peekType(t){if(this.length===0)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return this.#t++,t}toString(){const t=[];for(let e=this.#t;e<this.#e.length;e++){const n=this.#e[e];t.push(`${n.type}:${n.text}`)}return`<TokenString ${t.join(" ")}>`}}function K(s){const t=[],e=a=>{const c=i<s.length?JSON.stringify(s[i]):"$EOI";throw new Error(`invalid token ${c} at ${i}: ${a}`)};let n=[],r=[],i=0;for(;i<s.length;){let a=s.substring(i),c=a.match(un);c&&(i+=c[1].length,a=s.substring(i));const u={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};t.push(u);let l=cn[a[0]]||"";if(l){if(u.type=l,u.text=a[0],i++,l==="OPEN_PAREN")n.push(t.length-1),r.push(t.length-1);else if(l=="CLOSE_PAREN")n.length===0&&e("no matching open bracket"),u.match=n.pop(),t[u.match].match=t.length-1,u.depth--,u.linkBack=r.pop(),t[u.linkBack].linkNext=t.length-1;else if(l==="COMMA")u.linkBack=r.pop(),t[u.linkBack].linkNext=t.length-1,r.push(t.length-1);else if(l==="OPEN_BRACKET")u.type="BRACKET";else if(l==="CLOSE_BRACKET"){let f=t.pop().text;if(t.length>0&&t[t.length-1].type==="NUMBER"){const h=t.pop().text;f=h+f,t[t.length-1].value=L(h)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=f}continue}if(c=a.match(fn),c){if(u.text=c[1],i+=u.text.length,on.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(me)){u.type="TYPE";continue}u.type="ID";continue}if(c=a.match(ln),c){u.text=c[1],u.type="NUMBER",i+=u.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${i}`)}return new I(t.map(a=>Object.freeze(a)))}function _t(s,t){let e=[];for(const n in t.keys())s.has(n)&&e.push(n);if(e.length>1)throw new Error(`conflicting types: ${e.join(", ")}`)}function yt(s,t){if(t.peekKeyword(de)){const e=t.pop().text;if(e!==s)throw new Error(`expected ${s}, got ${e}`)}return t.popType("ID")}function M(s,t){const e=new Set;for(;;){const n=s.peekType("KEYWORD");if(n==null||t&&!t.has(n))break;if(s.pop(),e.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);e.add(n)}return Object.freeze(e)}function ye(s){let t=M(s,nn);return _t(t,O("constant payable nonpayable".split(" "))),_t(t,O("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function V(s,t){return s.popParams().map(e=>E.from(e,t))}function we(s){if(s.peekType("AT")){if(s.pop(),s.peekType("NUMBER"))return H(s.pop().text);throw new Error("invalid gas")}return null}function Q(s){if(s.length)throw new Error(`unexpected tokens at offset ${s.offset}: ${s.toString()}`)}const hn=new RegExp(/^(.*)\[([0-9]*)\]$/);function Vt(s){const t=s.match(me);if(o.assertArgument(t,"invalid type","type",s),s==="uint")return"uint256";if(s==="int")return"int256";if(t[2]){const e=parseInt(t[2]);o.assertArgument(e!==0&&e<=32,"invalid bytes length","type",s)}else if(t[3]){const e=parseInt(t[3]);o.assertArgument(e!==0&&e<=256&&e%8===0,"invalid numeric width","type",s)}return s}const x={},R=Symbol.for("_ethers_internal"),Mt="_ParamTypeInternal",Ht="_ErrorInternal",zt="_EventInternal",Jt="_ConstructorInternal",Kt="_FallbackInternal",Wt="_FunctionInternal",Yt="_StructInternal";class E{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(t,e,n,r,i,a,c,u){if(o.assertPrivate(t,x,"ParamType"),Object.defineProperty(this,R,{value:Mt}),a&&(a=Object.freeze(a.slice())),r==="array"){if(c==null||u==null)throw new Error("")}else if(c!=null||u!=null)throw new Error("");if(r==="tuple"){if(a==null)throw new Error("")}else if(a!=null)throw new Error("");o.defineProperties(this,{name:e,type:n,baseType:r,indexed:i,components:a,arrayLength:c,arrayChildren:u})}format(t){if(t==null&&(t="sighash"),t==="json"){const n=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=n,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const r={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map(i=>JSON.parse(i.format(t)))),JSON.stringify(r)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map(n=>n.format(t)).join(t==="full"?", ":",")+")":e+=this.type,t!=="sighash"&&(this.indexed===!0&&(e+=" indexed"),t==="full"&&this.name&&(e+=" "+this.name)),e}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return t.map(r=>n.arrayChildren.walk(r,e))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const n=this;return t.map((r,i)=>n.components[i].walk(r,e))}return e(this.type,t)}#t(t,e,n,r){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const a=this.arrayChildren,c=e.slice();c.forEach((u,l)=>{a.#t(t,u,n,f=>{c[l]=f})}),r(c);return}if(this.isTuple()){const a=this.components;let c;if(Array.isArray(e))c=e.slice();else{if(e==null||typeof e!="object")throw new Error("invalid tuple value");c=a.map(u=>{if(!u.name)throw new Error("cannot use object value with unnamed components");if(!(u.name in e))throw new Error(`missing value for component ${u.name}`);return e[u.name]})}if(c.length!==this.components.length)throw new Error("array is wrong length");c.forEach((u,l)=>{a[l].#t(t,u,n,f=>{c[l]=f})}),r(c);return}const i=n(this.type,e);i.then?t.push((async function(){r(await i)})()):r(i)}async walkAsync(t,e){const n=[],r=[t];return this.#t(n,t,e,i=>{r[0]=i}),n.length&&await Promise.all(n),r[0]}static from(t,e){if(E.isParamType(t))return t;if(typeof t=="string")try{return E.from(K(t),e)}catch{o.assertArgument(!1,"invalid param type","obj",t)}else if(t instanceof I){let c="",u="",l=null;M(t,O(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(u="tuple",l=t.popParams().map(b=>E.from(b)),c=`tuple(${l.map(b=>b.format()).join(",")})`):(c=Vt(t.popType("TYPE")),u=c);let f=null,h=null;for(;t.length&&t.peekType("BRACKET");){const b=t.pop();f=new E(x,"",c,u,null,l,h,f),h=b.value,c+=b.text,u="array",l=null}let d=null;if(M(t,rn).has("indexed")){if(!e)throw new Error("");d=!0}const y=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new E(x,y,c,u,d,l,h,f)}const n=t.name;o.assertArgument(!n||typeof n=="string"&&n.match(ge),"invalid name","obj.name",n);let r=t.indexed;r!=null&&(o.assertArgument(e,"parameter cannot be indexed","obj.indexed",t.indexed),r=!!r);let i=t.type,a=i.match(hn);if(a){const c=parseInt(a[2]||"-1"),u=E.from({type:a[1],components:t.components});return new E(x,n||"",i,"array",r,null,c,u)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const c=t.components!=null?t.components.map(l=>E.from(l)):null;return new E(x,n||"",i,"tuple",r,c,null,null)}return i=Vt(t.type),new E(x,n||"",i,i,r,null,null,null)}static isParamType(t){return t&&t[R]===Mt}}class q{type;inputs;constructor(t,e,n){o.assertPrivate(t,x,"Fragment"),n=Object.freeze(n.slice()),o.defineProperties(this,{type:e,inputs:n})}static from(t){if(typeof t=="string"){try{q.from(JSON.parse(t))}catch{}return q.from(K(t))}if(t instanceof I)switch(t.peekKeyword(de)){case"constructor":return _.from(t);case"error":return T.from(t);case"event":return C.from(t);case"fallback":case"receive":return $.from(t);case"function":return F.from(t);case"struct":return Z.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return _.from(t);case"error":return T.from(t);case"event":return C.from(t);case"fallback":case"receive":return $.from(t);case"function":return F.from(t);case"struct":return Z.from(t)}o.assert(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}o.assertArgument(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return _.isFragment(t)}static isError(t){return T.isFragment(t)}static isEvent(t){return C.isFragment(t)}static isFunction(t){return F.isFragment(t)}static isStruct(t){return Z.isFragment(t)}}class wt extends q{name;constructor(t,e,n,r){super(t,e,r),o.assertArgument(typeof n=="string"&&n.match(ge),"invalid identifier","name",n),r=Object.freeze(r.slice()),o.defineProperties(this,{name:n})}}function ct(s,t){return"("+t.map(e=>e.format(s)).join(s==="full"?", ":",")+")"}class T extends wt{constructor(t,e,n){super(t,"error",e,n),Object.defineProperty(this,R,{value:Ht})}get selector(){return rt(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("error"),e.push(this.name+ct(t,this.inputs)),e.join(" ")}static from(t){if(T.isFragment(t))return t;if(typeof t=="string")return T.from(K(t));if(t instanceof I){const e=yt("error",t),n=V(t);return Q(t),new T(x,e,n)}return new T(x,t.name,t.inputs?t.inputs.map(E.from):[])}static isFragment(t){return t&&t[R]===Ht}}class C extends wt{anonymous;constructor(t,e,n,r){super(t,"event",e,n),Object.defineProperty(this,R,{value:zt}),o.defineProperties(this,{anonymous:r})}get topicHash(){return rt(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("event"),e.push(this.name+ct(t,this.inputs)),t!=="sighash"&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){return e=(e||[]).map(r=>E.from(r)),new C(x,t,e,!1).topicHash}static from(t){if(C.isFragment(t))return t;if(typeof t=="string")try{return C.from(K(t))}catch{o.assertArgument(!1,"invalid event fragment","obj",t)}else if(t instanceof I){const e=yt("event",t),n=V(t,!0),r=!!M(t,O(["anonymous"])).has("anonymous");return Q(t),new C(x,e,n,r)}return new C(x,t.name,t.inputs?t.inputs.map(e=>E.from(e,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[R]===zt}}class _ extends q{payable;gas;constructor(t,e,n,r,i){super(t,e,n),Object.defineProperty(this,R,{value:Jt}),o.defineProperties(this,{payable:r,gas:i})}format(t){if(o.assert(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[`constructor${ct(t,this.inputs)}`];return this.payable&&e.push("payable"),this.gas!=null&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if(_.isFragment(t))return t;if(typeof t=="string")try{return _.from(K(t))}catch{o.assertArgument(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof I){M(t,O(["constructor"]));const e=V(t),n=!!M(t,en).has("payable"),r=we(t);return Q(t),new _(x,"constructor",e,n,r)}return new _(x,"constructor",t.inputs?t.inputs.map(E.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[R]===Jt}}class $ extends q{payable;constructor(t,e,n){super(t,"fallback",e),Object.defineProperty(this,R,{value:Kt}),o.defineProperties(this,{payable:n})}format(t){const e=this.inputs.length===0?"receive":"fallback";if(t==="json"){const n=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:n})}return`${e}()${this.payable?" payable":""}`}static from(t){if($.isFragment(t))return t;if(typeof t=="string")try{return $.from(K(t))}catch{o.assertArgument(!1,"invalid fallback fragment","obj",t)}else if(t instanceof I){const e=t.toString(),n=t.peekKeyword(O(["fallback","receive"]));if(o.assertArgument(n,"type must be fallback or receive","obj",e),t.popKeyword(O(["fallback","receive"]))==="receive"){const c=V(t);return o.assertArgument(c.length===0,"receive cannot have arguments","obj.inputs",c),M(t,O(["payable"])),Q(t),new $(x,[],!0)}let i=V(t);i.length?o.assertArgument(i.length===1&&i[0].type==="bytes","invalid fallback inputs","obj.inputs",i.map(c=>c.format("minimal")).join(", ")):i=[E.from("bytes")];const a=ye(t);if(o.assertArgument(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),M(t,O(["returns"])).has("returns")){const c=V(t);o.assertArgument(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(u=>u.format("minimal")).join(", "))}return Q(t),new $(x,i,a==="payable")}if(t.type==="receive")return new $(x,[],!0);if(t.type==="fallback"){const e=[E.from("bytes")],n=t.stateMutability==="payable";return new $(x,e,n)}o.assertArgument(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[R]===Kt}}class F extends wt{constant;outputs;stateMutability;payable;gas;constructor(t,e,n,r,i,a){super(t,"function",e,r),Object.defineProperty(this,R,{value:Wt}),i=Object.freeze(i.slice());const c=n==="view"||n==="pure",u=n==="payable";o.defineProperties(this,{constant:c,gas:a,outputs:i,payable:u,stateMutability:n})}get selector(){return rt(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(t))),outputs:this.outputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("function"),e.push(this.name+ct(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(ct(t,this.outputs))),this.gas!=null&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){return e=(e||[]).map(r=>E.from(r)),new F(x,t,"view",e,[],null).selector}static from(t){if(F.isFragment(t))return t;if(typeof t=="string")try{return F.from(K(t))}catch{o.assertArgument(!1,"invalid function fragment","obj",t)}else if(t instanceof I){const n=yt("function",t),r=V(t),i=ye(t);let a=[];M(t,O(["returns"])).has("returns")&&(a=V(t));const c=we(t);return Q(t),new F(x,n,i,r,a,c)}let e=t.stateMutability;return e==null&&(e="payable",typeof t.constant=="boolean"?(e="view",t.constant||(e="payable",typeof t.payable=="boolean"&&!t.payable&&(e="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(e="nonpayable")),new F(x,t.name,e,t.inputs?t.inputs.map(E.from):[],t.outputs?t.outputs.map(E.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[R]===Wt}}class Z extends wt{constructor(t,e,n){super(t,"struct",e,n),Object.defineProperty(this,R,{value:Yt})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return Z.from(K(t))}catch{o.assertArgument(!1,"invalid struct fragment","obj",t)}else if(t instanceof I){const e=yt("struct",t),n=V(t);return Q(t),new Z(x,e,n)}return new Z(x,t.name,t.inputs?t.inputs.map(E.from):[])}static isFragment(t){return t&&t[R]===Yt}}const S=new Map;S.set(0,"GENERIC_PANIC");S.set(1,"ASSERT_FALSE");S.set(17,"OVERFLOW");S.set(18,"DIVIDE_BY_ZERO");S.set(33,"ENUM_RANGE_ERROR");S.set(34,"BAD_STORAGE_DATA");S.set(49,"STACK_UNDERFLOW");S.set(50,"ARRAY_RANGE_ERROR");S.set(65,"OUT_OF_MEMORY");S.set(81,"UNINITIALIZED_FUNCTION_CALL");const dn=new RegExp(/^bytes([0-9]*)$/),pn=new RegExp(/^(u?int)([0-9]*)$/);let xt=null,Xt=1024;function gn(s,t,e,n){let r="missing revert data",i=null;const a=null;let c=null;if(e){r="execution reverted";const l=o.getBytes(e);if(e=o.hexlify(e),l.length===0)r+=" (no data present; likely require(false) occurred",i="require(false)";else if(l.length%32!==4)r+=" (could not decode reason; invalid data length)";else if(o.hexlify(l.slice(0,4))==="0x08c379a0")try{i=n.decode(["string"],l.slice(4))[0],c={signature:"Error(string)",name:"Error",args:[i]},r+=`: ${JSON.stringify(i)}`}catch{r+=" (could not decode reason; invalid string data)"}else if(o.hexlify(l.slice(0,4))==="0x4e487b71")try{const f=Number(n.decode(["uint256"],l.slice(4))[0]);c={signature:"Panic(uint256)",name:"Panic",args:[f]},i=`Panic due to ${S.get(f)||"UNKNOWN"}(${f})`,r+=`: ${i}`}catch{r+=" (could not decode panic code)"}else r+=" (unknown custom error)"}const u={to:t.to?o.getAddress(t.to):null,data:t.data||"0x"};return t.from&&(u.from=o.getAddress(t.from)),o.makeError(r,"CALL_EXCEPTION",{action:s,data:e,reason:i,transaction:u,invocation:a,revert:c})}class st{#t(t){if(t.isArray())return new He(this.#t(t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new ht(t.components.map(n=>this.#t(n)),t.name);switch(t.baseType){case"address":return new Ve(t.name);case"bool":return new ze(t.name);case"string":return new je(t.name);case"bytes":return new Je(t.name);case"":return new Ye(t.name)}let e=t.type.match(pn);if(e){let n=parseInt(e[2]||"256");return o.assertArgument(n!==0&&n<=256&&n%8===0,"invalid "+e[1]+" bit length","param",t),new qe(n/8,e[1]==="int",t.name)}if(e=t.type.match(dn),e){let n=parseInt(e[1]);return o.assertArgument(n!==0&&n<=32,"invalid bytes length","param",t),new Ke(n,t.name)}o.assertArgument(!1,"invalid type","type",t.type)}getDefaultValue(t){const e=t.map(r=>this.#t(E.from(r)));return new ht(e,"_").defaultValue()}encode(t,e){o.assertArgumentCount(e.length,t.length,"types/values length mismatch");const n=t.map(a=>this.#t(E.from(a))),r=new ht(n,"_"),i=new Nt;return r.encode(i,e),i.data}decode(t,e,n){const r=t.map(a=>this.#t(E.from(a)));return new ht(r,"_").decode(new It(e,n,Xt))}static _setDefaultMaxInflation(t){o.assertArgument(typeof t=="number"&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),Xt=t}static defaultAbiCoder(){return xt==null&&(xt=new st),xt}static getBuiltinCallException(t,e,n){return gn(t,e,n,st.defaultAbiCoder())}}class mn{fragment;name;signature;topic;args;constructor(t,e,n){const r=t.name,i=t.format();o.defineProperties(this,{fragment:t,name:r,signature:i,topic:e,args:n})}}class yn{fragment;name;args;signature;selector;value;constructor(t,e,n,r){const i=t.name,a=t.format();o.defineProperties(this,{fragment:t,name:i,args:n,signature:a,selector:e,value:r})}}class wn{fragment;name;args;signature;selector;constructor(t,e,n){const r=t.name,i=t.format();o.defineProperties(this,{fragment:t,name:r,args:n,signature:i,selector:e})}}class Zt{hash;_isIndexed;static isIndexed(t){return!!(t&&t._isIndexed)}constructor(t){o.defineProperties(this,{hash:t,_isIndexed:!0})}}const Qt={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},qt={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:s=>`reverted with reason string ${JSON.stringify(s)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:s=>{let t="unknown panic code";return s>=0&&s<=255&&Qt[s.toString()]&&(t=Qt[s.toString()]),`reverted with panic code 0x${s.toString(16)} (${t})`}}};class J{fragments;deploy;fallback;receive;#t;#e;#n;#r;constructor(t){let e=[];typeof t=="string"?e=JSON.parse(t):e=t,this.#n=new Map,this.#t=new Map,this.#e=new Map;const n=[];for(const a of e)try{n.push(q.from(a))}catch(c){console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`,c.message)}o.defineProperties(this,{fragments:Object.freeze(n)});let r=null,i=!1;this.#r=this.getAbiCoder(),this.fragments.forEach((a,c)=>{let u;switch(a.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}o.defineProperties(this,{deploy:a});return;case"fallback":a.inputs.length===0?i=!0:(o.assertArgument(!r||a.payable!==r.payable,"conflicting fallback fragments",`fragments[${c}]`,a),r=a,i=r.payable);return;case"function":u=this.#n;break;case"event":u=this.#e;break;case"error":u=this.#t;break;default:return}const l=a.format();u.has(l)||u.set(l,a)}),this.deploy||o.defineProperties(this,{deploy:_.from("constructor()")}),o.defineProperties(this,{fallback:r,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map(r=>r.format(e))}formatJson(){const t=this.fragments.map(e=>e.format("json"));return JSON.stringify(t.map(e=>JSON.parse(e)))}getAbiCoder(){return st.defaultAbiCoder()}#s(t,e,n){if(o.isHexString(t)){const i=t.toLowerCase();for(const a of this.#n.values())if(i===a.selector)return a;return null}if(t.indexOf("(")===-1){const i=[];for(const[a,c]of this.#n)a.split("(")[0]===t&&i.push(c);if(e){const a=e.length>0?e[e.length-1]:null;let c=e.length,u=!0;A.isTyped(a)&&a.type==="overrides"&&(u=!1,c--);for(let l=i.length-1;l>=0;l--){const f=i[l].inputs.length;f!==c&&(!u||f!==c-1)&&i.splice(l,1)}for(let l=i.length-1;l>=0;l--){const f=i[l].inputs;for(let h=0;h<e.length;h++)if(A.isTyped(e[h])){if(h>=f.length){if(e[h].type==="overrides")continue;i.splice(l,1);break}if(e[h].type!==f[h].baseType){i.splice(l,1);break}}}}if(i.length===1&&e&&e.length!==i[0].inputs.length){const a=e[e.length-1];(a==null||Array.isArray(a)||typeof a!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&n){const a=i.map(c=>JSON.stringify(c.format())).join(", ");o.assertArgument(!1,`ambiguous function description (i.e. matches ${a})`,"key",t)}return i[0]}const r=this.#n.get(F.from(t).format());return r||null}getFunctionName(t){const e=this.#s(t,null,!1);return o.assertArgument(e,"no matching function","key",t),e.name}hasFunction(t){return!!this.#s(t,null,!1)}getFunction(t,e){return this.#s(t,e||null,!0)}forEachFunction(t){const e=Array.from(this.#n.keys());e.sort((n,r)=>n.localeCompare(r));for(let n=0;n<e.length;n++){const r=e[n];t(this.#n.get(r),n)}}#i(t,e,n){if(o.isHexString(t)){const i=t.toLowerCase();for(const a of this.#e.values())if(i===a.topicHash)return a;return null}if(t.indexOf("(")===-1){const i=[];for(const[a,c]of this.#e)a.split("(")[0]===t&&i.push(c);if(e){for(let a=i.length-1;a>=0;a--)i[a].inputs.length<e.length&&i.splice(a,1);for(let a=i.length-1;a>=0;a--){const c=i[a].inputs;for(let u=0;u<e.length;u++)if(A.isTyped(e[u])&&e[u].type!==c[u].baseType){i.splice(a,1);break}}}if(i.length===0)return null;if(i.length>1&&n){const a=i.map(c=>JSON.stringify(c.format())).join(", ");o.assertArgument(!1,`ambiguous event description (i.e. matches ${a})`,"key",t)}return i[0]}const r=this.#e.get(C.from(t).format());return r||null}getEventName(t){const e=this.#i(t,null,!1);return o.assertArgument(e,"no matching event","key",t),e.name}hasEvent(t){return!!this.#i(t,null,!1)}getEvent(t,e){return this.#i(t,e||null,!0)}forEachEvent(t){const e=Array.from(this.#e.keys());e.sort((n,r)=>n.localeCompare(r));for(let n=0;n<e.length;n++){const r=e[n];t(this.#e.get(r),n)}}getError(t,e){if(o.isHexString(t)){const r=t.toLowerCase();if(qt[r])return T.from(qt[r].signature);for(const i of this.#t.values())if(r===i.selector)return i;return null}if(t.indexOf("(")===-1){const r=[];for(const[i,a]of this.#t)i.split("(")[0]===t&&r.push(a);if(r.length===0)return t==="Error"?T.from("error Error(string)"):t==="Panic"?T.from("error Panic(uint256)"):null;if(r.length>1){const i=r.map(a=>JSON.stringify(a.format())).join(", ");o.assertArgument(!1,`ambiguous error description (i.e. ${i})`,"name",t)}return r[0]}if(t=T.from(t).format(),t==="Error(string)")return T.from("error Error(string)");if(t==="Panic(uint256)")return T.from("error Panic(uint256)");const n=this.#t.get(t);return n||null}forEachError(t){const e=Array.from(this.#t.keys());e.sort((n,r)=>n.localeCompare(r));for(let n=0;n<e.length;n++){const r=e[n];t(this.#t.get(r),n)}}_decodeParams(t,e){return this.#r.decode(t,e)}_encodeParams(t,e){return this.#r.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if(typeof t=="string"){const n=this.getError(t);o.assertArgument(n,"unknown error","fragment",t),t=n}return o.assertArgument(o.dataSlice(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,o.dataSlice(e,4))}encodeErrorResult(t,e){if(typeof t=="string"){const n=this.getError(t);o.assertArgument(n,"unknown error","fragment",t),t=n}return o.concat([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if(typeof t=="string"){const n=this.getFunction(t);o.assertArgument(n,"unknown function","fragment",t),t=n}return o.assertArgument(o.dataSlice(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,o.dataSlice(e,4))}encodeFunctionData(t,e){if(typeof t=="string"){const n=this.getFunction(t);o.assertArgument(n,"unknown function","fragment",t),t=n}return o.concat([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if(typeof t=="string"){const i=this.getFunction(t);o.assertArgument(i,"unknown function","fragment",t),t=i}let n="invalid length for result data";const r=o.getBytesCopy(e);if(r.length%32===0)try{return this.#r.decode(t.outputs,r)}catch{n="could not decode result data"}o.assert(!1,n,"BAD_DATA",{value:o.hexlify(r),info:{method:t.name,signature:t.format()}})}makeError(t,e){const n=o.getBytes(t,"data"),r=st.getBuiltinCallException("call",e,n);if(r.message.startsWith("execution reverted (unknown custom error)")){const c=o.hexlify(n.slice(0,4)),u=this.getError(c);if(u)try{const l=this.#r.decode(u.inputs,n.slice(4));r.revert={name:u.name,signature:u.format(),args:l},r.reason=r.revert.signature,r.message=`execution reverted: ${r.reason}`}catch{r.message="execution reverted (coult not decode custom error)"}}const a=this.parseTransaction(e);return a&&(r.invocation={method:a.name,signature:a.signature,args:a.args}),r}encodeFunctionResult(t,e){if(typeof t=="string"){const n=this.getFunction(t);o.assertArgument(n,"unknown function","fragment",t),t=n}return o.hexlify(this.#r.encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if(typeof t=="string"){const i=this.getEvent(t);o.assertArgument(i,"unknown event","eventFragment",t),t=i}o.assert(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const n=[];t.anonymous||n.push(t.topicHash);const r=(i,a)=>i.type==="string"?rt(a):i.type==="bytes"?o.keccak256(o.hexlify(a)):(i.type==="bool"&&typeof a=="boolean"?a=a?"0x01":"0x00":i.type.match(/^u?int/)?a=Rt(a):i.type.match(/^bytes/)?a=o.zeroPadBytes(a,32):i.type==="address"&&this.#r.encode(["address"],[a]),o.zeroPadValue(o.hexlify(a),32));for(e.forEach((i,a)=>{const c=t.inputs[a];if(!c.indexed){o.assertArgument(i==null,"cannot filter non-indexed parameters; must be null","contract."+c.name,i);return}i==null?n.push(null):c.baseType==="array"||c.baseType==="tuple"?o.assertArgument(!1,"filtering with tuples or arrays not supported","contract."+c.name,i):Array.isArray(i)?n.push(i.map(u=>r(c,u))):n.push(r(c,i))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(t,e){if(typeof t=="string"){const a=this.getEvent(t);o.assertArgument(a,"unknown event","eventFragment",t),t=a}const n=[],r=[],i=[];return t.anonymous||n.push(t.topicHash),o.assertArgument(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach((a,c)=>{const u=e[c];if(a.indexed)if(a.type==="string")n.push(rt(u));else if(a.type==="bytes")n.push(o.keccak256(u));else{if(a.baseType==="tuple"||a.baseType==="array")throw new Error("not implemented");n.push(this.#r.encode([a.type],[u]))}else r.push(a),i.push(u)}),{data:this.#r.encode(r,i),topics:n}}decodeEventLog(t,e,n){if(typeof t=="string"){const g=this.getEvent(t);o.assertArgument(g,"unknown event","eventFragment",t),t=g}if(n!=null&&!t.anonymous){const g=t.topicHash;o.assertArgument(o.isHexString(n[0],32)&&n[0].toLowerCase()===g,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const r=[],i=[],a=[];t.inputs.forEach((g,y)=>{g.indexed?g.type==="string"||g.type==="bytes"||g.baseType==="tuple"||g.baseType==="array"?(r.push(E.from({type:"bytes32",name:g.name})),a.push(!0)):(r.push(g),a.push(!1)):(i.push(g),a.push(!1))});const c=n!=null?this.#r.decode(r,o.concat(n)):null,u=this.#r.decode(i,e,!0),l=[],f=[];let h=0,d=0;return t.inputs.forEach((g,y)=>{let b=null;if(g.indexed)if(c==null)b=new Zt(null);else if(a[y])b=new Zt(c[d++]);else try{b=c[d++]}catch(P){b=P}else try{b=u[h++]}catch(P){b=P}l.push(b),f.push(g.name||null)}),G.fromItems(l,f)}parseTransaction(t){const e=o.getBytes(t.data,"tx.data"),n=H(t.value!=null?t.value:0,"tx.value"),r=this.getFunction(o.hexlify(e.slice(0,4)));if(!r)return null;const i=this.#r.decode(r.inputs,e.slice(4));return new yn(r,r.selector,i,n)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new mn(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=o.hexlify(t),n=this.getError(o.dataSlice(e,0,4));if(!n)return null;const r=this.#r.decode(n.inputs,o.dataSlice(e,4));return new wn(n,n.selector,r)}static from(t){return t instanceof J?t:typeof t=="string"?new J(JSON.parse(t)):typeof t.formatJson=="function"?new J(t.formatJson()):typeof t.format=="function"?new J(t.format("json")):new J(t)}}const be=BigInt(0);function et(s){return s??null}function N(s){return s==null?null:s.toString()}class bn{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(t,e,n){o.defineProperties(this,{gasPrice:et(t),maxFeePerGas:et(e),maxPriorityFeePerGas:et(n)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:N(t),maxFeePerGas:N(e),maxPriorityFeePerGas:N(n)}}}function Ee(s){const t={};s.to&&(t.to=s.to),s.from&&(t.from=s.from),s.data&&(t.data=o.hexlify(s.data));const e="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const r of e)!(r in s)||s[r]==null||(t[r]=H(s[r],`request.${r}`));const n="type,nonce".split(/,/);for(const r of n)!(r in s)||s[r]==null||(t[r]=L(s[r],`request.${r}`));return s.accessList&&(t.accessList=le(s.accessList)),"blockTag"in s&&(t.blockTag=s.blockTag),"enableCcipRead"in s&&(t.enableCcipRead=!!s.enableCcipRead),"customData"in s&&(t.customData=s.customData),"blobVersionedHashes"in s&&s.blobVersionedHashes&&(t.blobVersionedHashes=s.blobVersionedHashes.slice()),"kzg"in s&&(t.kzg=s.kzg),"blobs"in s&&s.blobs&&(t.blobs=s.blobs.map(r=>o.isBytesLike(r)?o.hexlify(r):Object.assign({},r))),t}class En{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#t;constructor(t,e){this.#t=t.transactions.map(n=>typeof n!="string"?new lt(n,e):n),o.defineProperties(this,{provider:e,hash:et(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:et(t.prevRandao),extraData:t.extraData,baseFeePerGas:et(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return this.#t.map(t=>typeof t=="string"?t:t.hash)}get prefetchedTransactions(){const t=this.#t.slice();return t.length===0?[]:(o.assert(typeof t[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:n,gasLimit:r,gasUsed:i,hash:a,miner:c,prevRandao:u,nonce:l,number:f,parentHash:h,parentBeaconBlockRoot:d,stateRoot:g,receiptsRoot:y,timestamp:b,transactions:P}=this;return{_type:"Block",baseFeePerGas:N(t),difficulty:N(e),extraData:n,gasLimit:N(r),gasUsed:N(i),blobGasUsed:N(this.blobGasUsed),excessBlobGas:N(this.excessBlobGas),hash:a,miner:c,prevRandao:u,nonce:l,number:f,parentHash:h,timestamp:b,parentBeaconBlockRoot:d,stateRoot:g,receiptsRoot:y,transactions:P}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return this.#t.length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(t){let e;if(typeof t=="number")e=this.#t[t];else{const n=t.toLowerCase();for(const r of this.#t)if(typeof r=="string"){if(r!==n)continue;e=r;break}else{if(r.hash!==n)continue;e=r;break}}if(e==null)throw new Error("no such tx");return typeof e=="string"?await this.provider.getTransaction(e):e}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if(typeof t=="number")return e[t];t=t.toLowerCase();for(const n of e)if(n.hash===t)return n;o.assertArgument(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return xn(this)}}class ut{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor(t,e){this.provider=e;const n=Object.freeze(t.topics.slice());o.defineProperties(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:n,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:n,data:r,index:i,removed:a,topics:c,transactionHash:u,transactionIndex:l}=this;return{_type:"log",address:t,blockHash:e,blockNumber:n,data:r,index:i,removed:a,topics:c,transactionHash:u,transactionIndex:l}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return o.assert(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return o.assert(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return o.assert(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return Pn(this)}}class xe{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#t;constructor(t,e){this.#t=Object.freeze(t.logs.map(r=>new ut(r,e)));let n=be;t.effectiveGasPrice!=null?n=t.effectiveGasPrice:t.gasPrice!=null&&(n=t.gasPrice),o.defineProperties(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:n,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return this.#t}toJSON(){const{to:t,from:e,contractAddress:n,hash:r,index:i,blockHash:a,blockNumber:c,logsBloom:u,logs:l,status:f,root:h}=this;return{_type:"TransactionReceipt",blockHash:a,blockNumber:c,contractAddress:n,cumulativeGasUsed:N(this.cumulativeGasUsed),from:e,gasPrice:N(this.gasPrice),blobGasUsed:N(this.blobGasUsed),blobGasPrice:N(this.blobGasPrice),gasUsed:N(this.gasUsed),hash:r,index:i,logs:l,logsBloom:u,root:h,status:f,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(t==null)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(t==null)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return Ae(this)}reorderedEvent(t){return o.assert(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Pe(this,t)}}class lt{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;#t;constructor(t,e){this.provider=e,this.blockNumber=t.blockNumber!=null?t.blockNumber:null,this.blockHash=t.blockHash!=null?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=t.maxPriorityFeePerGas!=null?t.maxPriorityFeePerGas:null,this.maxFeePerGas=t.maxFeePerGas!=null?t.maxFeePerGas:null,this.maxFeePerBlobGas=t.maxFeePerBlobGas!=null?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=t.accessList!=null?t.accessList:null,this.blobVersionedHashes=t.blobVersionedHashes!=null?t.blobVersionedHashes:null,this.#t=-1}toJSON(){const{blockNumber:t,blockHash:e,index:n,hash:r,type:i,to:a,from:c,nonce:u,data:l,signature:f,accessList:h,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:h,blockNumber:t,blockHash:e,blobVersionedHashes:d,chainId:N(this.chainId),data:l,from:c,gasLimit:N(this.gasLimit),gasPrice:N(this.gasPrice),hash:r,maxFeePerGas:N(this.maxFeePerGas),maxPriorityFeePerGas:N(this.maxPriorityFeePerGas),maxFeePerBlobGas:N(this.maxFeePerBlobGas),nonce:u,signature:f,to:a,index:n,type:i,value:N(this.value)}}async getBlock(){let t=this.blockNumber;if(t==null){const n=await this.getTransaction();n&&(t=n.blockNumber)}if(t==null)return null;const e=this.provider.getBlock(t);if(e==null)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:e,blockNumber:n}=await o.resolveProperties({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:n-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const n=t??1,r=e??0;let i=this.#t,a=-1,c=i===-1;const u=async()=>{if(c)return null;const{blockNumber:d,nonce:g}=await o.resolveProperties({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(g<this.nonce){i=d;return}if(c)return null;const y=await this.getTransaction();if(!(y&&y.blockNumber!=null))for(a===-1&&(a=i-3,a<this.#t&&(a=this.#t));a<=d;){if(c)return null;const b=await this.provider.getBlock(a,!0);if(b==null)return;for(const P of b)if(P===this.hash)return;for(let P=0;P<b.length;P++){const w=await b.getTransaction(P);if(w.from===this.from&&w.nonce===this.nonce){if(c)return null;const k=await this.provider.getTransactionReceipt(w.hash);if(k==null||d-k.blockNumber+1<n)return;let W="replaced";w.data===this.data&&w.to===this.to&&w.value===this.value?W="repriced":w.data==="0x"&&w.from===w.to&&w.value===be&&(W="cancelled"),o.assert(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:W==="replaced"||W==="cancelled",reason:W,replacement:w.replaceableTransaction(i),hash:w.hash,receipt:k})}}a++}},l=d=>{if(d==null||d.status!==0)return d;o.assert(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},f=await this.provider.getTransactionReceipt(this.hash);if(n===0)return l(f);if(f){if(await f.confirmations()>=n)return l(f)}else if(await u(),n===0)return null;return await new Promise((d,g)=>{const y=[],b=()=>{y.forEach(w=>w())};if(y.push(()=>{c=!0}),r>0){const w=setTimeout(()=>{b(),g(o.makeError("wait for transaction timeout","TIMEOUT"))},r);y.push(()=>{clearTimeout(w)})}const P=async w=>{if(await w.confirmations()>=n){b();try{d(l(w))}catch(k){g(k)}}};if(y.push(()=>{this.provider.off(this.hash,P)}),this.provider.on(this.hash,P),i>=0){const w=async()=>{try{await u()}catch(k){if(o.isError(k,"TRANSACTION_REPLACED")){b(),g(k);return}}c||this.provider.once("block",w)};y.push(()=>{this.provider.off("block",w)}),this.provider.once("block",w)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return o.assert(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Ae(this)}reorderedEvent(t){return o.assert(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),o.assert(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Pe(this,t)}replaceableTransaction(t){o.assertArgument(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new lt(this,this.provider);return e.#t=t,e}}function xn(s){return{orphan:"drop-block",hash:s.hash,number:s.number}}function Pe(s,t){return{orphan:"reorder-transaction",tx:s,other:t}}function Ae(s){return{orphan:"drop-transaction",tx:s}}function Pn(s){return{orphan:"drop-log",log:{transactionHash:s.transactionHash,blockHash:s.blockHash,blockNumber:s.blockNumber,address:s.address,data:s.data,topics:Object.freeze(s.topics.slice()),index:s.index}}}class Bt extends ut{interface;fragment;args;constructor(t,e,n){super(t,t.provider);const r=e.decodeEventLog(n,t.data,t.topics);o.defineProperties(this,{args:r,fragment:n,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Ne extends ut{error;constructor(t,e){super(t,t.provider),o.defineProperties(this,{error:e})}}class An extends xe{#t;constructor(t,e,n){super(n,e),this.#t=t}get logs(){return super.logs.map(t=>{const e=t.topics.length?this.#t.getEvent(t.topics[0]):null;if(e)try{return new Bt(t,this.#t,e)}catch(n){return new Ne(t,n)}return t})}}class St extends lt{#t;constructor(t,e,n){super(n,e),this.#t=t}async wait(t,e){const n=await super.wait(t,e);return n==null?null:new An(this.#t,this.provider,n)}}class ve extends re{log;constructor(t,e,n,r){super(t,e,n),o.defineProperties(this,{log:r})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class Nn extends ve{constructor(t,e,n,r,i){super(t,e,n,new Bt(i,t.interface,r));const a=t.interface.decodeEventLog(r,this.log.data,this.log.topics);o.defineProperties(this,{args:a,fragment:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const jt=BigInt(0);function Oe(s){return s&&typeof s.call=="function"}function Te(s){return s&&typeof s.estimateGas=="function"}function bt(s){return s&&typeof s.resolveName=="function"}function Re(s){return s&&typeof s.sendTransaction=="function"}function ke(s){if(s!=null){if(bt(s))return s;if(s.provider)return s.provider}}class vn{#t;fragment;constructor(t,e,n){if(o.defineProperties(this,{fragment:e}),e.inputs.length<n.length)throw new Error("too many arguments");const r=j(t.runner,"resolveName"),i=bt(r)?r:null;this.#t=(async function(){const a=await Promise.all(e.inputs.map((c,u)=>n[u]==null?null:c.walkAsync(n[u],(f,h)=>f==="address"?Array.isArray(h)?Promise.all(h.map(d=>o.resolveAddress(d,i))):o.resolveAddress(h,i):h)));return t.interface.encodeFilterTopics(e,a)})()}getTopicFilter(){return this.#t}}function j(s,t){return s==null?null:typeof s[t]=="function"?s:s.provider&&typeof s.provider[t]=="function"?s.provider:null}function X(s){return s==null?null:s.provider||null}async function Ct(s,t){const e=A.dereference(s,"overrides");o.assertArgument(typeof e=="object","invalid overrides parameter","overrides",s);const n=Ee(e);return o.assertArgument(n.to==null||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),o.assertArgument(n.data==null||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function Ue(s,t,e){const n=j(s,"resolveName"),r=bt(n)?n:null;return await Promise.all(t.map((i,a)=>i.walkAsync(e[a],(c,u)=>(u=A.dereference(u,c),c==="address"?o.resolveAddress(u,r):u))))}function On(s){const t=async function(a){const c=await Ct(a,["data"]);c.to=await s.getAddress(),c.from&&(c.from=await o.resolveAddress(c.from,ke(s.runner)));const u=s.interface,l=H(c.value||jt,"overrides.value")===jt,f=(c.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!f&&!l&&o.assertArgument(!1,"cannot send data to receive or send value to non-payable fallback","overrides",a),o.assertArgument(u.fallback||f,"cannot send data to receive-only contract","overrides.data",c.data);const h=u.receive||u.fallback&&u.fallback.payable;return o.assertArgument(h||l,"cannot send value to non-payable fallback","overrides.value",c.value),o.assertArgument(u.fallback||f,"cannot send data to receive-only contract","overrides.data",c.data),c},e=async function(a){const c=j(s.runner,"call");o.assert(Oe(c),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await t(a);try{return await c.call(u)}catch(l){throw o.isCallException(l)&&l.data?s.interface.makeError(l.data,u):l}},n=async function(a){const c=s.runner;o.assert(Re(c),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await c.sendTransaction(await t(a)),l=X(s.runner);return new St(s.interface,l,u)},r=async function(a){const c=j(s.runner,"estimateGas");return o.assert(Te(c),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await c.estimateGas(await t(a))},i=async a=>await n(a);return o.defineProperties(i,{_contract:s,estimateGas:r,populateTransaction:t,send:n,staticCall:e}),i}function Tn(s,t){const e=function(...l){const f=s.interface.getFunction(t,l);return o.assert(f,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:l}}),f},n=async function(...l){const f=e(...l);let h={};if(f.inputs.length+1===l.length&&(h=await Ct(l.pop()),h.from&&(h.from=await o.resolveAddress(h.from,ke(s.runner)))),f.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await Ue(s.runner,f.inputs,l);return Object.assign({},h,await o.resolveProperties({to:s.getAddress(),data:s.interface.encodeFunctionData(f,d)}))},r=async function(...l){const f=await c(...l);return f.length===1?f[0]:f},i=async function(...l){const f=s.runner;o.assert(Re(f),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const h=await f.sendTransaction(await n(...l)),d=X(s.runner);return new St(s.interface,d,h)},a=async function(...l){const f=j(s.runner,"estimateGas");return o.assert(Te(f),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await f.estimateGas(await n(...l))},c=async function(...l){const f=j(s.runner,"call");o.assert(Oe(f),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const h=await n(...l);let d="0x";try{d=await f.call(h)}catch(y){throw o.isCallException(y)&&y.data?s.interface.makeError(y.data,h):y}const g=e(...l);return s.interface.decodeFunctionResult(g,d)},u=async(...l)=>e(...l).constant?await r(...l):await i(...l);return o.defineProperties(u,{name:s.interface.getFunctionName(t),_contract:s,_key:t,getFragment:e,estimateGas:a,populateTransaction:n,send:i,staticCall:r,staticCallResult:c}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const l=s.interface.getFunction(t);return o.assert(l,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),l}}),u}function Rn(s,t){const e=function(...r){const i=s.interface.getEvent(t,r);return o.assert(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:r}}),i},n=function(...r){return new vn(s,e(...r),r)};return o.defineProperties(n,{name:s.interface.getEventName(t),_contract:s,_key:t,getFragment:e}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=s.interface.getEvent(t);return o.assert(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),r}}),n}const pt=Symbol.for("_ethersInternal_contract"),Ie=new WeakMap;function kn(s,t){Ie.set(s[pt],t)}function U(s){return Ie.get(s[pt])}function Un(s){return s&&typeof s=="object"&&"getTopicFilter"in s&&typeof s.getTopicFilter=="function"&&s.fragment}async function Ft(s,t){let e,n=null;if(Array.isArray(t)){const i=function(a){if(o.isHexString(a,32))return a;const c=s.interface.getEvent(a);return o.assertArgument(c,"unknown fragment","name",a),c.topicHash};e=t.map(a=>a==null?null:Array.isArray(a)?a.map(i):i(a))}else t==="*"?e=[null]:typeof t=="string"?o.isHexString(t,32)?e=[t]:(n=s.interface.getEvent(t),o.assertArgument(n,"unknown fragment","event",t),e=[n.topicHash]):Un(t)?e=await t.getTopicFilter():"fragment"in t?(n=t.fragment,e=[n.topicHash]):o.assertArgument(!1,"unknown event name","event",t);e=e.map(i=>{if(i==null)return null;if(Array.isArray(i)){const a=Array.from(new Set(i.map(c=>c.toLowerCase())).values());return a.length===1?a[0]:(a.sort(),a)}return i.toLowerCase()});const r=e.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:n,tag:r,topics:e}}async function ot(s,t){const{subs:e}=U(s);return e.get((await Ft(s,t)).tag)||null}async function te(s,t,e){const n=X(s.runner);o.assert(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:r,tag:i,topics:a}=await Ft(s,e),{addr:c,subs:u}=U(s);let l=u.get(i);if(!l){const h={address:c||s,topics:a},d=P=>{let w=r;if(w==null)try{w=s.interface.getEvent(P.topics[0])}catch{}if(w){const k=w,W=r?s.interface.decodeEventLog(r,P.data,P.topics):[];Ot(s,e,W,Be=>new Nn(s,Be,e,k,P))}else Ot(s,e,[],k=>new ve(s,k,e,P))};let g=[];l={tag:i,listeners:[],start:()=>{g.length||g.push(n.on(h,d))},stop:async()=>{if(g.length==0)return;let P=g;g=[],await Promise.all(P),n.off(h,d)}},u.set(i,l)}return l}let vt=Promise.resolve();async function In(s,t,e,n){await vt;const r=await ot(s,t);if(!r)return!1;const i=r.listeners.length;return r.listeners=r.listeners.filter(({listener:a,once:c})=>{const u=Array.from(e);n&&u.push(n(c?null:a));try{a.call(s,...u)}catch{}return!c}),r.listeners.length===0&&(r.stop(),U(s).subs.delete(r.tag)),i>0}async function Ot(s,t,e,n){try{await vt}catch{}const r=In(s,t,e,n);return vt=r,await r}const dt=["then"];class nt{target;interface;runner;filters;[pt];fallback;constructor(t,e,n,r){o.assertArgument(typeof t=="string"||o.isAddressable(t),"invalid value for Contract target","target",t),n==null&&(n=null);const i=J.from(e);o.defineProperties(this,{target:t,runner:n,interface:i}),Object.defineProperty(this,pt,{value:{}});let a,c=null,u=null;if(r){const h=X(n);u=new St(this.interface,h,r)}let l=new Map;if(typeof t=="string")if(o.isHexString(t))c=t,a=Promise.resolve(t);else{const h=j(n,"resolveName");if(!bt(h))throw o.makeError("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});a=h.resolveName(t).then(d=>{if(d==null)throw o.makeError("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return U(this).addr=d,d})}else a=t.getAddress().then(h=>{if(h==null)throw new Error("TODO");return U(this).addr=h,h});kn(this,{addrPromise:a,addr:c,deployTx:u,subs:l});const f=new Proxy({},{get:(h,d,g)=>{if(typeof d=="symbol"||dt.indexOf(d)>=0)return Reflect.get(h,d,g);try{return this.getEvent(d)}catch(y){if(!o.isError(y,"INVALID_ARGUMENT")||y.argument!=="key")throw y}},has:(h,d)=>dt.indexOf(d)>=0?Reflect.has(h,d):Reflect.has(h,d)||this.interface.hasEvent(String(d))});return o.defineProperties(this,{filters:f}),o.defineProperties(this,{fallback:i.receive||i.fallback?On(this):null}),new Proxy(this,{get:(h,d,g)=>{if(typeof d=="symbol"||d in h||dt.indexOf(d)>=0)return Reflect.get(h,d,g);try{return h.getFunction(d)}catch(y){if(!o.isError(y,"INVALID_ARGUMENT")||y.argument!=="key")throw y}},has:(h,d)=>typeof d=="symbol"||d in h||dt.indexOf(d)>=0?Reflect.has(h,d):h.interface.hasFunction(d)})}connect(t){return new nt(this.target,this.interface,t)}attach(t){return new nt(t,this.interface,this.runner)}async getAddress(){return await U(this).addrPromise}async getDeployedCode(){const t=X(this.runner);o.assert(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return e==="0x"?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=X(this.runner);return o.assert(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((r,i)=>{const a=async()=>{try{if(await this.getDeployedCode()!=null)return r(this);n.once("block",a)}catch(c){i(c)}};a()})}deploymentTransaction(){return U(this).deployTx}getFunction(t){return typeof t!="string"&&(t=t.format()),Tn(this,t)}getEvent(t){return typeof t!="string"&&(t=t.format()),Rn(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,n){e==null&&(e=0),n==null&&(n="latest");const{addr:r,addrPromise:i}=U(this),a=r||await i,{fragment:c,topics:u}=await Ft(this,t),l={address:a,topics:u,fromBlock:e,toBlock:n},f=X(this.runner);return o.assert(f,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await f.getLogs(l)).map(h=>{let d=c;if(d==null)try{d=this.interface.getEvent(h.topics[0])}catch{}if(d)try{return new Bt(h,this.interface,d)}catch(g){return new Ne(h,g)}return new ut(h,f)})}async on(t,e){const n=await te(this,"on",t);return n.listeners.push({listener:e,once:!1}),n.start(),this}async once(t,e){const n=await te(this,"once",t);return n.listeners.push({listener:e,once:!0}),n.start(),this}async emit(t,...e){return await Ot(this,t,e,null)}async listenerCount(t){if(t){const r=await ot(this,t);return r?r.listeners.length:0}const{subs:e}=U(this);let n=0;for(const{listeners:r}of e.values())n+=r.length;return n}async listeners(t){if(t){const r=await ot(this,t);return r?r.listeners.map(({listener:i})=>i):[]}const{subs:e}=U(this);let n=[];for(const{listeners:r}of e.values())n=n.concat(r.map(({listener:i})=>i));return n}async off(t,e){const n=await ot(this,t);if(!n)return this;if(e){const r=n.listeners.map(({listener:i})=>i).indexOf(e);r>=0&&n.listeners.splice(r,1)}return(e==null||n.listeners.length===0)&&(n.stop(),U(this).subs.delete(n.tag)),this}async removeAllListeners(t){if(t){const e=await ot(this,t);if(!e)return this;e.stop(),U(this).subs.delete(e.tag)}else{const{subs:e}=U(this);for(const{tag:n,stop:r}of e.values())r(),e.delete(n)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){class e extends nt{constructor(r,i=null){super(r,t,i)}}return e}static from(t,e,n){return n==null&&(n=null),new this(t,e,n)}}function Bn(){return nt}class Sn extends Bn(){}exports.AbiCoder=st;exports.BaseContract=nt;exports.Block=En;exports.Contract=Sn;exports.EventPayload=re;exports.FeeData=bn;exports.Interface=J;exports.Log=ut;exports.TransactionReceipt=xe;exports.TransactionResponse=lt;exports.accessListify=le;exports.copyOverrides=Ct;exports.copyRequest=Ee;exports.fromTwos=ee;exports.getBigInt=H;exports.getNumber=L;exports.id=rt;exports.mask=at;exports.resolveArgs=Ue;exports.toBeArray=kt;exports.toBeHex=Rt;exports.toBigInt=Tt;exports.toQuantity=Ce;exports.toTwos=ne;exports.toUtf8Bytes=Ut;exports.toUtf8String=ie;
1
+ "use strict";const o=require("./web3-BKaP497Y.js"),gt=BigInt(0),B=BigInt(1),tt=9007199254740991;function ee(s,t){const e=mt(s,"value"),n=BigInt(L(t,"width"));if(o.assert(e>>n===gt,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:s}),e>>n-B){const r=(B<<n)-B;return-((~e&r)+B)}return e}function ne(s,t){let e=H(s,"value");const n=BigInt(L(t,"width")),r=B<<n-B;if(e<gt){e=-e,o.assert(e<=r,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:s});const i=(B<<n)-B;return(~e&i)+B}else o.assert(e<r,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:s});return e}function at(s,t){const e=mt(s,"value"),n=BigInt(L(t,"bits"));return e&(B<<n)-B}function H(s,t){switch(typeof s){case"bigint":return s;case"number":return o.assertArgument(Number.isInteger(s),"underflow",t||"value",s),o.assertArgument(s>=-tt&&s<=tt,"overflow",t||"value",s),BigInt(s);case"string":try{if(s==="")throw new Error("empty string");return s[0]==="-"&&s[1]!=="-"?-BigInt(s.substring(1)):BigInt(s)}catch(e){o.assertArgument(!1,`invalid BigNumberish string: ${e.message}`,t||"value",s)}}o.assertArgument(!1,"invalid BigNumberish value",t||"value",s)}function mt(s,t){const e=H(s,t);return o.assert(e>=gt,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:s}),e}const Lt="0123456789abcdef";function Tt(s){if(s instanceof Uint8Array){let t="0x0";for(const e of s)t+=Lt[e>>4],t+=Lt[e&15];return BigInt(t)}return H(s)}function L(s,t){switch(typeof s){case"bigint":return o.assertArgument(s>=-tt&&s<=tt,"overflow",t||"value",s),Number(s);case"number":return o.assertArgument(Number.isInteger(s),"underflow",t||"value",s),o.assertArgument(s>=-tt&&s<=tt,"overflow",t||"value",s),s;case"string":try{if(s==="")throw new Error("empty string");return L(BigInt(s),t)}catch(e){o.assertArgument(!1,`invalid numeric string: ${e.message}`,t||"value",s)}}o.assertArgument(!1,"invalid numeric value",t||"value",s)}function Se(s){return L(Tt(s))}function Rt(s,t){let n=mt(s,"value").toString(16);if(t==null)n.length%2&&(n="0"+n);else{const r=L(t,"width");for(o.assert(r*2>=n.length,`value exceeds width (${r} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:s});n.length<r*2;)n="0"+n}return"0x"+n}function kt(s){const t=mt(s,"value");if(t===gt)return new Uint8Array([]);let e=t.toString(16);e.length%2&&(e="0"+e);const n=new Uint8Array(e.length/2);for(let r=0;r<n.length;r++){const i=r*2;n[r]=parseInt(e.substring(i,i+2),16)}return n}function Ce(s){let t=o.hexlify(o.isBytesLike(s)?s:kt(s)).substring(2);for(;t.startsWith("0");)t=t.substring(1);return t===""&&(t="0"),"0x"+t}class re{filter;emitter;#t;constructor(t,e,n){this.#t=e,o.defineProperties(this,{emitter:t,filter:n})}async removeListener(){this.#t!=null&&await this.emitter.off(this.filter,this.#t)}}function Fe(s,t,e,n,r){o.assertArgument(!1,`invalid codepoint at offset ${t}; ${s}`,"bytes",e)}function se(s,t,e,n,r){if(s==="BAD_PREFIX"||s==="UNEXPECTED_CONTINUE"){let i=0;for(let a=t+1;a<e.length&&e[a]>>6===2;a++)i++;return i}return s==="OVERRUN"?e.length-t-1:0}function Le(s,t,e,n,r){return s==="OVERLONG"?(o.assertArgument(typeof r=="number","invalid bad code point for replacement","badCodepoint",r),n.push(r),0):(n.push(65533),se(s,t,e))}const De=Object.freeze({error:Fe,ignore:se,replace:Le});function $e(s,t){t==null&&(t=De.error);const e=o.getBytes(s,"bytes"),n=[];let r=0;for(;r<e.length;){const i=e[r++];if(i>>7===0){n.push(i);continue}let a=null,c=null;if((i&224)===192)a=1,c=127;else if((i&240)===224)a=2,c=2047;else if((i&248)===240)a=3,c=65535;else{(i&192)===128?r+=t("UNEXPECTED_CONTINUE",r-1,e,n):r+=t("BAD_PREFIX",r-1,e,n);continue}if(r-1+a>=e.length){r+=t("OVERRUN",r-1,e,n);continue}let u=i&(1<<8-a-1)-1;for(let l=0;l<a;l++){let f=e[r];if((f&192)!=128){r+=t("MISSING_CONTINUE",r,e,n),u=null;break}u=u<<6|f&63,r++}if(u!==null){if(u>1114111){r+=t("OUT_OF_RANGE",r-1-a,e,n,u);continue}if(u>=55296&&u<=57343){r+=t("UTF16_SURROGATE",r-1-a,e,n,u);continue}if(u<=c){r+=t("OVERLONG",r-1-a,e,n,u);continue}n.push(u)}}return n}function Ut(s,t){o.assertArgument(typeof s=="string","invalid string value","str",s),t!=null&&(o.assertNormalize(t),s=s.normalize(t));let e=[];for(let n=0;n<s.length;n++){const r=s.charCodeAt(n);if(r<128)e.push(r);else if(r<2048)e.push(r>>6|192),e.push(r&63|128);else if((r&64512)==55296){n++;const i=s.charCodeAt(n);o.assertArgument(n<s.length&&(i&64512)===56320,"invalid surrogate pair","str",s);const a=65536+((r&1023)<<10)+(i&1023);e.push(a>>18|240),e.push(a>>12&63|128),e.push(a>>6&63|128),e.push(a&63|128)}else e.push(r>>12|224),e.push(r>>6&63|128),e.push(r&63|128)}return new Uint8Array(e)}function Ge(s){return s.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function ie(s,t){return Ge($e(s,t))}const v=32,Pt=new Uint8Array(v),_e=["then"],ft={},ae=new WeakMap;function Y(s){return ae.get(s)}function Dt(s,t){ae.set(s,t)}function it(s,t){const e=new Error(`deferred error during ABI decoding triggered accessing ${s}`);throw e.error=t,e}function At(s,t,e){return s.indexOf(null)>=0?t.map((n,r)=>n instanceof G?At(Y(n),n,e):n):s.reduce((n,r,i)=>{let a=t.getValue(r);return r in n||(e&&a instanceof G&&(a=At(Y(a),a,e)),n[r]=a),n},{})}class G extends Array{#t;constructor(...t){const e=t[0];let n=t[1],r=(t[2]||[]).slice(),i=!0;e!==ft&&(n=t,r=[],i=!1),super(n.length),n.forEach((u,l)=>{this[l]=u});const a=r.reduce((u,l)=>(typeof l=="string"&&u.set(l,(u.get(l)||0)+1),u),new Map);if(Dt(this,Object.freeze(n.map((u,l)=>{const f=r[l];return f!=null&&a.get(f)===1?f:null}))),this.#t=[],this.#t==null&&this.#t,!i)return;Object.freeze(this);const c=new Proxy(this,{get:(u,l,f)=>{if(typeof l=="string"){if(l.match(/^[0-9]+$/)){const d=L(l,"%index");if(d<0||d>=this.length)throw new RangeError("out of result range");const g=u[d];return g instanceof Error&&it(`index ${d}`,g),g}if(_e.indexOf(l)>=0)return Reflect.get(u,l,f);const h=u[l];if(h instanceof Function)return function(...d){return h.apply(this===f?u:this,d)};if(!(l in u))return u.getValue.apply(this===f?u:this,[l])}return Reflect.get(u,l,f)}});return Dt(c,Y(this)),c}toArray(t){const e=[];return this.forEach((n,r)=>{n instanceof Error&&it(`index ${r}`,n),t&&n instanceof G&&(n=n.toArray(t)),e.push(n)}),e}toObject(t){const e=Y(this);return e.reduce((n,r,i)=>(o.assert(r!=null,`value at index ${i} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),At(e,this,t)),{})}slice(t,e){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),e==null&&(e=this.length),e<0&&(e+=this.length,e<0&&(e=0)),e>this.length&&(e=this.length);const n=Y(this),r=[],i=[];for(let a=t;a<e;a++)r.push(this[a]),i.push(n[a]);return new G(ft,r,i)}filter(t,e){const n=Y(this),r=[],i=[];for(let a=0;a<this.length;a++){const c=this[a];c instanceof Error&&it(`index ${a}`,c),t.call(e,c,a,this)&&(r.push(c),i.push(n[a]))}return new G(ft,r,i)}map(t,e){const n=[];for(let r=0;r<this.length;r++){const i=this[r];i instanceof Error&&it(`index ${r}`,i),n.push(t.call(e,i,r,this))}return n}getValue(t){const e=Y(this).indexOf(t);if(e===-1)return;const n=this[e];return n instanceof Error&&it(`property ${JSON.stringify(t)}`,n.error),n}static fromItems(t,e){return new G(ft,t,e)}}function $t(s){let t=kt(s);return o.assert(t.length<=v,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:v,offset:t.length}),t.length!==v&&(t=o.getBytesCopy(o.concat([Pt.slice(t.length%v),t]))),t}class z{name;type;localName;dynamic;constructor(t,e,n,r){o.defineProperties(this,{name:t,type:e,localName:n,dynamic:r},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){o.assertArgument(!1,t,this.localName,e)}}class Nt{#t;#e;constructor(){this.#t=[],this.#e=0}get data(){return o.concat(this.#t)}get length(){return this.#e}#n(t){return this.#t.push(t),this.#e+=t.length,t.length}appendWriter(t){return this.#n(o.getBytesCopy(t.data))}writeBytes(t){let e=o.getBytesCopy(t);const n=e.length%v;return n&&(e=o.getBytesCopy(o.concat([e,Pt.slice(n)]))),this.#n(e)}writeValue(t){return this.#n($t(t))}writeUpdatableValue(){const t=this.#t.length;return this.#t.push(Pt),this.#e+=v,e=>{this.#t[t]=$t(e)}}}class It{allowLoose;#t;#e;#n;#r;#s;constructor(t,e,n){o.defineProperties(this,{allowLoose:!!e}),this.#t=o.getBytesCopy(t),this.#n=0,this.#r=null,this.#s=n??1024,this.#e=0}get data(){return o.hexlify(this.#t)}get dataLength(){return this.#t.length}get consumed(){return this.#e}get bytes(){return new Uint8Array(this.#t)}#i(t){if(this.#r)return this.#r.#i(t);this.#n+=t,o.assert(this.#s<1||this.#n<=this.#s*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#s} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:o.getBytesCopy(this.#t),offset:this.#e,length:t,info:{bytesRead:this.#n,dataLength:this.dataLength}})}#a(t,e,n){let r=Math.ceil(e/v)*v;return this.#e+r>this.#t.length&&(this.allowLoose&&n&&this.#e+e<=this.#t.length?r=e:o.assert(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:o.getBytesCopy(this.#t),length:this.#t.length,offset:this.#e+r})),this.#t.slice(this.#e,this.#e+r)}subReader(t){const e=new It(this.#t.slice(this.#e+t),this.allowLoose,this.#s);return e.#r=this,e}readBytes(t,e){let n=this.#a(0,t,!!e);return this.#i(t),this.#e+=n.length,n.slice(0,t)}readValue(){return Tt(this.readBytes(v))}readIndex(){return Se(this.readBytes(v))}}const D={};function p(s,t){let e=!1;return t<0&&(e=!0,t*=-1),new A(D,`${e?"":"u"}int${t}`,s,{signed:e,width:t})}function m(s,t){return new A(D,`bytes${t||""}`,s,{size:t})}const Gt=Symbol.for("_ethers_typed");class A{type;value;#t;_typedSymbol;constructor(t,e,n,r){r==null&&(r=null),o.assertPrivate(D,t,"Typed"),o.defineProperties(this,{_typedSymbol:Gt,type:e,value:n}),this.#t=r,this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(t=>t.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return this.#t}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return this.#t===!0?-1:this.#t===!1?this.value.length:null}static from(t,e){return new A(D,t,e)}static uint8(t){return p(t,8)}static uint16(t){return p(t,16)}static uint24(t){return p(t,24)}static uint32(t){return p(t,32)}static uint40(t){return p(t,40)}static uint48(t){return p(t,48)}static uint56(t){return p(t,56)}static uint64(t){return p(t,64)}static uint72(t){return p(t,72)}static uint80(t){return p(t,80)}static uint88(t){return p(t,88)}static uint96(t){return p(t,96)}static uint104(t){return p(t,104)}static uint112(t){return p(t,112)}static uint120(t){return p(t,120)}static uint128(t){return p(t,128)}static uint136(t){return p(t,136)}static uint144(t){return p(t,144)}static uint152(t){return p(t,152)}static uint160(t){return p(t,160)}static uint168(t){return p(t,168)}static uint176(t){return p(t,176)}static uint184(t){return p(t,184)}static uint192(t){return p(t,192)}static uint200(t){return p(t,200)}static uint208(t){return p(t,208)}static uint216(t){return p(t,216)}static uint224(t){return p(t,224)}static uint232(t){return p(t,232)}static uint240(t){return p(t,240)}static uint248(t){return p(t,248)}static uint256(t){return p(t,256)}static uint(t){return p(t,256)}static int8(t){return p(t,-8)}static int16(t){return p(t,-16)}static int24(t){return p(t,-24)}static int32(t){return p(t,-32)}static int40(t){return p(t,-40)}static int48(t){return p(t,-48)}static int56(t){return p(t,-56)}static int64(t){return p(t,-64)}static int72(t){return p(t,-72)}static int80(t){return p(t,-80)}static int88(t){return p(t,-88)}static int96(t){return p(t,-96)}static int104(t){return p(t,-104)}static int112(t){return p(t,-112)}static int120(t){return p(t,-120)}static int128(t){return p(t,-128)}static int136(t){return p(t,-136)}static int144(t){return p(t,-144)}static int152(t){return p(t,-152)}static int160(t){return p(t,-160)}static int168(t){return p(t,-168)}static int176(t){return p(t,-176)}static int184(t){return p(t,-184)}static int192(t){return p(t,-192)}static int200(t){return p(t,-200)}static int208(t){return p(t,-208)}static int216(t){return p(t,-216)}static int224(t){return p(t,-224)}static int232(t){return p(t,-232)}static int240(t){return p(t,-240)}static int248(t){return p(t,-248)}static int256(t){return p(t,-256)}static int(t){return p(t,-256)}static bytes1(t){return m(t,1)}static bytes2(t){return m(t,2)}static bytes3(t){return m(t,3)}static bytes4(t){return m(t,4)}static bytes5(t){return m(t,5)}static bytes6(t){return m(t,6)}static bytes7(t){return m(t,7)}static bytes8(t){return m(t,8)}static bytes9(t){return m(t,9)}static bytes10(t){return m(t,10)}static bytes11(t){return m(t,11)}static bytes12(t){return m(t,12)}static bytes13(t){return m(t,13)}static bytes14(t){return m(t,14)}static bytes15(t){return m(t,15)}static bytes16(t){return m(t,16)}static bytes17(t){return m(t,17)}static bytes18(t){return m(t,18)}static bytes19(t){return m(t,19)}static bytes20(t){return m(t,20)}static bytes21(t){return m(t,21)}static bytes22(t){return m(t,22)}static bytes23(t){return m(t,23)}static bytes24(t){return m(t,24)}static bytes25(t){return m(t,25)}static bytes26(t){return m(t,26)}static bytes27(t){return m(t,27)}static bytes28(t){return m(t,28)}static bytes29(t){return m(t,29)}static bytes30(t){return m(t,30)}static bytes31(t){return m(t,31)}static bytes32(t){return m(t,32)}static address(t){return new A(D,"address",t)}static bool(t){return new A(D,"bool",!!t)}static bytes(t){return new A(D,"bytes",t)}static string(t){return new A(D,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new A(D,"overrides",Object.assign({},t))}static isTyped(t){return t&&typeof t=="object"&&"_typedSymbol"in t&&t._typedSymbol===Gt}static dereference(t,e){if(A.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}}class Ve extends z{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let n=A.dereference(e,"string");try{n=o.getAddress(n)}catch(r){return this._throwError(r.message,e)}return t.writeValue(n)}decode(t){return o.getAddress(Rt(t.readValue(),20))}}class Me extends z{coder;constructor(t){super(t.name,t.type,"_",t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function oe(s,t,e){let n=[];if(Array.isArray(e))n=e;else if(e&&typeof e=="object"){let u={};n=t.map(l=>{const f=l.localName;return o.assert(f,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:e}),o.assert(!u[f],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:e}),u[f]=!0,e[f]})}else o.assertArgument(!1,"invalid tuple value","tuple",e);o.assertArgument(t.length===n.length,"types/value length mismatch","tuple",e);let r=new Nt,i=new Nt,a=[];t.forEach((u,l)=>{let f=n[l];if(u.dynamic){let h=i.length;u.encode(i,f);let d=r.writeUpdatableValue();a.push(g=>{d(g+h)})}else u.encode(r,f)}),a.forEach(u=>{u(r.length)});let c=s.appendWriter(r);return c+=s.appendWriter(i),c}function ce(s,t){let e=[],n=[],r=s.subReader(0);return t.forEach(i=>{let a=null;if(i.dynamic){let c=s.readIndex(),u=r.subReader(c);try{a=i.decode(u)}catch(l){if(o.isError(l,"BUFFER_OVERRUN"))throw l;a=l,a.baseType=i.name,a.name=i.localName,a.type=i.type}}else try{a=i.decode(s)}catch(c){if(o.isError(c,"BUFFER_OVERRUN"))throw c;a=c,a.baseType=i.name,a.name=i.localName,a.type=i.type}if(a==null)throw new Error("investigate");e.push(a),n.push(i.localName||null)}),G.fromItems(e,n)}class He extends z{coder;length;constructor(t,e,n){const r=t.type+"["+(e>=0?e:"")+"]",i=e===-1||t.dynamic;super("array",r,n,i),o.defineProperties(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let n=0;n<this.length;n++)e.push(t);return e}encode(t,e){const n=A.dereference(e,"array");Array.isArray(n)||this._throwError("expected array value",n);let r=this.length;r===-1&&(r=n.length,t.writeValue(n.length)),o.assertArgumentCount(n.length,r,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let a=0;a<n.length;a++)i.push(this.coder);return oe(t,i,n)}decode(t){let e=this.length;e===-1&&(e=t.readIndex(),o.assert(e*v<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*v,length:t.dataLength}));let n=[];for(let r=0;r<e;r++)n.push(new Me(this.coder));return ce(t,n)}}class ze extends z{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const n=A.dereference(e,"bool");return t.writeValue(n?1:0)}decode(t){return!!t.readValue()}}class ue extends z{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=o.getBytesCopy(e);let n=t.writeValue(e.length);return n+=t.writeBytes(e),n}decode(t){return t.readBytes(t.readIndex(),!0)}}class Je extends ue{constructor(t){super("bytes",t)}decode(t){return o.hexlify(super.decode(t))}}class Ke extends z{size;constructor(t,e){let n="bytes"+String(t);super(n,n,e,!1),o.defineProperties(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,e){let n=o.getBytesCopy(A.dereference(e,this.type));return n.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(n)}decode(t){return o.hexlify(t.readBytes(this.size))}}const We=new Uint8Array([]);class Ye extends z{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return e!=null&&this._throwError("not null",e),t.writeBytes(We)}decode(t){return t.readBytes(0),null}}const Xe=BigInt(0),Ze=BigInt(1),Qe=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class qe extends z{size;signed;constructor(t,e,n){const r=(e?"int":"uint")+t*8;super(r,r,n,!1),o.defineProperties(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let n=H(A.dereference(e,this.type)),r=at(Qe,v*8);if(this.signed){let i=at(r,this.size*8-1);(n>i||n<-(i+Ze))&&this._throwError("value out-of-bounds",e),n=ne(n,8*v)}else(n<Xe||n>at(r,this.size*8))&&this._throwError("value out-of-bounds",e);return t.writeValue(n)}decode(t){let e=at(t.readValue(),this.size*8);return this.signed&&(e=ee(e,this.size*8)),e}}class je extends ue{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Ut(A.dereference(e,"string")))}decode(t){return ie(super.decode(t))}}class ht extends z{coders;constructor(t,e){let n=!1;const r=[];t.forEach(a=>{a.dynamic&&(n=!0),r.push(a.type)});const i="tuple("+r.join(",")+")";super("tuple",i,e,n),o.defineProperties(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(n=>{t.push(n.defaultValue())});const e=this.coders.reduce((n,r)=>{const i=r.localName;return i&&(n[i]||(n[i]=0),n[i]++),n},{});return this.coders.forEach((n,r)=>{let i=n.localName;!i||e[i]!==1||(i==="length"&&(i="_length"),t[i]==null&&(t[i]=t[r]))}),Object.freeze(t)}encode(t,e){const n=A.dereference(e,"tuple");return oe(t,this.coders,n)}decode(t){return ce(t,this.coders)}}function rt(s){return o.keccak256(Ut(s))}function Et(s,t){return{address:o.getAddress(s),storageKeys:t.map((e,n)=>(o.assertArgument(o.isHexString(e,32),"invalid slot",`storageKeys[${n}]`,e),e.toLowerCase()))}}function le(s){if(Array.isArray(s))return s.map((e,n)=>Array.isArray(e)?(o.assertArgument(e.length===2,"invalid slot set",`value[${n}]`,e),Et(e[0],e[1])):(o.assertArgument(e!=null&&typeof e=="object","invalid address-slot set","value",s),Et(e.address,e.storageKeys)));o.assertArgument(s!=null&&typeof s=="object","invalid access list","value",s);const t=Object.keys(s).map(e=>{const n=s[e].reduce((r,i)=>(r[i]=!0,r),{});return Et(e,Object.keys(n).sort())});return t.sort((e,n)=>e.address.localeCompare(n.address)),t}function O(s){const t=new Set;return s.forEach(e=>t.add(e)),Object.freeze(t)}const tn="external public payable override",en=O(tn.split(" ")),fe="constant external internal payable private public pure view override",nn=O(fe.split(" ")),he="constructor error event fallback function receive struct",de=O(he.split(" ")),pe="calldata memory storage payable indexed",rn=O(pe.split(" ")),sn="tuple returns",an=[he,pe,sn,fe].join(" "),on=O(an.split(" ")),cn={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},un=new RegExp("^(\\s*)"),ln=new RegExp("^([0-9]+)"),fn=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),ge=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),me=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class I{#t;#e;get offset(){return this.#t}get length(){return this.#e.length-this.#t}constructor(t){this.#t=0,this.#e=t.slice()}clone(){return new I(this.#e)}reset(){this.#t=0}#n(t=0,e=0){return new I(this.#e.slice(t,e).map(n=>Object.freeze(Object.assign({},n,{match:n.match-t,linkBack:n.linkBack-t,linkNext:n.linkNext-t}))))}popKeyword(t){const e=this.peek();if(e.type!=="KEYWORD"||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=this.#n(this.#t+1,t.match+1);return this.#t=t.match+1,e}popParams(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=[];for(;this.#t<t.match-1;){const n=this.peek().linkNext;e.push(this.#n(this.#t+1,n)),this.#t=n}return this.#t=t.match+1,e}peek(){if(this.#t>=this.#e.length)throw new Error("out-of-bounds");return this.#e[this.#t]}peekKeyword(t){const e=this.peekType("KEYWORD");return e!=null&&t.has(e)?e:null}peekType(t){if(this.length===0)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return this.#t++,t}toString(){const t=[];for(let e=this.#t;e<this.#e.length;e++){const n=this.#e[e];t.push(`${n.type}:${n.text}`)}return`<TokenString ${t.join(" ")}>`}}function K(s){const t=[],e=a=>{const c=i<s.length?JSON.stringify(s[i]):"$EOI";throw new Error(`invalid token ${c} at ${i}: ${a}`)};let n=[],r=[],i=0;for(;i<s.length;){let a=s.substring(i),c=a.match(un);c&&(i+=c[1].length,a=s.substring(i));const u={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};t.push(u);let l=cn[a[0]]||"";if(l){if(u.type=l,u.text=a[0],i++,l==="OPEN_PAREN")n.push(t.length-1),r.push(t.length-1);else if(l=="CLOSE_PAREN")n.length===0&&e("no matching open bracket"),u.match=n.pop(),t[u.match].match=t.length-1,u.depth--,u.linkBack=r.pop(),t[u.linkBack].linkNext=t.length-1;else if(l==="COMMA")u.linkBack=r.pop(),t[u.linkBack].linkNext=t.length-1,r.push(t.length-1);else if(l==="OPEN_BRACKET")u.type="BRACKET";else if(l==="CLOSE_BRACKET"){let f=t.pop().text;if(t.length>0&&t[t.length-1].type==="NUMBER"){const h=t.pop().text;f=h+f,t[t.length-1].value=L(h)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=f}continue}if(c=a.match(fn),c){if(u.text=c[1],i+=u.text.length,on.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(me)){u.type="TYPE";continue}u.type="ID";continue}if(c=a.match(ln),c){u.text=c[1],u.type="NUMBER",i+=u.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${i}`)}return new I(t.map(a=>Object.freeze(a)))}function _t(s,t){let e=[];for(const n in t.keys())s.has(n)&&e.push(n);if(e.length>1)throw new Error(`conflicting types: ${e.join(", ")}`)}function yt(s,t){if(t.peekKeyword(de)){const e=t.pop().text;if(e!==s)throw new Error(`expected ${s}, got ${e}`)}return t.popType("ID")}function M(s,t){const e=new Set;for(;;){const n=s.peekType("KEYWORD");if(n==null||t&&!t.has(n))break;if(s.pop(),e.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);e.add(n)}return Object.freeze(e)}function ye(s){let t=M(s,nn);return _t(t,O("constant payable nonpayable".split(" "))),_t(t,O("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function V(s,t){return s.popParams().map(e=>E.from(e,t))}function we(s){if(s.peekType("AT")){if(s.pop(),s.peekType("NUMBER"))return H(s.pop().text);throw new Error("invalid gas")}return null}function Q(s){if(s.length)throw new Error(`unexpected tokens at offset ${s.offset}: ${s.toString()}`)}const hn=new RegExp(/^(.*)\[([0-9]*)\]$/);function Vt(s){const t=s.match(me);if(o.assertArgument(t,"invalid type","type",s),s==="uint")return"uint256";if(s==="int")return"int256";if(t[2]){const e=parseInt(t[2]);o.assertArgument(e!==0&&e<=32,"invalid bytes length","type",s)}else if(t[3]){const e=parseInt(t[3]);o.assertArgument(e!==0&&e<=256&&e%8===0,"invalid numeric width","type",s)}return s}const x={},R=Symbol.for("_ethers_internal"),Mt="_ParamTypeInternal",Ht="_ErrorInternal",zt="_EventInternal",Jt="_ConstructorInternal",Kt="_FallbackInternal",Wt="_FunctionInternal",Yt="_StructInternal";class E{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(t,e,n,r,i,a,c,u){if(o.assertPrivate(t,x,"ParamType"),Object.defineProperty(this,R,{value:Mt}),a&&(a=Object.freeze(a.slice())),r==="array"){if(c==null||u==null)throw new Error("")}else if(c!=null||u!=null)throw new Error("");if(r==="tuple"){if(a==null)throw new Error("")}else if(a!=null)throw new Error("");o.defineProperties(this,{name:e,type:n,baseType:r,indexed:i,components:a,arrayLength:c,arrayChildren:u})}format(t){if(t==null&&(t="sighash"),t==="json"){const n=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=n,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const r={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map(i=>JSON.parse(i.format(t)))),JSON.stringify(r)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map(n=>n.format(t)).join(t==="full"?", ":",")+")":e+=this.type,t!=="sighash"&&(this.indexed===!0&&(e+=" indexed"),t==="full"&&this.name&&(e+=" "+this.name)),e}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return t.map(r=>n.arrayChildren.walk(r,e))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const n=this;return t.map((r,i)=>n.components[i].walk(r,e))}return e(this.type,t)}#t(t,e,n,r){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const a=this.arrayChildren,c=e.slice();c.forEach((u,l)=>{a.#t(t,u,n,f=>{c[l]=f})}),r(c);return}if(this.isTuple()){const a=this.components;let c;if(Array.isArray(e))c=e.slice();else{if(e==null||typeof e!="object")throw new Error("invalid tuple value");c=a.map(u=>{if(!u.name)throw new Error("cannot use object value with unnamed components");if(!(u.name in e))throw new Error(`missing value for component ${u.name}`);return e[u.name]})}if(c.length!==this.components.length)throw new Error("array is wrong length");c.forEach((u,l)=>{a[l].#t(t,u,n,f=>{c[l]=f})}),r(c);return}const i=n(this.type,e);i.then?t.push((async function(){r(await i)})()):r(i)}async walkAsync(t,e){const n=[],r=[t];return this.#t(n,t,e,i=>{r[0]=i}),n.length&&await Promise.all(n),r[0]}static from(t,e){if(E.isParamType(t))return t;if(typeof t=="string")try{return E.from(K(t),e)}catch{o.assertArgument(!1,"invalid param type","obj",t)}else if(t instanceof I){let c="",u="",l=null;M(t,O(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(u="tuple",l=t.popParams().map(b=>E.from(b)),c=`tuple(${l.map(b=>b.format()).join(",")})`):(c=Vt(t.popType("TYPE")),u=c);let f=null,h=null;for(;t.length&&t.peekType("BRACKET");){const b=t.pop();f=new E(x,"",c,u,null,l,h,f),h=b.value,c+=b.text,u="array",l=null}let d=null;if(M(t,rn).has("indexed")){if(!e)throw new Error("");d=!0}const y=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new E(x,y,c,u,d,l,h,f)}const n=t.name;o.assertArgument(!n||typeof n=="string"&&n.match(ge),"invalid name","obj.name",n);let r=t.indexed;r!=null&&(o.assertArgument(e,"parameter cannot be indexed","obj.indexed",t.indexed),r=!!r);let i=t.type,a=i.match(hn);if(a){const c=parseInt(a[2]||"-1"),u=E.from({type:a[1],components:t.components});return new E(x,n||"",i,"array",r,null,c,u)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const c=t.components!=null?t.components.map(l=>E.from(l)):null;return new E(x,n||"",i,"tuple",r,c,null,null)}return i=Vt(t.type),new E(x,n||"",i,i,r,null,null,null)}static isParamType(t){return t&&t[R]===Mt}}class q{type;inputs;constructor(t,e,n){o.assertPrivate(t,x,"Fragment"),n=Object.freeze(n.slice()),o.defineProperties(this,{type:e,inputs:n})}static from(t){if(typeof t=="string"){try{q.from(JSON.parse(t))}catch{}return q.from(K(t))}if(t instanceof I)switch(t.peekKeyword(de)){case"constructor":return _.from(t);case"error":return T.from(t);case"event":return C.from(t);case"fallback":case"receive":return $.from(t);case"function":return F.from(t);case"struct":return Z.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return _.from(t);case"error":return T.from(t);case"event":return C.from(t);case"fallback":case"receive":return $.from(t);case"function":return F.from(t);case"struct":return Z.from(t)}o.assert(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}o.assertArgument(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return _.isFragment(t)}static isError(t){return T.isFragment(t)}static isEvent(t){return C.isFragment(t)}static isFunction(t){return F.isFragment(t)}static isStruct(t){return Z.isFragment(t)}}class wt extends q{name;constructor(t,e,n,r){super(t,e,r),o.assertArgument(typeof n=="string"&&n.match(ge),"invalid identifier","name",n),r=Object.freeze(r.slice()),o.defineProperties(this,{name:n})}}function ct(s,t){return"("+t.map(e=>e.format(s)).join(s==="full"?", ":",")+")"}class T extends wt{constructor(t,e,n){super(t,"error",e,n),Object.defineProperty(this,R,{value:Ht})}get selector(){return rt(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("error"),e.push(this.name+ct(t,this.inputs)),e.join(" ")}static from(t){if(T.isFragment(t))return t;if(typeof t=="string")return T.from(K(t));if(t instanceof I){const e=yt("error",t),n=V(t);return Q(t),new T(x,e,n)}return new T(x,t.name,t.inputs?t.inputs.map(E.from):[])}static isFragment(t){return t&&t[R]===Ht}}class C extends wt{anonymous;constructor(t,e,n,r){super(t,"event",e,n),Object.defineProperty(this,R,{value:zt}),o.defineProperties(this,{anonymous:r})}get topicHash(){return rt(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("event"),e.push(this.name+ct(t,this.inputs)),t!=="sighash"&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){return e=(e||[]).map(r=>E.from(r)),new C(x,t,e,!1).topicHash}static from(t){if(C.isFragment(t))return t;if(typeof t=="string")try{return C.from(K(t))}catch{o.assertArgument(!1,"invalid event fragment","obj",t)}else if(t instanceof I){const e=yt("event",t),n=V(t,!0),r=!!M(t,O(["anonymous"])).has("anonymous");return Q(t),new C(x,e,n,r)}return new C(x,t.name,t.inputs?t.inputs.map(e=>E.from(e,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[R]===zt}}class _ extends q{payable;gas;constructor(t,e,n,r,i){super(t,e,n),Object.defineProperty(this,R,{value:Jt}),o.defineProperties(this,{payable:r,gas:i})}format(t){if(o.assert(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[`constructor${ct(t,this.inputs)}`];return this.payable&&e.push("payable"),this.gas!=null&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if(_.isFragment(t))return t;if(typeof t=="string")try{return _.from(K(t))}catch{o.assertArgument(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof I){M(t,O(["constructor"]));const e=V(t),n=!!M(t,en).has("payable"),r=we(t);return Q(t),new _(x,"constructor",e,n,r)}return new _(x,"constructor",t.inputs?t.inputs.map(E.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[R]===Jt}}class $ extends q{payable;constructor(t,e,n){super(t,"fallback",e),Object.defineProperty(this,R,{value:Kt}),o.defineProperties(this,{payable:n})}format(t){const e=this.inputs.length===0?"receive":"fallback";if(t==="json"){const n=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:n})}return`${e}()${this.payable?" payable":""}`}static from(t){if($.isFragment(t))return t;if(typeof t=="string")try{return $.from(K(t))}catch{o.assertArgument(!1,"invalid fallback fragment","obj",t)}else if(t instanceof I){const e=t.toString(),n=t.peekKeyword(O(["fallback","receive"]));if(o.assertArgument(n,"type must be fallback or receive","obj",e),t.popKeyword(O(["fallback","receive"]))==="receive"){const c=V(t);return o.assertArgument(c.length===0,"receive cannot have arguments","obj.inputs",c),M(t,O(["payable"])),Q(t),new $(x,[],!0)}let i=V(t);i.length?o.assertArgument(i.length===1&&i[0].type==="bytes","invalid fallback inputs","obj.inputs",i.map(c=>c.format("minimal")).join(", ")):i=[E.from("bytes")];const a=ye(t);if(o.assertArgument(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),M(t,O(["returns"])).has("returns")){const c=V(t);o.assertArgument(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(u=>u.format("minimal")).join(", "))}return Q(t),new $(x,i,a==="payable")}if(t.type==="receive")return new $(x,[],!0);if(t.type==="fallback"){const e=[E.from("bytes")],n=t.stateMutability==="payable";return new $(x,e,n)}o.assertArgument(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[R]===Kt}}class F extends wt{constant;outputs;stateMutability;payable;gas;constructor(t,e,n,r,i,a){super(t,"function",e,r),Object.defineProperty(this,R,{value:Wt}),i=Object.freeze(i.slice());const c=n==="view"||n==="pure",u=n==="payable";o.defineProperties(this,{constant:c,gas:a,outputs:i,payable:u,stateMutability:n})}get selector(){return rt(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(t))),outputs:this.outputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("function"),e.push(this.name+ct(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(ct(t,this.outputs))),this.gas!=null&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){return e=(e||[]).map(r=>E.from(r)),new F(x,t,"view",e,[],null).selector}static from(t){if(F.isFragment(t))return t;if(typeof t=="string")try{return F.from(K(t))}catch{o.assertArgument(!1,"invalid function fragment","obj",t)}else if(t instanceof I){const n=yt("function",t),r=V(t),i=ye(t);let a=[];M(t,O(["returns"])).has("returns")&&(a=V(t));const c=we(t);return Q(t),new F(x,n,i,r,a,c)}let e=t.stateMutability;return e==null&&(e="payable",typeof t.constant=="boolean"?(e="view",t.constant||(e="payable",typeof t.payable=="boolean"&&!t.payable&&(e="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(e="nonpayable")),new F(x,t.name,e,t.inputs?t.inputs.map(E.from):[],t.outputs?t.outputs.map(E.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[R]===Wt}}class Z extends wt{constructor(t,e,n){super(t,"struct",e,n),Object.defineProperty(this,R,{value:Yt})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return Z.from(K(t))}catch{o.assertArgument(!1,"invalid struct fragment","obj",t)}else if(t instanceof I){const e=yt("struct",t),n=V(t);return Q(t),new Z(x,e,n)}return new Z(x,t.name,t.inputs?t.inputs.map(E.from):[])}static isFragment(t){return t&&t[R]===Yt}}const S=new Map;S.set(0,"GENERIC_PANIC");S.set(1,"ASSERT_FALSE");S.set(17,"OVERFLOW");S.set(18,"DIVIDE_BY_ZERO");S.set(33,"ENUM_RANGE_ERROR");S.set(34,"BAD_STORAGE_DATA");S.set(49,"STACK_UNDERFLOW");S.set(50,"ARRAY_RANGE_ERROR");S.set(65,"OUT_OF_MEMORY");S.set(81,"UNINITIALIZED_FUNCTION_CALL");const dn=new RegExp(/^bytes([0-9]*)$/),pn=new RegExp(/^(u?int)([0-9]*)$/);let xt=null,Xt=1024;function gn(s,t,e,n){let r="missing revert data",i=null;const a=null;let c=null;if(e){r="execution reverted";const l=o.getBytes(e);if(e=o.hexlify(e),l.length===0)r+=" (no data present; likely require(false) occurred",i="require(false)";else if(l.length%32!==4)r+=" (could not decode reason; invalid data length)";else if(o.hexlify(l.slice(0,4))==="0x08c379a0")try{i=n.decode(["string"],l.slice(4))[0],c={signature:"Error(string)",name:"Error",args:[i]},r+=`: ${JSON.stringify(i)}`}catch{r+=" (could not decode reason; invalid string data)"}else if(o.hexlify(l.slice(0,4))==="0x4e487b71")try{const f=Number(n.decode(["uint256"],l.slice(4))[0]);c={signature:"Panic(uint256)",name:"Panic",args:[f]},i=`Panic due to ${S.get(f)||"UNKNOWN"}(${f})`,r+=`: ${i}`}catch{r+=" (could not decode panic code)"}else r+=" (unknown custom error)"}const u={to:t.to?o.getAddress(t.to):null,data:t.data||"0x"};return t.from&&(u.from=o.getAddress(t.from)),o.makeError(r,"CALL_EXCEPTION",{action:s,data:e,reason:i,transaction:u,invocation:a,revert:c})}class st{#t(t){if(t.isArray())return new He(this.#t(t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new ht(t.components.map(n=>this.#t(n)),t.name);switch(t.baseType){case"address":return new Ve(t.name);case"bool":return new ze(t.name);case"string":return new je(t.name);case"bytes":return new Je(t.name);case"":return new Ye(t.name)}let e=t.type.match(pn);if(e){let n=parseInt(e[2]||"256");return o.assertArgument(n!==0&&n<=256&&n%8===0,"invalid "+e[1]+" bit length","param",t),new qe(n/8,e[1]==="int",t.name)}if(e=t.type.match(dn),e){let n=parseInt(e[1]);return o.assertArgument(n!==0&&n<=32,"invalid bytes length","param",t),new Ke(n,t.name)}o.assertArgument(!1,"invalid type","type",t.type)}getDefaultValue(t){const e=t.map(r=>this.#t(E.from(r)));return new ht(e,"_").defaultValue()}encode(t,e){o.assertArgumentCount(e.length,t.length,"types/values length mismatch");const n=t.map(a=>this.#t(E.from(a))),r=new ht(n,"_"),i=new Nt;return r.encode(i,e),i.data}decode(t,e,n){const r=t.map(a=>this.#t(E.from(a)));return new ht(r,"_").decode(new It(e,n,Xt))}static _setDefaultMaxInflation(t){o.assertArgument(typeof t=="number"&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),Xt=t}static defaultAbiCoder(){return xt==null&&(xt=new st),xt}static getBuiltinCallException(t,e,n){return gn(t,e,n,st.defaultAbiCoder())}}class mn{fragment;name;signature;topic;args;constructor(t,e,n){const r=t.name,i=t.format();o.defineProperties(this,{fragment:t,name:r,signature:i,topic:e,args:n})}}class yn{fragment;name;args;signature;selector;value;constructor(t,e,n,r){const i=t.name,a=t.format();o.defineProperties(this,{fragment:t,name:i,args:n,signature:a,selector:e,value:r})}}class wn{fragment;name;args;signature;selector;constructor(t,e,n){const r=t.name,i=t.format();o.defineProperties(this,{fragment:t,name:r,args:n,signature:i,selector:e})}}class Zt{hash;_isIndexed;static isIndexed(t){return!!(t&&t._isIndexed)}constructor(t){o.defineProperties(this,{hash:t,_isIndexed:!0})}}const Qt={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},qt={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:s=>`reverted with reason string ${JSON.stringify(s)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:s=>{let t="unknown panic code";return s>=0&&s<=255&&Qt[s.toString()]&&(t=Qt[s.toString()]),`reverted with panic code 0x${s.toString(16)} (${t})`}}};class J{fragments;deploy;fallback;receive;#t;#e;#n;#r;constructor(t){let e=[];typeof t=="string"?e=JSON.parse(t):e=t,this.#n=new Map,this.#t=new Map,this.#e=new Map;const n=[];for(const a of e)try{n.push(q.from(a))}catch(c){console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`,c.message)}o.defineProperties(this,{fragments:Object.freeze(n)});let r=null,i=!1;this.#r=this.getAbiCoder(),this.fragments.forEach((a,c)=>{let u;switch(a.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}o.defineProperties(this,{deploy:a});return;case"fallback":a.inputs.length===0?i=!0:(o.assertArgument(!r||a.payable!==r.payable,"conflicting fallback fragments",`fragments[${c}]`,a),r=a,i=r.payable);return;case"function":u=this.#n;break;case"event":u=this.#e;break;case"error":u=this.#t;break;default:return}const l=a.format();u.has(l)||u.set(l,a)}),this.deploy||o.defineProperties(this,{deploy:_.from("constructor()")}),o.defineProperties(this,{fallback:r,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map(r=>r.format(e))}formatJson(){const t=this.fragments.map(e=>e.format("json"));return JSON.stringify(t.map(e=>JSON.parse(e)))}getAbiCoder(){return st.defaultAbiCoder()}#s(t,e,n){if(o.isHexString(t)){const i=t.toLowerCase();for(const a of this.#n.values())if(i===a.selector)return a;return null}if(t.indexOf("(")===-1){const i=[];for(const[a,c]of this.#n)a.split("(")[0]===t&&i.push(c);if(e){const a=e.length>0?e[e.length-1]:null;let c=e.length,u=!0;A.isTyped(a)&&a.type==="overrides"&&(u=!1,c--);for(let l=i.length-1;l>=0;l--){const f=i[l].inputs.length;f!==c&&(!u||f!==c-1)&&i.splice(l,1)}for(let l=i.length-1;l>=0;l--){const f=i[l].inputs;for(let h=0;h<e.length;h++)if(A.isTyped(e[h])){if(h>=f.length){if(e[h].type==="overrides")continue;i.splice(l,1);break}if(e[h].type!==f[h].baseType){i.splice(l,1);break}}}}if(i.length===1&&e&&e.length!==i[0].inputs.length){const a=e[e.length-1];(a==null||Array.isArray(a)||typeof a!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&n){const a=i.map(c=>JSON.stringify(c.format())).join(", ");o.assertArgument(!1,`ambiguous function description (i.e. matches ${a})`,"key",t)}return i[0]}const r=this.#n.get(F.from(t).format());return r||null}getFunctionName(t){const e=this.#s(t,null,!1);return o.assertArgument(e,"no matching function","key",t),e.name}hasFunction(t){return!!this.#s(t,null,!1)}getFunction(t,e){return this.#s(t,e||null,!0)}forEachFunction(t){const e=Array.from(this.#n.keys());e.sort((n,r)=>n.localeCompare(r));for(let n=0;n<e.length;n++){const r=e[n];t(this.#n.get(r),n)}}#i(t,e,n){if(o.isHexString(t)){const i=t.toLowerCase();for(const a of this.#e.values())if(i===a.topicHash)return a;return null}if(t.indexOf("(")===-1){const i=[];for(const[a,c]of this.#e)a.split("(")[0]===t&&i.push(c);if(e){for(let a=i.length-1;a>=0;a--)i[a].inputs.length<e.length&&i.splice(a,1);for(let a=i.length-1;a>=0;a--){const c=i[a].inputs;for(let u=0;u<e.length;u++)if(A.isTyped(e[u])&&e[u].type!==c[u].baseType){i.splice(a,1);break}}}if(i.length===0)return null;if(i.length>1&&n){const a=i.map(c=>JSON.stringify(c.format())).join(", ");o.assertArgument(!1,`ambiguous event description (i.e. matches ${a})`,"key",t)}return i[0]}const r=this.#e.get(C.from(t).format());return r||null}getEventName(t){const e=this.#i(t,null,!1);return o.assertArgument(e,"no matching event","key",t),e.name}hasEvent(t){return!!this.#i(t,null,!1)}getEvent(t,e){return this.#i(t,e||null,!0)}forEachEvent(t){const e=Array.from(this.#e.keys());e.sort((n,r)=>n.localeCompare(r));for(let n=0;n<e.length;n++){const r=e[n];t(this.#e.get(r),n)}}getError(t,e){if(o.isHexString(t)){const r=t.toLowerCase();if(qt[r])return T.from(qt[r].signature);for(const i of this.#t.values())if(r===i.selector)return i;return null}if(t.indexOf("(")===-1){const r=[];for(const[i,a]of this.#t)i.split("(")[0]===t&&r.push(a);if(r.length===0)return t==="Error"?T.from("error Error(string)"):t==="Panic"?T.from("error Panic(uint256)"):null;if(r.length>1){const i=r.map(a=>JSON.stringify(a.format())).join(", ");o.assertArgument(!1,`ambiguous error description (i.e. ${i})`,"name",t)}return r[0]}if(t=T.from(t).format(),t==="Error(string)")return T.from("error Error(string)");if(t==="Panic(uint256)")return T.from("error Panic(uint256)");const n=this.#t.get(t);return n||null}forEachError(t){const e=Array.from(this.#t.keys());e.sort((n,r)=>n.localeCompare(r));for(let n=0;n<e.length;n++){const r=e[n];t(this.#t.get(r),n)}}_decodeParams(t,e){return this.#r.decode(t,e)}_encodeParams(t,e){return this.#r.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if(typeof t=="string"){const n=this.getError(t);o.assertArgument(n,"unknown error","fragment",t),t=n}return o.assertArgument(o.dataSlice(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,o.dataSlice(e,4))}encodeErrorResult(t,e){if(typeof t=="string"){const n=this.getError(t);o.assertArgument(n,"unknown error","fragment",t),t=n}return o.concat([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if(typeof t=="string"){const n=this.getFunction(t);o.assertArgument(n,"unknown function","fragment",t),t=n}return o.assertArgument(o.dataSlice(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,o.dataSlice(e,4))}encodeFunctionData(t,e){if(typeof t=="string"){const n=this.getFunction(t);o.assertArgument(n,"unknown function","fragment",t),t=n}return o.concat([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if(typeof t=="string"){const i=this.getFunction(t);o.assertArgument(i,"unknown function","fragment",t),t=i}let n="invalid length for result data";const r=o.getBytesCopy(e);if(r.length%32===0)try{return this.#r.decode(t.outputs,r)}catch{n="could not decode result data"}o.assert(!1,n,"BAD_DATA",{value:o.hexlify(r),info:{method:t.name,signature:t.format()}})}makeError(t,e){const n=o.getBytes(t,"data"),r=st.getBuiltinCallException("call",e,n);if(r.message.startsWith("execution reverted (unknown custom error)")){const c=o.hexlify(n.slice(0,4)),u=this.getError(c);if(u)try{const l=this.#r.decode(u.inputs,n.slice(4));r.revert={name:u.name,signature:u.format(),args:l},r.reason=r.revert.signature,r.message=`execution reverted: ${r.reason}`}catch{r.message="execution reverted (coult not decode custom error)"}}const a=this.parseTransaction(e);return a&&(r.invocation={method:a.name,signature:a.signature,args:a.args}),r}encodeFunctionResult(t,e){if(typeof t=="string"){const n=this.getFunction(t);o.assertArgument(n,"unknown function","fragment",t),t=n}return o.hexlify(this.#r.encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if(typeof t=="string"){const i=this.getEvent(t);o.assertArgument(i,"unknown event","eventFragment",t),t=i}o.assert(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const n=[];t.anonymous||n.push(t.topicHash);const r=(i,a)=>i.type==="string"?rt(a):i.type==="bytes"?o.keccak256(o.hexlify(a)):(i.type==="bool"&&typeof a=="boolean"?a=a?"0x01":"0x00":i.type.match(/^u?int/)?a=Rt(a):i.type.match(/^bytes/)?a=o.zeroPadBytes(a,32):i.type==="address"&&this.#r.encode(["address"],[a]),o.zeroPadValue(o.hexlify(a),32));for(e.forEach((i,a)=>{const c=t.inputs[a];if(!c.indexed){o.assertArgument(i==null,"cannot filter non-indexed parameters; must be null","contract."+c.name,i);return}i==null?n.push(null):c.baseType==="array"||c.baseType==="tuple"?o.assertArgument(!1,"filtering with tuples or arrays not supported","contract."+c.name,i):Array.isArray(i)?n.push(i.map(u=>r(c,u))):n.push(r(c,i))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(t,e){if(typeof t=="string"){const a=this.getEvent(t);o.assertArgument(a,"unknown event","eventFragment",t),t=a}const n=[],r=[],i=[];return t.anonymous||n.push(t.topicHash),o.assertArgument(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach((a,c)=>{const u=e[c];if(a.indexed)if(a.type==="string")n.push(rt(u));else if(a.type==="bytes")n.push(o.keccak256(u));else{if(a.baseType==="tuple"||a.baseType==="array")throw new Error("not implemented");n.push(this.#r.encode([a.type],[u]))}else r.push(a),i.push(u)}),{data:this.#r.encode(r,i),topics:n}}decodeEventLog(t,e,n){if(typeof t=="string"){const g=this.getEvent(t);o.assertArgument(g,"unknown event","eventFragment",t),t=g}if(n!=null&&!t.anonymous){const g=t.topicHash;o.assertArgument(o.isHexString(n[0],32)&&n[0].toLowerCase()===g,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const r=[],i=[],a=[];t.inputs.forEach((g,y)=>{g.indexed?g.type==="string"||g.type==="bytes"||g.baseType==="tuple"||g.baseType==="array"?(r.push(E.from({type:"bytes32",name:g.name})),a.push(!0)):(r.push(g),a.push(!1)):(i.push(g),a.push(!1))});const c=n!=null?this.#r.decode(r,o.concat(n)):null,u=this.#r.decode(i,e,!0),l=[],f=[];let h=0,d=0;return t.inputs.forEach((g,y)=>{let b=null;if(g.indexed)if(c==null)b=new Zt(null);else if(a[y])b=new Zt(c[d++]);else try{b=c[d++]}catch(P){b=P}else try{b=u[h++]}catch(P){b=P}l.push(b),f.push(g.name||null)}),G.fromItems(l,f)}parseTransaction(t){const e=o.getBytes(t.data,"tx.data"),n=H(t.value!=null?t.value:0,"tx.value"),r=this.getFunction(o.hexlify(e.slice(0,4)));if(!r)return null;const i=this.#r.decode(r.inputs,e.slice(4));return new yn(r,r.selector,i,n)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new mn(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=o.hexlify(t),n=this.getError(o.dataSlice(e,0,4));if(!n)return null;const r=this.#r.decode(n.inputs,o.dataSlice(e,4));return new wn(n,n.selector,r)}static from(t){return t instanceof J?t:typeof t=="string"?new J(JSON.parse(t)):typeof t.formatJson=="function"?new J(t.formatJson()):typeof t.format=="function"?new J(t.format("json")):new J(t)}}const be=BigInt(0);function et(s){return s??null}function N(s){return s==null?null:s.toString()}class bn{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(t,e,n){o.defineProperties(this,{gasPrice:et(t),maxFeePerGas:et(e),maxPriorityFeePerGas:et(n)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:N(t),maxFeePerGas:N(e),maxPriorityFeePerGas:N(n)}}}function Ee(s){const t={};s.to&&(t.to=s.to),s.from&&(t.from=s.from),s.data&&(t.data=o.hexlify(s.data));const e="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const r of e)!(r in s)||s[r]==null||(t[r]=H(s[r],`request.${r}`));const n="type,nonce".split(/,/);for(const r of n)!(r in s)||s[r]==null||(t[r]=L(s[r],`request.${r}`));return s.accessList&&(t.accessList=le(s.accessList)),"blockTag"in s&&(t.blockTag=s.blockTag),"enableCcipRead"in s&&(t.enableCcipRead=!!s.enableCcipRead),"customData"in s&&(t.customData=s.customData),"blobVersionedHashes"in s&&s.blobVersionedHashes&&(t.blobVersionedHashes=s.blobVersionedHashes.slice()),"kzg"in s&&(t.kzg=s.kzg),"blobs"in s&&s.blobs&&(t.blobs=s.blobs.map(r=>o.isBytesLike(r)?o.hexlify(r):Object.assign({},r))),t}class En{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#t;constructor(t,e){this.#t=t.transactions.map(n=>typeof n!="string"?new lt(n,e):n),o.defineProperties(this,{provider:e,hash:et(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:et(t.prevRandao),extraData:t.extraData,baseFeePerGas:et(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return this.#t.map(t=>typeof t=="string"?t:t.hash)}get prefetchedTransactions(){const t=this.#t.slice();return t.length===0?[]:(o.assert(typeof t[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:n,gasLimit:r,gasUsed:i,hash:a,miner:c,prevRandao:u,nonce:l,number:f,parentHash:h,parentBeaconBlockRoot:d,stateRoot:g,receiptsRoot:y,timestamp:b,transactions:P}=this;return{_type:"Block",baseFeePerGas:N(t),difficulty:N(e),extraData:n,gasLimit:N(r),gasUsed:N(i),blobGasUsed:N(this.blobGasUsed),excessBlobGas:N(this.excessBlobGas),hash:a,miner:c,prevRandao:u,nonce:l,number:f,parentHash:h,timestamp:b,parentBeaconBlockRoot:d,stateRoot:g,receiptsRoot:y,transactions:P}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return this.#t.length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(t){let e;if(typeof t=="number")e=this.#t[t];else{const n=t.toLowerCase();for(const r of this.#t)if(typeof r=="string"){if(r!==n)continue;e=r;break}else{if(r.hash!==n)continue;e=r;break}}if(e==null)throw new Error("no such tx");return typeof e=="string"?await this.provider.getTransaction(e):e}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if(typeof t=="number")return e[t];t=t.toLowerCase();for(const n of e)if(n.hash===t)return n;o.assertArgument(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return xn(this)}}class ut{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor(t,e){this.provider=e;const n=Object.freeze(t.topics.slice());o.defineProperties(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:n,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:n,data:r,index:i,removed:a,topics:c,transactionHash:u,transactionIndex:l}=this;return{_type:"log",address:t,blockHash:e,blockNumber:n,data:r,index:i,removed:a,topics:c,transactionHash:u,transactionIndex:l}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return o.assert(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return o.assert(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return o.assert(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return Pn(this)}}class xe{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#t;constructor(t,e){this.#t=Object.freeze(t.logs.map(r=>new ut(r,e)));let n=be;t.effectiveGasPrice!=null?n=t.effectiveGasPrice:t.gasPrice!=null&&(n=t.gasPrice),o.defineProperties(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:n,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return this.#t}toJSON(){const{to:t,from:e,contractAddress:n,hash:r,index:i,blockHash:a,blockNumber:c,logsBloom:u,logs:l,status:f,root:h}=this;return{_type:"TransactionReceipt",blockHash:a,blockNumber:c,contractAddress:n,cumulativeGasUsed:N(this.cumulativeGasUsed),from:e,gasPrice:N(this.gasPrice),blobGasUsed:N(this.blobGasUsed),blobGasPrice:N(this.blobGasPrice),gasUsed:N(this.gasUsed),hash:r,index:i,logs:l,logsBloom:u,root:h,status:f,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(t==null)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(t==null)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return Ae(this)}reorderedEvent(t){return o.assert(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Pe(this,t)}}class lt{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;#t;constructor(t,e){this.provider=e,this.blockNumber=t.blockNumber!=null?t.blockNumber:null,this.blockHash=t.blockHash!=null?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=t.maxPriorityFeePerGas!=null?t.maxPriorityFeePerGas:null,this.maxFeePerGas=t.maxFeePerGas!=null?t.maxFeePerGas:null,this.maxFeePerBlobGas=t.maxFeePerBlobGas!=null?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=t.accessList!=null?t.accessList:null,this.blobVersionedHashes=t.blobVersionedHashes!=null?t.blobVersionedHashes:null,this.#t=-1}toJSON(){const{blockNumber:t,blockHash:e,index:n,hash:r,type:i,to:a,from:c,nonce:u,data:l,signature:f,accessList:h,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:h,blockNumber:t,blockHash:e,blobVersionedHashes:d,chainId:N(this.chainId),data:l,from:c,gasLimit:N(this.gasLimit),gasPrice:N(this.gasPrice),hash:r,maxFeePerGas:N(this.maxFeePerGas),maxPriorityFeePerGas:N(this.maxPriorityFeePerGas),maxFeePerBlobGas:N(this.maxFeePerBlobGas),nonce:u,signature:f,to:a,index:n,type:i,value:N(this.value)}}async getBlock(){let t=this.blockNumber;if(t==null){const n=await this.getTransaction();n&&(t=n.blockNumber)}if(t==null)return null;const e=this.provider.getBlock(t);if(e==null)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:e,blockNumber:n}=await o.resolveProperties({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:n-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const n=t??1,r=e??0;let i=this.#t,a=-1,c=i===-1;const u=async()=>{if(c)return null;const{blockNumber:d,nonce:g}=await o.resolveProperties({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(g<this.nonce){i=d;return}if(c)return null;const y=await this.getTransaction();if(!(y&&y.blockNumber!=null))for(a===-1&&(a=i-3,a<this.#t&&(a=this.#t));a<=d;){if(c)return null;const b=await this.provider.getBlock(a,!0);if(b==null)return;for(const P of b)if(P===this.hash)return;for(let P=0;P<b.length;P++){const w=await b.getTransaction(P);if(w.from===this.from&&w.nonce===this.nonce){if(c)return null;const k=await this.provider.getTransactionReceipt(w.hash);if(k==null||d-k.blockNumber+1<n)return;let W="replaced";w.data===this.data&&w.to===this.to&&w.value===this.value?W="repriced":w.data==="0x"&&w.from===w.to&&w.value===be&&(W="cancelled"),o.assert(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:W==="replaced"||W==="cancelled",reason:W,replacement:w.replaceableTransaction(i),hash:w.hash,receipt:k})}}a++}},l=d=>{if(d==null||d.status!==0)return d;o.assert(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},f=await this.provider.getTransactionReceipt(this.hash);if(n===0)return l(f);if(f){if(await f.confirmations()>=n)return l(f)}else if(await u(),n===0)return null;return await new Promise((d,g)=>{const y=[],b=()=>{y.forEach(w=>w())};if(y.push(()=>{c=!0}),r>0){const w=setTimeout(()=>{b(),g(o.makeError("wait for transaction timeout","TIMEOUT"))},r);y.push(()=>{clearTimeout(w)})}const P=async w=>{if(await w.confirmations()>=n){b();try{d(l(w))}catch(k){g(k)}}};if(y.push(()=>{this.provider.off(this.hash,P)}),this.provider.on(this.hash,P),i>=0){const w=async()=>{try{await u()}catch(k){if(o.isError(k,"TRANSACTION_REPLACED")){b(),g(k);return}}c||this.provider.once("block",w)};y.push(()=>{this.provider.off("block",w)}),this.provider.once("block",w)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return o.assert(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Ae(this)}reorderedEvent(t){return o.assert(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),o.assert(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Pe(this,t)}replaceableTransaction(t){o.assertArgument(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new lt(this,this.provider);return e.#t=t,e}}function xn(s){return{orphan:"drop-block",hash:s.hash,number:s.number}}function Pe(s,t){return{orphan:"reorder-transaction",tx:s,other:t}}function Ae(s){return{orphan:"drop-transaction",tx:s}}function Pn(s){return{orphan:"drop-log",log:{transactionHash:s.transactionHash,blockHash:s.blockHash,blockNumber:s.blockNumber,address:s.address,data:s.data,topics:Object.freeze(s.topics.slice()),index:s.index}}}class Bt extends ut{interface;fragment;args;constructor(t,e,n){super(t,t.provider);const r=e.decodeEventLog(n,t.data,t.topics);o.defineProperties(this,{args:r,fragment:n,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Ne extends ut{error;constructor(t,e){super(t,t.provider),o.defineProperties(this,{error:e})}}class An extends xe{#t;constructor(t,e,n){super(n,e),this.#t=t}get logs(){return super.logs.map(t=>{const e=t.topics.length?this.#t.getEvent(t.topics[0]):null;if(e)try{return new Bt(t,this.#t,e)}catch(n){return new Ne(t,n)}return t})}}class St extends lt{#t;constructor(t,e,n){super(n,e),this.#t=t}async wait(t,e){const n=await super.wait(t,e);return n==null?null:new An(this.#t,this.provider,n)}}class ve extends re{log;constructor(t,e,n,r){super(t,e,n),o.defineProperties(this,{log:r})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class Nn extends ve{constructor(t,e,n,r,i){super(t,e,n,new Bt(i,t.interface,r));const a=t.interface.decodeEventLog(r,this.log.data,this.log.topics);o.defineProperties(this,{args:a,fragment:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const jt=BigInt(0);function Oe(s){return s&&typeof s.call=="function"}function Te(s){return s&&typeof s.estimateGas=="function"}function bt(s){return s&&typeof s.resolveName=="function"}function Re(s){return s&&typeof s.sendTransaction=="function"}function ke(s){if(s!=null){if(bt(s))return s;if(s.provider)return s.provider}}class vn{#t;fragment;constructor(t,e,n){if(o.defineProperties(this,{fragment:e}),e.inputs.length<n.length)throw new Error("too many arguments");const r=j(t.runner,"resolveName"),i=bt(r)?r:null;this.#t=(async function(){const a=await Promise.all(e.inputs.map((c,u)=>n[u]==null?null:c.walkAsync(n[u],(f,h)=>f==="address"?Array.isArray(h)?Promise.all(h.map(d=>o.resolveAddress(d,i))):o.resolveAddress(h,i):h)));return t.interface.encodeFilterTopics(e,a)})()}getTopicFilter(){return this.#t}}function j(s,t){return s==null?null:typeof s[t]=="function"?s:s.provider&&typeof s.provider[t]=="function"?s.provider:null}function X(s){return s==null?null:s.provider||null}async function Ct(s,t){const e=A.dereference(s,"overrides");o.assertArgument(typeof e=="object","invalid overrides parameter","overrides",s);const n=Ee(e);return o.assertArgument(n.to==null||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),o.assertArgument(n.data==null||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function Ue(s,t,e){const n=j(s,"resolveName"),r=bt(n)?n:null;return await Promise.all(t.map((i,a)=>i.walkAsync(e[a],(c,u)=>(u=A.dereference(u,c),c==="address"?o.resolveAddress(u,r):u))))}function On(s){const t=async function(a){const c=await Ct(a,["data"]);c.to=await s.getAddress(),c.from&&(c.from=await o.resolveAddress(c.from,ke(s.runner)));const u=s.interface,l=H(c.value||jt,"overrides.value")===jt,f=(c.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!f&&!l&&o.assertArgument(!1,"cannot send data to receive or send value to non-payable fallback","overrides",a),o.assertArgument(u.fallback||f,"cannot send data to receive-only contract","overrides.data",c.data);const h=u.receive||u.fallback&&u.fallback.payable;return o.assertArgument(h||l,"cannot send value to non-payable fallback","overrides.value",c.value),o.assertArgument(u.fallback||f,"cannot send data to receive-only contract","overrides.data",c.data),c},e=async function(a){const c=j(s.runner,"call");o.assert(Oe(c),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await t(a);try{return await c.call(u)}catch(l){throw o.isCallException(l)&&l.data?s.interface.makeError(l.data,u):l}},n=async function(a){const c=s.runner;o.assert(Re(c),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await c.sendTransaction(await t(a)),l=X(s.runner);return new St(s.interface,l,u)},r=async function(a){const c=j(s.runner,"estimateGas");return o.assert(Te(c),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await c.estimateGas(await t(a))},i=async a=>await n(a);return o.defineProperties(i,{_contract:s,estimateGas:r,populateTransaction:t,send:n,staticCall:e}),i}function Tn(s,t){const e=function(...l){const f=s.interface.getFunction(t,l);return o.assert(f,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:l}}),f},n=async function(...l){const f=e(...l);let h={};if(f.inputs.length+1===l.length&&(h=await Ct(l.pop()),h.from&&(h.from=await o.resolveAddress(h.from,ke(s.runner)))),f.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await Ue(s.runner,f.inputs,l);return Object.assign({},h,await o.resolveProperties({to:s.getAddress(),data:s.interface.encodeFunctionData(f,d)}))},r=async function(...l){const f=await c(...l);return f.length===1?f[0]:f},i=async function(...l){const f=s.runner;o.assert(Re(f),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const h=await f.sendTransaction(await n(...l)),d=X(s.runner);return new St(s.interface,d,h)},a=async function(...l){const f=j(s.runner,"estimateGas");return o.assert(Te(f),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await f.estimateGas(await n(...l))},c=async function(...l){const f=j(s.runner,"call");o.assert(Oe(f),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const h=await n(...l);let d="0x";try{d=await f.call(h)}catch(y){throw o.isCallException(y)&&y.data?s.interface.makeError(y.data,h):y}const g=e(...l);return s.interface.decodeFunctionResult(g,d)},u=async(...l)=>e(...l).constant?await r(...l):await i(...l);return o.defineProperties(u,{name:s.interface.getFunctionName(t),_contract:s,_key:t,getFragment:e,estimateGas:a,populateTransaction:n,send:i,staticCall:r,staticCallResult:c}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const l=s.interface.getFunction(t);return o.assert(l,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),l}}),u}function Rn(s,t){const e=function(...r){const i=s.interface.getEvent(t,r);return o.assert(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:r}}),i},n=function(...r){return new vn(s,e(...r),r)};return o.defineProperties(n,{name:s.interface.getEventName(t),_contract:s,_key:t,getFragment:e}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=s.interface.getEvent(t);return o.assert(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),r}}),n}const pt=Symbol.for("_ethersInternal_contract"),Ie=new WeakMap;function kn(s,t){Ie.set(s[pt],t)}function U(s){return Ie.get(s[pt])}function Un(s){return s&&typeof s=="object"&&"getTopicFilter"in s&&typeof s.getTopicFilter=="function"&&s.fragment}async function Ft(s,t){let e,n=null;if(Array.isArray(t)){const i=function(a){if(o.isHexString(a,32))return a;const c=s.interface.getEvent(a);return o.assertArgument(c,"unknown fragment","name",a),c.topicHash};e=t.map(a=>a==null?null:Array.isArray(a)?a.map(i):i(a))}else t==="*"?e=[null]:typeof t=="string"?o.isHexString(t,32)?e=[t]:(n=s.interface.getEvent(t),o.assertArgument(n,"unknown fragment","event",t),e=[n.topicHash]):Un(t)?e=await t.getTopicFilter():"fragment"in t?(n=t.fragment,e=[n.topicHash]):o.assertArgument(!1,"unknown event name","event",t);e=e.map(i=>{if(i==null)return null;if(Array.isArray(i)){const a=Array.from(new Set(i.map(c=>c.toLowerCase())).values());return a.length===1?a[0]:(a.sort(),a)}return i.toLowerCase()});const r=e.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:n,tag:r,topics:e}}async function ot(s,t){const{subs:e}=U(s);return e.get((await Ft(s,t)).tag)||null}async function te(s,t,e){const n=X(s.runner);o.assert(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:r,tag:i,topics:a}=await Ft(s,e),{addr:c,subs:u}=U(s);let l=u.get(i);if(!l){const h={address:c||s,topics:a},d=P=>{let w=r;if(w==null)try{w=s.interface.getEvent(P.topics[0])}catch{}if(w){const k=w,W=r?s.interface.decodeEventLog(r,P.data,P.topics):[];Ot(s,e,W,Be=>new Nn(s,Be,e,k,P))}else Ot(s,e,[],k=>new ve(s,k,e,P))};let g=[];l={tag:i,listeners:[],start:()=>{g.length||g.push(n.on(h,d))},stop:async()=>{if(g.length==0)return;let P=g;g=[],await Promise.all(P),n.off(h,d)}},u.set(i,l)}return l}let vt=Promise.resolve();async function In(s,t,e,n){await vt;const r=await ot(s,t);if(!r)return!1;const i=r.listeners.length;return r.listeners=r.listeners.filter(({listener:a,once:c})=>{const u=Array.from(e);n&&u.push(n(c?null:a));try{a.call(s,...u)}catch{}return!c}),r.listeners.length===0&&(r.stop(),U(s).subs.delete(r.tag)),i>0}async function Ot(s,t,e,n){try{await vt}catch{}const r=In(s,t,e,n);return vt=r,await r}const dt=["then"];class nt{target;interface;runner;filters;[pt];fallback;constructor(t,e,n,r){o.assertArgument(typeof t=="string"||o.isAddressable(t),"invalid value for Contract target","target",t),n==null&&(n=null);const i=J.from(e);o.defineProperties(this,{target:t,runner:n,interface:i}),Object.defineProperty(this,pt,{value:{}});let a,c=null,u=null;if(r){const h=X(n);u=new St(this.interface,h,r)}let l=new Map;if(typeof t=="string")if(o.isHexString(t))c=t,a=Promise.resolve(t);else{const h=j(n,"resolveName");if(!bt(h))throw o.makeError("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});a=h.resolveName(t).then(d=>{if(d==null)throw o.makeError("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return U(this).addr=d,d})}else a=t.getAddress().then(h=>{if(h==null)throw new Error("TODO");return U(this).addr=h,h});kn(this,{addrPromise:a,addr:c,deployTx:u,subs:l});const f=new Proxy({},{get:(h,d,g)=>{if(typeof d=="symbol"||dt.indexOf(d)>=0)return Reflect.get(h,d,g);try{return this.getEvent(d)}catch(y){if(!o.isError(y,"INVALID_ARGUMENT")||y.argument!=="key")throw y}},has:(h,d)=>dt.indexOf(d)>=0?Reflect.has(h,d):Reflect.has(h,d)||this.interface.hasEvent(String(d))});return o.defineProperties(this,{filters:f}),o.defineProperties(this,{fallback:i.receive||i.fallback?On(this):null}),new Proxy(this,{get:(h,d,g)=>{if(typeof d=="symbol"||d in h||dt.indexOf(d)>=0)return Reflect.get(h,d,g);try{return h.getFunction(d)}catch(y){if(!o.isError(y,"INVALID_ARGUMENT")||y.argument!=="key")throw y}},has:(h,d)=>typeof d=="symbol"||d in h||dt.indexOf(d)>=0?Reflect.has(h,d):h.interface.hasFunction(d)})}connect(t){return new nt(this.target,this.interface,t)}attach(t){return new nt(t,this.interface,this.runner)}async getAddress(){return await U(this).addrPromise}async getDeployedCode(){const t=X(this.runner);o.assert(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return e==="0x"?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=X(this.runner);return o.assert(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((r,i)=>{const a=async()=>{try{if(await this.getDeployedCode()!=null)return r(this);n.once("block",a)}catch(c){i(c)}};a()})}deploymentTransaction(){return U(this).deployTx}getFunction(t){return typeof t!="string"&&(t=t.format()),Tn(this,t)}getEvent(t){return typeof t!="string"&&(t=t.format()),Rn(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,n){e==null&&(e=0),n==null&&(n="latest");const{addr:r,addrPromise:i}=U(this),a=r||await i,{fragment:c,topics:u}=await Ft(this,t),l={address:a,topics:u,fromBlock:e,toBlock:n},f=X(this.runner);return o.assert(f,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await f.getLogs(l)).map(h=>{let d=c;if(d==null)try{d=this.interface.getEvent(h.topics[0])}catch{}if(d)try{return new Bt(h,this.interface,d)}catch(g){return new Ne(h,g)}return new ut(h,f)})}async on(t,e){const n=await te(this,"on",t);return n.listeners.push({listener:e,once:!1}),n.start(),this}async once(t,e){const n=await te(this,"once",t);return n.listeners.push({listener:e,once:!0}),n.start(),this}async emit(t,...e){return await Ot(this,t,e,null)}async listenerCount(t){if(t){const r=await ot(this,t);return r?r.listeners.length:0}const{subs:e}=U(this);let n=0;for(const{listeners:r}of e.values())n+=r.length;return n}async listeners(t){if(t){const r=await ot(this,t);return r?r.listeners.map(({listener:i})=>i):[]}const{subs:e}=U(this);let n=[];for(const{listeners:r}of e.values())n=n.concat(r.map(({listener:i})=>i));return n}async off(t,e){const n=await ot(this,t);if(!n)return this;if(e){const r=n.listeners.map(({listener:i})=>i).indexOf(e);r>=0&&n.listeners.splice(r,1)}return(e==null||n.listeners.length===0)&&(n.stop(),U(this).subs.delete(n.tag)),this}async removeAllListeners(t){if(t){const e=await ot(this,t);if(!e)return this;e.stop(),U(this).subs.delete(e.tag)}else{const{subs:e}=U(this);for(const{tag:n,stop:r}of e.values())r(),e.delete(n)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){class e extends nt{constructor(r,i=null){super(r,t,i)}}return e}static from(t,e,n){return n==null&&(n=null),new this(t,e,n)}}function Bn(){return nt}class Sn extends Bn(){}exports.AbiCoder=st;exports.BaseContract=nt;exports.Block=En;exports.Contract=Sn;exports.EventPayload=re;exports.FeeData=bn;exports.Interface=J;exports.Log=ut;exports.TransactionReceipt=xe;exports.TransactionResponse=lt;exports.accessListify=le;exports.copyOverrides=Ct;exports.copyRequest=Ee;exports.fromTwos=ee;exports.getBigInt=H;exports.getNumber=L;exports.id=rt;exports.mask=at;exports.resolveArgs=Ue;exports.toBeArray=kt;exports.toBeHex=Rt;exports.toBigInt=Tt;exports.toQuantity=Ce;exports.toTwos=ne;exports.toUtf8Bytes=Ut;exports.toUtf8String=ie;
@@ -1,4 +1,4 @@
1
- import { by as f, bC as y, bJ as R, bW as fe, bB as m, bD as Nt, bS as He, bP as ot, bT as G, bA as Vt, h as ht, ch as he, cf as dt, U as Ct, ao as Y, c2 as Ot, bV as it, ci as ze, O as Je, bQ as Ft, cj as Ke, cg as de, bR as pt } from "./web3-BkEb7AgB.mjs";
1
+ import { by as f, bC as y, bJ as R, bW as fe, bB as m, bD as Nt, bS as He, bP as ot, bT as G, bA as Vt, h as ht, ch as he, cf as dt, U as Ct, ao as Y, c2 as Ot, bV as it, ci as ze, O as Je, bQ as Ft, cj as Ke, cg as de, bR as pt } from "./web3-BifDBsFp.mjs";
2
2
  const vt = BigInt(0), F = BigInt(1), at = 9007199254740991;
3
3
  function We(s, t) {
4
4
  const e = Tt(s, "value"), n = BigInt(K(t, "width"));