@wormhole-foundation/wormhole-connect 3.0.2-beta.0-development → 3.0.2-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 (290) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{basic-ChNCp6rI.js → basic-PUjrTVXb.js} +1 -1
  3. package/dist/assets/{evm-DSirgd5b.js → evm-CO5UWnAY.js} +2 -2
  4. package/dist/assets/{index-L-lC4rqb.js → index-1lzfHdT2.js} +1 -1
  5. package/dist/assets/{index-CHfaLf5J.js → index-DBVZDYF7.js} +1 -1
  6. package/dist/assets/index-DKlPX3ZI.js +1 -0
  7. package/dist/assets/{index-BtCrMDAu.js → index-Ddk7n7Ti.js} +1 -1
  8. package/dist/assets/{index-HhyysXFu.js → index-DyUmO4PR.js} +1 -1
  9. package/dist/assets/{index-BiwA3Bbq.js → index-MMzKxP1N.js} +1 -1
  10. package/dist/assets/{secp256k1-Cd7rIav0.js → secp256k1-0LtSM2L1.js} +1 -1
  11. package/dist/assets/{secp256k1-BQBOR8e3.js → secp256k1-DwTU3j1N.js} +1 -1
  12. package/dist/assets/{solana-DcwLWeKT.js → solana-DlGdMBSL.js} +4 -4
  13. package/dist/assets/{w3m-modal-DdptuLHe.js → w3m-modal-DD9Jgepz.js} +1 -1
  14. package/dist/main.js +72 -70
  15. package/dist/src/AppRouter.d.ts.map +1 -1
  16. package/dist/src/config/mainnet/tokens.d.ts.map +1 -1
  17. package/dist/src/config/testnet/tokens.d.ts.map +1 -1
  18. package/dist/src/config/tokens.d.ts +1 -1
  19. package/dist/src/config/tokens.d.ts.map +1 -1
  20. package/dist/src/exports/index.d.ts +2 -2
  21. package/dist/src/exports/index.d.ts.map +1 -1
  22. package/dist/src/hooks/useFetchQuotes.d.ts.map +1 -1
  23. package/dist/src/icons/Chains/PLUME.d.ts.map +1 -1
  24. package/dist/src/icons/PoweredBy.d.ts.map +1 -1
  25. package/dist/src/icons/Routing.d.ts +5 -0
  26. package/dist/src/icons/Routing.d.ts.map +1 -0
  27. package/dist/src/icons/Tokens/PLUME.d.ts.map +1 -1
  28. package/dist/src/store/transferInput.d.ts +1 -1
  29. package/dist/src/store/transferInput.d.ts.map +1 -1
  30. package/dist/src/utils/coingecko.d.ts.map +1 -1
  31. package/dist/src/utils/formatNumber.d.ts +23 -0
  32. package/dist/src/utils/formatNumber.d.ts.map +1 -0
  33. package/dist/src/utils/index.d.ts +3 -1
  34. package/dist/src/utils/index.d.ts.map +1 -1
  35. package/dist/src/utils/routes.d.ts +12 -0
  36. package/dist/src/utils/routes.d.ts.map +1 -0
  37. package/dist/src/views/v2/Bridge/AmountInput/index.d.ts.map +1 -1
  38. package/dist/src/views/v2/Bridge/AssetPicker/TokenItem.d.ts.map +1 -1
  39. package/dist/src/views/v2/Bridge/Routes/SingleRoute.d.ts.map +1 -1
  40. package/dist/src/views/v2/Redeem/TransactionDetails/index.d.ts.map +1 -1
  41. package/dist/src/views/v3/Bridge/AmountInput/index.d.ts.map +1 -1
  42. package/dist/src/views/v3/Bridge/AssetPicker/TokenItem.d.ts.map +1 -1
  43. package/dist/src/views/v3/Bridge/AssetPicker/index.d.ts.map +1 -1
  44. package/dist/src/views/v3/Bridge/GasSlider/index.d.ts.map +1 -1
  45. package/dist/src/views/v3/Bridge/Routes/Eta.d.ts +6 -0
  46. package/dist/src/views/v3/Bridge/Routes/Eta.d.ts.map +1 -0
  47. package/dist/src/views/v3/Bridge/Routes/RouteBadge.d.ts.map +1 -1
  48. package/dist/src/views/v3/Bridge/Routes/RoutesBottomSheet.d.ts +7 -6
  49. package/dist/src/views/v3/Bridge/Routes/RoutesBottomSheet.d.ts.map +1 -1
  50. package/dist/src/views/v3/Bridge/Routes/RoutesLink.d.ts +7 -0
  51. package/dist/src/views/v3/Bridge/Routes/RoutesLink.d.ts.map +1 -0
  52. package/dist/src/views/v3/Bridge/Routes/RoutesList.d.ts +2 -1
  53. package/dist/src/views/v3/Bridge/Routes/RoutesList.d.ts.map +1 -1
  54. package/dist/src/views/v3/Bridge/Routes/RoutesLoader.d.ts +4 -0
  55. package/dist/src/views/v3/Bridge/Routes/RoutesLoader.d.ts.map +1 -0
  56. package/dist/src/views/v3/Bridge/Routes/RoutesModal.d.ts +6 -5
  57. package/dist/src/views/v3/Bridge/Routes/RoutesModal.d.ts.map +1 -1
  58. package/dist/src/views/v3/Bridge/Routes/SingleRoute.d.ts +1 -0
  59. package/dist/src/views/v3/Bridge/Routes/SingleRoute.d.ts.map +1 -1
  60. package/dist/src/views/v3/Bridge/Routes/index.d.ts.map +1 -1
  61. package/dist/src/views/v3/Redeem/TransactionDetails/index.d.ts.map +1 -1
  62. package/lib/account-Br8E7RB6.js +1 -0
  63. package/lib/{account-BTK2b2Fv.mjs → account-CVa_3S2g.mjs} +1 -1
  64. package/lib/{address-8wLqn60W.mjs → address-BApwdEpr.mjs} +96 -96
  65. package/lib/address-BwQqFkyh.js +1 -0
  66. package/lib/address-C2pxq9b2.js +1 -0
  67. package/lib/{address-n0gAFMrZ.mjs → address-f6joE_ig.mjs} +12 -12
  68. package/lib/aptos-CMRGggVs.js +2 -0
  69. package/lib/{aptos-CK-j196x.js → aptos-CTKQNmlP.js} +1 -1
  70. package/lib/{aptos-B-DJQlwt.mjs → aptos-CfFbx7uf.mjs} +9 -9
  71. package/lib/{aptos-Bwcz9wZX.mjs → aptos-fozuppXh.mjs} +3 -3
  72. package/lib/{basic-DHWVLmCq.mjs → basic-BA2aRJJn.mjs} +2 -2
  73. package/lib/{basic-B5ZFelC_.js → basic-DUWaF2I0.js} +1 -1
  74. package/lib/{basic-E2M-9h1u.js → basic-DeiUayOA.js} +1 -1
  75. package/lib/{basic-Pour9Ggp.mjs → basic-DoC8u7J8.mjs} +2 -2
  76. package/lib/{blake2b-C5HyObld.mjs → blake2b-BGxWUAjG.mjs} +23 -23
  77. package/lib/blake2b-Fj1aPKgL.js +1 -0
  78. package/lib/{browser-ponyfill-jK8MKVVg.mjs → browser-ponyfill-D5AN8ZPp.mjs} +1 -1
  79. package/lib/browser-ponyfill-Dn6gsMYK.js +2 -0
  80. package/lib/{chain-Bm6u6eUF.mjs → chain-DAw2I5H8.mjs} +1 -1
  81. package/lib/chain-DnPXlO8g.js +1 -0
  82. package/lib/chunk-KJH4KKG6-BjF7YUcU.js +470 -0
  83. package/lib/{chunk-KJH4KKG6-DJsu-Y-X.mjs → chunk-KJH4KKG6-DmVjhXO7.mjs} +144 -144
  84. package/lib/{constants-Cf2YMjNo.js → constants-BtNs_2F4.js} +1 -1
  85. package/lib/{constants-B7AbX6qr.mjs → constants-Dcc2nVaW.mjs} +3 -3
  86. package/lib/contract-BEHYQLvJ.js +1 -0
  87. package/lib/{contract-llnN6ki0.mjs → contract-BkMAZomO.mjs} +123 -123
  88. package/lib/{core-CF5c7Vev.mjs → core-BHV42Qa0.mjs} +25 -26
  89. package/lib/core-CV23yxnG.js +889 -0
  90. package/lib/create-CHcGblj6.js +1 -0
  91. package/lib/{create-Dm87_0zG.mjs → create-CKLtL7hr.mjs} +1 -1
  92. package/lib/{evm-BYIGg8e4.mjs → evm-Bf7qbM19.mjs} +42 -42
  93. package/lib/{evm-B2hUWkt7.js → evm-ClWkquRx.js} +2 -2
  94. package/lib/{evm-fvvpk-li.mjs → evm-DhMoy8cH.mjs} +6 -6
  95. package/lib/{evm-DFNbMHoa.js → evm-tXmzU9Xp.js} +2 -2
  96. package/lib/executor.js +1 -1
  97. package/lib/executor.mjs +145 -138
  98. package/lib/hosted.js +1 -1
  99. package/lib/hosted.mjs +1 -1
  100. package/lib/{index-Cwo5AKUC.mjs → index-1rCCpdwd.mjs} +5 -5
  101. package/lib/{index-DBCa3k0j.mjs → index-3HvzWPL7.mjs} +9 -9
  102. package/lib/{index-MOwE6ses.mjs → index-B7ztYPhr.mjs} +21 -22
  103. package/lib/index-BM-0SeYB.js +1 -0
  104. package/lib/{index-DiQ8Ytrt.mjs → index-BTnpftLz.mjs} +1 -1
  105. package/lib/{index-BiCMaXJS.js → index-BWQMi6Rj.js} +1 -1
  106. package/lib/index-BbgKw2pu.js +1 -0
  107. package/lib/index-BblcpkoK.js +1 -0
  108. package/lib/index-Bfblsmud.js +1 -0
  109. package/lib/{index-C_0yAOSX.mjs → index-BfkFXEnG.mjs} +25082 -24072
  110. package/lib/{index-fi1sh8vr.mjs → index-BijBPDRn.mjs} +2 -2
  111. package/lib/index-BoquY9R2.js +337 -0
  112. package/lib/index-C2NtsO9Q.js +1 -0
  113. package/lib/{index-CNuk-XLX.mjs → index-C4JmrizV.mjs} +4 -4
  114. package/lib/index-C8TtXpOf.js +1 -0
  115. package/lib/index-CB8kOyIP.js +1 -0
  116. package/lib/index-CInVjUCW.js +1 -0
  117. package/lib/{index-BF11RebI.mjs → index-CLTklDbp.mjs} +1 -1
  118. package/lib/index-CQvgeH_r.js +1 -0
  119. package/lib/{index-DzYjoSJp.mjs → index-CUnOYRFQ.mjs} +23 -24
  120. package/lib/{index-DGh9LzN1.mjs → index-CWe_BTdo.mjs} +31 -31
  121. package/lib/{index-2Bz1Np4K.mjs → index-CZ91lJ9M.mjs} +5 -5
  122. package/lib/{index-Dgy1FO7C.js → index-CgyVnj6U.js} +1 -1
  123. package/lib/{index-BzJcFdt_.mjs → index-Clr2JjoJ.mjs} +44 -44
  124. package/lib/index-CnnCCv6Q.js +1 -0
  125. package/lib/{index-CJnRWlFf.mjs → index-CwxGLNEk.mjs} +48 -49
  126. package/lib/index-D7BLfz05.js +1 -0
  127. package/lib/index-DM7C-wvQ.js +3 -0
  128. package/lib/{index-DhIh3xiW.mjs → index-DNy_sNGr.mjs} +8 -8
  129. package/lib/{index-BZaRg0yd.mjs → index-DVcaDWmz.mjs} +1 -1
  130. package/lib/{index-CsAigASU.mjs → index-DWOP9OBp.mjs} +17 -17
  131. package/lib/{index-CTLz8Fz0.mjs → index-Dda5qc2t.mjs} +13 -14
  132. package/lib/{index-CLBXF_zH.mjs → index-DeaiBvpG.mjs} +16 -16
  133. package/lib/index-HOuGP-7b.js +1 -0
  134. package/lib/{index-Dt2uNp-N.mjs → index-KZve3tYJ.mjs} +4 -4
  135. package/lib/{index-CJDBidKv.mjs → index-SIyXqCAN.mjs} +41 -41
  136. package/lib/index-WhVYPMUr.js +1 -0
  137. package/lib/index-hmjT4xa7.js +1 -0
  138. package/lib/index-ledagFNU.js +1 -0
  139. package/lib/index-pbRVlgcN.js +1 -0
  140. package/lib/{index-BpQXUhR4.mjs → index-qK7AyMAk.mjs} +23 -27
  141. package/lib/index-ttZu99PZ.js +1 -0
  142. package/lib/{index.es-BqRBGIq6.mjs → index.es-BXRQf6Oi.mjs} +25 -26
  143. package/lib/index.es-BjGaOok5.js +11 -0
  144. package/lib/index.es-D6S74vhi.js +27 -0
  145. package/lib/{index.es-DgCZuUzB.mjs → index.es-cOw8juwf.mjs} +741 -737
  146. package/lib/index.js +1 -1
  147. package/lib/index.mjs +17 -16
  148. package/lib/mayan.js +3 -3
  149. package/lib/mayan.mjs +918 -891
  150. package/lib/mint-CL36R6ED.js +1 -0
  151. package/lib/{mint-Dc-VsiAn.mjs → mint-DunEG1jV.mjs} +32 -33
  152. package/lib/ntt.js +1 -1
  153. package/lib/ntt.mjs +2332 -2373
  154. package/lib/platform-7vCWzCny.js +1 -0
  155. package/lib/platform-BKhoO9So.js +1 -0
  156. package/lib/{platform-B95L0Vxv.mjs → platform-BN6LFtXE.mjs} +16 -16
  157. package/lib/{platform-DnP_1wGA.mjs → platform-BYLu9SzP.mjs} +4 -4
  158. package/lib/platform-Bbe26nx7.js +1 -0
  159. package/lib/{platform-DiG7WY9Z.mjs → platform-DCgWqmh1.mjs} +4 -4
  160. package/lib/{provider-jsonrpc-CRABh2gN.mjs → provider-jsonrpc-Bmgnrmpy.mjs} +155 -155
  161. package/lib/provider-jsonrpc-CbtP2Ffg.js +1 -0
  162. package/lib/{secp256k1-zHHDNAlH.mjs → secp256k1-BDQEvyHq.mjs} +1 -1
  163. package/lib/{secp256k1-obBDPYM-.mjs → secp256k1-C77Oh9AA.mjs} +1 -1
  164. package/lib/{secp256k1-2hq3Jk4g.mjs → secp256k1-CCn2vlXj.mjs} +1 -1
  165. package/lib/{secp256k1-B94G4gyy.js → secp256k1-CHAR40au.js} +1 -1
  166. package/lib/{secp256k1-DCcAh19h.js → secp256k1-D-DmPYcJ.js} +1 -1
  167. package/lib/{secp256k1-CjndBUS7.js → secp256k1-DYWDlveU.js} +1 -1
  168. package/lib/{signer-N_ccpPOz.mjs → signer-BIcn81N5.mjs} +18 -18
  169. package/lib/signer-H7atraks.js +1 -0
  170. package/lib/{solana-_Ha4YgiP.mjs → solana-B0QSg7B3.mjs} +30 -30
  171. package/lib/solana-Cs5VyB20.js +900 -0
  172. package/lib/solana-uvHG8JV5.js +1 -0
  173. package/lib/solana-zyfOlbhb.mjs +18 -0
  174. package/lib/{solanaEmbed.esm-DK5RIquB.mjs → solanaEmbed.esm-BqdznDuW.mjs} +623 -622
  175. package/lib/solanaEmbed.esm-D8vtESE6.js +10 -0
  176. package/lib/src/AppRouter.d.ts.map +1 -1
  177. package/lib/src/config/mainnet/tokens.d.ts.map +1 -1
  178. package/lib/src/config/testnet/tokens.d.ts.map +1 -1
  179. package/lib/src/config/tokens.d.ts +1 -1
  180. package/lib/src/config/tokens.d.ts.map +1 -1
  181. package/lib/src/exports/index.d.ts +2 -2
  182. package/lib/src/exports/index.d.ts.map +1 -1
  183. package/lib/src/hooks/useFetchQuotes.d.ts.map +1 -1
  184. package/lib/src/icons/Chains/PLUME.d.ts.map +1 -1
  185. package/lib/src/icons/PoweredBy.d.ts.map +1 -1
  186. package/lib/src/icons/Routing.d.ts +5 -0
  187. package/lib/src/icons/Routing.d.ts.map +1 -0
  188. package/lib/src/icons/Tokens/PLUME.d.ts.map +1 -1
  189. package/lib/src/store/transferInput.d.ts +1 -1
  190. package/lib/src/store/transferInput.d.ts.map +1 -1
  191. package/lib/src/utils/coingecko.d.ts.map +1 -1
  192. package/lib/src/utils/formatNumber.d.ts +23 -0
  193. package/lib/src/utils/formatNumber.d.ts.map +1 -0
  194. package/lib/src/utils/index.d.ts +3 -1
  195. package/lib/src/utils/index.d.ts.map +1 -1
  196. package/lib/src/utils/routes.d.ts +12 -0
  197. package/lib/src/utils/routes.d.ts.map +1 -0
  198. package/lib/src/views/v2/Bridge/AmountInput/index.d.ts.map +1 -1
  199. package/lib/src/views/v2/Bridge/AssetPicker/TokenItem.d.ts.map +1 -1
  200. package/lib/src/views/v2/Bridge/Routes/SingleRoute.d.ts.map +1 -1
  201. package/lib/src/views/v2/Redeem/TransactionDetails/index.d.ts.map +1 -1
  202. package/lib/src/views/v3/Bridge/AmountInput/index.d.ts.map +1 -1
  203. package/lib/src/views/v3/Bridge/AssetPicker/TokenItem.d.ts.map +1 -1
  204. package/lib/src/views/v3/Bridge/AssetPicker/index.d.ts.map +1 -1
  205. package/lib/src/views/v3/Bridge/GasSlider/index.d.ts.map +1 -1
  206. package/lib/src/views/v3/Bridge/Routes/Eta.d.ts +6 -0
  207. package/lib/src/views/v3/Bridge/Routes/Eta.d.ts.map +1 -0
  208. package/lib/src/views/v3/Bridge/Routes/RouteBadge.d.ts.map +1 -1
  209. package/lib/src/views/v3/Bridge/Routes/RoutesBottomSheet.d.ts +7 -6
  210. package/lib/src/views/v3/Bridge/Routes/RoutesBottomSheet.d.ts.map +1 -1
  211. package/lib/src/views/v3/Bridge/Routes/RoutesLink.d.ts +7 -0
  212. package/lib/src/views/v3/Bridge/Routes/RoutesLink.d.ts.map +1 -0
  213. package/lib/src/views/v3/Bridge/Routes/RoutesList.d.ts +2 -1
  214. package/lib/src/views/v3/Bridge/Routes/RoutesList.d.ts.map +1 -1
  215. package/lib/src/views/v3/Bridge/Routes/RoutesLoader.d.ts +4 -0
  216. package/lib/src/views/v3/Bridge/Routes/RoutesLoader.d.ts.map +1 -0
  217. package/lib/src/views/v3/Bridge/Routes/RoutesModal.d.ts +6 -5
  218. package/lib/src/views/v3/Bridge/Routes/RoutesModal.d.ts.map +1 -1
  219. package/lib/src/views/v3/Bridge/Routes/SingleRoute.d.ts +1 -0
  220. package/lib/src/views/v3/Bridge/Routes/SingleRoute.d.ts.map +1 -1
  221. package/lib/src/views/v3/Bridge/Routes/index.d.ts.map +1 -1
  222. package/lib/src/views/v3/Redeem/TransactionDetails/index.d.ts.map +1 -1
  223. package/lib/{sui-CQcQ6w_P.mjs → sui-B38DyOqM.mjs} +44 -44
  224. package/lib/{sui-BplKFZQu.mjs → sui-BpfnZR4f.mjs} +3 -3
  225. package/lib/sui-CT9MWY38.js +1 -0
  226. package/lib/{sui-_hvmCvD8.js → sui-DXQAMRQJ.js} +1 -1
  227. package/lib/{tokens-DNv0ZNvU.js → tokens-CmINcwKk.js} +31 -31
  228. package/lib/{tokens-Dl4YwW18.mjs → tokens-YxAPPVy3.mjs} +1726 -1724
  229. package/lib/transfer-BQ72fByU.js +1 -0
  230. package/lib/transfer-bTW0j9yh.mjs +58 -0
  231. package/lib/units-Ckije3Qv.js +1 -0
  232. package/lib/{units-DPWUSE6J.mjs → units-CtyvuzxQ.mjs} +13 -13
  233. package/lib/unsignedTransaction-C6Qp42VS.js +1 -0
  234. package/lib/{unsignedTransaction-DwcUilyN.mjs → unsignedTransaction-CXB-QCUC.mjs} +18 -18
  235. package/lib/{w3m-modal-BJILsxDp.mjs → w3m-modal-B7LUHLWC.mjs} +2 -2
  236. package/lib/{w3m-modal-D4CpFxO2.mjs → w3m-modal-BOTzBqbc.mjs} +2 -2
  237. package/lib/{w3m-modal-CrfHWSrF.js → w3m-modal-BTb03-7B.js} +1 -1
  238. package/lib/{w3m-modal-CBG2MSPp.js → w3m-modal-xmdf4r6V.js} +1 -1
  239. package/lib/web3-COTIsLs8.js +22 -0
  240. package/lib/{address-B-XN4tFw.mjs → web3-DYVeiqSa.mjs} +6599 -6576
  241. package/package.json +32 -32
  242. package/dist/assets/index-BWPgrXHs.js +0 -1
  243. package/lib/account-cRt2xMoW.js +0 -1
  244. package/lib/address-BGujeWtN.js +0 -22
  245. package/lib/address-C7DIAk4M.js +0 -1
  246. package/lib/address-KNhRm6oe.js +0 -1
  247. package/lib/aptos-f5TqmvqV.js +0 -2
  248. package/lib/blake2b-B-MRXUPb.js +0 -1
  249. package/lib/browser-ponyfill-CE6vRkjp.js +0 -2
  250. package/lib/chain-Hsn22HAP.js +0 -1
  251. package/lib/chunk-KJH4KKG6-CoyI75Ig.js +0 -470
  252. package/lib/contract-D2fTrJgn.js +0 -1
  253. package/lib/core-v0G9f7LX.js +0 -889
  254. package/lib/create-DoZZ7ciL.js +0 -1
  255. package/lib/index-B8-KKWD-.js +0 -1
  256. package/lib/index-BHbvgOMD.js +0 -1
  257. package/lib/index-BHfUgvSV.js +0 -1
  258. package/lib/index-BTKC7Hou.js +0 -1
  259. package/lib/index-BWXglAWd.js +0 -1
  260. package/lib/index-Bpp8C4u8.js +0 -1
  261. package/lib/index-CF2fHBHJ.js +0 -3
  262. package/lib/index-CTPz98nv.js +0 -1
  263. package/lib/index-ClMoiji-.js +0 -1
  264. package/lib/index-ClsVcH6F.js +0 -1
  265. package/lib/index-CqOI6LVu.js +0 -1
  266. package/lib/index-DCz_4mcz.js +0 -1
  267. package/lib/index-DKksdvND.js +0 -335
  268. package/lib/index-DRv3ZpVL.js +0 -1
  269. package/lib/index-DYqo8IhM.js +0 -1
  270. package/lib/index-DZubce9o.js +0 -1
  271. package/lib/index-DprM_IpB.js +0 -1
  272. package/lib/index-DshEQYMA.js +0 -1
  273. package/lib/index-JrM783SN.js +0 -1
  274. package/lib/index.es-C6YhioMN.js +0 -27
  275. package/lib/index.es-D3Xxxr8I.js +0 -11
  276. package/lib/mint-DlXC3sGi.js +0 -1
  277. package/lib/platform-B1XoDKoN.js +0 -1
  278. package/lib/platform-COuZC5Zc.js +0 -1
  279. package/lib/platform-NG3efAb2.js +0 -1
  280. package/lib/provider-jsonrpc-pXNHQF7n.js +0 -1
  281. package/lib/signer-CCa6npZ3.js +0 -1
  282. package/lib/solana-BJ3aReZw.mjs +0 -18
  283. package/lib/solana-BwyVgP30.js +0 -1
  284. package/lib/solana-CanFuMgA.js +0 -900
  285. package/lib/solanaEmbed.esm-C--1F7Lx.js +0 -10
  286. package/lib/sui-Bs83Gy5Z.js +0 -1
  287. package/lib/units-BvcKDiAx.js +0 -1
  288. package/lib/unsignedTransaction-dN_5EJf5.js +0 -1
  289. package/lib/web3-Bu_6UejS.mjs +0 -67
  290. package/lib/web3-Doz_0RHD.js +0 -1
@@ -1,3 +0,0 @@
1
- "use strict";const m=require("./address-BGujeWtN.js");function Fr(r){if(r!==void 0)return{connection:r}}var R={},_={};let N=class{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,n){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}};_.Layout=N;function Tt(r,t){return t.property?r+"["+t.property+"]":r}_.nameWithProperty=Tt;function zr(r,t){if(typeof r!="function")throw new TypeError("Class must be constructor");if(r.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof N))throw new TypeError("layout must be a Layout");if(t.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");r.layout_=t,t.boundConstructor_=r,t.makeDestinationObject=()=>new r,Object.defineProperty(r.prototype,"encode",{value:function(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(r,"decode",{value:function(e,n){return t.decode(e,n)},writable:!0})}_.bindConstructorLayout=zr;let q=class extends N{isCount(){throw new Error("ExternalLayout is abstract")}};class Un extends q{constructor(t,e){if(t===void 0&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e){e===void 0&&(e=0);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}let Pt=class extends q{constructor(t,e,n){if(!(t instanceof N))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Q||this.layout instanceof ie}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,n){return n===void 0&&(n=0),this.layout.encode(t,e,n+this.offset)}},Q=class extends N{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,n){return n===void 0&&(n=0),e.writeUIntLE(t,n,this.span),this.span}},ie=class extends N{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,n){return n===void 0&&(n=0),e.writeUIntBE(t,n,this.span),this.span}};class fe extends N{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntLE(e,this.span)}encode(t,e,n){return n===void 0&&(n=0),e.writeIntLE(t,n,this.span),this.span}}class be extends N{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readIntBE(e,this.span)}encode(t,e,n){return n===void 0&&(n=0),e.writeIntBE(t,n,this.span),this.span}}const wt=Math.pow(2,32);function We(r){const t=Math.floor(r/wt),e=r-t*wt;return{hi32:t,lo32:e}}function Xe(r,t){return r*wt+t}let Kr=class extends N{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const n=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return Xe(i,n)}encode(t,e,n){n===void 0&&(n=0);const i=We(t);return e.writeUInt32LE(i.lo32,n),e.writeUInt32LE(i.hi32,n+4),8}};class qr extends N{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const n=t.readUInt32BE(e),i=t.readUInt32BE(e+4);return Xe(n,i)}encode(t,e,n){n===void 0&&(n=0);const i=We(t);return e.writeUInt32BE(i.hi32,n),e.writeUInt32BE(i.lo32,n+4),8}}let Gr=class extends N{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const n=t.readUInt32LE(e),i=t.readInt32LE(e+4);return Xe(i,n)}encode(t,e,n){n===void 0&&(n=0);const i=We(t);return e.writeUInt32LE(i.lo32,n),e.writeInt32LE(i.hi32,n+4),8}};class Zr extends N{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const n=t.readInt32BE(e),i=t.readUInt32BE(e+4);return Xe(n,i)}encode(t,e,n){n===void 0&&(n=0);const i=We(t);return e.writeInt32BE(i.hi32,n),e.writeUInt32BE(i.lo32,n+4),8}}class Nn extends N{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatLE(e)}encode(t,e,n){return n===void 0&&(n=0),e.writeFloatLE(t,n),4}}class Mn extends N{constructor(t){super(4,t)}decode(t,e){return e===void 0&&(e=0),t.readFloatBE(e)}encode(t,e,n){return n===void 0&&(n=0),e.writeFloatBE(t,n),4}}class $n extends N{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleLE(e)}encode(t,e,n){return n===void 0&&(n=0),e.writeDoubleLE(t,n),8}}class jn extends N{constructor(t){super(8,t)}decode(t,e){return e===void 0&&(e=0),t.readDoubleBE(e)}encode(t,e,n){return n===void 0&&(n=0),e.writeDoubleBE(t,n),8}}class Vn extends N{constructor(t,e,n){if(!(t instanceof N))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof q&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof q)&&0<t.span&&(i=e*t.span),super(i,n),this.elementLayout=t,this.count=e}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let n=0,i=this.count;if(i instanceof q&&(i=i.decode(t,e)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let o=0;for(;o<i;)n+=this.elementLayout.getSpan(t,e+n),++o}return n}decode(t,e){e===void 0&&(e=0);const n=[];let i=0,o=this.count;for(o instanceof q&&(o=o.decode(t,e));i<o;)n.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return n}encode(t,e,n){n===void 0&&(n=0);const i=this.elementLayout,o=t.reduce((s,a)=>s+i.encode(a,e,n+s),0);return this.count instanceof q&&this.count.encode(t.length,e,n),o}}let Fn=class extends N{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((o,s)=>o&&s instanceof N,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&n===void 0&&(n=e,e=void 0);for(const o of t)if(0>o.span&&o.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((o,s)=>o+s.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let n=0;try{n=this.fields.reduce((i,o)=>{const s=o.getSpan(t,e);return e+=s,i+s},0)}catch{throw new RangeError("indeterminate span")}return n}decode(t,e){e===void 0&&(e=0);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n){n===void 0&&(n=0);const i=n;let o=0,s=0;for(const a of this.fields){let d=a.span;if(s=0<d?d:0,a.property!==void 0){const c=t[a.property];c!==void 0&&(s=a.encode(c,e,n),0>d&&(d=a.getSpan(e,n)))}o=n,n+=d}return o+s-i}fromArray(t){const e=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}},Ct=class{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},ze=class extends Ct{constructor(t,e){if(!(t instanceof q&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,n){return this.layout.encode(t,e,n)}},Ot=class extends N{constructor(t,e,n){const i=t instanceof Q||t instanceof ie;if(i)t=new ze(new Pt(t));else if(t instanceof q&&t.isCount())t=new ze(t);else if(!(t instanceof Ct))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof N))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let o=-1;e&&(o=e.span,0<=o&&i&&(o+=t.layout.span)),super(o,n),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let s=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return s(a)},this.configGetSourceVariant=function(a){s=a.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const n=this.registry[e];if(t.hasOwnProperty(n.property))return n}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let n;const i=this.discriminator,o=i.decode(t,e);let s=this.registry[o];if(s===void 0){let a=0;s=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),n=this.makeDestinationObject(),n[i.property]=o,n[s.property]=this.defaultLayout.decode(t,e+a)}else n=s.decode(t,e);return n}encode(t,e,n){n===void 0&&(n=0);const i=this.getSourceVariant(t);if(i===void 0){const o=this.discriminator,s=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=o.layout.span),o.encode(t[o.property],e,n),a+s.encode(t[s.property],e,n+a)}return i.encode(t,e,n)}addVariant(t,e,n){const i=new zn(this,t,e,n);return this.registry[t]=i,i}getVariant(t,e){let n=t;return m.dist.Buffer.isBuffer(t)&&(e===void 0&&(e=0),n=this.discriminator.decode(t,e)),this.registry[n]}},zn=class extends N{constructor(t,e,n,i){if(!(t instanceof Ot))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof N))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let o=t.span;0>t.span&&(o=n?n.span:0,0<=o&&t.usesPrefixDiscriminator&&(o+=t.discriminator.layout.span)),super(o,i),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),n+this.layout.getSpan(t,e+n)}decode(t,e){const n=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n){n===void 0&&(n=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);let o=i;if(this.layout&&(this.layout.encode(t[this.property],e,n+i),o+=this.layout.getSpan(e,n+i),0<=this.union.span&&o>this.union.span))throw new Error("encoded variant overruns containing union");return o}fromArray(t){if(this.layout)return this.layout.fromArray(t)}};function we(r){return 0>r&&(r+=4294967296),r}class Rt extends N{constructor(t,e,n){if(!(t instanceof Q||t instanceof ie))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&n===void 0&&(n=e,e=void 0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,n),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(o){return i=we(o),this},this._packedGetValue=function(){return i}}decode(t,e){const n=this.makeDestinationObject();e===void 0&&(e=0);const i=this.word.decode(t,e);this._packedSetValue(i);for(const o of this.fields)o.property!==void 0&&(n[o.property]=o.decode(i));return n}encode(t,e,n){n===void 0&&(n=0);const i=this.word.decode(e,n);this._packedSetValue(i);for(const o of this.fields)if(o.property!==void 0){const s=t[o.property];s!==void 0&&o.encode(s)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){const n=new xe(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new Kn(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}class xe{constructor(t,e,n){if(!(t instanceof Rt))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,o=t.fields.reduce((s,a)=>s+a.bits,0);if(e+o>i)throw new Error("bits too long for span remainder ("+(i-o)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=o,this.container.msb&&(this.start=i-o-e),this.wordMask=we(this.valueMask<<this.start),this.property=n}decode(){const t=this.container._packedGetValue();return we(t&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==we(t&this.valueMask))throw new TypeError(Tt("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=we(t<<this.start);this.container._packedSetValue(we(e&~this.wordMask)|n)}}let Kn=class extends xe{constructor(t,e){super(t,1,e)}decode(t,e){return!!xe.prototype.decode.call(this,t,e)}encode(t){return typeof t=="boolean"&&(t=+t),xe.prototype.encode.call(this,t)}},qn=class extends N{constructor(t,e){if(!(t instanceof q&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof q||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e){e===void 0&&(e=0);let n=this.span;return 0>n&&(n=this.length.decode(t,e)),t.slice(e,e+n)}encode(t,e,n){let i=this.length;if(this.length instanceof q&&(i=t.length),!(m.dist.Buffer.isBuffer(t)&&i===t.length))throw new TypeError(Tt("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(n+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),n,i,"hex"),this.length instanceof q&&this.length.encode(i,e,n),i}};class Gn extends N{constructor(t){super(-1,t)}getSpan(t,e){if(!m.dist.Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");e===void 0&&(e=0);let n=e;for(;n<t.length&&t[n]!==0;)n+=1;return 1+n-e}decode(t,e,n){e===void 0&&(e=0);let i=this.getSpan(t,e);return t.slice(e,e+i-1).toString("utf-8")}encode(t,e,n){n===void 0&&(n=0),typeof t!="string"&&(t=t.toString());const i=new m.dist.Buffer(t,"utf8"),o=i.length;if(n+o>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,n),e[n+o]=0,o+1}}class Zn extends N{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e){if(!m.dist.Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");return e===void 0&&(e=0),t.length-e}decode(t,e,n){e===void 0&&(e=0);let i=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");return t.slice(e,e+i).toString("utf-8")}encode(t,e,n){n===void 0&&(n=0),typeof t!="string"&&(t=t.toString());const i=new m.dist.Buffer(t,"utf8"),o=i.length;if(0<=this.maxSpan&&this.maxSpan<o)throw new RangeError("text length exceeds maxSpan");if(n+o>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(e,n),o}}class Hn extends N{constructor(t,e){super(0,e),this.value=t}decode(t,e,n){return this.value}encode(t,e,n){return 0}}_.ExternalLayout=q;_.GreedyCount=Un;_.OffsetLayout=Pt;_.UInt=Q;_.UIntBE=ie;_.Int=fe;_.IntBE=be;_.Float=Nn;_.FloatBE=Mn;_.Double=$n;_.DoubleBE=jn;_.Sequence=Vn;_.Structure=Fn;_.UnionDiscriminator=Ct;_.UnionLayoutDiscriminator=ze;_.Union=Ot;_.VariantLayout=zn;_.BitStructure=Rt;_.BitField=xe;_.Boolean=Kn;_.Blob=qn;_.CString=Gn;_.UTF8=Zn;_.Constant=Hn;_.greedy=(r,t)=>new Un(r,t);_.offset=(r,t,e)=>new Pt(r,t,e);_.u8=r=>new Q(1,r);_.u16=r=>new Q(2,r);_.u24=r=>new Q(3,r);_.u32=r=>new Q(4,r);_.u40=r=>new Q(5,r);_.u48=r=>new Q(6,r);_.nu64=r=>new Kr(r);_.u16be=r=>new ie(2,r);_.u24be=r=>new ie(3,r);_.u32be=r=>new ie(4,r);_.u40be=r=>new ie(5,r);_.u48be=r=>new ie(6,r);_.nu64be=r=>new qr(r);_.s8=r=>new fe(1,r);_.s16=r=>new fe(2,r);_.s24=r=>new fe(3,r);_.s32=r=>new fe(4,r);_.s40=r=>new fe(5,r);_.s48=r=>new fe(6,r);_.ns64=r=>new Gr(r);_.s16be=r=>new be(2,r);_.s24be=r=>new be(3,r);_.s32be=r=>new be(4,r);_.s40be=r=>new be(5,r);_.s48be=r=>new be(6,r);_.ns64be=r=>new Zr(r);_.f32=r=>new Nn(r);_.f32be=r=>new Mn(r);_.f64=r=>new $n(r);_.f64be=r=>new jn(r);_.struct=(r,t,e)=>new Fn(r,t,e);_.bits=(r,t,e)=>new Rt(r,t,e);_.seq=(r,t,e)=>new Vn(r,t,e);_.union=(r,t,e)=>new Ot(r,t,e);_.unionLayoutDiscriminator=(r,t)=>new ze(r,t);_.blob=(r,t)=>new qn(r,t);_.cstr=r=>new Gn(r);_.utf8=(r,t)=>new Zn(r,t);_.const=(r,t)=>new Hn(r,t);const Hr=m.getAugmentedNamespace(m.index_browser_esm);(function(r){var t=m.commonjsGlobal&&m.commonjsGlobal.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(r,"__esModule",{value:!0}),r.map=r.array=r.rustEnum=r.str=r.vecU8=r.tagged=r.vec=r.bool=r.option=r.publicKey=r.i256=r.u256=r.i128=r.u128=r.i64=r.u64=r.struct=r.f64=r.f32=r.i32=r.u32=r.i16=r.u16=r.i8=r.u8=void 0;const e=_,n=Hr,i=t(m.bnExports);var o=_;Object.defineProperty(r,"u8",{enumerable:!0,get:function(){return o.u8}}),Object.defineProperty(r,"i8",{enumerable:!0,get:function(){return o.s8}}),Object.defineProperty(r,"u16",{enumerable:!0,get:function(){return o.u16}}),Object.defineProperty(r,"i16",{enumerable:!0,get:function(){return o.s16}}),Object.defineProperty(r,"u32",{enumerable:!0,get:function(){return o.u32}}),Object.defineProperty(r,"i32",{enumerable:!0,get:function(){return o.s32}}),Object.defineProperty(r,"f32",{enumerable:!0,get:function(){return o.f32}}),Object.defineProperty(r,"f64",{enumerable:!0,get:function(){return o.f64}}),Object.defineProperty(r,"struct",{enumerable:!0,get:function(){return o.struct}});class s extends e.Layout{constructor(v,l,h){super(v,h),this.blob=(0,e.blob)(v),this.signed=l}decode(v,l=0){const h=new i.default(this.blob.decode(v,l),10,"le");return this.signed?h.fromTwos(this.span*8).clone():h}encode(v,l,h=0){return this.signed&&(v=v.toTwos(this.span*8)),this.blob.encode(v.toArrayLike(m.dist.Buffer,"le",this.span),l,h)}}function a(S){return new s(8,!1,S)}r.u64=a;function d(S){return new s(8,!0,S)}r.i64=d;function c(S){return new s(16,!1,S)}r.u128=c;function u(S){return new s(16,!0,S)}r.i128=u;function y(S){return new s(32,!1,S)}r.u256=y;function w(S){return new s(32,!0,S)}r.i256=w;class f extends e.Layout{constructor(v,l,h,k){super(v.span,k),this.layout=v,this.decoder=l,this.encoder=h}decode(v,l){return this.decoder(this.layout.decode(v,l))}encode(v,l,h){return this.layout.encode(this.encoder(v),l,h)}getSpan(v,l){return this.layout.getSpan(v,l)}}function p(S){return new f((0,e.blob)(32),v=>new n.PublicKey(v),v=>v.toBuffer(),S)}r.publicKey=p;class x extends e.Layout{constructor(v,l){super(-1,l),this.layout=v,this.discriminator=(0,e.u8)()}encode(v,l,h=0){return v==null?this.discriminator.encode(0,l,h):(this.discriminator.encode(1,l,h),this.layout.encode(v,l,h+1)+1)}decode(v,l=0){const h=this.discriminator.decode(v,l);if(h===0)return null;if(h===1)return this.layout.decode(v,l+1);throw new Error("Invalid option "+this.property)}getSpan(v,l=0){const h=this.discriminator.decode(v,l);if(h===0)return 1;if(h===1)return this.layout.getSpan(v,l+1)+1;throw new Error("Invalid option "+this.property)}}function g(S,v){return new x(S,v)}r.option=g;function A(S){return new f((0,e.u8)(),P,E,S)}r.bool=A;function P(S){if(S===0)return!1;if(S===1)return!0;throw new Error("Invalid bool: "+S)}function E(S){return S?1:0}function b(S,v){const l=(0,e.u32)("length"),h=(0,e.struct)([l,(0,e.seq)(S,(0,e.offset)(l,-l.span),"values")]);return new f(h,({values:k})=>k,k=>({values:k}),v)}r.vec=b;function T(S,v,l){const h=(0,e.struct)([a("tag"),v.replicate("data")]);function k({tag:U,data:F}){if(!U.eq(S))throw new Error("Invalid tag, expected: "+S.toString("hex")+", got: "+U.toString("hex"));return F}return new f(h,k,U=>({tag:S,data:U}),l)}r.tagged=T;function $(S){const v=(0,e.u32)("length"),l=(0,e.struct)([v,(0,e.blob)((0,e.offset)(v,-v.span),"data")]);return new f(l,({data:h})=>h,h=>({data:h}),S)}r.vecU8=$;function I(S){return new f($(),v=>v.toString("utf-8"),v=>m.dist.Buffer.from(v,"utf-8"),S)}r.str=I;function D(S,v,l){const h=(0,e.union)(l??(0,e.u8)(),v);return S.forEach((k,U)=>h.addVariant(U,k,k.property)),h}r.rustEnum=D;function B(S,v,l){const h=(0,e.struct)([(0,e.seq)(S,v,"values")]);return new f(h,({values:k})=>k,k=>({values:k}),l)}r.array=B;class O extends e.Layout{constructor(v,l,h){super(v.span+l.span,h),this.keyLayout=v,this.valueLayout=l}decode(v,l){l=l||0;const h=this.keyLayout.decode(v,l),k=this.valueLayout.decode(v,l+this.keyLayout.getSpan(v,l));return[h,k]}encode(v,l,h){h=h||0;const k=this.keyLayout.encode(v[0],l,h),U=this.valueLayout.encode(v[1],l,h+k);return k+U}getSpan(v,l){return this.keyLayout.getSpan(v,l)+this.valueLayout.getSpan(v,l)}}function C(S,v,l){const h=(0,e.u32)("length"),k=(0,e.struct)([h,(0,e.seq)(new O(S,v),(0,e.offset)(h,-h.span),"values")]);return new f(k,({values:U})=>new Map(U),U=>({values:Array.from(U.entries())}),l)}r.map=C})(R);var Bt={exports:{}};const Wr=/[\p{Lu}]/u,Xr=/[\p{Ll}]/u,Gt=/^[\p{Lu}](?![\p{Lu}])/gu,Wn=/([\p{Alpha}\p{N}_]|$)/u,Xn=/[_.\- ]+/,Yr=new RegExp("^"+Xn.source),Zt=new RegExp(Xn.source+Wn.source,"gu"),Ht=new RegExp("\\d+"+Wn.source,"gu"),Jr=(r,t,e)=>{let n=!1,i=!1,o=!1;for(let s=0;s<r.length;s++){const a=r[s];n&&Wr.test(a)?(r=r.slice(0,s)+"-"+r.slice(s),n=!1,o=i,i=!0,s++):i&&o&&Xr.test(a)?(r=r.slice(0,s-1)+"-"+r.slice(s-1),o=i,i=!1,n=!0):(n=t(a)===a&&e(a)!==a,o=i,i=e(a)===a&&t(a)!==a)}return r},Qr=(r,t)=>(Gt.lastIndex=0,r.replace(Gt,e=>t(e))),ei=(r,t)=>(Zt.lastIndex=0,Ht.lastIndex=0,r.replace(Zt,(e,n)=>t(n)).replace(Ht,e=>t(e))),Yn=(r,t)=>{if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(r)?r=r.map(o=>o.trim()).filter(o=>o.length).join("-"):r=r.trim(),r.length===0)return"";const e=t.locale===!1?o=>o.toLowerCase():o=>o.toLocaleLowerCase(t.locale),n=t.locale===!1?o=>o.toUpperCase():o=>o.toLocaleUpperCase(t.locale);return r.length===1?t.pascalCase?n(r):e(r):(r!==e(r)&&(r=Jr(r,e,n)),r=r.replace(Yr,""),t.preserveConsecutiveUppercase?r=Qr(r,e):r=e(r),t.pascalCase&&(r=n(r.charAt(0))+r.slice(1)),ei(r,n))};Bt.exports=Yn;Bt.exports.default=Yn;var ti=Bt.exports;const V=m.getDefaultExportFromCjs(ti);function ve(r){let t=r.length;for(;--t>=0;)r[t]=0}const ni=3,ri=258,Jn=29,ii=256,oi=ii+1+Jn,Qn=30,si=512,ai=new Array((oi+2)*2);ve(ai);const ci=new Array(Qn*2);ve(ci);const ui=new Array(si);ve(ui);const li=new Array(ri-ni+1);ve(li);const di=new Array(Jn);ve(di);const fi=new Array(Qn);ve(fi);const hi=(r,t,e,n)=>{let i=r&65535|0,o=r>>>16&65535|0,s=0;for(;e!==0;){s=e>2e3?2e3:e,e-=s;do i=i+t[n++]|0,o=o+i|0;while(--s);i%=65521,o%=65521}return i|o<<16|0};var yt=hi;const pi=()=>{let r,t=[];for(var e=0;e<256;e++){r=e;for(var n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;t[e]=r}return t},wi=new Uint32Array(pi()),yi=(r,t,e,n)=>{const i=wi,o=n+e;r^=-1;for(let s=n;s<o;s++)r=r>>>8^i[(r^t[s])&255];return r^-1};var Y=yi,gt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},er={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const gi=(r,t)=>Object.prototype.hasOwnProperty.call(r,t);var mi=function(r){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const n in e)gi(e,n)&&(r[n]=e[n])}}return r},bi=r=>{let t=0;for(let n=0,i=r.length;n<i;n++)t+=r[n].length;const e=new Uint8Array(t);for(let n=0,i=0,o=r.length;n<o;n++){let s=r[n];e.set(s,i),i+=s.length}return e},tr={assign:mi,flattenChunks:bi};let nr=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{nr=!1}const Ie=new Uint8Array(256);for(let r=0;r<256;r++)Ie[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;Ie[254]=Ie[254]=1;var vi=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let t,e,n,i,o,s=r.length,a=0;for(i=0;i<s;i++)e=r.charCodeAt(i),(e&64512)===55296&&i+1<s&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(e=65536+(e-55296<<10)+(n-56320),i++)),a+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(a),o=0,i=0;o<a;i++)e=r.charCodeAt(i),(e&64512)===55296&&i+1<s&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(e=65536+(e-55296<<10)+(n-56320),i++)),e<128?t[o++]=e:e<2048?(t[o++]=192|e>>>6,t[o++]=128|e&63):e<65536?(t[o++]=224|e>>>12,t[o++]=128|e>>>6&63,t[o++]=128|e&63):(t[o++]=240|e>>>18,t[o++]=128|e>>>12&63,t[o++]=128|e>>>6&63,t[o++]=128|e&63);return t};const _i=(r,t)=>{if(t<65534&&r.subarray&&nr)return String.fromCharCode.apply(null,r.length===t?r:r.subarray(0,t));let e="";for(let n=0;n<t;n++)e+=String.fromCharCode(r[n]);return e};var Ei=(r,t)=>{const e=t||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,t));let n,i;const o=new Array(e*2);for(i=0,n=0;n<e;){let s=r[n++];if(s<128){o[i++]=s;continue}let a=Ie[s];if(a>4){o[i++]=65533,n+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&n<e;)s=s<<6|r[n++]&63,a--;if(a>1){o[i++]=65533;continue}s<65536?o[i++]=s:(s-=65536,o[i++]=55296|s>>10&1023,o[i++]=56320|s&1023)}return _i(o,i)},Ai=(r,t)=>{t=t||r.length,t>r.length&&(t=r.length);let e=t-1;for(;e>=0&&(r[e]&192)===128;)e--;return e<0||e===0?t:e+Ie[r[e]]>t?e:t},mt={string2buf:vi,buf2string:Ei,utf8border:Ai};function xi(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var ki=xi;const De=16209,Si=16191;var Ii=function(t,e){let n,i,o,s,a,d,c,u,y,w,f,p,x,g,A,P,E,b,T,$,I,D,B,O;const C=t.state;n=t.next_in,B=t.input,i=n+(t.avail_in-5),o=t.next_out,O=t.output,s=o-(e-t.avail_out),a=o+(t.avail_out-257),d=C.dmax,c=C.wsize,u=C.whave,y=C.wnext,w=C.window,f=C.hold,p=C.bits,x=C.lencode,g=C.distcode,A=(1<<C.lenbits)-1,P=(1<<C.distbits)-1;e:do{p<15&&(f+=B[n++]<<p,p+=8,f+=B[n++]<<p,p+=8),E=x[f&A];t:for(;;){if(b=E>>>24,f>>>=b,p-=b,b=E>>>16&255,b===0)O[o++]=E&65535;else if(b&16){T=E&65535,b&=15,b&&(p<b&&(f+=B[n++]<<p,p+=8),T+=f&(1<<b)-1,f>>>=b,p-=b),p<15&&(f+=B[n++]<<p,p+=8,f+=B[n++]<<p,p+=8),E=g[f&P];n:for(;;){if(b=E>>>24,f>>>=b,p-=b,b=E>>>16&255,b&16){if($=E&65535,b&=15,p<b&&(f+=B[n++]<<p,p+=8,p<b&&(f+=B[n++]<<p,p+=8)),$+=f&(1<<b)-1,$>d){t.msg="invalid distance too far back",C.mode=De;break e}if(f>>>=b,p-=b,b=o-s,$>b){if(b=$-b,b>u&&C.sane){t.msg="invalid distance too far back",C.mode=De;break e}if(I=0,D=w,y===0){if(I+=c-b,b<T){T-=b;do O[o++]=w[I++];while(--b);I=o-$,D=O}}else if(y<b){if(I+=c+y-b,b-=y,b<T){T-=b;do O[o++]=w[I++];while(--b);if(I=0,y<T){b=y,T-=b;do O[o++]=w[I++];while(--b);I=o-$,D=O}}}else if(I+=y-b,b<T){T-=b;do O[o++]=w[I++];while(--b);I=o-$,D=O}for(;T>2;)O[o++]=D[I++],O[o++]=D[I++],O[o++]=D[I++],T-=3;T&&(O[o++]=D[I++],T>1&&(O[o++]=D[I++]))}else{I=o-$;do O[o++]=O[I++],O[o++]=O[I++],O[o++]=O[I++],T-=3;while(T>2);T&&(O[o++]=O[I++],T>1&&(O[o++]=O[I++]))}}else if(b&64){t.msg="invalid distance code",C.mode=De;break e}else{E=g[(E&65535)+(f&(1<<b)-1)];continue n}break}}else if(b&64)if(b&32){C.mode=Si;break e}else{t.msg="invalid literal/length code",C.mode=De;break e}else{E=x[(E&65535)+(f&(1<<b)-1)];continue t}break}}while(n<i&&o<a);T=p>>3,n-=T,p-=T<<3,f&=(1<<p)-1,t.next_in=n,t.next_out=o,t.avail_in=n<i?5+(i-n):5-(n-i),t.avail_out=o<a?257+(a-o):257-(o-a),C.hold=f,C.bits=p};const pe=15,Wt=852,Xt=592,Yt=0,it=1,Jt=2,Li=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Ti=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Pi=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Ci=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),Oi=(r,t,e,n,i,o,s,a)=>{const d=a.bits;let c=0,u=0,y=0,w=0,f=0,p=0,x=0,g=0,A=0,P=0,E,b,T,$,I,D=null,B;const O=new Uint16Array(pe+1),C=new Uint16Array(pe+1);let S=null,v,l,h;for(c=0;c<=pe;c++)O[c]=0;for(u=0;u<n;u++)O[t[e+u]]++;for(f=d,w=pe;w>=1&&O[w]===0;w--);if(f>w&&(f=w),w===0)return i[o++]=1<<24|64<<16|0,i[o++]=1<<24|64<<16|0,a.bits=1,0;for(y=1;y<w&&O[y]===0;y++);for(f<y&&(f=y),g=1,c=1;c<=pe;c++)if(g<<=1,g-=O[c],g<0)return-1;if(g>0&&(r===Yt||w!==1))return-1;for(C[1]=0,c=1;c<pe;c++)C[c+1]=C[c]+O[c];for(u=0;u<n;u++)t[e+u]!==0&&(s[C[t[e+u]]++]=u);if(r===Yt?(D=S=s,B=20):r===it?(D=Li,S=Ti,B=257):(D=Pi,S=Ci,B=0),P=0,u=0,c=y,I=o,p=f,x=0,T=-1,A=1<<f,$=A-1,r===it&&A>Wt||r===Jt&&A>Xt)return 1;for(;;){v=c-x,s[u]+1<B?(l=0,h=s[u]):s[u]>=B?(l=S[s[u]-B],h=D[s[u]-B]):(l=96,h=0),E=1<<c-x,b=1<<p,y=b;do b-=E,i[I+(P>>x)+b]=v<<24|l<<16|h|0;while(b!==0);for(E=1<<c-1;P&E;)E>>=1;if(E!==0?(P&=E-1,P+=E):P=0,u++,--O[c]===0){if(c===w)break;c=t[e+s[u]]}if(c>f&&(P&$)!==T){for(x===0&&(x=f),I+=y,p=c-x,g=1<<p;p+x<w&&(g-=O[p+x],!(g<=0));)p++,g<<=1;if(A+=1<<p,r===it&&A>Wt||r===Jt&&A>Xt)return 1;T=P&$,i[T]=f<<24|p<<16|I-o|0}}return P!==0&&(i[I+P]=c-x<<24|64<<16|0),a.bits=f,0};var ke=Oi;const Ri=0,rr=1,ir=2,{Z_FINISH:Qt,Z_BLOCK:Bi,Z_TREES:Ue,Z_OK:de,Z_STREAM_END:Di,Z_NEED_DICT:Ui,Z_STREAM_ERROR:W,Z_DATA_ERROR:or,Z_MEM_ERROR:sr,Z_BUF_ERROR:Ni,Z_DEFLATED:en}=er,Ye=16180,tn=16181,nn=16182,rn=16183,on=16184,sn=16185,an=16186,cn=16187,un=16188,ln=16189,Ke=16190,ee=16191,ot=16192,dn=16193,st=16194,fn=16195,hn=16196,pn=16197,wn=16198,Ne=16199,Me=16200,yn=16201,gn=16202,mn=16203,bn=16204,vn=16205,at=16206,_n=16207,En=16208,j=16209,ar=16210,cr=16211,Mi=852,$i=592,ji=15,Vi=ji,An=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function Fi(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const he=r=>{if(!r)return 1;const t=r.state;return!t||t.strm!==r||t.mode<Ye||t.mode>cr?1:0},ur=r=>{if(he(r))return W;const t=r.state;return r.total_in=r.total_out=t.total=0,r.msg="",t.wrap&&(r.adler=t.wrap&1),t.mode=Ye,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Mi),t.distcode=t.distdyn=new Int32Array($i),t.sane=1,t.back=-1,de},lr=r=>{if(he(r))return W;const t=r.state;return t.wsize=0,t.whave=0,t.wnext=0,ur(r)},dr=(r,t)=>{let e;if(he(r))return W;const n=r.state;return t<0?(e=0,t=-t):(e=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?W:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=e,n.wbits=t,lr(r))},fr=(r,t)=>{if(!r)return W;const e=new Fi;r.state=e,e.strm=r,e.window=null,e.mode=Ye;const n=dr(r,t);return n!==de&&(r.state=null),n},zi=r=>fr(r,Vi);let xn=!0,ct,ut;const Ki=r=>{if(xn){ct=new Int32Array(512),ut=new Int32Array(32);let t=0;for(;t<144;)r.lens[t++]=8;for(;t<256;)r.lens[t++]=9;for(;t<280;)r.lens[t++]=7;for(;t<288;)r.lens[t++]=8;for(ke(rr,r.lens,0,288,ct,0,r.work,{bits:9}),t=0;t<32;)r.lens[t++]=5;ke(ir,r.lens,0,32,ut,0,r.work,{bits:5}),xn=!1}r.lencode=ct,r.lenbits=9,r.distcode=ut,r.distbits=5},hr=(r,t,e,n)=>{let i;const o=r.state;return o.window===null&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),n>=o.wsize?(o.window.set(t.subarray(e-o.wsize,e),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(t.subarray(e-n,e-n+i),o.wnext),n-=i,n?(o.window.set(t.subarray(e-n,e),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0},qi=(r,t)=>{let e,n,i,o,s,a,d,c,u,y,w,f,p,x,g=0,A,P,E,b,T,$,I,D;const B=new Uint8Array(4);let O,C;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(he(r)||!r.output||!r.input&&r.avail_in!==0)return W;e=r.state,e.mode===ee&&(e.mode=ot),s=r.next_out,i=r.output,d=r.avail_out,o=r.next_in,n=r.input,a=r.avail_in,c=e.hold,u=e.bits,y=a,w=d,D=de;e:for(;;)switch(e.mode){case Ye:if(e.wrap===0){e.mode=ot;break}for(;u<16;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if(e.wrap&2&&c===35615){e.wbits===0&&(e.wbits=15),e.check=0,B[0]=c&255,B[1]=c>>>8&255,e.check=Y(e.check,B,2,0),c=0,u=0,e.mode=tn;break}if(e.head&&(e.head.done=!1),!(e.wrap&1)||(((c&255)<<8)+(c>>8))%31){r.msg="incorrect header check",e.mode=j;break}if((c&15)!==en){r.msg="unknown compression method",e.mode=j;break}if(c>>>=4,u-=4,I=(c&15)+8,e.wbits===0&&(e.wbits=I),I>15||I>e.wbits){r.msg="invalid window size",e.mode=j;break}e.dmax=1<<e.wbits,e.flags=0,r.adler=e.check=1,e.mode=c&512?ln:ee,c=0,u=0;break;case tn:for(;u<16;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if(e.flags=c,(e.flags&255)!==en){r.msg="unknown compression method",e.mode=j;break}if(e.flags&57344){r.msg="unknown header flags set",e.mode=j;break}e.head&&(e.head.text=c>>8&1),e.flags&512&&e.wrap&4&&(B[0]=c&255,B[1]=c>>>8&255,e.check=Y(e.check,B,2,0)),c=0,u=0,e.mode=nn;case nn:for(;u<32;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}e.head&&(e.head.time=c),e.flags&512&&e.wrap&4&&(B[0]=c&255,B[1]=c>>>8&255,B[2]=c>>>16&255,B[3]=c>>>24&255,e.check=Y(e.check,B,4,0)),c=0,u=0,e.mode=rn;case rn:for(;u<16;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}e.head&&(e.head.xflags=c&255,e.head.os=c>>8),e.flags&512&&e.wrap&4&&(B[0]=c&255,B[1]=c>>>8&255,e.check=Y(e.check,B,2,0)),c=0,u=0,e.mode=on;case on:if(e.flags&1024){for(;u<16;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}e.length=c,e.head&&(e.head.extra_len=c),e.flags&512&&e.wrap&4&&(B[0]=c&255,B[1]=c>>>8&255,e.check=Y(e.check,B,2,0)),c=0,u=0}else e.head&&(e.head.extra=null);e.mode=sn;case sn:if(e.flags&1024&&(f=e.length,f>a&&(f=a),f&&(e.head&&(I=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(n.subarray(o,o+f),I)),e.flags&512&&e.wrap&4&&(e.check=Y(e.check,n,f,o)),a-=f,o+=f,e.length-=f),e.length))break e;e.length=0,e.mode=an;case an:if(e.flags&2048){if(a===0)break e;f=0;do I=n[o+f++],e.head&&I&&e.length<65536&&(e.head.name+=String.fromCharCode(I));while(I&&f<a);if(e.flags&512&&e.wrap&4&&(e.check=Y(e.check,n,f,o)),a-=f,o+=f,I)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=cn;case cn:if(e.flags&4096){if(a===0)break e;f=0;do I=n[o+f++],e.head&&I&&e.length<65536&&(e.head.comment+=String.fromCharCode(I));while(I&&f<a);if(e.flags&512&&e.wrap&4&&(e.check=Y(e.check,n,f,o)),a-=f,o+=f,I)break e}else e.head&&(e.head.comment=null);e.mode=un;case un:if(e.flags&512){for(;u<16;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if(e.wrap&4&&c!==(e.check&65535)){r.msg="header crc mismatch",e.mode=j;break}c=0,u=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),r.adler=e.check=0,e.mode=ee;break;case ln:for(;u<32;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}r.adler=e.check=An(c),c=0,u=0,e.mode=Ke;case Ke:if(e.havedict===0)return r.next_out=s,r.avail_out=d,r.next_in=o,r.avail_in=a,e.hold=c,e.bits=u,Ui;r.adler=e.check=1,e.mode=ee;case ee:if(t===Bi||t===Ue)break e;case ot:if(e.last){c>>>=u&7,u-=u&7,e.mode=at;break}for(;u<3;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}switch(e.last=c&1,c>>>=1,u-=1,c&3){case 0:e.mode=dn;break;case 1:if(Ki(e),e.mode=Ne,t===Ue){c>>>=2,u-=2;break e}break;case 2:e.mode=hn;break;case 3:r.msg="invalid block type",e.mode=j}c>>>=2,u-=2;break;case dn:for(c>>>=u&7,u-=u&7;u<32;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if((c&65535)!==(c>>>16^65535)){r.msg="invalid stored block lengths",e.mode=j;break}if(e.length=c&65535,c=0,u=0,e.mode=st,t===Ue)break e;case st:e.mode=fn;case fn:if(f=e.length,f){if(f>a&&(f=a),f>d&&(f=d),f===0)break e;i.set(n.subarray(o,o+f),s),a-=f,o+=f,d-=f,s+=f,e.length-=f;break}e.mode=ee;break;case hn:for(;u<14;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if(e.nlen=(c&31)+257,c>>>=5,u-=5,e.ndist=(c&31)+1,c>>>=5,u-=5,e.ncode=(c&15)+4,c>>>=4,u-=4,e.nlen>286||e.ndist>30){r.msg="too many length or distance symbols",e.mode=j;break}e.have=0,e.mode=pn;case pn:for(;e.have<e.ncode;){for(;u<3;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}e.lens[S[e.have++]]=c&7,c>>>=3,u-=3}for(;e.have<19;)e.lens[S[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,O={bits:e.lenbits},D=ke(Ri,e.lens,0,19,e.lencode,0,e.work,O),e.lenbits=O.bits,D){r.msg="invalid code lengths set",e.mode=j;break}e.have=0,e.mode=wn;case wn:for(;e.have<e.nlen+e.ndist;){for(;g=e.lencode[c&(1<<e.lenbits)-1],A=g>>>24,P=g>>>16&255,E=g&65535,!(A<=u);){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if(E<16)c>>>=A,u-=A,e.lens[e.have++]=E;else{if(E===16){for(C=A+2;u<C;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if(c>>>=A,u-=A,e.have===0){r.msg="invalid bit length repeat",e.mode=j;break}I=e.lens[e.have-1],f=3+(c&3),c>>>=2,u-=2}else if(E===17){for(C=A+3;u<C;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}c>>>=A,u-=A,I=0,f=3+(c&7),c>>>=3,u-=3}else{for(C=A+7;u<C;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}c>>>=A,u-=A,I=0,f=11+(c&127),c>>>=7,u-=7}if(e.have+f>e.nlen+e.ndist){r.msg="invalid bit length repeat",e.mode=j;break}for(;f--;)e.lens[e.have++]=I}}if(e.mode===j)break;if(e.lens[256]===0){r.msg="invalid code -- missing end-of-block",e.mode=j;break}if(e.lenbits=9,O={bits:e.lenbits},D=ke(rr,e.lens,0,e.nlen,e.lencode,0,e.work,O),e.lenbits=O.bits,D){r.msg="invalid literal/lengths set",e.mode=j;break}if(e.distbits=6,e.distcode=e.distdyn,O={bits:e.distbits},D=ke(ir,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,O),e.distbits=O.bits,D){r.msg="invalid distances set",e.mode=j;break}if(e.mode=Ne,t===Ue)break e;case Ne:e.mode=Me;case Me:if(a>=6&&d>=258){r.next_out=s,r.avail_out=d,r.next_in=o,r.avail_in=a,e.hold=c,e.bits=u,Ii(r,w),s=r.next_out,i=r.output,d=r.avail_out,o=r.next_in,n=r.input,a=r.avail_in,c=e.hold,u=e.bits,e.mode===ee&&(e.back=-1);break}for(e.back=0;g=e.lencode[c&(1<<e.lenbits)-1],A=g>>>24,P=g>>>16&255,E=g&65535,!(A<=u);){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if(P&&!(P&240)){for(b=A,T=P,$=E;g=e.lencode[$+((c&(1<<b+T)-1)>>b)],A=g>>>24,P=g>>>16&255,E=g&65535,!(b+A<=u);){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}c>>>=b,u-=b,e.back+=b}if(c>>>=A,u-=A,e.back+=A,e.length=E,P===0){e.mode=vn;break}if(P&32){e.back=-1,e.mode=ee;break}if(P&64){r.msg="invalid literal/length code",e.mode=j;break}e.extra=P&15,e.mode=yn;case yn:if(e.extra){for(C=e.extra;u<C;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}e.length+=c&(1<<e.extra)-1,c>>>=e.extra,u-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=gn;case gn:for(;g=e.distcode[c&(1<<e.distbits)-1],A=g>>>24,P=g>>>16&255,E=g&65535,!(A<=u);){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if(!(P&240)){for(b=A,T=P,$=E;g=e.distcode[$+((c&(1<<b+T)-1)>>b)],A=g>>>24,P=g>>>16&255,E=g&65535,!(b+A<=u);){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}c>>>=b,u-=b,e.back+=b}if(c>>>=A,u-=A,e.back+=A,P&64){r.msg="invalid distance code",e.mode=j;break}e.offset=E,e.extra=P&15,e.mode=mn;case mn:if(e.extra){for(C=e.extra;u<C;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}e.offset+=c&(1<<e.extra)-1,c>>>=e.extra,u-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){r.msg="invalid distance too far back",e.mode=j;break}e.mode=bn;case bn:if(d===0)break e;if(f=w-d,e.offset>f){if(f=e.offset-f,f>e.whave&&e.sane){r.msg="invalid distance too far back",e.mode=j;break}f>e.wnext?(f-=e.wnext,p=e.wsize-f):p=e.wnext-f,f>e.length&&(f=e.length),x=e.window}else x=i,p=s-e.offset,f=e.length;f>d&&(f=d),d-=f,e.length-=f;do i[s++]=x[p++];while(--f);e.length===0&&(e.mode=Me);break;case vn:if(d===0)break e;i[s++]=e.length,d--,e.mode=Me;break;case at:if(e.wrap){for(;u<32;){if(a===0)break e;a--,c|=n[o++]<<u,u+=8}if(w-=d,r.total_out+=w,e.total+=w,e.wrap&4&&w&&(r.adler=e.check=e.flags?Y(e.check,i,w,s-w):yt(e.check,i,w,s-w)),w=d,e.wrap&4&&(e.flags?c:An(c))!==e.check){r.msg="incorrect data check",e.mode=j;break}c=0,u=0}e.mode=_n;case _n:if(e.wrap&&e.flags){for(;u<32;){if(a===0)break e;a--,c+=n[o++]<<u,u+=8}if(e.wrap&4&&c!==(e.total&4294967295)){r.msg="incorrect length check",e.mode=j;break}c=0,u=0}e.mode=En;case En:D=Di;break e;case j:D=or;break e;case ar:return sr;case cr:default:return W}return r.next_out=s,r.avail_out=d,r.next_in=o,r.avail_in=a,e.hold=c,e.bits=u,(e.wsize||w!==r.avail_out&&e.mode<j&&(e.mode<at||t!==Qt))&&hr(r,r.output,r.next_out,w-r.avail_out),y-=r.avail_in,w-=r.avail_out,r.total_in+=y,r.total_out+=w,e.total+=w,e.wrap&4&&w&&(r.adler=e.check=e.flags?Y(e.check,i,w,r.next_out-w):yt(e.check,i,w,r.next_out-w)),r.data_type=e.bits+(e.last?64:0)+(e.mode===ee?128:0)+(e.mode===Ne||e.mode===st?256:0),(y===0&&w===0||t===Qt)&&D===de&&(D=Ni),D},Gi=r=>{if(he(r))return W;let t=r.state;return t.window&&(t.window=null),r.state=null,de},Zi=(r,t)=>{if(he(r))return W;const e=r.state;return e.wrap&2?(e.head=t,t.done=!1,de):W},Hi=(r,t)=>{const e=t.length;let n,i,o;return he(r)||(n=r.state,n.wrap!==0&&n.mode!==Ke)?W:n.mode===Ke&&(i=1,i=yt(i,t,e,0),i!==n.check)?or:(o=hr(r,t,e,e),o?(n.mode=ar,sr):(n.havedict=1,de))};var Wi=lr,Xi=dr,Yi=ur,Ji=zi,Qi=fr,eo=qi,to=Gi,no=Zi,ro=Hi,io="pako inflate (from Nodeca project)",te={inflateReset:Wi,inflateReset2:Xi,inflateResetKeep:Yi,inflateInit:Ji,inflateInit2:Qi,inflate:eo,inflateEnd:to,inflateGetHeader:no,inflateSetDictionary:ro,inflateInfo:io};function oo(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var so=oo;const pr=Object.prototype.toString,{Z_NO_FLUSH:ao,Z_FINISH:co,Z_OK:Le,Z_STREAM_END:lt,Z_NEED_DICT:dt,Z_STREAM_ERROR:uo,Z_DATA_ERROR:kn,Z_MEM_ERROR:lo}=er;function Je(r){this.options=tr.assign({chunkSize:1024*64,windowBits:15,to:""},r||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(r&&r.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ki,this.strm.avail_out=0;let e=te.inflateInit2(this.strm,t.windowBits);if(e!==Le)throw new Error(gt[e]);if(this.header=new so,te.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=mt.string2buf(t.dictionary):pr.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=te.inflateSetDictionary(this.strm,t.dictionary),e!==Le)))throw new Error(gt[e])}Je.prototype.push=function(r,t){const e=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?co:ao,pr.call(r)==="[object ArrayBuffer]"?e.input=new Uint8Array(r):e.input=r,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(n),e.next_out=0,e.avail_out=n),o=te.inflate(e,s),o===dt&&i&&(o=te.inflateSetDictionary(e,i),o===Le?o=te.inflate(e,s):o===kn&&(o=dt));e.avail_in>0&&o===lt&&e.state.wrap>0&&r[e.next_in]!==0;)te.inflateReset(e),o=te.inflate(e,s);switch(o){case uo:case kn:case dt:case lo:return this.onEnd(o),this.ended=!0,!1}if(a=e.avail_out,e.next_out&&(e.avail_out===0||o===lt))if(this.options.to==="string"){let d=mt.utf8border(e.output,e.next_out),c=e.next_out-d,u=mt.buf2string(e.output,d);e.next_out=c,e.avail_out=n-c,c&&e.output.set(e.output.subarray(d,d+c),0),this.onData(u)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(o===Le&&a===0)){if(o===lt)return o=te.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(e.avail_in===0)break}}return!0};Je.prototype.onData=function(r){this.chunks.push(r)};Je.prototype.onEnd=function(r){r===Le&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=tr.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function fo(r,t){const e=new Je(t);if(e.push(r),e.err)throw e.msg||gt[e.err];return e.result}var ho=fo,po={inflate:ho};const{inflate:wo}=po;var yo=wo,wr={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(e=!1));function i(d,c,u){this.fn=d,this.context=c,this.once=u||!1}function o(d,c,u,y,w){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new i(u,y||d,w),p=e?e+c:c;return d._events[p]?d._events[p].fn?d._events[p]=[d._events[p],f]:d._events[p].push(f):(d._events[p]=f,d._eventsCount++),d}function s(d,c){--d._eventsCount===0?d._events=new n:delete d._events[c]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var c=[],u,y;if(this._eventsCount===0)return c;for(y in u=this._events)t.call(u,y)&&c.push(e?y.slice(1):y);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},a.prototype.listeners=function(c){var u=e?e+c:c,y=this._events[u];if(!y)return[];if(y.fn)return[y.fn];for(var w=0,f=y.length,p=new Array(f);w<f;w++)p[w]=y[w].fn;return p},a.prototype.listenerCount=function(c){var u=e?e+c:c,y=this._events[u];return y?y.fn?1:y.length:0},a.prototype.emit=function(c,u,y,w,f,p){var x=e?e+c:c;if(!this._events[x])return!1;var g=this._events[x],A=arguments.length,P,E;if(g.fn){switch(g.once&&this.removeListener(c,g.fn,void 0,!0),A){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,y),!0;case 4:return g.fn.call(g.context,u,y,w),!0;case 5:return g.fn.call(g.context,u,y,w,f),!0;case 6:return g.fn.call(g.context,u,y,w,f,p),!0}for(E=1,P=new Array(A-1);E<A;E++)P[E-1]=arguments[E];g.fn.apply(g.context,P)}else{var b=g.length,T;for(E=0;E<b;E++)switch(g[E].once&&this.removeListener(c,g[E].fn,void 0,!0),A){case 1:g[E].fn.call(g[E].context);break;case 2:g[E].fn.call(g[E].context,u);break;case 3:g[E].fn.call(g[E].context,u,y);break;case 4:g[E].fn.call(g[E].context,u,y,w);break;default:if(!P)for(T=1,P=new Array(A-1);T<A;T++)P[T-1]=arguments[T];g[E].fn.apply(g[E].context,P)}}return!0},a.prototype.on=function(c,u,y){return o(this,c,u,y,!1)},a.prototype.once=function(c,u,y){return o(this,c,u,y,!0)},a.prototype.removeListener=function(c,u,y,w){var f=e?e+c:c;if(!this._events[f])return this;if(!u)return s(this,f),this;var p=this._events[f];if(p.fn)p.fn===u&&(!w||p.once)&&(!y||p.context===y)&&s(this,f);else{for(var x=0,g=[],A=p.length;x<A;x++)(p[x].fn!==u||w&&!p[x].once||y&&p[x].context!==y)&&g.push(p[x]);g.length?this._events[f]=g.length===1?g[0]:g:s(this,f)}return this},a.prototype.removeAllListeners=function(c){var u;return c?(u=e?e+c:c,this._events[u]&&s(this,u)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(wr);var go=wr.exports;const mo=m.getDefaultExportFromCjs(go);function bo(r,t){return Array.apply(0,new Array(Math.ceil(r.length/t))).map((e,n)=>r.slice(n*t,(n+1)*t))}const Ee=r=>"version"in r;function vo(r){return r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),"0x")}function _o(r){r.indexOf("0x")===0&&(r=r.substr(2)),r.length%2===1&&(r="0"+r);let t=r.match(/.{2}/g);return t===null?m.bufferPolyfillExports.Buffer.from([]):m.bufferPolyfillExports.Buffer.from(t.map(e=>parseInt(e,16)))}var Eo=Object.freeze({__proto__:null,encode:vo,decode:_o});function yr(r){return new TextDecoder("utf-8").decode(r)}function gr(r){return new TextEncoder().encode(r)}var Ao=Object.freeze({__proto__:null,decode:yr,encode:gr});function bt(r){return m.bs58.encode(r)}function xo(r){return m.bs58.decode(r)}var ko=Object.freeze({__proto__:null,encode:bt,decode:xo});function vt(r){return r.toString("base64")}function Dt(r){return m.bufferPolyfillExports.Buffer.from(r,"base64")}var So=Object.freeze({__proto__:null,encode:vt,decode:Dt}),Io=Object.freeze({__proto__:null,hex:Eo,utf8:Ao,bs58:ko,base64:So});function mr(r){const t=new Map;return r.errors&&r.errors.forEach(e=>{var n;let i=(n=e.msg)!==null&&n!==void 0?n:e.name;t.set(e.code,i)}),t}function Lo(r,...t){if(r.args.length!=t.length)throw new Error("Invalid argument length");const e={};let n=0;return r.args.forEach(i=>{e[i.name]=t[n],n+=1}),e}function br(r,t={}){r.forEach(e=>{if("accounts"in e)br(e.accounts,t[e.name]);else if(t[e.name]===void 0)throw new Error(`Invalid arguments: ${e.name} not provided.`)})}function Z(r){return r instanceof m.PublicKey?r:new m.PublicKey(r)}class To extends TypeError{constructor(t,e){let n;const{message:i,...o}=t,{path:s}=t,a=s.length===0?i:"At path: "+s.join(".")+" -- "+i;super(a),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>{var d;return(d=n)!=null?d:n=[t,...e()]}}}function Po(r){return ge(r)&&typeof r[Symbol.iterator]=="function"}function ge(r){return typeof r=="object"&&r!=null}function se(r){return typeof r=="string"?JSON.stringify(r):""+r}function Co(r){const{done:t,value:e}=r.next();return t?void 0:e}function Oo(r,t,e,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:i,branch:o}=t,{type:s}=e,{refinement:a,message:d="Expected a value of type `"+s+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+se(n)+"`"}=r;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...r,message:d}}function*Sn(r,t,e,n){Po(r)||(r=[r]);for(const i of r){const o=Oo(i,t,e,n);o&&(yield o)}}function*Ut(r,t,e){e===void 0&&(e={});const{path:n=[],branch:i=[r],coerce:o=!1,mask:s=!1}=e,a={path:n,branch:i};if(o&&(r=t.coercer(r,a),s&&t.type!=="type"&&ge(t.schema)&&ge(r)&&!Array.isArray(r)))for(const c in r)t.schema[c]===void 0&&delete r[c];let d=!0;for(const c of t.validator(r,a))d=!1,yield[c,void 0];for(let[c,u,y]of t.entries(r,a)){const w=Ut(u,y,{path:c===void 0?n:[...n,c],branch:c===void 0?i:[...i,u],coerce:o,mask:s});for(const f of w)f[0]?(d=!1,yield[f[0],void 0]):o&&(u=f[1],c===void 0?r=u:r instanceof Map?r.set(c,u):r instanceof Set?r.add(u):ge(r)&&(r[c]=u))}if(d)for(const c of t.refiner(r,a))d=!1,yield[c,void 0];d&&(yield[void 0,r])}class ae{constructor(t){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:e,schema:n,validator:i,refiner:o,coercer:s=d=>d,entries:a=function*(){}}=t;this.type=e,this.schema=n,this.entries=a,this.coercer=s,i?this.validator=(d,c)=>{const u=i(d,c);return Sn(u,c,this,d)}:this.validator=()=>[],o?this.refiner=(d,c)=>{const u=o(d,c);return Sn(u,c,this,d)}:this.refiner=()=>[]}assert(t){return Ro(t,this)}create(t){return Nt(t,this)}is(t){return vr(t,this)}mask(t){return Bo(t,this)}validate(t,e){return e===void 0&&(e={}),Pe(t,this,e)}}function Ro(r,t){const e=Pe(r,t);if(e[0])throw e[0]}function Nt(r,t){const e=Pe(r,t,{coerce:!0});if(e[0])throw e[0];return e[1]}function Bo(r,t){const e=Pe(r,t,{coerce:!0,mask:!0});if(e[0])throw e[0];return e[1]}function vr(r,t){return!Pe(r,t)[0]}function Pe(r,t,e){e===void 0&&(e={});const n=Ut(r,t,e),i=Co(n);return i[0]?[new To(i[0],function*(){for(const s of n)s[0]&&(yield s[0])}),void 0]:[void 0,i[1]]}function Ce(r,t){return new ae({type:r,schema:null,validator:t})}function Do(){return Ce("any",()=>!0)}function ft(r){return new ae({type:"array",schema:r,*entries(t){if(r&&Array.isArray(t))for(const[e,n]of t.entries())yield[e,n,r]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||"Expected an array value, but received: "+se(t)}})}function Uo(){return Ce("boolean",r=>typeof r=="boolean")}function In(r){const t=se(r);return new ae({type:"literal",schema:r,validator(e){return e===r||"Expected the literal `"+t+"`, but received: "+se(e)}})}function $e(r){return new ae({...r,validator:(t,e)=>t===null||r.validator(t,e),refiner:(t,e)=>t===null||r.refiner(t,e)})}function Ve(){return Ce("number",r=>typeof r=="number"&&!isNaN(r)||"Expected a number, but received: "+se(r))}function Fe(r){return new ae({...r,validator:(t,e)=>t===void 0||r.validator(t,e),refiner:(t,e)=>t===void 0||r.refiner(t,e)})}function ce(){return Ce("string",r=>typeof r=="string"||"Expected a string, but received: "+se(r))}function oe(r){const t=Object.keys(r);return new ae({type:"type",schema:r,*entries(e){if(ge(e))for(const n of t)yield[n,e[n],r[n]]},validator(e){return ge(e)||"Expected an object, but received: "+se(e)}})}function _r(r){const t=r.map(e=>e.type).join(" | ");return new ae({type:"union",schema:null,coercer(e,n){return(r.find(o=>{const[s]=o.validate(e,{coerce:!0});return!s})||Mt()).coercer(e,n)},validator(e,n){const i=[];for(const o of r){const[...s]=Ut(e,o,n),[a]=s;if(a[0])for(const[d]of s)d&&i.push(d);else return[]}return["Expected the value to satisfy a union of `"+t+"`, but received: "+se(e),...i]}})}function Mt(){return Ce("unknown",()=>!0)}function No(r,t,e){return new ae({...r,coercer:(n,i)=>vr(n,t)?r.coercer(e(n,i),i):r.coercer(n,i)})}async function Mo(r,t,e,n){r=Z(r),n||(n=qe());const i=new m.Transaction;if(i.add(new m.TransactionInstruction({programId:r,keys:t??[],data:e})),n.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");return await n.sendAndConfirm(i,[])}const Ln=99;async function $o(r,t,e){return(await $t(r,t,e)).map(i=>i?{publicKey:i.publicKey,account:i.account}:null)}async function $t(r,t,e){if(t.length<=Ln)return await Tn(r,t,e);{const n=bo(t,Ln);return(await Promise.all(n.map(o=>Tn(r,o,e)))).flat()}}async function Tn(r,t,e){const n=e??r.commitment,{value:i,context:o}=await r.getMultipleAccountsInfoAndContext(t,n);return i.map((a,d)=>a===null?null:{publicKey:t[d],account:a,context:o})}async function Er(r,t,e,n,i){var o;e&&e.length>0&&t.sign(...e);const s=t._compile(),a=s.serialize(),c=t._serialize(a).toString("base64"),u={encoding:"base64",commitment:n??r.commitment};if(i){const p=(Array.isArray(i)?i:s.nonProgramIds()).map(x=>x.toBase58());u.accounts={encoding:"base64",addresses:p}}e&&(u.sigVerify=!0);const y=[c,u],w=await r._rpcRequest("simulateTransaction",y),f=Nt(w,zo);if("error"in f){let p;if("data"in f.error&&(p=(o=f.error.data)===null||o===void 0?void 0:o.logs,p&&Array.isArray(p))){const x=`
2
- `,g=x+p.join(x);console.error(f.error.message,g)}throw new m.SendTransactionError("failed to simulate transaction: "+f.error.message,p)}return f.result}function jo(r){return No(Ar(r),Vo,t=>"error"in t?t:{...t,result:Nt(t.result,r)})}const Vo=Ar(Mt());function Ar(r){return _r([oe({jsonrpc:In("2.0"),id:ce(),result:r}),oe({jsonrpc:In("2.0"),id:ce(),error:oe({code:Mt(),message:ce(),data:Fe(Do())})})])}function Fo(r){return jo(oe({context:oe({slot:Ve()}),value:r}))}const zo=Fo(oe({err:$e(_r([oe({}),ce()])),logs:$e(ft(ce())),accounts:Fe($e(ft($e(oe({executable:Uo(),owner:ce(),lamports:Ve(),data:ft(ce()),rentEpoch:Fe(Ve())}))))),unitsConsumed:Fe(Ve())}));var Ko=Object.freeze({__proto__:null,invoke:Mo,getMultipleAccounts:$o,getMultipleAccountsAndContext:$t,simulateTransaction:Er});class qo{constructor(t,e,n){this.connection=t,this.wallet=e,this.opts=n,this.publicKey=e==null?void 0:e.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(t,e){throw new Error("Provider local is not available on browser.")}static env(){throw new Error("Provider env is not available on browser.")}async sendAndConfirm(t,e,n){var i,o,s,a;if(n===void 0&&(n=this.opts),Ee(t))e&&t.sign(e);else if(t.feePayer=(i=t.feePayer)!==null&&i!==void 0?i:this.wallet.publicKey,t.recentBlockhash=(await this.connection.getLatestBlockhash(n.preflightCommitment)).blockhash,e)for(const c of e)t.partialSign(c);t=await this.wallet.signTransaction(t);const d=t.serialize();try{return await Pn(this.connection,d,n)}catch(c){if(c instanceof _t){const u=bt(Ee(t)?((o=t.signatures)===null||o===void 0?void 0:o[0])||new Uint8Array:(s=t.signature)!==null&&s!==void 0?s:new Uint8Array),y=await this.connection.getTransaction(u,{commitment:"confirmed"});if(y){const w=(a=y.meta)===null||a===void 0?void 0:a.logMessages;throw w?new m.SendTransactionError(c.message,w):c}else throw c}else throw c}}async sendAll(t,e){var n,i,o;e===void 0&&(e=this.opts);const s=(await this.connection.getLatestBlockhash(e.preflightCommitment)).blockhash;let a=t.map(u=>{var y,w;if(Ee(u.tx)){let f=u.tx;return u.signers&&f.sign(u.signers),f}else{let f=u.tx,p=(y=u.signers)!==null&&y!==void 0?y:[];return f.feePayer=(w=f.feePayer)!==null&&w!==void 0?w:this.wallet.publicKey,f.recentBlockhash=s,p.forEach(x=>{f.partialSign(x)}),f}});const d=await this.wallet.signAllTransactions(a),c=[];for(let u=0;u<a.length;u+=1){const y=d[u],w=y.serialize();try{c.push(await Pn(this.connection,w,e))}catch(f){if(f instanceof _t){const p=bt(Ee(y)?((n=y.signatures)===null||n===void 0?void 0:n[0])||new Uint8Array:(i=y.signature)!==null&&i!==void 0?i:new Uint8Array),x=await this.connection.getTransaction(p,{commitment:"confirmed"});if(x){const g=(o=x.meta)===null||o===void 0?void 0:o.logMessages;throw g?new m.SendTransactionError(f.message,g):f}else throw f}else throw f}}return c}async simulate(t,e,n,i){let o=(await this.connection.getLatestBlockhash(n??this.connection.commitment)).blockhash,s;if(Ee(t)?(e&&(t.sign(e),t=await this.wallet.signTransaction(t)),s=await this.connection.simulateTransaction(t,{commitment:n})):(t.feePayer=t.feePayer||this.wallet.publicKey,t.recentBlockhash=o,e&&(t=await this.wallet.signTransaction(t)),s=await Er(this.connection,t,e,n,i)),s.value.err)throw new Go(s.value);return s.value}}class Go extends Error{constructor(t,e){super(e),this.simulationResponse=t}}async function Pn(r,t,e){const n=e&&{skipPreflight:e.skipPreflight,preflightCommitment:e.preflightCommitment||e.commitment},i=await r.sendRawTransaction(t,n),o=(await r.confirmTransaction(i,e&&e.commitment)).value;if(o.err)throw new _t(`Raw transaction ${i} failed (${JSON.stringify(o)})`);return i}class _t extends Error{constructor(t){super(t)}}function qe(){return qo.local()}const Zo=new Set(["anchor-deprecated-state","debug-logs"]),xr=new Map;function Ho(r){if(!Zo.has(r))throw new Error("Invalid feature");xr.set(r,!0)}function jt(r){return xr.get(r)!==void 0}var Wo=Object.freeze({__proto__:null,set:Ho,isSet:jt});class Ge extends Error{constructor(t){super(t),this.name="IdlError"}}class Oe{constructor(t){this.stack=t}static parse(t){var e;const n=/^Program (\w*) invoke/,i=/^Program \w* success/,o=[];for(let s=0;s<t.length;s++){if(i.exec(t[s])){o.pop();continue}const a=(e=n.exec(t[s]))===null||e===void 0?void 0:e[1];a&&o.push(new m.PublicKey(a))}return new Oe(o)}}class Se extends Error{constructor(t,e,n,i,o,s){super(n.join(`
3
- `).replace("Program log: ","")),this.errorLogs=n,this.logs=i,this.error={errorCode:t,errorMessage:e,comparedValues:s,origin:o},this._programErrorStack=Oe.parse(i)}static parse(t){if(!t)return null;const e=t.findIndex(w=>w.startsWith("Program log: AnchorError"));if(e===-1)return null;const n=t[e],i=[n];let o;if(e+1<t.length){if(t[e+1]==="Program log: Left:"){const w=/^Program log: (.*)$/,f=w.exec(t[e+2])[1],p=w.exec(t[e+4])[1];o=[new m.PublicKey(f),new m.PublicKey(p)],i.push(...t.slice(e+1,e+5))}else if(t[e+1].startsWith("Program log: Left:")){const w=/^Program log: (Left|Right): (.*)$/,f=w.exec(t[e+1])[2],p=w.exec(t[e+2])[2];i.push(...t.slice(e+1,e+3)),o=[f,p]}}const a=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),c=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n),y=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(n);if(a){const[w,f,p]=a.slice(1,4),x={code:w,number:parseInt(f)};return new Se(x,p,i,t,void 0,o)}else if(c){const[w,f,p,x,g]=c.slice(1,6),A={code:p,number:parseInt(x)},P={file:w,line:parseInt(f)};return new Se(A,g,i,t,P,o)}else if(y){const[w,f,p,x]=y.slice(1,5),g=w,A={code:f,number:parseInt(p)};return new Se(A,x,i,t,g,o)}else return null}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}}class Ze extends Error{constructor(t,e,n){super(),this.code=t,this.msg=e,this.logs=n,n&&(this._programErrorStack=Oe.parse(n))}static parse(t,e){const n=t.toString();let i;if(n.includes("custom program error:")){let a=n.split("custom program error: ");if(a.length!==2)return null;i=a[1]}else{const a=n.match(/"Custom":([0-9]+)}/g);if(!a||a.length>1)return null;i=a[0].match(/([0-9]+)/g)[0]}let o;try{o=parseInt(i)}catch{return null}let s=e.get(o);return s!==void 0?new Ze(o,s,t.logs):(s=Xo.get(o),s!==void 0?new Ze(o,s,t.logs):null)}get program(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var t;return(t=this._programErrorStack)===null||t===void 0?void 0:t.stack}toString(){return this.msg}}function Vt(r,t){jt("debug-logs")&&console.log("Translating error:",r);const e=Se.parse(r.logs);if(e)return e;const n=Ze.parse(r,t);if(n)return n;if(r.logs){const i={get:function(o,s){return s==="programErrorStack"?o.programErrorStack.stack:s==="program"?o.programErrorStack.stack[r.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return r.programErrorStack=Oe.parse(r.logs),new Proxy(r,i)}return r}const L={InstructionMissing:100,InstructionFallbackNotFound:101,InstructionDidNotDeserialize:102,InstructionDidNotSerialize:103,IdlInstructionStub:1e3,IdlInstructionInvalidProgram:1001,ConstraintMut:2e3,ConstraintHasOne:2001,ConstraintSigner:2002,ConstraintRaw:2003,ConstraintOwner:2004,ConstraintRentExempt:2005,ConstraintSeeds:2006,ConstraintExecutable:2007,ConstraintState:2008,ConstraintAssociated:2009,ConstraintAssociatedInit:2010,ConstraintClose:2011,ConstraintAddress:2012,ConstraintZero:2013,ConstraintTokenMint:2014,ConstraintTokenOwner:2015,ConstraintMintMintAuthority:2016,ConstraintMintFreezeAuthority:2017,ConstraintMintDecimals:2018,ConstraintSpace:2019,ConstraintAccountIsNone:2020,RequireViolated:2500,RequireEqViolated:2501,RequireKeysEqViolated:2502,RequireNeqViolated:2503,RequireKeysNeqViolated:2504,RequireGtViolated:2505,RequireGteViolated:2506,AccountDiscriminatorAlreadySet:3e3,AccountDiscriminatorNotFound:3001,AccountDiscriminatorMismatch:3002,AccountDidNotDeserialize:3003,AccountDidNotSerialize:3004,AccountNotEnoughKeys:3005,AccountNotMutable:3006,AccountOwnedByWrongProgram:3007,InvalidProgramId:3008,InvalidProgramExecutable:3009,AccountNotSigner:3010,AccountNotSystemOwned:3011,AccountNotInitialized:3012,AccountNotProgramData:3013,AccountNotAssociatedTokenAccount:3014,AccountSysvarMismatch:3015,AccountReallocExceedsLimit:3016,AccountDuplicateReallocs:3017,DeclaredProgramIdMismatch:4100,Deprecated:5e3},Xo=new Map([[L.InstructionMissing,"8 byte instruction identifier not provided"],[L.InstructionFallbackNotFound,"Fallback functions are not supported"],[L.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[L.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[L.IdlInstructionStub,"The program was compiled without idl instructions"],[L.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[L.ConstraintMut,"A mut constraint was violated"],[L.ConstraintHasOne,"A has one constraint was violated"],[L.ConstraintSigner,"A signer constraint was violated"],[L.ConstraintRaw,"A raw constraint was violated"],[L.ConstraintOwner,"An owner constraint was violated"],[L.ConstraintRentExempt,"A rent exemption constraint was violated"],[L.ConstraintSeeds,"A seeds constraint was violated"],[L.ConstraintExecutable,"An executable constraint was violated"],[L.ConstraintState,"Deprecated Error, feel free to replace with something else"],[L.ConstraintAssociated,"An associated constraint was violated"],[L.ConstraintAssociatedInit,"An associated init constraint was violated"],[L.ConstraintClose,"A close constraint was violated"],[L.ConstraintAddress,"An address constraint was violated"],[L.ConstraintZero,"Expected zero account discriminant"],[L.ConstraintTokenMint,"A token mint constraint was violated"],[L.ConstraintTokenOwner,"A token owner constraint was violated"],[L.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[L.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[L.ConstraintMintDecimals,"A mint decimals constraint was violated"],[L.ConstraintSpace,"A space constraint was violated"],[L.ConstraintAccountIsNone,"A required account for the constraint is None"],[L.RequireViolated,"A require expression was violated"],[L.RequireEqViolated,"A require_eq expression was violated"],[L.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[L.RequireNeqViolated,"A require_neq expression was violated"],[L.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[L.RequireGtViolated,"A require_gt expression was violated"],[L.RequireGteViolated,"A require_gte expression was violated"],[L.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[L.AccountDiscriminatorNotFound,"No 8 byte discriminator was found on the account"],[L.AccountDiscriminatorMismatch,"8 byte discriminator did not match what was expected"],[L.AccountDidNotDeserialize,"Failed to deserialize the account"],[L.AccountDidNotSerialize,"Failed to serialize the account"],[L.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[L.AccountNotMutable,"The given account is not mutable"],[L.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[L.InvalidProgramId,"Program ID was not as expected"],[L.InvalidProgramExecutable,"Program account is not executable"],[L.AccountNotSigner,"The given account did not sign"],[L.AccountNotSystemOwned,"The given account is not owned by the system program"],[L.AccountNotInitialized,"The program expected this account to be already initialized"],[L.AccountNotProgramData,"The given account is not a program data account"],[L.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[L.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[L.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[L.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[L.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[L.Deprecated,"The API being used is deprecated and should no longer be used"]]);var Et=function(){return Et=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},Et.apply(this,arguments)},At=function(){return At=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},At.apply(this,arguments)};function Yo(r){return r.toLowerCase()}var Jo=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],Qo=/[^A-Z0-9]+/gi;function es(r,t){t===void 0&&(t={});for(var e=t.splitRegexp,n=e===void 0?Jo:e,i=t.stripRegexp,o=i===void 0?Qo:i,s=t.transform,a=s===void 0?Yo:s,d=t.delimiter,c=d===void 0?" ":d,u=Cn(Cn(r,n,"$1\0$2"),o,"\0"),y=0,w=u.length;u.charAt(y)==="\0";)y++;for(;u.charAt(w-1)==="\0";)w--;return u.slice(y,w).split("\0").map(a).join(c)}function Cn(r,t,e){return t instanceof RegExp?r.replace(t,e):t.reduce(function(n,i){return n.replace(i,e)},r)}function ts(r,t){return t===void 0&&(t={}),es(r,At({delimiter:"."},t))}function ns(r,t){return t===void 0&&(t={}),ts(r,Et({delimiter:"_"},t))}class K{static fieldLayout(t,e){const n=t.name!==void 0?V(t.name):void 0;switch(t.type){case"bool":return R.bool(n);case"u8":return R.u8(n);case"i8":return R.i8(n);case"u16":return R.u16(n);case"i16":return R.i16(n);case"u32":return R.u32(n);case"i32":return R.i32(n);case"f32":return R.f32(n);case"u64":return R.u64(n);case"i64":return R.i64(n);case"f64":return R.f64(n);case"u128":return R.u128(n);case"i128":return R.i128(n);case"u256":return R.u256(n);case"i256":return R.i256(n);case"bytes":return R.vecU8(n);case"string":return R.str(n);case"publicKey":return R.publicKey(n);default:{if("vec"in t.type)return R.vec(K.fieldLayout({name:void 0,type:t.type.vec},e),n);if("option"in t.type)return R.option(K.fieldLayout({name:void 0,type:t.type.option},e),n);if("defined"in t.type){if(!e)throw new Ge("User defined types not provided");const i=t.type.defined,o=e.filter(s=>s.name===i);if(o.length!==1)throw new Ge(`Type not found: ${JSON.stringify(t)}`);return K.typeDefLayout(o[0],e,n)}else if("array"in t.type){let i=t.type.array[0],o=t.type.array[1],s=K.fieldLayout({name:void 0,type:i},e);return R.array(s,o,n)}else throw new Error(`Not yet implemented: ${t}`)}}}static typeDefLayout(t,e=[],n){switch(t.type.kind){case"struct":{const i=t.type.fields.map(o=>K.fieldLayout(o,e));return R.struct(i,n)}case"enum":{let i=t.type.variants.map(o=>{const s=V(o.name);if(!o.fields)return R.struct([],s);const a=o.fields.map((d,c)=>d!=null&&d.name?K.fieldLayout(d,e):K.fieldLayout({type:d,name:c.toString()},e));return R.struct(a,s)});return n!==void 0?R.rustEnum(i).replicate(n):R.rustEnum(i,n)}case"alias":return K.fieldLayout({type:t.type.value,name:t.name},e)}}}const On="global";class Ft{constructor(t){this.idl=t,this.ixLayout=Ft.parseIxLayout(t);const e=new Map;t.instructions.forEach(n=>{const i=Rn(On,n.name);e.set(m.bs58.encode(i),{layout:this.ixLayout.get(n.name),name:n.name})}),this.sighashLayouts=e}encode(t,e){return this._encode(On,t,e)}_encode(t,e,n){const i=m.bufferPolyfillExports.Buffer.alloc(1e3),o=V(e),s=this.ixLayout.get(o);if(!s)throw new Error(`Unknown method: ${o}`);const a=s.encode(n,i),d=i.slice(0,a);return m.bufferPolyfillExports.Buffer.concat([Rn(t,e),d])}static parseIxLayout(t){const e=t.instructions.map(n=>{let i=n.args.map(s=>{var a,d;return K.fieldLayout(s,Array.from([...(a=t.accounts)!==null&&a!==void 0?a:[],...(d=t.types)!==null&&d!==void 0?d:[]]))});const o=V(n.name);return[o,R.struct(i,o)]});return new Map(e)}decode(t,e="hex"){typeof t=="string"&&(t=e==="hex"?m.bufferPolyfillExports.Buffer.from(t,"hex"):m.bs58.decode(t));let n=m.bs58.encode(t.slice(0,8)),i=t.slice(8);const o=this.sighashLayouts.get(n);return o?{data:o.layout.decode(i),name:o.name}:null}format(t,e){return J.format(t,e,this.idl)}}class J{static format(t,e,n){const i=n.instructions.filter(d=>t.name===d.name)[0];if(i===void 0)return console.error("Invalid instruction given"),null;const o=i.args.map(d=>({name:d.name,type:J.formatIdlType(d.type),data:J.formatIdlData(d,t.data[d.name],n.types)})),s=J.flattenIdlAccounts(i.accounts),a=e.map((d,c)=>c<s.length?{name:s[c].name,...d}:{name:void 0,...d});return{args:o,accounts:a}}static formatIdlType(t){if(typeof t=="string")return t;if("vec"in t)return`Vec<${this.formatIdlType(t.vec)}>`;if("option"in t)return`Option<${this.formatIdlType(t.option)}>`;if("defined"in t)return t.defined;if("array"in t)return`Array<${t.array[0]}; ${t.array[1]}>`;throw new Error(`Unknown IDL type: ${t}`)}static formatIdlData(t,e,n){if(typeof t.type=="string")return e.toString();if(t.type.hasOwnProperty("vec"))return"["+e.map(i=>this.formatIdlData({name:"",type:t.type.vec},i)).join(", ")+"]";if(t.type.hasOwnProperty("option"))return e===null?"null":this.formatIdlData({name:"",type:t.type.option},e,n);if(t.type.hasOwnProperty("defined")){if(n===void 0)throw new Error("User defined types not provided");const i=n.filter(o=>o.name===t.type.defined);if(i.length!==1)throw new Error(`Type not found: ${t.type.defined}`);return J.formatIdlDataDefined(i[0],e,n)}return"unknown"}static formatIdlDataDefined(t,e,n){switch(t.type.kind){case"struct":{const i=t.type;return"{ "+Object.keys(e).map(s=>{const a=i.fields.find(d=>d.name===s);if(!a)throw new Error("Unable to find type");return s+": "+J.formatIdlData(a,e[s],n)}).join(", ")+" }"}case"enum":{if(t.type.variants.length===0)return"{}";if(t.type.variants[0].name){const i=t.type.variants,o=Object.keys(e)[0],s=e[o],a=Object.keys(s).map(c=>{var u;const y=s[c],w=(u=i[o])===null||u===void 0?void 0:u.find(f=>f.name===c);if(!w)throw new Error("Unable to find variant");return c+": "+J.formatIdlData(w,y,n)}).join(", "),d=V(o,{pascalCase:!0});return a.length===0?d:`${d} { ${a} }`}else return"Tuple formatting not yet implemented"}case"alias":return J.formatIdlType(t.type.value)}}static flattenIdlAccounts(t,e){return t.map(n=>{const i=rs(n.name);if(n.hasOwnProperty("accounts")){const o=e?`${e} > ${i}`:i;return J.flattenIdlAccounts(n.accounts,o)}else return{...n,name:e?`${e} > ${i}`:i}}).flat()}}function rs(r){const t=r.replace(/([A-Z])/g," $1");return t.charAt(0).toUpperCase()+t.slice(1)}function Rn(r,t){let e=ns(t),n=`${r}:${e}`;return m.bufferPolyfillExports.Buffer.from(m.sha256(n).slice(0,8))}function kr(r,t){switch(t.type.kind){case"struct":return t.type.fields.map(e=>ue(r,e.type)).reduce((e,n)=>e+n,0);case"enum":{const e=t.type.variants.map(n=>n.fields?n.fields.map(i=>typeof i=="object"&&"name"in i?ue(r,i.type):ue(r,i)).reduce((i,o)=>i+o,0):0);return Math.max(...e)+1}case"alias":return ue(r,t.type.value)}}function ue(r,t){var e,n;switch(t){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"publicKey":return 32;default:if("vec"in t)return 1;if("option"in t)return 1+ue(r,t.option);if("coption"in t)return 4+ue(r,t.coption);if("defined"in t){const i=(n=(e=r.types)===null||e===void 0?void 0:e.filter(s=>s.name===t.defined))!==null&&n!==void 0?n:[];if(i.length!==1)throw new Ge(`Type not found: ${JSON.stringify(t)}`);let o=i[0];return kr(r,o)}if("array"in t){let i=t.array[0],o=t.array[1];return ue(r,i)*o}throw new Error(`Invalid type ${JSON.stringify(t)}`)}}const xt=8;function Sr(r){return m.dist.Buffer.from(m.sha256(r).slice(0,xt))}class ye{constructor(t){if(t.accounts===void 0){this.accountLayouts=new Map;return}const e=t.accounts.map(n=>[n.name,K.typeDefLayout(n,t.types)]);this.accountLayouts=new Map(e),this.idl=t}async encode(t,e){const n=m.bufferPolyfillExports.Buffer.alloc(1e3),i=this.accountLayouts.get(t);if(!i)throw new Error(`Unknown account: ${t}`);const o=i.encode(e,n);let s=n.slice(0,o),a=ye.accountDiscriminator(t);return m.bufferPolyfillExports.Buffer.concat([a,s])}decode(t,e){if(ye.accountDiscriminator(t).compare(e.slice(0,8)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(t,e)}decodeAny(t){const e=t.slice(0,8),n=Array.from(this.accountLayouts.keys()).find(i=>ye.accountDiscriminator(i).equals(e));if(!n)throw new Error("Account descriminator not found");return this.decodeUnchecked(n,t)}decodeUnchecked(t,e){const n=e.subarray(xt),i=this.accountLayouts.get(t);if(!i)throw new Error(`Unknown account: ${t}`);return i.decode(n)}memcmp(t,e){const n=ye.accountDiscriminator(t);return{offset:0,bytes:m.bs58.encode(e?m.bufferPolyfillExports.Buffer.concat([n,e]):n)}}size(t){var e;return xt+((e=kr(this.idl,t))!==null&&e!==void 0?e:0)}static accountDiscriminator(t){const e=`account:${V(t,{pascalCase:!0,preserveConsecutiveUppercase:!0})}`;return Sr(e)}}class is{constructor(t){if(t.events===void 0){this.layouts=new Map;return}const e=t.events.map(n=>{let i={name:n.name,type:{kind:"struct",fields:n.fields.map(o=>({name:o.name,type:o.type}))}};return[n.name,K.typeDefLayout(i,t.types)]});this.layouts=new Map(e),this.discriminators=new Map(t.events===void 0?[]:t.events.map(n=>[vt(os(n.name)),n.name]))}decode(t){let e;try{e=Dt(t)}catch{return null}const n=vt(e.slice(0,8)),i=this.discriminators.get(n);if(i===void 0)return null;const o=this.layouts.get(i);if(!o)throw new Error(`Unknown event: ${i}`);return{data:o.decode(e.slice(8)),name:i}}}function os(r){return Sr(`event:${r}`)}class ss{constructor(t){if(t.types===void 0){this.typeLayouts=new Map;return}const e=t.types.map(n=>[n.name,K.typeDefLayout(n,t.types)]);this.typeLayouts=new Map(e),this.idl=t}encode(t,e){const n=m.bufferPolyfillExports.Buffer.alloc(1e3),i=this.typeLayouts.get(t);if(!i)throw new Error(`Unknown type: ${t}`);const o=i.encode(e,n);return n.slice(0,o)}decode(t,e){const n=this.typeLayouts.get(t);if(!n)throw new Error(`Unknown type: ${t}`);return n.decode(e)}}class Ir{constructor(t){this.instruction=new Ft(t),this.accounts=new ye(t),this.events=new is(t),this.types=new ss(t)}}var as=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof m.dist.global<"u"?m.dist.global:typeof self<"u"?self:{};function cs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}class G{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,n){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}var Qe=G;function us(r,t){return t.property?r+"["+t.property+"]":r}class le extends G{isCount(){throw new Error("ExternalLayout is abstract")}}class Lr extends le{constructor(t,e,n){if(!(t instanceof G))throw new TypeError("layout must be a Layout");if(e===void 0)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof et||this.layout instanceof Tr}decode(t,e){return e===void 0&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,n){return n===void 0&&(n=0),this.layout.encode(t,e,n+this.offset)}}class et extends G{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,n){return n===void 0&&(n=0),e.writeUIntLE(t,n,this.span),this.span}}class Tr extends G{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return e===void 0&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,n){return n===void 0&&(n=0),e.writeUIntBE(t,n,this.span),this.span}}const kt=Math.pow(2,32);function Pr(r){const t=Math.floor(r/kt),e=r-t*kt;return{hi32:t,lo32:e}}function Cr(r,t){return r*kt+t}class ls extends G{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const n=t.readUInt32LE(e),i=t.readUInt32LE(e+4);return Cr(i,n)}encode(t,e,n){n===void 0&&(n=0);const i=Pr(t);return e.writeUInt32LE(i.lo32,n),e.writeUInt32LE(i.hi32,n+4),8}}class ds extends G{constructor(t){super(8,t)}decode(t,e){e===void 0&&(e=0);const n=t.readUInt32LE(e),i=t.readInt32LE(e+4);return Cr(i,n)}encode(t,e,n){n===void 0&&(n=0);const i=Pr(t);return e.writeUInt32LE(i.lo32,n),e.writeInt32LE(i.hi32,n+4),8}}class fs extends G{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((o,s)=>o&&s instanceof G,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&n===void 0&&(n=e,e=void 0);for(const o of t)if(0>o.span&&o.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((o,s)=>o+s.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let n=0;try{n=this.fields.reduce((i,o)=>{const s=o.getSpan(t,e);return e+=s,i+s},0)}catch{throw new RangeError("indeterminate span")}return n}decode(t,e){e===void 0&&(e=0);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n){n===void 0&&(n=0);const i=n;let o=0,s=0;for(const a of this.fields){let d=a.span;if(s=0<d?d:0,a.property!==void 0){const c=t[a.property];c!==void 0&&(s=a.encode(c,e,n),0>d&&(d=a.getSpan(e,n)))}o=n,n+=d}return o+s-i}fromArray(t){const e=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}}class Or{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class Bn extends Or{constructor(t,e){if(!(t instanceof le&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,n){return this.layout.encode(t,e,n)}}class Rr extends G{constructor(t,e,n){const i=t instanceof et||t instanceof Tr;if(i)t=new Bn(new Lr(t));else if(t instanceof le&&t.isCount())t=new Bn(t);else if(!(t instanceof Or))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof G))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let o=-1;e&&(o=e.span,0<=o&&i&&(o+=t.layout.span)),super(o,n),this.discriminator=t,this.usesPrefixDiscriminator=i,this.defaultLayout=e,this.registry={};let s=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return s(a)},this.configGetSourceVariant=function(a){s=a.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);const n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const n=this.registry[e];if(t.hasOwnProperty(n.property))return n}throw new Error("unable to infer src variant")}decode(t,e){e===void 0&&(e=0);let n;const i=this.discriminator,o=i.decode(t,e);let s=this.registry[o];if(s===void 0){let a=0;s=this.defaultLayout,this.usesPrefixDiscriminator&&(a=i.layout.span),n=this.makeDestinationObject(),n[i.property]=o,n[s.property]=this.defaultLayout.decode(t,e+a)}else n=s.decode(t,e);return n}encode(t,e,n){n===void 0&&(n=0);const i=this.getSourceVariant(t);if(i===void 0){const o=this.discriminator,s=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=o.layout.span),o.encode(t[o.property],e,n),a+s.encode(t[s.property],e,n+a)}return i.encode(t,e,n)}addVariant(t,e,n){const i=new hs(this,t,e,n);return this.registry[t]=i,i}getVariant(t,e){let n=t;return m.dist.Buffer.isBuffer(t)&&(e===void 0&&(e=0),n=this.discriminator.decode(t,e)),this.registry[n]}}class hs extends G{constructor(t,e,n,i){if(!(t instanceof Rr))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof G))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let o=t.span;0>t.span&&(o=n?n.span:0,0<=o&&t.usesPrefixDiscriminator&&(o+=t.discriminator.layout.span)),super(o,i),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e){if(0<=this.span)return this.span;e===void 0&&(e=0);let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),n+this.layout.getSpan(t,e+n)}decode(t,e){const n=this.makeDestinationObject();if(e===void 0&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n){n===void 0&&(n=0);let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);let o=i;if(this.layout&&(this.layout.encode(t[this.property],e,n+i),o+=this.layout.getSpan(e,n+i),0<=this.union.span&&o>this.union.span))throw new Error("encoded variant overruns containing union");return o}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}class ps extends G{constructor(t,e){if(!(t instanceof le&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof le||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e){e===void 0&&(e=0);let n=this.span;return 0>n&&(n=this.length.decode(t,e)),t.slice(e,e+n)}encode(t,e,n){let i=this.length;if(this.length instanceof le&&(i=t.length),!(m.dist.Buffer.isBuffer(t)&&i===t.length))throw new TypeError(us("Blob.encode",this)+" requires (length "+i+") Buffer as src");if(n+i>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),n,i,"hex"),this.length instanceof le&&this.length.encode(i,e,n),i}}var ws=(r,t,e)=>new Lr(r,t,e),ys=r=>new et(1,r),ne=r=>new et(4,r),gs=r=>new ls(r),re=r=>new ds(r),z=(r,t,e)=>new fs(r,t,e),Br=(r,t,e)=>new Rr(r,t,e),Re=(r,t)=>new ps(r,t);class ms extends Qe{constructor(t){super(-1,t),this.property=t,this.layout=z([ne("length"),ne("lengthPadding"),Re(ws(ne(),-8),"chars")],this.property)}encode(t,e,n=0){if(t==null)return this.layout.span;const i={chars:m.dist.Buffer.from(t,"utf8")};return this.layout.encode(i,e,n)}decode(t,e=0){return this.layout.decode(t,e).chars.toString()}getSpan(t,e=0){return ne().span+ne().span+new m.BN(new Uint8Array(t).slice(e,e+4),10,"le").toNumber()}}function tt(r){return new ms(r)}function X(r){return Re(32,r)}const H=Br(ne("instruction"));H.addVariant(0,z([re("lamports"),re("space"),X("owner")]),"createAccount");H.addVariant(1,z([X("owner")]),"assign");H.addVariant(2,z([re("lamports")]),"transfer");H.addVariant(3,z([X("base"),tt("seed"),re("lamports"),re("space"),X("owner")]),"createAccountWithSeed");H.addVariant(4,z([X("authorized")]),"advanceNonceAccount");H.addVariant(5,z([re("lamports")]),"withdrawNonceAccount");H.addVariant(6,z([X("authorized")]),"initializeNonceAccount");H.addVariant(7,z([X("authorized")]),"authorizeNonceAccount");H.addVariant(8,z([re("space")]),"allocate");H.addVariant(9,z([X("base"),tt("seed"),re("space"),X("owner")]),"allocateWithSeed");H.addVariant(10,z([X("base"),tt("seed"),X("owner")]),"assignWithSeed");H.addVariant(11,z([re("lamports"),tt("seed"),X("owner")]),"transferWithSeed");Math.max(...Object.values(H.registry).map(r=>r.span));class bs extends Qe{constructor(t,e,n,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=n}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,n){return this.layout.encode(this.encoder(t),e,n)}getSpan(t,e){return this.layout.getSpan(t,e)}}function Dn(r){return new bs(Re(32),t=>new m.PublicKey(t),t=>t.toBuffer(),r)}z([ne("version"),ne("state"),Dn("authorizedPubkey"),Dn("nonce"),z([gs("lamportsPerSignature")],"feeCalculator")]);function vs(r){return new TextDecoder().decode(m.sha256(r))}var _s=Object.freeze({__proto__:null,hash:vs});function Es(r,t,e){const n=m.bufferPolyfillExports.Buffer.concat([r.toBuffer(),m.bufferPolyfillExports.Buffer.from(t),e.toBuffer()]);return new m.PublicKey(m.sha256(n))}function Dr(r,...t){let e=[m.bufferPolyfillExports.Buffer.from([97,110,99,104,111,114])];t.forEach(i=>{e.push(i instanceof m.bufferPolyfillExports.Buffer?i:Z(i).toBuffer())});const[n]=m.PublicKey.findProgramAddressSync(e,Z(r));return n}var As=Object.freeze({__proto__:null,createWithSeedSync:Es,associated:Dr});const zt=new m.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),Kt=new m.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");function xs({mint:r,owner:t}){return m.PublicKey.findProgramAddressSync([t.toBuffer(),zt.toBuffer(),r.toBuffer()],Kt)[0]}var ks=Object.freeze({__proto__:null,TOKEN_PROGRAM_ID:zt,ASSOCIATED_PROGRAM_ID:Kt,associatedAddress:xs}),St={exports:{}};(function(r,t){var e=typeof self<"u"?self:as,n=function(){function o(){this.fetch=!1,this.DOMException=e.DOMException}return o.prototype=e,new o}();(function(o){(function(s){var a={searchParams:"URLSearchParams"in o,iterable:"Symbol"in o&&"iterator"in Symbol,blob:"FileReader"in o&&"Blob"in o&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in o,arrayBuffer:"ArrayBuffer"in o};function d(l){return l&&DataView.prototype.isPrototypeOf(l)}if(a.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(l){return l&&c.indexOf(Object.prototype.toString.call(l))>-1};function y(l){if(typeof l!="string"&&(l=String(l)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(l))throw new TypeError("Invalid character in header field name");return l.toLowerCase()}function w(l){return typeof l!="string"&&(l=String(l)),l}function f(l){var h={next:function(){var k=l.shift();return{done:k===void 0,value:k}}};return a.iterable&&(h[Symbol.iterator]=function(){return h}),h}function p(l){this.map={},l instanceof p?l.forEach(function(h,k){this.append(k,h)},this):Array.isArray(l)?l.forEach(function(h){this.append(h[0],h[1])},this):l&&Object.getOwnPropertyNames(l).forEach(function(h){this.append(h,l[h])},this)}p.prototype.append=function(l,h){l=y(l),h=w(h);var k=this.map[l];this.map[l]=k?k+", "+h:h},p.prototype.delete=function(l){delete this.map[y(l)]},p.prototype.get=function(l){return l=y(l),this.has(l)?this.map[l]:null},p.prototype.has=function(l){return this.map.hasOwnProperty(y(l))},p.prototype.set=function(l,h){this.map[y(l)]=w(h)},p.prototype.forEach=function(l,h){for(var k in this.map)this.map.hasOwnProperty(k)&&l.call(h,this.map[k],k,this)},p.prototype.keys=function(){var l=[];return this.forEach(function(h,k){l.push(k)}),f(l)},p.prototype.values=function(){var l=[];return this.forEach(function(h){l.push(h)}),f(l)},p.prototype.entries=function(){var l=[];return this.forEach(function(h,k){l.push([k,h])}),f(l)},a.iterable&&(p.prototype[Symbol.iterator]=p.prototype.entries);function x(l){if(l.bodyUsed)return Promise.reject(new TypeError("Already read"));l.bodyUsed=!0}function g(l){return new Promise(function(h,k){l.onload=function(){h(l.result)},l.onerror=function(){k(l.error)}})}function A(l){var h=new FileReader,k=g(h);return h.readAsArrayBuffer(l),k}function P(l){var h=new FileReader,k=g(h);return h.readAsText(l),k}function E(l){for(var h=new Uint8Array(l),k=new Array(h.length),U=0;U<h.length;U++)k[U]=String.fromCharCode(h[U]);return k.join("")}function b(l){if(l.slice)return l.slice(0);var h=new Uint8Array(l.byteLength);return h.set(new Uint8Array(l)),h.buffer}function T(){return this.bodyUsed=!1,this._initBody=function(l){this._bodyInit=l,l?typeof l=="string"?this._bodyText=l:a.blob&&Blob.prototype.isPrototypeOf(l)?this._bodyBlob=l:a.formData&&FormData.prototype.isPrototypeOf(l)?this._bodyFormData=l:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)?this._bodyText=l.toString():a.arrayBuffer&&a.blob&&d(l)?(this._bodyArrayBuffer=b(l.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(l)||u(l))?this._bodyArrayBuffer=b(l):this._bodyText=l=Object.prototype.toString.call(l):this._bodyText="",this.headers.get("content-type")||(typeof l=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var l=x(this);if(l)return l;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?x(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(A)}),this.text=function(){var l=x(this);if(l)return l;if(this._bodyBlob)return P(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(E(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(B)}),this.json=function(){return this.text().then(JSON.parse)},this}var $=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function I(l){var h=l.toUpperCase();return $.indexOf(h)>-1?h:l}function D(l,h){h=h||{};var k=h.body;if(l instanceof D){if(l.bodyUsed)throw new TypeError("Already read");this.url=l.url,this.credentials=l.credentials,h.headers||(this.headers=new p(l.headers)),this.method=l.method,this.mode=l.mode,this.signal=l.signal,!k&&l._bodyInit!=null&&(k=l._bodyInit,l.bodyUsed=!0)}else this.url=String(l);if(this.credentials=h.credentials||this.credentials||"same-origin",(h.headers||!this.headers)&&(this.headers=new p(h.headers)),this.method=I(h.method||this.method||"GET"),this.mode=h.mode||this.mode||null,this.signal=h.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&k)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(k)}D.prototype.clone=function(){return new D(this,{body:this._bodyInit})};function B(l){var h=new FormData;return l.trim().split("&").forEach(function(k){if(k){var U=k.split("="),F=U.shift().replace(/\+/g," "),M=U.join("=").replace(/\+/g," ");h.append(decodeURIComponent(F),decodeURIComponent(M))}}),h}function O(l){var h=new p,k=l.replace(/\r?\n[\t ]+/g," ");return k.split(/\r?\n/).forEach(function(U){var F=U.split(":"),M=F.shift().trim();if(M){var Be=F.join(":").trim();h.append(M,Be)}}),h}T.call(D.prototype);function C(l,h){h||(h={}),this.type="default",this.status=h.status===void 0?200:h.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in h?h.statusText:"OK",this.headers=new p(h.headers),this.url=h.url||"",this._initBody(l)}T.call(C.prototype),C.prototype.clone=function(){return new C(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},C.error=function(){var l=new C(null,{status:0,statusText:""});return l.type="error",l};var S=[301,302,303,307,308];C.redirect=function(l,h){if(S.indexOf(h)===-1)throw new RangeError("Invalid status code");return new C(null,{status:h,headers:{location:l}})},s.DOMException=o.DOMException;try{new s.DOMException}catch{s.DOMException=function(h,k){this.message=h,this.name=k;var U=Error(h);this.stack=U.stack},s.DOMException.prototype=Object.create(Error.prototype),s.DOMException.prototype.constructor=s.DOMException}function v(l,h){return new Promise(function(k,U){var F=new D(l,h);if(F.signal&&F.signal.aborted)return U(new s.DOMException("Aborted","AbortError"));var M=new XMLHttpRequest;function Be(){M.abort()}M.onload=function(){var _e={status:M.status,statusText:M.statusText,headers:O(M.getAllResponseHeaders()||"")};_e.url="responseURL"in M?M.responseURL:_e.headers.get("X-Request-URL");var rt="response"in M?M.response:M.responseText;k(new C(rt,_e))},M.onerror=function(){U(new TypeError("Network request failed"))},M.ontimeout=function(){U(new TypeError("Network request failed"))},M.onabort=function(){U(new s.DOMException("Aborted","AbortError"))},M.open(F.method,F.url,!0),F.credentials==="include"?M.withCredentials=!0:F.credentials==="omit"&&(M.withCredentials=!1),"responseType"in M&&a.blob&&(M.responseType="blob"),F.headers.forEach(function(_e,rt){M.setRequestHeader(rt,_e)}),F.signal&&(F.signal.addEventListener("abort",Be),M.onreadystatechange=function(){M.readyState===4&&F.signal.removeEventListener("abort",Be)}),M.send(typeof F._bodyInit>"u"?null:F._bodyInit)})}return v.polyfill=!0,o.fetch||(o.fetch=v,o.Headers=p,o.Request=D,o.Response=C),s.Headers=p,s.Request=D,s.Response=C,s.fetch=v,Object.defineProperty(s,"__esModule",{value:!0}),s})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;t=i.fetch,t.default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,r.exports=t})(St,St.exports);var Ss=cs(St.exports);async function Is(r,t,e=5){const n=`https://api.apr.dev/api/v0/program/${t.toString()}/latest?limit=${e}`,[i,o]=await Promise.all([Ur(r,t),Ss(n)]),s=(await o.json()).filter(d=>!d.aborted&&d.state==="Built"&&d.verified==="Verified");if(s.length===0)return null;const a=s[0];return i.slot.toNumber()!==a.verified_slot?null:a}async function Ur(r,t){const e=await r.getAccountInfo(t);if(e===null)throw new Error("program account not found");const{program:n}=It(e.data),i=await r.getAccountInfo(n.programdataAddress);if(i===null)throw new Error("program data account not found");const{programData:o}=It(i.data);return o}const Ls=R.rustEnum([R.struct([],"uninitialized"),R.struct([R.option(R.publicKey(),"authorityAddress")],"buffer"),R.struct([R.publicKey("programdataAddress")],"program"),R.struct([R.u64("slot"),R.option(R.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,R.u32());function It(r){return Ls.decode(r)}var Ts=Object.freeze({__proto__:null,verifiedBuild:Is,fetchData:Ur,decodeUpgradeableLoaderState:It}),Ps=Object.freeze({__proto__:null,sha256:_s,rpc:Ko,publicKey:As,bytes:Io,token:ks,features:Wo,registry:Ts});function Cs(r){return"accounts"in r}async function Os(r){const t=(await m.PublicKey.findProgramAddress([],r))[0];return await m.PublicKey.createWithSeed(t,Rs(),r)}function Rs(){return"anchor:idl"}const Bs=R.struct([R.publicKey("authority"),R.vecU8("data")]);function Ds(r){return Bs.decode(r)}function nt(r,t){var e,n;let i={};const o=r.args?r.args.length:0;if(t.length>o){if(t.length!==o+1)throw new Error(`provided too many arguments ${t} to instruction ${r==null?void 0:r.name} expecting: ${(n=(e=r.args)===null||e===void 0?void 0:e.map(s=>s.name))!==null&&n!==void 0?n:[]}`);i=t.pop()}return[t,i]}class He{static build(t,e,n){if(t.name==="_inner")throw new Ge("the _inner name is reserved");const i=(...o)=>{const[s,a]=nt(t,[...o]);br(t.accounts,a.accounts),Us(t,...o);const d=i.accounts(a.accounts);return a.remainingAccounts!==void 0&&d.push(...a.remainingAccounts),jt("debug-logs")&&console.log("Outgoing account metas:",d),new m.TransactionInstruction({keys:d,programId:n,data:e(t.name,Lo(t,...s))})};return i.accounts=o=>He.accountsArray(o,t.accounts,n,t.name),i}static accountsArray(t,e,n,i){return t?e.map(o=>{if(("accounts"in o?o.accounts:void 0)!==void 0){const a=t[o.name];return He.accountsArray(a,o.accounts,n,i).flat()}else{const a=o;let d;try{d=Z(t[o.name])}catch{throw new Error(`Wrong input type for account "${o.name}" in the instruction accounts object${i!==void 0?' for instruction "'+i+'"':""}. Expected PublicKey or string.`)}const c=a.isOptional&&d.equals(n),u=a.isMut&&!c,y=a.isSigner&&!c;return{pubkey:d,isWritable:u,isSigner:y}}}).flat():[]}}function Us(r,...t){}class Ns{static build(t,e){return(...i)=>{var o,s,a;const[,d]=nt(t,[...i]),c=new m.Transaction;if(d.preInstructions&&d.instructions)throw new Error("instructions is deprecated, use preInstructions");return(o=d.preInstructions)===null||o===void 0||o.forEach(u=>c.add(u)),(s=d.instructions)===null||s===void 0||s.forEach(u=>c.add(u)),c.add(e(...i)),(a=d.postInstructions)===null||a===void 0||a.forEach(u=>c.add(u)),c}}}class Ms{static build(t,e,n,i){return async(...s)=>{var a;const d=e(...s),[,c]=nt(t,[...s]);if(i.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await i.sendAndConfirm(d,(a=c.signers)!==null&&a!==void 0?a:[],c.options)}catch(u){throw Vt(u,n)}}}}class $s{static build(t,e,n,i){var o;const s={};return(o=t.accounts)===null||o===void 0||o.forEach(a=>{const d=V(a.name);s[d]=new js(t,a,n,i,e)}),s}}class js{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}get idlAccount(){return this._idlAccount}constructor(t,e,n,i,o){this._idlAccount=e,this._programId=n,this._provider=i??qe(),this._coder=o??new Ir(t),this._size=this._coder.accounts.size(e)}async fetchNullable(t,e){const{data:n}=await this.fetchNullableAndContext(t,e);return n}async fetchNullableAndContext(t,e){const n=await this.getAccountInfoAndContext(t,e),{value:i,context:o}=n;return{data:i&&i.data.length!==0?this._coder.accounts.decode(this._idlAccount.name,i.data):null,context:o}}async fetch(t,e){const{data:n}=await this.fetchNullableAndContext(t,e);if(n===null)throw new Error(`Account does not exist or has no data ${t.toString()}`);return n}async fetchAndContext(t,e){const{data:n,context:i}=await this.fetchNullableAndContext(t,e);if(n===null)throw new Error(`Account does not exist ${t.toString()}`);return{data:n,context:i}}async fetchMultiple(t,e){return(await this.fetchMultipleAndContext(t,e)).map(i=>i?i.data:null)}async fetchMultipleAndContext(t,e){return(await $t(this._provider.connection,t.map(i=>Z(i)),e)).map(i=>{if(i==null)return null;const{account:o,context:s}=i;return{data:this._coder.accounts.decode(this._idlAccount.name,o.data),context:s}})}async all(t){const e=this.coder.accounts.memcmp(this._idlAccount.name,t instanceof m.dist.Buffer?t:void 0),n=[];return(e==null?void 0:e.offset)!=null&&(e==null?void 0:e.bytes)!=null&&n.push({memcmp:{offset:e.offset,bytes:e.bytes}}),(e==null?void 0:e.dataSize)!=null&&n.push({dataSize:e.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...n,...Array.isArray(t)?t:[]]})).map(({pubkey:o,account:s})=>({publicKey:o,account:this._coder.accounts.decode(this._idlAccount.name,s.data)}))}subscribe(t,e){const n=Ae.get(t.toString());if(n)return n.ee;const i=new mo;t=Z(t);const o=this._provider.connection.onAccountChange(t,s=>{const a=this._coder.accounts.decode(this._idlAccount.name,s.data);i.emit("change",a)},e);return Ae.set(t.toString(),{ee:i,listener:o}),i}async unsubscribe(t){let e=Ae.get(t.toString());if(!e){console.warn("Address is not subscribed");return}Ae&&await this._provider.connection.removeAccountChangeListener(e.listener).then(()=>{Ae.delete(t.toString())}).catch(console.error)}async createInstruction(t,e){const n=this.size;if(this._provider.publicKey===void 0)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return m.SystemProgram.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:t.publicKey,space:e??n,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(e??n),programId:this._programId})}async associated(...t){const e=await this.associatedAddress(...t);return await this.fetch(e)}async associatedAddress(...t){return await Dr(this._programId,...t)}async getAccountInfo(t,e){return await this._provider.connection.getAccountInfo(Z(t),e)}async getAccountInfoAndContext(t,e){return await this._provider.connection.getAccountInfoAndContext(Z(t),e)}}const Ae=new Map,Lt="Program log: ",Nr="Program data: ",Vs=Lt.length,Fs=Nr.length;class zs{constructor(t,e,n){this._programId=t,this._provider=e,this._eventParser=new Mr(t,n),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(t,e){var n;let i=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(t)||this._eventListeners.set(t,[]),this._eventListeners.set(t,((n=this._eventListeners.get(t))!==null&&n!==void 0?n:[]).concat(i)),this._eventCallbacks.set(i,[t,e]),this._onLogsSubscriptionId!==void 0||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(o,s)=>{if(!o.err)for(const a of this._eventParser.parseLogs(o.logs)){const d=this._eventListeners.get(a.name);d&&d.forEach(c=>{const u=this._eventCallbacks.get(c);if(u){const[,y]=u;y(a.data,s.slot,o.signature)}})}})),i}async removeEventListener(t){const e=this._eventCallbacks.get(t);if(!e)throw new Error(`Event listener ${t} doesn't exist!`);const[n]=e;let i=this._eventListeners.get(n);if(!i)throw new Error(`Event listeners don't exist for ${n}!`);if(this._eventCallbacks.delete(t),i=i.filter(o=>o!==t),this._eventListeners.set(n,i),i.length===0&&this._eventListeners.delete(n),this._eventCallbacks.size===0){if(this._eventListeners.size!==0)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);this._onLogsSubscriptionId!==void 0&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class Mr{constructor(t,e){this.coder=e,this.programId=t}*parseLogs(t,e=!1){const n=new qs(t),i=new Ks;let o=n.next();for(;o!==null;){let[s,a,d]=this.handleLog(i,o,e);s&&(yield s),a&&i.push(a),d&&i.pop(),o=n.next()}}handleLog(t,e,n){return t.stack.length>0&&t.program()===this.programId.toString()?this.handleProgramLog(e,n):[null,...this.handleSystemLog(e)]}handleProgramLog(t,e){if(t.startsWith(Lt)||t.startsWith(Nr)){const n=t.startsWith(Lt)?t.slice(Vs):t.slice(Fs),i=this.coder.events.decode(n);if(e&&i===null)throw new Error(`Unable to decode event ${n}`);return[i,null,!1]}else return[null,...this.handleSystemLog(t)]}handleSystemLog(t){const e=t.split(":")[0];return e.match(/^Program (.*) success/g)!==null?[null,!0]:e.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:e.includes("invoke")?["cpi",!1]:[null,!1]}}class Ks{constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(t){this.stack.push(t)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class qs{constructor(t){this.logs=t}next(){if(this.logs.length===0)return null;let t=this.logs[0];return this.logs=this.logs.slice(1),t}}class Gs{static build(t,e,n,i,o,s,a){return async(...c)=>{var u;const y=e(...c),[,w]=nt(t,[...c]);let f;if(i.simulate===void 0)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{f=await i.simulate(y,w.signers,(u=w.options)===null||u===void 0?void 0:u.commitment)}catch(g){throw Vt(g,n)}if(f===void 0)throw new Error("Unable to simulate transaction");const p=f.logs;if(!p)throw new Error("Simulated logs not found");const x=[];if(a.events){let g=new Mr(s,o);for(const A of g.parseLogs(p))x.push(A)}return{events:x,raw:p}}}}function ht(r){return new $r(Re(8),t=>qt.fromBuffer(t),t=>t.toBuffer(),r)}function je(r){return new $r(Re(32),t=>new m.PublicKey(t),t=>t.toBuffer(),r)}function pt(r,t){return new Zs(r,t)}class $r extends Qe{constructor(t,e,n,i){super(t.span,i),this.layout=t,this.decoder=e,this.encoder=n}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,n){return this.layout.encode(this.encoder(t),e,n)}getSpan(t,e){return this.layout.getSpan(t,e)}}class Zs extends Qe{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=ne()}encode(t,e,n=0){return t==null?this.layout.span+this.discriminator.encode(0,e,n):(this.discriminator.encode(1,e,n),this.layout.encode(t,e,n+4)+4)}decode(t,e=0){const n=this.discriminator.decode(t,e);if(n===0)return null;if(n===1)return this.layout.decode(t,e+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(t,e=0){return this.layout.getSpan(t,e+4)+4}}class qt extends m.BN{toBuffer(){const t=super.toArray().reverse(),e=m.dist.Buffer.from(t);if(e.length===8)return e;if(e.length>=8)throw new Error("u64 too large");const n=m.dist.Buffer.alloc(8);return e.copy(n),n}static fromBuffer(t){if(t.length!==8)throw new Error(`Invalid buffer length: ${t.length}`);return new qt([...t].reverse().map(e=>`00${e.toString(16)}`.slice(-2)).join(""),16)}}const Hs=z([je("mint"),je("owner"),ht("amount"),pt(je(),"delegate"),(r=>{const t=Br(ys("discriminator"),null,r);return t.addVariant(0,z([]),"uninitialized"),t.addVariant(1,z([]),"initialized"),t.addVariant(2,z([]),"frozen"),t})("state"),pt(ht(),"isNative"),ht("delegatedAmount"),pt(je(),"closeAuthority")]);function Ws(r){return Hs.decode(r)}class Te{constructor(t,e,n,i,o,s,a,d){this._accounts=e,this._provider=n,this._programId=i,this._idlIx=o,this._idlTypes=a,this._customResolver=d,this._args=t,this._accountStore=new Xs(n,s,this._programId)}args(t){this._args=t}async resolve(){for(await this.resolveConst(this._idlIx.accounts),this._resolveEventCpi(this._idlIx.accounts);await this.resolvePdas(this._idlIx.accounts)+await this.resolveRelations(this._idlIx.accounts)+await this.resolveCustom()>0;);}async resolveCustom(){if(this._customResolver){const{accounts:t,resolved:e}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=t,e}return 0}resolveOptionalsHelper(t,e){const n={};for(const i of e){const o=i.name,s=t[o];s!==void 0&&(jr(s)?Cs(i)?n[o]=this.resolveOptionalsHelper(s,i.accounts):n[o]=Vr(s):s!==null?n[o]=Z(s):i.isOptional&&(n[o]=this._programId))}return n}resolveOptionals(t){Object.assign(this._accounts,this.resolveOptionalsHelper(t,this._idlIx.accounts))}get(t){const e=t.reduce((n,i)=>n&&n[i],this._accounts);if(e&&e.toBase58)return e}set(t,e){let n=this._accounts;t.forEach((i,o)=>{o==t.length-1&&(n[i]=e),n[i]=n[i]||{},n=n[i]})}async resolveConst(t,e=[]){for(let n=0;n<t.length;n+=1){const i=t[n],o=i.accounts;o&&await this.resolveConst(o,[...e,V(i.name)]);const s=i,a=V(i.name);if(s.isSigner&&!this.get([...e,a])){if(this._provider.wallet===void 0)throw new Error("This function requires the Provider interface implementor to have a 'wallet' field.");this.set([...e,a],this._provider.wallet.publicKey)}Reflect.has(Te.CONST_ACCOUNTS,a)&&!this.get([...e,a])&&this.set([...e,a],Te.CONST_ACCOUNTS[a])}}_resolveEventCpi(t,e=[]){for(const n in t){const i=t[n],o=i.accounts;o&&this._resolveEventCpi(o,[...e,V(i.name)]);const s=+n+1;if(s===t.length)return;const a=V(t[n].name),d=V(t[s].name);if(a==="eventAuthority"&&d==="program"){const c=[...e,a],u=[...e,d];this.get(c)||this.set(c,m.PublicKey.findProgramAddressSync([m.dist.Buffer.from("__event_authority")],this._programId)[0]),this.get(u)||this.set(u,this._programId);return}}}async resolvePdas(t,e=[]){let n=0;for(let i=0;i<t.length;i+=1){const o=t[i],s=o.accounts;s&&(n+=await this.resolvePdas(s,[...e,V(o.name)]));const a=o,d=V(o.name);a.pda&&a.pda.seeds.length>0&&!this.get([...e,d])&&await this.autoPopulatePda(a,e)&&(n+=1)}return n}async resolveRelations(t,e=[]){let n=0;for(let i=0;i<t.length;i+=1){const o=t[i],s=o.accounts;s&&(n+=await this.resolveRelations(s,[...e,V(o.name)]));const a=o.relations||[],d=V(o.name),c=[...e,d],u=this.get(c);if(u){const y=a.filter(w=>!this.get([...e,V(w)]));if(n+=y.length,y.length>0){const w=await this._accountStore.fetchAccount({publicKey:u});await Promise.all(y.map(async f=>{const p=V(f);return this.set([...e,p],w[p]),w[p]}))}}}return n}async autoPopulatePda(t,e=[]){if(!t.pda||!t.pda.seeds)throw new Error("Must have seeds");const n=await Promise.all(t.pda.seeds.map(s=>this.toBuffer(s,e)));if(n.some(s=>typeof s>"u"))return;const i=await this.parseProgramId(t,e);if(!i)return;const[o]=await m.PublicKey.findProgramAddress(n,i);this.set([...e,V(t.name)],o)}async parseProgramId(t,e=[]){var n;if(!(!((n=t.pda)===null||n===void 0)&&n.programId))return this._programId;switch(t.pda.programId.kind){case"const":return new m.PublicKey(this.toBufferConst(t.pda.programId.value));case"arg":return this.argValue(t.pda.programId);case"account":return await this.accountValue(t.pda.programId,e);default:throw new Error(`Unexpected program seed kind: ${t.pda.programId.kind}`)}}async toBuffer(t,e=[]){switch(t.kind){case"const":return this.toBufferConst(t);case"arg":return await this.toBufferArg(t);case"account":return await this.toBufferAccount(t,e);default:throw new Error(`Unexpected seed kind: ${t.kind}`)}}getType(t,e=[]){if(e.length>0&&t.defined){const n=this._idlTypes.find(s=>s.name===t.defined);if(!n)throw new Error(`Cannot find type ${t.defined}`);const o=n.type.fields.find(s=>s.name===e[0]);return this.getType(o.type,e.slice(1))}return t}toBufferConst(t){return this.toBufferValue(this.getType(t.type,(t.path||"").split(".").slice(1)),t.value)}async toBufferArg(t){const e=this.argValue(t);if(!(typeof e>"u"))return this.toBufferValue(this.getType(t.type,(t.path||"").split(".").slice(1)),e)}argValue(t){const e=t.path.split("."),n=V(e[0]),i=this._idlIx.args.findIndex(o=>o.name===n);if(i===-1)throw new Error(`Unable to find argument for seed: ${n}`);return e.slice(1).reduce((o,s)=>(o||{})[s],this._args[i])}async toBufferAccount(t,e=[]){const n=await this.accountValue(t,e);if(n)return this.toBufferValue(t.type,n)}async accountValue(t,e=[]){const n=t.path.split("."),i=n[0],o=this.get([...e,V(i)]);if(o===null)throw new Error("fieldPubkey is null");if(n.length===1)return o;const s=await this._accountStore.fetchAccount({publicKey:o,name:t.account});return this.parseAccountValue(s,n.slice(1))}parseAccountValue(t,e){let n;for(;e.length>0;)n=t[V(e[0])],e=e.slice(1);return n}toBufferValue(t,e){switch(t){case"u8":return m.dist.Buffer.from([e]);case"u16":let n=m.dist.Buffer.alloc(2);return n.writeUInt16LE(e),n;case"u32":let i=m.dist.Buffer.alloc(4);return i.writeUInt32LE(e),i;case"u64":let o=m.dist.Buffer.alloc(8);return o.writeBigUInt64LE(BigInt(e)),o;case"string":return m.dist.Buffer.from(gr(e));case"publicKey":return e.toBuffer();default:if(t.array)return m.dist.Buffer.from(e);throw new Error(`Unexpected seed type: ${t}`)}}}Te.CONST_ACCOUNTS={associatedTokenProgram:Kt,rent:m.SYSVAR_RENT_PUBKEY,systemProgram:m.SystemProgram.programId,tokenProgram:zt,clock:m.SYSVAR_CLOCK_PUBKEY};class Xs{constructor(t,e,n){this._provider=t,this._programId=n,this._cache=new Map,this._idls={},this._idls[n.toBase58()]=e}async ensureIdl(t){if(!this._idls[t.toBase58()]){const e=await me.fetchIdl(t,this._provider);if(e){const n=new me(e,t,this._provider);this._idls[t.toBase58()]=n.account}}return this._idls[t.toBase58()]}async fetchAccount({publicKey:t,name:e,programId:n=this._programId}){const i=t.toString();if(!this._cache.has(i))if(e==="TokenAccount"){const o=await this._provider.connection.getAccountInfo(t);if(o===null)throw new Error(`invalid account info for ${i}`);const s=Ws(o.data);this._cache.set(i,s)}else if(e){const o=await this.ensureIdl(n);if(o){const s=o[V(e)];if(s){const a=await s.fetch(t);this._cache.set(i,a)}}}else{const o=await this._provider.connection.getAccountInfo(t);if(o===null)throw new Error(`invalid account info for ${i}`);const s=o.data,a=await this.ensureIdl(o.owner);if(a){const d=Object.values(a)[0];if(!d)throw new Error("No accounts for this program");const c=d.coder.accounts.decodeAny(s);this._cache.set(i,c)}}return this._cache.get(i)}}class Ys{static build(t,e,n,i,o,s,a,d,c,u,y){return(...w)=>new Js(w,i,o,s,a,d,t,e,n,c,u,y)}}function jr(r){return typeof r=="object"&&r!==null&&!("_bn"in r)}function Vr(r,t){const e={};for(const n in r){const i=r[n];if(i===null)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");e[n]=jr(i)?Vr(i):Z(i)}return e}class Js{constructor(t,e,n,i,o,s,a,d,c,u,y,w){this._ixFn=e,this._txFn=n,this._rpcFn=i,this._simulateFn=o,this._viewFn=s,this._programId=d,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._autoResolveAccounts=!0,this._args=t,this._accountsResolver=new Te(t,this._accounts,a,d,c,u,y,w)}args(t){this._args=t,this._accountsResolver.args(t)}async pubkeys(){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._accounts}accounts(t){return this._autoResolveAccounts=!0,this._accountsResolver.resolveOptionals(t),this}accountsStrict(t){return this._autoResolveAccounts=!1,this._accountsResolver.resolveOptionals(t),this}signers(t){return this._signers=this._signers.concat(t),this}remainingAccounts(t){return this._remainingAccounts=this._remainingAccounts.concat(t),this}preInstructions(t){return this._preInstructions=this._preInstructions.concat(t),this}postInstructions(t){return this._postInstructions=this._postInstructions.concat(t),this}async rpc(t){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpcAndKeys(t){return{pubkeys:await this.pubkeys(),signature:await this.rpc(t)}}async view(t){if(this._autoResolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error("Method does not support views");return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async simulate(t){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async instruction(){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async prepare(){return{instruction:await this.instruction(),pubkeys:await this.pubkeys(),signers:await this._signers}}async transaction(){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}}class Qs{static build(t,e,n,i){const o=e.accounts.find(d=>d.isMut),s=!!e.returns;return o||!s?void 0:async(...d)=>{var c,u;let y=await n(...d);const w=`Program return: ${t} `;let f=y.raw.find(A=>A.startsWith(w));if(!f)throw new Error("View expected return log");let p=Dt(f.slice(w.length)),x=e.returns;if(!x)throw new Error("View expected return type");return K.fieldLayout({type:x},Array.from([...(c=i.accounts)!==null&&c!==void 0?c:[],...(u=i.types)!==null&&u!==void 0?u:[]])).decode(p)}}}class ea{static build(t,e,n,i,o){const s={},a={},d={},c={},u={},y={},w=mr(t),f=t.accounts?$s.build(t,e,n,i):{};return t.instructions.forEach(p=>{const x=He.build(p,($,I)=>e.instruction.encode($,I),n),g=Ns.build(p,x),A=Ms.build(p,g,w,i),P=Gs.build(p,g,w,i,e,n,t),E=Qs.build(n,p,P,t),b=Ys.build(i,n,p,x,g,A,P,E,f,t.types||[],o&&o(p)),T=V(p.name);a[T]=x,d[T]=g,s[T]=A,c[T]=P,u[T]=b,E&&(y[T]=E)}),[s,a,d,f,c,u,y]}}class me{get programId(){return this._programId}get idl(){return this._idl}get coder(){return this._coder}get provider(){return this._provider}constructor(t,e,n,i,o){e=Z(e),n||(n=qe()),this._idl=t,this._provider=n,this._programId=e,this._coder=i??new Ir(t),this._events=new zs(this._programId,n,this._coder);const[s,a,d,c,u,y,w]=ea.build(t,this._coder,e,n,o??(()=>{}));this.rpc=s,this.instruction=a,this.transaction=d,this.account=c,this.simulate=u,this.methods=y,this.views=w}static async at(t,e){const n=Z(t),i=await me.fetchIdl(n,e);if(!i)throw new Error(`IDL not found for program: ${t.toString()}`);return new me(i,n,e)}static async fetchIdl(t,e){e=e??qe();const n=Z(t),i=await Os(n),o=await e.connection.getAccountInfo(i);if(!o)return null;let s=Ds(o.data.slice(8));const a=yo(s.data);return JSON.parse(yr(a))}addEventListener(t,e){return this._events.addEventListener(t,e)}async removeEventListener(t){return await this._events.removeEventListener(t)}}new m.PublicKey("11111111111111111111111111111111");exports.Program=me;exports.createReadOnlyProvider=Fr;exports.dist=R;exports.index=Ps;exports.parseIdlErrors=mr;exports.translateError=Vt;
@@ -1 +0,0 @@
1
- "use strict";const t=require("./address-BGujeWtN.js");function b(n,e,o,s){t.ahash(n);const a=t.checkOpts$1({dkLen:32,asyncTick:10},s),{c:d,dkLen:i,asyncTick:r}=a;if(t.anumber(d),t.anumber(i),t.anumber(r),d<1)throw new Error("iterations (c) should be >= 1");const f=t.kdfInputToBytes(e),u=t.kdfInputToBytes(o),l=new Uint8Array(i),p=t.hmac.create(n,f),c=p._cloneInto().update(u);return{c:d,dkLen:i,asyncTick:r,DK:l,PRF:p,PRFSalt:c}}function T(n,e,o,s,a){return n.destroy(),e.destroy(),s&&s.destroy(),t.clean(a),o}function L(n,e,o,s){const{c:a,dkLen:d,DK:i,PRF:r,PRFSalt:f}=b(n,e,o,s);let u;const l=new Uint8Array(4),p=t.createView$1(l),c=new Uint8Array(r.outputLen);for(let w=1,y=0;y<d;w++,y+=r.outputLen){const m=i.subarray(y,y+r.outputLen);p.setInt32(0,w,!1),(u=f._cloneInto(u)).update(l).digestInto(c),m.set(c.subarray(0,m.length));for(let h=1;h<a;h++){r._cloneInto(u).update(c).digestInto(c);for(let k=0;k<m.length;k++)m[k]^=c[k]}}return T(r,f,i,u,c)}/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function I(n){if(typeof n!="string")throw new TypeError("invalid mnemonic type: "+typeof n);return n.normalize("NFKD")}function g(n){const e=I(n),o=e.split(" ");if(![12,15,18,21,24].includes(o.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:o}}const S=n=>I("mnemonic"+n);function F(n,e=""){return L(t.sha512$1,g(n).nfkd,S(e),{c:2048,dkLen:64})}exports.mnemonicToSeedSync=F;
@@ -1 +0,0 @@
1
- "use strict";var k=Object.defineProperty;var C=(g,s,t)=>s in g?k(g,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):g[s]=t;var i=(g,s,t)=>C(g,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./platform-B1XoDKoN.js"),d=require("./address-BGujeWtN.js"),v=require("./unsignedTransaction-DzSLsK-p.js"),b=[["Testnet",{tokenMessengerState:"0x5252abd1137094ed1db3e0d75bc36abcd287aee4bc310f8e047727ef5682e7c2",messageTransmitterState:"0x98234bd0fa9ac12cc0a20a144a22e36d6a32f7e0a97baaeaf9c76cdc6d122d2e",usdcTreasury:"0x7170137d4a6431bf83351ac025baf462909bffe2877d87716374fb42b9629ebe"}],["Mainnet",{tokenMessengerState:"0x45993eecc0382f37419864992c12faee2238f5cfe22b98ad3bf455baf65c8a2f",messageTransmitterState:"0xf68268c3d9b1df3215f2439400c1c4ea08ac4ef4bb7d6f3ca6a2a239e17510af",usdcTreasury:"0x57d6725e7a8b49a7b2a612f6bd66ab5f39fc95332ca48be421c3229d514a6de7"}]],T=d.constMap(b,[0,1]);class p{constructor(s,t,r,e){i(this,"network");i(this,"chain");i(this,"provider");i(this,"contracts");i(this,"usdcId");i(this,"usdcTreasuryId");i(this,"tokenMessengerId");i(this,"tokenMessengerStateId");i(this,"messageTransmitterId");i(this,"messageTransmitterStateId");var u,m,f,l;if(this.network=s,this.chain=t,this.provider=r,this.contracts=e,s==="Devnet")throw new Error("CircleBridge not supported on Devnet");const n=d.usdcContract.get(this.network,this.chain);if(!n)throw new Error(`No USDC contract configured for network=${this.network} chain=${this.chain}`);const{tokenMessengerState:o,messageTransmitterState:a,usdcTreasury:c}=T(s);if(!((u=e.cctp)!=null&&u.tokenMessenger))throw new Error(`Circle Token Messenger contract for domain ${t} not found`);if(!((m=e.cctp)!=null&&m.messageTransmitter))throw new Error(`Circle Message Transmitter contract for domain ${t} not found`);this.usdcId=n,this.usdcTreasuryId=c,this.tokenMessengerId=(f=e.cctp)==null?void 0:f.tokenMessenger,this.messageTransmitterId=(l=e.cctp)==null?void 0:l.messageTransmitter,this.tokenMessengerStateId=o,this.messageTransmitterStateId=a}async*transfer(s,t,r){const e=new h.Transaction,n=d.circleChainId.get(this.network,t.chain),[o,...a]=await h.SuiPlatform.getCoins(this.provider,s,this.usdcId);if(o===void 0)throw new Error("No USDC in wallet");const c=e.object(o.coinObjectId);a.length>0&&e.mergeCoins(c,a.map(m=>e.object(m.coinObjectId)));const[u]=e.splitCoins(c,[r]);e.moveCall({target:`${this.tokenMessengerId}::deposit_for_burn::deposit_for_burn`,arguments:[u,e.pure.u32(n),e.pure.address(t.address.toUniversalAddress().toString()),e.object(this.tokenMessengerStateId),e.object(this.messageTransmitterStateId),e.object("0x403"),e.object(this.usdcTreasuryId)],typeArguments:[this.usdcId]}),yield this.createUnsignedTx(e,"Sui.CircleBridge.Transfer")}async isTransferCompleted(s){const t=new h.Transaction;t.moveCall({target:`${this.messageTransmitterId}::state::is_nonce_used`,arguments:[t.object(this.messageTransmitterStateId),t.pure.u32(s.sourceDomain),t.pure.u64(s.nonce)]});const r=await this.provider.devInspectTransactionBlock({sender:"0x0000000000000000000000000000000000000000000000000000000000000000",transactionBlock:t});try{return!!r.results[0].returnValues[0][0][0]}catch(e){return console.error(`Error reading if nonce was used: ${e}`),!1}}async*redeem(s,t,r){const e=new h.Transaction,[n]=e.moveCall({target:`${this.messageTransmitterId}::receive_message::receive_message`,arguments:[e.pure.vector("u8",d.CircleBridge.serialize(t)),e.pure.vector("u8",d.hex.decode(r)),e.object(this.messageTransmitterStateId)]});if(!n)throw new Error("Failed to produce receipt");const[o]=e.moveCall({target:`${this.tokenMessengerId}::handle_receive_message::handle_receive_message`,arguments:[n,e.object(this.tokenMessengerStateId),e.object("0x403"),e.object(this.usdcTreasuryId)],typeArguments:[this.usdcId]});if(!o)throw new Error("Failed to produce stamp receipt ticket with burn message");const[a]=e.moveCall({target:`${this.tokenMessengerId}::handle_receive_message::deconstruct_stamp_receipt_ticket_with_burn_message`,arguments:[o]});if(!a)throw new Error("Failed to produce stamp receipt ticket");const[c]=e.moveCall({target:`${this.messageTransmitterId}::receive_message::stamp_receipt`,arguments:[a,e.object(this.messageTransmitterStateId)],typeArguments:[`${this.tokenMessengerId}::message_transmitter_authenticator::MessageTransmitterAuthenticator`]});if(!c)throw new Error("Failed to produce stamped receipt");e.moveCall({target:`${this.messageTransmitterId}::receive_message::complete_receive_message`,arguments:[c,e.object(this.messageTransmitterStateId)]}),yield this.createUnsignedTx(e,"Sui.CircleBridge.Redeem")}async parseTransactionDetails(s){var w;const t=await this.provider.waitForTransaction({digest:s,options:{showEvents:!0,showEffects:!0,showInput:!0}});if(!t)throw new Error("Transaction not found");if(!t.events)throw new Error("Transaction events not found");const r=(w=t.events)==null?void 0:w.find(I=>I.type.includes("send_message::MessageSent"));if(!r)throw new Error("No MessageSent event found");const e=new Uint8Array((r==null?void 0:r.parsedJson).message),[n,o]=d.CircleBridge.deserialize(e),{payload:a}=n,c=a.messageSender,u=a.mintRecipient,m=d.toCircleChain(this.network,n.sourceDomain),f=d.toCircleChain(this.network,n.destinationDomain),l={chain:m,address:a.burnToken};return{from:{chain:m,address:c},to:{chain:f,address:u},token:l,amount:a.amount,message:n,id:{hash:o}}}static async fromRpc(s,t){const[r,e]=await h.SuiPlatform.chainFromRpc(s),n=t[e];if(n.network!==r)throw new Error(`Network mismatch: ${n.network} != ${r}`);return new p(r,e,s,n.contracts)}createUnsignedTx(s,t,r=!1){return new v.SuiUnsignedTransaction(s,this.network,this.chain,t,r)}}d.registerProtocol("Sui","CircleBridge",p);exports.SuiCircleBridge=p;exports._suiCircleObjects=b;exports.suiCircleObjects=T;
@@ -1 +0,0 @@
1
- "use strict";var h=Object.defineProperty;var m=(a,e,t)=>e in a?h(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var s=(a,e,t)=>m(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./address-BGujeWtN.js"),w=require("./platform-NG3efAb2.js"),g=require("./create-DoZZ7ciL.js");class c{constructor(e,t,r,o){s(this,"network");s(this,"chain");s(this,"connection");s(this,"contracts");s(this,"chainId");s(this,"coreBridge");this.network=e,this.chain=t,this.connection=r,this.contracts=o,this.chainId=i.toChainId(t);const n=o.coreBridge;if(!n)throw new Error(`CoreBridge contract Address for chain ${t} not found`);this.coreBridge=n}getGuardianSet(e){throw new Error("Method not implemented.")}getGuardianSetIndex(){throw new Error("Method not implemented.")}getMessageFee(){throw new Error("Method not implemented.")}static async fromRpc(e,t){const[r,o]=await w.AptosPlatform.chainFromRpc(e),n=t[o];if(n.network!==r)throw new Error(`Network mismatch: ${n.network} !== ${r}`);return new c(r,o,e,n.contracts)}async*publishMessage(e,t){throw new Error("Method not implemented.")}async*verifyMessage(e,t){throw new Error("Not implemented.")}async parseTransaction(e){return(await this.parseMessages(e)).map(r=>({chain:r.emitterChain,emitter:r.emitterAddress,sequence:r.sequence}))}async parseMessages(e){const t=await this.connection.getTransactionByHash({transactionHash:e});if(t.type!=="user_transaction")throw new Error(`${e} is not a user_transaction`);const r=t.events.filter(o=>o.type.endsWith("WormholeMessage"));if(!r||r.length===0)throw new Error(`WormholeMessage not found for ${e}`);return r.map(o=>{const n=o.data,d=new i.UniversalAddress(BigInt(n.sender).toString(16).padStart(64,"0"));return g.createVAA("Uint8Array",{guardianSet:0,emitterChain:this.chain,emitterAddress:d,sequence:BigInt(n.sequence),timestamp:Number(n.timestamp),consistencyLevel:n.consistency_level,nonce:Number(n.nonce),signatures:[],payload:i.hex.decode(n.payload)})})}}i.registerProtocol("Aptos","WormholeCore",c);exports.AptosWormholeCore=c;
@@ -1 +0,0 @@
1
- "use strict";var h=Object.defineProperty;var m=(i,e,r)=>e in i?h(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var o=(i,e,r)=>m(i,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./address-BGujeWtN.js"),u=require("./platform-B1XoDKoN.js"),w=require("./create-DoZZ7ciL.js"),g=require("./address-C7DIAk4M.js");class c{constructor(e,r,t,n){o(this,"network");o(this,"chain");o(this,"provider");o(this,"contracts");o(this,"chainId");o(this,"coreBridgePackageId");this.network=e,this.chain=r,this.provider=t,this.contracts=n,this.chainId=d.toChainId(r);const s=n.coreBridge;if(!s)throw new Error(`CoreBridge contract Address for chain ${r} not found`);this.coreBridgePackageId=s}getGuardianSet(e){throw new Error("Method not implemented.")}getMessageFee(){throw new Error("Method not implemented.")}static async fromRpc(e,r){const[t,n]=await u.SuiPlatform.chainFromRpc(e),s=r[n];if(s.network!==t)throw new Error(`Network mismatch: ${s.network} !== ${t}`);return new c(t,n,e,s.contracts)}async*verifyMessage(e,r){throw new Error("Method not implemented.")}async*publishMessage(e,r){throw new Error("Method not implemented.")}async parseTransaction(e){return(await this.parseMessages(e)).map(t=>({emitter:t.emitterAddress,sequence:t.sequence,chain:this.chain}))}async getGuardianSetIndex(){throw new Error("Method not implemented.")}async parseMessages(e){var n;const t=(n=(await this.provider.getTransactionBlock({digest:e,options:{showEvents:!0,showEffects:!0,showInput:!0}})).events)==null?void 0:n.filter(s=>s.type.endsWith("WormholeMessage"));if(!t||t.length==0)throw new Error("WormholeMessage not found");return t.map(s=>{const a=s.parsedJson;return w.createVAA("Uint8Array",{emitterChain:this.chain,emitterAddress:new g.SuiAddress(a.sender).toUniversalAddress(),sequence:BigInt(a.sequence),guardianSet:0,timestamp:Number(a.timestamp),consistencyLevel:a.consistency_level,nonce:a.nonce,signatures:[],payload:new Uint8Array(a.payload)})})}}d.registerProtocol("Sui","WormholeCore",c);exports.SuiWormholeCore=c;
@@ -1 +0,0 @@
1
- "use strict";var y=Object.defineProperty;var g=(d,e,t)=>e in d?y(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var o=(d,e,t)=>g(d,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./address-BGujeWtN.js"),i=require("./address-KNhRm6oe.js"),f=require("./platform-NG3efAb2.js"),w=require("./unsignedTransaction-C1YeEl4G.js"),T=[{name:"tokenBridgeAddress",...r.universalAddressItem},{name:"chain",...r.chainItem()},{name:"domainSeparator",binary:"bytes",custom:r.bytes.encode(i.APTOS_SEPARATOR),omit:!0},{name:"tokenId",...r.universalAddressItem},{name:"domainSeparator",binary:"bytes",custom:new Uint8Array([255]),omit:!0}],m=d=>r.serialize(T,d);class c{constructor(e,t,s,n){o(this,"network");o(this,"chain");o(this,"connection");o(this,"contracts");o(this,"chainId");o(this,"tokenBridgeAddress");this.network=e,this.chain=t,this.connection=s,this.contracts=n,this.chainId=r.toChainId(t);const a=n.tokenBridge;if(!a)throw new Error(`TokenBridge contract Address for chain ${t} not found`);this.tokenBridgeAddress=a}static async fromRpc(e,t){const[s,n]=await f.AptosPlatform.chainFromRpc(e),a=t[n];if(a.network!==s)throw new Error("Network mismatch "+a.network+" !== "+s);return new c(s,n,e,a.contracts)}async isWrappedAsset(e){try{return await this.getOriginalAsset(e),!0}catch{return!1}}async getOriginalAsset(e){const t=e.toString().split(i.APTOS_SEPARATOR),s=await this.connection.getAccountResource({accountAddress:t[0],resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`});if(!s)throw r.ErrNotWrapped(e.toString());const n=r.toChain(parseInt(s.token_chain.number)),a=new r.UniversalAddress(s.token_address.external_address);return{chain:n,address:a}}async getTokenUniversalAddress(e){return new r.UniversalAddress(r.hex.encode(r.sha3_256(e.toString()),!0))}async getTokenNativeAddress(e,t){const s=e===this.chain?await this.getTypeFromExternalAddress(t.toString()):await this.getAssetFullyQualifiedType({chain:e,address:t});if(!s)throw new Error("Invalid asset address.");return new i.AptosAddress(s)}async hasWrappedAsset(e){try{return await this.getWrappedAsset(e),!0}catch{}return!1}async getWrappedAsset(e){if(r.isNative(e.address))throw new Error("native asset cannot be a wrapped asset");const t=await this.getAssetFullyQualifiedType(e);if(!t)throw new Error("Invalid asset address.");return await this.connection.getAccountResource({accountAddress:i.coalesceModuleAddress(t),resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`}),r.toNative(this.chain,t)}async isTransferCompleted(e){const s=(await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`})).consumed_vaas.elems.handle;try{return await this.connection.getTableItem({handle:s,data:{key_type:"vector<u8>",value_type:"u8",key:`0x${r.dist.Buffer.from(r.keccak_256(e.hash)).toString("hex")}`}}),!0}catch{return!1}}async getWrappedNative(){return r.toNative(this.chain,i.APTOS_COIN)}async*createAttestation(e,t){const s={chain:this.chain,address:new i.AptosAddress(e)},n=await this.getAssetFullyQualifiedType(s);if(!n)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::attest_token::attest_token_entry`,typeArguments:[n],functionArguments:[]},"Aptos.AttestToken")}async*submitAttestation(e,t){yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin_type`,typeArguments:[],functionArguments:[r.serialize$1(e)]},"Aptos.CreateWrappedCoinType");const s=await this.getAssetFullyQualifiedType(e.payload.token);if(!s)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin`,typeArguments:[s],functionArguments:[r.serialize$1(e)]},"Aptos.CreateWrappedCoin")}async*transfer(e,t,s,n,a){const l=0n,h=0n,u=r.isNative(s)?i.APTOS_COIN:s.toString(),A=t.address.toUniversalAddress().toUint8Array(),p=r.toChainId(t.chain);a?yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_with_payload_entry`,typeArguments:[u],functionArguments:[n,p,A,h,a]},"Aptos.TransferTokensWithPayload"):yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_entry`,typeArguments:[u],functionArguments:[n,p,A,l,h]},"Aptos.TransferTokens")}async*redeem(e,t,s=!0){const n=t.payload.token.chain===this.chain?await this.getTypeFromExternalAddress(t.payload.token.address.toString()):await this.getAssetFullyQualifiedType(t.payload.token);if(!n)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::complete_transfer::submit_vaa_and_register_entry`,typeArguments:[n],functionArguments:[r.serialize$1(t)]},"Aptos.CompleteTransfer")}async getAssetFullyQualifiedType(e){return e.chain===this.chain?i.isValidAptosType(e.address.toString())?e.address.toString():null:`${c.getForeignAssetAddress(this.chain,this.tokenBridgeAddress,e)}::coin::T`}async getTypeFromExternalAddress(e){try{const t=await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`}),{handle:s}=t.native_infos,n=await this.connection.getTableItem({handle:s,data:{key_type:`${this.tokenBridgeAddress}::token_hash::TokenHash`,value_type:"0x1::type_info::TypeInfo",key:{hash:e}}});return n?[n.account_address,String.fromCharCode(...r.hex.decode(n.module_name)),String.fromCharCode(...r.hex.decode(n.struct_name))].join(i.APTOS_SEPARATOR):null}catch{return null}}static getForeignAssetAddress(e,t,s){if(r.isNative(s.address))throw new Error("Invalid token address");const n=m({chain:s.chain,tokenBridgeAddress:new i.AptosAddress(t).toUniversalAddress(),tokenId:s.address.toUniversalAddress()});return r.hex.encode(r.sha3_256(n),!0)}createUnsignedTx(e,t,s=!1){return new w.AptosUnsignedTransaction(e,this.network,this.chain,t,s)}}r.registerProtocol("Aptos","TokenBridge",c);exports.AptosTokenBridge=c;